diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100755 index 0000000..6a780c4 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,3 @@ +# Contribution Guidelines + +Please submit all issues and pull requests to the [laravel/framework](http://github.com/laravel/framework) repository! diff --git a/app/commands/.gitkeep b/app/commands/.gitkeep new file mode 100755 index 0000000..e69de29 diff --git a/app/config/app.php b/app/config/app.php new file mode 100755 index 0000000..b54890a --- /dev/null +++ b/app/config/app.php @@ -0,0 +1,191 @@ + true, + + /* + |-------------------------------------------------------------------------- + | Application URL + |-------------------------------------------------------------------------- + | + | This URL is used by the console to properly generate URLs when using + | the Artisan command line tool. You should set this to the root of + | your application so that it is used when running Artisan tasks. + | + */ + + 'url' => 'http://localhost', + + /* + |-------------------------------------------------------------------------- + | Application Timezone + |-------------------------------------------------------------------------- + | + | Here you may specify the default timezone for your application, which + | will be used by the PHP date and date-time functions. We have gone + | ahead and set this to a sensible default for you out of the box. + | + */ + + 'timezone' => 'UTC', + + /* + |-------------------------------------------------------------------------- + | Application Locale Configuration + |-------------------------------------------------------------------------- + | + | The application locale determines the default locale that will be used + | by the translation service provider. You are free to set this value + | to any of the locales which will be supported by the application. + | + */ + + 'locale' => 'en', + + /* + |-------------------------------------------------------------------------- + | Application Fallback Locale + |-------------------------------------------------------------------------- + | + | The fallback locale determines the locale to use when the current one + | is not available. You may change the value to correspond to any of + | the language folders that are provided through your application. + | + */ + + 'fallback_locale' => 'en', + + /* + |-------------------------------------------------------------------------- + | Encryption Key + |-------------------------------------------------------------------------- + | + | This key is used by the Illuminate encrypter service and should be set + | to a random, 32 character string, otherwise these encrypted strings + | will not be safe. Please do this before deploying an application! + | + */ + + 'key' => 'yIqW9jqrcRHEzlFmg0tlESRxDUOKqdgB', + + /* + |-------------------------------------------------------------------------- + | Autoloaded Service Providers + |-------------------------------------------------------------------------- + | + | The service providers listed here will be automatically loaded on the + | request to your application. Feel free to add your own services to + | this array to grant expanded functionality to your applications. + | + */ + + 'providers' => array( + + 'Illuminate\Foundation\Providers\ArtisanServiceProvider', + 'Illuminate\Auth\AuthServiceProvider', + 'Illuminate\Cache\CacheServiceProvider', + 'Illuminate\Session\CommandsServiceProvider', + 'Illuminate\Foundation\Providers\ConsoleSupportServiceProvider', + 'Illuminate\Routing\ControllerServiceProvider', + 'Illuminate\Cookie\CookieServiceProvider', + 'Illuminate\Database\DatabaseServiceProvider', + 'Illuminate\Encryption\EncryptionServiceProvider', + 'Illuminate\Filesystem\FilesystemServiceProvider', + 'Illuminate\Hashing\HashServiceProvider', + 'Illuminate\Html\HtmlServiceProvider', + 'Illuminate\Log\LogServiceProvider', + 'Illuminate\Mail\MailServiceProvider', + 'Illuminate\Database\MigrationServiceProvider', + 'Illuminate\Pagination\PaginationServiceProvider', + 'Illuminate\Queue\QueueServiceProvider', + 'Illuminate\Redis\RedisServiceProvider', + 'Illuminate\Remote\RemoteServiceProvider', + 'Illuminate\Auth\Reminders\ReminderServiceProvider', + 'Illuminate\Database\SeedServiceProvider', + 'Illuminate\Session\SessionServiceProvider', + 'Illuminate\Translation\TranslationServiceProvider', + 'Illuminate\Validation\ValidationServiceProvider', + 'Illuminate\View\ViewServiceProvider', + 'Illuminate\Workbench\WorkbenchServiceProvider', + + ), + + /* + |-------------------------------------------------------------------------- + | Service Provider Manifest + |-------------------------------------------------------------------------- + | + | The service provider manifest is used by Laravel to lazy load service + | providers which are not needed for each request, as well to keep a + | list of all of the services. Here, you may set its storage spot. + | + */ + + 'manifest' => storage_path().'/meta', + + /* + |-------------------------------------------------------------------------- + | Class Aliases + |-------------------------------------------------------------------------- + | + | This array of class aliases will be registered when this application + | is started. However, feel free to register as many as you wish as + | the aliases are "lazy" loaded so they don't hinder performance. + | + */ + + 'aliases' => array( + + 'App' => 'Illuminate\Support\Facades\App', + 'Artisan' => 'Illuminate\Support\Facades\Artisan', + 'Auth' => 'Illuminate\Support\Facades\Auth', + 'Blade' => 'Illuminate\Support\Facades\Blade', + 'Cache' => 'Illuminate\Support\Facades\Cache', + 'ClassLoader' => 'Illuminate\Support\ClassLoader', + 'Config' => 'Illuminate\Support\Facades\Config', + 'Controller' => 'Illuminate\Routing\Controller', + 'Cookie' => 'Illuminate\Support\Facades\Cookie', + 'Crypt' => 'Illuminate\Support\Facades\Crypt', + 'DB' => 'Illuminate\Support\Facades\DB', + 'Eloquent' => 'Illuminate\Database\Eloquent\Model', + 'Event' => 'Illuminate\Support\Facades\Event', + 'File' => 'Illuminate\Support\Facades\File', + 'Form' => 'Illuminate\Support\Facades\Form', + 'Hash' => 'Illuminate\Support\Facades\Hash', + 'HTML' => 'Illuminate\Support\Facades\HTML', + 'Input' => 'Illuminate\Support\Facades\Input', + 'Lang' => 'Illuminate\Support\Facades\Lang', + 'Log' => 'Illuminate\Support\Facades\Log', + 'Mail' => 'Illuminate\Support\Facades\Mail', + 'Paginator' => 'Illuminate\Support\Facades\Paginator', + 'Password' => 'Illuminate\Support\Facades\Password', + 'Queue' => 'Illuminate\Support\Facades\Queue', + 'Redirect' => 'Illuminate\Support\Facades\Redirect', + 'Redis' => 'Illuminate\Support\Facades\Redis', + 'Request' => 'Illuminate\Support\Facades\Request', + 'Response' => 'Illuminate\Support\Facades\Response', + 'Route' => 'Illuminate\Support\Facades\Route', + 'Schema' => 'Illuminate\Support\Facades\Schema', + 'Seeder' => 'Illuminate\Database\Seeder', + 'Session' => 'Illuminate\Support\Facades\Session', + 'SSH' => 'Illuminate\Support\Facades\SSH', + 'Str' => 'Illuminate\Support\Str', + 'URL' => 'Illuminate\Support\Facades\URL', + 'Validator' => 'Illuminate\Support\Facades\Validator', + 'View' => 'Illuminate\Support\Facades\View', + + ), + +); diff --git a/app/config/auth.php b/app/config/auth.php new file mode 100755 index 0000000..eacbbfa --- /dev/null +++ b/app/config/auth.php @@ -0,0 +1,71 @@ + 'eloquent', + + /* + |-------------------------------------------------------------------------- + | Authentication Model + |-------------------------------------------------------------------------- + | + | When using the "Eloquent" authentication driver, we need to know which + | Eloquent model should be used to retrieve your users. Of course, it + | is often just the "User" model but you may use whatever you like. + | + */ + + 'model' => 'User', + + /* + |-------------------------------------------------------------------------- + | Authentication Table + |-------------------------------------------------------------------------- + | + | When using the "Database" authentication driver, we need to know which + | table should be used to retrieve your users. We have chosen a basic + | default value but you may easily change it to any table you like. + | + */ + + 'table' => 'users', + + /* + |-------------------------------------------------------------------------- + | Password Reminder Settings + |-------------------------------------------------------------------------- + | + | Here you may set the settings for password reminders, including a view + | that should be used as your password reminder e-mail. You will also + | be able to set the name of the table that holds the reset tokens. + | + | The "expire" time is the number of minutes that the reminder should be + | considered valid. This security feature keeps tokens short-lived so + | they have less time to be guessed. You may change this as needed. + | + */ + + 'reminder' => array( + + 'email' => 'emails.auth.reminder', + + 'table' => 'password_reminders', + + 'expire' => 60, + + ), + +); diff --git a/app/config/cache.php b/app/config/cache.php new file mode 100755 index 0000000..ce89842 --- /dev/null +++ b/app/config/cache.php @@ -0,0 +1,89 @@ + 'file', + + /* + |-------------------------------------------------------------------------- + | File Cache Location + |-------------------------------------------------------------------------- + | + | When using the "file" cache driver, we need a location where the cache + | files may be stored. A sensible default has been specified, but you + | are free to change it to any other place on disk that you desire. + | + */ + + 'path' => storage_path().'/cache', + + /* + |-------------------------------------------------------------------------- + | Database Cache Connection + |-------------------------------------------------------------------------- + | + | When using the "database" cache driver you may specify the connection + | that should be used to store the cached items. When this option is + | null the default database connection will be utilized for cache. + | + */ + + 'connection' => null, + + /* + |-------------------------------------------------------------------------- + | Database Cache Table + |-------------------------------------------------------------------------- + | + | When using the "database" cache driver we need to know the table that + | should be used to store the cached items. A default table name has + | been provided but you're free to change it however you deem fit. + | + */ + + 'table' => 'cache', + + /* + |-------------------------------------------------------------------------- + | Memcached Servers + |-------------------------------------------------------------------------- + | + | Now you may specify an array of your Memcached servers that should be + | used when utilizing the Memcached cache driver. All of the servers + | should contain a value for "host", "port", and "weight" options. + | + */ + + 'memcached' => array( + + array('host' => '127.0.0.1', 'port' => 11211, 'weight' => 100), + + ), + + /* + |-------------------------------------------------------------------------- + | Cache Key Prefix + |-------------------------------------------------------------------------- + | + | When utilizing a RAM based store such as APC or Memcached, there might + | be other applications utilizing the same cache. So, we'll specify a + | value to get prefixed to all our keys so we can avoid collisions. + | + */ + + 'prefix' => 'laravel', + +); diff --git a/app/config/compile.php b/app/config/compile.php new file mode 100755 index 0000000..d5e5518 --- /dev/null +++ b/app/config/compile.php @@ -0,0 +1,18 @@ + PDO::FETCH_CLASS, + + /* + |-------------------------------------------------------------------------- + | Default Database Connection Name + |-------------------------------------------------------------------------- + | + | Here you may specify which of the database connections below you wish + | to use as your default connection for all database work. Of course + | you may use many connections at once using the Database library. + | + */ + + 'default' => 'mysql', + + /* + |-------------------------------------------------------------------------- + | Database Connections + |-------------------------------------------------------------------------- + | + | Here are each of the database connections setup for your application. + | Of course, examples of configuring each database platform that is + | supported by Laravel is shown below to make development simple. + | + | + | All database work in Laravel is done through the PHP PDO facilities + | so make sure you have the driver for your particular database of + | choice installed on your machine before you begin development. + | + */ + + 'connections' => array( + + 'sqlite' => array( + 'driver' => 'sqlite', + 'database' => __DIR__.'/../database/production.sqlite', + 'prefix' => '', + ), + + 'mysql' => array( + 'driver' => 'mysql', + 'host' => 'localhost', + 'database' => 'mentors', + 'username' => 'root', + 'password' => 'kipsigei', + 'charset' => 'utf8', + 'collation' => 'utf8_unicode_ci', + 'prefix' => '', + ), + + 'pgsql' => array( + 'driver' => 'pgsql', + 'host' => 'localhost', + 'database' => 'database', + 'username' => 'root', + 'password' => '', + 'charset' => 'utf8', + 'prefix' => '', + 'schema' => 'public', + ), + + 'sqlsrv' => array( + 'driver' => 'sqlsrv', + 'host' => 'localhost', + 'database' => 'database', + 'username' => 'root', + 'password' => '', + 'prefix' => '', + ), + + ), + + /* + |-------------------------------------------------------------------------- + | Migration Repository Table + |-------------------------------------------------------------------------- + | + | This table keeps track of all the migrations that have already run for + | your application. Using this information, we can determine which of + | the migrations on disk haven't actually been run in the database. + | + */ + + 'migrations' => 'migrations', + + /* + |-------------------------------------------------------------------------- + | Redis Databases + |-------------------------------------------------------------------------- + | + | Redis is an open source, fast, and advanced key-value store that also + | provides a richer set of commands than a typical key-value systems + | such as APC or Memcached. Laravel makes it easy to dig right in. + | + */ + + 'redis' => array( + + 'cluster' => false, + + 'default' => array( + 'host' => '127.0.0.1', + 'port' => 6379, + 'database' => 0, + ), + + ), + +); diff --git a/app/config/mail.php b/app/config/mail.php new file mode 100755 index 0000000..41b4c4b --- /dev/null +++ b/app/config/mail.php @@ -0,0 +1,124 @@ + 'smtp', + + /* + |-------------------------------------------------------------------------- + | SMTP Host Address + |-------------------------------------------------------------------------- + | + | Here you may provide the host address of the SMTP server used by your + | applications. A default option is provided that is compatible with + | the Mailgun mail service which will provide reliable deliveries. + | + */ + + 'host' => 'smtp.mailgun.org', + + /* + |-------------------------------------------------------------------------- + | SMTP Host Port + |-------------------------------------------------------------------------- + | + | This is the SMTP port used by your application to delivery e-mails to + | users of your application. Like the host we have set this value to + | stay compatible with the Mailgun e-mail applications by default. + | + */ + + 'port' => 587, + + /* + |-------------------------------------------------------------------------- + | Global "From" Address + |-------------------------------------------------------------------------- + | + | You may wish for all e-mails sent by your application to be sent from + | the same address. Here, you may specify a name and address that is + | used globally for all e-mails that are sent by your application. + | + */ + + 'from' => array('address' => null, 'name' => null), + + /* + |-------------------------------------------------------------------------- + | E-Mail Encryption Protocol + |-------------------------------------------------------------------------- + | + | Here you may specify the encryption protocol that should be used when + | the application send e-mail messages. A sensible default using the + | transport layer security protocol should provide great security. + | + */ + + 'encryption' => 'tls', + + /* + |-------------------------------------------------------------------------- + | SMTP Server Username + |-------------------------------------------------------------------------- + | + | If your SMTP server requires a username for authentication, you should + | set it here. This will get used to authenticate with your server on + | connection. You may also set the "password" value below this one. + | + */ + + 'username' => null, + + /* + |-------------------------------------------------------------------------- + | SMTP Server Password + |-------------------------------------------------------------------------- + | + | Here you may set the password required by your SMTP server to send out + | messages from your application. This will be given to the server on + | connection so that the application will be able to send messages. + | + */ + + 'password' => null, + + /* + |-------------------------------------------------------------------------- + | Sendmail System Path + |-------------------------------------------------------------------------- + | + | When using the "sendmail" driver to send e-mails, we will need to know + | the path to where Sendmail lives on this server. A default path has + | been provided here, which will work well on most of your systems. + | + */ + + 'sendmail' => '/usr/sbin/sendmail -bs', + + /* + |-------------------------------------------------------------------------- + | Mail "Pretend" + |-------------------------------------------------------------------------- + | + | When this option is enabled, e-mail will not actually be sent over the + | web and will instead be written to your application's logs files so + | you may inspect the message. This is great for local development. + | + */ + + 'pretend' => false, + +); diff --git a/app/config/packages/.gitkeep b/app/config/packages/.gitkeep new file mode 100755 index 0000000..e69de29 diff --git a/app/config/queue.php b/app/config/queue.php new file mode 100755 index 0000000..6a879f7 --- /dev/null +++ b/app/config/queue.php @@ -0,0 +1,84 @@ + 'sync', + + /* + |-------------------------------------------------------------------------- + | Queue Connections + |-------------------------------------------------------------------------- + | + | Here you may configure the connection information for each server that + | is used by your application. A default configuration has been added + | for each back-end shipped with Laravel. You are free to add more. + | + */ + + 'connections' => array( + + 'sync' => array( + 'driver' => 'sync', + ), + + 'beanstalkd' => array( + 'driver' => 'beanstalkd', + 'host' => 'localhost', + 'queue' => 'default', + 'ttr' => 60, + ), + + 'sqs' => array( + 'driver' => 'sqs', + 'key' => 'your-public-key', + 'secret' => 'your-secret-key', + 'queue' => 'your-queue-url', + 'region' => 'us-east-1', + ), + + 'iron' => array( + 'driver' => 'iron', + 'host' => 'mq-aws-us-east-1.iron.io', + 'token' => 'your-token', + 'project' => 'your-project-id', + 'queue' => 'your-queue-name', + ), + + 'redis' => array( + 'driver' => 'redis', + 'queue' => 'default', + ), + + ), + + /* + |-------------------------------------------------------------------------- + | Failed Queue Jobs + |-------------------------------------------------------------------------- + | + | These options configure the behavior of failed queue job logging so you + | can control which database and table are used to store the jobs that + | have failed. You may change them to any database / table you wish. + | + */ + + 'failed' => array( + + 'database' => 'mysql', 'table' => 'failed_jobs', + + ), + +); diff --git a/app/config/remote.php b/app/config/remote.php new file mode 100755 index 0000000..2169c43 --- /dev/null +++ b/app/config/remote.php @@ -0,0 +1,59 @@ + 'production', + + /* + |-------------------------------------------------------------------------- + | Remote Server Connections + |-------------------------------------------------------------------------- + | + | These are the servers that will be accessible via the SSH task runner + | facilities of Laravel. This feature radically simplifies executing + | tasks on your servers, such as deploying out these applications. + | + */ + + 'connections' => array( + + 'production' => array( + 'host' => '', + 'username' => '', + 'password' => '', + 'key' => '', + 'keyphrase' => '', + 'root' => '/var/www', + ), + + ), + + /* + |-------------------------------------------------------------------------- + | Remote Server Groups + |-------------------------------------------------------------------------- + | + | Here you may list connections under a single group name, which allows + | you to easily access all of the servers at once using a short name + | that is extremely easy to remember, such as "web" or "database". + | + */ + + 'groups' => array( + + 'web' => array('production') + + ), + +); diff --git a/app/config/session.php b/app/config/session.php new file mode 100755 index 0000000..ae34302 --- /dev/null +++ b/app/config/session.php @@ -0,0 +1,140 @@ + 'file', + + /* + |-------------------------------------------------------------------------- + | Session Lifetime + |-------------------------------------------------------------------------- + | + | Here you may specify the number of minutes that you wish the session + | to be allowed to remain idle before it expires. If you want them + | to immediately expire on the browser closing, set that option. + | + */ + + 'lifetime' => 120, + + 'expire_on_close' => false, + + /* + |-------------------------------------------------------------------------- + | Session File Location + |-------------------------------------------------------------------------- + | + | When using the native session driver, we need a location where session + | files may be stored. A default has been set for you but a different + | location may be specified. This is only needed for file sessions. + | + */ + + 'files' => storage_path().'/sessions', + + /* + |-------------------------------------------------------------------------- + | Session Database Connection + |-------------------------------------------------------------------------- + | + | When using the "database" or "redis" session drivers, you may specify a + | connection that should be used to manage these sessions. This should + | correspond to a connection in your database configuration options. + | + */ + + 'connection' => null, + + /* + |-------------------------------------------------------------------------- + | Session Database Table + |-------------------------------------------------------------------------- + | + | When using the "database" session driver, you may specify the table we + | should use to manage the sessions. Of course, a sensible default is + | provided for you; however, you are free to change this as needed. + | + */ + + 'table' => 'sessions', + + /* + |-------------------------------------------------------------------------- + | Session Sweeping Lottery + |-------------------------------------------------------------------------- + | + | Some session drivers must manually sweep their storage location to get + | rid of old sessions from storage. Here are the chances that it will + | happen on a given request. By default, the odds are 2 out of 100. + | + */ + + 'lottery' => array(2, 100), + + /* + |-------------------------------------------------------------------------- + | Session Cookie Name + |-------------------------------------------------------------------------- + | + | Here you may change the name of the cookie used to identify a session + | instance by ID. The name specified here will get used every time a + | new session cookie is created by the framework for every driver. + | + */ + + 'cookie' => 'laravel_session', + + /* + |-------------------------------------------------------------------------- + | Session Cookie Path + |-------------------------------------------------------------------------- + | + | The session cookie path determines the path for which the cookie will + | be regarded as available. Typically, this will be the root path of + | your application but you are free to change this when necessary. + | + */ + + 'path' => '/', + + /* + |-------------------------------------------------------------------------- + | Session Cookie Domain + |-------------------------------------------------------------------------- + | + | Here you may change the domain of the cookie used to identify a session + | in your application. This will determine which domains the cookie is + | available to in your application. A sensible default has been set. + | + */ + + 'domain' => null, + + /* + |-------------------------------------------------------------------------- + | HTTPS Only Cookies + |-------------------------------------------------------------------------- + | + | By setting this option to true, session cookies will only be sent back + | to the server if the browser has a HTTPS connection. This will keep + | the cookie from being sent to you if it can not be done securely. + | + */ + + 'secure' => false, + +); diff --git a/app/config/testing/cache.php b/app/config/testing/cache.php new file mode 100755 index 0000000..66a8a39 --- /dev/null +++ b/app/config/testing/cache.php @@ -0,0 +1,20 @@ + 'array', + +); diff --git a/app/config/testing/session.php b/app/config/testing/session.php new file mode 100755 index 0000000..0364b63 --- /dev/null +++ b/app/config/testing/session.php @@ -0,0 +1,21 @@ + 'array', + +); diff --git a/app/config/view.php b/app/config/view.php new file mode 100755 index 0000000..34b8f38 --- /dev/null +++ b/app/config/view.php @@ -0,0 +1,31 @@ + array(__DIR__.'/../views'), + + /* + |-------------------------------------------------------------------------- + | Pagination View + |-------------------------------------------------------------------------- + | + | This view will be used to render the pagination link output, and can + | be easily customized here to show any view you like. A clean view + | compatible with Twitter's Bootstrap is given to you by default. + | + */ + + 'pagination' => 'pagination::slider-3', + +); diff --git a/app/config/workbench.php b/app/config/workbench.php new file mode 100755 index 0000000..87c5e38 --- /dev/null +++ b/app/config/workbench.php @@ -0,0 +1,31 @@ + '', + + /* + |-------------------------------------------------------------------------- + | Workbench Author E-Mail Address + |-------------------------------------------------------------------------- + | + | Like the option above, your e-mail address is used when generating new + | workbench packages. The e-mail is placed in your composer.json file + | automatically after the package is created by the workbench tool. + | + */ + + 'email' => '', + +); diff --git a/app/controllers/.gitkeep b/app/controllers/.gitkeep new file mode 100755 index 0000000..e69de29 diff --git a/app/controllers/BaseController.php b/app/controllers/BaseController.php new file mode 100755 index 0000000..2bee464 --- /dev/null +++ b/app/controllers/BaseController.php @@ -0,0 +1,18 @@ +layout)) + { + $this->layout = View::make($this->layout); + } + } + +} diff --git a/app/controllers/HomeController.php b/app/controllers/HomeController.php new file mode 100755 index 0000000..ede41a7 --- /dev/null +++ b/app/controllers/HomeController.php @@ -0,0 +1,23 @@ +call('UserTableSeeder'); + } + +} diff --git a/app/filters.php b/app/filters.php new file mode 100755 index 0000000..2a780f7 --- /dev/null +++ b/app/filters.php @@ -0,0 +1,80 @@ + '« Previous', + + 'next' => 'Next »', + +); diff --git a/app/lang/en/reminders.php b/app/lang/en/reminders.php new file mode 100755 index 0000000..e42148e --- /dev/null +++ b/app/lang/en/reminders.php @@ -0,0 +1,24 @@ + "Passwords must be at least six characters and match the confirmation.", + + "user" => "We can't find a user with that e-mail address.", + + "token" => "This password reset token is invalid.", + + "sent" => "Password reminder sent!", + +); diff --git a/app/lang/en/validation.php b/app/lang/en/validation.php new file mode 100755 index 0000000..b03b926 --- /dev/null +++ b/app/lang/en/validation.php @@ -0,0 +1,104 @@ + "The :attribute must be accepted.", + "active_url" => "The :attribute is not a valid URL.", + "after" => "The :attribute must be a date after :date.", + "alpha" => "The :attribute may only contain letters.", + "alpha_dash" => "The :attribute may only contain letters, numbers, and dashes.", + "alpha_num" => "The :attribute may only contain letters and numbers.", + "array" => "The :attribute must be an array.", + "before" => "The :attribute must be a date before :date.", + "between" => array( + "numeric" => "The :attribute must be between :min and :max.", + "file" => "The :attribute must be between :min and :max kilobytes.", + "string" => "The :attribute must be between :min and :max characters.", + "array" => "The :attribute must have between :min and :max items.", + ), + "confirmed" => "The :attribute confirmation does not match.", + "date" => "The :attribute is not a valid date.", + "date_format" => "The :attribute does not match the format :format.", + "different" => "The :attribute and :other must be different.", + "digits" => "The :attribute must be :digits digits.", + "digits_between" => "The :attribute must be between :min and :max digits.", + "email" => "The :attribute must be a valid email address.", + "exists" => "The selected :attribute is invalid.", + "image" => "The :attribute must be an image.", + "in" => "The selected :attribute is invalid.", + "integer" => "The :attribute must be an integer.", + "ip" => "The :attribute must be a valid IP address.", + "max" => array( + "numeric" => "The :attribute may not be greater than :max.", + "file" => "The :attribute may not be greater than :max kilobytes.", + "string" => "The :attribute may not be greater than :max characters.", + "array" => "The :attribute may not have more than :max items.", + ), + "mimes" => "The :attribute must be a file of type: :values.", + "min" => array( + "numeric" => "The :attribute must be at least :min.", + "file" => "The :attribute must be at least :min kilobytes.", + "string" => "The :attribute must be at least :min characters.", + "array" => "The :attribute must have at least :min items.", + ), + "not_in" => "The selected :attribute is invalid.", + "numeric" => "The :attribute must be a number.", + "regex" => "The :attribute format is invalid.", + "required" => "The :attribute field is required.", + "required_if" => "The :attribute field is required when :other is :value.", + "required_with" => "The :attribute field is required when :values is present.", + "required_with_all" => "The :attribute field is required when :values is present.", + "required_without" => "The :attribute field is required when :values is not present.", + "required_without_all" => "The :attribute field is required when none of :values are present.", + "same" => "The :attribute and :other must match.", + "size" => array( + "numeric" => "The :attribute must be :size.", + "file" => "The :attribute must be :size kilobytes.", + "string" => "The :attribute must be :size characters.", + "array" => "The :attribute must contain :size items.", + ), + "unique" => "The :attribute has already been taken.", + "url" => "The :attribute format is invalid.", + + /* + |-------------------------------------------------------------------------- + | Custom Validation Language Lines + |-------------------------------------------------------------------------- + | + | Here you may specify custom validation messages for attributes using the + | convention "attribute.rule" to name the lines. This makes it quick to + | specify a specific custom language line for a given attribute rule. + | + */ + + 'custom' => array( + 'attribute-name' => array( + 'rule-name' => 'custom-message', + ), + ), + + /* + |-------------------------------------------------------------------------- + | Custom Validation Attributes + |-------------------------------------------------------------------------- + | + | The following language lines are used to swap attribute place-holders + | with something more reader friendly such as E-Mail Address instead + | of "email". This simply helps us make messages a little cleaner. + | + */ + + 'attributes' => array(), + +); diff --git a/app/models/User.php b/app/models/User.php new file mode 100755 index 0000000..3232050 --- /dev/null +++ b/app/models/User.php @@ -0,0 +1,52 @@ +getKey(); + } + + /** + * Get the password for the user. + * + * @return string + */ + public function getAuthPassword() + { + return $this->password; + } + + /** + * Get the e-mail address where password reminders are sent. + * + * @return string + */ + public function getReminderEmail() + { + return $this->email; + } + +} diff --git a/app/routes.php b/app/routes.php new file mode 100755 index 0000000..e7d034f --- /dev/null +++ b/app/routes.php @@ -0,0 +1,22 @@ +client->request('GET', '/'); + + $this->assertTrue($this->client->getResponse()->isOk()); + } + +} diff --git a/app/tests/TestCase.php b/app/tests/TestCase.php new file mode 100755 index 0000000..d367fe5 --- /dev/null +++ b/app/tests/TestCase.php @@ -0,0 +1,19 @@ + + + + + + +

Password Reset

+ +
+ To reset your password, complete this form: {{ URL::to('password/reset', array($token)) }}. +
+ + diff --git a/app/views/hello.php b/app/views/hello.php new file mode 100755 index 0000000..aa8a311 --- /dev/null +++ b/app/views/hello.php @@ -0,0 +1,42 @@ + + + + + Laravel PHP Framework + + + +
+ Laravel PHP Framework +

You have arrived. and now you can do miracles

+
+ + diff --git a/artisan b/artisan new file mode 100755 index 0000000..5c408ad --- /dev/null +++ b/artisan @@ -0,0 +1,74 @@ +#!/usr/bin/env php +setRequestForConsoleEnvironment(); + +$artisan = Illuminate\Console\Application::start($app); + +/* +|-------------------------------------------------------------------------- +| Run The Artisan Application +|-------------------------------------------------------------------------- +| +| When we run the console application, the current CLI command will be +| executed in this console and the response sent back to a terminal +| or another output device for the developers. Here goes nothing! +| +*/ + +$status = $artisan->run(); + +/* +|-------------------------------------------------------------------------- +| Shutdown The Application +|-------------------------------------------------------------------------- +| +| Once Artisan has finished running. We will fire off the shutdown events +| so that any final work may be done by the application before we shut +| down the process. This is the last thing to happen to the request. +| +*/ + +$app->shutdown(); + +exit($status); diff --git a/bootstrap/autoload.php b/bootstrap/autoload.php new file mode 100755 index 0000000..6b32931 --- /dev/null +++ b/bootstrap/autoload.php @@ -0,0 +1,75 @@ + __DIR__.'/../app', + + /* + |-------------------------------------------------------------------------- + | Public Path + |-------------------------------------------------------------------------- + | + | The public path contains the assets for your web application, such as + | your JavaScript and CSS files, and also contains the primary entry + | point for web requests into these applications from the outside. + | + */ + + 'public' => __DIR__.'/../public', + + /* + |-------------------------------------------------------------------------- + | Base Path + |-------------------------------------------------------------------------- + | + | The base path is the root of the Laravel installation. Most likely you + | will not need to change this value. But, if for some wild reason it + | is necessary you will do so here, just proceed with some caution. + | + */ + + 'base' => __DIR__.'/..', + + /* + |-------------------------------------------------------------------------- + | Storage Path + |-------------------------------------------------------------------------- + | + | The storage path is used by Laravel to store cached Blade views, logs + | and other pieces of information. You may modify the path here when + | you want to change the location of this directory for your apps. + | + */ + + 'storage' => __DIR__.'/../app/storage', + +); diff --git a/bootstrap/start.php b/bootstrap/start.php new file mode 100755 index 0000000..a55def1 --- /dev/null +++ b/bootstrap/start.php @@ -0,0 +1,73 @@ +detectEnvironment(array( + + 'local' => array('your-machine-name'), + +)); + +/* +|-------------------------------------------------------------------------- +| Bind Paths +|-------------------------------------------------------------------------- +| +| Here we are binding the paths configured in paths.php to the app. You +| should not be changing these here. If you need to change these you +| may do so within the paths.php file and they will be bound here. +| +*/ + +$app->bindInstallPaths(require __DIR__.'/paths.php'); + +/* +|-------------------------------------------------------------------------- +| Load The Application +|-------------------------------------------------------------------------- +| +| Here we will load this Illuminate application. We will keep this in a +| separate location so we can isolate the creation of an application +| from the actual running of the application with a given request. +| +*/ + +$framework = $app['path.base']. + '/vendor/laravel/framework/src'; + +require $framework.'/Illuminate/Foundation/start.php'; + +/* +|-------------------------------------------------------------------------- +| Return The Application +|-------------------------------------------------------------------------- +| +| This script returns the application instance. The instance is given to +| the calling script so we can separate the building of the instances +| from the actual running of the application and sending responses. +| +*/ + +return $app; diff --git a/composer.json b/composer.json new file mode 100755 index 0000000..bb5662a --- /dev/null +++ b/composer.json @@ -0,0 +1,36 @@ +{ + "name": "laravel/laravel", + "description": "The Laravel Framework.", + "keywords": ["framework", "laravel"], + "license": "MIT", + "require": { + "laravel/framework": "4.1.*" + }, + "autoload": { + "classmap": [ + "app/commands", + "app/controllers", + "app/models", + "app/database/migrations", + "app/database/seeds", + "app/tests/TestCase.php" + ] + }, + "scripts": { + "post-install-cmd": [ + "php artisan clear-compiled", + "php artisan optimize" + ], + "post-update-cmd": [ + "php artisan clear-compiled", + "php artisan optimize" + ], + "post-create-project-cmd": [ + "php artisan key:generate" + ] + }, + "config": { + "preferred-install": "dist" + }, + "minimum-stability": "stable" +} diff --git a/composer.lock b/composer.lock new file mode 100755 index 0000000..76c9a88 --- /dev/null +++ b/composer.lock @@ -0,0 +1,1655 @@ +{ + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", + "This file is @generated automatically" + ], + "hash": "1629abbb640a9fe0280e95fc215de768", + "packages": [ + { + "name": "classpreloader/classpreloader", + "version": "1.0.2", + "source": { + "type": "git", + "url": "https://github.com/mtdowling/ClassPreloader.git", + "reference": "2c9f3bcbab329570c57339895bd11b5dd3b00877" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/mtdowling/ClassPreloader/zipball/2c9f3bcbab329570c57339895bd11b5dd3b00877", + "reference": "2c9f3bcbab329570c57339895bd11b5dd3b00877", + "shasum": "" + }, + "require": { + "nikic/php-parser": "~0.9", + "php": ">=5.3.3", + "symfony/console": "~2.1", + "symfony/filesystem": "~2.1", + "symfony/finder": "~2.1" + }, + "bin": [ + "classpreloader.php" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "autoload": { + "psr-0": { + "ClassPreloader": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Helps class loading performance by generating a single PHP file containing all of the autoloaded files for a specific use case", + "keywords": [ + "autoload", + "class", + "preload" + ], + "time": "2014-03-12 00:05:31" + }, + { + "name": "d11wtq/boris", + "version": "v1.0.8", + "source": { + "type": "git", + "url": "https://github.com/d11wtq/boris.git", + "reference": "125dd4e5752639af7678a22ea597115646d89c6e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/d11wtq/boris/zipball/125dd4e5752639af7678a22ea597115646d89c6e", + "reference": "125dd4e5752639af7678a22ea597115646d89c6e", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "suggest": { + "ext-pcntl": "*", + "ext-posix": "*", + "ext-readline": "*" + }, + "bin": [ + "bin/boris" + ], + "type": "library", + "autoload": { + "psr-0": { + "Boris": "lib" + } + }, + "notification-url": "https://packagist.org/downloads/", + "time": "2014-01-17 12:21:18" + }, + { + "name": "filp/whoops", + "version": "1.0.10", + "source": { + "type": "git", + "url": "https://github.com/filp/whoops.git", + "reference": "91e3fd4b0812017ffbeb24add55330664e1ea32a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/filp/whoops/zipball/91e3fd4b0812017ffbeb24add55330664e1ea32a", + "reference": "91e3fd4b0812017ffbeb24add55330664e1ea32a", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "require-dev": { + "mockery/mockery": "dev-master", + "silex/silex": "1.0.*@dev" + }, + "type": "library", + "autoload": { + "psr-0": { + "Whoops": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Filipe Dobreira", + "homepage": "https://github.com/filp", + "role": "Developer" + } + ], + "description": "php error handling for cool kids", + "homepage": "https://github.com/filp/whoops", + "keywords": [ + "error", + "exception", + "handling", + "library", + "silex-provider", + "whoops", + "zf2" + ], + "time": "2013-12-04 14:19:30" + }, + { + "name": "ircmaxell/password-compat", + "version": "1.0.3", + "source": { + "type": "git", + "url": "https://github.com/ircmaxell/password_compat.git", + "reference": "1fc1521b5e9794ea77e4eca30717be9635f1d4f4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/ircmaxell/password_compat/zipball/1fc1521b5e9794ea77e4eca30717be9635f1d4f4", + "reference": "1fc1521b5e9794ea77e4eca30717be9635f1d4f4", + "shasum": "" + }, + "type": "library", + "autoload": { + "files": [ + "lib/password.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Anthony Ferrara", + "email": "ircmaxell@php.net", + "homepage": "http://blog.ircmaxell.com" + } + ], + "description": "A compatibility library for the proposed simplified password hashing algorithm: https://wiki.php.net/rfc/password_hash", + "homepage": "https://github.com/ircmaxell/password_compat", + "keywords": [ + "hashing", + "password" + ], + "time": "2013-04-30 19:58:08" + }, + { + "name": "jeremeamia/SuperClosure", + "version": "1.0.1", + "source": { + "type": "git", + "url": "https://github.com/jeremeamia/super_closure.git", + "reference": "d05400085f7d4ae6f20ba30d36550836c0d061e8" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/jeremeamia/super_closure/zipball/d05400085f7d4ae6f20ba30d36550836c0d061e8", + "reference": "d05400085f7d4ae6f20ba30d36550836c0d061e8", + "shasum": "" + }, + "require": { + "nikic/php-parser": "~0.9", + "php": ">=5.3.3" + }, + "require-dev": { + "phpunit/phpunit": "~3.7" + }, + "type": "library", + "autoload": { + "psr-0": { + "Jeremeamia\\SuperClosure": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jeremy Lindblom" + } + ], + "description": "Doing interesting things with closures like serialization.", + "homepage": "https://github.com/jeremeamia/super_closure", + "keywords": [ + "closure", + "function", + "parser", + "serializable", + "serialize", + "tokenizer" + ], + "time": "2013-10-09 04:20:00" + }, + { + "name": "laravel/framework", + "version": "v4.1.30", + "source": { + "type": "git", + "url": "https://github.com/laravel/framework.git", + "reference": "1bbb6f16aa03c1de6d89ccbf4ca81bf98e1330ab" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/laravel/framework/zipball/1bbb6f16aa03c1de6d89ccbf4ca81bf98e1330ab", + "reference": "1bbb6f16aa03c1de6d89ccbf4ca81bf98e1330ab", + "shasum": "" + }, + "require": { + "classpreloader/classpreloader": "1.0.*", + "d11wtq/boris": "1.0.*", + "filp/whoops": "1.0.10", + "ircmaxell/password-compat": "1.0.*", + "jeremeamia/superclosure": "1.0.*", + "monolog/monolog": "1.*", + "nesbot/carbon": "1.*", + "patchwork/utf8": "1.1.*", + "php": ">=5.3.0", + "phpseclib/phpseclib": "0.3.*", + "predis/predis": "0.8.*", + "stack/builder": "1.0.*", + "swiftmailer/swiftmailer": "~5.0", + "symfony/browser-kit": "2.4.*", + "symfony/console": "2.4.*", + "symfony/css-selector": "2.4.*", + "symfony/debug": "2.4.*", + "symfony/dom-crawler": "2.4.*", + "symfony/finder": "2.4.*", + "symfony/http-foundation": "2.4.*", + "symfony/http-kernel": "2.4.*", + "symfony/process": "2.4.*", + "symfony/routing": "2.4.*", + "symfony/security-core": "2.4.*", + "symfony/translation": "2.4.*" + }, + "replace": { + "illuminate/auth": "self.version", + "illuminate/cache": "self.version", + "illuminate/config": "self.version", + "illuminate/console": "self.version", + "illuminate/container": "self.version", + "illuminate/cookie": "self.version", + "illuminate/database": "self.version", + "illuminate/encryption": "self.version", + "illuminate/events": "self.version", + "illuminate/exception": "self.version", + "illuminate/filesystem": "self.version", + "illuminate/foundation": "self.version", + "illuminate/hashing": "self.version", + "illuminate/html": "self.version", + "illuminate/http": "self.version", + "illuminate/log": "self.version", + "illuminate/mail": "self.version", + "illuminate/pagination": "self.version", + "illuminate/queue": "self.version", + "illuminate/redis": "self.version", + "illuminate/remote": "self.version", + "illuminate/routing": "self.version", + "illuminate/session": "self.version", + "illuminate/support": "self.version", + "illuminate/translation": "self.version", + "illuminate/validation": "self.version", + "illuminate/view": "self.version", + "illuminate/workbench": "self.version" + }, + "require-dev": { + "aws/aws-sdk-php": "2.6.*", + "iron-io/iron_mq": "1.5.*", + "mockery/mockery": "0.9.*", + "pda/pheanstalk": "2.1.*", + "phpunit/phpunit": "4.0.*" + }, + "suggest": { + "doctrine/dbal": "Allow renaming columns and dropping SQLite columns." + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.1-dev" + } + }, + "autoload": { + "classmap": [ + "src/Illuminate/Queue/IlluminateQueueClosure.php" + ], + "files": [ + "src/Illuminate/Support/helpers.php" + ], + "psr-0": { + "Illuminate": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Taylor Otwell", + "email": "taylorotwell@gmail.com", + "homepage": "https://github.com/taylorotwell", + "role": "Creator of Laravel" + } + ], + "description": "The Laravel Framework.", + "keywords": [ + "framework", + "laravel" + ], + "time": "2014-06-01 18:30:26" + }, + { + "name": "monolog/monolog", + "version": "1.9.1", + "source": { + "type": "git", + "url": "https://github.com/Seldaek/monolog.git", + "reference": "65026b610f8c19e61d7242f600530677b0466aac" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Seldaek/monolog/zipball/65026b610f8c19e61d7242f600530677b0466aac", + "reference": "65026b610f8c19e61d7242f600530677b0466aac", + "shasum": "" + }, + "require": { + "php": ">=5.3.0", + "psr/log": "~1.0" + }, + "require-dev": { + "aws/aws-sdk-php": "~2.4, >2.4.8", + "doctrine/couchdb": "~1.0@dev", + "graylog2/gelf-php": "~1.0", + "phpunit/phpunit": "~3.7.0", + "raven/raven": "~0.5", + "ruflin/elastica": "0.90.*" + }, + "suggest": { + "aws/aws-sdk-php": "Allow sending log messages to AWS services like DynamoDB", + "doctrine/couchdb": "Allow sending log messages to a CouchDB server", + "ext-amqp": "Allow sending log messages to an AMQP server (1.0+ required)", + "ext-mongo": "Allow sending log messages to a MongoDB server", + "graylog2/gelf-php": "Allow sending log messages to a GrayLog2 server", + "raven/raven": "Allow sending log messages to a Sentry server", + "rollbar/rollbar": "Allow sending log messages to Rollbar", + "ruflin/elastica": "Allow sending log messages to an Elastic Search server" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.9.x-dev" + } + }, + "autoload": { + "psr-4": { + "Monolog\\": "src/Monolog" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jordi Boggiano", + "email": "j.boggiano@seld.be", + "homepage": "http://seld.be", + "role": "Developer" + } + ], + "description": "Sends your logs to files, sockets, inboxes, databases and various web services", + "homepage": "http://github.com/Seldaek/monolog", + "keywords": [ + "log", + "logging", + "psr-3" + ], + "time": "2014-04-24 13:29:03" + }, + { + "name": "nesbot/carbon", + "version": "1.9.0", + "source": { + "type": "git", + "url": "https://github.com/briannesbitt/Carbon.git", + "reference": "b94de7192b01d0e80794eae984dcc773220ab0dc" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/b94de7192b01d0e80794eae984dcc773220ab0dc", + "reference": "b94de7192b01d0e80794eae984dcc773220ab0dc", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "require-dev": { + "phpunit/phpunit": "3.7.*" + }, + "type": "library", + "autoload": { + "psr-0": { + "Carbon": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Brian Nesbitt", + "email": "brian@nesbot.com", + "homepage": "http://nesbot.com" + } + ], + "description": "A simple API extension for DateTime.", + "homepage": "https://github.com/briannesbitt/Carbon", + "keywords": [ + "date", + "datetime", + "time" + ], + "time": "2014-05-13 02:29:30" + }, + { + "name": "nikic/php-parser", + "version": "v0.9.4", + "source": { + "type": "git", + "url": "https://github.com/nikic/PHP-Parser.git", + "reference": "1e5e280ae88a27effa2ae4aa2bd088494ed8594f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/1e5e280ae88a27effa2ae4aa2bd088494ed8594f", + "reference": "1e5e280ae88a27effa2ae4aa2bd088494ed8594f", + "shasum": "" + }, + "require": { + "php": ">=5.2" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "0.9-dev" + } + }, + "autoload": { + "psr-0": { + "PHPParser": "lib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Nikita Popov" + } + ], + "description": "A PHP parser written in PHP", + "keywords": [ + "parser", + "php" + ], + "time": "2013-08-25 17:11:40" + }, + { + "name": "patchwork/utf8", + "version": "v1.1.23", + "source": { + "type": "git", + "url": "https://github.com/nicolas-grekas/Patchwork-UTF8.git", + "reference": "c1edbc82aed49ff2bdef0a0f659bf69e3f7b14cc" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/nicolas-grekas/Patchwork-UTF8/zipball/c1edbc82aed49ff2bdef0a0f659bf69e3f7b14cc", + "reference": "c1edbc82aed49ff2bdef0a0f659bf69e3f7b14cc", + "shasum": "" + }, + "require": { + "lib-pcre": ">=7.3", + "php": ">=5.3.0" + }, + "suggest": { + "ext-iconv": "Use iconv for best performance", + "ext-intl": "Use Intl for best performance", + "ext-mbstring": "Use Mbstring for best performance" + }, + "type": "library", + "autoload": { + "psr-0": { + "Patchwork": "class/", + "Normalizer": "class/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "(Apache-2.0 or GPL-2.0)" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com", + "role": "Developer" + } + ], + "description": "Extensive, portable and performant handling of UTF-8 and grapheme clusters for PHP", + "homepage": "https://github.com/nicolas-grekas/Patchwork-UTF8", + "keywords": [ + "i18n", + "unicode", + "utf-8", + "utf8" + ], + "time": "2014-05-22 13:59:09" + }, + { + "name": "phpseclib/phpseclib", + "version": "0.3.6", + "source": { + "type": "git", + "url": "https://github.com/phpseclib/phpseclib.git", + "reference": "0ea31d9b65d49a8661e93bec19f44e989bd34c69" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpseclib/phpseclib/zipball/0ea31d9b65d49a8661e93bec19f44e989bd34c69", + "reference": "0ea31d9b65d49a8661e93bec19f44e989bd34c69", + "shasum": "" + }, + "require": { + "php": ">=5.0.0" + }, + "require-dev": { + "squizlabs/php_codesniffer": "1.*" + }, + "suggest": { + "ext-gmp": "Install the GMP (GNU Multiple Precision) extension in order to speed up arbitrary precision integer arithmetic operations.", + "ext-mcrypt": "Install the Mcrypt extension in order to speed up a wide variety of cryptographic operations.", + "pear-pear/PHP_Compat": "Install PHP_Compat to get phpseclib working on PHP < 4.3.3." + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "0.3-dev" + } + }, + "autoload": { + "psr-0": { + "Crypt": "phpseclib/", + "File": "phpseclib/", + "Math": "phpseclib/", + "Net": "phpseclib/", + "System": "phpseclib/" + }, + "files": [ + "phpseclib/Crypt/Random.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "include-path": [ + "phpseclib/" + ], + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jim Wigginton", + "email": "terrafrost@php.net", + "role": "Lead Developer" + }, + { + "name": "Patrick Monnerat", + "email": "pm@datasphere.ch", + "role": "Developer" + }, + { + "name": "Andreas Fischer", + "email": "bantu@phpbb.com", + "role": "Developer" + }, + { + "name": "Hans-Jürgen Petrich", + "email": "petrich@tronic-media.com", + "role": "Developer" + } + ], + "description": "PHP Secure Communications Library - Pure-PHP implementations of RSA, AES, SSH2, SFTP, X.509 etc.", + "homepage": "http://phpseclib.sourceforge.net", + "keywords": [ + "BigInteger", + "aes", + "asn.1", + "asn1", + "blowfish", + "crypto", + "cryptography", + "encryption", + "rsa", + "security", + "sftp", + "signature", + "signing", + "ssh", + "twofish", + "x.509", + "x509" + ], + "time": "2014-02-28 16:05:05" + }, + { + "name": "predis/predis", + "version": "v0.8.5", + "source": { + "type": "git", + "url": "https://github.com/nrk/predis.git", + "reference": "5f2eea628eb465d866ad2771927d83769c8f956c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/nrk/predis/zipball/5f2eea628eb465d866ad2771927d83769c8f956c", + "reference": "5f2eea628eb465d866ad2771927d83769c8f956c", + "shasum": "" + }, + "require": { + "php": ">=5.3.2" + }, + "suggest": { + "ext-curl": "Allows access to Webdis when paired with phpiredis", + "ext-phpiredis": "Allows faster serialization and deserialization of the Redis protocol" + }, + "type": "library", + "autoload": { + "psr-0": { + "Predis": "lib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Daniele Alessandri", + "email": "suppakilla@gmail.com", + "homepage": "http://clorophilla.net" + } + ], + "description": "Flexible and feature-complete PHP client library for Redis", + "homepage": "http://github.com/nrk/predis", + "keywords": [ + "nosql", + "predis", + "redis" + ], + "time": "2014-01-16 14:10:29" + }, + { + "name": "psr/log", + "version": "1.0.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/log.git", + "reference": "fe0936ee26643249e916849d48e3a51d5f5e278b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/log/zipball/fe0936ee26643249e916849d48e3a51d5f5e278b", + "reference": "fe0936ee26643249e916849d48e3a51d5f5e278b", + "shasum": "" + }, + "type": "library", + "autoload": { + "psr-0": { + "Psr\\Log\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common interface for logging libraries", + "keywords": [ + "log", + "psr", + "psr-3" + ], + "time": "2012-12-21 11:40:51" + }, + { + "name": "stack/builder", + "version": "v1.0.2", + "source": { + "type": "git", + "url": "https://github.com/stackphp/builder.git", + "reference": "b4af43e7b7f3f7fac919ff475b29f7c5dc7b23b7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/stackphp/builder/zipball/b4af43e7b7f3f7fac919ff475b29f7c5dc7b23b7", + "reference": "b4af43e7b7f3f7fac919ff475b29f7c5dc7b23b7", + "shasum": "" + }, + "require": { + "php": ">=5.3.0", + "symfony/http-foundation": "~2.1", + "symfony/http-kernel": "~2.1" + }, + "require-dev": { + "silex/silex": "~1.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "autoload": { + "psr-0": { + "Stack": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Igor Wiedler", + "email": "igor@wiedler.ch", + "homepage": "http://wiedler.ch/igor/" + } + ], + "description": "Builder for stack middlewares based on HttpKernelInterface.", + "keywords": [ + "stack" + ], + "time": "2014-01-28 19:42:24" + }, + { + "name": "swiftmailer/swiftmailer", + "version": "v5.2.0", + "source": { + "type": "git", + "url": "https://github.com/swiftmailer/swiftmailer.git", + "reference": "043e336b871f17a117f76ef8e190eddfc04c8d48" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/swiftmailer/swiftmailer/zipball/043e336b871f17a117f76ef8e190eddfc04c8d48", + "reference": "043e336b871f17a117f76ef8e190eddfc04c8d48", + "shasum": "" + }, + "require": { + "php": ">=5.2.4" + }, + "require-dev": { + "mockery/mockery": "~0.9.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "5.2-dev" + } + }, + "autoload": { + "files": [ + "lib/swift_required.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com", + "homepage": "http://fabien.potencier.org", + "role": "Lead Developer" + }, + { + "name": "Chris Corbyn" + } + ], + "description": "Swiftmailer, free feature-rich PHP mailer", + "homepage": "http://swiftmailer.org", + "keywords": [ + "mail", + "mailer" + ], + "time": "2014-05-08 08:11:19" + }, + { + "name": "symfony/browser-kit", + "version": "v2.4.6", + "target-dir": "Symfony/Component/BrowserKit", + "source": { + "type": "git", + "url": "https://github.com/symfony/BrowserKit.git", + "reference": "5c80003d5772de6120b5429f4b2f6e22957d4a07" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/BrowserKit/zipball/5c80003d5772de6120b5429f4b2f6e22957d4a07", + "reference": "5c80003d5772de6120b5429f4b2f6e22957d4a07", + "shasum": "" + }, + "require": { + "php": ">=5.3.3", + "symfony/dom-crawler": "~2.0" + }, + "require-dev": { + "symfony/css-selector": "~2.0", + "symfony/process": "~2.0" + }, + "suggest": { + "symfony/process": "" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.4-dev" + } + }, + "autoload": { + "psr-0": { + "Symfony\\Component\\BrowserKit\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com", + "homepage": "http://fabien.potencier.org", + "role": "Lead Developer" + }, + { + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + } + ], + "description": "Symfony BrowserKit Component", + "homepage": "http://symfony.com", + "time": "2014-05-12 09:27:48" + }, + { + "name": "symfony/console", + "version": "v2.4.6", + "target-dir": "Symfony/Component/Console", + "source": { + "type": "git", + "url": "https://github.com/symfony/Console.git", + "reference": "24f723436e62598c9dddee2a8573d6992504dc5d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/Console/zipball/24f723436e62598c9dddee2a8573d6992504dc5d", + "reference": "24f723436e62598c9dddee2a8573d6992504dc5d", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "symfony/event-dispatcher": "~2.1" + }, + "suggest": { + "symfony/event-dispatcher": "" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.4-dev" + } + }, + "autoload": { + "psr-0": { + "Symfony\\Component\\Console\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com", + "homepage": "http://fabien.potencier.org", + "role": "Lead Developer" + }, + { + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + } + ], + "description": "Symfony Console Component", + "homepage": "http://symfony.com", + "time": "2014-05-14 21:48:29" + }, + { + "name": "symfony/css-selector", + "version": "v2.4.6", + "target-dir": "Symfony/Component/CssSelector", + "source": { + "type": "git", + "url": "https://github.com/symfony/CssSelector.git", + "reference": "268d0a51166edaf84dfcf043c57f273685cb7c93" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/CssSelector/zipball/268d0a51166edaf84dfcf043c57f273685cb7c93", + "reference": "268d0a51166edaf84dfcf043c57f273685cb7c93", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.4-dev" + } + }, + "autoload": { + "psr-0": { + "Symfony\\Component\\CssSelector\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com", + "homepage": "http://fabien.potencier.org", + "role": "Lead Developer" + }, + { + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + }, + { + "name": "Jean-François Simon", + "email": "jeanfrancois.simon@sensiolabs.com" + } + ], + "description": "Symfony CssSelector Component", + "homepage": "http://symfony.com", + "time": "2014-05-12 09:27:48" + }, + { + "name": "symfony/debug", + "version": "v2.4.6", + "target-dir": "Symfony/Component/Debug", + "source": { + "type": "git", + "url": "https://github.com/symfony/Debug.git", + "reference": "6e721ae2cd7bde0f8dfa9c3186808a6c4140469c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/Debug/zipball/6e721ae2cd7bde0f8dfa9c3186808a6c4140469c", + "reference": "6e721ae2cd7bde0f8dfa9c3186808a6c4140469c", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "symfony/http-foundation": "~2.1", + "symfony/http-kernel": "~2.1" + }, + "suggest": { + "symfony/http-foundation": "", + "symfony/http-kernel": "" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.4-dev" + } + }, + "autoload": { + "psr-0": { + "Symfony\\Component\\Debug\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com", + "homepage": "http://fabien.potencier.org", + "role": "Lead Developer" + }, + { + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + } + ], + "description": "Symfony Debug Component", + "homepage": "http://symfony.com", + "time": "2014-04-30 06:22:28" + }, + { + "name": "symfony/dom-crawler", + "version": "v2.4.6", + "target-dir": "Symfony/Component/DomCrawler", + "source": { + "type": "git", + "url": "https://github.com/symfony/DomCrawler.git", + "reference": "77881ef11c064a490515a9fb1729b695c632ffe5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/DomCrawler/zipball/77881ef11c064a490515a9fb1729b695c632ffe5", + "reference": "77881ef11c064a490515a9fb1729b695c632ffe5", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "symfony/css-selector": "~2.0" + }, + "suggest": { + "symfony/css-selector": "" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.4-dev" + } + }, + "autoload": { + "psr-0": { + "Symfony\\Component\\DomCrawler\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com", + "homepage": "http://fabien.potencier.org", + "role": "Lead Developer" + }, + { + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + } + ], + "description": "Symfony DomCrawler Component", + "homepage": "http://symfony.com", + "time": "2014-05-31 02:02:48" + }, + { + "name": "symfony/event-dispatcher", + "version": "v2.5.0", + "target-dir": "Symfony/Component/EventDispatcher", + "source": { + "type": "git", + "url": "https://github.com/symfony/EventDispatcher.git", + "reference": "cb62ec8dd05893fc8e4f0e6e21e326e1fc731fe8" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/EventDispatcher/zipball/cb62ec8dd05893fc8e4f0e6e21e326e1fc731fe8", + "reference": "cb62ec8dd05893fc8e4f0e6e21e326e1fc731fe8", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "psr/log": "~1.0", + "symfony/config": "~2.0", + "symfony/dependency-injection": "~2.0", + "symfony/stopwatch": "~2.2" + }, + "suggest": { + "symfony/dependency-injection": "", + "symfony/http-kernel": "" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.5-dev" + } + }, + "autoload": { + "psr-0": { + "Symfony\\Component\\EventDispatcher\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com", + "homepage": "http://fabien.potencier.org", + "role": "Lead Developer" + }, + { + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + } + ], + "description": "Symfony EventDispatcher Component", + "homepage": "http://symfony.com", + "time": "2014-04-29 10:13:57" + }, + { + "name": "symfony/filesystem", + "version": "v2.5.0", + "target-dir": "Symfony/Component/Filesystem", + "source": { + "type": "git", + "url": "https://github.com/symfony/Filesystem.git", + "reference": "98e831eac836a0a5911626ce82684155f21d0e4d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/Filesystem/zipball/98e831eac836a0a5911626ce82684155f21d0e4d", + "reference": "98e831eac836a0a5911626ce82684155f21d0e4d", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.5-dev" + } + }, + "autoload": { + "psr-0": { + "Symfony\\Component\\Filesystem\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com", + "homepage": "http://fabien.potencier.org", + "role": "Lead Developer" + }, + { + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + } + ], + "description": "Symfony Filesystem Component", + "homepage": "http://symfony.com", + "time": "2014-04-16 10:36:21" + }, + { + "name": "symfony/finder", + "version": "v2.4.6", + "target-dir": "Symfony/Component/Finder", + "source": { + "type": "git", + "url": "https://github.com/symfony/Finder.git", + "reference": "46295af1b1e24304b35d5f20f1bf1ec0c2c4934a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/Finder/zipball/46295af1b1e24304b35d5f20f1bf1ec0c2c4934a", + "reference": "46295af1b1e24304b35d5f20f1bf1ec0c2c4934a", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.4-dev" + } + }, + "autoload": { + "psr-0": { + "Symfony\\Component\\Finder\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com", + "homepage": "http://fabien.potencier.org", + "role": "Lead Developer" + }, + { + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + } + ], + "description": "Symfony Finder Component", + "homepage": "http://symfony.com", + "time": "2014-05-22 13:46:01" + }, + { + "name": "symfony/http-foundation", + "version": "v2.4.6", + "target-dir": "Symfony/Component/HttpFoundation", + "source": { + "type": "git", + "url": "https://github.com/symfony/HttpFoundation.git", + "reference": "138498f3d64981cfafcb5eec3b2b96fce44a178e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/HttpFoundation/zipball/138498f3d64981cfafcb5eec3b2b96fce44a178e", + "reference": "138498f3d64981cfafcb5eec3b2b96fce44a178e", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "symfony/expression-language": "~2.4" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.4-dev" + } + }, + "autoload": { + "psr-0": { + "Symfony\\Component\\HttpFoundation\\": "" + }, + "classmap": [ + "Symfony/Component/HttpFoundation/Resources/stubs" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com", + "homepage": "http://fabien.potencier.org", + "role": "Lead Developer" + }, + { + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + } + ], + "description": "Symfony HttpFoundation Component", + "homepage": "http://symfony.com", + "time": "2014-05-22 16:21:00" + }, + { + "name": "symfony/http-kernel", + "version": "v2.4.6", + "target-dir": "Symfony/Component/HttpKernel", + "source": { + "type": "git", + "url": "https://github.com/symfony/HttpKernel.git", + "reference": "084a126a36ed011b098158d4d28daa9883ecc8f7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/HttpKernel/zipball/084a126a36ed011b098158d4d28daa9883ecc8f7", + "reference": "084a126a36ed011b098158d4d28daa9883ecc8f7", + "shasum": "" + }, + "require": { + "php": ">=5.3.3", + "psr/log": "~1.0", + "symfony/debug": "~2.3", + "symfony/event-dispatcher": "~2.1", + "symfony/http-foundation": "~2.4" + }, + "require-dev": { + "symfony/browser-kit": "~2.2", + "symfony/class-loader": "~2.1", + "symfony/config": "~2.0", + "symfony/console": "~2.2", + "symfony/dependency-injection": "~2.0", + "symfony/finder": "~2.0", + "symfony/process": "~2.0", + "symfony/routing": "~2.2", + "symfony/stopwatch": "~2.2", + "symfony/templating": "~2.2" + }, + "suggest": { + "symfony/browser-kit": "", + "symfony/class-loader": "", + "symfony/config": "", + "symfony/console": "", + "symfony/dependency-injection": "", + "symfony/finder": "" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.4-dev" + } + }, + "autoload": { + "psr-0": { + "Symfony\\Component\\HttpKernel\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com", + "homepage": "http://fabien.potencier.org", + "role": "Lead Developer" + }, + { + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + } + ], + "description": "Symfony HttpKernel Component", + "homepage": "http://symfony.com", + "time": "2014-05-31 18:42:13" + }, + { + "name": "symfony/process", + "version": "v2.4.6", + "target-dir": "Symfony/Component/Process", + "source": { + "type": "git", + "url": "https://github.com/symfony/Process.git", + "reference": "a7118cb290c62068b3c8ecfbf8b2eda8421fb841" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/Process/zipball/a7118cb290c62068b3c8ecfbf8b2eda8421fb841", + "reference": "a7118cb290c62068b3c8ecfbf8b2eda8421fb841", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.4-dev" + } + }, + "autoload": { + "psr-0": { + "Symfony\\Component\\Process\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com", + "homepage": "http://fabien.potencier.org", + "role": "Lead Developer" + }, + { + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + } + ], + "description": "Symfony Process Component", + "homepage": "http://symfony.com", + "time": "2014-05-22 13:46:01" + }, + { + "name": "symfony/routing", + "version": "v2.4.6", + "target-dir": "Symfony/Component/Routing", + "source": { + "type": "git", + "url": "https://github.com/symfony/Routing.git", + "reference": "74229f66e16bce6d2415ca44d4756f8e7ea880f8" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/Routing/zipball/74229f66e16bce6d2415ca44d4756f8e7ea880f8", + "reference": "74229f66e16bce6d2415ca44d4756f8e7ea880f8", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "doctrine/annotations": "~1.0", + "psr/log": "~1.0", + "symfony/config": "~2.2", + "symfony/expression-language": "~2.4", + "symfony/yaml": "~2.0" + }, + "suggest": { + "doctrine/annotations": "For using the annotation loader", + "symfony/config": "For using the all-in-one router or any loader", + "symfony/expression-language": "For using expression matching", + "symfony/yaml": "For using the YAML loader" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.4-dev" + } + }, + "autoload": { + "psr-0": { + "Symfony\\Component\\Routing\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com", + "homepage": "http://fabien.potencier.org", + "role": "Lead Developer" + }, + { + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + } + ], + "description": "Symfony Routing Component", + "homepage": "http://symfony.com", + "keywords": [ + "router", + "routing", + "uri", + "url" + ], + "time": "2014-04-23 14:04:21" + }, + { + "name": "symfony/security-core", + "version": "v2.4.6", + "target-dir": "Symfony/Component/Security/Core", + "source": { + "type": "git", + "url": "https://github.com/symfony/security-core.git", + "reference": "1fbe80d10b7a5bcb619abe3e4cfede795d9958dc" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/security-core/zipball/1fbe80d10b7a5bcb619abe3e4cfede795d9958dc", + "reference": "1fbe80d10b7a5bcb619abe3e4cfede795d9958dc", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "ircmaxell/password-compat": "1.0.*", + "psr/log": "~1.0", + "symfony/event-dispatcher": "~2.1", + "symfony/expression-language": "~2.4", + "symfony/http-foundation": "~2.4", + "symfony/validator": "~2.2" + }, + "suggest": { + "ircmaxell/password-compat": "For using the BCrypt password encoder in PHP <5.5", + "symfony/event-dispatcher": "", + "symfony/expression-language": "For using the expression voter", + "symfony/http-foundation": "", + "symfony/validator": "For using the user password constraint" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.4-dev" + } + }, + "autoload": { + "psr-0": { + "Symfony\\Component\\Security\\Core\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com", + "homepage": "http://fabien.potencier.org", + "role": "Lead Developer" + }, + { + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + } + ], + "description": "Symfony Security Component - Core Library", + "homepage": "http://symfony.com", + "time": "2014-04-23 14:04:21" + }, + { + "name": "symfony/translation", + "version": "v2.4.6", + "target-dir": "Symfony/Component/Translation", + "source": { + "type": "git", + "url": "https://github.com/symfony/Translation.git", + "reference": "9a3941444487ea57acd38f5c61bee1e0c3f69293" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/Translation/zipball/9a3941444487ea57acd38f5c61bee1e0c3f69293", + "reference": "9a3941444487ea57acd38f5c61bee1e0c3f69293", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "symfony/config": "~2.0", + "symfony/yaml": "~2.2" + }, + "suggest": { + "symfony/config": "", + "symfony/yaml": "" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.4-dev" + } + }, + "autoload": { + "psr-0": { + "Symfony\\Component\\Translation\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com", + "homepage": "http://fabien.potencier.org", + "role": "Lead Developer" + }, + { + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + } + ], + "description": "Symfony Translation Component", + "homepage": "http://symfony.com", + "time": "2014-05-22 13:46:01" + } + ], + "packages-dev": [ + + ], + "aliases": [ + + ], + "minimum-stability": "stable", + "stability-flags": [ + + ], + "platform": [ + + ], + "platform-dev": [ + + ] +} diff --git a/phpunit.xml b/phpunit.xml new file mode 100755 index 0000000..c330420 --- /dev/null +++ b/phpunit.xml @@ -0,0 +1,18 @@ + + + + + ./app/tests/ + + + diff --git a/public/.htaccess b/public/.htaccess new file mode 100755 index 0000000..77827ae --- /dev/null +++ b/public/.htaccess @@ -0,0 +1,15 @@ + + + Options -MultiViews + + + RewriteEngine On + + # Redirect Trailing Slashes... + RewriteRule ^(.*)/$ /$1 [L,R=301] + + # Handle Front Controller... + RewriteCond %{REQUEST_FILENAME} !-d + RewriteCond %{REQUEST_FILENAME} !-f + RewriteRule ^ index.php [L] + diff --git a/public/favicon.ico b/public/favicon.ico new file mode 100755 index 0000000..e69de29 diff --git a/public/index.php b/public/index.php new file mode 100755 index 0000000..f08822d --- /dev/null +++ b/public/index.php @@ -0,0 +1,49 @@ + + */ + +/* +|-------------------------------------------------------------------------- +| Register The Auto Loader +|-------------------------------------------------------------------------- +| +| Composer provides a convenient, automatically generated class loader +| for our application. We just need to utilize it! We'll require it +| into the script here so that we do not have to worry about the +| loading of any our classes "manually". Feels great to relax. +| +*/ + +require __DIR__.'/../bootstrap/autoload.php'; + +/* +|-------------------------------------------------------------------------- +| Turn On The Lights +|-------------------------------------------------------------------------- +| +| We need to illuminate PHP development, so let's turn on the lights. +| This bootstraps the framework and gets it ready for use, then it +| will load up this application so that we can run it and send +| the responses back to the browser and delight these users. +| +*/ + +$app = require_once __DIR__.'/../bootstrap/start.php'; + +/* +|-------------------------------------------------------------------------- +| Run The Application +|-------------------------------------------------------------------------- +| +| Once we have the application, we can simply call the run method, +| which will execute the request and send the response back to +| the client's browser allowing them to enjoy the creative +| and wonderful application we have whipped up for them. +| +*/ + +$app->run(); diff --git a/public/packages/.gitkeep b/public/packages/.gitkeep new file mode 100755 index 0000000..e69de29 diff --git a/public/robots.txt b/public/robots.txt new file mode 100755 index 0000000..eb05362 --- /dev/null +++ b/public/robots.txt @@ -0,0 +1,2 @@ +User-agent: * +Disallow: diff --git a/readme.md b/readme.md new file mode 100755 index 0000000..d113789 --- /dev/null +++ b/readme.md @@ -0,0 +1,21 @@ +## Laravel PHP Framework + +[![Latest Stable Version](https://poser.pugx.org/laravel/framework/version.png)](https://packagist.org/packages/laravel/framework) [![Total Downloads](https://poser.pugx.org/laravel/framework/d/total.png)](https://packagist.org/packages/laravel/framework) [![Build Status](https://travis-ci.org/laravel/framework.png)](https://travis-ci.org/laravel/framework) [![License](https://poser.pugx.org/laravel/framework/license.png)](https://packagist.org/packages/laravel/framework) + +Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable, creative experience to be truly fulfilling. Laravel attempts to take the pain out of development by easing common tasks used in the majority of web projects, such as authentication, routing, sessions, and caching. + +Laravel aims to make the development process a pleasing one for the developer without sacrificing application functionality. Happy developers make the best code. To this end, we've attempted to combine the very best of what we have seen in other web frameworks, including frameworks implemented in other languages, such as Ruby on Rails, ASP.NET MVC, and Sinatra. + +Laravel is accessible, yet powerful, providing powerful tools needed for large, robust applications. A superb inversion of control container, expressive migration system, and tightly integrated unit testing support give you the tools you need to build any application with which you are tasked. + +## Official Documentation + +Documentation for the entire framework can be found on the [Laravel website](http://laravel.com/docs). + +### Contributing To Laravel + +**All issues and pull requests should be filed on the [laravel/framework](http://github.com/laravel/framework) repository.** + +### License + +The Laravel framework is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT) diff --git a/server.php b/server.php new file mode 100755 index 0000000..5f187f3 --- /dev/null +++ b/server.php @@ -0,0 +1,19 @@ + and contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. \ No newline at end of file diff --git a/vendor/classpreloader/classpreloader/README.md b/vendor/classpreloader/classpreloader/README.md new file mode 100755 index 0000000..8a1eba2 --- /dev/null +++ b/vendor/classpreloader/classpreloader/README.md @@ -0,0 +1,108 @@ +Class Preloader for PHP +======================= + +This tool is used to generate a single PHP script containing all of the classes +required for a specific use case. Using a single compiled PHP script instead of relying on autoloading can help to improve the performance of specific use cases. For example, if your application executes the same bootstrap code on every request, then you could generate a preloader (the compiled output of this tool) to reduce the cost of autoloading the required classes over and over. + +What it actually does +--------------------- + +This tool listens for each file that is autoloaded, creates a list of files, traverses the parsed PHP file using [PHPParser](https://github.com/nikic/PHP-Parser) and any visitors of a Config object, wraps the code of each file in a namespace block if necessary, and writes the contents of every autoloaded file (in order) to a single PHP file. + +Notice +------ + +This tool should only be used for specific use cases. There is a tradeoff between preloading classes and autoloading classes. The point at which it is no longer beneficial to generate a preloader is application specific. You'll need to perform your own benchmarks to determine if this tool will speed up your application. + +Installation +------------ + +Add the ClassPreloader as a dependency to your composer.json file: + +```javascript +{ + "require": { + "classpreloader/classpreloader": "1.0.*" + }, + "config": { + "bin-dir": "bin" + } +} +``` + +Using the tool +-------------- + +You use the bin/classpreloader.php compile command with a few command line flags to generate a preloader. + +`--config`: A CSV containing a list of files to combine into a classmap, or the full path to a PHP script that returns an array of classes or a `\ClassPreloader\Config` object. + +`--output`: The path to the file to store the compiled PHP code. If the directory does not exist, the tool will attempt to create it. + +`--fix_dir`: (defaults to 1) Set to 0 to not replace "__DIR__" constants with the actual directory of the original file. + +`--fix_file`: (defaults to 1) Set to 0 to not replace "__FILE__" constants with the actual location of the original file. + +Writing a config file +--------------------- + +Creating a PHP based configuration file is fairly simple. Just include the vendor/classpreloader/classpreloader/src/ClassPreloader/ClassLoader.php file and call the `ClassLoader::getIncludes()` method, passing a function as the only argument. This function should accept a `ClassLoader` object and register the passed in object's autoloader using `$loader->register()`. It is important to register the `ClassLoader` autoloader after all other autoloaders are registered. + +An array or `\ClassPreloader\Config` must be returned from the config file. You can attach custom node visitors if you need to perform any sort of translation on each matching file before writing it to the output. + +```php +register(); + $aws = Aws\Common\Aws::factory(array( + 'key' => '***', + 'secret' => '***', + 'region' => 'us-east-1' + )); + $client = $aws->get('dynamodb'); + $client->listTables()->getAll(); +}); + +// Add a regex filter that requires all classes to match the regex +// $config->addInclusiveFilter('/Foo/'); + +// Add a regex filter that requires that a class does not match the filter +// $config->addExclusiveFilter('/Foo/'); + +return $config; +``` + +You would then run the classpreloader.php script and pass in the full path to the above PHP script. + +`php bin/classpreloader.php compile --config="/path/to/the_example.php" --output="/tmp/preloader.php"` + +The above command will create a file in /tmp/preloader.php that contains every file that was autoloaded while running the snippet of code in the anonymous function. You would generate this file and include it in your production script. + +Automating the process with Composer +------------------------------------ + +You can automate the process of creating preloaders using Composer's script functionality. For example, if you wanted to automatically create a preloader each time the AWS SDK for PHP is installed, you could define a script like the following in your composer.json file: + +```javascript +{ + "require": { + "classpreloader/classpreloader": "1.0.*" + }, + "scripts": { + "post-autoload-dump": "php bin/classpreloader.php compile --config=/path/to/the_example.php --output=/path/to/preload.php" + }, + "config": { + "bin-dir": "bin" + } +} +``` + +Using the above composer.json file, each time the project's autoloader is recreated using the install or update command, the classpreloader.php file will be executed. This script would generate a preload.php containing the classes required to run the previously demonstrated "the_example.php" configuration file. diff --git a/vendor/classpreloader/classpreloader/classpreloader.php b/vendor/classpreloader/classpreloader/classpreloader.php new file mode 100755 index 0000000..5dc4da1 --- /dev/null +++ b/vendor/classpreloader/classpreloader/classpreloader.php @@ -0,0 +1,10 @@ +#! /usr/bin/env php +run(); diff --git a/vendor/classpreloader/classpreloader/composer.json b/vendor/classpreloader/classpreloader/composer.json new file mode 100755 index 0000000..6d2a4bc --- /dev/null +++ b/vendor/classpreloader/classpreloader/composer.json @@ -0,0 +1,28 @@ +{ + "name": "classpreloader/classpreloader", + "description":"Helps class loading performance by generating a single PHP file containing all of the autoloaded files for a specific use case", + "keywords":["autoload","class","preload"], + "license":"MIT", + + "require":{ + "php": ">=5.3.3", + "symfony/console": "~2.1", + "symfony/filesystem": "~2.1", + "symfony/finder": "~2.1", + "nikic/php-parser": "~0.9" + }, + + "autoload": { + "psr-0": { + "ClassPreloader": "src/" + } + }, + + "bin": ["classpreloader.php"], + + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + } +} diff --git a/vendor/classpreloader/classpreloader/src/ClassPreloader/Application.php b/vendor/classpreloader/classpreloader/src/ClassPreloader/Application.php new file mode 100755 index 0000000..9e75916 --- /dev/null +++ b/vendor/classpreloader/classpreloader/src/ClassPreloader/Application.php @@ -0,0 +1,33 @@ +files() + ->in(__DIR__ . '/Command') + ->notName('Abstract*') + ->name('*.php'); + + // Add each command to the CLI + foreach ($finder as $file) { + $filename = str_replace('\\', '/', $file->getRealpath()); + $pos = strrpos($filename, '/ClassPreloader/') + strlen('/ClassPreloader/'); + $class = __NAMESPACE__ . '\\' + . substr(str_replace('/', '\\', substr($filename, $pos)), 0, -4); + $this->add(new $class()); + } + } +} diff --git a/vendor/classpreloader/classpreloader/src/ClassPreloader/ClassList.php b/vendor/classpreloader/classpreloader/src/ClassPreloader/ClassList.php new file mode 100755 index 0000000..aaea2b5 --- /dev/null +++ b/vendor/classpreloader/classpreloader/src/ClassPreloader/ClassList.php @@ -0,0 +1,87 @@ +clear(); + } + + /** + * Clear the contents of the list and reset the head node and current node + */ + public function clear() + { + $this->head = new ClassNode(null); + $this->current = $this->head; + } + + /** + * Traverse to the next node in the list + */ + public function next() + { + if (isset($this->current->next)) { + $this->current = $this->current->next; + } else { + $this->current->next = new ClassNode(null, $this->current); + $this->current = $this->current->next; + } + } + + /** + * Insert a value at the current position in the list. Any currently set + * value at this position will be pushed back in the list after the new + * value + * + * @param mixed $value Value to insert + */ + public function push($value) + { + if (!$this->current->value) { + $this->current->value = $value; + } else { + $temp = $this->current; + $this->current = new ClassNode($value, $temp->prev); + $this->current->next = $temp; + $temp->prev = $this->current; + if ($temp === $this->head) { + $this->head = $this->current; + } else { + $this->current->prev->next = $this->current; + } + } + } + + /** + * Traverse the ClassList and return a list of classes + * + * @return array + */ + public function getClasses() + { + $classes = array(); + $current = $this->head; + while ($current && $current->value) { + $classes[] = $current->value; + $current = $current->next; + } + + return array_filter($classes); + } +} diff --git a/vendor/classpreloader/classpreloader/src/ClassPreloader/ClassLoader.php b/vendor/classpreloader/classpreloader/src/ClassPreloader/ClassLoader.php new file mode 100755 index 0000000..55c7891 --- /dev/null +++ b/vendor/classpreloader/classpreloader/src/ClassPreloader/ClassLoader.php @@ -0,0 +1,110 @@ +classList = new ClassList(); + } + + /** + * Wrap a block of code in the autoloader and get a list of loaded classes + * + * @param \Callable $func Callable function + * + * @return Config + */ + public static function getIncludes($func) + { + $loader = new self(); + call_user_func($func, $loader); + $loader->unregister(); + + $config = new Config(); + foreach ($loader->getFilenames() as $file) { + $config->addFile($file); + } + + return $config; + } + + /** + * Registers this instance as an autoloader. + */ + public function register() + { + spl_autoload_register(array($this, 'loadClass'), true, true); + } + + /** + * Unregisters this instance as an autoloader. + */ + public function unregister() + { + spl_autoload_unregister(array($this, 'loadClass')); + } + + /** + * Loads the given class or interface. + * + * @param string $class The name of the class + * @return bool|null True, if loaded + */ + public function loadClass($class) + { + foreach (spl_autoload_functions() as $func) { + if (is_array($func) && $func[0] === $this) { + continue; + } + $this->classList->push($class); + if (call_user_func($func, $class)) { + break; + } + } + + $this->classList->next(); + + return true; + } + + /** + * Get an array of loaded file names in order of loading + * + * @return array + */ + public function getFilenames() + { + $files = array(); + foreach ($this->classList->getClasses() as $class) { + // Push interfaces before classes if not already loaded + $r = new \ReflectionClass($class); + foreach ($r->getInterfaces() as $inf) { + $name = $inf->getFileName(); + if ($name && !in_array($name, $files)) { + $files[] = $name; + } + } + $files[] = $r->getFileName(); + } + + return $files; + } +} diff --git a/vendor/classpreloader/classpreloader/src/ClassPreloader/ClassNode.php b/vendor/classpreloader/classpreloader/src/ClassPreloader/ClassNode.php new file mode 100755 index 0000000..78abb28 --- /dev/null +++ b/vendor/classpreloader/classpreloader/src/ClassPreloader/ClassNode.php @@ -0,0 +1,36 @@ +value = $value; + $this->prev = $prev; + } +} diff --git a/vendor/classpreloader/classpreloader/src/ClassPreloader/Command/PreCompileCommand.php b/vendor/classpreloader/classpreloader/src/ClassPreloader/Command/PreCompileCommand.php new file mode 100755 index 0000000..b49e3e6 --- /dev/null +++ b/vendor/classpreloader/classpreloader/src/ClassPreloader/Command/PreCompileCommand.php @@ -0,0 +1,216 @@ +printer = new \PHPParser_PrettyPrinter_Zend(); + $this->parser = new \PHPParser_Parser(new \PHPParser_Lexer()); + } + + /** + * {@inheritdoc} + */ + protected function configure() + { + parent::configure(); + + $this->setName('compile') + ->setDescription('Compiles classes into a single file') + ->addOption('config', null, InputOption::VALUE_REQUIRED, 'CSV of filenames to load, or the path to a PHP script that returns an array of file names') + ->addOption('output', null, InputOption::VALUE_REQUIRED) + ->addOption('fix_dir', null, InputOption::VALUE_REQUIRED, 'Convert __DIR__ constants to the original directory of a file', 1) + ->addOption('fix_file', null, InputOption::VALUE_REQUIRED, 'Convert __FILE__ constants to the original path of a file', 1) + ->addOption('strip_comments', null, InputOption::VALUE_REQUIRED, 'Set to 1 to strip comments from each source file', 0) + ->setHelp(<<%command.name% command iterates over each script, normalizes +the file to be wrapped in namespaces, and combines each file into a single PHP +file. +EOF + ); + } + + /** + * Get the node traverser used by the command + * + * @return NodeTraverser + */ + protected function getTraverser() + { + if (!$this->traverser) { + $this->traverser = new NodeTraverser(); + if ($this->input->getOption('fix_dir')) { + $this->traverser->addVisitor(new DirVisitor()); + } + if ($this->input->getOption('fix_file')) { + $this->traverser->addVisitor(new FileVisitor()); + } + } + + return $this->traverser; + } + + /** + * Get a pretty printed string of code from a file while applying visitors + * + * @param string $file Name of the file to get code from + * + * @return string + * @throws \RuntimeException + */ + protected function getCode($file) + { + if (!is_readable($file)) { + throw new \RuntimeException("Cannot open {$file} for reading"); + } + + if ($this->input->getOption('strip_comments')) { + $content = php_strip_whitespace($file); + } else { + $content = file_get_contents($file); + } + + $stmts = $this->getTraverser() + ->traverseFile($this->parser->parse($content), $file); + $pretty = $this->printer->prettyPrint($stmts); + + // Remove the open PHP tag + if (substr($pretty, 6) == "input->getOption('output')) { + throw new \InvalidArgumentException('An output option is required'); + } + + if (!$this->input->getOption('config')) { + throw new \InvalidArgumentException('A config option is required'); + } + } + + /** + * Get a list of files in order + * + * @param mixed $config Configuration option + * + * @return array + * @throws \InvalidArgumentException + */ + protected function getFileList($config) + { + $this->output->writeln('> Loading configuration file'); + $filesystem = new Filesystem(); + + if (strpos($config, ',')) { + return array_filter(explode(',', $config)); + } + + // Ensure absolute paths are resolved + if (!$filesystem->isAbsolutePath($config)) { + $config = getcwd() . '/' . $config; + } + + // Ensure that the config file exists + if (!file_exists($config)) { + throw new \InvalidArgumentException(sprintf('Configuration file "%s" does not exist.', $config)); + } + + $result = require $config; + + if ($result instanceof Config) { + foreach ($result->getVisitors() as $visitor) { + $this->getTraverser()->addVisitor($visitor); + } + + return $result; + } elseif (is_array($result)) { + return $result; + } + + throw new \InvalidArgumentException( + 'Config must return an array of filenames or a Config object' + ); + } + + /** + * Prepare the output file and directory + * + * @param string $outputFile The full path to the output file + * + * @throws \RuntimeException + */ + protected function prepareOutput($outputFile) + { + $dir = dirname($outputFile); + if (!is_dir($dir) && !mkdir($dir, 0777, true)) { + throw new \RuntimeException('Unable to create directory ' . $dir); + } + } + + /** + * {@inheritdoc} + */ + protected function execute(InputInterface $input, OutputInterface $output) + { + $this->input = $input; + $this->output = $output; + $this->validateCommand(); + $outputFile = $this->input->getOption('output'); + $config = $this->input->getOption('config'); + $files = $this->getFileList($config); + $output->writeLn('- Found ' . count($files) . ' files'); + + // Make sure that the output dir can be used or create it + $this->prepareOutput($outputFile); + + if (!$handle = fopen($input->getOption('output'), 'w')) { + throw new \RuntimeException( + "Unable to open {$outputFile} for writing" + ); + } + + // Write the first line of the output + fwrite($handle, "writeln('> Compiling classes'); + foreach ($files as $file) { + $this->output->writeln('- Writing ' . $file); + fwrite($handle, $this->getCode($file) . "\n"); + } + fclose($handle); + + $output->writeln("> Compiled loader written to {$outputFile}"); + $output->writeln('- ' . (round(filesize($outputFile) / 1024)) . ' kb'); + } +} diff --git a/vendor/classpreloader/classpreloader/src/ClassPreloader/Config.php b/vendor/classpreloader/classpreloader/src/ClassPreloader/Config.php new file mode 100755 index 0000000..30d815c --- /dev/null +++ b/vendor/classpreloader/classpreloader/src/ClassPreloader/Config.php @@ -0,0 +1,133 @@ +filenames[] = $filename; + + return $this; + } + + /** + * Get an array of file names that satisfy any added filters + * + * @return array + */ + public function getFilenames() + { + $filenames = array(); + foreach ($this->filenames as $f) { + foreach ($this->inclusiveFilters as $filter) { + if (!preg_match($filter, $f)) { + continue 2; + } + } + foreach ($this->exclusiveFilters as $filter) { + if (preg_match($filter, $f)) { + continue 2; + } + } + $filenames[] = $f; + } + + return $filenames; + } + + /** + * Get an iterator for the filenames + * + * @return \ArrayIterator + */ + public function getIterator() + { + return new \ArrayIterator($this->getFilenames()); + } + + /** + * Add a filter used to filter out classes matching a specific pattern + * + * @param string $pattern Regular expression pattern + * + * @return self + */ + public function addExclusiveFilter($pattern) + { + $this->exclusiveFilters[] = $pattern; + + return $this; + } + + /** + * Add a filter used to grab only file names matching the pattern + * + * @param string $pattern Regular expression pattern + * + * @return self + */ + public function addInclusiveFilter($pattern) + { + $this->inclusiveFilters[] = $pattern; + + return $this; + } + + /** + * Add a visitor that will visit each node when traversing the node list + * of each file. + * + * @param AbstractNodeVisitor $visitor Node visitor + * + * @return self + */ + public function addVisitor(AbstractNodeVisitor $visitor) + { + $this->visitors[] = $visitor; + + return $this; + } + + /** + * Get an array of node visitors + * + * @return array + */ + public function getVisitors() + { + return $this->visitors; + } +} diff --git a/vendor/classpreloader/classpreloader/src/ClassPreloader/Parser/AbstractNodeVisitor.php b/vendor/classpreloader/classpreloader/src/ClassPreloader/Parser/AbstractNodeVisitor.php new file mode 100755 index 0000000..cd05ab9 --- /dev/null +++ b/vendor/classpreloader/classpreloader/src/ClassPreloader/Parser/AbstractNodeVisitor.php @@ -0,0 +1,48 @@ +filename = $filename; + + return $this; + } + + /** + * Get the full path to the current file being parsed + * + * @return string + */ + public function getFilename() + { + return $this->filename; + } + + /** + * Get the directory of the current file being parsed + * + * @return string + */ + public function getDir() + { + return dirname($this->getFilename()); + } +} diff --git a/vendor/classpreloader/classpreloader/src/ClassPreloader/Parser/DirVisitor.php b/vendor/classpreloader/classpreloader/src/ClassPreloader/Parser/DirVisitor.php new file mode 100755 index 0000000..24dba9e --- /dev/null +++ b/vendor/classpreloader/classpreloader/src/ClassPreloader/Parser/DirVisitor.php @@ -0,0 +1,16 @@ +getDir()); + } + } +} diff --git a/vendor/classpreloader/classpreloader/src/ClassPreloader/Parser/FileVisitor.php b/vendor/classpreloader/classpreloader/src/ClassPreloader/Parser/FileVisitor.php new file mode 100755 index 0000000..bd0ed61 --- /dev/null +++ b/vendor/classpreloader/classpreloader/src/ClassPreloader/Parser/FileVisitor.php @@ -0,0 +1,16 @@ +getFilename()); + } + } +} diff --git a/vendor/classpreloader/classpreloader/src/ClassPreloader/Parser/NodeTraverser.php b/vendor/classpreloader/classpreloader/src/ClassPreloader/Parser/NodeTraverser.php new file mode 100755 index 0000000..960988a --- /dev/null +++ b/vendor/classpreloader/classpreloader/src/ClassPreloader/Parser/NodeTraverser.php @@ -0,0 +1,21 @@ +visitors as $visitor) { + if ($visitor instanceof AbstractNodeVisitor) { + $visitor->setFilename($filename); + } + } + + return $this->traverse($nodes); + } +} diff --git a/vendor/composer/ClassLoader.php b/vendor/composer/ClassLoader.php new file mode 100755 index 0000000..a710555 --- /dev/null +++ b/vendor/composer/ClassLoader.php @@ -0,0 +1,378 @@ + + * Jordi Boggiano + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Composer\Autoload; + +/** + * ClassLoader implements a PSR-0 class loader + * + * See https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-0.md + * + * $loader = new \Composer\Autoload\ClassLoader(); + * + * // register classes with namespaces + * $loader->add('Symfony\Component', __DIR__.'/component'); + * $loader->add('Symfony', __DIR__.'/framework'); + * + * // activate the autoloader + * $loader->register(); + * + * // to enable searching the include path (eg. for PEAR packages) + * $loader->setUseIncludePath(true); + * + * In this example, if you try to use a class in the Symfony\Component + * namespace or one of its children (Symfony\Component\Console for instance), + * the autoloader will first look for the class under the component/ + * directory, and it will then fallback to the framework/ directory if not + * found before giving up. + * + * This class is loosely based on the Symfony UniversalClassLoader. + * + * @author Fabien Potencier + * @author Jordi Boggiano + */ +class ClassLoader +{ + // PSR-4 + private $prefixLengthsPsr4 = array(); + private $prefixDirsPsr4 = array(); + private $fallbackDirsPsr4 = array(); + + // PSR-0 + private $prefixesPsr0 = array(); + private $fallbackDirsPsr0 = array(); + + private $useIncludePath = false; + private $classMap = array(); + + public function getPrefixes() + { + return call_user_func_array('array_merge', $this->prefixesPsr0); + } + + public function getPrefixesPsr4() + { + return $this->prefixDirsPsr4; + } + + public function getFallbackDirs() + { + return $this->fallbackDirsPsr0; + } + + public function getFallbackDirsPsr4() + { + return $this->fallbackDirsPsr4; + } + + public function getClassMap() + { + return $this->classMap; + } + + /** + * @param array $classMap Class to filename map + */ + public function addClassMap(array $classMap) + { + if ($this->classMap) { + $this->classMap = array_merge($this->classMap, $classMap); + } else { + $this->classMap = $classMap; + } + } + + /** + * Registers a set of PSR-0 directories for a given prefix, either + * appending or prepending to the ones previously set for this prefix. + * + * @param string $prefix The prefix + * @param array|string $paths The PSR-0 root directories + * @param bool $prepend Whether to prepend the directories + */ + public function add($prefix, $paths, $prepend = false) + { + if (!$prefix) { + if ($prepend) { + $this->fallbackDirsPsr0 = array_merge( + (array) $paths, + $this->fallbackDirsPsr0 + ); + } else { + $this->fallbackDirsPsr0 = array_merge( + $this->fallbackDirsPsr0, + (array) $paths + ); + } + + return; + } + + $first = $prefix[0]; + if (!isset($this->prefixesPsr0[$first][$prefix])) { + $this->prefixesPsr0[$first][$prefix] = (array) $paths; + + return; + } + if ($prepend) { + $this->prefixesPsr0[$first][$prefix] = array_merge( + (array) $paths, + $this->prefixesPsr0[$first][$prefix] + ); + } else { + $this->prefixesPsr0[$first][$prefix] = array_merge( + $this->prefixesPsr0[$first][$prefix], + (array) $paths + ); + } + } + + /** + * Registers a set of PSR-4 directories for a given namespace, either + * appending or prepending to the ones previously set for this namespace. + * + * @param string $prefix The prefix/namespace, with trailing '\\' + * @param array|string $paths The PSR-0 base directories + * @param bool $prepend Whether to prepend the directories + */ + public function addPsr4($prefix, $paths, $prepend = false) + { + if (!$prefix) { + // Register directories for the root namespace. + if ($prepend) { + $this->fallbackDirsPsr4 = array_merge( + (array) $paths, + $this->fallbackDirsPsr4 + ); + } else { + $this->fallbackDirsPsr4 = array_merge( + $this->fallbackDirsPsr4, + (array) $paths + ); + } + } elseif (!isset($this->prefixDirsPsr4[$prefix])) { + // Register directories for a new namespace. + $length = strlen($prefix); + if ('\\' !== $prefix[$length - 1]) { + throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); + } + $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; + $this->prefixDirsPsr4[$prefix] = (array) $paths; + } elseif ($prepend) { + // Prepend directories for an already registered namespace. + $this->prefixDirsPsr4[$prefix] = array_merge( + (array) $paths, + $this->prefixDirsPsr4[$prefix] + ); + } else { + // Append directories for an already registered namespace. + $this->prefixDirsPsr4[$prefix] = array_merge( + $this->prefixDirsPsr4[$prefix], + (array) $paths + ); + } + } + + /** + * Registers a set of PSR-0 directories for a given prefix, + * replacing any others previously set for this prefix. + * + * @param string $prefix The prefix + * @param array|string $paths The PSR-0 base directories + */ + public function set($prefix, $paths) + { + if (!$prefix) { + $this->fallbackDirsPsr0 = (array) $paths; + } else { + $this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths; + } + } + + /** + * Registers a set of PSR-4 directories for a given namespace, + * replacing any others previously set for this namespace. + * + * @param string $prefix The prefix/namespace, with trailing '\\' + * @param array|string $paths The PSR-4 base directories + */ + public function setPsr4($prefix, $paths) { + if (!$prefix) { + $this->fallbackDirsPsr4 = (array) $paths; + } else { + $length = strlen($prefix); + if ('\\' !== $prefix[$length - 1]) { + throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); + } + $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; + $this->prefixDirsPsr4[$prefix] = (array) $paths; + } + } + + /** + * Turns on searching the include path for class files. + * + * @param bool $useIncludePath + */ + public function setUseIncludePath($useIncludePath) + { + $this->useIncludePath = $useIncludePath; + } + + /** + * Can be used to check if the autoloader uses the include path to check + * for classes. + * + * @return bool + */ + public function getUseIncludePath() + { + return $this->useIncludePath; + } + + /** + * Registers this instance as an autoloader. + * + * @param bool $prepend Whether to prepend the autoloader or not + */ + public function register($prepend = false) + { + spl_autoload_register(array($this, 'loadClass'), true, $prepend); + } + + /** + * Unregisters this instance as an autoloader. + */ + public function unregister() + { + spl_autoload_unregister(array($this, 'loadClass')); + } + + /** + * Loads the given class or interface. + * + * @param string $class The name of the class + * @return bool|null True if loaded, null otherwise + */ + public function loadClass($class) + { + if ($file = $this->findFile($class)) { + includeFile($file); + + return true; + } + } + + /** + * Finds the path to the file where the class is defined. + * + * @param string $class The name of the class + * + * @return string|false The path if found, false otherwise + */ + public function findFile($class) + { + // work around for PHP 5.3.0 - 5.3.2 https://bugs.php.net/50731 + if ('\\' == $class[0]) { + $class = substr($class, 1); + } + + // class map lookup + if (isset($this->classMap[$class])) { + return $this->classMap[$class]; + } + + $file = $this->findFileWithExtension($class, '.php'); + + // Search for Hack files if we are running on HHVM + if ($file === null && defined('HHVM_VERSION')) { + $file = $this->findFileWithExtension($class, '.hh'); + } + + if ($file === null) { + // Remember that this class does not exist. + return $this->classMap[$class] = false; + } + + return $file; + } + + private function findFileWithExtension($class, $ext) + { + // PSR-4 lookup + $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext; + + $first = $class[0]; + if (isset($this->prefixLengthsPsr4[$first])) { + foreach ($this->prefixLengthsPsr4[$first] as $prefix => $length) { + if (0 === strpos($class, $prefix)) { + foreach ($this->prefixDirsPsr4[$prefix] as $dir) { + if (file_exists($file = $dir . DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $length))) { + return $file; + } + } + } + } + } + + // PSR-4 fallback dirs + foreach ($this->fallbackDirsPsr4 as $dir) { + if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) { + return $file; + } + } + + // PSR-0 lookup + if (false !== $pos = strrpos($class, '\\')) { + // namespaced class name + $logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1) + . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR); + } else { + // PEAR-like class name + $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext; + } + + if (isset($this->prefixesPsr0[$first])) { + foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) { + if (0 === strpos($class, $prefix)) { + foreach ($dirs as $dir) { + if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { + return $file; + } + } + } + } + } + + // PSR-0 fallback dirs + foreach ($this->fallbackDirsPsr0 as $dir) { + if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { + return $file; + } + } + + // PSR-0 include paths. + if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) { + return $file; + } + } +} + +/** + * Scope isolated include. + * + * Prevents access to $this/self from included files. + */ +function includeFile($file) +{ + include $file; +} diff --git a/vendor/composer/autoload_classmap.php b/vendor/composer/autoload_classmap.php new file mode 100755 index 0000000..86ec3ff --- /dev/null +++ b/vendor/composer/autoload_classmap.php @@ -0,0 +1,1530 @@ + $baseDir . '/app/controllers/BaseController.php', + 'Boris\\Boris' => $vendorDir . '/d11wtq/boris/lib/Boris/Boris.php', + 'Boris\\CLIOptionsHandler' => $vendorDir . '/d11wtq/boris/lib/Boris/CLIOptionsHandler.php', + 'Boris\\ColoredInspector' => $vendorDir . '/d11wtq/boris/lib/Boris/ColoredInspector.php', + 'Boris\\Config' => $vendorDir . '/d11wtq/boris/lib/Boris/Config.php', + 'Boris\\DumpInspector' => $vendorDir . '/d11wtq/boris/lib/Boris/DumpInspector.php', + 'Boris\\EvalWorker' => $vendorDir . '/d11wtq/boris/lib/Boris/EvalWorker.php', + 'Boris\\ExportInspector' => $vendorDir . '/d11wtq/boris/lib/Boris/ExportInspector.php', + 'Boris\\Inspector' => $vendorDir . '/d11wtq/boris/lib/Boris/Inspector.php', + 'Boris\\ReadlineClient' => $vendorDir . '/d11wtq/boris/lib/Boris/ReadlineClient.php', + 'Boris\\ShallowParser' => $vendorDir . '/d11wtq/boris/lib/Boris/ShallowParser.php', + 'Carbon\\Carbon' => $vendorDir . '/nesbot/carbon/src/Carbon/Carbon.php', + 'ClassPreloader\\Application' => $vendorDir . '/classpreloader/classpreloader/src/ClassPreloader/Application.php', + 'ClassPreloader\\ClassList' => $vendorDir . '/classpreloader/classpreloader/src/ClassPreloader/ClassList.php', + 'ClassPreloader\\ClassLoader' => $vendorDir . '/classpreloader/classpreloader/src/ClassPreloader/ClassLoader.php', + 'ClassPreloader\\ClassNode' => $vendorDir . '/classpreloader/classpreloader/src/ClassPreloader/ClassNode.php', + 'ClassPreloader\\Command\\PreCompileCommand' => $vendorDir . '/classpreloader/classpreloader/src/ClassPreloader/Command/PreCompileCommand.php', + 'ClassPreloader\\Config' => $vendorDir . '/classpreloader/classpreloader/src/ClassPreloader/Config.php', + 'ClassPreloader\\Parser\\AbstractNodeVisitor' => $vendorDir . '/classpreloader/classpreloader/src/ClassPreloader/Parser/AbstractNodeVisitor.php', + 'ClassPreloader\\Parser\\DirVisitor' => $vendorDir . '/classpreloader/classpreloader/src/ClassPreloader/Parser/DirVisitor.php', + 'ClassPreloader\\Parser\\FileVisitor' => $vendorDir . '/classpreloader/classpreloader/src/ClassPreloader/Parser/FileVisitor.php', + 'ClassPreloader\\Parser\\NodeTraverser' => $vendorDir . '/classpreloader/classpreloader/src/ClassPreloader/Parser/NodeTraverser.php', + 'Crypt_AES' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/AES.php', + 'Crypt_Base' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/Base.php', + 'Crypt_Blowfish' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/Blowfish.php', + 'Crypt_DES' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/DES.php', + 'Crypt_Hash' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/Hash.php', + 'Crypt_RC2' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/RC2.php', + 'Crypt_RC4' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/RC4.php', + 'Crypt_RSA' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/RSA.php', + 'Crypt_Rijndael' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/Rijndael.php', + 'Crypt_TripleDES' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/TripleDES.php', + 'Crypt_Twofish' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/Twofish.php', + 'DatabaseSeeder' => $baseDir . '/app/database/seeds/DatabaseSeeder.php', + 'File_ANSI' => $vendorDir . '/phpseclib/phpseclib/phpseclib/File/ANSI.php', + 'File_ASN1' => $vendorDir . '/phpseclib/phpseclib/phpseclib/File/ASN1.php', + 'File_ASN1_Element' => $vendorDir . '/phpseclib/phpseclib/phpseclib/File/ASN1.php', + 'File_X509' => $vendorDir . '/phpseclib/phpseclib/phpseclib/File/X509.php', + 'HomeController' => $baseDir . '/app/controllers/HomeController.php', + 'IlluminateQueueClosure' => $vendorDir . '/laravel/framework/src/Illuminate/Queue/IlluminateQueueClosure.php', + 'Illuminate\\Auth\\AuthManager' => $vendorDir . '/laravel/framework/src/Illuminate/Auth/AuthManager.php', + 'Illuminate\\Auth\\AuthServiceProvider' => $vendorDir . '/laravel/framework/src/Illuminate/Auth/AuthServiceProvider.php', + 'Illuminate\\Auth\\Console\\ClearRemindersCommand' => $vendorDir . '/laravel/framework/src/Illuminate/Auth/Console/ClearRemindersCommand.php', + 'Illuminate\\Auth\\Console\\RemindersControllerCommand' => $vendorDir . '/laravel/framework/src/Illuminate/Auth/Console/RemindersControllerCommand.php', + 'Illuminate\\Auth\\Console\\RemindersTableCommand' => $vendorDir . '/laravel/framework/src/Illuminate/Auth/Console/RemindersTableCommand.php', + 'Illuminate\\Auth\\DatabaseUserProvider' => $vendorDir . '/laravel/framework/src/Illuminate/Auth/DatabaseUserProvider.php', + 'Illuminate\\Auth\\EloquentUserProvider' => $vendorDir . '/laravel/framework/src/Illuminate/Auth/EloquentUserProvider.php', + 'Illuminate\\Auth\\GenericUser' => $vendorDir . '/laravel/framework/src/Illuminate/Auth/GenericUser.php', + 'Illuminate\\Auth\\Guard' => $vendorDir . '/laravel/framework/src/Illuminate/Auth/Guard.php', + 'Illuminate\\Auth\\Reminders\\DatabaseReminderRepository' => $vendorDir . '/laravel/framework/src/Illuminate/Auth/Reminders/DatabaseReminderRepository.php', + 'Illuminate\\Auth\\Reminders\\PasswordBroker' => $vendorDir . '/laravel/framework/src/Illuminate/Auth/Reminders/PasswordBroker.php', + 'Illuminate\\Auth\\Reminders\\RemindableInterface' => $vendorDir . '/laravel/framework/src/Illuminate/Auth/Reminders/RemindableInterface.php', + 'Illuminate\\Auth\\Reminders\\ReminderRepositoryInterface' => $vendorDir . '/laravel/framework/src/Illuminate/Auth/Reminders/ReminderRepositoryInterface.php', + 'Illuminate\\Auth\\Reminders\\ReminderServiceProvider' => $vendorDir . '/laravel/framework/src/Illuminate/Auth/Reminders/ReminderServiceProvider.php', + 'Illuminate\\Auth\\UserInterface' => $vendorDir . '/laravel/framework/src/Illuminate/Auth/UserInterface.php', + 'Illuminate\\Auth\\UserProviderInterface' => $vendorDir . '/laravel/framework/src/Illuminate/Auth/UserProviderInterface.php', + 'Illuminate\\Cache\\ApcStore' => $vendorDir . '/laravel/framework/src/Illuminate/Cache/ApcStore.php', + 'Illuminate\\Cache\\ApcWrapper' => $vendorDir . '/laravel/framework/src/Illuminate/Cache/ApcWrapper.php', + 'Illuminate\\Cache\\ArrayStore' => $vendorDir . '/laravel/framework/src/Illuminate/Cache/ArrayStore.php', + 'Illuminate\\Cache\\CacheManager' => $vendorDir . '/laravel/framework/src/Illuminate/Cache/CacheManager.php', + 'Illuminate\\Cache\\CacheServiceProvider' => $vendorDir . '/laravel/framework/src/Illuminate/Cache/CacheServiceProvider.php', + 'Illuminate\\Cache\\Console\\ClearCommand' => $vendorDir . '/laravel/framework/src/Illuminate/Cache/Console/ClearCommand.php', + 'Illuminate\\Cache\\DatabaseStore' => $vendorDir . '/laravel/framework/src/Illuminate/Cache/DatabaseStore.php', + 'Illuminate\\Cache\\FileStore' => $vendorDir . '/laravel/framework/src/Illuminate/Cache/FileStore.php', + 'Illuminate\\Cache\\MemcachedConnector' => $vendorDir . '/laravel/framework/src/Illuminate/Cache/MemcachedConnector.php', + 'Illuminate\\Cache\\MemcachedStore' => $vendorDir . '/laravel/framework/src/Illuminate/Cache/MemcachedStore.php', + 'Illuminate\\Cache\\RedisStore' => $vendorDir . '/laravel/framework/src/Illuminate/Cache/RedisStore.php', + 'Illuminate\\Cache\\RedisTaggedCache' => $vendorDir . '/laravel/framework/src/Illuminate/Cache/RedisTaggedCache.php', + 'Illuminate\\Cache\\Repository' => $vendorDir . '/laravel/framework/src/Illuminate/Cache/Repository.php', + 'Illuminate\\Cache\\StoreInterface' => $vendorDir . '/laravel/framework/src/Illuminate/Cache/StoreInterface.php', + 'Illuminate\\Cache\\TagSet' => $vendorDir . '/laravel/framework/src/Illuminate/Cache/TagSet.php', + 'Illuminate\\Cache\\TaggableStore' => $vendorDir . '/laravel/framework/src/Illuminate/Cache/TaggableStore.php', + 'Illuminate\\Cache\\TaggedCache' => $vendorDir . '/laravel/framework/src/Illuminate/Cache/TaggedCache.php', + 'Illuminate\\Cache\\WinCacheStore' => $vendorDir . '/laravel/framework/src/Illuminate/Cache/WinCacheStore.php', + 'Illuminate\\Cache\\XCacheStore' => $vendorDir . '/laravel/framework/src/Illuminate/Cache/XCacheStore.php', + 'Illuminate\\Config\\EnvironmentVariables' => $vendorDir . '/laravel/framework/src/Illuminate/Config/EnvironmentVariables.php', + 'Illuminate\\Config\\EnvironmentVariablesLoaderInterface' => $vendorDir . '/laravel/framework/src/Illuminate/Config/EnvironmentVariablesLoaderInterface.php', + 'Illuminate\\Config\\FileEnvironmentVariablesLoader' => $vendorDir . '/laravel/framework/src/Illuminate/Config/FileEnvironmentVariablesLoader.php', + 'Illuminate\\Config\\FileLoader' => $vendorDir . '/laravel/framework/src/Illuminate/Config/FileLoader.php', + 'Illuminate\\Config\\LoaderInterface' => $vendorDir . '/laravel/framework/src/Illuminate/Config/LoaderInterface.php', + 'Illuminate\\Config\\Repository' => $vendorDir . '/laravel/framework/src/Illuminate/Config/Repository.php', + 'Illuminate\\Console\\Application' => $vendorDir . '/laravel/framework/src/Illuminate/Console/Application.php', + 'Illuminate\\Console\\Command' => $vendorDir . '/laravel/framework/src/Illuminate/Console/Command.php', + 'Illuminate\\Container\\BindingResolutionException' => $vendorDir . '/laravel/framework/src/Illuminate/Container/Container.php', + 'Illuminate\\Container\\Container' => $vendorDir . '/laravel/framework/src/Illuminate/Container/Container.php', + 'Illuminate\\Cookie\\CookieJar' => $vendorDir . '/laravel/framework/src/Illuminate/Cookie/CookieJar.php', + 'Illuminate\\Cookie\\CookieServiceProvider' => $vendorDir . '/laravel/framework/src/Illuminate/Cookie/CookieServiceProvider.php', + 'Illuminate\\Cookie\\Guard' => $vendorDir . '/laravel/framework/src/Illuminate/Cookie/Guard.php', + 'Illuminate\\Cookie\\Queue' => $vendorDir . '/laravel/framework/src/Illuminate/Cookie/Queue.php', + 'Illuminate\\Database\\Capsule\\Manager' => $vendorDir . '/laravel/framework/src/Illuminate/Database/Capsule/Manager.php', + 'Illuminate\\Database\\Connection' => $vendorDir . '/laravel/framework/src/Illuminate/Database/Connection.php', + 'Illuminate\\Database\\ConnectionInterface' => $vendorDir . '/laravel/framework/src/Illuminate/Database/ConnectionInterface.php', + 'Illuminate\\Database\\ConnectionResolver' => $vendorDir . '/laravel/framework/src/Illuminate/Database/ConnectionResolver.php', + 'Illuminate\\Database\\ConnectionResolverInterface' => $vendorDir . '/laravel/framework/src/Illuminate/Database/ConnectionResolverInterface.php', + 'Illuminate\\Database\\Connectors\\ConnectionFactory' => $vendorDir . '/laravel/framework/src/Illuminate/Database/Connectors/ConnectionFactory.php', + 'Illuminate\\Database\\Connectors\\Connector' => $vendorDir . '/laravel/framework/src/Illuminate/Database/Connectors/Connector.php', + 'Illuminate\\Database\\Connectors\\ConnectorInterface' => $vendorDir . '/laravel/framework/src/Illuminate/Database/Connectors/ConnectorInterface.php', + 'Illuminate\\Database\\Connectors\\MySqlConnector' => $vendorDir . '/laravel/framework/src/Illuminate/Database/Connectors/MySqlConnector.php', + 'Illuminate\\Database\\Connectors\\PostgresConnector' => $vendorDir . '/laravel/framework/src/Illuminate/Database/Connectors/PostgresConnector.php', + 'Illuminate\\Database\\Connectors\\SQLiteConnector' => $vendorDir . '/laravel/framework/src/Illuminate/Database/Connectors/SQLiteConnector.php', + 'Illuminate\\Database\\Connectors\\SqlServerConnector' => $vendorDir . '/laravel/framework/src/Illuminate/Database/Connectors/SqlServerConnector.php', + 'Illuminate\\Database\\Console\\Migrations\\BaseCommand' => $vendorDir . '/laravel/framework/src/Illuminate/Database/Console/Migrations/BaseCommand.php', + 'Illuminate\\Database\\Console\\Migrations\\InstallCommand' => $vendorDir . '/laravel/framework/src/Illuminate/Database/Console/Migrations/InstallCommand.php', + 'Illuminate\\Database\\Console\\Migrations\\MigrateCommand' => $vendorDir . '/laravel/framework/src/Illuminate/Database/Console/Migrations/MigrateCommand.php', + 'Illuminate\\Database\\Console\\Migrations\\MigrateMakeCommand' => $vendorDir . '/laravel/framework/src/Illuminate/Database/Console/Migrations/MigrateMakeCommand.php', + 'Illuminate\\Database\\Console\\Migrations\\RefreshCommand' => $vendorDir . '/laravel/framework/src/Illuminate/Database/Console/Migrations/RefreshCommand.php', + 'Illuminate\\Database\\Console\\Migrations\\ResetCommand' => $vendorDir . '/laravel/framework/src/Illuminate/Database/Console/Migrations/ResetCommand.php', + 'Illuminate\\Database\\Console\\Migrations\\RollbackCommand' => $vendorDir . '/laravel/framework/src/Illuminate/Database/Console/Migrations/RollbackCommand.php', + 'Illuminate\\Database\\Console\\SeedCommand' => $vendorDir . '/laravel/framework/src/Illuminate/Database/Console/SeedCommand.php', + 'Illuminate\\Database\\DatabaseManager' => $vendorDir . '/laravel/framework/src/Illuminate/Database/DatabaseManager.php', + 'Illuminate\\Database\\DatabaseServiceProvider' => $vendorDir . '/laravel/framework/src/Illuminate/Database/DatabaseServiceProvider.php', + 'Illuminate\\Database\\Eloquent\\Builder' => $vendorDir . '/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php', + 'Illuminate\\Database\\Eloquent\\Collection' => $vendorDir . '/laravel/framework/src/Illuminate/Database/Eloquent/Collection.php', + 'Illuminate\\Database\\Eloquent\\MassAssignmentException' => $vendorDir . '/laravel/framework/src/Illuminate/Database/Eloquent/MassAssignmentException.php', + 'Illuminate\\Database\\Eloquent\\Model' => $vendorDir . '/laravel/framework/src/Illuminate/Database/Eloquent/Model.php', + 'Illuminate\\Database\\Eloquent\\ModelNotFoundException' => $vendorDir . '/laravel/framework/src/Illuminate/Database/Eloquent/ModelNotFoundException.php', + 'Illuminate\\Database\\Eloquent\\Relations\\BelongsTo' => $vendorDir . '/laravel/framework/src/Illuminate/Database/Eloquent/Relations/BelongsTo.php', + 'Illuminate\\Database\\Eloquent\\Relations\\BelongsToMany' => $vendorDir . '/laravel/framework/src/Illuminate/Database/Eloquent/Relations/BelongsToMany.php', + 'Illuminate\\Database\\Eloquent\\Relations\\HasMany' => $vendorDir . '/laravel/framework/src/Illuminate/Database/Eloquent/Relations/HasMany.php', + 'Illuminate\\Database\\Eloquent\\Relations\\HasManyThrough' => $vendorDir . '/laravel/framework/src/Illuminate/Database/Eloquent/Relations/HasManyThrough.php', + 'Illuminate\\Database\\Eloquent\\Relations\\HasOne' => $vendorDir . '/laravel/framework/src/Illuminate/Database/Eloquent/Relations/HasOne.php', + 'Illuminate\\Database\\Eloquent\\Relations\\HasOneOrMany' => $vendorDir . '/laravel/framework/src/Illuminate/Database/Eloquent/Relations/HasOneOrMany.php', + 'Illuminate\\Database\\Eloquent\\Relations\\MorphMany' => $vendorDir . '/laravel/framework/src/Illuminate/Database/Eloquent/Relations/MorphMany.php', + 'Illuminate\\Database\\Eloquent\\Relations\\MorphOne' => $vendorDir . '/laravel/framework/src/Illuminate/Database/Eloquent/Relations/MorphOne.php', + 'Illuminate\\Database\\Eloquent\\Relations\\MorphOneOrMany' => $vendorDir . '/laravel/framework/src/Illuminate/Database/Eloquent/Relations/MorphOneOrMany.php', + 'Illuminate\\Database\\Eloquent\\Relations\\MorphPivot' => $vendorDir . '/laravel/framework/src/Illuminate/Database/Eloquent/Relations/MorphPivot.php', + 'Illuminate\\Database\\Eloquent\\Relations\\MorphTo' => $vendorDir . '/laravel/framework/src/Illuminate/Database/Eloquent/Relations/MorphTo.php', + 'Illuminate\\Database\\Eloquent\\Relations\\MorphToMany' => $vendorDir . '/laravel/framework/src/Illuminate/Database/Eloquent/Relations/MorphToMany.php', + 'Illuminate\\Database\\Eloquent\\Relations\\Pivot' => $vendorDir . '/laravel/framework/src/Illuminate/Database/Eloquent/Relations/Pivot.php', + 'Illuminate\\Database\\Eloquent\\Relations\\Relation' => $vendorDir . '/laravel/framework/src/Illuminate/Database/Eloquent/Relations/Relation.php', + 'Illuminate\\Database\\Grammar' => $vendorDir . '/laravel/framework/src/Illuminate/Database/Grammar.php', + 'Illuminate\\Database\\MigrationServiceProvider' => $vendorDir . '/laravel/framework/src/Illuminate/Database/MigrationServiceProvider.php', + 'Illuminate\\Database\\Migrations\\DatabaseMigrationRepository' => $vendorDir . '/laravel/framework/src/Illuminate/Database/Migrations/DatabaseMigrationRepository.php', + 'Illuminate\\Database\\Migrations\\Migration' => $vendorDir . '/laravel/framework/src/Illuminate/Database/Migrations/Migration.php', + 'Illuminate\\Database\\Migrations\\MigrationCreator' => $vendorDir . '/laravel/framework/src/Illuminate/Database/Migrations/MigrationCreator.php', + 'Illuminate\\Database\\Migrations\\MigrationRepositoryInterface' => $vendorDir . '/laravel/framework/src/Illuminate/Database/Migrations/MigrationRepositoryInterface.php', + 'Illuminate\\Database\\Migrations\\Migrator' => $vendorDir . '/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php', + 'Illuminate\\Database\\MySqlConnection' => $vendorDir . '/laravel/framework/src/Illuminate/Database/MySqlConnection.php', + 'Illuminate\\Database\\PostgresConnection' => $vendorDir . '/laravel/framework/src/Illuminate/Database/PostgresConnection.php', + 'Illuminate\\Database\\QueryException' => $vendorDir . '/laravel/framework/src/Illuminate/Database/QueryException.php', + 'Illuminate\\Database\\Query\\Builder' => $vendorDir . '/laravel/framework/src/Illuminate/Database/Query/Builder.php', + 'Illuminate\\Database\\Query\\Expression' => $vendorDir . '/laravel/framework/src/Illuminate/Database/Query/Expression.php', + 'Illuminate\\Database\\Query\\Grammars\\Grammar' => $vendorDir . '/laravel/framework/src/Illuminate/Database/Query/Grammars/Grammar.php', + 'Illuminate\\Database\\Query\\Grammars\\MySqlGrammar' => $vendorDir . '/laravel/framework/src/Illuminate/Database/Query/Grammars/MySqlGrammar.php', + 'Illuminate\\Database\\Query\\Grammars\\PostgresGrammar' => $vendorDir . '/laravel/framework/src/Illuminate/Database/Query/Grammars/PostgresGrammar.php', + 'Illuminate\\Database\\Query\\Grammars\\SQLiteGrammar' => $vendorDir . '/laravel/framework/src/Illuminate/Database/Query/Grammars/SQLiteGrammar.php', + 'Illuminate\\Database\\Query\\Grammars\\SqlServerGrammar' => $vendorDir . '/laravel/framework/src/Illuminate/Database/Query/Grammars/SqlServerGrammar.php', + 'Illuminate\\Database\\Query\\JoinClause' => $vendorDir . '/laravel/framework/src/Illuminate/Database/Query/JoinClause.php', + 'Illuminate\\Database\\Query\\Processors\\MySqlProcessor' => $vendorDir . '/laravel/framework/src/Illuminate/Database/Query/Processors/MySqlProcessor.php', + 'Illuminate\\Database\\Query\\Processors\\PostgresProcessor' => $vendorDir . '/laravel/framework/src/Illuminate/Database/Query/Processors/PostgresProcessor.php', + 'Illuminate\\Database\\Query\\Processors\\Processor' => $vendorDir . '/laravel/framework/src/Illuminate/Database/Query/Processors/Processor.php', + 'Illuminate\\Database\\Query\\Processors\\SQLiteProcessor' => $vendorDir . '/laravel/framework/src/Illuminate/Database/Query/Processors/SQLiteProcessor.php', + 'Illuminate\\Database\\Query\\Processors\\SqlServerProcessor' => $vendorDir . '/laravel/framework/src/Illuminate/Database/Query/Processors/SqlServerProcessor.php', + 'Illuminate\\Database\\SQLiteConnection' => $vendorDir . '/laravel/framework/src/Illuminate/Database/SQLiteConnection.php', + 'Illuminate\\Database\\Schema\\Blueprint' => $vendorDir . '/laravel/framework/src/Illuminate/Database/Schema/Blueprint.php', + 'Illuminate\\Database\\Schema\\Builder' => $vendorDir . '/laravel/framework/src/Illuminate/Database/Schema/Builder.php', + 'Illuminate\\Database\\Schema\\Grammars\\Grammar' => $vendorDir . '/laravel/framework/src/Illuminate/Database/Schema/Grammars/Grammar.php', + 'Illuminate\\Database\\Schema\\Grammars\\MySqlGrammar' => $vendorDir . '/laravel/framework/src/Illuminate/Database/Schema/Grammars/MySqlGrammar.php', + 'Illuminate\\Database\\Schema\\Grammars\\PostgresGrammar' => $vendorDir . '/laravel/framework/src/Illuminate/Database/Schema/Grammars/PostgresGrammar.php', + 'Illuminate\\Database\\Schema\\Grammars\\SQLiteGrammar' => $vendorDir . '/laravel/framework/src/Illuminate/Database/Schema/Grammars/SQLiteGrammar.php', + 'Illuminate\\Database\\Schema\\Grammars\\SqlServerGrammar' => $vendorDir . '/laravel/framework/src/Illuminate/Database/Schema/Grammars/SqlServerGrammar.php', + 'Illuminate\\Database\\Schema\\MySqlBuilder' => $vendorDir . '/laravel/framework/src/Illuminate/Database/Schema/MySqlBuilder.php', + 'Illuminate\\Database\\SeedServiceProvider' => $vendorDir . '/laravel/framework/src/Illuminate/Database/SeedServiceProvider.php', + 'Illuminate\\Database\\Seeder' => $vendorDir . '/laravel/framework/src/Illuminate/Database/Seeder.php', + 'Illuminate\\Database\\SqlServerConnection' => $vendorDir . '/laravel/framework/src/Illuminate/Database/SqlServerConnection.php', + 'Illuminate\\Encryption\\DecryptException' => $vendorDir . '/laravel/framework/src/Illuminate/Encryption/Encrypter.php', + 'Illuminate\\Encryption\\Encrypter' => $vendorDir . '/laravel/framework/src/Illuminate/Encryption/Encrypter.php', + 'Illuminate\\Encryption\\EncryptionServiceProvider' => $vendorDir . '/laravel/framework/src/Illuminate/Encryption/EncryptionServiceProvider.php', + 'Illuminate\\Events\\Dispatcher' => $vendorDir . '/laravel/framework/src/Illuminate/Events/Dispatcher.php', + 'Illuminate\\Events\\EventServiceProvider' => $vendorDir . '/laravel/framework/src/Illuminate/Events/EventServiceProvider.php', + 'Illuminate\\Events\\Subscriber' => $vendorDir . '/laravel/framework/src/Illuminate/Events/Subscriber.php', + 'Illuminate\\Exception\\ExceptionDisplayerInterface' => $vendorDir . '/laravel/framework/src/Illuminate/Exception/ExceptionDisplayerInterface.php', + 'Illuminate\\Exception\\ExceptionServiceProvider' => $vendorDir . '/laravel/framework/src/Illuminate/Exception/ExceptionServiceProvider.php', + 'Illuminate\\Exception\\Handler' => $vendorDir . '/laravel/framework/src/Illuminate/Exception/Handler.php', + 'Illuminate\\Exception\\PlainDisplayer' => $vendorDir . '/laravel/framework/src/Illuminate/Exception/PlainDisplayer.php', + 'Illuminate\\Exception\\SymfonyDisplayer' => $vendorDir . '/laravel/framework/src/Illuminate/Exception/SymfonyDisplayer.php', + 'Illuminate\\Exception\\WhoopsDisplayer' => $vendorDir . '/laravel/framework/src/Illuminate/Exception/WhoopsDisplayer.php', + 'Illuminate\\Filesystem\\FileNotFoundException' => $vendorDir . '/laravel/framework/src/Illuminate/Filesystem/Filesystem.php', + 'Illuminate\\Filesystem\\Filesystem' => $vendorDir . '/laravel/framework/src/Illuminate/Filesystem/Filesystem.php', + 'Illuminate\\Filesystem\\FilesystemServiceProvider' => $vendorDir . '/laravel/framework/src/Illuminate/Filesystem/FilesystemServiceProvider.php', + 'Illuminate\\Foundation\\AliasLoader' => $vendorDir . '/laravel/framework/src/Illuminate/Foundation/AliasLoader.php', + 'Illuminate\\Foundation\\Application' => $vendorDir . '/laravel/framework/src/Illuminate/Foundation/Application.php', + 'Illuminate\\Foundation\\Artisan' => $vendorDir . '/laravel/framework/src/Illuminate/Foundation/Artisan.php', + 'Illuminate\\Foundation\\AssetPublisher' => $vendorDir . '/laravel/framework/src/Illuminate/Foundation/AssetPublisher.php', + 'Illuminate\\Foundation\\Composer' => $vendorDir . '/laravel/framework/src/Illuminate/Foundation/Composer.php', + 'Illuminate\\Foundation\\ConfigPublisher' => $vendorDir . '/laravel/framework/src/Illuminate/Foundation/ConfigPublisher.php', + 'Illuminate\\Foundation\\Console\\AssetPublishCommand' => $vendorDir . '/laravel/framework/src/Illuminate/Foundation/Console/AssetPublishCommand.php', + 'Illuminate\\Foundation\\Console\\AutoloadCommand' => $vendorDir . '/laravel/framework/src/Illuminate/Foundation/Console/AutoloadCommand.php', + 'Illuminate\\Foundation\\Console\\ChangesCommand' => $vendorDir . '/laravel/framework/src/Illuminate/Foundation/Console/ChangesCommand.php', + 'Illuminate\\Foundation\\Console\\ClearCompiledCommand' => $vendorDir . '/laravel/framework/src/Illuminate/Foundation/Console/ClearCompiledCommand.php', + 'Illuminate\\Foundation\\Console\\CommandMakeCommand' => $vendorDir . '/laravel/framework/src/Illuminate/Foundation/Console/CommandMakeCommand.php', + 'Illuminate\\Foundation\\Console\\ConfigPublishCommand' => $vendorDir . '/laravel/framework/src/Illuminate/Foundation/Console/ConfigPublishCommand.php', + 'Illuminate\\Foundation\\Console\\DownCommand' => $vendorDir . '/laravel/framework/src/Illuminate/Foundation/Console/DownCommand.php', + 'Illuminate\\Foundation\\Console\\EnvironmentCommand' => $vendorDir . '/laravel/framework/src/Illuminate/Foundation/Console/EnvironmentCommand.php', + 'Illuminate\\Foundation\\Console\\KeyGenerateCommand' => $vendorDir . '/laravel/framework/src/Illuminate/Foundation/Console/KeyGenerateCommand.php', + 'Illuminate\\Foundation\\Console\\MigratePublishCommand' => $vendorDir . '/laravel/framework/src/Illuminate/Foundation/Console/MigratePublishCommand.php', + 'Illuminate\\Foundation\\Console\\OptimizeCommand' => $vendorDir . '/laravel/framework/src/Illuminate/Foundation/Console/OptimizeCommand.php', + 'Illuminate\\Foundation\\Console\\RoutesCommand' => $vendorDir . '/laravel/framework/src/Illuminate/Foundation/Console/RoutesCommand.php', + 'Illuminate\\Foundation\\Console\\ServeCommand' => $vendorDir . '/laravel/framework/src/Illuminate/Foundation/Console/ServeCommand.php', + 'Illuminate\\Foundation\\Console\\TailCommand' => $vendorDir . '/laravel/framework/src/Illuminate/Foundation/Console/TailCommand.php', + 'Illuminate\\Foundation\\Console\\TinkerCommand' => $vendorDir . '/laravel/framework/src/Illuminate/Foundation/Console/TinkerCommand.php', + 'Illuminate\\Foundation\\Console\\UpCommand' => $vendorDir . '/laravel/framework/src/Illuminate/Foundation/Console/UpCommand.php', + 'Illuminate\\Foundation\\Console\\ViewPublishCommand' => $vendorDir . '/laravel/framework/src/Illuminate/Foundation/Console/ViewPublishCommand.php', + 'Illuminate\\Foundation\\EnvironmentDetector' => $vendorDir . '/laravel/framework/src/Illuminate/Foundation/EnvironmentDetector.php', + 'Illuminate\\Foundation\\MigrationPublisher' => $vendorDir . '/laravel/framework/src/Illuminate/Foundation/MigrationPublisher.php', + 'Illuminate\\Foundation\\ProviderRepository' => $vendorDir . '/laravel/framework/src/Illuminate/Foundation/ProviderRepository.php', + 'Illuminate\\Foundation\\Providers\\ArtisanServiceProvider' => $vendorDir . '/laravel/framework/src/Illuminate/Foundation/Providers/ArtisanServiceProvider.php', + 'Illuminate\\Foundation\\Providers\\CommandCreatorServiceProvider' => $vendorDir . '/laravel/framework/src/Illuminate/Foundation/Providers/CommandCreatorServiceProvider.php', + 'Illuminate\\Foundation\\Providers\\ComposerServiceProvider' => $vendorDir . '/laravel/framework/src/Illuminate/Foundation/Providers/ComposerServiceProvider.php', + 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider' => $vendorDir . '/laravel/framework/src/Illuminate/Foundation/Providers/ConsoleSupportServiceProvider.php', + 'Illuminate\\Foundation\\Providers\\KeyGeneratorServiceProvider' => $vendorDir . '/laravel/framework/src/Illuminate/Foundation/Providers/KeyGeneratorServiceProvider.php', + 'Illuminate\\Foundation\\Providers\\MaintenanceServiceProvider' => $vendorDir . '/laravel/framework/src/Illuminate/Foundation/Providers/MaintenanceServiceProvider.php', + 'Illuminate\\Foundation\\Providers\\OptimizeServiceProvider' => $vendorDir . '/laravel/framework/src/Illuminate/Foundation/Providers/OptimizeServiceProvider.php', + 'Illuminate\\Foundation\\Providers\\PublisherServiceProvider' => $vendorDir . '/laravel/framework/src/Illuminate/Foundation/Providers/PublisherServiceProvider.php', + 'Illuminate\\Foundation\\Providers\\RouteListServiceProvider' => $vendorDir . '/laravel/framework/src/Illuminate/Foundation/Providers/RouteListServiceProvider.php', + 'Illuminate\\Foundation\\Providers\\ServerServiceProvider' => $vendorDir . '/laravel/framework/src/Illuminate/Foundation/Providers/ServerServiceProvider.php', + 'Illuminate\\Foundation\\Providers\\TinkerServiceProvider' => $vendorDir . '/laravel/framework/src/Illuminate/Foundation/Providers/TinkerServiceProvider.php', + 'Illuminate\\Foundation\\Testing\\Client' => $vendorDir . '/laravel/framework/src/Illuminate/Foundation/Testing/Client.php', + 'Illuminate\\Foundation\\Testing\\TestCase' => $vendorDir . '/laravel/framework/src/Illuminate/Foundation/Testing/TestCase.php', + 'Illuminate\\Foundation\\ViewPublisher' => $vendorDir . '/laravel/framework/src/Illuminate/Foundation/ViewPublisher.php', + 'Illuminate\\Hashing\\BcryptHasher' => $vendorDir . '/laravel/framework/src/Illuminate/Hashing/BcryptHasher.php', + 'Illuminate\\Hashing\\HashServiceProvider' => $vendorDir . '/laravel/framework/src/Illuminate/Hashing/HashServiceProvider.php', + 'Illuminate\\Hashing\\HasherInterface' => $vendorDir . '/laravel/framework/src/Illuminate/Hashing/HasherInterface.php', + 'Illuminate\\Html\\FormBuilder' => $vendorDir . '/laravel/framework/src/Illuminate/Html/FormBuilder.php', + 'Illuminate\\Html\\HtmlBuilder' => $vendorDir . '/laravel/framework/src/Illuminate/Html/HtmlBuilder.php', + 'Illuminate\\Html\\HtmlServiceProvider' => $vendorDir . '/laravel/framework/src/Illuminate/Html/HtmlServiceProvider.php', + 'Illuminate\\Http\\FrameGuard' => $vendorDir . '/laravel/framework/src/Illuminate/Http/FrameGuard.php', + 'Illuminate\\Http\\JsonResponse' => $vendorDir . '/laravel/framework/src/Illuminate/Http/JsonResponse.php', + 'Illuminate\\Http\\RedirectResponse' => $vendorDir . '/laravel/framework/src/Illuminate/Http/RedirectResponse.php', + 'Illuminate\\Http\\Request' => $vendorDir . '/laravel/framework/src/Illuminate/Http/Request.php', + 'Illuminate\\Http\\Response' => $vendorDir . '/laravel/framework/src/Illuminate/Http/Response.php', + 'Illuminate\\Log\\LogServiceProvider' => $vendorDir . '/laravel/framework/src/Illuminate/Log/LogServiceProvider.php', + 'Illuminate\\Log\\Writer' => $vendorDir . '/laravel/framework/src/Illuminate/Log/Writer.php', + 'Illuminate\\Mail\\MailServiceProvider' => $vendorDir . '/laravel/framework/src/Illuminate/Mail/MailServiceProvider.php', + 'Illuminate\\Mail\\Mailer' => $vendorDir . '/laravel/framework/src/Illuminate/Mail/Mailer.php', + 'Illuminate\\Mail\\Message' => $vendorDir . '/laravel/framework/src/Illuminate/Mail/Message.php', + 'Illuminate\\Pagination\\BootstrapPresenter' => $vendorDir . '/laravel/framework/src/Illuminate/Pagination/BootstrapPresenter.php', + 'Illuminate\\Pagination\\Environment' => $vendorDir . '/laravel/framework/src/Illuminate/Pagination/Environment.php', + 'Illuminate\\Pagination\\PaginationServiceProvider' => $vendorDir . '/laravel/framework/src/Illuminate/Pagination/PaginationServiceProvider.php', + 'Illuminate\\Pagination\\Paginator' => $vendorDir . '/laravel/framework/src/Illuminate/Pagination/Paginator.php', + 'Illuminate\\Pagination\\Presenter' => $vendorDir . '/laravel/framework/src/Illuminate/Pagination/Presenter.php', + 'Illuminate\\Queue\\BeanstalkdQueue' => $vendorDir . '/laravel/framework/src/Illuminate/Queue/BeanstalkdQueue.php', + 'Illuminate\\Queue\\Capsule\\Manager' => $vendorDir . '/laravel/framework/src/Illuminate/Queue/Capsule/Manager.php', + 'Illuminate\\Queue\\Connectors\\BeanstalkdConnector' => $vendorDir . '/laravel/framework/src/Illuminate/Queue/Connectors/BeanstalkdConnector.php', + 'Illuminate\\Queue\\Connectors\\ConnectorInterface' => $vendorDir . '/laravel/framework/src/Illuminate/Queue/Connectors/ConnectorInterface.php', + 'Illuminate\\Queue\\Connectors\\IronConnector' => $vendorDir . '/laravel/framework/src/Illuminate/Queue/Connectors/IronConnector.php', + 'Illuminate\\Queue\\Connectors\\RedisConnector' => $vendorDir . '/laravel/framework/src/Illuminate/Queue/Connectors/RedisConnector.php', + 'Illuminate\\Queue\\Connectors\\SqsConnector' => $vendorDir . '/laravel/framework/src/Illuminate/Queue/Connectors/SqsConnector.php', + 'Illuminate\\Queue\\Connectors\\SyncConnector' => $vendorDir . '/laravel/framework/src/Illuminate/Queue/Connectors/SyncConnector.php', + 'Illuminate\\Queue\\Console\\FailedTableCommand' => $vendorDir . '/laravel/framework/src/Illuminate/Queue/Console/FailedTableCommand.php', + 'Illuminate\\Queue\\Console\\FlushFailedCommand' => $vendorDir . '/laravel/framework/src/Illuminate/Queue/Console/FlushFailedCommand.php', + 'Illuminate\\Queue\\Console\\ForgetFailedCommand' => $vendorDir . '/laravel/framework/src/Illuminate/Queue/Console/ForgetFailedCommand.php', + 'Illuminate\\Queue\\Console\\ListFailedCommand' => $vendorDir . '/laravel/framework/src/Illuminate/Queue/Console/ListFailedCommand.php', + 'Illuminate\\Queue\\Console\\ListenCommand' => $vendorDir . '/laravel/framework/src/Illuminate/Queue/Console/ListenCommand.php', + 'Illuminate\\Queue\\Console\\RetryCommand' => $vendorDir . '/laravel/framework/src/Illuminate/Queue/Console/RetryCommand.php', + 'Illuminate\\Queue\\Console\\SubscribeCommand' => $vendorDir . '/laravel/framework/src/Illuminate/Queue/Console/SubscribeCommand.php', + 'Illuminate\\Queue\\Console\\WorkCommand' => $vendorDir . '/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php', + 'Illuminate\\Queue\\FailConsoleServiceProvider' => $vendorDir . '/laravel/framework/src/Illuminate/Queue/FailConsoleServiceProvider.php', + 'Illuminate\\Queue\\Failed\\DatabaseFailedJobProvider' => $vendorDir . '/laravel/framework/src/Illuminate/Queue/Failed/DatabaseFailedJobProvider.php', + 'Illuminate\\Queue\\Failed\\FailedJobProviderInterface' => $vendorDir . '/laravel/framework/src/Illuminate/Queue/Failed/FailedJobProviderInterface.php', + 'Illuminate\\Queue\\IronQueue' => $vendorDir . '/laravel/framework/src/Illuminate/Queue/IronQueue.php', + 'Illuminate\\Queue\\Jobs\\BeanstalkdJob' => $vendorDir . '/laravel/framework/src/Illuminate/Queue/Jobs/BeanstalkdJob.php', + 'Illuminate\\Queue\\Jobs\\IronJob' => $vendorDir . '/laravel/framework/src/Illuminate/Queue/Jobs/IronJob.php', + 'Illuminate\\Queue\\Jobs\\Job' => $vendorDir . '/laravel/framework/src/Illuminate/Queue/Jobs/Job.php', + 'Illuminate\\Queue\\Jobs\\RedisJob' => $vendorDir . '/laravel/framework/src/Illuminate/Queue/Jobs/RedisJob.php', + 'Illuminate\\Queue\\Jobs\\SqsJob' => $vendorDir . '/laravel/framework/src/Illuminate/Queue/Jobs/SqsJob.php', + 'Illuminate\\Queue\\Jobs\\SyncJob' => $vendorDir . '/laravel/framework/src/Illuminate/Queue/Jobs/SyncJob.php', + 'Illuminate\\Queue\\Listener' => $vendorDir . '/laravel/framework/src/Illuminate/Queue/Listener.php', + 'Illuminate\\Queue\\Queue' => $vendorDir . '/laravel/framework/src/Illuminate/Queue/Queue.php', + 'Illuminate\\Queue\\QueueInterface' => $vendorDir . '/laravel/framework/src/Illuminate/Queue/QueueInterface.php', + 'Illuminate\\Queue\\QueueManager' => $vendorDir . '/laravel/framework/src/Illuminate/Queue/QueueManager.php', + 'Illuminate\\Queue\\QueueServiceProvider' => $vendorDir . '/laravel/framework/src/Illuminate/Queue/QueueServiceProvider.php', + 'Illuminate\\Queue\\RedisQueue' => $vendorDir . '/laravel/framework/src/Illuminate/Queue/RedisQueue.php', + 'Illuminate\\Queue\\SqsQueue' => $vendorDir . '/laravel/framework/src/Illuminate/Queue/SqsQueue.php', + 'Illuminate\\Queue\\SyncQueue' => $vendorDir . '/laravel/framework/src/Illuminate/Queue/SyncQueue.php', + 'Illuminate\\Queue\\Worker' => $vendorDir . '/laravel/framework/src/Illuminate/Queue/Worker.php', + 'Illuminate\\Redis\\Database' => $vendorDir . '/laravel/framework/src/Illuminate/Redis/Database.php', + 'Illuminate\\Redis\\RedisServiceProvider' => $vendorDir . '/laravel/framework/src/Illuminate/Redis/RedisServiceProvider.php', + 'Illuminate\\Remote\\Connection' => $vendorDir . '/laravel/framework/src/Illuminate/Remote/Connection.php', + 'Illuminate\\Remote\\ConnectionInterface' => $vendorDir . '/laravel/framework/src/Illuminate/Remote/ConnectionInterface.php', + 'Illuminate\\Remote\\GatewayInterface' => $vendorDir . '/laravel/framework/src/Illuminate/Remote/GatewayInterface.php', + 'Illuminate\\Remote\\MultiConnection' => $vendorDir . '/laravel/framework/src/Illuminate/Remote/MultiConnection.php', + 'Illuminate\\Remote\\RemoteManager' => $vendorDir . '/laravel/framework/src/Illuminate/Remote/RemoteManager.php', + 'Illuminate\\Remote\\RemoteServiceProvider' => $vendorDir . '/laravel/framework/src/Illuminate/Remote/RemoteServiceProvider.php', + 'Illuminate\\Remote\\SecLibGateway' => $vendorDir . '/laravel/framework/src/Illuminate/Remote/SecLibGateway.php', + 'Illuminate\\Routing\\Console\\MakeControllerCommand' => $vendorDir . '/laravel/framework/src/Illuminate/Routing/Console/MakeControllerCommand.php', + 'Illuminate\\Routing\\Controller' => $vendorDir . '/laravel/framework/src/Illuminate/Routing/Controller.php', + 'Illuminate\\Routing\\ControllerDispatcher' => $vendorDir . '/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php', + 'Illuminate\\Routing\\ControllerInspector' => $vendorDir . '/laravel/framework/src/Illuminate/Routing/ControllerInspector.php', + 'Illuminate\\Routing\\ControllerServiceProvider' => $vendorDir . '/laravel/framework/src/Illuminate/Routing/ControllerServiceProvider.php', + 'Illuminate\\Routing\\Generators\\ControllerGenerator' => $vendorDir . '/laravel/framework/src/Illuminate/Routing/Generators/ControllerGenerator.php', + 'Illuminate\\Routing\\Matching\\HostValidator' => $vendorDir . '/laravel/framework/src/Illuminate/Routing/Matching/HostValidator.php', + 'Illuminate\\Routing\\Matching\\MethodValidator' => $vendorDir . '/laravel/framework/src/Illuminate/Routing/Matching/MethodValidator.php', + 'Illuminate\\Routing\\Matching\\SchemeValidator' => $vendorDir . '/laravel/framework/src/Illuminate/Routing/Matching/SchemeValidator.php', + 'Illuminate\\Routing\\Matching\\UriValidator' => $vendorDir . '/laravel/framework/src/Illuminate/Routing/Matching/UriValidator.php', + 'Illuminate\\Routing\\Matching\\ValidatorInterface' => $vendorDir . '/laravel/framework/src/Illuminate/Routing/Matching/ValidatorInterface.php', + 'Illuminate\\Routing\\Redirector' => $vendorDir . '/laravel/framework/src/Illuminate/Routing/Redirector.php', + 'Illuminate\\Routing\\Route' => $vendorDir . '/laravel/framework/src/Illuminate/Routing/Route.php', + 'Illuminate\\Routing\\RouteCollection' => $vendorDir . '/laravel/framework/src/Illuminate/Routing/RouteCollection.php', + 'Illuminate\\Routing\\RouteFiltererInterface' => $vendorDir . '/laravel/framework/src/Illuminate/Routing/RouteFiltererInterface.php', + 'Illuminate\\Routing\\Router' => $vendorDir . '/laravel/framework/src/Illuminate/Routing/Router.php', + 'Illuminate\\Routing\\RoutingServiceProvider' => $vendorDir . '/laravel/framework/src/Illuminate/Routing/RoutingServiceProvider.php', + 'Illuminate\\Routing\\UrlGenerator' => $vendorDir . '/laravel/framework/src/Illuminate/Routing/UrlGenerator.php', + 'Illuminate\\Session\\CacheBasedSessionHandler' => $vendorDir . '/laravel/framework/src/Illuminate/Session/CacheBasedSessionHandler.php', + 'Illuminate\\Session\\CommandsServiceProvider' => $vendorDir . '/laravel/framework/src/Illuminate/Session/CommandsServiceProvider.php', + 'Illuminate\\Session\\Console\\SessionTableCommand' => $vendorDir . '/laravel/framework/src/Illuminate/Session/Console/SessionTableCommand.php', + 'Illuminate\\Session\\CookieSessionHandler' => $vendorDir . '/laravel/framework/src/Illuminate/Session/CookieSessionHandler.php', + 'Illuminate\\Session\\FileSessionHandler' => $vendorDir . '/laravel/framework/src/Illuminate/Session/FileSessionHandler.php', + 'Illuminate\\Session\\Middleware' => $vendorDir . '/laravel/framework/src/Illuminate/Session/Middleware.php', + 'Illuminate\\Session\\SessionInterface' => $vendorDir . '/laravel/framework/src/Illuminate/Session/SessionInterface.php', + 'Illuminate\\Session\\SessionManager' => $vendorDir . '/laravel/framework/src/Illuminate/Session/SessionManager.php', + 'Illuminate\\Session\\SessionServiceProvider' => $vendorDir . '/laravel/framework/src/Illuminate/Session/SessionServiceProvider.php', + 'Illuminate\\Session\\Store' => $vendorDir . '/laravel/framework/src/Illuminate/Session/Store.php', + 'Illuminate\\Session\\TokenMismatchException' => $vendorDir . '/laravel/framework/src/Illuminate/Session/TokenMismatchException.php', + 'Illuminate\\Support\\ClassLoader' => $vendorDir . '/laravel/framework/src/Illuminate/Support/ClassLoader.php', + 'Illuminate\\Support\\Collection' => $vendorDir . '/laravel/framework/src/Illuminate/Support/Collection.php', + 'Illuminate\\Support\\Contracts\\ArrayableInterface' => $vendorDir . '/laravel/framework/src/Illuminate/Support/Contracts/ArrayableInterface.php', + 'Illuminate\\Support\\Contracts\\JsonableInterface' => $vendorDir . '/laravel/framework/src/Illuminate/Support/Contracts/JsonableInterface.php', + 'Illuminate\\Support\\Contracts\\MessageProviderInterface' => $vendorDir . '/laravel/framework/src/Illuminate/Support/Contracts/MessageProviderInterface.php', + 'Illuminate\\Support\\Contracts\\RenderableInterface' => $vendorDir . '/laravel/framework/src/Illuminate/Support/Contracts/RenderableInterface.php', + 'Illuminate\\Support\\Contracts\\ResponsePreparerInterface' => $vendorDir . '/laravel/framework/src/Illuminate/Support/Contracts/ResponsePreparerInterface.php', + 'Illuminate\\Support\\Facades\\App' => $vendorDir . '/laravel/framework/src/Illuminate/Support/Facades/App.php', + 'Illuminate\\Support\\Facades\\Artisan' => $vendorDir . '/laravel/framework/src/Illuminate/Support/Facades/Artisan.php', + 'Illuminate\\Support\\Facades\\Auth' => $vendorDir . '/laravel/framework/src/Illuminate/Support/Facades/Auth.php', + 'Illuminate\\Support\\Facades\\Blade' => $vendorDir . '/laravel/framework/src/Illuminate/Support/Facades/Blade.php', + 'Illuminate\\Support\\Facades\\Cache' => $vendorDir . '/laravel/framework/src/Illuminate/Support/Facades/Cache.php', + 'Illuminate\\Support\\Facades\\Config' => $vendorDir . '/laravel/framework/src/Illuminate/Support/Facades/Config.php', + 'Illuminate\\Support\\Facades\\Cookie' => $vendorDir . '/laravel/framework/src/Illuminate/Support/Facades/Cookie.php', + 'Illuminate\\Support\\Facades\\Crypt' => $vendorDir . '/laravel/framework/src/Illuminate/Support/Facades/Crypt.php', + 'Illuminate\\Support\\Facades\\DB' => $vendorDir . '/laravel/framework/src/Illuminate/Support/Facades/DB.php', + 'Illuminate\\Support\\Facades\\Event' => $vendorDir . '/laravel/framework/src/Illuminate/Support/Facades/Event.php', + 'Illuminate\\Support\\Facades\\Facade' => $vendorDir . '/laravel/framework/src/Illuminate/Support/Facades/Facade.php', + 'Illuminate\\Support\\Facades\\File' => $vendorDir . '/laravel/framework/src/Illuminate/Support/Facades/File.php', + 'Illuminate\\Support\\Facades\\Form' => $vendorDir . '/laravel/framework/src/Illuminate/Support/Facades/Form.php', + 'Illuminate\\Support\\Facades\\HTML' => $vendorDir . '/laravel/framework/src/Illuminate/Support/Facades/HTML.php', + 'Illuminate\\Support\\Facades\\Hash' => $vendorDir . '/laravel/framework/src/Illuminate/Support/Facades/Hash.php', + 'Illuminate\\Support\\Facades\\Input' => $vendorDir . '/laravel/framework/src/Illuminate/Support/Facades/Input.php', + 'Illuminate\\Support\\Facades\\Lang' => $vendorDir . '/laravel/framework/src/Illuminate/Support/Facades/Lang.php', + 'Illuminate\\Support\\Facades\\Log' => $vendorDir . '/laravel/framework/src/Illuminate/Support/Facades/Log.php', + 'Illuminate\\Support\\Facades\\Mail' => $vendorDir . '/laravel/framework/src/Illuminate/Support/Facades/Mail.php', + 'Illuminate\\Support\\Facades\\Paginator' => $vendorDir . '/laravel/framework/src/Illuminate/Support/Facades/Paginator.php', + 'Illuminate\\Support\\Facades\\Password' => $vendorDir . '/laravel/framework/src/Illuminate/Support/Facades/Password.php', + 'Illuminate\\Support\\Facades\\Queue' => $vendorDir . '/laravel/framework/src/Illuminate/Support/Facades/Queue.php', + 'Illuminate\\Support\\Facades\\Redirect' => $vendorDir . '/laravel/framework/src/Illuminate/Support/Facades/Redirect.php', + 'Illuminate\\Support\\Facades\\Redis' => $vendorDir . '/laravel/framework/src/Illuminate/Support/Facades/Redis.php', + 'Illuminate\\Support\\Facades\\Request' => $vendorDir . '/laravel/framework/src/Illuminate/Support/Facades/Request.php', + 'Illuminate\\Support\\Facades\\Response' => $vendorDir . '/laravel/framework/src/Illuminate/Support/Facades/Response.php', + 'Illuminate\\Support\\Facades\\Route' => $vendorDir . '/laravel/framework/src/Illuminate/Support/Facades/Route.php', + 'Illuminate\\Support\\Facades\\SSH' => $vendorDir . '/laravel/framework/src/Illuminate/Support/Facades/SSH.php', + 'Illuminate\\Support\\Facades\\Schema' => $vendorDir . '/laravel/framework/src/Illuminate/Support/Facades/Schema.php', + 'Illuminate\\Support\\Facades\\Session' => $vendorDir . '/laravel/framework/src/Illuminate/Support/Facades/Session.php', + 'Illuminate\\Support\\Facades\\URL' => $vendorDir . '/laravel/framework/src/Illuminate/Support/Facades/URL.php', + 'Illuminate\\Support\\Facades\\Validator' => $vendorDir . '/laravel/framework/src/Illuminate/Support/Facades/Validator.php', + 'Illuminate\\Support\\Facades\\View' => $vendorDir . '/laravel/framework/src/Illuminate/Support/Facades/View.php', + 'Illuminate\\Support\\Fluent' => $vendorDir . '/laravel/framework/src/Illuminate/Support/Fluent.php', + 'Illuminate\\Support\\Manager' => $vendorDir . '/laravel/framework/src/Illuminate/Support/Manager.php', + 'Illuminate\\Support\\MessageBag' => $vendorDir . '/laravel/framework/src/Illuminate/Support/MessageBag.php', + 'Illuminate\\Support\\NamespacedItemResolver' => $vendorDir . '/laravel/framework/src/Illuminate/Support/NamespacedItemResolver.php', + 'Illuminate\\Support\\Pluralizer' => $vendorDir . '/laravel/framework/src/Illuminate/Support/Pluralizer.php', + 'Illuminate\\Support\\SerializableClosure' => $vendorDir . '/laravel/framework/src/Illuminate/Support/SerializableClosure.php', + 'Illuminate\\Support\\ServiceProvider' => $vendorDir . '/laravel/framework/src/Illuminate/Support/ServiceProvider.php', + 'Illuminate\\Support\\Str' => $vendorDir . '/laravel/framework/src/Illuminate/Support/Str.php', + 'Illuminate\\Translation\\FileLoader' => $vendorDir . '/laravel/framework/src/Illuminate/Translation/FileLoader.php', + 'Illuminate\\Translation\\LoaderInterface' => $vendorDir . '/laravel/framework/src/Illuminate/Translation/LoaderInterface.php', + 'Illuminate\\Translation\\TranslationServiceProvider' => $vendorDir . '/laravel/framework/src/Illuminate/Translation/TranslationServiceProvider.php', + 'Illuminate\\Translation\\Translator' => $vendorDir . '/laravel/framework/src/Illuminate/Translation/Translator.php', + 'Illuminate\\Validation\\DatabasePresenceVerifier' => $vendorDir . '/laravel/framework/src/Illuminate/Validation/DatabasePresenceVerifier.php', + 'Illuminate\\Validation\\Factory' => $vendorDir . '/laravel/framework/src/Illuminate/Validation/Factory.php', + 'Illuminate\\Validation\\PresenceVerifierInterface' => $vendorDir . '/laravel/framework/src/Illuminate/Validation/PresenceVerifierInterface.php', + 'Illuminate\\Validation\\ValidationServiceProvider' => $vendorDir . '/laravel/framework/src/Illuminate/Validation/ValidationServiceProvider.php', + 'Illuminate\\Validation\\Validator' => $vendorDir . '/laravel/framework/src/Illuminate/Validation/Validator.php', + 'Illuminate\\View\\Compilers\\BladeCompiler' => $vendorDir . '/laravel/framework/src/Illuminate/View/Compilers/BladeCompiler.php', + 'Illuminate\\View\\Compilers\\Compiler' => $vendorDir . '/laravel/framework/src/Illuminate/View/Compilers/Compiler.php', + 'Illuminate\\View\\Compilers\\CompilerInterface' => $vendorDir . '/laravel/framework/src/Illuminate/View/Compilers/CompilerInterface.php', + 'Illuminate\\View\\Engines\\CompilerEngine' => $vendorDir . '/laravel/framework/src/Illuminate/View/Engines/CompilerEngine.php', + 'Illuminate\\View\\Engines\\Engine' => $vendorDir . '/laravel/framework/src/Illuminate/View/Engines/Engine.php', + 'Illuminate\\View\\Engines\\EngineInterface' => $vendorDir . '/laravel/framework/src/Illuminate/View/Engines/EngineInterface.php', + 'Illuminate\\View\\Engines\\EngineResolver' => $vendorDir . '/laravel/framework/src/Illuminate/View/Engines/EngineResolver.php', + 'Illuminate\\View\\Engines\\PhpEngine' => $vendorDir . '/laravel/framework/src/Illuminate/View/Engines/PhpEngine.php', + 'Illuminate\\View\\Environment' => $vendorDir . '/laravel/framework/src/Illuminate/View/Environment.php', + 'Illuminate\\View\\FileViewFinder' => $vendorDir . '/laravel/framework/src/Illuminate/View/FileViewFinder.php', + 'Illuminate\\View\\View' => $vendorDir . '/laravel/framework/src/Illuminate/View/View.php', + 'Illuminate\\View\\ViewFinderInterface' => $vendorDir . '/laravel/framework/src/Illuminate/View/ViewFinderInterface.php', + 'Illuminate\\View\\ViewServiceProvider' => $vendorDir . '/laravel/framework/src/Illuminate/View/ViewServiceProvider.php', + 'Illuminate\\Workbench\\Console\\WorkbenchMakeCommand' => $vendorDir . '/laravel/framework/src/Illuminate/Workbench/Console/WorkbenchMakeCommand.php', + 'Illuminate\\Workbench\\Package' => $vendorDir . '/laravel/framework/src/Illuminate/Workbench/Package.php', + 'Illuminate\\Workbench\\PackageCreator' => $vendorDir . '/laravel/framework/src/Illuminate/Workbench/PackageCreator.php', + 'Illuminate\\Workbench\\Starter' => $vendorDir . '/laravel/framework/src/Illuminate/Workbench/Starter.php', + 'Illuminate\\Workbench\\WorkbenchServiceProvider' => $vendorDir . '/laravel/framework/src/Illuminate/Workbench/WorkbenchServiceProvider.php', + 'Jeremeamia\\SuperClosure\\ClosureLocation' => $vendorDir . '/jeremeamia/SuperClosure/src/Jeremeamia/SuperClosure/ClosureLocation.php', + 'Jeremeamia\\SuperClosure\\ClosureParser' => $vendorDir . '/jeremeamia/SuperClosure/src/Jeremeamia/SuperClosure/ClosureParser.php', + 'Jeremeamia\\SuperClosure\\SerializableClosure' => $vendorDir . '/jeremeamia/SuperClosure/src/Jeremeamia/SuperClosure/SerializableClosure.php', + 'Jeremeamia\\SuperClosure\\Visitor\\ClosureFinderVisitor' => $vendorDir . '/jeremeamia/SuperClosure/src/Jeremeamia/SuperClosure/Visitor/ClosureFinderVisitor.php', + 'Jeremeamia\\SuperClosure\\Visitor\\MagicConstantVisitor' => $vendorDir . '/jeremeamia/SuperClosure/src/Jeremeamia/SuperClosure/Visitor/MagicConstantVisitor.php', + 'Math_BigInteger' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Math/BigInteger.php', + 'Monolog\\ErrorHandler' => $vendorDir . '/monolog/monolog/src/Monolog/ErrorHandler.php', + 'Monolog\\Formatter\\ChromePHPFormatter' => $vendorDir . '/monolog/monolog/src/Monolog/Formatter/ChromePHPFormatter.php', + 'Monolog\\Formatter\\ElasticaFormatter' => $vendorDir . '/monolog/monolog/src/Monolog/Formatter/ElasticaFormatter.php', + 'Monolog\\Formatter\\FlowdockFormatter' => $vendorDir . '/monolog/monolog/src/Monolog/Formatter/FlowdockFormatter.php', + 'Monolog\\Formatter\\FormatterInterface' => $vendorDir . '/monolog/monolog/src/Monolog/Formatter/FormatterInterface.php', + 'Monolog\\Formatter\\GelfMessageFormatter' => $vendorDir . '/monolog/monolog/src/Monolog/Formatter/GelfMessageFormatter.php', + 'Monolog\\Formatter\\HtmlFormatter' => $vendorDir . '/monolog/monolog/src/Monolog/Formatter/HtmlFormatter.php', + 'Monolog\\Formatter\\JsonFormatter' => $vendorDir . '/monolog/monolog/src/Monolog/Formatter/JsonFormatter.php', + 'Monolog\\Formatter\\LineFormatter' => $vendorDir . '/monolog/monolog/src/Monolog/Formatter/LineFormatter.php', + 'Monolog\\Formatter\\LogglyFormatter' => $vendorDir . '/monolog/monolog/src/Monolog/Formatter/LogglyFormatter.php', + 'Monolog\\Formatter\\LogstashFormatter' => $vendorDir . '/monolog/monolog/src/Monolog/Formatter/LogstashFormatter.php', + 'Monolog\\Formatter\\NormalizerFormatter' => $vendorDir . '/monolog/monolog/src/Monolog/Formatter/NormalizerFormatter.php', + 'Monolog\\Formatter\\ScalarFormatter' => $vendorDir . '/monolog/monolog/src/Monolog/Formatter/ScalarFormatter.php', + 'Monolog\\Formatter\\WildfireFormatter' => $vendorDir . '/monolog/monolog/src/Monolog/Formatter/WildfireFormatter.php', + 'Monolog\\Handler\\AbstractHandler' => $vendorDir . '/monolog/monolog/src/Monolog/Handler/AbstractHandler.php', + 'Monolog\\Handler\\AbstractProcessingHandler' => $vendorDir . '/monolog/monolog/src/Monolog/Handler/AbstractProcessingHandler.php', + 'Monolog\\Handler\\AbstractSyslogHandler' => $vendorDir . '/monolog/monolog/src/Monolog/Handler/AbstractSyslogHandler.php', + 'Monolog\\Handler\\AmqpHandler' => $vendorDir . '/monolog/monolog/src/Monolog/Handler/AmqpHandler.php', + 'Monolog\\Handler\\BrowserConsoleHandler' => $vendorDir . '/monolog/monolog/src/Monolog/Handler/BrowserConsoleHandler.php', + 'Monolog\\Handler\\BufferHandler' => $vendorDir . '/monolog/monolog/src/Monolog/Handler/BufferHandler.php', + 'Monolog\\Handler\\ChromePHPHandler' => $vendorDir . '/monolog/monolog/src/Monolog/Handler/ChromePHPHandler.php', + 'Monolog\\Handler\\CouchDBHandler' => $vendorDir . '/monolog/monolog/src/Monolog/Handler/CouchDBHandler.php', + 'Monolog\\Handler\\CubeHandler' => $vendorDir . '/monolog/monolog/src/Monolog/Handler/CubeHandler.php', + 'Monolog\\Handler\\DoctrineCouchDBHandler' => $vendorDir . '/monolog/monolog/src/Monolog/Handler/DoctrineCouchDBHandler.php', + 'Monolog\\Handler\\DynamoDbHandler' => $vendorDir . '/monolog/monolog/src/Monolog/Handler/DynamoDbHandler.php', + 'Monolog\\Handler\\ElasticSearchHandler' => $vendorDir . '/monolog/monolog/src/Monolog/Handler/ElasticSearchHandler.php', + 'Monolog\\Handler\\ErrorLogHandler' => $vendorDir . '/monolog/monolog/src/Monolog/Handler/ErrorLogHandler.php', + 'Monolog\\Handler\\FilterHandler' => $vendorDir . '/monolog/monolog/src/Monolog/Handler/FilterHandler.php', + 'Monolog\\Handler\\FingersCrossedHandler' => $vendorDir . '/monolog/monolog/src/Monolog/Handler/FingersCrossedHandler.php', + 'Monolog\\Handler\\FingersCrossed\\ActivationStrategyInterface' => $vendorDir . '/monolog/monolog/src/Monolog/Handler/FingersCrossed/ActivationStrategyInterface.php', + 'Monolog\\Handler\\FingersCrossed\\ChannelLevelActivationStrategy' => $vendorDir . '/monolog/monolog/src/Monolog/Handler/FingersCrossed/ChannelLevelActivationStrategy.php', + 'Monolog\\Handler\\FingersCrossed\\ErrorLevelActivationStrategy' => $vendorDir . '/monolog/monolog/src/Monolog/Handler/FingersCrossed/ErrorLevelActivationStrategy.php', + 'Monolog\\Handler\\FirePHPHandler' => $vendorDir . '/monolog/monolog/src/Monolog/Handler/FirePHPHandler.php', + 'Monolog\\Handler\\FlowdockHandler' => $vendorDir . '/monolog/monolog/src/Monolog/Handler/FlowdockHandler.php', + 'Monolog\\Handler\\GelfHandler' => $vendorDir . '/monolog/monolog/src/Monolog/Handler/GelfHandler.php', + 'Monolog\\Handler\\GroupHandler' => $vendorDir . '/monolog/monolog/src/Monolog/Handler/GroupHandler.php', + 'Monolog\\Handler\\HandlerInterface' => $vendorDir . '/monolog/monolog/src/Monolog/Handler/HandlerInterface.php', + 'Monolog\\Handler\\HipChatHandler' => $vendorDir . '/monolog/monolog/src/Monolog/Handler/HipChatHandler.php', + 'Monolog\\Handler\\LogEntriesHandler' => $vendorDir . '/monolog/monolog/src/Monolog/Handler/LogEntriesHandler.php', + 'Monolog\\Handler\\LogglyHandler' => $vendorDir . '/monolog/monolog/src/Monolog/Handler/LogglyHandler.php', + 'Monolog\\Handler\\MailHandler' => $vendorDir . '/monolog/monolog/src/Monolog/Handler/MailHandler.php', + 'Monolog\\Handler\\MissingExtensionException' => $vendorDir . '/monolog/monolog/src/Monolog/Handler/MissingExtensionException.php', + 'Monolog\\Handler\\MongoDBHandler' => $vendorDir . '/monolog/monolog/src/Monolog/Handler/MongoDBHandler.php', + 'Monolog\\Handler\\NativeMailerHandler' => $vendorDir . '/monolog/monolog/src/Monolog/Handler/NativeMailerHandler.php', + 'Monolog\\Handler\\NewRelicHandler' => $vendorDir . '/monolog/monolog/src/Monolog/Handler/NewRelicHandler.php', + 'Monolog\\Handler\\NullHandler' => $vendorDir . '/monolog/monolog/src/Monolog/Handler/NullHandler.php', + 'Monolog\\Handler\\PushoverHandler' => $vendorDir . '/monolog/monolog/src/Monolog/Handler/PushoverHandler.php', + 'Monolog\\Handler\\RavenHandler' => $vendorDir . '/monolog/monolog/src/Monolog/Handler/RavenHandler.php', + 'Monolog\\Handler\\RedisHandler' => $vendorDir . '/monolog/monolog/src/Monolog/Handler/RedisHandler.php', + 'Monolog\\Handler\\RollbarHandler' => $vendorDir . '/monolog/monolog/src/Monolog/Handler/RollbarHandler.php', + 'Monolog\\Handler\\RotatingFileHandler' => $vendorDir . '/monolog/monolog/src/Monolog/Handler/RotatingFileHandler.php', + 'Monolog\\Handler\\SocketHandler' => $vendorDir . '/monolog/monolog/src/Monolog/Handler/SocketHandler.php', + 'Monolog\\Handler\\StreamHandler' => $vendorDir . '/monolog/monolog/src/Monolog/Handler/StreamHandler.php', + 'Monolog\\Handler\\SwiftMailerHandler' => $vendorDir . '/monolog/monolog/src/Monolog/Handler/SwiftMailerHandler.php', + 'Monolog\\Handler\\SyslogHandler' => $vendorDir . '/monolog/monolog/src/Monolog/Handler/SyslogHandler.php', + 'Monolog\\Handler\\SyslogUdpHandler' => $vendorDir . '/monolog/monolog/src/Monolog/Handler/SyslogUdpHandler.php', + 'Monolog\\Handler\\SyslogUdp\\UdpSocket' => $vendorDir . '/monolog/monolog/src/Monolog/Handler/SyslogUdp/UdpSocket.php', + 'Monolog\\Handler\\TestHandler' => $vendorDir . '/monolog/monolog/src/Monolog/Handler/TestHandler.php', + 'Monolog\\Handler\\ZendMonitorHandler' => $vendorDir . '/monolog/monolog/src/Monolog/Handler/ZendMonitorHandler.php', + 'Monolog\\Logger' => $vendorDir . '/monolog/monolog/src/Monolog/Logger.php', + 'Monolog\\Processor\\GitProcessor' => $vendorDir . '/monolog/monolog/src/Monolog/Processor/GitProcessor.php', + 'Monolog\\Processor\\IntrospectionProcessor' => $vendorDir . '/monolog/monolog/src/Monolog/Processor/IntrospectionProcessor.php', + 'Monolog\\Processor\\MemoryPeakUsageProcessor' => $vendorDir . '/monolog/monolog/src/Monolog/Processor/MemoryPeakUsageProcessor.php', + 'Monolog\\Processor\\MemoryProcessor' => $vendorDir . '/monolog/monolog/src/Monolog/Processor/MemoryProcessor.php', + 'Monolog\\Processor\\MemoryUsageProcessor' => $vendorDir . '/monolog/monolog/src/Monolog/Processor/MemoryUsageProcessor.php', + 'Monolog\\Processor\\ProcessIdProcessor' => $vendorDir . '/monolog/monolog/src/Monolog/Processor/ProcessIdProcessor.php', + 'Monolog\\Processor\\PsrLogMessageProcessor' => $vendorDir . '/monolog/monolog/src/Monolog/Processor/PsrLogMessageProcessor.php', + 'Monolog\\Processor\\TagProcessor' => $vendorDir . '/monolog/monolog/src/Monolog/Processor/TagProcessor.php', + 'Monolog\\Processor\\UidProcessor' => $vendorDir . '/monolog/monolog/src/Monolog/Processor/UidProcessor.php', + 'Monolog\\Processor\\WebProcessor' => $vendorDir . '/monolog/monolog/src/Monolog/Processor/WebProcessor.php', + 'Monolog\\Registry' => $vendorDir . '/monolog/monolog/src/Monolog/Registry.php', + 'Net_SCP' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Net/SCP.php', + 'Net_SFTP' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Net/SFTP.php', + 'Net_SFTP_Stream' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Net/SFTP/Stream.php', + 'Net_SSH1' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Net/SSH1.php', + 'Net_SSH2' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Net/SSH2.php', + 'Normalizer' => $vendorDir . '/patchwork/utf8/class/Normalizer.php', + 'PHPParser_Autoloader' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Autoloader.php', + 'PHPParser_Builder' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Builder.php', + 'PHPParser_BuilderAbstract' => $vendorDir . '/nikic/php-parser/lib/PHPParser/BuilderAbstract.php', + 'PHPParser_BuilderFactory' => $vendorDir . '/nikic/php-parser/lib/PHPParser/BuilderFactory.php', + 'PHPParser_Builder_Class' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Builder/Class.php', + 'PHPParser_Builder_Function' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Builder/Function.php', + 'PHPParser_Builder_Interface' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Builder/Interface.php', + 'PHPParser_Builder_Method' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Builder/Method.php', + 'PHPParser_Builder_Param' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Builder/Param.php', + 'PHPParser_Builder_Property' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Builder/Property.php', + 'PHPParser_Comment' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Comment.php', + 'PHPParser_Comment_Doc' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Comment/Doc.php', + 'PHPParser_Error' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Error.php', + 'PHPParser_Lexer' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Lexer.php', + 'PHPParser_Lexer_Emulative' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Lexer/Emulative.php', + 'PHPParser_Node' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node.php', + 'PHPParser_NodeAbstract' => $vendorDir . '/nikic/php-parser/lib/PHPParser/NodeAbstract.php', + 'PHPParser_NodeDumper' => $vendorDir . '/nikic/php-parser/lib/PHPParser/NodeDumper.php', + 'PHPParser_NodeTraverser' => $vendorDir . '/nikic/php-parser/lib/PHPParser/NodeTraverser.php', + 'PHPParser_NodeTraverserInterface' => $vendorDir . '/nikic/php-parser/lib/PHPParser/NodeTraverserInterface.php', + 'PHPParser_NodeVisitor' => $vendorDir . '/nikic/php-parser/lib/PHPParser/NodeVisitor.php', + 'PHPParser_NodeVisitorAbstract' => $vendorDir . '/nikic/php-parser/lib/PHPParser/NodeVisitorAbstract.php', + 'PHPParser_NodeVisitor_NameResolver' => $vendorDir . '/nikic/php-parser/lib/PHPParser/NodeVisitor/NameResolver.php', + 'PHPParser_Node_Arg' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Arg.php', + 'PHPParser_Node_Const' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Const.php', + 'PHPParser_Node_Expr' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Expr.php', + 'PHPParser_Node_Expr_Array' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Expr/Array.php', + 'PHPParser_Node_Expr_ArrayDimFetch' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Expr/ArrayDimFetch.php', + 'PHPParser_Node_Expr_ArrayItem' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Expr/ArrayItem.php', + 'PHPParser_Node_Expr_Assign' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Expr/Assign.php', + 'PHPParser_Node_Expr_AssignBitwiseAnd' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Expr/AssignBitwiseAnd.php', + 'PHPParser_Node_Expr_AssignBitwiseOr' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Expr/AssignBitwiseOr.php', + 'PHPParser_Node_Expr_AssignBitwiseXor' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Expr/AssignBitwiseXor.php', + 'PHPParser_Node_Expr_AssignConcat' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Expr/AssignConcat.php', + 'PHPParser_Node_Expr_AssignDiv' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Expr/AssignDiv.php', + 'PHPParser_Node_Expr_AssignMinus' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Expr/AssignMinus.php', + 'PHPParser_Node_Expr_AssignMod' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Expr/AssignMod.php', + 'PHPParser_Node_Expr_AssignMul' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Expr/AssignMul.php', + 'PHPParser_Node_Expr_AssignPlus' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Expr/AssignPlus.php', + 'PHPParser_Node_Expr_AssignRef' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Expr/AssignRef.php', + 'PHPParser_Node_Expr_AssignShiftLeft' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Expr/AssignShiftLeft.php', + 'PHPParser_Node_Expr_AssignShiftRight' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Expr/AssignShiftRight.php', + 'PHPParser_Node_Expr_BitwiseAnd' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Expr/BitwiseAnd.php', + 'PHPParser_Node_Expr_BitwiseNot' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Expr/BitwiseNot.php', + 'PHPParser_Node_Expr_BitwiseOr' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Expr/BitwiseOr.php', + 'PHPParser_Node_Expr_BitwiseXor' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Expr/BitwiseXor.php', + 'PHPParser_Node_Expr_BooleanAnd' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Expr/BooleanAnd.php', + 'PHPParser_Node_Expr_BooleanNot' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Expr/BooleanNot.php', + 'PHPParser_Node_Expr_BooleanOr' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Expr/BooleanOr.php', + 'PHPParser_Node_Expr_Cast' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Expr/Cast.php', + 'PHPParser_Node_Expr_Cast_Array' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Expr/Cast/Array.php', + 'PHPParser_Node_Expr_Cast_Bool' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Expr/Cast/Bool.php', + 'PHPParser_Node_Expr_Cast_Double' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Expr/Cast/Double.php', + 'PHPParser_Node_Expr_Cast_Int' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Expr/Cast/Int.php', + 'PHPParser_Node_Expr_Cast_Object' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Expr/Cast/Object.php', + 'PHPParser_Node_Expr_Cast_String' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Expr/Cast/String.php', + 'PHPParser_Node_Expr_Cast_Unset' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Expr/Cast/Unset.php', + 'PHPParser_Node_Expr_ClassConstFetch' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Expr/ClassConstFetch.php', + 'PHPParser_Node_Expr_Clone' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Expr/Clone.php', + 'PHPParser_Node_Expr_Closure' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Expr/Closure.php', + 'PHPParser_Node_Expr_ClosureUse' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Expr/ClosureUse.php', + 'PHPParser_Node_Expr_Concat' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Expr/Concat.php', + 'PHPParser_Node_Expr_ConstFetch' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Expr/ConstFetch.php', + 'PHPParser_Node_Expr_Div' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Expr/Div.php', + 'PHPParser_Node_Expr_Empty' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Expr/Empty.php', + 'PHPParser_Node_Expr_Equal' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Expr/Equal.php', + 'PHPParser_Node_Expr_ErrorSuppress' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Expr/ErrorSuppress.php', + 'PHPParser_Node_Expr_Eval' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Expr/Eval.php', + 'PHPParser_Node_Expr_Exit' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Expr/Exit.php', + 'PHPParser_Node_Expr_FuncCall' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Expr/FuncCall.php', + 'PHPParser_Node_Expr_Greater' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Expr/Greater.php', + 'PHPParser_Node_Expr_GreaterOrEqual' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Expr/GreaterOrEqual.php', + 'PHPParser_Node_Expr_Identical' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Expr/Identical.php', + 'PHPParser_Node_Expr_Include' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Expr/Include.php', + 'PHPParser_Node_Expr_Instanceof' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Expr/Instanceof.php', + 'PHPParser_Node_Expr_Isset' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Expr/Isset.php', + 'PHPParser_Node_Expr_List' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Expr/List.php', + 'PHPParser_Node_Expr_LogicalAnd' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Expr/LogicalAnd.php', + 'PHPParser_Node_Expr_LogicalOr' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Expr/LogicalOr.php', + 'PHPParser_Node_Expr_LogicalXor' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Expr/LogicalXor.php', + 'PHPParser_Node_Expr_MethodCall' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Expr/MethodCall.php', + 'PHPParser_Node_Expr_Minus' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Expr/Minus.php', + 'PHPParser_Node_Expr_Mod' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Expr/Mod.php', + 'PHPParser_Node_Expr_Mul' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Expr/Mul.php', + 'PHPParser_Node_Expr_New' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Expr/New.php', + 'PHPParser_Node_Expr_NotEqual' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Expr/NotEqual.php', + 'PHPParser_Node_Expr_NotIdentical' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Expr/NotIdentical.php', + 'PHPParser_Node_Expr_Plus' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Expr/Plus.php', + 'PHPParser_Node_Expr_PostDec' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Expr/PostDec.php', + 'PHPParser_Node_Expr_PostInc' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Expr/PostInc.php', + 'PHPParser_Node_Expr_PreDec' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Expr/PreDec.php', + 'PHPParser_Node_Expr_PreInc' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Expr/PreInc.php', + 'PHPParser_Node_Expr_Print' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Expr/Print.php', + 'PHPParser_Node_Expr_PropertyFetch' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Expr/PropertyFetch.php', + 'PHPParser_Node_Expr_ShellExec' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Expr/ShellExec.php', + 'PHPParser_Node_Expr_ShiftLeft' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Expr/ShiftLeft.php', + 'PHPParser_Node_Expr_ShiftRight' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Expr/ShiftRight.php', + 'PHPParser_Node_Expr_Smaller' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Expr/Smaller.php', + 'PHPParser_Node_Expr_SmallerOrEqual' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Expr/SmallerOrEqual.php', + 'PHPParser_Node_Expr_StaticCall' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Expr/StaticCall.php', + 'PHPParser_Node_Expr_StaticPropertyFetch' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Expr/StaticPropertyFetch.php', + 'PHPParser_Node_Expr_Ternary' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Expr/Ternary.php', + 'PHPParser_Node_Expr_UnaryMinus' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Expr/UnaryMinus.php', + 'PHPParser_Node_Expr_UnaryPlus' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Expr/UnaryPlus.php', + 'PHPParser_Node_Expr_Variable' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Expr/Variable.php', + 'PHPParser_Node_Expr_Yield' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Expr/Yield.php', + 'PHPParser_Node_Name' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Name.php', + 'PHPParser_Node_Name_FullyQualified' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Name/FullyQualified.php', + 'PHPParser_Node_Name_Relative' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Name/Relative.php', + 'PHPParser_Node_Param' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Param.php', + 'PHPParser_Node_Scalar' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Scalar.php', + 'PHPParser_Node_Scalar_ClassConst' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Scalar/ClassConst.php', + 'PHPParser_Node_Scalar_DNumber' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Scalar/DNumber.php', + 'PHPParser_Node_Scalar_DirConst' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Scalar/DirConst.php', + 'PHPParser_Node_Scalar_Encapsed' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Scalar/Encapsed.php', + 'PHPParser_Node_Scalar_FileConst' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Scalar/FileConst.php', + 'PHPParser_Node_Scalar_FuncConst' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Scalar/FuncConst.php', + 'PHPParser_Node_Scalar_LNumber' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Scalar/LNumber.php', + 'PHPParser_Node_Scalar_LineConst' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Scalar/LineConst.php', + 'PHPParser_Node_Scalar_MethodConst' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Scalar/MethodConst.php', + 'PHPParser_Node_Scalar_NSConst' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Scalar/NSConst.php', + 'PHPParser_Node_Scalar_String' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Scalar/String.php', + 'PHPParser_Node_Scalar_TraitConst' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Scalar/TraitConst.php', + 'PHPParser_Node_Stmt' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Stmt.php', + 'PHPParser_Node_Stmt_Break' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Stmt/Break.php', + 'PHPParser_Node_Stmt_Case' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Stmt/Case.php', + 'PHPParser_Node_Stmt_Catch' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Stmt/Catch.php', + 'PHPParser_Node_Stmt_Class' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Stmt/Class.php', + 'PHPParser_Node_Stmt_ClassConst' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Stmt/ClassConst.php', + 'PHPParser_Node_Stmt_ClassMethod' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Stmt/ClassMethod.php', + 'PHPParser_Node_Stmt_Const' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Stmt/Const.php', + 'PHPParser_Node_Stmt_Continue' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Stmt/Continue.php', + 'PHPParser_Node_Stmt_Declare' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Stmt/Declare.php', + 'PHPParser_Node_Stmt_DeclareDeclare' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Stmt/DeclareDeclare.php', + 'PHPParser_Node_Stmt_Do' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Stmt/Do.php', + 'PHPParser_Node_Stmt_Echo' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Stmt/Echo.php', + 'PHPParser_Node_Stmt_Else' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Stmt/Else.php', + 'PHPParser_Node_Stmt_ElseIf' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Stmt/ElseIf.php', + 'PHPParser_Node_Stmt_For' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Stmt/For.php', + 'PHPParser_Node_Stmt_Foreach' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Stmt/Foreach.php', + 'PHPParser_Node_Stmt_Function' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Stmt/Function.php', + 'PHPParser_Node_Stmt_Global' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Stmt/Global.php', + 'PHPParser_Node_Stmt_Goto' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Stmt/Goto.php', + 'PHPParser_Node_Stmt_HaltCompiler' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Stmt/HaltCompiler.php', + 'PHPParser_Node_Stmt_If' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Stmt/If.php', + 'PHPParser_Node_Stmt_InlineHTML' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Stmt/InlineHTML.php', + 'PHPParser_Node_Stmt_Interface' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Stmt/Interface.php', + 'PHPParser_Node_Stmt_Label' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Stmt/Label.php', + 'PHPParser_Node_Stmt_Namespace' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Stmt/Namespace.php', + 'PHPParser_Node_Stmt_Property' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Stmt/Property.php', + 'PHPParser_Node_Stmt_PropertyProperty' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Stmt/PropertyProperty.php', + 'PHPParser_Node_Stmt_Return' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Stmt/Return.php', + 'PHPParser_Node_Stmt_Static' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Stmt/Static.php', + 'PHPParser_Node_Stmt_StaticVar' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Stmt/StaticVar.php', + 'PHPParser_Node_Stmt_Switch' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Stmt/Switch.php', + 'PHPParser_Node_Stmt_Throw' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Stmt/Throw.php', + 'PHPParser_Node_Stmt_Trait' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Stmt/Trait.php', + 'PHPParser_Node_Stmt_TraitUse' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Stmt/TraitUse.php', + 'PHPParser_Node_Stmt_TraitUseAdaptation' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Stmt/TraitUseAdaptation.php', + 'PHPParser_Node_Stmt_TraitUseAdaptation_Alias' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Stmt/TraitUseAdaptation/Alias.php', + 'PHPParser_Node_Stmt_TraitUseAdaptation_Precedence' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Stmt/TraitUseAdaptation/Precedence.php', + 'PHPParser_Node_Stmt_TryCatch' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Stmt/TryCatch.php', + 'PHPParser_Node_Stmt_Unset' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Stmt/Unset.php', + 'PHPParser_Node_Stmt_Use' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Stmt/Use.php', + 'PHPParser_Node_Stmt_UseUse' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Stmt/UseUse.php', + 'PHPParser_Node_Stmt_While' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Node/Stmt/While.php', + 'PHPParser_Parser' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Parser.php', + 'PHPParser_PrettyPrinterAbstract' => $vendorDir . '/nikic/php-parser/lib/PHPParser/PrettyPrinterAbstract.php', + 'PHPParser_PrettyPrinter_Default' => $vendorDir . '/nikic/php-parser/lib/PHPParser/PrettyPrinter/Default.php', + 'PHPParser_PrettyPrinter_Zend' => $vendorDir . '/nikic/php-parser/lib/PHPParser/PrettyPrinter/Zend.php', + 'PHPParser_Serializer' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Serializer.php', + 'PHPParser_Serializer_XML' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Serializer/XML.php', + 'PHPParser_Template' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Template.php', + 'PHPParser_TemplateLoader' => $vendorDir . '/nikic/php-parser/lib/PHPParser/TemplateLoader.php', + 'PHPParser_Unserializer' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Unserializer.php', + 'PHPParser_Unserializer_XML' => $vendorDir . '/nikic/php-parser/lib/PHPParser/Unserializer/XML.php', + 'Patchwork\\PHP\\Shim\\Iconv' => $vendorDir . '/patchwork/utf8/class/Patchwork/PHP/Shim/Iconv.php', + 'Patchwork\\PHP\\Shim\\Intl' => $vendorDir . '/patchwork/utf8/class/Patchwork/PHP/Shim/Intl.php', + 'Patchwork\\PHP\\Shim\\Mbstring' => $vendorDir . '/patchwork/utf8/class/Patchwork/PHP/Shim/Mbstring.php', + 'Patchwork\\PHP\\Shim\\Normalizer' => $vendorDir . '/patchwork/utf8/class/Patchwork/PHP/Shim/Normalizer.php', + 'Patchwork\\PHP\\Shim\\Xml' => $vendorDir . '/patchwork/utf8/class/Patchwork/PHP/Shim/Xml.php', + 'Patchwork\\TurkishUtf8' => $vendorDir . '/patchwork/utf8/class/Patchwork/TurkishUtf8.php', + 'Patchwork\\Utf8' => $vendorDir . '/patchwork/utf8/class/Patchwork/Utf8.php', + 'Patchwork\\Utf8\\Bootup' => $vendorDir . '/patchwork/utf8/class/Patchwork/Utf8/Bootup.php', + 'Predis\\Autoloader' => $vendorDir . '/predis/predis/lib/Predis/Autoloader.php', + 'Predis\\BasicClientInterface' => $vendorDir . '/predis/predis/lib/Predis/BasicClientInterface.php', + 'Predis\\Client' => $vendorDir . '/predis/predis/lib/Predis/Client.php', + 'Predis\\ClientException' => $vendorDir . '/predis/predis/lib/Predis/ClientException.php', + 'Predis\\ClientInterface' => $vendorDir . '/predis/predis/lib/Predis/ClientInterface.php', + 'Predis\\Cluster\\CommandHashStrategyInterface' => $vendorDir . '/predis/predis/lib/Predis/Cluster/CommandHashStrategyInterface.php', + 'Predis\\Cluster\\Distribution\\DistributionStrategyInterface' => $vendorDir . '/predis/predis/lib/Predis/Cluster/Distribution/DistributionStrategyInterface.php', + 'Predis\\Cluster\\Distribution\\EmptyRingException' => $vendorDir . '/predis/predis/lib/Predis/Cluster/Distribution/EmptyRingException.php', + 'Predis\\Cluster\\Distribution\\HashRing' => $vendorDir . '/predis/predis/lib/Predis/Cluster/Distribution/HashRing.php', + 'Predis\\Cluster\\Distribution\\KetamaPureRing' => $vendorDir . '/predis/predis/lib/Predis/Cluster/Distribution/KetamaPureRing.php', + 'Predis\\Cluster\\Hash\\CRC16HashGenerator' => $vendorDir . '/predis/predis/lib/Predis/Cluster/Hash/CRC16HashGenerator.php', + 'Predis\\Cluster\\Hash\\HashGeneratorInterface' => $vendorDir . '/predis/predis/lib/Predis/Cluster/Hash/HashGeneratorInterface.php', + 'Predis\\Cluster\\PredisClusterHashStrategy' => $vendorDir . '/predis/predis/lib/Predis/Cluster/PredisClusterHashStrategy.php', + 'Predis\\Cluster\\RedisClusterHashStrategy' => $vendorDir . '/predis/predis/lib/Predis/Cluster/RedisClusterHashStrategy.php', + 'Predis\\Collection\\Iterator\\CursorBasedIterator' => $vendorDir . '/predis/predis/lib/Predis/Collection/Iterator/CursorBasedIterator.php', + 'Predis\\Collection\\Iterator\\HashKey' => $vendorDir . '/predis/predis/lib/Predis/Collection/Iterator/HashKey.php', + 'Predis\\Collection\\Iterator\\Keyspace' => $vendorDir . '/predis/predis/lib/Predis/Collection/Iterator/Keyspace.php', + 'Predis\\Collection\\Iterator\\ListKey' => $vendorDir . '/predis/predis/lib/Predis/Collection/Iterator/ListKey.php', + 'Predis\\Collection\\Iterator\\SetKey' => $vendorDir . '/predis/predis/lib/Predis/Collection/Iterator/SetKey.php', + 'Predis\\Collection\\Iterator\\SortedSetKey' => $vendorDir . '/predis/predis/lib/Predis/Collection/Iterator/SortedSetKey.php', + 'Predis\\Command\\AbstractCommand' => $vendorDir . '/predis/predis/lib/Predis/Command/AbstractCommand.php', + 'Predis\\Command\\CommandInterface' => $vendorDir . '/predis/predis/lib/Predis/Command/CommandInterface.php', + 'Predis\\Command\\ConnectionAuth' => $vendorDir . '/predis/predis/lib/Predis/Command/ConnectionAuth.php', + 'Predis\\Command\\ConnectionEcho' => $vendorDir . '/predis/predis/lib/Predis/Command/ConnectionEcho.php', + 'Predis\\Command\\ConnectionPing' => $vendorDir . '/predis/predis/lib/Predis/Command/ConnectionPing.php', + 'Predis\\Command\\ConnectionQuit' => $vendorDir . '/predis/predis/lib/Predis/Command/ConnectionQuit.php', + 'Predis\\Command\\ConnectionSelect' => $vendorDir . '/predis/predis/lib/Predis/Command/ConnectionSelect.php', + 'Predis\\Command\\HashDelete' => $vendorDir . '/predis/predis/lib/Predis/Command/HashDelete.php', + 'Predis\\Command\\HashExists' => $vendorDir . '/predis/predis/lib/Predis/Command/HashExists.php', + 'Predis\\Command\\HashGet' => $vendorDir . '/predis/predis/lib/Predis/Command/HashGet.php', + 'Predis\\Command\\HashGetAll' => $vendorDir . '/predis/predis/lib/Predis/Command/HashGetAll.php', + 'Predis\\Command\\HashGetMultiple' => $vendorDir . '/predis/predis/lib/Predis/Command/HashGetMultiple.php', + 'Predis\\Command\\HashIncrementBy' => $vendorDir . '/predis/predis/lib/Predis/Command/HashIncrementBy.php', + 'Predis\\Command\\HashIncrementByFloat' => $vendorDir . '/predis/predis/lib/Predis/Command/HashIncrementByFloat.php', + 'Predis\\Command\\HashKeys' => $vendorDir . '/predis/predis/lib/Predis/Command/HashKeys.php', + 'Predis\\Command\\HashLength' => $vendorDir . '/predis/predis/lib/Predis/Command/HashLength.php', + 'Predis\\Command\\HashScan' => $vendorDir . '/predis/predis/lib/Predis/Command/HashScan.php', + 'Predis\\Command\\HashSet' => $vendorDir . '/predis/predis/lib/Predis/Command/HashSet.php', + 'Predis\\Command\\HashSetMultiple' => $vendorDir . '/predis/predis/lib/Predis/Command/HashSetMultiple.php', + 'Predis\\Command\\HashSetPreserve' => $vendorDir . '/predis/predis/lib/Predis/Command/HashSetPreserve.php', + 'Predis\\Command\\HashValues' => $vendorDir . '/predis/predis/lib/Predis/Command/HashValues.php', + 'Predis\\Command\\KeyDelete' => $vendorDir . '/predis/predis/lib/Predis/Command/KeyDelete.php', + 'Predis\\Command\\KeyDump' => $vendorDir . '/predis/predis/lib/Predis/Command/KeyDump.php', + 'Predis\\Command\\KeyExists' => $vendorDir . '/predis/predis/lib/Predis/Command/KeyExists.php', + 'Predis\\Command\\KeyExpire' => $vendorDir . '/predis/predis/lib/Predis/Command/KeyExpire.php', + 'Predis\\Command\\KeyExpireAt' => $vendorDir . '/predis/predis/lib/Predis/Command/KeyExpireAt.php', + 'Predis\\Command\\KeyKeys' => $vendorDir . '/predis/predis/lib/Predis/Command/KeyKeys.php', + 'Predis\\Command\\KeyKeysV12x' => $vendorDir . '/predis/predis/lib/Predis/Command/KeyKeysV12x.php', + 'Predis\\Command\\KeyMove' => $vendorDir . '/predis/predis/lib/Predis/Command/KeyMove.php', + 'Predis\\Command\\KeyPersist' => $vendorDir . '/predis/predis/lib/Predis/Command/KeyPersist.php', + 'Predis\\Command\\KeyPreciseExpire' => $vendorDir . '/predis/predis/lib/Predis/Command/KeyPreciseExpire.php', + 'Predis\\Command\\KeyPreciseExpireAt' => $vendorDir . '/predis/predis/lib/Predis/Command/KeyPreciseExpireAt.php', + 'Predis\\Command\\KeyPreciseTimeToLive' => $vendorDir . '/predis/predis/lib/Predis/Command/KeyPreciseTimeToLive.php', + 'Predis\\Command\\KeyRandom' => $vendorDir . '/predis/predis/lib/Predis/Command/KeyRandom.php', + 'Predis\\Command\\KeyRename' => $vendorDir . '/predis/predis/lib/Predis/Command/KeyRename.php', + 'Predis\\Command\\KeyRenamePreserve' => $vendorDir . '/predis/predis/lib/Predis/Command/KeyRenamePreserve.php', + 'Predis\\Command\\KeyRestore' => $vendorDir . '/predis/predis/lib/Predis/Command/KeyRestore.php', + 'Predis\\Command\\KeyScan' => $vendorDir . '/predis/predis/lib/Predis/Command/KeyScan.php', + 'Predis\\Command\\KeySort' => $vendorDir . '/predis/predis/lib/Predis/Command/KeySort.php', + 'Predis\\Command\\KeyTimeToLive' => $vendorDir . '/predis/predis/lib/Predis/Command/KeyTimeToLive.php', + 'Predis\\Command\\KeyType' => $vendorDir . '/predis/predis/lib/Predis/Command/KeyType.php', + 'Predis\\Command\\ListIndex' => $vendorDir . '/predis/predis/lib/Predis/Command/ListIndex.php', + 'Predis\\Command\\ListInsert' => $vendorDir . '/predis/predis/lib/Predis/Command/ListInsert.php', + 'Predis\\Command\\ListLength' => $vendorDir . '/predis/predis/lib/Predis/Command/ListLength.php', + 'Predis\\Command\\ListPopFirst' => $vendorDir . '/predis/predis/lib/Predis/Command/ListPopFirst.php', + 'Predis\\Command\\ListPopFirstBlocking' => $vendorDir . '/predis/predis/lib/Predis/Command/ListPopFirstBlocking.php', + 'Predis\\Command\\ListPopLast' => $vendorDir . '/predis/predis/lib/Predis/Command/ListPopLast.php', + 'Predis\\Command\\ListPopLastBlocking' => $vendorDir . '/predis/predis/lib/Predis/Command/ListPopLastBlocking.php', + 'Predis\\Command\\ListPopLastPushHead' => $vendorDir . '/predis/predis/lib/Predis/Command/ListPopLastPushHead.php', + 'Predis\\Command\\ListPopLastPushHeadBlocking' => $vendorDir . '/predis/predis/lib/Predis/Command/ListPopLastPushHeadBlocking.php', + 'Predis\\Command\\ListPushHead' => $vendorDir . '/predis/predis/lib/Predis/Command/ListPushHead.php', + 'Predis\\Command\\ListPushHeadX' => $vendorDir . '/predis/predis/lib/Predis/Command/ListPushHeadX.php', + 'Predis\\Command\\ListPushTail' => $vendorDir . '/predis/predis/lib/Predis/Command/ListPushTail.php', + 'Predis\\Command\\ListPushTailX' => $vendorDir . '/predis/predis/lib/Predis/Command/ListPushTailX.php', + 'Predis\\Command\\ListRange' => $vendorDir . '/predis/predis/lib/Predis/Command/ListRange.php', + 'Predis\\Command\\ListRemove' => $vendorDir . '/predis/predis/lib/Predis/Command/ListRemove.php', + 'Predis\\Command\\ListSet' => $vendorDir . '/predis/predis/lib/Predis/Command/ListSet.php', + 'Predis\\Command\\ListTrim' => $vendorDir . '/predis/predis/lib/Predis/Command/ListTrim.php', + 'Predis\\Command\\PrefixHelpers' => $vendorDir . '/predis/predis/lib/Predis/Command/PrefixHelpers.php', + 'Predis\\Command\\PrefixableCommand' => $vendorDir . '/predis/predis/lib/Predis/Command/PrefixableCommand.php', + 'Predis\\Command\\PrefixableCommandInterface' => $vendorDir . '/predis/predis/lib/Predis/Command/PrefixableCommandInterface.php', + 'Predis\\Command\\Processor\\CommandProcessingInterface' => $vendorDir . '/predis/predis/lib/Predis/Command/Processor/CommandProcessingInterface.php', + 'Predis\\Command\\Processor\\CommandProcessorChainInterface' => $vendorDir . '/predis/predis/lib/Predis/Command/Processor/CommandProcessorChainInterface.php', + 'Predis\\Command\\Processor\\CommandProcessorInterface' => $vendorDir . '/predis/predis/lib/Predis/Command/Processor/CommandProcessorInterface.php', + 'Predis\\Command\\Processor\\KeyPrefixProcessor' => $vendorDir . '/predis/predis/lib/Predis/Command/Processor/KeyPrefixProcessor.php', + 'Predis\\Command\\Processor\\ProcessorChain' => $vendorDir . '/predis/predis/lib/Predis/Command/Processor/ProcessorChain.php', + 'Predis\\Command\\PubSubPublish' => $vendorDir . '/predis/predis/lib/Predis/Command/PubSubPublish.php', + 'Predis\\Command\\PubSubSubscribe' => $vendorDir . '/predis/predis/lib/Predis/Command/PubSubSubscribe.php', + 'Predis\\Command\\PubSubSubscribeByPattern' => $vendorDir . '/predis/predis/lib/Predis/Command/PubSubSubscribeByPattern.php', + 'Predis\\Command\\PubSubUnsubscribe' => $vendorDir . '/predis/predis/lib/Predis/Command/PubSubUnsubscribe.php', + 'Predis\\Command\\PubSubUnsubscribeByPattern' => $vendorDir . '/predis/predis/lib/Predis/Command/PubSubUnsubscribeByPattern.php', + 'Predis\\Command\\RawCommand' => $vendorDir . '/predis/predis/lib/Predis/Command/RawCommand.php', + 'Predis\\Command\\ScriptedCommand' => $vendorDir . '/predis/predis/lib/Predis/Command/ScriptedCommand.php', + 'Predis\\Command\\ServerBackgroundRewriteAOF' => $vendorDir . '/predis/predis/lib/Predis/Command/ServerBackgroundRewriteAOF.php', + 'Predis\\Command\\ServerBackgroundSave' => $vendorDir . '/predis/predis/lib/Predis/Command/ServerBackgroundSave.php', + 'Predis\\Command\\ServerClient' => $vendorDir . '/predis/predis/lib/Predis/Command/ServerClient.php', + 'Predis\\Command\\ServerConfig' => $vendorDir . '/predis/predis/lib/Predis/Command/ServerConfig.php', + 'Predis\\Command\\ServerDatabaseSize' => $vendorDir . '/predis/predis/lib/Predis/Command/ServerDatabaseSize.php', + 'Predis\\Command\\ServerEval' => $vendorDir . '/predis/predis/lib/Predis/Command/ServerEval.php', + 'Predis\\Command\\ServerEvalSHA' => $vendorDir . '/predis/predis/lib/Predis/Command/ServerEvalSHA.php', + 'Predis\\Command\\ServerFlushAll' => $vendorDir . '/predis/predis/lib/Predis/Command/ServerFlushAll.php', + 'Predis\\Command\\ServerFlushDatabase' => $vendorDir . '/predis/predis/lib/Predis/Command/ServerFlushDatabase.php', + 'Predis\\Command\\ServerInfo' => $vendorDir . '/predis/predis/lib/Predis/Command/ServerInfo.php', + 'Predis\\Command\\ServerInfoV26x' => $vendorDir . '/predis/predis/lib/Predis/Command/ServerInfoV26x.php', + 'Predis\\Command\\ServerLastSave' => $vendorDir . '/predis/predis/lib/Predis/Command/ServerLastSave.php', + 'Predis\\Command\\ServerMonitor' => $vendorDir . '/predis/predis/lib/Predis/Command/ServerMonitor.php', + 'Predis\\Command\\ServerObject' => $vendorDir . '/predis/predis/lib/Predis/Command/ServerObject.php', + 'Predis\\Command\\ServerSave' => $vendorDir . '/predis/predis/lib/Predis/Command/ServerSave.php', + 'Predis\\Command\\ServerScript' => $vendorDir . '/predis/predis/lib/Predis/Command/ServerScript.php', + 'Predis\\Command\\ServerShutdown' => $vendorDir . '/predis/predis/lib/Predis/Command/ServerShutdown.php', + 'Predis\\Command\\ServerSlaveOf' => $vendorDir . '/predis/predis/lib/Predis/Command/ServerSlaveOf.php', + 'Predis\\Command\\ServerSlowlog' => $vendorDir . '/predis/predis/lib/Predis/Command/ServerSlowlog.php', + 'Predis\\Command\\ServerTime' => $vendorDir . '/predis/predis/lib/Predis/Command/ServerTime.php', + 'Predis\\Command\\SetAdd' => $vendorDir . '/predis/predis/lib/Predis/Command/SetAdd.php', + 'Predis\\Command\\SetCardinality' => $vendorDir . '/predis/predis/lib/Predis/Command/SetCardinality.php', + 'Predis\\Command\\SetDifference' => $vendorDir . '/predis/predis/lib/Predis/Command/SetDifference.php', + 'Predis\\Command\\SetDifferenceStore' => $vendorDir . '/predis/predis/lib/Predis/Command/SetDifferenceStore.php', + 'Predis\\Command\\SetIntersection' => $vendorDir . '/predis/predis/lib/Predis/Command/SetIntersection.php', + 'Predis\\Command\\SetIntersectionStore' => $vendorDir . '/predis/predis/lib/Predis/Command/SetIntersectionStore.php', + 'Predis\\Command\\SetIsMember' => $vendorDir . '/predis/predis/lib/Predis/Command/SetIsMember.php', + 'Predis\\Command\\SetMembers' => $vendorDir . '/predis/predis/lib/Predis/Command/SetMembers.php', + 'Predis\\Command\\SetMove' => $vendorDir . '/predis/predis/lib/Predis/Command/SetMove.php', + 'Predis\\Command\\SetPop' => $vendorDir . '/predis/predis/lib/Predis/Command/SetPop.php', + 'Predis\\Command\\SetRandomMember' => $vendorDir . '/predis/predis/lib/Predis/Command/SetRandomMember.php', + 'Predis\\Command\\SetRemove' => $vendorDir . '/predis/predis/lib/Predis/Command/SetRemove.php', + 'Predis\\Command\\SetScan' => $vendorDir . '/predis/predis/lib/Predis/Command/SetScan.php', + 'Predis\\Command\\SetUnion' => $vendorDir . '/predis/predis/lib/Predis/Command/SetUnion.php', + 'Predis\\Command\\SetUnionStore' => $vendorDir . '/predis/predis/lib/Predis/Command/SetUnionStore.php', + 'Predis\\Command\\StringAppend' => $vendorDir . '/predis/predis/lib/Predis/Command/StringAppend.php', + 'Predis\\Command\\StringBitCount' => $vendorDir . '/predis/predis/lib/Predis/Command/StringBitCount.php', + 'Predis\\Command\\StringBitOp' => $vendorDir . '/predis/predis/lib/Predis/Command/StringBitOp.php', + 'Predis\\Command\\StringDecrement' => $vendorDir . '/predis/predis/lib/Predis/Command/StringDecrement.php', + 'Predis\\Command\\StringDecrementBy' => $vendorDir . '/predis/predis/lib/Predis/Command/StringDecrementBy.php', + 'Predis\\Command\\StringGet' => $vendorDir . '/predis/predis/lib/Predis/Command/StringGet.php', + 'Predis\\Command\\StringGetBit' => $vendorDir . '/predis/predis/lib/Predis/Command/StringGetBit.php', + 'Predis\\Command\\StringGetMultiple' => $vendorDir . '/predis/predis/lib/Predis/Command/StringGetMultiple.php', + 'Predis\\Command\\StringGetRange' => $vendorDir . '/predis/predis/lib/Predis/Command/StringGetRange.php', + 'Predis\\Command\\StringGetSet' => $vendorDir . '/predis/predis/lib/Predis/Command/StringGetSet.php', + 'Predis\\Command\\StringIncrement' => $vendorDir . '/predis/predis/lib/Predis/Command/StringIncrement.php', + 'Predis\\Command\\StringIncrementBy' => $vendorDir . '/predis/predis/lib/Predis/Command/StringIncrementBy.php', + 'Predis\\Command\\StringIncrementByFloat' => $vendorDir . '/predis/predis/lib/Predis/Command/StringIncrementByFloat.php', + 'Predis\\Command\\StringPreciseSetExpire' => $vendorDir . '/predis/predis/lib/Predis/Command/StringPreciseSetExpire.php', + 'Predis\\Command\\StringSet' => $vendorDir . '/predis/predis/lib/Predis/Command/StringSet.php', + 'Predis\\Command\\StringSetBit' => $vendorDir . '/predis/predis/lib/Predis/Command/StringSetBit.php', + 'Predis\\Command\\StringSetExpire' => $vendorDir . '/predis/predis/lib/Predis/Command/StringSetExpire.php', + 'Predis\\Command\\StringSetMultiple' => $vendorDir . '/predis/predis/lib/Predis/Command/StringSetMultiple.php', + 'Predis\\Command\\StringSetMultiplePreserve' => $vendorDir . '/predis/predis/lib/Predis/Command/StringSetMultiplePreserve.php', + 'Predis\\Command\\StringSetPreserve' => $vendorDir . '/predis/predis/lib/Predis/Command/StringSetPreserve.php', + 'Predis\\Command\\StringSetRange' => $vendorDir . '/predis/predis/lib/Predis/Command/StringSetRange.php', + 'Predis\\Command\\StringStrlen' => $vendorDir . '/predis/predis/lib/Predis/Command/StringStrlen.php', + 'Predis\\Command\\StringSubstr' => $vendorDir . '/predis/predis/lib/Predis/Command/StringSubstr.php', + 'Predis\\Command\\TransactionDiscard' => $vendorDir . '/predis/predis/lib/Predis/Command/TransactionDiscard.php', + 'Predis\\Command\\TransactionExec' => $vendorDir . '/predis/predis/lib/Predis/Command/TransactionExec.php', + 'Predis\\Command\\TransactionMulti' => $vendorDir . '/predis/predis/lib/Predis/Command/TransactionMulti.php', + 'Predis\\Command\\TransactionUnwatch' => $vendorDir . '/predis/predis/lib/Predis/Command/TransactionUnwatch.php', + 'Predis\\Command\\TransactionWatch' => $vendorDir . '/predis/predis/lib/Predis/Command/TransactionWatch.php', + 'Predis\\Command\\ZSetAdd' => $vendorDir . '/predis/predis/lib/Predis/Command/ZSetAdd.php', + 'Predis\\Command\\ZSetCardinality' => $vendorDir . '/predis/predis/lib/Predis/Command/ZSetCardinality.php', + 'Predis\\Command\\ZSetCount' => $vendorDir . '/predis/predis/lib/Predis/Command/ZSetCount.php', + 'Predis\\Command\\ZSetIncrementBy' => $vendorDir . '/predis/predis/lib/Predis/Command/ZSetIncrementBy.php', + 'Predis\\Command\\ZSetIntersectionStore' => $vendorDir . '/predis/predis/lib/Predis/Command/ZSetIntersectionStore.php', + 'Predis\\Command\\ZSetRange' => $vendorDir . '/predis/predis/lib/Predis/Command/ZSetRange.php', + 'Predis\\Command\\ZSetRangeByScore' => $vendorDir . '/predis/predis/lib/Predis/Command/ZSetRangeByScore.php', + 'Predis\\Command\\ZSetRank' => $vendorDir . '/predis/predis/lib/Predis/Command/ZSetRank.php', + 'Predis\\Command\\ZSetRemove' => $vendorDir . '/predis/predis/lib/Predis/Command/ZSetRemove.php', + 'Predis\\Command\\ZSetRemoveRangeByRank' => $vendorDir . '/predis/predis/lib/Predis/Command/ZSetRemoveRangeByRank.php', + 'Predis\\Command\\ZSetRemoveRangeByScore' => $vendorDir . '/predis/predis/lib/Predis/Command/ZSetRemoveRangeByScore.php', + 'Predis\\Command\\ZSetReverseRange' => $vendorDir . '/predis/predis/lib/Predis/Command/ZSetReverseRange.php', + 'Predis\\Command\\ZSetReverseRangeByScore' => $vendorDir . '/predis/predis/lib/Predis/Command/ZSetReverseRangeByScore.php', + 'Predis\\Command\\ZSetReverseRank' => $vendorDir . '/predis/predis/lib/Predis/Command/ZSetReverseRank.php', + 'Predis\\Command\\ZSetScan' => $vendorDir . '/predis/predis/lib/Predis/Command/ZSetScan.php', + 'Predis\\Command\\ZSetScore' => $vendorDir . '/predis/predis/lib/Predis/Command/ZSetScore.php', + 'Predis\\Command\\ZSetUnionStore' => $vendorDir . '/predis/predis/lib/Predis/Command/ZSetUnionStore.php', + 'Predis\\CommunicationException' => $vendorDir . '/predis/predis/lib/Predis/CommunicationException.php', + 'Predis\\Connection\\AbstractConnection' => $vendorDir . '/predis/predis/lib/Predis/Connection/AbstractConnection.php', + 'Predis\\Connection\\AggregatedConnectionInterface' => $vendorDir . '/predis/predis/lib/Predis/Connection/AggregatedConnectionInterface.php', + 'Predis\\Connection\\ClusterConnectionInterface' => $vendorDir . '/predis/predis/lib/Predis/Connection/ClusterConnectionInterface.php', + 'Predis\\Connection\\ComposableConnectionInterface' => $vendorDir . '/predis/predis/lib/Predis/Connection/ComposableConnectionInterface.php', + 'Predis\\Connection\\ComposableStreamConnection' => $vendorDir . '/predis/predis/lib/Predis/Connection/ComposableStreamConnection.php', + 'Predis\\Connection\\ConnectionException' => $vendorDir . '/predis/predis/lib/Predis/Connection/ConnectionException.php', + 'Predis\\Connection\\ConnectionFactory' => $vendorDir . '/predis/predis/lib/Predis/Connection/ConnectionFactory.php', + 'Predis\\Connection\\ConnectionFactoryInterface' => $vendorDir . '/predis/predis/lib/Predis/Connection/ConnectionFactoryInterface.php', + 'Predis\\Connection\\ConnectionInterface' => $vendorDir . '/predis/predis/lib/Predis/Connection/ConnectionInterface.php', + 'Predis\\Connection\\ConnectionParameters' => $vendorDir . '/predis/predis/lib/Predis/Connection/ConnectionParameters.php', + 'Predis\\Connection\\ConnectionParametersInterface' => $vendorDir . '/predis/predis/lib/Predis/Connection/ConnectionParametersInterface.php', + 'Predis\\Connection\\MasterSlaveReplication' => $vendorDir . '/predis/predis/lib/Predis/Connection/MasterSlaveReplication.php', + 'Predis\\Connection\\PhpiredisConnection' => $vendorDir . '/predis/predis/lib/Predis/Connection/PhpiredisConnection.php', + 'Predis\\Connection\\PhpiredisStreamConnection' => $vendorDir . '/predis/predis/lib/Predis/Connection/PhpiredisStreamConnection.php', + 'Predis\\Connection\\PredisCluster' => $vendorDir . '/predis/predis/lib/Predis/Connection/PredisCluster.php', + 'Predis\\Connection\\RedisCluster' => $vendorDir . '/predis/predis/lib/Predis/Connection/RedisCluster.php', + 'Predis\\Connection\\ReplicationConnectionInterface' => $vendorDir . '/predis/predis/lib/Predis/Connection/ReplicationConnectionInterface.php', + 'Predis\\Connection\\SingleConnectionInterface' => $vendorDir . '/predis/predis/lib/Predis/Connection/SingleConnectionInterface.php', + 'Predis\\Connection\\StreamConnection' => $vendorDir . '/predis/predis/lib/Predis/Connection/StreamConnection.php', + 'Predis\\Connection\\WebdisConnection' => $vendorDir . '/predis/predis/lib/Predis/Connection/WebdisConnection.php', + 'Predis\\ExecutableContextInterface' => $vendorDir . '/predis/predis/lib/Predis/ExecutableContextInterface.php', + 'Predis\\Helpers' => $vendorDir . '/predis/predis/lib/Predis/Helpers.php', + 'Predis\\Iterator\\MultiBulkResponse' => $vendorDir . '/predis/predis/lib/Predis/Iterator/MultiBulkResponse.php', + 'Predis\\Iterator\\MultiBulkResponseSimple' => $vendorDir . '/predis/predis/lib/Predis/Iterator/MultiBulkResponseSimple.php', + 'Predis\\Iterator\\MultiBulkResponseTuple' => $vendorDir . '/predis/predis/lib/Predis/Iterator/MultiBulkResponseTuple.php', + 'Predis\\Monitor\\MonitorContext' => $vendorDir . '/predis/predis/lib/Predis/Monitor/MonitorContext.php', + 'Predis\\NotSupportedException' => $vendorDir . '/predis/predis/lib/Predis/NotSupportedException.php', + 'Predis\\Option\\AbstractOption' => $vendorDir . '/predis/predis/lib/Predis/Option/AbstractOption.php', + 'Predis\\Option\\ClientCluster' => $vendorDir . '/predis/predis/lib/Predis/Option/ClientCluster.php', + 'Predis\\Option\\ClientConnectionFactory' => $vendorDir . '/predis/predis/lib/Predis/Option/ClientConnectionFactory.php', + 'Predis\\Option\\ClientExceptions' => $vendorDir . '/predis/predis/lib/Predis/Option/ClientExceptions.php', + 'Predis\\Option\\ClientOptions' => $vendorDir . '/predis/predis/lib/Predis/Option/ClientOptions.php', + 'Predis\\Option\\ClientOptionsInterface' => $vendorDir . '/predis/predis/lib/Predis/Option/ClientOptionsInterface.php', + 'Predis\\Option\\ClientPrefix' => $vendorDir . '/predis/predis/lib/Predis/Option/ClientPrefix.php', + 'Predis\\Option\\ClientProfile' => $vendorDir . '/predis/predis/lib/Predis/Option/ClientProfile.php', + 'Predis\\Option\\ClientReplication' => $vendorDir . '/predis/predis/lib/Predis/Option/ClientReplication.php', + 'Predis\\Option\\CustomOption' => $vendorDir . '/predis/predis/lib/Predis/Option/CustomOption.php', + 'Predis\\Option\\OptionInterface' => $vendorDir . '/predis/predis/lib/Predis/Option/OptionInterface.php', + 'Predis\\Pipeline\\FireAndForgetExecutor' => $vendorDir . '/predis/predis/lib/Predis/Pipeline/FireAndForgetExecutor.php', + 'Predis\\Pipeline\\MultiExecExecutor' => $vendorDir . '/predis/predis/lib/Predis/Pipeline/MultiExecExecutor.php', + 'Predis\\Pipeline\\PipelineContext' => $vendorDir . '/predis/predis/lib/Predis/Pipeline/PipelineContext.php', + 'Predis\\Pipeline\\PipelineExecutorInterface' => $vendorDir . '/predis/predis/lib/Predis/Pipeline/PipelineExecutorInterface.php', + 'Predis\\Pipeline\\SafeClusterExecutor' => $vendorDir . '/predis/predis/lib/Predis/Pipeline/SafeClusterExecutor.php', + 'Predis\\Pipeline\\SafeExecutor' => $vendorDir . '/predis/predis/lib/Predis/Pipeline/SafeExecutor.php', + 'Predis\\Pipeline\\StandardExecutor' => $vendorDir . '/predis/predis/lib/Predis/Pipeline/StandardExecutor.php', + 'Predis\\PredisException' => $vendorDir . '/predis/predis/lib/Predis/PredisException.php', + 'Predis\\Profile\\ServerProfile' => $vendorDir . '/predis/predis/lib/Predis/Profile/ServerProfile.php', + 'Predis\\Profile\\ServerProfileInterface' => $vendorDir . '/predis/predis/lib/Predis/Profile/ServerProfileInterface.php', + 'Predis\\Profile\\ServerVersion12' => $vendorDir . '/predis/predis/lib/Predis/Profile/ServerVersion12.php', + 'Predis\\Profile\\ServerVersion20' => $vendorDir . '/predis/predis/lib/Predis/Profile/ServerVersion20.php', + 'Predis\\Profile\\ServerVersion22' => $vendorDir . '/predis/predis/lib/Predis/Profile/ServerVersion22.php', + 'Predis\\Profile\\ServerVersion24' => $vendorDir . '/predis/predis/lib/Predis/Profile/ServerVersion24.php', + 'Predis\\Profile\\ServerVersion26' => $vendorDir . '/predis/predis/lib/Predis/Profile/ServerVersion26.php', + 'Predis\\Profile\\ServerVersion28' => $vendorDir . '/predis/predis/lib/Predis/Profile/ServerVersion28.php', + 'Predis\\Profile\\ServerVersionNext' => $vendorDir . '/predis/predis/lib/Predis/Profile/ServerVersionNext.php', + 'Predis\\Protocol\\CommandSerializerInterface' => $vendorDir . '/predis/predis/lib/Predis/Protocol/CommandSerializerInterface.php', + 'Predis\\Protocol\\ComposableProtocolInterface' => $vendorDir . '/predis/predis/lib/Predis/Protocol/ComposableProtocolInterface.php', + 'Predis\\Protocol\\ProtocolException' => $vendorDir . '/predis/predis/lib/Predis/Protocol/ProtocolException.php', + 'Predis\\Protocol\\ProtocolInterface' => $vendorDir . '/predis/predis/lib/Predis/Protocol/ProtocolInterface.php', + 'Predis\\Protocol\\ResponseHandlerInterface' => $vendorDir . '/predis/predis/lib/Predis/Protocol/ResponseHandlerInterface.php', + 'Predis\\Protocol\\ResponseReaderInterface' => $vendorDir . '/predis/predis/lib/Predis/Protocol/ResponseReaderInterface.php', + 'Predis\\Protocol\\Text\\ComposableTextProtocol' => $vendorDir . '/predis/predis/lib/Predis/Protocol/Text/ComposableTextProtocol.php', + 'Predis\\Protocol\\Text\\ResponseBulkHandler' => $vendorDir . '/predis/predis/lib/Predis/Protocol/Text/ResponseBulkHandler.php', + 'Predis\\Protocol\\Text\\ResponseErrorHandler' => $vendorDir . '/predis/predis/lib/Predis/Protocol/Text/ResponseErrorHandler.php', + 'Predis\\Protocol\\Text\\ResponseIntegerHandler' => $vendorDir . '/predis/predis/lib/Predis/Protocol/Text/ResponseIntegerHandler.php', + 'Predis\\Protocol\\Text\\ResponseMultiBulkHandler' => $vendorDir . '/predis/predis/lib/Predis/Protocol/Text/ResponseMultiBulkHandler.php', + 'Predis\\Protocol\\Text\\ResponseMultiBulkStreamHandler' => $vendorDir . '/predis/predis/lib/Predis/Protocol/Text/ResponseMultiBulkStreamHandler.php', + 'Predis\\Protocol\\Text\\ResponseStatusHandler' => $vendorDir . '/predis/predis/lib/Predis/Protocol/Text/ResponseStatusHandler.php', + 'Predis\\Protocol\\Text\\TextCommandSerializer' => $vendorDir . '/predis/predis/lib/Predis/Protocol/Text/TextCommandSerializer.php', + 'Predis\\Protocol\\Text\\TextProtocol' => $vendorDir . '/predis/predis/lib/Predis/Protocol/Text/TextProtocol.php', + 'Predis\\Protocol\\Text\\TextResponseReader' => $vendorDir . '/predis/predis/lib/Predis/Protocol/Text/TextResponseReader.php', + 'Predis\\PubSub\\AbstractPubSubContext' => $vendorDir . '/predis/predis/lib/Predis/PubSub/AbstractPubSubContext.php', + 'Predis\\PubSub\\DispatcherLoop' => $vendorDir . '/predis/predis/lib/Predis/PubSub/DispatcherLoop.php', + 'Predis\\PubSub\\PubSubContext' => $vendorDir . '/predis/predis/lib/Predis/PubSub/PubSubContext.php', + 'Predis\\Replication\\ReplicationStrategy' => $vendorDir . '/predis/predis/lib/Predis/Replication/ReplicationStrategy.php', + 'Predis\\ResponseError' => $vendorDir . '/predis/predis/lib/Predis/ResponseError.php', + 'Predis\\ResponseErrorInterface' => $vendorDir . '/predis/predis/lib/Predis/ResponseErrorInterface.php', + 'Predis\\ResponseObjectInterface' => $vendorDir . '/predis/predis/lib/Predis/ResponseObjectInterface.php', + 'Predis\\ResponseQueued' => $vendorDir . '/predis/predis/lib/Predis/ResponseQueued.php', + 'Predis\\ServerException' => $vendorDir . '/predis/predis/lib/Predis/ServerException.php', + 'Predis\\Session\\SessionHandler' => $vendorDir . '/predis/predis/lib/Predis/Session/SessionHandler.php', + 'Predis\\Transaction\\AbortedMultiExecException' => $vendorDir . '/predis/predis/lib/Predis/Transaction/AbortedMultiExecException.php', + 'Predis\\Transaction\\MultiExecContext' => $vendorDir . '/predis/predis/lib/Predis/Transaction/MultiExecContext.php', + 'Psr\\Log\\AbstractLogger' => $vendorDir . '/psr/log/Psr/Log/AbstractLogger.php', + 'Psr\\Log\\InvalidArgumentException' => $vendorDir . '/psr/log/Psr/Log/InvalidArgumentException.php', + 'Psr\\Log\\LogLevel' => $vendorDir . '/psr/log/Psr/Log/LogLevel.php', + 'Psr\\Log\\LoggerAwareInterface' => $vendorDir . '/psr/log/Psr/Log/LoggerAwareInterface.php', + 'Psr\\Log\\LoggerAwareTrait' => $vendorDir . '/psr/log/Psr/Log/LoggerAwareTrait.php', + 'Psr\\Log\\LoggerInterface' => $vendorDir . '/psr/log/Psr/Log/LoggerInterface.php', + 'Psr\\Log\\LoggerTrait' => $vendorDir . '/psr/log/Psr/Log/LoggerTrait.php', + 'Psr\\Log\\NullLogger' => $vendorDir . '/psr/log/Psr/Log/NullLogger.php', + 'SessionHandlerInterface' => $vendorDir . '/symfony/http-foundation/Symfony/Component/HttpFoundation/Resources/stubs/SessionHandlerInterface.php', + 'Stack\\Builder' => $vendorDir . '/stack/builder/src/Stack/Builder.php', + 'Stack\\StackedHttpKernel' => $vendorDir . '/stack/builder/src/Stack/StackedHttpKernel.php', + 'Symfony\\Component\\BrowserKit\\Client' => $vendorDir . '/symfony/browser-kit/Symfony/Component/BrowserKit/Client.php', + 'Symfony\\Component\\BrowserKit\\Cookie' => $vendorDir . '/symfony/browser-kit/Symfony/Component/BrowserKit/Cookie.php', + 'Symfony\\Component\\BrowserKit\\CookieJar' => $vendorDir . '/symfony/browser-kit/Symfony/Component/BrowserKit/CookieJar.php', + 'Symfony\\Component\\BrowserKit\\History' => $vendorDir . '/symfony/browser-kit/Symfony/Component/BrowserKit/History.php', + 'Symfony\\Component\\BrowserKit\\Request' => $vendorDir . '/symfony/browser-kit/Symfony/Component/BrowserKit/Request.php', + 'Symfony\\Component\\BrowserKit\\Response' => $vendorDir . '/symfony/browser-kit/Symfony/Component/BrowserKit/Response.php', + 'Symfony\\Component\\Console\\Application' => $vendorDir . '/symfony/console/Symfony/Component/Console/Application.php', + 'Symfony\\Component\\Console\\Command\\Command' => $vendorDir . '/symfony/console/Symfony/Component/Console/Command/Command.php', + 'Symfony\\Component\\Console\\Command\\HelpCommand' => $vendorDir . '/symfony/console/Symfony/Component/Console/Command/HelpCommand.php', + 'Symfony\\Component\\Console\\Command\\ListCommand' => $vendorDir . '/symfony/console/Symfony/Component/Console/Command/ListCommand.php', + 'Symfony\\Component\\Console\\ConsoleEvents' => $vendorDir . '/symfony/console/Symfony/Component/Console/ConsoleEvents.php', + 'Symfony\\Component\\Console\\Descriptor\\ApplicationDescription' => $vendorDir . '/symfony/console/Symfony/Component/Console/Descriptor/ApplicationDescription.php', + 'Symfony\\Component\\Console\\Descriptor\\Descriptor' => $vendorDir . '/symfony/console/Symfony/Component/Console/Descriptor/Descriptor.php', + 'Symfony\\Component\\Console\\Descriptor\\DescriptorInterface' => $vendorDir . '/symfony/console/Symfony/Component/Console/Descriptor/DescriptorInterface.php', + 'Symfony\\Component\\Console\\Descriptor\\JsonDescriptor' => $vendorDir . '/symfony/console/Symfony/Component/Console/Descriptor/JsonDescriptor.php', + 'Symfony\\Component\\Console\\Descriptor\\MarkdownDescriptor' => $vendorDir . '/symfony/console/Symfony/Component/Console/Descriptor/MarkdownDescriptor.php', + 'Symfony\\Component\\Console\\Descriptor\\TextDescriptor' => $vendorDir . '/symfony/console/Symfony/Component/Console/Descriptor/TextDescriptor.php', + 'Symfony\\Component\\Console\\Descriptor\\XmlDescriptor' => $vendorDir . '/symfony/console/Symfony/Component/Console/Descriptor/XmlDescriptor.php', + 'Symfony\\Component\\Console\\Event\\ConsoleCommandEvent' => $vendorDir . '/symfony/console/Symfony/Component/Console/Event/ConsoleCommandEvent.php', + 'Symfony\\Component\\Console\\Event\\ConsoleEvent' => $vendorDir . '/symfony/console/Symfony/Component/Console/Event/ConsoleEvent.php', + 'Symfony\\Component\\Console\\Event\\ConsoleExceptionEvent' => $vendorDir . '/symfony/console/Symfony/Component/Console/Event/ConsoleExceptionEvent.php', + 'Symfony\\Component\\Console\\Event\\ConsoleTerminateEvent' => $vendorDir . '/symfony/console/Symfony/Component/Console/Event/ConsoleTerminateEvent.php', + 'Symfony\\Component\\Console\\Formatter\\OutputFormatter' => $vendorDir . '/symfony/console/Symfony/Component/Console/Formatter/OutputFormatter.php', + 'Symfony\\Component\\Console\\Formatter\\OutputFormatterInterface' => $vendorDir . '/symfony/console/Symfony/Component/Console/Formatter/OutputFormatterInterface.php', + 'Symfony\\Component\\Console\\Formatter\\OutputFormatterStyle' => $vendorDir . '/symfony/console/Symfony/Component/Console/Formatter/OutputFormatterStyle.php', + 'Symfony\\Component\\Console\\Formatter\\OutputFormatterStyleInterface' => $vendorDir . '/symfony/console/Symfony/Component/Console/Formatter/OutputFormatterStyleInterface.php', + 'Symfony\\Component\\Console\\Formatter\\OutputFormatterStyleStack' => $vendorDir . '/symfony/console/Symfony/Component/Console/Formatter/OutputFormatterStyleStack.php', + 'Symfony\\Component\\Console\\Helper\\DescriptorHelper' => $vendorDir . '/symfony/console/Symfony/Component/Console/Helper/DescriptorHelper.php', + 'Symfony\\Component\\Console\\Helper\\DialogHelper' => $vendorDir . '/symfony/console/Symfony/Component/Console/Helper/DialogHelper.php', + 'Symfony\\Component\\Console\\Helper\\FormatterHelper' => $vendorDir . '/symfony/console/Symfony/Component/Console/Helper/FormatterHelper.php', + 'Symfony\\Component\\Console\\Helper\\Helper' => $vendorDir . '/symfony/console/Symfony/Component/Console/Helper/Helper.php', + 'Symfony\\Component\\Console\\Helper\\HelperInterface' => $vendorDir . '/symfony/console/Symfony/Component/Console/Helper/HelperInterface.php', + 'Symfony\\Component\\Console\\Helper\\HelperSet' => $vendorDir . '/symfony/console/Symfony/Component/Console/Helper/HelperSet.php', + 'Symfony\\Component\\Console\\Helper\\InputAwareHelper' => $vendorDir . '/symfony/console/Symfony/Component/Console/Helper/InputAwareHelper.php', + 'Symfony\\Component\\Console\\Helper\\ProgressHelper' => $vendorDir . '/symfony/console/Symfony/Component/Console/Helper/ProgressHelper.php', + 'Symfony\\Component\\Console\\Helper\\TableHelper' => $vendorDir . '/symfony/console/Symfony/Component/Console/Helper/TableHelper.php', + 'Symfony\\Component\\Console\\Input\\ArgvInput' => $vendorDir . '/symfony/console/Symfony/Component/Console/Input/ArgvInput.php', + 'Symfony\\Component\\Console\\Input\\ArrayInput' => $vendorDir . '/symfony/console/Symfony/Component/Console/Input/ArrayInput.php', + 'Symfony\\Component\\Console\\Input\\Input' => $vendorDir . '/symfony/console/Symfony/Component/Console/Input/Input.php', + 'Symfony\\Component\\Console\\Input\\InputArgument' => $vendorDir . '/symfony/console/Symfony/Component/Console/Input/InputArgument.php', + 'Symfony\\Component\\Console\\Input\\InputAwareInterface' => $vendorDir . '/symfony/console/Symfony/Component/Console/Input/InputAwareInterface.php', + 'Symfony\\Component\\Console\\Input\\InputDefinition' => $vendorDir . '/symfony/console/Symfony/Component/Console/Input/InputDefinition.php', + 'Symfony\\Component\\Console\\Input\\InputInterface' => $vendorDir . '/symfony/console/Symfony/Component/Console/Input/InputInterface.php', + 'Symfony\\Component\\Console\\Input\\InputOption' => $vendorDir . '/symfony/console/Symfony/Component/Console/Input/InputOption.php', + 'Symfony\\Component\\Console\\Input\\StringInput' => $vendorDir . '/symfony/console/Symfony/Component/Console/Input/StringInput.php', + 'Symfony\\Component\\Console\\Output\\BufferedOutput' => $vendorDir . '/symfony/console/Symfony/Component/Console/Output/BufferedOutput.php', + 'Symfony\\Component\\Console\\Output\\ConsoleOutput' => $vendorDir . '/symfony/console/Symfony/Component/Console/Output/ConsoleOutput.php', + 'Symfony\\Component\\Console\\Output\\ConsoleOutputInterface' => $vendorDir . '/symfony/console/Symfony/Component/Console/Output/ConsoleOutputInterface.php', + 'Symfony\\Component\\Console\\Output\\NullOutput' => $vendorDir . '/symfony/console/Symfony/Component/Console/Output/NullOutput.php', + 'Symfony\\Component\\Console\\Output\\Output' => $vendorDir . '/symfony/console/Symfony/Component/Console/Output/Output.php', + 'Symfony\\Component\\Console\\Output\\OutputInterface' => $vendorDir . '/symfony/console/Symfony/Component/Console/Output/OutputInterface.php', + 'Symfony\\Component\\Console\\Output\\StreamOutput' => $vendorDir . '/symfony/console/Symfony/Component/Console/Output/StreamOutput.php', + 'Symfony\\Component\\Console\\Shell' => $vendorDir . '/symfony/console/Symfony/Component/Console/Shell.php', + 'Symfony\\Component\\Console\\Tester\\ApplicationTester' => $vendorDir . '/symfony/console/Symfony/Component/Console/Tester/ApplicationTester.php', + 'Symfony\\Component\\Console\\Tester\\CommandTester' => $vendorDir . '/symfony/console/Symfony/Component/Console/Tester/CommandTester.php', + 'Symfony\\Component\\Console\\Tests\\Descriptor\\ObjectsProvider' => $vendorDir . '/symfony/console/Symfony/Component/Console/Tests/Descriptor/ObjectsProvider.php', + 'Symfony\\Component\\Console\\Tests\\Fixtures\\DescriptorApplication1' => $vendorDir . '/symfony/console/Symfony/Component/Console/Tests/Fixtures/DescriptorApplication1.php', + 'Symfony\\Component\\Console\\Tests\\Fixtures\\DescriptorApplication2' => $vendorDir . '/symfony/console/Symfony/Component/Console/Tests/Fixtures/DescriptorApplication2.php', + 'Symfony\\Component\\Console\\Tests\\Fixtures\\DescriptorCommand1' => $vendorDir . '/symfony/console/Symfony/Component/Console/Tests/Fixtures/DescriptorCommand1.php', + 'Symfony\\Component\\Console\\Tests\\Fixtures\\DescriptorCommand2' => $vendorDir . '/symfony/console/Symfony/Component/Console/Tests/Fixtures/DescriptorCommand2.php', + 'Symfony\\Component\\CssSelector\\CssSelector' => $vendorDir . '/symfony/css-selector/Symfony/Component/CssSelector/CssSelector.php', + 'Symfony\\Component\\CssSelector\\Exception\\ExceptionInterface' => $vendorDir . '/symfony/css-selector/Symfony/Component/CssSelector/Exception/ExceptionInterface.php', + 'Symfony\\Component\\CssSelector\\Exception\\ExpressionErrorException' => $vendorDir . '/symfony/css-selector/Symfony/Component/CssSelector/Exception/ExpressionErrorException.php', + 'Symfony\\Component\\CssSelector\\Exception\\InternalErrorException' => $vendorDir . '/symfony/css-selector/Symfony/Component/CssSelector/Exception/InternalErrorException.php', + 'Symfony\\Component\\CssSelector\\Exception\\ParseException' => $vendorDir . '/symfony/css-selector/Symfony/Component/CssSelector/Exception/ParseException.php', + 'Symfony\\Component\\CssSelector\\Exception\\SyntaxErrorException' => $vendorDir . '/symfony/css-selector/Symfony/Component/CssSelector/Exception/SyntaxErrorException.php', + 'Symfony\\Component\\CssSelector\\Node\\AbstractNode' => $vendorDir . '/symfony/css-selector/Symfony/Component/CssSelector/Node/AbstractNode.php', + 'Symfony\\Component\\CssSelector\\Node\\AttributeNode' => $vendorDir . '/symfony/css-selector/Symfony/Component/CssSelector/Node/AttributeNode.php', + 'Symfony\\Component\\CssSelector\\Node\\ClassNode' => $vendorDir . '/symfony/css-selector/Symfony/Component/CssSelector/Node/ClassNode.php', + 'Symfony\\Component\\CssSelector\\Node\\CombinedSelectorNode' => $vendorDir . '/symfony/css-selector/Symfony/Component/CssSelector/Node/CombinedSelectorNode.php', + 'Symfony\\Component\\CssSelector\\Node\\ElementNode' => $vendorDir . '/symfony/css-selector/Symfony/Component/CssSelector/Node/ElementNode.php', + 'Symfony\\Component\\CssSelector\\Node\\FunctionNode' => $vendorDir . '/symfony/css-selector/Symfony/Component/CssSelector/Node/FunctionNode.php', + 'Symfony\\Component\\CssSelector\\Node\\HashNode' => $vendorDir . '/symfony/css-selector/Symfony/Component/CssSelector/Node/HashNode.php', + 'Symfony\\Component\\CssSelector\\Node\\NegationNode' => $vendorDir . '/symfony/css-selector/Symfony/Component/CssSelector/Node/NegationNode.php', + 'Symfony\\Component\\CssSelector\\Node\\NodeInterface' => $vendorDir . '/symfony/css-selector/Symfony/Component/CssSelector/Node/NodeInterface.php', + 'Symfony\\Component\\CssSelector\\Node\\PseudoNode' => $vendorDir . '/symfony/css-selector/Symfony/Component/CssSelector/Node/PseudoNode.php', + 'Symfony\\Component\\CssSelector\\Node\\SelectorNode' => $vendorDir . '/symfony/css-selector/Symfony/Component/CssSelector/Node/SelectorNode.php', + 'Symfony\\Component\\CssSelector\\Node\\Specificity' => $vendorDir . '/symfony/css-selector/Symfony/Component/CssSelector/Node/Specificity.php', + 'Symfony\\Component\\CssSelector\\Parser\\Handler\\CommentHandler' => $vendorDir . '/symfony/css-selector/Symfony/Component/CssSelector/Parser/Handler/CommentHandler.php', + 'Symfony\\Component\\CssSelector\\Parser\\Handler\\HandlerInterface' => $vendorDir . '/symfony/css-selector/Symfony/Component/CssSelector/Parser/Handler/HandlerInterface.php', + 'Symfony\\Component\\CssSelector\\Parser\\Handler\\HashHandler' => $vendorDir . '/symfony/css-selector/Symfony/Component/CssSelector/Parser/Handler/HashHandler.php', + 'Symfony\\Component\\CssSelector\\Parser\\Handler\\IdentifierHandler' => $vendorDir . '/symfony/css-selector/Symfony/Component/CssSelector/Parser/Handler/IdentifierHandler.php', + 'Symfony\\Component\\CssSelector\\Parser\\Handler\\NumberHandler' => $vendorDir . '/symfony/css-selector/Symfony/Component/CssSelector/Parser/Handler/NumberHandler.php', + 'Symfony\\Component\\CssSelector\\Parser\\Handler\\StringHandler' => $vendorDir . '/symfony/css-selector/Symfony/Component/CssSelector/Parser/Handler/StringHandler.php', + 'Symfony\\Component\\CssSelector\\Parser\\Handler\\WhitespaceHandler' => $vendorDir . '/symfony/css-selector/Symfony/Component/CssSelector/Parser/Handler/WhitespaceHandler.php', + 'Symfony\\Component\\CssSelector\\Parser\\Parser' => $vendorDir . '/symfony/css-selector/Symfony/Component/CssSelector/Parser/Parser.php', + 'Symfony\\Component\\CssSelector\\Parser\\ParserInterface' => $vendorDir . '/symfony/css-selector/Symfony/Component/CssSelector/Parser/ParserInterface.php', + 'Symfony\\Component\\CssSelector\\Parser\\Reader' => $vendorDir . '/symfony/css-selector/Symfony/Component/CssSelector/Parser/Reader.php', + 'Symfony\\Component\\CssSelector\\Parser\\Shortcut\\ClassParser' => $vendorDir . '/symfony/css-selector/Symfony/Component/CssSelector/Parser/Shortcut/ClassParser.php', + 'Symfony\\Component\\CssSelector\\Parser\\Shortcut\\ElementParser' => $vendorDir . '/symfony/css-selector/Symfony/Component/CssSelector/Parser/Shortcut/ElementParser.php', + 'Symfony\\Component\\CssSelector\\Parser\\Shortcut\\EmptyStringParser' => $vendorDir . '/symfony/css-selector/Symfony/Component/CssSelector/Parser/Shortcut/EmptyStringParser.php', + 'Symfony\\Component\\CssSelector\\Parser\\Shortcut\\HashParser' => $vendorDir . '/symfony/css-selector/Symfony/Component/CssSelector/Parser/Shortcut/HashParser.php', + 'Symfony\\Component\\CssSelector\\Parser\\Token' => $vendorDir . '/symfony/css-selector/Symfony/Component/CssSelector/Parser/Token.php', + 'Symfony\\Component\\CssSelector\\Parser\\TokenStream' => $vendorDir . '/symfony/css-selector/Symfony/Component/CssSelector/Parser/TokenStream.php', + 'Symfony\\Component\\CssSelector\\Parser\\Tokenizer\\Tokenizer' => $vendorDir . '/symfony/css-selector/Symfony/Component/CssSelector/Parser/Tokenizer/Tokenizer.php', + 'Symfony\\Component\\CssSelector\\Parser\\Tokenizer\\TokenizerEscaping' => $vendorDir . '/symfony/css-selector/Symfony/Component/CssSelector/Parser/Tokenizer/TokenizerEscaping.php', + 'Symfony\\Component\\CssSelector\\Parser\\Tokenizer\\TokenizerPatterns' => $vendorDir . '/symfony/css-selector/Symfony/Component/CssSelector/Parser/Tokenizer/TokenizerPatterns.php', + 'Symfony\\Component\\CssSelector\\XPath\\Extension\\AbstractExtension' => $vendorDir . '/symfony/css-selector/Symfony/Component/CssSelector/XPath/Extension/AbstractExtension.php', + 'Symfony\\Component\\CssSelector\\XPath\\Extension\\AttributeMatchingExtension' => $vendorDir . '/symfony/css-selector/Symfony/Component/CssSelector/XPath/Extension/AttributeMatchingExtension.php', + 'Symfony\\Component\\CssSelector\\XPath\\Extension\\CombinationExtension' => $vendorDir . '/symfony/css-selector/Symfony/Component/CssSelector/XPath/Extension/CombinationExtension.php', + 'Symfony\\Component\\CssSelector\\XPath\\Extension\\ExtensionInterface' => $vendorDir . '/symfony/css-selector/Symfony/Component/CssSelector/XPath/Extension/ExtensionInterface.php', + 'Symfony\\Component\\CssSelector\\XPath\\Extension\\FunctionExtension' => $vendorDir . '/symfony/css-selector/Symfony/Component/CssSelector/XPath/Extension/FunctionExtension.php', + 'Symfony\\Component\\CssSelector\\XPath\\Extension\\HtmlExtension' => $vendorDir . '/symfony/css-selector/Symfony/Component/CssSelector/XPath/Extension/HtmlExtension.php', + 'Symfony\\Component\\CssSelector\\XPath\\Extension\\NodeExtension' => $vendorDir . '/symfony/css-selector/Symfony/Component/CssSelector/XPath/Extension/NodeExtension.php', + 'Symfony\\Component\\CssSelector\\XPath\\Extension\\PseudoClassExtension' => $vendorDir . '/symfony/css-selector/Symfony/Component/CssSelector/XPath/Extension/PseudoClassExtension.php', + 'Symfony\\Component\\CssSelector\\XPath\\Translator' => $vendorDir . '/symfony/css-selector/Symfony/Component/CssSelector/XPath/Translator.php', + 'Symfony\\Component\\CssSelector\\XPath\\TranslatorInterface' => $vendorDir . '/symfony/css-selector/Symfony/Component/CssSelector/XPath/TranslatorInterface.php', + 'Symfony\\Component\\CssSelector\\XPath\\XPathExpr' => $vendorDir . '/symfony/css-selector/Symfony/Component/CssSelector/XPath/XPathExpr.php', + 'Symfony\\Component\\Debug\\Debug' => $vendorDir . '/symfony/debug/Symfony/Component/Debug/Debug.php', + 'Symfony\\Component\\Debug\\DebugClassLoader' => $vendorDir . '/symfony/debug/Symfony/Component/Debug/DebugClassLoader.php', + 'Symfony\\Component\\Debug\\ErrorHandler' => $vendorDir . '/symfony/debug/Symfony/Component/Debug/ErrorHandler.php', + 'Symfony\\Component\\Debug\\ExceptionHandler' => $vendorDir . '/symfony/debug/Symfony/Component/Debug/ExceptionHandler.php', + 'Symfony\\Component\\Debug\\Exception\\ClassNotFoundException' => $vendorDir . '/symfony/debug/Symfony/Component/Debug/Exception/ClassNotFoundException.php', + 'Symfony\\Component\\Debug\\Exception\\ContextErrorException' => $vendorDir . '/symfony/debug/Symfony/Component/Debug/Exception/ContextErrorException.php', + 'Symfony\\Component\\Debug\\Exception\\DummyException' => $vendorDir . '/symfony/debug/Symfony/Component/Debug/Exception/DummyException.php', + 'Symfony\\Component\\Debug\\Exception\\FatalErrorException' => $vendorDir . '/symfony/debug/Symfony/Component/Debug/Exception/FatalErrorException.php', + 'Symfony\\Component\\Debug\\Exception\\FlattenException' => $vendorDir . '/symfony/debug/Symfony/Component/Debug/Exception/FlattenException.php', + 'Symfony\\Component\\Debug\\Exception\\UndefinedFunctionException' => $vendorDir . '/symfony/debug/Symfony/Component/Debug/Exception/UndefinedFunctionException.php', + 'Symfony\\Component\\Debug\\FatalErrorHandler\\ClassNotFoundFatalErrorHandler' => $vendorDir . '/symfony/debug/Symfony/Component/Debug/FatalErrorHandler/ClassNotFoundFatalErrorHandler.php', + 'Symfony\\Component\\Debug\\FatalErrorHandler\\FatalErrorHandlerInterface' => $vendorDir . '/symfony/debug/Symfony/Component/Debug/FatalErrorHandler/FatalErrorHandlerInterface.php', + 'Symfony\\Component\\Debug\\FatalErrorHandler\\UndefinedFunctionFatalErrorHandler' => $vendorDir . '/symfony/debug/Symfony/Component/Debug/FatalErrorHandler/UndefinedFunctionFatalErrorHandler.php', + 'Symfony\\Component\\Debug\\Tests\\Fixtures\\RequiredTwice' => $vendorDir . '/symfony/debug/Symfony/Component/Debug/Tests/Fixtures/RequiredTwice.php', + 'Symfony\\Component\\Debug\\Tests\\MockExceptionHandler' => $vendorDir . '/symfony/debug/Symfony/Component/Debug/Tests/MockExceptionHandler.php', + 'Symfony\\Component\\DomCrawler\\Crawler' => $vendorDir . '/symfony/dom-crawler/Symfony/Component/DomCrawler/Crawler.php', + 'Symfony\\Component\\DomCrawler\\Field\\ChoiceFormField' => $vendorDir . '/symfony/dom-crawler/Symfony/Component/DomCrawler/Field/ChoiceFormField.php', + 'Symfony\\Component\\DomCrawler\\Field\\FileFormField' => $vendorDir . '/symfony/dom-crawler/Symfony/Component/DomCrawler/Field/FileFormField.php', + 'Symfony\\Component\\DomCrawler\\Field\\FormField' => $vendorDir . '/symfony/dom-crawler/Symfony/Component/DomCrawler/Field/FormField.php', + 'Symfony\\Component\\DomCrawler\\Field\\InputFormField' => $vendorDir . '/symfony/dom-crawler/Symfony/Component/DomCrawler/Field/InputFormField.php', + 'Symfony\\Component\\DomCrawler\\Field\\TextareaFormField' => $vendorDir . '/symfony/dom-crawler/Symfony/Component/DomCrawler/Field/TextareaFormField.php', + 'Symfony\\Component\\DomCrawler\\Form' => $vendorDir . '/symfony/dom-crawler/Symfony/Component/DomCrawler/Form.php', + 'Symfony\\Component\\DomCrawler\\FormFieldRegistry' => $vendorDir . '/symfony/dom-crawler/Symfony/Component/DomCrawler/FormFieldRegistry.php', + 'Symfony\\Component\\DomCrawler\\Link' => $vendorDir . '/symfony/dom-crawler/Symfony/Component/DomCrawler/Link.php', + 'Symfony\\Component\\DomCrawler\\Tests\\Field\\FormFieldTestCase' => $vendorDir . '/symfony/dom-crawler/Symfony/Component/DomCrawler/Tests/Field/FormFieldTestCase.php', + 'Symfony\\Component\\EventDispatcher\\ContainerAwareEventDispatcher' => $vendorDir . '/symfony/event-dispatcher/Symfony/Component/EventDispatcher/ContainerAwareEventDispatcher.php', + 'Symfony\\Component\\EventDispatcher\\Debug\\TraceableEventDispatcher' => $vendorDir . '/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Debug/TraceableEventDispatcher.php', + 'Symfony\\Component\\EventDispatcher\\Debug\\TraceableEventDispatcherInterface' => $vendorDir . '/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Debug/TraceableEventDispatcherInterface.php', + 'Symfony\\Component\\EventDispatcher\\Debug\\WrappedListener' => $vendorDir . '/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Debug/WrappedListener.php', + 'Symfony\\Component\\EventDispatcher\\DependencyInjection\\RegisterListenersPass' => $vendorDir . '/symfony/event-dispatcher/Symfony/Component/EventDispatcher/DependencyInjection/RegisterListenersPass.php', + 'Symfony\\Component\\EventDispatcher\\Event' => $vendorDir . '/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Event.php', + 'Symfony\\Component\\EventDispatcher\\EventDispatcher' => $vendorDir . '/symfony/event-dispatcher/Symfony/Component/EventDispatcher/EventDispatcher.php', + 'Symfony\\Component\\EventDispatcher\\EventDispatcherInterface' => $vendorDir . '/symfony/event-dispatcher/Symfony/Component/EventDispatcher/EventDispatcherInterface.php', + 'Symfony\\Component\\EventDispatcher\\EventSubscriberInterface' => $vendorDir . '/symfony/event-dispatcher/Symfony/Component/EventDispatcher/EventSubscriberInterface.php', + 'Symfony\\Component\\EventDispatcher\\GenericEvent' => $vendorDir . '/symfony/event-dispatcher/Symfony/Component/EventDispatcher/GenericEvent.php', + 'Symfony\\Component\\EventDispatcher\\ImmutableEventDispatcher' => $vendorDir . '/symfony/event-dispatcher/Symfony/Component/EventDispatcher/ImmutableEventDispatcher.php', + 'Symfony\\Component\\Filesystem\\Exception\\ExceptionInterface' => $vendorDir . '/symfony/filesystem/Symfony/Component/Filesystem/Exception/ExceptionInterface.php', + 'Symfony\\Component\\Filesystem\\Exception\\FileNotFoundException' => $vendorDir . '/symfony/filesystem/Symfony/Component/Filesystem/Exception/FileNotFoundException.php', + 'Symfony\\Component\\Filesystem\\Exception\\IOException' => $vendorDir . '/symfony/filesystem/Symfony/Component/Filesystem/Exception/IOException.php', + 'Symfony\\Component\\Filesystem\\Exception\\IOExceptionInterface' => $vendorDir . '/symfony/filesystem/Symfony/Component/Filesystem/Exception/IOExceptionInterface.php', + 'Symfony\\Component\\Filesystem\\Filesystem' => $vendorDir . '/symfony/filesystem/Symfony/Component/Filesystem/Filesystem.php', + 'Symfony\\Component\\Filesystem\\Tests\\FilesystemTestCase' => $vendorDir . '/symfony/filesystem/Symfony/Component/Filesystem/Tests/FilesystemTestCase.php', + 'Symfony\\Component\\Finder\\Adapter\\AbstractAdapter' => $vendorDir . '/symfony/finder/Symfony/Component/Finder/Adapter/AbstractAdapter.php', + 'Symfony\\Component\\Finder\\Adapter\\AbstractFindAdapter' => $vendorDir . '/symfony/finder/Symfony/Component/Finder/Adapter/AbstractFindAdapter.php', + 'Symfony\\Component\\Finder\\Adapter\\AdapterInterface' => $vendorDir . '/symfony/finder/Symfony/Component/Finder/Adapter/AdapterInterface.php', + 'Symfony\\Component\\Finder\\Adapter\\BsdFindAdapter' => $vendorDir . '/symfony/finder/Symfony/Component/Finder/Adapter/BsdFindAdapter.php', + 'Symfony\\Component\\Finder\\Adapter\\GnuFindAdapter' => $vendorDir . '/symfony/finder/Symfony/Component/Finder/Adapter/GnuFindAdapter.php', + 'Symfony\\Component\\Finder\\Adapter\\PhpAdapter' => $vendorDir . '/symfony/finder/Symfony/Component/Finder/Adapter/PhpAdapter.php', + 'Symfony\\Component\\Finder\\Comparator\\Comparator' => $vendorDir . '/symfony/finder/Symfony/Component/Finder/Comparator/Comparator.php', + 'Symfony\\Component\\Finder\\Comparator\\DateComparator' => $vendorDir . '/symfony/finder/Symfony/Component/Finder/Comparator/DateComparator.php', + 'Symfony\\Component\\Finder\\Comparator\\NumberComparator' => $vendorDir . '/symfony/finder/Symfony/Component/Finder/Comparator/NumberComparator.php', + 'Symfony\\Component\\Finder\\Exception\\AccessDeniedException' => $vendorDir . '/symfony/finder/Symfony/Component/Finder/Exception/AccessDeniedException.php', + 'Symfony\\Component\\Finder\\Exception\\AdapterFailureException' => $vendorDir . '/symfony/finder/Symfony/Component/Finder/Exception/AdapterFailureException.php', + 'Symfony\\Component\\Finder\\Exception\\ExceptionInterface' => $vendorDir . '/symfony/finder/Symfony/Component/Finder/Exception/ExceptionInterface.php', + 'Symfony\\Component\\Finder\\Exception\\OperationNotPermitedException' => $vendorDir . '/symfony/finder/Symfony/Component/Finder/Exception/OperationNotPermitedException.php', + 'Symfony\\Component\\Finder\\Exception\\ShellCommandFailureException' => $vendorDir . '/symfony/finder/Symfony/Component/Finder/Exception/ShellCommandFailureException.php', + 'Symfony\\Component\\Finder\\Expression\\Expression' => $vendorDir . '/symfony/finder/Symfony/Component/Finder/Expression/Expression.php', + 'Symfony\\Component\\Finder\\Expression\\Glob' => $vendorDir . '/symfony/finder/Symfony/Component/Finder/Expression/Glob.php', + 'Symfony\\Component\\Finder\\Expression\\Regex' => $vendorDir . '/symfony/finder/Symfony/Component/Finder/Expression/Regex.php', + 'Symfony\\Component\\Finder\\Expression\\ValueInterface' => $vendorDir . '/symfony/finder/Symfony/Component/Finder/Expression/ValueInterface.php', + 'Symfony\\Component\\Finder\\Finder' => $vendorDir . '/symfony/finder/Symfony/Component/Finder/Finder.php', + 'Symfony\\Component\\Finder\\Glob' => $vendorDir . '/symfony/finder/Symfony/Component/Finder/Glob.php', + 'Symfony\\Component\\Finder\\Iterator\\CustomFilterIterator' => $vendorDir . '/symfony/finder/Symfony/Component/Finder/Iterator/CustomFilterIterator.php', + 'Symfony\\Component\\Finder\\Iterator\\DateRangeFilterIterator' => $vendorDir . '/symfony/finder/Symfony/Component/Finder/Iterator/DateRangeFilterIterator.php', + 'Symfony\\Component\\Finder\\Iterator\\DepthRangeFilterIterator' => $vendorDir . '/symfony/finder/Symfony/Component/Finder/Iterator/DepthRangeFilterIterator.php', + 'Symfony\\Component\\Finder\\Iterator\\ExcludeDirectoryFilterIterator' => $vendorDir . '/symfony/finder/Symfony/Component/Finder/Iterator/ExcludeDirectoryFilterIterator.php', + 'Symfony\\Component\\Finder\\Iterator\\FilePathsIterator' => $vendorDir . '/symfony/finder/Symfony/Component/Finder/Iterator/FilePathsIterator.php', + 'Symfony\\Component\\Finder\\Iterator\\FileTypeFilterIterator' => $vendorDir . '/symfony/finder/Symfony/Component/Finder/Iterator/FileTypeFilterIterator.php', + 'Symfony\\Component\\Finder\\Iterator\\FilecontentFilterIterator' => $vendorDir . '/symfony/finder/Symfony/Component/Finder/Iterator/FilecontentFilterIterator.php', + 'Symfony\\Component\\Finder\\Iterator\\FilenameFilterIterator' => $vendorDir . '/symfony/finder/Symfony/Component/Finder/Iterator/FilenameFilterIterator.php', + 'Symfony\\Component\\Finder\\Iterator\\FilterIterator' => $vendorDir . '/symfony/finder/Symfony/Component/Finder/Iterator/FilterIterator.php', + 'Symfony\\Component\\Finder\\Iterator\\MultiplePcreFilterIterator' => $vendorDir . '/symfony/finder/Symfony/Component/Finder/Iterator/MultiplePcreFilterIterator.php', + 'Symfony\\Component\\Finder\\Iterator\\PathFilterIterator' => $vendorDir . '/symfony/finder/Symfony/Component/Finder/Iterator/PathFilterIterator.php', + 'Symfony\\Component\\Finder\\Iterator\\RecursiveDirectoryIterator' => $vendorDir . '/symfony/finder/Symfony/Component/Finder/Iterator/RecursiveDirectoryIterator.php', + 'Symfony\\Component\\Finder\\Iterator\\SizeRangeFilterIterator' => $vendorDir . '/symfony/finder/Symfony/Component/Finder/Iterator/SizeRangeFilterIterator.php', + 'Symfony\\Component\\Finder\\Iterator\\SortableIterator' => $vendorDir . '/symfony/finder/Symfony/Component/Finder/Iterator/SortableIterator.php', + 'Symfony\\Component\\Finder\\Shell\\Command' => $vendorDir . '/symfony/finder/Symfony/Component/Finder/Shell/Command.php', + 'Symfony\\Component\\Finder\\Shell\\Shell' => $vendorDir . '/symfony/finder/Symfony/Component/Finder/Shell/Shell.php', + 'Symfony\\Component\\Finder\\SplFileInfo' => $vendorDir . '/symfony/finder/Symfony/Component/Finder/SplFileInfo.php', + 'Symfony\\Component\\Finder\\Tests\\FakeAdapter\\DummyAdapter' => $vendorDir . '/symfony/finder/Symfony/Component/Finder/Tests/FakeAdapter/DummyAdapter.php', + 'Symfony\\Component\\Finder\\Tests\\FakeAdapter\\FailingAdapter' => $vendorDir . '/symfony/finder/Symfony/Component/Finder/Tests/FakeAdapter/FailingAdapter.php', + 'Symfony\\Component\\Finder\\Tests\\FakeAdapter\\NamedAdapter' => $vendorDir . '/symfony/finder/Symfony/Component/Finder/Tests/FakeAdapter/NamedAdapter.php', + 'Symfony\\Component\\Finder\\Tests\\FakeAdapter\\UnsupportedAdapter' => $vendorDir . '/symfony/finder/Symfony/Component/Finder/Tests/FakeAdapter/UnsupportedAdapter.php', + 'Symfony\\Component\\Finder\\Tests\\Iterator\\Iterator' => $vendorDir . '/symfony/finder/Symfony/Component/Finder/Tests/Iterator/Iterator.php', + 'Symfony\\Component\\Finder\\Tests\\Iterator\\IteratorTestCase' => $vendorDir . '/symfony/finder/Symfony/Component/Finder/Tests/Iterator/IteratorTestCase.php', + 'Symfony\\Component\\Finder\\Tests\\Iterator\\MockFileListIterator' => $vendorDir . '/symfony/finder/Symfony/Component/Finder/Tests/Iterator/MockFileListIterator.php', + 'Symfony\\Component\\Finder\\Tests\\Iterator\\MockSplFileInfo' => $vendorDir . '/symfony/finder/Symfony/Component/Finder/Tests/Iterator/MockSplFileInfo.php', + 'Symfony\\Component\\Finder\\Tests\\Iterator\\RealIteratorTestCase' => $vendorDir . '/symfony/finder/Symfony/Component/Finder/Tests/Iterator/RealIteratorTestCase.php', + 'Symfony\\Component\\HttpFoundation\\AcceptHeader' => $vendorDir . '/symfony/http-foundation/Symfony/Component/HttpFoundation/AcceptHeader.php', + 'Symfony\\Component\\HttpFoundation\\AcceptHeaderItem' => $vendorDir . '/symfony/http-foundation/Symfony/Component/HttpFoundation/AcceptHeaderItem.php', + 'Symfony\\Component\\HttpFoundation\\ApacheRequest' => $vendorDir . '/symfony/http-foundation/Symfony/Component/HttpFoundation/ApacheRequest.php', + 'Symfony\\Component\\HttpFoundation\\BinaryFileResponse' => $vendorDir . '/symfony/http-foundation/Symfony/Component/HttpFoundation/BinaryFileResponse.php', + 'Symfony\\Component\\HttpFoundation\\Cookie' => $vendorDir . '/symfony/http-foundation/Symfony/Component/HttpFoundation/Cookie.php', + 'Symfony\\Component\\HttpFoundation\\ExpressionRequestMatcher' => $vendorDir . '/symfony/http-foundation/Symfony/Component/HttpFoundation/ExpressionRequestMatcher.php', + 'Symfony\\Component\\HttpFoundation\\FileBag' => $vendorDir . '/symfony/http-foundation/Symfony/Component/HttpFoundation/FileBag.php', + 'Symfony\\Component\\HttpFoundation\\File\\Exception\\AccessDeniedException' => $vendorDir . '/symfony/http-foundation/Symfony/Component/HttpFoundation/File/Exception/AccessDeniedException.php', + 'Symfony\\Component\\HttpFoundation\\File\\Exception\\FileException' => $vendorDir . '/symfony/http-foundation/Symfony/Component/HttpFoundation/File/Exception/FileException.php', + 'Symfony\\Component\\HttpFoundation\\File\\Exception\\FileNotFoundException' => $vendorDir . '/symfony/http-foundation/Symfony/Component/HttpFoundation/File/Exception/FileNotFoundException.php', + 'Symfony\\Component\\HttpFoundation\\File\\Exception\\UnexpectedTypeException' => $vendorDir . '/symfony/http-foundation/Symfony/Component/HttpFoundation/File/Exception/UnexpectedTypeException.php', + 'Symfony\\Component\\HttpFoundation\\File\\Exception\\UploadException' => $vendorDir . '/symfony/http-foundation/Symfony/Component/HttpFoundation/File/Exception/UploadException.php', + 'Symfony\\Component\\HttpFoundation\\File\\File' => $vendorDir . '/symfony/http-foundation/Symfony/Component/HttpFoundation/File/File.php', + 'Symfony\\Component\\HttpFoundation\\File\\MimeType\\ExtensionGuesser' => $vendorDir . '/symfony/http-foundation/Symfony/Component/HttpFoundation/File/MimeType/ExtensionGuesser.php', + 'Symfony\\Component\\HttpFoundation\\File\\MimeType\\ExtensionGuesserInterface' => $vendorDir . '/symfony/http-foundation/Symfony/Component/HttpFoundation/File/MimeType/ExtensionGuesserInterface.php', + 'Symfony\\Component\\HttpFoundation\\File\\MimeType\\FileBinaryMimeTypeGuesser' => $vendorDir . '/symfony/http-foundation/Symfony/Component/HttpFoundation/File/MimeType/FileBinaryMimeTypeGuesser.php', + 'Symfony\\Component\\HttpFoundation\\File\\MimeType\\FileinfoMimeTypeGuesser' => $vendorDir . '/symfony/http-foundation/Symfony/Component/HttpFoundation/File/MimeType/FileinfoMimeTypeGuesser.php', + 'Symfony\\Component\\HttpFoundation\\File\\MimeType\\MimeTypeExtensionGuesser' => $vendorDir . '/symfony/http-foundation/Symfony/Component/HttpFoundation/File/MimeType/MimeTypeExtensionGuesser.php', + 'Symfony\\Component\\HttpFoundation\\File\\MimeType\\MimeTypeGuesser' => $vendorDir . '/symfony/http-foundation/Symfony/Component/HttpFoundation/File/MimeType/MimeTypeGuesser.php', + 'Symfony\\Component\\HttpFoundation\\File\\MimeType\\MimeTypeGuesserInterface' => $vendorDir . '/symfony/http-foundation/Symfony/Component/HttpFoundation/File/MimeType/MimeTypeGuesserInterface.php', + 'Symfony\\Component\\HttpFoundation\\File\\UploadedFile' => $vendorDir . '/symfony/http-foundation/Symfony/Component/HttpFoundation/File/UploadedFile.php', + 'Symfony\\Component\\HttpFoundation\\HeaderBag' => $vendorDir . '/symfony/http-foundation/Symfony/Component/HttpFoundation/HeaderBag.php', + 'Symfony\\Component\\HttpFoundation\\IpUtils' => $vendorDir . '/symfony/http-foundation/Symfony/Component/HttpFoundation/IpUtils.php', + 'Symfony\\Component\\HttpFoundation\\JsonResponse' => $vendorDir . '/symfony/http-foundation/Symfony/Component/HttpFoundation/JsonResponse.php', + 'Symfony\\Component\\HttpFoundation\\ParameterBag' => $vendorDir . '/symfony/http-foundation/Symfony/Component/HttpFoundation/ParameterBag.php', + 'Symfony\\Component\\HttpFoundation\\RedirectResponse' => $vendorDir . '/symfony/http-foundation/Symfony/Component/HttpFoundation/RedirectResponse.php', + 'Symfony\\Component\\HttpFoundation\\Request' => $vendorDir . '/symfony/http-foundation/Symfony/Component/HttpFoundation/Request.php', + 'Symfony\\Component\\HttpFoundation\\RequestMatcher' => $vendorDir . '/symfony/http-foundation/Symfony/Component/HttpFoundation/RequestMatcher.php', + 'Symfony\\Component\\HttpFoundation\\RequestMatcherInterface' => $vendorDir . '/symfony/http-foundation/Symfony/Component/HttpFoundation/RequestMatcherInterface.php', + 'Symfony\\Component\\HttpFoundation\\RequestStack' => $vendorDir . '/symfony/http-foundation/Symfony/Component/HttpFoundation/RequestStack.php', + 'Symfony\\Component\\HttpFoundation\\Response' => $vendorDir . '/symfony/http-foundation/Symfony/Component/HttpFoundation/Response.php', + 'Symfony\\Component\\HttpFoundation\\ResponseHeaderBag' => $vendorDir . '/symfony/http-foundation/Symfony/Component/HttpFoundation/ResponseHeaderBag.php', + 'Symfony\\Component\\HttpFoundation\\ServerBag' => $vendorDir . '/symfony/http-foundation/Symfony/Component/HttpFoundation/ServerBag.php', + 'Symfony\\Component\\HttpFoundation\\Session\\Attribute\\AttributeBag' => $vendorDir . '/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Attribute/AttributeBag.php', + 'Symfony\\Component\\HttpFoundation\\Session\\Attribute\\AttributeBagInterface' => $vendorDir . '/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Attribute/AttributeBagInterface.php', + 'Symfony\\Component\\HttpFoundation\\Session\\Attribute\\NamespacedAttributeBag' => $vendorDir . '/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Attribute/NamespacedAttributeBag.php', + 'Symfony\\Component\\HttpFoundation\\Session\\Flash\\AutoExpireFlashBag' => $vendorDir . '/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Flash/AutoExpireFlashBag.php', + 'Symfony\\Component\\HttpFoundation\\Session\\Flash\\FlashBag' => $vendorDir . '/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Flash/FlashBag.php', + 'Symfony\\Component\\HttpFoundation\\Session\\Flash\\FlashBagInterface' => $vendorDir . '/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Flash/FlashBagInterface.php', + 'Symfony\\Component\\HttpFoundation\\Session\\Session' => $vendorDir . '/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Session.php', + 'Symfony\\Component\\HttpFoundation\\Session\\SessionBagInterface' => $vendorDir . '/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/SessionBagInterface.php', + 'Symfony\\Component\\HttpFoundation\\Session\\SessionInterface' => $vendorDir . '/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/SessionInterface.php', + 'Symfony\\Component\\HttpFoundation\\Session\\Storage\\Handler\\MemcacheSessionHandler' => $vendorDir . '/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/Handler/MemcacheSessionHandler.php', + 'Symfony\\Component\\HttpFoundation\\Session\\Storage\\Handler\\MemcachedSessionHandler' => $vendorDir . '/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/Handler/MemcachedSessionHandler.php', + 'Symfony\\Component\\HttpFoundation\\Session\\Storage\\Handler\\MongoDbSessionHandler' => $vendorDir . '/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/Handler/MongoDbSessionHandler.php', + 'Symfony\\Component\\HttpFoundation\\Session\\Storage\\Handler\\NativeFileSessionHandler' => $vendorDir . '/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/Handler/NativeFileSessionHandler.php', + 'Symfony\\Component\\HttpFoundation\\Session\\Storage\\Handler\\NativeSessionHandler' => $vendorDir . '/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/Handler/NativeSessionHandler.php', + 'Symfony\\Component\\HttpFoundation\\Session\\Storage\\Handler\\NullSessionHandler' => $vendorDir . '/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/Handler/NullSessionHandler.php', + 'Symfony\\Component\\HttpFoundation\\Session\\Storage\\Handler\\PdoSessionHandler' => $vendorDir . '/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/Handler/PdoSessionHandler.php', + 'Symfony\\Component\\HttpFoundation\\Session\\Storage\\Handler\\WriteCheckSessionHandler' => $vendorDir . '/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/Handler/WriteCheckSessionHandler.php', + 'Symfony\\Component\\HttpFoundation\\Session\\Storage\\MetadataBag' => $vendorDir . '/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/MetadataBag.php', + 'Symfony\\Component\\HttpFoundation\\Session\\Storage\\MockArraySessionStorage' => $vendorDir . '/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/MockArraySessionStorage.php', + 'Symfony\\Component\\HttpFoundation\\Session\\Storage\\MockFileSessionStorage' => $vendorDir . '/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/MockFileSessionStorage.php', + 'Symfony\\Component\\HttpFoundation\\Session\\Storage\\NativeSessionStorage' => $vendorDir . '/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php', + 'Symfony\\Component\\HttpFoundation\\Session\\Storage\\PhpBridgeSessionStorage' => $vendorDir . '/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/PhpBridgeSessionStorage.php', + 'Symfony\\Component\\HttpFoundation\\Session\\Storage\\Proxy\\AbstractProxy' => $vendorDir . '/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/Proxy/AbstractProxy.php', + 'Symfony\\Component\\HttpFoundation\\Session\\Storage\\Proxy\\NativeProxy' => $vendorDir . '/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/Proxy/NativeProxy.php', + 'Symfony\\Component\\HttpFoundation\\Session\\Storage\\Proxy\\SessionHandlerProxy' => $vendorDir . '/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/Proxy/SessionHandlerProxy.php', + 'Symfony\\Component\\HttpFoundation\\Session\\Storage\\SessionStorageInterface' => $vendorDir . '/symfony/http-foundation/Symfony/Component/HttpFoundation/Session/Storage/SessionStorageInterface.php', + 'Symfony\\Component\\HttpFoundation\\StreamedResponse' => $vendorDir . '/symfony/http-foundation/Symfony/Component/HttpFoundation/StreamedResponse.php', + 'Symfony\\Component\\HttpFoundation\\Tests\\ResponseTestCase' => $vendorDir . '/symfony/http-foundation/Symfony/Component/HttpFoundation/Tests/ResponseTestCase.php', + 'Symfony\\Component\\HttpKernel\\Bundle\\Bundle' => $vendorDir . '/symfony/http-kernel/Symfony/Component/HttpKernel/Bundle/Bundle.php', + 'Symfony\\Component\\HttpKernel\\Bundle\\BundleInterface' => $vendorDir . '/symfony/http-kernel/Symfony/Component/HttpKernel/Bundle/BundleInterface.php', + 'Symfony\\Component\\HttpKernel\\CacheClearer\\CacheClearerInterface' => $vendorDir . '/symfony/http-kernel/Symfony/Component/HttpKernel/CacheClearer/CacheClearerInterface.php', + 'Symfony\\Component\\HttpKernel\\CacheClearer\\ChainCacheClearer' => $vendorDir . '/symfony/http-kernel/Symfony/Component/HttpKernel/CacheClearer/ChainCacheClearer.php', + 'Symfony\\Component\\HttpKernel\\CacheWarmer\\CacheWarmer' => $vendorDir . '/symfony/http-kernel/Symfony/Component/HttpKernel/CacheWarmer/CacheWarmer.php', + 'Symfony\\Component\\HttpKernel\\CacheWarmer\\CacheWarmerAggregate' => $vendorDir . '/symfony/http-kernel/Symfony/Component/HttpKernel/CacheWarmer/CacheWarmerAggregate.php', + 'Symfony\\Component\\HttpKernel\\CacheWarmer\\CacheWarmerInterface' => $vendorDir . '/symfony/http-kernel/Symfony/Component/HttpKernel/CacheWarmer/CacheWarmerInterface.php', + 'Symfony\\Component\\HttpKernel\\CacheWarmer\\WarmableInterface' => $vendorDir . '/symfony/http-kernel/Symfony/Component/HttpKernel/CacheWarmer/WarmableInterface.php', + 'Symfony\\Component\\HttpKernel\\Client' => $vendorDir . '/symfony/http-kernel/Symfony/Component/HttpKernel/Client.php', + 'Symfony\\Component\\HttpKernel\\Config\\FileLocator' => $vendorDir . '/symfony/http-kernel/Symfony/Component/HttpKernel/Config/FileLocator.php', + 'Symfony\\Component\\HttpKernel\\Controller\\ControllerReference' => $vendorDir . '/symfony/http-kernel/Symfony/Component/HttpKernel/Controller/ControllerReference.php', + 'Symfony\\Component\\HttpKernel\\Controller\\ControllerResolver' => $vendorDir . '/symfony/http-kernel/Symfony/Component/HttpKernel/Controller/ControllerResolver.php', + 'Symfony\\Component\\HttpKernel\\Controller\\ControllerResolverInterface' => $vendorDir . '/symfony/http-kernel/Symfony/Component/HttpKernel/Controller/ControllerResolverInterface.php', + 'Symfony\\Component\\HttpKernel\\Controller\\TraceableControllerResolver' => $vendorDir . '/symfony/http-kernel/Symfony/Component/HttpKernel/Controller/TraceableControllerResolver.php', + 'Symfony\\Component\\HttpKernel\\DataCollector\\ConfigDataCollector' => $vendorDir . '/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/ConfigDataCollector.php', + 'Symfony\\Component\\HttpKernel\\DataCollector\\DataCollector' => $vendorDir . '/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/DataCollector.php', + 'Symfony\\Component\\HttpKernel\\DataCollector\\DataCollectorInterface' => $vendorDir . '/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/DataCollectorInterface.php', + 'Symfony\\Component\\HttpKernel\\DataCollector\\EventDataCollector' => $vendorDir . '/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/EventDataCollector.php', + 'Symfony\\Component\\HttpKernel\\DataCollector\\ExceptionDataCollector' => $vendorDir . '/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/ExceptionDataCollector.php', + 'Symfony\\Component\\HttpKernel\\DataCollector\\LateDataCollectorInterface' => $vendorDir . '/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/LateDataCollectorInterface.php', + 'Symfony\\Component\\HttpKernel\\DataCollector\\LoggerDataCollector' => $vendorDir . '/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/LoggerDataCollector.php', + 'Symfony\\Component\\HttpKernel\\DataCollector\\MemoryDataCollector' => $vendorDir . '/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/MemoryDataCollector.php', + 'Symfony\\Component\\HttpKernel\\DataCollector\\RequestDataCollector' => $vendorDir . '/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/RequestDataCollector.php', + 'Symfony\\Component\\HttpKernel\\DataCollector\\RouterDataCollector' => $vendorDir . '/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/RouterDataCollector.php', + 'Symfony\\Component\\HttpKernel\\DataCollector\\TimeDataCollector' => $vendorDir . '/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/TimeDataCollector.php', + 'Symfony\\Component\\HttpKernel\\DataCollector\\Util\\ValueExporter' => $vendorDir . '/symfony/http-kernel/Symfony/Component/HttpKernel/DataCollector/Util/ValueExporter.php', + 'Symfony\\Component\\HttpKernel\\Debug\\ErrorHandler' => $vendorDir . '/symfony/http-kernel/Symfony/Component/HttpKernel/Debug/ErrorHandler.php', + 'Symfony\\Component\\HttpKernel\\Debug\\ExceptionHandler' => $vendorDir . '/symfony/http-kernel/Symfony/Component/HttpKernel/Debug/ExceptionHandler.php', + 'Symfony\\Component\\HttpKernel\\Debug\\TraceableEventDispatcher' => $vendorDir . '/symfony/http-kernel/Symfony/Component/HttpKernel/Debug/TraceableEventDispatcher.php', + 'Symfony\\Component\\HttpKernel\\DependencyInjection\\AddClassesToCachePass' => $vendorDir . '/symfony/http-kernel/Symfony/Component/HttpKernel/DependencyInjection/AddClassesToCachePass.php', + 'Symfony\\Component\\HttpKernel\\DependencyInjection\\ConfigurableExtension' => $vendorDir . '/symfony/http-kernel/Symfony/Component/HttpKernel/DependencyInjection/ConfigurableExtension.php', + 'Symfony\\Component\\HttpKernel\\DependencyInjection\\ContainerAwareHttpKernel' => $vendorDir . '/symfony/http-kernel/Symfony/Component/HttpKernel/DependencyInjection/ContainerAwareHttpKernel.php', + 'Symfony\\Component\\HttpKernel\\DependencyInjection\\Extension' => $vendorDir . '/symfony/http-kernel/Symfony/Component/HttpKernel/DependencyInjection/Extension.php', + 'Symfony\\Component\\HttpKernel\\DependencyInjection\\MergeExtensionConfigurationPass' => $vendorDir . '/symfony/http-kernel/Symfony/Component/HttpKernel/DependencyInjection/MergeExtensionConfigurationPass.php', + 'Symfony\\Component\\HttpKernel\\DependencyInjection\\RegisterListenersPass' => $vendorDir . '/symfony/http-kernel/Symfony/Component/HttpKernel/DependencyInjection/RegisterListenersPass.php', + 'Symfony\\Component\\HttpKernel\\EventListener\\ErrorsLoggerListener' => $vendorDir . '/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/ErrorsLoggerListener.php', + 'Symfony\\Component\\HttpKernel\\EventListener\\EsiListener' => $vendorDir . '/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/EsiListener.php', + 'Symfony\\Component\\HttpKernel\\EventListener\\ExceptionListener' => $vendorDir . '/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/ExceptionListener.php', + 'Symfony\\Component\\HttpKernel\\EventListener\\FragmentListener' => $vendorDir . '/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/FragmentListener.php', + 'Symfony\\Component\\HttpKernel\\EventListener\\LocaleListener' => $vendorDir . '/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/LocaleListener.php', + 'Symfony\\Component\\HttpKernel\\EventListener\\ProfilerListener' => $vendorDir . '/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/ProfilerListener.php', + 'Symfony\\Component\\HttpKernel\\EventListener\\ResponseListener' => $vendorDir . '/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/ResponseListener.php', + 'Symfony\\Component\\HttpKernel\\EventListener\\RouterListener' => $vendorDir . '/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/RouterListener.php', + 'Symfony\\Component\\HttpKernel\\EventListener\\SessionListener' => $vendorDir . '/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/SessionListener.php', + 'Symfony\\Component\\HttpKernel\\EventListener\\StreamedResponseListener' => $vendorDir . '/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/StreamedResponseListener.php', + 'Symfony\\Component\\HttpKernel\\EventListener\\TestSessionListener' => $vendorDir . '/symfony/http-kernel/Symfony/Component/HttpKernel/EventListener/TestSessionListener.php', + 'Symfony\\Component\\HttpKernel\\Event\\FilterControllerEvent' => $vendorDir . '/symfony/http-kernel/Symfony/Component/HttpKernel/Event/FilterControllerEvent.php', + 'Symfony\\Component\\HttpKernel\\Event\\FilterResponseEvent' => $vendorDir . '/symfony/http-kernel/Symfony/Component/HttpKernel/Event/FilterResponseEvent.php', + 'Symfony\\Component\\HttpKernel\\Event\\FinishRequestEvent' => $vendorDir . '/symfony/http-kernel/Symfony/Component/HttpKernel/Event/FinishRequestEvent.php', + 'Symfony\\Component\\HttpKernel\\Event\\GetResponseEvent' => $vendorDir . '/symfony/http-kernel/Symfony/Component/HttpKernel/Event/GetResponseEvent.php', + 'Symfony\\Component\\HttpKernel\\Event\\GetResponseForControllerResultEvent' => $vendorDir . '/symfony/http-kernel/Symfony/Component/HttpKernel/Event/GetResponseForControllerResultEvent.php', + 'Symfony\\Component\\HttpKernel\\Event\\GetResponseForExceptionEvent' => $vendorDir . '/symfony/http-kernel/Symfony/Component/HttpKernel/Event/GetResponseForExceptionEvent.php', + 'Symfony\\Component\\HttpKernel\\Event\\KernelEvent' => $vendorDir . '/symfony/http-kernel/Symfony/Component/HttpKernel/Event/KernelEvent.php', + 'Symfony\\Component\\HttpKernel\\Event\\PostResponseEvent' => $vendorDir . '/symfony/http-kernel/Symfony/Component/HttpKernel/Event/PostResponseEvent.php', + 'Symfony\\Component\\HttpKernel\\Exception\\AccessDeniedHttpException' => $vendorDir . '/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/AccessDeniedHttpException.php', + 'Symfony\\Component\\HttpKernel\\Exception\\BadRequestHttpException' => $vendorDir . '/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/BadRequestHttpException.php', + 'Symfony\\Component\\HttpKernel\\Exception\\ConflictHttpException' => $vendorDir . '/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/ConflictHttpException.php', + 'Symfony\\Component\\HttpKernel\\Exception\\FatalErrorException' => $vendorDir . '/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/FatalErrorException.php', + 'Symfony\\Component\\HttpKernel\\Exception\\FlattenException' => $vendorDir . '/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/FlattenException.php', + 'Symfony\\Component\\HttpKernel\\Exception\\GoneHttpException' => $vendorDir . '/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/GoneHttpException.php', + 'Symfony\\Component\\HttpKernel\\Exception\\HttpException' => $vendorDir . '/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/HttpException.php', + 'Symfony\\Component\\HttpKernel\\Exception\\HttpExceptionInterface' => $vendorDir . '/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/HttpExceptionInterface.php', + 'Symfony\\Component\\HttpKernel\\Exception\\LengthRequiredHttpException' => $vendorDir . '/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/LengthRequiredHttpException.php', + 'Symfony\\Component\\HttpKernel\\Exception\\MethodNotAllowedHttpException' => $vendorDir . '/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/MethodNotAllowedHttpException.php', + 'Symfony\\Component\\HttpKernel\\Exception\\NotAcceptableHttpException' => $vendorDir . '/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/NotAcceptableHttpException.php', + 'Symfony\\Component\\HttpKernel\\Exception\\NotFoundHttpException' => $vendorDir . '/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/NotFoundHttpException.php', + 'Symfony\\Component\\HttpKernel\\Exception\\PreconditionFailedHttpException' => $vendorDir . '/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/PreconditionFailedHttpException.php', + 'Symfony\\Component\\HttpKernel\\Exception\\PreconditionRequiredHttpException' => $vendorDir . '/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/PreconditionRequiredHttpException.php', + 'Symfony\\Component\\HttpKernel\\Exception\\ServiceUnavailableHttpException' => $vendorDir . '/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/ServiceUnavailableHttpException.php', + 'Symfony\\Component\\HttpKernel\\Exception\\TooManyRequestsHttpException' => $vendorDir . '/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/TooManyRequestsHttpException.php', + 'Symfony\\Component\\HttpKernel\\Exception\\UnauthorizedHttpException' => $vendorDir . '/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/UnauthorizedHttpException.php', + 'Symfony\\Component\\HttpKernel\\Exception\\UnsupportedMediaTypeHttpException' => $vendorDir . '/symfony/http-kernel/Symfony/Component/HttpKernel/Exception/UnsupportedMediaTypeHttpException.php', + 'Symfony\\Component\\HttpKernel\\Fragment\\EsiFragmentRenderer' => $vendorDir . '/symfony/http-kernel/Symfony/Component/HttpKernel/Fragment/EsiFragmentRenderer.php', + 'Symfony\\Component\\HttpKernel\\Fragment\\FragmentHandler' => $vendorDir . '/symfony/http-kernel/Symfony/Component/HttpKernel/Fragment/FragmentHandler.php', + 'Symfony\\Component\\HttpKernel\\Fragment\\FragmentRendererInterface' => $vendorDir . '/symfony/http-kernel/Symfony/Component/HttpKernel/Fragment/FragmentRendererInterface.php', + 'Symfony\\Component\\HttpKernel\\Fragment\\HIncludeFragmentRenderer' => $vendorDir . '/symfony/http-kernel/Symfony/Component/HttpKernel/Fragment/HIncludeFragmentRenderer.php', + 'Symfony\\Component\\HttpKernel\\Fragment\\InlineFragmentRenderer' => $vendorDir . '/symfony/http-kernel/Symfony/Component/HttpKernel/Fragment/InlineFragmentRenderer.php', + 'Symfony\\Component\\HttpKernel\\Fragment\\RoutableFragmentRenderer' => $vendorDir . '/symfony/http-kernel/Symfony/Component/HttpKernel/Fragment/RoutableFragmentRenderer.php', + 'Symfony\\Component\\HttpKernel\\HttpCache\\Esi' => $vendorDir . '/symfony/http-kernel/Symfony/Component/HttpKernel/HttpCache/Esi.php', + 'Symfony\\Component\\HttpKernel\\HttpCache\\EsiResponseCacheStrategy' => $vendorDir . '/symfony/http-kernel/Symfony/Component/HttpKernel/HttpCache/EsiResponseCacheStrategy.php', + 'Symfony\\Component\\HttpKernel\\HttpCache\\EsiResponseCacheStrategyInterface' => $vendorDir . '/symfony/http-kernel/Symfony/Component/HttpKernel/HttpCache/EsiResponseCacheStrategyInterface.php', + 'Symfony\\Component\\HttpKernel\\HttpCache\\HttpCache' => $vendorDir . '/symfony/http-kernel/Symfony/Component/HttpKernel/HttpCache/HttpCache.php', + 'Symfony\\Component\\HttpKernel\\HttpCache\\Store' => $vendorDir . '/symfony/http-kernel/Symfony/Component/HttpKernel/HttpCache/Store.php', + 'Symfony\\Component\\HttpKernel\\HttpCache\\StoreInterface' => $vendorDir . '/symfony/http-kernel/Symfony/Component/HttpKernel/HttpCache/StoreInterface.php', + 'Symfony\\Component\\HttpKernel\\HttpKernel' => $vendorDir . '/symfony/http-kernel/Symfony/Component/HttpKernel/HttpKernel.php', + 'Symfony\\Component\\HttpKernel\\HttpKernelInterface' => $vendorDir . '/symfony/http-kernel/Symfony/Component/HttpKernel/HttpKernelInterface.php', + 'Symfony\\Component\\HttpKernel\\Kernel' => $vendorDir . '/symfony/http-kernel/Symfony/Component/HttpKernel/Kernel.php', + 'Symfony\\Component\\HttpKernel\\KernelEvents' => $vendorDir . '/symfony/http-kernel/Symfony/Component/HttpKernel/KernelEvents.php', + 'Symfony\\Component\\HttpKernel\\KernelInterface' => $vendorDir . '/symfony/http-kernel/Symfony/Component/HttpKernel/KernelInterface.php', + 'Symfony\\Component\\HttpKernel\\Log\\DebugLoggerInterface' => $vendorDir . '/symfony/http-kernel/Symfony/Component/HttpKernel/Log/DebugLoggerInterface.php', + 'Symfony\\Component\\HttpKernel\\Log\\LoggerInterface' => $vendorDir . '/symfony/http-kernel/Symfony/Component/HttpKernel/Log/LoggerInterface.php', + 'Symfony\\Component\\HttpKernel\\Log\\NullLogger' => $vendorDir . '/symfony/http-kernel/Symfony/Component/HttpKernel/Log/NullLogger.php', + 'Symfony\\Component\\HttpKernel\\Profiler\\BaseMemcacheProfilerStorage' => $vendorDir . '/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/BaseMemcacheProfilerStorage.php', + 'Symfony\\Component\\HttpKernel\\Profiler\\FileProfilerStorage' => $vendorDir . '/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/FileProfilerStorage.php', + 'Symfony\\Component\\HttpKernel\\Profiler\\MemcacheProfilerStorage' => $vendorDir . '/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/MemcacheProfilerStorage.php', + 'Symfony\\Component\\HttpKernel\\Profiler\\MemcachedProfilerStorage' => $vendorDir . '/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/MemcachedProfilerStorage.php', + 'Symfony\\Component\\HttpKernel\\Profiler\\MongoDbProfilerStorage' => $vendorDir . '/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/MongoDbProfilerStorage.php', + 'Symfony\\Component\\HttpKernel\\Profiler\\MysqlProfilerStorage' => $vendorDir . '/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/MysqlProfilerStorage.php', + 'Symfony\\Component\\HttpKernel\\Profiler\\PdoProfilerStorage' => $vendorDir . '/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/PdoProfilerStorage.php', + 'Symfony\\Component\\HttpKernel\\Profiler\\Profile' => $vendorDir . '/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/Profile.php', + 'Symfony\\Component\\HttpKernel\\Profiler\\Profiler' => $vendorDir . '/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/Profiler.php', + 'Symfony\\Component\\HttpKernel\\Profiler\\ProfilerStorageInterface' => $vendorDir . '/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/ProfilerStorageInterface.php', + 'Symfony\\Component\\HttpKernel\\Profiler\\RedisProfilerStorage' => $vendorDir . '/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/RedisProfilerStorage.php', + 'Symfony\\Component\\HttpKernel\\Profiler\\SqliteProfilerStorage' => $vendorDir . '/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/SqliteProfilerStorage.php', + 'Symfony\\Component\\HttpKernel\\TerminableInterface' => $vendorDir . '/symfony/http-kernel/Symfony/Component/HttpKernel/TerminableInterface.php', + 'Symfony\\Component\\HttpKernel\\Tests\\Fixtures\\ExtensionAbsentBundle\\ExtensionAbsentBundle' => $vendorDir . '/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fixtures/ExtensionAbsentBundle/ExtensionAbsentBundle.php', + 'Symfony\\Component\\HttpKernel\\Tests\\Fixtures\\ExtensionLoadedBundle\\DependencyInjection\\ExtensionLoadedExtension' => $vendorDir . '/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fixtures/ExtensionLoadedBundle/DependencyInjection/ExtensionLoadedExtension.php', + 'Symfony\\Component\\HttpKernel\\Tests\\Fixtures\\ExtensionLoadedBundle\\ExtensionLoadedBundle' => $vendorDir . '/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fixtures/ExtensionLoadedBundle/ExtensionLoadedBundle.php', + 'Symfony\\Component\\HttpKernel\\Tests\\Fixtures\\ExtensionPresentBundle\\Command\\BarCommand' => $vendorDir . '/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fixtures/ExtensionPresentBundle/Command/BarCommand.php', + 'Symfony\\Component\\HttpKernel\\Tests\\Fixtures\\ExtensionPresentBundle\\Command\\FooCommand' => $vendorDir . '/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fixtures/ExtensionPresentBundle/Command/FooCommand.php', + 'Symfony\\Component\\HttpKernel\\Tests\\Fixtures\\ExtensionPresentBundle\\DependencyInjection\\ExtensionPresentExtension' => $vendorDir . '/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fixtures/ExtensionPresentBundle/DependencyInjection/ExtensionPresentExtension.php', + 'Symfony\\Component\\HttpKernel\\Tests\\Fixtures\\ExtensionPresentBundle\\ExtensionPresentBundle' => $vendorDir . '/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fixtures/ExtensionPresentBundle/ExtensionPresentBundle.php', + 'Symfony\\Component\\HttpKernel\\Tests\\Fixtures\\FooBarBundle' => $vendorDir . '/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fixtures/FooBarBundle.php', + 'Symfony\\Component\\HttpKernel\\Tests\\Fixtures\\KernelForOverrideName' => $vendorDir . '/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fixtures/KernelForOverrideName.php', + 'Symfony\\Component\\HttpKernel\\Tests\\Fixtures\\TestClient' => $vendorDir . '/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fixtures/TestClient.php', + 'Symfony\\Component\\HttpKernel\\Tests\\Fixtures\\TestEventDispatcher' => $vendorDir . '/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Fixtures/TestEventDispatcher.php', + 'Symfony\\Component\\HttpKernel\\Tests\\HttpCache\\HttpCacheTestCase' => $vendorDir . '/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/HttpCache/HttpCacheTestCase.php', + 'Symfony\\Component\\HttpKernel\\Tests\\HttpCache\\TestHttpKernel' => $vendorDir . '/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/HttpCache/TestHttpKernel.php', + 'Symfony\\Component\\HttpKernel\\Tests\\HttpCache\\TestMultipleHttpKernel' => $vendorDir . '/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/HttpCache/TestMultipleHttpKernel.php', + 'Symfony\\Component\\HttpKernel\\Tests\\Logger' => $vendorDir . '/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Logger.php', + 'Symfony\\Component\\HttpKernel\\Tests\\Profiler\\Mock\\MemcacheMock' => $vendorDir . '/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Profiler/Mock/MemcacheMock.php', + 'Symfony\\Component\\HttpKernel\\Tests\\Profiler\\Mock\\MemcachedMock' => $vendorDir . '/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Profiler/Mock/MemcachedMock.php', + 'Symfony\\Component\\HttpKernel\\Tests\\Profiler\\Mock\\RedisMock' => $vendorDir . '/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/Profiler/Mock/RedisMock.php', + 'Symfony\\Component\\HttpKernel\\Tests\\TestHttpKernel' => $vendorDir . '/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/TestHttpKernel.php', + 'Symfony\\Component\\HttpKernel\\UriSigner' => $vendorDir . '/symfony/http-kernel/Symfony/Component/HttpKernel/UriSigner.php', + 'Symfony\\Component\\Process\\Exception\\ExceptionInterface' => $vendorDir . '/symfony/process/Symfony/Component/Process/Exception/ExceptionInterface.php', + 'Symfony\\Component\\Process\\Exception\\InvalidArgumentException' => $vendorDir . '/symfony/process/Symfony/Component/Process/Exception/InvalidArgumentException.php', + 'Symfony\\Component\\Process\\Exception\\LogicException' => $vendorDir . '/symfony/process/Symfony/Component/Process/Exception/LogicException.php', + 'Symfony\\Component\\Process\\Exception\\ProcessFailedException' => $vendorDir . '/symfony/process/Symfony/Component/Process/Exception/ProcessFailedException.php', + 'Symfony\\Component\\Process\\Exception\\ProcessTimedOutException' => $vendorDir . '/symfony/process/Symfony/Component/Process/Exception/ProcessTimedOutException.php', + 'Symfony\\Component\\Process\\Exception\\RuntimeException' => $vendorDir . '/symfony/process/Symfony/Component/Process/Exception/RuntimeException.php', + 'Symfony\\Component\\Process\\ExecutableFinder' => $vendorDir . '/symfony/process/Symfony/Component/Process/ExecutableFinder.php', + 'Symfony\\Component\\Process\\PhpExecutableFinder' => $vendorDir . '/symfony/process/Symfony/Component/Process/PhpExecutableFinder.php', + 'Symfony\\Component\\Process\\PhpProcess' => $vendorDir . '/symfony/process/Symfony/Component/Process/PhpProcess.php', + 'Symfony\\Component\\Process\\Process' => $vendorDir . '/symfony/process/Symfony/Component/Process/Process.php', + 'Symfony\\Component\\Process\\ProcessBuilder' => $vendorDir . '/symfony/process/Symfony/Component/Process/ProcessBuilder.php', + 'Symfony\\Component\\Process\\ProcessPipes' => $vendorDir . '/symfony/process/Symfony/Component/Process/ProcessPipes.php', + 'Symfony\\Component\\Process\\ProcessUtils' => $vendorDir . '/symfony/process/Symfony/Component/Process/ProcessUtils.php', + 'Symfony\\Component\\Process\\Tests\\ProcessInSigchildEnvironment' => $vendorDir . '/symfony/process/Symfony/Component/Process/Tests/ProcessInSigchildEnvironment.php', + 'Symfony\\Component\\Routing\\Annotation\\Route' => $vendorDir . '/symfony/routing/Symfony/Component/Routing/Annotation/Route.php', + 'Symfony\\Component\\Routing\\CompiledRoute' => $vendorDir . '/symfony/routing/Symfony/Component/Routing/CompiledRoute.php', + 'Symfony\\Component\\Routing\\Exception\\ExceptionInterface' => $vendorDir . '/symfony/routing/Symfony/Component/Routing/Exception/ExceptionInterface.php', + 'Symfony\\Component\\Routing\\Exception\\InvalidParameterException' => $vendorDir . '/symfony/routing/Symfony/Component/Routing/Exception/InvalidParameterException.php', + 'Symfony\\Component\\Routing\\Exception\\MethodNotAllowedException' => $vendorDir . '/symfony/routing/Symfony/Component/Routing/Exception/MethodNotAllowedException.php', + 'Symfony\\Component\\Routing\\Exception\\MissingMandatoryParametersException' => $vendorDir . '/symfony/routing/Symfony/Component/Routing/Exception/MissingMandatoryParametersException.php', + 'Symfony\\Component\\Routing\\Exception\\ResourceNotFoundException' => $vendorDir . '/symfony/routing/Symfony/Component/Routing/Exception/ResourceNotFoundException.php', + 'Symfony\\Component\\Routing\\Exception\\RouteNotFoundException' => $vendorDir . '/symfony/routing/Symfony/Component/Routing/Exception/RouteNotFoundException.php', + 'Symfony\\Component\\Routing\\Generator\\ConfigurableRequirementsInterface' => $vendorDir . '/symfony/routing/Symfony/Component/Routing/Generator/ConfigurableRequirementsInterface.php', + 'Symfony\\Component\\Routing\\Generator\\Dumper\\GeneratorDumper' => $vendorDir . '/symfony/routing/Symfony/Component/Routing/Generator/Dumper/GeneratorDumper.php', + 'Symfony\\Component\\Routing\\Generator\\Dumper\\GeneratorDumperInterface' => $vendorDir . '/symfony/routing/Symfony/Component/Routing/Generator/Dumper/GeneratorDumperInterface.php', + 'Symfony\\Component\\Routing\\Generator\\Dumper\\PhpGeneratorDumper' => $vendorDir . '/symfony/routing/Symfony/Component/Routing/Generator/Dumper/PhpGeneratorDumper.php', + 'Symfony\\Component\\Routing\\Generator\\UrlGenerator' => $vendorDir . '/symfony/routing/Symfony/Component/Routing/Generator/UrlGenerator.php', + 'Symfony\\Component\\Routing\\Generator\\UrlGeneratorInterface' => $vendorDir . '/symfony/routing/Symfony/Component/Routing/Generator/UrlGeneratorInterface.php', + 'Symfony\\Component\\Routing\\Loader\\AnnotationClassLoader' => $vendorDir . '/symfony/routing/Symfony/Component/Routing/Loader/AnnotationClassLoader.php', + 'Symfony\\Component\\Routing\\Loader\\AnnotationDirectoryLoader' => $vendorDir . '/symfony/routing/Symfony/Component/Routing/Loader/AnnotationDirectoryLoader.php', + 'Symfony\\Component\\Routing\\Loader\\AnnotationFileLoader' => $vendorDir . '/symfony/routing/Symfony/Component/Routing/Loader/AnnotationFileLoader.php', + 'Symfony\\Component\\Routing\\Loader\\ClosureLoader' => $vendorDir . '/symfony/routing/Symfony/Component/Routing/Loader/ClosureLoader.php', + 'Symfony\\Component\\Routing\\Loader\\PhpFileLoader' => $vendorDir . '/symfony/routing/Symfony/Component/Routing/Loader/PhpFileLoader.php', + 'Symfony\\Component\\Routing\\Loader\\XmlFileLoader' => $vendorDir . '/symfony/routing/Symfony/Component/Routing/Loader/XmlFileLoader.php', + 'Symfony\\Component\\Routing\\Loader\\YamlFileLoader' => $vendorDir . '/symfony/routing/Symfony/Component/Routing/Loader/YamlFileLoader.php', + 'Symfony\\Component\\Routing\\Matcher\\ApacheUrlMatcher' => $vendorDir . '/symfony/routing/Symfony/Component/Routing/Matcher/ApacheUrlMatcher.php', + 'Symfony\\Component\\Routing\\Matcher\\Dumper\\ApacheMatcherDumper' => $vendorDir . '/symfony/routing/Symfony/Component/Routing/Matcher/Dumper/ApacheMatcherDumper.php', + 'Symfony\\Component\\Routing\\Matcher\\Dumper\\DumperCollection' => $vendorDir . '/symfony/routing/Symfony/Component/Routing/Matcher/Dumper/DumperCollection.php', + 'Symfony\\Component\\Routing\\Matcher\\Dumper\\DumperPrefixCollection' => $vendorDir . '/symfony/routing/Symfony/Component/Routing/Matcher/Dumper/DumperPrefixCollection.php', + 'Symfony\\Component\\Routing\\Matcher\\Dumper\\DumperRoute' => $vendorDir . '/symfony/routing/Symfony/Component/Routing/Matcher/Dumper/DumperRoute.php', + 'Symfony\\Component\\Routing\\Matcher\\Dumper\\MatcherDumper' => $vendorDir . '/symfony/routing/Symfony/Component/Routing/Matcher/Dumper/MatcherDumper.php', + 'Symfony\\Component\\Routing\\Matcher\\Dumper\\MatcherDumperInterface' => $vendorDir . '/symfony/routing/Symfony/Component/Routing/Matcher/Dumper/MatcherDumperInterface.php', + 'Symfony\\Component\\Routing\\Matcher\\Dumper\\PhpMatcherDumper' => $vendorDir . '/symfony/routing/Symfony/Component/Routing/Matcher/Dumper/PhpMatcherDumper.php', + 'Symfony\\Component\\Routing\\Matcher\\RedirectableUrlMatcher' => $vendorDir . '/symfony/routing/Symfony/Component/Routing/Matcher/RedirectableUrlMatcher.php', + 'Symfony\\Component\\Routing\\Matcher\\RedirectableUrlMatcherInterface' => $vendorDir . '/symfony/routing/Symfony/Component/Routing/Matcher/RedirectableUrlMatcherInterface.php', + 'Symfony\\Component\\Routing\\Matcher\\RequestMatcherInterface' => $vendorDir . '/symfony/routing/Symfony/Component/Routing/Matcher/RequestMatcherInterface.php', + 'Symfony\\Component\\Routing\\Matcher\\TraceableUrlMatcher' => $vendorDir . '/symfony/routing/Symfony/Component/Routing/Matcher/TraceableUrlMatcher.php', + 'Symfony\\Component\\Routing\\Matcher\\UrlMatcher' => $vendorDir . '/symfony/routing/Symfony/Component/Routing/Matcher/UrlMatcher.php', + 'Symfony\\Component\\Routing\\Matcher\\UrlMatcherInterface' => $vendorDir . '/symfony/routing/Symfony/Component/Routing/Matcher/UrlMatcherInterface.php', + 'Symfony\\Component\\Routing\\RequestContext' => $vendorDir . '/symfony/routing/Symfony/Component/Routing/RequestContext.php', + 'Symfony\\Component\\Routing\\RequestContextAwareInterface' => $vendorDir . '/symfony/routing/Symfony/Component/Routing/RequestContextAwareInterface.php', + 'Symfony\\Component\\Routing\\Route' => $vendorDir . '/symfony/routing/Symfony/Component/Routing/Route.php', + 'Symfony\\Component\\Routing\\RouteCollection' => $vendorDir . '/symfony/routing/Symfony/Component/Routing/RouteCollection.php', + 'Symfony\\Component\\Routing\\RouteCompiler' => $vendorDir . '/symfony/routing/Symfony/Component/Routing/RouteCompiler.php', + 'Symfony\\Component\\Routing\\RouteCompilerInterface' => $vendorDir . '/symfony/routing/Symfony/Component/Routing/RouteCompilerInterface.php', + 'Symfony\\Component\\Routing\\Router' => $vendorDir . '/symfony/routing/Symfony/Component/Routing/Router.php', + 'Symfony\\Component\\Routing\\RouterInterface' => $vendorDir . '/symfony/routing/Symfony/Component/Routing/RouterInterface.php', + 'Symfony\\Component\\Routing\\Tests\\Fixtures\\AnnotatedClasses\\AbstractClass' => $vendorDir . '/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/AnnotatedClasses/AbstractClass.php', + 'Symfony\\Component\\Routing\\Tests\\Fixtures\\AnnotatedClasses\\BarClass' => $vendorDir . '/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/AnnotatedClasses/BarClass.php', + 'Symfony\\Component\\Routing\\Tests\\Fixtures\\AnnotatedClasses\\FooClass' => $vendorDir . '/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/AnnotatedClasses/FooClass.php', + 'Symfony\\Component\\Routing\\Tests\\Fixtures\\CustomXmlFileLoader' => $vendorDir . '/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/CustomXmlFileLoader.php', + 'Symfony\\Component\\Routing\\Tests\\Fixtures\\RedirectableUrlMatcher' => $vendorDir . '/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/RedirectableUrlMatcher.php', + 'Symfony\\Component\\Security\\Core\\AuthenticationEvents' => $vendorDir . '/symfony/security-core/Symfony/Component/Security/Core/AuthenticationEvents.php', + 'Symfony\\Component\\Security\\Core\\Authentication\\AuthenticationManagerInterface' => $vendorDir . '/symfony/security-core/Symfony/Component/Security/Core/Authentication/AuthenticationManagerInterface.php', + 'Symfony\\Component\\Security\\Core\\Authentication\\AuthenticationProviderManager' => $vendorDir . '/symfony/security-core/Symfony/Component/Security/Core/Authentication/AuthenticationProviderManager.php', + 'Symfony\\Component\\Security\\Core\\Authentication\\AuthenticationTrustResolver' => $vendorDir . '/symfony/security-core/Symfony/Component/Security/Core/Authentication/AuthenticationTrustResolver.php', + 'Symfony\\Component\\Security\\Core\\Authentication\\AuthenticationTrustResolverInterface' => $vendorDir . '/symfony/security-core/Symfony/Component/Security/Core/Authentication/AuthenticationTrustResolverInterface.php', + 'Symfony\\Component\\Security\\Core\\Authentication\\Provider\\AnonymousAuthenticationProvider' => $vendorDir . '/symfony/security-core/Symfony/Component/Security/Core/Authentication/Provider/AnonymousAuthenticationProvider.php', + 'Symfony\\Component\\Security\\Core\\Authentication\\Provider\\AuthenticationProviderInterface' => $vendorDir . '/symfony/security-core/Symfony/Component/Security/Core/Authentication/Provider/AuthenticationProviderInterface.php', + 'Symfony\\Component\\Security\\Core\\Authentication\\Provider\\DaoAuthenticationProvider' => $vendorDir . '/symfony/security-core/Symfony/Component/Security/Core/Authentication/Provider/DaoAuthenticationProvider.php', + 'Symfony\\Component\\Security\\Core\\Authentication\\Provider\\PreAuthenticatedAuthenticationProvider' => $vendorDir . '/symfony/security-core/Symfony/Component/Security/Core/Authentication/Provider/PreAuthenticatedAuthenticationProvider.php', + 'Symfony\\Component\\Security\\Core\\Authentication\\Provider\\RememberMeAuthenticationProvider' => $vendorDir . '/symfony/security-core/Symfony/Component/Security/Core/Authentication/Provider/RememberMeAuthenticationProvider.php', + 'Symfony\\Component\\Security\\Core\\Authentication\\Provider\\SimpleAuthenticationProvider' => $vendorDir . '/symfony/security-core/Symfony/Component/Security/Core/Authentication/Provider/SimpleAuthenticationProvider.php', + 'Symfony\\Component\\Security\\Core\\Authentication\\Provider\\UserAuthenticationProvider' => $vendorDir . '/symfony/security-core/Symfony/Component/Security/Core/Authentication/Provider/UserAuthenticationProvider.php', + 'Symfony\\Component\\Security\\Core\\Authentication\\RememberMe\\InMemoryTokenProvider' => $vendorDir . '/symfony/security-core/Symfony/Component/Security/Core/Authentication/RememberMe/InMemoryTokenProvider.php', + 'Symfony\\Component\\Security\\Core\\Authentication\\RememberMe\\PersistentToken' => $vendorDir . '/symfony/security-core/Symfony/Component/Security/Core/Authentication/RememberMe/PersistentToken.php', + 'Symfony\\Component\\Security\\Core\\Authentication\\RememberMe\\PersistentTokenInterface' => $vendorDir . '/symfony/security-core/Symfony/Component/Security/Core/Authentication/RememberMe/PersistentTokenInterface.php', + 'Symfony\\Component\\Security\\Core\\Authentication\\RememberMe\\TokenProviderInterface' => $vendorDir . '/symfony/security-core/Symfony/Component/Security/Core/Authentication/RememberMe/TokenProviderInterface.php', + 'Symfony\\Component\\Security\\Core\\Authentication\\SimpleAuthenticatorInterface' => $vendorDir . '/symfony/security-core/Symfony/Component/Security/Core/Authentication/SimpleAuthenticatorInterface.php', + 'Symfony\\Component\\Security\\Core\\Authentication\\SimpleFormAuthenticatorInterface' => $vendorDir . '/symfony/security-core/Symfony/Component/Security/Core/Authentication/SimpleFormAuthenticatorInterface.php', + 'Symfony\\Component\\Security\\Core\\Authentication\\SimplePreAuthenticatorInterface' => $vendorDir . '/symfony/security-core/Symfony/Component/Security/Core/Authentication/SimplePreAuthenticatorInterface.php', + 'Symfony\\Component\\Security\\Core\\Authentication\\Token\\AbstractToken' => $vendorDir . '/symfony/security-core/Symfony/Component/Security/Core/Authentication/Token/AbstractToken.php', + 'Symfony\\Component\\Security\\Core\\Authentication\\Token\\AnonymousToken' => $vendorDir . '/symfony/security-core/Symfony/Component/Security/Core/Authentication/Token/AnonymousToken.php', + 'Symfony\\Component\\Security\\Core\\Authentication\\Token\\PreAuthenticatedToken' => $vendorDir . '/symfony/security-core/Symfony/Component/Security/Core/Authentication/Token/PreAuthenticatedToken.php', + 'Symfony\\Component\\Security\\Core\\Authentication\\Token\\RememberMeToken' => $vendorDir . '/symfony/security-core/Symfony/Component/Security/Core/Authentication/Token/RememberMeToken.php', + 'Symfony\\Component\\Security\\Core\\Authentication\\Token\\TokenInterface' => $vendorDir . '/symfony/security-core/Symfony/Component/Security/Core/Authentication/Token/TokenInterface.php', + 'Symfony\\Component\\Security\\Core\\Authentication\\Token\\UsernamePasswordToken' => $vendorDir . '/symfony/security-core/Symfony/Component/Security/Core/Authentication/Token/UsernamePasswordToken.php', + 'Symfony\\Component\\Security\\Core\\Authorization\\AccessDecisionManager' => $vendorDir . '/symfony/security-core/Symfony/Component/Security/Core/Authorization/AccessDecisionManager.php', + 'Symfony\\Component\\Security\\Core\\Authorization\\AccessDecisionManagerInterface' => $vendorDir . '/symfony/security-core/Symfony/Component/Security/Core/Authorization/AccessDecisionManagerInterface.php', + 'Symfony\\Component\\Security\\Core\\Authorization\\ExpressionLanguage' => $vendorDir . '/symfony/security-core/Symfony/Component/Security/Core/Authorization/ExpressionLanguage.php', + 'Symfony\\Component\\Security\\Core\\Authorization\\Voter\\AuthenticatedVoter' => $vendorDir . '/symfony/security-core/Symfony/Component/Security/Core/Authorization/Voter/AuthenticatedVoter.php', + 'Symfony\\Component\\Security\\Core\\Authorization\\Voter\\ExpressionVoter' => $vendorDir . '/symfony/security-core/Symfony/Component/Security/Core/Authorization/Voter/ExpressionVoter.php', + 'Symfony\\Component\\Security\\Core\\Authorization\\Voter\\RoleHierarchyVoter' => $vendorDir . '/symfony/security-core/Symfony/Component/Security/Core/Authorization/Voter/RoleHierarchyVoter.php', + 'Symfony\\Component\\Security\\Core\\Authorization\\Voter\\RoleVoter' => $vendorDir . '/symfony/security-core/Symfony/Component/Security/Core/Authorization/Voter/RoleVoter.php', + 'Symfony\\Component\\Security\\Core\\Authorization\\Voter\\VoterInterface' => $vendorDir . '/symfony/security-core/Symfony/Component/Security/Core/Authorization/Voter/VoterInterface.php', + 'Symfony\\Component\\Security\\Core\\Encoder\\BCryptPasswordEncoder' => $vendorDir . '/symfony/security-core/Symfony/Component/Security/Core/Encoder/BCryptPasswordEncoder.php', + 'Symfony\\Component\\Security\\Core\\Encoder\\BasePasswordEncoder' => $vendorDir . '/symfony/security-core/Symfony/Component/Security/Core/Encoder/BasePasswordEncoder.php', + 'Symfony\\Component\\Security\\Core\\Encoder\\EncoderFactory' => $vendorDir . '/symfony/security-core/Symfony/Component/Security/Core/Encoder/EncoderFactory.php', + 'Symfony\\Component\\Security\\Core\\Encoder\\EncoderFactoryInterface' => $vendorDir . '/symfony/security-core/Symfony/Component/Security/Core/Encoder/EncoderFactoryInterface.php', + 'Symfony\\Component\\Security\\Core\\Encoder\\MessageDigestPasswordEncoder' => $vendorDir . '/symfony/security-core/Symfony/Component/Security/Core/Encoder/MessageDigestPasswordEncoder.php', + 'Symfony\\Component\\Security\\Core\\Encoder\\PasswordEncoderInterface' => $vendorDir . '/symfony/security-core/Symfony/Component/Security/Core/Encoder/PasswordEncoderInterface.php', + 'Symfony\\Component\\Security\\Core\\Encoder\\Pbkdf2PasswordEncoder' => $vendorDir . '/symfony/security-core/Symfony/Component/Security/Core/Encoder/Pbkdf2PasswordEncoder.php', + 'Symfony\\Component\\Security\\Core\\Encoder\\PlaintextPasswordEncoder' => $vendorDir . '/symfony/security-core/Symfony/Component/Security/Core/Encoder/PlaintextPasswordEncoder.php', + 'Symfony\\Component\\Security\\Core\\Event\\AuthenticationEvent' => $vendorDir . '/symfony/security-core/Symfony/Component/Security/Core/Event/AuthenticationEvent.php', + 'Symfony\\Component\\Security\\Core\\Event\\AuthenticationFailureEvent' => $vendorDir . '/symfony/security-core/Symfony/Component/Security/Core/Event/AuthenticationFailureEvent.php', + 'Symfony\\Component\\Security\\Core\\Exception\\AccessDeniedException' => $vendorDir . '/symfony/security-core/Symfony/Component/Security/Core/Exception/AccessDeniedException.php', + 'Symfony\\Component\\Security\\Core\\Exception\\AccountExpiredException' => $vendorDir . '/symfony/security-core/Symfony/Component/Security/Core/Exception/AccountExpiredException.php', + 'Symfony\\Component\\Security\\Core\\Exception\\AccountStatusException' => $vendorDir . '/symfony/security-core/Symfony/Component/Security/Core/Exception/AccountStatusException.php', + 'Symfony\\Component\\Security\\Core\\Exception\\AuthenticationCredentialsNotFoundException' => $vendorDir . '/symfony/security-core/Symfony/Component/Security/Core/Exception/AuthenticationCredentialsNotFoundException.php', + 'Symfony\\Component\\Security\\Core\\Exception\\AuthenticationException' => $vendorDir . '/symfony/security-core/Symfony/Component/Security/Core/Exception/AuthenticationException.php', + 'Symfony\\Component\\Security\\Core\\Exception\\AuthenticationServiceException' => $vendorDir . '/symfony/security-core/Symfony/Component/Security/Core/Exception/AuthenticationServiceException.php', + 'Symfony\\Component\\Security\\Core\\Exception\\BadCredentialsException' => $vendorDir . '/symfony/security-core/Symfony/Component/Security/Core/Exception/BadCredentialsException.php', + 'Symfony\\Component\\Security\\Core\\Exception\\CookieTheftException' => $vendorDir . '/symfony/security-core/Symfony/Component/Security/Core/Exception/CookieTheftException.php', + 'Symfony\\Component\\Security\\Core\\Exception\\CredentialsExpiredException' => $vendorDir . '/symfony/security-core/Symfony/Component/Security/Core/Exception/CredentialsExpiredException.php', + 'Symfony\\Component\\Security\\Core\\Exception\\DisabledException' => $vendorDir . '/symfony/security-core/Symfony/Component/Security/Core/Exception/DisabledException.php', + 'Symfony\\Component\\Security\\Core\\Exception\\ExceptionInterface' => $vendorDir . '/symfony/security-core/Symfony/Component/Security/Core/Exception/ExceptionInterface.php', + 'Symfony\\Component\\Security\\Core\\Exception\\InsufficientAuthenticationException' => $vendorDir . '/symfony/security-core/Symfony/Component/Security/Core/Exception/InsufficientAuthenticationException.php', + 'Symfony\\Component\\Security\\Core\\Exception\\InvalidArgumentException' => $vendorDir . '/symfony/security-core/Symfony/Component/Security/Core/Exception/InvalidArgumentException.php', + 'Symfony\\Component\\Security\\Core\\Exception\\InvalidCsrfTokenException' => $vendorDir . '/symfony/security-core/Symfony/Component/Security/Core/Exception/InvalidCsrfTokenException.php', + 'Symfony\\Component\\Security\\Core\\Exception\\LockedException' => $vendorDir . '/symfony/security-core/Symfony/Component/Security/Core/Exception/LockedException.php', + 'Symfony\\Component\\Security\\Core\\Exception\\LogoutException' => $vendorDir . '/symfony/security-core/Symfony/Component/Security/Core/Exception/LogoutException.php', + 'Symfony\\Component\\Security\\Core\\Exception\\NonceExpiredException' => $vendorDir . '/symfony/security-core/Symfony/Component/Security/Core/Exception/NonceExpiredException.php', + 'Symfony\\Component\\Security\\Core\\Exception\\ProviderNotFoundException' => $vendorDir . '/symfony/security-core/Symfony/Component/Security/Core/Exception/ProviderNotFoundException.php', + 'Symfony\\Component\\Security\\Core\\Exception\\RuntimeException' => $vendorDir . '/symfony/security-core/Symfony/Component/Security/Core/Exception/RuntimeException.php', + 'Symfony\\Component\\Security\\Core\\Exception\\SessionUnavailableException' => $vendorDir . '/symfony/security-core/Symfony/Component/Security/Core/Exception/SessionUnavailableException.php', + 'Symfony\\Component\\Security\\Core\\Exception\\TokenNotFoundException' => $vendorDir . '/symfony/security-core/Symfony/Component/Security/Core/Exception/TokenNotFoundException.php', + 'Symfony\\Component\\Security\\Core\\Exception\\UnsupportedUserException' => $vendorDir . '/symfony/security-core/Symfony/Component/Security/Core/Exception/UnsupportedUserException.php', + 'Symfony\\Component\\Security\\Core\\Exception\\UsernameNotFoundException' => $vendorDir . '/symfony/security-core/Symfony/Component/Security/Core/Exception/UsernameNotFoundException.php', + 'Symfony\\Component\\Security\\Core\\Role\\Role' => $vendorDir . '/symfony/security-core/Symfony/Component/Security/Core/Role/Role.php', + 'Symfony\\Component\\Security\\Core\\Role\\RoleHierarchy' => $vendorDir . '/symfony/security-core/Symfony/Component/Security/Core/Role/RoleHierarchy.php', + 'Symfony\\Component\\Security\\Core\\Role\\RoleHierarchyInterface' => $vendorDir . '/symfony/security-core/Symfony/Component/Security/Core/Role/RoleHierarchyInterface.php', + 'Symfony\\Component\\Security\\Core\\Role\\RoleInterface' => $vendorDir . '/symfony/security-core/Symfony/Component/Security/Core/Role/RoleInterface.php', + 'Symfony\\Component\\Security\\Core\\Role\\SwitchUserRole' => $vendorDir . '/symfony/security-core/Symfony/Component/Security/Core/Role/SwitchUserRole.php', + 'Symfony\\Component\\Security\\Core\\SecurityContext' => $vendorDir . '/symfony/security-core/Symfony/Component/Security/Core/SecurityContext.php', + 'Symfony\\Component\\Security\\Core\\SecurityContextInterface' => $vendorDir . '/symfony/security-core/Symfony/Component/Security/Core/SecurityContextInterface.php', + 'Symfony\\Component\\Security\\Core\\User\\AdvancedUserInterface' => $vendorDir . '/symfony/security-core/Symfony/Component/Security/Core/User/AdvancedUserInterface.php', + 'Symfony\\Component\\Security\\Core\\User\\ChainUserProvider' => $vendorDir . '/symfony/security-core/Symfony/Component/Security/Core/User/ChainUserProvider.php', + 'Symfony\\Component\\Security\\Core\\User\\EquatableInterface' => $vendorDir . '/symfony/security-core/Symfony/Component/Security/Core/User/EquatableInterface.php', + 'Symfony\\Component\\Security\\Core\\User\\InMemoryUserProvider' => $vendorDir . '/symfony/security-core/Symfony/Component/Security/Core/User/InMemoryUserProvider.php', + 'Symfony\\Component\\Security\\Core\\User\\User' => $vendorDir . '/symfony/security-core/Symfony/Component/Security/Core/User/User.php', + 'Symfony\\Component\\Security\\Core\\User\\UserChecker' => $vendorDir . '/symfony/security-core/Symfony/Component/Security/Core/User/UserChecker.php', + 'Symfony\\Component\\Security\\Core\\User\\UserCheckerInterface' => $vendorDir . '/symfony/security-core/Symfony/Component/Security/Core/User/UserCheckerInterface.php', + 'Symfony\\Component\\Security\\Core\\User\\UserInterface' => $vendorDir . '/symfony/security-core/Symfony/Component/Security/Core/User/UserInterface.php', + 'Symfony\\Component\\Security\\Core\\User\\UserProviderInterface' => $vendorDir . '/symfony/security-core/Symfony/Component/Security/Core/User/UserProviderInterface.php', + 'Symfony\\Component\\Security\\Core\\Util\\ClassUtils' => $vendorDir . '/symfony/security-core/Symfony/Component/Security/Core/Util/ClassUtils.php', + 'Symfony\\Component\\Security\\Core\\Util\\SecureRandom' => $vendorDir . '/symfony/security-core/Symfony/Component/Security/Core/Util/SecureRandom.php', + 'Symfony\\Component\\Security\\Core\\Util\\SecureRandomInterface' => $vendorDir . '/symfony/security-core/Symfony/Component/Security/Core/Util/SecureRandomInterface.php', + 'Symfony\\Component\\Security\\Core\\Util\\StringUtils' => $vendorDir . '/symfony/security-core/Symfony/Component/Security/Core/Util/StringUtils.php', + 'Symfony\\Component\\Security\\Core\\Validator\\Constraints\\UserPassword' => $vendorDir . '/symfony/security-core/Symfony/Component/Security/Core/Validator/Constraints/UserPassword.php', + 'Symfony\\Component\\Security\\Core\\Validator\\Constraints\\UserPasswordValidator' => $vendorDir . '/symfony/security-core/Symfony/Component/Security/Core/Validator/Constraints/UserPasswordValidator.php', + 'Symfony\\Component\\Translation\\Catalogue\\AbstractOperation' => $vendorDir . '/symfony/translation/Symfony/Component/Translation/Catalogue/AbstractOperation.php', + 'Symfony\\Component\\Translation\\Catalogue\\DiffOperation' => $vendorDir . '/symfony/translation/Symfony/Component/Translation/Catalogue/DiffOperation.php', + 'Symfony\\Component\\Translation\\Catalogue\\MergeOperation' => $vendorDir . '/symfony/translation/Symfony/Component/Translation/Catalogue/MergeOperation.php', + 'Symfony\\Component\\Translation\\Catalogue\\OperationInterface' => $vendorDir . '/symfony/translation/Symfony/Component/Translation/Catalogue/OperationInterface.php', + 'Symfony\\Component\\Translation\\Dumper\\CsvFileDumper' => $vendorDir . '/symfony/translation/Symfony/Component/Translation/Dumper/CsvFileDumper.php', + 'Symfony\\Component\\Translation\\Dumper\\DumperInterface' => $vendorDir . '/symfony/translation/Symfony/Component/Translation/Dumper/DumperInterface.php', + 'Symfony\\Component\\Translation\\Dumper\\FileDumper' => $vendorDir . '/symfony/translation/Symfony/Component/Translation/Dumper/FileDumper.php', + 'Symfony\\Component\\Translation\\Dumper\\IcuResFileDumper' => $vendorDir . '/symfony/translation/Symfony/Component/Translation/Dumper/IcuResFileDumper.php', + 'Symfony\\Component\\Translation\\Dumper\\IniFileDumper' => $vendorDir . '/symfony/translation/Symfony/Component/Translation/Dumper/IniFileDumper.php', + 'Symfony\\Component\\Translation\\Dumper\\JsonFileDumper' => $vendorDir . '/symfony/translation/Symfony/Component/Translation/Dumper/JsonFileDumper.php', + 'Symfony\\Component\\Translation\\Dumper\\MoFileDumper' => $vendorDir . '/symfony/translation/Symfony/Component/Translation/Dumper/MoFileDumper.php', + 'Symfony\\Component\\Translation\\Dumper\\PhpFileDumper' => $vendorDir . '/symfony/translation/Symfony/Component/Translation/Dumper/PhpFileDumper.php', + 'Symfony\\Component\\Translation\\Dumper\\PoFileDumper' => $vendorDir . '/symfony/translation/Symfony/Component/Translation/Dumper/PoFileDumper.php', + 'Symfony\\Component\\Translation\\Dumper\\QtFileDumper' => $vendorDir . '/symfony/translation/Symfony/Component/Translation/Dumper/QtFileDumper.php', + 'Symfony\\Component\\Translation\\Dumper\\XliffFileDumper' => $vendorDir . '/symfony/translation/Symfony/Component/Translation/Dumper/XliffFileDumper.php', + 'Symfony\\Component\\Translation\\Dumper\\YamlFileDumper' => $vendorDir . '/symfony/translation/Symfony/Component/Translation/Dumper/YamlFileDumper.php', + 'Symfony\\Component\\Translation\\Exception\\ExceptionInterface' => $vendorDir . '/symfony/translation/Symfony/Component/Translation/Exception/ExceptionInterface.php', + 'Symfony\\Component\\Translation\\Exception\\InvalidResourceException' => $vendorDir . '/symfony/translation/Symfony/Component/Translation/Exception/InvalidResourceException.php', + 'Symfony\\Component\\Translation\\Exception\\NotFoundResourceException' => $vendorDir . '/symfony/translation/Symfony/Component/Translation/Exception/NotFoundResourceException.php', + 'Symfony\\Component\\Translation\\Extractor\\ChainExtractor' => $vendorDir . '/symfony/translation/Symfony/Component/Translation/Extractor/ChainExtractor.php', + 'Symfony\\Component\\Translation\\Extractor\\ExtractorInterface' => $vendorDir . '/symfony/translation/Symfony/Component/Translation/Extractor/ExtractorInterface.php', + 'Symfony\\Component\\Translation\\IdentityTranslator' => $vendorDir . '/symfony/translation/Symfony/Component/Translation/IdentityTranslator.php', + 'Symfony\\Component\\Translation\\Interval' => $vendorDir . '/symfony/translation/Symfony/Component/Translation/Interval.php', + 'Symfony\\Component\\Translation\\Loader\\ArrayLoader' => $vendorDir . '/symfony/translation/Symfony/Component/Translation/Loader/ArrayLoader.php', + 'Symfony\\Component\\Translation\\Loader\\CsvFileLoader' => $vendorDir . '/symfony/translation/Symfony/Component/Translation/Loader/CsvFileLoader.php', + 'Symfony\\Component\\Translation\\Loader\\IcuDatFileLoader' => $vendorDir . '/symfony/translation/Symfony/Component/Translation/Loader/IcuDatFileLoader.php', + 'Symfony\\Component\\Translation\\Loader\\IcuResFileLoader' => $vendorDir . '/symfony/translation/Symfony/Component/Translation/Loader/IcuResFileLoader.php', + 'Symfony\\Component\\Translation\\Loader\\IniFileLoader' => $vendorDir . '/symfony/translation/Symfony/Component/Translation/Loader/IniFileLoader.php', + 'Symfony\\Component\\Translation\\Loader\\JsonFileLoader' => $vendorDir . '/symfony/translation/Symfony/Component/Translation/Loader/JsonFileLoader.php', + 'Symfony\\Component\\Translation\\Loader\\LoaderInterface' => $vendorDir . '/symfony/translation/Symfony/Component/Translation/Loader/LoaderInterface.php', + 'Symfony\\Component\\Translation\\Loader\\MoFileLoader' => $vendorDir . '/symfony/translation/Symfony/Component/Translation/Loader/MoFileLoader.php', + 'Symfony\\Component\\Translation\\Loader\\PhpFileLoader' => $vendorDir . '/symfony/translation/Symfony/Component/Translation/Loader/PhpFileLoader.php', + 'Symfony\\Component\\Translation\\Loader\\PoFileLoader' => $vendorDir . '/symfony/translation/Symfony/Component/Translation/Loader/PoFileLoader.php', + 'Symfony\\Component\\Translation\\Loader\\QtFileLoader' => $vendorDir . '/symfony/translation/Symfony/Component/Translation/Loader/QtFileLoader.php', + 'Symfony\\Component\\Translation\\Loader\\XliffFileLoader' => $vendorDir . '/symfony/translation/Symfony/Component/Translation/Loader/XliffFileLoader.php', + 'Symfony\\Component\\Translation\\Loader\\YamlFileLoader' => $vendorDir . '/symfony/translation/Symfony/Component/Translation/Loader/YamlFileLoader.php', + 'Symfony\\Component\\Translation\\MessageCatalogue' => $vendorDir . '/symfony/translation/Symfony/Component/Translation/MessageCatalogue.php', + 'Symfony\\Component\\Translation\\MessageCatalogueInterface' => $vendorDir . '/symfony/translation/Symfony/Component/Translation/MessageCatalogueInterface.php', + 'Symfony\\Component\\Translation\\MessageSelector' => $vendorDir . '/symfony/translation/Symfony/Component/Translation/MessageSelector.php', + 'Symfony\\Component\\Translation\\MetadataAwareInterface' => $vendorDir . '/symfony/translation/Symfony/Component/Translation/MetadataAwareInterface.php', + 'Symfony\\Component\\Translation\\PluralizationRules' => $vendorDir . '/symfony/translation/Symfony/Component/Translation/PluralizationRules.php', + 'Symfony\\Component\\Translation\\Tests\\Loader\\LocalizedTestCase' => $vendorDir . '/symfony/translation/Symfony/Component/Translation/Tests/Loader/LocalizedTestCase.php', + 'Symfony\\Component\\Translation\\Translator' => $vendorDir . '/symfony/translation/Symfony/Component/Translation/Translator.php', + 'Symfony\\Component\\Translation\\TranslatorInterface' => $vendorDir . '/symfony/translation/Symfony/Component/Translation/TranslatorInterface.php', + 'Symfony\\Component\\Translation\\Writer\\TranslationWriter' => $vendorDir . '/symfony/translation/Symfony/Component/Translation/Writer/TranslationWriter.php', + 'System_SSH_Agent' => $vendorDir . '/phpseclib/phpseclib/phpseclib/System/SSH_Agent.php', + 'System_SSH_Agent_Identity' => $vendorDir . '/phpseclib/phpseclib/phpseclib/System/SSH_Agent.php', + 'TestCase' => $baseDir . '/app/tests/TestCase.php', + 'User' => $baseDir . '/app/models/User.php', + 'Whoops\\Exception\\ErrorException' => $vendorDir . '/filp/whoops/src/Whoops/Exception/ErrorException.php', + 'Whoops\\Exception\\Frame' => $vendorDir . '/filp/whoops/src/Whoops/Exception/Frame.php', + 'Whoops\\Exception\\FrameCollection' => $vendorDir . '/filp/whoops/src/Whoops/Exception/FrameCollection.php', + 'Whoops\\Exception\\Inspector' => $vendorDir . '/filp/whoops/src/Whoops/Exception/Inspector.php', + 'Whoops\\Handler\\CallbackHandler' => $vendorDir . '/filp/whoops/src/Whoops/Handler/CallbackHandler.php', + 'Whoops\\Handler\\Handler' => $vendorDir . '/filp/whoops/src/Whoops/Handler/Handler.php', + 'Whoops\\Handler\\HandlerInterface' => $vendorDir . '/filp/whoops/src/Whoops/Handler/HandlerInterface.php', + 'Whoops\\Handler\\JsonResponseHandler' => $vendorDir . '/filp/whoops/src/Whoops/Handler/JsonResponseHandler.php', + 'Whoops\\Handler\\PrettyPageHandler' => $vendorDir . '/filp/whoops/src/Whoops/Handler/PrettyPageHandler.php', + 'Whoops\\Handler\\XmlResponseHandler' => $vendorDir . '/filp/whoops/src/Whoops/Handler/XmlResponseHandler.php', + 'Whoops\\Module' => $vendorDir . '/filp/whoops/src/Whoops/Provider/Zend/Module.php', + 'Whoops\\Provider\\Phalcon\\WhoopsServiceProvider' => $vendorDir . '/filp/whoops/src/Whoops/Provider/Phalcon/WhoopsServiceProvider.php', + 'Whoops\\Provider\\Silex\\WhoopsServiceProvider' => $vendorDir . '/filp/whoops/src/Whoops/Provider/Silex/WhoopsServiceProvider.php', + 'Whoops\\Provider\\Zend\\ExceptionStrategy' => $vendorDir . '/filp/whoops/src/Whoops/Provider/Zend/ExceptionStrategy.php', + 'Whoops\\Provider\\Zend\\RouteNotFoundStrategy' => $vendorDir . '/filp/whoops/src/Whoops/Provider/Zend/RouteNotFoundStrategy.php', + 'Whoops\\Run' => $vendorDir . '/filp/whoops/src/Whoops/Run.php', +); diff --git a/vendor/composer/autoload_files.php b/vendor/composer/autoload_files.php new file mode 100755 index 0000000..be45f2d --- /dev/null +++ b/vendor/composer/autoload_files.php @@ -0,0 +1,13 @@ + array($vendorDir . '/filp/whoops/src'), + 'System' => array($vendorDir . '/phpseclib/phpseclib/phpseclib'), + 'Symfony\\Component\\Translation\\' => array($vendorDir . '/symfony/translation'), + 'Symfony\\Component\\Security\\Core\\' => array($vendorDir . '/symfony/security-core'), + 'Symfony\\Component\\Routing\\' => array($vendorDir . '/symfony/routing'), + 'Symfony\\Component\\Process\\' => array($vendorDir . '/symfony/process'), + 'Symfony\\Component\\HttpKernel\\' => array($vendorDir . '/symfony/http-kernel'), + 'Symfony\\Component\\HttpFoundation\\' => array($vendorDir . '/symfony/http-foundation'), + 'Symfony\\Component\\Finder\\' => array($vendorDir . '/symfony/finder'), + 'Symfony\\Component\\Filesystem\\' => array($vendorDir . '/symfony/filesystem'), + 'Symfony\\Component\\EventDispatcher\\' => array($vendorDir . '/symfony/event-dispatcher'), + 'Symfony\\Component\\DomCrawler\\' => array($vendorDir . '/symfony/dom-crawler'), + 'Symfony\\Component\\Debug\\' => array($vendorDir . '/symfony/debug'), + 'Symfony\\Component\\CssSelector\\' => array($vendorDir . '/symfony/css-selector'), + 'Symfony\\Component\\Console\\' => array($vendorDir . '/symfony/console'), + 'Symfony\\Component\\BrowserKit\\' => array($vendorDir . '/symfony/browser-kit'), + 'Stack' => array($vendorDir . '/stack/builder/src'), + 'Psr\\Log\\' => array($vendorDir . '/psr/log'), + 'Predis' => array($vendorDir . '/predis/predis/lib'), + 'Patchwork' => array($vendorDir . '/patchwork/utf8/class'), + 'PHPParser' => array($vendorDir . '/nikic/php-parser/lib'), + 'Normalizer' => array($vendorDir . '/patchwork/utf8/class'), + 'Net' => array($vendorDir . '/phpseclib/phpseclib/phpseclib'), + 'Math' => array($vendorDir . '/phpseclib/phpseclib/phpseclib'), + 'Jeremeamia\\SuperClosure' => array($vendorDir . '/jeremeamia/SuperClosure/src'), + 'Illuminate' => array($vendorDir . '/laravel/framework/src'), + 'File' => array($vendorDir . '/phpseclib/phpseclib/phpseclib'), + 'Crypt' => array($vendorDir . '/phpseclib/phpseclib/phpseclib'), + 'ClassPreloader' => array($vendorDir . '/classpreloader/classpreloader/src'), + 'Carbon' => array($vendorDir . '/nesbot/carbon/src'), + 'Boris' => array($vendorDir . '/d11wtq/boris/lib'), +); diff --git a/vendor/composer/autoload_psr4.php b/vendor/composer/autoload_psr4.php new file mode 100755 index 0000000..97bc5b2 --- /dev/null +++ b/vendor/composer/autoload_psr4.php @@ -0,0 +1,10 @@ + array($vendorDir . '/monolog/monolog/src/Monolog'), +); diff --git a/vendor/composer/autoload_real.php b/vendor/composer/autoload_real.php new file mode 100755 index 0000000..34f50bc --- /dev/null +++ b/vendor/composer/autoload_real.php @@ -0,0 +1,62 @@ + $path) { + $loader->set($namespace, $path); + } + + $map = require __DIR__ . '/autoload_psr4.php'; + foreach ($map as $namespace => $path) { + $loader->setPsr4($namespace, $path); + } + + $classMap = require __DIR__ . '/autoload_classmap.php'; + if ($classMap) { + $loader->addClassMap($classMap); + } + + $loader->register(true); + + $includeFiles = require __DIR__ . '/autoload_files.php'; + foreach ($includeFiles as $file) { + composerRequiree4e3eb106a63a7e39b4baf325e8b1d7e($file); + } + + return $loader; + } +} + +function composerRequiree4e3eb106a63a7e39b4baf325e8b1d7e($file) +{ + require $file; +} diff --git a/vendor/composer/include_paths.php b/vendor/composer/include_paths.php new file mode 100755 index 0000000..958b960 --- /dev/null +++ b/vendor/composer/include_paths.php @@ -0,0 +1,10 @@ +=5.3.3" + }, + "require-dev": { + "symfony/config": "~2.0", + "symfony/yaml": "~2.2" + }, + "suggest": { + "symfony/config": "", + "symfony/yaml": "" + }, + "time": "2014-05-22 13:46:01", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.4-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-0": { + "Symfony\\Component\\Translation\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com", + "homepage": "http://fabien.potencier.org", + "role": "Lead Developer" + }, + { + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + } + ], + "description": "Symfony Translation Component", + "homepage": "http://symfony.com" + }, + { + "name": "symfony/security-core", + "version": "v2.4.6", + "version_normalized": "2.4.6.0", + "target-dir": "Symfony/Component/Security/Core", + "source": { + "type": "git", + "url": "https://github.com/symfony/security-core.git", + "reference": "1fbe80d10b7a5bcb619abe3e4cfede795d9958dc" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/security-core/zipball/1fbe80d10b7a5bcb619abe3e4cfede795d9958dc", + "reference": "1fbe80d10b7a5bcb619abe3e4cfede795d9958dc", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "ircmaxell/password-compat": "1.0.*", + "psr/log": "~1.0", + "symfony/event-dispatcher": "~2.1", + "symfony/expression-language": "~2.4", + "symfony/http-foundation": "~2.4", + "symfony/validator": "~2.2" + }, + "suggest": { + "ircmaxell/password-compat": "For using the BCrypt password encoder in PHP <5.5", + "symfony/event-dispatcher": "", + "symfony/expression-language": "For using the expression voter", + "symfony/http-foundation": "", + "symfony/validator": "For using the user password constraint" + }, + "time": "2014-04-23 14:04:21", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.4-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-0": { + "Symfony\\Component\\Security\\Core\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com", + "homepage": "http://fabien.potencier.org", + "role": "Lead Developer" + }, + { + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + } + ], + "description": "Symfony Security Component - Core Library", + "homepage": "http://symfony.com" + }, + { + "name": "psr/log", + "version": "1.0.0", + "version_normalized": "1.0.0.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/log.git", + "reference": "fe0936ee26643249e916849d48e3a51d5f5e278b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/log/zipball/fe0936ee26643249e916849d48e3a51d5f5e278b", + "reference": "fe0936ee26643249e916849d48e3a51d5f5e278b", + "shasum": "" + }, + "time": "2012-12-21 11:40:51", + "type": "library", + "installation-source": "dist", + "autoload": { + "psr-0": { + "Psr\\Log\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common interface for logging libraries", + "keywords": [ + "log", + "psr", + "psr-3" + ] + }, + { + "name": "symfony/http-foundation", + "version": "v2.4.6", + "version_normalized": "2.4.6.0", + "target-dir": "Symfony/Component/HttpFoundation", + "source": { + "type": "git", + "url": "https://github.com/symfony/HttpFoundation.git", + "reference": "138498f3d64981cfafcb5eec3b2b96fce44a178e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/HttpFoundation/zipball/138498f3d64981cfafcb5eec3b2b96fce44a178e", + "reference": "138498f3d64981cfafcb5eec3b2b96fce44a178e", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "symfony/expression-language": "~2.4" + }, + "time": "2014-05-22 16:21:00", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.4-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-0": { + "Symfony\\Component\\HttpFoundation\\": "" + }, + "classmap": [ + "Symfony/Component/HttpFoundation/Resources/stubs" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com", + "homepage": "http://fabien.potencier.org", + "role": "Lead Developer" + }, + { + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + } + ], + "description": "Symfony HttpFoundation Component", + "homepage": "http://symfony.com" + }, + { + "name": "symfony/event-dispatcher", + "version": "v2.5.0", + "version_normalized": "2.5.0.0", + "target-dir": "Symfony/Component/EventDispatcher", + "source": { + "type": "git", + "url": "https://github.com/symfony/EventDispatcher.git", + "reference": "cb62ec8dd05893fc8e4f0e6e21e326e1fc731fe8" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/EventDispatcher/zipball/cb62ec8dd05893fc8e4f0e6e21e326e1fc731fe8", + "reference": "cb62ec8dd05893fc8e4f0e6e21e326e1fc731fe8", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "psr/log": "~1.0", + "symfony/config": "~2.0", + "symfony/dependency-injection": "~2.0", + "symfony/stopwatch": "~2.2" + }, + "suggest": { + "symfony/dependency-injection": "", + "symfony/http-kernel": "" + }, + "time": "2014-04-29 10:13:57", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.5-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-0": { + "Symfony\\Component\\EventDispatcher\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com", + "homepage": "http://fabien.potencier.org", + "role": "Lead Developer" + }, + { + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + } + ], + "description": "Symfony EventDispatcher Component", + "homepage": "http://symfony.com" + }, + { + "name": "symfony/debug", + "version": "v2.4.6", + "version_normalized": "2.4.6.0", + "target-dir": "Symfony/Component/Debug", + "source": { + "type": "git", + "url": "https://github.com/symfony/Debug.git", + "reference": "6e721ae2cd7bde0f8dfa9c3186808a6c4140469c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/Debug/zipball/6e721ae2cd7bde0f8dfa9c3186808a6c4140469c", + "reference": "6e721ae2cd7bde0f8dfa9c3186808a6c4140469c", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "symfony/http-foundation": "~2.1", + "symfony/http-kernel": "~2.1" + }, + "suggest": { + "symfony/http-foundation": "", + "symfony/http-kernel": "" + }, + "time": "2014-04-30 06:22:28", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.4-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-0": { + "Symfony\\Component\\Debug\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com", + "homepage": "http://fabien.potencier.org", + "role": "Lead Developer" + }, + { + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + } + ], + "description": "Symfony Debug Component", + "homepage": "http://symfony.com" + }, + { + "name": "symfony/http-kernel", + "version": "v2.4.6", + "version_normalized": "2.4.6.0", + "target-dir": "Symfony/Component/HttpKernel", + "source": { + "type": "git", + "url": "https://github.com/symfony/HttpKernel.git", + "reference": "084a126a36ed011b098158d4d28daa9883ecc8f7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/HttpKernel/zipball/084a126a36ed011b098158d4d28daa9883ecc8f7", + "reference": "084a126a36ed011b098158d4d28daa9883ecc8f7", + "shasum": "" + }, + "require": { + "php": ">=5.3.3", + "psr/log": "~1.0", + "symfony/debug": "~2.3", + "symfony/event-dispatcher": "~2.1", + "symfony/http-foundation": "~2.4" + }, + "require-dev": { + "symfony/browser-kit": "~2.2", + "symfony/class-loader": "~2.1", + "symfony/config": "~2.0", + "symfony/console": "~2.2", + "symfony/dependency-injection": "~2.0", + "symfony/finder": "~2.0", + "symfony/process": "~2.0", + "symfony/routing": "~2.2", + "symfony/stopwatch": "~2.2", + "symfony/templating": "~2.2" + }, + "suggest": { + "symfony/browser-kit": "", + "symfony/class-loader": "", + "symfony/config": "", + "symfony/console": "", + "symfony/dependency-injection": "", + "symfony/finder": "" + }, + "time": "2014-05-31 18:42:13", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.4-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-0": { + "Symfony\\Component\\HttpKernel\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com", + "homepage": "http://fabien.potencier.org", + "role": "Lead Developer" + }, + { + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + } + ], + "description": "Symfony HttpKernel Component", + "homepage": "http://symfony.com" + }, + { + "name": "symfony/routing", + "version": "v2.4.6", + "version_normalized": "2.4.6.0", + "target-dir": "Symfony/Component/Routing", + "source": { + "type": "git", + "url": "https://github.com/symfony/Routing.git", + "reference": "74229f66e16bce6d2415ca44d4756f8e7ea880f8" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/Routing/zipball/74229f66e16bce6d2415ca44d4756f8e7ea880f8", + "reference": "74229f66e16bce6d2415ca44d4756f8e7ea880f8", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "doctrine/annotations": "~1.0", + "psr/log": "~1.0", + "symfony/config": "~2.2", + "symfony/expression-language": "~2.4", + "symfony/yaml": "~2.0" + }, + "suggest": { + "doctrine/annotations": "For using the annotation loader", + "symfony/config": "For using the all-in-one router or any loader", + "symfony/expression-language": "For using expression matching", + "symfony/yaml": "For using the YAML loader" + }, + "time": "2014-04-23 14:04:21", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.4-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-0": { + "Symfony\\Component\\Routing\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com", + "homepage": "http://fabien.potencier.org", + "role": "Lead Developer" + }, + { + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + } + ], + "description": "Symfony Routing Component", + "homepage": "http://symfony.com", + "keywords": [ + "router", + "routing", + "uri", + "url" + ] + }, + { + "name": "symfony/process", + "version": "v2.4.6", + "version_normalized": "2.4.6.0", + "target-dir": "Symfony/Component/Process", + "source": { + "type": "git", + "url": "https://github.com/symfony/Process.git", + "reference": "a7118cb290c62068b3c8ecfbf8b2eda8421fb841" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/Process/zipball/a7118cb290c62068b3c8ecfbf8b2eda8421fb841", + "reference": "a7118cb290c62068b3c8ecfbf8b2eda8421fb841", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "time": "2014-05-22 13:46:01", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.4-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-0": { + "Symfony\\Component\\Process\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com", + "homepage": "http://fabien.potencier.org", + "role": "Lead Developer" + }, + { + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + } + ], + "description": "Symfony Process Component", + "homepage": "http://symfony.com" + }, + { + "name": "symfony/finder", + "version": "v2.4.6", + "version_normalized": "2.4.6.0", + "target-dir": "Symfony/Component/Finder", + "source": { + "type": "git", + "url": "https://github.com/symfony/Finder.git", + "reference": "46295af1b1e24304b35d5f20f1bf1ec0c2c4934a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/Finder/zipball/46295af1b1e24304b35d5f20f1bf1ec0c2c4934a", + "reference": "46295af1b1e24304b35d5f20f1bf1ec0c2c4934a", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "time": "2014-05-22 13:46:01", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.4-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-0": { + "Symfony\\Component\\Finder\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com", + "homepage": "http://fabien.potencier.org", + "role": "Lead Developer" + }, + { + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + } + ], + "description": "Symfony Finder Component", + "homepage": "http://symfony.com" + }, + { + "name": "symfony/dom-crawler", + "version": "v2.4.6", + "version_normalized": "2.4.6.0", + "target-dir": "Symfony/Component/DomCrawler", + "source": { + "type": "git", + "url": "https://github.com/symfony/DomCrawler.git", + "reference": "77881ef11c064a490515a9fb1729b695c632ffe5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/DomCrawler/zipball/77881ef11c064a490515a9fb1729b695c632ffe5", + "reference": "77881ef11c064a490515a9fb1729b695c632ffe5", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "symfony/css-selector": "~2.0" + }, + "suggest": { + "symfony/css-selector": "" + }, + "time": "2014-05-31 02:02:48", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.4-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-0": { + "Symfony\\Component\\DomCrawler\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com", + "homepage": "http://fabien.potencier.org", + "role": "Lead Developer" + }, + { + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + } + ], + "description": "Symfony DomCrawler Component", + "homepage": "http://symfony.com" + }, + { + "name": "symfony/css-selector", + "version": "v2.4.6", + "version_normalized": "2.4.6.0", + "target-dir": "Symfony/Component/CssSelector", + "source": { + "type": "git", + "url": "https://github.com/symfony/CssSelector.git", + "reference": "268d0a51166edaf84dfcf043c57f273685cb7c93" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/CssSelector/zipball/268d0a51166edaf84dfcf043c57f273685cb7c93", + "reference": "268d0a51166edaf84dfcf043c57f273685cb7c93", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "time": "2014-05-12 09:27:48", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.4-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-0": { + "Symfony\\Component\\CssSelector\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com", + "homepage": "http://fabien.potencier.org", + "role": "Lead Developer" + }, + { + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + }, + { + "name": "Jean-François Simon", + "email": "jeanfrancois.simon@sensiolabs.com" + } + ], + "description": "Symfony CssSelector Component", + "homepage": "http://symfony.com" + }, + { + "name": "symfony/console", + "version": "v2.4.6", + "version_normalized": "2.4.6.0", + "target-dir": "Symfony/Component/Console", + "source": { + "type": "git", + "url": "https://github.com/symfony/Console.git", + "reference": "24f723436e62598c9dddee2a8573d6992504dc5d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/Console/zipball/24f723436e62598c9dddee2a8573d6992504dc5d", + "reference": "24f723436e62598c9dddee2a8573d6992504dc5d", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "symfony/event-dispatcher": "~2.1" + }, + "suggest": { + "symfony/event-dispatcher": "" + }, + "time": "2014-05-14 21:48:29", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.4-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-0": { + "Symfony\\Component\\Console\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com", + "homepage": "http://fabien.potencier.org", + "role": "Lead Developer" + }, + { + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + } + ], + "description": "Symfony Console Component", + "homepage": "http://symfony.com" + }, + { + "name": "symfony/browser-kit", + "version": "v2.4.6", + "version_normalized": "2.4.6.0", + "target-dir": "Symfony/Component/BrowserKit", + "source": { + "type": "git", + "url": "https://github.com/symfony/BrowserKit.git", + "reference": "5c80003d5772de6120b5429f4b2f6e22957d4a07" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/BrowserKit/zipball/5c80003d5772de6120b5429f4b2f6e22957d4a07", + "reference": "5c80003d5772de6120b5429f4b2f6e22957d4a07", + "shasum": "" + }, + "require": { + "php": ">=5.3.3", + "symfony/dom-crawler": "~2.0" + }, + "require-dev": { + "symfony/css-selector": "~2.0", + "symfony/process": "~2.0" + }, + "suggest": { + "symfony/process": "" + }, + "time": "2014-05-12 09:27:48", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.4-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-0": { + "Symfony\\Component\\BrowserKit\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com", + "homepage": "http://fabien.potencier.org", + "role": "Lead Developer" + }, + { + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + } + ], + "description": "Symfony BrowserKit Component", + "homepage": "http://symfony.com" + }, + { + "name": "swiftmailer/swiftmailer", + "version": "v5.2.0", + "version_normalized": "5.2.0.0", + "source": { + "type": "git", + "url": "https://github.com/swiftmailer/swiftmailer.git", + "reference": "043e336b871f17a117f76ef8e190eddfc04c8d48" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/swiftmailer/swiftmailer/zipball/043e336b871f17a117f76ef8e190eddfc04c8d48", + "reference": "043e336b871f17a117f76ef8e190eddfc04c8d48", + "shasum": "" + }, + "require": { + "php": ">=5.2.4" + }, + "require-dev": { + "mockery/mockery": "~0.9.1" + }, + "time": "2014-05-08 08:11:19", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "5.2-dev" + } + }, + "installation-source": "dist", + "autoload": { + "files": [ + "lib/swift_required.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com", + "homepage": "http://fabien.potencier.org", + "role": "Lead Developer" + }, + { + "name": "Chris Corbyn" + } + ], + "description": "Swiftmailer, free feature-rich PHP mailer", + "homepage": "http://swiftmailer.org", + "keywords": [ + "mail", + "mailer" + ] + }, + { + "name": "stack/builder", + "version": "v1.0.2", + "version_normalized": "1.0.2.0", + "source": { + "type": "git", + "url": "https://github.com/stackphp/builder.git", + "reference": "b4af43e7b7f3f7fac919ff475b29f7c5dc7b23b7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/stackphp/builder/zipball/b4af43e7b7f3f7fac919ff475b29f7c5dc7b23b7", + "reference": "b4af43e7b7f3f7fac919ff475b29f7c5dc7b23b7", + "shasum": "" + }, + "require": { + "php": ">=5.3.0", + "symfony/http-foundation": "~2.1", + "symfony/http-kernel": "~2.1" + }, + "require-dev": { + "silex/silex": "~1.0" + }, + "time": "2014-01-28 19:42:24", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-0": { + "Stack": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Igor Wiedler", + "email": "igor@wiedler.ch", + "homepage": "http://wiedler.ch/igor/" + } + ], + "description": "Builder for stack middlewares based on HttpKernelInterface.", + "keywords": [ + "stack" + ] + }, + { + "name": "predis/predis", + "version": "v0.8.5", + "version_normalized": "0.8.5.0", + "source": { + "type": "git", + "url": "https://github.com/nrk/predis.git", + "reference": "5f2eea628eb465d866ad2771927d83769c8f956c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/nrk/predis/zipball/5f2eea628eb465d866ad2771927d83769c8f956c", + "reference": "5f2eea628eb465d866ad2771927d83769c8f956c", + "shasum": "" + }, + "require": { + "php": ">=5.3.2" + }, + "suggest": { + "ext-curl": "Allows access to Webdis when paired with phpiredis", + "ext-phpiredis": "Allows faster serialization and deserialization of the Redis protocol" + }, + "time": "2014-01-16 14:10:29", + "type": "library", + "installation-source": "dist", + "autoload": { + "psr-0": { + "Predis": "lib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Daniele Alessandri", + "email": "suppakilla@gmail.com", + "homepage": "http://clorophilla.net" + } + ], + "description": "Flexible and feature-complete PHP client library for Redis", + "homepage": "http://github.com/nrk/predis", + "keywords": [ + "nosql", + "predis", + "redis" + ] + }, + { + "name": "phpseclib/phpseclib", + "version": "0.3.6", + "version_normalized": "0.3.6.0", + "source": { + "type": "git", + "url": "https://github.com/phpseclib/phpseclib.git", + "reference": "0ea31d9b65d49a8661e93bec19f44e989bd34c69" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpseclib/phpseclib/zipball/0ea31d9b65d49a8661e93bec19f44e989bd34c69", + "reference": "0ea31d9b65d49a8661e93bec19f44e989bd34c69", + "shasum": "" + }, + "require": { + "php": ">=5.0.0" + }, + "require-dev": { + "squizlabs/php_codesniffer": "1.*" + }, + "suggest": { + "ext-gmp": "Install the GMP (GNU Multiple Precision) extension in order to speed up arbitrary precision integer arithmetic operations.", + "ext-mcrypt": "Install the Mcrypt extension in order to speed up a wide variety of cryptographic operations.", + "pear-pear/PHP_Compat": "Install PHP_Compat to get phpseclib working on PHP < 4.3.3." + }, + "time": "2014-02-28 16:05:05", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "0.3-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-0": { + "Crypt": "phpseclib/", + "File": "phpseclib/", + "Math": "phpseclib/", + "Net": "phpseclib/", + "System": "phpseclib/" + }, + "files": [ + "phpseclib/Crypt/Random.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "include-path": [ + "phpseclib/" + ], + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jim Wigginton", + "email": "terrafrost@php.net", + "role": "Lead Developer" + }, + { + "name": "Patrick Monnerat", + "email": "pm@datasphere.ch", + "role": "Developer" + }, + { + "name": "Andreas Fischer", + "email": "bantu@phpbb.com", + "role": "Developer" + }, + { + "name": "Hans-Jürgen Petrich", + "email": "petrich@tronic-media.com", + "role": "Developer" + } + ], + "description": "PHP Secure Communications Library - Pure-PHP implementations of RSA, AES, SSH2, SFTP, X.509 etc.", + "homepage": "http://phpseclib.sourceforge.net", + "keywords": [ + "BigInteger", + "aes", + "asn.1", + "asn1", + "blowfish", + "crypto", + "cryptography", + "encryption", + "rsa", + "security", + "sftp", + "signature", + "signing", + "ssh", + "twofish", + "x.509", + "x509" + ] + }, + { + "name": "patchwork/utf8", + "version": "v1.1.23", + "version_normalized": "1.1.23.0", + "source": { + "type": "git", + "url": "https://github.com/nicolas-grekas/Patchwork-UTF8.git", + "reference": "c1edbc82aed49ff2bdef0a0f659bf69e3f7b14cc" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/nicolas-grekas/Patchwork-UTF8/zipball/c1edbc82aed49ff2bdef0a0f659bf69e3f7b14cc", + "reference": "c1edbc82aed49ff2bdef0a0f659bf69e3f7b14cc", + "shasum": "" + }, + "require": { + "lib-pcre": ">=7.3", + "php": ">=5.3.0" + }, + "suggest": { + "ext-iconv": "Use iconv for best performance", + "ext-intl": "Use Intl for best performance", + "ext-mbstring": "Use Mbstring for best performance" + }, + "time": "2014-05-22 13:59:09", + "type": "library", + "installation-source": "dist", + "autoload": { + "psr-0": { + "Patchwork": "class/", + "Normalizer": "class/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "(Apache-2.0 or GPL-2.0)" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com", + "role": "Developer" + } + ], + "description": "Extensive, portable and performant handling of UTF-8 and grapheme clusters for PHP", + "homepage": "https://github.com/nicolas-grekas/Patchwork-UTF8", + "keywords": [ + "i18n", + "unicode", + "utf-8", + "utf8" + ] + }, + { + "name": "nesbot/carbon", + "version": "1.9.0", + "version_normalized": "1.9.0.0", + "source": { + "type": "git", + "url": "https://github.com/briannesbitt/Carbon.git", + "reference": "b94de7192b01d0e80794eae984dcc773220ab0dc" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/b94de7192b01d0e80794eae984dcc773220ab0dc", + "reference": "b94de7192b01d0e80794eae984dcc773220ab0dc", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "require-dev": { + "phpunit/phpunit": "3.7.*" + }, + "time": "2014-05-13 02:29:30", + "type": "library", + "installation-source": "dist", + "autoload": { + "psr-0": { + "Carbon": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Brian Nesbitt", + "email": "brian@nesbot.com", + "homepage": "http://nesbot.com" + } + ], + "description": "A simple API extension for DateTime.", + "homepage": "https://github.com/briannesbitt/Carbon", + "keywords": [ + "date", + "datetime", + "time" + ] + }, + { + "name": "monolog/monolog", + "version": "1.9.1", + "version_normalized": "1.9.1.0", + "source": { + "type": "git", + "url": "https://github.com/Seldaek/monolog.git", + "reference": "65026b610f8c19e61d7242f600530677b0466aac" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Seldaek/monolog/zipball/65026b610f8c19e61d7242f600530677b0466aac", + "reference": "65026b610f8c19e61d7242f600530677b0466aac", + "shasum": "" + }, + "require": { + "php": ">=5.3.0", + "psr/log": "~1.0" + }, + "require-dev": { + "aws/aws-sdk-php": "~2.4, >2.4.8", + "doctrine/couchdb": "~1.0@dev", + "graylog2/gelf-php": "~1.0", + "phpunit/phpunit": "~3.7.0", + "raven/raven": "~0.5", + "ruflin/elastica": "0.90.*" + }, + "suggest": { + "aws/aws-sdk-php": "Allow sending log messages to AWS services like DynamoDB", + "doctrine/couchdb": "Allow sending log messages to a CouchDB server", + "ext-amqp": "Allow sending log messages to an AMQP server (1.0+ required)", + "ext-mongo": "Allow sending log messages to a MongoDB server", + "graylog2/gelf-php": "Allow sending log messages to a GrayLog2 server", + "raven/raven": "Allow sending log messages to a Sentry server", + "rollbar/rollbar": "Allow sending log messages to Rollbar", + "ruflin/elastica": "Allow sending log messages to an Elastic Search server" + }, + "time": "2014-04-24 13:29:03", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.9.x-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-4": { + "Monolog\\": "src/Monolog" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jordi Boggiano", + "email": "j.boggiano@seld.be", + "homepage": "http://seld.be", + "role": "Developer" + } + ], + "description": "Sends your logs to files, sockets, inboxes, databases and various web services", + "homepage": "http://github.com/Seldaek/monolog", + "keywords": [ + "log", + "logging", + "psr-3" + ] + }, + { + "name": "nikic/php-parser", + "version": "v0.9.4", + "version_normalized": "0.9.4.0", + "source": { + "type": "git", + "url": "https://github.com/nikic/PHP-Parser.git", + "reference": "1e5e280ae88a27effa2ae4aa2bd088494ed8594f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/1e5e280ae88a27effa2ae4aa2bd088494ed8594f", + "reference": "1e5e280ae88a27effa2ae4aa2bd088494ed8594f", + "shasum": "" + }, + "require": { + "php": ">=5.2" + }, + "time": "2013-08-25 17:11:40", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "0.9-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-0": { + "PHPParser": "lib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Nikita Popov" + } + ], + "description": "A PHP parser written in PHP", + "keywords": [ + "parser", + "php" + ] + }, + { + "name": "jeremeamia/SuperClosure", + "version": "1.0.1", + "version_normalized": "1.0.1.0", + "source": { + "type": "git", + "url": "https://github.com/jeremeamia/super_closure.git", + "reference": "d05400085f7d4ae6f20ba30d36550836c0d061e8" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/jeremeamia/super_closure/zipball/d05400085f7d4ae6f20ba30d36550836c0d061e8", + "reference": "d05400085f7d4ae6f20ba30d36550836c0d061e8", + "shasum": "" + }, + "require": { + "nikic/php-parser": "~0.9", + "php": ">=5.3.3" + }, + "require-dev": { + "phpunit/phpunit": "~3.7" + }, + "time": "2013-10-09 04:20:00", + "type": "library", + "installation-source": "dist", + "autoload": { + "psr-0": { + "Jeremeamia\\SuperClosure": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jeremy Lindblom" + } + ], + "description": "Doing interesting things with closures like serialization.", + "homepage": "https://github.com/jeremeamia/super_closure", + "keywords": [ + "closure", + "function", + "parser", + "serializable", + "serialize", + "tokenizer" + ] + }, + { + "name": "filp/whoops", + "version": "1.0.10", + "version_normalized": "1.0.10.0", + "source": { + "type": "git", + "url": "https://github.com/filp/whoops.git", + "reference": "91e3fd4b0812017ffbeb24add55330664e1ea32a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/filp/whoops/zipball/91e3fd4b0812017ffbeb24add55330664e1ea32a", + "reference": "91e3fd4b0812017ffbeb24add55330664e1ea32a", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "require-dev": { + "mockery/mockery": "dev-master", + "silex/silex": "1.0.*@dev" + }, + "time": "2013-12-04 14:19:30", + "type": "library", + "installation-source": "dist", + "autoload": { + "psr-0": { + "Whoops": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Filipe Dobreira", + "homepage": "https://github.com/filp", + "role": "Developer" + } + ], + "description": "php error handling for cool kids", + "homepage": "https://github.com/filp/whoops", + "keywords": [ + "error", + "exception", + "handling", + "library", + "silex-provider", + "whoops", + "zf2" + ] + }, + { + "name": "ircmaxell/password-compat", + "version": "1.0.3", + "version_normalized": "1.0.3.0", + "source": { + "type": "git", + "url": "https://github.com/ircmaxell/password_compat.git", + "reference": "1fc1521b5e9794ea77e4eca30717be9635f1d4f4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/ircmaxell/password_compat/zipball/1fc1521b5e9794ea77e4eca30717be9635f1d4f4", + "reference": "1fc1521b5e9794ea77e4eca30717be9635f1d4f4", + "shasum": "" + }, + "time": "2013-04-30 19:58:08", + "type": "library", + "installation-source": "dist", + "autoload": { + "files": [ + "lib/password.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Anthony Ferrara", + "email": "ircmaxell@php.net", + "homepage": "http://blog.ircmaxell.com" + } + ], + "description": "A compatibility library for the proposed simplified password hashing algorithm: https://wiki.php.net/rfc/password_hash", + "homepage": "https://github.com/ircmaxell/password_compat", + "keywords": [ + "hashing", + "password" + ] + }, + { + "name": "d11wtq/boris", + "version": "v1.0.8", + "version_normalized": "1.0.8.0", + "source": { + "type": "git", + "url": "https://github.com/d11wtq/boris.git", + "reference": "125dd4e5752639af7678a22ea597115646d89c6e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/d11wtq/boris/zipball/125dd4e5752639af7678a22ea597115646d89c6e", + "reference": "125dd4e5752639af7678a22ea597115646d89c6e", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "suggest": { + "ext-pcntl": "*", + "ext-posix": "*", + "ext-readline": "*" + }, + "time": "2014-01-17 12:21:18", + "bin": [ + "bin/boris" + ], + "type": "library", + "installation-source": "dist", + "autoload": { + "psr-0": { + "Boris": "lib" + } + }, + "notification-url": "https://packagist.org/downloads/" + }, + { + "name": "symfony/filesystem", + "version": "v2.5.0", + "version_normalized": "2.5.0.0", + "target-dir": "Symfony/Component/Filesystem", + "source": { + "type": "git", + "url": "https://github.com/symfony/Filesystem.git", + "reference": "98e831eac836a0a5911626ce82684155f21d0e4d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/Filesystem/zipball/98e831eac836a0a5911626ce82684155f21d0e4d", + "reference": "98e831eac836a0a5911626ce82684155f21d0e4d", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "time": "2014-04-16 10:36:21", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.5-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-0": { + "Symfony\\Component\\Filesystem\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com", + "homepage": "http://fabien.potencier.org", + "role": "Lead Developer" + }, + { + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + } + ], + "description": "Symfony Filesystem Component", + "homepage": "http://symfony.com" + }, + { + "name": "classpreloader/classpreloader", + "version": "1.0.2", + "version_normalized": "1.0.2.0", + "source": { + "type": "git", + "url": "https://github.com/mtdowling/ClassPreloader.git", + "reference": "2c9f3bcbab329570c57339895bd11b5dd3b00877" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/mtdowling/ClassPreloader/zipball/2c9f3bcbab329570c57339895bd11b5dd3b00877", + "reference": "2c9f3bcbab329570c57339895bd11b5dd3b00877", + "shasum": "" + }, + "require": { + "nikic/php-parser": "~0.9", + "php": ">=5.3.3", + "symfony/console": "~2.1", + "symfony/filesystem": "~2.1", + "symfony/finder": "~2.1" + }, + "time": "2014-03-12 00:05:31", + "bin": [ + "classpreloader.php" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-0": { + "ClassPreloader": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Helps class loading performance by generating a single PHP file containing all of the autoloaded files for a specific use case", + "keywords": [ + "autoload", + "class", + "preload" + ] + }, + { + "name": "laravel/framework", + "version": "v4.1.30", + "version_normalized": "4.1.30.0", + "source": { + "type": "git", + "url": "https://github.com/laravel/framework.git", + "reference": "1bbb6f16aa03c1de6d89ccbf4ca81bf98e1330ab" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/laravel/framework/zipball/1bbb6f16aa03c1de6d89ccbf4ca81bf98e1330ab", + "reference": "1bbb6f16aa03c1de6d89ccbf4ca81bf98e1330ab", + "shasum": "" + }, + "require": { + "classpreloader/classpreloader": "1.0.*", + "d11wtq/boris": "1.0.*", + "filp/whoops": "1.0.10", + "ircmaxell/password-compat": "1.0.*", + "jeremeamia/superclosure": "1.0.*", + "monolog/monolog": "1.*", + "nesbot/carbon": "1.*", + "patchwork/utf8": "1.1.*", + "php": ">=5.3.0", + "phpseclib/phpseclib": "0.3.*", + "predis/predis": "0.8.*", + "stack/builder": "1.0.*", + "swiftmailer/swiftmailer": "~5.0", + "symfony/browser-kit": "2.4.*", + "symfony/console": "2.4.*", + "symfony/css-selector": "2.4.*", + "symfony/debug": "2.4.*", + "symfony/dom-crawler": "2.4.*", + "symfony/finder": "2.4.*", + "symfony/http-foundation": "2.4.*", + "symfony/http-kernel": "2.4.*", + "symfony/process": "2.4.*", + "symfony/routing": "2.4.*", + "symfony/security-core": "2.4.*", + "symfony/translation": "2.4.*" + }, + "replace": { + "illuminate/auth": "self.version", + "illuminate/cache": "self.version", + "illuminate/config": "self.version", + "illuminate/console": "self.version", + "illuminate/container": "self.version", + "illuminate/cookie": "self.version", + "illuminate/database": "self.version", + "illuminate/encryption": "self.version", + "illuminate/events": "self.version", + "illuminate/exception": "self.version", + "illuminate/filesystem": "self.version", + "illuminate/foundation": "self.version", + "illuminate/hashing": "self.version", + "illuminate/html": "self.version", + "illuminate/http": "self.version", + "illuminate/log": "self.version", + "illuminate/mail": "self.version", + "illuminate/pagination": "self.version", + "illuminate/queue": "self.version", + "illuminate/redis": "self.version", + "illuminate/remote": "self.version", + "illuminate/routing": "self.version", + "illuminate/session": "self.version", + "illuminate/support": "self.version", + "illuminate/translation": "self.version", + "illuminate/validation": "self.version", + "illuminate/view": "self.version", + "illuminate/workbench": "self.version" + }, + "require-dev": { + "aws/aws-sdk-php": "2.6.*", + "iron-io/iron_mq": "1.5.*", + "mockery/mockery": "0.9.*", + "pda/pheanstalk": "2.1.*", + "phpunit/phpunit": "4.0.*" + }, + "suggest": { + "doctrine/dbal": "Allow renaming columns and dropping SQLite columns." + }, + "time": "2014-06-01 18:30:26", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.1-dev" + } + }, + "installation-source": "dist", + "autoload": { + "classmap": [ + "src/Illuminate/Queue/IlluminateQueueClosure.php" + ], + "files": [ + "src/Illuminate/Support/helpers.php" + ], + "psr-0": { + "Illuminate": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Taylor Otwell", + "email": "taylorotwell@gmail.com", + "homepage": "https://github.com/taylorotwell", + "role": "Creator of Laravel" + } + ], + "description": "The Laravel Framework.", + "keywords": [ + "framework", + "laravel" + ] + } +] diff --git a/vendor/d11wtq/boris/.gitignore b/vendor/d11wtq/boris/.gitignore new file mode 100755 index 0000000..614c2d3 --- /dev/null +++ b/vendor/d11wtq/boris/.gitignore @@ -0,0 +1,3 @@ +/vendor/ +*.swp +boris.phar diff --git a/vendor/d11wtq/boris/LICENSE b/vendor/d11wtq/boris/LICENSE new file mode 100755 index 0000000..ebd8fdd --- /dev/null +++ b/vendor/d11wtq/boris/LICENSE @@ -0,0 +1,20 @@ +Copyright (c) 2011 Chris Corbyn + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/vendor/d11wtq/boris/README.md b/vendor/d11wtq/boris/README.md new file mode 100755 index 0000000..cd5d75a --- /dev/null +++ b/vendor/d11wtq/boris/README.md @@ -0,0 +1,306 @@ +# Boris: A tiny little, but robust REPL for PHP + +![Demo](http://dl.dropbox.com/u/508607/BorisDemo-v3.gif "Quick Demo") + +Python has one. Ruby has one. Clojure has one. Now PHP has one too. Boris is +PHP's missing REPL (read-eval-print loop), allowing developers to experiment +with PHP code in the terminal in an interactive manner. If you make a mistake, +it doesn't matter, Boris will report the error and stand to attention for +further input. + +Everything you enter into Boris is evaluated and the result inspected so you +can understand what is happening. State is maintained between inputs, allowing +you to gradually build up a solution to a problem. + +## Why? + +I'm in the process of transitioning away from PHP to Ruby. I have come to find +PHP's lack of a real REPL to be frustrating and was not able to find an existing +implementation that was complete. Boris weighs in at a few hundred lines of +fairly straightforward code. + +## Installation + +### 1. As a pre-built phar file + +Boris is available for download as a Phar archive: + + - https://github.com/d11wtq/boris/releases/download/v1.0.8/boris.phar + +Simply download it and run it. + + curl -O https://github.com/d11wtq/boris/releases/download/v1.0.8/boris.phar + chmod +x boris.phar + ./boris.phar + +### 2. Via packagist + +For use with composer. + + - https://packagist.org/packages/d11wtq/boris + +### 3. Directly from this repo + +This is great if you want to stay really up-to-date. I don't commit unstable +code to master, ever. + + git clone git://github.com/d11wtq/boris.git + cd boris + ./bin/boris + +### 4. Build your own phar + +You can also build a PHAR file using [Box](http://box-project.org/): + + box build + +This will create a `boris.phar` file. Feel free to move it into your bin +directory: + + chmod +x boris.phar + mv boris.phar /usr/local/bin/boris + +### Pro Tip + +Add boris to your $PATH for easy access. + +## Usage + +When Boris starts, you will be at the `boris>` prompt. PHP code you enter at +this prompt is evaluated. If an expression spans multiple lines, Boris will +collect the input and then evaluate the expression when it is complete. Press +CTRL-C to clear a multi-line input buffer if you make a mistake. The output +is dumped with `var_dump()` by default. + + boris> $x = 1; + int(1) + boris> $y = 2; + int(2) + boris> "x + y = " . ($x + $y); + string(9) "x + y = 3" + boris> exit; + +You can also use CTRL-D to exit the REPL. + +### Cancelling long-running operations + +Long-running operations, such as infinite loops, may be cancelled at any time +without quitting the REPL, by using CTRL-C while the operation is running. + + boris> for ($i = 0; ; ++$i) { + *> if ($i % 2 == 0) printf("Tick\n"); + *> else printf("Tock\n"); + *> sleep(1); + *> } + Tick + Tock + Tick + Tock + Tick + Tock + Tick + ^CCancelling... + boris> + +### Using Boris with your application loaded + +You can also use Boris as part of a larger project (e.g. with your application +environment loaded). + + require_once 'lib/autoload.php'; + + $boris = new \Boris\Boris('myapp> '); + $boris->start(); + +The constructor parameter is optional and changes the prompt. + +If you want to pass local variables straight into Boris (e.g. parts of your +application), you can do that too (thanks to [@dhotston](https://github.com/dhotston)): + + $boris = new \Boris\Boris('myapp> '); + $boris->setLocal(array('appContext' => $appContext)); + $boris->start(); + +In the above example, $appContext will be present inside the REPL. + +### Using start hooks + +It is possible to add callbacks to Boris that are executed inside the REPL +before it begins looping. Any number of hooks can be added, and they will be +executed in order. Any variables set or exported by the hook will become +visible from inside the REPL and consequently, to subsequent hooks that are +run. + +There are two ways to specify hooks: as arbitrary strings of PHP code to +evaluate, or as callbacks given as closures. Both approaches allow you access +to the scope, though you need to do slightly more work with the callback +approach. + + // this will simply be evaluated in the REPL scope + // the variables $foo and $bar will be visible inside the REPL + $boris->onStart('$foo = 42; $bar = 2; echo "Hello Boris!\n";'); + + // this will be passed the REPL and it's scope as arguments + // any changes to the scope can be expressed by invoking the usual + // methods on the REPL + $boris->onStart(function($worker, $scope){ + extract($scope); // we could also just access specific vars by key + + echo '$foo * $bar = ' . ($foo * $bar) . "\n"; + + $worker->setLocal('name', 'Chris'); + }); + +Above we added two hooks. The first just gets passed to `eval()` and leaves +`$foo` and `$bar` in scope. The second uses the callback style and reads its +variables from the `$scope` parameter, then sets variables into the REPL +with `setLocal()`. + +### User configuration files + +If you have, things you always want to do when Boris starts, such as load +useful utility functions, change the prompt or set local variable, you +may create a ~/.borisrc file, which will be loaded whenever Boris starts up. + +The contents of this file are just arbitrary PHP code. You are *not* inside +the REPL itself in this file, but you have access to `$boris`, which is the +REPL object. Here's an example ~/.borisrc that sets the prompt. + + setPrompt('prompty> '); + +Boris will also look under your current working directory for this file. If +it finds one on both locations, they will both be loaded by default (not that +this is customizable at the code level). If you need to execute code in the +REPL itself, use hooks as documented above. + +Thanks to [@filp](https://github.com/filp) for this feature! + +### Customizing the output + +After each expression you enter, Boris passes it through an Inspector to get a +representation that is useful for debugging. The default is does some nice +highlighting of the data types in the value, to make it easier to read at a +glance, but you can change this behaviour. + +Any object that has an `inspect($variable)` method may be used for this purpose. + + $boris->setInspector(new BlinkInspector()); + +Boris comes with three alternatives out of the box: + + * \Boris\ColoredInspector, which does data-type highlighting and is the default + * \Boris\DumpInspector, which uses a simple, but effective var_dump() + * \Boris\ExportInspector, which uses var_export() + +Note that you can change this from inside the REPL too: + + boris> $this->setInspector(new \Boris\ExportInspector()); + -> NULL + boris> "Test"; + -> 'Test' + +To further customize object output within `\Boris\ColoredInspector`, you may +subclass and override the `objectVars($value)` method: + + class MyInspector extends \Boris\ColoredInspector { + public function objectVars($value) { + if ($value instanceof User) { + return array('user_id' => $value->getUserId()); + } + + return parent::objectVars($value); + } + } + +This overrides the default behavior of simply calling [`get_object_vars()`][get_object_vars] +on the object, allowing you to display properties that may be otherwise obfuscated +behind magic methods or property visibility. + + [get_object_vars]: http://php.net/get_object_vars + +## Boris doesn't display exceptions or errors when running in my app? + +Boris honours your environment. If your application has error handlers +installed, they will mask the error. Likewise, if an exception handler is +installed, you won't see a backtrace (unless your exception handler displays it). + +Since Boris is much more useful when you can see errors in the console, the best +thing to do is to disable any exception/error handlers when your application +is running inside of Boris. + +## What about PHP's interactive mode? + +PHP's interactive mode does not print the result of evaluating expressions and +more importantly, it exits if you type something that produces a fatal error, +such as invoking a function/method that does not exist, or an uncaught +exception. Boris is designed to be robust, like other REPLs, so you can +experiment with things that you know may error, without losing everything. + +## Architecture Overview + +This section of the README only applies to those curious enough to read the +code. Boris is quite different to other PHP REPLs, because it deals with fatal +errors (not Exceptions, fatal errors) in a special way. + +Boris will only work on POSIX systems (Linux and Mac OS). This is primarily +because it depends on the ability to fork, but also because it plays with signals +a lot too. + +Boris is made up of two parts: + + 1. A REPL worker process, which receives expressions to evaluate and print + 2. A readline client, which simply takes your input, sends it to the worker + and then loops + +If all errors in PHP were exceptions, building a REPL would be simple. This is +not the case, however. Some PHP errors are truly fatal and cannot be caught. +In order to prevent such fatal errors from killing the REPL, the worker looks +something like this: + + for(;;) { + $input = accept_some_input(); + if (fork_child()) { + wait_for_child(); + } else { // inside child + var_dump(eval($input)); + kill_parent(); + } + } + +The child is forked with all current variables and resources. It evaluates the +input then kills the parent, then the loop continues inside the child, waiting +for the next input. + +While the child is evaluating the input, the parent waits. The parent is +expecting the worst—that the child will die abnormally—at which point the parent +continues waiting for input and does not terminate. The state remains unchanged. + +After each expression is evaluated, the worker reports back to the main process +with a status code of 0 (keep running) or 1 (terminate). + +The main process (readline) of Boris is much more straightforward. It takes +your input, performs a (very) shallow parse on it, in order to decide if it +needs to wait for further input, or evaluate the input (one statement at a time) +it has received. If the worker reports back with a status code of 1, the process +terminates, otherwise the next iteration of the loop is entered. + +## Will it work with...? + +Boris depends on the following PHP features: + + - PHP >= 5.3 + - The Readline functions + - The PCNTL functions + - The POSIX functions + +There's no chance it can work on Windows, due to the dependency on POSIX +features (the code is almost entirely dependant on POSIX). + +## Copyright & Licensing + +Boris is written and maintained by Chris Corbyn (@d11wtq). You can use the +code as you see fit. See the LICENSE file for details. diff --git a/vendor/d11wtq/boris/bin/boris b/vendor/d11wtq/boris/bin/boris new file mode 100755 index 0000000..7f435b2 --- /dev/null +++ b/vendor/d11wtq/boris/bin/boris @@ -0,0 +1,16 @@ +#!/usr/bin/env php +apply($boris); + +$options = new \Boris\CLIOptionsHandler(); +$options->handle($boris); + +$boris->start(); diff --git a/vendor/d11wtq/boris/box.json b/vendor/d11wtq/boris/box.json new file mode 100755 index 0000000..e197cab --- /dev/null +++ b/vendor/d11wtq/boris/box.json @@ -0,0 +1,16 @@ +{ + "files": ["LICENSE"], + "finder": [ + { + "name": "*.php", + "exclude": [ + "tests" + ], + "in": "lib" + } + ], + "git-version": "git_tag", + "main": "bin/boris", + "output": "boris.phar", + "stub": true +} diff --git a/vendor/d11wtq/boris/composer.json b/vendor/d11wtq/boris/composer.json new file mode 100755 index 0000000..4ffa30d --- /dev/null +++ b/vendor/d11wtq/boris/composer.json @@ -0,0 +1,15 @@ +{ + "name": "d11wtq/boris", + "require": { + "php": ">=5.3.0" + }, + "suggest": { + "ext-readline": "*", + "ext-pcntl": "*", + "ext-posix": "*" + }, + "autoload": { + "psr-0": {"Boris": "lib"} + }, + "bin": ["bin/boris"] +} diff --git a/vendor/d11wtq/boris/lib/Boris/Boris.php b/vendor/d11wtq/boris/lib/Boris/Boris.php new file mode 100755 index 0000000..e2319cd --- /dev/null +++ b/vendor/d11wtq/boris/lib/Boris/Boris.php @@ -0,0 +1,174 @@ + ', $historyFile = null) { + $this->setPrompt($prompt); + $this->_historyFile = $historyFile + ? $historyFile + : sprintf('%s/.boris_history', getenv('HOME')) + ; + $this->_inspector = new ColoredInspector(); + } + + /** + * Add a new hook to run in the context of the REPL when it starts. + * + * @param mixed $hook + * + * The hook is either a string of PHP code to eval(), or a Closure accepting + * the EvalWorker object as its first argument and the array of defined + * local variables in the second argument. + * + * If the hook is a callback and needs to set any local variables in the + * REPL's scope, it should invoke $worker->setLocal($var_name, $value) to + * do so. + * + * Hooks are guaranteed to run in the order they were added and the state + * set by each hook is available to the next hook (either through global + * resources, such as classes and interfaces, or through the 2nd parameter + * of the callback, if any local variables were set. + * + * @example Contrived example where one hook sets the date and another + * prints it in the REPL. + * + * $boris->onStart(function($worker, $vars){ + * $worker->setLocal('date', date('Y-m-d')); + * }); + * + * $boris->onStart('echo "The date is $date\n";'); + */ + public function onStart($hook) { + $this->_startHooks[] = $hook; + } + + /** + * Add a new hook to run in the context of the REPL when a fatal error occurs. + * + * @param mixed $hook + * + * The hook is either a string of PHP code to eval(), or a Closure accepting + * the EvalWorker object as its first argument and the array of defined + * local variables in the second argument. + * + * If the hook is a callback and needs to set any local variables in the + * REPL's scope, it should invoke $worker->setLocal($var_name, $value) to + * do so. + * + * Hooks are guaranteed to run in the order they were added and the state + * set by each hook is available to the next hook (either through global + * resources, such as classes and interfaces, or through the 2nd parameter + * of the callback, if any local variables were set. + * + * @example An example if your project requires some database connection cleanup: + * + * $boris->onFailure(function($worker, $vars){ + * DB::reset(); + * }); + */ + public function onFailure($hook){ + $this->_failureHooks[] = $hook; + } + + /** + * Set a local variable, or many local variables. + * + * @example Setting a single variable + * $boris->setLocal('user', $bob); + * + * @example Setting many variables at once + * $boris->setLocal(array('user' => $bob, 'appContext' => $appContext)); + * + * This method can safely be invoked repeatedly. + * + * @param array|string $local + * @param mixed $value, optional + */ + public function setLocal($local, $value = null) { + if (!is_array($local)) { + $local = array($local => $value); + } + + $this->_exports = array_merge($this->_exports, $local); + } + + /** + * Sets the Boris prompt text + * + * @param string $prompt + */ + public function setPrompt($prompt) { + $this->_prompt = $prompt; + } + + /** + * Set an Inspector object for Boris to output return values with. + * + * @param object $inspector any object the responds to inspect($v) + */ + public function setInspector($inspector) { + $this->_inspector = $inspector; + } + + /** + * Start the REPL (display the readline prompt). + * + * This method never returns. + */ + public function start() { + declare(ticks = 1); + pcntl_signal(SIGINT, SIG_IGN, true); + + if (!$pipes = stream_socket_pair( + STREAM_PF_UNIX, STREAM_SOCK_STREAM, STREAM_IPPROTO_IP)) { + throw new \RuntimeException('Failed to create socket pair'); + } + + $pid = pcntl_fork(); + + if ($pid > 0) { + if (function_exists('setproctitle')) { + setproctitle('boris (master)'); + } + + fclose($pipes[0]); + $client = new ReadlineClient($pipes[1]); + $client->start($this->_prompt, $this->_historyFile); + } elseif ($pid < 0) { + throw new \RuntimeException('Failed to fork child process'); + } else { + if (function_exists('setproctitle')) { + setproctitle('boris (worker)'); + } + + fclose($pipes[1]); + $worker = new EvalWorker($pipes[0]); + $worker->setLocal($this->_exports); + $worker->setStartHooks($this->_startHooks); + $worker->setFailureHooks($this->_failureHooks); + $worker->setInspector($this->_inspector); + $worker->start(); + } + } +} diff --git a/vendor/d11wtq/boris/lib/Boris/CLIOptionsHandler.php b/vendor/d11wtq/boris/lib/Boris/CLIOptionsHandler.php new file mode 100755 index 0000000..2aa3ab3 --- /dev/null +++ b/vendor/d11wtq/boris/lib/Boris/CLIOptionsHandler.php @@ -0,0 +1,85 @@ + $value) { + switch ($option) { + /* + * Sets files to load at startup, may be used multiple times, + * i.e: boris -r test.php,foo/bar.php -r ba/foo.php --require hey.php + */ + case 'r': + case 'require': + $this->_handleRequire($boris, $value); + break; + + /* + * Show Usage info + */ + case 'h': + case 'help': + $this->_handleUsageInfo(); + break; + + /* + * Show version + */ + case 'v': + case 'version': + $this->_handleVersion(); + break; + } + } + } + + // -- Private Methods + + private function _handleRequire($boris, $paths) { + $require = array_reduce( + (array) $paths, + function($acc, $v) { return array_merge($acc, explode(',', $v)); }, + array() + ); + + $boris->onStart(function($worker, $scope) use($require) { + foreach($require as $path) { + require $path; + } + + $worker->setLocal(get_defined_vars()); + }); + } + + private function _handleUsageInfo() { + echo << + * @author Chris Corbyn + * + * Copyright © 2013 Rob Morris. + */ + +namespace Boris; + +/** + * Identifies data types in data structures and syntax highlights them. + */ +class ColoredInspector implements Inspector { + static $TERM_COLORS = array( + 'black' => "\033[0;30m", + 'white' => "\033[1;37m", + 'none' => "\033[1;30m", + 'dark_grey' => "\033[1;30m", + 'light_grey' => "\033[0;37m", + 'dark_red' => "\033[0;31m", + 'light_red' => "\033[1;31m", + 'dark_green' => "\033[0;32m", + 'light_green' => "\033[1;32m", + 'dark_yellow' => "\033[0;33m", + 'light_yellow' => "\033[1;33m", + 'dark_blue' => "\033[0;34m", + 'light_blue' => "\033[1;34m", + 'dark_purple' => "\033[0;35m", + 'light_purple' => "\033[1;35m", + 'dark_cyan' => "\033[0;36m", + 'light_cyan' => "\033[1;36m", + ); + + private $_fallback; + private $_colorMap = array(); + + /** + * Initialize a new ColoredInspector, using $colorMap. + * + * The colors should be an associative array with the keys: + * + * - 'integer' + * - 'float' + * - 'keyword' + * - 'string' + * - 'boolean' + * - 'default' + * + * And the values, one of the following colors: + * + * - 'none' + * - 'black' + * - 'white' + * - 'dark_grey' + * - 'light_grey' + * - 'dark_red' + * - 'light_red' + * - 'dark_green' + * - 'light_green' + * - 'dark_yellow' + * - 'light_yellow' + * - 'dark_blue' + * - 'light_blue' + * - 'dark_purple' + * - 'light_purple' + * - 'dark_cyan' + * - 'light_cyan' + * + * An empty $colorMap array effectively means 'none' for all types. + * + * @param array $colorMap + */ + public function __construct($colorMap = null) { + $this->_fallback = new DumpInspector(); + + if (isset($colorMap)) { + $this->_colorMap = $colorMap; + } else { + $this->_colorMap = $this->_defaultColorMap(); + } + } + + public function inspect($variable) { + return preg_replace( + '/^/m', + $this->_colorize('comment', '// '), + $this->_dump($variable) + ); + } + + /** + * Returns an associative array of an object's properties. + * + * This method is public so that subclasses may override it. + * + * @param object $value + * @return array + * */ + public function objectVars($value) { + return get_object_vars($value); + } + + // -- Private Methods + + public function _dump($value) { + $tests = array( + 'is_null' => '_dumpNull', + 'is_string' => '_dumpString', + 'is_bool' => '_dumpBoolean', + 'is_integer' => '_dumpInteger', + 'is_float' => '_dumpFloat', + 'is_array' => '_dumpArray', + 'is_object' => '_dumpObject' + ); + + foreach ($tests as $predicate => $outputMethod) { + if (call_user_func($predicate, $value)) + return call_user_func(array($this, $outputMethod), $value); + } + + return $this->_fallback->inspect($value); + } + + private function _dumpNull($value) { + return $this->_colorize('keyword', 'NULL'); + } + + private function _dumpString($value) { + return $this->_colorize('string', var_export($value, true)); + } + + private function _dumpBoolean($value) { + return $this->_colorize('bool', var_export($value, true)); + } + + private function _dumpInteger($value) { + return $this->_colorize('integer', var_export($value, true)); + } + + private function _dumpFloat($value) { + return $this->_colorize('float', var_export($value, true)); + } + + private function _dumpArray($value) { + return $this->_dumpStructure('array', $value); + } + + private function _dumpObject($value) { + return $this->_dumpStructure( + sprintf('object(%s)', get_class($value)), + $this->objectVars($value) + ); + } + + private function _dumpStructure($type, $value) { + return $this->_astToString($this->_buildAst($type, $value)); + } + + public function _buildAst($type, $value, $seen = array()) { + // FIXME: Improve this AST so it doesn't require access to dump() or colorize() + if ($this->_isSeen($value, $seen)) { + return $this->_colorize('default', '*** RECURSION ***'); + } else { + $nextSeen = array_merge($seen, array($value)); + } + + if (is_object($value)) { + $vars = $this->objectVars($value); + } else { + $vars = $value; + } + + $self = $this; + + return array( + 'name' => $this->_colorize('keyword', $type), + 'children' => empty($vars) ? array() : array_combine( + array_map(array($this, '_dump'), array_keys($vars)), + array_map( + function($v) use($self, $nextSeen) { + if (is_object($v)) { + return $self->_buildAst( + sprintf('object(%s)', get_class($v)), + $v, + $nextSeen + ); + } elseif (is_array($v)) { + return $self->_buildAst('array', $v, $nextSeen); + } else { + return $self->_dump($v); + } + }, + array_values($vars) + ) + ) + ); + } + + public function _astToString($node, $indent = 0) { + $children = $node['children']; + $self = $this; + + return implode( + "\n", + array( + sprintf('%s(', $node['name']), + implode( + ",\n", + array_map( + function($k) use($self, $children, $indent) { + if (is_array($children[$k])) { + return sprintf( + '%s%s => %s', + str_repeat(' ', ($indent + 1) * 2), + $k, + $self->_astToString($children[$k], $indent + 1) + ); + } else { + return sprintf( + '%s%s => %s', + str_repeat(' ', ($indent + 1) * 2), + $k, + $children[$k] + ); + } + }, + array_keys($children) + ) + ), + sprintf('%s)', str_repeat(' ', $indent * 2)) + ) + ); + } + + private function _defaultColorMap() { + return array( + 'integer' => 'light_green', + 'float' => 'light_yellow', + 'string' => 'light_red', + 'bool' => 'light_purple', + 'keyword' => 'light_cyan', + 'comment' => 'dark_grey', + 'default' => 'none' + ); + } + + private function _colorize($type, $value) { + if (!empty($this->_colorMap[$type])) { + $colorName = $this->_colorMap[$type]; + } else { + $colorName = $this->_colorMap['default']; + } + + return sprintf( + "%s%s\033[0m", + static::$TERM_COLORS[$colorName], + $value + ); + } + + private function _isSeen($value, $seen) { + foreach ($seen as $v) { + if ($v === $value) + return true; + } + + return false; + } +} diff --git a/vendor/d11wtq/boris/lib/Boris/Config.php b/vendor/d11wtq/boris/lib/Boris/Config.php new file mode 100755 index 0000000..f03d3b7 --- /dev/null +++ b/vendor/d11wtq/boris/lib/Boris/Config.php @@ -0,0 +1,85 @@ +_cascade = $cascade; + $this->_searchPaths = $searchPaths; + } + + /** + * Searches for configuration files in the available + * search paths, and applies them to the provided + * boris instance. + * + * Returns true if any configuration files were found. + * + * @param Boris\Boris $boris + * @return bool + */ + public function apply(Boris $boris) { + $applied = false; + + foreach($this->_searchPaths as $path) { + if (is_readable($path)) { + $this->_loadInIsolation($path, $boris); + + $applied = true; + $this->_files[] = $path; + + if (!$this->_cascade) { + break; + } + } + } + + return $applied; + } + + /** + * Returns an array of files that were loaded + * for this Config + * + * @return array + */ + public function loadedFiles() { + return $this->_files; + } + + // -- Private Methods + + private function _loadInIsolation($path, $boris) { + require $path; + } +} diff --git a/vendor/d11wtq/boris/lib/Boris/DumpInspector.php b/vendor/d11wtq/boris/lib/Boris/DumpInspector.php new file mode 100755 index 0000000..96ab38a --- /dev/null +++ b/vendor/d11wtq/boris/lib/Boris/DumpInspector.php @@ -0,0 +1,16 @@ +_socket = $socket; + $this->_inspector = new DumpInspector(); + stream_set_blocking($socket, 0); + } + + /** + * Set local variables to be placed in the workers's scope. + * + * @param array|string $local + * @param mixed $value, if $local is a string + */ + public function setLocal($local, $value = null) { + if (!is_array($local)) { + $local = array($local => $value); + } + + $this->_exports = array_merge($this->_exports, $local); + } + + /** + * Set hooks to run inside the worker before it starts looping. + * + * @param array $hooks + */ + public function setStartHooks($hooks) { + $this->_startHooks = $hooks; + } + + /** + * Set hooks to run inside the worker after a fatal error is caught. + * + * @param array $hooks + */ + public function setFailureHooks($hooks) { + $this->_failureHooks = $hooks; + } + + /** + * Set an Inspector object for Boris to output return values with. + * + * @param object $inspector any object the responds to inspect($v) + */ + public function setInspector($inspector) { + $this->_inspector = $inspector; + } + + /** + * Start the worker. + * + * This method never returns. + */ + public function start() { + $__scope = $this->_runHooks($this->_startHooks); + extract($__scope); + + $this->_write($this->_socket, self::READY); + + /* Note the naming of the local variables due to shared scope with the user here */ + for (;;) { + declare(ticks = 1); + // don't exit on ctrl-c + pcntl_signal(SIGINT, SIG_IGN, true); + + $this->_cancelled = false; + + $__input = $this->_transform($this->_read($this->_socket)); + + if ($__input === null) { + continue; + } + + $__response = self::DONE; + + $this->_ppid = posix_getpid(); + $this->_pid = pcntl_fork(); + + if ($this->_pid < 0) { + throw new \RuntimeException('Failed to fork child labourer'); + } elseif ($this->_pid > 0) { + // kill the child on ctrl-c + pcntl_signal(SIGINT, array($this, 'cancelOperation'), true); + pcntl_waitpid($this->_pid, $__status); + + if (!$this->_cancelled && $__status != (self::ABNORMAL_EXIT << 8)) { + $__response = self::EXITED; + } else { + $this->_runHooks($this->_failureHooks); + $__response = self::FAILED; + } + } else { + // user exception handlers normally cause a clean exit, so Boris will exit too + if (!$this->_exceptionHandler = + set_exception_handler(array($this, 'delegateExceptionHandler'))) { + restore_exception_handler(); + } + + // undo ctrl-c signal handling ready for user code execution + pcntl_signal(SIGINT, SIG_DFL, true); + $__pid = posix_getpid(); + + $__result = eval($__input); + + if (posix_getpid() != $__pid) { + // whatever the user entered caused a forked child + // (totally valid, but we don't want that child to loop and wait for input) + exit(0); + } + + if (preg_match('/\s*return\b/i', $__input)) { + fwrite(STDOUT, sprintf("%s\n", $this->_inspector->inspect($__result))); + } + $this->_expungeOldWorker(); + } + + $this->_write($this->_socket, $__response); + + if ($__response == self::EXITED) { + exit(0); + } + } + } + + /** + * While a child process is running, terminate it immediately. + */ + public function cancelOperation() { + printf("Cancelling...\n"); + $this->_cancelled = true; + posix_kill($this->_pid, SIGKILL); + pcntl_signal_dispatch(); + } + + /** + * If any user-defined exception handler is present, call it, but be sure to exit correctly. + */ + public function delegateExceptionHandler($ex) { + call_user_func($this->_exceptionHandler, $ex); + exit(self::ABNORMAL_EXIT); + } + + // -- Private Methods + + private function _runHooks($hooks) { + extract($this->_exports); + + foreach ($hooks as $__hook) { + if (is_string($__hook)) { + eval($__hook); + } elseif (is_callable($__hook)) { + call_user_func($__hook, $this, get_defined_vars()); + } else { + throw new \RuntimeException( + sprintf( + 'Hooks must be closures or strings of PHP code. Got [%s].', + gettype($__hook) + ) + ); + } + + // hooks may set locals + extract($this->_exports); + } + + return get_defined_vars(); + } + + private function _expungeOldWorker() { + posix_kill($this->_ppid, SIGTERM); + pcntl_signal_dispatch(); + } + + private function _write($socket, $data) { + if (!fwrite($socket, $data)) { + throw new \RuntimeException('Socket error: failed to write data'); + } + } + + private function _read($socket) + { + $read = array($socket); + $except = array($socket); + + if ($this->_select($read, $except) > 0) { + if ($read) { + return stream_get_contents($read[0]); + } else if ($except) { + throw new \UnexpectedValueException("Socket error: closed"); + } + } + } + + private function _select(&$read, &$except) { + $write = null; + set_error_handler(function(){return true;}, E_WARNING); + $result = stream_select($read, $write, $except, 10); + restore_error_handler(); + return $result; + } + + private function _transform($input) { + if ($input === null) { + return null; + } + + $transforms = array( + 'exit' => 'exit(0)' + ); + + foreach ($transforms as $from => $to) { + $input = preg_replace('/^\s*' . preg_quote($from, '/') . '\s*;?\s*$/', $to . ';', $input); + } + + return $input; + } +} diff --git a/vendor/d11wtq/boris/lib/Boris/ExportInspector.php b/vendor/d11wtq/boris/lib/Boris/ExportInspector.php new file mode 100755 index 0000000..2ac226b --- /dev/null +++ b/vendor/d11wtq/boris/lib/Boris/ExportInspector.php @@ -0,0 +1,14 @@ +_socket = $socket; + } + + /** + * Start the client with an prompt and readline history path. + * + * This method never returns. + * + * @param string $prompt + * @param string $historyFile + */ + public function start($prompt, $historyFile) { + readline_read_history($historyFile); + + declare(ticks = 1); + pcntl_signal(SIGCHLD, SIG_IGN); + pcntl_signal(SIGINT, array($this, 'clear'), true); + + // wait for the worker to finish executing hooks + if (fread($this->_socket, 1) != EvalWorker::READY) { + throw new \RuntimeException('EvalWorker failed to start'); + } + + $parser = new ShallowParser(); + $buf = ''; + $lineno = 1; + + for (;;) { + $this->_clear = false; + $line = readline( + sprintf( + '[%d] %s', + $lineno, + ($buf == '' + ? $prompt + : str_pad('*> ', strlen($prompt), ' ', STR_PAD_LEFT)) + ) + ); + + if ($this->_clear) { + $buf = ''; + continue; + } + + if (false === $line) { + $buf = 'exit(0);'; // ctrl-d acts like exit + } + + if (strlen($line) > 0) { + readline_add_history($line); + } + + $buf .= sprintf("%s\n", $line); + + if ($statements = $parser->statements($buf)) { + ++$lineno; + + $buf = ''; + foreach ($statements as $stmt) { + if (false === $written = fwrite($this->_socket, $stmt)) { + throw new \RuntimeException('Socket error: failed to write data'); + } + + if ($written > 0) { + $status = fread($this->_socket, 1); + if ($status == EvalWorker::EXITED) { + readline_write_history($historyFile); + echo "\n"; + exit(0); + } elseif ($status == EvalWorker::FAILED) { + break; + } + } + } + } + } + } + + /** + * Clear the input buffer. + */ + public function clear() { + // FIXME: I'd love to have this send \r to readline so it puts the user on a blank line + $this->_clear = true; + } +} diff --git a/vendor/d11wtq/boris/lib/Boris/ShallowParser.php b/vendor/d11wtq/boris/lib/Boris/ShallowParser.php new file mode 100755 index 0000000..624724b --- /dev/null +++ b/vendor/d11wtq/boris/lib/Boris/ShallowParser.php @@ -0,0 +1,233 @@ + ')', + '{' => '}', + '[' => ']', + '"' => '"', + "'" => "'", + '//' => "\n", + '#' => "\n", + '/*' => '*/', + '<<<' => '_heredoc_special_case_' + ); + + private $_initials; + + public function __construct() { + $this->_initials = '/^(' . implode('|', array_map(array($this, 'quote'), array_keys($this->_pairs))) . ')/'; + } + + /** + * Break the $buffer into chunks, with one for each highest-level construct possible. + * + * If the buffer is incomplete, returns an empty array. + * + * @param string $buffer + * + * @return array + */ + public function statements($buffer) { + $result = $this->_createResult($buffer); + + while (strlen($result->buffer) > 0) { + $this->_resetResult($result); + + if ($result->state == '<<<') { + if (!$this->_initializeHeredoc($result)) { + continue; + } + } + + $rules = array('_scanEscapedChar', '_scanRegion', '_scanStateEntrant', '_scanWsp', '_scanChar'); + + foreach ($rules as $method) { + if ($this->$method($result)) { + break; + } + } + + if ($result->stop) { + break; + } + } + + if (!empty($result->statements) && trim($result->stmt) === '' && strlen($result->buffer) == 0) { + $this->_combineStatements($result); + $this->_prepareForDebug($result); + return $result->statements; + } + } + + public function quote($token) { + return preg_quote($token, '/'); + } + + // -- Private Methods + + private function _createResult($buffer) { + $result = new \stdClass(); + $result->buffer = $buffer; + $result->stmt = ''; + $result->state = null; + $result->states = array(); + $result->statements = array(); + $result->stop = false; + + return $result; + } + + private function _resetResult($result) { + $result->stop = false; + $result->state = end($result->states); + $result->terminator = $result->state + ? '/^(.*?' . preg_quote($this->_pairs[$result->state], '/') . ')/s' + : null + ; + } + + private function _combineStatements($result) { + $combined = array(); + + foreach ($result->statements as $scope) { + if (trim($scope) == ';' || substr(trim($scope), -1) != ';') { + $combined[] = ((string) array_pop($combined)) . $scope; + } else { + $combined[] = $scope; + } + } + + $result->statements = $combined; + } + + private function _prepareForDebug($result) { + $result->statements []= $this->_prepareDebugStmt(array_pop($result->statements)); + } + + private function _initializeHeredoc($result) { + if (preg_match('/^([\'"]?)([a-z_][a-z0-9_]*)\\1/i', $result->buffer, $match)) { + $docId = $match[2]; + $result->stmt .= $match[0]; + $result->buffer = substr($result->buffer, strlen($match[0])); + + $result->terminator = '/^(.*?\n' . $docId . ');?\n/s'; + + return true; + } else { + return false; + } + } + + private function _scanWsp($result) { + if (preg_match('/^\s+/', $result->buffer, $match)) { + if (!empty($result->statements) && $result->stmt === '') { + $result->statements[] = array_pop($result->statements) . $match[0]; + } else { + $result->stmt .= $match[0]; + } + $result->buffer = substr($result->buffer, strlen($match[0])); + + return true; + } else { + return false; + } + } + + private function _scanEscapedChar($result) { + if (($result->state == '"' || $result->state == "'") + && preg_match('/^[^' . $result->state . ']*?\\\\./s', $result->buffer, $match)) { + + $result->stmt .= $match[0]; + $result->buffer = substr($result->buffer, strlen($match[0])); + + return true; + } else { + return false; + } + } + + private function _scanRegion($result) { + if (in_array($result->state, array('"', "'", '<<<', '//', '#', '/*'))) { + if (preg_match($result->terminator, $result->buffer, $match)) { + $result->stmt .= $match[1]; + $result->buffer = substr($result->buffer, strlen($match[1])); + array_pop($result->states); + } else { + $result->stop = true; + } + + return true; + } else { + return false; + } + } + + private function _scanStateEntrant($result) { + if (preg_match($this->_initials, $result->buffer, $match)) { + $result->stmt .= $match[0]; + $result->buffer = substr($result->buffer, strlen($match[0])); + $result->states[] = $match[0]; + + return true; + } else { + return false; + } + } + + private function _scanChar($result) { + $chr = substr($result->buffer, 0, 1); + $result->stmt .= $chr; + $result->buffer = substr($result->buffer, 1); + if ($result->state && $chr == $this->_pairs[$result->state]) { + array_pop($result->states); + } + + if (empty($result->states) && ($chr == ';' || $chr == '}')) { + if (!$this->_isLambda($result->stmt) || $chr == ';') { + $result->statements[] = $result->stmt; + $result->stmt = ''; + } + } + + return true; + } + + private function _isLambda($input) { + return preg_match( + '/^([^=]*?=\s*)?function\s*\([^\)]*\)\s*(use\s*\([^\)]*\)\s*)?\s*\{.*\}\s*;?$/is', + trim($input) + ); + } + + private function _isReturnable($input) { + $input = trim($input); + if (substr($input, -1) == ';' && substr($input, 0, 1) != '{') { + return $this->_isLambda($input) || !preg_match( + '/^(' . + 'echo|print|exit|die|goto|global|include|include_once|require|require_once|list|' . + 'return|do|for|foreach|while|if|function|namespace|class|interface|abstract|switch|' . + 'declare|throw|try|unset' . + ')\b/i', + $input + ); + } else { + return false; + } + } + + private function _prepareDebugStmt($input) { + if ($this->_isReturnable($input) && !preg_match('/^\s*return/i', $input)) { + $input = sprintf('return %s', $input); + } + + return $input; + } +} diff --git a/vendor/d11wtq/boris/lib/autoload.php b/vendor/d11wtq/boris/lib/autoload.php new file mode 100755 index 0000000..9ef54f4 --- /dev/null +++ b/vendor/d11wtq/boris/lib/autoload.php @@ -0,0 +1,18 @@ +register(new Whoops\Provider\Silex\WhoopsServiceProvider); +} + +// ... + +$app->run(); +``` + +And that's about it. By default, you'll get the pretty error pages if something goes awry in your development +environment, but you also have full access to the **whoops** library, obviously. For example, adding a new handler +into your app is as simple as extending `whoops`: + +```php +$app['whoops'] = $app->extend('whoops', function($whoops) { + $whoops->pushHandler(new DeleteWholeProjectHandler); + return $whoops; +}); +``` +### Integrating with Phalcon + +**whoops** comes packaged with a Phalcon Service Provider: `Whoops\Provider\Phalcon\WhoopsServiceProvider`. Using it +in your existing Phalcon project is easy. The provider uses the default Phalcon DI unless you pass a DI instance into the constructor. + +```php +new Whoops\Provider\Phalcon\WhoopsServiceProvider; + +// --- or --- + +$di = Phalcon\DI\FactoryDefault; +new Whoops\Provider\Phalcon\WhoopsServiceProvider($di); +``` + +### Integrating with Laravel 4/Illuminate + +If you're using Laravel 4, as of [this commit to laravel/framework](https://github.com/laravel/framework/commit/64f3a79aae254b71550a8097880f0b0e09062d24), you're already using Whoops! Yay! + +### Integrating with Laravel 3 + +User [@hugomrdias](https://github.com/hugomrdias) contributed a simple guide/example to help you integrate **whoops** with Laravel 3's IoC container, available at: + +https://gist.github.com/hugomrdias/5169713#file-start-php + +### Integrating with Zend Framework 2 + +User [@zsilbi](https://github.com/zsilbi) contributed a provider for ZF2 integration, +available in the following location: + +https://github.com/filp/whoops/tree/master/src/Whoops/Provider/Zend + +**Instructions:** + +- Add Whoops as a module to you app (/vendor/Whoops) +- Whoops must be the first module: + +```php +'modules' => array( + 'Whoops', + 'Application' + ) +``` + +- Move Module.php from /Whoops/Provider/Zend/Module.php to /Whoops/Module.php +- Use optional configurations in your controller config: + +```php +return array( + 'view_manager' => array( + 'display_not_found_reason' => true, + 'display_exceptions' => true, + 'json_exceptions' => array( + 'display' => true, + 'ajax_only' => true, + 'show_trace' => true + ) + ), +); +``` + +- NOTE: ob_clean(); is used to remove previous output, so you may use ob_start(); at the beginning of your app (index.php) + +### Opening referenced files with your favorite editor or IDE + +When using the pretty error page feature, whoops comes with the ability to +open referenced files directly in your IDE or editor. + +```php +setEditor('sublime'); +``` + +The following editors are currently supported by default. + +- `sublime` - Sublime Text 2 +- `emacs` - Emacs +- `textmate` - Textmate +- `macvim` - MacVim +- `xdebug` - xdebug (uses [xdebug.file_link_format](http://xdebug.org/docs/all_settings#file_link_format)) + +Adding your own editor is simple: + +```php + +$handler->setEditor(function($file, $line) { + return "whatever://open?file=$file&line=$line"; +}); + +``` + +You can add PhpStorm support with [PhpStormOpener](https://github.com/pinepain/PhpStormOpener#phpstormopener) (Mac OS X only): +```php + +$handler->setEditor( + function ($file, $line) { + // if your development server is not local it's good to map remote files to local + $translations = array('^' . __DIR__ => '~/Development/PhpStormOpener'); // change to your path + + foreach ($translations as $from => $to) { + $file = preg_replace('#' . $from . '#', $to, $file, 1); + } + + return "pstorm://$file:$line"; + } +); + +``` + +### Available Handlers + +**whoops** currently ships with the following built-in handlers, available in the `Whoops\Handler` namespace: + +- [`PrettyPageHandler`](https://github.com/filp/whoops/blob/master/src/Whoops/Handler/PrettyPageHandler.php) - Shows a pretty error page when something goes pants-up +- [`CallbackHandler`](https://github.com/filp/whoops/blob/master/src/Whoops/Handler/CallbackHandler.php) - Wraps a closure or other callable as a handler. You do not need to use this handler explicitly, **whoops** will automatically wrap any closure or callable you pass to `Whoops\Run::pushHandler` +- [`JsonResponseHandler`](https://github.com/filp/whoops/blob/master/src/Whoops/Handler/JsonResponseHandler.php) - Captures exceptions and returns information on them as a JSON string. Can be used to, for example, play nice with AJAX requests. + +## Contributing + +If you want to give me some feedback or make a suggestion, send me a message through +twitter: [@imfilp](https://twitter.com/imfilp) + +If you want to get your hands dirty, great! Here's a couple of steps/guidelines: + +- Fork/clone this repo, and update dev dependencies using Composer + +```bash +$ git clone git@github.com:filp/whoops.git +$ cd whoops +$ composer install --dev +``` + +- Create a new branch for your feature or fix + +```bash +$ git checkout -b feature/flames-on-the-side +``` + +- Add your changes & tests for those changes (in `tests/`). +- Remember to stick to the existing code style as best as possible. When in doubt, follow `PSR-2`. +- Send me a pull request! + +If you don't want to go through all this, but still found something wrong or missing, please +let me know, and/or **open a new issue report** so that I or others may take care of it. + +## Authors + +This library was primarily developed by [Filipe Dobreira](https://github.com/filp). + +A lot of awesome fixes and enhancements were also sent in by contributors, which you can find **[in this page right here](https://github.com/filp/whoops/contributors)**. + + +[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/filp/whoops/trend.png)](https://bitdeli.com/free "Bitdeli Badge") + diff --git a/vendor/filp/whoops/composer.json b/vendor/filp/whoops/composer.json new file mode 100755 index 0000000..ddae298 --- /dev/null +++ b/vendor/filp/whoops/composer.json @@ -0,0 +1,26 @@ +{ + "name": "filp/whoops", + "license": "MIT", + "description": "php error handling for cool kids", + "keywords": ["library", "error", "handling", "exception", "silex-provider", "whoops", "zf2"], + "homepage": "https://github.com/filp/whoops", + "authors": [ + { + "name": "Filipe Dobreira", + "homepage": "https://github.com/filp", + "role": "Developer" + } + ], + "require": { + "php": ">=5.3.0" + }, + "require-dev": { + "mockery/mockery": "dev-master", + "silex/silex": "1.0.*@dev" + }, + "autoload": { + "psr-0": { + "Whoops": "src/" + } + } +} diff --git a/vendor/filp/whoops/examples/example-ajax-only.php b/vendor/filp/whoops/examples/example-ajax-only.php new file mode 100755 index 0000000..9f44bd5 --- /dev/null +++ b/vendor/filp/whoops/examples/example-ajax-only.php @@ -0,0 +1,46 @@ + + * + * Run this example file with the PHP 5.4 web server with: + * + * $ cd project_dir + * $ php -S localhost:8080 + * + * and access localhost:8080/examples/example-ajax-only.php through your browser + * + * Or just run it through apache/nginx/what-have-yous as usual. + */ + +namespace Whoops\Example; +use Whoops\Run; +use Whoops\Handler\PrettyPageHandler; +use Whoops\Handler\JsonResponseHandler; +use RuntimeException; + +require __DIR__ . '/../vendor/autoload.php'; + +$run = new Run; + +// We want the error page to be shown by default, if this is a +// regular request, so that's the first thing to go into the stack: +$run->pushHandler(new PrettyPageHandler); + +// Now, we want a second handler that will run before the error page, +// and immediately return an error message in JSON format, if something +// goes awry. +$jsonHandler = new JsonResponseHandler; + +// Make sure it only triggers for AJAX requests: +$jsonHandler->onlyForAjaxRequests(true); + +// You can also tell JsonResponseHandler to give you a full stack trace: +// $jsonHandler->addTraceToOutput(true); + +// And push it into the stack: +$run->pushHandler($jsonHandler); + +// That's it! Register Whoops and throw a dummy exception: +$run->register(); +throw new RuntimeException("Oh fudge napkins!"); diff --git a/vendor/filp/whoops/examples/example-silex.php b/vendor/filp/whoops/examples/example-silex.php new file mode 100755 index 0000000..86530a4 --- /dev/null +++ b/vendor/filp/whoops/examples/example-silex.php @@ -0,0 +1,36 @@ + + * + * NOTE: Requires silex/silex, can be installed with composer + * within this project using the --dev flag: + * + * $ composer install --dev + * + * Run this example file with the PHP 5.4 web server with: + * + * $ cd project_dir + * $ php -S localhost:8080 + * + * and access localhost:8080/examples/example-silex.php through your browser + * + * Or just run it through apache/nginx/what-have-yous as usual. + */ +require __DIR__ . '/../vendor/autoload.php'; + +use Whoops\Provider\Silex\WhoopsServiceProvider; +use Silex\Application; + +$app = new Application; +$app['debug'] = true; + +if($app['debug']) { + $app->register(new WhoopsServiceProvider); +} + +$app->get('/', function() use($app) { + throw new RuntimeException("Oh no!"); +}); + +$app->run(); diff --git a/vendor/filp/whoops/examples/example.php b/vendor/filp/whoops/examples/example.php new file mode 100755 index 0000000..80c2b99 --- /dev/null +++ b/vendor/filp/whoops/examples/example.php @@ -0,0 +1,63 @@ + + * + * Run this example file with the PHP 5.4 web server with: + * + * $ cd project_dir + * $ php -S localhost:8080 + * + * and access localhost:8080/examples/example.php through your browser + * + * Or just run it through apache/nginx/what-have-yous as usual. + */ + +namespace Whoops\Example; +use Whoops\Run; +use Whoops\Handler\PrettyPageHandler; +use Exception as BaseException; + +require __DIR__ . '/../vendor/autoload.php'; + +class Exception extends BaseException {} + +$run = new Run; +$handler = new PrettyPageHandler; + +// Add a custom table to the layout: +$handler->addDataTable('Ice-cream I like', array( + 'Chocolate' => 'yes', + 'Coffee & chocolate' => 'a lot', + 'Strawberry & chocolate' => 'it\'s alright', + 'Vanilla' => 'ew' +)); + +$run->pushHandler($handler); + +// Example: tag all frames inside a function with their function name +$run->pushHandler(function($exception, $inspector, $run) { + + $inspector->getFrames()->map(function($frame) { + + if($function = $frame->getFunction()) { + $frame->addComment("This frame is within function '$function'", 'cpt-obvious'); + } + + return $frame; + }); + +}); + +$run->register(); + +function fooBar() { + throw new Exception("Something broke!"); +} + +function bar() +{ + fooBar(); +} + +bar(); diff --git a/vendor/filp/whoops/phpunit.xml.dist b/vendor/filp/whoops/phpunit.xml.dist new file mode 100755 index 0000000..a5abf9a --- /dev/null +++ b/vendor/filp/whoops/phpunit.xml.dist @@ -0,0 +1,15 @@ + + + + + + tests/Whoops/ + + + + + + src/Whoops/ + + + diff --git a/vendor/filp/whoops/src/Whoops/Exception/ErrorException.php b/vendor/filp/whoops/src/Whoops/Exception/ErrorException.php new file mode 100755 index 0000000..8a770af --- /dev/null +++ b/vendor/filp/whoops/src/Whoops/Exception/ErrorException.php @@ -0,0 +1,14 @@ + + */ + +namespace Whoops\Exception; +use ErrorException as BaseErrorException; + +/** + * Wraps ErrorException; mostly used for typing (at least now) + * to easily cleanup the stack trace of redundant info. + */ +class ErrorException extends BaseErrorException {} diff --git a/vendor/filp/whoops/src/Whoops/Exception/Frame.php b/vendor/filp/whoops/src/Whoops/Exception/Frame.php new file mode 100755 index 0000000..8895f26 --- /dev/null +++ b/vendor/filp/whoops/src/Whoops/Exception/Frame.php @@ -0,0 +1,252 @@ + + */ + +namespace Whoops\Exception; +use InvalidArgumentException; +use Serializable; + +class Frame implements Serializable +{ + /** + * @var array + */ + protected $frame; + + /** + * @var string + */ + protected $fileContentsCache; + + /** + * @var array[] + */ + protected $comments = array(); + + /** + * @param array[] + */ + public function __construct(array $frame) + { + $this->frame = $frame; + } + + /** + * @param bool $shortened + * @return string|null + */ + public function getFile($shortened = false) + { + if(empty($this->frame['file'])) { + return null; + } + + $file = $this->frame['file']; + + // Check if this frame occurred within an eval(). + // @todo: This can be made more reliable by checking if we've entered + // eval() in a previous trace, but will need some more work on the upper + // trace collector(s). + if(preg_match('/^(.*)\((\d+)\) : eval\(\)\'d code$/', $file, $matches)) { + $file = $this->frame['file'] = $matches[1]; + $this->frame['line'] = (int) $matches[2]; + } + + if($shortened && is_string($file)) { + // Replace the part of the path that all frames have in common, and add 'soft hyphens' for smoother line-breaks. + $dirname = dirname(dirname(dirname(dirname(dirname(dirname(__DIR__)))))); + $file = str_replace($dirname, "…", $file); + $file = str_replace("/", "/­", $file); + } + + return $file; + } + + /** + * @return int|null + */ + public function getLine() + { + return isset($this->frame['line']) ? $this->frame['line'] : null; + } + + /** + * @return string|null + */ + public function getClass() + { + return isset($this->frame['class']) ? $this->frame['class'] : null; + } + + /** + * @return string|null + */ + public function getFunction() + { + return isset($this->frame['function']) ? $this->frame['function'] : null; + } + + /** + * @return array + */ + public function getArgs() + { + return isset($this->frame['args']) ? (array) $this->frame['args'] : array(); + } + + /** + * Returns the full contents of the file for this frame, + * if it's known. + * @return string|null + */ + public function getFileContents() + { + if($this->fileContentsCache === null && $filePath = $this->getFile()) { + + // Return null if the file doesn't actually exist - this may + // happen in cases where the filename is provided as, for + // example, 'Unknown' + if(!is_file($filePath)) { + return null; + } + + $this->fileContentsCache = file_get_contents($filePath); + } + + return $this->fileContentsCache; + } + + /** + * Adds a comment to this frame, that can be received and + * used by other handlers. For example, the PrettyPage handler + * can attach these comments under the code for each frame. + * + * An interesting use for this would be, for example, code analysis + * & annotations. + * + * @param string $comment + * @param string $context Optional string identifying the origin of the comment + */ + public function addComment($comment, $context = 'global') + { + $this->comments[] = array( + 'comment' => $comment, + 'context' => $context + ); + } + + /** + * Returns all comments for this frame. Optionally allows + * a filter to only retrieve comments from a specific + * context. + * + * @param string $filter + * @return array[] + */ + public function getComments($filter = null) + { + $comments = $this->comments; + + if($filter !== null) { + $comments = array_filter($comments, function($c) use($filter) { + return $c['context'] == $filter; + }); + } + + return $comments; + } + + /** + * Returns the array containing the raw frame data from which + * this Frame object was built + * + * @return array + */ + public function getRawFrame() + { + return $this->frame; + } + + /** + * Returns the contents of the file for this frame as an + * array of lines, and optionally as a clamped range of lines. + * + * NOTE: lines are 0-indexed + * + * @example + * Get all lines for this file + * $frame->getFileLines(); // => array( 0 => ' '...', ...) + * @example + * Get one line for this file, starting at line 10 (zero-indexed, remember!) + * $frame->getFileLines(9, 1); // array( 10 => '...', 11 => '...') + * + * @throws InvalidArgumentException if $length is less than or equal to 0 + * @param int $start + * @param int $length + * @return string[]|null + */ + public function getFileLines($start = 0, $length = null) + { + if(null !== ($contents = $this->getFileContents())) { + $lines = explode("\n", $contents); + + // Get a subset of lines from $start to $end + if($length !== null) + { + $start = (int) $start; + $length = (int) $length; + if ($start < 0) { + $start = 0; + } + + if($length <= 0) { + throw new InvalidArgumentException( + "\$length($length) cannot be lower or equal to 0" + ); + } + + $lines = array_slice($lines, $start, $length, true); + } + + return $lines; + } + } + + /** + * Implements the Serializable interface, with special + * steps to also save the existing comments. + * + * @see Serializable::serialize + * @return string + */ + public function serialize() + { + $frame = $this->frame; + if(!empty($this->comments)) { + $frame['_comments'] = $this->comments; + } + + return serialize($frame); + } + + /** + * Unserializes the frame data, while also preserving + * any existing comment data. + * + * @see Serializable::unserialize + * @param string $serializedFrame + */ + public function unserialize($serializedFrame) + { + $frame = unserialize($serializedFrame); + + if(!empty($frame['_comments'])) { + $this->comments = $frame['_comments']; + unset($frame['_comments']); + } + + $this->frame = $frame; + } +} diff --git a/vendor/filp/whoops/src/Whoops/Exception/FrameCollection.php b/vendor/filp/whoops/src/Whoops/Exception/FrameCollection.php new file mode 100755 index 0000000..5708712 --- /dev/null +++ b/vendor/filp/whoops/src/Whoops/Exception/FrameCollection.php @@ -0,0 +1,122 @@ + + */ + +namespace Whoops\Exception; +use Whoops\Exception\Frame; +use UnexpectedValueException; +use IteratorAggregate; +use ArrayIterator; +use Serializable; +use Countable; + +/** + * Exposes a fluent interface for dealing with an ordered list + * of stack-trace frames. + */ +class FrameCollection implements IteratorAggregate, Serializable, Countable +{ + /** + * @var array[] + */ + private $frames; + + /** + * @param array $frames + */ + public function __construct(array $frames) + { + $this->frames = array_map(function($frame) { + return new Frame($frame); + }, $frames); + } + + /** + * Filters frames using a callable, returns the same FrameCollection + * + * @param callable $callable + * @return FrameCollection + */ + public function filter($callable) + { + $this->frames = array_filter($this->frames, $callable); + return $this; + } + + /** + * Map the collection of frames + * + * @param callable $callable + * @return FrameCollection + */ + public function map($callable) + { + // Contain the map within a higher-order callable + // that enforces type-correctness for the $callable + $this->frames = array_map(function($frame) use($callable) { + $frame = call_user_func($callable, $frame); + + if(!$frame instanceof Frame) { + throw new UnexpectedValueException( + "Callable to " . __METHOD__ . " must return a Frame object" + ); + } + + return $frame; + }, $this->frames); + + return $this; + } + + /** + * Returns an array with all frames, does not affect + * the internal array. + * + * @todo If this gets any more complex than this, + * have getIterator use this method. + * @see FrameCollection::getIterator + * @return array + */ + public function getArray() + { + return $this->frames; + } + + /** + * @see IteratorAggregate::getIterator + * @return ArrayIterator + */ + public function getIterator() + { + return new ArrayIterator($this->frames); + } + + /** + * @see Countable::count + * @return int + */ + public function count() + { + return count($this->frames); + } + + /** + * @see Serializable::serialize + * @return string + */ + public function serialize() + { + return serialize($this->frames); + } + + /** + * @see Serializable::unserialize + * @param string $serializedFrames + */ + public function unserialize($serializedFrames) + { + $this->frames = unserialize($serializedFrames); + } +} diff --git a/vendor/filp/whoops/src/Whoops/Exception/Inspector.php b/vendor/filp/whoops/src/Whoops/Exception/Inspector.php new file mode 100755 index 0000000..2ecf757 --- /dev/null +++ b/vendor/filp/whoops/src/Whoops/Exception/Inspector.php @@ -0,0 +1,115 @@ + + */ + +namespace Whoops\Exception; +use Whoops\Exception\FrameCollection; +use Whoops\Exception\ErrorException; +use Exception; + +class Inspector +{ + /** + * @var Exception + */ + private $exception; + + /** + * @var FrameCollection + */ + private $frames; + + /** + * @param Exception $exception The exception to inspect + */ + public function __construct(Exception $exception) + { + $this->exception = $exception; + } + + /** + * @return Exception + */ + public function getException() + { + return $this->exception; + } + + /** + * @return string + */ + public function getExceptionName() + { + return get_class($this->exception); + } + + /** + * @return string + */ + public function getExceptionMessage() + { + return $this->exception->getMessage(); + } + + /** + * Returns an iterator for the inspected exception's + * frames. + * @return FrameCollection + */ + public function getFrames() + { + if($this->frames === null) { + $frames = $this->exception->getTrace(); + + // If we're handling an ErrorException thrown by Whoops, + // get rid of the last frame, which matches the handleError method, + // and do not add the current exception to trace. We ensure that + // the next frame does have a filename / linenumber, though. + if($this->exception instanceof ErrorException && empty($frames[1]['line'])) { + $frames = array($this->getFrameFromError($this->exception)); + } else { + $firstFrame = $this->getFrameFromException($this->exception); + array_unshift($frames, $firstFrame); + } + $this->frames = new FrameCollection($frames); + } + + return $this->frames; + } + + /** + * Given an exception, generates an array in the format + * generated by Exception::getTrace() + * @param Exception $exception + * @return array + */ + protected function getFrameFromException(Exception $exception) + { + return array( + 'file' => $exception->getFile(), + 'line' => $exception->getLine(), + 'class' => get_class($exception), + 'args' => array( + $exception->getMessage() + ) + ); + } + + /** + * Given an error, generates an array in the format + * generated by ErrorException + * @param ErrorException $exception + * @return array + */ + protected function getFrameFromError(ErrorException $exception) + { + return array( + 'file' => $exception->getFile(), + 'line' => $exception->getLine(), + 'class' => null, + 'args' => array() + ); + } +} diff --git a/vendor/filp/whoops/src/Whoops/Handler/CallbackHandler.php b/vendor/filp/whoops/src/Whoops/Handler/CallbackHandler.php new file mode 100755 index 0000000..b039be8 --- /dev/null +++ b/vendor/filp/whoops/src/Whoops/Handler/CallbackHandler.php @@ -0,0 +1,49 @@ + + */ + +namespace Whoops\Handler; +use Whoops\Handler\Handler; +use InvalidArgumentException; + +/** + * Wrapper for Closures passed as handlers. Can be used + * directly, or will be instantiated automagically by Whoops\Run + * if passed to Run::pushHandler + */ +class CallbackHandler extends Handler +{ + /** + * @var callable + */ + protected $callable; + + /** + * @throws InvalidArgumentException If argument is not callable + * @param callable $callable + */ + public function __construct($callable) + { + if(!is_callable($callable)) { + throw new InvalidArgumentException( + 'Argument to ' . __METHOD__ . ' must be valid callable' + ); + } + + $this->callable = $callable; + } + + /** + * @return int|null + */ + public function handle() + { + $exception = $this->getException(); + $inspector = $this->getInspector(); + $run = $this->getRun(); + + return call_user_func($this->callable, $exception, $inspector, $run); + } +} diff --git a/vendor/filp/whoops/src/Whoops/Handler/Handler.php b/vendor/filp/whoops/src/Whoops/Handler/Handler.php new file mode 100755 index 0000000..a6ca5c4 --- /dev/null +++ b/vendor/filp/whoops/src/Whoops/Handler/Handler.php @@ -0,0 +1,89 @@ + + */ + +namespace Whoops\Handler; +use Whoops\Handler\HandlerInterface; +use Whoops\Exception\Inspector; +use Whoops\Run; +use Exception; + +/** + * Abstract implementation of a Handler. + */ +abstract class Handler implements HandlerInterface +{ + /** + * Return constants that can be returned from Handler::handle + * to message the handler walker. + */ + const DONE = 0x10; // returning this is optional, only exists for + // semantic purposes + const LAST_HANDLER = 0x20; + const QUIT = 0x30; + + /** + * @var Run + */ + private $run; + + /** + * @var Inspector $inspector + */ + private $inspector; + + /** + * @var Exception $exception + */ + private $exception; + + /** + * @param Run $run + */ + public function setRun(Run $run) + { + $this->run = $run; + } + + /** + * @return Run + */ + protected function getRun() + { + return $this->run; + } + + /** + * @param Inspector $inspector + */ + public function setInspector(Inspector $inspector) + { + $this->inspector = $inspector; + } + + /** + * @return Inspector + */ + protected function getInspector() + { + return $this->inspector; + } + + /** + * @param Exception $exception + */ + public function setException(Exception $exception) + { + $this->exception = $exception; + } + + /** + * @return Exception + */ + protected function getException() + { + return $this->exception; + } +} diff --git a/vendor/filp/whoops/src/Whoops/Handler/HandlerInterface.php b/vendor/filp/whoops/src/Whoops/Handler/HandlerInterface.php new file mode 100755 index 0000000..abb4078 --- /dev/null +++ b/vendor/filp/whoops/src/Whoops/Handler/HandlerInterface.php @@ -0,0 +1,33 @@ + + */ + +namespace Whoops\Handler; +use Whoops\Exception\Inspector; +use Whoops\Run; +use Exception; + +interface HandlerInterface +{ + /** + * @return int|null A handler may return nothing, or a Handler::HANDLE_* constant + */ + public function handle(); + + /** + * @param Run $run + */ + public function setRun(Run $run); + + /** + * @param Exception $exception + */ + public function setException(Exception $exception); + + /** + * @param Inspector $inspector + */ + public function setInspector(Inspector $inspector); +} diff --git a/vendor/filp/whoops/src/Whoops/Handler/JsonResponseHandler.php b/vendor/filp/whoops/src/Whoops/Handler/JsonResponseHandler.php new file mode 100755 index 0000000..a5e8d62 --- /dev/null +++ b/vendor/filp/whoops/src/Whoops/Handler/JsonResponseHandler.php @@ -0,0 +1,109 @@ + + */ + +namespace Whoops\Handler; +use Whoops\Handler\Handler; +use Whoops\Exception\Frame; + +/** + * Catches an exception and converts it to a JSON + * response. Additionally can also return exception + * frames for consumption by an API. + */ +class JsonResponseHandler extends Handler +{ + /** + * @var bool + */ + private $returnFrames = false; + + /** + * @var bool + */ + private $onlyForAjaxRequests = false; + + /** + * @param bool|null $returnFrames + * @return null|bool + */ + public function addTraceToOutput($returnFrames = null) + { + if(func_num_args() == 0) { + return $this->returnFrames; + } + + $this->returnFrames = (bool) $returnFrames; + } + + /** + * @param bool|null $onlyForAjaxRequests + * @return null|bool + */ + public function onlyForAjaxRequests($onlyForAjaxRequests = null) + { + if(func_num_args() == 0) { + return $this->onlyForAjaxRequests; + } + + $this->onlyForAjaxRequests = (bool) $onlyForAjaxRequests; + } + + /** + * Check, if possible, that this execution was triggered by an AJAX request. + * + * @return bool + */ + private function isAjaxRequest() + { + return ( + !empty($_SERVER['HTTP_X_REQUESTED_WITH']) + && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') + ; + } + + /** + * @return int + */ + public function handle() + { + if($this->onlyForAjaxRequests() && !$this->isAjaxRequest()) { + return Handler::DONE; + } + + $exception = $this->getException(); + + $response = array( + 'error' => array( + 'type' => get_class($exception), + 'message' => $exception->getMessage(), + 'file' => $exception->getFile(), + 'line' => $exception->getLine() + ) + ); + + if($this->addTraceToOutput()) { + $inspector = $this->getInspector(); + $frames = $inspector->getFrames(); + $frameData = array(); + + foreach($frames as $frame) { + /** @var Frame $frame */ + $frameData[] = array( + 'file' => $frame->getFile(), + 'line' => $frame->getLine(), + 'function' => $frame->getFunction(), + 'class' => $frame->getClass(), + 'args' => $frame->getArgs() + ); + } + + $response['error']['trace'] = $frameData; + } + + echo json_encode($response); + return Handler::QUIT; + } +} diff --git a/vendor/filp/whoops/src/Whoops/Handler/PrettyPageHandler.php b/vendor/filp/whoops/src/Whoops/Handler/PrettyPageHandler.php new file mode 100755 index 0000000..33c215f --- /dev/null +++ b/vendor/filp/whoops/src/Whoops/Handler/PrettyPageHandler.php @@ -0,0 +1,333 @@ + + */ + +namespace Whoops\Handler; +use Whoops\Handler\Handler; +use InvalidArgumentException; + +class PrettyPageHandler extends Handler +{ + /** + * @var string + */ + private $resourcesPath; + + /** + * @var array[] + */ + private $extraTables = array(); + + /** + * @var string + */ + private $pageTitle = 'Whoops! There was an error.'; + + /** + * A string identifier for a known IDE/text editor, or a closure + * that resolves a string that can be used to open a given file + * in an editor. If the string contains the special substrings + * %file or %line, they will be replaced with the correct data. + * + * @example + * "txmt://open?url=%file&line=%line" + * @var mixed $editor + */ + protected $editor; + + /** + * A list of known editor strings + * @var array + */ + protected $editors = array( + 'sublime' => 'subl://open?url=file://%file&line=%line', + 'textmate' => 'txmt://open?url=file://%file&line=%line', + 'emacs' => 'emacs://open?url=file://%file&line=%line', + 'macvim' => 'mvim://open/?url=file://%file&line=%line' + ); + + /** + * Constructor. + */ + public function __construct() + { + if (ini_get('xdebug.file_link_format') || extension_loaded('xdebug')) { + // Register editor using xdebug's file_link_format option. + $this->editors['xdebug'] = function($file, $line) { + return str_replace(array('%f', '%l'), array($file, $line), ini_get('xdebug.file_link_format')); + }; + } + } + + /** + * @return int|null + */ + public function handle() + { + // Check conditions for outputting HTML: + // @todo: make this more robust + if(php_sapi_name() === 'cli' && !isset($_ENV['whoops-test'])) { + return Handler::DONE; + } + + // Get the 'pretty-template.php' template file + // @todo: this can be made more dynamic &&|| cleaned-up + if(!($resources = $this->getResourcesPath())) { + $resources = __DIR__ . '/../Resources'; + } + + $templateFile = "$resources/pretty-template.php"; + + // @todo: Make this more reliable, + // possibly by adding methods to append CSS & JS to the page + $cssFile = "$resources/pretty-page.css"; + + // Prepare the $v global variable that will pass relevant + // information to the template + $inspector = $this->getInspector(); + $frames = $inspector->getFrames(); + + $v = (object) array( + 'title' => $this->getPageTitle(), + 'name' => explode('\\', $inspector->getExceptionName()), + 'message' => $inspector->getException()->getMessage(), + 'frames' => $frames, + 'hasFrames' => !!count($frames), + 'handler' => $this, + 'handlers' => $this->getRun()->getHandlers(), + 'pageStyle' => file_get_contents($cssFile), + + 'tables' => array( + 'Server/Request Data' => $_SERVER, + 'GET Data' => $_GET, + 'POST Data' => $_POST, + 'Files' => $_FILES, + 'Cookies' => $_COOKIE, + 'Session' => isset($_SESSION) ? $_SESSION: array(), + 'Environment Variables' => $_ENV + ) + ); + + $extraTables = array_map(function($table) { + return $table instanceof \Closure ? $table() : $table; + }, $this->getDataTables()); + + // Add extra entries list of data tables: + $v->tables = array_merge($extraTables, $v->tables); + + call_user_func(function() use($templateFile, $v) { + // $e -> cleanup output, optionally preserving URIs as anchors: + $e = function($_, $allowLinks = false) { + $escaped = htmlspecialchars($_, ENT_QUOTES, 'UTF-8'); + + // convert URIs to clickable anchor elements: + if($allowLinks) { + $escaped = preg_replace( + '@([A-z]+?://([-\w\.]+[-\w])+(:\d+)?(/([\w/_\.#-]*(\?\S+)?[^\.\s])?)?)@', + "$1", $escaped + ); + } + + return $escaped; + }; + + // $slug -> sluggify string (i.e: Hello world! -> hello-world) + $slug = function($_) { + $_ = str_replace(" ", "-", $_); + $_ = preg_replace('/[^\w\d\-\_]/i', '', $_); + return strtolower($_); + }; + + require $templateFile; + }); + + + return Handler::QUIT; + } + + /** + * Adds an entry to the list of tables displayed in the template. + * The expected data is a simple associative array. Any nested arrays + * will be flattened with print_r + * @param string $label + * @param array $data + */ + public function addDataTable($label, array $data) + { + $this->extraTables[$label] = $data; + } + + /** + * Lazily adds an entry to the list of tables displayed in the table. + * The supplied callback argument will be called when the error is rendered, + * it should produce a simple associative array. Any nested arrays will + * be flattened with print_r. + * + * @throws InvalidArgumentException If $callback is not callable + * @param string $label + * @param callable $callback Callable returning an associative array + */ + public function addDataTableCallback($label, /* callable */ $callback) + { + if (!is_callable($callback)) { + throw new InvalidArgumentException('Expecting callback argument to be callable'); + } + + $this->extraTables[$label] = function() use ($callback) { + try { + $result = call_user_func($callback); + + // Only return the result if it can be iterated over by foreach(). + return is_array($result) || $result instanceof \Traversable ? $result : array(); + } catch (\Exception $e) { + // Don't allow failure to break the rendering of the original exception. + return array(); + } + }; + } + + /** + * Returns all the extra data tables registered with this handler. + * Optionally accepts a 'label' parameter, to only return the data + * table under that label. + * @param string|null $label + * @return array[] + */ + public function getDataTables($label = null) + { + if($label !== null) { + return isset($this->extraTables[$label]) ? + $this->extraTables[$label] : array(); + } + + return $this->extraTables; + } + + /** + * Adds an editor resolver, identified by a string + * name, and that may be a string path, or a callable + * resolver. If the callable returns a string, it will + * be set as the file reference's href attribute. + * + * @example + * $run->addEditor('macvim', "mvim://open?url=file://%file&line=%line") + * @example + * $run->addEditor('remove-it', function($file, $line) { + * unlink($file); + * return "http://stackoverflow.com"; + * }); + * @param string $identifier + * @param string $resolver + */ + public function addEditor($identifier, $resolver) + { + $this->editors[$identifier] = $resolver; + } + + /** + * Set the editor to use to open referenced files, by a string + * identifier, or a callable that will be executed for every + * file reference, with a $file and $line argument, and should + * return a string. + * + * @example + * $run->setEditor(function($file, $line) { return "file:///{$file}"; }); + * @example + * $run->setEditor('sublime'); + * + * @throws InvalidArgumentException If invalid argument identifier provided + * @param string|callable $editor + */ + public function setEditor($editor) + { + if(!is_callable($editor) && !isset($this->editors[$editor])) { + throw new InvalidArgumentException( + "Unknown editor identifier: $editor. Known editors:" . + implode(",", array_keys($this->editors)) + ); + } + + $this->editor = $editor; + } + + /** + * Given a string file path, and an integer file line, + * executes the editor resolver and returns, if available, + * a string that may be used as the href property for that + * file reference. + * + * @throws InvalidArgumentException If editor resolver does not return a string + * @param string $filePath + * @param int $line + * @return string|bool + */ + public function getEditorHref($filePath, $line) + { + if($this->editor === null) { + return false; + } + + $editor = $this->editor; + if(is_string($editor)) { + $editor = $this->editors[$editor]; + } + + if(is_callable($editor)) { + $editor = call_user_func($editor, $filePath, $line); + } + + // Check that the editor is a string, and replace the + // %line and %file placeholders: + if(!is_string($editor)) { + throw new InvalidArgumentException( + __METHOD__ . " should always resolve to a string; got something else instead" + ); + } + + $editor = str_replace("%line", rawurlencode($line), $editor); + $editor = str_replace("%file", rawurlencode($filePath), $editor); + + return $editor; + } + + /** + * @var string + */ + public function setPageTitle($title) + { + $this->pageTitle = (string) $title; + } + + /** + * @return string + */ + public function getPageTitle() + { + return $this->pageTitle; + } + + /** + * @return string + */ + public function getResourcesPath() + { + return $this->resourcesPath; + } + + /** + * @throws InvalidArgumentException If argument is not a valid directory + * @param string $resourcesPath + */ + public function setResourcesPath($resourcesPath) + { + if(!is_dir($resourcesPath)) { + throw new InvalidArgumentException( + "$resourcesPath is not a valid directory" + ); + } + + $this->resourcesPath = $resourcesPath; + } +} diff --git a/vendor/filp/whoops/src/Whoops/Handler/XmlResponseHandler.php b/vendor/filp/whoops/src/Whoops/Handler/XmlResponseHandler.php new file mode 100755 index 0000000..d79331e --- /dev/null +++ b/vendor/filp/whoops/src/Whoops/Handler/XmlResponseHandler.php @@ -0,0 +1,137 @@ + + */ + +namespace Whoops\Handler; + +use SimpleXMLElement; +use Whoops\Exception\Frame; +use Whoops\Handler\Handler; + +/** + * Catches an exception and converts it to an XML + * response. Additionally can also return exception + * frames for consumption by an API. + */ +class XmlResponseHandler extends Handler +{ + /** + * @var bool + */ + private $returnFrames = false; + + /** + * @param bool|null $returnFrames + * @return null|bool + */ + public function addTraceToOutput($returnFrames = null) + { + if(func_num_args() == 0) { + return $this->returnFrames; + } + + $this->returnFrames = (bool) $returnFrames; + } + + /** + * @return int + */ + public function handle() + { + $exception = $this->getException(); + + $response = array( + 'error' => array( + 'type' => get_class($exception), + 'message' => $exception->getMessage(), + 'file' => $exception->getFile(), + 'line' => $exception->getLine() + ) + ); + + if($this->addTraceToOutput()) { + $inspector = $this->getInspector(); + $frames = $inspector->getFrames(); + $frameData = array(); + + foreach($frames as $frame) { + /** @var Frame $frame */ + $frameData[] = array( + 'file' => $frame->getFile(), + 'line' => $frame->getLine(), + 'function' => $frame->getFunction(), + 'class' => $frame->getClass(), + 'args' => $frame->getArgs() + ); + } + + $response['error']['trace'] = array_flip($frameData); + } + + echo $this->toXml($response); + + return Handler::QUIT; + } + + /** + * @param SimpleXMLElement $node Node to append data to, will be modified in place + * @param array|Traversable $data + * @return SimpleXMLElement The modified node, for chaining + */ + private static function addDataToNode(\SimpleXMLElement $node, $data) + { + assert('is_array($data) || $node instanceof Traversable'); + + foreach($data as $key => $value) + { + if (is_numeric($key)) + { + // Convert the key to a valid string + $key = "unknownNode_". (string) $key; + } + + // Delete any char not allowed in XML element names + $key = preg_replace('/[^a-z0-9\-\_\.\:]/i', '', $key); + + if (is_array($value)) + { + $child = $node->addChild($key); + self::addDataToNode($child, $value); + } + else + { + $value = str_replace('&', '&', print_r($value, true)); + $node->addChild($key, $value); + } + } + + return $node; + } + + /** + * The main function for converting to an XML document. + * + * @param array|Traversable $data + * @return string XML + */ + private static function toXml($data) + { + assert('is_array($data) || $node instanceof Traversable'); + + // turn off compatibility mode as simple xml throws a wobbly if you don't. + $compatibilityMode = ini_get('zend.ze1_compatibility_mode'); + if ($compatibilityMode) { + ini_set('zend.ze1_compatibility_mode', 0); + } + + $node = simplexml_load_string(""); + $xml = self::addDataToNode($node, $data)->asXML(); + + if ($compatibilityMode) { + ini_set('zend.ze1_compatibility_mode', $compatibilityMode); + } + return $xml; + } +} diff --git a/vendor/filp/whoops/src/Whoops/Provider/Phalcon/WhoopsServiceProvider.php b/vendor/filp/whoops/src/Whoops/Provider/Phalcon/WhoopsServiceProvider.php new file mode 100755 index 0000000..89dc8f7 --- /dev/null +++ b/vendor/filp/whoops/src/Whoops/Provider/Phalcon/WhoopsServiceProvider.php @@ -0,0 +1,78 @@ + + */ + +namespace Whoops\Provider\Phalcon; + +use Whoops\Run; +use Whoops\Handler\PrettyPageHandler; +use Whoops\Handler\JsonResponseHandler; +use Phalcon\DI; +use Phalcon\DI\Exception; + +class WhoopsServiceProvider +{ + /** + * @param DI $di + */ + public function __construct(DI $di = null) + { + if (!$di) { + $di = DI::getDefault(); + } + + // There's only ever going to be one error page...right? + $di->setShared('whoops.pretty_page_handler', function() { + return new PrettyPageHandler; + }); + + // There's only ever going to be one error page...right? + $di->setShared('whoops.json_response_handler', function() { + $jsonHandler = new JsonResponseHandler; + $jsonHandler->onlyForAjaxRequests(true); + return $jsonHandler; + }); + + // Retrieves info on the Phalcon environment and ships it off + // to the PrettyPageHandler's data tables: + // This works by adding a new handler to the stack that runs + // before the error page, retrieving the shared page handler + // instance, and working with it to add new data tables + $phalcon_info_handler = function() use($di) { + try { + $request = $di['request']; + } catch (Exception $e) { + // This error occurred too early in the application's life + // and the request instance is not yet available. + return; + } + + // Request info: + $di['whoops.pretty_page_handler']->addDataTable('Phalcon Application (Request)', array( + 'URI' => $request->getScheme().'://'.$request->getServer('HTTP_HOST').$request->getServer('REQUEST_URI'), + 'Request URI' => $request->getServer('REQUEST_URI'), + 'Path Info' => $request->getServer('PATH_INFO'), + 'Query String'=> $request->getServer('QUERY_STRING') ?: '', + 'HTTP Method' => $request->getMethod(), + 'Script Name' => $request->getServer('SCRIPT_NAME'), + //'Base Path' => $request->getBasePath(), + //'Base URL' => $request->getBaseUrl(), + 'Scheme' => $request->getScheme(), + 'Port' => $request->getServer('SERVER_PORT'), + 'Host' => $request->getServerName(), + )); + }; + + $di->setShared('whoops', function() use($di, $phalcon_info_handler) { + $run = new Run; + $run->pushHandler($di['whoops.pretty_page_handler']); + $run->pushHandler($phalcon_info_handler); + $run->pushHandler($di['whoops.json_response_handler']); + return $run; + }); + + $di['whoops']->register(); + } +} diff --git a/vendor/filp/whoops/src/Whoops/Provider/Silex/WhoopsServiceProvider.php b/vendor/filp/whoops/src/Whoops/Provider/Silex/WhoopsServiceProvider.php new file mode 100755 index 0000000..519ddfc --- /dev/null +++ b/vendor/filp/whoops/src/Whoops/Provider/Silex/WhoopsServiceProvider.php @@ -0,0 +1,85 @@ + + */ + +namespace Whoops\Provider\Silex; +use Whoops\Run; +use Whoops\Handler\PrettyPageHandler; +use Silex\ServiceProviderInterface; +use Silex\Application; +use Symfony\Component\HttpFoundation\Request; +use RuntimeException; + +class WhoopsServiceProvider implements ServiceProviderInterface +{ + /** + * @param Application $app + */ + public function register(Application $app) + { + // There's only ever going to be one error page...right? + $app['whoops.error_page_handler'] = $app->share(function() { + return new PrettyPageHandler; + }); + + // Retrieves info on the Silex environment and ships it off + // to the PrettyPageHandler's data tables: + // This works by adding a new handler to the stack that runs + // before the error page, retrieving the shared page handler + // instance, and working with it to add new data tables + $app['whoops.silex_info_handler'] = $app->protect(function() use($app) { + try { + /** @var Request $request */ + $request = $app['request']; + } catch (RuntimeException $e) { + // This error occurred too early in the application's life + // and the request instance is not yet available. + return; + } + + /** @var PrettyPageHandler $errorPageHandler */ + $errorPageHandler = $app["whoops.error_page_handler"]; + + // General application info: + $errorPageHandler->addDataTable('Silex Application', array( + 'Charset' => $app['charset'], + 'Locale' => $app['locale'], + 'Route Class' => $app['route_class'], + 'Dispatcher Class' => $app['dispatcher_class'], + 'Application Class'=> get_class($app) + )); + + // Request info: + $errorPageHandler->addDataTable('Silex Application (Request)', array( + 'URI' => $request->getUri(), + 'Request URI' => $request->getRequestUri(), + 'Path Info' => $request->getPathInfo(), + 'Query String'=> $request->getQueryString() ?: '', + 'HTTP Method' => $request->getMethod(), + 'Script Name' => $request->getScriptName(), + 'Base Path' => $request->getBasePath(), + 'Base URL' => $request->getBaseUrl(), + 'Scheme' => $request->getScheme(), + 'Port' => $request->getPort(), + 'Host' => $request->getHost(), + )); + }); + + $app['whoops'] = $app->share(function() use($app) { + $run = new Run; + $run->pushHandler($app['whoops.error_page_handler']); + $run->pushHandler($app['whoops.silex_info_handler']); + return $run; + }); + + $app->error(array($app['whoops'], Run::EXCEPTION_HANDLER)); + $app['whoops']->register(); + } + + /** + * @see Silex\ServiceProviderInterface::boot + */ + public function boot(Application $app) {} +} diff --git a/vendor/filp/whoops/src/Whoops/Provider/Zend/ExceptionStrategy.php b/vendor/filp/whoops/src/Whoops/Provider/Zend/ExceptionStrategy.php new file mode 100755 index 0000000..e0731de --- /dev/null +++ b/vendor/filp/whoops/src/Whoops/Provider/Zend/ExceptionStrategy.php @@ -0,0 +1,59 @@ + + */ + +namespace Whoops\Provider\Zend; + +use Whoops\Run; + +use Zend\Mvc\View\Http\ExceptionStrategy as BaseExceptionStrategy; +use Zend\Mvc\MvcEvent; +use Zend\Mvc\Application; + +class ExceptionStrategy extends BaseExceptionStrategy { + + protected $run; + + public function __construct(Run $run) { + $this->run = $run; + return $this; + } + + public function prepareExceptionViewModel(MvcEvent $event) { + // Do nothing if no error in the event + $error = $event->getError(); + if (empty($error)) { + return; + } + + // Do nothing if the result is a response object + $result = $event->getResult(); + if ($result instanceof Response) { + return; + } + + switch ($error) { + case Application::ERROR_CONTROLLER_NOT_FOUND: + case Application::ERROR_CONTROLLER_INVALID: + case Application::ERROR_ROUTER_NO_MATCH: + // Specifically not handling these + return; + + case Application::ERROR_EXCEPTION: + default: + $exception = $event->getParam('exception'); + if($exception) { + $response = $event->getResponse(); + if (!$response || $response->getStatusCode() === 200) { + header('HTTP/1.0 500 Internal Server Error', true, 500); + } + ob_clean(); + $this->run->handleException($event->getParam('exception')); + } + break; + } + } + +} diff --git a/vendor/filp/whoops/src/Whoops/Provider/Zend/Module.php b/vendor/filp/whoops/src/Whoops/Provider/Zend/Module.php new file mode 100755 index 0000000..44f14ca --- /dev/null +++ b/vendor/filp/whoops/src/Whoops/Provider/Zend/Module.php @@ -0,0 +1,106 @@ + + * + * The Whoops directory should be added as a module to ZF2 (/vendor/Whoops) + * + * Whoops must be added as the first module + * For example: + * 'modules' => array( + * 'Whoops', + * 'Application', + * ), + * + * This file should be moved next to Whoops/Run.php (/vendor/Whoops/Module.php) + * + */ + +namespace Whoops; + +use Whoops\Run; +use Whoops\Provider\Zend\ExceptionStrategy; +use Whoops\Provider\Zend\RouteNotFoundStrategy; +use Whoops\Handler\JsonResponseHandler; +use Whoops\Handler\PrettyPageHandler; +use Zend\EventManager\EventInterface; +use Zend\Console\Request as ConsoleRequest; + +class Module +{ + protected $run; + + public function onBootstrap(EventInterface $event) + { + $prettyPageHandler = new PrettyPageHandler(); + + // Set editor + $config = $event->getApplication()->getServiceManager()->get('Config'); + if (isset($config['view_manager']['editor'])) { + $prettyPageHandler->setEditor($config['view_manager']['editor']); + } + + + $this->run = new Run(); + $this->run->register(); + $this->run->pushHandler($prettyPageHandler); + + $this->attachListeners($event); + } + + public function getAutoloaderConfig() + { + return array( + 'Zend\Loader\StandardAutoloader' => array( + 'namespaces' => array( + __NAMESPACE__ => __DIR__ . '/src/' . __NAMESPACE__, + ), + ), + ); + } + + private function attachListeners(EventInterface $event) + { + $request = $event->getRequest(); + $application = $event->getApplication(); + $services = $application->getServiceManager(); + $events = $application->getEventManager(); + $config = $services->get('Config'); + + //Display exceptions based on configuration and console mode + if ($request instanceof ConsoleRequest || empty($config['view_manager']['display_exceptions'])) + return; + + $jsonHandler = new JsonResponseHandler(); + + if (!empty($config['view_manager']['json_exceptions']['show_trace'])) { + //Add trace to the JSON output + $jsonHandler->addTraceToOutput(true); + } + + if (!empty($config['view_manager']['json_exceptions']['ajax_only'])) { + //Only return JSON response for AJAX requests + $jsonHandler->onlyForAjaxRequests(true); + } + + if (!empty($config['view_manager']['json_exceptions']['display'])) { + //Turn on JSON handler + $this->run->pushHandler($jsonHandler); + } + + //Attach the Whoops ExceptionStrategy + $exceptionStrategy = new ExceptionStrategy($this->run); + $exceptionStrategy->attach($events); + + //Attach the Whoops RouteNotFoundStrategy + $routeNotFoundStrategy = new RouteNotFoundStrategy($this->run); + $routeNotFoundStrategy->attach($events); + + //Detach default ExceptionStrategy + $services->get('Zend\Mvc\View\Http\ExceptionStrategy')->detach($events); + + //Detach default RouteNotFoundStrategy + $services->get('Zend\Mvc\View\Http\RouteNotFoundStrategy')->detach($events); + } + +} diff --git a/vendor/filp/whoops/src/Whoops/Provider/Zend/RouteNotFoundStrategy.php b/vendor/filp/whoops/src/Whoops/Provider/Zend/RouteNotFoundStrategy.php new file mode 100755 index 0000000..6c0b3de --- /dev/null +++ b/vendor/filp/whoops/src/Whoops/Provider/Zend/RouteNotFoundStrategy.php @@ -0,0 +1,64 @@ + + */ + +namespace Whoops\Provider\Zend; + +use Whoops\Run; + +use Zend\Mvc\View\Http\RouteNotFoundStrategy as BaseRouteNotFoundStrategy; +use Zend\Mvc\MvcEvent; +use Zend\Stdlib\ResponseInterface as Response; +use Zend\View\Model\ViewModel; + +class RouteNotFoundStrategy extends BaseRouteNotFoundStrategy { + + protected $run; + + public function __construct(Run $run) { + $this->run = $run; + } + + public function prepareNotFoundViewModel(MvcEvent $e) { + $vars = $e->getResult(); + if ($vars instanceof Response) { + // Already have a response as the result + return; + } + + $response = $e->getResponse(); + if ($response->getStatusCode() != 404) { + // Only handle 404 responses + return; + } + + if (!$vars instanceof ViewModel) { + $model = new ViewModel(); + if (is_string($vars)) { + $model->setVariable('message', $vars); + } else { + $model->setVariable('message', 'Page not found.'); + } + } else { + $model = $vars; + if ($model->getVariable('message') === null) { + $model->setVariable('message', 'Page not found.'); + } + } + // If displaying reasons, inject the reason + $this->injectNotFoundReason($model, $e); + + // If displaying exceptions, inject + $this->injectException($model, $e); + + // Inject controller if we're displaying either the reason or the exception + $this->injectController($model, $e); + + ob_clean(); + + throw new \Exception($model->getVariable('message') . ' ' . $model->getVariable('reason')); + } + +} diff --git a/vendor/filp/whoops/src/Whoops/Provider/Zend/module.config.example.php b/vendor/filp/whoops/src/Whoops/Provider/Zend/module.config.example.php new file mode 100755 index 0000000..13198a8 --- /dev/null +++ b/vendor/filp/whoops/src/Whoops/Provider/Zend/module.config.example.php @@ -0,0 +1,20 @@ + + * + * Example controller configuration + */ + +return array( + 'view_manager' => array( + 'editor' => 'sublime', + 'display_not_found_reason' => true, + 'display_exceptions' => true, + 'json_exceptions' => array( + 'display' => true, + 'ajax_only' => true, + 'show_trace' => true + ) + ), +); diff --git a/vendor/filp/whoops/src/Whoops/Resources/pretty-page.css b/vendor/filp/whoops/src/Whoops/Resources/pretty-page.css new file mode 100755 index 0000000..56a073d --- /dev/null +++ b/vendor/filp/whoops/src/Whoops/Resources/pretty-page.css @@ -0,0 +1,319 @@ +.cf:before, .cf:after {content: " ";display: table;} .cf:after {clear: both;} .cf {*zoom: 1;} +body { + font: 14px helvetica, arial, sans-serif; + color: #2B2B2B; + background-color: #D4D4D4; + padding:0; + margin: 0; + max-height: 100%; +} + a { + text-decoration: none; + } + +.container{ + height: 100%; + width: 100%; + position: fixed; + margin: 0; + padding: 0; + left: 0; + top: 0; +} + +.branding { + position: absolute; + top: 10px; + right: 20px; + color: #777777; + font-size: 10px; + z-index: 100; +} + .branding a { + color: #CD3F3F; + } + +header { + padding: 30px 20px; + color: white; + background: #272727; + box-sizing: border-box; + border-left: 5px solid #CD3F3F; +} + .exc-title { + margin: 0; + color: #616161; + text-shadow: 0 1px 2px rgba(0, 0, 0, .1); + } + .exc-title-primary { color: #CD3F3F; } + .exc-message { + font-size: 32px; + margin: 5px 0; + word-wrap: break-word; + } + +.stack-container { + height: 100%; + position: relative; +} + +.details-container { + height: 100%; + overflow: auto; + float: right; + width: 70%; + background: #DADADA; +} + .details { + padding: 10px; + padding-left: 5px; + border-left: 5px solid rgba(0, 0, 0, .1); + } + +.frames-container { + height: 100%; + overflow: auto; + float: left; + width: 30%; + background: #FFF; +} + .frame { + padding: 14px; + background: #F3F3F3; + border-right: 1px solid rgba(0, 0, 0, .2); + cursor: pointer; + } + .frame.active { + background-color: #4288CE; + color: #F3F3F3; + box-shadow: inset -2px 0 0 rgba(255, 255, 255, .1); + text-shadow: 0 1px 0 rgba(0, 0, 0, .2); + } + + .frame:not(.active):hover { + background: #BEE9EA; + } + + .frame-class, .frame-function, .frame-index { + font-weight: bold; + } + + .frame-index { + font-size: 11px; + color: #BDBDBD; + } + + .frame-class { + color: #4288CE; + } + .active .frame-class { + color: #BEE9EA; + } + + .frame-file { + font-family: consolas, monospace; + word-wrap:break-word; + } + + .frame-file .editor-link { + color: #272727; + } + + .frame-line { + font-weight: bold; + color: #4288CE; + } + + .active .frame-line { color: #BEE9EA; } + .frame-line:before { + content: ":"; + } + + .frame-code { + padding: 10px; + padding-left: 5px; + background: #BDBDBD; + display: none; + border-left: 5px solid #4288CE; + } + + .frame-code.active { + display: block; + } + + .frame-code .frame-file { + background: #C6C6C6; + color: #525252; + text-shadow: 0 1px 0 #E7E7E7; + padding: 10px 10px 5px 10px; + + border-top-right-radius: 6px; + border-top-left-radius: 6px; + + border: 1px solid rgba(0, 0, 0, .1); + border-bottom: none; + box-shadow: inset 0 1px 0 #DADADA; + } + + .code-block { + padding: 10px; + margin: 0; + box-shadow: inset 0 0 6px rgba(0, 0, 0, .3); + } + + .linenums { + margin: 0; + margin-left: 10px; + } + + .frame-comments { + box-shadow: inset 0 0 6px rgba(0, 0, 0, .3); + border: 1px solid rgba(0, 0, 0, .2); + border-top: none; + + border-bottom-right-radius: 6px; + border-bottom-left-radius: 6px; + + padding: 5px; + font-size: 12px; + background: #404040; + } + + .frame-comments.empty { + padding: 8px 15px; + } + + .frame-comments.empty:before { + content: "No comments for this stack frame."; + font-style: italic; + color: #828282; + } + + .frame-comment { + padding: 10px; + color: #D2D2D2; + } + .frame-comment a { + color: #BEE9EA; + font-weight: bold; + text-decoration: none; + } + .frame-comment a:hover { + color: #4bb1b1; + } + + .frame-comment:not(:last-child) { + border-bottom: 1px dotted rgba(0, 0, 0, .3); + } + + .frame-comment-context { + font-size: 10px; + font-weight: bold; + color: #86D2B6; + } + +.data-table-container label { + font-size: 16px; + font-weight: bold; + color: #4288CE; + margin: 10px 0; + padding: 10px 0; + + display: block; + margin-bottom: 5px; + padding-bottom: 5px; + border-bottom: 1px dotted rgba(0, 0, 0, .2); +} + .data-table { + width: 100%; + margin: 10px 0; + } + + .data-table tbody { + font: 13px consolas, monospace; + } + + .data-table thead { + display: none; + } + + .data-table tr { + padding: 5px 0; + } + + .data-table td:first-child { + width: 20%; + min-width: 130px; + overflow: hidden; + font-weight: bold; + color: #463C54; + padding-right: 5px; + + } + + .data-table td:last-child { + width: 80%; + -ms-word-break: break-all; + word-break: break-all; + word-break: break-word; + -webkit-hyphens: auto; + -moz-hyphens: auto; + hyphens: auto; + } + + .data-table .empty { + color: rgba(0, 0, 0, .3); + font-style: italic; + } + +.handler { + padding: 10px; + font: 14px monospace; +} + +.handler.active { + color: #BBBBBB; + background: #989898; + font-weight: bold; +} + +/* prettify code style +Uses the Doxy theme as a base */ +pre .str, code .str { color: #BCD42A; } /* string */ +pre .kwd, code .kwd { color: #4bb1b1; font-weight: bold; } /* keyword*/ +pre .com, code .com { color: #888; font-weight: bold; } /* comment */ +pre .typ, code .typ { color: #ef7c61; } /* type */ +pre .lit, code .lit { color: #BCD42A; } /* literal */ +pre .pun, code .pun { color: #fff; font-weight: bold; } /* punctuation */ +pre .pln, code .pln { color: #e9e4e5; } /* plaintext */ +pre .tag, code .tag { color: #4bb1b1; } /* html/xml tag */ +pre .htm, code .htm { color: #dda0dd; } /* html tag */ +pre .xsl, code .xsl { color: #d0a0d0; } /* xslt tag */ +pre .atn, code .atn { color: #ef7c61; font-weight: normal;} /* html/xml attribute name */ +pre .atv, code .atv { color: #bcd42a; } /* html/xml attribute value */ +pre .dec, code .dec { color: #606; } /* decimal */ +pre.prettyprint, code.prettyprint { + font-family: 'Source Code Pro', Monaco, Consolas, "Lucida Console", monospace;; + background: #333; + color: #e9e4e5; +} + pre.prettyprint { + white-space: pre-wrap; + } + + pre.prettyprint a, code.prettyprint a { + text-decoration:none; + } + + .linenums li { + color: #A5A5A5; + } + + .linenums li.current{ + background: rgba(255, 100, 100, .07); + padding-top: 4px; + padding-left: 1px; + } + .linenums li.current.active { + background: rgba(255, 100, 100, .17); + } diff --git a/vendor/filp/whoops/src/Whoops/Resources/pretty-template.php b/vendor/filp/whoops/src/Whoops/Resources/pretty-template.php new file mode 100755 index 0000000..e5ab982 --- /dev/null +++ b/vendor/filp/whoops/src/Whoops/Resources/pretty-template.php @@ -0,0 +1,216 @@ + + + + + + <?php echo $e($v->title) ?> + + + + +
+ +
+ +
+ + + frames as $i => $frame): ?> + +
+
+ frames) - $i - 1) ?>. + getClass() ?: '') ?> + getFunction() ?: '') ?> +
+ + + getFile(true) ?: '<#unknown>') ?>getLine() ?> + +
+ + +
+ +
+ +
+
+

+ name as $i => $nameSection): ?> + name) - 1): ?> + + + + + +

+

+ message) ?> +

+
+
+ + +
+ frames as $i => $frame): ?> + + getLine(); ?> +
+
+ getFile(); ?> + handler->getEditorHref($filePath, (int) $line)): ?> + Open: + + ') ?> + + + ') ?> + +
+ getFileLines($line - 8, 10); + $range = array_map(function($line){ return empty($line) ? ' ' : $line;}, $range); + $start = key($range) + 1; + $code = join("\n", $range); + ?> +
+ + + getComments(); + ?> +
+ $comment): ?> + +
+ + +
+ +
+ +
+ +
+ + +
+
+ tables as $label => $data): ?> +
+ + + + + + + + + + $value): ?> + + + + + +
KeyValue
+ + empty + +
+ +
+ + +
+ + handlers as $i => $handler): ?> +
+ . +
+ +
+ +
+
+ +
+
+ + + + + + diff --git a/vendor/filp/whoops/src/Whoops/Run.php b/vendor/filp/whoops/src/Whoops/Run.php new file mode 100755 index 0000000..dacbf30 --- /dev/null +++ b/vendor/filp/whoops/src/Whoops/Run.php @@ -0,0 +1,382 @@ + + */ + +namespace Whoops; +use Whoops\Handler\HandlerInterface; +use Whoops\Handler\Handler; +use Whoops\Handler\CallbackHandler; +use Whoops\Exception\Inspector; +use Whoops\Exception\ErrorException; +use InvalidArgumentException; +use Exception; + +class Run +{ + const EXCEPTION_HANDLER = "handleException"; + const ERROR_HANDLER = "handleError"; + const SHUTDOWN_HANDLER = "handleShutdown"; + + protected $isRegistered; + protected $allowQuit = true; + protected $sendOutput = true; + protected $sendHttpCode = 500; + + /** + * @var HandlerInterface[] + */ + protected $handlerStack = array(); + + protected $silencedPatterns = array(); + + /** + * Pushes a handler to the end of the stack + * + * @throws InvalidArgumentException If argument is not callable or instance of HandlerInterface + * @param Callable|HandlerInterface $handler + * @return Run + */ + public function pushHandler($handler) + { + if(is_callable($handler)) { + $handler = new CallbackHandler($handler); + } + + if(!$handler instanceof HandlerInterface) { + throw new InvalidArgumentException( + "Argument to " . __METHOD__ . " must be a callable, or instance of" + . "Whoops\\Handler\\HandlerInterface" + ); + } + + $this->handlerStack[] = $handler; + return $this; + } + + /** + * Removes the last handler in the stack and returns it. + * Returns null if there"s nothing else to pop. + * @return null|HandlerInterface + */ + public function popHandler() + { + return array_pop($this->handlerStack); + } + + /** + * Returns an array with all handlers, in the + * order they were added to the stack. + * @return array + */ + public function getHandlers() + { + return $this->handlerStack; + } + + /** + * Clears all handlers in the handlerStack, including + * the default PrettyPage handler. + * @return Run + */ + public function clearHandlers() + { + $this->handlerStack = array(); + return $this; + } + + /** + * @param Exception $exception + * @return Inspector + */ + protected function getInspector(Exception $exception) + { + return new Inspector($exception); + } + + /** + * Registers this instance as an error handler. + * @return Run + */ + public function register() + { + if(!$this->isRegistered) { + // Workaround PHP bug 42098 + // https://bugs.php.net/bug.php?id=42098 + class_exists("\\Whoops\\Exception\\ErrorException"); + class_exists("\\Whoops\\Exception\\FrameCollection"); + class_exists("\\Whoops\\Exception\\Frame"); + class_exists("\\Whoops\\Exception\\Inspector"); + + set_error_handler(array($this, self::ERROR_HANDLER)); + set_exception_handler(array($this, self::EXCEPTION_HANDLER)); + register_shutdown_function(array($this, self::SHUTDOWN_HANDLER)); + + $this->isRegistered = true; + } + + return $this; + } + + /** + * Unregisters all handlers registered by this Whoops\Run instance + * @return Run + */ + public function unregister() + { + if($this->isRegistered) { + restore_exception_handler(); + restore_error_handler(); + + $this->isRegistered = false; + } + + return $this; + } + + /** + * Should Whoops allow Handlers to force the script to quit? + * @param bool|int $exit + * @return bool + */ + public function allowQuit($exit = null) + { + if(func_num_args() == 0) { + return $this->allowQuit; + } + + return $this->allowQuit = (bool) $exit; + } + + /** + * Silence particular errors in particular files + * @param array|string $patterns List or a single regex pattern to match + * @param integer $levels Defaults to E_STRICT | E_DEPRECATED + * @return \Whoops\Run + */ + public function silenceErrorsInPaths($patterns, $levels = 10240) + { + $this->silencedPatterns = array_merge( + $this->silencedPatterns, + array_map( + function ($pattern) use ($levels) { + return array( + "pattern" => $pattern, + "levels" => $levels, + ); + }, + (array) $patterns + ) + ); + return $this; + } + + /* + * Should Whoops send HTTP error code to the browser if possible? + * Whoops will by default send HTTP code 500, but you may wish to + * use 502, 503, or another 5xx family code. + * + * @param bool|int $code + * @return bool + */ + public function sendHttpCode($code = null) + { + if(func_num_args() == 0) { + return $this->sendHttpCode; + } + + if(!$code) { + return $this->sendHttpCode = false; + } + + if($code === true) { + $code = 500; + } + + if ($code < 400 || 600 <= $code) { + throw new InvalidArgumentException( + "Invalid status code '$code', must be 4xx or 5xx" + ); + } + + return $this->sendHttpCode = $code; + } + + /** + * Should Whoops push output directly to the client? + * If this is false, output will be returned by handleException + * @param bool|int $send + * @return bool + */ + public function writeToOutput($send = null) + { + if(func_num_args() == 0) { + return $this->sendOutput; + } + + return $this->sendOutput = (bool) $send; + } + + /** + * Handles an exception, ultimately generating a Whoops error + * page. + * + * @param Exception $exception + * @return string Output generated by handlers + */ + public function handleException(Exception $exception) + { + // Walk the registered handlers in the reverse order + // they were registered, and pass off the exception + $inspector = $this->getInspector($exception); + + // Capture output produced while handling the exception, + // we might want to send it straight away to the client, + // or return it silently. + ob_start(); + + // Just in case there are no handlers: + $handlerResponse = null; + + for($i = count($this->handlerStack) - 1; $i >= 0; $i--) { + $handler = $this->handlerStack[$i]; + + $handler->setRun($this); + $handler->setInspector($inspector); + $handler->setException($exception); + + $handlerResponse = $handler->handle($exception); + + if(in_array($handlerResponse, array(Handler::LAST_HANDLER, Handler::QUIT))) { + // The Handler has handled the exception in some way, and + // wishes to quit execution (Handler::QUIT), or skip any + // other handlers (Handler::LAST_HANDLER). If $this->allowQuit + // is false, Handler::QUIT behaves like Handler::LAST_HANDLER + break; + } + } + + $output = ob_get_clean(); + + // If we're allowed to, send output generated by handlers directly + // to the output, otherwise, and if the script doesn't quit, return + // it so that it may be used by the caller + if($this->writeToOutput()) { + // @todo Might be able to clean this up a bit better + // If we're going to quit execution, cleanup all other output + // buffers before sending our own output: + if($handlerResponse == Handler::QUIT && $this->allowQuit()) { + while (ob_get_level() > 0) ob_end_clean(); + } + + if($this->sendHttpCode() && isset($_SERVER["REQUEST_URI"]) && !headers_sent()) { + $httpCode = $this->sendHttpCode(); + + if (function_exists('http_response_code')) { + http_response_code($httpCode); + } else { + // http_response_code is added in 5.4. + // For compatibility with 5.3 we use the third argument in header call + // First argument must be a real header. + // If it is empty, PHP will ignore the third argument. + // If it is invalid, such as a single space, Apache will handle it well, + // but the PHP development server will hang. + // Setting a full status line would require us to hardcode + // string values for all different status code, and detect the protocol. + // which is an extra error-prone complexity. + header('X-Ignore-This: 1', true, $httpCode); + } + } + + echo $output; + } + + // Handlers are done! Check if we got here because of Handler::QUIT + // ($handlerResponse will be the response from the last queried handler) + // and if so, try to quit execution. + if($handlerResponse == Handler::QUIT && $this->allowQuit()) { + exit; + } + + return $output; + } + + /** + * Converts generic PHP errors to \ErrorException + * instances, before passing them off to be handled. + * + * This method MUST be compatible with set_error_handler. + * + * @param int $level + * @param string $message + * @param string $file + * @param int $line + * + * @return bool + */ + public function handleError($level, $message, $file = null, $line = null) + { + if ($level & error_reporting()) { + foreach ($this->silencedPatterns as $entry) { + $pathMatches = (bool) preg_match($entry["pattern"], $file); + $levelMatches = $level & $entry["levels"]; + if ($pathMatches && $levelMatches) { + // Ignore the error, abort handling + return true; + } + } + + $exception = new ErrorException($message, $level, 0, $file, $line); + if ($this->canThrowExceptions) { + throw $exception; + } else { + $this->handleException($exception); + } + } + } + + /** + * Special case to deal with Fatal errors and the like. + */ + public function handleShutdown() + { + // If we reached this step, we are in shutdown handler. + // An exception thrown in a shutdown handler will not be propagated + // to the exception handler. Pass that information along. + $this->canThrowExceptions = false; + + $error = error_get_last(); + if ($error && $this->isLevelFatal($error['type'])) { + // If there was a fatal error, + // it was not handled in handleError yet. + $this->handleError( + $error['type'], + $error['message'], + $error['file'], + $error['line'] + ); + } + } + + /** + * In certain scenarios, like in shutdown handler, we can not throw exceptions + * @var boolean + */ + private $canThrowExceptions = true; + + private static function isLevelFatal($level) + { + return in_array( + $level, + array( + E_ERROR, + E_PARSE, + E_CORE_ERROR, + E_CORE_WARNING, + E_COMPILE_ERROR, + E_COMPILE_WARNING + ) + ); + } +} diff --git a/vendor/filp/whoops/tests/Whoops/Exception/FrameCollectionTest.php b/vendor/filp/whoops/tests/Whoops/Exception/FrameCollectionTest.php new file mode 100755 index 0000000..136d115 --- /dev/null +++ b/vendor/filp/whoops/tests/Whoops/Exception/FrameCollectionTest.php @@ -0,0 +1,150 @@ + + */ + +namespace Whoops\Exception; +use Whoops\Exception\FrameCollection; +use Whoops\TestCase; +use Mockery as m; + +class FrameCollectionTest extends TestCase +{ + /** + * Stupid little counter for tagging frames + * with a unique but predictable id + * @var int + */ + private $frameIdCounter = 0; + + /** + * @return array + */ + public function getFrameData() + { + $id = ++$this->frameIdCounter; + return array( + 'file' => __DIR__ . '/../../fixtures/frame.lines-test.php', + 'line' => $id, + 'function' => 'test-' . $id, + 'class' => 'MyClass', + 'args' => array(true, 'hello') + ); + } + + /** + * @param int $total + * @return array + */ + public function getFrameDataList($total) + { + $total = max((int) $total, 1); + $self = $this; + $frames = array_map(function() use($self) { + return $self->getFrameData(); + }, range(1, $total)); + + return $frames; + } + + /** + * @param array $frames + * @return Whoops\Exception\FrameCollection + */ + private function getFrameCollectionInstance($frames = null) + { + if($frames === null) { + $frames = $this->getFrameDataList(10); + } + + return new FrameCollection($frames); + } + + /** + * @covers Whoops\Exception\FrameCollection::filter + * @covers Whoops\Exception\FrameCollection::count + */ + public function testFilterFrames() + { + $frames = $this->getFrameCollectionInstance(); + + // Filter out all frames with a line number under 6 + $frames->filter(function($frame) { + return $frame->getLine() <= 5; + }); + + $this->assertCount(5, $frames); + } + + /** + * @covers Whoops\Exception\FrameCollection::map + */ + public function testMapFrames() + { + $frames = $this->getFrameCollectionInstance(); + + // Filter out all frames with a line number under 6 + $frames->map(function($frame) { + $frame->addComment("This is cool", "test"); + return $frame; + }); + + $this->assertCount(10, $frames); + } + + + /** + * @covers Whoops\Exception\FrameCollection::map + * @expectedException UnexpectedValueException + */ + public function testMapFramesEnforceType() + { + $frames = $this->getFrameCollectionInstance(); + + // Filter out all frames with a line number under 6 + $frames->map(function($frame) { + return "bajango"; + }); + } + + /** + * @covers Whoops\Exception\FrameCollection::getArray + */ + public function testGetArray() + { + $frames = $this->getFrameCollectionInstance(); + $frames = $frames->getArray(); + + $this->assertCount(10, $frames); + foreach($frames as $frame) { + $this->assertInstanceOf('Whoops\\Exception\\Frame', $frame); + } + } + + /** + * @covers Whoops\Exception\FrameCollection::getIterator + */ + public function testCollectionIsIterable() + { + $frames = $this->getFrameCollectionInstance(); + foreach($frames as $frame) { + $this->assertInstanceOf('Whoops\\Exception\\Frame', $frame); + } + } + + /** + * @covers Whoops\Exception\FrameCollection::serialize + * @covers Whoops\Exception\FrameCollection::unserialize + */ + public function testCollectionIsSerializable() + { + $frames = $this->getFrameCollectionInstance(); + $serializedFrames = serialize($frames); + $newFrames = unserialize($serializedFrames); + + foreach($newFrames as $frame) { + $this->assertInstanceOf('Whoops\\Exception\\Frame', $frame); + } + } +} diff --git a/vendor/filp/whoops/tests/Whoops/Exception/FrameTest.php b/vendor/filp/whoops/tests/Whoops/Exception/FrameTest.php new file mode 100755 index 0000000..a4558be --- /dev/null +++ b/vendor/filp/whoops/tests/Whoops/Exception/FrameTest.php @@ -0,0 +1,209 @@ + + */ + +namespace Whoops\Exception; +use Whoops\Exception\Frame; +use Whoops\TestCase; +use Mockery as m; + +class FrameTest extends TestCase +{ + /** + * @return array + */ + private function getFrameData() + { + return array( + 'file' => __DIR__ . '/../../fixtures/frame.lines-test.php', + 'line' => 0, + 'function' => 'test', + 'class' => 'MyClass', + 'args' => array(true, 'hello') + ); + } + + /** + * @param array $data + * @return Frame + */ + private function getFrameInstance($data = null) + { + if($data === null) { + $data = $this->getFrameData(); + } + + return new Frame($data); + } + + /** + * @covers Whoops\Exception\Frame::getFile + */ + public function testGetFile() + { + $data = $this->getFrameData(); + $frame = $this->getFrameInstance($data); + + $this->assertEquals($frame->getFile(), $data['file']); + } + + /** + * @covers Whoops\Exception\Frame::getLine + */ + public function testGetLine() + { + $data = $this->getFrameData(); + $frame = $this->getFrameInstance($data); + + $this->assertEquals($frame->getLine(), $data['line']); + } + + /** + * @covers Whoops\Exception\Frame::getClass + */ + public function testGetClass() + { + $data = $this->getFrameData(); + $frame = $this->getFrameInstance($data); + + $this->assertEquals($frame->getClass(), $data['class']); + } + + /** + * @covers Whoops\Exception\Frame::getFunction + */ + public function testGetFunction() + { + $data = $this->getFrameData(); + $frame = $this->getFrameInstance($data); + + $this->assertEquals($frame->getFunction(), $data['function']); + } + + /** + * @covers Whoops\Exception\Frame::getArgs + */ + public function testGetArgs() + { + $data = $this->getFrameData(); + $frame = $this->getFrameInstance($data); + + $this->assertEquals($frame->getArgs(), $data['args']); + } + + /** + * @covers Whoops\Exception\Frame::getFileContents + */ + public function testGetFileContents() + { + $data = $this->getFrameData(); + $frame = $this->getFrameInstance($data); + + $this->assertEquals($frame->getFileContents(), file_get_contents($data['file'])); + } + + /** + * @covers Whoops\Exception\Frame::getFileLines + */ + public function testGetFileLines() + { + $data = $this->getFrameData(); + $frame = $this->getFrameInstance($data); + + $lines = explode("\n", $frame->getFileContents()); + $this->assertEquals($frame->getFileLines(), $lines); + } + + /** + * @covers Whoops\Exception\Frame::getFileLines + */ + public function testGetFileLinesRange() + { + $data = $this->getFrameData(); + $frame = $this->getFrameInstance($data); + + $lines = $frame->getFileLines(0, 3); + + $this->assertEquals($lines[0], 'assertEquals($lines[1], '// Line 2'); + $this->assertEquals($lines[2], '// Line 3'); + } + + /** + * @covers Whoops\Exception\Frame::addComment + * @covers Whoops\Exception\Frame::getComments + */ + public function testGetComments() + { + $frame = $this->getFrameInstance(); + $testComments = array( + 'Dang, yo!', + 'Errthangs broken!', + 'Dayumm!' + ); + + $frame->addComment($testComments[0]); + $frame->addComment($testComments[1]); + $frame->addComment($testComments[2]); + + $comments = $frame->getComments(); + + $this->assertCount(3, $comments); + + $this->assertEquals($comments[0]['comment'], $testComments[0]); + $this->assertEquals($comments[1]['comment'], $testComments[1]); + $this->assertEquals($comments[2]['comment'], $testComments[2]); + } + + /** + * @covers Whoops\Exception\Frame::addComment + * @covers Whoops\Exception\Frame::getComments + */ + public function testGetFilteredComments() + { + $frame = $this->getFrameInstance(); + $testComments = array( + array('Dang, yo!', 'test'), + array('Errthangs broken!', 'test'), + 'Dayumm!' + ); + + $frame->addComment($testComments[0][0], $testComments[0][1]); + $frame->addComment($testComments[1][0], $testComments[1][1]); + $frame->addComment($testComments[2][0], $testComments[2][1]); + + $comments = $frame->getComments('test'); + + $this->assertCount(2, $comments); + $this->assertEquals($comments[0]['comment'], $testComments[0][0]); + $this->assertEquals($comments[1]['comment'], $testComments[1][0]); + } + + /** + * @covers Whoops\Exception\Frame::serialize + * @covers Whoops\Exception\Frame::unserialize + */ + public function testFrameIsSerializable() + { + $data = $this->getFrameData(); + $frame = $this->getFrameInstance(); + $commentText = "Gee I hope this works"; + $commentContext = "test"; + + $frame->addComment($commentText, $commentContext); + + $serializedFrame = serialize($frame); + $newFrame = unserialize($serializedFrame); + + $this->assertInstanceOf('Whoops\\Exception\\Frame', $newFrame); + $this->assertEquals($newFrame->getFile(), $data['file']); + $this->assertEquals($newFrame->getLine(), $data['line']); + + $comments = $newFrame->getComments(); + $this->assertCount(1, $comments); + $this->assertEquals($comments[0]["comment"], $commentText); + $this->assertEquals($comments[0]["context"], $commentContext); + } +} diff --git a/vendor/filp/whoops/tests/Whoops/Exception/InspectorTest.php b/vendor/filp/whoops/tests/Whoops/Exception/InspectorTest.php new file mode 100755 index 0000000..7c78740 --- /dev/null +++ b/vendor/filp/whoops/tests/Whoops/Exception/InspectorTest.php @@ -0,0 +1,67 @@ + + */ + +namespace Whoops\Exception; +use Whoops\Exception\Inspector; +use Whoops\TestCase; +use RuntimeException; +use Exception; +use Mockery as m; + +class InspectorTest extends TestCase +{ + /** + * @param string $message + * @return Exception + */ + protected function getException($message = null) + { + return m::mock('Exception', array($message)); + } + + /** + * @param Exception $exception|null + * @return Whoops\Exception\Inspector + */ + protected function getInspectorInstance(Exception $exception = null) + { + return new Inspector($exception); + } + + /** + * @covers Whoops\Exception\Inspector::getExceptionName + */ + public function testReturnsCorrectExceptionName() + { + $exception = $this->getException(); + $inspector = $this->getInspectorInstance($exception); + + $this->assertEquals(get_class($exception), $inspector->getExceptionName()); + } + + /** + * @covers Whoops\Exception\Inspector::__construct + * @covers Whoops\Exception\Inspector::getException + */ + public function testExceptionIsStoredAndReturned() + { + $exception = $this->getException(); + $inspector = $this->getInspectorInstance($exception); + + $this->assertSame($exception, $inspector->getException()); + } + + /** + * @covers Whoops\Exception\Inspector::getFrames + */ + public function testGetFramesReturnsCollection() + { + $exception = $this->getException(); + $inspector = $this->getInspectorInstance($exception); + + $this->assertInstanceOf('Whoops\\Exception\\FrameCollection', $inspector->getFrames()); + } +} diff --git a/vendor/filp/whoops/tests/Whoops/Handler/JsonResponseHandlerTest.php b/vendor/filp/whoops/tests/Whoops/Handler/JsonResponseHandlerTest.php new file mode 100755 index 0000000..548d4f7 --- /dev/null +++ b/vendor/filp/whoops/tests/Whoops/Handler/JsonResponseHandlerTest.php @@ -0,0 +1,96 @@ + + */ + +namespace Whoops\Handler; +use Whoops\TestCase; +use Whoops\Handler\JsonResponseHandler; +use RuntimeException; + +class JsonResponseHandlerTest extends TestCase +{ + /** + * @return Whoops\Handler\JsonResponseHandler + */ + private function getHandler() + { + return new JsonResponseHandler; + } + + /** + * @return RuntimeException + */ + public function getException($message = 'test message') + { + return new RuntimeException($message); + } + + /** + * @param bool $withTrace + * @return array + */ + private function getJsonResponseFromHandler($withTrace = false) + { + $handler = $this->getHandler(); + $handler->addTraceToOutput($withTrace); + + $run = $this->getRunInstance(); + $run->pushHandler($handler); + $run->register(); + + $exception = $this->getException(); + ob_start(); + $run->handleException($exception); + $json = json_decode(ob_get_clean(), true); + + // Check that the json response is parse-able: + $this->assertEquals(json_last_error(), JSON_ERROR_NONE); + + return $json; + } + + /** + * @covers Whoops\Handler\JsonResponseHandler::addTraceToOutput + * @covers Whoops\Handler\JsonResponseHandler::handle + */ + public function testReturnsWithoutFrames() + { + $json = $this->getJsonResponseFromHandler($withTrace = false); + + // Check that the response has the expected keys: + $this->assertArrayHasKey('error', $json); + $this->assertArrayHasKey('type', $json['error']); + $this->assertArrayHasKey('file', $json['error']); + $this->assertArrayHasKey('line', $json['error']); + + // Check the field values: + $this->assertEquals($json['error']['file'], __FILE__); + $this->assertEquals($json['error']['message'], 'test message'); + $this->assertEquals($json['error']['type'], get_class($this->getException())); + + // Check that the trace is NOT returned: + $this->assertArrayNotHasKey('trace', $json['error']); + } + + /** + * @covers Whoops\Handler\JsonResponseHandler::addTraceToOutput + * @covers Whoops\Handler\JsonResponseHandler::handle + */ + public function testReturnsWithFrames() + { + $json = $this->getJsonResponseFromHandler($withTrace = true); + + // Check that the trace is returned: + $this->assertArrayHasKey('trace', $json['error']); + + // Check that a random frame has the expected fields + $traceFrame = reset($json['error']['trace']); + $this->assertArrayHasKey('file', $traceFrame); + $this->assertArrayHasKey('line', $traceFrame); + $this->assertArrayHasKey('function', $traceFrame); + $this->assertArrayHasKey('class', $traceFrame); + $this->assertArrayHasKey('args', $traceFrame); + } +} diff --git a/vendor/filp/whoops/tests/Whoops/Handler/PrettyPageHandlerTest.php b/vendor/filp/whoops/tests/Whoops/Handler/PrettyPageHandlerTest.php new file mode 100755 index 0000000..0df881b --- /dev/null +++ b/vendor/filp/whoops/tests/Whoops/Handler/PrettyPageHandlerTest.php @@ -0,0 +1,267 @@ + + */ + +namespace Whoops\Handler; +use Whoops\TestCase; +use Whoops\Handler\PrettyPageHandler; +use RuntimeException; +use InvalidArgumentException; + +class PrettyPageHandlerTest extends TestCase +{ + /** + * @return Whoops\Handler\JsonResponseHandler + */ + private function getHandler() + { + return new PrettyPageHandler; + } + + /** + * @return RuntimeException + */ + public function getException() + { + return new RuntimeException; + } + + /** + * Test that PrettyPageHandle handles the template without + * any errors. + * @covers Whoops\Handler\PrettyPageHandler::handle + */ + public function testHandleWithoutErrors() + { + $run = $this->getRunInstance(); + $handler = $this->getHandler(); + + $run->pushHandler($handler); + + ob_start(); + $run->handleException($this->getException()); + ob_get_clean(); + + // Reached the end without errors + $this->assertTrue(true); + } + + /** + * @covers Whoops\Handler\PrettyPageHandler::setPageTitle + * @covers Whoops\Handler\PrettyPageHandler::getPageTitle + */ + public function testGetSetPageTitle() + { + $title = 'My Cool Error Handler'; + $handler = $this->getHandler(); + $handler->setPageTitle($title); + + $this->assertEquals($title, $handler->getPagetitle()); + } + + /** + * @covers Whoops\Handler\PrettyPageHandler::setResourcesPath + * @covers Whoops\Handler\PrettyPageHandler::getResourcesPath + */ + public function testGetSetResourcesPath() + { + $path = __DIR__; // guaranteed to be valid! + $handler = $this->getHandler(); + + $handler->setResourcesPath($path); + $this->assertEquals($path, $handler->getResourcesPath()); + } + + /** + * @covers Whoops\Handler\PrettyPageHandler::setResourcesPath + * @expectedException InvalidArgumentException + */ + public function testSetInvalidResourcesPath() + { + $path = __DIR__ . '/ZIMBABWE'; // guaranteed to be invalid! + $this->getHandler()->setResourcesPath($path); + } + + /** + * @covers Whoops\Handler\PrettyPageHandler::getDataTables + * @covers Whoops\Handler\PrettyPageHandler::addDataTable + */ + public function testGetSetDataTables() + { + $handler = $this->getHandler(); + + // should have no tables by default: + $this->assertEmpty($handler->getDataTables()); + + $tableOne = array( + 'ice' => 'cream', + 'ice-ice' => 'baby' + ); + + $tableTwo = array( + 'dolan' =>'pls', + 'time' => time() + ); + + $handler->addDataTable('table 1', $tableOne); + $handler->addDataTable('table 2', $tableTwo); + + // should contain both tables: + $tables = $handler->getDataTables(); + $this->assertCount(2, $tables); + + $this->assertEquals($tableOne, $tables['table 1']); + $this->assertEquals($tableTwo, $tables['table 2']); + + // should contain only table 1 + $this->assertEquals($tableOne, $handler->getDataTables('table 1')); + + // should return an empty table: + $this->assertEmpty($handler->getDataTables('ZIMBABWE!')); + } + + /** + * @covers Whoops\Handler\PrettyPageHandler::getDataTables + * @covers Whoops\Handler\PrettyPageHandler::addDataTableCallback + */ + public function testSetCallbackDataTables() + { + $handler = $this->getHandler(); + + $this->assertEmpty($handler->getDataTables()); + $table1 = function() { + return array( + 'hammer' => 'time', + 'foo' => 'bar', + ); + }; + $expected1 = array('hammer' => 'time', 'foo' => 'bar'); + + $table2 = function() use ($expected1) { + return array( + 'another' => 'table', + 'this' => $expected1, + ); + }; + $expected2 = array('another' => 'table', 'this' => $expected1); + + $table3 = create_function('', 'return array("oh my" => "how times have changed!");'); + $expected3 = array('oh my' => 'how times have changed!'); + + // Sanity check, make sure expected values really are correct. + $this->assertSame($expected1, $table1()); + $this->assertSame($expected2, $table2()); + $this->assertSame($expected3, $table3()); + + $handler->addDataTableCallback('table1', $table1); + $handler->addDataTableCallback('table2', $table2); + $handler->addDataTableCallback('table3', $table3); + + $tables = $handler->getDataTables(); + $this->assertCount(3, $tables); + + // Supplied callable is wrapped in a closure + $this->assertInstanceOf('Closure', $tables['table1']); + $this->assertInstanceOf('Closure', $tables['table2']); + $this->assertInstanceOf('Closure', $tables['table3']); + + // Run each wrapped callable and check results against expected output. + $this->assertEquals($expected1, $tables['table1']()); + $this->assertEquals($expected2, $tables['table2']()); + $this->assertEquals($expected3, $tables['table3']()); + + $this->assertSame($tables['table1'], $handler->getDataTables('table1')); + $this->assertSame($expected1, call_user_func($handler->getDataTables('table1'))); + } + + /** + * @covers Whoops\Handler\PrettyPageHandler::setEditor + * @covers Whoops\Handler\PrettyPageHandler::getEditorHref + */ + public function testSetEditorSimple() + { + $handler = $this->getHandler(); + $handler->setEditor('sublime'); + + $this->assertEquals( + $handler->getEditorHref('/foo/bar.php', 10), + 'subl://open?url=file://%2Ffoo%2Fbar.php&line=10' + ); + + $this->assertEquals( + $handler->getEditorHref('/foo/with space?.php', 2324), + 'subl://open?url=file://%2Ffoo%2Fwith%20space%3F.php&line=2324' + ); + + $this->assertEquals( + $handler->getEditorHref('/foo/bar/with-dash.php', 0), + 'subl://open?url=file://%2Ffoo%2Fbar%2Fwith-dash.php&line=0' + ); + } + + /** + * @covers Whoops\Handler\PrettyPageHandler::setEditor + * @covers Whoops\Handler\PrettyPageHandler::getEditorHref + */ + public function testSetEditorCallable() + { + $handler = $this->getHandler(); + $handler->setEditor(function($file, $line) { + $file = rawurlencode($file); + $line = rawurlencode($line); + return "http://google.com/search/?q=$file:$line"; + }); + + $this->assertEquals( + $handler->getEditorHref('/foo/bar.php', 10), + 'http://google.com/search/?q=%2Ffoo%2Fbar.php:10' + ); + } + + /** + * @covers Whoops\Handler\PrettyPageHandler::setEditor + * @covers Whoops\Handler\PrettyPageHandler::addEditor + * @covers Whoops\Handler\PrettyPageHandler::getEditorHref + */ + public function testAddEditor() + { + $handler = $this->getHandler(); + $handler->addEditor('test-editor', function($file, $line) { + return "cool beans $file:$line"; + }); + + $handler->setEditor('test-editor'); + + $this->assertEquals( + $handler->getEditorHref('hello', 20), + 'cool beans hello:20' + ); + } + + public function testEditorXdebug() + { + $originalValue = ini_get('xdebug.file_link_format'); + + ini_set('xdebug.file_link_format', '%f:%l'); + + $handler = $this->getHandler(); + $handler->setEditor('xdebug'); + + $this->assertEquals( + '/foo/bar.php:10', + $handler->getEditorHref('/foo/bar.php', 10) + ); + + ini_set('xdebug.file_link_format', 'subl://open?url=%f&line=%l'); + + // xdebug doesn't do any URL encoded, matching that behaviour. + $this->assertEquals( + 'subl://open?url=/foo/with space?.php&line=2324', + $handler->getEditorHref('/foo/with space?.php', 2324) + ); + + ini_set('xdebug.file_link_format', $originalValue); + } +} diff --git a/vendor/filp/whoops/tests/Whoops/Handler/XmlResponseHandlerTest.php b/vendor/filp/whoops/tests/Whoops/Handler/XmlResponseHandlerTest.php new file mode 100755 index 0000000..91dec35 --- /dev/null +++ b/vendor/filp/whoops/tests/Whoops/Handler/XmlResponseHandlerTest.php @@ -0,0 +1,82 @@ +getRunInstance(); + $run->pushHandler($handler); + $run->register(); + + ob_start(); + $run->handleException($this->getException()); + $data = ob_get_clean(); + + $this->assertTrue($this->isValidXml($data)); + + return simplexml_load_string($data); + } + + /** + * @depends testSimpleValid + */ + public function testSimpleValidFile(\SimpleXMLElement $xml) + { + $this->checkField($xml, 'file', $this->getException()->getFile()); + } + + /** + * @depends testSimpleValid + */ + public function testSimpleValidLine(\SimpleXMLElement $xml) + { + $this->checkField($xml, 'line', (string) $this->getException()->getLine()); + } + + /** + * @depends testSimpleValid + */ + public function testSimpleValidType(\SimpleXMLElement $xml) + { + $this->checkField($xml, 'type', get_class($this->getException())); + } + + + /** + * Helper for testSimpleValid* + */ + private function checkField(\SimpleXMLElement $xml, $field, $value) + { + $list = $xml->xpath('/root/error/'.$field); + $this->assertArrayHasKey(0, $list); + $this->assertSame($value, (string) $list[0]); + } + + private function getException() + { + return new RuntimeException; + } + + /** + * See if passed string is a valid XML document + * @param string $data + * @return boolean + */ + private function isValidXml($data) + { + $prev = libxml_use_internal_errors(true); + $xml = simplexml_load_string($data); + libxml_use_internal_errors($prev); + return $xml !== false; + } +} diff --git a/vendor/filp/whoops/tests/Whoops/RunTest.php b/vendor/filp/whoops/tests/Whoops/RunTest.php new file mode 100755 index 0000000..54bde25 --- /dev/null +++ b/vendor/filp/whoops/tests/Whoops/RunTest.php @@ -0,0 +1,406 @@ + + */ + +namespace Whoops; +use Whoops\TestCase; +use Whoops\Run; +use Whoops\Handler\Handler; +use ArrayObject; +use Mockery as m; +use InvalidArgumentException; +use RuntimeException; +use Exception; + +class RunTest extends TestCase +{ + + /** + * @param string $message + * @return Exception + */ + protected function getException($message = null) + { + return m::mock('Exception', array($message)); + } + + /** + * @return Handler + */ + protected function getHandler() + { + return m::mock('Whoops\\Handler\\Handler') + ->shouldReceive('setRun') + ->andReturn(null) + ->mock() + + ->shouldReceive('setInspector') + ->andReturn(null) + ->mock() + + ->shouldReceive('setException') + ->andReturn(null) + ->mock() + ; + } + + /** + * @covers Whoops\Run::clearHandlers + */ + public function testClearHandlers() + { + $run = $this->getRunInstance(); + $run->clearHandlers(); + + $handlers = $run->getHandlers(); + + $this->assertEmpty($handlers); + } + + /** + * @covers Whoops\Run::pushHandler + */ + public function testPushHandler() + { + $run = $this->getRunInstance(); + $run->clearHandlers(); + + $handlerOne = $this->getHandler(); + $handlerTwo = $this->getHandler(); + + $run->pushHandler($handlerOne); + $run->pushHandler($handlerTwo); + + $handlers = $run->getHandlers(); + + $this->assertCount(2, $handlers); + $this->assertContains($handlerOne, $handlers); + $this->assertContains($handlerTwo, $handlers); + } + + /** + * @expectedException InvalidArgumentException + * @covers Whoops\Run::pushHandler + */ + public function testPushInvalidHandler() + { + $run = $this->getRunInstance(); + $run->pushHandler($banana = 'actually turnip'); + } + + /** + * @covers Whoops\Run::pushHandler + */ + public function testPushClosureBecomesHandler() + { + $run = $this->getRunInstance(); + $run->pushHandler(function() {}); + $this->assertInstanceOf('Whoops\\Handler\\CallbackHandler', $run->popHandler()); + } + + /** + * @covers Whoops\Run::popHandler + * @covers Whoops\Run::getHandlers + */ + public function testPopHandler() + { + $run = $this->getRunInstance(); + + $handlerOne = $this->getHandler(); + $handlerTwo = $this->getHandler(); + $handlerThree = $this->getHandler(); + + $run->pushHandler($handlerOne); + $run->pushHandler($handlerTwo); + $run->pushHandler($handlerThree); + + $this->assertSame($handlerThree, $run->popHandler()); + $this->assertSame($handlerTwo, $run->popHandler()); + $this->assertSame($handlerOne, $run->popHandler()); + + // Should return null if there's nothing else in + // the stack + $this->assertNull($run->popHandler()); + + // Should be empty since we popped everything off + // the stack: + $this->assertEmpty($run->getHandlers()); + } + + /** + * @covers Whoops\Run::register + */ + public function testRegisterHandler() + { + // It is impossible to test the Run::register method using phpunit, + // as given how every test is always inside a giant try/catch block, + // any thrown exception will never hit a global exception handler. + // On the other hand, there is not much need in testing + // a call to a native PHP function. + $this->assertTrue(true); + } + + /** + * @covers Whoops\Run::unregister + * @expectedException Exception + */ + public function testUnregisterHandler() + { + $run = $this->getRunInstance(); + $run->register(); + + $handler = $this->getHandler(); + $run->pushHandler($handler); + + $run->unregister(); + throw $this->getException("I'm not supposed to be caught!"); + } + + /** + * @covers Whoops\Run::pushHandler + * @covers Whoops\Run::getHandlers + */ + public function testHandlerHoldsOrder() + { + $run = $this->getRunInstance(); + + $handlerOne = $this->getHandler(); + $handlerTwo = $this->getHandler(); + $handlerThree = $this->getHandler(); + $handlerFour = $this->getHandler(); + + $run->pushHandler($handlerOne); + $run->pushHandler($handlerTwo); + $run->pushHandler($handlerThree); + $run->pushHandler($handlerFour); + + $handlers = $run->getHandlers(); + + $this->assertSame($handlers[0], $handlerOne); + $this->assertSame($handlers[1], $handlerTwo); + $this->assertSame($handlers[2], $handlerThree); + $this->assertSame($handlers[3], $handlerFour); + } + + /** + * @todo possibly split this up a bit and move + * some of this test to Handler unit tests? + * @covers Whoops\Run::handleException + */ + public function testHandlersGonnaHandle() + { + $run = $this->getRunInstance(); + $exception = $this->getException(); + $order = new ArrayObject; + + $handlerOne = $this->getHandler(); + $handlerTwo = $this->getHandler(); + $handlerThree = $this->getHandler(); + + $handlerOne->shouldReceive('handle') + ->andReturnUsing(function() use($order) { $order[] = 1; }); + $handlerTwo->shouldReceive('handle') + ->andReturnUsing(function() use($order) { $order[] = 2; }); + $handlerThree->shouldReceive('handle') + ->andReturnUsing(function() use($order) { $order[] = 3; }); + + $run->pushHandler($handlerOne); + $run->pushHandler($handlerTwo); + $run->pushHandler($handlerThree); + + // Get an exception to be handled, and verify that the handlers + // are given the handler, and in the inverse order they were + // registered. + $run->handleException($exception); + $this->assertEquals((array) $order, array(3, 2, 1)); + } + + /** + * @covers Whoops\Run::handleException + */ + public function testLastHandler() + { + $run = $this->getRunInstance(); + + $handlerOne = $this->getHandler(); + $handlerTwo = $this->getHandler(); + + $run->pushHandler($handlerOne); + $run->pushHandler($handlerTwo); + + $test = $this; + $handlerOne + ->shouldReceive('handle') + ->andReturnUsing(function () use($test) { + $test->fail('$handlerOne should not be called'); + }) + ; + + $handlerTwo + ->shouldReceive('handle') + ->andReturn(Handler::LAST_HANDLER) + ; + + $run->handleException($this->getException()); + + // Reached the end without errors + $this->assertTrue(true); + } + + /** + * Test error suppression using @ operator. + */ + public function testErrorSuppression() + { + $run = $this->getRunInstance(); + $run->register(); + + $handler = $this->getHandler(); + $run->pushHandler($handler); + + $test = $this; + $handler + ->shouldReceive('handle') + ->andReturnUsing(function () use($test) { + $test->fail('$handler should not be called, error not suppressed'); + }) + ; + + @trigger_error("Test error suppression"); + + // Reached the end without errors + $this->assertTrue(true); + } + + public function testErrorCatching() + { + $run = $this->getRunInstance(); + $run->register(); + + $handler = $this->getHandler(); + $run->pushHandler($handler); + + $test = $this; + $handler + ->shouldReceive('handle') + ->andReturnUsing(function () use($test) { + $test->fail('$handler should not be called error should be caught'); + }) + ; + + try { + trigger_error(E_USER_NOTICE, 'foo'); + $this->fail('Should not continue after error thrown'); + } catch (\ErrorException $e) { + // Do nothing + $this->assertTrue(true); + return; + } + $this->fail('Should not continue here, should have been caught.'); + } + + /** + * Test to make sure that error_reporting is respected. + */ + public function testErrorReporting() + { + $run = $this->getRunInstance(); + $run->register(); + + $handler = $this->getHandler(); + $run->pushHandler($handler); + + $test = $this; + $handler + ->shouldReceive('handle') + ->andReturnUsing(function () use($test) { + $test->fail('$handler should not be called, error_reporting not respected'); + }) + ; + + $oldLevel = error_reporting(E_ALL ^ E_USER_NOTICE); + trigger_error("Test error reporting", E_USER_NOTICE); + error_reporting($oldLevel); + + // Reached the end without errors + $this->assertTrue(true); + } + + /** + * @covers Whoops\Run::silenceErrorsInPaths + */ + public function testSilenceErrorsInPaths() + { + $run = $this->getRunInstance(); + $run->register(); + + $handler = $this->getHandler(); + $run->pushHandler($handler); + + $test = $this; + $handler + ->shouldReceive('handle') + ->andReturnUsing(function () use($test) { + $test->fail('$handler should not be called, silenceErrorsInPaths not respected'); + }) + ; + + $run->silenceErrorsInPaths('@^'.preg_quote(__FILE__).'$@', E_USER_NOTICE); + trigger_error('Test', E_USER_NOTICE); + $this->assertTrue(true); + } + + /** + * @covers Whoops\Run::handleException + * @covers Whoops\Run::writeToOutput + */ + public function testOutputIsSent() + { + $run = $this->getRunInstance(); + $run->pushHandler(function() { + echo "hello there"; + }); + + ob_start(); + $run->handleException(new RuntimeException); + $this->assertEquals("hello there", ob_get_clean()); + } + + /** + * @covers Whoops\Run::handleException + * @covers Whoops\Run::writeToOutput + */ + public function testOutputIsNotSent() + { + $run = $this->getRunInstance(); + $run->writeToOutput(false); + $run->pushHandler(function() { + echo "hello there"; + }); + + ob_start(); + $this->assertEquals("hello there", $run->handleException(new RuntimeException)); + $this->assertEquals("", ob_get_clean()); + } + + /** + * @covers Whoops\Run::sendHttpCode + */ + public function testSendHttpCode() + { + $run = $this->getRunInstance(); + $run->sendHttpCode(true); + $this->assertEquals(500, $run->sendHttpCode()); + } + + /** + * @covers Whoops\Run::sendHttpCode + * @expectedException InvalidArgumentException + */ + public function testSendHttpCodeWrongCode() + { + $this->getRunInstance()->sendHttpCode(1337); + } +} diff --git a/vendor/filp/whoops/tests/Whoops/TestCase.php b/vendor/filp/whoops/tests/Whoops/TestCase.php new file mode 100755 index 0000000..6722569 --- /dev/null +++ b/vendor/filp/whoops/tests/Whoops/TestCase.php @@ -0,0 +1,22 @@ + + */ + +namespace Whoops; +use Whoops\Run; + +class TestCase extends \PHPUnit_Framework_TestCase +{ + /** + * @return Run + */ + protected function getRunInstance() + { + $run = new Run; + $run->allowQuit(false); + + return $run; + } +} diff --git a/vendor/filp/whoops/tests/bootstrap.php b/vendor/filp/whoops/tests/bootstrap.php new file mode 100755 index 0000000..d88d772 --- /dev/null +++ b/vendor/filp/whoops/tests/bootstrap.php @@ -0,0 +1,11 @@ + + * + * Bootstraper for PHPUnit tests. + */ +error_reporting(E_ALL | E_STRICT); +$_ENV['whoops-test'] = true; +$loader = require_once __DIR__ . '/../vendor/autoload.php'; +$loader->add('Whoops\\', __DIR__); diff --git a/vendor/filp/whoops/tests/fixtures/frame.lines-test.php b/vendor/filp/whoops/tests/fixtures/frame.lines-test.php new file mode 100755 index 0000000..687a052 --- /dev/null +++ b/vendor/filp/whoops/tests/fixtures/frame.lines-test.php @@ -0,0 +1,10 @@ += 5.3.7` OR a version that has the `$2y` fix backported into it (such as Debian provides). + +The runtime checks have been removed due to this version issue. To see if password_compat is available for your system, run the included `version-test.php`. If it outputs "Pass", you can safely use the library. If not, you cannot. + +If you attempt to use password-compat on an unsupported version, attempts to create or verify hashes will return `false`. You have been warned! + +The reason for this is that PHP prior to 5.3.7 contains a security issue with its BCRYPT implementation. Therefore, it's highly recommended that you upgrade to a newer version of PHP prior to using this layer. + +Installation +============ + +To install, simply `require` the `password.php` file under `lib`. + +You can also install it via `Composer` by using the [Packagist archive](http://packagist.org/packages/ircmaxell/password-compat). + +Usage +===== + +**Creating Password Hashes** + +To create a password hash from a password, simply use the `password_hash` function. + + $hash = password_hash($password, PASSWORD_BCRYPT); + +Note that the algorithm that we chose is `PASSWORD_BCRYPT`. That's the current strongest algorithm supported. This is the `BCRYPT` crypt algorithm. It produces a 60 character hash as the result. + +`BCRYPT` also allows for you to define a `cost` parameter in the options array. This allows for you to change the CPU cost of the algorithm: + + $hash = password_hash($password, PASSWORD_BCRYPT, ["cost" => 10]); + +That's the same as the default. The cost can range from `4` to `31`. I would suggest that you use the highest cost that you can, while keeping response time reasonable (I target between 0.1 and 0.5 seconds for a hash, depending on use-case). + +Another algorithm name is supported: + + PASSWORD_DEFAULT + +This will use the strongest algorithm available to PHP at the current time. Presently, this is the same as specifying `PASSWORD_BCRYPT`. But in future versions of PHP, it may be updated to use a stronger algorithm if one is introduced. It can also be changed if a problem is identified with the BCRYPT algorithm. Note that if you use this option, you are **strongly** encouraged to store it in a `VARCHAR(255)` column to avoid truncation issues if a future algorithm increases the length of the generated hash. + +It is very important that you should check the return value of `password_hash` prior to storing it, because a `false` may be returned if it encountered an error. + +**Verifying Password Hashes** + +To verify a hash created by `password_hash`, simply call: + + if (password_verify($password, $hash)) { + /* Valid */ + } else { + /* Invalid */ + } + +That's all there is to it. + +**Rehashing Passwords** + +From time to time you may update your hashing parameters (algorithm, cost, etc). So a function to determine if rehashing is necessary is available: + + if (password_verify($password, $hash)) { + if (password_needs_rehash($hash, $algorithm, $options)) { + $hash = password_hash($password, $algorithm, $options); + /* Store new hash in db */ + } + } diff --git a/vendor/ircmaxell/password-compat/composer.json b/vendor/ircmaxell/password-compat/composer.json new file mode 100755 index 0000000..e0d4f14 --- /dev/null +++ b/vendor/ircmaxell/password-compat/composer.json @@ -0,0 +1,18 @@ +{ + "name": "ircmaxell/password-compat", + "description": "A compatibility library for the proposed simplified password hashing algorithm: https://wiki.php.net/rfc/password_hash", + "version": "1.0.3", + "keywords": ["password", "hashing"], + "homepage": "https://github.com/ircmaxell/password_compat", + "license": "MIT", + "authors": [ + { + "name": "Anthony Ferrara", + "email": "ircmaxell@php.net", + "homepage": "http://blog.ircmaxell.com" + } + ], + "autoload": { + "files": ["lib/password.php"] + } +} \ No newline at end of file diff --git a/vendor/ircmaxell/password-compat/lib/password.php b/vendor/ircmaxell/password-compat/lib/password.php new file mode 100755 index 0000000..4d0e8b7 --- /dev/null +++ b/vendor/ircmaxell/password-compat/lib/password.php @@ -0,0 +1,222 @@ + + * @license http://www.opensource.org/licenses/mit-license.html MIT License + * @copyright 2012 The Authors + */ + +if (!defined('PASSWORD_BCRYPT')) { + + define('PASSWORD_BCRYPT', 1); + define('PASSWORD_DEFAULT', PASSWORD_BCRYPT); + + /** + * Hash the password using the specified algorithm + * + * @param string $password The password to hash + * @param int $algo The algorithm to use (Defined by PASSWORD_* constants) + * @param array $options The options for the algorithm to use + * + * @return string|false The hashed password, or false on error. + */ + function password_hash($password, $algo, array $options = array()) { + if (!function_exists('crypt')) { + trigger_error("Crypt must be loaded for password_hash to function", E_USER_WARNING); + return null; + } + if (!is_string($password)) { + trigger_error("password_hash(): Password must be a string", E_USER_WARNING); + return null; + } + if (!is_int($algo)) { + trigger_error("password_hash() expects parameter 2 to be long, " . gettype($algo) . " given", E_USER_WARNING); + return null; + } + switch ($algo) { + case PASSWORD_BCRYPT: + // Note that this is a C constant, but not exposed to PHP, so we don't define it here. + $cost = 10; + if (isset($options['cost'])) { + $cost = $options['cost']; + if ($cost < 4 || $cost > 31) { + trigger_error(sprintf("password_hash(): Invalid bcrypt cost parameter specified: %d", $cost), E_USER_WARNING); + return null; + } + } + // The length of salt to generate + $raw_salt_len = 16; + // The length required in the final serialization + $required_salt_len = 22; + $hash_format = sprintf("$2y$%02d$", $cost); + break; + default: + trigger_error(sprintf("password_hash(): Unknown password hashing algorithm: %s", $algo), E_USER_WARNING); + return null; + } + if (isset($options['salt'])) { + switch (gettype($options['salt'])) { + case 'NULL': + case 'boolean': + case 'integer': + case 'double': + case 'string': + $salt = (string) $options['salt']; + break; + case 'object': + if (method_exists($options['salt'], '__tostring')) { + $salt = (string) $options['salt']; + break; + } + case 'array': + case 'resource': + default: + trigger_error('password_hash(): Non-string salt parameter supplied', E_USER_WARNING); + return null; + } + if (strlen($salt) < $required_salt_len) { + trigger_error(sprintf("password_hash(): Provided salt is too short: %d expecting %d", strlen($salt), $required_salt_len), E_USER_WARNING); + return null; + } elseif (0 == preg_match('#^[a-zA-Z0-9./]+$#D', $salt)) { + $salt = str_replace('+', '.', base64_encode($salt)); + } + } else { + $buffer = ''; + $buffer_valid = false; + if (function_exists('mcrypt_create_iv') && !defined('PHALANGER')) { + $buffer = mcrypt_create_iv($raw_salt_len, MCRYPT_DEV_URANDOM); + if ($buffer) { + $buffer_valid = true; + } + } + if (!$buffer_valid && function_exists('openssl_random_pseudo_bytes')) { + $buffer = openssl_random_pseudo_bytes($raw_salt_len); + if ($buffer) { + $buffer_valid = true; + } + } + if (!$buffer_valid && is_readable('/dev/urandom')) { + $f = fopen('/dev/urandom', 'r'); + $read = strlen($buffer); + while ($read < $raw_salt_len) { + $buffer .= fread($f, $raw_salt_len - $read); + $read = strlen($buffer); + } + fclose($f); + if ($read >= $raw_salt_len) { + $buffer_valid = true; + } + } + if (!$buffer_valid || strlen($buffer) < $raw_salt_len) { + $bl = strlen($buffer); + for ($i = 0; $i < $raw_salt_len; $i++) { + if ($i < $bl) { + $buffer[$i] = $buffer[$i] ^ chr(mt_rand(0, 255)); + } else { + $buffer .= chr(mt_rand(0, 255)); + } + } + } + $salt = str_replace('+', '.', base64_encode($buffer)); + } + $salt = substr($salt, 0, $required_salt_len); + + $hash = $hash_format . $salt; + + $ret = crypt($password, $hash); + + if (!is_string($ret) || strlen($ret) <= 13) { + return false; + } + + return $ret; + } + + /** + * Get information about the password hash. Returns an array of the information + * that was used to generate the password hash. + * + * array( + * 'algo' => 1, + * 'algoName' => 'bcrypt', + * 'options' => array( + * 'cost' => 10, + * ), + * ) + * + * @param string $hash The password hash to extract info from + * + * @return array The array of information about the hash. + */ + function password_get_info($hash) { + $return = array( + 'algo' => 0, + 'algoName' => 'unknown', + 'options' => array(), + ); + if (substr($hash, 0, 4) == '$2y$' && strlen($hash) == 60) { + $return['algo'] = PASSWORD_BCRYPT; + $return['algoName'] = 'bcrypt'; + list($cost) = sscanf($hash, "$2y$%d$"); + $return['options']['cost'] = $cost; + } + return $return; + } + + /** + * Determine if the password hash needs to be rehashed according to the options provided + * + * If the answer is true, after validating the password using password_verify, rehash it. + * + * @param string $hash The hash to test + * @param int $algo The algorithm used for new password hashes + * @param array $options The options array passed to password_hash + * + * @return boolean True if the password needs to be rehashed. + */ + function password_needs_rehash($hash, $algo, array $options = array()) { + $info = password_get_info($hash); + if ($info['algo'] != $algo) { + return true; + } + switch ($algo) { + case PASSWORD_BCRYPT: + $cost = isset($options['cost']) ? $options['cost'] : 10; + if ($cost != $info['options']['cost']) { + return true; + } + break; + } + return false; + } + + /** + * Verify a password against a hash using a timing attack resistant approach + * + * @param string $password The password to verify + * @param string $hash The hash to verify against + * + * @return boolean If the password matches the hash + */ + function password_verify($password, $hash) { + if (!function_exists('crypt')) { + trigger_error("Crypt must be loaded for password_verify to function", E_USER_WARNING); + return false; + } + $ret = crypt($password, $hash); + if (!is_string($ret) || strlen($ret) != strlen($hash) || strlen($ret) <= 13) { + return false; + } + + $status = 0; + for ($i = 0; $i < strlen($ret); $i++) { + $status |= (ord($ret[$i]) ^ ord($hash[$i])); + } + + return $status === 0; + } +} + + + diff --git a/vendor/ircmaxell/password-compat/phpunit.xml.dist b/vendor/ircmaxell/password-compat/phpunit.xml.dist new file mode 100755 index 0000000..b2b3afb --- /dev/null +++ b/vendor/ircmaxell/password-compat/phpunit.xml.dist @@ -0,0 +1,29 @@ + + + + + test/Unit + + + + + lib/ + + + diff --git a/vendor/ircmaxell/password-compat/test/Unit/PasswordGetInfoTest.php b/vendor/ircmaxell/password-compat/test/Unit/PasswordGetInfoTest.php new file mode 100755 index 0000000..6aab976 --- /dev/null +++ b/vendor/ircmaxell/password-compat/test/Unit/PasswordGetInfoTest.php @@ -0,0 +1,26 @@ + 0, 'algoName' => 'unknown', 'options' => array())), + array('$2y$', array('algo' => 0, 'algoName' => 'unknown', 'options' => array())), + array('$2y$07$usesomesillystringfore2uDLvp1Ii2e./U9C8sBjqp8I90dH6hi', array('algo' => PASSWORD_BCRYPT, 'algoName' => 'bcrypt', 'options' => array('cost' => 7))), + array('$2y$10$usesomesillystringfore2uDLvp1Ii2e./U9C8sBjqp8I90dH6hi', array('algo' => PASSWORD_BCRYPT, 'algoName' => 'bcrypt', 'options' => array('cost' => 10))), + + ); + } + + public function testFuncExists() { + $this->assertTrue(function_exists('password_get_info')); + } + + /** + * @dataProvider provideInfo + */ + public function testInfo($hash, $info) { + $this->assertEquals($info, password_get_info($hash)); + } + +} \ No newline at end of file diff --git a/vendor/ircmaxell/password-compat/test/Unit/PasswordHashTest.php b/vendor/ircmaxell/password-compat/test/Unit/PasswordHashTest.php new file mode 100755 index 0000000..9e5e9ec --- /dev/null +++ b/vendor/ircmaxell/password-compat/test/Unit/PasswordHashTest.php @@ -0,0 +1,84 @@ +assertTrue(function_exists('password_hash')); + } + + public function testStringLength() { + $this->assertEquals(60, strlen(password_hash('foo', PASSWORD_BCRYPT))); + } + + public function testHash() { + $hash = password_hash('foo', PASSWORD_BCRYPT); + $this->assertEquals($hash, crypt('foo', $hash)); + } + + public function testKnownSalt() { + $hash = password_hash("rasmuslerdorf", PASSWORD_BCRYPT, array("cost" => 7, "salt" => "usesomesillystringforsalt")); + $this->assertEquals('$2y$07$usesomesillystringfore2uDLvp1Ii2e./U9C8sBjqp8I90dH6hi', $hash); + } + + public function testRawSalt() { + $hash = password_hash("test", PASSWORD_BCRYPT, array("salt" => "123456789012345678901" . chr(0))); + $this->assertEquals('$2y$10$MTIzNDU2Nzg5MDEyMzQ1Nej0NmcAWSLR.oP7XOR9HD/vjUuOj100y', $hash); + } + + /** + * @expectedException PHPUnit_Framework_Error + */ + public function testInvalidAlgo() { + password_hash('foo', array()); + } + + /** + * @expectedException PHPUnit_Framework_Error + */ + public function testInvalidAlgo2() { + password_hash('foo', 2); + } + + /** + * @expectedException PHPUnit_Framework_Error + */ + public function testInvalidPassword() { + password_hash(array(), 1); + } + + /** + * @expectedException PHPUnit_Framework_Error + */ + public function testInvalidSalt() { + password_hash('foo', PASSWORD_BCRYPT, array('salt' => array())); + } + + /** + * @expectedException PHPUnit_Framework_Error + */ + public function testInvalidBcryptCostLow() { + password_hash('foo', PASSWORD_BCRYPT, array('cost' => 3)); + } + + /** + * @expectedException PHPUnit_Framework_Error + */ + public function testInvalidBcryptCostHigh() { + password_hash('foo', PASSWORD_BCRYPT, array('cost' => 32)); + } + + /** + * @expectedException PHPUnit_Framework_Error + */ + public function testInvalidBcryptCostInvalid() { + password_hash('foo', PASSWORD_BCRYPT, array('cost' => 'foo')); + } + + /** + * @expectedException PHPUnit_Framework_Error + */ + public function testInvalidBcryptSaltShort() { + password_hash('foo', PASSWORD_BCRYPT, array('salt' => 'abc')); + } + +} \ No newline at end of file diff --git a/vendor/ircmaxell/password-compat/test/Unit/PasswordNeedsRehashTest.php b/vendor/ircmaxell/password-compat/test/Unit/PasswordNeedsRehashTest.php new file mode 100755 index 0000000..c2932dc --- /dev/null +++ b/vendor/ircmaxell/password-compat/test/Unit/PasswordNeedsRehashTest.php @@ -0,0 +1,26 @@ + 7), false), + array('$2y$07$usesomesillystringfore2udlvp1ii2e./u9c8sbjqp8i90dh6hi', PASSWORD_BCRYPT, array('cost' => 5), true), + ); + } + + public function testFuncExists() { + $this->assertTrue(function_exists('password_needs_rehash')); + } + + /** + * @dataProvider provideCases + */ + public function testCases($hash, $algo, $options, $valid) { + $this->assertEquals($valid, password_needs_rehash($hash, $algo, $options)); + } + +} \ No newline at end of file diff --git a/vendor/ircmaxell/password-compat/test/Unit/PasswordVerifyTest.php b/vendor/ircmaxell/password-compat/test/Unit/PasswordVerifyTest.php new file mode 100755 index 0000000..9f67bb9 --- /dev/null +++ b/vendor/ircmaxell/password-compat/test/Unit/PasswordVerifyTest.php @@ -0,0 +1,29 @@ +assertTrue(function_exists('password_verify')); + } + + public function testFailedType() { + $this->assertFalse(password_verify(123, 123)); + } + + public function testSaltOnly() { + $this->assertFalse(password_verify('foo', '$2a$07$usesomesillystringforsalt$')); + } + + public function testInvalidPassword() { + $this->assertFalse(password_verify('rasmusler', '$2a$07$usesomesillystringfore2uDLvp1Ii2e./U9C8sBjqp8I90dH6hi')); + } + + public function testValidPassword() { + $this->assertTrue(password_verify('rasmuslerdorf', '$2a$07$usesomesillystringfore2uDLvp1Ii2e./U9C8sBjqp8I90dH6hi')); + } + + public function testInValidHash() { + $this->assertFalse(password_verify('rasmuslerdorf', '$2a$07$usesomesillystringfore2uDLvp1Ii2e./U9C8sBjqp8I90dH6hj')); + } + +} \ No newline at end of file diff --git a/vendor/ircmaxell/password-compat/version-test.php b/vendor/ircmaxell/password-compat/version-test.php new file mode 100755 index 0000000..f527e30 --- /dev/null +++ b/vendor/ircmaxell/password-compat/version-test.php @@ -0,0 +1,8 @@ + Uncaught exception 'Exception' with message 'Serialization of 'Closure' is not allowed' + +It's true! If you try to serialize a `Closure`, PHP will throw an exception and tell you that it is not allowed. But +even though it is not "allowed" by PHP, the Super Closure library ([jeremeamia/superclosure][3] on Packagist) makes it +**possible**. + +I'm not joking, *you really can serialize a PHP closure*! + +```php + Hello, World! +$helloWorld('Jeremy'); +//> Hello, Jeremy! + +$serialized = serialize($helloWorld); +$unserialized = unserialize($serialized); + +$unserialized(); +//> Hello, World! +$unserialized('Jeremy'); +//> Hello, Jeremy! +``` +Yep, pretty cool huh? + +## Tell Me More! + +It all started way back in the beginning of 2010 when PHP 5.3 was starting to gain traction. I wrote a blog post called +[Extending PHP 5.3 Closures with Serialization and Reflection][4] on my former employers' blog, [HTMList][5], showing +how it can be done. Since then I've made a few iterations on the code, and this most recent iteration brings with it a +generally more robust solution that takes advantage of the fabulous [nikic/php-parser][6] library. + +### Features + +* Grants the ability to serialize closures +* Handles closures with used/inherited/imported variables +* Handles closures that use other closures +* Handles closures that reference class names in the parameters or body +* Handles recursive closures (PHP 5.4+ only) +* Allows you to get the code of a closure +* Allows you to get the names and values of variables used by a closure +* Allows you to get an Abstract Syntax Tree (AST) representing the code of a closure +* Replaces magic constants with their expected values so that the closure behaves as expected after unserialization +* Uses an accurate parsing method of a context-free grammar via the [nikic/php-parser][6] library +* PSR-0 compliant and installable via Composer + +### Caveats + +1. For any variables used by reference (e.g., `function () use (&$vars, &$like, &$these) {…}`), the references are not + maintained after serialization/unserialization. The only exception is when (in PHP 5.4+ only) the used variable is a + reference to the `SerializableClosure` object being serialized, which is the case with a recursive function. For some + reason — *that I actually don't quite understand* — this works. +2. If you have two closures defined on a single line (you shouldn't do this anyway), you will not be able to serialize + either one since it is ambiguous which closure's code should be parsed. +3. Because the technique to acquire the code and context of the closure requires reflection and full AST-style parsing, + the performance of serializing a closure is likely not good. +4. **Warning**: Both `eval()` and `extract()` are required to unserialize the closure. These functions are considered + dangerous by many, so you will have to evaluate whether or not you actual want to be using this library if these + functions concern you. These functions *must* be used to make this technique work. + +## Installation + +To install the Super Closure library in your project using Composer, first add the following to your `composer.json` +config file. + + { + "require": { + "jeremeamia/superclosure": "~1.0" + } + } + +Then run Composer's install or update commands to complete installation. Please visit the [Composer homepage][7] for +more information about how to use Composer. + +## Why Would I Need To Serialize Closures? + +Well, since you are here looking at this README, you may already have a use case in mind. Even though this concept began +as an experiment, there have been some use cases that have come up in the wild. + +For example, in a [video about Laravel 4 and IronMQ][8] by [UserScape][9], at about the 7:50 mark they show how you can +push a closure onto a queue as a job so that it can be executed by a worker. This is nice because you do not have to +create a whole class for a job that might be really simple. The closure serialization is done by a [class in the Laravel +4 framework][10] that is based on one of my older versions of SuperClosure. + +Essentially this library let's you create closures in one process and use them in another. It would even be possible to +provide closures (or algorithms) as a service through an API. + +## Who Is Using Super Closure? + +- [Laravel 4](https://github.com/laravel/framework) - Serializes a closure to potentially push onto a job queue. +- [HTTP Mock for PHP](https://github.com/InterNations/http-mock) - Serialize a closure to send to remote server within + a test workflow. +- [Jumper](https://github.com/kakawait/Jumper) - Serialize a closure to run on remote host via SSH. +- [nicmart/Benchmark](https://github.com/nicmart/Benchmark) - Uses the `ClosureParser` to display a benchmarked + Closure's code. +- Please let me know if and how your project uses Super Closure. + +[1]: https://secure.travis-ci.org/jeremeamia/super_closure.png?branch=master +[2]: http://travis-ci.org/#!/jeremeamia/super_closure +[3]: http://packagist.org/packages/jeremeamia/SuperClosure +[4]: http://www.htmlist.com/development/extending-php-5-3-closures-with-serialization-and-reflection/ +[5]: http://www.htmlist.com +[6]: https://github.com/nikic/PHP-Parser +[7]: http://getcomposer.org +[8]: http://vimeo.com/64703617 +[9]: http://www.userscape.com +[10]: https://github.com/illuminate/support/blob/master/SerializableClosure.php diff --git a/vendor/jeremeamia/SuperClosure/composer.json b/vendor/jeremeamia/SuperClosure/composer.json new file mode 100755 index 0000000..2477e38 --- /dev/null +++ b/vendor/jeremeamia/SuperClosure/composer.json @@ -0,0 +1,23 @@ +{ + "name": "jeremeamia/SuperClosure", + "type": "library", + "description": "Doing interesting things with closures like serialization.", + "keywords": ["closure", "serialize", "serializable", "function", "parser", "tokenizer"], + "homepage": "https://github.com/jeremeamia/super_closure", + "license": "MIT", + "authors": [ + { + "name": "Jeremy Lindblom" + } + ], + "require": { + "php": ">=5.3.3", + "nikic/php-parser": "~0.9" + }, + "require-dev": { + "phpunit/phpunit": "~3.7" + }, + "autoload": { + "psr-0": { "Jeremeamia\\SuperClosure": "src/" } + } +} diff --git a/vendor/jeremeamia/SuperClosure/demo/factorial.php b/vendor/jeremeamia/SuperClosure/demo/factorial.php new file mode 100755 index 0000000..8dc8fbd --- /dev/null +++ b/vendor/jeremeamia/SuperClosure/demo/factorial.php @@ -0,0 +1,23 @@ + 120 + +$serialized = serialize($factorial); +$unserialized = unserialize($serialized); + +echo $unserialized(5) . PHP_EOL; +//> 120 + diff --git a/vendor/jeremeamia/SuperClosure/demo/hello-world.php b/vendor/jeremeamia/SuperClosure/demo/hello-world.php new file mode 100755 index 0000000..ce54218 --- /dev/null +++ b/vendor/jeremeamia/SuperClosure/demo/hello-world.php @@ -0,0 +1,23 @@ + Hello, World! +$helloWorld('Jeremy'); +//> Hello, Jeremy! + +$serialized = serialize($helloWorld); +$unserialized = unserialize($serialized); + +$unserialized(); +//> Hello, World! +$unserialized('Jeremy'); +//> Hello, Jeremy! diff --git a/vendor/jeremeamia/SuperClosure/phpunit.xml.dist b/vendor/jeremeamia/SuperClosure/phpunit.xml.dist new file mode 100755 index 0000000..299507c --- /dev/null +++ b/vendor/jeremeamia/SuperClosure/phpunit.xml.dist @@ -0,0 +1,34 @@ + + + + + + ./tests/Jeremeamia/SuperClosure/Test + + + + + + ./src/Jeremeamia/SuperClosure + + + + + + + + + + + diff --git a/vendor/jeremeamia/SuperClosure/src/Jeremeamia/SuperClosure/ClosureLocation.php b/vendor/jeremeamia/SuperClosure/src/Jeremeamia/SuperClosure/ClosureLocation.php new file mode 100755 index 0000000..cbdbe0b --- /dev/null +++ b/vendor/jeremeamia/SuperClosure/src/Jeremeamia/SuperClosure/ClosureLocation.php @@ -0,0 +1,77 @@ +directory = dirname($reflection->getFileName()); + $location->file = $reflection->getFileName(); + $location->function = $reflection->getName(); + $location->line = $reflection->getStartLine(); + + // @codeCoverageIgnoreStart + if (version_compare(PHP_VERSION, '5.4', '>=')) { + $closureScopeClass = $reflection->getClosureScopeClass(); + $location->closureScopeClass = $closureScopeClass ? $closureScopeClass->getName() : null; + } + // @codeCoverageIgnoreEnd + + return $location; + } + + public function finalize() + { + if ($this->class || $this->trait) { + $class = $this->class ?: $this->trait; + $this->method = "{$class}::{$this->function}"; + } + + if (!$this->class && $this->trait) { + $this->class = $this->closureScopeClass; + } + } + + +} diff --git a/vendor/jeremeamia/SuperClosure/src/Jeremeamia/SuperClosure/ClosureParser.php b/vendor/jeremeamia/SuperClosure/src/Jeremeamia/SuperClosure/ClosureParser.php new file mode 100755 index 0000000..ca08073 --- /dev/null +++ b/vendor/jeremeamia/SuperClosure/src/Jeremeamia/SuperClosure/ClosureParser.php @@ -0,0 +1,195 @@ +isClosure()) { + throw new \InvalidArgumentException('You must provide the reflection of a closure.'); + } + + $this->reflection = $reflection; + } + + /** + * Returns the reflection of the closure + * + * @return \ReflectionFunction + */ + public function getReflection() + { + return $this->reflection; + } + + /** + * Returns the abstract syntax tree (AST) of the closure's code. Class names are resolved to their fully-qualified + * class names (FQCN) and magic constants are resolved to their values as they would be in the context of the + * closure. + * + * @return \PHPParser_Node_Expr_Closure + * @throws \InvalidArgumentException + */ + public function getClosureAbstractSyntaxTree() + { + if (!$this->abstractSyntaxTree) { + try { + // Parse the code from the file containing the closure and create an AST with FQCN resolved + $fileAst = $this->getFileAbstractSyntaxTree(); + $closureFinder = new ClosureFinderVisitor($this->reflection); + $fileTraverser = new \PHPParser_NodeTraverser(); + $fileTraverser->addVisitor(new \PHPParser_NodeVisitor_NameResolver); + $fileTraverser->addVisitor($closureFinder); + $fileTraverser->traverse($fileAst); + } catch (\PHPParser_Error $e) { + // @codeCoverageIgnoreStart + throw new \InvalidArgumentException('There was an error parsing the file containing the closure.'); + // @codeCoverageIgnoreEnd + } + + // Find the first closure defined in the AST that is on the line where the closure is located + $closureAst = $closureFinder->getClosureNode(); + if (!$closureAst) { + // @codeCoverageIgnoreStart + throw new \InvalidArgumentException('The closure was not found within the abstract syntax tree.'); + // @codeCoverageIgnoreEnd + } + + // Resolve additional nodes by making a second pass through just the closure's nodes + $closureTraverser = new \PHPParser_NodeTraverser(); + $closureTraverser->addVisitor(new MagicConstantVisitor($closureFinder->getLocation())); + $closureAst = $closureTraverser->traverse(array($closureAst)); + $this->abstractSyntaxTree = $closureAst[0]; + } + + return $this->abstractSyntaxTree; + } + + /** + * Returns the variables that in the "use" clause of the closure definition. These are referred to as the "used + * variables", "static variables", or "closed upon variables", "context" of the closure. + * + * @return array + */ + public function getUsedVariables() + { + if (!$this->usedVariables) { + // Get the variable names defined in the AST + $usedVarNames = array_map(function ($usedVar) { + return $usedVar->var; + }, $this->getClosureAbstractSyntaxTree()->uses); + + // Get the variable names and values using reflection + $usedVarValues = $this->reflection->getStaticVariables(); + + // Combine the two arrays to create a canonical hash of variable names and values + $this->usedVariables = array(); + foreach ($usedVarNames as $name) { + if (isset($usedVarValues[$name])) { + $this->usedVariables[$name] = $usedVarValues[$name]; + } + } + } + + return $this->usedVariables; + } + + /** + * Returns the formatted code of the closure + * + * @return string + */ + public function getCode() + { + if (!$this->code) { + // Use the pretty printer to print the closure code from the AST + $printer = new \PHPParser_PrettyPrinter_Default(); + $this->code = $printer->prettyPrint(array($this->getClosureAbstractSyntaxTree())); + } + + return $this->code; + } + + /** + * Loads the PHP file and produces an abstract syntax tree (AST) of the code. This is stored in an internal cache by + * the filename for memoization within the same process + * + * @return array + */ + protected function getFileAbstractSyntaxTree() + { + $filename = $this->reflection->getFileName(); + + if (!isset(self::$cache[$filename])) { + $parser = new \PHPParser_Parser(new \PHPParser_Lexer_Emulative); + self::$cache[$filename] = $parser->parse(file_get_contents($filename)); + } + + return self::$cache[$filename]; + } +} diff --git a/vendor/jeremeamia/SuperClosure/src/Jeremeamia/SuperClosure/SerializableClosure.php b/vendor/jeremeamia/SuperClosure/src/Jeremeamia/SuperClosure/SerializableClosure.php new file mode 100755 index 0000000..b3b9959 --- /dev/null +++ b/vendor/jeremeamia/SuperClosure/src/Jeremeamia/SuperClosure/SerializableClosure.php @@ -0,0 +1,114 @@ +closure = $closure; + } + + /** + * @return \ReflectionFunction + */ + public function getReflection() + { + if (!$this->reflection) { + $this->reflection = new \ReflectionFunction($this->closure); + } + + return $this->reflection; + } + + /** + * @return \Closure + */ + public function getClosure() + { + return $this->closure; + } + + /** + * Invokes the original closure + * + * @return mixed + */ + public function __invoke() + { + return $this->getReflection()->invokeArgs(func_get_args()); + } + + /** + * Serialize the code and of context of the closure + * + * @return string + */ + public function serialize() + { + if (!$this->state) { + $this->createState(); + } + + return serialize($this->state); + } + + /** + * Unserializes the closure data and recreates the closure. Attempts to recreate the closure's context as well by + * extracting the used variables into the scope. Variables names in this method are surrounded with underlines in + * order to prevent collisions with the variables in the context. NOTE: There be dragons here! Both `eval` and + * `extract` are used in this method + * + * @param string $__serialized__ + */ + public function unserialize($__serialized__) + { + // Unserialize the data we need to reconstruct the SuperClosure + $this->state = unserialize($__serialized__); + list($__code__, $__context__) = $this->state; + + // Simulate the original context the Closure was created in + extract($__context__); + + // Evaluate the code to recreate the Closure + eval("\$this->closure = {$__code__};"); + } + + /** + * Uses the closure parser to fetch the closure's code and context + */ + protected function createState() + { + $parser = new ClosureParser($this->getReflection()); + $this->state = array($parser->getCode()); + // Add the used variables (context) to the state, but wrap all closures with SerializableClosure + $this->state[] = array_map(function ($var) { + return ($var instanceof \Closure) ? new self($var) : $var; + }, $parser->getUsedVariables()); + } +} diff --git a/vendor/jeremeamia/SuperClosure/src/Jeremeamia/SuperClosure/Visitor/ClosureFinderVisitor.php b/vendor/jeremeamia/SuperClosure/src/Jeremeamia/SuperClosure/Visitor/ClosureFinderVisitor.php new file mode 100755 index 0000000..56c0625 --- /dev/null +++ b/vendor/jeremeamia/SuperClosure/src/Jeremeamia/SuperClosure/Visitor/ClosureFinderVisitor.php @@ -0,0 +1,109 @@ +reflection = $reflection; + $this->location = new ClosureLocation; + } + + public function beforeTraverse(array $nodes) + { + $this->location = ClosureLocation::fromReflection($this->reflection); + } + + public function afterTraverse(array $nodes) + { + $this->location->finalize(); + } + + public function enterNode(\PHPParser_Node $node) + { + // Determine information about the closure's location + if (!$this->closureNode) { + if ($node instanceof \PHPParser_Node_Stmt_Namespace) { + $this->location->namespace = is_array($node->name->parts) ? implode('\\', $node->name->parts) : null; + } + if ($node instanceof \PHPParser_Node_Stmt_Trait) { + $this->location->trait = $this->location->namespace . '\\' . $node->name; + $this->location->class = null; + } + elseif ($node instanceof \PHPParser_Node_Stmt_Class) { + $this->location->class = $this->location->namespace . '\\' . $node->name; + $this->location->trait = null; + } + } + + // Locate the node of the closure + if ($node instanceof \PHPParser_Node_Expr_Closure) { + if ($node->getAttribute('startLine') == $this->reflection->getStartLine()) { + if ($this->closureNode) { + throw new \RuntimeException('Two closures were declared on the same line of code. Cannot determine ' + . 'which closure was the intended target.'); + } else { + $this->closureNode = $node; + } + } + } + } + + public function leaveNode(\PHPParser_Node $node) + { + // Determine information about the closure's location + if (!$this->closureNode) { + if ($node instanceof \PHPParser_Node_Stmt_Namespace) { + $this->location->namespace = null; + } + if ($node instanceof \PHPParser_Node_Stmt_Trait) { + $this->location->trait = null; + } + elseif ($node instanceof \PHPParser_Node_Stmt_Class) { + $this->location->class = null; + } + } + } + + /** + * @return \PHPParser_Node_Expr_Closure + */ + public function getClosureNode() + { + return $this->closureNode; + } + + /** + * @return ClosureLocation + */ + public function getLocation() + { + return $this->location; + } +} diff --git a/vendor/jeremeamia/SuperClosure/src/Jeremeamia/SuperClosure/Visitor/MagicConstantVisitor.php b/vendor/jeremeamia/SuperClosure/src/Jeremeamia/SuperClosure/Visitor/MagicConstantVisitor.php new file mode 100755 index 0000000..8a1846a --- /dev/null +++ b/vendor/jeremeamia/SuperClosure/src/Jeremeamia/SuperClosure/Visitor/MagicConstantVisitor.php @@ -0,0 +1,50 @@ +location = $location; + } + + public function leaveNode(\PHPParser_Node $node) + { + switch ($node->getType()) { + case 'Scalar_LineConst' : + return new NumberNode($node->getAttribute('startLine')); + case 'Scalar_FileConst' : + return new StringNode($this->location->file); + case 'Scalar_DirConst' : + return new StringNode($this->location->directory); + case 'Scalar_FuncConst' : + return new StringNode($this->location->function); + case 'Scalar_NSConst' : + return new StringNode($this->location->namespace); + case 'Scalar_ClassConst' : + return new StringNode($this->location->class); + case 'Scalar_MethodConst' : + return new StringNode($this->location->method); + case 'Scalar_TraitConst' : + return new StringNode($this->location->trait); + } + } +} diff --git a/vendor/jeremeamia/SuperClosure/tests/Jeremeamia/SuperClosure/Test/ClosureLocationTest.php b/vendor/jeremeamia/SuperClosure/tests/Jeremeamia/SuperClosure/Test/ClosureLocationTest.php new file mode 100755 index 0000000..4475248 --- /dev/null +++ b/vendor/jeremeamia/SuperClosure/tests/Jeremeamia/SuperClosure/Test/ClosureLocationTest.php @@ -0,0 +1,33 @@ +assertEquals(array('directory', 'file', 'function', 'line'), array_keys($setProperties)); + } + + public function testCanFinalizeLocation() + { + $location = new ClosureLocation(); + $location->function = '[function]'; + $location->trait = '[trait]'; + + $r = new \ReflectionObject($location); + $p = $r->getProperty('closureScopeClass'); + $p->setAccessible(true); + $p->setValue($location, '[class]'); + + $location->finalize(); + $this->assertEquals('[trait]::[function]', $location->method); + $this->assertEquals('[class]', $location->class); + } +} diff --git a/vendor/jeremeamia/SuperClosure/tests/Jeremeamia/SuperClosure/Test/ClosureParserTest.php b/vendor/jeremeamia/SuperClosure/tests/Jeremeamia/SuperClosure/Test/ClosureParserTest.php new file mode 100755 index 0000000..be4ec3e --- /dev/null +++ b/vendor/jeremeamia/SuperClosure/tests/Jeremeamia/SuperClosure/Test/ClosureParserTest.php @@ -0,0 +1,100 @@ +assertSame($reflection, $parser->getReflection()); + } + + /** + * @covers \Jeremeamia\SuperClosure\ClosureParser::fromClosure + */ + public function testCanUseFactoryMethodToCreateParser() + { + $parser = ClosureParser::fromClosure(function () {}); + + $this->assertInstanceOf('Jeremeamia\SuperClosure\ClosureParser', $parser); + } + + /** + * @covers \Jeremeamia\SuperClosure\ClosureParser::__construct + */ + public function testRaisesErrorWhenNonClosureIsProvided() + { + $this->setExpectedException('InvalidArgumentException'); + + $reflection = new \ReflectionFunction('strpos'); + $parser = new ClosureParser($reflection); + } + + /** + * @covers \Jeremeamia\SuperClosure\ClosureParser::getCode + */ + public function testCanGetCodeFromParser() + { + $closure = function () {}; + $expectedCode = "function () {\n \n};"; + $parser = new ClosureParser(new \ReflectionFunction($closure)); + $actualCode = $parser->getCode(); + + $this->assertEquals($expectedCode, $actualCode); + } + + /** + * @covers \Jeremeamia\SuperClosure\ClosureParser::getUsedVariables + */ + public function testCanGetUsedVariablesFromParser() + { + $foo = 1; + $bar = 2; + $closure = function () use ($foo, $bar) {}; + $expectedVars = array('foo' => 1, 'bar' => 2); + $parser = new ClosureParser(new \ReflectionFunction($closure)); + $actualVars = $parser->getUsedVariables(); + + $this->assertEquals($expectedVars, $actualVars); + } + + /** + * @covers \Jeremeamia\SuperClosure\ClosureParser::clearCache + */ + public function testCanClearCache() + { + $parserClass = 'Jeremeamia\SuperClosure\ClosureParser'; + + $p = new \ReflectionProperty($parserClass, 'cache'); + $p->setAccessible(true); + $p->setValue(null, array('foo' => 'bar')); + + $this->assertEquals(array('foo' => 'bar'), $this->readAttribute($parserClass, 'cache')); + + ClosureParser::clearCache(); + + $this->assertEquals(array(), $this->readAttribute($parserClass, 'cache')); + } + + /** + * @covers \Jeremeamia\SuperClosure\ClosureParser::getClosureAbstractSyntaxTree + * @covers \Jeremeamia\SuperClosure\ClosureParser::getFileAbstractSyntaxTree + */ + public function testCanGetClosureAst() + { + $closure = function () {}; + $parser = new ClosureParser(new \ReflectionFunction($closure)); + $ast = $parser->getClosureAbstractSyntaxTree(); + $this->assertInstanceOf('PHPParser_Node_Expr_Closure', $ast); + } +} diff --git a/vendor/jeremeamia/SuperClosure/tests/Jeremeamia/SuperClosure/Test/SerializableClosureTest.php b/vendor/jeremeamia/SuperClosure/tests/Jeremeamia/SuperClosure/Test/SerializableClosureTest.php new file mode 100755 index 0000000..1beac8d --- /dev/null +++ b/vendor/jeremeamia/SuperClosure/tests/Jeremeamia/SuperClosure/Test/SerializableClosureTest.php @@ -0,0 +1,115 @@ +originalClosure = $exp; + $this->serializableClosure = new SerializableClosure($exp); + } + + public function testClosureProxiesToTheOriginalClosureWhenInvoked() + { + $this->assertInstanceOf('\Closure', $this->serializableClosure->getClosure()); + $this->assertSame($this->originalClosure, $this->serializableClosure->getClosure()); + $this->assertEquals( + call_user_func($this->originalClosure, 4), + call_user_func($this->serializableClosure, 4) + ); + } + + public function testClosureBehavesTheSameAfterSerializationProcess() + { + $originalReturnValue = call_user_func($this->serializableClosure, 4); + $serializedClosure = serialize($this->serializableClosure); + $unserializedClosure = unserialize($serializedClosure); + $finalReturnValue = call_user_func($unserializedClosure, 4); + + $this->assertEquals($originalReturnValue, $finalReturnValue); + } + + public function testCanSerializeRecursiveClosure() + { + if (version_compare(PHP_VERSION, '5.4', '<')) { + $this->markTestSkipped('Requires version 5.4+ of PHP'); + } + + $factorial = new SerializableClosure(function ($n) use (&$factorial) { + return ($n <= 1) ? 1 : $n * $factorial($n - 1); + }); + + $this->assertEquals(120, call_user_func($factorial, 5)); + } + + public function testCanSerializeMultipleTimes() + { + $result = call_user_func($this->serializableClosure, 5); + $this->assertEquals(32, $result); + + $serializedOnce = unserialize(serialize($this->serializableClosure)); + $this->assertEquals(32, call_user_func($serializedOnce, 5)); + $internalState = $this->readAttribute($serializedOnce, 'state'); + $this->assertCount(2, $internalState); + + $serializedAgain = unserialize(serialize($this->serializableClosure)); + $this->assertEquals(32, call_user_func($serializedAgain, 5)); + $this->assertEquals($internalState, $this->readAttribute($serializedAgain, 'state')); + + $serializedTwice = unserialize(serialize($serializedOnce)); + $this->assertEquals(32, call_user_func($serializedTwice, 5)); + $this->assertEquals($internalState, $this->readAttribute($serializedTwice, 'state')); + } + + /** + * CAVEAT #1: Serializing a closure will sever relationships with things passed by reference + */ + public function testDoesNotMaintainsReferencesEvenWhenVariablesAreStillInScope() + { + $num = 0; + $inc = new SerializableClosure(function () use (&$num) { + $num++; + }); + + $inc(); + $inc(); + $this->assertEquals(2, $num, '$num should be incremented twice because by reference'); + + $newInc = unserialize(serialize($inc)); + /** @var $newInc \Closure */ + $newInc(); + $this->assertEquals(2, $num, '$num should not be incremented again because the reference is lost'); + } + + /** + * CAVEAT #2: You can't serialize a closure if there are two closures declared on one line + */ + public function testCannotDetermineWhichClosureToUseIfTwoDeclaredOnTheSameLine() + { + $this->setExpectedException('Exception'); + + $add = function ($a, $b) {return $a + $b;}; $sub = function ($a, $b) {return $a - $b;}; + $serialized = serialize(new SerializableClosure($sub)); + } +} diff --git a/vendor/jeremeamia/SuperClosure/tests/Jeremeamia/SuperClosure/Test/Visitor/ClosureFinderVisitorTest.php b/vendor/jeremeamia/SuperClosure/tests/Jeremeamia/SuperClosure/Test/Visitor/ClosureFinderVisitorTest.php new file mode 100755 index 0000000..b067cc7 --- /dev/null +++ b/vendor/jeremeamia/SuperClosure/tests/Jeremeamia/SuperClosure/Test/Visitor/ClosureFinderVisitorTest.php @@ -0,0 +1,57 @@ + 14)); + $closureFinder->enterNode($closureNode); + + $this->assertSame($closureNode, $closureFinder->getClosureNode()); + } + + public function testClosureNodeIsAmbiguousIfMultipleClosuresOnLine() + { + $this->setExpectedException('RuntimeException'); + + $closure = function () {}; function () {}; // Take the line number here and set it as the "startLine" + $closureFinder = new ClosureFinderVisitor(new \ReflectionFunction($closure)); + $closureFinder->enterNode(new \PHPParser_Node_Expr_Closure(array(), array('startLine' => 27))); + $closureFinder->enterNode(new \PHPParser_Node_Expr_Closure(array(), array('startLine' => 27))); + } + + public function testCalculatesClosureLocation() + { + $closure = function () {}; // Take the line number here and set it as the "startLine" + $closureFinder = new ClosureFinderVisitor(new \ReflectionFunction($closure)); + + $closureFinder->beforeTraverse(array()); + + $node = new \PHPParser_Node_Stmt_Namespace(new \PHPParser_Node_Name(array('Foo', 'Bar'))); + $closureFinder->enterNode($node); + $closureFinder->leaveNode($node); + + $node = new \PHPParser_Node_Stmt_Trait('Fizz'); + $closureFinder->enterNode($node); + $closureFinder->leaveNode($node); + + $node = new \PHPParser_Node_Stmt_Class('Buzz'); + $closureFinder->enterNode($node); + $closureFinder->leaveNode($node); + + $closureFinder->afterTraverse(array()); + + $setProperties = array_filter(get_object_vars($closureFinder->getLocation())); + $this->assertEquals(array('directory', 'file', 'function', 'line'), array_keys($setProperties)); + } +} diff --git a/vendor/jeremeamia/SuperClosure/tests/Jeremeamia/SuperClosure/Test/Visitor/MagicConstantVisitorTest.php b/vendor/jeremeamia/SuperClosure/tests/Jeremeamia/SuperClosure/Test/Visitor/MagicConstantVisitorTest.php new file mode 100755 index 0000000..48440c8 --- /dev/null +++ b/vendor/jeremeamia/SuperClosure/tests/Jeremeamia/SuperClosure/Test/Visitor/MagicConstantVisitorTest.php @@ -0,0 +1,54 @@ +class = '[class]'; + $location->directory = '[directory]'; + $location->file = '[file]'; + $location->function = '[function]'; + $location->line = '[line]'; + $location->method = '[method]'; + $location->namespace = '[namespace]'; + $location->trait = '[trait]'; + + $nodes = array( + 'PHPParser_Node_Scalar_LineConst' => 'PHPParser_Node_Scalar_LNumber', + 'PHPParser_Node_Scalar_FileConst' => 'PHPParser_Node_Scalar_String', + 'PHPParser_Node_Scalar_DirConst' => 'PHPParser_Node_Scalar_String', + 'PHPParser_Node_Scalar_FuncConst' => 'PHPParser_Node_Scalar_String', + 'PHPParser_Node_Scalar_NSConst' => 'PHPParser_Node_Scalar_String', + 'PHPParser_Node_Scalar_ClassConst' => 'PHPParser_Node_Scalar_String', + 'PHPParser_Node_Scalar_MethodConst' => 'PHPParser_Node_Scalar_String', + 'PHPParser_Node_Scalar_TraitConst' => 'PHPParser_Node_Scalar_String', + 'PHPParser_Node_Scalar_String' => 'PHPParser_Node_Scalar_String', + + ); + + $visitor = new MagicConstantVisitor($location); + foreach ($nodes as $originalNodeName => $resultNodeName) { + $mockNode = $this->getMockBuilder($originalNodeName) + ->disableOriginalConstructor() + ->setMethods(array('getType', 'getAttribute')) + ->getMock(); + $mockNode->expects($this->any()) + ->method('getAttribute') + ->will($this->returnValue(1)); + $mockNode->expects($this->any()) + ->method('getType') + ->will($this->returnValue(substr($originalNodeName, 15))); + $resultNode = $visitor->leaveNode($mockNode) ?: $mockNode; + $this->assertInstanceOf($resultNodeName, $resultNode); + } + } +} diff --git a/vendor/jeremeamia/SuperClosure/tests/bootstrap.php b/vendor/jeremeamia/SuperClosure/tests/bootstrap.php new file mode 100755 index 0000000..16fe799 --- /dev/null +++ b/vendor/jeremeamia/SuperClosure/tests/bootstrap.php @@ -0,0 +1,4 @@ + + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/vendor/laravel/framework/composer.json b/vendor/laravel/framework/composer.json new file mode 100755 index 0000000..cb57dff --- /dev/null +++ b/vendor/laravel/framework/composer.json @@ -0,0 +1,96 @@ +{ + "name": "laravel/framework", + "description": "The Laravel Framework.", + "keywords": ["framework", "laravel"], + "license": "MIT", + "authors": [ + { + "name": "Taylor Otwell", + "email": "taylorotwell@gmail.com" + } + ], + "require": { + "php": ">=5.3.0", + "classpreloader/classpreloader": "1.0.*", + "d11wtq/boris": "1.0.*", + "ircmaxell/password-compat": "1.0.*", + "filp/whoops": "1.0.10", + "jeremeamia/superclosure": "1.0.*", + "monolog/monolog": "1.*", + "nesbot/carbon": "1.*", + "patchwork/utf8": "1.1.*", + "phpseclib/phpseclib": "0.3.*", + "predis/predis": "0.8.*", + "stack/builder": "1.0.*", + "swiftmailer/swiftmailer": "~5.0", + "symfony/browser-kit": "2.4.*", + "symfony/console": "2.4.*", + "symfony/css-selector": "2.4.*", + "symfony/debug": "2.4.*", + "symfony/dom-crawler": "2.4.*", + "symfony/finder": "2.4.*", + "symfony/http-foundation": "2.4.*", + "symfony/http-kernel": "2.4.*", + "symfony/process": "2.4.*", + "symfony/routing": "2.4.*", + "symfony/security-core": "2.4.*", + "symfony/translation": "2.4.*" + }, + "replace": { + "illuminate/auth": "self.version", + "illuminate/cache": "self.version", + "illuminate/config": "self.version", + "illuminate/console": "self.version", + "illuminate/container": "self.version", + "illuminate/cookie": "self.version", + "illuminate/database": "self.version", + "illuminate/encryption": "self.version", + "illuminate/events": "self.version", + "illuminate/exception": "self.version", + "illuminate/filesystem": "self.version", + "illuminate/foundation": "self.version", + "illuminate/hashing": "self.version", + "illuminate/http": "self.version", + "illuminate/html": "self.version", + "illuminate/log": "self.version", + "illuminate/mail": "self.version", + "illuminate/pagination": "self.version", + "illuminate/queue": "self.version", + "illuminate/redis": "self.version", + "illuminate/remote": "self.version", + "illuminate/routing": "self.version", + "illuminate/session": "self.version", + "illuminate/support": "self.version", + "illuminate/translation": "self.version", + "illuminate/validation": "self.version", + "illuminate/view": "self.version", + "illuminate/workbench": "self.version" + }, + "require-dev": { + "aws/aws-sdk-php": "2.6.*", + "iron-io/iron_mq": "1.5.*", + "pda/pheanstalk": "2.1.*", + "mockery/mockery": "0.9.*", + "phpunit/phpunit": "4.0.*" + }, + "autoload": { + "classmap": [ + "src/Illuminate/Queue/IlluminateQueueClosure.php" + ], + "files": [ + "src/Illuminate/Support/helpers.php" + ], + "psr-0": { + "Illuminate": "src/" + } + }, + "extra": { + "branch-alias": { + "dev-master": "4.1-dev" + } + }, + "suggest": { + "doctrine/dbal": "Allow renaming columns and dropping SQLite columns." + }, + "minimum-stability": "dev" +} diff --git a/vendor/laravel/framework/phpunit.php b/vendor/laravel/framework/phpunit.php new file mode 100755 index 0000000..7e0cfdd --- /dev/null +++ b/vendor/laravel/framework/phpunit.php @@ -0,0 +1,30 @@ + + + + + ./tests/ + + + + + + src + + vendor + + + + diff --git a/vendor/laravel/framework/readme.md b/vendor/laravel/framework/readme.md new file mode 100755 index 0000000..bf23d76 --- /dev/null +++ b/vendor/laravel/framework/readme.md @@ -0,0 +1,29 @@ +## Laravel Framework (Kernel) + +[![Build Status](https://travis-ci.org/laravel/framework.svg)](https://travis-ci.org/laravel/framework) +[![Total Downloads](https://poser.pugx.org/laravel/framework/downloads.svg)](https://packagist.org/packages/laravel/framework) +[![Latest Stable Version](https://poser.pugx.org/laravel/framework/v/stable.svg)](https://packagist.org/packages/laravel/framework) +[![Latest Unstable Version](https://poser.pugx.org/laravel/framework/v/unstable.svg)](https://packagist.org/packages/laravel/framework) +[![License](https://poser.pugx.org/laravel/framework/license.svg)](https://packagist.org/packages/laravel/framework) + +> **Note:** This repository contains the core code of the Laravel framework. If you want to build an application using Laravel 4, visit the main [Laravel repository](https://github.com/laravel/laravel). + +## Laravel PHP Framework + +Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable, creative experience to be truly fulfilling. Laravel attempts to take the pain out of development by easing common tasks used in the majority of web projects, such as authentication, routing, sessions, and caching. + +Laravel aims to make the development process a pleasing one for the developer without sacrificing application functionality. Happy developers make the best code. To this end, we've attempted to combine the very best of what we have seen in other web frameworks, including frameworks implemented in other languages, such as Ruby on Rails, ASP.NET MVC, and Sinatra. + +Laravel is accessible, yet powerful, providing powerful tools needed for large, robust applications. A superb inversion of control container, expressive migration system, and tightly integrated unit testing support give you the tools you need to build any application with which you are tasked. + +## Official Documentation + +Documentation for the entire framework can be found on the [Laravel website](http://laravel.com/docs). + +## Contributing + +Thank you for considering contributing to the Laravel framework. If you are submitting a bug-fix, or an enhancement that is **not** a breaking change, submit your pull request to the branch corresponding to the latest stable release of the framework, such as the `4.1` branch. If you are submitting a breaking change or an entirely new component, submit your pull request to the `master` branch. + +### License + +The Laravel framework is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT) diff --git a/vendor/laravel/framework/src/Illuminate/Auth/AuthManager.php b/vendor/laravel/framework/src/Illuminate/Auth/AuthManager.php new file mode 100755 index 0000000..f662c45 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Auth/AuthManager.php @@ -0,0 +1,116 @@ +setCookieJar($this->app['cookie']); + + $guard->setDispatcher($this->app['events']); + + return $guard->setRequest($this->app->refresh('request', $guard, 'setRequest')); + } + + /** + * Call a custom driver creator. + * + * @param string $driver + * @return mixed + */ + protected function callCustomCreator($driver) + { + $custom = parent::callCustomCreator($driver); + + if ($custom instanceof Guard) return $custom; + + return new Guard($custom, $this->app['session.store']); + } + + /** + * Create an instance of the database driver. + * + * @return \Illuminate\Auth\Guard + */ + public function createDatabaseDriver() + { + $provider = $this->createDatabaseProvider(); + + return new Guard($provider, $this->app['session.store']); + } + + /** + * Create an instance of the database user provider. + * + * @return \Illuminate\Auth\DatabaseUserProvider + */ + protected function createDatabaseProvider() + { + $connection = $this->app['db']->connection(); + + // When using the basic database user provider, we need to inject the table we + // want to use, since this is not an Eloquent model we will have no way to + // know without telling the provider, so we'll inject the config value. + $table = $this->app['config']['auth.table']; + + return new DatabaseUserProvider($connection, $this->app['hash'], $table); + } + + /** + * Create an instance of the Eloquent driver. + * + * @return \Illuminate\Auth\Guard + */ + public function createEloquentDriver() + { + $provider = $this->createEloquentProvider(); + + return new Guard($provider, $this->app['session.store']); + } + + /** + * Create an instance of the Eloquent user provider. + * + * @return \Illuminate\Auth\EloquentUserProvider + */ + protected function createEloquentProvider() + { + $model = $this->app['config']['auth.model']; + + return new EloquentUserProvider($this->app['hash'], $model); + } + + /** + * Get the default authentication driver name. + * + * @return string + */ + public function getDefaultDriver() + { + return $this->app['config']['auth.driver']; + } + + /** + * Set the default authentication driver name. + * + * @param string $name + * @return void + */ + public function setDefaultDriver($name) + { + $this->app['config']['auth.driver'] = $name; + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Auth/AuthServiceProvider.php b/vendor/laravel/framework/src/Illuminate/Auth/AuthServiceProvider.php new file mode 100755 index 0000000..fc1dae1 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Auth/AuthServiceProvider.php @@ -0,0 +1,43 @@ +app->bindShared('auth', function($app) + { + // Once the authentication service has actually been requested by the developer + // we will set a variable in the application indicating such. This helps us + // know that we need to set any queued cookies in the after event later. + $app['auth.loaded'] = true; + + return new AuthManager($app); + }); + } + + + /** + * Get the services provided by the provider. + * + * @return array + */ + public function provides() + { + return array('auth'); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Auth/Console/ClearRemindersCommand.php b/vendor/laravel/framework/src/Illuminate/Auth/Console/ClearRemindersCommand.php new file mode 100755 index 0000000..8bb5cb2 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Auth/Console/ClearRemindersCommand.php @@ -0,0 +1,33 @@ +laravel['auth.reminder.repository']->deleteExpired(); + + $this->info('Expired reminders cleared!'); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Auth/Console/RemindersControllerCommand.php b/vendor/laravel/framework/src/Illuminate/Auth/Console/RemindersControllerCommand.php new file mode 100755 index 0000000..67f3bec --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Auth/Console/RemindersControllerCommand.php @@ -0,0 +1,65 @@ +files = $files; + } + + /** + * Execute the console command. + * + * @return void + */ + public function fire() + { + $destination = $this->laravel['path'].'/controllers/RemindersController.php'; + + if ( ! $this->files->exists($destination)) + { + $this->files->copy(__DIR__.'/stubs/controller.stub', $destination); + + $this->info('Password reminders controller created successfully!'); + + $this->comment("Route: Route::controller('password', 'RemindersController');"); + } + else + { + $this->error('Password reminders controller already exists!'); + } + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Auth/Console/RemindersTableCommand.php b/vendor/laravel/framework/src/Illuminate/Auth/Console/RemindersTableCommand.php new file mode 100755 index 0000000..c03801c --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Auth/Console/RemindersTableCommand.php @@ -0,0 +1,94 @@ +files = $files; + } + + /** + * Execute the console command. + * + * @return void + */ + public function fire() + { + $fullPath = $this->createBaseMigration(); + + $this->files->put($fullPath, $this->getMigrationStub()); + + $this->info('Migration created successfully!'); + + $this->call('dump-autoload'); + } + + /** + * Create a base migration file for the reminders. + * + * @return string + */ + protected function createBaseMigration() + { + $name = 'create_password_reminders_table'; + + $path = $this->laravel['path'].'/database/migrations'; + + return $this->laravel['migration.creator']->create($name, $path); + } + + /** + * Get the contents of the reminder migration stub. + * + * @return string + */ + protected function getMigrationStub() + { + $stub = $this->files->get(__DIR__.'/stubs/reminders.stub'); + + return str_replace('password_reminders', $this->getTable(), $stub); + } + + /** + * Get the password reminder table name. + * + * @return string + */ + protected function getTable() + { + return $this->laravel['config']->get('auth.reminder.table'); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Auth/Console/stubs/controller.stub b/vendor/laravel/framework/src/Illuminate/Auth/Console/stubs/controller.stub new file mode 100755 index 0000000..ac59e48 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Auth/Console/stubs/controller.stub @@ -0,0 +1,75 @@ +with('error', Lang::get($response)); + + case Password::REMINDER_SENT: + return Redirect::back()->with('status', Lang::get($response)); + } + } + + /** + * Display the password reset view for the given token. + * + * @param string $token + * @return Response + */ + public function getReset($token = null) + { + if (is_null($token)) App::abort(404); + + return View::make('password.reset')->with('token', $token); + } + + /** + * Handle a POST request to reset a user's password. + * + * @return Response + */ + public function postReset() + { + $credentials = Input::only( + 'email', 'password', 'password_confirmation', 'token' + ); + + $response = Password::reset($credentials, function($user, $password) + { + $user->password = Hash::make($password); + + $user->save(); + }); + + switch ($response) + { + case Password::INVALID_PASSWORD: + case Password::INVALID_TOKEN: + case Password::INVALID_USER: + return Redirect::back()->with('error', Lang::get($response)); + + case Password::PASSWORD_RESET: + return Redirect::to('/'); + } + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Auth/Console/stubs/reminders.stub b/vendor/laravel/framework/src/Illuminate/Auth/Console/stubs/reminders.stub new file mode 100755 index 0000000..dfbcf83 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Auth/Console/stubs/reminders.stub @@ -0,0 +1,33 @@ +string('email')->index(); + $table->string('token')->index(); + $table->timestamp('created_at'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::drop('password_reminders'); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Auth/DatabaseUserProvider.php b/vendor/laravel/framework/src/Illuminate/Auth/DatabaseUserProvider.php new file mode 100755 index 0000000..7a35c67 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Auth/DatabaseUserProvider.php @@ -0,0 +1,140 @@ +conn = $conn; + $this->table = $table; + $this->hasher = $hasher; + } + + /** + * Retrieve a user by their unique identifier. + * + * @param mixed $identifier + * @return \Illuminate\Auth\UserInterface|null + */ + public function retrieveById($identifier) + { + $user = $this->conn->table($this->table)->find($identifier); + + if ( ! is_null($user)) + { + return new GenericUser((array) $user); + } + } + + /** + * Retrieve a user by by their unique identifier and "remember me" token. + * + * @param mixed $identifier + * @param string $token + * @return \Illuminate\Auth\UserInterface|null + */ + public function retrieveByToken($identifier, $token) + { + $user = $this->conn->table($this->table) + ->where('id', $identifier) + ->where('remember_token', $token) + ->first(); + + if ( ! is_null($user)) + { + return new GenericUser((array) $user); + } + } + + /** + * Update the "remember me" token for the given user in storage. + * + * @param \Illuminate\Auth\UserInterface $user + * @param string $token + * @return void + */ + public function updateRememberToken(UserInterface $user, $token) + { + $this->conn->table($this->table) + ->where('id', $user->getAuthIdentifier()) + ->update(array('remember_token' => $token)); + } + + /** + * Retrieve a user by the given credentials. + * + * @param array $credentials + * @return \Illuminate\Auth\UserInterface|null + */ + public function retrieveByCredentials(array $credentials) + { + // First we will add each credential element to the query as a where clause. + // Then we can execute the query and, if we found a user, return it in a + // generic "user" object that will be utilized by the Guard instances. + $query = $this->conn->table($this->table); + + foreach ($credentials as $key => $value) + { + if ( ! str_contains($key, 'password')) + { + $query->where($key, $value); + } + } + + // Now we are ready to execute the query to see if we have an user matching + // the given credentials. If not, we will just return nulls and indicate + // that there are no matching users for these given credential arrays. + $user = $query->first(); + + if ( ! is_null($user)) + { + return new GenericUser((array) $user); + } + } + + /** + * Validate a user against the given credentials. + * + * @param \Illuminate\Auth\UserInterface $user + * @param array $credentials + * @return bool + */ + public function validateCredentials(UserInterface $user, array $credentials) + { + $plain = $credentials['password']; + + return $this->hasher->check($plain, $user->getAuthPassword()); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Auth/EloquentUserProvider.php b/vendor/laravel/framework/src/Illuminate/Auth/EloquentUserProvider.php new file mode 100755 index 0000000..a546add --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Auth/EloquentUserProvider.php @@ -0,0 +1,123 @@ +model = $model; + $this->hasher = $hasher; + } + + /** + * Retrieve a user by their unique identifier. + * + * @param mixed $identifier + * @return \Illuminate\Auth\UserInterface|null + */ + public function retrieveById($identifier) + { + return $this->createModel()->newQuery()->find($identifier); + } + + /** + * Retrieve a user by by their unique identifier and "remember me" token. + * + * @param mixed $identifier + * @param string $token + * @return \Illuminate\Auth\UserInterface|null + */ + public function retrieveByToken($identifier, $token) + { + $model = $this->createModel(); + + return $model->newQuery() + ->where($model->getKeyName(), $identifier) + ->where($model->getRememberTokenName(), $token) + ->first(); + } + + /** + * Update the "remember me" token for the given user in storage. + * + * @param \Illuminate\Auth\UserInterface $user + * @param string $token + * @return void + */ + public function updateRememberToken(UserInterface $user, $token) + { + $user->setAttribute($user->getRememberTokenName(), $token); + + $user->save(); + } + + /** + * Retrieve a user by the given credentials. + * + * @param array $credentials + * @return \Illuminate\Auth\UserInterface|null + */ + public function retrieveByCredentials(array $credentials) + { + // First we will add each credential element to the query as a where clause. + // Then we can execute the query and, if we found a user, return it in a + // Eloquent User "model" that will be utilized by the Guard instances. + $query = $this->createModel()->newQuery(); + + foreach ($credentials as $key => $value) + { + if ( ! str_contains($key, 'password')) $query->where($key, $value); + } + + return $query->first(); + } + + /** + * Validate a user against the given credentials. + * + * @param \Illuminate\Auth\UserInterface $user + * @param array $credentials + * @return bool + */ + public function validateCredentials(UserInterface $user, array $credentials) + { + $plain = $credentials['password']; + + return $this->hasher->check($plain, $user->getAuthPassword()); + } + + /** + * Create a new instance of the model. + * + * @return \Illuminate\Database\Eloquent\Model + */ + public function createModel() + { + $class = '\\'.ltrim($this->model, '\\'); + + return new $class; + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Auth/GenericUser.php b/vendor/laravel/framework/src/Illuminate/Auth/GenericUser.php new file mode 100755 index 0000000..d7a39b4 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Auth/GenericUser.php @@ -0,0 +1,119 @@ +attributes = $attributes; + } + + /** + * Get the unique identifier for the user. + * + * @return mixed + */ + public function getAuthIdentifier() + { + return $this->attributes['id']; + } + + /** + * Get the password for the user. + * + * @return string + */ + public function getAuthPassword() + { + return $this->attributes['password']; + } + + /** + * Get the token value for the "remember me" session. + * + * @return string + */ + public function getRememberToken() + { + return $this->attributes['remember_token']; + } + + /** + * Set the token value for the "remember me" session. + * + * @param string $value + * @return void + */ + public function setRememberToken($value) + { + $this->attributes['remember_token'] = $value; + } + + /** + * Get the column name for the "remember me" token. + * + * @return string + */ + public function getRememberTokenName() + { + return 'remember_token'; + } + + /** + * Dynamically access the user's attributes. + * + * @param string $key + * @return mixed + */ + public function __get($key) + { + return $this->attributes[$key]; + } + + /** + * Dynamically set an attribute on the user. + * + * @param string $key + * @param mixed $value + * @return void + */ + public function __set($key, $value) + { + $this->attributes[$key] = $value; + } + + /** + * Dynamically check if a value is set on the user. + * + * @param string $key + * @return bool + */ + public function __isset($key) + { + return isset($this->attributes[$key]); + } + + /** + * Dynamically unset a value on the user. + * + * @param string $key + * @return bool + */ + public function __unset($key) + { + unset($this->attributes[$key]); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Auth/Guard.php b/vendor/laravel/framework/src/Illuminate/Auth/Guard.php new file mode 100755 index 0000000..371e4a2 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Auth/Guard.php @@ -0,0 +1,741 @@ +session = $session; + $this->request = $request; + $this->provider = $provider; + } + + /** + * Determine if the current user is authenticated. + * + * @return bool + */ + public function check() + { + return ! is_null($this->user()); + } + + /** + * Determine if the current user is a guest. + * + * @return bool + */ + public function guest() + { + return ! $this->check(); + } + + /** + * Get the currently authenticated user. + * + * @return \Illuminate\Auth\UserInterface|null + */ + public function user() + { + if ($this->loggedOut) return; + + // If we have already retrieved the user for the current request we can just + // return it back immediately. We do not want to pull the user data every + // request into the method because that would tremendously slow an app. + if ( ! is_null($this->user)) + { + return $this->user; + } + + $id = $this->session->get($this->getName()); + + // First we will try to load the user using the identifier in the session if + // one exists. Otherwise we will check for a "remember me" cookie in this + // request, and if one exists, attempt to retrieve the user using that. + $user = null; + + if ( ! is_null($id)) + { + $user = $this->provider->retrieveByID($id); + } + + // If the user is null, but we decrypt a "recaller" cookie we can attempt to + // pull the user data on that cookie which serves as a remember cookie on + // the application. Once we have a user we can return it to the caller. + $recaller = $this->getRecaller(); + + if (is_null($user) && ! is_null($recaller)) + { + $user = $this->getUserByRecaller($recaller); + } + + return $this->user = $user; + } + + /** + * Get the ID for the currently authenticated user. + * + * @return int|null + */ + public function id() + { + if ($this->loggedOut) return; + + return $this->session->get($this->getName()) ?: $this->getRecallerId(); + } + + /** + * Pull a user from the repository by its recaller ID. + * + * @param string $recaller + * @return mixed + */ + protected function getUserByRecaller($recaller) + { + if ($this->validRecaller($recaller) && ! $this->tokenRetrievalAttempted) + { + $this->tokenRetrievalAttempted = true; + + list($id, $token) = explode('|', $recaller, 2); + + $this->viaRemember = ! is_null($user = $this->provider->retrieveByToken($id, $token)); + + return $user; + } + } + + /** + * Get the decrypted recaller cookie for the request. + * + * @return string|null + */ + protected function getRecaller() + { + return $this->request->cookies->get($this->getRecallerName()); + } + + /** + * Get the user ID from the recaller cookie. + * + * @return string + */ + protected function getRecallerId() + { + if ($this->validRecaller($recaller = $this->getRecaller())) + { + return head(explode('|', $recaller)); + } + } + + /** + * Determine if the recaller cookie is in a valid format. + * + * @param string $recaller + * @return bool + */ + protected function validRecaller($recaller) + { + if ( ! is_string($recaller) || ! str_contains($recaller, '|')) return false; + + $segments = explode('|', $recaller); + + return count($segments) == 2 && trim($segments[0]) !== '' && trim($segments[1]) !== ''; + } + + /** + * Log a user into the application without sessions or cookies. + * + * @param array $credentials + * @return bool + */ + public function once(array $credentials = array()) + { + if ($this->validate($credentials)) + { + $this->setUser($this->lastAttempted); + + return true; + } + + return false; + } + + /** + * Validate a user's credentials. + * + * @param array $credentials + * @return bool + */ + public function validate(array $credentials = array()) + { + return $this->attempt($credentials, false, false); + } + + /** + * Attempt to authenticate using HTTP Basic Auth. + * + * @param string $field + * @param \Symfony\Component\HttpFoundation\Request $request + * @return \Symfony\Component\HttpFoundation\Response|null + */ + public function basic($field = 'email', Request $request = null) + { + if ($this->check()) return; + + $request = $request ?: $this->getRequest(); + + // If a username is set on the HTTP basic request, we will return out without + // interrupting the request lifecycle. Otherwise, we'll need to generate a + // request indicating that the given credentials were invalid for login. + if ($this->attemptBasic($request, $field)) return; + + return $this->getBasicResponse(); + } + + /** + * Perform a stateless HTTP Basic login attempt. + * + * @param string $field + * @param \Symfony\Component\HttpFoundation\Request $request + * @return \Symfony\Component\HttpFoundation\Response|null + */ + public function onceBasic($field = 'email', Request $request = null) + { + $request = $request ?: $this->getRequest(); + + if ( ! $this->once($this->getBasicCredentials($request, $field))) + { + return $this->getBasicResponse(); + } + } + + /** + * Attempt to authenticate using basic authentication. + * + * @param \Symfony\Component\HttpFoundation\Request $request + * @param string $field + * @return bool + */ + protected function attemptBasic(Request $request, $field) + { + if ( ! $request->getUser()) return false; + + return $this->attempt($this->getBasicCredentials($request, $field)); + } + + /** + * Get the credential array for a HTTP Basic request. + * + * @param \Symfony\Component\HttpFoundation\Request $request + * @param string $field + * @return array + */ + protected function getBasicCredentials(Request $request, $field) + { + return array($field => $request->getUser(), 'password' => $request->getPassword()); + } + + /** + * Get the response for basic authentication. + * + * @return \Symfony\Component\HttpFoundation\Response + */ + protected function getBasicResponse() + { + $headers = array('WWW-Authenticate' => 'Basic'); + + return new Response('Invalid credentials.', 401, $headers); + } + + /** + * Attempt to authenticate a user using the given credentials. + * + * @param array $credentials + * @param bool $remember + * @param bool $login + * @return bool + */ + public function attempt(array $credentials = array(), $remember = false, $login = true) + { + $this->fireAttemptEvent($credentials, $remember, $login); + + $this->lastAttempted = $user = $this->provider->retrieveByCredentials($credentials); + + // If an implementation of UserInterface was returned, we'll ask the provider + // to validate the user against the given credentials, and if they are in + // fact valid we'll log the users into the application and return true. + if ($this->hasValidCredentials($user, $credentials)) + { + if ($login) $this->login($user, $remember); + + return true; + } + + return false; + } + + /** + * Determine if the user matches the credentials. + * + * @param mixed $user + * @param array $credentials + * @return bool + */ + protected function hasValidCredentials($user, $credentials) + { + return ! is_null($user) && $this->provider->validateCredentials($user, $credentials); + } + + /** + * Fire the attempt event with the arguments. + * + * @param array $credentials + * @param bool $remember + * @param bool $login + * @return void + */ + protected function fireAttemptEvent(array $credentials, $remember, $login) + { + if ($this->events) + { + $payload = array($credentials, $remember, $login); + + $this->events->fire('auth.attempt', $payload); + } + } + + /** + * Register an authentication attempt event listener. + * + * @param mixed $callback + * @return void + */ + public function attempting($callback) + { + if ($this->events) + { + $this->events->listen('auth.attempt', $callback); + } + } + + /** + * Log a user into the application. + * + * @param \Illuminate\Auth\UserInterface $user + * @param bool $remember + * @return void + */ + public function login(UserInterface $user, $remember = false) + { + $this->updateSession($user->getAuthIdentifier()); + + // If the user should be permanently "remembered" by the application we will + // queue a permanent cookie that contains the encrypted copy of the user + // identifier. We will then decrypt this later to retrieve the users. + if ($remember) + { + $this->createRememberTokenIfDoesntExist($user); + + $this->queueRecallerCookie($user); + } + + // If we have an event dispatcher instance set we will fire an event so that + // any listeners will hook into the authentication events and run actions + // based on the login and logout events fired from the guard instances. + if (isset($this->events)) + { + $this->events->fire('auth.login', array($user, $remember)); + } + + $this->setUser($user); + } + + /** + * Update the session with the given ID. + * + * @param string $id + * @return void + */ + protected function updateSession($id) + { + $this->session->put($this->getName(), $id); + + $this->session->migrate(true); + } + + /** + * Log the given user ID into the application. + * + * @param mixed $id + * @param bool $remember + * @return \Illuminate\Auth\UserInterface + */ + public function loginUsingId($id, $remember = false) + { + $this->session->put($this->getName(), $id); + + $this->login($user = $this->provider->retrieveById($id), $remember); + + return $user; + } + + /** + * Log the given user ID into the application without sessions or cookies. + * + * @param mixed $id + * @return bool + */ + public function onceUsingId($id) + { + $this->setUser($this->provider->retrieveById($id)); + + return $this->user instanceof UserInterface; + } + + /** + * Queue the recaller cookie into the cookie jar. + * + * @param \Illuminate\Auth\UserInterface $user + * @return void + */ + protected function queueRecallerCookie(UserInterface $user) + { + $value = $user->getAuthIdentifier().'|'.$user->getRememberToken(); + + $this->getCookieJar()->queue($this->createRecaller($value)); + } + + /** + * Create a remember me cookie for a given ID. + * + * @param string $value + * @return \Symfony\Component\HttpFoundation\Cookie + */ + protected function createRecaller($value) + { + return $this->getCookieJar()->forever($this->getRecallerName(), $value); + } + + /** + * Log the user out of the application. + * + * @return void + */ + public function logout() + { + $user = $this->user(); + + // If we have an event dispatcher instance, we can fire off the logout event + // so any further processing can be done. This allows the developer to be + // listening for anytime a user signs out of this application manually. + $this->clearUserDataFromStorage(); + + if ( ! is_null($this->user)) + { + $this->refreshRememberToken($user); + } + + if (isset($this->events)) + { + $this->events->fire('auth.logout', array($user)); + } + + // Once we have fired the logout event we will clear the users out of memory + // so they are no longer available as the user is no longer considered as + // being signed into this application and should not be available here. + $this->user = null; + + $this->loggedOut = true; + } + + /** + * Remove the user data from the session and cookies. + * + * @return void + */ + protected function clearUserDataFromStorage() + { + $this->session->forget($this->getName()); + + $recaller = $this->getRecallerName(); + + $this->getCookieJar()->queue($this->getCookieJar()->forget($recaller)); + } + + /** + * Refresh the remember token for the user. + * + * @param \Illuminate\Auth\UserInterface $user + * @return void + */ + protected function refreshRememberToken(UserInterface $user) + { + $user->setRememberToken($token = str_random(60)); + + $this->provider->updateRememberToken($user, $token); + } + + /** + * Create a new remember token for the user if one doesn't already exist. + * + * @param \Illuminate\Auth\UserInterface $user + * @return void + */ + protected function createRememberTokenIfDoesntExist(UserInterface $user) + { + if (is_null($user->getRememberToken())) + { + $this->refreshRememberToken($user); + } + } + + /** + * Get the cookie creator instance used by the guard. + * + * @return \Illuminate\Cookie\CookieJar + * + * @throws \RuntimeException + */ + public function getCookieJar() + { + if ( ! isset($this->cookie)) + { + throw new \RuntimeException("Cookie jar has not been set."); + } + + return $this->cookie; + } + + /** + * Set the cookie creator instance used by the guard. + * + * @param \Illuminate\Cookie\CookieJar $cookie + * @return void + */ + public function setCookieJar(CookieJar $cookie) + { + $this->cookie = $cookie; + } + + /** + * Get the event dispatcher instance. + * + * @return \Illuminate\Events\Dispatcher + */ + public function getDispatcher() + { + return $this->events; + } + + /** + * Set the event dispatcher instance. + * + * @param \Illuminate\Events\Dispatcher + */ + public function setDispatcher(Dispatcher $events) + { + $this->events = $events; + } + + /** + * Get the session store used by the guard. + * + * @return \Illuminate\Session\Store + */ + public function getSession() + { + return $this->session; + } + + /** + * Get the user provider used by the guard. + * + * @return \Illuminate\Auth\UserProviderInterface + */ + public function getProvider() + { + return $this->provider; + } + + /** + * Set the user provider used by the guard. + * + * @param \Illuminate\Auth\UserProviderInterface $provider + * @return void + */ + public function setProvider(UserProviderInterface $provider) + { + $this->provider = $provider; + } + + /** + * Return the currently cached user of the application. + * + * @return \Illuminate\Auth\UserInterface|null + */ + public function getUser() + { + return $this->user; + } + + /** + * Set the current user of the application. + * + * @param \Illuminate\Auth\UserInterface $user + * @return void + */ + public function setUser(UserInterface $user) + { + $this->user = $user; + + $this->loggedOut = false; + } + + /** + * Get the current request instance. + * + * @return \Symfony\Component\HttpFoundation\Request + */ + public function getRequest() + { + return $this->request ?: Request::createFromGlobals(); + } + + /** + * Set the current request instance. + * + * @param \Symfony\Component\HttpFoundation\Request + * @return \Illuminate\Auth\Guard + */ + public function setRequest(Request $request) + { + $this->request = $request; + + return $this; + } + + /** + * Get the last user we attempted to authenticate. + * + * @return \Illuminate\Auth\UserInterface + */ + public function getLastAttempted() + { + return $this->lastAttempted; + } + + /** + * Get a unique identifier for the auth session value. + * + * @return string + */ + public function getName() + { + return 'login_'.md5(get_class($this)); + } + + /** + * Get the name of the cookie used to store the "recaller". + * + * @return string + */ + public function getRecallerName() + { + return 'remember_'.md5(get_class($this)); + } + + /** + * Determine if the user was authenticated via "remember me" cookie. + * + * @return bool + */ + public function viaRemember() + { + return $this->viaRemember; + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Auth/Reminders/DatabaseReminderRepository.php b/vendor/laravel/framework/src/Illuminate/Auth/Reminders/DatabaseReminderRepository.php new file mode 100755 index 0000000..299e936 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Auth/Reminders/DatabaseReminderRepository.php @@ -0,0 +1,182 @@ +table = $table; + $this->hashKey = $hashKey; + $this->expires = $expires * 60; + $this->connection = $connection; + } + + /** + * Create a new reminder record and token. + * + * @param \Illuminate\Auth\Reminders\RemindableInterface $user + * @return string + */ + public function create(RemindableInterface $user) + { + $email = $user->getReminderEmail(); + + // We will create a new, random token for the user so that we can e-mail them + // a safe link to the password reset form. Then we will insert a record in + // the database so that we can verify the token within the actual reset. + $token = $this->createNewToken($user); + + $this->getTable()->insert($this->getPayload($email, $token)); + + return $token; + } + + /** + * Build the record payload for the table. + * + * @param string $email + * @param string $token + * @return array + */ + protected function getPayload($email, $token) + { + return array('email' => $email, 'token' => $token, 'created_at' => new Carbon); + } + + /** + * Determine if a reminder record exists and is valid. + * + * @param \Illuminate\Auth\Reminders\RemindableInterface $user + * @param string $token + * @return bool + */ + public function exists(RemindableInterface $user, $token) + { + $email = $user->getReminderEmail(); + + $reminder = (array) $this->getTable()->where('email', $email)->where('token', $token)->first(); + + return $reminder && ! $this->reminderExpired($reminder); + } + + /** + * Determine if the reminder has expired. + * + * @param array $reminder + * @return bool + */ + protected function reminderExpired($reminder) + { + $createdPlusHour = strtotime($reminder['created_at']) + $this->expires; + + return $createdPlusHour < $this->getCurrentTime(); + } + + /** + * Get the current UNIX timestamp. + * + * @return int + */ + protected function getCurrentTime() + { + return time(); + } + + /** + * Delete a reminder record by token. + * + * @param string $token + * @return void + */ + public function delete($token) + { + $this->getTable()->where('token', $token)->delete(); + } + + /** + * Delete expired reminders. + * + * @return void + */ + public function deleteExpired() + { + $expired = Carbon::now()->subSeconds($this->expires); + + $this->getTable()->where('created_at', '<', $expired)->delete(); + } + + /** + * Create a new token for the user. + * + * @param \Illuminate\Auth\Reminders\RemindableInterface $user + * @return string + */ + public function createNewToken(RemindableInterface $user) + { + $email = $user->getReminderEmail(); + + $value = str_shuffle(sha1($email.spl_object_hash($this).microtime(true))); + + return hash_hmac('sha1', $value, $this->hashKey); + } + + /** + * Begin a new database query against the table. + * + * @return \Illuminate\Database\Query\Builder + */ + protected function getTable() + { + return $this->connection->table($this->table); + } + + /** + * Get the database connection instance. + * + * @return \Illuminate\Database\Connection + */ + public function getConnection() + { + return $this->connection; + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Auth/Reminders/PasswordBroker.php b/vendor/laravel/framework/src/Illuminate/Auth/Reminders/PasswordBroker.php new file mode 100755 index 0000000..4f6d5c5 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Auth/Reminders/PasswordBroker.php @@ -0,0 +1,284 @@ +users = $users; + $this->mailer = $mailer; + $this->reminders = $reminders; + $this->reminderView = $reminderView; + } + + /** + * Send a password reminder to a user. + * + * @param array $credentials + * @param Closure $callback + * @return string + */ + public function remind(array $credentials, Closure $callback = null) + { + // First we will check to see if we found a user at the given credentials and + // if we did not we will redirect back to this current URI with a piece of + // "flash" data in the session to indicate to the developers the errors. + $user = $this->getUser($credentials); + + if (is_null($user)) + { + return self::INVALID_USER; + } + + // Once we have the reminder token, we are ready to send a message out to the + // user with a link to reset their password. We will then redirect back to + // the current URI having nothing set in the session to indicate errors. + $token = $this->reminders->create($user); + + $this->sendReminder($user, $token, $callback); + + return self::REMINDER_SENT; + } + + /** + * Send the password reminder e-mail. + * + * @param \Illuminate\Auth\Reminders\RemindableInterface $user + * @param string $token + * @param Closure $callback + * @return int + */ + public function sendReminder(RemindableInterface $user, $token, Closure $callback = null) + { + // We will use the reminder view that was given to the broker to display the + // password reminder e-mail. We'll pass a "token" variable into the views + // so that it may be displayed for an user to click for password reset. + $view = $this->reminderView; + + return $this->mailer->send($view, compact('token', 'user'), function($m) use ($user, $token, $callback) + { + $m->to($user->getReminderEmail()); + + if ( ! is_null($callback)) call_user_func($callback, $m, $user, $token); + }); + } + + /** + * Reset the password for the given token. + * + * @param array $credentials + * @param Closure $callback + * @return mixed + */ + public function reset(array $credentials, Closure $callback) + { + // If the responses from the validate method is not a user instance, we will + // assume that it is a redirect and simply return it from this method and + // the user is properly redirected having an error message on the post. + $user = $this->validateReset($credentials); + + if ( ! $user instanceof RemindableInterface) + { + return $user; + } + + $pass = $credentials['password']; + + // Once we have called this callback, we will remove this token row from the + // table and return the response from this callback so the user gets sent + // to the destination given by the developers from the callback return. + call_user_func($callback, $user, $pass); + + $this->reminders->delete($credentials['token']); + + return self::PASSWORD_RESET; + } + + /** + * Validate a password reset for the given credentials. + * + * @param array $credentials + * @return \Illuminate\Auth\Reminders\RemindableInterface + */ + protected function validateReset(array $credentials) + { + if (is_null($user = $this->getUser($credentials))) + { + return self::INVALID_USER; + } + + if ( ! $this->validNewPasswords($credentials)) + { + return self::INVALID_PASSWORD; + } + + if ( ! $this->reminders->exists($user, $credentials['token'])) + { + return self::INVALID_TOKEN; + } + + return $user; + } + + /** + * Set a custom password validator. + * + * @param \Closure $callback + * @return void + */ + public function validator(Closure $callback) + { + $this->passwordValidator = $callback; + } + + /** + * Determine if the passwords match for the request. + * + * @param array $credentials + * @return bool + */ + protected function validNewPasswords(array $credentials) + { + list($password, $confirm) = array($credentials['password'], $credentials['password_confirmation']); + + if (isset($this->passwordValidator)) + { + return call_user_func($this->passwordValidator, $credentials) && $password == $confirm; + } + else + { + return $this->validatePasswordWithDefaults($credentials); + } + } + + /** + * Determine if the passwords are valid for the request. + * + * @param array $credentials + * @return bool + */ + protected function validatePasswordWithDefaults(array $credentials) + { + $matches = $credentials['password'] == $credentials['password_confirmation']; + + return $matches && $credentials['password'] && strlen($credentials['password']) >= 6; + } + + /** + * Get the user for the given credentials. + * + * @param array $credentials + * @return \Illuminate\Auth\Reminders\RemindableInterface + * + * @throws \UnexpectedValueException + */ + public function getUser(array $credentials) + { + $credentials = array_except($credentials, array('token')); + + $user = $this->users->retrieveByCredentials($credentials); + + if ($user && ! $user instanceof RemindableInterface) + { + throw new \UnexpectedValueException("User must implement Remindable interface."); + } + + return $user; + } + + /** + * Get the password reminder repository implementation. + * + * @return \Illuminate\Auth\Reminders\ReminderRepositoryInterface + */ + protected function getRepository() + { + return $this->reminders; + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Auth/Reminders/RemindableInterface.php b/vendor/laravel/framework/src/Illuminate/Auth/Reminders/RemindableInterface.php new file mode 100755 index 0000000..645fa87 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Auth/Reminders/RemindableInterface.php @@ -0,0 +1,12 @@ +registerPasswordBroker(); + + $this->registerReminderRepository(); + + $this->registerCommands(); + } + + /** + * Register the password broker instance. + * + * @return void + */ + protected function registerPasswordBroker() + { + $this->app->bindShared('auth.reminder', function($app) + { + // The reminder repository is responsible for storing the user e-mail addresses + // and password reset tokens. It will be used to verify the tokens are valid + // for the given e-mail addresses. We will resolve an implementation here. + $reminders = $app['auth.reminder.repository']; + + $users = $app['auth']->driver()->getProvider(); + + $view = $app['config']['auth.reminder.email']; + + // The password broker uses the reminder repository to validate tokens and send + // reminder e-mails, as well as validating that password reset process as an + // aggregate service of sorts providing a convenient interface for resets. + return new PasswordBroker( + + $reminders, $users, $app['mailer'], $view + + ); + }); + } + + /** + * Register the reminder repository implementation. + * + * @return void + */ + protected function registerReminderRepository() + { + $this->app->bindShared('auth.reminder.repository', function($app) + { + $connection = $app['db']->connection(); + + // The database reminder repository is an implementation of the reminder repo + // interface, and is responsible for the actual storing of auth tokens and + // their e-mail addresses. We will inject this table and hash key to it. + $table = $app['config']['auth.reminder.table']; + + $key = $app['config']['app.key']; + + $expire = $app['config']->get('auth.reminder.expire', 60); + + return new DbRepository($connection, $table, $key, $expire); + }); + } + + /** + * Register the auth related console commands. + * + * @return void + */ + protected function registerCommands() + { + $this->app->bindShared('command.auth.reminders', function($app) + { + return new RemindersTableCommand($app['files']); + }); + + $this->app->bindShared('command.auth.reminders.clear', function($app) + { + return new ClearRemindersCommand; + }); + + $this->app->bindShared('command.auth.reminders.controller', function($app) + { + return new RemindersControllerCommand($app['files']); + }); + + $this->commands( + 'command.auth.reminders', 'command.auth.reminders.clear', 'command.auth.reminders.controller' + ); + } + + /** + * Get the services provided by the provider. + * + * @return array + */ + public function provides() + { + return array('auth.reminder', 'auth.reminder.repository', 'command.auth.reminders'); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Auth/UserInterface.php b/vendor/laravel/framework/src/Illuminate/Auth/UserInterface.php new file mode 100755 index 0000000..b2740a6 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Auth/UserInterface.php @@ -0,0 +1,41 @@ +=5.3.0", + "illuminate/cookie": "4.1.*", + "illuminate/encryption": "4.1.*", + "illuminate/events": "4.1.*", + "illuminate/hashing": "4.1.*", + "illuminate/http": "4.1.*", + "illuminate/session": "4.1.*", + "illuminate/support": "4.1.*", + "nesbot/carbon": "1.*" + }, + "require-dev": { + "illuminate/console": "4.1.*", + "illuminate/routing": "4.1.*", + "phpunit/phpunit": "4.0.*" + }, + "autoload": { + "psr-0": {"Illuminate\\Auth": ""} + }, + "target-dir": "Illuminate/Auth", + "extra": { + "branch-alias": { + "dev-master": "4.1-dev" + } + }, + "minimum-stability": "dev" +} diff --git a/vendor/laravel/framework/src/Illuminate/Cache/ApcStore.php b/vendor/laravel/framework/src/Illuminate/Cache/ApcStore.php new file mode 100755 index 0000000..d81282d --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Cache/ApcStore.php @@ -0,0 +1,128 @@ +apc = $apc; + $this->prefix = $prefix; + } + + /** + * Retrieve an item from the cache by key. + * + * @param string $key + * @return mixed + */ + public function get($key) + { + $value = $this->apc->get($this->prefix.$key); + + if ($value !== false) + { + return $value; + } + } + + /** + * Store an item in the cache for a given number of minutes. + * + * @param string $key + * @param mixed $value + * @param int $minutes + * @return array|bool + */ + public function put($key, $value, $minutes) + { + $this->apc->put($this->prefix.$key, $value, $minutes * 60); + } + + /** + * Increment the value of an item in the cache. + * + * @param string $key + * @param mixed $value + * @return array|bool + */ + public function increment($key, $value = 1) + { + return $this->apc->increment($this->prefix.$key, $value); + } + + /** + * Decrement the value of an item in the cache. + * + * @param string $key + * @param mixed $value + * @return array|bool + */ + public function decrement($key, $value = 1) + { + return $this->apc->decrement($this->prefix.$key, $value); + } + + /** + * Store an item in the cache indefinitely. + * + * @param string $key + * @param mixed $value + * @return array|bool + */ + public function forever($key, $value) + { + return $this->put($key, $value, 0); + } + + /** + * Remove an item from the cache. + * + * @param string $key + * @return array|bool + */ + public function forget($key) + { + $this->apc->delete($this->prefix.$key); + } + + /** + * Remove all items from the cache. + * + * @return void + */ + public function flush() + { + $this->apc->flush(); + } + + /** + * Get the cache key prefix. + * + * @return string + */ + public function getPrefix() + { + return $this->prefix; + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Cache/ApcWrapper.php b/vendor/laravel/framework/src/Illuminate/Cache/ApcWrapper.php new file mode 100755 index 0000000..891f19b --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Cache/ApcWrapper.php @@ -0,0 +1,91 @@ +apcu = function_exists('apcu_fetch'); + } + + /** + * Get an item from the cache. + * + * @param string $key + * @return mixed + */ + public function get($key) + { + return $this->apcu ? apcu_fetch($key) : apc_fetch($key); + } + + /** + * Store an item in the cache. + * + * @param string $key + * @param mixed $value + * @param int $seconds + * @return array|bool + */ + public function put($key, $value, $seconds) + { + return $this->apcu ? apcu_store($key, $value, $seconds) : apc_store($key, $value, $seconds); + } + + /** + * Increment the value of an item in the cache. + * + * @param string $key + * @param mixed $value + * @return array|bool + */ + public function increment($key, $value) + { + return $this->apcu ? apcu_inc($key, $value) : apc_inc($key, $value); + } + + /** + * Decrement the value of an item in the cache. + * + * @param string $key + * @param mixed $value + * @return array|bool + */ + public function decrement($key, $value) + { + return $this->apcu ? apcu_dec($key, $value) : apc_dec($key, $value); + } + + /** + * Remove an item from the cache. + * + * @param string $key + * @return array|bool + */ + public function delete($key) + { + return $this->apcu ? apcu_delete($key) : apc_delete($key); + } + + /** + * Remove all items from the cache. + * + * @return void + */ + public function flush() + { + $this->apcu ? apcu_clear_cache() : apc_clear_cache('user'); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Cache/ArrayStore.php b/vendor/laravel/framework/src/Illuminate/Cache/ArrayStore.php new file mode 100755 index 0000000..3afb2bc --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Cache/ArrayStore.php @@ -0,0 +1,110 @@ +storage)) + { + return $this->storage[$key]; + } + } + + /** + * Store an item in the cache for a given number of minutes. + * + * @param string $key + * @param mixed $value + * @param int $minutes + * @return void + */ + public function put($key, $value, $minutes) + { + $this->storage[$key] = $value; + } + + /** + * Increment the value of an item in the cache. + * + * @param string $key + * @param mixed $value + * @return void + */ + public function increment($key, $value = 1) + { + $this->storage[$key] = $this->storage[$key] + $value; + + return $this->storage[$key]; + } + + /** + * Increment the value of an item in the cache. + * + * @param string $key + * @param mixed $value + * @return void + */ + public function decrement($key, $value = 1) + { + $this->storage[$key] = $this->storage[$key] - $value; + + return $this->storage[$key]; + } + + /** + * Store an item in the cache indefinitely. + * + * @param string $key + * @param mixed $value + * @return void + */ + public function forever($key, $value) + { + return $this->put($key, $value, 0); + } + + /** + * Remove an item from the cache. + * + * @param string $key + * @return void + */ + public function forget($key) + { + unset($this->storage[$key]); + } + + /** + * Remove all items from the cache. + * + * @return void + */ + public function flush() + { + $this->storage = array(); + } + + /** + * Get the cache key prefix. + * + * @return string + */ + public function getPrefix() + { + return ''; + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Cache/CacheManager.php b/vendor/laravel/framework/src/Illuminate/Cache/CacheManager.php new file mode 100755 index 0000000..fd9e99f --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Cache/CacheManager.php @@ -0,0 +1,171 @@ +repository(new ApcStore(new ApcWrapper, $this->getPrefix())); + } + + /** + * Create an instance of the array cache driver. + * + * @return \Illuminate\Cache\ArrayStore + */ + protected function createArrayDriver() + { + return $this->repository(new ArrayStore); + } + + /** + * Create an instance of the file cache driver. + * + * @return \Illuminate\Cache\FileStore + */ + protected function createFileDriver() + { + $path = $this->app['config']['cache.path']; + + return $this->repository(new FileStore($this->app['files'], $path)); + } + + /** + * Create an instance of the Memcached cache driver. + * + * @return \Illuminate\Cache\MemcachedStore + */ + protected function createMemcachedDriver() + { + $servers = $this->app['config']['cache.memcached']; + + $memcached = $this->app['memcached.connector']->connect($servers); + + return $this->repository(new MemcachedStore($memcached, $this->getPrefix())); + } + + /** + * Create an instance of the WinCache cache driver. + * + * @return \Illuminate\Cache\WinCacheStore + */ + protected function createWincacheDriver() + { + return $this->repository(new WinCacheStore($this->getPrefix())); + } + + /** + * Create an instance of the XCache cache driver. + * + * @return \Illuminate\Cache\WinCacheStore + */ + protected function createXcacheDriver() + { + return $this->repository(new XCacheStore($this->getPrefix())); + } + + /** + * Create an instance of the Redis cache driver. + * + * @return \Illuminate\Cache\RedisStore + */ + protected function createRedisDriver() + { + $redis = $this->app['redis']; + + return $this->repository(new RedisStore($redis, $this->getPrefix())); + } + + /** + * Create an instance of the database cache driver. + * + * @return \Illuminate\Cache\DatabaseStore + */ + protected function createDatabaseDriver() + { + $connection = $this->getDatabaseConnection(); + + $encrypter = $this->app['encrypter']; + + // We allow the developer to specify which connection and table should be used + // to store the cached items. We also need to grab a prefix in case a table + // is being used by multiple applications although this is very unlikely. + $table = $this->app['config']['cache.table']; + + $prefix = $this->getPrefix(); + + return $this->repository(new DatabaseStore($connection, $encrypter, $table, $prefix)); + } + + /** + * Get the database connection for the database driver. + * + * @return \Illuminate\Database\Connection + */ + protected function getDatabaseConnection() + { + $connection = $this->app['config']['cache.connection']; + + return $this->app['db']->connection($connection); + } + + /** + * Get the cache "prefix" value. + * + * @return string + */ + public function getPrefix() + { + return $this->app['config']['cache.prefix']; + } + + /** + * Set the cache "prefix" value. + * + * @param string $name + * @return void + */ + public function setPrefix($name) + { + $this->app['config']['cache.prefix'] = $name; + } + + /** + * Create a new cache repository with the given implementation. + * + * @param \Illuminate\Cache\StoreInterface $store + * @return \Illuminate\Cache\Repository + */ + protected function repository(StoreInterface $store) + { + return new Repository($store); + } + + /** + * Get the default cache driver name. + * + * @return string + */ + public function getDefaultDriver() + { + return $this->app['config']['cache.driver']; + } + + /** + * Set the default cache driver name. + * + * @param string $name + * @return void + */ + public function setDefaultDriver($name) + { + $this->app['config']['cache.driver'] = $name; + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Cache/CacheServiceProvider.php b/vendor/laravel/framework/src/Illuminate/Cache/CacheServiceProvider.php new file mode 100755 index 0000000..cd77a0b --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Cache/CacheServiceProvider.php @@ -0,0 +1,64 @@ +app->bindShared('cache', function($app) + { + return new CacheManager($app); + }); + + $this->app->bindShared('cache.store', function($app) + { + return $app['cache']->driver(); + }); + + $this->app->bindShared('memcached.connector', function() + { + return new MemcachedConnector; + }); + + $this->registerCommands(); + } + + /** + * Register the cache related console commands. + * + * @return void + */ + public function registerCommands() + { + $this->app->bindShared('command.cache.clear', function($app) + { + return new Console\ClearCommand($app['cache'], $app['files']); + }); + + $this->commands('command.cache.clear'); + } + + /** + * Get the services provided by the provider. + * + * @return array + */ + public function provides() + { + return array('cache', 'cache.store', 'memcached.connector', 'command.cache.clear'); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Cache/Console/ClearCommand.php b/vendor/laravel/framework/src/Illuminate/Cache/Console/ClearCommand.php new file mode 100755 index 0000000..c64cf09 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Cache/Console/ClearCommand.php @@ -0,0 +1,66 @@ +cache = $cache; + $this->files = $files; + } + + /** + * Execute the console command. + * + * @return void + */ + public function fire() + { + $this->cache->flush(); + + $this->files->delete($this->laravel['config']['app.manifest'].'/services.json'); + + $this->info('Application cache cleared!'); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Cache/DatabaseStore.php b/vendor/laravel/framework/src/Illuminate/Cache/DatabaseStore.php new file mode 100755 index 0000000..4df44bf --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Cache/DatabaseStore.php @@ -0,0 +1,221 @@ +table = $table; + $this->prefix = $prefix; + $this->encrypter = $encrypter; + $this->connection = $connection; + } + + /** + * Retrieve an item from the cache by key. + * + * @param string $key + * @return mixed + */ + public function get($key) + { + $prefixed = $this->prefix.$key; + + $cache = $this->table()->where('key', '=', $prefixed)->first(); + + // If we have a cache record we will check the expiration time against current + // time on the system and see if the record has expired. If it has, we will + // remove the records from the database table so it isn't returned again. + if ( ! is_null($cache)) + { + if (is_array($cache)) $cache = (object) $cache; + + if (time() >= $cache->expiration) + { + return $this->forget($key); + } + + return $this->encrypter->decrypt($cache->value); + } + } + + /** + * Store an item in the cache for a given number of minutes. + * + * @param string $key + * @param mixed $value + * @param int $minutes + * @return void + */ + public function put($key, $value, $minutes) + { + $key = $this->prefix.$key; + + // All of the cached values in the database are encrypted in case this is used + // as a session data store by the consumer. We'll also calculate the expire + // time and place that on the table so we will check it on our retrieval. + $value = $this->encrypter->encrypt($value); + + $expiration = $this->getTime() + ($minutes * 60); + + try + { + $this->table()->insert(compact('key', 'value', 'expiration')); + } + catch (\Exception $e) + { + $this->table()->where('key', '=', $key)->update(compact('value', 'expiration')); + } + } + + /** + * Increment the value of an item in the cache. + * + * @param string $key + * @param mixed $value + * @return void + * + * @throws \LogicException + */ + public function increment($key, $value = 1) + { + throw new \LogicException("Increment operations not supported by this driver."); + } + + /** + * Increment the value of an item in the cache. + * + * @param string $key + * @param mixed $value + * @return void + * + * @throws \LogicException + */ + public function decrement($key, $value = 1) + { + throw new \LogicException("Decrement operations not supported by this driver."); + } + + /** + * Get the current system time. + * + * @return int + */ + protected function getTime() + { + return time(); + } + + /** + * Store an item in the cache indefinitely. + * + * @param string $key + * @param mixed $value + * @return void + */ + public function forever($key, $value) + { + return $this->put($key, $value, 5256000); + } + + /** + * Remove an item from the cache. + * + * @param string $key + * @return void + */ + public function forget($key) + { + $this->table()->where('key', '=', $this->prefix.$key)->delete(); + } + + /** + * Remove all items from the cache. + * + * @return void + */ + public function flush() + { + $this->table()->delete(); + } + + /** + * Get a query builder for the cache table. + * + * @return \Illuminate\Database\Query\Builder + */ + protected function table() + { + return $this->connection->table($this->table); + } + + /** + * Get the underlying database connection. + * + * @return \Illuminate\Database\Connection + */ + public function getConnection() + { + return $this->connection; + } + + /** + * Get the encrypter instance. + * + * @return \Illuminate\Encryption\Encrypter + */ + public function getEncrypter() + { + return $this->encrypter; + } + + /** + * Get the cache key prefix. + * + * @return string + */ + public function getPrefix() + { + return $this->prefix; + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Cache/FileStore.php b/vendor/laravel/framework/src/Illuminate/Cache/FileStore.php new file mode 100755 index 0000000..5c794b5 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Cache/FileStore.php @@ -0,0 +1,232 @@ +files = $files; + $this->directory = $directory; + } + + /** + * Retrieve an item from the cache by key. + * + * @param string $key + * @return mixed + */ + public function get($key) + { + $path = $this->path($key); + + // If the file doesn't exists, we obviously can't return the cache so we will + // just return null. Otherwise, we'll get the contents of the file and get + // the expiration UNIX timestamps from the start of the file's contents. + if ( ! $this->files->exists($path)) + { + return null; + } + + try + { + $expire = substr($contents = $this->files->get($path), 0, 10); + } + catch (\Exception $e) + { + return null; + } + + // If the current time is greater than expiration timestamps we will delete + // the file and return null. This helps clean up the old files and keeps + // this directory much cleaner for us as old files aren't hanging out. + if (time() >= $expire) + { + return $this->forget($key); + } + + return unserialize(substr($contents, 10)); + } + + /** + * Store an item in the cache for a given number of minutes. + * + * @param string $key + * @param mixed $value + * @param int $minutes + * @return void + */ + public function put($key, $value, $minutes) + { + $value = $this->expiration($minutes).serialize($value); + + $this->createCacheDirectory($path = $this->path($key)); + + $this->files->put($path, $value); + } + + /** + * Create the file cache directory if necessary. + * + * @param string $path + * @return void + */ + protected function createCacheDirectory($path) + { + try + { + $this->files->makeDirectory(dirname($path), 0777, true, true); + } + catch (\Exception $e) + { + // + } + } + + /** + * Increment the value of an item in the cache. + * + * @param string $key + * @param mixed $value + * @return void + * + * @throws \LogicException + */ + public function increment($key, $value = 1) + { + throw new \LogicException("Increment operations not supported by this driver."); + } + + /** + * Decrement the value of an item in the cache. + * + * @param string $key + * @param mixed $value + * @return void + * + * @throws \LogicException + */ + public function decrement($key, $value = 1) + { + throw new \LogicException("Decrement operations not supported by this driver."); + } + + /** + * Store an item in the cache indefinitely. + * + * @param string $key + * @param mixed $value + * @return void + */ + public function forever($key, $value) + { + return $this->put($key, $value, 0); + } + + /** + * Remove an item from the cache. + * + * @param string $key + * @return void + */ + public function forget($key) + { + $file = $this->path($key); + + if ($this->files->exists($file)) + { + $this->files->delete($file); + } + } + + /** + * Remove all items from the cache. + * + * @return void + */ + public function flush() + { + foreach ($this->files->directories($this->directory) as $directory) + { + $this->files->deleteDirectory($directory); + } + } + + /** + * Get the full path for the given cache key. + * + * @param string $key + * @return string + */ + protected function path($key) + { + $parts = array_slice(str_split($hash = md5($key), 2), 0, 2); + + return $this->directory.'/'.join('/', $parts).'/'.$hash; + } + + /** + * Get the expiration time based on the given minutes. + * + * @param int $minutes + * @return int + */ + protected function expiration($minutes) + { + if ($minutes === 0) return 9999999999; + + return time() + ($minutes * 60); + } + + /** + * Get the Filesystem instance. + * + * @return \Illuminate\Filesystem\Filesystem + */ + public function getFilesystem() + { + return $this->files; + } + + /** + * Get the working directory of the cache. + * + * @return string + */ + public function getDirectory() + { + return $this->directory; + } + + /** + * Get the cache key prefix. + * + * @return string + */ + public function getPrefix() + { + return ''; + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Cache/MemcachedConnector.php b/vendor/laravel/framework/src/Illuminate/Cache/MemcachedConnector.php new file mode 100755 index 0000000..92272d0 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Cache/MemcachedConnector.php @@ -0,0 +1,47 @@ +getMemcached(); + + // For each server in the array, we'll just extract the configuration and add + // the server to the Memcached connection. Once we have added all of these + // servers we'll verify the connection is successful and return it back. + foreach ($servers as $server) + { + $memcached->addServer( + $server['host'], $server['port'], $server['weight'] + ); + } + + if ($memcached->getVersion() === false) + { + throw new \RuntimeException("Could not establish Memcached connection."); + } + + return $memcached; + } + + /** + * Get a new Memcached instance. + * + * @return \Memcached + */ + protected function getMemcached() + { + return new Memcached; + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Cache/MemcachedStore.php b/vendor/laravel/framework/src/Illuminate/Cache/MemcachedStore.php new file mode 100755 index 0000000..6537c09 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Cache/MemcachedStore.php @@ -0,0 +1,140 @@ +memcached = $memcached; + $this->prefix = strlen($prefix) > 0 ? $prefix.':' : ''; + } + + /** + * Retrieve an item from the cache by key. + * + * @param string $key + * @return mixed + */ + public function get($key) + { + $value = $this->memcached->get($this->prefix.$key); + + if ($this->memcached->getResultCode() == 0) + { + return $value; + } + } + + /** + * Store an item in the cache for a given number of minutes. + * + * @param string $key + * @param mixed $value + * @param int $minutes + * @return void + */ + public function put($key, $value, $minutes) + { + $this->memcached->set($this->prefix.$key, $value, $minutes * 60); + } + + /** + * Increment the value of an item in the cache. + * + * @param string $key + * @param mixed $value + * @return void + */ + public function increment($key, $value = 1) + { + return $this->memcached->increment($this->prefix.$key, $value); + } + + /** + * Decrement the value of an item in the cache. + * + * @param string $key + * @param mixed $value + * @return void + */ + public function decrement($key, $value = 1) + { + return $this->memcached->decrement($this->prefix.$key, $value); + } + + /** + * Store an item in the cache indefinitely. + * + * @param string $key + * @param mixed $value + * @return void + */ + public function forever($key, $value) + { + return $this->put($key, $value, 0); + } + + /** + * Remove an item from the cache. + * + * @param string $key + * @return void + */ + public function forget($key) + { + $this->memcached->delete($this->prefix.$key); + } + + /** + * Remove all items from the cache. + * + * @return void + */ + public function flush() + { + $this->memcached->flush(); + } + + /** + * Get the underlying Memcached connection. + * + * @return \Memcached + */ + public function getMemcached() + { + return $this->memcached; + } + + /** + * Get the cache key prefix. + * + * @return string + */ + public function getPrefix() + { + return $this->prefix; + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Cache/RedisStore.php b/vendor/laravel/framework/src/Illuminate/Cache/RedisStore.php new file mode 100755 index 0000000..3fd1575 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Cache/RedisStore.php @@ -0,0 +1,185 @@ +redis = $redis; + $this->connection = $connection; + $this->prefix = strlen($prefix) > 0 ? $prefix.':' : ''; + } + + /** + * Retrieve an item from the cache by key. + * + * @param string $key + * @return mixed + */ + public function get($key) + { + if ( ! is_null($value = $this->connection()->get($this->prefix.$key))) + { + return is_numeric($value) ? $value : unserialize($value); + } + } + + /** + * Store an item in the cache for a given number of minutes. + * + * @param string $key + * @param mixed $value + * @param int $minutes + * @return void + */ + public function put($key, $value, $minutes) + { + $value = is_numeric($value) ? $value : serialize($value); + + $this->connection()->set($this->prefix.$key, $value); + + $this->connection()->expire($this->prefix.$key, $minutes * 60); + } + + /** + * Increment the value of an item in the cache. + * + * @param string $key + * @param mixed $value + * @return void + */ + public function increment($key, $value = 1) + { + return $this->connection()->incrby($this->prefix.$key, $value); + } + + /** + * Increment the value of an item in the cache. + * + * @param string $key + * @param mixed $value + * @return void + */ + public function decrement($key, $value = 1) + { + return $this->connection()->decrby($this->prefix.$key, $value); + } + + /** + * Store an item in the cache indefinitely. + * + * @param string $key + * @param mixed $value + * @return void + */ + public function forever($key, $value) + { + $value = is_numeric($value) ? $value : serialize($value); + + $this->connection()->set($this->prefix.$key, $value); + } + + /** + * Remove an item from the cache. + * + * @param string $key + * @return void + */ + public function forget($key) + { + $this->connection()->del($this->prefix.$key); + } + + /** + * Remove all items from the cache. + * + * @return void + */ + public function flush() + { + $this->connection()->flushdb(); + } + + /** + * Begin executing a new tags operation. + * + * @param array|dynamic $names + * @return \Illuminate\Cache\RedisTaggedCache + */ + public function tags($names) + { + return new RedisTaggedCache($this, new TagSet($this, is_array($names) ? $names : func_get_args())); + } + + /** + * Get the Redis connection instance. + * + * @return \Predis\Connection\SingleConnectionInterface + */ + public function connection() + { + return $this->redis->connection($this->connection); + } + + /** + * Set the connection name to be used. + * + * @param string $connection + * @return void + */ + public function setConnection($connection) + { + $this->connection = $connection; + } + + /** + * Get the Redis database instance. + * + * @return \Illuminate\Redis\Database + */ + public function getRedis() + { + return $this->redis; + } + + /** + * Get the cache key prefix. + * + * @return string + */ + public function getPrefix() + { + return $this->prefix; + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Cache/RedisTaggedCache.php b/vendor/laravel/framework/src/Illuminate/Cache/RedisTaggedCache.php new file mode 100755 index 0000000..4c99fa5 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Cache/RedisTaggedCache.php @@ -0,0 +1,90 @@ +pushForeverKeys($namespace = $this->tags->getNamespace(), $key); + + $this->store->forever($this->getPrefix().sha1($namespace).':'.$key, $value); + } + + /** + * Remove all items from the cache. + * + * @return void + */ + public function flush() + { + $this->deleteForeverKeys(); + + parent::flush(); + } + + /** + * Store a copy of the full key for each namespace segment. + * + * @param string $namespace + * @param string $key + * @return void + */ + protected function pushForeverKeys($namespace, $key) + { + $fullKey = $this->getPrefix().sha1($namespace).':'.$key; + + foreach (explode('|', $namespace) as $segment) + { + $this->store->connection()->lpush($this->foreverKey($segment), $fullKey); + } + } + + /** + * Delete all of the items that were stored forever. + * + * @return void + */ + protected function deleteForeverKeys() + { + foreach (explode('|', $this->tags->getNamespace()) as $segment) + { + $this->deleteForeverValues($segment = $this->foreverKey($segment)); + + $this->store->connection()->del($segment); + } + } + + /** + * Delete all of the keys that have been stored forever. + * + * @param string $foreverKey + * @return void + */ + protected function deleteForeverValues($foreverKey) + { + $forever = array_unique($this->store->connection()->lrange($foreverKey, 0, -1)); + + if (count($forever) > 0) + { + call_user_func_array(array($this->store->connection(), 'del'), $forever); + } + } + + /** + * Get the forever reference key for the segment. + * + * @param string $segment + * @return string + */ + protected function foreverKey($segment) + { + return $this->getPrefix().$segment.':forever'; + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Cache/Repository.php b/vendor/laravel/framework/src/Illuminate/Cache/Repository.php new file mode 100755 index 0000000..1d4a042 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Cache/Repository.php @@ -0,0 +1,283 @@ +store = $store; + } + + /** + * Determine if an item exists in the cache. + * + * @param string $key + * @return bool + */ + public function has($key) + { + return ! is_null($this->get($key)); + } + + /** + * Retrieve an item from the cache by key. + * + * @param string $key + * @param mixed $default + * @return mixed + */ + public function get($key, $default = null) + { + $value = $this->store->get($key); + + return ! is_null($value) ? $value : value($default); + } + + /** + * Store an item in the cache. + * + * @param string $key + * @param mixed $value + * @param \DateTime|int $minutes + * @return void + */ + public function put($key, $value, $minutes) + { + $minutes = $this->getMinutes($minutes); + + $this->store->put($key, $value, $minutes); + } + + /** + * Store an item in the cache if the key does not exist. + * + * @param string $key + * @param mixed $value + * @param \DateTime|int $minutes + * @return bool + */ + public function add($key, $value, $minutes) + { + if (is_null($this->get($key))) + { + $this->put($key, $value, $minutes); return true; + } + + return false; + } + + /** + * Get an item from the cache, or store the default value. + * + * @param string $key + * @param \DateTime|int $minutes + * @param Closure $callback + * @return mixed + */ + public function remember($key, $minutes, Closure $callback) + { + // If the item exists in the cache we will just return this immediately + // otherwise we will execute the given Closure and cache the result + // of that execution for the given number of minutes in storage. + if ( ! is_null($value = $this->get($key))) + { + return $value; + } + + $this->put($key, $value = $callback(), $minutes); + + return $value; + } + + /** + * Get an item from the cache, or store the default value forever. + * + * @param string $key + * @param Closure $callback + * @return mixed + */ + public function sear($key, Closure $callback) + { + return $this->rememberForever($key, $callback); + } + + /** + * Get an item from the cache, or store the default value forever. + * + * @param string $key + * @param Closure $callback + * @return mixed + */ + public function rememberForever($key, Closure $callback) + { + // If the item exists in the cache we will just return this immediately + // otherwise we will execute the given Closure and cache the result + // of that execution for the given number of minutes. It's easy. + if ( ! is_null($value = $this->get($key))) + { + return $value; + } + + $this->forever($key, $value = $callback()); + + return $value; + } + + /** + * Get the default cache time. + * + * @return int + */ + public function getDefaultCacheTime() + { + return $this->default; + } + + /** + * Set the default cache time in minutes. + * + * @param int $minutes + * @return void + */ + public function setDefaultCacheTime($minutes) + { + $this->default = $minutes; + } + + /** + * Get the cache store implementation. + * + * @return \Illuminate\Cache\StoreInterface + */ + public function getStore() + { + return $this->store; + } + + /** + * Determine if a cached value exists. + * + * @param string $key + * @return bool + */ + public function offsetExists($key) + { + return $this->has($key); + } + + /** + * Retrieve an item from the cache by key. + * + * @param string $key + * @return mixed + */ + public function offsetGet($key) + { + return $this->get($key); + } + + /** + * Store an item in the cache for the default time. + * + * @param string $key + * @param mixed $value + * @return void + */ + public function offsetSet($key, $value) + { + $this->put($key, $value, $this->default); + } + + /** + * Remove an item from the cache. + * + * @param string $key + * @return void + */ + public function offsetUnset($key) + { + return $this->forget($key); + } + + /** + * Calculate the number of minutes with the given duration. + * + * @param \DateTime|int $duration + * @return int + */ + protected function getMinutes($duration) + { + if ($duration instanceof DateTime) + { + $duration = Carbon::instance($duration); + + return max(0, Carbon::now()->diffInMinutes($duration, false)); + } + else + { + return is_string($duration) ? intval($duration) : $duration; + } + } + + /** + * Register a macro with the Cache class. + * + * @param string $name + * @param callable $callback + * @return void + */ + public function macro($name, $callback) + { + $this->macros[$name] = $callback; + } + + /** + * Handle dynamic calls into macros or pass missing methods to the store. + * + * @param string $method + * @param array $parameters + * @return mixed + */ + public function __call($method, $parameters) + { + if (isset($this->macros[$method])) + { + return call_user_func_array($this->macros[$method], $parameters); + } + else + { + return call_user_func_array(array($this->store, $method), $parameters); + } + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Cache/StoreInterface.php b/vendor/laravel/framework/src/Illuminate/Cache/StoreInterface.php new file mode 100755 index 0000000..54efca6 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Cache/StoreInterface.php @@ -0,0 +1,72 @@ +store = $store; + $this->names = $names; + } + + /** + * Reset all tags in the set. + * + * @return void + */ + public function reset() + { + array_walk($this->names, array($this, 'resetTag')); + } + + /** + * Get the unique tag identifier for a given tag. + * + * @param string $name + * @return string + */ + public function tagId($name) + { + return $this->store->get($this->tagKey($name)) ?: $this->resetTag($name); + } + + /** + * Get an array of tag identifiers for all of the tags in the set. + * + * @return array + */ + protected function tagIds() + { + return array_map(array($this, 'tagId'), $this->names); + } + + /** + * Get a unique namespace that changes when any of the tags are flushed. + * + * @return string + */ + public function getNamespace() + { + return implode('|', $this->tagIds()); + } + + /** + * Reset the tag and return the new tag identifier + * + * @param string $name + * @return string + */ + public function resetTag($name) + { + $this->store->forever($this->tagKey($name), $id = str_replace('.', '', uniqid('', true))); + + return $id; + } + + /** + * Get the tag identifier key for a given tag. + * + * @param string $name + * @return string + */ + public function tagKey($name) + { + return 'tag:'.$name.':key'; + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Cache/TaggableStore.php b/vendor/laravel/framework/src/Illuminate/Cache/TaggableStore.php new file mode 100755 index 0000000..0450a43 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Cache/TaggableStore.php @@ -0,0 +1,27 @@ +tags($name); + } + + /** + * Begin executing a new tags operation. + * + * @param array|dynamic $names + * @return \Illuminate\Cache\TaggedCache + */ + public function tags($names) + { + return new TaggedCache($this, new TagSet($this, is_array($names) ? $names : func_get_args())); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Cache/TaggedCache.php b/vendor/laravel/framework/src/Illuminate/Cache/TaggedCache.php new file mode 100755 index 0000000..fe8d124 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Cache/TaggedCache.php @@ -0,0 +1,219 @@ +tags = $tags; + $this->store = $store; + } + + /** + * Determine if an item exists in the cache. + * + * @param string $key + * @return bool + */ + public function has($key) + { + return ! is_null($this->get($key)); + } + + /** + * Retrieve an item from the cache by key. + * + * @param string $key + * @param mixed $default + * @return mixed + */ + public function get($key, $default = null) + { + $value = $this->store->get($this->taggedItemKey($key)); + + return ! is_null($value) ? $value : value($default); + } + + /** + * Store an item in the cache for a given number of minutes. + * + * @param string $key + * @param mixed $value + * @param int $minutes + * @return void + */ + public function put($key, $value, $minutes) + { + return $this->store->put($this->taggedItemKey($key), $value, $minutes); + } + + /** + * Store an item in the cache if the key does not exist. + * + * @param string $key + * @param mixed $value + * @param \DateTime|int $minutes + * @return bool + */ + public function add($key, $value, $minutes) + { + if (is_null($this->get($key))) + { + $this->put($key, $value, $minutes); return true; + } + + return false; + } + + /** + * Increment the value of an item in the cache. + * + * @param string $key + * @param mixed $value + * @return void + */ + public function increment($key, $value = 1) + { + $this->store->increment($this->taggedItemKey($key), $value); + } + + /** + * Increment the value of an item in the cache. + * + * @param string $key + * @param mixed $value + * @return void + */ + public function decrement($key, $value = 1) + { + $this->store->decrement($this->taggedItemKey($key), $value); + } + + /** + * Store an item in the cache indefinitely. + * + * @param string $key + * @param mixed $value + * @return void + */ + public function forever($key, $value) + { + $this->store->forever($this->taggedItemKey($key), $value); + } + + /** + * Remove an item from the cache. + * + * @param string $key + * @return void + */ + public function forget($key) + { + $this->store->forget($this->taggedItemKey($key)); + } + + /** + * Remove all items from the cache. + * + * @return void + */ + public function flush() + { + $this->tags->reset(); + } + + /** + * Get an item from the cache, or store the default value. + * + * @param string $key + * @param int $minutes + * @param Closure $callback + * @return mixed + */ + public function remember($key, $minutes, Closure $callback) + { + // If the item exists in the cache we will just return this immediately + // otherwise we will execute the given Closure and cache the result + // of that execution for the given number of minutes in storage. + if ($this->has($key)) return $this->get($key); + + $this->put($key, $value = $callback(), $minutes); + + return $value; + } + + /** + * Get an item from the cache, or store the default value forever. + * + * @param string $key + * @param Closure $callback + * @return mixed + */ + public function sear($key, Closure $callback) + { + return $this->rememberForever($key, $callback); + } + + /** + * Get an item from the cache, or store the default value forever. + * + * @param string $key + * @param Closure $callback + * @return mixed + */ + public function rememberForever($key, Closure $callback) + { + // If the item exists in the cache we will just return this immediately + // otherwise we will execute the given Closure and cache the result + // of that execution for the given number of minutes. It's easy. + if ($this->has($key)) return $this->get($key); + + $this->forever($key, $value = $callback()); + + return $value; + } + + /** + * Get a fully qualified key for a tagged item. + * + * @param string $key + * @return string + */ + public function taggedItemKey($key) + { + return $this->getPrefix().sha1($this->tags->getNamespace()).':'.$key; + } + + /** + * Get the cache key prefix. + * + * @return string + */ + public function getPrefix() + { + return $this->store->getPrefix(); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Cache/WinCacheStore.php b/vendor/laravel/framework/src/Illuminate/Cache/WinCacheStore.php new file mode 100755 index 0000000..e161156 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Cache/WinCacheStore.php @@ -0,0 +1,119 @@ +prefix = $prefix; + } + + /** + * Retrieve an item from the cache by key. + * + * @param string $key + * @return mixed + */ + public function get($key) + { + $value = wincache_ucache_get($this->prefix.$key); + + if ($value !== false) + { + return $value; + } + } + + /** + * Store an item in the cache for a given number of minutes. + * + * @param string $key + * @param mixed $value + * @param int $minutes + * @return void + */ + public function put($key, $value, $minutes) + { + wincache_ucache_set($this->prefix.$key, $value, $minutes * 60); + } + + /** + * Increment the value of an item in the cache. + * + * @param string $key + * @param mixed $value + * @return void + */ + public function increment($key, $value = 1) + { + return wincache_ucache_inc($this->prefix.$key, $value); + } + + /** + * Increment the value of an item in the cache. + * + * @param string $key + * @param mixed $value + * @return void + */ + public function decrement($key, $value = 1) + { + return wincache_ucache_dec($this->prefix.$key, $value); + } + + /** + * Store an item in the cache indefinitely. + * + * @param string $key + * @param mixed $value + * @return void + */ + public function forever($key, $value) + { + return $this->put($key, $value, 0); + } + + /** + * Remove an item from the cache. + * + * @param string $key + * @return void + */ + public function forget($key) + { + wincache_ucache_delete($this->prefix.$key); + } + + /** + * Remove all items from the cache. + * + * @return void + */ + public function flush() + { + wincache_ucache_clear(); + } + + /** + * Get the cache key prefix. + * + * @return string + */ + public function getPrefix() + { + return $this->prefix; + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Cache/XCacheStore.php b/vendor/laravel/framework/src/Illuminate/Cache/XCacheStore.php new file mode 100755 index 0000000..4db379f --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Cache/XCacheStore.php @@ -0,0 +1,119 @@ +prefix = $prefix; + } + + /** + * Retrieve an item from the cache by key. + * + * @param string $key + * @return mixed + */ + public function get($key) + { + $value = xcache_get($this->prefix.$key); + + if (isset($value)) + { + return $value; + } + } + + /** + * Store an item in the cache for a given number of minutes. + * + * @param string $key + * @param mixed $value + * @param int $minutes + * @return void + */ + public function put($key, $value, $minutes) + { + xcache_set($this->prefix.$key, $value, $minutes * 60); + } + + /** + * Increment the value of an item in the cache. + * + * @param string $key + * @param mixed $value + * @return void + */ + public function increment($key, $value = 1) + { + return xcache_inc($this->prefix.$key, $value); + } + + /** + * Increment the value of an item in the cache. + * + * @param string $key + * @param mixed $value + * @return void + */ + public function decrement($key, $value = 1) + { + return xcache_dec($this->prefix.$key, $value); + } + + /** + * Store an item in the cache indefinitely. + * + * @param string $key + * @param mixed $value + * @return void + */ + public function forever($key, $value) + { + return $this->put($key, $value, 0); + } + + /** + * Remove an item from the cache. + * + * @param string $key + * @return void + */ + public function forget($key) + { + xcache_unset($this->prefix.$key); + } + + /** + * Remove all items from the cache. + * + * @return void + */ + public function flush() + { + xcache_clear_cache(XC_TYPE_VAR); + } + + /** + * Get the cache key prefix. + * + * @return string + */ + public function getPrefix() + { + return $this->prefix; + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Cache/composer.json b/vendor/laravel/framework/src/Illuminate/Cache/composer.json new file mode 100755 index 0000000..e3d36f2 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Cache/composer.json @@ -0,0 +1,32 @@ +{ + "name": "illuminate/cache", + "license": "MIT", + "authors": [ + { + "name": "Taylor Otwell", + "email": "taylorotwell@gmail.com" + } + ], + "require": { + "php": ">=5.3.0", + "illuminate/support": "4.1.*", + "nesbot/carbon": "1.*" + }, + "require-dev": { + "phpunit/phpunit": "4.0.*", + "illuminate/database": "4.1.*", + "illuminate/encryption": "4.1.*", + "illuminate/filesystem": "4.1.*", + "illuminate/redis": "4.1.*" + }, + "autoload": { + "psr-0": {"Illuminate\\Cache": ""} + }, + "target-dir": "Illuminate/Cache", + "extra": { + "branch-alias": { + "dev-master": "4.1-dev" + } + }, + "minimum-stability": "dev" +} diff --git a/vendor/laravel/framework/src/Illuminate/Config/EnvironmentVariables.php b/vendor/laravel/framework/src/Illuminate/Config/EnvironmentVariables.php new file mode 100755 index 0000000..3098b14 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Config/EnvironmentVariables.php @@ -0,0 +1,45 @@ +loader = $loader; + } + + /** + * Load the server variables for a given environment. + * + * @param string $environment + */ + public function load($environment = null) + { + foreach ($this->loader->load($environment) as $key => $value) + { + $_ENV[$key] = $value; + + $_SERVER[$key] = $value; + + putenv("{$key}={$value}"); + } + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Config/EnvironmentVariablesLoaderInterface.php b/vendor/laravel/framework/src/Illuminate/Config/EnvironmentVariablesLoaderInterface.php new file mode 100755 index 0000000..376f666 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Config/EnvironmentVariablesLoaderInterface.php @@ -0,0 +1,13 @@ +files = $files; + $this->path = $path ?: base_path(); + } + + /** + * Load the environment variables for the given environment. + * + * @param string $environment + * @return array + */ + public function load($environment = null) + { + if ($environment == 'production') $environment = null; + + if ( ! $this->files->exists($path = $this->getFile($environment))) + { + return array(); + } + else + { + return $this->files->getRequire($path); + } + } + + /** + * Get the file for the given environment. + * + * @param string $environment + * @return string + */ + protected function getFile($environment) + { + if ($environment) + { + return $this->path.'/.env.'.$environment.'.php'; + } + else + { + return $this->path.'/.env.php'; + } + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Config/FileLoader.php b/vendor/laravel/framework/src/Illuminate/Config/FileLoader.php new file mode 100755 index 0000000..b89e4e8 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Config/FileLoader.php @@ -0,0 +1,255 @@ +files = $files; + $this->defaultPath = $defaultPath; + } + + /** + * Load the given configuration group. + * + * @param string $environment + * @param string $group + * @param string $namespace + * @return array + */ + public function load($environment, $group, $namespace = null) + { + $items = array(); + + // First we'll get the root configuration path for the environment which is + // where all of the configuration files live for that namespace, as well + // as any environment folders with their specific configuration items. + $path = $this->getPath($namespace); + + if (is_null($path)) + { + return $items; + } + + // First we'll get the main configuration file for the groups. Once we have + // that we can check for any environment specific files, which will get + // merged on top of the main arrays to make the environments cascade. + $file = "{$path}/{$group}.php"; + + if ($this->files->exists($file)) + { + $items = $this->files->getRequire($file); + } + + // Finally we're ready to check for the environment specific configuration + // file which will be merged on top of the main arrays so that they get + // precedence over them if we are currently in an environments setup. + $file = "{$path}/{$environment}/{$group}.php"; + + if ($this->files->exists($file)) + { + $items = $this->mergeEnvironment($items, $file); + } + + return $items; + } + + /** + * Merge the items in the given file into the items. + * + * @param array $items + * @param string $file + * @return array + */ + protected function mergeEnvironment(array $items, $file) + { + return array_replace_recursive($items, $this->files->getRequire($file)); + } + + /** + * Determine if the given group exists. + * + * @param string $group + * @param string $namespace + * @return bool + */ + public function exists($group, $namespace = null) + { + $key = $group.$namespace; + + // We'll first check to see if we have determined if this namespace and + // group combination have been checked before. If they have, we will + // just return the cached result so we don't have to hit the disk. + if (isset($this->exists[$key])) + { + return $this->exists[$key]; + } + + $path = $this->getPath($namespace); + + // To check if a group exists, we will simply get the path based on the + // namespace, and then check to see if this files exists within that + // namespace. False is returned if no path exists for a namespace. + if (is_null($path)) + { + return $this->exists[$key] = false; + } + + $file = "{$path}/{$group}.php"; + + // Finally, we can simply check if this file exists. We will also cache + // the value in an array so we don't have to go through this process + // again on subsequent checks for the existing of the config file. + $exists = $this->files->exists($file); + + return $this->exists[$key] = $exists; + } + + /** + * Apply any cascades to an array of package options. + * + * @param string $env + * @param string $package + * @param string $group + * @param array $items + * @return array + */ + public function cascadePackage($env, $package, $group, $items) + { + // First we will look for a configuration file in the packages configuration + // folder. If it exists, we will load it and merge it with these original + // options so that we will easily "cascade" a package's configurations. + $file = "packages/{$package}/{$group}.php"; + + if ($this->files->exists($path = $this->defaultPath.'/'.$file)) + { + $items = array_merge($items, $this->getRequire($path)); + } + + // Once we have merged the regular package configuration we need to look for + // an environment specific configuration file. If one exists, we will get + // the contents and merge them on top of this array of options we have. + $path = $this->getPackagePath($env, $package, $group); + + if ($this->files->exists($path)) + { + $items = array_merge($items, $this->getRequire($path)); + } + + return $items; + } + + /** + * Get the package path for an environment and group. + * + * @param string $env + * @param string $package + * @param string $group + * @return string + */ + protected function getPackagePath($env, $package, $group) + { + $file = "packages/{$package}/{$env}/{$group}.php"; + + return $this->defaultPath.'/'.$file; + } + + /** + * Get the configuration path for a namespace. + * + * @param string $namespace + * @return string + */ + protected function getPath($namespace) + { + if (is_null($namespace)) + { + return $this->defaultPath; + } + elseif (isset($this->hints[$namespace])) + { + return $this->hints[$namespace]; + } + } + + /** + * Add a new namespace to the loader. + * + * @param string $namespace + * @param string $hint + * @return void + */ + public function addNamespace($namespace, $hint) + { + $this->hints[$namespace] = $hint; + } + + /** + * Returns all registered namespaces with the config + * loader. + * + * @return array + */ + public function getNamespaces() + { + return $this->hints; + } + + /** + * Get a file's contents by requiring it. + * + * @param string $path + * @return mixed + */ + protected function getRequire($path) + { + return $this->files->getRequire($path); + } + + /** + * Get the Filesystem instance. + * + * @return \Illuminate\Filesystem\Filesystem + */ + public function getFilesystem() + { + return $this->files; + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Config/LoaderInterface.php b/vendor/laravel/framework/src/Illuminate/Config/LoaderInterface.php new file mode 100755 index 0000000..d4b6a8f --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Config/LoaderInterface.php @@ -0,0 +1,52 @@ +loader = $loader; + $this->environment = $environment; + } + + /** + * Determine if the given configuration value exists. + * + * @param string $key + * @return bool + */ + public function has($key) + { + $default = microtime(true); + + return $this->get($key, $default) !== $default; + } + + /** + * Determine if a configuration group exists. + * + * @param string $key + * @return bool + */ + public function hasGroup($key) + { + list($namespace, $group, $item) = $this->parseKey($key); + + return $this->loader->exists($group, $namespace); + } + + /** + * Get the specified configuration value. + * + * @param string $key + * @param mixed $default + * @return mixed + */ + public function get($key, $default = null) + { + list($namespace, $group, $item) = $this->parseKey($key); + + // Configuration items are actually keyed by "collection", which is simply a + // combination of each namespace and groups, which allows a unique way to + // identify the arrays of configuration items for the particular files. + $collection = $this->getCollection($group, $namespace); + + $this->load($group, $namespace, $collection); + + return array_get($this->items[$collection], $item, $default); + } + + /** + * Set a given configuration value. + * + * @param string $key + * @param mixed $value + * @return void + */ + public function set($key, $value) + { + list($namespace, $group, $item) = $this->parseKey($key); + + $collection = $this->getCollection($group, $namespace); + + // We'll need to go ahead and lazy load each configuration groups even when + // we're just setting a configuration item so that the set item does not + // get overwritten if a different item in the group is requested later. + $this->load($group, $namespace, $collection); + + if (is_null($item)) + { + $this->items[$collection] = $value; + } + else + { + array_set($this->items[$collection], $item, $value); + } + } + + /** + * Load the configuration group for the key. + * + * @param string $group + * @param string $namespace + * @param string $collection + * @return void + */ + protected function load($group, $namespace, $collection) + { + $env = $this->environment; + + // If we've already loaded this collection, we will just bail out since we do + // not want to load it again. Once items are loaded a first time they will + // stay kept in memory within this class and not loaded from disk again. + if (isset($this->items[$collection])) + { + return; + } + + $items = $this->loader->load($env, $group, $namespace); + + // If we've already loaded this collection, we will just bail out since we do + // not want to load it again. Once items are loaded a first time they will + // stay kept in memory within this class and not loaded from disk again. + if (isset($this->afterLoad[$namespace])) + { + $items = $this->callAfterLoad($namespace, $group, $items); + } + + $this->items[$collection] = $items; + } + + /** + * Call the after load callback for a namespace. + * + * @param string $namespace + * @param string $group + * @param array $items + * @return array + */ + protected function callAfterLoad($namespace, $group, $items) + { + $callback = $this->afterLoad[$namespace]; + + return call_user_func($callback, $this, $group, $items); + } + + /** + * Parse an array of namespaced segments. + * + * @param string $key + * @return array + */ + protected function parseNamespacedSegments($key) + { + list($namespace, $item) = explode('::', $key); + + // If the namespace is registered as a package, we will just assume the group + // is equal to the namespace since all packages cascade in this way having + // a single file per package, otherwise we'll just parse them as normal. + if (in_array($namespace, $this->packages)) + { + return $this->parsePackageSegments($key, $namespace, $item); + } + + return parent::parseNamespacedSegments($key); + } + + /** + * Parse the segments of a package namespace. + * + * @param string $key + * @param string $namespace + * @param string $item + * @return array + */ + protected function parsePackageSegments($key, $namespace, $item) + { + $itemSegments = explode('.', $item); + + // If the configuration file doesn't exist for the given package group we can + // assume that we should implicitly use the config file matching the name + // of the namespace. Generally packages should use one type or another. + if ( ! $this->loader->exists($itemSegments[0], $namespace)) + { + return array($namespace, 'config', $item); + } + + return parent::parseNamespacedSegments($key); + } + + /** + * Register a package for cascading configuration. + * + * @param string $package + * @param string $hint + * @param string $namespace + * @return void + */ + public function package($package, $hint, $namespace = null) + { + $namespace = $this->getPackageNamespace($package, $namespace); + + $this->packages[] = $namespace; + + // First we will simply register the namespace with the repository so that it + // can be loaded. Once we have done that we'll register an after namespace + // callback so that we can cascade an application package configuration. + $this->addNamespace($namespace, $hint); + + $this->afterLoading($namespace, function($me, $group, $items) use ($package) + { + $env = $me->getEnvironment(); + + $loader = $me->getLoader(); + + return $loader->cascadePackage($env, $package, $group, $items); + }); + } + + /** + * Get the configuration namespace for a package. + * + * @param string $package + * @param string $namespace + * @return string + */ + protected function getPackageNamespace($package, $namespace) + { + if (is_null($namespace)) + { + list($vendor, $namespace) = explode('/', $package); + } + + return $namespace; + } + + /** + * Register an after load callback for a given namespace. + * + * @param string $namespace + * @param \Closure $callback + * @return void + */ + public function afterLoading($namespace, Closure $callback) + { + $this->afterLoad[$namespace] = $callback; + } + + /** + * Get the collection identifier. + * + * @param string $group + * @param string $namespace + * @return string + */ + protected function getCollection($group, $namespace = null) + { + $namespace = $namespace ?: '*'; + + return $namespace.'::'.$group; + } + + /** + * Add a new namespace to the loader. + * + * @param string $namespace + * @param string $hint + * @return void + */ + public function addNamespace($namespace, $hint) + { + $this->loader->addNamespace($namespace, $hint); + } + + /** + * Returns all registered namespaces with the config + * loader. + * + * @return array + */ + public function getNamespaces() + { + return $this->loader->getNamespaces(); + } + + /** + * Get the loader implementation. + * + * @return \Illuminate\Config\LoaderInterface + */ + public function getLoader() + { + return $this->loader; + } + + /** + * Set the loader implementation. + * + * @param \Illuminate\Config\LoaderInterface $loader + * @return void + */ + public function setLoader(LoaderInterface $loader) + { + $this->loader = $loader; + } + + /** + * Get the current configuration environment. + * + * @return string + */ + public function getEnvironment() + { + return $this->environment; + } + + /** + * Get the after load callback array. + * + * @return array + */ + public function getAfterLoadCallbacks() + { + return $this->afterLoad; + } + + /** + * Get all of the configuration items. + * + * @return array + */ + public function getItems() + { + return $this->items; + } + + /** + * Determine if the given configuration option exists. + * + * @param string $key + * @return bool + */ + public function offsetExists($key) + { + return $this->has($key); + } + + /** + * Get a configuration option. + * + * @param string $key + * @return mixed + */ + public function offsetGet($key) + { + return $this->get($key); + } + + /** + * Set a configuration option. + * + * @param string $key + * @param mixed $value + * @return void + */ + public function offsetSet($key, $value) + { + $this->set($key, $value); + } + + /** + * Unset a configuration option. + * + * @param string $key + * @return void + */ + public function offsetUnset($key) + { + $this->set($key, null); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Config/composer.json b/vendor/laravel/framework/src/Illuminate/Config/composer.json new file mode 100755 index 0000000..74b9ff0 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Config/composer.json @@ -0,0 +1,28 @@ +{ + "name": "illuminate/config", + "license": "MIT", + "authors": [ + { + "name": "Taylor Otwell", + "email": "taylorotwell@gmail.com" + } + ], + "require": { + "php": ">=5.3.0", + "illuminate/filesystem": "4.1.*", + "illuminate/support": "4.1.*" + }, + "require-dev": { + "phpunit/phpunit": "4.0.*" + }, + "autoload": { + "psr-0": {"Illuminate\\Config": ""} + }, + "target-dir": "Illuminate/Config", + "extra": { + "branch-alias": { + "dev-master": "4.1-dev" + } + }, + "minimum-stability": "dev" +} diff --git a/vendor/laravel/framework/src/Illuminate/Console/Application.php b/vendor/laravel/framework/src/Illuminate/Console/Application.php new file mode 100755 index 0000000..054e33c --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Console/Application.php @@ -0,0 +1,238 @@ +boot(); + } + + /** + * Create a new Console application. + * + * @param \Illuminate\Foundation\Application $app + * @return \Illuminate\Console\Application + */ + public static function make($app) + { + $app->boot(); + + $console = with($console = new static('Laravel Framework', $app::VERSION)) + ->setLaravel($app) + ->setExceptionHandler($app['exception']) + ->setAutoExit(false); + + $app->instance('artisan', $console); + + return $console; + } + + /** + * Boot the Console application. + * + * @return \Illuminate\Console\Application + */ + public function boot() + { + require $this->laravel['path'].'/start/artisan.php'; + + // If the event dispatcher is set on the application, we will fire an event + // with the Artisan instance to provide each listener the opportunity to + // register their commands on this application before it gets started. + if (isset($this->laravel['events'])) + { + $this->laravel['events'] + ->fire('artisan.start', array($this)); + } + + return $this; + } + + /** + * Run an Artisan console command by name. + * + * @param string $command + * @param array $parameters + * @param \Symfony\Component\Console\Output\OutputInterface $output + * @return void + */ + public function call($command, array $parameters = array(), OutputInterface $output = null) + { + $parameters['command'] = $command; + + // Unless an output interface implementation was specifically passed to us we + // will use the "NullOutput" implementation by default to keep any writing + // suppressed so it doesn't leak out to the browser or any other source. + $output = $output ?: new NullOutput; + + $input = new ArrayInput($parameters); + + return $this->find($command)->run($input, $output); + } + + /** + * Add a command to the console. + * + * @param \Symfony\Component\Console\Command\Command $command + * @return \Symfony\Component\Console\Command\Command + */ + public function add(SymfonyCommand $command) + { + if ($command instanceof Command) + { + $command->setLaravel($this->laravel); + } + + return $this->addToParent($command); + } + + /** + * Add the command to the parent instance. + * + * @param \Symfony\Component\Console\Command\Command $command + * @return \Symfony\Component\Console\Command\Command + */ + protected function addToParent(SymfonyCommand $command) + { + return parent::add($command); + } + + /** + * Add a command, resolving through the application. + * + * @param string $command + * @return \Symfony\Component\Console\Command\Command + */ + public function resolve($command) + { + return $this->add($this->laravel[$command]); + } + + /** + * Resolve an array of commands through the application. + * + * @param array|dynamic $commands + * @return void + */ + public function resolveCommands($commands) + { + $commands = is_array($commands) ? $commands : func_get_args(); + + foreach ($commands as $command) + { + $this->resolve($command); + } + } + + /** + * Get the default input definitions for the applications. + * + * @return \Symfony\Component\Console\Input\InputDefinition + */ + protected function getDefaultInputDefinition() + { + $definition = parent::getDefaultInputDefinition(); + + $definition->addOption($this->getEnvironmentOption()); + + return $definition; + } + + /** + * Get the global environment option for the definition. + * + * @return \Symfony\Component\Console\Input\InputOption + */ + protected function getEnvironmentOption() + { + $message = 'The environment the command should run under.'; + + return new InputOption('--env', null, InputOption::VALUE_OPTIONAL, $message); + } + + /** + * Render the given exception. + * + * @param \Exception $e + * @param \Symfony\Component\Console\Output\OutputInterface $output + * @return void + */ + public function renderException($e, $output) + { + // If we have an exception handler instance, we will call that first in case + // it has some handlers that need to be run first. We will pass "true" as + // the second parameter to indicate that it's handling a console error. + if (isset($this->exceptionHandler)) + { + $this->exceptionHandler->handleConsole($e); + } + + parent::renderException($e, $output); + } + + /** + * Set the exception handler instance. + * + * @param \Illuminate\Exception\Handler $handler + * @return \Illuminate\Console\Application + */ + public function setExceptionHandler($handler) + { + $this->exceptionHandler = $handler; + + return $this; + } + + /** + * Set the Laravel application instance. + * + * @param \Illuminate\Foundation\Application $laravel + * @return \Illuminate\Console\Application + */ + public function setLaravel($laravel) + { + $this->laravel = $laravel; + + return $this; + } + + /** + * Set whether the Console app should auto-exit when done. + * + * @param bool $boolean + * @return \Illuminate\Console\Application + */ + public function setAutoExit($boolean) + { + parent::setAutoExit($boolean); + + return $this; + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Console/Command.php b/vendor/laravel/framework/src/Illuminate/Console/Command.php new file mode 100755 index 0000000..3035343 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Console/Command.php @@ -0,0 +1,334 @@ +name); + + // We will go ahead and set the name, description, and parameters on console + // commands just to make things a little easier on the developer. This is + // so they don't have to all be manually specified in the constructors. + $this->setDescription($this->description); + + $this->specifyParameters(); + } + + /** + * Specify the arguments and options on the command. + * + * @return void + */ + protected function specifyParameters() + { + // We will loop through all of the arguments and options for the command and + // set them all on the base command instance. This specifies what can get + // passed into these commands as "parameters" to control the execution. + foreach ($this->getArguments() as $arguments) + { + call_user_func_array(array($this, 'addArgument'), $arguments); + } + + foreach ($this->getOptions() as $options) + { + call_user_func_array(array($this, 'addOption'), $options); + } + } + + /** + * Run the console command. + * + * @param \Symfony\Component\Console\Input\InputInterface $input + * @param \Symfony\Component\Console\Output\OutputInterface $output + * @return integer + */ + public function run(InputInterface $input, OutputInterface $output) + { + $this->input = $input; + + $this->output = $output; + + return parent::run($input, $output); + } + + /** + * Execute the console command. + * + * @param \Symfony\Component\Console\Input\InputInterface $input + * @param \Symfony\Component\Console\Output\OutputInterface $output + * @return mixed + */ + protected function execute(InputInterface $input, OutputInterface $output) + { + return $this->fire(); + } + + /** + * Call another console command. + * + * @param string $command + * @param array $arguments + * @return integer + */ + public function call($command, array $arguments = array()) + { + $instance = $this->getApplication()->find($command); + + $arguments['command'] = $command; + + return $instance->run(new ArrayInput($arguments), $this->output); + } + + /** + * Call another console command silently. + * + * @param string $command + * @param array $arguments + * @return integer + */ + public function callSilent($command, array $arguments = array()) + { + $instance = $this->getApplication()->find($command); + + $arguments['command'] = $command; + + return $instance->run(new ArrayInput($arguments), new NullOutput); + } + + /** + * Get the value of a command argument. + * + * @param string $key + * @return string|array + */ + public function argument($key = null) + { + if (is_null($key)) return $this->input->getArguments(); + + return $this->input->getArgument($key); + } + + /** + * Get the value of a command option. + * + * @param string $key + * @return string|array + */ + public function option($key = null) + { + if (is_null($key)) return $this->input->getOptions(); + + return $this->input->getOption($key); + } + + /** + * Confirm a question with the user. + * + * @param string $question + * @param bool $default + * @return bool + */ + public function confirm($question, $default = true) + { + $dialog = $this->getHelperSet()->get('dialog'); + + return $dialog->askConfirmation($this->output, "$question", $default); + } + + /** + * Prompt the user for input. + * + * @param string $question + * @param string $default + * @return string + */ + public function ask($question, $default = null) + { + $dialog = $this->getHelperSet()->get('dialog'); + + return $dialog->ask($this->output, "$question", $default); + } + + + /** + * Prompt the user for input but hide the answer from the console. + * + * @param string $question + * @param bool $fallback + * @return string + */ + public function secret($question, $fallback = true) + { + $dialog = $this->getHelperSet()->get('dialog'); + + return $dialog->askHiddenResponse($this->output, "$question", $fallback); + } + + /** + * Give the user a single choice from an array of answers. + * + * @param string $question + * @param array $choices + * @param string $default + * @param mixed $attempts + * @return bool + */ + public function choice($question, array $choices, $default = null, $attempts = false) + { + $dialog = $this->getHelperSet()->get('dialog'); + + return $dialog->select($this->output, "$question", $choices, $default, $attempts); + } + + /** + * Write a string as standard output. + * + * @param string $string + * @return void + */ + public function line($string) + { + $this->output->writeln($string); + } + + /** + * Write a string as information output. + * + * @param string $string + * @return void + */ + public function info($string) + { + $this->output->writeln("$string"); + } + + /** + * Write a string as comment output. + * + * @param string $string + * @return void + */ + public function comment($string) + { + $this->output->writeln("$string"); + } + + /** + * Write a string as question output. + * + * @param string $string + * @return void + */ + public function question($string) + { + $this->output->writeln("$string"); + } + + /** + * Write a string as error output. + * + * @param string $string + * @return void + */ + public function error($string) + { + $this->output->writeln("$string"); + } + + /** + * Get the console command arguments. + * + * @return array + */ + protected function getArguments() + { + return array(); + } + + /** + * Get the console command options. + * + * @return array + */ + protected function getOptions() + { + return array(); + } + + /** + * Get the output implementation. + * + * @return \Symfony\Component\Console\Output\OutputInterface + */ + public function getOutput() + { + return $this->output; + } + + /** + * Set the Laravel application instance. + * + * @return \Illuminate\Foundation\Application + */ + public function getLaravel() + { + return $this->laravel; + } + + /** + * Set the Laravel application instance. + * + * @param \Illuminate\Foundation\Application $laravel + * @return void + */ + public function setLaravel($laravel) + { + $this->laravel = $laravel; + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Console/composer.json b/vendor/laravel/framework/src/Illuminate/Console/composer.json new file mode 100755 index 0000000..1def930 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Console/composer.json @@ -0,0 +1,29 @@ +{ + "name": "illuminate/console", + "license": "MIT", + "authors": [ + { + "name": "Taylor Otwell", + "email": "taylorotwell@gmail.com" + } + ], + "require": { + "php": ">=5.3.0", + "symfony/console": "2.4.*" + }, + "require-dev": { + "phpunit/phpunit": "4.0.*" + }, + "autoload": { + "psr-0": { + "Illuminate\\Console": "" + } + }, + "target-dir": "Illuminate/Console", + "extra": { + "branch-alias": { + "dev-master": "4.1-dev" + } + }, + "minimum-stability": "dev" +} diff --git a/vendor/laravel/framework/src/Illuminate/Container/Container.php b/vendor/laravel/framework/src/Illuminate/Container/Container.php new file mode 100755 index 0000000..851878d --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Container/Container.php @@ -0,0 +1,848 @@ +bound($abstract) || $this->isAlias($abstract); + } + + /** + * Determine if the given abstract type has been bound. + * + * @param string $abstract + * @return bool + */ + public function bound($abstract) + { + return isset($this[$abstract]) || isset($this->instances[$abstract]); + } + + /** + * Determine if a given string is an alias. + * + * @param string $name + * @return bool + */ + public function isAlias($name) + { + return isset($this->aliases[$name]); + } + + /** + * Register a binding with the container. + * + * @param string $abstract + * @param Closure|string|null $concrete + * @param bool $shared + * @return void + */ + public function bind($abstract, $concrete = null, $shared = false) + { + // If the given types are actually an array, we will assume an alias is being + // defined and will grab this "real" abstract class name and register this + // alias with the container so that it can be used as a shortcut for it. + if (is_array($abstract)) + { + list($abstract, $alias) = $this->extractAlias($abstract); + + $this->alias($abstract, $alias); + } + + // If no concrete type was given, we will simply set the concrete type to the + // abstract type. This will allow concrete type to be registered as shared + // without being forced to state their classes in both of the parameter. + $this->dropStaleInstances($abstract); + + if (is_null($concrete)) + { + $concrete = $abstract; + } + + // If the factory is not a Closure, it means it is just a class name which is + // is bound into this container to the abstract type and we will just wrap + // it up inside a Closure to make things more convenient when extending. + if ( ! $concrete instanceof Closure) + { + $concrete = $this->getClosure($abstract, $concrete); + } + + $bound = $this->bound($abstract); + + $this->bindings[$abstract] = compact('concrete', 'shared'); + + // If the abstract type was already bound in this container, we will fire the + // rebound listener so that any objects which have already gotten resolved + // can have their copy of the object updated via the listener callbacks. + if ($bound) + { + $this->rebound($abstract); + } + } + + /** + * Get the Closure to be used when building a type. + * + * @param string $abstract + * @param string $concrete + * @return \Closure + */ + protected function getClosure($abstract, $concrete) + { + return function($c, $parameters = array()) use ($abstract, $concrete) + { + $method = ($abstract == $concrete) ? 'build' : 'make'; + + return $c->$method($concrete, $parameters); + }; + } + + /** + * Register a binding if it hasn't already been registered. + * + * @param string $abstract + * @param Closure|string|null $concrete + * @param bool $shared + * @return void + */ + public function bindIf($abstract, $concrete = null, $shared = false) + { + if ( ! $this->bound($abstract)) + { + $this->bind($abstract, $concrete, $shared); + } + } + + /** + * Register a shared binding in the container. + * + * @param string $abstract + * @param Closure|string|null $concrete + * @return void + */ + public function singleton($abstract, $concrete = null) + { + return $this->bind($abstract, $concrete, true); + } + + /** + * Wrap a Closure such that it is shared. + * + * @param Closure $closure + * @return Closure + */ + public function share(Closure $closure) + { + return function($container) use ($closure) + { + // We'll simply declare a static variable within the Closures and if it has + // not been set we will execute the given Closures to resolve this value + // and return it back to these consumers of the method as an instance. + static $object; + + if (is_null($object)) + { + $object = $closure($container); + } + + return $object; + }; + } + + /** + * Bind a shared Closure into the container. + * + * @param string $abstract + * @param \Closure $closure + * @return void + */ + public function bindShared($abstract, Closure $closure) + { + return $this->bind($abstract, $this->share($closure), true); + } + + /** + * "Extend" an abstract type in the container. + * + * @param string $abstract + * @param Closure $closure + * @return void + * + * @throws \InvalidArgumentException + */ + public function extend($abstract, Closure $closure) + { + if ( ! isset($this->bindings[$abstract])) + { + throw new \InvalidArgumentException("Type {$abstract} is not bound."); + } + + if (isset($this->instances[$abstract])) + { + $this->instances[$abstract] = $closure($this->instances[$abstract], $this); + + $this->rebound($abstract); + } + else + { + $extender = $this->getExtender($abstract, $closure); + + $this->bind($abstract, $extender, $this->isShared($abstract)); + } + } + + /** + * Get an extender Closure for resolving a type. + * + * @param string $abstract + * @param \Closure $closure + * @return \Closure + */ + protected function getExtender($abstract, Closure $closure) + { + // To "extend" a binding, we will grab the old "resolver" Closure and pass it + // into a new one. The old resolver will be called first and the result is + // handed off to the "new" resolver, along with this container instance. + $resolver = $this->bindings[$abstract]['concrete']; + + return function($container) use ($resolver, $closure) + { + return $closure($resolver($container), $container); + }; + } + + /** + * Register an existing instance as shared in the container. + * + * @param string $abstract + * @param mixed $instance + * @return void + */ + public function instance($abstract, $instance) + { + // First, we will extract the alias from the abstract if it is an array so we + // are using the correct name when binding the type. If we get an alias it + // will be registered with the container so we can resolve it out later. + if (is_array($abstract)) + { + list($abstract, $alias) = $this->extractAlias($abstract); + + $this->alias($abstract, $alias); + } + + unset($this->aliases[$abstract]); + + // We'll check to determine if this type has been bound before, and if it has + // we will fire the rebound callbacks registered with the container and it + // can be updated with consuming classes that have gotten resolved here. + $bound = $this->bound($abstract); + + $this->instances[$abstract] = $instance; + + if ($bound) + { + $this->rebound($abstract); + } + } + + /** + * Alias a type to a shorter name. + * + * @param string $abstract + * @param string $alias + * @return void + */ + public function alias($abstract, $alias) + { + $this->aliases[$alias] = $abstract; + } + + /** + * Extract the type and alias from a given definition. + * + * @param array $definition + * @return array + */ + protected function extractAlias(array $definition) + { + return array(key($definition), current($definition)); + } + + /** + * Bind a new callback to an abstract's rebind event. + * + * @param string $abstract + * @param \Closure $callback + * @return mixed + */ + public function rebinding($abstract, Closure $callback) + { + $this->reboundCallbacks[$abstract][] = $callback; + + if ($this->bound($abstract)) return $this->make($abstract); + } + + /** + * Refresh an instance on the given target and method. + * + * @param string $abstract + * @param mixed $target + * @param string $method + * @return mixed + */ + public function refresh($abstract, $target, $method) + { + return $this->rebinding($abstract, function($app, $instance) use ($target, $method) + { + $target->{$method}($instance); + }); + } + + /** + * Fire the "rebound" callbacks for the given abstract type. + * + * @param string $abstract + * @return void + */ + protected function rebound($abstract) + { + $instance = $this->make($abstract); + + foreach ($this->getReboundCallbacks($abstract) as $callback) + { + call_user_func($callback, $this, $instance); + } + } + + /** + * Get the rebound callbacks for a given type. + * + * @param string $abstract + * @return array + */ + protected function getReboundCallbacks($abstract) + { + if (isset($this->reboundCallbacks[$abstract])) + { + return $this->reboundCallbacks[$abstract]; + } + else + { + return array(); + } + } + + /** + * Resolve the given type from the container. + * + * @param string $abstract + * @param array $parameters + * @return mixed + */ + public function make($abstract, $parameters = array()) + { + $abstract = $this->getAlias($abstract); + + $this->resolved[$abstract] = true; + + // If an instance of the type is currently being managed as a singleton we'll + // just return an existing instance instead of instantiating new instances + // so the developer can keep using the same objects instance every time. + if (isset($this->instances[$abstract])) + { + return $this->instances[$abstract]; + } + + $concrete = $this->getConcrete($abstract); + + // We're ready to instantiate an instance of the concrete type registered for + // the binding. This will instantiate the types, as well as resolve any of + // its "nested" dependencies recursively until all have gotten resolved. + if ($this->isBuildable($concrete, $abstract)) + { + $object = $this->build($concrete, $parameters); + } + else + { + $object = $this->make($concrete, $parameters); + } + + // If the requested type is registered as a singleton we'll want to cache off + // the instances in "memory" so we can return it later without creating an + // entirely new instance of an object on each subsequent request for it. + if ($this->isShared($abstract)) + { + $this->instances[$abstract] = $object; + } + + $this->fireResolvingCallbacks($abstract, $object); + + return $object; + } + + /** + * Get the concrete type for a given abstract. + * + * @param string $abstract + * @return mixed $concrete + */ + protected function getConcrete($abstract) + { + // If we don't have a registered resolver or concrete for the type, we'll just + // assume each type is a concrete name and will attempt to resolve it as is + // since the container should be able to resolve concretes automatically. + if ( ! isset($this->bindings[$abstract])) + { + if ($this->missingLeadingSlash($abstract) && isset($this->bindings['\\'.$abstract])) + { + $abstract = '\\'.$abstract; + } + + return $abstract; + } + else + { + return $this->bindings[$abstract]['concrete']; + } + } + + /** + * Determine if the given abstract has a leading slash. + * + * @param string $abstract + * @return bool + */ + protected function missingLeadingSlash($abstract) + { + return is_string($abstract) && strpos($abstract, '\\') !== 0; + } + + /** + * Instantiate a concrete instance of the given type. + * + * @param string $concrete + * @param array $parameters + * @return mixed + * + * @throws BindingResolutionException + */ + public function build($concrete, $parameters = array()) + { + // If the concrete type is actually a Closure, we will just execute it and + // hand back the results of the functions, which allows functions to be + // used as resolvers for more fine-tuned resolution of these objects. + if ($concrete instanceof Closure) + { + return $concrete($this, $parameters); + } + + $reflector = new ReflectionClass($concrete); + + // If the type is not instantiable, the developer is attempting to resolve + // an abstract type such as an Interface of Abstract Class and there is + // no binding registered for the abstractions so we need to bail out. + if ( ! $reflector->isInstantiable()) + { + $message = "Target [$concrete] is not instantiable."; + + throw new BindingResolutionException($message); + } + + $constructor = $reflector->getConstructor(); + + // If there are no constructors, that means there are no dependencies then + // we can just resolve the instances of the objects right away, without + // resolving any other types or dependencies out of these containers. + if (is_null($constructor)) + { + return new $concrete; + } + + $dependencies = $constructor->getParameters(); + + // Once we have all the constructor's parameters we can create each of the + // dependency instances and then use the reflection instances to make a + // new instance of this class, injecting the created dependencies in. + $parameters = $this->keyParametersByArgument( + $dependencies, $parameters + ); + + $instances = $this->getDependencies( + $dependencies, $parameters + ); + + return $reflector->newInstanceArgs($instances); + } + + /** + * Resolve all of the dependencies from the ReflectionParameters. + * + * @param array $parameters + * @param array $primitives + * @return array + */ + protected function getDependencies($parameters, array $primitives = array()) + { + $dependencies = array(); + + foreach ($parameters as $parameter) + { + $dependency = $parameter->getClass(); + + // If the class is null, it means the dependency is a string or some other + // primitive type which we can not resolve since it is not a class and + // we will just bomb out with an error since we have no-where to go. + if (array_key_exists($parameter->name, $primitives)) + { + $dependencies[] = $primitives[$parameter->name]; + } + elseif (is_null($dependency)) + { + $dependencies[] = $this->resolveNonClass($parameter); + } + else + { + $dependencies[] = $this->resolveClass($parameter); + } + } + + return (array) $dependencies; + } + + /** + * Resolve a non-class hinted dependency. + * + * @param ReflectionParameter $parameter + * @return mixed + * + * @throws BindingResolutionException + */ + protected function resolveNonClass(ReflectionParameter $parameter) + { + if ($parameter->isDefaultValueAvailable()) + { + return $parameter->getDefaultValue(); + } + else + { + $message = "Unresolvable dependency resolving [$parameter]."; + + throw new BindingResolutionException($message); + } + } + + /** + * Resolve a class based dependency from the container. + * + * @param \ReflectionParameter $parameter + * @return mixed + * + * @throws BindingResolutionException + */ + protected function resolveClass(ReflectionParameter $parameter) + { + try + { + return $this->make($parameter->getClass()->name); + } + + // If we can not resolve the class instance, we will check to see if the value + // is optional, and if it is we will return the optional parameter value as + // the value of the dependency, similarly to how we do this with scalars. + catch (BindingResolutionException $e) + { + if ($parameter->isOptional()) + { + return $parameter->getDefaultValue(); + } + else + { + throw $e; + } + } + } + + /** + * If extra parameters are passed by numeric ID, rekey them by argument name. + * + * @param array $dependencies + * @param array $parameters + * @param array + * @return array + */ + protected function keyParametersByArgument(array $dependencies, array $parameters) + { + foreach ($parameters as $key => $value) + { + if (is_numeric($key)) + { + unset($parameters[$key]); + + $parameters[$dependencies[$key]->name] = $value; + } + } + + return $parameters; + } + + /** + * Register a new resolving callback. + * + * @param string $abstract + * @param \Closure $callback + * @return void + */ + public function resolving($abstract, Closure $callback) + { + $this->resolvingCallbacks[$abstract][] = $callback; + } + + /** + * Register a new resolving callback for all types. + * + * @param \Closure $callback + * @return void + */ + public function resolvingAny(Closure $callback) + { + $this->globalResolvingCallbacks[] = $callback; + } + + /** + * Fire all of the resolving callbacks. + * + * @param mixed $object + * @return void + */ + protected function fireResolvingCallbacks($abstract, $object) + { + if (isset($this->resolvingCallbacks[$abstract])) + { + $this->fireCallbackArray($object, $this->resolvingCallbacks[$abstract]); + } + + $this->fireCallbackArray($object, $this->globalResolvingCallbacks); + } + + /** + * Fire an array of callbacks with an object. + * + * @param mixed $object + * @param array $callbacks + */ + protected function fireCallbackArray($object, array $callbacks) + { + foreach ($callbacks as $callback) + { + call_user_func($callback, $object, $this); + } + } + + /** + * Determine if a given type is shared. + * + * @param string $abstract + * @return bool + */ + public function isShared($abstract) + { + if (isset($this->bindings[$abstract]['shared'])) + { + $shared = $this->bindings[$abstract]['shared']; + } + else + { + $shared = false; + } + + return isset($this->instances[$abstract]) || $shared === true; + } + + /** + * Determine if the given concrete is buildable. + * + * @param mixed $concrete + * @param string $abstract + * @return bool + */ + protected function isBuildable($concrete, $abstract) + { + return $concrete === $abstract || $concrete instanceof Closure; + } + + /** + * Get the alias for an abstract if available. + * + * @param string $abstract + * @return string + */ + protected function getAlias($abstract) + { + return isset($this->aliases[$abstract]) ? $this->aliases[$abstract] : $abstract; + } + + /** + * Get the container's bindings. + * + * @return array + */ + public function getBindings() + { + return $this->bindings; + } + + /** + * Drop all of the stale instances and aliases. + * + * @param string $abstract + * @return void + */ + protected function dropStaleInstances($abstract) + { + unset($this->instances[$abstract]); + + unset($this->aliases[$abstract]); + } + + /** + * Remove a resolved instance from the instance cache. + * + * @param string $abstract + * @return void + */ + public function forgetInstance($abstract) + { + unset($this->instances[$abstract]); + } + + /** + * Clear all of the instances from the container. + * + * @return void + */ + public function forgetInstances() + { + $this->instances = array(); + } + + /** + * Determine if a given offset exists. + * + * @param string $key + * @return bool + */ + public function offsetExists($key) + { + return isset($this->bindings[$key]); + } + + /** + * Get the value at a given offset. + * + * @param string $key + * @return mixed + */ + public function offsetGet($key) + { + return $this->make($key); + } + + /** + * Set the value at a given offset. + * + * @param string $key + * @param mixed $value + * @return void + */ + public function offsetSet($key, $value) + { + // If the value is not a Closure, we will make it one. This simply gives + // more "drop-in" replacement functionality for the Pimple which this + // container's simplest functions are base modeled and built after. + if ( ! $value instanceof Closure) + { + $value = function() use ($value) + { + return $value; + }; + } + + $this->bind($key, $value); + } + + /** + * Unset the value at a given offset. + * + * @param string $key + * @return void + */ + public function offsetUnset($key) + { + unset($this->bindings[$key]); + + unset($this->instances[$key]); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Container/composer.json b/vendor/laravel/framework/src/Illuminate/Container/composer.json new file mode 100755 index 0000000..67912c2 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Container/composer.json @@ -0,0 +1,28 @@ +{ + "name": "illuminate/container", + "license": "MIT", + "authors": [ + { + "name": "Taylor Otwell", + "email": "taylorotwell@gmail.com" + } + ], + "require": { + "php": ">=5.3.0" + }, + "require-dev": { + "phpunit/phpunit": "4.0.*" + }, + "autoload": { + "psr-0": { + "Illuminate\\Container": "" + } + }, + "target-dir": "Illuminate/Container", + "extra": { + "branch-alias": { + "dev-master": "4.1-dev" + } + }, + "minimum-stability": "dev" +} diff --git a/vendor/laravel/framework/src/Illuminate/Cookie/CookieJar.php b/vendor/laravel/framework/src/Illuminate/Cookie/CookieJar.php new file mode 100755 index 0000000..f5bd7ca --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Cookie/CookieJar.php @@ -0,0 +1,167 @@ +getPathAndDomain($path, $domain); + + $time = ($minutes == 0) ? 0 : time() + ($minutes * 60); + + return new Cookie($name, $value, $time, $path, $domain, $secure, $httpOnly); + } + + /** + * Create a cookie that lasts "forever" (five years). + * + * @param string $name + * @param string $value + * @param string $path + * @param string $domain + * @param bool $secure + * @param bool $httpOnly + * @return \Symfony\Component\HttpFoundation\Cookie + */ + public function forever($name, $value, $path = null, $domain = null, $secure = false, $httpOnly = true) + { + return $this->make($name, $value, 2628000, $path, $domain, $secure, $httpOnly); + } + + /** + * Expire the given cookie. + * + * @param string $name + * @param string $path + * @param string $domain + * @return \Symfony\Component\HttpFoundation\Cookie + */ + public function forget($name, $path = null, $domain = null) + { + return $this->make($name, null, -2628000, $path, $domain); + } + + /** + * Determine if a cookie has been queued. + * + * @param string $key + * @return bool + */ + public function hasQueued($key) + { + return ! is_null($this->queued($key)); + } + + /** + * Get a queued cookie instance. + * + * @param string $key + * @param mixed $default + * @return \Symfony\Component\HttpFoundation\Cookie + */ + public function queued($key, $default = null) + { + return array_get($this->queued, $key, $default); + } + + /** + * Queue a cookie to send with the next response. + * + * @param dynamic + * @return void + */ + public function queue() + { + if (head(func_get_args()) instanceof Cookie) + { + $cookie = head(func_get_args()); + } + else + { + $cookie = call_user_func_array(array($this, 'make'), func_get_args()); + } + + $this->queued[$cookie->getName()] = $cookie; + } + + /** + * Remove a cookie from the queue. + * + * @param $cookieName + */ + public function unqueue($name) + { + unset($this->queued[$name]); + } + + /** + * Get the path and domain, or the default values. + * + * @param string $path + * @param string $domain + * @return array + */ + protected function getPathAndDomain($path, $domain) + { + return array($path ?: $this->path, $domain ?: $this->domain); + } + + /** + * Set the default path and domain for the jar. + * + * @param string $path + * @param string $domain + * @return self + */ + public function setDefaultPathAndDomain($path, $domain) + { + list($this->path, $this->domain) = array($path, $domain); + + return $this; + } + + /** + * Get the cookies which have been queued for the next request + * + * @return array + */ + public function getQueuedCookies() + { + return $this->queued; + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Cookie/CookieServiceProvider.php b/vendor/laravel/framework/src/Illuminate/Cookie/CookieServiceProvider.php new file mode 100755 index 0000000..d02a716 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Cookie/CookieServiceProvider.php @@ -0,0 +1,21 @@ +app->bindShared('cookie', function($app) + { + $config = $app['config']['session']; + + return with(new CookieJar)->setDefaultPathAndDomain($config['path'], $config['domain']); + }); + } +} diff --git a/vendor/laravel/framework/src/Illuminate/Cookie/Guard.php b/vendor/laravel/framework/src/Illuminate/Cookie/Guard.php new file mode 100755 index 0000000..3a2b39e --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Cookie/Guard.php @@ -0,0 +1,141 @@ +app = $app; + $this->encrypter = $encrypter; + } + + /** + * Handle the given request and get the response. + * + * @implements HttpKernelInterface::handle + * + * @param \Symfony\Component\HttpFoundation\Request $request + * @param int $type + * @param bool $catch + * @return \Symfony\Component\HttpFoundation\Response + */ + public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true) + { + return $this->encrypt($this->app->handle($this->decrypt($request), $type, $catch)); + } + + /** + * Decrypt the cookies on the request. + * + * @param \Symfony\Component\HttpFoundation\Request $request + * @return \Symfony\Component\HttpFoundation\Request + */ + protected function decrypt(Request $request) + { + foreach ($request->cookies as $key => $c) + { + try + { + $request->cookies->set($key, $this->decryptCookie($c)); + } + catch (DecryptException $e) + { + $request->cookies->set($key, null); + } + } + + return $request; + } + + /** + * Decrypt the given cookie and return the value. + * + * @param string|array $cookie + * @return string|array + */ + protected function decryptCookie($cookie) + { + return is_array($cookie) + ? $this->decryptArray($cookie) + : $this->encrypter->decrypt($cookie); + } + + /** + * Decrypt an array based cookie. + * + * @param array $cookie + * @return array + */ + protected function decryptArray(array $cookie) + { + $decrypted = array(); + + foreach ($cookie as $key => $value) + { + $decrypted[$key] = $this->encrypter->decrypt($value); + } + + return $decrypted; + } + + /** + * Encrypt the cookies on an outgoing response. + * + * @param \Symfony\Component\HttpFoundation\Response $response + * @return \Symfony\Component\HttpFoundation\Response + */ + protected function encrypt(Response $response) + { + foreach ($response->headers->getCookies() as $key => $c) + { + $encrypted = $this->encrypter->encrypt($c->getValue()); + + $response->headers->setCookie($this->duplicate($c, $encrypted)); + } + + return $response; + } + + /** + * Duplicate a cookie with a new value. + * + * @param \Symfony\Component\HttpFoundation\Cookie $cookie + * @param mixed $value + * @return \Symfony\Component\HttpFoundation\Cookie + */ + protected function duplicate(Cookie $c, $value) + { + return new Cookie( + $c->getName(), $value, $c->getExpiresTime(), $c->getPath(), + $c->getDomain(), $c->isSecure(), $c->isHttpOnly() + ); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Cookie/Queue.php b/vendor/laravel/framework/src/Illuminate/Cookie/Queue.php new file mode 100755 index 0000000..65354cb --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Cookie/Queue.php @@ -0,0 +1,57 @@ +app = $app; + $this->cookies = $cookies; + } + + /** + * Handle the given request and get the response. + * + * @implements HttpKernelInterface::handle + * + * @param \Symfony\Component\HttpFoundation\Request $request + * @param int $type + * @param bool $catch + * @return \Symfony\Component\HttpFoundation\Response + */ + public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true) + { + $response = $this->app->handle($request, $type, $catch); + + foreach ($this->cookies->getQueuedCookies() as $cookie) + { + $response->headers->setCookie($cookie); + } + + return $response; + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Cookie/composer.json b/vendor/laravel/framework/src/Illuminate/Cookie/composer.json new file mode 100755 index 0000000..5c6dd26 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Cookie/composer.json @@ -0,0 +1,33 @@ +{ + "name": "illuminate/cookie", + "license": "MIT", + "authors": [ + { + "name": "Taylor Otwell", + "email": "taylorotwell@gmail.com" + } + ], + "require": { + "php": ">=5.3.0", + "illuminate/encryption": "4.1.*", + "illuminate/support": "4.1.*", + "symfony/http-kernel": "2.4.*", + "symfony/http-foundation": "2.4.*" + }, + "require-dev": { + "mockery/mockery": "0.9.*", + "phpunit/phpunit": "4.0.*" + }, + "autoload": { + "psr-0": { + "Illuminate\\Cookie": "" + } + }, + "target-dir": "Illuminate/Cookie", + "extra": { + "branch-alias": { + "dev-master": "4.1-dev" + } + }, + "minimum-stability": "dev" +} diff --git a/vendor/laravel/framework/src/Illuminate/Database/Capsule/Manager.php b/vendor/laravel/framework/src/Illuminate/Database/Capsule/Manager.php new file mode 100755 index 0000000..812dd1c --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Database/Capsule/Manager.php @@ -0,0 +1,283 @@ +setupContainer($container); + + // Once we have the container setup, we will setup the default configuration + // options in the container "config" binding. This will make the database + // manager behave correctly since all the correct binding are in place. + $this->setupDefaultConfiguration(); + + $this->setupManager(); + } + + /** + * Setup the IoC container instance. + * + * @param \Illuminate\Container\Container|null $container + * @return void + */ + protected function setupContainer($container) + { + $this->container = $container ?: new Container; + + $this->container->instance('config', new Fluent); + } + + /** + * Setup the default database configuration options. + * + * @return void + */ + protected function setupDefaultConfiguration() + { + $this->container['config']['database.fetch'] = PDO::FETCH_ASSOC; + + $this->container['config']['database.default'] = 'default'; + } + + /** + * Build the database manager instance. + * + * @return void + */ + protected function setupManager() + { + $factory = new ConnectionFactory($this->container); + + $this->manager = new DatabaseManager($this->container, $factory); + } + + /** + * Get a connection instance from the global manager. + * + * @param string $connection + * @return \Illuminate\Database\Connection + */ + public static function connection($connection = null) + { + return static::$instance->getConnection($connection); + } + + /** + * Get a fluent query builder instance. + * + * @param string $table + * @param string $connection + * @return \Illuminate\Database\Query\Builder + */ + public static function table($table, $connection = null) + { + return static::$instance->connection($connection)->table($table); + } + + /** + * Get a schema builder instance. + * + * @param string $connection + * @return \Illuminate\Database\Schema\Builder + */ + public static function schema($connection = null) + { + return static::$instance->connection($connection)->getSchemaBuilder(); + } + + /** + * Get a registered connection instance. + * + * @param string $name + * @return \Illuminate\Database\Connection + */ + public function getConnection($name = null) + { + return $this->manager->connection($name); + } + + /** + * Register a connection with the manager. + * + * @param array $config + * @param string $name + * @return void + */ + public function addConnection(array $config, $name = 'default') + { + $connections = $this->container['config']['database.connections']; + + $connections[$name] = $config; + + $this->container['config']['database.connections'] = $connections; + } + + /** + * Bootstrap Eloquent so it is ready for usage. + * + * @return void + */ + public function bootEloquent() + { + Eloquent::setConnectionResolver($this->manager); + + // If we have an event dispatcher instance, we will go ahead and register it + // with the Eloquent ORM, allowing for model callbacks while creating and + // updating "model" instances; however, if it not necessary to operate. + if ($dispatcher = $this->getEventDispatcher()) + { + Eloquent::setEventDispatcher($dispatcher); + } + } + + /** + * Set the fetch mode for the database connections. + * + * @param int $fetchMode + * @return \Illuminate\Database\Capsule\Manager + */ + public function setFetchMode($fetchMode) + { + $this->container['config']['database.fetch'] = $fetchMode; + + return $this; + } + + /** + * Make this capsule instance available globally. + * + * @return void + */ + public function setAsGlobal() + { + static::$instance = $this; + } + + /** + * Get the database manager instance. + * + * @return \Illuminate\Database\Manager + */ + public function getDatabaseManager() + { + return $this->manager; + } + + /** + * Get the current event dispatcher instance. + * + * @return \Illuminate\Events\Dispatcher + */ + public function getEventDispatcher() + { + if ($this->container->bound('events')) + { + return $this->container['events']; + } + } + + /** + * Set the event dispatcher instance to be used by connections. + * + * @param \Illuminate\Events\Dispatcher $dispatcher + * @return void + */ + public function setEventDispatcher(Dispatcher $dispatcher) + { + $this->container->instance('events', $dispatcher); + } + + /** + * Get the current cache manager instance. + * + * @return \Illuminate\Cache\Manager + */ + public function getCacheManager() + { + if ($this->container->bound('cache')) + { + return $this->container['cache']; + } + } + + /** + * Set the cache manager to be used by connections. + * + * @param \Illuminate\Cache\CacheManager $cache + * @return void + */ + public function setCacheManager(CacheManager $cache) + { + $this->container->instance('cache', $cache); + } + + /** + * Get the IoC container instance. + * + * @return \Illuminate\Container\Container + */ + public function getContainer() + { + return $this->container; + } + + /** + * Set the IoC container instance. + * + * @param \Illuminate\Container\Container $container + * @return void + */ + public function setContainer(Container $container) + { + $this->container = $container; + } + + /** + * Dynamically pass methods to the default connection. + * + * @param string $method + * @param array $parameters + * @return mixed + */ + public static function __callStatic($method, $parameters) + { + return call_user_func_array(array(static::connection(), $method), $parameters); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Database/Connection.php b/vendor/laravel/framework/src/Illuminate/Database/Connection.php new file mode 100755 index 0000000..7dc8130 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Database/Connection.php @@ -0,0 +1,1018 @@ +pdo = $pdo; + + // First we will setup the default properties. We keep track of the DB + // name we are connected to since it is needed when some reflective + // type commands are run such as checking whether a table exists. + $this->database = $database; + + $this->tablePrefix = $tablePrefix; + + $this->config = $config; + + // We need to initialize a query grammar and the query post processors + // which are both very important parts of the database abstractions + // so we initialize these to their default values while starting. + $this->useDefaultQueryGrammar(); + + $this->useDefaultPostProcessor(); + } + + /** + * Set the query grammar to the default implementation. + * + * @return void + */ + public function useDefaultQueryGrammar() + { + $this->queryGrammar = $this->getDefaultQueryGrammar(); + } + + /** + * Get the default query grammar instance. + * + * @return \Illuminate\Database\Query\Grammars\Grammar + */ + protected function getDefaultQueryGrammar() + { + return new Query\Grammars\Grammar; + } + + /** + * Set the schema grammar to the default implementation. + * + * @return void + */ + public function useDefaultSchemaGrammar() + { + $this->schemaGrammar = $this->getDefaultSchemaGrammar(); + } + + /** + * Get the default schema grammar instance. + * + * @return \Illuminate\Database\Schema\Grammars\Grammar + */ + protected function getDefaultSchemaGrammar() {} + + /** + * Set the query post processor to the default implementation. + * + * @return void + */ + public function useDefaultPostProcessor() + { + $this->postProcessor = $this->getDefaultPostProcessor(); + } + + /** + * Get the default post processor instance. + * + * @return \Illuminate\Database\Query\Processors\Processor + */ + protected function getDefaultPostProcessor() + { + return new Query\Processors\Processor; + } + + /** + * Get a schema builder instance for the connection. + * + * @return \Illuminate\Database\Schema\Builder + */ + public function getSchemaBuilder() + { + if (is_null($this->schemaGrammar)) { $this->useDefaultSchemaGrammar(); } + + return new Schema\Builder($this); + } + + /** + * Begin a fluent query against a database table. + * + * @param string $table + * @return \Illuminate\Database\Query\Builder + */ + public function table($table) + { + $processor = $this->getPostProcessor(); + + $query = new Query\Builder($this, $this->getQueryGrammar(), $processor); + + return $query->from($table); + } + + /** + * Get a new raw query expression. + * + * @param mixed $value + * @return \Illuminate\Database\Query\Expression + */ + public function raw($value) + { + return new Query\Expression($value); + } + + /** + * Run a select statement and return a single result. + * + * @param string $query + * @param array $bindings + * @return mixed + */ + public function selectOne($query, $bindings = array()) + { + $records = $this->select($query, $bindings); + + return count($records) > 0 ? reset($records) : null; + } + + /** + * Run a select statement against the database. + * + * @param string $query + * @param array $bindings + * @return array + */ + public function select($query, $bindings = array()) + { + return $this->run($query, $bindings, function($me, $query, $bindings) + { + if ($me->pretending()) return array(); + + // For select statements, we'll simply execute the query and return an array + // of the database result set. Each element in the array will be a single + // row from the database table, and will either be an array or objects. + $statement = $me->getReadPdo()->prepare($query); + + $statement->execute($me->prepareBindings($bindings)); + + return $statement->fetchAll($me->getFetchMode()); + }); + } + + /** + * Run an insert statement against the database. + * + * @param string $query + * @param array $bindings + * @return bool + */ + public function insert($query, $bindings = array()) + { + return $this->statement($query, $bindings); + } + + /** + * Run an update statement against the database. + * + * @param string $query + * @param array $bindings + * @return int + */ + public function update($query, $bindings = array()) + { + return $this->affectingStatement($query, $bindings); + } + + /** + * Run a delete statement against the database. + * + * @param string $query + * @param array $bindings + * @return int + */ + public function delete($query, $bindings = array()) + { + return $this->affectingStatement($query, $bindings); + } + + /** + * Execute an SQL statement and return the boolean result. + * + * @param string $query + * @param array $bindings + * @return bool + */ + public function statement($query, $bindings = array()) + { + return $this->run($query, $bindings, function($me, $query, $bindings) + { + if ($me->pretending()) return true; + + $bindings = $me->prepareBindings($bindings); + + return $me->getPdo()->prepare($query)->execute($bindings); + }); + } + + /** + * Run an SQL statement and get the number of rows affected. + * + * @param string $query + * @param array $bindings + * @return int + */ + public function affectingStatement($query, $bindings = array()) + { + return $this->run($query, $bindings, function($me, $query, $bindings) + { + if ($me->pretending()) return 0; + + // For update or delete statements, we want to get the number of rows affected + // by the statement and return that back to the developer. We'll first need + // to execute the statement and then we'll use PDO to fetch the affected. + $statement = $me->getPdo()->prepare($query); + + $statement->execute($me->prepareBindings($bindings)); + + return $statement->rowCount(); + }); + } + + /** + * Run a raw, unprepared query against the PDO connection. + * + * @param string $query + * @return bool + */ + public function unprepared($query) + { + return $this->run($query, array(), function($me, $query) + { + if ($me->pretending()) return true; + + return (bool) $me->getPdo()->exec($query); + }); + } + + /** + * Prepare the query bindings for execution. + * + * @param array $bindings + * @return array + */ + public function prepareBindings(array $bindings) + { + $grammar = $this->getQueryGrammar(); + + foreach ($bindings as $key => $value) + { + // We need to transform all instances of the DateTime class into an actual + // date string. Each query grammar maintains its own date string format + // so we'll just ask the grammar for the format to get from the date. + if ($value instanceof DateTime) + { + $bindings[$key] = $value->format($grammar->getDateFormat()); + } + elseif ($value === false) + { + $bindings[$key] = 0; + } + } + + return $bindings; + } + + /** + * Execute a Closure within a transaction. + * + * @param Closure $callback + * @return mixed + * + * @throws \Exception + */ + public function transaction(Closure $callback) + { + $this->beginTransaction(); + + // We'll simply execute the given callback within a try / catch block + // and if we catch any exception we can rollback the transaction + // so that none of the changes are persisted to the database. + try + { + $result = $callback($this); + + $this->commit(); + } + + // If we catch an exception, we will roll back so nothing gets messed + // up in the database. Then we'll re-throw the exception so it can + // be handled how the developer sees fit for their applications. + catch (\Exception $e) + { + $this->rollBack(); + + throw $e; + } + + return $result; + } + + /** + * Start a new database transaction. + * + * @return void + */ + public function beginTransaction() + { + ++$this->transactions; + + if ($this->transactions == 1) + { + $this->pdo->beginTransaction(); + } + + $this->fireConnectionEvent('beganTransaction'); + } + + /** + * Commit the active database transaction. + * + * @return void + */ + public function commit() + { + if ($this->transactions == 1) $this->pdo->commit(); + + --$this->transactions; + + $this->fireConnectionEvent('committed'); + } + + /** + * Rollback the active database transaction. + * + * @return void + */ + public function rollBack() + { + if ($this->transactions == 1) + { + $this->transactions = 0; + + $this->pdo->rollBack(); + } + else + { + --$this->transactions; + } + + $this->fireConnectionEvent('rollingBack'); + } + + /** + * Get the number of active transactions. + * + * @return int + */ + public function transactionLevel() + { + return $this->transactions; + } + + /** + * Execute the given callback in "dry run" mode. + * + * @param Closure $callback + * @return array + */ + public function pretend(Closure $callback) + { + $this->pretending = true; + + $this->queryLog = array(); + + // Basically to make the database connection "pretend", we will just return + // the default values for all the query methods, then we will return an + // array of queries that were "executed" within the Closure callback. + $callback($this); + + $this->pretending = false; + + return $this->queryLog; + } + + /** + * Run a SQL statement and log its execution context. + * + * @param string $query + * @param array $bindings + * @param Closure $callback + * @return mixed + * + * @throws QueryException + */ + protected function run($query, $bindings, Closure $callback) + { + $start = microtime(true); + + // To execute the statement, we'll simply call the callback, which will actually + // run the SQL against the PDO connection. Then we can calculate the time it + // took to execute and log the query SQL, bindings and time in our memory. + try + { + $result = $callback($this, $query, $bindings); + } + + // If an exception occurs when attempting to run a query, we'll format the error + // message to include the bindings with SQL, which will make this exception a + // lot more helpful to the developer instead of just the database's errors. + catch (\Exception $e) + { + throw new QueryException($query, $this->prepareBindings($bindings), $e); + } + + // Once we have run the query we will calculate the time that it took to run and + // then log the query, bindings, and execution time so we will report them on + // the event that the developer needs them. We'll log time in milliseconds. + $time = $this->getElapsedTime($start); + + $this->logQuery($query, $bindings, $time); + + return $result; + } + + /** + * Log a query in the connection's query log. + * + * @param string $query + * @param array $bindings + * @param $time + * @return void + */ + public function logQuery($query, $bindings, $time = null) + { + if (isset($this->events)) + { + $this->events->fire('illuminate.query', array($query, $bindings, $time, $this->getName())); + } + + if ( ! $this->loggingQueries) return; + + $this->queryLog[] = compact('query', 'bindings', 'time'); + } + + /** + * Register a database query listener with the connection. + * + * @param Closure $callback + * @return void + */ + public function listen(Closure $callback) + { + if (isset($this->events)) + { + $this->events->listen('illuminate.query', $callback); + } + } + + /** + * Fire an event for this connection. + * + * @param string $event + * @return void + */ + protected function fireConnectionEvent($event) + { + if (isset($this->events)) + { + $this->events->fire('connection.'.$this->getName().'.'.$event, $this); + } + } + + /** + * Get the elapsed time since a given starting point. + * + * @param int $start + * @return float + */ + protected function getElapsedTime($start) + { + return round((microtime(true) - $start) * 1000, 2); + } + + /** + * Get a Doctrine Schema Column instance. + * + * @param string $table + * @param string $column + * @return \Doctrine\DBAL\Schema\Column + */ + public function getDoctrineColumn($table, $column) + { + $schema = $this->getDoctrineSchemaManager(); + + return $schema->listTableDetails($table)->getColumn($column); + } + + /** + * Get the Doctrine DBAL schema manager for the connection. + * + * @return \Doctrine\DBAL\Schema\AbstractSchemaManager + */ + public function getDoctrineSchemaManager() + { + return $this->getDoctrineDriver()->getSchemaManager($this->getDoctrineConnection()); + } + + /** + * Get the Doctrine DBAL database connection instance. + * + * @return \Doctrine\DBAL\Connection + */ + public function getDoctrineConnection() + { + $driver = $this->getDoctrineDriver(); + + $data = array('pdo' => $this->pdo, 'dbname' => $this->getConfig('database')); + + return new DoctrineConnection($data, $driver); + } + + /** + * Get the current PDO connection. + * + * @return PDO + */ + public function getPdo() + { + return $this->pdo; + } + + /** + * Get the current PDO connection used for reading. + * + * @return PDO + */ + public function getReadPdo() + { + if ($this->transactions >= 1) return $this->getPdo(); + + return $this->readPdo ?: $this->pdo; + } + + /** + * Set the PDO connection. + * + * @param PDO $pdo + * @return \Illuminate\Database\Connection + */ + public function setPdo(PDO $pdo) + { + $this->pdo = $pdo; + + return $this; + } + + /** + * Set the PDO connection used for reading. + * + * @param PDO $pdo + * @return \Illuminate\Database\Connection + */ + public function setReadPdo(PDO $pdo) + { + $this->readPdo = $pdo; + + return $this; + } + + /** + * Get the database connection name. + * + * @return string|null + */ + public function getName() + { + return $this->getConfig('name'); + } + + /** + * Get an option from the configuration options. + * + * @param string $option + * @return mixed + */ + public function getConfig($option) + { + return array_get($this->config, $option); + } + + /** + * Get the PDO driver name. + * + * @return string + */ + public function getDriverName() + { + return $this->pdo->getAttribute(\PDO::ATTR_DRIVER_NAME); + } + + /** + * Get the query grammar used by the connection. + * + * @return \Illuminate\Database\Query\Grammars\Grammar + */ + public function getQueryGrammar() + { + return $this->queryGrammar; + } + + /** + * Set the query grammar used by the connection. + * + * @param \Illuminate\Database\Query\Grammars\Grammar + * @return void + */ + public function setQueryGrammar(Query\Grammars\Grammar $grammar) + { + $this->queryGrammar = $grammar; + } + + /** + * Get the schema grammar used by the connection. + * + * @return \Illuminate\Database\Query\Grammars\Grammar + */ + public function getSchemaGrammar() + { + return $this->schemaGrammar; + } + + /** + * Set the schema grammar used by the connection. + * + * @param \Illuminate\Database\Schema\Grammars\Grammar + * @return void + */ + public function setSchemaGrammar(Schema\Grammars\Grammar $grammar) + { + $this->schemaGrammar = $grammar; + } + + /** + * Get the query post processor used by the connection. + * + * @return \Illuminate\Database\Query\Processors\Processor + */ + public function getPostProcessor() + { + return $this->postProcessor; + } + + /** + * Set the query post processor used by the connection. + * + * @param \Illuminate\Database\Query\Processors\Processor + * @return void + */ + public function setPostProcessor(Processor $processor) + { + $this->postProcessor = $processor; + } + + /** + * Get the event dispatcher used by the connection. + * + * @return \Illuminate\Events\Dispatcher + */ + public function getEventDispatcher() + { + return $this->events; + } + + /** + * Set the event dispatcher instance on the connection. + * + * @param \Illuminate\Events\Dispatcher + * @return void + */ + public function setEventDispatcher(\Illuminate\Events\Dispatcher $events) + { + $this->events = $events; + } + + /** + * Get the paginator environment instance. + * + * @return \Illuminate\Pagination\Environment + */ + public function getPaginator() + { + if ($this->paginator instanceof Closure) + { + $this->paginator = call_user_func($this->paginator); + } + + return $this->paginator; + } + + /** + * Set the pagination environment instance. + * + * @param \Illuminate\Pagination\Environment|\Closure $paginator + * @return void + */ + public function setPaginator($paginator) + { + $this->paginator = $paginator; + } + + /** + * Get the cache manager instance. + * + * @return \Illuminate\Cache\CacheManager + */ + public function getCacheManager() + { + if ($this->cache instanceof Closure) + { + $this->cache = call_user_func($this->cache); + } + + return $this->cache; + } + + /** + * Set the cache manager instance on the connection. + * + * @param \Illuminate\Cache\CacheManager|\Closure $cache + * @return void + */ + public function setCacheManager($cache) + { + $this->cache = $cache; + } + + /** + * Determine if the connection in a "dry run". + * + * @return bool + */ + public function pretending() + { + return $this->pretending === true; + } + + /** + * Get the default fetch mode for the connection. + * + * @return int + */ + public function getFetchMode() + { + return $this->fetchMode; + } + + /** + * Set the default fetch mode for the connection. + * + * @param int $fetchMode + * @return int + */ + public function setFetchMode($fetchMode) + { + $this->fetchMode = $fetchMode; + } + + /** + * Get the connection query log. + * + * @return array + */ + public function getQueryLog() + { + return $this->queryLog; + } + + /** + * Clear the query log. + * + * @return void + */ + public function flushQueryLog() + { + $this->queryLog = array(); + } + + /** + * Enable the query log on the connection. + * + * @return void + */ + public function enableQueryLog() + { + $this->loggingQueries = true; + } + + /** + * Disable the query log on the connection. + * + * @return void + */ + public function disableQueryLog() + { + $this->loggingQueries = false; + } + + /** + * Determine whether we're logging queries. + * + * @return bool + */ + public function logging() + { + return $this->loggingQueries; + } + + /** + * Get the name of the connected database. + * + * @return string + */ + public function getDatabaseName() + { + return $this->database; + } + + /** + * Set the name of the connected database. + * + * @param string $database + * @return string + */ + public function setDatabaseName($database) + { + $this->database = $database; + } + + /** + * Get the table prefix for the connection. + * + * @return string + */ + public function getTablePrefix() + { + return $this->tablePrefix; + } + + /** + * Set the table prefix in use by the connection. + * + * @param string $prefix + * @return void + */ + public function setTablePrefix($prefix) + { + $this->tablePrefix = $prefix; + + $this->getQueryGrammar()->setTablePrefix($prefix); + } + + /** + * Set the table prefix and return the grammar. + * + * @param \Illuminate\Database\Grammar $grammar + * @return \Illuminate\Database\Grammar + */ + public function withTablePrefix(Grammar $grammar) + { + $grammar->setTablePrefix($this->tablePrefix); + + return $grammar; + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Database/ConnectionInterface.php b/vendor/laravel/framework/src/Illuminate/Database/ConnectionInterface.php new file mode 100755 index 0000000..f6ff5e0 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Database/ConnectionInterface.php @@ -0,0 +1,69 @@ + $connection) + { + $this->addConnection($name, $connection); + } + } + + /** + * Get a database connection instance. + * + * @param string $name + * @return \Illuminate\Database\Connection + */ + public function connection($name = null) + { + if (is_null($name)) $name = $this->getDefaultConnection(); + + return $this->connections[$name]; + } + + /** + * Add a connection to the resolver. + * + * @param string $name + * @param \Illuminate\Database\Connection $connection + * @return void + */ + public function addConnection($name, Connection $connection) + { + $this->connections[$name] = $connection; + } + + /** + * Check if a connection has been registered. + * + * @param string $name + * @return bool + */ + public function hasConnection($name) + { + return isset($this->connections[$name]); + } + + /** + * Get the default connection name. + * + * @return string + */ + public function getDefaultConnection() + { + return $this->default; + } + + /** + * Set the default connection name. + * + * @param string $name + * @return void + */ + public function setDefaultConnection($name) + { + $this->default = $name; + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Database/ConnectionResolverInterface.php b/vendor/laravel/framework/src/Illuminate/Database/ConnectionResolverInterface.php new file mode 100755 index 0000000..46abdc0 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Database/ConnectionResolverInterface.php @@ -0,0 +1,28 @@ +container = $container; + } + + /** + * Establish a PDO connection based on the configuration. + * + * @param array $config + * @param string $name + * @return \Illuminate\Database\Connection + */ + public function make(array $config, $name = null) + { + $config = $this->parseConfig($config, $name); + + if (isset($config['read'])) + { + return $this->createReadWriteConnection($config); + } + else + { + return $this->createSingleConnection($config); + } + } + + /** + * Create a single database connection instance. + * + * @param array $config + * @return \Illuminate\Database\Connection + */ + protected function createSingleConnection(array $config) + { + $pdo = $this->createConnector($config)->connect($config); + + return $this->createConnection($config['driver'], $pdo, $config['database'], $config['prefix'], $config); + } + + /** + * Create a single database connection instance. + * + * @param array $config + * @return \Illuminate\Database\Connection + */ + protected function createReadWriteConnection(array $config) + { + $connection = $this->createSingleConnection($this->getWriteConfig($config)); + + return $connection->setReadPdo($this->createReadPdo($config)); + } + + /** + * Create a new PDO instance for reading. + * + * @param array $config + * @return \PDO + */ + protected function createReadPdo(array $config) + { + $readConfig = $this->getReadConfig($config); + + return $this->createConnector($readConfig)->connect($readConfig); + } + + /** + * Get the read configuration for a read / write connection. + * + * @param array $config + * @return array + */ + protected function getReadConfig(array $config) + { + $readConfig = $this->getReadWriteConfig($config, 'read'); + + return $this->mergeReadWriteConfig($config, $readConfig); + } + + /** + * Get the read configuration for a read / write connection. + * + * @param array $config + * @return array + */ + protected function getWriteConfig(array $config) + { + $writeConfig = $this->getReadWriteConfig($config, 'write'); + + return $this->mergeReadWriteConfig($config, $writeConfig); + } + + /** + * Get a read / write level configuration. + * + * @param array $config + * @param string $type + * @return array + */ + protected function getReadWriteConfig(array $config, $type) + { + if (isset($config[$type][0])) + { + return $config[$type][array_rand($config[$type])]; + } + else + { + return $config[$type]; + } + } + + /** + * Merge a configuration for a read / write connection. + * + * @param array $config + * @param array $merge + * @return array + */ + protected function mergeReadWriteConfig(array $config, array $merge) + { + return array_except(array_merge($config, $merge), array('read', 'write')); + } + + /** + * Parse and prepare the database configuration. + * + * @param array $config + * @param string $name + * @return array + */ + protected function parseConfig(array $config, $name) + { + return array_add(array_add($config, 'prefix', ''), 'name', $name); + } + + /** + * Create a connector instance based on the configuration. + * + * @param array $config + * @return \Illuminate\Database\Connectors\ConnectorInterface + * + * @throws \InvalidArgumentException + */ + public function createConnector(array $config) + { + if ( ! isset($config['driver'])) + { + throw new \InvalidArgumentException("A driver must be specified."); + } + + if ($this->container->bound($key = "db.connector.{$config['driver']}")) + { + return $this->container->make($key); + } + + switch ($config['driver']) + { + case 'mysql': + return new MySqlConnector; + + case 'pgsql': + return new PostgresConnector; + + case 'sqlite': + return new SQLiteConnector; + + case 'sqlsrv': + return new SqlServerConnector; + } + + throw new \InvalidArgumentException("Unsupported driver [{$config['driver']}]"); + } + + /** + * Create a new connection instance. + * + * @param string $driver + * @param PDO $connection + * @param string $database + * @param string $prefix + * @param array $config + * @return \Illuminate\Database\Connection + * + * @throws \InvalidArgumentException + */ + protected function createConnection($driver, PDO $connection, $database, $prefix = '', array $config = array()) + { + if ($this->container->bound($key = "db.connection.{$driver}")) + { + return $this->container->make($key, array($connection, $database, $prefix, $config)); + } + + switch ($driver) + { + case 'mysql': + return new MySqlConnection($connection, $database, $prefix, $config); + + case 'pgsql': + return new PostgresConnection($connection, $database, $prefix, $config); + + case 'sqlite': + return new SQLiteConnection($connection, $database, $prefix, $config); + + case 'sqlsrv': + return new SqlServerConnection($connection, $database, $prefix, $config); + } + + throw new \InvalidArgumentException("Unsupported driver [$driver]"); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php b/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php new file mode 100755 index 0000000..90648b6 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php @@ -0,0 +1,71 @@ + PDO::CASE_NATURAL, + PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, + PDO::ATTR_ORACLE_NULLS => PDO::NULL_NATURAL, + PDO::ATTR_STRINGIFY_FETCHES => false, + PDO::ATTR_EMULATE_PREPARES => false, + ); + + /** + * Get the PDO options based on the configuration. + * + * @param array $config + * @return array + */ + public function getOptions(array $config) + { + $options = array_get($config, 'options', array()); + + return array_diff_key($this->options, $options) + $options; + } + + /** + * Create a new PDO connection. + * + * @param string $dsn + * @param array $config + * @param array $options + * @return PDO + */ + public function createConnection($dsn, array $config, array $options) + { + $username = array_get($config, 'username'); + + $password = array_get($config, 'password'); + + return new PDO($dsn, $username, $password, $options); + } + + /** + * Get the default PDO connection options. + * + * @return array + */ + public function getDefaultOptions() + { + return $this->options; + } + + /** + * Set the default PDO connection options. + * + * @param array $options + * @return void + */ + public function setDefaultOptions(array $options) + { + $this->options = $options; + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Database/Connectors/ConnectorInterface.php b/vendor/laravel/framework/src/Illuminate/Database/Connectors/ConnectorInterface.php new file mode 100755 index 0000000..c2c76a5 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Database/Connectors/ConnectorInterface.php @@ -0,0 +1,13 @@ +getDsn($config); + + // We need to grab the PDO options that should be used while making the brand + // new connection instance. The PDO options control various aspects of the + // connection's behavior, and some might be specified by the developers. + $options = $this->getOptions($config); + + $connection = $this->createConnection($dsn, $config, $options); + + $collation = $config['collation']; + + // Next we will set the "names" and "collation" on the clients connections so + // a correct character set will be used by this client. The collation also + // is set on the server but needs to be set here on this client objects. + $charset = $config['charset']; + + $names = "set names '$charset'". + ( ! is_null($collation) ? " collate '$collation'" : ''); + + $connection->prepare($names)->execute(); + + // If the "strict" option has been configured for the connection we'll enable + // strict mode on all of these tables. This enforces some extra rules when + // using the MySQL database system and is a quicker way to enforce them. + if (isset($config['strict']) && $config['strict']) + { + $connection->prepare("set session sql_mode='STRICT_ALL_TABLES'")->execute(); + } + + return $connection; + } + + /** + * Create a DSN string from a configuration. + * + * @param array $config + * @return string + */ + protected function getDsn(array $config) + { + // First we will create the basic DSN setup as well as the port if it is in + // in the configuration options. This will give us the basic DSN we will + // need to establish the PDO connections and return them back for use. + extract($config); + + $dsn = "mysql:host={$host};dbname={$database}"; + + if (isset($config['port'])) + { + $dsn .= ";port={$port}"; + } + + // Sometimes the developer may specify the specific UNIX socket that should + // be used. If that is the case we will add that option to the string we + // have created so that it gets utilized while the connection is made. + if (isset($config['unix_socket'])) + { + $dsn .= ";unix_socket={$config['unix_socket']}"; + } + + return $dsn; + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Database/Connectors/PostgresConnector.php b/vendor/laravel/framework/src/Illuminate/Database/Connectors/PostgresConnector.php new file mode 100755 index 0000000..8a2ff23 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Database/Connectors/PostgresConnector.php @@ -0,0 +1,82 @@ + PDO::CASE_NATURAL, + PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, + PDO::ATTR_ORACLE_NULLS => PDO::NULL_NATURAL, + PDO::ATTR_STRINGIFY_FETCHES => false, + ); + + + /** + * Establish a database connection. + * + * @param array $config + * @return PDO + */ + public function connect(array $config) + { + // First we'll create the basic DSN and connection instance connecting to the + // using the configuration option specified by the developer. We will also + // set the default character set on the connections to UTF-8 by default. + $dsn = $this->getDsn($config); + + $options = $this->getOptions($config); + + $connection = $this->createConnection($dsn, $config, $options); + + $charset = $config['charset']; + + $connection->prepare("set names '$charset'")->execute(); + + // Unlike MySQL, Postgres allows the concept of "schema" and a default schema + // may have been specified on the connections. If that is the case we will + // set the default schema search paths to the specified database schema. + if (isset($config['schema'])) + { + $schema = $config['schema']; + + $connection->prepare("set search_path to {$schema}")->execute(); + } + + return $connection; + } + + /** + * Create a DSN string from a configuration. + * + * @param array $config + * @return string + */ + protected function getDsn(array $config) + { + // First we will create the basic DSN setup as well as the port if it is in + // in the configuration options. This will give us the basic DSN we will + // need to establish the PDO connections and return them back for use. + extract($config); + + $host = isset($host) ? "host={$host};" : ''; + + $dsn = "pgsql:{$host}dbname={$database}"; + + // If a port was specified, we will add it to this Postgres DSN connections + // format. Once we have done that we are ready to return this connection + // string back out for usage, as this has been fully constructed here. + if (isset($config['port'])) + { + $dsn .= ";port={$port}"; + } + + return $dsn; + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Database/Connectors/SQLiteConnector.php b/vendor/laravel/framework/src/Illuminate/Database/Connectors/SQLiteConnector.php new file mode 100755 index 0000000..596ef28 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Database/Connectors/SQLiteConnector.php @@ -0,0 +1,38 @@ +getOptions($config); + + // SQLite supports "in-memory" databases that only last as long as the owning + // connection does. These are useful for tests or for short lifetime store + // querying. In-memory databases may only have a single open connection. + if ($config['database'] == ':memory:') + { + return $this->createConnection('sqlite::memory:', $config, $options); + } + + $path = realpath($config['database']); + + // Here we'll verify that the SQLite database exists before going any further + // as the developer probably wants to know if the database exists and this + // SQLite driver will not throw any exception if it does not by default. + if ($path === false) + { + throw new \InvalidArgumentException("Database does not exist."); + } + + return $this->createConnection("sqlite:{$path}", $config, $options); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Database/Connectors/SqlServerConnector.php b/vendor/laravel/framework/src/Illuminate/Database/Connectors/SqlServerConnector.php new file mode 100755 index 0000000..deb7d34 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Database/Connectors/SqlServerConnector.php @@ -0,0 +1,69 @@ + PDO::CASE_NATURAL, + PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, + PDO::ATTR_ORACLE_NULLS => PDO::NULL_NATURAL, + PDO::ATTR_STRINGIFY_FETCHES => false, + ); + + /** + * Establish a database connection. + * + * @param array $config + * @return PDO + */ + public function connect(array $config) + { + $options = $this->getOptions($config); + + return $this->createConnection($this->getDsn($config), $config, $options); + } + + /** + * Create a DSN string from a configuration. + * + * @param array $config + * @return string + */ + protected function getDsn(array $config) + { + extract($config); + + // First we will create the basic DSN setup as well as the port if it is in + // in the configuration options. This will give us the basic DSN we will + // need to establish the PDO connections and return them back for use. + $port = isset($config['port']) ? ','.$port : ''; + + if (in_array('dblib', $this->getAvailableDrivers())) + { + return "dblib:host={$host}{$port};dbname={$database}"; + } + else + { + $dbName = $database != '' ? ";Database={$database}" : ''; + + return "sqlsrv:Server={$host}{$port}{$dbName}"; + } + } + + /** + * Get the available PDO drivers. + * + * @return array + */ + protected function getAvailableDrivers() + { + return PDO::getAvailableDrivers(); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/BaseCommand.php b/vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/BaseCommand.php new file mode 100755 index 0000000..7dfef57 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/BaseCommand.php @@ -0,0 +1,49 @@ +input->getOption('path'); + + // First, we will check to see if a path option has been defined. If it has + // we will use the path relative to the root of this installation folder + // so that migrations may be run for any path within the applications. + if ( ! is_null($path)) + { + return $this->laravel['path.base'].'/'.$path; + } + + $package = $this->input->getOption('package'); + + // If the package is in the list of migration paths we received we will put + // the migrations in that path. Otherwise, we will assume the package is + // is in the package directories and will place them in that location. + if ( ! is_null($package)) + { + return $this->packagePath.'/'.$package.'/src/migrations'; + } + + $bench = $this->input->getOption('bench'); + + // Finally we will check for the workbench option, which is a shortcut into + // specifying the full path for a "workbench" project. Workbenches allow + // developers to develop packages along side a "standard" app install. + if ( ! is_null($bench)) + { + $path = "/workbench/{$bench}/src/migrations"; + + return $this->laravel['path.base'].$path; + } + + return $this->laravel['path'].'/database/migrations'; + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/InstallCommand.php b/vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/InstallCommand.php new file mode 100755 index 0000000..d89c0c4 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/InstallCommand.php @@ -0,0 +1,69 @@ +repository = $repository; + } + + /** + * Execute the console command. + * + * @return void + */ + public function fire() + { + $this->repository->setSource($this->input->getOption('database')); + + $this->repository->createRepository(); + + $this->info("Migration table created successfully."); + } + + /** + * Get the console command options. + * + * @return array + */ + protected function getOptions() + { + return array( + array('database', null, InputOption::VALUE_OPTIONAL, 'The database connection to use.'), + ); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/MigrateCommand.php b/vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/MigrateCommand.php new file mode 100755 index 0000000..b9c9533 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/MigrateCommand.php @@ -0,0 +1,123 @@ +migrator = $migrator; + $this->packagePath = $packagePath; + } + + /** + * Execute the console command. + * + * @return void + */ + public function fire() + { + $this->prepareDatabase(); + + // The pretend option can be used for "simulating" the migration and grabbing + // the SQL queries that would fire if the migration were to be run against + // a database for real, which is helpful for double checking migrations. + $pretend = $this->input->getOption('pretend'); + + $path = $this->getMigrationPath(); + + $this->migrator->run($path, $pretend); + + // Once the migrator has run we will grab the note output and send it out to + // the console screen, since the migrator itself functions without having + // any instances of the OutputInterface contract passed into the class. + foreach ($this->migrator->getNotes() as $note) + { + $this->output->writeln($note); + } + + // Finally, if the "seed" option has been given, we will re-run the database + // seed task to re-populate the database, which is convenient when adding + // a migration and a seed at the same time, as it is only this command. + if ($this->input->getOption('seed')) + { + $this->call('db:seed'); + } + } + + /** + * Prepare the migration database for running. + * + * @return void + */ + protected function prepareDatabase() + { + $this->migrator->setConnection($this->input->getOption('database')); + + if ( ! $this->migrator->repositoryExists()) + { + $options = array('--database' => $this->input->getOption('database')); + + $this->call('migrate:install', $options); + } + } + + /** + * Get the console command options. + * + * @return array + */ + protected function getOptions() + { + return array( + array('bench', null, InputOption::VALUE_OPTIONAL, 'The name of the workbench to migrate.', null), + + array('database', null, InputOption::VALUE_OPTIONAL, 'The database connection to use.'), + + array('path', null, InputOption::VALUE_OPTIONAL, 'The path to migration files.', null), + + array('package', null, InputOption::VALUE_OPTIONAL, 'The package to migrate.', null), + + array('pretend', null, InputOption::VALUE_NONE, 'Dump the SQL queries that would be run.'), + + array('seed', null, InputOption::VALUE_NONE, 'Indicates if the seed task should be re-run.'), + ); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/MigrateMakeCommand.php b/vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/MigrateMakeCommand.php new file mode 100755 index 0000000..5fc6933 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/MigrateMakeCommand.php @@ -0,0 +1,127 @@ +creator = $creator; + $this->packagePath = $packagePath; + } + + /** + * Execute the console command. + * + * @return void + */ + public function fire() + { + // It's possible for the developer to specify the tables to modify in this + // schema operation. The developer may also specify if this table needs + // to be freshly created so we can create the appropriate migrations. + $name = $this->input->getArgument('name'); + + $table = $this->input->getOption('table'); + + $create = $this->input->getOption('create'); + + if ( ! $table && is_string($create)) $table = $create; + + // Now we are ready to write the migration out to disk. Once we've written + // the migration out, we will dump-autoload for the entire framework to + // make sure that the migrations are registered by the class loaders. + $this->writeMigration($name, $table, $create); + + $this->call('dump-autoload'); + } + + /** + * Write the migration file to disk. + * + * @param string $name + * @param string $table + * @param bool $create + * @return string + */ + protected function writeMigration($name, $table, $create) + { + $path = $this->getMigrationPath(); + + $file = pathinfo($this->creator->create($name, $path, $table, $create), PATHINFO_FILENAME); + + $this->line("Created Migration: $file"); + } + + /** + * Get the console command arguments. + * + * @return array + */ + protected function getArguments() + { + return array( + array('name', InputArgument::REQUIRED, 'The name of the migration'), + ); + } + + /** + * Get the console command options. + * + * @return array + */ + protected function getOptions() + { + return array( + array('bench', null, InputOption::VALUE_OPTIONAL, 'The workbench the migration belongs to.', null), + + array('create', null, InputOption::VALUE_OPTIONAL, 'The table to be created.'), + + array('package', null, InputOption::VALUE_OPTIONAL, 'The package the migration belongs to.', null), + + array('path', null, InputOption::VALUE_OPTIONAL, 'Where to store the migration.', null), + + array('table', null, InputOption::VALUE_OPTIONAL, 'The table to migrate.'), + ); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/RefreshCommand.php b/vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/RefreshCommand.php new file mode 100755 index 0000000..f627f84 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/RefreshCommand.php @@ -0,0 +1,83 @@ +input->getOption('database'); + + $this->call('migrate:reset', array('--database' => $database)); + + // The refresh command is essentially just a brief aggregate of a few other of + // the migration commands and just provides a convenient wrapper to execute + // them in succession. We'll also see if we need to re-seed the database. + $this->call('migrate', array('--database' => $database)); + + if ($this->needsSeeding()) + { + $this->runSeeder($database); + } + } + + /** + * Determine if the developer has requested database seeding. + * + * @return bool + */ + protected function needsSeeding() + { + return $this->option('seed') || $this->option('seeder'); + } + + /** + * Run the database seeder command. + * + * @param string $database + * @return void + */ + protected function runSeeder($database) + { + $class = $this->option('seeder') ?: 'DatabaseSeeder'; + + $this->call('db:seed', array('--database' => $database, '--class' => $class)); + } + + /** + * Get the console command options. + * + * @return array + */ + protected function getOptions() + { + return array( + array('database', null, InputOption::VALUE_OPTIONAL, 'The database connection to use.'), + + array('seed', null, InputOption::VALUE_NONE, 'Indicates if the seed task should be re-run.'), + + array('seeder', null, InputOption::VALUE_OPTIONAL, 'The class name of the root seeder.'), + ); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/ResetCommand.php b/vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/ResetCommand.php new file mode 100755 index 0000000..223ee40 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/ResetCommand.php @@ -0,0 +1,84 @@ +migrator = $migrator; + } + + /** + * Execute the console command. + * + * @return void + */ + public function fire() + { + $this->migrator->setConnection($this->input->getOption('database')); + + $pretend = $this->input->getOption('pretend'); + + while (true) + { + $count = $this->migrator->rollback($pretend); + + // Once the migrator has run we will grab the note output and send it out to + // the console screen, since the migrator itself functions without having + // any instances of the OutputInterface contract passed into the class. + foreach ($this->migrator->getNotes() as $note) + { + $this->output->writeln($note); + } + + if ($count == 0) break; + } + } + + /** + * Get the console command options. + * + * @return array + */ + protected function getOptions() + { + return array( + array('database', null, InputOption::VALUE_OPTIONAL, 'The database connection to use.'), + + array('pretend', null, InputOption::VALUE_NONE, 'Dump the SQL queries that would be run.'), + ); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/RollbackCommand.php b/vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/RollbackCommand.php new file mode 100755 index 0000000..8e85488 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/RollbackCommand.php @@ -0,0 +1,79 @@ +migrator = $migrator; + } + + /** + * Execute the console command. + * + * @return void + */ + public function fire() + { + $this->migrator->setConnection($this->input->getOption('database')); + + $pretend = $this->input->getOption('pretend'); + + $this->migrator->rollback($pretend); + + // Once the migrator has run we will grab the note output and send it out to + // the console screen, since the migrator itself functions without having + // any instances of the OutputInterface contract passed into the class. + foreach ($this->migrator->getNotes() as $note) + { + $this->output->writeln($note); + } + } + + /** + * Get the console command options. + * + * @return array + */ + protected function getOptions() + { + return array( + array('database', null, InputOption::VALUE_OPTIONAL, 'The database connection to use.'), + + array('pretend', null, InputOption::VALUE_NONE, 'Dump the SQL queries that would be run.'), + ); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Database/Console/SeedCommand.php b/vendor/laravel/framework/src/Illuminate/Database/Console/SeedCommand.php new file mode 100755 index 0000000..c9197e6 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Database/Console/SeedCommand.php @@ -0,0 +1,93 @@ +resolver = $resolver; + } + + /** + * Execute the console command. + * + * @return void + */ + public function fire() + { + $this->resolver->setDefaultConnection($this->getDatabase()); + + $this->getSeeder()->run(); + } + + /** + * Get a seeder instance from the container. + * + * @return \Illuminate\Database\Seeder + */ + protected function getSeeder() + { + $class = $this->laravel->make($this->input->getOption('class')); + + return $class->setContainer($this->laravel)->setCommand($this); + } + + /** + * Get the name of the database connection to use. + * + * @return string + */ + protected function getDatabase() + { + $database = $this->input->getOption('database'); + + return $database ?: $this->laravel['config']['database.default']; + } + + /** + * Get the console command options. + * + * @return array + */ + protected function getOptions() + { + return array( + array('class', null, InputOption::VALUE_OPTIONAL, 'The class name of the root seeder', 'DatabaseSeeder'), + + array('database', null, InputOption::VALUE_OPTIONAL, 'The database connection to seed'), + ); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Database/DatabaseManager.php b/vendor/laravel/framework/src/Illuminate/Database/DatabaseManager.php new file mode 100755 index 0000000..01ed3f6 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Database/DatabaseManager.php @@ -0,0 +1,246 @@ +app = $app; + $this->factory = $factory; + } + + /** + * Get a database connection instance. + * + * @param string $name + * @return \Illuminate\Database\Connection + */ + public function connection($name = null) + { + $name = $name ?: $this->getDefaultConnection(); + + // If we haven't created this connection, we'll create it based on the config + // provided in the application. Once we've created the connections we will + // set the "fetch mode" for PDO which determines the query return types. + if ( ! isset($this->connections[$name])) + { + $connection = $this->makeConnection($name); + + $this->connections[$name] = $this->prepare($connection); + } + + return $this->connections[$name]; + } + + /** + * Reconnect to the given database. + * + * @param string $name + * @return \Illuminate\Database\Connection + */ + public function reconnect($name = null) + { + $name = $name ?: $this->getDefaultConnection(); + + $this->disconnect($name); + + return $this->connection($name); + } + + /** + * Disconnect from the given database. + * + * @param string $name + * @return void + */ + public function disconnect($name = null) + { + $name = $name ?: $this->getDefaultConnection(); + + unset($this->connections[$name]); + } + + /** + * Make the database connection instance. + * + * @param string $name + * @return \Illuminate\Database\Connection + */ + protected function makeConnection($name) + { + $config = $this->getConfig($name); + + // First we will check by the connection name to see if an extension has been + // registered specifically for that connection. If it has we will call the + // Closure and pass it the config allowing it to resolve the connection. + if (isset($this->extensions[$name])) + { + return call_user_func($this->extensions[$name], $config, $name); + } + + $driver = $config['driver']; + + // Next we will check to see if an extension has been registered for a driver + // and will call the Closure if so, which allows us to have a more generic + // resolver for the drivers themselves which applies to all connections. + if (isset($this->extensions[$driver])) + { + return call_user_func($this->extensions[$driver], $config, $name); + } + + return $this->factory->make($config, $name); + } + + /** + * Prepare the database connection instance. + * + * @param \Illuminate\Database\Connection $connection + * @return \Illuminate\Database\Connection + */ + protected function prepare(Connection $connection) + { + $connection->setFetchMode($this->app['config']['database.fetch']); + + if ($this->app->bound('events')) + { + $connection->setEventDispatcher($this->app['events']); + } + + // The database connection can also utilize a cache manager instance when cache + // functionality is used on queries, which provides an expressive interface + // to caching both fluent queries and Eloquent queries that are executed. + $app = $this->app; + + $connection->setCacheManager(function() use ($app) + { + return $app['cache']; + }); + + // We will setup a Closure to resolve the paginator instance on the connection + // since the Paginator isn't used on every request and needs quite a few of + // our dependencies. It'll be more efficient to lazily resolve instances. + $connection->setPaginator(function() use ($app) + { + return $app['paginator']; + }); + + return $connection; + } + + /** + * Get the configuration for a connection. + * + * @param string $name + * @return array + * + * @throws \InvalidArgumentException + */ + protected function getConfig($name) + { + $name = $name ?: $this->getDefaultConnection(); + + // To get the database connection configuration, we will just pull each of the + // connection configurations and get the configurations for the given name. + // If the configuration doesn't exist, we'll throw an exception and bail. + $connections = $this->app['config']['database.connections']; + + if (is_null($config = array_get($connections, $name))) + { + throw new \InvalidArgumentException("Database [$name] not configured."); + } + + return $config; + } + + /** + * Get the default connection name. + * + * @return string + */ + public function getDefaultConnection() + { + return $this->app['config']['database.default']; + } + + /** + * Set the default connection name. + * + * @param string $name + * @return void + */ + public function setDefaultConnection($name) + { + $this->app['config']['database.default'] = $name; + } + + /** + * Register an extension connection resolver. + * + * @param string $name + * @param callable $resolver + * @return void + */ + public function extend($name, $resolver) + { + $this->extensions[$name] = $resolver; + } + + /** + * Return all of the created connections. + * + * @return array + */ + public function getConnections() + { + return $this->connections; + } + + /** + * Dynamically pass methods to the default connection. + * + * @param string $method + * @param array $parameters + * @return mixed + */ + public function __call($method, $parameters) + { + return call_user_func_array(array($this->connection(), $method), $parameters); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Database/DatabaseServiceProvider.php b/vendor/laravel/framework/src/Illuminate/Database/DatabaseServiceProvider.php new file mode 100755 index 0000000..4926422 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Database/DatabaseServiceProvider.php @@ -0,0 +1,45 @@ +app['db']); + + Model::setEventDispatcher($this->app['events']); + } + + /** + * Register the service provider. + * + * @return void + */ + public function register() + { + // The connection factory is used to create the actual connection instances on + // the database. We will inject the factory into the manager so that it may + // make the connections while they are actually needed and not of before. + $this->app->bindShared('db.factory', function($app) + { + return new ConnectionFactory($app); + }); + + // The database manager is used to resolve various connections, since multiple + // connections might be managed. It also implements the connection resolver + // interface which may be used by other components requiring connections. + $this->app->bindShared('db', function($app) + { + return new DatabaseManager($app, $app['db.factory']); + }); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php b/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php new file mode 100755 index 0000000..f930b8a --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php @@ -0,0 +1,935 @@ +query = $query; + } + + /** + * Find a model by its primary key. + * + * @param mixed $id + * @param array $columns + * @return \Illuminate\Database\Eloquent\Model|static|null + */ + public function find($id, $columns = array('*')) + { + if (is_array($id)) + { + return $this->findMany($id, $columns); + } + + $this->query->where($this->model->getKeyName(), '=', $id); + + return $this->first($columns); + } + + /** + * Find a model by its primary key. + * + * @param array $id + * @param array $columns + * @return \Illuminate\Database\Eloquent\Model|Collection|static + */ + public function findMany($id, $columns = array('*')) + { + if (empty($id)) return $this->model->newCollection(); + + $this->query->whereIn($this->model->getKeyName(), $id); + + return $this->get($columns); + } + + /** + * Find a model by its primary key or throw an exception. + * + * @param mixed $id + * @param array $columns + * @return \Illuminate\Database\Eloquent\Model|static + * + * @throws ModelNotFoundException + */ + public function findOrFail($id, $columns = array('*')) + { + if ( ! is_null($model = $this->find($id, $columns))) return $model; + + throw with(new ModelNotFoundException)->setModel(get_class($this->model)); + } + + /** + * Execute the query and get the first result. + * + * @param array $columns + * @return \Illuminate\Database\Eloquent\Model|static|null + */ + public function first($columns = array('*')) + { + return $this->take(1)->get($columns)->first(); + } + + /** + * Execute the query and get the first result or throw an exception. + * + * @param array $columns + * @return \Illuminate\Database\Eloquent\Model|static + * + * @throws ModelNotFoundException + */ + public function firstOrFail($columns = array('*')) + { + if ( ! is_null($model = $this->first($columns))) return $model; + + throw with(new ModelNotFoundException)->setModel(get_class($this->model)); + } + + /** + * Execute the query as a "select" statement. + * + * @param array $columns + * @return \Illuminate\Database\Eloquent\Collection|static[] + */ + public function get($columns = array('*')) + { + $models = $this->getModels($columns); + + // If we actually found models we will also eager load any relationships that + // have been specified as needing to be eager loaded, which will solve the + // n+1 query issue for the developers to avoid running a lot of queries. + if (count($models) > 0) + { + $models = $this->eagerLoadRelations($models); + } + + return $this->model->newCollection($models); + } + + /** + * Pluck a single column from the database. + * + * @param string $column + * @return mixed + */ + public function pluck($column) + { + $result = $this->first(array($column)); + + if ($result) return $result->{$column}; + } + + /** + * Chunk the results of the query. + * + * @param int $count + * @param callable $callback + * @return void + */ + public function chunk($count, $callback) + { + $results = $this->forPage($page = 1, $count)->get(); + + while (count($results) > 0) + { + // On each chunk result set, we will pass them to the callback and then let the + // developer take care of everything within the callback, which allows us to + // keep the memory low for spinning through large result sets for working. + call_user_func($callback, $results); + + $page++; + + $results = $this->forPage($page, $count)->get(); + } + } + + /** + * Get an array with the values of a given column. + * + * @param string $column + * @param string $key + * @return array + */ + public function lists($column, $key = null) + { + $results = $this->query->lists($column, $key); + + // If the model has a mutator for the requested column, we will spin through + // the results and mutate the values so that the mutated version of these + // columns are returned as you would expect from these Eloquent models. + if ($this->model->hasGetMutator($column)) + { + foreach ($results as $key => &$value) + { + $fill = array($column => $value); + + $value = $this->model->newFromBuilder($fill)->$column; + } + } + + return $results; + } + + /** + * Get a paginator for the "select" statement. + * + * @param int $perPage + * @param array $columns + * @return \Illuminate\Pagination\Paginator + */ + public function paginate($perPage = null, $columns = array('*')) + { + $perPage = $perPage ?: $this->model->getPerPage(); + + $paginator = $this->query->getConnection()->getPaginator(); + + if (isset($this->query->groups)) + { + return $this->groupedPaginate($paginator, $perPage, $columns); + } + else + { + return $this->ungroupedPaginate($paginator, $perPage, $columns); + } + } + + /** + * Get a paginator for a grouped statement. + * + * @param \Illuminate\Pagination\Environment $paginator + * @param int $perPage + * @param array $columns + * @return \Illuminate\Pagination\Paginator + */ + protected function groupedPaginate($paginator, $perPage, $columns) + { + $results = $this->get($columns)->all(); + + return $this->query->buildRawPaginator($paginator, $results, $perPage); + } + + /** + * Get a paginator for an ungrouped statement. + * + * @param \Illuminate\Pagination\Environment $paginator + * @param int $perPage + * @param array $columns + * @return \Illuminate\Pagination\Paginator + */ + protected function ungroupedPaginate($paginator, $perPage, $columns) + { + $total = $this->query->getPaginationCount(); + + // Once we have the paginator we need to set the limit and offset values for + // the query so we can get the properly paginated items. Once we have an + // array of items we can create the paginator instances for the items. + $page = $paginator->getCurrentPage($total); + + $this->query->forPage($page, $perPage); + + return $paginator->make($this->get($columns)->all(), $total, $perPage); + } + + /** + * Update a record in the database. + * + * @param array $values + * @return int + */ + public function update(array $values) + { + return $this->query->update($this->addUpdatedAtColumn($values)); + } + + /** + * Increment a column's value by a given amount. + * + * @param string $column + * @param int $amount + * @param array $extra + * @return int + */ + public function increment($column, $amount = 1, array $extra = array()) + { + $extra = $this->addUpdatedAtColumn($extra); + + return $this->query->increment($column, $amount, $extra); + } + + /** + * Decrement a column's value by a given amount. + * + * @param string $column + * @param int $amount + * @param array $extra + * @return int + */ + public function decrement($column, $amount = 1, array $extra = array()) + { + $extra = $this->addUpdatedAtColumn($extra); + + return $this->query->decrement($column, $amount, $extra); + } + + /** + * Add the "updated at" column to an array of values. + * + * @param array $values + * @return array + */ + protected function addUpdatedAtColumn(array $values) + { + if ( ! $this->model->usesTimestamps()) return $values; + + $column = $this->model->getUpdatedAtColumn(); + + return array_add($values, $column, $this->model->freshTimestampString()); + } + + /** + * Delete a record from the database. + * + * @return int + */ + public function delete() + { + if ($this->model->isSoftDeleting()) + { + return $this->softDelete(); + } + else + { + return $this->query->delete(); + } + } + + /** + * Soft delete the record in the database. + * + * @return int + */ + protected function softDelete() + { + $column = $this->model->getDeletedAtColumn(); + + return $this->update(array($column => $this->model->freshTimestampString())); + } + + /** + * Force a delete on a set of soft deleted models. + * + * @return int + */ + public function forceDelete() + { + return $this->query->delete(); + } + + /** + * Restore the soft-deleted model instances. + * + * @return int + */ + public function restore() + { + if ($this->model->isSoftDeleting()) + { + $column = $this->model->getDeletedAtColumn(); + + return $this->update(array($column => null)); + } + } + + /** + * Include the soft deleted models in the results. + * + * @return \Illuminate\Database\Eloquent\Builder|static + */ + public function withTrashed() + { + $column = $this->model->getQualifiedDeletedAtColumn(); + + foreach ((array) $this->query->wheres as $key => $where) + { + // If the where clause is a soft delete date constraint, we will remove it from + // the query and reset the keys on the wheres. This allows this developer to + // include deleted model in a relationship result set that is lazy loaded. + if ($this->isSoftDeleteConstraint($where, $column)) + { + unset($this->query->wheres[$key]); + + $this->query->wheres = array_values($this->query->wheres); + } + } + + return $this; + } + + /** + * Force the result set to only included soft deletes. + * + * @return \Illuminate\Database\Eloquent\Builder|static + */ + public function onlyTrashed() + { + $this->withTrashed(); + + $this->query->whereNotNull($this->model->getQualifiedDeletedAtColumn()); + + return $this; + } + + /** + * Determine if the given where clause is a soft delete constraint. + * + * @param array $where + * @param string $column + * @return bool + */ + protected function isSoftDeleteConstraint(array $where, $column) + { + return $where['type'] == 'Null' && $where['column'] == $column; + } + + /** + * Get the hydrated models without eager loading. + * + * @param array $columns + * @return array|static[] + */ + public function getModels($columns = array('*')) + { + // First, we will simply get the raw results from the query builders which we + // can use to populate an array with Eloquent models. We will pass columns + // that should be selected as well, which are typically just everything. + $results = $this->query->get($columns); + + $connection = $this->model->getConnectionName(); + + $models = array(); + + // Once we have the results, we can spin through them and instantiate a fresh + // model instance for each records we retrieved from the database. We will + // also set the proper connection name for the model after we create it. + foreach ($results as $result) + { + $models[] = $model = $this->model->newFromBuilder($result); + + $model->setConnection($connection); + } + + return $models; + } + + /** + * Eager load the relationships for the models. + * + * @param array $models + * @return array + */ + public function eagerLoadRelations(array $models) + { + foreach ($this->eagerLoad as $name => $constraints) + { + // For nested eager loads we'll skip loading them here and they will be set as an + // eager load on the query to retrieve the relation so that they will be eager + // loaded on that query, because that is where they get hydrated as models. + if (strpos($name, '.') === false) + { + $models = $this->loadRelation($models, $name, $constraints); + } + } + + return $models; + } + + /** + * Eagerly load the relationship on a set of models. + * + * @param array $models + * @param string $name + * @param \Closure $constraints + * @return array + */ + protected function loadRelation(array $models, $name, Closure $constraints) + { + // First we will "back up" the existing where conditions on the query so we can + // add our eager constraints. Then we will merge the wheres that were on the + // query back to it in order that any where conditions might be specified. + $relation = $this->getRelation($name); + + $relation->addEagerConstraints($models); + + call_user_func($constraints, $relation); + + $models = $relation->initRelation($models, $name); + + // Once we have the results, we just match those back up to their parent models + // using the relationship instance. Then we just return the finished arrays + // of models which have been eagerly hydrated and are readied for return. + $results = $relation->getEager(); + + return $relation->match($models, $results, $name); + } + + /** + * Get the relation instance for the given relation name. + * + * @param string $relation + * @return \Illuminate\Database\Eloquent\Relations\Relation + */ + public function getRelation($relation) + { + $me = $this; + + // We want to do a relationship query without any constraints so that we will + // not have to remove these where clauses manually which gets really hacky + // and is error prone while we remove the developer's own where clauses. + $query = Relation::noConstraints(function() use ($me, $relation) + { + return $me->getModel()->$relation(); + }); + + $nested = $this->nestedRelations($relation); + + // If there are nested relationships set on the query, we will put those onto + // the query instances so that they can be handled after this relationship + // is loaded. In this way they will all trickle down as they are loaded. + if (count($nested) > 0) + { + $query->getQuery()->with($nested); + } + + return $query; + } + + /** + * Get the deeply nested relations for a given top-level relation. + * + * @param string $relation + * @return array + */ + protected function nestedRelations($relation) + { + $nested = array(); + + // We are basically looking for any relationships that are nested deeper than + // the given top-level relationship. We will just check for any relations + // that start with the given top relations and adds them to our arrays. + foreach ($this->eagerLoad as $name => $constraints) + { + if ($this->isNested($name, $relation)) + { + $nested[substr($name, strlen($relation.'.'))] = $constraints; + } + } + + return $nested; + } + + /** + * Determine if the relationship is nested. + * + * @param string $name + * @param string $relation + * @return bool + */ + protected function isNested($name, $relation) + { + $dots = str_contains($name, '.'); + + return $dots && starts_with($name, $relation.'.'); + } + + /** + * Add a basic where clause to the query. + * + * @param string $column + * @param string $operator + * @param mixed $value + * @param string $boolean + * @return \Illuminate\Database\Eloquent\Builder|static + */ + public function where($column, $operator = null, $value = null, $boolean = 'and') + { + if ($column instanceof Closure) + { + $query = $this->model->newQuery(false); + + call_user_func($column, $query); + + $this->query->addNestedWhereQuery($query->getQuery(), $boolean); + } + else + { + call_user_func_array(array($this->query, 'where'), func_get_args()); + } + + return $this; + } + + /** + * Add an "or where" clause to the query. + * + * @param string $column + * @param string $operator + * @param mixed $value + * @return \Illuminate\Database\Eloquent\Builder|static + */ + public function orWhere($column, $operator = null, $value = null) + { + return $this->where($column, $operator, $value, 'or'); + } + + /** + * Add a relationship count condition to the query. + * + * @param string $relation + * @param string $operator + * @param int $count + * @param string $boolean + * @param \Closure $callback + * @return \Illuminate\Database\Eloquent\Builder|static + */ + public function has($relation, $operator = '>=', $count = 1, $boolean = 'and', $callback = null) + { + $relation = $this->getHasRelationQuery($relation); + + $query = $relation->getRelationCountQuery($relation->getRelated()->newQuery(), $this); + + if ($callback) call_user_func($callback, $query); + + return $this->addHasWhere($query, $relation, $operator, $count, $boolean); + } + + /** + * Add a relationship count condition to the query with where clauses. + * + * @param string $relation + * @param \Closure $callback + * @param string $operator + * @param int $count + * @return \Illuminate\Database\Eloquent\Builder|static + */ + public function whereHas($relation, Closure $callback, $operator = '>=', $count = 1) + { + return $this->has($relation, $operator, $count, 'and', $callback); + } + + /** + * Add a relationship count condition to the query with an "or". + * + * @param string $relation + * @param string $operator + * @param int $count + * @return \Illuminate\Database\Eloquent\Builder|static + */ + public function orHas($relation, $operator = '>=', $count = 1) + { + return $this->has($relation, $operator, $count, 'or'); + } + + /** + * Add a relationship count condition to the query with where clauses and an "or". + * + * @param string $relation + * @param \Closure $callback + * @param string $operator + * @param int $count + * @return \Illuminate\Database\Eloquent\Builder|static + */ + public function orWhereHas($relation, Closure $callback, $operator = '>=', $count = 1) + { + return $this->has($relation, $operator, $count, 'or', $callback); + } + + /** + * Add the "has" condition where clause to the query. + * + * @param \Illuminate\Database\Eloquent\Builder $hasQuery + * @param \Illuminate\Database\Eloquent\Relations\Relation $relation + * @param string $operator + * @param int $count + * @param string $boolean + * @return \Illuminate\Database\Eloquent\Builder + */ + protected function addHasWhere(Builder $hasQuery, Relation $relation, $operator, $count, $boolean) + { + $this->mergeWheresToHas($hasQuery, $relation); + + if (is_numeric($count)) + { + $count = new Expression($count); + } + + return $this->where(new Expression('('.$hasQuery->toSql().')'), $operator, $count, $boolean); + } + + /** + * Merge the "wheres" from a relation query to a has query. + * + * @param \Illuminate\Database\Eloquent\Builder $hasQuery + * @param \Illuminate\Database\Eloquent\Relations\Relation $relation + * @return void + */ + protected function mergeWheresToHas(Builder $hasQuery, Relation $relation) + { + // Here we have the "has" query and the original relation. We need to copy over any + // where clauses the developer may have put in the relationship function over to + // the has query, and then copy the bindings from the "has" query to the main. + $relationQuery = $relation->getBaseQuery(); + + $hasQuery->mergeWheres( + $relationQuery->wheres, $relationQuery->getBindings() + ); + + $this->query->mergeBindings($hasQuery->getQuery()); + } + + /** + * Get the "has relation" base query instance. + * + * @param string $relation + * @return \Illuminate\Database\Eloquent\Builder + */ + protected function getHasRelationQuery($relation) + { + $me = $this; + + return Relation::noConstraints(function() use ($me, $relation) + { + return $me->getModel()->$relation(); + }); + } + + /** + * Set the relationships that should be eager loaded. + * + * @param dynamic $relations + * @return \Illuminate\Database\Eloquent\Builder|static + */ + public function with($relations) + { + if (is_string($relations)) $relations = func_get_args(); + + $eagers = $this->parseRelations($relations); + + $this->eagerLoad = array_merge($this->eagerLoad, $eagers); + + return $this; + } + + /** + * Parse a list of relations into individuals. + * + * @param array $relations + * @return array + */ + protected function parseRelations(array $relations) + { + $results = array(); + + foreach ($relations as $name => $constraints) + { + // If the "relation" value is actually a numeric key, we can assume that no + // constraints have been specified for the eager load and we'll just put + // an empty Closure with the loader so that we can treat all the same. + if (is_numeric($name)) + { + $f = function() {}; + + list($name, $constraints) = array($constraints, $f); + } + + // We need to separate out any nested includes. Which allows the developers + // to load deep relationships using "dots" without stating each level of + // the relationship with its own key in the array of eager load names. + $results = $this->parseNested($name, $results); + + $results[$name] = $constraints; + } + + return $results; + } + + /** + * Parse the nested relationships in a relation. + * + * @param string $name + * @param array $results + * @return array + */ + protected function parseNested($name, $results) + { + $progress = array(); + + // If the relation has already been set on the result array, we will not set it + // again, since that would override any constraints that were already placed + // on the relationships. We will only set the ones that are not specified. + foreach (explode('.', $name) as $segment) + { + $progress[] = $segment; + + if ( ! isset($results[$last = implode('.', $progress)])) + { + $results[$last] = function() {}; + } + } + + return $results; + } + + /** + * Call the given model scope on the underlying model. + * + * @param string $scope + * @param array $parameters + * @return \Illuminate\Database\Query\Builder + */ + protected function callScope($scope, $parameters) + { + array_unshift($parameters, $this); + + return call_user_func_array(array($this->model, $scope), $parameters) ?: $this; + } + + /** + * Get the underlying query builder instance. + * + * @return \Illuminate\Database\Query\Builder|static + */ + public function getQuery() + { + return $this->query; + } + + /** + * Set the underlying query builder instance. + * + * @param \Illuminate\Database\Query\Builder $query + * @return void + */ + public function setQuery($query) + { + $this->query = $query; + } + + /** + * Get the relationships being eagerly loaded. + * + * @return array + */ + public function getEagerLoads() + { + return $this->eagerLoad; + } + + /** + * Set the relationships being eagerly loaded. + * + * @param array $eagerLoad + * @return void + */ + public function setEagerLoads(array $eagerLoad) + { + $this->eagerLoad = $eagerLoad; + } + + /** + * Get the model instance being queried. + * + * @return \Illuminate\Database\Eloquent\Model + */ + public function getModel() + { + return $this->model; + } + + /** + * Set a model instance for the model being queried. + * + * @param \Illuminate\Database\Eloquent\Model $model + * @return \Illuminate\Database\Eloquent\Builder + */ + public function setModel(Model $model) + { + $this->model = $model; + + $this->query->from($model->getTable()); + + return $this; + } + + /** + * Dynamically handle calls into the query instance. + * + * @param string $method + * @param array $parameters + * @return mixed + */ + public function __call($method, $parameters) + { + if (method_exists($this->model, $scope = 'scope'.ucfirst($method))) + { + return $this->callScope($scope, $parameters); + } + else + { + $result = call_user_func_array(array($this->query, $method), $parameters); + } + + return in_array($method, $this->passthru) ? $result : $this; + } + + /** + * Force a clone of the underlying query builder when cloning. + * + * @return void + */ + public function __clone() + { + $this->query = clone $this->query; + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Collection.php b/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Collection.php new file mode 100755 index 0000000..48e751c --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Collection.php @@ -0,0 +1,253 @@ +getKey(); + } + + return array_first($this->items, function($itemKey, $model) use ($key) + { + return $model->getKey() == $key; + + }, $default); + } + + /** + * Load a set of relationships onto the collection. + * + * @param dynamic $relations + * @return \Illuminate\Database\Eloquent\Collection + */ + public function load($relations) + { + if (count($this->items) > 0) + { + if (is_string($relations)) $relations = func_get_args(); + + $query = $this->first()->newQuery()->with($relations); + + $this->items = $query->eagerLoadRelations($this->items); + } + + return $this; + } + + /** + * Add an item to the collection. + * + * @param mixed $item + * @return \Illuminate\Database\Eloquent\Collection + */ + public function add($item) + { + $this->items[] = $item; + + return $this; + } + + /** + * Determine if a key exists in the collection. + * + * @param mixed $key + * @return bool + */ + public function contains($key) + { + return ! is_null($this->find($key)); + } + + /** + * Fetch a nested element of the collection. + * + * @param string $key + * @return \Illuminate\Support\Collection + */ + public function fetch($key) + { + return new static(array_fetch($this->toArray(), $key)); + } + + /** + * Get the max value of a given key. + * + * @param string $key + * @return mixed + */ + public function max($key) + { + return $this->reduce(function($result, $item) use ($key) + { + return (is_null($result) || $item->{$key} > $result) ? $item->{$key} : $result; + }); + } + + /** + * Get the min value of a given key. + * + * @param string $key + * @return mixed + */ + public function min($key) + { + return $this->reduce(function($result, $item) use ($key) + { + return (is_null($result) || $item->{$key} < $result) ? $item->{$key} : $result; + }); + } + + /** + * Get the array of primary keys + * + * @return array + */ + public function modelKeys() + { + return array_map(function($m) { return $m->getKey(); }, $this->items); + } + + /** + * Merge the collection with the given items. + * + * @param \Illuminate\Support\Collection|\Illuminate\Support\Contracts\ArrayableInterface|array $items + * @return \Illuminate\Support\Collection + */ + public function merge($collection) + { + $dictionary = $this->getDictionary(); + + foreach ($collection as $item) + { + $dictionary[$item->getKey()] = $item; + } + + return new static(array_values($dictionary)); + } + + /** + * Diff the collection with the given items. + * + * @param \Illuminate\Support\Collection|\Illuminate\Support\Contracts\ArrayableInterface|array $items + * @return \Illuminate\Support\Collection + */ + public function diff($collection) + { + $diff = new static; + + $dictionary = $this->getDictionary($collection); + + foreach ($this->items as $item) + { + if ( ! isset($dictionary[$item->getKey()])) + { + $diff->add($item); + } + } + + return $diff; + } + + /** + * Intersect the collection with the given items. + * + * @param \Illuminate\Support\Collection|\Illuminate\Support\Contracts\ArrayableInterface|array $items + * @return \Illuminate\Support\Collection + */ + public function intersect($collection) + { + $intersect = new static; + + $dictionary = $this->getDictionary($collection); + + foreach ($this->items as $item) + { + if (isset($dictionary[$item->getKey()])) + { + $intersect->add($item); + } + } + + return $intersect; + } + + /** + * Return only unique items from the collection. + * + * @return \Illuminate\Support\Collection + */ + public function unique() + { + $dictionary = $this->getDictionary(); + + return new static(array_values($dictionary)); + } + + /** + * Returns only the models from the collection with the specified keys. + * + * @param mixed $keys + * @return \Illuminate\Support\Collection + */ + public function only($keys) + { + $dictionary = array_only($this->getDictionary($this), $keys); + + return new static(array_values($dictionary)); + } + + /** + * Returns all models in the collection except the models with specified keys. + * + * @param mixed $keys + * @return \Illuminate\Support\Collection + */ + public function except($keys) + { + $dictionary = array_except($this->getDictionary($this), $keys); + + return new static(array_values($dictionary)); + } + + /** + * Get a dictionary keyed by primary keys. + * + * @param \Illuminate\Support\Collection $collection + * @return array + */ + public function getDictionary($collection = null) + { + $collection = $collection ?: $this; + + $dictionary = array(); + + foreach ($collection as $value) + { + $dictionary[$value->getKey()] = $value; + } + + return $dictionary; + } + + /** + * Get a base Support collection instance from this collection. + * + * @return \Illuminate\Support\Collection + */ + public function toBase() + { + return new BaseCollection($this->items); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Database/Eloquent/MassAssignmentException.php b/vendor/laravel/framework/src/Illuminate/Database/Eloquent/MassAssignmentException.php new file mode 100755 index 0000000..c7fe78e --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Database/Eloquent/MassAssignmentException.php @@ -0,0 +1,3 @@ +bootIfNotBooted(); + + $this->syncOriginal(); + + $this->fill($attributes); + } + + /** + * Check if the model needs to be booted and if so, do it. + * + * @return void + */ + protected function bootIfNotBooted() + { + if ( ! isset(static::$booted[get_class($this)])) + { + static::$booted[get_class($this)] = true; + + $this->fireModelEvent('booting', false); + + static::boot(); + + $this->fireModelEvent('booted', false); + } + } + + /** + * The "booting" method of the model. + * + * @return void + */ + protected static function boot() + { + $class = get_called_class(); + + static::$mutatorCache[$class] = array(); + + // Here we will extract all of the mutated attributes so that we can quickly + // spin through them after we export models to their array form, which we + // need to be fast. This will let us always know the attributes mutate. + foreach (get_class_methods($class) as $method) + { + if (preg_match('/^get(.+)Attribute$/', $method, $matches)) + { + if (static::$snakeAttributes) $matches[1] = snake_case($matches[1]); + + static::$mutatorCache[$class][] = lcfirst($matches[1]); + } + } + } + + /** + * Register an observer with the Model. + * + * @param object $class + * @return void + */ + public static function observe($class) + { + $instance = new static; + + $className = get_class($class); + + // When registering a model observer, we will spin through the possible events + // and determine if this observer has that method. If it does, we will hook + // it into the model's event system, making it convenient to watch these. + foreach ($instance->getObservableEvents() as $event) + { + if (method_exists($class, $event)) + { + static::registerModelEvent($event, $className.'@'.$event); + } + } + } + + /** + * Fill the model with an array of attributes. + * + * @param array $attributes + * @return \Illuminate\Database\Eloquent\Model|static + * + * @throws MassAssignmentException + */ + public function fill(array $attributes) + { + $totallyGuarded = $this->totallyGuarded(); + + foreach ($this->fillableFromArray($attributes) as $key => $value) + { + $key = $this->removeTableFromKey($key); + + // The developers may choose to place some attributes in the "fillable" + // array, which means only those attributes may be set through mass + // assignment to the model, and all others will just be ignored. + if ($this->isFillable($key)) + { + $this->setAttribute($key, $value); + } + elseif ($totallyGuarded) + { + throw new MassAssignmentException($key); + } + } + + return $this; + } + + /** + * Get the fillable attributes of a given array. + * + * @param array $attributes + * @return array + */ + protected function fillableFromArray(array $attributes) + { + if (count($this->fillable) > 0 && ! static::$unguarded) + { + return array_intersect_key($attributes, array_flip($this->fillable)); + } + + return $attributes; + } + + /** + * Create a new instance of the given model. + * + * @param array $attributes + * @param bool $exists + * @return \Illuminate\Database\Eloquent\Model|static + */ + public function newInstance($attributes = array(), $exists = false) + { + // This method just provides a convenient way for us to generate fresh model + // instances of this current model. It is particularly useful during the + // hydration of new objects via the Eloquent query builder instances. + $model = new static((array) $attributes); + + $model->exists = $exists; + + return $model; + } + + /** + * Create a new model instance that is existing. + * + * @param array $attributes + * @return \Illuminate\Database\Eloquent\Model|static + */ + public function newFromBuilder($attributes = array()) + { + $instance = $this->newInstance(array(), true); + + $instance->setRawAttributes((array) $attributes, true); + + return $instance; + } + + /** + * Create a collection of models from plain arrays. + * + * @param array $items + * @param string $connection + * @return \Illuminate\Database\Eloquent\Collection + */ + public static function hydrate(array $items, $connection = null) + { + $collection = with($instance = new static)->newCollection(); + + foreach ($items as $item) + { + $model = $instance->newFromBuilder($item); + + if ( ! is_null($connection)) + { + $model->setConnection($connection); + } + + $collection->push($model); + } + + return $collection; + } + + /** + * Create a collection of models from a raw query. + * + * @param string $query + * @param array $bindings + * @param string $connection + * @return \Illuminate\Database\Eloquent\Collection + */ + public static function hydrateRaw($query, $bindings = array(), $connection = null) + { + $instance = new static; + + if ( ! is_null($connection)) + { + $instance->setConnection($connection); + } + + $items = $instance->getConnection()->select($query, $bindings); + + return static::hydrate($items, $connection); + } + + /** + * Save a new model and return the instance. + * + * @param array $attributes + * @return \Illuminate\Database\Eloquent\Model|static + */ + public static function create(array $attributes) + { + $model = new static($attributes); + + $model->save(); + + return $model; + } + + /** + * Get the first record matching the attributes or create it. + * + * @param array $attributes + * @return \Illuminate\Database\Eloquent\Model + */ + public static function firstOrCreate(array $attributes) + { + if ( ! is_null($instance = static::firstByAttributes($attributes))) + { + return $instance; + } + + return static::create($attributes); + } + + /** + * Get the first record matching the attributes or instantiate it. + * + * @param array $attributes + * @return \Illuminate\Database\Eloquent\Model + */ + public static function firstOrNew(array $attributes) + { + if ( ! is_null($instance = static::firstByAttributes($attributes))) + { + return $instance; + } + + return new static($attributes); + } + + /** + * Get the first model for the given attributes. + * + * @param array $attributes + * @return \Illuminate\Database\Eloquent\Model|null + */ + protected static function firstByAttributes($attributes) + { + $query = static::query(); + + foreach ($attributes as $key => $value) + { + $query->where($key, $value); + } + + return $query->first() ?: null; + } + + /** + * Begin querying the model. + * + * @return \Illuminate\Database\Eloquent\Builder|static + */ + public static function query() + { + return with(new static)->newQuery(); + } + + /** + * Begin querying the model on a given connection. + * + * @param string $connection + * @return \Illuminate\Database\Eloquent\Builder|static + */ + public static function on($connection = null) + { + // First we will just create a fresh instance of this model, and then we can + // set the connection on the model so that it is be used for the queries + // we execute, as well as being set on each relationship we retrieve. + $instance = new static; + + $instance->setConnection($connection); + + return $instance->newQuery(); + } + + /** + * Get all of the models from the database. + * + * @param array $columns + * @return \Illuminate\Database\Eloquent\Collection|static[] + */ + public static function all($columns = array('*')) + { + $instance = new static; + + return $instance->newQuery()->get($columns); + } + + /** + * Find a model by its primary key. + * + * @param mixed $id + * @param array $columns + * @return \Illuminate\Database\Eloquent\Model|Collection|static + */ + public static function find($id, $columns = array('*')) + { + if (is_array($id) && empty($id)) return new Collection; + + $instance = new static; + + return $instance->newQuery()->find($id, $columns); + } + + /** + * Find a model by its primary key or return new static. + * + * @param mixed $id + * @param array $columns + * @return \Illuminate\Database\Eloquent\Model|Collection|static + */ + public static function findOrNew($id, $columns = array('*')) + { + if ( ! is_null($model = static::find($id, $columns))) return $model; + + return new static($columns); + } + + /** + * Find a model by its primary key or throw an exception. + * + * @param mixed $id + * @param array $columns + * @return \Illuminate\Database\Eloquent\Model|Collection|static + * + * @throws ModelNotFoundException + */ + public static function findOrFail($id, $columns = array('*')) + { + if ( ! is_null($model = static::find($id, $columns))) return $model; + + throw with(new ModelNotFoundException)->setModel(get_called_class()); + } + + /** + * Eager load relations on the model. + * + * @param array|string $relations + * @return \Illuminate\Database\Eloquent\Model + */ + public function load($relations) + { + if (is_string($relations)) $relations = func_get_args(); + + $query = $this->newQuery()->with($relations); + + $query->eagerLoadRelations(array($this)); + + return $this; + } + + /** + * Being querying a model with eager loading. + * + * @param array|string $relations + * @return \Illuminate\Database\Eloquent\Builder|static + */ + public static function with($relations) + { + if (is_string($relations)) $relations = func_get_args(); + + $instance = new static; + + return $instance->newQuery()->with($relations); + } + + /** + * Define a one-to-one relationship. + * + * @param string $related + * @param string $foreignKey + * @param string $localKey + * @return \Illuminate\Database\Eloquent\Relations\HasOne + */ + public function hasOne($related, $foreignKey = null, $localKey = null) + { + $foreignKey = $foreignKey ?: $this->getForeignKey(); + + $instance = new $related; + + $localKey = $localKey ?: $this->getKeyName(); + + return new HasOne($instance->newQuery(), $this, $instance->getTable().'.'.$foreignKey, $localKey); + } + + /** + * Define a polymorphic one-to-one relationship. + * + * @param string $related + * @param string $name + * @param string $type + * @param string $id + * @param string $localKey + * @return \Illuminate\Database\Eloquent\Relations\MorphOne + */ + public function morphOne($related, $name, $type = null, $id = null, $localKey = null) + { + $instance = new $related; + + list($type, $id) = $this->getMorphs($name, $type, $id); + + $table = $instance->getTable(); + + $localKey = $localKey ?: $this->getKeyName(); + + return new MorphOne($instance->newQuery(), $this, $table.'.'.$type, $table.'.'.$id, $localKey); + } + + /** + * Define an inverse one-to-one or many relationship. + * + * @param string $related + * @param string $foreignKey + * @param string $otherKey + * @param string $relation + * @return \Illuminate\Database\Eloquent\Relations\BelongsTo + */ + public function belongsTo($related, $foreignKey = null, $otherKey = null, $relation = null) + { + // If no relation name was given, we will use this debug backtrace to extract + // the calling method's name and use that as the relationship name as most + // of the time this will be what we desire to use for the relationships. + if (is_null($relation)) + { + list(, $caller) = debug_backtrace(false); + + $relation = $caller['function']; + } + + // If no foreign key was supplied, we can use a backtrace to guess the proper + // foreign key name by using the name of the relationship function, which + // when combined with an "_id" should conventionally match the columns. + if (is_null($foreignKey)) + { + $foreignKey = snake_case($relation).'_id'; + } + + $instance = new $related; + + // Once we have the foreign key names, we'll just create a new Eloquent query + // for the related models and returns the relationship instance which will + // actually be responsible for retrieving and hydrating every relations. + $query = $instance->newQuery(); + + $otherKey = $otherKey ?: $instance->getKeyName(); + + return new BelongsTo($query, $this, $foreignKey, $otherKey, $relation); + } + + /** + * Define a polymorphic, inverse one-to-one or many relationship. + * + * @param string $name + * @param string $type + * @param string $id + * @return \Illuminate\Database\Eloquent\Relations\MorphTo + */ + public function morphTo($name = null, $type = null, $id = null) + { + // If no name is provided, we will use the backtrace to get the function name + // since that is most likely the name of the polymorphic interface. We can + // use that to get both the class and foreign key that will be utilized. + if (is_null($name)) + { + list(, $caller) = debug_backtrace(false); + + $name = snake_case($caller['function']); + } + + list($type, $id) = $this->getMorphs($name, $type, $id); + + // If the type value is null it is probably safe to assume we're eager loading + // the relationship. When that is the case we will pass in a dummy query as + // there are multiple types in the morph and we can't use single queries. + if (is_null($class = $this->$type)) + { + return new MorphTo( + $this->newQuery(), $this, $id, null, $type, $name + ); + } + + // If we are not eager loading the relationship we will essentially treat this + // as a belongs-to style relationship since morph-to extends that class and + // we will pass in the appropriate values so that it behaves as expected. + else + { + $instance = new $class; + + return new MorphTo( + with($instance)->newQuery(), $this, $id, $instance->getKeyName(), $type, $name + ); + } + } + + /** + * Define a one-to-many relationship. + * + * @param string $related + * @param string $foreignKey + * @param string $localKey + * @return \Illuminate\Database\Eloquent\Relations\HasMany + */ + public function hasMany($related, $foreignKey = null, $localKey = null) + { + $foreignKey = $foreignKey ?: $this->getForeignKey(); + + $instance = new $related; + + $localKey = $localKey ?: $this->getKeyName(); + + return new HasMany($instance->newQuery(), $this, $instance->getTable().'.'.$foreignKey, $localKey); + } + + /** + * Define a has-many-through relationship. + * + * @param string $related + * @param string $through + * @param string|null $firstKey + * @param string|null $secondKey + * @return \Illuminate\Database\Eloquent\Relations\HasManyThrough + */ + public function hasManyThrough($related, $through, $firstKey = null, $secondKey = null) + { + $through = new $through; + + $firstKey = $firstKey ?: $this->getForeignKey(); + + $secondKey = $secondKey ?: $through->getForeignKey(); + + return new HasManyThrough(with(new $related)->newQuery(), $this, $through, $firstKey, $secondKey); + } + + /** + * Define a polymorphic one-to-many relationship. + * + * @param string $related + * @param string $name + * @param string $type + * @param string $id + * @param string $localKey + * @return \Illuminate\Database\Eloquent\Relations\MorphMany + */ + public function morphMany($related, $name, $type = null, $id = null, $localKey = null) + { + $instance = new $related; + + // Here we will gather up the morph type and ID for the relationship so that we + // can properly query the intermediate table of a relation. Finally, we will + // get the table and create the relationship instances for the developers. + list($type, $id) = $this->getMorphs($name, $type, $id); + + $table = $instance->getTable(); + + $localKey = $localKey ?: $this->getKeyName(); + + return new MorphMany($instance->newQuery(), $this, $table.'.'.$type, $table.'.'.$id, $localKey); + } + + /** + * Define a many-to-many relationship. + * + * @param string $related + * @param string $table + * @param string $foreignKey + * @param string $otherKey + * @param string $relation + * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany + */ + public function belongsToMany($related, $table = null, $foreignKey = null, $otherKey = null, $relation = null) + { + // If no relationship name was passed, we will pull backtraces to get the + // name of the calling function. We will use that function name as the + // title of this relation since that is a great convention to apply. + if (is_null($relation)) + { + $relation = $this->getBelongsToManyCaller(); + } + + // First, we'll need to determine the foreign key and "other key" for the + // relationship. Once we have determined the keys we'll make the query + // instances as well as the relationship instances we need for this. + $foreignKey = $foreignKey ?: $this->getForeignKey(); + + $instance = new $related; + + $otherKey = $otherKey ?: $instance->getForeignKey(); + + // If no table name was provided, we can guess it by concatenating the two + // models using underscores in alphabetical order. The two model names + // are transformed to snake case from their default CamelCase also. + if (is_null($table)) + { + $table = $this->joiningTable($related); + } + + // Now we're ready to create a new query builder for the related model and + // the relationship instances for the relation. The relations will set + // appropriate query constraint and entirely manages the hydrations. + $query = $instance->newQuery(); + + return new BelongsToMany($query, $this, $table, $foreignKey, $otherKey, $relation); + } + + /** + * Define a polymorphic many-to-many relationship. + * + * @param string $related + * @param string $name + * @param string $table + * @param string $foreignKey + * @param string $otherKey + * @param bool $inverse + * @return \Illuminate\Database\Eloquent\Relations\MorphToMany + */ + public function morphToMany($related, $name, $table = null, $foreignKey = null, $otherKey = null, $inverse = false) + { + $caller = $this->getBelongsToManyCaller(); + + // First, we will need to determine the foreign key and "other key" for the + // relationship. Once we have determined the keys we will make the query + // instances, as well as the relationship instances we need for these. + $foreignKey = $foreignKey ?: $name.'_id'; + + $instance = new $related; + + $otherKey = $otherKey ?: $instance->getForeignKey(); + + // Now we're ready to create a new query builder for this related model and + // the relationship instances for this relation. This relations will set + // appropriate query constraints then entirely manages the hydrations. + $query = $instance->newQuery(); + + $table = $table ?: str_plural($name); + + return new MorphToMany( + $query, $this, $name, $table, $foreignKey, + $otherKey, $caller, $inverse + ); + } + + /** + * Define a polymorphic, inverse many-to-many relationship. + * + * @param string $related + * @param string $name + * @param string $table + * @param string $foreignKey + * @param string $otherKey + * @return \Illuminate\Database\Eloquent\Relations\MorphToMany + */ + public function morphedByMany($related, $name, $table = null, $foreignKey = null, $otherKey = null) + { + $foreignKey = $foreignKey ?: $this->getForeignKey(); + + // For the inverse of the polymorphic many-to-many relations, we will change + // the way we determine the foreign and other keys, as it is the opposite + // of the morph-to-many method since we're figuring out these inverses. + $otherKey = $otherKey ?: $name.'_id'; + + return $this->morphToMany($related, $name, $table, $foreignKey, $otherKey, true); + } + + /** + * Get the relationship name of the belongs to many. + * + * @return string + */ + protected function getBelongsToManyCaller() + { + $self = __FUNCTION__; + + $caller = array_first(debug_backtrace(false), function($key, $trace) use ($self) + { + $caller = $trace['function']; + + return ( ! in_array($caller, Model::$manyMethods) && $caller != $self); + }); + + return ! is_null($caller) ? $caller['function'] : null; + } + + /** + * Get the joining table name for a many-to-many relation. + * + * @param string $related + * @return string + */ + public function joiningTable($related) + { + // The joining table name, by convention, is simply the snake cased models + // sorted alphabetically and concatenated with an underscore, so we can + // just sort the models and join them together to get the table name. + $base = snake_case(class_basename($this)); + + $related = snake_case(class_basename($related)); + + $models = array($related, $base); + + // Now that we have the model names in an array we can just sort them and + // use the implode function to join them together with an underscores, + // which is typically used by convention within the database system. + sort($models); + + return strtolower(implode('_', $models)); + } + + /** + * Destroy the models for the given IDs. + * + * @param array|int $ids + * @return int + */ + public static function destroy($ids) + { + // We'll initialize a count here so we will return the total number of deletes + // for the operation. The developers can then check this number as a boolean + // type value or get this total count of records deleted for logging, etc. + $count = 0; + + $ids = is_array($ids) ? $ids : func_get_args(); + + $instance = new static; + + // We will actually pull the models from the database table and call delete on + // each of them individually so that their events get fired properly with a + // correct set of attributes in case the developers wants to check these. + $key = $instance->getKeyName(); + + foreach ($instance->whereIn($key, $ids)->get() as $model) + { + if ($model->delete()) $count++; + } + + return $count; + } + + /** + * Delete the model from the database. + * + * @return bool|null + */ + public function delete() + { + if (is_null($this->primaryKey)) + { + throw new \Exception("No primary key defined on model."); + } + + if ($this->exists) + { + if ($this->fireModelEvent('deleting') === false) return false; + + // Here, we'll touch the owning models, verifying these timestamps get updated + // for the models. This will allow any caching to get broken on the parents + // by the timestamp. Then we will go ahead and delete the model instance. + $this->touchOwners(); + + $this->performDeleteOnModel(); + + $this->exists = false; + + // Once the model has been deleted, we will fire off the deleted event so that + // the developers may hook into post-delete operations. We will then return + // a boolean true as the delete is presumably successful on the database. + $this->fireModelEvent('deleted', false); + + return true; + } + } + + /** + * Force a hard delete on a soft deleted model. + * + * @return void + */ + public function forceDelete() + { + $softDelete = $this->softDelete; + + // We will temporarily disable false delete to allow us to perform the real + // delete operation against the model. We will then restore the deleting + // state to what this was prior to this given hard deleting operation. + $this->softDelete = false; + + $this->delete(); + + $this->softDelete = $softDelete; + } + + /** + * Perform the actual delete query on this model instance. + * + * @return void + */ + protected function performDeleteOnModel() + { + $query = $this->newQuery()->where($this->getKeyName(), $this->getKey()); + + if ($this->softDelete) + { + $this->{static::DELETED_AT} = $time = $this->freshTimestamp(); + + $query->update(array(static::DELETED_AT => $this->fromDateTime($time))); + } + else + { + $query->delete(); + } + } + + /** + * Restore a soft-deleted model instance. + * + * @return bool|null + */ + public function restore() + { + if ($this->softDelete) + { + // If the restoring event does not return false, we will proceed with this + // restore operation. Otherwise, we bail out so the developer will stop + // the restore totally. We will clear the deleted timestamp and save. + if ($this->fireModelEvent('restoring') === false) + { + return false; + } + + $this->{static::DELETED_AT} = null; + + // Once we have saved the model, we will fire the "restored" event so this + // developer will do anything they need to after a restore operation is + // totally finished. Then we will return the result of the save call. + $result = $this->save(); + + $this->fireModelEvent('restored', false); + + return $result; + } + } + + /** + * Register a saving model event with the dispatcher. + * + * @param \Closure|string $callback + * @return void + */ + public static function saving($callback) + { + static::registerModelEvent('saving', $callback); + } + + /** + * Register a saved model event with the dispatcher. + * + * @param \Closure|string $callback + * @return void + */ + public static function saved($callback) + { + static::registerModelEvent('saved', $callback); + } + + /** + * Register an updating model event with the dispatcher. + * + * @param \Closure|string $callback + * @return void + */ + public static function updating($callback) + { + static::registerModelEvent('updating', $callback); + } + + /** + * Register an updated model event with the dispatcher. + * + * @param \Closure|string $callback + * @return void + */ + public static function updated($callback) + { + static::registerModelEvent('updated', $callback); + } + + /** + * Register a creating model event with the dispatcher. + * + * @param \Closure|string $callback + * @return void + */ + public static function creating($callback) + { + static::registerModelEvent('creating', $callback); + } + + /** + * Register a created model event with the dispatcher. + * + * @param \Closure|string $callback + * @return void + */ + public static function created($callback) + { + static::registerModelEvent('created', $callback); + } + + /** + * Register a deleting model event with the dispatcher. + * + * @param \Closure|string $callback + * @return void + */ + public static function deleting($callback) + { + static::registerModelEvent('deleting', $callback); + } + + /** + * Register a deleted model event with the dispatcher. + * + * @param \Closure|string $callback + * @return void + */ + public static function deleted($callback) + { + static::registerModelEvent('deleted', $callback); + } + + /** + * Register a restoring model event with the dispatcher. + * + * @param \Closure|string $callback + * @return void + */ + public static function restoring($callback) + { + static::registerModelEvent('restoring', $callback); + } + + /** + * Register a restored model event with the dispatcher. + * + * @param \Closure|string $callback + * @return void + */ + public static function restored($callback) + { + static::registerModelEvent('restored', $callback); + } + + /** + * Remove all of the event listeners for the model. + * + * @return void + */ + public static function flushEventListeners() + { + if ( ! isset(static::$dispatcher)) return; + + $instance = new static; + + foreach ($instance->getObservableEvents() as $event) + { + static::$dispatcher->forget("eloquent.{$event}: ".get_called_class()); + } + } + + /** + * Register a model event with the dispatcher. + * + * @param string $event + * @param \Closure|string $callback + * @return void + */ + protected static function registerModelEvent($event, $callback) + { + if (isset(static::$dispatcher)) + { + $name = get_called_class(); + + static::$dispatcher->listen("eloquent.{$event}: {$name}", $callback); + } + } + + /** + * Get the observable event names. + * + * @return array + */ + public function getObservableEvents() + { + return array_merge( + array( + 'creating', 'created', 'updating', 'updated', + 'deleting', 'deleted', 'saving', 'saved', + 'restoring', 'restored', + ), + $this->observables + ); + } + + /** + * Increment a column's value by a given amount. + * + * @param string $column + * @param int $amount + * @return int + */ + protected function increment($column, $amount = 1) + { + return $this->incrementOrDecrement($column, $amount, 'increment'); + } + + /** + * Decrement a column's value by a given amount. + * + * @param string $column + * @param int $amount + * @return int + */ + protected function decrement($column, $amount = 1) + { + return $this->incrementOrDecrement($column, $amount, 'decrement'); + } + + /** + * Run the increment or decrement method on the model. + * + * @param string $column + * @param int $amount + * @param string $method + * @return int + */ + protected function incrementOrDecrement($column, $amount, $method) + { + $query = $this->newQuery(); + + if ( ! $this->exists) + { + return $query->{$method}($column, $amount); + } + + return $query->where($this->getKeyName(), $this->getKey())->{$method}($column, $amount); + } + + /** + * Update the model in the database. + * + * @param array $attributes + * @return mixed + */ + public function update(array $attributes = array()) + { + if ( ! $this->exists) + { + return $this->newQuery()->update($attributes); + } + + return $this->fill($attributes)->save(); + } + + /** + * Save the model and all of its relationships. + * + * @return bool + */ + public function push() + { + if ( ! $this->save()) return false; + + // To sync all of the relationships to the database, we will simply spin through + // the relationships and save each model via this "push" method, which allows + // us to recurs into all of these nested relations for this model instance. + foreach ($this->relations as $models) + { + foreach (Collection::make($models) as $model) + { + if ( ! $model->push()) return false; + } + } + + return true; + } + + /** + * Save the model to the database. + * + * @param array $options + * @return bool + */ + public function save(array $options = array()) + { + $query = $this->newQueryWithDeleted(); + + // If the "saving" event returns false we'll bail out of the save and return + // false, indicating that the save failed. This gives an opportunities to + // listeners to cancel save operations if validations fail or whatever. + if ($this->fireModelEvent('saving') === false) + { + return false; + } + + // If the model already exists in the database we can just update our record + // that is already in this database using the current IDs in this "where" + // clause to only update this model. Otherwise, we'll just insert them. + if ($this->exists) + { + $saved = $this->performUpdate($query); + } + + // If the model is brand new, we'll insert it into our database and set the + // ID attribute on the model to the value of the newly inserted row's ID + // which is typically an auto-increment value managed by the database. + else + { + $saved = $this->performInsert($query); + } + + if ($saved) $this->finishSave($options); + + return $saved; + } + + /** + * Finish processing on a successful save operation. + * + * @param array $options + * @return void + */ + protected function finishSave(array $options) + { + $this->syncOriginal(); + + $this->fireModelEvent('saved', false); + + if (array_get($options, 'touch', true)) $this->touchOwners(); + } + + /** + * Perform a model update operation. + * + * @param \Illuminate\Database\Eloquent\Builder $query + * @return bool + */ + protected function performUpdate(Builder $query) + { + $dirty = $this->getDirty(); + + if (count($dirty) > 0) + { + // If the updating event returns false, we will cancel the update operation so + // developers can hook Validation systems into their models and cancel this + // operation if the model does not pass validation. Otherwise, we update. + if ($this->fireModelEvent('updating') === false) + { + return false; + } + + // First we need to create a fresh query instance and touch the creation and + // update timestamp on the model which are maintained by us for developer + // convenience. Then we will just continue saving the model instances. + if ($this->timestamps) + { + $this->updateTimestamps(); + } + + // Once we have run the update operation, we will fire the "updated" event for + // this model instance. This will allow developers to hook into these after + // models are updated, giving them a chance to do any special processing. + $dirty = $this->getDirty(); + + if (count($dirty) > 0) + { + $this->setKeysForSaveQuery($query)->update($dirty); + + $this->fireModelEvent('updated', false); + } + } + + return true; + } + + /** + * Perform a model insert operation. + * + * @param \Illuminate\Database\Eloquent\Builder $query + * @return bool + */ + protected function performInsert(Builder $query) + { + if ($this->fireModelEvent('creating') === false) return false; + + // First we'll need to create a fresh query instance and touch the creation and + // update timestamps on this model, which are maintained by us for developer + // convenience. After, we will just continue saving these model instances. + if ($this->timestamps) + { + $this->updateTimestamps(); + } + + // If the model has an incrementing key, we can use the "insertGetId" method on + // the query builder, which will give us back the final inserted ID for this + // table from the database. Not all tables have to be incrementing though. + $attributes = $this->attributes; + + if ($this->incrementing) + { + $this->insertAndSetId($query, $attributes); + } + + // If the table is not incrementing we'll simply insert this attributes as they + // are, as this attributes arrays must contain an "id" column already placed + // there by the developer as the manually determined key for these models. + else + { + $query->insert($attributes); + } + + // We will go ahead and set the exists property to true, so that it is set when + // the created event is fired, just in case the developer tries to update it + // during the event. This will allow them to do so and run an update here. + $this->exists = true; + + $this->fireModelEvent('created', false); + + return true; + } + + /** + * Insert the given attributes and set the ID on the model. + * + * @param \Illuminate\Database\Eloquent\Builder $query + * @param array $attributes + * @return void + */ + protected function insertAndSetId(Builder $query, $attributes) + { + $id = $query->insertGetId($attributes, $keyName = $this->getKeyName()); + + $this->setAttribute($keyName, $id); + } + + /** + * Touch the owning relations of the model. + * + * @return void + */ + public function touchOwners() + { + foreach ($this->touches as $relation) + { + $this->$relation()->touch(); + } + } + + /** + * Determine if the model touches a given relation. + * + * @param string $relation + * @return bool + */ + public function touches($relation) + { + return in_array($relation, $this->touches); + } + + /** + * Fire the given event for the model. + * + * @param string $event + * @param bool $halt + * @return mixed + */ + protected function fireModelEvent($event, $halt = true) + { + if ( ! isset(static::$dispatcher)) return true; + + // We will append the names of the class to the event to distinguish it from + // other model events that are fired, allowing us to listen on each model + // event set individually instead of catching event for all the models. + $event = "eloquent.{$event}: ".get_class($this); + + $method = $halt ? 'until' : 'fire'; + + return static::$dispatcher->$method($event, $this); + } + + /** + * Set the keys for a save update query. + * + * @param \Illuminate\Database\Eloquent\Builder $query + * @return \Illuminate\Database\Eloquent\Builder + */ + protected function setKeysForSaveQuery(Builder $query) + { + $query->where($this->getKeyName(), '=', $this->getKeyForSaveQuery()); + + return $query; + } + + /** + * Get the primary key value for a save query. + * + * @return mixed + */ + protected function getKeyForSaveQuery() + { + if (isset($this->original[$this->getKeyName()])) + { + return $this->original[$this->getKeyName()]; + } + else + { + return $this->getAttribute($this->getKeyName()); + } + } + + /** + * Update the model's update timestamp. + * + * @return bool + */ + public function touch() + { + $this->updateTimestamps(); + + return $this->save(); + } + + /** + * Update the creation and update timestamps. + * + * @return void + */ + protected function updateTimestamps() + { + $time = $this->freshTimestamp(); + + if ( ! $this->isDirty(static::UPDATED_AT)) + { + $this->setUpdatedAt($time); + } + + if ( ! $this->exists && ! $this->isDirty(static::CREATED_AT)) + { + $this->setCreatedAt($time); + } + } + + /** + * Set the value of the "created at" attribute. + * + * @param mixed $value + * @return void + */ + public function setCreatedAt($value) + { + $this->{static::CREATED_AT} = $value; + } + + /** + * Set the value of the "updated at" attribute. + * + * @param mixed $value + * @return void + */ + public function setUpdatedAt($value) + { + $this->{static::UPDATED_AT} = $value; + } + + /** + * Get the name of the "created at" column. + * + * @return string + */ + public function getCreatedAtColumn() + { + return static::CREATED_AT; + } + + /** + * Get the name of the "updated at" column. + * + * @return string + */ + public function getUpdatedAtColumn() + { + return static::UPDATED_AT; + } + + /** + * Get the name of the "deleted at" column. + * + * @return string + */ + public function getDeletedAtColumn() + { + return static::DELETED_AT; + } + + /** + * Get the fully qualified "deleted at" column. + * + * @return string + */ + public function getQualifiedDeletedAtColumn() + { + return $this->getTable().'.'.$this->getDeletedAtColumn(); + } + + /** + * Get a fresh timestamp for the model. + * + * @return \Carbon\Carbon + */ + public function freshTimestamp() + { + return new Carbon; + } + + /** + * Get a fresh timestamp for the model. + * + * @return string + */ + public function freshTimestampString() + { + return $this->fromDateTime($this->freshTimestamp()); + } + + /** + * Get a new query builder for the model's table. + * + * @param bool $excludeDeleted + * @return \Illuminate\Database\Eloquent\Builder|static + */ + public function newQuery($excludeDeleted = true) + { + $builder = $this->newEloquentBuilder($this->newBaseQueryBuilder()); + + // Once we have the query builders, we will set the model instances so the + // builder can easily access any information it may need from the model + // while it is constructing and executing various queries against it. + $builder->setModel($this)->with($this->with); + + if ($excludeDeleted && $this->softDelete) + { + $builder->whereNull($this->getQualifiedDeletedAtColumn()); + } + + return $builder; + } + + /** + * Get a new query builder that includes soft deletes. + * + * @return \Illuminate\Database\Eloquent\Builder|static + */ + public function newQueryWithDeleted() + { + return $this->newQuery(false); + } + + /** + * Create a new Eloquent query builder for the model. + * + * @param \Illuminate\Database\Query\Builder $query + * @return \Illuminate\Database\Eloquent\Builder|static + */ + public function newEloquentBuilder($query) + { + return new Builder($query); + } + + /** + * Determine if the model instance has been soft-deleted. + * + * @return bool + */ + public function trashed() + { + return $this->softDelete && ! is_null($this->{static::DELETED_AT}); + } + + /** + * Get a new query builder that includes soft deletes. + * + * @return \Illuminate\Database\Eloquent\Builder|static + */ + public static function withTrashed() + { + return with(new static)->newQueryWithDeleted(); + } + + /** + * Get a new query builder that only includes soft deletes. + * + * @return \Illuminate\Database\Eloquent\Builder|static + */ + public static function onlyTrashed() + { + $instance = new static; + + $column = $instance->getQualifiedDeletedAtColumn(); + + return $instance->newQueryWithDeleted()->whereNotNull($column); + } + + /** + * Get a new query builder instance for the connection. + * + * @return \Illuminate\Database\Query\Builder + */ + protected function newBaseQueryBuilder() + { + $conn = $this->getConnection(); + + $grammar = $conn->getQueryGrammar(); + + return new QueryBuilder($conn, $grammar, $conn->getPostProcessor()); + } + + /** + * Create a new Eloquent Collection instance. + * + * @param array $models + * @return \Illuminate\Database\Eloquent\Collection + */ + public function newCollection(array $models = array()) + { + return new Collection($models); + } + + /** + * Create a new pivot model instance. + * + * @param \Illuminate\Database\Eloquent\Model $parent + * @param array $attributes + * @param string $table + * @param bool $exists + * @return \Illuminate\Database\Eloquent\Relations\Pivot + */ + public function newPivot(Model $parent, array $attributes, $table, $exists) + { + return new Pivot($parent, $attributes, $table, $exists); + } + + /** + * Get the table associated with the model. + * + * @return string + */ + public function getTable() + { + if (isset($this->table)) return $this->table; + + return str_replace('\\', '', snake_case(str_plural(class_basename($this)))); + } + + /** + * Set the table associated with the model. + * + * @param string $table + * @return void + */ + public function setTable($table) + { + $this->table = $table; + } + + /** + * Get the value of the model's primary key. + * + * @return mixed + */ + public function getKey() + { + return $this->getAttribute($this->getKeyName()); + } + + /** + * Get the primary key for the model. + * + * @return string + */ + public function getKeyName() + { + return $this->primaryKey; + } + + /** + * Get the table qualified key name. + * + * @return string + */ + public function getQualifiedKeyName() + { + return $this->getTable().'.'.$this->getKeyName(); + } + + /** + * Determine if the model uses timestamps. + * + * @return bool + */ + public function usesTimestamps() + { + return $this->timestamps; + } + + /** + * Determine if the model instance uses soft deletes. + * + * @return bool + */ + public function isSoftDeleting() + { + return $this->softDelete; + } + + /** + * Set the soft deleting property on the model. + * + * @param bool $enabled + * @return void + */ + public function setSoftDeleting($enabled) + { + $this->softDelete = $enabled; + } + + /** + * Get the polymorphic relationship columns. + * + * @param string $name + * @param string $type + * @param string $id + * @return array + */ + protected function getMorphs($name, $type, $id) + { + $type = $type ?: $name.'_type'; + + $id = $id ?: $name.'_id'; + + return array($type, $id); + } + + /** + * Get the class name for polymorphic relations. + * + * @return string + */ + public function getMorphClass() + { + return $this->morphClass ?: get_class($this); + } + + /** + * Get the number of models to return per page. + * + * @return int + */ + public function getPerPage() + { + return $this->perPage; + } + + /** + * Set the number of models to return per page. + * + * @param int $perPage + * @return void + */ + public function setPerPage($perPage) + { + $this->perPage = $perPage; + } + + /** + * Get the default foreign key name for the model. + * + * @return string + */ + public function getForeignKey() + { + return snake_case(class_basename($this)).'_id'; + } + + /** + * Get the hidden attributes for the model. + * + * @return array + */ + public function getHidden() + { + return $this->hidden; + } + + /** + * Set the hidden attributes for the model. + * + * @param array $hidden + * @return void + */ + public function setHidden(array $hidden) + { + $this->hidden = $hidden; + } + + /** + * Set the visible attributes for the model. + * + * @param array $visible + * @return void + */ + public function setVisible(array $visible) + { + $this->visible = $visible; + } + + /** + * Set the accessors to append to model arrays. + * + * @param array $appends + * @return void + */ + public function setAppends(array $appends) + { + $this->appends = $appends; + } + + /** + * Get the fillable attributes for the model. + * + * @return array + */ + public function getFillable() + { + return $this->fillable; + } + + /** + * Set the fillable attributes for the model. + * + * @param array $fillable + * @return \Illuminate\Database\Eloquent\Model + */ + public function fillable(array $fillable) + { + $this->fillable = $fillable; + + return $this; + } + + /** + * Set the guarded attributes for the model. + * + * @param array $guarded + * @return \Illuminate\Database\Eloquent\Model + */ + public function guard(array $guarded) + { + $this->guarded = $guarded; + + return $this; + } + + /** + * Disable all mass assignable restrictions. + * + * @return void + */ + public static function unguard() + { + static::$unguarded = true; + } + + /** + * Enable the mass assignment restrictions. + * + * @return void + */ + public static function reguard() + { + static::$unguarded = false; + } + + /** + * Set "unguard" to a given state. + * + * @param bool $state + * @return void + */ + public static function setUnguardState($state) + { + static::$unguarded = $state; + } + + /** + * Determine if the given attribute may be mass assigned. + * + * @param string $key + * @return bool + */ + public function isFillable($key) + { + if (static::$unguarded) return true; + + // If the key is in the "fillable" array, we can of course assume that it's + // a fillable attribute. Otherwise, we will check the guarded array when + // we need to determine if the attribute is black-listed on the model. + if (in_array($key, $this->fillable)) return true; + + if ($this->isGuarded($key)) return false; + + return empty($this->fillable) && ! starts_with($key, '_'); + } + + /** + * Determine if the given key is guarded. + * + * @param string $key + * @return bool + */ + public function isGuarded($key) + { + return in_array($key, $this->guarded) || $this->guarded == array('*'); + } + + /** + * Determine if the model is totally guarded. + * + * @return bool + */ + public function totallyGuarded() + { + return count($this->fillable) == 0 && $this->guarded == array('*'); + } + + /** + * Remove the table name from a given key. + * + * @param string $key + * @return string + */ + protected function removeTableFromKey($key) + { + if ( ! str_contains($key, '.')) return $key; + + return last(explode('.', $key)); + } + + /** + * Get the relationships that are touched on save. + * + * @return array + */ + public function getTouchedRelations() + { + return $this->touches; + } + + /** + * Set the relationships that are touched on save. + * + * @param array $touches + * @return void + */ + public function setTouchedRelations(array $touches) + { + $this->touches = $touches; + } + + /** + * Get the value indicating whether the IDs are incrementing. + * + * @return bool + */ + public function getIncrementing() + { + return $this->incrementing; + } + + /** + * Set whether IDs are incrementing. + * + * @param bool $value + * @return void + */ + public function setIncrementing($value) + { + $this->incrementing = $value; + } + + /** + * Convert the model instance to JSON. + * + * @param int $options + * @return string + */ + public function toJson($options = 0) + { + return json_encode($this->toArray(), $options); + } + + /** + * Convert the model instance to an array. + * + * @return array + */ + public function toArray() + { + $attributes = $this->attributesToArray(); + + return array_merge($attributes, $this->relationsToArray()); + } + + /** + * Convert the model's attributes to an array. + * + * @return array + */ + public function attributesToArray() + { + $attributes = $this->getArrayableAttributes(); + + // If an attribute is a date, we will cast it to a string after converting it + // to a DateTime / Carbon instance. This is so we will get some consistent + // formatting while accessing attributes vs. arraying / JSONing a model. + foreach ($this->getDates() as $key) + { + if ( ! isset($attributes[$key])) continue; + + $attributes[$key] = (string) $this->asDateTime($attributes[$key]); + } + + // We want to spin through all the mutated attributes for this model and call + // the mutator for the attribute. We cache off every mutated attributes so + // we don't have to constantly check on attributes that actually change. + foreach ($this->getMutatedAttributes() as $key) + { + if ( ! array_key_exists($key, $attributes)) continue; + + $attributes[$key] = $this->mutateAttributeForArray( + $key, $attributes[$key] + ); + } + + // Here we will grab all of the appended, calculated attributes to this model + // as these attributes are not really in the attributes array, but are run + // when we need to array or JSON the model for convenience to the coder. + foreach ($this->appends as $key) + { + $attributes[$key] = $this->mutateAttributeForArray($key, null); + } + + return $attributes; + } + + /** + * Get an attribute array of all arrayable attributes. + * + * @return array + */ + protected function getArrayableAttributes() + { + return $this->getArrayableItems($this->attributes); + } + + /** + * Get the model's relationships in array form. + * + * @return array + */ + public function relationsToArray() + { + $attributes = array(); + + foreach ($this->getArrayableRelations() as $key => $value) + { + if (in_array($key, $this->hidden)) continue; + + // If the values implements the Arrayable interface we can just call this + // toArray method on the instances which will convert both models and + // collections to their proper array form and we'll set the values. + if ($value instanceof ArrayableInterface) + { + $relation = $value->toArray(); + } + + // If the value is null, we'll still go ahead and set it in this list of + // attributes since null is used to represent empty relationships if + // if it a has one or belongs to type relationships on the models. + elseif (is_null($value)) + { + $relation = $value; + } + + // If the relationships snake-casing is enabled, we will snake case this + // key so that the relation attribute is snake cased in this returned + // array to the developers, making this consistent with attributes. + if (static::$snakeAttributes) + { + $key = snake_case($key); + } + + // If the relation value has been set, we will set it on this attributes + // list for returning. If it was not arrayable or null, we'll not set + // the value on the array because it is some type of invalid value. + if (isset($relation) || is_null($value)) + { + $attributes[$key] = $relation; + } + } + + return $attributes; + } + + /** + * Get an attribute array of all arrayable relations. + * + * @return array + */ + protected function getArrayableRelations() + { + return $this->getArrayableItems($this->relations); + } + + /** + * Get an attribute array of all arrayable values. + * + * @param array $values + * @return array + */ + protected function getArrayableItems(array $values) + { + if (count($this->visible) > 0) + { + return array_intersect_key($values, array_flip($this->visible)); + } + + return array_diff_key($values, array_flip($this->hidden)); + } + + /** + * Get an attribute from the model. + * + * @param string $key + * @return mixed + */ + public function getAttribute($key) + { + $inAttributes = array_key_exists($key, $this->attributes); + + // If the key references an attribute, we can just go ahead and return the + // plain attribute value from the model. This allows every attribute to + // be dynamically accessed through the _get method without accessors. + if ($inAttributes || $this->hasGetMutator($key)) + { + return $this->getAttributeValue($key); + } + + // If the key already exists in the relationships array, it just means the + // relationship has already been loaded, so we'll just return it out of + // here because there is no need to query within the relations twice. + if (array_key_exists($key, $this->relations)) + { + return $this->relations[$key]; + } + + // If the "attribute" exists as a method on the model, we will just assume + // it is a relationship and will load and return results from the query + // and hydrate the relationship's value on the "relationships" array. + $camelKey = camel_case($key); + + if (method_exists($this, $camelKey)) + { + return $this->getRelationshipFromMethod($key, $camelKey); + } + } + + /** + * Get a plain attribute (not a relationship). + * + * @param string $key + * @return mixed + */ + protected function getAttributeValue($key) + { + $value = $this->getAttributeFromArray($key); + + // If the attribute has a get mutator, we will call that then return what + // it returns as the value, which is useful for transforming values on + // retrieval from the model to a form that is more useful for usage. + if ($this->hasGetMutator($key)) + { + return $this->mutateAttribute($key, $value); + } + + // If the attribute is listed as a date, we will convert it to a DateTime + // instance on retrieval, which makes it quite convenient to work with + // date fields without having to create a mutator for each property. + elseif (in_array($key, $this->getDates())) + { + if ($value) return $this->asDateTime($value); + } + + return $value; + } + + /** + * Get an attribute from the $attributes array. + * + * @param string $key + * @return mixed + */ + protected function getAttributeFromArray($key) + { + if (array_key_exists($key, $this->attributes)) + { + return $this->attributes[$key]; + } + } + + /** + * Get a relationship value from a method. + * + * @param string $key + * @param string $camelKey + * @return mixed + * + * @throws \LogicException + */ + protected function getRelationshipFromMethod($key, $camelKey) + { + $relations = $this->$camelKey(); + + if ( ! $relations instanceof Relation) + { + throw new LogicException('Relationship method must return an object of type ' + . 'Illuminate\Database\Eloquent\Relations\Relation'); + } + + return $this->relations[$key] = $relations->getResults(); + } + + /** + * Determine if a get mutator exists for an attribute. + * + * @param string $key + * @return bool + */ + public function hasGetMutator($key) + { + return method_exists($this, 'get'.studly_case($key).'Attribute'); + } + + /** + * Get the value of an attribute using its mutator. + * + * @param string $key + * @param mixed $value + * @return mixed + */ + protected function mutateAttribute($key, $value) + { + return $this->{'get'.studly_case($key).'Attribute'}($value); + } + + /** + * Get the value of an attribute using its mutator for array conversion. + * + * @param string $key + * @param mixed $value + * @return mixed + */ + protected function mutateAttributeForArray($key, $value) + { + $value = $this->mutateAttribute($key, $value); + + return $value instanceof ArrayableInterface ? $value->toArray() : $value; + } + + /** + * Set a given attribute on the model. + * + * @param string $key + * @param mixed $value + * @return void + */ + public function setAttribute($key, $value) + { + // First we will check for the presence of a mutator for the set operation + // which simply lets the developers tweak the attribute as it is set on + // the model, such as "json_encoding" an listing of data for storage. + if ($this->hasSetMutator($key)) + { + $method = 'set'.studly_case($key).'Attribute'; + + return $this->{$method}($value); + } + + // If an attribute is listed as a "date", we'll convert it from a DateTime + // instance into a form proper for storage on the database tables using + // the connection grammar's date format. We will auto set the values. + elseif (in_array($key, $this->getDates())) + { + if ($value) + { + $value = $this->fromDateTime($value); + } + } + + $this->attributes[$key] = $value; + } + + /** + * Determine if a set mutator exists for an attribute. + * + * @param string $key + * @return bool + */ + public function hasSetMutator($key) + { + return method_exists($this, 'set'.studly_case($key).'Attribute'); + } + + /** + * Get the attributes that should be converted to dates. + * + * @return array + */ + public function getDates() + { + $defaults = array(static::CREATED_AT, static::UPDATED_AT, static::DELETED_AT); + + return array_merge($this->dates, $defaults); + } + + /** + * Convert a DateTime to a storable string. + * + * @param \DateTime|int $value + * @return string + */ + public function fromDateTime($value) + { + $format = $this->getDateFormat(); + + // If the value is already a DateTime instance, we will just skip the rest of + // these checks since they will be a waste of time, and hinder performance + // when checking the field. We will just return the DateTime right away. + if ($value instanceof DateTime) + { + // + } + + // If the value is totally numeric, we will assume it is a UNIX timestamp and + // format the date as such. Once we have the date in DateTime form we will + // format it according to the proper format for the database connection. + elseif (is_numeric($value)) + { + $value = Carbon::createFromTimestamp($value); + } + + // If the value is in simple year, month, day format, we will format it using + // that setup. This is for simple "date" fields which do not have hours on + // the field. This conveniently picks up those dates and format correct. + elseif (preg_match('/^(\d{4})-(\d{2})-(\d{2})$/', $value)) + { + $value = Carbon::createFromFormat('Y-m-d', $value)->startOfDay(); + } + + // If this value is some other type of string, we'll create the DateTime with + // the format used by the database connection. Once we get the instance we + // can return back the finally formatted DateTime instances to the devs. + elseif ( ! $value instanceof DateTime) + { + $value = Carbon::createFromFormat($format, $value); + } + + return $value->format($format); + } + + /** + * Return a timestamp as DateTime object. + * + * @param mixed $value + * @return \Carbon\Carbon + */ + protected function asDateTime($value) + { + // If this value is an integer, we will assume it is a UNIX timestamp's value + // and format a Carbon object from this timestamp. This allows flexibility + // when defining your date fields as they might be UNIX timestamps here. + if (is_numeric($value)) + { + return Carbon::createFromTimestamp($value); + } + + // If the value is in simply year, month, day format, we will instantiate the + // Carbon instances from that format. Again, this provides for simple date + // fields on the database, while still supporting Carbonized conversion. + elseif (preg_match('/^(\d{4})-(\d{2})-(\d{2})$/', $value)) + { + return Carbon::createFromFormat('Y-m-d', $value)->startOfDay(); + } + + // Finally, we will just assume this date is in the format used by default on + // the database connection and use that format to create the Carbon object + // that is returned back out to the developers after we convert it here. + elseif ( ! $value instanceof DateTime) + { + $format = $this->getDateFormat(); + + return Carbon::createFromFormat($format, $value); + } + + return Carbon::instance($value); + } + + /** + * Get the format for database stored dates. + * + * @return string + */ + protected function getDateFormat() + { + return $this->getConnection()->getQueryGrammar()->getDateFormat(); + } + + /** + * Clone the model into a new, non-existing instance. + * + * @return \Illuminate\Database\Eloquent\Model + */ + public function replicate() + { + $attributes = array_except($this->attributes, array($this->getKeyName())); + + with($instance = new static)->setRawAttributes($attributes); + + return $instance->setRelations($this->relations); + } + + /** + * Get all of the current attributes on the model. + * + * @return array + */ + public function getAttributes() + { + return $this->attributes; + } + + /** + * Set the array of model attributes. No checking is done. + * + * @param array $attributes + * @param bool $sync + * @return void + */ + public function setRawAttributes(array $attributes, $sync = false) + { + $this->attributes = $attributes; + + if ($sync) $this->syncOriginal(); + } + + /** + * Get the model's original attribute values. + * + * @param string $key + * @param mixed $default + * @return array + */ + public function getOriginal($key = null, $default = null) + { + return array_get($this->original, $key, $default); + } + + /** + * Sync the original attributes with the current. + * + * @return \Illuminate\Database\Eloquent\Model + */ + public function syncOriginal() + { + $this->original = $this->attributes; + + return $this; + } + + /** + * Determine if a given attribute is dirty. + * + * @param string $attribute + * @return bool + */ + public function isDirty($attribute) + { + return array_key_exists($attribute, $this->getDirty()); + } + + /** + * Get the attributes that have been changed since last sync. + * + * @return array + */ + public function getDirty() + { + $dirty = array(); + + foreach ($this->attributes as $key => $value) + { + if ( ! array_key_exists($key, $this->original)) + { + $dirty[$key] = $value; + } + elseif ($value !== $this->original[$key] && + ! $this->originalIsNumericallyEquivalent($key)) + { + $dirty[$key] = $value; + } + } + + return $dirty; + } + + /** + * Determine if the new and old values for a given key are numerically equivalent. + * + * @param string $key + * @return bool + */ + protected function originalIsNumericallyEquivalent($key) + { + $current = $this->attributes[$key]; + + $original = $this->original[$key]; + + return is_numeric($current) && is_numeric($original) && strcmp((string) $current, (string) $original) === 0; + } + + /** + * Get all the loaded relations for the instance. + * + * @return array + */ + public function getRelations() + { + return $this->relations; + } + + /** + * Get a specified relationship. + * + * @param string $relation + * @return mixed + */ + public function getRelation($relation) + { + return $this->relations[$relation]; + } + + /** + * Set the specific relationship in the model. + * + * @param string $relation + * @param mixed $value + * @return \Illuminate\Database\Eloquent\Model + */ + public function setRelation($relation, $value) + { + $this->relations[$relation] = $value; + + return $this; + } + + /** + * Set the entire relations array on the model. + * + * @param array $relations + * @return \Illuminate\Database\Eloquent\Model + */ + public function setRelations(array $relations) + { + $this->relations = $relations; + + return $this; + } + + /** + * Get the database connection for the model. + * + * @return \Illuminate\Database\Connection + */ + public function getConnection() + { + return static::resolveConnection($this->connection); + } + + /** + * Get the current connection name for the model. + * + * @return string + */ + public function getConnectionName() + { + return $this->connection; + } + + /** + * Set the connection associated with the model. + * + * @param string $name + * @return \Illuminate\Database\Eloquent\Model + */ + public function setConnection($name) + { + $this->connection = $name; + + return $this; + } + + /** + * Resolve a connection instance. + * + * @param string $connection + * @return \Illuminate\Database\Connection + */ + public static function resolveConnection($connection = null) + { + return static::$resolver->connection($connection); + } + + /** + * Get the connection resolver instance. + * + * @return \Illuminate\Database\ConnectionResolverInterface + */ + public static function getConnectionResolver() + { + return static::$resolver; + } + + /** + * Set the connection resolver instance. + * + * @param \Illuminate\Database\ConnectionResolverInterface $resolver + * @return void + */ + public static function setConnectionResolver(Resolver $resolver) + { + static::$resolver = $resolver; + } + + /** + * Unset the connection resolver for models. + * + * @return void + */ + public static function unsetConnectionResolver() + { + static::$resolver = null; + } + + /** + * Get the event dispatcher instance. + * + * @return \Illuminate\Events\Dispatcher + */ + public static function getEventDispatcher() + { + return static::$dispatcher; + } + + /** + * Set the event dispatcher instance. + * + * @param \Illuminate\Events\Dispatcher $dispatcher + * @return void + */ + public static function setEventDispatcher(Dispatcher $dispatcher) + { + static::$dispatcher = $dispatcher; + } + + /** + * Unset the event dispatcher for models. + * + * @return void + */ + public static function unsetEventDispatcher() + { + static::$dispatcher = null; + } + + /** + * Get the mutated attributes for a given instance. + * + * @return array + */ + public function getMutatedAttributes() + { + $class = get_class($this); + + if (isset(static::$mutatorCache[$class])) + { + return static::$mutatorCache[get_class($this)]; + } + + return array(); + } + + /** + * Dynamically retrieve attributes on the model. + * + * @param string $key + * @return mixed + */ + public function __get($key) + { + return $this->getAttribute($key); + } + + /** + * Dynamically set attributes on the model. + * + * @param string $key + * @param mixed $value + * @return void + */ + public function __set($key, $value) + { + $this->setAttribute($key, $value); + } + + /** + * Determine if the given attribute exists. + * + * @param mixed $offset + * @return bool + */ + public function offsetExists($offset) + { + return isset($this->$offset); + } + + /** + * Get the value for a given offset. + * + * @param mixed $offset + * @return mixed + */ + public function offsetGet($offset) + { + return $this->$offset; + } + + /** + * Set the value for a given offset. + * + * @param mixed $offset + * @param mixed $value + * @return void + */ + public function offsetSet($offset, $value) + { + $this->$offset = $value; + } + + /** + * Unset the value for a given offset. + * + * @param mixed $offset + * @return void + */ + public function offsetUnset($offset) + { + unset($this->$offset); + } + + /** + * Determine if an attribute exists on the model. + * + * @param string $key + * @return bool + */ + public function __isset($key) + { + return ((isset($this->attributes[$key]) || isset($this->relations[$key])) || + ($this->hasGetMutator($key) && ! is_null($this->getAttributeValue($key)))); + } + + /** + * Unset an attribute on the model. + * + * @param string $key + * @return void + */ + public function __unset($key) + { + unset($this->attributes[$key]); + + unset($this->relations[$key]); + } + + /** + * Handle dynamic method calls into the method. + * + * @param string $method + * @param array $parameters + * @return mixed + */ + public function __call($method, $parameters) + { + if (in_array($method, array('increment', 'decrement'))) + { + return call_user_func_array(array($this, $method), $parameters); + } + + $query = $this->newQuery(); + + return call_user_func_array(array($query, $method), $parameters); + } + + /** + * Handle dynamic static method calls into the method. + * + * @param string $method + * @param array $parameters + * @return mixed + */ + public static function __callStatic($method, $parameters) + { + $instance = new static; + + return call_user_func_array(array($instance, $method), $parameters); + } + + /** + * Convert the model to its string representation. + * + * @return string + */ + public function __toString() + { + return $this->toJson(); + } + + /** + * When a model is being unserialized, check if it needs to be booted. + * + * @return void + */ + public function __wakeup() + { + $this->bootIfNotBooted(); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Database/Eloquent/ModelNotFoundException.php b/vendor/laravel/framework/src/Illuminate/Database/Eloquent/ModelNotFoundException.php new file mode 100755 index 0000000..2256f13 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Database/Eloquent/ModelNotFoundException.php @@ -0,0 +1,37 @@ +model = $model; + + $this->message = "No query results for model [{$model}]."; + + return $this; + } + + /** + * Get the affected Eloquent model. + * + * @return string + */ + public function getModel() + { + return $this->model; + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/BelongsTo.php b/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/BelongsTo.php new file mode 100755 index 0000000..ec78aeb --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/BelongsTo.php @@ -0,0 +1,263 @@ +otherKey = $otherKey; + $this->relation = $relation; + $this->foreignKey = $foreignKey; + + parent::__construct($query, $parent); + } + + /** + * Get the results of the relationship. + * + * @return mixed + */ + public function getResults() + { + return $this->query->first(); + } + + /** + * Set the base constraints on the relation query. + * + * @return void + */ + public function addConstraints() + { + if (static::$constraints) + { + // For belongs to relationships, which are essentially the inverse of has one + // or has many relationships, we need to actually query on the primary key + // of the related models matching on the foreign key that's on a parent. + $table = $this->related->getTable(); + + $this->query->where($table.'.'.$this->otherKey, '=', $this->parent->{$this->foreignKey}); + } + } + + /** + * Add the constraints for a relationship count query. + * + * @param \Illuminate\Database\Eloquent\Builder $query + * @param \Illuminate\Database\Eloquent\Builder $parent + * @return \Illuminate\Database\Eloquent\Builder + */ + public function getRelationCountQuery(Builder $query, Builder $parent) + { + $query->select(new Expression('count(*)')); + + $otherKey = $this->wrap($query->getModel()->getTable().'.'.$this->otherKey); + + return $query->where($this->getQualifiedForeignKey(), '=', new Expression($otherKey)); + } + + /** + * Set the constraints for an eager load of the relation. + * + * @param array $models + * @return void + */ + public function addEagerConstraints(array $models) + { + // We'll grab the primary key name of the related models since it could be set to + // a non-standard name and not "id". We will then construct the constraint for + // our eagerly loading query so it returns the proper models from execution. + $key = $this->related->getTable().'.'.$this->otherKey; + + $this->query->whereIn($key, $this->getEagerModelKeys($models)); + } + + /** + * Gather the keys from an array of related models. + * + * @param array $models + * @return array + */ + protected function getEagerModelKeys(array $models) + { + $keys = array(); + + // First we need to gather all of the keys from the parent models so we know what + // to query for via the eager loading query. We will add them to an array then + // execute a "where in" statement to gather up all of those related records. + foreach ($models as $model) + { + if ( ! is_null($value = $model->{$this->foreignKey})) + { + $keys[] = $value; + } + } + + // If there are no keys that were not null we will just return an array with 0 in + // it so the query doesn't fail, but will not return any results, which should + // be what this developer is expecting in a case where this happens to them. + if (count($keys) == 0) + { + return array(0); + } + + return array_values(array_unique($keys)); + } + + /** + * Initialize the relation on a set of models. + * + * @param array $models + * @param string $relation + * @return array + */ + public function initRelation(array $models, $relation) + { + foreach ($models as $model) + { + $model->setRelation($relation, null); + } + + return $models; + } + + /** + * Match the eagerly loaded results to their parents. + * + * @param array $models + * @param \Illuminate\Database\Eloquent\Collection $results + * @param string $relation + * @return array + */ + public function match(array $models, Collection $results, $relation) + { + $foreign = $this->foreignKey; + + $other = $this->otherKey; + + // First we will get to build a dictionary of the child models by their primary + // key of the relationship, then we can easily match the children back onto + // the parents using that dictionary and the primary key of the children. + $dictionary = array(); + + foreach ($results as $result) + { + $dictionary[$result->getAttribute($other)] = $result; + } + + // Once we have the dictionary constructed, we can loop through all the parents + // and match back onto their children using these keys of the dictionary and + // the primary key of the children to map them onto the correct instances. + foreach ($models as $model) + { + if (isset($dictionary[$model->$foreign])) + { + $model->setRelation($relation, $dictionary[$model->$foreign]); + } + } + + return $models; + } + + /** + * Associate the model instance to the given parent. + * + * @param \Illuminate\Database\Eloquent\Model $model + * @return \Illuminate\Database\Eloquent\Model + */ + public function associate(Model $model) + { + $this->parent->setAttribute($this->foreignKey, $model->getAttribute($this->otherKey)); + + return $this->parent->setRelation($this->relation, $model); + } + + /** + * Update the parent model on the relationship. + * + * @param array $attributes + * @return mixed + */ + public function update(array $attributes) + { + $instance = $this->getResults(); + + return $instance->fill($attributes)->save(); + } + + /** + * Get the foreign key of the relationship. + * + * @return string + */ + public function getForeignKey() + { + return $this->foreignKey; + } + + /** + * Get the fully qualified foreign key of the relationship. + * + * @return string + */ + public function getQualifiedForeignKey() + { + return $this->parent->getTable().'.'.$this->foreignKey; + } + + /** + * Get the associated key of the relationship. + * + * @return string + */ + public function getOtherKey() + { + return $this->otherKey; + } + + /** + * Get the fully qualified associated key of the relationship. + * + * @return string + */ + public function getQualifiedOtherKeyName() + { + return $this->related->getTable().'.'.$this->otherKey; + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/BelongsToMany.php b/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/BelongsToMany.php new file mode 100755 index 0000000..16ebe72 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/BelongsToMany.php @@ -0,0 +1,1037 @@ +table = $table; + $this->otherKey = $otherKey; + $this->foreignKey = $foreignKey; + $this->relationName = $relationName; + + parent::__construct($query, $parent); + } + + /** + * Get the results of the relationship. + * + * @return mixed + */ + public function getResults() + { + return $this->get(); + } + + /** + * Set a where clause for a pivot table column. + * + * @param string $column + * @param string $operator + * @param mixed $value + * @param string $boolean + * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany + */ + public function wherePivot($column, $operator = null, $value = null, $boolean = 'and') + { + return $this->where($this->table.'.'.$column, $operator, $value, $boolean); + } + + /** + * Set an or where clause for a pivot table column. + * + * @param string $column + * @param string $operator + * @param mixed $value + * @param string $boolean + * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany + */ + public function orWherePivot($column, $operator = null, $value = null) + { + return $this->wherePivot($column, $operator, $value, 'or'); + } + + /** + * Execute the query and get the first result. + * + * @param array $columns + * @return mixed + */ + public function first($columns = array('*')) + { + $results = $this->take(1)->get($columns); + + return count($results) > 0 ? $results->first() : null; + } + + /** + * Execute the query and get the first result or throw an exception. + * + * @param array $columns + * @return \Illuminate\Database\Eloquent\Model|static + * + * @throws \Illuminate\Database\Eloquent\ModelNotFoundException + */ + public function firstOrFail($columns = array('*')) + { + if ( ! is_null($model = $this->first($columns))) return $model; + + throw new ModelNotFoundException; + } + + /** + * Execute the query as a "select" statement. + * + * @param array $columns + * @return \Illuminate\Database\Eloquent\Collection + */ + public function get($columns = array('*')) + { + // First we'll add the proper select columns onto the query so it is run with + // the proper columns. Then, we will get the results and hydrate out pivot + // models with the result of those columns as a separate model relation. + $select = $this->getSelectColumns($columns); + + $models = $this->query->addSelect($select)->getModels(); + + $this->hydratePivotRelation($models); + + // If we actually found models we will also eager load any relationships that + // have been specified as needing to be eager loaded. This will solve the + // n + 1 query problem for the developer and also increase performance. + if (count($models) > 0) + { + $models = $this->query->eagerLoadRelations($models); + } + + return $this->related->newCollection($models); + } + + /** + * Get a paginator for the "select" statement. + * + * @param int $perPage + * @param array $columns + * @return \Illuminate\Pagination\Paginator + */ + public function paginate($perPage = null, $columns = array('*')) + { + $this->query->addSelect($this->getSelectColumns($columns)); + + // When paginating results, we need to add the pivot columns to the query and + // then hydrate into the pivot objects once the results have been gathered + // from the database since this isn't performed by the Eloquent builder. + $pager = $this->query->paginate($perPage, $columns); + + $this->hydratePivotRelation($pager->getItems()); + + return $pager; + } + + /** + * Hydrate the pivot table relationship on the models. + * + * @param array $models + * @return void + */ + protected function hydratePivotRelation(array $models) + { + // To hydrate the pivot relationship, we will just gather the pivot attributes + // and create a new Pivot model, which is basically a dynamic model that we + // will set the attributes, table, and connections on so it they be used. + foreach ($models as $model) + { + $pivot = $this->newExistingPivot($this->cleanPivotAttributes($model)); + + $model->setRelation('pivot', $pivot); + } + } + + /** + * Get the pivot attributes from a model. + * + * @param \Illuminate\Database\Eloquent\Model $model + * @return array + */ + protected function cleanPivotAttributes(Model $model) + { + $values = array(); + + foreach ($model->getAttributes() as $key => $value) + { + // To get the pivots attributes we will just take any of the attributes which + // begin with "pivot_" and add those to this arrays, as well as unsetting + // them from the parent's models since they exist in a different table. + if (strpos($key, 'pivot_') === 0) + { + $values[substr($key, 6)] = $value; + + unset($model->$key); + } + } + + return $values; + } + + /** + * Set the base constraints on the relation query. + * + * @return void + */ + public function addConstraints() + { + $this->setJoin(); + + if (static::$constraints) $this->setWhere(); + } + + /** + * Add the constraints for a relationship count query. + * + * @param \Illuminate\Database\Eloquent\Builder $query + * @param \Illuminate\Database\Eloquent\Builder $parent + * @return \Illuminate\Database\Eloquent\Builder + */ + public function getRelationCountQuery(Builder $query, Builder $parent) + { + if ($parent->getQuery()->from == $query->getQuery()->from) + { + return $this->getRelationCountQueryForSelfJoin($query, $parent); + } + else + { + $this->setJoin($query); + + return parent::getRelationCountQuery($query, $parent); + } + } + + /** + * Add the constraints for a relationship count query on the same table. + * + * @param \Illuminate\Database\Eloquent\Builder $query + * @param \Illuminate\Database\Eloquent\Builder $parent + * @return \Illuminate\Database\Eloquent\Builder + */ + public function getRelationCountQueryForSelfJoin(Builder $query, Builder $parent) + { + $query->select(new \Illuminate\Database\Query\Expression('count(*)')); + + $tablePrefix = $this->query->getQuery()->getConnection()->getTablePrefix(); + + $query->from($this->table.' as '.$tablePrefix.$hash = $this->getRelationCountHash()); + + $key = $this->wrap($this->getQualifiedParentKeyName()); + + return $query->where($hash.'.'.$this->foreignKey, '=', new \Illuminate\Database\Query\Expression($key)); + } + + /** + * Get a relationship join table hash. + * + * @return string + */ + public function getRelationCountHash() + { + return 'self_'.md5(microtime(true)); + } + + /** + * Set the select clause for the relation query. + * + * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany + */ + protected function getSelectColumns(array $columns = array('*')) + { + if ($columns == array('*')) + { + $columns = array($this->related->getTable().'.*'); + } + + return array_merge($columns, $this->getAliasedPivotColumns()); + } + + /** + * Get the pivot columns for the relation. + * + * @return array + */ + protected function getAliasedPivotColumns() + { + $defaults = array($this->foreignKey, $this->otherKey); + + // We need to alias all of the pivot columns with the "pivot_" prefix so we + // can easily extract them out of the models and put them into the pivot + // relationships when they are retrieved and hydrated into the models. + $columns = array(); + + foreach (array_merge($defaults, $this->pivotColumns) as $column) + { + $columns[] = $this->table.'.'.$column.' as pivot_'.$column; + } + + return array_unique($columns); + } + + /** + * Set the join clause for the relation query. + * + * @param \Illuminate\Database\Eloquent\Builder|null + * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany + */ + protected function setJoin($query = null) + { + $query = $query ?: $this->query; + + // We need to join to the intermediate table on the related model's primary + // key column with the intermediate table's foreign key for the related + // model instance. Then we can set the "where" for the parent models. + $baseTable = $this->related->getTable(); + + $key = $baseTable.'.'.$this->related->getKeyName(); + + $query->join($this->table, $key, '=', $this->getOtherKey()); + + return $this; + } + + /** + * Set the where clause for the relation query. + * + * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany + */ + protected function setWhere() + { + $foreign = $this->getForeignKey(); + + $this->query->where($foreign, '=', $this->parent->getKey()); + + return $this; + } + + /** + * Set the constraints for an eager load of the relation. + * + * @param array $models + * @return void + */ + public function addEagerConstraints(array $models) + { + $this->query->whereIn($this->getForeignKey(), $this->getKeys($models)); + } + + /** + * Initialize the relation on a set of models. + * + * @param array $models + * @param string $relation + * @return array + */ + public function initRelation(array $models, $relation) + { + foreach ($models as $model) + { + $model->setRelation($relation, $this->related->newCollection()); + } + + return $models; + } + + /** + * Match the eagerly loaded results to their parents. + * + * @param array $models + * @param \Illuminate\Database\Eloquent\Collection $results + * @param string $relation + * @return array + */ + public function match(array $models, Collection $results, $relation) + { + $dictionary = $this->buildDictionary($results); + + // Once we have an array dictionary of child objects we can easily match the + // children back to their parent using the dictionary and the keys on the + // the parent models. Then we will return the hydrated models back out. + foreach ($models as $model) + { + if (isset($dictionary[$key = $model->getKey()])) + { + $collection = $this->related->newCollection($dictionary[$key]); + + $model->setRelation($relation, $collection); + } + } + + return $models; + } + + /** + * Build model dictionary keyed by the relation's foreign key. + * + * @param \Illuminate\Database\Eloquent\Collection $results + * @return array + */ + protected function buildDictionary(Collection $results) + { + $foreign = $this->foreignKey; + + // First we will build a dictionary of child models keyed by the foreign key + // of the relation so that we will easily and quickly match them to their + // parents without having a possibly slow inner loops for every models. + $dictionary = array(); + + foreach ($results as $result) + { + $dictionary[$result->pivot->$foreign][] = $result; + } + + return $dictionary; + } + + /** + * Touch all of the related models for the relationship. + * + * E.g.: Touch all roles associated with this user. + * + * @return void + */ + public function touch() + { + $key = $this->getRelated()->getKeyName(); + + $columns = $this->getRelatedFreshUpdate(); + + // If we actually have IDs for the relation, we will run the query to update all + // the related model's timestamps, to make sure these all reflect the changes + // to the parent models. This will help us keep any caching synced up here. + $ids = $this->getRelatedIds(); + + if (count($ids) > 0) + { + $this->getRelated()->newQuery()->whereIn($key, $ids)->update($columns); + } + } + + /** + * Get all of the IDs for the related models. + * + * @return array + */ + public function getRelatedIds() + { + $related = $this->getRelated(); + + $fullKey = $related->getQualifiedKeyName(); + + return $this->getQuery()->select($fullKey)->lists($related->getKeyName()); + } + + /** + * Save a new model and attach it to the parent model. + * + * @param \Illuminate\Database\Eloquent\Model $model + * @param array $joining + * @param bool $touch + * @return \Illuminate\Database\Eloquent\Model + */ + public function save(Model $model, array $joining = array(), $touch = true) + { + $model->save(array('touch' => false)); + + $this->attach($model->getKey(), $joining, $touch); + + return $model; + } + + /** + * Save an array of new models and attach them to the parent model. + * + * @param array $models + * @param array $joinings + * @return array + */ + public function saveMany(array $models, array $joinings = array()) + { + foreach ($models as $key => $model) + { + $this->save($model, (array) array_get($joinings, $key), false); + } + + $this->touchIfTouching(); + + return $models; + } + + /** + * Create a new instance of the related model. + * + * @param array $attributes + * @param array $joining + * @param bool $touch + * @return \Illuminate\Database\Eloquent\Model + */ + public function create(array $attributes, array $joining = array(), $touch = true) + { + $instance = $this->related->newInstance($attributes); + + // Once we save the related model, we need to attach it to the base model via + // through intermediate table so we'll use the existing "attach" method to + // accomplish this which will insert the record and any more attributes. + $instance->save(array('touch' => false)); + + $this->attach($instance->getKey(), $joining, $touch); + + return $instance; + } + + /** + * Create an array of new instances of the related models. + * + * @param array $records + * @param array $joinings + * @return \Illuminate\Database\Eloquent\Model + */ + public function createMany(array $records, array $joinings = array()) + { + $instances = array(); + + foreach ($records as $key => $record) + { + $instances[] = $this->create($record, (array) array_get($joinings, $key), false); + } + + $this->touchIfTouching(); + + return $instances; + } + + /** + * Sync the intermediate tables with a list of IDs or collection of models. + * + * @param $ids + * @param bool $detaching + * @return array + */ + public function sync($ids, $detaching = true) + { + $changes = array( + 'attached' => array(), 'detached' => array(), 'updated' => array() + ); + + if ($ids instanceof Collection) $ids = $ids->modelKeys(); + + // First we need to attach any of the associated models that are not currently + // in this joining table. We'll spin through the given IDs, checking to see + // if they exist in the array of current ones, and if not we will insert. + $current = $this->newPivotQuery()->lists($this->otherKey); + + $records = $this->formatSyncList($ids); + + $detach = array_diff($current, array_keys($records)); + + // Next, we will take the differences of the currents and given IDs and detach + // all of the entities that exist in the "current" array but are not in the + // the array of the IDs given to the method which will complete the sync. + if ($detaching && count($detach) > 0) + { + $this->detach($detach); + + $changes['detached'] = (array) array_map('intval', $detach); + } + + // Now we are finally ready to attach the new records. Note that we'll disable + // touching until after the entire operation is complete so we don't fire a + // ton of touch operations until we are totally done syncing the records. + $changes = array_merge( + $changes, $this->attachNew($records, $current, false) + ); + + if (count($changes['attached']) || count($changes['updated'])) + { + $this->touchIfTouching(); + } + + return $changes; + } + + /** + * Format the sync list so that it is keyed by ID. + * + * @param array $records + * @return array + */ + protected function formatSyncList(array $records) + { + $results = array(); + + foreach ($records as $id => $attributes) + { + if ( ! is_array($attributes)) + { + list($id, $attributes) = array($attributes, array()); + } + + $results[$id] = $attributes; + } + + return $results; + } + + /** + * Attach all of the IDs that aren't in the current array. + * + * @param array $records + * @param array $current + * @param bool $touch + * @return array + */ + protected function attachNew(array $records, array $current, $touch = true) + { + $changes = array('attached' => array(), 'updated' => array()); + + foreach ($records as $id => $attributes) + { + // If the ID is not in the list of existing pivot IDs, we will insert a new pivot + // record, otherwise, we will just update this existing record on this joining + // table, so that the developers will easily update these records pain free. + if ( ! in_array($id, $current)) + { + $this->attach($id, $attributes, $touch); + + $changes['attached'][] = (int) $id; + } + + // Now we'll try to update an existing pivot record with the attributes that were + // given to the method. If the model is actually updated we will add it to the + // list of updated pivot records so we return them back out to the consumer. + elseif (count($attributes) > 0) + { + if ($this->updateExistingPivot($id, $attributes, $touch)) + { + $changes['updated'][] = (int) $id; + } + } + } + return $changes; + } + + /** + * Update an existing pivot record on the table. + * + * @param mixed $id + * @param array $attributes + * @param bool $touch + * @return void + */ + public function updateExistingPivot($id, array $attributes, $touch) + { + if (in_array($this->updatedAt(), $this->pivotColumns)) + { + $attributes = $this->setTimestampsOnAttach($attributes, true); + } + + $updated = $this->newPivotStatementForId($id)->update($attributes); + + if ($touch) $this->touchIfTouching(); + + return $updated; + } + + /** + * Attach a model to the parent. + * + * @param mixed $id + * @param array $attributes + * @param bool $touch + * @return void + */ + public function attach($id, array $attributes = array(), $touch = true) + { + if ($id instanceof Model) $id = $id->getKey(); + + $query = $this->newPivotStatement(); + + $query->insert($this->createAttachRecords((array) $id, $attributes)); + + if ($touch) $this->touchIfTouching(); + } + + /** + * Create an array of records to insert into the pivot table. + * + * @param array $ids + * @return array + */ + protected function createAttachRecords($ids, array $attributes) + { + $records = array(); + + $timed = in_array($this->createdAt(), $this->pivotColumns); + + // To create the attachment records, we will simply spin through the IDs given + // and create a new record to insert for each ID. Each ID may actually be a + // key in the array, with extra attributes to be placed in other columns. + foreach ($ids as $key => $value) + { + $records[] = $this->attacher($key, $value, $attributes, $timed); + } + + return $records; + } + + /** + * Create a full attachment record payload. + * + * @param int $key + * @param mixed $value + * @param array $attributes + * @param bool $timed + * @return array + */ + protected function attacher($key, $value, $attributes, $timed) + { + list($id, $extra) = $this->getAttachId($key, $value, $attributes); + + // To create the attachment records, we will simply spin through the IDs given + // and create a new record to insert for each ID. Each ID may actually be a + // key in the array, with extra attributes to be placed in other columns. + $record = $this->createAttachRecord($id, $timed); + + return array_merge($record, $extra); + } + + /** + * Get the attach record ID and extra attributes. + * + * @param mixed $key + * @param mixed $value + * @param array $attributes + * @return array + */ + protected function getAttachId($key, $value, array $attributes) + { + if (is_array($value)) + { + return array($key, array_merge($value, $attributes)); + } + else + { + return array($value, $attributes); + } + } + + /** + * Create a new pivot attachment record. + * + * @param int $id + * @param bool $timed + * @return array + */ + protected function createAttachRecord($id, $timed) + { + $record[$this->foreignKey] = $this->parent->getKey(); + + $record[$this->otherKey] = $id; + + // If the record needs to have creation and update timestamps, we will make + // them by calling the parent model's "freshTimestamp" method which will + // provide us with a fresh timestamp in this model's preferred format. + if ($timed) + { + $record = $this->setTimestampsOnAttach($record); + } + + return $record; + } + + /** + * Set the creation and update timestamps on an attach record. + * + * @param array $record + * @param bool $exists + * @return array + */ + protected function setTimestampsOnAttach(array $record, $exists = false) + { + $fresh = $this->parent->freshTimestamp(); + + if ( ! $exists) $record[$this->createdAt()] = $fresh; + + $record[$this->updatedAt()] = $fresh; + + return $record; + } + + /** + * Detach models from the relationship. + * + * @param int|array $ids + * @param bool $touch + * @return int + */ + public function detach($ids = array(), $touch = true) + { + if ($ids instanceof Model) $ids = (array) $ids->getKey(); + + $query = $this->newPivotQuery(); + + // If associated IDs were passed to the method we will only delete those + // associations, otherwise all of the association ties will be broken. + // We'll return the numbers of affected rows when we do the deletes. + $ids = (array) $ids; + + if (count($ids) > 0) + { + $query->whereIn($this->otherKey, $ids); + } + + if ($touch) $this->touchIfTouching(); + + // Once we have all of the conditions set on the statement, we are ready + // to run the delete on the pivot table. Then, if the touch parameter + // is true, we will go ahead and touch all related models to sync. + $results = $query->delete(); + + return $results; + } + + /** + * If we're touching the parent model, touch. + * + * @return void + */ + public function touchIfTouching() + { + if ($this->touchingParent()) $this->getParent()->touch(); + + if ($this->getParent()->touches($this->relationName)) $this->touch(); + } + + /** + * Determine if we should touch the parent on sync. + * + * @return bool + */ + protected function touchingParent() + { + return $this->getRelated()->touches($this->guessInverseRelation()); + } + + /** + * Attempt to guess the name of the inverse of the relation. + * + * @return string + */ + protected function guessInverseRelation() + { + return camel_case(str_plural(class_basename($this->getParent()))); + } + + /** + * Create a new query builder for the pivot table. + * + * @return \Illuminate\Database\Query\Builder + */ + protected function newPivotQuery() + { + $query = $this->newPivotStatement(); + + return $query->where($this->foreignKey, $this->parent->getKey()); + } + + /** + * Get a new plain query builder for the pivot table. + * + * @return \Illuminate\Database\Query\Builder + */ + public function newPivotStatement() + { + return $this->query->getQuery()->newQuery()->from($this->table); + } + + /** + * Get a new pivot statement for a given "other" ID. + * + * @param mixed $id + * @return \Illuminate\Database\Query\Builder + */ + public function newPivotStatementForId($id) + { + $pivot = $this->newPivotStatement(); + + $key = $this->parent->getKey(); + + return $pivot->where($this->foreignKey, $key)->where($this->otherKey, $id); + } + + /** + * Create a new pivot model instance. + * + * @param array $attributes + * @param bool $exists + * @return \Illuminate\Database\Eloquent\Relations\Pivot + */ + public function newPivot(array $attributes = array(), $exists = false) + { + $pivot = $this->related->newPivot($this->parent, $attributes, $this->table, $exists); + + return $pivot->setPivotKeys($this->foreignKey, $this->otherKey); + } + + /** + * Create a new existing pivot model instance. + * + * @param array $attributes + * @return \Illuminate\Database\Eloquent\Relations\Pivot + */ + public function newExistingPivot(array $attributes = array()) + { + return $this->newPivot($attributes, true); + } + + /** + * Set the columns on the pivot table to retrieve. + * + * @param array $columns + * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany + */ + public function withPivot($columns) + { + $columns = is_array($columns) ? $columns : func_get_args(); + + $this->pivotColumns = array_merge($this->pivotColumns, $columns); + + return $this; + } + + /** + * Specify that the pivot table has creation and update timestamps. + * + * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany + */ + public function withTimestamps($createdAt = null, $updatedAt = null) + { + return $this->withPivot($createdAt ?: $this->createdAt(), $updatedAt ?: $this->updatedAt()); + } + + /** + * Get the related model's updated at column name. + * + * @return string + */ + public function getRelatedFreshUpdate() + { + return array($this->related->getUpdatedAtColumn() => $this->related->freshTimestamp()); + } + + /** + * Get the key for comparing against the parent key in "has" query. + * + * @return string + */ + public function getHasCompareKey() + { + return $this->getForeignKey(); + } + + /** + * Get the fully qualified foreign key for the relation. + * + * @return string + */ + public function getForeignKey() + { + return $this->table.'.'.$this->foreignKey; + } + + /** + * Get the fully qualified "other key" for the relation. + * + * @return string + */ + public function getOtherKey() + { + return $this->table.'.'.$this->otherKey; + } + + /** + * Get the fully qualified parent key name. + * + * @return string + */ + protected function getQualifiedParentKeyName() + { + return $this->parent->getQualifiedKeyName(); + } + + /** + * Get the intermediate table for the relationship. + * + * @return string + */ + public function getTable() + { + return $this->table; + } + + /** + * Get the relationship name for the relationship. + * + * @return string + */ + public function getRelationName() + { + return $this->relationName; + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/HasMany.php b/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/HasMany.php new file mode 100755 index 0000000..159a658 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/HasMany.php @@ -0,0 +1,47 @@ +query->get(); + } + + /** + * Initialize the relation on a set of models. + * + * @param array $models + * @param string $relation + * @return array + */ + public function initRelation(array $models, $relation) + { + foreach ($models as $model) + { + $model->setRelation($relation, $this->related->newCollection()); + } + + return $models; + } + + /** + * Match the eagerly loaded results to their parents. + * + * @param array $models + * @param \Illuminate\Database\Eloquent\Collection $results + * @param string $relation + * @return array + */ + public function match(array $models, Collection $results, $relation) + { + return $this->matchMany($models, $results, $relation); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/HasManyThrough.php b/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/HasManyThrough.php new file mode 100755 index 0000000..013df2e --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/HasManyThrough.php @@ -0,0 +1,255 @@ +firstKey = $firstKey; + $this->secondKey = $secondKey; + $this->farParent = $farParent; + + parent::__construct($query, $parent); + } + + /** + * Set the base constraints on the relation query. + * + * @return void + */ + public function addConstraints() + { + $parentTable = $this->parent->getTable(); + + $this->setJoin(); + + if (static::$constraints) + { + $this->query->where($parentTable.'.'.$this->firstKey, '=', $this->farParent->getKey()); + } + } + + /** + * Add the constraints for a relationship count query. + * + * @param \Illuminate\Database\Eloquent\Builder $query + * @param \Illuminate\Database\Eloquent\Builder $parent + * @return \Illuminate\Database\Eloquent\Builder + */ + public function getRelationCountQuery(Builder $query, Builder $parent) + { + $parentTable = $this->parent->getTable(); + + $this->setJoin($query); + + $query->select(new Expression('count(*)')); + + $key = $this->wrap($parentTable.'.'.$this->firstKey); + + return $query->where($this->getHasCompareKey(), '=', new Expression($key)); + } + + /** + * Set the join clause on the query. + * + * @param \Illuminate\Database\Eloquent\Builder|null $query + * @return void + */ + protected function setJoin(Builder $query = null) + { + $query = $query ?: $this->query; + + $foreignKey = $this->related->getTable().'.'.$this->secondKey; + + $query->join($this->parent->getTable(), $this->getQualifiedParentKeyName(), '=', $foreignKey); + } + + /** + * Set the constraints for an eager load of the relation. + * + * @param array $models + * @return void + */ + public function addEagerConstraints(array $models) + { + $table = $this->parent->getTable(); + + $this->query->whereIn($table.'.'.$this->firstKey, $this->getKeys($models)); + } + + /** + * Initialize the relation on a set of models. + * + * @param array $models + * @param string $relation + * @return array + */ + public function initRelation(array $models, $relation) + { + foreach ($models as $model) + { + $model->setRelation($relation, $this->related->newCollection()); + } + + return $models; + } + + /** + * Match the eagerly loaded results to their parents. + * + * @param array $models + * @param \Illuminate\Database\Eloquent\Collection $results + * @param string $relation + * @return array + */ + public function match(array $models, Collection $results, $relation) + { + $dictionary = $this->buildDictionary($results); + + // Once we have the dictionary we can simply spin through the parent models to + // link them up with their children using the keyed dictionary to make the + // matching very convenient and easy work. Then we'll just return them. + foreach ($models as $model) + { + $key = $model->getKey(); + + if (isset($dictionary[$key])) + { + $value = $this->related->newCollection($dictionary[$key]); + + $model->setRelation($relation, $value); + } + } + + return $models; + } + + /** + * Build model dictionary keyed by the relation's foreign key. + * + * @param \Illuminate\Database\Eloquent\Collection $results + * @return array + */ + protected function buildDictionary(Collection $results) + { + $dictionary = array(); + + $foreign = $this->farParent->getForeignKey(); + + // First we will create a dictionary of models keyed by the foreign key of the + // relationship as this will allow us to quickly access all of the related + // models without having to do nested looping which will be quite slow. + foreach ($results as $result) + { + $dictionary[$result->{$foreign}][] = $result; + } + + return $dictionary; + } + + /** + * Get the results of the relationship. + * + * @return mixed + */ + public function getResults() + { + return $this->get(); + } + + /** + * Execute the query as a "select" statement. + * + * @param array $columns + * @return \Illuminate\Database\Eloquent\Collection + */ + public function get($columns = array('*')) + { + // First we'll add the proper select columns onto the query so it is run with + // the proper columns. Then, we will get the results and hydrate out pivot + // models with the result of those columns as a separate model relation. + $select = $this->getSelectColumns($columns); + + $models = $this->query->addSelect($select)->getModels(); + + // If we actually found models we will also eager load any relationships that + // have been specified as needing to be eager loaded. This will solve the + // n + 1 query problem for the developer and also increase performance. + if (count($models) > 0) + { + $models = $this->query->eagerLoadRelations($models); + } + + return $this->related->newCollection($models); + } + + /** + * Set the select clause for the relation query. + * + * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany + */ + protected function getSelectColumns(array $columns = array('*')) + { + if ($columns == array('*')) + { + $columns = array($this->related->getTable().'.*'); + } + + return array_merge($columns, array($this->parent->getTable().'.'.$this->firstKey)); + } + + /** + * Get the key name of the parent model. + * + * @return string + */ + protected function getQualifiedParentKeyName() + { + return $this->parent->getQualifiedKeyName(); + } + + /** + * Get the key for comparing against the parent key in "has" query. + * + * @return string + */ + public function getHasCompareKey() + { + return $this->farParent->getQualifiedKeyName(); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/HasOne.php b/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/HasOne.php new file mode 100755 index 0000000..fd0f9a0 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/HasOne.php @@ -0,0 +1,47 @@ +query->first(); + } + + /** + * Initialize the relation on a set of models. + * + * @param array $models + * @param string $relation + * @return array + */ + public function initRelation(array $models, $relation) + { + foreach ($models as $model) + { + $model->setRelation($relation, null); + } + + return $models; + } + + /** + * Match the eagerly loaded results to their parents. + * + * @param array $models + * @param \Illuminate\Database\Eloquent\Collection $results + * @param string $relation + * @return array + */ + public function match(array $models, Collection $results, $relation) + { + return $this->matchOne($models, $results, $relation); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/HasOneOrMany.php b/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/HasOneOrMany.php new file mode 100755 index 0000000..c3b0ba7 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/HasOneOrMany.php @@ -0,0 +1,294 @@ +localKey = $localKey; + $this->foreignKey = $foreignKey; + + parent::__construct($query, $parent); + } + + /** + * Set the base constraints on the relation query. + * + * @return void + */ + public function addConstraints() + { + if (static::$constraints) + { + $this->query->where($this->foreignKey, '=', $this->getParentKey()); + } + } + + /** + * Set the constraints for an eager load of the relation. + * + * @param array $models + * @return void + */ + public function addEagerConstraints(array $models) + { + $this->query->whereIn($this->foreignKey, $this->getKeys($models, $this->localKey)); + } + + /** + * Match the eagerly loaded results to their single parents. + * + * @param array $models + * @param \Illuminate\Database\Eloquent\Collection $results + * @param string $relation + * @return array + */ + public function matchOne(array $models, Collection $results, $relation) + { + return $this->matchOneOrMany($models, $results, $relation, 'one'); + } + + /** + * Match the eagerly loaded results to their many parents. + * + * @param array $models + * @param \Illuminate\Database\Eloquent\Collection $results + * @param string $relation + * @return array + */ + public function matchMany(array $models, Collection $results, $relation) + { + return $this->matchOneOrMany($models, $results, $relation, 'many'); + } + + /** + * Match the eagerly loaded results to their many parents. + * + * @param array $models + * @param \Illuminate\Database\Eloquent\Collection $results + * @param string $relation + * @param string $type + * @return array + */ + protected function matchOneOrMany(array $models, Collection $results, $relation, $type) + { + $dictionary = $this->buildDictionary($results); + + // Once we have the dictionary we can simply spin through the parent models to + // link them up with their children using the keyed dictionary to make the + // matching very convenient and easy work. Then we'll just return them. + foreach ($models as $model) + { + $key = $model->getAttribute($this->localKey); + + if (isset($dictionary[$key])) + { + $value = $this->getRelationValue($dictionary, $key, $type); + + $model->setRelation($relation, $value); + } + } + + return $models; + } + + /** + * Get the value of a relationship by one or many type. + * + * @param array $dictionary + * @param string $key + * @param string $type + * @return mixed + */ + protected function getRelationValue(array $dictionary, $key, $type) + { + $value = $dictionary[$key]; + + return $type == 'one' ? reset($value) : $this->related->newCollection($value); + } + + /** + * Build model dictionary keyed by the relation's foreign key. + * + * @param \Illuminate\Database\Eloquent\Collection $results + * @return array + */ + protected function buildDictionary(Collection $results) + { + $dictionary = array(); + + $foreign = $this->getPlainForeignKey(); + + // First we will create a dictionary of models keyed by the foreign key of the + // relationship as this will allow us to quickly access all of the related + // models without having to do nested looping which will be quite slow. + foreach ($results as $result) + { + $dictionary[$result->{$foreign}][] = $result; + } + + return $dictionary; + } + + /** + * Attach a model instance to the parent model. + * + * @param \Illuminate\Database\Eloquent\Model $model + * @return \Illuminate\Database\Eloquent\Model + */ + public function save(Model $model) + { + $model->setAttribute($this->getPlainForeignKey(), $this->getParentKey()); + + return $model->save() ? $model : false; + } + + /** + * Attach an array of models to the parent instance. + * + * @param array $models + * @return array + */ + public function saveMany(array $models) + { + array_walk($models, array($this, 'save')); + + return $models; + } + + /** + * Create a new instance of the related model. + * + * @param array $attributes + * @return \Illuminate\Database\Eloquent\Model + */ + public function create(array $attributes) + { + $foreign = array( + $this->getPlainForeignKey() => $this->getParentKey(), + ); + + // Here we will set the raw attributes to avoid hitting the "fill" method so + // that we do not have to worry about a mass accessor rules blocking sets + // on the models. Otherwise, some of these attributes will not get set. + $instance = $this->related->newInstance(); + + $instance->setRawAttributes(array_merge($attributes, $foreign)); + + $instance->save(); + + return $instance; + } + + /** + * Create an array of new instances of the related model. + * + * @param array $records + * @return array + */ + public function createMany(array $records) + { + $instances = array(); + + foreach ($records as $record) + { + $instances[] = $this->create($record); + } + + return $instances; + } + + /** + * Perform an update on all the related models. + * + * @param array $attributes + * @return int + */ + public function update(array $attributes) + { + if ($this->related->usesTimestamps()) + { + $attributes[$this->relatedUpdatedAt()] = $this->related->freshTimestamp(); + } + + return $this->query->update($attributes); + } + + /** + * Get the key for comparing against the parent key in "has" query. + * + * @return string + */ + public function getHasCompareKey() + { + return $this->getForeignKey(); + } + + /** + * Get the foreign key for the relationship. + * + * @return string + */ + public function getForeignKey() + { + return $this->foreignKey; + } + + /** + * Get the plain foreign key. + * + * @return string + */ + public function getPlainForeignKey() + { + $segments = explode('.', $this->getForeignKey()); + + return $segments[count($segments) - 1]; + } + + /** + * Get the key value of the paren's local key. + * + * @return mixed + */ + public function getParentKey() + { + return $this->parent->getAttribute($this->localKey); + } + + /** + * Get the fully qualified parent key name. + * + * @return string + */ + public function getQualifiedParentKeyName() + { + return $this->parent->getTable().'.'.$this->localKey; + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/MorphMany.php b/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/MorphMany.php new file mode 100755 index 0000000..1abdf37 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/MorphMany.php @@ -0,0 +1,47 @@ +query->get(); + } + + /** + * Initialize the relation on a set of models. + * + * @param array $models + * @param string $relation + * @return array + */ + public function initRelation(array $models, $relation) + { + foreach ($models as $model) + { + $model->setRelation($relation, $this->related->newCollection()); + } + + return $models; + } + + /** + * Match the eagerly loaded results to their parents. + * + * @param array $models + * @param \Illuminate\Database\Eloquent\Collection $results + * @param string $relation + * @return array + */ + public function match(array $models, Collection $results, $relation) + { + return $this->matchMany($models, $results, $relation); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/MorphOne.php b/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/MorphOne.php new file mode 100755 index 0000000..fdebc24 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/MorphOne.php @@ -0,0 +1,47 @@ +query->first(); + } + + /** + * Initialize the relation on a set of models. + * + * @param array $models + * @param string $relation + * @return array + */ + public function initRelation(array $models, $relation) + { + foreach ($models as $model) + { + $model->setRelation($relation, null); + } + + return $models; + } + + /** + * Match the eagerly loaded results to their parents. + * + * @param array $models + * @param \Illuminate\Database\Eloquent\Collection $results + * @param string $relation + * @return array + */ + public function match(array $models, Collection $results, $relation) + { + return $this->matchOne($models, $results, $relation); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/MorphOneOrMany.php b/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/MorphOneOrMany.php new file mode 100755 index 0000000..a9c28bd --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/MorphOneOrMany.php @@ -0,0 +1,163 @@ +morphType = $type; + + $this->morphClass = $parent->getMorphClass(); + + parent::__construct($query, $parent, $id, $localKey); + } + + /** + * Set the base constraints on the relation query. + * + * @return void + */ + public function addConstraints() + { + if (static::$constraints) + { + parent::addConstraints(); + + $this->query->where($this->morphType, $this->morphClass); + } + } + + /** + * Add the constraints for a relationship count query. + * + * @param \Illuminate\Database\Eloquent\Builder $query + * @param \Illuminate\Database\Eloquent\Builder $parent + * @return \Illuminate\Database\Eloquent\Builder + */ + public function getRelationCountQuery(Builder $query, Builder $parent) + { + $query = parent::getRelationCountQuery($query, $parent); + + return $query->where($this->morphType, $this->morphClass); + } + + /** + * Set the constraints for an eager load of the relation. + * + * @param array $models + * @return void + */ + public function addEagerConstraints(array $models) + { + parent::addEagerConstraints($models); + + $this->query->where($this->morphType, $this->morphClass); + } + + /** + * Attach a model instance to the parent model. + * + * @param \Illuminate\Database\Eloquent\Model $model + * @return \Illuminate\Database\Eloquent\Model + */ + public function save(Model $model) + { + $model->setAttribute($this->getPlainMorphType(), $this->morphClass); + + return parent::save($model); + } + + /** + * Create a new instance of the related model. + * + * @param array $attributes + * @return \Illuminate\Database\Eloquent\Model + */ + public function create(array $attributes) + { + $foreign = $this->getForeignAttributesForCreate(); + + // When saving a polymorphic relationship, we need to set not only the foreign + // key, but also the foreign key type, which is typically the class name of + // the parent model. This makes the polymorphic item unique in the table. + $attributes = array_merge($attributes, $foreign); + + $instance = $this->related->newInstance($attributes); + + $instance->save(); + + return $instance; + } + + /** + * Get the foreign ID and type for creating a related model. + * + * @return array + */ + protected function getForeignAttributesForCreate() + { + $foreign = array($this->getPlainForeignKey() => $this->getParentKey()); + + $foreign[last(explode('.', $this->morphType))] = $this->morphClass; + + return $foreign; + } + + /** + * Get the foreign key "type" name. + * + * @return string + */ + public function getMorphType() + { + return $this->morphType; + } + + /** + * Get the plain morph type name without the table. + * + * @return string + */ + public function getPlainMorphType() + { + return last(explode('.', $this->morphType)); + } + + /** + * Get the class name of the parent model. + * + * @return string + */ + public function getMorphClass() + { + return $this->morphClass; + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/MorphPivot.php b/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/MorphPivot.php new file mode 100755 index 0000000..7daa0fb --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/MorphPivot.php @@ -0,0 +1,47 @@ +where($this->morphType, $this->getAttribute($this->morphType)); + + return parent::setKeysForSaveQuery($query); + } + + /** + * Delete the pivot model record from the database. + * + * @return int + */ + public function delete() + { + $query = $this->getDeleteQuery(); + + $query->where($this->morphType, $this->getAttribute($this->morphType)); + + return $query->delete(); + } + + /** + * Set the morph type for the pivot. + * + * @param string $morphType + * @return \Illuminate\Database\Eloquent\Relations\MorphPivot + */ + public function setMorphType($morphType) + { + $this->morphType = $morphType; + + return $this; + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/MorphTo.php b/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/MorphTo.php new file mode 100755 index 0000000..122d478 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/MorphTo.php @@ -0,0 +1,196 @@ +morphType = $type; + + parent::__construct($query, $parent, $foreignKey, $otherKey, $relation); + } + + /** + * Set the constraints for an eager load of the relation. + * + * @param array $models + * @return void + */ + public function addEagerConstraints(array $models) + { + $this->buildDictionary($this->models = Collection::make($models)); + } + + /** + * Build a dictionary with the models. + * + * @param \Illuminate\Database\Eloquent\Models $models + * @return void + */ + protected function buildDictionary(Collection $models) + { + foreach ($models as $model) + { + if ($model->{$this->morphType}) + { + $this->dictionary[$model->{$this->morphType}][$model->{$this->foreignKey}][] = $model; + } + } + } + + /** + * Match the eagerly loaded results to their parents. + * + * @param array $models + * @param \Illuminate\Database\Eloquent\Collection $results + * @param string $relation + * @return array + */ + public function match(array $models, Collection $results, $relation) + { + return $models; + } + + /** + * Associate the model instance to the given parent. + * + * @param \Illuminate\Database\Eloquent\Model $model + * @return \Illuminate\Database\Eloquent\Model + */ + public function associate(Model $model) + { + $this->parent->setAttribute($this->foreignKey, $model->getKey()); + + $this->parent->setAttribute($this->morphType, get_class($model)); + + return $this->parent->setRelation($this->relation, $model); + } + + /** + * Get the results of the relationship. + * + * Called via eager load method of Eloquent query builder. + * + * @return mixed + */ + public function getEager() + { + foreach (array_keys($this->dictionary) as $type) + { + $this->matchToMorphParents($type, $this->getResultsByType($type)); + } + + return $this->models; + } + + /** + * Match the results for a given type to their parents. + * + * @param string $type + * @param \Illuminate\Database\Eloquent\Collection $results + * @return void + */ + protected function matchToMorphParents($type, Collection $results) + { + foreach ($results as $result) + { + if (isset($this->dictionary[$type][$result->getKey()])) + { + foreach ($this->dictionary[$type][$result->getKey()] as $model) + { + $model->setRelation($this->relation, $result); + } + } + } + } + + /** + * Get all of the relation results for a type. + * + * @param string $type + * @return \Illuminate\Database\Eloquent\Collection + */ + protected function getResultsByType($type) + { + $instance = $this->createModelByType($type); + + $key = $instance->getKeyName(); + + return $instance->whereIn($key, $this->gatherKeysByType($type)->all())->get(); + } + + /** + * Gather all of the foreign keys for a given type. + * + * @param string $type + * @return array + */ + protected function gatherKeysByType($type) + { + $foreign = $this->foreignKey; + + return BaseCollection::make($this->dictionary[$type])->map(function($models) use ($foreign) + { + return head($models)->{$foreign}; + + })->unique(); + } + + /** + * Create a new model instance by type. + * + * @param string $type + * @return \Illuminate\Database\Eloquent\Model + */ + public function createModelByType($type) + { + return new $type; + } + + /** + * Get the dictionary used by the relationship. + * + * @return array + */ + public function getDictionary() + { + return $this->dictionary; + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/MorphToMany.php b/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/MorphToMany.php new file mode 100755 index 0000000..6d8eeb1 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/MorphToMany.php @@ -0,0 +1,158 @@ +inverse = $inverse; + $this->morphType = $name.'_type'; + $this->morphClass = $inverse ? get_class($query->getModel()) : get_class($parent); + + parent::__construct($query, $parent, $table, $foreignKey, $otherKey, $relationName); + } + + /** + * Set the where clause for the relation query. + * + * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany + */ + protected function setWhere() + { + parent::setWhere(); + + $this->query->where($this->table.'.'.$this->morphType, $this->morphClass); + + return $this; + } + + /** + * Add the constraints for a relationship count query. + * + * @param \Illuminate\Database\Eloquent\Builder $query + * @param \Illuminate\Database\Eloquent\Builder $parent + * @return \Illuminate\Database\Eloquent\Builder + */ + public function getRelationCountQuery(Builder $query, Builder $parent) + { + $query = parent::getRelationCountQuery($query, $parent); + + return $query->where($this->table.'.'.$this->morphType, $this->morphClass); + } + + /** + * Set the constraints for an eager load of the relation. + * + * @param array $models + * @return void + */ + public function addEagerConstraints(array $models) + { + parent::addEagerConstraints($models); + + $this->query->where($this->table.'.'.$this->morphType, $this->morphClass); + } + + /** + * Create a new pivot attachment record. + * + * @param int $id + * @param bool $timed + * @return array + */ + protected function createAttachRecord($id, $timed) + { + $record = parent::createAttachRecord($id, $timed); + + return array_add($record, $this->morphType, $this->morphClass); + } + + /** + * Create a new query builder for the pivot table. + * + * @return \Illuminate\Database\Query\Builder + */ + protected function newPivotQuery() + { + $query = parent::newPivotQuery(); + + return $query->where($this->morphType, $this->morphClass); + } + + /** + * Create a new pivot model instance. + * + * @param array $attributes + * @param bool $exists + * @return \Illuminate\Database\Eloquent\Relations\Pivot + */ + public function newPivot(array $attributes = array(), $exists = false) + { + $pivot = new MorphPivot($this->parent, $attributes, $this->table, $exists); + + $pivot->setPivotKeys($this->foreignKey, $this->otherKey); + + $pivot->setMorphType($this->morphType); + + return $pivot; + } + + /** + * Get the foreign key "type" name. + * + * @return string + */ + public function getMorphType() + { + return $this->morphType; + } + + /** + * Get the class name of the parent model. + * + * @return string + */ + public function getMorphClass() + { + return $this->morphClass; + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/Pivot.php b/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/Pivot.php new file mode 100755 index 0000000..2b01297 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/Pivot.php @@ -0,0 +1,171 @@ +setRawAttributes($attributes); + + $this->setTable($table); + + $this->setConnection($parent->getConnectionName()); + + // We store off the parent instance so we will access the timestamp column names + // for the model, since the pivot model timestamps aren't easily configurable + // from the developer's point of view. We can use the parents to get these. + $this->parent = $parent; + + $this->exists = $exists; + + $this->timestamps = $this->hasTimestampAttributes(); + } + + /** + * Set the keys for a save update query. + * + * @param \Illuminate\Database\Eloquent\Builder + * @return \Illuminate\Database\Eloquent\Builder + */ + protected function setKeysForSaveQuery(Builder $query) + { + $query->where($this->foreignKey, $this->getAttribute($this->foreignKey)); + + return $query->where($this->otherKey, $this->getAttribute($this->otherKey)); + } + + /** + * Delete the pivot model record from the database. + * + * @return int + */ + public function delete() + { + return $this->getDeleteQuery()->delete(); + } + + /** + * Get the query builder for a delete operation on the pivot. + * + * @return \Illuminate\Database\Eloquent\Builder + */ + protected function getDeleteQuery() + { + $foreign = $this->getAttribute($this->foreignKey); + + $query = $this->newQuery()->where($this->foreignKey, $foreign); + + return $query->where($this->otherKey, $this->getAttribute($this->otherKey)); + } + + /** + * Get the foreign key column name. + * + * @return string + */ + public function getForeignKey() + { + return $this->foreignKey; + } + + /** + * Get the "other key" column name. + * + * @return string + */ + public function getOtherKey() + { + return $this->otherKey; + } + + /** + * Set the key names for the pivot model instance. + * + * @param string $foreignKey + * @param string $otherKey + * @return \Illuminate\Database\Eloquent\Relations\Pivot + */ + public function setPivotKeys($foreignKey, $otherKey) + { + $this->foreignKey = $foreignKey; + + $this->otherKey = $otherKey; + + return $this; + } + + /** + * Determine if the pivot model has timestamp attributes. + * + * @return bool + */ + public function hasTimestampAttributes() + { + return array_key_exists($this->getCreatedAtColumn(), $this->attributes); + } + + /** + * Get the name of the "created at" column. + * + * @return string + */ + public function getCreatedAtColumn() + { + return $this->parent->getCreatedAtColumn(); + } + + /** + * Get the name of the "updated at" column. + * + * @return string + */ + public function getUpdatedAtColumn() + { + return $this->parent->getUpdatedAtColumn(); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/Relation.php b/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/Relation.php new file mode 100755 index 0000000..9739ddd --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/Relation.php @@ -0,0 +1,298 @@ +query = $query; + $this->parent = $parent; + $this->related = $query->getModel(); + + $this->addConstraints(); + } + + /** + * Set the base constraints on the relation query. + * + * @return void + */ + abstract public function addConstraints(); + + /** + * Set the constraints for an eager load of the relation. + * + * @param array $models + * @return void + */ + abstract public function addEagerConstraints(array $models); + + /** + * Initialize the relation on a set of models. + * + * @param array $models + * @param string $relation + * @return array + */ + abstract public function initRelation(array $models, $relation); + + /** + * Match the eagerly loaded results to their parents. + * + * @param array $models + * @param \Illuminate\Database\Eloquent\Collection $results + * @param string $relation + * @return array + */ + abstract public function match(array $models, Collection $results, $relation); + + /** + * Get the results of the relationship. + * + * @return mixed + */ + abstract public function getResults(); + + /** + * Get the relationship for eager loading. + * + * @return \Illuminate\Database\Eloquent\Collection + */ + public function getEager() + { + return $this->get(); + } + + /** + * Touch all of the related models for the relationship. + * + * @return void + */ + public function touch() + { + $column = $this->getRelated()->getUpdatedAtColumn(); + + $this->rawUpdate(array($column => $this->getRelated()->freshTimestampString())); + } + + /** + * Restore all of the soft deleted related models. + * + * @return int + */ + public function restore() + { + return $this->query->withTrashed()->restore(); + } + + /** + * Run a raw update against the base query. + * + * @param array $attributes + * @return int + */ + public function rawUpdate(array $attributes = array()) + { + return $this->query->update($attributes); + } + + /** + * Add the constraints for a relationship count query. + * + * @param \Illuminate\Database\Eloquent\Builder $query + * @param \Illuminate\Database\Eloquent\Builder $parent + * @return \Illuminate\Database\Eloquent\Builder + */ + public function getRelationCountQuery(Builder $query, Builder $parent) + { + $query->select(new Expression('count(*)')); + + $key = $this->wrap($this->getQualifiedParentKeyName()); + + return $query->where($this->getHasCompareKey(), '=', new Expression($key)); + } + + /** + * Run a callback with constraints disabled on the relation. + * + * @param \Closure $callback + * @return mixed + */ + public static function noConstraints(Closure $callback) + { + static::$constraints = false; + + // When resetting the relation where clause, we want to shift the first element + // off of the bindings, leaving only the constraints that the developers put + // as "extra" on the relationships, and not original relation constraints. + $results = call_user_func($callback); + + static::$constraints = true; + + return $results; + } + + /** + * Get all of the primary keys for an array of models. + * + * @param array $models + * @param string $key + * @return array + */ + protected function getKeys(array $models, $key = null) + { + return array_values(array_map(function($value) use ($key) + { + return $key ? $value->getAttribute($key) : $value->getKey(); + + }, $models)); + } + + /** + * Get the underlying query for the relation. + * + * @return \Illuminate\Database\Eloquent\Builder + */ + public function getQuery() + { + return $this->query; + } + + /** + * Get the base query builder driving the Eloquent builder. + * + * @return \Illuminate\Database\Query\Builder + */ + public function getBaseQuery() + { + return $this->query->getQuery(); + } + + /** + * Get the parent model of the relation. + * + * @return \Illuminate\Database\Eloquent\Model + */ + public function getParent() + { + return $this->parent; + } + + /** + * Get the fully qualified parent key name. + * + * @return string + */ + protected function getQualifiedParentKeyName() + { + return $this->parent->getQualifiedKeyName(); + } + + /** + * Get the related model of the relation. + * + * @return \Illuminate\Database\Eloquent\Model + */ + public function getRelated() + { + return $this->related; + } + + /** + * Get the name of the "created at" column. + * + * @return string + */ + public function createdAt() + { + return $this->parent->getCreatedAtColumn(); + } + + /** + * Get the name of the "updated at" column. + * + * @return string + */ + public function updatedAt() + { + return $this->parent->getUpdatedAtColumn(); + } + + /** + * Get the name of the related model's "updated at" column. + * + * @return string + */ + public function relatedUpdatedAt() + { + return $this->related->getUpdatedAtColumn(); + } + + /** + * Wrap the given value with the parent query's grammar. + * + * @param string $value + * @return string + */ + public function wrap($value) + { + return $this->parent->getQuery()->getGrammar()->wrap($value); + } + + /** + * Handle dynamic method calls to the relationship. + * + * @param string $method + * @param array $parameters + * @return mixed + */ + public function __call($method, $parameters) + { + $result = call_user_func_array(array($this->query, $method), $parameters); + + if ($result === $this->query) return $this; + + return $result; + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Database/Grammar.php b/vendor/laravel/framework/src/Illuminate/Database/Grammar.php new file mode 100755 index 0000000..c67c495 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Database/Grammar.php @@ -0,0 +1,179 @@ +isExpression($table)) return $this->getValue($table); + + return $this->wrap($this->tablePrefix.$table); + } + + /** + * Wrap a value in keyword identifiers. + * + * @param string $value + * @return string + */ + public function wrap($value) + { + if ($this->isExpression($value)) return $this->getValue($value); + + // If the value being wrapped has a column alias we will need to separate out + // the pieces so we can wrap each of the segments of the expression on it + // own, and then joins them both back together with the "as" connector. + if (strpos(strtolower($value), ' as ') !== false) + { + $segments = explode(' ', $value); + + return $this->wrap($segments[0]).' as '.$this->wrap($segments[2]); + } + + $wrapped = array(); + + $segments = explode('.', $value); + + // If the value is not an aliased table expression, we'll just wrap it like + // normal, so if there is more than one segment, we will wrap the first + // segments as if it was a table and the rest as just regular values. + foreach ($segments as $key => $segment) + { + if ($key == 0 && count($segments) > 1) + { + $wrapped[] = $this->wrapTable($segment); + } + else + { + $wrapped[] = $this->wrapValue($segment); + } + } + + return implode('.', $wrapped); + } + + /** + * Wrap a single string in keyword identifiers. + * + * @param string $value + * @return string + */ + protected function wrapValue($value) + { + if ($value === '*') return $value; + + return '"'.str_replace('"', '""', $value).'"'; + } + + /** + * Convert an array of column names into a delimited string. + * + * @param array $columns + * @return string + */ + public function columnize(array $columns) + { + return implode(', ', array_map(array($this, 'wrap'), $columns)); + } + + /** + * Create query parameter place-holders for an array. + * + * @param array $values + * @return string + */ + public function parameterize(array $values) + { + return implode(', ', array_map(array($this, 'parameter'), $values)); + } + + /** + * Get the appropriate query parameter place-holder for a value. + * + * @param mixed $value + * @return string + */ + public function parameter($value) + { + return $this->isExpression($value) ? $this->getValue($value) : '?'; + } + + /** + * Get the value of a raw expression. + * + * @param \Illuminate\Database\Query\Expression $expression + * @return string + */ + public function getValue($expression) + { + return $expression->getValue(); + } + + /** + * Determine if the given value is a raw expression. + * + * @param mixed $value + * @return bool + */ + public function isExpression($value) + { + return $value instanceof Query\Expression; + } + + /** + * Get the format for database stored dates. + * + * @return string + */ + public function getDateFormat() + { + return 'Y-m-d H:i:s'; + } + + /** + * Get the grammar's table prefix. + * + * @return string + */ + public function getTablePrefix() + { + return $this->tablePrefix; + } + + /** + * Set the grammar's table prefix. + * + * @param string $prefix + * @return \Illuminate\Database\Grammar + */ + public function setTablePrefix($prefix) + { + $this->tablePrefix = $prefix; + + return $this; + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Database/MigrationServiceProvider.php b/vendor/laravel/framework/src/Illuminate/Database/MigrationServiceProvider.php new file mode 100755 index 0000000..797d7fb --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Database/MigrationServiceProvider.php @@ -0,0 +1,207 @@ +registerRepository(); + + // Once we have registered the migrator instance we will go ahead and register + // all of the migration related commands that are used by the "Artisan" CLI + // so that they may be easily accessed for registering with the consoles. + $this->registerMigrator(); + + $this->registerCommands(); + } + + /** + * Register the migration repository service. + * + * @return void + */ + protected function registerRepository() + { + $this->app->bindShared('migration.repository', function($app) + { + $table = $app['config']['database.migrations']; + + return new DatabaseMigrationRepository($app['db'], $table); + }); + } + + /** + * Register the migrator service. + * + * @return void + */ + protected function registerMigrator() + { + // The migrator is responsible for actually running and rollback the migration + // files in the application. We'll pass in our database connection resolver + // so the migrator can resolve any of these connections when it needs to. + $this->app->bindShared('migrator', function($app) + { + $repository = $app['migration.repository']; + + return new Migrator($repository, $app['db'], $app['files']); + }); + } + + /** + * Register all of the migration commands. + * + * @return void + */ + protected function registerCommands() + { + $commands = array('Migrate', 'Rollback', 'Reset', 'Refresh', 'Install', 'Make'); + + // We'll simply spin through the list of commands that are migration related + // and register each one of them with an application container. They will + // be resolved in the Artisan start file and registered on the console. + foreach ($commands as $command) + { + $this->{'register'.$command.'Command'}(); + } + + // Once the commands are registered in the application IoC container we will + // register them with the Artisan start event so that these are available + // when the Artisan application actually starts up and is getting used. + $this->commands( + 'command.migrate', 'command.migrate.make', + 'command.migrate.install', 'command.migrate.rollback', + 'command.migrate.reset', 'command.migrate.refresh' + ); + } + + /** + * Register the "migrate" migration command. + * + * @return void + */ + protected function registerMigrateCommand() + { + $this->app->bindShared('command.migrate', function($app) + { + $packagePath = $app['path.base'].'/vendor'; + + return new MigrateCommand($app['migrator'], $packagePath); + }); + } + + /** + * Register the "rollback" migration command. + * + * @return void + */ + protected function registerRollbackCommand() + { + $this->app->bindShared('command.migrate.rollback', function($app) + { + return new RollbackCommand($app['migrator']); + }); + } + + /** + * Register the "reset" migration command. + * + * @return void + */ + protected function registerResetCommand() + { + $this->app->bindShared('command.migrate.reset', function($app) + { + return new ResetCommand($app['migrator']); + }); + } + + /** + * Register the "refresh" migration command. + * + * @return void + */ + protected function registerRefreshCommand() + { + $this->app->bindShared('command.migrate.refresh', function($app) + { + return new RefreshCommand; + }); + } + + /** + * Register the "install" migration command. + * + * @return void + */ + protected function registerInstallCommand() + { + $this->app->bindShared('command.migrate.install', function($app) + { + return new InstallCommand($app['migration.repository']); + }); + } + + /** + * Register the "install" migration command. + * + * @return void + */ + protected function registerMakeCommand() + { + $this->app->bindShared('migration.creator', function($app) + { + return new MigrationCreator($app['files']); + }); + + $this->app->bindShared('command.migrate.make', function($app) + { + // Once we have the migration creator registered, we will create the command + // and inject the creator. The creator is responsible for the actual file + // creation of the migrations, and may be extended by these developers. + $creator = $app['migration.creator']; + + $packagePath = $app['path.base'].'/vendor'; + + return new MigrateMakeCommand($creator, $packagePath); + }); + } + + /** + * Get the services provided by the provider. + * + * @return array + */ + public function provides() + { + return array( + 'migrator', 'migration.repository', 'command.migrate', + 'command.migrate.rollback', 'command.migrate.reset', + 'command.migrate.refresh', 'command.migrate.install', + 'migration.creator', 'command.migrate.make', + ); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Database/Migrations/DatabaseMigrationRepository.php b/vendor/laravel/framework/src/Illuminate/Database/Migrations/DatabaseMigrationRepository.php new file mode 100755 index 0000000..8894710 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Database/Migrations/DatabaseMigrationRepository.php @@ -0,0 +1,181 @@ +table = $table; + $this->resolver = $resolver; + } + + /** + * Get the ran migrations. + * + * @return array + */ + public function getRan() + { + return $this->table()->lists('migration'); + } + + /** + * Get the last migration batch. + * + * @return array + */ + public function getLast() + { + $query = $this->table()->where('batch', $this->getLastBatchNumber()); + + return $query->orderBy('migration', 'desc')->get(); + } + + /** + * Log that a migration was run. + * + * @param string $file + * @param int $batch + * @return void + */ + public function log($file, $batch) + { + $record = array('migration' => $file, 'batch' => $batch); + + $this->table()->insert($record); + } + + /** + * Remove a migration from the log. + * + * @param object $migration + * @return void + */ + public function delete($migration) + { + $this->table()->where('migration', $migration->migration)->delete(); + } + + /** + * Get the next migration batch number. + * + * @return int + */ + public function getNextBatchNumber() + { + return $this->getLastBatchNumber() + 1; + } + + /** + * Get the last migration batch number. + * + * @return int + */ + public function getLastBatchNumber() + { + return $this->table()->max('batch'); + } + + /** + * Create the migration repository data store. + * + * @return void + */ + public function createRepository() + { + $schema = $this->getConnection()->getSchemaBuilder(); + + $schema->create($this->table, function($table) + { + // The migrations table is responsible for keeping track of which of the + // migrations have actually run for the application. We'll create the + // table to hold the migration file's path as well as the batch ID. + $table->string('migration'); + + $table->integer('batch'); + }); + } + + /** + * Determine if the migration repository exists. + * + * @return bool + */ + public function repositoryExists() + { + $schema = $this->getConnection()->getSchemaBuilder(); + + return $schema->hasTable($this->table); + } + + /** + * Get a query builder for the migration table. + * + * @return \Illuminate\Database\Query\Builder + */ + protected function table() + { + return $this->getConnection()->table($this->table); + } + + /** + * Get the connection resolver instance. + * + * @return \Illuminate\Database\ConnectionResolverInterface + */ + public function getConnectionResolver() + { + return $this->resolver; + } + + /** + * Resolve the database connection instance. + * + * @return \Illuminate\Database\Connection + */ + public function getConnection() + { + return $this->resolver->connection($this->connection); + } + + /** + * Set the information source to gather data. + * + * @param string $name + * @return void + */ + public function setSource($name) + { + $this->connection = $name; + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migration.php b/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migration.php new file mode 100755 index 0000000..eb75d14 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migration.php @@ -0,0 +1,22 @@ +connection; + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Database/Migrations/MigrationCreator.php b/vendor/laravel/framework/src/Illuminate/Database/Migrations/MigrationCreator.php new file mode 100755 index 0000000..1b6460e --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Database/Migrations/MigrationCreator.php @@ -0,0 +1,171 @@ +files = $files; + } + + /** + * Create a new migration at the given path. + * + * @param string $name + * @param string $path + * @param string $table + * @param bool $create + * @return string + */ + public function create($name, $path, $table = null, $create = false) + { + $path = $this->getPath($name, $path); + + // First we will get the stub file for the migration, which serves as a type + // of template for the migration. Once we have those we will populate the + // various place-holders, save the file, and run the post create event. + $stub = $this->getStub($table, $create); + + $this->files->put($path, $this->populateStub($name, $stub, $table)); + + $this->firePostCreateHooks(); + + return $path; + } + + /** + * Get the migration stub file. + * + * @param string $table + * @return string + */ + protected function getStub($table, $create) + { + if (is_null($table)) + { + return $this->files->get($this->getStubPath().'/blank.stub'); + } + + // We also have stubs for creating new tables and modifying existing tables + // to save the developer some typing when they are creating a new tables + // or modifying existing tables. We'll grab the appropriate stub here. + else + { + $stub = $create ? 'create.stub' : 'update.stub'; + + return $this->files->get($this->getStubPath()."/{$stub}"); + } + } + + /** + * Populate the place-holders in the migration stub. + * + * @param string $name + * @param string $stub + * @param string $table + * @return string + */ + protected function populateStub($name, $stub, $table) + { + $stub = str_replace('{{class}}', studly_case($name), $stub); + + // Here we will replace the table place-holders with the table specified by + // the developer, which is useful for quickly creating a tables creation + // or update migration from the console instead of typing it manually. + if ( ! is_null($table)) + { + $stub = str_replace('{{table}}', $table, $stub); + } + + return $stub; + } + + /** + * Fire the registered post create hooks. + * + * @return void + */ + protected function firePostCreateHooks() + { + foreach ($this->postCreate as $callback) + { + call_user_func($callback); + } + } + + /** + * Register a post migration create hook. + * + * @param Closure $callback + * @return void + */ + public function afterCreate(Closure $callback) + { + $this->postCreate[] = $callback; + } + + /** + * Get the full path name to the migration. + * + * @param string $name + * @param string $path + * @return string + */ + protected function getPath($name, $path) + { + return $path.'/'.$this->getDatePrefix().'_'.$name.'.php'; + } + + /** + * Get the date prefix for the migration. + * + * @return string + */ + protected function getDatePrefix() + { + return date('Y_m_d_His'); + } + + /** + * Get the path to the stubs. + * + * @return string + */ + public function getStubPath() + { + return __DIR__.'/stubs'; + } + + /** + * Get the filesystem instance. + * + * @return \Illuminate\Filesystem\Filesystem + */ + public function getFilesystem() + { + return $this->files; + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Database/Migrations/MigrationRepositoryInterface.php b/vendor/laravel/framework/src/Illuminate/Database/Migrations/MigrationRepositoryInterface.php new file mode 100755 index 0000000..dfafa15 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Database/Migrations/MigrationRepositoryInterface.php @@ -0,0 +1,65 @@ +files = $files; + $this->resolver = $resolver; + $this->repository = $repository; + } + + /** + * Run the outstanding migrations at a given path. + * + * @param string $path + * @param bool $pretend + * @return void + */ + public function run($path, $pretend = false) + { + $this->notes = array(); + + $this->requireFiles($path, $files = $this->getMigrationFiles($path)); + + // Once we grab all of the migration files for the path, we will compare them + // against the migrations that have already been run for this package then + // run each of the outstanding migrations against a database connection. + $ran = $this->repository->getRan(); + + $migrations = array_diff($files, $ran); + + $this->runMigrationList($migrations, $pretend); + } + + /** + * Run an array of migrations. + * + * @param array $migrations + * @param bool $pretend + * @return void + */ + public function runMigrationList($migrations, $pretend = false) + { + // First we will just make sure that there are any migrations to run. If there + // aren't, we will just make a note of it to the developer so they're aware + // that all of the migrations have been run against this database system. + if (count($migrations) == 0) + { + $this->note('Nothing to migrate.'); + + return; + } + + $batch = $this->repository->getNextBatchNumber(); + + // Once we have the array of migrations, we will spin through them and run the + // migrations "up" so the changes are made to the databases. We'll then log + // that the migration was run so we don't repeat it next time we execute. + foreach ($migrations as $file) + { + $this->runUp($file, $batch, $pretend); + } + } + + /** + * Run "up" a migration instance. + * + * @param string $file + * @param int $batch + * @param bool $pretend + * @return void + */ + protected function runUp($file, $batch, $pretend) + { + // First we will resolve a "real" instance of the migration class from this + // migration file name. Once we have the instances we can run the actual + // command such as "up" or "down", or we can just simulate the action. + $migration = $this->resolve($file); + + if ($pretend) + { + return $this->pretendToRun($migration, 'up'); + } + + $migration->up(); + + // Once we have run a migrations class, we will log that it was run in this + // repository so that we don't try to run it next time we do a migration + // in the application. A migration repository keeps the migrate order. + $this->repository->log($file, $batch); + + $this->note("Migrated: $file"); + } + + /** + * Rollback the last migration operation. + * + * @param bool $pretend + * @return int + */ + public function rollback($pretend = false) + { + $this->notes = array(); + + // We want to pull in the last batch of migrations that ran on the previous + // migration operation. We'll then reverse those migrations and run each + // of them "down" to reverse the last migration "operation" which ran. + $migrations = $this->repository->getLast(); + + if (count($migrations) == 0) + { + $this->note('Nothing to rollback.'); + + return count($migrations); + } + + // We need to reverse these migrations so that they are "downed" in reverse + // to what they run on "up". It lets us backtrack through the migrations + // and properly reverse the entire database schema operation that ran. + foreach ($migrations as $migration) + { + $this->runDown((object) $migration, $pretend); + } + + return count($migrations); + } + + /** + * Run "down" a migration instance. + * + * @param object $migration + * @param bool $pretend + * @return void + */ + protected function runDown($migration, $pretend) + { + $file = $migration->migration; + + // First we will get the file name of the migration so we can resolve out an + // instance of the migration. Once we get an instance we can either run a + // pretend execution of the migration or we can run the real migration. + $instance = $this->resolve($file); + + if ($pretend) + { + return $this->pretendToRun($instance, 'down'); + } + + $instance->down(); + + // Once we have successfully run the migration "down" we will remove it from + // the migration repository so it will be considered to have not been run + // by the application then will be able to fire by any later operation. + $this->repository->delete($migration); + + $this->note("Rolled back: $file"); + } + + /** + * Get all of the migration files in a given path. + * + * @param string $path + * @return array + */ + public function getMigrationFiles($path) + { + $files = $this->files->glob($path.'/*_*.php'); + + // Once we have the array of files in the directory we will just remove the + // extension and take the basename of the file which is all we need when + // finding the migrations that haven't been run against the databases. + if ($files === false) return array(); + + $files = array_map(function($file) + { + return str_replace('.php', '', basename($file)); + + }, $files); + + // Once we have all of the formatted file names we will sort them and since + // they all start with a timestamp this should give us the migrations in + // the order they were actually created by the application developers. + sort($files); + + return $files; + } + + /** + * Require in all the migration files in a given path. + * + * @param array $files + * @return void + */ + public function requireFiles($path, array $files) + { + foreach ($files as $file) $this->files->requireOnce($path.'/'.$file.'.php'); + } + + /** + * Pretend to run the migrations. + * + * @param object $migration + * @return void + */ + protected function pretendToRun($migration, $method) + { + foreach ($this->getQueries($migration, $method) as $query) + { + $name = get_class($migration); + + $this->note("{$name}: {$query['query']}"); + } + } + + /** + * Get all of the queries that would be run for a migration. + * + * @param object $migration + * @param string $method + * @return array + */ + protected function getQueries($migration, $method) + { + $connection = $migration->getConnection(); + + // Now that we have the connections we can resolve it and pretend to run the + // queries against the database returning the array of raw SQL statements + // that would get fired against the database system for this migration. + $db = $this->resolveConnection($connection); + + return $db->pretend(function() use ($migration, $method) + { + $migration->$method(); + }); + } + + /** + * Resolve a migration instance from a file. + * + * @param string $file + * @return object + */ + public function resolve($file) + { + $file = implode('_', array_slice(explode('_', $file), 4)); + + $class = studly_case($file); + + return new $class; + } + + /** + * Raise a note event for the migrator. + * + * @param string $message + * @return void + */ + protected function note($message) + { + $this->notes[] = $message; + } + + /** + * Get the notes for the last operation. + * + * @return array + */ + public function getNotes() + { + return $this->notes; + } + + /** + * Resolve the database connection instance. + * + * @return \Illuminate\Database\Connection + */ + public function resolveConnection() + { + return $this->resolver->connection($this->connection); + } + + /** + * Set the default connection name. + * + * @param string $name + * @return void + */ + public function setConnection($name) + { + if ( ! is_null($name)) + { + $this->resolver->setDefaultConnection($name); + } + + $this->repository->setSource($name); + + $this->connection = $name; + } + + /** + * Get the migration repository instance. + * + * @return \Illuminate\Database\Migrations\MigrationRepositoryInterface + */ + public function getRepository() + { + return $this->repository; + } + + /** + * Determine if the migration repository exists. + * + * @return bool + */ + public function repositoryExists() + { + return $this->repository->repositoryExists(); + } + + /** + * Get the file system instance. + * + * @return \Illuminate\Filesystem\Filesystem + */ + public function getFilesystem() + { + return $this->files; + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Database/Migrations/stubs/blank.stub b/vendor/laravel/framework/src/Illuminate/Database/Migrations/stubs/blank.stub new file mode 100755 index 0000000..a711201 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Database/Migrations/stubs/blank.stub @@ -0,0 +1,28 @@ +increments('id'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::drop('{{table}}'); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Database/Migrations/stubs/update.stub b/vendor/laravel/framework/src/Illuminate/Database/Migrations/stubs/update.stub new file mode 100755 index 0000000..cc2c904 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Database/Migrations/stubs/update.stub @@ -0,0 +1,34 @@ +schemaGrammar)) { $this->useDefaultSchemaGrammar(); } + + return new MySqlBuilder($this); + } + + /** + * Get the default query grammar instance. + * + * @return \Illuminate\Database\Query\Grammars\MySqlGrammar + */ + protected function getDefaultQueryGrammar() + { + return $this->withTablePrefix(new QueryGrammar); + } + + /** + * Get the default schema grammar instance. + * + * @return \Illuminate\Database\Schema\Grammars\MySqlGrammar + */ + protected function getDefaultSchemaGrammar() + { + return $this->withTablePrefix(new SchemaGrammar); + } + + /** + * Get the default post processor instance. + * + * @return \Illuminate\Database\Query\Processors\Processor + */ + protected function getDefaultPostProcessor() + { + return new Query\Processors\MySqlProcessor; + } + + /** + * Get the Doctrine DBAL driver. + * + * @return \Doctrine\DBAL\Driver\PDOMySql\Driver + */ + protected function getDoctrineDriver() + { + return new DoctrineDriver; + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Database/PostgresConnection.php b/vendor/laravel/framework/src/Illuminate/Database/PostgresConnection.php new file mode 100755 index 0000000..56b6c4e --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Database/PostgresConnection.php @@ -0,0 +1,50 @@ +withTablePrefix(new QueryGrammar); + } + + /** + * Get the default schema grammar instance. + * + * @return \Illuminate\Database\Schema\Grammars\PostgresGrammar + */ + protected function getDefaultSchemaGrammar() + { + return $this->withTablePrefix(new SchemaGrammar); + } + + /** + * Get the default post processor instance. + * + * @return \Illuminate\Database\Query\Processors\PostgresProcessor + */ + protected function getDefaultPostProcessor() + { + return new PostgresProcessor; + } + + /** + * Get the Doctrine DBAL driver. + * + * @return \Doctrine\DBAL\Driver\PDOPgSql\Driver + */ + protected function getDoctrineDriver() + { + return new DoctrineDriver; + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php b/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php new file mode 100755 index 0000000..66a9365 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php @@ -0,0 +1,1996 @@ +', '<=', '>=', '<>', '!=', + 'like', 'not like', 'between', 'ilike', + '&', '|', '^', '<<', '>>', + ); + + /** + * Create a new query builder instance. + * + * @param \Illuminate\Database\ConnectionInterface $connection + * @param \Illuminate\Database\Query\Grammars\Grammar $grammar + * @param \Illuminate\Database\Query\Processors\Processor $processor + * @return void + */ + public function __construct(ConnectionInterface $connection, + Grammar $grammar, + Processor $processor) + { + $this->grammar = $grammar; + $this->processor = $processor; + $this->connection = $connection; + } + + /** + * Set the columns to be selected. + * + * @param array $columns + * @return \Illuminate\Database\Query\Builder|static + */ + public function select($columns = array('*')) + { + $this->columns = is_array($columns) ? $columns : func_get_args(); + + return $this; + } + + /** + * Add a new "raw" select expression to the query. + * + * @param string $expression + * @return \Illuminate\Database\Query\Builder|static + */ + public function selectRaw($expression) + { + return $this->select(new Expression($expression)); + } + + /** + * Add a new select column to the query. + * + * @param mixed $column + * @return \Illuminate\Database\Query\Builder|static + */ + public function addSelect($column) + { + $column = is_array($column) ? $column : func_get_args(); + + $this->columns = array_merge((array) $this->columns, $column); + + return $this; + } + + /** + * Force the query to only return distinct results. + * + * @return \Illuminate\Database\Query\Builder|static + */ + public function distinct() + { + $this->distinct = true; + + return $this; + } + + /** + * Set the table which the query is targeting. + * + * @param string $table + * @return \Illuminate\Database\Query\Builder|static + */ + public function from($table) + { + $this->from = $table; + + return $this; + } + + /** + * Add a join clause to the query. + * + * @param string $table + * @param string $first + * @param string $operator + * @param string $two + * @param string $type + * @param bool $where + * @return \Illuminate\Database\Query\Builder|static + */ + public function join($table, $one, $operator = null, $two = null, $type = 'inner', $where = false) + { + // If the first "column" of the join is really a Closure instance the developer + // is trying to build a join with a complex "on" clause containing more than + // one condition, so we'll add the join and call a Closure with the query. + if ($one instanceof Closure) + { + $this->joins[] = new JoinClause($this, $type, $table); + + call_user_func($one, end($this->joins)); + } + + // If the column is simply a string, we can assume the join simply has a basic + // "on" clause with a single condition. So we will just build the join with + // this simple join clauses attached to it. There is not a join callback. + else + { + $join = new JoinClause($this, $type, $table); + + $this->joins[] = $join->on( + $one, $operator, $two, 'and', $where + ); + } + + return $this; + } + + /** + * Add a "join where" clause to the query. + * + * @param string $table + * @param string $first + * @param string $operator + * @param string $two + * @param string $type + * @return \Illuminate\Database\Query\Builder|static + */ + public function joinWhere($table, $one, $operator, $two, $type = 'inner') + { + return $this->join($table, $one, $operator, $two, $type, true); + } + + /** + * Add a left join to the query. + * + * @param string $table + * @param string $first + * @param string $operator + * @param string $second + * @return \Illuminate\Database\Query\Builder|static + */ + public function leftJoin($table, $first, $operator = null, $second = null) + { + return $this->join($table, $first, $operator, $second, 'left'); + } + + /** + * Add a "join where" clause to the query. + * + * @param string $table + * @param string $first + * @param string $operator + * @param string $two + * @return \Illuminate\Database\Query\Builder|static + */ + public function leftJoinWhere($table, $one, $operator, $two) + { + return $this->joinWhere($table, $one, $operator, $two, 'left'); + } + + /** + * Add a basic where clause to the query. + * + * @param string $column + * @param string $operator + * @param mixed $value + * @param string $boolean + * @return \Illuminate\Database\Query\Builder|static + * + * @throws \InvalidArgumentException + */ + public function where($column, $operator = null, $value = null, $boolean = 'and') + { + if (func_num_args() == 2) + { + list($value, $operator) = array($operator, '='); + } + elseif ($this->invalidOperatorAndValue($operator, $value)) + { + throw new \InvalidArgumentException("Value must be provided."); + } + + // If the columns is actually a Closure instance, we will assume the developer + // wants to begin a nested where statement which is wrapped in parenthesis. + // We'll add that Closure to the query then return back out immediately. + if ($column instanceof Closure) + { + return $this->whereNested($column, $boolean); + } + + // If the given operator is not found in the list of valid operators we will + // assume that the developer is just short-cutting the '=' operators and + // we will set the operators to '=' and set the values appropriately. + if ( ! in_array(strtolower($operator), $this->operators, true)) + { + list($value, $operator) = array($operator, '='); + } + + // If the value is a Closure, it means the developer is performing an entire + // sub-select within the query and we will need to compile the sub-select + // within the where clause to get the appropriate query record results. + if ($value instanceof Closure) + { + return $this->whereSub($column, $operator, $value, $boolean); + } + + // If the value is "null", we will just assume the developer wants to add a + // where null clause to the query. So, we will allow a short-cut here to + // that method for convenience so the developer doesn't have to check. + if (is_null($value)) + { + return $this->whereNull($column, $boolean, $operator != '='); + } + + // Now that we are working with just a simple query we can put the elements + // in our array and add the query binding to our array of bindings that + // will be bound to each SQL statements when it is finally executed. + $type = 'Basic'; + + $this->wheres[] = compact('type', 'column', 'operator', 'value', 'boolean'); + + if ( ! $value instanceof Expression) + { + $this->bindings[] = $value; + } + + return $this; + } + + /** + * Add an "or where" clause to the query. + * + * @param string $column + * @param string $operator + * @param mixed $value + * @return \Illuminate\Database\Query\Builder|static + */ + public function orWhere($column, $operator = null, $value = null) + { + return $this->where($column, $operator, $value, 'or'); + } + + /** + * Determine if the given operator and value combination is legal. + * + * @param string $operator + * @param mixed $value + * @return bool + */ + protected function invalidOperatorAndValue($operator, $value) + { + $isOperator = in_array($operator, $this->operators); + + return ($isOperator && $operator != '=' && is_null($value)); + } + + /** + * Add a raw where clause to the query. + * + * @param string $sql + * @param array $bindings + * @param string $boolean + * @return \Illuminate\Database\Query\Builder|static + */ + public function whereRaw($sql, array $bindings = array(), $boolean = 'and') + { + $type = 'raw'; + + $this->wheres[] = compact('type', 'sql', 'boolean'); + + $this->bindings = array_merge($this->bindings, $bindings); + + return $this; + } + + /** + * Add a raw or where clause to the query. + * + * @param string $sql + * @param array $bindings + * @return \Illuminate\Database\Query\Builder|static + */ + public function orWhereRaw($sql, array $bindings = array()) + { + return $this->whereRaw($sql, $bindings, 'or'); + } + + /** + * Add a where between statement to the query. + * + * @param string $column + * @param array $values + * @param string $boolean + * @param bool $not + * @return \Illuminate\Database\Query\Builder|static + */ + public function whereBetween($column, array $values, $boolean = 'and', $not = false) + { + $type = 'between'; + + $this->wheres[] = compact('column', 'type', 'boolean', 'not'); + + $this->bindings = array_merge($this->bindings, $values); + + return $this; + } + + /** + * Add an or where between statement to the query. + * + * @param string $column + * @param array $values + * @return \Illuminate\Database\Query\Builder|static + */ + public function orWhereBetween($column, array $values) + { + return $this->whereBetween($column, $values, 'or'); + } + + /** + * Add a where not between statement to the query. + * + * @param string $column + * @param array $values + * @param string $boolean + * @return \Illuminate\Database\Query\Builder|static + */ + public function whereNotBetween($column, array $values, $boolean = 'and') + { + return $this->whereBetween($column, $values, $boolean, true); + } + + /** + * Add an or where not between statement to the query. + * + * @param string $column + * @param array $values + * @return \Illuminate\Database\Query\Builder|static + */ + public function orWhereNotBetween($column, array $values) + { + return $this->whereNotBetween($column, $values, 'or'); + } + + /** + * Add a nested where statement to the query. + * + * @param \Closure $callback + * @param string $boolean + * @return \Illuminate\Database\Query\Builder|static + */ + public function whereNested(Closure $callback, $boolean = 'and') + { + // To handle nested queries we'll actually create a brand new query instance + // and pass it off to the Closure that we have. The Closure can simply do + // do whatever it wants to a query then we will store it for compiling. + $query = $this->newQuery(); + + $query->from($this->from); + + call_user_func($callback, $query); + + return $this->addNestedWhereQuery($query, $boolean); + } + + /** + * Add another query builder as a nested where to the query builder. + * + * @param \Illuminate\Database\Query\Builder|static $query + * @param string $boolean + * @return \Illuminate\Database\Query\Builder|static + */ + public function addNestedWhereQuery($query, $boolean = 'and') + { + if (count($query->wheres)) + { + $type = 'Nested'; + + $this->wheres[] = compact('type', 'query', 'boolean'); + + $this->mergeBindings($query); + } + + return $this; + } + + /** + * Add a full sub-select to the query. + * + * @param string $column + * @param string $operator + * @param \Closure $callback + * @param string $boolean + * @return \Illuminate\Database\Query\Builder|static + */ + protected function whereSub($column, $operator, Closure $callback, $boolean) + { + $type = 'Sub'; + + $query = $this->newQuery(); + + // Once we have the query instance we can simply execute it so it can add all + // of the sub-select's conditions to itself, and then we can cache it off + // in the array of where clauses for the "main" parent query instance. + call_user_func($callback, $query); + + $this->wheres[] = compact('type', 'column', 'operator', 'query', 'boolean'); + + $this->mergeBindings($query); + + return $this; + } + + /** + * Add an exists clause to the query. + * + * @param \Closure $callback + * @param string $boolean + * @param bool $not + * @return \Illuminate\Database\Query\Builder|static + */ + public function whereExists(Closure $callback, $boolean = 'and', $not = false) + { + $type = $not ? 'NotExists' : 'Exists'; + + $query = $this->newQuery(); + + // Similar to the sub-select clause, we will create a new query instance so + // the developer may cleanly specify the entire exists query and we will + // compile the whole thing in the grammar and insert it into the SQL. + call_user_func($callback, $query); + + $this->wheres[] = compact('type', 'operator', 'query', 'boolean'); + + $this->mergeBindings($query); + + return $this; + } + + /** + * Add an or exists clause to the query. + * + * @param \Closure $callback + * @param bool $not + * @return \Illuminate\Database\Query\Builder|static + */ + public function orWhereExists(Closure $callback, $not = false) + { + return $this->whereExists($callback, 'or', $not); + } + + /** + * Add a where not exists clause to the query. + * + * @param \Closure $callback + * @param string $boolean + * @return \Illuminate\Database\Query\Builder|static + */ + public function whereNotExists(Closure $callback, $boolean = 'and') + { + return $this->whereExists($callback, $boolean, true); + } + + /** + * Add a where not exists clause to the query. + * + * @param \Closure $callback + * @return \Illuminate\Database\Query\Builder|static + */ + public function orWhereNotExists(Closure $callback) + { + return $this->orWhereExists($callback, true); + } + + /** + * Add a "where in" clause to the query. + * + * @param string $column + * @param mixed $values + * @param string $boolean + * @param bool $not + * @return \Illuminate\Database\Query\Builder|static + */ + public function whereIn($column, $values, $boolean = 'and', $not = false) + { + $type = $not ? 'NotIn' : 'In'; + + // If the value of the where in clause is actually a Closure, we will assume that + // the developer is using a full sub-select for this "in" statement, and will + // execute those Closures, then we can re-construct the entire sub-selects. + if ($values instanceof Closure) + { + return $this->whereInSub($column, $values, $boolean, $not); + } + + $this->wheres[] = compact('type', 'column', 'values', 'boolean'); + + $this->bindings = array_merge($this->bindings, $values); + + return $this; + } + + /** + * Add an "or where in" clause to the query. + * + * @param string $column + * @param mixed $values + * @return \Illuminate\Database\Query\Builder|static + */ + public function orWhereIn($column, $values) + { + return $this->whereIn($column, $values, 'or'); + } + + /** + * Add a "where not in" clause to the query. + * + * @param string $column + * @param mixed $values + * @param string $boolean + * @return \Illuminate\Database\Query\Builder|static + */ + public function whereNotIn($column, $values, $boolean = 'and') + { + return $this->whereIn($column, $values, $boolean, true); + } + + /** + * Add an "or where not in" clause to the query. + * + * @param string $column + * @param mixed $values + * @return \Illuminate\Database\Query\Builder|static + */ + public function orWhereNotIn($column, $values) + { + return $this->whereNotIn($column, $values, 'or'); + } + + /** + * Add a where in with a sub-select to the query. + * + * @param string $column + * @param \Closure $callback + * @param string $boolean + * @param bool $not + * @return \Illuminate\Database\Query\Builder|static + */ + protected function whereInSub($column, Closure $callback, $boolean, $not) + { + $type = $not ? 'NotInSub' : 'InSub'; + + // To create the exists sub-select, we will actually create a query and call the + // provided callback with the query so the developer may set any of the query + // conditions they want for the in clause, then we'll put it in this array. + call_user_func($callback, $query = $this->newQuery()); + + $this->wheres[] = compact('type', 'column', 'query', 'boolean'); + + $this->mergeBindings($query); + + return $this; + } + + /** + * Add a "where null" clause to the query. + * + * @param string $column + * @param string $boolean + * @param bool $not + * @return \Illuminate\Database\Query\Builder|static + */ + public function whereNull($column, $boolean = 'and', $not = false) + { + $type = $not ? 'NotNull' : 'Null'; + + $this->wheres[] = compact('type', 'column', 'boolean'); + + return $this; + } + + /** + * Add an "or where null" clause to the query. + * + * @param string $column + * @return \Illuminate\Database\Query\Builder|static + */ + public function orWhereNull($column) + { + return $this->whereNull($column, 'or'); + } + + /** + * Add a "where not null" clause to the query. + * + * @param string $column + * @param string $boolean + * @return \Illuminate\Database\Query\Builder|static + */ + public function whereNotNull($column, $boolean = 'and') + { + return $this->whereNull($column, $boolean, true); + } + + /** + * Add an "or where not null" clause to the query. + * + * @param string $column + * @return \Illuminate\Database\Query\Builder|static + */ + public function orWhereNotNull($column) + { + return $this->whereNotNull($column, 'or'); + } + + /** + * Add a "where day" statement to the query. + * + * @param string $column + * @param string $operator + * @param int $value + * @param string $boolean + * @return \Illuminate\Database\Query\Builder|static + */ + public function whereDay($column, $operator, $value, $boolean = 'and') + { + return $this->addDateBasedWhere('Day', $column, $operator, $value, $boolean); + } + + /** + * Add a "where month" statement to the query. + * + * @param string $column + * @param string $operator + * @param int $value + * @param string $boolean + * @return \Illuminate\Database\Query\Builder|static + */ + public function whereMonth($column, $operator, $value, $boolean = 'and') + { + return $this->addDateBasedWhere('Month', $column, $operator, $value, $boolean); + } + + /** + * Add a "where year" statement to the query. + * + * @param string $column + * @param string $operator + * @param int $value + * @param string $boolean + * @return \Illuminate\Database\Query\Builder|static + */ + public function whereYear($column, $operator, $value, $boolean = 'and') + { + return $this->addDateBasedWhere('Year', $column, $operator, $value, $boolean); + } + + /** + * Add a date based (year, month, day) statement to the query. + * + * @param string $type + * @param string $column + * @param string $operator + * @param int $value + * @param string $boolean + * @return \Illuminate\Database\Query\Builder|static + */ + protected function addDateBasedWhere($type, $column, $operator, $value, $boolean = 'and') + { + $this->wheres[] = compact('column', 'type', 'boolean', 'operator', 'value'); + + $this->bindings[] = $value; + + return $this; + } + + /** + * Handles dynamic "where" clauses to the query. + * + * @param string $method + * @param string $parameters + * @return \Illuminate\Database\Query\Builder|static + */ + public function dynamicWhere($method, $parameters) + { + $finder = substr($method, 5); + + $segments = preg_split('/(And|Or)(?=[A-Z])/', $finder, -1, PREG_SPLIT_DELIM_CAPTURE); + + // The connector variable will determine which connector will be used for the + // query condition. We will change it as we come across new boolean values + // in the dynamic method strings, which could contain a number of these. + $connector = 'and'; + + $index = 0; + + foreach ($segments as $segment) + { + // If the segment is not a boolean connector, we can assume it is a column's name + // and we will add it to the query as a new constraint as a where clause, then + // we can keep iterating through the dynamic method string's segments again. + if ($segment != 'And' && $segment != 'Or') + { + $this->addDynamic($segment, $connector, $parameters, $index); + + $index++; + } + + // Otherwise, we will store the connector so we know how the next where clause we + // find in the query should be connected to the previous ones, meaning we will + // have the proper boolean connector to connect the next where clause found. + else + { + $connector = $segment; + } + } + + return $this; + } + + /** + * Add a single dynamic where clause statement to the query. + * + * @param string $segment + * @param string $connector + * @param array $parameters + * @param int $index + * @return void + */ + protected function addDynamic($segment, $connector, $parameters, $index) + { + // Once we have parsed out the columns and formatted the boolean operators we + // are ready to add it to this query as a where clause just like any other + // clause on the query. Then we'll increment the parameter index values. + $bool = strtolower($connector); + + $this->where(snake_case($segment), '=', $parameters[$index], $bool); + } + + /** + * Add a "group by" clause to the query. + * + * @param dynamic $columns + * @return \Illuminate\Database\Query\Builder|static + */ + public function groupBy() + { + $this->groups = array_merge((array) $this->groups, func_get_args()); + + return $this; + } + + /** + * Add a "having" clause to the query. + * + * @param string $column + * @param string $operator + * @param string $value + * @return \Illuminate\Database\Query\Builder|static + */ + public function having($column, $operator = null, $value = null) + { + $type = 'basic'; + + $this->havings[] = compact('type', 'column', 'operator', 'value'); + + $this->bindings[] = $value; + + return $this; + } + + /** + * Add a raw having clause to the query. + * + * @param string $sql + * @param array $bindings + * @param string $boolean + * @return \Illuminate\Database\Query\Builder|static + */ + public function havingRaw($sql, array $bindings = array(), $boolean = 'and') + { + $type = 'raw'; + + $this->havings[] = compact('type', 'sql', 'boolean'); + + $this->bindings = array_merge($this->bindings, $bindings); + + return $this; + } + + /** + * Add a raw or having clause to the query. + * + * @param string $sql + * @param array $bindings + * @return \Illuminate\Database\Query\Builder|static + */ + public function orHavingRaw($sql, array $bindings = array()) + { + return $this->havingRaw($sql, $bindings, 'or'); + } + + /** + * Add an "order by" clause to the query. + * + * @param string $column + * @param string $direction + * @return \Illuminate\Database\Query\Builder|static + */ + public function orderBy($column, $direction = 'asc') + { + $direction = strtolower($direction) == 'asc' ? 'asc' : 'desc'; + + $this->orders[] = compact('column', 'direction'); + + return $this; + } + + /** + * Add an "order by" clause for a timestamp to the query. + * + * @param string $column + * @return \Illuminate\Database\Query\Builder|static + */ + public function latest($column = 'created_at') + { + return $this->orderBy($column, 'desc'); + } + + /** + * Add an "order by" clause for a timestamp to the query. + * + * @param string $column + * @return \Illuminate\Database\Query\Builder|static + */ + public function oldest($column = 'created_at') + { + return $this->orderBy($column, 'asc'); + } + + /** + * Add a raw "order by" clause to the query. + * + * @param string $sql + * @param array $bindings + * @return \Illuminate\Database\Query\Builder|static + */ + public function orderByRaw($sql, $bindings = array()) + { + $type = 'raw'; + + $this->orders[] = compact('type', 'sql'); + + $this->bindings = array_merge($this->bindings, $bindings); + + return $this; + } + + /** + * Set the "offset" value of the query. + * + * @param int $value + * @return \Illuminate\Database\Query\Builder|static + */ + public function offset($value) + { + $this->offset = max(0, $value); + + return $this; + } + + /** + * Alias to set the "offset" value of the query. + * + * @param int $value + * @return \Illuminate\Database\Query\Builder|static + */ + public function skip($value) + { + return $this->offset($value); + } + + /** + * Set the "limit" value of the query. + * + * @param int $value + * @return \Illuminate\Database\Query\Builder|static + */ + public function limit($value) + { + if ($value > 0) $this->limit = $value; + + return $this; + } + + /** + * Alias to set the "limit" value of the query. + * + * @param int $value + * @return \Illuminate\Database\Query\Builder|static + */ + public function take($value) + { + return $this->limit($value); + } + + /** + * Set the limit and offset for a given page. + * + * @param int $page + * @param int $perPage + * @return \Illuminate\Database\Query\Builder|static + */ + public function forPage($page, $perPage = 15) + { + return $this->skip(($page - 1) * $perPage)->take($perPage); + } + + /** + * Add a union statement to the query. + * + * @param \Illuminate\Database\Query\Builder|\Closure $query + * @param bool $all + * @return \Illuminate\Database\Query\Builder|static + */ + public function union($query, $all = false) + { + if ($query instanceof Closure) + { + call_user_func($query, $query = $this->newQuery()); + } + + $this->unions[] = compact('query', 'all'); + + return $this->mergeBindings($query); + } + + /** + * Add a union all statement to the query. + * + * @param \Illuminate\Database\Query\Builder|\Closure $query + * @return \Illuminate\Database\Query\Builder|static + */ + public function unionAll($query) + { + return $this->union($query, true); + } + + /** + * Lock the selected rows in the table. + * + * @param bool $update + * @return \Illuminate\Database\Query\Builder + */ + public function lock($value = true) + { + $this->lock = $value; + + return $this; + } + + /** + * Lock the selected rows in the table for updating. + * + * @return \Illuminate\Database\Query\Builder + */ + public function lockForUpdate() + { + return $this->lock(true); + } + + /** + * Share lock the selected rows in the table. + * + * @return \Illuminate\Database\Query\Builder + */ + public function sharedLock() + { + return $this->lock(false); + } + + /** + * Get the SQL representation of the query. + * + * @return string + */ + public function toSql() + { + return $this->grammar->compileSelect($this); + } + + /** + * Indicate that the query results should be cached. + * + * @param \DateTime|int $minutes + * @param string $key + * @return \Illuminate\Database\Query\Builder|static + */ + public function remember($minutes, $key = null) + { + list($this->cacheMinutes, $this->cacheKey) = array($minutes, $key); + + return $this; + } + + /** + * Indicate that the query results should be cached forever. + * + * @param string $key + * @return \Illuminate\Database\Query\Builder|static + */ + public function rememberForever($key = null) + { + return $this->remember(-1, $key); + } + + /** + * Indicate that the results, if cached, should use the given cache tags. + * + * @param array|dynamic $cacheTags + * @return \Illuminate\Database\Query\Builder|static + */ + public function cacheTags($cacheTags) + { + $this->cacheTags = $cacheTags; + + return $this; + } + + /** + * Indicate that the results, if cached, should use the given cache driver. + * + * @param string $cacheDriver + * @return \Illuminate\Database\Query\Builder|static + */ + public function cacheDriver($cacheDriver) + { + $this->cacheDriver = $cacheDriver; + + return $this; + } + + /** + * Execute a query for a single record by ID. + * + * @param int $id + * @param array $columns + * @return mixed|static + */ + public function find($id, $columns = array('*')) + { + return $this->where('id', '=', $id)->first($columns); + } + + /** + * Pluck a single column's value from the first result of a query. + * + * @param string $column + * @return mixed + */ + public function pluck($column) + { + $result = (array) $this->first(array($column)); + + return count($result) > 0 ? reset($result) : null; + } + + /** + * Execute the query and get the first result. + * + * @param array $columns + * @return mixed|static + */ + public function first($columns = array('*')) + { + $results = $this->take(1)->get($columns); + + return count($results) > 0 ? reset($results) : null; + } + + /** + * Execute the query as a "select" statement. + * + * @param array $columns + * @return array|static[] + */ + public function get($columns = array('*')) + { + if ( ! is_null($this->cacheMinutes)) return $this->getCached($columns); + + return $this->getFresh($columns); + } + + /** + * Execute the query as a fresh "select" statement. + * + * @param array $columns + * @return array|static[] + */ + public function getFresh($columns = array('*')) + { + if (is_null($this->columns)) $this->columns = $columns; + + return $this->processor->processSelect($this, $this->runSelect()); + } + + /** + * Run the query as a "select" statement against the connection. + * + * @return array + */ + protected function runSelect() + { + return $this->connection->select($this->toSql(), $this->bindings); + } + + /** + * Execute the query as a cached "select" statement. + * + * @param array $columns + * @return array + */ + public function getCached($columns = array('*')) + { + if (is_null($this->columns)) $this->columns = $columns; + + // If the query is requested to be cached, we will cache it using a unique key + // for this database connection and query statement, including the bindings + // that are used on this query, providing great convenience when caching. + list($key, $minutes) = $this->getCacheInfo(); + + $cache = $this->getCache(); + + $callback = $this->getCacheCallback($columns); + + // If the "minutes" value is less than zero, we will use that as the indicator + // that the value should be remembered values should be stored indefinitely + // and if we have minutes we will use the typical remember function here. + if ($minutes < 0) + { + return $cache->rememberForever($key, $callback); + } + else + { + return $cache->remember($key, $minutes, $callback); + } + } + + /** + * Get the cache object with tags assigned, if applicable. + * + * @return \Illuminate\Cache\CacheManager + */ + protected function getCache() + { + $cache = $this->connection->getCacheManager()->driver($this->cacheDriver); + + return $this->cacheTags ? $cache->tags($this->cacheTags) : $cache; + } + + /** + * Get the cache key and cache minutes as an array. + * + * @return array + */ + protected function getCacheInfo() + { + return array($this->getCacheKey(), $this->cacheMinutes); + } + + /** + * Get a unique cache key for the complete query. + * + * @return string + */ + public function getCacheKey() + { + return $this->cacheKey ?: $this->generateCacheKey(); + } + + /** + * Generate the unique cache key for the query. + * + * @return string + */ + public function generateCacheKey() + { + $name = $this->connection->getName(); + + return md5($name.$this->toSql().serialize($this->bindings)); + } + + /** + * Get the Closure callback used when caching queries. + * + * @param array $columns + * @return \Closure + */ + protected function getCacheCallback($columns) + { + $me = $this; + + return function() use ($me, $columns) { return $me->getFresh($columns); }; + } + + /** + * Chunk the results of the query. + * + * @param int $count + * @param callable $callback + * @return void + */ + public function chunk($count, $callback) + { + $results = $this->forPage($page = 1, $count)->get(); + + while (count($results) > 0) + { + // On each chunk result set, we will pass them to the callback and then let the + // developer take care of everything within the callback, which allows us to + // keep the memory low for spinning through large result sets for working. + call_user_func($callback, $results); + + $page++; + + $results = $this->forPage($page, $count)->get(); + } + } + + /** + * Get an array with the values of a given column. + * + * @param string $column + * @param string $key + * @return array + */ + public function lists($column, $key = null) + { + $columns = $this->getListSelect($column, $key); + + // First we will just get all of the column values for the record result set + // then we can associate those values with the column if it was specified + // otherwise we can just give these values back without a specific key. + $results = new Collection($this->get($columns)); + + $values = $results->fetch($columns[0])->all(); + + // If a key was specified and we have results, we will go ahead and combine + // the values with the keys of all of the records so that the values can + // be accessed by the key of the rows instead of simply being numeric. + if ( ! is_null($key) && count($results) > 0) + { + $keys = $results->fetch($key)->all(); + + return array_combine($keys, $values); + } + + return $values; + } + + /** + * Get the columns that should be used in a list array. + * + * @param string $column + * @param string $key + * @return array + */ + protected function getListSelect($column, $key) + { + $select = is_null($key) ? array($column) : array($column, $key); + + // If the selected column contains a "dot", we will remove it so that the list + // operation can run normally. Specifying the table is not needed, since we + // really want the names of the columns as it is in this resulting array. + if (($dot = strpos($select[0], '.')) !== false) + { + $select[0] = substr($select[0], $dot + 1); + } + + return $select; + } + + /** + * Concatenate values of a given column as a string. + * + * @param string $column + * @param string $glue + * @return string + */ + public function implode($column, $glue = null) + { + if (is_null($glue)) return implode($this->lists($column)); + + return implode($glue, $this->lists($column)); + } + + /** + * Get a paginator for the "select" statement. + * + * @param int $perPage + * @param array $columns + * @return \Illuminate\Pagination\Paginator + */ + public function paginate($perPage = 15, $columns = array('*')) + { + $paginator = $this->connection->getPaginator(); + + if (isset($this->groups)) + { + return $this->groupedPaginate($paginator, $perPage, $columns); + } + else + { + return $this->ungroupedPaginate($paginator, $perPage, $columns); + } + } + + /** + * Create a paginator for a grouped pagination statement. + * + * @param \Illuminate\Pagination\Environment $paginator + * @param int $perPage + * @param array $columns + * @return \Illuminate\Pagination\Paginator + */ + protected function groupedPaginate($paginator, $perPage, $columns) + { + $results = $this->get($columns); + + return $this->buildRawPaginator($paginator, $results, $perPage); + } + + /** + * Build a paginator instance from a raw result array. + * + * @param \Illuminate\Pagination\Environment $paginator + * @param array $results + * @param int $perPage + * @return \Illuminate\Pagination\Paginator + */ + public function buildRawPaginator($paginator, $results, $perPage) + { + // For queries which have a group by, we will actually retrieve the entire set + // of rows from the table and "slice" them via PHP. This is inefficient and + // the developer must be aware of this behavior; however, it's an option. + $start = ($paginator->getCurrentPage() - 1) * $perPage; + + $sliced = array_slice($results, $start, $perPage); + + return $paginator->make($sliced, count($results), $perPage); + } + + /** + * Create a paginator for an un-grouped pagination statement. + * + * @param \Illuminate\Pagination\Environment $paginator + * @param int $perPage + * @param array $columns + * @return \Illuminate\Pagination\Paginator + */ + protected function ungroupedPaginate($paginator, $perPage, $columns) + { + $total = $this->getPaginationCount(); + + // Once we have the total number of records to be paginated, we can grab the + // current page and the result array. Then we are ready to create a brand + // new Paginator instances for the results which will create the links. + $page = $paginator->getCurrentPage($total); + + $results = $this->forPage($page, $perPage)->get($columns); + + return $paginator->make($results, $total, $perPage); + } + + /** + * Get the count of the total records for pagination. + * + * @return int + */ + public function getPaginationCount() + { + $this->backupFieldsForCount(); + + // Because some database engines may throw errors if we leave the ordering + // statements on the query, we will "back them up" and remove them from + // the query. Once we have the count we will put them back onto this. + $total = $this->count(); + + $this->restoreFieldsForCount(); + + return $total; + } + + /** + * Backup certain fields for a pagination count. + * + * @return void + */ + protected function backupFieldsForCount() + { + foreach (array('orders', 'limit', 'offset') as $field) + { + $this->backups[$field] = $this->{$field}; + + $this->{$field} = null; + } + + } + + /** + * Restore certain fields for a pagination count. + * + * @return void + */ + protected function restoreFieldsForCount() + { + foreach (array('orders', 'limit', 'offset') as $field) + { + $this->{$field} = $this->backups[$field]; + } + + $this->backups = array(); + } + + /** + * Determine if any rows exist for the current query. + * + * @return bool + */ + public function exists() + { + return $this->count() > 0; + } + + /** + * Retrieve the "count" result of the query. + * + * @param string $columns + * @return int + */ + public function count($columns = '*') + { + if ( ! is_array($columns)) + { + $columns = array($columns); + } + + return (int) $this->aggregate(__FUNCTION__, $columns); + } + + /** + * Retrieve the minimum value of a given column. + * + * @param string $column + * @return mixed + */ + public function min($column) + { + return $this->aggregate(__FUNCTION__, array($column)); + } + + /** + * Retrieve the maximum value of a given column. + * + * @param string $column + * @return mixed + */ + public function max($column) + { + return $this->aggregate(__FUNCTION__, array($column)); + } + + /** + * Retrieve the sum of the values of a given column. + * + * @param string $column + * @return mixed + */ + public function sum($column) + { + $result = $this->aggregate(__FUNCTION__, array($column)); + + return $result ?: 0; + } + + /** + * Retrieve the average of the values of a given column. + * + * @param string $column + * @return mixed + */ + public function avg($column) + { + return $this->aggregate(__FUNCTION__, array($column)); + } + + /** + * Execute an aggregate function on the database. + * + * @param string $function + * @param array $columns + * @return mixed + */ + public function aggregate($function, $columns = array('*')) + { + $this->aggregate = compact('function', 'columns'); + + $previousColumns = $this->columns; + + $results = $this->get($columns); + + // Once we have executed the query, we will reset the aggregate property so + // that more select queries can be executed against the database without + // the aggregate value getting in the way when the grammar builds it. + $this->aggregate = null; + + $this->columns = $previousColumns; + + if (isset($results[0])) + { + $result = array_change_key_case((array) $results[0]); + + return $result['aggregate']; + } + } + + /** + * Insert a new record into the database. + * + * @param array $values + * @return bool + */ + public function insert(array $values) + { + // Since every insert gets treated like a batch insert, we will make sure the + // bindings are structured in a way that is convenient for building these + // inserts statements by verifying the elements are actually an array. + if ( ! is_array(reset($values))) + { + $values = array($values); + } + + // Since every insert gets treated like a batch insert, we will make sure the + // bindings are structured in a way that is convenient for building these + // inserts statements by verifying the elements are actually an array. + else + { + foreach ($values as $key => $value) + { + ksort($value); $values[$key] = $value; + } + } + + // We'll treat every insert like a batch insert so we can easily insert each + // of the records into the database consistently. This will make it much + // easier on the grammars to just handle one type of record insertion. + $bindings = array(); + + foreach ($values as $record) + { + $bindings = array_merge($bindings, array_values($record)); + } + + $sql = $this->grammar->compileInsert($this, $values); + + // Once we have compiled the insert statement's SQL we can execute it on the + // connection and return a result as a boolean success indicator as that + // is the same type of result returned by the raw connection instance. + $bindings = $this->cleanBindings($bindings); + + return $this->connection->insert($sql, $bindings); + } + + /** + * Insert a new record and get the value of the primary key. + * + * @param array $values + * @param string $sequence + * @return int + */ + public function insertGetId(array $values, $sequence = null) + { + $sql = $this->grammar->compileInsertGetId($this, $values, $sequence); + + $values = $this->cleanBindings($values); + + return $this->processor->processInsertGetId($this, $sql, $values, $sequence); + } + + /** + * Update a record in the database. + * + * @param array $values + * @return int + */ + public function update(array $values) + { + $bindings = array_values(array_merge($values, $this->bindings)); + + $sql = $this->grammar->compileUpdate($this, $values); + + return $this->connection->update($sql, $this->cleanBindings($bindings)); + } + + /** + * Increment a column's value by a given amount. + * + * @param string $column + * @param int $amount + * @param array $extra + * @return int + */ + public function increment($column, $amount = 1, array $extra = array()) + { + $wrapped = $this->grammar->wrap($column); + + $columns = array_merge(array($column => $this->raw("$wrapped + $amount")), $extra); + + return $this->update($columns); + } + + /** + * Decrement a column's value by a given amount. + * + * @param string $column + * @param int $amount + * @param array $extra + * @return int + */ + public function decrement($column, $amount = 1, array $extra = array()) + { + $wrapped = $this->grammar->wrap($column); + + $columns = array_merge(array($column => $this->raw("$wrapped - $amount")), $extra); + + return $this->update($columns); + } + + /** + * Delete a record from the database. + * + * @param mixed $id + * @return int + */ + public function delete($id = null) + { + // If an ID is passed to the method, we will set the where clause to check + // the ID to allow developers to simply and quickly remove a single row + // from their database without manually specifying the where clauses. + if ( ! is_null($id)) $this->where('id', '=', $id); + + $sql = $this->grammar->compileDelete($this); + + return $this->connection->delete($sql, $this->bindings); + } + + /** + * Run a truncate statement on the table. + * + * @return void + */ + public function truncate() + { + foreach ($this->grammar->compileTruncate($this) as $sql => $bindings) + { + $this->connection->statement($sql, $bindings); + } + } + + /** + * Get a new instance of the query builder. + * + * @return \Illuminate\Database\Query\Builder + */ + public function newQuery() + { + return new Builder($this->connection, $this->grammar, $this->processor); + } + + /** + * Merge an array of where clauses and bindings. + * + * @param array $wheres + * @param array $bindings + * @return void + */ + public function mergeWheres($wheres, $bindings) + { + $this->wheres = array_merge((array) $this->wheres, (array) $wheres); + + $this->bindings = array_values(array_merge($this->bindings, (array) $bindings)); + } + + /** + * Remove all of the expressions from a list of bindings. + * + * @param array $bindings + * @return array + */ + protected function cleanBindings(array $bindings) + { + return array_values(array_filter($bindings, function($binding) + { + return ! $binding instanceof Expression; + })); + } + + /** + * Create a raw database expression. + * + * @param mixed $value + * @return \Illuminate\Database\Query\Expression + */ + public function raw($value) + { + return $this->connection->raw($value); + } + + /** + * Get the current query value bindings. + * + * @return array + */ + public function getBindings() + { + return $this->bindings; + } + + /** + * Set the bindings on the query builder. + * + * @param array $bindings + * @return \Illuminate\Database\Query\Builder + */ + public function setBindings(array $bindings) + { + $this->bindings = $bindings; + + return $this; + } + + /** + * Add a binding to the query. + * + * @param mixed $value + * @return \Illuminate\Database\Query\Builder + */ + public function addBinding($value) + { + $this->bindings[] = $value; + + return $this; + } + + /** + * Merge an array of bindings into our bindings. + * + * @param \Illuminate\Database\Query\Builder $query + * @return \Illuminate\Database\Query\Builder + */ + public function mergeBindings(Builder $query) + { + $this->bindings = array_values(array_merge($this->bindings, $query->bindings)); + + return $this; + } + + /** + * Get the database connection instance. + * + * @return \Illuminate\Database\ConnectionInterface + */ + public function getConnection() + { + return $this->connection; + } + + /** + * Get the database query processor instance. + * + * @return \Illuminate\Database\Query\Processors\Processor + */ + public function getProcessor() + { + return $this->processor; + } + + /** + * Get the query grammar instance. + * + * @return \Illuminate\Database\Grammar + */ + public function getGrammar() + { + return $this->grammar; + } + + /** + * Handle dynamic method calls into the method. + * + * @param string $method + * @param array $parameters + * @return mixed + * + * @throws \BadMethodCallException + */ + public function __call($method, $parameters) + { + if (starts_with($method, 'where')) + { + return $this->dynamicWhere($method, $parameters); + } + + $className = get_class($this); + + throw new \BadMethodCallException("Call to undefined method {$className}::{$method}()"); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Database/Query/Expression.php b/vendor/laravel/framework/src/Illuminate/Database/Query/Expression.php new file mode 100755 index 0000000..68d2236 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Database/Query/Expression.php @@ -0,0 +1,43 @@ +value = $value; + } + + /** + * Get the value of the expression. + * + * @return mixed + */ + public function getValue() + { + return $this->value; + } + + /** + * Get the value of the expression. + * + * @return string + */ + public function __toString() + { + return (string) $this->getValue(); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Database/Query/Grammars/Grammar.php b/vendor/laravel/framework/src/Illuminate/Database/Query/Grammars/Grammar.php new file mode 100755 index 0000000..2b7d36f --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Database/Query/Grammars/Grammar.php @@ -0,0 +1,724 @@ +columns)) $query->columns = array('*'); + + return trim($this->concatenate($this->compileComponents($query))); + } + + /** + * Compile the components necessary for a select clause. + * + * @param \Illuminate\Database\Query\Builder + * @return array + */ + protected function compileComponents(Builder $query) + { + $sql = array(); + + foreach ($this->selectComponents as $component) + { + // To compile the query, we'll spin through each component of the query and + // see if that component exists. If it does we'll just call the compiler + // function for the component which is responsible for making the SQL. + if ( ! is_null($query->$component)) + { + $method = 'compile'.ucfirst($component); + + $sql[$component] = $this->$method($query, $query->$component); + } + } + + return $sql; + } + + /** + * Compile an aggregated select clause. + * + * @param \Illuminate\Database\Query\Builder $query + * @param array $aggregate + * @return string + */ + protected function compileAggregate(Builder $query, $aggregate) + { + $column = $this->columnize($aggregate['columns']); + + // If the query has a "distinct" constraint and we're not asking for all columns + // we need to prepend "distinct" onto the column name so that the query takes + // it into account when it performs the aggregating operations on the data. + if ($query->distinct && $column !== '*') + { + $column = 'distinct '.$column; + } + + return 'select '.$aggregate['function'].'('.$column.') as aggregate'; + } + + /** + * Compile the "select *" portion of the query. + * + * @param \Illuminate\Database\Query\Builder $query + * @param array $columns + * @return string + */ + protected function compileColumns(Builder $query, $columns) + { + // If the query is actually performing an aggregating select, we will let that + // compiler handle the building of the select clauses, as it will need some + // more syntax that is best handled by that function to keep things neat. + if ( ! is_null($query->aggregate)) return; + + $select = $query->distinct ? 'select distinct ' : 'select '; + + return $select.$this->columnize($columns); + } + + /** + * Compile the "from" portion of the query. + * + * @param \Illuminate\Database\Query\Builder $query + * @param string $table + * @return string + */ + protected function compileFrom(Builder $query, $table) + { + return 'from '.$this->wrapTable($table); + } + + /** + * Compile the "join" portions of the query. + * + * @param \Illuminate\Database\Query\Builder $query + * @param array $joins + * @return string + */ + protected function compileJoins(Builder $query, $joins) + { + $sql = array(); + + foreach ($joins as $join) + { + $table = $this->wrapTable($join->table); + + // First we need to build all of the "on" clauses for the join. There may be many + // of these clauses so we will need to iterate through each one and build them + // separately, then we'll join them up into a single string when we're done. + $clauses = array(); + + foreach ($join->clauses as $clause) + { + $clauses[] = $this->compileJoinConstraint($clause); + } + + // Once we have constructed the clauses, we'll need to take the boolean connector + // off of the first clause as it obviously will not be required on that clause + // because it leads the rest of the clauses, thus not requiring any boolean. + $clauses[0] = $this->removeLeadingBoolean($clauses[0]); + + $clauses = implode(' ', $clauses); + + $type = $join->type; + + // Once we have everything ready to go, we will just concatenate all the parts to + // build the final join statement SQL for the query and we can then return the + // final clause back to the callers as a single, stringified join statement. + $sql[] = "$type join $table on $clauses"; + } + + return implode(' ', $sql); + } + + /** + * Create a join clause constraint segment. + * + * @param array $clause + * @return string + */ + protected function compileJoinConstraint(array $clause) + { + $first = $this->wrap($clause['first']); + + $second = $clause['where'] ? '?' : $this->wrap($clause['second']); + + return "{$clause['boolean']} $first {$clause['operator']} $second"; + } + + /** + * Compile the "where" portions of the query. + * + * @param \Illuminate\Database\Query\Builder $query + * @return string + */ + protected function compileWheres(Builder $query) + { + $sql = array(); + + if (is_null($query->wheres)) return ''; + + // Each type of where clauses has its own compiler function which is responsible + // for actually creating the where clauses SQL. This helps keep the code nice + // and maintainable since each clause has a very small method that it uses. + foreach ($query->wheres as $where) + { + $method = "where{$where['type']}"; + + $sql[] = $where['boolean'].' '.$this->$method($query, $where); + } + + // If we actually have some where clauses, we will strip off the first boolean + // operator, which is added by the query builders for convenience so we can + // avoid checking for the first clauses in each of the compilers methods. + if (count($sql) > 0) + { + $sql = implode(' ', $sql); + + return 'where '.preg_replace('/and |or /', '', $sql, 1); + } + + return ''; + } + + /** + * Compile a nested where clause. + * + * @param \Illuminate\Database\Query\Builder $query + * @param array $where + * @return string + */ + protected function whereNested(Builder $query, $where) + { + $nested = $where['query']; + + return '('.substr($this->compileWheres($nested), 6).')'; + } + + /** + * Compile a where condition with a sub-select. + * + * @param \Illuminate\Database\Query\Builder $query + * @param array $where + * @return string + */ + protected function whereSub(Builder $query, $where) + { + $select = $this->compileSelect($where['query']); + + return $this->wrap($where['column']).' '.$where['operator']." ($select)"; + } + + /** + * Compile a basic where clause. + * + * @param \Illuminate\Database\Query\Builder $query + * @param array $where + * @return string + */ + protected function whereBasic(Builder $query, $where) + { + $value = $this->parameter($where['value']); + + return $this->wrap($where['column']).' '.$where['operator'].' '.$value; + } + + /** + * Compile a "between" where clause. + * + * @param \Illuminate\Database\Query\Builder $query + * @param array $where + * @return string + */ + protected function whereBetween(Builder $query, $where) + { + $between = $where['not'] ? 'not between' : 'between'; + + return $this->wrap($where['column']).' '.$between.' ? and ?'; + } + + /** + * Compile a where exists clause. + * + * @param \Illuminate\Database\Query\Builder $query + * @param array $where + * @return string + */ + protected function whereExists(Builder $query, $where) + { + return 'exists ('.$this->compileSelect($where['query']).')'; + } + + /** + * Compile a where exists clause. + * + * @param \Illuminate\Database\Query\Builder $query + * @param array $where + * @return string + */ + protected function whereNotExists(Builder $query, $where) + { + return 'not exists ('.$this->compileSelect($where['query']).')'; + } + + /** + * Compile a "where in" clause. + * + * @param \Illuminate\Database\Query\Builder $query + * @param array $where + * @return string + */ + protected function whereIn(Builder $query, $where) + { + $values = $this->parameterize($where['values']); + + return $this->wrap($where['column']).' in ('.$values.')'; + } + + /** + * Compile a "where not in" clause. + * + * @param \Illuminate\Database\Query\Builder $query + * @param array $where + * @return string + */ + protected function whereNotIn(Builder $query, $where) + { + $values = $this->parameterize($where['values']); + + return $this->wrap($where['column']).' not in ('.$values.')'; + } + + /** + * Compile a where in sub-select clause. + * + * @param \Illuminate\Database\Query\Builder $query + * @param array $where + * @return string + */ + protected function whereInSub(Builder $query, $where) + { + $select = $this->compileSelect($where['query']); + + return $this->wrap($where['column']).' in ('.$select.')'; + } + + /** + * Compile a where not in sub-select clause. + * + * @param \Illuminate\Database\Query\Builder $query + * @param array $where + * @return string + */ + protected function whereNotInSub(Builder $query, $where) + { + $select = $this->compileSelect($where['query']); + + return $this->wrap($where['column']).' not in ('.$select.')'; + } + + /** + * Compile a "where null" clause. + * + * @param \Illuminate\Database\Query\Builder $query + * @param array $where + * @return string + */ + protected function whereNull(Builder $query, $where) + { + return $this->wrap($where['column']).' is null'; + } + + /** + * Compile a "where not null" clause. + * + * @param \Illuminate\Database\Query\Builder $query + * @param array $where + * @return string + */ + protected function whereNotNull(Builder $query, $where) + { + return $this->wrap($where['column']).' is not null'; + } + + /** + * Compile a "where day" clause. + * + * @param \Illuminate\Database\Query\Builder $query + * @param array $where + * @return string + */ + protected function whereDay(Builder $query, $where) + { + return $this->dateBasedWhere('day', $query, $where); + } + + /** + * Compile a "where month" clause. + * + * @param \Illuminate\Database\Query\Builder $query + * @param array $where + * @return string + */ + protected function whereMonth(Builder $query, $where) + { + return $this->dateBasedWhere('month', $query, $where); + } + + /** + * Compile a "where year" clause. + * + * @param \Illuminate\Database\Query\Builder $query + * @param array $where + * @return string + */ + protected function whereYear(Builder $query, $where) + { + return $this->dateBasedWhere('year', $query, $where); + } + + /** + * Compile a date based where clause. + * + * @param string $type + * @param \Illuminate\Database\Query\Builder $query + * @param array $where + * @return string + */ + protected function dateBasedWhere($type, Builder $query, $where) + { + $value = $this->parameter($where['value']); + + return $type.'('.$this->wrap($where['column']).') '.$where['operator'].' '.$value; + } + + /** + * Compile a raw where clause. + * + * @param \Illuminate\Database\Query\Builder $query + * @param array $where + * @return string + */ + protected function whereRaw(Builder $query, $where) + { + return $where['sql']; + } + + /** + * Compile the "group by" portions of the query. + * + * @param \Illuminate\Database\Query\Builder $query + * @param array $groups + * @return string + */ + protected function compileGroups(Builder $query, $groups) + { + return 'group by '.$this->columnize($groups); + } + + /** + * Compile the "having" portions of the query. + * + * @param \Illuminate\Database\Query\Builder $query + * @param array $havings + * @return string + */ + protected function compileHavings(Builder $query, $havings) + { + $sql = implode(' ', array_map(array($this, 'compileHaving'), $havings)); + + return 'having '.preg_replace('/and /', '', $sql, 1); + } + + /** + * Compile a single having clause. + * + * @param array $having + * @return string + */ + protected function compileHaving(array $having) + { + // If the having clause is "raw", we can just return the clause straight away + // without doing any more processing on it. Otherwise, we will compile the + // clause into SQL based on the components that make it up from builder. + if ($having['type'] === 'raw') + { + return $having['boolean'].' '.$having['sql']; + } + + return $this->compileBasicHaving($having); + } + + /** + * Compile a basic having clause. + * + * @param array $having + * @return string + */ + protected function compileBasicHaving($having) + { + $column = $this->wrap($having['column']); + + $parameter = $this->parameter($having['value']); + + return 'and '.$column.' '.$having['operator'].' '.$parameter; + } + + /** + * Compile the "order by" portions of the query. + * + * @param \Illuminate\Database\Query\Builder $query + * @param array $orders + * @return string + */ + protected function compileOrders(Builder $query, $orders) + { + $me = $this; + + return 'order by '.implode(', ', array_map(function($order) use ($me) + { + if (isset($order['sql'])) return $order['sql']; + + return $me->wrap($order['column']).' '.$order['direction']; + } + , $orders)); + } + + /** + * Compile the "limit" portions of the query. + * + * @param \Illuminate\Database\Query\Builder $query + * @param int $limit + * @return string + */ + protected function compileLimit(Builder $query, $limit) + { + return 'limit '.(int) $limit; + } + + /** + * Compile the "offset" portions of the query. + * + * @param \Illuminate\Database\Query\Builder $query + * @param int $offset + * @return string + */ + protected function compileOffset(Builder $query, $offset) + { + return 'offset '.(int) $offset; + } + + /** + * Compile the "union" queries attached to the main query. + * + * @param \Illuminate\Database\Query\Builder $query + * @return string + */ + protected function compileUnions(Builder $query) + { + $sql = ''; + + foreach ($query->unions as $union) + { + $sql .= $this->compileUnion($union); + } + + return ltrim($sql); + } + + /** + * Compile a single union statement. + * + * @param array $union + * @return string + */ + protected function compileUnion(array $union) + { + $joiner = $union['all'] ? ' union all ' : ' union '; + + return $joiner.$union['query']->toSql(); + } + + /** + * Compile an insert statement into SQL. + * + * @param \Illuminate\Database\Query\Builder $query + * @param array $values + * @return string + */ + public function compileInsert(Builder $query, array $values) + { + // Essentially we will force every insert to be treated as a batch insert which + // simply makes creating the SQL easier for us since we can utilize the same + // basic routine regardless of an amount of records given to us to insert. + $table = $this->wrapTable($query->from); + + if ( ! is_array(reset($values))) + { + $values = array($values); + } + + $columns = $this->columnize(array_keys(reset($values))); + + // We need to build a list of parameter place-holders of values that are bound + // to the query. Each insert should have the exact same amount of parameter + // bindings so we can just go off the first list of values in this array. + $parameters = $this->parameterize(reset($values)); + + $value = array_fill(0, count($values), "($parameters)"); + + $parameters = implode(', ', $value); + + return "insert into $table ($columns) values $parameters"; + } + + /** + * Compile an insert and get ID statement into SQL. + * + * @param \Illuminate\Database\Query\Builder $query + * @param array $values + * @param string $sequence + * @return string + */ + public function compileInsertGetId(Builder $query, $values, $sequence) + { + return $this->compileInsert($query, $values); + } + + /** + * Compile an update statement into SQL. + * + * @param \Illuminate\Database\Query\Builder $query + * @param array $values + * @return string + */ + public function compileUpdate(Builder $query, $values) + { + $table = $this->wrapTable($query->from); + + // Each one of the columns in the update statements needs to be wrapped in the + // keyword identifiers, also a place-holder needs to be created for each of + // the values in the list of bindings so we can make the sets statements. + $columns = array(); + + foreach ($values as $key => $value) + { + $columns[] = $this->wrap($key).' = '.$this->parameter($value); + } + + $columns = implode(', ', $columns); + + // If the query has any "join" clauses, we will setup the joins on the builder + // and compile them so we can attach them to this update, as update queries + // can get join statements to attach to other tables when they're needed. + if (isset($query->joins)) + { + $joins = ' '.$this->compileJoins($query, $query->joins); + } + else + { + $joins = ''; + } + + // Of course, update queries may also be constrained by where clauses so we'll + // need to compile the where clauses and attach it to the query so only the + // intended records are updated by the SQL statements we generate to run. + $where = $this->compileWheres($query); + + return trim("update {$table}{$joins} set $columns $where"); + } + + /** + * Compile a delete statement into SQL. + * + * @param \Illuminate\Database\Query\Builder $query + * @param array $values + * @return string + */ + public function compileDelete(Builder $query) + { + $table = $this->wrapTable($query->from); + + $where = is_array($query->wheres) ? $this->compileWheres($query) : ''; + + return trim("delete from $table ".$where); + } + + /** + * Compile a truncate table statement into SQL. + * + * @param \Illuminate\Database\Query\Builder $query + * @return array + */ + public function compileTruncate(Builder $query) + { + return array('truncate '.$this->wrapTable($query->from) => array()); + } + + /** + * Compile the lock into SQL. + * + * @param \Illuminate\Database\Query\Builder $query + * @param bool|string $value + * @return string + */ + protected function compileLock(Builder $query, $value) + { + return is_string($value) ? $value : ''; + } + + /** + * Concatenate an array of segments, removing empties. + * + * @param array $segments + * @return string + */ + protected function concatenate($segments) + { + return implode(' ', array_filter($segments, function($value) + { + return (string) $value !== ''; + })); + } + + /** + * Remove the leading boolean from a statement. + * + * @param string $value + * @return string + */ + protected function removeLeadingBoolean($value) + { + return preg_replace('/and |or /', '', $value, 1); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Database/Query/Grammars/MySqlGrammar.php b/vendor/laravel/framework/src/Illuminate/Database/Query/Grammars/MySqlGrammar.php new file mode 100755 index 0000000..4c3fdc7 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Database/Query/Grammars/MySqlGrammar.php @@ -0,0 +1,108 @@ +unions) + { + $sql = '('.$sql.') '.$this->compileUnions($query); + } + + return $sql; + } + + /** + * Compile a single union statement. + * + * @param array $union + * @return string + */ + protected function compileUnion(array $union) + { + $joiner = $union['all'] ? ' union all ' : ' union '; + + return $joiner.'('.$union['query']->toSql().')'; + } + + /** + * Compile the lock into SQL. + * + * @param \Illuminate\Database\Query\Builder $query + * @param bool|string $value + * @return string + */ + protected function compileLock(Builder $query, $value) + { + if (is_string($value)) return $value; + + return $value ? 'for update' : 'lock in share mode'; + } + + /** + * Compile an update statement into SQL. + * + * @param \Illuminate\Database\Query\Builder $query + * @param array $values + * @return string + */ + public function compileUpdate(Builder $query, $values) + { + $sql = parent::compileUpdate($query, $values); + + if (isset($query->orders)) + { + $sql .= ' '.$this->compileOrders($query, $query->orders); + } + + if (isset($query->limit)) + { + $sql .= ' '.$this->compileLimit($query, $query->limit); + } + + return rtrim($sql); + } + + /** + * Wrap a single string in keyword identifiers. + * + * @param string $value + * @return string + */ + protected function wrapValue($value) + { + if ($value === '*') return $value; + + return '`'.str_replace('`', '``', $value).'`'; + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Database/Query/Grammars/PostgresGrammar.php b/vendor/laravel/framework/src/Illuminate/Database/Query/Grammars/PostgresGrammar.php new file mode 100755 index 0000000..0894e14 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Database/Query/Grammars/PostgresGrammar.php @@ -0,0 +1,176 @@ +', '<=', '>=', '<>', '!=', + 'like', 'not like', 'between', 'ilike', + '&', '|', '#', '<<', '>>', + ); + + /** + * Compile the lock into SQL. + * + * @param \Illuminate\Database\Query\Builder $query + * @param bool|string $value + * @return string + */ + protected function compileLock(Builder $query, $value) + { + if (is_string($value)) return $value; + + return $value ? 'for update' : 'for share'; + } + + /** + * Compile an update statement into SQL. + * + * @param \Illuminate\Database\Query\Builder $query + * @param array $values + * @return string + */ + public function compileUpdate(Builder $query, $values) + { + $table = $this->wrapTable($query->from); + + // Each one of the columns in the update statements needs to be wrapped in the + // keyword identifiers, also a place-holder needs to be created for each of + // the values in the list of bindings so we can make the sets statements. + $columns = $this->compileUpdateColumns($values); + + $from = $this->compileUpdateFrom($query); + + $where = $this->compileUpdateWheres($query); + + return trim("update {$table} set {$columns}{$from} $where"); + } + + /** + * Compile the columns for the update statement. + * + * @param array $values + * @return string + */ + protected function compileUpdateColumns($values) + { + $columns = array(); + + // When gathering the columns for an update statement, we'll wrap each of the + // columns and convert it to a parameter value. Then we will concatenate a + // list of the columns that can be added into this update query clauses. + foreach ($values as $key => $value) + { + $columns[] = $this->wrap($key).' = '.$this->parameter($value); + } + + return implode(', ', $columns); + } + + /** + * Compile the "from" clause for an update with a join. + * + * @param \Illuminate\Database\Query\Builder $query + * @return string + */ + protected function compileUpdateFrom(Builder $query) + { + if ( ! isset($query->joins)) return ''; + + $froms = array(); + + // When using Postgres, updates with joins list the joined tables in the from + // clause, which is different than other systems like MySQL. Here, we will + // compile out the tables that are joined and add them to a from clause. + foreach ($query->joins as $join) + { + $froms[] = $this->wrapTable($join->table); + } + + if (count($froms) > 0) return ' from '.implode(', ', $froms); + } + + /** + * Compile the additional where clauses for updates with joins. + * + * @param \Illuminate\Database\Query\Builder $query + * @return string + */ + protected function compileUpdateWheres(Builder $query) + { + $baseWhere = $this->compileWheres($query); + + if ( ! isset($query->joins)) return $baseWhere; + + // Once we compile the join constraints, we will either use them as the where + // clause or append them to the existing base where clauses. If we need to + // strip the leading boolean we will do so when using as the only where. + $joinWhere = $this->compileUpdateJoinWheres($query); + + if (trim($baseWhere) == '') + { + return 'where '.$this->removeLeadingBoolean($joinWhere); + } + else + { + return $baseWhere.' '.$joinWhere; + } + } + + /** + * Compile the "join" clauses for an update. + * + * @param \Illuminate\Database\Query\Builder $query + * @return string + */ + protected function compileUpdateJoinWheres(Builder $query) + { + $joinWheres = array(); + + // Here we will just loop through all of the join constraints and compile them + // all out then implode them. This should give us "where" like syntax after + // everything has been built and then we will join it to the real wheres. + foreach ($query->joins as $join) + { + foreach ($join->clauses as $clause) + { + $joinWheres[] = $this->compileJoinConstraint($clause); + } + } + + return implode(' ', $joinWheres); + } + + /** + * Compile an insert and get ID statement into SQL. + * + * @param \Illuminate\Database\Query\Builder $query + * @param array $values + * @param string $sequence + * @return string + */ + public function compileInsertGetId(Builder $query, $values, $sequence) + { + if (is_null($sequence)) $sequence = 'id'; + + return $this->compileInsert($query, $values).' returning '.$this->wrap($sequence); + } + + /** + * Compile a truncate table statement into SQL. + * + * @param \Illuminate\Database\Query\Builder $query + * @return array + */ + public function compileTruncate(Builder $query) + { + return array('truncate '.$this->wrapTable($query->from).' restart identity' => array()); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Database/Query/Grammars/SQLiteGrammar.php b/vendor/laravel/framework/src/Illuminate/Database/Query/Grammars/SQLiteGrammar.php new file mode 100755 index 0000000..01558d3 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Database/Query/Grammars/SQLiteGrammar.php @@ -0,0 +1,130 @@ +', '<=', '>=', '<>', '!=', + 'like', 'not like', 'between', 'ilike', + '&', '|', '<<', '>>', + ); + + /** + * Compile an insert statement into SQL. + * + * @param \Illuminate\Database\Query\Builder $query + * @param array $values + * @return string + */ + public function compileInsert(Builder $query, array $values) + { + // Essentially we will force every insert to be treated as a batch insert which + // simply makes creating the SQL easier for us since we can utilize the same + // basic routine regardless of an amount of records given to us to insert. + $table = $this->wrapTable($query->from); + + if ( ! is_array(reset($values))) + { + $values = array($values); + } + + // If there is only one record being inserted, we will just use the usual query + // grammar insert builder because no special syntax is needed for the single + // row inserts in SQLite. However, if there are multiples, we'll continue. + if (count($values) == 1) + { + return parent::compileInsert($query, reset($values)); + } + + $names = $this->columnize(array_keys(reset($values))); + + $columns = array(); + + // SQLite requires us to build the multi-row insert as a listing of select with + // unions joining them together. So we'll build out this list of columns and + // then join them all together with select unions to complete the queries. + foreach (array_keys(reset($values)) as $column) + { + $columns[] = '? as '.$this->wrap($column); + } + + $columns = array_fill(0, count($values), implode(', ', $columns)); + + return "insert into $table ($names) select ".implode(' union select ', $columns); + } + + /** + * Compile a truncate table statement into SQL. + * + * @param \Illuminate\Database\Query\Builder $query + * @return array + */ + public function compileTruncate(Builder $query) + { + $sql = array('delete from sqlite_sequence where name = ?' => array($query->from)); + + $sql['delete from '.$this->wrapTable($query->from)] = array(); + + return $sql; + } + + /** + * Compile a "where day" clause. + * + * @param \Illuminate\Database\Query\Builder $query + * @param array $where + * @return string + */ + protected function whereDay(Builder $query, $where) + { + return $this->dateBasedWhere('%d', $query, $where); + } + + /** + * Compile a "where month" clause. + * + * @param \Illuminate\Database\Query\Builder $query + * @param array $where + * @return string + */ + protected function whereMonth(Builder $query, $where) + { + return $this->dateBasedWhere('%m', $query, $where); + } + + /** + * Compile a "where year" clause. + * + * @param \Illuminate\Database\Query\Builder $query + * @param array $where + * @return string + */ + protected function whereYear(Builder $query, $where) + { + return $this->dateBasedWhere('%Y', $query, $where); + } + + /** + * Compile a date based where clause. + * + * @param string $type + * @param \Illuminate\Database\Query\Builder $query + * @param array $where + * @return string + */ + protected function dateBasedWhere($type, Builder $query, $where) + { + $value = str_pad($where['value'], 2, '0', STR_PAD_LEFT); + + $value = $this->parameter($value); + + return 'strftime(\''.$type.'\', '.$this->wrap($where['column']).') '.$where['operator'].' '.$value; + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Database/Query/Grammars/SqlServerGrammar.php b/vendor/laravel/framework/src/Illuminate/Database/Query/Grammars/SqlServerGrammar.php new file mode 100755 index 0000000..f6faaf8 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Database/Query/Grammars/SqlServerGrammar.php @@ -0,0 +1,226 @@ +', '<=', '>=', '!<', '!>', '<>', '!=', + 'like', 'not like', 'between', 'ilike', + '&', '&=', '|', '|=', '^', '^=', + ); + + /** + * Compile a select query into SQL. + * + * @param \Illuminate\Database\Query\Builder + * @return string + */ + public function compileSelect(Builder $query) + { + $components = $this->compileComponents($query); + + // If an offset is present on the query, we will need to wrap the query in + // a big "ANSI" offset syntax block. This is very nasty compared to the + // other database systems but is necessary for implementing features. + if ($query->offset > 0) + { + return $this->compileAnsiOffset($query, $components); + } + + return $this->concatenate($components); + } + + /** + * Compile the "select *" portion of the query. + * + * @param \Illuminate\Database\Query\Builder $query + * @param array $columns + * @return string + */ + protected function compileColumns(Builder $query, $columns) + { + if ( ! is_null($query->aggregate)) return; + + $select = $query->distinct ? 'select distinct ' : 'select '; + + // If there is a limit on the query, but not an offset, we will add the top + // clause to the query, which serves as a "limit" type clause within the + // SQL Server system similar to the limit keywords available in MySQL. + if ($query->limit > 0 && $query->offset <= 0) + { + $select .= 'top '.$query->limit.' '; + } + + return $select.$this->columnize($columns); + } + + /** + * Compile the "from" portion of the query. + * + * @param \Illuminate\Database\Query\Builder $query + * @param string $table + * @return string + */ + protected function compileFrom(Builder $query, $table) + { + $from = parent::compileFrom($query, $table); + + if (is_string($query->lock)) return $from.' '.$query->lock; + + if ( ! is_null($query->lock)) + { + return $from.' with(rowlock,'.($query->lock ? 'updlock,' : '').'holdlock)'; + } + else + { + return $from; + } + } + + /** + * Create a full ANSI offset clause for the query. + * + * @param \Illuminate\Database\Query\Builder $query + * @param array $components + * @return string + */ + protected function compileAnsiOffset(Builder $query, $components) + { + // An ORDER BY clause is required to make this offset query work, so if one does + // not exist we'll just create a dummy clause to trick the database and so it + // does not complain about the queries for not having an "order by" clause. + if ( ! isset($components['orders'])) + { + $components['orders'] = 'order by (select 0)'; + } + + // We need to add the row number to the query so we can compare it to the offset + // and limit values given for the statements. So we will add an expression to + // the "select" that will give back the row numbers on each of the records. + $orderings = $components['orders']; + + $components['columns'] .= $this->compileOver($orderings); + + unset($components['orders']); + + // Next we need to calculate the constraints that should be placed on the query + // to get the right offset and limit from our query but if there is no limit + // set we will just handle the offset only since that is all that matters. + $constraint = $this->compileRowConstraint($query); + + $sql = $this->concatenate($components); + + // We are now ready to build the final SQL query so we'll create a common table + // expression from the query and get the records with row numbers within our + // given limit and offset value that we just put on as a query constraint. + return $this->compileTableExpression($sql, $constraint); + } + + /** + * Compile the over statement for a table expression. + * + * @param string $orderings + * @return string + */ + protected function compileOver($orderings) + { + return ", row_number() over ({$orderings}) as row_num"; + } + + /** + * Compile the limit / offset row constraint for a query. + * + * @param \Illuminate\Database\Query\Builder $query + * @return string + */ + protected function compileRowConstraint($query) + { + $start = $query->offset + 1; + + if ($query->limit > 0) + { + $finish = $query->offset + $query->limit; + + return "between {$start} and {$finish}"; + } + + return ">= {$start}"; + } + + /** + * Compile a common table expression for a query. + * + * @param string $sql + * @param string $constraint + * @return string + */ + protected function compileTableExpression($sql, $constraint) + { + return "select * from ({$sql}) as temp_table where row_num {$constraint}"; + } + + /** + * Compile the "limit" portions of the query. + * + * @param \Illuminate\Database\Query\Builder $query + * @param int $limit + * @return string + */ + protected function compileLimit(Builder $query, $limit) + { + return ''; + } + + /** + * Compile the "offset" portions of the query. + * + * @param \Illuminate\Database\Query\Builder $query + * @param int $offset + * @return string + */ + protected function compileOffset(Builder $query, $offset) + { + return ''; + } + + /** + * Compile a truncate table statement into SQL. + * + * @param \Illuminate\Database\Query\Builder $query + * @return array + */ + public function compileTruncate(Builder $query) + { + return array('truncate table '.$this->wrapTable($query->from) => array()); + } + + /** + * Get the format for database stored dates. + * + * @return string + */ + public function getDateFormat() + { + return 'Y-m-d H:i:s.000'; + } + + /** + * Wrap a single string in keyword identifiers. + * + * @param string $value + * @return string + */ + protected function wrapValue($value) + { + if ($value === '*') return $value; + + return '['.str_replace(']', ']]', $value).']'; + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Database/Query/JoinClause.php b/vendor/laravel/framework/src/Illuminate/Database/Query/JoinClause.php new file mode 100755 index 0000000..d2f7419 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Database/Query/JoinClause.php @@ -0,0 +1,108 @@ +type = $type; + $this->query = $query; + $this->table = $table; + } + + /** + * Add an "on" clause to the join. + * + * @param string $first + * @param string $operator + * @param string $second + * @param string $boolean + * @param bool $where + * @return \Illuminate\Database\Query\JoinClause + */ + public function on($first, $operator, $second, $boolean = 'and', $where = false) + { + $this->clauses[] = compact('first', 'operator', 'second', 'boolean', 'where'); + + if ($where) $this->query->addBinding($second); + + return $this; + } + + /** + * Add an "or on" clause to the join. + * + * @param string $first + * @param string $operator + * @param string $second + * @return \Illuminate\Database\Query\JoinClause + */ + public function orOn($first, $operator, $second) + { + return $this->on($first, $operator, $second, 'or'); + } + + /** + * Add an "on where" clause to the join. + * + * @param string $first + * @param string $operator + * @param string $second + * @param string $boolean + * @return \Illuminate\Database\Query\JoinClause + */ + public function where($first, $operator, $second, $boolean = 'and') + { + return $this->on($first, $operator, $second, $boolean, true); + } + + /** + * Add an "or on where" clause to the join. + * + * @param string $first + * @param string $operator + * @param string $second + * @param string $boolean + * @return \Illuminate\Database\Query\JoinClause + */ + public function orWhere($first, $operator, $second) + { + return $this->on($first, $operator, $second, 'or', true); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Database/Query/Processors/MySqlProcessor.php b/vendor/laravel/framework/src/Illuminate/Database/Query/Processors/MySqlProcessor.php new file mode 100755 index 0000000..dd2f4d8 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Database/Query/Processors/MySqlProcessor.php @@ -0,0 +1,16 @@ +column_name; }, $results); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Database/Query/Processors/PostgresProcessor.php b/vendor/laravel/framework/src/Illuminate/Database/Query/Processors/PostgresProcessor.php new file mode 100755 index 0000000..87ef347 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Database/Query/Processors/PostgresProcessor.php @@ -0,0 +1,40 @@ +getConnection()->select($sql, $values); + + $sequence = $sequence ?: 'id'; + + $result = (array) $results[0]; + + $id = $result[$sequence]; + + return is_numeric($id) ? (int) $id : $id; + } + + /** + * Process the results of a column listing query. + * + * @param array $results + * @return array + */ + public function processColumnListing($results) + { + return array_values(array_map(function($r) { return $r->column_name; }, $results)); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Database/Query/Processors/Processor.php b/vendor/laravel/framework/src/Illuminate/Database/Query/Processors/Processor.php new file mode 100755 index 0000000..b960092 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Database/Query/Processors/Processor.php @@ -0,0 +1,48 @@ +getConnection()->insert($sql, $values); + + $id = $query->getConnection()->getPdo()->lastInsertId($sequence); + + return is_numeric($id) ? (int) $id : $id; + } + + /** + * Process the results of a column listing query. + * + * @param array $results + * @return array + */ + public function processColumnListing($results) + { + return $results; + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Database/Query/Processors/SQLiteProcessor.php b/vendor/laravel/framework/src/Illuminate/Database/Query/Processors/SQLiteProcessor.php new file mode 100755 index 0000000..dbd3e7e --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Database/Query/Processors/SQLiteProcessor.php @@ -0,0 +1,16 @@ +name; }, $results)); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Database/Query/Processors/SqlServerProcessor.php b/vendor/laravel/framework/src/Illuminate/Database/Query/Processors/SqlServerProcessor.php new file mode 100755 index 0000000..cfdb432 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Database/Query/Processors/SqlServerProcessor.php @@ -0,0 +1,36 @@ +getConnection()->insert($sql, $values); + + $id = $query->getConnection()->getPdo()->lastInsertId(); + + return is_numeric($id) ? (int) $id : $id; + } + + /** + * Process the results of a column listing query. + * + * @param array $results + * @return array + */ + public function processColumnListing($results) + { + return array_values(array_map(function($r) { return $r->name; }, $results)); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Database/QueryException.php b/vendor/laravel/framework/src/Illuminate/Database/QueryException.php new file mode 100755 index 0000000..c73dbf6 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Database/QueryException.php @@ -0,0 +1,76 @@ +sql = $sql; + $this->bindings = $bindings; + $this->previous = $previous; + $this->code = $previous->getCode(); + $this->message = $this->formatMessage($sql, $bindings, $previous); + + if ($previous instanceof PDOException) + { + $this->errorInfo = $previous->errorInfo; + } + } + + /** + * Format the SQL error message. + * + * @param string $sql + * @param array $bindings + * @param \Exception $previous + * @return string + */ + protected function formatMessage($sql, $bindings, $previous) + { + return $previous->getMessage().' (SQL: '.str_replace_array('\?', $bindings, $sql).')'; + } + + /** + * Get the SQL for the query. + * + * @return string + */ + public function getSql() + { + return $this->sql; + } + + /** + * Get the bindings for the query. + * + * @return array + */ + public function getBindings() + { + return $this->bindings; + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Database/README.md b/vendor/laravel/framework/src/Illuminate/Database/README.md new file mode 100755 index 0000000..5009fc0 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Database/README.md @@ -0,0 +1,71 @@ +## Illuminate Database + +The Illuminate Database component is a full database toolkit for PHP, providing an expressive query builder, ActiveRecord style ORM, and schema builder. It currently supports MySQL, Postgres, SQL Server, and SQLite. It also serves as the database layer of the Laravel PHP framework. + +### Usage Instructions + +First, create a new "Capsule" manager instance. Capsule aims to make configuring the library for usage outside of the Laravel framework as easy as possible. + +```PHP +use Illuminate\Database\Capsule\Manager as Capsule; + +$capsule = new Capsule; + +$capsule->addConnection([ + 'driver' => 'mysql', + 'host' => 'localhost', + 'database' => 'database', + 'username' => 'root', + 'password' => 'password', + 'charset' => 'utf8', + 'collation' => 'utf8_unicode_ci', + 'prefix' => '', +]); + +// Set the event dispatcher used by Eloquent models... (optional) +use Illuminate\Events\Dispatcher; +use Illuminate\Container\Container; +$capsule->setEventDispatcher(new Dispatcher(new Container)); + +// Set the cache manager instance used by connections... (optional) +$capsule->setCacheManager(...); + +// Make this Capsule instance available globally via static methods... (optional) +$capsule->setAsGlobal(); + +// Setup the Eloquent ORM... (optional; unless you've used setEventDispatcher()) +$capsule->bootEloquent(); +``` + +Once the Capsule instance has been registered. You may use it like so: + +**Using The Query Builder** + +```PHP +$users = Capsule::table('users')->where('votes', '>', 100)->get(); +``` +Other core methods may be accessed directly from the Capsule in the same manner as from the DB facade: +```PHP +$results = Capsule::select('select * from users where id = ?', array(1)); +``` + +**Using The Schema Builder** + +```PHP +Capsule::schema()->create('users', function($table) +{ + $table->increments('id'); + $table->string('email')->unique(); + $table->timestamps(); +}); +``` + +**Using The Eloquent ORM** + +```PHP +class User extends Illuminate\Database\Eloquent\Model {} + +$users = User::where('votes', '>', 1)->get(); +``` + +For further documentation on using the various database facilities this library provides, consult the [Laravel framework documentation](http://laravel.com/docs). diff --git a/vendor/laravel/framework/src/Illuminate/Database/SQLiteConnection.php b/vendor/laravel/framework/src/Illuminate/Database/SQLiteConnection.php new file mode 100755 index 0000000..86603fc --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Database/SQLiteConnection.php @@ -0,0 +1,49 @@ +withTablePrefix(new QueryGrammar); + } + + /** + * Get the default schema grammar instance. + * + * @return \Illuminate\Database\Schema\Grammars\SQLiteGrammar + */ + protected function getDefaultSchemaGrammar() + { + return $this->withTablePrefix(new SchemaGrammar); + } + + /** + * Get the default post processor instance. + * + * @return \Illuminate\Database\Query\Processors\Processor + */ + protected function getDefaultPostProcessor() + { + return new Query\Processors\SQLiteProcessor; + } + + /** + * Get the Doctrine DBAL driver. + * + * @return \Doctrine\DBAL\Driver\PDOSqlite\Driver + */ + protected function getDoctrineDriver() + { + return new DoctrineDriver; + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Database/Schema/Blueprint.php b/vendor/laravel/framework/src/Illuminate/Database/Schema/Blueprint.php new file mode 100755 index 0000000..9a6ffeb --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Database/Schema/Blueprint.php @@ -0,0 +1,825 @@ +table = $table; + + if ( ! is_null($callback)) $callback($this); + } + + /** + * Execute the blueprint against the database. + * + * @param \Illuminate\Database\Connection $connection + * @param \Illuminate\Database\Schema\Grammars\Grammar $grammar + * @return void + */ + public function build(Connection $connection, Grammar $grammar) + { + foreach ($this->toSql($connection, $grammar) as $statement) + { + $connection->statement($statement); + } + } + + /** + * Get the raw SQL statements for the blueprint. + * + * @param \Illuminate\Database\Connection $connection + * @param \Illuminate\Database\Schema\Grammars\Grammar $grammar + * @return array + */ + public function toSql(Connection $connection, Grammar $grammar) + { + $this->addImpliedCommands(); + + $statements = array(); + + // Each type of command has a corresponding compiler function on the schema + // grammar which is used to build the necessary SQL statements to build + // the blueprint element, so we'll just call that compilers function. + foreach ($this->commands as $command) + { + $method = 'compile'.ucfirst($command->name); + + if (method_exists($grammar, $method)) + { + if ( ! is_null($sql = $grammar->$method($this, $command, $connection))) + { + $statements = array_merge($statements, (array) $sql); + } + } + } + + return $statements; + } + + /** + * Add the commands that are implied by the blueprint. + * + * @return void + */ + protected function addImpliedCommands() + { + if (count($this->columns) > 0 && ! $this->creating()) + { + array_unshift($this->commands, $this->createCommand('add')); + } + + $this->addFluentIndexes(); + } + + /** + * Add the index commands fluently specified on columns. + * + * @return void + */ + protected function addFluentIndexes() + { + foreach ($this->columns as $column) + { + foreach (array('primary', 'unique', 'index') as $index) + { + // If the index has been specified on the given column, but is simply + // equal to "true" (boolean), no name has been specified for this + // index, so we will simply call the index methods without one. + if ($column->$index === true) + { + $this->$index($column->name); + + continue 2; + } + + // If the index has been specified on the column and it is something + // other than boolean true, we will assume a name was provided on + // the index specification, and pass in the name to the method. + elseif (isset($column->$index)) + { + $this->$index($column->name, $column->$index); + + continue 2; + } + } + } + } + + /** + * Determine if the blueprint has a create command. + * + * @return bool + */ + protected function creating() + { + foreach ($this->commands as $command) + { + if ($command->name == 'create') return true; + } + + return false; + } + + /** + * Indicate that the table needs to be created. + * + * @return \Illuminate\Support\Fluent + */ + public function create() + { + return $this->addCommand('create'); + } + + /** + * Indicate that the table should be dropped. + * + * @return \Illuminate\Support\Fluent + */ + public function drop() + { + return $this->addCommand('drop'); + } + + /** + * Indicate that the table should be dropped if it exists. + * + * @return \Illuminate\Support\Fluent + */ + public function dropIfExists() + { + return $this->addCommand('dropIfExists'); + } + + /** + * Indicate that the given columns should be dropped. + * + * @param string|array $columns + * @return \Illuminate\Support\Fluent + */ + public function dropColumn($columns) + { + $columns = is_array($columns) ? $columns : (array) func_get_args(); + + return $this->addCommand('dropColumn', compact('columns')); + } + + /** + * Indicate that the given columns should be renamed. + * + * @param string $from + * @param string $to + * @return \Illuminate\Support\Fluent + */ + public function renameColumn($from, $to) + { + return $this->addCommand('renameColumn', compact('from', 'to')); + } + + /** + * Indicate that the given primary key should be dropped. + * + * @param string|array $index + * @return \Illuminate\Support\Fluent + */ + public function dropPrimary($index = null) + { + return $this->dropIndexCommand('dropPrimary', 'primary', $index); + } + + /** + * Indicate that the given unique key should be dropped. + * + * @param string|array $index + * @return \Illuminate\Support\Fluent + */ + public function dropUnique($index) + { + return $this->dropIndexCommand('dropUnique', 'unique', $index); + } + + /** + * Indicate that the given index should be dropped. + * + * @param string|array $index + * @return \Illuminate\Support\Fluent + */ + public function dropIndex($index) + { + return $this->dropIndexCommand('dropIndex', 'index', $index); + } + + /** + * Indicate that the given foreign key should be dropped. + * + * @param string $index + * @return \Illuminate\Support\Fluent + */ + public function dropForeign($index) + { + return $this->dropIndexCommand('dropForeign', 'foreign', $index); + } + + /** + * Indicate that the timestamp columns should be dropped. + * + * @return void + */ + public function dropTimestamps() + { + $this->dropColumn('created_at', 'updated_at'); + } + + /** + * Indicate that the soft delete column should be dropped. + * + * @return void + */ + public function dropSoftDeletes() + { + $this->dropColumn('deleted_at'); + } + + /** + * Rename the table to a given name. + * + * @param string $to + * @return \Illuminate\Support\Fluent + */ + public function rename($to) + { + return $this->addCommand('rename', compact('to')); + } + + /** + * Specify the primary key(s) for the table. + * + * @param string|array $columns + * @param string $name + * @return \Illuminate\Support\Fluent + */ + public function primary($columns, $name = null) + { + return $this->indexCommand('primary', $columns, $name); + } + + /** + * Specify a unique index for the table. + * + * @param string|array $columns + * @param string $name + * @return \Illuminate\Support\Fluent + */ + public function unique($columns, $name = null) + { + return $this->indexCommand('unique', $columns, $name); + } + + /** + * Specify an index for the table. + * + * @param string|array $columns + * @param string $name + * @return \Illuminate\Support\Fluent + */ + public function index($columns, $name = null) + { + return $this->indexCommand('index', $columns, $name); + } + + /** + * Specify a foreign key for the table. + * + * @param string|array $columns + * @param string $name + * @return \Illuminate\Support\Fluent + */ + public function foreign($columns, $name = null) + { + return $this->indexCommand('foreign', $columns, $name); + } + + /** + * Create a new auto-incrementing integer column on the table. + * + * @param string $column + * @return \Illuminate\Support\Fluent + */ + public function increments($column) + { + return $this->unsignedInteger($column, true); + } + + /** + * Create a new auto-incrementing big integer column on the table. + * + * @param string $column + * @return \Illuminate\Support\Fluent + */ + public function bigIncrements($column) + { + return $this->unsignedBigInteger($column, true); + } + + /** + * Create a new char column on the table. + * + * @param string $column + * @param int $length + * @return \Illuminate\Support\Fluent + */ + public function char($column, $length = 255) + { + return $this->addColumn('char', $column, compact('length')); + } + + /** + * Create a new string column on the table. + * + * @param string $column + * @param int $length + * @return \Illuminate\Support\Fluent + */ + public function string($column, $length = 255) + { + return $this->addColumn('string', $column, compact('length')); + } + + /** + * Create a new text column on the table. + * + * @param string $column + * @return \Illuminate\Support\Fluent + */ + public function text($column) + { + return $this->addColumn('text', $column); + } + + /** + * Create a new medium text column on the table. + * + * @param string $column + * @return \Illuminate\Support\Fluent + */ + public function mediumText($column) + { + return $this->addColumn('mediumText', $column); + } + + /** + * Create a new long text column on the table. + * + * @param string $column + * @return \Illuminate\Support\Fluent + */ + public function longText($column) + { + return $this->addColumn('longText', $column); + } + + /** + * Create a new integer column on the table. + * + * @param string $column + * @param bool $autoIncrement + * @param bool $unsigned + * @return \Illuminate\Support\Fluent + */ + public function integer($column, $autoIncrement = false, $unsigned = false) + { + return $this->addColumn('integer', $column, compact('autoIncrement', 'unsigned')); + } + + /** + * Create a new big integer column on the table. + * + * @param string $column + * @param bool $autoIncrement + * @param bool $unsigned + * @return \Illuminate\Support\Fluent + */ + public function bigInteger($column, $autoIncrement = false, $unsigned = false) + { + return $this->addColumn('bigInteger', $column, compact('autoIncrement', 'unsigned')); + } + + /** + * Create a new medium integer column on the table. + * + * @param string $column + * @param bool $autoIncrement + * @param bool $unsigned + * @return \Illuminate\Support\Fluent + */ + public function mediumInteger($column, $autoIncrement = false, $unsigned = false) + { + return $this->addColumn('mediumInteger', $column, compact('autoIncrement', 'unsigned')); + } + + /** + * Create a new tiny integer column on the table. + * + * @param string $column + * @param bool $autoIncrement + * @param bool $unsigned + * @return \Illuminate\Support\Fluent + */ + public function tinyInteger($column, $autoIncrement = false, $unsigned = false) + { + return $this->addColumn('tinyInteger', $column, compact('autoIncrement', 'unsigned')); + } + + /** + * Create a new small integer column on the table. + * + * @param string $column + * @param bool $autoIncrement + * @param bool $unsigned + * @return \Illuminate\Support\Fluent + */ + public function smallInteger($column, $autoIncrement = false, $unsigned = false) + { + return $this->addColumn('smallInteger', $column, compact('autoIncrement', 'unsigned')); + } + + /** + * Create a new unsigned integer column on the table. + * + * @param string $column + * @param bool $autoIncrement + * @return \Illuminate\Support\Fluent + */ + public function unsignedInteger($column, $autoIncrement = false) + { + return $this->integer($column, $autoIncrement, true); + } + + /** + * Create a new unsigned big integer column on the table. + * + * @param string $column + * @param bool $autoIncrement + * @return \Illuminate\Support\Fluent + */ + public function unsignedBigInteger($column, $autoIncrement = false) + { + return $this->bigInteger($column, $autoIncrement, true); + } + + /** + * Create a new float column on the table. + * + * @param string $column + * @param int $total + * @param int $places + * @return \Illuminate\Support\Fluent + */ + public function float($column, $total = 8, $places = 2) + { + return $this->addColumn('float', $column, compact('total', 'places')); + } + + /** + * Create a new double column on the table. + * + * @param string $column + * @param int|null $total + * @param int|null $places + * @return \Illuminate\Support\Fluent + * + */ + public function double($column, $total = null, $places = null) + { + return $this->addColumn('double', $column, compact('total', 'places')); + } + + /** + * Create a new decimal column on the table. + * + * @param string $column + * @param int $total + * @param int $places + * @return \Illuminate\Support\Fluent + */ + public function decimal($column, $total = 8, $places = 2) + { + return $this->addColumn('decimal', $column, compact('total', 'places')); + } + + /** + * Create a new boolean column on the table. + * + * @param string $column + * @return \Illuminate\Support\Fluent + */ + public function boolean($column) + { + return $this->addColumn('boolean', $column); + } + + /** + * Create a new enum column on the table. + * + * @param string $column + * @param array $allowed + * @return \Illuminate\Support\Fluent + */ + public function enum($column, array $allowed) + { + return $this->addColumn('enum', $column, compact('allowed')); + } + + /** + * Create a new date column on the table. + * + * @param string $column + * @return \Illuminate\Support\Fluent + */ + public function date($column) + { + return $this->addColumn('date', $column); + } + + /** + * Create a new date-time column on the table. + * + * @param string $column + * @return \Illuminate\Support\Fluent + */ + public function dateTime($column) + { + return $this->addColumn('dateTime', $column); + } + + /** + * Create a new time column on the table. + * + * @param string $column + * @return \Illuminate\Support\Fluent + */ + public function time($column) + { + return $this->addColumn('time', $column); + } + + /** + * Create a new timestamp column on the table. + * + * @param string $column + * @return \Illuminate\Support\Fluent + */ + public function timestamp($column) + { + return $this->addColumn('timestamp', $column); + } + + /** + * Add nullable creation and update timestamps to the table. + * + * @return void + */ + public function nullableTimestamps() + { + $this->timestamp('created_at')->nullable(); + + $this->timestamp('updated_at')->nullable(); + } + + /** + * Add creation and update timestamps to the table. + * + * @return void + */ + public function timestamps() + { + $this->timestamp('created_at'); + + $this->timestamp('updated_at'); + } + + /** + * Add a "deleted at" timestamp for the table. + * + * @return void + */ + public function softDeletes() + { + $this->timestamp('deleted_at')->nullable(); + } + + /** + * Create a new binary column on the table. + * + * @param string $column + * @return \Illuminate\Support\Fluent + */ + public function binary($column) + { + return $this->addColumn('binary', $column); + } + + /** + * Add the proper columns for a polymorphic table. + * + * @param string $name + * @return void + */ + public function morphs($name) + { + $this->unsignedInteger("{$name}_id"); + + $this->string("{$name}_type"); + } + + /** + * Create a new drop index command on the blueprint. + * + * @param string $command + * @param string $type + * @param string|array $index + * @return \Illuminate\Support\Fluent + */ + protected function dropIndexCommand($command, $type, $index) + { + $columns = array(); + + // If the given "index" is actually an array of columns, the developer means + // to drop an index merely by specifying the columns involved without the + // conventional name, so we will built the index name from the columns. + if (is_array($index)) + { + $columns = $index; + + $index = $this->createIndexName($type, $columns); + } + + return $this->indexCommand($command, $columns, $index); + } + + /** + * Add a new index command to the blueprint. + * + * @param string $type + * @param string|array $columns + * @param string $index + * @return \Illuminate\Support\Fluent + */ + protected function indexCommand($type, $columns, $index) + { + $columns = (array) $columns; + + // If no name was specified for this index, we will create one using a basic + // convention of the table name, followed by the columns, followed by an + // index type, such as primary or index, which makes the index unique. + if (is_null($index)) + { + $index = $this->createIndexName($type, $columns); + } + + return $this->addCommand($type, compact('index', 'columns')); + } + + /** + * Create a default index name for the table. + * + * @param string $type + * @param array $columns + * @return string + */ + protected function createIndexName($type, array $columns) + { + $index = strtolower($this->table.'_'.implode('_', $columns).'_'.$type); + + return str_replace(array('-', '.'), '_', $index); + } + + /** + * Add a new column to the blueprint. + * + * @param string $type + * @param string $name + * @param array $parameters + * @return \Illuminate\Support\Fluent + */ + protected function addColumn($type, $name, array $parameters = array()) + { + $attributes = array_merge(compact('type', 'name'), $parameters); + + $this->columns[] = $column = new Fluent($attributes); + + return $column; + } + + /** + * Remove a column from the schema blueprint. + * + * @param string $name + * @return \Illuminate\Database\Schema\Blueprint + */ + public function removeColumn($name) + { + $this->columns = array_values(array_filter($this->columns, function($c) use ($name) + { + return $c['attributes']['name'] != $name; + })); + + return $this; + } + + /** + * Add a new command to the blueprint. + * + * @param string $name + * @param array $parameters + * @return \Illuminate\Support\Fluent + */ + protected function addCommand($name, array $parameters = array()) + { + $this->commands[] = $command = $this->createCommand($name, $parameters); + + return $command; + } + + /** + * Create a new Fluent command. + * + * @param string $name + * @param array $parameters + * @return \Illuminate\Support\Fluent + */ + protected function createCommand($name, array $parameters = array()) + { + return new Fluent(array_merge(compact('name'), $parameters)); + } + + /** + * Get the table the blueprint describes. + * + * @return string + */ + public function getTable() + { + return $this->table; + } + + /** + * Get the columns that should be added. + * + * @return array + */ + public function getColumns() + { + return $this->columns; + } + + /** + * Get the commands on the blueprint. + * + * @return array + */ + public function getCommands() + { + return $this->commands; + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Database/Schema/Builder.php b/vendor/laravel/framework/src/Illuminate/Database/Schema/Builder.php new file mode 100755 index 0000000..43891d6 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Database/Schema/Builder.php @@ -0,0 +1,225 @@ +connection = $connection; + $this->grammar = $connection->getSchemaGrammar(); + } + + /** + * Determine if the given table exists. + * + * @param string $table + * @return bool + */ + public function hasTable($table) + { + $sql = $this->grammar->compileTableExists(); + + $table = $this->connection->getTablePrefix().$table; + + return count($this->connection->select($sql, array($table))) > 0; + } + + /** + * Determine if the given table has a given column. + * + * @param string $table + * @param string $column + * @return bool + */ + public function hasColumn($table, $column) + { + $column = strtolower($column); + + return in_array($column, array_map('strtolower', $this->getColumnListing($table))); + } + + /** + * Get the column listing for a given table. + * + * @param string $table + * @return array + */ + public function getColumnListing($table) + { + $table = $this->connection->getTablePrefix().$table; + + $results = $this->connection->select($this->grammar->compileColumnExists($table)); + + return $this->connection->getPostProcessor()->processColumnListing($results); + } + + /** + * Modify a table on the schema. + * + * @param string $table + * @param Closure $callback + * @return \Illuminate\Database\Schema\Blueprint + */ + public function table($table, Closure $callback) + { + $this->build($this->createBlueprint($table, $callback)); + } + + /** + * Create a new table on the schema. + * + * @param string $table + * @param Closure $callback + * @return \Illuminate\Database\Schema\Blueprint + */ + public function create($table, Closure $callback) + { + $blueprint = $this->createBlueprint($table); + + $blueprint->create(); + + $callback($blueprint); + + $this->build($blueprint); + } + + /** + * Drop a table from the schema. + * + * @param string $table + * @return \Illuminate\Database\Schema\Blueprint + */ + public function drop($table) + { + $blueprint = $this->createBlueprint($table); + + $blueprint->drop(); + + $this->build($blueprint); + } + + /** + * Drop a table from the schema if it exists. + * + * @param string $table + * @return \Illuminate\Database\Schema\Blueprint + */ + public function dropIfExists($table) + { + $blueprint = $this->createBlueprint($table); + + $blueprint->dropIfExists(); + + $this->build($blueprint); + } + + /** + * Rename a table on the schema. + * + * @param string $from + * @param string $to + * @return \Illuminate\Database\Schema\Blueprint + */ + public function rename($from, $to) + { + $blueprint = $this->createBlueprint($from); + + $blueprint->rename($to); + + $this->build($blueprint); + } + + /** + * Execute the blueprint to build / modify the table. + * + * @param \Illuminate\Database\Schema\Blueprint $blueprint + * @return void + */ + protected function build(Blueprint $blueprint) + { + $blueprint->build($this->connection, $this->grammar); + } + + /** + * Create a new command set with a Closure. + * + * @param string $table + * @param Closure $callback + * @return \Illuminate\Database\Schema\Blueprint + */ + protected function createBlueprint($table, Closure $callback = null) + { + if (isset($this->resolver)) + { + return call_user_func($this->resolver, $table, $callback); + } + else + { + return new Blueprint($table, $callback); + } + } + + /** + * Get the database connection instance. + * + * @return \Illuminate\Database\Connection + */ + public function getConnection() + { + return $this->connection; + } + + /** + * Set the database connection instance. + * + * @param \Illuminate\Database\Connection + * @return \Illuminate\Database\Schema\Builder + */ + public function setConnection(Connection $connection) + { + $this->connection = $connection; + + return $this; + } + + /** + * Set the Schema Blueprint resolver callback. + * + * @param \Closure $resolver + * @return void + */ + public function blueprintResolver(Closure $resolver) + { + $this->resolver = $resolver; + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Database/Schema/Grammars/Grammar.php b/vendor/laravel/framework/src/Illuminate/Database/Schema/Grammars/Grammar.php new file mode 100755 index 0000000..c5c57cc --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Database/Schema/Grammars/Grammar.php @@ -0,0 +1,269 @@ +getDoctrineSchemaManager(); + + $table = $this->getTablePrefix().$blueprint->getTable(); + + $column = $connection->getDoctrineColumn($table, $command->from); + + $tableDiff = $this->getRenamedDiff($blueprint, $command, $column, $schema); + + return (array) $schema->getDatabasePlatform()->getAlterTableSQL($tableDiff); + } + + /** + * Get a new column instance with the new column name. + * + * @param \Illuminate\Database\Schema\Blueprint $blueprint + * @param \Illuminate\Support\Fluent $command + * @param \Doctrine\DBAL\Schema\Column $column + * @param \Doctrine\DBAL\Schema\AbstractSchemaManager $schema + * @return \Doctrine\DBAL\Schema\TableDiff + */ + protected function getRenamedDiff(Blueprint $blueprint, Fluent $command, Column $column, SchemaManager $schema) + { + $tableDiff = $this->getDoctrineTableDiff($blueprint, $schema); + + return $this->setRenamedColumns($tableDiff, $command, $column); + } + + /** + * Set the renamed columns on the table diff. + * + * @param \Doctrine\DBAL\Schema\TableDiff $tableDiff + * @param \Illuminate\Support\Fluent $command + * @param \Doctrine\DBAL\Schema\Column $column + * @return \Doctrine\DBAL\Schema\TableDiff + */ + protected function setRenamedColumns(TableDiff $tableDiff, Fluent $command, Column $column) + { + $newColumn = new Column($command->to, $column->getType(), $column->toArray()); + + $tableDiff->renamedColumns = array($command->from => $newColumn); + + return $tableDiff; + } + + /** + * Compile a foreign key command. + * + * @param \Illuminate\Database\Schema\Blueprint $blueprint + * @param \Illuminate\Support\Fluent $command + * @return string + */ + public function compileForeign(Blueprint $blueprint, Fluent $command) + { + $table = $this->wrapTable($blueprint); + + $on = $this->wrapTable($command->on); + + // We need to prepare several of the elements of the foreign key definition + // before we can create the SQL, such as wrapping the tables and convert + // an array of columns to comma-delimited strings for the SQL queries. + $columns = $this->columnize($command->columns); + + $onColumns = $this->columnize((array) $command->references); + + $sql = "alter table {$table} add constraint {$command->index} "; + + $sql .= "foreign key ({$columns}) references {$on} ({$onColumns})"; + + // Once we have the basic foreign key creation statement constructed we can + // build out the syntax for what should happen on an update or delete of + // the affected columns, which will get something like "cascade", etc. + if ( ! is_null($command->onDelete)) + { + $sql .= " on delete {$command->onDelete}"; + } + + if ( ! is_null($command->onUpdate)) + { + $sql .= " on update {$command->onUpdate}"; + } + + return $sql; + } + + /** + * Compile the blueprint's column definitions. + * + * @param \Illuminate\Database\Schema\Blueprint $blueprint + * @return array + */ + protected function getColumns(Blueprint $blueprint) + { + $columns = array(); + + foreach ($blueprint->getColumns() as $column) + { + // Each of the column types have their own compiler functions which are tasked + // with turning the column definition into its SQL format for this platform + // used by the connection. The column's modifiers are compiled and added. + $sql = $this->wrap($column).' '.$this->getType($column); + + $columns[] = $this->addModifiers($sql, $blueprint, $column); + } + + return $columns; + } + + /** + * Add the column modifiers to the definition. + * + * @param string $sql + * @param \Illuminate\Database\Schema\Blueprint $blueprint + * @param \Illuminate\Support\Fluent $column + * @return string + */ + protected function addModifiers($sql, Blueprint $blueprint, Fluent $column) + { + foreach ($this->modifiers as $modifier) + { + if (method_exists($this, $method = "modify{$modifier}")) + { + $sql .= $this->{$method}($blueprint, $column); + } + } + + return $sql; + } + + /** + * Get the primary key command if it exists on the blueprint. + * + * @param \Illuminate\Database\Schema\Blueprint $blueprint + * @return \Illuminate\Support\Fluent|null + */ + protected function getCommandByName(Blueprint $blueprint, $name) + { + $commands = $this->getCommandsByName($blueprint, $name); + + if (count($commands) > 0) + { + return reset($commands); + } + } + + /** + * Get all of the commands with a given name. + * + * @param \Illuminate\Database\Schema\Blueprint $blueprint + * @param string $name + * @return array + */ + protected function getCommandsByName(Blueprint $blueprint, $name) + { + return array_filter($blueprint->getCommands(), function($value) use ($name) + { + return $value->name == $name; + }); + } + + /** + * Get the SQL for the column data type. + * + * @param \Illuminate\Support\Fluent $column + * @return string + */ + protected function getType(Fluent $column) + { + return $this->{"type".ucfirst($column->type)}($column); + } + + /** + * Add a prefix to an array of values. + * + * @param string $prefix + * @param array $values + * @return array + */ + public function prefixArray($prefix, array $values) + { + return array_map(function($value) use ($prefix) + { + return $prefix.' '.$value; + + }, $values); + } + + /** + * Wrap a table in keyword identifiers. + * + * @param mixed $table + * @return string + */ + public function wrapTable($table) + { + if ($table instanceof Blueprint) $table = $table->getTable(); + + return parent::wrapTable($table); + } + + /** + * Wrap a value in keyword identifiers. + * + * @param string $value + * @return string + */ + public function wrap($value) + { + if ($value instanceof Fluent) $value = $value->name; + + return parent::wrap($value); + } + + /** + * Format a value so that it can be used in "default" clauses. + * + * @param mixed $value + * @return string + */ + protected function getDefaultValue($value) + { + if ($value instanceof Expression) return $value; + + if (is_bool($value)) return "'".intval($value)."'"; + + return "'".strval($value)."'"; + } + + /** + * Create an empty Doctrine DBAL TableDiff from the Blueprint. + * + * @param \Illuminate\Database\Schema\Blueprint $blueprint + * @param \Doctrine\DBAL\Schema\AbstractSchemaManager $schema + * @return \Doctrine\DBAL\Schema\TableDiff + */ + protected function getDoctrineTableDiff(Blueprint $blueprint, SchemaManager $schema) + { + $table = $this->getTablePrefix().$blueprint->getTable(); + + $tableDiff = new TableDiff($table); + + $tableDiff->fromTable = $schema->listTableDetails($table); + + return $tableDiff; + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Database/Schema/Grammars/MySqlGrammar.php b/vendor/laravel/framework/src/Illuminate/Database/Schema/Grammars/MySqlGrammar.php new file mode 100755 index 0000000..de6d8da --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Database/Schema/Grammars/MySqlGrammar.php @@ -0,0 +1,583 @@ +getColumns($blueprint)); + + $sql = 'create table '.$this->wrapTable($blueprint)." ($columns)"; + + // Once we have the primary SQL, we can add the encoding option to the SQL for + // the table. Then, we can check if a storage engine has been supplied for + // the table. If so, we will add the engine declaration to the SQL query. + $sql = $this->compileCreateEncoding($sql, $connection); + + if (isset($blueprint->engine)) + { + $sql .= ' engine = '.$blueprint->engine; + } + + return $sql; + } + + /** + * Append the character set specifications to a command. + * + * @param string $sql + * @param \Illuminate\Database\Connection $connection + * @return string + */ + protected function compileCreateEncoding($sql, Connection $connection) + { + if ( ! is_null($charset = $connection->getConfig('charset'))) + { + $sql .= ' default character set '.$charset; + } + + if ( ! is_null($collation = $connection->getConfig('collation'))) + { + $sql .= ' collate '.$collation; + } + + return $sql; + } + + /** + * Compile a create table command. + * + * @param \Illuminate\Database\Schema\Blueprint $blueprint + * @param \Illuminate\Support\Fluent $command + * @return string + */ + public function compileAdd(Blueprint $blueprint, Fluent $command) + { + $table = $this->wrapTable($blueprint); + + $columns = $this->prefixArray('add', $this->getColumns($blueprint)); + + return 'alter table '.$table.' '.implode(', ', $columns); + } + + /** + * Compile a primary key command. + * + * @param \Illuminate\Database\Schema\Blueprint $blueprint + * @param \Illuminate\Support\Fluent $command + * @return string + */ + public function compilePrimary(Blueprint $blueprint, Fluent $command) + { + $command->name(null); + + return $this->compileKey($blueprint, $command, 'primary key'); + } + + /** + * Compile a unique key command. + * + * @param \Illuminate\Database\Schema\Blueprint $blueprint + * @param \Illuminate\Support\Fluent $command + * @return string + */ + public function compileUnique(Blueprint $blueprint, Fluent $command) + { + return $this->compileKey($blueprint, $command, 'unique'); + } + + /** + * Compile a plain index key command. + * + * @param \Illuminate\Database\Schema\Blueprint $blueprint + * @param \Illuminate\Support\Fluent $command + * @return string + */ + public function compileIndex(Blueprint $blueprint, Fluent $command) + { + return $this->compileKey($blueprint, $command, 'index'); + } + + /** + * Compile an index creation command. + * + * @param \Illuminate\Database\Schema\Blueprint $blueprint + * @param \Illuminate\Support\Fluent $command + * @param string $type + * @return string + */ + protected function compileKey(Blueprint $blueprint, Fluent $command, $type) + { + $columns = $this->columnize($command->columns); + + $table = $this->wrapTable($blueprint); + + return "alter table {$table} add {$type} {$command->index}($columns)"; + } + + /** + * Compile a drop table command. + * + * @param \Illuminate\Database\Schema\Blueprint $blueprint + * @param \Illuminate\Support\Fluent $command + * @return string + */ + public function compileDrop(Blueprint $blueprint, Fluent $command) + { + return 'drop table '.$this->wrapTable($blueprint); + } + + /** + * Compile a drop table (if exists) command. + * + * @param \Illuminate\Database\Schema\Blueprint $blueprint + * @param \Illuminate\Support\Fluent $command + * @return string + */ + public function compileDropIfExists(Blueprint $blueprint, Fluent $command) + { + return 'drop table if exists '.$this->wrapTable($blueprint); + } + + /** + * Compile a drop column command. + * + * @param \Illuminate\Database\Schema\Blueprint $blueprint + * @param \Illuminate\Support\Fluent $command + * @return string + */ + public function compileDropColumn(Blueprint $blueprint, Fluent $command) + { + $columns = $this->prefixArray('drop', $this->wrapArray($command->columns)); + + $table = $this->wrapTable($blueprint); + + return 'alter table '.$table.' '.implode(', ', $columns); + } + + /** + * Compile a drop primary key command. + * + * @param \Illuminate\Database\Schema\Blueprint $blueprint + * @param \Illuminate\Support\Fluent $command + * @return string + */ + public function compileDropPrimary(Blueprint $blueprint, Fluent $command) + { + return 'alter table '.$this->wrapTable($blueprint).' drop primary key'; + } + + /** + * Compile a drop unique key command. + * + * @param \Illuminate\Database\Schema\Blueprint $blueprint + * @param \Illuminate\Support\Fluent $command + * @return string + */ + public function compileDropUnique(Blueprint $blueprint, Fluent $command) + { + $table = $this->wrapTable($blueprint); + + return "alter table {$table} drop index {$command->index}"; + } + + /** + * Compile a drop index command. + * + * @param \Illuminate\Database\Schema\Blueprint $blueprint + * @param \Illuminate\Support\Fluent $command + * @return string + */ + public function compileDropIndex(Blueprint $blueprint, Fluent $command) + { + $table = $this->wrapTable($blueprint); + + return "alter table {$table} drop index {$command->index}"; + } + + /** + * Compile a drop foreign key command. + * + * @param \Illuminate\Database\Schema\Blueprint $blueprint + * @param \Illuminate\Support\Fluent $command + * @return string + */ + public function compileDropForeign(Blueprint $blueprint, Fluent $command) + { + $table = $this->wrapTable($blueprint); + + return "alter table {$table} drop foreign key {$command->index}"; + } + + /** + * Compile a rename table command. + * + * @param \Illuminate\Database\Schema\Blueprint $blueprint + * @param \Illuminate\Support\Fluent $command + * @return string + */ + public function compileRename(Blueprint $blueprint, Fluent $command) + { + $from = $this->wrapTable($blueprint); + + return "rename table {$from} to ".$this->wrapTable($command->to); + } + + /** + * Create the column definition for a char type. + * + * @param \Illuminate\Support\Fluent $column + * @return string + */ + protected function typeChar(Fluent $column) + { + return "char({$column->length})"; + } + + /** + * Create the column definition for a string type. + * + * @param \Illuminate\Support\Fluent $column + * @return string + */ + protected function typeString(Fluent $column) + { + return "varchar({$column->length})"; + } + + /** + * Create the column definition for a text type. + * + * @param \Illuminate\Support\Fluent $column + * @return string + */ + protected function typeText(Fluent $column) + { + return 'text'; + } + + /** + * Create the column definition for a medium text type. + * + * @param \Illuminate\Support\Fluent $column + * @return string + */ + protected function typeMediumText(Fluent $column) + { + return 'mediumtext'; + } + + /** + * Create the column definition for a long text type. + * + * @param \Illuminate\Support\Fluent $column + * @return string + */ + protected function typeLongText(Fluent $column) + { + return 'longtext'; + } + + /** + * Create the column definition for a big integer type. + * + * @param \Illuminate\Support\Fluent $column + * @return string + */ + protected function typeBigInteger(Fluent $column) + { + return 'bigint'; + } + + /** + * Create the column definition for a integer type. + * + * @param \Illuminate\Support\Fluent $column + * @return string + */ + protected function typeInteger(Fluent $column) + { + return 'int'; + } + + /** + * Create the column definition for a medium integer type. + * + * @param \Illuminate\Support\Fluent $column + * @return string + */ + protected function typeMediumInteger(Fluent $column) + { + return 'mediumint'; + } + + /** + * Create the column definition for a tiny integer type. + * + * @param \Illuminate\Support\Fluent $column + * @return string + */ + protected function typeTinyInteger(Fluent $column) + { + return 'tinyint'; + } + + /** + * Create the column definition for a small integer type. + * + * @param \Illuminate\Support\Fluent $column + * @return string + */ + protected function typeSmallInteger(Fluent $column) + { + return 'smallint'; + } + + /** + * Create the column definition for a float type. + * + * @param \Illuminate\Support\Fluent $column + * @return string + */ + protected function typeFloat(Fluent $column) + { + return "float({$column->total}, {$column->places})"; + } + + /** + * Create the column definition for a double type. + * + * @param \Illuminate\Support\Fluent $column + * @return string + */ + protected function typeDouble(Fluent $column) + { + if ($column->total && $column->places) + { + return "double({$column->total}, {$column->places})"; + } + else + { + return 'double'; + } + } + + /** + * Create the column definition for a decimal type. + * + * @param \Illuminate\Support\Fluent $column + * @return string + */ + protected function typeDecimal(Fluent $column) + { + return "decimal({$column->total}, {$column->places})"; + } + + /** + * Create the column definition for a boolean type. + * + * @param \Illuminate\Support\Fluent $column + * @return string + */ + protected function typeBoolean(Fluent $column) + { + return 'tinyint(1)'; + } + + /** + * Create the column definition for an enum type. + * + * @param \Illuminate\Support\Fluent $column + * @return string + */ + protected function typeEnum(Fluent $column) + { + return "enum('".implode("', '", $column->allowed)."')"; + } + + /** + * Create the column definition for a date type. + * + * @param \Illuminate\Support\Fluent $column + * @return string + */ + protected function typeDate(Fluent $column) + { + return 'date'; + } + + /** + * Create the column definition for a date-time type. + * + * @param \Illuminate\Support\Fluent $column + * @return string + */ + protected function typeDateTime(Fluent $column) + { + return 'datetime'; + } + + /** + * Create the column definition for a time type. + * + * @param \Illuminate\Support\Fluent $column + * @return string + */ + protected function typeTime(Fluent $column) + { + return 'time'; + } + + /** + * Create the column definition for a timestamp type. + * + * @param \Illuminate\Support\Fluent $column + * @return string + */ + protected function typeTimestamp(Fluent $column) + { + if ( ! $column->nullable) return 'timestamp default 0'; + + return 'timestamp'; + } + + /** + * Create the column definition for a binary type. + * + * @param \Illuminate\Support\Fluent $column + * @return string + */ + protected function typeBinary(Fluent $column) + { + return 'blob'; + } + + /** + * Get the SQL for an unsigned column modifier. + * + * @param \Illuminate\Database\Schema\Blueprint $blueprint + * @param \Illuminate\Support\Fluent $column + * @return string|null + */ + protected function modifyUnsigned(Blueprint $blueprint, Fluent $column) + { + if ($column->unsigned) return ' unsigned'; + } + + /** + * Get the SQL for a nullable column modifier. + * + * @param \Illuminate\Database\Schema\Blueprint $blueprint + * @param \Illuminate\Support\Fluent $column + * @return string|null + */ + protected function modifyNullable(Blueprint $blueprint, Fluent $column) + { + return $column->nullable ? ' null' : ' not null'; + } + + /** + * Get the SQL for a default column modifier. + * + * @param \Illuminate\Database\Schema\Blueprint $blueprint + * @param \Illuminate\Support\Fluent $column + * @return string|null + */ + protected function modifyDefault(Blueprint $blueprint, Fluent $column) + { + if ( ! is_null($column->default)) + { + return " default ".$this->getDefaultValue($column->default); + } + } + + /** + * Get the SQL for an auto-increment column modifier. + * + * @param \Illuminate\Database\Schema\Blueprint $blueprint + * @param \Illuminate\Support\Fluent $column + * @return string|null + */ + protected function modifyIncrement(Blueprint $blueprint, Fluent $column) + { + if (in_array($column->type, $this->serials) && $column->autoIncrement) + { + return ' auto_increment primary key'; + } + } + + /** + * Get the SQL for an "after" column modifier. + * + * @param \Illuminate\Database\Schema\Blueprint $blueprint + * @param \Illuminate\Support\Fluent $column + * @return string|null + */ + protected function modifyAfter(Blueprint $blueprint, Fluent $column) + { + if ( ! is_null($column->after)) + { + return ' after '.$this->wrap($column->after); + } + } + + /** + * Wrap a single string in keyword identifiers. + * + * @param string $value + * @return string + */ + protected function wrapValue($value) + { + if ($value === '*') return $value; + + return '`'.str_replace('`', '``', $value).'`'; + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Database/Schema/Grammars/PostgresGrammar.php b/vendor/laravel/framework/src/Illuminate/Database/Schema/Grammars/PostgresGrammar.php new file mode 100755 index 0000000..7691617 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Database/Schema/Grammars/PostgresGrammar.php @@ -0,0 +1,489 @@ +getColumns($blueprint)); + + return 'create table '.$this->wrapTable($blueprint)." ($columns)"; + } + + /** + * Compile a create table command. + * + * @param \Illuminate\Database\Schema\Blueprint $blueprint + * @param \Illuminate\Support\Fluent $command + * @return string + */ + public function compileAdd(Blueprint $blueprint, Fluent $command) + { + $table = $this->wrapTable($blueprint); + + $columns = $this->prefixArray('add column', $this->getColumns($blueprint)); + + return 'alter table '.$table.' '.implode(', ', $columns); + } + + /** + * Compile a primary key command. + * + * @param \Illuminate\Database\Schema\Blueprint $blueprint + * @param \Illuminate\Support\Fluent $command + * @return string + */ + public function compilePrimary(Blueprint $blueprint, Fluent $command) + { + $columns = $this->columnize($command->columns); + + return 'alter table '.$this->wrapTable($blueprint)." add primary key ({$columns})"; + } + + /** + * Compile a unique key command. + * + * @param \Illuminate\Database\Schema\Blueprint $blueprint + * @param \Illuminate\Support\Fluent $command + * @return string + */ + public function compileUnique(Blueprint $blueprint, Fluent $command) + { + $table = $this->wrapTable($blueprint); + + $columns = $this->columnize($command->columns); + + return "alter table $table add constraint {$command->index} unique ($columns)"; + } + + /** + * Compile a plain index key command. + * + * @param \Illuminate\Database\Schema\Blueprint $blueprint + * @param \Illuminate\Support\Fluent $command + * @return string + */ + public function compileIndex(Blueprint $blueprint, Fluent $command) + { + $columns = $this->columnize($command->columns); + + return "create index {$command->index} on ".$this->wrapTable($blueprint)." ({$columns})"; + } + + /** + * Compile a drop table command. + * + * @param \Illuminate\Database\Schema\Blueprint $blueprint + * @param \Illuminate\Support\Fluent $command + * @return string + */ + public function compileDrop(Blueprint $blueprint, Fluent $command) + { + return 'drop table '.$this->wrapTable($blueprint); + } + + /** + * Compile a drop table (if exists) command. + * + * @param \Illuminate\Database\Schema\Blueprint $blueprint + * @param \Illuminate\Support\Fluent $command + * @return string + */ + public function compileDropIfExists(Blueprint $blueprint, Fluent $command) + { + return 'drop table if exists '.$this->wrapTable($blueprint); + } + + /** + * Compile a drop column command. + * + * @param \Illuminate\Database\Schema\Blueprint $blueprint + * @param \Illuminate\Support\Fluent $command + * @return string + */ + public function compileDropColumn(Blueprint $blueprint, Fluent $command) + { + $columns = $this->prefixArray('drop column', $this->wrapArray($command->columns)); + + $table = $this->wrapTable($blueprint); + + return 'alter table '.$table.' '.implode(', ', $columns); + } + + /** + * Compile a drop primary key command. + * + * @param \Illuminate\Database\Schema\Blueprint $blueprint + * @param \Illuminate\Support\Fluent $command + * @return string + */ + public function compileDropPrimary(Blueprint $blueprint, Fluent $command) + { + $table = $blueprint->getTable(); + + return 'alter table '.$this->wrapTable($blueprint)." drop constraint {$table}_pkey"; + } + + /** + * Compile a drop unique key command. + * + * @param \Illuminate\Database\Schema\Blueprint $blueprint + * @param \Illuminate\Support\Fluent $command + * @return string + */ + public function compileDropUnique(Blueprint $blueprint, Fluent $command) + { + $table = $this->wrapTable($blueprint); + + return "alter table {$table} drop constraint {$command->index}"; + } + + /** + * Compile a drop index command. + * + * @param \Illuminate\Database\Schema\Blueprint $blueprint + * @param \Illuminate\Support\Fluent $command + * @return string + */ + public function compileDropIndex(Blueprint $blueprint, Fluent $command) + { + return "drop index {$command->index}"; + } + + /** + * Compile a drop foreign key command. + * + * @param \Illuminate\Database\Schema\Blueprint $blueprint + * @param \Illuminate\Support\Fluent $command + * @return string + */ + public function compileDropForeign(Blueprint $blueprint, Fluent $command) + { + $table = $this->wrapTable($blueprint); + + return "alter table {$table} drop constraint {$command->index}"; + } + + /** + * Compile a rename table command. + * + * @param \Illuminate\Database\Schema\Blueprint $blueprint + * @param \Illuminate\Support\Fluent $command + * @return string + */ + public function compileRename(Blueprint $blueprint, Fluent $command) + { + $from = $this->wrapTable($blueprint); + + return "alter table {$from} rename to ".$this->wrapTable($command->to); + } + + /** + * Create the column definition for a char type. + * + * @param \Illuminate\Support\Fluent $column + * @return string + */ + protected function typeChar(Fluent $column) + { + return "char({$column->length})"; + } + + /** + * Create the column definition for a string type. + * + * @param \Illuminate\Support\Fluent $column + * @return string + */ + protected function typeString(Fluent $column) + { + return "varchar({$column->length})"; + } + + /** + * Create the column definition for a text type. + * + * @param \Illuminate\Support\Fluent $column + * @return string + */ + protected function typeText(Fluent $column) + { + return 'text'; + } + + /** + * Create the column definition for a medium text type. + * + * @param \Illuminate\Support\Fluent $column + * @return string + */ + protected function typeMediumText(Fluent $column) + { + return 'text'; + } + + /** + * Create the column definition for a long text type. + * + * @param \Illuminate\Support\Fluent $column + * @return string + */ + protected function typeLongText(Fluent $column) + { + return 'text'; + } + + /** + * Create the column definition for a integer type. + * + * @param \Illuminate\Support\Fluent $column + * @return string + */ + protected function typeInteger(Fluent $column) + { + return $column->autoIncrement ? 'serial' : 'integer'; + } + + /** + * Create the column definition for a big integer type. + * + * @param \Illuminate\Support\Fluent $column + * @return string + */ + protected function typeBigInteger(Fluent $column) + { + return $column->autoIncrement ? 'bigserial' : 'bigint'; + } + + /** + * Create the column definition for a medium integer type. + * + * @param \Illuminate\Support\Fluent $column + * @return string + */ + protected function typeMediumInteger(Fluent $column) + { + return 'integer'; + } + + /** + * Create the column definition for a tiny integer type. + * + * @param \Illuminate\Support\Fluent $column + * @return string + */ + protected function typeTinyInteger(Fluent $column) + { + return 'smallint'; + } + + /** + * Create the column definition for a small integer type. + * + * @param \Illuminate\Support\Fluent $column + * @return string + */ + protected function typeSmallInteger(Fluent $column) + { + return 'smallint'; + } + + /** + * Create the column definition for a float type. + * + * @param \Illuminate\Support\Fluent $column + * @return string + */ + protected function typeFloat(Fluent $column) + { + return 'real'; + } + + /** + * Create the column definition for a double type. + * + * @param \Illuminate\Support\Fluent $column + * @return string + */ + protected function typeDouble(Fluent $column) + { + return 'double precision'; + } + + /** + * Create the column definition for a decimal type. + * + * @param \Illuminate\Support\Fluent $column + * @return string + */ + protected function typeDecimal(Fluent $column) + { + return "decimal({$column->total}, {$column->places})"; + } + + /** + * Create the column definition for a boolean type. + * + * @param \Illuminate\Support\Fluent $column + * @return string + */ + protected function typeBoolean(Fluent $column) + { + return 'boolean'; + } + + /** + * Create the column definition for an enum type. + * + * @param \Illuminate\Support\Fluent $column + * @return string + */ + protected function typeEnum(Fluent $column) + { + $allowed = array_map(function($a) { return "'".$a."'"; }, $column->allowed); + + return "varchar(255) check (\"{$column->name}\" in (".implode(', ', $allowed)."))"; + } + + /** + * Create the column definition for a date type. + * + * @param \Illuminate\Support\Fluent $column + * @return string + */ + protected function typeDate(Fluent $column) + { + return 'date'; + } + + /** + * Create the column definition for a date-time type. + * + * @param \Illuminate\Support\Fluent $column + * @return string + */ + protected function typeDateTime(Fluent $column) + { + return 'timestamp'; + } + + /** + * Create the column definition for a time type. + * + * @param \Illuminate\Support\Fluent $column + * @return string + */ + protected function typeTime(Fluent $column) + { + return 'time'; + } + + /** + * Create the column definition for a timestamp type. + * + * @param \Illuminate\Support\Fluent $column + * @return string + */ + protected function typeTimestamp(Fluent $column) + { + return 'timestamp'; + } + + /** + * Create the column definition for a binary type. + * + * @param \Illuminate\Support\Fluent $column + * @return string + */ + protected function typeBinary(Fluent $column) + { + return 'bytea'; + } + + /** + * Get the SQL for a nullable column modifier. + * + * @param \Illuminate\Database\Schema\Blueprint $blueprint + * @param \Illuminate\Support\Fluent $column + * @return string|null + */ + protected function modifyNullable(Blueprint $blueprint, Fluent $column) + { + return $column->nullable ? ' null' : ' not null'; + } + + /** + * Get the SQL for a default column modifier. + * + * @param \Illuminate\Database\Schema\Blueprint $blueprint + * @param \Illuminate\Support\Fluent $column + * @return string|null + */ + protected function modifyDefault(Blueprint $blueprint, Fluent $column) + { + if ( ! is_null($column->default)) + { + return " default ".$this->getDefaultValue($column->default); + } + } + + /** + * Get the SQL for an auto-increment column modifier. + * + * @param \Illuminate\Database\Schema\Blueprint $blueprint + * @param \Illuminate\Support\Fluent $column + * @return string|null + */ + protected function modifyIncrement(Blueprint $blueprint, Fluent $column) + { + if (in_array($column->type, $this->serials) && $column->autoIncrement) + { + return ' primary key'; + } + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Database/Schema/Grammars/SQLiteGrammar.php b/vendor/laravel/framework/src/Illuminate/Database/Schema/Grammars/SQLiteGrammar.php new file mode 100755 index 0000000..01be7b1 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Database/Schema/Grammars/SQLiteGrammar.php @@ -0,0 +1,551 @@ +getColumns($blueprint)); + + $sql = 'create table '.$this->wrapTable($blueprint)." ($columns"; + + // SQLite forces primary keys to be added when the table is initially created + // so we will need to check for a primary key commands and add the columns + // to the table's declaration here so they can be created on the tables. + $sql .= (string) $this->addForeignKeys($blueprint); + + $sql .= (string) $this->addPrimaryKeys($blueprint); + + return $sql .= ')'; + } + + /** + * Get the foreign key syntax for a table creation statement. + * + * @param \Illuminate\Database\Schema\Blueprint $blueprint + * @return string|null + */ + protected function addForeignKeys(Blueprint $blueprint) + { + $sql = ''; + + $foreigns = $this->getCommandsByName($blueprint, 'foreign'); + + // Once we have all the foreign key commands for the table creation statement + // we'll loop through each of them and add them to the create table SQL we + // are building, since SQLite needs foreign keys on the tables creation. + foreach ($foreigns as $foreign) + { + $sql .= $this->getForeignKey($foreign); + + if ( ! is_null($foreign->onDelete)) + { + $sql .= " on delete {$foreign->onDelete}"; + } + + if ( ! is_null($foreign->onUpdate)) + { + $sql .= " on update {$foreign->onUpdate}"; + } + } + + return $sql; + } + + /** + * Get the SQL for the foreign key. + * + * @param \Illuminate\Support\Fluent $foreign + * @return string + */ + protected function getForeignKey($foreign) + { + $on = $this->wrapTable($foreign->on); + + // We need to columnize the columns that the foreign key is being defined for + // so that it is a properly formatted list. Once we have done this, we can + // return the foreign key SQL declaration to the calling method for use. + $columns = $this->columnize($foreign->columns); + + $onColumns = $this->columnize((array) $foreign->references); + + return ", foreign key($columns) references $on($onColumns)"; + } + + /** + * Get the primary key syntax for a table creation statement. + * + * @param \Illuminate\Database\Schema\Blueprint $blueprint + * @return string|null + */ + protected function addPrimaryKeys(Blueprint $blueprint) + { + $primary = $this->getCommandByName($blueprint, 'primary'); + + if ( ! is_null($primary)) + { + $columns = $this->columnize($primary->columns); + + return ", primary key ({$columns})"; + } + } + + /** + * Compile alter table commands for adding columns + * + * @param \Illuminate\Database\Schema\Blueprint $blueprint + * @param \Illuminate\Support\Fluent $command + * @return array + */ + public function compileAdd(Blueprint $blueprint, Fluent $command) + { + $table = $this->wrapTable($blueprint); + + $columns = $this->prefixArray('add column', $this->getColumns($blueprint)); + + foreach ($columns as $column) + { + $statements[] = 'alter table '.$table.' '.$column; + } + + return $statements; + } + + /** + * Compile a unique key command. + * + * @param \Illuminate\Database\Schema\Blueprint $blueprint + * @param \Illuminate\Support\Fluent $command + * @return string + */ + public function compileUnique(Blueprint $blueprint, Fluent $command) + { + $columns = $this->columnize($command->columns); + + $table = $this->wrapTable($blueprint); + + return "create unique index {$command->index} on {$table} ({$columns})"; + } + + /** + * Compile a plain index key command. + * + * @param \Illuminate\Database\Schema\Blueprint $blueprint + * @param \Illuminate\Support\Fluent $command + * @return string + */ + public function compileIndex(Blueprint $blueprint, Fluent $command) + { + $columns = $this->columnize($command->columns); + + $table = $this->wrapTable($blueprint); + + return "create index {$command->index} on {$table} ({$columns})"; + } + + /** + * Compile a foreign key command. + * + * @param \Illuminate\Database\Schema\Blueprint $blueprint + * @param \Illuminate\Support\Fluent $command + * @return string + */ + public function compileForeign(Blueprint $blueprint, Fluent $command) + { + // Handled on table creation... + } + + /** + * Compile a drop table command. + * + * @param \Illuminate\Database\Schema\Blueprint $blueprint + * @param \Illuminate\Support\Fluent $command + * @return string + */ + public function compileDrop(Blueprint $blueprint, Fluent $command) + { + return 'drop table '.$this->wrapTable($blueprint); + } + + /** + * Compile a drop table (if exists) command. + * + * @param \Illuminate\Database\Schema\Blueprint $blueprint + * @param \Illuminate\Support\Fluent $command + * @return string + */ + public function compileDropIfExists(Blueprint $blueprint, Fluent $command) + { + return 'drop table if exists '.$this->wrapTable($blueprint); + } + + /** + * Compile a drop column command. + * + * @param \Illuminate\Database\Schema\Blueprint $blueprint + * @param \Illuminate\Support\Fluent $command + * @param \Illuminate\Database\Connection $connection + * @return array + */ + public function compileDropColumn(Blueprint $blueprint, Fluent $command, Connection $connection) + { + $schema = $connection->getDoctrineSchemaManager(); + + $tableDiff = $this->getDoctrineTableDiff($blueprint, $schema); + + foreach ($command->columns as $name) + { + $column = $connection->getDoctrineColumn($blueprint->getTable(), $name); + + $tableDiff->removedColumns[$name] = $column; + } + + return (array) $schema->getDatabasePlatform()->getAlterTableSQL($tableDiff); + } + + /** + * Compile a drop unique key command. + * + * @param \Illuminate\Database\Schema\Blueprint $blueprint + * @param \Illuminate\Support\Fluent $command + * @return string + */ + public function compileDropUnique(Blueprint $blueprint, Fluent $command) + { + return "drop index {$command->index}"; + } + + /** + * Compile a drop index command. + * + * @param \Illuminate\Database\Schema\Blueprint $blueprint + * @param \Illuminate\Support\Fluent $command + * @return string + */ + public function compileDropIndex(Blueprint $blueprint, Fluent $command) + { + return "drop index {$command->index}"; + } + + /** + * Compile a rename table command. + * + * @param \Illuminate\Database\Schema\Blueprint $blueprint + * @param \Illuminate\Support\Fluent $command + * @return string + */ + public function compileRename(Blueprint $blueprint, Fluent $command) + { + $from = $this->wrapTable($blueprint); + + return "alter table {$from} rename to ".$this->wrapTable($command->to); + } + + /** + * Create the column definition for a char type. + * + * @param \Illuminate\Support\Fluent $column + * @return string + */ + protected function typeChar(Fluent $column) + { + return 'varchar'; + } + + /** + * Create the column definition for a string type. + * + * @param \Illuminate\Support\Fluent $column + * @return string + */ + protected function typeString(Fluent $column) + { + return 'varchar'; + } + + /** + * Create the column definition for a text type. + * + * @param \Illuminate\Support\Fluent $column + * @return string + */ + protected function typeText(Fluent $column) + { + return 'text'; + } + + /** + * Create the column definition for a medium text type. + * + * @param \Illuminate\Support\Fluent $column + * @return string + */ + protected function typeMediumText(Fluent $column) + { + return 'text'; + } + + /** + * Create the column definition for a long text type. + * + * @param \Illuminate\Support\Fluent $column + * @return string + */ + protected function typeLongText(Fluent $column) + { + return 'text'; + } + + /** + * Create the column definition for a integer type. + * + * @param \Illuminate\Support\Fluent $column + * @return string + */ + protected function typeInteger(Fluent $column) + { + return 'integer'; + } + + /** + * Create the column definition for a big integer type. + * + * @param \Illuminate\Support\Fluent $column + * @return string + */ + protected function typeBigInteger(Fluent $column) + { + return 'integer'; + } + + /** + * Create the column definition for a medium integer type. + * + * @param \Illuminate\Support\Fluent $column + * @return string + */ + protected function typeMediumInteger(Fluent $column) + { + return 'integer'; + } + + /** + * Create the column definition for a tiny integer type. + * + * @param \Illuminate\Support\Fluent $column + * @return string + */ + protected function typeTinyInteger(Fluent $column) + { + return 'integer'; + } + + /** + * Create the column definition for a small integer type. + * + * @param \Illuminate\Support\Fluent $column + * @return string + */ + protected function typeSmallInteger(Fluent $column) + { + return 'integer'; + } + + /** + * Create the column definition for a float type. + * + * @param \Illuminate\Support\Fluent $column + * @return string + */ + protected function typeFloat(Fluent $column) + { + return 'float'; + } + + /** + * Create the column definition for a double type. + * + * @param \Illuminate\Support\Fluent $column + * @return string + */ + protected function typeDouble(Fluent $column) + { + return 'float'; + } + + /** + * Create the column definition for a decimal type. + * + * @param \Illuminate\Support\Fluent $column + * @return string + */ + protected function typeDecimal(Fluent $column) + { + return 'float'; + } + + /** + * Create the column definition for a boolean type. + * + * @param \Illuminate\Support\Fluent $column + * @return string + */ + protected function typeBoolean(Fluent $column) + { + return 'tinyint'; + } + + /** + * Create the column definition for an enum type. + * + * @param \Illuminate\Support\Fluent $column + * @return string + */ + protected function typeEnum(Fluent $column) + { + return 'varchar'; + } + + /** + * Create the column definition for a date type. + * + * @param \Illuminate\Support\Fluent $column + * @return string + */ + protected function typeDate(Fluent $column) + { + return 'date'; + } + + /** + * Create the column definition for a date-time type. + * + * @param \Illuminate\Support\Fluent $column + * @return string + */ + protected function typeDateTime(Fluent $column) + { + return 'datetime'; + } + + /** + * Create the column definition for a time type. + * + * @param \Illuminate\Support\Fluent $column + * @return string + */ + protected function typeTime(Fluent $column) + { + return 'time'; + } + + /** + * Create the column definition for a timestamp type. + * + * @param \Illuminate\Support\Fluent $column + * @return string + */ + protected function typeTimestamp(Fluent $column) + { + return 'datetime'; + } + + /** + * Create the column definition for a binary type. + * + * @param \Illuminate\Support\Fluent $column + * @return string + */ + protected function typeBinary(Fluent $column) + { + return 'blob'; + } + + /** + * Get the SQL for a nullable column modifier. + * + * @param \Illuminate\Database\Schema\Blueprint $blueprint + * @param \Illuminate\Support\Fluent $column + * @return string|null + */ + protected function modifyNullable(Blueprint $blueprint, Fluent $column) + { + return $column->nullable ? ' null' : ' not null'; + } + + /** + * Get the SQL for a default column modifier. + * + * @param \Illuminate\Database\Schema\Blueprint $blueprint + * @param \Illuminate\Support\Fluent $column + * @return string|null + */ + protected function modifyDefault(Blueprint $blueprint, Fluent $column) + { + if ( ! is_null($column->default)) + { + return " default ".$this->getDefaultValue($column->default); + } + } + + /** + * Get the SQL for an auto-increment column modifier. + * + * @param \Illuminate\Database\Schema\Blueprint $blueprint + * @param \Illuminate\Support\Fluent $column + * @return string|null + */ + protected function modifyIncrement(Blueprint $blueprint, Fluent $column) + { + if (in_array($column->type, $this->serials) && $column->autoIncrement) + { + return ' primary key autoincrement'; + } + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Database/Schema/Grammars/SqlServerGrammar.php b/vendor/laravel/framework/src/Illuminate/Database/Schema/Grammars/SqlServerGrammar.php new file mode 100755 index 0000000..751969c --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Database/Schema/Grammars/SqlServerGrammar.php @@ -0,0 +1,486 @@ +getColumns($blueprint)); + + return 'create table '.$this->wrapTable($blueprint)." ($columns)"; + } + + /** + * Compile a create table command. + * + * @param \Illuminate\Database\Schema\Blueprint $blueprint + * @param \Illuminate\Support\Fluent $command + * @return string + */ + public function compileAdd(Blueprint $blueprint, Fluent $command) + { + $table = $this->wrapTable($blueprint); + + $columns = $this->getColumns($blueprint); + + return 'alter table '.$table.' add '.implode(', ', $columns); + } + + /** + * Compile a primary key command. + * + * @param \Illuminate\Database\Schema\Blueprint $blueprint + * @param \Illuminate\Support\Fluent $command + * @return string + */ + public function compilePrimary(Blueprint $blueprint, Fluent $command) + { + $columns = $this->columnize($command->columns); + + $table = $this->wrapTable($blueprint); + + return "alter table {$table} add constraint {$command->index} primary key ({$columns})"; + } + + /** + * Compile a unique key command. + * + * @param \Illuminate\Database\Schema\Blueprint $blueprint + * @param \Illuminate\Support\Fluent $command + * @return string + */ + public function compileUnique(Blueprint $blueprint, Fluent $command) + { + $columns = $this->columnize($command->columns); + + $table = $this->wrapTable($blueprint); + + return "create unique index {$command->index} on {$table} ({$columns})"; + } + + /** + * Compile a plain index key command. + * + * @param \Illuminate\Database\Schema\Blueprint $blueprint + * @param \Illuminate\Support\Fluent $command + * @return string + */ + public function compileIndex(Blueprint $blueprint, Fluent $command) + { + $columns = $this->columnize($command->columns); + + $table = $this->wrapTable($blueprint); + + return "create index {$command->index} on {$table} ({$columns})"; + } + + /** + * Compile a drop table command. + * + * @param \Illuminate\Database\Schema\Blueprint $blueprint + * @param \Illuminate\Support\Fluent $command + * @return string + */ + public function compileDrop(Blueprint $blueprint, Fluent $command) + { + return 'drop table '.$this->wrapTable($blueprint); + } + + /** + * Compile a drop column command. + * + * @param \Illuminate\Database\Schema\Blueprint $blueprint + * @param \Illuminate\Support\Fluent $command + * @return string + */ + public function compileDropColumn(Blueprint $blueprint, Fluent $command) + { + $columns = $this->wrapArray($command->columns); + + $table = $this->wrapTable($blueprint); + + return 'alter table '.$table.' drop column '.implode(', ', $columns); + } + + /** + * Compile a drop primary key command. + * + * @param \Illuminate\Database\Schema\Blueprint $blueprint + * @param \Illuminate\Support\Fluent $command + * @return string + */ + public function compileDropPrimary(Blueprint $blueprint, Fluent $command) + { + $table = $blueprint->getTable(); + + $table = $this->wrapTable($blueprint); + + return "alter table {$table} drop constraint {$command->index}"; + } + + /** + * Compile a drop unique key command. + * + * @param \Illuminate\Database\Schema\Blueprint $blueprint + * @param \Illuminate\Support\Fluent $command + * @return string + */ + public function compileDropUnique(Blueprint $blueprint, Fluent $command) + { + $table = $this->wrapTable($blueprint); + + return "drop index {$command->index} on {$table}"; + } + + /** + * Compile a drop index command. + * + * @param \Illuminate\Database\Schema\Blueprint $blueprint + * @param \Illuminate\Support\Fluent $command + * @return string + */ + public function compileDropIndex(Blueprint $blueprint, Fluent $command) + { + $table = $this->wrapTable($blueprint); + + return "drop index {$command->index} on {$table}"; + } + + /** + * Compile a drop foreign key command. + * + * @param \Illuminate\Database\Schema\Blueprint $blueprint + * @param \Illuminate\Support\Fluent $command + * @return string + */ + public function compileDropForeign(Blueprint $blueprint, Fluent $command) + { + $table = $this->wrapTable($blueprint); + + return "alter table {$table} drop constraint {$command->index}"; + } + + /** + * Compile a rename table command. + * + * @param \Illuminate\Database\Schema\Blueprint $blueprint + * @param \Illuminate\Support\Fluent $command + * @return string + */ + public function compileRename(Blueprint $blueprint, Fluent $command) + { + $from = $this->wrapTable($blueprint); + + return "sp_rename {$from}, ".$this->wrapTable($command->to); + } + + /** + * Create the column definition for a char type. + * + * @param \Illuminate\Support\Fluent $column + * @return string + */ + protected function typeChar(Fluent $column) + { + return "nchar({$column->length})"; + } + + + /** + * Create the column definition for a string type. + * + * @param \Illuminate\Support\Fluent $column + * @return string + */ + protected function typeString(Fluent $column) + { + return "nvarchar({$column->length})"; + } + + /** + * Create the column definition for a text type. + * + * @param \Illuminate\Support\Fluent $column + * @return string + */ + protected function typeText(Fluent $column) + { + return 'nvarchar(max)'; + } + + /** + * Create the column definition for a medium text type. + * + * @param \Illuminate\Support\Fluent $column + * @return string + */ + protected function typeMediumText(Fluent $column) + { + return 'nvarchar(max)'; + } + + /** + * Create the column definition for a long text type. + * + * @param \Illuminate\Support\Fluent $column + * @return string + */ + protected function typeLongText(Fluent $column) + { + return 'nvarchar(max)'; + } + + /** + * Create the column definition for a integer type. + * + * @param \Illuminate\Support\Fluent $column + * @return string + */ + protected function typeInteger(Fluent $column) + { + return 'int'; + } + + /** + * Create the column definition for a big integer type. + * + * @param \Illuminate\Support\Fluent $column + * @return string + */ + protected function typeBigInteger(Fluent $column) + { + return 'bigint'; + } + + /** + * Create the column definition for a medium integer type. + * + * @param \Illuminate\Support\Fluent $column + * @return string + */ + protected function typeMediumInteger(Fluent $column) + { + return 'int'; + } + + /** + * Create the column definition for a tiny integer type. + * + * @param \Illuminate\Support\Fluent $column + * @return string + */ + protected function typeTinyInteger(Fluent $column) + { + return 'tinyint'; + } + + /** + * Create the column definition for a small integer type. + * + * @param \Illuminate\Support\Fluent $column + * @return string + */ + protected function typeSmallInteger(Fluent $column) + { + return 'smallint'; + } + + /** + * Create the column definition for a float type. + * + * @param \Illuminate\Support\Fluent $column + * @return string + */ + protected function typeFloat(Fluent $column) + { + return 'float'; + } + + /** + * Create the column definition for a double type. + * + * @param \Illuminate\Support\Fluent $column + * @return string + */ + protected function typeDouble(Fluent $column) + { + return 'float'; + } + + /** + * Create the column definition for a decimal type. + * + * @param \Illuminate\Support\Fluent $column + * @return string + */ + protected function typeDecimal(Fluent $column) + { + return "decimal({$column->total}, {$column->places})"; + } + + /** + * Create the column definition for a boolean type. + * + * @param \Illuminate\Support\Fluent $column + * @return string + */ + protected function typeBoolean(Fluent $column) + { + return 'bit'; + } + + /** + * Create the column definition for an enum type. + * + * @param \Illuminate\Support\Fluent $column + * @return string + */ + protected function typeEnum(Fluent $column) + { + return 'nvarchar(255)'; + } + + /** + * Create the column definition for a date type. + * + * @param \Illuminate\Support\Fluent $column + * @return string + */ + protected function typeDate(Fluent $column) + { + return 'date'; + } + + /** + * Create the column definition for a date-time type. + * + * @param \Illuminate\Support\Fluent $column + * @return string + */ + protected function typeDateTime(Fluent $column) + { + return 'datetime'; + } + + /** + * Create the column definition for a time type. + * + * @param \Illuminate\Support\Fluent $column + * @return string + */ + protected function typeTime(Fluent $column) + { + return 'time'; + } + + /** + * Create the column definition for a timestamp type. + * + * @param \Illuminate\Support\Fluent $column + * @return string + */ + protected function typeTimestamp(Fluent $column) + { + return 'datetime'; + } + + /** + * Create the column definition for a binary type. + * + * @param \Illuminate\Support\Fluent $column + * @return string + */ + protected function typeBinary(Fluent $column) + { + return 'varbinary(max)'; + } + + /** + * Get the SQL for a nullable column modifier. + * + * @param \Illuminate\Database\Schema\Blueprint $blueprint + * @param \Illuminate\Support\Fluent $column + * @return string|null + */ + protected function modifyNullable(Blueprint $blueprint, Fluent $column) + { + return $column->nullable ? ' null' : ' not null'; + } + + /** + * Get the SQL for a default column modifier. + * + * @param \Illuminate\Database\Schema\Blueprint $blueprint + * @param \Illuminate\Support\Fluent $column + * @return string|null + */ + protected function modifyDefault(Blueprint $blueprint, Fluent $column) + { + if ( ! is_null($column->default)) + { + return " default ".$this->getDefaultValue($column->default); + } + } + + /** + * Get the SQL for an auto-increment column modifier. + * + * @param \Illuminate\Database\Schema\Blueprint $blueprint + * @param \Illuminate\Support\Fluent $column + * @return string|null + */ + protected function modifyIncrement(Blueprint $blueprint, Fluent $column) + { + if (in_array($column->type, $this->serials) && $column->autoIncrement) + { + return ' identity primary key'; + } + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Database/Schema/MySqlBuilder.php b/vendor/laravel/framework/src/Illuminate/Database/Schema/MySqlBuilder.php new file mode 100755 index 0000000..7472681 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Database/Schema/MySqlBuilder.php @@ -0,0 +1,41 @@ +grammar->compileTableExists(); + + $database = $this->connection->getDatabaseName(); + + $table = $this->connection->getTablePrefix().$table; + + return count($this->connection->select($sql, array($database, $table))) > 0; + } + + /** + * Get the column listing for a given table. + * + * @param string $table + * @return array + */ + public function getColumnListing($table) + { + $sql = $this->grammar->compileColumnExists(); + + $database = $this->connection->getDatabaseName(); + + $table = $this->connection->getTablePrefix().$table; + + $results = $this->connection->select($sql, array($database, $table)); + + return $this->connection->getPostProcessor()->processColumnListing($results); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Database/SeedServiceProvider.php b/vendor/laravel/framework/src/Illuminate/Database/SeedServiceProvider.php new file mode 100755 index 0000000..be92913 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Database/SeedServiceProvider.php @@ -0,0 +1,55 @@ +registerSeedCommand(); + + $this->app->bindShared('seeder', function($app) + { + return new Seeder; + }); + + $this->commands('command.seed'); + } + + /** + * Register the seed console command. + * + * @return void + */ + protected function registerSeedCommand() + { + $this->app->bindShared('command.seed', function($app) + { + return new SeedCommand($app['db']); + }); + } + + /** + * Get the services provided by the provider. + * + * @return array + */ + public function provides() + { + return array('seeder', 'command.seed'); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Database/Seeder.php b/vendor/laravel/framework/src/Illuminate/Database/Seeder.php new file mode 100755 index 0000000..547cfb9 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Database/Seeder.php @@ -0,0 +1,98 @@ +resolve($class)->run(); + + if (isset($this->command)) + { + $this->command->getOutput()->writeln("Seeded: $class"); + } + } + + /** + * Resolve an instance of the given seeder class. + * + * @param string $class + * @return \Illuminate\Database\Seeder + */ + protected function resolve($class) + { + if (isset($this->container)) + { + $instance = $this->container->make($class); + + $instance->setContainer($this->container); + } + else + { + $instance = new $class; + } + + if (isset($this->command)) + { + $instance->setCommand($this->command); + } + + return $instance; + } + + /** + * Set the IoC container instance. + * + * @param \Illuminate\Container\Container $container + * @return \Illuminate\Database\Seeder + */ + public function setContainer(Container $container) + { + $this->container = $container; + + return $this; + } + + /** + * Set the console command instance. + * + * @param \Illuminate\Console\Command $command + * @return \Illuminate\Database\Seeder + */ + public function setCommand(Command $command) + { + $this->command = $command; + + return $this; + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Database/SqlServerConnection.php b/vendor/laravel/framework/src/Illuminate/Database/SqlServerConnection.php new file mode 100755 index 0000000..47d3ac2 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Database/SqlServerConnection.php @@ -0,0 +1,91 @@ +getDriverName() == 'sqlsrv') + { + return parent::transaction($callback); + } + + $this->pdo->exec('BEGIN TRAN'); + + // We'll simply execute the given callback within a try / catch block + // and if we catch any exception we can rollback the transaction + // so that none of the changes are persisted to the database. + try + { + $result = $callback($this); + + $this->pdo->exec('COMMIT TRAN'); + } + + // If we catch an exception, we will roll back so nothing gets messed + // up in the database. Then we'll re-throw the exception so it can + // be handled how the developer sees fit for their applications. + catch (\Exception $e) + { + $this->pdo->exec('ROLLBACK TRAN'); + + throw $e; + } + + return $result; + } + + /** + * Get the default query grammar instance. + * + * @return \Illuminate\Database\Query\Grammars\SqlServerGrammar + */ + protected function getDefaultQueryGrammar() + { + return $this->withTablePrefix(new QueryGrammar); + } + + /** + * Get the default schema grammar instance. + * + * @return \Illuminate\Database\Schema\Grammars\SqlServerGrammar + */ + protected function getDefaultSchemaGrammar() + { + return $this->withTablePrefix(new SchemaGrammar); + } + + /** + * Get the default post processor instance. + * + * @return \Illuminate\Database\Query\Processors\Processor + */ + protected function getDefaultPostProcessor() + { + return new SqlServerProcessor; + } + + /** + * Get the Doctrine DBAL Driver. + * + * @return \Doctrine\DBAL\Driver\PDOSqlsrv\Driver + */ + protected function getDoctrineDriver() + { + return new DoctrineDriver; + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Database/composer.json b/vendor/laravel/framework/src/Illuminate/Database/composer.json new file mode 100755 index 0000000..372efb5 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Database/composer.json @@ -0,0 +1,39 @@ +{ + "name": "illuminate/database", + "license": "MIT", + "keywords": ["laravel", "database", "sql", "orm"], + "authors": [ + { + "name": "Taylor Otwell", + "email": "taylorotwell@gmail.com" + } + ], + "require": { + "php": ">=5.3.0", + "illuminate/container": "4.1.*", + "illuminate/events": "4.1.*", + "illuminate/support": "4.1.*", + "nesbot/carbon": "1.*" + }, + "require-dev": { + "illuminate/cache": "4.1.*", + "illuminate/console": "4.1.*", + "illuminate/filesystem": "4.1.*", + "illuminate/pagination": "4.1.*", + "illuminate/support": "4.1.*", + "mockery/mockery": "0.9.*", + "phpunit/phpunit": "4.0.*" + }, + "autoload": { + "psr-0": { + "Illuminate\\Database": "" + } + }, + "target-dir": "Illuminate/Database", + "extra": { + "branch-alias": { + "dev-master": "4.1-dev" + } + }, + "minimum-stability": "dev" +} diff --git a/vendor/laravel/framework/src/Illuminate/Encryption/Encrypter.php b/vendor/laravel/framework/src/Illuminate/Encryption/Encrypter.php new file mode 100755 index 0000000..c59c016 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Encryption/Encrypter.php @@ -0,0 +1,280 @@ +key = $key; + } + + /** + * Encrypt the given value. + * + * @param string $value + * @return string + */ + public function encrypt($value) + { + $iv = mcrypt_create_iv($this->getIvSize(), $this->getRandomizer()); + + $value = base64_encode($this->padAndMcrypt($value, $iv)); + + // Once we have the encrypted value we will go ahead base64_encode the input + // vector and create the MAC for the encrypted value so we can verify its + // authenticity. Then, we'll JSON encode the data in a "payload" array. + $mac = $this->hash($iv = base64_encode($iv), $value); + + return base64_encode(json_encode(compact('iv', 'value', 'mac'))); + } + + /** + * Pad and use mcrypt on the given value and input vector. + * + * @param string $value + * @param string $iv + * @return string + */ + protected function padAndMcrypt($value, $iv) + { + $value = $this->addPadding(serialize($value)); + + return mcrypt_encrypt($this->cipher, $this->key, $value, $this->mode, $iv); + } + + /** + * Decrypt the given value. + * + * @param string $payload + * @return string + */ + public function decrypt($payload) + { + $payload = $this->getJsonPayload($payload); + + // We'll go ahead and remove the PKCS7 padding from the encrypted value before + // we decrypt it. Once we have the de-padded value, we will grab the vector + // and decrypt the data, passing back the unserialized from of the value. + $value = base64_decode($payload['value']); + + $iv = base64_decode($payload['iv']); + + return unserialize($this->stripPadding($this->mcryptDecrypt($value, $iv))); + } + + /** + * Run the mcrypt decryption routine for the value. + * + * @param string $value + * @param string $iv + * @return string + */ + protected function mcryptDecrypt($value, $iv) + { + return mcrypt_decrypt($this->cipher, $this->key, $value, $this->mode, $iv); + } + + /** + * Get the JSON array from the given payload. + * + * @param string $payload + * @return array + * + * @throws DecryptException + */ + protected function getJsonPayload($payload) + { + $payload = json_decode(base64_decode($payload), true); + + // If the payload is not valid JSON or does not have the proper keys set we will + // assume it is invalid and bail out of the routine since we will not be able + // to decrypt the given value. We'll also check the MAC for this encryption. + if ( ! $payload || $this->invalidPayload($payload)) + { + throw new DecryptException("Invalid data."); + } + + if ( ! $this->validMac($payload)) + { + throw new DecryptException("MAC is invalid."); + } + + return $payload; + } + + /** + * Determine if the MAC for the given payload is valid. + * + * @param array $payload + * @return bool + */ + protected function validMac(array $payload) + { + $bytes = with(new SecureRandom)->nextBytes(16); + + $calcMac = hash_hmac('sha256', $this->hash($payload['iv'], $payload['value']), $bytes, true); + + return StringUtils::equals(hash_hmac('sha256', $payload['mac'], $bytes, true), $calcMac); + } + + /** + * Create a MAC for the given value. + * + * @param string $iv + * @param string $value + * @return string + */ + protected function hash($iv, $value) + { + return hash_hmac('sha256', $iv.$value, $this->key); + } + + /** + * Add PKCS7 padding to a given value. + * + * @param string $value + * @return string + */ + protected function addPadding($value) + { + $pad = $this->block - (strlen($value) % $this->block); + + return $value.str_repeat(chr($pad), $pad); + } + + /** + * Remove the padding from the given value. + * + * @param string $value + * @return string + */ + protected function stripPadding($value) + { + $pad = ord($value[($len = strlen($value)) - 1]); + + return $this->paddingIsValid($pad, $value) ? substr($value, 0, $len - $pad) : $value; + } + + /** + * Determine if the given padding for a value is valid. + * + * @param string $pad + * @param string $value + * @return bool + */ + protected function paddingIsValid($pad, $value) + { + $beforePad = strlen($value) - $pad; + + return substr($value, $beforePad) == str_repeat(substr($value, -1), $pad); + } + + /** + * Verify that the encryption payload is valid. + * + * @param array|mixed $data + * @return bool + */ + protected function invalidPayload($data) + { + return ! is_array($data) || ! isset($data['iv']) || ! isset($data['value']) || ! isset($data['mac']); + } + + /** + * Get the IV size for the cipher. + * + * @return int + */ + protected function getIvSize() + { + return mcrypt_get_iv_size($this->cipher, $this->mode); + } + + /** + * Get the random data source available for the OS. + * + * @return int + */ + protected function getRandomizer() + { + if (defined('MCRYPT_DEV_URANDOM')) return MCRYPT_DEV_URANDOM; + + if (defined('MCRYPT_DEV_RANDOM')) return MCRYPT_DEV_RANDOM; + + mt_srand(); + + return MCRYPT_RAND; + } + + /** + * Set the encryption key. + * + * @param string $key + * @return void + */ + public function setKey($key) + { + $this->key = $key; + } + + /** + * Set the encryption cipher. + * + * @param string $cipher + * @return void + */ + public function setCipher($cipher) + { + $this->cipher = $cipher; + } + + /** + * Set the encryption mode. + * + * @param string $mode + * @return void + */ + public function setMode($mode) + { + $this->mode = $mode; + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Encryption/EncryptionServiceProvider.php b/vendor/laravel/framework/src/Illuminate/Encryption/EncryptionServiceProvider.php new file mode 100755 index 0000000..ed0befa --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Encryption/EncryptionServiceProvider.php @@ -0,0 +1,20 @@ +app->bindShared('encrypter', function($app) + { + return new Encrypter($app['config']['app.key']); + }); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Encryption/composer.json b/vendor/laravel/framework/src/Illuminate/Encryption/composer.json new file mode 100755 index 0000000..c230952 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Encryption/composer.json @@ -0,0 +1,30 @@ +{ + "name": "illuminate/encryption", + "license": "MIT", + "authors": [ + { + "name": "Taylor Otwell", + "email": "taylorotwell@gmail.com" + } + ], + "require": { + "php": ">=5.3.0", + "illuminate/support": "4.1.*", + "symfony/security-core": "2.4.*" + }, + "require-dev": { + "phpunit/phpunit": "4.0.*" + }, + "autoload": { + "psr-0": { + "Illuminate\\Encryption": "" + } + }, + "target-dir": "Illuminate/Encryption", + "extra": { + "branch-alias": { + "dev-master": "4.1-dev" + } + }, + "minimum-stability": "dev" +} diff --git a/vendor/laravel/framework/src/Illuminate/Events/Dispatcher.php b/vendor/laravel/framework/src/Illuminate/Events/Dispatcher.php new file mode 100755 index 0000000..1f9a803 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Events/Dispatcher.php @@ -0,0 +1,340 @@ +container = $container ?: new Container; + } + + /** + * Register an event listener with the dispatcher. + * + * @param string|array $event + * @param mixed $listener + * @param int $priority + * @return void + */ + public function listen($events, $listener, $priority = 0) + { + foreach ((array) $events as $event) + { + if (str_contains($event, '*')) + { + return $this->setupWildcardListen($event, $listener); + } + + $this->listeners[$event][$priority][] = $this->makeListener($listener); + + unset($this->sorted[$event]); + } + } + + /** + * Setup a wildcard listener callback. + * + * @param string $event + * @param mixed $listener + * @return void + */ + protected function setupWildcardListen($event, $listener) + { + $this->wildcards[$event][] = $this->makeListener($listener); + } + + /** + * Determine if a given event has listeners. + * + * @param string $eventName + * @return bool + */ + public function hasListeners($eventName) + { + return isset($this->listeners[$eventName]); + } + + /** + * Register a queued event and payload. + * + * @param string $event + * @param array $payload + * @return void + */ + public function queue($event, $payload = array()) + { + $me = $this; + + $this->listen($event.'_queue', function() use ($me, $event, $payload) + { + $me->fire($event, $payload); + }); + } + + /** + * Register an event subscriber with the dispatcher. + * + * @param string $subscriber + * @return void + */ + public function subscribe($subscriber) + { + $subscriber = $this->resolveSubscriber($subscriber); + + $subscriber->subscribe($this); + } + + /** + * Resolve the subscriber instance. + * + * @param mixed $subscriber + * @return mixed + */ + protected function resolveSubscriber($subscriber) + { + if (is_string($subscriber)) + { + return $this->container->make($subscriber); + } + + return $subscriber; + } + + /** + * Fire an event until the first non-null response is returned. + * + * @param string $event + * @param array $payload + * @return mixed + */ + public function until($event, $payload = array()) + { + return $this->fire($event, $payload, true); + } + + /** + * Flush a set of queued events. + * + * @param string $event + * @return void + */ + public function flush($event) + { + $this->fire($event.'_queue'); + } + + /** + * Get the event that is currently firing. + * + * @return string + */ + public function firing() + { + return last($this->firing); + } + + /** + * Fire an event and call the listeners. + * + * @param string $event + * @param mixed $payload + * @param bool $halt + * @return array|null + */ + public function fire($event, $payload = array(), $halt = false) + { + $responses = array(); + + // If an array is not given to us as the payload, we will turn it into one so + // we can easily use call_user_func_array on the listeners, passing in the + // payload to each of them so that they receive each of these arguments. + if ( ! is_array($payload)) $payload = array($payload); + + $this->firing[] = $event; + + foreach ($this->getListeners($event) as $listener) + { + $response = call_user_func_array($listener, $payload); + + // If a response is returned from the listener and event halting is enabled + // we will just return this response, and not call the rest of the event + // listeners. Otherwise we will add the response on the response list. + if ( ! is_null($response) && $halt) + { + array_pop($this->firing); + + return $response; + } + + // If a boolean false is returned from a listener, we will stop propagating + // the event to any further listeners down in the chain, else we keep on + // looping through the listeners and firing every one in our sequence. + if ($response === false) break; + + $responses[] = $response; + } + + array_pop($this->firing); + + return $halt ? null : $responses; + } + + /** + * Get all of the listeners for a given event name. + * + * @param string $eventName + * @return array + */ + public function getListeners($eventName) + { + $wildcards = $this->getWildcardListeners($eventName); + + if ( ! isset($this->sorted[$eventName])) + { + $this->sortListeners($eventName); + } + + return array_merge($this->sorted[$eventName], $wildcards); + } + + /** + * Get the wildcard listeners for the event. + * + * @param string $eventName + * @return array + */ + protected function getWildcardListeners($eventName) + { + $wildcards = array(); + + foreach ($this->wildcards as $key => $listeners) + { + if (str_is($key, $eventName)) $wildcards = array_merge($wildcards, $listeners); + } + + return $wildcards; + } + + /** + * Sort the listeners for a given event by priority. + * + * @param string $eventName + * @return array + */ + protected function sortListeners($eventName) + { + $this->sorted[$eventName] = array(); + + // If listeners exist for the given event, we will sort them by the priority + // so that we can call them in the correct order. We will cache off these + // sorted event listeners so we do not have to re-sort on every events. + if (isset($this->listeners[$eventName])) + { + krsort($this->listeners[$eventName]); + + $this->sorted[$eventName] = call_user_func_array('array_merge', $this->listeners[$eventName]); + } + } + + /** + * Register an event listener with the dispatcher. + * + * @param mixed $listener + * @return mixed + */ + public function makeListener($listener) + { + if (is_string($listener)) + { + $listener = $this->createClassListener($listener); + } + + return $listener; + } + + /** + * Create a class based listener using the IoC container. + * + * @param mixed $listener + * @return \Closure + */ + public function createClassListener($listener) + { + $container = $this->container; + + return function() use ($listener, $container) + { + // If the listener has an @ sign, we will assume it is being used to delimit + // the class name from the handle method name. This allows for handlers + // to run multiple handler methods in a single class for convenience. + $segments = explode('@', $listener); + + $method = count($segments) == 2 ? $segments[1] : 'handle'; + + $callable = array($container->make($segments[0]), $method); + + // We will make a callable of the listener instance and a method that should + // be called on that instance, then we will pass in the arguments that we + // received in this method into this listener class instance's methods. + $data = func_get_args(); + + return call_user_func_array($callable, $data); + }; + } + + /** + * Remove a set of listeners from the dispatcher. + * + * @param string $event + * @return void + */ + public function forget($event) + { + unset($this->listeners[$event]); + + unset($this->sorted[$event]); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Events/EventServiceProvider.php b/vendor/laravel/framework/src/Illuminate/Events/EventServiceProvider.php new file mode 100755 index 0000000..94b8e4b --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Events/EventServiceProvider.php @@ -0,0 +1,20 @@ +app['events'] = $this->app->share(function($app) + { + return new Dispatcher($app); + }); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Events/Subscriber.php b/vendor/laravel/framework/src/Illuminate/Events/Subscriber.php new file mode 100755 index 0000000..2731511 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Events/Subscriber.php @@ -0,0 +1,25 @@ +=5.3.0", + "illuminate/container": "4.1.*", + "illuminate/support": "4.1.*" + }, + "require-dev": { + "mockery/mockery": "0.9.*", + "phpunit/phpunit": "4.0.*" + }, + "autoload": { + "psr-0": { + "Illuminate\\Events": "" + } + }, + "target-dir": "Illuminate/Events", + "extra": { + "branch-alias": { + "dev-master": "4.1-dev" + } + }, + "minimum-stability": "dev" +} diff --git a/vendor/laravel/framework/src/Illuminate/Exception/ExceptionDisplayerInterface.php b/vendor/laravel/framework/src/Illuminate/Exception/ExceptionDisplayerInterface.php new file mode 100755 index 0000000..a976062 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Exception/ExceptionDisplayerInterface.php @@ -0,0 +1,14 @@ +registerDisplayers(); + + $this->registerHandler(); + } + + /** + * Register the exception displayers. + * + * @return void + */ + protected function registerDisplayers() + { + $this->registerPlainDisplayer(); + + $this->registerDebugDisplayer(); + } + + /** + * Register the exception handler instance. + * + * @return void + */ + protected function registerHandler() + { + $this->app['exception'] = $this->app->share(function($app) + { + return new Handler($app, $app['exception.plain'], $app['exception.debug']); + }); + } + + /** + * Register the plain exception displayer. + * + * @return void + */ + protected function registerPlainDisplayer() + { + $this->app['exception.plain'] = $this->app->share(function($app) + { + // If the application is running in a console environment, we will just always + // use the debug handler as there is no point in the console ever returning + // out HTML. This debug handler always returns JSON from the console env. + if ($app->runningInConsole()) + { + return $app['exception.debug']; + } + else + { + return new PlainDisplayer; + } + }); + } + + /** + * Register the Whoops exception displayer. + * + * @return void + */ + protected function registerDebugDisplayer() + { + $this->registerWhoops(); + + $this->app['exception.debug'] = $this->app->share(function($app) + { + return new WhoopsDisplayer($app['whoops'], $app->runningInConsole()); + }); + } + + /** + * Register the Whoops error display service. + * + * @return void + */ + protected function registerWhoops() + { + $this->registerWhoopsHandler(); + + $this->app['whoops'] = $this->app->share(function($app) + { + // We will instruct Whoops to not exit after it displays the exception as it + // will otherwise run out before we can do anything else. We just want to + // let the framework go ahead and finish a request on this end instead. + with($whoops = new Run)->allowQuit(false); + + $whoops->writeToOutput(false); + + return $whoops->pushHandler($app['whoops.handler']); + }); + } + + /** + * Register the Whoops handler for the request. + * + * @return void + */ + protected function registerWhoopsHandler() + { + if ($this->shouldReturnJson()) + { + $this->app['whoops.handler'] = $this->app->share(function() + { + return new JsonResponseHandler; + }); + } + else + { + $this->registerPrettyWhoopsHandler(); + } + } + + /** + * Determine if the error provider should return JSON. + * + * @return bool + */ + protected function shouldReturnJson() + { + return $this->app->runningInConsole() || $this->requestWantsJson(); + } + + /** + * Determine if the request warrants a JSON response. + * + * @return bool + */ + protected function requestWantsJson() + { + return $this->app['request']->ajax() || $this->app['request']->wantsJson(); + } + + /** + * Register the "pretty" Whoops handler. + * + * @return void + */ + protected function registerPrettyWhoopsHandler() + { + $me = $this; + + $this->app['whoops.handler'] = $this->app->share(function() use ($me) + { + with($handler = new PrettyPageHandler)->setEditor('sublime'); + + // If the resource path exists, we will register the resource path with Whoops + // so our custom Laravel branded exception pages will be used when they are + // displayed back to the developer. Otherwise, the default pages are run. + if ( ! is_null($path = $me->resourcePath())) + { + $handler->setResourcesPath($path); + } + + return $handler; + }); + } + + /** + * Get the resource path for Whoops. + * + * @return string + */ + public function resourcePath() + { + if (is_dir($path = $this->getResourcePath())) return $path; + } + + /** + * Get the Whoops custom resource path. + * + * @return string + */ + protected function getResourcePath() + { + $base = $this->app['path.base']; + + return $base.'/vendor/laravel/framework/src/Illuminate/Exception/resources'; + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Exception/Handler.php b/vendor/laravel/framework/src/Illuminate/Exception/Handler.php new file mode 100755 index 0000000..be79b4e --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Exception/Handler.php @@ -0,0 +1,384 @@ +debug = $debug; + $this->plainDisplayer = $plainDisplayer; + $this->debugDisplayer = $debugDisplayer; + $this->responsePreparer = $responsePreparer; + } + + /** + * Register the exception / error handlers for the application. + * + * @param string $environment + * @return void + */ + public function register($environment) + { + $this->registerErrorHandler(); + + $this->registerExceptionHandler(); + + if ($environment != 'testing') $this->registerShutdownHandler(); + } + + /** + * Register the PHP error handler. + * + * @return void + */ + protected function registerErrorHandler() + { + set_error_handler(array($this, 'handleError')); + } + + /** + * Register the PHP exception handler. + * + * @return void + */ + protected function registerExceptionHandler() + { + set_exception_handler(array($this, 'handleUncaughtException')); + } + + /** + * Register the PHP shutdown handler. + * + * @return void + */ + protected function registerShutdownHandler() + { + register_shutdown_function(array($this, 'handleShutdown')); + } + + /** + * Handle a PHP error for the application. + * + * @param int $level + * @param string $message + * @param string $file + * @param int $line + * @param array $context + * + * @throws \ErrorException + */ + public function handleError($level, $message, $file = '', $line = 0, $context = array()) + { + if (error_reporting() & $level) + { + throw new ErrorException($message, 0, $level, $file, $line); + } + } + + /** + * Handle an exception for the application. + * + * @param \Exception $exception + * @return \Symfony\Component\HttpFoundation\Response + */ + public function handleException($exception) + { + $response = $this->callCustomHandlers($exception); + + // If one of the custom error handlers returned a response, we will send that + // response back to the client after preparing it. This allows a specific + // type of exceptions to handled by a Closure giving great flexibility. + if ( ! is_null($response)) + { + return $this->prepareResponse($response); + } + + // If no response was sent by this custom exception handler, we will call the + // default exception displayer for the current application context and let + // it show the exception to the user / developer based on the situation. + return $this->displayException($exception); + } + + /** + * Handle an uncaught exception. + * + * @param \Exception $exception + * @return void + */ + public function handleUncaughtException($exception) + { + $this->handleException($exception)->send(); + } + + /** + * Handle the PHP shutdown event. + * + * @return void + */ + public function handleShutdown() + { + $error = error_get_last(); + + // If an error has occurred that has not been displayed, we will create a fatal + // error exception instance and pass it into the regular exception handling + // code so it can be displayed back out to the developer for information. + if ( ! is_null($error)) + { + extract($error); + + if ( ! $this->isFatal($type)) return; + + $this->handleException(new FatalError($message, $type, 0, $file, $line))->send(); + } + } + + /** + * Determine if the error type is fatal. + * + * @param int $type + * @return bool + */ + protected function isFatal($type) + { + return in_array($type, array(E_ERROR, E_CORE_ERROR, E_COMPILE_ERROR, E_PARSE)); + } + + /** + * Handle a console exception. + * + * @param \Exception $exception + * @return void + */ + public function handleConsole($exception) + { + return $this->callCustomHandlers($exception, true); + } + + /** + * Handle the given exception. + * + * @param \Exception $exception + * @param bool $fromConsole + * @return void + */ + protected function callCustomHandlers($exception, $fromConsole = false) + { + foreach ($this->handlers as $handler) + { + // If this exception handler does not handle the given exception, we will just + // go the next one. A handler may type-hint an exception that it handles so + // we can have more granularity on the error handling for the developer. + if ( ! $this->handlesException($handler, $exception)) + { + continue; + } + elseif ($exception instanceof HttpExceptionInterface) + { + $code = $exception->getStatusCode(); + } + + // If the exception doesn't implement the HttpExceptionInterface, we will just + // use the generic 500 error code for a server side error. If it implements + // the HttpException interfaces we'll grab the error code from the class. + else + { + $code = 500; + } + + // We will wrap this handler in a try / catch and avoid white screens of death + // if any exceptions are thrown from a handler itself. This way we will get + // at least some errors, and avoid errors with no data or not log writes. + try + { + $response = $handler($exception, $code, $fromConsole); + } + catch (\Exception $e) + { + $response = $this->formatException($e); + } + + // If this handler returns a "non-null" response, we will return it so it will + // get sent back to the browsers. Once the handler returns a valid response + // we will cease iterating through them and calling these other handlers. + if (isset($response) && ! is_null($response)) + { + return $response; + } + } + } + + /** + * Display the given exception to the user. + * + * @param \Exception $exception + * @return void + */ + protected function displayException($exception) + { + $displayer = $this->debug ? $this->debugDisplayer : $this->plainDisplayer; + + return $displayer->display($exception); + } + + /** + * Determine if the given handler handles this exception. + * + * @param Closure $handler + * @param \Exception $exception + * @return bool + */ + protected function handlesException(Closure $handler, $exception) + { + $reflection = new ReflectionFunction($handler); + + return $reflection->getNumberOfParameters() == 0 || $this->hints($reflection, $exception); + } + + /** + * Determine if the given handler type hints the exception. + * + * @param ReflectionFunction $reflection + * @param \Exception $exception + * @return bool + */ + protected function hints(ReflectionFunction $reflection, $exception) + { + $parameters = $reflection->getParameters(); + + $expected = $parameters[0]; + + return ! $expected->getClass() || $expected->getClass()->isInstance($exception); + } + + /** + * Format an exception thrown by a handler. + * + * @param \Exception $e + * @return string + */ + protected function formatException(\Exception $e) + { + if ($this->debug) + { + $location = $e->getMessage().' in '.$e->getFile().':'.$e->getLine(); + + return 'Error in exception handler: '.$location; + } + + return 'Error in exception handler.'; + } + + /** + * Register an application error handler. + * + * @param Closure $callback + * @return void + */ + public function error(Closure $callback) + { + array_unshift($this->handlers, $callback); + } + + /** + * Register an application error handler at the bottom of the stack. + * + * @param Closure $callback + * @return void + */ + public function pushError(Closure $callback) + { + $this->handlers[] = $callback; + } + + /** + * Prepare the given response. + * + * @param mixed $response + * @return \Illuminate\Http\Response + */ + protected function prepareResponse($response) + { + return $this->responsePreparer->prepareResponse($response); + } + + /** + * Determine if we are running in the console. + * + * @return bool + */ + public function runningInConsole() + { + return php_sapi_name() == 'cli'; + } + + /** + * Set the debug level for the handler. + * + * @param bool $debug + * @return void + */ + public function setDebug($debug) + { + $this->debug = $debug; + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Exception/PlainDisplayer.php b/vendor/laravel/framework/src/Illuminate/Exception/PlainDisplayer.php new file mode 100755 index 0000000..7c53ad7 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Exception/PlainDisplayer.php @@ -0,0 +1,24 @@ +getStatusCode() : 500; + + $headers = $exception instanceof HttpExceptionInterface ? $exception->getHeaders() : array(); + + return new Response(file_get_contents(__DIR__.'/resources/plain.html'), $status, $headers); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Exception/SymfonyDisplayer.php b/vendor/laravel/framework/src/Illuminate/Exception/SymfonyDisplayer.php new file mode 100755 index 0000000..9bc45c7 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Exception/SymfonyDisplayer.php @@ -0,0 +1,36 @@ +symfony = $symfony; + } + + /** + * Display the given exception to the user. + * + * @param \Exception $exception + */ + public function display(Exception $exception) + { + $this->symfony->handle($exception); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Exception/WhoopsDisplayer.php b/vendor/laravel/framework/src/Illuminate/Exception/WhoopsDisplayer.php new file mode 100755 index 0000000..ec42912 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Exception/WhoopsDisplayer.php @@ -0,0 +1,52 @@ +whoops = $whoops; + $this->runningInConsole = $runningInConsole; + } + + /** + * Display the given exception to the user. + * + * @param \Exception $exception + * @return \Symfony\Component\HttpFoundation\Response + */ + public function display(Exception $exception) + { + $status = $exception instanceof HttpExceptionInterface ? $exception->getStatusCode() : 500; + + $headers = $exception instanceof HttpExceptionInterface ? $exception->getHeaders() : array(); + + return new Response($this->whoops->handleException($exception), $status, $headers); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Exception/composer.json b/vendor/laravel/framework/src/Illuminate/Exception/composer.json new file mode 100755 index 0000000..32c5e02 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Exception/composer.json @@ -0,0 +1,34 @@ +{ + "name": "illuminate/exception", + "license": "MIT", + "authors": [ + { + "name": "Taylor Otwell", + "email": "taylorotwell@gmail.com" + } + ], + "require": { + "php": ">=5.3.0", + "filp/whoops": "1.0.10", + "illuminate/support": "4.1.*", + "symfony/http-foundation": "2.4.*", + "symfony/http-kernel": "2.4.*" + }, + "require-dev": { + "monolog/monolog": "1.*", + "mockery/mockery": "0.9.*", + "phpunit/phpunit": "4.0.*" + }, + "autoload": { + "psr-0": { + "Illuminate\\Exception": "" + } + }, + "target-dir": "Illuminate/Exception", + "extra": { + "branch-alias": { + "dev-master": "4.1-dev" + } + }, + "minimum-stability": "dev" +} diff --git a/vendor/laravel/framework/src/Illuminate/Exception/resources/plain.html b/vendor/laravel/framework/src/Illuminate/Exception/resources/plain.html new file mode 100755 index 0000000..7f9aa3c --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Exception/resources/plain.html @@ -0,0 +1,71 @@ + + + + + + + + +
+

Whoops, looks like something went wrong.

+ +
+ + diff --git a/vendor/laravel/framework/src/Illuminate/Exception/resources/pretty-page.css b/vendor/laravel/framework/src/Illuminate/Exception/resources/pretty-page.css new file mode 100755 index 0000000..23b71e2 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Exception/resources/pretty-page.css @@ -0,0 +1,310 @@ +.cf:before, .cf:after {content: " ";display: table;} .cf:after {clear: both;} .cf {*zoom: 1;} +body { + font: 14px "Lucida Grande", "Lucida Sans Unicode", "Lucida Sans", Geneva, Verdana, sans-serif; + color: #2B2B2B; + background-color: #e7e7e7; + padding:0; + margin: 0; + max-height: 100%; +} + a { + text-decoration: none; + color: #FE8A59; + } + +.container{ + height: 100%; + width: 100%; + position: fixed; + margin: 0; + padding: 0; + left: 0; + top: 0; +} + +.branding { + position: absolute; + top: 10px; + right: 20px; + color: #777777; + font-size: 10px; + z-index: 100; +} + .branding a { + color: #CD3F3F; + } + +header { + padding: 20px 20px; + color: #555; + background: #ddd; + box-sizing: border-box; + border-left: 5px solid #ED3D1A; + background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQMAAACWCAYAAADaDe2PAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyRpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMy1jMDExIDY2LjE0NTY2MSwgMjAxMi8wMi8wNi0xNDo1NjoyNyAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENTNiAoTWFjaW50b3NoKSIgeG1wTU06SW5zdGFuY2VJRD0ieG1wLmlpZDpBNTk1RDY3OTlBRkQxMUUyOUM0M0EzNzM1OTdBRTY0NyIgeG1wTU06RG9jdW1lbnRJRD0ieG1wLmRpZDpBNTk1RDY3QTlBRkQxMUUyOUM0M0EzNzM1OTdBRTY0NyI+IDx4bXBNTTpEZXJpdmVkRnJvbSBzdFJlZjppbnN0YW5jZUlEPSJ4bXAuaWlkOkE1OTVENjc3OUFGRDExRTI5QzQzQTM3MzU5N0FFNjQ3IiBzdFJlZjpkb2N1bWVudElEPSJ4bXAuZGlkOkE1OTVENjc4OUFGRDExRTI5QzQzQTM3MzU5N0FFNjQ3Ii8+IDwvcmRmOkRlc2NyaXB0aW9uPiA8L3JkZjpSREY+IDwveDp4bXBtZXRhPiA8P3hwYWNrZXQgZW5kPSJyIj8+GLAjkgAAEaxJREFUeNrsXet22zYTXFHUXXZT93nyo0/eH3mfpI5lybpQrPAd7GeEEYGFRBEXzpyjY7eRbYrEDmYHi8WormuS4O+vX+nBGOmvhf5+ZHxvfi2M/+b3K5wvr+ry2l1eBwKAiPDPt2/RX2PZY3C3BXTz68j4WR8U+vPMLq/N5bXFEASAx5BB28x9LbjN7+nG4L4Ha60OTnjEAOBJBpc0YHz5Mr4S4M0gDxHct+D58vpxedV4zAAgIIMLCYz0TDpPJMh9iG55eb3jMQOALM9WRLDIjAgYK3qsLwIAWc2ek0ivrdavc+Nr1fhvRWRTy+950ukCAAAOMhgFDvDm6xoB2KDI4cXy7xOdAn3gcQOAnQxUMI0fHODnK+/rCicd6HPLe1QqtCeYiQBgJYODQ2YzjkZAXZvFQwaaMglnFpWjvBGYiQBgQeExYyrSUIU8O/0zRz0rnyn8jKvUzcbxnuWdCggA8iaDf759q0hWvhv70uNOE1QbeAkVAIAWZUAkK90dO/LyGOBSBzP9AgCghQyOjlnVlNoxqwP1GVyrBmvKs6YCAO4nA72jKhd1oEzC2vEZlnj0AHBdGSgoU1CysWcV+cxakXvVAJWJANBGBh7qQP3MIvLPpczEs+M9T3j8AHBdGbA6qDLwDlSa4DITVWUizEQAuEYGF3VQ61lV8nOxewfKSHSZorGnPAAQTBmwOpAUEc0T+HwudVAmkPIAQBgy0EVIkk09Kcjso0DpwEwEgBZlQMJUgb2D2KFWFmxmIioTAaCNDC7q4KTThRzUwZncS41TgpkIgAxaIe0unII6UErHVUOBykQAZNCiDqQlyhOSbYEODRe5oTIRABk48m0JUsi5lSnq2p25ImxzBkAGV3EQqoMykZx7I3gPzEQAZHAlVcjNOziRe6VklkjaAwC9KgNWB5INTKl4B66lRlYHMBMBkEFDHdQk7yycQlWiZKkRlYkAyKAFigykJcopVPO5WqQpoDIRABlcUQdnklclrhL57G+Of0dlIgAysMymEnUwS2RGlVRZojIRABlcQUWyEmWFVIp3JHUUKwwTAGTwO6TLjMo7SKF45yT4TDATAZDBjdKakUq+/U7u7k5rQmViyhhpUp/qV4Fbcn3W88VWmEezd3CK/B7UmhCeHYNJEcIrhkz0QT/Wr7Lx1awb4eXlHW7ZfWSgluSk5zMq7+BnAvfhQ6cCEwe5TUl2+hTw+KAvrgT8WDjrq/c86Z97w+28nQxYHUjIYC6U4TFADYoXQbrwg3Cac99BzwHvG/QuLIxnDzK48ed4A9PEgxBiB+9bWDju14LkRiogQ2G8moH/6Px+QbKqVJCBBTshGSxJdo5BDNiQ+4DZFcn3awD2nN6c6UPuBVlp9foBMrgNex3ghWAALBJh3lrP+ivH51H/DjNRPusrgp31NNPbnm1lKJAmnrTarUAGt93cHcmKclJSB1ty10nMtCo6ItatUPfwC/W/LHvWQV1pBcdBzpOXWjmaXiH5P2jAntC9ZcM7kp2ulJo62OiBYQObiYCdNB9NBGbQ86uyBLQiBLXC9XJFIZSaKF5BBrcxMC/LucDGWwqsuyf38ulEfyasVbejK+VUGzK/GfznG8YUE8KXFgJb0QANxS42FLGsdqmDQquIVG4yLzWOHOrgMOQ8U0AGW/Lbq1Ibs7s5098S9DYc9DO+dgDvSv+9HcjAX6ZJ1UFK3kFFMjMRlYl2vGsVNXEE5ocx0/c1PnbUvvfkyfAbBoGunF3puvuI0tr0sxUMTPRMdM/0b45Z/dQggz6xsQT8Mw2o/V1XZOCzvXmR0A2WHO3O6QJ6JtqDfeNQjNOAz/hnCwmNyb5nBWRwpzooKK2GIXuBJ4BtzjJJbpswnilcDUJF7SXJMxpIT4subz5vYJJAshwZm8x1YUXYGiuR5LVlLIachffUbm6vhkD2XQ9eaTlnKoeuMA6CNAg9E++bgUmnCiFn4XfLc36izL2hrslAIqlNdZDLrMZQS6wTxLxzwvhwKKyQ9/CnZQw/U8ZNbromg9rDO0hNHVTCzwZ14MabY9J4CphGqjH82kL8Rc7P9xE5rmJ96fJQasaMZKlxQjATJQH30zFRhAy6Ew3QUCwe9KB91ME8sUEsMRPRM9GNI9mXGxeBx8YHDcxQfJT77VNlmJp3sCeYiV0qrYMjXSgDX9/Rcm1TkIFsBpXWdafmHRDJ9legMlHuH9QWUg1ZBWgrSCLKzFB85Lq49HzGFL0Dact4HMDiRuUg19D+QUXt/kZBGZUsFw++iT51B6ktyUmWGieUlicSUo7vHf5BSJV1oHZ/Y5IL6Rc9PORc1YFrRjNzS1QmumFb32dJHvI+bqndGF9SBoZi0UPASEuUpwmqgx25G6PCTJTn52+OsfoUgRrM1lAsegoYKZYJDmDJrkZUJsrluE1tzSIYIzbDM2lDsejpAUvbiqdynHvz80nMxCfEugjvjvGyDkysJ8rUUOwrB/M5dGSV6AB2eSNlgson5OxLEfsHth2Ok1SJv68b+uGpDlKT1JKj3ZnoUJnohqs6cRxBwL1T+2rZPEXi75NdfdRBijPoTqAORlAHXuPl4Jg0Qi/bvlG7oajSmSnIoF1aSbc3p+gdSM/rWyT42UIGm62s/Smw0qrJ3b1pDDK4fuNyXllgdSBJh2AmyuBqhsLlyn1ipNNYNT6/kH3ZOClDsQgQLNINTDNKr1hHutSIykQ/Rblz3Mv1g2OEg1+dsvXX5fWnRxrwP0Px769fo7/RZYBg2QofHufXm8QGL58B4Ar2J/3eM+LdiY0OqtKiIrnd+r3gE6Inxt+8d2af6+cc9VgOMfP6bGBaUJqlvJKlRlQmdqu4bvUPCj3Dr/WM/6IVwFKTQVcSP/py5RCBdib5GQupHbpi5roSMxGViX6K670D/6AZ/H/p3L/r4L82JpAmXMHWI2dO6Ui2pj+yEMxWakb7jlgXjxvbHpZrh+EWhuyfdiT7fUngQH5L64MigxO5TzluqoPUTsWt9TU/C57BvKN8dwjpwpue0dsCeq3fNzby/j6D/2yM76P+vv7n2zcCGdjzamlRRqrqgA+kdaUCa5061Yh30UTyStePU/dJF7okKA58PpE7yecYkgyOA1AHChs9k7ny2DXJmq0OGSM9Zsc64EKs3/OR8Tx+QxwWmx0ZmDlgzurgSLKlRs51T4j534J/YrxCmN6VEfxHSsAMTJEMmFlL4cBIVR2oa54JZjJlJv5A8P/fJCwDBX9tBH/S0j8lMmB1IM3xFuTXSi0W8FKjq66AKxOHYiaO6VejL1TwnxuzfzbSPzUy+NApgORaCh0suwTvNS+nuj7nU8ZStFnZNw6c97PsPxLM22h2z/mogyX5VTHGBGUmfhFIZdX34GcGkn/cyPdD7zD8MIK/IiBKMthrWSaRiGOdf6copblFmuvQmLkmyFOiwT81Zv6Yrm9P8ga9IIOArL0neenxMuG8ekuyE6SUOniNPPhDO/2m3D+Qe8uw2nPwHaogbjIwc+qR8LpTNdqO9FmqbMNMv/aRXDebfWXg4G8afc3Athm1XJD0LzyCuMmAT2CSqoMVpVu1x0uNrmBiM/EcKPib+f4oQPD7Fvhs9fW2qS9uWPoT4R8vGfCDXHgM1lS9A26R5up4VGjSe+sx+DnfD7lvxTbzS/DmUC5zkp2mDTIIrA4kBlsO3sGOZFuYH1WZ2FzmCzUWzvTrEt+po9+pZv4vDtV1K9mADHpUBzOP648pr74lXfgieN+9lYkxLfNd3dX3gL/D/Q9WFtX1TMOu+IyeDHw2MPHMmSoZSFuk+VYmFvRp9oVe5mtW9/VZ4MM7Y239D5TZuAEVxNuy22d7Mz/sY6LPYEPyfQttPRMf0bfvVtSG5D88cOaXQqULL5b70WX/RJDBg9TBkeQtwZQU/DfRZ3DWqZHrWDlzo1YMTr8Z/E3ZH1NdP7dbfxb4ByeQQZxQAfLHQNQB1x24lhqXWkWEDH6iT8c/ldLeDz1G5haiHfqO0ajJgCWxtLBFBcpros+B1YFrV+Mo0DM7N3L+FGfQN7IbpxOtzt5BBvGBT2CSnsrMR7KlNlBHRs4fk7SuIsr7uxpPvNw4sqSb/JlBBhGmCj5nJ8Rez0/02a03ZFmva+bPtZnHUeAfDHb/QuxkkIM6KOh3p7+I4L42Zf9QavUl/sEg9y+kcBrwTvsBUsMstDpoBn/frbrbgr9p+g35WLeNJoTC4R9sQAZx4Ux+G5j6Vge8m8/s2xfDqbu8VJZ1E887xtQb2Verlvq+7UEG8XkHc48gW9BjNveMGsFfRhL8NX2W+ZqmH9COvR5XS8t71kNSUamQge/2Zu4UVHUQ/DG06nbNcj8w89+cLnDJdpvqY/8AZBCZd7DwCOLFDTnfqBH4JcV/CnShrxVkcBu4XLntOU9pIPUHKZHBify2N3Nb9bMjkMpIg5+lv2SD0Zra9y0AbmXl2u48iPqDMrHr3XmQwbVDV8w+/SFO5JUQnrnkR45ZyyS1JWH33a04CJSnShe+50y4qZEBr4lLr3uhZ9iC4nL6eebnSj/z5J4mJB2RiD4bvcA4vN0/mFjGVpG7f5AaGdTkd8YCH2gaC8zAl3bZkXZEIsJmm3vHlkoXbMe9Z+0flAle814H0TiBa+1qg4+0I9LQjmd7RJrmKldeNdI4kEFgBt9FNuOb1/aIxh7Sw1d4sKbaNToGuMqVTf+gBhmEB5cox1Dj79vK+1a8C8lgTOmeRxkLXNuduf7gFWQQjzpYBfi7FX0uc/bZXddnaZXVAZYa7/MPbNudZ3pC2oIMwsN3e3MXM39FYYt7eIONa0WEjVMcFHI7jmQ/nYn0v/H+D5BBYPZ2bTa5dQaOtaVXZaRILnCqcERc3zXhTMnenDeb+oMi8evf0/2FNrzv4U0/1O/6+w+Ks8R36zHw1ojnTvwDVxVrFve5zOAzbLVKWJOsoOhMvzr+qXX1kfZLVMBSYzdqzKVA5/R5BgbIIDB2+mHM6bNpxcgInop+Pb6rzuDzzoXPD/sWulGgrnLl5Nutlxk9MBXw7/o1angLuaHW6ZGkEKnPw1tzxjvZe2pwu7QfqY65ItMHVxuvXMGFSBKoQTxGPN8EFeQznSa40tCSZPtIoAyAh8xWM+GAVuoAS41yApjoezvznDST9Q9ABmnDpxCJjcQDblsrpvpeTu9UUrZzMUEGwEPVgaQQSWGdck77IAVQGiRQdvh7m700QAZAL+pAcnArP2/uADX0FMBceUJsgQyygU9pNu9bqAZGAKXhAfRhpu5ABkAI1CTviDQkM9EkgL7GOrdgP4IMgFDgohjJM81530IIAqg0CSTddg5kkBekhUicLvybEQGwCTjp6W9yWfueMmkmAzLIC7y+PRe8l4Nnn/DY7VsB1MY9PhA6HQGR411IBgrrxAZ1CAVADQWQrfEKMsgPlYc6UK76kuJeD+dzLec9EwAf+DuY9vMgg3zVgZo9JYVIfN5CFSEBsALo66yL2lAA2aUBIIPhqgNpIdJIpwuvERAA7weY9kwAJ02Ig+4bCTLIF1uSm2tsxO0DEACnAH2fdmUagej1ADLIGlyIJO0R2ZeZGCoFIPrc2LUnHEMHMhgYOPedCoP0UfsW+KzLec8pAOlZ3/QBAJDBYKEKkV6E72UzsQvZPKJftwT32UiH6wH2SANABsCv0tjVv8+cwe9pkVbQr8VAfROAmQZUePQgA+B3bMnev8/EwlNSswIIkQIoHEEAIANADp+lRgVXE5SQKQB/nuQ3BoEMgJDqQNrzoNSE0EwX2AScBSCAM30uBx4J3ZpABsBdObUyE5+F719oBbA3fIAywDWbaQCMQJAB0BE+dJBLa/znJN/01CUBwAgEGQA9QEn/P6l/o88FGIEgA6Bn8FLjMoJrgREIMgACg3sehDhRi43AQe4MBBkAscGngWpXf+9I2BgEMgCiBJuJ5QMJAEYgyABIRB2odukvHf9eGIEgAyBBqJlb1R6sO/g92BoMMgASx1aPA996AnNrMCoCQQZAJuDTleYCAsBKAMgAGAAhqBme9y+MdLBX+v8foADyxn8CDABulgqUemYwnwAAAABJRU5ErkJggg==); + background-repeat:no-repeat; + background-position:right; +} + .exc-title { + margin: 0; + color: #616161; + font-weight:normal; + } + .exc-title-primary { color: #ED591A; } + .exc-message { + font-size: 16px; + margin: 5px 0; + word-wrap: break-word; + } + +.stack-container { + height: 100%; + position: relative; +} + +.details-container { + height: 100%; + overflow: auto; + float: right; + width: 70%; + background: #fff; +} + .details { + padding: 10px 20px; + border-left: 5px solid rgba(0, 0, 0, .2); + } + +.frames-container { + height: 100%; + overflow: auto; + float: left; + width: 30%; + background: #FFF; +} + .frame { + padding: 14px; + background: #F3F3F3; + border-right: 1px solid rgba(0, 0, 0, .2); + cursor: pointer; + font-size:12px; + } + .frame.active { + background-color: #ED591A; + color: #F3F3F3; + + } + + .frame:not(.active):hover { + background: #F0E5DF; + } + + .frame-class, .frame-function, .frame-index { + font-weight: bold; + } + + .frame-index { + font-size: 11px; + color: #BDBDBD; + } + + .frame-class { + color: #ED591A; + } + .active .frame-class { + color: #5E2204; + } + + .frame-file { + font-family: 'Source Code Pro', Monaco, Consolas, "Lucida Console", monospace; + color:#999; + word-wrap:break-word; + } + .editor-link { + color: inherit; + } + .editor-link:hover strong { + color: #F0E5DF; + } + + .editor-link-callout { + padding: 2px 4px; + background: #872D00; + } + + .frame-line { + font-weight: bold; + color: #A33202; + } + + .active .frame-file{ color:#872D00; } + + .active .frame-line { color: #fff; } + .frame-line:before { + content: ":"; + } + + .frame-code { + padding: 20px; + background: #f0f0f0; + display: none; + border-left: 5px solid #EDA31A; + } + + .frame-code.active { + display: block; + } + + .frame-code .frame-file { + background: #ED591A; + color: #fff; + padding: 10px 10px 10px 10px; + font-size:11px; + font-weight:normal; + } + + .code-block { + padding: 10px; + margin: 0; + box-shadow: inset 0 0 6px rgba(0, 0, 0, .3); + } + + .linenums { + margin: 0; + margin-left: 10px; + } + + .frame-comments { + border-top: none; + padding: 5px; + font-size: 12px; + background: #404040; + } + + .frame-comments.empty { + padding: 8px 15px; + } + + .frame-comments.empty:before { + content: "No comments for this stack frame."; + color: #828282; + } + + .frame-comment { + padding: 10px 5px; + color: #D2D2D2; + } + + .frame-comment:not(:last-child) { + border-bottom: 1px dotted rgba(0, 0, 0, .3); + } + + .frame-comment-context { + font-size: 10px; + font-weight: bold; + color: #86D2B6; + } + +.data-table-container label { + font-size: 16px; + font-weight: bold; + color: #ED591A; + margin: 10px 0; + padding: 10px 0; + + display: block; + margin-bottom: 5px; + padding-bottom: 5px; + border-bottom: 1px solid rgba(0, 0, 0, .08); +} + .data-table { + width: 100%; + margin: 10px 0; + font: 12px 'Source Code Pro', Monaco, Consolas, "Lucida Console", monospace; + } + + .data-table thead { + display: none; + } + + .data-table tr { + padding: 5px 0; + } + + .data-table td:first-child { + width: 20%; + min-width: 130px; + overflow: hidden; + color: #463C54; + padding-right: 5px; + + } + + .data-table td:last-child { + width: 80%; + color:#999; + -ms-word-break: break-all; + word-break: break-all; + word-break: break-word; + -webkit-hyphens: auto; + -moz-hyphens: auto; + hyphens: auto; + } + + .data-table .empty { + color: rgba(0, 0, 0, .3); + font-style: italic; + } + +.handler { + padding: 10px; + font: 14px monospace; +} + +.handler.active { + color: #BBBBBB; + background: #989898; + font-weight: bold; +} + +/* prettify code style +Uses the Doxy theme as a base */ +pre .str, code .str { color: #E3B446; } /* string */ +pre .kwd, code .kwd { color: #DB613B; font-weight: bold; } /* keyword*/ +pre .com, code .com { color: #555; font-weight: bold; } /* comment */ +pre .typ, code .typ { color: #fff; } /* type */ +pre .lit, code .lit { color: #17CFB6; } /* literal */ +pre .pun, code .pun { color: #93a1a1; font-weight: bold; } /* punctuation */ +pre .pln, code .pln { color: #ccc; } /* plaintext */ +pre .tag, code .tag { color: #DB613B; } /* html/xml tag */ +pre .htm, code .htm { color: #dda0dd; } /* html tag */ +pre .xsl, code .xsl { color: #d0a0d0; } /* xslt tag */ +pre .atn, code .atn { color: #fff; font-weight: normal;} /* html/xml attribute name */ +pre .atv, code .atv { color: #E3B446; } /* html/xml attribute value */ +pre .dec, code .dec { color: #fff; } /* decimal */ +pre.prettyprint, code.prettyprint { + font-weight:normal; + font-family: 'Source Code Pro', Monaco, Consolas, "Lucida Console", monospace; + background: #272727; + color: #929292; + font-size:11px; + line-height:1.5em; +} + pre.prettyprint { + white-space: pre-wrap; + } + + pre.prettyprint a, code.prettyprint a { + text-decoration:none; + } + + .linenums li { + color: #A5A5A5; + } + + .linenums li.current{ + background: rgba(255, 255, 255, .05); + padding-top: 4px; + padding-left: 1px; + } + .linenums li.current.active { + background: rgba(255, 255, 255, .1); + } diff --git a/vendor/laravel/framework/src/Illuminate/Exception/resources/pretty-template.php b/vendor/laravel/framework/src/Illuminate/Exception/resources/pretty-template.php new file mode 100755 index 0000000..f1ab90f --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Exception/resources/pretty-template.php @@ -0,0 +1,215 @@ + + + + + + <?php echo $e($v->title) ?> + + + + +
+ +
+ +
+ + + frames as $i => $frame): ?> + +
+
+ frames) - $i - 1) ?>. + getClass() ?: '') ?> + getFunction() ?: '') ?> +
+ + + getFile(true) ?: '<#unknown>') ?>getLine() ?> + +
+ + +
+ +
+ +
+
+

+ name as $i => $nameSection): ?> + name) - 1): ?> + + + + + +

+

+ message) ?> +

+
+
+ + +
+ frames as $i => $frame): ?> + + getLine(); ?> +
+
+ getFile(); ?> + handler->getEditorHref($filePath, (int) $line)): ?> + + open: ') ?> + + + ') ?> + +
+ getFileLines($line - 8, 10); + $range = array_map(function($line){ return empty($line) ? ' ' : $line;}, $range); + $start = key($range) + 1; + $code = join("\n", $range); + ?> +
+ + + getComments(); + ?> +
+ $comment): ?> + +
+ + +
+ +
+ +
+ +
+ + +
+
+ tables as $label => $data): ?> +
+ + + + + + + + + + $value): ?> + + + + + +
KeyValue
+ + empty + +
+ +
+ + +
+ + handlers as $i => $handler): ?> +
+ . +
+ +
+ +
+
+ +
+
+ + + + + + diff --git a/vendor/laravel/framework/src/Illuminate/Filesystem/Filesystem.php b/vendor/laravel/framework/src/Illuminate/Filesystem/Filesystem.php new file mode 100755 index 0000000..e533046 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Filesystem/Filesystem.php @@ -0,0 +1,406 @@ +isFile($path)) return file_get_contents($path); + + throw new FileNotFoundException("File does not exist at path {$path}"); + } + + /** + * Get the returned value of a file. + * + * @param string $path + * @return mixed + * + * @throws FileNotFoundException + */ + public function getRequire($path) + { + if ($this->isFile($path)) return require $path; + + throw new FileNotFoundException("File does not exist at path {$path}"); + } + + /** + * Require the given file once. + * + * @param string $file + * @return mixed + */ + public function requireOnce($file) + { + require_once $file; + } + + /** + * Write the contents of a file. + * + * @param string $path + * @param string $contents + * @return int + */ + public function put($path, $contents) + { + return file_put_contents($path, $contents); + } + + /** + * Prepend to a file. + * + * @param string $path + * @param string $data + * @return int + */ + public function prepend($path, $data) + { + if ($this->exists($path)) + { + return $this->put($path, $data.$this->get($path)); + } + else + { + return $this->put($path, $data); + } + } + + /** + * Append to a file. + * + * @param string $path + * @param string $data + * @return int + */ + public function append($path, $data) + { + return file_put_contents($path, $data, FILE_APPEND); + } + + /** + * Delete the file at a given path. + * + * @param string|array $paths + * @return bool + */ + public function delete($paths) + { + $paths = is_array($paths) ? $paths : func_get_args(); + + $success = true; + + foreach ($paths as $path) { if ( ! @unlink($path)) $success = false; } + + return $success; + } + + /** + * Move a file to a new location. + * + * @param string $path + * @param string $target + * @return bool + */ + public function move($path, $target) + { + return rename($path, $target); + } + + /** + * Copy a file to a new location. + * + * @param string $path + * @param string $target + * @return bool + */ + public function copy($path, $target) + { + return copy($path, $target); + } + + /** + * Extract the file extension from a file path. + * + * @param string $path + * @return string + */ + public function extension($path) + { + return pathinfo($path, PATHINFO_EXTENSION); + } + + /** + * Get the file type of a given file. + * + * @param string $path + * @return string + */ + public function type($path) + { + return filetype($path); + } + + /** + * Get the file size of a given file. + * + * @param string $path + * @return int + */ + public function size($path) + { + return filesize($path); + } + + /** + * Get the file's last modification time. + * + * @param string $path + * @return int + */ + public function lastModified($path) + { + return filemtime($path); + } + + /** + * Determine if the given path is a directory. + * + * @param string $directory + * @return bool + */ + public function isDirectory($directory) + { + return is_dir($directory); + } + + /** + * Determine if the given path is writable. + * + * @param string $path + * @return bool + */ + public function isWritable($path) + { + return is_writable($path); + } + + /** + * Determine if the given path is a file. + * + * @param string $file + * @return bool + */ + public function isFile($file) + { + return is_file($file); + } + + /** + * Find path names matching a given pattern. + * + * @param string $pattern + * @param int $flags + * @return array + */ + public function glob($pattern, $flags = 0) + { + return glob($pattern, $flags); + } + + /** + * Get an array of all files in a directory. + * + * @param string $directory + * @return array + */ + public function files($directory) + { + $glob = glob($directory.'/*'); + + if ($glob === false) return array(); + + // To get the appropriate files, we'll simply glob the directory and filter + // out any "files" that are not truly files so we do not end up with any + // directories in our list, but only true files within the directory. + return array_filter($glob, function($file) + { + return filetype($file) == 'file'; + }); + } + + /** + * Get all of the files from the given directory (recursive). + * + * @param string $directory + * @return array + */ + public function allFiles($directory) + { + return iterator_to_array(Finder::create()->files()->in($directory), false); + } + + /** + * Get all of the directories within a given directory. + * + * @param string $directory + * @return array + */ + public function directories($directory) + { + $directories = array(); + + foreach (Finder::create()->in($directory)->directories()->depth(0) as $dir) + { + $directories[] = $dir->getPathname(); + } + + return $directories; + } + + /** + * Create a directory. + * + * @param string $path + * @param int $mode + * @param bool $recursive + * @param bool $force + * @return bool + */ + public function makeDirectory($path, $mode = 0777, $recursive = false, $force = false) + { + if ($force) + { + return @mkdir($path, $mode, $recursive); + } + else + { + return mkdir($path, $mode, $recursive); + } + } + + /** + * Copy a directory from one location to another. + * + * @param string $directory + * @param string $destination + * @param int $options + * @return bool + */ + public function copyDirectory($directory, $destination, $options = null) + { + if ( ! $this->isDirectory($directory)) return false; + + $options = $options ?: FilesystemIterator::SKIP_DOTS; + + // If the destination directory does not actually exist, we will go ahead and + // create it recursively, which just gets the destination prepared to copy + // the files over. Once we make the directory we'll proceed the copying. + if ( ! $this->isDirectory($destination)) + { + $this->makeDirectory($destination, 0777, true); + } + + $items = new FilesystemIterator($directory, $options); + + foreach ($items as $item) + { + // As we spin through items, we will check to see if the current file is actually + // a directory or a file. When it is actually a directory we will need to call + // back into this function recursively to keep copying these nested folders. + $target = $destination.'/'.$item->getBasename(); + + if ($item->isDir()) + { + $path = $item->getPathname(); + + if ( ! $this->copyDirectory($path, $target, $options)) return false; + } + + // If the current items is just a regular file, we will just copy this to the new + // location and keep looping. If for some reason the copy fails we'll bail out + // and return false, so the developer is aware that the copy process failed. + else + { + if ( ! $this->copy($item->getPathname(), $target)) return false; + } + } + + return true; + } + + /** + * Recursively delete a directory. + * + * The directory itself may be optionally preserved. + * + * @param string $directory + * @param bool $preserve + * @return bool + */ + public function deleteDirectory($directory, $preserve = false) + { + if ( ! $this->isDirectory($directory)) return false; + + $items = new FilesystemIterator($directory); + + foreach ($items as $item) + { + // If the item is a directory, we can just recurse into the function and + // delete that sub-director, otherwise we'll just delete the file and + // keep iterating through each file until the directory is cleaned. + if ($item->isDir()) + { + $this->deleteDirectory($item->getPathname()); + } + + // If the item is just a file, we can go ahead and delete it since we're + // just looping through and waxing all of the files in this directory + // and calling directories recursively, so we delete the real path. + else + { + $this->delete($item->getPathname()); + } + } + + if ( ! $preserve) @rmdir($directory); + + return true; + } + + /** + * Empty the specified directory of all files and folders. + * + * @param string $directory + * @return bool + */ + public function cleanDirectory($directory) + { + return $this->deleteDirectory($directory, true); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Filesystem/FilesystemServiceProvider.php b/vendor/laravel/framework/src/Illuminate/Filesystem/FilesystemServiceProvider.php new file mode 100755 index 0000000..5e76b2a --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Filesystem/FilesystemServiceProvider.php @@ -0,0 +1,17 @@ +app->bindShared('files', function() { return new Filesystem; }); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Filesystem/composer.json b/vendor/laravel/framework/src/Illuminate/Filesystem/composer.json new file mode 100755 index 0000000..8778b7d --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Filesystem/composer.json @@ -0,0 +1,30 @@ +{ + "name": "illuminate/filesystem", + "license": "MIT", + "authors": [ + { + "name": "Taylor Otwell", + "email": "taylorotwell@gmail.com" + } + ], + "require": { + "php": ">=5.3.0", + "illuminate/support": "4.1.*", + "symfony/finder": "2.4.*" + }, + "require-dev": { + "phpunit/phpunit": "4.0.*" + }, + "autoload": { + "psr-0": { + "Illuminate\\Filesystem": "" + } + }, + "target-dir": "Illuminate/Filesystem", + "extra": { + "branch-alias": { + "dev-master": "4.1-dev" + } + }, + "minimum-stability": "dev" +} diff --git a/vendor/laravel/framework/src/Illuminate/Foundation/AliasLoader.php b/vendor/laravel/framework/src/Illuminate/Foundation/AliasLoader.php new file mode 100755 index 0000000..6c6e2d9 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Foundation/AliasLoader.php @@ -0,0 +1,158 @@ +aliases = $aliases; + } + + /** + * Get or create the singleton alias loader instance. + * + * @param array $aliases + * @return \Illuminate\Foundation\AliasLoader + */ + public static function getInstance(array $aliases = array()) + { + if (is_null(static::$instance)) static::$instance = new static($aliases); + + $aliases = array_merge(static::$instance->getAliases(), $aliases); + + static::$instance->setAliases($aliases); + + return static::$instance; + } + + /** + * Load a class alias if it is registered. + * + * @param string $alias + * @return void + */ + public function load($alias) + { + if (isset($this->aliases[$alias])) + { + return class_alias($this->aliases[$alias], $alias); + } + } + + /** + * Add an alias to the loader. + * + * @param string $class + * @param string $alias + * @return void + */ + public function alias($class, $alias) + { + $this->aliases[$class] = $alias; + } + + /** + * Register the loader on the auto-loader stack. + * + * @return void + */ + public function register() + { + if ( ! $this->registered) + { + $this->prependToLoaderStack(); + + $this->registered = true; + } + } + + /** + * Prepend the load method to the auto-loader stack. + * + * @return void + */ + protected function prependToLoaderStack() + { + spl_autoload_register(array($this, 'load'), true, true); + } + + /** + * Get the registered aliases. + * + * @return array + */ + public function getAliases() + { + return $this->aliases; + } + + /** + * Set the registered aliases. + * + * @param array $aliases + * @return void + */ + public function setAliases(array $aliases) + { + $this->aliases = $aliases; + } + + /** + * Indicates if the loader has been registered. + * + * @return bool + */ + public function isRegistered() + { + return $this->registered; + } + + /** + * Set the "registered" state of the loader. + * + * @param bool $value + * @return void + */ + public function setRegistered($value) + { + $this->registered = $value; + } + + /** + * Set the value of the singleton alias loader. + * + * @param \Illuminate\Foundation\AliasLoader $loader + * @return void + */ + public static function setInstance($loader) + { + static::$instance = $loader; + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Foundation/Application.php b/vendor/laravel/framework/src/Illuminate/Foundation/Application.php new file mode 100755 index 0000000..6e20717 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Foundation/Application.php @@ -0,0 +1,1128 @@ +registerBaseBindings($request ?: $this->createNewRequest()); + + $this->registerBaseServiceProviders(); + + $this->registerBaseMiddlewares(); + } + + /** + * Create a new request instance from the request class. + * + * @return \Illuminate\Http\Request + */ + protected function createNewRequest() + { + return forward_static_call(array(static::$requestClass, 'createFromGlobals')); + } + + /** + * Register the basic bindings into the container. + * + * @param \Illuminate\Http\Request $request + * @return void + */ + protected function registerBaseBindings($request) + { + $this->instance('request', $request); + + $this->instance('Illuminate\Container\Container', $this); + } + + /** + * Register all of the base service providers. + * + * @return void + */ + protected function registerBaseServiceProviders() + { + foreach (array('Event', 'Exception', 'Routing') as $name) + { + $this->{"register{$name}Provider"}(); + } + } + + /** + * Register the exception service provider. + * + * @return void + */ + protected function registerExceptionProvider() + { + $this->register(new ExceptionServiceProvider($this)); + } + + /** + * Register the routing service provider. + * + * @return void + */ + protected function registerRoutingProvider() + { + $this->register(new RoutingServiceProvider($this)); + } + + /** + * Register the event service provider. + * + * @return void + */ + protected function registerEventProvider() + { + $this->register(new EventServiceProvider($this)); + } + + /** + * Bind the installation paths to the application. + * + * @param array $paths + * @return void + */ + public function bindInstallPaths(array $paths) + { + $this->instance('path', realpath($paths['app'])); + + // Here we will bind the install paths into the container as strings that can be + // accessed from any point in the system. Each path key is prefixed with path + // so that they have the consistent naming convention inside the container. + foreach (array_except($paths, array('app')) as $key => $value) + { + $this->instance("path.{$key}", realpath($value)); + } + } + + /** + * Get the application bootstrap file. + * + * @return string + */ + public static function getBootstrapFile() + { + return __DIR__.'/start.php'; + } + + /** + * Start the exception handling for the request. + * + * @return void + */ + public function startExceptionHandling() + { + $this['exception']->register($this->environment()); + + $this['exception']->setDebug($this['config']['app.debug']); + } + + /** + * Get or check the current application environment. + * + * @param dynamic + * @return string + */ + public function environment() + { + if (count(func_get_args()) > 0) + { + return in_array($this['env'], func_get_args()); + } + else + { + return $this['env']; + } + } + + /** + * Determine if application is in local environment. + * + * @return bool + */ + public function isLocal() + { + return $this['env'] == 'local'; + } + + /** + * Detect the application's current environment. + * + * @param array|string $envs + * @return string + */ + public function detectEnvironment($envs) + { + $args = isset($_SERVER['argv']) ? $_SERVER['argv'] : null; + + return $this['env'] = with(new EnvironmentDetector())->detect($envs, $args); + } + + /** + * Determine if we are running in the console. + * + * @return bool + */ + public function runningInConsole() + { + return php_sapi_name() == 'cli'; + } + + /** + * Determine if we are running unit tests. + * + * @return bool + */ + public function runningUnitTests() + { + return $this['env'] == 'testing'; + } + + /** + * Force register a service provider with the application. + * + * @param \Illuminate\Support\ServiceProvider|string $provider + * @param array $options + * @return \Illuminate\Support\ServiceProvider + */ + public function forgeRegister($provider, $options = array()) + { + return $this->register($provider, $options, true); + } + + /** + * Register a service provider with the application. + * + * @param \Illuminate\Support\ServiceProvider|string $provider + * @param array $options + * @param bool $force + * @return \Illuminate\Support\ServiceProvider + */ + public function register($provider, $options = array(), $force = false) + { + if ($registered = $this->getRegistered($provider) && ! $force) + return $registered; + + // If the given "provider" is a string, we will resolve it, passing in the + // application instance automatically for the developer. This is simply + // a more convenient way of specifying your service provider classes. + if (is_string($provider)) + { + $provider = $this->resolveProviderClass($provider); + } + + $provider->register(); + + // Once we have registered the service we will iterate through the options + // and set each of them on the application so they will be available on + // the actual loading of the service objects and for developer usage. + foreach ($options as $key => $value) + { + $this[$key] = $value; + } + + $this->markAsRegistered($provider); + + // If the application has already booted, we will call this boot method on + // the provider class so it has an opportunity to do its boot logic and + // will be ready for any usage by the developer's application logics. + if ($this->booted) $provider->boot(); + + return $provider; + } + + /** + * Get the registered service provider instance if it exists. + * + * @param \Illuminate\Support\ServiceProvider|string $provider + * @return \Illuminate\Support\ServiceProvider|null + */ + public function getRegistered($provider) + { + $name = is_string($provider) ? $provider : get_class($provider); + + if (array_key_exists($name, $this->loadedProviders)) + { + return array_first($this->serviceProviders, function($key, $value) use ($name) + { + return get_class($value) == $name; + }); + } + } + + /** + * Resolve a service provider instance from the class name. + * + * @param string $provider + * @return \Illuminate\Support\ServiceProvider + */ + public function resolveProviderClass($provider) + { + return new $provider($this); + } + + /** + * Mark the given provider as registered. + * + * @param \Illuminate\Support\ServiceProvider + * @return void + */ + protected function markAsRegistered($provider) + { + $this['events']->fire($class = get_class($provider), array($provider)); + + $this->serviceProviders[] = $provider; + + $this->loadedProviders[$class] = true; + } + + /** + * Load and boot all of the remaining deferred providers. + * + * @return void + */ + public function loadDeferredProviders() + { + // We will simply spin through each of the deferred providers and register each + // one and boot them if the application has booted. This should make each of + // the remaining services available to this application for immediate use. + foreach ($this->deferredServices as $service => $provider) + { + $this->loadDeferredProvider($service); + } + + $this->deferredServices = array(); + } + + /** + * Load the provider for a deferred service. + * + * @param string $service + * @return void + */ + protected function loadDeferredProvider($service) + { + $provider = $this->deferredServices[$service]; + + // If the service provider has not already been loaded and registered we can + // register it with the application and remove the service from this list + // of deferred services, since it will already be loaded on subsequent. + if ( ! isset($this->loadedProviders[$provider])) + { + $this->registerDeferredProvider($provider, $service); + } + } + + /** + * Register a deferred provider and service. + * + * @param string $provider + * @param string $service + * @return void + */ + public function registerDeferredProvider($provider, $service = null) + { + // Once the provider that provides the deferred service has been registered we + // will remove it from our local list of the deferred services with related + // providers so that this container does not try to resolve it out again. + if ($service) unset($this->deferredServices[$service]); + + $this->register($instance = new $provider($this)); + + if ( ! $this->booted) + { + $this->booting(function() use ($instance) + { + $instance->boot(); + }); + } + } + + /** + * Resolve the given type from the container. + * + * (Overriding Container::make) + * + * @param string $abstract + * @param array $parameters + * @return mixed + */ + public function make($abstract, $parameters = array()) + { + $abstract = $this->getAlias($abstract); + + if (isset($this->deferredServices[$abstract])) + { + $this->loadDeferredProvider($abstract); + } + + return parent::make($abstract, $parameters); + } + + /** + * Register a "before" application filter. + * + * @param Closure|string $callback + * @return void + */ + public function before($callback) + { + return $this['router']->before($callback); + } + + /** + * Register an "after" application filter. + * + * @param Closure|string $callback + * @return void + */ + public function after($callback) + { + return $this['router']->after($callback); + } + + /** + * Register a "finish" application filter. + * + * @param Closure|string $callback + * @return void + */ + public function finish($callback) + { + $this->finishCallbacks[] = $callback; + } + + /** + * Register a "shutdown" callback. + * + * @param callable $callback + * @return void + */ + public function shutdown($callback = null) + { + if (is_null($callback)) + { + $this->fireAppCallbacks($this->shutdownCallbacks); + } + else + { + $this->shutdownCallbacks[] = $callback; + } + } + + /** + * Register a function for determining when to use array sessions. + * + * @param \Closure $callback + * @return void + */ + public function useArraySessions(Closure $callback) + { + $this->bind('session.reject', function() use ($callback) + { + return $callback; + }); + } + + /** + * Determine if the application has booted. + * + * @return bool + */ + public function isBooted() + { + return $this->booted; + } + + /** + * Boot the application's service providers. + * + * @return void + */ + public function boot() + { + if ($this->booted) return; + + array_walk($this->serviceProviders, function($p) { $p->boot(); }); + + $this->bootApplication(); + } + + /** + * Boot the application and fire app callbacks. + * + * @return void + */ + protected function bootApplication() + { + // Once the application has booted we will also fire some "booted" callbacks + // for any listeners that need to do work after this initial booting gets + // finished. This is useful when ordering the boot-up processes we run. + $this->fireAppCallbacks($this->bootingCallbacks); + + $this->booted = true; + + $this->fireAppCallbacks($this->bootedCallbacks); + } + + /** + * Register a new boot listener. + * + * @param mixed $callback + * @return void + */ + public function booting($callback) + { + $this->bootingCallbacks[] = $callback; + } + + /** + * Register a new "booted" listener. + * + * @param mixed $callback + * @return void + */ + public function booted($callback) + { + $this->bootedCallbacks[] = $callback; + + if ($this->isBooted()) $this->fireAppCallbacks(array($callback)); + } + + /** + * Run the application and send the response. + * + * @param \Symfony\Component\HttpFoundation\Request $request + * @return void + */ + public function run(SymfonyRequest $request = null) + { + $request = $request ?: $this['request']; + + $response = with($stack = $this->getStackedClient())->handle($request); + + $response->send(); + + $stack->terminate($request, $response); + } + + /** + * Get the stacked HTTP kernel for the application. + * + * @return \Symfony\Component\HttpKernel\HttpKernelInterface + */ + protected function getStackedClient() + { + $sessionReject = $this->bound('session.reject') ? $this['session.reject'] : null; + + $client = with(new \Stack\Builder) + ->push('Illuminate\Cookie\Guard', $this['encrypter']) + ->push('Illuminate\Cookie\Queue', $this['cookie']) + ->push('Illuminate\Session\Middleware', $this['session'], $sessionReject); + + $this->mergeCustomMiddlewares($client); + + return $client->resolve($this); + } + + /** + * Merge the developer defined middlewares onto the stack. + * + * @param \Stack\Builder + * @return void + */ + protected function mergeCustomMiddlewares(\Stack\Builder $stack) + { + foreach ($this->middlewares as $middleware) + { + list($class, $parameters) = array_values($middleware); + + array_unshift($parameters, $class); + + call_user_func_array(array($stack, 'push'), $parameters); + } + } + + /** + * Register the default, but optional middlewares. + * + * @return void + */ + protected function registerBaseMiddlewares() + { + $this->middleware('Illuminate\Http\FrameGuard'); + } + + /** + * Add a HttpKernel middleware onto the stack. + * + * @param string $class + * @param array $parameters + * @return \Illuminate\Foundation\Application + */ + public function middleware($class, array $parameters = array()) + { + $this->middlewares[] = compact('class', 'parameters'); + + return $this; + } + + /** + * Remove a custom middleware from the application. + * + * @param string $class + * @return void + */ + public function forgetMiddleware($class) + { + $this->middlewares = array_filter($this->middlewares, function($m) use ($class) + { + return $m['class'] != $class; + }); + } + + /** + * Handle the given request and get the response. + * + * Provides compatibility with BrowserKit functional testing. + * + * @implements HttpKernelInterface::handle + * + * @param \Symfony\Component\HttpFoundation\Request $request + * @param int $type + * @param bool $catch + * @return \Symfony\Component\HttpFoundation\Response + */ + public function handle(SymfonyRequest $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true) + { + try + { + $this->refreshRequest($request = Request::createFromBase($request)); + + $this->boot(); + + return $this->dispatch($request); + } + catch (\Exception $e) + { + if ($this->runningUnitTests()) throw $e; + + return $this['exception']->handleException($e); + } + } + + /** + * Handle the given request and get the response. + * + * @param \Illuminate\Http\Request $request + * @return \Symfony\Component\HttpFoundation\Response + */ + public function dispatch(Request $request) + { + if ($this->isDownForMaintenance()) + { + $response = $this['events']->until('illuminate.app.down'); + + if ( ! is_null($response)) return $this->prepareResponse($response, $request); + } + + if ($this->runningUnitTests() && ! $this['session']->isStarted()) + { + $this['session']->start(); + } + + return $this['router']->dispatch($this->prepareRequest($request)); + } + + /** + * Terminate the request and send the response to the browser. + * + * @param \Symfony\Component\HttpFoundation\Request $request + * @param \Symfony\Component\HttpFoundation\Response $response + * @return void + */ + public function terminate(SymfonyRequest $request, SymfonyResponse $response) + { + $this->callFinishCallbacks($request, $response); + + $this->shutdown(); + } + + /** + * Refresh the bound request instance in the container. + * + * @param \Illuminate\Http\Request $request + * @return void + */ + protected function refreshRequest(Request $request) + { + $this->instance('request', $request); + + Facade::clearResolvedInstance('request'); + } + + /** + * Call the "finish" callbacks assigned to the application. + * + * @param \Symfony\Component\HttpFoundation\Request $request + * @param \Symfony\Component\HttpFoundation\Response $response + * @return void + */ + public function callFinishCallbacks(SymfonyRequest $request, SymfonyResponse $response) + { + foreach ($this->finishCallbacks as $callback) + { + call_user_func($callback, $request, $response); + } + } + + /** + * Call the booting callbacks for the application. + * + * @return void + */ + protected function fireAppCallbacks(array $callbacks) + { + foreach ($callbacks as $callback) + { + call_user_func($callback, $this); + } + } + + /** + * Prepare the request by injecting any services. + * + * @param \Illuminate\Http\Request $request + * @return \Illuminate\Http\Request + */ + public function prepareRequest(Request $request) + { + if ( ! is_null($this['config']['session.driver']) && ! $request->hasSession()) + { + $request->setSession($this['session']->driver()); + } + + return $request; + } + + /** + * Prepare the given value as a Response object. + * + * @param mixed $value + * @return \Symfony\Component\HttpFoundation\Response + */ + public function prepareResponse($value) + { + if ( ! $value instanceof SymfonyResponse) $value = new Response($value); + + return $value->prepare($this['request']); + } + + /** + * Determine if the application is ready for responses. + * + * @return bool + */ + public function readyForResponses() + { + return $this->booted; + } + + /** + * Determine if the application is currently down for maintenance. + * + * @return bool + */ + public function isDownForMaintenance() + { + return file_exists($this['path.storage'].'/meta/down'); + } + + /** + * Register a maintenance mode event listener. + * + * @param \Closure $callback + * @return void + */ + public function down(Closure $callback) + { + $this['events']->listen('illuminate.app.down', $callback); + } + + /** + * Throw an HttpException with the given data. + * + * @param int $code + * @param string $message + * @param array $headers + * @return void + * + * @throws \Symfony\Component\HttpKernel\Exception\HttpException + * @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException + */ + public function abort($code, $message = '', array $headers = array()) + { + if ($code == 404) + { + throw new NotFoundHttpException($message); + } + else + { + throw new HttpException($code, $message, null, $headers); + } + } + + /** + * Register a 404 error handler. + * + * @param Closure $callback + * @return void + */ + public function missing(Closure $callback) + { + $this->error(function(NotFoundHttpException $e) use ($callback) + { + return call_user_func($callback, $e); + }); + } + + /** + * Register an application error handler. + * + * @param \Closure $callback + * @return void + */ + public function error(Closure $callback) + { + $this['exception']->error($callback); + } + + /** + * Register an error handler at the bottom of the stack. + * + * @param \Closure $callback + * @return void + */ + public function pushError(Closure $callback) + { + $this['exception']->pushError($callback); + } + + /** + * Register an error handler for fatal errors. + * + * @param Closure $callback + * @return void + */ + public function fatal(Closure $callback) + { + $this->error(function(FatalErrorException $e) use ($callback) + { + return call_user_func($callback, $e); + }); + } + + /** + * Get the configuration loader instance. + * + * @return \Illuminate\Config\LoaderInterface + */ + public function getConfigLoader() + { + return new FileLoader(new Filesystem, $this['path'].'/config'); + } + + /** + * Get the environment variables loader instance. + * + * @return \Illuminate\Config\EnvironmentVariablesLoaderInterface + */ + public function getEnvironmentVariablesLoader() + { + return new FileEnvironmentVariablesLoader(new Filesystem, $this['path.base']); + } + + /** + * Get the service provider repository instance. + * + * @return \Illuminate\Foundation\ProviderRepository + */ + public function getProviderRepository() + { + $manifest = $this['config']['app.manifest']; + + return new ProviderRepository(new Filesystem, $manifest); + } + + /** + * Get the service providers that have been loaded. + * + * @return array + */ + public function getLoadedProviders() + { + return $this->loadedProviders; + } + + /** + * Set the application's deferred services. + * + * @param array $services + * @return void + */ + public function setDeferredServices(array $services) + { + $this->deferredServices = $services; + } + + /** + * Determine if the given service is a deferred service. + * + * @param string $service + * @return bool + */ + public function isDeferredService($service) + { + return isset($this->deferredServices[$service]); + } + + /** + * Get or set the request class for the application. + * + * @param string $class + * @return string + */ + public static function requestClass($class = null) + { + if ( ! is_null($class)) static::$requestClass = $class; + + return static::$requestClass; + } + + /** + * Set the application request for the console environment. + * + * @return void + */ + public function setRequestForConsoleEnvironment() + { + $url = $this['config']->get('app.url', 'http://localhost'); + + $parameters = array($url, 'GET', array(), array(), array(), $_SERVER); + + $this->refreshRequest(static::onRequest('create', $parameters)); + } + + /** + * Call a method on the default request class. + * + * @param string $method + * @param array $parameters + * @return mixed + */ + public static function onRequest($method, $parameters = array()) + { + return forward_static_call_array(array(static::requestClass(), $method), $parameters); + } + + /** + * Get the current application locale. + * + * @return string + */ + public function getLocale() + { + return $this['config']->get('app.locale'); + } + + /** + * Set the current application locale. + * + * @param string $locale + * @return void + */ + public function setLocale($locale) + { + $this['config']->set('app.locale', $locale); + + $this['translator']->setLocale($locale); + + $this['events']->fire('locale.changed', array($locale)); + } + + /** + * Register the core class aliases in the container. + * + * @return void + */ + public function registerCoreContainerAliases() + { + $aliases = array( + 'app' => 'Illuminate\Foundation\Application', + 'artisan' => 'Illuminate\Console\Application', + 'auth' => 'Illuminate\Auth\AuthManager', + 'auth.reminder.repository' => 'Illuminate\Auth\Reminders\ReminderRepositoryInterface', + 'blade.compiler' => 'Illuminate\View\Compilers\BladeCompiler', + 'cache' => 'Illuminate\Cache\CacheManager', + 'cache.store' => 'Illuminate\Cache\Repository', + 'config' => 'Illuminate\Config\Repository', + 'cookie' => 'Illuminate\Cookie\CookieJar', + 'encrypter' => 'Illuminate\Encryption\Encrypter', + 'db' => 'Illuminate\Database\DatabaseManager', + 'events' => 'Illuminate\Events\Dispatcher', + 'files' => 'Illuminate\Filesystem\Filesystem', + 'form' => 'Illuminate\Html\FormBuilder', + 'hash' => 'Illuminate\Hashing\HasherInterface', + 'html' => 'Illuminate\Html\HtmlBuilder', + 'translator' => 'Illuminate\Translation\Translator', + 'log' => 'Illuminate\Log\Writer', + 'mailer' => 'Illuminate\Mail\Mailer', + 'paginator' => 'Illuminate\Pagination\Environment', + 'auth.reminder' => 'Illuminate\Auth\Reminders\PasswordBroker', + 'queue' => 'Illuminate\Queue\QueueManager', + 'redirect' => 'Illuminate\Routing\Redirector', + 'redis' => 'Illuminate\Redis\Database', + 'request' => 'Illuminate\Http\Request', + 'router' => 'Illuminate\Routing\Router', + 'session' => 'Illuminate\Session\SessionManager', + 'session.store' => 'Illuminate\Session\Store', + 'remote' => 'Illuminate\Remote\RemoteManager', + 'url' => 'Illuminate\Routing\UrlGenerator', + 'validator' => 'Illuminate\Validation\Factory', + 'view' => 'Illuminate\View\Environment', + ); + + foreach ($aliases as $key => $alias) + { + $this->alias($key, $alias); + } + } + + /** + * Dynamically access application services. + * + * @param string $key + * @return mixed + */ + public function __get($key) + { + return $this[$key]; + } + + /** + * Dynamically set application services. + * + * @param string $key + * @param mixed $value + * @return void + */ + public function __set($key, $value) + { + $this[$key] = $value; + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Foundation/Artisan.php b/vendor/laravel/framework/src/Illuminate/Foundation/Artisan.php new file mode 100755 index 0000000..8a61154 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Foundation/Artisan.php @@ -0,0 +1,60 @@ +app = $app; + } + + /** + * Get the Artisan console instance. + * + * @return \Illuminate\Console\Application + */ + protected function getArtisan() + { + if ( ! is_null($this->artisan)) return $this->artisan; + + $this->app->loadDeferredProviders(); + + $this->artisan = ConsoleApplication::make($this->app); + + return $this->artisan->boot(); + } + + /** + * Dynamically pass all missing methods to console Artisan. + * + * @param string $method + * @param array $parameters + * @return mixed + */ + public function __call($method, $parameters) + { + return call_user_func_array(array($this->getArtisan(), $method), $parameters); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Foundation/AssetPublisher.php b/vendor/laravel/framework/src/Illuminate/Foundation/AssetPublisher.php new file mode 100755 index 0000000..a7fd36d --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Foundation/AssetPublisher.php @@ -0,0 +1,94 @@ +files = $files; + $this->publishPath = $publishPath; + } + + /** + * Copy all assets from a given path to the publish path. + * + * @param string $name + * @param string $source + * @return bool + * + * @throws \RuntimeException + */ + public function publish($name, $source) + { + $destination = $this->publishPath."/packages/{$name}"; + + $success = $this->files->copyDirectory($source, $destination); + + if ( ! $success) + { + throw new \RuntimeException("Unable to publish assets."); + } + + return $success; + } + + /** + * Publish a given package's assets to the publish path. + * + * @param string $package + * @param string $packagePath + * @return bool + */ + public function publishPackage($package, $packagePath = null) + { + $packagePath = $packagePath ?: $this->packagePath; + + // Once we have the package path we can just create the source and destination + // path and copy the directory from one to the other. The directory copy is + // recursive so all nested files and directories will get copied as well. + $source = $packagePath."/{$package}/public"; + + return $this->publish($package, $source); + } + + /** + * Set the default package path. + * + * @param string $packagePath + * @return void + */ + public function setPackagePath($packagePath) + { + $this->packagePath = $packagePath; + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Foundation/Composer.php b/vendor/laravel/framework/src/Illuminate/Foundation/Composer.php new file mode 100755 index 0000000..00dc38b --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Foundation/Composer.php @@ -0,0 +1,98 @@ +files = $files; + $this->workingPath = $workingPath; + } + + /** + * Regenerate the Composer autoloader files. + * + * @param string $extra + * @return void + */ + public function dumpAutoloads($extra = '') + { + $process = $this->getProcess(); + + $process->setCommandLine(trim($this->findComposer().' dump-autoload '.$extra)); + + $process->run(); + } + + /** + * Regenerate the optimized Composer autoloader files. + * + * @return void + */ + public function dumpOptimized() + { + $this->dumpAutoloads('--optimize'); + } + + /** + * Get the composer command for the environment. + * + * @return string + */ + protected function findComposer() + { + if ($this->files->exists($this->workingPath.'/composer.phar')) + { + return 'php composer.phar'; + } + + return 'composer'; + } + + /** + * Get a new Symfony process instance. + * + * @return \Symfony\Component\Process\Process + */ + protected function getProcess() + { + return with(new Process('', $this->workingPath))->setTimeout(null); + } + + /** + * Set the working path used by the class. + * + * @param string $path + * @return \Illuminate\Foundation\Composer + */ + public function setWorkingPath($path) + { + $this->workingPath = realpath($path); + + return $this; + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Foundation/ConfigPublisher.php b/vendor/laravel/framework/src/Illuminate/Foundation/ConfigPublisher.php new file mode 100755 index 0000000..136a634 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Foundation/ConfigPublisher.php @@ -0,0 +1,122 @@ +files = $files; + $this->publishPath = $publishPath; + } + + /** + * Publish configuration files from a given path. + * + * @param string $package + * @param string $source + * @return bool + */ + public function publish($package, $source) + { + $destination = $this->publishPath."/packages/{$package}"; + + $this->makeDestination($destination); + + return $this->files->copyDirectory($source, $destination); + } + + /** + * Publish the configuration files for a package. + * + * @param string $package + * @param string $packagePath + * @return bool + */ + public function publishPackage($package, $packagePath = null) + { + // First we will figure out the source of the package's configuration location + // which we do by convention. Once we have that we will move the files over + // to the "main" configuration directory for this particular application. + $path = $packagePath ?: $this->packagePath; + + $source = $this->getSource($package, $path); + + return $this->publish($package, $source); + } + + /** + * Get the source configuration directory to publish. + * + * @param string $package + * @param string $packagePath + * @return string + * + * @throws \InvalidArgumentException + */ + protected function getSource($package, $packagePath) + { + $source = $packagePath."/{$package}/src/config"; + + if ( ! $this->files->isDirectory($source)) + { + throw new \InvalidArgumentException("Configuration not found."); + } + + return $source; + } + + /** + * Create the destination directory if it doesn't exist. + * + * @param string $destination + * @return void + */ + protected function makeDestination($destination) + { + if ( ! $this->files->isDirectory($destination)) + { + $this->files->makeDirectory($destination, 0777, true); + } + } + + /** + * Set the default package path. + * + * @param string $packagePath + * @return void + */ + public function setPackagePath($packagePath) + { + $this->packagePath = $packagePath; + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Foundation/Console/AssetPublishCommand.php b/vendor/laravel/framework/src/Illuminate/Foundation/Console/AssetPublishCommand.php new file mode 100755 index 0000000..d9cbf9d --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Foundation/Console/AssetPublishCommand.php @@ -0,0 +1,170 @@ +assets = $assets; + } + + /** + * Execute the console command. + * + * @return void + */ + public function fire() + { + foreach ($this->getPackages() as $package) + { + $this->publishAssets($package); + } + } + + /** + * Publish the assets for a given package name. + * + * @param string $package + * @return void + */ + protected function publishAssets($package) + { + if ( ! is_null($path = $this->getPath())) + { + $this->assets->publish($package, $path); + } + else + { + $this->assets->publishPackage($package); + } + + $this->output->writeln('Assets published for package: '.$package); + } + + /** + * Get the name of the package being published. + * + * @return array + */ + protected function getPackages() + { + if ( ! is_null($package = $this->input->getArgument('package'))) + { + return array($package); + } + elseif ( ! is_null($bench = $this->input->getOption('bench'))) + { + return array($bench); + } + + return $this->findAllAssetPackages(); + } + + /** + * Find all the asset hosting packages in the system. + * + * @return array + */ + protected function findAllAssetPackages() + { + $vendor = $this->laravel['path.base'].'/vendor'; + + $packages = array(); + + foreach (Finder::create()->directories()->in($vendor)->name('public')->depth('< 3') as $package) + { + $packages[] = $package->getRelativePath(); + } + + return $packages; + } + + /** + * Get the specified path to the files. + * + * @return string + */ + protected function getPath() + { + $path = $this->input->getOption('path'); + + // First we will check for an explicitly specified path from the user. If one + // exists we will use that as the path to the assets. This allows the free + // storage of assets wherever is best for this developer's web projects. + if ( ! is_null($path)) + { + return $this->laravel['path.base'].'/'.$path; + } + + // If a "bench" option was specified, we will publish from a workbench as the + // source location. This is mainly just a short-cut for having to manually + // specify the full workbench path using the --path command line option. + $bench = $this->input->getOption('bench'); + + if ( ! is_null($bench)) + { + return $this->laravel['path.base']."/workbench/{$bench}/public"; + } + } + + /** + * Get the console command arguments. + * + * @return array + */ + protected function getArguments() + { + return array( + array('package', InputArgument::OPTIONAL, 'The name of package being published.'), + ); + } + + /** + * Get the console command options. + * + * @return array + */ + protected function getOptions() + { + return array( + array('bench', null, InputOption::VALUE_OPTIONAL, 'The name of the workbench to publish.', null), + + array('path', null, InputOption::VALUE_OPTIONAL, 'The path to the asset files.', null), + ); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Foundation/Console/AutoloadCommand.php b/vendor/laravel/framework/src/Illuminate/Foundation/Console/AutoloadCommand.php new file mode 100755 index 0000000..69123bf --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Foundation/Console/AutoloadCommand.php @@ -0,0 +1,91 @@ +composer = $composer; + } + + /** + * Execute the console command. + * + * @return void + */ + public function fire() + { + $this->call('optimize'); + + foreach ($this->findWorkbenches() as $workbench) + { + $this->comment("Running for workbench [{$workbench['name']}]..."); + + $this->composer->setWorkingPath($workbench['path'])->dumpOptimized(); + } + } + + /** + * Get all of the workbench directories. + * + * @return array + */ + protected function findWorkbenches() + { + $results = array(); + + foreach ($this->getWorkbenchComposers() as $file) + { + $results[] = array('name' => $file->getRelativePath(), 'path' => $file->getPath()); + } + + return $results; + } + + /** + * Get all of the workbench composer files. + * + * @return \Symfony\Component\Finder\Finder + */ + protected function getWorkbenchComposers() + { + $workbench = $this->laravel['path.base'].'/workbench'; + + if ( ! is_dir($workbench)) return array(); + + return Finder::create()->files()->in($workbench)->name('composer.json')->depth('< 3'); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Foundation/Console/ChangesCommand.php b/vendor/laravel/framework/src/Illuminate/Foundation/Console/ChangesCommand.php new file mode 100755 index 0000000..fabfbaf --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Foundation/Console/ChangesCommand.php @@ -0,0 +1,114 @@ +getChangeVersion($this->getChangesArray()); + + $this->writeHeader($version); + + foreach ($changes as $change) + { + $this->line($this->formatMessage($change)); + } + } + + /** + * Write the heading for the change log. + * + * @param string $version + * @return void + */ + protected function writeHeader($version) + { + $this->info($heading = 'Changes For Laravel '.$version); + + $this->comment(str_repeat('-', strlen($heading))); + } + + /** + * Format the given change message. + * + * @param array $change + * @return string + */ + protected function formatMessage(array $change) + { + $message = '-> '.$change['message'].''; + + if ( ! is_null($change['backport'])) + { + $message .= ' (Backported to '.$change['backport'].')'; + } + + return $message; + } + + /** + * Get the change list for the specified version. + * + * @param array $changes + * @return array + */ + protected function getChangeVersion(array $changes) + { + $version = $this->argument('version'); + + if (is_null($version)) + { + $latest = head(array_keys($changes)); + + return array($latest, $changes[$latest]); + } + else + { + return array($version, array_get($changes, $version, array())); + } + } + + /** + * Get the changes array from disk. + * + * @return array + */ + protected function getChangesArray() + { + return json_decode(file_get_contents(__DIR__.'/../changes.json'), true); + } + + /** + * Get the console command arguments. + * + * @return array + */ + protected function getArguments() + { + return array( + array('version', InputArgument::OPTIONAL, 'The version to list changes for.'), + ); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Foundation/Console/ClearCompiledCommand.php b/vendor/laravel/framework/src/Illuminate/Foundation/Console/ClearCompiledCommand.php new file mode 100755 index 0000000..a0b9b86 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Foundation/Console/ClearCompiledCommand.php @@ -0,0 +1,39 @@ +laravel['path.base'].'/bootstrap/compiled.php')) + { + @unlink($path); + } + + if (file_exists($path = $this->laravel['path.storage'].'/meta/services.json')) + { + @unlink($path); + } + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Foundation/Console/CommandMakeCommand.php b/vendor/laravel/framework/src/Illuminate/Foundation/Console/CommandMakeCommand.php new file mode 100755 index 0000000..9f73ee8 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Foundation/Console/CommandMakeCommand.php @@ -0,0 +1,160 @@ +files = $files; + } + + /** + * Execute the console command. + * + * @return void + */ + public function fire() + { + $path = $this->getPath(); + + $stub = $this->files->get(__DIR__.'/stubs/command.stub'); + + // We'll grab the class name to determine the file name. Since applications are + // typically using the PSR-0 standards we can safely assume the classes name + // will correspond to what the actual file should be stored as on storage. + $file = $path.'/'.$this->input->getArgument('name').'.php'; + + $this->writeCommand($file, $stub); + } + + /** + * Write the finished command file to disk. + * + * @param string $file + * @param string $stub + * @return void + */ + protected function writeCommand($file, $stub) + { + if ( ! file_exists($file)) + { + $this->files->put($file, $this->formatStub($stub)); + + $this->info('Command created successfully.'); + } + else + { + $this->error('Command already exists!'); + } + } + + /** + * Format the command class stub. + * + * @param string $stub + * @return string + */ + protected function formatStub($stub) + { + $stub = str_replace('{{class}}', $this->input->getArgument('name'), $stub); + + if ( ! is_null($this->option('command'))) + { + $stub = str_replace('command:name', $this->option('command'), $stub); + } + + return $this->addNamespace($stub); + } + + /** + * Add the proper namespace to the command. + * + * @param string $stub + * @return string + */ + protected function addNamespace($stub) + { + if ( ! is_null($namespace = $this->input->getOption('namespace'))) + { + return str_replace('{{namespace}}', ' namespace '.$namespace.';', $stub); + } + else + { + return str_replace('{{namespace}}', '', $stub); + } + } + + /** + * Get the path where the command should be stored. + * + * @return string + */ + protected function getPath() + { + $path = $this->input->getOption('path'); + + if (is_null($path)) + { + return $this->laravel['path'].'/commands'; + } + else + { + return $this->laravel['path.base'].'/'.$path; + } + } + + /** + * Get the console command arguments. + * + * @return array + */ + protected function getArguments() + { + return array( + array('name', InputArgument::REQUIRED, 'The name of the command.'), + ); + } + + /** + * Get the console command options. + * + * @return array + */ + protected function getOptions() + { + return array( + array('command', null, InputOption::VALUE_OPTIONAL, 'The terminal command that should be assigned.', null), + + array('path', null, InputOption::VALUE_OPTIONAL, 'The path where the command should be stored.', null), + + array('namespace', null, InputOption::VALUE_OPTIONAL, 'The command namespace.', null), + ); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Foundation/Console/ConfigPublishCommand.php b/vendor/laravel/framework/src/Illuminate/Foundation/Console/ConfigPublishCommand.php new file mode 100755 index 0000000..728569d --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Foundation/Console/ConfigPublishCommand.php @@ -0,0 +1,104 @@ +config = $config; + } + + /** + * Execute the console command. + * + * @return void + */ + public function fire() + { + $package = $this->input->getArgument('package'); + + if ( ! is_null($path = $this->getPath())) + { + $this->config->publish($package, $path); + } + else + { + $this->config->publishPackage($package); + } + + $this->output->writeln('Configuration published for package: '.$package); + } + + /** + * Get the specified path to the files. + * + * @return string + */ + protected function getPath() + { + $path = $this->input->getOption('path'); + + if ( ! is_null($path)) + { + return $this->laravel['path.base'].'/'.$path; + } + } + + /** + * Get the console command arguments. + * + * @return array + */ + protected function getArguments() + { + return array( + array('package', InputArgument::REQUIRED, 'The name of the package being published.'), + ); + } + + /** + * Get the console command options. + * + * @return array + */ + protected function getOptions() + { + return array( + array('path', null, InputOption::VALUE_OPTIONAL, 'The path to the configuration files.', null), + ); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Foundation/Console/DownCommand.php b/vendor/laravel/framework/src/Illuminate/Foundation/Console/DownCommand.php new file mode 100755 index 0000000..81fd951 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Foundation/Console/DownCommand.php @@ -0,0 +1,33 @@ +laravel['path.storage'].'/meta/down'); + + $this->comment('Application is now in maintenance mode.'); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Foundation/Console/EnvironmentCommand.php b/vendor/laravel/framework/src/Illuminate/Foundation/Console/EnvironmentCommand.php new file mode 100755 index 0000000..5a12976 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Foundation/Console/EnvironmentCommand.php @@ -0,0 +1,31 @@ +line('Current application environment: '.$this->laravel['env'].''); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Foundation/Console/KeyGenerateCommand.php b/vendor/laravel/framework/src/Illuminate/Foundation/Console/KeyGenerateCommand.php new file mode 100755 index 0000000..50a6b8e --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Foundation/Console/KeyGenerateCommand.php @@ -0,0 +1,80 @@ +files = $files; + } + + /** + * Execute the console command. + * + * @return void + */ + public function fire() + { + list($path, $contents) = $this->getKeyFile(); + + $key = $this->getRandomKey(); + + $contents = str_replace($this->laravel['config']['app.key'], $key, $contents); + + $this->files->put($path, $contents); + + $this->laravel['config']['app.key'] = $key; + + $this->info("Application key [$key] set successfully."); + } + + /** + * Get the key file and contents. + * + * @return array + */ + protected function getKeyFile() + { + $env = $this->option('env') ? $this->option('env').'/' : ''; + + $contents = $this->files->get($path = $this->laravel['path']."/config/{$env}app.php"); + + return array($path, $contents); + } + + /** + * Generate a random key for the application. + * + * @return string + */ + protected function getRandomKey() + { + return Str::random(32); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Foundation/Console/MigratePublishCommand.php b/vendor/laravel/framework/src/Illuminate/Foundation/Console/MigratePublishCommand.php new file mode 100755 index 0000000..a7deca9 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Foundation/Console/MigratePublishCommand.php @@ -0,0 +1,63 @@ +laravel['migration.publisher']->publish( + $this->getSourcePath(), $this->laravel['path'].'/database/migrations' + ); + + foreach ($published as $migration) + { + $this->line('Published: '.basename($migration)); + } + } + + /** + * Get the path to the source files. + * + * @return string + */ + protected function getSourcePath() + { + $vendor = $this->laravel['path.base'].'/vendor'; + + return $vendor.'/'.$this->argument('package').'/src/migrations'; + } + + /** + * Get the console command arguments. + * + * @return array + */ + protected function getArguments() + { + return array( + array('package', InputArgument::REQUIRED, 'The name of the package being published.'), + ); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Foundation/Console/Optimize/config.php b/vendor/laravel/framework/src/Illuminate/Foundation/Console/Optimize/config.php new file mode 100755 index 0000000..2cd02a2 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Foundation/Console/Optimize/config.php @@ -0,0 +1,117 @@ +composer = $composer; + } + + /** + * Execute the console command. + * + * @return void + */ + public function fire() + { + $this->info('Generating optimized class loader'); + + if ($this->option('psr')) + { + $this->composer->dumpAutoloads(); + } + else + { + $this->composer->dumpOptimized(); + } + + if ($this->option('force') || ! $this->laravel['config']['app.debug']) + { + $this->info('Compiling common classes'); + + $this->compileClasses(); + } + else + { + $this->call('clear-compiled'); + } + } + + /** + * Generate the compiled class file. + * + * @return void + */ + protected function compileClasses() + { + $this->registerClassPreloaderCommand(); + + $outputPath = $this->laravel['path.base'].'/bootstrap/compiled.php'; + + $this->callSilent('compile', array( + '--config' => implode(',', $this->getClassFiles()), + '--output' => $outputPath, + '--strip_comments' => 1, + )); + } + + /** + * Get the classes that should be combined and compiled. + * + * @return array + */ + protected function getClassFiles() + { + $app = $this->laravel; + + $core = require __DIR__.'/Optimize/config.php'; + + return array_merge($core, $this->laravel['config']['compile']); + } + + /** + * Register the pre-compiler command instance with Artisan. + * + * @return void + */ + protected function registerClassPreloaderCommand() + { + $this->getApplication()->add(new PreCompileCommand); + } + + /** + * Get the console command options. + * + * @return array + */ + protected function getOptions() + { + return array( + array('force', null, InputOption::VALUE_NONE, 'Force the compiled class file to be written.'), + + array('psr', null, InputOption::VALUE_NONE, 'Do not optimize Composer dump-autoload.'), + ); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Foundation/Console/RoutesCommand.php b/vendor/laravel/framework/src/Illuminate/Foundation/Console/RoutesCommand.php new file mode 100755 index 0000000..16f8e81 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Foundation/Console/RoutesCommand.php @@ -0,0 +1,231 @@ +router = $router; + $this->routes = $router->getRoutes(); + } + + /** + * Execute the console command. + * + * @return void + */ + public function fire() + { + $this->table = $this->getHelperSet()->get('table'); + + if (count($this->routes) == 0) + { + return $this->error("Your application doesn't have any routes."); + } + + $this->displayRoutes($this->getRoutes()); + } + + /** + * Compile the routes into a displayable format. + * + * @return array + */ + protected function getRoutes() + { + $results = array(); + + foreach($this->routes as $route) + { + $results[] = $this->getRouteInformation($route); + } + + return array_filter($results); + } + + /** + * Get the route information for a given route. + * + * @param string $name + * @param \Illuminate\Routing\Route $route + * @return array + */ + protected function getRouteInformation(Route $route) + { + $uri = implode('|', $route->methods()).' '.$route->uri(); + + return $this->filterRoute(array( + 'host' => $route->domain(), + 'uri' => $uri, + 'name' => $route->getName(), + 'action' => $route->getActionName(), + 'before' => $this->getBeforeFilters($route), + 'after' => $this->getAfterFilters($route) + )); + } + + /** + * Display the route information on the console. + * + * @param array $routes + * @return void + */ + protected function displayRoutes(array $routes) + { + $this->table->setHeaders($this->headers)->setRows($routes); + + $this->table->render($this->getOutput()); + } + + /** + * Get before filters + * + * @param \Illuminate\Routing\Route $route + * @return string + */ + protected function getBeforeFilters($route) + { + $before = array_keys($route->beforeFilters()); + + $before = array_unique(array_merge($before, $this->getPatternFilters($route))); + + return implode(', ', $before); + } + + /** + * Get all of the pattern filters matching the route. + * + * @param \Illuminate\Routing\Route $route + * @return array + */ + protected function getPatternFilters($route) + { + $patterns = array(); + + foreach ($route->methods() as $method) + { + // For each method supported by the route we will need to gather up the patterned + // filters for that method. We will then merge these in with the other filters + // we have already gathered up then return them back out to these consumers. + $inner = $this->getMethodPatterns($route->uri(), $method); + + $patterns = array_merge($patterns, array_keys($inner)); + } + + return $patterns; + } + + /** + * Get the pattern filters for a given URI and method. + * + * @param string $uri + * @param string $method + * @return array + */ + protected function getMethodPatterns($uri, $method) + { + return $this->router->findPatternFilters(Request::create($uri, $method)); + } + + /** + * Get after filters + * + * @param Route $route + * @return string + */ + protected function getAfterFilters($route) + { + return implode(', ', array_keys($route->afterFilters())); + } + + /** + * Filter the route by URI and / or name. + * + * @param array $route + * @return array|null + */ + protected function filterRoute(array $route) + { + if (($this->option('name') && ! str_contains($route['name'], $this->option('name'))) || + $this->option('path') && ! str_contains($route['uri'], $this->option('path'))) + { + return null; + } + else + { + return $route; + } + } + + /** + * Get the console command options. + * + * @return array + */ + protected function getOptions() + { + return array( + array('name', null, InputOption::VALUE_OPTIONAL, 'Filter the routes by name.'), + + array('path', null, InputOption::VALUE_OPTIONAL, 'Filter the routes by path.'), + ); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Foundation/Console/ServeCommand.php b/vendor/laravel/framework/src/Illuminate/Foundation/Console/ServeCommand.php new file mode 100755 index 0000000..998105f --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Foundation/Console/ServeCommand.php @@ -0,0 +1,73 @@ +checkPhpVersion(); + + chdir($this->laravel['path.base']); + + $host = $this->input->getOption('host'); + + $port = $this->input->getOption('port'); + + $public = $this->laravel['path.public']; + + $this->info("Laravel development server started on http://{$host}:{$port}"); + + passthru('"'.PHP_BINARY.'"'." -S {$host}:{$port} -t \"{$public}\" server.php"); + } + + /** + * Check the current PHP version is >= 5.4. + * + * @return void + * + * @throws \Exception + */ + protected function checkPhpVersion() + { + if (version_compare(PHP_VERSION, '5.4.0', '<')) + { + throw new \Exception('This PHP binary is not version 5.4 or greater.'); + } + } + + /** + * Get the console command options. + * + * @return array + */ + protected function getOptions() + { + return array( + array('host', null, InputOption::VALUE_OPTIONAL, 'The host address to serve the application on.', 'localhost'), + + array('port', null, InputOption::VALUE_OPTIONAL, 'The port to serve the application on.', 8000), + ); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Foundation/Console/TailCommand.php b/vendor/laravel/framework/src/Illuminate/Foundation/Console/TailCommand.php new file mode 100755 index 0000000..b4c7871 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Foundation/Console/TailCommand.php @@ -0,0 +1,167 @@ +getPath($this->argument('connection')); + + if ($path) + { + $this->tailLogFile($path, $this->argument('connection')); + } + else + { + $this->error('Could not determine path to log file.'); + } + } + + /** + * Tail the given log file for the connection. + * + * @param string $path + * @param string $connection + * @return void + */ + protected function tailLogFile($path, $connection) + { + if (is_null($connection)) + { + $this->tailLocalLogs($path); + } + else + { + $this->tailRemoteLogs($path, $connection); + } + } + + /** + * Tail a local log file for the application. + * + * @param string $path + * @return string + */ + protected function tailLocalLogs($path) + { + $output = $this->output; + + $lines = $this->option('lines'); + + with(new Process('tail -f -n '.$lines.' '.$path))->setTimeout(null)->run(function($type, $line) use ($output) + { + $output->write($line); + }); + } + + /** + * Tail a remote log file at the given path and connection. + * + * @param string $path + * @param string $connection + * @return void + */ + protected function tailRemoteLogs($path, $connection) + { + $out = $this->output; + + $lines = $this->option('lines'); + + $this->getRemote($connection)->run('tail -f -n '.$lines.' '.$path, function($line) use ($out) + { + $out->write($line); + }); + } + + /** + * Get a connection to the remote server. + * + * @param string $connection + * @return \Illuminate\Remote\Connection + */ + protected function getRemote($connection) + { + return $this->laravel['remote']->connection($connection); + } + + /** + * Get the path to the Laravel log file. + * + * @param string $connection + * @return string + */ + protected function getPath($connection) + { + if ($this->option('path')) return $this->option('path'); + + if (is_null($connection)) + { + return base_path().'/app/storage/logs/laravel.log'; + } + else + { + return $this->getRoot($connection).'/app/storage/logs/laravel.log'; + } + } + + /** + * Get the path to the Laravel install root. + * + * @param string $connection + * @return string + */ + protected function getRoot($connection) + { + return $this->laravel['config']['remote.connections.'.$connection.'.root']; + } + + /** + * Get the console command arguments. + * + * @return array + */ + protected function getArguments() + { + return array( + array('connection', InputArgument::OPTIONAL, 'The remote connection name'), + ); + } + + /** + * Get the console command options. + * + * @return array + */ + protected function getOptions() + { + return array( + array('path', null, InputOption::VALUE_OPTIONAL, 'The fully qualified path to the log file.'), + + array('lines', null, InputOption::VALUE_OPTIONAL, 'The number of lines to tail.', 20), + ); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Foundation/Console/TinkerCommand.php b/vendor/laravel/framework/src/Illuminate/Foundation/Console/TinkerCommand.php new file mode 100755 index 0000000..af70ece --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Foundation/Console/TinkerCommand.php @@ -0,0 +1,124 @@ +supportsBoris()) + { + $this->runBorisShell(); + } + else + { + $this->comment('Full REPL not supported. Falling back to simple shell.'); + + $this->runPlainShell(); + } + } + + /** + * Run the Boris REPL with the current context. + * + * @return void + */ + protected function runBorisShell() + { + $this->setupBorisErrorHandling(); + + with(new \Boris\Boris('> '))->start(); + } + + /** + * Setup the Boris exception handling. + * + * @return void + */ + protected function setupBorisErrorHandling() + { + restore_error_handler(); restore_exception_handler(); + + $this->laravel->make('artisan')->setCatchExceptions(false); + + $this->laravel->error(function() { return ''; }); + } + + /** + * Run the plain Artisan tinker shell. + * + * @return void + */ + protected function runPlainShell() + { + $input = $this->prompt(); + + while ($input != 'quit') + { + // We will wrap the execution of the command in a try / catch block so we + // can easily display the errors in a convenient way instead of having + // them bubble back out to the CLI and stop the entire command loop. + try + { + if (starts_with($input, 'dump ')) + { + $input = 'var_dump('.substr($input, 5).');'; + } + + eval($input); + } + + // If an exception occurs, we will just display the message and keep this + // loop going so we can keep executing commands. However, when a fatal + // error occurs, we have no choice but to bail out of this routines. + catch (\Exception $e) + { + $this->error($e->getMessage()); + } + + $input = $this->prompt(); + } + } + + /** + * Prompt the developer for a command. + * + * @return string + */ + protected function prompt() + { + $dialog = $this->getHelperSet()->get('dialog'); + + return $dialog->ask($this->output, ">", null); + } + + /** + * Determine if the current environment supports Boris. + * + * @return bool + */ + protected function supportsBoris() + { + return extension_loaded('readline') && extension_loaded('posix') && extension_loaded('pcntl'); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Foundation/Console/UpCommand.php b/vendor/laravel/framework/src/Illuminate/Foundation/Console/UpCommand.php new file mode 100755 index 0000000..f34248a --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Foundation/Console/UpCommand.php @@ -0,0 +1,33 @@ +laravel['path.storage'].'/meta/down'); + + $this->info('Application is now live.'); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Foundation/Console/ViewPublishCommand.php b/vendor/laravel/framework/src/Illuminate/Foundation/Console/ViewPublishCommand.php new file mode 100755 index 0000000..4353619 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Foundation/Console/ViewPublishCommand.php @@ -0,0 +1,104 @@ +view = $view; + } + + /** + * Execute the console command. + * + * @return void + */ + public function fire() + { + $package = $this->input->getArgument('package'); + + if ( ! is_null($path = $this->getPath())) + { + $this->view->publish($package, $path); + } + else + { + $this->view->publishPackage($package); + } + + $this->output->writeln('Views published for package: '.$package); + } + + /** + * Get the specified path to the files. + * + * @return string + */ + protected function getPath() + { + $path = $this->input->getOption('path'); + + if ( ! is_null($path)) + { + return $this->laravel['path.base'].'/'.$path; + } + } + + /** + * Get the console command arguments. + * + * @return array + */ + protected function getArguments() + { + return array( + array('package', InputArgument::REQUIRED, 'The name of the package being published.'), + ); + } + + /** + * Get the console command options. + * + * @return array + */ + protected function getOptions() + { + return array( + array('path', null, InputOption::VALUE_OPTIONAL, 'The path to the source view files.', null), + ); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Foundation/Console/stubs/command.stub b/vendor/laravel/framework/src/Illuminate/Foundation/Console/stubs/command.stub new file mode 100755 index 0000000..d48e675 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Foundation/Console/stubs/command.stub @@ -0,0 +1,67 @@ +detectConsoleEnvironment($environments, $consoleArgs); + } + else + { + return $this->detectWebEnvironment($environments); + } + } + + /** + * Set the application environment for a web request. + * + * @param array|string $environments + * @return string + */ + protected function detectWebEnvironment($environments) + { + // If the given environment is just a Closure, we will defer the environment check + // to the Closure the developer has provided, which allows them to totally swap + // the webs environment detection logic with their own custom Closure's code. + if ($environments instanceof Closure) + { + return call_user_func($environments); + } + + foreach ($environments as $environment => $hosts) + { + // To determine the current environment, we'll simply iterate through the possible + // environments and look for the host that matches the host for this request we + // are currently processing here, then return back these environment's names. + foreach ((array) $hosts as $host) + { + if ($this->isMachine($host)) return $environment; + } + } + + return 'production'; + } + + /** + * Set the application environment from command-line arguments. + * + * @param mixed $environments + * @param array $args + * @return string + */ + protected function detectConsoleEnvironment($environments, array $args) + { + // First we will check if an environment argument was passed via console arguments + // and if it was that automatically overrides as the environment. Otherwise, we + // will check the environment as a "web" request like a typical HTTP request. + if ( ! is_null($value = $this->getEnvironmentArgument($args))) + { + return head(array_slice(explode('=', $value), 1)); + } + else + { + return $this->detectWebEnvironment($environments); + } + } + + /** + * Get the environment argument from the console. + * + * @param array $args + * @return string|null + */ + protected function getEnvironmentArgument(array $args) + { + return array_first($args, function($k, $v) + { + return starts_with($v, '--env'); + }); + } + + /** + * Determine if the name matches the machine name. + * + * @param string $name + * @return bool + */ + public function isMachine($name) + { + return str_is($name, gethostname()); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Foundation/MigrationPublisher.php b/vendor/laravel/framework/src/Illuminate/Foundation/MigrationPublisher.php new file mode 100755 index 0000000..8ec77e1 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Foundation/MigrationPublisher.php @@ -0,0 +1,132 @@ +files = $files; + } + + /** + * Publish the given package's migrations. + * + * @param string $source + * @param string $destination + * @return array + */ + public function publish($source, $destination) + { + $add = 0; + + $published = array(); + + foreach ($this->getFreshMigrations($source, $destination) as $file) + { + $add++; + + $newName = $this->getNewMigrationName($file, $add); + + $this->files->copy( + $file, $newName = $destination.'/'.$newName + ); + + $published[] = $newName; + } + + return $published; + } + + /** + * Get the fresh migrations for the source. + * + * @param string $source + * @param string $destination + * @return array + */ + protected function getFreshMigrations($source, $destination) + { + $me = $this; + + return array_filter($this->getPackageMigrations($source), function($file) use ($me, $destination) + { + return ! $me->migrationExists($file, $destination); + }); + } + + /** + * Determine if the migration is already published. + * + * @param string $migration + * @return bool + */ + public function migrationExists($migration, $destination) + { + $existing = $this->getExistingMigrationNames($destination); + + return in_array(substr(basename($migration), 18), $existing); + } + + /** + * Get the existing migration names from the destination. + * + * @param string $destination + * @return array + */ + public function getExistingMigrationNames($destination) + { + if (isset($this->existing[$destination])) return $this->existing[$destination]; + + return $this->existing[$destination] = array_map(function($file) + { + return substr(basename($file), 18); + + }, $this->files->files($destination)); + } + + /** + * Get the file list from the source directory. + * + * @param string $source + * @return array + */ + protected function getPackageMigrations($source) + { + $files = array_filter($this->files->files($source), function($file) + { + return ! starts_with($file, '.'); + }); + + sort($files); + + return $files; + } + + /** + * Get the new migration name. + * + * @param string $file + * @param int $add + * @return string + */ + protected function getNewMigrationName($file, $add) + { + return Carbon::now()->addSeconds($add)->format('Y_m_d_His').substr(basename($file), 17); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Foundation/ProviderRepository.php b/vendor/laravel/framework/src/Illuminate/Foundation/ProviderRepository.php new file mode 100755 index 0000000..7173984 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Foundation/ProviderRepository.php @@ -0,0 +1,231 @@ + array()); + + /** + * Create a new service repository instance. + * + * @param \Illuminate\Filesystem\Filesystem $files + * @param string $manifestPath + * @return void + */ + public function __construct(Filesystem $files, $manifestPath) + { + $this->files = $files; + $this->manifestPath = $manifestPath; + } + + /** + * Register the application service providers. + * + * @param \Illuminate\Foundation\Application $app + * @param array $providers + * @param string $path + * @return void + */ + public function load(Application $app, array $providers) + { + $manifest = $this->loadManifest(); + + // First we will load the service manifest, which contains information on all + // service providers registered with the application and which services it + // provides. This is used to know which services are "deferred" loaders. + if ($this->shouldRecompile($manifest, $providers)) + { + $manifest = $this->compileManifest($app, $providers); + } + + // If the application is running in the console, we will not lazy load any of + // the service providers. This is mainly because it's not as necessary for + // performance and also so any provided Artisan commands get registered. + if ($app->runningInConsole()) + { + $manifest['eager'] = $manifest['providers']; + } + + // Next, we will register events to load the providers for each of the events + // that it has requested. This allows the service provider to defer itself + // while still getting automatically loaded when a certain event occurs. + foreach ($manifest['when'] as $provider => $events) + { + $this->registerLoadEvents($app, $provider, $events); + } + + // We will go ahead and register all of the eagerly loaded providers with the + // application so their services can be registered with the application as + // a provided service. Then we will set the deferred service list on it. + foreach ($manifest['eager'] as $provider) + { + $app->register($this->createProvider($app, $provider)); + } + + $app->setDeferredServices($manifest['deferred']); + } + + /** + * Register the load events for the given provider. + * + * @param \Illuminate\Foundation\Application $app + * @param string $provider + * @param array $events + * @return void + */ + protected function registerLoadEvents(Application $app, $provider, array $events) + { + if (count($events) < 1) return; + + $app->make('events')->listen($events, function() use ($app, $provider) + { + $app->register($provider); + }); + } + + /** + * Compile the application manifest file. + * + * @param \Illuminate\Foundation\Application $app + * @param array $providers + * @return array + */ + protected function compileManifest(Application $app, $providers) + { + // The service manifest should contain a list of all of the providers for + // the application so we can compare it on each request to the service + // and determine if the manifest should be recompiled or is current. + $manifest = $this->freshManifest($providers); + + foreach ($providers as $provider) + { + $instance = $this->createProvider($app, $provider); + + // When recompiling the service manifest, we will spin through each of the + // providers and check if it's a deferred provider or not. If so we'll + // add it's provided services to the manifest and note the provider. + if ($instance->isDeferred()) + { + foreach ($instance->provides() as $service) + { + $manifest['deferred'][$service] = $provider; + } + + $manifest['when'][$provider] = $instance->when(); + } + + // If the service providers are not deferred, we will simply add it to an + // of eagerly loaded providers that will be registered with the app on + // each request to the applications instead of being lazy loaded in. + else + { + $manifest['eager'][] = $provider; + } + } + + return $this->writeManifest($manifest); + } + + /** + * Create a new provider instance. + * + * @param \Illuminate\Foundation\Application $app + * @param string $provider + * @return \Illuminate\Support\ServiceProvider + */ + public function createProvider(Application $app, $provider) + { + return new $provider($app); + } + + /** + * Determine if the manifest should be compiled. + * + * @param array $manifest + * @param array $providers + * @return bool + */ + public function shouldRecompile($manifest, $providers) + { + return is_null($manifest) || $manifest['providers'] != $providers; + } + + /** + * Load the service provider manifest JSON file. + * + * @return array + */ + public function loadManifest() + { + $path = $this->manifestPath.'/services.json'; + + // The service manifest is a file containing a JSON representation of every + // service provided by the application and whether its provider is using + // deferred loading or should be eagerly loaded on each request to us. + if ($this->files->exists($path)) + { + $manifest = json_decode($this->files->get($path), true); + + return array_merge($this->default, $manifest); + } + } + + /** + * Write the service manifest file to disk. + * + * @param array $manifest + * @return array + */ + public function writeManifest($manifest) + { + $path = $this->manifestPath.'/services.json'; + + $this->files->put($path, json_encode($manifest)); + + return $manifest; + } + + /** + * Create a fresh manifest array. + * + * @param array $providers + * @return array + */ + protected function freshManifest(array $providers) + { + list($eager, $deferred) = array(array(), array()); + + return compact('providers', 'eager', 'deferred'); + } + + /** + * Get the filesystem instance. + * + * @return \Illuminate\Filesystem\Filesystem + */ + public function getFilesystem() + { + return $this->files; + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Foundation/Providers/ArtisanServiceProvider.php b/vendor/laravel/framework/src/Illuminate/Foundation/Providers/ArtisanServiceProvider.php new file mode 100755 index 0000000..8e83929 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Foundation/Providers/ArtisanServiceProvider.php @@ -0,0 +1,58 @@ +app->bindShared('artisan', function($app) + { + return new Artisan($app); + }); + + $this->app->bindShared('command.tail', function($app) + { + return new TailCommand; + }); + + $this->app->bindShared('command.changes', function($app) + { + return new ChangesCommand; + }); + + $this->app->bindShared('command.environment', function($app) + { + return new EnvironmentCommand; + }); + + $this->commands('command.tail', 'command.changes', 'command.environment'); + } + + /** + * Get the services provided by the provider. + * + * @return array + */ + public function provides() + { + return array('artisan', 'command.changes', 'command.environment'); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Foundation/Providers/CommandCreatorServiceProvider.php b/vendor/laravel/framework/src/Illuminate/Foundation/Providers/CommandCreatorServiceProvider.php new file mode 100755 index 0000000..07610a8 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Foundation/Providers/CommandCreatorServiceProvider.php @@ -0,0 +1,42 @@ +app->bindShared('command.command.make', function($app) + { + return new CommandMakeCommand($app['files']); + }); + + $this->commands('command.command.make'); + } + + /** + * Get the services provided by the provider. + * + * @return array + */ + public function provides() + { + return array( + 'command.command.make', + ); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Foundation/Providers/ComposerServiceProvider.php b/vendor/laravel/framework/src/Illuminate/Foundation/Providers/ComposerServiceProvider.php new file mode 100755 index 0000000..570e22d --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Foundation/Providers/ComposerServiceProvider.php @@ -0,0 +1,46 @@ +app->bindShared('composer', function($app) + { + return new Composer($app['files'], $app['path.base']); + }); + + $this->app->bindShared('command.dump-autoload', function($app) + { + return new AutoloadCommand($app['composer']); + }); + + $this->commands('command.dump-autoload'); + } + + /** + * Get the services provided by the provider. + * + * @return array + */ + public function provides() + { + return array('composer', 'command.dump-autoload'); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Foundation/Providers/ConsoleSupportServiceProvider.php b/vendor/laravel/framework/src/Illuminate/Foundation/Providers/ConsoleSupportServiceProvider.php new file mode 100755 index 0000000..307a39a --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Foundation/Providers/ConsoleSupportServiceProvider.php @@ -0,0 +1,73 @@ +instances = array(); + + foreach ($this->providers as $provider) + { + $this->instances[] = $this->app->register($provider); + } + } + + /** + * Get the services provided by the provider. + * + * @return array + */ + public function provides() + { + $provides = array(); + + foreach ($this->providers as $provider) + { + $instance = $this->app->resolveProviderClass($provider); + + $provides = array_merge($provides, $instance->provides()); + } + + return $provides; + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Foundation/Providers/KeyGeneratorServiceProvider.php b/vendor/laravel/framework/src/Illuminate/Foundation/Providers/KeyGeneratorServiceProvider.php new file mode 100755 index 0000000..755ac36 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Foundation/Providers/KeyGeneratorServiceProvider.php @@ -0,0 +1,40 @@ +app->bindShared('command.key.generate', function($app) + { + return new KeyGenerateCommand($app['files']); + }); + + $this->commands('command.key.generate'); + } + + /** + * Get the services provided by the provider. + * + * @return array + */ + public function provides() + { + return array('command.key.generate'); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Foundation/Providers/MaintenanceServiceProvider.php b/vendor/laravel/framework/src/Illuminate/Foundation/Providers/MaintenanceServiceProvider.php new file mode 100755 index 0000000..02c267b --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Foundation/Providers/MaintenanceServiceProvider.php @@ -0,0 +1,46 @@ +app->bindShared('command.up', function($app) + { + return new UpCommand; + }); + + $this->app->bindShared('command.down', function($app) + { + return new DownCommand; + }); + + $this->commands('command.up', 'command.down'); + } + + /** + * Get the services provided by the provider. + * + * @return array + */ + public function provides() + { + return array('command.up', 'command.down'); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Foundation/Providers/OptimizeServiceProvider.php b/vendor/laravel/framework/src/Illuminate/Foundation/Providers/OptimizeServiceProvider.php new file mode 100755 index 0000000..998c998 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Foundation/Providers/OptimizeServiceProvider.php @@ -0,0 +1,66 @@ +registerOptimizeCommand(); + + $this->registerClearCompiledCommand(); + + $this->commands('command.optimize', 'command.clear-compiled'); + } + + /** + * Register the optimize command. + * + * @return void + */ + protected function registerOptimizeCommand() + { + $this->app->bindShared('command.optimize', function($app) + { + return new OptimizeCommand($app['composer']); + }); + } + + /** + * Register the compiled file remover command. + * + * @return void + */ + protected function registerClearCompiledCommand() + { + $this->app->bindShared('command.clear-compiled', function() + { + return new ClearCompiledCommand; + }); + } + + /** + * Get the services provided by the provider. + * + * @return array + */ + public function provides() + { + return array('command.optimize', 'command.clear-compiled'); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Foundation/Providers/PublisherServiceProvider.php b/vendor/laravel/framework/src/Illuminate/Foundation/Providers/PublisherServiceProvider.php new file mode 100755 index 0000000..e0d7837 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Foundation/Providers/PublisherServiceProvider.php @@ -0,0 +1,201 @@ +registerAssetPublisher(); + + $this->registerConfigPublisher(); + + $this->registerViewPublisher(); + + $this->registerMigrationPublisher(); + + $this->commands( + 'command.asset.publish', 'command.config.publish', + 'command.view.publish', 'command.migrate.publish' + ); + } + + /** + * Register the asset publisher service and command. + * + * @return void + */ + protected function registerAssetPublisher() + { + $this->registerAssetPublishCommand(); + + $this->app->bindShared('asset.publisher', function($app) + { + $publicPath = $app['path.public']; + + // The asset "publisher" is responsible for moving package's assets into the + // web accessible public directory of an application so they can actually + // be served to the browser. Otherwise, they would be locked in vendor. + $publisher = new AssetPublisher($app['files'], $publicPath); + + $publisher->setPackagePath($app['path.base'].'/vendor'); + + return $publisher; + }); + } + + /** + * Register the asset publish console command. + * + * @return void + */ + protected function registerAssetPublishCommand() + { + $this->app->bindShared('command.asset.publish', function($app) + { + return new AssetPublishCommand($app['asset.publisher']); + }); + } + + /** + * Register the configuration publisher class and command. + * + * @return void + */ + protected function registerConfigPublisher() + { + $this->registerConfigPublishCommand(); + + $this->app->bindShared('config.publisher', function($app) + { + $path = $app['path'].'/config'; + + // Once we have created the configuration publisher, we will set the default + // package path on the object so that it knows where to find the packages + // that are installed for the application and can move them to the app. + $publisher = new ConfigPublisher($app['files'], $path); + + $publisher->setPackagePath($app['path.base'].'/vendor'); + + return $publisher; + }); + } + + /** + * Register the configuration publish console command. + * + * @return void + */ + protected function registerConfigPublishCommand() + { + $this->app->bindShared('command.config.publish', function($app) + { + return new ConfigPublishCommand($app['config.publisher']); + }); + } + + /** + * Register the view publisher class and command. + * + * @return void + */ + protected function registerViewPublisher() + { + $this->registerViewPublishCommand(); + + $this->app->bindShared('view.publisher', function($app) + { + $viewPath = $app['path'].'/views'; + + // Once we have created the view publisher, we will set the default packages + // path on this object so that it knows where to find all of the packages + // that are installed for the application and can move them to the app. + $publisher = new ViewPublisher($app['files'], $viewPath); + + $publisher->setPackagePath($app['path.base'].'/vendor'); + + return $publisher; + }); + } + + /** + * Register the view publish console command. + * + * @return void + */ + protected function registerViewPublishCommand() + { + $this->app->bindShared('command.view.publish', function($app) + { + return new ViewPublishCommand($app['view.publisher']); + }); + } + + /** + * Register the migration publisher class and command. + * + * @return void + */ + protected function registerMigrationPublisher() + { + $this->registerMigratePublishCommand(); + + $this->app->bindShared('migration.publisher', function($app) + { + return new MigrationPublisher($app['files']); + }); + } + + /** + * Register the migration publisher command. + * + * @return void + */ + protected function registerMigratePublishCommand() + { + $this->app->bindShared('command.migrate.publish', function($app) + { + return new MigratePublishCommand; + }); + } + + /** + * Get the services provided by the provider. + * + * @return array + */ + public function provides() + { + return array( + 'asset.publisher', + 'command.asset.publish', + 'config.publisher', + 'command.config.publish', + 'view.publisher', + 'command.view.publish', + 'migration.publisher', + 'command.migrate.publish', + ); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Foundation/Providers/RouteListServiceProvider.php b/vendor/laravel/framework/src/Illuminate/Foundation/Providers/RouteListServiceProvider.php new file mode 100755 index 0000000..9dcbd9e --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Foundation/Providers/RouteListServiceProvider.php @@ -0,0 +1,40 @@ +app->bindShared('command.routes', function($app) + { + return new RoutesCommand($app['router']); + }); + + $this->commands('command.routes'); + } + + /** + * Get the services provided by the provider. + * + * @return array + */ + public function provides() + { + return array('command.routes'); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Foundation/Providers/ServerServiceProvider.php b/vendor/laravel/framework/src/Illuminate/Foundation/Providers/ServerServiceProvider.php new file mode 100755 index 0000000..3d1e316 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Foundation/Providers/ServerServiceProvider.php @@ -0,0 +1,40 @@ +app->bindShared('command.serve', function() + { + return new ServeCommand; + }); + + $this->commands('command.serve'); + } + + /** + * Get the services provided by the provider. + * + * @return array + */ + public function provides() + { + return array('command.serve'); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Foundation/Providers/TinkerServiceProvider.php b/vendor/laravel/framework/src/Illuminate/Foundation/Providers/TinkerServiceProvider.php new file mode 100755 index 0000000..81ef0d0 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Foundation/Providers/TinkerServiceProvider.php @@ -0,0 +1,40 @@ +app->bindShared('command.tinker', function() + { + return new TinkerCommand; + }); + + $this->commands('command.tinker'); + } + + /** + * Get the services provided by the provider. + * + * @return array + */ + public function provides() + { + return array('command.tinker'); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Client.php b/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Client.php new file mode 100755 index 0000000..d32425e --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Client.php @@ -0,0 +1,38 @@ +getRequestParameters($request)); + + $httpRequest->files->replace($this->filterFiles($httpRequest->files->all())); + + return $httpRequest; + } + + /** + * Get the request parameters from a BrowserKit request. + * + * @param \Symfony\Component\BrowserKit\Request $request + * @return array + */ + protected function getRequestParameters(DomRequest $request) + { + return array( + $request->getUri(), $request->getMethod(), $request->getParameters(), $request->getCookies(), + $request->getFiles(), $request->getServer(), $request->getContent() + ); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Foundation/Testing/TestCase.php b/vendor/laravel/framework/src/Illuminate/Foundation/Testing/TestCase.php new file mode 100755 index 0000000..fb88b50 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Foundation/Testing/TestCase.php @@ -0,0 +1,431 @@ +app) + { + $this->refreshApplication(); + } + } + + /** + * Refresh the application instance. + * + * @return void + */ + protected function refreshApplication() + { + $this->app = $this->createApplication(); + + $this->client = $this->createClient(); + + $this->app->setRequestForConsoleEnvironment(); + + $this->app->boot(); + } + + /** + * Creates the application. + * + * Needs to be implemented by subclasses. + * + * @return \Symfony\Component\HttpKernel\HttpKernelInterface + */ + abstract public function createApplication(); + + /** + * Call the given URI and return the Response. + * + * @param string $method + * @param string $uri + * @param array $parameters + * @param array $files + * @param array $server + * @param string $content + * @param bool $changeHistory + * @return \Illuminate\Http\Response + */ + public function call() + { + call_user_func_array(array($this->client, 'request'), func_get_args()); + + return $this->client->getResponse(); + } + + /** + * Call the given HTTPS URI and return the Response. + * + * @param string $method + * @param string $uri + * @param array $parameters + * @param array $files + * @param array $server + * @param string $content + * @param bool $changeHistory + * @return \Illuminate\Http\Response + */ + public function callSecure() + { + $parameters = func_get_args(); + + $parameters[1] = 'https://localhost/'.ltrim($parameters[1], '/'); + + return call_user_func_array(array($this, 'call'), $parameters); + } + + /** + * Call a controller action and return the Response. + * + * @param string $method + * @param string $action + * @param array $wildcards + * @param array $parameters + * @param array $files + * @param array $server + * @param string $content + * @param bool $changeHistory + * @return \Illuminate\Http\Response + */ + public function action($method, $action, $wildcards = array(), $parameters = array(), $files = array(), $server = array(), $content = null, $changeHistory = true) + { + $uri = $this->app['url']->action($action, $wildcards, true); + + return $this->call($method, $uri, $parameters, $files, $server, $content, $changeHistory); + } + + /** + * Call a named route and return the Response. + * + * @param string $method + * @param string $name + * @param array $routeParameters + * @param array $parameters + * @param array $files + * @param array $server + * @param string $content + * @param bool $changeHistory + * @return \Illuminate\Http\Response + */ + public function route($method, $name, $routeParameters = array(), $parameters = array(), $files = array(), $server = array(), $content = null, $changeHistory = true) + { + $uri = $this->app['url']->route($name, $routeParameters); + + return $this->call($method, $uri, $parameters, $files, $server, $content, $changeHistory); + } + + /** + * Assert that the client response has an OK status code. + * + * @return void + */ + public function assertResponseOk() + { + $response = $this->client->getResponse(); + + $actual = $response->getStatusCode(); + + return $this->assertTrue($response->isOk(), 'Expected status code 200, got ' .$actual); + } + + /** + * Assert that the client response has a given code. + * + * @param int $code + * @return void + */ + public function assertResponseStatus($code) + { + return $this->assertEquals($code, $this->client->getResponse()->getStatusCode()); + } + + /** + * Assert that the response view has a given piece of bound data. + * + * @param string|array $key + * @param mixed $value + * @return void + */ + public function assertViewHas($key, $value = null) + { + if (is_array($key)) return $this->assertViewHasAll($key); + + $response = $this->client->getResponse(); + + if ( ! isset($response->original) || ! $response->original instanceof View) + { + return $this->assertTrue(false, 'The response was not a view.'); + } + + if (is_null($value)) + { + $this->assertArrayHasKey($key, $response->original->getData()); + } + else + { + $this->assertEquals($value, $response->original->$key); + } + } + + /** + * Assert that the view has a given list of bound data. + * + * @param array $bindings + * @return void + */ + public function assertViewHasAll(array $bindings) + { + foreach ($bindings as $key => $value) + { + if (is_int($key)) + { + $this->assertViewHas($value); + } + else + { + $this->assertViewHas($key, $value); + } + } + } + + /** + * Assert that the response view is missing a piece of bound data. + * + * @param string $key + * @return void + */ + public function assertViewMissing($key) + { + $response = $this->client->getResponse(); + + if ( ! isset($response->original) || ! $response->original instanceof View) + { + return $this->assertTrue(false, 'The response was not a view.'); + } + + $this->assertArrayNotHasKey($key, $response->original->getData()); + } + + /** + * Assert whether the client was redirected to a given URI. + * + * @param string $uri + * @param array $with + * @return void + */ + public function assertRedirectedTo($uri, $with = array()) + { + $response = $this->client->getResponse(); + + $this->assertInstanceOf('Illuminate\Http\RedirectResponse', $response); + + $this->assertEquals($this->app['url']->to($uri), $response->headers->get('Location')); + + $this->assertSessionHasAll($with); + } + + /** + * Assert whether the client was redirected to a given route. + * + * @param string $name + * @param array $parameters + * @param array $with + * @return void + */ + public function assertRedirectedToRoute($name, $parameters = array(), $with = array()) + { + $this->assertRedirectedTo($this->app['url']->route($name, $parameters), $with); + } + + /** + * Assert whether the client was redirected to a given action. + * + * @param string $name + * @param array $parameters + * @param array $with + * @return void + */ + public function assertRedirectedToAction($name, $parameters = array(), $with = array()) + { + $this->assertRedirectedTo($this->app['url']->action($name, $parameters), $with); + } + + /** + * Assert that the session has a given list of values. + * + * @param string|array $key + * @param mixed $value + * @return void + */ + public function assertSessionHas($key, $value = null) + { + if (is_array($key)) return $this->assertSessionHasAll($key); + + if (is_null($value)) + { + $this->assertTrue($this->app['session.store']->has($key), "Session missing key: $key"); + } + else + { + $this->assertEquals($value, $this->app['session.store']->get($key)); + } + } + + /** + * Assert that the session has a given list of values. + * + * @param array $bindings + * @return void + */ + public function assertSessionHasAll(array $bindings) + { + foreach ($bindings as $key => $value) + { + if (is_int($key)) + { + $this->assertSessionHas($value); + } + else + { + $this->assertSessionHas($key, $value); + } + } + } + + /** + * Assert that the session has errors bound. + * + * @param string|array $bindings + * @param mixed $format + * @return void + */ + public function assertSessionHasErrors($bindings = array(), $format = null) + { + $this->assertSessionHas('errors'); + + $bindings = (array)$bindings; + + $errors = $this->app['session.store']->get('errors'); + + foreach ($bindings as $key => $value) + { + if (is_int($key)) + { + $this->assertTrue($errors->has($value), "Session missing error: $value"); + } + else + { + $this->assertContains($value, $errors->get($key, $format)); + } + } + } + + /** + * Assert that the session has old input. + * + * @return void + */ + public function assertHasOldInput() + { + $this->assertSessionHas('_old_input'); + } + + /** + * Set the session to the given array. + * + * @param array $data + * @return void + */ + public function session(array $data) + { + $this->startSession(); + + foreach ($data as $key => $value) + { + $this->app['session']->put($key, $value); + } + } + + /** + * Flush all of the current session data. + * + * @return void + */ + public function flushSession() + { + $this->startSession(); + + $this->app['session']->flush(); + } + + /** + * Start the session for the application. + * + * @return void + */ + protected function startSession() + { + if ( ! $this->app['session']->isStarted()) + { + $this->app['session']->start(); + } + } + + /** + * Set the currently logged in user for the application. + * + * @param \Illuminate\Auth\UserInterface $user + * @param string $driver + * @return void + */ + public function be(UserInterface $user, $driver = null) + { + $this->app['auth']->driver($driver)->setUser($user); + } + + /** + * Seed a given database connection. + * + * @param string $class + * @return void + */ + public function seed($class = 'DatabaseSeeder') + { + $this->app['artisan']->call('db:seed', array('--class' => $class)); + } + + /** + * Create a new HttpKernel client instance. + * + * @param array $server + * @return \Symfony\Component\HttpKernel\Client + */ + protected function createClient(array $server = array()) + { + return new Client($this->app, $server); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Foundation/ViewPublisher.php b/vendor/laravel/framework/src/Illuminate/Foundation/ViewPublisher.php new file mode 100755 index 0000000..c223991 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Foundation/ViewPublisher.php @@ -0,0 +1,117 @@ +files = $files; + $this->publishPath = $publishPath; + } + + /** + * Publish view files from a given path. + * + * @param string $package + * @param string $source + * @return void + */ + public function publish($package, $source) + { + $destination = $this->publishPath."/packages/{$package}"; + + $this->makeDestination($destination); + + return $this->files->copyDirectory($source, $destination); + } + + /** + * Publish the view files for a package. + * + * @param string $package + * @param string $packagePath + * @return void + */ + public function publishPackage($package, $packagePath = null) + { + $source = $this->getSource($package, $packagePath ?: $this->packagePath); + + return $this->publish($package, $source); + } + + /** + * Get the source views directory to publish. + * + * @param string $package + * @param string $packagePath + * @return string + * + * @throws \InvalidArgumentException + */ + protected function getSource($package, $packagePath) + { + $source = $packagePath."/{$package}/src/views"; + + if ( ! $this->files->isDirectory($source)) + { + throw new \InvalidArgumentException("Views not found."); + } + + return $source; + } + + /** + * Create the destination directory if it doesn't exist. + * + * @param string $destination + * @return void + */ + protected function makeDestination($destination) + { + if ( ! $this->files->isDirectory($destination)) + { + $this->files->makeDirectory($destination, 0777, true); + } + } + + /** + * Set the default package path. + * + * @param string $packagePath + * @return void + */ + public function setPackagePath($packagePath) + { + $this->packagePath = $packagePath; + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Foundation/changes.json b/vendor/laravel/framework/src/Illuminate/Foundation/changes.json new file mode 100755 index 0000000..1eba3ae --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Foundation/changes.json @@ -0,0 +1,180 @@ +{ + "4.1.*": [ + {"message": "Added new SSH task runner tools.", "backport": null}, + {"message": "Allow before and after validation rules to reference other fields.", "backport": null}, + {"message": "Added splice method to Collection class.", "backport": null}, + {"message": "Added newest and oldest methods to query builder for timestamp short-hand queries.", "backport": null}, + {"message": "Rebuild the routing layer for speed and efficiency.", "backport": null}, + {"message": "Added morphToMany relation for polymorphic many-to-many relations.", "backport": null}, + {"message": "Make Boris available from Tinker command when available.", "backport": null}, + {"message": "Allow route names to be specified on resources.", "backport": null}, + {"message": "Collection `push` now appends. New `prepend` method on collections.", "backport": null}, + {"message": "Use environment for log file name.", "backport": null}, + {"message": "Use 'bit' as storage type for boolean on SQL Server.", "backport": null}, + {"message": "Added new 'firing' method to event dispatcher, deprecated passing of event as last parameter.", "backport": null}, + {"message": "Added QueryException with better formatted error messages.", "backport": null}, + {"message": "Added 'input' method to Router.", "backport": null}, + {"message": "Laravel now generates a single laravel.log file instead of many files.", "backport": null}, + {"message": "Added new 'tail' Artisan command for tailing remote log files.", "backport": null}, + {"message": "Support passing an array of files or dynamic arguments into File::delete.", "backport": null}, + {"message": "Support calling local controller methods as filters using @method syntax.", "backport": null}, + {"message": "Support passing Carbon instances into Cache put style methods.", "backport": null}, + {"message": "New SessionInterface implementation - moved away from Symfony's implementation.", "backport": null}, + {"message": "Native session driver has been replaced by 'file'. Specifying 'native' driver will just use the new file driver.", "backport": null}, + {"message": "Now using Stack\\Builder in Application::run.", "backport": null}, + {"message": "Cookies should now be accessed via Input::cookie - Cookie::get will continue to work for this release.", "backport": null}, + {"message": "When accessing cookies outside of a request context, you will need to decrypt them manually.", "backport": null}, + {"message": "When unit testing, the application instance is now refreshed once per test class - not every test.", "backport": null}, + {"message": "Added 'whereNotBetween' support to the query builder.", "backport": null}, + {"message": "Added App::middleware method to inject middlewares onto Stack.", "backport": null}, + {"message": "Deprecate 'close' application hooks, Stack middlewares should be used instead.", "backport": null}, + {"message": "A new packages directory within `lang` can now override package language files.", "backport": null}, + {"message": "Added new 'Auth::viaRemember method to determine if user was authed via 'remember me' cookie.", "backport": null}, + {"message": "Allow passing a view name to paginator's 'links' method.", "backport": null}, + {"message": "Added new hasManyThrough relationship type.", "backport": null}, + {"message": "Cloned Eloquent query builders now clone the underlying query builder.", "backport": null}, + {"message": "Allow for passing of custom attributes into Validator::make as fourth parameter.", "backport": null}, + {"message": "Allow comma delimited list of queues to be passed to queue:listen / queue:work to implement queue priority.", "backport": null}, + {"message": "When new bindings are added to container, old aliases bound to that key will now be dropped.", "backport": null}, + {"message": "Added new 'resolvable' and 'isAlias' methods to the container.", "backport": null}, + {"message": "BelongsTo relationships may now reference any key on parent model, not just primary key.", "backport": null}, + {"message": "HasOne, HasMany, and morph relationships may now use any key on parent model, not just primary key.", "backport": null}, + {"message": "Eloquent 'has' method will now maintain where clauses set on relation.", "backport": null}, + {"message": "New 'whereHas' and 'orWhereHas' Eloquent methods that allow extra constraints on 'has' type queries.", "backport": null}, + {"message": "New 'or' syntax in Blade echos can be used to build isset statements and echos.", "backport": null}, + {"message": "Allow the 'name' of belongsTo and belongsToMany to be explictly set.", "backport": null}, + {"message": "New Cache::tags feature that allows tagging cached items and flushing them by any tag.", "backport": null}, + {"message": "New FrameGuard middleware sends SAMEORIGIN X-Frame-Options header on each response by default.", "backport": null}, + {"message": "Added 'joinWhere' and 'leftJoinWhere' to query builder for joins with bindings.", "backport": null}, + {"message": "Added 'require_without_all' validation rule.", "backport": null}, + {"message": "Controller method is now passed to missingMethod as first parameter.", "backport": null}, + {"message": "New @append Blade directive for appending content onto a section.", "backport": null}, + {"message": "Session IDs are now automatically regenerated on login.", "backport": null}, + {"message": "Improve Auth::once to get rid of redundant database call.", "backport": null}, + {"message": "In addition to the 'remember' function, query builder now supports 'rememberForever'.", "backport": null}, + {"message": "Changes (breaking) to the return values of password reminder functions to provide more freedom to developer.", "backport": null}, + {"message": "Added new `auth:reminders-controller' command to generate an entire password reminder controller.", "backport": null}, + {"message": "New 'Password::validator' function that allows custom validation on passwords when resetting.", "backport": null}, + {"message": "Added support for checking job attempts to Iron.io queue jobs.", "backport": null}, + {"message": "Added support for releasing pushed Iron.io jobs back onto the queue.", "backport": null}, + {"message": "Allow strict mode option to be enabled for MySQL connections.", "backport": null}, + {"message": "Added 'wherePivot' and 'orWherePivot' methods to BelongsToMany relationship for convenience.", "backport": null}, + {"message": "Added automatic separation of read / write connections into database layer.", "backport": null}, + {"message": "Added automatic failed job handling for all queue drivers. New --tries switch for queue:listen and queue:work.", "backport": null}, + {"message": "Cache:add now returns true when the value is actually added. False is returned otherwise.", "backport": null}, + {"message": "Added merge, diff, and intersect to the Collection class.", "backport": null}, + {"message": "Added fragment method to paginator.", "backport": null}, + {"message": "Added 'renderSections' method to the View.", "backport": null}, + {"message": "Added pessimistic locking to query builder via 'lock', 'lockForUpdate', and 'sharedLock'.", "backport": null}, + {"message": "Closure can now be passed to Collection->first, functions similarly to array_first.", "backport": null}, + {"message": "Added Mail::failures to get the failed recipients for a message.", "backport": null}, + {"message": "Renamed `Model::tags($cacheTags)` to `Model::cacheTags($cacheTags)`", "backport": null}, + {"message": "Model::destroy now returns the total number of records deleted.", "backport": null}, + {"message": "Fixed relative URL generation.", "backport": null}, + {"message": "Added --seeder option to migrate:refresh Artisan command.", "backport": null}, + {"message": "Added 'cacheDriver' method to query builder.", "backport": null}, + {"message": "Added support for whereHas on belongsTo relationships.", "backport": null}, + {"message": "Added groupBy to Collection class.", "backport": null}, + {"message": "Added the View::composers method.", "backport": null}, + {"message": "Added new 'sometimes' validation rule short-cut to only run validation if rule is present.", "backport": null}, + {"message": "Duplicate service providers can't be registered without 'force' parameter.", "backport": null}, + {"message": "Added --lines option to the 'tail' Artisan command.", "backport": null}, + {"message": "Allow 'keytext' option to be set on Remote configuration.", "backport": null}, + {"message": "Added support for '.env' files in the project root directory for loading $_ENV and $_SERVER.", "backport": null}, + {"message": "Added 'getString' method to the SSH class to allow fetching remote file into a string.", "backport": null}, + {"message": "Added 'append_config' helper to assign high keys to configuration items.", "backport": null}, + {"message": "Nested where queries using Closures with Eloquent will now use Eloquent query builder.", "backport": null}, + {"message": "Allow passing a string into the 'sortBy' and 'sortByDesc' Collection methods.", "backport": null}, + {"message": "Added 'sum' method to the base Support collection.", "backport": null}, + {"message": "Return an empty Collection if the array given to Eloquent::find is empty.", "backport": null}, + {"message": "Added 'toBase' method to Eloquent collection.", "backport": null}, + {"message": "New 'Route::matched' event available.", "backport": null}, + {"message": "Added new 'selectRaw' method to query builder.", "backport": null}, + {"message": "Fixed required_with behavior to match required_without. Added required_with_any.", "backport": null}, + {"message": "Added ability to register custom message replacers with the Validator.", "backport": null}, + {"message": "Added support for 'char' columns in the Schema builder.", "backport": null}, + {"message": "Added 'forgetBeforeFilter' and 'forgetAfterFilter' to controllers.", "backport": null}, + {"message": "Allow container parameter overrides to be specified by argument name.", "backport": null}, + {"message": "BelongsToMany 'sync' method now returns array with information on what changed.", "backport": null}, + {"message": "TTR configuration option now supported on Beanstalk queues.", "backport": null}, + {"message": "Added support for eager loading of MorphTo relationships.", "backport": null}, + {"message": "Added 'assertViewMissing' method to TestCase.", "backport": null}, + {"message": "Added 'whereYear', 'whereMonth', and 'whereDay'.", "backport": null}, + {"message": "Added events for committing, rolling back, and starting transactions on databsae connections.", "backport": null}, + {"message": "Added 'Auth::id' method to just get the authenticate user ID from the session / recaller cookie.", "backport": null}, + {"message": "New 'Input::exists' function for checking for the mere presence of input items.", "backport": null}, + {"message": "New system for invalidating remember me cookies on logout.", "backport": null}, + {"message": "Iron queue now accepts ssl_verifypeer configuration option.", "backport": null}, + {"message": "Make column quoting more robust for greater security when passing an array of user input into update methods.", "backport": null} + ], + "4.0.*": [ + {"message": "Added implode method to query builder and Collection class.", "backport": null}, + {"message": "Fixed bug that caused Model->push method to fail.", "backport": null}, + {"message": "Make session cookie HttpOnly by default.", "backport": null}, + {"message": "Added mail.pretend configuration option.", "backport": null}, + {"message": "Query elapsed time is now reported as float instead of string.", "backport": null}, + {"message": "Added Model::query method for generating an empty query builder.", "backport": null}, + {"message": "The @yield Blade directive now accepts a default value as the second argument.", "backport": null}, + {"message": "Fixed bug causing null to be passed to auth.logout event.", "backport": null}, + {"message": "Added polyfill for array_column forward compatibility.", "backport": null}, + {"message": "Passing NULL to validator exists rule as extra condition will do where null check.", "backport": null}, + {"message": "Auth::extend Closures should only return UserProviderInterface implementations.", "backport": null}, + {"message": "Make it easier to extend the Request class.", "backport": null}, + {"message": "Transparent support for APCu cache via 'apc' driver.", "backport": null}, + {"message": "Add morphs short-cut for adding polymorphic schema columns.", "backport": null}, + {"message": "Namespaces are now excluded from guessed model names.", "backport": null}, + {"message": "Added new --command option to command:make Artisan command.", "backport": null}, + {"message": "Added mediumText and longText to schema builder.", "backport": null}, + {"message": "Added support for macros on the Response class.", "backport": null}, + {"message": "Added support for view creators in addition to composers.", "backport": null}, + {"message": "Allow App::down to be bypassed if the event returns null.", "backport": null}, + {"message": "Added Request::format function to get human-readable expected Response format.", "backport": null}, + {"message": "Allow array sizes to be checked by validator.", "backport": null}, + {"message": "Added support for where conditions on unique validation rule.", "backport": null}, + {"message": "Restore method on Eloquent models now fires restoring and restored events.", "backport": null}, + {"message": "Fixed re-population of radio buttons and checkboxes in FormBuilder.", "backport": null}, + {"message": "Postgres ENUMs are now more truly implemented using 'check' constraints.", "backport": null}, + {"message": "Added selectMonth and selectYear to FormBuilder.", "backport": null}, + {"message": "Fix container resolution of default values for non-scalar dependencies.", "backport": null}, + {"message": "Allow optional path to be specified with calling _path helpers.", "backport": null}, + {"message": "Emulate nested transactions in the database connection layer.", "backport": null}, + {"message": "Added new appends property to Eloquent for adding to arrays and JSON.", "backport": null}, + {"message": "Allow connection to be configurable when using Redis based sessions.", "backport": null}, + {"message": "Allow passing DateTime objects to Queue::later.", "backport": null}, + {"message": "Added Queue::bulk method for pushing several jobs out at once.", "backport": null}, + {"message": "Added 'dates' property to Eloquent model for convenient setting of date columns.", "backport": null}, + {"message": "Added 'chunk' method to query builder and Eloquent for doing work on large result sets.", "backport": null}, + {"message": "Facades are now mockable without an application root.", "backport": null}, + {"message": "Data may now be dynamically bound to views via magic methods.", "backport": null}, + {"message": "Added support for XCache cache driver.", "backport": null}, + {"message": "Added 'env' command to get current environment.", "backport": null}, + {"message": "Added new --path and --name options to 'routes' Artisan command.", "backport": null}, + {"message": "Implement JSONable and Arrayable interfaces on Paginator.", "backport": null}, + {"message": "Foreign characters now supported in validation 'alpha' rules.", "backport": null}, + {"message": "Added 'prepend' method to Filesystem.", "backport": null}, + {"message": "Added 'reduce' collection to Collection, and 'min' and 'max' to Eloquent Collection.", "backport": null}, + {"message": "Added 'firstOrCreate' and 'firstOrNew' methods to Eloquent model.", "backport": null}, + {"message": "Added Redirect::away method to always redirect to external URL with no validation.", "backport": null}, + {"message": "Added 'double' method to Schema builder.", "backport": null}, + {"message": "Pass keys to 'map' method on Collection.", "backport": null}, + {"message": "Added 'orderByRaw' method to query builder.", "backport": null}, + {"message": "Added --bench option to controller:make Artisan command.", "backport": null}, + {"message": "Moved newPivot method into model for custom Pivot model instances.", "backport": null}, + {"message": "Added 'shared' method to View to pull a single shared item out.", "backport": null}, + {"message": "Added assertHasOldInput test assertion.", "backport": null}, + {"message": "Added slick new 'sometimes' method to Validator for conditionally adding rules.", "backport": null}, + {"message": "Added new '--sleep' option to queue:listen command to control time between jobs.", "backport": null}, + {"message": "Allow Blade processing on echos to be escaped using the @ sign.", "backport": null}, + {"message": "Allow custom messages to be registered when using Validator::extend.", "backport": null}, + {"message": "Added new auth:clear-reminders command for clearing expired password reminders.", "backport": null}, + {"message": "Added Cookie::queue method for creating cookies that are automatically attached to the final response.", "backport": null}, + {"message": "Allow environment to be checked via App::environment method.", "backport": null}, + {"message": "Add support for order by and limit on MySQL update queries.", "backport": null}, + {"message": "Tweak Container::resolve to accept a type, new resolvingAny method for all objects.", "backport": null}, + {"message": "Do not run queue workers while application is in maintenance mode.", "backport": null}, + {"message": "Values returned from scopes are now returned for chaining.", "backport": null}, + {"message": "New 'nullableTimestamps' method on Schema builder.", "backport": null}, + {"message": "Added 'extend' alias method for 'addConnector' in QueueManager class.", "backport": null}, + {"message": "Fixed exception handling bug that caused HTML to be dumped into console.", "backport": null} + ] +} diff --git a/vendor/laravel/framework/src/Illuminate/Foundation/start.php b/vendor/laravel/framework/src/Illuminate/Foundation/start.php new file mode 100755 index 0000000..f90b879 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Foundation/start.php @@ -0,0 +1,271 @@ +instance('app', $app); + +/* +|-------------------------------------------------------------------------- +| Check For The Test Environment +|-------------------------------------------------------------------------- +| +| If the "unitTesting" variable is set, it means we are running the unit +| tests for the application and should override this environment here +| so we use the right configuration. The flag gets set by TestCase. +| +*/ + +if (isset($unitTesting)) +{ + $app['env'] = $env = $testEnvironment; +} + +/* +|-------------------------------------------------------------------------- +| Load The Illuminate Facades +|-------------------------------------------------------------------------- +| +| The facades provide a terser static interface over the various parts +| of the application, allowing their methods to be accessed through +| a mixtures of magic methods and facade derivatives. It's slick. +| +*/ + +Facade::clearResolvedInstances(); + +Facade::setFacadeApplication($app); + +/* +|-------------------------------------------------------------------------- +| Register Facade Aliases To Full Classes +|-------------------------------------------------------------------------- +| +| By default, we use short keys in the container for each of the core +| pieces of the framework. Here we will register the aliases for a +| list of all of the fully qualified class names making DI easy. +| +*/ + +$app->registerCoreContainerAliases(); + +/* +|-------------------------------------------------------------------------- +| Register The Environment Variables +|-------------------------------------------------------------------------- +| +| Here we will register all of the $_ENV and $_SERVER variables into the +| process so that they're globally available configuration options so +| sensitive configuration information can be swept out of the code. +| +*/ + +with($envVariables = new EnvironmentVariables( + $app->getEnvironmentVariablesLoader()))->load($env); + +/* +|-------------------------------------------------------------------------- +| Register The Configuration Repository +|-------------------------------------------------------------------------- +| +| The configuration repository is used to lazily load in the options for +| this application from the configuration files. The files are easily +| separated by their concerns so they do not become really crowded. +| +*/ + +$app->instance('config', $config = new Config( + + $app->getConfigLoader(), $env + +)); + +/* +|-------------------------------------------------------------------------- +| Register Application Exception Handling +|-------------------------------------------------------------------------- +| +| We will go ahead and register the application exception handling here +| which will provide a great output of exception details and a stack +| trace in the case of exceptions while an application is running. +| +*/ + +$app->startExceptionHandling(); + +if ($env != 'testing') ini_set('display_errors', 'Off'); + +/* +|-------------------------------------------------------------------------- +| Set The Default Timezone +|-------------------------------------------------------------------------- +| +| Here we will set the default timezone for PHP. PHP is notoriously mean +| if the timezone is not explicitly set. This will be used by each of +| the PHP date and date-time functions throughout the application. +| +*/ + +$config = $app['config']['app']; + +date_default_timezone_set($config['timezone']); + +/* +|-------------------------------------------------------------------------- +| Register The Alias Loader +|-------------------------------------------------------------------------- +| +| The alias loader is responsible for lazy loading the class aliases setup +| for the application. We will only register it if the "config" service +| is bound in the application since it contains the alias definitions. +| +*/ + +$aliases = $config['aliases']; + +AliasLoader::getInstance($aliases)->register(); + +/* +|-------------------------------------------------------------------------- +| Enable HTTP Method Override +|-------------------------------------------------------------------------- +| +| Next we will tell the request class to allow HTTP method overriding +| since we use this to simulate PUT and DELETE requests from forms +| as they are not currently supported by plain HTML form setups. +| +*/ + +Request::enableHttpMethodParameterOverride(); + +/* +|-------------------------------------------------------------------------- +| Register The Core Service Providers +|-------------------------------------------------------------------------- +| +| The Illuminate core service providers register all of the core pieces +| of the Illuminate framework including session, caching, encryption +| and more. It's simply a convenient wrapper for the registration. +| +*/ + +$providers = $config['providers']; + +$app->getProviderRepository()->load($app, $providers); + +/* +|-------------------------------------------------------------------------- +| Register Booted Start Files +|-------------------------------------------------------------------------- +| +| Once the application has been booted there are several "start" files +| we will want to include. We'll register our "booted" handler here +| so the files are included after the application gets booted up. +| +*/ + +$app->booted(function() use ($app, $env) +{ + +/* +|-------------------------------------------------------------------------- +| Load The Application Start Script +|-------------------------------------------------------------------------- +| +| The start scripts gives this application the opportunity to override +| any of the existing IoC bindings, as well as register its own new +| bindings for things like repositories, etc. We'll load it here. +| +*/ + +$path = $app['path'].'/start/global.php'; + +if (file_exists($path)) require $path; + +/* +|-------------------------------------------------------------------------- +| Load The Environment Start Script +|-------------------------------------------------------------------------- +| +| The environment start script is only loaded if it exists for the app +| environment currently active, which allows some actions to happen +| in one environment while not in the other, keeping things clean. +| +*/ + +$path = $app['path']."/start/{$env}.php"; + +if (file_exists($path)) require $path; + +/* +|-------------------------------------------------------------------------- +| Load The Application Routes +|-------------------------------------------------------------------------- +| +| The Application routes are kept separate from the application starting +| just to keep the file a little cleaner. We'll go ahead and load in +| all of the routes now and return the application to the callers. +| +*/ + +$routes = $app['path'].'/routes.php'; + +if (file_exists($routes)) require $routes; + +}); diff --git a/vendor/laravel/framework/src/Illuminate/Hashing/BcryptHasher.php b/vendor/laravel/framework/src/Illuminate/Hashing/BcryptHasher.php new file mode 100755 index 0000000..c5db5f5 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Hashing/BcryptHasher.php @@ -0,0 +1,62 @@ +rounds; + + $hash = password_hash($value, PASSWORD_BCRYPT, array('cost' => $cost)); + + if ($hash === false) + { + throw new \RuntimeException("Bcrypt hashing not supported."); + } + + return $hash; + } + + /** + * Check the given plain value against a hash. + * + * @param string $value + * @param string $hashedValue + * @param array $options + * @return bool + */ + public function check($value, $hashedValue, array $options = array()) + { + return password_verify($value, $hashedValue); + } + + /** + * Check if the given hash has been hashed using the given options. + * + * @param string $hashedValue + * @param array $options + * @return bool + */ + public function needsRehash($hashedValue, array $options = array()) + { + $cost = isset($options['rounds']) ? $options['rounds'] : $this->rounds; + + return password_needs_rehash($hashedValue, PASSWORD_BCRYPT, array('cost' => $cost)); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Hashing/HashServiceProvider.php b/vendor/laravel/framework/src/Illuminate/Hashing/HashServiceProvider.php new file mode 100755 index 0000000..cc1f5c2 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Hashing/HashServiceProvider.php @@ -0,0 +1,34 @@ +app->bindShared('hash', function() { return new BcryptHasher; }); + } + + /** + * Get the services provided by the provider. + * + * @return array + */ + public function provides() + { + return array('hash'); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Hashing/HasherInterface.php b/vendor/laravel/framework/src/Illuminate/Hashing/HasherInterface.php new file mode 100755 index 0000000..7070690 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Hashing/HasherInterface.php @@ -0,0 +1,33 @@ +=5.3.0", + "illuminate/support": "4.1.*", + "ircmaxell/password-compat": "1.0.*" + }, + "require-dev": { + "phpunit/phpunit": "4.0.*" + }, + "autoload": { + "psr-0": { + "Illuminate\\Hashing": "" + } + }, + "target-dir": "Illuminate/Hashing", + "extra": { + "branch-alias": { + "dev-master": "4.1-dev" + } + }, + "minimum-stability": "dev" +} diff --git a/vendor/laravel/framework/src/Illuminate/Html/FormBuilder.php b/vendor/laravel/framework/src/Illuminate/Html/FormBuilder.php new file mode 100755 index 0000000..729c0bb --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Html/FormBuilder.php @@ -0,0 +1,1007 @@ +url = $url; + $this->html = $html; + $this->csrfToken = $csrfToken; + } + + /** + * Open up a new HTML form. + * + * @param array $options + * @return string + */ + public function open(array $options = array()) + { + $method = array_get($options, 'method', 'post'); + + // We need to extract the proper method from the attributes. If the method is + // something other than GET or POST we'll use POST since we will spoof the + // actual method since forms don't support the reserved methods in HTML. + $attributes['method'] = $this->getMethod($method); + + $attributes['action'] = $this->getAction($options); + + $attributes['accept-charset'] = 'UTF-8'; + + // If the method is PUT, PATCH or DELETE we will need to add a spoofer hidden + // field that will instruct the Symfony request to pretend the method is a + // different method than it actually is, for convenience from the forms. + $append = $this->getAppendage($method); + + if (isset($options['files']) && $options['files']) + { + $options['enctype'] = 'multipart/form-data'; + } + + // Finally we're ready to create the final form HTML field. We will attribute + // format the array of attributes. We will also add on the appendage which + // is used to spoof requests for this PUT, PATCH, etc. methods on forms. + $attributes = array_merge( + + $attributes, array_except($options, $this->reserved) + + ); + + // Finally, we will concatenate all of the attributes into a single string so + // we can build out the final form open statement. We'll also append on an + // extra value for the hidden _method field if it's needed for the form. + $attributes = $this->html->attributes($attributes); + + return ''.$append; + } + + /** + * Create a new model based form builder. + * + * @param mixed $model + * @param array $options + * @return string + */ + public function model($model, array $options = array()) + { + $this->model = $model; + + return $this->open($options); + } + + /** + * Set the model instance on the form builder. + * + * @param mixed $model + * @return void + */ + public function setModel($model) + { + $this->model = $model; + } + + /** + * Close the current form. + * + * @return string + */ + public function close() + { + $this->labels = array(); + + $this->model = null; + + return ''; + } + + /** + * Generate a hidden field with the current CSRF token. + * + * @return string + */ + public function token() + { + return $this->hidden('_token', $this->csrfToken); + } + + /** + * Create a form label element. + * + * @param string $name + * @param string $value + * @param array $options + * @return string + */ + public function label($name, $value = null, $options = array()) + { + $this->labels[] = $name; + + $options = $this->html->attributes($options); + + $value = e($this->formatLabel($name, $value)); + + return ''; + } + + /** + * Format the label value. + * + * @param string $name + * @param string|null $value + * @return string + */ + protected function formatLabel($name, $value) + { + return $value ?: ucwords(str_replace('_', ' ', $name)); + } + + /** + * Create a form input field. + * + * @param string $type + * @param string $name + * @param string $value + * @param array $options + * @return string + */ + public function input($type, $name, $value = null, $options = array()) + { + if ( ! isset($options['name'])) $options['name'] = $name; + + // We will get the appropriate value for the given field. We will look for the + // value in the session for the value in the old input data then we'll look + // in the model instance if one is set. Otherwise we will just use empty. + $id = $this->getIdAttribute($name, $options); + + if ( ! in_array($type, $this->skipValueTypes)) + { + $value = $this->getValueAttribute($name, $value); + } + + // Once we have the type, value, and ID we can merge them into the rest of the + // attributes array so we can convert them into their HTML attribute format + // when creating the HTML element. Then, we will return the entire input. + $merge = compact('type', 'value', 'id'); + + $options = array_merge($options, $merge); + + return 'html->attributes($options).'>'; + } + + /** + * Create a text input field. + * + * @param string $name + * @param string $value + * @param array $options + * @return string + */ + public function text($name, $value = null, $options = array()) + { + return $this->input('text', $name, $value, $options); + } + + /** + * Create a password input field. + * + * @param string $name + * @param array $options + * @return string + */ + public function password($name, $options = array()) + { + return $this->input('password', $name, '', $options); + } + + /** + * Create a hidden input field. + * + * @param string $name + * @param string $value + * @param array $options + * @return string + */ + public function hidden($name, $value = null, $options = array()) + { + return $this->input('hidden', $name, $value, $options); + } + + /** + * Create an e-mail input field. + * + * @param string $name + * @param string $value + * @param array $options + * @return string + */ + public function email($name, $value = null, $options = array()) + { + return $this->input('email', $name, $value, $options); + } + + /** + * Create a url input field. + * + * @param string $name + * @param string $value + * @param array $options + * @return string + */ + public function url($name, $value = null, $options = array()) + { + return $this->input('url', $name, $value, $options); + } + + /** + * Create a file input field. + * + * @param string $name + * @param array $options + * @return string + */ + public function file($name, $options = array()) + { + return $this->input('file', $name, null, $options); + } + + /** + * Create a textarea input field. + * + * @param string $name + * @param string $value + * @param array $options + * @return string + */ + public function textarea($name, $value = null, $options = array()) + { + if ( ! isset($options['name'])) $options['name'] = $name; + + // Next we will look for the rows and cols attributes, as each of these are put + // on the textarea element definition. If they are not present, we will just + // assume some sane default values for these attributes for the developer. + $options = $this->setTextAreaSize($options); + + $options['id'] = $this->getIdAttribute($name, $options); + + $value = (string) $this->getValueAttribute($name, $value); + + unset($options['size']); + + // Next we will convert the attributes into a string form. Also we have removed + // the size attribute, as it was merely a short-cut for the rows and cols on + // the element. Then we'll create the final textarea elements HTML for us. + $options = $this->html->attributes($options); + + return ''.e($value).''; + } + + /** + * Set the text area size on the attributes. + * + * @param array $options + * @return array + */ + protected function setTextAreaSize($options) + { + if (isset($options['size'])) + { + return $this->setQuickTextAreaSize($options); + } + + // If the "size" attribute was not specified, we will just look for the regular + // columns and rows attributes, using sane defaults if these do not exist on + // the attributes array. We'll then return this entire options array back. + $cols = array_get($options, 'cols', 50); + + $rows = array_get($options, 'rows', 10); + + return array_merge($options, compact('cols', 'rows')); + } + + /** + * Set the text area size using the quick "size" attribute. + * + * @param array $options + * @return array + */ + protected function setQuickTextAreaSize($options) + { + $segments = explode('x', $options['size']); + + return array_merge($options, array('cols' => $segments[0], 'rows' => $segments[1])); + } + + /** + * Create a select box field. + * + * @param string $name + * @param array $list + * @param string $selected + * @param array $options + * @return string + */ + public function select($name, $list = array(), $selected = null, $options = array()) + { + // When building a select box the "value" attribute is really the selected one + // so we will use that when checking the model or session for a value which + // should provide a convenient method of re-populating the forms on post. + $selected = $this->getValueAttribute($name, $selected); + + $options['id'] = $this->getIdAttribute($name, $options); + + if ( ! isset($options['name'])) $options['name'] = $name; + + // We will simply loop through the options and build an HTML value for each of + // them until we have an array of HTML declarations. Then we will join them + // all together into one single HTML element that can be put on the form. + $html = array(); + + foreach ($list as $value => $display) + { + $html[] = $this->getSelectOption($display, $value, $selected); + } + + // Once we have all of this HTML, we can join this into a single element after + // formatting the attributes into an HTML "attributes" string, then we will + // build out a final select statement, which will contain all the values. + $options = $this->html->attributes($options); + + $list = implode('', $html); + + return "{$list}"; + } + + /** + * Create a select range field. + * + * @param string $name + * @param string $begin + * @param string $end + * @param string $selected + * @param array $options + * @return string + */ + public function selectRange($name, $begin, $end, $selected = null, $options = array()) + { + $range = array_combine($range = range($begin, $end), $range); + + return $this->select($name, $range, $selected, $options); + } + + /** + * Create a select year field. + * + * @param string $name + * @param string $begin + * @param string $end + * @param string $selected + * @param array $options + * @return string + */ + public function selectYear() + { + return call_user_func_array(array($this, 'selectRange'), func_get_args()); + } + + /** + * Create a select month field. + * + * @param string $name + * @param string $selected + * @param array $options + * @param string $format + * @return string + */ + public function selectMonth($name, $selected = null, $options = array(), $format = '%B') + { + $months = array(); + + foreach (range(1, 12) as $month) + { + $months[$month] = strftime($format, mktime(0, 0, 0, $month, 1)); + } + + return $this->select($name, $months, $selected, $options); + } + + /** + * Get the select option for the given value. + * + * @param string $display + * @param string $value + * @param string $selected + * @return string + */ + public function getSelectOption($display, $value, $selected) + { + if (is_array($display)) + { + return $this->optionGroup($display, $value, $selected); + } + + return $this->option($display, $value, $selected); + } + + /** + * Create an option group form element. + * + * @param array $list + * @param string $label + * @param string $selected + * @return string + */ + protected function optionGroup($list, $label, $selected) + { + $html = array(); + + foreach ($list as $value => $display) + { + $html[] = $this->option($display, $value, $selected); + } + + return ''.implode('', $html).''; + } + + /** + * Create a select element option. + * + * @param string $display + * @param string $value + * @param string $selected + * @return string + */ + protected function option($display, $value, $selected) + { + $selected = $this->getSelectedValue($value, $selected); + + $options = array('value' => e($value), 'selected' => $selected); + + return 'html->attributes($options).'>'.e($display).''; + } + + /** + * Determine if the value is selected. + * + * @param string $value + * @param string $selected + * @return string + */ + protected function getSelectedValue($value, $selected) + { + if (is_array($selected)) + { + return in_array($value, $selected) ? 'selected' : null; + } + + return ((string) $value == (string) $selected) ? 'selected' : null; + } + + /** + * Create a checkbox input field. + * + * @param string $name + * @param mixed $value + * @param bool $checked + * @param array $options + * @return string + */ + public function checkbox($name, $value = 1, $checked = null, $options = array()) + { + return $this->checkable('checkbox', $name, $value, $checked, $options); + } + + /** + * Create a radio button input field. + * + * @param string $name + * @param mixed $value + * @param bool $checked + * @param array $options + * @return string + */ + public function radio($name, $value = null, $checked = null, $options = array()) + { + if (is_null($value)) $value = $name; + + return $this->checkable('radio', $name, $value, $checked, $options); + } + + /** + * Create a checkable input field. + * + * @param string $type + * @param string $name + * @param mixed $value + * @param bool $checked + * @param array $options + * @return string + */ + protected function checkable($type, $name, $value, $checked, $options) + { + $checked = $this->getCheckedState($type, $name, $value, $checked); + + if ($checked) $options['checked'] = 'checked'; + + return $this->input($type, $name, $value, $options); + } + + /** + * Get the check state for a checkable input. + * + * @param string $type + * @param string $name + * @param mixed $value + * @param bool $checked + * @return bool + */ + protected function getCheckedState($type, $name, $value, $checked) + { + switch ($type) + { + case 'checkbox': + return $this->getCheckboxCheckedState($name, $value, $checked); + + case 'radio': + return $this->getRadioCheckedState($name, $value, $checked); + + default: + return $this->getValueAttribute($name) == $value; + } + } + + /** + * Get the check state for a checkbox input. + * + * @param string $name + * @param mixed $value + * @param bool $checked + * @return bool + */ + protected function getCheckboxCheckedState($name, $value, $checked) + { + if (isset($this->session) && ! $this->oldInputIsEmpty() && is_null($this->old($name))) return false; + + if ($this->missingOldAndModel($name)) return $checked; + + $posted = $this->getValueAttribute($name); + + return is_array($posted) ? in_array($value, $posted) : (bool) $posted; + } + + /** + * Get the check state for a radio input. + * + * @param string $name + * @param mixed $value + * @param bool $checked + * @return bool + */ + protected function getRadioCheckedState($name, $value, $checked) + { + if ($this->missingOldAndModel($name)) return $checked; + + return $this->getValueAttribute($name) == $value; + } + + /** + * Determine if old input or model input exists for a key. + * + * @param string $name + * @return bool + */ + protected function missingOldAndModel($name) + { + return (is_null($this->old($name)) && is_null($this->getModelValueAttribute($name))); + } + + /** + * Create a HTML reset input element. + * + * @param string $value + * @param array $attributes + * @return string + */ + public function reset($value, $attributes = array()) + { + return $this->input('reset', null, $value, $attributes); + } + + /** + * Create a HTML image input element. + * + * @param string $url + * @param string $name + * @param array $attributes + * @return string + */ + public function image($url, $name = null, $attributes = array()) + { + $attributes['src'] = $this->url->asset($url); + + return $this->input('image', $name, null, $attributes); + } + + /** + * Create a submit button element. + * + * @param string $value + * @param array $options + * @return string + */ + public function submit($value = null, $options = array()) + { + return $this->input('submit', null, $value, $options); + } + + /** + * Create a button element. + * + * @param string $value + * @param array $options + * @return string + */ + public function button($value = null, $options = array()) + { + if ( ! array_key_exists('type', $options) ) + { + $options['type'] = 'button'; + } + + return 'html->attributes($options).'>'.$value.''; + } + + /** + * Register a custom form macro. + * + * @param string $name + * @param callable $macro + * @return void + */ + public function macro($name, $macro) + { + $this->macros[$name] = $macro; + } + + /** + * Parse the form action method. + * + * @param string $method + * @return string + */ + protected function getMethod($method) + { + $method = strtoupper($method); + + return $method != 'GET' ? 'POST' : $method; + } + + /** + * Get the form action from the options. + * + * @param array $options + * @return string + */ + protected function getAction(array $options) + { + // We will also check for a "route" or "action" parameter on the array so that + // developers can easily specify a route or controller action when creating + // a form providing a convenient interface for creating the form actions. + if (isset($options['url'])) + { + return $this->getUrlAction($options['url']); + } + + if (isset($options['route'])) + { + return $this->getRouteAction($options['route']); + } + + // If an action is available, we are attempting to open a form to a controller + // action route. So, we will use the URL generator to get the path to these + // actions and return them from the method. Otherwise, we'll use current. + elseif (isset($options['action'])) + { + return $this->getControllerAction($options['action']); + } + + return $this->url->current(); + } + + /** + * Get the action for a "url" option. + * + * @param array|string $options + * @return string + */ + protected function getUrlAction($options) + { + if (is_array($options)) + { + return $this->url->to($options[0], array_slice($options, 1)); + } + + return $this->url->to($options); + } + + /** + * Get the action for a "route" option. + * + * @param array|string $options + * @return string + */ + protected function getRouteAction($options) + { + if (is_array($options)) + { + return $this->url->route($options[0], array_slice($options, 1)); + } + + return $this->url->route($options); + } + + /** + * Get the action for an "action" option. + * + * @param array|string $options + * @return string + */ + protected function getControllerAction($options) + { + if (is_array($options)) + { + return $this->url->action($options[0], array_slice($options, 1)); + } + + return $this->url->action($options); + } + + /** + * Get the form appendage for the given method. + * + * @param string $method + * @return string + */ + protected function getAppendage($method) + { + list($method, $appendage) = array(strtoupper($method), ''); + + // If the HTTP method is in this list of spoofed methods, we will attach the + // method spoofer hidden input to the form. This allows us to use regular + // form to initiate PUT and DELETE requests in addition to the typical. + if (in_array($method, $this->spoofedMethods)) + { + $appendage .= $this->hidden('_method', $method); + } + + // If the method is something other than GET we will go ahead and attach the + // CSRF token to the form, as this can't hurt and is convenient to simply + // always have available on every form the developers creates for them. + if ($method != 'GET') + { + $appendage .= $this->token(); + } + + return $appendage; + } + + /** + * Get the ID attribute for a field name. + * + * @param string $name + * @param array $attributes + * @return string + */ + public function getIdAttribute($name, $attributes) + { + if (array_key_exists('id', $attributes)) + { + return $attributes['id']; + } + + if (in_array($name, $this->labels)) + { + return $name; + } + } + + /** + * Get the value that should be assigned to the field. + * + * @param string $name + * @param string $value + * @return string + */ + public function getValueAttribute($name, $value = null) + { + if (is_null($name)) return $value; + + if ( ! is_null($this->old($name))) + { + return $this->old($name); + } + + if ( ! is_null($value)) return $value; + + if (isset($this->model)) + { + return $this->getModelValueAttribute($name); + } + } + + /** + * Get the model value that should be assigned to the field. + * + * @param string $name + * @return string + */ + protected function getModelValueAttribute($name) + { + if (is_object($this->model)) + { + return object_get($this->model, $this->transformKey($name)); + } + elseif (is_array($this->model)) + { + return array_get($this->model, $this->transformKey($name)); + } + } + + /** + * Get a value from the session's old input. + * + * @param string $name + * @return string + */ + public function old($name) + { + if (isset($this->session)) + { + return $this->session->getOldInput($this->transformKey($name)); + } + } + + /** + * Determine if the old input is empty. + * + * @return bool + */ + public function oldInputIsEmpty() + { + return (isset($this->session) && count($this->session->getOldInput()) == 0); + } + + /** + * Transform key from array to dot syntax. + * + * @param string $key + * @return string + */ + protected function transformKey($key) + { + return str_replace(array('.', '[]', '[', ']'), array('_', '', '.', ''), $key); + } + + /** + * Get the session store implementation. + * + * @return \Illuminate\Session\Store $session + */ + public function getSessionStore() + { + return $this->session; + } + + /** + * Set the session store implementation. + * + * @param \Illuminate\Session\Store $session + * @return \Illuminate\Html\FormBuilder + */ + public function setSessionStore(Session $session) + { + $this->session = $session; + + return $this; + } + + /** + * Dynamically handle calls to the form builder. + * + * @param string $method + * @param array $parameters + * @return mixed + * + * @throws \BadMethodCallException + */ + public function __call($method, $parameters) + { + if (isset($this->macros[$method])) + { + return call_user_func_array($this->macros[$method], $parameters); + } + + throw new \BadMethodCallException("Method {$method} does not exist."); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Html/HtmlBuilder.php b/vendor/laravel/framework/src/Illuminate/Html/HtmlBuilder.php new file mode 100755 index 0000000..133b720 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Html/HtmlBuilder.php @@ -0,0 +1,414 @@ +url = $url; + } + + /** + * Register a custom HTML macro. + * + * @param string $name + * @param callable $macro + * @return void + */ + public function macro($name, $macro) + { + $this->macros[$name] = $macro; + } + + /** + * Convert an HTML string to entities. + * + * @param string $value + * @return string + */ + public function entities($value) + { + return htmlentities($value, ENT_QUOTES, 'UTF-8', false); + } + + /** + * Convert entities to HTML characters. + * + * @param string $value + * @return string + */ + public function decode($value) + { + return html_entity_decode($value, ENT_QUOTES, 'UTF-8'); + } + + /** + * Generate a link to a JavaScript file. + * + * @param string $url + * @param array $attributes + * @param bool $secure + * @return string + */ + public function script($url, $attributes = array(), $secure = null) + { + $attributes['src'] = $this->url->asset($url, $secure); + + return 'attributes($attributes).'>'.PHP_EOL; + } + + /** + * Generate a link to a CSS file. + * + * @param string $url + * @param array $attributes + * @param bool $secure + * @return string + */ + public function style($url, $attributes = array(), $secure = null) + { + $defaults = array('media' => 'all', 'type' => 'text/css', 'rel' => 'stylesheet'); + + $attributes = $attributes + $defaults; + + $attributes['href'] = $this->url->asset($url, $secure); + + return 'attributes($attributes).'>'.PHP_EOL; + } + + /** + * Generate an HTML image element. + * + * @param string $url + * @param string $alt + * @param array $attributes + * @param bool $secure + * @return string + */ + public function image($url, $alt = null, $attributes = array(), $secure = null) + { + $attributes['alt'] = $alt; + + return 'attributes($attributes).'>'; + } + + /** + * Generate a HTML link. + * + * @param string $url + * @param string $title + * @param array $attributes + * @param bool $secure + * @return string + */ + public function link($url, $title = null, $attributes = array(), $secure = null) + { + $url = $this->url->to($url, array(), $secure); + + if (is_null($title) || $title === false) $title = $url; + + return 'attributes($attributes).'>'.$this->entities($title).''; + } + + /** + * Generate a HTTPS HTML link. + * + * @param string $url + * @param string $title + * @param array $attributes + * @return string + */ + public function secureLink($url, $title = null, $attributes = array()) + { + return $this->link($url, $title, $attributes, true); + } + + /** + * Generate a HTML link to an asset. + * + * @param string $url + * @param string $title + * @param array $attributes + * @param bool $secure + * @return string + */ + public function linkAsset($url, $title = null, $attributes = array(), $secure = null) + { + $url = $this->url->asset($url, $secure); + + return $this->link($url, $title ?: $url, $attributes, $secure); + } + + /** + * Generate a HTTPS HTML link to an asset. + * + * @param string $url + * @param string $title + * @param array $attributes + * @return string + */ + public function linkSecureAsset($url, $title = null, $attributes = array()) + { + return $this->linkAsset($url, $title, $attributes, true); + } + + /** + * Generate a HTML link to a named route. + * + * @param string $name + * @param string $title + * @param array $parameters + * @param array $attributes + * @return string + */ + public function linkRoute($name, $title = null, $parameters = array(), $attributes = array()) + { + return $this->link($this->url->route($name, $parameters), $title, $attributes); + } + + /** + * Generate a HTML link to a controller action. + * + * @param string $action + * @param string $title + * @param array $parameters + * @param array $attributes + * @return string + */ + public function linkAction($action, $title = null, $parameters = array(), $attributes = array()) + { + return $this->link($this->url->action($action, $parameters), $title, $attributes); + } + + /** + * Generate a HTML link to an email address. + * + * @param string $email + * @param string $title + * @param array $attributes + * @return string + */ + public function mailto($email, $title = null, $attributes = array()) + { + $email = $this->email($email); + + $title = $title ?: $email; + + $email = $this->obfuscate('mailto:') . $email; + + return 'attributes($attributes).'>'.$this->entities($title).''; + } + + /** + * Obfuscate an e-mail address to prevent spam-bots from sniffing it. + * + * @param string $email + * @return string + */ + public function email($email) + { + return str_replace('@', '@', $this->obfuscate($email)); + } + + /** + * Generate an ordered list of items. + * + * @param array $list + * @param array $attributes + * @return string + */ + public function ol($list, $attributes = array()) + { + return $this->listing('ol', $list, $attributes); + } + + /** + * Generate an un-ordered list of items. + * + * @param array $list + * @param array $attributes + * @return string + */ + public function ul($list, $attributes = array()) + { + return $this->listing('ul', $list, $attributes); + } + + /** + * Create a listing HTML element. + * + * @param string $type + * @param array $list + * @param array $attributes + * @return string + */ + protected function listing($type, $list, $attributes = array()) + { + $html = ''; + + if (count($list) == 0) return $html; + + // Essentially we will just spin through the list and build the list of the HTML + // elements from the array. We will also handled nested lists in case that is + // present in the array. Then we will build out the final listing elements. + foreach ($list as $key => $value) + { + $html .= $this->listingElement($key, $type, $value); + } + + $attributes = $this->attributes($attributes); + + return "<{$type}{$attributes}>{$html}"; + } + + /** + * Create the HTML for a listing element. + * + * @param mixed $key + * @param string $type + * @param string $value + * @return string + */ + protected function listingElement($key, $type, $value) + { + if (is_array($value)) + { + return $this->nestedListing($key, $type, $value); + } + else + { + return '
  • '.e($value).'
  • '; + } + } + + /** + * Create the HTML for a nested listing attribute. + * + * @param mixed $key + * @param string $type + * @param string $value + * @return string + */ + protected function nestedListing($key, $type, $value) + { + if (is_int($key)) + { + return $this->listing($type, $value); + } + else + { + return '
  • '.$key.$this->listing($type, $value).'
  • '; + } + } + + /** + * Build an HTML attribute string from an array. + * + * @param array $attributes + * @return string + */ + public function attributes($attributes) + { + $html = array(); + + // For numeric keys we will assume that the key and the value are the same + // as this will convert HTML attributes such as "required" to a correct + // form like required="required" instead of using incorrect numerics. + foreach ((array) $attributes as $key => $value) + { + $element = $this->attributeElement($key, $value); + + if ( ! is_null($element)) $html[] = $element; + } + + return count($html) > 0 ? ' '.implode(' ', $html) : ''; + } + + /** + * Build a single attribute element. + * + * @param string $key + * @param string $value + * @return string + */ + protected function attributeElement($key, $value) + { + if (is_numeric($key)) $key = $value; + + if ( ! is_null($value)) return $key.'="'.e($value).'"'; + } + + /** + * Obfuscate a string to prevent spam-bots from sniffing it. + * + * @param string $value + * @return string + */ + public function obfuscate($value) + { + $safe = ''; + + foreach (str_split($value) as $letter) + { + if (ord($letter) > 128) return $letter; + + // To properly obfuscate the value, we will randomly convert each letter to + // its entity or hexadecimal representation, keeping a bot from sniffing + // the randomly obfuscated letters out of the string on the responses. + switch (rand(1, 3)) + { + case 1: + $safe .= '&#'.ord($letter).';'; break; + + case 2: + $safe .= '&#x'.dechex(ord($letter)).';'; break; + + case 3: + $safe .= $letter; + } + } + + return $safe; + } + + /** + * Dynamically handle calls to the html class. + * + * @param string $method + * @param array $parameters + * @return mixed + * + * @throws \BadMethodCallException + */ + public function __call($method, $parameters) + { + if (isset($this->macros[$method])) + { + return call_user_func_array($this->macros[$method], $parameters); + } + + throw new \BadMethodCallException("Method {$method} does not exist."); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Html/HtmlServiceProvider.php b/vendor/laravel/framework/src/Illuminate/Html/HtmlServiceProvider.php new file mode 100755 index 0000000..702051e --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Html/HtmlServiceProvider.php @@ -0,0 +1,64 @@ +registerHtmlBuilder(); + + $this->registerFormBuilder(); + } + + /** + * Register the HTML builder instance. + * + * @return void + */ + protected function registerHtmlBuilder() + { + $this->app->bindShared('html', function($app) + { + return new HtmlBuilder($app['url']); + }); + } + + /** + * Register the form builder instance. + * + * @return void + */ + protected function registerFormBuilder() + { + $this->app->bindShared('form', function($app) + { + $form = new FormBuilder($app['html'], $app['url'], $app['session.store']->getToken()); + + return $form->setSessionStore($app['session.store']); + }); + } + + /** + * Get the services provided by the provider. + * + * @return array + */ + public function provides() + { + return array('html', 'form'); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Html/composer.json b/vendor/laravel/framework/src/Illuminate/Html/composer.json new file mode 100755 index 0000000..6f408a2 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Html/composer.json @@ -0,0 +1,32 @@ +{ + "name": "illuminate/html", + "license": "MIT", + "authors": [ + { + "name": "Taylor Otwell", + "email": "taylorotwell@gmail.com" + } + ], + "require": { + "php": ">=5.3.0", + "illuminate/http": "4.1.*", + "illuminate/session": "4.1.*", + "illuminate/support": "4.1.*" + }, + "require-dev": { + "mockery/mockery": "0.9.*", + "phpunit/phpunit": "4.0.*" + }, + "autoload": { + "psr-0": { + "Illuminate\\Html": "" + } + }, + "target-dir": "Illuminate/Html", + "extra": { + "branch-alias": { + "dev-master": "4.1-dev" + } + }, + "minimum-stability": "dev" +} diff --git a/vendor/laravel/framework/src/Illuminate/Http/FrameGuard.php b/vendor/laravel/framework/src/Illuminate/Http/FrameGuard.php new file mode 100755 index 0000000..9237605 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Http/FrameGuard.php @@ -0,0 +1,45 @@ +app = $app; + } + + /** + * Handle the given request and get the response. + * + * @implements HttpKernelInterface::handle + * + * @param \Symfony\Component\HttpFoundation\Request $request + * @param int $type + * @param bool $catch + * @return \Symfony\Component\HttpFoundation\Response + */ + public function handle(SymfonyRequest $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true) + { + $response = $this->app->handle($request, $type, $catch); + + $response->headers->set('X-Frame-Options', 'SAMEORIGIN', false); + + return $response; + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Http/JsonResponse.php b/vendor/laravel/framework/src/Illuminate/Http/JsonResponse.php new file mode 100755 index 0000000..0c23026 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Http/JsonResponse.php @@ -0,0 +1,82 @@ +jsonOptions = $options; + + parent::__construct($data, $status, $headers); + } + + /** + * Get the json_decoded data from the response + * + * @param bool $assoc + * @param int $depth + * @return mixed + */ + public function getData($assoc = false, $depth = 512) + { + return json_decode($this->data, $assoc, $depth); + } + + /** + * {@inheritdoc} + */ + public function setData($data = array()) + { + $this->data = $data instanceof JsonableInterface + ? $data->toJson($this->jsonOptions) + : json_encode($data, $this->jsonOptions); + + return $this->update(); + } + + /** + * Set a header on the Response. + * + * @param string $key + * @param string $value + * @param bool $replace + * @return \Illuminate\Http\Response + */ + public function header($key, $value, $replace = true) + { + $this->headers->set($key, $value, $replace); + + return $this; + } + + /** + * Add a cookie to the response. + * + * @param \Symfony\Component\HttpFoundation\Cookie $cookie + * @return \Illuminate\Http\Response + */ + public function withCookie(Cookie $cookie) + { + $this->headers->setCookie($cookie); + + return $this; + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Http/RedirectResponse.php b/vendor/laravel/framework/src/Illuminate/Http/RedirectResponse.php new file mode 100755 index 0000000..b0a72aa --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Http/RedirectResponse.php @@ -0,0 +1,191 @@ +headers->set($key, $value, $replace); + + return $this; + } + + /** + * Flash a piece of data to the session. + * + * @param string $key + * @param mixed $value + * @return \Illuminate\Http\RedirectResponse + */ + public function with($key, $value = null) + { + if (is_array($key)) + { + foreach ($key as $k => $v) $this->with($k, $v); + } + else + { + $this->session->flash($key, $value); + } + + return $this; + } + + /** + * Add a cookie to the response. + * + * @param \Symfony\Component\HttpFoundation\Cookie $cookie + * @return \Illuminate\Http\RedirectResponse + */ + public function withCookie(Cookie $cookie) + { + $this->headers->setCookie($cookie); + + return $this; + } + + /** + * Flash an array of input to the session. + * + * @param array $input + * @return \Illuminate\Http\RedirectResponse + */ + public function withInput(array $input = null) + { + $input = $input ?: $this->request->input(); + + $this->session->flashInput($input); + + return $this; + } + + /** + * Flash an array of input to the session. + * + * @param dynamic string + * @return \Illuminate\Http\RedirectResponse + */ + public function onlyInput() + { + return $this->withInput($this->request->only(func_get_args())); + } + + /** + * Flash an array of input to the session. + * + * @param dynamic string + * @return \Illuminate\Http\RedirectResponse + */ + public function exceptInput() + { + return $this->withInput($this->request->except(func_get_args())); + } + + /** + * Flash a container of errors to the session. + * + * @param \Illuminate\Support\Contracts\MessageProviderInterface|array $provider + * @return \Illuminate\Http\RedirectResponse + */ + public function withErrors($provider) + { + if ($provider instanceof MessageProviderInterface) + { + $this->with('errors', $provider->getMessageBag()); + } + else + { + $this->with('errors', new MessageBag((array) $provider)); + } + + return $this; + } + + /** + * Get the request instance. + * + * @return \Illuminate\Http\Request + */ + public function getRequest() + { + return $this->request; + } + + /** + * Set the request instance. + * + * @param \Illuminate\Http\Request $request + * @return void + */ + public function setRequest(Request $request) + { + $this->request = $request; + } + + /** + * Get the session store implementation. + * + * @return \Illuminate\Session\Store + */ + public function getSession() + { + return $this->session; + } + + /** + * Set the session store implementation. + * + * @param \Illuminate\Session\Store $store + * @return void + */ + public function setSession(SessionStore $session) + { + $this->session = $session; + } + + /** + * Dynamically bind flash data in the session. + * + * @param string $method + * @param array $parameters + * @return void + * + * @throws \BadMethodCallException + */ + public function __call($method, $parameters) + { + if (starts_with($method, 'with')) + { + return $this->with(snake_case(substr($method, 4)), $parameters[0]); + } + + throw new \BadMethodCallException("Method [$method] does not exist on Redirect."); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Http/Request.php b/vendor/laravel/framework/src/Illuminate/Http/Request.php new file mode 100755 index 0000000..d26bdec --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Http/Request.php @@ -0,0 +1,555 @@ +getMethod(); + } + + /** + * Get the root URL for the application. + * + * @return string + */ + public function root() + { + return rtrim($this->getSchemeAndHttpHost().$this->getBaseUrl(), '/'); + } + + /** + * Get the URL (no query string) for the request. + * + * @return string + */ + public function url() + { + return rtrim(preg_replace('/\?.*/', '', $this->getUri()), '/'); + } + + /** + * Get the full URL for the request. + * + * @return string + */ + public function fullUrl() + { + $query = $this->getQueryString(); + + return $query ? $this->url().'?'.$query : $this->url(); + } + + /** + * Get the current path info for the request. + * + * @return string + */ + public function path() + { + $pattern = trim($this->getPathInfo(), '/'); + + return $pattern == '' ? '/' : $pattern; + } + + /** + * Get the current encoded path info for the request. + * + * @return string + */ + public function decodedPath() + { + return rawurldecode($this->path()); + } + + /** + * Get a segment from the URI (1 based index). + * + * @param string $index + * @param mixed $default + * @return string + */ + public function segment($index, $default = null) + { + return array_get($this->segments(), $index - 1, $default); + } + + /** + * Get all of the segments for the request path. + * + * @return array + */ + public function segments() + { + $segments = explode('/', $this->path()); + + return array_values(array_filter($segments, function($v) { return $v != ''; })); + } + + /** + * Determine if the current request URI matches a pattern. + * + * @param dynamic string + * @return bool + */ + public function is() + { + foreach (func_get_args() as $pattern) + { + if (str_is($pattern, urldecode($this->path()))) + { + return true; + } + } + + return false; + } + + /** + * Determine if the request is the result of an AJAX call. + * + * @return bool + */ + public function ajax() + { + return $this->isXmlHttpRequest(); + } + + /** + * Determine if the request is over HTTPS. + * + * @return bool + */ + public function secure() + { + return $this->isSecure(); + } + + /** + * Determine if the request contains a given input item key. + * + * @param string|array $key + * @return bool + */ + public function exists($key) + { + $keys = is_array($key) ? $key : func_get_args(); + + $input = $this->all(); + + foreach ($keys as $value) + { + if ( ! array_key_exists($value, $input)) return false; + } + + return true; + } + + /** + * Determine if the request contains a non-emtpy value for an input item. + * + * @param string|array $key + * @return bool + */ + public function has($key) + { + $keys = is_array($key) ? $key : func_get_args(); + + foreach ($keys as $value) + { + if ($this->isEmptyString($value)) return false; + } + + return true; + } + + /** + * Determine if the given input key is an empty string for "has". + * + * @param string $key + * @return bool + */ + protected function isEmptyString($key) + { + $boolOrArray = is_bool($this->input($key)) || is_array($this->input($key)); + + return ! $boolOrArray && trim((string) $this->input($key)) === ''; + } + + /** + * Get all of the input and files for the request. + * + * @return array + */ + public function all() + { + return array_merge_recursive($this->input(), $this->files->all()); + } + + /** + * Retrieve an input item from the request. + * + * @param string $key + * @param mixed $default + * @return string + */ + public function input($key = null, $default = null) + { + $input = $this->getInputSource()->all() + $this->query->all(); + + return array_get($input, $key, $default); + } + + /** + * Get a subset of the items from the input data. + * + * @param array $keys + * @return array + */ + public function only($keys) + { + $keys = is_array($keys) ? $keys : func_get_args(); + + return array_only($this->input(), $keys) + array_fill_keys($keys, null); + } + + /** + * Get all of the input except for a specified array of items. + * + * @param array $keys + * @return array + */ + public function except($keys) + { + $keys = is_array($keys) ? $keys : func_get_args(); + + $results = $this->input(); + + foreach ($keys as $key) array_forget($results, $key); + + return $results; + } + + /** + * Retrieve a query string item from the request. + * + * @param string $key + * @param mixed $default + * @return string + */ + public function query($key = null, $default = null) + { + return $this->retrieveItem('query', $key, $default); + } + + /** + * Determine if a cookie is set on the request. + * + * @param string $key + * @return bool + */ + public function hasCookie($key) + { + return ! is_null($this->cookie($key)); + } + + /** + * Retrieve a cookie from the request. + * + * @param string $key + * @param mixed $default + * @return string + */ + public function cookie($key = null, $default = null) + { + return $this->retrieveItem('cookies', $key, $default); + } + + /** + * Retrieve a file from the request. + * + * @param string $key + * @param mixed $default + * @return \Symfony\Component\HttpFoundation\File\UploadedFile|array + */ + public function file($key = null, $default = null) + { + return array_get($this->files->all(), $key, $default); + } + + /** + * Determine if the uploaded data contains a file. + * + * @param string $key + * @return bool + */ + public function hasFile($key) + { + if (is_array($file = $this->file($key))) $file = head($file); + + return $file instanceof \SplFileInfo && $file->getPath() != ''; + } + + /** + * Retrieve a header from the request. + * + * @param string $key + * @param mixed $default + * @return string + */ + public function header($key = null, $default = null) + { + return $this->retrieveItem('headers', $key, $default); + } + + /** + * Retrieve a server variable from the request. + * + * @param string $key + * @param mixed $default + * @return string + */ + public function server($key = null, $default = null) + { + return $this->retrieveItem('server', $key, $default); + } + + /** + * Retrieve an old input item. + * + * @param string $key + * @param mixed $default + * @return mixed + */ + public function old($key = null, $default = null) + { + return $this->session()->getOldInput($key, $default); + } + + /** + * Flash the input for the current request to the session. + * + * @param string $filter + * @param array $keys + * @return void + */ + public function flash($filter = null, $keys = array()) + { + $flash = ( ! is_null($filter)) ? $this->$filter($keys) : $this->input(); + + $this->session()->flashInput($flash); + } + + /** + * Flash only some of the input to the session. + * + * @param dynamic string + * @return void + */ + public function flashOnly($keys) + { + $keys = is_array($keys) ? $keys : func_get_args(); + + return $this->flash('only', $keys); + } + + /** + * Flash only some of the input to the session. + * + * @param dynamic string + * @return void + */ + public function flashExcept($keys) + { + $keys = is_array($keys) ? $keys : func_get_args(); + + return $this->flash('except', $keys); + } + + /** + * Flush all of the old input from the session. + * + * @return void + */ + public function flush() + { + $this->session()->flashInput(array()); + } + + /** + * Retrieve a parameter item from a given source. + * + * @param string $source + * @param string $key + * @param mixed $default + * @return string + */ + protected function retrieveItem($source, $key, $default) + { + if (is_null($key)) + { + return $this->$source->all(); + } + else + { + return $this->$source->get($key, $default, true); + } + } + + /** + * Merge new input into the current request's input array. + * + * @param array $input + * @return void + */ + public function merge(array $input) + { + $this->getInputSource()->add($input); + } + + /** + * Replace the input for the current request. + * + * @param array $input + * @return void + */ + public function replace(array $input) + { + $this->getInputSource()->replace($input); + } + + /** + * Get the JSON payload for the request. + * + * @param string $key + * @param mixed $default + * @return mixed + */ + public function json($key = null, $default = null) + { + if ( ! isset($this->json)) + { + $this->json = new ParameterBag((array) json_decode($this->getContent(), true)); + } + + if (is_null($key)) return $this->json; + + return array_get($this->json->all(), $key, $default); + } + + /** + * Get the input source for the request. + * + * @return \Symfony\Component\HttpFoundation\ParameterBag + */ + protected function getInputSource() + { + if ($this->isJson()) return $this->json(); + + return $this->getMethod() == 'GET' ? $this->query : $this->request; + } + + /** + * Determine if the request is sending JSON. + * + * @return bool + */ + public function isJson() + { + return str_contains($this->header('CONTENT_TYPE'), '/json'); + } + + /** + * Determine if the current request is asking for JSON in return. + * + * @return bool + */ + public function wantsJson() + { + $acceptable = $this->getAcceptableContentTypes(); + + return isset($acceptable[0]) && $acceptable[0] == 'application/json'; + } + + /** + * Get the data format expected in the response. + * + * @return string + */ + public function format($default = 'html') + { + foreach ($this->getAcceptableContentTypes() as $type) + { + if ($format = $this->getFormat($type)) return $format; + } + + return $default; + } + + /** + * Create an Illuminate request from a Symfony instance. + * + * @param \Symfony\Component\HttpFoundation\Request $request + * @return \Illuminate\Http\Request + */ + public static function createFromBase(SymfonyRequest $request) + { + if ($request instanceof static) return $request; + + return with(new static)->duplicate( + + $request->query->all(), $request->request->all(), $request->attributes->all(), + + $request->cookies->all(), $request->files->all(), $request->server->all() + ); + } + + /** + * Get the session associated with the request. + * + * @return \Illuminate\Session\Store + * + * @throws \RuntimeException + */ + public function session() + { + if ( ! $this->hasSession()) + { + throw new \RuntimeException("Session store not set on request."); + } + + return $this->getSession(); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Http/Response.php b/vendor/laravel/framework/src/Illuminate/Http/Response.php new file mode 100755 index 0000000..58812e1 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Http/Response.php @@ -0,0 +1,112 @@ +headers->set($key, $value, $replace); + + return $this; + } + + /** + * Add a cookie to the response. + * + * @param \Symfony\Component\HttpFoundation\Cookie $cookie + * @return \Illuminate\Http\Response + */ + public function withCookie(Cookie $cookie) + { + $this->headers->setCookie($cookie); + + return $this; + } + + /** + * Set the content on the response. + * + * @param mixed $content + * @return void + */ + public function setContent($content) + { + $this->original = $content; + + // If the content is "JSONable" we will set the appropriate header and convert + // the content to JSON. This is useful when returning something like models + // from routes that will be automatically transformed to their JSON form. + if ($this->shouldBeJson($content)) + { + $this->headers->set('Content-Type', 'application/json'); + + $content = $this->morphToJson($content); + } + + // If this content implements the "RenderableInterface", then we will call the + // render method on the object so we will avoid any "__toString" exceptions + // that might be thrown and have their errors obscured by PHP's handling. + elseif ($content instanceof RenderableInterface) + { + $content = $content->render(); + } + + return parent::setContent($content); + } + + /** + * Morph the given content into JSON. + * + * @param mixed $content + * @return string + */ + protected function morphToJson($content) + { + if ($content instanceof JsonableInterface) return $content->toJson(); + + return json_encode($content); + } + + /** + * Determine if the given content should be turned into JSON. + * + * @param mixed $content + * @return bool + */ + protected function shouldBeJson($content) + { + return $content instanceof JsonableInterface || + $content instanceof ArrayObject || + is_array($content); + } + + /** + * Get the original response content. + * + * @return mixed + */ + public function getOriginalContent() + { + return $this->original; + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Http/composer.json b/vendor/laravel/framework/src/Illuminate/Http/composer.json new file mode 100755 index 0000000..a9391e6 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Http/composer.json @@ -0,0 +1,33 @@ +{ + "name": "illuminate/http", + "license": "MIT", + "authors": [ + { + "name": "Taylor Otwell", + "email": "taylorotwell@gmail.com" + } + ], + "require": { + "php": ">=5.3.0", + "illuminate/session": "4.1.*", + "illuminate/support": "4.1.*", + "symfony/http-foundation": "2.4.*", + "symfony/http-kernel": "2.4.*" + }, + "require-dev": { + "mockery/mockery": "0.9.*", + "phpunit/phpunit": "4.0.*" + }, + "autoload": { + "psr-0": { + "Illuminate\\Http": "" + } + }, + "target-dir": "Illuminate/Http", + "extra": { + "branch-alias": { + "dev-master": "4.1-dev" + } + }, + "minimum-stability": "dev" +} diff --git a/vendor/laravel/framework/src/Illuminate/Log/LogServiceProvider.php b/vendor/laravel/framework/src/Illuminate/Log/LogServiceProvider.php new file mode 100755 index 0000000..0e10a09 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Log/LogServiceProvider.php @@ -0,0 +1,47 @@ +app['env']), $this->app['events'] + ); + + $this->app->instance('log', $logger); + + // If the setup Closure has been bound in the container, we will resolve it + // and pass in the logger instance. This allows this to defer all of the + // logger class setup until the last possible second, improving speed. + if (isset($this->app['log.setup'])) + { + call_user_func($this->app['log.setup'], $logger); + } + } + + /** + * Get the services provided by the provider. + * + * @return array + */ + public function provides() + { + return array('log'); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Log/Writer.php b/vendor/laravel/framework/src/Illuminate/Log/Writer.php new file mode 100755 index 0000000..5294960 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Log/Writer.php @@ -0,0 +1,254 @@ +monolog = $monolog; + + if (isset($dispatcher)) + { + $this->dispatcher = $dispatcher; + } + } + + /** + * Call Monolog with the given method and parameters. + * + * @param string $method + * @param array $parameters + * @return mixed + */ + protected function callMonolog($method, $parameters) + { + if (is_array($parameters[0])) + { + $parameters[0] = json_encode($parameters[0]); + } + + return call_user_func_array(array($this->monolog, $method), $parameters); + } + + /** + * Register a file log handler. + * + * @param string $path + * @param string $level + * @return void + */ + public function useFiles($path, $level = 'debug') + { + $level = $this->parseLevel($level); + + $this->monolog->pushHandler($handler = new StreamHandler($path, $level)); + + $handler->setFormatter(new LineFormatter(null, null, true)); + } + + /** + * Register a daily file log handler. + * + * @param string $path + * @param int $days + * @param string $level + * @return void + */ + public function useDailyFiles($path, $days = 0, $level = 'debug') + { + $level = $this->parseLevel($level); + + $this->monolog->pushHandler($handler = new RotatingFileHandler($path, $days, $level)); + + $handler->setFormatter(new LineFormatter(null, null, true)); + } + + /** + * Parse the string level into a Monolog constant. + * + * @param string $level + * @return int + * + * @throws \InvalidArgumentException + */ + protected function parseLevel($level) + { + switch ($level) + { + case 'debug': + return MonologLogger::DEBUG; + + case 'info': + return MonologLogger::INFO; + + case 'notice': + return MonologLogger::NOTICE; + + case 'warning': + return MonologLogger::WARNING; + + case 'error': + return MonologLogger::ERROR; + + case 'critical': + return MonologLogger::CRITICAL; + + case 'alert': + return MonologLogger::ALERT; + + case 'emergency': + return MonologLogger::EMERGENCY; + + default: + throw new \InvalidArgumentException("Invalid log level."); + } + } + + /** + * Register a new callback handler for when + * a log event is triggered. + * + * @param Closure $callback + * @return void + * + * @throws \RuntimeException + */ + public function listen(Closure $callback) + { + if ( ! isset($this->dispatcher)) + { + throw new \RuntimeException("Events dispatcher has not been set."); + } + + $this->dispatcher->listen('illuminate.log', $callback); + } + + /** + * Get the underlying Monolog instance. + * + * @return \Monolog\Logger + */ + public function getMonolog() + { + return $this->monolog; + } + + /** + * Get the event dispatcher instance. + * + * @return \Illuminate\Events\Dispatcher + */ + public function getEventDispatcher() + { + return $this->dispatcher; + } + + /** + * Set the event dispatcher instance. + * + * @param \Illuminate\Events\Dispatcher + * @return void + */ + public function setEventDispatcher(Dispatcher $dispatcher) + { + $this->dispatcher = $dispatcher; + } + + /** + * Fires a log event. + * + * @param string $level + * @param array $parameters + * @return void + */ + protected function fireLogEvent($level, $message, array $context = array()) + { + // If the event dispatcher is set, we will pass along the parameters to the + // log listeners. These are useful for building profilers or other tools + // that aggregate all of the log messages for a given "request" cycle. + if (isset($this->dispatcher)) + { + $this->dispatcher->fire('illuminate.log', compact('level', 'message', 'context')); + } + } + + /** + * Dynamically pass log calls into the writer. + * + * @param dynamic (level, param, param) + * @return mixed + */ + public function write() + { + $level = head(func_get_args()); + + return call_user_func_array(array($this, $level), array_slice(func_get_args(), 1)); + } + + /** + * Dynamically handle error additions. + * + * @param string $method + * @param array $parameters + * @return mixed + * + * @throws \BadMethodCallException + */ + public function __call($method, $parameters) + { + if (in_array($method, $this->levels)) + { + call_user_func_array(array($this, 'fireLogEvent'), array_merge(array($method), $parameters)); + + $method = 'add'.ucfirst($method); + + return $this->callMonolog($method, $parameters); + } + + throw new \BadMethodCallException("Method [$method] does not exist."); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Log/composer.json b/vendor/laravel/framework/src/Illuminate/Log/composer.json new file mode 100755 index 0000000..6836ca9 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Log/composer.json @@ -0,0 +1,32 @@ +{ + "name": "illuminate/log", + "license": "MIT", + "authors": [ + { + "name": "Taylor Otwell", + "email": "taylorotwell@gmail.com" + } + ], + "require": { + "php": ">=5.3.0", + "illuminate/support": "4.1.*", + "monolog/monolog": "1.*" + }, + "require-dev": { + "mockery/mockery": "0.9.*", + "phpunit/phpunit": "4.0.*", + "illuminate/events": "4.1.*" + }, + "autoload": { + "psr-0": { + "Illuminate\\Log": "" + } + }, + "target-dir": "Illuminate/Log", + "extra": { + "branch-alias": { + "dev-master": "4.1-dev" + } + }, + "minimum-stability": "dev" +} diff --git a/vendor/laravel/framework/src/Illuminate/Mail/MailServiceProvider.php b/vendor/laravel/framework/src/Illuminate/Mail/MailServiceProvider.php new file mode 100755 index 0000000..40beb30 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Mail/MailServiceProvider.php @@ -0,0 +1,181 @@ +app->bindShared('mailer', function($app) use ($me) + { + $me->registerSwiftMailer(); + + // Once we have create the mailer instance, we will set a container instance + // on the mailer. This allows us to resolve mailer classes via containers + // for maximum testability on said classes instead of passing Closures. + $mailer = new Mailer($app['view'], $app['swift.mailer']); + + $mailer->setLogger($app['log'])->setQueue($app['queue']); + + $mailer->setContainer($app); + + // If a "from" address is set, we will set it on the mailer so that all mail + // messages sent by the applications will utilize the same "from" address + // on each one, which makes the developer's life a lot more convenient. + $from = $app['config']['mail.from']; + + if (is_array($from) && isset($from['address'])) + { + $mailer->alwaysFrom($from['address'], $from['name']); + } + + // Here we will determine if the mailer should be in "pretend" mode for this + // environment, which will simply write out e-mail to the logs instead of + // sending it over the web, which is useful for local dev environments. + $pretend = $app['config']->get('mail.pretend', false); + + $mailer->pretend($pretend); + + return $mailer; + }); + } + + /** + * Register the Swift Mailer instance. + * + * @return void + */ + public function registerSwiftMailer() + { + $config = $this->app['config']['mail']; + + $this->registerSwiftTransport($config); + + // Once we have the transporter registered, we will register the actual Swift + // mailer instance, passing in the transport instances, which allows us to + // override this transporter instances during app start-up if necessary. + $this->app['swift.mailer'] = $this->app->share(function($app) + { + return new Swift_Mailer($app['swift.transport']); + }); + } + + /** + * Register the Swift Transport instance. + * + * @param array $config + * @return void + * + * @throws \InvalidArgumentException + */ + protected function registerSwiftTransport($config) + { + switch ($config['driver']) + { + case 'smtp': + return $this->registerSmtpTransport($config); + + case 'sendmail': + return $this->registerSendmailTransport($config); + + case 'mail': + return $this->registerMailTransport($config); + + default: + throw new \InvalidArgumentException('Invalid mail driver.'); + } + } + + /** + * Register the SMTP Swift Transport instance. + * + * @param array $config + * @return void + */ + protected function registerSmtpTransport($config) + { + $this->app['swift.transport'] = $this->app->share(function($app) use ($config) + { + extract($config); + + // The Swift SMTP transport instance will allow us to use any SMTP backend + // for delivering mail such as Sendgrid, Amazon SMS, or a custom server + // a developer has available. We will just pass this configured host. + $transport = SmtpTransport::newInstance($host, $port); + + if (isset($encryption)) + { + $transport->setEncryption($encryption); + } + + // Once we have the transport we will check for the presence of a username + // and password. If we have it we will set the credentials on the Swift + // transporter instance so that we'll properly authenticate delivery. + if (isset($username)) + { + $transport->setUsername($username); + + $transport->setPassword($password); + } + + return $transport; + }); + } + + /** + * Register the Sendmail Swift Transport instance. + * + * @param array $config + * @return void + */ + protected function registerSendmailTransport($config) + { + $this->app['swift.transport'] = $this->app->share(function($app) use ($config) + { + return SendmailTransport::newInstance($config['sendmail']); + }); + } + + /** + * Register the Mail Swift Transport instance. + * + * @param array $config + * @return void + */ + protected function registerMailTransport($config) + { + $this->app['swift.transport'] = $this->app->share(function() + { + return MailTransport::newInstance(); + }); + } + + /** + * Get the services provided by the provider. + * + * @return array + */ + public function provides() + { + return array('mailer', 'swift.mailer', 'swift.transport'); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Mail/Mailer.php b/vendor/laravel/framework/src/Illuminate/Mail/Mailer.php new file mode 100755 index 0000000..d55c56e --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Mail/Mailer.php @@ -0,0 +1,474 @@ +views = $views; + $this->swift = $swift; + } + + /** + * Set the global from address and name. + * + * @param string $address + * @param string $name + * @return void + */ + public function alwaysFrom($address, $name = null) + { + $this->from = compact('address', 'name'); + } + + /** + * Send a new message when only a plain part. + * + * @param string $view + * @param array $data + * @param mixed $callback + * @return int + */ + public function plain($view, array $data, $callback) + { + return $this->send(array('text' => $view), $data, $callback); + } + + /** + * Send a new message using a view. + * + * @param string|array $view + * @param array $data + * @param Closure|string $callback + * @return int + */ + public function send($view, array $data, $callback) + { + // First we need to parse the view, which could either be a string or an array + // containing both an HTML and plain text versions of the view which should + // be used when sending an e-mail. We will extract both of them out here. + list($view, $plain) = $this->parseView($view); + + $data['message'] = $message = $this->createMessage(); + + $this->callMessageBuilder($callback, $message); + + // Once we have retrieved the view content for the e-mail we will set the body + // of this message using the HTML type, which will provide a simple wrapper + // to creating view based emails that are able to receive arrays of data. + $this->addContent($message, $view, $plain, $data); + + $message = $message->getSwiftMessage(); + + return $this->sendSwiftMessage($message); + } + + /** + * Queue a new e-mail message for sending. + * + * @param string|array $view + * @param array $data + * @param Closure|string $callback + * @param string $queue + * @return void + */ + public function queue($view, array $data, $callback, $queue = null) + { + $callback = $this->buildQueueCallable($callback); + + $this->queue->push('mailer@handleQueuedMessage', compact('view', 'data', 'callback'), $queue); + } + + /** + * Queue a new e-mail message for sending on the given queue. + * + * @param string $queue + * @param string|array $view + * @param array $data + * @param Closure|string $callback + * @return void + */ + public function queueOn($queue, $view, array $data, $callback) + { + $this->queue($view, $data, $callback, $queue); + } + + /** + * Queue a new e-mail message for sending after (n) seconds. + * + * @param int $delay + * @param string|array $view + * @param array $data + * @param Closure|string $callback + * @param string $queue + * @return void + */ + public function later($delay, $view, array $data, $callback, $queue = null) + { + $callback = $this->buildQueueCallable($callback); + + $this->queue->later($delay, 'mailer@handleQueuedMessage', compact('view', 'data', 'callback'), $queue); + } + + /** + * Queue a new e-mail message for sending after (n) seconds on the given queue. + * + * @param string $queue + * @param int $delay + * @param string|array $view + * @param array $data + * @param Closure|string $callback + * @return void + */ + public function laterOn($queue, $delay, $view, array $data, $callback) + { + $this->later($delay, $view, $data, $callback, $queue); + } + + /** + * Build the callable for a queued e-mail job. + * + * @param mixed $callback + * @return mixed + */ + protected function buildQueueCallable($callback) + { + if ( ! $callback instanceof Closure) return $callback; + + return serialize(new SerializableClosure($callback)); + } + + /** + * Handle a queued e-mail message job. + * + * @param \Illuminate\Queue\Jobs\Job $job + * @param array $data + * @return void + */ + public function handleQueuedMessage($job, $data) + { + $this->send($data['view'], $data['data'], $this->getQueuedCallable($data)); + + $job->delete(); + } + + /** + * Get the true callable for a queued e-mail message. + * + * @param array $data + * @return mixed + */ + protected function getQueuedCallable(array $data) + { + if (str_contains($data['callback'], 'SerializableClosure')) + { + return with(unserialize($data['callback']))->getClosure(); + } + + return $data['callback']; + } + + /** + * Add the content to a given message. + * + * @param \Illuminate\Mail\Message $message + * @param string $view + * @param string $plain + * @param array $data + * @return void + */ + protected function addContent($message, $view, $plain, $data) + { + if (isset($view)) + { + $message->setBody($this->getView($view, $data), 'text/html'); + } + + if (isset($plain)) + { + $message->addPart($this->getView($plain, $data), 'text/plain'); + } + } + + /** + * Parse the given view name or array. + * + * @param string|array $view + * @return array + * + * @throws \InvalidArgumentException + */ + protected function parseView($view) + { + if (is_string($view)) return array($view, null); + + // If the given view is an array with numeric keys, we will just assume that + // both a "pretty" and "plain" view were provided, so we will return this + // array as is, since must should contain both views with numeric keys. + if (is_array($view) && isset($view[0])) + { + return $view; + } + + // If the view is an array, but doesn't contain numeric keys, we will assume + // the the views are being explicitly specified and will extract them via + // named keys instead, allowing the developers to use one or the other. + elseif (is_array($view)) + { + return array( + array_get($view, 'html'), array_get($view, 'text') + ); + } + + throw new \InvalidArgumentException("Invalid view."); + } + + /** + * Send a Swift Message instance. + * + * @param \Swift_Message $message + * @return int + */ + protected function sendSwiftMessage($message) + { + if ( ! $this->pretending) + { + return $this->swift->send($message, $this->failedRecipients); + } + elseif (isset($this->logger)) + { + $this->logMessage($message); + + return 1; + } + } + + /** + * Log that a message was sent. + * + * @param \Swift_Message $message + * @return void + */ + protected function logMessage($message) + { + $emails = implode(', ', array_keys((array) $message->getTo())); + + $this->logger->info("Pretending to mail message to: {$emails}"); + } + + /** + * Call the provided message builder. + * + * @param Closure|string $callback + * @param \Illuminate\Mail\Message $message + * @return mixed + * + * @throws \InvalidArgumentException + */ + protected function callMessageBuilder($callback, $message) + { + if ($callback instanceof Closure) + { + return call_user_func($callback, $message); + } + elseif (is_string($callback)) + { + return $this->container[$callback]->mail($message); + } + + throw new \InvalidArgumentException("Callback is not valid."); + } + + /** + * Create a new message instance. + * + * @return \Illuminate\Mail\Message + */ + protected function createMessage() + { + $message = new Message(new Swift_Message); + + // If a global from address has been specified we will set it on every message + // instances so the developer does not have to repeat themselves every time + // they create a new message. We will just go ahead and push the address. + if (isset($this->from['address'])) + { + $message->from($this->from['address'], $this->from['name']); + } + + return $message; + } + + /** + * Render the given view. + * + * @param string $view + * @param array $data + * @return \Illuminate\View\View + */ + protected function getView($view, $data) + { + return $this->views->make($view, $data)->render(); + } + + /** + * Tell the mailer to not really send messages. + * + * @param bool $value + * @return void + */ + public function pretend($value = true) + { + $this->pretending = $value; + } + + /** + * Get the view environment instance. + * + * @return \Illuminate\View\Environment + */ + public function getViewEnvironment() + { + return $this->views; + } + + /** + * Get the Swift Mailer instance. + * + * @return \Swift_Mailer + */ + public function getSwiftMailer() + { + return $this->swift; + } + + /** + * Get the array of failed recipients. + * + * @return array + */ + public function failures() + { + return $this->failedRecipients; + } + + /** + * Set the Swift Mailer instance. + * + * @param \Swift_Mailer $swift + * @return void + */ + public function setSwiftMailer($swift) + { + $this->swift = $swift; + } + + /** + * Set the log writer instance. + * + * @param \Illuminate\Log\Writer $logger + * @return \Illuminate\Mail\Mailer + */ + public function setLogger(Writer $logger) + { + $this->logger = $logger; + + return $this; + } + + /** + * Set the queue manager instance. + * + * @param \Illuminate\Queue\QueueManager $queue + * @return \Illuminate\Mail\Mailer + */ + public function setQueue(QueueManager $queue) + { + $this->queue = $queue; + + return $this; + } + + /** + * Set the IoC container instance. + * + * @param \Illuminate\Container\Container $container + * @return void + */ + public function setContainer(Container $container) + { + $this->container = $container; + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Mail/Message.php b/vendor/laravel/framework/src/Illuminate/Mail/Message.php new file mode 100755 index 0000000..f1b02fd --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Mail/Message.php @@ -0,0 +1,295 @@ +swift = $swift; + } + + /** + * Add a "from" address to the message. + * + * @param string $address + * @param string $name + * @return \Illuminate\Mail\Message + */ + public function from($address, $name = null) + { + $this->swift->setFrom($address, $name); + + return $this; + } + + /** + * Set the "sender" of the message. + * + * @param string $address + * @param string $name + * @return \Illuminate\Mail\Message + */ + public function sender($address, $name = null) + { + $this->swift->setSender($address, $name); + + return $this; + } + + /** + * Set the "return path" of the message. + * + * @param string $address + * @return \Illuminate\Mail\Message + */ + public function returnPath($address) + { + $this->swift->setReturnPath($address); + + return $this; + } + + /** + * Add a recipient to the message. + * + * @param string|array $address + * @param string $name + * @return \Illuminate\Mail\Message + */ + public function to($address, $name = null) + { + return $this->addAddresses($address, $name, 'To'); + } + + /** + * Add a carbon copy to the message. + * + * @param string $address + * @param string $name + * @return \Illuminate\Mail\Message + */ + public function cc($address, $name = null) + { + return $this->addAddresses($address, $name, 'Cc'); + } + + /** + * Add a blind carbon copy to the message. + * + * @param string $address + * @param string $name + * @return \Illuminate\Mail\Message + */ + public function bcc($address, $name = null) + { + return $this->addAddresses($address, $name, 'Bcc'); + } + + /** + * Add a reply to address to the message. + * + * @param string $address + * @param string $name + * @return \Illuminate\Mail\Message + */ + public function replyTo($address, $name = null) + { + return $this->addAddresses($address, $name, 'ReplyTo'); + } + + /** + * Add a recipient to the message. + * + * @param string|array $address + * @param string $name + * @param string $type + * @return \Illuminate\Mail\Message + */ + protected function addAddresses($address, $name, $type) + { + if (is_array($address)) + { + $this->swift->{"set{$type}"}($address, $name); + } + else + { + $this->swift->{"add{$type}"}($address, $name); + } + + return $this; + } + + /** + * Set the subject of the message. + * + * @param string $subject + * @return \Illuminate\Mail\Message + */ + public function subject($subject) + { + $this->swift->setSubject($subject); + + return $this; + } + + /** + * Set the message priority level. + * + * @param int $level + * @return \Illuminate\Mail\Message + */ + public function priority($level) + { + $this->swift->setPriority($level); + + return $this; + } + + /** + * Attach a file to the message. + * + * @param string $file + * @param array $options + * @return \Illuminate\Mail\Message + */ + public function attach($file, array $options = array()) + { + $attachment = $this->createAttachmentFromPath($file); + + return $this->prepAttachment($attachment, $options); + } + + /** + * Create a Swift Attachment instance. + * + * @param string $file + * @return \Swift_Attachment + */ + protected function createAttachmentFromPath($file) + { + return Swift_Attachment::fromPath($file); + } + + /** + * Attach in-memory data as an attachment. + * + * @param string $data + * @param string $name + * @param array $options + * @return \Illuminate\Mail\Message + */ + public function attachData($data, $name, array $options = array()) + { + $attachment = $this->createAttachmentFromData($data, $name); + + return $this->prepAttachment($attachment, $options); + } + + /** + * Create a Swift Attachment instance from data. + * + * @param string $data + * @param string $name + * @return \Swift_Attachment + */ + protected function createAttachmentFromData($data, $name) + { + return Swift_Attachment::newInstance($data, $name); + } + + /** + * Embed a file in the message and get the CID. + * + * @param string $file + * @return string + */ + public function embed($file) + { + return $this->swift->embed(Swift_Image::fromPath($file)); + } + + /** + * Embed in-memory data in the message and get the CID. + * + * @param string $data + * @param string $name + * @param string $contentType + * @return string + */ + public function embedData($data, $name, $contentType = null) + { + $image = Swift_Image::newInstance($data, $name, $contentType); + + return $this->swift->embed($image); + } + + /** + * Prepare and attach the given attachment. + * + * @param \Swift_Attachment $attachment + * @param array $options + * @return \Illuminate\Mail\Message + */ + protected function prepAttachment($attachment, $options = array()) + { + // First we will check for a MIME type on the message, which instructs the + // mail client on what type of attachment the file is so that it may be + // downloaded correctly by the user. The MIME option is not required. + if (isset($options['mime'])) + { + $attachment->setContentType($options['mime']); + } + + // If an alternative name was given as an option, we will set that on this + // attachment so that it will be downloaded with the desired names from + // the developer, otherwise the default file names will get assigned. + if (isset($options['as'])) + { + $attachment->setFilename($options['as']); + } + + $this->swift->attach($attachment); + + return $this; + } + + /** + * Get the underlying Swift Message instance. + * + * @return \Swift_Message + */ + public function getSwiftMessage() + { + return $this->swift; + } + + /** + * Dynamically pass missing methods to the Swift instance. + * + * @param string $method + * @param array $parameters + * @return mixed + */ + public function __call($method, $parameters) + { + $callable = array($this->swift, $method); + + return call_user_func_array($callable, $parameters); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Mail/composer.json b/vendor/laravel/framework/src/Illuminate/Mail/composer.json new file mode 100755 index 0000000..fbb6b0f --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Mail/composer.json @@ -0,0 +1,35 @@ +{ + "name": "illuminate/mail", + "license": "MIT", + "authors": [ + { + "name": "Taylor Otwell", + "email": "taylorotwell@gmail.com" + } + ], + "require": { + "php": ">=5.3.0", + "illuminate/container": "4.1.*", + "illuminate/log": "4.1.*", + "illuminate/support": "4.1.*", + "illuminate/view": "4.1.*", + "swiftmailer/swiftmailer": "~5.0" + }, + "require-dev": { + "illuminate/queue": "4.1.*", + "mockery/mockery": "0.9.*", + "phpunit/phpunit": "4.0.*" + }, + "autoload": { + "psr-0": { + "Illuminate\\Mail": "" + } + }, + "target-dir": "Illuminate/Mail", + "extra": { + "branch-alias": { + "dev-master": "4.1-dev" + } + }, + "minimum-stability": "dev" +} diff --git a/vendor/laravel/framework/src/Illuminate/Pagination/BootstrapPresenter.php b/vendor/laravel/framework/src/Illuminate/Pagination/BootstrapPresenter.php new file mode 100755 index 0000000..65049cb --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Pagination/BootstrapPresenter.php @@ -0,0 +1,39 @@ +'.$page.''; + } + + /** + * Get HTML wrapper for disabled text. + * + * @param string $text + * @return string + */ + public function getDisabledTextWrapper($text) + { + return '
  • '.$text.'
  • '; + } + + /** + * Get HTML wrapper for active text. + * + * @param string $text + * @return string + */ + public function getActivePageWrapper($text) + { + return '
  • '.$text.'
  • '; + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Pagination/Environment.php b/vendor/laravel/framework/src/Illuminate/Pagination/Environment.php new file mode 100755 index 0000000..83450f7 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Pagination/Environment.php @@ -0,0 +1,289 @@ +view = $view; + $this->trans = $trans; + $this->request = $request; + $this->pageName = $pageName; + $this->setupPaginationEnvironment(); + } + + /** + * Setup the pagination environment. + * + * @return void + */ + protected function setupPaginationEnvironment() + { + $this->view->addNamespace('pagination', __DIR__.'/views'); + } + + /** + * Get a new paginator instance. + * + * @param array $items + * @param int $total + * @param int $perPage + * @return \Illuminate\Pagination\Paginator + */ + public function make(array $items, $total, $perPage) + { + $paginator = new Paginator($this, $items, $total, $perPage); + + return $paginator->setupPaginationContext(); + } + + /** + * Get the pagination view. + * + * @param \Illuminate\Pagination\Paginator $paginator + * @param string $view + * @return \Illuminate\View\View + */ + public function getPaginationView(Paginator $paginator, $view = null) + { + $data = array('environment' => $this, 'paginator' => $paginator); + + return $this->view->make($this->getViewName($view), $data); + } + + /** + * Get the number of the current page. + * + * @return int + */ + public function getCurrentPage() + { + $page = (int) $this->currentPage ?: $this->request->input($this->pageName, 1); + + if ($page < 1 || filter_var($page, FILTER_VALIDATE_INT) === false) + { + return 1; + } + + return $page; + } + + /** + * Set the number of the current page. + * + * @param int $number + * @return void + */ + public function setCurrentPage($number) + { + $this->currentPage = $number; + } + + /** + * Get the root URL for the request. + * + * @return string + */ + public function getCurrentUrl() + { + return $this->baseUrl ?: $this->request->url(); + } + + /** + * Set the base URL in use by the paginator. + * + * @param string $baseUrl + * @return void + */ + public function setBaseUrl($baseUrl) + { + $this->baseUrl = $baseUrl; + } + + /** + * Set the input page parameter name used by the paginator. + * + * @param string $pageName + * @return void + */ + public function setPageName($pageName) + { + $this->pageName = $pageName; + } + + /** + * Get the input page parameter name used by the paginator. + * + * @return string + */ + public function getPageName() + { + return $this->pageName; + } + + /** + * Get the name of the pagination view. + * + * @param string $view + * @return string + */ + public function getViewName($view = null) + { + if ( ! is_null($view)) return $view; + + return $this->viewName ?: 'pagination::slider'; + } + + /** + * Set the name of the pagination view. + * + * @param string $viewName + * @return void + */ + public function setViewName($viewName) + { + $this->viewName = $viewName; + } + + /** + * Get the locale of the paginator. + * + * @return string + */ + public function getLocale() + { + return $this->locale; + } + + /** + * Set the locale of the paginator. + * + * @param string $locale + * @return void + */ + public function setLocale($locale) + { + $this->locale = $locale; + } + + /** + * Get the active request instance. + * + * @return \Symfony\Component\HttpFoundation\Request + */ + public function getRequest() + { + return $this->request; + } + + /** + * Set the active request instance. + * + * @param \Symfony\Component\HttpFoundation\Request $request + * @return void + */ + public function setRequest(Request $request) + { + $this->request = $request; + } + + /** + * Get the current view driver. + * + * @return \Illuminate\View\Environment + */ + public function getViewDriver() + { + return $this->view; + } + + /** + * Set the current view driver. + * + * @param \Illuminate\View\Environment $view + * @return void + */ + public function setViewDriver(ViewEnvironment $view) + { + $this->view = $view; + } + + /** + * Get the translator instance. + * + * @return \Symfony\Component\Translation\TranslatorInterface + */ + public function getTranslator() + { + return $this->trans; + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Pagination/PaginationServiceProvider.php b/vendor/laravel/framework/src/Illuminate/Pagination/PaginationServiceProvider.php new file mode 100755 index 0000000..7737cdb --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Pagination/PaginationServiceProvider.php @@ -0,0 +1,43 @@ +app->bindShared('paginator', function($app) + { + $paginator = new Environment($app['request'], $app['view'], $app['translator']); + + $paginator->setViewName($app['config']['view.pagination']); + + $app->refresh('request', $paginator, 'setRequest'); + + return $paginator; + }); + } + + /** + * Get the services provided by the provider. + * + * @return array + */ + public function provides() + { + return array('paginator'); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Pagination/Paginator.php b/vendor/laravel/framework/src/Illuminate/Pagination/Paginator.php new file mode 100755 index 0000000..55f6ec3 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Pagination/Paginator.php @@ -0,0 +1,505 @@ +env = $env; + $this->items = $items; + $this->total = (int) $total; + $this->perPage = (int) $perPage; + } + + /** + * Setup the pagination context (current and last page). + * + * @return \Illuminate\Pagination\Paginator + */ + public function setupPaginationContext() + { + $this->calculateCurrentAndLastPages(); + + $this->calculateItemRanges(); + + return $this; + } + + /** + * Calculate the current and last pages for this instance. + * + * @return void + */ + protected function calculateCurrentAndLastPages() + { + $this->lastPage = (int) ceil($this->total / $this->perPage); + + $this->currentPage = $this->calculateCurrentPage($this->lastPage); + } + + /** + * Calculate the first and last item number for this instance. + * + * @return void + */ + protected function calculateItemRanges() + { + $this->from = $this->total ? ($this->currentPage - 1) * $this->perPage + 1 : 0; + + $this->to = min($this->total, $this->currentPage * $this->perPage); + } + + /** + * Get the current page for the request. + * + * @param int $lastPage + * @return int + */ + protected function calculateCurrentPage($lastPage) + { + $page = $this->env->getCurrentPage(); + + // The page number will get validated and adjusted if it either less than one + // or greater than the last page available based on the count of the given + // items array. If it's greater than the last, we'll give back the last. + if (is_numeric($page) && $page > $lastPage) + { + return $lastPage > 0 ? $lastPage : 1; + } + + return $this->isValidPageNumber($page) ? (int) $page : 1; + } + + /** + * Determine if the given value is a valid page number. + * + * @param int $page + * @return bool + */ + protected function isValidPageNumber($page) + { + return $page >= 1 && filter_var($page, FILTER_VALIDATE_INT) !== false; + } + + /** + * Get the pagination links view. + * + * @param string $view + * @return \Illuminate\View\View + */ + public function links($view = null) + { + return $this->env->getPaginationView($this, $view); + } + + /** + * Get a URL for a given page number. + * + * @param int $page + * @return string + */ + public function getUrl($page) + { + $parameters = array( + $this->env->getPageName() => $page, + ); + + // If we have any extra query string key / value pairs that need to be added + // onto the URL, we will put them in query string form and then attach it + // to the URL. This allows for extra information like sortings storage. + if (count($this->query) > 0) + { + $parameters = array_merge($parameters, $this->query); + } + + $fragment = $this->buildFragment(); + + return $this->env->getCurrentUrl().'?'.http_build_query($parameters, null, '&').$fragment; + } + + /** + * Get / set the URL fragment to be appended to URLs. + * + * @param string|null $fragment + * @return \Illuminate\Pagination\Paginator|string + */ + public function fragment($fragment = null) + { + if (is_null($fragment)) return $this->fragment; + + $this->fragment = $fragment; return $this; + } + + /** + * Build the full fragment portion of a URL. + * + * @return string + */ + protected function buildFragment() + { + return $this->fragment ? '#'.$this->fragment : ''; + } + + /** + * Add a query string value to the paginator. + * + * @param string $key + * @param string $value + * @return \Illuminate\Pagination\Paginator + */ + public function appends($key, $value = null) + { + if (is_array($key)) return $this->appendArray($key); + + return $this->addQuery($key, $value); + } + + /** + * Add an array of query string values. + * + * @param array $keys + * @return \Illuminate\Pagination\Paginator + */ + protected function appendArray(array $keys) + { + foreach ($keys as $key => $value) + { + $this->addQuery($key, $value); + } + + return $this; + } + + /** + * Add a query string value to the paginator. + * + * @param string $key + * @param string $value + * @return \Illuminate\Pagination\Paginator + */ + public function addQuery($key, $value) + { + $this->query[$key] = $value; + + return $this; + } + + /** + * Get the current page for the request. + * + * @param int|null $total + * @return int + */ + public function getCurrentPage($total = null) + { + if (is_null($total)) + { + return $this->currentPage; + } + else + { + return min($this->currentPage, (int) ceil($total / $this->perPage)); + } + } + + /** + * Get the last page that should be available. + * + * @return int + */ + public function getLastPage() + { + return $this->lastPage; + } + + /** + * Get the number of the first item on the paginator. + * + * @return int + */ + public function getFrom() + { + return $this->from; + } + + /** + * Get the number of the last item on the paginator. + * + * @return int + */ + public function getTo() + { + return $this->to; + } + + /** + * Get the number of items to be displayed per page. + * + * @return int + */ + public function getPerPage() + { + return $this->perPage; + } + + /** + * Get a collection instance containing the items. + * + * @return \Illuminate\Support\Collection + */ + public function getCollection() + { + return new Collection($this->items); + } + + /** + * Get the items being paginated. + * + * @return array + */ + public function getItems() + { + return $this->items; + } + + /** + * Set the items being paginated. + * + * @param mixed $items + * @return void + */ + public function setItems($items) + { + $this->items = $items; + } + + /** + * Get the total number of items in the collection. + * + * @return int + */ + public function getTotal() + { + return $this->total; + } + + /** + * Set the base URL in use by the paginator. + * + * @param string $baseUrl + * @return void + */ + public function setBaseUrl($baseUrl) + { + $this->env->setBaseUrl($baseUrl); + } + + /** + * Get the pagination environment. + * + * @return \Illuminate\Pagination\Environment + */ + public function getEnvironment() + { + return $this->env; + } + + /** + * Get an iterator for the items. + * + * @return ArrayIterator + */ + public function getIterator() + { + return new ArrayIterator($this->items); + } + + /** + * Determine if the list of items is empty or not. + * + * @return bool + */ + public function isEmpty() + { + return empty($this->items); + } + + /** + * Get the number of items for the current page. + * + * @return int + */ + public function count() + { + return count($this->items); + } + + /** + * Determine if the given item exists. + * + * @param mixed $key + * @return bool + */ + public function offsetExists($key) + { + return array_key_exists($key, $this->items); + } + + /** + * Get the item at the given offset. + * + * @param mixed $key + * @return mixed + */ + public function offsetGet($key) + { + return $this->items[$key]; + } + + /** + * Set the item at the given offset. + * + * @param mixed $key + * @param mixed $value + * @return void + */ + public function offsetSet($key, $value) + { + $this->items[$key] = $value; + } + + /** + * Unset the item at the given key. + * + * @param mixed $key + * @return void + */ + public function offsetUnset($key) + { + unset($this->items[$key]); + } + + /** + * Get the instance as an array. + * + * @return array + */ + public function toArray() + { + return array( + 'total' => $this->total, 'per_page' => $this->perPage, + 'current_page' => $this->currentPage, 'last_page' => $this->lastPage, + 'from' => $this->from, 'to' => $this->to, 'data' => $this->getCollection()->toArray(), + ); + } + + /** + * Convert the object to its JSON representation. + * + * @param int $options + * @return string + */ + public function toJson($options = 0) + { + return json_encode($this->toArray(), $options); + } + + /** + * Call a method on the underlying Collection + * + * @param string $method + * @param array $arguments + * @return mixed + */ + public function __call($method, $arguments) + { + return call_user_func_array(array($this->getCollection(), $method), $arguments); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Pagination/Presenter.php b/vendor/laravel/framework/src/Illuminate/Pagination/Presenter.php new file mode 100755 index 0000000..9e4f825 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Pagination/Presenter.php @@ -0,0 +1,280 @@ +paginator = $paginator; + $this->lastPage = $this->paginator->getLastPage(); + $this->currentPage = $this->paginator->getCurrentPage(); + } + + /** + * Get HTML wrapper for a page link. + * + * @param string $url + * @param int $page + * @return string + */ + abstract public function getPageLinkWrapper($url, $page); + + /** + * Get HTML wrapper for disabled text. + * + * @param string $text + * @return string + */ + abstract public function getDisabledTextWrapper($text); + + /** + * Get HTML wrapper for active text. + * + * @param string $text + * @return string + */ + abstract public function getActivePageWrapper($text); + + /** + * Render the Pagination contents. + * + * @return string + */ + public function render() + { + // The hard-coded thirteen represents the minimum number of pages we need to + // be able to create a sliding page window. If we have less than that, we + // will just render a simple range of page links insteadof the sliding. + if ($this->lastPage < 13) + { + $content = $this->getPageRange(1, $this->lastPage); + } + else + { + $content = $this->getPageSlider(); + } + + return $this->getPrevious().$content.$this->getNext(); + } + + /** + * Create a range of pagination links. + * + * @param int $start + * @param int $end + * @return string + */ + public function getPageRange($start, $end) + { + $pages = array(); + + for ($page = $start; $page <= $end; $page++) + { + // If the current page is equal to the page we're iterating on, we will create a + // disabled link for that page. Otherwise, we can create a typical active one + // for the link. We will use this implementing class's methods to get HTML. + if ($this->currentPage == $page) + { + $pages[] = $this->getActivePageWrapper($page); + } + else + { + $pages[] = $this->getLink($page); + } + } + + return implode('', $pages); + } + + /** + * Create a pagination slider link window. + * + * @return string + */ + protected function getPageSlider() + { + $window = 6; + + // If the current page is very close to the beginning of the page range, we will + // just render the beginning of the page range, followed by the last 2 of the + // links in this list, since we will not have room to create a full slider. + if ($this->currentPage <= $window) + { + $ending = $this->getFinish(); + + return $this->getPageRange(1, $window + 2).$ending; + } + + // If the current page is close to the ending of the page range we will just get + // this first couple pages, followed by a larger window of these ending pages + // since we're too close to the end of the list to create a full on slider. + elseif ($this->currentPage >= $this->lastPage - $window) + { + $start = $this->lastPage - 8; + + $content = $this->getPageRange($start, $this->lastPage); + + return $this->getStart().$content; + } + + // If we have enough room on both sides of the current page to build a slider we + // will surround it with both the beginning and ending caps, with this window + // of pages in the middle providing a Google style sliding paginator setup. + else + { + $content = $this->getAdjacentRange(); + + return $this->getStart().$content.$this->getFinish(); + } + } + + /** + * Get the page range for the current page window. + * + * @return string + */ + public function getAdjacentRange() + { + return $this->getPageRange($this->currentPage - 3, $this->currentPage + 3); + } + + /** + * Create the beginning leader of a pagination slider. + * + * @return string + */ + public function getStart() + { + return $this->getPageRange(1, 2).$this->getDots(); + } + + /** + * Create the ending cap of a pagination slider. + * + * @return string + */ + public function getFinish() + { + $content = $this->getPageRange($this->lastPage - 1, $this->lastPage); + + return $this->getDots().$content; + } + + /** + * Get the previous page pagination element. + * + * @param string $text + * @return string + */ + public function getPrevious($text = '«') + { + // If the current page is less than or equal to one, it means we can't go any + // further back in the pages, so we will render a disabled previous button + // when that is the case. Otherwise, we will give it an active "status". + if ($this->currentPage <= 1) + { + return $this->getDisabledTextWrapper($text); + } + else + { + $url = $this->paginator->getUrl($this->currentPage - 1); + + return $this->getPageLinkWrapper($url, $text); + } + } + + /** + * Get the next page pagination element. + * + * @param string $text + * @return string + */ + public function getNext($text = '»') + { + // If the current page is greater than or equal to the last page, it means we + // can't go any further into the pages, as we're already on this last page + // that is available, so we will make it the "next" link style disabled. + if ($this->currentPage >= $this->lastPage) + { + return $this->getDisabledTextWrapper($text); + } + else + { + $url = $this->paginator->getUrl($this->currentPage + 1); + + return $this->getPageLinkWrapper($url, $text); + } + } + + /** + * Get a pagination "dot" element. + * + * @return string + */ + public function getDots() + { + return $this->getDisabledTextWrapper("..."); + } + + /** + * Create a pagination slider link. + * + * @param mixed $page + * @return string + */ + public function getLink($page) + { + $url = $this->paginator->getUrl($page); + + return $this->getPageLinkWrapper($url, $page); + } + + /** + * Set the value of the current page. + * + * @param int $page + * @return void + */ + public function setCurrentPage($page) + { + $this->currentPage = $page; + } + + /** + * Set the value of the last page. + * + * @param int $page + * @return void + */ + public function setLastPage($page) + { + $this->lastPage = $page; + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Pagination/composer.json b/vendor/laravel/framework/src/Illuminate/Pagination/composer.json new file mode 100755 index 0000000..7d09a3b --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Pagination/composer.json @@ -0,0 +1,34 @@ +{ + "name": "illuminate/pagination", + "license": "MIT", + "authors": [ + { + "name": "Taylor Otwell", + "email": "taylorotwell@gmail.com" + } + ], + "require": { + "php": ">=5.3.0", + "illuminate/http": "4.1.*", + "illuminate/support": "4.1.*", + "illuminate/view": "4.1.*", + "symfony/http-foundation": "2.4.*", + "symfony/translation": "2.4.*" + }, + "require-dev": { + "mockery/mockery": "0.9.*", + "phpunit/phpunit": "4.0.*" + }, + "autoload": { + "psr-0": { + "Illuminate\\Pagination": "" + } + }, + "target-dir": "Illuminate/Pagination", + "extra": { + "branch-alias": { + "dev-master": "4.1-dev" + } + }, + "minimum-stability": "dev" +} diff --git a/vendor/laravel/framework/src/Illuminate/Pagination/views/simple.php b/vendor/laravel/framework/src/Illuminate/Pagination/views/simple.php new file mode 100755 index 0000000..3a13482 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Pagination/views/simple.php @@ -0,0 +1,15 @@ +getTranslator(); +?> + +getLastPage() > 1): ?> +
      + getPrevious($trans->trans('pagination.previous')); + + echo $presenter->getNext($trans->trans('pagination.next')); + ?> +
    + diff --git a/vendor/laravel/framework/src/Illuminate/Pagination/views/slider-3.php b/vendor/laravel/framework/src/Illuminate/Pagination/views/slider-3.php new file mode 100755 index 0000000..5757e6c --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Pagination/views/slider-3.php @@ -0,0 +1,9 @@ + + +getLastPage() > 1): ?> +
      + render(); ?> +
    + diff --git a/vendor/laravel/framework/src/Illuminate/Pagination/views/slider.php b/vendor/laravel/framework/src/Illuminate/Pagination/views/slider.php new file mode 100755 index 0000000..2344162 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Pagination/views/slider.php @@ -0,0 +1,11 @@ + + +getLastPage() > 1): ?> + + diff --git a/vendor/laravel/framework/src/Illuminate/Queue/BeanstalkdQueue.php b/vendor/laravel/framework/src/Illuminate/Queue/BeanstalkdQueue.php new file mode 100755 index 0000000..719eab1 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Queue/BeanstalkdQueue.php @@ -0,0 +1,142 @@ +default = $default; + $this->timeToRun = $timeToRun; + $this->pheanstalk = $pheanstalk; + } + + /** + * Push a new job onto the queue. + * + * @param string $job + * @param mixed $data + * @param string $queue + * @return mixed + */ + public function push($job, $data = '', $queue = null) + { + return $this->pushRaw($this->createPayload($job, $data), $queue); + } + + /** + * Push a raw payload onto the queue. + * + * @param string $payload + * @param string $queue + * @param array $options + * @return mixed + */ + public function pushRaw($payload, $queue = null, array $options = array()) + { + return $this->pheanstalk->useTube($this->getQueue($queue))->put( + $payload, Pheanstalk::DEFAULT_PRIORITY, Pheanstalk::DEFAULT_DELAY, $this->timeToRun + ); + } + + /** + * Push a new job onto the queue after a delay. + * + * @param \DateTime|int $delay + * @param string $job + * @param mixed $data + * @param string $queue + * @return mixed + */ + public function later($delay, $job, $data = '', $queue = null) + { + $payload = $this->createPayload($job, $data); + + $pheanstalk = $this->pheanstalk->useTube($this->getQueue($queue)); + + return $pheanstalk->put($payload, Pheanstalk::DEFAULT_PRIORITY, $this->getSeconds($delay)); + } + + /** + * Pop the next job off of the queue. + * + * @param string $queue + * @return \Illuminate\Queue\Jobs\Job|null + */ + public function pop($queue = null) + { + $queue = $this->getQueue($queue); + + $job = $this->pheanstalk->watchOnly($queue)->reserve(0); + + if ($job instanceof Pheanstalk_Job) + { + return new BeanstalkdJob($this->container, $this->pheanstalk, $job, $queue); + } + } + + /** + * Delete a message from the Beanstalk queue. + * + * @param string $queue + * @param string $id + * @return void + */ + public function deleteMessage($queue, $id) + { + $this->pheanstalk->useTube($this->getQueue($queue))->delete($id); + } + + /** + * Get the queue or return the default. + * + * @param string|null $queue + * @return string + */ + public function getQueue($queue) + { + return $queue ?: $this->default; + } + + /** + * Get the underlying Pheanstalk instance. + * + * @return Pheanstalk + */ + public function getPheanstalk() + { + return $this->pheanstalk; + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Queue/Capsule/Manager.php b/vendor/laravel/framework/src/Illuminate/Queue/Capsule/Manager.php new file mode 100755 index 0000000..59d61b6 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Queue/Capsule/Manager.php @@ -0,0 +1,231 @@ +setupContainer($container); + + // Once we have the container setup, we will setup the default configuration + // options in the container "config" bindings. This just makes this queue + // manager behave correctly since all the correct binding are in place. + $this->setupDefaultConfiguration(); + + $this->setupManager(); + + $this->registerConnectors(); + } + + /** + * Setup the IoC container instance. + * + * @param \Illuminate\Container\Container $container + * @return void + */ + protected function setupContainer($container) + { + $this->container = $container ?: new Container; + + $this->container->instance('config', new Fluent); + } + + /** + * Setup the default queue configuration options. + * + * @return void + */ + protected function setupDefaultConfiguration() + { + $this->container['config']['queue.default'] = 'default'; + } + + /** + * Build the queue manager instance. + * + * @return void + */ + protected function setupManager() + { + $this->manager = new QueueManager($this->container); + } + + /** + * Register the default connectors that the component ships with. + * + * @return void + */ + protected function registerConnectors() + { + $provider = new QueueServiceProvider($this->container); + + $provider->registerConnectors($this->manager); + } + + /** + * Get a connection instance from the global manager. + * + * @param string $connection + * @return \Illuminate\Queue\QueueInterface + */ + public static function connection($connection = null) + { + return static::$instance->getConnection($connection); + } + + /** + * Push a new job onto the queue. + * + * @param string $job + * @param mixed $data + * @param string $queue + * @param string $connection + * @return mixed + */ + public static function push($job, $data = '', $queue = null, $connection = null) + { + return static::$instance->connection($connection)->push($job, $data, $queue); + } + + /** + * Push a new an array of jobs onto the queue. + * + * @param array $jobs + * @param mixed $data + * @param string $queue + * @param string $connection + * @return mixed + */ + public static function bulk($jobs, $data = '', $queue = null, $connection = null) + { + return static::$instance->connection($connection)->bulk($jobs, $data, $queue); + } + + /** + * Push a new job onto the queue after a delay. + * + * @param \DateTime|int $delay + * @param string $job + * @param mixed $data + * @param string $queue + * @param string $connection + * @return mixed + */ + public static function later($delay, $job, $data = '', $queue = null, $connection = null) + { + return static::$instance->connection($connection)->later($delay, $job, $data, $queue); + } + + /** + * Get a registered connection instance. + * + * @param string $name + * @return \Illuminate\Queue\QueueInterface + */ + public function getConnection($name = null) + { + return $this->manager->connection($name); + } + + /** + * Register a connection with the manager. + * + * @param array $config + * @param string $name + * @return void + */ + public function addConnection(array $config, $name = 'default') + { + $this->container['config']["queue.connections.{$name}"] = $config; + } + + /** + * Make this capsule instance available globally. + * + * @return void + */ + public function setAsGlobal() + { + static::$instance = $this; + } + + /** + * Get the queue manager instance. + * + * @return \Illuminate\Queue\Manager + */ + public function getQueueManager() + { + return $this->manager; + } + + /** + * Get the IoC container instance. + * + * @return \Illuminate\Container\Container + */ + public function getContainer() + { + return $this->container; + } + + /** + * Set the IoC container instance. + * + * @param \Illuminate\Container\Container $container + * @return void + */ + public function setContainer(Container $container) + { + $this->container = $container; + } + + /** + * Pass dynamic instance methods to the manager. + * + * @param string $method + * @param array $parameters + * @return mixed + */ + public function __call($method, $parameters) + { + return call_user_func_array(array($this->manager, $method), $parameters); + } + + /** + * Dynamically pass methods to the default connection. + * + * @param string $method + * @param array $parameters + * @return mixed + */ + public static function __callStatic($method, $parameters) + { + return call_user_func_array(array(static::connection(), $method), $parameters); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Queue/Connectors/BeanstalkdConnector.php b/vendor/laravel/framework/src/Illuminate/Queue/Connectors/BeanstalkdConnector.php new file mode 100755 index 0000000..8986433 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Queue/Connectors/BeanstalkdConnector.php @@ -0,0 +1,23 @@ +crypt = $crypt; + $this->request = $request; + } + + /** + * Establish a queue connection. + * + * @param array $config + * @return \Illuminate\Queue\QueueInterface + */ + public function connect(array $config) + { + $ironConfig = array('token' => $config['token'], 'project_id' => $config['project']); + + if (isset($config['host'])) $ironConfig['host'] = $config['host']; + + $iron = new IronMQ($ironConfig); + + if (isset($config['ssl_verifypeer'])) + { + $iron->ssl_verifypeer = $config['ssl_verifypeer']; + } + + return new IronQueue($iron, $this->crypt, $this->request, $config['queue']); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Queue/Connectors/RedisConnector.php b/vendor/laravel/framework/src/Illuminate/Queue/Connectors/RedisConnector.php new file mode 100755 index 0000000..ab83618 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Queue/Connectors/RedisConnector.php @@ -0,0 +1,46 @@ +redis = $redis; + $this->connection = $connection; + } + + /** + * Establish a queue connection. + * + * @param array $config + * @return \Illuminate\Queue\QueueInterface + */ + public function connect(array $config) + { + return new RedisQueue($this->redis, $config['queue'], $this->connection); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Queue/Connectors/SqsConnector.php b/vendor/laravel/framework/src/Illuminate/Queue/Connectors/SqsConnector.php new file mode 100755 index 0000000..86aeeca --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Queue/Connectors/SqsConnector.php @@ -0,0 +1,21 @@ +files = $files; + } + + /** + * Execute the console command. + * + * @return void + */ + public function fire() + { + $fullPath = $this->createBaseMigration(); + + $this->files->put($fullPath, $this->files->get(__DIR__.'/stubs/failed_jobs.stub')); + + $this->info('Migration created successfully!'); + } + + /** + * Create a base migration file for the table. + * + * @return string + */ + protected function createBaseMigration() + { + $name = 'create_failed_jobs_table'; + + $path = $this->laravel['path'].'/database/migrations'; + + return $this->laravel['migration.creator']->create($name, $path); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Queue/Console/FlushFailedCommand.php b/vendor/laravel/framework/src/Illuminate/Queue/Console/FlushFailedCommand.php new file mode 100755 index 0000000..0ece99b --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Queue/Console/FlushFailedCommand.php @@ -0,0 +1,33 @@ +laravel['queue.failer']->flush(); + + $this->info('All failed jobs deleted successfully!'); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Queue/Console/ForgetFailedCommand.php b/vendor/laravel/framework/src/Illuminate/Queue/Console/ForgetFailedCommand.php new file mode 100755 index 0000000..fef76f0 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Queue/Console/ForgetFailedCommand.php @@ -0,0 +1,51 @@ +laravel['queue.failer']->forget($this->argument('id'))) + { + $this->info('Failed job deleted successfully!'); + } + else + { + $this->error('No failed job matches the given ID.'); + } + } + + /** + * Get the console command arguments. + * + * @return array + */ + protected function getArguments() + { + return array( + array('id', InputArgument::REQUIRED, 'The ID of the failed job'), + ); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Queue/Console/ListFailedCommand.php b/vendor/laravel/framework/src/Illuminate/Queue/Console/ListFailedCommand.php new file mode 100755 index 0000000..03bc411 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Queue/Console/ListFailedCommand.php @@ -0,0 +1,62 @@ +laravel['queue.failer']->all() as $failed) + { + $rows[] = $this->parseFailedJob((array) $failed); + } + + if (count($rows) == 0) + { + return $this->info('No failed jobs!'); + } + + $table = $this->getHelperSet()->get('table'); + + $table->setHeaders(array('ID', 'Connection', 'Queue', 'Class', 'Failed At')) + ->setRows($rows) + ->render($this->output); + } + + /** + * Parse the failed job row. + * + * @param array $failed + * @return array + */ + protected function parseFailedJob(array $failed) + { + $row = array_values(array_except($failed, array('payload'))); + + array_splice($row, 3, 0, array_get(json_decode($failed['payload'], true), 'job')); + + return $row; + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Queue/Console/ListenCommand.php b/vendor/laravel/framework/src/Illuminate/Queue/Console/ListenCommand.php new file mode 100755 index 0000000..0156d6c --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Queue/Console/ListenCommand.php @@ -0,0 +1,140 @@ +listener = $listener; + } + + /** + * Execute the console command. + * + * @return void + */ + public function fire() + { + $this->setListenerOptions(); + + $delay = $this->input->getOption('delay'); + + // The memory limit is the amount of memory we will allow the script to occupy + // before killing it and letting a process manager restart it for us, which + // is to protect us against any memory leaks that will be in the scripts. + $memory = $this->input->getOption('memory'); + + $connection = $this->input->getArgument('connection'); + + $timeout = $this->input->getOption('timeout'); + + // We need to get the right queue for the connection which is set in the queue + // configuration file for the application. We will pull it based on the set + // connection being run for the queue operation currently being executed. + $queue = $this->getQueue($connection); + + $this->listener->listen( + $connection, $queue, $delay, $memory, $timeout + ); + } + + /** + * Get the name of the queue connection to listen on. + * + * @param string $connection + * @return string + */ + protected function getQueue($connection) + { + if (is_null($connection)) + { + $connection = $this->laravel['config']['queue.default']; + } + + $queue = $this->laravel['config']->get("queue.connections.{$connection}.queue", 'default'); + + return $this->input->getOption('queue') ?: $queue; + } + + /** + * Set the options on the queue listener. + * + * @return void + */ + protected function setListenerOptions() + { + $this->listener->setEnvironment($this->laravel->environment()); + + $this->listener->setSleep($this->option('sleep')); + + $this->listener->setMaxTries($this->option('tries')); + } + + /** + * Get the console command arguments. + * + * @return array + */ + protected function getArguments() + { + return array( + array('connection', InputArgument::OPTIONAL, 'The name of connection'), + ); + } + + /** + * Get the console command options. + * + * @return array + */ + protected function getOptions() + { + return array( + array('queue', null, InputOption::VALUE_OPTIONAL, 'The queue to listen on', null), + + array('delay', null, InputOption::VALUE_OPTIONAL, 'Amount of time to delay failed jobs', 0), + + array('memory', null, InputOption::VALUE_OPTIONAL, 'The memory limit in megabytes', 128), + + array('timeout', null, InputOption::VALUE_OPTIONAL, 'Seconds a job may run before timing out', 60), + + array('sleep', null, InputOption::VALUE_OPTIONAL, 'Seconds to wait before checking queue for jobs', 3), + + array('tries', null, InputOption::VALUE_OPTIONAL, 'Number of times to attempt a job before logging it failed', 0), + ); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Queue/Console/RetryCommand.php b/vendor/laravel/framework/src/Illuminate/Queue/Console/RetryCommand.php new file mode 100755 index 0000000..454b56d --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Queue/Console/RetryCommand.php @@ -0,0 +1,74 @@ +laravel['queue.failer']->find($this->argument('id')); + + if ( ! is_null($failed)) + { + $failed->payload = $this->resetAttempts($failed->payload); + + $this->laravel['queue']->connection($failed->connection)->pushRaw($failed->payload, $failed->queue); + + $this->laravel['queue.failer']->forget($failed->id); + + $this->info('The failed job has been pushed back onto the queue!'); + } + else + { + $this->error('No failed job matches the given ID.'); + } + } + + /** + * Reset the payload attempts. + * + * @param string $payload + * @return string + */ + protected function resetAttempts($payload) + { + $payload = json_decode($payload, true); + + if (isset($payload['attempts'])) $payload['attempts'] = 0; + + return json_encode($payload); + } + + /** + * Get the console command arguments. + * + * @return array + */ + protected function getArguments() + { + return array( + array('id', InputArgument::REQUIRED, 'The ID of the failed job'), + ); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Queue/Console/SubscribeCommand.php b/vendor/laravel/framework/src/Illuminate/Queue/Console/SubscribeCommand.php new file mode 100755 index 0000000..89c4209 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Queue/Console/SubscribeCommand.php @@ -0,0 +1,153 @@ +laravel['queue']->connection(); + + if ( ! $iron instanceof IronQueue) + { + throw new RuntimeException("Iron.io based queue must be default."); + } + + $iron->getIron()->updateQueue($this->argument('queue'), $this->getQueueOptions()); + + $this->line('Queue subscriber added: '.$this->argument('url').''); + } + + /** + * Get the queue options. + * + * @return array + */ + protected function getQueueOptions() + { + return array( + 'push_type' => $this->getPushType(), 'subscribers' => $this->getSubscriberList() + ); + } + + /** + * Get the push type for the queue. + * + * @return string + */ + protected function getPushType() + { + if ($this->option('type')) return $this->option('type'); + + try + { + return $this->getQueue()->push_type; + } + catch (\Exception $e) + { + return 'multicast'; + } + } + + /** + * Get the current subscribers for the queue. + * + * @return array + */ + protected function getSubscriberList() + { + $subscribers = $this->getCurrentSubscribers(); + + $subscribers[] = array('url' => $this->argument('url')); + + return $subscribers; + } + + /** + * Get the current subscriber list. + * + * @return array + */ + protected function getCurrentSubscribers() + { + try + { + return $this->getQueue()->subscribers; + } + catch (\Exception $e) + { + return array(); + } + } + + /** + * Get the queue information from Iron.io. + * + * @return object + */ + protected function getQueue() + { + if (isset($this->meta)) return $this->meta; + + return $this->meta = $this->laravel['queue']->getIron()->getQueue($this->argument('queue')); + } + + /** + * Get the console command arguments. + * + * @return array + */ + protected function getArguments() + { + return array( + array('queue', InputArgument::REQUIRED, 'The name of Iron.io queue.'), + + array('url', InputArgument::REQUIRED, 'The URL to be subscribed.'), + ); + } + + /** + * Get the console command options. + * + * @return array + */ + protected function getOptions() + { + return array( + array('type', null, InputOption::VALUE_OPTIONAL, 'The push type for the queue.'), + ); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php b/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php new file mode 100755 index 0000000..5a9728b --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php @@ -0,0 +1,113 @@ +worker = $worker; + } + + /** + * Execute the console command. + * + * @return void + */ + public function fire() + { + if ($this->downForMaintenance()) return; + + $queue = $this->option('queue'); + + $delay = $this->option('delay'); + + // The memory limit is the amount of memory we will allow the script to occupy + // before killing it and letting a process manager restart it for us, which + // is to protect us against any memory leaks that will be in the scripts. + $memory = $this->option('memory'); + + $connection = $this->argument('connection'); + + $this->worker->pop($connection, $queue, $delay, $memory, $this->option('sleep'), $this->option('tries')); + } + + /** + * Determine if the worker should run in maintenance mode. + * + * @return bool + */ + protected function downForMaintenance() + { + if ($this->option('force')) return false; + + return $this->laravel->isDownForMaintenance(); + } + + /** + * Get the console command arguments. + * + * @return array + */ + protected function getArguments() + { + return array( + array('connection', InputArgument::OPTIONAL, 'The name of connection', null), + ); + } + + /** + * Get the console command options. + * + * @return array + */ + protected function getOptions() + { + return array( + array('queue', null, InputOption::VALUE_OPTIONAL, 'The queue to listen on'), + + array('delay', null, InputOption::VALUE_OPTIONAL, 'Amount of time to delay failed jobs', 0), + + array('force', null, InputOption::VALUE_NONE, 'Force the worker to run even in maintenance mode'), + + array('memory', null, InputOption::VALUE_OPTIONAL, 'The memory limit in megabytes', 128), + + array('sleep', null, InputOption::VALUE_OPTIONAL, 'Number of seconds to sleep when no job is available', 3), + + array('tries', null, InputOption::VALUE_OPTIONAL, 'Number of times to attempt a job before logging it failed', 0), + ); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Queue/Console/stubs/failed_jobs.stub b/vendor/laravel/framework/src/Illuminate/Queue/Console/stubs/failed_jobs.stub new file mode 100755 index 0000000..61efc17 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Queue/Console/stubs/failed_jobs.stub @@ -0,0 +1,35 @@ +increments('id'); + $table->text('connection'); + $table->text('queue'); + $table->text('payload'); + $table->timestamp('failed_at'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::drop('failed_jobs'); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Queue/FailConsoleServiceProvider.php b/vendor/laravel/framework/src/Illuminate/Queue/FailConsoleServiceProvider.php new file mode 100755 index 0000000..92447f3 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Queue/FailConsoleServiceProvider.php @@ -0,0 +1,69 @@ +app->bindShared('command.queue.failed', function($app) + { + return new ListFailedCommand; + }); + + $this->app->bindShared('command.queue.retry', function($app) + { + return new RetryCommand; + }); + + $this->app->bindShared('command.queue.forget', function($app) + { + return new ForgetFailedCommand; + }); + + $this->app->bindShared('command.queue.flush', function($app) + { + return new FlushFailedCommand; + }); + + $this->app->bindShared('command.queue.failed-table', function($app) + { + return new FailedTableCommand($app['files']); + }); + + $this->commands( + 'command.queue.failed', 'command.queue.retry', 'command.queue.forget', + 'command.queue.flush', 'command.queue.failed-table' + ); + } + + /** + * Get the services provided by the provider. + * + * @return array + */ + public function provides() + { + return array( + 'command.queue.failed', 'command.queue.retry', 'command.queue.forget', 'command.queue.flush', 'command.queue.failed-table', + ); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Queue/Failed/DatabaseFailedJobProvider.php b/vendor/laravel/framework/src/Illuminate/Queue/Failed/DatabaseFailedJobProvider.php new file mode 100755 index 0000000..1fbf6f1 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Queue/Failed/DatabaseFailedJobProvider.php @@ -0,0 +1,111 @@ +table = $table; + $this->resolver = $resolver; + $this->database = $database; + } + + /** + * Log a failed job into storage. + * + * @param string $connection + * @param string $queue + * @param string $payload + * @return void + */ + public function log($connection, $queue, $payload) + { + $failed_at = Carbon::now(); + + $this->getTable()->insert(compact('connection', 'queue', 'payload', 'failed_at')); + } + + /** + * Get a list of all of the failed jobs. + * + * @return array + */ + public function all() + { + return $this->getTable()->orderBy('id', 'desc')->get(); + } + + /** + * Get a single failed job. + * + * @param mixed $id + * @return array + */ + public function find($id) + { + return $this->getTable()->find($id); + } + + /** + * Delete a single failed job from storage. + * + * @param mixed $id + * @return bool + */ + public function forget($id) + { + return $this->getTable()->where('id', $id)->delete() > 0; + } + + /** + * Flush all of the failed jobs from storage. + * + * @return void + */ + public function flush() + { + $this->getTable()->delete(); + } + + /** + * Get a new query builder instance for the table. + * + * @return \Illuminate\Database\Query\Builder + */ + protected function getTable() + { + return $this->resolver->connection($this->database)->table($this->table); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Queue/Failed/FailedJobProviderInterface.php b/vendor/laravel/framework/src/Illuminate/Queue/Failed/FailedJobProviderInterface.php new file mode 100755 index 0000000..7db652e --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Queue/Failed/FailedJobProviderInterface.php @@ -0,0 +1,45 @@ +iron = $iron; + $this->crypt = $crypt; + $this->request = $request; + $this->default = $default; + } + + /** + * Push a new job onto the queue. + * + * @param string $job + * @param mixed $data + * @param string $queue + * @return mixed + */ + public function push($job, $data = '', $queue = null) + { + return $this->pushRaw($this->createPayload($job, $data, $queue), $queue); + } + + /** + * Push a raw payload onto the queue. + * + * @param string $payload + * @param string $queue + * @param array $options + * @return mixed + */ + public function pushRaw($payload, $queue = null, array $options = array()) + { + $payload = $this->crypt->encrypt($payload); + + return $this->iron->postMessage($this->getQueue($queue), $payload, $options)->id; + } + + /** + * Push a raw payload onto the queue after encrypting the payload. + * + * @param string $payload + * @param string $queue + * @param int $delay + * @return mixed + */ + public function recreate($payload, $queue = null, $delay) + { + $options = array('delay' => $this->getSeconds($delay)); + + return $this->pushRaw($payload, $queue, $options); + } + + /** + * Push a new job onto the queue after a delay. + * + * @param \DateTime|int $delay + * @param string $job + * @param mixed $data + * @param string $queue + * @return mixed + */ + public function later($delay, $job, $data = '', $queue = null) + { + $delay = $this->getSeconds($delay); + + $payload = $this->createPayload($job, $data, $queue); + + return $this->pushRaw($payload, $this->getQueue($queue), compact('delay')); + } + + /** + * Pop the next job off of the queue. + * + * @param string $queue + * @return \Illuminate\Queue\Jobs\Job|null + */ + public function pop($queue = null) + { + $queue = $this->getQueue($queue); + + $job = $this->iron->getMessage($queue); + + // If we were able to pop a message off of the queue, we will need to decrypt + // the message body, as all Iron.io messages are encrypted, since the push + // queues will be a security hazard to unsuspecting developers using it. + if ( ! is_null($job)) + { + $job->body = $this->crypt->decrypt($job->body); + + return new IronJob($this->container, $this, $job); + } + } + + /** + * Delete a message from the Iron queue. + * + * @param string $queue + * @param string $id + * @return void + */ + public function deleteMessage($queue, $id) + { + $this->iron->deleteMessage($queue, $id); + } + + /** + * Marshal a push queue request and fire the job. + * + * @return \Illuminate\Http\Response + */ + public function marshal() + { + $this->createPushedIronJob($this->marshalPushedJob())->fire(); + + return new Response('OK'); + } + + /** + * Marshal out the pushed job and payload. + * + * @return object + */ + protected function marshalPushedJob() + { + $r = $this->request; + + $body = $this->crypt->decrypt($r->getContent()); + + return (object) array( + 'id' => $r->header('iron-message-id'), 'body' => $body, 'pushed' => true, + ); + } + + /** + * Create a new IronJob for a pushed job. + * + * @param object $job + * @return \Illuminate\Queue\Jobs\IronJob + */ + protected function createPushedIronJob($job) + { + return new IronJob($this->container, $this, $job, true); + } + + /** + * Create a payload string from the given job and data. + * + * @param string $job + * @param mixed $data + * @param string $queue + * @return string + */ + protected function createPayload($job, $data = '', $queue = null) + { + $payload = $this->setMeta(parent::createPayload($job, $data), 'attempts', 1); + + return $this->setMeta($payload, 'queue', $this->getQueue($queue)); + } + + /** + * Get the queue or return the default. + * + * @param string|null $queue + * @return string + */ + public function getQueue($queue) + { + return $queue ?: $this->default; + } + + /** + * Get the underlying IronMQ instance. + * + * @return IronMQ + */ + public function getIron() + { + return $this->iron; + } + + /** + * Get the request instance. + * + * @return \Symfony\Component\HttpFoundation\Request + */ + public function getRequest() + { + return $this->request; + } + + /** + * Set the request instance. + * + * @param \Symfony\Component\HttpFoundation\Request $request + * @return void + */ + public function setRequest(Request $request) + { + $this->request = $request; + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Queue/Jobs/BeanstalkdJob.php b/vendor/laravel/framework/src/Illuminate/Queue/Jobs/BeanstalkdJob.php new file mode 100755 index 0000000..1ff7b34 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Queue/Jobs/BeanstalkdJob.php @@ -0,0 +1,150 @@ +job = $job; + $this->queue = $queue; + $this->container = $container; + $this->pheanstalk = $pheanstalk; + } + + /** + * Fire the job. + * + * @return void + */ + public function fire() + { + $this->resolveAndFire(json_decode($this->getRawBody(), true)); + } + + /** + * Get the raw body string for the job. + * + * @return string + */ + public function getRawBody() + { + return $this->job->getData(); + } + + /** + * Delete the job from the queue. + * + * @return void + */ + public function delete() + { + parent::delete(); + + $this->pheanstalk->delete($this->job); + } + + /** + * Release the job back into the queue. + * + * @param int $delay + * @return void + */ + public function release($delay = 0) + { + $priority = Pheanstalk::DEFAULT_PRIORITY; + + $this->pheanstalk->release($this->job, $priority, $delay); + } + + /** + * Bury the job in the queue. + * + * @return void + */ + public function bury() + { + $this->pheanstalk->bury($this->job); + } + + /** + * Get the number of times the job has been attempted. + * + * @return int + */ + public function attempts() + { + $stats = $this->pheanstalk->statsJob($this->job); + + return (int) $stats->reserves; + } + + /** + * Get the job identifier. + * + * @return string + */ + public function getJobId() + { + return $this->job->getId(); + } + + /** + * Get the IoC container instance. + * + * @return \Illuminate\Container\Container + */ + public function getContainer() + { + return $this->container; + } + + /** + * Get the underlying Pheanstalk instance. + * + * @return Pheanstalk + */ + public function getPheanstalk() + { + return $this->pheanstalk; + } + + /** + * Get the underlying Pheanstalk job. + * + * @return Pheanstalk_Job + */ + public function getPheanstalkJob() + { + return $this->job; + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Queue/Jobs/IronJob.php b/vendor/laravel/framework/src/Illuminate/Queue/Jobs/IronJob.php new file mode 100755 index 0000000..99b2ba4 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Queue/Jobs/IronJob.php @@ -0,0 +1,172 @@ +job = $job; + $this->iron = $iron; + $this->pushed = $pushed; + $this->container = $container; + } + + /** + * Fire the job. + * + * @return void + */ + public function fire() + { + $this->resolveAndFire(json_decode($this->getRawBody(), true)); + } + + /** + * Get the raw body string for the job. + * + * @return string + */ + public function getRawBody() + { + return $this->job->body; + } + + /** + * Delete the job from the queue. + * + * @return void + */ + public function delete() + { + parent::delete(); + + if (isset($this->job->pushed)) return; + + $this->iron->deleteMessage($this->getQueue(), $this->job->id); + } + + /** + * Release the job back into the queue. + * + * @param int $delay + * @return void + */ + public function release($delay = 0) + { + if ( ! $this->pushed) $this->delete(); + + $this->recreateJob($delay); + } + + /** + * Release a pushed job back onto the queue. + * + * @param int $delay + * @return void + */ + protected function recreateJob($delay) + { + $payload = json_decode($this->job->body, true); + + array_set($payload, 'attempts', array_get($payload, 'attempts', 1) + 1); + + $this->iron->recreate(json_encode($payload), $this->getQueue(), $delay); + } + + /** + * Get the number of times the job has been attempted. + * + * @return int + */ + public function attempts() + { + return array_get(json_decode($this->job->body, true), 'attempts', 1); + } + + /** + * Get the job identifier. + * + * @return string + */ + public function getJobId() + { + return $this->job->id; + } + + /** + * Get the IoC container instance. + * + * @return \Illuminate\Container\Container + */ + public function getContainer() + { + return $this->container; + } + + /** + * Get the underlying Iron queue instance. + * + * @return \Illuminate\Queue\IronQueue + */ + public function getIron() + { + return $this->iron; + } + + /** + * Get the underlying IronMQ job. + * + * @return array + */ + public function getIronJob() + { + return $this->job; + } + + /** + * Get the name of the queue the job belongs to. + * + * @return string + */ + public function getQueue() + { + return array_get(json_decode($this->job->body, true), 'queue'); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Queue/Jobs/Job.php b/vendor/laravel/framework/src/Illuminate/Queue/Jobs/Job.php new file mode 100755 index 0000000..491fe88 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Queue/Jobs/Job.php @@ -0,0 +1,161 @@ +deleted = true; + } + + /** + * Determine if the job has been deleted. + * + * @return bool + */ + public function isDeleted() + { + return $this->deleted; + } + + /** + * Release the job back into the queue. + * + * @param int $delay + * @return void + */ + abstract public function release($delay = 0); + + /** + * Get the number of times the job has been attempted. + * + * @return int + */ + abstract public function attempts(); + + /** + * Get the raw body string for the job. + * + * @return string + */ + abstract public function getRawBody(); + + /** + * Resolve and fire the job handler method. + * + * @param array $payload + * @return void + */ + protected function resolveAndFire(array $payload) + { + list($class, $method) = $this->parseJob($payload['job']); + + $this->instance = $this->resolve($class); + + $this->instance->{$method}($this, $payload['data']); + } + + /** + * Resolve the given job handler. + * + * @param string $class + * @return mixed + */ + protected function resolve($class) + { + return $this->container->make($class); + } + + /** + * Parse the job declaration into class and method. + * + * @param string $job + * @return array + */ + protected function parseJob($job) + { + $segments = explode('@', $job); + + return count($segments) > 1 ? $segments : array($segments[0], 'fire'); + } + + /** + * Determine if job should be auto-deleted. + * + * @return bool + */ + public function autoDelete() + { + return isset($this->instance->delete); + } + + /** + * Calculate the number of seconds with the given delay. + * + * @param \DateTime|int $delay + * @return int + */ + protected function getSeconds($delay) + { + if ($delay instanceof DateTime) + { + return max(0, $delay->getTimestamp() - $this->getTime()); + } + else + { + return intval($delay); + } + } + + /** + * Get the name of the queue the job belongs to. + * + * @return string + */ + public function getQueue() + { + return $this->queue; + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Queue/Jobs/RedisJob.php b/vendor/laravel/framework/src/Illuminate/Queue/Jobs/RedisJob.php new file mode 100755 index 0000000..93fba74 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Queue/Jobs/RedisJob.php @@ -0,0 +1,134 @@ +job = $job; + $this->redis = $redis; + $this->queue = $queue; + $this->container = $container; + } + + /** + * Fire the job. + * + * @return void + */ + public function fire() + { + $this->resolveAndFire(json_decode($this->getRawBody(), true)); + } + + /** + * Get the raw body string for the job. + * + * @return string + */ + public function getRawBody() + { + return $this->job; + } + + /** + * Delete the job from the queue. + * + * @return void + */ + public function delete() + { + parent::delete(); + + $this->redis->deleteReserved($this->queue, $this->job); + } + + /** + * Release the job back into the queue. + * + * @param int $delay + * @return void + */ + public function release($delay = 0) + { + $this->delete(); + + $this->redis->release($this->queue, $this->job, $delay, $this->attempts() + 1); + } + + /** + * Get the number of times the job has been attempted. + * + * @return int + */ + public function attempts() + { + return array_get(json_decode($this->job, true), 'attempts'); + } + + /** + * Get the job identifier. + * + * @return string + */ + public function getJobId() + { + return array_get(json_decode($this->job, true), 'id'); + } + + /** + * Get the IoC container instance. + * + * @return \Illuminate\Container\Container + */ + public function getContainer() + { + return $this->container; + } + + /** + * Get the underlying queue driver instance. + * + * @return \Illuminate\Redis\Database + */ + public function getRedisQueue() + { + return $this->redis; + } + + /** + * Get the underlying Redis job. + * + * @return string + */ + public function getRedisJob() + { + return $this->job; + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Queue/Jobs/SqsJob.php b/vendor/laravel/framework/src/Illuminate/Queue/Jobs/SqsJob.php new file mode 100755 index 0000000..0e666bd --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Queue/Jobs/SqsJob.php @@ -0,0 +1,139 @@ +sqs = $sqs; + $this->job = $job; + $this->queue = $queue; + $this->container = $container; + } + + /** + * Fire the job. + * + * @return void + */ + public function fire() + { + $this->resolveAndFire(json_decode($this->getRawBody(), true)); + } + + /** + * Get the raw body string for the job. + * + * @return string + */ + public function getRawBody() + { + return $this->job['Body']; + } + + /** + * Delete the job from the queue. + * + * @return void + */ + public function delete() + { + parent::delete(); + + $this->sqs->deleteMessage(array( + + 'QueueUrl' => $this->queue, 'ReceiptHandle' => $this->job['ReceiptHandle'], + + )); + } + + /** + * Release the job back into the queue. + * + * @param int $delay + * @return void + */ + public function release($delay = 0) + { + // SQS job releases are handled by the server configuration... + } + + /** + * Get the number of times the job has been attempted. + * + * @return int + */ + public function attempts() + { + return (int) $this->job['Attributes']['ApproximateReceiveCount']; + } + + /** + * Get the job identifier. + * + * @return string + */ + public function getJobId() + { + return $this->job['MessageId']; + } + + /** + * Get the IoC container instance. + * + * @return \Illuminate\Container\Container + */ + public function getContainer() + { + return $this->container; + } + + /** + * Get the underlying SQS client instance. + * + * @return \Aws\Sqs\SqsClient + */ + public function getSqs() + { + return $this->sqs; + } + + /** + * Get the underlying raw SQS job. + * + * @return array + */ + public function getSqsJob() + { + return $this->job; + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Queue/Jobs/SyncJob.php b/vendor/laravel/framework/src/Illuminate/Queue/Jobs/SyncJob.php new file mode 100755 index 0000000..c574005 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Queue/Jobs/SyncJob.php @@ -0,0 +1,107 @@ +job = $job; + $this->data = $data; + $this->container = $container; + } + + /** + * Fire the job. + * + * @return void + */ + public function fire() + { + $data = json_decode($this->data, true); + + if ($this->job instanceof Closure) + { + call_user_func($this->job, $this, $data); + } + else + { + $this->resolveAndFire(array('job' => $this->job, 'data' => $data)); + } + } + + /** + * Get the raw body string for the job. + * + * @return string + */ + public function getRawBody() + { + // + } + + /** + * Delete the job from the queue. + * + * @return void + */ + public function delete() + { + parent::delete(); + } + + /** + * Release the job back into the queue. + * + * @param int $delay + * @return void + */ + public function release($delay = 0) + { + // + } + + /** + * Get the number of times the job has been attempted. + * + * @return int + */ + public function attempts() + { + return 1; + } + + /** + * Get the job identifier. + * + * @return string + */ + public function getJobId() + { + return ''; + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Queue/Listener.php b/vendor/laravel/framework/src/Illuminate/Queue/Listener.php new file mode 100755 index 0000000..8057e4b --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Queue/Listener.php @@ -0,0 +1,202 @@ +commandPath = $commandPath; + $this->environment = $environment; + } + + /** + * Listen to the given queue connection. + * + * @param string $connection + * @param string $queue + * @param string $delay + * @param string $memory + * @param int $timeout + * @return void + */ + public function listen($connection, $queue, $delay, $memory, $timeout = 60) + { + $process = $this->makeProcess($connection, $queue, $delay, $memory, $timeout); + + while(true) + { + $this->runProcess($process, $memory); + } + } + + /** + * Run the given process. + * + * @param \Symfony\Component\Process\Process $process + * @param int $memory + * @return void + */ + public function runProcess(Process $process, $memory) + { + $process->run(); + + // Once we have run the job we'll go check if the memory limit has been + // exceeded for the script. If it has, we will kill this script so a + // process managers will restart this with a clean slate of memory. + if ($this->memoryExceeded($memory)) + { + $this->stop(); return; + } + } + + /** + * Create a new Symfony process for the worker. + * + * @param string $connection + * @param string $queue + * @param int $delay + * @param int $memory + * @param int $timeout + * @return \Symfony\Component\Process\Process + */ + public function makeProcess($connection, $queue, $delay, $memory, $timeout) + { + $string = $this->workerCommand; + + // If the environment is set, we will append it to the command string so the + // workers will run under the specified environment. Otherwise, they will + // just run under the production environment which is not always right. + if (isset($this->environment)) + { + $string .= ' --env='.$this->environment; + } + + // Next, we will just format out the worker commands with all of the various + // options available for the command. This will produce the final command + // line that we will pass into a Symfony process object for processing. + $command = sprintf( + $string, $connection, $queue, $delay, + $memory, $this->sleep, $this->maxTries + ); + + return new Process($command, $this->commandPath, null, null, $timeout); + } + + /** + * Determine if the memory limit has been exceeded. + * + * @param int $memoryLimit + * @return bool + */ + public function memoryExceeded($memoryLimit) + { + return (memory_get_usage() / 1024 / 1024) >= $memoryLimit; + } + + /** + * Stop listening and bail out of the script. + * + * @return void + */ + public function stop() + { + die; + } + + /** + * Get the current listener environment. + * + * @return string + */ + public function getEnvironment() + { + return $this->environment; + } + + /** + * Set the current environment. + * + * @param string $environment + * @return void + */ + public function setEnvironment($environment) + { + $this->environment = $environment; + } + + /** + * Get the amount of seconds to wait before polling the queue. + * + * @return int + */ + public function getSleep() + { + return $this->sleep; + } + + /** + * Set the amount of seconds to wait before polling the queue. + * + * @param int $sleep + * @return void + */ + public function setSleep($sleep) + { + $this->sleep = $sleep; + } + + /** + * Set the amount of times to try a job before logging it failed. + * + * @param int $tries + * @return void + */ + public function setMaxTries($tries) + { + $this->maxTries = $tries; + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Queue/Queue.php b/vendor/laravel/framework/src/Illuminate/Queue/Queue.php new file mode 100755 index 0000000..1214848 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Queue/Queue.php @@ -0,0 +1,131 @@ +push($job, $data, $queue); + } + } + + /** + * Create a payload string from the given job and data. + * + * @param string $job + * @param mixed $data + * @param string $queue + * @return string + */ + protected function createPayload($job, $data = '', $queue = null) + { + if ($job instanceof Closure) + { + return json_encode($this->createClosurePayload($job, $data)); + } + else + { + return json_encode(array('job' => $job, 'data' => $data)); + } + } + + /** + * Create a payload string for the given Closure job. + * + * @param \Closure $job + * @param mixed $data + * @return string + */ + protected function createClosurePayload($job, $data) + { + $closure = serialize(new SerializableClosure($job)); + + return array('job' => 'IlluminateQueueClosure', 'data' => compact('closure')); + } + + /** + * Set additional meta on a payload string. + * + * @param string $payload + * @param string $key + * @param string $value + * @return string + */ + protected function setMeta($payload, $key, $value) + { + $payload = json_decode($payload, true); + + return json_encode(array_set($payload, $key, $value)); + } + + /** + * Calculate the number of seconds with the given delay. + * + * @param \DateTime|int $delay + * @return int + */ + protected function getSeconds($delay) + { + if ($delay instanceof DateTime) + { + return max(0, $delay->getTimestamp() - $this->getTime()); + } + else + { + return intval($delay); + } + } + + /** + * Get the current UNIX timestamp. + * + * @return int + */ + public function getTime() + { + return time(); + } + + /** + * Set the IoC container instance. + * + * @param \Illuminate\Container\Container $container + * @return void + */ + public function setContainer(Container $container) + { + $this->container = $container; + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Queue/QueueInterface.php b/vendor/laravel/framework/src/Illuminate/Queue/QueueInterface.php new file mode 100755 index 0000000..69f9241 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Queue/QueueInterface.php @@ -0,0 +1,44 @@ +app = $app; + } + + /** + * Register an event listener for the failed job event. + * + * @param mixed $callback + * @return void + */ + public function failing($callback) + { + $this->app['events']->listen('illuminate.queue.failed', $callback); + } + + /** + * Determine if the driver is connected. + * + * @param string $name + * @return bool + */ + public function connected($name = null) + { + return isset($this->connections[$name ?: $this->getDefaultDriver()]); + } + + /** + * Resolve a queue connection instance. + * + * @param string $name + * @return \Illuminate\Queue\QueueInterface + */ + public function connection($name = null) + { + $name = $name ?: $this->getDefaultDriver(); + + // If the connection has not been resolved yet we will resolve it now as all + // of the connections are resolved when they are actually needed so we do + // not make any unnecessary connection to the various queue end-points. + if ( ! isset($this->connections[$name])) + { + $this->connections[$name] = $this->resolve($name); + + $this->connections[$name]->setContainer($this->app); + } + + return $this->connections[$name]; + } + + /** + * Resolve a queue connection. + * + * @param string $name + * @return \Illuminate\Queue\QueueInterface + */ + protected function resolve($name) + { + $config = $this->getConfig($name); + + return $this->getConnector($config['driver'])->connect($config); + } + + /** + * Get the connector for a given driver. + * + * @param string $driver + * @return \Illuminate\Queue\Connectors\ConnectorInterface + * + * @throws \InvalidArgumentException + */ + protected function getConnector($driver) + { + if (isset($this->connectors[$driver])) + { + return call_user_func($this->connectors[$driver]); + } + + throw new \InvalidArgumentException("No connector for [$driver]"); + } + + /** + * Add a queue connection resolver. + * + * @param string $driver + * @param Closure $resolver + * @return void + */ + public function extend($driver, Closure $resolver) + { + return $this->addConnector($driver, $resolver); + } + + /** + * Add a queue connection resolver. + * + * @param string $driver + * @param Closure $resolver + * @return void + */ + public function addConnector($driver, Closure $resolver) + { + $this->connectors[$driver] = $resolver; + } + + /** + * Get the queue connection configuration. + * + * @param string $name + * @return array + */ + protected function getConfig($name) + { + return $this->app['config']["queue.connections.{$name}"]; + } + + /** + * Get the name of the default queue connection. + * + * @return string + */ + public function getDefaultDriver() + { + return $this->app['config']['queue.default']; + } + + /** + * Set the name of the default queue connection. + * + * @param string $name + * @return void + */ + public function setDefaultDriver($name) + { + $this->app['config']['queue.default'] = $name; + } + + /** + * Get the full name for the given connection. + * + * @param string $connection + * @return string + */ + public function getName($connection = null) + { + return $connection ?: $this->getDefaultDriver(); + } + + /** + * Dynamically pass calls to the default connection. + * + * @param string $method + * @param array $parameters + * @return mixed + */ + public function __call($method, $parameters) + { + $callable = array($this->connection(), $method); + + return call_user_func_array($callable, $parameters); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Queue/QueueServiceProvider.php b/vendor/laravel/framework/src/Illuminate/Queue/QueueServiceProvider.php new file mode 100755 index 0000000..cfc83e9 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Queue/QueueServiceProvider.php @@ -0,0 +1,272 @@ +registerManager(); + + $this->registerWorker(); + + $this->registerListener(); + + $this->registerSubscriber(); + + $this->registerFailedJobServices(); + } + + /** + * Register the queue manager. + * + * @return void + */ + protected function registerManager() + { + $me = $this; + + $this->app->bindShared('queue', function($app) use ($me) + { + // Once we have an instance of the queue manager, we will register the various + // resolvers for the queue connectors. These connectors are responsible for + // creating the classes that accept queue configs and instantiate queues. + $manager = new QueueManager($app); + + $me->registerConnectors($manager); + + return $manager; + }); + } + + /** + * Register the queue worker. + * + * @return void + */ + protected function registerWorker() + { + $this->registerWorkCommand(); + + $this->app->bindShared('queue.worker', function($app) + { + return new Worker($app['queue'], $app['queue.failer'], $app['events']); + }); + } + + /** + * Register the queue worker console command. + * + * @return void + */ + protected function registerWorkCommand() + { + $this->app->bindShared('command.queue.work', function($app) + { + return new WorkCommand($app['queue.worker']); + }); + + $this->commands('command.queue.work'); + } + + /** + * Register the queue listener. + * + * @return void + */ + protected function registerListener() + { + $this->registerListenCommand(); + + $this->app->bindShared('queue.listener', function($app) + { + return new Listener($app['path.base']); + }); + } + + /** + * Register the queue listener console command. + * + * @return void + */ + protected function registerListenCommand() + { + $this->app->bindShared('command.queue.listen', function($app) + { + return new ListenCommand($app['queue.listener']); + }); + + $this->commands('command.queue.listen'); + } + + /** + * Register the push queue subscribe command. + * + * @return void + */ + protected function registerSubscriber() + { + $this->app->bindShared('command.queue.subscribe', function($app) + { + return new SubscribeCommand; + }); + + $this->commands('command.queue.subscribe'); + } + + /** + * Register the connectors on the queue manager. + * + * @param \Illuminate\Queue\QueueManager $manager + * @return void + */ + public function registerConnectors($manager) + { + foreach (array('Sync', 'Beanstalkd', 'Redis', 'Sqs', 'Iron') as $connector) + { + $this->{"register{$connector}Connector"}($manager); + } + } + + /** + * Register the Sync queue connector. + * + * @param \Illuminate\Queue\QueueManager $manager + * @return void + */ + protected function registerSyncConnector($manager) + { + $manager->addConnector('sync', function() + { + return new SyncConnector; + }); + } + + /** + * Register the Beanstalkd queue connector. + * + * @param \Illuminate\Queue\QueueManager $manager + * @return void + */ + protected function registerBeanstalkdConnector($manager) + { + $manager->addConnector('beanstalkd', function() + { + return new BeanstalkdConnector; + }); + } + + /** + * Register the Redis queue connector. + * + * @param \Illuminate\Queue\QueueManager $manager + * @return void + */ + protected function registerRedisConnector($manager) + { + $app = $this->app; + + $manager->addConnector('redis', function() use ($app) + { + return new RedisConnector($app['redis']); + }); + } + + /** + * Register the Amazon SQS queue connector. + * + * @param \Illuminate\Queue\QueueManager $manager + * @return void + */ + protected function registerSqsConnector($manager) + { + $manager->addConnector('sqs', function() + { + return new SqsConnector; + }); + } + + /** + * Register the IronMQ queue connector. + * + * @param \Illuminate\Queue\QueueManager $manager + * @return void + */ + protected function registerIronConnector($manager) + { + $app = $this->app; + + $manager->addConnector('iron', function() use ($app) + { + return new IronConnector($app['encrypter'], $app['request']); + }); + + $this->registerIronRequestBinder(); + } + + /** + * Register the request rebinding event for the Iron queue. + * + * @return void + */ + protected function registerIronRequestBinder() + { + $this->app->rebinding('request', function($app, $request) + { + if ($app['queue']->connected('iron')) + { + $app['queue']->connection('iron')->setRequest($request); + } + }); + } + + /** + * Register the failed job services. + * + * @return void + */ + protected function registerFailedJobServices() + { + $this->app->bindShared('queue.failer', function($app) + { + $config = $app['config']['queue.failed']; + + return new DatabaseFailedJobProvider($app['db'], $config['database'], $config['table']); + }); + } + + /** + * Get the services provided by the provider. + * + * @return array + */ + public function provides() + { + return array( + 'queue', 'queue.worker', 'queue.listener', 'queue.failer', + 'command.queue.work', 'command.queue.listen', 'command.queue.subscribe' + ); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Queue/README.md b/vendor/laravel/framework/src/Illuminate/Queue/README.md new file mode 100755 index 0000000..e6a715b --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Queue/README.md @@ -0,0 +1,34 @@ +## Illuminate Queue + +The Laravel Queue component provides a unified API across a variety of different queue services. Queues allow you to defer the processing of a time consuming task, such as sending an e-mail, until a later time, thus drastically speeding up the web requests to your application. + +### Usage Instructions + +First, create a new Queue `Capsule` manager instance. Similar to the "Capsule" provided for the Eloquent ORM, the queue Capsule aims to make configuring the library for usage outside of the Laravel framework as easy as possible. + +```PHP +use Illuminate\Queue\Capsule\Manager as Queue; + +$queue = new Queue; + +$queue->addConnection([ + 'driver' => 'beanstalkd', + 'host' => 'localhost', + 'queue' => 'default', +]); + +// Make this Capsule instance available globally via static methods... (optional) +$queue->setAsGlobal(); +``` + +Once the Capsule instance has been registered. You may use it like so: + +```PHP +// As an instance... +$queue->push('SendEmail', array('message' => $message)); + +// If setAsGlobal has been called... +Queue::push('SendEmail', array('message' => $message)); +``` + +For further documentation on using the queue, consult the [Laravel framework documentation](http://laravel.com/docs). diff --git a/vendor/laravel/framework/src/Illuminate/Queue/RedisQueue.php b/vendor/laravel/framework/src/Illuminate/Queue/RedisQueue.php new file mode 100755 index 0000000..bfce401 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Queue/RedisQueue.php @@ -0,0 +1,246 @@ +redis = $redis; + $this->default = $default; + $this->connection = $connection; + } + + /** + * Push a new job onto the queue. + * + * @param string $job + * @param mixed $data + * @param string $queue + * @return void + */ + public function push($job, $data = '', $queue = null) + { + return $this->pushRaw($this->createPayload($job, $data), $queue); + } + + /** + * Push a raw payload onto the queue. + * + * @param string $payload + * @param string $queue + * @param array $options + * @return mixed + */ + public function pushRaw($payload, $queue = null, array $options = array()) + { + $this->redis->rpush($this->getQueue($queue), $payload); + + return array_get(json_decode($payload, true), 'id'); + } + + /** + * Push a new job onto the queue after a delay. + * + * @param \DateTime|int $delay + * @param string $job + * @param mixed $data + * @param string $queue + * @return void + */ + public function later($delay, $job, $data = '', $queue = null) + { + $payload = $this->createPayload($job, $data); + + $delay = $this->getSeconds($delay); + + $this->redis->zadd($this->getQueue($queue).':delayed', $this->getTime() + $delay, $payload); + + return array_get(json_decode($payload, true), 'id'); + } + + /** + * Release a reserved job back onto the queue. + * + * @param string $queue + * @param string $payload + * @param int $delay + * @param int $attempts + * @return void + */ + public function release($queue, $payload, $delay, $attempts) + { + $payload = $this->setMeta($payload, 'attempts', $attempts); + + $this->redis->zadd($this->getQueue($queue).':delayed', $this->getTime() + $delay, $payload); + } + + /** + * Pop the next job off of the queue. + * + * @param string $queue + * @return \Illuminate\Queue\Jobs\Job|null + */ + public function pop($queue = null) + { + $original = $queue ?: $this->default; + + $this->migrateAllExpiredJobs($queue = $this->getQueue($queue)); + + $job = $this->redis->lpop($queue); + + if ( ! is_null($job)) + { + $this->redis->zadd($queue.':reserved', $this->getTime() + 60, $job); + + return new RedisJob($this->container, $this, $job, $original); + } + } + + /** + * Delete a reserved job from the queue. + * + * @param string $queue + * @param string $job + * @return void + */ + public function deleteReserved($queue, $job) + { + $this->redis->zrem($this->getQueue($queue).':reserved', $job); + } + + /** + * Migrate all of the waiting jobs in the queue. + * + * @param string $queue + * @return void + */ + protected function migrateAllExpiredJobs($queue) + { + $this->migrateExpiredJobs($queue.':delayed', $queue); + + $this->migrateExpiredJobs($queue.':reserved', $queue); + } + + /** + * Migrate the delayed jobs that are ready to the regular queue. + * + * @param string $from + * @param string $to + * @return void + */ + public function migrateExpiredJobs($from, $to) + { + $jobs = $this->getExpiredJobs($from, $time = $this->getTime()); + + if (count($jobs) > 0) + { + $this->removeExpiredJobs($from, $time); + + call_user_func_array(array($this->redis, 'rpush'), array_merge(array($to), $jobs)); + } + } + + /** + * Get the delayed jobs that are ready. + * + * @param string $queue + * @param int $time + * @return array + */ + protected function getExpiredJobs($queue, $time) + { + return $this->redis->zrangebyscore($queue, '-inf', $time); + } + + /** + * Remove the delayed jobs that are ready for processing. + * + * @param string $queue + * @param int $time + * @return void + */ + protected function removeExpiredJobs($queue, $time) + { + $this->redis->zremrangebyscore($queue, '-inf', $time); + } + + /** + * Create a payload string from the given job and data. + * + * @param string $job + * @param mixed $data + * @param string $queue + * @return string + */ + protected function createPayload($job, $data = '', $queue = null) + { + $payload = parent::createPayload($job, $data); + + $payload = $this->setMeta($payload, 'id', $this->getRandomId()); + + return $this->setMeta($payload, 'attempts', 1); + } + + /** + * Get a random ID string. + * + * @return string + */ + protected function getRandomId() + { + return str_random(20); + } + + /** + * Get the queue or return the default. + * + * @param string|null $queue + * @return string + */ + protected function getQueue($queue) + { + return 'queues:'.($queue ?: $this->default); + } + + /** + * Get the underlying Redis instance. + * + * @return \Illuminate\Redis\Database + */ + public function getRedis() + { + return $this->redis; + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Queue/SqsQueue.php b/vendor/laravel/framework/src/Illuminate/Queue/SqsQueue.php new file mode 100755 index 0000000..e78fb60 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Queue/SqsQueue.php @@ -0,0 +1,126 @@ +sqs = $sqs; + $this->default = $default; + } + + /** + * Push a new job onto the queue. + * + * @param string $job + * @param mixed $data + * @param string $queue + * @return mixed + */ + public function push($job, $data = '', $queue = null) + { + return $this->pushRaw($this->createPayload($job, $data), $queue); + } + + /** + * Push a raw payload onto the queue. + * + * @param string $payload + * @param string $queue + * @param array $options + * @return mixed + */ + public function pushRaw($payload, $queue = null, array $options = array()) + { + $response = $this->sqs->sendMessage(array('QueueUrl' => $this->getQueue($queue), 'MessageBody' => $payload)); + + return $response->get('MessageId'); + } + + /** + * Push a new job onto the queue after a delay. + * + * @param \DateTime|int $delay + * @param string $job + * @param mixed $data + * @param string $queue + * @return mixed + */ + public function later($delay, $job, $data = '', $queue = null) + { + $payload = $this->createPayload($job, $data); + + $delay = $this->getSeconds($delay); + + return $this->sqs->sendMessage(array( + + 'QueueUrl' => $this->getQueue($queue), 'MessageBody' => $payload, 'DelaySeconds' => $delay, + + ))->get('MessageId'); + } + + /** + * Pop the next job off of the queue. + * + * @param string $queue + * @return \Illuminate\Queue\Jobs\Job|null + */ + public function pop($queue = null) + { + $queue = $this->getQueue($queue); + + $response = $this->sqs->receiveMessage( + array('QueueUrl' => $queue, 'AttributeNames' => array('ApproximateReceiveCount')) + ); + + if (count($response['Messages']) > 0) + { + return new SqsJob($this->container, $this->sqs, $queue, $response['Messages'][0]); + } + } + + /** + * Get the queue or return the default. + * + * @param string|null $queue + * @return string + */ + public function getQueue($queue) + { + return $queue ?: $this->default; + } + + /** + * Get the underlying SQS instance. + * + * @return \Aws\Sqs\SqsClient + */ + public function getSqs() + { + return $this->sqs; + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Queue/SyncQueue.php b/vendor/laravel/framework/src/Illuminate/Queue/SyncQueue.php new file mode 100755 index 0000000..8da5bab --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Queue/SyncQueue.php @@ -0,0 +1,67 @@ +resolveJob($job, json_encode($data))->fire(); + + return 0; + } + + /** + * Push a raw payload onto the queue. + * + * @param string $payload + * @param string $queue + * @param array $options + * @return mixed + */ + public function pushRaw($payload, $queue = null, array $options = array()) + { + // + } + + /** + * Push a new job onto the queue after a delay. + * + * @param \DateTime|int $delay + * @param string $job + * @param mixed $data + * @param string $queue + * @return mixed + */ + public function later($delay, $job, $data = '', $queue = null) + { + return $this->push($job, $data, $queue); + } + + /** + * Pop the next job off of the queue. + * + * @param string $queue + * @return \Illuminate\Queue\Jobs\Job|null + */ + public function pop($queue = null) {} + + /** + * Resolve a Sync job instance. + * + * @param string $job + * @param string $data + * @return \Illuminate\Queue\Jobs\SyncJob + */ + protected function resolveJob($job, $data) + { + return new Jobs\SyncJob($this->container, $job, $data); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Queue/Worker.php b/vendor/laravel/framework/src/Illuminate/Queue/Worker.php new file mode 100755 index 0000000..437dd4b --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Queue/Worker.php @@ -0,0 +1,203 @@ +failer = $failer; + $this->events = $events; + $this->manager = $manager; + } + + /** + * Listen to the given queue. + * + * @param string $connectionName + * @param string $queue + * @param int $delay + * @param int $memory + * @param int $sleep + * @param int $maxTries + * @return void + */ + public function pop($connectionName, $queue = null, $delay = 0, $memory = 128, $sleep = 3, $maxTries = 0) + { + $connection = $this->manager->connection($connectionName); + + $job = $this->getNextJob($connection, $queue); + + // If we're able to pull a job off of the stack, we will process it and + // then make sure we are not exceeding our memory limits for the run + // which is to protect against run-away memory leakages from here. + if ( ! is_null($job)) + { + $this->process( + $this->manager->getName($connectionName), $job, $maxTries, $delay + ); + } + else + { + $this->sleep($sleep); + } + } + + /** + * Get the next job from the queue connection. + * + * @param \Illuminate\Queue\Queue $connection + * @param string $queue + * @return \Illuminate\Queue\Jobs\Job|null + */ + protected function getNextJob($connection, $queue) + { + if (is_null($queue)) return $connection->pop(); + + foreach (explode(',', $queue) as $queue) + { + if ( ! is_null($job = $connection->pop($queue))) return $job; + } + } + + /** + * Process a given job from the queue. + * + * @param string $connection + * @param \Illuminate\Queue\Jobs\Job $job + * @param int $maxTries + * @param int $delay + * @return void + * + * @throws \Exception + */ + public function process($connection, Job $job, $maxTries = 0, $delay = 0) + { + if ($maxTries > 0 && $job->attempts() > $maxTries) + { + return $this->logFailedJob($connection, $job); + } + + try + { + // First we will fire off the job. Once it is done we will see if it will + // be auto-deleted after processing and if so we will go ahead and run + // the delete method on the job. Otherwise we will just keep moving. + $job->fire(); + + if ($job->autoDelete()) $job->delete(); + } + + catch (\Exception $e) + { + // If we catch an exception, we will attempt to release the job back onto + // the queue so it is not lost. This will let is be retried at a later + // time by another listener (or the same one). We will do that here. + if ( ! $job->isDeleted()) $job->release($delay); + + throw $e; + } + } + + /** + * Log a failed job into storage. + * + * @param string $connection + * @param \Illuminate\Queue\Jobs\Job $job + * @return void + */ + protected function logFailedJob($connection, Job $job) + { + if ($this->failer) + { + $this->failer->log($connection, $job->getQueue(), $job->getRawBody()); + + $job->delete(); + + $this->raiseFailedJobEvent($connection, $job); + } + } + + /** + * Raise the failed queue job event. + * + * @param string $connection + * @param \Illuminate\Queue\Jobs\Job $job + * @return void + */ + protected function raiseFailedJobEvent($connection, Job $job) + { + if ($this->events) + { + $data = json_decode($job->getRawBody(), true); + + $this->events->fire('illuminate.queue.failed', array($connection, $job, $data)); + } + } + + /** + * Sleep the script for a given number of seconds. + * + * @param int $seconds + * @return void + */ + public function sleep($seconds) + { + sleep($seconds); + } + + /** + * Get the queue manager instance. + * + * @return \Illuminate\Queue\QueueManager + */ + public function getManager() + { + return $this->manager; + } + + /** + * Set the queue manager instance. + * + * @param \Illuminate\Queue\QueueManager $manager + * @return void + */ + public function setManager(QueueManager $manager) + { + $this->manager = $manager; + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Queue/composer.json b/vendor/laravel/framework/src/Illuminate/Queue/composer.json new file mode 100755 index 0000000..d9e914f --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Queue/composer.json @@ -0,0 +1,44 @@ +{ + "name": "illuminate/queue", + "license": "MIT", + "authors": [ + { + "name": "Taylor Otwell", + "email": "taylorotwell@gmail.com" + } + ], + "require": { + "php": ">=5.3.0", + "illuminate/console": "4.1.*", + "illuminate/container": "4.1.*", + "illuminate/http": "4.1.*", + "illuminate/support": "4.1.*", + "symfony/process": "2.4.*" + }, + "require-dev": { + "illuminate/events": "4.1.*", + "aws/aws-sdk-php": "2.6.*", + "iron-io/iron_mq": "1.5.*", + "pda/pheanstalk": "2.1.*", + "mockery/mockery": "0.9.*", + "phpunit/phpunit": "4.0.*" + }, + "autoload": { + "psr-0": { + "Illuminate\\Queue": "" + }, + "classmap": [ + "IlluminateQueueClosure.php" + ] + }, + "target-dir": "Illuminate/Queue", + "extra": { + "branch-alias": { + "dev-master": "4.1-dev" + } + }, + "suggest": { + "illuminate/redis": "Allows use of the Redis queue driver." + }, + "minimum-stability": "dev" +} diff --git a/vendor/laravel/framework/src/Illuminate/Redis/Database.php b/vendor/laravel/framework/src/Illuminate/Redis/Database.php new file mode 100755 index 0000000..67f14dd --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Redis/Database.php @@ -0,0 +1,98 @@ +clients = $this->createAggregateClient($servers); + } + else + { + $this->clients = $this->createSingleClients($servers); + } + } + + /** + * Create a new aggregate client supporting sharding. + * + * @param array $servers + * @return array + */ + protected function createAggregateClient(array $servers) + { + $servers = array_except($servers, array('cluster')); + + return array('default' => new Client(array_values($servers))); + } + + /** + * Create an array of single connection clients. + * + * @param array $servers + * @return array + */ + protected function createSingleClients(array $servers) + { + $clients = array(); + + foreach ($servers as $key => $server) + { + $clients[$key] = new Client($server); + } + + return $clients; + } + + /** + * Get a specific Redis connection instance. + * + * @param string $name + * @return \Predis\Connection\SingleConnectionInterface + */ + public function connection($name = 'default') + { + return $this->clients[$name ?: 'default']; + } + + /** + * Run a command against the Redis database. + * + * @param string $method + * @param array $parameters + * @return mixed + */ + public function command($method, array $parameters = array()) + { + return call_user_func_array(array($this->clients['default'], $method), $parameters); + } + + /** + * Dynamically make a Redis command. + * + * @param string $method + * @param array $parameters + * @return mixed + */ + public function __call($method, $parameters) + { + return $this->command($method, $parameters); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Redis/RedisServiceProvider.php b/vendor/laravel/framework/src/Illuminate/Redis/RedisServiceProvider.php new file mode 100755 index 0000000..947d365 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Redis/RedisServiceProvider.php @@ -0,0 +1,37 @@ +app->bindShared('redis', function($app) + { + return new Database($app['config']['database.redis']); + }); + } + + /** + * Get the services provided by the provider. + * + * @return array + */ + public function provides() + { + return array('redis'); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Redis/composer.json b/vendor/laravel/framework/src/Illuminate/Redis/composer.json new file mode 100755 index 0000000..aee8fb9 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Redis/composer.json @@ -0,0 +1,31 @@ +{ + "name": "illuminate/redis", + "license": "MIT", + "authors": [ + { + "name": "Taylor Otwell", + "email": "taylorotwell@gmail.com" + } + ], + "require": { + "php": ">=5.3.0", + "illuminate/support": "4.1.*", + "predis/predis": "0.8.*" + }, + "require-dev": { + "mockery/mockery": "0.9.*", + "phpunit/phpunit": "4.0.*" + }, + "autoload": { + "psr-0": { + "Illuminate\\Redis": "" + } + }, + "target-dir": "Illuminate/Redis", + "extra": { + "branch-alias": { + "dev-master": "4.1-dev" + } + }, + "minimum-stability": "dev" +} diff --git a/vendor/laravel/framework/src/Illuminate/Remote/Connection.php b/vendor/laravel/framework/src/Illuminate/Remote/Connection.php new file mode 100755 index 0000000..3b43bbd --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Remote/Connection.php @@ -0,0 +1,274 @@ +name = $name; + $this->host = $host; + $this->username = $username; + $this->gateway = $gateway ?: new SecLibGateway($host, $auth, new Filesystem); + } + + /** + * Define a set of commands as a task. + * + * @param string $task + * @param string|array $commands + * @return void + */ + public function define($task, $commands) + { + $this->tasks[$task] = $commands; + } + + /** + * Run a task against the connection. + * + * @param string $task + * @param \Closure $callback + * @return void + */ + public function task($task, Closure $callback = null) + { + if (isset($this->tasks[$task])) + { + return $this->run($this->tasks[$task], $callback); + } + } + + /** + * Run a set of commands against the connection. + * + * @param string|array $commands + * @param \Closure $callback + * @return void + */ + public function run($commands, Closure $callback = null) + { + // First, we will initialize the SSH gateway, and then format the commands so + // they can be run. Once we have the commands formatted and the server is + // ready to go we will just fire off these commands against the server. + $gateway = $this->getGateway(); + + $callback = $this->getCallback($callback); + + $gateway->run($this->formatCommands($commands)); + + // After running the commands against the server, we will continue to ask for + // the next line of output that is available, and write it them out using + // our callback. Once we hit the end of output, we'll bail out of here. + while (true) + { + if (is_null($line = $gateway->nextLine())) break; + + call_user_func($callback, $line, $this); + } + } + + /** + * Download the contents of a remote file. + * + * @param string $remote + * @param string $local + * @return void + */ + public function get($remote, $local) + { + $this->getGateway()->get($remote, $local); + } + + /** + * Get the contents of a remote file. + * + * @param string $remote + * @return string + */ + public function getString($remote) + { + return $this->getGateway()->getString($remote); + } + + /** + * Upload a local file to the server. + * + * @param string $local + * @param string $remote + * @return void + */ + public function put($local, $remote) + { + $this->getGateway()->put($local, $remote); + } + + /** + * Upload a string to to the given file on the server. + * + * @param string $remote + * @param string $contents + * @return void + */ + public function putString($remote, $contents) + { + $this->getGateway()->putString($remote, $contents); + } + + /** + * Display the given line using the default output. + * + * @param string $line + * @return void + */ + public function display($line) + { + $server = $this->username.'@'.$this->host; + + $lead = '['.$server.'] ('.$this->name.')'; + + $this->getOutput()->writeln($lead.' '.$line); + } + + /** + * Format the given command set. + * + * @param string|array $commands + * @return string + */ + protected function formatCommands($commands) + { + return is_array($commands) ? implode(' && ', $commands) : $commands; + } + + /** + * Get the display callback for the connection. + * + * @param \Closure|null $callback + * @return \Closure + */ + protected function getCallback($callback) + { + if ( ! is_null($callback)) return $callback; + + $me = $this; + + return function($line) use ($me) { $me->display($line); }; + } + + /** + * Get the exit status of the last command. + * + * @return int|bool + */ + public function status() + { + return $this->gateway->status(); + } + + /** + * Get the gateway implementation. + * + * @return \Illuminate\Remote\GatewayInterface + * + * @throws \RuntimeException + */ + public function getGateway() + { + if ( ! $this->gateway->connected()) + { + if ( ! $this->gateway->connect($this->username)) + { + throw new \RuntimeException("Unable to connect to remote server."); + } + } + + return $this->gateway; + } + + /** + * Get the output implementation for the connection. + * + * @return \Symfony\Component\Console\Output\OutputInterface + */ + public function getOutput() + { + if (is_null($this->output)) $this->output = new NullOutput; + + return $this->output; + } + + /** + * Set the output implementation. + * + * @param \Symfony\Component\Console\Output\OutputInterface $output + * @return void + */ + public function setOutput(OutputInterface $output) + { + $this->output = $output; + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Remote/ConnectionInterface.php b/vendor/laravel/framework/src/Illuminate/Remote/ConnectionInterface.php new file mode 100755 index 0000000..0b46ab3 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Remote/ConnectionInterface.php @@ -0,0 +1,52 @@ +connections = $connections; + } + + /** + * Define a set of commands as a task. + * + * @param string $task + * @param string|array $commands + * @return void + */ + public function define($task, $commands) + { + foreach ($this->connections as $connection) + { + $connection->define($task, $commands); + } + } + + /** + * Run a task against the connection. + * + * @param string $task + * @param \Closure $callback + * @return void + */ + public function task($task, Closure $callback = null) + { + foreach ($this->connections as $connection) + { + $connection->task($task, $callback); + } + } + + /** + * Run a set of commands against the connection. + * + * @param string|array $commands + * @param \Closure $callback + * @return void + */ + public function run($commands, Closure $callback = null) + { + foreach ($this->connections as $connection) + { + $connection->run($commands, $callback); + } + } + + /** + * Upload a local file to the server. + * + * @param string $local + * @param string $remote + * @return void + */ + public function put($local, $remote) + { + foreach ($this->connections as $connection) + { + $connection->put($local, $remote); + } + } + + /** + * Upload a string to to the given file on the server. + * + * @param string $remote + * @param string $contents + * @return void + */ + public function putString($remote, $contents) + { + foreach ($this->connections as $connection) + { + $connection->putString($remote, $contents); + } + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Remote/RemoteManager.php b/vendor/laravel/framework/src/Illuminate/Remote/RemoteManager.php new file mode 100755 index 0000000..7fbd4da --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Remote/RemoteManager.php @@ -0,0 +1,213 @@ +app = $app; + } + + /** + * Get a remote connection instance. + * + * @param string|array|dynamic $name + * @return \Illuminate\Remote\ConnectionInterface + */ + public function into($name) + { + if (is_string($name) || is_array($name)) + { + return $this->connection($name); + } + else + { + return $this->connection(func_get_args()); + } + } + + /** + * Get a remote connection instance. + * + * @param string|array $name + * @return \Illuminate\Remote\ConnectionInterface + */ + public function connection($name = null) + { + if (is_array($name)) return $this->multiple($name); + + return $this->resolve($name ?: $this->getDefaultConnection()); + } + + /** + * Get a connection group instance by name. + * + * @param string $name + * @return \Illuminate\Remote\ConnectionInterface + */ + public function group($name) + { + return $this->connection($this->app['config']['remote.groups.'.$name]); + } + + /** + * Resolve a multiple connection instance. + * + * @param array $names + * @return \Illuminate\Remote\MultiConnection + */ + public function multiple(array $names) + { + return new MultiConnection(array_map(array($this, 'resolve'), $names)); + } + + /** + * Resolve a remote connection instance. + * + * @param string $name + * @return \Illuminate\Remote\Connection + */ + public function resolve($name) + { + if ( ! isset($this->connections[$name])) + { + $this->connections[$name] = $this->makeConnection($name, $this->getConfig($name)); + } + + return $this->connections[$name]; + } + + /** + * Make a new connection instance. + * + * @param string $name + * @param array $config + * @return \Illuminate\Remote\Connection + */ + protected function makeConnection($name, array $config) + { + $this->setOutput($connection = new Connection( + + $name, $config['host'], $config['username'], $this->getAuth($config) + + )); + + return $connection; + } + + /** + * Set the output implementation on the connection. + * + * @param \Illuminate\Remote\Connection $connection + * @return void + */ + protected function setOutput(Connection $connection) + { + $output = php_sapi_name() == 'cli' ? new ConsoleOutput : new NullOutput; + + $connection->setOutput($output); + } + + /** + * Format the appropriate authentication array payload. + * + * @param array $config + * @return array + * + * @throws \InvalidArgumentException + */ + protected function getAuth(array $config) + { + if (isset($config['agent']) && $config['agent'] === true) + { + return array('agent' => true); + } + elseif (isset($config['key']) && trim($config['key']) != '') + { + return array('key' => $config['key'], 'keyphrase' => $config['keyphrase']); + } + elseif (isset($config['keytext']) && trim($config['keytext']) != '') + { + return array('keytext' => $config['keytext']); + } + elseif (isset($config['password'])) + { + return array('password' => $config['password']); + } + + throw new \InvalidArgumentException('Password / key is required.'); + } + + /** + * Get the configuration for a remote server. + * + * @param string $name + * @return array + * + * @throws \InvalidArgumentException + */ + protected function getConfig($name) + { + $config = $this->app['config']['remote.connections.'.$name]; + + if ( ! is_null($config)) return $config; + + throw new \InvalidArgumentException("Remote connection [$name] not defined."); + } + + /** + * Get the default connection name. + * + * @return string + */ + public function getDefaultConnection() + { + return $this->app['config']['remote.default']; + } + + /** + * Set the default connection name. + * + * @param string $name + * @return void + */ + public function setDefaultConnection($name) + { + $this->app['config']['remote.default'] = $name; + } + + /** + * Dynamically pass methods to the default connection. + * + * @param string $method + * @param array $parameters + * @return mixed + */ + public function __call($method, $parameters) + { + return call_user_func_array(array($this->connection(), $method), $parameters); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Remote/RemoteServiceProvider.php b/vendor/laravel/framework/src/Illuminate/Remote/RemoteServiceProvider.php new file mode 100755 index 0000000..0bceea9 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Remote/RemoteServiceProvider.php @@ -0,0 +1,37 @@ +app->bindShared('remote', function($app) + { + return new RemoteManager($app); + }); + } + + /** + * Get the services provided by the provider. + * + * @return array + */ + public function provides() + { + return array('remote'); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Remote/SecLibGateway.php b/vendor/laravel/framework/src/Illuminate/Remote/SecLibGateway.php new file mode 100755 index 0000000..84f2e36 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Remote/SecLibGateway.php @@ -0,0 +1,320 @@ +auth = $auth; + $this->files = $files; + $this->setHostAndPort($host); + } + + /** + * Set the host and port from a full host string. + * + * @param string $host + * @return void + */ + protected function setHostAndPort($host) + { + if ( ! str_contains($host, ':')) + { + $this->host = $host; + } + else + { + list($this->host, $this->port) = explode(':', $host); + + $this->port = (int) $this->port; + } + } + + /** + * Connect to the SSH server. + * + * @param string $username + * @return bool + */ + public function connect($username) + { + return $this->getConnection()->login($username, $this->getAuthForLogin()); + } + + /** + * Determine if the gateway is connected. + * + * @return bool + */ + public function connected() + { + return $this->getConnection()->isConnected(); + } + + /** + * Run a command against the server (non-blocking). + * + * @param string $command + * @return void + */ + public function run($command) + { + $this->getConnection()->exec($command, false); + } + + /** + * Download the contents of a remote file. + * + * @param string $remote + * @param string $local + * @return void + */ + public function get($remote, $local) + { + $this->getConnection()->get($remote, $local); + } + + /** + * Get the contents of a remote file. + * + * @param string $remote + * @return string + */ + public function getString($remote) + { + return $this->getConnection()->get($remote); + } + + /** + * Upload a local file to the server. + * + * @param string $local + * @param string $remote + * @return void + */ + public function put($local, $remote) + { + $this->getConnection()->put($remote, $local, NET_SFTP_LOCAL_FILE); + } + + /** + * Upload a string to to the given file on the server. + * + * @param string $remote + * @param string $contents + * @return void + */ + public function putString($remote, $contents) + { + $this->getConnection()->put($remote, $contents); + } + + /** + * Get the next line of output from the server. + * + * @return string|null + */ + public function nextLine() + { + $value = $this->getConnection()->_get_channel_packet(NET_SSH2_CHANNEL_EXEC); + + return $value === true ? null : $value; + } + + /** + * Get the authentication object for login. + * + * @return \Crypt_RSA|\System_SSH_Agent|string + * @throws \InvalidArgumentException + */ + protected function getAuthForLogin() + { + if ($this->useAgent()) return $this->getAgent(); + + // If a "key" was specified in the auth credentials, we will load it into a + // secure RSA key instance, which will be used to connect to the servers + // in place of a password, and avoids the developer specifying a pass. + elseif ($this->hasRsaKey()) + { + return $this->loadRsaKey($this->auth); + } + + // If a plain password was set on the auth credentials, we will just return + // that as it can be used to connect to the server. This will be used if + // there is no RSA key and it gets specified in the credential arrays. + elseif (isset($this->auth['password'])) + { + return $this->auth['password']; + } + + throw new \InvalidArgumentException('Password / key is required.'); + } + + /** + * Determine if an RSA key is configured. + * + * @return bool + */ + protected function hasRsaKey() + { + $hasKey = (isset($this->auth['key']) && trim($this->auth['key']) != ''); + + return $hasKey || (isset($this->auth['keytext']) && trim($this->auth['keytext']) != ''); + } + + /** + * Load the RSA key instance. + * + * @param array $auth + * @return \Crypt_RSA + */ + protected function loadRsaKey(array $auth) + { + with($key = $this->getKey($auth))->loadKey($this->readRsaKey($auth)); + + return $key; + } + + /** + * Read the contents of the RSA key. + * + * @param array $auth + * @return string + */ + protected function readRsaKey(array $auth) + { + if (isset($auth['key'])) return $this->files->get($auth['key']); + + return $auth['keytext']; + } + + /** + * Create a new RSA key instance. + * + * @param array $auth + * @return \Crypt_RSA + */ + protected function getKey(array $auth) + { + with($key = $this->getNewKey())->setPassword(array_get($auth, 'keyphrase')); + + return $key; + } + + /** + * Determine if the SSH Agent should provide an RSA key. + * + * @return bool + */ + protected function useAgent() + { + return isset($this->auth['agent']) && $this->auth['agent'] === true; + } + + /** + * Get a new SSH Agent instance. + * + * @return \System_SSH_Agent + */ + public function getAgent() + { + return new System_SSH_Agent; + } + + /** + * Get a new RSA key instance. + * + * @return \Crypt_RSA + */ + public function getNewKey() + { + return new Crypt_RSA; + } + + /** + * Get the exit status of the last command. + * + * @return int|bool + */ + public function status() + { + return $this->getConnection()->getExitStatus(); + } + + /** + * Get the host used by the gateway. + * + * @return string + */ + public function getHost() + { + return $this->host; + } + + /** + * Get the port used by the gateway. + * + * @return int + */ + public function getPort() + { + return $this->port; + } + + /** + * Get the underlying Net_SFTP connection. + * + * @return \Net_SFTP + */ + public function getConnection() + { + if ($this->connection) return $this->connection; + + return $this->connection = new Net_SFTP($this->host, $this->port); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Remote/composer.json b/vendor/laravel/framework/src/Illuminate/Remote/composer.json new file mode 100755 index 0000000..c26645b --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Remote/composer.json @@ -0,0 +1,33 @@ +{ + "name": "illuminate/remote", + "license": "MIT", + "authors": [ + { + "name": "Taylor Otwell", + "email": "taylorotwell@gmail.com" + } + ], + "require": { + "php": ">=5.3.0", + "illuminate/filesystem": "4.1.*", + "illuminate/support": "4.1.*", + "phpseclib/phpseclib": "0.3.*" + }, + "require-dev": { + "illuminate/console": "4.1.*", + "mockery/mockery": "0.9.*", + "phpunit/phpunit": "4.0.*" + }, + "autoload": { + "psr-0": { + "Illuminate\\Remote": "" + } + }, + "target-dir": "Illuminate/Remote", + "extra": { + "branch-alias": { + "dev-master": "4.1-dev" + } + }, + "minimum-stability": "dev" +} diff --git a/vendor/laravel/framework/src/Illuminate/Routing/Console/MakeControllerCommand.php b/vendor/laravel/framework/src/Illuminate/Routing/Console/MakeControllerCommand.php new file mode 100755 index 0000000..a07ed31 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Routing/Console/MakeControllerCommand.php @@ -0,0 +1,182 @@ +path = $path; + $this->generator = $generator; + } + + /** + * Execute the console command. + * + * @return void + */ + public function fire() + { + $this->generateController(); + } + + /** + * Generate a new resourceful controller file. + * + * @return void + */ + protected function generateController() + { + // Once we have the controller and resource that we are going to be generating + // we will grab the path and options. We allow the developers to include or + // exclude given methods from the resourceful controllers we're building. + $controller = $this->input->getArgument('name'); + + $path = $this->getPath(); + + $options = $this->getBuildOptions(); + + // Finally, we're ready to generate the actual controller file on disk and let + // the developer start using it. The controller will be stored in the right + // place based on the namespace of this controller specified by commands. + $this->generator->make($controller, $path, $options); + + $this->info('Controller created successfully!'); + } + + /** + * Get the path in which to store the controller. + * + * @return string + */ + protected function getPath() + { + if ( ! is_null($this->input->getOption('path'))) + { + return $this->laravel['path.base'].'/'.$this->input->getOption('path'); + } + elseif ($bench = $this->input->getOption('bench')) + { + return $this->getWorkbenchPath($bench); + } + + return $this->path; + } + + /** + * Get the workbench path for the controller. + * + * @param string $bench + * @return string + */ + protected function getWorkbenchPath($bench) + { + $path = $this->laravel['path.base'].'/workbench/'.$bench.'/src/controllers'; + + if ( ! $this->laravel['files']->isDirectory($path)) + { + $this->laravel['files']->makeDirectory($path); + } + + return $path; + } + + /** + * Get the options for controller generation. + * + * @return array + */ + protected function getBuildOptions() + { + $only = $this->explodeOption('only'); + + $except = $this->explodeOption('except'); + + return compact('only', 'except'); + } + + /** + * Get and explode a given input option. + * + * @param string $name + * @return array + */ + protected function explodeOption($name) + { + $option = $this->input->getOption($name); + + return is_null($option) ? array() : explode(',', $option); + } + + /** + * Get the console command arguments. + * + * @return array + */ + protected function getArguments() + { + return array( + array('name', InputArgument::REQUIRED, 'The name of the controller class'), + ); + } + + + /** + * Get the console command options. + * + * @return array + */ + protected function getOptions() + { + return array( + array('bench', null, InputOption::VALUE_OPTIONAL, 'The workbench the controller belongs to'), + + array('only', null, InputOption::VALUE_OPTIONAL, 'The methods that should be included'), + + array('except', null, InputOption::VALUE_OPTIONAL, 'The methods that should be excluded'), + + array('path', null, InputOption::VALUE_OPTIONAL, 'Where to place the controller'), + ); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Routing/Controller.php b/vendor/laravel/framework/src/Illuminate/Routing/Controller.php new file mode 100755 index 0000000..9d27771 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Routing/Controller.php @@ -0,0 +1,271 @@ +beforeFilters[] = $this->parseFilter($filter, $options); + } + + /** + * Register an "after" filter on the controller. + * + * @param \Closure|string $filter + * @param array $options + * @return void + */ + public function afterFilter($filter, array $options = array()) + { + $this->afterFilters[] = $this->parseFilter($filter, $options); + } + + /** + * Parse the given filter and options. + * + * @param \Closure|string $filter + * @param array $options + * @return array + */ + protected function parseFilter($filter, array $options) + { + $parameters = array(); + + $original = $filter; + + if ($filter instanceof Closure) + { + $filter = $this->registerClosureFilter($filter); + } + elseif ($this->isInstanceFilter($filter)) + { + $filter = $this->registerInstanceFilter($filter); + } + else + { + list($filter, $parameters) = Route::parseFilter($filter); + } + + return compact('original', 'filter', 'parameters', 'options'); + } + + /** + * Register an anonymous controller filter Closure. + * + * @param \Closure $filter + * @return string + */ + protected function registerClosureFilter(Closure $filter) + { + $this->getFilterer()->filter($name = spl_object_hash($filter), $filter); + + return $name; + } + + /** + * Register a controller instance method as a filter. + * + * @param string $filter + * @return string + */ + protected function registerInstanceFilter($filter) + { + $this->getFilterer()->filter($filter, array($this, substr($filter, 1))); + + return $filter; + } + + /** + * Determine if a filter is a local method on the controller. + * + * @param mixed $filter + * @return boolean + * + * @throws \InvalidArgumentException + */ + protected function isInstanceFilter($filter) + { + if (is_string($filter) && starts_with($filter, '@')) + { + if (method_exists($this, substr($filter, 1))) return true; + + throw new \InvalidArgumentException("Filter method [$filter] does not exist."); + } + + return false; + } + + /** + * Remove the given before filter. + * + * @param string $filter + * @return void + */ + public function forgetBeforeFilter($filter) + { + $this->beforeFilters = $this->removeFilter($filter, $this->getBeforeFilters()); + } + + /** + * Remove the given after filter. + * + * @param string $filter + * @return void + */ + public function forgetAfterFilter($filter) + { + $this->afterFilters = $this->removeFilter($filter, $this->getAfterFilters()); + } + + /** + * Remove the given controller filter from the provided filter array. + * + * @param string $removing + * @param array $current + * @return array + */ + protected function removeFilter($removing, $current) + { + return array_filter($current, function($filter) use ($removing) + { + return $filter['original'] != $removing; + }); + } + + /** + * Get the registered "before" filters. + * + * @return array + */ + public function getBeforeFilters() + { + return $this->beforeFilters; + } + + /** + * Get the registered "after" filters. + * + * @return array + */ + public function getAfterFilters() + { + return $this->afterFilters; + } + + /** + * Get the route filterer implementation. + * + * @return \Illuminate\Routing\RouteFiltererInterface + */ + public static function getFilterer() + { + return static::$filterer; + } + + /** + * Set the route filterer implementation. + * + * @param \Illuminate\Routing\RouteFiltererInterface $filterer + * @return void + */ + public static function setFilterer(RouteFiltererInterface $filterer) + { + static::$filterer = $filterer; + } + + /** + * Create the layout used by the controller. + * + * @return void + */ + protected function setupLayout() {} + + /** + * Execute an action on the controller. + * + * @param string $method + * @param array $parameters + * @return \Symfony\Component\HttpFoundation\Response + */ + public function callAction($method, $parameters) + { + $this->setupLayout(); + + $response = call_user_func_array(array($this, $method), $parameters); + + // If no response is returned from the controller action and a layout is being + // used we will assume we want to just return the layout view as any nested + // views were probably bound on this view during this controller actions. + if (is_null($response) && ! is_null($this->layout)) + { + $response = $this->layout; + } + + return $response; + } + + /** + * Handle calls to missing methods on the controller. + * + * @param array $parameters + * @return mixed + * + * @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException + */ + public function missingMethod($parameters = array()) + { + throw new NotFoundHttpException("Controller method not found."); + } + + /** + * Handle calls to missing methods on the controller. + * + * @param string $method + * @param array $parameters + * @return mixed + * + * @throws \BadMethodCallException + */ + public function __call($method, $parameters) + { + throw new \BadMethodCallException("Method [$method] does not exist."); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php b/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php new file mode 100755 index 0000000..8afd852 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php @@ -0,0 +1,243 @@ +filterer = $filterer; + $this->container = $container; + } + + /** + * Dispatch a request to a given controller and method. + * + * @param \Illuminate\Routing\Route $route + * @param \Illuminate\Http\Request $request + * @param string $controller + * @param string $method + * @return mixed + */ + public function dispatch(Route $route, Request $request, $controller, $method) + { + // First we will make an instance of this controller via the IoC container instance + // so that we can call the methods on it. We will also apply any "after" filters + // to the route so that they will be run by the routers after this processing. + $instance = $this->makeController($controller); + + $this->assignAfter($instance, $route, $request, $method); + + $response = $this->before($instance, $route, $request, $method); + + // If no before filters returned a response we'll call the method on the controller + // to get the response to be returned to the router. We will then return it back + // out for processing by this router and the after filters can be called then. + if (is_null($response)) + { + $response = $this->call($instance, $route, $method); + } + + return $response; + } + + /** + * Make a controller instance via the IoC container. + * + * @param string $controller + * @return mixed + */ + protected function makeController($controller) + { + Controller::setFilterer($this->filterer); + + return $this->container->make($controller); + } + + /** + * Call the given controller instance method. + * + * @param \Illuminate\Routing\Controller $instance + * @param \Illuminate\Routing\Route $route + * @param string $method + * @return mixed + */ + protected function call($instance, $route, $method) + { + $parameters = $route->parametersWithoutNulls(); + + return $instance->callAction($method, $parameters); + } + + /** + * Call the "before" filters for the controller. + * + * @param \Illuminate\Routing\Controller $instance + * @param \Illuminate\Routing\Route $route + * @param \Illuminate\Http\Request $request + * @param string $method + * @return mixed + */ + protected function before($instance, $route, $request, $method) + { + foreach ($instance->getBeforeFilters() as $filter) + { + if ($this->filterApplies($filter, $request, $method)) + { + // Here we will just check if the filter applies. If it does we will call the filter + // and return the responses if it isn't null. If it is null, we will keep hitting + // them until we get a response or are finished iterating through this filters. + $response = $this->callFilter($filter, $route, $request); + + if ( ! is_null($response)) return $response; + } + } + } + + /** + * Apply the applicable after filters to the route. + * + * @param \Illuminate\Routing\Controller $instance + * @param \Illuminate\Routing\Route $route + * @param \Illuminate\Http\Request $request + * @param string $method + * @return mixed + */ + protected function assignAfter($instance, $route, $request, $method) + { + foreach ($instance->getAfterFilters() as $filter) + { + // If the filter applies, we will add it to the route, since it has already been + // registered on the filterer by the controller, and will just let the normal + // router take care of calling these filters so we do not duplicate logics. + if ($this->filterApplies($filter, $request, $method)) + { + $route->after($this->getAssignableAfter($filter)); + } + } + } + + /** + * Get the assignable after filter for the route. + * + * @param Closure|string $filter + * @return string + */ + protected function getAssignableAfter($filter) + { + return $filter['original'] instanceof Closure ? $filter['filter'] : $filter['original']; + } + + /** + * Determine if the given filter applies to the request. + * + * @param array $filter + * @param \Illuminate\Http\Request $request + * @param string $method + * @return bool + */ + protected function filterApplies($filter, $request, $method) + { + foreach (array('Only', 'Except', 'On') as $type) + { + if ($this->{"filterFails{$type}"}($filter, $request, $method)) + { + return false; + } + } + + return true; + } + + /** + * Determine if the filter fails the "only" constraint. + * + * @param array $filter + * @param \Illuminate\Http\Request $request + * @param string $method + * @return bool + */ + protected function filterFailsOnly($filter, $request, $method) + { + if ( ! isset($filter['options']['only'])) return false; + + return ! in_array($method, (array) $filter['options']['only']); + } + + /** + * Determine if the filter fails the "except" constraint. + * + * @param array $filter + * @param \Illuminate\Http\Request $request + * @param string $method + * @return bool + */ + protected function filterFailsExcept($filter, $request, $method) + { + if ( ! isset($filter['options']['except'])) return false; + + return in_array($method, (array) $filter['options']['except']); + } + + /** + * Determine if the filter fails the "on" constraint. + * + * @param array $filter + * @param \Illuminate\Http\Request $request + * @param string $method + * @return bool + */ + protected function filterFailsOn($filter, $request, $method) + { + $on = array_get($filter, 'options.on', null); + + if (is_null($on)) return false; + + // If the "on" is a string, we will explode it on the pipe so you can set any + // amount of methods on the filter constraints and it will still work like + // you specified an array. Then we will check if the method is in array. + if (is_string($on)) $on = explode('|', $on); + + return ! in_array(strtolower($request->getMethod()), $on); + } + + /** + * Call the given controller filter method. + * + * @param array $filter + * @param \Illuminate\Routing\Route $route + * @param \Illuminate\Http\Request $request + * @return mixed + */ + protected function callFilter($filter, $route, $request) + { + extract($filter); + + return $this->filterer->callRouteFilter($filter, $parameters, $route, $request); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Routing/ControllerInspector.php b/vendor/laravel/framework/src/Illuminate/Routing/ControllerInspector.php new file mode 100755 index 0000000..12c7221 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Routing/ControllerInspector.php @@ -0,0 +1,137 @@ +getMethods() as $method) + { + if ($this->isRoutable($method, $reflection->name)) + { + $data = $this->getMethodData($method, $prefix); + + // If the routable method is an index method, we will create a special index + // route which is simply the prefix and the verb and does not contain any + // the wildcard place-holders that each "typical" routes would contain. + if ($data['plain'] == $prefix.'/index') + { + $routable[$method->name][] = $data; + + $routable[$method->name][] = $this->getIndexData($data, $prefix); + } + + // If the routable method is not a special index method, we will just add in + // the data to the returned results straight away. We do not need to make + // any special routes for this scenario but only just add these routes. + else + { + $routable[$method->name][] = $data; + } + } + } + + return $routable; + } + + /** + * Determine if the given controller method is routable. + * + * @param ReflectionMethod $method + * @param string $controller + * @return bool + */ + public function isRoutable(ReflectionMethod $method, $controller) + { + if ($method->class == 'Illuminate\Routing\Controller') return false; + + return $method->isPublic() && starts_with($method->name, $this->verbs); + } + + /** + * Get the method data for a given method. + * + * @param ReflectionMethod $method + * @return array + */ + public function getMethodData(ReflectionMethod $method, $prefix) + { + $verb = $this->getVerb($name = $method->name); + + $uri = $this->addUriWildcards($plain = $this->getPlainUri($name, $prefix)); + + return compact('verb', 'plain', 'uri'); + } + + /** + * Get the routable data for an index method. + * + * @param array $data + * @param string $prefix + * @return array + */ + protected function getIndexData($data, $prefix) + { + return array('verb' => $data['verb'], 'plain' => $prefix, 'uri' => $prefix); + } + + /** + * Extract the verb from a controller action. + * + * @param string $name + * @return string + */ + public function getVerb($name) + { + return head(explode('_', snake_case($name))); + } + + /** + * Determine the URI from the given method name. + * + * @param string $name + * @param string $prefix + * @return string + */ + public function getPlainUri($name, $prefix) + { + return $prefix.'/'.implode('-', array_slice(explode('_', snake_case($name)), 1)); + } + + /** + * Add wildcards to the given URI. + * + * @param string $uri + * @return string + */ + public function addUriWildcards($uri) + { + return $uri.'/{one?}/{two?}/{three?}/{four?}/{five?}'; + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Routing/ControllerServiceProvider.php b/vendor/laravel/framework/src/Illuminate/Routing/ControllerServiceProvider.php new file mode 100755 index 0000000..764808b --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Routing/ControllerServiceProvider.php @@ -0,0 +1,60 @@ +registerGenerator(); + + $this->commands('command.controller.make'); + } + + /** + * Register the controller generator command. + * + * @return void + */ + protected function registerGenerator() + { + $this->app->bindShared('command.controller.make', function($app) + { + // The controller generator is responsible for building resourceful controllers + // quickly and easily for the developers via the Artisan CLI. We'll go ahead + // and register this command instances in this container for registration. + $path = $app['path'].'/controllers'; + + $generator = new ControllerGenerator($app['files']); + + return new MakeControllerCommand($generator, $path); + }); + } + + /** + * Get the services provided by the provider. + * + * @return array + */ + public function provides() + { + return array( + 'command.controller.make' + ); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Routing/Generators/ControllerGenerator.php b/vendor/laravel/framework/src/Illuminate/Routing/Generators/ControllerGenerator.php new file mode 100755 index 0000000..5b93d2b --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Routing/Generators/ControllerGenerator.php @@ -0,0 +1,209 @@ +files = $files; + } + + /** + * Create a new resourceful controller file. + * + * @param string $controller + * @param string $path + * @param array $options + * @return void + */ + public function make($controller, $path, array $options = array()) + { + $stub = $this->addMethods($this->getController($controller), $options); + + $this->writeFile($stub, $controller, $path); + + return false; + } + + /** + * Write the completed stub to disk. + * + * @param string $stub + * @param string $controller + * @param string $path + * @return void + */ + protected function writeFile($stub, $controller, $path) + { + if (str_contains($controller, '\\')) + { + $this->makeDirectory($controller, $path); + } + + $controller = str_replace('\\', DIRECTORY_SEPARATOR, $controller); + + if ( ! $this->files->exists($fullPath = $path."/{$controller}.php")) + { + return $this->files->put($fullPath, $stub); + } + } + + /** + * Create the directory for the controller. + * + * @param string $controller + * @param string $path + * @return void + */ + protected function makeDirectory($controller, $path) + { + $directory = $this->getDirectory($controller); + + if ( ! $this->files->isDirectory($full = $path.'/'.$directory)) + { + $this->files->makeDirectory($full, 0777, true); + } + } + + /** + * Get the directory the controller should live in. + * + * @param string $controller + * @return string + */ + protected function getDirectory($controller) + { + return implode('/', array_slice(explode('\\', $controller), 0, -1)); + } + + /** + * Get the controller class stub. + * + * @param string $controller + * @return string + */ + protected function getController($controller) + { + $stub = $this->files->get(__DIR__.'/stubs/controller.stub'); + + // We will explode out the controller name on the namespace delimiter so we + // are able to replace a namespace in this stub file. If no namespace is + // provided we'll just clear out the namespace place-holder locations. + $segments = explode('\\', $controller); + + $stub = $this->replaceNamespace($segments, $stub); + + return str_replace('{{class}}', last($segments), $stub); + } + + /** + * Replace the namespace on the controller. + * + * @param array $segments + * @param string $stub + * @return string + */ + protected function replaceNamespace(array $segments, $stub) + { + if (count($segments) > 1) + { + $namespace = implode('\\', array_slice($segments, 0, -1)); + + return str_replace('{{namespace}}', ' namespace '.$namespace.';', $stub); + } + else + { + return str_replace('{{namespace}}', '', $stub); + } + } + + /** + * Add the method stubs to the controller. + * + * @param string $stub + * @param array $options + * @return string + */ + protected function addMethods($stub, array $options) + { + // Once we have the applicable methods, we can just spin through those methods + // and add each one to our array of method stubs. Then we will implode them + // them all with end-of-line characters and return the final joined list. + $stubs = $this->getMethodStubs($options); + + $methods = implode(PHP_EOL.PHP_EOL, $stubs); + + return str_replace('{{methods}}', $methods, $stub); + } + + /** + * Get all of the method stubs for the given options. + * + * @param array $options + * @return array + */ + protected function getMethodStubs($options) + { + $stubs = array(); + + // Each stub is conveniently kept in its own file so we can just grab the ones + // we need from disk to build the controller file. Once we have them all in + // an array we will return this list of methods so they can be joined up. + foreach ($this->getMethods($options) as $method) + { + $stubs[] = $this->files->get(__DIR__."/stubs/{$method}.stub"); + } + + return $stubs; + } + + /** + * Get the applicable methods based on the options. + * + * @param array $options + * @return array + */ + protected function getMethods($options) + { + if (isset($options['only']) && count($options['only']) > 0) + { + return $options['only']; + } + elseif (isset($options['except']) && count($options['except']) > 0) + { + return array_diff($this->defaults, $options['except']); + } + + return $this->defaults; + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Routing/Generators/stubs/controller.stub b/vendor/laravel/framework/src/Illuminate/Routing/Generators/stubs/controller.stub new file mode 100755 index 0000000..b6d02dd --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Routing/Generators/stubs/controller.stub @@ -0,0 +1,7 @@ +getCompiled()->getHostRegex())) return true; + + return preg_match($route->getCompiled()->getHostRegex(), $request->getHost()); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Routing/Matching/MethodValidator.php b/vendor/laravel/framework/src/Illuminate/Routing/Matching/MethodValidator.php new file mode 100755 index 0000000..211bc30 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Routing/Matching/MethodValidator.php @@ -0,0 +1,20 @@ +getMethod(), $route->methods()); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Routing/Matching/SchemeValidator.php b/vendor/laravel/framework/src/Illuminate/Routing/Matching/SchemeValidator.php new file mode 100755 index 0000000..009bb94 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Routing/Matching/SchemeValidator.php @@ -0,0 +1,29 @@ +httpOnly()) + { + return ! $request->secure(); + } + elseif ($route->secure()) + { + return $request->secure(); + } + + return true; + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Routing/Matching/UriValidator.php b/vendor/laravel/framework/src/Illuminate/Routing/Matching/UriValidator.php new file mode 100755 index 0000000..b0b4302 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Routing/Matching/UriValidator.php @@ -0,0 +1,22 @@ +path() == '/' ? '/' : '/'.$request->path(); + + return preg_match($route->getCompiled()->getRegex(), rawurldecode($path)); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Routing/Matching/ValidatorInterface.php b/vendor/laravel/framework/src/Illuminate/Routing/Matching/ValidatorInterface.php new file mode 100755 index 0000000..65e5638 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Routing/Matching/ValidatorInterface.php @@ -0,0 +1,17 @@ +generator = $generator; + } + + /** + * Create a new redirect response to the "home" route. + * + * @param int $status + * @return \Illuminate\Http\RedirectResponse + */ + public function home($status = 302) + { + return $this->to($this->generator->route('home'), $status); + } + + /** + * Create a new redirect response to the previous location. + * + * @param int $status + * @param array $headers + * @return \Illuminate\Http\RedirectResponse + */ + public function back($status = 302, $headers = array()) + { + $back = $this->generator->getRequest()->headers->get('referer'); + + return $this->createRedirect($back, $status, $headers); + } + + /** + * Create a new redirect response to the current URI. + * + * @param int $status + * @param array $headers + * @return \Illuminate\Http\RedirectResponse + */ + public function refresh($status = 302, $headers = array()) + { + return $this->to($this->generator->getRequest()->path(), $status, $headers); + } + + /** + * Create a new redirect response, while putting the current URL in the session. + * + * @param string $path + * @param int $status + * @param array $headers + * @param bool $secure + * @return \Illuminate\Http\RedirectResponse + */ + public function guest($path, $status = 302, $headers = array(), $secure = null) + { + $this->session->put('url.intended', $this->generator->full()); + + return $this->to($path, $status, $headers, $secure); + } + + /** + * Create a new redirect response to the previously intended location. + * + * @param string $default + * @param int $status + * @param array $headers + * @param bool $secure + * @return \Illuminate\Http\RedirectResponse + */ + public function intended($default = '/', $status = 302, $headers = array(), $secure = null) + { + $path = $this->session->get('url.intended', $default); + + $this->session->forget('url.intended'); + + return $this->to($path, $status, $headers, $secure); + } + + /** + * Create a new redirect response to the given path. + * + * @param string $path + * @param int $status + * @param array $headers + * @param bool $secure + * @return \Illuminate\Http\RedirectResponse + */ + public function to($path, $status = 302, $headers = array(), $secure = null) + { + $path = $this->generator->to($path, array(), $secure); + + return $this->createRedirect($path, $status, $headers); + } + + /** + * Create a new redirect response to an external URL (no validation). + * + * @param string $path + * @param int $status + * @param array $headers + * @return \Illuminate\Http\RedirectResponse + */ + public function away($path, $status = 302, $headers = array()) + { + return $this->createRedirect($path, $status, $headers); + } + + /** + * Create a new redirect response to the given HTTPS path. + * + * @param string $path + * @param int $status + * @param array $headers + * @return \Illuminate\Http\RedirectResponse + */ + public function secure($path, $status = 302, $headers = array()) + { + return $this->to($path, $status, $headers, true); + } + + /** + * Create a new redirect response to a named route. + * + * @param string $route + * @param array $parameters + * @param int $status + * @param array $headers + * @return \Illuminate\Http\RedirectResponse + */ + public function route($route, $parameters = array(), $status = 302, $headers = array()) + { + $path = $this->generator->route($route, $parameters); + + return $this->to($path, $status, $headers); + } + + /** + * Create a new redirect response to a controller action. + * + * @param string $action + * @param array $parameters + * @param int $status + * @param array $headers + * @return \Illuminate\Http\RedirectResponse + */ + public function action($action, $parameters = array(), $status = 302, $headers = array()) + { + $path = $this->generator->action($action, $parameters); + + return $this->to($path, $status, $headers); + } + + /** + * Create a new redirect response. + * + * @param string $path + * @param int $status + * @param array $headers + * @return \Illuminate\Http\RedirectResponse + */ + protected function createRedirect($path, $status, $headers) + { + $redirect = new RedirectResponse($path, $status, $headers); + + if (isset($this->session)) + { + $redirect->setSession($this->session); + } + + $redirect->setRequest($this->generator->getRequest()); + + return $redirect; + } + + /** + * Get the URL generator instance. + * + * @return \Illuminate\Routing\UrlGenerator + */ + public function getUrlGenerator() + { + return $this->generator; + } + + /** + * Set the active session store. + * + * @param \Illuminate\Session\Store $session + * @return void + */ + public function setSession(SessionStore $session) + { + $this->session = $session; + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Routing/Route.php b/vendor/laravel/framework/src/Illuminate/Routing/Route.php new file mode 100755 index 0000000..d8b834d --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Routing/Route.php @@ -0,0 +1,812 @@ +uri = $uri; + $this->methods = (array) $methods; + $this->action = $this->parseAction($action); + + if (isset($this->action['prefix'])) + { + $this->prefix($this->action['prefix']); + } + } + + /** + * Run the route action and return the response. + * + * @return mixed + */ + public function run() + { + $parameters = array_filter($this->parameters(), function($p) { return isset($p); }); + + return call_user_func_array($this->action['uses'], $parameters); + } + + /** + * Determine if the route matches given request. + * + * @param \Illuminate\Http\Request $request + * @param bool $includingMethod + * @return bool + */ + public function matches(Request $request, $includingMethod = true) + { + $this->compileRoute(); + + foreach ($this->getValidators() as $validator) + { + if ( ! $includingMethod && $validator instanceof MethodValidator) continue; + + if ( ! $validator->matches($this, $request)) return false; + } + + return true; + } + + /** + * Compile the route into a Symfony CompiledRoute instance. + * + * @return void + */ + protected function compileRoute() + { + $optionals = $this->extractOptionalParameters(); + + $uri = preg_replace('/\{(\w+?)\?\}/', '{$1}', $this->uri); + + $this->compiled = with( + + new SymfonyRoute($uri, $optionals, $this->wheres, array(), $this->domain() ?: '') + + )->compile(); + } + + /** + * Get the optional parameters for the route. + * + * @return array + */ + protected function extractOptionalParameters() + { + preg_match_all('/\{(\w+?)\?\}/', $this->uri, $matches); + + $optional = array(); + + if (isset($matches[1])) + { + foreach ($matches[1] as $key) { $optional[$key] = null; } + } + + return $optional; + } + + /** + * Get the "before" filters for the route. + * + * @return array + */ + public function beforeFilters() + { + if ( ! isset($this->action['before'])) return array(); + + return $this->parseFilters($this->action['before']); + } + + /** + * Get the "after" filters for the route. + * + * @return array + */ + public function afterFilters() + { + if ( ! isset($this->action['after'])) return array(); + + return $this->parseFilters($this->action['after']); + } + + /** + * Parse the given filter string. + * + * @param string $filters + * @return array + */ + public static function parseFilters($filters) + { + return array_build(static::explodeFilters($filters), function($key, $value) + { + return Route::parseFilter($value); + }); + } + + /** + * Turn the filters into an array if they aren't already. + * + * @param array|string $filters + * @return array + */ + protected static function explodeFilters($filters) + { + if (is_array($filters)) return static::explodeArrayFilters($filters); + + return explode('|', $filters); + } + + /** + * Flatten out an array of filter declarations. + * + * @param array $filters + * @return array + */ + protected static function explodeArrayFilters(array $filters) + { + $results = array(); + + foreach ($filters as $filter) + { + $results = array_merge($results, explode('|', $filter)); + } + + return $results; + } + + /** + * Parse the given filter into name and parameters. + * + * @param string $filter + * @return array + */ + public static function parseFilter($filter) + { + if ( ! str_contains($filter, ':')) return array($filter, array()); + + return static::parseParameterFilter($filter); + } + + /** + * Parse a filter with parameters. + * + * @param string $filter + * @return array + */ + protected static function parseParameterFilter($filter) + { + list($name, $parameters) = explode(':', $filter, 2); + + return array($name, explode(',', $parameters)); + } + + /** + * Get a given parameter from the route. + * + * @param string $name + * @param mixed $default + * @return string + */ + public function getParameter($name, $default = null) + { + return $this->parameter($name, $default); + } + + /** + * Get a given parameter from the route. + * + * @param string $name + * @param mixed $default + * @return string + */ + public function parameter($name, $default = null) + { + return array_get($this->parameters(), $name) ?: $default; + } + + /** + * Set a parameter to the given value. + * + * @param string $name + * @param mixed $value + * @return void + */ + public function setParameter($name, $value) + { + $this->parameters(); + + $this->parameters[$name] = $value; + } + + /** + * Unset a parameter on the route if it is set. + * + * @param string $name + * @return void + */ + public function forgetParameter($name) + { + $this->parameters(); + + unset($this->parameters[$name]); + } + + /** + * Get the key / value list of parameters for the route. + * + * @return array + * + * @throws \LogicException + */ + public function parameters() + { + if (isset($this->parameters)) + { + return array_map(function($value) + { + return is_string($value) ? urldecode($value) : $value; + + }, $this->parameters); + } + + throw new \LogicException("Route is not bound."); + } + + /** + * Get the key / value list of parameters without null values. + * + * @return array + */ + public function parametersWithoutNulls() + { + return array_filter($this->parameters(), function($p) { return ! is_null($p); }); + } + + /** + * Get all of the parameter names for the route. + * + * @return array + */ + public function parameterNames() + { + if (isset($this->parameterNames)) return $this->parameterNames; + + return $this->parameterNames = $this->compileParameterNames(); + } + + /** + * Get the parameter names for the route. + * + * @return array + */ + protected function compileParameterNames() + { + preg_match_all('/\{(.*?)\}/', $this->domain().$this->uri, $matches); + + return array_map(function($m) { return trim($m, '?'); }, $matches[1]); + } + + /** + * Bind the route to a given request for execution. + * + * @param \Illuminate\Http\Request $request + * @return \Illuminate\Routing\Route + */ + public function bind(Request $request) + { + $this->compileRoute(); + + $this->bindParameters($request); + + return $this; + } + + /** + * Extract the parameter list from the request. + * + * @param \Illuminate\Http\Request $request + * @return array + */ + public function bindParameters(Request $request) + { + // If the route has a regular expression for the host part of the URI, we will + // compile that and get the parameter matches for this domain. We will then + // merge them into this parameters array so that this array is completed. + $params = $this->matchToKeys( + + array_slice($this->bindPathParameters($request), 1) + + ); + + // If the route has a regular expression for the host part of the URI, we will + // compile that and get the parameter matches for this domain. We will then + // merge them into this parameters array so that this array is completed. + if ( ! is_null($this->compiled->getHostRegex())) + { + $params = $this->bindHostParameters( + $request, $params + ); + } + + return $this->parameters = $this->replaceDefaults($params); + } + + /** + * Get the parameter matches for the path portion of the URI. + * + * @param \Illuminate\Http\Request $request + * @return array + */ + protected function bindPathParameters(Request $request) + { + preg_match($this->compiled->getRegex(), '/'.$request->decodedPath(), $matches); + + return $matches; + } + + /** + * Extract the parameter list from the host part of the request. + * + * @param \Illuminate\Http\Request $request + * @return array + */ + protected function bindHostParameters(Request $request, $parameters) + { + preg_match($this->compiled->getHostRegex(), $request->getHost(), $matches); + + return array_merge($this->matchToKeys(array_slice($matches, 1)), $parameters); + } + + /** + * Combine a set of parameter matches with the route's keys. + * + * @param array $matches + * @return array + */ + protected function matchToKeys(array $matches) + { + if (count($this->parameterNames()) == 0) return array(); + + $parameters = array_intersect_key($matches, array_flip($this->parameterNames())); + + return array_filter($parameters, function($value) + { + return is_string($value) && strlen($value) > 0; + }); + } + + /** + * Replace null parameters with their defaults. + * + * @param array $parameters + * @return array + */ + protected function replaceDefaults(array $parameters) + { + foreach ($parameters as $key => &$value) + { + $value = isset($value) ? $value : array_get($this->defaults, $key); + } + + return $parameters; + } + + /** + * Parse the route action into a standard array. + * + * @param \Closure|array $action + * @return array + */ + protected function parseAction($action) + { + // If the action is already a Closure instance, we will just set that instance + // as the "uses" property, because there is nothing else we need to do when + // it is available. Otherwise we will need to find it in the action list. + if ($action instanceof Closure) + { + return array('uses' => $action); + } + + // If no "uses" property has been set, we will dig through the array to find a + // Closure instance within this list. We will set the first Closure we come + // across into the "uses" property that will get fired off by this route. + elseif ( ! isset($action['uses'])) + { + $action['uses'] = $this->findClosure($action); + } + + return $action; + } + + /** + * Find the Closure in an action array. + * + * @param array $action + * @return \Closure + */ + protected function findClosure(array $action) + { + return array_first($action, function($key, $value) + { + return $value instanceof Closure; + }); + } + + /** + * Get the route validators for the instance. + * + * @return array + */ + public static function getValidators() + { + if (isset(static::$validators)) return static::$validators; + + // To match the route, we will use a chain of responsibility pattern with the + // validator implementations. We will spin through each one making sure it + // passes and then we will know if the route as a whole matches request. + return static::$validators = array( + new MethodValidator, new SchemeValidator, + new HostValidator, new UriValidator, + ); + } + + /** + * Add before filters to the route. + * + * @param string $filters + * @return \Illuminate\Routing\Route + */ + public function before($filters) + { + return $this->addFilters('before', $filters); + } + + /** + * Add after filters to the route. + * + * @param string $filters + * @return \Illuminate\Routing\Route + */ + public function after($filters) + { + return $this->addFilters('after', $filters); + } + + /** + * Add the given filters to the route by type. + * + * @param string $type + * @param string $filters + * @return \Illuminate\Routing\Route + */ + protected function addFilters($type, $filters) + { + if (isset($this->action[$type])) + { + $this->action[$type] .= '|'.$filters; + } + else + { + $this->action[$type] = $filters; + } + + return $this; + } + + /** + * Set a default value for the route. + * + * @param string $key + * @param mixed $value + * @return \Illuminate\Routing\Route + */ + public function defaults($key, $value) + { + $this->defaults[$key] = $value; + + return $this; + } + + /** + * Set a regular expression requirement on the route. + * + * @param array|string $name + * @param string $expression + * @return \Illuminate\Routing\Route + */ + public function where($name, $expression = null) + { + foreach ($this->parseWhere($name, $expression) as $name => $expression) + { + $this->wheres[$name] = $expression; + } + + return $this; + } + + /** + * Parse arguments to the where method into an array. + * + * @param array|string $name + * @param string $expression + * @return \Illuminate\Routing\Route + */ + protected function parseWhere($name, $expression) + { + return is_array($name) ? $name : array($name => $expression); + } + + /** + * Set a list of regular expression requirements on the route. + * + * @param array $wheres + * @return \Illuminate\Routing\Route + */ + protected function whereArray(array $wheres) + { + foreach ($wheres as $name => $expression) + { + $this->where($name, $expression); + } + + return $this; + } + + /** + * Add a prefix to the route URI. + * + * @param string $prefix + * @return \Illuminate\Routing\Route + */ + public function prefix($prefix) + { + $this->uri = trim($prefix, '/').'/'.trim($this->uri, '/'); + + return $this; + } + + /** + * Get the URI associated with the route. + * + * @return string + */ + public function getPath() + { + return $this->uri(); + } + + /** + * Get the URI associated with the route. + * + * @return string + */ + public function uri() + { + return $this->uri; + } + + /** + * Get the HTTP verbs the route responds to. + * + * @return array + */ + public function getMethods() + { + return $this->methods(); + } + + /** + * Get the HTTP verbs the route responds to. + * + * @return array + */ + public function methods() + { + return $this->methods; + } + + /** + * Determine if the route only responds to HTTP requests. + * + * @return bool + */ + public function httpOnly() + { + return in_array('http', $this->action, true); + } + + /** + * Determine if the route only responds to HTTPS requests. + * + * @return bool + */ + public function httpsOnly() + { + return $this->secure(); + } + + /** + * Determine if the route only responds to HTTPS requests. + * + * @return bool + */ + public function secure() + { + return in_array('https', $this->action, true); + } + + /** + * Get the domain defined for the route. + * + * @return string|null + */ + public function domain() + { + return array_get($this->action, 'domain'); + } + + /** + * Get the URI that the route responds to. + * + * @return string + */ + public function getUri() + { + return $this->uri; + } + + /** + * Set the URI that the route responds to. + * + * @param string $uri + * @return \Illuminate\Routing\Route + */ + public function setUri($uri) + { + $this->uri = $uri; + + return $this; + } + + /** + * Get the prefix of the route instance. + * + * @return string + */ + public function getPrefix() + { + return array_get($this->action, 'prefix'); + } + + /** + * Get the name of the route instance. + * + * @return string + */ + public function getName() + { + return array_get($this->action, 'as'); + } + + /** + * Get the action name for the route. + * + * @return string + */ + public function getActionName() + { + return array_get($this->action, 'controller', 'Closure'); + } + + /** + * Get the action array for the route. + * + * @return array + */ + public function getAction() + { + return $this->action; + } + + /** + * Set the action array for the route. + * + * @param array $action + * @return \Illuminate\Routing\Route + */ + public function setAction(array $action) + { + $this->action = $action; + + return $this; + } + + /** + * Get the compiled version of the route. + * + * @return \Symfony\Component\Routing\CompiledRoute + */ + public function getCompiled() + { + return $this->compiled; + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Routing/RouteCollection.php b/vendor/laravel/framework/src/Illuminate/Routing/RouteCollection.php new file mode 100755 index 0000000..7ed5132 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Routing/RouteCollection.php @@ -0,0 +1,305 @@ +addToCollections($route); + + $this->addLookups($route); + + return $route; + } + + /** + * Add the given route to the arrays of routes. + * + * @param \Illuminate\Routing\Route $route + * @return void + */ + protected function addToCollections($route) + { + foreach ($route->methods() as $method) + { + $this->routes[$method][$route->domain().$route->getUri()] = $route; + } + + $this->allRoutes[$method.$route->domain().$route->getUri()] = $route; + } + + /** + * Add the route to any look-up tables if necessary. + * + * @param \Illuminate\Routing\Route $route + * @return void + */ + protected function addLookups($route) + { + // If the route has a name, we will add it to the name look-up table so that we + // will quickly be able to find any route associate with a name and not have + // to iterate through every route every time we need to perform a look-up. + $action = $route->getAction(); + + if (isset($action['as'])) + { + $this->nameList[$action['as']] = $route; + } + + // When the route is routing to a controller we will also store the action that + // is used by the route. This will let us reverse route to controllers while + // processing a request and easily generate URLs to the given controllers. + if (isset($action['controller'])) + { + $this->addToActionList($action, $route); + } + } + + /** + * Add a route to the controller action dictionary. + * + * @param array $action + * @param \Illuminate\Routing\Route $route + * @return void + */ + protected function addToActionList($action, $route) + { + if ( ! isset($this->actionList[$action['controller']])) + { + $this->actionList[$action['controller']] = $route; + } + } + + /** + * Find the first route matching a given request. + * + * @param \Illuminate\Http\Request $request + * @return \Illuminate\Routing\Route + * + * @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException + */ + public function match(Request $request) + { + $routes = $this->get($request->getMethod()); + + // First, we will see if we can find a matching route for this current request + // method. If we can, great, we can just return it so that it can be called + // by the consumer. Otherwise we will check for routes with another verb. + $route = $this->check($routes, $request); + + if ( ! is_null($route)) + { + return $route->bind($request); + } + + // If no route was found, we will check if a matching is route is specified on + // another HTTP verb. If it is we will need to throw a MethodNotAllowed and + // inform the user agent of which HTTP verb it should use for this route. + $others = $this->checkForAlternateVerbs($request); + + if (count($others) > 0) + { + return $this->getOtherMethodsRoute($request, $others); + } + + throw new NotFoundHttpException; + } + + /** + * Determine if any routes match on another HTTP verb. + * + * @param \Illuminate\Http\Request $request + * @return array + */ + protected function checkForAlternateVerbs($request) + { + $methods = array_diff(Router::$verbs, array($request->getMethod())); + + // Here we will spin through all verbs except for the current request verb and + // check to see if any routes respond to them. If they do, we will return a + // proper error response with the correct headers on the response string. + $others = array(); + + foreach ($methods as $method) + { + if ( ! is_null($this->check($this->get($method), $request, false))) + { + $others[] = $method; + } + } + + return $others; + } + + /** + * Get a route (if necessary) that responds when other available methods are present. + * + * @param \Illuminate\Http\Request $request + * @param array $others + * @return \Illuminate\Routing\Route + * + * @throws \Symfony\Component\Routing\Exception\MethodNotAllowedHttpException + */ + protected function getOtherMethodsRoute($request, array $others) + { + if ($request->method() == 'OPTIONS') + { + return with(new Route('OPTIONS', $request->path(), function() use ($others) + { + return new Response('', 200, array('Allow' => implode(',', $others))); + + }))->bind($request); + } + else + { + $this->methodNotAllowed($others); + } + } + + /** + * Throw a method not allowed HTTP exception. + * + * @param array $others + * @return void + * + * @throws \Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException + */ + protected function methodNotAllowed(array $others) + { + throw new MethodNotAllowedHttpException($others); + } + + /** + * Determine if a route in the array matches the request. + * + * @param array $routes + * @param \Illuminate\http\Request $request + * @param bool $includingMethod + * @return \Illuminate\Routing\Route|null + */ + protected function check(array $routes, $request, $includingMethod = true) + { + return array_first($routes, function($key, $value) use ($request, $includingMethod) + { + return $value->matches($request, $includingMethod); + }); + } + + /** + * Get all of the routes in the collection. + * + * @param string|null $method + * @return array + */ + protected function get($method = null) + { + if (is_null($method)) return $this->getRoutes(); + + return array_get($this->routes, $method, array()); + } + + /** + * Determine if the route collection contains a given named route. + * + * @param string $name + * @return bool + */ + public function hasNamedRoute($name) + { + return ! is_null($this->getByName($name)); + } + + /** + * Get a route instance by its name. + * + * @param string $name + * @return \Illuminate\Routing\Route|null + */ + public function getByName($name) + { + return isset($this->nameList[$name]) ? $this->nameList[$name] : null; + } + + /** + * Get a route instance by its controller action. + * + * @param string $action + * @return \Illuminate\Routing\Route|null + */ + public function getByAction($action) + { + return isset($this->actionList[$action]) ? $this->actionList[$action] : null; + } + + /** + * Get all of the routes in the collection. + * + * @return array + */ + public function getRoutes() + { + return array_values($this->allRoutes); + } + + /** + * Get an iterator for the items. + * + * @return ArrayIterator + */ + public function getIterator() + { + return new ArrayIterator($this->getRoutes()); + } + + /** + * Count the number of items in the collection. + * + * @return int + */ + public function count() + { + return count($this->getRoutes()); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Routing/RouteFiltererInterface.php b/vendor/laravel/framework/src/Illuminate/Routing/RouteFiltererInterface.php new file mode 100755 index 0000000..2cc0d12 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Routing/RouteFiltererInterface.php @@ -0,0 +1,26 @@ +events = $events; + $this->routes = new RouteCollection; + $this->container = $container ?: new Container; + + $this->bind('_missing', function($v) { return explode('/', $v); }); + } + + /** + * Register a new GET route with the router. + * + * @param string $uri + * @param \Closure|array|string $action + * @return \Illuminate\Routing\Route + */ + public function get($uri, $action) + { + return $this->addRoute(array('GET', 'HEAD'), $uri, $action); + } + + /** + * Register a new POST route with the router. + * + * @param string $uri + * @param \Closure|array|string $action + * @return \Illuminate\Routing\Route + */ + public function post($uri, $action) + { + return $this->addRoute('POST', $uri, $action); + } + + /** + * Register a new PUT route with the router. + * + * @param string $uri + * @param \Closure|array|string $action + * @return \Illuminate\Routing\Route + */ + public function put($uri, $action) + { + return $this->addRoute('PUT', $uri, $action); + } + + /** + * Register a new PATCH route with the router. + * + * @param string $uri + * @param \Closure|array|string $action + * @return \Illuminate\Routing\Route + */ + public function patch($uri, $action) + { + return $this->addRoute('PATCH', $uri, $action); + } + + /** + * Register a new DELETE route with the router. + * + * @param string $uri + * @param \Closure|array|string $action + * @return \Illuminate\Routing\Route + */ + public function delete($uri, $action) + { + return $this->addRoute('DELETE', $uri, $action); + } + + /** + * Register a new OPTIONS route with the router. + * + * @param string $uri + * @param \Closure|array|string $action + * @return \Illuminate\Routing\Route + */ + public function options($uri, $action) + { + return $this->addRoute('OPTIONS', $uri, $action); + } + + /** + * Register a new route responding to all verbs. + * + * @param string $uri + * @param \Closure|array|string $action + * @return \Illuminate\Routing\Route + */ + public function any($uri, $action) + { + $verbs = array('GET', 'HEAD', 'POST', 'PUT', 'PATCH', 'DELETE'); + + return $this->addRoute($verbs, $uri, $action); + } + + /** + * Register a new route with the given verbs. + * + * @param array|string $methods + * @param string $uri + * @param \Closure|array|string $action + * @return \Illuminate\Routing\Route + */ + public function match($methods, $uri, $action) + { + return $this->addRoute($methods, $uri, $action); + } + + /** + * Register an array of controllers with wildcard routing. + * + * @param array $controllers + * @return void + */ + public function controllers(array $controllers) + { + foreach ($controllers as $uri => $name) + { + $this->controller($uri, $name); + } + } + + /** + * Route a controller to a URI with wildcard routing. + * + * @param string $uri + * @param string $controller + * @param array $names + * @return void + */ + public function controller($uri, $controller, $names = array()) + { + $prepended = $controller; + + // First, we will check to see if a controller prefix has been registered in + // the route group. If it has, we will need to prefix it before trying to + // reflect into the class instance and pull out the method for routing. + if (count($this->groupStack) > 0) + { + $prepended = $this->prependGroupUses($controller); + } + + $routable = $this->getInspector()->getRoutable($prepended, $uri); + + // When a controller is routed using this method, we use Reflection to parse + // out all of the routable methods for the controller, then register each + // route explicitly for the developers, so reverse routing is possible. + foreach ($routable as $method => $routes) + { + foreach ($routes as $route) + { + $this->registerInspected($route, $controller, $method, $names); + } + } + + $this->addFallthroughRoute($controller, $uri); + } + + /** + * Register an inspected controller route. + * + * @param array $route + * @param string $controller + * @param string $method + * @param array $names + * @return void + */ + protected function registerInspected($route, $controller, $method, &$names) + { + $action = array('uses' => $controller.'@'.$method); + + // If a given controller method has been named, we will assign the name to the + // controller action array, which provides for a short-cut to method naming + // so you don't have to define an individual route for these controllers. + $action['as'] = array_pull($names, $method); + + $this->{$route['verb']}($route['uri'], $action); + } + + /** + * Add a fallthrough route for a controller. + * + * @param string $controller + * @param string $uri + * @return void + */ + protected function addFallthroughRoute($controller, $uri) + { + $missing = $this->any($uri.'/{_missing}', $controller.'@missingMethod'); + + $missing->where('_missing', '(.*)'); + } + + /** + * Route a resource to a controller. + * + * @param string $name + * @param string $controller + * @param array $options + * @return void + */ + public function resource($name, $controller, array $options = array()) + { + // If the resource name contains a slash, we will assume the developer wishes to + // register these resource routes with a prefix so we will set that up out of + // the box so they don't have to mess with it. Otherwise, we will continue. + if (str_contains($name, '/')) + { + $this->prefixedResource($name, $controller, $options); + + return; + } + + // We need to extract the base resource from the resource name. Nested resources + // are supported in the framework, but we need to know what name to use for a + // place-holder on the route wildcards, which should be the base resources. + $base = $this->getResourceWildcard(last(explode('.', $name))); + + $defaults = $this->resourceDefaults; + + foreach ($this->getResourceMethods($defaults, $options) as $m) + { + $this->{'addResource'.ucfirst($m)}($name, $base, $controller, $options); + } + } + + /** + * Build a set of prefixed resource routes. + * + * @param string $name + * @param string $controller + * @param array $options + * @return void + */ + protected function prefixedResource($name, $controller, array $options) + { + list($name, $prefix) = $this->getResourcePrefix($name); + + // We need to extract the base resource from the resource name. Nested resources + // are supported in the framework, but we need to know what name to use for a + // place-holder on the route wildcards, which should be the base resources. + $callback = function($me) use ($name, $controller, $options) + { + $me->resource($name, $controller, $options); + }; + + return $this->group(compact('prefix'), $callback); + } + + /** + * Extract the resource and prefix from a resource name. + * + * @param string $name + * @return array + */ + protected function getResourcePrefix($name) + { + $segments = explode('/', $name); + + // To get the prefix, we will take all of the name segments and implode them on + // a slash. This will generate a proper URI prefix for us. Then we take this + // last segment, which will be considered the final resources name we use. + $prefix = implode('/', array_slice($segments, 0, -1)); + + return array($segments[count($segments) - 1], $prefix); + } + + /** + * Get the applicable resource methods. + * + * @param array $defaults + * @param array $options + * @return array + */ + protected function getResourceMethods($defaults, $options) + { + if (isset($options['only'])) + { + return array_intersect($defaults, $options['only']); + } + elseif (isset($options['except'])) + { + return array_diff($defaults, $options['except']); + } + + return $defaults; + } + + /** + * Get the base resource URI for a given resource. + * + * @param string $resource + * @return string + */ + public function getResourceUri($resource) + { + if ( ! str_contains($resource, '.')) return $resource; + + // Once we have built the base URI, we'll remove the wildcard holder for this + // base resource name so that the individual route adders can suffix these + // paths however they need to, as some do not have any wildcards at all. + $segments = explode('.', $resource); + + $uri = $this->getNestedResourceUri($segments); + + return str_replace('/{'.$this->getResourceWildcard(last($segments)).'}', '', $uri); + } + + /** + * Get the URI for a nested resource segment array. + * + * @param array $segments + * @return string + */ + protected function getNestedResourceUri(array $segments) + { + $me = $this; + + // We will spin through the segments and create a place-holder for each of the + // resource segments, as well as the resource itself. Then we should get an + // entire string for the resource URI that contains all nested resources. + return implode('/', array_map(function($s) use ($me) + { + return $s.'/{'.$me->getResourceWildcard($s).'}'; + + }, $segments)); + } + + /** + * Get the action array for a resource route. + * + * @param string $resource + * @param string $controller + * @param string $method + * @param array $options + * @return array + */ + protected function getResourceAction($resource, $controller, $method, $options) + { + $name = $this->getResourceName($resource, $method, $options); + + return array('as' => $name, 'uses' => $controller.'@'.$method); + } + + /** + * Get the name for a given resource. + * + * @param string $resource + * @param string $method + * @param array $options + * @return string + */ + protected function getResourceName($resource, $method, $options) + { + if (isset($options['names'][$method])) return $options['names'][$method]; + + // If a global prefix has been assigned to all names for this resource, we will + // grab that so we can prepend it onto the name when we create this name for + // the resource action. Otherwise we'll just use an empty string for here. + $prefix = isset($options['as']) ? $options['as'].'.' : ''; + + if (count($this->groupStack) == 0) + { + return $prefix.$resource.'.'.$method; + } + + return $this->getGroupResourceName($prefix, $resource, $method); + } + + /** + * Get the resource name for a grouped resource. + * + * @param string $prefix + * @param string $resource + * @param string $method + * @return string + */ + protected function getGroupResourceName($prefix, $resource, $method) + { + $group = str_replace('/', '.', $this->getLastGroupPrefix()); + + return trim("{$prefix}{$group}.{$resource}.{$method}", '.'); + } + + /** + * Format a resource wildcard for usage. + * + * @param string $value + * @return string + */ + public function getResourceWildcard($value) + { + return str_replace('-', '_', $value); + } + + /** + * Add the index method for a resourceful route. + * + * @param string $name + * @param string $base + * @param string $controller + * @param array $options + * @return Route + */ + protected function addResourceIndex($name, $base, $controller, $options) + { + $action = $this->getResourceAction($name, $controller, 'index', $options); + + return $this->get($this->getResourceUri($name), $action); + } + + /** + * Add the create method for a resourceful route. + * + * @param string $name + * @param string $base + * @param string $controller + * @param array $options + * @return Route + */ + protected function addResourceCreate($name, $base, $controller, $options) + { + $action = $this->getResourceAction($name, $controller, 'create', $options); + + return $this->get($this->getResourceUri($name).'/create', $action); + } + + /** + * Add the store method for a resourceful route. + * + * @param string $name + * @param string $base + * @param string $controller + * @param array $options + * @return Route + */ + protected function addResourceStore($name, $base, $controller, $options) + { + $action = $this->getResourceAction($name, $controller, 'store', $options); + + return $this->post($this->getResourceUri($name), $action); + } + + /** + * Add the show method for a resourceful route. + * + * @param string $name + * @param string $base + * @param string $controller + * @param array $options + * @return Route + */ + protected function addResourceShow($name, $base, $controller, $options) + { + $uri = $this->getResourceUri($name).'/{'.$base.'}'; + + return $this->get($uri, $this->getResourceAction($name, $controller, 'show', $options)); + } + + /** + * Add the edit method for a resourceful route. + * + * @param string $name + * @param string $base + * @param string $controller + * @param array $options + * @return Route + */ + protected function addResourceEdit($name, $base, $controller, $options) + { + $uri = $this->getResourceUri($name).'/{'.$base.'}/edit'; + + return $this->get($uri, $this->getResourceAction($name, $controller, 'edit', $options)); + } + + /** + * Add the update method for a resourceful route. + * + * @param string $name + * @param string $base + * @param string $controller + * @param array $options + * @return void + */ + protected function addResourceUpdate($name, $base, $controller, $options) + { + $this->addPutResourceUpdate($name, $base, $controller, $options); + + return $this->addPatchResourceUpdate($name, $base, $controller); + } + + /** + * Add the update method for a resourceful route. + * + * @param string $name + * @param string $base + * @param string $controller + * @param array $options + * @return Route + */ + protected function addPutResourceUpdate($name, $base, $controller, $options) + { + $uri = $this->getResourceUri($name).'/{'.$base.'}'; + + return $this->put($uri, $this->getResourceAction($name, $controller, 'update', $options)); + } + + /** + * Add the update method for a resourceful route. + * + * @param string $name + * @param string $base + * @param string $controller + * @return void + */ + protected function addPatchResourceUpdate($name, $base, $controller) + { + $uri = $this->getResourceUri($name).'/{'.$base.'}'; + + $this->patch($uri, $controller.'@update'); + } + + /** + * Add the destroy method for a resourceful route. + * + * @param string $name + * @param string $base + * @param string $controller + * @param array $options + * @return Route + */ + protected function addResourceDestroy($name, $base, $controller, $options) + { + $action = $this->getResourceAction($name, $controller, 'destroy', $options); + + return $this->delete($this->getResourceUri($name).'/{'.$base.'}', $action); + } + + /** + * Create a route group with shared attributes. + * + * @param array $attributes + * @param Closure $callback + * @return void + */ + public function group(array $attributes, Closure $callback) + { + $this->updateGroupStack($attributes); + + // Once we have updated the group stack, we will execute the user Closure and + // merge in the groups attributes when the route is created. After we have + // run the callback, we will pop the attributes off of this group stack. + call_user_func($callback, $this); + + array_pop($this->groupStack); + } + + /** + * Update the group stack with the given attributes. + * + * @param array $attributes + * @return void + */ + protected function updateGroupStack(array $attributes) + { + if (count($this->groupStack) > 0) + { + $attributes = $this->mergeGroup($attributes, last($this->groupStack)); + } + + $this->groupStack[] = $attributes; + } + + /** + * Merge the given array with the last group stack. + * + * @param array $new + * @return array + */ + public function mergeWithLastGroup($new) + { + return $this->mergeGroup($new, last($this->groupStack)); + } + + /** + * Merge the given group attributes. + * + * @param array $new + * @param array $old + * @return array + */ + public static function mergeGroup($new, $old) + { + $new['namespace'] = static::formatUsesPrefix($new, $old); + + $new['prefix'] = static::formatGroupPrefix($new, $old); + + if (isset($new['domain'])) unset($old['domain']); + + return array_merge_recursive(array_except($old, array('namespace', 'prefix')), $new); + } + + /** + * Format the uses prefix for the new group attributes. + * + * @param array $new + * @param array $old + * @return string + */ + protected static function formatUsesPrefix($new, $old) + { + if (isset($new['namespace'])) + { + return trim(array_get($old, 'namespace'), '\\').'\\'.trim($new['namespace'], '\\'); + } + else + { + return array_get($old, 'namespace'); + } + } + + /** + * Format the prefix for the new group attributes. + * + * @param array $new + * @param array $old + * @return string + */ + protected static function formatGroupPrefix($new, $old) + { + if (isset($new['prefix'])) + { + return trim(array_get($old, 'prefix'), '/').'/'.trim($new['prefix'], '/'); + } + else + { + return array_get($old, 'prefix'); + } + } + + /** + * Get the prefix from the last group on the stack. + * + * @return string + */ + protected function getLastGroupPrefix() + { + if (count($this->groupStack) > 0) + { + return array_get(last($this->groupStack), 'prefix', ''); + } + + return ''; + } + + /** + * Add a route to the underlying route collection. + * + * @param array|string $methods + * @param string $uri + * @param \Closure|array|string $action + * @return \Illuminate\Routing\Route + */ + protected function addRoute($methods, $uri, $action) + { + return $this->routes->add($this->createRoute($methods, $uri, $action)); + } + + /** + * Create a new route instance. + * + * @param array|string $methods + * @param string $uri + * @param mixed $action + * @return \Illuminate\Routing\Route + */ + protected function createRoute($methods, $uri, $action) + { + // If the route is routing to a controller we will parse the route action into + // an acceptable array format before registering it and creating this route + // instance itself. We need to build the Closure that will call this out. + if ($this->routingToController($action)) + { + $action = $this->getControllerAction($action); + } + + $route = $this->newRoute( + $methods, $uri = $this->prefix($uri), $action + ); + + $route->where($this->patterns); + + // If we have groups that need to be merged, we will merge them now after this + // route has already been created and is ready to go. After we're done with + // the merge we will be ready to return the route back out to the caller. + if (count($this->groupStack) > 0) + { + $this->mergeController($route); + } + + return $route; + } + + /** + * Create a new Route object. + * + * @param array|string $methods + * @param string $uri + * @param mixed $action + * @return \Illuminate\Routing\Route + */ + protected function newRoute($methods, $uri, $action) + { + return new Route($methods, $uri, $action); + } + + /** + * Prefix the given URI with the last prefix. + * + * @param string $uri + * @return string + */ + protected function prefix($uri) + { + return trim(trim($this->getLastGroupPrefix(), '/').'/'.trim($uri, '/'), '/') ?: '/'; + } + + /** + * Merge the group stack with the controller action. + * + * @param \Illuminate\Routing\Route $route + * @return void + */ + protected function mergeController($route) + { + $action = $this->mergeWithLastGroup($route->getAction()); + + $route->setAction($action); + } + + /** + * Determine if the action is routing to a controller. + * + * @param array $action + * @return bool + */ + protected function routingToController($action) + { + if ($action instanceof Closure) return false; + + return is_string($action) || is_string(array_get($action, 'uses')); + } + + /** + * Add a controller based route action to the action array. + * + * @param array|string $action + * @return array + */ + protected function getControllerAction($action) + { + if (is_string($action)) $action = array('uses' => $action); + + // Here we'll get an instance of this controller dispatcher and hand it off to + // the Closure so it will be used to resolve the class instances out of our + // IoC container instance and call the appropriate methods on the class. + if (count($this->groupStack) > 0) + { + $action['uses'] = $this->prependGroupUses($action['uses']); + } + + // Here we'll get an instance of this controller dispatcher and hand it off to + // the Closure so it will be used to resolve the class instances out of our + // IoC container instance and call the appropriate methods on the class. + $action['controller'] = $action['uses']; + + $closure = $this->getClassClosure($action['uses']); + + return array_set($action, 'uses', $closure); + } + + /** + * Get the Closure for a controller based action. + * + * @param string $controller + * @return \Closure + */ + protected function getClassClosure($controller) + { + $me = $this; + + // Here we'll get an instance of this controller dispatcher and hand it off to + // the Closure so it will be used to resolve the class instances out of our + // IoC container instance and call the appropriate methods on the class. + $d = $this->getControllerDispatcher(); + + return function() use ($me, $d, $controller) + { + $route = $me->current(); + + $request = $me->getCurrentRequest(); + + // Now we can split the controller and method out of the action string so that we + // can call them appropriately on the class. This controller and method are in + // in the Class@method format and we need to explode them out then use them. + list($class, $method) = explode('@', $controller); + + return $d->dispatch($route, $request, $class, $method); + }; + } + + /** + * Prepend the last group uses onto the use clause. + * + * @param string $uses + * @return string + */ + protected function prependGroupUses($uses) + { + $group = last($this->groupStack); + + return isset($group['namespace']) ? $group['namespace'].'\\'.$uses : $uses; + } + + /** + * Dispatch the request to the application. + * + * @param \Illuminate\Http\Request $request + * @return \Illuminate\Http\Response + */ + public function dispatch(Request $request) + { + $this->currentRequest = $request; + + // If no response was returned from the before filter, we will call the proper + // route instance to get the response. If no route is found a response will + // still get returned based on why no routes were found for this request. + $response = $this->callFilter('before', $request); + + if (is_null($response)) + { + $response = $this->dispatchToRoute($request); + } + + $response = $this->prepareResponse($request, $response); + + // Once this route has run and the response has been prepared, we will run the + // after filter to do any last work on the response or for this application + // before we will return the response back to the consuming code for use. + $this->callFilter('after', $request, $response); + + return $response; + } + + /** + * Dispatch the request to a route and return the response. + * + * @param \Illuminate\Http\Request $request + * @return mixed + */ + public function dispatchToRoute(Request $request) + { + $route = $this->findRoute($request); + + $this->events->fire('router.matched', array($route, $request)); + + // Once we have successfully matched the incoming request to a given route we + // can call the before filters on that route. This works similar to global + // filters in that if a response is returned we will not call the route. + $response = $this->callRouteBefore($route, $request); + + if (is_null($response)) + { + $response = $route->run($request); + } + + $response = $this->prepareResponse($request, $response); + + // After we have a prepared response from the route or filter we will call to + // the "after" filters to do any last minute processing on this request or + // response object before the response is returned back to the consumer. + $this->callRouteAfter($route, $request, $response); + + return $response; + } + + /** + * Find the route matching a given request. + * + * @param \Illuminate\Http\Request $request + * @return \Illuminate\Routing\Route + */ + protected function findRoute($request) + { + $this->current = $route = $this->routes->match($request); + + return $this->substituteBindings($route); + } + + /** + * Substitute the route bindings onto the route. + * + * @param \Illuminate\Routing\Route $route + * @return \Illuminate\Routing\Route + */ + protected function substituteBindings($route) + { + foreach ($route->parameters() as $key => $value) + { + if (isset($this->binders[$key])) + { + $route->setParameter($key, $this->performBinding($key, $value, $route)); + } + } + + return $route; + } + + /** + * Call the binding callback for the given key. + * + * @param string $key + * @param string $value + * @param \Illuminate\Routing\Route $route + * @return mixed + */ + protected function performBinding($key, $value, $route) + { + return call_user_func($this->binders[$key], $value, $route); + } + + /** + * Register a route matched event listener. + * + * @param callable $callback + * @return void + */ + public function matched($callback) + { + $this->events->listen('router.matched', $callback); + } + + /** + * Register a new "before" filter with the router. + * + * @param mixed $callback + * @return void + */ + public function before($callback) + { + $this->addGlobalFilter('before', $callback); + } + + /** + * Register a new "after" filter with the router. + * + * @param mixed $callback + * @return void + */ + public function after($callback) + { + $this->addGlobalFilter('after', $callback); + } + + /** + * Register a new global filter with the router. + * + * @param string $filter + * @param mixed $callback + * @return void + */ + protected function addGlobalFilter($filter, $callback) + { + $this->events->listen('router.'.$filter, $this->parseFilter($callback)); + } + + /** + * Register a new filter with the router. + * + * @param string $name + * @param mixed $callback + * @return void + */ + public function filter($name, $callback) + { + $this->events->listen('router.filter: '.$name, $this->parseFilter($callback)); + } + + /** + * Parse the registered filter. + * + * @param \Closure|string $callback + * @return mixed + */ + protected function parseFilter($callback) + { + if (is_string($callback) && ! str_contains($callback, '@')) + { + return $callback.'@filter'; + } + else + { + return $callback; + } + } + + /** + * Register a pattern-based filter with the router. + * + * @param string $pattern + * @param string $name + * @param array|null $methods + */ + public function when($pattern, $name, $methods = null) + { + if ( ! is_null($methods)) $methods = array_map('strtoupper', (array) $methods); + + $this->patternFilters[$pattern][] = compact('name', 'methods'); + } + + /** + * Register a regular expression based filter with the router. + * + * @param string $pattern + * @param string $name + * @param array|null $methods + * @return void + */ + public function whenRegex($pattern, $name, $methods = null) + { + if ( ! is_null($methods)) $methods = array_map('strtoupper', (array) $methods); + + $this->regexFilters[$pattern][] = compact('name', 'methods'); + } + + /** + * Register a model binder for a wildcard. + * + * @param string $key + * @param string $class + * @param \Closure $callback + * @return void + * + * @throws NotFoundHttpException + */ + public function model($key, $class, Closure $callback = null) + { + return $this->bind($key, function($value) use ($class, $callback) + { + if (is_null($value)) return null; + + // For model binders, we will attempt to retrieve the models using the find + // method on the model instance. If we cannot retrieve the models we'll + // throw a not found exception otherwise we will return the instance. + if ($model = with(new $class)->find($value)) + { + return $model; + } + + // If a callback was supplied to the method we will call that to determine + // what we should do when the model is not found. This just gives these + // developer a little greater flexibility to decide what will happen. + if ($callback instanceof Closure) + { + return call_user_func($callback); + } + + throw new NotFoundHttpException; + }); + } + + /** + * Add a new route parameter binder. + * + * @param string $key + * @param callable $binder + * @return void + */ + public function bind($key, $binder) + { + $this->binders[str_replace('-', '_', $key)] = $binder; + } + + /** + * Set a global where pattern on all routes + * + * @param string $key + * @param string $pattern + * @return void + */ + public function pattern($key, $pattern) + { + $this->patterns[$key] = $pattern; + } + + /** + * Call the given filter with the request and response. + * + * @param string $filter + * @param \Illuminate\Http\Request $request + * @param \Illuminate\Http\Response $response + * @return mixed + */ + protected function callFilter($filter, $request, $response = null) + { + if ( ! $this->filtering) return null; + + return $this->events->until('router.'.$filter, array($request, $response)); + } + + /** + * Call the given route's before filters. + * + * @param \Illuminate\Routing\Route $route + * @param \Illuminate\Http\Request $request + * @return mixed + */ + public function callRouteBefore($route, $request) + { + $response = $this->callPatternFilters($route, $request); + + return $response ?: $this->callAttachedBefores($route, $request); + } + + /** + * Call the pattern based filters for the request. + * + * @param \Illuminate\Routing\Route $route + * @param \Illuminate\Http\Request $request + * @return mixed|null + */ + protected function callPatternFilters($route, $request) + { + foreach ($this->findPatternFilters($request) as $filter => $parameters) + { + $response = $this->callRouteFilter($filter, $parameters, $route, $request); + + if ( ! is_null($response)) return $response; + } + } + + /** + * Find the patterned filters matching a request. + * + * @param \Illuminate\Http\Request $request + * @return array + */ + public function findPatternFilters($request) + { + $results = array(); + + list($path, $method) = array($request->path(), $request->getMethod()); + + foreach ($this->patternFilters as $pattern => $filters) + { + // To find the patterned middlewares for a request, we just need to check these + // registered patterns against the path info for the current request to this + // applications, and when it matches we will merge into these middlewares. + if (str_is($pattern, $path)) + { + $merge = $this->patternsByMethod($method, $filters); + + $results = array_merge($results, $merge); + } + } + + foreach ($this->regexFilters as $pattern => $filters) + { + // To find the patterned middlewares for a request, we just need to check these + // registered patterns against the path info for the current request to this + // applications, and when it matches we will merge into these middlewares. + if (preg_match($pattern, $path)) + { + $merge = $this->patternsByMethod($method, $filters); + + $results = array_merge($results, $merge); + } + } + + return $results; + } + + /** + * Filter pattern filters that don't apply to the request verb. + * + * @param \Illuminate\Http\Request $request + * @param array $filters + * @return array + */ + protected function patternsByMethod($method, $filters) + { + $results = array(); + + foreach ($filters as $filter) + { + // The idea here is to check and see if the pattern filter applies to this HTTP + // request based on the request methods. Pattern filters might be limited by + // the request verb to make it simply to assign to the given verb at once. + if ($this->filterSupportsMethod($filter, $method)) + { + $parsed = Route::parseFilters($filter['name']); + + $results = array_merge($results, $parsed); + } + } + + return $results; + } + + /** + * Determine if the given pattern filters applies to a given method. + * + * @param array $filter + * @param array $method + * @return bool + */ + protected function filterSupportsMethod($filter, $method) + { + $methods = $filter['methods']; + + return (is_null($methods) || in_array($method, $methods)); + } + + /** + * Call the given route's before (non-pattern) filters. + * + * @param \Illuminate\Routing\Route $route + * @param \Illuminate\Http\Request $request + * @return mixed + */ + protected function callAttachedBefores($route, $request) + { + foreach ($route->beforeFilters() as $filter => $parameters) + { + $response = $this->callRouteFilter($filter, $parameters, $route, $request); + + if ( ! is_null($response)) return $response; + } + } + + /** + * Call the given route's before filters. + * + * @param \Illuminate\Routing\Route $route + * @param \Illuminate\Http\Request $request + * @param \Illuminate\Http\Response $response + * @return mixed + */ + public function callRouteAfter($route, $request, $response) + { + foreach ($route->afterFilters() as $filter => $parameters) + { + $this->callRouteFilter($filter, $parameters, $route, $request, $response); + } + } + + /** + * Call the given route filter. + * + * @param string $filter + * @param array $parameters + * @param \Illuminate\Routing\Route $route + * @param \Illuminate\Http\Request $request + * @param \Illuminate\Http\Response|null $response + * @return mixed + */ + public function callRouteFilter($filter, $parameters, $route, $request, $response = null) + { + if ( ! $this->filtering) return null; + + $data = array_merge(array($route, $request, $response), $parameters); + + return $this->events->until('router.filter: '.$filter, $this->cleanFilterParameters($data)); + } + + /** + * Clean the parameters being passed to a filter callback. + * + * @param array $parameters + * @return array + */ + protected function cleanFilterParameters(array $parameters) + { + return array_filter($parameters, function($p) + { + return ! is_null($p) && $p !== ''; + }); + } + + /** + * Create a response instance from the given value. + * + * @param \Symfony\Component\HttpFoundation\Request $request + * @param mixed $response + * @return \Illuminate\Http\Response + */ + protected function prepareResponse($request, $response) + { + if ( ! $response instanceof SymfonyResponse) + { + $response = new Response($response); + } + + return $response->prepare($request); + } + + /** + * Run a callback with filters disable on the router. + * + * @param callable $callback + * @return void + */ + public function withoutFilters($callback) + { + $this->disableFilters(); + + call_user_func($callback); + + $this->enableFilters(); + } + + /** + * Enable route filtering on the router. + * + * @return void + */ + public function enableFilters() + { + $this->filtering = true; + } + + /** + * Disable route filtering on the router. + * + * @return void + */ + public function disableFilters() + { + $this->filtering = false; + } + + /** + * Get a route parameter for the current route. + * + * @param string $key + * @param string $default + * @return mixed + */ + public function input($key, $default = null) + { + return $this->current()->parameter($key, $default); + } + + /** + * Get the currently dispatched route instance. + * + * @return \Illuminate\Routing\Route + */ + public function getCurrentRoute() + { + return $this->current(); + } + + /** + * Get the currently dispatched route instance. + * + * @return \Illuminate\Routing\Route + */ + public function current() + { + return $this->current; + } + + /** + * Get the current route name. + * + * @return string|null + */ + public function currentRouteName() + { + return ($this->current()) ? $this->current()->getName() : null; + } + + /** + * Alias for the "currentRouteNamed" method. + * + * @param dynamic string + * @return bool + */ + public function is() + { + foreach (func_get_args() as $pattern) + { + if (str_is($pattern, $this->currentRouteName())) + { + return true; + } + } + + return false; + } + + /** + * Determine if the current route matches a given name. + * + * @param string $name + * @return bool + */ + public function currentRouteNamed($name) + { + return ($this->current()) ? $this->current()->getName() == $name : false; + } + + /** + * Get the current route action. + * + * @return string|null + */ + public function currentRouteAction() + { + $action = $this->current()->getAction(); + + return isset($action['controller']) ? $action['controller'] : null; + } + + /** + * Alias for the "currentRouteUses" method. + * + * @param dynamic string + * @return bool + */ + public function isAction() + { + foreach (func_get_args() as $pattern) + { + if (str_is($pattern, $this->currentRouteAction())) + { + return true; + } + } + + return false; + } + + /** + * Determine if the current route action matches a given action. + * + * @param string $action + * @return bool + */ + public function currentRouteUses($action) + { + return $this->currentRouteAction() == $action; + } + + /** + * Get the request currently being dispatched. + * + * @return \Illuminate\Http\Request + */ + public function getCurrentRequest() + { + return $this->currentRequest; + } + + /** + * Get the underlying route collection. + * + * @return \Illuminate\Routing\RouteCollection + */ + public function getRoutes() + { + return $this->routes; + } + + /** + * Get the controller dispatcher instance. + * + * @return \Illuminate\Routing\ControllerDispatcher + */ + public function getControllerDispatcher() + { + if (is_null($this->controllerDispatcher)) + { + $this->controllerDispatcher = new ControllerDispatcher($this, $this->container); + } + + return $this->controllerDispatcher; + } + + /** + * Set the controller dispatcher instance. + * + * @param \Illuminate\Routing\ControllerDispatcher $dispatcher + * @return void + */ + public function setControllerDispatcher(ControllerDispatcher $dispatcher) + { + $this->controllerDispatcher = $dispatcher; + } + + /** + * Get a controller inspector instance. + * + * @return \Illuminate\Routing\ControllerInspector + */ + public function getInspector() + { + return $this->inspector ?: $this->inspector = new ControllerInspector; + } + + /** + * Get the response for a given request. + * + * @param \Symfony\Component\HttpFoundation\Request $request + * @return \Symfony\Component\HttpFoundation\Response + */ + public function handle(SymfonyRequest $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true) + { + return $this->dispatch(Request::createFromBase($request)); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Routing/RoutingServiceProvider.php b/vendor/laravel/framework/src/Illuminate/Routing/RoutingServiceProvider.php new file mode 100755 index 0000000..f08b9f2 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Routing/RoutingServiceProvider.php @@ -0,0 +1,88 @@ +registerRouter(); + + $this->registerUrlGenerator(); + + $this->registerRedirector(); + } + + /** + * Register the router instance. + * + * @return void + */ + protected function registerRouter() + { + $this->app['router'] = $this->app->share(function($app) + { + $router = new Router($app['events'], $app); + + // If the current application environment is "testing", we will disable the + // routing filters, since they can be tested independently of the routes + // and just get in the way of our typical controller testing concerns. + if ($app['env'] == 'testing') + { + $router->disableFilters(); + } + + return $router; + }); + } + + /** + * Register the URL generator service. + * + * @return void + */ + protected function registerUrlGenerator() + { + $this->app['url'] = $this->app->share(function($app) + { + // The URL generator needs the route collection that exists on the router. + // Keep in mind this is an object, so we're passing by references here + // and all the registered routes will be available to the generator. + $routes = $app['router']->getRoutes(); + + return new UrlGenerator($routes, $app->rebinding('request', function($app, $request) + { + $app['url']->setRequest($request); + })); + }); + } + + /** + * Register the Redirector service. + * + * @return void + */ + protected function registerRedirector() + { + $this->app['redirect'] = $this->app->share(function($app) + { + $redirector = new Redirector($app['url']); + + // If the session is set on the application instance, we'll inject it into + // the redirector instance. This allows the redirect responses to allow + // for the quite convenient "with" methods that flash to the session. + if (isset($app['session.store'])) + { + $redirector->setSession($app['session.store']); + } + + return $redirector; + }); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Routing/UrlGenerator.php b/vendor/laravel/framework/src/Illuminate/Routing/UrlGenerator.php new file mode 100755 index 0000000..33b62bf --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Routing/UrlGenerator.php @@ -0,0 +1,496 @@ + '/', + '%40' => '@', + '%3A' => ':', + '%3B' => ';', + '%2C' => ',', + '%3D' => '=', + '%2B' => '+', + '%21' => '!', + '%2A' => '*', + '%7C' => '|', + ); + + /** + * Create a new URL Generator instance. + * + * @param \Illuminate\Routing\RouteCollection $routes + * @param \Symfony\Component\HttpFoundation\Request $request + * @return void + */ + public function __construct(RouteCollection $routes, Request $request) + { + $this->routes = $routes; + + $this->setRequest($request); + } + + /** + * Get the full URL for the current request. + * + * @return string + */ + public function full() + { + return $this->request->fullUrl(); + } + + /** + * Get the current URL for the request. + * + * @return string + */ + public function current() + { + return $this->to($this->request->getPathInfo()); + } + + /** + * Get the URL for the previous request. + * + * @return string + */ + public function previous() + { + return $this->to($this->request->headers->get('referer')); + } + + /** + * Generate a absolute URL to the given path. + * + * @param string $path + * @param mixed $extra + * @param bool $secure + * @return string + */ + public function to($path, $extra = array(), $secure = null) + { + // First we will check if the URL is already a valid URL. If it is we will not + // try to generate a new one but will simply return the URL as is, which is + // convenient since developers do not always have to check if it's valid. + if ($this->isValidUrl($path)) return $path; + + $scheme = $this->getScheme($secure); + + $tail = implode('/', array_map( + 'rawurlencode', (array) $extra) + ); + + // Once we have the scheme we will compile the "tail" by collapsing the values + // into a single string delimited by slashes. This just makes it convenient + // for passing the array of parameters to this URL as a list of segments. + $root = $this->getRootUrl($scheme); + + return $this->trimUrl($root, $path, $tail); + } + + /** + * Generate a secure, absolute URL to the given path. + * + * @param string $path + * @param array $parameters + * @return string + */ + public function secure($path, $parameters = array()) + { + return $this->to($path, $parameters, true); + } + + /** + * Generate a URL to an application asset. + * + * @param string $path + * @param bool $secure + * @return string + */ + public function asset($path, $secure = null) + { + if ($this->isValidUrl($path)) return $path; + + // Once we get the root URL, we will check to see if it contains an index.php + // file in the paths. If it does, we will remove it since it is not needed + // for asset paths, but only for routes to endpoints in the application. + $root = $this->getRootUrl($this->getScheme($secure)); + + return $this->removeIndex($root).'/'.trim($path, '/'); + } + + /** + * Remove the index.php file from a path. + * + * @param string $root + * @return string + */ + protected function removeIndex($root) + { + $i = 'index.php'; + + return str_contains($root, $i) ? str_replace('/'.$i, '', $root) : $root; + } + + /** + * Generate a URL to a secure asset. + * + * @param string $path + * @return string + */ + public function secureAsset($path) + { + return $this->asset($path, true); + } + + /** + * Get the scheme for a raw URL. + * + * @param bool $secure + * @return string + */ + protected function getScheme($secure) + { + if (is_null($secure)) + { + return $this->request->getScheme().'://'; + } + else + { + return $secure ? 'https://' : 'http://'; + } + } + + /** + * Get the URL to a named route. + * + * @param string $name + * @param mixed $parameters + * @param bool $absolute + * @param \Illuminate\Routing\Route $route + * @return string + * + * @throws \InvalidArgumentException + */ + public function route($name, $parameters = array(), $absolute = true, $route = null) + { + $route = $route ?: $this->routes->getByName($name); + + $parameters = (array) $parameters; + + if ( ! is_null($route)) + { + return $this->toRoute($route, $parameters, $absolute); + } + else + { + throw new InvalidArgumentException("Route [{$name}] not defined."); + } + } + + /** + * Get the URL for a given route instance. + * + * @param \Illuminate\Routing\Route $route + * @param array $parameters + * @param bool $absolute + * @return string + */ + protected function toRoute($route, array $parameters, $absolute) + { + $domain = $this->getRouteDomain($route, $parameters); + + $uri = strtr(rawurlencode($this->trimUrl( + $root = $this->replaceRoot($route, $domain, $parameters), + $this->replaceRouteParameters($route->uri(), $parameters) + )), $this->dontEncode).$this->getRouteQueryString($parameters); + + return $absolute ? $uri : '/'.ltrim(str_replace($root, '', $uri), '/'); + } + + /** + * Replace the parameters on the root path. + * + * @param \Illuminate\Routing\Route $route + * @param string $domain + * @param array $parameters + * @return string + */ + protected function replaceRoot($route, $domain, &$parameters) + { + return $this->replaceRouteParameters($this->getRouteRoot($route, $domain), $parameters); + } + + /** + * Replace all of the wildcard parameters for a route path. + * + * @param string $path + * @param array $parameters + * @return string + */ + protected function replaceRouteParameters($path, array &$parameters) + { + if (count($parameters)) + { + $path = preg_replace_sub( + '/\{.*?\}/', $parameters, $this->replaceNamedParameters($path, $parameters) + ); + } + + return trim(preg_replace('/\{.*?\?\}/', '', $path), '/'); + } + + /** + * Replace all of the named parameters in the path. + * + * @param string $path + * @param array $parameters + * @return string + */ + protected function replaceNamedParameters($path, &$parameters) + { + return preg_replace_callback('/\{(.*?)\??\}/', function($m) use (&$parameters) + { + return isset($parameters[$m[1]]) ? array_pull($parameters, $m[1]) : $m[0]; + + }, $path); + } + + /** + * Get the query string for a given route. + * + * @param array $parameters + * @return string + */ + protected function getRouteQueryString(array $parameters) + { + // First we will get all of the string parameters that are remaining after we + // have replaced the route wildcards. We'll then build a query string from + // these string parameters then use it as a starting point for the rest. + if (count($parameters) == 0) return ''; + + $query = http_build_query( + $keyed = $this->getStringParameters($parameters) + ); + + // Lastly, if there are still parameters remaining, we will fetch the numeric + // parameters that are in the array and add them to the query string or we + // will make the initial query string if it wasn't started with strings. + if (count($keyed) < count($parameters)) + { + $query .= '&'.implode( + '&', $this->getNumericParameters($parameters) + ); + } + + return '?'.trim($query, '&'); + } + + /** + * Get the string parameters from a given list. + * + * @param array $parameters + * @return array + */ + protected function getStringParameters(array $parameters) + { + return array_where($parameters, function($k, $v) { return is_string($k); }); + } + + /** + * Get the numeric parameters from a given list. + * + * @param array $parameters + * @return array + */ + protected function getNumericParameters(array $parameters) + { + return array_where($parameters, function($k, $v) { return is_numeric($k); }); + } + + /** + * Get the formatted domain for a given route. + * + * @param \Illuminate\Routing\Route $route + * @param array $parameters + * @return string + */ + protected function getRouteDomain($route, &$parameters) + { + return $route->domain() ? $this->formatDomain($route, $parameters) : null; + } + + /** + * Format the domain and port for the route and request. + * + * @param \Illuminate\Routing\Route $route + * @param array $parameters + * @return string + */ + protected function formatDomain($route, &$parameters) + { + return $this->addPortToDomain($this->getDomainAndScheme($route)); + } + + /** + * Get the domain and scheme for the route. + * + * @param \Illuminate\Routing\Route $route + * @return string + */ + protected function getDomainAndScheme($route) + { + return $this->getRouteScheme($route).$route->domain(); + } + + /** + * Add the port to the domain if necessary. + * + * @param string $domain + * @return string + */ + protected function addPortToDomain($domain) + { + if (in_array($this->request->getPort(), array('80', '443'))) + { + return $domain; + } + else + { + return $domain .= ':'.$this->request->getPort(); + } + } + + /** + * Get the root of the route URL. + * + * @param \Illuminate\Routing\Route $route + * @param string $domain + * @return string + */ + protected function getRouteRoot($route, $domain) + { + return $this->getRootUrl($this->getRouteScheme($route), $domain); + } + + /** + * Get the scheme for the given route. + * + * @param \Illuminate\Routing\Route $route + * @return string + */ + protected function getRouteScheme($route) + { + if ($route->httpOnly()) + { + return $this->getScheme(false); + } + elseif ($route->httpsOnly()) + { + return $this->getScheme(true); + } + else + { + return $this->getScheme(null); + } + } + + /** + * Get the URL to a controller action. + * + * @param string $action + * @param mixed $parameters + * @param bool $absolute + * @return string + */ + public function action($action, $parameters = array(), $absolute = true) + { + return $this->route($action, $parameters, $absolute, $this->routes->getByAction($action)); + } + + /** + * Get the base URL for the request. + * + * @param string $scheme + * @param string $root + * @return string + */ + protected function getRootUrl($scheme, $root = null) + { + $root = $root ?: $this->request->root(); + + $start = starts_with($root, 'http://') ? 'http://' : 'https://'; + + return preg_replace('~'.$start.'~', $scheme, $root, 1); + } + + /** + * Determine if the given path is a valid URL. + * + * @param string $path + * @return bool + */ + public function isValidUrl($path) + { + if (starts_with($path, array('#', '//', 'mailto:', 'tel:'))) return true; + + return filter_var($path, FILTER_VALIDATE_URL) !== false; + } + + /** + * Format the given URL segments into a single URL. + * + * @param string $root + * @param string $path + * @param string $tail + * @return string + */ + protected function trimUrl($root, $path, $tail = '') + { + return trim($root.'/'.trim($path.'/'.$tail, '/'), '/'); + } + + /** + * Get the request instance. + * + * @return \Symfony\Component\HttpFoundation\Request + */ + public function getRequest() + { + return $this->request; + } + + /** + * Set the current request instance. + * + * @param \Symfony\Component\HttpFoundation\Request $request + * @return void + */ + public function setRequest(Request $request) + { + $this->request = $request; + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Routing/composer.json b/vendor/laravel/framework/src/Illuminate/Routing/composer.json new file mode 100755 index 0000000..1a6897d --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Routing/composer.json @@ -0,0 +1,38 @@ +{ + "name": "illuminate/routing", + "license": "MIT", + "authors": [ + { + "name": "Taylor Otwell", + "email": "taylorotwell@gmail.com" + } + ], + "require": { + "php": ">=5.3.0", + "illuminate/container": "4.1.*", + "illuminate/http": "4.1.*", + "illuminate/session": "4.1.*", + "illuminate/support": "4.1.*", + "symfony/http-foundation": "2.4.*", + "symfony/http-kernel": "2.4.*", + "symfony/routing": "2.4.*" + }, + "require-dev": { + "illuminate/console": "4.1.*", + "illuminate/filesystem": "4.1.*", + "mockery/mockery": "0.9.*", + "phpunit/phpunit": "4.0.*" + }, + "autoload": { + "psr-0": { + "Illuminate\\Routing": "" + } + }, + "target-dir": "Illuminate/Routing", + "extra": { + "branch-alias": { + "dev-master": "4.1-dev" + } + }, + "minimum-stability": "dev" +} diff --git a/vendor/laravel/framework/src/Illuminate/Session/CacheBasedSessionHandler.php b/vendor/laravel/framework/src/Illuminate/Session/CacheBasedSessionHandler.php new file mode 100755 index 0000000..cd7b763 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Session/CacheBasedSessionHandler.php @@ -0,0 +1,92 @@ +cache = $cache; + $this->minutes = $minutes; + } + + /** + * {@inheritDoc} + */ + public function open($savePath, $sessionName) + { + return true; + } + + /** + * {@inheritDoc} + */ + public function close() + { + return true; + } + + /** + * {@inheritDoc} + */ + public function read($sessionId) + { + return $this->cache->get($sessionId) ?: ''; + } + + /** + * {@inheritDoc} + */ + public function write($sessionId, $data) + { + return $this->cache->put($sessionId, $data, $this->minutes); + } + + /** + * {@inheritDoc} + */ + public function destroy($sessionId) + { + return $this->cache->forget($sessionId); + } + + /** + * {@inheritDoc} + */ + public function gc($lifetime) + { + return true; + } + + /** + * Get the underlying cache repository. + * + * @return \Illuminate\Cache\Repository + */ + public function getCache() + { + return $this->cache; + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Session/CommandsServiceProvider.php b/vendor/laravel/framework/src/Illuminate/Session/CommandsServiceProvider.php new file mode 100755 index 0000000..bafed8d --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Session/CommandsServiceProvider.php @@ -0,0 +1,39 @@ +app->bindShared('command.session.database', function($app) + { + return new Console\SessionTableCommand($app['files']); + }); + + $this->commands('command.session.database'); + } + + /** + * Get the services provided by the provider. + * + * @return array + */ + public function provides() + { + return array('command.session.database'); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Session/Console/SessionTableCommand.php b/vendor/laravel/framework/src/Illuminate/Session/Console/SessionTableCommand.php new file mode 100755 index 0000000..3f45d83 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Session/Console/SessionTableCommand.php @@ -0,0 +1,70 @@ +files = $files; + } + + /** + * Execute the console command. + * + * @return void + */ + public function fire() + { + $fullPath = $this->createBaseMigration(); + + $this->files->put($fullPath, $this->files->get(__DIR__.'/stubs/database.stub')); + + $this->info('Migration created successfully!'); + } + + /** + * Create a base migration file for the session. + * + * @return string + */ + protected function createBaseMigration() + { + $name = 'create_session_table'; + + $path = $this->laravel['path'].'/database/migrations'; + + return $this->laravel['migration.creator']->create($name, $path); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Session/Console/stubs/database.stub b/vendor/laravel/framework/src/Illuminate/Session/Console/stubs/database.stub new file mode 100755 index 0000000..2aac433 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Session/Console/stubs/database.stub @@ -0,0 +1,32 @@ +string('id')->unique(); + $t->text('payload'); + $t->integer('last_activity'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::drop('sessions'); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Session/CookieSessionHandler.php b/vendor/laravel/framework/src/Illuminate/Session/CookieSessionHandler.php new file mode 100755 index 0000000..0a10290 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Session/CookieSessionHandler.php @@ -0,0 +1,94 @@ +cookie = $cookie; + $this->minutes = $minutes; + } + + /** + * {@inheritDoc} + */ + public function open($savePath, $sessionName) + { + return true; + } + + /** + * {@inheritDoc} + */ + public function close() + { + return true; + } + + /** + * {@inheritDoc} + */ + public function read($sessionId) + { + return $this->request->cookies->get($sessionId) ?: ''; + } + + /** + * {@inheritDoc} + */ + public function write($sessionId, $data) + { + $this->cookie->queue($sessionId, $data, $this->minutes); + } + + /** + * {@inheritDoc} + */ + public function destroy($sessionId) + { + $this->cookie->queue($this->cookie->forget($sessionId)); + } + + /** + * {@inheritDoc} + */ + public function gc($lifetime) + { + return true; + } + + /** + * Set the request instance. + * + * @param \Symfony\Component\HttpFoundation\Request $request + * @return void + */ + public function setRequest(Request $request) + { + $this->request = $request; + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Session/FileSessionHandler.php b/vendor/laravel/framework/src/Illuminate/Session/FileSessionHandler.php new file mode 100755 index 0000000..50ed541 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Session/FileSessionHandler.php @@ -0,0 +1,99 @@ +path = $path; + $this->files = $files; + } + + /** + * {@inheritDoc} + */ + public function open($savePath, $sessionName) + { + return true; + } + + /** + * {@inheritDoc} + */ + public function close() + { + return true; + } + + /** + * {@inheritDoc} + */ + public function read($sessionId) + { + if ($this->files->exists($path = $this->path.'/'.$sessionId)) + { + return $this->files->get($path); + } + else + { + return ''; + } + } + + /** + * {@inheritDoc} + */ + public function write($sessionId, $data) + { + $this->files->put($this->path.'/'.$sessionId, $data); + } + + /** + * {@inheritDoc} + */ + public function destroy($sessionId) + { + $this->files->delete($this->path.'/'.$sessionId); + } + + /** + * {@inheritDoc} + */ + public function gc($lifetime) + { + $files = Finder::create() + ->in($this->path) + ->files() + ->ignoreDotFiles(true) + ->date('<= now - '.$lifetime.' seconds'); + + foreach ($files as $file) + { + $this->files->delete($file->getRealPath()); + } + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Session/Middleware.php b/vendor/laravel/framework/src/Illuminate/Session/Middleware.php new file mode 100755 index 0000000..b92ce58 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Session/Middleware.php @@ -0,0 +1,257 @@ +app = $app; + $this->reject = $reject; + $this->manager = $manager; + } + + /** + * Handle the given request and get the response. + * + * @implements HttpKernelInterface::handle + * + * @param \Symfony\Component\HttpFoundation\Request $request + * @param int $type + * @param bool $catch + * @return \Symfony\Component\HttpFoundation\Response + */ + public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true) + { + $this->checkRequestForArraySessions($request); + + // If a session driver has been configured, we will need to start the session here + // so that the data is ready for an application. Note that the Laravel sessions + // do not make use of PHP "native" sessions in any way since they are crappy. + if ($this->sessionConfigured()) + { + $session = $this->startSession($request); + + $request->setSession($session); + } + + $response = $this->app->handle($request, $type, $catch); + + // Again, if the session has been configured we will need to close out the session + // so that the attributes may be persisted to some storage medium. We will also + // add the session identifier cookie to the application response headers now. + if ($this->sessionConfigured()) + { + $this->closeSession($session); + + $this->addCookieToResponse($response, $session); + } + + return $response; + } + + /** + * Check the request and reject callback for array sessions. + * + * @param \Symfony\Component\HttpFoundation\Request $request + * @return void + */ + public function checkRequestForArraySessions(Request $request) + { + if (is_null($this->reject)) return; + + if (call_user_func($this->reject, $request)) + { + $this->manager->setDefaultDriver('array'); + } + } + + /** + * Start the session for the given request. + * + * @param \Symfony\Component\HttpFoundation\Request $request + * @return \Illuminate\Session\SessionInterface + */ + protected function startSession(Request $request) + { + with($session = $this->getSession($request))->setRequestOnHandler($request); + + $session->start(); + + return $session; + } + + /** + * Close the session handling for the request. + * + * @param \Illuminate\Session\SessionInterface $session + * @return void + */ + protected function closeSession(SessionInterface $session) + { + $session->save(); + + $this->collectGarbage($session); + } + + /** + * Get the full URL for the request. + * + * @param \Symfony\Component\HttpFoundation\Request $request + * @return string + */ + protected function getUrl(Request $request) + { + $url = rtrim(preg_replace('/\?.*/', '', $request->getUri()), '/'); + + return $request->getQueryString() ? $url.'?'.$request->getQueryString() : $url; + } + + /** + * Remove the garbage from the session if necessary. + * + * @param \Illuminate\Session\SessionInterface $session + * @return void + */ + protected function collectGarbage(SessionInterface $session) + { + $config = $this->manager->getSessionConfig(); + + // Here we will see if this request hits the garbage collection lottery by hitting + // the odds needed to perform garbage collection on any given request. If we do + // hit it, we'll call this handler to let it delete all the expired sessions. + if ($this->configHitsLottery($config)) + { + $session->getHandler()->gc($this->getLifetimeSeconds()); + } + } + + /** + * Determine if the configuration odds hit the lottery. + * + * @param array $config + * @return bool + */ + protected function configHitsLottery(array $config) + { + return mt_rand(1, $config['lottery'][1]) <= $config['lottery'][0]; + } + + /** + * Add the session cookie to the application response. + * + * @param \Symfony\Component\HttpFoundation\Response $response + * @param \Symfony\Component\HttpFoundation\Session\SessionInterface $session + * @return void + */ + protected function addCookieToResponse(Response $response, SessionInterface $session) + { + $s = $session; + + if ($this->sessionIsPersistent($c = $this->manager->getSessionConfig())) + { + $secure = array_get($c, 'secure', false); + + $response->headers->setCookie(new Cookie( + $s->getName(), $s->getId(), $this->getCookieLifetime(), $c['path'], $c['domain'], $secure + )); + } + } + + /** + * Get the session lifetime in seconds. + * + * + */ + protected function getLifetimeSeconds() + { + return array_get($this->manager->getSessionConfig(), 'lifetime') * 60; + } + + /** + * Get the cookie lifetime in seconds. + * + * @return int + */ + protected function getCookieLifetime() + { + $config = $this->manager->getSessionConfig(); + + return $config['expire_on_close'] ? 0 : Carbon::now()->addMinutes($config['lifetime']); + } + + /** + * Determine if a session driver has been configured. + * + * @return bool + */ + protected function sessionConfigured() + { + return ! is_null(array_get($this->manager->getSessionConfig(), 'driver')); + } + + /** + * Determine if the configured session driver is persistent. + * + * @param array|null $config + * @return bool + */ + protected function sessionIsPersistent(array $config = null) + { + // Some session drivers are not persistent, such as the test array driver or even + // when the developer don't have a session driver configured at all, which the + // session cookies will not need to get set on any responses in those cases. + $config = $config ?: $this->manager->getSessionConfig(); + + return ! in_array($config['driver'], array(null, 'array')); + } + + /** + * Get the session implementation from the manager. + * + * @return \Illuminate\Session\SessionInterface + */ + public function getSession(Request $request) + { + $session = $this->manager->driver(); + + $session->setId($request->cookies->get($session->getName())); + + return $session; + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Session/SessionInterface.php b/vendor/laravel/framework/src/Illuminate/Session/SessionInterface.php new file mode 100755 index 0000000..43537d4 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Session/SessionInterface.php @@ -0,0 +1,30 @@ +buildSession(parent::callCustomCreator($driver)); + } + + /** + * Create an instance of the "array" session driver. + * + * @return \Illuminate\Session\Store + */ + protected function createArrayDriver() + { + return new Store($this->app['config']['session.cookie'], new NullSessionHandler); + } + + /** + * Create an instance of the "cookie" session driver. + * + * @return \Illuminate\Session\Store + */ + protected function createCookieDriver() + { + $lifetime = $this->app['config']['session.lifetime']; + + return $this->buildSession(new CookieSessionHandler($this->app['cookie'], $lifetime)); + } + + /** + * Create an instance of the file session driver. + * + * @return \Illuminate\Session\Store + */ + protected function createFileDriver() + { + return $this->createNativeDriver(); + } + + /** + * Create an instance of the file session driver. + * + * @return \Illuminate\Session\Store + */ + protected function createNativeDriver() + { + $path = $this->app['config']['session.files']; + + return $this->buildSession(new FileSessionHandler($this->app['files'], $path)); + } + + /** + * Create an instance of the database session driver. + * + * @return \Illuminate\Session\Store + */ + protected function createDatabaseDriver() + { + $connection = $this->getDatabaseConnection(); + + $table = $connection->getTablePrefix().$this->app['config']['session.table']; + + return $this->buildSession(new PdoSessionHandler($connection->getPdo(), $this->getDatabaseOptions($table))); + } + + /** + * Get the database connection for the database driver. + * + * @return \Illuminate\Database\Connection + */ + protected function getDatabaseConnection() + { + $connection = $this->app['config']['session.connection']; + + return $this->app['db']->connection($connection); + } + + + /** + * Get the database session options. + * + * @param string $table + * @return array + */ + protected function getDatabaseOptions($table) + { + return array('db_table' => $table, 'db_id_col' => 'id', 'db_data_col' => 'payload', 'db_time_col' => 'last_activity'); + } + + /** + * Create an instance of the APC session driver. + * + * @return \Illuminate\Session\Store + */ + protected function createApcDriver() + { + return $this->createCacheBased('apc'); + } + + /** + * Create an instance of the Memcached session driver. + * + * @return \Illuminate\Session\Store + */ + protected function createMemcachedDriver() + { + return $this->createCacheBased('memcached'); + } + + /** + * Create an instance of the Wincache session driver. + * + * @return \Illuminate\Session\Store + */ + protected function createWincacheDriver() + { + return $this->createCacheBased('wincache'); + } + + /** + * Create an instance of the Redis session driver. + * + * @return \Illuminate\Session\Store + */ + protected function createRedisDriver() + { + $handler = $this->createCacheHandler('redis'); + + $handler->getCache()->getStore()->setConnection($this->app['config']['session.connection']); + + return $this->buildSession($handler); + } + + + /** + * Create an instance of a cache driven driver. + * + * @param string $driver + * @return \Illuminate\Session\Store + */ + protected function createCacheBased($driver) + { + return $this->buildSession($this->createCacheHandler($driver)); + } + + /** + * Create the cache based session handler instance. + * + * @param string $driver + * @return \Illuminate\Session\CacheBasedSessionHandler + */ + protected function createCacheHandler($driver) + { + $minutes = $this->app['config']['session.lifetime']; + + return new CacheBasedSessionHandler($this->app['cache']->driver($driver), $minutes); + } + + /** + * Build the session instance. + * + * @param \SessionHandlerInterface $handler + * @return \Illuminate\Session\Store + */ + protected function buildSession($handler) + { + return new Store($this->app['config']['session.cookie'], $handler); + } + + /** + * Get the session configuration. + * + * @return array + */ + public function getSessionConfig() + { + return $this->app['config']['session']; + } + + /** + * Get the default session driver name. + * + * @return string + */ + public function getDefaultDriver() + { + return $this->app['config']['session.driver']; + } + + /** + * Set the default session driver name. + * + * @param string $name + * @return void + */ + public function setDefaultDriver($name) + { + $this->app['config']['session.driver'] = $name; + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Session/SessionServiceProvider.php b/vendor/laravel/framework/src/Illuminate/Session/SessionServiceProvider.php new file mode 100755 index 0000000..e27ffba --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Session/SessionServiceProvider.php @@ -0,0 +1,75 @@ +setupDefaultDriver(); + + $this->registerSessionManager(); + + $this->registerSessionDriver(); + } + + /** + * Setup the default session driver for the application. + * + * @return void + */ + protected function setupDefaultDriver() + { + if ($this->app->runningInConsole()) + { + $this->app['config']['session.driver'] = 'array'; + } + } + + /** + * Register the session manager instance. + * + * @return void + */ + protected function registerSessionManager() + { + $this->app->bindShared('session', function($app) + { + return new SessionManager($app); + }); + } + + /** + * Register the session driver instance. + * + * @return void + */ + protected function registerSessionDriver() + { + $this->app->bindShared('session.store', function($app) + { + // First, we will create the session manager which is responsible for the + // creation of the various session drivers when they are needed by the + // application instance, and will resolve them on a lazy load basis. + $manager = $app['session']; + + return $manager->driver(); + }); + } + + /** + * Get the session driver name. + * + * @return string + */ + protected function getDriver() + { + return $this->app['config']['session.driver']; + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Session/Store.php b/vendor/laravel/framework/src/Illuminate/Session/Store.php new file mode 100755 index 0000000..50ed01e --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Session/Store.php @@ -0,0 +1,590 @@ +name = $name; + $this->handler = $handler; + $this->metaBag = new MetadataBag; + $this->setId($id ?: $this->generateSessionId()); + } + + /** + * {@inheritdoc} + */ + public function start() + { + $this->loadSession(); + + if ( ! $this->has('_token')) $this->regenerateToken(); + + return $this->started = true; + } + + /** + * Load the session data from the handler. + * + * @return void + */ + protected function loadSession() + { + $this->attributes = $this->readFromHandler(); + + foreach (array_merge($this->bags, array($this->metaBag)) as $bag) + { + $this->initializeLocalBag($bag); + + $bag->initialize($this->bagData[$bag->getStorageKey()]); + } + } + + /** + * Read the session data from the handler. + * + * @return array + */ + protected function readFromHandler() + { + $data = $this->handler->read($this->getId()); + + return $data ? unserialize($data) : array(); + } + + /** + * Initialize a bag in storage if it doesn't exist. + * + * @param \Symfony\Component\HttpFoundation\Session\SessionBagInterface $bag + * @return void + */ + protected function initializeLocalBag($bag) + { + $this->bagData[$bag->getStorageKey()] = $this->get($bag->getStorageKey(), array()); + + $this->forget($bag->getStorageKey()); + } + + /** + * {@inheritdoc} + */ + public function getId() + { + return $this->id; + } + + /** + * {@inheritdoc} + */ + public function setId($id) + { + $this->id = $id ?: $this->generateSessionId(); + } + + /** + * Get a new, random session ID. + * + * @return string + */ + protected function generateSessionId() + { + return sha1(uniqid(true).str_random(25).microtime(true)); + } + + /** + * {@inheritdoc} + */ + public function getName() + { + return $this->name; + } + + /** + * {@inheritdoc} + */ + public function setName($name) + { + $this->name = $name; + } + + /** + * {@inheritdoc} + */ + public function invalidate($lifetime = null) + { + $this->attributes = array(); + + $this->migrate(); + + return true; + } + + /** + * {@inheritdoc} + */ + public function migrate($destroy = false, $lifetime = null) + { + if ($destroy) $this->handler->destroy($this->getId()); + + $this->id = $this->generateSessionId(); return true; + } + + /** + * Generate a new session identifier. + * + * @param bool $destroy + * @return bool + */ + public function regenerate($destroy = false) + { + return $this->migrate($destroy); + } + + /** + * {@inheritdoc} + */ + public function save() + { + $this->addBagDataToSession(); + + $this->ageFlashData(); + + $this->handler->write($this->getId(), serialize($this->attributes)); + + $this->started = false; + } + + /** + * Merge all of the bag data into the session. + * + * @return void + */ + protected function addBagDataToSession() + { + foreach (array_merge($this->bags, array($this->metaBag)) as $bag) + { + $this->put($bag->getStorageKey(), $this->bagData[$bag->getStorageKey()]); + } + } + + /** + * Age the flash data for the session. + * + * @return void + */ + public function ageFlashData() + { + foreach ($this->get('flash.old', array()) as $old) { $this->forget($old); } + + $this->put('flash.old', $this->get('flash.new', array())); + + $this->put('flash.new', array()); + } + + /** + * {@inheritdoc} + */ + public function has($name) + { + return ! is_null($this->get($name)); + } + + /** + * {@inheritdoc} + */ + public function get($name, $default = null) + { + return array_get($this->attributes, $name, $default); + } + + /** + * Determine if the session contains old input. + * + * @param string $key + * @return bool + */ + public function hasOldInput($key = null) + { + $old = $this->getOldInput($key); + + return is_null($key) ? count($old) > 0 : ! is_null($old); + } + + /** + * Get the requested item from the flashed input array. + * + * @param string $key + * @param mixed $default + * @return mixed + */ + public function getOldInput($key = null, $default = null) + { + $input = $this->get('_old_input', array()); + + // Input that is flashed to the session can be easily retrieved by the + // developer, making repopulating old forms and the like much more + // convenient, since the request's previous input is available. + if (is_null($key)) return $input; + + return array_get($input, $key, $default); + } + + /** + * {@inheritdoc} + */ + public function set($name, $value) + { + array_set($this->attributes, $name, $value); + } + + /** + * Put a key / value pair or array of key / value pairs in the session. + * + * @param string|array $key + * @param mixed|null $value + * @return void + */ + public function put($key, $value) + { + if ( ! is_array($key)) $key = array($key => $value); + + foreach ($key as $arrayKey => $arrayValue) + { + $this->set($arrayKey, $arrayValue); + } + } + + /** + * Push a value onto a session array. + * + * @param string $key + * @param mixed $value + * @return void + */ + public function push($key, $value) + { + $array = $this->get($key, array()); + + $array[] = $value; + + $this->put($key, $array); + } + + /** + * Flash a key / value pair to the session. + * + * @param string $key + * @param mixed $value + * @return void + */ + public function flash($key, $value) + { + $this->put($key, $value); + + $this->push('flash.new', $key); + + $this->removeFromOldFlashData(array($key)); + } + + /** + * Flash an input array to the session. + * + * @param array $value + * @return void + */ + public function flashInput(array $value) + { + $this->flash('_old_input', $value); + } + + /** + * Reflash all of the session flash data. + * + * @return void + */ + public function reflash() + { + $this->mergeNewFlashes($this->get('flash.old', array())); + + $this->put('flash.old', array()); + } + + /** + * Reflash a subset of the current flash data. + * + * @param array|dynamic $keys + * @return void + */ + public function keep($keys = null) + { + $keys = is_array($keys) ? $keys : func_get_args(); + + $this->mergeNewFlashes($keys); + + $this->removeFromOldFlashData($keys); + } + + /** + * Merge new flash keys into the new flash array. + * + * @param array $keys + * @return void + */ + protected function mergeNewFlashes(array $keys) + { + $values = array_unique(array_merge($this->get('flash.new', array()), $keys)); + + $this->put('flash.new', $values); + } + + /** + * Remove the given keys from the old flash data. + * + * @param array $keys + * @return void + */ + protected function removeFromOldFlashData(array $keys) + { + $this->put('flash.old', array_diff($this->get('flash.old', array()), $keys)); + } + + /** + * {@inheritdoc} + */ + public function all() + { + return $this->attributes; + } + + /** + * {@inheritdoc} + */ + public function replace(array $attributes) + { + foreach ($attributes as $key => $value) + { + $this->put($key, $value); + } + } + + /** + * {@inheritdoc} + */ + public function remove($name) + { + return array_pull($this->attributes, $name); + } + + /** + * Remove an item from the session. + * + * @param string $key + * @return void + */ + public function forget($key) + { + array_forget($this->attributes, $key); + } + + /** + * {@inheritdoc} + */ + public function clear() + { + $this->attributes = array(); + + foreach ($this->bags as $bag) + { + $bag->clear(); + } + } + + /** + * Remove all of the items from the session. + * + * @return void + */ + public function flush() + { + $this->clear(); + } + + /** + * {@inheritdoc} + */ + public function isStarted() + { + return $this->started; + } + + /** + * {@inheritdoc} + */ + public function registerBag(SessionBagInterface $bag) + { + $this->bags[$bag->getStorageKey()] = $bag; + } + + /** + * {@inheritdoc} + */ + public function getBag($name) + { + return array_get($this->bags, $name, function() + { + throw new \InvalidArgumentException("Bag not registered."); + }); + } + + /** + * {@inheritdoc} + */ + public function getMetadataBag() + { + return $this->metaBag; + } + + /** + * Get the raw bag data array for a given bag. + * + * @param string $name + * @return array + */ + public function getBagData($name) + { + return array_get($this->bagData, $name, array()); + } + + /** + * Get the CSRF token value. + * + * @return string + */ + public function token() + { + return $this->get('_token'); + } + + /** + * Get the CSRF token value. + * + * @return string + */ + public function getToken() + { + return $this->token(); + } + + /** + * Regenerate the CSRF token value. + * + * @return void + */ + public function regenerateToken() + { + $this->put('_token', str_random(40)); + } + + /** + * Get the underlying session handler implementation. + * + * @return \SessionHandlerInterface + */ + public function getHandler() + { + return $this->handler; + } + + /** + * Determine if the session handler needs a request. + * + * @return bool + */ + public function handlerNeedsRequest() + { + return $this->handler instanceof CookieSessionHandler; + } + + /** + * Set the request on the handler instance. + * + * @param \Symfony\Component\HttpFoundation\Request $request + * @return void + */ + public function setRequestOnHandler(Request $request) + { + if ($this->handlerNeedsRequest()) + { + $this->handler->setRequest($request); + } + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Session/TokenMismatchException.php b/vendor/laravel/framework/src/Illuminate/Session/TokenMismatchException.php new file mode 100755 index 0000000..0bc5841 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Session/TokenMismatchException.php @@ -0,0 +1,3 @@ +=5.3.0", + "illuminate/cache": "4.1.*", + "illuminate/cookie": "4.1.*", + "illuminate/encryption": "4.1.*", + "illuminate/support": "4.1.*", + "nesbot/carbon": "1.*", + "symfony/finder": "2.4.*", + "symfony/http-foundation": "2.4.*" + }, + "require-dev": { + "illuminate/console": "4.1.*", + "mockery/mockery": "0.9.*", + "phpunit/phpunit": "4.0.*" + }, + "autoload": { + "psr-0": { + "Illuminate\\Session": "" + } + }, + "target-dir": "Illuminate/Session", + "extra": { + "branch-alias": { + "dev-master": "4.1-dev" + } + }, + "minimum-stability": "dev" +} diff --git a/vendor/laravel/framework/src/Illuminate/Support/ClassLoader.php b/vendor/laravel/framework/src/Illuminate/Support/ClassLoader.php new file mode 100755 index 0000000..7287218 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Support/ClassLoader.php @@ -0,0 +1,113 @@ +items = $items; + } + + /** + * Create a new collection instance if the value isn't one already. + * + * @param mixed $items + * @return \Illuminate\Support\Collection + */ + public static function make($items) + { + if (is_null($items)) return new static; + + if ($items instanceof Collection) return $items; + + return new static(is_array($items) ? $items : array($items)); + } + + /** + * Get all of the items in the collection. + * + * @return array + */ + public function all() + { + return $this->items; + } + + /** + * Collapse the collection items into a single array. + * + * @return \Illuminate\Support\Collection + */ + public function collapse() + { + $results = array(); + + foreach ($this->items as $values) + { + $results = array_merge($results, $values); + } + + return new static($results); + } + + /** + * Diff the collection with the given items. + * + * @param \Illuminate\Support\Collection|\Illuminate\Support\Contracts\ArrayableInterface|array $items + * @return \Illuminate\Support\Collection + */ + public function diff($items) + { + return new static(array_diff($this->items, $this->getArrayableItems($items))); + } + + /** + * Execute a callback over each item. + * + * @param Closure $callback + * @return \Illuminate\Support\Collection + */ + public function each(Closure $callback) + { + array_map($callback, $this->items); + + return $this; + } + + /** + * Fetch a nested element of the collection. + * + * @param string $key + * @return \Illuminate\Support\Collection + */ + public function fetch($key) + { + return new static(array_fetch($this->items, $key)); + } + + /** + * Run a filter over each of the items. + * + * @param Closure $callback + * @return \Illuminate\Support\Collection + */ + public function filter(Closure $callback) + { + return new static(array_filter($this->items, $callback)); + } + + /** + * Get the first item from the collection. + * + * @param \Closure $callback + * @param mixed $default + * @return mixed|null + */ + public function first(Closure $callback = null, $default = null) + { + if (is_null($callback)) + { + return count($this->items) > 0 ? reset($this->items) : null; + } + else + { + return array_first($this->items, $callback, $default); + } + } + + /** + * Get a flattened array of the items in the collection. + * + * @return array + */ + public function flatten() + { + return new static(array_flatten($this->items)); + } + + /** + * Remove an item from the collection by key. + * + * @param mixed $key + * @return void + */ + public function forget($key) + { + unset($this->items[$key]); + } + + /** + * Get an item from the collection by key. + * + * @param mixed $key + * @param mixed $default + * @return mixed + */ + public function get($key, $default = null) + { + if (array_key_exists($key, $this->items)) + { + return $this->items[$key]; + } + + return value($default); + } + + /** + * Group an associative array by a field or Closure value. + * + * @param callable|string $groupBy + * @return \Illuminate\Support\Collection + */ + public function groupBy($groupBy) + { + $results = array(); + + foreach ($this->items as $key => $value) + { + $key = is_callable($groupBy) ? $groupBy($value, $key) : data_get($value, $groupBy); + + $results[$key][] = $value; + } + + return new static($results); + } + + /** + * Determine if an item exists in the collection by key. + * + * @param mixed $key + * @return bool + */ + public function has($key) + { + return array_key_exists($key, $this->items); + } + + /** + * Concatenate values of a given key as a string. + * + * @param string $value + * @param string $glue + * @return string + */ + public function implode($value, $glue = null) + { + if (is_null($glue)) return implode($this->lists($value)); + + return implode($glue, $this->lists($value)); + } + + /** + * Intersect the collection with the given items. + * + * @param \Illuminate\Support\Collection|\Illuminate\Support\Contracts\ArrayableInterface|array $items + * @return \Illuminate\Support\Collection + */ + public function intersect($items) + { + return new static(array_intersect($this->items, $this->getArrayableItems($items))); + } + + /** + * Determine if the collection is empty or not. + * + * @return bool + */ + public function isEmpty() + { + return empty($this->items); + } + + /** + * Get the last item from the collection. + * + * @return mixed|null + */ + public function last() + { + return count($this->items) > 0 ? end($this->items) : null; + } + + /** + * Get an array with the values of a given key. + * + * @param string $value + * @param string $key + * @return array + */ + public function lists($value, $key = null) + { + return array_pluck($this->items, $value, $key); + } + + /** + * Run a map over each of the items. + * + * @param Closure $callback + * @return \Illuminate\Support\Collection + */ + public function map(Closure $callback) + { + return new static(array_map($callback, $this->items, array_keys($this->items))); + } + + /** + * Merge the collection with the given items. + * + * @param \Illuminate\Support\Collection|\Illuminate\Support\Contracts\ArrayableInterface|array $items + * @return \Illuminate\Support\Collection + */ + public function merge($items) + { + return new static(array_merge($this->items, $this->getArrayableItems($items))); + } + + /** + * Get and remove the last item from the collection. + * + * @return mixed|null + */ + public function pop() + { + return array_pop($this->items); + } + + /** + * Push an item onto the beginning of the collection. + * + * @param mixed $value + * @return void + */ + public function prepend($value) + { + array_unshift($this->items, $value); + } + + /** + * Push an item onto the end of the collection. + * + * @param mixed $value + * @return void + */ + public function push($value) + { + $this->items[] = $value; + } + + /** + * Pulls an item from the collection. + * + * @param mixed $key + * @param mixed $default + * @return mixed + */ + public function pull($key, $default = null) + { + return array_pull($this->items, $key, $default); + } + + /** + * Put an item in the collection by key. + * + * @param mixed $key + * @param mixed $value + * @return void + */ + public function put($key, $value) + { + $this->items[$key] = $value; + } + + /** + * Reduce the collection to a single value. + * + * @param callable $callback + * @param mixed $initial + * @return mixed + */ + public function reduce($callback, $initial = null) + { + return array_reduce($this->items, $callback, $initial); + } + + /** + * Get one or more items randomly from the collection. + * + * @param int $amount + * @return mixed + */ + public function random($amount = 1) + { + $keys = array_rand($this->items, $amount); + + return is_array($keys) ? array_intersect_key($this->items, array_flip($keys)) : $this->items[$keys]; + } + + /** + * Reverse items order. + * + * @return \Illuminate\Support\Collection + */ + public function reverse() + { + return new static(array_reverse($this->items)); + } + + /** + * Get and remove the first item from the collection. + * + * @return mixed|null + */ + public function shift() + { + return array_shift($this->items); + } + + /** + * Slice the underlying collection array. + * + * @param int $offset + * @param int $length + * @param bool $preserveKeys + * @return \Illuminate\Support\Collection + */ + public function slice($offset, $length = null, $preserveKeys = false) + { + return new static(array_slice($this->items, $offset, $length, $preserveKeys)); + } + + /** + * Chunk the underlying collection array. + * + * @param int $size + * @param bool $preserveKeys + * @return \Illuminate\Support\Collection + */ + public function chunk($size, $preserveKeys = false) + { + $chunks = new static; + + foreach (array_chunk($this->items, $size, $preserveKeys) as $chunk) + { + $chunks->push(new static($chunk)); + } + + return $chunks; + } + + /** + * Sort through each item with a callback. + * + * @param Closure $callback + * @return \Illuminate\Support\Collection + */ + public function sort(Closure $callback) + { + uasort($this->items, $callback); + + return $this; + } + + /** + * Sort the collection using the given Closure. + * + * @param \Closure|string $callback + * @param int $options + * @param bool $descending + * @return \Illuminate\Support\Collection + */ + public function sortBy($callback, $options = SORT_REGULAR, $descending = false) + { + $results = array(); + + if (is_string($callback)) $callback = + $this->valueRetriever($callback); + + // First we will loop through the items and get the comparator from a callback + // function which we were given. Then, we will sort the returned values and + // and grab the corresponding values for the sorted keys from this array. + foreach ($this->items as $key => $value) + { + $results[$key] = $callback($value); + } + + $descending ? arsort($results, $options) + : asort($results, $options); + + // Once we have sorted all of the keys in the array, we will loop through them + // and grab the corresponding model so we can set the underlying items list + // to the sorted version. Then we'll just return the collection instance. + foreach (array_keys($results) as $key) + { + $results[$key] = $this->items[$key]; + } + + $this->items = $results; + + return $this; + } + + /** + * Sort the collection in descending order using the given Closure. + * + * @param \Closure|string $callback + * @param int $options + * @return \Illuminate\Support\Collection + */ + public function sortByDesc($callback, $options = SORT_REGULAR) + { + return $this->sortBy($callback, $options, true); + } + + /** + * Splice portion of the underlying collection array. + * + * @param int $offset + * @param int $length + * @param mixed $replacement + * @return \Illuminate\Support\Collection + */ + public function splice($offset, $length = 0, $replacement = array()) + { + return new static(array_splice($this->items, $offset, $length, $replacement)); + } + + /** + * Get the sum of the given values. + * + * @param \Closure $callback + * @param string $callback + * @return mixed + */ + public function sum($callback) + { + if (is_string($callback)) + { + $callback = $this->valueRetriever($callback); + } + + return $this->reduce(function($result, $item) use ($callback) + { + return $result += $callback($item); + + }, 0); + } + + /** + * Take the first or last {$limit} items. + * + * @param int $limit + * @return \Illuminate\Support\Collection + */ + public function take($limit = null) + { + if ($limit < 0) return $this->slice($limit, abs($limit)); + + return $this->slice(0, $limit); + } + + /** + * Transform each item in the collection using a callback. + * + * @param Closure $callback + * @return \Illuminate\Support\Collection + */ + public function transform(Closure $callback) + { + $this->items = array_map($callback, $this->items); + + return $this; + } + + /** + * Return only unique items from the collection array. + * + * @return \Illuminate\Support\Collection + */ + public function unique() + { + return new static(array_unique($this->items)); + } + + /** + * Reset the keys on the underlying array. + * + * @return \Illuminate\Support\Collection + */ + public function values() + { + $this->items = array_values($this->items); + + return $this; + } + + /** + * Get a value retrieving callback. + * + * @param string $value + * @return \Closure + */ + protected function valueRetriever($value) + { + return function($item) use ($value) + { + return data_get($item, $value); + }; + } + + /** + * Get the collection of items as a plain array. + * + * @return array + */ + public function toArray() + { + return array_map(function($value) + { + return $value instanceof ArrayableInterface ? $value->toArray() : $value; + + }, $this->items); + } + + /** + * Get the collection of items as JSON. + * + * @param int $options + * @return string + */ + public function toJson($options = 0) + { + return json_encode($this->toArray(), $options); + } + + /** + * Get an iterator for the items. + * + * @return ArrayIterator + */ + public function getIterator() + { + return new ArrayIterator($this->items); + } + + /** + * Get a CachingIterator instance. + * + * @return \CachingIterator + */ + public function getCachingIterator($flags = CachingIterator::CALL_TOSTRING) + { + return new CachingIterator($this->getIterator(), $flags); + } + + /** + * Count the number of items in the collection. + * + * @return int + */ + public function count() + { + return count($this->items); + } + + /** + * Determine if an item exists at an offset. + * + * @param mixed $key + * @return bool + */ + public function offsetExists($key) + { + return array_key_exists($key, $this->items); + } + + /** + * Get an item at a given offset. + * + * @param mixed $key + * @return mixed + */ + public function offsetGet($key) + { + return $this->items[$key]; + } + + /** + * Set the item at a given offset. + * + * @param mixed $key + * @param mixed $value + * @return void + */ + public function offsetSet($key, $value) + { + if (is_null($key)) + { + $this->items[] = $value; + } + else + { + $this->items[$key] = $value; + } + } + + /** + * Unset the item at a given offset. + * + * @param string $key + * @return void + */ + public function offsetUnset($key) + { + unset($this->items[$key]); + } + + /** + * Convert the collection to its string representation. + * + * @return string + */ + public function __toString() + { + return $this->toJson(); + } + + /** + * Results array of items from Collection or ArrayableInterface. + * + * @param \Illuminate\Support\Collection|\Illuminate\Support\Contracts\ArrayableInterface|array $items + * @return array + */ + private function getArrayableItems($items) + { + if ($items instanceof Collection) + { + $items = $items->all(); + } + elseif ($items instanceof ArrayableInterface) + { + $items = $items->toArray(); + } + + return $items; + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Support/Contracts/ArrayableInterface.php b/vendor/laravel/framework/src/Illuminate/Support/Contracts/ArrayableInterface.php new file mode 100755 index 0000000..0383492 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Support/Contracts/ArrayableInterface.php @@ -0,0 +1,12 @@ +getEngineResolver()->resolve('blade')->getCompiler(); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Support/Facades/Cache.php b/vendor/laravel/framework/src/Illuminate/Support/Facades/Cache.php new file mode 100755 index 0000000..dbcca06 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Support/Facades/Cache.php @@ -0,0 +1,16 @@ +cookie($key, null)); + } + + /** + * Retrieve a cookie from the request. + * + * @param string $key + * @param mixed $default + * @return string + */ + public static function get($key = null, $default = null) + { + return static::$app['request']->cookie($key, $default); + } + + /** + * Get the registered name of the component. + * + * @return string + */ + protected static function getFacadeAccessor() { return 'cookie'; } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Support/Facades/Crypt.php b/vendor/laravel/framework/src/Illuminate/Support/Facades/Crypt.php new file mode 100755 index 0000000..d5992bb --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Support/Facades/Crypt.php @@ -0,0 +1,15 @@ +instance(static::getFacadeAccessor(), $instance); + } + + /** + * Initiate a mock expectation on the facade. + * + * @param dynamic + * @return \Mockery\Expectation + */ + public static function shouldReceive() + { + $name = static::getFacadeAccessor(); + + if (static::isMock()) + { + $mock = static::$resolvedInstance[$name]; + } + else + { + $mock = static::createFreshMockInstance($name); + } + + return call_user_func_array(array($mock, 'shouldReceive'), func_get_args()); + } + + /** + * Create a fresh mock instance for the given class. + * + * @param string $name + * @return \Mockery\Expectation + */ + protected static function createFreshMockInstance($name) + { + static::$resolvedInstance[$name] = $mock = static::createMockByName($name); + + if (isset(static::$app)) + { + static::$app->instance($name, $mock); + } + + return $mock; + } + + /** + * Create a fresh mock instance for the given class. + * + * @param string $name + * @return \Mockery\Expectation + */ + protected static function createMockByName($name) + { + $class = static::getMockableClass($name); + + return $class ? \Mockery::mock($class) : \Mockery::mock(); + } + + /** + * Determines whether a mock is set as the instance of the facade. + * + * @return bool + */ + protected static function isMock() + { + $name = static::getFacadeAccessor(); + + return isset(static::$resolvedInstance[$name]) && static::$resolvedInstance[$name] instanceof MockInterface; + } + + /** + * Get the mockable class for the bound instance. + * + * @return string + */ + protected static function getMockableClass() + { + if ($root = static::getFacadeRoot()) return get_class($root); + } + + /** + * Get the root object behind the facade. + * + * @return mixed + */ + public static function getFacadeRoot() + { + return static::resolveFacadeInstance(static::getFacadeAccessor()); + } + + /** + * Get the registered name of the component. + * + * @return string + * + * @throws \RuntimeException + */ + protected static function getFacadeAccessor() + { + throw new \RuntimeException("Facade does not implement getFacadeAccessor method."); + } + + /** + * Resolve the facade root instance from the container. + * + * @param string $name + * @return mixed + */ + protected static function resolveFacadeInstance($name) + { + if (is_object($name)) return $name; + + if (isset(static::$resolvedInstance[$name])) + { + return static::$resolvedInstance[$name]; + } + + return static::$resolvedInstance[$name] = static::$app[$name]; + } + + /** + * Clear a resolved facade instance. + * + * @param string $name + * @return void + */ + public static function clearResolvedInstance($name) + { + unset(static::$resolvedInstance[$name]); + } + + /** + * Clear all of the resolved instances. + * + * @return void + */ + public static function clearResolvedInstances() + { + static::$resolvedInstance = array(); + } + + /** + * Get the application instance behind the facade. + * + * @return \Illuminate\Foundation\Application + */ + public static function getFacadeApplication() + { + return static::$app; + } + + /** + * Set the application instance. + * + * @param \Illuminate\Foundation\Application $app + * @return void + */ + public static function setFacadeApplication($app) + { + static::$app = $app; + } + + /** + * Handle dynamic, static calls to the object. + * + * @param string $method + * @param array $args + * @return mixed + */ + public static function __callStatic($method, $args) + { + $instance = static::getFacadeRoot(); + + switch (count($args)) + { + case 0: + return $instance->$method(); + + case 1: + return $instance->$method($args[0]); + + case 2: + return $instance->$method($args[0], $args[1]); + + case 3: + return $instance->$method($args[0], $args[1], $args[2]); + + case 4: + return $instance->$method($args[0], $args[1], $args[2], $args[3]); + + default: + return call_user_func_array(array($instance, $method), $args); + } + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Support/Facades/File.php b/vendor/laravel/framework/src/Illuminate/Support/Facades/File.php new file mode 100755 index 0000000..058203d --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Support/Facades/File.php @@ -0,0 +1,15 @@ +input($key, $default); + } + + /** + * Get the registered name of the component. + * + * @return string + */ + protected static function getFacadeAccessor() { return 'request'; } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Support/Facades/Lang.php b/vendor/laravel/framework/src/Illuminate/Support/Facades/Lang.php new file mode 100755 index 0000000..fe2b8b4 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Support/Facades/Lang.php @@ -0,0 +1,15 @@ +make($view, $data), $status, $headers); + } + + /** + * Return a new JSON response from the application. + * + * @param string|array $data + * @param int $status + * @param array $headers + * @param int $options + * @return \Illuminate\Http\JsonResponse + */ + public static function json($data = array(), $status = 200, array $headers = array(), $options = 0) + { + if ($data instanceof ArrayableInterface) + { + $data = $data->toArray(); + } + + return new JsonResponse($data, $status, $headers, $options); + } + + /** + * Return a new streamed response from the application. + * + * @param \Closure $callback + * @param int $status + * @param array $headers + * @return \Symfony\Component\HttpFoundation\StreamedResponse + */ + public static function stream($callback, $status = 200, array $headers = array()) + { + return new StreamedResponse($callback, $status, $headers); + } + + /** + * Create a new file download response. + * + * @param \SplFileInfo|string $file + * @param string $name + * @param array $headers + * @param null|string $disposition + * @return \Symfony\Component\HttpFoundation\BinaryFileResponse + */ + public static function download($file, $name = null, array $headers = array(), $disposition = 'attachment') + { + $response = new BinaryFileResponse($file, 200, $headers, true, $disposition); + + if ( ! is_null($name)) + { + return $response->setContentDisposition($disposition, $name, Str::ascii($name)); + } + + return $response; + } + + /** + * Register a macro with the Response class. + * + * @param string $name + * @param callable $callback + * @return void + */ + public static function macro($name, $callback) + { + static::$macros[$name] = $callback; + } + + /** + * Handle dynamic calls into Response macros. + * + * @param string $method + * @param array $parameters + * @return mixed + * + * @throws \BadMethodCallException + */ + public static function __callStatic($method, $parameters) + { + if (isset(static::$macros[$method])) + { + return call_user_func_array(static::$macros[$method], $parameters); + } + + throw new \BadMethodCallException("Call to undefined method $method"); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Support/Facades/Route.php b/vendor/laravel/framework/src/Illuminate/Support/Facades/Route.php new file mode 100755 index 0000000..73e6db9 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Support/Facades/Route.php @@ -0,0 +1,37 @@ +currentRouteNamed($name); + } + + /** + * Determine if the current route uses a given controller action. + * + * @param string $action + * @return bool + */ + public static function uses($action) + { + return static::$app['router']->currentRouteUses($action); + } + + /** + * Get the registered name of the component. + * + * @return string + */ + protected static function getFacadeAccessor() { return 'router'; } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Support/Facades/SSH.php b/vendor/laravel/framework/src/Illuminate/Support/Facades/SSH.php new file mode 100755 index 0000000..5178a4b --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Support/Facades/SSH.php @@ -0,0 +1,16 @@ +connection($name)->getSchemaBuilder(); + } + + /** + * Get the registered name of the component. + * + * @return string + */ + protected static function getFacadeAccessor() + { + return static::$app['db']->connection()->getSchemaBuilder(); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Support/Facades/Session.php b/vendor/laravel/framework/src/Illuminate/Support/Facades/Session.php new file mode 100755 index 0000000..fdc6c7f --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Support/Facades/Session.php @@ -0,0 +1,16 @@ + $value) + { + $this->attributes[$key] = $value; + } + } + + /** + * Get an attribute from the container. + * + * @param string $key + * @param mixed $default + * @return mixed + */ + public function get($key, $default = null) + { + if (array_key_exists($key, $this->attributes)) + { + return $this->attributes[$key]; + } + + return value($default); + } + + /** + * Get the attributes from the container. + * + * @return array + */ + public function getAttributes() + { + return $this->attributes; + } + + /** + * Convert the Fluent instance to an array. + * + * @return array + */ + public function toArray() + { + return $this->attributes; + } + + /** + * Convert the Fluent instance to JSON. + * + * @param int $options + * @return string + */ + public function toJson($options = 0) + { + return json_encode($this->toArray(), $options); + } + + /** + * Determine if the given offset exists. + * + * @param string $offset + * @return bool + */ + public function offsetExists($offset) + { + return isset($this->{$offset}); + } + + /** + * Get the value for a given offset. + * + * @param string $offset + * @return mixed + */ + public function offsetGet($offset) + { + return $this->{$offset}; + } + + /** + * Set the value at the given offset. + * + * @param string $offset + * @param mixed $value + * @return void + */ + public function offsetSet($offset, $value) + { + $this->{$offset} = $value; + } + + /** + * Unset the value at the given offset. + * + * @param string $offset + * @return void + */ + public function offsetUnset($offset) + { + unset($this->{$offset}); + } + + /** + * Handle dynamic calls to the container to set attributes. + * + * @param string $method + * @param array $parameters + * @return \Illuminate\Support\Fluent + */ + public function __call($method, $parameters) + { + $this->attributes[$method] = count($parameters) > 0 ? $parameters[0] : true; + + return $this; + } + + /** + * Dynamically retrieve the value of an attribute. + * + * @param string $key + * @return mixed + */ + public function __get($key) + { + return $this->get($key); + } + + /** + * Dynamically set the value of an attribute. + * + * @param string $key + * @param mixed $value + * @return void + */ + public function __set($key, $value) + { + $this->attributes[$key] = $value; + } + + /** + * Dynamically check if an attribute is set. + * + * @param string $key + * @return void + */ + public function __isset($key) + { + return isset($this->attributes[$key]); + } + + /** + * Dynamically unset an attribute. + * + * @param string $key + * @return void + */ + public function __unset($key) + { + unset($this->attributes[$key]); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Support/Manager.php b/vendor/laravel/framework/src/Illuminate/Support/Manager.php new file mode 100755 index 0000000..7775a7d --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Support/Manager.php @@ -0,0 +1,134 @@ +app = $app; + } + + /** + * Get a driver instance. + * + * @param string $driver + * @return mixed + */ + public function driver($driver = null) + { + $driver = $driver ?: $this->getDefaultDriver(); + + // If the given driver has not been created before, we will create the instances + // here and cache it so we can return it next time very quickly. If there is + // already a driver created by this name, we'll just return that instance. + if ( ! isset($this->drivers[$driver])) + { + $this->drivers[$driver] = $this->createDriver($driver); + } + + return $this->drivers[$driver]; + } + + /** + * Create a new driver instance. + * + * @param string $driver + * @return mixed + * + * @throws \InvalidArgumentException + */ + protected function createDriver($driver) + { + $method = 'create'.ucfirst($driver).'Driver'; + + // We'll check to see if a creator method exists for the given driver. If not we + // will check for a custom driver creator, which allows developers to create + // drivers using their own customized driver creator Closure to create it. + if (isset($this->customCreators[$driver])) + { + return $this->callCustomCreator($driver); + } + elseif (method_exists($this, $method)) + { + return $this->$method(); + } + + throw new \InvalidArgumentException("Driver [$driver] not supported."); + } + + /** + * Call a custom driver creator. + * + * @param string $driver + * @return mixed + */ + protected function callCustomCreator($driver) + { + return $this->customCreators[$driver]($this->app); + } + + /** + * Register a custom driver creator Closure. + * + * @param string $driver + * @param Closure $callback + * @return \Illuminate\Support\Manager|static + */ + public function extend($driver, Closure $callback) + { + $this->customCreators[$driver] = $callback; + + return $this; + } + + /** + * Get all of the created "drivers". + * + * @return array + */ + public function getDrivers() + { + return $this->drivers; + } + + /** + * Dynamically call the default driver instance. + * + * @param string $method + * @param array $parameters + * @return mixed + */ + public function __call($method, $parameters) + { + return call_user_func_array(array($this->driver(), $method), $parameters); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Support/MessageBag.php b/vendor/laravel/framework/src/Illuminate/Support/MessageBag.php new file mode 100755 index 0000000..fcf7531 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Support/MessageBag.php @@ -0,0 +1,294 @@ + $value) + { + $this->messages[$key] = (array) $value; + } + } + + /** + * Add a message to the bag. + * + * @param string $key + * @param string $message + * @return \Illuminate\Support\MessageBag + */ + public function add($key, $message) + { + if ($this->isUnique($key, $message)) + { + $this->messages[$key][] = $message; + } + + return $this; + } + + /** + * Merge a new array of messages into the bag. + * + * @param \Illuminate\Support\Contracts\MessageProviderInterface|array $messages + * @return \Illuminate\Support\MessageBag + */ + public function merge($messages) + { + if ($messages instanceof MessageProviderInterface) + { + $messages = $messages->getMessageBag()->getMessages(); + } + + $this->messages = array_merge_recursive($this->messages, $messages); + + return $this; + } + + /** + * Determine if a key and message combination already exists. + * + * @param string $key + * @param string $message + * @return bool + */ + protected function isUnique($key, $message) + { + $messages = (array) $this->messages; + + return ! isset($messages[$key]) || ! in_array($message, $messages[$key]); + } + + /** + * Determine if messages exist for a given key. + * + * @param string $key + * @return bool + */ + public function has($key = null) + { + return $this->first($key) !== ''; + } + + /** + * Get the first message from the bag for a given key. + * + * @param string $key + * @param string $format + * @return string + */ + public function first($key = null, $format = null) + { + $messages = is_null($key) ? $this->all($format) : $this->get($key, $format); + + return (count($messages) > 0) ? $messages[0] : ''; + } + + /** + * Get all of the messages from the bag for a given key. + * + * @param string $key + * @param string $format + * @return array + */ + public function get($key, $format = null) + { + $format = $this->checkFormat($format); + + // If the message exists in the container, we will transform it and return + // the message. Otherwise, we'll return an empty array since the entire + // methods is to return back an array of messages in the first place. + if (array_key_exists($key, $this->messages)) + { + return $this->transform($this->messages[$key], $format, $key); + } + + return array(); + } + + /** + * Get all of the messages for every key in the bag. + * + * @param string $format + * @return array + */ + public function all($format = null) + { + $format = $this->checkFormat($format); + + $all = array(); + + foreach ($this->messages as $key => $messages) + { + $all = array_merge($all, $this->transform($messages, $format, $key)); + } + + return $all; + } + + /** + * Format an array of messages. + * + * @param array $messages + * @param string $format + * @param string $messageKey + * @return array + */ + protected function transform($messages, $format, $messageKey) + { + $messages = (array) $messages; + + // We will simply spin through the given messages and transform each one + // replacing the :message place holder with the real message allowing + // the messages to be easily formatted to each developer's desires. + foreach ($messages as $key => &$message) + { + $replace = array(':message', ':key'); + + $message = str_replace($replace, array($message, $messageKey), $format); + } + + return $messages; + } + + /** + * Get the appropriate format based on the given format. + * + * @param string $format + * @return string + */ + protected function checkFormat($format) + { + return ($format === null) ? $this->format : $format; + } + + /** + * Get the raw messages in the container. + * + * @return array + */ + public function getMessages() + { + return $this->messages; + } + + /** + * Get the messages for the instance. + * + * @return \Illuminate\Support\MessageBag + */ + public function getMessageBag() + { + return $this; + } + + /** + * Get the default message format. + * + * @return string + */ + public function getFormat() + { + return $this->format; + } + + /** + * Set the default message format. + * + * @param string $format + * @return \Illuminate\Support\MessageBag + */ + public function setFormat($format = ':message') + { + $this->format = $format; + + return $this; + } + + /** + * Determine if the message bag has any messages. + * + * @return bool + */ + public function isEmpty() + { + return ! $this->any(); + } + + /** + * Determine if the message bag has any messages. + * + * @return bool + */ + public function any() + { + return $this->count() > 0; + } + + /** + * Get the number of messages in the container. + * + * @return int + */ + public function count() + { + return count($this->messages, COUNT_RECURSIVE) - count($this->messages); + } + + /** + * Get the instance as an array. + * + * @return array + */ + public function toArray() + { + return $this->getMessages(); + } + + /** + * Convert the object to its JSON representation. + * + * @param int $options + * @return string + */ + public function toJson($options = 0) + { + return json_encode($this->toArray(), $options); + } + + /** + * Convert the message bag to its string representation. + * + * @return string + */ + public function __toString() + { + return $this->toJson(); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Support/NamespacedItemResolver.php b/vendor/laravel/framework/src/Illuminate/Support/NamespacedItemResolver.php new file mode 100755 index 0000000..4d09f85 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Support/NamespacedItemResolver.php @@ -0,0 +1,109 @@ +parsed[$key])) + { + return $this->parsed[$key]; + } + + $segments = explode('.', $key); + + // If the key does not contain a double colon, it means the key is not in a + // namespace, and is just a regular configuration item. Namespaces are a + // tool for organizing configuration items for things such as modules. + if (strpos($key, '::') === false) + { + $parsed = $this->parseBasicSegments($segments); + } + else + { + $parsed = $this->parseNamespacedSegments($key); + } + + // Once we have the parsed array of this key's elements, such as its groups + // and namespace, we will cache each array inside a simple list that has + // the key and the parsed array for quick look-ups for later requests. + return $this->parsed[$key] = $parsed; + } + + /** + * Parse an array of basic segments. + * + * @param array $segments + * @return array + */ + protected function parseBasicSegments(array $segments) + { + // The first segment in a basic array will always be the group, so we can go + // ahead and grab that segment. If there is only one total segment we are + // just pulling an entire group out of the array and not a single item. + $group = $segments[0]; + + if (count($segments) == 1) + { + return array(null, $group, null); + } + + // If there is more than one segment in this group, it means we are pulling + // a specific item out of a groups and will need to return the item name + // as well as the group so we know which item to pull from the arrays. + else + { + $item = implode('.', array_slice($segments, 1)); + + return array(null, $group, $item); + } + } + + /** + * Parse an array of namespaced segments. + * + * @param string $key + * @return array + */ + protected function parseNamespacedSegments($key) + { + list($namespace, $item) = explode('::', $key); + + // First we'll just explode the first segment to get the namespace and group + // since the item should be in the remaining segments. Once we have these + // two pieces of data we can proceed with parsing out the item's value. + $itemSegments = explode('.', $item); + + $groupAndItem = array_slice($this->parseBasicSegments($itemSegments), 1); + + return array_merge(array($namespace), $groupAndItem); + } + + /** + * Set the parsed value of a key. + * + * @param string $key + * @param array $parsed + * @return void + */ + public function setParsedKey($key, $parsed) + { + $this->parsed[$key] = $parsed; + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Support/Pluralizer.php b/vendor/laravel/framework/src/Illuminate/Support/Pluralizer.php new file mode 100755 index 0000000..81a3073 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Support/Pluralizer.php @@ -0,0 +1,246 @@ + "$1zes", + '/^(ox)$/i' => "$1en", + '/([m|l])ouse$/i' => "$1ice", + '/(matr|vert|ind)ix|ex$/i' => "$1ices", + '/(x|ch|ss|sh)$/i' => "$1es", + '/([^aeiouy]|qu)y$/i' => "$1ies", + '/(hive)$/i' => "$1s", + '/(?:([^f])fe|([lr])f)$/i' => "$1$2ves", + '/(shea|lea|loa|thie)f$/i' => "$1ves", + '/sis$/i' => "ses", + '/([ti])um$/i' => "$1a", + '/(tomat|potat|ech|her|vet)o$/i' => "$1oes", + '/(bu)s$/i' => "$1ses", + '/(alias)$/i' => "$1es", + '/(octop)us$/i' => "$1i", + '/(ax|test)is$/i' => "$1es", + '/(us)$/i' => "$1es", + '/s$/i' => "s", + '/$/' => "s", + ); + + /** + * Singular word form rules. + * + * @var array + */ + public static $singular = array( + '/(quiz)zes$/i' => "$1", + '/(matr)ices$/i' => "$1ix", + '/(vert|ind)ices$/i' => "$1ex", + '/^(ox)en$/i' => "$1", + '/(alias)es$/i' => "$1", + '/(octop|vir)i$/i' => "$1us", + '/(cris|ax|test)es$/i' => "$1is", + '/(shoe)s$/i' => "$1", + '/(o)es$/i' => "$1", + '/(bus)es$/i' => "$1", + '/([m|l])ice$/i' => "$1ouse", + '/(x|ch|ss|sh)es$/i' => "$1", + '/(m)ovies$/i' => "$1ovie", + '/(s)eries$/i' => "$1eries", + '/([^aeiouy]|qu)ies$/i' => "$1y", + '/([lr])ves$/i' => "$1f", + '/(tive)s$/i' => "$1", + '/(hive)s$/i' => "$1", + '/(li|wi|kni)ves$/i' => "$1fe", + '/(shea|loa|lea|thie)ves$/i' => "$1f", + '/(^analy)ses$/i' => "$1sis", + '/((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)ses$/i' => "$1$2sis", + '/([ti])a$/i' => "$1um", + '/(n)ews$/i' => "$1ews", + '/(h|bl)ouses$/i' => "$1ouse", + '/(corpse)s$/i' => "$1", + '/(us)es$/i' => "$1", + '/(us|ss)$/i' => "$1", + '/s$/i' => "", + ); + + /** + * Irregular word forms. + * + * @var array + */ + public static $irregular = array( + 'child' => 'children', + 'foot' => 'feet', + 'freshman' => 'freshmen', + 'goose' => 'geese', + 'human' => 'humans', + 'man' => 'men', + 'move' => 'moves', + 'person' => 'people', + 'sex' => 'sexes', + 'tooth' => 'teeth', + ); + + /** + * Uncountable word forms. + * + * @var array + */ + public static $uncountable = array( + 'audio', + 'equipment', + 'deer', + 'fish', + 'gold', + 'information', + 'money', + 'rice', + 'police', + 'series', + 'sheep', + 'species', + 'moose', + 'chassis', + 'traffic', + 'coreopsis', + ); + + /** + * The cached copies of the plural inflections. + * + * @var array + */ + protected static $pluralCache = array(); + + /** + * The cached copies of the singular inflections. + * + * @var array + */ + protected static $singularCache = array(); + + /** + * Get the singular form of the given word. + * + * @param string $value + * @return string + */ + public static function singular($value) + { + if (isset(static::$singularCache[$value])) + { + return static::$singularCache[$value]; + } + + $result = static::inflect($value, static::$singular, static::$irregular); + + return static::$singularCache[$value] = $result ?: $value; + } + + /** + * Get the plural form of the given word. + * + * @param string $value + * @param int $count + * @return string + */ + public static function plural($value, $count = 2) + { + if ($count == 1) return $value; + + // First we'll check the cache of inflected values. We cache each word that + // is inflected so we don't have to spin through the regular expressions + // on each subsequent method calls for this word by the app developer. + if (isset(static::$pluralCache[$value])) + { + return static::$pluralCache[$value]; + } + + $irregular = array_flip(static::$irregular); + + // When doing the singular to plural transformation, we'll flip the irregular + // array since we need to swap sides on the keys and values. After we have + // the transformed value we will cache it in memory for faster look-ups. + $plural = static::$plural; + + $result = static::inflect($value, $plural, $irregular); + + return static::$pluralCache[$value] = $result; + } + + /** + * Perform auto inflection on an English word. + * + * @param string $value + * @param array $source + * @param array $irregular + * @return string + */ + protected static function inflect($value, $source, $irregular) + { + if (static::uncountable($value)) return $value; + + // Next, we will check the "irregular" patterns which contain words that are + // not easily summarized in regular expression rules, like "children" and + // "teeth", both of which cannot get inflected using our typical rules. + foreach ($irregular as $irregular => $pattern) + { + if (preg_match($pattern = '/'.$pattern.'$/i', $value)) + { + $irregular = static::matchCase($irregular, $value); + + return preg_replace($pattern, $irregular, $value); + } + } + + // Finally, we'll spin through the array of regular expressions and look for + // matches for the word. If we find a match, we will cache and return the + // transformed value so we will quickly look it up on subsequent calls. + foreach ($source as $pattern => $inflected) + { + if (preg_match($pattern, $value)) + { + $inflected = preg_replace($pattern, $inflected, $value); + + return static::matchCase($inflected, $value); + } + } + } + + /** + * Determine if the given value is uncountable. + * + * @param string $value + * @return bool + */ + protected static function uncountable($value) + { + return in_array(strtolower($value), static::$uncountable); + } + + /** + * Attempt to match the case on two strings. + * + * @param string $value + * @param string $comparison + * @return string + */ + protected static function matchCase($value, $comparison) + { + $functions = array('mb_strtolower', 'mb_strtoupper', 'ucfirst', 'ucwords'); + + foreach ($functions as $function) + { + if (call_user_func($function, $comparison) === $comparison) + { + return call_user_func($function, $value); + } + } + + return $value; + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Support/SerializableClosure.php b/vendor/laravel/framework/src/Illuminate/Support/SerializableClosure.php new file mode 100755 index 0000000..1d8efac --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Support/SerializableClosure.php @@ -0,0 +1,59 @@ +determineCodeAndVariables(); + + return $this->code; + } + + /** + * Returns the "used" variables of the closure being serialized + * + * @return array + */ + public function getVariables() + { + $this->determineCodeAndVariables(); + + return $this->variables; + } + + /** + * Uses the serialize method directly to lazily fetch the code and variables if needed + */ + protected function determineCodeAndVariables() + { + if (!$this->code) + { + list($this->code, $this->variables) = unserialize($this->serialize()); + } + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Support/ServiceProvider.php b/vendor/laravel/framework/src/Illuminate/Support/ServiceProvider.php new file mode 100755 index 0000000..346e6c7 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Support/ServiceProvider.php @@ -0,0 +1,192 @@ +app = $app; + } + + /** + * Bootstrap the application events. + * + * @return void + */ + public function boot() {} + + /** + * Register the service provider. + * + * @return void + */ + abstract public function register(); + + /** + * Register the package's component namespaces. + * + * @param string $package + * @param string $namespace + * @param string $path + * @return void + */ + public function package($package, $namespace = null, $path = null) + { + $namespace = $this->getPackageNamespace($package, $namespace); + + // In this method we will register the configuration package for the package + // so that the configuration options cleanly cascade into the application + // folder to make the developers lives much easier in maintaining them. + $path = $path ?: $this->guessPackagePath(); + + $config = $path.'/config'; + + if ($this->app['files']->isDirectory($config)) + { + $this->app['config']->package($package, $config, $namespace); + } + + // Next we will check for any "language" components. If language files exist + // we will register them with this given package's namespace so that they + // may be accessed using the translation facilities of the application. + $lang = $path.'/lang'; + + if ($this->app['files']->isDirectory($lang)) + { + $this->app['translator']->addNamespace($namespace, $lang); + } + + // Next, we will see if the application view folder contains a folder for the + // package and namespace. If it does, we'll give that folder precedence on + // the loader list for the views so the package views can be overridden. + $appView = $this->getAppViewPath($package); + + if ($this->app['files']->isDirectory($appView)) + { + $this->app['view']->addNamespace($namespace, $appView); + } + + // Finally we will register the view namespace so that we can access each of + // the views available in this package. We use a standard convention when + // registering the paths to every package's views and other components. + $view = $path.'/views'; + + if ($this->app['files']->isDirectory($view)) + { + $this->app['view']->addNamespace($namespace, $view); + } + } + + /** + * Guess the package path for the provider. + * + * @return string + */ + public function guessPackagePath() + { + $path = with(new ReflectionClass($this))->getFileName(); + + return realpath(dirname($path).'/../../'); + } + + /** + * Determine the namespace for a package. + * + * @param string $package + * @param string $namespace + * @return string + */ + protected function getPackageNamespace($package, $namespace) + { + if (is_null($namespace)) + { + list($vendor, $namespace) = explode('/', $package); + } + + return $namespace; + } + + /** + * Register the package's custom Artisan commands. + * + * @param array $commands + * @return void + */ + public function commands($commands) + { + $commands = is_array($commands) ? $commands : func_get_args(); + + // To register the commands with Artisan, we will grab each of the arguments + // passed into the method and listen for Artisan "start" event which will + // give us the Artisan console instance which we will give commands to. + $events = $this->app['events']; + + $events->listen('artisan.start', function($artisan) use ($commands) + { + $artisan->resolveCommands($commands); + }); + } + + /** + * Get the application package view path. + * + * @param string $package + * @return string + */ + protected function getAppViewPath($package) + { + return $this->app['path']."/views/packages/{$package}"; + } + + /** + * Get the services provided by the provider. + * + * @return array + */ + public function provides() + { + return array(); + } + + /** + * Get the events that trigger this service provider to register. + * + * @return array + */ + public function when() + { + return array(); + } + + /** + * Determine if the provider is deferred. + * + * @return bool + */ + public function isDeferred() + { + return $this->defer; + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Support/Str.php b/vendor/laravel/framework/src/Illuminate/Support/Str.php new file mode 100755 index 0000000..ba8e669 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Support/Str.php @@ -0,0 +1,356 @@ +=5.3.0" + }, + "require-dev": { + "jeremeamia/superclosure": "1.0.*", + "patchwork/utf8": "1.1.*", + "mockery/mockery": "0.9.*", + "phpunit/phpunit": "4.0.*" + }, + "autoload": { + "psr-0": { + "Illuminate\\Support": "" + }, + "files": [ + "Illuminate/Support/helpers.php" + ] + }, + "target-dir": "Illuminate/Support", + "extra": { + "branch-alias": { + "dev-master": "4.1-dev" + } + }, + "minimum-stability": "dev" +} diff --git a/vendor/laravel/framework/src/Illuminate/Support/helpers.php b/vendor/laravel/framework/src/Illuminate/Support/helpers.php new file mode 100755 index 0000000..ede5d6c --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Support/helpers.php @@ -0,0 +1,1102 @@ +action($name, $parameters); + } +} + +if ( ! function_exists('app')) +{ + /** + * Get the root Facade application instance. + * + * @param string $make + * @return mixed + */ + function app($make = null) + { + if ( ! is_null($make)) + { + return app()->make($make); + } + + return Illuminate\Support\Facades\Facade::getFacadeApplication(); + } +} + +if ( ! function_exists('app_path')) +{ + /** + * Get the path to the application folder. + * + * @param string $path + * @return string + */ + function app_path($path = '') + { + return app('path').($path ? '/'.$path : $path); + } +} + +if ( ! function_exists('append_config')) +{ + /** + * Assign high numeric IDs to a config item to force appending. + * + * @param array $array + * @return array + */ + function append_config(array $array) + { + $start = 9999; + + foreach ($array as $key => $value) + { + if (is_numeric($key)) + { + $start++; + + $array[$start] = array_pull($array, $key); + } + } + + return $array; + } +} + +if ( ! function_exists('array_add')) +{ + /** + * Add an element to an array if it doesn't exist. + * + * @param array $array + * @param string $key + * @param mixed $value + * @return array + */ + function array_add($array, $key, $value) + { + if ( ! isset($array[$key])) $array[$key] = $value; + + return $array; + } +} + +if ( ! function_exists('array_build')) +{ + /** + * Build a new array using a callback. + * + * @param array $array + * @param \Closure $callback + * @return array + */ + function array_build($array, Closure $callback) + { + $results = array(); + + foreach ($array as $key => $value) + { + list($innerKey, $innerValue) = call_user_func($callback, $key, $value); + + $results[$innerKey] = $innerValue; + } + + return $results; + } +} + +if ( ! function_exists('array_divide')) +{ + /** + * Divide an array into two arrays. One with keys and the other with values. + * + * @param array $array + * @return array + */ + function array_divide($array) + { + return array(array_keys($array), array_values($array)); + } +} + +if ( ! function_exists('array_dot')) +{ + /** + * Flatten a multi-dimensional associative array with dots. + * + * @param array $array + * @param string $prepend + * @return array + */ + function array_dot($array, $prepend = '') + { + $results = array(); + + foreach ($array as $key => $value) + { + if (is_array($value)) + { + $results = array_merge($results, array_dot($value, $prepend.$key.'.')); + } + else + { + $results[$prepend.$key] = $value; + } + } + + return $results; + } +} + +if ( ! function_exists('array_except')) +{ + /** + * Get all of the given array except for a specified array of items. + * + * @param array $array + * @param array $keys + * @return array + */ + function array_except($array, $keys) + { + return array_diff_key($array, array_flip((array) $keys)); + } +} + +if ( ! function_exists('array_fetch')) +{ + /** + * Fetch a flattened array of a nested array element. + * + * @param array $array + * @param string $key + * @return array + */ + function array_fetch($array, $key) + { + foreach (explode('.', $key) as $segment) + { + $results = array(); + + foreach ($array as $value) + { + $value = (array) $value; + + $results[] = $value[$segment]; + } + + $array = array_values($results); + } + + return array_values($results); + } +} + +if ( ! function_exists('array_first')) +{ + /** + * Return the first element in an array passing a given truth test. + * + * @param array $array + * @param Closure $callback + * @param mixed $default + * @return mixed + */ + function array_first($array, $callback, $default = null) + { + foreach ($array as $key => $value) + { + if (call_user_func($callback, $key, $value)) return $value; + } + + return value($default); + } +} + +if ( ! function_exists('array_last')) +{ + /** + * Return the last element in an array passing a given truth test. + * + * @param array $array + * @param Closure $callback + * @param mixed $default + * @return mixed + */ + function array_last($array, $callback, $default = null) + { + return array_first(array_reverse($array), $callback, $default); + } +} + +if ( ! function_exists('array_flatten')) +{ + /** + * Flatten a multi-dimensional array into a single level. + * + * @param array $array + * @return array + */ + function array_flatten($array) + { + $return = array(); + + array_walk_recursive($array, function($x) use (&$return) { $return[] = $x; }); + + return $return; + } +} + +if ( ! function_exists('array_forget')) +{ + /** + * Remove an array item from a given array using "dot" notation. + * + * @param array $array + * @param string $key + * @return void + */ + function array_forget(&$array, $key) + { + $keys = explode('.', $key); + + while (count($keys) > 1) + { + $key = array_shift($keys); + + if ( ! isset($array[$key]) || ! is_array($array[$key])) + { + return; + } + + $array =& $array[$key]; + } + + unset($array[array_shift($keys)]); + } +} + +if ( ! function_exists('array_get')) +{ + /** + * Get an item from an array using "dot" notation. + * + * @param array $array + * @param string $key + * @param mixed $default + * @return mixed + */ + function array_get($array, $key, $default = null) + { + if (is_null($key)) return $array; + + if (isset($array[$key])) return $array[$key]; + + foreach (explode('.', $key) as $segment) + { + if ( ! is_array($array) || ! array_key_exists($segment, $array)) + { + return value($default); + } + + $array = $array[$segment]; + } + + return $array; + } +} + +if ( ! function_exists('array_only')) +{ + /** + * Get a subset of the items from the given array. + * + * @param array $array + * @param array $keys + * @return array + */ + function array_only($array, $keys) + { + return array_intersect_key($array, array_flip((array) $keys)); + } +} + +if ( ! function_exists('array_pluck')) +{ + /** + * Pluck an array of values from an array. + * + * @param array $array + * @param string $value + * @param string $key + * @return array + */ + function array_pluck($array, $value, $key = null) + { + $results = array(); + + foreach ($array as $item) + { + $itemValue = is_object($item) ? $item->{$value} : $item[$value]; + + // If the key is "null", we will just append the value to the array and keep + // looping. Otherwise we will key the array using the value of the key we + // received from the developer. Then we'll return the final array form. + if (is_null($key)) + { + $results[] = $itemValue; + } + else + { + $itemKey = is_object($item) ? $item->{$key} : $item[$key]; + + $results[$itemKey] = $itemValue; + } + } + + return $results; + } +} + +if ( ! function_exists('array_pull')) +{ + /** + * Get a value from the array, and remove it. + * + * @param array $array + * @param string $key + * @param mixed $default + * @return mixed + */ + function array_pull(&$array, $key, $default = null) + { + $value = array_get($array, $key, $default); + + array_forget($array, $key); + + return $value; + } +} + +if ( ! function_exists('array_set')) +{ + /** + * Set an array item to a given value using "dot" notation. + * + * If no key is given to the method, the entire array will be replaced. + * + * @param array $array + * @param string $key + * @param mixed $value + * @return array + */ + function array_set(&$array, $key, $value) + { + if (is_null($key)) return $array = $value; + + $keys = explode('.', $key); + + while (count($keys) > 1) + { + $key = array_shift($keys); + + // If the key doesn't exist at this depth, we will just create an empty array + // to hold the next value, allowing us to create the arrays to hold final + // values at the correct depth. Then we'll keep digging into the array. + if ( ! isset($array[$key]) || ! is_array($array[$key])) + { + $array[$key] = array(); + } + + $array =& $array[$key]; + } + + $array[array_shift($keys)] = $value; + + return $array; + } +} + +if ( ! function_exists('array_sort')) +{ + /** + * Sort the array using the given Closure. + * + * @param array $array + * @param \Closure $callback + * @return array + */ + function array_sort($array, Closure $callback) + { + return Illuminate\Support\Collection::make($array)->sortBy($callback)->all(); + } +} + +if ( ! function_exists('array_where')) +{ + /** + * Filter the array using the given Closure. + * + * @param array $array + * @param \Closure $callback + * @return array + */ + function array_where($array, Closure $callback) + { + $filtered = array(); + + foreach ($array as $key => $value) + { + if (call_user_func($callback, $key, $value)) $filtered[$key] = $value; + } + + return $filtered; + } +} + +if ( ! function_exists('asset')) +{ + /** + * Generate an asset path for the application. + * + * @param string $path + * @param bool $secure + * @return string + */ + function asset($path, $secure = null) + { + return app('url')->asset($path, $secure); + } +} + +if ( ! function_exists('base_path')) +{ + /** + * Get the path to the base of the install. + * + * @param string $path + * @return string + */ + function base_path($path = '') + { + return app()->make('path.base').($path ? '/'.$path : $path); + } +} + +if ( ! function_exists('camel_case')) +{ + /** + * Convert a value to camel case. + * + * @param string $value + * @return string + */ + function camel_case($value) + { + return Illuminate\Support\Str::camel($value); + } +} + +if ( ! function_exists('class_basename')) +{ + /** + * Get the class "basename" of the given object / class. + * + * @param string|object $class + * @return string + */ + function class_basename($class) + { + $class = is_object($class) ? get_class($class) : $class; + + return basename(str_replace('\\', '/', $class)); + } +} + +if ( ! function_exists('csrf_token')) +{ + /** + * Get the CSRF token value. + * + * @return string + * + * @throws RuntimeException + */ + function csrf_token() + { + $session = app('session'); + + if (isset($session)) + { + return $session->getToken(); + } + else + { + throw new RuntimeException("Application session store not set."); + } + } +} + +if ( ! function_exists('data_get')) +{ + /** + * Get an item from an array or object using "dot" notation. + * + * @param mixed $target + * @param string $key + * @param mixed $default + * @return mixed + */ + function data_get($target, $key, $default = null) + { + if (is_null($key)) return $target; + + foreach (explode('.', $key) as $segment) + { + if (is_array($target)) + { + if ( ! array_key_exists($segment, $target)) + { + return value($default); + } + + $target = $target[$segment]; + } + elseif (is_object($target)) + { + if ( ! isset($target->{$segment})) + { + return value($default); + } + + $target = $target->{$segment}; + } + else + { + return value($default); + } + } + + return $target; + } +} + +if ( ! function_exists('dd')) +{ + /** + * Dump the passed variables and end the script. + * + * @param dynamic mixed + * @return void + */ + function dd() + { + array_map(function($x) { var_dump($x); }, func_get_args()); die; + } +} + +if ( ! function_exists('e')) +{ + /** + * Escape HTML entities in a string. + * + * @param string $value + * @return string + */ + function e($value) + { + return htmlentities($value, ENT_QUOTES, 'UTF-8', false); + } +} + +if ( ! function_exists('ends_with')) +{ + /** + * Determine if a given string ends with a given substring. + * + * @param string $haystack + * @param string|array $needle + * @return bool + */ + function ends_with($haystack, $needle) + { + return Illuminate\Support\Str::endsWith($haystack, $needle); + } +} + +if ( ! function_exists('head')) +{ + /** + * Get the first element of an array. Useful for method chaining. + * + * @param array $array + * @return mixed + */ + function head($array) + { + return reset($array); + } +} + +if ( ! function_exists('link_to')) +{ + /** + * Generate a HTML link. + * + * @param string $url + * @param string $title + * @param array $attributes + * @param bool $secure + * @return string + */ + function link_to($url, $title = null, $attributes = array(), $secure = null) + { + return app('html')->link($url, $title, $attributes, $secure); + } +} + +if ( ! function_exists('last')) +{ + /** + * Get the last element from an array. + * + * @param array $array + * @return mixed + */ + function last($array) + { + return end($array); + } +} + +if ( ! function_exists('link_to_asset')) +{ + /** + * Generate a HTML link to an asset. + * + * @param string $url + * @param string $title + * @param array $attributes + * @param bool $secure + * @return string + */ + function link_to_asset($url, $title = null, $attributes = array(), $secure = null) + { + return app('html')->linkAsset($url, $title, $attributes, $secure); + } +} + +if ( ! function_exists('link_to_route')) +{ + /** + * Generate a HTML link to a named route. + * + * @param string $name + * @param string $title + * @param array $parameters + * @param array $attributes + * @return string + */ + function link_to_route($name, $title = null, $parameters = array(), $attributes = array()) + { + return app('html')->linkRoute($name, $title, $parameters, $attributes); + } +} + +if ( ! function_exists('link_to_action')) +{ + /** + * Generate a HTML link to a controller action. + * + * @param string $action + * @param string $title + * @param array $parameters + * @param array $attributes + * @return string + */ + function link_to_action($action, $title = null, $parameters = array(), $attributes = array()) + { + return app('html')->linkAction($action, $title, $parameters, $attributes); + } +} + +if ( ! function_exists('object_get')) +{ + /** + * Get an item from an object using "dot" notation. + * + * @param object $object + * @param string $key + * @param mixed $default + * @return mixed + */ + function object_get($object, $key, $default = null) + { + if (is_null($key) || trim($key) == '') return $object; + + foreach (explode('.', $key) as $segment) + { + if ( ! is_object($object) || ! isset($object->{$segment})) + { + return value($default); + } + + $object = $object->{$segment}; + } + + return $object; + } +} + +if ( ! function_exists('preg_replace_sub')) +{ + /** + * Replace a given pattern with each value in the array in sequentially. + * + * @param string $pattern + * @param array $replacements + * @param string $subject + * @return string + */ + function preg_replace_sub($pattern, &$replacements, $subject) + { + return preg_replace_callback($pattern, function($match) use (&$replacements) + { + return array_shift($replacements); + + }, $subject); + } +} + +if ( ! function_exists('public_path')) +{ + /** + * Get the path to the public folder. + * + * @param string $path + * @return string + */ + function public_path($path = '') + { + return app()->make('path.public').($path ? '/'.$path : $path); + } +} + +if ( ! function_exists('route')) +{ + /** + * Generate a URL to a named route. + * + * @param string $route + * @param array $parameters + * @return string + */ + function route($route, $parameters = array()) + { + return app('url')->route($route, $parameters); + } +} + +if ( ! function_exists('secure_asset')) +{ + /** + * Generate an asset path for the application. + * + * @param string $path + * @return string + */ + function secure_asset($path) + { + return asset($path, true); + } +} + +if ( ! function_exists('secure_url')) +{ + /** + * Generate a HTTPS url for the application. + * + * @param string $path + * @param mixed $parameters + * @return string + */ + function secure_url($path, $parameters = array()) + { + return url($path, $parameters, true); + } +} + +if ( ! function_exists('snake_case')) +{ + /** + * Convert a string to snake case. + * + * @param string $value + * @param string $delimiter + * @return string + */ + function snake_case($value, $delimiter = '_') + { + return Illuminate\Support\Str::snake($value, $delimiter); + } +} + +if ( ! function_exists('starts_with')) +{ + /** + * Determine if a given string starts with a given substring. + * + * @param string $haystack + * @param string|array $needle + * @return bool + */ + function starts_with($haystack, $needle) + { + return Illuminate\Support\Str::startsWith($haystack, $needle); + } +} + +if ( ! function_exists('storage_path')) +{ + /** + * Get the path to the storage folder. + * + * @param string $path + * @return string + */ + function storage_path($path = '') + { + return app('path.storage').($path ? '/'.$path : $path); + } +} + +if ( ! function_exists('str_contains')) +{ + /** + * Determine if a given string contains a given substring. + * + * @param string $haystack + * @param string|array $needle + * @return bool + */ + function str_contains($haystack, $needle) + { + return Illuminate\Support\Str::contains($haystack, $needle); + } +} + +if ( ! function_exists('str_finish')) +{ + /** + * Cap a string with a single instance of a given value. + * + * @param string $value + * @param string $cap + * @return string + */ + function str_finish($value, $cap) + { + return Illuminate\Support\Str::finish($value, $cap); + } +} + +if ( ! function_exists('str_is')) +{ + /** + * Determine if a given string matches a given pattern. + * + * @param string $pattern + * @param string $value + * @return bool + */ + function str_is($pattern, $value) + { + return Illuminate\Support\Str::is($pattern, $value); + } +} + +if ( ! function_exists('str_limit')) +{ + /** + * Limit the number of characters in a string. + * + * @param string $value + * @param int $limit + * @param string $end + * @return string + */ + function str_limit($value, $limit = 100, $end = '...') + { + return Illuminate\Support\Str::limit($value, $limit, $end); + } +} + +if ( ! function_exists('str_plural')) +{ + /** + * Get the plural form of an English word. + * + * @param string $value + * @param int $count + * @return string + */ + function str_plural($value, $count = 2) + { + return Illuminate\Support\Str::plural($value, $count); + } +} + +if ( ! function_exists('str_random')) +{ + /** + * Generate a more truly "random" alpha-numeric string. + * + * @param int $length + * @return string + * + * @throws \RuntimeException + */ + function str_random($length = 16) + { + return Illuminate\Support\Str::random($length); + } +} + +if ( ! function_exists('str_replace_array')) +{ + /** + * Replace a given value in the string sequentially with an array. + * + * @param string $search + * @param array $replace + * @param string $subject + * @return string + */ + function str_replace_array($search, array $replace, $subject) + { + foreach ($replace as $value) + { + $subject = preg_replace('/'.$search.'/', $value, $subject, 1); + } + + return $subject; + } +} + +if ( ! function_exists('str_singular')) +{ + /** + * Get the singular form of an English word. + * + * @param string $value + * @return string + */ + function str_singular($value) + { + return Illuminate\Support\Str::singular($value); + } +} + +if ( ! function_exists('studly_case')) +{ + /** + * Convert a value to studly caps case. + * + * @param string $value + * @return string + */ + function studly_case($value) + { + return Illuminate\Support\Str::studly($value); + } +} + +if ( ! function_exists('trans')) +{ + /** + * Translate the given message. + * + * @param string $id + * @param array $parameters + * @param string $domain + * @param string $locale + * @return string + */ + function trans($id, $parameters = array(), $domain = 'messages', $locale = null) + { + return app('translator')->trans($id, $parameters, $domain, $locale); + } +} + +if ( ! function_exists('trans_choice')) +{ + /** + * Translates the given message based on a count. + * + * @param string $id + * @param int $number + * @param array $parameters + * @param string $domain + * @param string $locale + * @return string + */ + function trans_choice($id, $number, array $parameters = array(), $domain = 'messages', $locale = null) + { + return app('translator')->transChoice($id, $number, $parameters, $domain, $locale); + } +} + +if ( ! function_exists('url')) +{ + /** + * Generate a url for the application. + * + * @param string $path + * @param mixed $parameters + * @param bool $secure + * @return string + */ + function url($path = null, $parameters = array(), $secure = null) + { + return app('url')->to($path, $parameters, $secure); + } +} + +if ( ! function_exists('value')) +{ + /** + * Return the default value of the given value. + * + * @param mixed $value + * @return mixed + */ + function value($value) + { + return $value instanceof Closure ? $value() : $value; + } +} + +if ( ! function_exists('with')) +{ + /** + * Return the given object. Useful for chaining. + * + * @param mixed $object + * @return mixed + */ + function with($object) + { + return $object; + } +} diff --git a/vendor/laravel/framework/src/Illuminate/Translation/FileLoader.php b/vendor/laravel/framework/src/Illuminate/Translation/FileLoader.php new file mode 100755 index 0000000..28adfc5 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Translation/FileLoader.php @@ -0,0 +1,132 @@ +path = $path; + $this->files = $files; + } + + /** + * Load the messages for the given locale. + * + * @param string $locale + * @param string $group + * @param string $namespace + * @return array + */ + public function load($locale, $group, $namespace = null) + { + if (is_null($namespace) || $namespace == '*') + { + return $this->loadPath($this->path, $locale, $group); + } + else + { + return $this->loadNamespaced($locale, $group, $namespace); + } + } + + /** + * Load a namespaced translation group. + * + * @param string $locale + * @param string $group + * @param string $namespace + * @return array + */ + protected function loadNamespaced($locale, $group, $namespace) + { + if (isset($this->hints[$namespace])) + { + $lines = $this->loadPath($this->hints[$namespace], $locale, $group); + + return $this->loadNamespaceOverrides($lines, $locale, $group, $namespace); + } + + return array(); + } + + /** + * Load a local namespaced translation group for overrides. + * + * @param array $lines + * @param string $locale + * @param string $group + * @param string $namespace + * @return array + */ + protected function loadNamespaceOverrides(array $lines, $locale, $group, $namespace) + { + $file = "{$this->path}/packages/{$locale}/{$namespace}/{$group}.php"; + + if ($this->files->exists($file)) + { + return array_replace_recursive($lines, $this->files->getRequire($file)); + } + + return $lines; + } + + /** + * Load a locale from a given path. + * + * @param string $path + * @param string $locale + * @param string $group + * @return array + */ + protected function loadPath($path, $locale, $group) + { + if ($this->files->exists($full = "{$path}/{$locale}/{$group}.php")) + { + return $this->files->getRequire($full); + } + + return array(); + } + + /** + * Add a new namespace to the loader. + * + * @param string $namespace + * @param string $hint + * @return void + */ + public function addNamespace($namespace, $hint) + { + $this->hints[$namespace] = $hint; + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Translation/LoaderInterface.php b/vendor/laravel/framework/src/Illuminate/Translation/LoaderInterface.php new file mode 100755 index 0000000..f0fbac5 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Translation/LoaderInterface.php @@ -0,0 +1,24 @@ +registerLoader(); + + $this->app->bindShared('translator', function($app) + { + $loader = $app['translation.loader']; + + // When registering the translator component, we'll need to set the default + // locale as well as the fallback locale. So, we'll grab the application + // configuration so we can easily get both of these values from there. + $locale = $app['config']['app.locale']; + + $trans = new Translator($loader, $locale); + + $trans->setFallback($app['config']['app.fallback_locale']); + + return $trans; + }); + } + + /** + * Register the translation line loader. + * + * @return void + */ + protected function registerLoader() + { + $this->app->bindShared('translation.loader', function($app) + { + return new FileLoader($app['files'], $app['path'].'/lang'); + }); + } + + /** + * Get the services provided by the provider. + * + * @return array + */ + public function provides() + { + return array('translator', 'translation.loader'); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Translation/Translator.php b/vendor/laravel/framework/src/Illuminate/Translation/Translator.php new file mode 100755 index 0000000..3f1f4f6 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Translation/Translator.php @@ -0,0 +1,366 @@ +loader = $loader; + $this->locale = $locale; + } + + /** + * Determine if a translation exists. + * + * @param string $key + * @param string $locale + * @return bool + */ + public function has($key, $locale = null) + { + return $this->get($key, array(), $locale) !== $key; + } + + /** + * Get the translation for the given key. + * + * @param string $key + * @param array $replace + * @param string $locale + * @return string + */ + public function get($key, array $replace = array(), $locale = null) + { + list($namespace, $group, $item) = $this->parseKey($key); + + // Here we will get the locale that should be used for the language line. If one + // was not passed, we will use the default locales which was given to us when + // the translator was instantiated. Then, we can load the lines and return. + foreach ($this->parseLocale($locale) as $locale) + { + $this->load($namespace, $group, $locale); + + $line = $this->getLine( + $namespace, $group, $locale, $item, $replace + ); + + if ( ! is_null($line)) break; + } + + // If the line doesn't exist, we will return back the key which was requested as + // that will be quick to spot in the UI if language keys are wrong or missing + // from the application's language files. Otherwise we can return the line. + if ( ! isset($line)) return $key; + + return $line; + } + + /** + * Retrieve a language line out the loaded array. + * + * @param string $namespace + * @param string $group + * @param string $locale + * @param string $item + * @param array $replace + * @return string|null + */ + protected function getLine($namespace, $group, $locale, $item, array $replace) + { + $line = array_get($this->loaded[$namespace][$group][$locale], $item); + + if (is_string($line)) + { + return $this->makeReplacements($line, $replace); + } + elseif (is_array($line) && count($line) > 0) + { + return $line; + } + } + + /** + * Make the place-holder replacements on a line. + * + * @param string $line + * @param array $replace + * @return string + */ + protected function makeReplacements($line, array $replace) + { + $replace = $this->sortReplacements($replace); + + foreach ($replace as $key => $value) + { + $line = str_replace(':'.$key, $value, $line); + } + + return $line; + } + + /** + * Sort the replacements array. + * + * @param array $replace + * @return array + */ + protected function sortReplacements(array $replace) + { + return with(new Collection($replace))->sortBy(function($r) + { + return mb_strlen($r) * -1; + }); + } + + /** + * Get a translation according to an integer value. + * + * @param string $key + * @param int $number + * @param array $replace + * @param string $locale + * @return string + */ + public function choice($key, $number, array $replace = array(), $locale = null) + { + $line = $this->get($key, $replace, $locale = $locale ?: $this->locale); + + $replace['count'] = $number; + + return $this->makeReplacements($this->getSelector()->choose($line, $number, $locale), $replace); + } + + /** + * Get the translation for a given key. + * + * @param string $id + * @param array $parameters + * @param string $domain + * @param string $locale + * @return string + */ + public function trans($id, array $parameters = array(), $domain = 'messages', $locale = null) + { + return $this->get($id, $parameters, $locale); + } + + /** + * Get a translation according to an integer value. + * + * @param string $id + * @param int $number + * @param array $parameters + * @param string $domain + * @param string $locale + * @return string + */ + public function transChoice($id, $number, array $parameters = array(), $domain = 'messages', $locale = null) + { + return $this->choice($id, $number, $parameters, $locale); + } + + /** + * Load the specified language group. + * + * @param string $namespace + * @param string $group + * @param string $locale + * @return void + */ + public function load($namespace, $group, $locale) + { + if ($this->isLoaded($namespace, $group, $locale)) return; + + // The loader is responsible for returning the array of language lines for the + // given namespace, group, and locale. We'll set the lines in this array of + // lines that have already been loaded so that we can easily access them. + $lines = $this->loader->load($locale, $group, $namespace); + + $this->loaded[$namespace][$group][$locale] = $lines; + } + + /** + * Determine if the given group has been loaded. + * + * @param string $namespace + * @param string $group + * @param string $locale + * @return bool + */ + protected function isLoaded($namespace, $group, $locale) + { + return isset($this->loaded[$namespace][$group][$locale]); + } + + /** + * Add a new namespace to the loader. + * + * @param string $namespace + * @param string $hint + * @return void + */ + public function addNamespace($namespace, $hint) + { + $this->loader->addNamespace($namespace, $hint); + } + + /** + * Parse a key into namespace, group, and item. + * + * @param string $key + * @return array + */ + public function parseKey($key) + { + $segments = parent::parseKey($key); + + if (is_null($segments[0])) $segments[0] = '*'; + + return $segments; + } + + /** + * Get the array of locales to be checked. + * + * @return array + */ + protected function parseLocale($locale) + { + if ( ! is_null($locale)) + { + return array_filter(array($locale, $this->fallback)); + } + else + { + return array_filter(array($this->locale, $this->fallback)); + } + } + + /** + * Get the message selector instance. + * + * @return \Symfony\Component\Translation\MessageSelector + */ + public function getSelector() + { + if ( ! isset($this->selector)) + { + $this->selector = new MessageSelector; + } + + return $this->selector; + } + + /** + * Set the message selector instance. + * + * @param \Symfony\Component\Translation\MessageSelector $selector + * @return void + */ + public function setSelector(MessageSelector $selector) + { + $this->selector = $selector; + } + + /** + * Get the language line loader implementation. + * + * @return \Illuminate\Translation\LoaderInterface + */ + public function getLoader() + { + return $this->loader; + } + + /** + * Get the default locale being used. + * + * @return string + */ + public function locale() + { + return $this->getLocale(); + } + + /** + * Get the default locale being used. + * + * @return string + */ + public function getLocale() + { + return $this->locale; + } + + /** + * Set the default locale. + * + * @param string $locale + * @return void + */ + public function setLocale($locale) + { + $this->locale = $locale; + } + + /** + * Get the fallback locale being used. + * + * @return string + */ + public function getFallback() + { + return $this->fallback; + } + + /** + * Set the fallback locale being used. + * + * @param string $fallback + * @return void + */ + public function setFallback($fallback) + { + $this->fallback = $fallback; + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Translation/composer.json b/vendor/laravel/framework/src/Illuminate/Translation/composer.json new file mode 100755 index 0000000..3919022 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Translation/composer.json @@ -0,0 +1,32 @@ +{ + "name": "illuminate/translation", + "license": "MIT", + "authors": [ + { + "name": "Taylor Otwell", + "email": "taylorotwell@gmail.com" + } + ], + "require": { + "php": ">=5.3.0", + "illuminate/filesystem": "4.1.*", + "illuminate/support": "4.1.*", + "symfony/translation": "2.4.*" + }, + "require-dev": { + "mockery/mockery": "0.9.*", + "phpunit/phpunit": "4.0.*" + }, + "autoload": { + "psr-0": { + "Illuminate\\Translation": "" + } + }, + "target-dir": "Illuminate/Translation", + "extra": { + "branch-alias": { + "dev-master": "4.1-dev" + } + }, + "minimum-stability": "dev" +} diff --git a/vendor/laravel/framework/src/Illuminate/Validation/DatabasePresenceVerifier.php b/vendor/laravel/framework/src/Illuminate/Validation/DatabasePresenceVerifier.php new file mode 100755 index 0000000..c277e5b --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Validation/DatabasePresenceVerifier.php @@ -0,0 +1,127 @@ +db = $db; + } + + /** + * Count the number of objects in a collection having the given value. + * + * @param string $collection + * @param string $column + * @param string $value + * @param int $excludeId + * @param string $idColumn + * @param array $extra + * @return int + */ + public function getCount($collection, $column, $value, $excludeId = null, $idColumn = null, array $extra = array()) + { + $query = $this->table($collection)->where($column, '=', $value); + + if ( ! is_null($excludeId) && $excludeId != 'NULL') + { + $query->where($idColumn ?: 'id', '<>', $excludeId); + } + + foreach ($extra as $key => $extraValue) + { + $this->addWhere($query, $key, $extraValue); + } + + return $query->count(); + } + + /** + * Count the number of objects in a collection with the given values. + * + * @param string $collection + * @param string $column + * @param array $values + * @param array $extra + * @return int + */ + public function getMultiCount($collection, $column, array $values, array $extra = array()) + { + $query = $this->table($collection)->whereIn($column, $values); + + foreach ($extra as $key => $extraValue) + { + $this->addWhere($query, $key, $extraValue); + } + + return $query->count(); + } + + /** + * Add a "where" clause to the given query. + * + * @param \Illuminate\Database\Query\Builder $query + * @param string $key + * @param string $extraValue + * @return void + */ + protected function addWhere($query, $key, $extraValue) + { + if ($extraValue === 'NULL') + { + $query->whereNull($key); + } + elseif ($extraValue === 'NOT_NULL') + { + $query->whereNotNull($key); + } + else + { + $query->where($key, $extraValue); + } + } + + /** + * Get a query builder for the given table. + * + * @param string $table + * @return \Illuminate\Database\Query\Builder + */ + protected function table($table) + { + return $this->db->connection($this->connection)->table($table); + } + + /** + * Set the connection to be used. + * + * @param string $connection + * @return void + */ + public function setConnection($connection) + { + $this->connection = $connection; + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Validation/Factory.php b/vendor/laravel/framework/src/Illuminate/Validation/Factory.php new file mode 100755 index 0000000..1d4cf4e --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Validation/Factory.php @@ -0,0 +1,239 @@ +container = $container; + $this->translator = $translator; + } + + /** + * Create a new Validator instance. + * + * @param array $data + * @param array $rules + * @param array $messages + * @param array $customAttributes + * @return \Illuminate\Validation\Validator + */ + public function make(array $data, array $rules, array $messages = array(), array $customAttributes = array()) + { + // The presence verifier is responsible for checking the unique and exists data + // for the validator. It is behind an interface so that multiple versions of + // it may be written besides database. We'll inject it into the validator. + $validator = $this->resolve($data, $rules, $messages, $customAttributes); + + if ( ! is_null($this->verifier)) + { + $validator->setPresenceVerifier($this->verifier); + } + + // Next we'll set the IoC container instance of the validator, which is used to + // resolve out class based validator extensions. If it is not set then these + // types of extensions will not be possible on these validation instances. + if ( ! is_null($this->container)) + { + $validator->setContainer($this->container); + } + + $this->addExtensions($validator); + + return $validator; + } + + /** + * Add the extensions to a validator instance. + * + * @param \Illuminate\Validation\Validator $validator + * @return void + */ + protected function addExtensions(Validator $validator) + { + $validator->addExtensions($this->extensions); + + // Next, we will add the implicit extensions, which are similar to the required + // and accepted rule in that they are run even if the attributes is not in a + // array of data that is given to a validator instances via instantiation. + $implicit = $this->implicitExtensions; + + $validator->addImplicitExtensions($implicit); + + $validator->addReplacers($this->replacers); + + $validator->setFallbackMessages($this->fallbackMessages); + } + + /** + * Resolve a new Validator instance. + * + * @param array $data + * @param array $rules + * @param array $messages + * @param array $customAttributes + * @return \Illuminate\Validation\Validator + */ + protected function resolve(array $data, array $rules, array $messages, array $customAttributes) + { + if (is_null($this->resolver)) + { + return new Validator($this->translator, $data, $rules, $messages, $customAttributes); + } + else + { + return call_user_func($this->resolver, $this->translator, $data, $rules, $messages, $customAttributes); + } + } + + /** + * Register a custom validator extension. + * + * @param string $rule + * @param \Closure|string $extension + * @param string $message + * @return void + */ + public function extend($rule, $extension, $message = null) + { + $this->extensions[$rule] = $extension; + + if ($message) $this->fallbackMessages[snake_case($rule)] = $message; + } + + /** + * Register a custom implicit validator extension. + * + * @param string $rule + * @param \Closure|string $extension + * @param string $message + * @return void + */ + public function extendImplicit($rule, $extension, $message = null) + { + $this->implicitExtensions[$rule] = $extension; + + if ($message) $this->fallbackMessages[snake_case($rule)] = $message; + } + + /** + * Register a custom implicit validator message replacer. + * + * @param string $rule + * @param \Closure|string $replacer + * @return void + */ + public function replacer($rule, $replacer) + { + $this->replacers[$rule] = $replacer; + } + + /** + * Set the Validator instance resolver. + * + * @param Closure $resolver + * @return void + */ + public function resolver(Closure $resolver) + { + $this->resolver = $resolver; + } + + /** + * Get the Translator implementation. + * + * @return \Symfony\Component\Translation\TranslatorInterface + */ + public function getTranslator() + { + return $this->translator; + } + + /** + * Get the Presence Verifier implementation. + * + * @return \Illuminate\Validation\PresenceVerifierInterface + */ + public function getPresenceVerifier() + { + return $this->verifier; + } + + /** + * Set the Presence Verifier implementation. + * + * @param \Illuminate\Validation\PresenceVerifierInterface $presenceVerifier + * @return void + */ + public function setPresenceVerifier(PresenceVerifierInterface $presenceVerifier) + { + $this->verifier = $presenceVerifier; + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Validation/PresenceVerifierInterface.php b/vendor/laravel/framework/src/Illuminate/Validation/PresenceVerifierInterface.php new file mode 100755 index 0000000..32fd3f4 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Validation/PresenceVerifierInterface.php @@ -0,0 +1,29 @@ +registerPresenceVerifier(); + + $this->app->bindShared('validator', function($app) + { + $validator = new Factory($app['translator'], $app); + + // The validation presence verifier is responsible for determining the existence + // of values in a given data collection, typically a relational database or + // other persistent data stores. And it is used to check for uniqueness. + if (isset($app['validation.presence'])) + { + $validator->setPresenceVerifier($app['validation.presence']); + } + + return $validator; + }); + } + + /** + * Register the database presence verifier. + * + * @return void + */ + protected function registerPresenceVerifier() + { + $this->app->bindShared('validation.presence', function($app) + { + return new DatabasePresenceVerifier($app['db']); + }); + } + + /** + * Get the services provided by the provider. + * + * @return array + */ + public function provides() + { + return array('validator', 'validation.presence'); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Validation/Validator.php b/vendor/laravel/framework/src/Illuminate/Validation/Validator.php new file mode 100755 index 0000000..58abec7 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Validation/Validator.php @@ -0,0 +1,2228 @@ +translator = $translator; + $this->customMessages = $messages; + $this->data = $this->parseData($data); + $this->rules = $this->explodeRules($rules); + $this->customAttributes = $customAttributes; + } + + /** + * Parse the data and hydrate the files array. + * + * @param array $data + * @return array + */ + protected function parseData(array $data) + { + $this->files = array(); + + foreach ($data as $key => $value) + { + // If this value is an instance of the HttpFoundation File class we will + // remove it from the data array and add it to the files array, which + // we use to conveniently separate out these files from other data. + if ($value instanceof File) + { + $this->files[$key] = $value; + + unset($data[$key]); + } + } + + return $data; + } + + /** + * Explode the rules into an array of rules. + * + * @param string|array $rules + * @return array + */ + protected function explodeRules($rules) + { + foreach ($rules as $key => &$rule) + { + $rule = (is_string($rule)) ? explode('|', $rule) : $rule; + } + + return $rules; + } + + /** + * Add conditions to a given field based on a Closure. + * + * @param string $attribute + * @param string|array $rules + * @param callable $callback + * @return void + */ + public function sometimes($attribute, $rules, $callback) + { + $payload = new Fluent(array_merge($this->data, $this->files)); + + if (call_user_func($callback, $payload)) + { + foreach ((array) $attribute as $key) + { + $this->mergeRules($key, $rules); + } + } + } + + /** + * Merge additional rules into a given attribute. + * + * @param string $attribute + * @param string|array $rules + * @return void + */ + public function mergeRules($attribute, $rules) + { + $current = array_get($this->rules, $attribute, array()); + + $merge = head($this->explodeRules(array($rules))); + + $this->rules[$attribute] = array_merge($current, $merge); + } + + /** + * Determine if the data passes the validation rules. + * + * @return bool + */ + public function passes() + { + $this->messages = new MessageBag; + + // We'll spin through each rule, validating the attributes attached to that + // rule. Any error messages will be added to the containers with each of + // the other error messages, returning true if we don't have messages. + foreach ($this->rules as $attribute => $rules) + { + foreach ($rules as $rule) + { + $this->validate($attribute, $rule); + } + } + + return count($this->messages->all()) === 0; + } + + /** + * Determine if the data fails the validation rules. + * + * @return bool + */ + public function fails() + { + return ! $this->passes(); + } + + /** + * Validate a given attribute against a rule. + * + * @param string $attribute + * @param string $rule + * @return void + */ + protected function validate($attribute, $rule) + { + if (trim($rule) == '') return; + + list($rule, $parameters) = $this->parseRule($rule); + + // We will get the value for the given attribute from the array of data and then + // verify that the attribute is indeed validatable. Unless the rule implies + // that the attribute is required, rules are not run for missing values. + $value = $this->getValue($attribute); + + $validatable = $this->isValidatable($rule, $attribute, $value); + + $method = "validate{$rule}"; + + if ($validatable && ! $this->$method($attribute, $value, $parameters, $this)) + { + $this->addFailure($attribute, $rule, $parameters); + } + } + + /** + * Get the value of a given attribute. + * + * @param string $attribute + * @return mixed + */ + protected function getValue($attribute) + { + if ( ! is_null($value = array_get($this->data, $attribute))) + { + return $value; + } + elseif ( ! is_null($value = array_get($this->files, $attribute))) + { + return $value; + } + } + + /** + * Determine if the attribute is validatable. + * + * @param string $rule + * @param string $attribute + * @param mixed $value + * @return bool + */ + protected function isValidatable($rule, $attribute, $value) + { + return $this->presentOrRuleIsImplicit($rule, $attribute, $value) && + $this->passesOptionalCheck($attribute); + } + + /** + * Determine if the field is present, or the rule implies required. + * + * @param string $rule + * @param string $attribute + * @param mixed $value + * @return bool + */ + protected function presentOrRuleIsImplicit($rule, $attribute, $value) + { + return $this->validateRequired($attribute, $value) || $this->isImplicit($rule); + } + + /** + * Determine if the attribute passes any optional check. + * + * @param string $attribute + * @return bool + */ + protected function passesOptionalCheck($attribute) + { + if ($this->hasRule($attribute, array('Sometimes'))) + { + return array_key_exists($attribute, $this->data) || array_key_exists($attribute, $this->files); + } + else + { + return true; + } + } + + /** + * Determine if a given rule implies the attribute is required. + * + * @param string $rule + * @return bool + */ + protected function isImplicit($rule) + { + return in_array($rule, $this->implicitRules); + } + + /** + * Add a failed rule and error message to the collection. + * + * @param string $attribute + * @param string $rule + * @param array $parameters + * @return void + */ + protected function addFailure($attribute, $rule, $parameters) + { + $this->addError($attribute, $rule, $parameters); + + $this->failedRules[$attribute][$rule] = $parameters; + } + + /** + * Add an error message to the validator's collection of messages. + * + * @param string $attribute + * @param string $rule + * @param array $parameters + * @return void + */ + protected function addError($attribute, $rule, $parameters) + { + $message = $this->getMessage($attribute, $rule); + + $message = $this->doReplacements($message, $attribute, $rule, $parameters); + + $this->messages->add($attribute, $message); + } + + /** + * "Validate" optional attributes. + * + * Always returns true, just lets us put sometimes in rules. + * + * @return bool + */ + protected function validateSometimes() + { + return true; + } + + /** + * Validate that a required attribute exists. + * + * @param string $attribute + * @param mixed $value + * @return bool + */ + protected function validateRequired($attribute, $value) + { + if (is_null($value)) + { + return false; + } + elseif (is_string($value) && trim($value) === '') + { + return false; + } + elseif ($value instanceof File) + { + return (string) $value->getPath() != ''; + } + + return true; + } + + /** + * Validate the given attribute is filled if it is present. + * + * @param string $attribute + * @param mixed $value + * @return bool + */ + protected function validateFilled($attribute, $value) + { + if (array_key_exists($attribute, $this->data) || array_key_exists($attribute, $this->files)) + { + return $this->validateRequired($attribute, $value); + } + else + { + return true; + } + } + + /** + * Determine if any of the given attributes fail the required test. + * + * @param array $attributes + * @return bool + */ + protected function anyFailingRequired(array $attributes) + { + foreach ($attributes as $key) + { + if ( ! $this->validateRequired($key, $this->getValue($key))) + { + return true; + } + } + + return false; + } + + /** + * Determine if all of the given attributes fail the required test. + * + * @param array $attributes + * @return bool + */ + protected function allFailingRequired(array $attributes) + { + foreach ($attributes as $key) + { + if ($this->validateRequired($key, $this->getValue($key))) + { + return false; + } + } + + return true; + } + + /** + * Validate that an attribute exists when any other attribute exists. + * + * @param string $attribute + * @param mixed $value + * @param mixed $parameters + * @return bool + */ + protected function validateRequiredWith($attribute, $value, $parameters) + { + if ( ! $this->allFailingRequired($parameters)) + { + return $this->validateRequired($attribute, $value); + } + + return true; + } + + /** + * Validate that an attribute exists when all other attributes exists. + * + * @param string $attribute + * @param mixed $value + * @param mixed $parameters + * @return bool + */ + protected function validateRequiredWithAll($attribute, $value, $parameters) + { + if ( ! $this->anyFailingRequired($parameters)) + { + return $this->validateRequired($attribute, $value); + } + + return true; + } + + /** + * Validate that an attribute exists when another attribute does not. + * + * @param string $attribute + * @param mixed $value + * @param mixed $parameters + * @return bool + */ + protected function validateRequiredWithout($attribute, $value, $parameters) + { + if ($this->anyFailingRequired($parameters)) + { + return $this->validateRequired($attribute, $value); + } + + return true; + } + + /** + * Validate that an attribute exists when all other attributes do not. + * + * @param string $attribute + * @param mixed $value + * @param mixed $parameters + * @return bool + */ + protected function validateRequiredWithoutAll($attribute, $value, $parameters) + { + if ($this->allFailingRequired($parameters)) + { + return $this->validateRequired($attribute, $value); + } + + return true; + } + + /** + * Validate that an attribute exists when another attribute has a given value. + * + * @param string $attribute + * @param mixed $value + * @param mixed $parameters + * @return bool + */ + protected function validateRequiredIf($attribute, $value, $parameters) + { + $this->requireParameterCount(2, $parameters, 'required_if'); + + if ($parameters[1] == array_get($this->data, $parameters[0])) + { + return $this->validateRequired($attribute, $value); + } + + return true; + } + + /** + * Get the number of attributes in a list that are present. + * + * @param array $attributes + * @return int + */ + protected function getPresentCount($attributes) + { + $count = 0; + + foreach ($attributes as $key) + { + if (array_get($this->data, $key) || array_get($this->files, $key)) + { + $count++; + } + } + + return $count; + } + + /** + * Validate that an attribute has a matching confirmation. + * + * @param string $attribute + * @param mixed $value + * @return bool + */ + protected function validateConfirmed($attribute, $value) + { + return $this->validateSame($attribute, $value, array($attribute.'_confirmation')); + } + + /** + * Validate that two attributes match. + * + * @param string $attribute + * @param mixed $value + * @param array $parameters + * @return bool + */ + protected function validateSame($attribute, $value, $parameters) + { + $this->requireParameterCount(1, $parameters, 'same'); + + $other = array_get($this->data, $parameters[0]); + + return (isset($other) && $value == $other); + } + + /** + * Validate that an attribute is different from another attribute. + * + * @param string $attribute + * @param mixed $value + * @param array $parameters + * @return bool + */ + protected function validateDifferent($attribute, $value, $parameters) + { + $this->requireParameterCount(1, $parameters, 'different'); + + $other = $parameters[0]; + + return isset($this->data[$other]) && $value != $this->data[$other]; + } + + /** + * Validate that an attribute was "accepted". + * + * This validation rule implies the attribute is "required". + * + * @param string $attribute + * @param mixed $value + * @return bool + */ + protected function validateAccepted($attribute, $value) + { + $acceptable = array('yes', 'on', '1', 1, true, 'true'); + + return ($this->validateRequired($attribute, $value) && in_array($value, $acceptable, true)); + } + + /** + * Validate that an attribute is an array. + * + * @param string $attribute + * @param mixed $value + * @return bool + */ + protected function validateArray($attribute, $value) + { + return is_array($value); + } + + /** + * Validate that an attribute is numeric. + * + * @param string $attribute + * @param mixed $value + * @return bool + */ + protected function validateNumeric($attribute, $value) + { + return is_numeric($value); + } + + /** + * Validate that an attribute is an integer. + * + * @param string $attribute + * @param mixed $value + * @return bool + */ + protected function validateInteger($attribute, $value) + { + return filter_var($value, FILTER_VALIDATE_INT) !== false; + } + + /** + * Validate that an attribute has a given number of digits. + * + * @param string $attribute + * @param mixed $value + * @param array $parameters + * @return bool + */ + protected function validateDigits($attribute, $value, $parameters) + { + $this->requireParameterCount(1, $parameters, 'digits'); + + return $this->validateNumeric($attribute, $value) + && strlen((string) $value) == $parameters[0]; + } + + /** + * Validate that an attribute is between a given number of digits. + * + * @param string $attribute + * @param mixed $value + * @param array $parameters + * @return bool + */ + protected function validateDigitsBetween($attribute, $value, $parameters) + { + $this->requireParameterCount(2, $parameters, 'digits_between'); + + $length = strlen((string) $value); + + return $length >= $parameters[0] && $length <= $parameters[1]; + } + + /** + * Validate the size of an attribute. + * + * @param string $attribute + * @param mixed $value + * @param array $parameters + * @return bool + */ + protected function validateSize($attribute, $value, $parameters) + { + $this->requireParameterCount(1, $parameters, 'size'); + + return $this->getSize($attribute, $value) == $parameters[0]; + } + + /** + * Validate the size of an attribute is between a set of values. + * + * @param string $attribute + * @param mixed $value + * @param array $parameters + * @return bool + */ + protected function validateBetween($attribute, $value, $parameters) + { + $this->requireParameterCount(2, $parameters, 'between'); + + $size = $this->getSize($attribute, $value); + + return $size >= $parameters[0] && $size <= $parameters[1]; + } + + /** + * Validate the size of an attribute is greater than a minimum value. + * + * @param string $attribute + * @param mixed $value + * @param array $parameters + * @return bool + */ + protected function validateMin($attribute, $value, $parameters) + { + $this->requireParameterCount(1, $parameters, 'min'); + + return $this->getSize($attribute, $value) >= $parameters[0]; + } + + /** + * Validate the size of an attribute is less than a maximum value. + * + * @param string $attribute + * @param mixed $value + * @param array $parameters + * @return bool + */ + protected function validateMax($attribute, $value, $parameters) + { + $this->requireParameterCount(1, $parameters, 'max'); + + if ($value instanceof UploadedFile && ! $value->isValid()) return false; + + return $this->getSize($attribute, $value) <= $parameters[0]; + } + + /** + * Get the size of an attribute. + * + * @param string $attribute + * @param mixed $value + * @return mixed + */ + protected function getSize($attribute, $value) + { + $hasNumeric = $this->hasRule($attribute, $this->numericRules); + + // This method will determine if the attribute is a number, string, or file and + // return the proper size accordingly. If it is a number, then number itself + // is the size. If it is a file, we take kilobytes, and for a string the + // entire length of the string will be considered the attribute size. + if (is_numeric($value) && $hasNumeric) + { + return array_get($this->data, $attribute); + } + elseif (is_array($value)) + { + return count($value); + } + elseif ($value instanceof File) + { + return $value->getSize() / 1024; + } + else + { + return $this->getStringSize($value); + } + } + + /** + * Get the size of a string. + * + * @param string $value + * @return int + */ + protected function getStringSize($value) + { + if (function_exists('mb_strlen')) return mb_strlen($value); + + return strlen($value); + } + + /** + * Validate an attribute is contained within a list of values. + * + * @param string $attribute + * @param mixed $value + * @param array $parameters + * @return bool + */ + protected function validateIn($attribute, $value, $parameters) + { + return in_array((string) $value, $parameters); + } + + /** + * Validate an attribute is not contained within a list of values. + * + * @param string $attribute + * @param mixed $value + * @param array $parameters + * @return bool + */ + protected function validateNotIn($attribute, $value, $parameters) + { + return ! in_array((string) $value, $parameters); + } + + /** + * Validate the uniqueness of an attribute value on a given database table. + * + * If a database column is not specified, the attribute will be used. + * + * @param string $attribute + * @param mixed $value + * @param array $parameters + * @return bool + */ + protected function validateUnique($attribute, $value, $parameters) + { + $this->requireParameterCount(1, $parameters, 'unique'); + + $table = $parameters[0]; + + // The second parameter position holds the name of the column that needs to + // be verified as unique. If this parameter isn't specified we will just + // assume that this column to be verified shares the attribute's name. + $column = isset($parameters[1]) ? $parameters[1] : $attribute; + + list($idColumn, $id) = array(null, null); + + if (isset($parameters[2])) + { + list($idColumn, $id) = $this->getUniqueIds($parameters); + + if (strtolower($id) == 'null') $id = null; + } + + // The presence verifier is responsible for counting rows within this store + // mechanism which might be a relational database or any other permanent + // data store like Redis, etc. We will use it to determine uniqueness. + $verifier = $this->getPresenceVerifier(); + + $extra = $this->getUniqueExtra($parameters); + + return $verifier->getCount( + + $table, $column, $value, $id, $idColumn, $extra + + ) == 0; + } + + /** + * Get the excluded ID column and value for the unique rule. + * + * @param array $parameters + * @return array + */ + protected function getUniqueIds($parameters) + { + $idColumn = isset($parameters[3]) ? $parameters[3] : 'id'; + + return array($idColumn, $parameters[2]); + } + + /** + * Get the extra conditions for a unique rule. + * + * @param array $parameters + * @return array + */ + protected function getUniqueExtra($parameters) + { + if (isset($parameters[4])) + { + return $this->getExtraConditions(array_slice($parameters, 4)); + } + else + { + return array(); + } + } + + /** + * Validate the existence of an attribute value in a database table. + * + * @param string $attribute + * @param mixed $value + * @param array $parameters + * @return bool + */ + protected function validateExists($attribute, $value, $parameters) + { + $this->requireParameterCount(1, $parameters, 'exists'); + + $table = $parameters[0]; + + // The second parameter position holds the name of the column that should be + // verified as existing. If this parameter is not specified we will guess + // that the columns being "verified" shares the given attribute's name. + $column = isset($parameters[1]) ? $parameters[1] : $attribute; + + $expected = (is_array($value)) ? count($value) : 1; + + return $this->getExistCount($table, $column, $value, $parameters) >= $expected; + } + + /** + * Get the number of records that exist in storage. + * + * @param string $table + * @param string $column + * @param mixed $value + * @param array $parameters + * @return int + */ + protected function getExistCount($table, $column, $value, $parameters) + { + $verifier = $this->getPresenceVerifier(); + + $extra = $this->getExtraExistConditions($parameters); + + if (is_array($value)) + { + return $verifier->getMultiCount($table, $column, $value, $extra); + } + else + { + return $verifier->getCount($table, $column, $value, null, null, $extra); + } + } + + /** + * Get the extra exist conditions. + * + * @param array $parameters + * @return array + */ + protected function getExtraExistConditions(array $parameters) + { + return $this->getExtraConditions(array_values(array_slice($parameters, 2))); + } + + /** + * Get the extra conditions for a unique / exists rule. + * + * @param array $segments + * @return array + */ + protected function getExtraConditions(array $segments) + { + $extra = array(); + + $count = count($segments); + + for ($i = 0; $i < $count; $i = $i + 2) + { + $extra[$segments[$i]] = $segments[$i + 1]; + } + + return $extra; + } + + /** + * Validate that an attribute is a valid IP. + * + * @param string $attribute + * @param mixed $value + * @return bool + */ + protected function validateIp($attribute, $value) + { + return filter_var($value, FILTER_VALIDATE_IP) !== false; + } + + /** + * Validate that an attribute is a valid e-mail address. + * + * @param string $attribute + * @param mixed $value + * @return bool + */ + protected function validateEmail($attribute, $value) + { + return filter_var($value, FILTER_VALIDATE_EMAIL) !== false; + } + + /** + * Validate that an attribute is a valid URL. + * + * @param string $attribute + * @param mixed $value + * @return bool + */ + protected function validateUrl($attribute, $value) + { + return filter_var($value, FILTER_VALIDATE_URL) !== false; + } + + /** + * Validate that an attribute is an active URL. + * + * @param string $attribute + * @param mixed $value + * @return bool + */ + protected function validateActiveUrl($attribute, $value) + { + $url = str_replace(array('http://', 'https://', 'ftp://'), '', strtolower($value)); + + return checkdnsrr($url); + } + + /** + * Validate the MIME type of a file is an image MIME type. + * + * @param string $attribute + * @param mixed $value + * @return bool + */ + protected function validateImage($attribute, $value) + { + return $this->validateMimes($attribute, $value, array('jpeg', 'png', 'gif', 'bmp')); + } + + /** + * Validate the MIME type of a file upload attribute is in a set of MIME types. + * + * @param string $attribute + * @param array $value + * @param array $parameters + * @return bool + */ + protected function validateMimes($attribute, $value, $parameters) + { + if ( ! $value instanceof File) + { + return false; + } + + // The Symfony File class should do a decent job of guessing the extension + // based on the true MIME type so we'll just loop through the array of + // extensions and compare it to the guessed extension of the files. + if ($value->isValid() && $value->getPath() != '') + { + return in_array($value->guessExtension(), $parameters); + } + else + { + return false; + } + } + + /** + * Validate that an attribute contains only alphabetic characters. + * + * @param string $attribute + * @param mixed $value + * @return bool + */ + protected function validateAlpha($attribute, $value) + { + return preg_match('/^\pL+$/u', $value); + } + + /** + * Validate that an attribute contains only alpha-numeric characters. + * + * @param string $attribute + * @param mixed $value + * @return bool + */ + protected function validateAlphaNum($attribute, $value) + { + return preg_match('/^[\pL\pN]+$/u', $value); + } + + /** + * Validate that an attribute contains only alpha-numeric characters, dashes, and underscores. + * + * @param string $attribute + * @param mixed $value + * @return bool + */ + protected function validateAlphaDash($attribute, $value) + { + return preg_match('/^[\pL\pN_-]+$/u', $value); + } + + /** + * Validate that an attribute passes a regular expression check. + * + * @param string $attribute + * @param mixed $value + * @param array $parameters + * @return bool + */ + protected function validateRegex($attribute, $value, $parameters) + { + $this->requireParameterCount(1, $parameters, 'regex'); + + return preg_match($parameters[0], $value); + } + + /** + * Validate that an attribute is a valid date. + * + * @param string $attribute + * @param mixed $value + * @return bool + */ + protected function validateDate($attribute, $value) + { + if ($value instanceof DateTime) return true; + + if (strtotime($value) === false) return false; + + $date = date_parse($value); + + return checkdate($date['month'], $date['day'], $date['year']); + } + + /** + * Validate that an attribute matches a date format. + * + * @param string $attribute + * @param mixed $value + * @param array $parameters + * @return bool + */ + protected function validateDateFormat($attribute, $value, $parameters) + { + $this->requireParameterCount(1, $parameters, 'date_format'); + + $parsed = date_parse_from_format($parameters[0], $value); + + return $parsed['error_count'] === 0 && $parsed['warning_count'] === 0; + } + + /** + * Validate the date is before a given date. + * + * @param string $attribute + * @param mixed $value + * @param array $parameters + * @return bool + */ + protected function validateBefore($attribute, $value, $parameters) + { + $this->requireParameterCount(1, $parameters, 'before'); + + if ( ! ($date = strtotime($parameters[0]))) + { + return strtotime($value) < strtotime($this->getValue($parameters[0])); + } + else + { + return strtotime($value) < $date; + } + } + + /** + * Validate the date is after a given date. + * + * @param string $attribute + * @param mixed $value + * @param array $parameters + * @return bool + */ + protected function validateAfter($attribute, $value, $parameters) + { + $this->requireParameterCount(1, $parameters, 'after'); + + if ( ! ($date = strtotime($parameters[0]))) + { + return strtotime($value) > strtotime($this->getValue($parameters[0])); + } + else + { + return strtotime($value) > $date; + } + } + + /** + * Get the validation message for an attribute and rule. + * + * @param string $attribute + * @param string $rule + * @return string + */ + protected function getMessage($attribute, $rule) + { + $lowerRule = snake_case($rule); + + $inlineMessage = $this->getInlineMessage($attribute, $lowerRule); + + // First we will retrieve the custom message for the validation rule if one + // exists. If a custom validation message is being used we'll return the + // custom message, otherwise we'll keep searching for a valid message. + if ( ! is_null($inlineMessage)) + { + return $inlineMessage; + } + + $customKey = "validation.custom.{$attribute}.{$lowerRule}"; + + $customMessage = $this->translator->trans($customKey); + + // First we check for a custom defined validation message for the attribute + // and rule. This allows the developer to specify specific messages for + // only some attributes and rules that need to get specially formed. + if ($customMessage !== $customKey) + { + return $customMessage; + } + + // If the rule being validated is a "size" rule, we will need to gather the + // specific error message for the type of attribute being validated such + // as a number, file or string which all have different message types. + elseif (in_array($rule, $this->sizeRules)) + { + return $this->getSizeMessage($attribute, $rule); + } + + // Finally, if no developer specified messages have been set, and no other + // special messages apply for this rule, we will just pull the default + // messages out of the translator service for this validation rule. + $key = "validation.{$lowerRule}"; + + if ($key != ($value = $this->translator->trans($key))) + { + return $value; + } + + return $this->getInlineMessage( + $attribute, $lowerRule, $this->fallbackMessages + ) ?: $key; + } + + /** + * Get the inline message for a rule if it exists. + * + * @param string $attribute + * @param string $lowerRule + * @param array $source + * @return string + */ + protected function getInlineMessage($attribute, $lowerRule, $source = null) + { + $source = $source ?: $this->customMessages; + + $keys = array("{$attribute}.{$lowerRule}", $lowerRule); + + // First we will check for a custom message for an attribute specific rule + // message for the fields, then we will check for a general custom line + // that is not attribute specific. If we find either we'll return it. + foreach ($keys as $key) + { + if (isset($source[$key])) return $source[$key]; + } + } + + /** + * Get the proper error message for an attribute and size rule. + * + * @param string $attribute + * @param string $rule + * @return string + */ + protected function getSizeMessage($attribute, $rule) + { + $lowerRule = snake_case($rule); + + // There are three different types of size validations. The attribute may be + // either a number, file, or string so we will check a few things to know + // which type of value it is and return the correct line for that type. + $type = $this->getAttributeType($attribute); + + $key = "validation.{$lowerRule}.{$type}"; + + return $this->translator->trans($key); + } + + /** + * Get the data type of the given attribute. + * + * @param string $attribute + * @return string + */ + protected function getAttributeType($attribute) + { + // We assume that the attributes present in the file array are files so that + // means that if the attribute does not have a numeric rule and the files + // list doesn't have it we'll just consider it a string by elimination. + if ($this->hasRule($attribute, $this->numericRules)) + { + return 'numeric'; + } + elseif ($this->hasRule($attribute, array('Array'))) + { + return 'array'; + } + elseif (array_key_exists($attribute, $this->files)) + { + return 'file'; + } + + return 'string'; + } + + /** + * Replace all error message place-holders with actual values. + * + * @param string $message + * @param string $attribute + * @param string $rule + * @param array $parameters + * @return string + */ + protected function doReplacements($message, $attribute, $rule, $parameters) + { + $message = str_replace(':attribute', $this->getAttribute($attribute), $message); + + if (isset($this->replacers[snake_case($rule)])) + { + $message = $this->callReplacer($message, $attribute, snake_case($rule), $parameters); + } + elseif (method_exists($this, $replacer = "replace{$rule}")) + { + $message = $this->$replacer($message, $attribute, $rule, $parameters); + } + + return $message; + } + + /** + * Transform an array of attributes to their displayable form. + * + * @param array $values + * @return array + */ + protected function getAttributeList(array $values) + { + $attributes = array(); + + // For each attribute in the list we will simply get its displayable form as + // this is convenient when replacing lists of parameters like some of the + // replacement functions do when formatting out the validation message. + foreach ($values as $key => $value) + { + $attributes[$key] = $this->getAttribute($value); + } + + return $attributes; + } + + /** + * Get the displayable name of the attribute. + * + * @param string $attribute + * @return string + */ + protected function getAttribute($attribute) + { + // The developer may dynamically specify the array of custom attributes + // on this Validator instance. If the attribute exists in this array + // it takes precedence over all other ways we can pull attributes. + if (isset($this->customAttributes[$attribute])) + { + return $this->customAttributes[$attribute]; + } + + $key = "validation.attributes.{$attribute}"; + + // We allow for the developer to specify language lines for each of the + // attributes allowing for more displayable counterparts of each of + // the attributes. This provides the ability for simple formats. + if (($line = $this->translator->trans($key)) !== $key) + { + return $line; + } + + // If no language line has been specified for the attribute all of the + // underscores are removed from the attribute name and that will be + // used as default versions of the attribute's displayable names. + else + { + return str_replace('_', ' ', snake_case($attribute)); + } + } + + /** + * Replace all place-holders for the between rule. + * + * @param string $message + * @param string $attribute + * @param string $rule + * @param array $parameters + * @return string + */ + protected function replaceBetween($message, $attribute, $rule, $parameters) + { + return str_replace(array(':min', ':max'), $parameters, $message); + } + + /** + * Replace all place-holders for the digits rule. + * + * @param string $message + * @param string $attribute + * @param string $rule + * @param array $parameters + * @return string + */ + protected function replaceDigits($message, $attribute, $rule, $parameters) + { + return str_replace(':digits', $parameters[0], $message); + } + + /** + * Replace all place-holders for the digits (between) rule. + * + * @param string $message + * @param string $attribute + * @param string $rule + * @param array $parameters + * @return string + */ + protected function replaceDigitsBetween($message, $attribute, $rule, $parameters) + { + return str_replace(array(':min', ':max'), $parameters, $message); + } + + /** + * Replace all place-holders for the size rule. + * + * @param string $message + * @param string $attribute + * @param string $rule + * @param array $parameters + * @return string + */ + protected function replaceSize($message, $attribute, $rule, $parameters) + { + return str_replace(':size', $parameters[0], $message); + } + + /** + * Replace all place-holders for the min rule. + * + * @param string $message + * @param string $attribute + * @param string $rule + * @param array $parameters + * @return string + */ + protected function replaceMin($message, $attribute, $rule, $parameters) + { + return str_replace(':min', $parameters[0], $message); + } + + /** + * Replace all place-holders for the max rule. + * + * @param string $message + * @param string $attribute + * @param string $rule + * @param array $parameters + * @return string + */ + protected function replaceMax($message, $attribute, $rule, $parameters) + { + return str_replace(':max', $parameters[0], $message); + } + + /** + * Replace all place-holders for the in rule. + * + * @param string $message + * @param string $attribute + * @param string $rule + * @param array $parameters + * @return string + */ + protected function replaceIn($message, $attribute, $rule, $parameters) + { + return str_replace(':values', implode(', ', $parameters), $message); + } + + /** + * Replace all place-holders for the not_in rule. + * + * @param string $message + * @param string $attribute + * @param string $rule + * @param array $parameters + * @return string + */ + protected function replaceNotIn($message, $attribute, $rule, $parameters) + { + return str_replace(':values', implode(', ', $parameters), $message); + } + + /** + * Replace all place-holders for the mimes rule. + * + * @param string $message + * @param string $attribute + * @param string $rule + * @param array $parameters + * @return string + */ + protected function replaceMimes($message, $attribute, $rule, $parameters) + { + return str_replace(':values', implode(', ', $parameters), $message); + } + + /** + * Replace all place-holders for the required_with rule. + * + * @param string $message + * @param string $attribute + * @param string $rule + * @param array $parameters + * @return string + */ + protected function replaceRequiredWith($message, $attribute, $rule, $parameters) + { + $parameters = $this->getAttributeList($parameters); + + return str_replace(':values', implode(' / ', $parameters), $message); + } + + /** + * Replace all place-holders for the required_without rule. + * + * @param string $message + * @param string $attribute + * @param string $rule + * @param array $parameters + * @return string + */ + protected function replaceRequiredWithout($message, $attribute, $rule, $parameters) + { + $parameters = $this->getAttributeList($parameters); + + return str_replace(':values', implode(' / ', $parameters), $message); + } + + /** + * Replace all place-holders for the required_without_all rule. + * + * @param string $message + * @param string $attribute + * @param string $rule + * @param array $parameters + * @return string + */ + protected function replaceRequiredWithoutAll($message, $attribute, $rule, $parameters) + { + $parameters = $this->getAttributeList($parameters); + + return str_replace(':values', implode(' / ', $parameters), $message); + } + + /** + * Replace all place-holders for the required_if rule. + * + * @param string $message + * @param string $attribute + * @param string $rule + * @param array $parameters + * @return string + */ + protected function replaceRequiredIf($message, $attribute, $rule, $parameters) + { + $parameters[0] = $this->getAttribute($parameters[0]); + + return str_replace(array(':other', ':value'), $parameters, $message); + } + + /** + * Replace all place-holders for the same rule. + * + * @param string $message + * @param string $attribute + * @param string $rule + * @param array $parameters + * @return string + */ + protected function replaceSame($message, $attribute, $rule, $parameters) + { + return str_replace(':other', $this->getAttribute($parameters[0]), $message); + } + + /** + * Replace all place-holders for the different rule. + * + * @param string $message + * @param string $attribute + * @param string $rule + * @param array $parameters + * @return string + */ + protected function replaceDifferent($message, $attribute, $rule, $parameters) + { + return str_replace(':other', $this->getAttribute($parameters[0]), $message); + } + + /** + * Replace all place-holders for the date_format rule. + * + * @param string $message + * @param string $attribute + * @param string $rule + * @param array $parameters + * @return string + */ + protected function replaceDateFormat($message, $attribute, $rule, $parameters) + { + return str_replace(':format', $parameters[0], $message); + } + + /** + * Replace all place-holders for the before rule. + * + * @param string $message + * @param string $attribute + * @param string $rule + * @param array $parameters + * @return string + */ + protected function replaceBefore($message, $attribute, $rule, $parameters) + { + if ( ! (strtotime($parameters[0]))) + { + return str_replace(':date', $this->getAttribute($parameters[0]), $message); + } + else + { + return str_replace(':date', $parameters[0], $message); + } + } + + /** + * Replace all place-holders for the after rule. + * + * @param string $message + * @param string $attribute + * @param string $rule + * @param array $parameters + * @return string + */ + protected function replaceAfter($message, $attribute, $rule, $parameters) + { + if ( ! (strtotime($parameters[0]))) + { + return str_replace(':date', $this->getAttribute($parameters[0]), $message); + } + else + { + return str_replace(':date', $parameters[0], $message); + } + } + + /** + * Determine if the given attribute has a rule in the given set. + * + * @param string $attribute + * @param array $rules + * @return bool + */ + protected function hasRule($attribute, $rules) + { + $rules = (array) $rules; + + // To determine if the attribute has a rule in the ruleset, we will spin + // through each of the rules assigned to the attribute and parse them + // all, then check to see if the parsed rules exists in the arrays. + foreach ($this->rules[$attribute] as $rule) + { + list($rule, $parameters) = $this->parseRule($rule); + + if (in_array($rule, $rules)) return true; + } + + return false; + } + + /** + * Extract the rule name and parameters from a rule. + * + * @param string $rule + * @return array + */ + protected function parseRule($rule) + { + $parameters = array(); + + // The format for specifying validation rules and parameters follows an + // easy {rule}:{parameters} formatting convention. For instance the + // rule "Max:3" states that the value may only be three letters. + if (strpos($rule, ':') !== false) + { + list($rule, $parameter) = explode(':', $rule, 2); + + $parameters = $this->parseParameters($rule, $parameter); + } + + return array(studly_case($rule), $parameters); + } + + /** + * Parse a parameter list. + * + * @param string $rule + * @param string $parameter + * @return array + */ + protected function parseParameters($rule, $parameter) + { + if (strtolower($rule) == 'regex') return array($parameter); + + return str_getcsv($parameter); + } + + /** + * Get the array of custom validator extensions. + * + * @return array + */ + public function getExtensions() + { + return $this->extensions; + } + + /** + * Register an array of custom validator extensions. + * + * @param array $extensions + * @return void + */ + public function addExtensions(array $extensions) + { + if ($extensions) + { + $keys = array_map('snake_case', array_keys($extensions)); + + $extensions = array_combine($keys, array_values($extensions)); + } + + $this->extensions = array_merge($this->extensions, $extensions); + } + + /** + * Register an array of custom implicit validator extensions. + * + * @param array $extensions + * @return void + */ + public function addImplicitExtensions(array $extensions) + { + $this->addExtensions($extensions); + + foreach ($extensions as $rule => $extension) + { + $this->implicitRules[] = studly_case($rule); + } + } + + /** + * Register a custom validator extension. + * + * @param string $rule + * @param \Closure|string $extension + * @return void + */ + public function addExtension($rule, $extension) + { + $this->extensions[snake_case($rule)] = $extension; + } + + /** + * Register a custom implicit validator extension. + * + * @param string $rule + * @param \Closure|string $extension + * @return void + */ + public function addImplicitExtension($rule, $extension) + { + $this->addExtension($rule, $extension); + + $this->implicitRules[] = studly_case($rule); + } + + /** + * Get the array of custom validator message replacers. + * + * @return array + */ + public function getReplacers() + { + return $this->replacers; + } + + /** + * Register an array of custom validator message replacers. + * + * @param array $replacers + * @return void + */ + public function addReplacers(array $replacers) + { + if ($replacers) + { + $keys = array_map('snake_case', array_keys($replacers)); + + $replacers = array_combine($keys, array_values($replacers)); + } + + $this->replacers = array_merge($this->replacers, $replacers); + } + + /** + * Register a custom validator message replacer. + * + * @param string $rule + * @param \Closure|string $replacer + * @return void + */ + public function addReplacer($rule, $replacer) + { + $this->replacers[snake_case($rule)] = $replacer; + } + + /** + * Get the data under validation. + * + * @return array + */ + public function getData() + { + return $this->data; + } + + /** + * Set the data under validation. + * + * @param array $data + * @return void + */ + public function setData(array $data) + { + $this->data = $this->parseData($data); + } + + /** + * Get the validation rules. + * + * @return array + */ + public function getRules() + { + return $this->rules; + } + + /** + * Set the validation rules. + * + * @param array $rules + * @return \Illuminate\Validation\Validator + */ + public function setRules(array $rules) + { + $this->rules = $this->explodeRules($rules); + + return $this; + } + + /** + * Set the custom attributes on the validator. + * + * @param array $attributes + * @return \Illuminate\Validation\Validator + */ + public function setAttributeNames(array $attributes) + { + $this->customAttributes = $attributes; + + return $this; + } + + /** + * Get the files under validation. + * + * @return array + */ + public function getFiles() + { + return $this->files; + } + + /** + * Set the files under validation. + * + * @param array $files + * @return \Illuminate\Validation\Validator + */ + public function setFiles(array $files) + { + $this->files = $files; + + return $this; + } + + /** + * Get the Presence Verifier implementation. + * + * @return \Illuminate\Validation\PresenceVerifierInterface + * + * @throws \RuntimeException + */ + public function getPresenceVerifier() + { + if ( ! isset($this->presenceVerifier)) + { + throw new \RuntimeException("Presence verifier has not been set."); + } + + return $this->presenceVerifier; + } + + /** + * Set the Presence Verifier implementation. + * + * @param \Illuminate\Validation\PresenceVerifierInterface $presenceVerifier + * @return void + */ + public function setPresenceVerifier(PresenceVerifierInterface $presenceVerifier) + { + $this->presenceVerifier = $presenceVerifier; + } + + /** + * Get the Translator implementation. + * + * @return \Symfony\Component\Translation\TranslatorInterface + */ + public function getTranslator() + { + return $this->translator; + } + + /** + * Set the Translator implementation. + * + * @param \Symfony\Component\Translation\TranslatorInterface $translator + * @return void + */ + public function setTranslator(TranslatorInterface $translator) + { + $this->translator = $translator; + } + + /** + * Get the custom messages for the validator + * + * @return array + */ + public function getCustomMessages() + { + return $this->customMessages; + } + + /** + * Set the custom messages for the validator + * + * @param array $messages + * @return void + */ + public function setCustomMessages(array $messages) + { + $this->customMessages = array_merge($this->customMessages, $messages); + } + + /** + * Get the fallback messages for the validator. + * + * @return array + */ + public function getFallbackMessages() + { + return $this->fallbackMessages; + } + + /** + * Set the fallback messages for the validator. + * + * @param array $messages + * @return void + */ + public function setFallbackMessages(array $messages) + { + $this->fallbackMessages = $messages; + } + + /** + * Get the failed validation rules. + * + * @return array + */ + public function failed() + { + return $this->failedRules; + } + + /** + * Get the message container for the validator. + * + * @return \Illuminate\Support\MessageBag + */ + public function messages() + { + if ( ! $this->messages) $this->passes(); + + return $this->messages; + } + + /** + * An alternative more semantic shortcut to the message container. + * + * @return \Illuminate\Support\MessageBag + */ + public function errors() + { + if ( ! $this->messages) $this->passes(); + + return $this->messages; + } + + /** + * Get the messages for the instance. + * + * @return \Illuminate\Support\MessageBag + */ + public function getMessageBag() + { + return $this->messages(); + } + + /** + * Set the IoC container instance. + * + * @param \Illuminate\Container\Container $container + * @return void + */ + public function setContainer(Container $container) + { + $this->container = $container; + } + + /** + * Call a custom validator extension. + * + * @param string $rule + * @param array $parameters + * @return bool + */ + protected function callExtension($rule, $parameters) + { + $callback = $this->extensions[$rule]; + + if ($callback instanceof Closure) + { + return call_user_func_array($callback, $parameters); + } + elseif (is_string($callback)) + { + return $this->callClassBasedExtension($callback, $parameters); + } + } + + /** + * Call a class based validator extension. + * + * @param string $callback + * @param array $parameters + * @return bool + */ + protected function callClassBasedExtension($callback, $parameters) + { + list($class, $method) = explode('@', $callback); + + return call_user_func_array(array($this->container->make($class), $method), $parameters); + } + + /** + * Call a custom validator message replacer. + * + * @param string $message + * @param string $attribute + * @param string $rule + * @param array $parameters + * @return string + */ + protected function callReplacer($message, $attribute, $rule, $parameters) + { + $callback = $this->replacers[$rule]; + + if ($callback instanceof Closure) + { + return call_user_func_array($callback, func_get_args()); + } + elseif (is_string($callback)) + { + return $this->callClassBasedReplacer($callback, $message, $attribute, $rule, $parameters); + } + } + + /** + * Call a class based validator message replacer. + * + * @param string $callback + * @param string $message + * @param string $attribute + * @param string $rule + * @param array $parameters + * @return string + */ + protected function callClassBasedReplacer($callback, $message, $attribute, $rule, $parameters) + { + list($class, $method) = explode('@', $callback); + + return call_user_func_array(array($this->container->make($class), $method), array_slice(func_get_args(), 1)); + } + + /** + * Require a certain number of parameters to be present. + * + * @param int $count + * @param array $parameters + * @param string $rule + * @return void + * @throws \InvalidArgumentException + */ + protected function requireParameterCount($count, $parameters, $rule) + { + if (count($parameters) < $count) + { + throw new \InvalidArgumentException("Validation rule $rule requires at least $count parameters."); + } + } + + /** + * Handle dynamic calls to class methods. + * + * @param string $method + * @param array $parameters + * @return mixed + * + * @throws \BadMethodCallException + */ + public function __call($method, $parameters) + { + $rule = snake_case(substr($method, 8)); + + if (isset($this->extensions[$rule])) + { + return $this->callExtension($rule, $parameters); + } + + throw new \BadMethodCallException("Method [$method] does not exist."); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Validation/composer.json b/vendor/laravel/framework/src/Illuminate/Validation/composer.json new file mode 100755 index 0000000..c0ca2d6 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Validation/composer.json @@ -0,0 +1,34 @@ +{ + "name": "illuminate/validation", + "license": "MIT", + "authors": [ + { + "name": "Taylor Otwell", + "email": "taylorotwell@gmail.com" + } + ], + "require": { + "php": ">=5.3.0", + "illuminate/container": "4.1.*", + "illuminate/support": "4.1.*", + "symfony/http-foundation": "2.4.*", + "symfony/translation": "2.4.*" + }, + "require-dev": { + "illuminate/database": "4.1.*", + "mockery/mockery": "0.9.*", + "phpunit/phpunit": "4.0.*" + }, + "autoload": { + "psr-0": { + "Illuminate\\Validation": "" + } + }, + "target-dir": "Illuminate/Validation", + "extra": { + "branch-alias": { + "dev-master": "4.1-dev" + } + }, + "minimum-stability": "dev" +} diff --git a/vendor/laravel/framework/src/Illuminate/View/Compilers/BladeCompiler.php b/vendor/laravel/framework/src/Illuminate/View/Compilers/BladeCompiler.php new file mode 100755 index 0000000..86b12ef --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/View/Compilers/BladeCompiler.php @@ -0,0 +1,541 @@ +setPath($path); + } + + $contents = $this->compileString($this->files->get($this->getPath())); + + if ( ! is_null($this->cachePath)) + { + $this->files->put($this->getCompiledPath($this->getPath()), $contents); + } + } + + /** + * Get the path currently being compiled. + * + * @return string + */ + public function getPath() + { + return $this->path; + } + + /** + * Set the path currently being compiled. + * + * @param string $path + * @return void + */ + public function setPath($path) + { + $this->path = $path; + } + + /** + * Compile the given Blade template contents. + * + * @param string $value + * @return string + */ + public function compileString($value) + { + foreach ($this->compilers as $compiler) + { + $value = $this->{"compile{$compiler}"}($value); + } + + return $value; + } + + /** + * Register a custom Blade compiler. + * + * @param Closure $compiler + * @return void + */ + public function extend(Closure $compiler) + { + $this->extensions[] = $compiler; + } + + /** + * Execute the user defined extensions. + * + * @param string $value + * @return string + */ + protected function compileExtensions($value) + { + foreach ($this->extensions as $compiler) + { + $value = call_user_func($compiler, $value, $this); + } + + return $value; + } + + /** + * Compile Blade template extensions into valid PHP. + * + * @param string $value + * @return string + */ + protected function compileExtends($value) + { + // By convention, Blade views using template inheritance must begin with the + // @extends expression, otherwise they will not be compiled with template + // inheritance. So, if they do not start with that we will just return. + if (strpos($value, '@extends') !== 0) + { + return $value; + } + + $lines = preg_split("/(\r?\n)/", $value); + + // Next, we just want to split the values by lines, and create an expression + // to include the parent layout at the end of the templates. Which allows + // the sections to get registered before the parent view gets rendered. + $lines = $this->compileLayoutExtends($lines); + + return implode("\r\n", array_slice($lines, 1)); + } + + /** + * Compile the proper template inheritance for the lines. + * + * @param array $lines + * @return array + */ + protected function compileLayoutExtends($lines) + { + $pattern = $this->createMatcher('extends'); + + $lines[] = preg_replace($pattern, '$1@include$2', $lines[0]); + + return $lines; + } + + /** + * Compile Blade comments into valid PHP. + * + * @param string $value + * @return string + */ + protected function compileComments($value) + { + $pattern = sprintf('/%s--((.|\s)*?)--%s/', $this->contentTags[0], $this->contentTags[1]); + + return preg_replace($pattern, '', $value); + } + + /** + * Compile Blade echos into valid PHP. + * + * @param string $value + * @return string + */ + protected function compileEchos($value) + { + $difference = strlen($this->contentTags[0]) - strlen($this->escapedTags[0]); + + if ($difference > 0) + { + return $this->compileEscapedEchos($this->compileRegularEchos($value)); + } + + return $this->compileRegularEchos($this->compileEscapedEchos($value)); + } + + /** + * Compile the "regular" echo statements. + * + * @param string $value + * @return string + */ + protected function compileRegularEchos($value) + { + $me = $this; + + $pattern = sprintf('/(@)?%s\s*(.+?)\s*%s/s', $this->contentTags[0], $this->contentTags[1]); + + $callback = function($matches) use ($me) + { + return $matches[1] ? substr($matches[0], 1) : 'compileEchoDefaults($matches[2]).'; ?>'; + }; + + return preg_replace_callback($pattern, $callback, $value); + } + + /** + * Compile the escaped echo statements. + * + * @param string $value + * @return string + */ + protected function compileEscapedEchos($value) + { + $me = $this; + + $pattern = sprintf('/%s\s*(.+?)\s*%s/s', $this->escapedTags[0], $this->escapedTags[1]); + + $callback = function($matches) use ($me) + { + return 'compileEchoDefaults($matches[1]).'); ?>'; + }; + + return preg_replace_callback($pattern, $callback, $value); + } + + /** + * Compile the default values for the echo statement. + * + * @param string $value + * @return string + */ + public function compileEchoDefaults($value) + { + return preg_replace('/^(?=\$)(.+?)(?:\s+or\s+)(.+?)$/s', 'isset($1) ? $1 : $2', $value); + } + + /** + * Compile Blade structure openings into valid PHP. + * + * @param string $value + * @return string + */ + protected function compileOpenings($value) + { + $pattern = '/(?(R)\((?:[^\(\)]|(?R))*\)|(?', $value); + } + + /** + * Compile Blade structure closings into valid PHP. + * + * @param string $value + * @return string + */ + protected function compileClosings($value) + { + $pattern = '/(\s*)@(endif|endforeach|endfor|endwhile)(\s*)/'; + + return preg_replace($pattern, '$1$3', $value); + } + + /** + * Compile Blade else statements into valid PHP. + * + * @param string $value + * @return string + */ + protected function compileElse($value) + { + $pattern = $this->createPlainMatcher('else'); + + return preg_replace($pattern, '$1$2', $value); + } + + /** + * Compile Blade unless statements into valid PHP. + * + * @param string $value + * @return string + */ + protected function compileUnless($value) + { + $pattern = $this->createMatcher('unless'); + + return preg_replace($pattern, '$1', $value); + } + + /** + * Compile Blade end unless statements into valid PHP. + * + * @param string $value + * @return string + */ + protected function compileEndUnless($value) + { + $pattern = $this->createPlainMatcher('endunless'); + + return preg_replace($pattern, '$1$2', $value); + } + + /** + * Compile Blade include statements into valid PHP. + * + * @param string $value + * @return string + */ + protected function compileIncludes($value) + { + $pattern = $this->createOpenMatcher('include'); + + $replace = '$1make$2, array_except(get_defined_vars(), array(\'__data\', \'__path\')))->render(); ?>'; + + return preg_replace($pattern, $replace, $value); + } + + /** + * Compile Blade each statements into valid PHP. + * + * @param string $value + * @return string + */ + protected function compileEach($value) + { + $pattern = $this->createMatcher('each'); + + return preg_replace($pattern, '$1renderEach$2; ?>', $value); + } + + /** + * Compile Blade yield statements into valid PHP. + * + * @param string $value + * @return string + */ + protected function compileYields($value) + { + $pattern = $this->createMatcher('yield'); + + return preg_replace($pattern, '$1yieldContent$2; ?>', $value); + } + + /** + * Compile Blade show statements into valid PHP. + * + * @param string $value + * @return string + */ + protected function compileShows($value) + { + $pattern = $this->createPlainMatcher('show'); + + return preg_replace($pattern, '$1yieldSection(); ?>$2', $value); + } + + /** + * Compile Blade language and language choice statements into valid PHP. + * + * @param string $value + * @return string + */ + protected function compileLanguage($value) + { + $pattern = $this->createMatcher('lang'); + + $value = preg_replace($pattern, '$1', $value); + + $pattern = $this->createMatcher('choice'); + + return preg_replace($pattern, '$1', $value); + } + + /** + * Compile Blade section start statements into valid PHP. + * + * @param string $value + * @return string + */ + protected function compileSectionStart($value) + { + $pattern = $this->createMatcher('section'); + + return preg_replace($pattern, '$1startSection$2; ?>', $value); + } + + /** + * Compile Blade section stop statements into valid PHP. + * + * @param string $value + * @return string + */ + protected function compileSectionStop($value) + { + $pattern = $this->createPlainMatcher('stop'); + + $value = preg_replace($pattern, '$1stopSection(); ?>$2', $value); + + $pattern = $this->createPlainMatcher('endsection'); + + return preg_replace($pattern, '$1stopSection(); ?>$2', $value); + } + + /** + * Compile Blade section append statements into valid PHP. + * + * @param string $value + * @return string + */ + protected function compileSectionAppend($value) + { + $pattern = $this->createPlainMatcher('append'); + + return preg_replace($pattern, '$1appendSection(); ?>$2', $value); + } + + /** + * Compile Blade section stop statements into valid PHP. + * + * @param string $value + * @return string + */ + protected function compileSectionOverwrite($value) + { + $pattern = $this->createPlainMatcher('overwrite'); + + return preg_replace($pattern, '$1stopSection(true); ?>$2', $value); + } + + /** + * Get the regular expression for a generic Blade function. + * + * @param string $function + * @return string + */ + public function createMatcher($function) + { + return '/(?{$property} = array(preg_quote($openTag), preg_quote($closeTag)); + } + + /** + * Sets the escaped content tags used for the compiler. + * + * @param string $openTag + * @param string $closeTag + * @return void + */ + public function setEscapedContentTags($openTag, $closeTag) + { + $this->setContentTags($openTag, $closeTag, true); + } + + /** + * Gets the content tags used for the compiler. + * + * @return string + */ + public function getContentTags() + { + return $this->contentTags; + } + + /** + * Gets the escaped content tags used for the compiler. + * + * @return string + */ + public function getEscapedContentTags() + { + return $this->escapedTags; + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/View/Compilers/Compiler.php b/vendor/laravel/framework/src/Illuminate/View/Compilers/Compiler.php new file mode 100755 index 0000000..81034aa --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/View/Compilers/Compiler.php @@ -0,0 +1,68 @@ +files = $files; + $this->cachePath = $cachePath; + } + + /** + * Get the path to the compiled version of a view. + * + * @param string $path + * @return string + */ + public function getCompiledPath($path) + { + return $this->cachePath.'/'.md5($path); + } + + /** + * Determine if the view at the given path is expired. + * + * @param string $path + * @return bool + */ + public function isExpired($path) + { + $compiled = $this->getCompiledPath($path); + + // If the compiled file doesn't exist we will indicate that the view is expired + // so that it can be re-compiled. Else, we will verify the last modification + // of the views is less than the modification times of the compiled views. + if ( ! $this->cachePath || ! $this->files->exists($compiled)) + { + return true; + } + + $lastModified = $this->files->lastModified($path); + + return $lastModified >= $this->files->lastModified($compiled); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/View/Compilers/CompilerInterface.php b/vendor/laravel/framework/src/Illuminate/View/Compilers/CompilerInterface.php new file mode 100755 index 0000000..85034b0 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/View/Compilers/CompilerInterface.php @@ -0,0 +1,29 @@ +compiler = $compiler; + } + + /** + * Get the evaluated contents of the view. + * + * @param string $path + * @param array $data + * @return string + */ + public function get($path, array $data = array()) + { + $this->lastCompiled[] = $path; + + // If this given view has expired, which means it has simply been edited since + // it was last compiled, we will re-compile the views so we can evaluate a + // fresh copy of the view. We'll pass the compiler the path of the view. + if ($this->compiler->isExpired($path)) + { + $this->compiler->compile($path); + } + + $compiled = $this->compiler->getCompiledPath($path); + + // Once we have the path to the compiled file, we will evaluate the paths with + // typical PHP just like any other templates. We also keep a stack of views + // which have been rendered for right exception messages to be generated. + $results = $this->evaluatePath($compiled, $data); + + array_pop($this->lastCompiled); + + return $results; + } + + /** + * Handle a view exception. + * + * @param \Exception $e + * @return void + * + * @throws $e + */ + protected function handleViewException($e) + { + $e = new \ErrorException($this->getMessage($e), 0, 1, $e->getFile(), $e->getLine(), $e); + + ob_get_clean(); throw $e; + } + + /** + * Get the exception message for an exception. + * + * @param \Exception $e + * @return string + */ + protected function getMessage($e) + { + return $e->getMessage().' (View: '.realpath(last($this->lastCompiled)).')'; + } + + /** + * Get the compiler implementation. + * + * @return \Illuminate\View\Compilers\CompilerInterface + */ + public function getCompiler() + { + return $this->compiler; + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/View/Engines/Engine.php b/vendor/laravel/framework/src/Illuminate/View/Engines/Engine.php new file mode 100755 index 0000000..4ea9796 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/View/Engines/Engine.php @@ -0,0 +1,22 @@ +lastRendered; + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/View/Engines/EngineInterface.php b/vendor/laravel/framework/src/Illuminate/View/Engines/EngineInterface.php new file mode 100755 index 0000000..5368734 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/View/Engines/EngineInterface.php @@ -0,0 +1,14 @@ +resolvers[$engine] = $resolver; + } + + /** + * Resolver an engine instance by name. + * + * @param string $engine + * @return \Illuminate\View\Engines\EngineInterface + */ + public function resolve($engine) + { + if ( ! isset($this->resolved[$engine])) + { + $this->resolved[$engine] = call_user_func($this->resolvers[$engine]); + } + + return $this->resolved[$engine]; + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/View/Engines/PhpEngine.php b/vendor/laravel/framework/src/Illuminate/View/Engines/PhpEngine.php new file mode 100755 index 0000000..c45d00d --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/View/Engines/PhpEngine.php @@ -0,0 +1,60 @@ +evaluatePath($path, $data); + } + + /** + * Get the evaluated contents of the view at the given path. + * + * @param string $__path + * @param array $__data + * @return string + */ + protected function evaluatePath($__path, $__data) + { + ob_start(); + + extract($__data); + + // We'll evaluate the contents of the view inside a try/catch block so we can + // flush out any stray output that might get out before an error occurs or + // an exception is thrown. This prevents any partial views from leaking. + try + { + include $__path; + } + catch (\Exception $e) + { + $this->handleViewException($e); + } + + return ltrim(ob_get_clean()); + } + + /** + * Handle a view exception. + * + * @param \Exception $e + * @return void + * + * @throws $e + */ + protected function handleViewException($e) + { + ob_get_clean(); throw $e; + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/View/Environment.php b/vendor/laravel/framework/src/Illuminate/View/Environment.php new file mode 100755 index 0000000..60cf5ab --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/View/Environment.php @@ -0,0 +1,805 @@ + 'blade', 'php' => 'php'); + + /** + * The view composer events. + * + * @var array + */ + protected $composers = array(); + + /** + * All of the finished, captured sections. + * + * @var array + */ + protected $sections = array(); + + /** + * The stack of in-progress sections. + * + * @var array + */ + protected $sectionStack = array(); + + /** + * The number of active rendering operations. + * + * @var int + */ + protected $renderCount = 0; + + /** + * Create a new view environment instance. + * + * @param \Illuminate\View\Engines\EngineResolver $engines + * @param \Illuminate\View\ViewFinderInterface $finder + * @param \Illuminate\Events\Dispatcher $events + * @return void + */ + public function __construct(EngineResolver $engines, ViewFinderInterface $finder, Dispatcher $events) + { + $this->finder = $finder; + $this->events = $events; + $this->engines = $engines; + + $this->share('__env', $this); + } + + /** + * Get the evaluated view contents for the given view. + * + * @param string $view + * @param array $data + * @param array $mergeData + * @return \Illuminate\View\View + */ + public function make($view, $data = array(), $mergeData = array()) + { + $path = $this->finder->find($view); + + $data = array_merge($mergeData, $this->parseData($data)); + + $this->callCreator($view = new View($this, $this->getEngineFromPath($path), $view, $path, $data)); + + return $view; + } + + /** + * Parse the given data into a raw array. + * + * @param mixed $data + * @return array + */ + protected function parseData($data) + { + return $data instanceof Arrayable ? $data->toArray() : $data; + } + + /** + * Get the evaluated view contents for a named view. + * + * @param string $view + * @param mixed $data + * @return \Illuminate\View\View + */ + public function of($view, $data = array()) + { + return $this->make($this->names[$view], $data); + } + + /** + * Register a named view. + * + * @param string $view + * @param string $name + * @return void + */ + public function name($view, $name) + { + $this->names[$name] = $view; + } + + /** + * Determine if a given view exists. + * + * @param string $view + * @return bool + */ + public function exists($view) + { + try + { + $this->finder->find($view); + } + catch (\InvalidArgumentException $e) + { + return false; + } + + return true; + } + + /** + * Get the rendered contents of a partial from a loop. + * + * @param string $view + * @param array $data + * @param string $iterator + * @param string $empty + * @return string + */ + public function renderEach($view, $data, $iterator, $empty = 'raw|') + { + $result = ''; + + // If is actually data in the array, we will loop through the data and append + // an instance of the partial view to the final result HTML passing in the + // iterated value of this data array, allowing the views to access them. + if (count($data) > 0) + { + foreach ($data as $key => $value) + { + $data = array('key' => $key, $iterator => $value); + + $result .= $this->make($view, $data)->render(); + } + } + + // If there is no data in the array, we will render the contents of the empty + // view. Alternatively, the "empty view" could be a raw string that begins + // with "raw|" for convenience and to let this know that it is a string. + else + { + if (starts_with($empty, 'raw|')) + { + $result = substr($empty, 4); + } + else + { + $result = $this->make($empty)->render(); + } + } + + return $result; + } + + /** + * Get the appropriate view engine for the given path. + * + * @param string $path + * @return \Illuminate\View\Engines\EngineInterface + */ + protected function getEngineFromPath($path) + { + $engine = $this->extensions[$this->getExtension($path)]; + + return $this->engines->resolve($engine); + } + + /** + * Get the extension used by the view file. + * + * @param string $path + * @return string + */ + protected function getExtension($path) + { + $extensions = array_keys($this->extensions); + + return array_first($extensions, function($key, $value) use ($path) + { + return ends_with($path, $value); + }); + } + + /** + * Add a piece of shared data to the environment. + * + * @param string $key + * @param mixed $value + * @return void + */ + public function share($key, $value = null) + { + if ( ! is_array($key)) return $this->shared[$key] = $value; + + foreach ($key as $innerKey => $innerValue) + { + $this->share($innerKey, $innerValue); + } + } + + /** + * Register a view creator event. + * + * @param array|string $views + * @param \Closure|string $callback + * @return array + */ + public function creator($views, $callback) + { + $creators = array(); + + foreach ((array) $views as $view) + { + $creators[] = $this->addViewEvent($view, $callback, 'creating: '); + } + + return $creators; + } + + /** + * Register multiple view composers via an array. + * + * @param array $composers + * @return array + */ + public function composers(array $composers) + { + $registered = array(); + + foreach ($composers as $callback => $views) + { + $registered += $this->composer($views, $callback); + } + + return $registered; + } + + /** + * Register a view composer event. + * + * @param array|string $views + * @param \Closure|string $callback + * @return array + */ + public function composer($views, $callback, $priority = null) + { + $composers = array(); + + foreach ((array) $views as $view) + { + $composers[] = $this->addViewEvent($view, $callback, 'composing: ', $priority); + } + + return $composers; + } + + /** + * Add an event for a given view. + * + * @param string $view + * @param Closure|string $callback + * @param string $prefix + * @return Closure + */ + protected function addViewEvent($view, $callback, $prefix = 'composing: ', $priority = null) + { + if ($callback instanceof Closure) + { + $this->addEventListener($prefix.$view, $callback, $priority); + + return $callback; + } + elseif (is_string($callback)) + { + return $this->addClassEvent($view, $callback, $prefix, $priority); + } + } + + /** + * Register a class based view composer. + * + * @param string $view + * @param string $class + * @param string $prefix + * @return \Closure + */ + protected function addClassEvent($view, $class, $prefix, $priority = null) + { + $name = $prefix.$view; + + // When registering a class based view "composer", we will simply resolve the + // classes from the application IoC container then call the compose method + // on the instance. This allows for convenient, testable view composers. + $callback = $this->buildClassEventCallback($class, $prefix); + + $this->addEventListener($name, $callback, $priority); + + return $callback; + } + + /** + * Add a listener to the event dispatcher. + * + * @param string $name + * @param \Closure $callback + * @param integer $priority + */ + protected function addEventListener($name, $callback, $priority = null) + { + if (is_null($priority)) + { + $this->events->listen($name, $callback); + } + else + { + $this->events->listen($name, $callback, $priority); + } + } + + /** + * Build a class based container callback Closure. + * + * @param string $class + * @param string $prefix + * @return \Closure + */ + protected function buildClassEventCallback($class, $prefix) + { + $container = $this->container; + + list($class, $method) = $this->parseClassEvent($class, $prefix); + + // Once we have the class and method name, we can build the Closure to resolve + // the instance out of the IoC container and call the method on it with the + // given arguments that are passed to the Closure as the composer's data. + return function() use ($class, $method, $container) + { + $callable = array($container->make($class), $method); + + return call_user_func_array($callable, func_get_args()); + }; + } + + /** + * Parse a class based composer name. + * + * @param string $class + * @param string $prefix + * @return array + */ + protected function parseClassEvent($class, $prefix) + { + if (str_contains($class, '@')) + { + return explode('@', $class); + } + else + { + $method = str_contains($prefix, 'composing') ? 'compose' : 'create'; + + return array($class, $method); + } + } + + /** + * Call the composer for a given view. + * + * @param \Illuminate\View\View $view + * @return void + */ + public function callComposer(View $view) + { + $this->events->fire('composing: '.$view->getName(), array($view)); + } + + /** + * Call the creator for a given view. + * + * @param \Illuminate\View\View $view + * @return void + */ + public function callCreator(View $view) + { + $this->events->fire('creating: '.$view->getName(), array($view)); + } + + /** + * Start injecting content into a section. + * + * @param string $section + * @param string $content + * @return void + */ + public function startSection($section, $content = '') + { + if ($content === '') + { + ob_start() && $this->sectionStack[] = $section; + } + else + { + $this->extendSection($section, $content); + } + } + + /** + * Inject inline content into a section. + * + * @param string $section + * @param string $content + * @return void + */ + public function inject($section, $content) + { + return $this->startSection($section, $content); + } + + /** + * Stop injecting content into a section and return its contents. + * + * @return string + */ + public function yieldSection() + { + return $this->yieldContent($this->stopSection()); + } + + /** + * Stop injecting content into a section. + * + * @param bool $overwrite + * @return string + */ + public function stopSection($overwrite = false) + { + $last = array_pop($this->sectionStack); + + if ($overwrite) + { + $this->sections[$last] = ob_get_clean(); + } + else + { + $this->extendSection($last, ob_get_clean()); + } + + return $last; + } + + /** + * Stop injecting content into a section and append it. + * + * @return string + */ + public function appendSection() + { + $last = array_pop($this->sectionStack); + + if (isset($this->sections[$last])) + { + $this->sections[$last] .= ob_get_clean(); + } + else + { + $this->sections[$last] = ob_get_clean(); + } + + return $last; + } + + /** + * Append content to a given section. + * + * @param string $section + * @param string $content + * @return void + */ + protected function extendSection($section, $content) + { + if (isset($this->sections[$section])) + { + $content = str_replace('@parent', $content, $this->sections[$section]); + + $this->sections[$section] = $content; + } + else + { + $this->sections[$section] = $content; + } + } + + /** + * Get the string contents of a section. + * + * @param string $section + * @param string $default + * @return string + */ + public function yieldContent($section, $default = '') + { + return isset($this->sections[$section]) ? $this->sections[$section] : $default; + } + + /** + * Flush all of the section contents. + * + * @return void + */ + public function flushSections() + { + $this->sections = array(); + + $this->sectionStack = array(); + } + + /** + * Flush all of the section contents if done rendering. + * + * @return void + */ + public function flushSectionsIfDoneRendering() + { + if ($this->doneRendering()) $this->flushSections(); + } + + /** + * Increment the rendering counter. + * + * @return void + */ + public function incrementRender() + { + $this->renderCount++; + } + + /** + * Decrement the rendering counter. + * + * @return void + */ + public function decrementRender() + { + $this->renderCount--; + } + + /** + * Check if there are no active render operations. + * + * @return bool + */ + public function doneRendering() + { + return $this->renderCount == 0; + } + + /** + * Add a location to the array of view locations. + * + * @param string $location + * @return void + */ + public function addLocation($location) + { + $this->finder->addLocation($location); + } + + /** + * Add a new namespace to the loader. + * + * @param string $namespace + * @param string|array $hints + * @return void + */ + public function addNamespace($namespace, $hints) + { + $this->finder->addNamespace($namespace, $hints); + } + + /** + * Prepend a new namespace to the loader. + * + * @param string $namespace + * @param string|array $hints + * @return void + */ + public function prependNamespace($namespace, $hints) + { + $this->finder->prependNamespace($namespace, $hints); + } + + /** + * Register a valid view extension and its engine. + * + * @param string $extension + * @param string $engine + * @param Closure $resolver + * @return void + */ + public function addExtension($extension, $engine, $resolver = null) + { + $this->finder->addExtension($extension); + + if (isset($resolver)) + { + $this->engines->register($engine, $resolver); + } + + unset($this->extensions[$extension]); + + $this->extensions = array_merge(array($extension => $engine), $this->extensions); + } + + /** + * Get the extension to engine bindings. + * + * @return array + */ + public function getExtensions() + { + return $this->extensions; + } + + /** + * Get the engine resolver instance. + * + * @return \Illuminate\View\Engines\EngineResolver + */ + public function getEngineResolver() + { + return $this->engines; + } + + /** + * Get the view finder instance. + * + * @return \Illuminate\View\ViewFinderInterface + */ + public function getFinder() + { + return $this->finder; + } + + /** + * Set the view finder instance. + * + * @return void + */ + public function setFinder(ViewFinderInterface $finder) + { + $this->finder = $finder; + } + + /** + * Get the event dispatcher instance. + * + * @return \Illuminate\Events\Dispatcher + */ + public function getDispatcher() + { + return $this->events; + } + + /** + * Set the event dispatcher instance. + * + * @param \Illuminate\Events\Dispatcher + * @return void + */ + public function setDispatcher(Dispatcher $events) + { + $this->events = $events; + } + + /** + * Get the IoC container instance. + * + * @return \Illuminate\Container\Container + */ + public function getContainer() + { + return $this->container; + } + + /** + * Set the IoC container instance. + * + * @param \Illuminate\Container\Container $container + * @return void + */ + public function setContainer(Container $container) + { + $this->container = $container; + } + + /** + * Get an item from the shared data. + * + * @param string $key + * @param mixed $default + * @return mixed + */ + public function shared($key, $default = null) + { + return array_get($this->shared, $key, $default); + } + + /** + * Get all of the shared data for the environment. + * + * @return array + */ + public function getShared() + { + return $this->shared; + } + + /** + * Get the entire array of sections. + * + * @return array + */ + public function getSections() + { + return $this->sections; + } + + /** + * Get all of the registered named views in environment. + * + * @return array + */ + public function getNames() + { + return $this->names; + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/View/FileViewFinder.php b/vendor/laravel/framework/src/Illuminate/View/FileViewFinder.php new file mode 100755 index 0000000..308edc4 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/View/FileViewFinder.php @@ -0,0 +1,262 @@ +files = $files; + $this->paths = $paths; + + if (isset($extensions)) + { + $this->extensions = $extensions; + } + } + + /** + * Get the fully qualified location of the view. + * + * @param string $name + * @return string + */ + public function find($name) + { + if (isset($this->views[$name])) return $this->views[$name]; + + if (strpos($name, '::') !== false) + { + return $this->views[$name] = $this->findNamedPathView($name); + } + + return $this->views[$name] = $this->findInPaths($name, $this->paths); + } + + /** + * Get the path to a template with a named path. + * + * @param string $name + * @return string + */ + protected function findNamedPathView($name) + { + list($namespace, $view) = $this->getNamespaceSegments($name); + + return $this->findInPaths($view, $this->hints[$namespace]); + } + + /** + * Get the segments of a template with a named path. + * + * @param string $name + * @return array + * + * @throws \InvalidArgumentException + */ + protected function getNamespaceSegments($name) + { + $segments = explode('::', $name); + + if (count($segments) != 2) + { + throw new \InvalidArgumentException("View [$name] has an invalid name."); + } + + if ( ! isset($this->hints[$segments[0]])) + { + throw new \InvalidArgumentException("No hint path defined for [{$segments[0]}]."); + } + + return $segments; + } + + /** + * Find the given view in the list of paths. + * + * @param string $name + * @param array $paths + * @return string + * + * @throws \InvalidArgumentException + */ + protected function findInPaths($name, $paths) + { + foreach ((array) $paths as $path) + { + foreach ($this->getPossibleViewFiles($name) as $file) + { + if ($this->files->exists($viewPath = $path.'/'.$file)) + { + return $viewPath; + } + } + } + + throw new \InvalidArgumentException("View [$name] not found."); + } + + /** + * Get an array of possible view files. + * + * @param string $name + * @return array + */ + protected function getPossibleViewFiles($name) + { + return array_map(function($extension) use ($name) + { + return str_replace('.', '/', $name).'.'.$extension; + + }, $this->extensions); + } + + /** + * Add a location to the finder. + * + * @param string $location + * @return void + */ + public function addLocation($location) + { + $this->paths[] = $location; + } + + /** + * Add a namespace hint to the finder. + * + * @param string $namespace + * @param string|array $hints + * @return void + */ + public function addNamespace($namespace, $hints) + { + $hints = (array) $hints; + + if (isset($this->hints[$namespace])) + { + $hints = array_merge($this->hints[$namespace], $hints); + } + + $this->hints[$namespace] = $hints; + } + + /** + * Prepend a namespace hint to the finder. + * + * @param string $namespace + * @param string|array $hints + * @return void + */ + public function prependNamespace($namespace, $hints) + { + $hints = (array) $hints; + + if (isset($this->hints[$namespace])) + { + $hints = array_merge($hints, $this->hints[$namespace]); + } + + $this->hints[$namespace] = $hints; + } + + /** + * Register an extension with the view finder. + * + * @param string $extension + * @return void + */ + public function addExtension($extension) + { + if (($index = array_search($extension, $this->extensions)) !== false) + { + unset($this->extensions[$index]); + } + + array_unshift($this->extensions, $extension); + } + + /** + * Get the filesystem instance. + * + * @return \Illuminate\Filesystem\Filesystem + */ + public function getFilesystem() + { + return $this->files; + } + + /** + * Get the active view paths. + * + * @return array + */ + public function getPaths() + { + return $this->paths; + } + + /** + * Get the namespace to file path hints. + * + * @return array + */ + public function getHints() + { + return $this->hints; + } + + /** + * Get registered extensions. + * + * @return array + */ + public function getExtensions() + { + return $this->extensions; + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/View/View.php b/vendor/laravel/framework/src/Illuminate/View/View.php new file mode 100755 index 0000000..4c31060 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/View/View.php @@ -0,0 +1,390 @@ +view = $view; + $this->path = $path; + $this->engine = $engine; + $this->environment = $environment; + + $this->data = $data instanceof Arrayable ? $data->toArray() : (array) $data; + } + + /** + * Get the string contents of the view. + * + * @param \Closure $callback + * @return string + */ + public function render(Closure $callback = null) + { + $contents = $this->renderContents(); + + $response = isset($callback) ? $callback($this, $contents) : null; + + // Once we have the contents of the view, we will flush the sections if we are + // done rendering all views so that there is nothing left hanging over when + // another view is rendered in the future via the application developers. + $this->environment->flushSectionsIfDoneRendering(); + + return $response ?: $contents; + } + + /** + * Get the contents of the view instance. + * + * @return string + */ + protected function renderContents() + { + // We will keep track of the amount of views being rendered so we can flush + // the section after the complete rendering operation is done. This will + // clear out the sections for any separate views that may be rendered. + $this->environment->incrementRender(); + + $this->environment->callComposer($this); + + $contents = $this->getContents(); + + // Once we've finished rendering the view, we'll decrement the render count + // so that each sections get flushed out next time a view is created and + // no old sections are staying around in the memory of an environment. + $this->environment->decrementRender(); + + return $contents; + } + + /** + * Get the sections of the rendered view. + * + * @return array + */ + public function renderSections() + { + $env = $this->environment; + + return $this->render(function($view) use ($env) + { + return $env->getSections(); + }); + } + + /** + * Get the evaluated contents of the view. + * + * @return string + */ + protected function getContents() + { + return $this->engine->get($this->path, $this->gatherData()); + } + + /** + * Get the data bound to the view instance. + * + * @return array + */ + protected function gatherData() + { + $data = array_merge($this->environment->getShared(), $this->data); + + foreach ($data as $key => $value) + { + if ($value instanceof Renderable) + { + $data[$key] = $value->render(); + } + } + + return $data; + } + + /** + * Add a piece of data to the view. + * + * @param string|array $key + * @param mixed $value + * @return \Illuminate\View\View + */ + public function with($key, $value = null) + { + if (is_array($key)) + { + $this->data = array_merge($this->data, $key); + } + else + { + $this->data[$key] = $value; + } + + return $this; + } + + /** + * Add a view instance to the view data. + * + * @param string $key + * @param string $view + * @param array $data + * @return \Illuminate\View\View + */ + public function nest($key, $view, array $data = array()) + { + return $this->with($key, $this->environment->make($view, $data)); + } + + /** + * Add validation errors to the view. + * + * @param \Illuminate\Support\Contracts\MessageProviderInterface|array $provider + * @return \Illuminate\View\View + */ + public function withErrors($provider) + { + if ($provider instanceof MessageProviderInterface) + { + $this->with('errors', $provider->getMessageBag()); + } + else + { + $this->with('errors', new MessageBag((array) $provider)); + } + + return $this; + } + + /** + * Get the view environment instance. + * + * @return \Illuminate\View\Environment + */ + public function getEnvironment() + { + return $this->environment; + } + + /** + * Get the view's rendering engine. + * + * @return \Illuminate\View\Engines\EngineInterface + */ + public function getEngine() + { + return $this->engine; + } + + /** + * Get the name of the view. + * + * @return string + */ + public function getName() + { + return $this->view; + } + + /** + * Get the array of view data. + * + * @return array + */ + public function getData() + { + return $this->data; + } + + /** + * Get the path to the view file. + * + * @return string + */ + public function getPath() + { + return $this->path; + } + + /** + * Set the path to the view. + * + * @param string $path + * @return void + */ + public function setPath($path) + { + $this->path = $path; + } + + /** + * Determine if a piece of data is bound. + * + * @param string $key + * @return bool + */ + public function offsetExists($key) + { + return array_key_exists($key, $this->data); + } + + /** + * Get a piece of bound data to the view. + * + * @param string $key + * @return mixed + */ + public function offsetGet($key) + { + return $this->data[$key]; + } + + /** + * Set a piece of data on the view. + * + * @param string $key + * @param mixed $value + * @return void + */ + public function offsetSet($key, $value) + { + $this->with($key, $value); + } + + /** + * Unset a piece of data from the view. + * + * @param string $key + * @return void + */ + public function offsetUnset($key) + { + unset($this->data[$key]); + } + + /** + * Get a piece of data from the view. + * + * @return mixed + */ + public function &__get($key) + { + return $this->data[$key]; + } + + /** + * Set a piece of data on the view. + * + * @param string $key + * @param mixed $value + * @return void + */ + public function __set($key, $value) + { + $this->with($key, $value); + } + + /** + * Check if a piece of data is bound to the view. + * + * @param string $key + * @return bool + */ + public function __isset($key) + { + return isset($this->data[$key]); + } + + /** + * Remove a piece of bound data from the view. + * + * @param string $key + * @return bool + */ + public function __unset($key) + { + unset($this->data[$key]); + } + + /** + * Dynamically bind parameters to the view. + * + * @param string $method + * @param array $parameters + * @return \Illuminate\View\View + * + * @throws \BadMethodCallException + */ + public function __call($method, $parameters) + { + if (starts_with($method, 'with')) + { + return $this->with(snake_case(substr($method, 4)), $parameters[0]); + } + + throw new \BadMethodCallException("Method [$method] does not exist on view."); + } + + /** + * Get the string contents of the view. + * + * @return string + */ + public function __toString() + { + return $this->render(); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/View/ViewFinderInterface.php b/vendor/laravel/framework/src/Illuminate/View/ViewFinderInterface.php new file mode 100755 index 0000000..6e284d5 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/View/ViewFinderInterface.php @@ -0,0 +1,38 @@ +registerEngineResolver(); + + $this->registerViewFinder(); + + // Once the other components have been registered we're ready to include the + // view environment and session binder. The session binder will bind onto + // the "before" application event and add errors into shared view data. + $this->registerEnvironment(); + + $this->registerSessionBinder(); + } + + /** + * Register the engine resolver instance. + * + * @return void + */ + public function registerEngineResolver() + { + $me = $this; + + $this->app->bindShared('view.engine.resolver', function($app) use ($me) + { + $resolver = new EngineResolver; + + // Next we will register the various engines with the resolver so that the + // environment can resolve the engines it needs for various views based + // on the extension of view files. We call a method for each engines. + foreach (array('php', 'blade') as $engine) + { + $me->{'register'.ucfirst($engine).'Engine'}($resolver); + } + + return $resolver; + }); + } + + /** + * Register the PHP engine implementation. + * + * @param \Illuminate\View\Engines\EngineResolver $resolver + * @return void + */ + public function registerPhpEngine($resolver) + { + $resolver->register('php', function() { return new PhpEngine; }); + } + + /** + * Register the Blade engine implementation. + * + * @param \Illuminate\View\Engines\EngineResolver $resolver + * @return void + */ + public function registerBladeEngine($resolver) + { + $app = $this->app; + + // The Compiler engine requires an instance of the CompilerInterface, which in + // this case will be the Blade compiler, so we'll first create the compiler + // instance to pass into the engine so it can compile the views properly. + $app->bindShared('blade.compiler', function($app) + { + $cache = $app['path.storage'].'/views'; + + return new BladeCompiler($app['files'], $cache); + }); + + $resolver->register('blade', function() use ($app) + { + return new CompilerEngine($app['blade.compiler'], $app['files']); + }); + } + + /** + * Register the view finder implementation. + * + * @return void + */ + public function registerViewFinder() + { + $this->app->bindShared('view.finder', function($app) + { + $paths = $app['config']['view.paths']; + + return new FileViewFinder($app['files'], $paths); + }); + } + + /** + * Register the view environment. + * + * @return void + */ + public function registerEnvironment() + { + $this->app->bindShared('view', function($app) + { + // Next we need to grab the engine resolver instance that will be used by the + // environment. The resolver will be used by an environment to get each of + // the various engine implementations such as plain PHP or Blade engine. + $resolver = $app['view.engine.resolver']; + + $finder = $app['view.finder']; + + $env = new Environment($resolver, $finder, $app['events']); + + // We will also set the container instance on this view environment since the + // view composers may be classes registered in the container, which allows + // for great testable, flexible composers for the application developer. + $env->setContainer($app); + + $env->share('app', $app); + + return $env; + }); + } + + /** + * Register the session binder for the view environment. + * + * @return void + */ + protected function registerSessionBinder() + { + list($app, $me) = array($this->app, $this); + + $app->booted(function() use ($app, $me) + { + // If the current session has an "errors" variable bound to it, we will share + // its value with all view instances so the views can easily access errors + // without having to bind. An empty bag is set when there aren't errors. + if ($me->sessionHasErrors($app)) + { + $errors = $app['session.store']->get('errors'); + + $app['view']->share('errors', $errors); + } + + // Putting the errors in the view for every view allows the developer to just + // assume that some errors are always available, which is convenient since + // they don't have to continually run checks for the presence of errors. + else + { + $app['view']->share('errors', new MessageBag); + } + }); + } + + /** + * Determine if the application session has errors. + * + * @param \Illuminate\Foundation\Application $app + * @return bool + */ + public function sessionHasErrors($app) + { + $config = $app['config']['session']; + + if (isset($app['session.store']) && ! is_null($config['driver'])) + { + return $app['session.store']->has('errors'); + } + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/View/composer.json b/vendor/laravel/framework/src/Illuminate/View/composer.json new file mode 100755 index 0000000..da44ce9 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/View/composer.json @@ -0,0 +1,33 @@ +{ + "name": "illuminate/view", + "license": "MIT", + "authors": [ + { + "name": "Taylor Otwell", + "email": "taylorotwell@gmail.com" + } + ], + "require": { + "php": ">=5.3.0", + "illuminate/container": "4.1.*", + "illuminate/events": "4.1.*", + "illuminate/filesystem": "4.1.*", + "illuminate/support": "4.1.*" + }, + "require-dev": { + "mockery/mockery": "0.9.*", + "phpunit/phpunit": "4.0.*" + }, + "autoload": { + "psr-0": { + "Illuminate\\View": "" + } + }, + "target-dir": "Illuminate/View", + "extra": { + "branch-alias": { + "dev-master": "4.1-dev" + } + }, + "minimum-stability": "dev" +} diff --git a/vendor/laravel/framework/src/Illuminate/Workbench/Console/WorkbenchMakeCommand.php b/vendor/laravel/framework/src/Illuminate/Workbench/Console/WorkbenchMakeCommand.php new file mode 100755 index 0000000..064f5e9 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Workbench/Console/WorkbenchMakeCommand.php @@ -0,0 +1,137 @@ +creator = $creator; + } + + /** + * Execute the console command. + * + * @return void + */ + public function fire() + { + $workbench = $this->runCreator($this->buildPackage()); + + $this->info('Package workbench created!'); + + $this->callComposerUpdate($workbench); + } + + /** + * Run the package creator class for a given Package. + * + * @param \Illuminate\Workbench\Package $package + * @return string + */ + protected function runCreator($package) + { + $path = $this->laravel['path.base'].'/workbench'; + + $plain = ! $this->option('resources'); + + return $this->creator->create($package, $path, $plain); + } + + /** + * Call the composer update routine on the path. + * + * @param string $path + * @return void + */ + protected function callComposerUpdate($path) + { + chdir($path); + + passthru('composer install --dev'); + } + + /** + * Build the package details from user input. + * + * @return \Illuminate\Workbench\Package + */ + protected function buildPackage() + { + list($vendor, $name) = $this->getPackageSegments(); + + $config = $this->laravel['config']['workbench']; + + return new Package($vendor, $name, $config['name'], $config['email']); + } + + /** + * Get the package vendor and name segments from the input. + * + * @return array + */ + protected function getPackageSegments() + { + $package = $this->argument('package'); + + return array_map('studly_case', explode('/', $package, 2)); + } + + /** + * Get the console command arguments. + * + * @return array + */ + protected function getArguments() + { + return array( + array('package', InputArgument::REQUIRED, 'The name (vendor/name) of the package.'), + ); + } + + /** + * Get the console command options. + * + * @return array + */ + protected function getOptions() + { + return array( + array('resources', null, InputOption::VALUE_NONE, 'Create Laravel specific directories.'), + ); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Workbench/Package.php b/vendor/laravel/framework/src/Illuminate/Workbench/Package.php new file mode 100755 index 0000000..b87f8c2 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Workbench/Package.php @@ -0,0 +1,76 @@ +name = $name; + $this->email = $email; + $this->vendor = $vendor; + $this->author = $author; + $this->lowerName = snake_case($name, '-'); + $this->lowerVendor = snake_case($vendor, '-'); + } + + /** + * Get the full package name. + * + * @return string + */ + public function getFullName() + { + return $this->lowerVendor.'/'.$this->lowerName; + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Workbench/PackageCreator.php b/vendor/laravel/framework/src/Illuminate/Workbench/PackageCreator.php new file mode 100755 index 0000000..3716be9 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Workbench/PackageCreator.php @@ -0,0 +1,373 @@ +files = $files; + } + + /** + * Create a new package stub. + * + * @param \Illuminate\Workbench\Package $package + * @param string $path + * @param bool $plain + * @return string + */ + public function create(Package $package, $path, $plain = true) + { + $directory = $this->createDirectory($package, $path); + + // To create the package, we will spin through a list of building blocks that + // make up each package. We'll then call the method to build that block on + // the class, which keeps the actual building of stuff nice and cleaned. + foreach ($this->getBlocks($plain) as $block) + { + $this->{"write{$block}"}($package, $directory, $plain); + } + + return $directory; + } + + /** + * Create a package with all resource directories. + * + * @param Package $package + * @param string $path + * @return void + */ + public function createWithResources(Package $package, $path) + { + return $this->create($package, $path, false); + } + + /** + * Get the blocks for a given package. + * + * @param bool $plain + * @return array + */ + protected function getBlocks($plain) + { + return $plain ? $this->basicBlocks : $this->blocks; + } + + /** + * Write the support files to the package root. + * + * @param \Illuminate\Workbench\Package $package + * @param string $directory + * @return void + */ + public function writeSupportFiles(Package $package, $directory, $plain) + { + foreach (array('PhpUnit', 'Travis', 'Composer', 'Ignore') as $file) + { + $this->{"write{$file}File"}($package, $directory, $plain); + } + } + + /** + * Write the PHPUnit stub file. + * + * @param \Illuminate\Workbench\Package $package + * @param string $directory + * @return void + */ + protected function writePhpUnitFile(Package $package, $directory) + { + $stub = __DIR__.'/stubs/phpunit.xml'; + + $this->files->copy($stub, $directory.'/phpunit.xml'); + } + + /** + * Write the Travis stub file. + * + * @param \Illuminate\Workbench\Package $package + * @param string $directory + * @return void + */ + protected function writeTravisFile(Package $package, $directory) + { + $stub = __DIR__.'/stubs/.travis.yml'; + + $this->files->copy($stub, $directory.'/.travis.yml'); + } + + /** + * Write the Composer.json stub file. + * + * @param \Illuminate\Workbench\Package $package + * @param string $directory + * @return void + */ + protected function writeComposerFile(Package $package, $directory, $plain) + { + $stub = $this->getComposerStub($plain); + + $stub = $this->formatPackageStub($package, $stub); + + $this->files->put($directory.'/composer.json', $stub); + } + + /** + * Get the Composer.json stub file contents. + * + * @param bool $plain + * @return string + */ + protected function getComposerStub($plain) + { + if ($plain) return $this->files->get(__DIR__.'/stubs/plain.composer.json'); + + return $this->files->get(__DIR__.'/stubs/composer.json'); + } + + /** + * Write the stub .gitignore file for the package. + * + * @param \Illuminate\Workbench\Package $package + * @param string $directory + * @return void + */ + public function writeIgnoreFile(Package $package, $directory, $plain) + { + $this->files->copy(__DIR__.'/stubs/gitignore.txt', $directory.'/.gitignore'); + } + + /** + * Create the support directories for a package. + * + * @param \Illuminate\Workbench\Package $package + * @param string $directory + * @return void + */ + public function writeSupportDirectories(Package $package, $directory) + { + foreach (array('config', 'controllers', 'lang', 'migrations', 'views') as $support) + { + $this->writeSupportDirectory($package, $support, $directory); + } + } + + /** + * Write a specific support directory for the package. + * + * @param \Illuminate\Workbench\Package $package + * @param string $support + * @param string $directory + * @return void + */ + protected function writeSupportDirectory(Package $package, $support, $directory) + { + // Once we create the source directory, we will write an empty file to the + // directory so that it will be kept in source control allowing the dev + // to go ahead and push these components to GitHub right on creation. + $path = $directory.'/src/'.$support; + + $this->files->makeDirectory($path, 0777, true); + + $this->files->put($path.'/.gitkeep', ''); + } + + /** + * Create the public directory for the package. + * + * @param \Illuminate\Workbench\Package $package + * @param string $directory + * @return void + */ + public function writePublicDirectory(Package $package, $directory, $plain) + { + if ($plain) return; + + $this->files->makeDirectory($directory.'/public'); + + $this->files->put($directory.'/public/.gitkeep', ''); + } + + /** + * Create the test directory for the package. + * + * @param \Illuminate\Workbench\Package $package + * @param string $directory + * @return void + */ + public function writeTestDirectory(Package $package, $directory) + { + $this->files->makeDirectory($directory.'/tests'); + + $this->files->put($directory.'/tests/.gitkeep', ''); + } + + /** + * Write the stub ServiceProvider for the package. + * + * @param \Illuminate\Workbench\Package $package + * @param string $directory + * @return void + */ + public function writeServiceProvider(Package $package, $directory, $plain) + { + // Once we have the service provider stub, we will need to format it and make + // the necessary replacements to the class, namespaces, etc. Then we'll be + // able to write it out into the package's workbench directory for them. + $stub = $this->getProviderStub($package, $plain); + + $this->writeProviderStub($package, $directory, $stub); + } + + /** + * Write the service provider stub for the package. + * + * @param \Illuminate\Workbench\Package $package + * @param string $directory + * @param string $stub + * @return void + */ + protected function writeProviderStub(Package $package, $directory, $stub) + { + $path = $this->createClassDirectory($package, $directory); + + // The primary source directory where the package's classes will live may not + // exist yet, so we will need to create it before we write these providers + // out to that location. We'll go ahead and create now here before then. + $file = $path.'/'.$package->name.'ServiceProvider.php'; + + $this->files->put($file, $stub); + } + + /** + * Get the stub for a ServiceProvider. + * + * @param \Illuminate\Workbench\Package $package + * @param bool $plain + * @return string + */ + protected function getProviderStub(Package $package, $plain) + { + return $this->formatPackageStub($package, $this->getProviderFile($plain)); + } + + /** + * Load the raw service provider file. + * + * @param bool $plain + * @return string + */ + protected function getProviderFile($plain) + { + if ($plain) + { + return $this->files->get(__DIR__.'/stubs/plain.provider.stub'); + } + else + { + return $this->files->get(__DIR__.'/stubs/provider.stub'); + } + } + + /** + * Create the main source directory for the package. + * + * @param \Illuminate\Workbench\Package $package + * @param string $directory + * @return string + */ + protected function createClassDirectory(Package $package, $directory) + { + $path = $directory.'/src/'.$package->vendor.'/'.$package->name; + + if ( ! $this->files->isDirectory($path)) + { + $this->files->makeDirectory($path, 0777, true); + } + + return $path; + } + + /** + * Format a generic package stub file. + * + * @param \Illuminate\Workbench\Package $package + * @param string $stub + * @return string + */ + protected function formatPackageStub(Package $package, $stub) + { + foreach (get_object_vars($package) as $key => $value) + { + $stub = str_replace('{{'.snake_case($key).'}}', $value, $stub); + } + + return $stub; + } + + /** + * Create a workbench directory for the package. + * + * @param \Illuminate\Workbench\Package $package + * @param string $path + * @return string + * + * @throws \InvalidArgumentException + */ + protected function createDirectory(Package $package, $path) + { + $fullPath = $path.'/'.$package->getFullName(); + + // If the directory doesn't exist, we will go ahead and create the package + // directory in the workbench location. We will use this entire package + // name when creating the directory to avoid any potential conflicts. + if ( ! $this->files->isDirectory($fullPath)) + { + $this->files->makeDirectory($fullPath, 0777, true); + + return $fullPath; + } + + throw new \InvalidArgumentException("Package exists."); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Workbench/Starter.php b/vendor/laravel/framework/src/Illuminate/Workbench/Starter.php new file mode 100755 index 0000000..b90c368 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Workbench/Starter.php @@ -0,0 +1,33 @@ +in($path)->files()->name('autoload.php')->depth('<= 3')->followLinks(); + + foreach ($autoloads as $file) + { + $files->requireOnce($file->getRealPath()); + } + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Workbench/WorkbenchServiceProvider.php b/vendor/laravel/framework/src/Illuminate/Workbench/WorkbenchServiceProvider.php new file mode 100755 index 0000000..f0b0d36 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Workbench/WorkbenchServiceProvider.php @@ -0,0 +1,45 @@ +app->bindShared('package.creator', function($app) + { + return new PackageCreator($app['files']); + }); + + $this->app->bindShared('command.workbench', function($app) + { + return new WorkbenchMakeCommand($app['package.creator']); + }); + + $this->commands('command.workbench'); + } + + /** + * Get the services provided by the provider. + * + * @return array + */ + public function provides() + { + return array('package.creator', 'command.workbench'); + } + +} diff --git a/vendor/laravel/framework/src/Illuminate/Workbench/composer.json b/vendor/laravel/framework/src/Illuminate/Workbench/composer.json new file mode 100755 index 0000000..3ea4002 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Workbench/composer.json @@ -0,0 +1,33 @@ +{ + "name": "illuminate/workbench", + "license": "MIT", + "authors": [ + { + "name": "Taylor Otwell", + "email": "taylorotwell@gmail.com" + } + ], + "require": { + "php": ">=5.3.0", + "illuminate/filesystem": "4.1.*", + "illuminate/support": "4.1.*", + "symfony/finder": "2.4.*" + }, + "require-dev": { + "illuminate/console": "4.1.*", + "mockery/mockery": "0.9.*", + "phpunit/phpunit": "4.0.*" + }, + "autoload": { + "psr-0": { + "Illuminate\\Workbench": "" + } + }, + "target-dir": "Illuminate/Workbench", + "extra": { + "branch-alias": { + "dev-master": "4.1-dev" + } + }, + "minimum-stability": "dev" +} diff --git a/vendor/laravel/framework/src/Illuminate/Workbench/stubs/.travis.yml b/vendor/laravel/framework/src/Illuminate/Workbench/stubs/.travis.yml new file mode 100755 index 0000000..aa14ee5 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Workbench/stubs/.travis.yml @@ -0,0 +1,14 @@ +language: php + +php: + - 5.3 + - 5.4 + - 5.5 + - 5.6 + - hhvm + +before_script: + - composer self-update + - composer install --prefer-source --no-interaction --dev + +script: phpunit diff --git a/vendor/laravel/framework/src/Illuminate/Workbench/stubs/composer.json b/vendor/laravel/framework/src/Illuminate/Workbench/stubs/composer.json new file mode 100755 index 0000000..6802339 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Workbench/stubs/composer.json @@ -0,0 +1,23 @@ +{ + "name": "{{lower_vendor}}/{{lower_name}}", + "description": "", + "authors": [ + { + "name": "{{author}}", + "email": "{{email}}" + } + ], + "require": { + "php": ">=5.3.0", + "illuminate/support": "4.1.*" + }, + "autoload": { + "classmap": [ + "src/migrations" + ], + "psr-0": { + "{{vendor}}\\{{name}}\\": "src/" + } + }, + "minimum-stability": "stable" +} diff --git a/vendor/laravel/framework/src/Illuminate/Workbench/stubs/gitignore.txt b/vendor/laravel/framework/src/Illuminate/Workbench/stubs/gitignore.txt new file mode 100755 index 0000000..5826402 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Workbench/stubs/gitignore.txt @@ -0,0 +1,4 @@ +/vendor +composer.phar +composer.lock +.DS_Store diff --git a/vendor/laravel/framework/src/Illuminate/Workbench/stubs/phpunit.xml b/vendor/laravel/framework/src/Illuminate/Workbench/stubs/phpunit.xml new file mode 100755 index 0000000..3347b75 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Workbench/stubs/phpunit.xml @@ -0,0 +1,18 @@ + + + + + ./tests/ + + + diff --git a/vendor/laravel/framework/src/Illuminate/Workbench/stubs/plain.composer.json b/vendor/laravel/framework/src/Illuminate/Workbench/stubs/plain.composer.json new file mode 100755 index 0000000..42698d3 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Workbench/stubs/plain.composer.json @@ -0,0 +1,20 @@ +{ + "name": "{{lower_vendor}}/{{lower_name}}", + "description": "", + "authors": [ + { + "name": "{{author}}", + "email": "{{email}}" + } + ], + "require": { + "php": ">=5.3.0", + "illuminate/support": "4.1.*" + }, + "autoload": { + "psr-0": { + "{{vendor}}\\{{name}}": "src/" + } + }, + "minimum-stability": "stable" +} diff --git a/vendor/laravel/framework/src/Illuminate/Workbench/stubs/plain.provider.stub b/vendor/laravel/framework/src/Illuminate/Workbench/stubs/plain.provider.stub new file mode 100755 index 0000000..68f4abc --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Workbench/stubs/plain.provider.stub @@ -0,0 +1,34 @@ +package('{{lower_vendor}}/{{lower_name}}'); + } + + /** + * Register the service provider. + * + * @return void + */ + public function register() + { + // + } + + /** + * Get the services provided by the provider. + * + * @return array + */ + public function provides() + { + return array(); + } + +} diff --git a/vendor/monolog/monolog/CHANGELOG.mdown b/vendor/monolog/monolog/CHANGELOG.mdown new file mode 100755 index 0000000..d675996 --- /dev/null +++ b/vendor/monolog/monolog/CHANGELOG.mdown @@ -0,0 +1,163 @@ +### 1.9.1 (2014-04-24) + + * Fixed regression in RotatingFileHandler file permissions + * Fixed initialization of the BufferHandler to make sure it gets flushed after receiving records + * Fixed ChromePHPHandler and FirePHPHandler's activation strategies to be more conservative + +### 1.9.0 (2014-04-20) + + * Added LogEntriesHandler to send logs to a LogEntries account + * Added $filePermissions to tweak file mode on StreamHandler and RotatingFileHandler + * Added $useFormatting flag to MemoryProcessor to make it send raw data in bytes + * Added support for table formatting in FirePHPHandler via the table context key + * Added a TagProcessor to add tags to records, and support for tags in RavenHandler + * Added $appendNewline flag to the JsonFormatter to enable using it when logging to files + * Added sound support to the PushoverHandler + * Fixed multi-threading support in StreamHandler + * Fixed empty headers issue when ChromePHPHandler received no records + * Fixed default format of the ErrorLogHandler + +### 1.8.0 (2014-03-23) + + * Break: the LineFormatter now strips newlines by default because this was a bug, set $allowInlineLineBreaks to true if you need them + * Added BrowserConsoleHandler to send logs to any browser's console via console.log() injection in the output + * Added FilterHandler to filter records and only allow those of a given list of levels through to the wrapped handler + * Added FlowdockHandler to send logs to a Flowdock account + * Added RollbarHandler to send logs to a Rollbar account + * Added HtmlFormatter to send prettier log emails with colors for each log level + * Added GitProcessor to add the current branch/commit to extra record data + * Added a Monolog\Registry class to allow easier global access to pre-configured loggers + * Added support for the new official graylog2/gelf-php lib for GelfHandler, upgrade if you can by replacing the mlehner/gelf-php requirement + * Added support for HHVM + * Added support for Loggly batch uploads + * Added support for tweaking the content type and encoding in NativeMailerHandler + * Added $skipClassesPartials to tweak the ignored classes in the IntrospectionProcessor + * Fixed batch request support in GelfHandler + +### 1.7.0 (2013-11-14) + + * Added ElasticSearchHandler to send logs to an Elastic Search server + * Added DynamoDbHandler and ScalarFormatter to send logs to Amazon's Dynamo DB + * Added SyslogUdpHandler to send logs to a remote syslogd server + * Added LogglyHandler to send logs to a Loggly account + * Added $level to IntrospectionProcessor so it only adds backtraces when needed + * Added $version to LogstashFormatter to allow using the new v1 Logstash format + * Added $appName to NewRelicHandler + * Added configuration of Pushover notification retries/expiry + * Added $maxColumnWidth to NativeMailerHandler to change the 70 chars default + * Added chainability to most setters for all handlers + * Fixed RavenHandler batch processing so it takes the message from the record with highest priority + * Fixed HipChatHandler batch processing so it sends all messages at once + * Fixed issues with eAccelerator + * Fixed and improved many small things + +### 1.6.0 (2013-07-29) + + * Added HipChatHandler to send logs to a HipChat chat room + * Added ErrorLogHandler to send logs to PHP's error_log function + * Added NewRelicHandler to send logs to NewRelic's service + * Added Monolog\ErrorHandler helper class to register a Logger as exception/error/fatal handler + * Added ChannelLevelActivationStrategy for the FingersCrossedHandler to customize levels by channel + * Added stack traces output when normalizing exceptions (json output & co) + * Added Monolog\Logger::API constant (currently 1) + * Added support for ChromePHP's v4.0 extension + * Added support for message priorities in PushoverHandler, see $highPriorityLevel and $emergencyLevel + * Added support for sending messages to multiple users at once with the PushoverHandler + * Fixed RavenHandler's support for batch sending of messages (when behind a Buffer or FingersCrossedHandler) + * Fixed normalization of Traversables with very large data sets, only the first 1000 items are shown now + * Fixed issue in RotatingFileHandler when an open_basedir restriction is active + * Fixed minor issues in RavenHandler and bumped the API to Raven 0.5.0 + * Fixed SyslogHandler issue when many were used concurrently with different facilities + +### 1.5.0 (2013-04-23) + + * Added ProcessIdProcessor to inject the PID in log records + * Added UidProcessor to inject a unique identifier to all log records of one request/run + * Added support for previous exceptions in the LineFormatter exception serialization + * Added Monolog\Logger::getLevels() to get all available levels + * Fixed ChromePHPHandler so it avoids sending headers larger than Chrome can handle + +### 1.4.1 (2013-04-01) + + * Fixed exception formatting in the LineFormatter to be more minimalistic + * Fixed RavenHandler's handling of context/extra data, requires Raven client >0.1.0 + * Fixed log rotation in RotatingFileHandler to work with long running scripts spanning multiple days + * Fixed WebProcessor array access so it checks for data presence + * Fixed Buffer, Group and FingersCrossed handlers to make use of their processors + +### 1.4.0 (2013-02-13) + + * Added RedisHandler to log to Redis via the Predis library or the phpredis extension + * Added ZendMonitorHandler to log to the Zend Server monitor + * Added the possibility to pass arrays of handlers and processors directly in the Logger constructor + * Added `$useSSL` option to the PushoverHandler which is enabled by default + * Fixed ChromePHPHandler and FirePHPHandler issue when multiple instances are used simultaneously + * Fixed header injection capability in the NativeMailHandler + +### 1.3.1 (2013-01-11) + + * Fixed LogstashFormatter to be usable with stream handlers + * Fixed GelfMessageFormatter levels on Windows + +### 1.3.0 (2013-01-08) + + * Added PSR-3 compliance, the `Monolog\Logger` class is now an instance of `Psr\Log\LoggerInterface` + * Added PsrLogMessageProcessor that you can selectively enable for full PSR-3 compliance + * Added LogstashFormatter (combine with SocketHandler or StreamHandler to send logs to Logstash) + * Added PushoverHandler to send mobile notifications + * Added CouchDBHandler and DoctrineCouchDBHandler + * Added RavenHandler to send data to Sentry servers + * Added support for the new MongoClient class in MongoDBHandler + * Added microsecond precision to log records' timestamps + * Added `$flushOnOverflow` param to BufferHandler to flush by batches instead of losing + the oldest entries + * Fixed normalization of objects with cyclic references + +### 1.2.1 (2012-08-29) + + * Added new $logopts arg to SyslogHandler to provide custom openlog options + * Fixed fatal error in SyslogHandler + +### 1.2.0 (2012-08-18) + + * Added AmqpHandler (for use with AMQP servers) + * Added CubeHandler + * Added NativeMailerHandler::addHeader() to send custom headers in mails + * Added the possibility to specify more than one recipient in NativeMailerHandler + * Added the possibility to specify float timeouts in SocketHandler + * Added NOTICE and EMERGENCY levels to conform with RFC 5424 + * Fixed the log records to use the php default timezone instead of UTC + * Fixed BufferHandler not being flushed properly on PHP fatal errors + * Fixed normalization of exotic resource types + * Fixed the default format of the SyslogHandler to avoid duplicating datetimes in syslog + +### 1.1.0 (2012-04-23) + + * Added Monolog\Logger::isHandling() to check if a handler will + handle the given log level + * Added ChromePHPHandler + * Added MongoDBHandler + * Added GelfHandler (for use with Graylog2 servers) + * Added SocketHandler (for use with syslog-ng for example) + * Added NormalizerFormatter + * Added the possibility to change the activation strategy of the FingersCrossedHandler + * Added possibility to show microseconds in logs + * Added `server` and `referer` to WebProcessor output + +### 1.0.2 (2011-10-24) + + * Fixed bug in IE with large response headers and FirePHPHandler + +### 1.0.1 (2011-08-25) + + * Added MemoryPeakUsageProcessor and MemoryUsageProcessor + * Added Monolog\Logger::getName() to get a logger's channel name + +### 1.0.0 (2011-07-06) + + * Added IntrospectionProcessor to get info from where the logger was called + * Fixed WebProcessor in CLI + +### 1.0.0-RC1 (2011-07-01) + + * Initial release diff --git a/vendor/monolog/monolog/LICENSE b/vendor/monolog/monolog/LICENSE new file mode 100755 index 0000000..5df1c39 --- /dev/null +++ b/vendor/monolog/monolog/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) Jordi Boggiano + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is furnished +to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/vendor/monolog/monolog/README.mdown b/vendor/monolog/monolog/README.mdown new file mode 100755 index 0000000..fd28a47 --- /dev/null +++ b/vendor/monolog/monolog/README.mdown @@ -0,0 +1,267 @@ +Monolog - Logging for PHP 5.3+ [![Build Status](https://secure.travis-ci.org/Seldaek/monolog.png)](http://travis-ci.org/Seldaek/monolog) +============================== + +[![Total Downloads](https://poser.pugx.org/monolog/monolog/downloads.png)](https://packagist.org/packages/monolog/monolog) +[![Latest Stable Version](https://poser.pugx.org/monolog/monolog/v/stable.png)](https://packagist.org/packages/monolog/monolog) + + +Monolog sends your logs to files, sockets, inboxes, databases and various +web services. See the complete list of handlers below. Special handlers +allow you to build advanced logging strategies. + +This library implements the [PSR-3](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-3-logger-interface.md) +interface that you can type-hint against in your own libraries to keep +a maximum of interoperability. You can also use it in your applications to +make sure you can always use another compatible logger at a later time. + +Usage +----- + +```php +pushHandler(new StreamHandler('path/to/your.log', Logger::WARNING)); + +// add records to the log +$log->addWarning('Foo'); +$log->addError('Bar'); +``` + +Core Concepts +------------- + +Every `Logger` instance has a channel (name) and a stack of handlers. Whenever +you add a record to the logger, it traverses the handler stack. Each handler +decides whether it handled fully the record, and if so, the propagation of the +record ends there. + +This allows for flexible logging setups, for example having a `StreamHandler` at +the bottom of the stack that will log anything to disk, and on top of that add +a `MailHandler` that will send emails only when an error message is logged. +Handlers also have a `$bubble` property which defines whether they block the +record or not if they handled it. In this example, setting the `MailHandler`'s +`$bubble` argument to false means that records handled by the `MailHandler` will +not propagate to the `StreamHandler` anymore. + +You can create many `Logger`s, each defining a channel (e.g.: db, request, +router, ..) and each of them combining various handlers, which can be shared +or not. The channel is reflected in the logs and allows you to easily see or +filter records. + +Each Handler also has a Formatter, a default one with settings that make sense +will be created if you don't set one. The formatters normalize and format +incoming records so that they can be used by the handlers to output useful +information. + +Custom severity levels are not available. Only the eight +[RFC 5424](http://tools.ietf.org/html/rfc5424) levels (debug, info, notice, +warning, error, critical, alert, emergency) are present for basic filtering +purposes, but for sorting and other use cases that would require +flexibility, you should add Processors to the Logger that can add extra +information (tags, user ip, ..) to the records before they are handled. + +Log Levels +---------- + +Monolog supports the logging levels described by [RFC 5424](http://tools.ietf.org/html/rfc5424). + +- **DEBUG** (100): Detailed debug information. + +- **INFO** (200): Interesting events. Examples: User logs in, SQL logs. + +- **NOTICE** (250): Normal but significant events. + +- **WARNING** (300): Exceptional occurrences that are not errors. Examples: + Use of deprecated APIs, poor use of an API, undesirable things that are not + necessarily wrong. + +- **ERROR** (400): Runtime errors that do not require immediate action but + should typically be logged and monitored. + +- **CRITICAL** (500): Critical conditions. Example: Application component + unavailable, unexpected exception. + +- **ALERT** (550): Action must be taken immediately. Example: Entire website + down, database unavailable, etc. This should trigger the SMS alerts and wake + you up. + +- **EMERGENCY** (600): Emergency: system is unusable. + +Docs +==== + +**See the `doc` directory for more detailed documentation. +The following is only a list of all parts that come with Monolog.** + +Handlers +-------- + +### Log to files and syslog + +- _StreamHandler_: Logs records into any PHP stream, use this for log files. +- _RotatingFileHandler_: Logs records to a file and creates one logfile per day. + It will also delete files older than `$maxFiles`. You should use + [logrotate](http://linuxcommand.org/man_pages/logrotate8.html) for high profile + setups though, this is just meant as a quick and dirty solution. +- _SyslogHandler_: Logs records to the syslog. +- _ErrorLogHandler_: Logs records to PHP's + [`error_log()`](http://docs.php.net/manual/en/function.error-log.php) function. + +### Send alerts and emails + +- _NativeMailerHandler_: Sends emails using PHP's + [`mail()`](http://php.net/manual/en/function.mail.php) function. +- _SwiftMailerHandler_: Sends emails using a [`Swift_Mailer`](http://swiftmailer.org/) instance. +- _PushoverHandler_: Sends mobile notifications via the [Pushover](https://www.pushover.net/) API. +- _HipChatHandler_: Logs records to a [HipChat](http://hipchat.com) chat room using its API. +- _FlowdockHandler_: Logs records to a [Flowdock](https://www.flowdock.com/) account. + +### Log specific servers and networked logging + +- _SocketHandler_: Logs records to [sockets](http://php.net/fsockopen), use this + for UNIX and TCP sockets. See an [example](https://github.com/Seldaek/monolog/blob/master/doc/sockets.md). +- _AmqpHandler_: Logs records to an [amqp](http://www.amqp.org/) compatible + server. Requires the [php-amqp](http://pecl.php.net/package/amqp) extension (1.0+). +- _GelfHandler_: Logs records to a [Graylog2](http://www.graylog2.org) server. +- _CubeHandler_: Logs records to a [Cube](http://square.github.com/cube/) server. +- _RavenHandler_: Logs records to a [Sentry](http://getsentry.com/) server using + [raven](https://packagist.org/packages/raven/raven). +- _ZendMonitorHandler_: Logs records to the Zend Monitor present in Zend Server. +- _NewRelicHandler_: Logs records to a [NewRelic](http://newrelic.com/) application. +- _LogglyHandler_: Logs records to a [Loggly](http://www.loggly.com/) account. +- _RollbarHandler_: Logs records to a [Rollbar](https://rollbar.com/) account. +- _SyslogUdpHandler_: Logs records to a remote [Syslogd](http://www.rsyslog.com/) server. +- _LogEntriesHandler_: Logs records to a [LogEntries](http://logentries.com/) account. + +### Logging in development + +- _FirePHPHandler_: Handler for [FirePHP](http://www.firephp.org/), providing + inline `console` messages within [FireBug](http://getfirebug.com/). +- _ChromePHPHandler_: Handler for [ChromePHP](http://www.chromephp.com/), providing + inline `console` messages within Chrome. +- _BrowserConsoleHandler_: Handler to send logs to browser's Javascript `console` with + no browser extension required. Most browsers supporting `console` API are supported. + +### Log to databases + +- _RedisHandler_: Logs records to a [redis](http://redis.io) server. +- _MongoDBHandler_: Handler to write records in MongoDB via a + [Mongo](http://pecl.php.net/package/mongo) extension connection. +- _CouchDBHandler_: Logs records to a CouchDB server. +- _DoctrineCouchDBHandler_: Logs records to a CouchDB server via the Doctrine CouchDB ODM. +- _ElasticSearchHandler_: Logs records to an Elastic Search server. +- _DynamoDbHandler_: Logs records to a DynamoDB table with the [AWS SDK](https://github.com/aws/aws-sdk-php). + +### Wrappers / Special Handlers + +- _FingersCrossedHandler_: A very interesting wrapper. It takes a logger as + parameter and will accumulate log records of all levels until a record + exceeds the defined severity level. At which point it delivers all records, + including those of lower severity, to the handler it wraps. This means that + until an error actually happens you will not see anything in your logs, but + when it happens you will have the full information, including debug and info + records. This provides you with all the information you need, but only when + you need it. +- _NullHandler_: Any record it can handle will be thrown away. This can be used + to put on top of an existing handler stack to disable it temporarily. +- _BufferHandler_: This handler will buffer all the log records it receives + until `close()` is called at which point it will call `handleBatch()` on the + handler it wraps with all the log messages at once. This is very useful to + send an email with all records at once for example instead of having one mail + for every log record. +- _GroupHandler_: This handler groups other handlers. Every record received is + sent to all the handlers it is configured with. +- _FilterHandler_: This handler only lets records of the given levels through + to the wrapped handler. +- _TestHandler_: Used for testing, it records everything that is sent to it and + has accessors to read out the information. + +Formatters +---------- + +- _LineFormatter_: Formats a log record into a one-line string. +- _HtmlFormatter_: Used to format log records into a human readable html table, mainly suitable for emails. +- _NormalizerFormatter_: Normalizes objects/resources down to strings so a record can easily be serialized/encoded. +- _ScalarFormatter_: Used to format log records into an associative array of scalar values. +- _JsonFormatter_: Encodes a log record into json. +- _WildfireFormatter_: Used to format log records into the Wildfire/FirePHP protocol, only useful for the FirePHPHandler. +- _ChromePHPFormatter_: Used to format log records into the ChromePHP format, only useful for the ChromePHPHandler. +- _GelfMessageFormatter_: Used to format log records into Gelf message instances, only useful for the GelfHandler. +- _LogstashFormatter_: Used to format log records into [logstash](http://logstash.net/) event json, useful for any handler listed under inputs [here](http://logstash.net/docs/1.1.5/). +- _ElasticaFormatter_: Used to format log records into an Elastica\Document object, only useful for the ElasticSearchHandler. +- _LogglyFormatter_: Used to format log records into Loggly messages, only useful for the LogglyHandler. +- _FlowdockFormatter_: Used to format log records into Flowdock messages, only useful for the FlowdockHandler. + +Processors +---------- + +- _IntrospectionProcessor_: Adds the line/file/class/method from which the log call originated. +- _WebProcessor_: Adds the current request URI, request method and client IP to a log record. +- _MemoryUsageProcessor_: Adds the current memory usage to a log record. +- _MemoryPeakUsageProcessor_: Adds the peak memory usage to a log record. +- _ProcessIdProcessor_: Adds the process id to a log record. +- _UidProcessor_: Adds a unique identifier to a log record. +- _GitProcessor_: Adds the current git branch and commit to a log record. +- _TagProcessor_: Adds an array of predefined tags to a log record. + +Utilities +--------- + +- _Registry_: The `Monolog\Registry` class lets you configure global loggers that you + can then statically access from anywhere. It is not really a best practice but can + help in some older codebases or for ease of use. +- _ErrorHandler_: The `Monolog\ErrorHandler` class allows you to easily register + a Logger instance as an exception handler, error handler or fatal error handler. +- _ErrorLevelActivationStrategy_: Activates a FingersCrossedHandler when a certain log + level is reached. +- _ChannelLevelActivationStrategy_: Activates a FingersCrossedHandler when a certain + log level is reached, depending on which channel received the log record. + +About +===== + +Requirements +------------ + +- Monolog works with PHP 5.3 or above, and is also tested to work with HHVM. + +Submitting bugs and feature requests +------------------------------------ + +Bugs and feature request are tracked on [GitHub](https://github.com/Seldaek/monolog/issues) + +Frameworks Integration +---------------------- + +- Frameworks and libraries using [PSR-3](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-3-logger-interface.md) + can be used very easily with Monolog since it implements the interface. +- [Symfony2](http://symfony.com) comes out of the box with Monolog. +- [Silex](http://silex.sensiolabs.org/) comes out of the box with Monolog. +- [Laravel 4](http://laravel.com/) comes out of the box with Monolog. +- [PPI](http://www.ppi.io/) comes out of the box with Monolog. +- [CakePHP](http://cakephp.org/) is usable with Monolog via the [cakephp-monolog](https://github.com/jadb/cakephp-monolog) plugin. +- [Slim](http://www.slimframework.com/) is usable with Monolog via the [Slim-Monolog](https://github.com/Flynsarmy/Slim-Monolog) log writer. +- [XOOPS 2.6](http://xoops.org/) comes out of the box with Monolog. +- [Aura.Web_Project](https://github.com/auraphp/Aura.Web_Project) comes out of the box with Monolog. + +Author +------ + +Jordi Boggiano - -
    +See also the list of [contributors](https://github.com/Seldaek/monolog/contributors) which participated in this project. + +License +------- + +Monolog is licensed under the MIT License - see the `LICENSE` file for details + +Acknowledgements +---------------- + +This library is heavily inspired by Python's [Logbook](http://packages.python.org/Logbook/) +library, although most concepts have been adjusted to fit to the PHP world. diff --git a/vendor/monolog/monolog/composer.json b/vendor/monolog/monolog/composer.json new file mode 100755 index 0000000..bcbe1b6 --- /dev/null +++ b/vendor/monolog/monolog/composer.json @@ -0,0 +1,45 @@ +{ + "name": "monolog/monolog", + "description": "Sends your logs to files, sockets, inboxes, databases and various web services", + "keywords": ["log", "logging", "psr-3"], + "homepage": "http://github.com/Seldaek/monolog", + "type": "library", + "license": "MIT", + "authors": [ + { + "name": "Jordi Boggiano", + "email": "j.boggiano@seld.be", + "homepage": "http://seld.be" + } + ], + "require": { + "php": ">=5.3.0", + "psr/log": "~1.0" + }, + "require-dev": { + "phpunit/phpunit": "~3.7.0", + "graylog2/gelf-php": "~1.0", + "raven/raven": "~0.5", + "ruflin/elastica": "0.90.*", + "doctrine/couchdb": "~1.0@dev", + "aws/aws-sdk-php": "~2.4, >2.4.8" + }, + "suggest": { + "graylog2/gelf-php": "Allow sending log messages to a GrayLog2 server", + "raven/raven": "Allow sending log messages to a Sentry server", + "doctrine/couchdb": "Allow sending log messages to a CouchDB server", + "ruflin/elastica": "Allow sending log messages to an Elastic Search server", + "ext-amqp": "Allow sending log messages to an AMQP server (1.0+ required)", + "ext-mongo": "Allow sending log messages to a MongoDB server", + "aws/aws-sdk-php": "Allow sending log messages to AWS services like DynamoDB", + "rollbar/rollbar": "Allow sending log messages to Rollbar" + }, + "autoload": { + "psr-4": {"Monolog\\": "src/Monolog"} + }, + "extra": { + "branch-alias": { + "dev-master": "1.9.x-dev" + } + } +} diff --git a/vendor/monolog/monolog/doc/extending.md b/vendor/monolog/monolog/doc/extending.md new file mode 100755 index 0000000..bb39ddc --- /dev/null +++ b/vendor/monolog/monolog/doc/extending.md @@ -0,0 +1,76 @@ +Extending Monolog +================= + +Monolog is fully extensible, allowing you to adapt your logger to your needs. + +Writing your own handler +------------------------ + +Monolog provides many built-in handlers. But if the one you need does not +exist, you can write it and use it in your logger. The only requirement is +to implement `Monolog\Handler\HandlerInterface`. + +Let's write a PDOHandler to log records to a database. We will extend the +abstract class provided by Monolog to keep things DRY. + +```php +pdo = $pdo; + parent::__construct($level, $bubble); + } + + protected function write(array $record) + { + if (!$this->initialized) { + $this->initialize(); + } + + $this->statement->execute(array( + 'channel' => $record['channel'], + 'level' => $record['level'], + 'message' => $record['formatted'], + 'time' => $record['datetime']->format('U'), + )); + } + + private function initialize() + { + $this->pdo->exec( + 'CREATE TABLE IF NOT EXISTS monolog ' + .'(channel VARCHAR(255), level INTEGER, message LONGTEXT, time INTEGER UNSIGNED)' + ); + $this->statement = $this->pdo->prepare( + 'INSERT INTO monolog (channel, level, message, time) VALUES (:channel, :level, :message, :time)' + ); + + $this->initialized = true; + } +} +``` + +You can now use this handler in your logger: + +```php +pushHandler(new PDOHandler(new PDO('sqlite:logs.sqlite'))); + +// You can now use your logger +$logger->addInfo('My logger is now ready'); +``` + +The `Monolog\Handler\AbstractProcessingHandler` class provides most of the +logic needed for the handler, including the use of processors and the formatting +of the record (which is why we use ``$record['formatted']`` instead of ``$record['message']``). diff --git a/vendor/monolog/monolog/doc/sockets.md b/vendor/monolog/monolog/doc/sockets.md new file mode 100755 index 0000000..fad30a9 --- /dev/null +++ b/vendor/monolog/monolog/doc/sockets.md @@ -0,0 +1,37 @@ +Sockets Handler +=============== + +This handler allows you to write your logs to sockets using [fsockopen](http://php.net/fsockopen) +or [pfsockopen](http://php.net/pfsockopen). + +Persistent sockets are mainly useful in web environments where you gain some performance not closing/opening +the connections between requests. + +Basic Example +------------- + +```php +setPersistent(true); + +// Now add the handler +$logger->pushHandler($handler, Logger::DEBUG); + +// You can now use your logger +$logger->addInfo('My logger is now ready'); + +``` + +In this example, using syslog-ng, you should see the log on the log server: + + cweb1 [2012-02-26 00:12:03] my_logger.INFO: My logger is now ready [] [] + diff --git a/vendor/monolog/monolog/doc/usage.md b/vendor/monolog/monolog/doc/usage.md new file mode 100755 index 0000000..846bd51 --- /dev/null +++ b/vendor/monolog/monolog/doc/usage.md @@ -0,0 +1,162 @@ +Using Monolog +============= + +Installation +------------ + +Monolog is available on Packagist ([monolog/monolog](http://packagist.org/packages/monolog/monolog)) +and as such installable via [Composer](http://getcomposer.org/). + +```bash +php composer.phar require monolog/monolog '~1.7' +``` + +If you do not use Composer, you can grab the code from GitHub, and use any +PSR-0 compatible autoloader (e.g. the [Symfony2 ClassLoader component](https://github.com/symfony/ClassLoader)) +to load Monolog classes. + +Configuring a logger +-------------------- + +Here is a basic setup to log to a file and to firephp on the DEBUG level: + +```php +pushHandler(new StreamHandler(__DIR__.'/my_app.log', Logger::DEBUG)); +$logger->pushHandler(new FirePHPHandler()); + +// You can now use your logger +$logger->addInfo('My logger is now ready'); +``` + +Let's explain it. The first step is to create the logger instance which will +be used in your code. The argument is a channel name, which is useful when +you use several loggers (see below for more details about it). + +The logger itself does not know how to handle a record. It delegates it to +some handlers. The code above registers two handlers in the stack to allow +handling records in two different ways. + +Note that the FirePHPHandler is called first as it is added on top of the +stack. This allows you to temporarily add a logger with bubbling disabled if +you want to override other configured loggers. + +Adding extra data in the records +-------------------------------- + +Monolog provides two different ways to add extra informations along the simple +textual message. + +### Using the logging context + +The first way is the context, allowing to pass an array of data along the +record: + +```php +addInfo('Adding a new user', array('username' => 'Seldaek')); +``` + +Simple handlers (like the StreamHandler for instance) will simply format +the array to a string but richer handlers can take advantage of the context +(FirePHP is able to display arrays in pretty way for instance). + +### Using processors + +The second way is to add extra data for all records by using a processor. +Processors can be any callable. They will get the record as parameter and +must return it after having eventually changed the `extra` part of it. Let's +write a processor adding some dummy data in the record: + +```php +pushProcessor(function ($record) { + $record['extra']['dummy'] = 'Hello world!'; + + return $record; +}); +``` + +Monolog provides some built-in processors that can be used in your project. +Look at the [README file](https://github.com/Seldaek/monolog/blob/master/README.mdown) for the list. + +> Tip: processors can also be registered on a specific handler instead of + the logger to apply only for this handler. + +Leveraging channels +------------------- + +Channels are a great way to identify to which part of the application a record +is related. This is useful in big applications (and is leveraged by +MonologBundle in Symfony2). + +Picture two loggers sharing a handler that writes to a single log file. +Channels would allow you to identify the logger that issued every record. +You can easily grep through the log files filtering this or that channel. + +```php +pushHandler($stream); +$logger->pushHandler($firephp); + +// Create a logger for the security-related stuff with a different channel +$securityLogger = new Logger('security'); +$securityLogger->pushHandler($stream); +$securityLogger->pushHandler($firephp); +``` + +Customizing log format +---------------------- + +In Monolog it's easy to customize the format of the logs written into files, +sockets, mails, databases and other handlers. Most of the handlers use the + +```php +$record['formatted'] +``` + +value to be automatically put into the log device. This value depends on the +formatter settings. You can choose between predefined formatter classes or +write your own (e.g. a multiline text file for human-readable output). + +To configure a predefined formatter class, just set it as the handler's field: + +```php +// the default date format is "Y-m-d H:i:s" +$dateFormat = "Y n j, g:i a"; +// the default output format is "[%datetime%] %channel%.%level_name%: %message% %context% %extra%\n" +$output = "%datetime% > %level_name% > %message% %context% %extra%\n"; +// finally, create a formatter +$formatter = new LineFormatter($output, $dateFormat); + +// Create a handler +$stream = new StreamHandler(__DIR__.'/my_app.log', Logger::DEBUG); +$stream->setFormatter($formatter); +// bind it to a logger object +$securityLogger = new Logger('security'); +$securityLogger->pushHandler($stream); +``` + +You may also reuse the same formatter between multiple handlers and share those +handlers between multiple loggers. diff --git a/vendor/monolog/monolog/phpunit.xml.dist b/vendor/monolog/monolog/phpunit.xml.dist new file mode 100755 index 0000000..1754570 --- /dev/null +++ b/vendor/monolog/monolog/phpunit.xml.dist @@ -0,0 +1,15 @@ + + + + + + tests/Monolog/ + + + + + + src/Monolog/ + + + diff --git a/vendor/monolog/monolog/src/Monolog/ErrorHandler.php b/vendor/monolog/monolog/src/Monolog/ErrorHandler.php new file mode 100755 index 0000000..f9cca00 --- /dev/null +++ b/vendor/monolog/monolog/src/Monolog/ErrorHandler.php @@ -0,0 +1,208 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog; + +use Psr\Log\LoggerInterface; +use Psr\Log\LogLevel; + +/** + * Monolog error handler + * + * A facility to enable logging of runtime errors, exceptions and fatal errors. + * + * Quick setup: ErrorHandler::register($logger); + * + * @author Jordi Boggiano + */ +class ErrorHandler +{ + private $logger; + + private $previousExceptionHandler; + private $uncaughtExceptionLevel; + + private $previousErrorHandler; + private $errorLevelMap; + + private $fatalLevel; + private $reservedMemory; + private static $fatalErrors = array(E_ERROR, E_PARSE, E_CORE_ERROR, E_COMPILE_ERROR, E_USER_ERROR); + + public function __construct(LoggerInterface $logger) + { + $this->logger = $logger; + } + + /** + * Registers a new ErrorHandler for a given Logger + * + * By default it will handle errors, exceptions and fatal errors + * + * @param LoggerInterface $logger + * @param array|false $errorLevelMap an array of E_* constant to LogLevel::* constant mapping, or false to disable error handling + * @param int|false $exceptionLevel a LogLevel::* constant, or false to disable exception handling + * @param int|false $fatalLevel a LogLevel::* constant, or false to disable fatal error handling + * @return ErrorHandler + */ + public static function register(LoggerInterface $logger, $errorLevelMap = array(), $exceptionLevel = null, $fatalLevel = null) + { + $handler = new static($logger); + if ($errorLevelMap !== false) { + $handler->registerErrorHandler($errorLevelMap); + } + if ($exceptionLevel !== false) { + $handler->registerExceptionHandler($exceptionLevel); + } + if ($fatalLevel !== false) { + $handler->registerFatalHandler($fatalLevel); + } + + return $handler; + } + + public function registerExceptionHandler($level = null, $callPrevious = true) + { + $prev = set_exception_handler(array($this, 'handleException')); + $this->uncaughtExceptionLevel = $level; + if ($callPrevious && $prev) { + $this->previousExceptionHandler = $prev; + } + } + + public function registerErrorHandler(array $levelMap = array(), $callPrevious = true, $errorTypes = -1) + { + $prev = set_error_handler(array($this, 'handleError'), $errorTypes); + $this->errorLevelMap = array_replace($this->defaultErrorLevelMap(), $levelMap); + if ($callPrevious) { + $this->previousErrorHandler = $prev ?: true; + } + } + + public function registerFatalHandler($level = null, $reservedMemorySize = 20) + { + register_shutdown_function(array($this, 'handleFatalError')); + + $this->reservedMemory = str_repeat(' ', 1024 * $reservedMemorySize); + $this->fatalLevel = $level; + } + + protected function defaultErrorLevelMap() + { + return array( + E_ERROR => LogLevel::CRITICAL, + E_WARNING => LogLevel::WARNING, + E_PARSE => LogLevel::ALERT, + E_NOTICE => LogLevel::NOTICE, + E_CORE_ERROR => LogLevel::CRITICAL, + E_CORE_WARNING => LogLevel::WARNING, + E_COMPILE_ERROR => LogLevel::ALERT, + E_COMPILE_WARNING => LogLevel::WARNING, + E_USER_ERROR => LogLevel::ERROR, + E_USER_WARNING => LogLevel::WARNING, + E_USER_NOTICE => LogLevel::NOTICE, + E_STRICT => LogLevel::NOTICE, + E_RECOVERABLE_ERROR => LogLevel::ERROR, + E_DEPRECATED => LogLevel::NOTICE, + E_USER_DEPRECATED => LogLevel::NOTICE, + ); + } + + /** + * @private + */ + public function handleException(\Exception $e) + { + $this->logger->log( + $this->uncaughtExceptionLevel === null ? LogLevel::ERROR : $this->uncaughtExceptionLevel, + sprintf('Uncaught Exception %s: "%s" at %s line %s', get_class($e), $e->getMessage(), $e->getFile(), $e->getLine()), + array('exception' => $e) + ); + + if ($this->previousExceptionHandler) { + call_user_func($this->previousExceptionHandler, $e); + } + } + + /** + * @private + */ + public function handleError($code, $message, $file = '', $line = 0, $context = array()) + { + if (!(error_reporting() & $code)) { + return; + } + + $level = isset($this->errorLevelMap[$code]) ? $this->errorLevelMap[$code] : LogLevel::CRITICAL; + $this->logger->log($level, self::codeToString($code).': '.$message, array('file' => $file, 'line' => $line)); + + if ($this->previousErrorHandler === true) { + return false; + } elseif ($this->previousErrorHandler) { + return call_user_func($this->previousErrorHandler, $code, $message, $file, $line, $context); + } + } + + /** + * @private + */ + public function handleFatalError() + { + $this->reservedMemory = null; + + $lastError = error_get_last(); + if ($lastError && in_array($lastError['type'], self::$fatalErrors)) { + $this->logger->log( + $this->fatalLevel === null ? LogLevel::ALERT : $this->fatalLevel, + 'Fatal Error ('.self::codeToString($lastError['type']).'): '.$lastError['message'], + array('file' => $lastError['file'], 'line' => $lastError['line']) + ); + } + } + + private static function codeToString($code) + { + switch ($code) { + case E_ERROR: + return 'E_ERROR'; + case E_WARNING: + return 'E_WARNING'; + case E_PARSE: + return 'E_PARSE'; + case E_NOTICE: + return 'E_NOTICE'; + case E_CORE_ERROR: + return 'E_CORE_ERROR'; + case E_CORE_WARNING: + return 'E_CORE_WARNING'; + case E_COMPILE_ERROR: + return 'E_COMPILE_ERROR'; + case E_COMPILE_WARNING: + return 'E_COMPILE_WARNING'; + case E_USER_ERROR: + return 'E_USER_ERROR'; + case E_USER_WARNING: + return 'E_USER_WARNING'; + case E_USER_NOTICE: + return 'E_USER_NOTICE'; + case E_STRICT: + return 'E_STRICT'; + case E_RECOVERABLE_ERROR: + return 'E_RECOVERABLE_ERROR'; + case E_DEPRECATED: + return 'E_DEPRECATED'; + case E_USER_DEPRECATED: + return 'E_USER_DEPRECATED'; + } + + return 'Unknown PHP error'; + } +} diff --git a/vendor/monolog/monolog/src/Monolog/Formatter/ChromePHPFormatter.php b/vendor/monolog/monolog/src/Monolog/Formatter/ChromePHPFormatter.php new file mode 100755 index 0000000..56d3e27 --- /dev/null +++ b/vendor/monolog/monolog/src/Monolog/Formatter/ChromePHPFormatter.php @@ -0,0 +1,79 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Formatter; + +use Monolog\Logger; + +/** + * Formats a log message according to the ChromePHP array format + * + * @author Christophe Coevoet + */ +class ChromePHPFormatter implements FormatterInterface +{ + /** + * Translates Monolog log levels to Wildfire levels. + */ + private $logLevels = array( + Logger::DEBUG => 'log', + Logger::INFO => 'info', + Logger::NOTICE => 'info', + Logger::WARNING => 'warn', + Logger::ERROR => 'error', + Logger::CRITICAL => 'error', + Logger::ALERT => 'error', + Logger::EMERGENCY => 'error', + ); + + /** + * {@inheritdoc} + */ + public function format(array $record) + { + // Retrieve the line and file if set and remove them from the formatted extra + $backtrace = 'unknown'; + if (isset($record['extra']['file']) && isset($record['extra']['line'])) { + $backtrace = $record['extra']['file'].' : '.$record['extra']['line']; + unset($record['extra']['file']); + unset($record['extra']['line']); + } + + $message = array('message' => $record['message']); + if ($record['context']) { + $message['context'] = $record['context']; + } + if ($record['extra']) { + $message['extra'] = $record['extra']; + } + if (count($message) === 1) { + $message = reset($message); + } + + return array( + $record['channel'], + $message, + $backtrace, + $this->logLevels[$record['level']], + ); + } + + public function formatBatch(array $records) + { + $formatted = array(); + + foreach ($records as $record) { + $formatted[] = $this->format($record); + } + + return $formatted; + } +} diff --git a/vendor/monolog/monolog/src/Monolog/Formatter/ElasticaFormatter.php b/vendor/monolog/monolog/src/Monolog/Formatter/ElasticaFormatter.php new file mode 100755 index 0000000..b0b0cf0 --- /dev/null +++ b/vendor/monolog/monolog/src/Monolog/Formatter/ElasticaFormatter.php @@ -0,0 +1,87 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Formatter; + +use Elastica\Document; + +/** + * Format a log message into an Elastica Document + * + * @author Jelle Vink + */ +class ElasticaFormatter extends NormalizerFormatter +{ + /** + * @var string Elastic search index name + */ + protected $index; + + /** + * @var string Elastic search document type + */ + protected $type; + + /** + * @param string $index Elastic Search index name + * @param string $type Elastic Search document type + */ + public function __construct($index, $type) + { + parent::__construct(\DateTime::ISO8601); + $this->index = $index; + $this->type = $type; + } + + /** + * {@inheritdoc} + */ + public function format(array $record) + { + $record = parent::format($record); + + return $this->getDocument($record); + } + + /** + * Getter index + * @return string + */ + public function getIndex() + { + return $this->index; + } + + /** + * Getter type + * @return string + */ + public function getType() + { + return $this->type; + } + + /** + * Convert a log message into an Elastica Document + * + * @param array $record Log message + * @return Document + */ + protected function getDocument($record) + { + $document = new Document(); + $document->setData($record); + $document->setType($this->type); + $document->setIndex($this->index); + + return $document; + } +} diff --git a/vendor/monolog/monolog/src/Monolog/Formatter/FlowdockFormatter.php b/vendor/monolog/monolog/src/Monolog/Formatter/FlowdockFormatter.php new file mode 100755 index 0000000..af63d01 --- /dev/null +++ b/vendor/monolog/monolog/src/Monolog/Formatter/FlowdockFormatter.php @@ -0,0 +1,104 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Formatter; + +/** + * formats the record to be used in the FlowdockHandler + * + * @author Dominik Liebler + */ +class FlowdockFormatter implements FormatterInterface +{ + /** + * @var string + */ + private $source; + + /** + * @var string + */ + private $sourceEmail; + + /** + * @param string $source + * @param string $sourceEmail + */ + public function __construct($source, $sourceEmail) + { + $this->source = $source; + $this->sourceEmail = $sourceEmail; + } + + /** + * {@inheritdoc} + */ + public function format(array $record) + { + $tags = array( + '#logs', + '#' . strtolower($record['level_name']), + '#' . $record['channel'], + ); + + foreach ($record['extra'] as $value) { + $tags[] = '#' . $value; + } + + $subject = sprintf( + 'in %s: %s - %s', + $this->source, + $record['level_name'], + $this->getShortMessage($record['message']) + ); + + $record['flowdock'] = array( + 'source' => $this->source, + 'from_address' => $this->sourceEmail, + 'subject' => $subject, + 'content' => $record['message'], + 'tags' => $tags, + 'project' => $this->source, + ); + + return $record; + } + + /** + * {@inheritdoc} + */ + public function formatBatch(array $records) + { + $formatted = array(); + + foreach ($records as $record) { + $formatted[] = $this->format($record); + } + + return $formatted; + } + + /** + * @param string $message + * + * @return string + */ + public function getShortMessage($message) + { + $maxLength = 45; + + if (strlen($message) > $maxLength) { + $message = substr($message, 0, $maxLength - 4) . ' ...'; + } + + return $message; + } +} diff --git a/vendor/monolog/monolog/src/Monolog/Formatter/FormatterInterface.php b/vendor/monolog/monolog/src/Monolog/Formatter/FormatterInterface.php new file mode 100755 index 0000000..b5de751 --- /dev/null +++ b/vendor/monolog/monolog/src/Monolog/Formatter/FormatterInterface.php @@ -0,0 +1,36 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Formatter; + +/** + * Interface for formatters + * + * @author Jordi Boggiano + */ +interface FormatterInterface +{ + /** + * Formats a log record. + * + * @param array $record A record to format + * @return mixed The formatted record + */ + public function format(array $record); + + /** + * Formats a set of log records. + * + * @param array $records A set of records to format + * @return mixed The formatted set of records + */ + public function formatBatch(array $records); +} diff --git a/vendor/monolog/monolog/src/Monolog/Formatter/GelfMessageFormatter.php b/vendor/monolog/monolog/src/Monolog/Formatter/GelfMessageFormatter.php new file mode 100755 index 0000000..6ebfaa7 --- /dev/null +++ b/vendor/monolog/monolog/src/Monolog/Formatter/GelfMessageFormatter.php @@ -0,0 +1,101 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Formatter; + +use Monolog\Logger; +use Gelf\Message; + +/** + * Serializes a log message to GELF + * @see http://www.graylog2.org/about/gelf + * + * @author Matt Lehner + */ +class GelfMessageFormatter extends NormalizerFormatter +{ + /** + * @var string the name of the system for the Gelf log message + */ + protected $systemName; + + /** + * @var string a prefix for 'extra' fields from the Monolog record (optional) + */ + protected $extraPrefix; + + /** + * @var string a prefix for 'context' fields from the Monolog record (optional) + */ + protected $contextPrefix; + + /** + * Translates Monolog log levels to Graylog2 log priorities. + */ + private $logLevels = array( + Logger::DEBUG => 7, + Logger::INFO => 6, + Logger::NOTICE => 5, + Logger::WARNING => 4, + Logger::ERROR => 3, + Logger::CRITICAL => 2, + Logger::ALERT => 1, + Logger::EMERGENCY => 0, + ); + + public function __construct($systemName = null, $extraPrefix = null, $contextPrefix = 'ctxt_') + { + parent::__construct('U.u'); + + $this->systemName = $systemName ?: gethostname(); + + $this->extraPrefix = $extraPrefix; + $this->contextPrefix = $contextPrefix; + } + + /** + * {@inheritdoc} + */ + public function format(array $record) + { + $record = parent::format($record); + $message = new Message(); + $message + ->setTimestamp($record['datetime']) + ->setShortMessage((string) $record['message']) + ->setFacility($record['channel']) + ->setHost($this->systemName) + ->setLine(isset($record['extra']['line']) ? $record['extra']['line'] : null) + ->setFile(isset($record['extra']['file']) ? $record['extra']['file'] : null) + ->setLevel($this->logLevels[$record['level']]); + + // Do not duplicate these values in the additional fields + unset($record['extra']['line']); + unset($record['extra']['file']); + + foreach ($record['extra'] as $key => $val) { + $message->setAdditional($this->extraPrefix . $key, is_scalar($val) ? $val : $this->toJson($val)); + } + + foreach ($record['context'] as $key => $val) { + $message->setAdditional($this->contextPrefix . $key, is_scalar($val) ? $val : $this->toJson($val)); + } + + if (null === $message->getFile() && isset($record['context']['exception'])) { + if (preg_match("/^(.+):([0-9]+)$/", $record['context']['exception']['file'], $matches)) { + $message->setFile($matches[1]); + $message->setLine($matches[2]); + } + } + + return $message; + } +} diff --git a/vendor/monolog/monolog/src/Monolog/Formatter/HtmlFormatter.php b/vendor/monolog/monolog/src/Monolog/Formatter/HtmlFormatter.php new file mode 100755 index 0000000..f07c871 --- /dev/null +++ b/vendor/monolog/monolog/src/Monolog/Formatter/HtmlFormatter.php @@ -0,0 +1,127 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Formatter; + +use Monolog\Logger; + +/** + * Formats incoming records into an HTML table + * + * This is especially useful for html email logging + * + * @author Tiago Brito + */ +class HtmlFormatter extends NormalizerFormatter +{ + /** + * Translates Monolog log levels to html color priorities. + */ + private $logLevels = array( + Logger::DEBUG => '#cccccc', + Logger::INFO => '#468847', + Logger::NOTICE => '#3a87ad', + Logger::WARNING => '#c09853', + Logger::ERROR => '#f0ad4e', + Logger::CRITICAL => '#FF7708', + Logger::ALERT => '#C12A19', + Logger::EMERGENCY => '#000000', + ); + + /** + * @param string $dateFormat The format of the timestamp: one supported by DateTime::format + */ + public function __construct($dateFormat = null) + { + parent::__construct($dateFormat); + } + + /** + * Creates an HTML table row + * + * @param string $th Row header content + * @param string $td Row standard cell content + * @return string + */ + private function addRow($th, $td = ' ') + { + $th = htmlspecialchars($th, ENT_NOQUOTES, 'UTF-8'); + $td = '
    '.htmlspecialchars($td, ENT_NOQUOTES, 'UTF-8').'
    '; + + return "\n$th:\n".$td."\n"; + } + + /** + * Create a HTML h1 tag + * + * @param string $title Text to be in the h1 + * @param integer $level Error level + * @return string + */ + private function addTitle($title, $level) + { + $title = htmlspecialchars($title, ENT_NOQUOTES, 'UTF-8'); + + return '

    '.$title.'

    '; + } + /** + * Formats a log record. + * + * @param array $record A record to format + * @return mixed The formatted record + */ + public function format(array $record) + { + $output = $this->addTitle($record['level_name'], $record['level']); + $output .= ''; + + $output .= $this->addRow('Message', (string) $record['message']); + $output .= $this->addRow('Time', $record['datetime']->format('Y-m-d\TH:i:s.uO')); + $output .= $this->addRow('Channel', $record['channel']); + if ($record['context']) { + $output .= $this->addRow('Context', $this->convertToString($record['context'])); + } + if ($record['extra']) { + $output .= $this->addRow('Extra', $this->convertToString($record['extra'])); + } + + return $output.'
    '; + } + + /** + * Formats a set of log records. + * + * @param array $records A set of records to format + * @return mixed The formatted set of records + */ + public function formatBatch(array $records) + { + $message = ''; + foreach ($records as $record) { + $message .= $this->format($record); + } + + return $message; + } + + protected function convertToString($data) + { + if (null === $data || is_scalar($data)) { + return (string) $data; + } + + $data = $this->normalize($data); + if (version_compare(PHP_VERSION, '5.4.0', '>=')) { + return json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE); + } + + return str_replace('\\/', '/', json_encode($data)); + } +} diff --git a/vendor/monolog/monolog/src/Monolog/Formatter/JsonFormatter.php b/vendor/monolog/monolog/src/Monolog/Formatter/JsonFormatter.php new file mode 100755 index 0000000..ac6f58c --- /dev/null +++ b/vendor/monolog/monolog/src/Monolog/Formatter/JsonFormatter.php @@ -0,0 +1,116 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Formatter; + +/** + * Encodes whatever record data is passed to it as json + * + * This can be useful to log to databases or remote APIs + * + * @author Jordi Boggiano + */ +class JsonFormatter implements FormatterInterface +{ + protected $batchMode; + protected $appendNewline; + + const BATCH_MODE_JSON = 1; + const BATCH_MODE_NEWLINES = 2; + + /** + * @param int $batchMode + */ + public function __construct($batchMode = self::BATCH_MODE_JSON, $appendNewline = true) + { + $this->batchMode = $batchMode; + $this->appendNewline = $appendNewline; + } + + /** + * The batch mode option configures the formatting style for + * multiple records. By default, multiple records will be + * formatted as a JSON-encoded array. However, for + * compatibility with some API endpoints, alternive styles + * are available. + * + * @return int + */ + public function getBatchMode() + { + return $this->batchMode; + } + + /** + * True if newlines are appended to every formatted record + * + * @return bool + */ + public function isAppendingNewlines() + { + return $this->appendNewline; + } + + /** + * {@inheritdoc} + */ + public function format(array $record) + { + return json_encode($record) . ($this->appendNewline ? "\n" : ''); + } + + /** + * {@inheritdoc} + */ + public function formatBatch(array $records) + { + switch ($this->batchMode) { + case static::BATCH_MODE_NEWLINES: + return $this->formatBatchNewlines($records); + + case static::BATCH_MODE_JSON: + default: + return $this->formatBatchJson($records); + } + } + + /** + * Return a JSON-encoded array of records. + * + * @param array $records + * @return string + */ + protected function formatBatchJson(array $records) + { + return json_encode($records); + } + + /** + * Use new lines to separate records instead of a + * JSON-encoded array. + * + * @param array $records + * @return string + */ + protected function formatBatchNewlines(array $records) + { + $instance = $this; + + $oldNewline = $this->appendNewline; + $this->appendNewline = false; + array_walk($records, function (&$value, $key) use ($instance) { + $value = $instance->format($value); + }); + $this->appendNewline = $oldNewline; + + return implode("\n", $records); + } +} diff --git a/vendor/monolog/monolog/src/Monolog/Formatter/LineFormatter.php b/vendor/monolog/monolog/src/Monolog/Formatter/LineFormatter.php new file mode 100755 index 0000000..9ef0a64 --- /dev/null +++ b/vendor/monolog/monolog/src/Monolog/Formatter/LineFormatter.php @@ -0,0 +1,113 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Formatter; + +use Exception; + +/** + * Formats incoming records into a one-line string + * + * This is especially useful for logging to files + * + * @author Jordi Boggiano + * @author Christophe Coevoet + */ +class LineFormatter extends NormalizerFormatter +{ + const SIMPLE_FORMAT = "[%datetime%] %channel%.%level_name%: %message% %context% %extra%\n"; + + protected $format; + protected $allowInlineLineBreaks; + + /** + * @param string $format The format of the message + * @param string $dateFormat The format of the timestamp: one supported by DateTime::format + * @param bool $allowInlineLineBreaks Whether to allow inline line breaks in log entries + */ + public function __construct($format = null, $dateFormat = null, $allowInlineLineBreaks = false) + { + $this->format = $format ?: static::SIMPLE_FORMAT; + $this->allowInlineLineBreaks = $allowInlineLineBreaks; + parent::__construct($dateFormat); + } + + /** + * {@inheritdoc} + */ + public function format(array $record) + { + $vars = parent::format($record); + + $output = $this->format; + foreach ($vars['extra'] as $var => $val) { + if (false !== strpos($output, '%extra.'.$var.'%')) { + $output = str_replace('%extra.'.$var.'%', $this->replaceNewlines($this->convertToString($val)), $output); + unset($vars['extra'][$var]); + } + } + foreach ($vars as $var => $val) { + if (false !== strpos($output, '%'.$var.'%')) { + $output = str_replace('%'.$var.'%', $this->replaceNewlines($this->convertToString($val)), $output); + } + } + + return $output; + } + + public function formatBatch(array $records) + { + $message = ''; + foreach ($records as $record) { + $message .= $this->format($record); + } + + return $message; + } + + protected function normalizeException(Exception $e) + { + $previousText = ''; + if ($previous = $e->getPrevious()) { + do { + $previousText .= ', '.get_class($previous).': '.$previous->getMessage().' at '.$previous->getFile().':'.$previous->getLine(); + } while ($previous = $previous->getPrevious()); + } + + return '[object] ('.get_class($e).': '.$e->getMessage().' at '.$e->getFile().':'.$e->getLine().$previousText.')'; + } + + protected function convertToString($data) + { + if (null === $data || is_bool($data)) { + return var_export($data, true); + } + + if (is_scalar($data)) { + return (string) $data; + } + + if (version_compare(PHP_VERSION, '5.4.0', '>=')) { + return $this->toJson($data, true); + } + + return str_replace('\\/', '/', @json_encode($data)); + } + + protected function replaceNewlines($str) + { + if ($this->allowInlineLineBreaks) { + return $str; + } + + return preg_replace('{[\r\n]+}', ' ', $str); + } +} diff --git a/vendor/monolog/monolog/src/Monolog/Formatter/LogglyFormatter.php b/vendor/monolog/monolog/src/Monolog/Formatter/LogglyFormatter.php new file mode 100755 index 0000000..5ef0d9f --- /dev/null +++ b/vendor/monolog/monolog/src/Monolog/Formatter/LogglyFormatter.php @@ -0,0 +1,47 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Formatter; + +/** + * Encodes message information into JSON in a format compatible with Loggly. + * + * @author Adam Pancutt + */ +class LogglyFormatter extends JsonFormatter +{ + /** + * Overrides the default batch mode to new lines for compatibility with the + * Loggly bulk API. + * + * @param integer $batchMode + */ + public function __construct($batchMode = self::BATCH_MODE_NEWLINES, $appendNewline = false) + { + parent::__construct($batchMode, $appendNewline); + } + + /** + * Appends the 'timestamp' parameter for indexing by Loggly. + * + * @see https://www.loggly.com/docs/automated-parsing/#json + * @see \Monolog\Formatter\JsonFormatter::format() + */ + public function format(array $record) + { + if (isset($record["datetime"]) && ($record["datetime"] instanceof \DateTime)) { + $record["timestamp"] = $record["datetime"]->format("c"); + // TODO 2.0 unset the 'datetime' parameter, retained for BC + } + + return parent::format($record); + } +} diff --git a/vendor/monolog/monolog/src/Monolog/Formatter/LogstashFormatter.php b/vendor/monolog/monolog/src/Monolog/Formatter/LogstashFormatter.php new file mode 100755 index 0000000..7a7b3b3 --- /dev/null +++ b/vendor/monolog/monolog/src/Monolog/Formatter/LogstashFormatter.php @@ -0,0 +1,165 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Formatter; + +/** + * Serializes a log message to Logstash Event Format + * + * @see http://logstash.net/ + * @see https://github.com/logstash/logstash/blob/master/lib/logstash/event.rb + * + * @author Tim Mower + */ +class LogstashFormatter extends NormalizerFormatter +{ + const V0 = 0; + const V1 = 1; + + /** + * @var string the name of the system for the Logstash log message, used to fill the @source field + */ + protected $systemName; + + /** + * @var string an application name for the Logstash log message, used to fill the @type field + */ + protected $applicationName; + + /** + * @var string a prefix for 'extra' fields from the Monolog record (optional) + */ + protected $extraPrefix; + + /** + * @var string a prefix for 'context' fields from the Monolog record (optional) + */ + protected $contextPrefix; + + /** + * @var integer logstash format version to use + */ + protected $version; + + /** + * @param string $applicationName the application that sends the data, used as the "type" field of logstash + * @param string $systemName the system/machine name, used as the "source" field of logstash, defaults to the hostname of the machine + * @param string $extraPrefix prefix for extra keys inside logstash "fields" + * @param string $contextPrefix prefix for context keys inside logstash "fields", defaults to ctxt_ + */ + public function __construct($applicationName, $systemName = null, $extraPrefix = null, $contextPrefix = 'ctxt_', $version = self::V0) + { + // logstash requires a ISO 8601 format date with optional millisecond precision. + parent::__construct('Y-m-d\TH:i:s.uP'); + + $this->systemName = $systemName ?: gethostname(); + $this->applicationName = $applicationName; + $this->extraPrefix = $extraPrefix; + $this->contextPrefix = $contextPrefix; + $this->version = $version; + } + + /** + * {@inheritdoc} + */ + public function format(array $record) + { + $record = parent::format($record); + + if ($this->version === self::V1) { + $message = $this->formatV1($record); + } else { + $message = $this->formatV0($record); + } + + return $this->toJson($message) . "\n"; + } + + protected function formatV0(array $record) + { + if (empty($record['datetime'])) { + $record['datetime'] = gmdate('c'); + } + $message = array( + '@timestamp' => $record['datetime'], + '@source' => $this->systemName, + '@fields' => array() + ); + if (isset($record['message'])) { + $message['@message'] = $record['message']; + } + if (isset($record['channel'])) { + $message['@tags'] = array($record['channel']); + $message['@fields']['channel'] = $record['channel']; + } + if (isset($record['level'])) { + $message['@fields']['level'] = $record['level']; + } + if ($this->applicationName) { + $message['@type'] = $this->applicationName; + } + if (isset($record['extra']['server'])) { + $message['@source_host'] = $record['extra']['server']; + } + if (isset($record['extra']['url'])) { + $message['@source_path'] = $record['extra']['url']; + } + if (!empty($record['extra'])) { + foreach ($record['extra'] as $key => $val) { + $message['@fields'][$this->extraPrefix . $key] = $val; + } + } + if (!empty($record['context'])) { + foreach ($record['context'] as $key => $val) { + $message['@fields'][$this->contextPrefix . $key] = $val; + } + } + + return $message; + } + + protected function formatV1(array $record) + { + if (empty($record['datetime'])) { + $record['datetime'] = gmdate('c'); + } + $message = array( + '@timestamp' => $record['datetime'], + '@version' => 1, + 'host' => $this->systemName, + ); + if (isset($record['message'])) { + $message['message'] = $record['message']; + } + if (isset($record['channel'])) { + $message['type'] = $record['channel']; + $message['channel'] = $record['channel']; + } + if (isset($record['level_name'])) { + $message['level'] = $record['level_name']; + } + if ($this->applicationName) { + $message['type'] = $this->applicationName; + } + if (!empty($record['extra'])) { + foreach ($record['extra'] as $key => $val) { + $message[$this->extraPrefix . $key] = $val; + } + } + if (!empty($record['context'])) { + foreach ($record['context'] as $key => $val) { + $message[$this->contextPrefix . $key] = $val; + } + } + + return $message; + } +} diff --git a/vendor/monolog/monolog/src/Monolog/Formatter/NormalizerFormatter.php b/vendor/monolog/monolog/src/Monolog/Formatter/NormalizerFormatter.php new file mode 100755 index 0000000..dfa3cb9 --- /dev/null +++ b/vendor/monolog/monolog/src/Monolog/Formatter/NormalizerFormatter.php @@ -0,0 +1,136 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Formatter; + +use Exception; + +/** + * Normalizes incoming records to remove objects/resources so it's easier to dump to various targets + * + * @author Jordi Boggiano + */ +class NormalizerFormatter implements FormatterInterface +{ + const SIMPLE_DATE = "Y-m-d H:i:s"; + + protected $dateFormat; + + /** + * @param string $dateFormat The format of the timestamp: one supported by DateTime::format + */ + public function __construct($dateFormat = null) + { + $this->dateFormat = $dateFormat ?: static::SIMPLE_DATE; + } + + /** + * {@inheritdoc} + */ + public function format(array $record) + { + return $this->normalize($record); + } + + /** + * {@inheritdoc} + */ + public function formatBatch(array $records) + { + foreach ($records as $key => $record) { + $records[$key] = $this->format($record); + } + + return $records; + } + + protected function normalize($data) + { + if (null === $data || is_scalar($data)) { + return $data; + } + + if (is_array($data) || $data instanceof \Traversable) { + $normalized = array(); + + $count = 1; + foreach ($data as $key => $value) { + if ($count++ >= 1000) { + $normalized['...'] = 'Over 1000 items, aborting normalization'; + break; + } + $normalized[$key] = $this->normalize($value); + } + + return $normalized; + } + + if ($data instanceof \DateTime) { + return $data->format($this->dateFormat); + } + + if (is_object($data)) { + if ($data instanceof Exception) { + return $this->normalizeException($data); + } + + return sprintf("[object] (%s: %s)", get_class($data), $this->toJson($data, true)); + } + + if (is_resource($data)) { + return '[resource]'; + } + + return '[unknown('.gettype($data).')]'; + } + + protected function normalizeException(Exception $e) + { + $data = array( + 'class' => get_class($e), + 'message' => $e->getMessage(), + 'file' => $e->getFile().':'.$e->getLine(), + ); + + $trace = $e->getTrace(); + foreach ($trace as $frame) { + if (isset($frame['file'])) { + $data['trace'][] = $frame['file'].':'.$frame['line']; + } else { + $data['trace'][] = json_encode($frame); + } + } + + if ($previous = $e->getPrevious()) { + $data['previous'] = $this->normalizeException($previous); + } + + return $data; + } + + protected function toJson($data, $ignoreErrors = false) + { + // suppress json_encode errors since it's twitchy with some inputs + if ($ignoreErrors) { + if (version_compare(PHP_VERSION, '5.4.0', '>=')) { + return @json_encode($data, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE); + } + + return @json_encode($data); + } + + if (version_compare(PHP_VERSION, '5.4.0', '>=')) { + return json_encode($data, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE); + } + + return json_encode($data); + } +} diff --git a/vendor/monolog/monolog/src/Monolog/Formatter/ScalarFormatter.php b/vendor/monolog/monolog/src/Monolog/Formatter/ScalarFormatter.php new file mode 100755 index 0000000..5d345d5 --- /dev/null +++ b/vendor/monolog/monolog/src/Monolog/Formatter/ScalarFormatter.php @@ -0,0 +1,48 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Formatter; + +/** + * Formats data into an associative array of scalar values. + * Objects and arrays will be JSON encoded. + * + * @author Andrew Lawson + */ +class ScalarFormatter extends NormalizerFormatter +{ + /** + * {@inheritdoc} + */ + public function format(array $record) + { + foreach ($record as $key => $value) { + $record[$key] = $this->normalizeValue($value); + } + + return $record; + } + + /** + * @param mixed $value + * @return mixed + */ + protected function normalizeValue($value) + { + $normalized = $this->normalize($value); + + if (is_array($normalized) || is_object($normalized)) { + return $this->toJson($normalized, true); + } + + return $normalized; + } +} diff --git a/vendor/monolog/monolog/src/Monolog/Formatter/WildfireFormatter.php b/vendor/monolog/monolog/src/Monolog/Formatter/WildfireFormatter.php new file mode 100755 index 0000000..654710a --- /dev/null +++ b/vendor/monolog/monolog/src/Monolog/Formatter/WildfireFormatter.php @@ -0,0 +1,113 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Formatter; + +use Monolog\Logger; + +/** + * Serializes a log message according to Wildfire's header requirements + * + * @author Eric Clemmons (@ericclemmons) + * @author Christophe Coevoet + * @author Kirill chEbba Chebunin + */ +class WildfireFormatter extends NormalizerFormatter +{ + const TABLE = 'table'; + + /** + * Translates Monolog log levels to Wildfire levels. + */ + private $logLevels = array( + Logger::DEBUG => 'LOG', + Logger::INFO => 'INFO', + Logger::NOTICE => 'INFO', + Logger::WARNING => 'WARN', + Logger::ERROR => 'ERROR', + Logger::CRITICAL => 'ERROR', + Logger::ALERT => 'ERROR', + Logger::EMERGENCY => 'ERROR', + ); + + /** + * {@inheritdoc} + */ + public function format(array $record) + { + // Retrieve the line and file if set and remove them from the formatted extra + $file = $line = ''; + if (isset($record['extra']['file'])) { + $file = $record['extra']['file']; + unset($record['extra']['file']); + } + if (isset($record['extra']['line'])) { + $line = $record['extra']['line']; + unset($record['extra']['line']); + } + + $record = $this->normalize($record); + $message = array('message' => $record['message']); + $handleError = false; + if ($record['context']) { + $message['context'] = $record['context']; + $handleError = true; + } + if ($record['extra']) { + $message['extra'] = $record['extra']; + $handleError = true; + } + if (count($message) === 1) { + $message = reset($message); + } + + if (isset($record['context'][self::TABLE])) { + $type = 'TABLE'; + $label = $record['channel'] .': '. $record['message']; + $message = $record['context'][self::TABLE]; + } else { + $type = $this->logLevels[$record['level']]; + $label = $record['channel']; + } + + // Create JSON object describing the appearance of the message in the console + $json = $this->toJson(array( + array( + 'Type' => $type, + 'File' => $file, + 'Line' => $line, + 'Label' => $label, + ), + $message, + ), $handleError); + + // The message itself is a serialization of the above JSON object + it's length + return sprintf( + '%s|%s|', + strlen($json), + $json + ); + } + + public function formatBatch(array $records) + { + throw new \BadMethodCallException('Batch formatting does not make sense for the WildfireFormatter'); + } + + protected function normalize($data) + { + if (is_object($data) && !$data instanceof \DateTime) { + return $data; + } + + return parent::normalize($data); + } +} diff --git a/vendor/monolog/monolog/src/Monolog/Handler/AbstractHandler.php b/vendor/monolog/monolog/src/Monolog/Handler/AbstractHandler.php new file mode 100755 index 0000000..3bb21b7 --- /dev/null +++ b/vendor/monolog/monolog/src/Monolog/Handler/AbstractHandler.php @@ -0,0 +1,184 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Handler; + +use Monolog\Logger; +use Monolog\Formatter\FormatterInterface; +use Monolog\Formatter\LineFormatter; + +/** + * Base Handler class providing the Handler structure + * + * @author Jordi Boggiano + */ +abstract class AbstractHandler implements HandlerInterface +{ + protected $level = Logger::DEBUG; + protected $bubble = true; + + /** + * @var FormatterInterface + */ + protected $formatter; + protected $processors = array(); + + /** + * @param integer $level The minimum logging level at which this handler will be triggered + * @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not + */ + public function __construct($level = Logger::DEBUG, $bubble = true) + { + $this->level = $level; + $this->bubble = $bubble; + } + + /** + * {@inheritdoc} + */ + public function isHandling(array $record) + { + return $record['level'] >= $this->level; + } + + /** + * {@inheritdoc} + */ + public function handleBatch(array $records) + { + foreach ($records as $record) { + $this->handle($record); + } + } + + /** + * Closes the handler. + * + * This will be called automatically when the object is destroyed + */ + public function close() + { + } + + /** + * {@inheritdoc} + */ + public function pushProcessor($callback) + { + if (!is_callable($callback)) { + throw new \InvalidArgumentException('Processors must be valid callables (callback or object with an __invoke method), '.var_export($callback, true).' given'); + } + array_unshift($this->processors, $callback); + + return $this; + } + + /** + * {@inheritdoc} + */ + public function popProcessor() + { + if (!$this->processors) { + throw new \LogicException('You tried to pop from an empty processor stack.'); + } + + return array_shift($this->processors); + } + + /** + * {@inheritdoc} + */ + public function setFormatter(FormatterInterface $formatter) + { + $this->formatter = $formatter; + + return $this; + } + + /** + * {@inheritdoc} + */ + public function getFormatter() + { + if (!$this->formatter) { + $this->formatter = $this->getDefaultFormatter(); + } + + return $this->formatter; + } + + /** + * Sets minimum logging level at which this handler will be triggered. + * + * @param integer $level + * @return self + */ + public function setLevel($level) + { + $this->level = $level; + + return $this; + } + + /** + * Gets minimum logging level at which this handler will be triggered. + * + * @return integer + */ + public function getLevel() + { + return $this->level; + } + + /** + * Sets the bubbling behavior. + * + * @param Boolean $bubble true means that this handler allows bubbling. + * false means that bubbling is not permitted. + * @return self + */ + public function setBubble($bubble) + { + $this->bubble = $bubble; + + return $this; + } + + /** + * Gets the bubbling behavior. + * + * @return Boolean true means that this handler allows bubbling. + * false means that bubbling is not permitted. + */ + public function getBubble() + { + return $this->bubble; + } + + public function __destruct() + { + try { + $this->close(); + } catch (\Exception $e) { + // do nothing + } + } + + /** + * Gets the default formatter. + * + * @return FormatterInterface + */ + protected function getDefaultFormatter() + { + return new LineFormatter(); + } +} diff --git a/vendor/monolog/monolog/src/Monolog/Handler/AbstractProcessingHandler.php b/vendor/monolog/monolog/src/Monolog/Handler/AbstractProcessingHandler.php new file mode 100755 index 0000000..6f18f72 --- /dev/null +++ b/vendor/monolog/monolog/src/Monolog/Handler/AbstractProcessingHandler.php @@ -0,0 +1,66 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Handler; + +/** + * Base Handler class providing the Handler structure + * + * Classes extending it should (in most cases) only implement write($record) + * + * @author Jordi Boggiano + * @author Christophe Coevoet + */ +abstract class AbstractProcessingHandler extends AbstractHandler +{ + /** + * {@inheritdoc} + */ + public function handle(array $record) + { + if (!$this->isHandling($record)) { + return false; + } + + $record = $this->processRecord($record); + + $record['formatted'] = $this->getFormatter()->format($record); + + $this->write($record); + + return false === $this->bubble; + } + + /** + * Writes the record down to the log of the implementing handler + * + * @param array $record + * @return void + */ + abstract protected function write(array $record); + + /** + * Processes a record. + * + * @param array $record + * @return array + */ + protected function processRecord(array $record) + { + if ($this->processors) { + foreach ($this->processors as $processor) { + $record = call_user_func($processor, $record); + } + } + + return $record; + } +} diff --git a/vendor/monolog/monolog/src/Monolog/Handler/AbstractSyslogHandler.php b/vendor/monolog/monolog/src/Monolog/Handler/AbstractSyslogHandler.php new file mode 100755 index 0000000..3eb83bd --- /dev/null +++ b/vendor/monolog/monolog/src/Monolog/Handler/AbstractSyslogHandler.php @@ -0,0 +1,92 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Handler; + +use Monolog\Logger; +use Monolog\Formatter\LineFormatter; + +/** + * Common syslog functionality + */ +abstract class AbstractSyslogHandler extends AbstractProcessingHandler +{ + protected $facility; + + /** + * Translates Monolog log levels to syslog log priorities. + */ + protected $logLevels = array( + Logger::DEBUG => LOG_DEBUG, + Logger::INFO => LOG_INFO, + Logger::NOTICE => LOG_NOTICE, + Logger::WARNING => LOG_WARNING, + Logger::ERROR => LOG_ERR, + Logger::CRITICAL => LOG_CRIT, + Logger::ALERT => LOG_ALERT, + Logger::EMERGENCY => LOG_EMERG, + ); + + /** + * List of valid log facility names. + */ + protected $facilities = array( + 'auth' => LOG_AUTH, + 'authpriv' => LOG_AUTHPRIV, + 'cron' => LOG_CRON, + 'daemon' => LOG_DAEMON, + 'kern' => LOG_KERN, + 'lpr' => LOG_LPR, + 'mail' => LOG_MAIL, + 'news' => LOG_NEWS, + 'syslog' => LOG_SYSLOG, + 'user' => LOG_USER, + 'uucp' => LOG_UUCP, + ); + + /** + * @param mixed $facility + * @param integer $level The minimum logging level at which this handler will be triggered + * @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not + */ + public function __construct($facility = LOG_USER, $level = Logger::DEBUG, $bubble = true) + { + parent::__construct($level, $bubble); + + if (!defined('PHP_WINDOWS_VERSION_BUILD')) { + $this->facilities['local0'] = LOG_LOCAL0; + $this->facilities['local1'] = LOG_LOCAL1; + $this->facilities['local2'] = LOG_LOCAL2; + $this->facilities['local3'] = LOG_LOCAL3; + $this->facilities['local4'] = LOG_LOCAL4; + $this->facilities['local5'] = LOG_LOCAL5; + $this->facilities['local6'] = LOG_LOCAL6; + $this->facilities['local7'] = LOG_LOCAL7; + } + + // convert textual description of facility to syslog constant + if (array_key_exists(strtolower($facility), $this->facilities)) { + $facility = $this->facilities[strtolower($facility)]; + } elseif (!in_array($facility, array_values($this->facilities), true)) { + throw new \UnexpectedValueException('Unknown facility value "'.$facility.'" given'); + } + + $this->facility = $facility; + } + + /** + * {@inheritdoc} + */ + protected function getDefaultFormatter() + { + return new LineFormatter('%channel%.%level_name%: %message% %context% %extra%'); + } +} diff --git a/vendor/monolog/monolog/src/Monolog/Handler/AmqpHandler.php b/vendor/monolog/monolog/src/Monolog/Handler/AmqpHandler.php new file mode 100755 index 0000000..2db0d08 --- /dev/null +++ b/vendor/monolog/monolog/src/Monolog/Handler/AmqpHandler.php @@ -0,0 +1,69 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Handler; + +use Monolog\Logger; +use Monolog\Formatter\JsonFormatter; + +class AmqpHandler extends AbstractProcessingHandler +{ + /** + * @var \AMQPExchange $exchange + */ + protected $exchange; + + /** + * @param \AMQPExchange $exchange AMQP exchange, ready for use + * @param string $exchangeName + * @param int $level + * @param bool $bubble Whether the messages that are handled can bubble up the stack or not + */ + public function __construct(\AMQPExchange $exchange, $exchangeName = 'log', $level = Logger::DEBUG, $bubble = true) + { + $this->exchange = $exchange; + $this->exchange->setName($exchangeName); + + parent::__construct($level, $bubble); + } + + /** + * {@inheritDoc} + */ + protected function write(array $record) + { + $data = $record["formatted"]; + + $routingKey = sprintf( + '%s.%s', + substr($record['level_name'], 0, 4), + $record['channel'] + ); + + $this->exchange->publish( + $data, + strtolower($routingKey), + 0, + array( + 'delivery_mode' => 2, + 'Content-type' => 'application/json' + ) + ); + } + + /** + * {@inheritDoc} + */ + protected function getDefaultFormatter() + { + return new JsonFormatter(JsonFormatter::BATCH_MODE_JSON, false); + } +} diff --git a/vendor/monolog/monolog/src/Monolog/Handler/BrowserConsoleHandler.php b/vendor/monolog/monolog/src/Monolog/Handler/BrowserConsoleHandler.php new file mode 100755 index 0000000..43190b9 --- /dev/null +++ b/vendor/monolog/monolog/src/Monolog/Handler/BrowserConsoleHandler.php @@ -0,0 +1,184 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Handler; + +use Monolog\Formatter\LineFormatter; + +/** + * Handler sending logs to browser's javascript console with no browser extension required + * + * @author Olivier Poitrey + */ +class BrowserConsoleHandler extends AbstractProcessingHandler +{ + protected static $initialized = false; + protected static $records = array(); + + /** + * {@inheritDoc} + * + * Formatted output may contain some formatting markers to be transfered to `console.log` using the %c format. + * + * Example of formatted string: + * + * You can do [[blue text]]{color: blue} or [[green background]]{background-color: green; color: white} + * + */ + protected function getDefaultFormatter() + { + return new LineFormatter('[[%channel%]]{macro: autolabel} [[%level_name%]]{font-weight: bold} %message%'); + } + + /** + * {@inheritDoc} + */ + protected function write(array $record) + { + // Accumulate records + self::$records[] = $record; + + // Register shutdown handler if not already done + if (PHP_SAPI !== 'cli' && !self::$initialized) { + self::$initialized = true; + register_shutdown_function(array('Monolog\Handler\BrowserConsoleHandler', 'send')); + } + } + + /** + * Convert records to javascript console commands and send it to the browser. + * This method is automatically called on PHP shutdown if output is HTML. + */ + public static function send() + { + // Check content type + foreach (headers_list() as $header) { + if (stripos($header, 'content-type:') === 0) { + if (stripos($header, 'text/html') === false) { + // This handler only works with HTML outputs + return; + } + break; + } + } + + if (count(self::$records)) { + echo ''; + self::reset(); + } + } + + /** + * Forget all logged records + */ + public static function reset() + { + self::$records = array(); + } + + private static function generateScript() + { + $script = array(); + foreach (self::$records as $record) { + $context = self::dump('Context', $record['context']); + $extra = self::dump('Extra', $record['extra']); + + if (empty($context) && empty($extra)) { + $script[] = self::call_array('log', self::handleStyles($record['formatted'])); + } else { + $script = array_merge($script, + array(self::call_array('groupCollapsed', self::handleStyles($record['formatted']))), + $context, + $extra, + array(self::call('groupEnd')) + ); + } + } + + return "(function (c) {if (c && c.groupCollapsed) {\n" . implode("\n", $script) . "\n}})(console);"; + } + + private static function handleStyles($formatted) + { + $args = array(self::quote('font-weight: normal')); + $format = '%c' . $formatted; + preg_match_all('/\[\[(.*?)\]\]\{([^}]*)\}/s', $format, $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER); + + foreach (array_reverse($matches) as $match) { + $args[] = self::quote(self::handleCustomStyles($match[2][0], $match[1][0])); + $args[] = '"font-weight: normal"'; + + $pos = $match[0][1]; + $format = substr($format, 0, $pos) . '%c' . $match[1][0] . '%c' . substr($format, $pos + strlen($match[0][0])); + } + + array_unshift($args, self::quote($format)); + + return $args; + } + + private static function handleCustomStyles($style, $string) + { + static $colors = array('blue', 'green', 'red', 'magenta', 'orange', 'black', 'grey'); + static $labels = array(); + + return preg_replace_callback('/macro\s*:(.*?)(?:;|$)/', function ($m) use ($string, &$colors, &$labels) { + if (trim($m[1]) === 'autolabel') { + // Format the string as a label with consistent auto assigned background color + if (!isset($labels[$string])) { + $labels[$string] = $colors[count($labels) % count($colors)]; + } + $color = $labels[$string]; + + return "background-color: $color; color: white; border-radius: 3px; padding: 0 2px 0 2px"; + } + + return $m[1]; + }, $style); + } + + private static function dump($title, array $dict) + { + $script = array(); + $dict = array_filter($dict); + if (empty($dict)) { + return $script; + } + $script[] = self::call('log', self::quote('%c%s'), self::quote('font-weight: bold'), self::quote($title)); + foreach ($dict as $key => $value) { + $value = json_encode($value); + if (empty($value)) { + $value = self::quote(''); + } + $script[] = self::call('log', self::quote('%s: %o'), self::quote($key), $value); + } + + return $script; + } + + private static function quote($arg) + { + return '"' . addcslashes($arg, "\"\n") . '"'; + } + + private static function call() + { + $args = func_get_args(); + $method = array_shift($args); + + return self::call_array($method, $args); + } + + private static function call_array($method, array $args) + { + return 'c.' . $method . '(' . implode(', ', $args) . ');'; + } +} diff --git a/vendor/monolog/monolog/src/Monolog/Handler/BufferHandler.php b/vendor/monolog/monolog/src/Monolog/Handler/BufferHandler.php new file mode 100755 index 0000000..183d239 --- /dev/null +++ b/vendor/monolog/monolog/src/Monolog/Handler/BufferHandler.php @@ -0,0 +1,102 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Handler; + +use Monolog\Logger; + +/** + * Buffers all records until closing the handler and then pass them as batch. + * + * This is useful for a MailHandler to send only one mail per request instead of + * sending one per log message. + * + * @author Christophe Coevoet + */ +class BufferHandler extends AbstractHandler +{ + protected $handler; + protected $bufferSize = 0; + protected $bufferLimit; + protected $flushOnOverflow; + protected $buffer = array(); + protected $initialized = false; + + /** + * @param HandlerInterface $handler Handler. + * @param integer $bufferLimit How many entries should be buffered at most, beyond that the oldest items are removed from the buffer. + * @param integer $level The minimum logging level at which this handler will be triggered + * @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not + * @param Boolean $flushOnOverflow If true, the buffer is flushed when the max size has been reached, by default oldest entries are discarded + */ + public function __construct(HandlerInterface $handler, $bufferLimit = 0, $level = Logger::DEBUG, $bubble = true, $flushOnOverflow = false) + { + parent::__construct($level, $bubble); + $this->handler = $handler; + $this->bufferLimit = (int) $bufferLimit; + $this->flushOnOverflow = $flushOnOverflow; + } + + /** + * {@inheritdoc} + */ + public function handle(array $record) + { + if ($record['level'] < $this->level) { + return false; + } + + if (!$this->initialized) { + // __destructor() doesn't get called on Fatal errors + register_shutdown_function(array($this, 'close')); + $this->initialized = true; + } + + if ($this->bufferLimit > 0 && $this->bufferSize === $this->bufferLimit) { + if ($this->flushOnOverflow) { + $this->flush(); + } else { + array_shift($this->buffer); + $this->bufferSize--; + } + } + + if ($this->processors) { + foreach ($this->processors as $processor) { + $record = call_user_func($processor, $record); + } + } + + $this->buffer[] = $record; + $this->bufferSize++; + + return false === $this->bubble; + } + + public function flush() + { + if ($this->bufferSize === 0) { + return; + } + + $this->handler->handleBatch($this->buffer); + $this->bufferSize = 0; + $this->buffer = array(); + } + + /** + * {@inheritdoc} + */ + public function close() + { + $this->flush(); + } +} diff --git a/vendor/monolog/monolog/src/Monolog/Handler/ChromePHPHandler.php b/vendor/monolog/monolog/src/Monolog/Handler/ChromePHPHandler.php new file mode 100755 index 0000000..ff7a780 --- /dev/null +++ b/vendor/monolog/monolog/src/Monolog/Handler/ChromePHPHandler.php @@ -0,0 +1,192 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Handler; + +use Monolog\Formatter\ChromePHPFormatter; +use Monolog\Logger; + +/** + * Handler sending logs to the ChromePHP extension (http://www.chromephp.com/) + * + * @author Christophe Coevoet + */ +class ChromePHPHandler extends AbstractProcessingHandler +{ + /** + * Version of the extension + */ + const VERSION = '4.0'; + + /** + * Header name + */ + const HEADER_NAME = 'X-ChromeLogger-Data'; + + protected static $initialized = false; + + /** + * Tracks whether we sent too much data + * + * Chrome limits the headers to 256KB, so when we sent 240KB we stop sending + * + * @var Boolean + */ + protected static $overflowed = false; + + protected static $json = array( + 'version' => self::VERSION, + 'columns' => array('label', 'log', 'backtrace', 'type'), + 'rows' => array(), + ); + + protected static $sendHeaders = true; + + /** + * {@inheritdoc} + */ + public function handleBatch(array $records) + { + $messages = array(); + + foreach ($records as $record) { + if ($record['level'] < $this->level) { + continue; + } + $messages[] = $this->processRecord($record); + } + + if (!empty($messages)) { + $messages = $this->getFormatter()->formatBatch($messages); + self::$json['rows'] = array_merge(self::$json['rows'], $messages); + $this->send(); + } + } + + /** + * {@inheritDoc} + */ + protected function getDefaultFormatter() + { + return new ChromePHPFormatter(); + } + + /** + * Creates & sends header for a record + * + * @see sendHeader() + * @see send() + * @param array $record + */ + protected function write(array $record) + { + self::$json['rows'][] = $record['formatted']; + + $this->send(); + } + + /** + * Sends the log header + * + * @see sendHeader() + */ + protected function send() + { + if (self::$overflowed || !self::$sendHeaders) { + return; + } + + if (!self::$initialized) { + self::$initialized = true; + + self::$sendHeaders = $this->headersAccepted(); + if (!self::$sendHeaders) { + return; + } + + self::$json['request_uri'] = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : ''; + } + + $json = @json_encode(self::$json); + $data = base64_encode(utf8_encode($json)); + if (strlen($data) > 240*1024) { + self::$overflowed = true; + + $record = array( + 'message' => 'Incomplete logs, chrome header size limit reached', + 'context' => array(), + 'level' => Logger::WARNING, + 'level_name' => Logger::getLevelName(Logger::WARNING), + 'channel' => 'monolog', + 'datetime' => new \DateTime(), + 'extra' => array(), + ); + self::$json['rows'][count(self::$json['rows']) - 1] = $this->getFormatter()->format($record); + $json = @json_encode(self::$json); + $data = base64_encode(utf8_encode($json)); + } + + if (trim($data) !== '') { + $this->sendHeader(self::HEADER_NAME, $data); + } + } + + /** + * Send header string to the client + * + * @param string $header + * @param string $content + */ + protected function sendHeader($header, $content) + { + if (!headers_sent() && self::$sendHeaders) { + header(sprintf('%s: %s', $header, $content)); + } + } + + /** + * Verifies if the headers are accepted by the current user agent + * + * @return Boolean + */ + protected function headersAccepted() + { + if (empty($_SERVER['HTTP_USER_AGENT'])) { + return false; + } + + return preg_match('{\bChrome/\d+[\.\d+]*\b}', $_SERVER['HTTP_USER_AGENT']); + } + + /** + * BC getter for the sendHeaders property that has been made static + */ + public function __get($property) + { + if ('sendHeaders' !== $property) { + throw new \InvalidArgumentException('Undefined property '.$property); + } + + return static::$sendHeaders; + } + + /** + * BC setter for the sendHeaders property that has been made static + */ + public function __set($property, $value) + { + if ('sendHeaders' !== $property) { + throw new \InvalidArgumentException('Undefined property '.$property); + } + + static::$sendHeaders = $value; + } +} diff --git a/vendor/monolog/monolog/src/Monolog/Handler/CouchDBHandler.php b/vendor/monolog/monolog/src/Monolog/Handler/CouchDBHandler.php new file mode 100755 index 0000000..b3687c3 --- /dev/null +++ b/vendor/monolog/monolog/src/Monolog/Handler/CouchDBHandler.php @@ -0,0 +1,72 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Handler; + +use Monolog\Formatter\JsonFormatter; +use Monolog\Logger; + +/** + * CouchDB handler + * + * @author Markus Bachmann + */ +class CouchDBHandler extends AbstractProcessingHandler +{ + private $options; + + public function __construct(array $options = array(), $level = Logger::DEBUG, $bubble = true) + { + $this->options = array_merge(array( + 'host' => 'localhost', + 'port' => 5984, + 'dbname' => 'logger', + 'username' => null, + 'password' => null, + ), $options); + + parent::__construct($level, $bubble); + } + + /** + * {@inheritDoc} + */ + protected function write(array $record) + { + $basicAuth = null; + if ($this->options['username']) { + $basicAuth = sprintf('%s:%s@', $this->options['username'], $this->options['password']); + } + + $url = 'http://'.$basicAuth.$this->options['host'].':'.$this->options['port'].'/'.$this->options['dbname']; + $context = stream_context_create(array( + 'http' => array( + 'method' => 'POST', + 'content' => $record['formatted'], + 'ignore_errors' => true, + 'max_redirects' => 0, + 'header' => 'Content-type: application/json', + ) + )); + + if (false === @file_get_contents($url, null, $context)) { + throw new \RuntimeException(sprintf('Could not connect to %s', $url)); + } + } + + /** + * {@inheritDoc} + */ + protected function getDefaultFormatter() + { + return new JsonFormatter(JsonFormatter::BATCH_MODE_JSON, false); + } +} diff --git a/vendor/monolog/monolog/src/Monolog/Handler/CubeHandler.php b/vendor/monolog/monolog/src/Monolog/Handler/CubeHandler.php new file mode 100755 index 0000000..d968720 --- /dev/null +++ b/vendor/monolog/monolog/src/Monolog/Handler/CubeHandler.php @@ -0,0 +1,145 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Handler; + +use Monolog\Logger; + +/** + * Logs to Cube. + * + * @link http://square.github.com/cube/ + * @author Wan Chen + */ +class CubeHandler extends AbstractProcessingHandler +{ + private $udpConnection = null; + private $httpConnection = null; + private $scheme = null; + private $host = null; + private $port = null; + private $acceptedSchemes = array('http', 'udp'); + + /** + * Create a Cube handler + * + * @throws UnexpectedValueException when given url is not a valid url. + * A valid url must consists of three parts : protocol://host:port + * Only valid protocol used by Cube are http and udp + */ + public function __construct($url, $level = Logger::DEBUG, $bubble = true) + { + $urlInfos = parse_url($url); + + if (!isset($urlInfos['scheme']) || !isset($urlInfos['host']) || !isset($urlInfos['port'])) { + throw new \UnexpectedValueException('URL "'.$url.'" is not valid'); + } + + if (!in_array($urlInfos['scheme'], $this->acceptedSchemes)) { + throw new \UnexpectedValueException( + 'Invalid protocol (' . $urlInfos['scheme'] . ').' + . ' Valid options are ' . implode(', ', $this->acceptedSchemes)); + } + + $this->scheme = $urlInfos['scheme']; + $this->host = $urlInfos['host']; + $this->port = $urlInfos['port']; + + parent::__construct($level, $bubble); + } + + /** + * Establish a connection to an UDP socket + * + * @throws LogicException when unable to connect to the socket + */ + protected function connectUdp() + { + if (!extension_loaded('sockets')) { + throw new MissingExtensionException('The sockets extension is required to use udp URLs with the CubeHandler'); + } + + $this->udpConnection = socket_create(AF_INET, SOCK_DGRAM, 0); + if (!$this->udpConnection) { + throw new \LogicException('Unable to create a socket'); + } + + if (!socket_connect($this->udpConnection, $this->host, $this->port)) { + throw new \LogicException('Unable to connect to the socket at ' . $this->host . ':' . $this->port); + } + } + + /** + * Establish a connection to a http server + */ + protected function connectHttp() + { + if (!extension_loaded('curl')) { + throw new \LogicException('The curl extension is needed to use http URLs with the CubeHandler'); + } + + $this->httpConnection = curl_init('http://'.$this->host.':'.$this->port.'/1.0/event/put'); + + if (!$this->httpConnection) { + throw new \LogicException('Unable to connect to ' . $this->host . ':' . $this->port); + } + + curl_setopt($this->httpConnection, CURLOPT_CUSTOMREQUEST, "POST"); + curl_setopt($this->httpConnection, CURLOPT_RETURNTRANSFER, true); + } + + /** + * {@inheritdoc} + */ + protected function write(array $record) + { + $date = $record['datetime']; + + $data = array('time' => $date->format('Y-m-d\TH:i:s.uO')); + unset($record['datetime']); + + if (isset($record['context']['type'])) { + $data['type'] = $record['context']['type']; + unset($record['context']['type']); + } else { + $data['type'] = $record['channel']; + } + + $data['data'] = $record['context']; + $data['data']['level'] = $record['level']; + + $this->{'write'.$this->scheme}(json_encode($data)); + } + + private function writeUdp($data) + { + if (!$this->udpConnection) { + $this->connectUdp(); + } + + socket_send($this->udpConnection, $data, strlen($data), 0); + } + + private function writeHttp($data) + { + if (!$this->httpConnection) { + $this->connectHttp(); + } + + curl_setopt($this->httpConnection, CURLOPT_POSTFIELDS, '['.$data.']'); + curl_setopt($this->httpConnection, CURLOPT_HTTPHEADER, array( + 'Content-Type: application/json', + 'Content-Length: ' . strlen('['.$data.']')) + ); + + return curl_exec($this->httpConnection); + } +} diff --git a/vendor/monolog/monolog/src/Monolog/Handler/DoctrineCouchDBHandler.php b/vendor/monolog/monolog/src/Monolog/Handler/DoctrineCouchDBHandler.php new file mode 100755 index 0000000..b91ffec --- /dev/null +++ b/vendor/monolog/monolog/src/Monolog/Handler/DoctrineCouchDBHandler.php @@ -0,0 +1,45 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Handler; + +use Monolog\Logger; +use Monolog\Formatter\NormalizerFormatter; +use Doctrine\CouchDB\CouchDBClient; + +/** + * CouchDB handler for Doctrine CouchDB ODM + * + * @author Markus Bachmann + */ +class DoctrineCouchDBHandler extends AbstractProcessingHandler +{ + private $client; + + public function __construct(CouchDBClient $client, $level = Logger::DEBUG, $bubble = true) + { + $this->client = $client; + parent::__construct($level, $bubble); + } + + /** + * {@inheritDoc} + */ + protected function write(array $record) + { + $this->client->postDocument($record['formatted']); + } + + protected function getDefaultFormatter() + { + return new NormalizerFormatter; + } +} diff --git a/vendor/monolog/monolog/src/Monolog/Handler/DynamoDbHandler.php b/vendor/monolog/monolog/src/Monolog/Handler/DynamoDbHandler.php new file mode 100755 index 0000000..e7f843c --- /dev/null +++ b/vendor/monolog/monolog/src/Monolog/Handler/DynamoDbHandler.php @@ -0,0 +1,89 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Handler; + +use Aws\Common\Aws; +use Aws\DynamoDb\DynamoDbClient; +use Monolog\Formatter\ScalarFormatter; +use Monolog\Logger; + +/** + * Amazon DynamoDB handler (http://aws.amazon.com/dynamodb/) + * + * @link https://github.com/aws/aws-sdk-php/ + * @author Andrew Lawson + */ +class DynamoDbHandler extends AbstractProcessingHandler +{ + const DATE_FORMAT = 'Y-m-d\TH:i:s.uO'; + + /** + * @var DynamoDbClient + */ + protected $client; + + /** + * @var string + */ + protected $table; + + /** + * @param DynamoDbClient $client + * @param string $table + * @param integer $level + * @param boolean $bubble + */ + public function __construct(DynamoDbClient $client, $table, $level = Logger::DEBUG, $bubble = true) + { + if (!defined('Aws\Common\Aws::VERSION') || version_compare('3.0', Aws::VERSION, '<=')) { + throw new \RuntimeException('The DynamoDbHandler is only known to work with the AWS SDK 2.x releases'); + } + + $this->client = $client; + $this->table = $table; + + parent::__construct($level, $bubble); + } + + /** + * {@inheritdoc} + */ + protected function write(array $record) + { + $filtered = $this->filterEmptyFields($record['formatted']); + $formatted = $this->client->formatAttributes($filtered); + + $this->client->putItem(array( + 'TableName' => $this->table, + 'Item' => $formatted + )); + } + + /** + * @param array $record + * @return array + */ + protected function filterEmptyFields(array $record) + { + return array_filter($record, function ($value) { + return !empty($value) || false === $value || 0 === $value; + }); + } + + /** + * {@inheritdoc} + */ + protected function getDefaultFormatter() + { + return new ScalarFormatter(self::DATE_FORMAT); + } +} diff --git a/vendor/monolog/monolog/src/Monolog/Handler/ElasticSearchHandler.php b/vendor/monolog/monolog/src/Monolog/Handler/ElasticSearchHandler.php new file mode 100755 index 0000000..96e5d57 --- /dev/null +++ b/vendor/monolog/monolog/src/Monolog/Handler/ElasticSearchHandler.php @@ -0,0 +1,128 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Handler; + +use Monolog\Formatter\FormatterInterface; +use Monolog\Formatter\ElasticaFormatter; +use Monolog\Logger; +use Elastica\Client; +use Elastica\Exception\ExceptionInterface; + +/** + * Elastic Search handler + * + * Usage example: + * + * $client = new \Elastica\Client(); + * $options = array( + * 'index' => 'elastic_index_name', + * 'type' => 'elastic_doc_type', + * ); + * $handler = new ElasticSearchHandler($client, $options); + * $log = new Logger('application'); + * $log->pushHandler($handler); + * + * @author Jelle Vink + */ +class ElasticSearchHandler extends AbstractProcessingHandler +{ + /** + * @var Client + */ + protected $client; + + /** + * @var array Handler config options + */ + protected $options = array(); + + /** + * @param Client $client Elastica Client object + * @param array $options Handler configuration + * @param integer $level The minimum logging level at which this handler will be triggered + * @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not + */ + public function __construct(Client $client, array $options = array(), $level = Logger::DEBUG, $bubble = true) + { + parent::__construct($level, $bubble); + $this->client = $client; + $this->options = array_merge( + array( + 'index' => 'monolog', // Elastic index name + 'type' => 'record', // Elastic document type + 'ignore_error' => false, // Suppress Elastica exceptions + ), + $options + ); + } + + /** + * {@inheritDoc} + */ + protected function write(array $record) + { + $this->bulkSend(array($record['formatted'])); + } + + /** + * {@inheritdoc} + */ + public function setFormatter(FormatterInterface $formatter) + { + if ($formatter instanceof ElasticaFormatter) { + return parent::setFormatter($formatter); + } + throw new \InvalidArgumentException('ElasticSearchHandler is only compatible with ElasticaFormatter'); + } + + /** + * Getter options + * @return array + */ + public function getOptions() + { + return $this->options; + } + + /** + * {@inheritDoc} + */ + protected function getDefaultFormatter() + { + return new ElasticaFormatter($this->options['index'], $this->options['type']); + } + + /** + * {@inheritdoc} + */ + public function handleBatch(array $records) + { + $documents = $this->getFormatter()->formatBatch($records); + $this->bulkSend($documents); + } + + /** + * Use Elasticsearch bulk API to send list of documents + * @param array $documents + * @throws \RuntimeException + */ + protected function bulkSend(array $documents) + { + try { + $this->client->addDocuments($documents); + } catch (ExceptionInterface $e) { + if (!$this->options['ignore_error']) { + throw new \RuntimeException("Error sending messages to Elasticsearch", 0, $e); + } + } + } +} diff --git a/vendor/monolog/monolog/src/Monolog/Handler/ErrorLogHandler.php b/vendor/monolog/monolog/src/Monolog/Handler/ErrorLogHandler.php new file mode 100755 index 0000000..038db4e --- /dev/null +++ b/vendor/monolog/monolog/src/Monolog/Handler/ErrorLogHandler.php @@ -0,0 +1,72 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Handler; + +use Monolog\Formatter\LineFormatter; +use Monolog\Logger; + +/** + * Stores to PHP error_log() handler. + * + * @author Elan Ruusamäe + */ +class ErrorLogHandler extends AbstractProcessingHandler +{ + const OPERATING_SYSTEM = 0; + const SAPI = 4; + + protected $messageType; + + /** + * @param integer $messageType Says where the error should go. + * @param integer $level The minimum logging level at which this handler will be triggered + * @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not + */ + public function __construct($messageType = self::OPERATING_SYSTEM, $level = Logger::DEBUG, $bubble = true) + { + parent::__construct($level, $bubble); + + if (false === in_array($messageType, self::getAvailableTypes())) { + $message = sprintf('The given message type "%s" is not supported', print_r($messageType, true)); + throw new \InvalidArgumentException($message); + } + + $this->messageType = $messageType; + } + + /** + * @return array With all available types + */ + public static function getAvailableTypes() + { + return array( + self::OPERATING_SYSTEM, + self::SAPI, + ); + } + + /** + * {@inheritDoc} + */ + protected function getDefaultFormatter() + { + return new LineFormatter('[%datetime%] %channel%.%level_name%: %message% %context% %extra%'); + } + + /** + * {@inheritdoc} + */ + protected function write(array $record) + { + error_log((string) $record['formatted'], $this->messageType); + } +} diff --git a/vendor/monolog/monolog/src/Monolog/Handler/FilterHandler.php b/vendor/monolog/monolog/src/Monolog/Handler/FilterHandler.php new file mode 100755 index 0000000..597db73 --- /dev/null +++ b/vendor/monolog/monolog/src/Monolog/Handler/FilterHandler.php @@ -0,0 +1,131 @@ + + */ +class FilterHandler extends AbstractHandler +{ + /** + * Handler or factory callable($record, $this) + * + * @var callable|\Monolog\Handler\HandlerInterface + */ + protected $handler; + + /** + * Minimum level for logs that are passes to handler + * + * @var int + */ + protected $acceptedLevels; + + /** + * Whether the messages that are handled can bubble up the stack or not + * + * @var Boolean + */ + protected $bubble; + + /** + * @param callable|HandlerInterface $handler Handler or factory callable($record, $this). + * @param int|array $minLevelOrList A list of levels to accept or a minimum level if maxLevel is provided + * @param int $maxLevel Maximum level to accept, only used if $minLevelOrList is not an array + * @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not + */ + public function __construct($handler, $minLevelOrList = Logger::DEBUG, $maxLevel = Logger::EMERGENCY, $bubble = true) + { + $this->handler = $handler; + $this->bubble = $bubble; + $this->setAcceptedLevels($minLevelOrList, $maxLevel); + } + + /** + * @return array + */ + public function getAcceptedLevels() + { + return array_flip($this->acceptedLevels); + } + + /** + * @param int|array $minLevelOrList A list of levels to accept or a minimum level if maxLevel is provided + * @param int $maxLevel Maximum level to accept, only used if $minLevelOrList is not an array + */ + public function setAcceptedLevels($minLevelOrList = Logger::DEBUG, $maxLevel = Logger::EMERGENCY) + { + if (is_array($minLevelOrList)) { + $acceptedLevels = $minLevelOrList; + } else { + $acceptedLevels = array_filter(Logger::getLevels(), function ($level) use ($minLevelOrList, $maxLevel) { + return $level >= $minLevelOrList && $level <= $maxLevel; + }); + } + $this->acceptedLevels = array_flip($acceptedLevels); + } + + /** + * {@inheritdoc} + */ + public function isHandling(array $record) + { + return isset($this->acceptedLevels[$record['level']]); + } + + /** + * {@inheritdoc} + */ + public function handle(array $record) + { + if (!$this->isHandling($record)) { + return false; + } + + // The same logic as in FingersCrossedHandler + if (!$this->handler instanceof HandlerInterface) { + if (!is_callable($this->handler)) { + throw new \RuntimeException( + "The given handler (" . json_encode($this->handler) + . ") is not a callable nor a Monolog\\Handler\\HandlerInterface object" + ); + } + $this->handler = call_user_func($this->handler, $record, $this); + if (!$this->handler instanceof HandlerInterface) { + throw new \RuntimeException("The factory callable should return a HandlerInterface"); + } + } + + if ($this->processors) { + foreach ($this->processors as $processor) { + $record = call_user_func($processor, $record); + } + } + + $this->handler->handle($record); + + return false === $this->bubble; + } + + /** + * {@inheritdoc} + */ + public function handleBatch(array $records) + { + $filtered = array(); + foreach ($records as $record) { + if ($this->isHandling($record)) { + $filtered[] = $record; + } + } + + $this->handler->handleBatch($filtered); + } +} diff --git a/vendor/monolog/monolog/src/Monolog/Handler/FingersCrossed/ActivationStrategyInterface.php b/vendor/monolog/monolog/src/Monolog/Handler/FingersCrossed/ActivationStrategyInterface.php new file mode 100755 index 0000000..c3e42ef --- /dev/null +++ b/vendor/monolog/monolog/src/Monolog/Handler/FingersCrossed/ActivationStrategyInterface.php @@ -0,0 +1,28 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Handler\FingersCrossed; + +/** + * Interface for activation strategies for the FingersCrossedHandler. + * + * @author Johannes M. Schmitt + */ +interface ActivationStrategyInterface +{ + /** + * Returns whether the given record activates the handler. + * + * @param array $record + * @return Boolean + */ + public function isHandlerActivated(array $record); +} diff --git a/vendor/monolog/monolog/src/Monolog/Handler/FingersCrossed/ChannelLevelActivationStrategy.php b/vendor/monolog/monolog/src/Monolog/Handler/FingersCrossed/ChannelLevelActivationStrategy.php new file mode 100755 index 0000000..646d57a --- /dev/null +++ b/vendor/monolog/monolog/src/Monolog/Handler/FingersCrossed/ChannelLevelActivationStrategy.php @@ -0,0 +1,57 @@ + +* +* For the full copyright and license information, please view the LICENSE +* file that was distributed with this source code. +*/ + +namespace Monolog\Handler\FingersCrossed; + +/** + * Channel and Error level based monolog activation strategy. Allows to trigger activation + * based on level per channel. e.g. trigger activation on level 'ERROR' by default, except + * for records of the 'sql' channel; those should trigger activation on level 'WARN'. + * + * Example: + * + * + * $activationStrategy = new ChannelLevelActivationStrategy( + * Logger::CRITICAL, + * array( + * 'request' => Logger::ALERT, + * 'sensitive' => Logger::ERROR, + * ) + * ); + * $handler = new FingersCrossedHandler(new StreamHandler('php://stderr'), $activationStrategy); + * + * + * @author Mike Meessen + */ +class ChannelLevelActivationStrategy implements ActivationStrategyInterface +{ + private $defaultActionLevel; + private $channelToActionLevel; + + /** + * @param int $defaultActionLevel The default action level to be used if the record's category doesn't match any + * @param array $categoryToActionLevel An array that maps channel names to action levels. + */ + public function __construct($defaultActionLevel, $channelToActionLevel = array()) + { + $this->defaultActionLevel = $defaultActionLevel; + $this->channelToActionLevel = $channelToActionLevel; + } + + public function isHandlerActivated(array $record) + { + if (isset($this->channelToActionLevel[$record['channel']])) { + return $record['level'] >= $this->channelToActionLevel[$record['channel']]; + } + + return $record['level'] >= $this->defaultActionLevel; + } +} diff --git a/vendor/monolog/monolog/src/Monolog/Handler/FingersCrossed/ErrorLevelActivationStrategy.php b/vendor/monolog/monolog/src/Monolog/Handler/FingersCrossed/ErrorLevelActivationStrategy.php new file mode 100755 index 0000000..7cd8ef1 --- /dev/null +++ b/vendor/monolog/monolog/src/Monolog/Handler/FingersCrossed/ErrorLevelActivationStrategy.php @@ -0,0 +1,32 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Handler\FingersCrossed; + +/** + * Error level based activation strategy. + * + * @author Johannes M. Schmitt + */ +class ErrorLevelActivationStrategy implements ActivationStrategyInterface +{ + private $actionLevel; + + public function __construct($actionLevel) + { + $this->actionLevel = $actionLevel; + } + + public function isHandlerActivated(array $record) + { + return $record['level'] >= $this->actionLevel; + } +} diff --git a/vendor/monolog/monolog/src/Monolog/Handler/FingersCrossedHandler.php b/vendor/monolog/monolog/src/Monolog/Handler/FingersCrossedHandler.php new file mode 100755 index 0000000..bc51e4e --- /dev/null +++ b/vendor/monolog/monolog/src/Monolog/Handler/FingersCrossedHandler.php @@ -0,0 +1,118 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Handler; + +use Monolog\Handler\FingersCrossed\ErrorLevelActivationStrategy; +use Monolog\Handler\FingersCrossed\ActivationStrategyInterface; +use Monolog\Logger; + +/** + * Buffers all records until a certain level is reached + * + * The advantage of this approach is that you don't get any clutter in your log files. + * Only requests which actually trigger an error (or whatever your actionLevel is) will be + * in the logs, but they will contain all records, not only those above the level threshold. + * + * You can find the various activation strategies in the + * Monolog\Handler\FingersCrossed\ namespace. + * + * @author Jordi Boggiano + */ +class FingersCrossedHandler extends AbstractHandler +{ + protected $handler; + protected $activationStrategy; + protected $buffering = true; + protected $bufferSize; + protected $buffer = array(); + protected $stopBuffering; + + /** + * @param callable|HandlerInterface $handler Handler or factory callable($record, $fingersCrossedHandler). + * @param int|ActivationStrategyInterface $activationStrategy Strategy which determines when this handler takes action + * @param int $bufferSize How many entries should be buffered at most, beyond that the oldest items are removed from the buffer. + * @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not + * @param Boolean $stopBuffering Whether the handler should stop buffering after being triggered (default true) + */ + public function __construct($handler, $activationStrategy = null, $bufferSize = 0, $bubble = true, $stopBuffering = true) + { + if (null === $activationStrategy) { + $activationStrategy = new ErrorLevelActivationStrategy(Logger::WARNING); + } + + // convert simple int activationStrategy to an object + if (!$activationStrategy instanceof ActivationStrategyInterface) { + $activationStrategy = new ErrorLevelActivationStrategy($activationStrategy); + } + + $this->handler = $handler; + $this->activationStrategy = $activationStrategy; + $this->bufferSize = $bufferSize; + $this->bubble = $bubble; + $this->stopBuffering = $stopBuffering; + } + + /** + * {@inheritdoc} + */ + public function isHandling(array $record) + { + return true; + } + + /** + * {@inheritdoc} + */ + public function handle(array $record) + { + if ($this->processors) { + foreach ($this->processors as $processor) { + $record = call_user_func($processor, $record); + } + } + + if ($this->buffering) { + $this->buffer[] = $record; + if ($this->bufferSize > 0 && count($this->buffer) > $this->bufferSize) { + array_shift($this->buffer); + } + if ($this->activationStrategy->isHandlerActivated($record)) { + if ($this->stopBuffering) { + $this->buffering = false; + } + if (!$this->handler instanceof HandlerInterface) { + if (!is_callable($this->handler)) { + throw new \RuntimeException("The given handler (".json_encode($this->handler).") is not a callable nor a Monolog\Handler\HandlerInterface object"); + } + $this->handler = call_user_func($this->handler, $record, $this); + if (!$this->handler instanceof HandlerInterface) { + throw new \RuntimeException("The factory callable should return a HandlerInterface"); + } + } + $this->handler->handleBatch($this->buffer); + $this->buffer = array(); + } + } else { + $this->handler->handle($record); + } + + return false === $this->bubble; + } + + /** + * Resets the state of the handler. Stops forwarding records to the wrapped handler. + */ + public function reset() + { + $this->buffering = true; + } +} diff --git a/vendor/monolog/monolog/src/Monolog/Handler/FirePHPHandler.php b/vendor/monolog/monolog/src/Monolog/Handler/FirePHPHandler.php new file mode 100755 index 0000000..fee4795 --- /dev/null +++ b/vendor/monolog/monolog/src/Monolog/Handler/FirePHPHandler.php @@ -0,0 +1,195 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Handler; + +use Monolog\Formatter\WildfireFormatter; + +/** + * Simple FirePHP Handler (http://www.firephp.org/), which uses the Wildfire protocol. + * + * @author Eric Clemmons (@ericclemmons) + */ +class FirePHPHandler extends AbstractProcessingHandler +{ + /** + * WildFire JSON header message format + */ + const PROTOCOL_URI = 'http://meta.wildfirehq.org/Protocol/JsonStream/0.2'; + + /** + * FirePHP structure for parsing messages & their presentation + */ + const STRUCTURE_URI = 'http://meta.firephp.org/Wildfire/Structure/FirePHP/FirebugConsole/0.1'; + + /** + * Must reference a "known" plugin, otherwise headers won't display in FirePHP + */ + const PLUGIN_URI = 'http://meta.firephp.org/Wildfire/Plugin/FirePHP/Library-FirePHPCore/0.3'; + + /** + * Header prefix for Wildfire to recognize & parse headers + */ + const HEADER_PREFIX = 'X-Wf'; + + /** + * Whether or not Wildfire vendor-specific headers have been generated & sent yet + */ + protected static $initialized = false; + + /** + * Shared static message index between potentially multiple handlers + * @var int + */ + protected static $messageIndex = 1; + + protected static $sendHeaders = true; + + /** + * Base header creation function used by init headers & record headers + * + * @param array $meta Wildfire Plugin, Protocol & Structure Indexes + * @param string $message Log message + * @return array Complete header string ready for the client as key and message as value + */ + protected function createHeader(array $meta, $message) + { + $header = sprintf('%s-%s', self::HEADER_PREFIX, join('-', $meta)); + + return array($header => $message); + } + + /** + * Creates message header from record + * + * @see createHeader() + * @param array $record + * @return string + */ + protected function createRecordHeader(array $record) + { + // Wildfire is extensible to support multiple protocols & plugins in a single request, + // but we're not taking advantage of that (yet), so we're using "1" for simplicity's sake. + return $this->createHeader( + array(1, 1, 1, self::$messageIndex++), + $record['formatted'] + ); + } + + /** + * {@inheritDoc} + */ + protected function getDefaultFormatter() + { + return new WildfireFormatter(); + } + + /** + * Wildfire initialization headers to enable message parsing + * + * @see createHeader() + * @see sendHeader() + * @return array + */ + protected function getInitHeaders() + { + // Initial payload consists of required headers for Wildfire + return array_merge( + $this->createHeader(array('Protocol', 1), self::PROTOCOL_URI), + $this->createHeader(array(1, 'Structure', 1), self::STRUCTURE_URI), + $this->createHeader(array(1, 'Plugin', 1), self::PLUGIN_URI) + ); + } + + /** + * Send header string to the client + * + * @param string $header + * @param string $content + */ + protected function sendHeader($header, $content) + { + if (!headers_sent() && self::$sendHeaders) { + header(sprintf('%s: %s', $header, $content)); + } + } + + /** + * Creates & sends header for a record, ensuring init headers have been sent prior + * + * @see sendHeader() + * @see sendInitHeaders() + * @param array $record + */ + protected function write(array $record) + { + if (!self::$sendHeaders) { + return; + } + + // WildFire-specific headers must be sent prior to any messages + if (!self::$initialized) { + self::$initialized = true; + + self::$sendHeaders = $this->headersAccepted(); + if (!self::$sendHeaders) { + return; + } + + foreach ($this->getInitHeaders() as $header => $content) { + $this->sendHeader($header, $content); + } + } + + $header = $this->createRecordHeader($record); + if (trim(current($header)) !== '') { + $this->sendHeader(key($header), current($header)); + } + } + + /** + * Verifies if the headers are accepted by the current user agent + * + * @return Boolean + */ + protected function headersAccepted() + { + if (!empty($_SERVER['HTTP_USER_AGENT']) && preg_match('{\bFirePHP/\d+\.\d+\b}', $_SERVER['HTTP_USER_AGENT'])) { + return true; + } + + return isset($_SERVER['HTTP_X_FIREPHP_VERSION']); + } + + /** + * BC getter for the sendHeaders property that has been made static + */ + public function __get($property) + { + if ('sendHeaders' !== $property) { + throw new \InvalidArgumentException('Undefined property '.$property); + } + + return static::$sendHeaders; + } + + /** + * BC setter for the sendHeaders property that has been made static + */ + public function __set($property, $value) + { + if ('sendHeaders' !== $property) { + throw new \InvalidArgumentException('Undefined property '.$property); + } + + static::$sendHeaders = $value; + } +} diff --git a/vendor/monolog/monolog/src/Monolog/Handler/FlowdockHandler.php b/vendor/monolog/monolog/src/Monolog/Handler/FlowdockHandler.php new file mode 100755 index 0000000..0916343 --- /dev/null +++ b/vendor/monolog/monolog/src/Monolog/Handler/FlowdockHandler.php @@ -0,0 +1,103 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Handler; + +use Monolog\Logger; + +/** + * Sends notifications through the Flowdock push API + * + * This must be configured with a FlowdockFormatter instance via setFormatter() + * + * Notes: + * API token - Flowdock API token + * + * @author Dominik Liebler + * @see https://www.flowdock.com/api/push + */ +class FlowdockHandler extends SocketHandler +{ + /** + * @var string + */ + protected $apiToken; + + /** + * @param string $apiToken + * @param bool|int $level The minimum logging level at which this handler will be triggered + * @param bool $bubble Whether the messages that are handled can bubble up the stack or not + * + * @throws MissingExtensionException if OpenSSL is missing + */ + public function __construct($apiToken, $level = Logger::DEBUG, $bubble = true) + { + if (!extension_loaded('openssl')) { + throw new MissingExtensionException('The OpenSSL PHP extension is required to use the FlowdockHandler'); + } + + parent::__construct('ssl://api.flowdock.com:443', $level, $bubble); + $this->apiToken = $apiToken; + } + + /** + * {@inheritdoc} + * + * @param array $record + */ + public function write(array $record) + { + parent::write($record); + + $this->closeSocket(); + } + + /** + * {@inheritdoc} + * + * @param array $record + * @return string + */ + protected function generateDataStream($record) + { + $content = $this->buildContent($record); + + return $this->buildHeader($content) . $content; + } + + /** + * Builds the body of API call + * + * @param array $record + * @return string + */ + private function buildContent($record) + { + return json_encode($record['formatted']['flowdock']); + } + + /** + * Builds the header of the API Call + * + * @param string $content + * @return string + */ + private function buildHeader($content) + { + $header = "POST /v1/messages/team_inbox/" . $this->apiToken . " HTTP/1.1\r\n"; + $header .= "Host: api.flowdock.com\r\n"; + $header .= "Content-Type: application/json\r\n"; + $header .= "Content-Length: " . strlen($content) . "\r\n"; + $header .= "\r\n"; + + return $header; + } +} diff --git a/vendor/monolog/monolog/src/Monolog/Handler/GelfHandler.php b/vendor/monolog/monolog/src/Monolog/Handler/GelfHandler.php new file mode 100755 index 0000000..790f636 --- /dev/null +++ b/vendor/monolog/monolog/src/Monolog/Handler/GelfHandler.php @@ -0,0 +1,72 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Handler; + +use Gelf\IMessagePublisher; +use Gelf\PublisherInterface; +use InvalidArgumentException; +use Monolog\Logger; +use Monolog\Formatter\GelfMessageFormatter; + +/** + * Handler to send messages to a Graylog2 (http://www.graylog2.org) server + * + * @author Matt Lehner + * @author Benjamin Zikarsky + */ +class GelfHandler extends AbstractProcessingHandler +{ + /** + * @var Publisher the publisher object that sends the message to the server + */ + protected $publisher; + + /** + * @param PublisherInterface|IMessagePublisher $publisher a publisher object + * @param integer $level The minimum logging level at which this handler will be triggered + * @param boolean $bubble Whether the messages that are handled can bubble up the stack or not + */ + public function __construct($publisher, $level = Logger::DEBUG, $bubble = true) + { + parent::__construct($level, $bubble); + + if (!$publisher instanceof IMessagePublisher && !$publisher instanceof PublisherInterface) { + throw new InvalidArgumentException("Invalid publisher, expected a Gelf\IMessagePublisher or Gelf\PublisherInterface instance"); + } + + $this->publisher = $publisher; + } + + /** + * {@inheritdoc} + */ + public function close() + { + $this->publisher = null; + } + + /** + * {@inheritdoc} + */ + protected function write(array $record) + { + $this->publisher->publish($record['formatted']); + } + + /** + * {@inheritDoc} + */ + protected function getDefaultFormatter() + { + return new GelfMessageFormatter(); + } +} diff --git a/vendor/monolog/monolog/src/Monolog/Handler/GroupHandler.php b/vendor/monolog/monolog/src/Monolog/Handler/GroupHandler.php new file mode 100755 index 0000000..99384d3 --- /dev/null +++ b/vendor/monolog/monolog/src/Monolog/Handler/GroupHandler.php @@ -0,0 +1,80 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Handler; + +/** + * Forwards records to multiple handlers + * + * @author Lenar Lõhmus + */ +class GroupHandler extends AbstractHandler +{ + protected $handlers; + + /** + * @param array $handlers Array of Handlers. + * @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not + */ + public function __construct(array $handlers, $bubble = true) + { + foreach ($handlers as $handler) { + if (!$handler instanceof HandlerInterface) { + throw new \InvalidArgumentException('The first argument of the GroupHandler must be an array of HandlerInterface instances.'); + } + } + + $this->handlers = $handlers; + $this->bubble = $bubble; + } + + /** + * {@inheritdoc} + */ + public function isHandling(array $record) + { + foreach ($this->handlers as $handler) { + if ($handler->isHandling($record)) { + return true; + } + } + + return false; + } + + /** + * {@inheritdoc} + */ + public function handle(array $record) + { + if ($this->processors) { + foreach ($this->processors as $processor) { + $record = call_user_func($processor, $record); + } + } + + foreach ($this->handlers as $handler) { + $handler->handle($record); + } + + return false === $this->bubble; + } + + /** + * {@inheritdoc} + */ + public function handleBatch(array $records) + { + foreach ($this->handlers as $handler) { + $handler->handleBatch($records); + } + } +} diff --git a/vendor/monolog/monolog/src/Monolog/Handler/HandlerInterface.php b/vendor/monolog/monolog/src/Monolog/Handler/HandlerInterface.php new file mode 100755 index 0000000..accff03 --- /dev/null +++ b/vendor/monolog/monolog/src/Monolog/Handler/HandlerInterface.php @@ -0,0 +1,90 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Handler; + +use Monolog\Formatter\FormatterInterface; + +/** + * Interface that all Monolog Handlers must implement + * + * @author Jordi Boggiano + */ +interface HandlerInterface +{ + /** + * Checks whether the given record will be handled by this handler. + * + * This is mostly done for performance reasons, to avoid calling processors for nothing. + * + * Handlers should still check the record levels within handle(), returning false in isHandling() + * is no guarantee that handle() will not be called, and isHandling() might not be called + * for a given record. + * + * @param array $record + * + * @return Boolean + */ + public function isHandling(array $record); + + /** + * Handles a record. + * + * All records may be passed to this method, and the handler should discard + * those that it does not want to handle. + * + * The return value of this function controls the bubbling process of the handler stack. + * Unless the bubbling is interrupted (by returning true), the Logger class will keep on + * calling further handlers in the stack with a given log record. + * + * @param array $record The record to handle + * @return Boolean true means that this handler handled the record, and that bubbling is not permitted. + * false means the record was either not processed or that this handler allows bubbling. + */ + public function handle(array $record); + + /** + * Handles a set of records at once. + * + * @param array $records The records to handle (an array of record arrays) + */ + public function handleBatch(array $records); + + /** + * Adds a processor in the stack. + * + * @param callable $callback + * @return self + */ + public function pushProcessor($callback); + + /** + * Removes the processor on top of the stack and returns it. + * + * @return callable + */ + public function popProcessor(); + + /** + * Sets the formatter. + * + * @param FormatterInterface $formatter + * @return self + */ + public function setFormatter(FormatterInterface $formatter); + + /** + * Gets the formatter. + * + * @return FormatterInterface + */ + public function getFormatter(); +} diff --git a/vendor/monolog/monolog/src/Monolog/Handler/HipChatHandler.php b/vendor/monolog/monolog/src/Monolog/Handler/HipChatHandler.php new file mode 100755 index 0000000..38ce931 --- /dev/null +++ b/vendor/monolog/monolog/src/Monolog/Handler/HipChatHandler.php @@ -0,0 +1,300 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Handler; + +use Monolog\Logger; + +/** + * Sends notifications through the hipchat api to a hipchat room + * + * Notes: + * API token - HipChat API token + * Room - HipChat Room Id or name, where messages are sent + * Name - Name used to send the message (from) + * notify - Should the message trigger a notification in the clients + * + * @author Rafael Dohms + * @see https://www.hipchat.com/docs/api + */ +class HipChatHandler extends SocketHandler +{ + /** + * The maximum allowed length for the name used in the "from" field. + */ + const MAXIMUM_NAME_LENGTH = 15; + + /** + * The maximum allowed length for the message. + */ + const MAXIMUM_MESSAGE_LENGTH = 9500; + + /** + * @var string + */ + private $token; + + /** + * @var array + */ + private $room; + + /** + * @var string + */ + private $name; + + /** + * @var boolean + */ + private $notify; + + /** + * @var string + */ + private $format; + + /** + * @param string $token HipChat API Token + * @param string $room The room that should be alerted of the message (Id or Name) + * @param string $name Name used in the "from" field + * @param bool $notify Trigger a notification in clients or not + * @param int $level The minimum logging level at which this handler will be triggered + * @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not + * @param Boolean $useSSL Whether to connect via SSL. + * @param string $format The format of the messages (default to text, can be set to html if you have html in the messages) + */ + public function __construct($token, $room, $name = 'Monolog', $notify = false, $level = Logger::CRITICAL, $bubble = true, $useSSL = true, $format = 'text') + { + if (!$this->validateStringLength($name, static::MAXIMUM_NAME_LENGTH)) { + throw new \InvalidArgumentException('The supplied name is too long. HipChat\'s v1 API supports names up to 15 UTF-8 characters.'); + } + + $connectionString = $useSSL ? 'ssl://api.hipchat.com:443' : 'api.hipchat.com:80'; + parent::__construct($connectionString, $level, $bubble); + + $this->token = $token; + $this->name = $name; + $this->notify = $notify; + $this->room = $room; + $this->format = $format; + } + + /** + * {@inheritdoc} + * + * @param array $record + * @return string + */ + protected function generateDataStream($record) + { + $content = $this->buildContent($record); + + return $this->buildHeader($content) . $content; + } + + /** + * Builds the body of API call + * + * @param array $record + * @return string + */ + private function buildContent($record) + { + $dataArray = array( + 'from' => $this->name, + 'room_id' => $this->room, + 'notify' => $this->notify, + 'message' => $record['formatted'], + 'message_format' => $this->format, + 'color' => $this->getAlertColor($record['level']), + ); + + return http_build_query($dataArray); + } + + /** + * Builds the header of the API Call + * + * @param string $content + * @return string + */ + private function buildHeader($content) + { + $header = "POST /v1/rooms/message?format=json&auth_token=".$this->token." HTTP/1.1\r\n"; + $header .= "Host: api.hipchat.com\r\n"; + $header .= "Content-Type: application/x-www-form-urlencoded\r\n"; + $header .= "Content-Length: " . strlen($content) . "\r\n"; + $header .= "\r\n"; + + return $header; + } + + /** + * Assigns a color to each level of log records. + * + * @param integer $level + * @return string + */ + protected function getAlertColor($level) + { + switch (true) { + case $level >= Logger::ERROR: + return 'red'; + case $level >= Logger::WARNING: + return 'yellow'; + case $level >= Logger::INFO: + return 'green'; + case $level == Logger::DEBUG: + return 'gray'; + default: + return 'yellow'; + } + } + + /** + * {@inheritdoc} + * + * @param array $record + */ + public function write(array $record) + { + parent::write($record); + $this->closeSocket(); + } + + /** + * {@inheritdoc} + */ + public function handleBatch(array $records) + { + if (count($records) == 0) { + return true; + } + + $batchRecords = $this->combineRecords($records); + + $handled = false; + foreach ($batchRecords as $batchRecord) { + if ($this->isHandling($batchRecord)) { + $this->write($batchRecord); + $handled = true; + } + } + + if (!$handled) { + return false; + } + + return false === $this->bubble; + } + + /** + * Combines multiple records into one. Error level of the combined record + * will be the highest level from the given records. Datetime will be taken + * from the first record. + * + * @param $records + * @return array + */ + private function combineRecords($records) + { + $batchRecord = null; + $batchRecords = array(); + $batchedMessages = array(); + $messages = array(); + $formattedMessages = array(); + $level = 0; + $levelName = null; + $datetime = null; + + foreach ($records as $record) { + $record = $this->processRecord($record); + + if ($record['level'] > $level) { + $level = $record['level']; + $levelName = $record['level_name']; + } + + if (null === $datetime) { + $datetime = $record['datetime']; + } + + $messages[] = $record['message']; + $messgeStr = implode(PHP_EOL, $messages); + $formattedMessages[] = $this->getFormatter()->format($record); + $formattedMessageStr = implode('', $formattedMessages); + + $batchRecord = array( + 'message' => $messgeStr, + 'formatted' => $formattedMessageStr, + 'context' => array(), + 'extra' => array(), + ); + + if (!$this->validateStringLength($batchRecord['formatted'], static::MAXIMUM_MESSAGE_LENGTH)) { + // Pop the last message and implode the remainging messages + $lastMessage = array_pop($messages); + $lastFormattedMessage = array_pop($formattedMessages); + $batchRecord['message'] = implode(PHP_EOL, $messages); + $batchRecord['formatted'] = implode('', $formattedMessages); + + $batchRecords[] = $batchRecord; + $messages = array($lastMessage); + $formattedMessages = array($lastFormattedMessage); + + $batchRecord = null; + } + } + + if (null !== $batchRecord) { + $batchRecords[] = $batchRecord; + } + + // Set the max level and datetime for all records + foreach ($batchRecords as &$batchRecord) { + $batchRecord = array_merge( + $batchRecord, + array( + 'level' => $level, + 'level_name' => $levelName, + 'datetime' => $datetime + ) + ); + } + + return $batchRecords; + } + + /** + * Validates the length of a string. + * + * If the `mb_strlen()` function is available, it will use that, as HipChat + * allows UTF-8 characters. Otherwise, it will fall back to `strlen()`. + * + * Note that this might cause false failures in the specific case of using + * a valid name with less than 16 characters, but 16 or more bytes, on a + * system where `mb_strlen()` is unavailable. + * + * @param string $str + * @param int $length + * + * @return bool + */ + private function validateStringLength($str, $length) + { + if (function_exists('mb_strlen')) { + return (mb_strlen($str) <= $length); + } + + return (strlen($str) <= $length); + } +} diff --git a/vendor/monolog/monolog/src/Monolog/Handler/LogEntriesHandler.php b/vendor/monolog/monolog/src/Monolog/Handler/LogEntriesHandler.php new file mode 100755 index 0000000..18b3fa4 --- /dev/null +++ b/vendor/monolog/monolog/src/Monolog/Handler/LogEntriesHandler.php @@ -0,0 +1,57 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Handler; + +use Monolog\Logger; + +/** + * @author Robert Kaufmann III + */ +class LogEntriesHandler extends SocketHandler +{ + + /** + * @var string + */ + protected $logToken; + + /** + * @param string $token Log token supplied by LogEntries + * @param boolean $useSSL Whether or not SSL encryption should be used. + * @param int $level The minimum logging level to trigger this handler + * @param boolean $bubble Whether or not messages that are handled should bubble up the stack. + * + * @throws MissingExtensionExcpetion If SSL encryption is set to true and OpenSSL is missing + */ + public function __construct($token, $useSSL = true, $level = Logger::DEBUG, $bubble = true) + { + if ($useSSL && !extension_loaded('openssl')) { + throw new MissingExtensionException('The OpenSSL PHP plugin is required to use SSL encrypted connection for LogEntriesHandler'); + } + + $endpoint = $useSSL ? 'ssl://api.logentries.com:20000' : 'data.logentries.com:80'; + parent::__construct($endpoint, $level, $bubble); + $this->logToken = $token; + } + + /** + * {@inheritdoc} + * + * @param array $record + * @return string + */ + protected function generateDataStream($record) + { + return $this->logToken . ' ' . $record['formatted']; + } + +} diff --git a/vendor/monolog/monolog/src/Monolog/Handler/LogglyHandler.php b/vendor/monolog/monolog/src/Monolog/Handler/LogglyHandler.php new file mode 100755 index 0000000..9a3de6e --- /dev/null +++ b/vendor/monolog/monolog/src/Monolog/Handler/LogglyHandler.php @@ -0,0 +1,93 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Handler; + +use Monolog\Logger; +use Monolog\Formatter\LogglyFormatter; + +/** + * Sends errors to Loggly. + * + * @author Przemek Sobstel + * @author Adam Pancutt + */ +class LogglyHandler extends AbstractProcessingHandler +{ + const HOST = 'logs-01.loggly.com'; + const ENDPOINT_SINGLE = 'inputs'; + const ENDPOINT_BATCH = 'bulk'; + + protected $token; + + protected $tag; + + public function __construct($token, $level = Logger::DEBUG, $bubble = true) + { + if (!extension_loaded('curl')) { + throw new \LogicException('The curl extension is needed to use the LogglyHandler'); + } + + $this->token = $token; + + parent::__construct($level, $bubble); + } + + public function setTag($tag) + { + $this->tag = $tag; + } + + protected function write(array $record) + { + $this->send($record["formatted"], self::ENDPOINT_SINGLE); + } + + public function handleBatch(array $records) + { + $level = $this->level; + + $records = array_filter($records, function ($record) use ($level) { + return ($record['level'] >= $level); + }); + + if ($records) { + $this->send($this->getFormatter()->formatBatch($records), self::ENDPOINT_BATCH); + } + } + + protected function send($data, $endpoint) + { + $url = sprintf("https://%s/%s/%s/", self::HOST, $endpoint, $this->token); + + $headers = array('Content-Type: application/json'); + + if ($this->tag) { + $headers[] = "X-LOGGLY-TAG: {$this->tag}"; + } + + $ch = curl_init(); + + curl_setopt($ch, CURLOPT_URL, $url); + curl_setopt($ch, CURLOPT_POST, true); + curl_setopt($ch, CURLOPT_POSTFIELDS, $data); + curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + + curl_exec($ch); + curl_close($ch); + } + + protected function getDefaultFormatter() + { + return new LogglyFormatter(); + } +} diff --git a/vendor/monolog/monolog/src/Monolog/Handler/MailHandler.php b/vendor/monolog/monolog/src/Monolog/Handler/MailHandler.php new file mode 100755 index 0000000..8629272 --- /dev/null +++ b/vendor/monolog/monolog/src/Monolog/Handler/MailHandler.php @@ -0,0 +1,55 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Handler; + +/** + * Base class for all mail handlers + * + * @author Gyula Sallai + */ +abstract class MailHandler extends AbstractProcessingHandler +{ + /** + * {@inheritdoc} + */ + public function handleBatch(array $records) + { + $messages = array(); + + foreach ($records as $record) { + if ($record['level'] < $this->level) { + continue; + } + $messages[] = $this->processRecord($record); + } + + if (!empty($messages)) { + $this->send((string) $this->getFormatter()->formatBatch($messages), $messages); + } + } + + /** + * Send a mail with the given content + * + * @param string $content + * @param array $records the array of log records that formed this content + */ + abstract protected function send($content, array $records); + + /** + * {@inheritdoc} + */ + protected function write(array $record) + { + $this->send((string) $record['formatted'], array($record)); + } +} diff --git a/vendor/monolog/monolog/src/Monolog/Handler/MissingExtensionException.php b/vendor/monolog/monolog/src/Monolog/Handler/MissingExtensionException.php new file mode 100755 index 0000000..0cb21cd --- /dev/null +++ b/vendor/monolog/monolog/src/Monolog/Handler/MissingExtensionException.php @@ -0,0 +1,22 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Handler; + +/** + * Exception can be thrown if an extension for an handler is missing + * + * @author Christian Bergau + */ +class MissingExtensionException extends \Exception +{ + +} diff --git a/vendor/monolog/monolog/src/Monolog/Handler/MongoDBHandler.php b/vendor/monolog/monolog/src/Monolog/Handler/MongoDBHandler.php new file mode 100755 index 0000000..6c431f2 --- /dev/null +++ b/vendor/monolog/monolog/src/Monolog/Handler/MongoDBHandler.php @@ -0,0 +1,55 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Handler; + +use Monolog\Logger; +use Monolog\Formatter\NormalizerFormatter; + +/** + * Logs to a MongoDB database. + * + * usage example: + * + * $log = new Logger('application'); + * $mongodb = new MongoDBHandler(new \Mongo("mongodb://localhost:27017"), "logs", "prod"); + * $log->pushHandler($mongodb); + * + * @author Thomas Tourlourat + */ +class MongoDBHandler extends AbstractProcessingHandler +{ + protected $mongoCollection; + + public function __construct($mongo, $database, $collection, $level = Logger::DEBUG, $bubble = true) + { + if (!($mongo instanceof \MongoClient || $mongo instanceof \Mongo)) { + throw new \InvalidArgumentException('MongoClient or Mongo instance required'); + } + + $this->mongoCollection = $mongo->selectCollection($database, $collection); + + parent::__construct($level, $bubble); + } + + protected function write(array $record) + { + $this->mongoCollection->save($record["formatted"]); + } + + /** + * {@inheritDoc} + */ + protected function getDefaultFormatter() + { + return new NormalizerFormatter(); + } +} diff --git a/vendor/monolog/monolog/src/Monolog/Handler/NativeMailerHandler.php b/vendor/monolog/monolog/src/Monolog/Handler/NativeMailerHandler.php new file mode 100755 index 0000000..f97df48 --- /dev/null +++ b/vendor/monolog/monolog/src/Monolog/Handler/NativeMailerHandler.php @@ -0,0 +1,147 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Handler; + +use Monolog\Logger; + +/** + * NativeMailerHandler uses the mail() function to send the emails + * + * @author Christophe Coevoet + * @author Mark Garrett + */ +class NativeMailerHandler extends MailHandler +{ + /** + * The email address to which the message is delivered + * @var string + */ + protected $to; + + /** + * The subject of the email + * @var string + */ + protected $subject; + + /** + * Optional headers for the message + * @var array + */ + protected $headers = array(); + + /** + * The wordwrap length for the message + * @var integer + */ + protected $maxColumnWidth; + + /** + * The Content-type for the message + * @var string + */ + protected $contentType = 'text/plain'; + + /** + * The encoding for the message + * @var string + */ + protected $encoding = 'utf-8'; + + /** + * @param string|array $to The receiver of the mail + * @param string $subject The subject of the mail + * @param string $from The sender of the mail + * @param integer $level The minimum logging level at which this handler will be triggered + * @param boolean $bubble Whether the messages that are handled can bubble up the stack or not + * @param int $maxColumnWidth The maximum column width that the message lines will have + */ + public function __construct($to, $subject, $from, $level = Logger::ERROR, $bubble = true, $maxColumnWidth = 70) + { + parent::__construct($level, $bubble); + $this->to = is_array($to) ? $to : array($to); + $this->subject = $subject; + $this->addHeader(sprintf('From: %s', $from)); + $this->maxColumnWidth = $maxColumnWidth; + } + + /** + * Add headers to the message + * + * @param string|array $headers Custom added headers + * @return null + */ + public function addHeader($headers) + { + foreach ((array) $headers as $header) { + if (strpos($header, "\n") !== false || strpos($header, "\r") !== false) { + throw new \InvalidArgumentException('Headers can not contain newline characters for security reasons'); + } + $this->headers[] = $header; + } + } + + /** + * {@inheritdoc} + */ + protected function send($content, array $records) + { + $content = wordwrap($content, $this->maxColumnWidth); + $headers = ltrim(implode("\r\n", $this->headers) . "\r\n", "\r\n"); + $headers .= 'Content-type: ' . $this->getContentType() . '; charset=' . $this->getEncoding() . "\r\n"; + if ($this->getContentType() == 'text/html' && false === strpos($headers, 'MIME-Version:')) { + $headers .= 'MIME-Version: 1.0' . "\r\n"; + } + foreach ($this->to as $to) { + mail($to, $this->subject, $content, $headers); + } + } + + /** + * @return string $contentType + */ + public function getContentType() + { + return $this->contentType; + } + + /** + * @return string $encoding + */ + public function getEncoding() + { + return $this->encoding; + } + + /** + * @param string $contentType The content type of the email - Defaults to text/plain. Use text/html for HTML + * messages. + * @return self + */ + public function setContentType($contentType) + { + $this->contentType = $contentType; + + return $this; + } + + /** + * @param string $encoding + * @return self + */ + public function setEncoding($encoding) + { + $this->encoding = $encoding; + + return $this; + } +} diff --git a/vendor/monolog/monolog/src/Monolog/Handler/NewRelicHandler.php b/vendor/monolog/monolog/src/Monolog/Handler/NewRelicHandler.php new file mode 100755 index 0000000..31bc5d2 --- /dev/null +++ b/vendor/monolog/monolog/src/Monolog/Handler/NewRelicHandler.php @@ -0,0 +1,102 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Handler; + +use Monolog\Logger; + +/** + * Class to record a log on a NewRelic application + * + * @see https://newrelic.com/docs/php/new-relic-for-php + */ +class NewRelicHandler extends AbstractProcessingHandler +{ + /** + * Name of the New Relic application that will receive logs from this handler. + * + * @var string + */ + protected $appName; + + /** + * {@inheritDoc} + * + * @param string $appName + */ + public function __construct($level = Logger::ERROR, $bubble = true, $appName = null) + { + parent::__construct($level, $bubble); + + $this->appName = $appName; + } + + /** + * {@inheritDoc} + */ + protected function write(array $record) + { + if (!$this->isNewRelicEnabled()) { + throw new MissingExtensionException('The newrelic PHP extension is required to use the NewRelicHandler'); + } + + if ($appName = $this->getAppName($record['context'])) { + $this->setNewRelicAppName($appName); + } + + if (isset($record['context']['exception']) && $record['context']['exception'] instanceof \Exception) { + newrelic_notice_error($record['message'], $record['context']['exception']); + unset($record['context']['exception']); + } else { + newrelic_notice_error($record['message']); + } + + foreach ($record['context'] as $key => $parameter) { + newrelic_add_custom_parameter($key, $parameter); + } + } + + /** + * Checks whether the NewRelic extension is enabled in the system. + * + * @return bool + */ + protected function isNewRelicEnabled() + { + return extension_loaded('newrelic'); + } + + /** + * Returns the appname where this log should be sent. Each log can override the default appname, set in this + * handler's constructor, by providing the appname in its context. + * + * @param array $context + * @return null|string + */ + protected function getAppName(array $context) + { + if (isset($context['appname'])) { + return $context['appname']; + } + + return $this->appName; + } + + /** + * Sets the NewRelic application that should receive this log. + * + * @param string $appName + */ + protected function setNewRelicAppName($appName) + { + newrelic_set_appname($appName); + } +} diff --git a/vendor/monolog/monolog/src/Monolog/Handler/NullHandler.php b/vendor/monolog/monolog/src/Monolog/Handler/NullHandler.php new file mode 100755 index 0000000..3754e45 --- /dev/null +++ b/vendor/monolog/monolog/src/Monolog/Handler/NullHandler.php @@ -0,0 +1,45 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Handler; + +use Monolog\Logger; + +/** + * Blackhole + * + * Any record it can handle will be thrown away. This can be used + * to put on top of an existing stack to override it temporarily. + * + * @author Jordi Boggiano + */ +class NullHandler extends AbstractHandler +{ + /** + * @param integer $level The minimum logging level at which this handler will be triggered + */ + public function __construct($level = Logger::DEBUG) + { + parent::__construct($level, false); + } + + /** + * {@inheritdoc} + */ + public function handle(array $record) + { + if ($record['level'] < $this->level) { + return false; + } + + return true; + } +} diff --git a/vendor/monolog/monolog/src/Monolog/Handler/PushoverHandler.php b/vendor/monolog/monolog/src/Monolog/Handler/PushoverHandler.php new file mode 100755 index 0000000..2c80afe --- /dev/null +++ b/vendor/monolog/monolog/src/Monolog/Handler/PushoverHandler.php @@ -0,0 +1,145 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Handler; + +use Monolog\Logger; + +/** + * Sends notifications through the pushover api to mobile phones + * + * @author Sebastian Göttschkes + * @see https://www.pushover.net/api + */ +class PushoverHandler extends SocketHandler +{ + private $token; + private $users; + private $title; + private $user; + private $retry; + private $expire; + + private $highPriorityLevel; + private $emergencyLevel; + + /** + * Sounds the api supports by default + * @see https://pushover.net/api#sounds + * @var array + */ + private $sounds = array( + 'pushover', 'bike', 'bugle', 'cashregister', 'classical', 'cosmic', 'falling', 'gamelan', 'incoming', + 'intermission', 'magic', 'mechanical', 'pianobar', 'siren', 'spacealarm', 'tugboat', 'alien', 'climb', + 'persistent', 'echo', 'updown', 'none', + ); + + /** + * @param string $token Pushover api token + * @param string|array $users Pushover user id or array of ids the message will be sent to + * @param string $title Title sent to the Pushover API + * @param integer $level The minimum logging level at which this handler will be triggered + * @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not + * @param Boolean $useSSL Whether to connect via SSL. Required when pushing messages to users that are not + * the pushover.net app owner. OpenSSL is required for this option. + * @param integer $highPriorityLevel The minimum logging level at which this handler will start + * sending "high priority" requests to the Pushover API + * @param integer $emergencyLevel The minimum logging level at which this handler will start + * sending "emergency" requests to the Pushover API + * @param integer $retry The retry parameter specifies how often (in seconds) the Pushover servers will send the same notification to the user. + * @param integer $expire The expire parameter specifies how many seconds your notification will continue to be retried for (every retry seconds). + */ + public function __construct($token, $users, $title = null, $level = Logger::CRITICAL, $bubble = true, $useSSL = true, $highPriorityLevel = Logger::CRITICAL, $emergencyLevel = Logger::EMERGENCY, $retry = 30, $expire = 25200) + { + $connectionString = $useSSL ? 'ssl://api.pushover.net:443' : 'api.pushover.net:80'; + parent::__construct($connectionString, $level, $bubble); + + $this->token = $token; + $this->users = (array) $users; + $this->title = $title ?: gethostname(); + $this->highPriorityLevel = $highPriorityLevel; + $this->emergencyLevel = $emergencyLevel; + $this->retry = $retry; + $this->expire = $expire; + } + + protected function generateDataStream($record) + { + $content = $this->buildContent($record); + + return $this->buildHeader($content) . $content; + } + + private function buildContent($record) + { + // Pushover has a limit of 512 characters on title and message combined. + $maxMessageLength = 512 - strlen($this->title); + $message = substr($record['message'], 0, $maxMessageLength); + $timestamp = $record['datetime']->getTimestamp(); + + $dataArray = array( + 'token' => $this->token, + 'user' => $this->user, + 'message' => $message, + 'title' => $this->title, + 'timestamp' => $timestamp + ); + + if ($record['level'] >= $this->emergencyLevel) { + $dataArray['priority'] = 2; + $dataArray['retry'] = $this->retry; + $dataArray['expire'] = $this->expire; + } elseif ($record['level'] >= $this->highPriorityLevel) { + $dataArray['priority'] = 1; + } + + if (isset($record['context']['sound']) && in_array($record['context']['sound'], $this->sounds)) { + $dataArray['sound'] = $record['context']['sound']; + } elseif (isset($record['extra']['sound']) && in_array($record['extra']['sound'], $this->sounds)) { + $dataArray['sound'] = $record['extra']['sound']; + } + + return http_build_query($dataArray); + } + + private function buildHeader($content) + { + $header = "POST /1/messages.json HTTP/1.1\r\n"; + $header .= "Host: api.pushover.net\r\n"; + $header .= "Content-Type: application/x-www-form-urlencoded\r\n"; + $header .= "Content-Length: " . strlen($content) . "\r\n"; + $header .= "\r\n"; + + return $header; + } + + public function write(array $record) + { + foreach ($this->users as $user) { + $this->user = $user; + + parent::write($record); + $this->closeSocket(); + } + + $this->user = null; + } + + public function setHighPriorityLevel($value) + { + $this->highPriorityLevel = $value; + } + + public function setEmergencyLevel($value) + { + $this->emergencyLevel = $value; + } +} diff --git a/vendor/monolog/monolog/src/Monolog/Handler/RavenHandler.php b/vendor/monolog/monolog/src/Monolog/Handler/RavenHandler.php new file mode 100755 index 0000000..b8f701e --- /dev/null +++ b/vendor/monolog/monolog/src/Monolog/Handler/RavenHandler.php @@ -0,0 +1,175 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Handler; + +use Monolog\Formatter\LineFormatter; +use Monolog\Formatter\FormatterInterface; +use Monolog\Logger; +use Raven_Client; + +/** + * Handler to send messages to a Sentry (https://github.com/dcramer/sentry) server + * using raven-php (https://github.com/getsentry/raven-php) + * + * @author Marc Abramowitz + */ +class RavenHandler extends AbstractProcessingHandler +{ + /** + * Translates Monolog log levels to Raven log levels. + */ + private $logLevels = array( + Logger::DEBUG => Raven_Client::DEBUG, + Logger::INFO => Raven_Client::INFO, + Logger::NOTICE => Raven_Client::INFO, + Logger::WARNING => Raven_Client::WARNING, + Logger::ERROR => Raven_Client::ERROR, + Logger::CRITICAL => Raven_Client::FATAL, + Logger::ALERT => Raven_Client::FATAL, + Logger::EMERGENCY => Raven_Client::FATAL, + ); + + /** + * @var Raven_Client the client object that sends the message to the server + */ + protected $ravenClient; + + /** + * @var LineFormatter The formatter to use for the logs generated via handleBatch() + */ + protected $batchFormatter; + + /** + * @param Raven_Client $ravenClient + * @param integer $level The minimum logging level at which this handler will be triggered + * @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not + */ + public function __construct(Raven_Client $ravenClient, $level = Logger::DEBUG, $bubble = true) + { + parent::__construct($level, $bubble); + + $this->ravenClient = $ravenClient; + } + + /** + * {@inheritdoc} + */ + public function handleBatch(array $records) + { + $level = $this->level; + + // filter records based on their level + $records = array_filter($records, function ($record) use ($level) { + return $record['level'] >= $level; + }); + + if (!$records) { + return; + } + + // the record with the highest severity is the "main" one + $record = array_reduce($records, function ($highest, $record) { + if ($record['level'] >= $highest['level']) { + return $record; + } + + return $highest; + }); + + // the other ones are added as a context item + $logs = array(); + foreach ($records as $r) { + $logs[] = $this->processRecord($r); + } + + if ($logs) { + $record['context']['logs'] = (string) $this->getBatchFormatter()->formatBatch($logs); + } + + $this->handle($record); + } + + /** + * Sets the formatter for the logs generated by handleBatch(). + * + * @param FormatterInterface $formatter + */ + public function setBatchFormatter(FormatterInterface $formatter) + { + $this->batchFormatter = $formatter; + } + + /** + * Gets the formatter for the logs generated by handleBatch(). + * + * @return FormatterInterface + */ + public function getBatchFormatter() + { + if (!$this->batchFormatter) { + $this->batchFormatter = $this->getDefaultBatchFormatter(); + } + + return $this->batchFormatter; + } + + /** + * {@inheritdoc} + */ + protected function write(array $record) + { + $options = array(); + $options['level'] = $this->logLevels[$record['level']]; + $options['tags'] = array(); + if (!empty($record['extra']['tags'])) { + $options['tags'] = array_merge($options['tags'], $record['extra']['tags']); + unset($record['extra']['tags']); + } + if (!empty($record['context']['tags'])) { + $options['tags'] = array_merge($options['tags'], $record['context']['tags']); + unset($record['context']['tags']); + } + if (!empty($record['context'])) { + $options['extra']['context'] = $record['context']; + } + if (!empty($record['extra'])) { + $options['extra']['extra'] = $record['extra']; + } + + if (isset($record['context']['exception']) && $record['context']['exception'] instanceof \Exception) { + $options['extra']['message'] = $record['formatted']; + $this->ravenClient->captureException($record['context']['exception'], $options); + + return; + } + + $this->ravenClient->captureMessage($record['formatted'], array(), $options); + } + + /** + * {@inheritDoc} + */ + protected function getDefaultFormatter() + { + return new LineFormatter('[%channel%] %message%'); + } + + /** + * Gets the default formatter for the logs generated by handleBatch(). + * + * @return FormatterInterface + */ + protected function getDefaultBatchFormatter() + { + return new LineFormatter(); + } +} diff --git a/vendor/monolog/monolog/src/Monolog/Handler/RedisHandler.php b/vendor/monolog/monolog/src/Monolog/Handler/RedisHandler.php new file mode 100755 index 0000000..3fc7f34 --- /dev/null +++ b/vendor/monolog/monolog/src/Monolog/Handler/RedisHandler.php @@ -0,0 +1,58 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Handler; + +use Monolog\Logger; +use Monolog\Formatter\LineFormatter; + +/** + * Logs to a Redis key using rpush + * + * usage example: + * + * $log = new Logger('application'); + * $redis = new RedisHandler(new Predis\Client("tcp://localhost:6379"), "logs", "prod"); + * $log->pushHandler($redis); + * + * @author Thomas Tourlourat + */ +class RedisHandler extends AbstractProcessingHandler +{ + private $redisClient; + private $redisKey; + + # redis instance, key to use + public function __construct($redis, $key, $level = Logger::DEBUG, $bubble = true) + { + if (!(($redis instanceof \Predis\Client) || ($redis instanceof \Redis))) { + throw new \InvalidArgumentException('Predis\Client or Redis instance required'); + } + + $this->redisClient = $redis; + $this->redisKey = $key; + + parent::__construct($level, $bubble); + } + + protected function write(array $record) + { + $this->redisClient->rpush($this->redisKey, $record["formatted"]); + } + + /** + * {@inheritDoc} + */ + protected function getDefaultFormatter() + { + return new LineFormatter(); + } +} diff --git a/vendor/monolog/monolog/src/Monolog/Handler/RollbarHandler.php b/vendor/monolog/monolog/src/Monolog/Handler/RollbarHandler.php new file mode 100755 index 0000000..fb02ad6 --- /dev/null +++ b/vendor/monolog/monolog/src/Monolog/Handler/RollbarHandler.php @@ -0,0 +1,64 @@ + + */ +class RollbarHandler extends AbstractProcessingHandler +{ + /** + * Rollbar notifier + * + * @var RollbarNotifier + */ + protected $rollbarNotifier; + + /** + * @param RollbarNotifier $rollbarNotifier RollbarNotifier object constructed with valid token + * @param integer $level The minimum logging level at which this handler will be triggered + * @param boolean $bubble Whether the messages that are handled can bubble up the stack or not + */ + public function __construct(RollbarNotifier $rollbarNotifier, $level = Logger::ERROR, $bubble = true) + { + $this->rollbarNotifier = $rollbarNotifier; + + parent::__construct($level, $bubble); + } + + /** + * {@inheritdoc} + */ + protected function write(array $record) + { + if (isset($record['context']['exception']) && $record['context']['exception'] instanceof Exception) { + $this->rollbarNotifier->report_exception($record['context']['exception']); + } else { + $extraData = array( + 'level' => $record['level'], + 'channel' => $record['channel'], + 'datetime' => $record['datetime']->format('U'), + ); + + $this->rollbarNotifier->report_message( + $record['message'], + $record['level_name'], + array_merge($record['context'], $record['extra'], $extraData) + ); + } + } + + /** + * {@inheritdoc} + */ + public function close() + { + $this->rollbarNotifier->flush(); + } +} diff --git a/vendor/monolog/monolog/src/Monolog/Handler/RotatingFileHandler.php b/vendor/monolog/monolog/src/Monolog/Handler/RotatingFileHandler.php new file mode 100755 index 0000000..6213d6e --- /dev/null +++ b/vendor/monolog/monolog/src/Monolog/Handler/RotatingFileHandler.php @@ -0,0 +1,152 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Handler; + +use Monolog\Logger; + +/** + * Stores logs to files that are rotated every day and a limited number of files are kept. + * + * This rotation is only intended to be used as a workaround. Using logrotate to + * handle the rotation is strongly encouraged when you can use it. + * + * @author Christophe Coevoet + * @author Jordi Boggiano + */ +class RotatingFileHandler extends StreamHandler +{ + protected $filename; + protected $maxFiles; + protected $mustRotate; + protected $nextRotation; + protected $filenameFormat; + protected $dateFormat; + + /** + * @param string $filename + * @param integer $maxFiles The maximal amount of files to keep (0 means unlimited) + * @param integer $level The minimum logging level at which this handler will be triggered + * @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not + * @param int $filePermissions Optional file permissions (default (0644) are only for owner read/write) + */ + public function __construct($filename, $maxFiles = 0, $level = Logger::DEBUG, $bubble = true, $filePermission = null) + { + $this->filename = $filename; + $this->maxFiles = (int) $maxFiles; + $this->nextRotation = new \DateTime('tomorrow'); + $this->filenameFormat = '{filename}-{date}'; + $this->dateFormat = 'Y-m-d'; + + parent::__construct($this->getTimedFilename(), $level, $bubble, $filePermission); + } + + /** + * {@inheritdoc} + */ + public function close() + { + parent::close(); + + if (true === $this->mustRotate) { + $this->rotate(); + } + } + + public function setFilenameFormat($filenameFormat, $dateFormat) + { + $this->filenameFormat = $filenameFormat; + $this->dateFormat = $dateFormat; + $this->url = $this->getTimedFilename(); + $this->close(); + } + + /** + * {@inheritdoc} + */ + protected function write(array $record) + { + // on the first record written, if the log is new, we should rotate (once per day) + if (null === $this->mustRotate) { + $this->mustRotate = !file_exists($this->url); + } + + if ($this->nextRotation < $record['datetime']) { + $this->mustRotate = true; + $this->close(); + } + + parent::write($record); + } + + /** + * Rotates the files. + */ + protected function rotate() + { + // update filename + $this->url = $this->getTimedFilename(); + $this->nextRotation = new \DateTime('tomorrow'); + + // skip GC of old logs if files are unlimited + if (0 === $this->maxFiles) { + return; + } + + $logFiles = glob($this->getGlobPattern()); + if ($this->maxFiles >= count($logFiles)) { + // no files to remove + return; + } + + // Sorting the files by name to remove the older ones + usort($logFiles, function ($a, $b) { + return strcmp($b, $a); + }); + + foreach (array_slice($logFiles, $this->maxFiles) as $file) { + if (is_writable($file)) { + unlink($file); + } + } + } + + protected function getTimedFilename() + { + $fileInfo = pathinfo($this->filename); + $timedFilename = str_replace( + array('{filename}', '{date}'), + array($fileInfo['filename'], date($this->dateFormat)), + $fileInfo['dirname'] . '/' . $this->filenameFormat + ); + + if (!empty($fileInfo['extension'])) { + $timedFilename .= '.'.$fileInfo['extension']; + } + + return $timedFilename; + } + + protected function getGlobPattern() + { + $fileInfo = pathinfo($this->filename); + $glob = str_replace( + array('{filename}', '{date}'), + array($fileInfo['filename'], '*'), + $fileInfo['dirname'] . '/' . $this->filenameFormat + ); + if (!empty($fileInfo['extension'])) { + $glob .= '.'.$fileInfo['extension']; + } + + return $glob; + } +} diff --git a/vendor/monolog/monolog/src/Monolog/Handler/SocketHandler.php b/vendor/monolog/monolog/src/Monolog/Handler/SocketHandler.php new file mode 100755 index 0000000..4faa327 --- /dev/null +++ b/vendor/monolog/monolog/src/Monolog/Handler/SocketHandler.php @@ -0,0 +1,285 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Handler; + +use Monolog\Logger; + +/** + * Stores to any socket - uses fsockopen() or pfsockopen(). + * + * @author Pablo de Leon Belloc + * @see http://php.net/manual/en/function.fsockopen.php + */ +class SocketHandler extends AbstractProcessingHandler +{ + private $connectionString; + private $connectionTimeout; + private $resource; + private $timeout = 0; + private $persistent = false; + private $errno; + private $errstr; + + /** + * @param string $connectionString Socket connection string + * @param integer $level The minimum logging level at which this handler will be triggered + * @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not + */ + public function __construct($connectionString, $level = Logger::DEBUG, $bubble = true) + { + parent::__construct($level, $bubble); + $this->connectionString = $connectionString; + $this->connectionTimeout = (float) ini_get('default_socket_timeout'); + } + + /** + * Connect (if necessary) and write to the socket + * + * @param array $record + * + * @throws \UnexpectedValueException + * @throws \RuntimeException + */ + public function write(array $record) + { + $this->connectIfNotConnected(); + $data = $this->generateDataStream($record); + $this->writeToSocket($data); + } + + /** + * We will not close a PersistentSocket instance so it can be reused in other requests. + */ + public function close() + { + if (!$this->isPersistent()) { + $this->closeSocket(); + } + } + + /** + * Close socket, if open + */ + public function closeSocket() + { + if (is_resource($this->resource)) { + fclose($this->resource); + $this->resource = null; + } + } + + /** + * Set socket connection to nbe persistent. It only has effect before the connection is initiated. + * + * @param type $boolean + */ + public function setPersistent($boolean) + { + $this->persistent = (boolean) $boolean; + } + + /** + * Set connection timeout. Only has effect before we connect. + * + * @param float $seconds + * + * @see http://php.net/manual/en/function.fsockopen.php + */ + public function setConnectionTimeout($seconds) + { + $this->validateTimeout($seconds); + $this->connectionTimeout = (float) $seconds; + } + + /** + * Set write timeout. Only has effect before we connect. + * + * @param float $seconds + * + * @see http://php.net/manual/en/function.stream-set-timeout.php + */ + public function setTimeout($seconds) + { + $this->validateTimeout($seconds); + $this->timeout = (float) $seconds; + } + + /** + * Get current connection string + * + * @return string + */ + public function getConnectionString() + { + return $this->connectionString; + } + + /** + * Get persistent setting + * + * @return boolean + */ + public function isPersistent() + { + return $this->persistent; + } + + /** + * Get current connection timeout setting + * + * @return float + */ + public function getConnectionTimeout() + { + return $this->connectionTimeout; + } + + /** + * Get current in-transfer timeout + * + * @return float + */ + public function getTimeout() + { + return $this->timeout; + } + + /** + * Check to see if the socket is currently available. + * + * UDP might appear to be connected but might fail when writing. See http://php.net/fsockopen for details. + * + * @return boolean + */ + public function isConnected() + { + return is_resource($this->resource) + && !feof($this->resource); // on TCP - other party can close connection. + } + + /** + * Wrapper to allow mocking + */ + protected function pfsockopen() + { + return @pfsockopen($this->connectionString, -1, $this->errno, $this->errstr, $this->connectionTimeout); + } + + /** + * Wrapper to allow mocking + */ + protected function fsockopen() + { + return @fsockopen($this->connectionString, -1, $this->errno, $this->errstr, $this->connectionTimeout); + } + + /** + * Wrapper to allow mocking + * + * @see http://php.net/manual/en/function.stream-set-timeout.php + */ + protected function streamSetTimeout() + { + $seconds = floor($this->timeout); + $microseconds = round(($this->timeout - $seconds)*1e6); + + return stream_set_timeout($this->resource, $seconds, $microseconds); + } + + /** + * Wrapper to allow mocking + */ + protected function fwrite($data) + { + return @fwrite($this->resource, $data); + } + + /** + * Wrapper to allow mocking + */ + protected function streamGetMetadata() + { + return stream_get_meta_data($this->resource); + } + + private function validateTimeout($value) + { + $ok = filter_var($value, FILTER_VALIDATE_FLOAT); + if ($ok === false || $value < 0) { + throw new \InvalidArgumentException("Timeout must be 0 or a positive float (got $value)"); + } + } + + private function connectIfNotConnected() + { + if ($this->isConnected()) { + return; + } + $this->connect(); + } + + protected function generateDataStream($record) + { + return (string) $record['formatted']; + } + + private function connect() + { + $this->createSocketResource(); + $this->setSocketTimeout(); + } + + private function createSocketResource() + { + if ($this->isPersistent()) { + $resource = $this->pfsockopen(); + } else { + $resource = $this->fsockopen(); + } + if (!$resource) { + throw new \UnexpectedValueException("Failed connecting to $this->connectionString ($this->errno: $this->errstr)"); + } + $this->resource = $resource; + } + + private function setSocketTimeout() + { + if (!$this->streamSetTimeout()) { + throw new \UnexpectedValueException("Failed setting timeout with stream_set_timeout()"); + } + } + + private function writeToSocket($data) + { + $length = strlen($data); + $sent = 0; + while ($this->isConnected() && $sent < $length) { + if (0 == $sent) { + $chunk = $this->fwrite($data); + } else { + $chunk = $this->fwrite(substr($data, $sent)); + } + if ($chunk === false) { + throw new \RuntimeException("Could not write to socket"); + } + $sent += $chunk; + $socketInfo = $this->streamGetMetadata(); + if ($socketInfo['timed_out']) { + throw new \RuntimeException("Write timed-out"); + } + } + if (!$this->isConnected() && $sent < $length) { + throw new \RuntimeException("End-of-file reached, probably we got disconnected (sent $sent of $length)"); + } + } + +} diff --git a/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php b/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php new file mode 100755 index 0000000..5c8fc1f --- /dev/null +++ b/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php @@ -0,0 +1,87 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Handler; + +use Monolog\Logger; + +/** + * Stores to any stream resource + * + * Can be used to store into php://stderr, remote and local files, etc. + * + * @author Jordi Boggiano + */ +class StreamHandler extends AbstractProcessingHandler +{ + protected $stream; + protected $url; + private $errorMessage; + protected $filePermission; + + /** + * @param string $stream + * @param integer $level The minimum logging level at which this handler will be triggered + * @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not + * @param int $filePermissions Optional file permissions (default (0644) are only for owner read/write) + */ + public function __construct($stream, $level = Logger::DEBUG, $bubble = true, $filePermission = null) + { + parent::__construct($level, $bubble); + if (is_resource($stream)) { + $this->stream = $stream; + } else { + $this->url = $stream; + } + + $this->filePermission = $filePermission; + } + + /** + * {@inheritdoc} + */ + public function close() + { + if (is_resource($this->stream)) { + fclose($this->stream); + } + $this->stream = null; + } + + /** + * {@inheritdoc} + */ + protected function write(array $record) + { + if (!is_resource($this->stream)) { + if (!$this->url) { + throw new \LogicException('Missing stream url, the stream can not be opened. This may be caused by a premature call to close().'); + } + $this->errorMessage = null; + set_error_handler(array($this, 'customErrorHandler')); + $this->stream = fopen($this->url, 'a'); + if ($this->filePermission !== null) { + @chmod($this->url, $this->filePermission); + } + restore_error_handler(); + if (!is_resource($this->stream)) { + $this->stream = null; + throw new \UnexpectedValueException(sprintf('The stream or file "%s" could not be opened: '.$this->errorMessage, $this->url)); + } + } + fwrite($this->stream, (string) $record['formatted']); + } + + private function customErrorHandler($code, $msg) + { + $this->errorMessage = preg_replace('{^fopen\(.*?\): }', '', $msg); + } +} diff --git a/vendor/monolog/monolog/src/Monolog/Handler/SwiftMailerHandler.php b/vendor/monolog/monolog/src/Monolog/Handler/SwiftMailerHandler.php new file mode 100755 index 0000000..ca03cca --- /dev/null +++ b/vendor/monolog/monolog/src/Monolog/Handler/SwiftMailerHandler.php @@ -0,0 +1,55 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Handler; + +use Monolog\Logger; + +/** + * SwiftMailerHandler uses Swift_Mailer to send the emails + * + * @author Gyula Sallai + */ +class SwiftMailerHandler extends MailHandler +{ + protected $mailer; + protected $message; + + /** + * @param \Swift_Mailer $mailer The mailer to use + * @param callable|\Swift_Message $message An example message for real messages, only the body will be replaced + * @param integer $level The minimum logging level at which this handler will be triggered + * @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not + */ + public function __construct(\Swift_Mailer $mailer, $message, $level = Logger::ERROR, $bubble = true) + { + parent::__construct($level, $bubble); + $this->mailer = $mailer; + if (!$message instanceof \Swift_Message && is_callable($message)) { + $message = call_user_func($message); + } + if (!$message instanceof \Swift_Message) { + throw new \InvalidArgumentException('You must provide either a Swift_Message instance or a callable returning it'); + } + $this->message = $message; + } + + /** + * {@inheritdoc} + */ + protected function send($content, array $records) + { + $message = clone $this->message; + $message->setBody($content); + + $this->mailer->send($message); + } +} diff --git a/vendor/monolog/monolog/src/Monolog/Handler/SyslogHandler.php b/vendor/monolog/monolog/src/Monolog/Handler/SyslogHandler.php new file mode 100755 index 0000000..47c73e1 --- /dev/null +++ b/vendor/monolog/monolog/src/Monolog/Handler/SyslogHandler.php @@ -0,0 +1,67 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Handler; + +use Monolog\Logger; + +/** + * Logs to syslog service. + * + * usage example: + * + * $log = new Logger('application'); + * $syslog = new SyslogHandler('myfacility', 'local6'); + * $formatter = new LineFormatter("%channel%.%level_name%: %message% %extra%"); + * $syslog->setFormatter($formatter); + * $log->pushHandler($syslog); + * + * @author Sven Paulus + */ +class SyslogHandler extends AbstractSyslogHandler +{ + protected $ident; + protected $logopts; + + /** + * @param string $ident + * @param mixed $facility + * @param integer $level The minimum logging level at which this handler will be triggered + * @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not + * @param int $logopts Option flags for the openlog() call, defaults to LOG_PID + */ + public function __construct($ident, $facility = LOG_USER, $level = Logger::DEBUG, $bubble = true, $logopts = LOG_PID) + { + parent::__construct($facility, $level, $bubble); + + $this->ident = $ident; + $this->logopts = $logopts; + } + + /** + * {@inheritdoc} + */ + public function close() + { + closelog(); + } + + /** + * {@inheritdoc} + */ + protected function write(array $record) + { + if (!openlog($this->ident, $this->logopts, $this->facility)) { + throw new \LogicException('Can\'t open syslog for ident "'.$this->ident.'" and facility "'.$this->facility.'"'); + } + syslog($this->logLevels[$record['level']], (string) $record['formatted']); + } +} diff --git a/vendor/monolog/monolog/src/Monolog/Handler/SyslogUdp/UdpSocket.php b/vendor/monolog/monolog/src/Monolog/Handler/SyslogUdp/UdpSocket.php new file mode 100755 index 0000000..d87ab9d --- /dev/null +++ b/vendor/monolog/monolog/src/Monolog/Handler/SyslogUdp/UdpSocket.php @@ -0,0 +1,62 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Handler\SyslogUdp; + +class UdpSocket +{ + const DATAGRAM_MAX_LENGTH = 2048; + + public function __construct($ip, $port = 514) + { + $this->ip = $ip; + $this->port = $port; + $this->socket = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP); + } + + public function write($line, $header = "") + { + $remaining = $line; + while (!is_null($remaining)) { + list($chunk, $remaining) = $this->splitLineIfNessesary($remaining, $header); + $this->send($chunk); + } + } + + public function close() + { + socket_close($this->socket); + } + + protected function send($chunk) + { + socket_sendto($this->socket, $chunk, strlen($chunk), $flags = 0, $this->ip, $this->port); + } + + protected function splitLineIfNessesary($line, $header) + { + if ($this->shouldSplitLine($line, $header)) { + $chunkSize = self::DATAGRAM_MAX_LENGTH - strlen($header); + $chunk = $header . substr($line, 0, $chunkSize); + $remaining = substr($line, $chunkSize); + } else { + $chunk = $header . $line; + $remaining = null; + } + + return array($chunk, $remaining); + } + + protected function shouldSplitLine($remaining, $header) + { + return strlen($header.$remaining) > self::DATAGRAM_MAX_LENGTH; + } +} diff --git a/vendor/monolog/monolog/src/Monolog/Handler/SyslogUdpHandler.php b/vendor/monolog/monolog/src/Monolog/Handler/SyslogUdpHandler.php new file mode 100755 index 0000000..4aadffc --- /dev/null +++ b/vendor/monolog/monolog/src/Monolog/Handler/SyslogUdpHandler.php @@ -0,0 +1,80 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Handler; + +use Monolog\Logger; +use Monolog\Handler\SyslogUdp\UdpSocket; + +/** + * A Handler for logging to a remote syslogd server. + * + * @author Jesper Skovgaard Nielsen + */ +class SyslogUdpHandler extends AbstractSyslogHandler +{ + /** + * @param string $host + * @param int $port + * @param mixed $facility + * @param integer $level The minimum logging level at which this handler will be triggered + * @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not + */ + public function __construct($host, $port = 514, $facility = LOG_USER, $level = Logger::DEBUG, $bubble = true) + { + parent::__construct($facility, $level, $bubble); + + $this->socket = new UdpSocket($host, $port ?: 514); + } + + protected function write(array $record) + { + $lines = $this->splitMessageIntoLines($record['formatted']); + + $header = $this->makeCommonSyslogHeader($this->logLevels[$record['level']]); + + foreach ($lines as $line) { + $this->socket->write($line, $header); + } + } + + public function close() + { + $this->socket->close(); + } + + private function splitMessageIntoLines($message) + { + if (is_array($message)) { + $message = implode("\n", $message); + } + + return preg_split('/$\R?^/m', $message); + } + + /** + * Make common syslog header (see rfc5424) + */ + private function makeCommonSyslogHeader($severity) + { + $priority = $severity + $this->facility; + + return "<$priority>: "; + } + + /** + * Inject your own socket, mainly used for testing + */ + public function setSocket($socket) + { + $this->socket = $socket; + } +} diff --git a/vendor/monolog/monolog/src/Monolog/Handler/TestHandler.php b/vendor/monolog/monolog/src/Monolog/Handler/TestHandler.php new file mode 100755 index 0000000..085d9e1 --- /dev/null +++ b/vendor/monolog/monolog/src/Monolog/Handler/TestHandler.php @@ -0,0 +1,140 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Handler; + +use Monolog\Logger; + +/** + * Used for testing purposes. + * + * It records all records and gives you access to them for verification. + * + * @author Jordi Boggiano + */ +class TestHandler extends AbstractProcessingHandler +{ + protected $records = array(); + protected $recordsByLevel = array(); + + public function getRecords() + { + return $this->records; + } + + public function hasEmergency($record) + { + return $this->hasRecord($record, Logger::EMERGENCY); + } + + public function hasAlert($record) + { + return $this->hasRecord($record, Logger::ALERT); + } + + public function hasCritical($record) + { + return $this->hasRecord($record, Logger::CRITICAL); + } + + public function hasError($record) + { + return $this->hasRecord($record, Logger::ERROR); + } + + public function hasWarning($record) + { + return $this->hasRecord($record, Logger::WARNING); + } + + public function hasNotice($record) + { + return $this->hasRecord($record, Logger::NOTICE); + } + + public function hasInfo($record) + { + return $this->hasRecord($record, Logger::INFO); + } + + public function hasDebug($record) + { + return $this->hasRecord($record, Logger::DEBUG); + } + + public function hasEmergencyRecords() + { + return isset($this->recordsByLevel[Logger::EMERGENCY]); + } + + public function hasAlertRecords() + { + return isset($this->recordsByLevel[Logger::ALERT]); + } + + public function hasCriticalRecords() + { + return isset($this->recordsByLevel[Logger::CRITICAL]); + } + + public function hasErrorRecords() + { + return isset($this->recordsByLevel[Logger::ERROR]); + } + + public function hasWarningRecords() + { + return isset($this->recordsByLevel[Logger::WARNING]); + } + + public function hasNoticeRecords() + { + return isset($this->recordsByLevel[Logger::NOTICE]); + } + + public function hasInfoRecords() + { + return isset($this->recordsByLevel[Logger::INFO]); + } + + public function hasDebugRecords() + { + return isset($this->recordsByLevel[Logger::DEBUG]); + } + + protected function hasRecord($record, $level) + { + if (!isset($this->recordsByLevel[$level])) { + return false; + } + + if (is_array($record)) { + $record = $record['message']; + } + + foreach ($this->recordsByLevel[$level] as $rec) { + if ($rec['message'] === $record) { + return true; + } + } + + return false; + } + + /** + * {@inheritdoc} + */ + protected function write(array $record) + { + $this->recordsByLevel[$record['level']][] = $record; + $this->records[] = $record; + } +} diff --git a/vendor/monolog/monolog/src/Monolog/Handler/ZendMonitorHandler.php b/vendor/monolog/monolog/src/Monolog/Handler/ZendMonitorHandler.php new file mode 100755 index 0000000..f22cf21 --- /dev/null +++ b/vendor/monolog/monolog/src/Monolog/Handler/ZendMonitorHandler.php @@ -0,0 +1,95 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Handler; + +use Monolog\Formatter\NormalizerFormatter; +use Monolog\Logger; + +/** + * Handler sending logs to Zend Monitor + * + * @author Christian Bergau + */ +class ZendMonitorHandler extends AbstractProcessingHandler +{ + /** + * Monolog level / ZendMonitor Custom Event priority map + * + * @var array + */ + protected $levelMap = array( + Logger::DEBUG => 1, + Logger::INFO => 2, + Logger::NOTICE => 3, + Logger::WARNING => 4, + Logger::ERROR => 5, + Logger::CRITICAL => 6, + Logger::ALERT => 7, + Logger::EMERGENCY => 0, + ); + + /** + * Construct + * + * @param int $level + * @param bool $bubble + * @throws MissingExtensionException + */ + public function __construct($level = Logger::DEBUG, $bubble = true) + { + if (!function_exists('zend_monitor_custom_event')) { + throw new MissingExtensionException('You must have Zend Server installed in order to use this handler'); + } + parent::__construct($level, $bubble); + } + + /** + * {@inheritdoc} + */ + protected function write(array $record) + { + $this->writeZendMonitorCustomEvent( + $this->levelMap[$record['level']], + $record['message'], + $record['formatted'] + ); + } + + /** + * Write a record to Zend Monitor + * + * @param int $level + * @param string $message + * @param array $formatted + */ + protected function writeZendMonitorCustomEvent($level, $message, $formatted) + { + zend_monitor_custom_event($level, $message, $formatted); + } + + /** + * {@inheritdoc} + */ + public function getDefaultFormatter() + { + return new NormalizerFormatter(); + } + + /** + * Get the level map + * + * @return array + */ + public function getLevelMap() + { + return $this->levelMap; + } +} diff --git a/vendor/monolog/monolog/src/Monolog/Logger.php b/vendor/monolog/monolog/src/Monolog/Logger.php new file mode 100755 index 0000000..f6d7f80 --- /dev/null +++ b/vendor/monolog/monolog/src/Monolog/Logger.php @@ -0,0 +1,582 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog; + +use Monolog\Handler\HandlerInterface; +use Monolog\Handler\StreamHandler; +use Psr\Log\LoggerInterface; +use Psr\Log\InvalidArgumentException; + +/** + * Monolog log channel + * + * It contains a stack of Handlers and a stack of Processors, + * and uses them to store records that are added to it. + * + * @author Jordi Boggiano + */ +class Logger implements LoggerInterface +{ + /** + * Detailed debug information + */ + const DEBUG = 100; + + /** + * Interesting events + * + * Examples: User logs in, SQL logs. + */ + const INFO = 200; + + /** + * Uncommon events + */ + const NOTICE = 250; + + /** + * Exceptional occurrences that are not errors + * + * Examples: Use of deprecated APIs, poor use of an API, + * undesirable things that are not necessarily wrong. + */ + const WARNING = 300; + + /** + * Runtime errors + */ + const ERROR = 400; + + /** + * Critical conditions + * + * Example: Application component unavailable, unexpected exception. + */ + const CRITICAL = 500; + + /** + * Action must be taken immediately + * + * Example: Entire website down, database unavailable, etc. + * This should trigger the SMS alerts and wake you up. + */ + const ALERT = 550; + + /** + * Urgent alert. + */ + const EMERGENCY = 600; + + /** + * Monolog API version + * + * This is only bumped when API breaks are done and should + * follow the major version of the library + * + * @var int + */ + const API = 1; + + /** + * Logging levels from syslog protocol defined in RFC 5424 + * + * @var array $levels Logging levels + */ + protected static $levels = array( + 100 => 'DEBUG', + 200 => 'INFO', + 250 => 'NOTICE', + 300 => 'WARNING', + 400 => 'ERROR', + 500 => 'CRITICAL', + 550 => 'ALERT', + 600 => 'EMERGENCY', + ); + + /** + * @var \DateTimeZone + */ + protected static $timezone; + + /** + * @var string + */ + protected $name; + + /** + * The handler stack + * + * @var HandlerInterface[] + */ + protected $handlers; + + /** + * Processors that will process all log records + * + * To process records of a single handler instead, add the processor on that specific handler + * + * @var callable[] + */ + protected $processors; + + /** + * @param string $name The logging channel + * @param HandlerInterface[] $handlers Optional stack of handlers, the first one in the array is called first, etc. + * @param callable[] $processors Optional array of processors + */ + public function __construct($name, array $handlers = array(), array $processors = array()) + { + $this->name = $name; + $this->handlers = $handlers; + $this->processors = $processors; + } + + /** + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Pushes a handler on to the stack. + * + * @param HandlerInterface $handler + */ + public function pushHandler(HandlerInterface $handler) + { + array_unshift($this->handlers, $handler); + } + + /** + * Pops a handler from the stack + * + * @return HandlerInterface + */ + public function popHandler() + { + if (!$this->handlers) { + throw new \LogicException('You tried to pop from an empty handler stack.'); + } + + return array_shift($this->handlers); + } + + /** + * Adds a processor on to the stack. + * + * @param callable $callback + */ + public function pushProcessor($callback) + { + if (!is_callable($callback)) { + throw new \InvalidArgumentException('Processors must be valid callables (callback or object with an __invoke method), '.var_export($callback, true).' given'); + } + array_unshift($this->processors, $callback); + } + + /** + * Removes the processor on top of the stack and returns it. + * + * @return callable + */ + public function popProcessor() + { + if (!$this->processors) { + throw new \LogicException('You tried to pop from an empty processor stack.'); + } + + return array_shift($this->processors); + } + + /** + * Adds a log record. + * + * @param integer $level The logging level + * @param string $message The log message + * @param array $context The log context + * @return Boolean Whether the record has been processed + */ + public function addRecord($level, $message, array $context = array()) + { + if (!$this->handlers) { + $this->pushHandler(new StreamHandler('php://stderr', static::DEBUG)); + } + + if (!static::$timezone) { + static::$timezone = new \DateTimeZone(date_default_timezone_get() ?: 'UTC'); + } + + $record = array( + 'message' => (string) $message, + 'context' => $context, + 'level' => $level, + 'level_name' => static::getLevelName($level), + 'channel' => $this->name, + 'datetime' => \DateTime::createFromFormat('U.u', sprintf('%.6F', microtime(true)), static::$timezone)->setTimezone(static::$timezone), + 'extra' => array(), + ); + // check if any handler will handle this message + $handlerKey = null; + foreach ($this->handlers as $key => $handler) { + if ($handler->isHandling($record)) { + $handlerKey = $key; + break; + } + } + // none found + if (null === $handlerKey) { + return false; + } + + // found at least one, process message and dispatch it + foreach ($this->processors as $processor) { + $record = call_user_func($processor, $record); + } + while (isset($this->handlers[$handlerKey]) && + false === $this->handlers[$handlerKey]->handle($record)) { + $handlerKey++; + } + + return true; + } + + /** + * Adds a log record at the DEBUG level. + * + * @param string $message The log message + * @param array $context The log context + * @return Boolean Whether the record has been processed + */ + public function addDebug($message, array $context = array()) + { + return $this->addRecord(static::DEBUG, $message, $context); + } + + /** + * Adds a log record at the INFO level. + * + * @param string $message The log message + * @param array $context The log context + * @return Boolean Whether the record has been processed + */ + public function addInfo($message, array $context = array()) + { + return $this->addRecord(static::INFO, $message, $context); + } + + /** + * Adds a log record at the NOTICE level. + * + * @param string $message The log message + * @param array $context The log context + * @return Boolean Whether the record has been processed + */ + public function addNotice($message, array $context = array()) + { + return $this->addRecord(static::NOTICE, $message, $context); + } + + /** + * Adds a log record at the WARNING level. + * + * @param string $message The log message + * @param array $context The log context + * @return Boolean Whether the record has been processed + */ + public function addWarning($message, array $context = array()) + { + return $this->addRecord(static::WARNING, $message, $context); + } + + /** + * Adds a log record at the ERROR level. + * + * @param string $message The log message + * @param array $context The log context + * @return Boolean Whether the record has been processed + */ + public function addError($message, array $context = array()) + { + return $this->addRecord(static::ERROR, $message, $context); + } + + /** + * Adds a log record at the CRITICAL level. + * + * @param string $message The log message + * @param array $context The log context + * @return Boolean Whether the record has been processed + */ + public function addCritical($message, array $context = array()) + { + return $this->addRecord(static::CRITICAL, $message, $context); + } + + /** + * Adds a log record at the ALERT level. + * + * @param string $message The log message + * @param array $context The log context + * @return Boolean Whether the record has been processed + */ + public function addAlert($message, array $context = array()) + { + return $this->addRecord(static::ALERT, $message, $context); + } + + /** + * Adds a log record at the EMERGENCY level. + * + * @param string $message The log message + * @param array $context The log context + * @return Boolean Whether the record has been processed + */ + public function addEmergency($message, array $context = array()) + { + return $this->addRecord(static::EMERGENCY, $message, $context); + } + + /** + * Gets all supported logging levels. + * + * @return array Assoc array with human-readable level names => level codes. + */ + public static function getLevels() + { + return array_flip(static::$levels); + } + + /** + * Gets the name of the logging level. + * + * @param integer $level + * @return string + */ + public static function getLevelName($level) + { + if (!isset(static::$levels[$level])) { + throw new InvalidArgumentException('Level "'.$level.'" is not defined, use one of: '.implode(', ', array_keys(static::$levels))); + } + + return static::$levels[$level]; + } + + /** + * Checks whether the Logger has a handler that listens on the given level + * + * @param integer $level + * @return Boolean + */ + public function isHandling($level) + { + $record = array( + 'level' => $level, + ); + + foreach ($this->handlers as $handler) { + if ($handler->isHandling($record)) { + return true; + } + } + + return false; + } + + /** + * Adds a log record at an arbitrary level. + * + * This method allows for compatibility with common interfaces. + * + * @param mixed $level The log level + * @param string $message The log message + * @param array $context The log context + * @return Boolean Whether the record has been processed + */ + public function log($level, $message, array $context = array()) + { + if (is_string($level) && defined(__CLASS__.'::'.strtoupper($level))) { + $level = constant(__CLASS__.'::'.strtoupper($level)); + } + + return $this->addRecord($level, $message, $context); + } + + /** + * Adds a log record at the DEBUG level. + * + * This method allows for compatibility with common interfaces. + * + * @param string $message The log message + * @param array $context The log context + * @return Boolean Whether the record has been processed + */ + public function debug($message, array $context = array()) + { + return $this->addRecord(static::DEBUG, $message, $context); + } + + /** + * Adds a log record at the INFO level. + * + * This method allows for compatibility with common interfaces. + * + * @param string $message The log message + * @param array $context The log context + * @return Boolean Whether the record has been processed + */ + public function info($message, array $context = array()) + { + return $this->addRecord(static::INFO, $message, $context); + } + + /** + * Adds a log record at the INFO level. + * + * This method allows for compatibility with common interfaces. + * + * @param string $message The log message + * @param array $context The log context + * @return Boolean Whether the record has been processed + */ + public function notice($message, array $context = array()) + { + return $this->addRecord(static::NOTICE, $message, $context); + } + + /** + * Adds a log record at the WARNING level. + * + * This method allows for compatibility with common interfaces. + * + * @param string $message The log message + * @param array $context The log context + * @return Boolean Whether the record has been processed + */ + public function warn($message, array $context = array()) + { + return $this->addRecord(static::WARNING, $message, $context); + } + + /** + * Adds a log record at the WARNING level. + * + * This method allows for compatibility with common interfaces. + * + * @param string $message The log message + * @param array $context The log context + * @return Boolean Whether the record has been processed + */ + public function warning($message, array $context = array()) + { + return $this->addRecord(static::WARNING, $message, $context); + } + + /** + * Adds a log record at the ERROR level. + * + * This method allows for compatibility with common interfaces. + * + * @param string $message The log message + * @param array $context The log context + * @return Boolean Whether the record has been processed + */ + public function err($message, array $context = array()) + { + return $this->addRecord(static::ERROR, $message, $context); + } + + /** + * Adds a log record at the ERROR level. + * + * This method allows for compatibility with common interfaces. + * + * @param string $message The log message + * @param array $context The log context + * @return Boolean Whether the record has been processed + */ + public function error($message, array $context = array()) + { + return $this->addRecord(static::ERROR, $message, $context); + } + + /** + * Adds a log record at the CRITICAL level. + * + * This method allows for compatibility with common interfaces. + * + * @param string $message The log message + * @param array $context The log context + * @return Boolean Whether the record has been processed + */ + public function crit($message, array $context = array()) + { + return $this->addRecord(static::CRITICAL, $message, $context); + } + + /** + * Adds a log record at the CRITICAL level. + * + * This method allows for compatibility with common interfaces. + * + * @param string $message The log message + * @param array $context The log context + * @return Boolean Whether the record has been processed + */ + public function critical($message, array $context = array()) + { + return $this->addRecord(static::CRITICAL, $message, $context); + } + + /** + * Adds a log record at the ALERT level. + * + * This method allows for compatibility with common interfaces. + * + * @param string $message The log message + * @param array $context The log context + * @return Boolean Whether the record has been processed + */ + public function alert($message, array $context = array()) + { + return $this->addRecord(static::ALERT, $message, $context); + } + + /** + * Adds a log record at the EMERGENCY level. + * + * This method allows for compatibility with common interfaces. + * + * @param string $message The log message + * @param array $context The log context + * @return Boolean Whether the record has been processed + */ + public function emerg($message, array $context = array()) + { + return $this->addRecord(static::EMERGENCY, $message, $context); + } + + /** + * Adds a log record at the EMERGENCY level. + * + * This method allows for compatibility with common interfaces. + * + * @param string $message The log message + * @param array $context The log context + * @return Boolean Whether the record has been processed + */ + public function emergency($message, array $context = array()) + { + return $this->addRecord(static::EMERGENCY, $message, $context); + } +} diff --git a/vendor/monolog/monolog/src/Monolog/Processor/GitProcessor.php b/vendor/monolog/monolog/src/Monolog/Processor/GitProcessor.php new file mode 100755 index 0000000..96c2abf --- /dev/null +++ b/vendor/monolog/monolog/src/Monolog/Processor/GitProcessor.php @@ -0,0 +1,64 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Processor; + +use Monolog\Logger; + +/** + * Injects Git branch and Git commit SHA in all records + * + * @author Nick Otter + * @author Jordi Boggiano + */ +class GitProcessor +{ + private $level; + private static $cache; + + public function __construct($level = Logger::DEBUG) + { + $this->level = $level; + } + + /** + * @param array $record + * @return array + */ + public function __invoke(array $record) + { + // return if the level is not high enough + if ($record['level'] < $this->level) { + return $record; + } + + $record['extra']['git'] = self::getGitInfo(); + + return $record; + } + + private static function getGitInfo() + { + if (self::$cache) { + return self::$cache; + } + + $branches = `git branch -v --no-abbrev`; + if (preg_match('{^\* (.+?)\s+([a-f0-9]{40})(?:\s|$)}m', $branches, $matches)) { + return self::$cache = array( + 'branch' => $matches[1], + 'commit' => $matches[2], + ); + } + + return self::$cache = array(); + } +} diff --git a/vendor/monolog/monolog/src/Monolog/Processor/IntrospectionProcessor.php b/vendor/monolog/monolog/src/Monolog/Processor/IntrospectionProcessor.php new file mode 100755 index 0000000..a2c48ce --- /dev/null +++ b/vendor/monolog/monolog/src/Monolog/Processor/IntrospectionProcessor.php @@ -0,0 +1,82 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Processor; + +use Monolog\Logger; + +/** + * Injects line/file:class/function where the log message came from + * + * Warning: This only works if the handler processes the logs directly. + * If you put the processor on a handler that is behind a FingersCrossedHandler + * for example, the processor will only be called once the trigger level is reached, + * and all the log records will have the same file/line/.. data from the call that + * triggered the FingersCrossedHandler. + * + * @author Jordi Boggiano + */ +class IntrospectionProcessor +{ + private $level; + + private $skipClassesPartials; + + public function __construct($level = Logger::DEBUG, array $skipClassesPartials = array('Monolog\\')) + { + $this->level = $level; + $this->skipClassesPartials = $skipClassesPartials; + } + + /** + * @param array $record + * @return array + */ + public function __invoke(array $record) + { + // return if the level is not high enough + if ($record['level'] < $this->level) { + return $record; + } + + $trace = debug_backtrace(); + + // skip first since it's always the current method + array_shift($trace); + // the call_user_func call is also skipped + array_shift($trace); + + $i = 0; + + while (isset($trace[$i]['class'])) { + foreach ($this->skipClassesPartials as $part) { + if (strpos($trace[$i]['class'], $part) !== false) { + $i++; + continue 2; + } + } + break; + } + + // we should have the call source now + $record['extra'] = array_merge( + $record['extra'], + array( + 'file' => isset($trace[$i-1]['file']) ? $trace[$i-1]['file'] : null, + 'line' => isset($trace[$i-1]['line']) ? $trace[$i-1]['line'] : null, + 'class' => isset($trace[$i]['class']) ? $trace[$i]['class'] : null, + 'function' => isset($trace[$i]['function']) ? $trace[$i]['function'] : null, + ) + ); + + return $record; + } +} diff --git a/vendor/monolog/monolog/src/Monolog/Processor/MemoryPeakUsageProcessor.php b/vendor/monolog/monolog/src/Monolog/Processor/MemoryPeakUsageProcessor.php new file mode 100755 index 0000000..552fd70 --- /dev/null +++ b/vendor/monolog/monolog/src/Monolog/Processor/MemoryPeakUsageProcessor.php @@ -0,0 +1,40 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Processor; + +/** + * Injects memory_get_peak_usage in all records + * + * @see Monolog\Processor\MemoryProcessor::__construct() for options + * @author Rob Jensen + */ +class MemoryPeakUsageProcessor extends MemoryProcessor +{ + /** + * @param array $record + * @return array + */ + public function __invoke(array $record) + { + $bytes = memory_get_peak_usage($this->realUsage); + $formatted = $this->formatBytes($bytes); + + $record['extra'] = array_merge( + $record['extra'], + array( + 'memory_peak_usage' => $formatted, + ) + ); + + return $record; + } +} diff --git a/vendor/monolog/monolog/src/Monolog/Processor/MemoryProcessor.php b/vendor/monolog/monolog/src/Monolog/Processor/MemoryProcessor.php new file mode 100755 index 0000000..7e53f47 --- /dev/null +++ b/vendor/monolog/monolog/src/Monolog/Processor/MemoryProcessor.php @@ -0,0 +1,64 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Processor; + +/** + * Some methods that are common for all memory processors + * + * @author Rob Jensen + */ +abstract class MemoryProcessor +{ + /** + * @var boolean If true, get the real size of memory allocated from system. Else, only the memory used by emalloc() is reported. + */ + protected $realUsage; + + /** + * @var boolean If true, then format memory size to human readable string (MB, KB, B depending on size) + */ + protected $useFormatting; + + /** + * @param boolean $realUsage Set this to true to get the real size of memory allocated from system. + * @param boolean $useFormatting If true, then format memory size to human readable string (MB, KB, B depending on size) + */ + public function __construct($realUsage = true, $useFormatting = true) + { + $this->realUsage = (boolean) $realUsage; + $this->useFormatting = (boolean) $useFormatting; + } + + /** + * Formats bytes into a human readable string if $this->useFormatting is true, otherwise return $bytes as is + * + * @param int $bytes + * @return string|int Formatted string if $this->useFormatting is true, otherwise return $bytes as is + */ + protected function formatBytes($bytes) + { + $bytes = (int) $bytes; + + if (!$this->useFormatting) { + return $bytes; + } + + if ($bytes > 1024*1024) { + return round($bytes/1024/1024, 2).' MB'; + } elseif ($bytes > 1024) { + return round($bytes/1024, 2).' KB'; + } + + return $bytes . ' B'; + } + +} diff --git a/vendor/monolog/monolog/src/Monolog/Processor/MemoryUsageProcessor.php b/vendor/monolog/monolog/src/Monolog/Processor/MemoryUsageProcessor.php new file mode 100755 index 0000000..0c4dd9a --- /dev/null +++ b/vendor/monolog/monolog/src/Monolog/Processor/MemoryUsageProcessor.php @@ -0,0 +1,40 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Processor; + +/** + * Injects memory_get_usage in all records + * + * @see Monolog\Processor\MemoryProcessor::__construct() for options + * @author Rob Jensen + */ +class MemoryUsageProcessor extends MemoryProcessor +{ + /** + * @param array $record + * @return array + */ + public function __invoke(array $record) + { + $bytes = memory_get_usage($this->realUsage); + $formatted = $this->formatBytes($bytes); + + $record['extra'] = array_merge( + $record['extra'], + array( + 'memory_usage' => $formatted, + ) + ); + + return $record; + } +} diff --git a/vendor/monolog/monolog/src/Monolog/Processor/ProcessIdProcessor.php b/vendor/monolog/monolog/src/Monolog/Processor/ProcessIdProcessor.php new file mode 100755 index 0000000..9d3f559 --- /dev/null +++ b/vendor/monolog/monolog/src/Monolog/Processor/ProcessIdProcessor.php @@ -0,0 +1,31 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Processor; + +/** + * Adds value of getmypid into records + * + * @author Andreas Hörnicke + */ +class ProcessIdProcessor +{ + /** + * @param array $record + * @return array + */ + public function __invoke(array $record) + { + $record['extra']['process_id'] = getmypid(); + + return $record; + } +} diff --git a/vendor/monolog/monolog/src/Monolog/Processor/PsrLogMessageProcessor.php b/vendor/monolog/monolog/src/Monolog/Processor/PsrLogMessageProcessor.php new file mode 100755 index 0000000..b63fccc --- /dev/null +++ b/vendor/monolog/monolog/src/Monolog/Processor/PsrLogMessageProcessor.php @@ -0,0 +1,42 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Processor; + +/** + * Processes a record's message according to PSR-3 rules + * + * It replaces {foo} with the value from $context['foo'] + * + * @author Jordi Boggiano + */ +class PsrLogMessageProcessor +{ + /** + * @param array $record + * @return array + */ + public function __invoke(array $record) + { + if (false === strpos($record['message'], '{')) { + return $record; + } + + $replacements = array(); + foreach ($record['context'] as $key => $val) { + $replacements['{'.$key.'}'] = $val; + } + + $record['message'] = strtr($record['message'], $replacements); + + return $record; + } +} diff --git a/vendor/monolog/monolog/src/Monolog/Processor/TagProcessor.php b/vendor/monolog/monolog/src/Monolog/Processor/TagProcessor.php new file mode 100755 index 0000000..2784cef --- /dev/null +++ b/vendor/monolog/monolog/src/Monolog/Processor/TagProcessor.php @@ -0,0 +1,34 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Processor; + +/** + * Adds a tags array into record + * + * @author Martijn Riemers + */ +class TagProcessor +{ + private $tags; + + public function __construct(array $tags = array()) + { + $this->tags = $tags; + } + + public function __invoke(array $record) + { + $record['extra']['tags'] = $this->tags; + + return $record; + } +} diff --git a/vendor/monolog/monolog/src/Monolog/Processor/UidProcessor.php b/vendor/monolog/monolog/src/Monolog/Processor/UidProcessor.php new file mode 100755 index 0000000..80270d0 --- /dev/null +++ b/vendor/monolog/monolog/src/Monolog/Processor/UidProcessor.php @@ -0,0 +1,38 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Processor; + +/** + * Adds a unique identifier into records + * + * @author Simon Mönch + */ +class UidProcessor +{ + private $uid; + + public function __construct($length = 7) + { + if (!is_int($length) || $length > 32 || $length < 1) { + throw new \InvalidArgumentException('The uid length must be an integer between 1 and 32'); + } + + $this->uid = substr(hash('md5', uniqid('', true)), 0, $length); + } + + public function __invoke(array $record) + { + $record['extra']['uid'] = $this->uid; + + return $record; + } +} diff --git a/vendor/monolog/monolog/src/Monolog/Processor/WebProcessor.php b/vendor/monolog/monolog/src/Monolog/Processor/WebProcessor.php new file mode 100755 index 0000000..4c2bc19 --- /dev/null +++ b/vendor/monolog/monolog/src/Monolog/Processor/WebProcessor.php @@ -0,0 +1,66 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Processor; + +/** + * Injects url/method and remote IP of the current web request in all records + * + * @author Jordi Boggiano + */ +class WebProcessor +{ + protected $serverData; + + /** + * @param mixed $serverData array or object w/ ArrayAccess that provides access to the $_SERVER data + */ + public function __construct($serverData = null) + { + if (null === $serverData) { + $this->serverData =& $_SERVER; + } elseif (is_array($serverData) || $serverData instanceof \ArrayAccess) { + $this->serverData = $serverData; + } else { + throw new \UnexpectedValueException('$serverData must be an array or object implementing ArrayAccess.'); + } + } + + /** + * @param array $record + * @return array + */ + public function __invoke(array $record) + { + // skip processing if for some reason request data + // is not present (CLI or wonky SAPIs) + if (!isset($this->serverData['REQUEST_URI'])) { + return $record; + } + + $record['extra'] = array_merge( + $record['extra'], + array( + 'url' => $this->serverData['REQUEST_URI'], + 'ip' => isset($this->serverData['REMOTE_ADDR']) ? $this->serverData['REMOTE_ADDR'] : null, + 'http_method' => isset($this->serverData['REQUEST_METHOD']) ? $this->serverData['REQUEST_METHOD'] : null, + 'server' => isset($this->serverData['SERVER_NAME']) ? $this->serverData['SERVER_NAME'] : null, + 'referrer' => isset($this->serverData['HTTP_REFERER']) ? $this->serverData['HTTP_REFERER'] : null, + ) + ); + + if (isset($this->serverData['UNIQUE_ID'])) { + $record['extra']['unique_id'] = $this->serverData['UNIQUE_ID']; + } + + return $record; + } +} diff --git a/vendor/monolog/monolog/src/Monolog/Registry.php b/vendor/monolog/monolog/src/Monolog/Registry.php new file mode 100755 index 0000000..a3eba07 --- /dev/null +++ b/vendor/monolog/monolog/src/Monolog/Registry.php @@ -0,0 +1,118 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog; + +use InvalidArgumentException; + +/** + * Monolog log registry + * + * Allows to get `Logger` instances in the global scope + * via static method calls on this class. + * + * + * $application = new Monolog\Logger('application'); + * $api = new Monolog\Logger('api'); + * + * Monolog\Registry::addLogger($application); + * Monolog\Registry::addLogger($api); + * + * function testLogger() + * { + * Monolog\Registry::api()->addError('Sent to $api Logger instance'); + * Monolog\Registry::application()->addError('Sent to $application Logger instance'); + * } + * + * + * @author Tomas Tatarko + */ +class Registry +{ + /** + * List of all loggers in the registry (ba named indexes) + * + * @var Logger[] + */ + private static $loggers = array(); + + /** + * Adds new logging channel to the registry + * + * @param Logger $logger Instance of the logging channel + * @param string|null $name Name of the logging channel ($logger->getName() by default) + * @param boolean $overwrite Overwrite instance in the registry if the given name already exists? + * @throws \InvalidArgumentException If $overwrite set to false and named Logger instance already exists + */ + public static function addLogger(Logger $logger, $name = null, $overwrite = false) + { + $name = $name ?: $logger->getName(); + + if (isset(self::$loggers[$name]) && !$overwrite) { + throw new InvalidArgumentException('Logger with the given name already exists'); + } + + self::$loggers[$name] = $logger; + } + + /** + * Removes instance from registry by name or instance + * + * @param string|Logger $logger Name or logger instance + */ + public static function removeLogger($logger) + { + if ($logger instanceof Logger) { + if (false !== ($idx = array_search($logger, self::$loggers, true))) { + unset(self::$loggers[$idx]); + } + } else { + unset(self::$loggers[$logger]); + } + } + + /** + * Clears the registry + */ + public static function clear() + { + self::$loggers = array(); + } + + /** + * Gets Logger instance from the registry + * + * @param string $name Name of the requested Logger instance + * @return Logger Requested instance of Logger + * @throws \InvalidArgumentException If named Logger instance is not in the registry + */ + public static function getInstance($name) + { + if (!isset(self::$loggers[$name])) { + throw new InvalidArgumentException(sprintf('Requested "%s" logger instance is not in the registry', $name)); + } + + return self::$loggers[$name]; + } + + /** + * Gets Logger instance from the registry via static method call + * + * @param string $name Name of the requested Logger instance + * @param array $arguments Arguments passed to static method call + * @return Logger Requested instance of Logger + * @throws \InvalidArgumentException If named Logger instance is not in the registry + */ + public static function __callStatic($name, $arguments) + { + return self::getInstance($name); + } +} diff --git a/vendor/monolog/monolog/tests/Monolog/ErrorHandlerTest.php b/vendor/monolog/monolog/tests/Monolog/ErrorHandlerTest.php new file mode 100755 index 0000000..a9a3f30 --- /dev/null +++ b/vendor/monolog/monolog/tests/Monolog/ErrorHandlerTest.php @@ -0,0 +1,31 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog; + +use Monolog\Handler\TestHandler; + +class ErrorHandlerTest extends \PHPUnit_Framework_TestCase +{ + public function testHandleError() + { + $logger = new Logger('test', array($handler = new TestHandler)); + $errHandler = new ErrorHandler($logger); + + $errHandler->registerErrorHandler(array(E_USER_NOTICE => Logger::EMERGENCY), false); + trigger_error('Foo', E_USER_ERROR); + $this->assertCount(1, $handler->getRecords()); + $this->assertTrue($handler->hasErrorRecords()); + trigger_error('Foo', E_USER_NOTICE); + $this->assertCount(2, $handler->getRecords()); + $this->assertTrue($handler->hasEmergencyRecords()); + } +} diff --git a/vendor/monolog/monolog/tests/Monolog/Formatter/ChromePHPFormatterTest.php b/vendor/monolog/monolog/tests/Monolog/Formatter/ChromePHPFormatterTest.php new file mode 100755 index 0000000..e7f7334 --- /dev/null +++ b/vendor/monolog/monolog/tests/Monolog/Formatter/ChromePHPFormatterTest.php @@ -0,0 +1,158 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Formatter; + +use Monolog\Logger; + +class ChromePHPFormatterTest extends \PHPUnit_Framework_TestCase +{ + /** + * @covers Monolog\Formatter\ChromePHPFormatter::format + */ + public function testDefaultFormat() + { + $formatter = new ChromePHPFormatter(); + $record = array( + 'level' => Logger::ERROR, + 'level_name' => 'ERROR', + 'channel' => 'meh', + 'context' => array('from' => 'logger'), + 'datetime' => new \DateTime("@0"), + 'extra' => array('ip' => '127.0.0.1'), + 'message' => 'log', + ); + + $message = $formatter->format($record); + + $this->assertEquals( + array( + 'meh', + array( + 'message' => 'log', + 'context' => array('from' => 'logger'), + 'extra' => array('ip' => '127.0.0.1'), + ), + 'unknown', + 'error' + ), + $message + ); + } + + /** + * @covers Monolog\Formatter\ChromePHPFormatter::format + */ + public function testFormatWithFileAndLine() + { + $formatter = new ChromePHPFormatter(); + $record = array( + 'level' => Logger::CRITICAL, + 'level_name' => 'CRITICAL', + 'channel' => 'meh', + 'context' => array('from' => 'logger'), + 'datetime' => new \DateTime("@0"), + 'extra' => array('ip' => '127.0.0.1', 'file' => 'test', 'line' => 14), + 'message' => 'log', + ); + + $message = $formatter->format($record); + + $this->assertEquals( + array( + 'meh', + array( + 'message' => 'log', + 'context' => array('from' => 'logger'), + 'extra' => array('ip' => '127.0.0.1'), + ), + 'test : 14', + 'error' + ), + $message + ); + } + + /** + * @covers Monolog\Formatter\ChromePHPFormatter::format + */ + public function testFormatWithoutContext() + { + $formatter = new ChromePHPFormatter(); + $record = array( + 'level' => Logger::DEBUG, + 'level_name' => 'DEBUG', + 'channel' => 'meh', + 'context' => array(), + 'datetime' => new \DateTime("@0"), + 'extra' => array(), + 'message' => 'log', + ); + + $message = $formatter->format($record); + + $this->assertEquals( + array( + 'meh', + 'log', + 'unknown', + 'log' + ), + $message + ); + } + + /** + * @covers Monolog\Formatter\ChromePHPFormatter::formatBatch + */ + public function testBatchFormatThrowException() + { + $formatter = new ChromePHPFormatter(); + $records = array( + array( + 'level' => Logger::INFO, + 'level_name' => 'INFO', + 'channel' => 'meh', + 'context' => array(), + 'datetime' => new \DateTime("@0"), + 'extra' => array(), + 'message' => 'log', + ), + array( + 'level' => Logger::WARNING, + 'level_name' => 'WARNING', + 'channel' => 'foo', + 'context' => array(), + 'datetime' => new \DateTime("@0"), + 'extra' => array(), + 'message' => 'log2', + ), + ); + + $this->assertEquals( + array( + array( + 'meh', + 'log', + 'unknown', + 'info' + ), + array( + 'foo', + 'log2', + 'unknown', + 'warn' + ), + ), + $formatter->formatBatch($records) + ); + } +} diff --git a/vendor/monolog/monolog/tests/Monolog/Formatter/ElasticaFormatterTest.php b/vendor/monolog/monolog/tests/Monolog/Formatter/ElasticaFormatterTest.php new file mode 100755 index 0000000..546e5c2 --- /dev/null +++ b/vendor/monolog/monolog/tests/Monolog/Formatter/ElasticaFormatterTest.php @@ -0,0 +1,79 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Formatter; + +use Monolog\Logger; + +class ElasticaFormatterTest extends \PHPUnit_Framework_TestCase +{ + public function setUp() + { + if (!class_exists("Elastica\Document")) { + $this->markTestSkipped("ruflin/elastica not installed"); + } + } + + /** + * @covers Monolog\Formatter\ElasticaFormatter::__construct + * @covers Monolog\Formatter\ElasticaFormatter::format + * @covers Monolog\Formatter\ElasticaFormatter::getDocument + */ + public function testFormat() + { + // test log message + $msg = array( + 'level' => Logger::ERROR, + 'level_name' => 'ERROR', + 'channel' => 'meh', + 'context' => array('foo' => 7, 'bar', 'class' => new \stdClass), + 'datetime' => new \DateTime("@0"), + 'extra' => array(), + 'message' => 'log', + ); + + // expected values + $expected = $msg; + $expected['datetime'] = '1970-01-01T00:00:00+0000'; + $expected['context'] = array( + 'class' => '[object] (stdClass: {})', + 'foo' => 7, + 0 => 'bar', + ); + + // format log message + $formatter = new ElasticaFormatter('my_index', 'doc_type'); + $doc = $formatter->format($msg); + $this->assertInstanceOf('Elastica\Document', $doc); + + // Document parameters + $params = $doc->getParams(); + $this->assertEquals('my_index', $params['_index']); + $this->assertEquals('doc_type', $params['_type']); + + // Document data values + $data = $doc->getData(); + foreach (array_keys($expected) as $key) { + $this->assertEquals($expected[$key], $data[$key]); + } + } + + /** + * @covers Monolog\Formatter\ElasticaFormatter::getIndex + * @covers Monolog\Formatter\ElasticaFormatter::getType + */ + public function testGetters() + { + $formatter = new ElasticaFormatter('my_index', 'doc_type'); + $this->assertEquals('my_index', $formatter->getIndex()); + $this->assertEquals('doc_type', $formatter->getType()); + } +} diff --git a/vendor/monolog/monolog/tests/Monolog/Formatter/FlowdockFormatterTest.php b/vendor/monolog/monolog/tests/Monolog/Formatter/FlowdockFormatterTest.php new file mode 100755 index 0000000..1b2fd97 --- /dev/null +++ b/vendor/monolog/monolog/tests/Monolog/Formatter/FlowdockFormatterTest.php @@ -0,0 +1,55 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Formatter; + +use Monolog\Logger; +use Monolog\TestCase; + +class FlowdockFormatterTest extends TestCase +{ + /** + * @covers Monolog\Formatter\FlowdockFormatter::format + */ + public function testFormat() + { + $formatter = new FlowdockFormatter('test_source', 'source@test.com'); + $record = $this->getRecord(); + + $expected = array( + 'source' => 'test_source', + 'from_address' => 'source@test.com', + 'subject' => 'in test_source: WARNING - test', + 'content' => 'test', + 'tags' => array('#logs', '#warning', '#test'), + 'project' => 'test_source', + ); + $formatted = $formatter->format($record); + + $this->assertEquals($expected, $formatted['flowdock']); + } + + /** + * @ covers Monolog\Formatter\FlowdockFormatter::formatBatch + */ + public function testFormatBatch() + { + $formatter = new FlowdockFormatter('test_source', 'source@test.com'); + $records = array( + $this->getRecord(Logger::WARNING), + $this->getRecord(Logger::DEBUG), + ); + $formatted = $formatter->formatBatch($records); + + $this->assertArrayHasKey('flowdock', $formatted[0]); + $this->assertArrayHasKey('flowdock', $formatted[1]); + } +} diff --git a/vendor/monolog/monolog/tests/Monolog/Formatter/GelfMessageFormatterTest.php b/vendor/monolog/monolog/tests/Monolog/Formatter/GelfMessageFormatterTest.php new file mode 100755 index 0000000..d47ba91 --- /dev/null +++ b/vendor/monolog/monolog/tests/Monolog/Formatter/GelfMessageFormatterTest.php @@ -0,0 +1,191 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Formatter; + +use Monolog\Logger; + +class GelfMessageFormatterTest extends \PHPUnit_Framework_TestCase +{ + public function setUp() + { + if (!class_exists('\Gelf\Message')) { + $this->markTestSkipped("graylog2/gelf-php or mlehner/gelf-php is not installed"); + } + } + + /** + * @covers Monolog\Formatter\GelfMessageFormatter::format + */ + public function testDefaultFormatter() + { + $formatter = new GelfMessageFormatter(); + $record = array( + 'level' => Logger::ERROR, + 'level_name' => 'ERROR', + 'channel' => 'meh', + 'context' => array(), + 'datetime' => new \DateTime("@0"), + 'extra' => array(), + 'message' => 'log', + ); + + $message = $formatter->format($record); + + $this->assertInstanceOf('Gelf\Message', $message); + $this->assertEquals(0, $message->getTimestamp()); + $this->assertEquals('log', $message->getShortMessage()); + $this->assertEquals('meh', $message->getFacility()); + $this->assertEquals(null, $message->getLine()); + $this->assertEquals(null, $message->getFile()); + $this->assertEquals($this->isLegacy() ? 3 : 'error', $message->getLevel()); + $this->assertNotEmpty($message->getHost()); + + $formatter = new GelfMessageFormatter('mysystem'); + + $message = $formatter->format($record); + + $this->assertInstanceOf('Gelf\Message', $message); + $this->assertEquals('mysystem', $message->getHost()); + } + + /** + * @covers Monolog\Formatter\GelfMessageFormatter::format + */ + public function testFormatWithFileAndLine() + { + $formatter = new GelfMessageFormatter(); + $record = array( + 'level' => Logger::ERROR, + 'level_name' => 'ERROR', + 'channel' => 'meh', + 'context' => array('from' => 'logger'), + 'datetime' => new \DateTime("@0"), + 'extra' => array('file' => 'test', 'line' => 14), + 'message' => 'log', + ); + + $message = $formatter->format($record); + + $this->assertInstanceOf('Gelf\Message', $message); + $this->assertEquals('test', $message->getFile()); + $this->assertEquals(14, $message->getLine()); + } + + /** + * @covers Monolog\Formatter\GelfMessageFormatter::format + */ + public function testFormatWithContext() + { + $formatter = new GelfMessageFormatter(); + $record = array( + 'level' => Logger::ERROR, + 'level_name' => 'ERROR', + 'channel' => 'meh', + 'context' => array('from' => 'logger'), + 'datetime' => new \DateTime("@0"), + 'extra' => array('key' => 'pair'), + 'message' => 'log' + ); + + $message = $formatter->format($record); + + $this->assertInstanceOf('Gelf\Message', $message); + + $message_array = $message->toArray(); + + $this->assertArrayHasKey('_ctxt_from', $message_array); + $this->assertEquals('logger', $message_array['_ctxt_from']); + + // Test with extraPrefix + $formatter = new GelfMessageFormatter(null, null, 'CTX'); + $message = $formatter->format($record); + + $this->assertInstanceOf('Gelf\Message', $message); + + $message_array = $message->toArray(); + + $this->assertArrayHasKey('_CTXfrom', $message_array); + $this->assertEquals('logger', $message_array['_CTXfrom']); + + } + + /** + * @covers Monolog\Formatter\GelfMessageFormatter::format + */ + public function testFormatWithContextContainingException() + { + $formatter = new GelfMessageFormatter(); + $record = array( + 'level' => Logger::ERROR, + 'level_name' => 'ERROR', + 'channel' => 'meh', + 'context' => array('from' => 'logger', 'exception' => array( + 'class' => '\Exception', + 'file' => '/some/file/in/dir.php:56', + 'trace' => array('/some/file/1.php:23', '/some/file/2.php:3') + )), + 'datetime' => new \DateTime("@0"), + 'extra' => array(), + 'message' => 'log' + ); + + $message = $formatter->format($record); + + $this->assertInstanceOf('Gelf\Message', $message); + + $this->assertEquals("/some/file/in/dir.php", $message->getFile()); + $this->assertEquals("56", $message->getLine()); + + } + + /** + * @covers Monolog\Formatter\GelfMessageFormatter::format + */ + public function testFormatWithExtra() + { + $formatter = new GelfMessageFormatter(); + $record = array( + 'level' => Logger::ERROR, + 'level_name' => 'ERROR', + 'channel' => 'meh', + 'context' => array('from' => 'logger'), + 'datetime' => new \DateTime("@0"), + 'extra' => array('key' => 'pair'), + 'message' => 'log' + ); + + $message = $formatter->format($record); + + $this->assertInstanceOf('Gelf\Message', $message); + + $message_array = $message->toArray(); + + $this->assertArrayHasKey('_key', $message_array); + $this->assertEquals('pair', $message_array['_key']); + + // Test with extraPrefix + $formatter = new GelfMessageFormatter(null, 'EXT'); + $message = $formatter->format($record); + + $this->assertInstanceOf('Gelf\Message', $message); + + $message_array = $message->toArray(); + + $this->assertArrayHasKey('_EXTkey', $message_array); + $this->assertEquals('pair', $message_array['_EXTkey']); + } + + private function isLegacy() + { + return interface_exists('\Gelf\IMessagePublisher'); + } +} diff --git a/vendor/monolog/monolog/tests/Monolog/Formatter/JsonFormatterTest.php b/vendor/monolog/monolog/tests/Monolog/Formatter/JsonFormatterTest.php new file mode 100755 index 0000000..d18c476 --- /dev/null +++ b/vendor/monolog/monolog/tests/Monolog/Formatter/JsonFormatterTest.php @@ -0,0 +1,79 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Formatter; + +use Monolog\Logger; +use Monolog\TestCase; + +class JsonFormatterTest extends TestCase +{ + /** + * @covers Monolog\Formatter\JsonFormatter::__construct + * @covers Monolog\Formatter\JsonFormatter::getBatchMode + * @covers Monolog\Formatter\JsonFormatter::isAppendingNewlines + */ + public function testConstruct() + { + $formatter = new JsonFormatter(); + $this->assertEquals(JsonFormatter::BATCH_MODE_JSON, $formatter->getBatchMode()); + $this->assertEquals(true, $formatter->isAppendingNewlines()); + $formatter = new JsonFormatter(JsonFormatter::BATCH_MODE_NEWLINES, false); + $this->assertEquals(JsonFormatter::BATCH_MODE_NEWLINES, $formatter->getBatchMode()); + $this->assertEquals(false, $formatter->isAppendingNewlines()); + } + + /** + * @covers Monolog\Formatter\JsonFormatter::format + */ + public function testFormat() + { + $formatter = new JsonFormatter(); + $record = $this->getRecord(); + $this->assertEquals(json_encode($record)."\n", $formatter->format($record)); + + $formatter = new JsonFormatter(JsonFormatter::BATCH_MODE_JSON, false); + $record = $this->getRecord(); + $this->assertEquals(json_encode($record), $formatter->format($record)); + } + + /** + * @covers Monolog\Formatter\JsonFormatter::formatBatch + * @covers Monolog\Formatter\JsonFormatter::formatBatchJson + */ + public function testFormatBatch() + { + $formatter = new JsonFormatter(); + $records = array( + $this->getRecord(Logger::WARNING), + $this->getRecord(Logger::DEBUG), + ); + $this->assertEquals(json_encode($records), $formatter->formatBatch($records)); + } + + /** + * @covers Monolog\Formatter\JsonFormatter::formatBatch + * @covers Monolog\Formatter\JsonFormatter::formatBatchNewlines + */ + public function testFormatBatchNewlines() + { + + $formatter = new JsonFormatter(JsonFormatter::BATCH_MODE_NEWLINES); + $records = $expected = array( + $this->getRecord(Logger::WARNING), + $this->getRecord(Logger::DEBUG), + ); + array_walk($expected, function (&$value, $key) { + $value = json_encode($value); + }); + $this->assertEquals(implode("\n", $expected), $formatter->formatBatch($records)); + } +} diff --git a/vendor/monolog/monolog/tests/Monolog/Formatter/LineFormatterTest.php b/vendor/monolog/monolog/tests/Monolog/Formatter/LineFormatterTest.php new file mode 100755 index 0000000..096e564 --- /dev/null +++ b/vendor/monolog/monolog/tests/Monolog/Formatter/LineFormatterTest.php @@ -0,0 +1,194 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Formatter; + +/** + * @covers Monolog\Formatter\LineFormatter + */ +class LineFormatterTest extends \PHPUnit_Framework_TestCase +{ + public function testDefFormatWithString() + { + $formatter = new LineFormatter(null, 'Y-m-d'); + $message = $formatter->format(array( + 'level_name' => 'WARNING', + 'channel' => 'log', + 'context' => array(), + 'message' => 'foo', + 'datetime' => new \DateTime, + 'extra' => array(), + )); + $this->assertEquals('['.date('Y-m-d').'] log.WARNING: foo [] []'."\n", $message); + } + + public function testDefFormatWithArrayContext() + { + $formatter = new LineFormatter(null, 'Y-m-d'); + $message = $formatter->format(array( + 'level_name' => 'ERROR', + 'channel' => 'meh', + 'message' => 'foo', + 'datetime' => new \DateTime, + 'extra' => array(), + 'context' => array( + 'foo' => 'bar', + 'baz' => 'qux', + 'bool' => false, + 'null' => null, + ) + )); + $this->assertEquals('['.date('Y-m-d').'] meh.ERROR: foo {"foo":"bar","baz":"qux","bool":false,"null":null} []'."\n", $message); + } + + public function testDefFormatExtras() + { + $formatter = new LineFormatter(null, 'Y-m-d'); + $message = $formatter->format(array( + 'level_name' => 'ERROR', + 'channel' => 'meh', + 'context' => array(), + 'datetime' => new \DateTime, + 'extra' => array('ip' => '127.0.0.1'), + 'message' => 'log', + )); + $this->assertEquals('['.date('Y-m-d').'] meh.ERROR: log [] {"ip":"127.0.0.1"}'."\n", $message); + } + + public function testFormatExtras() + { + $formatter = new LineFormatter("[%datetime%] %channel%.%level_name%: %message% %context% %extra.file% %extra%\n", 'Y-m-d'); + $message = $formatter->format(array( + 'level_name' => 'ERROR', + 'channel' => 'meh', + 'context' => array(), + 'datetime' => new \DateTime, + 'extra' => array('ip' => '127.0.0.1', 'file' => 'test'), + 'message' => 'log', + )); + $this->assertEquals('['.date('Y-m-d').'] meh.ERROR: log [] test {"ip":"127.0.0.1"}'."\n", $message); + } + + public function testDefFormatWithObject() + { + $formatter = new LineFormatter(null, 'Y-m-d'); + $message = $formatter->format(array( + 'level_name' => 'ERROR', + 'channel' => 'meh', + 'context' => array(), + 'datetime' => new \DateTime, + 'extra' => array('foo' => new TestFoo, 'bar' => new TestBar, 'baz' => array(), 'res' => fopen('php://memory', 'rb')), + 'message' => 'foobar', + )); + + $this->assertEquals('['.date('Y-m-d').'] meh.ERROR: foobar [] {"foo":"[object] (Monolog\\\\Formatter\\\\TestFoo: {\\"foo\\":\\"foo\\"})","bar":"[object] (Monolog\\\\Formatter\\\\TestBar: {})","baz":[],"res":"[resource]"}'."\n", $message); + } + + public function testDefFormatWithException() + { + $formatter = new LineFormatter(null, 'Y-m-d'); + $message = $formatter->format(array( + 'level_name' => 'CRITICAL', + 'channel' => 'core', + 'context' => array('exception' => new \RuntimeException('Foo')), + 'datetime' => new \DateTime, + 'extra' => array(), + 'message' => 'foobar', + )); + + $path = str_replace('\\/', '/', json_encode(__FILE__)); + + $this->assertEquals('['.date('Y-m-d').'] core.CRITICAL: foobar {"exception":"[object] (RuntimeException: Foo at '.substr($path, 1, -1).':'.(__LINE__-8).')"} []'."\n", $message); + } + + public function testDefFormatWithPreviousException() + { + $formatter = new LineFormatter(null, 'Y-m-d'); + $previous = new \LogicException('Wut?'); + $message = $formatter->format(array( + 'level_name' => 'CRITICAL', + 'channel' => 'core', + 'context' => array('exception' => new \RuntimeException('Foo', 0, $previous)), + 'datetime' => new \DateTime, + 'extra' => array(), + 'message' => 'foobar', + )); + + $path = str_replace('\\/', '/', json_encode(__FILE__)); + + $this->assertEquals('['.date('Y-m-d').'] core.CRITICAL: foobar {"exception":"[object] (RuntimeException: Foo at '.substr($path, 1, -1).':'.(__LINE__-8).', LogicException: Wut? at '.substr($path, 1, -1).':'.(__LINE__-12).')"} []'."\n", $message); + } + + public function testBatchFormat() + { + $formatter = new LineFormatter(null, 'Y-m-d'); + $message = $formatter->formatBatch(array( + array( + 'level_name' => 'CRITICAL', + 'channel' => 'test', + 'message' => 'bar', + 'context' => array(), + 'datetime' => new \DateTime, + 'extra' => array(), + ), + array( + 'level_name' => 'WARNING', + 'channel' => 'log', + 'message' => 'foo', + 'context' => array(), + 'datetime' => new \DateTime, + 'extra' => array(), + ), + )); + $this->assertEquals('['.date('Y-m-d').'] test.CRITICAL: bar [] []'."\n".'['.date('Y-m-d').'] log.WARNING: foo [] []'."\n", $message); + } + + public function testFormatShouldStripInlineLineBreaks() + { + $formatter = new LineFormatter(null, 'Y-m-d'); + $message = $formatter->format( + array( + 'message' => "foo\nbar", + 'context' => array(), + 'extra' => array(), + ) + ); + + $this->assertRegExp('/foo bar/', $message); + } + + public function testFormatShouldNotStripInlineLineBreaksWhenFlagIsSet() + { + $formatter = new LineFormatter(null, 'Y-m-d', true); + $message = $formatter->format( + array( + 'message' => "foo\nbar", + 'context' => array(), + 'extra' => array(), + ) + ); + + $this->assertRegExp('/foo\nbar/', $message); + } +} + +class TestFoo +{ + public $foo = 'foo'; +} + +class TestBar +{ + public function __toString() + { + return 'bar'; + } +} diff --git a/vendor/monolog/monolog/tests/Monolog/Formatter/LogglyFormatterTest.php b/vendor/monolog/monolog/tests/Monolog/Formatter/LogglyFormatterTest.php new file mode 100755 index 0000000..6d59b3f --- /dev/null +++ b/vendor/monolog/monolog/tests/Monolog/Formatter/LogglyFormatterTest.php @@ -0,0 +1,40 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Formatter; + +use Monolog\TestCase; + +class LogglyFormatterTest extends TestCase +{ + /** + * @covers Monolog\Formatter\LogglyFormatter::__construct + */ + public function testConstruct() + { + $formatter = new LogglyFormatter(); + $this->assertEquals(LogglyFormatter::BATCH_MODE_NEWLINES, $formatter->getBatchMode()); + $formatter = new LogglyFormatter(LogglyFormatter::BATCH_MODE_JSON); + $this->assertEquals(LogglyFormatter::BATCH_MODE_JSON, $formatter->getBatchMode()); + } + + /** + * @covers Monolog\Formatter\LogglyFormatter::format + */ + public function testFormat() + { + $formatter = new LogglyFormatter(); + $record = $this->getRecord(); + $formatted_decoded = json_decode($formatter->format($record), true); + $this->assertArrayHasKey("timestamp", $formatted_decoded); + $this->assertEquals(new \DateTime($formatted_decoded["timestamp"]), $record["datetime"]); + } +} diff --git a/vendor/monolog/monolog/tests/Monolog/Formatter/LogstashFormatterTest.php b/vendor/monolog/monolog/tests/Monolog/Formatter/LogstashFormatterTest.php new file mode 100755 index 0000000..5776ab7 --- /dev/null +++ b/vendor/monolog/monolog/tests/Monolog/Formatter/LogstashFormatterTest.php @@ -0,0 +1,292 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Formatter; + +use Monolog\Logger; + +class LogstashFormatterTest extends \PHPUnit_Framework_TestCase +{ + + /** + * @covers Monolog\Formatter\LogstashFormatter::format + */ + public function testDefaultFormatter() + { + $formatter = new LogstashFormatter('test', 'hostname'); + $record = array( + 'level' => Logger::ERROR, + 'level_name' => 'ERROR', + 'channel' => 'meh', + 'context' => array(), + 'datetime' => new \DateTime("@0"), + 'extra' => array(), + 'message' => 'log', + ); + + $message = json_decode($formatter->format($record), true); + + $this->assertEquals("1970-01-01T00:00:00.000000+00:00", $message['@timestamp']); + $this->assertEquals('log', $message['@message']); + $this->assertEquals('meh', $message['@fields']['channel']); + $this->assertContains('meh', $message['@tags']); + $this->assertEquals(Logger::ERROR, $message['@fields']['level']); + $this->assertEquals('test', $message['@type']); + $this->assertEquals('hostname', $message['@source']); + + $formatter = new LogstashFormatter('mysystem'); + + $message = json_decode($formatter->format($record), true); + + $this->assertEquals('mysystem', $message['@type']); + } + + /** + * @covers Monolog\Formatter\LogstashFormatter::format + */ + public function testFormatWithFileAndLine() + { + $formatter = new LogstashFormatter('test'); + $record = array( + 'level' => Logger::ERROR, + 'level_name' => 'ERROR', + 'channel' => 'meh', + 'context' => array('from' => 'logger'), + 'datetime' => new \DateTime("@0"), + 'extra' => array('file' => 'test', 'line' => 14), + 'message' => 'log', + ); + + $message = json_decode($formatter->format($record), true); + + $this->assertEquals('test', $message['@fields']['file']); + $this->assertEquals(14, $message['@fields']['line']); + } + + /** + * @covers Monolog\Formatter\LogstashFormatter::format + */ + public function testFormatWithContext() + { + $formatter = new LogstashFormatter('test'); + $record = array( + 'level' => Logger::ERROR, + 'level_name' => 'ERROR', + 'channel' => 'meh', + 'context' => array('from' => 'logger'), + 'datetime' => new \DateTime("@0"), + 'extra' => array('key' => 'pair'), + 'message' => 'log' + ); + + $message = json_decode($formatter->format($record), true); + + $message_array = $message['@fields']; + + $this->assertArrayHasKey('ctxt_from', $message_array); + $this->assertEquals('logger', $message_array['ctxt_from']); + + // Test with extraPrefix + $formatter = new LogstashFormatter('test', null, null, 'CTX'); + $message = json_decode($formatter->format($record), true); + + $message_array = $message['@fields']; + + $this->assertArrayHasKey('CTXfrom', $message_array); + $this->assertEquals('logger', $message_array['CTXfrom']); + + } + + /** + * @covers Monolog\Formatter\LogstashFormatter::format + */ + public function testFormatWithExtra() + { + $formatter = new LogstashFormatter('test'); + $record = array( + 'level' => Logger::ERROR, + 'level_name' => 'ERROR', + 'channel' => 'meh', + 'context' => array('from' => 'logger'), + 'datetime' => new \DateTime("@0"), + 'extra' => array('key' => 'pair'), + 'message' => 'log' + ); + + $message = json_decode($formatter->format($record), true); + + $message_array = $message['@fields']; + + $this->assertArrayHasKey('key', $message_array); + $this->assertEquals('pair', $message_array['key']); + + // Test with extraPrefix + $formatter = new LogstashFormatter('test', null, 'EXT'); + $message = json_decode($formatter->format($record), true); + + $message_array = $message['@fields']; + + $this->assertArrayHasKey('EXTkey', $message_array); + $this->assertEquals('pair', $message_array['EXTkey']); + } + + public function testFormatWithApplicationName() + { + $formatter = new LogstashFormatter('app', 'test'); + $record = array( + 'level' => Logger::ERROR, + 'level_name' => 'ERROR', + 'channel' => 'meh', + 'context' => array('from' => 'logger'), + 'datetime' => new \DateTime("@0"), + 'extra' => array('key' => 'pair'), + 'message' => 'log' + ); + + $message = json_decode($formatter->format($record), true); + + $this->assertArrayHasKey('@type', $message); + $this->assertEquals('app', $message['@type']); + } + + /** + * @covers Monolog\Formatter\LogstashFormatter::format + */ + public function testDefaultFormatterV1() + { + $formatter = new LogstashFormatter('test', 'hostname', null, 'ctxt_', LogstashFormatter::V1); + $record = array( + 'level' => Logger::ERROR, + 'level_name' => 'ERROR', + 'channel' => 'meh', + 'context' => array(), + 'datetime' => new \DateTime("@0"), + 'extra' => array(), + 'message' => 'log', + ); + + $message = json_decode($formatter->format($record), true); + + $this->assertEquals("1970-01-01T00:00:00.000000+00:00", $message['@timestamp']); + $this->assertEquals("1", $message['@version']); + $this->assertEquals('log', $message['message']); + $this->assertEquals('meh', $message['channel']); + $this->assertEquals('ERROR', $message['level']); + $this->assertEquals('test', $message['type']); + $this->assertEquals('hostname', $message['host']); + + $formatter = new LogstashFormatter('mysystem', null, null, 'ctxt_', LogstashFormatter::V1); + + $message = json_decode($formatter->format($record), true); + + $this->assertEquals('mysystem', $message['type']); + } + + /** + * @covers Monolog\Formatter\LogstashFormatter::format + */ + public function testFormatWithFileAndLineV1() + { + $formatter = new LogstashFormatter('test', null, null, 'ctxt_', LogstashFormatter::V1); + $record = array( + 'level' => Logger::ERROR, + 'level_name' => 'ERROR', + 'channel' => 'meh', + 'context' => array('from' => 'logger'), + 'datetime' => new \DateTime("@0"), + 'extra' => array('file' => 'test', 'line' => 14), + 'message' => 'log', + ); + + $message = json_decode($formatter->format($record), true); + + $this->assertEquals('test', $message['file']); + $this->assertEquals(14, $message['line']); + } + + /** + * @covers Monolog\Formatter\LogstashFormatter::format + */ + public function testFormatWithContextV1() + { + $formatter = new LogstashFormatter('test', null, null, 'ctxt_', LogstashFormatter::V1); + $record = array( + 'level' => Logger::ERROR, + 'level_name' => 'ERROR', + 'channel' => 'meh', + 'context' => array('from' => 'logger'), + 'datetime' => new \DateTime("@0"), + 'extra' => array('key' => 'pair'), + 'message' => 'log' + ); + + $message = json_decode($formatter->format($record), true); + + $this->assertArrayHasKey('ctxt_from', $message); + $this->assertEquals('logger', $message['ctxt_from']); + + // Test with extraPrefix + $formatter = new LogstashFormatter('test', null, null, 'CTX', LogstashFormatter::V1); + $message = json_decode($formatter->format($record), true); + + $this->assertArrayHasKey('CTXfrom', $message); + $this->assertEquals('logger', $message['CTXfrom']); + + } + + /** + * @covers Monolog\Formatter\LogstashFormatter::format + */ + public function testFormatWithExtraV1() + { + $formatter = new LogstashFormatter('test', null, null, 'ctxt_', LogstashFormatter::V1); + $record = array( + 'level' => Logger::ERROR, + 'level_name' => 'ERROR', + 'channel' => 'meh', + 'context' => array('from' => 'logger'), + 'datetime' => new \DateTime("@0"), + 'extra' => array('key' => 'pair'), + 'message' => 'log' + ); + + $message = json_decode($formatter->format($record), true); + + $this->assertArrayHasKey('key', $message); + $this->assertEquals('pair', $message['key']); + + // Test with extraPrefix + $formatter = new LogstashFormatter('test', null, 'EXT', 'ctxt_', LogstashFormatter::V1); + $message = json_decode($formatter->format($record), true); + + $this->assertArrayHasKey('EXTkey', $message); + $this->assertEquals('pair', $message['EXTkey']); + } + + public function testFormatWithApplicationNameV1() + { + $formatter = new LogstashFormatter('app', 'test', null, 'ctxt_', LogstashFormatter::V1); + $record = array( + 'level' => Logger::ERROR, + 'level_name' => 'ERROR', + 'channel' => 'meh', + 'context' => array('from' => 'logger'), + 'datetime' => new \DateTime("@0"), + 'extra' => array('key' => 'pair'), + 'message' => 'log' + ); + + $message = json_decode($formatter->format($record), true); + + $this->assertArrayHasKey('type', $message); + $this->assertEquals('app', $message['type']); + } +} diff --git a/vendor/monolog/monolog/tests/Monolog/Formatter/NormalizerFormatterTest.php b/vendor/monolog/monolog/tests/Monolog/Formatter/NormalizerFormatterTest.php new file mode 100755 index 0000000..7477871 --- /dev/null +++ b/vendor/monolog/monolog/tests/Monolog/Formatter/NormalizerFormatterTest.php @@ -0,0 +1,182 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Formatter; + +/** + * @covers Monolog\Formatter\NormalizerFormatter + */ +class NormalizerFormatterTest extends \PHPUnit_Framework_TestCase +{ + public function testFormat() + { + $formatter = new NormalizerFormatter('Y-m-d'); + $formatted = $formatter->format(array( + 'level_name' => 'ERROR', + 'channel' => 'meh', + 'message' => 'foo', + 'datetime' => new \DateTime, + 'extra' => array('foo' => new TestFooNorm, 'bar' => new TestBarNorm, 'baz' => array(), 'res' => fopen('php://memory', 'rb')), + 'context' => array( + 'foo' => 'bar', + 'baz' => 'qux', + ), + )); + + $this->assertEquals(array( + 'level_name' => 'ERROR', + 'channel' => 'meh', + 'message' => 'foo', + 'datetime' => date('Y-m-d'), + 'extra' => array( + 'foo' => '[object] (Monolog\\Formatter\\TestFooNorm: {"foo":"foo"})', + 'bar' => '[object] (Monolog\\Formatter\\TestBarNorm: {})', + 'baz' => array(), + 'res' => '[resource]', + ), + 'context' => array( + 'foo' => 'bar', + 'baz' => 'qux', + ) + ), $formatted); + } + + public function testFormatExceptions() + { + $formatter = new NormalizerFormatter('Y-m-d'); + $e = new \LogicException('bar'); + $e2 = new \RuntimeException('foo', 0, $e); + $formatted = $formatter->format(array( + 'exception' => $e2, + )); + + $this->assertGreaterThan(5, count($formatted['exception']['trace'])); + $this->assertTrue(isset($formatted['exception']['previous'])); + unset($formatted['exception']['trace'], $formatted['exception']['previous']); + + $this->assertEquals(array( + 'exception' => array( + 'class' => get_class($e2), + 'message' => $e2->getMessage(), + 'file' => $e2->getFile().':'.$e2->getLine(), + ) + ), $formatted); + } + + public function testBatchFormat() + { + $formatter = new NormalizerFormatter('Y-m-d'); + $formatted = $formatter->formatBatch(array( + array( + 'level_name' => 'CRITICAL', + 'channel' => 'test', + 'message' => 'bar', + 'context' => array(), + 'datetime' => new \DateTime, + 'extra' => array(), + ), + array( + 'level_name' => 'WARNING', + 'channel' => 'log', + 'message' => 'foo', + 'context' => array(), + 'datetime' => new \DateTime, + 'extra' => array(), + ), + )); + $this->assertEquals(array( + array( + 'level_name' => 'CRITICAL', + 'channel' => 'test', + 'message' => 'bar', + 'context' => array(), + 'datetime' => date('Y-m-d'), + 'extra' => array(), + ), + array( + 'level_name' => 'WARNING', + 'channel' => 'log', + 'message' => 'foo', + 'context' => array(), + 'datetime' => date('Y-m-d'), + 'extra' => array(), + ), + ), $formatted); + } + + /** + * Test issue #137 + */ + public function testIgnoresRecursiveObjectReferences() + { + // set up the recursion + $foo = new \stdClass(); + $bar = new \stdClass(); + + $foo->bar = $bar; + $bar->foo = $foo; + + // set an error handler to assert that the error is not raised anymore + $that = $this; + set_error_handler(function ($level, $message, $file, $line, $context) use ($that) { + if (error_reporting() & $level) { + restore_error_handler(); + $that->fail("$message should not be raised"); + } + }); + + $formatter = new NormalizerFormatter(); + $reflMethod = new \ReflectionMethod($formatter, 'toJson'); + $reflMethod->setAccessible(true); + $res = $reflMethod->invoke($formatter, array($foo, $bar), true); + + restore_error_handler(); + + $this->assertEquals(@json_encode(array($foo, $bar)), $res); + } + + public function testIgnoresInvalidTypes() + { + // set up the recursion + $resource = fopen(__FILE__, 'r'); + + // set an error handler to assert that the error is not raised anymore + $that = $this; + set_error_handler(function ($level, $message, $file, $line, $context) use ($that) { + if (error_reporting() & $level) { + restore_error_handler(); + $that->fail("$message should not be raised"); + } + }); + + $formatter = new NormalizerFormatter(); + $reflMethod = new \ReflectionMethod($formatter, 'toJson'); + $reflMethod->setAccessible(true); + $res = $reflMethod->invoke($formatter, array($resource), true); + + restore_error_handler(); + + $this->assertEquals(@json_encode(array($resource)), $res); + } +} + +class TestFooNorm +{ + public $foo = 'foo'; +} + +class TestBarNorm +{ + public function __toString() + { + return 'bar'; + } +} diff --git a/vendor/monolog/monolog/tests/Monolog/Formatter/ScalarFormatterTest.php b/vendor/monolog/monolog/tests/Monolog/Formatter/ScalarFormatterTest.php new file mode 100755 index 0000000..b8cbb13 --- /dev/null +++ b/vendor/monolog/monolog/tests/Monolog/Formatter/ScalarFormatterTest.php @@ -0,0 +1,96 @@ +formatter = new ScalarFormatter(); + } + + public function buildTrace(\Exception $e) + { + $data = array(); + $trace = $e->getTrace(); + foreach ($trace as $frame) { + if (isset($frame['file'])) { + $data[] = $frame['file'].':'.$frame['line']; + } else { + $data[] = json_encode($frame); + } + } + + return $data; + } + + public function encodeJson($data) + { + if (version_compare(PHP_VERSION, '5.4.0', '>=')) { + return json_encode($data, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE); + } + + return json_encode($data); + } + + public function testFormat() + { + $exception = new \Exception('foo'); + $formatted = $this->formatter->format(array( + 'foo' => 'string', + 'bar' => 1, + 'baz' => false, + 'bam' => array(1,2,3), + 'bat' => array('foo' => 'bar'), + 'bap' => \DateTime::createFromFormat(\DateTime::ISO8601, '1970-01-01T00:00:00+0000'), + 'ban' => $exception + )); + + $this->assertSame(array( + 'foo' => 'string', + 'bar' => 1, + 'baz' => false, + 'bam' => $this->encodeJson(array(1,2,3)), + 'bat' => $this->encodeJson(array('foo' => 'bar')), + 'bap' => '1970-01-01 00:00:00', + 'ban' => $this->encodeJson(array( + 'class' => get_class($exception), + 'message' => $exception->getMessage(), + 'file' => $exception->getFile() . ':' . $exception->getLine(), + 'trace' => $this->buildTrace($exception) + )) + ), $formatted); + } + + public function testFormatWithErrorContext() + { + $context = array('file' => 'foo', 'line' => 1); + $formatted = $this->formatter->format(array( + 'context' => $context + )); + + $this->assertSame(array( + 'context' => $this->encodeJson($context) + ), $formatted); + } + + public function testFormatWithExceptionContext() + { + $exception = new \Exception('foo'); + $formatted = $this->formatter->format(array( + 'context' => array( + 'exception' => $exception + ) + )); + + $this->assertSame(array( + 'context' => $this->encodeJson(array( + 'exception' => array( + 'class' => get_class($exception), + 'message' => $exception->getMessage(), + 'file' => $exception->getFile() . ':' . $exception->getLine(), + 'trace' => $this->buildTrace($exception) + ) + )) + ), $formatted); + } +} diff --git a/vendor/monolog/monolog/tests/Monolog/Formatter/WildfireFormatterTest.php b/vendor/monolog/monolog/tests/Monolog/Formatter/WildfireFormatterTest.php new file mode 100755 index 0000000..52f15a3 --- /dev/null +++ b/vendor/monolog/monolog/tests/Monolog/Formatter/WildfireFormatterTest.php @@ -0,0 +1,142 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Formatter; + +use Monolog\Logger; + +class WildfireFormatterTest extends \PHPUnit_Framework_TestCase +{ + /** + * @covers Monolog\Formatter\WildfireFormatter::format + */ + public function testDefaultFormat() + { + $wildfire = new WildfireFormatter(); + $record = array( + 'level' => Logger::ERROR, + 'level_name' => 'ERROR', + 'channel' => 'meh', + 'context' => array('from' => 'logger'), + 'datetime' => new \DateTime("@0"), + 'extra' => array('ip' => '127.0.0.1'), + 'message' => 'log', + ); + + $message = $wildfire->format($record); + + $this->assertEquals( + '125|[{"Type":"ERROR","File":"","Line":"","Label":"meh"},' + .'{"message":"log","context":{"from":"logger"},"extra":{"ip":"127.0.0.1"}}]|', + $message + ); + } + + /** + * @covers Monolog\Formatter\WildfireFormatter::format + */ + public function testFormatWithFileAndLine() + { + $wildfire = new WildfireFormatter(); + $record = array( + 'level' => Logger::ERROR, + 'level_name' => 'ERROR', + 'channel' => 'meh', + 'context' => array('from' => 'logger'), + 'datetime' => new \DateTime("@0"), + 'extra' => array('ip' => '127.0.0.1', 'file' => 'test', 'line' => 14), + 'message' => 'log', + ); + + $message = $wildfire->format($record); + + $this->assertEquals( + '129|[{"Type":"ERROR","File":"test","Line":14,"Label":"meh"},' + .'{"message":"log","context":{"from":"logger"},"extra":{"ip":"127.0.0.1"}}]|', + $message + ); + } + + /** + * @covers Monolog\Formatter\WildfireFormatter::format + */ + public function testFormatWithoutContext() + { + $wildfire = new WildfireFormatter(); + $record = array( + 'level' => Logger::ERROR, + 'level_name' => 'ERROR', + 'channel' => 'meh', + 'context' => array(), + 'datetime' => new \DateTime("@0"), + 'extra' => array(), + 'message' => 'log', + ); + + $message = $wildfire->format($record); + + $this->assertEquals( + '58|[{"Type":"ERROR","File":"","Line":"","Label":"meh"},"log"]|', + $message + ); + } + + /** + * @covers Monolog\Formatter\WildfireFormatter::formatBatch + * @expectedException BadMethodCallException + */ + public function testBatchFormatThrowException() + { + $wildfire = new WildfireFormatter(); + $record = array( + 'level' => Logger::ERROR, + 'level_name' => 'ERROR', + 'channel' => 'meh', + 'context' => array(), + 'datetime' => new \DateTime("@0"), + 'extra' => array(), + 'message' => 'log', + ); + + $wildfire->formatBatch(array($record)); + } + + /** + * @covers Monolog\Formatter\WildfireFormatter::format + */ + public function testTableFormat() + { + $wildfire = new WildfireFormatter(); + $record = array( + 'level' => Logger::ERROR, + 'level_name' => 'ERROR', + 'channel' => 'table-channel', + 'context' => array( + WildfireFormatter::TABLE => array( + array('col1', 'col2', 'col3'), + array('val1', 'val2', 'val3'), + array('foo1', 'foo2', 'foo3'), + array('bar1', 'bar2', 'bar3'), + ), + ), + 'datetime' => new \DateTime("@0"), + 'extra' => array(), + 'message' => 'table-message', + ); + + $message = $wildfire->format($record); + + $this->assertEquals( + '171|[{"Type":"TABLE","File":"","Line":"","Label":"table-channel: table-message"},[["col1","col2","col3"],["val1","val2","val3"],["foo1","foo2","foo3"],["bar1","bar2","bar3"]]]|', + $message + ); + } +} diff --git a/vendor/monolog/monolog/tests/Monolog/Functional/Handler/FirePHPHandlerTest.php b/vendor/monolog/monolog/tests/Monolog/Functional/Handler/FirePHPHandlerTest.php new file mode 100755 index 0000000..7e4e7eb --- /dev/null +++ b/vendor/monolog/monolog/tests/Monolog/Functional/Handler/FirePHPHandlerTest.php @@ -0,0 +1,32 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +spl_autoload_register(function ($class) { + $file = __DIR__.'/../../../../src/'.strtr($class, '\\', '/').'.php'; + if (file_exists($file)) { + require $file; + + return true; + } +}); + +use Monolog\Logger; +use Monolog\Handler\FirePHPHandler; +use Monolog\Handler\ChromePHPHandler; + +$logger = new Logger('firephp'); +$logger->pushHandler(new FirePHPHandler); +$logger->pushHandler(new ChromePHPHandler()); + +$logger->addDebug('Debug'); +$logger->addInfo('Info'); +$logger->addWarning('Warning'); +$logger->addError('Error'); diff --git a/vendor/monolog/monolog/tests/Monolog/Handler/AbstractHandlerTest.php b/vendor/monolog/monolog/tests/Monolog/Handler/AbstractHandlerTest.php new file mode 100755 index 0000000..01d522f --- /dev/null +++ b/vendor/monolog/monolog/tests/Monolog/Handler/AbstractHandlerTest.php @@ -0,0 +1,104 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Handler; + +use Monolog\TestCase; +use Monolog\Logger; +use Monolog\Formatter\LineFormatter; +use Monolog\Processor\WebProcessor; + +class AbstractHandlerTest extends TestCase +{ + /** + * @covers Monolog\Handler\AbstractHandler::__construct + * @covers Monolog\Handler\AbstractHandler::getLevel + * @covers Monolog\Handler\AbstractHandler::setLevel + * @covers Monolog\Handler\AbstractHandler::getBubble + * @covers Monolog\Handler\AbstractHandler::setBubble + * @covers Monolog\Handler\AbstractHandler::getFormatter + * @covers Monolog\Handler\AbstractHandler::setFormatter + */ + public function testConstructAndGetSet() + { + $handler = $this->getMockForAbstractClass('Monolog\Handler\AbstractHandler', array(Logger::WARNING, false)); + $this->assertEquals(Logger::WARNING, $handler->getLevel()); + $this->assertEquals(false, $handler->getBubble()); + + $handler->setLevel(Logger::ERROR); + $handler->setBubble(true); + $handler->setFormatter($formatter = new LineFormatter); + $this->assertEquals(Logger::ERROR, $handler->getLevel()); + $this->assertEquals(true, $handler->getBubble()); + $this->assertSame($formatter, $handler->getFormatter()); + } + + /** + * @covers Monolog\Handler\AbstractHandler::handleBatch + */ + public function testHandleBatch() + { + $handler = $this->getMockForAbstractClass('Monolog\Handler\AbstractHandler'); + $handler->expects($this->exactly(2)) + ->method('handle'); + $handler->handleBatch(array($this->getRecord(), $this->getRecord())); + } + + /** + * @covers Monolog\Handler\AbstractHandler::isHandling + */ + public function testIsHandling() + { + $handler = $this->getMockForAbstractClass('Monolog\Handler\AbstractHandler', array(Logger::WARNING, false)); + $this->assertTrue($handler->isHandling($this->getRecord())); + $this->assertFalse($handler->isHandling($this->getRecord(Logger::DEBUG))); + } + + /** + * @covers Monolog\Handler\AbstractHandler::getFormatter + * @covers Monolog\Handler\AbstractHandler::getDefaultFormatter + */ + public function testGetFormatterInitializesDefault() + { + $handler = $this->getMockForAbstractClass('Monolog\Handler\AbstractHandler'); + $this->assertInstanceOf('Monolog\Formatter\LineFormatter', $handler->getFormatter()); + } + + /** + * @covers Monolog\Handler\AbstractHandler::pushProcessor + * @covers Monolog\Handler\AbstractHandler::popProcessor + * @expectedException LogicException + */ + public function testPushPopProcessor() + { + $logger = $this->getMockForAbstractClass('Monolog\Handler\AbstractHandler'); + $processor1 = new WebProcessor; + $processor2 = new WebProcessor; + + $logger->pushProcessor($processor1); + $logger->pushProcessor($processor2); + + $this->assertEquals($processor2, $logger->popProcessor()); + $this->assertEquals($processor1, $logger->popProcessor()); + $logger->popProcessor(); + } + + /** + * @covers Monolog\Handler\AbstractHandler::pushProcessor + * @expectedException InvalidArgumentException + */ + public function testPushProcessorWithNonCallable() + { + $handler = $this->getMockForAbstractClass('Monolog\Handler\AbstractHandler'); + + $handler->pushProcessor(new \stdClass()); + } +} diff --git a/vendor/monolog/monolog/tests/Monolog/Handler/AbstractProcessingHandlerTest.php b/vendor/monolog/monolog/tests/Monolog/Handler/AbstractProcessingHandlerTest.php new file mode 100755 index 0000000..24d4f63 --- /dev/null +++ b/vendor/monolog/monolog/tests/Monolog/Handler/AbstractProcessingHandlerTest.php @@ -0,0 +1,80 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Handler; + +use Monolog\TestCase; +use Monolog\Logger; +use Monolog\Processor\WebProcessor; + +class AbstractProcessingHandlerTest extends TestCase +{ + /** + * @covers Monolog\Handler\AbstractProcessingHandler::handle + */ + public function testHandleLowerLevelMessage() + { + $handler = $this->getMockForAbstractClass('Monolog\Handler\AbstractProcessingHandler', array(Logger::WARNING, true)); + $this->assertFalse($handler->handle($this->getRecord(Logger::DEBUG))); + } + + /** + * @covers Monolog\Handler\AbstractProcessingHandler::handle + */ + public function testHandleBubbling() + { + $handler = $this->getMockForAbstractClass('Monolog\Handler\AbstractProcessingHandler', array(Logger::DEBUG, true)); + $this->assertFalse($handler->handle($this->getRecord())); + } + + /** + * @covers Monolog\Handler\AbstractProcessingHandler::handle + */ + public function testHandleNotBubbling() + { + $handler = $this->getMockForAbstractClass('Monolog\Handler\AbstractProcessingHandler', array(Logger::DEBUG, false)); + $this->assertTrue($handler->handle($this->getRecord())); + } + + /** + * @covers Monolog\Handler\AbstractProcessingHandler::handle + */ + public function testHandleIsFalseWhenNotHandled() + { + $handler = $this->getMockForAbstractClass('Monolog\Handler\AbstractProcessingHandler', array(Logger::WARNING, false)); + $this->assertTrue($handler->handle($this->getRecord())); + $this->assertFalse($handler->handle($this->getRecord(Logger::DEBUG))); + } + + /** + * @covers Monolog\Handler\AbstractProcessingHandler::processRecord + */ + public function testProcessRecord() + { + $handler = $this->getMockForAbstractClass('Monolog\Handler\AbstractProcessingHandler'); + $handler->pushProcessor(new WebProcessor(array( + 'REQUEST_URI' => '', + 'REQUEST_METHOD' => '', + 'REMOTE_ADDR' => '', + 'SERVER_NAME' => '', + 'UNIQUE_ID' => '', + ))); + $handledRecord = null; + $handler->expects($this->once()) + ->method('write') + ->will($this->returnCallback(function ($record) use (&$handledRecord) { + $handledRecord = $record; + })) + ; + $handler->handle($this->getRecord()); + $this->assertEquals(6, count($handledRecord['extra'])); + } +} diff --git a/vendor/monolog/monolog/tests/Monolog/Handler/AmqpHandlerTest.php b/vendor/monolog/monolog/tests/Monolog/Handler/AmqpHandlerTest.php new file mode 100755 index 0000000..249f2b7 --- /dev/null +++ b/vendor/monolog/monolog/tests/Monolog/Handler/AmqpHandlerTest.php @@ -0,0 +1,80 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Handler; + +use Monolog\TestCase; +use Monolog\Logger; + +/** + * @covers Monolog\Handler\RotatingFileHandler + */ +class AmqpHandlerTest extends TestCase +{ + public function setUp() + { + if (!class_exists('AMQPConnection') || !class_exists('AMQPExchange')) { + $this->markTestSkipped("amqp-php not installed"); + } + + if (!class_exists('AMQPChannel')) { + $this->markTestSkipped("Please update AMQP to version >= 1.0"); + } + } + + public function testHandle() + { + $messages = array(); + + $exchange = $this->getMock('AMQPExchange', array('publish', 'setName'), array(), '', false); + $exchange->expects($this->once()) + ->method('setName') + ->with('log') + ; + $exchange->expects($this->any()) + ->method('publish') + ->will($this->returnCallback(function ($message, $routing_key, $flags = 0, $attributes = array()) use (&$messages) { + $messages[] = array($message, $routing_key, $flags, $attributes); + })) + ; + + $handler = new AmqpHandler($exchange, 'log'); + + $record = $this->getRecord(Logger::WARNING, 'test', array('data' => new \stdClass, 'foo' => 34)); + + $expected = array( + array( + 'message' => 'test', + 'context' => array( + 'data' => array(), + 'foo' => 34, + ), + 'level' => 300, + 'level_name' => 'WARNING', + 'channel' => 'test', + 'extra' => array(), + ), + 'warn.test', + 0, + array( + 'delivery_mode' => 2, + 'Content-type' => 'application/json' + ) + ); + + $handler->handle($record); + + $this->assertCount(1, $messages); + $messages[0][0] = json_decode($messages[0][0], true); + unset($messages[0][0]['datetime']); + $this->assertEquals($expected, $messages[0]); + } +} diff --git a/vendor/monolog/monolog/tests/Monolog/Handler/BrowserConsoleHandlerTest.php b/vendor/monolog/monolog/tests/Monolog/Handler/BrowserConsoleHandlerTest.php new file mode 100755 index 0000000..f3d8038 --- /dev/null +++ b/vendor/monolog/monolog/tests/Monolog/Handler/BrowserConsoleHandlerTest.php @@ -0,0 +1,131 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Handler; + +use Monolog\TestCase; +use Monolog\Logger; + +/** + * @covers Monolog\Handler\BrowserConsoleHandlerTest + */ +class BrowserConsoleHandlerTest extends TestCase +{ + protected function setUp() + { + BrowserConsoleHandler::reset(); + } + + protected function generateScript() + { + $reflMethod = new \ReflectionMethod('Monolog\Handler\BrowserConsoleHandler', 'generateScript'); + $reflMethod->setAccessible(true); + + return $reflMethod->invoke(null); + } + + public function testStyling() + { + $handler = new BrowserConsoleHandler(); + $handler->setFormatter($this->getIdentityFormatter()); + + $handler->handle($this->getRecord(Logger::DEBUG, 'foo[[bar]]{color: red}')); + + $expected = <<assertEquals($expected, $this->generateScript()); + } + + public function testEscaping() + { + $handler = new BrowserConsoleHandler(); + $handler->setFormatter($this->getIdentityFormatter()); + + $handler->handle($this->getRecord(Logger::DEBUG, "[foo] [[\"bar\n[baz]\"]]{color: red}")); + + $expected = <<assertEquals($expected, $this->generateScript()); + } + + + public function testAutolabel() + { + $handler = new BrowserConsoleHandler(); + $handler->setFormatter($this->getIdentityFormatter()); + + $handler->handle($this->getRecord(Logger::DEBUG, '[[foo]]{macro: autolabel}')); + $handler->handle($this->getRecord(Logger::DEBUG, '[[bar]]{macro: autolabel}')); + $handler->handle($this->getRecord(Logger::DEBUG, '[[foo]]{macro: autolabel}')); + + $expected = <<assertEquals($expected, $this->generateScript()); + } + + public function testContext() + { + $handler = new BrowserConsoleHandler(); + $handler->setFormatter($this->getIdentityFormatter()); + + $handler->handle($this->getRecord(Logger::DEBUG, 'test', array('foo' => 'bar'))); + + $expected = <<assertEquals($expected, $this->generateScript()); + } + + public function testConcurrentHandlers() + { + $handler1 = new BrowserConsoleHandler(); + $handler1->setFormatter($this->getIdentityFormatter()); + + $handler2 = new BrowserConsoleHandler(); + $handler2->setFormatter($this->getIdentityFormatter()); + + $handler1->handle($this->getRecord(Logger::DEBUG, 'test1')); + $handler2->handle($this->getRecord(Logger::DEBUG, 'test2')); + $handler1->handle($this->getRecord(Logger::DEBUG, 'test3')); + $handler2->handle($this->getRecord(Logger::DEBUG, 'test4')); + + $expected = <<assertEquals($expected, $this->generateScript()); + } +} diff --git a/vendor/monolog/monolog/tests/Monolog/Handler/BufferHandlerTest.php b/vendor/monolog/monolog/tests/Monolog/Handler/BufferHandlerTest.php new file mode 100755 index 0000000..beb08cf --- /dev/null +++ b/vendor/monolog/monolog/tests/Monolog/Handler/BufferHandlerTest.php @@ -0,0 +1,149 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Handler; + +use Monolog\TestCase; +use Monolog\Logger; + +class BufferHandlerTest extends TestCase +{ + /** + * @covers Monolog\Handler\BufferHandler::__construct + * @covers Monolog\Handler\BufferHandler::handle + * @covers Monolog\Handler\BufferHandler::close + */ + public function testHandleBuffers() + { + $test = new TestHandler(); + $handler = new BufferHandler($test); + $handler->handle($this->getRecord(Logger::DEBUG)); + $handler->handle($this->getRecord(Logger::INFO)); + $this->assertFalse($test->hasDebugRecords()); + $this->assertFalse($test->hasInfoRecords()); + $handler->close(); + $this->assertTrue($test->hasInfoRecords()); + $this->assertTrue(count($test->getRecords()) === 2); + } + + /** + * @covers Monolog\Handler\BufferHandler::close + * @covers Monolog\Handler\BufferHandler::flush + */ + public function testDestructPropagatesRecords() + { + $test = new TestHandler(); + $handler = new BufferHandler($test); + $handler->handle($this->getRecord(Logger::WARNING)); + $handler->handle($this->getRecord(Logger::DEBUG)); + $handler->__destruct(); + $this->assertTrue($test->hasWarningRecords()); + $this->assertTrue($test->hasDebugRecords()); + } + + /** + * @covers Monolog\Handler\BufferHandler::handle + */ + public function testHandleBufferLimit() + { + $test = new TestHandler(); + $handler = new BufferHandler($test, 2); + $handler->handle($this->getRecord(Logger::DEBUG)); + $handler->handle($this->getRecord(Logger::DEBUG)); + $handler->handle($this->getRecord(Logger::INFO)); + $handler->handle($this->getRecord(Logger::WARNING)); + $handler->close(); + $this->assertTrue($test->hasWarningRecords()); + $this->assertTrue($test->hasInfoRecords()); + $this->assertFalse($test->hasDebugRecords()); + } + + /** + * @covers Monolog\Handler\BufferHandler::handle + */ + public function testHandleBufferLimitWithFlushOnOverflow() + { + $test = new TestHandler(); + $handler = new BufferHandler($test, 3, Logger::DEBUG, true, true); + + // send two records + $handler->handle($this->getRecord(Logger::DEBUG)); + $handler->handle($this->getRecord(Logger::DEBUG)); + $handler->handle($this->getRecord(Logger::DEBUG)); + $this->assertFalse($test->hasDebugRecords()); + $this->assertCount(0, $test->getRecords()); + + // overflow + $handler->handle($this->getRecord(Logger::INFO)); + $this->assertTrue($test->hasDebugRecords()); + $this->assertCount(3, $test->getRecords()); + + // should buffer again + $handler->handle($this->getRecord(Logger::WARNING)); + $this->assertCount(3, $test->getRecords()); + + $handler->close(); + $this->assertCount(5, $test->getRecords()); + $this->assertTrue($test->hasWarningRecords()); + $this->assertTrue($test->hasInfoRecords()); + } + + /** + * @covers Monolog\Handler\BufferHandler::handle + */ + public function testHandleLevel() + { + $test = new TestHandler(); + $handler = new BufferHandler($test, 0, Logger::INFO); + $handler->handle($this->getRecord(Logger::DEBUG)); + $handler->handle($this->getRecord(Logger::INFO)); + $handler->handle($this->getRecord(Logger::WARNING)); + $handler->handle($this->getRecord(Logger::DEBUG)); + $handler->close(); + $this->assertTrue($test->hasWarningRecords()); + $this->assertTrue($test->hasInfoRecords()); + $this->assertFalse($test->hasDebugRecords()); + } + + /** + * @covers Monolog\Handler\BufferHandler::flush + */ + public function testFlush() + { + $test = new TestHandler(); + $handler = new BufferHandler($test, 0); + $handler->handle($this->getRecord(Logger::DEBUG)); + $handler->handle($this->getRecord(Logger::INFO)); + $handler->flush(); + $this->assertTrue($test->hasInfoRecords()); + $this->assertTrue($test->hasDebugRecords()); + $this->assertFalse($test->hasWarningRecords()); + } + + /** + * @covers Monolog\Handler\BufferHandler::handle + */ + public function testHandleUsesProcessors() + { + $test = new TestHandler(); + $handler = new BufferHandler($test); + $handler->pushProcessor(function ($record) { + $record['extra']['foo'] = true; + + return $record; + }); + $handler->handle($this->getRecord(Logger::WARNING)); + $handler->flush(); + $this->assertTrue($test->hasWarningRecords()); + $records = $test->getRecords(); + $this->assertTrue($records[0]['extra']['foo']); + } +} diff --git a/vendor/monolog/monolog/tests/Monolog/Handler/ChromePHPHandlerTest.php b/vendor/monolog/monolog/tests/Monolog/Handler/ChromePHPHandlerTest.php new file mode 100755 index 0000000..2f55faf --- /dev/null +++ b/vendor/monolog/monolog/tests/Monolog/Handler/ChromePHPHandlerTest.php @@ -0,0 +1,141 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Handler; + +use Monolog\TestCase; +use Monolog\Logger; + +/** + * @covers Monolog\Handler\ChromePHPHandler + */ +class ChromePHPHandlerTest extends TestCase +{ + protected function setUp() + { + TestChromePHPHandler::reset(); + $_SERVER['HTTP_USER_AGENT'] = 'Monolog Test; Chrome/1.0'; + } + + public function testHeaders() + { + $handler = new TestChromePHPHandler(); + $handler->setFormatter($this->getIdentityFormatter()); + $handler->handle($this->getRecord(Logger::DEBUG)); + $handler->handle($this->getRecord(Logger::WARNING)); + + $expected = array( + 'X-ChromeLogger-Data' => base64_encode(utf8_encode(json_encode(array( + 'version' => ChromePHPHandler::VERSION, + 'columns' => array('label', 'log', 'backtrace', 'type'), + 'rows' => array( + 'test', + 'test', + ), + 'request_uri' => '', + )))) + ); + + $this->assertEquals($expected, $handler->getHeaders()); + } + + public function testHeadersOverflow() + { + $handler = new TestChromePHPHandler(); + $handler->handle($this->getRecord(Logger::DEBUG)); + $handler->handle($this->getRecord(Logger::WARNING, str_repeat('a', 150*1024))); + + // overflow chrome headers limit + $handler->handle($this->getRecord(Logger::WARNING, str_repeat('a', 100*1024))); + + $expected = array( + 'X-ChromeLogger-Data' => base64_encode(utf8_encode(json_encode(array( + 'version' => ChromePHPHandler::VERSION, + 'columns' => array('label', 'log', 'backtrace', 'type'), + 'rows' => array( + array( + 'test', + 'test', + 'unknown', + 'log', + ), + array( + 'test', + str_repeat('a', 150*1024), + 'unknown', + 'warn', + ), + array( + 'monolog', + 'Incomplete logs, chrome header size limit reached', + 'unknown', + 'warn', + ), + ), + 'request_uri' => '', + )))) + ); + + $this->assertEquals($expected, $handler->getHeaders()); + } + + public function testConcurrentHandlers() + { + $handler = new TestChromePHPHandler(); + $handler->setFormatter($this->getIdentityFormatter()); + $handler->handle($this->getRecord(Logger::DEBUG)); + $handler->handle($this->getRecord(Logger::WARNING)); + + $handler2 = new TestChromePHPHandler(); + $handler2->setFormatter($this->getIdentityFormatter()); + $handler2->handle($this->getRecord(Logger::DEBUG)); + $handler2->handle($this->getRecord(Logger::WARNING)); + + $expected = array( + 'X-ChromeLogger-Data' => base64_encode(utf8_encode(json_encode(array( + 'version' => ChromePHPHandler::VERSION, + 'columns' => array('label', 'log', 'backtrace', 'type'), + 'rows' => array( + 'test', + 'test', + 'test', + 'test', + ), + 'request_uri' => '', + )))) + ); + + $this->assertEquals($expected, $handler2->getHeaders()); + } +} + +class TestChromePHPHandler extends ChromePHPHandler +{ + protected $headers = array(); + + public static function reset() + { + self::$initialized = false; + self::$overflowed = false; + self::$sendHeaders = true; + self::$json['rows'] = array(); + } + + protected function sendHeader($header, $content) + { + $this->headers[$header] = $content; + } + + public function getHeaders() + { + return $this->headers; + } +} diff --git a/vendor/monolog/monolog/tests/Monolog/Handler/CouchDBHandlerTest.php b/vendor/monolog/monolog/tests/Monolog/Handler/CouchDBHandlerTest.php new file mode 100755 index 0000000..78a1d15 --- /dev/null +++ b/vendor/monolog/monolog/tests/Monolog/Handler/CouchDBHandlerTest.php @@ -0,0 +1,41 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Handler; + +use Monolog\TestCase; +use Monolog\Logger; + +class CouchDBHandlerTest extends TestCase +{ + public function testHandle() + { + $record = $this->getRecord(Logger::WARNING, 'test', array('data' => new \stdClass, 'foo' => 34)); + + $expected = array( + 'message' => 'test', + 'context' => array('data' => '[object] (stdClass: {})', 'foo' => 34), + 'level' => Logger::WARNING, + 'level_name' => 'WARNING', + 'channel' => 'test', + 'datetime' => $record['datetime']->format('Y-m-d H:i:s'), + 'extra' => array(), + ); + + $handler = new CouchDBHandler(); + + try { + $handler->handle($record); + } catch (\RuntimeException $e) { + $this->markTestSkipped('Could not connect to couchdb server on http://localhost:5984'); + } + } +} diff --git a/vendor/monolog/monolog/tests/Monolog/Handler/DoctrineCouchDBHandlerTest.php b/vendor/monolog/monolog/tests/Monolog/Handler/DoctrineCouchDBHandlerTest.php new file mode 100755 index 0000000..d67da90 --- /dev/null +++ b/vendor/monolog/monolog/tests/Monolog/Handler/DoctrineCouchDBHandlerTest.php @@ -0,0 +1,52 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Handler; + +use Monolog\TestCase; +use Monolog\Logger; + +class DoctrineCouchDBHandlerTest extends TestCase +{ + protected function setup() + { + if (!class_exists('Doctrine\CouchDB\CouchDBClient')) { + $this->markTestSkipped('The "doctrine/couchdb" package is not installed'); + } + } + + public function testHandle() + { + $client = $this->getMockBuilder('Doctrine\\CouchDB\\CouchDBClient') + ->setMethods(array('postDocument')) + ->disableOriginalConstructor() + ->getMock(); + + $record = $this->getRecord(Logger::WARNING, 'test', array('data' => new \stdClass, 'foo' => 34)); + + $expected = array( + 'message' => 'test', + 'context' => array('data' => '[object] (stdClass: {})', 'foo' => 34), + 'level' => Logger::WARNING, + 'level_name' => 'WARNING', + 'channel' => 'test', + 'datetime' => $record['datetime']->format('Y-m-d H:i:s'), + 'extra' => array(), + ); + + $client->expects($this->once()) + ->method('postDocument') + ->with($expected); + + $handler = new DoctrineCouchDBHandler($client); + $handler->handle($record); + } +} diff --git a/vendor/monolog/monolog/tests/Monolog/Handler/DynamoDbHandlerTest.php b/vendor/monolog/monolog/tests/Monolog/Handler/DynamoDbHandlerTest.php new file mode 100755 index 0000000..a38a8cb --- /dev/null +++ b/vendor/monolog/monolog/tests/Monolog/Handler/DynamoDbHandlerTest.php @@ -0,0 +1,73 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Handler; + +use Monolog\TestCase; + +class DynamoDbHandlerTest extends TestCase +{ + public function setUp() + { + if (!class_exists('Aws\DynamoDb\DynamoDbClient')) { + $this->markTestSkipped('aws/aws-sdk-php not installed'); + } + + $this->client = $this->getMockBuilder('Aws\DynamoDb\DynamoDbClient') + ->setMethods(array('formatAttributes', '__call')) + ->disableOriginalConstructor()->getMock(); + } + + public function testConstruct() + { + $this->assertInstanceOf('Monolog\Handler\DynamoDbHandler', new DynamoDbHandler($this->client, 'foo')); + } + + public function testInterface() + { + $this->assertInstanceOf('Monolog\Handler\HandlerInterface', new DynamoDbHandler($this->client, 'foo')); + } + + public function testGetFormatter() + { + $handler = new DynamoDbHandler($this->client, 'foo'); + $this->assertInstanceOf('Monolog\Formatter\ScalarFormatter', $handler->getFormatter()); + } + + public function testHandle() + { + $record = $this->getRecord(); + $formatter = $this->getMock('Monolog\Formatter\FormatterInterface'); + $formatted = array('foo' => 1, 'bar' => 2); + $handler = new DynamoDbHandler($this->client, 'foo'); + $handler->setFormatter($formatter); + + $formatter + ->expects($this->once()) + ->method('format') + ->with($record) + ->will($this->returnValue($formatted)); + $this->client + ->expects($this->once()) + ->method('formatAttributes') + ->with($this->isType('array')) + ->will($this->returnValue($formatted)); + $this->client + ->expects($this->once()) + ->method('__call') + ->with('putItem', array(array( + 'TableName' => 'foo', + 'Item' => $formatted + ))); + + $handler->handle($record); + } +} diff --git a/vendor/monolog/monolog/tests/Monolog/Handler/ElasticSearchHandlerTest.php b/vendor/monolog/monolog/tests/Monolog/Handler/ElasticSearchHandlerTest.php new file mode 100755 index 0000000..1687074 --- /dev/null +++ b/vendor/monolog/monolog/tests/Monolog/Handler/ElasticSearchHandlerTest.php @@ -0,0 +1,239 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Handler; + +use Monolog\Formatter\ElasticaFormatter; +use Monolog\Formatter\NormalizerFormatter; +use Monolog\TestCase; +use Monolog\Logger; +use Elastica\Client; +use Elastica\Request; +use Elastica\Response; + +class ElasticSearchHandlerTest extends TestCase +{ + /** + * @var Client mock + */ + protected $client; + + /** + * @var array Default handler options + */ + protected $options = array( + 'index' => 'my_index', + 'type' => 'doc_type', + ); + + public function setUp() + { + // Elastica lib required + if (!class_exists("Elastica\Client")) { + $this->markTestSkipped("ruflin/elastica not installed"); + } + + // base mock Elastica Client object + $this->client = $this->getMockBuilder('Elastica\Client') + ->setMethods(array('addDocuments')) + ->disableOriginalConstructor() + ->getMock(); + } + + /** + * @covers Monolog\Handler\ElasticSearchHandler::write + * @covers Monolog\Handler\ElasticSearchHandler::handleBatch + * @covers Monolog\Handler\ElasticSearchHandler::bulkSend + * @covers Monolog\Handler\ElasticSearchHandler::getDefaultFormatter + */ + public function testHandle() + { + // log message + $msg = array( + 'level' => Logger::ERROR, + 'level_name' => 'ERROR', + 'channel' => 'meh', + 'context' => array('foo' => 7, 'bar', 'class' => new \stdClass), + 'datetime' => new \DateTime("@0"), + 'extra' => array(), + 'message' => 'log', + ); + + // format expected result + $formatter = new ElasticaFormatter($this->options['index'], $this->options['type']); + $expected = array($formatter->format($msg)); + + // setup ES client mock + $this->client->expects($this->any()) + ->method('addDocuments') + ->with($expected); + + // perform tests + $handler = new ElasticSearchHandler($this->client, $this->options); + $handler->handle($msg); + $handler->handleBatch(array($msg)); + } + + /** + * @covers Monolog\Handler\ElasticSearchHandler::setFormatter + */ + public function testSetFormatter() + { + $handler = new ElasticSearchHandler($this->client); + $formatter = new ElasticaFormatter('index_new', 'type_new'); + $handler->setFormatter($formatter); + $this->assertInstanceOf('Monolog\Formatter\ElasticaFormatter', $handler->getFormatter()); + $this->assertEquals('index_new', $handler->getFormatter()->getIndex()); + $this->assertEquals('type_new', $handler->getFormatter()->getType()); + } + + /** + * @covers Monolog\Handler\ElasticSearchHandler::setFormatter + * @expectedException InvalidArgumentException + * @expectedExceptionMessage ElasticSearchHandler is only compatible with ElasticaFormatter + */ + public function testSetFormatterInvalid() + { + $handler = new ElasticSearchHandler($this->client); + $formatter = new NormalizerFormatter(); + $handler->setFormatter($formatter); + } + + /** + * @covers Monolog\Handler\ElasticSearchHandler::__construct + * @covers Monolog\Handler\ElasticSearchHandler::getOptions + */ + public function testOptions() + { + $expected = array( + 'index' => $this->options['index'], + 'type' => $this->options['type'], + 'ignore_error' => false, + ); + $handler = new ElasticSearchHandler($this->client, $this->options); + $this->assertEquals($expected, $handler->getOptions()); + } + + /** + * @covers Monolog\Handler\ElasticSearchHandler::bulkSend + * @dataProvider providerTestConnectionErrors + */ + public function testConnectionErrors($ignore, $expectedError) + { + $clientOpts = array('host' => '127.0.0.1', 'port' => 1); + $client = new Client($clientOpts); + $handlerOpts = array('ignore_error' => $ignore); + $handler = new ElasticSearchHandler($client, $handlerOpts); + + if ($expectedError) { + $this->setExpectedException($expectedError[0], $expectedError[1]); + $handler->handle($this->getRecord()); + } else { + $this->assertFalse($handler->handle($this->getRecord())); + } + } + + /** + * @return array + */ + public function providerTestConnectionErrors() + { + return array( + array(false, array('RuntimeException', 'Error sending messages to Elasticsearch')), + array(true, false), + ); + } + + /** + * Integration test using localhost Elastic Search server + * + * @covers Monolog\Handler\ElasticSearchHandler::__construct + * @covers Monolog\Handler\ElasticSearchHandler::handleBatch + * @covers Monolog\Handler\ElasticSearchHandler::bulkSend + * @covers Monolog\Handler\ElasticSearchHandler::getDefaultFormatter + */ + public function testHandleIntegration() + { + $msg = array( + 'level' => Logger::ERROR, + 'level_name' => 'ERROR', + 'channel' => 'meh', + 'context' => array('foo' => 7, 'bar', 'class' => new \stdClass), + 'datetime' => new \DateTime("@0"), + 'extra' => array(), + 'message' => 'log', + ); + + $expected = $msg; + $expected['datetime'] = $msg['datetime']->format(\DateTime::ISO8601); + $expected['context'] = array( + 'class' => '[object] (stdClass: {})', + 'foo' => 7, + 0 => 'bar', + ); + + $client = new Client(); + $handler = new ElasticSearchHandler($client, $this->options); + try { + $handler->handleBatch(array($msg)); + } catch (\RuntimeException $e) { + $this->markTestSkipped("Cannot connect to Elastic Search server on localhost"); + } + + // check document id from ES server response + $documentId = $this->getCreatedDocId($client->getLastResponse()); + $this->assertNotEmpty($documentId, 'No elastic document id received'); + + // retrieve document source from ES and validate + $document = $this->getDocSourceFromElastic( + $client, + $this->options['index'], + $this->options['type'], + $documentId + ); + $this->assertEquals($expected, $document); + + // remove test index from ES + $client->request("/{$this->options['index']}", Request::DELETE); + } + + /** + * Return last created document id from ES response + * @param Response $response Elastica Response object + * @return string|null + */ + protected function getCreatedDocId(Response $response) + { + $data = $response->getData(); + if (!empty($data['items'][0]['create']['_id'])) { + return $data['items'][0]['create']['_id']; + } + } + + /** + * Retrieve document by id from Elasticsearch + * @param Client $client Elastica client + * @param string $index + * @param string $type + * @param string $documentId + * @return array + */ + protected function getDocSourceFromElastic(Client $client, $index, $type, $documentId) + { + $resp = $client->request("/{$index}/{$type}/{$documentId}", Request::GET); + $data = $resp->getData(); + if (!empty($data['_source'])) { + return $data['_source']; + } + + return array(); + } +} diff --git a/vendor/monolog/monolog/tests/Monolog/Handler/ErrorLogHandlerTest.php b/vendor/monolog/monolog/tests/Monolog/Handler/ErrorLogHandlerTest.php new file mode 100755 index 0000000..19bfdb5 --- /dev/null +++ b/vendor/monolog/monolog/tests/Monolog/Handler/ErrorLogHandlerTest.php @@ -0,0 +1,43 @@ +handle($this->getRecord(Logger::ERROR)); + + $this->assertStringMatchesFormat('[%s] test.ERROR: test [] []', $GLOBALS['error_log'][0]); + $this->assertSame($GLOBALS['error_log'][1], $type); + } +} diff --git a/vendor/monolog/monolog/tests/Monolog/Handler/FilterHandlerTest.php b/vendor/monolog/monolog/tests/Monolog/Handler/FilterHandlerTest.php new file mode 100755 index 0000000..1f86c8e --- /dev/null +++ b/vendor/monolog/monolog/tests/Monolog/Handler/FilterHandlerTest.php @@ -0,0 +1,151 @@ +assertFalse($handler->isHandling($this->getRecord(Logger::DEBUG))); + $this->assertTrue($handler->isHandling($this->getRecord(Logger::INFO))); + $this->assertTrue($handler->isHandling($this->getRecord(Logger::NOTICE))); + $this->assertFalse($handler->isHandling($this->getRecord(Logger::WARNING))); + $this->assertFalse($handler->isHandling($this->getRecord(Logger::ERROR))); + $this->assertFalse($handler->isHandling($this->getRecord(Logger::CRITICAL))); + $this->assertFalse($handler->isHandling($this->getRecord(Logger::ALERT))); + $this->assertFalse($handler->isHandling($this->getRecord(Logger::EMERGENCY))); + } + + /** + * @covers Monolog\Handler\FilterHandler::handle + * @covers Monolog\Handler\FilterHandler::setAcceptedLevels + * @covers Monolog\Handler\FilterHandler::isHandling + */ + public function testHandleProcessOnlyNeededLevels() + { + $test = new TestHandler(); + $handler = new FilterHandler($test, Logger::INFO, Logger::NOTICE); + + $handler->handle($this->getRecord(Logger::DEBUG)); + $this->assertFalse($test->hasDebugRecords()); + + $handler->handle($this->getRecord(Logger::INFO)); + $this->assertTrue($test->hasInfoRecords()); + $handler->handle($this->getRecord(Logger::NOTICE)); + $this->assertTrue($test->hasNoticeRecords()); + + $handler->handle($this->getRecord(Logger::WARNING)); + $this->assertFalse($test->hasWarningRecords()); + $handler->handle($this->getRecord(Logger::ERROR)); + $this->assertFalse($test->hasErrorRecords()); + $handler->handle($this->getRecord(Logger::CRITICAL)); + $this->assertFalse($test->hasCriticalRecords()); + $handler->handle($this->getRecord(Logger::ALERT)); + $this->assertFalse($test->hasAlertRecords()); + $handler->handle($this->getRecord(Logger::EMERGENCY)); + $this->assertFalse($test->hasEmergencyRecords()); + + $test = new TestHandler(); + $handler = new FilterHandler($test, array(Logger::INFO, Logger::ERROR)); + + $handler->handle($this->getRecord(Logger::DEBUG)); + $this->assertFalse($test->hasDebugRecords()); + $handler->handle($this->getRecord(Logger::INFO)); + $this->assertTrue($test->hasInfoRecords()); + $handler->handle($this->getRecord(Logger::NOTICE)); + $this->assertFalse($test->hasNoticeRecords()); + $handler->handle($this->getRecord(Logger::ERROR)); + $this->assertTrue($test->hasErrorRecords()); + $handler->handle($this->getRecord(Logger::CRITICAL)); + $this->assertFalse($test->hasCriticalRecords()); + } + + /** + * @covers Monolog\Handler\FilterHandler::setAcceptedLevels + * @covers Monolog\Handler\FilterHandler::getAcceptedLevels + */ + public function testAcceptedLevelApi() + { + $test = new TestHandler(); + $handler = new FilterHandler($test); + + $levels = array(Logger::INFO, Logger::ERROR); + $handler->setAcceptedLevels($levels); + $this->assertSame($levels, $handler->getAcceptedLevels()); + } + + /** + * @covers Monolog\Handler\FilterHandler::handle + */ + public function testHandleUsesProcessors() + { + $test = new TestHandler(); + $handler = new FilterHandler($test, Logger::DEBUG, Logger::EMERGENCY); + $handler->pushProcessor( + function ($record) { + $record['extra']['foo'] = true; + + return $record; + } + ); + $handler->handle($this->getRecord(Logger::WARNING)); + $this->assertTrue($test->hasWarningRecords()); + $records = $test->getRecords(); + $this->assertTrue($records[0]['extra']['foo']); + } + + /** + * @covers Monolog\Handler\FilterHandler::handle + */ + public function testHandleRespectsBubble() + { + $test = new TestHandler(); + + $handler = new FilterHandler($test, Logger::INFO, Logger::NOTICE, false); + $this->assertTrue($handler->handle($this->getRecord(Logger::INFO))); + $this->assertFalse($handler->handle($this->getRecord(Logger::WARNING))); + + $handler = new FilterHandler($test, Logger::INFO, Logger::NOTICE, true); + $this->assertFalse($handler->handle($this->getRecord(Logger::INFO))); + $this->assertFalse($handler->handle($this->getRecord(Logger::WARNING))); + } + + /** + * @covers Monolog\Handler\FilterHandler::handle + */ + public function testHandleWithCallback() + { + $test = new TestHandler(); + $handler = new FilterHandler( + function ($record, $handler) use ($test) { + return $test; + }, Logger::INFO, Logger::NOTICE, false + ); + $handler->handle($this->getRecord(Logger::DEBUG)); + $handler->handle($this->getRecord(Logger::INFO)); + $this->assertFalse($test->hasDebugRecords()); + $this->assertTrue($test->hasInfoRecords()); + } + + /** + * @covers Monolog\Handler\FilterHandler::handle + * @expectedException \RuntimeException + */ + public function testHandleWithBadCallbackThrowsException() + { + $handler = new FilterHandler( + function ($record, $handler) { + return 'foo'; + } + ); + $handler->handle($this->getRecord(Logger::WARNING)); + } +} diff --git a/vendor/monolog/monolog/tests/Monolog/Handler/FingersCrossedHandlerTest.php b/vendor/monolog/monolog/tests/Monolog/Handler/FingersCrossedHandlerTest.php new file mode 100755 index 0000000..12c5ea1 --- /dev/null +++ b/vendor/monolog/monolog/tests/Monolog/Handler/FingersCrossedHandlerTest.php @@ -0,0 +1,189 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Handler; + +use Monolog\TestCase; +use Monolog\Logger; +use Monolog\Handler\FingersCrossed\ErrorLevelActivationStrategy; +use Monolog\Handler\FingersCrossed\ChannelLevelActivationStrategy; + +class FingersCrossedHandlerTest extends TestCase +{ + /** + * @covers Monolog\Handler\FingersCrossedHandler::__construct + * @covers Monolog\Handler\FingersCrossedHandler::handle + */ + public function testHandleBuffers() + { + $test = new TestHandler(); + $handler = new FingersCrossedHandler($test); + $handler->handle($this->getRecord(Logger::DEBUG)); + $handler->handle($this->getRecord(Logger::INFO)); + $this->assertFalse($test->hasDebugRecords()); + $this->assertFalse($test->hasInfoRecords()); + $handler->handle($this->getRecord(Logger::WARNING)); + $this->assertTrue($test->hasInfoRecords()); + $this->assertTrue(count($test->getRecords()) === 3); + } + + /** + * @covers Monolog\Handler\FingersCrossedHandler::handle + */ + public function testHandleStopsBufferingAfterTrigger() + { + $test = new TestHandler(); + $handler = new FingersCrossedHandler($test); + $handler->handle($this->getRecord(Logger::WARNING)); + $handler->handle($this->getRecord(Logger::DEBUG)); + $this->assertTrue($test->hasWarningRecords()); + $this->assertTrue($test->hasDebugRecords()); + } + + /** + * @covers Monolog\Handler\FingersCrossedHandler::handle + * @covers Monolog\Handler\FingersCrossedHandler::reset + */ + public function testHandleRestartBufferingAfterReset() + { + $test = new TestHandler(); + $handler = new FingersCrossedHandler($test); + $handler->handle($this->getRecord(Logger::WARNING)); + $handler->handle($this->getRecord(Logger::DEBUG)); + $handler->reset(); + $handler->handle($this->getRecord(Logger::INFO)); + $this->assertTrue($test->hasWarningRecords()); + $this->assertTrue($test->hasDebugRecords()); + $this->assertFalse($test->hasInfoRecords()); + } + + /** + * @covers Monolog\Handler\FingersCrossedHandler::handle + */ + public function testHandleRestartBufferingAfterBeingTriggeredWhenStopBufferingIsDisabled() + { + $test = new TestHandler(); + $handler = new FingersCrossedHandler($test, Logger::WARNING, 0, false, false); + $handler->handle($this->getRecord(Logger::DEBUG)); + $handler->handle($this->getRecord(Logger::WARNING)); + $handler->handle($this->getRecord(Logger::INFO)); + $this->assertTrue($test->hasWarningRecords()); + $this->assertTrue($test->hasDebugRecords()); + $this->assertFalse($test->hasInfoRecords()); + } + + /** + * @covers Monolog\Handler\FingersCrossedHandler::handle + */ + public function testHandleBufferLimit() + { + $test = new TestHandler(); + $handler = new FingersCrossedHandler($test, Logger::WARNING, 2); + $handler->handle($this->getRecord(Logger::DEBUG)); + $handler->handle($this->getRecord(Logger::DEBUG)); + $handler->handle($this->getRecord(Logger::INFO)); + $handler->handle($this->getRecord(Logger::WARNING)); + $this->assertTrue($test->hasWarningRecords()); + $this->assertTrue($test->hasInfoRecords()); + $this->assertFalse($test->hasDebugRecords()); + } + + /** + * @covers Monolog\Handler\FingersCrossedHandler::handle + */ + public function testHandleWithCallback() + { + $test = new TestHandler(); + $handler = new FingersCrossedHandler(function ($record, $handler) use ($test) { + return $test; + }); + $handler->handle($this->getRecord(Logger::DEBUG)); + $handler->handle($this->getRecord(Logger::INFO)); + $this->assertFalse($test->hasDebugRecords()); + $this->assertFalse($test->hasInfoRecords()); + $handler->handle($this->getRecord(Logger::WARNING)); + $this->assertTrue($test->hasInfoRecords()); + $this->assertTrue(count($test->getRecords()) === 3); + } + + /** + * @covers Monolog\Handler\FingersCrossedHandler::handle + * @expectedException RuntimeException + */ + public function testHandleWithBadCallbackThrowsException() + { + $handler = new FingersCrossedHandler(function ($record, $handler) { + return 'foo'; + }); + $handler->handle($this->getRecord(Logger::WARNING)); + } + + /** + * @covers Monolog\Handler\FingersCrossedHandler::isHandling + */ + public function testIsHandlingAlways() + { + $test = new TestHandler(); + $handler = new FingersCrossedHandler($test, Logger::ERROR); + $this->assertTrue($handler->isHandling($this->getRecord(Logger::DEBUG))); + } + + /** + * @covers Monolog\Handler\FingersCrossedHandler::__construct + * @covers Monolog\Handler\FingersCrossed\ErrorLevelActivationStrategy::__construct + * @covers Monolog\Handler\FingersCrossed\ErrorLevelActivationStrategy::isHandlerActivated + */ + public function testErrorLevelActivationStrategy() + { + $test = new TestHandler(); + $handler = new FingersCrossedHandler($test, new ErrorLevelActivationStrategy(Logger::WARNING)); + $handler->handle($this->getRecord(Logger::DEBUG)); + $this->assertFalse($test->hasDebugRecords()); + $handler->handle($this->getRecord(Logger::WARNING)); + $this->assertTrue($test->hasDebugRecords()); + $this->assertTrue($test->hasWarningRecords()); + } + + /** + * @covers Monolog\Handler\FingersCrossed\ChannelLevelActivationStrategy::__construct + * @covers Monolog\Handler\FingersCrossed\ChannelLevelActivationStrategy::isHandlerActivated + */ + public function testChannelLevelActivationStrategy() + { + $test = new TestHandler(); + $handler = new FingersCrossedHandler($test, new ChannelLevelActivationStrategy(Logger::ERROR, array('othertest' => Logger::DEBUG))); + $handler->handle($this->getRecord(Logger::WARNING)); + $this->assertFalse($test->hasWarningRecords()); + $record = $this->getRecord(Logger::DEBUG); + $record['channel'] = 'othertest'; + $handler->handle($record); + $this->assertTrue($test->hasDebugRecords()); + $this->assertTrue($test->hasWarningRecords()); + } + + /** + * @covers Monolog\Handler\FingersCrossedHandler::handle + */ + public function testHandleUsesProcessors() + { + $test = new TestHandler(); + $handler = new FingersCrossedHandler($test, Logger::INFO); + $handler->pushProcessor(function ($record) { + $record['extra']['foo'] = true; + + return $record; + }); + $handler->handle($this->getRecord(Logger::WARNING)); + $this->assertTrue($test->hasWarningRecords()); + $records = $test->getRecords(); + $this->assertTrue($records[0]['extra']['foo']); + } +} diff --git a/vendor/monolog/monolog/tests/Monolog/Handler/FirePHPHandlerTest.php b/vendor/monolog/monolog/tests/Monolog/Handler/FirePHPHandlerTest.php new file mode 100755 index 0000000..0eb10a6 --- /dev/null +++ b/vendor/monolog/monolog/tests/Monolog/Handler/FirePHPHandlerTest.php @@ -0,0 +1,96 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Handler; + +use Monolog\TestCase; +use Monolog\Logger; + +/** + * @covers Monolog\Handler\FirePHPHandler + */ +class FirePHPHandlerTest extends TestCase +{ + public function setUp() + { + TestFirePHPHandler::reset(); + $_SERVER['HTTP_USER_AGENT'] = 'Monolog Test; FirePHP/1.0'; + } + + public function testHeaders() + { + $handler = new TestFirePHPHandler; + $handler->setFormatter($this->getIdentityFormatter()); + $handler->handle($this->getRecord(Logger::DEBUG)); + $handler->handle($this->getRecord(Logger::WARNING)); + + $expected = array( + 'X-Wf-Protocol-1' => 'http://meta.wildfirehq.org/Protocol/JsonStream/0.2', + 'X-Wf-1-Structure-1' => 'http://meta.firephp.org/Wildfire/Structure/FirePHP/FirebugConsole/0.1', + 'X-Wf-1-Plugin-1' => 'http://meta.firephp.org/Wildfire/Plugin/FirePHP/Library-FirePHPCore/0.3', + 'X-Wf-1-1-1-1' => 'test', + 'X-Wf-1-1-1-2' => 'test', + ); + + $this->assertEquals($expected, $handler->getHeaders()); + } + + public function testConcurrentHandlers() + { + $handler = new TestFirePHPHandler; + $handler->setFormatter($this->getIdentityFormatter()); + $handler->handle($this->getRecord(Logger::DEBUG)); + $handler->handle($this->getRecord(Logger::WARNING)); + + $handler2 = new TestFirePHPHandler; + $handler2->setFormatter($this->getIdentityFormatter()); + $handler2->handle($this->getRecord(Logger::DEBUG)); + $handler2->handle($this->getRecord(Logger::WARNING)); + + $expected = array( + 'X-Wf-Protocol-1' => 'http://meta.wildfirehq.org/Protocol/JsonStream/0.2', + 'X-Wf-1-Structure-1' => 'http://meta.firephp.org/Wildfire/Structure/FirePHP/FirebugConsole/0.1', + 'X-Wf-1-Plugin-1' => 'http://meta.firephp.org/Wildfire/Plugin/FirePHP/Library-FirePHPCore/0.3', + 'X-Wf-1-1-1-1' => 'test', + 'X-Wf-1-1-1-2' => 'test', + ); + + $expected2 = array( + 'X-Wf-1-1-1-3' => 'test', + 'X-Wf-1-1-1-4' => 'test', + ); + + $this->assertEquals($expected, $handler->getHeaders()); + $this->assertEquals($expected2, $handler2->getHeaders()); + } +} + +class TestFirePHPHandler extends FirePHPHandler +{ + protected $headers = array(); + + public static function reset() + { + self::$initialized = false; + self::$sendHeaders = true; + self::$messageIndex = 1; + } + + protected function sendHeader($header, $content) + { + $this->headers[$header] = $content; + } + + public function getHeaders() + { + return $this->headers; + } +} diff --git a/vendor/monolog/monolog/tests/Monolog/Handler/Fixtures/.gitkeep b/vendor/monolog/monolog/tests/Monolog/Handler/Fixtures/.gitkeep new file mode 100755 index 0000000..e69de29 diff --git a/vendor/monolog/monolog/tests/Monolog/Handler/FlowdockHandlerTest.php b/vendor/monolog/monolog/tests/Monolog/Handler/FlowdockHandlerTest.php new file mode 100755 index 0000000..4b120d5 --- /dev/null +++ b/vendor/monolog/monolog/tests/Monolog/Handler/FlowdockHandlerTest.php @@ -0,0 +1,88 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Handler; + +use Monolog\Formatter\FlowdockFormatter; +use Monolog\TestCase; +use Monolog\Logger; + +/** + * @author Dominik Liebler + * @see https://www.hipchat.com/docs/api + */ +class FlowdockHandlerTest extends TestCase +{ + /** + * @var resource + */ + private $res; + + /** + * @var FlowdockHandler + */ + private $handler; + + public function setUp() + { + if (!extension_loaded('openssl')) { + $this->markTestSkipped('This test requires openssl to run'); + } + } + + public function testWriteHeader() + { + $this->createHandler(); + $this->handler->handle($this->getRecord(Logger::CRITICAL, 'test1')); + fseek($this->res, 0); + $content = fread($this->res, 1024); + + $this->assertRegexp('/POST \/v1\/messages\/team_inbox\/.* HTTP\/1.1\\r\\nHost: api.flowdock.com\\r\\nContent-Type: application\/json\\r\\nContent-Length: \d{2,4}\\r\\n\\r\\n/', $content); + + return $content; + } + + /** + * @depends testWriteHeader + */ + public function testWriteContent($content) + { + $this->assertRegexp('/"source":"test_source"/', $content); + $this->assertRegexp('/"from_address":"source@test\.com"/', $content); + } + + private function createHandler($token = 'myToken') + { + $constructorArgs = array($token, Logger::DEBUG); + $this->res = fopen('php://memory', 'a'); + $this->handler = $this->getMock( + '\Monolog\Handler\FlowdockHandler', + array('fsockopen', 'streamSetTimeout', 'closeSocket'), + $constructorArgs + ); + + $reflectionProperty = new \ReflectionProperty('\Monolog\Handler\SocketHandler', 'connectionString'); + $reflectionProperty->setAccessible(true); + $reflectionProperty->setValue($this->handler, 'localhost:1234'); + + $this->handler->expects($this->any()) + ->method('fsockopen') + ->will($this->returnValue($this->res)); + $this->handler->expects($this->any()) + ->method('streamSetTimeout') + ->will($this->returnValue(true)); + $this->handler->expects($this->any()) + ->method('closeSocket') + ->will($this->returnValue(true)); + + $this->handler->setFormatter(new FlowdockFormatter('test_source', 'source@test.com')); + } +} diff --git a/vendor/monolog/monolog/tests/Monolog/Handler/GelfHandlerLegacyTest.php b/vendor/monolog/monolog/tests/Monolog/Handler/GelfHandlerLegacyTest.php new file mode 100755 index 0000000..d60a6db --- /dev/null +++ b/vendor/monolog/monolog/tests/Monolog/Handler/GelfHandlerLegacyTest.php @@ -0,0 +1,93 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Handler; + +use Gelf\Message; +use Monolog\TestCase; +use Monolog\Logger; +use Monolog\Formatter\GelfMessageFormatter; + +class GelfHandlerLegacyTest extends TestCase +{ + public function setUp() + { + if (!class_exists('Gelf\MessagePublisher') || !class_exists('Gelf\Message')) { + $this->markTestSkipped("mlehner/gelf-php not installed"); + } + } + + /** + * @covers Monolog\Handler\GelfHandler::__construct + */ + public function testConstruct() + { + $handler = new GelfHandler($this->getMessagePublisher()); + $this->assertInstanceOf('Monolog\Handler\GelfHandler', $handler); + } + + protected function getHandler($messagePublisher) + { + $handler = new GelfHandler($messagePublisher); + + return $handler; + } + + protected function getMessagePublisher() + { + return new MockMessagePublisher('localhost'); + } + + public function testDebug() + { + $messagePublisher = $this->getMessagePublisher(); + $handler = $this->getHandler($messagePublisher); + + $record = $this->getRecord(Logger::DEBUG, "A test debug message"); + $handler->handle($record); + + $this->assertEquals(7, $messagePublisher->lastMessage->getLevel()); + $this->assertEquals('test', $messagePublisher->lastMessage->getFacility()); + $this->assertEquals($record['message'], $messagePublisher->lastMessage->getShortMessage()); + $this->assertEquals(null, $messagePublisher->lastMessage->getFullMessage()); + } + + public function testWarning() + { + $messagePublisher = $this->getMessagePublisher(); + $handler = $this->getHandler($messagePublisher); + + $record = $this->getRecord(Logger::WARNING, "A test warning message"); + $handler->handle($record); + + $this->assertEquals(4, $messagePublisher->lastMessage->getLevel()); + $this->assertEquals('test', $messagePublisher->lastMessage->getFacility()); + $this->assertEquals($record['message'], $messagePublisher->lastMessage->getShortMessage()); + $this->assertEquals(null, $messagePublisher->lastMessage->getFullMessage()); + } + + public function testInjectedGelfMessageFormatter() + { + $messagePublisher = $this->getMessagePublisher(); + $handler = $this->getHandler($messagePublisher); + + $handler->setFormatter(new GelfMessageFormatter('mysystem', 'EXT', 'CTX')); + + $record = $this->getRecord(Logger::WARNING, "A test warning message"); + $record['extra']['blarg'] = 'yep'; + $record['context']['from'] = 'logger'; + $handler->handle($record); + + $this->assertEquals('mysystem', $messagePublisher->lastMessage->getHost()); + $this->assertArrayHasKey('_EXTblarg', $messagePublisher->lastMessage->toArray()); + $this->assertArrayHasKey('_CTXfrom', $messagePublisher->lastMessage->toArray()); + } +} diff --git a/vendor/monolog/monolog/tests/Monolog/Handler/GelfHandlerTest.php b/vendor/monolog/monolog/tests/Monolog/Handler/GelfHandlerTest.php new file mode 100755 index 0000000..8313687 --- /dev/null +++ b/vendor/monolog/monolog/tests/Monolog/Handler/GelfHandlerTest.php @@ -0,0 +1,119 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Handler; + +use Gelf\Message; +use Monolog\TestCase; +use Monolog\Logger; +use Monolog\Formatter\GelfMessageFormatter; + +class GelfHandlerTest extends TestCase +{ + public function setUp() + { + if (!class_exists('Gelf\Publisher') || !class_exists('Gelf\Message')) { + $this->markTestSkipped("graylog2/gelf-php not installed"); + } + } + + /** + * @covers Monolog\Handler\GelfHandler::__construct + */ + public function testConstruct() + { + $handler = new GelfHandler($this->getMessagePublisher()); + $this->assertInstanceOf('Monolog\Handler\GelfHandler', $handler); + } + + protected function getHandler($messagePublisher) + { + $handler = new GelfHandler($messagePublisher); + + return $handler; + } + + protected function getMessagePublisher() + { + return $this->getMock('Gelf\Publisher', array('publish'), array(), '', false); + } + + public function testDebug() + { + $record = $this->getRecord(Logger::DEBUG, "A test debug message"); + $expectedMessage = new Message(); + $expectedMessage + ->setLevel(7) + ->setFacility("test") + ->setShortMessage($record['message']) + ->setTimestamp($record['datetime']) + ; + + $messagePublisher = $this->getMessagePublisher(); + $messagePublisher->expects($this->once()) + ->method('publish') + ->with($expectedMessage); + + $handler = $this->getHandler($messagePublisher); + + $handler->handle($record); + + } + + public function testWarning() + { + $record = $this->getRecord(Logger::WARNING, "A test warning message"); + $expectedMessage = new Message(); + $expectedMessage + ->setLevel(4) + ->setFacility("test") + ->setShortMessage($record['message']) + ->setTimestamp($record['datetime']) + ; + + $messagePublisher = $this->getMessagePublisher(); + $messagePublisher->expects($this->once()) + ->method('publish') + ->with($expectedMessage); + + $handler = $this->getHandler($messagePublisher); + + $handler->handle($record); + } + + public function testInjectedGelfMessageFormatter() + { + $record = $this->getRecord(Logger::WARNING, "A test warning message"); + $record['extra']['blarg'] = 'yep'; + $record['context']['from'] = 'logger'; + + $expectedMessage = new Message(); + $expectedMessage + ->setLevel(4) + ->setFacility("test") + ->setHost("mysystem") + ->setShortMessage($record['message']) + ->setTimestamp($record['datetime']) + ->setAdditional("EXTblarg", 'yep') + ->setAdditional("CTXfrom", 'logger') + ; + + $messagePublisher = $this->getMessagePublisher(); + $messagePublisher->expects($this->once()) + ->method('publish') + ->with($expectedMessage); + + $handler = $this->getHandler($messagePublisher); + $handler->setFormatter(new GelfMessageFormatter('mysystem', 'EXT', 'CTX')); + $handler->handle($record); + + } +} diff --git a/vendor/monolog/monolog/tests/Monolog/Handler/GroupHandlerTest.php b/vendor/monolog/monolog/tests/Monolog/Handler/GroupHandlerTest.php new file mode 100755 index 0000000..c6298a6 --- /dev/null +++ b/vendor/monolog/monolog/tests/Monolog/Handler/GroupHandlerTest.php @@ -0,0 +1,89 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Handler; + +use Monolog\TestCase; +use Monolog\Logger; + +class GroupHandlerTest extends TestCase +{ + /** + * @covers Monolog\Handler\GroupHandler::__construct + * @expectedException InvalidArgumentException + */ + public function testConstructorOnlyTakesHandler() + { + new GroupHandler(array(new TestHandler(), "foo")); + } + + /** + * @covers Monolog\Handler\GroupHandler::__construct + * @covers Monolog\Handler\GroupHandler::handle + */ + public function testHandle() + { + $testHandlers = array(new TestHandler(), new TestHandler()); + $handler = new GroupHandler($testHandlers); + $handler->handle($this->getRecord(Logger::DEBUG)); + $handler->handle($this->getRecord(Logger::INFO)); + foreach ($testHandlers as $test) { + $this->assertTrue($test->hasDebugRecords()); + $this->assertTrue($test->hasInfoRecords()); + $this->assertTrue(count($test->getRecords()) === 2); + } + } + + /** + * @covers Monolog\Handler\GroupHandler::handleBatch + */ + public function testHandleBatch() + { + $testHandlers = array(new TestHandler(), new TestHandler()); + $handler = new GroupHandler($testHandlers); + $handler->handleBatch(array($this->getRecord(Logger::DEBUG), $this->getRecord(Logger::INFO))); + foreach ($testHandlers as $test) { + $this->assertTrue($test->hasDebugRecords()); + $this->assertTrue($test->hasInfoRecords()); + $this->assertTrue(count($test->getRecords()) === 2); + } + } + + /** + * @covers Monolog\Handler\GroupHandler::isHandling + */ + public function testIsHandling() + { + $testHandlers = array(new TestHandler(Logger::ERROR), new TestHandler(Logger::WARNING)); + $handler = new GroupHandler($testHandlers); + $this->assertTrue($handler->isHandling($this->getRecord(Logger::ERROR))); + $this->assertTrue($handler->isHandling($this->getRecord(Logger::WARNING))); + $this->assertFalse($handler->isHandling($this->getRecord(Logger::DEBUG))); + } + + /** + * @covers Monolog\Handler\GroupHandler::handle + */ + public function testHandleUsesProcessors() + { + $test = new TestHandler(); + $handler = new GroupHandler(array($test)); + $handler->pushProcessor(function ($record) { + $record['extra']['foo'] = true; + + return $record; + }); + $handler->handle($this->getRecord(Logger::WARNING)); + $this->assertTrue($test->hasWarningRecords()); + $records = $test->getRecords(); + $this->assertTrue($records[0]['extra']['foo']); + } +} diff --git a/vendor/monolog/monolog/tests/Monolog/Handler/HipChatHandlerTest.php b/vendor/monolog/monolog/tests/Monolog/Handler/HipChatHandlerTest.php new file mode 100755 index 0000000..8b9e4d4 --- /dev/null +++ b/vendor/monolog/monolog/tests/Monolog/Handler/HipChatHandlerTest.php @@ -0,0 +1,167 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Handler; + +use Monolog\TestCase; +use Monolog\Logger; + +/** + * @author Rafael Dohms + * @see https://www.hipchat.com/docs/api + */ +class HipChatHandlerTest extends TestCase +{ + + private $res; + private $handler; + + public function testWriteHeader() + { + $this->createHandler(); + $this->handler->handle($this->getRecord(Logger::CRITICAL, 'test1')); + fseek($this->res, 0); + $content = fread($this->res, 1024); + + $this->assertRegexp('/POST \/v1\/rooms\/message\?format=json&auth_token=.* HTTP\/1.1\\r\\nHost: api.hipchat.com\\r\\nContent-Type: application\/x-www-form-urlencoded\\r\\nContent-Length: \d{2,4}\\r\\n\\r\\n/', $content); + + return $content; + } + + /** + * @depends testWriteHeader + */ + public function testWriteContent($content) + { + $this->assertRegexp('/from=Monolog&room_id=room1¬ify=0&message=test1&message_format=text&color=red$/', $content); + } + + public function testWriteWithComplexMessage() + { + $this->createHandler(); + $this->handler->handle($this->getRecord(Logger::CRITICAL, 'Backup of database "example" finished in 16 minutes.')); + fseek($this->res, 0); + $content = fread($this->res, 1024); + + $this->assertRegexp('/message=Backup\+of\+database\+%22example%22\+finished\+in\+16\+minutes\./', $content); + } + + /** + * @dataProvider provideLevelColors + */ + public function testWriteWithErrorLevelsAndColors($level, $expectedColor) + { + $this->createHandler(); + $this->handler->handle($this->getRecord($level, 'Backup of database "example" finished in 16 minutes.')); + fseek($this->res, 0); + $content = fread($this->res, 1024); + + $this->assertRegexp('/color='.$expectedColor.'/', $content); + } + + public function provideLevelColors() + { + return array( + array(Logger::DEBUG, 'gray'), + array(Logger::INFO, 'green'), + array(Logger::WARNING, 'yellow'), + array(Logger::ERROR, 'red'), + array(Logger::CRITICAL, 'red'), + array(Logger::ALERT, 'red'), + array(Logger::EMERGENCY,'red'), + array(Logger::NOTICE, 'green'), + ); + } + + /** + * @dataProvider provideBatchRecords + */ + public function testHandleBatch($records, $expectedColor) + { + $this->createHandler(); + + $this->handler->handleBatch($records); + + fseek($this->res, 0); + $content = fread($this->res, 1024); + + $this->assertRegexp('/color='.$expectedColor.'/', $content); + } + + public function provideBatchRecords() + { + return array( + array( + array( + array('level' => Logger::WARNING, 'message' => 'Oh bugger!', 'level_name' => 'warning', 'datetime' => new \DateTime()), + array('level' => Logger::NOTICE, 'message' => 'Something noticeable happened.', 'level_name' => 'notice', 'datetime' => new \DateTime()), + array('level' => Logger::CRITICAL, 'message' => 'Everything is broken!', 'level_name' => 'critical', 'datetime' => new \DateTime()) + ), + 'red', + ), + array( + array( + array('level' => Logger::WARNING, 'message' => 'Oh bugger!', 'level_name' => 'warning', 'datetime' => new \DateTime()), + array('level' => Logger::NOTICE, 'message' => 'Something noticeable happened.', 'level_name' => 'notice', 'datetime' => new \DateTime()), + ), + 'yellow', + ), + array( + array( + array('level' => Logger::DEBUG, 'message' => 'Just debugging.', 'level_name' => 'debug', 'datetime' => new \DateTime()), + array('level' => Logger::NOTICE, 'message' => 'Something noticeable happened.', 'level_name' => 'notice', 'datetime' => new \DateTime()), + ), + 'green', + ), + array( + array( + array('level' => Logger::DEBUG, 'message' => 'Just debugging.', 'level_name' => 'debug', 'datetime' => new \DateTime()), + ), + 'gray', + ), + ); + } + + private function createHandler($token = 'myToken', $room = 'room1', $name = 'Monolog', $notify = false) + { + $constructorArgs = array($token, $room, $name, $notify, Logger::DEBUG); + $this->res = fopen('php://memory', 'a'); + $this->handler = $this->getMock( + '\Monolog\Handler\HipChatHandler', + array('fsockopen', 'streamSetTimeout', 'closeSocket'), + $constructorArgs + ); + + $reflectionProperty = new \ReflectionProperty('\Monolog\Handler\SocketHandler', 'connectionString'); + $reflectionProperty->setAccessible(true); + $reflectionProperty->setValue($this->handler, 'localhost:1234'); + + $this->handler->expects($this->any()) + ->method('fsockopen') + ->will($this->returnValue($this->res)); + $this->handler->expects($this->any()) + ->method('streamSetTimeout') + ->will($this->returnValue(true)); + $this->handler->expects($this->any()) + ->method('closeSocket') + ->will($this->returnValue(true)); + + $this->handler->setFormatter($this->getIdentityFormatter()); + } + + /** + * @expectedException InvalidArgumentException + */ + public function testCreateWithTooLongName() + { + $hipChatHandler = new \Monolog\Handler\HipChatHandler('token', 'room', 'SixteenCharsHere'); + } +} diff --git a/vendor/monolog/monolog/tests/Monolog/Handler/LogEntriesHandlerTest.php b/vendor/monolog/monolog/tests/Monolog/Handler/LogEntriesHandlerTest.php new file mode 100755 index 0000000..7af60be --- /dev/null +++ b/vendor/monolog/monolog/tests/Monolog/Handler/LogEntriesHandlerTest.php @@ -0,0 +1,84 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Handler; + +use Monolog\TestCase; +use Monolog\Logger; + +/** + * @author Robert Kaufmann III + */ +class LogEntriesHandlerTest extends TestCase +{ + /** + * @var resource + */ + private $res; + + /** + * @var LogEntriesHandler + */ + private $handler; + + public function testWriteContent() + { + $this->createHandler(); + $this->handler->handle($this->getRecord(Logger::CRITICAL, 'Critical write test')); + + fseek($this->res, 0); + $content = fread($this->res, 1024); + + $this->assertRegexp('/testToken \[\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\] test.CRITICAL: Critical write test/', $content); + } + + public function testWriteBatchContent() + { + $records = array( + $this->getRecord(), + $this->getRecord(), + $this->getRecord() + ); + $this->createHandler(); + $this->handler->handleBatch($records); + + fseek($this->res, 0); + $content = fread($this->res, 1024); + + $this->assertRegexp('/(testToken \[\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\] .* \[\] \[\]\n){3}/', $content); + } + + private function createHandler() + { + $useSSL = extension_loaded('openssl'); + $args = array('testToken', $useSSL, Logger::DEBUG, true); + $this->res = fopen('php://memory', 'a'); + $this->handler = $this->getMock( + '\Monolog\Handler\LogEntriesHandler', + array('fsockopen', 'streamSetTimeout', 'closeSocket'), + $args + ); + + $reflectionProperty = new \ReflectionProperty('\Monolog\Handler\SocketHandler', 'connectionString'); + $reflectionProperty->setAccessible(true); + $reflectionProperty->setValue($this->handler, 'localhost:1234'); + + $this->handler->expects($this->any()) + ->method('fsockopen') + ->will($this->returnValue($this->res)); + $this->handler->expects($this->any()) + ->method('streamSetTimeout') + ->will($this->returnValue(true)); + $this->handler->expects($this->any()) + ->method('closeSocket') + ->will($this->returnValue(true)); + } +} diff --git a/vendor/monolog/monolog/tests/Monolog/Handler/MailHandlerTest.php b/vendor/monolog/monolog/tests/Monolog/Handler/MailHandlerTest.php new file mode 100755 index 0000000..6754f3d --- /dev/null +++ b/vendor/monolog/monolog/tests/Monolog/Handler/MailHandlerTest.php @@ -0,0 +1,75 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Handler; + +use Monolog\Logger; +use Monolog\TestCase; + +class MailHandlerTest extends TestCase +{ + /** + * @covers Monolog\Handler\MailHandler::handleBatch + */ + public function testHandleBatch() + { + $formatter = $this->getMock('Monolog\\Formatter\\FormatterInterface'); + $formatter->expects($this->once()) + ->method('formatBatch'); // Each record is formatted + + $handler = $this->getMockForAbstractClass('Monolog\\Handler\\MailHandler'); + $handler->expects($this->once()) + ->method('send'); + $handler->expects($this->never()) + ->method('write'); // write is for individual records + + $handler->setFormatter($formatter); + + $handler->handleBatch($this->getMultipleRecords()); + } + + /** + * @covers Monolog\Handler\MailHandler::handleBatch + */ + public function testHandleBatchNotSendsMailIfMessagesAreBelowLevel() + { + $records = array( + $this->getRecord(Logger::DEBUG, 'debug message 1'), + $this->getRecord(Logger::DEBUG, 'debug message 2'), + $this->getRecord(Logger::INFO, 'information'), + ); + + $handler = $this->getMockForAbstractClass('Monolog\\Handler\\MailHandler'); + $handler->expects($this->never()) + ->method('send'); + $handler->setLevel(Logger::ERROR); + + $handler->handleBatch($records); + } + + /** + * @covers Monolog\Handler\MailHandler::write + */ + public function testHandle() + { + $handler = $this->getMockForAbstractClass('Monolog\\Handler\\MailHandler'); + + $record = $this->getRecord(); + $records = array($record); + $records[0]['formatted'] = '['.$record['datetime']->format('Y-m-d H:i:s').'] test.WARNING: test [] []'."\n"; + + $handler->expects($this->once()) + ->method('send') + ->with($records[0]['formatted'], $records); + + $handler->handle($record); + } +} diff --git a/vendor/monolog/monolog/tests/Monolog/Handler/MockRavenClient.php b/vendor/monolog/monolog/tests/Monolog/Handler/MockRavenClient.php new file mode 100755 index 0000000..fbaab9b --- /dev/null +++ b/vendor/monolog/monolog/tests/Monolog/Handler/MockRavenClient.php @@ -0,0 +1,26 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Handler; + +use Raven_Client; + +class MockRavenClient extends Raven_Client +{ + public function capture($data, $stack, $vars = null) + { + $this->lastData = $data; + $this->lastStack = $stack; + } + + public $lastData; + public $lastStack; +} diff --git a/vendor/monolog/monolog/tests/Monolog/Handler/MongoDBHandlerTest.php b/vendor/monolog/monolog/tests/Monolog/Handler/MongoDBHandlerTest.php new file mode 100755 index 0000000..7f06d66 --- /dev/null +++ b/vendor/monolog/monolog/tests/Monolog/Handler/MongoDBHandlerTest.php @@ -0,0 +1,63 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Handler; + +use Monolog\TestCase; +use Monolog\Logger; + +class MongoDBHandlerTest extends TestCase +{ + /** + * @expectedException InvalidArgumentException + */ + public function testConstructorShouldThrowExceptionForInvalidMongo() + { + new MongoDBHandler(new \stdClass(), 'DB', 'Collection'); + } + + public function testHandle() + { + $mongo = $this->getMock('Mongo', array('selectCollection'), array(), '', false); + $collection = $this->getMock('stdClass', array('save')); + + $mongo->expects($this->once()) + ->method('selectCollection') + ->with('DB', 'Collection') + ->will($this->returnValue($collection)); + + $record = $this->getRecord(Logger::WARNING, 'test', array('data' => new \stdClass, 'foo' => 34)); + + $expected = array( + 'message' => 'test', + 'context' => array('data' => '[object] (stdClass: {})', 'foo' => 34), + 'level' => Logger::WARNING, + 'level_name' => 'WARNING', + 'channel' => 'test', + 'datetime' => $record['datetime']->format('Y-m-d H:i:s'), + 'extra' => array(), + ); + + $collection->expects($this->once()) + ->method('save') + ->with($expected); + + $handler = new MongoDBHandler($mongo, 'DB', 'Collection'); + $handler->handle($record); + } +} + +if (!class_exists('Mongo')) { + class Mongo + { + public function selectCollection() {} + } +} diff --git a/vendor/monolog/monolog/tests/Monolog/Handler/NativeMailerHandlerTest.php b/vendor/monolog/monolog/tests/Monolog/Handler/NativeMailerHandlerTest.php new file mode 100755 index 0000000..50ceace --- /dev/null +++ b/vendor/monolog/monolog/tests/Monolog/Handler/NativeMailerHandlerTest.php @@ -0,0 +1,43 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Handler; + +use Monolog\TestCase; + +class NativeMailerHandlerTest extends TestCase +{ + /** + * @expectedException InvalidArgumentException + */ + public function testConstructorHeaderInjection() + { + $mailer = new NativeMailerHandler('spammer@example.org', 'dear victim', "receiver@example.org\r\nFrom: faked@attacker.org"); + } + + /** + * @expectedException InvalidArgumentException + */ + public function testSetterHeaderInjection() + { + $mailer = new NativeMailerHandler('spammer@example.org', 'dear victim', 'receiver@example.org'); + $mailer->addHeader("Content-Type: text/html\r\nFrom: faked@attacker.org"); + } + + /** + * @expectedException InvalidArgumentException + */ + public function testSetterArrayHeaderInjection() + { + $mailer = new NativeMailerHandler('spammer@example.org', 'dear victim', 'receiver@example.org'); + $mailer->addHeader(array("Content-Type: text/html\r\nFrom: faked@attacker.org")); + } +} diff --git a/vendor/monolog/monolog/tests/Monolog/Handler/NewRelicHandlerTest.php b/vendor/monolog/monolog/tests/Monolog/Handler/NewRelicHandlerTest.php new file mode 100755 index 0000000..f959a36 --- /dev/null +++ b/vendor/monolog/monolog/tests/Monolog/Handler/NewRelicHandlerTest.php @@ -0,0 +1,102 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Handler; + +use Monolog\TestCase; +use Monolog\Logger; +use Psr\Log\LogLevel; + +class NewRelicHandlerTest extends TestCase +{ + public static $appname; + + public function setUp() + { + $this::$appname = null; + } + + /** + * @expectedException Monolog\Handler\MissingExtensionException + */ + public function testThehandlerThrowsAnExceptionIfTheNRExtensionIsNotLoaded() + { + $handler = new StubNewRelicHandlerWithoutExtension(); + $handler->handle($this->getRecord(Logger::ERROR)); + } + + public function testThehandlerCanHandleTheRecord() + { + $handler = new StubNewRelicHandler(); + $handler->handle($this->getRecord(Logger::ERROR)); + } + + public function testThehandlerCanAddParamsToTheNewRelicTrace() + { + $handler = new StubNewRelicHandler(); + $handler->handle($this->getRecord(Logger::ERROR, 'log message', array('a' => 'b'))); + } + + public function testTheAppNameIsNullByDefault() + { + $handler = new StubNewRelicHandler(); + $handler->handle($this->getRecord(Logger::ERROR, 'log message')); + + $this->assertEquals(null, $this::$appname); + } + + public function testTheAppNameCanBeInjectedFromtheConstructor() + { + $handler = new StubNewRelicHandler(LogLevel::ALERT, false, 'myAppName'); + $handler->handle($this->getRecord(Logger::ERROR, 'log message')); + + $this->assertEquals('myAppName', $this::$appname); + } + + public function testTheAppNameCanBeOverriddenFromEachLog() + { + $handler = new StubNewRelicHandler(LogLevel::ALERT, false, 'myAppName'); + $handler->handle($this->getRecord(Logger::ERROR, 'log message', array('appname' => 'logAppName'))); + + $this->assertEquals('logAppName', $this::$appname); + } +} + +class StubNewRelicHandlerWithoutExtension extends NewRelicHandler +{ + protected function isNewRelicEnabled() + { + return false; + } +} + +class StubNewRelicHandler extends NewRelicHandler +{ + protected function isNewRelicEnabled() + { + return true; + } +} + +function newrelic_notice_error() +{ + return true; +} + +function newrelic_set_appname($appname) +{ + return NewRelicHandlerTest::$appname = $appname; +} + +function newrelic_add_custom_parameter() +{ + return true; +} diff --git a/vendor/monolog/monolog/tests/Monolog/Handler/NullHandlerTest.php b/vendor/monolog/monolog/tests/Monolog/Handler/NullHandlerTest.php new file mode 100755 index 0000000..292df78 --- /dev/null +++ b/vendor/monolog/monolog/tests/Monolog/Handler/NullHandlerTest.php @@ -0,0 +1,33 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Handler; + +use Monolog\TestCase; +use Monolog\Logger; + +/** + * @covers Monolog\Handler\NullHandler::handle + */ +class NullHandlerTest extends TestCase +{ + public function testHandle() + { + $handler = new NullHandler(); + $this->assertTrue($handler->handle($this->getRecord())); + } + + public function testHandleLowerLevelRecord() + { + $handler = new NullHandler(Logger::WARNING); + $this->assertFalse($handler->handle($this->getRecord(Logger::DEBUG))); + } +} diff --git a/vendor/monolog/monolog/tests/Monolog/Handler/PushoverHandlerTest.php b/vendor/monolog/monolog/tests/Monolog/Handler/PushoverHandlerTest.php new file mode 100755 index 0000000..e048a02 --- /dev/null +++ b/vendor/monolog/monolog/tests/Monolog/Handler/PushoverHandlerTest.php @@ -0,0 +1,142 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Handler; + +use Monolog\TestCase; +use Monolog\Logger; + +/** + * Almost all examples (expected header, titles, messages) taken from + * https://www.pushover.net/api + * @author Sebastian Göttschkes + * @see https://www.pushover.net/api + */ +class PushoverHandlerTest extends TestCase +{ + + private $res; + private $handler; + + public function testWriteHeader() + { + $this->createHandler(); + $this->handler->setHighPriorityLevel(Logger::EMERGENCY); // skip priority notifications + $this->handler->handle($this->getRecord(Logger::CRITICAL, 'test1')); + fseek($this->res, 0); + $content = fread($this->res, 1024); + + $this->assertRegexp('/POST \/1\/messages.json HTTP\/1.1\\r\\nHost: api.pushover.net\\r\\nContent-Type: application\/x-www-form-urlencoded\\r\\nContent-Length: \d{2,4}\\r\\n\\r\\n/', $content); + + return $content; + } + + /** + * @depends testWriteHeader + */ + public function testWriteContent($content) + { + $this->assertRegexp('/token=myToken&user=myUser&message=test1&title=Monolog×tamp=\d{10}$/', $content); + } + + public function testWriteWithComplexTitle() + { + $this->createHandler('myToken', 'myUser', 'Backup finished - SQL1', Logger::EMERGENCY); + $this->handler->handle($this->getRecord(Logger::CRITICAL, 'test1')); + fseek($this->res, 0); + $content = fread($this->res, 1024); + + $this->assertRegexp('/title=Backup\+finished\+-\+SQL1/', $content); + } + + public function testWriteWithComplexMessage() + { + $this->createHandler(); + $this->handler->setHighPriorityLevel(Logger::EMERGENCY); // skip priority notifications + $this->handler->handle($this->getRecord(Logger::CRITICAL, 'Backup of database "example" finished in 16 minutes.')); + fseek($this->res, 0); + $content = fread($this->res, 1024); + + $this->assertRegexp('/message=Backup\+of\+database\+%22example%22\+finished\+in\+16\+minutes\./', $content); + } + + public function testWriteWithTooLongMessage() + { + $message = str_pad('test', 520, 'a'); + $this->createHandler(); + $this->handler->setHighPriorityLevel(Logger::EMERGENCY); // skip priority notifications + $this->handler->handle($this->getRecord(Logger::CRITICAL, $message)); + fseek($this->res, 0); + $content = fread($this->res, 1024); + + $expectedMessage = substr($message, 0, 505); + + $this->assertRegexp('/message=' . $expectedMessage . '&title/', $content); + } + + public function testWriteWithHighPriority() + { + $this->createHandler(); + $this->handler->handle($this->getRecord(Logger::CRITICAL, 'test1')); + fseek($this->res, 0); + $content = fread($this->res, 1024); + + $this->assertRegexp('/token=myToken&user=myUser&message=test1&title=Monolog×tamp=\d{10}&priority=1$/', $content); + } + + public function testWriteWithEmergencyPriority() + { + $this->createHandler(); + $this->handler->handle($this->getRecord(Logger::EMERGENCY, 'test1')); + fseek($this->res, 0); + $content = fread($this->res, 1024); + + $this->assertRegexp('/token=myToken&user=myUser&message=test1&title=Monolog×tamp=\d{10}&priority=2&retry=30&expire=25200$/', $content); + } + + public function testWriteToMultipleUsers() + { + $this->createHandler('myToken', array('userA', 'userB')); + $this->handler->handle($this->getRecord(Logger::EMERGENCY, 'test1')); + fseek($this->res, 0); + $content = fread($this->res, 1024); + + $this->assertRegexp('/token=myToken&user=userA&message=test1&title=Monolog×tamp=\d{10}&priority=2&retry=30&expire=25200POST/', $content); + $this->assertRegexp('/token=myToken&user=userB&message=test1&title=Monolog×tamp=\d{10}&priority=2&retry=30&expire=25200$/', $content); + } + + private function createHandler($token = 'myToken', $user = 'myUser', $title = 'Monolog') + { + $constructorArgs = array($token, $user, $title); + $this->res = fopen('php://memory', 'a'); + $this->handler = $this->getMock( + '\Monolog\Handler\PushoverHandler', + array('fsockopen', 'streamSetTimeout', 'closeSocket'), + $constructorArgs + ); + + $reflectionProperty = new \ReflectionProperty('\Monolog\Handler\SocketHandler', 'connectionString'); + $reflectionProperty->setAccessible(true); + $reflectionProperty->setValue($this->handler, 'localhost:1234'); + + $this->handler->expects($this->any()) + ->method('fsockopen') + ->will($this->returnValue($this->res)); + $this->handler->expects($this->any()) + ->method('streamSetTimeout') + ->will($this->returnValue(true)); + $this->handler->expects($this->any()) + ->method('closeSocket') + ->will($this->returnValue(true)); + + $this->handler->setFormatter($this->getIdentityFormatter()); + } +} diff --git a/vendor/monolog/monolog/tests/Monolog/Handler/RavenHandlerTest.php b/vendor/monolog/monolog/tests/Monolog/Handler/RavenHandlerTest.php new file mode 100755 index 0000000..8fe8696 --- /dev/null +++ b/vendor/monolog/monolog/tests/Monolog/Handler/RavenHandlerTest.php @@ -0,0 +1,150 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Handler; + +use Monolog\TestCase; +use Monolog\Logger; +use Monolog\Formatter\LineFormatter; + +class RavenHandlerTest extends TestCase +{ + public function setUp() + { + if (!class_exists("Raven_Client")) { + $this->markTestSkipped("raven/raven not installed"); + } + + require_once __DIR__ . '/MockRavenClient.php'; + } + + /** + * @covers Monolog\Handler\RavenHandler::__construct + */ + public function testConstruct() + { + $handler = new RavenHandler($this->getRavenClient()); + $this->assertInstanceOf('Monolog\Handler\RavenHandler', $handler); + } + + protected function getHandler($ravenClient) + { + $handler = new RavenHandler($ravenClient); + + return $handler; + } + + protected function getRavenClient() + { + $dsn = 'http://43f6017361224d098402974103bfc53d:a6a0538fc2934ba2bed32e08741b2cd3@marca.python.live.cheggnet.com:9000/1'; + + return new MockRavenClient($dsn); + } + + public function testDebug() + { + $ravenClient = $this->getRavenClient(); + $handler = $this->getHandler($ravenClient); + + $record = $this->getRecord(Logger::DEBUG, "A test debug message"); + $handler->handle($record); + + $this->assertEquals($ravenClient::DEBUG, $ravenClient->lastData['level']); + $this->assertContains($record['message'], $ravenClient->lastData['message']); + } + + public function testWarning() + { + $ravenClient = $this->getRavenClient(); + $handler = $this->getHandler($ravenClient); + + $record = $this->getRecord(Logger::WARNING, "A test warning message"); + $handler->handle($record); + + $this->assertEquals($ravenClient::WARNING, $ravenClient->lastData['level']); + $this->assertContains($record['message'], $ravenClient->lastData['message']); + } + + public function testTag() + { + $ravenClient = $this->getRavenClient(); + $handler = $this->getHandler($ravenClient); + + $tags = array(1, 2, 'foo'); + $record = $this->getRecord(Logger::INFO, "test", array('tags' => $tags)); + $handler->handle($record); + + $this->assertEquals($tags, $ravenClient->lastData['tags']); + } + + public function testException() + { + $ravenClient = $this->getRavenClient(); + $handler = $this->getHandler($ravenClient); + + try { + $this->methodThatThrowsAnException(); + } catch (\Exception $e) { + $record = $this->getRecord(Logger::ERROR, $e->getMessage(), array('exception' => $e)); + $handler->handle($record); + } + + $this->assertEquals($record['message'], $ravenClient->lastData['message']); + } + + public function testHandleBatch() + { + $records = $this->getMultipleRecords(); + $records[] = $this->getRecord(Logger::WARNING, 'warning'); + $records[] = $this->getRecord(Logger::WARNING, 'warning'); + + $logFormatter = $this->getMock('Monolog\\Formatter\\FormatterInterface'); + $logFormatter->expects($this->once())->method('formatBatch'); + + $formatter = $this->getMock('Monolog\\Formatter\\FormatterInterface'); + $formatter->expects($this->once())->method('format')->with($this->callback(function ($record) { + return $record['level'] == 400; + })); + + $handler = $this->getHandler($this->getRavenClient()); + $handler->setBatchFormatter($logFormatter); + $handler->setFormatter($formatter); + $handler->handleBatch($records); + } + + public function testHandleBatchDoNothingIfRecordsAreBelowLevel() + { + $records = array( + $this->getRecord(Logger::DEBUG, 'debug message 1'), + $this->getRecord(Logger::DEBUG, 'debug message 2'), + $this->getRecord(Logger::INFO, 'information'), + ); + + $handler = $this->getMock('Monolog\Handler\RavenHandler', null, array($this->getRavenClient())); + $handler->expects($this->never())->method('handle'); + $handler->setLevel(Logger::ERROR); + $handler->handleBatch($records); + } + + public function testGetSetBatchFormatter() + { + $ravenClient = $this->getRavenClient(); + $handler = $this->getHandler($ravenClient); + + $handler->setBatchFormatter($formatter = new LineFormatter()); + $this->assertSame($formatter, $handler->getBatchFormatter()); + } + + private function methodThatThrowsAnException() + { + throw new \Exception('This is an exception'); + } +} diff --git a/vendor/monolog/monolog/tests/Monolog/Handler/RedisHandlerTest.php b/vendor/monolog/monolog/tests/Monolog/Handler/RedisHandlerTest.php new file mode 100755 index 0000000..3629f8a --- /dev/null +++ b/vendor/monolog/monolog/tests/Monolog/Handler/RedisHandlerTest.php @@ -0,0 +1,71 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Handler; + +use Monolog\TestCase; +use Monolog\Logger; +use Monolog\Formatter\LineFormatter; + +class RedisHandlerTest extends TestCase +{ + /** + * @expectedException InvalidArgumentException + */ + public function testConstructorShouldThrowExceptionForInvalidRedis() + { + new RedisHandler(new \stdClass(), 'key'); + } + + public function testConstructorShouldWorkWithPredis() + { + $redis = $this->getMock('Predis\Client'); + $this->assertInstanceof('Monolog\Handler\RedisHandler', new RedisHandler($redis, 'key')); + } + + public function testConstructorShouldWorkWithRedis() + { + $redis = $this->getMock('Redis'); + $this->assertInstanceof('Monolog\Handler\RedisHandler', new RedisHandler($redis, 'key')); + } + + public function testPredisHandle() + { + $redis = $this->getMock('Predis\Client', array('rpush')); + + // Predis\Client uses rpush + $redis->expects($this->once()) + ->method('rpush') + ->with('key', 'test'); + + $record = $this->getRecord(Logger::WARNING, 'test', array('data' => new \stdClass, 'foo' => 34)); + + $handler = new RedisHandler($redis, 'key'); + $handler->setFormatter(new LineFormatter("%message%")); + $handler->handle($record); + } + + public function testRedisHandle() + { + $redis = $this->getMock('Redis', array('rpush')); + + // Redis uses rPush + $redis->expects($this->once()) + ->method('rPush') + ->with('key', 'test'); + + $record = $this->getRecord(Logger::WARNING, 'test', array('data' => new \stdClass, 'foo' => 34)); + + $handler = new RedisHandler($redis, 'key'); + $handler->setFormatter(new LineFormatter("%message%")); + $handler->handle($record); + } +} diff --git a/vendor/monolog/monolog/tests/Monolog/Handler/RotatingFileHandlerTest.php b/vendor/monolog/monolog/tests/Monolog/Handler/RotatingFileHandlerTest.php new file mode 100755 index 0000000..f4cefda --- /dev/null +++ b/vendor/monolog/monolog/tests/Monolog/Handler/RotatingFileHandlerTest.php @@ -0,0 +1,99 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Handler; + +use Monolog\TestCase; + +/** + * @covers Monolog\Handler\RotatingFileHandler + */ +class RotatingFileHandlerTest extends TestCase +{ + public function setUp() + { + $dir = __DIR__.'/Fixtures'; + chmod($dir, 0777); + if (!is_writable($dir)) { + $this->markTestSkipped($dir.' must be writeable to test the RotatingFileHandler.'); + } + } + + public function testRotationCreatesNewFile() + { + touch(__DIR__.'/Fixtures/foo-'.date('Y-m-d', time() - 86400).'.rot'); + + $handler = new RotatingFileHandler(__DIR__.'/Fixtures/foo.rot'); + $handler->setFormatter($this->getIdentityFormatter()); + $handler->handle($this->getRecord()); + + $log = __DIR__.'/Fixtures/foo-'.date('Y-m-d').'.rot'; + $this->assertTrue(file_exists($log)); + $this->assertEquals('test', file_get_contents($log)); + } + + /** + * @dataProvider rotationTests + */ + public function testRotation($createFile) + { + touch($old1 = __DIR__.'/Fixtures/foo-'.date('Y-m-d', time() - 86400).'.rot'); + touch($old2 = __DIR__.'/Fixtures/foo-'.date('Y-m-d', time() - 86400 * 2).'.rot'); + touch($old3 = __DIR__.'/Fixtures/foo-'.date('Y-m-d', time() - 86400 * 3).'.rot'); + touch($old4 = __DIR__.'/Fixtures/foo-'.date('Y-m-d', time() - 86400 * 4).'.rot'); + + $log = __DIR__.'/Fixtures/foo-'.date('Y-m-d').'.rot'; + + if ($createFile) { + touch($log); + } + + $handler = new RotatingFileHandler(__DIR__.'/Fixtures/foo.rot', 2); + $handler->setFormatter($this->getIdentityFormatter()); + $handler->handle($this->getRecord()); + + $handler->close(); + + $this->assertTrue(file_exists($log)); + $this->assertTrue(file_exists($old1)); + $this->assertEquals($createFile, file_exists($old2)); + $this->assertEquals($createFile, file_exists($old3)); + $this->assertEquals($createFile, file_exists($old4)); + $this->assertEquals('test', file_get_contents($log)); + } + + public function rotationTests() + { + return array( + 'Rotation is triggered when the file of the current day is not present' + => array(true), + 'Rotation is not triggered when the file is already present' + => array(false), + ); + } + + public function testReuseCurrentFile() + { + $log = __DIR__.'/Fixtures/foo-'.date('Y-m-d').'.rot'; + file_put_contents($log, "foo"); + $handler = new RotatingFileHandler(__DIR__.'/Fixtures/foo.rot'); + $handler->setFormatter($this->getIdentityFormatter()); + $handler->handle($this->getRecord()); + $this->assertEquals('footest', file_get_contents($log)); + } + + public function tearDown() + { + foreach (glob(__DIR__.'/Fixtures/*.rot') as $file) { + unlink($file); + } + } +} diff --git a/vendor/monolog/monolog/tests/Monolog/Handler/SocketHandlerTest.php b/vendor/monolog/monolog/tests/Monolog/Handler/SocketHandlerTest.php new file mode 100755 index 0000000..3a925eb --- /dev/null +++ b/vendor/monolog/monolog/tests/Monolog/Handler/SocketHandlerTest.php @@ -0,0 +1,283 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Handler; + +use Monolog\TestCase; +use Monolog\Logger; + +/** + * @author Pablo de Leon Belloc + */ +class SocketHandlerTest extends TestCase +{ + /** + * @var Monolog\Handler\SocketHandler + */ + private $handler; + + /** + * @var resource + */ + private $res; + + /** + * @expectedException UnexpectedValueException + */ + public function testInvalidHostname() + { + $this->createHandler('garbage://here'); + $this->writeRecord('data'); + } + + /** + * @expectedException \InvalidArgumentException + */ + public function testBadConnectionTimeout() + { + $this->createHandler('localhost:1234'); + $this->handler->setConnectionTimeout(-1); + } + + public function testSetConnectionTimeout() + { + $this->createHandler('localhost:1234'); + $this->handler->setConnectionTimeout(10.1); + $this->assertEquals(10.1, $this->handler->getConnectionTimeout()); + } + + /** + * @expectedException \InvalidArgumentException + */ + public function testBadTimeout() + { + $this->createHandler('localhost:1234'); + $this->handler->setTimeout(-1); + } + + public function testSetTimeout() + { + $this->createHandler('localhost:1234'); + $this->handler->setTimeout(10.25); + $this->assertEquals(10.25, $this->handler->getTimeout()); + } + + public function testSetConnectionString() + { + $this->createHandler('tcp://localhost:9090'); + $this->assertEquals('tcp://localhost:9090', $this->handler->getConnectionString()); + } + + /** + * @expectedException UnexpectedValueException + */ + public function testExceptionIsThrownOnFsockopenError() + { + $this->setMockHandler(array('fsockopen')); + $this->handler->expects($this->once()) + ->method('fsockopen') + ->will($this->returnValue(false)); + $this->writeRecord('Hello world'); + } + + /** + * @expectedException UnexpectedValueException + */ + public function testExceptionIsThrownOnPfsockopenError() + { + $this->setMockHandler(array('pfsockopen')); + $this->handler->expects($this->once()) + ->method('pfsockopen') + ->will($this->returnValue(false)); + $this->handler->setPersistent(true); + $this->writeRecord('Hello world'); + } + + /** + * @expectedException UnexpectedValueException + */ + public function testExceptionIsThrownIfCannotSetTimeout() + { + $this->setMockHandler(array('streamSetTimeout')); + $this->handler->expects($this->once()) + ->method('streamSetTimeout') + ->will($this->returnValue(false)); + $this->writeRecord('Hello world'); + } + + /** + * @expectedException RuntimeException + */ + public function testWriteFailsOnIfFwriteReturnsFalse() + { + $this->setMockHandler(array('fwrite')); + + $callback = function ($arg) { + $map = array( + 'Hello world' => 6, + 'world' => false, + ); + + return $map[$arg]; + }; + + $this->handler->expects($this->exactly(2)) + ->method('fwrite') + ->will($this->returnCallback($callback)); + + $this->writeRecord('Hello world'); + } + + /** + * @expectedException RuntimeException + */ + public function testWriteFailsIfStreamTimesOut() + { + $this->setMockHandler(array('fwrite', 'streamGetMetadata')); + + $callback = function ($arg) { + $map = array( + 'Hello world' => 6, + 'world' => 5, + ); + + return $map[$arg]; + }; + + $this->handler->expects($this->exactly(1)) + ->method('fwrite') + ->will($this->returnCallback($callback)); + $this->handler->expects($this->exactly(1)) + ->method('streamGetMetadata') + ->will($this->returnValue(array('timed_out' => true))); + + $this->writeRecord('Hello world'); + } + + /** + * @expectedException RuntimeException + */ + public function testWriteFailsOnIncompleteWrite() + { + $this->setMockHandler(array('fwrite', 'streamGetMetadata')); + + $res = $this->res; + $callback = function ($string) use ($res) { + fclose($res); + + return strlen('Hello'); + }; + + $this->handler->expects($this->exactly(1)) + ->method('fwrite') + ->will($this->returnCallback($callback)); + $this->handler->expects($this->exactly(1)) + ->method('streamGetMetadata') + ->will($this->returnValue(array('timed_out' => false))); + + $this->writeRecord('Hello world'); + } + + public function testWriteWithMemoryFile() + { + $this->setMockHandler(); + $this->writeRecord('test1'); + $this->writeRecord('test2'); + $this->writeRecord('test3'); + fseek($this->res, 0); + $this->assertEquals('test1test2test3', fread($this->res, 1024)); + } + + public function testWriteWithMock() + { + $this->setMockHandler(array('fwrite')); + + $callback = function ($arg) { + $map = array( + 'Hello world' => 6, + 'world' => 5, + ); + + return $map[$arg]; + }; + + $this->handler->expects($this->exactly(2)) + ->method('fwrite') + ->will($this->returnCallback($callback)); + + $this->writeRecord('Hello world'); + } + + public function testClose() + { + $this->setMockHandler(); + $this->writeRecord('Hello world'); + $this->assertInternalType('resource', $this->res); + $this->handler->close(); + $this->assertFalse(is_resource($this->res), "Expected resource to be closed after closing handler"); + } + + public function testCloseDoesNotClosePersistentSocket() + { + $this->setMockHandler(); + $this->handler->setPersistent(true); + $this->writeRecord('Hello world'); + $this->assertTrue(is_resource($this->res)); + $this->handler->close(); + $this->assertTrue(is_resource($this->res)); + } + + private function createHandler($connectionString) + { + $this->handler = new SocketHandler($connectionString); + $this->handler->setFormatter($this->getIdentityFormatter()); + } + + private function writeRecord($string) + { + $this->handler->handle($this->getRecord(Logger::WARNING, $string)); + } + + private function setMockHandler(array $methods = array()) + { + $this->res = fopen('php://memory', 'a'); + + $defaultMethods = array('fsockopen', 'pfsockopen', 'streamSetTimeout'); + $newMethods = array_diff($methods, $defaultMethods); + + $finalMethods = array_merge($defaultMethods, $newMethods); + + $this->handler = $this->getMock( + '\Monolog\Handler\SocketHandler', $finalMethods, array('localhost:1234') + ); + + if (!in_array('fsockopen', $methods)) { + $this->handler->expects($this->any()) + ->method('fsockopen') + ->will($this->returnValue($this->res)); + } + + if (!in_array('pfsockopen', $methods)) { + $this->handler->expects($this->any()) + ->method('pfsockopen') + ->will($this->returnValue($this->res)); + } + + if (!in_array('streamSetTimeout', $methods)) { + $this->handler->expects($this->any()) + ->method('streamSetTimeout') + ->will($this->returnValue(true)); + } + + $this->handler->setFormatter($this->getIdentityFormatter()); + } + +} diff --git a/vendor/monolog/monolog/tests/Monolog/Handler/StreamHandlerTest.php b/vendor/monolog/monolog/tests/Monolog/Handler/StreamHandlerTest.php new file mode 100755 index 0000000..63d4fef --- /dev/null +++ b/vendor/monolog/monolog/tests/Monolog/Handler/StreamHandlerTest.php @@ -0,0 +1,88 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Handler; + +use Monolog\TestCase; +use Monolog\Logger; + +class StreamHandlerTest extends TestCase +{ + /** + * @covers Monolog\Handler\StreamHandler::__construct + * @covers Monolog\Handler\StreamHandler::write + */ + public function testWrite() + { + $handle = fopen('php://memory', 'a+'); + $handler = new StreamHandler($handle); + $handler->setFormatter($this->getIdentityFormatter()); + $handler->handle($this->getRecord(Logger::WARNING, 'test')); + $handler->handle($this->getRecord(Logger::WARNING, 'test2')); + $handler->handle($this->getRecord(Logger::WARNING, 'test3')); + fseek($handle, 0); + $this->assertEquals('testtest2test3', fread($handle, 100)); + } + + /** + * @covers Monolog\Handler\StreamHandler::close + */ + public function testClose() + { + $handle = fopen('php://memory', 'a+'); + $handler = new StreamHandler($handle); + $this->assertTrue(is_resource($handle)); + $handler->close(); + $this->assertFalse(is_resource($handle)); + } + + /** + * @covers Monolog\Handler\StreamHandler::write + */ + public function testWriteCreatesTheStreamResource() + { + $handler = new StreamHandler('php://memory'); + $handler->handle($this->getRecord()); + } + + /** + * @expectedException LogicException + * @covers Monolog\Handler\StreamHandler::__construct + * @covers Monolog\Handler\StreamHandler::write + */ + public function testWriteMissingResource() + { + $handler = new StreamHandler(null); + $handler->handle($this->getRecord()); + } + + /** + * @expectedException UnexpectedValueException + * @covers Monolog\Handler\StreamHandler::__construct + * @covers Monolog\Handler\StreamHandler::write + */ + public function testWriteInvalidResource() + { + $handler = new StreamHandler('bogus://url'); + $handler->handle($this->getRecord()); + } + + /** + * @expectedException UnexpectedValueException + * @covers Monolog\Handler\StreamHandler::__construct + * @covers Monolog\Handler\StreamHandler::write + */ + public function testWriteNonExistingResource() + { + $handler = new StreamHandler('/foo/bar/baz/'.rand(0, 10000)); + $handler->handle($this->getRecord()); + } +} diff --git a/vendor/monolog/monolog/tests/Monolog/Handler/SyslogHandlerTest.php b/vendor/monolog/monolog/tests/Monolog/Handler/SyslogHandlerTest.php new file mode 100755 index 0000000..98219ac --- /dev/null +++ b/vendor/monolog/monolog/tests/Monolog/Handler/SyslogHandlerTest.php @@ -0,0 +1,43 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Handler; +use Monolog\Logger; + +class SyslogHandlerTest extends \PHPUnit_Framework_TestCase +{ + /** + * @covers Monolog\Handler\SyslogHandler::__construct + */ + public function testConstruct() + { + $handler = new SyslogHandler('test'); + $this->assertInstanceOf('Monolog\Handler\SyslogHandler', $handler); + + $handler = new SyslogHandler('test', LOG_USER); + $this->assertInstanceOf('Monolog\Handler\SyslogHandler', $handler); + + $handler = new SyslogHandler('test', 'user'); + $this->assertInstanceOf('Monolog\Handler\SyslogHandler', $handler); + + $handler = new SyslogHandler('test', LOG_USER, Logger::DEBUG, true, LOG_PERROR); + $this->assertInstanceOf('Monolog\Handler\SyslogHandler', $handler); + } + + /** + * @covers Monolog\Handler\SyslogHandler::__construct + */ + public function testConstructInvalidFacility() + { + $this->setExpectedException('UnexpectedValueException'); + $handler = new SyslogHandler('test', 'unknown'); + } +} diff --git a/vendor/monolog/monolog/tests/Monolog/Handler/SyslogUdpHandlerTest.php b/vendor/monolog/monolog/tests/Monolog/Handler/SyslogUdpHandlerTest.php new file mode 100755 index 0000000..269a296 --- /dev/null +++ b/vendor/monolog/monolog/tests/Monolog/Handler/SyslogUdpHandlerTest.php @@ -0,0 +1,37 @@ +setFormatter(new \Monolog\Formatter\ChromePHPFormatter()); + + $socket = $this->getMock('\Monolog\Handler\SyslogUdp\UdpSocket', array('write'), array('lol', 'lol')); + $socket->expects($this->at(0)) + ->method('write') + ->with("lol", "<".(LOG_AUTHPRIV + LOG_WARNING).">: "); + $socket->expects($this->at(1)) + ->method('write') + ->with("hej", "<".(LOG_AUTHPRIV + LOG_WARNING).">: "); + + $handler->setSocket($socket); + + $handler->handle($this->getRecordWithMessage("hej\nlol")); + } + + protected function getRecordWithMessage($msg) + { + return array('message' => $msg, 'level' => \Monolog\Logger::WARNING, 'context' => null, 'extra' => array(), 'channel' => 'lol'); + } +} diff --git a/vendor/monolog/monolog/tests/Monolog/Handler/TestHandlerTest.php b/vendor/monolog/monolog/tests/Monolog/Handler/TestHandlerTest.php new file mode 100755 index 0000000..801d80a --- /dev/null +++ b/vendor/monolog/monolog/tests/Monolog/Handler/TestHandlerTest.php @@ -0,0 +1,56 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Handler; + +use Monolog\TestCase; +use Monolog\Logger; + +/** + * @covers Monolog\Handler\TestHandler + */ +class TestHandlerTest extends TestCase +{ + /** + * @dataProvider methodProvider + */ + public function testHandler($method, $level) + { + $handler = new TestHandler; + $record = $this->getRecord($level, 'test'.$method); + $this->assertFalse($handler->{'has'.$method}($record)); + $this->assertFalse($handler->{'has'.$method.'Records'}()); + $handler->handle($record); + + $this->assertFalse($handler->{'has'.$method}('bar')); + $this->assertTrue($handler->{'has'.$method}($record)); + $this->assertTrue($handler->{'has'.$method}('test'.$method)); + $this->assertTrue($handler->{'has'.$method.'Records'}()); + + $records = $handler->getRecords(); + unset($records[0]['formatted']); + $this->assertEquals(array($record), $records); + } + + public function methodProvider() + { + return array( + array('Emergency', Logger::EMERGENCY), + array('Alert' , Logger::ALERT), + array('Critical' , Logger::CRITICAL), + array('Error' , Logger::ERROR), + array('Warning' , Logger::WARNING), + array('Info' , Logger::INFO), + array('Notice' , Logger::NOTICE), + array('Debug' , Logger::DEBUG), + ); + } +} diff --git a/vendor/monolog/monolog/tests/Monolog/Handler/UdpSocketTest.php b/vendor/monolog/monolog/tests/Monolog/Handler/UdpSocketTest.php new file mode 100755 index 0000000..d16b0a3 --- /dev/null +++ b/vendor/monolog/monolog/tests/Monolog/Handler/UdpSocketTest.php @@ -0,0 +1,45 @@ +getMock('\Monolog\Handler\SyslogUdp\UdpSocket', array('send'), array('lol', 'lol')); + + $socket->expects($this->at(0)) + ->method('send') + ->with("HEADER: The quick brown fox jumps over the lazy dog"); + + $socket->write("The quick brown fox jumps over the lazy dog", "HEADER: "); + } + + public function testWeSplitLongMessages() + { + $socket = $this->getMock('\Monolog\Handler\SyslogUdp\UdpSocket', array('send'), array('lol', 'lol')); + + $socket->expects($this->at(1)) + ->method('send') + ->with("The quick brown fox jumps over the lazy dog"); + + $aStringOfLength2048 = str_repeat("derp", 2048/4); + + $socket->write($aStringOfLength2048."The quick brown fox jumps over the lazy dog"); + } + + public function testAllSplitMessagesHasAHeader() + { + $socket = $this->getMock('\Monolog\Handler\SyslogUdp\UdpSocket', array('send'), array('lol', 'lol')); + + $socket->expects($this->exactly(5)) + ->method('send') + ->with($this->stringStartsWith("HEADER")); + + $aStringOfLength8192 = str_repeat("derp", 2048); + + $socket->write($aStringOfLength8192, "HEADER"); + } +} diff --git a/vendor/monolog/monolog/tests/Monolog/Handler/ZendMonitorHandlerTest.php b/vendor/monolog/monolog/tests/Monolog/Handler/ZendMonitorHandlerTest.php new file mode 100755 index 0000000..416039e --- /dev/null +++ b/vendor/monolog/monolog/tests/Monolog/Handler/ZendMonitorHandlerTest.php @@ -0,0 +1,69 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Handler; + +use Monolog\TestCase; + +class ZendMonitorHandlerTest extends TestCase +{ + protected $zendMonitorHandler; + + public function setUp() + { + if (!function_exists('zend_monitor_custom_event')) { + $this->markTestSkipped('ZendServer is not installed'); + } + } + + /** + * @covers Monolog\Handler\ZendMonitorHandler::write + */ + public function testWrite() + { + $record = $this->getRecord(); + $formatterResult = array( + 'message' => $record['message'] + ); + + $zendMonitor = $this->getMockBuilder('Monolog\Handler\ZendMonitorHandler') + ->setMethods(array('writeZendMonitorCustomEvent', 'getDefaultFormatter')) + ->getMock(); + + $formatterMock = $this->getMockBuilder('Monolog\Formatter\NormalizerFormatter') + ->disableOriginalConstructor() + ->getMock(); + + $formatterMock->expects($this->once()) + ->method('format') + ->will($this->returnValue($formatterResult)); + + $zendMonitor->expects($this->once()) + ->method('getDefaultFormatter') + ->will($this->returnValue($formatterMock)); + + $levelMap = $zendMonitor->getLevelMap(); + + $zendMonitor->expects($this->once()) + ->method('writeZendMonitorCustomEvent') + ->with($levelMap[$record['level']], $record['message'], $formatterResult); + + $zendMonitor->handle($record); + } + + /** + * @covers Monolog\Handler\ZendMonitorHandler::getDefaultFormatter + */ + public function testGetDefaultFormatterReturnsNormalizerFormatter() + { + $zendMonitor = new ZendMonitorHandler(); + $this->assertInstanceOf('Monolog\Formatter\NormalizerFormatter', $zendMonitor->getDefaultFormatter()); + } +} diff --git a/vendor/monolog/monolog/tests/Monolog/LoggerTest.php b/vendor/monolog/monolog/tests/Monolog/LoggerTest.php new file mode 100755 index 0000000..7a19c0b --- /dev/null +++ b/vendor/monolog/monolog/tests/Monolog/LoggerTest.php @@ -0,0 +1,409 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog; + +use Monolog\Processor\WebProcessor; +use Monolog\Handler\TestHandler; + +class LoggerTest extends \PHPUnit_Framework_TestCase +{ + /** + * @covers Monolog\Logger::getName + */ + public function testGetName() + { + $logger = new Logger('foo'); + $this->assertEquals('foo', $logger->getName()); + } + + /** + * @covers Monolog\Logger::getLevelName + */ + public function testGetLevelName() + { + $this->assertEquals('ERROR', Logger::getLevelName(Logger::ERROR)); + } + + /** + * @covers Monolog\Logger::getLevelName + * @expectedException InvalidArgumentException + */ + public function testGetLevelNameThrows() + { + Logger::getLevelName(5); + } + + /** + * @covers Monolog\Logger::__construct + */ + public function testChannel() + { + $logger = new Logger('foo'); + $handler = new TestHandler; + $logger->pushHandler($handler); + $logger->addWarning('test'); + list($record) = $handler->getRecords(); + $this->assertEquals('foo', $record['channel']); + } + + /** + * @covers Monolog\Logger::addRecord + */ + public function testLog() + { + $logger = new Logger(__METHOD__); + + $handler = $this->getMock('Monolog\Handler\NullHandler', array('handle')); + $handler->expects($this->once()) + ->method('handle'); + $logger->pushHandler($handler); + + $this->assertTrue($logger->addWarning('test')); + } + + /** + * @covers Monolog\Logger::addRecord + */ + public function testLogNotHandled() + { + $logger = new Logger(__METHOD__); + + $handler = $this->getMock('Monolog\Handler\NullHandler', array('handle'), array(Logger::ERROR)); + $handler->expects($this->never()) + ->method('handle'); + $logger->pushHandler($handler); + + $this->assertFalse($logger->addWarning('test')); + } + + public function testHandlersInCtor() + { + $handler1 = new TestHandler; + $handler2 = new TestHandler; + $logger = new Logger(__METHOD__, array($handler1, $handler2)); + + $this->assertEquals($handler1, $logger->popHandler()); + $this->assertEquals($handler2, $logger->popHandler()); + } + + public function testProcessorsInCtor() + { + $processor1 = new WebProcessor; + $processor2 = new WebProcessor; + $logger = new Logger(__METHOD__, array(), array($processor1, $processor2)); + + $this->assertEquals($processor1, $logger->popProcessor()); + $this->assertEquals($processor2, $logger->popProcessor()); + } + + /** + * @covers Monolog\Logger::pushHandler + * @covers Monolog\Logger::popHandler + * @expectedException LogicException + */ + public function testPushPopHandler() + { + $logger = new Logger(__METHOD__); + $handler1 = new TestHandler; + $handler2 = new TestHandler; + + $logger->pushHandler($handler1); + $logger->pushHandler($handler2); + + $this->assertEquals($handler2, $logger->popHandler()); + $this->assertEquals($handler1, $logger->popHandler()); + $logger->popHandler(); + } + + /** + * @covers Monolog\Logger::pushProcessor + * @covers Monolog\Logger::popProcessor + * @expectedException LogicException + */ + public function testPushPopProcessor() + { + $logger = new Logger(__METHOD__); + $processor1 = new WebProcessor; + $processor2 = new WebProcessor; + + $logger->pushProcessor($processor1); + $logger->pushProcessor($processor2); + + $this->assertEquals($processor2, $logger->popProcessor()); + $this->assertEquals($processor1, $logger->popProcessor()); + $logger->popProcessor(); + } + + /** + * @covers Monolog\Logger::pushProcessor + * @expectedException InvalidArgumentException + */ + public function testPushProcessorWithNonCallable() + { + $logger = new Logger(__METHOD__); + + $logger->pushProcessor(new \stdClass()); + } + + /** + * @covers Monolog\Logger::addRecord + */ + public function testProcessorsAreExecuted() + { + $logger = new Logger(__METHOD__); + $handler = new TestHandler; + $logger->pushHandler($handler); + $logger->pushProcessor(function ($record) { + $record['extra']['win'] = true; + + return $record; + }); + $logger->addError('test'); + list($record) = $handler->getRecords(); + $this->assertTrue($record['extra']['win']); + } + + /** + * @covers Monolog\Logger::addRecord + */ + public function testProcessorsAreCalledOnlyOnce() + { + $logger = new Logger(__METHOD__); + $handler = $this->getMock('Monolog\Handler\HandlerInterface'); + $handler->expects($this->any()) + ->method('isHandling') + ->will($this->returnValue(true)) + ; + $handler->expects($this->any()) + ->method('handle') + ->will($this->returnValue(true)) + ; + $logger->pushHandler($handler); + + $processor = $this->getMockBuilder('Monolog\Processor\WebProcessor') + ->disableOriginalConstructor() + ->setMethods(array('__invoke')) + ->getMock() + ; + $processor->expects($this->once()) + ->method('__invoke') + ->will($this->returnArgument(0)) + ; + $logger->pushProcessor($processor); + + $logger->addError('test'); + } + + /** + * @covers Monolog\Logger::addRecord + */ + public function testProcessorsNotCalledWhenNotHandled() + { + $logger = new Logger(__METHOD__); + $handler = $this->getMock('Monolog\Handler\HandlerInterface'); + $handler->expects($this->once()) + ->method('isHandling') + ->will($this->returnValue(false)) + ; + $logger->pushHandler($handler); + $that = $this; + $logger->pushProcessor(function ($record) use ($that) { + $that->fail('The processor should not be called'); + }); + $logger->addAlert('test'); + } + + /** + * @covers Monolog\Logger::addRecord + */ + public function testHandlersNotCalledBeforeFirstHandling() + { + $logger = new Logger(__METHOD__); + + $handler1 = $this->getMock('Monolog\Handler\HandlerInterface'); + $handler1->expects($this->never()) + ->method('isHandling') + ->will($this->returnValue(false)) + ; + $handler1->expects($this->once()) + ->method('handle') + ->will($this->returnValue(false)) + ; + $logger->pushHandler($handler1); + + $handler2 = $this->getMock('Monolog\Handler\HandlerInterface'); + $handler2->expects($this->once()) + ->method('isHandling') + ->will($this->returnValue(true)) + ; + $handler2->expects($this->once()) + ->method('handle') + ->will($this->returnValue(false)) + ; + $logger->pushHandler($handler2); + + $handler3 = $this->getMock('Monolog\Handler\HandlerInterface'); + $handler3->expects($this->once()) + ->method('isHandling') + ->will($this->returnValue(false)) + ; + $handler3->expects($this->never()) + ->method('handle') + ; + $logger->pushHandler($handler3); + + $logger->debug('test'); + } + + /** + * @covers Monolog\Logger::addRecord + */ + public function testBubblingWhenTheHandlerReturnsFalse() + { + $logger = new Logger(__METHOD__); + + $handler1 = $this->getMock('Monolog\Handler\HandlerInterface'); + $handler1->expects($this->any()) + ->method('isHandling') + ->will($this->returnValue(true)) + ; + $handler1->expects($this->once()) + ->method('handle') + ->will($this->returnValue(false)) + ; + $logger->pushHandler($handler1); + + $handler2 = $this->getMock('Monolog\Handler\HandlerInterface'); + $handler2->expects($this->any()) + ->method('isHandling') + ->will($this->returnValue(true)) + ; + $handler2->expects($this->once()) + ->method('handle') + ->will($this->returnValue(false)) + ; + $logger->pushHandler($handler2); + + $logger->debug('test'); + } + + /** + * @covers Monolog\Logger::addRecord + */ + public function testNotBubblingWhenTheHandlerReturnsTrue() + { + $logger = new Logger(__METHOD__); + + $handler1 = $this->getMock('Monolog\Handler\HandlerInterface'); + $handler1->expects($this->any()) + ->method('isHandling') + ->will($this->returnValue(true)) + ; + $handler1->expects($this->never()) + ->method('handle') + ; + $logger->pushHandler($handler1); + + $handler2 = $this->getMock('Monolog\Handler\HandlerInterface'); + $handler2->expects($this->any()) + ->method('isHandling') + ->will($this->returnValue(true)) + ; + $handler2->expects($this->once()) + ->method('handle') + ->will($this->returnValue(true)) + ; + $logger->pushHandler($handler2); + + $logger->debug('test'); + } + + /** + * @covers Monolog\Logger::isHandling + */ + public function testIsHandling() + { + $logger = new Logger(__METHOD__); + + $handler1 = $this->getMock('Monolog\Handler\HandlerInterface'); + $handler1->expects($this->any()) + ->method('isHandling') + ->will($this->returnValue(false)) + ; + + $logger->pushHandler($handler1); + $this->assertFalse($logger->isHandling(Logger::DEBUG)); + + $handler2 = $this->getMock('Monolog\Handler\HandlerInterface'); + $handler2->expects($this->any()) + ->method('isHandling') + ->will($this->returnValue(true)) + ; + + $logger->pushHandler($handler2); + $this->assertTrue($logger->isHandling(Logger::DEBUG)); + } + + /** + * @dataProvider logMethodProvider + * @covers Monolog\Logger::addDebug + * @covers Monolog\Logger::addInfo + * @covers Monolog\Logger::addNotice + * @covers Monolog\Logger::addWarning + * @covers Monolog\Logger::addError + * @covers Monolog\Logger::addCritical + * @covers Monolog\Logger::addAlert + * @covers Monolog\Logger::addEmergency + * @covers Monolog\Logger::debug + * @covers Monolog\Logger::info + * @covers Monolog\Logger::notice + * @covers Monolog\Logger::warn + * @covers Monolog\Logger::err + * @covers Monolog\Logger::crit + * @covers Monolog\Logger::alert + * @covers Monolog\Logger::emerg + */ + public function testLogMethods($method, $expectedLevel) + { + $logger = new Logger('foo'); + $handler = new TestHandler; + $logger->pushHandler($handler); + $logger->{$method}('test'); + list($record) = $handler->getRecords(); + $this->assertEquals($expectedLevel, $record['level']); + } + + public function logMethodProvider() + { + return array( + // monolog methods + array('addDebug', Logger::DEBUG), + array('addInfo', Logger::INFO), + array('addNotice', Logger::NOTICE), + array('addWarning', Logger::WARNING), + array('addError', Logger::ERROR), + array('addCritical', Logger::CRITICAL), + array('addAlert', Logger::ALERT), + array('addEmergency', Logger::EMERGENCY), + + // ZF/Sf2 compat methods + array('debug', Logger::DEBUG), + array('info', Logger::INFO), + array('notice', Logger::NOTICE), + array('warn', Logger::WARNING), + array('err', Logger::ERROR), + array('crit', Logger::CRITICAL), + array('alert', Logger::ALERT), + array('emerg', Logger::EMERGENCY), + ); + } +} diff --git a/vendor/monolog/monolog/tests/Monolog/Processor/GitProcessorTest.php b/vendor/monolog/monolog/tests/Monolog/Processor/GitProcessorTest.php new file mode 100755 index 0000000..5adb505 --- /dev/null +++ b/vendor/monolog/monolog/tests/Monolog/Processor/GitProcessorTest.php @@ -0,0 +1,29 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Processor; + +use Monolog\TestCase; + +class GitProcessorTest extends TestCase +{ + /** + * @covers Monolog\Processor\GitProcessor::__invoke + */ + public function testProcessor() + { + $processor = new GitProcessor(); + $record = $processor($this->getRecord()); + + $this->assertArrayHasKey('git', $record['extra']); + $this->assertTrue(!is_array($record['extra']['git']['branch'])); + } +} diff --git a/vendor/monolog/monolog/tests/Monolog/Processor/IntrospectionProcessorTest.php b/vendor/monolog/monolog/tests/Monolog/Processor/IntrospectionProcessorTest.php new file mode 100755 index 0000000..0dd411d --- /dev/null +++ b/vendor/monolog/monolog/tests/Monolog/Processor/IntrospectionProcessorTest.php @@ -0,0 +1,123 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Acme; + +class Tester +{ + public function test($handler, $record) + { + $handler->handle($record); + } +} + +function tester($handler, $record) +{ + $handler->handle($record); +} + +namespace Monolog\Processor; + +use Monolog\Logger; +use Monolog\TestCase; +use Monolog\Handler\TestHandler; + +class IntrospectionProcessorTest extends TestCase +{ + public function getHandler() + { + $processor = new IntrospectionProcessor(); + $handler = new TestHandler(); + $handler->pushProcessor($processor); + + return $handler; + } + + public function testProcessorFromClass() + { + $handler = $this->getHandler(); + $tester = new \Acme\Tester; + $tester->test($handler, $this->getRecord()); + list($record) = $handler->getRecords(); + $this->assertEquals(__FILE__, $record['extra']['file']); + $this->assertEquals(18, $record['extra']['line']); + $this->assertEquals('Acme\Tester', $record['extra']['class']); + $this->assertEquals('test', $record['extra']['function']); + } + + public function testProcessorFromFunc() + { + $handler = $this->getHandler(); + \Acme\tester($handler, $this->getRecord()); + list($record) = $handler->getRecords(); + $this->assertEquals(__FILE__, $record['extra']['file']); + $this->assertEquals(24, $record['extra']['line']); + $this->assertEquals(null, $record['extra']['class']); + $this->assertEquals('Acme\tester', $record['extra']['function']); + } + + public function testLevelTooLow() + { + $input = array( + 'level' => Logger::DEBUG, + 'extra' => array(), + ); + + $expected = $input; + + $processor = new IntrospectionProcessor(Logger::CRITICAL); + $actual = $processor($input); + + $this->assertEquals($expected, $actual); + } + + public function testLevelEqual() + { + $input = array( + 'level' => Logger::CRITICAL, + 'extra' => array(), + ); + + $expected = $input; + $expected['extra'] = array( + 'file' => null, + 'line' => null, + 'class' => 'ReflectionMethod', + 'function' => 'invokeArgs', + ); + + $processor = new IntrospectionProcessor(Logger::CRITICAL); + $actual = $processor($input); + + $this->assertEquals($expected, $actual); + } + + public function testLevelHigher() + { + $input = array( + 'level' => Logger::EMERGENCY, + 'extra' => array(), + ); + + $expected = $input; + $expected['extra'] = array( + 'file' => null, + 'line' => null, + 'class' => 'ReflectionMethod', + 'function' => 'invokeArgs', + ); + + $processor = new IntrospectionProcessor(Logger::CRITICAL); + $actual = $processor($input); + + $this->assertEquals($expected, $actual); + } +} diff --git a/vendor/monolog/monolog/tests/Monolog/Processor/MemoryPeakUsageProcessorTest.php b/vendor/monolog/monolog/tests/Monolog/Processor/MemoryPeakUsageProcessorTest.php new file mode 100755 index 0000000..eb66614 --- /dev/null +++ b/vendor/monolog/monolog/tests/Monolog/Processor/MemoryPeakUsageProcessorTest.php @@ -0,0 +1,42 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Processor; + +use Monolog\TestCase; + +class MemoryPeakUsageProcessorTest extends TestCase +{ + /** + * @covers Monolog\Processor\MemoryPeakUsageProcessor::__invoke + * @covers Monolog\Processor\MemoryProcessor::formatBytes + */ + public function testProcessor() + { + $processor = new MemoryPeakUsageProcessor(); + $record = $processor($this->getRecord()); + $this->assertArrayHasKey('memory_peak_usage', $record['extra']); + $this->assertRegExp('#[0-9.]+ (M|K)?B$#', $record['extra']['memory_peak_usage']); + } + + /** + * @covers Monolog\Processor\MemoryPeakUsageProcessor::__invoke + * @covers Monolog\Processor\MemoryProcessor::formatBytes + */ + public function testProcessorWithoutFormatting() + { + $processor = new MemoryPeakUsageProcessor(true, false); + $record = $processor($this->getRecord()); + $this->assertArrayHasKey('memory_peak_usage', $record['extra']); + $this->assertInternalType('int', $record['extra']['memory_peak_usage']); + $this->assertGreaterThan(0, $record['extra']['memory_peak_usage']); + } +} diff --git a/vendor/monolog/monolog/tests/Monolog/Processor/MemoryUsageProcessorTest.php b/vendor/monolog/monolog/tests/Monolog/Processor/MemoryUsageProcessorTest.php new file mode 100755 index 0000000..4692dbf --- /dev/null +++ b/vendor/monolog/monolog/tests/Monolog/Processor/MemoryUsageProcessorTest.php @@ -0,0 +1,42 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Processor; + +use Monolog\TestCase; + +class MemoryUsageProcessorTest extends TestCase +{ + /** + * @covers Monolog\Processor\MemoryUsageProcessor::__invoke + * @covers Monolog\Processor\MemoryProcessor::formatBytes + */ + public function testProcessor() + { + $processor = new MemoryUsageProcessor(); + $record = $processor($this->getRecord()); + $this->assertArrayHasKey('memory_usage', $record['extra']); + $this->assertRegExp('#[0-9.]+ (M|K)?B$#', $record['extra']['memory_usage']); + } + + /** + * @covers Monolog\Processor\MemoryUsageProcessor::__invoke + * @covers Monolog\Processor\MemoryProcessor::formatBytes + */ + public function testProcessorWithoutFormatting() + { + $processor = new MemoryUsageProcessor(true, false); + $record = $processor($this->getRecord()); + $this->assertArrayHasKey('memory_usage', $record['extra']); + $this->assertInternalType('int', $record['extra']['memory_usage']); + $this->assertGreaterThan(0, $record['extra']['memory_usage']); + } +} diff --git a/vendor/monolog/monolog/tests/Monolog/Processor/ProcessIdProcessorTest.php b/vendor/monolog/monolog/tests/Monolog/Processor/ProcessIdProcessorTest.php new file mode 100755 index 0000000..458d2a3 --- /dev/null +++ b/vendor/monolog/monolog/tests/Monolog/Processor/ProcessIdProcessorTest.php @@ -0,0 +1,30 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Processor; + +use Monolog\TestCase; + +class ProcessIdProcessorTest extends TestCase +{ + /** + * @covers Monolog\Processor\ProcessIdProcessor::__invoke + */ + public function testProcessor() + { + $processor = new ProcessIdProcessor(); + $record = $processor($this->getRecord()); + $this->assertArrayHasKey('process_id', $record['extra']); + $this->assertInternalType('int', $record['extra']['process_id']); + $this->assertGreaterThan(0, $record['extra']['process_id']); + $this->assertEquals(getmypid(), $record['extra']['process_id']); + } +} diff --git a/vendor/monolog/monolog/tests/Monolog/Processor/TagProcessorTest.php b/vendor/monolog/monolog/tests/Monolog/Processor/TagProcessorTest.php new file mode 100755 index 0000000..851a9dc --- /dev/null +++ b/vendor/monolog/monolog/tests/Monolog/Processor/TagProcessorTest.php @@ -0,0 +1,29 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Processor; + +use Monolog\TestCase; + +class TagProcessorTest extends TestCase +{ + /** + * @covers Monolog\Processor\TagProcessor::__invoke + */ + public function testProcessor() + { + $tags = array(1, 2, 3); + $processor = new TagProcessor($tags); + $record = $processor($this->getRecord()); + + $this->assertEquals($tags, $record['extra']['tags']); + } +} diff --git a/vendor/monolog/monolog/tests/Monolog/Processor/UidProcessorTest.php b/vendor/monolog/monolog/tests/Monolog/Processor/UidProcessorTest.php new file mode 100755 index 0000000..7ced62c --- /dev/null +++ b/vendor/monolog/monolog/tests/Monolog/Processor/UidProcessorTest.php @@ -0,0 +1,27 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Processor; + +use Monolog\TestCase; + +class UidProcessorTest extends TestCase +{ + /** + * @covers Monolog\Processor\UidProcessor::__invoke + */ + public function testProcessor() + { + $processor = new UidProcessor(); + $record = $processor($this->getRecord()); + $this->assertArrayHasKey('uid', $record['extra']); + } +} diff --git a/vendor/monolog/monolog/tests/Monolog/Processor/WebProcessorTest.php b/vendor/monolog/monolog/tests/Monolog/Processor/WebProcessorTest.php new file mode 100755 index 0000000..df29fdd --- /dev/null +++ b/vendor/monolog/monolog/tests/Monolog/Processor/WebProcessorTest.php @@ -0,0 +1,83 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog\Processor; + +use Monolog\TestCase; + +class WebProcessorTest extends TestCase +{ + public function testProcessor() + { + $server = array( + 'REQUEST_URI' => 'A', + 'REMOTE_ADDR' => 'B', + 'REQUEST_METHOD' => 'C', + 'HTTP_REFERER' => 'D', + 'SERVER_NAME' => 'F', + 'UNIQUE_ID' => 'G', + ); + + $processor = new WebProcessor($server); + $record = $processor($this->getRecord()); + $this->assertEquals($server['REQUEST_URI'], $record['extra']['url']); + $this->assertEquals($server['REMOTE_ADDR'], $record['extra']['ip']); + $this->assertEquals($server['REQUEST_METHOD'], $record['extra']['http_method']); + $this->assertEquals($server['HTTP_REFERER'], $record['extra']['referrer']); + $this->assertEquals($server['SERVER_NAME'], $record['extra']['server']); + $this->assertEquals($server['UNIQUE_ID'], $record['extra']['unique_id']); + } + + public function testProcessorDoNothingIfNoRequestUri() + { + $server = array( + 'REMOTE_ADDR' => 'B', + 'REQUEST_METHOD' => 'C', + ); + $processor = new WebProcessor($server); + $record = $processor($this->getRecord()); + $this->assertEmpty($record['extra']); + } + + public function testProcessorReturnNullIfNoHttpReferer() + { + $server = array( + 'REQUEST_URI' => 'A', + 'REMOTE_ADDR' => 'B', + 'REQUEST_METHOD' => 'C', + 'SERVER_NAME' => 'F', + ); + $processor = new WebProcessor($server); + $record = $processor($this->getRecord()); + $this->assertNull($record['extra']['referrer']); + } + + public function testProcessorDoesNotAddUniqueIdIfNotPresent() + { + $server = array( + 'REQUEST_URI' => 'A', + 'REMOTE_ADDR' => 'B', + 'REQUEST_METHOD' => 'C', + 'SERVER_NAME' => 'F', + ); + $processor = new WebProcessor($server); + $record = $processor($this->getRecord()); + $this->assertFalse(isset($record['extra']['unique_id'])); + } + + /** + * @expectedException UnexpectedValueException + */ + public function testInvalidData() + { + new WebProcessor(new \stdClass); + } +} diff --git a/vendor/monolog/monolog/tests/Monolog/PsrLogCompatTest.php b/vendor/monolog/monolog/tests/Monolog/PsrLogCompatTest.php new file mode 100755 index 0000000..ab89944 --- /dev/null +++ b/vendor/monolog/monolog/tests/Monolog/PsrLogCompatTest.php @@ -0,0 +1,47 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog; + +use Monolog\Handler\TestHandler; +use Monolog\Formatter\LineFormatter; +use Monolog\Processor\PsrLogMessageProcessor; +use Psr\Log\Test\LoggerInterfaceTest; + +class PsrLogCompatTest extends LoggerInterfaceTest +{ + private $handler; + + public function getLogger() + { + $logger = new Logger('foo'); + $logger->pushHandler($handler = new TestHandler); + $logger->pushProcessor(new PsrLogMessageProcessor); + $handler->setFormatter(new LineFormatter('%level_name% %message%')); + + $this->handler = $handler; + + return $logger; + } + + public function getLogs() + { + $convert = function ($record) { + $lower = function ($match) { + return strtolower($match[0]); + }; + + return preg_replace_callback('{^[A-Z]+}', $lower, $record['formatted']); + }; + + return array_map($convert, $this->handler->getRecords()); + } +} diff --git a/vendor/monolog/monolog/tests/Monolog/TestCase.php b/vendor/monolog/monolog/tests/Monolog/TestCase.php new file mode 100755 index 0000000..cae7934 --- /dev/null +++ b/vendor/monolog/monolog/tests/Monolog/TestCase.php @@ -0,0 +1,58 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Monolog; + +class TestCase extends \PHPUnit_Framework_TestCase +{ + /** + * @return array Record + */ + protected function getRecord($level = Logger::WARNING, $message = 'test', $context = array()) + { + return array( + 'message' => $message, + 'context' => $context, + 'level' => $level, + 'level_name' => Logger::getLevelName($level), + 'channel' => 'test', + 'datetime' => \DateTime::createFromFormat('U.u', sprintf('%.6F', microtime(true))), + 'extra' => array(), + ); + } + + /** + * @return array + */ + protected function getMultipleRecords() + { + return array( + $this->getRecord(Logger::DEBUG, 'debug message 1'), + $this->getRecord(Logger::DEBUG, 'debug message 2'), + $this->getRecord(Logger::INFO, 'information'), + $this->getRecord(Logger::WARNING, 'warning'), + $this->getRecord(Logger::ERROR, 'error') + ); + } + + /** + * @return Monolog\Formatter\FormatterInterface + */ + protected function getIdentityFormatter() + { + $formatter = $this->getMock('Monolog\\Formatter\\FormatterInterface'); + $formatter->expects($this->any()) + ->method('format') + ->will($this->returnCallback(function ($record) { return $record['message']; })); + + return $formatter; + } +} diff --git a/vendor/monolog/monolog/tests/bootstrap.php b/vendor/monolog/monolog/tests/bootstrap.php new file mode 100755 index 0000000..b78740e --- /dev/null +++ b/vendor/monolog/monolog/tests/bootstrap.php @@ -0,0 +1,15 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +$loader = require __DIR__ . "/../vendor/autoload.php"; +$loader->addPsr4('Monolog\\', __DIR__.'/Monolog'); + +date_default_timezone_set('UTC'); diff --git a/vendor/nesbot/carbon/LICENSE b/vendor/nesbot/carbon/LICENSE new file mode 100755 index 0000000..8957ee6 --- /dev/null +++ b/vendor/nesbot/carbon/LICENSE @@ -0,0 +1,19 @@ +Copyright (C) Brian Nesbitt + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is furnished +to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. \ No newline at end of file diff --git a/vendor/nesbot/carbon/composer.json b/vendor/nesbot/carbon/composer.json new file mode 100755 index 0000000..aa9d17f --- /dev/null +++ b/vendor/nesbot/carbon/composer.json @@ -0,0 +1,30 @@ +{ + "name": "nesbot/carbon", + "type": "library", + "description": "A simple API extension for DateTime.", + "keywords": [ + "date", + "time", + "DateTime" + ], + "homepage": "https://github.com/briannesbitt/Carbon", + "license": "MIT", + "authors": [ + { + "name": "Brian Nesbitt", + "email": "brian@nesbot.com", + "homepage": "http://nesbot.com" + } + ], + "require": { + "php": ">=5.3.0" + }, + "require-dev": { + "phpunit/phpunit": "3.7.*" + }, + "autoload": { + "psr-0": { + "Carbon": "src" + } + } +} \ No newline at end of file diff --git a/vendor/nesbot/carbon/history.md b/vendor/nesbot/carbon/history.md new file mode 100755 index 0000000..72b1691 --- /dev/null +++ b/vendor/nesbot/carbon/history.md @@ -0,0 +1,80 @@ +1.9.0 / 2014-05-12 +================== +* Changed self references to static to allow for easier child classes +* Fixed a couple of tests to account for London DST +* Fixed a test that failed due to inconsistent DateTime COOKIE strings + +1.8.0 / 2014-01-06 +================== +* Added .gitattributes file to to ignore some files on export (thanks @lucasmichot) +* Removed unnecessary __set tz/timezone switch +* Added min() / max() (thanks @lucasmichot) +* Fixed startOfWeek() / endOfWeek() when crossing year boundary. +* Fixed bug in detecting relative keywords in ctor parameter when using a test now + +1.7.0 / 2013-12-04 +================== +* Added startOfYear() / endOfYear() (thanks @semalead) +* Added average() (thanks @semalead) + +1.6.0 / 2013-11-23 +================== +* Fixed "Cannot access property ::$toStringFormat" when extending Carbon and type juggling to a string occurs + +1.5.0 / 2013-11-21 +================== +* Diff for humans now shows 2 weeks ago instead of 14 days ago +* Added a local getter to test if the instance is in the local timezone +* Added a utc getter to check if the instance is in UTC timezone +* Fixed dst comment / phpdoc and psr issues +* Optimize timezone getters (thanks @semalead) +* Added static __toString formatting (thanks @cviebrock and @anlutro) + +1.4.0 / 2013-09-08 +================== +* Corrected various PHPdocs +* formatLocalized() is now more OS independent +* Improved diff methods +* Test now can be mocked using a relative term + +1.3.0 / 2013-08-21 +================== + + * Added modifier methods firstOfMonth(), lastOfMonth(), nthOfMonth(), next(), previous(), and so on + * Added modifiers startOfWeek() and endOfWeek() + * Added testing helpers to allow mocking of new Carbon(), new Carbon('now') and Carbon::now() + * Added formatLocalized() to format a string using strftime() with the current locale + * Improved diffInSeconds() + * Improved [add|sub][Years|Months|Days|Hours|Minutes|Seconds|Weeks] + * Docblocks everywhere ;( + * Magic class properties + * Added PHP 5.5 to travis test coverage + * General Code cleanup + +1.2.0 / 2012-10-14 +================== + + * Added history.md + * Implemented __isset() (thanks @flevour) + * Simplified tomorrow()/yesterday() to rely on today()... more DRY + * Simplified __set() and fixed exception text + * Updated readme + +1.1.0 / 2012-09-16 +================== + + * Updated composer.json + * Added better error messaging for failed readme generation + * Fixed readme typos + * Added static helpers `today()`, `tomorrow()`, `yesterday()` + * Simplified `now()` code + +1.0.1 / 2012-09-10 +================== + + * Added travis-ci.org + +1.0.0 / 2012-09-10 +================== + + * Initial release diff --git a/vendor/nesbot/carbon/phpunit.xml.dist b/vendor/nesbot/carbon/phpunit.xml.dist new file mode 100755 index 0000000..2acc50d --- /dev/null +++ b/vendor/nesbot/carbon/phpunit.xml.dist @@ -0,0 +1,25 @@ + + + + + + src/Carbon + + + + + + tests + + + \ No newline at end of file diff --git a/vendor/nesbot/carbon/readme.md b/vendor/nesbot/carbon/readme.md new file mode 100755 index 0000000..395fbe1 --- /dev/null +++ b/vendor/nesbot/carbon/readme.md @@ -0,0 +1,865 @@ +> **This file is autogenerated. Please see the [Contributing](#about-contributing) section from more information.** + +# Carbon + +[![Latest Stable Version](https://poser.pugx.org/nesbot/carbon/v/stable.png)](https://packagist.org/packages/nesbot/carbon) [![Total Downloads](https://poser.pugx.org/nesbot/carbon/downloads.png)](https://packagist.org/packages/nesbot/carbon) [![Build Status](https://secure.travis-ci.org/briannesbitt/Carbon.png)](http://travis-ci.org/briannesbitt/Carbon) + +A simple API extension for DateTime with PHP 5.3+ + +```php +printf("Right now is %s", Carbon::now()->toDateTimeString()); +printf("Right now in Vancouver is %s", Carbon::now('America/Vancouver')); //implicit __toString() +$tomorrow = Carbon::now()->addDay(); +$lastWeek = Carbon::now()->subWeek(); +$nextSummerOlympics = Carbon::createFromDate(2012)->addYears(4); + +$officialDate = Carbon::now()->toRFC2822String(); + +$howOldAmI = Carbon::createFromDate(1975, 5, 21)->age; + +$noonTodayLondonTime = Carbon::createFromTime(12, 0, 0, 'Europe/London'); + +$worldWillEnd = Carbon::createFromDate(2012, 12, 21, 'GMT'); + +// Don't really want to die so mock now +Carbon::setTestNow(Carbon::createFromDate(2000, 1, 1)); + +// comparisons are always done in UTC +if (Carbon::now()->gte($worldWillEnd)) { + die(); +} + +// Phew! Return to normal behaviour +Carbon::setTestNow(); + +if (Carbon::now()->isWeekend()) { + echo 'Party!'; +} +echo Carbon::now()->subMinutes(2)->diffForHumans(); // '2 minutes ago' + +// ... but also does 'from now', 'after' and 'before' +// rolling up to seconds, minutes, hours, days, months, years + +$daysSinceEpoch = Carbon::createFromTimeStamp(0)->diffInDays(); +``` + +## README Contents + +* [Installation](#install) + * [Requirements](#requirements) + * [With composer](#install-composer) + * [Without composer](#install-nocomposer) +* [API](#api) + * [Instantiation](#api-instantiation) + * [Testing Aids](#api-testing) + * [Getters](#api-getters) + * [Setters](#api-setters) + * [Fluent Setters](#api-settersfluent) + * [IsSet](#api-isset) + * [String Formatting and Localization](#api-formatting) + * [Common Formats](#api-commonformats) + * [Comparison](#api-comparison) + * [Addition and Subtraction](#api-addsub) + * [Difference](#api-difference) + * [Difference for Humans](#api-humandiff) + * [Modifiers](#api-modifiers) + * [Constants](#api-constants) +* [About](#about) + * [Contributing](#about-contributing) + * [Author](#about-author) + * [License](#about-license) + * [History](#about-history) + * [Why the name Carbon?](#about-whyname) + + +## Installation + + +### Requirements + +- Any flavour of PHP 5.3+ should do +- [optional] PHPUnit to execute the test suite + + +### With Composer + +The easiest way to install Carbon is via [composer](http://getcomposer.org/). Create the following `composer.json` file and run the `php composer.phar install` command to install it. + +```json +{ + "require": { + "nesbot/Carbon": "*" + } +} +``` + +```php + +### Without Composer + +Why are you not using [composer](http://getcomposer.org/)? Download [Carbon.php](https://github.com/briannesbitt/Carbon/blob/master/Carbon/Carbon.php) from the repo and save the file into your project path somewhere. + +```php + +## API + +The Carbon class is [inherited](http://php.net/manual/en/keyword.extends.php) from the PHP [DateTime](http://www.php.net/manual/en/class.datetime.php) class. + +```php + **Note: I live in Ottawa, Ontario, Canada and if the timezone is not specified in the examples then the default of 'America/Toronto' is to be assumed. Typically Ottawa is -0500 but when daylight savings time is on we are -0400.** + +Special care has been taken to ensure timezones are handled correctly, and where appropriate are based on the underlying DateTime implementation. For example all comparisons are done in UTC or in the timezone of the datetime being used. + +```php +$dtToronto = Carbon::createFromDate(2012, 1, 1, 'America/Toronto'); +$dtVancouver = Carbon::createFromDate(2012, 1, 1, 'America/Vancouver'); + +echo $dtVancouver->diffInHours($dtToronto); // 3 +``` + +Also `is` comparisons are done in the timezone of the provided Carbon instance. For example my current timezone is -13 hours from Tokyo. So `Carbon::now('Asia/Tokyo')->isToday()` would only return false for any time past 1 PM my time. This doesn't make sense since `now()` in tokyo is always today in Tokyo. Thus the comparison to `now()` is done in the same timezone as the current instance. + + +### Instantiation + +There are several different methods available to create a new instance of Carbon. First there is a constructor. It overrides the [parent constructor](http://www.php.net/manual/en/datetime.construct.php) and you are best to read about the first parameter from the PHP manual and understand the date/time string formats it accepts. You'll hopefully find yourself rarely using the constructor but rather relying on the explicit static methods for improved readability. + +```php +$carbon = new Carbon(); // equivalent to Carbon::now() +$carbon = new Carbon('first day of January 2008', 'America/Vancouver'); +echo get_class($carbon); // 'Carbon\Carbon' +``` + +You'll notice above that the timezone (2nd) parameter was passed as a string rather than a `\DateTimeZone` instance. All DateTimeZone parameters have been augmented so you can pass a DateTimeZone instance or a string and the timezone will be created for you. This is again shown in the next example which also introduces the `now()` function. + +```php +$now = Carbon::now(); + +$nowInLondonTz = Carbon::now(new DateTimeZone('Europe/London')); + +// or just pass the timezone as a string +$nowInLondonTz = Carbon::now('Europe/London'); +``` + +If you really love your fluid method calls and get frustrated by the extra line or ugly pair of brackets necessary when using the constructor you'll enjoy the `parse` method. + +```php +echo (new Carbon('first day of December 2008'))->addWeeks(2); // 2008-12-15 00:00:00 +echo Carbon::parse('first day of December 2008')->addWeeks(2); // 2008-12-15 00:00:00 +``` + +To accompany `now()`, a few other static instantiation helpers exist to create widely known instances. The only thing to really notice here is that `today()`, `tomorrow()` and `yesterday()`, besides behaving as expected, all accept a timezone parameter and each has their time value set to `00:00:00`. + +```php +$now = Carbon::now(); +echo $now; // 2014-01-06 22:52:03 +$today = Carbon::today(); +echo $today; // 2014-01-06 00:00:00 +$tomorrow = Carbon::tomorrow('Europe/London'); +echo $tomorrow; // 2014-01-08 00:00:00 +$yesterday = Carbon::yesterday(); +echo $yesterday; // 2014-01-05 00:00:00 +``` + +The next group of static helpers are the `createXXX()` helpers. Most of the static `create` functions allow you to provide as many or as few arguments as you want and will provide default values for all others. Generally default values are the current date, time or timezone. Higher values will wrap appropriately but invalid values will throw an `InvalidArgumentException` with an informative message. The message is obtained from an [DateTime::getLastErrors()](http://php.net/manual/en/datetime.getlasterrors.php) call. + +```php +Carbon::createFromDate($year, $month, $day, $tz); +Carbon::createFromTime($hour, $minute, $second, $tz); +Carbon::create($year, $month, $day, $hour, $minute, $second, $tz); +``` + +`createFromDate()` will default the time to now. `createFromTime()` will default the date to today. `create()` will default any null parameter to the current respective value. As before, the `$tz` defaults to the current timezone and otherwise can be a DateTimeZone instance or simply a string timezone value. The only special case for default values (mimicking the underlying PHP library) occurs when an hour value is specified but no minutes or seconds, they will get defaulted to 0. + +```php +$xmasThisYear = Carbon::createFromDate(null, 12, 25); // Year defaults to current year +$Y2K = Carbon::create(2000, 1, 1, 0, 0, 0); +$alsoY2K = Carbon::create(1999, 12, 31, 24); +$noonLondonTz = Carbon::createFromTime(12, 0, 0, 'Europe/London'); + +// A two digit minute could not be found +try { Carbon::create(1975, 5, 21, 22, -2, 0); } catch(InvalidArgumentException $x) { echo $x->getMessage(); } +``` + +```php +Carbon::createFromFormat($format, $time, $tz); +``` + +`createFromFormat()` is mostly a wrapper for the base php function [DateTime::createFromFormat](http://php.net/manual/en/datetime.createfromformat.php). The difference being again the `$tz` argument can be a DateTimeZone instance or a string timezone value. Also, if there are errors with the format this function will call the `DateTime::getLastErrors()` method and then throw a `InvalidArgumentException` with the errors as the message. If you look at the source for the `createXX()` functions above, they all make a call to `createFromFormat()`. + +```php +echo Carbon::createFromFormat('Y-m-d H', '1975-05-21 22')->toDateTimeString(); // 1975-05-21 22:00:00 +``` + +The final two create functions are for working with [unix timestamps](http://en.wikipedia.org/wiki/Unix_time). The first will create a Carbon instance equal to the given timestamp and will set the timezone as well or default it to the current timezone. The second, `createFromTimestampUTC()`, is different in that the timezone will remain UTC (GMT). The second acts the same as `Carbon::createFromFormat('@'.$timestamp)` but I have just made it a little more explicit. Negative timestamps are also allowed. + +```php +echo Carbon::createFromTimeStamp(-1)->toDateTimeString(); // 1969-12-31 18:59:59 +echo Carbon::createFromTimeStamp(-1, 'Europe/London')->toDateTimeString(); // 1970-01-01 00:59:59 +echo Carbon::createFromTimeStampUTC(-1)->toDateTimeString(); // 1969-12-31 23:59:59 +``` + +You can also create a `copy()` of an existing Carbon instance. As expected the date, time and timezone values are all copied to the new instance. + +```php +$dt = Carbon::now(); +echo $dt->diffInYears($dt->copy()->addYear()); // 1 + +// $dt was unchanged and still holds the value of Carbon:now() +``` + +Finally, if you find yourself inheriting a `\DateTime` instance from another library, fear not! You can create a `Carbon` instance via a friendly `instance()` function. + +```php +$dt = new \DateTime('first day of January 2008'); // <== instance from another API +$carbon = Carbon::instance($dt); +echo get_class($carbon); // 'Carbon\Carbon' +echo $carbon->toDateTimeString(); // 2008-01-01 00:00:00 +``` + + +### Testing Aids + +The testing methods allow you to set a Carbon instance (real or mock) to be returned when a "now" instance is created. The provided instance will be returned specifically under the following conditions: +- A call to the static now() method, ex. Carbon::now() +- When a null (or blank string) is passed to the constructor or parse(), ex. new Carbon(null) +- When the string "now" is passed to the constructor or parse(), ex. new Carbon('now') + +```php +$knownDate = Carbon::create(2001, 5, 21, 12); // create testing date +Carbon::setTestNow($knownDate); // set the mock (of course this could be a real mock object) +echo Carbon::now(); // 2001-05-21 12:00:00 +echo new Carbon(); // 2001-05-21 12:00:00 +echo Carbon::parse(); // 2001-05-21 12:00:00 +echo new Carbon('now'); // 2001-05-21 12:00:00 +echo Carbon::parse('now'); // 2001-05-21 12:00:00 +var_dump(Carbon::hasTestNow()); // bool(true) +Carbon::setTestNow(); // clear the mock +var_dump(Carbon::hasTestNow()); // bool(false) +echo Carbon::now(); // 2014-01-06 22:52:03 +``` + +A more meaning full example: + +```php +class SeasonalProduct +{ + protected $price; + + public function __construct($price) + { + $this->price = $price; + } + + public function getPrice() { + $multiplier = 1; + if (Carbon::now()->month == 12) { + $multiplier = 2; + } + + return $this->price * $multiplier; + } +} + +$product = new SeasonalProduct(100); +Carbon::setTestNow(Carbon::parse('first day of March 2000')); +echo $product->getPrice(); // 100 +Carbon::setTestNow(Carbon::parse('first day of December 2000')); +echo $product->getPrice(); // 200 +Carbon::setTestNow(Carbon::parse('first day of May 2000')); +echo $product->getPrice(); // 100 +Carbon::setTestNow(); +``` + +Relative phrases are also mocked according to the given "now" instance. + +```php +$knownDate = Carbon::create(2001, 5, 21, 12); // create testing date +Carbon::setTestNow($knownDate); // set the mock +echo new Carbon('tomorrow'); // 2001-05-22 00:00:00 +echo new Carbon('yesterday'); // 2001-05-20 00:00:00 +echo new Carbon('next wednesday'); // 2001-05-23 00:00:00 +echo new Carbon('last friday'); // 2001-05-18 00:00:00 +echo new Carbon('this thursday'); // 2001-05-24 00:00:00 +Carbon::setTestNow(); // always clear it ! +``` + +The list of words that are considered to be relative modifiers are: +- this +- next +- last +- tomorrow +- yesterday +- + +- - +- first +- last +- ago + +Be aware that similar to the next(), previous() and modify() methods some of these relative modifiers will set the time to 00:00:00. + + +### Getters + +The getters are implemented via PHP's `__get()` method. This enables you to access the value as if it was a property rather than a function call. + +```php +$dt = Carbon::create(2012, 9, 5, 23, 26, 11); + +// These getters specifically return integers, ie intval() +var_dump($dt->year); // int(2012) +var_dump($dt->month); // int(9) +var_dump($dt->day); // int(5) +var_dump($dt->hour); // int(23) +var_dump($dt->minute); // int(26) +var_dump($dt->second); // int(11) +var_dump($dt->dayOfWeek); // int(3) +var_dump($dt->dayOfYear); // int(248) +var_dump($dt->weekOfYear); // int(36) +var_dump($dt->daysInMonth); // int(30) +var_dump($dt->timestamp); // int(1346901971) +var_dump(Carbon::createFromDate(1975, 5, 21)->age); // int(38) calculated vs now in the same tz +var_dump($dt->quarter); // int(3) + +// Returns an int of seconds difference from UTC (+/- sign included) +var_dump(Carbon::createFromTimestampUTC(0)->offset); // int(0) +var_dump(Carbon::createFromTimestamp(0)->offset); // int(-18000) + +// Returns an int of hours difference from UTC (+/- sign included) +var_dump(Carbon::createFromTimestamp(0)->offsetHours); // int(-5) + +// Indicates if day light savings time is on +var_dump(Carbon::createFromDate(2012, 1, 1)->dst); // bool(false) +var_dump(Carbon::createFromDate(2012, 9, 1)->dst); // bool(true) + +// Indicates if the instance is in the same timezone as the local timzezone +var_dump(Carbon::now()->local); // bool(true) +var_dump(Carbon::now('America/Vancouver')->local); // bool(false) + +// Indicates if the instance is in the UTC timezone +var_dump(Carbon::now()->utc); // bool(false) +var_dump(Carbon::now('Europe/London')->utc); // bool(true) +var_dump(Carbon::createFromTimestampUTC(0)->utc); // bool(true) + +// Gets the DateTimeZone instance +echo get_class(Carbon::now()->timezone); // DateTimeZone +echo get_class(Carbon::now()->tz); // DateTimeZone + +// Gets the DateTimeZone instance name, shortcut for ->timezone->getName() +echo Carbon::now()->timezoneName; // America/Toronto +echo Carbon::now()->tzName; // America/Toronto +``` + + +### Setters + +The following setters are implemented via PHP's `__set()` method. Its good to take note here that none of the setters, with the obvious exception of explicitly setting the timezone, will change the timezone of the instance. Specifically, setting the timestamp will not set the corresponding timezone to UTC. + +```php +$dt = Carbon::now(); + +$dt->year = 1975; +$dt->month = 13; // would force year++ and month = 1 +$dt->month = 5; +$dt->day = 21; +$dt->hour = 22; +$dt->minute = 32; +$dt->second = 5; + +$dt->timestamp = 169957925; // This will not change the timezone + +// Set the timezone via DateTimeZone instance or string +$dt->timezone = new DateTimeZone('Europe/London'); +$dt->timezone = 'Europe/London'; +$dt->tz = 'Europe/London'; +``` + + +### Fluent Setters + +No arguments are optional for the setters, but there are enough variety in the function definitions that you shouldn't need them anyway. Its good to take note here that none of the setters, with the obvious exception of explicitly setting the timezone, will change the timezone of the instance. Specifically, setting the timestamp will not set the corresponding timezone to UTC. + +```php +$dt = Carbon::now(); + +$dt->year(1975)->month(5)->day(21)->hour(22)->minute(32)->second(5)->toDateTimeString(); +$dt->setDate(1975, 5, 21)->setTime(22, 32, 5)->toDateTimeString(); +$dt->setDateTime(1975, 5, 21, 22, 32, 5)->toDateTimeString(); + +$dt->timestamp(169957925)->timezone('Europe/London'); + +$dt->tz('America/Toronto')->setTimezone('America/Vancouver'); +``` + + +### IsSet + +The PHP function `__isset()` is implemented. This was done as some external systems (ex. [Twig](http://twig.sensiolabs.org/doc/recipes.html#using-dynamic-object-properties)) validate the existence of a property before using it. This is done using the `isset()` or `empty()` method. You can read more about these on the PHP site: [__isset()](http://www.php.net/manual/en/language.oop5.overloading.php#object.isset), [isset()](http://www.php.net/manual/en/function.isset.php), [empty()](http://www.php.net/manual/en/function.empty.php). + +```php +var_dump(isset(Carbon::now()->iDoNotExist)); // bool(false) +var_dump(isset(Carbon::now()->hour)); // bool(true) +var_dump(empty(Carbon::now()->iDoNotExist)); // bool(true) +var_dump(empty(Carbon::now()->year)); // bool(false) +``` + + +### String Formatting and Localization + +All of the available `toXXXString()` methods rely on the base class method [DateTime::format()](http://php.net/manual/en/datetime.format.php). You'll notice the `__toString()` method is defined which allows a Carbon instance to be printed as a pretty date time string when used in a string context. + +```php +$dt = Carbon::create(1975, 12, 25, 14, 15, 16); + +var_dump($dt->toDateTimeString() == $dt); // bool(true) => uses __toString() +echo $dt->toDateString(); // 1975-12-25 +echo $dt->toFormattedDateString(); // Dec 25, 1975 +echo $dt->toTimeString(); // 14:15:16 +echo $dt->toDateTimeString(); // 1975-12-25 14:15:16 +echo $dt->toDayDateTimeString(); // Thu, Dec 25, 1975 2:15 PM + +// ... of course format() is still available +echo $dt->format('l jS \\of F Y h:i:s A'); // Thursday 25th of December 1975 02:15:16 PM +``` + +You can also set the default __toString() format (which defaults to `Y-m-d H:i:s`) thats used when [type juggling](http://php.net/manual/en/language.types.type-juggling.php) occurs. + +```php +Carbon::setToStringFormat('jS \o\f F, Y g:i:s a'); +echo $dt; // 25th of December, 1975 2:15:16 pm +Carbon::resetToStringFormat(); +echo $dt; // 1975-12-25 14:15:16 +``` + +Unfortunately the base class DateTime does not have any localization support. To begin localization support a `formatLocalized($format)` method has been added. The implementation makes a call to [strftime](http://www.php.net/strftime) using the current instance timestamp. If you first set the current locale with [setlocale()](http://www.php.net/setlocale) then the string returned will be formatted in the correct locale. + +```php +setlocale(LC_TIME, 'German'); +echo $dt->formatLocalized('%A %d %B %Y'); // Donnerstag 25 Dezember 1975 +setlocale(LC_TIME, ''); +echo $dt->formatLocalized('%A %d %B %Y'); // Thursday 25 December 1975 +``` + + +## Common Formats + +The following are wrappers for the common formats provided in the [DateTime class](http://www.php.net/manual/en/class.datetime.php). + +```php +$dt = Carbon::now(); + +echo $dt->toATOMString(); // same as $dt->format(DateTime::ATOM); +echo $dt->toCOOKIEString(); +echo $dt->toISO8601String(); +echo $dt->toRFC822String(); +echo $dt->toRFC850String(); +echo $dt->toRFC1036String(); +echo $dt->toRFC1123String(); +echo $dt->toRFC2822String(); +echo $dt->toRFC3339String(); +echo $dt->toRSSString(); +echo $dt->toW3CString(); +``` + + +### Comparison + +Simple comparison is offered up via the following functions. Remember that the comparison is done in the UTC timezone so things aren't always as they seem. + +```php +echo Carbon::now()->tzName; // America/Toronto +$first = Carbon::create(2012, 9, 5, 23, 26, 11); +$second = Carbon::create(2012, 9, 5, 20, 26, 11, 'America/Vancouver'); + +echo $first->toDateTimeString(); // 2012-09-05 23:26:11 +echo $first->tzName; // America/Toronto +echo $second->toDateTimeString(); // 2012-09-05 20:26:11 +echo $second->tzName; // America/Vancouver + +var_dump($first->eq($second)); // bool(true) +var_dump($first->ne($second)); // bool(false) +var_dump($first->gt($second)); // bool(false) +var_dump($first->gte($second)); // bool(true) +var_dump($first->lt($second)); // bool(false) +var_dump($first->lte($second)); // bool(true) + +$first->setDateTime(2012, 1, 1, 0, 0, 0); +$second->setDateTime(2012, 1, 1, 0, 0, 0); // Remember tz is 'America/Vancouver' + +var_dump($first->eq($second)); // bool(false) +var_dump($first->ne($second)); // bool(true) +var_dump($first->gt($second)); // bool(false) +var_dump($first->gte($second)); // bool(false) +var_dump($first->lt($second)); // bool(true) +var_dump($first->lte($second)); // bool(true) +``` + +To determine if the current instance is between two other instances you can use the aptly named `between()` method. The third parameter indicates if an equal to comparison should be done. The default is true which determines if its between or equal to the boundaries. + +```php +$first = Carbon::create(2012, 9, 5, 1); +$second = Carbon::create(2012, 9, 5, 5); +var_dump(Carbon::create(2012, 9, 5, 3)->between($first, $second)); // bool(true) +var_dump(Carbon::create(2012, 9, 5, 5)->between($first, $second)); // bool(true) +var_dump(Carbon::create(2012, 9, 5, 5)->between($first, $second, false)); // bool(false) +``` + +Woah! Did you forget min() and max() ? Nope. That is covered as well by the suitably named `min()` and `max()` methods. As usual the default parameter is now if null is specified. + +```php +$dt1 = Carbon::create(2012, 1, 1, 0, 0, 0); +$dt2 = Carbon::create(2014, 1, 30, 0, 0, 0); +echo $dt1->min($dt2); // 2012-01-01 00:00:00 + +$dt1 = Carbon::create(2012, 1, 1, 0, 0, 0); +$dt2 = Carbon::create(2014, 1, 30, 0, 0, 0); +echo $dt1->max($dt2); // 2014-01-30 00:00:00 + +// now is the default param +$dt1 = Carbon::create(2000, 1, 1, 0, 0, 0); +echo $dt1->max(); // 2014-01-06 22:52:03 +``` + +To handle the most used cases there are some simple helper functions that hopefully are obvious from their names. For the methods that compare to `now()` (ex. isToday()) in some manner the `now()` is created in the same timezone as the instance. + +```php +$dt = Carbon::now(); + +$dt->isWeekday(); +$dt->isWeekend(); +$dt->isYesterday(); +$dt->isToday(); +$dt->isTomorrow(); +$dt->isFuture(); +$dt->isPast(); +$dt->isLeapYear(); +``` + + +### Addition and Subtraction + +The default DateTime provides a couple of different methods for easily adding and subtracting time. There is `modify()`, `add()` and `sub()`. `modify()` takes a *magical* date/time format string, 'last day of next month', that it parses and applies the modification while `add()` and `sub()` use a `DateInterval` class thats not so obvious, `new \DateInterval('P6YT5M')`. Hopefully using these fluent functions will be more clear and easier to read after not seeing your code for a few weeks. But of course I don't make you choose since the base class functions are still available. + +```php +$dt = Carbon::create(2012, 1, 31, 0); + +echo $dt->toDateTimeString(); // 2012-01-31 00:00:00 + +echo $dt->addYears(5); // 2017-01-31 00:00:00 +echo $dt->addYear(); // 2018-01-31 00:00:00 +echo $dt->subYear(); // 2017-01-31 00:00:00 +echo $dt->subYears(5); // 2012-01-31 00:00:00 + +echo $dt->addMonths(60); // 2017-01-31 00:00:00 +echo $dt->addMonth(); // 2017-03-03 00:00:00 equivalent of $dt->month($dt->month + 1); so it wraps +echo $dt->subMonth(); // 2017-02-03 00:00:00 +echo $dt->subMonths(60); // 2012-02-03 00:00:00 + +echo $dt->addDays(29); // 2012-03-03 00:00:00 +echo $dt->addDay(); // 2012-03-04 00:00:00 +echo $dt->subDay(); // 2012-03-03 00:00:00 +echo $dt->subDays(29); // 2012-02-03 00:00:00 + +echo $dt->addWeekdays(4); // 2012-02-09 00:00:00 +echo $dt->addWeekday(); // 2012-02-10 00:00:00 +echo $dt->subWeekday(); // 2012-02-09 00:00:00 +echo $dt->subWeekdays(4); // 2012-02-03 00:00:00 + +echo $dt->addWeeks(3); // 2012-02-24 00:00:00 +echo $dt->addWeek(); // 2012-03-02 00:00:00 +echo $dt->subWeek(); // 2012-02-24 00:00:00 +echo $dt->subWeeks(3); // 2012-02-03 00:00:00 + +echo $dt->addHours(24); // 2012-02-04 00:00:00 +echo $dt->addHour(); // 2012-02-04 01:00:00 +echo $dt->subHour(); // 2012-02-04 00:00:00 +echo $dt->subHours(24); // 2012-02-03 00:00:00 + +echo $dt->addMinutes(61); // 2012-02-03 01:01:00 +echo $dt->addMinute(); // 2012-02-03 01:02:00 +echo $dt->subMinute(); // 2012-02-03 01:01:00 +echo $dt->subMinutes(61); // 2012-02-03 00:00:00 + +echo $dt->addSeconds(61); // 2012-02-03 00:01:01 +echo $dt->addSecond(); // 2012-02-03 00:01:02 +echo $dt->subSecond(); // 2012-02-03 00:01:01 +echo $dt->subSeconds(61); // 2012-02-03 00:00:00 +``` + +For fun you can also pass negative values to `addXXX()`, in fact that's how `subXXX()` is implemented. + + +### Difference + +These functions always return the **total difference** expressed in the specified time requested. This differs from the base class `diff()` function where an interval of 61 seconds would be returned as 1 minute and 1 second via a `DateInterval` instance. The `diffInMinutes()` function would simply return 1. All values are truncated and not rounded. Each function below has a default first parameter which is the Carbon instance to compare to, or null if you want to use `now()`. The 2nd parameter again is optional and indicates if you want the return value to be the absolute value or a relative value that might have a `-` (negative) sign if the passed in date is less than the current instance. This will default to true, return the absolute value. The comparisons are done in UTC. + +```php +// Carbon::diffInYears(Carbon $dt = null, $abs = true) + +echo Carbon::now('America/Vancouver')->diffInSeconds(Carbon::now('Europe/London')); // 0 + +$dtOttawa = Carbon::createFromDate(2000, 1, 1, 'America/Toronto'); +$dtVancouver = Carbon::createFromDate(2000, 1, 1, 'America/Vancouver'); +echo $dtOttawa->diffInHours($dtVancouver); // 3 + +echo $dtOttawa->diffInHours($dtVancouver, false); // 3 +echo $dtVancouver->diffInHours($dtOttawa, false); // -3 + +$dt = Carbon::create(2012, 1, 31, 0); +echo $dt->diffInDays($dt->copy()->addMonth()); // 31 +echo $dt->diffInDays($dt->copy()->subMonth(), false); // -31 + +$dt = Carbon::create(2012, 4, 30, 0); +echo $dt->diffInDays($dt->copy()->addMonth()); // 30 +echo $dt->diffInDays($dt->copy()->addWeek()); // 7 + +$dt = Carbon::create(2012, 1, 1, 0); +echo $dt->diffInMinutes($dt->copy()->addSeconds(59)); // 0 +echo $dt->diffInMinutes($dt->copy()->addSeconds(60)); // 1 +echo $dt->diffInMinutes($dt->copy()->addSeconds(119)); // 1 +echo $dt->diffInMinutes($dt->copy()->addSeconds(120)); // 2 + +// others that are defined +// diffInYears(), diffInMonths(), diffInDays() +// diffInHours(), diffInMinutes(), diffInSeconds() +``` +```php +// Carbon::average(Carbon $dt = null) +``` + + +### Difference for Humans + +It is easier for humans to read `1 month ago` compared to 30 days ago. This is a common function seen in most date libraries so I thought I would add it here as well. It uses approximations for a month being 4 weeks. The lone argument for the function is the other Carbon instance to diff against, and of course it defaults to `now()` if not specified. + +This method will add a phrase after the difference value relative to the instance and the passed in instance. There are 4 possibilities: + +* When comparing a value in the past to default now: + * 1 hour ago + * 5 months ago + +* When comparing a value in the future to default now: + * 1 hour from now + * 5 months from now + +* When comparing a value in the past to another value: + * 1 hour before + * 5 months before + +* When comparing a value in the future to another value: + * 1 hour after + * 5 months after + +```php +// The most typical usage is for comments +// The instance is the date the comment was created and its being compared to default now() +echo Carbon::now()->subDays(5)->diffForHumans(); // 5 days ago + +echo Carbon::now()->diffForHumans(Carbon::now()->subYear()); // 1 year after + +$dt = Carbon::createFromDate(2011, 2, 1); + +echo $dt->diffForHumans($dt->copy()->addMonth()); // 1 month before +echo $dt->diffForHumans($dt->copy()->subMonth()); // 1 month after + +echo Carbon::now()->addSeconds(5)->diffForHumans(); // 5 seconds from now + +echo Carbon::now()->subDays(24)->diffForHumans(); // 3 weeks ago +``` + + +### Modifiers + +These group of methods perform helpful modifications to the current instance. Most of them are self explanatory from their names... or at least should be. You'll also notice that the startOfXXX(), next() and previous() methods set the time to 00:00:00 and the endOfXXX() methods set the time to 23:59:59. + +The only one slightly different is the `average()` function. It moves your instance to the middle date between itself and the provided Carbon argument. + +```php +$dt = Carbon::create(2012, 1, 31, 12, 0, 0); +echo $dt->startOfDay(); // 2012-01-31 00:00:00 + +$dt = Carbon::create(2012, 1, 31, 12, 0, 0); +echo $dt->endOfDay(); // 2012-01-31 23:59:59 + +$dt = Carbon::create(2012, 1, 31, 12, 0, 0); +echo $dt->startOfMonth(); // 2012-01-01 00:00:00 + +$dt = Carbon::create(2012, 1, 31, 12, 0, 0); +echo $dt->endOfMonth(); // 2012-01-31 23:59:59 + +$dt = Carbon::create(2012, 1, 31, 12, 0, 0); +echo $dt->startOfYear(); // 2012-01-01 00:00:00 + +$dt = Carbon::create(2012, 1, 31, 12, 0, 0); +echo $dt->endOfYear(); // 2012-12-31 23:59:59 + +$dt = Carbon::create(2012, 1, 31, 12, 0, 0); +echo $dt->startOfDecade(); // 2010-01-01 00:00:00 + +$dt = Carbon::create(2012, 1, 31, 12, 0, 0); +echo $dt->endOfDecade(); // 2019-12-31 23:59:59 + +$dt = Carbon::create(2012, 1, 31, 12, 0, 0); +echo $dt->startOfCentury(); // 2000-01-01 00:00:00 + +$dt = Carbon::create(2012, 1, 31, 12, 0, 0); +echo $dt->endOfCentury(); // 2099-12-31 23:59:59 + +$dt = Carbon::create(2012, 1, 31, 12, 0, 0); +echo $dt->startOfWeek(); // 2012-01-30 00:00:00 +var_dump($dt->dayOfWeek == Carbon::MONDAY); // bool(true) : ISO8601 week starts on Monday + +$dt = Carbon::create(2012, 1, 31, 12, 0, 0); +echo $dt->endOfWeek(); // 2012-02-05 23:59:59 +var_dump($dt->dayOfWeek == Carbon::SUNDAY); // bool(true) : ISO8601 week ends on Sunday + +$dt = Carbon::create(2012, 1, 31, 12, 0, 0); +echo $dt->next(Carbon::WEDNESDAY); // 2012-02-01 00:00:00 +var_dump($dt->dayOfWeek == Carbon::WEDNESDAY); // bool(true) + +$dt = Carbon::create(2012, 1, 1, 12, 0, 0); +echo $dt->next(); // 2012-01-08 00:00:00 + +$dt = Carbon::create(2012, 1, 31, 12, 0, 0); +echo $dt->previous(Carbon::WEDNESDAY); // 2012-01-25 00:00:00 +var_dump($dt->dayOfWeek == Carbon::WEDNESDAY); // bool(true) + +$dt = Carbon::create(2012, 1, 1, 12, 0, 0); +echo $dt->previous(); // 2011-12-25 00:00:00 + +$start = Carbon::create(2014, 1, 1, 0, 0, 0); +$end = Carbon::create(2014, 1, 30, 0, 0, 0); +echo $start->average($end); // 2014-01-15 12:00:00 + +// others that are defined that are similar +// firstOfMonth(), lastOfMonth(), nthOfMonth() +// firstOfQuarter(), lastOfQuarter(), nthOfQuarter() +// firstOfYear(), lastOfYear(), nthOfYear() + +``` + + +### Constants + +The following constants are defined in the Carbon class. + +* SUNDAY = 0 +* MONDAY = 1 +* TUESDAY = 2 +* WEDNESDAY = 3 +* THURSDAY = 4 +* FRIDAY = 5 +* SATURDAY = 6 +* MONTHS_PER_YEAR = 12 +* HOURS_PER_DAY = 24 +* MINUTES_PER_HOUR = 60 +* SECONDS_PER_MINUTE = 60 + +```php +$dt = Carbon::createFromDate(2012, 10, 6); +if ($dt->dayOfWeek === Carbon::SATURDAY) { + echo 'Place bets on Ottawa Senators Winning!'; +} +``` + + +## About + + +### Contributing + +I hate reading a readme.md file that has code errors and/or sample output that is incorrect. I tried something new with this project and wrote a quick readme parser that can **lint** sample source code or **execute** and inject the actual result into a generated readme. + +> **Don't make changes to the `readme.md` directly!!** + +Change the `readme.src.md` and then use the `readme.php` to generate the new `readme.md` file. It can be run at the command line using `php readme.php` from the project root. Maybe someday I'll extract this out to another project or at least run it with a post receive hook, but for now its just a local tool, deal with it. + +The commands are quickly explained below. To see some examples you can view the raw `readme.src.md` file in this repo. + +`{{::lint()}}` + +The `lint` command is meant for confirming the code is valid and will `eval()` the code passed into the function. Assuming there were no errors, the executed source code will then be injected back into the text replacing out the `{{::lint()}}`. When you look at the raw `readme.src.md` you will see that the code can span several lines. Remember the code is executed in the context of the running script so any variables will be available for the rest of the file. + + {{::lint($var = 'brian nesbitt';)}} => $var = 'brian nesbitt'; + +> As mentioned the `$var` can later be echo'd and you would get 'brian nesbitt' as all of the source is executed in the same scope. + +`{{varName::exec()}}` and `{{varName_eval}}` + +The `exec` command begins by performing an `eval()` on the code passed into the function. The executed source code will then be injected back into the text replacing out the `{{varName::exec()}}`. This will also create a variable named `varName_eval` that you can then place anywhere in the file and it will get replaced with the output of the `eval()`. You can use any type of output (`echo`, `printf`, `var_dump` etc) statement to return the result value as an output buffer is setup to capture the output. + + {{exVarName::exec(echo $var;)}} => echo $var; + {{exVarName_eval}} => brian nesbitt // $var is still set from above + +`/*pad()*/` + +The `pad()` is a special source modifier. This will pad the code block to the indicated number of characters using spaces. Its particularly handy for aligning `//` comments when showing results. + + {{exVarName1::exec(echo 12345;/*pad(20)*/)}} // {{exVarName1_eval}} + {{exVarName2::exec(echo 6;/*pad(20)*/)}} // {{exVarName2_eval}} + +... would generate to: + + echo 12345; // 12345 + echo 6; // 6 + +Apart from the readme the typical steps can be used to contribute your own improvements. + +* Fork +* Clone +* PHPUnit +* Branch +* PHPUnit +* Code +* PHPUnit +* Commit +* Push +* Pull request +* Relax and play Castle Crashers + + +### Author + +Brian Nesbitt - - + + +### License + +Carbon is licensed under the MIT License - see the `LICENSE` file for details + + +### History + +You can view the history of the Carbon project in the [history file](https://github.com/briannesbitt/Carbon/blob/master/history.md). + + +### Why the name Carbon? + +Read about [Carbon Dating](http://en.wikipedia.org/wiki/Radiocarbon_dating) + +![](https://cruel-carlota.pagodabox.com/55ce479cc1edc5e0cc5b4b6f9a7a9200) \ No newline at end of file diff --git a/vendor/nesbot/carbon/src/Carbon/Carbon.php b/vendor/nesbot/carbon/src/Carbon/Carbon.php new file mode 100755 index 0000000..fe3e37b --- /dev/null +++ b/vendor/nesbot/carbon/src/Carbon/Carbon.php @@ -0,0 +1,2127 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Carbon; + +use DateTime; +use DateTimeZone; +use InvalidArgumentException; + +/** + * A simple API extension for DateTime + * + * @property integer $year + * @property integer $month + * @property integer $day + * @property integer $hour + * @property integer $minute + * @property integer $second + * @property integer $timestamp seconds since the Unix Epoch + * @property-read integer $dayOfWeek 0 (for Sunday) through 6 (for Saturday) + * @property-read integer $dayOfYear 0 through 365 + * @property-read integer $weekOfYear ISO-8601 week number of year, weeks starting on Monday + * @property-read integer $daysInMonth number of days in the given month + * @property-read integer $age does a diffInYears() with default parameters + * @property-read integer $quarter the quarter of this instance, 1 - 4 + * @property-read integer $offset the timezone offset in seconds from UTC + * @property-read integer $offsetHours the timezone offset in hours from UTC + * @property-read boolean $dst daylight savings time indicator, true if DST, false otherwise + * @property-read boolean $local checks if the timezone is local, true if local, false otherwise + * @property-read boolean $utc checks if the timezone is UTC, true if UTC, false otherwise + * @property-read string $timezoneName + * @property-read string $tzName + * + * @property-read DateTimeZone $timezone the current timezone + * @property-read DateTimeZone $tz alias of timezone + * @property-write DateTimeZone|string $timezone the current timezone + * @property-write DateTimeZone|string $tz alias of timezone + * + */ +class Carbon extends DateTime +{ + /** + * The day constants + */ + const SUNDAY = 0; + const MONDAY = 1; + const TUESDAY = 2; + const WEDNESDAY = 3; + const THURSDAY = 4; + const FRIDAY = 5; + const SATURDAY = 6; + + /** + * Names of days of the week. + * + * @var array + */ + protected static $days = array( + self::SUNDAY => 'Sunday', + self::MONDAY => 'Monday', + self::TUESDAY => 'Tuesday', + self::WEDNESDAY => 'Wednesday', + self::THURSDAY => 'Thursday', + self::FRIDAY => 'Friday', + self::SATURDAY => 'Saturday' + ); + + /** + * Terms used to detect if a time passed is a relative date for testing purposes + * + * @var array + */ + protected static $relativeKeywords = array( + 'this', + 'next', + 'last', + 'tomorrow', + 'yesterday', + '+', + '-', + 'first', + 'last', + 'ago' + ); + + /** + * Number of X in Y + */ + const MONTHS_PER_YEAR = 12; + const WEEKS_PER_YEAR = 52; + const DAYS_PER_WEEK = 7; + const HOURS_PER_DAY = 24; + const MINUTES_PER_HOUR = 60; + const SECONDS_PER_MINUTE = 60; + + /** + * Default format to use for __toString method when type juggling occurs. + * + * @var string + */ + const DEFAULT_TO_STRING_FORMAT = 'Y-m-d H:i:s'; + + /** + * Format to use for __toString method when type juggling occurs. + * + * @var string + */ + protected static $toStringFormat = self::DEFAULT_TO_STRING_FORMAT; + + /** + * A test Carbon instance to be returned when now instances are created + * + * @var Carbon + */ + protected static $testNow; + + /** + * Creates a DateTimeZone from a string or a DateTimeZone + * + * @param DateTimeZone|string $object + * + * @return DateTimeZone + * + * @throws InvalidArgumentException + */ + protected static function safeCreateDateTimeZone($object) + { + if ($object instanceof DateTimeZone) { + return $object; + } + + $tz = @timezone_open((string) $object); + + if ($tz === false) { + throw new InvalidArgumentException('Unknown or bad timezone ('.$object.')'); + } + + return $tz; + } + + /////////////////////////////////////////////////////////////////// + //////////////////////////// CONSTRUCTORS ///////////////////////// + /////////////////////////////////////////////////////////////////// + + /** + * Create a new Carbon instance. + * + * Please see the testing aids section (specifically static::setTestNow()) + * for more on the possibility of this constructor returning a test instance. + * + * @param string $time + * @param DateTimeZone|string $tz + */ + public function __construct($time = null, $tz = null) + { + // If the class has a test now set and we are trying to create a now() + // instance then override as required + if (static::hasTestNow() && (empty($time) || $time === 'now' || static::hasRelativeKeywords($time))) { + $testInstance = clone static::getTestNow(); + if (static::hasRelativeKeywords($time)) { + $testInstance->modify($time); + } + + //shift the time according to the given time zone + if ($tz !== NULL && $tz != static::getTestNow()->tz) { + $testInstance->setTimezone($tz); + } else { + $tz = $testInstance->tz; + } + + $time = $testInstance->toDateTimeString(); + } + + if ($tz !== null) { + parent::__construct($time, static::safeCreateDateTimeZone($tz)); + } else { + parent::__construct($time); + } + } + + /** + * Create a Carbon instance from a DateTime one + * + * @param DateTime $dt + * + * @return Carbon + */ + public static function instance(DateTime $dt) + { + return new static($dt->format('Y-m-d H:i:s'), $dt->getTimeZone()); + } + + /** + * Create a carbon instance from a string. This is an alias for the + * constructor that allows better fluent syntax as it allows you to do + * Carbon::parse('Monday next week')->fn() rather than + * (new Carbon('Monday next week'))->fn() + * + * @param string $time + * @param DateTimeZone|string $tz + * + * @return Carbon + */ + public static function parse($time = null, $tz = null) + { + return new static($time, $tz); + } + + /** + * Get a Carbon instance for the current date and time + * + * @param DateTimeZone|string $tz + * + * @return Carbon + */ + public static function now($tz = null) + { + return new static(null, $tz); + } + + /** + * Create a Carbon instance for today + * + * @param DateTimeZone|string $tz + * + * @return Carbon + */ + public static function today($tz = null) + { + return static::now($tz)->startOfDay(); + } + + /** + * Create a Carbon instance for tomorrow + * + * @param DateTimeZone|string $tz + * + * @return Carbon + */ + public static function tomorrow($tz = null) + { + return static::today($tz)->addDay(); + } + + /** + * Create a Carbon instance for yesterday + * + * @param DateTimeZone|string $tz + * + * @return Carbon + */ + public static function yesterday($tz = null) + { + return static::today($tz)->subDay(); + } + + /** + * Create a new Carbon instance from a specific date and time. + * + * If any of $year, $month or $day are set to null their now() values + * will be used. + * + * If $hour is null it will be set to its now() value and the default values + * for $minute and $second will be their now() values. + * If $hour is not null then the default values for $minute and $second + * will be 0. + * + * @param integer $year + * @param integer $month + * @param integer $day + * @param integer $hour + * @param integer $minute + * @param integer $second + * @param DateTimeZone|string $tz + * + * @return Carbon + */ + public static function create($year = null, $month = null, $day = null, $hour = null, $minute = null, $second = null, $tz = null) + { + $year = ($year === null) ? date('Y') : $year; + $month = ($month === null) ? date('n') : $month; + $day = ($day === null) ? date('j') : $day; + + if ($hour === null) { + $hour = date('G'); + $minute = ($minute === null) ? date('i') : $minute; + $second = ($second === null) ? date('s') : $second; + } else { + $minute = ($minute === null) ? 0 : $minute; + $second = ($second === null) ? 0 : $second; + } + + return static::createFromFormat('Y-n-j G:i:s', sprintf('%s-%s-%s %s:%02s:%02s', $year, $month, $day, $hour, $minute, $second), $tz); + } + + /** + * Create a Carbon instance from just a date. The time portion is set to now. + * + * @param integer $year + * @param integer $month + * @param integer $day + * @param DateTimeZone|string $tz + * + * @return Carbon + */ + public static function createFromDate($year = null, $month = null, $day = null, $tz = null) + { + return static::create($year, $month, $day, null, null, null, $tz); + } + + /** + * Create a Carbon instance from just a time. The date portion is set to today. + * + * @param integer $hour + * @param integer $minute + * @param integer $second + * @param DateTimeZone|string $tz + * + * @return Carbon + */ + public static function createFromTime($hour = null, $minute = null, $second = null, $tz = null) + { + return static::create(null, null, null, $hour, $minute, $second, $tz); + } + + /** + * Create a Carbon instance from a specific format + * + * @param string $format + * @param string $time + * @param DateTimeZone|string $tz + * + * @return Carbon + * + * @throws InvalidArgumentException + */ + public static function createFromFormat($format, $time, $tz = null) + { + if ($tz !== null) { + $dt = parent::createFromFormat($format, $time, static::safeCreateDateTimeZone($tz)); + } else { + $dt = parent::createFromFormat($format, $time); + } + + if ($dt instanceof DateTime) { + return static::instance($dt); + } + + $errors = static::getLastErrors(); + throw new InvalidArgumentException(implode(PHP_EOL, $errors['errors'])); + } + + /** + * Create a Carbon instance from a timestamp + * + * @param integer $timestamp + * @param DateTimeZone|string $tz + * + * @return Carbon + */ + public static function createFromTimestamp($timestamp, $tz = null) + { + return static::now($tz)->setTimestamp($timestamp); + } + + /** + * Create a Carbon instance from an UTC timestamp + * + * @param integer $timestamp + * + * @return Carbon + */ + public static function createFromTimestampUTC($timestamp) + { + return new static('@'.$timestamp); + } + + /** + * Get a copy of the instance + * + * @return Carbon + */ + public function copy() + { + return static::instance($this); + } + + /////////////////////////////////////////////////////////////////// + ///////////////////////// GETTERS AND SETTERS ///////////////////// + /////////////////////////////////////////////////////////////////// + + /** + * Get a part of the Carbon object + * + * @param string $name + * + * @throws InvalidArgumentException + * + * @return string|integer|DateTimeZone + */ + public function __get($name) + { + switch ($name) { + case 'year': + return intval($this->format('Y')); + + case 'month': + return intval($this->format('n')); + + case 'day': + return intval($this->format('j')); + + case 'hour': + return intval($this->format('G')); + + case 'minute': + return intval($this->format('i')); + + case 'second': + return intval($this->format('s')); + + case 'dayOfWeek': + return intval($this->format('w')); + + case 'dayOfYear': + return intval($this->format('z')); + + case 'weekOfYear': + return intval($this->format('W')); + + case 'daysInMonth': + return intval($this->format('t')); + + case 'timestamp': + return intval($this->format('U')); + + case 'age': + return intval($this->diffInYears()); + + case 'quarter': + return intval(($this->month - 1) / 3) + 1; + + case 'offset': + return $this->getOffset(); + + case 'offsetHours': + return $this->getOffset() / self::SECONDS_PER_MINUTE / self::MINUTES_PER_HOUR; + + case 'dst': + return $this->format('I') == '1'; + + case 'local': + return $this->offset == $this->copy()->setTimezone(date_default_timezone_get())->offset; + + case 'utc': + return $this->offset == 0; + + case 'timezone': + case 'tz': + return $this->getTimezone(); + + case 'timezoneName': + case 'tzName': + return $this->getTimezone()->getName(); + + default: + throw new InvalidArgumentException(sprintf("Unknown getter '%s'", $name)); + } + } + + /** + * Check if an attribute exists on the object + * + * @param string $name + * + * @return boolean + */ + public function __isset($name) + { + try { + $this->__get($name); + } catch (InvalidArgumentException $e) { + return false; + } + + return true; + } + + /** + * Set a part of the Carbon object + * + * @param string $name + * @param string|integer|DateTimeZone $value + * + * @throws InvalidArgumentException + */ + public function __set($name, $value) + { + switch ($name) { + case 'year': + parent::setDate($value, $this->month, $this->day); + break; + + case 'month': + parent::setDate($this->year, $value, $this->day); + break; + + case 'day': + parent::setDate($this->year, $this->month, $value); + break; + + case 'hour': + parent::setTime($value, $this->minute, $this->second); + break; + + case 'minute': + parent::setTime($this->hour, $value, $this->second); + break; + + case 'second': + parent::setTime($this->hour, $this->minute, $value); + break; + + case 'timestamp': + parent::setTimestamp($value); + break; + + case 'timezone': + case 'tz': + $this->setTimezone($value); + break; + + default: + throw new InvalidArgumentException(sprintf("Unknown setter '%s'", $name)); + } + } + + /** + * Set the instance's year + * + * @param integer $value + * + * @return Carbon + */ + public function year($value) + { + $this->year = $value; + + return $this; + } + + /** + * Set the instance's month + * + * @param integer $value + * + * @return Carbon + */ + public function month($value) + { + $this->month = $value; + + return $this; + } + + /** + * Set the instance's day + * + * @param integer $value + * + * @return Carbon + */ + public function day($value) + { + $this->day = $value; + + return $this; + } + + /** + * Set the date all together + * + * @param integer $year + * @param integer $month + * @param integer $day + * + * @return Carbon + */ + public function setDate($year, $month, $day) + { + return $this->year($year)->month($month)->day($day); + } + + /** + * Set the instance's hour + * + * @param integer $value + * + * @return Carbon + */ + public function hour($value) + { + $this->hour = $value; + + return $this; + } + + /** + * Set the instance's minute + * + * @param integer $value + * + * @return Carbon + */ + public function minute($value) + { + $this->minute = $value; + + return $this; + } + + /** + * Set the instance's second + * + * @param integer $value + * + * @return Carbon + */ + public function second($value) + { + $this->second = $value; + + return $this; + } + + /** + * Set the time all together + * + * @param integer $hour + * @param integer $minute + * @param integer $second + * + * @return Carbon + */ + public function setTime($hour, $minute, $second = 0) + { + return $this->hour($hour)->minute($minute)->second($second); + } + + /** + * Set the date and time all together + * + * @param integer $year + * @param integer $month + * @param integer $day + * @param integer $hour + * @param integer $minute + * @param integer $second + * + * @return Carbon + */ + public function setDateTime($year, $month, $day, $hour, $minute, $second) + { + return $this->setDate($year, $month, $day)->setTime($hour, $minute, $second); + } + + /** + * Set the instance's timestamp + * + * @param integer $value + * + * @return Carbon + */ + public function timestamp($value) + { + $this->timestamp = $value; + + return $this; + } + + /** + * Alias for setTimezone() + * + * @param DateTimeZone|string $value + * + * @return Carbon + */ + public function timezone($value) + { + return $this->setTimezone($value); + } + + /** + * Alias for setTimezone() + * + * @param DateTimeZone|string $value + * + * @return Carbon + */ + public function tz($value) + { + return $this->setTimezone($value); + } + + /** + * Set the instance's timezone from a string or object + * + * @param DateTimeZone|string $value + * + * @return Carbon + */ + public function setTimezone($value) + { + parent::setTimezone(static::safeCreateDateTimeZone($value)); + + return $this; + } + + /////////////////////////////////////////////////////////////////// + ///////////////////////// TESTING AIDS //////////////////////////// + /////////////////////////////////////////////////////////////////// + + /** + * Set a Carbon instance (real or mock) to be returned when a "now" + * instance is created. The provided instance will be returned + * specifically under the following conditions: + * - A call to the static now() method, ex. Carbon::now() + * - When a null (or blank string) is passed to the constructor or parse(), ex. new Carbon(null) + * - When the string "now" is passed to the constructor or parse(), ex. new Carbon('now') + * + * Note the timezone parameter was left out of the examples above and + * has no affect as the mock value will be returned regardless of its value. + * + * To clear the test instance call this method using the default + * parameter of null. + * + * @param Carbon $testNow + */ + public static function setTestNow(Carbon $testNow = null) + { + static::$testNow = $testNow; + } + + /** + * Get the Carbon instance (real or mock) to be returned when a "now" + * instance is created. + * + * @return Carbon the current instance used for testing + */ + public static function getTestNow() + { + return static::$testNow; + } + + /** + * Determine if there is a valid test instance set. A valid test instance + * is anything that is not null. + * + * @return boolean true if there is a test instance, otherwise false + */ + public static function hasTestNow() + { + return static::getTestNow() !== null; + } + + /** + * Determine if there is a relative keyword in the time string, this is to + * create dates relative to now for test instances. e.g.: next tuesday + * + * @param string $time + * + * @return boolean true if there is a keyword, otherwise false + */ + public static function hasRelativeKeywords($time) { + // skip common format with a '-' in it + if (preg_match('/[0-9]{4}-[0-9]{1,2}-[0-9]{1,2}/', $time) === 1) { + return false; + } + + foreach(static::$relativeKeywords as $keyword) { + if (stripos($time, $keyword) !== false) { + return true; + } + } + + return false; + } + + /////////////////////////////////////////////////////////////////// + /////////////////////// STRING FORMATTING ///////////////////////// + /////////////////////////////////////////////////////////////////// + + /** + * Format the instance with the current locale. You can set the current + * locale using setlocale() http://php.net/setlocale. + * + * @param string $format + * + * @return string + */ + public function formatLocalized($format = self::COOKIE) + { + // Check for Windows to find and replace the %e + // modifier correctly + if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') { + $format = preg_replace('#(?timestamp); + } + + /** + * Reset the format used to the default when type juggling a Carbon instance to a string + * + */ + public static function resetToStringFormat() + { + static::setToStringFormat(self::DEFAULT_TO_STRING_FORMAT); + } + + /** + * Set the default format used when type juggling a Carbon instance to a string + * + * @param string $format + */ + public static function setToStringFormat($format) + { + static::$toStringFormat = $format; + } + + /** + * Format the instance as a string using the set format + * + * @return string + */ + public function __toString() + { + return $this->format(static::$toStringFormat); + } + + /** + * Format the instance as date + * + * @return string + */ + public function toDateString() + { + return $this->format('Y-m-d'); + } + + /** + * Format the instance as a readable date + * + * @return string + */ + public function toFormattedDateString() + { + return $this->format('M j, Y'); + } + + /** + * Format the instance as time + * + * @return string + */ + public function toTimeString() + { + return $this->format('H:i:s'); + } + + /** + * Format the instance as date and time + * + * @return string + */ + public function toDateTimeString() + { + return $this->format('Y-m-d H:i:s'); + } + + /** + * Format the instance with day, date and time + * + * @return string + */ + public function toDayDateTimeString() + { + return $this->format('D, M j, Y g:i A'); + } + + /** + * Format the instance as ATOM + * + * @return string + */ + public function toATOMString() + { + return $this->format(self::ATOM); + } + + /** + * Format the instance as COOKIE + * + * @return string + */ + public function toCOOKIEString() + { + return $this->format(self::COOKIE); + } + + /** + * Format the instance as ISO8601 + * + * @return string + */ + public function toISO8601String() + { + return $this->format(self::ISO8601); + } + + /** + * Format the instance as RFC822 + * + * @return string + */ + public function toRFC822String() + { + return $this->format(self::RFC822); + } + + /** + * Format the instance as RFC850 + * + * @return string + */ + public function toRFC850String() + { + return $this->format(self::RFC850); + } + + /** + * Format the instance as RFC1036 + * + * @return string + */ + public function toRFC1036String() + { + return $this->format(self::RFC1036); + } + + /** + * Format the instance as RFC1123 + * + * @return string + */ + public function toRFC1123String() + { + return $this->format(self::RFC1123); + } + + /** + * Format the instance as RFC2822 + * + * @return string + */ + public function toRFC2822String() + { + return $this->format(self::RFC2822); + } + + /** + * Format the instance as RFC3339 + * + * @return string + */ + public function toRFC3339String() + { + return $this->format(self::RFC3339); + } + + /** + * Format the instance as RSS + * + * @return string + */ + public function toRSSString() + { + return $this->format(self::RSS); + } + + /** + * Format the instance as W3C + * + * @return string + */ + public function toW3CString() + { + return $this->format(self::W3C); + } + + /////////////////////////////////////////////////////////////////// + ////////////////////////// COMPARISONS //////////////////////////// + /////////////////////////////////////////////////////////////////// + + /** + * Determines if the instance is equal to another + * + * @param Carbon $dt + * + * @return boolean + */ + public function eq(Carbon $dt) + { + return $this == $dt; + } + + /** + * Determines if the instance is not equal to another + * + * @param Carbon $dt + * + * @return boolean + */ + public function ne(Carbon $dt) + { + return !$this->eq($dt); + } + + /** + * Determines if the instance is greater (after) than another + * + * @param Carbon $dt + * + * @return boolean + */ + public function gt(Carbon $dt) + { + return $this > $dt; + } + + /** + * Determines if the instance is greater (after) than or equal to another + * + * @param Carbon $dt + * + * @return boolean + */ + public function gte(Carbon $dt) + { + return $this >= $dt; + } + + /** + * Determines if the instance is less (before) than another + * + * @param Carbon $dt + * + * @return boolean + */ + public function lt(Carbon $dt) + { + return $this < $dt; + } + + /** + * Determines if the instance is less (before) or equal to another + * + * @param Carbon $dt + * + * @return boolean + */ + public function lte(Carbon $dt) + { + return $this <= $dt; + } + + /** + * Determines if the instance is between two others + * + * @param Carbon $dt1 + * @param Carbon $dt2 + * @param boolean $equal Indicates if a > and < comparison should be used or <= or >= + * + * @return boolean + */ + public function between(Carbon $dt1, Carbon $dt2, $equal = true) + { + if ($dt1->gt($dt2)) { + $temp = $dt1; + $dt1 = $dt2; + $dt2 = $temp; + } + + if ($equal) { + return $this->gte($dt1) && $this->lte($dt2); + } else { + return $this->gt($dt1) && $this->lt($dt2); + } + } + + /** + * Get the minimum instance between a given instance (default now) and the current instance. + * + * @param Carbon $dt + * + * @return Carbon + */ + public function min(Carbon $dt = null) + { + $dt = ($dt === null) ? static::now($this->tz) : $dt; + + return $this->lt($dt) ? $this : $dt; + } + + /** + * Get the maximum instance between a given instance (default now) and the current instance. + * + * @param Carbon $dt + * + * @return Carbon + */ + public function max(Carbon $dt = null) + { + $dt = ($dt === null) ? static::now($this->tz) : $dt; + + return $this->gt($dt) ? $this : $dt; + } + + /** + * Determines if the instance is a weekday + * + * @return boolean + */ + public function isWeekday() + { + return ($this->dayOfWeek != self::SUNDAY && $this->dayOfWeek != self::SATURDAY); + } + + /** + * Determines if the instance is a weekend day + * + * @return boolean + */ + public function isWeekend() + { + return !$this->isWeekDay(); + } + + /** + * Determines if the instance is yesterday + * + * @return boolean + */ + public function isYesterday() + { + return $this->toDateString() === static::now($this->tz)->subDay()->toDateString(); + } + + /** + * Determines if the instance is today + * + * @return boolean + */ + public function isToday() + { + return $this->toDateString() === static::now($this->tz)->toDateString(); + } + + /** + * Determines if the instance is tomorrow + * + * @return boolean + */ + public function isTomorrow() + { + return $this->toDateString() === static::now($this->tz)->addDay()->toDateString(); + } + + /** + * Determines if the instance is in the future, ie. greater (after) than now + * + * @return boolean + */ + public function isFuture() + { + return $this->gt(static::now($this->tz)); + } + + /** + * Determines if the instance is in the past, ie. less (before) than now + * + * @return boolean + */ + public function isPast() + { + return !$this->isFuture(); + } + + /** + * Determines if the instance is a leap year + * + * @return boolean + */ + public function isLeapYear() + { + return $this->format('L') == '1'; + } + + /////////////////////////////////////////////////////////////////// + /////////////////// ADDITIONS AND SUBSTRACTIONS /////////////////// + /////////////////////////////////////////////////////////////////// + + /** + * Add years to the instance. Positive $value travel forward while + * negative $value travel into the past. + * + * @param integer $value + * + * @return Carbon + */ + public function addYears($value) + { + return $this->modify(intval($value) . ' year'); + } + + /** + * Add a year to the instance + * + * @return Carbon + */ + public function addYear() + { + return $this->addYears(1); + } + + /** + * Remove a year from the instance + * + * @return Carbon + */ + public function subYear() + { + return $this->addYears(-1); + } + + /** + * Remove years from the instance. + * + * @param integer $value + * + * @return Carbon + */ + public function subYears($value) + { + return $this->addYears(-1 * $value); + } + + /** + * Add months to the instance. Positive $value travels forward while + * negative $value travels into the past. + * + * @param integer $value + * + * @return Carbon + */ + public function addMonths($value) + { + return $this->modify(intval($value) . ' month'); + } + + /** + * Add a month to the instance + * + * @return Carbon + */ + public function addMonth() + { + return $this->addMonths(1); + } + + /** + * Remove a month from the instance + * + * @return Carbon + */ + public function subMonth() + { + return $this->addMonths(-1); + } + + /** + * Remove months from the instance + * + * @param integer $value + * + * @return Carbon + */ + public function subMonths($value) + { + return $this->addMonths(-1 * $value); + } + + /** + * Add days to the instance. Positive $value travels forward while + * negative $value travels into the past. + * + * @param integer $value + * + * @return Carbon + */ + public function addDays($value) + { + return $this->modify(intval($value) . ' day'); + } + + /** + * Add a day to the instance + * + * @return Carbon + */ + public function addDay() + { + return $this->addDays(1); + } + + /** + * Remove a day from the instance + * + * @return Carbon + */ + public function subDay() + { + return $this->addDays(-1); + } + + /** + * Remove days from the instance + * + * @param integer $value + * + * @return Carbon + */ + public function subDays($value) + { + return $this->addDays(-1 * $value); + } + + /** + * Add weekdays to the instance. Positive $value travels forward while + * negative $value travels into the past. + * + * @param integer $value + * + * @return Carbon + */ + public function addWeekdays($value) + { + return $this->modify(intval($value) . ' weekday'); + } + + /** + * Add a weekday to the instance + * + * @return Carbon + */ + public function addWeekday() + { + return $this->addWeekdays(1); + } + + /** + * Remove a weekday from the instance + * + * @return Carbon + */ + public function subWeekday() + { + return $this->addWeekdays(-1); + } + + /** + * Remove weekdays from the instance + * + * @param integer $value + * + * @return Carbon + */ + public function subWeekdays($value) + { + return $this->addWeekdays(-1 * $value); + } + + /** + * Add weeks to the instance. Positive $value travels forward while + * negative $value travels into the past. + * + * @param integer $value + * + * @return Carbon + */ + public function addWeeks($value) + { + return $this->modify(intval($value) . ' week'); + } + + /** + * Add a week to the instance + * + * @return Carbon + */ + public function addWeek() + { + return $this->addWeeks(1); + } + + /** + * Remove a week from the instance + * + * @return Carbon + */ + public function subWeek() + { + return $this->addWeeks(-1); + } + + /** + * Remove weeks to the instance + * + * @param integer $value + * + * @return Carbon + */ + public function subWeeks($value) + { + return $this->addWeeks(-1 * $value); + } + + /** + * Add hours to the instance. Positive $value travels forward while + * negative $value travels into the past. + * + * @param integer $value + * + * @return Carbon + */ + public function addHours($value) + { + return $this->modify(intval($value) . ' hour'); + } + + /** + * Add an hour to the instance + * + * @return Carbon + */ + public function addHour() + { + return $this->addHours(1); + } + + /** + * Remove an hour from the instance + * + * @return Carbon + */ + public function subHour() + { + return $this->addHours(-1); + } + + /** + * Remove hours from the instance + * + * @param integer $value + * + * @return Carbon + */ + public function subHours($value) + { + return $this->addHours(-1 * $value); + } + + /** + * Add minutes to the instance. Positive $value travels forward while + * negative $value travels into the past. + * + * @param integer $value + * + * @return Carbon + */ + public function addMinutes($value) + { + return $this->modify(intval($value) . ' minute'); + } + + /** + * Add a minute to the instance + * + * @return Carbon + */ + public function addMinute() + { + return $this->addMinutes(1); + } + + /** + * Remove a minute from the instance + * + * @return Carbon + */ + public function subMinute() + { + return $this->addMinutes(-1); + } + + /** + * Remove minutes from the instance + * + * @param integer $value + * + * @return Carbon + */ + public function subMinutes($value) + { + return $this->addMinutes(-1 * $value); + } + + /** + * Add seconds to the instance. Positive $value travels forward while + * negative $value travels into the past. + * + * @param integer $value + * + * @return Carbon + */ + public function addSeconds($value) + { + return $this->modify(intval($value) . ' second'); + } + + /** + * Add a second to the instance + * + * @return Carbon + */ + public function addSecond() + { + return $this->addSeconds(1); + } + + /** + * Remove a second from the instance + * + * @return Carbon + */ + public function subSecond() + { + return $this->addSeconds(-1); + } + + /** + * Remove seconds from the instance + * + * @param integer $value + * + * @return Carbon + */ + public function subSeconds($value) + { + return $this->addSeconds(-1 * $value); + } + + /////////////////////////////////////////////////////////////////// + /////////////////////////// DIFFERENCES /////////////////////////// + /////////////////////////////////////////////////////////////////// + + /** + * Get the difference in years + * + * @param Carbon $dt + * @param boolean $abs Get the absolute of the difference + * + * @return integer + */ + public function diffInYears(Carbon $dt = null, $abs = true) + { + $dt = ($dt === null) ? static::now($this->tz) : $dt; + + return intval($this->diff($dt, $abs)->format('%r%y')); + } + + /** + * Get the difference in months + * + * @param Carbon $dt + * @param boolean $abs Get the absolute of the difference + * + * @return integer + */ + public function diffInMonths(Carbon $dt = null, $abs = true) + { + $dt = ($dt === null) ? static::now($this->tz) : $dt; + + return $this->diffInYears($dt, $abs) * self::MONTHS_PER_YEAR + $this->diff($dt, $abs)->format('%r%m'); + } + + /** + * Get the difference in days + * + * @param Carbon $dt + * @param boolean $abs Get the absolute of the difference + * + * @return integer + */ + public function diffInDays(Carbon $dt = null, $abs = true) + { + $dt = ($dt === null) ? static::now($this->tz) : $dt; + + return intval($this->diff($dt, $abs)->format('%r%a')); + } + + /** + * Get the difference in hours + * + * @param Carbon $dt + * @param boolean $abs Get the absolute of the difference + * + * @return integer + */ + public function diffInHours(Carbon $dt = null, $abs = true) + { + $dt = ($dt === null) ? static::now($this->tz) : $dt; + + return intval($this->diffInMinutes($dt, $abs) / self::MINUTES_PER_HOUR); + } + + /** + * Get the difference in minutes + * + * @param Carbon $dt + * @param boolean $abs Get the absolute of the difference + * + * @return integer + */ + public function diffInMinutes(Carbon $dt = null, $abs = true) + { + $dt = ($dt === null) ? static::now($this->tz) : $dt; + + return intval($this->diffInSeconds($dt, $abs) / self::SECONDS_PER_MINUTE); + } + + /** + * Get the difference in seconds + * + * @param Carbon $dt + * @param boolean $abs Get the absolute of the difference + * + * @return integer + */ + public function diffInSeconds(Carbon $dt = null, $abs = true) + { + $dt = ($dt === null) ? static::now($this->tz) : $dt; + + $value = $dt->getTimestamp() - $this->getTimestamp(); + + return $abs ? abs($value) : $value; + } + + /** + * Get the difference in a human readable format. + * + * When comparing a value in the past to default now: + * 1 hour ago + * 5 months ago + * + * When comparing a value in the future to default now: + * 1 hour from now + * 5 months from now + * + * When comparing a value in the past to another value: + * 1 hour before + * 5 months before + * + * When comparing a value in the future to another value: + * 1 hour after + * 5 months after + * + * @param Carbon $other + * + * @return string + */ + public function diffForHumans(Carbon $other = null) + { + $isNow = $other === null; + + if ($isNow) { + $other = static::now($this->tz); + } + + $isFuture = $this->gt($other); + + $delta = $other->diffInSeconds($this); + + // 4 weeks per month, 365 days per year... good enough!! + $divs = array( + 'second' => self::SECONDS_PER_MINUTE, + 'minute' => self::MINUTES_PER_HOUR, + 'hour' => self::HOURS_PER_DAY, + 'day' => self::DAYS_PER_WEEK, + 'week' => 4, + 'month' => self::MONTHS_PER_YEAR + ); + + $unit = 'year'; + + foreach ($divs as $divUnit => $divValue) { + if ($delta < $divValue) { + $unit = $divUnit; + break; + } + + $delta = floor($delta / $divValue); + } + + if ($delta == 0) { + $delta = 1; + } + + $txt = $delta . ' ' . $unit; + $txt .= $delta == 1 ? '' : 's'; + + if ($isNow) { + if ($isFuture) { + return $txt . ' from now'; + } + + return $txt . ' ago'; + } + + if ($isFuture) { + return $txt . ' after'; + } + + return $txt . ' before'; + } + + /////////////////////////////////////////////////////////////////// + //////////////////////////// MODIFIERS //////////////////////////// + /////////////////////////////////////////////////////////////////// + + /** + * Resets the time to 00:00:00 + * + * @return Carbon + */ + public function startOfDay() + { + return $this->hour(0)->minute(0)->second(0); + } + + /** + * Resets the time to 23:59:59 + * + * @return Carbon + */ + public function endOfDay() + { + return $this->hour(23)->minute(59)->second(59); + } + + /** + * Resets the date to the first day of the month and the time to 00:00:00 + * + * @return Carbon + */ + public function startOfMonth() + { + return $this->startOfDay()->day(1); + } + + /** + * Resets the date to end of the month and time to 23:59:59 + * + * @return Carbon + */ + public function endOfMonth() + { + return $this->day($this->daysInMonth)->endOfDay(); + } + + /** + * Resets the date to the first day of the year and the time to 00:00:00 + * + * @return Carbon + */ + public function startOfYear() + { + return $this->month(1)->startOfMonth(); + } + + /** + * Resets the date to end of the year and time to 23:59:59 + * + * @return Carbon + */ + public function endOfYear() + { + return $this->month(self::MONTHS_PER_YEAR)->endOfMonth(); + } + + /** + * Resets the date to the first day of the decade and the time to 00:00:00 + * + * @return Carbon + */ + public function startOfDecade() + { + return $this->startOfYear()->year($this->year - $this->year % 10); + } + + /** + * Resets the date to end of the decade and time to 23:59:59 + * + * @return Carbon + */ + public function endOfDecade() + { + return $this->endOfYear()->year($this->year - $this->year % 10 + 9); + } + + + /** + * Resets the date to the first day of the century and the time to 00:00:00 + * + * @return Carbon + */ + public function startOfCentury() + { + return $this->startOfYear()->year($this->year - $this->year % 100); + } + + /** + * Resets the date to end of the century and time to 23:59:59 + * + * @return Carbon + */ + public function endOfCentury() + { + return $this->endOfYear()->year($this->year - $this->year % 100 + 99); + } + + /** + * Resets the date to the first day of the ISO-8601 week (Monday) and the time to 00:00:00 + * + * @return Carbon + */ + public function startOfWeek() + { + if ($this->dayOfWeek != self::MONDAY) $this->previous(self::MONDAY); + + return $this->startOfDay(); + } + + /** + * Resets the date to end of the ISO-8601 week (Sunday) and time to 23:59:59 + * + * @return Carbon + */ + public function endOfWeek() + { + if ($this->dayOfWeek != self::SUNDAY) $this->next(self::SUNDAY); + + return $this->endOfDay(); + } + + /** + * Modify to the next occurance of a given day of the week. + * If no dayOfWeek is provided, modify to the next occurance + * of the current day of the week. Use the supplied consts + * to indicate the desired dayOfWeek, ex. static::MONDAY. + * + * @param int $dayOfWeek + * + * @return mixed + */ + public function next($dayOfWeek = null) + { + $this->startOfDay(); + + if ($dayOfWeek === null) { + $dayOfWeek = $this->dayOfWeek; + } + + return $this->modify('next ' . self::$days[$dayOfWeek]); + } + + /** + * Modify to the previous occurance of a given day of the week. + * If no dayOfWeek is provided, modify to the previous occurance + * of the current day of the week. Use the supplied consts + * to indicate the desired dayOfWeek, ex. static::MONDAY. + * + * @param int $dayOfWeek + * + * @return mixed + */ + public function previous($dayOfWeek = null) + { + $this->startOfDay(); + + if ($dayOfWeek === null) { + $dayOfWeek = $this->dayOfWeek; + } + + return $this->modify('last ' . self::$days[$dayOfWeek]); + } + + /** + * Modify to the first occurance of a given day of the week + * in the current month. If no dayOfWeek is provided, modify to the + * first day of the current month. Use the supplied consts + * to indicate the desired dayOfWeek, ex. static::MONDAY. + * + * @param int $dayOfWeek + * + * @return mixed + */ + public function firstOfMonth($dayOfWeek = null) + { + $this->startOfDay(); + + if ($dayOfWeek === null) { + return $this->day(1); + } + + return $this->modify('first ' . self::$days[$dayOfWeek] . ' of ' . $this->format('F') . ' ' . $this->year); + } + + /** + * Modify to the last occurance of a given day of the week + * in the current month. If no dayOfWeek is provided, modify to the + * last day of the current month. Use the supplied consts + * to indicate the desired dayOfWeek, ex. static::MONDAY. + * + * @param int $dayOfWeek + * + * @return mixed + */ + public function lastOfMonth($dayOfWeek = null) + { + $this->startOfDay(); + + if ($dayOfWeek === null) { + return $this->day($this->daysInMonth); + } + + return $this->modify('last ' . self::$days[$dayOfWeek] . ' of ' . $this->format('F') . ' ' . $this->year); + } + + /** + * Modify to the given occurance of a given day of the week + * in the current month. If the calculated occurance is outside the scope + * of the current month, then return false and no modifications are made. + * Use the supplied consts to indicate the desired dayOfWeek, ex. static::MONDAY. + * + * @param int $nth + * @param int $dayOfWeek + * + * @return mixed + */ + public function nthOfMonth($nth, $dayOfWeek) + { + $dt = $this->copy(); + $dt->firstOfMonth(); + $month = $dt->month; + $year = $dt->year; + $dt->modify('+' . $nth . ' ' . self::$days[$dayOfWeek]); + + if ($month !== $dt->month || $year !== $dt->year) { + return false; + } + + return $this->modify($dt); + } + + /** + * Modify to the first occurance of a given day of the week + * in the current quarter. If no dayOfWeek is provided, modify to the + * first day of the current quarter. Use the supplied consts + * to indicate the desired dayOfWeek, ex. static::MONDAY. + * + * @param int $dayOfWeek + * + * @return mixed + */ + public function firstOfQuarter($dayOfWeek = null) + { + $this->month(($this->quarter * 3) - 2); + + return $this->firstOfMonth($dayOfWeek); + } + + /** + * Modify to the last occurance of a given day of the week + * in the current quarter. If no dayOfWeek is provided, modify to the + * last day of the current quarter. Use the supplied consts + * to indicate the desired dayOfWeek, ex. static::MONDAY. + * + * @param int $dayOfWeek + * + * @return mixed + */ + public function lastOfQuarter($dayOfWeek = null) + { + $this->month(($this->quarter * 3)); + + return $this->lastOfMonth($dayOfWeek); + } + + /** + * Modify to the given occurance of a given day of the week + * in the current quarter. If the calculated occurance is outside the scope + * of the current quarter, then return false and no modifications are made. + * Use the supplied consts to indicate the desired dayOfWeek, ex. static::MONDAY. + * + * @param int $nth + * @param int $dayOfWeek + * + * @return mixed + */ + public function nthOfQuarter($nth, $dayOfWeek) + { + $dt = $this->copy(); + $dt->month(($this->quarter * 3)); + $last_month = $dt->month; + $year = $dt->year; + $dt->firstOfQuarter(); + $dt->modify('+' . $nth . ' ' . self::$days[$dayOfWeek]); + + if ($last_month < $dt->month || $year !== $dt->year) { + return false; + } + + return $this->modify($dt); + } + + /** + * Modify to the first occurance of a given day of the week + * in the current year. If no dayOfWeek is provided, modify to the + * first day of the current year. Use the supplied consts + * to indicate the desired dayOfWeek, ex. static::MONDAY. + * + * @param int $dayOfWeek + * + * @return mixed + */ + public function firstOfYear($dayOfWeek = null) + { + $this->month(1); + + return $this->firstOfMonth($dayOfWeek); + } + + /** + * Modify to the last occurance of a given day of the week + * in the current year. If no dayOfWeek is provided, modify to the + * last day of the current year. Use the supplied consts + * to indicate the desired dayOfWeek, ex. static::MONDAY. + * + * @param int $dayOfWeek + * + * @return mixed + */ + public function lastOfYear($dayOfWeek = null) + { + $this->month(self::MONTHS_PER_YEAR); + + return $this->lastOfMonth($dayOfWeek); + } + + /** + * Modify to the given occurance of a given day of the week + * in the current year. If the calculated occurance is outside the scope + * of the current year, then return false and no modifications are made. + * Use the supplied consts to indicate the desired dayOfWeek, ex. static::MONDAY. + * + * @param int $nth + * @param int $dayOfWeek + * + * @return mixed + */ + public function nthOfYear($nth, $dayOfWeek) + { + $dt = $this->copy(); + $year = $dt->year; + $dt->firstOfYear(); + $dt->modify('+' . $nth . ' ' . self::$days[$dayOfWeek]); + + if ($year !== $dt->year) { + return false; + } + + return $this->modify($dt); + } + + /** + * Modify the current instance to the average of a given instance (default now) and the current instance. + * + * @param Carbon $dt + * + * @return Carbon + */ + public function average(Carbon $dt = null) + { + $dt = ($dt === null) ? static::now($this->tz) : $dt; + + return $this->addSeconds(intval($this->diffInSeconds($dt, false) / 2)); + } +} diff --git a/vendor/nesbot/carbon/tests/AddTest.php b/vendor/nesbot/carbon/tests/AddTest.php new file mode 100755 index 0000000..aa6bca0 --- /dev/null +++ b/vendor/nesbot/carbon/tests/AddTest.php @@ -0,0 +1,163 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +use Carbon\Carbon; + +class AddTest extends TestFixture +{ + public function testAddYearsPositive() + { + $this->assertSame(1976, Carbon::createFromDate(1975)->addYears(1)->year); + } + public function testAddYearsZero() + { + $this->assertSame(1975, Carbon::createFromDate(1975)->addYears(0)->year); + } + public function testAddYearsNegative() + { + $this->assertSame(1974, Carbon::createFromDate(1975)->addYears(-1)->year); + } + + public function testAddYear() + { + $this->assertSame(1976, Carbon::createFromDate(1975)->addYear()->year); + } + + public function testAddMonthsPositive() + { + $this->assertSame(1, Carbon::createFromDate(1975, 12)->addMonths(1)->month); + } + public function testAddMonthsZero() + { + $this->assertSame(12, Carbon::createFromDate(1975, 12)->addMonths(0)->month); + } + public function testAddMonthsNegative() + { + $this->assertSame(11, Carbon::createFromDate(1975, 12, 1)->addMonths(-1)->month); + } + + public function testAddMonth() + { + $this->assertSame(1, Carbon::createFromDate(1975, 12)->addMonth()->month); + } + public function testAddMonthWithOverflow() + { + $this->assertSame(3, Carbon::createFromDate(2012, 1, 31)->addMonth()->month); + } + + public function testAddDaysPositive() + { + $this->assertSame(1, Carbon::createFromDate(1975, 5, 31)->addDays(1)->day); + } + public function testAddDaysZero() + { + $this->assertSame(31, Carbon::createFromDate(1975, 5, 31)->addDays(0)->day); + } + public function testAddDaysNegative() + { + $this->assertSame(30, Carbon::createFromDate(1975, 5, 31)->addDays(-1)->day); + } + + public function testAddDay() + { + $this->assertSame(1, Carbon::createFromDate(1975, 5, 31)->addDay()->day); + } + + public function testAddWeekdaysPositive() + { + $this->assertSame(17, Carbon::createFromDate(2012, 1, 4)->addWeekdays(9)->day); + } + public function testAddWeekdaysZero() + { + $this->assertSame(4, Carbon::createFromDate(2012, 1, 4)->addWeekdays(0)->day); + } + public function testAddWeekdaysNegative() + { + $this->assertSame(18, Carbon::createFromDate(2012, 1, 31)->addWeekdays(-9)->day); + } + + public function testAddWeekday() + { + $this->assertSame(9, Carbon::createFromDate(2012, 1, 6)->addWeekday()->day); + } + + public function testAddWeeksPositive() + { + $this->assertSame(28, Carbon::createFromDate(1975, 5, 21)->addWeeks(1)->day); + } + public function testAddWeeksZero() + { + $this->assertSame(21, Carbon::createFromDate(1975, 5, 21)->addWeeks(0)->day); + } + public function testAddWeeksNegative() + { + $this->assertSame(14, Carbon::createFromDate(1975, 5, 21)->addWeeks(-1)->day); + } + + public function testAddWeek() + { + $this->assertSame(28, Carbon::createFromDate(1975, 5, 21)->addWeek()->day); + } + + public function testAddHoursPositive() + { + $this->assertSame(1, Carbon::createFromTime(0)->addHours(1)->hour); + } + public function testAddHoursZero() + { + $this->assertSame(0, Carbon::createFromTime(0)->addHours(0)->hour); + } + public function testAddHoursNegative() + { + $this->assertSame(23, Carbon::createFromTime(0)->addHours(-1)->hour); + } + + public function testAddHour() + { + $this->assertSame(1, Carbon::createFromTime(0)->addHour()->hour); + } + + public function testAddMinutesPositive() + { + $this->assertSame(1, Carbon::createFromTime(0, 0)->addMinutes(1)->minute); + } + public function testAddMinutesZero() + { + $this->assertSame(0, Carbon::createFromTime(0, 0)->addMinutes(0)->minute); + } + public function testAddMinutesNegative() + { + $this->assertSame(59, Carbon::createFromTime(0, 0)->addMinutes(-1)->minute); + } + + public function testAddMinute() + { + $this->assertSame(1, Carbon::createFromTime(0, 0)->addMinute()->minute); + } + + public function testAddSecondsPositive() + { + $this->assertSame(1, Carbon::createFromTime(0, 0, 0)->addSeconds(1)->second); + } + public function testAddSecondsZero() + { + $this->assertSame(0, Carbon::createFromTime(0, 0, 0)->addSeconds(0)->second); + } + public function testAddSecondsNegative() + { + $this->assertSame(59, Carbon::createFromTime(0, 0, 0)->addSeconds(-1)->second); + } + + public function testAddSecond() + { + $this->assertSame(1, Carbon::createFromTime(0, 0, 0)->addSecond()->second); + } +} diff --git a/vendor/nesbot/carbon/tests/ComparisonTest.php b/vendor/nesbot/carbon/tests/ComparisonTest.php new file mode 100755 index 0000000..b1dfd3b --- /dev/null +++ b/vendor/nesbot/carbon/tests/ComparisonTest.php @@ -0,0 +1,168 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +use Carbon\Carbon; + +class ComparisonTest extends TestFixture +{ + public function testEqualToTrue() + { + $this->assertTrue(Carbon::createFromDate(2000, 1, 1)->eq(Carbon::createFromDate(2000, 1, 1))); + } + public function testEqualToFalse() + { + $this->assertFalse(Carbon::createFromDate(2000, 1, 1)->eq(Carbon::createFromDate(2000, 1, 2))); + } + public function testEqualWithTimezoneTrue() + { + $this->assertTrue(Carbon::create(2000, 1, 1, 12, 0, 0, 'America/Toronto')->eq(Carbon::create(2000, 1, 1, 9, 0, 0, 'America/Vancouver'))); + } + public function testEqualWithTimezoneFalse() + { + $this->assertFalse(Carbon::createFromDate(2000, 1, 1, 'America/Toronto')->eq(Carbon::createFromDate(2000, 1, 1, 'America/Vancouver'))); + } + + public function testNotEqualToTrue() + { + $this->assertTrue(Carbon::createFromDate(2000, 1, 1)->ne(Carbon::createFromDate(2000, 1, 2))); + } + public function testNotEqualToFalse() + { + $this->assertFalse(Carbon::createFromDate(2000, 1, 1)->ne(Carbon::createFromDate(2000, 1, 1))); + } + public function testNotEqualWithTimezone() + { + $this->assertTrue(Carbon::createFromDate(2000, 1, 1, 'America/Toronto')->ne(Carbon::createFromDate(2000, 1, 1, 'America/Vancouver'))); + } + + public function testGreaterThanTrue() + { + $this->assertTrue(Carbon::createFromDate(2000, 1, 1)->gt(Carbon::createFromDate(1999, 12, 31))); + } + public function testGreaterThanFalse() + { + $this->assertFalse(Carbon::createFromDate(2000, 1, 1)->gt(Carbon::createFromDate(2000, 1, 2))); + } + public function testGreaterThanWithTimezoneTrue() + { + $dt1 = Carbon::create(2000, 1, 1, 12, 0, 0, 'America/Toronto'); + $dt2 = Carbon::create(2000, 1, 1, 8, 59, 59, 'America/Vancouver'); + $this->assertTrue($dt1->gt($dt2)); + } + public function testGreaterThanWithTimezoneFalse() + { + $dt1 = Carbon::create(2000, 1, 1, 12, 0, 0, 'America/Toronto'); + $dt2 = Carbon::create(2000, 1, 1, 9, 0, 1, 'America/Vancouver'); + $this->assertFalse($dt1->gt($dt2)); + } + + public function testGreaterThanOrEqualTrue() + { + $this->assertTrue(Carbon::createFromDate(2000, 1, 1)->gte(Carbon::createFromDate(1999, 12, 31))); + } + public function testGreaterThanOrEqualTrueEqual() + { + $this->assertTrue(Carbon::createFromDate(2000, 1, 1)->gte(Carbon::createFromDate(2000, 1, 1))); + } + public function testGreaterThanOrEqualFalse() + { + $this->assertFalse(Carbon::createFromDate(2000, 1, 1)->gte(Carbon::createFromDate(2000, 1, 2))); + } + + public function testLessThanTrue() + { + $this->assertTrue(Carbon::createFromDate(2000, 1, 1)->lt(Carbon::createFromDate(2000, 1, 2))); + } + public function testLessThanFalse() + { + $this->assertFalse(Carbon::createFromDate(2000, 1, 1)->lt(Carbon::createFromDate(1999, 12, 31))); + } + + public function testLessThanOrEqualTrue() + { + $this->assertTrue(Carbon::createFromDate(2000, 1, 1)->lte(Carbon::createFromDate(2000, 1, 2))); + } + public function testLessThanOrEqualTrueEqual() + { + $this->assertTrue(Carbon::createFromDate(2000, 1, 1)->lte(Carbon::createFromDate(2000, 1, 1))); + } + public function testLessThanOrEqualFalse() + { + $this->assertFalse(Carbon::createFromDate(2000, 1, 1)->lte(Carbon::createFromDate(1999, 12, 31))); + } + + public function testBetweenEqualTrue() + { + $this->assertTrue(Carbon::createFromDate(2000, 1, 15)->between(Carbon::createFromDate(2000, 1, 1), Carbon::createFromDate(2000, 1, 31), true)); + } + public function testBetweenNotEqualTrue() + { + $this->assertTrue(Carbon::createFromDate(2000, 1, 15)->between(Carbon::createFromDate(2000, 1, 1), Carbon::createFromDate(2000, 1, 31), false)); + } + public function testBetweenEqualFalse() + { + $this->assertFalse(Carbon::createFromDate(1999, 12, 31)->between(Carbon::createFromDate(2000, 1, 1), Carbon::createFromDate(2000, 1, 31), true)); + } + public function testBetweenNotEqualFalse() + { + $this->assertFalse(Carbon::createFromDate(2000, 1, 1)->between(Carbon::createFromDate(2000, 1, 1), Carbon::createFromDate(2000, 1, 31), false)); + } + public function testBetweenEqualSwitchTrue() + { + $this->assertTrue(Carbon::createFromDate(2000, 1, 15)->between(Carbon::createFromDate(2000, 1, 31), Carbon::createFromDate(2000, 1, 1), true)); + } + public function testBetweenNotEqualSwitchTrue() + { + $this->assertTrue(Carbon::createFromDate(2000, 1, 15)->between(Carbon::createFromDate(2000, 1, 31), Carbon::createFromDate(2000, 1, 1), false)); + } + public function testBetweenEqualSwitchFalse() + { + $this->assertFalse(Carbon::createFromDate(1999, 12, 31)->between(Carbon::createFromDate(2000, 1, 31), Carbon::createFromDate(2000, 1, 1), true)); + } + public function testBetweenNotEqualSwitchFalse() + { + $this->assertFalse(Carbon::createFromDate(2000, 1, 1)->between(Carbon::createFromDate(2000, 1, 31), Carbon::createFromDate(2000, 1, 1), false)); + } + + public function testMinIsFluid() + { + $dt = Carbon::now(); + $this->assertTrue($dt->min() instanceof Carbon); + } + public function testMinWithNow() + { + $dt = Carbon::create(2012, 1, 1, 0, 0, 0)->min(); + $this->assertCarbon($dt, 2012, 1, 1, 0, 0, 0); + } + public function testMinWithInstance() + { + $dt1 = Carbon::create(2013, 12, 31, 23, 59, 59); + $dt2 = Carbon::create(2012, 1, 1, 0, 0, 0)->min($dt1); + $this->assertCarbon($dt2, 2012, 1, 1, 0, 0, 0); + } + + public function testMaxIsFluid() + { + $dt = Carbon::now(); + $this->assertTrue($dt->max() instanceof Carbon); + } + public function testMaxWithNow() + { + $dt = Carbon::create(2099, 12, 31, 23, 59, 59)->max(); + $this->assertCarbon($dt, 2099, 12, 31, 23, 59, 59); + } + public function testMaxWithInstance() + { + $dt1 = Carbon::create(2012, 1, 1, 0, 0, 0); + $dt2 = Carbon::create(2099, 12, 31, 23, 59, 59)->max($dt1); + $this->assertCarbon($dt2, 2099, 12, 31, 23, 59, 59); + } +} diff --git a/vendor/nesbot/carbon/tests/ConstructTest.php b/vendor/nesbot/carbon/tests/ConstructTest.php new file mode 100755 index 0000000..a78a0c0 --- /dev/null +++ b/vendor/nesbot/carbon/tests/ConstructTest.php @@ -0,0 +1,100 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +use Carbon\Carbon; + +class ConstructTest extends TestFixture +{ + public function testCreatesAnInstanceDefaultToNow() + { + $c = new Carbon(); + $now = Carbon::now(); + $this->assertEquals('Carbon\Carbon', get_class($c)); + $this->assertEquals($now->tzName, $c->tzName); + $this->assertCarbon($c, $now->year, $now->month, $now->day, $now->hour, $now->minute, $now->second); + } + public function testParseCreatesAnInstanceDefaultToNow() + { + $c = Carbon::parse(); + $now = Carbon::now(); + $this->assertEquals('Carbon\Carbon', get_class($c)); + $this->assertEquals($now->tzName, $c->tzName); + $this->assertCarbon($c, $now->year, $now->month, $now->day, $now->hour, $now->minute, $now->second); + } + + public function testWithFancyString() + { + $c = new Carbon('first day of January 2008'); + $this->assertCarbon($c, 2008, 1, 1, 0, 0, 0); + } + public function testParseWithFancyString() + { + $c = Carbon::parse('first day of January 2008'); + $this->assertCarbon($c, 2008, 1, 1, 0, 0, 0); + } + + public function testDefaultTimezone() + { + $c = new Carbon('now'); + $this->assertSame('America/Toronto', $c->tzName); + } + public function testParseWithDefaultTimezone() + { + $c = Carbon::parse('now'); + $this->assertSame('America/Toronto', $c->tzName); + } + + public function testSettingTimezone() + { + $timezone = 'Europe/London'; + $dtz = new \DateTimeZone($timezone); + $dt = new \DateTime('now', $dtz); + $dayLightSavingTimeOffset = $dt->format('I'); + + $c = new Carbon('now', $dtz); + $this->assertSame($timezone, $c->tzName); + $this->assertSame(0 + $dayLightSavingTimeOffset, $c->offsetHours); + } + public function testParseSettingTimezone() + { + $timezone = 'Europe/London'; + $dtz = new \DateTimeZone($timezone); + $dt = new \DateTime('now', $dtz); + $dayLightSavingTimeOffset = $dt->format('I'); + + $c = Carbon::parse('now', $dtz); + $this->assertSame($timezone, $c->tzName); + $this->assertSame(0 + $dayLightSavingTimeOffset, $c->offsetHours); + } + + public function testSettingTimezoneWithString() + { + $timezone = 'Asia/Tokyo'; + $dtz = new \DateTimeZone($timezone); + $dt = new \DateTime('now', $dtz); + $dayLightSavingTimeOffset = $dt->format('I'); + + $c = new Carbon('now', $timezone); + $this->assertSame($timezone, $c->tzName); + $this->assertSame(9 + $dayLightSavingTimeOffset, $c->offsetHours); + } + public function testParseSettingTimezoneWithString() + { + $timezone = 'Asia/Tokyo'; + $dtz = new \DateTimeZone($timezone); + $dt = new \DateTime('now', $dtz); + $dayLightSavingTimeOffset = $dt->format('I'); + + $c = Carbon::parse('now', $timezone); + $this->assertSame($timezone, $c->tzName); + $this->assertSame(9 + $dayLightSavingTimeOffset, $c->offsetHours); + } +} diff --git a/vendor/nesbot/carbon/tests/CopyTest.php b/vendor/nesbot/carbon/tests/CopyTest.php new file mode 100755 index 0000000..cf2c723 --- /dev/null +++ b/vendor/nesbot/carbon/tests/CopyTest.php @@ -0,0 +1,30 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +use Carbon\Carbon; + +class CopyTest extends TestFixture +{ + public function testCopy() + { + $dating = Carbon::now(); + $dating2 = $dating->copy(); + $this->assertNotSame($dating, $dating2); + } + + public function testCopyEnsureTzIsCopied() + { + $dating = Carbon::createFromDate(2000, 1, 1, 'Europe/London'); + $dating2 = $dating->copy(); + $this->assertSame($dating->tzName, $dating2->tzName); + $this->assertSame($dating->offset, $dating2->offset); + } +} diff --git a/vendor/nesbot/carbon/tests/CreateFromDateTest.php b/vendor/nesbot/carbon/tests/CreateFromDateTest.php new file mode 100755 index 0000000..f8ebbc0 --- /dev/null +++ b/vendor/nesbot/carbon/tests/CreateFromDateTest.php @@ -0,0 +1,59 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +use Carbon\Carbon; + +class CreateFromDateTest extends TestFixture +{ + public function testCreateFromDateWithDefaults() + { + $d = Carbon::createFromDate(); + $this->assertSame($d->timestamp, Carbon::create(null, null, null, null, null, null)->timestamp); + } + + public function testCreateFromDate() + { + $d = Carbon::createFromDate(1975, 5, 21); + $this->assertCarbon($d, 1975, 5, 21); + } + + public function testCreateFromDateWithYear() + { + $d = Carbon::createFromDate(1975); + $this->assertSame(1975, $d->year); + } + + public function testCreateFromDateWithMonth() + { + $d = Carbon::createFromDate(null, 5); + $this->assertSame(5, $d->month); + } + + public function testCreateFromDateWithDay() + { + $d = Carbon::createFromDate(null, null, 21); + $this->assertSame(21, $d->day); + } + + public function testCreateFromDateWithTimezone() + { + $d = Carbon::createFromDate(1975, 5, 21, 'Europe/London'); + $this->assertCarbon($d, 1975, 5, 21); + $this->assertSame('Europe/London', $d->tzName); + } + + public function testCreateFromDateWithDateTimeZone() + { + $d = Carbon::createFromDate(1975, 5, 21, new \DateTimeZone('Europe/London')); + $this->assertCarbon($d, 1975, 5, 21); + $this->assertSame('Europe/London', $d->tzName); + } +} diff --git a/vendor/nesbot/carbon/tests/CreateFromFormatTest.php b/vendor/nesbot/carbon/tests/CreateFromFormatTest.php new file mode 100755 index 0000000..9cc69ec --- /dev/null +++ b/vendor/nesbot/carbon/tests/CreateFromFormatTest.php @@ -0,0 +1,36 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +use Carbon\Carbon; + +class CreateFromFormatTest extends TestFixture +{ + public function testCreateFromFormatReturnsCarbon() + { + $d = Carbon::createFromFormat('Y-m-d H:i:s', '1975-05-21 22:32:11'); + $this->assertCarbon($d, 1975, 5, 21, 22, 32, 11); + $this->assertTrue($d instanceof Carbon); + } + + public function testCreateFromFormatWithTimezoneString() + { + $d = Carbon::createFromFormat('Y-m-d H:i:s', '1975-05-21 22:32:11', 'Europe/London'); + $this->assertCarbon($d, 1975, 5, 21, 22, 32, 11); + $this->assertSame('Europe/London', $d->tzName); + } + + public function testCreateFromFormatWithTimezone() + { + $d = Carbon::createFromFormat('Y-m-d H:i:s', '1975-05-21 22:32:11', new \DateTimeZone('Europe/London')); + $this->assertCarbon($d, 1975, 5, 21, 22, 32, 11); + $this->assertSame('Europe/London', $d->tzName); + } +} diff --git a/vendor/nesbot/carbon/tests/CreateFromTimeTest.php b/vendor/nesbot/carbon/tests/CreateFromTimeTest.php new file mode 100755 index 0000000..c2b9b56 --- /dev/null +++ b/vendor/nesbot/carbon/tests/CreateFromTimeTest.php @@ -0,0 +1,60 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +use Carbon\Carbon; + +class CreateFromTimeTest extends TestFixture +{ + public function testCreateFromDateWithDefaults() + { + $d = Carbon::createFromTime(); + $this->assertSame($d->timestamp, Carbon::create(null, null, null, null, null, null)->timestamp); + } + + public function testCreateFromDate() + { + $d = Carbon::createFromTime(23, 5, 21); + $this->assertCarbon($d, Carbon::now()->year, Carbon::now()->month, Carbon::now()->day, 23, 5, 21); + } + + public function testCreateFromTimeWithHour() + { + $d = Carbon::createFromTime(22); + $this->assertSame(22, $d->hour); + $this->assertSame(0, $d->minute); + $this->assertSame(0, $d->second); + } + + public function testCreateFromTimeWithMinute() + { + $d = Carbon::createFromTime(null, 5); + $this->assertSame(5, $d->minute); + } + + public function testCreateFromTimeWithSecond() + { + $d = Carbon::createFromTime(null, null, 21); + $this->assertSame(21, $d->second); + } + + public function testCreateFromTimeWithDateTimeZone() + { + $d = Carbon::createFromTime(12, 0, 0, new \DateTimeZone('Europe/London')); + $this->assertCarbon($d, Carbon::now()->year, Carbon::now()->month, Carbon::now()->day, 12, 0, 0); + $this->assertSame('Europe/London', $d->tzName); + } + public function testCreateFromTimeWithTimeZoneString() + { + $d = Carbon::createFromTime(12, 0, 0, 'Europe/London'); + $this->assertCarbon($d, Carbon::now()->year, Carbon::now()->month, Carbon::now()->day, 12, 0, 0); + $this->assertSame('Europe/London', $d->tzName); + } +} diff --git a/vendor/nesbot/carbon/tests/CreateFromTimestampTest.php b/vendor/nesbot/carbon/tests/CreateFromTimestampTest.php new file mode 100755 index 0000000..b5a54ce --- /dev/null +++ b/vendor/nesbot/carbon/tests/CreateFromTimestampTest.php @@ -0,0 +1,51 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +use Carbon\Carbon; + +class CreateFromTimestampTest extends TestFixture +{ + public function testCreateReturnsDatingInstance() + { + $d = Carbon::createFromTimestamp(Carbon::create(1975, 5, 21, 22, 32, 5)->timestamp); + $this->assertCarbon($d, 1975, 5, 21, 22, 32, 5); + } + + public function testCreateFromTimestampUsesDefaultTimezone() + { + $d = Carbon::createFromTimestamp(0); + + // We know Toronto is -5 since no DST in Jan + $this->assertSame(1969, $d->year); + $this->assertSame(-5 * 3600, $d->offset); + } + + public function testCreateFromTimestampWithDateTimeZone() + { + $d = Carbon::createFromTimestamp(0, new \DateTimeZone('UTC')); + $this->assertSame('UTC', $d->tzName); + $this->assertCarbon($d, 1970, 1, 1, 0, 0, 0); + } + public function testCreateFromTimestampWithString() + { + $d = Carbon::createFromTimestamp(0, 'UTC'); + $this->assertCarbon($d, 1970, 1, 1, 0, 0, 0); + $this->assertTrue($d->offset === 0); + $this->assertSame('UTC', $d->tzName); + } + + public function testCreateFromTimestampGMTDoesNotUseDefaultTimezone() + { + $d = Carbon::createFromTimestampUTC(0); + $this->assertCarbon($d, 1970, 1, 1, 0, 0, 0); + $this->assertTrue($d->offset === 0); + } +} diff --git a/vendor/nesbot/carbon/tests/CreateTest.php b/vendor/nesbot/carbon/tests/CreateTest.php new file mode 100755 index 0000000..c79d4bd --- /dev/null +++ b/vendor/nesbot/carbon/tests/CreateTest.php @@ -0,0 +1,133 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +use Carbon\Carbon; + +class CreateTest extends TestFixture +{ + public function testCreateReturnsDatingInstance() + { + $d = Carbon::create(); + $this->assertTrue($d instanceof Carbon); + } + + public function testCreateWithDefaults() + { + $d = Carbon::create(); + $this->assertSame($d->timestamp, Carbon::now()->timestamp); + } + + public function testCreateWithYear() + { + $d = Carbon::create(2012); + $this->assertSame(2012, $d->year); + } + public function testCreateWithInvalidYear() + { + $this->setExpectedException('InvalidArgumentException'); + $d = Carbon::create(-3); + } + + public function testCreateWithMonth() + { + $d = Carbon::create(null, 3); + $this->assertSame(3, $d->month); + } + public function testCreateWithInvalidMonth() + { + $this->setExpectedException('InvalidArgumentException'); + $d = Carbon::create(null, -5); + } + public function testCreateMonthWraps() + { + $d = Carbon::create(2011, 0, 1, 0, 0, 0); + $this->assertCarbon($d, 2010, 12, 1, 0, 0, 0); + } + + public function testCreateWithDay() + { + $d = Carbon::create(null, null, 21); + $this->assertSame(21, $d->day); + } + public function testCreateWithInvalidDay() + { + $this->setExpectedException('InvalidArgumentException'); + $d = Carbon::create(null, null, -4); + } + public function testCreateDayWraps() + { + $d = Carbon::create(2011, 1, 40, 0, 0, 0); + $this->assertCarbon($d, 2011, 2, 9, 0, 0, 0); + } + + public function testCreateWithHourAndDefaultMinSecToZero() + { + $d = Carbon::create(null, null, null, 14); + $this->assertSame(14, $d->hour); + $this->assertSame(0, $d->minute); + $this->assertSame(0, $d->second); + } + public function testCreateWithInvalidHour() + { + $this->setExpectedException('InvalidArgumentException'); + $d = Carbon::create(null, null, null, -1); + } + public function testCreateHourWraps() + { + $d = Carbon::create(2011, 1, 1, 24, 0, 0); + $this->assertCarbon($d, 2011, 1, 2, 0, 0, 0); + } + + public function testCreateWithMinute() + { + $d = Carbon::create(null, null, null, null, 58); + $this->assertSame(58, $d->minute); + } + public function testCreateWithInvalidMinute() + { + $this->setExpectedException('InvalidArgumentException'); + $d = Carbon::create(2011, 1, 1, 0, -2, 0); + } + public function testCreateMinuteWraps() + { + $d = Carbon::create(2011, 1, 1, 0, 62, 0); + $this->assertCarbon($d, 2011, 1, 1, 1, 2, 0); + } + + public function testCreateWithSecond() + { + $d = Carbon::create(null, null, null, null, null, 59); + $this->assertSame(59, $d->second); + } + public function testCreateWithInvalidSecond() + { + $this->setExpectedException('InvalidArgumentException'); + $d = Carbon::create(null, null, null, null, null, -2); + } + public function testCreateSecondsWrap() + { + $d = Carbon::create(2012, 1, 1, 0, 0, 61); + $this->assertCarbon($d, 2012, 1, 1, 0, 1, 1); + } + + public function testCreateWithDateTimeZone() + { + $d = Carbon::create(2012, 1, 1, 0, 0, 0, new \DateTimeZone('Europe/London')); + $this->assertCarbon($d, 2012, 1, 1, 0, 0, 0); + $this->assertSame('Europe/London', $d->tzName); + } + public function testCreateWithTimeZoneString() + { + $d = Carbon::create(2012, 1, 1, 0, 0, 0, 'Europe/London'); + $this->assertCarbon($d, 2012, 1, 1, 0, 0, 0); + $this->assertSame('Europe/London', $d->tzName); + } +} diff --git a/vendor/nesbot/carbon/tests/DayOfWeekModifiersTest.php b/vendor/nesbot/carbon/tests/DayOfWeekModifiersTest.php new file mode 100755 index 0000000..668c3f5 --- /dev/null +++ b/vendor/nesbot/carbon/tests/DayOfWeekModifiersTest.php @@ -0,0 +1,268 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +use Carbon\Carbon; + +class DayOfWeekModifiersTest extends TestFixture +{ + public function testStartOfWeek() + { + $d = Carbon::create(1980, 8, 7, 12, 11, 9)->startOfWeek(); + $this->assertCarbon($d, 1980, 8, 4, 0, 0, 0); + } + + public function testStartOfWeekFromWeekStart() + { + $d = Carbon::createFromDate(1980, 8, 4)->startOfWeek(); + $this->assertCarbon($d, 1980, 8, 4, 0, 0, 0); + } + + public function testStartOfWeekCrossingYearBoundary() { + $d = Carbon::createFromDate(2013, 12, 31, 'GMT'); + $d->startOfWeek(); + $this->assertCarbon($d, 2013, 12, 30, 0, 0, 0); + } + + public function testEndOfWeek() + { + $d = Carbon::create(1980, 8, 7, 11, 12, 13)->endOfWeek(); + $this->assertCarbon($d, 1980, 8, 10, 23, 59, 59); + } + + public function testEndOfWeekFromWeekEnd() + { + $d = Carbon::createFromDate(1980, 8, 9)->endOfWeek(); + $this->assertCarbon($d, 1980, 8, 10, 23, 59, 59); + } + + public function testEndOfWeekCrossingYearBoundary() { + $d = Carbon::createFromDate(2013, 12, 31, 'GMT'); + $d->endOfWeek(); + $this->assertCarbon($d, 2014, 1, 5, 23, 59, 59); + } + + public function testNext() + { + $d = Carbon::createFromDate(1975, 5, 21)->next(); + $this->assertCarbon($d, 1975, 5, 28, 0, 0, 0); + } + + public function testNextMonday() + { + $d = Carbon::createFromDate(1975, 5, 21)->next(Carbon::MONDAY); + $this->assertCarbon($d, 1975, 5, 26, 0, 0, 0); + } + + public function testNextSaturday() + { + $d = Carbon::createFromDate(1975, 5, 21)->next(6); + $this->assertCarbon($d, 1975, 5, 24, 0, 0, 0); + } + + public function testNextTimestamp() + { + $d = Carbon::createFromDate(1975, 11, 14)->next(); + $this->assertCarbon($d, 1975, 11, 21, 0, 0, 0); + } + + public function testPrevious() + { + $d = Carbon::createFromDate(1975, 5, 21)->previous(); + $this->assertCarbon($d, 1975, 5, 14, 0, 0, 0); + } + + public function testPreviousMonday() + { + $d = Carbon::createFromDate(1975, 5, 21)->previous(Carbon::MONDAY); + $this->assertCarbon($d, 1975, 5, 19, 0, 0, 0); + } + + public function testPreviousSaturday() + { + $d = Carbon::createFromDate(1975, 5, 21)->previous(6); + $this->assertCarbon($d, 1975, 5, 17, 0, 0, 0); + } + + public function testPreviousTimestamp() + { + $d = Carbon::createFromDate(1975, 11, 28)->previous(); + $this->assertCarbon($d, 1975, 11, 21, 0, 0, 0); + } + + public function testFirstDayOfMonth() + { + $d = Carbon::createFromDate(1975, 11, 21)->firstOfMonth(); + $this->assertCarbon($d, 1975, 11, 1, 0, 0, 0); + } + + public function testFirstWednesdayOfMonth() + { + $d = Carbon::createFromDate(1975, 11, 21)->firstOfMonth(Carbon::WEDNESDAY); + $this->assertCarbon($d, 1975, 11, 5, 0, 0, 0); + } + + public function testFirstFridayOfMonth() + { + $d = Carbon::createFromDate(1975, 11, 21)->firstOfMonth(5); + $this->assertCarbon($d, 1975, 11, 7, 0, 0, 0); + } + + public function testLastDayOfMonth() + { + $d = Carbon::createFromDate(1975, 12, 5)->lastOfMonth(); + $this->assertCarbon($d, 1975, 12, 31, 0, 0, 0); + } + + public function testLastTuesdayOfMonth() + { + $d = Carbon::createFromDate(1975, 12, 1)->lastOfMonth(Carbon::TUESDAY); + $this->assertCarbon($d, 1975, 12, 30, 0, 0, 0); + } + + public function testLastFridayOfMonth() + { + $d = Carbon::createFromDate(1975, 12, 5)->lastOfMonth(5); + $this->assertCarbon($d, 1975, 12, 26, 0, 0, 0); + } + + public function testNthOfMonthOutsideScope() + { + $this->assertFalse(Carbon::createFromDate(1975, 12, 5)->nthOfMonth(6, Carbon::MONDAY)); + } + + public function testNthOfMonthOutsideYear() + { + $this->assertFalse(Carbon::createFromDate(1975, 12, 5)->nthOfMonth(55, Carbon::MONDAY)); + } + + public function test2ndMondayOfMonth() + { + $d = Carbon::createFromDate(1975, 12, 5)->nthOfMonth(2, Carbon::MONDAY); + $this->assertCarbon($d, 1975, 12, 8, 0, 0, 0); + } + + public function test3rdWednesdayOfMonth() + { + $d = Carbon::createFromDate(1975, 12, 5)->nthOfMonth(3, 3); + $this->assertCarbon($d, 1975, 12, 17, 0, 0, 0); + } + + public function testFirstDayOfQuarter() + { + $d = Carbon::createFromDate(1975, 11, 21)->firstOfQuarter(); + $this->assertCarbon($d, 1975, 10, 1, 0, 0, 0); + } + + public function testFirstWednesdayOfQuarter() + { + $d = Carbon::createFromDate(1975, 11, 21)->firstOfQuarter(Carbon::WEDNESDAY); + $this->assertCarbon($d, 1975, 10, 1, 0, 0, 0); + } + + public function testFirstFridayOfQuarter() + { + $d = Carbon::createFromDate(1975, 11, 21)->firstOfQuarter(5); + $this->assertCarbon($d, 1975, 10, 3, 0, 0, 0); + } + + public function testLastDayOfQuarter() + { + $d = Carbon::createFromDate(1975, 8, 5)->lastOfQuarter(); + $this->assertCarbon($d, 1975, 9, 30, 0, 0, 0); + } + + public function testLastTuesdayOfQuarter() + { + $d = Carbon::createFromDate(1975, 8, 1)->lastOfQuarter(Carbon::TUESDAY); + $this->assertCarbon($d, 1975, 9, 30, 0, 0, 0); + } + + public function testLastFridayOfQuarter() + { + $d = Carbon::createFromDate(1975, 7, 5)->lastOfQuarter(5); + $this->assertCarbon($d, 1975, 9, 26, 0, 0, 0); + } + + public function testNthOfQuarterOutsideScope() + { + $this->assertFalse(Carbon::createFromDate(1975, 1, 5)->nthOfQuarter(20, Carbon::MONDAY)); + } + + public function testNthOfQuarterOutsideYear() + { + $this->assertFalse(Carbon::createFromDate(1975, 1, 5)->nthOfQuarter(55, Carbon::MONDAY)); + } + + public function test2ndMondayOfQuarter() + { + $d = Carbon::createFromDate(1975, 8, 5)->nthOfQuarter(2, Carbon::MONDAY); + $this->assertCarbon($d, 1975, 7, 14, 0, 0, 0); + } + + public function test3rdWednesdayOfQuarter() + { + $d = Carbon::createFromDate(1975, 8, 5)->nthOfQuarter(3, 3); + $this->assertCarbon($d, 1975, 7, 16, 0, 0, 0); + } + + public function testFirstDayOfYear() + { + $d = Carbon::createFromDate(1975, 11, 21)->firstOfYear(); + $this->assertCarbon($d, 1975, 1, 1, 0, 0, 0); + } + + public function testFirstWednesdayOfYear() + { + $d = Carbon::createFromDate(1975, 11, 21)->firstOfYear(Carbon::WEDNESDAY); + $this->assertCarbon($d, 1975, 1, 1, 0, 0, 0); + } + + public function testFirstFridayOfYear() + { + $d = Carbon::createFromDate(1975, 11, 21)->firstOfYear(5); + $this->assertCarbon($d, 1975, 1, 3, 0, 0, 0); + } + + public function testLastDayOfYear() + { + $d = Carbon::createFromDate(1975, 8, 5)->lastOfYear(); + $this->assertCarbon($d, 1975, 12, 31, 0, 0, 0); + } + + public function testLastTuesdayOfYear() + { + $d = Carbon::createFromDate(1975, 8, 1)->lastOfYear(Carbon::TUESDAY); + $this->assertCarbon($d, 1975, 12, 30, 0, 0, 0); + } + + public function testLastFridayOfYear() + { + $d = Carbon::createFromDate(1975, 7, 5)->lastOfYear(5); + $this->assertCarbon($d, 1975, 12, 26, 0, 0, 0); + } + + public function testNthOfYearOutsideScope() + { + $this->assertFalse(Carbon::createFromDate(1975, 1, 5)->nthOfYear(55, Carbon::MONDAY)); + } + + public function test2ndMondayOfYear() + { + $d = Carbon::createFromDate(1975, 8, 5)->nthOfYear(2, Carbon::MONDAY); + $this->assertCarbon($d, 1975, 1, 13, 0, 0, 0); + } + + public function test3rdWednesdayOfYear() + { + $d = Carbon::createFromDate(1975, 8, 5)->nthOfYear(3, 3); + $this->assertCarbon($d, 1975, 1, 15, 0, 0, 0); + } +} diff --git a/vendor/nesbot/carbon/tests/DiffTest.php b/vendor/nesbot/carbon/tests/DiffTest.php new file mode 100755 index 0000000..c34c892 --- /dev/null +++ b/vendor/nesbot/carbon/tests/DiffTest.php @@ -0,0 +1,604 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +use Carbon\Carbon; + +class DiffTest extends TestFixture +{ + public function testDiffInYearsPositive() + { + $dt = Carbon::createFromDate(2000, 1, 1); + $this->assertSame(1, $dt->diffInYears($dt->copy()->addYear())); + } + public function testDiffInYearsNegativeWithSign() + { + $dt = Carbon::createFromDate(2000, 1, 1); + $this->assertSame(-1, $dt->diffInYears($dt->copy()->subYear(), false)); + } + public function testDiffInYearsNegativeNoSign() + { + $dt = Carbon::createFromDate(2000, 1, 1); + $this->assertSame(1, $dt->diffInYears($dt->copy()->subYear())); + } + public function testDiffInYearsVsDefaultNow() + { + $this->assertSame(1, Carbon::now()->subYear()->diffInYears()); + } + public function testDiffInYearsEnsureIsTruncated() + { + $dt = Carbon::createFromDate(2000, 1, 1); + $this->assertSame(1, $dt->diffInYears($dt->copy()->addYear()->addMonths(7))); + } + + public function testDiffInMonthsPositive() + { + $dt = Carbon::createFromDate(2000, 1, 1); + $this->assertSame(13, $dt->diffInMonths($dt->copy()->addYear()->addMonth())); + } + public function testDiffInMonthsNegativeWithSign() + { + $dt = Carbon::createFromDate(2000, 1, 1); + $this->assertSame(-11, $dt->diffInMonths($dt->copy()->subYear()->addMonth(), false)); + } + public function testDiffInMonthsNegativeNoSign() + { + $dt = Carbon::createFromDate(2000, 1, 1); + $this->assertSame(11, $dt->diffInMonths($dt->copy()->subYear()->addMonth())); + } + public function testDiffInMonthsVsDefaultNow() + { + $this->assertSame(12, Carbon::now()->subYear()->diffInMonths()); + } + public function testDiffInMonthsEnsureIsTruncated() + { + $dt = Carbon::createFromDate(2000, 1, 1); + $this->assertSame(1, $dt->diffInMonths($dt->copy()->addMonth()->addDays(16))); + } + + public function testDiffInDaysPositive() + { + $dt = Carbon::createFromDate(2000, 1, 1); + $this->assertSame(366, $dt->diffInDays($dt->copy()->addYear())); + } + public function testDiffInDaysNegativeWithSign() + { + $dt = Carbon::createFromDate(2000, 1, 1); + $this->assertSame(-365, $dt->diffInDays($dt->copy()->subYear(), false)); + } + public function testDiffInDaysNegativeNoSign() + { + $dt = Carbon::createFromDate(2000, 1, 1); + $this->assertSame(365, $dt->diffInDays($dt->copy()->subYear())); + } + public function testDiffInDaysVsDefaultNow() + { + $this->assertSame(7, Carbon::now()->subWeek()->diffInDays()); + } + public function testDiffInDaysEnsureIsTruncated() + { + $dt = Carbon::createFromDate(2000, 1, 1); + $this->assertSame(1, $dt->diffInDays($dt->copy()->addDay()->addHours(13))); + } + + public function testDiffInHoursPositive() + { + $dt = Carbon::createFromDate(2000, 1, 1); + $this->assertSame(26, $dt->diffInHours($dt->copy()->addDay()->addHours(2))); + } + public function testDiffInHoursNegativeWithSign() + { + $dt = Carbon::createFromDate(2000, 1, 1); + $this->assertSame(-22, $dt->diffInHours($dt->copy()->subDay()->addHours(2), false)); + } + public function testDiffInHoursNegativeNoSign() + { + $dt = Carbon::createFromDate(2000, 1, 1); + $this->assertSame(22, $dt->diffInHours($dt->copy()->subDay()->addHours(2))); + } + public function testDiffInHoursVsDefaultNow() + { + $this->assertSame(48, Carbon::now()->subDays(2)->diffInHours()); + } + public function testDiffInHoursEnsureIsTruncated() + { + $dt = Carbon::createFromDate(2000, 1, 1); + $this->assertSame(1, $dt->diffInHours($dt->copy()->addHour()->addMinutes(31))); + } + + public function testDiffInMinutesPositive() + { + $dt = Carbon::createFromDate(2000, 1, 1); + $this->assertSame(62, $dt->diffInMinutes($dt->copy()->addHour()->addMinutes(2))); + } + public function testDiffInMinutesPositiveAlot() + { + $dt = Carbon::createFromDate(2000, 1, 1); + $this->assertSame(1502, $dt->diffInMinutes($dt->copy()->addHours(25)->addMinutes(2))); + } + public function testDiffInMinutesNegativeWithSign() + { + $dt = Carbon::createFromDate(2000, 1, 1); + $this->assertSame(-58, $dt->diffInMinutes($dt->copy()->subHour()->addMinutes(2), false)); + } + public function testDiffInMinutesNegativeNoSign() + { + $dt = Carbon::createFromDate(2000, 1, 1); + $this->assertSame(58, $dt->diffInMinutes($dt->copy()->subHour()->addMinutes(2))); + } + public function testDiffInMinutesVsDefaultNow() + { + $this->assertSame(60, Carbon::now()->subHour()->diffInMinutes()); + } + public function testDiffInMinutesEnsureIsTruncated() + { + $dt = Carbon::createFromDate(2000, 1, 1); + $this->assertSame(1, $dt->diffInMinutes($dt->copy()->addMinute()->addSeconds(31))); + } + + public function testDiffInSecondsPositive() + { + $dt = Carbon::createFromDate(2000, 1, 1); + $this->assertSame(62, $dt->diffInSeconds($dt->copy()->addMinute()->addSeconds(2))); + } + public function testDiffInSecondsPositiveAlot() + { + $dt = Carbon::createFromDate(2000, 1, 1); + $this->assertSame(7202, $dt->diffInSeconds($dt->copy()->addHours(2)->addSeconds(2))); + } + public function testDiffInSecondsNegativeWithSign() + { + $dt = Carbon::createFromDate(2000, 1, 1); + $this->assertSame(-58, $dt->diffInSeconds($dt->copy()->subMinute()->addSeconds(2), false)); + } + public function testDiffInSecondsNegativeNoSign() + { + $dt = Carbon::createFromDate(2000, 1, 1); + $this->assertSame(58, $dt->diffInSeconds($dt->copy()->subMinute()->addSeconds(2))); + } + public function testDiffInSecondsVsDefaultNow() + { + $this->assertSame(3600, Carbon::now()->subHour()->diffInSeconds()); + } + public function testDiffInSecondsEnsureIsTruncated() + { + $dt = Carbon::createFromDate(2000, 1, 1); + $this->assertSame(1, $dt->diffInSeconds($dt->copy()->addSeconds(1.9))); + } + + public function testDiffInSecondsWithTimezones() + { + $dtOttawa = Carbon::createFromDate(2000, 1, 1, 'America/Toronto'); + $dtVancouver = Carbon::createFromDate(2000, 1, 1, 'America/Vancouver'); + $this->assertSame(3*60*60, $dtOttawa->diffInSeconds($dtVancouver)); + } + public function testDiffInSecondsWithTimezonesAndVsDefault() + { + $dt = Carbon::now('America/Vancouver'); + $this->assertSame(0, $dt->diffInSeconds()); + } + + public function testDiffForHumansNowAndSecond() + { + $d = Carbon::now(); + $this->assertSame('1 second ago', $d->diffForHumans()); + } + public function testDiffForHumansNowAndSecondWithTimezone() + { + $d = Carbon::now('America/Vancouver'); + $this->assertSame('1 second ago', $d->diffForHumans()); + } + public function testDiffForHumansNowAndSeconds() + { + $d = Carbon::now()->subSeconds(2); + $this->assertSame('2 seconds ago', $d->diffForHumans()); + } + public function testDiffForHumansNowAndNearlyMinute() + { + $d = Carbon::now()->subSeconds(59); + $this->assertSame('59 seconds ago', $d->diffForHumans()); + } + public function testDiffForHumansNowAndMinute() + { + $d = Carbon::now()->subMinute(); + $this->assertSame('1 minute ago', $d->diffForHumans()); + } + public function testDiffForHumansNowAndMinutes() + { + $d = Carbon::now()->subMinutes(2); + $this->assertSame('2 minutes ago', $d->diffForHumans()); + } + public function testDiffForHumansNowAndNearlyHour() + { + $d = Carbon::now()->subMinutes(59); + $this->assertSame('59 minutes ago', $d->diffForHumans()); + } + public function testDiffForHumansNowAndHour() + { + $d = Carbon::now()->subHour(); + $this->assertSame('1 hour ago', $d->diffForHumans()); + } + public function testDiffForHumansNowAndHours() + { + $d = Carbon::now()->subHours(2); + $this->assertSame('2 hours ago', $d->diffForHumans()); + } + public function testDiffForHumansNowAndNearlyDay() + { + $d = Carbon::now()->subHours(23); + $this->assertSame('23 hours ago', $d->diffForHumans()); + } + public function testDiffForHumansNowAndDay() + { + $d = Carbon::now()->subDay(); + $this->assertSame('1 day ago', $d->diffForHumans()); + } + public function testDiffForHumansNowAndDays() + { + $d = Carbon::now()->subDays(2); + $this->assertSame('2 days ago', $d->diffForHumans()); + } + public function testDiffForHumansNowAndNearlyWeek() + { + $d = Carbon::now()->subDays(6); + $this->assertSame('6 days ago', $d->diffForHumans()); + } + public function testDiffForHumansNowAndWeek() + { + $d = Carbon::now()->subWeek(); + $this->assertSame('1 week ago', $d->diffForHumans()); + } + public function testDiffForHumansNowAndWeeks() + { + $d = Carbon::now()->subWeeks(2); + $this->assertSame('2 weeks ago', $d->diffForHumans()); + } + public function testDiffForHumansNowAndNearlyMonth() + { + $d = Carbon::now()->subWeeks(3); + $this->assertSame('3 weeks ago', $d->diffForHumans()); + } + public function testDiffForHumansNowAndMonth() + { + $d = Carbon::now()->subWeeks(4); + $this->assertSame('1 month ago', $d->diffForHumans()); + $d = Carbon::now()->subMonth(); + $this->assertSame('1 month ago', $d->diffForHumans()); + } + public function testDiffForHumansNowAndMonths() + { + $d = Carbon::now()->subMonths(2); + $this->assertSame('2 months ago', $d->diffForHumans()); + } + public function testDiffForHumansNowAndNearlyYear() + { + $d = Carbon::now()->subMonths(11); + $this->assertSame('11 months ago', $d->diffForHumans()); + } + public function testDiffForHumansNowAndYear() + { + $d = Carbon::now()->subYear(); + $this->assertSame('1 year ago', $d->diffForHumans()); + } + public function testDiffForHumansNowAndYears() + { + $d = Carbon::now()->subYears(2); + $this->assertSame('2 years ago', $d->diffForHumans()); + } + + public function testDiffForHumansNowAndFutureSecond() + { + $d = Carbon::now()->addSecond(); + $this->assertSame('1 second from now', $d->diffForHumans()); + } + public function testDiffForHumansNowAndFutureSeconds() + { + $d = Carbon::now()->addSeconds(2); + $this->assertSame('2 seconds from now', $d->diffForHumans()); + } + public function testDiffForHumansNowAndNearlyFutureMinute() + { + $d = Carbon::now()->addSeconds(59); + $this->assertSame('59 seconds from now', $d->diffForHumans()); + } + public function testDiffForHumansNowAndFutureMinute() + { + $d = Carbon::now()->addMinute(); + $this->assertSame('1 minute from now', $d->diffForHumans()); + } + public function testDiffForHumansNowAndFutureMinutes() + { + $d = Carbon::now()->addMinutes(2); + $this->assertSame('2 minutes from now', $d->diffForHumans()); + } + public function testDiffForHumansNowAndNearlyFutureHour() + { + $d = Carbon::now()->addMinutes(59); + $this->assertSame('59 minutes from now', $d->diffForHumans()); + } + public function testDiffForHumansNowAndFutureHour() + { + $d = Carbon::now()->addHour(); + $this->assertSame('1 hour from now', $d->diffForHumans()); + } + public function testDiffForHumansNowAndFutureHours() + { + $d = Carbon::now()->addHours(2); + $this->assertSame('2 hours from now', $d->diffForHumans()); + } + public function testDiffForHumansNowAndNearlyFutureDay() + { + $d = Carbon::now()->addHours(23); + $this->assertSame('23 hours from now', $d->diffForHumans()); + } + public function testDiffForHumansNowAndFutureDay() + { + $d = Carbon::now()->addDay(); + $this->assertSame('1 day from now', $d->diffForHumans()); + } + public function testDiffForHumansNowAndFutureDays() + { + $d = Carbon::now()->addDays(2); + $this->assertSame('2 days from now', $d->diffForHumans()); + } + public function testDiffForHumansNowAndNearlyFutureWeek() + { + $d = Carbon::now()->addDays(6); + $this->assertSame('6 days from now', $d->diffForHumans()); + } + public function testDiffForHumansNowAndFutureWeek() + { + $d = Carbon::now()->addWeek(); + $this->assertSame('1 week from now', $d->diffForHumans()); + } + public function testDiffForHumansNowAndFutureWeeks() + { + $d = Carbon::now()->addWeeks(2); + $this->assertSame('2 weeks from now', $d->diffForHumans()); + } + public function testDiffForHumansNowAndNearlyFutureMonth() + { + $d = Carbon::now()->addWeeks(3); + $this->assertSame('3 weeks from now', $d->diffForHumans()); + } + public function testDiffForHumansNowAndFutureMonth() + { + $d = Carbon::now()->addWeeks(4); + $this->assertSame('1 month from now', $d->diffForHumans()); + $d = Carbon::now()->addMonth(); + $this->assertSame('1 month from now', $d->diffForHumans()); + } + public function testDiffForHumansNowAndFutureMonths() + { + $d = Carbon::now()->addMonths(2); + $this->assertSame('2 months from now', $d->diffForHumans()); + } + public function testDiffForHumansNowAndNearlyFutureYear() + { + $d = Carbon::now()->addMonths(11); + $this->assertSame('11 months from now', $d->diffForHumans()); + } + public function testDiffForHumansNowAndFutureYear() + { + $d = Carbon::now()->addYear(); + $this->assertSame('1 year from now', $d->diffForHumans()); + } + public function testDiffForHumansNowAndFutureYears() + { + $d = Carbon::now()->addYears(2); + $this->assertSame('2 years from now', $d->diffForHumans()); + } + + public function testDiffForHumansOtherAndSecond() + { + $d = Carbon::now()->addSecond(); + $this->assertSame('1 second before', Carbon::now()->diffForHumans($d)); + } + public function testDiffForHumansOtherAndSeconds() + { + $d = Carbon::now()->addSeconds(2); + $this->assertSame('2 seconds before', Carbon::now()->diffForHumans($d)); + } + public function testDiffForHumansOtherAndNearlyMinute() + { + $d = Carbon::now()->addSeconds(59); + $this->assertSame('59 seconds before', Carbon::now()->diffForHumans($d)); + } + public function testDiffForHumansOtherAndMinute() + { + $d = Carbon::now()->addMinute(); + $this->assertSame('1 minute before', Carbon::now()->diffForHumans($d)); + } + public function testDiffForHumansOtherAndMinutes() + { + $d = Carbon::now()->addMinutes(2); + $this->assertSame('2 minutes before', Carbon::now()->diffForHumans($d)); + } + public function testDiffForHumansOtherAndNearlyHour() + { + $d = Carbon::now()->addMinutes(59); + $this->assertSame('59 minutes before', Carbon::now()->diffForHumans($d)); + } + public function testDiffForHumansOtherAndHour() + { + $d = Carbon::now()->addHour(); + $this->assertSame('1 hour before', Carbon::now()->diffForHumans($d)); + } + public function testDiffForHumansOtherAndHours() + { + $d = Carbon::now()->addHours(2); + $this->assertSame('2 hours before', Carbon::now()->diffForHumans($d)); + } + public function testDiffForHumansOtherAndNearlyDay() + { + $d = Carbon::now()->addHours(23); + $this->assertSame('23 hours before', Carbon::now()->diffForHumans($d)); + } + public function testDiffForHumansOtherAndDay() + { + $d = Carbon::now()->addDay(); + $this->assertSame('1 day before', Carbon::now()->diffForHumans($d)); + } + public function testDiffForHumansOtherAndDays() + { + $d = Carbon::now()->addDays(2); + $this->assertSame('2 days before', Carbon::now()->diffForHumans($d)); + } + public function testDiffForHumansOtherAndNearlyWeek() + { + $d = Carbon::now()->addDays(6); + $this->assertSame('6 days before', Carbon::now()->diffForHumans($d)); + } + public function testDiffForHumansOtherAndWeek() + { + $d = Carbon::now()->addWeek(); + $this->assertSame('1 week before', Carbon::now()->diffForHumans($d)); + } + public function testDiffForHumansOtherAndWeeks() + { + $d = Carbon::now()->addWeeks(2); + $this->assertSame('2 weeks before', Carbon::now()->diffForHumans($d)); + } + public function testDiffForHumansOtherAndNearlyMonth() + { + $d = Carbon::now()->addWeeks(3); + $this->assertSame('3 weeks before', Carbon::now()->diffForHumans($d)); + } + public function testDiffForHumansOtherAndMonth() + { + $d = Carbon::now()->addWeeks(4); + $this->assertSame('1 month before', Carbon::now()->diffForHumans($d)); + $d = Carbon::now()->addMonth(); + $this->assertSame('1 month before', Carbon::now()->diffForHumans($d)); + } + public function testDiffForHumansOtherAndMonths() + { + $d = Carbon::now()->addMonths(2); + $this->assertSame('2 months before', Carbon::now()->diffForHumans($d)); + } + public function testDiffForHumansOtherAndNearlyYear() + { + $d = Carbon::now()->addMonths(11); + $this->assertSame('11 months before', Carbon::now()->diffForHumans($d)); + } + public function testDiffForHumansOtherAndYear() + { + $d = Carbon::now()->addYear(); + $this->assertSame('1 year before', Carbon::now()->diffForHumans($d)); + } + public function testDiffForHumansOtherAndYears() + { + $d = Carbon::now()->addYears(2); + $this->assertSame('2 years before', Carbon::now()->diffForHumans($d)); + } + + public function testDiffForHumansOtherAndFutureSecond() + { + $d = Carbon::now()->subSecond(); + $this->assertSame('1 second after', Carbon::now()->diffForHumans($d)); + } + public function testDiffForHumansOtherAndFutureSeconds() + { + $d = Carbon::now()->subSeconds(2); + $this->assertSame('2 seconds after', Carbon::now()->diffForHumans($d)); + } + public function testDiffForHumansOtherAndNearlyFutureMinute() + { + $d = Carbon::now()->subSeconds(59); + $this->assertSame('59 seconds after', Carbon::now()->diffForHumans($d)); + } + public function testDiffForHumansOtherAndFutureMinute() + { + $d = Carbon::now()->subMinute(); + $this->assertSame('1 minute after', Carbon::now()->diffForHumans($d)); + } + public function testDiffForHumansOtherAndFutureMinutes() + { + $d = Carbon::now()->subMinutes(2); + $this->assertSame('2 minutes after', Carbon::now()->diffForHumans($d)); + } + public function testDiffForHumansOtherAndNearlyFutureHour() + { + $d = Carbon::now()->subMinutes(59); + $this->assertSame('59 minutes after', Carbon::now()->diffForHumans($d)); + } + public function testDiffForHumansOtherAndFutureHour() + { + $d = Carbon::now()->subHour(); + $this->assertSame('1 hour after', Carbon::now()->diffForHumans($d)); + } + public function testDiffForHumansOtherAndFutureHours() + { + $d = Carbon::now()->subHours(2); + $this->assertSame('2 hours after', Carbon::now()->diffForHumans($d)); + } + public function testDiffForHumansOtherAndNearlyFutureDay() + { + $d = Carbon::now()->subHours(23); + $this->assertSame('23 hours after', Carbon::now()->diffForHumans($d)); + } + public function testDiffForHumansOtherAndFutureDay() + { + $d = Carbon::now()->subDay(); + $this->assertSame('1 day after', Carbon::now()->diffForHumans($d)); + } + public function testDiffForHumansOtherAndFutureDays() + { + $d = Carbon::now()->subDays(2); + $this->assertSame('2 days after', Carbon::now()->diffForHumans($d)); + } + public function testDiffForHumansOtherAndNearlyFutureWeek() + { + $d = Carbon::now()->subDays(6); + $this->assertSame('6 days after', Carbon::now()->diffForHumans($d)); + } + public function testDiffForHumansOtherAndFutureWeek() + { + $d = Carbon::now()->subWeek(); + $this->assertSame('1 week after', Carbon::now()->diffForHumans($d)); + } + public function testDiffForHumansOtherAndFutureWeeks() + { + $d = Carbon::now()->subWeeks(2); + $this->assertSame('2 weeks after', Carbon::now()->diffForHumans($d)); + } + public function testDiffForHumansOtherAndNearlyFutureMonth() + { + $d = Carbon::now()->subWeeks(3); + $this->assertSame('3 weeks after', Carbon::now()->diffForHumans($d)); + } + public function testDiffForHumansOtherAndFutureMonth() + { + $d = Carbon::now()->subWeeks(4); + $this->assertSame('1 month after', Carbon::now()->diffForHumans($d)); + $d = Carbon::now()->subMonth(); + $this->assertSame('1 month after', Carbon::now()->diffForHumans($d)); + } + public function testDiffForHumansOtherAndFutureMonths() + { + $d = Carbon::now()->subMonths(2); + $this->assertSame('2 months after', Carbon::now()->diffForHumans($d)); + } + public function testDiffForHumansOtherAndNearlyFutureYear() + { + $d = Carbon::now()->subMonths(11); + $this->assertSame('11 months after', Carbon::now()->diffForHumans($d)); + } + public function testDiffForHumansOtherAndFutureYear() + { + $d = Carbon::now()->subYear(); + $this->assertSame('1 year after', Carbon::now()->diffForHumans($d)); + } + public function testDiffForHumansOtherAndFutureYears() + { + $d = Carbon::now()->subYears(2); + $this->assertSame('2 years after', Carbon::now()->diffForHumans($d)); + } +} diff --git a/vendor/nesbot/carbon/tests/FluidSettersTest.php b/vendor/nesbot/carbon/tests/FluidSettersTest.php new file mode 100755 index 0000000..e7176f3 --- /dev/null +++ b/vendor/nesbot/carbon/tests/FluidSettersTest.php @@ -0,0 +1,108 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +use Carbon\Carbon; + +class FluidSettersTest extends TestFixture +{ + public function testFluidYearSetter() + { + $d = Carbon::now(); + $this->assertTrue($d->year(1995) instanceof Carbon); + $this->assertSame(1995, $d->year); + } + + public function testFluidMonthSetter() + { + $d = Carbon::now(); + $this->assertTrue($d->month(3) instanceof Carbon); + $this->assertSame(3, $d->month); + } + public function testFluidMonthSetterWithWrap() + { + $d = Carbon::createFromDate(2012, 8, 21); + $this->assertTrue($d->month(13) instanceof Carbon); + $this->assertSame(1, $d->month); + } + + public function testFluidDaySetter() + { + $d = Carbon::now(); + $this->assertTrue($d->day(2) instanceof Carbon); + $this->assertSame(2, $d->day); + } + public function testFluidDaySetterWithWrap() + { + $d = Carbon::createFromDate(2000, 1, 1); + $this->assertTrue($d->day(32) instanceof Carbon); + $this->assertSame(1, $d->day); + } + + public function testFluidSetDate() + { + $d = Carbon::createFromDate(2000, 1, 1); + $this->assertTrue($d->setDate(1995, 13, 32) instanceof Carbon); + $this->assertCarbon($d, 1996, 2, 1); + } + + public function testFluidHourSetter() + { + $d = Carbon::now(); + $this->assertTrue($d->hour(2) instanceof Carbon); + $this->assertSame(2, $d->hour); + } + public function testFluidHourSetterWithWrap() + { + $d = Carbon::now(); + $this->assertTrue($d->hour(25) instanceof Carbon); + $this->assertSame(1, $d->hour); + } + + public function testFluidMinuteSetter() + { + $d = Carbon::now(); + $this->assertTrue($d->minute(2) instanceof Carbon); + $this->assertSame(2, $d->minute); + } + public function testFluidMinuteSetterWithWrap() + { + $d = Carbon::now(); + $this->assertTrue($d->minute(61) instanceof Carbon); + $this->assertSame(1, $d->minute); + } + + public function testFluidSecondSetter() + { + $d = Carbon::now(); + $this->assertTrue($d->second(2) instanceof Carbon); + $this->assertSame(2, $d->second); + } + public function testFluidSecondSetterWithWrap() + { + $d = Carbon::now(); + $this->assertTrue($d->second(62) instanceof Carbon); + $this->assertSame(2, $d->second); + } + + public function testFluidSetTime() + { + $d = Carbon::createFromDate(2000, 1, 1); + $this->assertTrue($d->setTime(25, 61, 61) instanceof Carbon); + $this->assertCarbon($d, 2000, 1, 2, 2, 2, 1); + } + + public function testFluidTimestampSetter() + { + $d = Carbon::now(); + $this->assertTrue($d->timestamp(10) instanceof Carbon); + $this->assertSame(10, $d->timestamp); + } +} diff --git a/vendor/nesbot/carbon/tests/GettersTest.php b/vendor/nesbot/carbon/tests/GettersTest.php new file mode 100755 index 0000000..212cda0 --- /dev/null +++ b/vendor/nesbot/carbon/tests/GettersTest.php @@ -0,0 +1,228 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +use Carbon\Carbon; + +class GettersTest extends TestFixture +{ + public function testGettersThrowExceptionOnUnknownGetter() + { + $this->setExpectedException('InvalidArgumentException'); + Carbon::create(1234, 5, 6, 7, 8, 9)->sdfsdfss; + } + public function testYearGetter() + { + $d = Carbon::create(1234, 5, 6, 7, 8, 9); + $this->assertSame(1234, $d->year); + } + public function testMonthGetter() + { + $d = Carbon::create(1234, 5, 6, 7, 8, 9); + $this->assertSame(5, $d->month); + } + public function testDayGetter() + { + $d = Carbon::create(1234, 5, 6, 7, 8, 9); + $this->assertSame(6, $d->day); + } + public function testHourGetter() + { + $d = Carbon::create(1234, 5, 6, 7, 8, 9); + $this->assertSame(7, $d->hour); + } + public function testMinuteGetter() + { + $d = Carbon::create(1234, 5, 6, 7, 8, 9); + $this->assertSame(8, $d->minute); + } + public function testSecondGetter() + { + $d = Carbon::create(1234, 5, 6, 7, 8, 9); + $this->assertSame(9, $d->second); + } + public function testDayOfWeeGetter() + { + $d = Carbon::create(2012, 5, 7, 7, 8, 9); + $this->assertSame(Carbon::MONDAY, $d->dayOfWeek); + } + public function testDayOfYearGetter() + { + $d = Carbon::createFromDate(2012, 5, 7); + $this->assertSame(127, $d->dayOfYear); + } + public function testDaysInMonthGetter() + { + $d = Carbon::createFromDate(2012, 5, 7); + $this->assertSame(31, $d->daysInMonth); + } + public function testTimestampGetter() + { + $d = Carbon::create(); + $d->setTimezone('GMT'); + $this->assertSame(0, $d->setDateTime(1970, 1, 1, 0, 0, 0)->timestamp); + } + + public function testGetAge() + { + $d = Carbon::now(); + $this->assertSame(0, $d->age); + } + public function testGetAgeWithRealAge() + { + $d = Carbon::createFromDate(1975, 5, 21); + $age = intval(substr(date('Ymd') - date('Ymd', $d->timestamp), 0, -4)); + + $this->assertSame($age, $d->age); + } + + public function testGetQuarterFirst() + { + $d = Carbon::createFromDate(2012, 1, 1); + $this->assertSame(1, $d->quarter); + } + public function testGetQuarterFirstEnd() + { + $d = Carbon::createFromDate(2012, 3, 31); + $this->assertSame(1, $d->quarter); + } + public function testGetQuarterSecond() + { + $d = Carbon::createFromDate(2012, 4, 1); + $this->assertSame(2, $d->quarter); + } + public function testGetQuarterThird() + { + $d = Carbon::createFromDate(2012, 7, 1); + $this->assertSame(3, $d->quarter); + } + public function testGetQuarterFourth() + { + $d = Carbon::createFromDate(2012, 10, 1); + $this->assertSame(4, $d->quarter); + } + public function testGetQuarterFirstLast() + { + $d = Carbon::createFromDate(2012, 12, 31); + $this->assertSame(4, $d->quarter); + } + + public function testGetLocalTrue() + { + // Default timezone has been set to America/Toronto in TestFixture.php + // @see : http://en.wikipedia.org/wiki/List_of_UTC_time_offsets + $this->assertTrue(Carbon::createFromDate(2012, 1, 1, 'America/Toronto')->local); + $this->assertTrue(Carbon::createFromDate(2012, 1, 1, 'America/New_York')->local); + } + public function testGetLocalFalse() + { + $this->assertFalse(Carbon::createFromDate(2012, 7, 1, 'UTC')->local); + $this->assertFalse(Carbon::createFromDate(2012, 7, 1, 'Europe/London')->local); + } + + public function testGetUtcFalse() + { + $this->assertFalse(Carbon::createFromDate(2013, 1, 1, 'America/Toronto')->utc); + $this->assertFalse(Carbon::createFromDate(2013, 1, 1, 'Europe/Paris')->utc); + } + public function testGetUtcTrue() + { + $this->assertTrue(Carbon::createFromDate(2013, 1, 1, 'Atlantic/Reykjavik')->utc); + $this->assertTrue(Carbon::createFromDate(2013, 1, 1, 'Europe/Lisbon')->utc); + $this->assertTrue(Carbon::createFromDate(2013, 1, 1, 'Africa/Casablanca')->utc); + $this->assertTrue(Carbon::createFromDate(2013, 1, 1, 'Africa/Dakar')->utc); + $this->assertTrue(Carbon::createFromDate(2013, 1, 1, 'Europe/Dublin')->utc); + $this->assertTrue(Carbon::createFromDate(2013, 1, 1, 'Europe/London')->utc); + $this->assertTrue(Carbon::createFromDate(2013, 1, 1, 'UTC')->utc); + $this->assertTrue(Carbon::createFromDate(2013, 1, 1, 'GMT')->utc); + } + + public function testGetDstFalse() + { + $this->assertFalse(Carbon::createFromDate(2012, 1, 1, 'America/Toronto')->dst); + } + public function testGetDstTrue() + { + $this->assertTrue(Carbon::createFromDate(2012, 7, 1, 'America/Toronto')->dst); + } + + public function testOffsetForTorontoWithDST() + { + $this->assertSame(-18000, Carbon::createFromDate(2012, 1, 1, 'America/Toronto')->offset); + } + public function testOffsetForTorontoNoDST() + { + $this->assertSame(-14400, Carbon::createFromDate(2012, 6, 1, 'America/Toronto')->offset); + } + public function testOffsetForGMT() + { + $this->assertSame(0, Carbon::createFromDate(2012, 6, 1, 'GMT')->offset); + } + public function testOffsetHoursForTorontoWithDST() + { + $this->assertSame(-5, Carbon::createFromDate(2012, 1, 1, 'America/Toronto')->offsetHours); + } + public function testOffsetHoursForTorontoNoDST() + { + $this->assertSame(-4, Carbon::createFromDate(2012, 6, 1, 'America/Toronto')->offsetHours); + } + public function testOffsetHoursForGMT() + { + $this->assertSame(0, Carbon::createFromDate(2012, 6, 1, 'GMT')->offsetHours); + } + + public function testIsLeapYearTrue() + { + $this->assertTrue(Carbon::createFromDate(2012, 1, 1)->isLeapYear()); + } + public function testIsLeapYearFalse() + { + $this->assertFalse(Carbon::createFromDate(2011, 1, 1)->isLeapYear()); + } + + public function testWeekOfYearFirstWeek() + { + $this->assertSame(52, Carbon::createFromDate(2012, 1, 1)->weekOfYear); + $this->assertSame(1, Carbon::createFromDate(2012, 1, 2)->weekOfYear); + } + public function testWeekOfYearLastWeek() + { + $this->assertSame(52, Carbon::createFromDate(2012, 12, 30)->weekOfYear); + $this->assertSame(1, Carbon::createFromDate(2012, 12, 31)->weekOfYear); + } + + public function testGetTimezone() + { + $dt = Carbon::createFromDate(2000, 1, 1, 'America/Toronto'); + $this->assertSame('America/Toronto', $dt->timezone->getName()); + } + public function testGetTz() + { + $dt = Carbon::createFromDate(2000, 1, 1, 'America/Toronto'); + $this->assertSame('America/Toronto', $dt->tz->getName()); + } + public function testGetTimezoneName() + { + $dt = Carbon::createFromDate(2000, 1, 1, 'America/Toronto'); + $this->assertSame('America/Toronto', $dt->timezoneName); + } + public function testGetTzName() + { + $dt = Carbon::createFromDate(2000, 1, 1, 'America/Toronto'); + $this->assertSame('America/Toronto', $dt->tzName); + } + + public function testInvalidGetter() + { + $this->setExpectedException('InvalidArgumentException'); + $d = Carbon::now(); + $bb = $d->doesNotExit; + } +} diff --git a/vendor/nesbot/carbon/tests/InstanceTest.php b/vendor/nesbot/carbon/tests/InstanceTest.php new file mode 100755 index 0000000..15dbf59 --- /dev/null +++ b/vendor/nesbot/carbon/tests/InstanceTest.php @@ -0,0 +1,27 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +use Carbon\Carbon; + +class InstanceTest extends TestFixture +{ + public function testInstanceFromDateTime() + { + $dating = Carbon::instance(\DateTime::createFromFormat('Y-m-d H:i:s', '1975-05-21 22:32:11')); + $this->assertCarbon($dating, 1975, 5, 21, 22, 32, 11); + } + + public function testInstanceFromDateTimeKeepsTimezoneName() + { + $dating = Carbon::instance(\DateTime::createFromFormat('Y-m-d H:i:s', '1975-05-21 22:32:11')->setTimezone(new \DateTimeZone('America/Vancouver'))); + $this->assertSame('America/Vancouver', $dating->tzName); + } +} diff --git a/vendor/nesbot/carbon/tests/IsTest.php b/vendor/nesbot/carbon/tests/IsTest.php new file mode 100755 index 0000000..e44f87c --- /dev/null +++ b/vendor/nesbot/carbon/tests/IsTest.php @@ -0,0 +1,97 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +use Carbon\Carbon; + +class IsTest extends TestFixture +{ + public function testIsWeekdayTrue() + { + $this->assertTrue(Carbon::createFromDate(2012, 1, 2)->isWeekday()); + } + public function testIsWeekdayFalse() + { + $this->assertFalse(Carbon::createFromDate(2012, 1, 1)->isWeekday()); + } + public function testIsWeekendTrue() + { + $this->assertTrue(Carbon::createFromDate(2012, 1, 1)->isWeekend()); + } + public function testIsWeekendFalse() + { + $this->assertFalse(Carbon::createFromDate(2012, 1, 2)->isWeekend()); + } + + public function testIsYesterdayTrue() + { + $this->assertTrue(Carbon::now()->subDay()->isYesterday()); + } + public function testIsYesterdayFalseWithToday() + { + $this->assertFalse(Carbon::now()->endOfDay()->isYesterday()); + } + public function testIsYesterdayFalseWith2Days() + { + $this->assertFalse(Carbon::now()->subDays(2)->startOfDay()->isYesterday()); + } + + public function testIsTodayTrue() + { + $this->assertTrue(Carbon::now()->isToday()); + } + public function testIsTodayFalseWithYesterday() + { + $this->assertFalse(Carbon::now()->subDay()->endOfDay()->isToday()); + } + public function testIsTodayFalseWithTomorrow() + { + $this->assertFalse(Carbon::now()->addDay()->startOfDay()->isToday()); + } + public function testIsTodayWithTimezone() + { + $this->assertTrue(Carbon::now('Asia/Tokyo')->isToday()); + } + + public function testIsTomorrowTrue() + { + $this->assertTrue(Carbon::now()->addDay()->isTomorrow()); + } + public function testIsTomorrowFalseWithToday() + { + $this->assertFalse(Carbon::now()->endOfDay()->isTomorrow()); + } + public function testIsTomorrowFalseWith2Days() + { + $this->assertFalse(Carbon::now()->addDays(2)->startOfDay()->isTomorrow()); + } + + public function testIsFutureTrue() + { + $this->assertTrue(Carbon::now()->addSecond()->isFuture()); + } + public function testIsFutureFalse() + { + $this->assertFalse(Carbon::now()->isFuture()); + } + public function testIsFutureFalseInThePast() + { + $this->assertFalse(Carbon::now()->subSecond()->isFuture()); + } + + public function testIsPastTrue() + { + $this->assertTrue(Carbon::now()->subSecond()->isPast()); + } + public function testIsPast() + { + $this->assertFalse(Carbon::now()->addSecond()->isPast()); + } +} diff --git a/vendor/nesbot/carbon/tests/IssetTest.php b/vendor/nesbot/carbon/tests/IssetTest.php new file mode 100755 index 0000000..e66c97c --- /dev/null +++ b/vendor/nesbot/carbon/tests/IssetTest.php @@ -0,0 +1,27 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +use Carbon\Carbon; + +class IssetTest extends TestFixture +{ + public function testIssetReturnFalseForUnknownProperty() + { + $this->assertFalse(isset(Carbon::create(1234, 5, 6, 7, 8, 9)->sdfsdfss)); + } + public function testIssetReturnTrueForProperties() + { + $properties = array('year', 'month', 'day', 'hour', 'minute', 'second', 'dayOfWeek', 'dayOfYear', 'daysInMonth', 'timestamp', 'age', 'quarter', 'dst', 'offset', 'offsetHours', 'timezone', 'timezoneName', 'tz', 'tzName'); + foreach ($properties as $property) { + $this->assertTrue(isset(Carbon::create(1234, 5, 6, 7, 8, 9)->$property)); + } + } +} diff --git a/vendor/nesbot/carbon/tests/NowAndOtherStaticHelpersTest.php b/vendor/nesbot/carbon/tests/NowAndOtherStaticHelpersTest.php new file mode 100755 index 0000000..c89b9cf --- /dev/null +++ b/vendor/nesbot/carbon/tests/NowAndOtherStaticHelpersTest.php @@ -0,0 +1,65 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +use Carbon\Carbon; + +class NowAndOtherStaticHelpersTest extends TestFixture +{ + public function testNow() + { + $dt = Carbon::now(); + $this->assertSame(time(), $dt->timestamp); + } + public function testNowWithTimezone() + { + $dt = Carbon::now('Europe/London'); + $this->assertSame(time(), $dt->timestamp); + $this->assertSame('Europe/London', $dt->tzName); + } + + public function testToday() + { + $dt = Carbon::today(); + $this->assertSame(date('Y-m-d 00:00:00'), $dt->toDateTimeString()); + } + public function testTodayWithTimezone() + { + $dt = Carbon::today('Europe/London'); + $dt2 = new \DateTime('now', new \DateTimeZone('Europe/London')); + $this->assertSame($dt2->format('Y-m-d 00:00:00'), $dt->toDateTimeString()); + } + + public function testTomorrow() + { + $dt = Carbon::tomorrow(); + $dt2 = new \DateTime('tomorrow'); + $this->assertSame($dt2->format('Y-m-d 00:00:00'), $dt->toDateTimeString()); + } + public function testTomorrowWithTimezone() + { + $dt = Carbon::tomorrow('Europe/London'); + $dt2 = new \DateTime('tomorrow', new \DateTimeZone('Europe/London')); + $this->assertSame($dt2->format('Y-m-d 00:00:00'), $dt->toDateTimeString()); + } + + public function testYesterday() + { + $dt = Carbon::yesterday(); + $dt2 = new \DateTime('yesterday'); + $this->assertSame($dt2->format('Y-m-d 00:00:00'), $dt->toDateTimeString()); + } + public function testYesterdayWithTimezone() + { + $dt = Carbon::yesterday('Europe/London'); + $dt2 = new \DateTime('yesterday', new \DateTimeZone('Europe/London')); + $this->assertSame($dt2->format('Y-m-d 00:00:00'), $dt->toDateTimeString()); + } +} diff --git a/vendor/nesbot/carbon/tests/SettersTest.php b/vendor/nesbot/carbon/tests/SettersTest.php new file mode 100755 index 0000000..dccbbd1 --- /dev/null +++ b/vendor/nesbot/carbon/tests/SettersTest.php @@ -0,0 +1,187 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +use Carbon\Carbon; + +class SettersTest extends TestFixture +{ + public function testYearSetter() + { + $d = Carbon::now(); + $d->year = 1995; + $this->assertSame(1995, $d->year); + } + + public function testMonthSetter() + { + $d = Carbon::now(); + $d->month = 3; + $this->assertSame(3, $d->month); + } + public function testMonthSetterWithWrap() + { + $d = Carbon::now(); + $d->month = 13; + $this->assertSame(1, $d->month); + } + + public function testDaySetter() + { + $d = Carbon::now(); + $d->day = 2; + $this->assertSame(2, $d->day); + } + public function testDaySetterWithWrap() + { + $d = Carbon::createFromDate(2012, 8, 5); + $d->day = 32; + $this->assertSame(1, $d->day); + } + + public function testHourSetter() + { + $d = Carbon::now(); + $d->hour = 2; + $this->assertSame(2, $d->hour); + } + public function testHourSetterWithWrap() + { + $d = Carbon::now(); + $d->hour = 25; + $this->assertSame(1, $d->hour); + } + + public function testMinuteSetter() + { + $d = Carbon::now(); + $d->minute = 2; + $this->assertSame(2, $d->minute); + } + public function testMinuteSetterWithWrap() + { + $d = Carbon::now(); + $d->minute = 65; + $this->assertSame(5, $d->minute); + } + + public function testSecondSetter() + { + $d = Carbon::now(); + $d->second = 2; + $this->assertSame(2, $d->second); + } + public function testSecondSetterWithWrap() + { + $d = Carbon::now(); + $d->second = 65; + $this->assertSame(5, $d->second); + } + + public function testTimestampSetter() + { + $d = Carbon::now(); + $d->timestamp = 10; + $this->assertSame(10, $d->timestamp); + + $d->setTimestamp(11); + $this->assertSame(11, $d->timestamp); + } + + public function testSetTimezoneWithInvalidTimezone() + { + $this->setExpectedException('InvalidArgumentException'); + $d = Carbon::now(); + $d->setTimezone('sdf'); + } + public function testTimezoneWithInvalidTimezone() + { + $d = Carbon::now(); + + try { + $d->timezone = 'sdf'; + $this->fail('InvalidArgumentException was not been raised.'); + } catch (InvalidArgumentException $expected) {} + + try { + $d->timezone('sdf'); + $this->fail('InvalidArgumentException was not been raised.'); + } catch (InvalidArgumentException $expected) {} + } + public function testTzWithInvalidTimezone() + { + $d = Carbon::now(); + + try { + $d->tz = 'sdf'; + $this->fail('InvalidArgumentException was not been raised.'); + } catch (InvalidArgumentException $expected) {} + + try { + $d->tz('sdf'); + $this->fail('InvalidArgumentException was not been raised.'); + } catch (InvalidArgumentException $expected) {} + } + public function testSetTimezoneUsingString() + { + $d = Carbon::now(); + $d->setTimezone('America/Toronto'); + $this->assertSame('America/Toronto', $d->tzName); + } + public function testTimezoneUsingString() + { + $d = Carbon::now(); + $d->timezone = 'America/Toronto'; + $this->assertSame('America/Toronto', $d->tzName); + + $d->timezone('America/Vancouver'); + $this->assertSame('America/Vancouver', $d->tzName); + } + public function testTzUsingString() + { + $d = Carbon::now(); + $d->tz = 'America/Toronto'; + $this->assertSame('America/Toronto', $d->tzName); + + $d->tz('America/Vancouver'); + $this->assertSame('America/Vancouver', $d->tzName); + } + public function testSetTimezoneUsingDateTimeZone() + { + $d = Carbon::now(); + $d->setTimezone(new \DateTimeZone('America/Toronto')); + $this->assertSame('America/Toronto', $d->tzName); + } + public function testTimezoneUsingDateTimeZone() + { + $d = Carbon::now(); + $d->timezone = new \DateTimeZone('America/Toronto'); + $this->assertSame('America/Toronto', $d->tzName); + + $d->timezone(new \DateTimeZone('America/Vancouver')); + $this->assertSame('America/Vancouver', $d->tzName); + } + public function testTzUsingDateTimeZone() + { + $d = Carbon::now(); + $d->tz = new \DateTimeZone('America/Toronto'); + $this->assertSame('America/Toronto', $d->tzName); + + $d->tz(new \DateTimeZone('America/Vancouver')); + $this->assertSame('America/Vancouver', $d->tzName); + } + + public function testInvalidSetter() + { + $this->setExpectedException('InvalidArgumentException'); + $d = Carbon::now(); + $d->doesNotExit = 'bb'; + } +} diff --git a/vendor/nesbot/carbon/tests/StartEndOfTest.php b/vendor/nesbot/carbon/tests/StartEndOfTest.php new file mode 100755 index 0000000..bb2a043 --- /dev/null +++ b/vendor/nesbot/carbon/tests/StartEndOfTest.php @@ -0,0 +1,210 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +use Carbon\Carbon; + +class StartEndOfTest extends TestFixture +{ + public function testStartOfDay() + { + $dt = Carbon::now(); + $this->assertTrue($dt->startOfDay() instanceof Carbon); + $this->assertCarbon($dt, $dt->year, $dt->month, $dt->day, 0, 0, 0); + } + public function testEndOfDay() + { + $dt = Carbon::now(); + $this->assertTrue($dt->endOfDay() instanceof Carbon); + $this->assertCarbon($dt, $dt->year, $dt->month, $dt->day, 23, 59, 59); + } + + public function testStartOfMonthIsFluid() + { + $dt = Carbon::now(); + $this->assertTrue($dt->startOfMonth() instanceof Carbon); + } + public function testStartOfMonthFromNow() + { + $dt = Carbon::now()->startOfMonth(); + $this->assertCarbon($dt, $dt->year, $dt->month, 1, 0, 0, 0); + } + public function testStartOfMonthFromLastDay() + { + $dt = Carbon::create(2000, 1, 31, 2, 3, 4)->startOfMonth(); + $this->assertCarbon($dt, 2000, 1, 1, 0, 0, 0); + } + + public function testStartOfYearIsFluid() + { + $dt = Carbon::now(); + $this->assertTrue($dt->startOfYear() instanceof Carbon); + } + public function testStartOfYearFromNow() + { + $dt = Carbon::now()->startOfYear(); + $this->assertCarbon($dt, $dt->year, 1, 1, 0, 0, 0); + } + public function testStartOfYearFromFirstDay() + { + $dt = Carbon::create(2000, 1, 1, 1, 1, 1)->startOfYear(); + $this->assertCarbon($dt, 2000, 1, 1, 0, 0, 0); + } + public function testStartOfYearFromLastDay() + { + $dt = Carbon::create(2000, 12, 31, 23, 59, 59)->startOfYear(); + $this->assertCarbon($dt, 2000, 1, 1, 0, 0, 0); + } + + public function testEndOfMonthIsFluid() + { + $dt = Carbon::now(); + $this->assertTrue($dt->endOfMonth() instanceof Carbon); + } + public function testEndOfMonth() + { + $dt = Carbon::create(2000, 1, 1, 2, 3, 4)->endOfMonth(); + $this->assertCarbon($dt, 2000, 1, 31, 23, 59, 59); + } + public function testEndOfMonthFromLastDay() + { + $dt = Carbon::create(2000, 1, 31, 2, 3, 4)->endOfMonth(); + $this->assertCarbon($dt, 2000, 1, 31, 23, 59, 59); + } + + public function testEndOfYearIsFluid() + { + $dt = Carbon::now(); + $this->assertTrue($dt->endOfYear() instanceof Carbon); + } + public function testEndOfYearFromNow() + { + $dt = Carbon::now()->endOfYear(); + $this->assertCarbon($dt, $dt->year, 12, 31, 23, 59, 59); + } + public function testEndOfYearFromFirstDay() + { + $dt = Carbon::create(2000, 1, 1, 1, 1, 1)->endOfYear(); + $this->assertCarbon($dt, 2000, 12, 31, 23, 59, 59); + } + public function testEndOfYearFromLastDay() + { + $dt = Carbon::create(2000, 12, 31, 23, 59, 59)->endOfYear(); + $this->assertCarbon($dt, 2000, 12, 31, 23, 59, 59); + } + + public function testStartOfDecadeIsFluid() + { + $dt = Carbon::now(); + $this->assertTrue($dt->startOfDecade() instanceof Carbon); + } + public function testStartOfDecadeFromNow() + { + $dt = Carbon::now()->startOfDecade(); + $this->assertCarbon($dt, $dt->year - $dt->year % 10, 1, 1, 0, 0, 0); + } + public function testStartOfDecadeFromFirstDay() + { + $dt = Carbon::create(2000, 1, 1, 1, 1, 1)->startOfDecade(); + $this->assertCarbon($dt, 2000, 1, 1, 0, 0, 0); + } + public function testStartOfDecadeFromLastDay() + { + $dt = Carbon::create(2009, 12, 31, 23, 59, 59)->startOfDecade(); + $this->assertCarbon($dt, 2000, 1, 1, 0, 0, 0); + } + + public function testEndOfDecadeIsFluid() + { + $dt = Carbon::now(); + $this->assertTrue($dt->endOfDecade() instanceof Carbon); + } + public function testEndOfDecadeFromNow() + { + $dt = Carbon::now()->endOfDecade(); + $this->assertCarbon($dt, $dt->year - $dt->year % 10 + 9, 12, 31, 23, 59, 59); + } + public function testEndOfDecadeFromFirstDay() + { + $dt = Carbon::create(2000, 1, 1, 1, 1, 1)->endOfDecade(); + $this->assertCarbon($dt, 2009, 12, 31, 23, 59, 59); + } + public function testEndOfDecadeFromLastDay() + { + $dt = Carbon::create(2009, 12, 31, 23, 59, 59)->endOfDecade(); + $this->assertCarbon($dt, 2009, 12, 31, 23, 59, 59); + } + + public function testStartOfCenturyIsFluid() + { + $dt = Carbon::now(); + $this->assertTrue($dt->startOfCentury() instanceof Carbon); + } + public function testStartOfCenturyFromNow() + { + $dt = Carbon::now()->startOfCentury(); + $this->assertCarbon($dt, $dt->year - $dt->year % 100, 1, 1, 0, 0, 0); + } + public function testStartOfCenturyFromFirstDay() + { + $dt = Carbon::create(2000, 1, 1, 1, 1, 1)->startOfCentury(); + $this->assertCarbon($dt, 2000, 1, 1, 0, 0, 0); + } + public function testStartOfCenturyFromLastDay() + { + $dt = Carbon::create(2009, 12, 31, 23, 59, 59)->startOfCentury(); + $this->assertCarbon($dt, 2000, 1, 1, 0, 0, 0); + } + + public function testEndOfCenturyIsFluid() + { + $dt = Carbon::now(); + $this->assertTrue($dt->endOfCentury() instanceof Carbon); + } + public function testEndOfCenturyFromNow() + { + $dt = Carbon::now()->endOfCentury(); + $this->assertCarbon($dt, $dt->year - $dt->year % 100 + 99, 12, 31, 23, 59, 59); + } + public function testEndOfCenturyFromFirstDay() + { + $dt = Carbon::create(2000, 1, 1, 1, 1, 1)->endOfCentury(); + $this->assertCarbon($dt, 2099, 12, 31, 23, 59, 59); + } + public function testEndOfCenturyFromLastDay() + { + $dt = Carbon::create(2099, 12, 31, 23, 59, 59)->endOfCentury(); + $this->assertCarbon($dt, 2099, 12, 31, 23, 59, 59); + } + + public function testAverageIsFluid() + { + $dt = Carbon::now()->average(); + $this->assertTrue($dt instanceof Carbon); + } + public function testAverageFromSame() + { + $dt1 = Carbon::create(2000, 1, 31, 2, 3, 4); + $dt2 = Carbon::create(2000, 1, 31, 2, 3, 4)->average($dt1); + $this->assertCarbon($dt2, 2000, 1, 31, 2, 3, 4); + } + public function testAverageFromGreater() + { + $dt1 = Carbon::create(2000, 1, 1, 1, 1, 1); + $dt2 = Carbon::create(2009, 12, 31, 23, 59, 59)->average($dt1); + $this->assertCarbon($dt2, 2004, 12, 31, 12, 30, 30); + } + public function testAverageFromLower() + { + $dt1 = Carbon::create(2009, 12, 31, 23, 59, 59); + $dt2 = Carbon::create(2000, 1, 1, 1, 1, 1)->average($dt1); + $this->assertCarbon($dt2, 2004, 12, 31, 12, 30, 30); + } +} diff --git a/vendor/nesbot/carbon/tests/StringsTest.php b/vendor/nesbot/carbon/tests/StringsTest.php new file mode 100755 index 0000000..e893ed0 --- /dev/null +++ b/vendor/nesbot/carbon/tests/StringsTest.php @@ -0,0 +1,148 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +use Carbon\Carbon; + +class MyCarbon extends Carbon {} + +class StringsTest extends TestFixture +{ + public function testToString() + { + $d = Carbon::now(); + $this->assertSame(Carbon::now()->toDateTimeString(), ''.$d); + } + public function testSetToStringFormat() + { + Carbon::setToStringFormat('jS \o\f F, Y g:i:s a'); + $d = Carbon::create(1975, 12, 25, 14, 15, 16); + $this->assertSame('25th of December, 1975 2:15:16 pm', ''.$d); + } + public function testResetToStringFormat() + { + $d = Carbon::now(); + Carbon::setToStringFormat('123'); + Carbon::resetToStringFormat(); + $this->assertSame($d->toDateTimeString(), ''.$d); + } + public function testExtendedClassToString() { + $d = MyCarbon::now(); + $this->assertSame($d->toDateTimeString(), ''.$d); + } + + public function testToDateString() + { + $d = Carbon::create(1975, 12, 25, 14, 15, 16); + $this->assertSame('1975-12-25', $d->toDateString()); + } + public function testToFormattedDateString() + { + $d = Carbon::create(1975, 12, 25, 14, 15, 16); + $this->assertSame('Dec 25, 1975', $d->toFormattedDateString()); + } + public function testToLocalizedFormattedDateString() + { + /**************** + + Working out a Travis issue on how to set a different locale + other than EN to test this. + + + $cache = setlocale(LC_TIME, 0); + setlocale(LC_TIME, 'German'); + $d = Carbon::create(1975, 12, 25, 14, 15, 16); + $this->assertSame('Donnerstag 25 Dezember 1975', $d->formatLocalized('%A %d %B %Y')); + setlocale(LC_TIME, $cache); + + *****************/ + } + public function testToTimeString() + { + $d = Carbon::create(1975, 12, 25, 14, 15, 16); + $this->assertSame('14:15:16', $d->toTimeString()); + } + public function testToDateTimeString() + { + $d = Carbon::create(1975, 12, 25, 14, 15, 16); + $this->assertSame('1975-12-25 14:15:16', $d->toDateTimeString()); + } + public function testToDateTimeStringWithPaddedZeroes() + { + $d = Carbon::create(2000, 5, 2, 4, 3, 4); + $this->assertSame('2000-05-02 04:03:04', $d->toDateTimeString()); + } + public function testToDayDateTimeString() + { + $d = Carbon::create(1975, 12, 25, 14, 15, 16); + $this->assertSame('Thu, Dec 25, 1975 2:15 PM', $d->toDayDateTimeString()); + } + + public function testToATOMString() + { + $d = Carbon::create(1975, 12, 25, 14, 15, 16); + $this->assertSame('1975-12-25T14:15:16-05:00', $d->toATOMString()); + } + public function testToCOOKIEString() + { + $d = Carbon::create(1975, 12, 25, 14, 15, 16); + if( \DateTime::COOKIE === 'l, d-M-y H:i:s T' ) + $cookieString = 'Thursday, 25-Dec-75 14:15:16 EST'; + else + $cookieString = 'Thursday, 25-Dec-1975 14:15:16 EST'; + + $this->assertSame($cookieString, $d->toCOOKIEString()); + } + public function testToISO8601String() + { + $d = Carbon::create(1975, 12, 25, 14, 15, 16); + $this->assertSame('1975-12-25T14:15:16-0500', $d->toISO8601String()); + } + public function testToRC822String() + { + $d = Carbon::create(1975, 12, 25, 14, 15, 16); + $this->assertSame('Thu, 25 Dec 75 14:15:16 -0500', $d->toRFC822String()); + } + public function testToRFC850String() + { + $d = Carbon::create(1975, 12, 25, 14, 15, 16); + $this->assertSame('Thursday, 25-Dec-75 14:15:16 EST', $d->toRFC850String()); + } + public function testToRFC1036String() + { + $d = Carbon::create(1975, 12, 25, 14, 15, 16); + $this->assertSame('Thu, 25 Dec 75 14:15:16 -0500', $d->toRFC1036String()); + } + public function testToRFC1123String() + { + $d = Carbon::create(1975, 12, 25, 14, 15, 16); + $this->assertSame('Thu, 25 Dec 1975 14:15:16 -0500', $d->toRFC1123String()); + } + public function testToRFC2822String() + { + $d = Carbon::create(1975, 12, 25, 14, 15, 16); + $this->assertSame('Thu, 25 Dec 1975 14:15:16 -0500', $d->toRFC2822String()); + } + public function testToRFC3339String() + { + $d = Carbon::create(1975, 12, 25, 14, 15, 16); + $this->assertSame('1975-12-25T14:15:16-05:00', $d->toRFC3339String()); + } + public function testToRSSString() + { + $d = Carbon::create(1975, 12, 25, 14, 15, 16); + $this->assertSame('Thu, 25 Dec 1975 14:15:16 -0500', $d->toRSSString()); + } + public function testToW3CString() + { + $d = Carbon::create(1975, 12, 25, 14, 15, 16); + $this->assertSame('1975-12-25T14:15:16-05:00', $d->toW3CString()); + } +} diff --git a/vendor/nesbot/carbon/tests/SubTest.php b/vendor/nesbot/carbon/tests/SubTest.php new file mode 100755 index 0000000..47df78c --- /dev/null +++ b/vendor/nesbot/carbon/tests/SubTest.php @@ -0,0 +1,159 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +use Carbon\Carbon; + +class SubTest extends TestFixture +{ + public function testSubYearsPositive() + { + $this->assertSame(1974, Carbon::createFromDate(1975)->subYears(1)->year); + } + public function testSubYearsZero() + { + $this->assertSame(1975, Carbon::createFromDate(1975)->subYears(0)->year); + } + public function testSubYearsNegative() + { + $this->assertSame(1976, Carbon::createFromDate(1975)->subYears(-1)->year); + } + + public function testSubYear() + { + $this->assertSame(1974, Carbon::createFromDate(1975)->subYear()->year); + } + + public function testSubMonthsPositive() + { + $this->assertSame(12, Carbon::createFromDate(1975, 1, 1)->subMonths(1)->month); + } + public function testSubMonthsZero() + { + $this->assertSame(1, Carbon::createFromDate(1975, 1, 1)->subMonths(0)->month); + } + public function testSubMonthsNegative() + { + $this->assertSame(2, Carbon::createFromDate(1975, 1, 1)->subMonths(-1)->month); + } + + public function testSubMonth() + { + $this->assertSame(12, Carbon::createFromDate(1975, 1, 1)->subMonth()->month); + } + + public function testSubDaysPositive() + { + $this->assertSame(30, Carbon::createFromDate(1975, 5, 1)->subDays(1)->day); + } + public function testSubDaysZero() + { + $this->assertSame(1, Carbon::createFromDate(1975, 5, 1)->subDays(0)->day); + } + public function testSubDaysNegative() + { + $this->assertSame(2, Carbon::createFromDate(1975, 5, 1)->subDays(-1)->day); + } + + public function testSubDay() + { + $this->assertSame(30, Carbon::createFromDate(1975, 5, 1)->subDay()->day); + } + + public function testSubWeekdaysPositive() + { + $this->assertSame(22, Carbon::createFromDate(2012, 1, 4)->subWeekdays(9)->day); + } + public function testSubWeekdaysZero() + { + $this->assertSame(4, Carbon::createFromDate(2012, 1, 4)->subWeekdays(0)->day); + } + public function testSubWeekdaysNegative() + { + $this->assertSame(13, Carbon::createFromDate(2012, 1, 31)->subWeekdays(-9)->day); + } + + public function testSubWeekday() + { + $this->assertSame(6, Carbon::createFromDate(2012, 1, 9)->subWeekday()->day); + } + + public function testSubWeeksPositive() + { + $this->assertSame(14, Carbon::createFromDate(1975, 5, 21)->subWeeks(1)->day); + } + public function testSubWeeksZero() + { + $this->assertSame(21, Carbon::createFromDate(1975, 5, 21)->subWeeks(0)->day); + } + public function testSubWeeksNegative() + { + $this->assertSame(28, Carbon::createFromDate(1975, 5, 21)->subWeeks(-1)->day); + } + + public function testSubWeek() + { + $this->assertSame(14, Carbon::createFromDate(1975, 5, 21)->subWeek()->day); + } + + public function testSubHoursPositive() + { + $this->assertSame(23, Carbon::createFromTime(0)->subHours(1)->hour); + } + public function testSubHoursZero() + { + $this->assertSame(0, Carbon::createFromTime(0)->subHours(0)->hour); + } + public function testSubHoursNegative() + { + $this->assertSame(1, Carbon::createFromTime(0)->subHours(-1)->hour); + } + + public function testSubHour() + { + $this->assertSame(23, Carbon::createFromTime(0)->subHour()->hour); + } + + public function testSubMinutesPositive() + { + $this->assertSame(59, Carbon::createFromTime(0, 0)->subMinutes(1)->minute); + } + public function testSubMinutesZero() + { + $this->assertSame(0, Carbon::createFromTime(0, 0)->subMinutes(0)->minute); + } + public function testSubMinutesNegative() + { + $this->assertSame(1, Carbon::createFromTime(0, 0)->subMinutes(-1)->minute); + } + + public function testSubMinute() + { + $this->assertSame(59, Carbon::createFromTime(0, 0)->subMinute()->minute); + } + + public function testSubSecondsPositive() + { + $this->assertSame(59, Carbon::createFromTime(0, 0, 0)->subSeconds(1)->second); + } + public function testSubSecondsZero() + { + $this->assertSame(0, Carbon::createFromTime(0, 0, 0)->subSeconds(0)->second); + } + public function testSubSecondsNegative() + { + $this->assertSame(1, Carbon::createFromTime(0, 0, 0)->subSeconds(-1)->second); + } + + public function testSubSecond() + { + $this->assertSame(59, Carbon::createFromTime(0, 0, 0)->subSecond()->second); + } +} diff --git a/vendor/nesbot/carbon/tests/TestFixture.php b/vendor/nesbot/carbon/tests/TestFixture.php new file mode 100755 index 0000000..fa5d670 --- /dev/null +++ b/vendor/nesbot/carbon/tests/TestFixture.php @@ -0,0 +1,51 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +require __DIR__.'/../vendor/autoload.php'; + +use Carbon\Carbon; + +class TestFixture extends \PHPUnit_Framework_TestCase +{ + private $saveTz; + + protected function setUp() + { + //save current timezone + $this->saveTz = date_default_timezone_get(); + + date_default_timezone_set('America/Toronto'); + } + + protected function tearDown() + { + date_default_timezone_set($this->saveTz); + } + + protected function assertCarbon(Carbon $d, $year, $month, $day, $hour = null, $minute = null, $second = null) + { + $this->assertSame($year, $d->year, 'Carbon->year'); + $this->assertSame($month, $d->month, 'Carbon->month'); + $this->assertSame($day, $d->day, 'Carbon->day'); + + if ($hour !== null) { + $this->assertSame($hour, $d->hour, 'Carbon->hour'); + } + + if ($minute !== null) { + $this->assertSame($minute, $d->minute, 'Carbon->minute'); + } + + if ($second !== null) { + $this->assertSame($second, $d->second, 'Carbon->second'); + } + } +} diff --git a/vendor/nesbot/carbon/tests/TestingAidsTest.php b/vendor/nesbot/carbon/tests/TestingAidsTest.php new file mode 100755 index 0000000..e2ed0ac --- /dev/null +++ b/vendor/nesbot/carbon/tests/TestingAidsTest.php @@ -0,0 +1,123 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +use Carbon\Carbon; + +class TestingAidsTest extends TestFixture +{ + public function testTestingAidsWithTestNowNotSet() + { + Carbon::setTestNow(); + + $this->assertFalse(Carbon::hasTestNow()); + $this->assertNull(Carbon::getTestNow()); + } + public function testTestingAidsWithTestNowSet() + { + $notNow = Carbon::yesterday(); + Carbon::setTestNow($notNow); + + $this->assertTrue(Carbon::hasTestNow()); + $this->assertSame($notNow, Carbon::getTestNow()); + } + + public function testConstructorWithTestValueSet() + { + $notNow = Carbon::yesterday(); + Carbon::setTestNow($notNow); + + $this->assertEquals($notNow, new Carbon()); + $this->assertEquals($notNow, new Carbon(null)); + $this->assertEquals($notNow, new Carbon('')); + $this->assertEquals($notNow, new Carbon('now')); + } + + public function testNowWithTestValueSet() + { + $notNow = Carbon::yesterday(); + Carbon::setTestNow($notNow); + + $this->assertEquals($notNow, Carbon::now()); + } + + public function testParseWithTestValueSet() + { + $notNow = Carbon::yesterday(); + Carbon::setTestNow($notNow); + + $this->assertEquals($notNow, Carbon::parse()); + $this->assertEquals($notNow, Carbon::parse(null)); + $this->assertEquals($notNow, Carbon::parse('')); + $this->assertEquals($notNow, Carbon::parse('now')); + } + + public function testParseRelativeWithTestValueSet() + { + $notNow = Carbon::parse('2013-09-01 05:15:05'); + Carbon::setTestNow($notNow); + + $this->assertEquals('2013-09-01 05:10:05', Carbon::parse('5 minutes ago')->toDateTimeString()); + + $this->assertEquals('2013-08-25 05:15:05', Carbon::parse('1 week ago')->toDateTimeString()); + + $this->assertEquals('2013-09-02 00:00:00', Carbon::parse('tomorrow')->toDateTimeString()); + $this->assertEquals('2013-08-31 00:00:00', Carbon::parse('yesterday')->toDateTimeString()); + + $this->assertEquals('2013-09-02 05:15:05', Carbon::parse('+1 day')->toDateTimeString()); + $this->assertEquals('2013-08-31 05:15:05', Carbon::parse('-1 day')->toDateTimeString()); + + $this->assertEquals('2013-09-02 00:00:00', Carbon::parse('next monday')->toDateTimeString()); + $this->assertEquals('2013-09-03 00:00:00', Carbon::parse('next tuesday')->toDateTimeString()); + $this->assertEquals('2013-09-04 00:00:00', Carbon::parse('next wednesday')->toDateTimeString()); + $this->assertEquals('2013-09-05 00:00:00', Carbon::parse('next thursday')->toDateTimeString()); + $this->assertEquals('2013-09-06 00:00:00', Carbon::parse('next friday')->toDateTimeString()); + $this->assertEquals('2013-09-07 00:00:00', Carbon::parse('next saturday')->toDateTimeString()); + $this->assertEquals('2013-09-08 00:00:00', Carbon::parse('next sunday')->toDateTimeString()); + + $this->assertEquals('2013-08-26 00:00:00', Carbon::parse('last monday')->toDateTimeString()); + $this->assertEquals('2013-08-27 00:00:00', Carbon::parse('last tuesday')->toDateTimeString()); + $this->assertEquals('2013-08-28 00:00:00', Carbon::parse('last wednesday')->toDateTimeString()); + $this->assertEquals('2013-08-29 00:00:00', Carbon::parse('last thursday')->toDateTimeString()); + $this->assertEquals('2013-08-30 00:00:00', Carbon::parse('last friday')->toDateTimeString()); + $this->assertEquals('2013-08-31 00:00:00', Carbon::parse('last saturday')->toDateTimeString()); + $this->assertEquals('2013-08-25 00:00:00', Carbon::parse('last sunday')->toDateTimeString()); + + $this->assertEquals('2013-09-02 00:00:00', Carbon::parse('this monday')->toDateTimeString()); + $this->assertEquals('2013-09-03 00:00:00', Carbon::parse('this tuesday')->toDateTimeString()); + $this->assertEquals('2013-09-04 00:00:00', Carbon::parse('this wednesday')->toDateTimeString()); + $this->assertEquals('2013-09-05 00:00:00', Carbon::parse('this thursday')->toDateTimeString()); + $this->assertEquals('2013-09-06 00:00:00', Carbon::parse('this friday')->toDateTimeString()); + $this->assertEquals('2013-09-07 00:00:00', Carbon::parse('this saturday')->toDateTimeString()); + $this->assertEquals('2013-09-01 00:00:00', Carbon::parse('this sunday')->toDateTimeString()); + + $this->assertEquals('2013-10-01 05:15:05', Carbon::parse('first day of next month')->toDateTimeString()); + $this->assertEquals('2013-09-30 05:15:05', Carbon::parse('last day of this month')->toDateTimeString()); + } + + public function testParseRelativeWithMinusSignsInDate() + { + $notNow = Carbon::parse('2013-09-01 05:15:05'); + Carbon::setTestNow($notNow); + + $this->assertEquals('2000-01-03 00:00:00', Carbon::parse('2000-1-3')->toDateTimeString()); + $this->assertEquals('2000-10-10 00:00:00', Carbon::parse('2000-10-10')->toDateTimeString()); + } + + public function testTimeZoneWithTestValueSet() + { + $notNow = Carbon::parse('2013-07-01 12:00:00', 'America/New_York'); + Carbon::setTestNow($notNow); + + $this->assertEquals('2013-07-01T12:00:00-0400', Carbon::parse('now')->toISO8601String()); + $this->assertEquals('2013-07-01T11:00:00-0500', Carbon::parse('now', 'America/Mexico_City')->toISO8601String()); + $this->assertEquals('2013-07-01T09:00:00-0700', Carbon::parse('now', 'America/Vancouver')->toISO8601String()); + } +} diff --git a/vendor/nikic/php-parser/.travis.yml b/vendor/nikic/php-parser/.travis.yml new file mode 100755 index 0000000..e5ec7c9 --- /dev/null +++ b/vendor/nikic/php-parser/.travis.yml @@ -0,0 +1,7 @@ +language: php + +php: + - 5.2 + - 5.3 + - 5.4 + - 5.5 \ No newline at end of file diff --git a/vendor/nikic/php-parser/CHANGELOG.md b/vendor/nikic/php-parser/CHANGELOG.md new file mode 100755 index 0000000..55b7aa4 --- /dev/null +++ b/vendor/nikic/php-parser/CHANGELOG.md @@ -0,0 +1,155 @@ +Version 0.9.5-dev +----------------- + +Nothing yet. + +Version 0.9.4 (25.08.2013) +-------------------------- +* [PHP 5.5] Add support for `ClassName::class`. This is parsed as an `Expr_ClassConstFetch` with `'class'` being the + constant name. + +* Syntax errors now include information on expected tokens and mimic the format of PHP's own (pre 5.4) error messages. + Example: + + Old: Unexpected token T_STATIC on line 1 + New: Syntax error, unexpected T_STATIC, expecting T_STRING or T_NS_SEPARATOR or '{' + +* `PHPParser_PrettyPrinter_Zend` was renamed to `PHPParser_PrettyPrinter_Default` as the default pretty printer only + very loosely applies the Zend Coding Standard. The class `PHPParser_PrettyPrinter_Zend` extends + `PHPParser_PrettyPrinter_Default` to maintain backwards compatibility. + +* The pretty printer now prints namespaces in semicolon-style if possible (i.e. if the file does not contain a global + namespace declaration). + +* Added `prettyPrintFile(array $stmts)` method which will pretty print a file of statements including the opening + `` at the start and end + of files using inline HTML. + +* There now is a builder for interfaces (`PHPParser_Builder_Interface`). + +* An interface for the node traversation has been added: `PHPParser_NodeTraverserInterface` + +* Fix pretty printing of `include` expressions (precedence information was missing). + +* Fix "undefined index" notices when generating the expected tokens for a syntax error. + +* Improve performance of `PrettyPrinter` construction by no longer using the `uniqid()` function. + +Version 0.9.3 (22.11.2012) +-------------------------- + +* [BC] As `list()` in `foreach` is now supported the structure of list assignments changed: + + 1. There is no longer a dedicated `AssignList` node; instead a normal `Assign` node is used with a `List` as `var`. + 2. Nested lists are now `List` nodes too, instead of just arrays. + +* [BC] As arbitrary expressions are allowed in `empty()` now its subnode was renamed from `var` to `expr`. + +* [BC] The protected `pSafe()` method in `PrettyPrinterAbstract` was renamed to `pNoIndent()`. + +* [PHP 5.5] Add support for arbitrary expressions in `empty()`. + +* [PHP 5.5] Add support for constant array / string dereferencing. + Examples: `"foo"[2]`, `[1, 2, 3][2]` + +* [PHP 5.5] Add support for `yield` expressions. This adds a new `Yield` expression type, with subnodes `key` and + `value`. + +* [PHP 5.5] Add support for `finally`. This adds a new `finallyStmts` subnode to the `TryCatch` node. If there is no + finally clause it will be `null`. + +* [PHP 5.5] Add support for `list()` destructuring of `foreach` values. + Example: `foreach ($coords as list($x, $y)) { ... }` + +* Improve pretty printing of expressions by printing less unnecessary parentheses. In particular concatenations are now + printed as `$a . $b . $c . $d . $e` rather than `$a . ($b . ($c . ($d . $e)))`. This is implemented by taking operator + associativity into account. New protected methods added to the pretty printer are `pPrec()`, `pInfixOp()`, + `pPrefixOp()` and `pPostfixOp()`. This also fixes an issue with extraneous parentheses in closure bodies. + +* Fix formatting of fall-through `case` statements in the Zend pretty printer. + +* Fix parsing of `$foo =& new Bar`. It is now properly parsed as `AssignRef` (instead of `Assign`). + +* Fix assignment of `$endAttributes`. Sometimes the attributes of the token right after the node were assigned, rather + than the attributes of the last token in the node. + +* `rebuildParser.php` is now designed to be run from the command line rather than from the browser. + +Version 0.9.2 (07.07.2012) +-------------------------- + +* Add `Class->getMethods()` function, which returns all methods contained in the `stmts` array of the class node. This + does not take inherited methods into account. + +* Add `isPublic()`, `isProtected()`, `isPrivate()`. `isAbstract()`, `isFinal()` and `isStatic()` accessors to the + `ClassMethod`, `Property` and `Class` nodes. (`Property` and `Class` obviously only have the accessors relevant to + them.) + +* Fix parsing of new expressions in parentheses, e.g. `return(new Foo);`. + +* [BC] Due to the below changes nodes now optionally accept an `$attributes` array as the + last parameter, instead of the previously used `$line` and `$docComment` parameters. + +* Add mechanism for adding attributes to nodes in the lexer. + + The following attributes are now added by default: + + * `startLine`: The line the node started in. + * `endLine`: The line the node ended in. + * `comments`: An array of comments. The comments are instances of `PHPParser_Comment` + (or `PHPParser_Comment_Doc` for doc comments). + + The methods `getLine()` and `setLine()` still exist and function as before, but internally + operator on the `startLine` attribute. + + `getDocComment()` also continues to exist. It returns the last comment in the `comments` + attribute if it is a doc comment, otherwise `null`. As `getDocComment()` now returns a + comment object (which can be modified using `->setText()`) the `setDocComment()` method was + removed. Comment objects implement a `__toString()` method, so `getDocComment()` should + continue to work properly with old code. + +* [BC] Use inject-once approach for lexer: + + Now the lexer is injected only once when creating the parser. Instead of + + $parser = new PHPParser_Parser; + $parser->parse(new PHPParser_Lexer($code)); + $parser->parse(new PHPParser_Lexer($code2)); + + you write: + + $parser = new PHPParser_Parser(new PHPParser_Lexer); + $parser->parse($code); + $parser->parse($code2); + +* Fix `NameResolver` visitor to also resolve class names in `catch` blocks. + +Version 0.9.1 (24.04.2012) +-------------------------- + +* Add ability to add attributes to nodes: + + It is now possible to add attributes to a node using `$node->setAttribute('name', 'value')` and to retrieve them using + `$node->getAttribute('name' [, 'default'])`. Additionally the existance of an attribute can be checked with + `$node->hasAttribute('name')` and all attributes can be returned using `$node->getAttributes()`. + +* Add code generation features: Builders and templates. + + For more infos, see the [code generation documentation][1]. + +* [BC] Don't traverse nodes merged by another visitor: + + If a NodeVisitor returns an array of nodes to merge, these will no longer be traversed by all other visitors. This + behavior only caused problems. + +* Fix line numbers for some list structures. +* Fix XML unserialization of empty nodes. +* Fix parsing of integers that overflow into floats. +* Fix emulation of NOWDOC and binary floats. + +Version 0.9.0 (05.01.2012) +-------------------------- + +First version. + + [1]: https://github.com/nikic/PHP-Parser/blob/master/doc/3_Code_generation.markdown \ No newline at end of file diff --git a/vendor/nikic/php-parser/LICENSE b/vendor/nikic/php-parser/LICENSE new file mode 100755 index 0000000..443210b --- /dev/null +++ b/vendor/nikic/php-parser/LICENSE @@ -0,0 +1,31 @@ +Copyright (c) 2011 by Nikita Popov. + +Some rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + disclaimer in the documentation and/or other materials provided + with the distribution. + + * The names of the contributors may not be used to endorse or + promote products derived from this software without specific + prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file diff --git a/vendor/nikic/php-parser/README.md b/vendor/nikic/php-parser/README.md new file mode 100755 index 0000000..8711eab --- /dev/null +++ b/vendor/nikic/php-parser/README.md @@ -0,0 +1,78 @@ +PHP Parser +========== + +This is a PHP 5.5 (and older) parser written in PHP. It's purpose is to simplify static code analysis and +manipulation. + +Documentation can be found in the [`doc/`][1] directory. + +***Note: This project is experimental, so the API is subject to change.*** + +In a Nutshell +------------- + +Basically, the parser does nothing more than turn some PHP code into an abstract syntax tree. ("nothing +more" is kind of sarcastic here as PHP has a ... uhm, let's just say "not nice" ... grammar, which makes +parsing PHP very hard.) + +For example, if you stick this code in the parser: + +```php +=5.2" + }, + "autoload": { + "psr-0": { "PHPParser": "lib/" } + }, + "extra": { + "branch-alias": { + "dev-master": "0.9-dev" + } + } +} diff --git a/vendor/nikic/php-parser/doc/0_Introduction.markdown b/vendor/nikic/php-parser/doc/0_Introduction.markdown new file mode 100755 index 0000000..d4b0b7b --- /dev/null +++ b/vendor/nikic/php-parser/doc/0_Introduction.markdown @@ -0,0 +1,81 @@ +Introduction +============ + +This project is a PHP 5.5 (and older) parser **written in PHP itself**. + +What is this for? +----------------- + +A parser is useful for [static analysis][0] and manipulation of code and basically any other +application dealing with code programmatically. A parser constructs an [Abstract Syntax Tree][1] +(AST) of the code and thus allows dealing with it in an abstract and robust way. + +There are other ways of dealing with source code. One that PHP supports natively is using the +token stream generated by [`token_get_all`][2]. The token stream is much more low level than +the AST and thus has different applications: It allows to also analyze the exact formatting of +a file. On the other hand the token stream is much harder to deal with for more complex analysis. +For example an AST abstracts away the fact that in PHP variables can be written as `$foo`, but also +as `$$bar`, `${'foobar'}` or even `${!${''}=barfoo()}`. You don't have to worry about recognizing +all the different syntaxes from a stream of tokens. + +Another questions is: Why would I want to have a PHP parser *written in PHP*? Well, PHP might not be +a language especially suited for fast parsing, but processing the AST is much easier in PHP than it +would be in other, faster languages like C. Furthermore the people most probably wanting to do +programmatic PHP code analysis are incidentally PHP developers, not C developers. + +What can it parse? +------------------ + +The parser uses a PHP 5.5 compliant grammar, which is backwards compatible with at least PHP 5.4, PHP 5.3 +and PHP 5.2 (and maybe older). + +As the parser is based on the tokens returned by `token_get_all` (which is only able to lex the PHP +version it runs on), additionally a wrapper for emulating new tokens from 5.3, 5.4 and 5.5 is provided. This +allows to parse PHP 5.5 source code running on PHP 5.2, for example. This emulation is very hacky and not +yet perfect, but it should work well on any sane code. + +What output does it produce? +---------------------------- + +The parser produces an [Abstract Syntax Tree][1] (AST) also known as a node tree. How this looks like +can best be seen in an example. The program `parse($code); +} catch (PHPParser_Error $e) { + echo 'Parse Error: ', $e->getMessage(); +} +``` + +The `parse` method will return an array of statement nodes (`$stmts`). + +### Emulative lexer + +Instead of `PHPParser_Lexer` one can also use `PHPParser_Lexer_Emulative`. This class will emulate tokens +of newer PHP versions and as such allow parsing PHP 5.5 on PHP 5.2, for example. So if you want to parse +PHP code of newer versions than the one you are running, you should use the emulative lexer. + +Node tree +--------- + +If you use the above code with `$code = "subNodeName`. The `Stmt_Echo` node has only one subnode `exprs`. So in order to access it +in the above example you would write `$stmts[0]->exprs`. If you wanted to access name of the function +call, you would write `$stmts[0]->exprs[1]->name`. + +All nodes also define a `getType()` method that returns the node type (the type is the class name +without the `PHPParser_Node_` prefix). + +It is possible to associate custom metadata with a node using the `setAttribute()` method. This data +can then be retrieved using `hasAttribute()`, `getAttribute()` and `getAttributes()`. + +By default the lexer adds the `startLine`, `endLine` and `comments` attributes. `comments` is an array +of `PHPParser_Comment[_Doc]` instances. + +The start line can also be accessed using `getLine()`/`setLine()` (instead of `getAttribute('startLine')`). +The last doc comment from the `comments` attribute can be obtained using `getDocComment()`. + +Pretty printer +-------------- + +The pretty printer component compiles the AST back to PHP code. As the parser does not retain formatting +information the formatting is done using a specified scheme. Currently there is only one scheme available, +namely `PHPParser_PrettyPrinter_Default`. + +```php +parse($code); + + // change + $stmts[0] // the echo statement + ->exprs // sub expressions + [0] // the first of them (the string node) + ->value // it's value, i.e. 'Hi ' + = 'Hallo '; // change to 'Hallo ' + + // pretty print + $code = 'prettyPrint($stmts); + + echo $code; +} catch (PHPParser_Error $e) { + echo 'Parse Error: ', $e->getMessage(); +} +``` + +The above code will output: + + parse`, then changed and then +again converted to code using `PHPParser_PrettyPrinter_Default->prettyPrint`. + +The `prettyPrint` method pretty prints a statements array. It is also possible to pretty print only a +single expression using `prettyPrintExpr`. + +Node traversation +----------------- + +The above pretty printing example used the fact that the source code was known and thus it was easy to +write code that accesses a certain part of a node tree and changes it. Normally this is not the case. +Usually you want to change / analyze code in a generic way, where you don't know how the node tree is +going to look like. + +For this purpose the parser provides a component for traversing and visiting the node tree. The basic +structure of a program using this `PHPParser_NodeTraverser` looks like this: + +```php +addVisitor(new MyNodeVisitor); + +try { + // parse + $stmts = $parser->parse($code); + + // traverse + $stmts = $traverser->traverse($stmts); + + // pretty print + $code = 'prettyPrint($stmts); + + echo $code; +} catch (PHPParser_Error $e) { + echo 'Parse Error: ', $e->getMessage(); +} +``` + +A same node visitor for this code might look like this: + +```php +value = 'foo'; + } + } +} +``` + +The above node visitor would change all string literals in the program to `'foo'`. + +All visitors must implement the `PHPParser_NodeVisitor` interface, which defined the following four +methods: + + public function beforeTraverse(array $nodes); + public function enterNode(PHPParser_Node $node); + public function leaveNode(PHPParser_Node $node); + public function afterTraverse(array $nodes); + +The `beforeTraverse` method is called once before the traversal begins and is passed the nodes the +traverser was called with. This method can be used for resetting values before traversation or +preparing the tree for traversal. + +The `afterTraverse` method is similar to the `beforeTraverse` method, with the only difference that +it is called once after the traversal. + +The `enterNode` and `leaveNode` methods are called on every node, the former when it is entered, +i.e. before its subnodes are traversed, the latter when it is left. + +All four methods can either return the changed node or not return at all (i.e. `null`) in which +case the current node is not changed. The `leaveNode` method can furthermore return two special +values: If `false` is returned the current node will be removed from the parent array. If an `array` +is returned the current node will be merged into the parent array at the offset of the current node. +I.e. if in `array(A, B, C)` the node `B` should be replaced with `array(X, Y, Z)` the result will be +`array(A, X, Y, Z, C)`. + +Instead of manually implementing the `NodeVisitor` interface you can also extend the `NodeVisitorAbstract` +class, which will define empty default implementations for all the above methods. + +The NameResolver node visitor +----------------------------- + +One visitor is already bundled with the package: `PHPParser_NodeVisitor_NameResolver`. This visitor +helps you work with namespaced code by trying to resolve most names to fully qualified ones. + +For example, consider the following code: + + use A as B; + new B\C(); + +In order to know that `B\C` really is `A\C` you would need to track aliases and namespaces yourself. +The `NameResolver` takes care of that and resolves names as far as possible. + +After running it most names will be fully qualified. The only names that will stay unqualified are +unqualified function and constant names. These are resolved at runtime and thus the visitor can't +know which function they are referring to. In most cases this is a non-issue as the global functions +are meant. + +Also the `NameResolver` adds a `namespacedName` subnode to class, function and constant declarations +that contains the namespaced name instead of only the shortname that is available via `name`. + +Example: Converting namespaced code to pseudo namespaces +-------------------------------------------------------- + +A small example to understand the concept: We want to convert namespaced code to pseudo namespaces +so it works on 5.2, i.e. names like `A\\B` should be converted to `A_B`. Note that such conversions +are fairly complicated if you take PHP's dynamic features into account, so our conversion will +assume that no dynamic features are used. + +We start off with the following base code: + +```php +addVisitor(new PHPParser_NodeVisitor_NameResolver); // we will need resolved names +$traverser->addVisitor(new NodeVisitor_NamespaceConverter); // our own node visitor + +// iterate over all .php files in the directory +$files = new RecursiveIteratorIterator(new RecursiveDirectoryIterator(IN_DIR)); +$files = new RegexIterator($files, '/\.php$/'); + +foreach ($files as $file) { + try { + // read the file that should be converted + $code = file_get_contents($file); + + // parse + $stmts = $parser->parse($code); + + // traverse + $stmts = $traverser->traverse($stmts); + + // pretty print + $code = 'prettyPrint($stmts); + + // write the converted file to the target directory + file_put_contents( + substr_replace($file->getPathname(), OUT_DIR, 0, strlen(IN_DIR)), + $code + ); + } catch (PHPParser_Error $e) { + echo 'Parse Error: ', $e->getMessage(); + } +} +``` + +Now lets start with the main code, the `NodeVisitor_NamespaceConverter`. One thing it needs to do +is convert `A\\B` style names to `A_B` style ones. + +```php +toString('_')); + } + } +} +``` + +The above code profits from the fact that the `NameResolver` already resolved all names as far as +possible, so we don't need to do that. All the need to create a string with the name parts separated +by underscores instead of backslashes. This is what `$node->toString('_')` does. (If you want to +create a name with backslashes either write `$node->toString()` or `(string) $node`.) Then we create +a new name from the string and return it. Returning a new node replaces the old node. + +Another thing we need to do is change the class/function/const declarations. Currently they contain +only the shortname (i.e. the last part of the name), but they need to contain the complete class +name: + +```php +toString('_')); + } elseif ($node instanceof PHPParser_Node_Stmt_Class + || $node instanceof PHPParser_Node_Stmt_Interface + || $node instanceof PHPParser_Node_Stmt_Function) { + $node->name = $node->namespacedName->toString('_'); + } elseif ($node instanceof PHPParser_Node_Stmt_Const) { + foreach ($node->consts as $const) { + $const->name = $const->namespacedName->toString('_'); + } + } + } +} +``` + +There is not much more to it than converting the namespaced name to string with `_` as separator. + +The last thing we need to do is remove the `namespace` and `use` statements: + +```php +toString('_')); + } elseif ($node instanceof PHPParser_Node_Stmt_Class + || $node instanceof PHPParser_Node_Stmt_Interface + || $node instanceof PHPParser_Node_Stmt_Function) { + $node->name = $node->namespacedName->toString('_'); + } elseif ($node instanceof PHPParser_Node_Stmt_Const) { + foreach ($node->consts as $const) { + $const->name = $const->namespacedName->toString('_'); + } + } elseif ($node instanceof PHPParser_Node_Stmt_Namespace) { + // returning an array merges is into the parent array + return $node->stmts; + } elseif ($node instanceof PHPParser_Node_Stmt_Use) { + // returning false removed the node altogether + return false; + } + } +} +``` + +That's all. \ No newline at end of file diff --git a/vendor/nikic/php-parser/doc/3_Other_node_tree_representations.markdown b/vendor/nikic/php-parser/doc/3_Other_node_tree_representations.markdown new file mode 100755 index 0000000..e4fc080 --- /dev/null +++ b/vendor/nikic/php-parser/doc/3_Other_node_tree_representations.markdown @@ -0,0 +1,201 @@ +Other node tree representations +=============================== + +It is possible to convert the AST in several textual representations, which serve different uses. + +Simple serialization +-------------------- + +It is possible to serialize the node tree using `serialize()` and also unserialize it using +`unserialize()`. The output is not human readable and not easily processable from anything +but PHP, but it is compact and generates fast. The main application thus is in caching. + +Human readable dumping +---------------------- + +Furthermore it is possible to dump nodes into a human readable form using the `dump` method of +`PHPParser_NodeDumper`. This can be used for debugging. + +```php +parse($code); + + echo '
    ' . htmlspecialchars($nodeDumper->dump($stmts)) . '
    '; +} catch (PHPParser_Error $e) { + echo 'Parse Error: ', $e->getMessage(); +} +``` + +The above output will have an output looking roughly like this: + +``` +array( + 0: Stmt_Function( + byRef: false + params: array( + 0: Param( + name: msg + default: null + type: null + byRef: false + ) + ) + stmts: array( + 0: Stmt_Echo( + exprs: array( + 0: Expr_Variable( + name: msg + ) + 1: Scalar_String( + value: + + ) + ) + ) + ) + name: printLine + ) + 1: Expr_FuncCall( + name: Name( + parts: array( + 0: printLine + ) + ) + args: array( + 0: Arg( + value: Scalar_String( + value: Hallo World!!! + ) + byRef: false + ) + ) + ) +) +``` + +Serialization to XML +-------------------- + +It is also possible to serialize the node tree to XML using `PHPParser_Serializer_XML->serialize()` +and to unserialize it using `PHPParser_Unserializer_XML->unserialize()`. This is useful for +interfacing with other languages and applications or for doing transformation using XSLT. + +```php +parse($code); + + echo '
    ' . htmlspecialchars($serializer->serialize($stmts)) . '
    '; +} catch (PHPParser_Error $e) { + echo 'Parse Error: ', $e->getMessage(); +} +``` + +Produces: + +```xml + + + + + + + + + + + + msg + + + + + + + + + + + + + + + + + + + + + msg + + + + + + + + + + + + + + + printLine + + + + + + + + printLine + + + + + + + + + + + Hallo World!!! + + + + + + + + + + + + +``` \ No newline at end of file diff --git a/vendor/nikic/php-parser/doc/4_Code_generation.markdown b/vendor/nikic/php-parser/doc/4_Code_generation.markdown new file mode 100755 index 0000000..9541573 --- /dev/null +++ b/vendor/nikic/php-parser/doc/4_Code_generation.markdown @@ -0,0 +1,265 @@ +Code generation +=============== + +It is also possible to generate code using the parser, by first creating an Abstract Syntax Tree and then using the +pretty printer to convert it to PHP code. To simplify code generation, the project comes with a set of builders for +common structures as well as simple templating support. Both features are described in the following: + +Builders +-------- + +The project provides builders for classes, interfaces, methods, functions, parameters and properties, which +allow creating node trees with a fluid interface, instead of instantiating all nodes manually. + +Here is an example: + +```php +class('SomeClass') + ->extend('SomeOtherClass') + ->implement('A\Few', 'Interfaces') + ->makeAbstract() // ->makeFinal() + + ->addStmt($factory->method('someMethod') + ->makeAbstract() // ->makeFinal() + ->addParam($factory->param('someParam')->setTypeHint('SomeClass')) + ) + + ->addStmt($factory->method('anotherMethod') + ->makeProtected() // ->makePublic() [default], ->makePrivate() + ->addParam($factory->param('someParam')->setDefault('test')) + // it is possible to add manually created nodes + ->addStmt(new PHPParser_Node_Expr_Print(new PHPParser_Node_Expr_Variable('someParam'))) + ) + + // properties will be correctly reordered above the methods + ->addStmt($factory->property('someProperty')->makeProtected()) + ->addStmt($factory->property('anotherProperty')->makePrivate()->setDefault(array(1, 2, 3))) + + ->getNode() +; + +$stmts = array($node); +echo $prettyPrinter->prettyPrint($stmts); +``` + +This will produce the following output with the default pretty printer: + +```php +__name__; + } + + /** + * Sets the __name__. + * + * @param __type__ $__name__ The new __name__ + */ + public function set__Name__($__name__) { + $this->__name__ = $__name__; + } +} +``` + +Using this template we can easily create a class with multiple properties and their respective getters and setters: + +```php + 'title', 'type' => 'string'], + ['name' => 'body', 'type' => 'string'], + ['name' => 'author', 'type' => 'User'], + ['name' => 'timestamp', 'type' => 'DateTime'], +]; + +$class = $factory->class('BlogPost')->implement('Post'); + +foreach ($properties as $propertyPlaceholders) { + $stmts = $template->getStmts($propertyPlaceholders); + + $class->addStmts( + // $stmts contains all statements from the template. So [0] fetches the class statement + // and ->stmts retrieves the methods. + $stmts[0]->stmts + ); +} + +echo $prettyPrinter->prettyPrint(array($class->getNode())); +``` + +The result would look roughly like this: + +```php +title; + } + + /** + * Sets the title. + * + * @param string $title The new title + */ + public function setTitle($title) + { + $this->title = $title; + } + + /** + * Gets the body. + * + * @return string The body + */ + public function getBody() + { + return $this->body; + } + + /** + * Sets the body. + * + * @param string $body The new body + */ + public function setBody($body) + { + $this->body = $body; + } + + /** + * Gets the author. + * + * @return User The author + */ + public function getAuthor() + { + return $this->author; + } + + /** + * Sets the author. + * + * @param User $author The new author + */ + public function setAuthor($author) + { + $this->author = $author; + } + + /** + * Gets the timestamp. + * + * @return DateTime The timestamp + */ + public function getTimestamp() + { + return $this->timestamp; + } + + /** + * Sets the timestamp. + * + * @param DateTime $timestamp The new timestamp + */ + public function setTimestamp($timestamp) + { + $this->timestamp = $timestamp; + } +} +``` + +When using multiple templates it is easier to manage them on the filesystem. They can be loaded using the +`TemplateLoader`: + +```php +load('GetterSetter'); + +// loads ./templates/Collection.php +$collectionTemplate = $loader->load('Collection'); + +// The use of a suffix is optional. The following code for example is equivalent: +$loader = new PHPParser_TemplateLoader($parser, './templates'); + +// loads ./templates/GetterSetter.php +$getterSetterTemplate = $loader->load('GetterSetter.php'); + +// loads ./templates/Collection.php +$collectionTemplate = $loader->load('Collection.php'); +``` \ No newline at end of file diff --git a/vendor/nikic/php-parser/doc/component/Lexer.markdown b/vendor/nikic/php-parser/doc/component/Lexer.markdown new file mode 100755 index 0000000..cfdea4b --- /dev/null +++ b/vendor/nikic/php-parser/doc/component/Lexer.markdown @@ -0,0 +1,114 @@ +Lexer component documentation +============================= + +The lexer is responsible for providing tokens to the parser. The project comes with two lexers: `PHPParser_Lexer` and +`PHPParser_Lexer_Emulative`. The latter is an extension of the former, which adds the ability to emulate tokens of +newer PHP versions and thus allows parsing of new code on older versions. + +A lexer has to define the following public interface: + + startLexing($code); + getNextToken(&$value = null, &$startAttributes = null, &$endAttributes = null); + handleHaltCompiler(); + +startLexing +----------- + +The `startLexing` method is invoked when the `parse()` method of the parser is called. It's argument will be whatever +was passed to the `parse()` method. + +Even though `startLexing` is meant to accept a source code string, you could for example overwrite it to accept a file: + +```php +parse('someFile.php')); +var_dump($parser->parse('someOtherFile.php')); +``` + +getNextToken +------------ + +`getNextToken` returns the ID of the next token and sets some additional information in the three variables which it +accepts by-ref. If no more tokens are available it has to return `0`, which is the ID of the `EOF` token. + +The first by-ref variable `$value` should contain the textual content of the token. It is what will be available as `$1` +etc in the parser. + +The other two by-ref variables `$startAttributes` and `$endAttributes` define which attributes will eventually be +assigned to the generated nodes: The parser will take the `$startAttributes` from the first token which is part of the +node and the `$endAttributes` from the last token that is part of the node. + +E.g. if the tokens `T_FUNCTION T_STRING ... '{' ... '}'` constitute a node, then the `$startAttributes` from the +`T_FUNCTION` token will be taken and the `$endAttributes` from the `'}'` token. + +By default the lexer creates the attributes `startLine`, `comments` (both part of `$startAttributes`) and `endLine` +(part of `$endAttributes`). + +If you don't want all these attributes to be added (to reduce memory usage of the AST) you can simply remove them by +overriding the method: + +```php +fileName = $fileName; + parent::startLexing(file_get_contents($fileName)); + } + + public function getNextToken(&$value = null, &$startAttributes = null, &$endAttributes = null) { + $tokenId = parent::getNextToken($value, $startAttributes, $endAttributes); + + // we could use either $startAttributes or $endAttributes here, because the fileName is always the same + // (regardless of whether it is the start or end token). We choose $endAttributes, because it is slightly + // more efficient (as the parser has to keep a stack for the $startAttributes). + $endAttributes['fileName'] = $fileName; + + return $tokenId; + } +} +``` + +handleHaltCompiler +------------------ + +The method is invoked whenever a `T_HALT_COMPILER` token is encountered. It has to return the remaining string after the +construct (not including `();`). \ No newline at end of file diff --git a/vendor/nikic/php-parser/grammar/README.md b/vendor/nikic/php-parser/grammar/README.md new file mode 100755 index 0000000..b39b13f --- /dev/null +++ b/vendor/nikic/php-parser/grammar/README.md @@ -0,0 +1,29 @@ +What do all those files mean? +============================= + + * `zend_language_parser.phpy`: PHP grammer written in a pseudo language + * `analyze.php`: Analyzes the `.phpy`-grammer and outputs some info about it + * `rebuildParser.php`: Preprocesses the `.phpy`-grammar and builds the parser using `kmyacc` + * `kmyacc.php.parser`: A `kmyacc` parser prototype file for PHP + +.phpy pseudo language +===================== + +The `.phpy` file is a normal grammer in `kmyacc` (`yacc`) style, with some transformations +applied to it: + + * Nodes are created using the syntax `Name[..., ...]`. This is transformed into + `new PHPParser_Node_Name(..., ..., $attributes)` + * `Name::abc` is transformed to `PHPParser_Node_Name::abc` + * Some function-like constructs are resolved (see `rebuildParser.php` for a list) + * Associative arrays are written as `[key: value, ...]`, which is transformed to + `array('key' => value, ...)` + +Building the parser +=================== + +In order to rebuild the parser, you need [moriyoshi's fork of kmyacc](https://github.com/moriyoshi/kmyacc-forked). +After you compiled/installed it, run the `rebuildParser.php` script. + +By default only the `Parser.php` is built. If you want to additionally build `Parser/Debug.php` and `y.output` run the +script with `--debug`. If you want to retain the preprocessed grammar pass `--keep-tmp-grammar`. \ No newline at end of file diff --git a/vendor/nikic/php-parser/grammar/analyze.php b/vendor/nikic/php-parser/grammar/analyze.php new file mode 100755 index 0000000..50101df --- /dev/null +++ b/vendor/nikic/php-parser/grammar/analyze.php @@ -0,0 +1,96 @@ +\'[^\\\\\']*+(?:\\\\.[^\\\\\']*+)*+\') + (?"[^\\\\"]*+(?:\\\\.[^\\\\"]*+)*+") + (?(?&singleQuotedString)|(?&doubleQuotedString)) + (?/\*[^*]*+(?:\*(?!/)[^*]*+)*+\*/) + (?\{[^\'"/{}]*+(?:(?:(?&string)|(?&comment)|(?&code)|/)[^\'"/{}]*+)*+}) +)'; + +const RULE_BLOCK = '(?[a-z_]++):(?[^\'"/{};]*+(?:(?:(?&string)|(?&comment)|(?&code)|/|})[^\'"/{};]*+)*+);'; + +$usedTerminals = array_flip(array( + 'T_VARIABLE', 'T_STRING', 'T_INLINE_HTML', 'T_ENCAPSED_AND_WHITESPACE', + 'T_LNUMBER', 'T_DNUMBER', 'T_CONSTANT_ENCAPSED_STRING', 'T_STRING_VARNAME', 'T_NUM_STRING' +)); +$unusedNonterminals = array_flip(array( + 'case_separator', 'optional_comma' +)); + +function regex($regex) { + return '~' . LIB . '(?:' . str_replace('~', '\~', $regex) . ')~'; +} + +function magicSplit($regex, $string) { + $pieces = preg_split(regex('(?:(?&string)|(?&comment)|(?&code))(*SKIP)(*FAIL)|' . $regex), $string); + + foreach ($pieces as &$piece) { + $piece = trim($piece); + } + + return array_filter($pieces); +} + +echo '
    ';
    +
    +////////////////////
    +////////////////////
    +////////////////////
    +
    +list($defs, $ruleBlocks) = magicSplit('%%', file_get_contents(GRAMMAR_FILE));
    +
    +if ('' !== trim(preg_replace(regex(RULE_BLOCK), '', $ruleBlocks))) {
    +    die('Not all rule blocks were properly recognized!');
    +}
    +
    +preg_match_all(regex(RULE_BLOCK), $ruleBlocks, $ruleBlocksMatches, PREG_SET_ORDER);
    +foreach ($ruleBlocksMatches as $match) {
    +    $ruleBlockName = $match['name'];
    +    $rules = magicSplit('\|', $match['rules']);
    +
    +    foreach ($rules as &$rule) {
    +        $parts = magicSplit('\s+', $rule);
    +        $usedParts = array();
    +
    +        foreach ($parts as $part) {
    +            if ('{' === $part[0]) {
    +                preg_match_all('~\$([0-9]+)~', $part, $backReferencesMatches, PREG_SET_ORDER);
    +                foreach ($backReferencesMatches as $match) {
    +                    $usedParts[$match[1]] = true;
    +                }
    +            }
    +        }
    +
    +        $i = 1;
    +        foreach ($parts as &$part) {
    +            if ('/' === $part[0]) {
    +                continue;
    +            }
    +
    +            if (isset($usedParts[$i])) {
    +                if ('\'' === $part[0] || '{' === $part[0]
    +                    || (ctype_upper($part[0]) && !isset($usedTerminals[$part]))
    +                    || (ctype_lower($part[0]) && isset($unusedNonterminals[$part]))
    +                ) {
    +                    $part = '' . $part . '';
    +                } else {
    +                    $part = '' . $part . '';
    +                }
    +            } elseif ((ctype_upper($part[0]) && isset($usedTerminals[$part]))
    +                      || (ctype_lower($part[0]) && !isset($unusedNonterminals[$part]))
    +
    +            ) {
    +                $part = '' . $part . '';
    +            }
    +
    +            ++$i;
    +        }
    +
    +        $rule = implode(' ', $parts);
    +    }
    +
    +    echo $ruleBlockName, ':', "\n", '      ', implode("\n" . '    | ', $rules), "\n", ';', "\n\n";
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/grammar/kmyacc.php.parser b/vendor/nikic/php-parser/grammar/kmyacc.php.parser
    new file mode 100755
    index 0000000..757c752
    --- /dev/null
    +++ b/vendor/nikic/php-parser/grammar/kmyacc.php.parser
    @@ -0,0 +1,361 @@
    +yyval
    +#semval($,%t) $this->yyval
    +#semval(%n) $this->yyastk[$this->stackPos-(%l-%n)]
    +#semval(%n,%t) $this->yyastk[$this->stackPos-(%l-%n)]
    +#include;
    +
    +/* This is an automatically GENERATED file, which should not be manually edited.
    + * Instead edit one of the following:
    + *  * the grammar file grammar/zend_language_parser.phpy
    + *  * the parser skeleton grammar/kymacc.php.parser
    + *  * the preprocessing script grammar/rebuildParser.php
    + *
    + * The skeleton for this parser was written by Moriyoshi Koizumi and is based on
    + * the work by Masato Bito and is in the PUBLIC DOMAIN.
    + */
    +#if -t
    +class #(-p)_Debug extends #(-p)
    +#endif
    +#ifnot -t
    +class #(-p)
    +#endif
    +{
    +#ifnot -t
    +    const TOKEN_NONE    = -1;
    +    const TOKEN_INVALID = #(YYBADCH);
    +
    +    const TOKEN_MAP_SIZE = #(YYMAXLEX);
    +
    +    const YYLAST       = #(YYLAST);
    +    const YY2TBLSTATE  = #(YY2TBLSTATE);
    +    const YYGLAST      = #(YYGLAST);
    +    const YYNLSTATES   = #(YYNLSTATES);
    +    const YYUNEXPECTED = #(YYUNEXPECTED);
    +    const YYDEFAULT    = #(YYDEFAULT);
    +
    +    // {{{ Tokens
    +#tokenval
    +    const %s = %n;
    +#endtokenval
    +    // }}}
    +
    +    /* @var array Map of token ids to their respective names */
    +    protected static $terminals = array(
    +        #listvar terminals
    +        , "???"
    +    );
    +
    +    /* @var array Map which translates lexer tokens to internal tokens */
    +    protected static $translate = array(
    +        #listvar yytranslate
    +    );
    +
    +    protected static $yyaction = array(
    +        #listvar yyaction
    +    );
    +
    +    protected static $yycheck = array(
    +        #listvar yycheck
    +    );
    +
    +    protected static $yybase = array(
    +        #listvar yybase
    +    );
    +
    +    protected static $yydefault = array(
    +        #listvar yydefault
    +    );
    +
    +    protected static $yygoto = array(
    +        #listvar yygoto
    +    );
    +
    +    protected static $yygcheck = array(
    +        #listvar yygcheck
    +    );
    +
    +    protected static $yygbase = array(
    +        #listvar yygbase
    +    );
    +
    +    protected static $yygdefault = array(
    +        #listvar yygdefault
    +    );
    +
    +    protected static $yylhs = array(
    +        #listvar yylhs
    +    );
    +
    +    protected static $yylen = array(
    +        #listvar yylen
    +    );
    +
    +    protected $yyval;
    +    protected $yyastk;
    +    protected $stackPos;
    +    protected $lexer;
    +
    +    /**
    +     * Creates a parser instance.
    +     *
    +     * @param PHPParser_Lexer $lexer A lexer
    +     */
    +    public function __construct(PHPParser_Lexer $lexer) {
    +        $this->lexer = $lexer;
    +    }
    +#endif
    +#if -t
    +    protected static $yyproduction = array(
    +        #production-strings;
    +    );
    +
    +    protected function yyprintln($msg) {
    +        echo $msg, "\n";
    +    }
    +
    +    protected function YYTRACE_NEWSTATE($state, $tokenId) {
    +        $this->yyprintln(
    +            '% State ' . $state
    +          . ', Lookahead ' . ($tokenId == self::TOKEN_NONE ? '--none--' : self::$terminals[$tokenId])
    +        );
    +    }
    +
    +    protected function YYTRACE_READ($tokenId) {
    +        $this->yyprintln('% Reading ' . self::$terminals[$tokenId]);
    +    }
    +
    +    protected function YYTRACE_SHIFT($tokenId) {
    +        $this->yyprintln('% Shift ' . self::$terminals[$tokenId]);
    +    }
    +
    +    protected function YYTRACE_ACCEPT() {
    +        $this->yyprintln('% Accepted.');
    +    }
    +
    +    protected function YYTRACE_REDUCE($n) {
    +        $this->yyprintln('% Reduce by (' . $n . ') ' . self::$yyproduction[$n]);
    +    }
    +
    +    protected function YYTRACE_POP($state) {
    +        $this->yyprintln('% Recovering, uncovers state ' . $state);
    +    }
    +
    +    protected function YYTRACE_DISCARD($tokenId) {
    +        $this->yyprintln('% Discard ' . self::$terminals[$tokenId]);
    +    }
    +#endif
    +
    +    /**
    +#ifnot -t
    +     * Parses PHP code into a node tree.
    +#endif
    +#if -t
    +     * Parses PHP code into a node tree and prints out debugging information.
    +#endif
    +     *
    +     * @param string $code The source code to parse
    +     *
    +     * @return PHPParser_Node[] Array of statements
    +     */
    +    public function parse($code) {
    +        $this->lexer->startLexing($code);
    +
    +        // We start off with no lookahead-token
    +        $tokenId = self::TOKEN_NONE;
    +
    +        // The attributes for a node are taken from the first and last token of the node.
    +        // From the first token only the startAttributes are taken and from the last only
    +        // the endAttributes. Both are merged using the array union operator (+).
    +        $startAttributes = array('startLine' => 1);
    +        $endAttributes   = array();
    +
    +        // In order to figure out the attributes for the starting token, we have to keep
    +        // them in a stack
    +        $attributeStack = array($startAttributes);
    +
    +        // Start off in the initial state and keep a stack of previous states
    +        $state = 0;
    +        $stateStack = array($state);
    +
    +        // AST stack (?)
    +        $this->yyastk = array();
    +
    +        // Current position in the stack(s)
    +        $this->stackPos = 0;
    +
    +        for (;;) {
    +#if -t
    +            $this->YYTRACE_NEWSTATE($state, $tokenId);
    +
    +#endif
    +            if (self::$yybase[$state] == 0) {
    +                $yyn = self::$yydefault[$state];
    +            } else {
    +                if ($tokenId === self::TOKEN_NONE) {
    +                    // Fetch the next token id from the lexer and fetch additional info by-ref.
    +                    // The end attributes are fetched into a temporary variable and only set once the token is really
    +                    // shifted (not during read). Otherwise you would sometimes get off-by-one errors, when a rule is
    +                    // reduced after a token was read but not yet shifted.
    +                    $origTokenId = $this->lexer->getNextToken($tokenValue, $startAttributes, $nextEndAttributes);
    +
    +                    // map the lexer token id to the internally used token id's
    +                    $tokenId = $origTokenId >= 0 && $origTokenId < self::TOKEN_MAP_SIZE
    +                        ? self::$translate[$origTokenId]
    +                        : self::TOKEN_INVALID;
    +
    +                    if ($tokenId === self::TOKEN_INVALID) {
    +                        throw new RangeException(sprintf(
    +                            'The lexer returned an invalid token (id=%d, value=%s)',
    +                            $origTokenId, $tokenValue
    +                        ));
    +                    }
    +
    +                    $attributeStack[$this->stackPos] = $startAttributes;
    +#if -t
    +
    +                    $this->YYTRACE_READ($tokenId);
    +#endif
    +                }
    +
    +                if ((($yyn = self::$yybase[$state] + $tokenId) >= 0
    +                     && $yyn < self::YYLAST && self::$yycheck[$yyn] == $tokenId
    +                     || ($state < self::YY2TBLSTATE
    +                        && ($yyn = self::$yybase[$state + self::YYNLSTATES] + $tokenId) >= 0
    +                        && $yyn < self::YYLAST
    +                        && self::$yycheck[$yyn] == $tokenId))
    +                    && ($yyn = self::$yyaction[$yyn]) != self::YYDEFAULT) {
    +                    /*
    +                     * >= YYNLSTATE: shift and reduce
    +                     * > 0: shift
    +                     * = 0: accept
    +                     * < 0: reduce
    +                     * = -YYUNEXPECTED: error
    +                     */
    +                    if ($yyn > 0) {
    +                        /* shift */
    +#if -t
    +                        $this->YYTRACE_SHIFT($tokenId);
    +
    +#endif
    +                        ++$this->stackPos;
    +
    +                        $stateStack[$this->stackPos]     = $state = $yyn;
    +                        $this->yyastk[$this->stackPos]   = $tokenValue;
    +                        $attributeStack[$this->stackPos] = $startAttributes;
    +                        $endAttributes = $nextEndAttributes;
    +                        $tokenId = self::TOKEN_NONE;
    +
    +                        if ($yyn < self::YYNLSTATES)
    +                            continue;
    +
    +                        /* $yyn >= YYNLSTATES means shift-and-reduce */
    +                        $yyn -= self::YYNLSTATES;
    +                    } else {
    +                        $yyn = -$yyn;
    +                    }
    +                } else {
    +                    $yyn = self::$yydefault[$state];
    +                }
    +            }
    +
    +            for (;;) {
    +                /* reduce/error */
    +                if ($yyn == 0) {
    +                    /* accept */
    +#if -t
    +                    $this->YYTRACE_ACCEPT();
    +#endif
    +                    return $this->yyval;
    +                } elseif ($yyn != self::YYUNEXPECTED) {
    +                    /* reduce */
    +#if -t
    +                    $this->YYTRACE_REDUCE($yyn);
    +#endif
    +                    try {
    +                        $this->{'yyn' . $yyn}(
    +                            $attributeStack[$this->stackPos - self::$yylen[$yyn]]
    +                            + $endAttributes
    +                        );
    +                    } catch (PHPParser_Error $e) {
    +                        if (-1 === $e->getRawLine()) {
    +                            $e->setRawLine($startAttributes['startLine']);
    +                        }
    +
    +                        throw $e;
    +                    }
    +
    +                    /* Goto - shift nonterminal */
    +                    $this->stackPos -= self::$yylen[$yyn];
    +                    $yyn = self::$yylhs[$yyn];
    +                    if (($yyp = self::$yygbase[$yyn] + $stateStack[$this->stackPos]) >= 0
    +                         && $yyp < self::YYGLAST
    +                         && self::$yygcheck[$yyp] == $yyn) {
    +                        $state = self::$yygoto[$yyp];
    +                    } else {
    +                        $state = self::$yygdefault[$yyn];
    +                    }
    +
    +                    ++$this->stackPos;
    +
    +                    $stateStack[$this->stackPos]     = $state;
    +                    $this->yyastk[$this->stackPos]   = $this->yyval;
    +                    $attributeStack[$this->stackPos] = $startAttributes;
    +                } else {
    +                    /* error */
    +                    $expected = array();
    +
    +                    $base = self::$yybase[$state];
    +                    for ($i = 0; $i < self::TOKEN_MAP_SIZE; ++$i) {
    +                        $n = $base + $i;
    +                        if ($n >= 0 && $n < self::YYLAST && self::$yycheck[$n] == $i
    +                         || $state < self::YY2TBLSTATE
    +                            && ($n = self::$yybase[$state + self::YYNLSTATES] + $i) >= 0
    +                            && $n < self::YYLAST && self::$yycheck[$n] == $i
    +                        ) {
    +                            if (self::$yyaction[$n] != self::YYUNEXPECTED) {
    +                                if (count($expected) == 4) {
    +                                    /* Too many expected tokens */
    +                                    $expected = array();
    +                                    break;
    +                                }
    +
    +                                $expected[] = self::$terminals[$i];
    +                            }
    +                        }
    +                    }
    +
    +                    $expectedString = '';
    +                    if ($expected) {
    +                        $expectedString = ', expecting ' . implode(' or ', $expected);
    +                    }
    +
    +                    throw new PHPParser_Error(
    +                        'Syntax error, unexpected ' . self::$terminals[$tokenId] . $expectedString,
    +                        $startAttributes['startLine']
    +                    );
    +                }
    +
    +                if ($state < self::YYNLSTATES)
    +                    break;
    +                /* >= YYNLSTATES means shift-and-reduce */
    +                $yyn = $state - self::YYNLSTATES;
    +            }
    +        }
    +    }
    +#ifnot -t
    +#reduce
    +
    +    protected function yyn%n($attributes) {
    +        %b
    +    }
    +#noact
    +
    +    protected function yyn%n() {
    +        $this->yyval = $this->yyastk[$this->stackPos];
    +    }
    +#endreduce
    +#endif
    +}
    +#tailcode;
    diff --git a/vendor/nikic/php-parser/grammar/rebuildParser.php b/vendor/nikic/php-parser/grammar/rebuildParser.php
    new file mode 100755
    index 0000000..0aa1f8b
    --- /dev/null
    +++ b/vendor/nikic/php-parser/grammar/rebuildParser.php
    @@ -0,0 +1,225 @@
    +\'[^\\\\\']*+(?:\\\\.[^\\\\\']*+)*+\')
    +    (?"[^\\\\"]*+(?:\\\\.[^\\\\"]*+)*+")
    +    (?(?&singleQuotedString)|(?&doubleQuotedString))
    +    (?/\*[^*]*+(?:\*(?!/)[^*]*+)*+\*/)
    +    (?\{[^\'"/{}]*+(?:(?:(?&string)|(?&comment)|(?&code)|/)[^\'"/{}]*+)*+})
    +)';
    +
    +const PARAMS = '\[(?[^[\]]*+(?:\[(?¶ms)\][^[\]]*+)*+)\]';
    +const ARGS   = '\((?[^()]*+(?:\((?&args)\)[^()]*+)*+)\)';
    +
    +///////////////////
    +/// Main script ///
    +///////////////////
    +
    +echo 'Building temporary preproprocessed grammar file.', "\n";
    +
    +$grammarCode = file_get_contents($grammarFile);
    +
    +$grammarCode = resolveConstants($grammarCode);
    +$grammarCode = resolveNodes($grammarCode);
    +$grammarCode = resolveMacros($grammarCode);
    +$grammarCode = resolveArrays($grammarCode);
    +
    +file_put_contents($tmpGrammarFile, $grammarCode);
    +
    +echo "Building parser.\n";
    +$output = trim(shell_exec("$kmyacc -l -m $skeletonFile -p PHPParser_Parser $tmpGrammarFile 2>&1"));
    +echo "Output: \"$output\"\n";
    +
    +moveFileWithDirCheck($tmpResultFile, $parserResultFile);
    +
    +if ($optionDebug) {
    +    echo "Building debug parser.\n";
    +    $output = trim(shell_exec("$kmyacc -t -v -l -m $skeletonFile -p PHPParser_Parser $tmpGrammarFile 2>&1"));
    +    echo "Output: \"$output\"\n";
    +
    +    moveFileWithDirCheck($tmpResultFile, $debugParserResultFile);
    +}
    +
    +if (!$optionKeepTmpGrammar) {
    +    unlink($tmpGrammarFile);
    +}
    +
    +///////////////////////////////
    +/// Preprocessing functions ///
    +///////////////////////////////
    +
    +function resolveConstants($code) {
    +    return preg_replace('~[A-Z][a-zA-Z_]++::~', 'PHPParser_Node_$0', $code);
    +}
    +
    +function resolveNodes($code) {
    +    return preg_replace_callback(
    +        '~(?[A-Z][a-zA-Z_]++)\s*' . PARAMS . '~',
    +        function($matches) {
    +            // recurse
    +            $matches['params'] = resolveNodes($matches['params']);
    +
    +            $params = magicSplit(
    +                '(?:' . PARAMS . '|' . ARGS . ')(*SKIP)(*FAIL)|,',
    +                $matches['params']
    +            );
    +
    +            $paramCode = '';
    +            foreach ($params as $param) {
    +                $paramCode .= $param . ', ';
    +            }
    +
    +            return 'new PHPParser_Node_' . $matches['name'] . '(' . $paramCode . '$attributes)';
    +        },
    +        $code
    +    );
    +}
    +
    +function resolveMacros($code) {
    +    return preg_replace_callback(
    +        '~\b(?)(?!array\()(?[a-z][A-Za-z]++)' . ARGS . '~',
    +        function($matches) {
    +            // recurse
    +            $matches['args'] = resolveMacros($matches['args']);
    +
    +            $name = $matches['name'];
    +            $args = magicSplit(
    +                '(?:' . PARAMS . '|' . ARGS . ')(*SKIP)(*FAIL)|,',
    +                $matches['args']
    +            );
    +
    +            if ('error' == $name) {
    +                assertArgs(1, $args, $name);
    +
    +                return 'throw new PHPParser_Error(' . $args[0] . ')';
    +            }
    +
    +            if ('init' == $name) {
    +                return '$$ = array(' . implode(', ', $args) . ')';
    +            }
    +
    +            if ('push' == $name) {
    +                assertArgs(2, $args, $name);
    +
    +                return $args[0] . '[] = ' . $args[1] . '; $$ = ' . $args[0];
    +            }
    +
    +            if ('pushNormalizing' == $name) {
    +                assertArgs(2, $args, $name);
    +
    +                return 'if (is_array(' . $args[1] . ')) { $$ = array_merge(' . $args[0] . ', ' . $args[1] . '); } else { ' . $args[0] . '[] = ' . $args[1] . '; $$ = ' . $args[0] . '; }';
    +            }
    +
    +            if ('toArray' == $name) {
    +                assertArgs(1, $args, $name);
    +
    +                return 'is_array(' . $args[0] . ') ? ' . $args[0] . ' : array(' . $args[0] . ')';
    +            }
    +
    +            if ('parseVar' == $name) {
    +                assertArgs(1, $args, $name);
    +
    +                return 'substr(' . $args[0] . ', 1)';
    +            }
    +
    +            if ('parseEncapsed' == $name) {
    +                assertArgs(2, $args, $name);
    +
    +                return 'foreach (' . $args[0] . ' as &$s) { if (is_string($s)) { $s = PHPParser_Node_Scalar_String::parseEscapeSequences($s, ' . $args[1] . '); } }';
    +            }
    +
    +            if ('parseEncapsedDoc' == $name) {
    +                assertArgs(1, $args, $name);
    +
    +                return 'foreach (' . $args[0] . ' as &$s) { if (is_string($s)) { $s = PHPParser_Node_Scalar_String::parseEscapeSequences($s, null); } } $s = preg_replace(\'~(\r\n|\n|\r)$~\', \'\', $s); if (\'\' === $s) array_pop(' . $args[0] . ');';
    +            }
    +
    +            throw new Exception(sprintf('Unknown macro "%s"', $name));
    +        },
    +        $code
    +    );
    +}
    +
    +function assertArgs($num, $args, $name) {
    +    if ($num != count($args)) {
    +        die('Wrong argument count for ' . $name . '().');
    +    }
    +}
    +
    +function resolveArrays($code) {
    +    return preg_replace_callback(
    +        '~' . PARAMS . '~',
    +        function ($matches) {
    +            $elements = magicSplit(
    +                '(?:' . PARAMS . '|' . ARGS . ')(*SKIP)(*FAIL)|,',
    +                $matches['params']
    +            );
    +
    +            // don't convert [] to array, it might have different meaning
    +            if (empty($elements)) {
    +                return $matches[0];
    +            }
    +
    +            $elementCodes = array();
    +            foreach ($elements as $element) {
    +                // convert only arrays where all elements have keys
    +                if (false === strpos($element, ':')) {
    +                    return $matches[0];
    +                }
    +
    +                list($key, $value) = explode(':', $element, 2);
    +                $elementCodes[] = "'" . $key . "' =>" . $value;
    +            }
    +
    +            return 'array(' . implode(', ', $elementCodes) . ')';
    +        },
    +        $code
    +    );
    +}
    +
    +function moveFileWithDirCheck($fromPath, $toPath) {
    +    $dir = dirname($toPath);
    +    if (!is_dir($dir)) {
    +        mkdir($dir, 0777, true);
    +    }
    +    rename($fromPath, $toPath);
    +}
    +
    +//////////////////////////////
    +/// Regex helper functions ///
    +//////////////////////////////
    +
    +function regex($regex) {
    +    return '~' . LIB . '(?:' . str_replace('~', '\~', $regex) . ')~';
    +}
    +
    +function magicSplit($regex, $string) {
    +    $pieces = preg_split(regex('(?:(?&string)|(?&comment)|(?&code))(*SKIP)(*FAIL)|' . $regex), $string);
    +
    +    foreach ($pieces as &$piece) {
    +        $piece = trim($piece);
    +    }
    +
    +    return array_filter($pieces);
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/grammar/zend_language_parser.phpy b/vendor/nikic/php-parser/grammar/zend_language_parser.phpy
    new file mode 100755
    index 0000000..85d72b2
    --- /dev/null
    +++ b/vendor/nikic/php-parser/grammar/zend_language_parser.phpy
    @@ -0,0 +1,906 @@
    +%pure_parser
    +%expect 2
    +
    +%left T_INCLUDE T_INCLUDE_ONCE T_EVAL T_REQUIRE T_REQUIRE_ONCE
    +%left ','
    +%left T_LOGICAL_OR
    +%left T_LOGICAL_XOR
    +%left T_LOGICAL_AND
    +%right T_PRINT
    +%right T_YIELD
    +%left '=' T_PLUS_EQUAL T_MINUS_EQUAL T_MUL_EQUAL T_DIV_EQUAL T_CONCAT_EQUAL T_MOD_EQUAL T_AND_EQUAL T_OR_EQUAL T_XOR_EQUAL T_SL_EQUAL T_SR_EQUAL
    +%left '?' ':'
    +%left T_BOOLEAN_OR
    +%left T_BOOLEAN_AND
    +%left '|'
    +%left '^'
    +%left '&'
    +%nonassoc T_IS_EQUAL T_IS_NOT_EQUAL T_IS_IDENTICAL T_IS_NOT_IDENTICAL
    +%nonassoc '<' T_IS_SMALLER_OR_EQUAL '>' T_IS_GREATER_OR_EQUAL
    +%left T_SL T_SR
    +%left '+' '-' '.'
    +%left '*' '/' '%'
    +%right '!'
    +%nonassoc T_INSTANCEOF
    +%right '~' T_INC T_DEC T_INT_CAST T_DOUBLE_CAST T_STRING_CAST T_ARRAY_CAST T_OBJECT_CAST T_BOOL_CAST T_UNSET_CAST '@'
    +%right '['
    +%nonassoc T_NEW T_CLONE
    +%token T_EXIT
    +%token T_IF
    +%left T_ELSEIF
    +%left T_ELSE
    +%left T_ENDIF
    +%token T_LNUMBER
    +%token T_DNUMBER
    +%token T_STRING
    +%token T_STRING_VARNAME
    +%token T_VARIABLE
    +%token T_NUM_STRING
    +%token T_INLINE_HTML
    +%token T_CHARACTER
    +%token T_BAD_CHARACTER
    +%token T_ENCAPSED_AND_WHITESPACE
    +%token T_CONSTANT_ENCAPSED_STRING
    +%token T_ECHO
    +%token T_DO
    +%token T_WHILE
    +%token T_ENDWHILE
    +%token T_FOR
    +%token T_ENDFOR
    +%token T_FOREACH
    +%token T_ENDFOREACH
    +%token T_DECLARE
    +%token T_ENDDECLARE
    +%token T_AS
    +%token T_SWITCH
    +%token T_ENDSWITCH
    +%token T_CASE
    +%token T_DEFAULT
    +%token T_BREAK
    +%token T_CONTINUE
    +%token T_GOTO
    +%token T_FUNCTION
    +%token T_CONST
    +%token T_RETURN
    +%token T_TRY
    +%token T_CATCH
    +%token T_FINALLY
    +%token T_THROW
    +%token T_USE
    +%token T_INSTEADOF
    +%token T_GLOBAL
    +%right T_STATIC T_ABSTRACT T_FINAL T_PRIVATE T_PROTECTED T_PUBLIC
    +%token T_VAR
    +%token T_UNSET
    +%token T_ISSET
    +%token T_EMPTY
    +%token T_HALT_COMPILER
    +%token T_CLASS
    +%token T_TRAIT
    +%token T_INTERFACE
    +%token T_EXTENDS
    +%token T_IMPLEMENTS
    +%token T_OBJECT_OPERATOR
    +%token T_DOUBLE_ARROW
    +%token T_LIST
    +%token T_ARRAY
    +%token T_CALLABLE
    +%token T_CLASS_C
    +%token T_TRAIT_C
    +%token T_METHOD_C
    +%token T_FUNC_C
    +%token T_LINE
    +%token T_FILE
    +%token T_COMMENT
    +%token T_DOC_COMMENT
    +%token T_OPEN_TAG
    +%token T_OPEN_TAG_WITH_ECHO
    +%token T_CLOSE_TAG
    +%token T_WHITESPACE
    +%token T_START_HEREDOC
    +%token T_END_HEREDOC
    +%token T_DOLLAR_OPEN_CURLY_BRACES
    +%token T_CURLY_OPEN
    +%token T_PAAMAYIM_NEKUDOTAYIM
    +%token T_NAMESPACE
    +%token T_NS_C
    +%token T_DIR
    +%token T_NS_SEPARATOR
    +
    +%%
    +
    +start:
    +    top_statement_list                                      { $$ = Stmt_Namespace::postprocess($1); }
    +;
    +
    +top_statement_list:
    +      top_statement_list top_statement                      { pushNormalizing($1, $2); }
    +    | /* empty */                                           { init(); }
    +;
    +
    +namespace_name:
    +      T_STRING                                              { init($1); }
    +    | namespace_name T_NS_SEPARATOR T_STRING                { push($1, $3); }
    +;
    +
    +top_statement:
    +      statement                                             { $$ = $1; }
    +    | function_declaration_statement                        { $$ = $1; }
    +    | class_declaration_statement                           { $$ = $1; }
    +    | T_HALT_COMPILER
    +          { $$ = Stmt_HaltCompiler[$this->lexer->handleHaltCompiler()]; }
    +    | T_NAMESPACE namespace_name ';'                        { $$ = Stmt_Namespace[Name[$2], null]; }
    +    | T_NAMESPACE namespace_name '{' top_statement_list '}' { $$ = Stmt_Namespace[Name[$2], $4]; }
    +    | T_NAMESPACE '{' top_statement_list '}'                { $$ = Stmt_Namespace[null,     $3]; }
    +    | T_USE use_declarations ';'                            { $$ = Stmt_Use[$2]; }
    +    | T_CONST constant_declaration_list ';'                 { $$ = Stmt_Const[$2]; }
    +;
    +
    +use_declarations:
    +      use_declarations ',' use_declaration                  { push($1, $3); }
    +    | use_declaration                                       { init($1); }
    +;
    +
    +use_declaration:
    +      namespace_name                                        { $$ = Stmt_UseUse[Name[$1], null]; }
    +    | namespace_name T_AS T_STRING                          { $$ = Stmt_UseUse[Name[$1], $3]; }
    +    | T_NS_SEPARATOR namespace_name                         { $$ = Stmt_UseUse[Name[$2], null]; }
    +    | T_NS_SEPARATOR namespace_name T_AS T_STRING           { $$ = Stmt_UseUse[Name[$2], $4]; }
    +;
    +
    +constant_declaration_list:
    +      constant_declaration_list ',' constant_declaration    { push($1, $3); }
    +    | constant_declaration                                  { init($1); }
    +;
    +
    +constant_declaration:
    +    T_STRING '=' static_scalar                              { $$ = Const[$1, $3]; }
    +;
    +
    +inner_statement_list:
    +      inner_statement_list inner_statement                  { pushNormalizing($1, $2); }
    +    | /* empty */                                           { init(); }
    +;
    +
    +inner_statement:
    +      statement                                             { $$ = $1; }
    +    | function_declaration_statement                        { $$ = $1; }
    +    | class_declaration_statement                           { $$ = $1; }
    +    | T_HALT_COMPILER                                       { error('__halt_compiler() can only be used from the outermost scope'); }
    +;
    +
    +statement:
    +      '{' inner_statement_list '}'                          { $$ = $2; }
    +    | T_IF parentheses_expr statement elseif_list else_single
    +          { $$ = Stmt_If[$2, [stmts: toArray($3), elseifs: $4, else: $5]]; }
    +    | T_IF parentheses_expr ':' inner_statement_list new_elseif_list new_else_single T_ENDIF ';'
    +          { $$ = Stmt_If[$2, [stmts: $4, elseifs: $5, else: $6]]; }
    +    | T_WHILE parentheses_expr while_statement              { $$ = Stmt_While[$2, $3]; }
    +    | T_DO statement T_WHILE parentheses_expr ';'           { $$ = Stmt_Do   [$4, toArray($2)]; }
    +    | T_FOR '(' for_expr ';'  for_expr ';' for_expr ')' for_statement
    +          { $$ = Stmt_For[[init: $3, cond: $5, loop: $7, stmts: $9]]; }
    +    | T_SWITCH parentheses_expr switch_case_list            { $$ = Stmt_Switch[$2, $3]; }
    +    | T_BREAK ';'                                           { $$ = Stmt_Break[null]; }
    +    | T_BREAK expr ';'                                      { $$ = Stmt_Break[$2]; }
    +    | T_CONTINUE ';'                                        { $$ = Stmt_Continue[null]; }
    +    | T_CONTINUE expr ';'                                   { $$ = Stmt_Continue[$2]; }
    +    | T_RETURN ';'                                          { $$ = Stmt_Return[null]; }
    +    | T_RETURN expr ';'                                     { $$ = Stmt_Return[$2]; }
    +    | yield_expr ';'                                        { $$ = $1; }
    +    | T_GLOBAL global_var_list ';'                          { $$ = Stmt_Global[$2]; }
    +    | T_STATIC static_var_list ';'                          { $$ = Stmt_Static[$2]; }
    +    | T_ECHO expr_list ';'                                  { $$ = Stmt_Echo[$2]; }
    +    | T_INLINE_HTML                                         { $$ = Stmt_InlineHTML[$1]; }
    +    | expr ';'                                              { $$ = $1; }
    +    | T_UNSET '(' variables_list ')' ';'                    { $$ = Stmt_Unset[$3]; }
    +    | T_FOREACH '(' expr T_AS foreach_variable ')' foreach_statement
    +          { $$ = Stmt_Foreach[$3, $5[0], [keyVar: null, byRef: $5[1], stmts: $7]]; }
    +    | T_FOREACH '(' expr T_AS variable T_DOUBLE_ARROW foreach_variable ')' foreach_statement
    +          { $$ = Stmt_Foreach[$3, $7[0], [keyVar: $5, byRef: $7[1], stmts: $9]]; }
    +    | T_DECLARE '(' declare_list ')' declare_statement      { $$ = Stmt_Declare[$3, $5]; }
    +    | ';'                                                   { $$ = array(); /* means: no statement */ }
    +    | T_TRY '{' inner_statement_list '}' catches optional_finally
    +          { $$ = Stmt_TryCatch[$3, $5, $6]; }
    +    | T_THROW expr ';'                                      { $$ = Stmt_Throw[$2]; }
    +    | T_GOTO T_STRING ';'                                   { $$ = Stmt_Goto[$2]; }
    +    | T_STRING ':'                                          { $$ = Stmt_Label[$1]; }
    +;
    +
    +catches:
    +      /* empty */                                           { init(); }
    +    | catches catch                                         { push($1, $2); }
    +;
    +
    +catch:
    +    T_CATCH '(' name T_VARIABLE ')' '{' inner_statement_list '}'
    +        { $$ = Stmt_Catch[$3, parseVar($4), $7]; }
    +;
    +
    +optional_finally:
    +      /* empty */                                           { $$ = null; }
    +    | T_FINALLY '{' inner_statement_list '}'                { $$ = $3; }
    +;
    +
    +variables_list:
    +      variable                                              { init($1); }
    +    | variables_list ',' variable                           { push($1, $3); }
    +;
    +
    +optional_ref:
    +      /* empty */                                           { $$ = false; }
    +    | '&'                                                   { $$ = true; }
    +;
    +
    +function_declaration_statement:
    +    T_FUNCTION optional_ref T_STRING '(' parameter_list ')' '{' inner_statement_list '}'
    +        { $$ = Stmt_Function[$3, [byRef: $2, params: $5, stmts: $8]]; }
    +;
    +
    +class_declaration_statement:
    +      class_entry_type T_STRING extends_from implements_list '{' class_statement_list '}'
    +          { $$ = Stmt_Class[$2, [type: $1, extends: $3, implements: $4, stmts: $6]]; }
    +    | T_INTERFACE T_STRING interface_extends_list '{' class_statement_list '}'
    +          { $$ = Stmt_Interface[$2, [extends: $3, stmts: $5]]; }
    +    | T_TRAIT T_STRING '{' class_statement_list '}'
    +          { $$ = Stmt_Trait[$2, $4]; }
    +;
    +
    +class_entry_type:
    +      T_CLASS                                               { $$ = 0; }
    +    | T_ABSTRACT T_CLASS                                    { $$ = Stmt_Class::MODIFIER_ABSTRACT; }
    +    | T_FINAL T_CLASS                                       { $$ = Stmt_Class::MODIFIER_FINAL; }
    +;
    +
    +extends_from:
    +      /* empty */                                           { $$ = null; }
    +    | T_EXTENDS name                                        { $$ = $2; }
    +;
    +
    +interface_extends_list:
    +      /* empty */                                           { $$ = array(); }
    +    | T_EXTENDS name_list                                   { $$ = $2; }
    +;
    +
    +implements_list:
    +      /* empty */                                           { $$ = array(); }
    +    | T_IMPLEMENTS name_list                                { $$ = $2; }
    +;
    +
    +name_list:
    +      name                                                  { init($1); }
    +    | name_list ',' name                                    { push($1, $3); }
    +;
    +
    +for_statement:
    +      statement                                             { $$ = toArray($1); }
    +    | ':' inner_statement_list T_ENDFOR ';'                 { $$ = $2; }
    +;
    +
    +foreach_statement:
    +      statement                                             { $$ = toArray($1); }
    +    | ':' inner_statement_list T_ENDFOREACH ';'             { $$ = $2; }
    +;
    +
    +declare_statement:
    +      statement                                             { $$ = toArray($1); }
    +    | ':' inner_statement_list T_ENDDECLARE ';'             { $$ = $2; }
    +;
    +
    +declare_list:
    +      declare_list_element                                  { init($1); }
    +    | declare_list ',' declare_list_element                 { push($1, $3); }
    +;
    +
    +declare_list_element:
    +      T_STRING '=' static_scalar                            { $$ = Stmt_DeclareDeclare[$1, $3]; }
    +;
    +
    +switch_case_list:
    +      '{' case_list '}'                                     { $$ = $2; }
    +    | '{' ';' case_list '}'                                 { $$ = $3; }
    +    | ':' case_list T_ENDSWITCH ';'                         { $$ = $2; }
    +    | ':' ';' case_list T_ENDSWITCH ';'                     { $$ = $3; }
    +;
    +
    +case_list:
    +      /* empty */                                           { init(); }
    +    | case_list case                                        { push($1, $2); }
    +;
    +
    +case:
    +      T_CASE expr case_separator inner_statement_list       { $$ = Stmt_Case[$2, $4]; }
    +    | T_DEFAULT case_separator inner_statement_list         { $$ = Stmt_Case[null, $3]; }
    +;
    +
    +case_separator:
    +      ':'
    +    | ';'
    +;
    +
    +while_statement:
    +      statement                                             { $$ = toArray($1); }
    +    | ':' inner_statement_list T_ENDWHILE ';'               { $$ = $2; }
    +;
    +
    +elseif_list:
    +      /* empty */                                           { init(); }
    +    | elseif_list elseif                                    { push($1, $2); }
    +;
    +
    +elseif:
    +      T_ELSEIF parentheses_expr statement                   { $$ = Stmt_ElseIf[$2, toArray($3)]; }
    +;
    +
    +new_elseif_list:
    +      /* empty */                                           { init(); }
    +    | new_elseif_list new_elseif                            { push($1, $2); }
    +;
    +
    +new_elseif:
    +     T_ELSEIF parentheses_expr ':' inner_statement_list     { $$ = Stmt_ElseIf[$2, $4]; }
    +;
    +
    +else_single:
    +      /* empty */                                           { $$ = null; }
    +    | T_ELSE statement                                      { $$ = Stmt_Else[toArray($2)]; }
    +;
    +
    +new_else_single:
    +      /* empty */                                           { $$ = null; }
    +    | T_ELSE ':' inner_statement_list                       { $$ = Stmt_Else[$3]; }
    +;
    +
    +foreach_variable:
    +      variable                                              { $$ = array($1, false); }
    +    | '&' variable                                          { $$ = array($2, true); }
    +    | list_expr                                             { $$ = array($1, false); }
    +;
    +
    +parameter_list:
    +      non_empty_parameter_list                              { $$ = $1; }
    +    | /* empty */                                           { $$ = array(); }
    +;
    +
    +non_empty_parameter_list:
    +      parameter                                             { init($1); }
    +    | non_empty_parameter_list ',' parameter                { push($1, $3); }
    +;
    +
    +parameter:
    +      optional_class_type optional_ref T_VARIABLE
    +          { $$ = Param[parseVar($3), null, $1, $2]; }
    +    | optional_class_type optional_ref T_VARIABLE '=' static_scalar
    +          { $$ = Param[parseVar($3), $5, $1, $2]; }
    +;
    +
    +optional_class_type:
    +      /* empty */                                           { $$ = null; }
    +    | name                                                  { $$ = $1; }
    +    | T_ARRAY                                               { $$ = 'array'; }
    +    | T_CALLABLE                                            { $$ = 'callable'; }
    +;
    +
    +argument_list:
    +      '(' ')'                                               { $$ = array(); }
    +    | '(' non_empty_argument_list ')'                       { $$ = $2; }
    +    | '(' yield_expr ')'                                    { $$ = array(Arg[$2, false]); }
    +;
    +
    +non_empty_argument_list:
    +      argument                                              { init($1); }
    +    | non_empty_argument_list ',' argument                  { push($1, $3); }
    +;
    +
    +argument:
    +      expr                                                  { $$ = Arg[$1, false]; }
    +    | '&' variable                                          { $$ = Arg[$2, true]; }
    +;
    +
    +global_var_list:
    +      global_var_list ',' global_var                        { push($1, $3); }
    +    | global_var                                            { init($1); }
    +;
    +
    +global_var:
    +      T_VARIABLE                                            { $$ = Expr_Variable[parseVar($1)]; }
    +    | '$' variable                                          { $$ = Expr_Variable[$2]; }
    +    | '$' '{' expr '}'                                      { $$ = Expr_Variable[$3]; }
    +;
    +
    +static_var_list:
    +      static_var_list ',' static_var                        { push($1, $3); }
    +    | static_var                                            { init($1); }
    +;
    +
    +static_var:
    +      T_VARIABLE                                            { $$ = Stmt_StaticVar[parseVar($1), null]; }
    +    | T_VARIABLE '=' static_scalar                          { $$ = Stmt_StaticVar[parseVar($1), $3]; }
    +;
    +
    +class_statement_list:
    +      class_statement_list class_statement                  { push($1, $2); }
    +    | /* empty */                                           { init(); }
    +;
    +
    +class_statement:
    +      variable_modifiers property_declaration_list ';'      { $$ = Stmt_Property[$1, $2]; }
    +    | T_CONST constant_declaration_list ';'                 { $$ = Stmt_ClassConst[$2]; }
    +    | method_modifiers T_FUNCTION optional_ref T_STRING '(' parameter_list ')' method_body
    +          { $$ = Stmt_ClassMethod[$4, [type: $1, byRef: $3, params: $6, stmts: $8]]; }
    +    | T_USE name_list trait_adaptations                     { $$ = Stmt_TraitUse[$2, $3]; }
    +;
    +
    +trait_adaptations:
    +      ';'                                                   { $$ = array(); }
    +    | '{' trait_adaptation_list '}'                         { $$ = $2; }
    +;
    +
    +trait_adaptation_list:
    +      /* empty */                                           { init(); }
    +    | trait_adaptation_list trait_adaptation                { push($1, $2); }
    +;
    +
    +trait_adaptation:
    +      trait_method_reference_fully_qualified T_INSTEADOF name_list ';'
    +          { $$ = Stmt_TraitUseAdaptation_Precedence[$1[0], $1[1], $3]; }
    +    | trait_method_reference T_AS member_modifier T_STRING ';'
    +          { $$ = Stmt_TraitUseAdaptation_Alias[$1[0], $1[1], $3, $4]; }
    +    | trait_method_reference T_AS member_modifier ';'
    +          { $$ = Stmt_TraitUseAdaptation_Alias[$1[0], $1[1], $3, null]; }
    +    | trait_method_reference T_AS T_STRING ';'
    +          { $$ = Stmt_TraitUseAdaptation_Alias[$1[0], $1[1], null, $3]; }
    +;
    +
    +trait_method_reference_fully_qualified:
    +      name T_PAAMAYIM_NEKUDOTAYIM T_STRING                  { $$ = array($1, $3); }
    +;
    +trait_method_reference:
    +      trait_method_reference_fully_qualified                { $$ = $1; }
    +    | T_STRING                                              { $$ = array(null, $1); }
    +;
    +
    +method_body:
    +      ';' /* abstract method */                             { $$ = null; }
    +    | '{' inner_statement_list '}'                          { $$ = $2; }
    +;
    +
    +variable_modifiers:
    +      non_empty_member_modifiers                            { $$ = $1; }
    +    | T_VAR                                                 { $$ = Stmt_Class::MODIFIER_PUBLIC; }
    +;
    +
    +method_modifiers:
    +      /* empty */                                           { $$ = Stmt_Class::MODIFIER_PUBLIC; }
    +    | non_empty_member_modifiers                            { $$ = $1; }
    +;
    +
    +non_empty_member_modifiers:
    +      member_modifier                                       { $$ = $1; }
    +    | non_empty_member_modifiers member_modifier            { Stmt_Class::verifyModifier($1, $2); $$ = $1 | $2; }
    +;
    +
    +member_modifier:
    +      T_PUBLIC                                              { $$ = Stmt_Class::MODIFIER_PUBLIC; }
    +    | T_PROTECTED                                           { $$ = Stmt_Class::MODIFIER_PROTECTED; }
    +    | T_PRIVATE                                             { $$ = Stmt_Class::MODIFIER_PRIVATE; }
    +    | T_STATIC                                              { $$ = Stmt_Class::MODIFIER_STATIC; }
    +    | T_ABSTRACT                                            { $$ = Stmt_Class::MODIFIER_ABSTRACT; }
    +    | T_FINAL                                               { $$ = Stmt_Class::MODIFIER_FINAL; }
    +;
    +
    +property_declaration_list:
    +      property_declaration                                  { init($1); }
    +    | property_declaration_list ',' property_declaration    { push($1, $3); }
    +;
    +
    +property_declaration:
    +      T_VARIABLE                                            { $$ = Stmt_PropertyProperty[parseVar($1), null]; }
    +    | T_VARIABLE '=' static_scalar                          { $$ = Stmt_PropertyProperty[parseVar($1), $3]; }
    +;
    +
    +expr_list:
    +      expr_list ',' expr                                    { push($1, $3); }
    +    | expr                                                  { init($1); }
    +;
    +
    +for_expr:
    +      /* empty */                                           { $$ = array(); }
    +    | expr_list                                             { $$ = $1; }
    +;
    +
    +expr:
    +      variable                                              { $$ = $1; }
    +    | list_expr '=' expr                                    { $$ = Expr_Assign[$1, $3]; }
    +    | variable '=' expr                                     { $$ = Expr_Assign[$1, $3]; }
    +    | variable '=' '&' variable                             { $$ = Expr_AssignRef[$1, $4]; }
    +    | variable '=' '&' new_expr                             { $$ = Expr_AssignRef[$1, $4]; }
    +    | new_expr                                              { $$ = $1; }
    +    | T_CLONE expr                                          { $$ = Expr_Clone[$2]; }
    +    | variable T_PLUS_EQUAL expr                            { $$ = Expr_AssignPlus      [$1, $3]; }
    +    | variable T_MINUS_EQUAL expr                           { $$ = Expr_AssignMinus     [$1, $3]; }
    +    | variable T_MUL_EQUAL expr                             { $$ = Expr_AssignMul       [$1, $3]; }
    +    | variable T_DIV_EQUAL expr                             { $$ = Expr_AssignDiv       [$1, $3]; }
    +    | variable T_CONCAT_EQUAL expr                          { $$ = Expr_AssignConcat    [$1, $3]; }
    +    | variable T_MOD_EQUAL expr                             { $$ = Expr_AssignMod       [$1, $3]; }
    +    | variable T_AND_EQUAL expr                             { $$ = Expr_AssignBitwiseAnd[$1, $3]; }
    +    | variable T_OR_EQUAL expr                              { $$ = Expr_AssignBitwiseOr [$1, $3]; }
    +    | variable T_XOR_EQUAL expr                             { $$ = Expr_AssignBitwiseXor[$1, $3]; }
    +    | variable T_SL_EQUAL expr                              { $$ = Expr_AssignShiftLeft [$1, $3]; }
    +    | variable T_SR_EQUAL expr                              { $$ = Expr_AssignShiftRight[$1, $3]; }
    +    | variable T_INC                                        { $$ = Expr_PostInc[$1]; }
    +    | T_INC variable                                        { $$ = Expr_PreInc [$2]; }
    +    | variable T_DEC                                        { $$ = Expr_PostDec[$1]; }
    +    | T_DEC variable                                        { $$ = Expr_PreDec [$2]; }
    +    | expr T_BOOLEAN_OR expr                                { $$ = Expr_BooleanOr [$1, $3]; }
    +    | expr T_BOOLEAN_AND expr                               { $$ = Expr_BooleanAnd[$1, $3]; }
    +    | expr T_LOGICAL_OR expr                                { $$ = Expr_LogicalOr [$1, $3]; }
    +    | expr T_LOGICAL_AND expr                               { $$ = Expr_LogicalAnd[$1, $3]; }
    +    | expr T_LOGICAL_XOR expr                               { $$ = Expr_LogicalXor[$1, $3]; }
    +    | expr '|' expr                                         { $$ = Expr_BitwiseOr [$1, $3]; }
    +    | expr '&' expr                                         { $$ = Expr_BitwiseAnd[$1, $3]; }
    +    | expr '^' expr                                         { $$ = Expr_BitwiseXor[$1, $3]; }
    +    | expr '.' expr                                         { $$ = Expr_Concat    [$1, $3]; }
    +    | expr '+' expr                                         { $$ = Expr_Plus      [$1, $3]; }
    +    | expr '-' expr                                         { $$ = Expr_Minus     [$1, $3]; }
    +    | expr '*' expr                                         { $$ = Expr_Mul       [$1, $3]; }
    +    | expr '/' expr                                         { $$ = Expr_Div       [$1, $3]; }
    +    | expr '%' expr                                         { $$ = Expr_Mod       [$1, $3]; }
    +    | expr T_SL expr                                        { $$ = Expr_ShiftLeft [$1, $3]; }
    +    | expr T_SR expr                                        { $$ = Expr_ShiftRight[$1, $3]; }
    +    | '+' expr %prec T_INC                                  { $$ = Expr_UnaryPlus [$2]; }
    +    | '-' expr %prec T_INC                                  { $$ = Expr_UnaryMinus[$2]; }
    +    | '!' expr                                              { $$ = Expr_BooleanNot[$2]; }
    +    | '~' expr                                              { $$ = Expr_BitwiseNot[$2]; }
    +    | expr T_IS_IDENTICAL expr                              { $$ = Expr_Identical     [$1, $3]; }
    +    | expr T_IS_NOT_IDENTICAL expr                          { $$ = Expr_NotIdentical  [$1, $3]; }
    +    | expr T_IS_EQUAL expr                                  { $$ = Expr_Equal         [$1, $3]; }
    +    | expr T_IS_NOT_EQUAL expr                              { $$ = Expr_NotEqual      [$1, $3]; }
    +    | expr '<' expr                                         { $$ = Expr_Smaller       [$1, $3]; }
    +    | expr T_IS_SMALLER_OR_EQUAL expr                       { $$ = Expr_SmallerOrEqual[$1, $3]; }
    +    | expr '>' expr                                         { $$ = Expr_Greater       [$1, $3]; }
    +    | expr T_IS_GREATER_OR_EQUAL expr                       { $$ = Expr_GreaterOrEqual[$1, $3]; }
    +    | expr T_INSTANCEOF class_name_reference                { $$ = Expr_Instanceof    [$1, $3]; }
    +    | parentheses_expr                                      { $$ = $1; }
    +    /* we need a separate '(' new_expr ')' rule to avoid problems caused by a s/r conflict */
    +    | '(' new_expr ')'                                      { $$ = $2; }
    +    | expr '?' expr ':' expr                                { $$ = Expr_Ternary[$1, $3,   $5]; }
    +    | expr '?' ':' expr                                     { $$ = Expr_Ternary[$1, null, $4]; }
    +    | T_ISSET '(' variables_list ')'                        { $$ = Expr_Isset[$3]; }
    +    | T_EMPTY '(' expr ')'                                  { $$ = Expr_Empty[$3]; }
    +    | T_INCLUDE expr                                        { $$ = Expr_Include[$2, Expr_Include::TYPE_INCLUDE]; }
    +    | T_INCLUDE_ONCE expr                                   { $$ = Expr_Include[$2, Expr_Include::TYPE_INCLUDE_ONCE]; }
    +    | T_EVAL parentheses_expr                               { $$ = Expr_Eval[$2]; }
    +    | T_REQUIRE expr                                        { $$ = Expr_Include[$2, Expr_Include::TYPE_REQUIRE]; }
    +    | T_REQUIRE_ONCE expr                                   { $$ = Expr_Include[$2, Expr_Include::TYPE_REQUIRE_ONCE]; }
    +    | T_INT_CAST expr                                       { $$ = Expr_Cast_Int     [$2]; }
    +    | T_DOUBLE_CAST expr                                    { $$ = Expr_Cast_Double  [$2]; }
    +    | T_STRING_CAST expr                                    { $$ = Expr_Cast_String  [$2]; }
    +    | T_ARRAY_CAST expr                                     { $$ = Expr_Cast_Array   [$2]; }
    +    | T_OBJECT_CAST expr                                    { $$ = Expr_Cast_Object  [$2]; }
    +    | T_BOOL_CAST expr                                      { $$ = Expr_Cast_Bool    [$2]; }
    +    | T_UNSET_CAST expr                                     { $$ = Expr_Cast_Unset   [$2]; }
    +    | T_EXIT exit_expr                                      { $$ = Expr_Exit         [$2]; }
    +    | '@' expr                                              { $$ = Expr_ErrorSuppress[$2]; }
    +    | scalar                                                { $$ = $1; }
    +    | array_expr                                            { $$ = $1; }
    +    | scalar_dereference                                    { $$ = $1; }
    +    | '`' backticks_expr '`'                                { $$ = Expr_ShellExec[$2]; }
    +    | T_PRINT expr                                          { $$ = Expr_Print[$2]; }
    +    | T_YIELD                                               { $$ = Expr_Yield[null, null]; }
    +    | T_FUNCTION optional_ref '(' parameter_list ')' lexical_vars '{' inner_statement_list '}'
    +          { $$ = Expr_Closure[[static: false, byRef: $2, params: $4, uses: $6, stmts: $8]]; }
    +    | T_STATIC T_FUNCTION optional_ref '(' parameter_list ')' lexical_vars '{' inner_statement_list '}'
    +          { $$ = Expr_Closure[[static: true, byRef: $3, params: $5, uses: $7, stmts: $9]]; }
    +;
    +
    +parentheses_expr:
    +      '(' expr ')'                                          { $$ = $2; }
    +    | '(' yield_expr ')'                                    { $$ = $2; }
    +;
    +
    +yield_expr:
    +      T_YIELD expr                                          { $$ = Expr_Yield[$2, null]; }
    +    | T_YIELD expr T_DOUBLE_ARROW expr                      { $$ = Expr_Yield[$4, $2]; }
    +;
    +
    +array_expr:
    +      T_ARRAY '(' array_pair_list ')'                       { $$ = Expr_Array[$3]; }
    +    | '[' array_pair_list ']'                               { $$ = Expr_Array[$2]; }
    +;
    +
    +scalar_dereference:
    +      array_expr '[' dim_offset ']'                         { $$ = Expr_ArrayDimFetch[$1, $3]; }
    +    | T_CONSTANT_ENCAPSED_STRING '[' dim_offset ']'
    +          { $$ = Expr_ArrayDimFetch[Scalar_String[Scalar_String::parse($1)], $3]; }
    +    | scalar_dereference '[' dim_offset ']'                 { $$ = Expr_ArrayDimFetch[$1, $3]; }
    +    /* alternative array syntax missing intentionally */
    +;
    +
    +new_expr:
    +      T_NEW class_name_reference ctor_arguments             { $$ = Expr_New[$2, $3]; }
    +;
    +
    +lexical_vars:
    +      /* empty */                                           { $$ = array(); }
    +    | T_USE '(' lexical_var_list ')'                        { $$ = $3; }
    +;
    +
    +lexical_var_list:
    +      lexical_var                                           { init($1); }
    +    | lexical_var_list ',' lexical_var                      { push($1, $3); }
    +;
    +
    +lexical_var:
    +      optional_ref T_VARIABLE                               { $$ = Expr_ClosureUse[parseVar($2), $1]; }
    +;
    +
    +function_call:
    +      name argument_list                                    { $$ = Expr_FuncCall[$1, $2]; }
    +    | class_name_or_var T_PAAMAYIM_NEKUDOTAYIM T_STRING argument_list
    +          { $$ = Expr_StaticCall[$1, $3, $4]; }
    +    | class_name_or_var T_PAAMAYIM_NEKUDOTAYIM '{' expr '}' argument_list
    +          { $$ = Expr_StaticCall[$1, $4, $6]; }
    +    | static_property argument_list {
    +            if ($1 instanceof PHPParser_Node_Expr_StaticPropertyFetch) {
    +                $$ = Expr_StaticCall[$1->class, Expr_Variable[$1->name], $2];
    +            } elseif ($1 instanceof PHPParser_Node_Expr_ArrayDimFetch) {
    +                $tmp = $1;
    +                while ($tmp->var instanceof PHPParser_Node_Expr_ArrayDimFetch) {
    +                    $tmp = $tmp->var;
    +                }
    +
    +                $$ = Expr_StaticCall[$tmp->var->class, $1, $2];
    +                $tmp->var = Expr_Variable[$tmp->var->name];
    +            } else {
    +                throw new Exception;
    +            }
    +          }
    +    | variable_without_objects argument_list
    +          { $$ = Expr_FuncCall[$1, $2]; }
    +    | function_call '[' dim_offset ']'                      { $$ = Expr_ArrayDimFetch[$1, $3]; }
    +      /* alternative array syntax missing intentionally */
    +;
    +
    +class_name:
    +      T_STATIC                                              { $$ = Name['static']; }
    +    | name                                                  { $$ = $1; }
    +;
    +
    +name:
    +      namespace_name                                        { $$ = Name[$1]; }
    +    | T_NS_SEPARATOR namespace_name                         { $$ = Name_FullyQualified[$2]; }
    +    | T_NAMESPACE T_NS_SEPARATOR namespace_name             { $$ = Name_Relative[$3]; }
    +;
    +
    +class_name_reference:
    +      class_name                                            { $$ = $1; }
    +    | dynamic_class_name_reference                          { $$ = $1; }
    +;
    +
    +dynamic_class_name_reference:
    +      object_access_for_dcnr                                { $$ = $1; }
    +    | base_variable                                         { $$ = $1; }
    +;
    +
    +class_name_or_var:
    +      class_name                                            { $$ = $1; }
    +    | reference_variable                                    { $$ = $1; }
    +;
    +
    +object_access_for_dcnr:
    +    | base_variable T_OBJECT_OPERATOR object_property
    +          { $$ = Expr_PropertyFetch[$1, $3]; }
    +    | object_access_for_dcnr T_OBJECT_OPERATOR object_property
    +          { $$ = Expr_PropertyFetch[$1, $3]; }
    +    | object_access_for_dcnr '[' dim_offset ']'             { $$ = Expr_ArrayDimFetch[$1, $3]; }
    +    | object_access_for_dcnr '{' expr '}'                   { $$ = Expr_ArrayDimFetch[$1, $3]; }
    +;
    +
    +exit_expr:
    +      /* empty */                                           { $$ = null; }
    +    | '(' ')'                                               { $$ = null; }
    +    | parentheses_expr                                      { $$ = $1; }
    +;
    +
    +backticks_expr:
    +      /* empty */                                           { $$ = array(); }
    +    | T_ENCAPSED_AND_WHITESPACE                             { $$ = array(Scalar_String::parseEscapeSequences($1, '`')); }
    +    | encaps_list                                           { parseEncapsed($1, '`'); $$ = $1; }
    +;
    +
    +ctor_arguments:
    +      /* empty */                                           { $$ = array(); }
    +    | argument_list                                         { $$ = $1; }
    +;
    +
    +common_scalar:
    +      T_LNUMBER                                             { $$ = Scalar_LNumber[Scalar_LNumber::parse($1)]; }
    +    | T_DNUMBER                                             { $$ = Scalar_DNumber[Scalar_DNumber::parse($1)]; }
    +    | T_CONSTANT_ENCAPSED_STRING                            { $$ = Scalar_String[Scalar_String::parse($1)]; }
    +    | T_LINE                                                { $$ = Scalar_LineConst[]; }
    +    | T_FILE                                                { $$ = Scalar_FileConst[]; }
    +    | T_DIR                                                 { $$ = Scalar_DirConst[]; }
    +    | T_CLASS_C                                             { $$ = Scalar_ClassConst[]; }
    +    | T_TRAIT_C                                             { $$ = Scalar_TraitConst[]; }
    +    | T_METHOD_C                                            { $$ = Scalar_MethodConst[]; }
    +    | T_FUNC_C                                              { $$ = Scalar_FuncConst[]; }
    +    | T_NS_C                                                { $$ = Scalar_NSConst[]; }
    +    | T_START_HEREDOC T_ENCAPSED_AND_WHITESPACE T_END_HEREDOC
    +          { $$ = Scalar_String[Scalar_String::parseDocString($1, $2)]; }
    +    | T_START_HEREDOC T_END_HEREDOC
    +          { $$ = Scalar_String['']; }
    +    | name                                                  { $$ = Expr_ConstFetch[$1]; }
    +;
    +
    +static_scalar: /* compile-time evaluated scalars */
    +      common_scalar                                         { $$ = $1; }
    +    | class_name T_PAAMAYIM_NEKUDOTAYIM class_const_name    { $$ = Expr_ClassConstFetch[$1, $3]; }
    +    | '+' static_scalar                                     { $$ = Expr_UnaryPlus[$2]; }
    +    | '-' static_scalar                                     { $$ = Expr_UnaryMinus[$2]; }
    +    | T_ARRAY '(' static_array_pair_list ')'                { $$ = Expr_Array[$3]; }
    +    | '[' static_array_pair_list ']'                        { $$ = Expr_Array[$2]; }
    +;
    +
    +scalar:
    +      common_scalar                                         { $$ = $1; }
    +    | class_name_or_var T_PAAMAYIM_NEKUDOTAYIM class_const_name
    +          { $$ = Expr_ClassConstFetch[$1, $3]; }
    +    | '"' encaps_list '"'
    +          { parseEncapsed($2, '"'); $$ = Scalar_Encapsed[$2]; }
    +    | T_START_HEREDOC encaps_list T_END_HEREDOC
    +          { parseEncapsedDoc($2); $$ = Scalar_Encapsed[$2]; }
    +;
    +
    +class_const_name:
    +      T_STRING                                              { $$ = $1; }
    +    | T_CLASS                                               { $$ = 'class'; }
    +;
    +
    +static_array_pair_list:
    +      /* empty */                                           { $$ = array(); }
    +    | non_empty_static_array_pair_list optional_comma       { $$ = $1; }
    +;
    +
    +optional_comma:
    +      /* empty */
    +    | ','
    +;
    +
    +non_empty_static_array_pair_list:
    +      non_empty_static_array_pair_list ',' static_array_pair { push($1, $3); }
    +    | static_array_pair                                      { init($1); }
    +;
    +
    +static_array_pair:
    +      static_scalar T_DOUBLE_ARROW static_scalar            { $$ = Expr_ArrayItem[$3, $1,   false]; }
    +    | static_scalar                                         { $$ = Expr_ArrayItem[$1, null, false]; }
    +;
    +
    +variable:
    +      object_access                                         { $$ = $1; }
    +    | base_variable                                         { $$ = $1; }
    +    | function_call                                         { $$ = $1; }
    +    | new_expr_array_deref                                  { $$ = $1; }
    +;
    +
    +new_expr_array_deref:
    +      '(' new_expr ')' '[' dim_offset ']'                   { $$ = Expr_ArrayDimFetch[$2, $5]; }
    +    | new_expr_array_deref '[' dim_offset ']'               { $$ = Expr_ArrayDimFetch[$1, $3]; }
    +      /* alternative array syntax missing intentionally */
    +;
    +
    +object_access:
    +      variable_or_new_expr T_OBJECT_OPERATOR object_property
    +          { $$ = Expr_PropertyFetch[$1, $3]; }
    +    | variable_or_new_expr T_OBJECT_OPERATOR object_property argument_list
    +          { $$ = Expr_MethodCall[$1, $3, $4]; }
    +    | object_access argument_list                           { $$ = Expr_FuncCall[$1, $2]; }
    +    | object_access '[' dim_offset ']'                      { $$ = Expr_ArrayDimFetch[$1, $3]; }
    +    | object_access '{' expr '}'                            { $$ = Expr_ArrayDimFetch[$1, $3]; }
    +;
    +
    +variable_or_new_expr:
    +      variable                                              { $$ = $1; }
    +    | '(' new_expr ')'                                      { $$ = $2; }
    +;
    +
    +variable_without_objects:
    +      reference_variable                                    { $$ = $1; }
    +    | '$' variable_without_objects                          { $$ = Expr_Variable[$2]; }
    +;
    +
    +base_variable:
    +      variable_without_objects                              { $$ = $1; }
    +    | static_property                                       { $$ = $1; }
    +;
    +
    +static_property:
    +      class_name_or_var T_PAAMAYIM_NEKUDOTAYIM '$' reference_variable
    +          { $$ = Expr_StaticPropertyFetch[$1, $4]; }
    +    | static_property_with_arrays                           { $$ = $1; }
    +;
    +
    +static_property_with_arrays:
    +      class_name_or_var T_PAAMAYIM_NEKUDOTAYIM T_VARIABLE
    +          { $$ = Expr_StaticPropertyFetch[$1, parseVar($3)]; }
    +    | class_name_or_var T_PAAMAYIM_NEKUDOTAYIM '$' '{' expr '}'
    +          { $$ = Expr_StaticPropertyFetch[$1, $5]; }
    +    | static_property_with_arrays '[' dim_offset ']'        { $$ = Expr_ArrayDimFetch[$1, $3]; }
    +    | static_property_with_arrays '{' expr '}'              { $$ = Expr_ArrayDimFetch[$1, $3]; }
    +;
    +
    +reference_variable:
    +      reference_variable '[' dim_offset ']'                 { $$ = Expr_ArrayDimFetch[$1, $3]; }
    +    | reference_variable '{' expr '}'                       { $$ = Expr_ArrayDimFetch[$1, $3]; }
    +    | T_VARIABLE                                            { $$ = Expr_Variable[parseVar($1)]; }
    +    | '$' '{' expr '}'                                      { $$ = Expr_Variable[$3]; }
    +;
    +
    +dim_offset:
    +      /* empty */                                           { $$ = null; }
    +    | expr                                                  { $$ = $1; }
    +;
    +
    +object_property:
    +      T_STRING                                              { $$ = $1; }
    +    | '{' expr '}'                                          { $$ = $2; }
    +    | variable_without_objects                              { $$ = $1; }
    +;
    +
    +list_expr:
    +      T_LIST '(' list_expr_elements ')'                     { $$ = Expr_List[$3]; }
    +;
    +
    +list_expr_elements:
    +      list_expr_elements ',' list_expr_element              { push($1, $3); }
    +    | list_expr_element                                     { init($1); }
    +;
    +
    +list_expr_element:
    +      variable                                              { $$ = $1; }
    +    | list_expr                                             { $$ = $1; }
    +    | /* empty */                                           { $$ = null; }
    +;
    +
    +array_pair_list:
    +      /* empty */                                           { $$ = array(); }
    +    | non_empty_array_pair_list optional_comma              { $$ = $1; }
    +;
    +
    +non_empty_array_pair_list:
    +      non_empty_array_pair_list ',' array_pair              { push($1, $3); }
    +    | array_pair                                            { init($1); }
    +;
    +
    +array_pair:
    +      expr T_DOUBLE_ARROW expr                              { $$ = Expr_ArrayItem[$3, $1,   false]; }
    +    | expr                                                  { $$ = Expr_ArrayItem[$1, null, false]; }
    +    | expr T_DOUBLE_ARROW '&' variable                      { $$ = Expr_ArrayItem[$4, $1,   true]; }
    +    | '&' variable                                          { $$ = Expr_ArrayItem[$2, null, true]; }
    +;
    +
    +encaps_list:
    +      encaps_list encaps_var                                { push($1, $2); }
    +    | encaps_list T_ENCAPSED_AND_WHITESPACE                 { push($1, $2); }
    +    | encaps_var                                            { init($1); }
    +    | T_ENCAPSED_AND_WHITESPACE encaps_var                  { init($1, $2); }
    +;
    +
    +encaps_var:
    +      T_VARIABLE                                            { $$ = Expr_Variable[parseVar($1)]; }
    +    | T_VARIABLE '[' encaps_var_offset ']'                  { $$ = Expr_ArrayDimFetch[Expr_Variable[parseVar($1)], $3]; }
    +    | T_VARIABLE T_OBJECT_OPERATOR T_STRING                 { $$ = Expr_PropertyFetch[Expr_Variable[parseVar($1)], $3]; }
    +    | T_DOLLAR_OPEN_CURLY_BRACES expr '}'                   { $$ = Expr_Variable[$2]; }
    +    | T_DOLLAR_OPEN_CURLY_BRACES T_STRING_VARNAME '}'       { $$ = Expr_Variable[$2]; }
    +    | T_DOLLAR_OPEN_CURLY_BRACES T_STRING_VARNAME '[' expr ']' '}'
    +          { $$ = Expr_ArrayDimFetch[Expr_Variable[$2], $4]; }
    +    | T_CURLY_OPEN variable '}'                             { $$ = $2; }
    +;
    +
    +encaps_var_offset:
    +      T_STRING                                              { $$ = Scalar_String[$1]; }
    +    | T_NUM_STRING                                          { $$ = Scalar_String[$1]; }
    +    | T_VARIABLE                                            { $$ = Expr_Variable[parseVar($1)]; }
    +;
    +
    +%%
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/Autoloader.php b/vendor/nikic/php-parser/lib/PHPParser/Autoloader.php
    new file mode 100755
    index 0000000..314dffb
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/Autoloader.php
    @@ -0,0 +1,33 @@
    +name = $name;
    +
    +        $this->type = 0;
    +        $this->extends = null;
    +        $this->implements = array();
    +
    +        $this->uses = $this->constants = $this->properties = $this->methods = array();
    +    }
    +
    +    /**
    +     * Extends a class.
    +     *
    +     * @param PHPParser_Node_Name|string $class Name of class to extend
    +     *
    +     * @return PHPParser_Builder_Class The builder instance (for fluid interface)
    +     */
    +    public function extend($class) {
    +        $this->extends = $this->normalizeName($class);
    +
    +        return $this;
    +    }
    +
    +    /**
    +     * Implements one or more interfaces.
    +     *
    +     * @param PHPParser_Node_Name|string $interface Name of interface to implement
    +     * @param PHPParser_Node_Name|string $...       More interfaces to implement
    +     *
    +     * @return PHPParser_Builder_Class The builder instance (for fluid interface)
    +     */
    +    public function implement() {
    +        foreach (func_get_args() as $interface) {
    +            $this->implements[] = $this->normalizeName($interface);
    +        }
    +
    +        return $this;
    +    }
    +
    +    /**
    +     * Makes the class abstract.
    +     *
    +     * @return PHPParser_Builder_Class The builder instance (for fluid interface)
    +     */
    +    public function makeAbstract() {
    +        $this->setModifier(PHPParser_Node_Stmt_Class::MODIFIER_ABSTRACT);
    +
    +        return $this;
    +    }
    +
    +    /**
    +     * Makes the class final.
    +     *
    +     * @return PHPParser_Builder_Class The builder instance (for fluid interface)
    +     */
    +    public function makeFinal() {
    +        $this->setModifier(PHPParser_Node_Stmt_Class::MODIFIER_FINAL);
    +
    +        return $this;
    +    }
    +
    +    /**
    +     * Adds a statement.
    +     *
    +     * @param PHPParser_Node_Stmt|PHPParser_Builder $stmt The statement to add
    +     *
    +     * @return PHPParser_Builder_Class The builder instance (for fluid interface)
    +     */
    +    public function addStmt($stmt) {
    +        $stmt = $this->normalizeNode($stmt);
    +
    +        $targets = array(
    +            'Stmt_TraitUse'    => &$this->uses,
    +            'Stmt_ClassConst'  => &$this->constants,
    +            'Stmt_Property'    => &$this->properties,
    +            'Stmt_ClassMethod' => &$this->methods,
    +        );
    +
    +        $type = $stmt->getType();
    +        if (!isset($targets[$type])) {
    +            throw new LogicException(sprintf('Unexpected node of type "%s"', $type));
    +        }
    +
    +        $targets[$type][] = $stmt;
    +
    +        return $this;
    +    }
    +
    +    /**
    +     * Adds multiple statements.
    +     *
    +     * @param array $stmts The statements to add
    +     *
    +     * @return PHPParser_Builder_Class The builder instance (for fluid interface)
    +     */
    +    public function addStmts(array $stmts) {
    +        foreach ($stmts as $stmt) {
    +            $this->addStmt($stmt);
    +        }
    +
    +        return $this;
    +    }
    +
    +    /**
    +     * Returns the built class node.
    +     *
    +     * @return PHPParser_Node_Stmt_Class The built class node
    +     */
    +    public function getNode() {
    +        return new PHPParser_Node_Stmt_Class($this->name, array(
    +            'type' => $this->type,
    +            'extends' => $this->extends,
    +            'implements' => $this->implements,
    +            'stmts' => array_merge($this->uses, $this->constants, $this->properties, $this->methods),
    +        ));
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/Builder/Function.php b/vendor/nikic/php-parser/lib/PHPParser/Builder/Function.php
    new file mode 100755
    index 0000000..462ad96
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/Builder/Function.php
    @@ -0,0 +1,109 @@
    +name = $name;
    +
    +        $this->returnByRef = false;
    +        $this->params = array();
    +        $this->stmts = array();
    +    }
    +
    +    /**
    +     * Make the function return by reference.
    +     *
    +     * @return PHPParser_Builder_Function The builder instance (for fluid interface)
    +     */
    +    public function makeReturnByRef() {
    +        $this->returnByRef = true;
    +
    +        return $this;
    +    }
    +
    +    /**
    +     * Adds a parameter.
    +     *
    +     * @param PHPParser_Node_Param|PHPParser_Builder_Param $param The parameter to add
    +     *
    +     * @return PHPParser_Builder_Function The builder instance (for fluid interface)
    +     */
    +    public function addParam($param) {
    +        $param = $this->normalizeNode($param);
    +
    +        if (!$param instanceof PHPParser_Node_Param) {
    +            throw new LogicException(sprintf('Expected parameter node, got "%s"', $param->getType()));
    +        }
    +
    +        $this->params[] = $param;
    +
    +        return $this;
    +    }
    +
    +    /**
    +     * Adds multiple parameters.
    +     *
    +     * @param array $params The parameters to add
    +     *
    +     * @return PHPParser_Builder_Function The builder instance (for fluid interface)
    +     */
    +    public function addParams(array $params) {
    +        foreach ($params as $param) {
    +            $this->addParam($param);
    +        }
    +
    +        return $this;
    +    }
    +
    +    /**
    +     * Adds a statement.
    +     *
    +     * @param PHPParser_Node|PHPParser_Builder $stmt The statement to add
    +     *
    +     * @return PHPParser_Builder_Function The builder instance (for fluid interface)
    +     */
    +    public function addStmt($stmt) {
    +        $this->stmts[] = $this->normalizeNode($stmt);
    +
    +        return $this;
    +    }
    +
    +    /**
    +     * Adds multiple statements.
    +     *
    +     * @param array $stmts The statements to add
    +     *
    +     * @return PHPParser_Builder_Function The builder instance (for fluid interface)
    +     */
    +    public function addStmts(array $stmts) {
    +        foreach ($stmts as $stmt) {
    +            $this->addStmt($stmt);
    +        }
    +
    +        return $this;
    +    }
    +
    +    /**
    +     * Returns the built function node.
    +     *
    +     * @return PHPParser_Node_Stmt_Function The built function node
    +     */
    +    public function getNode() {
    +        return new PHPParser_Node_Stmt_Function($this->name, array(
    +            'byRef'  => $this->returnByRef,
    +            'params' => $this->params,
    +            'stmts'  => $this->stmts,
    +        ));
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/Builder/Interface.php b/vendor/nikic/php-parser/lib/PHPParser/Builder/Interface.php
    new file mode 100755
    index 0000000..8c76dc9
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/Builder/Interface.php
    @@ -0,0 +1,92 @@
    +name = $name;
    +        $this->extends = array();
    +        $this->constants = $this->methods = array();
    +    }
    +
    +    /**
    +     * Extends one or more interfaces.
    +     *
    +     * @param PHPParser_Node_Name|string $interface Name of interface to extend
    +     * @param PHPParser_Node_Name|string $...       More interfaces to extend
    +     *
    +     * @return PHPParser_Builder_Interface The builder instance (for fluid interface)
    +     */
    +    public function extend() {
    +        foreach (func_get_args() as $interface) {
    +            $this->extends[] = $this->normalizeName($interface);
    +        }
    +
    +        return $this;
    +    }
    +
    +    /**
    +     * Adds a statement.
    +     *
    +     * @param PHPParser_Node_Stmt|PHPParser_Builder $stmt The statement to add
    +     *
    +     * @return PHPParser_Builder_Interface The builder instance (for fluid interface)
    +     */
    +    public function addStmt($stmt) {
    +        $stmt = $this->normalizeNode($stmt);
    +
    +        $type = $stmt->getType();
    +        switch ($type) {
    +            case 'Stmt_ClassConst':
    +                $this->constants[] = $stmt;
    +                break;
    +
    +            case 'Stmt_ClassMethod':
    +                // we erase all statements in the body of an interface method
    +                $stmt->stmts = null;
    +                $this->methods[] = $stmt;
    +                break;
    +
    +            default:
    +                throw new LogicException(sprintf('Unexpected node of type "%s"', $type));
    +        }
    +
    +        return $this;
    +    }
    +
    +    /**
    +     * Adds multiple statements.
    +     *
    +     * @param array $stmts The statements to add
    +     *
    +     * @return PHPParser_Builder_Class The builder instance (for fluid interface)
    +     */
    +    public function addStmts(array $stmts) {
    +        foreach ($stmts as $stmt) {
    +            $this->addStmt($stmt);
    +        }
    +
    +        return $this;
    +    }
    +
    +    /**
    +     * Returns the built class node.
    +     *
    +     * @return PHPParser_Node_Stmt_Interface The built interface node
    +     */
    +    public function getNode() {
    +        return new PHPParser_Node_Stmt_Interface($this->name, array(
    +            'extends' => $this->extends,
    +            'stmts' => array_merge($this->constants, $this->methods),
    +        ));
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/Builder/Method.php b/vendor/nikic/php-parser/lib/PHPParser/Builder/Method.php
    new file mode 100755
    index 0000000..7244ba5
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/Builder/Method.php
    @@ -0,0 +1,187 @@
    +name = $name;
    +
    +        $this->type = 0;
    +        $this->returnByRef = false;
    +        $this->params = array();
    +        $this->stmts = array();
    +    }
    +
    +    /**
    +     * Makes the method public.
    +     *
    +     * @return PHPParser_Builder_Method The builder instance (for fluid interface)
    +     */
    +    public function makePublic() {
    +        $this->setModifier(PHPParser_Node_Stmt_Class::MODIFIER_PUBLIC);
    +
    +        return $this;
    +    }
    +
    +    /**
    +     * Makes the method protected.
    +     *
    +     * @return PHPParser_Builder_Method The builder instance (for fluid interface)
    +     */
    +    public function makeProtected() {
    +        $this->setModifier(PHPParser_Node_Stmt_Class::MODIFIER_PROTECTED);
    +
    +        return $this;
    +    }
    +
    +    /**
    +     * Makes the method private.
    +     *
    +     * @return PHPParser_Builder_Method The builder instance (for fluid interface)
    +     */
    +    public function makePrivate() {
    +        $this->setModifier(PHPParser_Node_Stmt_Class::MODIFIER_PRIVATE);
    +
    +        return $this;
    +    }
    +
    +    /**
    +     * Makes the method static.
    +     *
    +     * @return PHPParser_Builder_Method The builder instance (for fluid interface)
    +     */
    +    public function makeStatic() {
    +        $this->setModifier(PHPParser_Node_Stmt_Class::MODIFIER_STATIC);
    +
    +        return $this;
    +    }
    +
    +    /**
    +     * Makes the method abstract.
    +     *
    +     * @return PHPParser_Builder_Method The builder instance (for fluid interface)
    +     */
    +    public function makeAbstract() {
    +        if (!empty($this->stmts)) {
    +            throw new LogicException('Cannot make method with statements abstract');
    +        }
    +
    +        $this->setModifier(PHPParser_Node_Stmt_Class::MODIFIER_ABSTRACT);
    +        $this->stmts = null; // abstract methods don't have statements
    +
    +        return $this;
    +    }
    +
    +    /**
    +     * Makes the method final.
    +     *
    +     * @return PHPParser_Builder_Method The builder instance (for fluid interface)
    +     */
    +    public function makeFinal() {
    +        $this->setModifier(PHPParser_Node_Stmt_Class::MODIFIER_FINAL);
    +
    +        return $this;
    +    }
    +
    +    /**
    +     * Make the method return by reference.
    +     *
    +     * @return PHPParser_Builder_Method The builder instance (for fluid interface)
    +     */
    +    public function makeReturnByRef() {
    +        $this->returnByRef = true;
    +
    +        return $this;
    +    }
    +
    +    /**
    +     * Adds a parameter.
    +     *
    +     * @param PHPParser_Node_Param|PHPParser_Builder_Param $param The parameter to add
    +     *
    +     * @return PHPParser_Builder_Method The builder instance (for fluid interface)
    +     */
    +    public function addParam($param) {
    +        $param = $this->normalizeNode($param);
    +
    +        if (!$param instanceof PHPParser_Node_Param) {
    +            throw new LogicException(sprintf('Expected parameter node, got "%s"', $param->getType()));
    +        }
    +
    +        $this->params[] = $param;
    +
    +        return $this;
    +    }
    +
    +    /**
    +     * Adds multiple parameters.
    +     *
    +     * @param array $params The parameters to add
    +     *
    +     * @return PHPParser_Builder_Method The builder instance (for fluid interface)
    +     */
    +    public function addParams(array $params) {
    +        foreach ($params as $param) {
    +            $this->addParam($param);
    +        }
    +
    +        return $this;
    +    }
    +
    +    /**
    +     * Adds a statement.
    +     *
    +     * @param PHPParser_Node|PHPParser_Builder $stmt The statement to add
    +     *
    +     * @return PHPParser_Builder_Method The builder instance (for fluid interface)
    +     */
    +    public function addStmt($stmt) {
    +        if (null === $this->stmts) {
    +            throw new LogicException('Cannot add statements to an abstract method');
    +        }
    +
    +        $this->stmts[] = $this->normalizeNode($stmt);
    +
    +        return $this;
    +    }
    +
    +    /**
    +     * Adds multiple statements.
    +     *
    +     * @param array $stmts The statements to add
    +     *
    +     * @return PHPParser_Builder_Method The builder instance (for fluid interface)
    +     */
    +    public function addStmts(array $stmts) {
    +        foreach ($stmts as $stmt) {
    +            $this->addStmt($stmt);
    +        }
    +
    +        return $this;
    +    }
    +
    +    /**
    +     * Returns the built method node.
    +     *
    +     * @return PHPParser_Node_Stmt_ClassMethod The built method node
    +     */
    +    public function getNode() {
    +        return new PHPParser_Node_Stmt_ClassMethod($this->name, array(
    +            'type'   => $this->type !== 0 ? $this->type : PHPParser_Node_Stmt_Class::MODIFIER_PUBLIC,
    +            'byRef'  => $this->returnByRef,
    +            'params' => $this->params,
    +            'stmts'  => $this->stmts,
    +        ));
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/Builder/Param.php b/vendor/nikic/php-parser/lib/PHPParser/Builder/Param.php
    new file mode 100755
    index 0000000..4c217a9
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/Builder/Param.php
    @@ -0,0 +1,75 @@
    +name = $name;
    +
    +        $this->default = null;
    +        $this->type = null;
    +        $this->byRef = false;
    +    }
    +
    +    /**
    +     * Sets default value for the parameter.
    +     *
    +     * @param mixed $value Default value to use
    +     *
    +     * @return PHPParser_Builder_Param The builder instance (for fluid interface)
    +     */
    +    public function setDefault($value) {
    +        $this->default = $this->normalizeValue($value);
    +
    +        return $this;
    +    }
    +
    +    /**
    +     * Sets type hint for the parameter.
    +     *
    +     * @param string|PHPParser_Node_Name $type Type hint to use
    +     *
    +     * @return PHPParser_Builder_Param The builder instance (for fluid interface)
    +     */
    +    public function setTypeHint($type) {
    +        if ($type === 'array' || $type === 'callable') {
    +            $this->type = $type;
    +        } else {
    +            $this->type = $this->normalizeName($type);
    +        }
    +
    +        return $this;
    +    }
    +
    +    /**
    +     * Make the parameter accept the value by reference.
    +     *
    +     * @return PHPParser_Builder_Param The builder instance (for fluid interface)
    +     */
    +    public function makeByRef() {
    +        $this->byRef = true;
    +
    +        return $this;
    +    }
    +
    +    /**
    +     * Returns the built parameter node.
    +     *
    +     * @return PHPParser_Node_Param The built parameter node
    +     */
    +    public function getNode() {
    +        return new PHPParser_Node_Param(
    +            $this->name, $this->default, $this->type, $this->byRef
    +        );
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/Builder/Property.php b/vendor/nikic/php-parser/lib/PHPParser/Builder/Property.php
    new file mode 100755
    index 0000000..806632c
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/Builder/Property.php
    @@ -0,0 +1,92 @@
    +name = $name;
    +
    +        $this->type = 0;
    +        $this->default = null;
    +    }
    +
    +    /**
    +     * Makes the property public.
    +     *
    +     * @return PHPParser_Builder_Property The builder instance (for fluid interface)
    +     */
    +    public function makePublic() {
    +        $this->setModifier(PHPParser_Node_Stmt_Class::MODIFIER_PUBLIC);
    +
    +        return $this;
    +    }
    +
    +    /**
    +     * Makes the property protected.
    +     *
    +     * @return PHPParser_Builder_Property The builder instance (for fluid interface)
    +     */
    +    public function makeProtected() {
    +        $this->setModifier(PHPParser_Node_Stmt_Class::MODIFIER_PROTECTED);
    +
    +        return $this;
    +    }
    +
    +    /**
    +     * Makes the property private.
    +     *
    +     * @return PHPParser_Builder_Property The builder instance (for fluid interface)
    +     */
    +    public function makePrivate() {
    +        $this->setModifier(PHPParser_Node_Stmt_Class::MODIFIER_PRIVATE);
    +
    +        return $this;
    +    }
    +
    +    /**
    +     * Makes the property static.
    +     *
    +     * @return PHPParser_Builder_Property The builder instance (for fluid interface)
    +     */
    +    public function makeStatic() {
    +        $this->setModifier(PHPParser_Node_Stmt_Class::MODIFIER_STATIC);
    +
    +        return $this;
    +    }
    +
    +    /**
    +     * Sets default value for the property.
    +     *
    +     * @param mixed $value Default value to use
    +     *
    +     * @return PHPParser_Builder_Property The builder instance (for fluid interface)
    +     */
    +    public function setDefault($value) {
    +        $this->default = $this->normalizeValue($value);
    +
    +        return $this;
    +    }
    +
    +    /**
    +     * Returns the built class node.
    +     *
    +     * @return PHPParser_Node_Stmt_Property The built property node
    +     */
    +    public function getNode() {
    +        return new PHPParser_Node_Stmt_Property(
    +            $this->type !== 0 ? $this->type : PHPParser_Node_Stmt_Class::MODIFIER_PUBLIC,
    +            array(
    +                new PHPParser_Node_Stmt_PropertyProperty($this->name, $this->default)
    +            )
    +        );
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/BuilderAbstract.php b/vendor/nikic/php-parser/lib/PHPParser/BuilderAbstract.php
    new file mode 100755
    index 0000000..d17b060
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/BuilderAbstract.php
    @@ -0,0 +1,94 @@
    +getNode();
    +        } elseif ($node instanceof PHPParser_Node) {
    +            return $node;
    +        }
    +
    +        throw new LogicException('Expected node or builder object');
    +    }
    +
    +    /**
    +     * Normalizes a name: Converts plain string names to PHPParser_Node_Name.
    +     *
    +     * @param PHPParser_Node_Name|string $name The name to normalize
    +     *
    +     * @return PHPParser_Node_Name The normalized name
    +     */
    +    protected function normalizeName($name) {
    +        if ($name instanceof PHPParser_Node_Name) {
    +            return $name;
    +        } else {
    +            return new PHPParser_Node_Name($name);
    +        }
    +    }
    +
    +    /**
    +     * Normalizes a value: Converts nulls, booleans, integers,
    +     * floats, strings and arrays into their respective nodes
    +     *
    +     * @param mixed $value The value to normalize
    +     *
    +     * @return PHPParser_Node_Expr The normalized value
    +     */
    +    protected function normalizeValue($value) {
    +        if ($value instanceof PHPParser_Node) {
    +            return $value;
    +        } elseif (is_null($value)) {
    +            return new PHPParser_Node_Expr_ConstFetch(
    +                new PHPParser_Node_Name('null')
    +            );
    +        } elseif (is_bool($value)) {
    +            return new PHPParser_Node_Expr_ConstFetch(
    +                new PHPParser_Node_Name($value ? 'true' : 'false')
    +            );
    +        } elseif (is_int($value)) {
    +            return new PHPParser_Node_Scalar_LNumber($value);
    +        } elseif (is_float($value)) {
    +            return new PHPParser_Node_Scalar_DNumber($value);
    +        } elseif (is_string($value)) {
    +            return new PHPParser_Node_Scalar_String($value);
    +        } elseif (is_array($value)) {
    +            $items = array();
    +            $lastKey = -1;
    +            foreach ($value as $itemKey => $itemValue) {
    +                // for consecutive, numeric keys don't generate keys
    +                if (null !== $lastKey && ++$lastKey === $itemKey) {
    +                    $items[] = new PHPParser_Node_Expr_ArrayItem(
    +                        $this->normalizeValue($itemValue)
    +                    );
    +                } else {
    +                    $lastKey = null;
    +                    $items[] = new PHPParser_Node_Expr_ArrayItem(
    +                        $this->normalizeValue($itemValue),
    +                        $this->normalizeValue($itemKey)
    +                    );
    +                }
    +            }
    +
    +            return new PHPParser_Node_Expr_Array($items);
    +        } else {
    +            throw new LogicException('Invalid value');
    +        }
    +    }
    +
    +    /**
    +     * Sets a modifier in the $this->type property.
    +     *
    +     * @param int $modifier Modifier to set
    +     */
    +    protected function setModifier($modifier) {
    +        PHPParser_Node_Stmt_Class::verifyModifier($this->type, $modifier);
    +        $this->type |= $modifier;
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/BuilderFactory.php b/vendor/nikic/php-parser/lib/PHPParser/BuilderFactory.php
    new file mode 100755
    index 0000000..48941dc
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/BuilderFactory.php
    @@ -0,0 +1,87 @@
    +text = $text;
    +        $this->line = $line;
    +    }
    +
    +    /**
    +     * Gets the comment text.
    +     *
    +     * @return string The comment text (including comment delimiters like /*)
    +     */
    +    public function getText() {
    +        return $this->text;
    +    }
    +
    +    /**
    +     * Sets the comment text.
    +     *
    +     * @param string $text The comment text (including comment delimiters like /*)
    +     */
    +    public function setText($text) {
    +        $this->text = $text;
    +    }
    +
    +    /**
    +     * Gets the line number the comment started on.
    +     *
    +     * @return int Line number
    +     */
    +    public function getLine() {
    +        return $this->line;
    +    }
    +
    +    /**
    +     * Sets the line number the comment started on.
    +     *
    +     * @param int $line Line number
    +     */
    +    public function setLine($line) {
    +        $this->line = $line;
    +    }
    +
    +    /**
    +     * Gets the comment text.
    +     *
    +     * @return string The comment text (including comment delimiters like /*)
    +     */
    +    public function __toString() {
    +        return $this->text;
    +    }
    +
    +    /**
    +     * Gets the reformatted comment text.
    +     *
    +     * "Reformatted" here means that we try to clean up the whitespace at the
    +     * starts of the lines. This is necessary because we receive the comments
    +     * without trailing whitespace on the first line, but with trailing whitespace
    +     * on all subsequent lines.
    +     *
    +     * @return mixed|string
    +     */
    +    public function getReformattedText() {
    +        $text = trim($this->text);
    +        if (false === strpos($text, "\n")) {
    +            // Single line comments don't need further processing
    +            return $text;
    +        } elseif (preg_match('((*BSR_ANYCRLF)(*ANYCRLF)^.*(?:\R\s+\*.*)+$)', $text)) {
    +            // Multi line comment of the type
    +            //
    +            //     /*
    +            //      * Some text.
    +            //      * Some more text.
    +            //      */
    +            //
    +            // is handled by replacing the whitespace sequences before the * by a single space
    +            return preg_replace('(^\s+\*)m', ' *', $this->text);
    +        } elseif (preg_match('(^/\*\*?\s*[\r\n])', $text) && preg_match('(\n(\s*)\*/$)', $text, $matches)) {
    +            // Multi line comment of the type
    +            //
    +            //    /*
    +            //        Some text.
    +            //        Some more text.
    +            //    */
    +            //
    +            // is handled by removing the whitespace sequence on the line before the closing
    +            // */ on all lines. So if the last line is "    */", then "    " is removed at the
    +            // start of all lines.
    +            return preg_replace('(^' . preg_quote($matches[1]) . ')m', '', $text);
    +        } elseif (preg_match('(^/\*\*?\s*(?!\s))', $text, $matches)) {
    +            // Multi line comment of the type
    +            //
    +            //     /* Some text.
    +            //        Some more text.
    +            //        Even more text. */
    +            //
    +            // is handled by taking the length of the "/* " segment and leaving only that
    +            // many space characters before the lines. Thus in the above example only three
    +            // space characters are left at the start of every line.
    +            return preg_replace('(^\s*(?= {' . strlen($matches[0]) . '}(?!\s)))m', '', $text);
    +        }
    +
    +        // No idea how to format this comment, so simply return as is
    +        return $text;
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/Comment/Doc.php b/vendor/nikic/php-parser/lib/PHPParser/Comment/Doc.php
    new file mode 100755
    index 0000000..95e4bc9
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/Comment/Doc.php
    @@ -0,0 +1,5 @@
    +rawMessage = (string) $message;
    +        $this->rawLine    = (int) $line;
    +        $this->updateMessage();
    +    }
    +
    +    /**
    +     * Gets the error message
    +     *
    +     * @return string Error message
    +     */
    +    public function getRawMessage() {
    +        return $this->rawMessage;
    +    }
    +
    +    /**
    +     * Sets the line of the PHP file the error occurred in.
    +     *
    +     * @param string $message Error message
    +     */
    +    public function setRawMessage($message) {
    +        $this->rawMessage = (string) $message;
    +        $this->updateMessage();
    +    }
    +
    +    /**
    +     * Gets the error line in the PHP file.
    +     *
    +     * @return int Error line in the PHP file
    +     */
    +    public function getRawLine() {
    +        return $this->rawLine;
    +    }
    +
    +    /**
    +     * Sets the line of the PHP file the error occurred in.
    +     *
    +     * @param int $line Error line in the PHP file
    +     */
    +    public function setRawLine($line) {
    +        $this->rawLine = (int) $line;
    +        $this->updateMessage();
    +    }
    +
    +    /**
    +     * Updates the exception message after a change to rawMessage or rawLine.
    +     */
    +    protected function updateMessage() {
    +        $this->message = $this->rawMessage;
    +
    +        if (-1 === $this->rawLine) {
    +            $this->message .= ' on unknown line';
    +        } else {
    +            $this->message .= ' on line ' . $this->rawLine;
    +        }
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/Lexer.php b/vendor/nikic/php-parser/lib/PHPParser/Lexer.php
    new file mode 100755
    index 0000000..0ca5d49
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/Lexer.php
    @@ -0,0 +1,191 @@
    +tokenMap = $this->createTokenMap();
    +
    +        // map of tokens to drop while lexing (the map is only used for isset lookup,
    +        // that's why the value is simply set to 1; the value is never actually used.)
    +        $this->dropTokens = array_fill_keys(array(T_WHITESPACE, T_OPEN_TAG), 1);
    +    }
    +
    +    /**
    +     * Initializes the lexer for lexing the provided source code.
    +     *
    +     * @param string $code The source code to lex
    +     *
    +     * @throws PHPParser_Error on lexing errors (unterminated comment or unexpected character)
    +     */
    +    public function startLexing($code) {
    +        $this->resetErrors();
    +        $this->tokens = @token_get_all($code);
    +        $this->handleErrors();
    +
    +        $this->code = $code; // keep the code around for __halt_compiler() handling
    +        $this->pos  = -1;
    +        $this->line =  1;
    +    }
    +
    +    protected function resetErrors() {
    +        // clear error_get_last() by forcing an undefined variable error
    +        @$undefinedVariable;
    +    }
    +
    +    protected function handleErrors() {
    +        $error = error_get_last();
    +
    +        if (preg_match(
    +            '~^Unterminated comment starting line ([0-9]+)$~',
    +            $error['message'], $matches
    +        )) {
    +            throw new PHPParser_Error('Unterminated comment', $matches[1]);
    +        }
    +
    +        if (preg_match(
    +            '~^Unexpected character in input:  \'(.)\' \(ASCII=([0-9]+)\)~s',
    +            $error['message'], $matches
    +        )) {
    +            throw new PHPParser_Error(sprintf(
    +                'Unexpected character "%s" (ASCII %d)',
    +                $matches[1], $matches[2]
    +            ));
    +        }
    +
    +        // PHP cuts error message after null byte, so need special case
    +        if (preg_match('~^Unexpected character in input:  \'$~', $error['message'])) {
    +            throw new PHPParser_Error('Unexpected null byte');
    +        }
    +    }
    +
    +    /**
    +     * Fetches the next token.
    +     *
    +     * @param mixed $value           Variable to store token content in
    +     * @param mixed $startAttributes Variable to store start attributes in
    +     * @param mixed $endAttributes   Variable to store end attributes in
    +     *
    +     * @return int Token id
    +     */
    +    public function getNextToken(&$value = null, &$startAttributes = null, &$endAttributes = null) {
    +        $startAttributes = array();
    +        $endAttributes   = array();
    +
    +        while (isset($this->tokens[++$this->pos])) {
    +            $token = $this->tokens[$this->pos];
    +
    +            if (is_string($token)) {
    +                $startAttributes['startLine'] = $this->line;
    +                $endAttributes['endLine']     = $this->line;
    +
    +                // bug in token_get_all
    +                if ('b"' === $token) {
    +                    $value = 'b"';
    +                    return ord('"');
    +                } else {
    +                    $value = $token;
    +                    return ord($token);
    +                }
    +            } else {
    +                $this->line += substr_count($token[1], "\n");
    +
    +                if (T_COMMENT === $token[0]) {
    +                    $startAttributes['comments'][] = new PHPParser_Comment($token[1], $token[2]);
    +                } elseif (T_DOC_COMMENT === $token[0]) {
    +                    $startAttributes['comments'][] = new PHPParser_Comment_Doc($token[1], $token[2]);
    +                } elseif (!isset($this->dropTokens[$token[0]])) {
    +                    $value = $token[1];
    +                    $startAttributes['startLine'] = $token[2];
    +                    $endAttributes['endLine']     = $this->line;
    +
    +                    return $this->tokenMap[$token[0]];
    +                }
    +            }
    +        }
    +
    +        $startAttributes['startLine'] = $this->line;
    +
    +        // 0 is the EOF token
    +        return 0;
    +    }
    +
    +    /**
    +     * Handles __halt_compiler() by returning the text after it.
    +     *
    +     * @return string Remaining text
    +     */
    +    public function handleHaltCompiler() {
    +        // get the length of the text before the T_HALT_COMPILER token
    +        $textBefore = '';
    +        for ($i = 0; $i <= $this->pos; ++$i) {
    +            if (is_string($this->tokens[$i])) {
    +                $textBefore .= $this->tokens[$i];
    +            } else {
    +                $textBefore .= $this->tokens[$i][1];
    +            }
    +        }
    +
    +        // text after T_HALT_COMPILER, still including ();
    +        $textAfter = substr($this->code, strlen($textBefore));
    +
    +        // ensure that it is followed by ();
    +        // this simplifies the situation, by not allowing any comments
    +        // in between of the tokens.
    +        if (!preg_match('~\s*\(\s*\)\s*(?:;|\?>\r?\n?)~', $textAfter, $matches)) {
    +            throw new PHPParser_Error('__halt_compiler must be followed by "();"');
    +        }
    +
    +        // prevent the lexer from returning any further tokens
    +        $this->pos = count($this->tokens);
    +
    +        // return with (); removed
    +        return (string) substr($textAfter, strlen($matches[0])); // (string) converts false to ''
    +    }
    +
    +    /**
    +     * Creates the token map.
    +     *
    +     * The token map maps the PHP internal token identifiers
    +     * to the identifiers used by the Parser. Additionally it
    +     * maps T_OPEN_TAG_WITH_ECHO to T_ECHO and T_CLOSE_TAG to ';'.
    +     *
    +     * @return array The token map
    +     */
    +    protected function createTokenMap() {
    +        $tokenMap = array();
    +
    +        // 256 is the minimum possible token number, as everything below
    +        // it is an ASCII value
    +        for ($i = 256; $i < 1000; ++$i) {
    +            // T_DOUBLE_COLON is equivalent to T_PAAMAYIM_NEKUDOTAYIM
    +            if (T_DOUBLE_COLON === $i) {
    +                $tokenMap[$i] = PHPParser_Parser::T_PAAMAYIM_NEKUDOTAYIM;
    +            // T_OPEN_TAG_WITH_ECHO with dropped T_OPEN_TAG results in T_ECHO
    +            } elseif(T_OPEN_TAG_WITH_ECHO === $i) {
    +                $tokenMap[$i] = PHPParser_Parser::T_ECHO;
    +            // T_CLOSE_TAG is equivalent to ';'
    +            } elseif(T_CLOSE_TAG === $i) {
    +                $tokenMap[$i] = ord(';');
    +            // and the others can be mapped directly
    +            } elseif ('UNKNOWN' !== ($name = token_name($i))
    +                      && defined($name = 'PHPParser_Parser::' . $name)
    +            ) {
    +                $tokenMap[$i] = constant($name);
    +            }
    +        }
    +
    +        return $tokenMap;
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/Lexer/Emulative.php b/vendor/nikic/php-parser/lib/PHPParser/Lexer/Emulative.php
    new file mode 100755
    index 0000000..1c74ef0
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/Lexer/Emulative.php
    @@ -0,0 +1,200 @@
    + array(
    +                'finally'       => PHPParser_Parser::T_FINALLY,
    +                'yield'         => PHPParser_Parser::T_YIELD,
    +            ),
    +            '5.4.0-dev' => array(
    +                'callable'      => PHPParser_Parser::T_CALLABLE,
    +                'insteadof'     => PHPParser_Parser::T_INSTEADOF,
    +                'trait'         => PHPParser_Parser::T_TRAIT,
    +                '__trait__'     => PHPParser_Parser::T_TRAIT_C,
    +            ),
    +            '5.3.0-dev' => array(
    +                '__dir__'       => PHPParser_Parser::T_DIR,
    +                'goto'          => PHPParser_Parser::T_GOTO,
    +                'namespace'     => PHPParser_Parser::T_NAMESPACE,
    +                '__namespace__' => PHPParser_Parser::T_NS_C,
    +            ),
    +        );
    +
    +        $this->newKeywords = array();
    +        foreach ($newKeywordsPerVersion as $version => $newKeywords) {
    +            if (version_compare(PHP_VERSION, $version, '>=')) {
    +                break;
    +            }
    +
    +            $this->newKeywords += $newKeywords;
    +        }
    +    }
    +
    +    public function startLexing($code) {
    +        $this->inObjectAccess = false;
    +
    +        // on PHP 5.4 don't do anything
    +        if (version_compare(PHP_VERSION, '5.4.0RC1', '>=')) {
    +            parent::startLexing($code);
    +        } else {
    +            $code = $this->preprocessCode($code);
    +            parent::startLexing($code);
    +            $this->postprocessTokens();
    +        }
    +    }
    +
    +    /*
    +     * Replaces new features in the code by ~__EMU__{NAME}__{DATA}__~ sequences.
    +     * ~LABEL~ is never valid PHP code, that's why we can (to some degree) safely
    +     * use it here.
    +     * Later when preprocessing the tokens these sequences will either be replaced
    +     * by real tokens or replaced with their original content (e.g. if they occured
    +     * inside a string, i.e. a place where they don't have a special meaning).
    +     */
    +    protected function preprocessCode($code) {
    +        // binary notation (0b010101101001...)
    +        $code = preg_replace('(\b0b[01]+\b)', '~__EMU__BINARY__$0__~', $code);
    +
    +        if (version_compare(PHP_VERSION, '5.3.0', '<')) {
    +            // namespace separator (backslash not followed by some special characters,
    +            // which are not valid after a NS separator, but would cause problems with
    +            // escape sequence parsing if one would replace the backslash there)
    +            $code = preg_replace('(\\\\(?!["\'`${\\\\]))', '~__EMU__NS__~', $code);
    +
    +            // nowdoc (<<<'ABC'\ncontent\nABC;)
    +            $code = preg_replace_callback(
    +                '((*BSR_ANYCRLF)        # set \R to (?>\r\n|\r|\n)
    +                  (b?<<<[\t ]*\'([a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)\'\R) # opening token
    +                  ((?:(?!\2;?\R).*\R)*) # content
    +                  (\2)                  # closing token
    +                  (?=;?\R)              # must be followed by newline (with optional semicolon)
    +                 )x',
    +                array($this, 'encodeNowdocCallback'),
    +                $code
    +            );
    +        }
    +
    +        return $code;
    +    }
    +
    +    /*
    +     * As nowdocs can have arbitrary content but LABELs can only contain a certain
    +     * range of characters, the nowdoc content is encoded as hex and separated by
    +     * 'x' tokens. So the result of the encoding will look like this:
    +     * ~__EMU__NOWDOC__{HEX(START_TOKEN)}x{HEX(CONTENT)}x{HEX(END_TOKEN)}~
    +     */
    +    public function encodeNowdocCallback(array $matches) {
    +        return '~__EMU__NOWDOC__'
    +                . bin2hex($matches[1]) . 'x' . bin2hex($matches[3]) . 'x' . bin2hex($matches[4])
    +                . '__~';
    +    }
    +
    +    /*
    +     * Replaces the ~__EMU__...~ sequences with real tokens or their original
    +     * value.
    +     */
    +    protected function postprocessTokens() {
    +        // we need to manually iterate and manage a count because we'll change
    +        // the tokens array on the way
    +        for ($i = 0, $c = count($this->tokens); $i < $c; ++$i) {
    +            // first check that the following tokens are form ~LABEL~,
    +            // then match the __EMU__... sequence.
    +            if ('~' === $this->tokens[$i]
    +                && isset($this->tokens[$i + 2])
    +                && '~' === $this->tokens[$i + 2]
    +                && T_STRING === $this->tokens[$i + 1][0]
    +                && preg_match('(^__EMU__([A-Z]++)__(?:([A-Za-z0-9]++)__)?$)', $this->tokens[$i + 1][1], $matches)
    +            ) {
    +                if ('BINARY' === $matches[1]) {
    +                    // the binary number can either be an integer or a double, so return a LNUMBER
    +                    // or DNUMBER respectively
    +                    $replace = array(
    +                        array(is_int(bindec($matches[2])) ? T_LNUMBER : T_DNUMBER, $matches[2], $this->tokens[$i + 1][2])
    +                    );
    +                } elseif ('NS' === $matches[1]) {
    +                    // a \ single char token is returned here and replaced by a
    +                    // PHPParser_Parser::T_NS_SEPARATOR token in ->getNextToken(). This hacks around
    +                    // the limitations arising from T_NS_SEPARATOR not being defined on 5.3
    +                    $replace = array('\\');
    +                } elseif ('NOWDOC' === $matches[1]) {
    +                    // decode the encoded nowdoc payload; pack('H*' is bin2hex( for 5.3
    +                    list($start, $content, $end) = explode('x', $matches[2]);
    +                    list($start, $content, $end) = array(pack('H*', $start), pack('H*', $content), pack('H*', $end));
    +
    +                    $replace = array();
    +                    $replace[] = array(T_START_HEREDOC, $start, $this->tokens[$i + 1][2]);
    +                    if ('' !== $content) {
    +                        $replace[] = array(T_ENCAPSED_AND_WHITESPACE, $content, -1);
    +                    }
    +                    $replace[] = array(T_END_HEREDOC, $end, -1);
    +                } else {
    +                    // just ignore all other __EMU__ sequences
    +                    continue;
    +                }
    +
    +                array_splice($this->tokens, $i, 3, $replace);
    +                $c -= 3 - count($replace);
    +            // for multichar tokens (e.g. strings) replace any ~__EMU__...~ sequences
    +            // in their content with the original character sequence
    +            } elseif (is_array($this->tokens[$i])
    +                      && 0 !== strpos($this->tokens[$i][1], '__EMU__')
    +            ) {
    +                $this->tokens[$i][1] = preg_replace_callback(
    +                    '(~__EMU__([A-Z]++)__(?:([A-Za-z0-9]++)__)?~)',
    +                    array($this, 'restoreContentCallback'),
    +                    $this->tokens[$i][1]
    +                );
    +            }
    +        }
    +    }
    +
    +    /*
    +     * This method is a callback for restoring EMU sequences in
    +     * multichar tokens (like strings) to their original value.
    +     */
    +    public function restoreContentCallback(array $matches) {
    +        if ('BINARY' === $matches[1]) {
    +            return $matches[2];
    +        } elseif ('NS' === $matches[1]) {
    +            return '\\';
    +        } elseif ('NOWDOC' === $matches[1]) {
    +            list($start, $content, $end) = explode('x', $matches[2]);
    +            return pack('H*', $start) . pack('H*', $content) . pack('H*', $end);
    +        } else {
    +            return $matches[0];
    +        }
    +    }
    +
    +    public function getNextToken(&$value = null, &$startAttributes = null, &$endAttributes = null) {
    +        $token = parent::getNextToken($value, $startAttributes, $endAttributes);
    +
    +        // replace new keywords by their respective tokens. This is not done
    +        // if we currently are in an object access (e.g. in $obj->namespace
    +        // "namespace" stays a T_STRING tokens and isn't converted to T_NAMESPACE)
    +        if (PHPParser_Parser::T_STRING === $token && !$this->inObjectAccess) {
    +            if (isset($this->newKeywords[strtolower($value)])) {
    +                return $this->newKeywords[strtolower($value)];
    +            }
    +        // backslashes are replaced by T_NS_SEPARATOR tokens
    +        } elseif (92 === $token) { // ord('\\')
    +            return PHPParser_Parser::T_NS_SEPARATOR;
    +        // keep track of whether we currently are in an object access (after ->)
    +        } elseif (PHPParser_Parser::T_OBJECT_OPERATOR === $token) {
    +            $this->inObjectAccess = true;
    +        } else {
    +            $this->inObjectAccess = false;
    +        }
    +
    +        return $token;
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/Node.php b/vendor/nikic/php-parser/lib/PHPParser/Node.php
    new file mode 100755
    index 0000000..c47d49d
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/Node.php
    @@ -0,0 +1,75 @@
    + $value,
    +                'byRef' => $byRef
    +            ),
    +            $attributes
    +        );
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/Node/Const.php b/vendor/nikic/php-parser/lib/PHPParser/Node/Const.php
    new file mode 100755
    index 0000000..e4e7794
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/Node/Const.php
    @@ -0,0 +1,25 @@
    + $name,
    +                'value' => $value,
    +            ),
    +            $attributes
    +        );
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/Node/Expr.php b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr.php
    new file mode 100755
    index 0000000..293dab3
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr.php
    @@ -0,0 +1,5 @@
    + $items
    +            ),
    +            $attributes
    +        );
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/ArrayDimFetch.php b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/ArrayDimFetch.php
    new file mode 100755
    index 0000000..f7d8628
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/ArrayDimFetch.php
    @@ -0,0 +1,25 @@
    + $var,
    +                'dim' => $dim
    +            ),
    +            $attributes
    +        );
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/ArrayItem.php b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/ArrayItem.php
    new file mode 100755
    index 0000000..f3c42ba
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/ArrayItem.php
    @@ -0,0 +1,28 @@
    + $key,
    +                'value' => $value,
    +                'byRef' => $byRef
    +            ),
    +            $attributes
    +        );
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/Assign.php b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/Assign.php
    new file mode 100755
    index 0000000..1619425
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/Assign.php
    @@ -0,0 +1,25 @@
    + $var,
    +                'expr' => $expr
    +            ),
    +            $attributes
    +        );
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/AssignBitwiseAnd.php b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/AssignBitwiseAnd.php
    new file mode 100755
    index 0000000..013f1a8
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/AssignBitwiseAnd.php
    @@ -0,0 +1,25 @@
    + $var,
    +                'expr' => $expr
    +            ),
    +            $attributes
    +        );
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/AssignBitwiseOr.php b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/AssignBitwiseOr.php
    new file mode 100755
    index 0000000..c5c4764
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/AssignBitwiseOr.php
    @@ -0,0 +1,25 @@
    + $var,
    +                'expr' => $expr
    +            ),
    +            $attributes
    +        );
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/AssignBitwiseXor.php b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/AssignBitwiseXor.php
    new file mode 100755
    index 0000000..91ed068
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/AssignBitwiseXor.php
    @@ -0,0 +1,25 @@
    + $var,
    +                'expr' => $expr
    +            ),
    +            $attributes
    +        );
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/AssignConcat.php b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/AssignConcat.php
    new file mode 100755
    index 0000000..3f634ae
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/AssignConcat.php
    @@ -0,0 +1,25 @@
    + $var,
    +                'expr' => $expr
    +            ),
    +            $attributes
    +        );
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/AssignDiv.php b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/AssignDiv.php
    new file mode 100755
    index 0000000..7992a66
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/AssignDiv.php
    @@ -0,0 +1,25 @@
    + $var,
    +                'expr' => $expr
    +            ),
    +            $attributes
    +        );
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/AssignMinus.php b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/AssignMinus.php
    new file mode 100755
    index 0000000..62f00b3
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/AssignMinus.php
    @@ -0,0 +1,25 @@
    + $var,
    +                'expr' => $expr
    +            ),
    +            $attributes
    +        );
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/AssignMod.php b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/AssignMod.php
    new file mode 100755
    index 0000000..98cbe75
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/AssignMod.php
    @@ -0,0 +1,25 @@
    + $var,
    +                'expr' => $expr
    +            ),
    +            $attributes
    +        );
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/AssignMul.php b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/AssignMul.php
    new file mode 100755
    index 0000000..63bdae7
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/AssignMul.php
    @@ -0,0 +1,25 @@
    + $var,
    +                'expr' => $expr
    +            ),
    +            $attributes
    +        );
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/AssignPlus.php b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/AssignPlus.php
    new file mode 100755
    index 0000000..99b866c
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/AssignPlus.php
    @@ -0,0 +1,25 @@
    + $var,
    +                'expr' => $expr
    +            ),
    +            $attributes
    +        );
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/AssignRef.php b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/AssignRef.php
    new file mode 100755
    index 0000000..0bcf0b0
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/AssignRef.php
    @@ -0,0 +1,25 @@
    + $var,
    +                'expr' => $expr
    +            ),
    +            $attributes
    +        );
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/AssignShiftLeft.php b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/AssignShiftLeft.php
    new file mode 100755
    index 0000000..f3ec3e5
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/AssignShiftLeft.php
    @@ -0,0 +1,25 @@
    + $var,
    +                'expr' => $expr
    +            ),
    +            $attributes
    +        );
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/AssignShiftRight.php b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/AssignShiftRight.php
    new file mode 100755
    index 0000000..0b4743b
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/AssignShiftRight.php
    @@ -0,0 +1,25 @@
    + $var,
    +                'expr' => $expr
    +            ),
    +            $attributes
    +        );
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/BitwiseAnd.php b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/BitwiseAnd.php
    new file mode 100755
    index 0000000..fffac44
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/BitwiseAnd.php
    @@ -0,0 +1,25 @@
    + $left,
    +                'right' => $right
    +            ),
    +            $attributes
    +        );
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/BitwiseNot.php b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/BitwiseNot.php
    new file mode 100755
    index 0000000..635d200
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/BitwiseNot.php
    @@ -0,0 +1,22 @@
    + $expr
    +            ),
    +            $attributes
    +        );
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/BitwiseOr.php b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/BitwiseOr.php
    new file mode 100755
    index 0000000..cebd70d
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/BitwiseOr.php
    @@ -0,0 +1,25 @@
    + $left,
    +                'right' => $right
    +            ),
    +            $attributes
    +        );
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/BitwiseXor.php b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/BitwiseXor.php
    new file mode 100755
    index 0000000..742ca82
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/BitwiseXor.php
    @@ -0,0 +1,25 @@
    + $left,
    +                'right' => $right
    +            ),
    +            $attributes
    +        );
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/BooleanAnd.php b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/BooleanAnd.php
    new file mode 100755
    index 0000000..fd7e499
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/BooleanAnd.php
    @@ -0,0 +1,25 @@
    + $left,
    +                'right' => $right
    +            ),
    +            $attributes
    +        );
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/BooleanNot.php b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/BooleanNot.php
    new file mode 100755
    index 0000000..0a8a24c
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/BooleanNot.php
    @@ -0,0 +1,22 @@
    + $expr
    +            ),
    +            $attributes
    +        );
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/BooleanOr.php b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/BooleanOr.php
    new file mode 100755
    index 0000000..cd03851
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/BooleanOr.php
    @@ -0,0 +1,25 @@
    + $left,
    +                'right' => $right
    +            ),
    +            $attributes
    +        );
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/Cast.php b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/Cast.php
    new file mode 100755
    index 0000000..562cccc
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/Cast.php
    @@ -0,0 +1,22 @@
    + $expr
    +            ),
    +            $attributes
    +        );
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/Cast/Array.php b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/Cast/Array.php
    new file mode 100755
    index 0000000..e712d49
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/Cast/Array.php
    @@ -0,0 +1,5 @@
    + $class,
    +                'name'  => $name
    +            ),
    +            $attributes
    +        );
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/Clone.php b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/Clone.php
    new file mode 100755
    index 0000000..1d9d023
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/Clone.php
    @@ -0,0 +1,22 @@
    + $expr
    +            ),
    +            $attributes
    +        );
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/Closure.php b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/Closure.php
    new file mode 100755
    index 0000000..536268d
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/Closure.php
    @@ -0,0 +1,35 @@
    + array(): Statements
    +     *                          'params' => array(): Parameters
    +     *                          'uses'   => array(): use()s
    +     *                          'byRef'  => false  : Whether to return by reference
    +     *                          'static' => false  : Whether the closure is static
    +     * @param array $attributes Additional attributes
    +     */
    +    public function __construct(array $subNodes = array(), array $attributes = array()) {
    +        parent::__construct(
    +            $subNodes + array(
    +                'stmts'  => array(),
    +                'params' => array(),
    +                'uses'   => array(),
    +                'byRef'  => false,
    +                'static' => false,
    +            ),
    +            $attributes
    +        );
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/ClosureUse.php b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/ClosureUse.php
    new file mode 100755
    index 0000000..f10b3a7
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/ClosureUse.php
    @@ -0,0 +1,25 @@
    + $var,
    +                'byRef' => $byRef
    +            ),
    +            $attributes
    +        );
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/Concat.php b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/Concat.php
    new file mode 100755
    index 0000000..724cb6b
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/Concat.php
    @@ -0,0 +1,25 @@
    + $left,
    +                'right' => $right
    +            ),
    +            $attributes
    +        );
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/ConstFetch.php b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/ConstFetch.php
    new file mode 100755
    index 0000000..8a21884
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/ConstFetch.php
    @@ -0,0 +1,22 @@
    + $name
    +            ),
    +            $attributes
    +        );
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/Div.php b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/Div.php
    new file mode 100755
    index 0000000..caa5d2c
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/Div.php
    @@ -0,0 +1,25 @@
    + $left,
    +                'right' => $right
    +            ),
    +            $attributes
    +        );
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/Empty.php b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/Empty.php
    new file mode 100755
    index 0000000..fb55505
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/Empty.php
    @@ -0,0 +1,22 @@
    + $expr
    +            ),
    +            $attributes
    +        );
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/Equal.php b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/Equal.php
    new file mode 100755
    index 0000000..64861c1
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/Equal.php
    @@ -0,0 +1,25 @@
    + $left,
    +                'right' => $right
    +            ),
    +            $attributes
    +        );
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/ErrorSuppress.php b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/ErrorSuppress.php
    new file mode 100755
    index 0000000..7222529
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/ErrorSuppress.php
    @@ -0,0 +1,22 @@
    + $expr
    +            ),
    +            $attributes
    +        );
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/Eval.php b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/Eval.php
    new file mode 100755
    index 0000000..0b607b0
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/Eval.php
    @@ -0,0 +1,22 @@
    + $expr
    +            ),
    +            $attributes
    +        );
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/Exit.php b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/Exit.php
    new file mode 100755
    index 0000000..6870b44
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/Exit.php
    @@ -0,0 +1,22 @@
    + $expr
    +            ),
    +            $attributes
    +        );
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/FuncCall.php b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/FuncCall.php
    new file mode 100755
    index 0000000..8f85df1
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/FuncCall.php
    @@ -0,0 +1,25 @@
    + $name,
    +                'args' => $args
    +            ),
    +            $attributes
    +        );
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/Greater.php b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/Greater.php
    new file mode 100755
    index 0000000..2ff3b94
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/Greater.php
    @@ -0,0 +1,25 @@
    + $left,
    +                'right' => $right
    +            ),
    +            $attributes
    +        );
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/GreaterOrEqual.php b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/GreaterOrEqual.php
    new file mode 100755
    index 0000000..015106d
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/GreaterOrEqual.php
    @@ -0,0 +1,25 @@
    + $left,
    +                'right' => $right
    +            ),
    +            $attributes
    +        );
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/Identical.php b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/Identical.php
    new file mode 100755
    index 0000000..1f2ac01
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/Identical.php
    @@ -0,0 +1,25 @@
    + $left,
    +                'right' => $right
    +            ),
    +            $attributes
    +        );
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/Include.php b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/Include.php
    new file mode 100755
    index 0000000..040de25
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/Include.php
    @@ -0,0 +1,30 @@
    + $expr,
    +                'type' => $type
    +            ),
    +            $attributes
    +        );
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/Instanceof.php b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/Instanceof.php
    new file mode 100755
    index 0000000..95da70c
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/Instanceof.php
    @@ -0,0 +1,25 @@
    + $expr,
    +                'class' => $class
    +            ),
    +            $attributes
    +        );
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/Isset.php b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/Isset.php
    new file mode 100755
    index 0000000..b831dad
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/Isset.php
    @@ -0,0 +1,22 @@
    + $vars
    +            ),
    +            $attributes
    +        );
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/List.php b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/List.php
    new file mode 100755
    index 0000000..8c491c9
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/List.php
    @@ -0,0 +1,22 @@
    + $vars,
    +            ),
    +            $attributes
    +        );
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/LogicalAnd.php b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/LogicalAnd.php
    new file mode 100755
    index 0000000..98609c8
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/LogicalAnd.php
    @@ -0,0 +1,25 @@
    + $left,
    +                'right' => $right
    +            ),
    +            $attributes
    +        );
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/LogicalOr.php b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/LogicalOr.php
    new file mode 100755
    index 0000000..f472644
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/LogicalOr.php
    @@ -0,0 +1,25 @@
    + $left,
    +                'right' => $right
    +            ),
    +            $attributes
    +        );
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/LogicalXor.php b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/LogicalXor.php
    new file mode 100755
    index 0000000..16c24ff
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/LogicalXor.php
    @@ -0,0 +1,25 @@
    + $left,
    +                'right' => $right
    +            ),
    +            $attributes
    +        );
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/MethodCall.php b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/MethodCall.php
    new file mode 100755
    index 0000000..89187e2
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/MethodCall.php
    @@ -0,0 +1,28 @@
    + $var,
    +                'name' => $name,
    +                'args' => $args
    +            ),
    +            $attributes
    +        );
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/Minus.php b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/Minus.php
    new file mode 100755
    index 0000000..b9c4f46
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/Minus.php
    @@ -0,0 +1,25 @@
    + $left,
    +                'right' => $right
    +            ),
    +            $attributes
    +        );
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/Mod.php b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/Mod.php
    new file mode 100755
    index 0000000..f3d706f
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/Mod.php
    @@ -0,0 +1,25 @@
    + $left,
    +                'right' => $right
    +            ),
    +            $attributes
    +        );
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/Mul.php b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/Mul.php
    new file mode 100755
    index 0000000..007c4be
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/Mul.php
    @@ -0,0 +1,25 @@
    + $left,
    +                'right' => $right
    +            ),
    +            $attributes
    +        );
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/New.php b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/New.php
    new file mode 100755
    index 0000000..5faaadc
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/New.php
    @@ -0,0 +1,25 @@
    + $class,
    +                'args'  => $args
    +            ),
    +            $attributes
    +        );
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/NotEqual.php b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/NotEqual.php
    new file mode 100755
    index 0000000..5e6b1be
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/NotEqual.php
    @@ -0,0 +1,25 @@
    + $left,
    +                'right' => $right
    +            ),
    +            $attributes
    +        );
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/NotIdentical.php b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/NotIdentical.php
    new file mode 100755
    index 0000000..4756cff
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/NotIdentical.php
    @@ -0,0 +1,25 @@
    + $left,
    +                'right' => $right
    +            ),
    +            $attributes
    +        );
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/Plus.php b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/Plus.php
    new file mode 100755
    index 0000000..a9ea336
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/Plus.php
    @@ -0,0 +1,25 @@
    + $left,
    +                'right' => $right
    +            ),
    +            $attributes
    +        );
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/PostDec.php b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/PostDec.php
    new file mode 100755
    index 0000000..2fdcfad
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/PostDec.php
    @@ -0,0 +1,22 @@
    + $var
    +            ),
    +            $attributes
    +        );
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/PostInc.php b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/PostInc.php
    new file mode 100755
    index 0000000..93968ff
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/PostInc.php
    @@ -0,0 +1,22 @@
    + $var
    +            ),
    +            $attributes
    +        );
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/PreDec.php b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/PreDec.php
    new file mode 100755
    index 0000000..fdb3c9e
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/PreDec.php
    @@ -0,0 +1,22 @@
    + $var
    +            ),
    +            $attributes
    +        );
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/PreInc.php b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/PreInc.php
    new file mode 100755
    index 0000000..0074966
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/PreInc.php
    @@ -0,0 +1,22 @@
    + $var
    +            ),
    +            $attributes
    +        );
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/Print.php b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/Print.php
    new file mode 100755
    index 0000000..04eb120
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/Print.php
    @@ -0,0 +1,22 @@
    + $expr
    +            ),
    +            $attributes
    +        );
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/PropertyFetch.php b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/PropertyFetch.php
    new file mode 100755
    index 0000000..f77756e
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/PropertyFetch.php
    @@ -0,0 +1,25 @@
    + $var,
    +                'name' => $name
    +            ),
    +            $attributes
    +        );
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/ShellExec.php b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/ShellExec.php
    new file mode 100755
    index 0000000..86fd2e2
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/ShellExec.php
    @@ -0,0 +1,22 @@
    + $parts
    +            ),
    +            $attributes
    +        );
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/ShiftLeft.php b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/ShiftLeft.php
    new file mode 100755
    index 0000000..8953056
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/ShiftLeft.php
    @@ -0,0 +1,25 @@
    + $left,
    +                'right' => $right
    +            ),
    +            $attributes
    +        );
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/ShiftRight.php b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/ShiftRight.php
    new file mode 100755
    index 0000000..f5079d4
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/ShiftRight.php
    @@ -0,0 +1,25 @@
    + $left,
    +                'right' => $right
    +            ),
    +            $attributes
    +        );
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/Smaller.php b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/Smaller.php
    new file mode 100755
    index 0000000..9f6c862
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/Smaller.php
    @@ -0,0 +1,25 @@
    + $left,
    +                'right' => $right
    +            ),
    +            $attributes
    +        );
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/SmallerOrEqual.php b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/SmallerOrEqual.php
    new file mode 100755
    index 0000000..01741bb
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/SmallerOrEqual.php
    @@ -0,0 +1,25 @@
    + $left,
    +                'right' => $right
    +            ),
    +            $attributes
    +        );
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/StaticCall.php b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/StaticCall.php
    new file mode 100755
    index 0000000..68b8415
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/StaticCall.php
    @@ -0,0 +1,28 @@
    + $class,
    +                'name'  => $name,
    +                'args'  => $args
    +            ),
    +            $attributes
    +        );
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/StaticPropertyFetch.php b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/StaticPropertyFetch.php
    new file mode 100755
    index 0000000..0e7826d
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/StaticPropertyFetch.php
    @@ -0,0 +1,25 @@
    + $class,
    +                'name'  => $name
    +            ),
    +            $attributes
    +        );
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/Ternary.php b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/Ternary.php
    new file mode 100755
    index 0000000..6b25c34
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/Ternary.php
    @@ -0,0 +1,28 @@
    + $cond,
    +                'if'   => $if,
    +                'else' => $else
    +            ),
    +            $attributes
    +        );
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/UnaryMinus.php b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/UnaryMinus.php
    new file mode 100755
    index 0000000..1bf6edd
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/UnaryMinus.php
    @@ -0,0 +1,22 @@
    + $expr
    +            ),
    +            $attributes
    +        );
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/UnaryPlus.php b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/UnaryPlus.php
    new file mode 100755
    index 0000000..588a9e9
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/UnaryPlus.php
    @@ -0,0 +1,22 @@
    + $expr
    +            ),
    +            $attributes
    +        );
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/Variable.php b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/Variable.php
    new file mode 100755
    index 0000000..8e3ac26
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/Variable.php
    @@ -0,0 +1,22 @@
    + $name
    +            ),
    +            $attributes
    +        );
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/Yield.php b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/Yield.php
    new file mode 100755
    index 0000000..051ab3b
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/Node/Expr/Yield.php
    @@ -0,0 +1,25 @@
    + $key,
    +                'value' => $value,
    +            ),
    +            $attributes
    +        );
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/Node/Name.php b/vendor/nikic/php-parser/lib/PHPParser/Node/Name.php
    new file mode 100755
    index 0000000..d553632
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/Node/Name.php
    @@ -0,0 +1,168 @@
    + $parts,
    +            ),
    +            $attributes
    +        );
    +    }
    +
    +    /**
    +     * Gets the first part of the name, i.e. everything before the first namespace separator.
    +     *
    +     * @return string First part of the name
    +     */
    +    public function getFirst() {
    +        return $this->parts[0];
    +    }
    +
    +    /**
    +     * Gets the last part of the name, i.e. everything after the last namespace separator.
    +     *
    +     * @return string Last part of the name
    +     */
    +    public function getLast() {
    +        return $this->parts[count($this->parts) - 1];
    +    }
    +
    +    /**
    +     * Checks whether the name is unqualified. (E.g. Name)
    +     *
    +     * @return bool Whether the name is unqualified
    +     */
    +    public function isUnqualified() {
    +        return 1 == count($this->parts);
    +    }
    +
    +    /**
    +     * Checks whether the name is qualified. (E.g. Name\Name)
    +     *
    +     * @return bool Whether the name is qualified
    +     */
    +    public function isQualified() {
    +        return 1 < count($this->parts);
    +    }
    +
    +    /**
    +     * Checks whether the name is fully qualified. (E.g. \Name)
    +     *
    +     * @return bool Whether the name is fully qualified
    +     */
    +    public function isFullyQualified() {
    +        return false;
    +    }
    +
    +    /**
    +     * Checks whether the name is explicitly relative to the current namespace. (E.g. namespace\Name)
    +     *
    +     * @return bool Whether the name is relative
    +     */
    +    public function isRelative() {
    +        return false;
    +    }
    +
    +    /**
    +     * Returns a string representation of the name by imploding the namespace parts with a separator.
    +     *
    +     * @param string $separator The separator to use (defaults to the namespace separator \)
    +     *
    +     * @return string String representation
    +     */
    +    public function toString($separator = '\\') {
    +        return implode($separator, $this->parts);
    +    }
    +
    +    /**
    +     * Returns a string representation of the name by imploding the namespace parts with the
    +     * namespace separator.
    +     *
    +     * @return string String representation
    +     */
    +    public function __toString() {
    +        return implode('\\', $this->parts);
    +    }
    +
    +    /**
    +     * Sets the whole name.
    +     *
    +     * @param string|array|self $name The name to set the whole name to
    +     */
    +    public function set($name) {
    +        $this->parts = $this->prepareName($name);
    +    }
    +
    +    /**
    +     * Prepends a name to this name.
    +     *
    +     * @param string|array|self $name Name to prepend
    +     */
    +    public function prepend($name) {
    +        $this->parts = array_merge($this->prepareName($name), $this->parts);
    +    }
    +
    +    /**
    +     * Appends a name to this name.
    +     *
    +     * @param string|array|self $name Name to append
    +     */
    +    public function append($name) {
    +        $this->parts = array_merge($this->parts, $this->prepareName($name));
    +    }
    +
    +    /**
    +     * Sets the first part of the name.
    +     *
    +     * @param string|array|self $name The name to set the first part to
    +     */
    +    public function setFirst($name) {
    +        array_splice($this->parts, 0, 1, $this->prepareName($name));
    +    }
    +
    +    /**
    +     * Sets the last part of the name.
    +     *
    +     * @param string|array|self $name The name to set the last part to
    +     */
    +    public function setLast($name) {
    +        array_splice($this->parts, -1, 1, $this->prepareName($name));
    +    }
    +
    +    /**
    +     * Prepares a (string, array or Name node) name for use in name changing methods by converting
    +     * it to an array.
    +     *
    +     * @param string|array|self $name Name to prepare
    +     *
    +     * @return array Prepared name
    +     */
    +    protected function prepareName($name) {
    +        if (is_string($name)) {
    +            return explode('\\', $name);
    +        } elseif (is_array($name)) {
    +            return $name;
    +        } elseif ($name instanceof self) {
    +            return $name->parts;
    +        }
    +
    +        throw new InvalidArgumentException(
    +            'When changing a name you need to pass either a string, an array or a Name node'
    +        );
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/Node/Name/FullyQualified.php b/vendor/nikic/php-parser/lib/PHPParser/Node/Name/FullyQualified.php
    new file mode 100755
    index 0000000..5531ad1
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/Node/Name/FullyQualified.php
    @@ -0,0 +1,40 @@
    + $name,
    +                'default' => $default,
    +                'type'    => $type,
    +                'byRef'   => $byRef
    +            ),
    +            $attributes
    +        );
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/Node/Scalar.php b/vendor/nikic/php-parser/lib/PHPParser/Node/Scalar.php
    new file mode 100755
    index 0000000..a2cfeb2
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/Node/Scalar.php
    @@ -0,0 +1,5 @@
    + $value
    +            ),
    +            $attributes
    +        );
    +    }
    +
    +    /**
    +     * Parses a DNUMBER token like PHP would.
    +     *
    +     * @param string $str A string number
    +     *
    +     * @return float The parsed number
    +     */
    +    public static function parse($str) {
    +        // if string contains any of .eE just cast it to float
    +        if (false !== strpbrk($str, '.eE')) {
    +            return (float) $str;
    +        }
    +
    +        // otherwise it's an integer notation that overflowed into a float
    +        // if it starts with 0 it's one of the special integer notations
    +        if ('0' === $str[0]) {
    +            // hex
    +            if ('x' === $str[1] || 'X' === $str[1]) {
    +                return hexdec($str);
    +            }
    +
    +            // bin
    +            if ('b' === $str[1] || 'B' === $str[1]) {
    +                return bindec($str);
    +            }
    +
    +            // oct
    +            // substr($str, 0, strcspn($str, '89')) cuts the string at the first invalid digit (8 or 9)
    +            // so that only the digits before that are used
    +            return octdec(substr($str, 0, strcspn($str, '89')));
    +        }
    +
    +        // dec
    +        return (float) $str;
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/Node/Scalar/DirConst.php b/vendor/nikic/php-parser/lib/PHPParser/Node/Scalar/DirConst.php
    new file mode 100755
    index 0000000..d3be11b
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/Node/Scalar/DirConst.php
    @@ -0,0 +1,13 @@
    + $parts
    +            ),
    +            $attributes
    +        );
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/Node/Scalar/FileConst.php b/vendor/nikic/php-parser/lib/PHPParser/Node/Scalar/FileConst.php
    new file mode 100755
    index 0000000..b0737f0
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/Node/Scalar/FileConst.php
    @@ -0,0 +1,13 @@
    + $value
    +            ),
    +            $attributes
    +        );
    +    }
    +
    +    /**
    +     * Parses an LNUMBER token (dec, hex, oct and bin notations) like PHP would.
    +     *
    +     * @param string $str A string number
    +     *
    +     * @return int The parsed number
    +     */
    +    public static function parse($str) {
    +        // handle plain 0 specially
    +        if ('0' === $str) {
    +            return 0;
    +        }
    +
    +        // if first char is 0 (and number isn't 0) it's a special syntax
    +        if ('0' === $str[0]) {
    +            // hex
    +            if ('x' === $str[1] || 'X' === $str[1]) {
    +                return hexdec($str);
    +            }
    +
    +            // bin
    +            if ('b' === $str[1] || 'B' === $str[1]) {
    +                return bindec($str);
    +            }
    +
    +            // oct (intval instead of octdec to get proper cutting behavior with malformed numbers)
    +            return intval($str, 8);
    +        }
    +
    +        // dec
    +        return (int) $str;
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/Node/Scalar/LineConst.php b/vendor/nikic/php-parser/lib/PHPParser/Node/Scalar/LineConst.php
    new file mode 100755
    index 0000000..bde002d
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/Node/Scalar/LineConst.php
    @@ -0,0 +1,13 @@
    + '\\',
    +        '$'  =>  '$',
    +        'n'  => "\n",
    +        'r'  => "\r",
    +        't'  => "\t",
    +        'f'  => "\f",
    +        'v'  => "\v",
    +        'e'  => "\x1B",
    +    );
    +
    +    /**
    +     * Constructs a string scalar node.
    +     *
    +     * @param string $value      Value of the string
    +     * @param array  $attributes Additional attributes
    +     */
    +    public function __construct($value = '', array $attributes = array()) {
    +        parent::__construct(
    +            array(
    +                'value' => $value
    +            ),
    +            $attributes
    +        );
    +    }
    +
    +    /**
    +     * Parses a string token.
    +     *
    +     * @param string $str String token content
    +     *
    +     * @return string The parsed string
    +     */
    +    public static function parse($str) {
    +        $bLength = 0;
    +        if ('b' === $str[0]) {
    +            $bLength = 1;
    +        }
    +
    +        if ('\'' === $str[$bLength]) {
    +            return str_replace(
    +                array('\\\\', '\\\''),
    +                array(  '\\',   '\''),
    +                substr($str, $bLength + 1, -1)
    +            );
    +        } else {
    +            return self::parseEscapeSequences(substr($str, $bLength + 1, -1), '"');
    +        }
    +    }
    +
    +    /**
    +     * Parses escape sequences in strings (all string types apart from single quoted).
    +     *
    +     * @param string      $str   String without quotes
    +     * @param null|string $quote Quote type
    +     *
    +     * @return string String with escape sequences parsed
    +     */
    +    public static function parseEscapeSequences($str, $quote) {
    +        if (null !== $quote) {
    +            $str = str_replace('\\' . $quote, $quote, $str);
    +        }
    +
    +        return preg_replace_callback(
    +            '~\\\\([\\\\$nrtfve]|[xX][0-9a-fA-F]{1,2}|[0-7]{1,3})~',
    +            array(__CLASS__, 'parseCallback'),
    +            $str
    +        );
    +    }
    +
    +    public static function parseCallback($matches) {
    +        $str = $matches[1];
    +
    +        if (isset(self::$replacements[$str])) {
    +            return self::$replacements[$str];
    +        } elseif ('x' === $str[0] || 'X' === $str[0]) {
    +            return chr(hexdec($str));
    +        } else {
    +            return chr(octdec($str));
    +        }
    +    }
    +
    +    /**
    +     * Parses a constant doc string.
    +     *
    +     * @param string $startToken Doc string start token content (<< $num,
    +            ),
    +            $attributes
    +        );
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/Node/Stmt/Case.php b/vendor/nikic/php-parser/lib/PHPParser/Node/Stmt/Case.php
    new file mode 100755
    index 0000000..bf90c6e
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/Node/Stmt/Case.php
    @@ -0,0 +1,25 @@
    + $cond,
    +                'stmts' => $stmts,
    +            ),
    +            $attributes
    +        );
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/Node/Stmt/Catch.php b/vendor/nikic/php-parser/lib/PHPParser/Node/Stmt/Catch.php
    new file mode 100755
    index 0000000..336cf2d
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/Node/Stmt/Catch.php
    @@ -0,0 +1,28 @@
    + $type,
    +                'var'   => $var,
    +                'stmts' => $stmts,
    +            ),
    +            $attributes
    +        );
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/Node/Stmt/Class.php b/vendor/nikic/php-parser/lib/PHPParser/Node/Stmt/Class.php
    new file mode 100755
    index 0000000..2585d98
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/Node/Stmt/Class.php
    @@ -0,0 +1,102 @@
    + true,
    +        'parent' => true,
    +        'static' => true,
    +    );
    +
    +    /**
    +     * Constructs a class node.
    +     *
    +     * @param string      $name       Name
    +     * @param array       $subNodes   Array of the following optional subnodes:
    +     *                                'type'       => 0      : Type
    +     *                                'extends'    => null   : Name of extended class
    +     *                                'implements' => array(): Names of implemented interfaces
    +     *                                'stmts'      => array(): Statements
    +     * @param array       $attributes Additional attributes
    +     */
    +    public function __construct($name, array $subNodes = array(), array $attributes = array()) {
    +        parent::__construct(
    +            $subNodes + array(
    +                'type'       => 0,
    +                'extends'    => null,
    +                'implements' => array(),
    +                'stmts'      => array(),
    +            ),
    +            $attributes
    +        );
    +        $this->name = $name;
    +
    +        if (isset(self::$specialNames[(string) $this->name])) {
    +            throw new PHPParser_Error(sprintf('Cannot use "%s" as class name as it is reserved', $this->name));
    +        }
    +
    +        if (isset(self::$specialNames[(string) $this->extends])) {
    +            throw new PHPParser_Error(sprintf('Cannot use "%s" as class name as it is reserved', $this->extends));
    +        }
    +
    +        foreach ($this->implements as $interface) {
    +            if (isset(self::$specialNames[(string) $interface])) {
    +                throw new PHPParser_Error(sprintf('Cannot use "%s" as interface name as it is reserved', $interface));
    +            }
    +        }
    +    }
    +
    +    public function isAbstract() {
    +        return (bool) ($this->type & self::MODIFIER_ABSTRACT);
    +    }
    +
    +    public function isFinal() {
    +        return (bool) ($this->type & self::MODIFIER_FINAL);
    +    }
    +
    +    public function getMethods() {
    +        $methods = array();
    +        foreach ($this->stmts as $stmt) {
    +            if ($stmt instanceof PHPParser_Node_Stmt_ClassMethod) {
    +                $methods[] = $stmt;
    +            }
    +        }
    +        return $methods;
    +    }
    +
    +    public static function verifyModifier($a, $b) {
    +        if ($a & 7 && $b & 7) {
    +            throw new PHPParser_Error('Multiple access type modifiers are not allowed');
    +        }
    +
    +        if ($a & self::MODIFIER_ABSTRACT && $b & self::MODIFIER_ABSTRACT) {
    +            throw new PHPParser_Error('Multiple abstract modifiers are not allowed');
    +        }
    +
    +        if ($a & self::MODIFIER_STATIC && $b & self::MODIFIER_STATIC) {
    +            throw new PHPParser_Error('Multiple static modifiers are not allowed');
    +        }
    +
    +        if ($a & self::MODIFIER_FINAL && $b & self::MODIFIER_FINAL) {
    +            throw new PHPParser_Error('Multiple final modifiers are not allowed');
    +        }
    +
    +        if ($a & 48 && $b & 48) {
    +            throw new PHPParser_Error('Cannot use the final and abstract modifier at the same time');
    +        }
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/Node/Stmt/ClassConst.php b/vendor/nikic/php-parser/lib/PHPParser/Node/Stmt/ClassConst.php
    new file mode 100755
    index 0000000..6d0895c
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/Node/Stmt/ClassConst.php
    @@ -0,0 +1,22 @@
    + $consts,
    +            ),
    +            $attributes
    +        );
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/Node/Stmt/ClassMethod.php b/vendor/nikic/php-parser/lib/PHPParser/Node/Stmt/ClassMethod.php
    new file mode 100755
    index 0000000..99c0c3d
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/Node/Stmt/ClassMethod.php
    @@ -0,0 +1,66 @@
    + MODIFIER_PUBLIC: Type
    +     *                                'byRef'  => false          : Whether to return by reference
    +     *                                'params' => array()        : Parameters
    +     *                                'stmts'  => array()        : Statements
    +     * @param array       $attributes Additional attributes
    +     */
    +    public function __construct($name, array $subNodes = array(), array $attributes = array()) {
    +        parent::__construct(
    +            $subNodes + array(
    +                'type'   => PHPParser_Node_Stmt_Class::MODIFIER_PUBLIC,
    +                'byRef'  => false,
    +                'params' => array(),
    +                'stmts'  => array(),
    +            ),
    +            $attributes
    +        );
    +        $this->name = $name;
    +
    +        if (($this->type & PHPParser_Node_Stmt_Class::MODIFIER_STATIC)
    +            && ('__construct' == $this->name || '__destruct' == $this->name || '__clone' == $this->name)
    +        ) {
    +            throw new PHPParser_Error(sprintf('"%s" method cannot be static', $this->name));
    +        }
    +    }
    +
    +    public function isPublic() {
    +        return (bool) ($this->type & PHPParser_Node_Stmt_Class::MODIFIER_PUBLIC);
    +    }
    +
    +    public function isProtected() {
    +        return (bool) ($this->type & PHPParser_Node_Stmt_Class::MODIFIER_PROTECTED);
    +    }
    +
    +    public function isPrivate() {
    +        return (bool) ($this->type & PHPParser_Node_Stmt_Class::MODIFIER_PRIVATE);
    +    }
    +
    +    public function isAbstract() {
    +        return (bool) ($this->type & PHPParser_Node_Stmt_Class::MODIFIER_ABSTRACT);
    +    }
    +
    +    public function isFinal() {
    +        return (bool) ($this->type & PHPParser_Node_Stmt_Class::MODIFIER_FINAL);
    +    }
    +
    +    public function isStatic() {
    +        return (bool) ($this->type & PHPParser_Node_Stmt_Class::MODIFIER_STATIC);
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/Node/Stmt/Const.php b/vendor/nikic/php-parser/lib/PHPParser/Node/Stmt/Const.php
    new file mode 100755
    index 0000000..9a7ea08
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/Node/Stmt/Const.php
    @@ -0,0 +1,22 @@
    + $consts,
    +            ),
    +            $attributes
    +        );
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/Node/Stmt/Continue.php b/vendor/nikic/php-parser/lib/PHPParser/Node/Stmt/Continue.php
    new file mode 100755
    index 0000000..bc82e54
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/Node/Stmt/Continue.php
    @@ -0,0 +1,22 @@
    + $num,
    +            ),
    +            $attributes
    +        );
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/Node/Stmt/Declare.php b/vendor/nikic/php-parser/lib/PHPParser/Node/Stmt/Declare.php
    new file mode 100755
    index 0000000..c10083c
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/Node/Stmt/Declare.php
    @@ -0,0 +1,25 @@
    + $declares,
    +                'stmts'    => $stmts,
    +            ),
    +            $attributes
    +        );
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/Node/Stmt/DeclareDeclare.php b/vendor/nikic/php-parser/lib/PHPParser/Node/Stmt/DeclareDeclare.php
    new file mode 100755
    index 0000000..1526e66
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/Node/Stmt/DeclareDeclare.php
    @@ -0,0 +1,25 @@
    +value pair node.
    +     *
    +     * @param string              $key        Key
    +     * @param PHPParser_Node_Expr $value      Value
    +     * @param array               $attributes Additional attributes
    +     */
    +    public function __construct($key, PHPParser_Node_Expr $value, array $attributes = array()) {
    +        parent::__construct(
    +            array(
    +                'key'   => $key,
    +                'value' => $value,
    +            ),
    +            $attributes
    +        );
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/Node/Stmt/Do.php b/vendor/nikic/php-parser/lib/PHPParser/Node/Stmt/Do.php
    new file mode 100755
    index 0000000..12070c0
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/Node/Stmt/Do.php
    @@ -0,0 +1,25 @@
    + $cond,
    +                'stmts' => $stmts,
    +            ),
    +            $attributes
    +        );
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/Node/Stmt/Echo.php b/vendor/nikic/php-parser/lib/PHPParser/Node/Stmt/Echo.php
    new file mode 100755
    index 0000000..77a5d59
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/Node/Stmt/Echo.php
    @@ -0,0 +1,22 @@
    + $exprs,
    +            ),
    +            $attributes
    +        );
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/Node/Stmt/Else.php b/vendor/nikic/php-parser/lib/PHPParser/Node/Stmt/Else.php
    new file mode 100755
    index 0000000..18ff649
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/Node/Stmt/Else.php
    @@ -0,0 +1,22 @@
    + $stmts,
    +            ),
    +            $attributes
    +        );
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/Node/Stmt/ElseIf.php b/vendor/nikic/php-parser/lib/PHPParser/Node/Stmt/ElseIf.php
    new file mode 100755
    index 0000000..ec0cff8
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/Node/Stmt/ElseIf.php
    @@ -0,0 +1,25 @@
    + $cond,
    +                'stmts' => $stmts,
    +            ),
    +            $attributes
    +        );
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/Node/Stmt/For.php b/vendor/nikic/php-parser/lib/PHPParser/Node/Stmt/For.php
    new file mode 100755
    index 0000000..870c7a1
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/Node/Stmt/For.php
    @@ -0,0 +1,32 @@
    + array(): Init expressions
    +     *                          'cond'  => array(): Loop conditions
    +     *                          'loop'  => array(): Loop expressions
    +     *                          'stmts' => array(): Statements
    +     * @param array $attributes Additional attributes
    +     */
    +    public function __construct(array $subNodes = array(), array $attributes = array()) {
    +        parent::__construct(
    +            $subNodes + array(
    +                'init'  => array(),
    +                'cond'  => array(),
    +                'loop'  => array(),
    +                'stmts' => array(),
    +            ),
    +            $attributes
    +        );
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/Node/Stmt/Foreach.php b/vendor/nikic/php-parser/lib/PHPParser/Node/Stmt/Foreach.php
    new file mode 100755
    index 0000000..a209c32
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/Node/Stmt/Foreach.php
    @@ -0,0 +1,35 @@
    + null   : Variable to assign key to
    +     *                                        'byRef'  => false  : Whether to assign value by reference
    +     *                                        'stmts'  => array(): Statements
    +     * @param array               $attributes Additional attributes
    +     */
    +    public function __construct(PHPParser_Node_Expr $expr, PHPParser_Node_Expr $valueVar, array $subNodes = array(), array $attributes = array()) {
    +        parent::__construct(
    +            $subNodes + array(
    +                'keyVar' => null,
    +                'byRef'  => false,
    +                'stmts'  => array(),
    +            ),
    +            $attributes
    +        );
    +        $this->expr     = $expr;
    +        $this->valueVar = $valueVar;
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/Node/Stmt/Function.php b/vendor/nikic/php-parser/lib/PHPParser/Node/Stmt/Function.php
    new file mode 100755
    index 0000000..f62de9e
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/Node/Stmt/Function.php
    @@ -0,0 +1,32 @@
    + false  : Whether to return by reference
    +     *                           'params' => array(): Parameters
    +     *                           'stmts'  => array(): Statements
    +     * @param array  $attributes Additional attributes
    +     */
    +    public function __construct($name, array $subNodes = array(), array $attributes = array()) {
    +        parent::__construct(
    +            $subNodes + array(
    +                'byRef'  => false,
    +                'params' => array(),
    +                'stmts'  => array(),
    +            ),
    +            $attributes
    +        );
    +        $this->name = $name;
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/Node/Stmt/Global.php b/vendor/nikic/php-parser/lib/PHPParser/Node/Stmt/Global.php
    new file mode 100755
    index 0000000..ba841ca
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/Node/Stmt/Global.php
    @@ -0,0 +1,22 @@
    + $vars,
    +            ),
    +            $attributes
    +        );
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/Node/Stmt/Goto.php b/vendor/nikic/php-parser/lib/PHPParser/Node/Stmt/Goto.php
    new file mode 100755
    index 0000000..8de1020
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/Node/Stmt/Goto.php
    @@ -0,0 +1,22 @@
    + $name,
    +            ),
    +            $attributes
    +        );
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/Node/Stmt/HaltCompiler.php b/vendor/nikic/php-parser/lib/PHPParser/Node/Stmt/HaltCompiler.php
    new file mode 100755
    index 0000000..0f4c4b1
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/Node/Stmt/HaltCompiler.php
    @@ -0,0 +1,22 @@
    + $remaining,
    +            ),
    +            $attributes
    +        );
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/Node/Stmt/If.php b/vendor/nikic/php-parser/lib/PHPParser/Node/Stmt/If.php
    new file mode 100755
    index 0000000..44c150b
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/Node/Stmt/If.php
    @@ -0,0 +1,33 @@
    + array(): Statements
    +     *                                        'elseifs' => array(): Elseif clauses
    +     *                                        'else'    => null   : Else clause
    +     * @param array               $attributes Additional attributes
    +     */
    +    public function __construct(PHPParser_Node_Expr $cond, array $subNodes = array(), array $attributes = array()) {
    +        parent::__construct(
    +            $subNodes + array(
    +                'stmts'   => array(),
    +                'elseifs' => array(),
    +                'else'    => null,
    +            ),
    +            $attributes
    +        );
    +        $this->cond = $cond;
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/Node/Stmt/InlineHTML.php b/vendor/nikic/php-parser/lib/PHPParser/Node/Stmt/InlineHTML.php
    new file mode 100755
    index 0000000..d0578de
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/Node/Stmt/InlineHTML.php
    @@ -0,0 +1,22 @@
    + $value,
    +            ),
    +            $attributes
    +        );
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/Node/Stmt/Interface.php b/vendor/nikic/php-parser/lib/PHPParser/Node/Stmt/Interface.php
    new file mode 100755
    index 0000000..8fc0241
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/Node/Stmt/Interface.php
    @@ -0,0 +1,45 @@
    + true,
    +        'parent' => true,
    +        'static' => true,
    +    );
    +
    +    /**
    +     * Constructs a class node.
    +     *
    +     * @param string $name       Name
    +     * @param array  $subNodes   Array of the following optional subnodes:
    +     *                           'extends' => array(): Name of extended interfaces
    +     *                           'stmts'   => array(): Statements
    +     * @param array  $attributes Additional attributes
    +     */
    +    public function __construct($name, array $subNodes = array(), array $attributes = array()) {
    +        parent::__construct(
    +            $subNodes + array(
    +                'extends' => array(),
    +                'stmts'   => array(),
    +            ),
    +            $attributes
    +        );
    +        $this->name = $name;
    +
    +        if (isset(self::$specialNames[(string) $this->name])) {
    +            throw new PHPParser_Error(sprintf('Cannot use "%s" as interface name as it is reserved', $this->name));
    +        }
    +
    +        foreach ($this->extends as $interface) {
    +            if (isset(self::$specialNames[(string) $interface])) {
    +                throw new PHPParser_Error(sprintf('Cannot use "%s" as interface name as it is reserved', $interface));
    +            }
    +        }
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/Node/Stmt/Label.php b/vendor/nikic/php-parser/lib/PHPParser/Node/Stmt/Label.php
    new file mode 100755
    index 0000000..66dc51e
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/Node/Stmt/Label.php
    @@ -0,0 +1,22 @@
    + $name,
    +            ),
    +            $attributes
    +        );
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/Node/Stmt/Namespace.php b/vendor/nikic/php-parser/lib/PHPParser/Node/Stmt/Namespace.php
    new file mode 100755
    index 0000000..7647239
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/Node/Stmt/Namespace.php
    @@ -0,0 +1,122 @@
    + true,
    +        'parent' => true,
    +        'static' => true,
    +    );
    +
    +    /**
    +     * Constructs a namespace node.
    +     *
    +     * @param null|PHPParser_Node_Name $name       Name
    +     * @param PHPParser_Node[]         $stmts      Statements
    +     * @param array                    $attributes Additional attributes
    +     */
    +    public function __construct(PHPParser_Node_Name $name = null, $stmts = array(), array $attributes = array()) {
    +        parent::__construct(
    +            array(
    +                'name'  => $name,
    +                'stmts' => $stmts,
    +            ),
    +            $attributes
    +        );
    +
    +        if (isset(self::$specialNames[(string) $this->name])) {
    +            throw new PHPParser_Error(sprintf('Cannot use "%s" as namespace name as it is reserved', $this->name));
    +        }
    +
    +        if (null !== $this->stmts) {
    +            foreach ($this->stmts as $stmt) {
    +                if ($stmt instanceof PHPParser_Node_Stmt_Namespace) {
    +                    throw new PHPParser_Error('Namespace declarations cannot be nested', $stmt->getLine());
    +                }
    +            }
    +        }
    +    }
    +
    +    public static function postprocess(array $stmts) {
    +        // null = not in namespace, false = semicolon style, true = bracket style
    +        $bracketed = null;
    +
    +        // whether any statements that aren't allowed before a namespace declaration are encountered
    +        // (the only valid statement currently is a declare)
    +        $hasNotAllowedStmts = false;
    +
    +        // offsets for semicolon style namespaces
    +        // (required for transplanting the following statements into their ->stmts property)
    +        $nsOffsets = array();
    +
    +        foreach ($stmts as $i => $stmt) {
    +            if ($stmt instanceof PHPParser_Node_Stmt_Namespace) {
    +                // ->stmts is null if semicolon style is used
    +                $currentBracketed = null !== $stmt->stmts;
    +
    +                // if no namespace statement has been encountered yet
    +                if (!isset($bracketed)) {
    +                    // set the namespacing style
    +                    $bracketed = $currentBracketed;
    +
    +                    // and ensure that it isn't preceded by a not allowed statement
    +                    if ($hasNotAllowedStmts) {
    +                        throw new PHPParser_Error('Namespace declaration statement has to be the very first statement in the script', $stmt->getLine());
    +                    }
    +                // otherwise ensure that the style of the current namespace matches the style of
    +                // namespaceing used before in this document
    +                } elseif ($bracketed !== $currentBracketed) {
    +                    throw new PHPParser_Error('Cannot mix bracketed namespace declarations with unbracketed namespace declarations', $stmt->getLine());
    +                }
    +
    +                // for semicolon style namespaces remember the offset
    +                if (!$bracketed) {
    +                    $nsOffsets[] = $i;
    +                }
    +            // declare() and __halt_compiler() are the only valid statements outside of namespace declarations
    +            } elseif (!$stmt instanceof PHPParser_Node_Stmt_Declare
    +                      && !$stmt instanceof PHPParser_Node_Stmt_HaltCompiler
    +            ) {
    +                if (true === $bracketed) {
    +                    throw new PHPParser_Error('No code may exist outside of namespace {}', $stmt->getLine());
    +                }
    +
    +                $hasNotAllowedStmts = true;
    +            }
    +        }
    +
    +        // if bracketed namespaces were used or no namespaces were used at all just return the
    +        // original statements
    +        if (!isset($bracketed) || true === $bracketed) {
    +            return $stmts;
    +        // for semicolon style transplant statements
    +        } else {
    +            // take all statements preceding the first namespace
    +            $newStmts = array_slice($stmts, 0, $nsOffsets[0]);
    +
    +            // iterate over all following namespaces
    +            for ($i = 0, $c = count($nsOffsets); $i < $c; ++$i) {
    +                $newStmts[] = $nsStmt = $stmts[$nsOffsets[$i]];
    +
    +                // the last namespace takes all statements after it
    +                if ($c === $i + 1) {
    +                    $nsStmt->stmts = array_slice($stmts, $nsOffsets[$i] + 1);
    +
    +                    // if the last statement is __halt_compiler() put it outside the namespace
    +                    if (end($nsStmt->stmts) instanceof PHPParser_Node_Stmt_HaltCompiler) {
    +                        $newStmts[] = array_pop($nsStmt->stmts);
    +                    }
    +                // and all the others take all statements between the current and the following one
    +                } else {
    +                    $nsStmt->stmts = array_slice($stmts, $nsOffsets[$i] + 1, $nsOffsets[$i + 1] - $nsOffsets[$i] - 1);
    +                }
    +            }
    +
    +            return $newStmts;
    +        }
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/Node/Stmt/Property.php b/vendor/nikic/php-parser/lib/PHPParser/Node/Stmt/Property.php
    new file mode 100755
    index 0000000..5cc9d0c
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/Node/Stmt/Property.php
    @@ -0,0 +1,41 @@
    + $type,
    +                'props' => $props,
    +            ),
    +            $attributes
    +        );
    +    }
    +
    +    public function isPublic() {
    +        return (bool) ($this->type & PHPParser_Node_Stmt_Class::MODIFIER_PUBLIC);
    +    }
    +
    +    public function isProtected() {
    +        return (bool) ($this->type & PHPParser_Node_Stmt_Class::MODIFIER_PROTECTED);
    +    }
    +
    +    public function isPrivate() {
    +        return (bool) ($this->type & PHPParser_Node_Stmt_Class::MODIFIER_PRIVATE);
    +    }
    +
    +    public function isStatic() {
    +        return (bool) ($this->type & PHPParser_Node_Stmt_Class::MODIFIER_STATIC);
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/Node/Stmt/PropertyProperty.php b/vendor/nikic/php-parser/lib/PHPParser/Node/Stmt/PropertyProperty.php
    new file mode 100755
    index 0000000..e2854f1
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/Node/Stmt/PropertyProperty.php
    @@ -0,0 +1,25 @@
    + $name,
    +                'default' => $default,
    +            ),
    +            $attributes
    +        );
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/Node/Stmt/Return.php b/vendor/nikic/php-parser/lib/PHPParser/Node/Stmt/Return.php
    new file mode 100755
    index 0000000..4697530
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/Node/Stmt/Return.php
    @@ -0,0 +1,22 @@
    + $expr,
    +            ),
    +            $attributes
    +        );
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/Node/Stmt/Static.php b/vendor/nikic/php-parser/lib/PHPParser/Node/Stmt/Static.php
    new file mode 100755
    index 0000000..f44d1ed
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/Node/Stmt/Static.php
    @@ -0,0 +1,22 @@
    + $vars,
    +            ),
    +            $attributes
    +        );
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/Node/Stmt/StaticVar.php b/vendor/nikic/php-parser/lib/PHPParser/Node/Stmt/StaticVar.php
    new file mode 100755
    index 0000000..3c5b144
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/Node/Stmt/StaticVar.php
    @@ -0,0 +1,25 @@
    + $name,
    +                'default' => $default,
    +            ),
    +            $attributes
    +        );
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/Node/Stmt/Switch.php b/vendor/nikic/php-parser/lib/PHPParser/Node/Stmt/Switch.php
    new file mode 100755
    index 0000000..f7022a0
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/Node/Stmt/Switch.php
    @@ -0,0 +1,25 @@
    + $cond,
    +                'cases' => $cases,
    +            ),
    +            $attributes
    +        );
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/Node/Stmt/Throw.php b/vendor/nikic/php-parser/lib/PHPParser/Node/Stmt/Throw.php
    new file mode 100755
    index 0000000..990de1a
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/Node/Stmt/Throw.php
    @@ -0,0 +1,22 @@
    + $expr,
    +            ),
    +            $attributes
    +        );
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/Node/Stmt/Trait.php b/vendor/nikic/php-parser/lib/PHPParser/Node/Stmt/Trait.php
    new file mode 100755
    index 0000000..14737a5
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/Node/Stmt/Trait.php
    @@ -0,0 +1,25 @@
    + $name,
    +                'stmts' => $stmts,
    +            ),
    +            $attributes
    +        );
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/Node/Stmt/TraitUse.php b/vendor/nikic/php-parser/lib/PHPParser/Node/Stmt/TraitUse.php
    new file mode 100755
    index 0000000..8db1b7e
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/Node/Stmt/TraitUse.php
    @@ -0,0 +1,25 @@
    + $traits,
    +                'adaptations' => $adaptations,
    +            ),
    +            $attributes
    +        );
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/Node/Stmt/TraitUseAdaptation.php b/vendor/nikic/php-parser/lib/PHPParser/Node/Stmt/TraitUseAdaptation.php
    new file mode 100755
    index 0000000..63b2b27
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/Node/Stmt/TraitUseAdaptation.php
    @@ -0,0 +1,5 @@
    + $trait,
    +                'method'      => $method,
    +                'newModifier' => $newModifier,
    +                'newName'     => $newName,
    +            ),
    +            $attributes
    +        );
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/Node/Stmt/TraitUseAdaptation/Precedence.php b/vendor/nikic/php-parser/lib/PHPParser/Node/Stmt/TraitUseAdaptation/Precedence.php
    new file mode 100755
    index 0000000..30ae8e4
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/Node/Stmt/TraitUseAdaptation/Precedence.php
    @@ -0,0 +1,28 @@
    + $trait,
    +                'method'    => $method,
    +                'insteadof' => $insteadof,
    +            ),
    +            $attributes
    +        );
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/Node/Stmt/TryCatch.php b/vendor/nikic/php-parser/lib/PHPParser/Node/Stmt/TryCatch.php
    new file mode 100755
    index 0000000..796aae3
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/Node/Stmt/TryCatch.php
    @@ -0,0 +1,32 @@
    + $stmts,
    +                'catches'      => $catches,
    +                'finallyStmts' => $finallyStmts,
    +            ),
    +            $attributes
    +        );
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/Node/Stmt/Unset.php b/vendor/nikic/php-parser/lib/PHPParser/Node/Stmt/Unset.php
    new file mode 100755
    index 0000000..e079c29
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/Node/Stmt/Unset.php
    @@ -0,0 +1,22 @@
    + $vars,
    +            ),
    +            $attributes
    +        );
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/Node/Stmt/Use.php b/vendor/nikic/php-parser/lib/PHPParser/Node/Stmt/Use.php
    new file mode 100755
    index 0000000..36dc0b1
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/Node/Stmt/Use.php
    @@ -0,0 +1,22 @@
    + $uses,
    +            ),
    +            $attributes
    +        );
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/Node/Stmt/UseUse.php b/vendor/nikic/php-parser/lib/PHPParser/Node/Stmt/UseUse.php
    new file mode 100755
    index 0000000..2287af0
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/Node/Stmt/UseUse.php
    @@ -0,0 +1,36 @@
    +getLast();
    +        }
    +
    +        if ('self' == $alias || 'parent' == $alias) {
    +            throw new PHPParser_Error(sprintf(
    +                'Cannot use "%s" as "%s" because "%2$s" is a special class name',
    +                $name, $alias
    +            ));
    +        }
    +
    +        parent::__construct(
    +            array(
    +                'name'  => $name,
    +                'alias' => $alias,
    +            ),
    +            $attributes
    +        );
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/Node/Stmt/While.php b/vendor/nikic/php-parser/lib/PHPParser/Node/Stmt/While.php
    new file mode 100755
    index 0000000..4dde965
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/Node/Stmt/While.php
    @@ -0,0 +1,25 @@
    + $cond,
    +                'stmts' => $stmts,
    +            ),
    +            $attributes
    +        );
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/NodeAbstract.php b/vendor/nikic/php-parser/lib/PHPParser/NodeAbstract.php
    new file mode 100755
    index 0000000..e7d0456
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/NodeAbstract.php
    @@ -0,0 +1,125 @@
    +subNodes   = $subNodes;
    +        $this->attributes = $attributes;
    +    }
    +
    +    /**
    +     * Gets the type of the node.
    +     *
    +     * @return string Type of the node
    +     */
    +    public function getType() {
    +        return substr(get_class($this), 15);
    +    }
    +
    +    /**
    +     * Gets the names of the sub nodes.
    +     *
    +     * @return array Names of sub nodes
    +     */
    +    public function getSubNodeNames() {
    +        return array_keys($this->subNodes);
    +    }
    +
    +    /**
    +     * Gets line the node started in.
    +     *
    +     * @return int Line
    +     */
    +    public function getLine() {
    +        return $this->getAttribute('startLine', -1);
    +    }
    +
    +    /**
    +     * Sets line the node started in.
    +     *
    +     * @param int $line Line
    +     */
    +    public function setLine($line) {
    +        $this->setAttribute('startLine', (int) $line);
    +    }
    +
    +    /**
    +     * Gets the doc comment of the node.
    +     *
    +     * The doc comment has to be the last comment associated with the node.
    +     *
    +     * @return null|PHPParser_Comment_Doc Doc comment object or null
    +     */
    +    public function getDocComment() {
    +        $comments = $this->getAttribute('comments');
    +        if (!$comments) {
    +            return null;
    +        }
    +
    +        $lastComment = $comments[count($comments) - 1];
    +        if (!$lastComment instanceof PHPParser_Comment_Doc) {
    +            return null;
    +        }
    +
    +        return $lastComment;
    +    }
    +
    +    /**
    +     * {@inheritDoc}
    +     */
    +    public function setAttribute($key, $value) {
    +        $this->attributes[$key] = $value;
    +    }
    +
    +    /**
    +     * {@inheritDoc}
    +     */
    +    public function hasAttribute($key) {
    +        return array_key_exists($key, $this->attributes);
    +    }
    +
    +    /**
    +     * {@inheritDoc}
    +     */
    +    public function &getAttribute($key, $default = null) {
    +        if (!array_key_exists($key, $this->attributes)) {
    +            return $default;
    +        } else {
    +            return $this->attributes[$key];
    +        }
    +    }
    +
    +    /**
    +     * {@inheritDoc}
    +     */
    +    public function getAttributes() {
    +        return $this->attributes;
    +    }
    +
    +    /* Magic interfaces */
    +
    +    public function &__get($name) {
    +        return $this->subNodes[$name];
    +    }
    +    public function __set($name, $value) {
    +        $this->subNodes[$name] = $value;
    +    }
    +    public function __isset($name) {
    +        return isset($this->subNodes[$name]);
    +    }
    +    public function __unset($name) {
    +        unset($this->subNodes[$name]);
    +    }
    +    public function getIterator() {
    +        return new ArrayIterator($this->subNodes);
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/NodeDumper.php b/vendor/nikic/php-parser/lib/PHPParser/NodeDumper.php
    new file mode 100755
    index 0000000..283d630
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/NodeDumper.php
    @@ -0,0 +1,39 @@
    +getType() . '(';
    +        } elseif (is_array($node)) {
    +            $r = 'array(';
    +        } else {
    +            throw new InvalidArgumentException('Can only dump nodes and arrays.');
    +        }
    +
    +        foreach ($node as $key => $value) {
    +            $r .= "\n" . '    ' . $key . ': ';
    +
    +            if (null === $value) {
    +                $r .= 'null';
    +            } elseif (false === $value) {
    +                $r .= 'false';
    +            } elseif (true === $value) {
    +                $r .= 'true';
    +            } elseif (is_scalar($value)) {
    +                $r .= $value;
    +            } else {
    +                $r .= str_replace("\n", "\n" . '    ', $this->dump($value));
    +            }
    +        }
    +
    +        return $r . "\n" . ')';
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/NodeTraverser.php b/vendor/nikic/php-parser/lib/PHPParser/NodeTraverser.php
    new file mode 100755
    index 0000000..348e78d
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/NodeTraverser.php
    @@ -0,0 +1,118 @@
    +visitors = array();
    +    }
    +
    +    /**
    +     * Adds a visitor.
    +     *
    +     * @param PHPParser_NodeVisitor $visitor Visitor to add
    +     */
    +    public function addVisitor(PHPParser_NodeVisitor $visitor) {
    +        $this->visitors[] = $visitor;
    +    }
    +
    +    /**
    +     * Traverses an array of nodes using the registered visitors.
    +     *
    +     * @param PHPParser_Node[] $nodes Array of nodes
    +     *
    +     * @return PHPParser_Node[] Traversed array of nodes
    +     */
    +    public function traverse(array $nodes) {
    +        foreach ($this->visitors as $visitor) {
    +            if (null !== $return = $visitor->beforeTraverse($nodes)) {
    +                $nodes = $return;
    +            }
    +        }
    +
    +        $nodes = $this->traverseArray($nodes);
    +
    +        foreach ($this->visitors as $visitor) {
    +            if (null !== $return = $visitor->afterTraverse($nodes)) {
    +                $nodes = $return;
    +            }
    +        }
    +
    +        return $nodes;
    +    }
    +
    +    protected function traverseNode(PHPParser_Node $node) {
    +        $node = clone $node;
    +
    +        foreach ($node->getSubNodeNames() as $name) {
    +            $subNode =& $node->$name;
    +
    +            if (is_array($subNode)) {
    +                $subNode = $this->traverseArray($subNode);
    +            } elseif ($subNode instanceof PHPParser_Node) {
    +                foreach ($this->visitors as $visitor) {
    +                    if (null !== $return = $visitor->enterNode($subNode)) {
    +                        $subNode = $return;
    +                    }
    +                }
    +
    +                $subNode = $this->traverseNode($subNode);
    +
    +                foreach ($this->visitors as $visitor) {
    +                    if (null !== $return = $visitor->leaveNode($subNode)) {
    +                        $subNode = $return;
    +                    }
    +                }
    +            }
    +        }
    +
    +        return $node;
    +    }
    +
    +    protected function traverseArray(array $nodes) {
    +        $doNodes = array();
    +
    +        foreach ($nodes as $i => &$node) {
    +            if (is_array($node)) {
    +                $node = $this->traverseArray($node);
    +            } elseif ($node instanceof PHPParser_Node) {
    +                foreach ($this->visitors as $visitor) {
    +                    if (null !== $return = $visitor->enterNode($node)) {
    +                        $node = $return;
    +                    }
    +                }
    +
    +                $node = $this->traverseNode($node);
    +
    +                foreach ($this->visitors as $visitor) {
    +                    $return = $visitor->leaveNode($node);
    +
    +                    if (false === $return) {
    +                        $doNodes[] = array($i, array());
    +                        break;
    +                    } elseif (is_array($return)) {
    +                        $doNodes[] = array($i, $return);
    +                        break;
    +                    } elseif (null !== $return) {
    +                        $node = $return;
    +                    }
    +                }
    +            }
    +        }
    +
    +        if (!empty($doNodes)) {
    +            while (list($i, $replace) = array_pop($doNodes)) {
    +                array_splice($nodes, $i, 1, $replace);
    +            }
    +        }
    +
    +        return $nodes;
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/NodeTraverserInterface.php b/vendor/nikic/php-parser/lib/PHPParser/NodeTraverserInterface.php
    new file mode 100755
    index 0000000..898eaa0
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/NodeTraverserInterface.php
    @@ -0,0 +1,21 @@
    +namespace = null;
    +        $this->aliases   = array();
    +    }
    +
    +    public function enterNode(PHPParser_Node $node) {
    +        if ($node instanceof PHPParser_Node_Stmt_Namespace) {
    +            $this->namespace = $node->name;
    +            $this->aliases   = array();
    +        } elseif ($node instanceof PHPParser_Node_Stmt_UseUse) {
    +            if (isset($this->aliases[$node->alias])) {
    +                throw new PHPParser_Error(
    +                    sprintf(
    +                        'Cannot use "%s" as "%s" because the name is already in use',
    +                        $node->name, $node->alias
    +                    ),
    +                    $node->getLine()
    +                );
    +            }
    +
    +            $this->aliases[$node->alias] = $node->name;
    +        } elseif ($node instanceof PHPParser_Node_Stmt_Class) {
    +            if (null !== $node->extends) {
    +                $node->extends = $this->resolveClassName($node->extends);
    +            }
    +
    +            foreach ($node->implements as &$interface) {
    +                $interface = $this->resolveClassName($interface);
    +            }
    +
    +            $this->addNamespacedName($node);
    +        } elseif ($node instanceof PHPParser_Node_Stmt_Interface) {
    +            foreach ($node->extends as &$interface) {
    +                $interface = $this->resolveClassName($interface);
    +            }
    +
    +            $this->addNamespacedName($node);
    +        } elseif ($node instanceof PHPParser_Node_Stmt_Trait) {
    +            $this->addNamespacedName($node);
    +        } elseif ($node instanceof PHPParser_Node_Stmt_Function) {
    +            $this->addNamespacedName($node);
    +        } elseif ($node instanceof PHPParser_Node_Stmt_Const) {
    +            foreach ($node->consts as $const) {
    +                $this->addNamespacedName($const);
    +            }
    +        } elseif ($node instanceof PHPParser_Node_Expr_StaticCall
    +                  || $node instanceof PHPParser_Node_Expr_StaticPropertyFetch
    +                  || $node instanceof PHPParser_Node_Expr_ClassConstFetch
    +                  || $node instanceof PHPParser_Node_Expr_New
    +                  || $node instanceof PHPParser_Node_Expr_Instanceof
    +        ) {
    +            if ($node->class instanceof PHPParser_Node_Name) {
    +                $node->class = $this->resolveClassName($node->class);
    +            }
    +        } elseif ($node instanceof PHPParser_Node_Stmt_Catch) {
    +            $node->type = $this->resolveClassName($node->type);
    +        } elseif ($node instanceof PHPParser_Node_Expr_FuncCall
    +                  || $node instanceof PHPParser_Node_Expr_ConstFetch
    +        ) {
    +            if ($node->name instanceof PHPParser_Node_Name) {
    +                $node->name = $this->resolveOtherName($node->name);
    +            }
    +        } elseif ($node instanceof PHPParser_Node_Stmt_TraitUse) {
    +            foreach ($node->traits as &$trait) {
    +                $trait = $this->resolveClassName($trait);
    +            }
    +        } elseif ($node instanceof PHPParser_Node_Param
    +                  && $node->type instanceof PHPParser_Node_Name
    +        ) {
    +            $node->type = $this->resolveClassName($node->type);
    +        }
    +    }
    +
    +    protected function resolveClassName(PHPParser_Node_Name $name) {
    +        // don't resolve special class names
    +        if (in_array((string) $name, array('self', 'parent', 'static'))) {
    +            return $name;
    +        }
    +
    +        // fully qualified names are already resolved
    +        if ($name->isFullyQualified()) {
    +            return $name;
    +        }
    +
    +        // resolve aliases (for non-relative names)
    +        if (!$name->isRelative() && isset($this->aliases[$name->getFirst()])) {
    +            $name->setFirst($this->aliases[$name->getFirst()]);
    +        // if no alias exists prepend current namespace
    +        } elseif (null !== $this->namespace) {
    +            $name->prepend($this->namespace);
    +        }
    +
    +        return new PHPParser_Node_Name_FullyQualified($name->parts, $name->getAttributes());
    +    }
    +
    +    protected function resolveOtherName(PHPParser_Node_Name $name) {
    +        // fully qualified names are already resolved and we can't do anything about unqualified
    +        // ones at compiler-time
    +        if ($name->isFullyQualified() || $name->isUnqualified()) {
    +            return $name;
    +        }
    +
    +        // resolve aliases for qualified names
    +        if ($name->isQualified() && isset($this->aliases[$name->getFirst()])) {
    +            $name->setFirst($this->aliases[$name->getFirst()]);
    +        // prepend namespace for relative names
    +        } elseif (null !== $this->namespace) {
    +            $name->prepend($this->namespace);
    +        }
    +
    +        return new PHPParser_Node_Name_FullyQualified($name->parts, $name->getAttributes());
    +    }
    +
    +    protected function addNamespacedName(PHPParser_Node $node) {
    +        if (null !== $this->namespace) {
    +            $node->namespacedName = clone $this->namespace;
    +            $node->namespacedName->append($node->name);
    +        } else {
    +            $node->namespacedName = new PHPParser_Node_Name($node->name, $node->getAttributes());
    +        }
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/NodeVisitorAbstract.php b/vendor/nikic/php-parser/lib/PHPParser/NodeVisitorAbstract.php
    new file mode 100755
    index 0000000..75ae698
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/NodeVisitorAbstract.php
    @@ -0,0 +1,12 @@
    +'",
    +        "T_IS_GREATER_OR_EQUAL",
    +        "T_SL",
    +        "T_SR",
    +        "'+'",
    +        "'-'",
    +        "'.'",
    +        "'*'",
    +        "'/'",
    +        "'%'",
    +        "'!'",
    +        "T_INSTANCEOF",
    +        "'~'",
    +        "T_INC",
    +        "T_DEC",
    +        "T_INT_CAST",
    +        "T_DOUBLE_CAST",
    +        "T_STRING_CAST",
    +        "T_ARRAY_CAST",
    +        "T_OBJECT_CAST",
    +        "T_BOOL_CAST",
    +        "T_UNSET_CAST",
    +        "'@'",
    +        "'['",
    +        "T_NEW",
    +        "T_CLONE",
    +        "T_EXIT",
    +        "T_IF",
    +        "T_ELSEIF",
    +        "T_ELSE",
    +        "T_ENDIF",
    +        "T_LNUMBER",
    +        "T_DNUMBER",
    +        "T_STRING",
    +        "T_STRING_VARNAME",
    +        "T_VARIABLE",
    +        "T_NUM_STRING",
    +        "T_INLINE_HTML",
    +        "T_ENCAPSED_AND_WHITESPACE",
    +        "T_CONSTANT_ENCAPSED_STRING",
    +        "T_ECHO",
    +        "T_DO",
    +        "T_WHILE",
    +        "T_ENDWHILE",
    +        "T_FOR",
    +        "T_ENDFOR",
    +        "T_FOREACH",
    +        "T_ENDFOREACH",
    +        "T_DECLARE",
    +        "T_ENDDECLARE",
    +        "T_AS",
    +        "T_SWITCH",
    +        "T_ENDSWITCH",
    +        "T_CASE",
    +        "T_DEFAULT",
    +        "T_BREAK",
    +        "T_CONTINUE",
    +        "T_GOTO",
    +        "T_FUNCTION",
    +        "T_CONST",
    +        "T_RETURN",
    +        "T_TRY",
    +        "T_CATCH",
    +        "T_FINALLY",
    +        "T_THROW",
    +        "T_USE",
    +        "T_INSTEADOF",
    +        "T_GLOBAL",
    +        "T_STATIC",
    +        "T_ABSTRACT",
    +        "T_FINAL",
    +        "T_PRIVATE",
    +        "T_PROTECTED",
    +        "T_PUBLIC",
    +        "T_VAR",
    +        "T_UNSET",
    +        "T_ISSET",
    +        "T_EMPTY",
    +        "T_HALT_COMPILER",
    +        "T_CLASS",
    +        "T_TRAIT",
    +        "T_INTERFACE",
    +        "T_EXTENDS",
    +        "T_IMPLEMENTS",
    +        "T_OBJECT_OPERATOR",
    +        "T_DOUBLE_ARROW",
    +        "T_LIST",
    +        "T_ARRAY",
    +        "T_CALLABLE",
    +        "T_CLASS_C",
    +        "T_TRAIT_C",
    +        "T_METHOD_C",
    +        "T_FUNC_C",
    +        "T_LINE",
    +        "T_FILE",
    +        "T_START_HEREDOC",
    +        "T_END_HEREDOC",
    +        "T_DOLLAR_OPEN_CURLY_BRACES",
    +        "T_CURLY_OPEN",
    +        "T_PAAMAYIM_NEKUDOTAYIM",
    +        "T_NAMESPACE",
    +        "T_NS_C",
    +        "T_DIR",
    +        "T_NS_SEPARATOR",
    +        "';'",
    +        "'{'",
    +        "'}'",
    +        "'('",
    +        "')'",
    +        "'$'",
    +        "'`'",
    +        "']'",
    +        "'\"'"
    +        , "???"
    +    );
    +
    +    /* @var array Map which translates lexer tokens to internal tokens */
    +    protected static $translate = array(
    +            0,  151,  151,  151,  151,  151,  151,  151,  151,  151,
    +          151,  151,  151,  151,  151,  151,  151,  151,  151,  151,
    +          151,  151,  151,  151,  151,  151,  151,  151,  151,  151,
    +          151,  151,  151,   48,  150,  151,  147,   47,   31,  151,
    +          145,  146,   45,   42,    7,   43,   44,   46,  151,  151,
    +          151,  151,  151,  151,  151,  151,  151,  151,   26,  142,
    +           36,   13,   38,   25,   60,  151,  151,  151,  151,  151,
    +          151,  151,  151,  151,  151,  151,  151,  151,  151,  151,
    +          151,  151,  151,  151,  151,  151,  151,  151,  151,  151,
    +          151,   61,  151,  149,   30,  151,  148,  151,  151,  151,
    +          151,  151,  151,  151,  151,  151,  151,  151,  151,  151,
    +          151,  151,  151,  151,  151,  151,  151,  151,  151,  151,
    +          151,  151,  151,  143,   29,  144,   50,  151,  151,  151,
    +          151,  151,  151,  151,  151,  151,  151,  151,  151,  151,
    +          151,  151,  151,  151,  151,  151,  151,  151,  151,  151,
    +          151,  151,  151,  151,  151,  151,  151,  151,  151,  151,
    +          151,  151,  151,  151,  151,  151,  151,  151,  151,  151,
    +          151,  151,  151,  151,  151,  151,  151,  151,  151,  151,
    +          151,  151,  151,  151,  151,  151,  151,  151,  151,  151,
    +          151,  151,  151,  151,  151,  151,  151,  151,  151,  151,
    +          151,  151,  151,  151,  151,  151,  151,  151,  151,  151,
    +          151,  151,  151,  151,  151,  151,  151,  151,  151,  151,
    +          151,  151,  151,  151,  151,  151,  151,  151,  151,  151,
    +          151,  151,  151,  151,  151,  151,  151,  151,  151,  151,
    +          151,  151,  151,  151,  151,  151,  151,  151,  151,  151,
    +          151,  151,  151,  151,  151,  151,    1,    2,    3,    4,
    +            5,    6,    8,    9,   10,   11,   12,   14,   15,   16,
    +           17,   18,   19,   20,   21,   22,   23,   24,   27,   28,
    +           32,   33,   34,   35,   37,   39,   40,   41,   49,   51,
    +           52,   53,   54,   55,   56,   57,   58,   59,   62,   63,
    +           64,   65,   66,   67,   68,   69,   70,   71,   72,   73,
    +           74,   75,  151,  151,   76,   77,   78,   79,   80,   81,
    +           82,   83,   84,   85,   86,   87,   88,   89,   90,   91,
    +           92,   93,   94,   95,   96,   97,   98,   99,  100,  101,
    +          102,  103,  104,  105,  106,  107,  108,  109,  110,  111,
    +          112,  113,  114,  115,  116,  117,  118,  119,  120,  121,
    +          122,  123,  124,  125,  126,  127,  128,  129,  130,  131,
    +          132,  151,  151,  151,  151,  151,  151,  133,  134,  135,
    +          136,  137,  138,  139,  140,  141
    +    );
    +
    +    protected static $yyaction = array(
    +           59,   60,  325,   61,   62,-32766,-32766,-32766,  324,   63,
    +           64,-32767,-32767,-32767,-32767,   98,   99,  100,  101,  102,
    +           57,  917,-32766,  298,-32766,-32766,   41,  106,  107,  108,
    +          109,  110,  111,  112,  113,  114,  115,  116,  267,  346,
    +           65,   66,  927,  249,  929,  928,   67,  535,   68,  220,
    +          221,   69,   70,   71,   72,   73,   74,   75,   76,   31,
    +          232,   77,  318,  326,  730,  732,  462,  836,  837,  362,
    +          348,  895,  238,  578,  280,  363,   46,   27,  327,  859,
    +          364,  246,  365,  454,  366,   39,  223,  328,-32766,-32766,
    +        -32766,   36,   37,  367,  333,  360,   38,  368,  329,  423,
    +           78,  848,  122,  278,  279,-32766,  286,-32766,   35,  369,
    +          370,  371,  372,  373,  389,  343,  861,  330,  560,  602,
    +          374,  375,  376,  377,  848,  842,  843,  844,  845,  839,
    +          840,  239,   82,   83,   84, -350,  389,  846,  841,  330,
    +          584,  504,  126,   47,  227,  259,  244,  802,  248,   40,
    +          351,   85,   86,   87,   88,   89,   90,   91,   92,   93,
    +           94,   95,   96,   97,   98,   99,  100,  101,  102,  103,
    +          104,  105,  788,  233,  576,-32766,-32766,-32766,  701,  702,
    +          703,  700,  699,  698,  630,    0,-32766,-32766,-32766,  655,
    +          656,  216,-32766,  215,-32766,-32766,-32766,-32766,-32766,-32767,
    +        -32767,-32767,-32767,-32766,  788,  322,  329,  319,  899,  544,
    +         -117,  257,  128,  277,-32766,-32766,-32766,  369,  370,  889,
    +          693,  261,  895,  225,  226,-32766,  540,  602,  374,  375,
    +          675,  535,  344,-32766,  535,-32766,  895,  376,-32766,-32766,
    +        -32766,  575,-32766,   53,-32766,  322,-32766,  658,  263,-32766,
    +          187,  257,  600,-32766,-32766,-32766,  788,-32766,-32766,-32766,
    +          693,   34,-32766,  535,  350,-32766,  388,-32766,  860,  812,
    +        -32766,-32766,-32766,-32766,-32766,  222,-32766,   54,-32766,   56,
    +          127,-32766,  100,  101,  102,-32766,-32766,-32766,  788,   22,
    +        -32766,-32766,  601,  268,-32766,  924,  259,-32766,  388,  666,
    +          631,  389,-32766,-32766,  330,-32766,  322,  224,  334,-32766,
    +          259,  917,  257,  503,  861,  535,  103,  104,  105,-32766,
    +          233,  693,-32766,-32766,-32766,  118,-32766,  494,-32766,  340,
    +        -32766,  506,  902,-32766,-32766,-32766,  126,-32766,-32766,-32766,
    +          345,-32766,-32766,-32766,  213,  123,-32766,  535,  130,-32766,
    +          388,-32766,  452,  599,-32766,-32766,-32766,-32766,-32766,  119,
    +        -32766,  120,-32766,  788,  233,-32766,  189, -113,  190,-32766,
    +        -32766,-32766,  194,  217,-32766,-32766,  195,  125,-32766,-32766,
    +        -32766,-32766,  388,  188,  685,  858,-32766,-32766,  117,-32766,
    +          329,  319,  353,   28,  509,  788,  597,  277,  357,  468,
    +          680,  369,  370,  516,-32766,-32766,-32766,  131,  287,   49,
    +          540,  602,  374,  375,  477,  478,-32766,  520,-32766,-32766,
    +          528,-32766,  535,-32766,-32766,-32766,-32766,  655,  656,-32766,
    +        -32766,-32766,  263,-32766,  519,-32766,  507,-32766,  542,  129,
    +        -32766,  679,  525,  588,-32766,-32766,-32766,  526,-32766,-32766,
    +        -32766,  690,  530,-32766,  535,  306,-32766,  388,-32766,  541,
    +          511,-32766,-32766,-32766,-32766,-32766,  224,-32766,   50,-32766,
    +           58,  482,-32766,   55,  805,   51,-32766,-32766,-32766,  788,
    +           52,-32766,-32766,  416,  232,-32766,  502,  687,-32766,  388,
    +          445,  491,  229,-32766,-32766,  551,-32766,  922,  549,  415,
    +        -32766,  339,  341,  535,  536,  399,  535,  400,  402,  414,
    +        -32766, -158,  401,-32766,-32766,-32766,  493,-32766,  479,-32766,
    +          475,-32766, -161,  604,-32766,-32766,-32766,  265,-32766,-32766,
    +        -32766,  788,-32766,-32766,-32766,  266,  917,-32766,  535,  256,
    +        -32766,  388,-32766,  342,  212,-32766,-32766,-32766,-32766,-32766,
    +          338,-32766,  471,-32766,  457,  473,-32766,  359,  603,  258,
    +        -32766,-32766,-32766,  788,  255,-32766,-32766,  577,  260,-32766,
    +          376,  579,-32766,  388,  847,  247,    0,-32766,-32766, -350,
    +        -32766,  657,    0,  337,-32766,    0,    0, -351,  245,    0,
    +          535,  121,  193,   42,-32766, -282,  791,-32766,-32766,-32766,
    +            0,-32766,    0,-32766,    0,-32766,    0,    0,-32766,  570,
    +        -32766, -290,-32766,-32766,-32766,  788,-32766,-32766,-32766, -291,
    +          499,-32766,  535,  300,-32766,  388,-32766,  288,  251,-32766,
    +        -32766,-32766,-32766,-32766,  242,-32766,  407,-32766,  684,  340,
    +        -32766,  686,  614,  616,-32766,-32766,-32766,  618,  563,-32766,
    +        -32766,  625,  624,-32766,  633,  580,-32766,  388,  565,  587,
    +          574,  572,-32766,  513,-32766,  512,   45,   44,-32766,  569,
    +          571,  573,  586,  545,  535,  683,  676,  234,-32766,  510,
    +          515,-32766,-32766,-32766,  517,-32766,  522,-32766,   81,-32766,
    +          124,  523,-32766,-32766,-32766,  524,-32766,-32766,-32766,  527,
    +        -32766,-32766,-32766,  505,  529,-32766,  535,  890,-32766,  388,
    +        -32766,  900,  668,-32766,-32766,-32766,-32766,-32766,  827,-32766,
    +          892,-32766,  880,  894,-32766,  191,  192,  896,-32766,-32766,
    +        -32766,  923,  356,-32766,-32766,  623,  926,-32766,  622,  925,
    +        -32766,  388,   32,   33,  185,  568,-32766,  321,-32766,  317,
    +           43,  262,  836,  837,  237,-32766,-32766,  236,   48,-32766,
    +          838,  535,  235,   30,  219,-32766,  218,  214,-32766,-32766,
    +        -32766,  186,-32766,   80,-32766,   79,-32766,-32766,-32766,-32766,
    +          768,  829,  767,-32766,-32766,-32766,  446, -114,-32766,-32766,
    +          854,  659,-32766,  795,  792,-32766,  388,  498,  472,  437,
    +          358,  354,  307,-32766,  289,   25,   24,   23,  442, -113,
    +          842,  843,  844,  845,  839,  840,  309,  786,    0,  480,
    +          874,  855,  846,  841,  329,  319,  921,  826,-32766,  329,
    +        -32766,  277,-32766,-32766,  891,  369,  370,-32766,-32766,-32766,
    +          369,  370,  875,  879,  540,  602,  374,  375,  893,  560,
    +          602,  374,  375,  329,-32766,  811,-32766,-32766,-32766,-32766,
    +        -32766,  799,  797,  798,  369,  370,  263,  329,  796,    0,
    +            0,  329,  543,  560,  602,  374,  375,  598,  369,  370,
    +            0,    0,  369,  370,  329,    0,    0,  560,  602,  374,
    +          375,  560,  602,  374,  375,  369,  370,    0,    0,    0,
    +          329,  691,    0,    0,  560,  602,  374,  375,    0,    0,
    +            0,  369,  370,  329,    0,  790,    0,  329,  501,  591,
    +          560,  602,  374,  375,  369,  370,    0,    0,  369,  370,
    +            0,  329,  593,  560,  602,  374,  375,  560,  602,  374,
    +          375,    0,  369,  370,  492,    0,    0,    0,  514,    0,
    +          486,  560,  602,  374,  375,  329,    0,    0,    0,  329,
    +            0,  561,    0,    0,    0,  789,  369,  370,    0,    0,
    +          369,  370,-32766,-32766,-32766,  560,  602,  374,  375,  560,
    +          602,  374,  375,    0,  329,    0,    0,    0,    0,-32766,
    +            0,-32766,-32766,-32766,-32766,  369,  370,    0,    0,    0,
    +            0,    0,    0,    0,  560,  602,  374,  375
    +    );
    +
    +    protected static $yycheck = array(
    +            2,    3,    4,    5,    6,    8,    9,   10,    7,   11,
    +           12,   36,   37,   38,   39,   40,   41,   42,   43,   44,
    +           61,   76,   25,   73,   27,   28,   13,   14,   15,   16,
    +           17,   18,   19,   20,   21,   22,   23,   24,   61,    7,
    +           42,   43,   71,   76,   73,   74,   48,   71,   50,   51,
    +           52,   53,   54,   55,   56,   57,   58,   59,   60,   61,
    +           62,   63,   64,   65,   51,   52,   76,   69,   70,   71,
    +           71,   73,    7,   75,    7,   77,   78,   79,   80,  134,
    +           82,  122,   84,   81,   86,  135,  136,   89,    8,    9,
    +           10,   93,   94,   95,   96,    7,   98,   99,   96,  122,
    +          102,  134,  143,  105,  106,   25,    7,   27,    7,  107,
    +          108,  113,  114,  115,  138,   26,  117,  141,  116,  117,
    +          118,  119,  124,  125,  134,  127,  128,  129,  130,  131,
    +          132,  133,    8,    9,   10,  122,  138,  139,  140,  141,
    +          142,  143,  143,  145,   31,  147,  148,  146,  150,   25,
    +            7,   27,   28,   29,   30,   31,   32,   33,   34,   35,
    +           36,   37,   38,   39,   40,   41,   42,   43,   44,   45,
    +           46,   47,   12,   49,  142,    8,    9,   10,  106,  107,
    +          108,  109,  110,  111,   26,    0,    8,    9,   10,  125,
    +          126,   31,   25,    7,   27,   28,   29,   30,   31,   32,
    +           33,   34,   35,   25,   12,   97,   96,   97,   71,  142,
    +          146,  103,   61,  103,    8,    9,   10,  107,  108,   73,
    +          112,    7,   73,   31,    7,   65,  116,  117,  118,  119,
    +          142,   71,  143,    8,   71,   75,   73,  124,   78,   79,
    +           80,  142,   82,   61,   84,   97,   86,  146,  138,   89,
    +            7,  103,  144,   93,   94,   95,   12,   65,   98,   99,
    +          112,    7,  102,   71,   71,  105,  106,   75,   71,  106,
    +           78,   79,   80,  113,   82,   31,   84,   61,   86,   61,
    +          143,   89,   42,   43,   44,   93,   94,   95,   12,  146,
    +           98,   99,  144,  147,  102,  144,  147,  105,  106,   73,
    +          142,  138,  142,  143,  141,  113,   97,   31,  145,   65,
    +          147,   76,  103,   71,  117,   71,   45,   46,   47,   75,
    +           49,  112,   78,   79,   80,  143,   82,   71,   84,  141,
    +           86,  143,  146,   89,  142,  143,  143,   93,   94,   95,
    +            7,   65,   98,   99,  123,    7,  102,   71,  143,  105,
    +          106,   75,  147,  144,   78,   79,   80,  113,   82,  143,
    +           84,  143,   86,   12,   49,   89,   13,  146,   13,   93,
    +           94,   95,   13,  147,   98,   99,   13,   26,  102,    8,
    +            9,  105,  106,   13,  142,  150,  142,  143,   13,  113,
    +           96,   97,   66,   67,   26,   12,   31,  103,   66,   67,
    +          144,  107,  108,   26,    8,    9,   10,   91,   92,   61,
    +          116,  117,  118,  119,  100,  101,   65,   26,  142,  143,
    +           26,   25,   71,   27,   28,   29,   75,  125,  126,   78,
    +           79,   80,  138,   82,   26,   84,   26,   86,  144,   26,
    +           89,  142,  143,   26,   93,   94,   95,   26,   65,   98,
    +           99,  142,  143,  102,   71,   72,  105,  106,   75,  142,
    +          143,   78,   79,   80,  113,   82,   31,   84,   61,   86,
    +           61,   68,   89,   61,   73,   61,   93,   94,   95,   12,
    +           61,   98,   99,   88,   62,  102,   71,   71,  105,  106,
    +           88,   71,   88,  142,  143,   71,  113,   71,   71,   71,
    +           65,   71,   71,   71,   71,   71,   71,   71,   71,   71,
    +           75,   88,   73,   78,   79,   80,   73,   82,   73,   84,
    +           73,   86,   73,  117,   89,  142,  143,   76,   93,   94,
    +           95,   12,   65,   98,   99,   76,   76,  102,   71,  121,
    +          105,  106,   75,   80,   88,   78,   79,   80,  113,   82,
    +           96,   84,   90,   86,   90,  103,   89,   96,  117,  104,
    +           93,   94,   95,   12,  120,   98,   99,  142,  120,  102,
    +          124,  142,  105,  106,  134,  122,   -1,  142,  143,  122,
    +          113,  146,   -1,  141,   65,   -1,   -1,  122,  122,   -1,
    +           71,  123,  123,  123,   75,  137,  146,   78,   79,   80,
    +           -1,   82,   -1,   84,   -1,   86,   -1,   -1,   89,  142,
    +          143,  137,   93,   94,   95,   12,   65,   98,   99,  137,
    +          137,  102,   71,  137,  105,  106,   75,  137,  137,   78,
    +           79,   80,  113,   82,  137,   84,  141,   86,  142,  141,
    +           89,  142,  142,  142,   93,   94,   95,  142,  142,   98,
    +           99,  142,  142,  102,  142,  142,  105,  106,  142,  142,
    +          142,  142,  143,  142,  113,  142,  142,  142,   65,  142,
    +          142,  142,  142,  142,   71,  142,  142,  145,   75,  143,
    +          143,   78,   79,   80,  143,   82,  143,   84,  143,   86,
    +          143,  143,   89,  142,  143,  143,   93,   94,   95,  143,
    +           65,   98,   99,  143,  143,  102,   71,  144,  105,  106,
    +           75,  144,  144,   78,   79,   80,  113,   82,  144,   84,
    +          144,   86,  144,  144,   89,   42,   43,  144,   93,   94,
    +           95,  144,  144,   98,   99,  144,  144,  102,  144,  144,
    +          105,  106,  145,  145,   61,  142,  143,  145,  113,  145,
    +          145,  145,   69,   70,  145,   65,   73,  145,  145,  145,
    +           77,   71,  145,  145,  145,   75,  145,  145,   78,   79,
    +           80,  145,   82,  145,   84,  145,   86,  142,  143,   89,
    +          146,  146,  146,   93,   94,   95,  146,  146,   98,   99,
    +          146,  146,  102,  146,  146,  105,  106,  146,  146,  146,
    +          146,  146,  146,  113,  146,  146,  146,  146,  125,  146,
    +          127,  128,  129,  130,  131,  132,  133,  148,   -1,  149,
    +          149,  149,  139,  140,   96,   97,  149,  149,  145,   96,
    +          147,  103,  142,  143,  149,  107,  108,    8,    9,   10,
    +          107,  108,  149,  149,  116,  117,  118,  119,  149,  116,
    +          117,  118,  119,   96,   25,  149,   27,   28,   29,   30,
    +           31,  149,  149,  149,  107,  108,  138,   96,  149,   -1,
    +           -1,   96,  144,  116,  117,  118,  119,  144,  107,  108,
    +           -1,   -1,  107,  108,   96,   -1,   -1,  116,  117,  118,
    +          119,  116,  117,  118,  119,  107,  108,   -1,   -1,   -1,
    +           96,  144,   -1,   -1,  116,  117,  118,  119,   -1,   -1,
    +           -1,  107,  108,   96,   -1,  144,   -1,   96,   83,  144,
    +          116,  117,  118,  119,  107,  108,   -1,   -1,  107,  108,
    +           -1,   96,  144,  116,  117,  118,  119,  116,  117,  118,
    +          119,   -1,  107,  108,   85,   -1,   -1,   -1,  144,   -1,
    +           87,  116,  117,  118,  119,   96,   -1,   -1,   -1,   96,
    +           -1,  144,   -1,   -1,   -1,  144,  107,  108,   -1,   -1,
    +          107,  108,    8,    9,   10,  116,  117,  118,  119,  116,
    +          117,  118,  119,   -1,   96,   -1,   -1,   -1,   -1,   25,
    +           -1,   27,   28,   29,   30,  107,  108,   -1,   -1,   -1,
    +           -1,   -1,   -1,   -1,  116,  117,  118,  119
    +    );
    +
    +    protected static $yybase = array(
    +            0,  728,  294,  110,  817,  804,    2,  863,  859,  733,
    +          821,  788,  771,  835,  775,  757,  888,  888,  888,  888,
    +          888,  368,  377,  391,  394,  391,  410,   -2,   -2,   -2,
    +          435,  244,  244,  635,  244,  276,  603,  467,  519,  383,
    +          351,  160,  192,  551,  551,  551,  551,  690,  690,  551,
    +          551,  551,  551,  551,  551,  551,  551,  551,  551,  551,
    +          551,  551,  551,  551,  551,  551,  551,  551,  551,  551,
    +          551,  551,  551,  551,  551,  551,  551,  551,  551,  551,
    +          551,  551,  551,  551,  551,  551,  551,  551,  551,  551,
    +          551,  551,  551,  551,  551,  551,  551,  551,  551,  551,
    +          551,  551,  551,  551,  551,  551,  551,  551,  551,  551,
    +          551,  551,  551,  551,  551,  551,  551,  551,  551,  551,
    +          551,  551,  551,  551,  551,  551,  551,  551,  551,  551,
    +          551,  551,  158,  429,  468,  470,  527,  528,  529,  530,
    +          450,  456,  634,  587,  583,  413,  579,  578,  576,  574,
    +          568,  588,  567,  670,  563,  124,  124,  124,  124,  124,
    +          124,  124,  124,  124,  124,  225,  371,  206,  206,  206,
    +          206,  206,  206,  206,  206,  206,  206,  206,  206,  206,
    +          206,  206,  178,  178,   80,  683,  683,  683,  683,  683,
    +          683,  683,  683,  683,  683,  683,   -3,  396,  964,  829,
    +          167,  167,  167,  167,   13,  -25,  -25,  -25,  -25,  148,
    +          108,  209,  113,  113,  446,  446,  422,  547,  163,  163,
    +          163,  163,  163,  163,  163,  163,  163,  163,  449,  415,
    +          240,  240,  614,  614,   64,   64,   64,   64,  302,  -33,
    +          -55,  235,   -1,  256,  451,  137,  137,  137,  459,  440,
    +          460,  193,  271,  271,  271,  -24,  -24,  -24,  -24,  545,
    +          -24,  -24,  -24,  188,  216,  -50,  -50,  -29,  205,  464,
    +          594,  462,  591,  299,  482,  -41,  317,  442,  226,  454,
    +          442,  326,  332,  314,  458,   89,  226,  158,  197,  309,
    +          218,  425,  428,  531,  395,   67,   99,   32,  -23,  182,
    +          146,  143,  402,  640,  636,  186,  151,  465,  101,  -10,
    +          182,  221,  534,   88,    1,  533,  242,  365,  598,  436,
    +          618,  438,  436,  445,  365,  613,  613,  613,  613,  365,
    +          432,  618,  618,  365,  422,  618,  254,  432,  365,  444,
    +          432,  448,  613,  523,  521,  436,  439,  418,  618,  618,
    +          618,  438,  365,  613,  452,  243,  618,  613,  452,  365,
    +          445,  185,  417,  348,  605,  630,  602,  434,  560,  441,
    +          406,  621,  619,  628,  437,  430,  622,  597,  495,  518,
    +          431,  375,  407,  414,  419,  497,  412,  466,  454,  498,
    +          315,  457,  491,  457,  719,  486,  474,  453,  463,  517,
    +          370,  353,  536,  495,  648,  656,  669,  433,  532,  653,
    +          457,  714,  525,  338,  355,  617,  427,  457,  612,  457,
    +          537,  457,  647,  426,  592,  495,  315,  315,  315,  645,
    +          713,  712,  706,  699,  694,  693,  685,  409,  678,  516,
    +          655,   65,  626,  458,  490,  424,  513,  214,  677,  457,
    +          457,  541,  545,  457,  512,  524,  661,  510,  652,  447,
    +          469,  672,  440,  654,  457,  461,  671,  214,  408,  403,
    +          641,  509,  543,  604,  548,  359,  644,  606,  552,  363,
    +          595,  421,  506,  660,  659,  663,  505,  556,  420,  401,
    +          443,  609,  501,  651,  423,  483,  455,  404,  561,  416,
    +          658,  500,  499,  496,    0,    0,    0,    0,    0,    0,
    +            0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    +            0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    +            0,    0,   -2,   -2,   -2,   -2,   -2,   -2,   -2,   -2,
    +           -2,   -2,   -2,   -2,   -2,   -2,   -2,   -2,   -2,   -2,
    +           -2,   -2,   -2,   -2,   -2,   -2,   -2,   -2,    0,    0,
    +            0,   -2,   -2,   -2,   -2,   -2,   -2,   -2,   -2,   -2,
    +           -2,   -2,   -2,   -2,   -2,   -2,   -2,   -2,   -2,   -2,
    +           -2,   -2,   -2,   -2,   -2,   -2,   -2,   -2,   -2,   -2,
    +           -2,   -2,   -2,   -2,   -2,   -2,   -2,   -2,   -2,   -2,
    +           -2,   -2,   -2,   -2,   -2,   -2,   -2,   -2,   -2,   -2,
    +           -2,   -2,   -2,   -2,   -2,   -2,   -2,   -2,   -2,   -2,
    +           -2,   -2,   -2,   -2,   -2,   -2,   -2,   -2,   -2,   -2,
    +           -2,   -2,   -2,   -2,   -2,   -2,   -2,   -2,   -2,   -2,
    +           -2,   -2,   -2,   -2,   -2,   -2,   -2,   -2,   -2,   -2,
    +           -2,   -2,   -2,   -2,   -2,   -2,   -2,   -2,   -2,   -2,
    +           -2,   -2,   -2,  124,  124,  124,  124,  124,  124,  124,
    +          124,  124,  124,  124,  124,  124,  124,  124,  124,  124,
    +          124,  124,  124,  124,  124,  124,    0,    0,    0,    0,
    +            0,    0,    0,    0,    0,    0,  124,  124,  124,  124,
    +          124,  124,  124,  124,  124,  124,  124,  124,  124,  124,
    +          124,  124,  124,  124,  124,  124,  163,  163,  163,  163,
    +          163,  163,  163,  163,  163,  163,  163,  124,  124,  124,
    +          124,  124,  124,  124,  124,    0,  271,  271,  271,  271,
    +           72,   72,   72,  163,  163,  163,  163,  163,  163,    0,
    +            0,    0,    0,    0,    0,    0,    0,    0,    0,   72,
    +           72,  271,  271,  163,  163,  -24,  -24,  -24,  -24,  -24,
    +          -50,  -50,  -50,  146,  -24,  -50,  149,  149,  149,  -50,
    +          -50,  -50,  146,    0,    0,    0,    0,    0,    0,    0,
    +          149,    0,    0,    0,  432,  618,    0,    0,    0,  149,
    +          316,  316,  316,  316,  214,  182,    0,  495,  432,    0,
    +          439,  432,    0,    0,    0,  618,    0,    0,    0,    0,
    +            0,    0,  338,  532,  333,  495,    0,    0,    0,    0,
    +            0,    0,    0,  495,  217,  217,    0,    0,  409,    0,
    +            0,    0,    0,  333,    0,    0,  214
    +    );
    +
    +    protected static $yydefault = array(
    +            3,32767,32767,    1,32767,32767,32767,32767,32767,32767,
    +        32767,32767,32767,32767,32767,32767,  106,   98,  112,   97,
    +          108,32767,32767,32767,32767,32767,32767,32767,32767,32767,
    +        32767,  377,  377,32767,  334,32767,32767,32767,32767,32767,
    +        32767,32767,32767,  179,  179,  179,32767,32767,32767,  366,
    +          366,  366,  366,  366,  366,  366,  366,  366,  366,32767,
    +        32767,32767,32767,32767,  257,32767,32767,32767,32767,32767,
    +        32767,32767,32767,32767,32767,32767,32767,32767,32767,32767,
    +        32767,32767,32767,32767,32767,32767,32767,32767,32767,32767,
    +        32767,32767,32767,32767,32767,32767,32767,32767,32767,32767,
    +        32767,32767,32767,32767,32767,32767,32767,32767,32767,32767,
    +        32767,32767,32767,32767,32767,32767,32767,32767,32767,32767,
    +        32767,32767,32767,32767,32767,32767,32767,32767,32767,32767,
    +        32767,32767,32767,32767,  262,  382,32767,32767,32767,32767,
    +        32767,32767,32767,32767,32767,32767,32767,32767,32767,32767,
    +        32767,32767,32767,32767,32767,  238,  239,  241,  242,  178,
    +          367,  131,  263,  381,  177,  205,  207,  256,  206,  183,
    +          188,  189,  190,  191,  192,  193,  194,  195,  196,  197,
    +          198,  182,  235,  234,  203,  331,  331,  334,32767,32767,
    +        32767,32767,32767,32767,32767,32767,  204,  208,  210,  209,
    +          225,  226,  223,  224,  181,  227,  228,  229,  230,  163,
    +          163,  163,32767,32767,  376,  376,32767,32767,32767,32767,
    +        32767,32767,32767,32767,32767,32767,32767,32767,  164,32767,
    +          217,  218,  292,  292,  122,  122,  122,  122,  122,32767,
    +        32767,32767,32767,32767,  300,32767,32767,32767,32767,32767,
    +          302,32767,  212,  213,  211,32767,32767,32767,32767,32767,
    +        32767,32767,32767,32767,  339,  301,32767,32767,32767,32767,
    +        32767,32767,32767,32767,  352,  288,32767,32767,32767,  281,
    +        32767,  109,  111,   61,  318,32767,32767,32767,32767,32767,
    +          357,32767,32767,32767,   17,32767,32767,32767,  389,  352,
    +        32767,32767,   19,32767,32767,32767,32767,  233,32767,32767,
    +          356,  350,32767,32767,32767,32767,32767,   65,  297,32767,
    +          303,32767,32767,32767,   65,32767,32767,32767,32767,   65,
    +        32767,  355,  354,   65,32767,  282,  333,32767,   65,   76,
    +        32767,   74,32767,   95,   95,32767,32767,   78,  329,  345,
    +        32767,32767,   65,32767,  270,  333,32767,32767,  270,   65,
    +        32767,32767,    4,  307,32767,32767,32767,32767,32767,32767,
    +        32767,32767,32767,32767,32767,32767,32767,32767,  283,32767,
    +        32767,32767,  253,  254,  341,32767,  342,32767,  281,32767,
    +          221,  200,32767,  202,32767,32767,  286,  289,32767,32767,
    +        32767,  140,32767,  284,32767,  186,32767,32767,32767,32767,
    +          384,32767,32767,  180,32767,32767,32767,  136,32767,   63,
    +        32767,  374,32767,32767,  350,  285,  214,  215,  216,32767,
    +        32767,32767,32767,32767,32767,32767,32767,  351,32767,32767,
    +        32767,  116,32767,  318,32767,32767,32767,   77,32767,  184,
    +          132,32767,32767,  383,32767,32767,32767,32767,32767,32767,
    +          338,32767,32767,32767,   64,32767,32767,   79,32767,32767,
    +          350,32767,32767,32767,32767,  120,32767,32767,32767,  175,
    +        32767,32767,32767,32767,32767,  350,32767,32767,32767,32767,
    +        32767,32767,32767,32767,    4,32767,  157,32767,32767,32767,
    +        32767,32767,32767,32767,   25,   25,    3,   25,  103,   25,
    +          143,    3,   95,   95,   58,  143,   25,  143,   25,   25,
    +           25,   25,   25,   25,   25,  150,   25,   25,   25,   25,
    +           25
    +    );
    +
    +    protected static $yygoto = array(
    +          161,  135,  135,  140,  135,  161,  136,  137,  138,  143,
    +          145,  169,  163,  159,  159,  159,  159,  140,  140,  160,
    +          160,  160,  160,  160,  160,  160,  160,  160,  160,  155,
    +          156,  157,  158,  167,  134,  750,  751,  390,  753,  774,
    +          775,  776,  777,  778,  779,  780,  782,  718,  139,  141,
    +          142,  144,  165,  166,  168,  184,  196,  197,  198,  199,
    +          200,  201,  202,  203,  205,  206,  207,  208,  230,  231,
    +          252,  253,  254,  426,  427,  428,  170,  171,  172,  173,
    +          174,  175,  176,  177,  178,  179,  180,  181,  146,  147,
    +          148,  162,  149,  164,  150,  182,  151,  152,  153,  183,
    +          154,  132,  443,  443,  443,  443,  443,  443,  443,  443,
    +          443,  443,  443,  311,  485,  421,  421,  449,  417,  419,
    +          419,  391,  393,  410,  424,  450,  453,  464,  470,  335,
    +          335,  335,  335,  335,  335,  335,  335,  335,  335,  335,
    +          335,  335,  335,  335,  335,  646,  646,  906,  906,  813,
    +          813,  654,  654,  654,  654,  654,  405,  538,  538,  538,
    +          495,  444,  444,  444,  444,  444,  444,  444,  444,  444,
    +          444,  444,  611,  611,  611,  611,  270,  606,  612,  490,
    +          392,  392,  392,  392,  392,  392,  392,  392,  392,  392,
    +          392,  392,  392,  392,  392,  392,  539,  539,  539,  582,
    +          395,  395,    5,  878,   16,  210,    6,  211,  396,  396,
    +          537,  537,  537,    7,  422,   17,   18,    8,   19,    9,
    +           10,   11,  910,   20,   12,   13,   14,   15,  455,  483,
    +          632,  617,  615,  613,  615,  508,  398,  641,  636,  850,
    +          850,  850,  850,  850,  850,  850,  850,  850,  850,  850,
    +          430,  431,  432,  433,  434,  435,  436,  438,  466,  835,
    +          458,  463,  500,  467,  273,  315,  830,    1,  697,  316,
    +          809,  810,    2,  771,   26,   21,  285,  554,  672,  621,
    +          852,  853,  868,  652,  707,  276,  661,  807,  877,  807,
    +          439,  291,  250,  885,  885,  808,  241,  886,  886,  294,
    +          476,   29,  294,  916,  916,  481,  901,  901,  901,  866,
    +          292,  484,  919,  916,  408,  903,  299,  299,  299,  418,
    +          884,  304,  397,  397,  429,  716,  762,  404,  919,  919,
    +          299,  825,  824,  459,  650,  546,  664,  851,  518,  310,
    +          488,  404,  404,  312,  271,  272,  552,  804,  669,  620,
    +          863,  487,  403,    0,  705,    0,    0,    0,    0,  302,
    +            0,    0,  425,    0,    0,    0,    0,    0,    0,    0,
    +            0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    +            0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    +            0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    +            0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    +            0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    +            0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    +            0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
    +            0,    0,    0,  409
    +    );
    +
    +    protected static $yygcheck = array(
    +           24,   24,   24,   24,   24,   24,   24,   24,   24,   24,
    +           24,   24,   24,   24,   24,   24,   24,   24,   24,   24,
    +           24,   24,   24,   24,   24,   24,   24,   24,   24,   24,
    +           24,   24,   24,   24,   24,   24,   24,   24,   24,   24,
    +           24,   24,   24,   24,   24,   24,   24,   24,   24,   24,
    +           24,   24,   24,   24,   24,   24,   24,   24,   24,   24,
    +           24,   24,   24,   24,   24,   24,   24,   24,   24,   24,
    +           24,   24,   24,   24,   24,   24,   24,   24,   24,   24,
    +           24,   24,   24,   24,   24,   24,   24,   24,   24,   24,
    +           24,   24,   24,   24,   24,   24,   24,   24,   24,   24,
    +           24,   24,   38,   38,   38,   38,   38,   38,   38,   38,
    +           38,   38,   38,   32,   32,   32,   32,   32,   32,   32,
    +           32,   32,   32,   32,   32,   32,   32,   32,   32,   38,
    +           38,   38,   38,   38,   38,   38,   38,   38,   38,   38,
    +           38,   38,   38,   38,   38,   53,   53,   53,   53,   38,
    +           38,   38,   38,   38,   38,   38,   75,    6,    6,    6,
    +           38,   92,   92,   92,   92,   92,   92,   92,   92,   92,
    +           92,   92,   38,   38,   38,   38,   48,   38,   38,   38,
    +           89,   89,   89,   89,   89,   89,   89,   89,   89,   89,
    +           89,   89,   89,   89,   89,   89,    7,    7,    7,   31,
    +           89,   89,   13,   57,   13,   44,   13,   44,   92,   92,
    +            5,    5,    5,   13,   83,   13,   13,   13,   13,   13,
    +           13,   13,  112,   13,   13,   13,   13,   13,   21,   21,
    +            5,    5,    5,    5,    5,    5,    5,    5,    5,   99,
    +           99,   99,   99,   99,   99,   99,   99,   99,   99,   99,
    +           84,   84,   84,   84,   84,   84,   84,   84,   84,   57,
    +           40,   40,   40,   46,   46,   46,   15,    2,   72,   72,
    +           57,   57,    2,   15,   15,   15,   15,   12,   12,   12,
    +           12,   12,   12,   12,   12,    4,   59,   57,   57,   57,
    +           15,   28,   98,   91,   91,   57,   98,   90,   90,    4,
    +          101,   15,    4,  113,  113,   15,   91,   91,   91,  104,
    +           39,   30,  113,  113,   39,  110,   96,   96,   96,   39,
    +           91,   29,   95,   95,   25,   75,   76,   25,  113,  113,
    +           96,   97,   97,   39,   55,   10,   60,  100,   50,   96,
    +           39,   25,   25,    9,   48,   48,   11,   87,   61,   47,
    +          103,   82,    4,   -1,   74,   -1,   -1,   -1,   -1,    4,
    +           -1,   -1,    4,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
    +           -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
    +           -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
    +           -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
    +           -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
    +           -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
    +           -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
    +           -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
    +           -1,   -1,   -1,   75
    +    );
    +
    +    protected static $yygbase = array(
    +            0,    0, -239,    0,   22,  209,  156,  195,    0,   21,
    +           55,    1,   89, -303,    0,  -52,    0,    0,    0,    0,
    +            0,  184,    0,    0,  -30,  294,    0,    0,  245,  102,
    +           98,  174,  -99,    0,    0,    0,    0,    0,  -83,  -19,
    +           25,    0,    0,    0, -310,    0,    7,   -2, -168,    0,
    +           51,    0,    0,  -67,    0,   96,    0,  -61,    0,  251,
    +           50,    2,    0,    0,    0,    0,    0,    0,    0,    0,
    +            0,    0,   40,    0,   -6,  109,   93,    0,    0,    0,
    +            0,    0,   -7,  182,  200,    0,    0,   23,    0,  -32,
    +           65,   61,  -24,    0,    0,   90,   71,   85,   48,   54,
    +           49,  114,    0,   -5,  122,    0,    0,    0,    0,    0,
    +          100,    0,  188,   63,    0
    +    );
    +
    +    protected static $yygdefault = array(
    +        -32768,  361,    3,  533,  378,  557,  558,  559,  295,  293,
    +          547,  553,  460,    4,  555,  763,  281,  562,  282,  469,
    +          564,  412,  566,  567,  133,  379,  296,  297,  413,  303,
    +          456,  581,  204,  301,  583,  283,  585,  590,  284,  489,
    +          440,  380,  347,  451,  209,  420,  447,  619,  269,  627,
    +          521,  635,  638,  381,  441,  649,  352,  806,  308,  660,
    +          665,  670,  673,  323,  313,  465,  677,  678,  243,  682,
    +          496,  497,  696,  228,  704,  717,  320,  781,  783,  382,
    +          383,  406,  474,  394,  411,  800,  314,  803,  384,  385,
    +          331,  332,  821,  818,  275,  871,  274,  349,  240,  856,
    +          857,  461,  355,  909,  867,  264,  386,  387,  290,  305,
    +          904,  336,  911,  918,  448
    +    );
    +
    +    protected static $yylhs = array(
    +            0,    1,    2,    2,    4,    4,    3,    3,    3,    3,
    +            3,    3,    3,    3,    3,    8,    8,   10,   10,   10,
    +           10,    9,    9,   11,   13,   13,   14,   14,   14,   14,
    +            5,    5,    5,    5,    5,    5,    5,    5,    5,    5,
    +            5,    5,    5,    5,    5,    5,    5,    5,    5,    5,
    +            5,    5,    5,    5,    5,    5,    5,    5,   35,   35,
    +           37,   36,   36,   29,   29,   39,   39,    6,    7,    7,
    +            7,   41,   41,   41,   42,   42,   45,   45,   43,   43,
    +           46,   46,   22,   22,   31,   31,   34,   34,   33,   33,
    +           47,   23,   23,   23,   23,   48,   48,   49,   49,   50,
    +           50,   20,   20,   16,   16,   51,   18,   18,   52,   17,
    +           17,   19,   19,   30,   30,   30,   40,   40,   54,   54,
    +           55,   55,   56,   56,   56,   56,   57,   57,   57,   58,
    +           58,   59,   59,   26,   26,   60,   60,   60,   27,   27,
    +           61,   61,   44,   44,   62,   62,   62,   62,   67,   67,
    +           68,   68,   69,   69,   69,   69,   70,   71,   71,   66,
    +           66,   63,   63,   65,   65,   73,   73,   72,   72,   72,
    +           72,   72,   72,   64,   64,   74,   74,   28,   28,   21,
    +           21,   24,   24,   24,   24,   24,   24,   24,   24,   24,
    +           24,   24,   24,   24,   24,   24,   24,   24,   24,   24,
    +           24,   24,   24,   24,   24,   24,   24,   24,   24,   24,
    +           24,   24,   24,   24,   24,   24,   24,   24,   24,   24,
    +           24,   24,   24,   24,   24,   24,   24,   24,   24,   24,
    +           24,   24,   24,   24,   24,   24,   24,   24,   24,   24,
    +           24,   24,   24,   24,   24,   24,   24,   24,   24,   24,
    +           24,   24,   24,   24,   24,   24,   24,   24,   24,   24,
    +           15,   15,   25,   25,   79,   79,   80,   80,   80,   75,
    +           82,   82,   86,   86,   87,   88,   88,   88,   88,   88,
    +           88,   92,   92,   38,   38,   38,   76,   76,   93,   93,
    +           89,   89,   94,   94,   94,   94,   94,   77,   77,   77,
    +           81,   81,   81,   85,   85,   99,   99,   99,   99,   99,
    +           99,   99,   99,   99,   99,   99,   99,   99,   99,   12,
    +           12,   12,   12,   12,   12,   78,   78,   78,   78,  100,
    +          100,  101,  101,  103,  103,  102,  102,  104,  104,   32,
    +           32,   32,   32,  106,  106,  105,  105,  105,  105,  105,
    +          107,  107,   91,   91,   95,   95,   90,   90,  108,  108,
    +          108,  108,   96,   96,   96,   96,   84,   84,   97,   97,
    +           97,   53,  109,  109,  110,  110,  110,   83,   83,  111,
    +          111,  112,  112,  112,  112,   98,   98,   98,   98,  113,
    +          113,  113,  113,  113,  113,  113,  114,  114,  114
    +    );
    +
    +    protected static $yylen = array(
    +            1,    1,    2,    0,    1,    3,    1,    1,    1,    1,
    +            3,    5,    4,    3,    3,    3,    1,    1,    3,    2,
    +            4,    3,    1,    3,    2,    0,    1,    1,    1,    1,
    +            3,    5,    8,    3,    5,    9,    3,    2,    3,    2,
    +            3,    2,    3,    2,    3,    3,    3,    1,    2,    5,
    +            7,    9,    5,    1,    6,    3,    3,    2,    0,    2,
    +            8,    0,    4,    1,    3,    0,    1,    9,    7,    6,
    +            5,    1,    2,    2,    0,    2,    0,    2,    0,    2,
    +            1,    3,    1,    4,    1,    4,    1,    4,    1,    3,
    +            3,    3,    4,    4,    5,    0,    2,    4,    3,    1,
    +            1,    1,    4,    0,    2,    3,    0,    2,    4,    0,
    +            2,    0,    3,    1,    2,    1,    1,    0,    1,    3,
    +            3,    5,    0,    1,    1,    1,    2,    3,    3,    1,
    +            3,    1,    2,    3,    1,    1,    2,    4,    3,    1,
    +            1,    3,    2,    0,    3,    3,    8,    3,    1,    3,
    +            0,    2,    4,    5,    4,    4,    3,    1,    1,    1,
    +            3,    1,    1,    0,    1,    1,    2,    1,    1,    1,
    +            1,    1,    1,    1,    3,    1,    3,    3,    1,    0,
    +            1,    1,    3,    3,    4,    4,    1,    2,    3,    3,
    +            3,    3,    3,    3,    3,    3,    3,    3,    3,    2,
    +            2,    2,    2,    3,    3,    3,    3,    3,    3,    3,
    +            3,    3,    3,    3,    3,    3,    3,    3,    3,    2,
    +            2,    2,    2,    3,    3,    3,    3,    3,    3,    3,
    +            3,    3,    1,    3,    5,    4,    4,    4,    2,    2,
    +            2,    2,    2,    2,    2,    2,    2,    2,    2,    2,
    +            2,    2,    1,    1,    1,    3,    2,    1,    9,   10,
    +            3,    3,    2,    4,    4,    3,    4,    4,    4,    3,
    +            0,    4,    1,    3,    2,    2,    4,    6,    2,    2,
    +            4,    1,    1,    1,    2,    3,    1,    1,    1,    1,
    +            1,    1,    0,    3,    3,    4,    4,    0,    2,    1,
    +            0,    1,    1,    0,    1,    1,    1,    1,    1,    1,
    +            1,    1,    1,    1,    1,    1,    3,    2,    1,    1,
    +            3,    2,    2,    4,    3,    1,    3,    3,    3,    1,
    +            1,    0,    2,    0,    1,    3,    1,    3,    1,    1,
    +            1,    1,    1,    6,    4,    3,    4,    2,    4,    4,
    +            1,    3,    1,    2,    1,    1,    4,    1,    3,    6,
    +            4,    4,    4,    4,    1,    4,    0,    1,    1,    3,
    +            1,    4,    3,    1,    1,    1,    0,    0,    2,    3,
    +            1,    3,    1,    4,    2,    2,    2,    1,    2,    1,
    +            4,    3,    3,    3,    6,    3,    1,    1,    1
    +    );
    +
    +    protected $yyval;
    +    protected $yyastk;
    +    protected $stackPos;
    +    protected $lexer;
    +
    +    /**
    +     * Creates a parser instance.
    +     *
    +     * @param PHPParser_Lexer $lexer A lexer
    +     */
    +    public function __construct(PHPParser_Lexer $lexer) {
    +        $this->lexer = $lexer;
    +    }
    +
    +    /**
    +     * Parses PHP code into a node tree.
    +     *
    +     * @param string $code The source code to parse
    +     *
    +     * @return PHPParser_Node[] Array of statements
    +     */
    +    public function parse($code) {
    +        $this->lexer->startLexing($code);
    +
    +        // We start off with no lookahead-token
    +        $tokenId = self::TOKEN_NONE;
    +
    +        // The attributes for a node are taken from the first and last token of the node.
    +        // From the first token only the startAttributes are taken and from the last only
    +        // the endAttributes. Both are merged using the array union operator (+).
    +        $startAttributes = array('startLine' => 1);
    +        $endAttributes   = array();
    +
    +        // In order to figure out the attributes for the starting token, we have to keep
    +        // them in a stack
    +        $attributeStack = array($startAttributes);
    +
    +        // Start off in the initial state and keep a stack of previous states
    +        $state = 0;
    +        $stateStack = array($state);
    +
    +        // AST stack (?)
    +        $this->yyastk = array();
    +
    +        // Current position in the stack(s)
    +        $this->stackPos = 0;
    +
    +        for (;;) {
    +            if (self::$yybase[$state] == 0) {
    +                $yyn = self::$yydefault[$state];
    +            } else {
    +                if ($tokenId === self::TOKEN_NONE) {
    +                    // Fetch the next token id from the lexer and fetch additional info by-ref.
    +                    // The end attributes are fetched into a temporary variable and only set once the token is really
    +                    // shifted (not during read). Otherwise you would sometimes get off-by-one errors, when a rule is
    +                    // reduced after a token was read but not yet shifted.
    +                    $origTokenId = $this->lexer->getNextToken($tokenValue, $startAttributes, $nextEndAttributes);
    +
    +                    // map the lexer token id to the internally used token id's
    +                    $tokenId = $origTokenId >= 0 && $origTokenId < self::TOKEN_MAP_SIZE
    +                        ? self::$translate[$origTokenId]
    +                        : self::TOKEN_INVALID;
    +
    +                    if ($tokenId === self::TOKEN_INVALID) {
    +                        throw new RangeException(sprintf(
    +                            'The lexer returned an invalid token (id=%d, value=%s)',
    +                            $origTokenId, $tokenValue
    +                        ));
    +                    }
    +
    +                    $attributeStack[$this->stackPos] = $startAttributes;
    +                }
    +
    +                if ((($yyn = self::$yybase[$state] + $tokenId) >= 0
    +                     && $yyn < self::YYLAST && self::$yycheck[$yyn] == $tokenId
    +                     || ($state < self::YY2TBLSTATE
    +                        && ($yyn = self::$yybase[$state + self::YYNLSTATES] + $tokenId) >= 0
    +                        && $yyn < self::YYLAST
    +                        && self::$yycheck[$yyn] == $tokenId))
    +                    && ($yyn = self::$yyaction[$yyn]) != self::YYDEFAULT) {
    +                    /*
    +                     * >= YYNLSTATE: shift and reduce
    +                     * > 0: shift
    +                     * = 0: accept
    +                     * < 0: reduce
    +                     * = -YYUNEXPECTED: error
    +                     */
    +                    if ($yyn > 0) {
    +                        /* shift */
    +                        ++$this->stackPos;
    +
    +                        $stateStack[$this->stackPos]     = $state = $yyn;
    +                        $this->yyastk[$this->stackPos]   = $tokenValue;
    +                        $attributeStack[$this->stackPos] = $startAttributes;
    +                        $endAttributes = $nextEndAttributes;
    +                        $tokenId = self::TOKEN_NONE;
    +
    +                        if ($yyn < self::YYNLSTATES)
    +                            continue;
    +
    +                        /* $yyn >= YYNLSTATES means shift-and-reduce */
    +                        $yyn -= self::YYNLSTATES;
    +                    } else {
    +                        $yyn = -$yyn;
    +                    }
    +                } else {
    +                    $yyn = self::$yydefault[$state];
    +                }
    +            }
    +
    +            for (;;) {
    +                /* reduce/error */
    +                if ($yyn == 0) {
    +                    /* accept */
    +                    return $this->yyval;
    +                } elseif ($yyn != self::YYUNEXPECTED) {
    +                    /* reduce */
    +                    try {
    +                        $this->{'yyn' . $yyn}(
    +                            $attributeStack[$this->stackPos - self::$yylen[$yyn]]
    +                            + $endAttributes
    +                        );
    +                    } catch (PHPParser_Error $e) {
    +                        if (-1 === $e->getRawLine()) {
    +                            $e->setRawLine($startAttributes['startLine']);
    +                        }
    +
    +                        throw $e;
    +                    }
    +
    +                    /* Goto - shift nonterminal */
    +                    $this->stackPos -= self::$yylen[$yyn];
    +                    $yyn = self::$yylhs[$yyn];
    +                    if (($yyp = self::$yygbase[$yyn] + $stateStack[$this->stackPos]) >= 0
    +                         && $yyp < self::YYGLAST
    +                         && self::$yygcheck[$yyp] == $yyn) {
    +                        $state = self::$yygoto[$yyp];
    +                    } else {
    +                        $state = self::$yygdefault[$yyn];
    +                    }
    +
    +                    ++$this->stackPos;
    +
    +                    $stateStack[$this->stackPos]     = $state;
    +                    $this->yyastk[$this->stackPos]   = $this->yyval;
    +                    $attributeStack[$this->stackPos] = $startAttributes;
    +                } else {
    +                    /* error */
    +                    $expected = array();
    +
    +                    $base = self::$yybase[$state];
    +                    for ($i = 0; $i < self::TOKEN_MAP_SIZE; ++$i) {
    +                        $n = $base + $i;
    +                        if ($n >= 0 && $n < self::YYLAST && self::$yycheck[$n] == $i
    +                         || $state < self::YY2TBLSTATE
    +                            && ($n = self::$yybase[$state + self::YYNLSTATES] + $i) >= 0
    +                            && $n < self::YYLAST && self::$yycheck[$n] == $i
    +                        ) {
    +                            if (self::$yyaction[$n] != self::YYUNEXPECTED) {
    +                                if (count($expected) == 4) {
    +                                    /* Too many expected tokens */
    +                                    $expected = array();
    +                                    break;
    +                                }
    +
    +                                $expected[] = self::$terminals[$i];
    +                            }
    +                        }
    +                    }
    +
    +                    $expectedString = '';
    +                    if ($expected) {
    +                        $expectedString = ', expecting ' . implode(' or ', $expected);
    +                    }
    +
    +                    throw new PHPParser_Error(
    +                        'Syntax error, unexpected ' . self::$terminals[$tokenId] . $expectedString,
    +                        $startAttributes['startLine']
    +                    );
    +                }
    +
    +                if ($state < self::YYNLSTATES)
    +                    break;
    +                /* >= YYNLSTATES means shift-and-reduce */
    +                $yyn = $state - self::YYNLSTATES;
    +            }
    +        }
    +    }
    +
    +    protected function yyn0() {
    +        $this->yyval = $this->yyastk[$this->stackPos];
    +    }
    +
    +    protected function yyn1($attributes) {
    +         $this->yyval = PHPParser_Node_Stmt_Namespace::postprocess($this->yyastk[$this->stackPos-(1-1)]); 
    +    }
    +
    +    protected function yyn2($attributes) {
    +         if (is_array($this->yyastk[$this->stackPos-(2-2)])) { $this->yyval = array_merge($this->yyastk[$this->stackPos-(2-1)], $this->yyastk[$this->stackPos-(2-2)]); } else { $this->yyastk[$this->stackPos-(2-1)][] = $this->yyastk[$this->stackPos-(2-2)]; $this->yyval = $this->yyastk[$this->stackPos-(2-1)]; }; 
    +    }
    +
    +    protected function yyn3($attributes) {
    +         $this->yyval = array(); 
    +    }
    +
    +    protected function yyn4($attributes) {
    +         $this->yyval = array($this->yyastk[$this->stackPos-(1-1)]); 
    +    }
    +
    +    protected function yyn5($attributes) {
    +         $this->yyastk[$this->stackPos-(3-1)][] = $this->yyastk[$this->stackPos-(3-3)]; $this->yyval = $this->yyastk[$this->stackPos-(3-1)]; 
    +    }
    +
    +    protected function yyn6($attributes) {
    +         $this->yyval = $this->yyastk[$this->stackPos-(1-1)]; 
    +    }
    +
    +    protected function yyn7($attributes) {
    +         $this->yyval = $this->yyastk[$this->stackPos-(1-1)]; 
    +    }
    +
    +    protected function yyn8($attributes) {
    +         $this->yyval = $this->yyastk[$this->stackPos-(1-1)]; 
    +    }
    +
    +    protected function yyn9($attributes) {
    +         $this->yyval = new PHPParser_Node_Stmt_HaltCompiler($this->lexer->handleHaltCompiler(), $attributes); 
    +    }
    +
    +    protected function yyn10($attributes) {
    +         $this->yyval = new PHPParser_Node_Stmt_Namespace(new PHPParser_Node_Name($this->yyastk[$this->stackPos-(3-2)], $attributes), null, $attributes); 
    +    }
    +
    +    protected function yyn11($attributes) {
    +         $this->yyval = new PHPParser_Node_Stmt_Namespace(new PHPParser_Node_Name($this->yyastk[$this->stackPos-(5-2)], $attributes), $this->yyastk[$this->stackPos-(5-4)], $attributes); 
    +    }
    +
    +    protected function yyn12($attributes) {
    +         $this->yyval = new PHPParser_Node_Stmt_Namespace(null, $this->yyastk[$this->stackPos-(4-3)], $attributes); 
    +    }
    +
    +    protected function yyn13($attributes) {
    +         $this->yyval = new PHPParser_Node_Stmt_Use($this->yyastk[$this->stackPos-(3-2)], $attributes); 
    +    }
    +
    +    protected function yyn14($attributes) {
    +         $this->yyval = new PHPParser_Node_Stmt_Const($this->yyastk[$this->stackPos-(3-2)], $attributes); 
    +    }
    +
    +    protected function yyn15($attributes) {
    +         $this->yyastk[$this->stackPos-(3-1)][] = $this->yyastk[$this->stackPos-(3-3)]; $this->yyval = $this->yyastk[$this->stackPos-(3-1)]; 
    +    }
    +
    +    protected function yyn16($attributes) {
    +         $this->yyval = array($this->yyastk[$this->stackPos-(1-1)]); 
    +    }
    +
    +    protected function yyn17($attributes) {
    +         $this->yyval = new PHPParser_Node_Stmt_UseUse(new PHPParser_Node_Name($this->yyastk[$this->stackPos-(1-1)], $attributes), null, $attributes); 
    +    }
    +
    +    protected function yyn18($attributes) {
    +         $this->yyval = new PHPParser_Node_Stmt_UseUse(new PHPParser_Node_Name($this->yyastk[$this->stackPos-(3-1)], $attributes), $this->yyastk[$this->stackPos-(3-3)], $attributes); 
    +    }
    +
    +    protected function yyn19($attributes) {
    +         $this->yyval = new PHPParser_Node_Stmt_UseUse(new PHPParser_Node_Name($this->yyastk[$this->stackPos-(2-2)], $attributes), null, $attributes); 
    +    }
    +
    +    protected function yyn20($attributes) {
    +         $this->yyval = new PHPParser_Node_Stmt_UseUse(new PHPParser_Node_Name($this->yyastk[$this->stackPos-(4-2)], $attributes), $this->yyastk[$this->stackPos-(4-4)], $attributes); 
    +    }
    +
    +    protected function yyn21($attributes) {
    +         $this->yyastk[$this->stackPos-(3-1)][] = $this->yyastk[$this->stackPos-(3-3)]; $this->yyval = $this->yyastk[$this->stackPos-(3-1)]; 
    +    }
    +
    +    protected function yyn22($attributes) {
    +         $this->yyval = array($this->yyastk[$this->stackPos-(1-1)]); 
    +    }
    +
    +    protected function yyn23($attributes) {
    +         $this->yyval = new PHPParser_Node_Const($this->yyastk[$this->stackPos-(3-1)], $this->yyastk[$this->stackPos-(3-3)], $attributes); 
    +    }
    +
    +    protected function yyn24($attributes) {
    +         if (is_array($this->yyastk[$this->stackPos-(2-2)])) { $this->yyval = array_merge($this->yyastk[$this->stackPos-(2-1)], $this->yyastk[$this->stackPos-(2-2)]); } else { $this->yyastk[$this->stackPos-(2-1)][] = $this->yyastk[$this->stackPos-(2-2)]; $this->yyval = $this->yyastk[$this->stackPos-(2-1)]; }; 
    +    }
    +
    +    protected function yyn25($attributes) {
    +         $this->yyval = array(); 
    +    }
    +
    +    protected function yyn26($attributes) {
    +         $this->yyval = $this->yyastk[$this->stackPos-(1-1)]; 
    +    }
    +
    +    protected function yyn27($attributes) {
    +         $this->yyval = $this->yyastk[$this->stackPos-(1-1)]; 
    +    }
    +
    +    protected function yyn28($attributes) {
    +         $this->yyval = $this->yyastk[$this->stackPos-(1-1)]; 
    +    }
    +
    +    protected function yyn29($attributes) {
    +         throw new PHPParser_Error('__halt_compiler() can only be used from the outermost scope'); 
    +    }
    +
    +    protected function yyn30($attributes) {
    +         $this->yyval = $this->yyastk[$this->stackPos-(3-2)]; 
    +    }
    +
    +    protected function yyn31($attributes) {
    +         $this->yyval = new PHPParser_Node_Stmt_If($this->yyastk[$this->stackPos-(5-2)], array('stmts' => is_array($this->yyastk[$this->stackPos-(5-3)]) ? $this->yyastk[$this->stackPos-(5-3)] : array($this->yyastk[$this->stackPos-(5-3)]), 'elseifs' => $this->yyastk[$this->stackPos-(5-4)], 'else' => $this->yyastk[$this->stackPos-(5-5)]), $attributes); 
    +    }
    +
    +    protected function yyn32($attributes) {
    +         $this->yyval = new PHPParser_Node_Stmt_If($this->yyastk[$this->stackPos-(8-2)], array('stmts' => $this->yyastk[$this->stackPos-(8-4)], 'elseifs' => $this->yyastk[$this->stackPos-(8-5)], 'else' => $this->yyastk[$this->stackPos-(8-6)]), $attributes); 
    +    }
    +
    +    protected function yyn33($attributes) {
    +         $this->yyval = new PHPParser_Node_Stmt_While($this->yyastk[$this->stackPos-(3-2)], $this->yyastk[$this->stackPos-(3-3)], $attributes); 
    +    }
    +
    +    protected function yyn34($attributes) {
    +         $this->yyval = new PHPParser_Node_Stmt_Do($this->yyastk[$this->stackPos-(5-4)], is_array($this->yyastk[$this->stackPos-(5-2)]) ? $this->yyastk[$this->stackPos-(5-2)] : array($this->yyastk[$this->stackPos-(5-2)]), $attributes); 
    +    }
    +
    +    protected function yyn35($attributes) {
    +         $this->yyval = new PHPParser_Node_Stmt_For(array('init' => $this->yyastk[$this->stackPos-(9-3)], 'cond' => $this->yyastk[$this->stackPos-(9-5)], 'loop' => $this->yyastk[$this->stackPos-(9-7)], 'stmts' => $this->yyastk[$this->stackPos-(9-9)]), $attributes); 
    +    }
    +
    +    protected function yyn36($attributes) {
    +         $this->yyval = new PHPParser_Node_Stmt_Switch($this->yyastk[$this->stackPos-(3-2)], $this->yyastk[$this->stackPos-(3-3)], $attributes); 
    +    }
    +
    +    protected function yyn37($attributes) {
    +         $this->yyval = new PHPParser_Node_Stmt_Break(null, $attributes); 
    +    }
    +
    +    protected function yyn38($attributes) {
    +         $this->yyval = new PHPParser_Node_Stmt_Break($this->yyastk[$this->stackPos-(3-2)], $attributes); 
    +    }
    +
    +    protected function yyn39($attributes) {
    +         $this->yyval = new PHPParser_Node_Stmt_Continue(null, $attributes); 
    +    }
    +
    +    protected function yyn40($attributes) {
    +         $this->yyval = new PHPParser_Node_Stmt_Continue($this->yyastk[$this->stackPos-(3-2)], $attributes); 
    +    }
    +
    +    protected function yyn41($attributes) {
    +         $this->yyval = new PHPParser_Node_Stmt_Return(null, $attributes); 
    +    }
    +
    +    protected function yyn42($attributes) {
    +         $this->yyval = new PHPParser_Node_Stmt_Return($this->yyastk[$this->stackPos-(3-2)], $attributes); 
    +    }
    +
    +    protected function yyn43($attributes) {
    +         $this->yyval = $this->yyastk[$this->stackPos-(2-1)]; 
    +    }
    +
    +    protected function yyn44($attributes) {
    +         $this->yyval = new PHPParser_Node_Stmt_Global($this->yyastk[$this->stackPos-(3-2)], $attributes); 
    +    }
    +
    +    protected function yyn45($attributes) {
    +         $this->yyval = new PHPParser_Node_Stmt_Static($this->yyastk[$this->stackPos-(3-2)], $attributes); 
    +    }
    +
    +    protected function yyn46($attributes) {
    +         $this->yyval = new PHPParser_Node_Stmt_Echo($this->yyastk[$this->stackPos-(3-2)], $attributes); 
    +    }
    +
    +    protected function yyn47($attributes) {
    +         $this->yyval = new PHPParser_Node_Stmt_InlineHTML($this->yyastk[$this->stackPos-(1-1)], $attributes); 
    +    }
    +
    +    protected function yyn48($attributes) {
    +         $this->yyval = $this->yyastk[$this->stackPos-(2-1)]; 
    +    }
    +
    +    protected function yyn49($attributes) {
    +         $this->yyval = new PHPParser_Node_Stmt_Unset($this->yyastk[$this->stackPos-(5-3)], $attributes); 
    +    }
    +
    +    protected function yyn50($attributes) {
    +         $this->yyval = new PHPParser_Node_Stmt_Foreach($this->yyastk[$this->stackPos-(7-3)], $this->yyastk[$this->stackPos-(7-5)][0], array('keyVar' => null, 'byRef' => $this->yyastk[$this->stackPos-(7-5)][1], 'stmts' => $this->yyastk[$this->stackPos-(7-7)]), $attributes); 
    +    }
    +
    +    protected function yyn51($attributes) {
    +         $this->yyval = new PHPParser_Node_Stmt_Foreach($this->yyastk[$this->stackPos-(9-3)], $this->yyastk[$this->stackPos-(9-7)][0], array('keyVar' => $this->yyastk[$this->stackPos-(9-5)], 'byRef' => $this->yyastk[$this->stackPos-(9-7)][1], 'stmts' => $this->yyastk[$this->stackPos-(9-9)]), $attributes); 
    +    }
    +
    +    protected function yyn52($attributes) {
    +         $this->yyval = new PHPParser_Node_Stmt_Declare($this->yyastk[$this->stackPos-(5-3)], $this->yyastk[$this->stackPos-(5-5)], $attributes); 
    +    }
    +
    +    protected function yyn53($attributes) {
    +         $this->yyval = array(); /* means: no statement */ 
    +    }
    +
    +    protected function yyn54($attributes) {
    +         $this->yyval = new PHPParser_Node_Stmt_TryCatch($this->yyastk[$this->stackPos-(6-3)], $this->yyastk[$this->stackPos-(6-5)], $this->yyastk[$this->stackPos-(6-6)], $attributes); 
    +    }
    +
    +    protected function yyn55($attributes) {
    +         $this->yyval = new PHPParser_Node_Stmt_Throw($this->yyastk[$this->stackPos-(3-2)], $attributes); 
    +    }
    +
    +    protected function yyn56($attributes) {
    +         $this->yyval = new PHPParser_Node_Stmt_Goto($this->yyastk[$this->stackPos-(3-2)], $attributes); 
    +    }
    +
    +    protected function yyn57($attributes) {
    +         $this->yyval = new PHPParser_Node_Stmt_Label($this->yyastk[$this->stackPos-(2-1)], $attributes); 
    +    }
    +
    +    protected function yyn58($attributes) {
    +         $this->yyval = array(); 
    +    }
    +
    +    protected function yyn59($attributes) {
    +         $this->yyastk[$this->stackPos-(2-1)][] = $this->yyastk[$this->stackPos-(2-2)]; $this->yyval = $this->yyastk[$this->stackPos-(2-1)]; 
    +    }
    +
    +    protected function yyn60($attributes) {
    +         $this->yyval = new PHPParser_Node_Stmt_Catch($this->yyastk[$this->stackPos-(8-3)], substr($this->yyastk[$this->stackPos-(8-4)], 1), $this->yyastk[$this->stackPos-(8-7)], $attributes); 
    +    }
    +
    +    protected function yyn61($attributes) {
    +         $this->yyval = null; 
    +    }
    +
    +    protected function yyn62($attributes) {
    +         $this->yyval = $this->yyastk[$this->stackPos-(4-3)]; 
    +    }
    +
    +    protected function yyn63($attributes) {
    +         $this->yyval = array($this->yyastk[$this->stackPos-(1-1)]); 
    +    }
    +
    +    protected function yyn64($attributes) {
    +         $this->yyastk[$this->stackPos-(3-1)][] = $this->yyastk[$this->stackPos-(3-3)]; $this->yyval = $this->yyastk[$this->stackPos-(3-1)]; 
    +    }
    +
    +    protected function yyn65($attributes) {
    +         $this->yyval = false; 
    +    }
    +
    +    protected function yyn66($attributes) {
    +         $this->yyval = true; 
    +    }
    +
    +    protected function yyn67($attributes) {
    +         $this->yyval = new PHPParser_Node_Stmt_Function($this->yyastk[$this->stackPos-(9-3)], array('byRef' => $this->yyastk[$this->stackPos-(9-2)], 'params' => $this->yyastk[$this->stackPos-(9-5)], 'stmts' => $this->yyastk[$this->stackPos-(9-8)]), $attributes); 
    +    }
    +
    +    protected function yyn68($attributes) {
    +         $this->yyval = new PHPParser_Node_Stmt_Class($this->yyastk[$this->stackPos-(7-2)], array('type' => $this->yyastk[$this->stackPos-(7-1)], 'extends' => $this->yyastk[$this->stackPos-(7-3)], 'implements' => $this->yyastk[$this->stackPos-(7-4)], 'stmts' => $this->yyastk[$this->stackPos-(7-6)]), $attributes); 
    +    }
    +
    +    protected function yyn69($attributes) {
    +         $this->yyval = new PHPParser_Node_Stmt_Interface($this->yyastk[$this->stackPos-(6-2)], array('extends' => $this->yyastk[$this->stackPos-(6-3)], 'stmts' => $this->yyastk[$this->stackPos-(6-5)]), $attributes); 
    +    }
    +
    +    protected function yyn70($attributes) {
    +         $this->yyval = new PHPParser_Node_Stmt_Trait($this->yyastk[$this->stackPos-(5-2)], $this->yyastk[$this->stackPos-(5-4)], $attributes); 
    +    }
    +
    +    protected function yyn71($attributes) {
    +         $this->yyval = 0; 
    +    }
    +
    +    protected function yyn72($attributes) {
    +         $this->yyval = PHPParser_Node_Stmt_Class::MODIFIER_ABSTRACT; 
    +    }
    +
    +    protected function yyn73($attributes) {
    +         $this->yyval = PHPParser_Node_Stmt_Class::MODIFIER_FINAL; 
    +    }
    +
    +    protected function yyn74($attributes) {
    +         $this->yyval = null; 
    +    }
    +
    +    protected function yyn75($attributes) {
    +         $this->yyval = $this->yyastk[$this->stackPos-(2-2)]; 
    +    }
    +
    +    protected function yyn76($attributes) {
    +         $this->yyval = array(); 
    +    }
    +
    +    protected function yyn77($attributes) {
    +         $this->yyval = $this->yyastk[$this->stackPos-(2-2)]; 
    +    }
    +
    +    protected function yyn78($attributes) {
    +         $this->yyval = array(); 
    +    }
    +
    +    protected function yyn79($attributes) {
    +         $this->yyval = $this->yyastk[$this->stackPos-(2-2)]; 
    +    }
    +
    +    protected function yyn80($attributes) {
    +         $this->yyval = array($this->yyastk[$this->stackPos-(1-1)]); 
    +    }
    +
    +    protected function yyn81($attributes) {
    +         $this->yyastk[$this->stackPos-(3-1)][] = $this->yyastk[$this->stackPos-(3-3)]; $this->yyval = $this->yyastk[$this->stackPos-(3-1)]; 
    +    }
    +
    +    protected function yyn82($attributes) {
    +         $this->yyval = is_array($this->yyastk[$this->stackPos-(1-1)]) ? $this->yyastk[$this->stackPos-(1-1)] : array($this->yyastk[$this->stackPos-(1-1)]); 
    +    }
    +
    +    protected function yyn83($attributes) {
    +         $this->yyval = $this->yyastk[$this->stackPos-(4-2)]; 
    +    }
    +
    +    protected function yyn84($attributes) {
    +         $this->yyval = is_array($this->yyastk[$this->stackPos-(1-1)]) ? $this->yyastk[$this->stackPos-(1-1)] : array($this->yyastk[$this->stackPos-(1-1)]); 
    +    }
    +
    +    protected function yyn85($attributes) {
    +         $this->yyval = $this->yyastk[$this->stackPos-(4-2)]; 
    +    }
    +
    +    protected function yyn86($attributes) {
    +         $this->yyval = is_array($this->yyastk[$this->stackPos-(1-1)]) ? $this->yyastk[$this->stackPos-(1-1)] : array($this->yyastk[$this->stackPos-(1-1)]); 
    +    }
    +
    +    protected function yyn87($attributes) {
    +         $this->yyval = $this->yyastk[$this->stackPos-(4-2)]; 
    +    }
    +
    +    protected function yyn88($attributes) {
    +         $this->yyval = array($this->yyastk[$this->stackPos-(1-1)]); 
    +    }
    +
    +    protected function yyn89($attributes) {
    +         $this->yyastk[$this->stackPos-(3-1)][] = $this->yyastk[$this->stackPos-(3-3)]; $this->yyval = $this->yyastk[$this->stackPos-(3-1)]; 
    +    }
    +
    +    protected function yyn90($attributes) {
    +         $this->yyval = new PHPParser_Node_Stmt_DeclareDeclare($this->yyastk[$this->stackPos-(3-1)], $this->yyastk[$this->stackPos-(3-3)], $attributes); 
    +    }
    +
    +    protected function yyn91($attributes) {
    +         $this->yyval = $this->yyastk[$this->stackPos-(3-2)]; 
    +    }
    +
    +    protected function yyn92($attributes) {
    +         $this->yyval = $this->yyastk[$this->stackPos-(4-3)]; 
    +    }
    +
    +    protected function yyn93($attributes) {
    +         $this->yyval = $this->yyastk[$this->stackPos-(4-2)]; 
    +    }
    +
    +    protected function yyn94($attributes) {
    +         $this->yyval = $this->yyastk[$this->stackPos-(5-3)]; 
    +    }
    +
    +    protected function yyn95($attributes) {
    +         $this->yyval = array(); 
    +    }
    +
    +    protected function yyn96($attributes) {
    +         $this->yyastk[$this->stackPos-(2-1)][] = $this->yyastk[$this->stackPos-(2-2)]; $this->yyval = $this->yyastk[$this->stackPos-(2-1)]; 
    +    }
    +
    +    protected function yyn97($attributes) {
    +         $this->yyval = new PHPParser_Node_Stmt_Case($this->yyastk[$this->stackPos-(4-2)], $this->yyastk[$this->stackPos-(4-4)], $attributes); 
    +    }
    +
    +    protected function yyn98($attributes) {
    +         $this->yyval = new PHPParser_Node_Stmt_Case(null, $this->yyastk[$this->stackPos-(3-3)], $attributes); 
    +    }
    +
    +    protected function yyn99() {
    +        $this->yyval = $this->yyastk[$this->stackPos];
    +    }
    +
    +    protected function yyn100() {
    +        $this->yyval = $this->yyastk[$this->stackPos];
    +    }
    +
    +    protected function yyn101($attributes) {
    +         $this->yyval = is_array($this->yyastk[$this->stackPos-(1-1)]) ? $this->yyastk[$this->stackPos-(1-1)] : array($this->yyastk[$this->stackPos-(1-1)]); 
    +    }
    +
    +    protected function yyn102($attributes) {
    +         $this->yyval = $this->yyastk[$this->stackPos-(4-2)]; 
    +    }
    +
    +    protected function yyn103($attributes) {
    +         $this->yyval = array(); 
    +    }
    +
    +    protected function yyn104($attributes) {
    +         $this->yyastk[$this->stackPos-(2-1)][] = $this->yyastk[$this->stackPos-(2-2)]; $this->yyval = $this->yyastk[$this->stackPos-(2-1)]; 
    +    }
    +
    +    protected function yyn105($attributes) {
    +         $this->yyval = new PHPParser_Node_Stmt_ElseIf($this->yyastk[$this->stackPos-(3-2)], is_array($this->yyastk[$this->stackPos-(3-3)]) ? $this->yyastk[$this->stackPos-(3-3)] : array($this->yyastk[$this->stackPos-(3-3)]), $attributes); 
    +    }
    +
    +    protected function yyn106($attributes) {
    +         $this->yyval = array(); 
    +    }
    +
    +    protected function yyn107($attributes) {
    +         $this->yyastk[$this->stackPos-(2-1)][] = $this->yyastk[$this->stackPos-(2-2)]; $this->yyval = $this->yyastk[$this->stackPos-(2-1)]; 
    +    }
    +
    +    protected function yyn108($attributes) {
    +         $this->yyval = new PHPParser_Node_Stmt_ElseIf($this->yyastk[$this->stackPos-(4-2)], $this->yyastk[$this->stackPos-(4-4)], $attributes); 
    +    }
    +
    +    protected function yyn109($attributes) {
    +         $this->yyval = null; 
    +    }
    +
    +    protected function yyn110($attributes) {
    +         $this->yyval = new PHPParser_Node_Stmt_Else(is_array($this->yyastk[$this->stackPos-(2-2)]) ? $this->yyastk[$this->stackPos-(2-2)] : array($this->yyastk[$this->stackPos-(2-2)]), $attributes); 
    +    }
    +
    +    protected function yyn111($attributes) {
    +         $this->yyval = null; 
    +    }
    +
    +    protected function yyn112($attributes) {
    +         $this->yyval = new PHPParser_Node_Stmt_Else($this->yyastk[$this->stackPos-(3-3)], $attributes); 
    +    }
    +
    +    protected function yyn113($attributes) {
    +         $this->yyval = array($this->yyastk[$this->stackPos-(1-1)], false); 
    +    }
    +
    +    protected function yyn114($attributes) {
    +         $this->yyval = array($this->yyastk[$this->stackPos-(2-2)], true); 
    +    }
    +
    +    protected function yyn115($attributes) {
    +         $this->yyval = array($this->yyastk[$this->stackPos-(1-1)], false); 
    +    }
    +
    +    protected function yyn116($attributes) {
    +         $this->yyval = $this->yyastk[$this->stackPos-(1-1)]; 
    +    }
    +
    +    protected function yyn117($attributes) {
    +         $this->yyval = array(); 
    +    }
    +
    +    protected function yyn118($attributes) {
    +         $this->yyval = array($this->yyastk[$this->stackPos-(1-1)]); 
    +    }
    +
    +    protected function yyn119($attributes) {
    +         $this->yyastk[$this->stackPos-(3-1)][] = $this->yyastk[$this->stackPos-(3-3)]; $this->yyval = $this->yyastk[$this->stackPos-(3-1)]; 
    +    }
    +
    +    protected function yyn120($attributes) {
    +         $this->yyval = new PHPParser_Node_Param(substr($this->yyastk[$this->stackPos-(3-3)], 1), null, $this->yyastk[$this->stackPos-(3-1)], $this->yyastk[$this->stackPos-(3-2)], $attributes); 
    +    }
    +
    +    protected function yyn121($attributes) {
    +         $this->yyval = new PHPParser_Node_Param(substr($this->yyastk[$this->stackPos-(5-3)], 1), $this->yyastk[$this->stackPos-(5-5)], $this->yyastk[$this->stackPos-(5-1)], $this->yyastk[$this->stackPos-(5-2)], $attributes); 
    +    }
    +
    +    protected function yyn122($attributes) {
    +         $this->yyval = null; 
    +    }
    +
    +    protected function yyn123($attributes) {
    +         $this->yyval = $this->yyastk[$this->stackPos-(1-1)]; 
    +    }
    +
    +    protected function yyn124($attributes) {
    +         $this->yyval = 'array'; 
    +    }
    +
    +    protected function yyn125($attributes) {
    +         $this->yyval = 'callable'; 
    +    }
    +
    +    protected function yyn126($attributes) {
    +         $this->yyval = array(); 
    +    }
    +
    +    protected function yyn127($attributes) {
    +         $this->yyval = $this->yyastk[$this->stackPos-(3-2)]; 
    +    }
    +
    +    protected function yyn128($attributes) {
    +         $this->yyval = array(new PHPParser_Node_Arg($this->yyastk[$this->stackPos-(3-2)], false, $attributes)); 
    +    }
    +
    +    protected function yyn129($attributes) {
    +         $this->yyval = array($this->yyastk[$this->stackPos-(1-1)]); 
    +    }
    +
    +    protected function yyn130($attributes) {
    +         $this->yyastk[$this->stackPos-(3-1)][] = $this->yyastk[$this->stackPos-(3-3)]; $this->yyval = $this->yyastk[$this->stackPos-(3-1)]; 
    +    }
    +
    +    protected function yyn131($attributes) {
    +         $this->yyval = new PHPParser_Node_Arg($this->yyastk[$this->stackPos-(1-1)], false, $attributes); 
    +    }
    +
    +    protected function yyn132($attributes) {
    +         $this->yyval = new PHPParser_Node_Arg($this->yyastk[$this->stackPos-(2-2)], true, $attributes); 
    +    }
    +
    +    protected function yyn133($attributes) {
    +         $this->yyastk[$this->stackPos-(3-1)][] = $this->yyastk[$this->stackPos-(3-3)]; $this->yyval = $this->yyastk[$this->stackPos-(3-1)]; 
    +    }
    +
    +    protected function yyn134($attributes) {
    +         $this->yyval = array($this->yyastk[$this->stackPos-(1-1)]); 
    +    }
    +
    +    protected function yyn135($attributes) {
    +         $this->yyval = new PHPParser_Node_Expr_Variable(substr($this->yyastk[$this->stackPos-(1-1)], 1), $attributes); 
    +    }
    +
    +    protected function yyn136($attributes) {
    +         $this->yyval = new PHPParser_Node_Expr_Variable($this->yyastk[$this->stackPos-(2-2)], $attributes); 
    +    }
    +
    +    protected function yyn137($attributes) {
    +         $this->yyval = new PHPParser_Node_Expr_Variable($this->yyastk[$this->stackPos-(4-3)], $attributes); 
    +    }
    +
    +    protected function yyn138($attributes) {
    +         $this->yyastk[$this->stackPos-(3-1)][] = $this->yyastk[$this->stackPos-(3-3)]; $this->yyval = $this->yyastk[$this->stackPos-(3-1)]; 
    +    }
    +
    +    protected function yyn139($attributes) {
    +         $this->yyval = array($this->yyastk[$this->stackPos-(1-1)]); 
    +    }
    +
    +    protected function yyn140($attributes) {
    +         $this->yyval = new PHPParser_Node_Stmt_StaticVar(substr($this->yyastk[$this->stackPos-(1-1)], 1), null, $attributes); 
    +    }
    +
    +    protected function yyn141($attributes) {
    +         $this->yyval = new PHPParser_Node_Stmt_StaticVar(substr($this->yyastk[$this->stackPos-(3-1)], 1), $this->yyastk[$this->stackPos-(3-3)], $attributes); 
    +    }
    +
    +    protected function yyn142($attributes) {
    +         $this->yyastk[$this->stackPos-(2-1)][] = $this->yyastk[$this->stackPos-(2-2)]; $this->yyval = $this->yyastk[$this->stackPos-(2-1)]; 
    +    }
    +
    +    protected function yyn143($attributes) {
    +         $this->yyval = array(); 
    +    }
    +
    +    protected function yyn144($attributes) {
    +         $this->yyval = new PHPParser_Node_Stmt_Property($this->yyastk[$this->stackPos-(3-1)], $this->yyastk[$this->stackPos-(3-2)], $attributes); 
    +    }
    +
    +    protected function yyn145($attributes) {
    +         $this->yyval = new PHPParser_Node_Stmt_ClassConst($this->yyastk[$this->stackPos-(3-2)], $attributes); 
    +    }
    +
    +    protected function yyn146($attributes) {
    +         $this->yyval = new PHPParser_Node_Stmt_ClassMethod($this->yyastk[$this->stackPos-(8-4)], array('type' => $this->yyastk[$this->stackPos-(8-1)], 'byRef' => $this->yyastk[$this->stackPos-(8-3)], 'params' => $this->yyastk[$this->stackPos-(8-6)], 'stmts' => $this->yyastk[$this->stackPos-(8-8)]), $attributes); 
    +    }
    +
    +    protected function yyn147($attributes) {
    +         $this->yyval = new PHPParser_Node_Stmt_TraitUse($this->yyastk[$this->stackPos-(3-2)], $this->yyastk[$this->stackPos-(3-3)], $attributes); 
    +    }
    +
    +    protected function yyn148($attributes) {
    +         $this->yyval = array(); 
    +    }
    +
    +    protected function yyn149($attributes) {
    +         $this->yyval = $this->yyastk[$this->stackPos-(3-2)]; 
    +    }
    +
    +    protected function yyn150($attributes) {
    +         $this->yyval = array(); 
    +    }
    +
    +    protected function yyn151($attributes) {
    +         $this->yyastk[$this->stackPos-(2-1)][] = $this->yyastk[$this->stackPos-(2-2)]; $this->yyval = $this->yyastk[$this->stackPos-(2-1)]; 
    +    }
    +
    +    protected function yyn152($attributes) {
    +         $this->yyval = new PHPParser_Node_Stmt_TraitUseAdaptation_Precedence($this->yyastk[$this->stackPos-(4-1)][0], $this->yyastk[$this->stackPos-(4-1)][1], $this->yyastk[$this->stackPos-(4-3)], $attributes); 
    +    }
    +
    +    protected function yyn153($attributes) {
    +         $this->yyval = new PHPParser_Node_Stmt_TraitUseAdaptation_Alias($this->yyastk[$this->stackPos-(5-1)][0], $this->yyastk[$this->stackPos-(5-1)][1], $this->yyastk[$this->stackPos-(5-3)], $this->yyastk[$this->stackPos-(5-4)], $attributes); 
    +    }
    +
    +    protected function yyn154($attributes) {
    +         $this->yyval = new PHPParser_Node_Stmt_TraitUseAdaptation_Alias($this->yyastk[$this->stackPos-(4-1)][0], $this->yyastk[$this->stackPos-(4-1)][1], $this->yyastk[$this->stackPos-(4-3)], null, $attributes); 
    +    }
    +
    +    protected function yyn155($attributes) {
    +         $this->yyval = new PHPParser_Node_Stmt_TraitUseAdaptation_Alias($this->yyastk[$this->stackPos-(4-1)][0], $this->yyastk[$this->stackPos-(4-1)][1], null, $this->yyastk[$this->stackPos-(4-3)], $attributes); 
    +    }
    +
    +    protected function yyn156($attributes) {
    +         $this->yyval = array($this->yyastk[$this->stackPos-(3-1)], $this->yyastk[$this->stackPos-(3-3)]); 
    +    }
    +
    +    protected function yyn157($attributes) {
    +         $this->yyval = $this->yyastk[$this->stackPos-(1-1)]; 
    +    }
    +
    +    protected function yyn158($attributes) {
    +         $this->yyval = array(null, $this->yyastk[$this->stackPos-(1-1)]); 
    +    }
    +
    +    protected function yyn159($attributes) {
    +         $this->yyval = null; 
    +    }
    +
    +    protected function yyn160($attributes) {
    +         $this->yyval = $this->yyastk[$this->stackPos-(3-2)]; 
    +    }
    +
    +    protected function yyn161($attributes) {
    +         $this->yyval = $this->yyastk[$this->stackPos-(1-1)]; 
    +    }
    +
    +    protected function yyn162($attributes) {
    +         $this->yyval = PHPParser_Node_Stmt_Class::MODIFIER_PUBLIC; 
    +    }
    +
    +    protected function yyn163($attributes) {
    +         $this->yyval = PHPParser_Node_Stmt_Class::MODIFIER_PUBLIC; 
    +    }
    +
    +    protected function yyn164($attributes) {
    +         $this->yyval = $this->yyastk[$this->stackPos-(1-1)]; 
    +    }
    +
    +    protected function yyn165($attributes) {
    +         $this->yyval = $this->yyastk[$this->stackPos-(1-1)]; 
    +    }
    +
    +    protected function yyn166($attributes) {
    +         PHPParser_Node_Stmt_Class::verifyModifier($this->yyastk[$this->stackPos-(2-1)], $this->yyastk[$this->stackPos-(2-2)]); $this->yyval = $this->yyastk[$this->stackPos-(2-1)] | $this->yyastk[$this->stackPos-(2-2)]; 
    +    }
    +
    +    protected function yyn167($attributes) {
    +         $this->yyval = PHPParser_Node_Stmt_Class::MODIFIER_PUBLIC; 
    +    }
    +
    +    protected function yyn168($attributes) {
    +         $this->yyval = PHPParser_Node_Stmt_Class::MODIFIER_PROTECTED; 
    +    }
    +
    +    protected function yyn169($attributes) {
    +         $this->yyval = PHPParser_Node_Stmt_Class::MODIFIER_PRIVATE; 
    +    }
    +
    +    protected function yyn170($attributes) {
    +         $this->yyval = PHPParser_Node_Stmt_Class::MODIFIER_STATIC; 
    +    }
    +
    +    protected function yyn171($attributes) {
    +         $this->yyval = PHPParser_Node_Stmt_Class::MODIFIER_ABSTRACT; 
    +    }
    +
    +    protected function yyn172($attributes) {
    +         $this->yyval = PHPParser_Node_Stmt_Class::MODIFIER_FINAL; 
    +    }
    +
    +    protected function yyn173($attributes) {
    +         $this->yyval = array($this->yyastk[$this->stackPos-(1-1)]); 
    +    }
    +
    +    protected function yyn174($attributes) {
    +         $this->yyastk[$this->stackPos-(3-1)][] = $this->yyastk[$this->stackPos-(3-3)]; $this->yyval = $this->yyastk[$this->stackPos-(3-1)]; 
    +    }
    +
    +    protected function yyn175($attributes) {
    +         $this->yyval = new PHPParser_Node_Stmt_PropertyProperty(substr($this->yyastk[$this->stackPos-(1-1)], 1), null, $attributes); 
    +    }
    +
    +    protected function yyn176($attributes) {
    +         $this->yyval = new PHPParser_Node_Stmt_PropertyProperty(substr($this->yyastk[$this->stackPos-(3-1)], 1), $this->yyastk[$this->stackPos-(3-3)], $attributes); 
    +    }
    +
    +    protected function yyn177($attributes) {
    +         $this->yyastk[$this->stackPos-(3-1)][] = $this->yyastk[$this->stackPos-(3-3)]; $this->yyval = $this->yyastk[$this->stackPos-(3-1)]; 
    +    }
    +
    +    protected function yyn178($attributes) {
    +         $this->yyval = array($this->yyastk[$this->stackPos-(1-1)]); 
    +    }
    +
    +    protected function yyn179($attributes) {
    +         $this->yyval = array(); 
    +    }
    +
    +    protected function yyn180($attributes) {
    +         $this->yyval = $this->yyastk[$this->stackPos-(1-1)]; 
    +    }
    +
    +    protected function yyn181($attributes) {
    +         $this->yyval = $this->yyastk[$this->stackPos-(1-1)]; 
    +    }
    +
    +    protected function yyn182($attributes) {
    +         $this->yyval = new PHPParser_Node_Expr_Assign($this->yyastk[$this->stackPos-(3-1)], $this->yyastk[$this->stackPos-(3-3)], $attributes); 
    +    }
    +
    +    protected function yyn183($attributes) {
    +         $this->yyval = new PHPParser_Node_Expr_Assign($this->yyastk[$this->stackPos-(3-1)], $this->yyastk[$this->stackPos-(3-3)], $attributes); 
    +    }
    +
    +    protected function yyn184($attributes) {
    +         $this->yyval = new PHPParser_Node_Expr_AssignRef($this->yyastk[$this->stackPos-(4-1)], $this->yyastk[$this->stackPos-(4-4)], $attributes); 
    +    }
    +
    +    protected function yyn185($attributes) {
    +         $this->yyval = new PHPParser_Node_Expr_AssignRef($this->yyastk[$this->stackPos-(4-1)], $this->yyastk[$this->stackPos-(4-4)], $attributes); 
    +    }
    +
    +    protected function yyn186($attributes) {
    +         $this->yyval = $this->yyastk[$this->stackPos-(1-1)]; 
    +    }
    +
    +    protected function yyn187($attributes) {
    +         $this->yyval = new PHPParser_Node_Expr_Clone($this->yyastk[$this->stackPos-(2-2)], $attributes); 
    +    }
    +
    +    protected function yyn188($attributes) {
    +         $this->yyval = new PHPParser_Node_Expr_AssignPlus($this->yyastk[$this->stackPos-(3-1)], $this->yyastk[$this->stackPos-(3-3)], $attributes); 
    +    }
    +
    +    protected function yyn189($attributes) {
    +         $this->yyval = new PHPParser_Node_Expr_AssignMinus($this->yyastk[$this->stackPos-(3-1)], $this->yyastk[$this->stackPos-(3-3)], $attributes); 
    +    }
    +
    +    protected function yyn190($attributes) {
    +         $this->yyval = new PHPParser_Node_Expr_AssignMul($this->yyastk[$this->stackPos-(3-1)], $this->yyastk[$this->stackPos-(3-3)], $attributes); 
    +    }
    +
    +    protected function yyn191($attributes) {
    +         $this->yyval = new PHPParser_Node_Expr_AssignDiv($this->yyastk[$this->stackPos-(3-1)], $this->yyastk[$this->stackPos-(3-3)], $attributes); 
    +    }
    +
    +    protected function yyn192($attributes) {
    +         $this->yyval = new PHPParser_Node_Expr_AssignConcat($this->yyastk[$this->stackPos-(3-1)], $this->yyastk[$this->stackPos-(3-3)], $attributes); 
    +    }
    +
    +    protected function yyn193($attributes) {
    +         $this->yyval = new PHPParser_Node_Expr_AssignMod($this->yyastk[$this->stackPos-(3-1)], $this->yyastk[$this->stackPos-(3-3)], $attributes); 
    +    }
    +
    +    protected function yyn194($attributes) {
    +         $this->yyval = new PHPParser_Node_Expr_AssignBitwiseAnd($this->yyastk[$this->stackPos-(3-1)], $this->yyastk[$this->stackPos-(3-3)], $attributes); 
    +    }
    +
    +    protected function yyn195($attributes) {
    +         $this->yyval = new PHPParser_Node_Expr_AssignBitwiseOr($this->yyastk[$this->stackPos-(3-1)], $this->yyastk[$this->stackPos-(3-3)], $attributes); 
    +    }
    +
    +    protected function yyn196($attributes) {
    +         $this->yyval = new PHPParser_Node_Expr_AssignBitwiseXor($this->yyastk[$this->stackPos-(3-1)], $this->yyastk[$this->stackPos-(3-3)], $attributes); 
    +    }
    +
    +    protected function yyn197($attributes) {
    +         $this->yyval = new PHPParser_Node_Expr_AssignShiftLeft($this->yyastk[$this->stackPos-(3-1)], $this->yyastk[$this->stackPos-(3-3)], $attributes); 
    +    }
    +
    +    protected function yyn198($attributes) {
    +         $this->yyval = new PHPParser_Node_Expr_AssignShiftRight($this->yyastk[$this->stackPos-(3-1)], $this->yyastk[$this->stackPos-(3-3)], $attributes); 
    +    }
    +
    +    protected function yyn199($attributes) {
    +         $this->yyval = new PHPParser_Node_Expr_PostInc($this->yyastk[$this->stackPos-(2-1)], $attributes); 
    +    }
    +
    +    protected function yyn200($attributes) {
    +         $this->yyval = new PHPParser_Node_Expr_PreInc($this->yyastk[$this->stackPos-(2-2)], $attributes); 
    +    }
    +
    +    protected function yyn201($attributes) {
    +         $this->yyval = new PHPParser_Node_Expr_PostDec($this->yyastk[$this->stackPos-(2-1)], $attributes); 
    +    }
    +
    +    protected function yyn202($attributes) {
    +         $this->yyval = new PHPParser_Node_Expr_PreDec($this->yyastk[$this->stackPos-(2-2)], $attributes); 
    +    }
    +
    +    protected function yyn203($attributes) {
    +         $this->yyval = new PHPParser_Node_Expr_BooleanOr($this->yyastk[$this->stackPos-(3-1)], $this->yyastk[$this->stackPos-(3-3)], $attributes); 
    +    }
    +
    +    protected function yyn204($attributes) {
    +         $this->yyval = new PHPParser_Node_Expr_BooleanAnd($this->yyastk[$this->stackPos-(3-1)], $this->yyastk[$this->stackPos-(3-3)], $attributes); 
    +    }
    +
    +    protected function yyn205($attributes) {
    +         $this->yyval = new PHPParser_Node_Expr_LogicalOr($this->yyastk[$this->stackPos-(3-1)], $this->yyastk[$this->stackPos-(3-3)], $attributes); 
    +    }
    +
    +    protected function yyn206($attributes) {
    +         $this->yyval = new PHPParser_Node_Expr_LogicalAnd($this->yyastk[$this->stackPos-(3-1)], $this->yyastk[$this->stackPos-(3-3)], $attributes); 
    +    }
    +
    +    protected function yyn207($attributes) {
    +         $this->yyval = new PHPParser_Node_Expr_LogicalXor($this->yyastk[$this->stackPos-(3-1)], $this->yyastk[$this->stackPos-(3-3)], $attributes); 
    +    }
    +
    +    protected function yyn208($attributes) {
    +         $this->yyval = new PHPParser_Node_Expr_BitwiseOr($this->yyastk[$this->stackPos-(3-1)], $this->yyastk[$this->stackPos-(3-3)], $attributes); 
    +    }
    +
    +    protected function yyn209($attributes) {
    +         $this->yyval = new PHPParser_Node_Expr_BitwiseAnd($this->yyastk[$this->stackPos-(3-1)], $this->yyastk[$this->stackPos-(3-3)], $attributes); 
    +    }
    +
    +    protected function yyn210($attributes) {
    +         $this->yyval = new PHPParser_Node_Expr_BitwiseXor($this->yyastk[$this->stackPos-(3-1)], $this->yyastk[$this->stackPos-(3-3)], $attributes); 
    +    }
    +
    +    protected function yyn211($attributes) {
    +         $this->yyval = new PHPParser_Node_Expr_Concat($this->yyastk[$this->stackPos-(3-1)], $this->yyastk[$this->stackPos-(3-3)], $attributes); 
    +    }
    +
    +    protected function yyn212($attributes) {
    +         $this->yyval = new PHPParser_Node_Expr_Plus($this->yyastk[$this->stackPos-(3-1)], $this->yyastk[$this->stackPos-(3-3)], $attributes); 
    +    }
    +
    +    protected function yyn213($attributes) {
    +         $this->yyval = new PHPParser_Node_Expr_Minus($this->yyastk[$this->stackPos-(3-1)], $this->yyastk[$this->stackPos-(3-3)], $attributes); 
    +    }
    +
    +    protected function yyn214($attributes) {
    +         $this->yyval = new PHPParser_Node_Expr_Mul($this->yyastk[$this->stackPos-(3-1)], $this->yyastk[$this->stackPos-(3-3)], $attributes); 
    +    }
    +
    +    protected function yyn215($attributes) {
    +         $this->yyval = new PHPParser_Node_Expr_Div($this->yyastk[$this->stackPos-(3-1)], $this->yyastk[$this->stackPos-(3-3)], $attributes); 
    +    }
    +
    +    protected function yyn216($attributes) {
    +         $this->yyval = new PHPParser_Node_Expr_Mod($this->yyastk[$this->stackPos-(3-1)], $this->yyastk[$this->stackPos-(3-3)], $attributes); 
    +    }
    +
    +    protected function yyn217($attributes) {
    +         $this->yyval = new PHPParser_Node_Expr_ShiftLeft($this->yyastk[$this->stackPos-(3-1)], $this->yyastk[$this->stackPos-(3-3)], $attributes); 
    +    }
    +
    +    protected function yyn218($attributes) {
    +         $this->yyval = new PHPParser_Node_Expr_ShiftRight($this->yyastk[$this->stackPos-(3-1)], $this->yyastk[$this->stackPos-(3-3)], $attributes); 
    +    }
    +
    +    protected function yyn219($attributes) {
    +         $this->yyval = new PHPParser_Node_Expr_UnaryPlus($this->yyastk[$this->stackPos-(2-2)], $attributes); 
    +    }
    +
    +    protected function yyn220($attributes) {
    +         $this->yyval = new PHPParser_Node_Expr_UnaryMinus($this->yyastk[$this->stackPos-(2-2)], $attributes); 
    +    }
    +
    +    protected function yyn221($attributes) {
    +         $this->yyval = new PHPParser_Node_Expr_BooleanNot($this->yyastk[$this->stackPos-(2-2)], $attributes); 
    +    }
    +
    +    protected function yyn222($attributes) {
    +         $this->yyval = new PHPParser_Node_Expr_BitwiseNot($this->yyastk[$this->stackPos-(2-2)], $attributes); 
    +    }
    +
    +    protected function yyn223($attributes) {
    +         $this->yyval = new PHPParser_Node_Expr_Identical($this->yyastk[$this->stackPos-(3-1)], $this->yyastk[$this->stackPos-(3-3)], $attributes); 
    +    }
    +
    +    protected function yyn224($attributes) {
    +         $this->yyval = new PHPParser_Node_Expr_NotIdentical($this->yyastk[$this->stackPos-(3-1)], $this->yyastk[$this->stackPos-(3-3)], $attributes); 
    +    }
    +
    +    protected function yyn225($attributes) {
    +         $this->yyval = new PHPParser_Node_Expr_Equal($this->yyastk[$this->stackPos-(3-1)], $this->yyastk[$this->stackPos-(3-3)], $attributes); 
    +    }
    +
    +    protected function yyn226($attributes) {
    +         $this->yyval = new PHPParser_Node_Expr_NotEqual($this->yyastk[$this->stackPos-(3-1)], $this->yyastk[$this->stackPos-(3-3)], $attributes); 
    +    }
    +
    +    protected function yyn227($attributes) {
    +         $this->yyval = new PHPParser_Node_Expr_Smaller($this->yyastk[$this->stackPos-(3-1)], $this->yyastk[$this->stackPos-(3-3)], $attributes); 
    +    }
    +
    +    protected function yyn228($attributes) {
    +         $this->yyval = new PHPParser_Node_Expr_SmallerOrEqual($this->yyastk[$this->stackPos-(3-1)], $this->yyastk[$this->stackPos-(3-3)], $attributes); 
    +    }
    +
    +    protected function yyn229($attributes) {
    +         $this->yyval = new PHPParser_Node_Expr_Greater($this->yyastk[$this->stackPos-(3-1)], $this->yyastk[$this->stackPos-(3-3)], $attributes); 
    +    }
    +
    +    protected function yyn230($attributes) {
    +         $this->yyval = new PHPParser_Node_Expr_GreaterOrEqual($this->yyastk[$this->stackPos-(3-1)], $this->yyastk[$this->stackPos-(3-3)], $attributes); 
    +    }
    +
    +    protected function yyn231($attributes) {
    +         $this->yyval = new PHPParser_Node_Expr_Instanceof($this->yyastk[$this->stackPos-(3-1)], $this->yyastk[$this->stackPos-(3-3)], $attributes); 
    +    }
    +
    +    protected function yyn232($attributes) {
    +         $this->yyval = $this->yyastk[$this->stackPos-(1-1)]; 
    +    }
    +
    +    protected function yyn233($attributes) {
    +         $this->yyval = $this->yyastk[$this->stackPos-(3-2)]; 
    +    }
    +
    +    protected function yyn234($attributes) {
    +         $this->yyval = new PHPParser_Node_Expr_Ternary($this->yyastk[$this->stackPos-(5-1)], $this->yyastk[$this->stackPos-(5-3)], $this->yyastk[$this->stackPos-(5-5)], $attributes); 
    +    }
    +
    +    protected function yyn235($attributes) {
    +         $this->yyval = new PHPParser_Node_Expr_Ternary($this->yyastk[$this->stackPos-(4-1)], null, $this->yyastk[$this->stackPos-(4-4)], $attributes); 
    +    }
    +
    +    protected function yyn236($attributes) {
    +         $this->yyval = new PHPParser_Node_Expr_Isset($this->yyastk[$this->stackPos-(4-3)], $attributes); 
    +    }
    +
    +    protected function yyn237($attributes) {
    +         $this->yyval = new PHPParser_Node_Expr_Empty($this->yyastk[$this->stackPos-(4-3)], $attributes); 
    +    }
    +
    +    protected function yyn238($attributes) {
    +         $this->yyval = new PHPParser_Node_Expr_Include($this->yyastk[$this->stackPos-(2-2)], PHPParser_Node_Expr_Include::TYPE_INCLUDE, $attributes); 
    +    }
    +
    +    protected function yyn239($attributes) {
    +         $this->yyval = new PHPParser_Node_Expr_Include($this->yyastk[$this->stackPos-(2-2)], PHPParser_Node_Expr_Include::TYPE_INCLUDE_ONCE, $attributes); 
    +    }
    +
    +    protected function yyn240($attributes) {
    +         $this->yyval = new PHPParser_Node_Expr_Eval($this->yyastk[$this->stackPos-(2-2)], $attributes); 
    +    }
    +
    +    protected function yyn241($attributes) {
    +         $this->yyval = new PHPParser_Node_Expr_Include($this->yyastk[$this->stackPos-(2-2)], PHPParser_Node_Expr_Include::TYPE_REQUIRE, $attributes); 
    +    }
    +
    +    protected function yyn242($attributes) {
    +         $this->yyval = new PHPParser_Node_Expr_Include($this->yyastk[$this->stackPos-(2-2)], PHPParser_Node_Expr_Include::TYPE_REQUIRE_ONCE, $attributes); 
    +    }
    +
    +    protected function yyn243($attributes) {
    +         $this->yyval = new PHPParser_Node_Expr_Cast_Int($this->yyastk[$this->stackPos-(2-2)], $attributes); 
    +    }
    +
    +    protected function yyn244($attributes) {
    +         $this->yyval = new PHPParser_Node_Expr_Cast_Double($this->yyastk[$this->stackPos-(2-2)], $attributes); 
    +    }
    +
    +    protected function yyn245($attributes) {
    +         $this->yyval = new PHPParser_Node_Expr_Cast_String($this->yyastk[$this->stackPos-(2-2)], $attributes); 
    +    }
    +
    +    protected function yyn246($attributes) {
    +         $this->yyval = new PHPParser_Node_Expr_Cast_Array($this->yyastk[$this->stackPos-(2-2)], $attributes); 
    +    }
    +
    +    protected function yyn247($attributes) {
    +         $this->yyval = new PHPParser_Node_Expr_Cast_Object($this->yyastk[$this->stackPos-(2-2)], $attributes); 
    +    }
    +
    +    protected function yyn248($attributes) {
    +         $this->yyval = new PHPParser_Node_Expr_Cast_Bool($this->yyastk[$this->stackPos-(2-2)], $attributes); 
    +    }
    +
    +    protected function yyn249($attributes) {
    +         $this->yyval = new PHPParser_Node_Expr_Cast_Unset($this->yyastk[$this->stackPos-(2-2)], $attributes); 
    +    }
    +
    +    protected function yyn250($attributes) {
    +         $this->yyval = new PHPParser_Node_Expr_Exit($this->yyastk[$this->stackPos-(2-2)], $attributes); 
    +    }
    +
    +    protected function yyn251($attributes) {
    +         $this->yyval = new PHPParser_Node_Expr_ErrorSuppress($this->yyastk[$this->stackPos-(2-2)], $attributes); 
    +    }
    +
    +    protected function yyn252($attributes) {
    +         $this->yyval = $this->yyastk[$this->stackPos-(1-1)]; 
    +    }
    +
    +    protected function yyn253($attributes) {
    +         $this->yyval = $this->yyastk[$this->stackPos-(1-1)]; 
    +    }
    +
    +    protected function yyn254($attributes) {
    +         $this->yyval = $this->yyastk[$this->stackPos-(1-1)]; 
    +    }
    +
    +    protected function yyn255($attributes) {
    +         $this->yyval = new PHPParser_Node_Expr_ShellExec($this->yyastk[$this->stackPos-(3-2)], $attributes); 
    +    }
    +
    +    protected function yyn256($attributes) {
    +         $this->yyval = new PHPParser_Node_Expr_Print($this->yyastk[$this->stackPos-(2-2)], $attributes); 
    +    }
    +
    +    protected function yyn257($attributes) {
    +         $this->yyval = new PHPParser_Node_Expr_Yield(null, null, $attributes); 
    +    }
    +
    +    protected function yyn258($attributes) {
    +         $this->yyval = new PHPParser_Node_Expr_Closure(array('static' => false, 'byRef' => $this->yyastk[$this->stackPos-(9-2)], 'params' => $this->yyastk[$this->stackPos-(9-4)], 'uses' => $this->yyastk[$this->stackPos-(9-6)], 'stmts' => $this->yyastk[$this->stackPos-(9-8)]), $attributes); 
    +    }
    +
    +    protected function yyn259($attributes) {
    +         $this->yyval = new PHPParser_Node_Expr_Closure(array('static' => true, 'byRef' => $this->yyastk[$this->stackPos-(10-3)], 'params' => $this->yyastk[$this->stackPos-(10-5)], 'uses' => $this->yyastk[$this->stackPos-(10-7)], 'stmts' => $this->yyastk[$this->stackPos-(10-9)]), $attributes); 
    +    }
    +
    +    protected function yyn260($attributes) {
    +         $this->yyval = $this->yyastk[$this->stackPos-(3-2)]; 
    +    }
    +
    +    protected function yyn261($attributes) {
    +         $this->yyval = $this->yyastk[$this->stackPos-(3-2)]; 
    +    }
    +
    +    protected function yyn262($attributes) {
    +         $this->yyval = new PHPParser_Node_Expr_Yield($this->yyastk[$this->stackPos-(2-2)], null, $attributes); 
    +    }
    +
    +    protected function yyn263($attributes) {
    +         $this->yyval = new PHPParser_Node_Expr_Yield($this->yyastk[$this->stackPos-(4-4)], $this->yyastk[$this->stackPos-(4-2)], $attributes); 
    +    }
    +
    +    protected function yyn264($attributes) {
    +         $this->yyval = new PHPParser_Node_Expr_Array($this->yyastk[$this->stackPos-(4-3)], $attributes); 
    +    }
    +
    +    protected function yyn265($attributes) {
    +         $this->yyval = new PHPParser_Node_Expr_Array($this->yyastk[$this->stackPos-(3-2)], $attributes); 
    +    }
    +
    +    protected function yyn266($attributes) {
    +         $this->yyval = new PHPParser_Node_Expr_ArrayDimFetch($this->yyastk[$this->stackPos-(4-1)], $this->yyastk[$this->stackPos-(4-3)], $attributes); 
    +    }
    +
    +    protected function yyn267($attributes) {
    +         $this->yyval = new PHPParser_Node_Expr_ArrayDimFetch(new PHPParser_Node_Scalar_String(PHPParser_Node_Scalar_String::parse($this->yyastk[$this->stackPos-(4-1)]), $attributes), $this->yyastk[$this->stackPos-(4-3)], $attributes); 
    +    }
    +
    +    protected function yyn268($attributes) {
    +         $this->yyval = new PHPParser_Node_Expr_ArrayDimFetch($this->yyastk[$this->stackPos-(4-1)], $this->yyastk[$this->stackPos-(4-3)], $attributes); 
    +    }
    +
    +    protected function yyn269($attributes) {
    +         $this->yyval = new PHPParser_Node_Expr_New($this->yyastk[$this->stackPos-(3-2)], $this->yyastk[$this->stackPos-(3-3)], $attributes); 
    +    }
    +
    +    protected function yyn270($attributes) {
    +         $this->yyval = array(); 
    +    }
    +
    +    protected function yyn271($attributes) {
    +         $this->yyval = $this->yyastk[$this->stackPos-(4-3)]; 
    +    }
    +
    +    protected function yyn272($attributes) {
    +         $this->yyval = array($this->yyastk[$this->stackPos-(1-1)]); 
    +    }
    +
    +    protected function yyn273($attributes) {
    +         $this->yyastk[$this->stackPos-(3-1)][] = $this->yyastk[$this->stackPos-(3-3)]; $this->yyval = $this->yyastk[$this->stackPos-(3-1)]; 
    +    }
    +
    +    protected function yyn274($attributes) {
    +         $this->yyval = new PHPParser_Node_Expr_ClosureUse(substr($this->yyastk[$this->stackPos-(2-2)], 1), $this->yyastk[$this->stackPos-(2-1)], $attributes); 
    +    }
    +
    +    protected function yyn275($attributes) {
    +         $this->yyval = new PHPParser_Node_Expr_FuncCall($this->yyastk[$this->stackPos-(2-1)], $this->yyastk[$this->stackPos-(2-2)], $attributes); 
    +    }
    +
    +    protected function yyn276($attributes) {
    +         $this->yyval = new PHPParser_Node_Expr_StaticCall($this->yyastk[$this->stackPos-(4-1)], $this->yyastk[$this->stackPos-(4-3)], $this->yyastk[$this->stackPos-(4-4)], $attributes); 
    +    }
    +
    +    protected function yyn277($attributes) {
    +         $this->yyval = new PHPParser_Node_Expr_StaticCall($this->yyastk[$this->stackPos-(6-1)], $this->yyastk[$this->stackPos-(6-4)], $this->yyastk[$this->stackPos-(6-6)], $attributes); 
    +    }
    +
    +    protected function yyn278($attributes) {
    +        
    +            if ($this->yyastk[$this->stackPos-(2-1)] instanceof PHPParser_Node_Expr_StaticPropertyFetch) {
    +                $this->yyval = new PHPParser_Node_Expr_StaticCall($this->yyastk[$this->stackPos-(2-1)]->class, new PHPParser_Node_Expr_Variable($this->yyastk[$this->stackPos-(2-1)]->name, $attributes), $this->yyastk[$this->stackPos-(2-2)], $attributes);
    +            } elseif ($this->yyastk[$this->stackPos-(2-1)] instanceof PHPParser_Node_Expr_ArrayDimFetch) {
    +                $tmp = $this->yyastk[$this->stackPos-(2-1)];
    +                while ($tmp->var instanceof PHPParser_Node_Expr_ArrayDimFetch) {
    +                    $tmp = $tmp->var;
    +                }
    +
    +                $this->yyval = new PHPParser_Node_Expr_StaticCall($tmp->var->class, $this->yyastk[$this->stackPos-(2-1)], $this->yyastk[$this->stackPos-(2-2)], $attributes);
    +                $tmp->var = new PHPParser_Node_Expr_Variable($tmp->var->name, $attributes);
    +            } else {
    +                throw new Exception;
    +            }
    +          
    +    }
    +
    +    protected function yyn279($attributes) {
    +         $this->yyval = new PHPParser_Node_Expr_FuncCall($this->yyastk[$this->stackPos-(2-1)], $this->yyastk[$this->stackPos-(2-2)], $attributes); 
    +    }
    +
    +    protected function yyn280($attributes) {
    +         $this->yyval = new PHPParser_Node_Expr_ArrayDimFetch($this->yyastk[$this->stackPos-(4-1)], $this->yyastk[$this->stackPos-(4-3)], $attributes); 
    +    }
    +
    +    protected function yyn281($attributes) {
    +         $this->yyval = new PHPParser_Node_Name('static', $attributes); 
    +    }
    +
    +    protected function yyn282($attributes) {
    +         $this->yyval = $this->yyastk[$this->stackPos-(1-1)]; 
    +    }
    +
    +    protected function yyn283($attributes) {
    +         $this->yyval = new PHPParser_Node_Name($this->yyastk[$this->stackPos-(1-1)], $attributes); 
    +    }
    +
    +    protected function yyn284($attributes) {
    +         $this->yyval = new PHPParser_Node_Name_FullyQualified($this->yyastk[$this->stackPos-(2-2)], $attributes); 
    +    }
    +
    +    protected function yyn285($attributes) {
    +         $this->yyval = new PHPParser_Node_Name_Relative($this->yyastk[$this->stackPos-(3-3)], $attributes); 
    +    }
    +
    +    protected function yyn286($attributes) {
    +         $this->yyval = $this->yyastk[$this->stackPos-(1-1)]; 
    +    }
    +
    +    protected function yyn287($attributes) {
    +         $this->yyval = $this->yyastk[$this->stackPos-(1-1)]; 
    +    }
    +
    +    protected function yyn288($attributes) {
    +         $this->yyval = $this->yyastk[$this->stackPos-(1-1)]; 
    +    }
    +
    +    protected function yyn289($attributes) {
    +         $this->yyval = $this->yyastk[$this->stackPos-(1-1)]; 
    +    }
    +
    +    protected function yyn290($attributes) {
    +         $this->yyval = $this->yyastk[$this->stackPos-(1-1)]; 
    +    }
    +
    +    protected function yyn291($attributes) {
    +         $this->yyval = $this->yyastk[$this->stackPos-(1-1)]; 
    +    }
    +
    +    protected function yyn292() {
    +        $this->yyval = $this->yyastk[$this->stackPos];
    +    }
    +
    +    protected function yyn293($attributes) {
    +         $this->yyval = new PHPParser_Node_Expr_PropertyFetch($this->yyastk[$this->stackPos-(3-1)], $this->yyastk[$this->stackPos-(3-3)], $attributes); 
    +    }
    +
    +    protected function yyn294($attributes) {
    +         $this->yyval = new PHPParser_Node_Expr_PropertyFetch($this->yyastk[$this->stackPos-(3-1)], $this->yyastk[$this->stackPos-(3-3)], $attributes); 
    +    }
    +
    +    protected function yyn295($attributes) {
    +         $this->yyval = new PHPParser_Node_Expr_ArrayDimFetch($this->yyastk[$this->stackPos-(4-1)], $this->yyastk[$this->stackPos-(4-3)], $attributes); 
    +    }
    +
    +    protected function yyn296($attributes) {
    +         $this->yyval = new PHPParser_Node_Expr_ArrayDimFetch($this->yyastk[$this->stackPos-(4-1)], $this->yyastk[$this->stackPos-(4-3)], $attributes); 
    +    }
    +
    +    protected function yyn297($attributes) {
    +         $this->yyval = null; 
    +    }
    +
    +    protected function yyn298($attributes) {
    +         $this->yyval = null; 
    +    }
    +
    +    protected function yyn299($attributes) {
    +         $this->yyval = $this->yyastk[$this->stackPos-(1-1)]; 
    +    }
    +
    +    protected function yyn300($attributes) {
    +         $this->yyval = array(); 
    +    }
    +
    +    protected function yyn301($attributes) {
    +         $this->yyval = array(PHPParser_Node_Scalar_String::parseEscapeSequences($this->yyastk[$this->stackPos-(1-1)], '`')); 
    +    }
    +
    +    protected function yyn302($attributes) {
    +         foreach ($this->yyastk[$this->stackPos-(1-1)] as &$s) { if (is_string($s)) { $s = PHPParser_Node_Scalar_String::parseEscapeSequences($s, '`'); } }; $this->yyval = $this->yyastk[$this->stackPos-(1-1)]; 
    +    }
    +
    +    protected function yyn303($attributes) {
    +         $this->yyval = array(); 
    +    }
    +
    +    protected function yyn304($attributes) {
    +         $this->yyval = $this->yyastk[$this->stackPos-(1-1)]; 
    +    }
    +
    +    protected function yyn305($attributes) {
    +         $this->yyval = new PHPParser_Node_Scalar_LNumber(PHPParser_Node_Scalar_LNumber::parse($this->yyastk[$this->stackPos-(1-1)]), $attributes); 
    +    }
    +
    +    protected function yyn306($attributes) {
    +         $this->yyval = new PHPParser_Node_Scalar_DNumber(PHPParser_Node_Scalar_DNumber::parse($this->yyastk[$this->stackPos-(1-1)]), $attributes); 
    +    }
    +
    +    protected function yyn307($attributes) {
    +         $this->yyval = new PHPParser_Node_Scalar_String(PHPParser_Node_Scalar_String::parse($this->yyastk[$this->stackPos-(1-1)]), $attributes); 
    +    }
    +
    +    protected function yyn308($attributes) {
    +         $this->yyval = new PHPParser_Node_Scalar_LineConst($attributes); 
    +    }
    +
    +    protected function yyn309($attributes) {
    +         $this->yyval = new PHPParser_Node_Scalar_FileConst($attributes); 
    +    }
    +
    +    protected function yyn310($attributes) {
    +         $this->yyval = new PHPParser_Node_Scalar_DirConst($attributes); 
    +    }
    +
    +    protected function yyn311($attributes) {
    +         $this->yyval = new PHPParser_Node_Scalar_ClassConst($attributes); 
    +    }
    +
    +    protected function yyn312($attributes) {
    +         $this->yyval = new PHPParser_Node_Scalar_TraitConst($attributes); 
    +    }
    +
    +    protected function yyn313($attributes) {
    +         $this->yyval = new PHPParser_Node_Scalar_MethodConst($attributes); 
    +    }
    +
    +    protected function yyn314($attributes) {
    +         $this->yyval = new PHPParser_Node_Scalar_FuncConst($attributes); 
    +    }
    +
    +    protected function yyn315($attributes) {
    +         $this->yyval = new PHPParser_Node_Scalar_NSConst($attributes); 
    +    }
    +
    +    protected function yyn316($attributes) {
    +         $this->yyval = new PHPParser_Node_Scalar_String(PHPParser_Node_Scalar_String::parseDocString($this->yyastk[$this->stackPos-(3-1)], $this->yyastk[$this->stackPos-(3-2)]), $attributes); 
    +    }
    +
    +    protected function yyn317($attributes) {
    +         $this->yyval = new PHPParser_Node_Scalar_String('', $attributes); 
    +    }
    +
    +    protected function yyn318($attributes) {
    +         $this->yyval = new PHPParser_Node_Expr_ConstFetch($this->yyastk[$this->stackPos-(1-1)], $attributes); 
    +    }
    +
    +    protected function yyn319($attributes) {
    +         $this->yyval = $this->yyastk[$this->stackPos-(1-1)]; 
    +    }
    +
    +    protected function yyn320($attributes) {
    +         $this->yyval = new PHPParser_Node_Expr_ClassConstFetch($this->yyastk[$this->stackPos-(3-1)], $this->yyastk[$this->stackPos-(3-3)], $attributes); 
    +    }
    +
    +    protected function yyn321($attributes) {
    +         $this->yyval = new PHPParser_Node_Expr_UnaryPlus($this->yyastk[$this->stackPos-(2-2)], $attributes); 
    +    }
    +
    +    protected function yyn322($attributes) {
    +         $this->yyval = new PHPParser_Node_Expr_UnaryMinus($this->yyastk[$this->stackPos-(2-2)], $attributes); 
    +    }
    +
    +    protected function yyn323($attributes) {
    +         $this->yyval = new PHPParser_Node_Expr_Array($this->yyastk[$this->stackPos-(4-3)], $attributes); 
    +    }
    +
    +    protected function yyn324($attributes) {
    +         $this->yyval = new PHPParser_Node_Expr_Array($this->yyastk[$this->stackPos-(3-2)], $attributes); 
    +    }
    +
    +    protected function yyn325($attributes) {
    +         $this->yyval = $this->yyastk[$this->stackPos-(1-1)]; 
    +    }
    +
    +    protected function yyn326($attributes) {
    +         $this->yyval = new PHPParser_Node_Expr_ClassConstFetch($this->yyastk[$this->stackPos-(3-1)], $this->yyastk[$this->stackPos-(3-3)], $attributes); 
    +    }
    +
    +    protected function yyn327($attributes) {
    +         foreach ($this->yyastk[$this->stackPos-(3-2)] as &$s) { if (is_string($s)) { $s = PHPParser_Node_Scalar_String::parseEscapeSequences($s, '"'); } }; $this->yyval = new PHPParser_Node_Scalar_Encapsed($this->yyastk[$this->stackPos-(3-2)], $attributes); 
    +    }
    +
    +    protected function yyn328($attributes) {
    +         foreach ($this->yyastk[$this->stackPos-(3-2)] as &$s) { if (is_string($s)) { $s = PHPParser_Node_Scalar_String::parseEscapeSequences($s, null); } } $s = preg_replace('~(\r\n|\n|\r)$~', '', $s); if ('' === $s) array_pop($this->yyastk[$this->stackPos-(3-2)]);; $this->yyval = new PHPParser_Node_Scalar_Encapsed($this->yyastk[$this->stackPos-(3-2)], $attributes); 
    +    }
    +
    +    protected function yyn329($attributes) {
    +         $this->yyval = $this->yyastk[$this->stackPos-(1-1)]; 
    +    }
    +
    +    protected function yyn330($attributes) {
    +         $this->yyval = 'class'; 
    +    }
    +
    +    protected function yyn331($attributes) {
    +         $this->yyval = array(); 
    +    }
    +
    +    protected function yyn332($attributes) {
    +         $this->yyval = $this->yyastk[$this->stackPos-(2-1)]; 
    +    }
    +
    +    protected function yyn333() {
    +        $this->yyval = $this->yyastk[$this->stackPos];
    +    }
    +
    +    protected function yyn334() {
    +        $this->yyval = $this->yyastk[$this->stackPos];
    +    }
    +
    +    protected function yyn335($attributes) {
    +         $this->yyastk[$this->stackPos-(3-1)][] = $this->yyastk[$this->stackPos-(3-3)]; $this->yyval = $this->yyastk[$this->stackPos-(3-1)]; 
    +    }
    +
    +    protected function yyn336($attributes) {
    +         $this->yyval = array($this->yyastk[$this->stackPos-(1-1)]); 
    +    }
    +
    +    protected function yyn337($attributes) {
    +         $this->yyval = new PHPParser_Node_Expr_ArrayItem($this->yyastk[$this->stackPos-(3-3)], $this->yyastk[$this->stackPos-(3-1)], false, $attributes); 
    +    }
    +
    +    protected function yyn338($attributes) {
    +         $this->yyval = new PHPParser_Node_Expr_ArrayItem($this->yyastk[$this->stackPos-(1-1)], null, false, $attributes); 
    +    }
    +
    +    protected function yyn339($attributes) {
    +         $this->yyval = $this->yyastk[$this->stackPos-(1-1)]; 
    +    }
    +
    +    protected function yyn340($attributes) {
    +         $this->yyval = $this->yyastk[$this->stackPos-(1-1)]; 
    +    }
    +
    +    protected function yyn341($attributes) {
    +         $this->yyval = $this->yyastk[$this->stackPos-(1-1)]; 
    +    }
    +
    +    protected function yyn342($attributes) {
    +         $this->yyval = $this->yyastk[$this->stackPos-(1-1)]; 
    +    }
    +
    +    protected function yyn343($attributes) {
    +         $this->yyval = new PHPParser_Node_Expr_ArrayDimFetch($this->yyastk[$this->stackPos-(6-2)], $this->yyastk[$this->stackPos-(6-5)], $attributes); 
    +    }
    +
    +    protected function yyn344($attributes) {
    +         $this->yyval = new PHPParser_Node_Expr_ArrayDimFetch($this->yyastk[$this->stackPos-(4-1)], $this->yyastk[$this->stackPos-(4-3)], $attributes); 
    +    }
    +
    +    protected function yyn345($attributes) {
    +         $this->yyval = new PHPParser_Node_Expr_PropertyFetch($this->yyastk[$this->stackPos-(3-1)], $this->yyastk[$this->stackPos-(3-3)], $attributes); 
    +    }
    +
    +    protected function yyn346($attributes) {
    +         $this->yyval = new PHPParser_Node_Expr_MethodCall($this->yyastk[$this->stackPos-(4-1)], $this->yyastk[$this->stackPos-(4-3)], $this->yyastk[$this->stackPos-(4-4)], $attributes); 
    +    }
    +
    +    protected function yyn347($attributes) {
    +         $this->yyval = new PHPParser_Node_Expr_FuncCall($this->yyastk[$this->stackPos-(2-1)], $this->yyastk[$this->stackPos-(2-2)], $attributes); 
    +    }
    +
    +    protected function yyn348($attributes) {
    +         $this->yyval = new PHPParser_Node_Expr_ArrayDimFetch($this->yyastk[$this->stackPos-(4-1)], $this->yyastk[$this->stackPos-(4-3)], $attributes); 
    +    }
    +
    +    protected function yyn349($attributes) {
    +         $this->yyval = new PHPParser_Node_Expr_ArrayDimFetch($this->yyastk[$this->stackPos-(4-1)], $this->yyastk[$this->stackPos-(4-3)], $attributes); 
    +    }
    +
    +    protected function yyn350($attributes) {
    +         $this->yyval = $this->yyastk[$this->stackPos-(1-1)]; 
    +    }
    +
    +    protected function yyn351($attributes) {
    +         $this->yyval = $this->yyastk[$this->stackPos-(3-2)]; 
    +    }
    +
    +    protected function yyn352($attributes) {
    +         $this->yyval = $this->yyastk[$this->stackPos-(1-1)]; 
    +    }
    +
    +    protected function yyn353($attributes) {
    +         $this->yyval = new PHPParser_Node_Expr_Variable($this->yyastk[$this->stackPos-(2-2)], $attributes); 
    +    }
    +
    +    protected function yyn354($attributes) {
    +         $this->yyval = $this->yyastk[$this->stackPos-(1-1)]; 
    +    }
    +
    +    protected function yyn355($attributes) {
    +         $this->yyval = $this->yyastk[$this->stackPos-(1-1)]; 
    +    }
    +
    +    protected function yyn356($attributes) {
    +         $this->yyval = new PHPParser_Node_Expr_StaticPropertyFetch($this->yyastk[$this->stackPos-(4-1)], $this->yyastk[$this->stackPos-(4-4)], $attributes); 
    +    }
    +
    +    protected function yyn357($attributes) {
    +         $this->yyval = $this->yyastk[$this->stackPos-(1-1)]; 
    +    }
    +
    +    protected function yyn358($attributes) {
    +         $this->yyval = new PHPParser_Node_Expr_StaticPropertyFetch($this->yyastk[$this->stackPos-(3-1)], substr($this->yyastk[$this->stackPos-(3-3)], 1), $attributes); 
    +    }
    +
    +    protected function yyn359($attributes) {
    +         $this->yyval = new PHPParser_Node_Expr_StaticPropertyFetch($this->yyastk[$this->stackPos-(6-1)], $this->yyastk[$this->stackPos-(6-5)], $attributes); 
    +    }
    +
    +    protected function yyn360($attributes) {
    +         $this->yyval = new PHPParser_Node_Expr_ArrayDimFetch($this->yyastk[$this->stackPos-(4-1)], $this->yyastk[$this->stackPos-(4-3)], $attributes); 
    +    }
    +
    +    protected function yyn361($attributes) {
    +         $this->yyval = new PHPParser_Node_Expr_ArrayDimFetch($this->yyastk[$this->stackPos-(4-1)], $this->yyastk[$this->stackPos-(4-3)], $attributes); 
    +    }
    +
    +    protected function yyn362($attributes) {
    +         $this->yyval = new PHPParser_Node_Expr_ArrayDimFetch($this->yyastk[$this->stackPos-(4-1)], $this->yyastk[$this->stackPos-(4-3)], $attributes); 
    +    }
    +
    +    protected function yyn363($attributes) {
    +         $this->yyval = new PHPParser_Node_Expr_ArrayDimFetch($this->yyastk[$this->stackPos-(4-1)], $this->yyastk[$this->stackPos-(4-3)], $attributes); 
    +    }
    +
    +    protected function yyn364($attributes) {
    +         $this->yyval = new PHPParser_Node_Expr_Variable(substr($this->yyastk[$this->stackPos-(1-1)], 1), $attributes); 
    +    }
    +
    +    protected function yyn365($attributes) {
    +         $this->yyval = new PHPParser_Node_Expr_Variable($this->yyastk[$this->stackPos-(4-3)], $attributes); 
    +    }
    +
    +    protected function yyn366($attributes) {
    +         $this->yyval = null; 
    +    }
    +
    +    protected function yyn367($attributes) {
    +         $this->yyval = $this->yyastk[$this->stackPos-(1-1)]; 
    +    }
    +
    +    protected function yyn368($attributes) {
    +         $this->yyval = $this->yyastk[$this->stackPos-(1-1)]; 
    +    }
    +
    +    protected function yyn369($attributes) {
    +         $this->yyval = $this->yyastk[$this->stackPos-(3-2)]; 
    +    }
    +
    +    protected function yyn370($attributes) {
    +         $this->yyval = $this->yyastk[$this->stackPos-(1-1)]; 
    +    }
    +
    +    protected function yyn371($attributes) {
    +         $this->yyval = new PHPParser_Node_Expr_List($this->yyastk[$this->stackPos-(4-3)], $attributes); 
    +    }
    +
    +    protected function yyn372($attributes) {
    +         $this->yyastk[$this->stackPos-(3-1)][] = $this->yyastk[$this->stackPos-(3-3)]; $this->yyval = $this->yyastk[$this->stackPos-(3-1)]; 
    +    }
    +
    +    protected function yyn373($attributes) {
    +         $this->yyval = array($this->yyastk[$this->stackPos-(1-1)]); 
    +    }
    +
    +    protected function yyn374($attributes) {
    +         $this->yyval = $this->yyastk[$this->stackPos-(1-1)]; 
    +    }
    +
    +    protected function yyn375($attributes) {
    +         $this->yyval = $this->yyastk[$this->stackPos-(1-1)]; 
    +    }
    +
    +    protected function yyn376($attributes) {
    +         $this->yyval = null; 
    +    }
    +
    +    protected function yyn377($attributes) {
    +         $this->yyval = array(); 
    +    }
    +
    +    protected function yyn378($attributes) {
    +         $this->yyval = $this->yyastk[$this->stackPos-(2-1)]; 
    +    }
    +
    +    protected function yyn379($attributes) {
    +         $this->yyastk[$this->stackPos-(3-1)][] = $this->yyastk[$this->stackPos-(3-3)]; $this->yyval = $this->yyastk[$this->stackPos-(3-1)]; 
    +    }
    +
    +    protected function yyn380($attributes) {
    +         $this->yyval = array($this->yyastk[$this->stackPos-(1-1)]); 
    +    }
    +
    +    protected function yyn381($attributes) {
    +         $this->yyval = new PHPParser_Node_Expr_ArrayItem($this->yyastk[$this->stackPos-(3-3)], $this->yyastk[$this->stackPos-(3-1)], false, $attributes); 
    +    }
    +
    +    protected function yyn382($attributes) {
    +         $this->yyval = new PHPParser_Node_Expr_ArrayItem($this->yyastk[$this->stackPos-(1-1)], null, false, $attributes); 
    +    }
    +
    +    protected function yyn383($attributes) {
    +         $this->yyval = new PHPParser_Node_Expr_ArrayItem($this->yyastk[$this->stackPos-(4-4)], $this->yyastk[$this->stackPos-(4-1)], true, $attributes); 
    +    }
    +
    +    protected function yyn384($attributes) {
    +         $this->yyval = new PHPParser_Node_Expr_ArrayItem($this->yyastk[$this->stackPos-(2-2)], null, true, $attributes); 
    +    }
    +
    +    protected function yyn385($attributes) {
    +         $this->yyastk[$this->stackPos-(2-1)][] = $this->yyastk[$this->stackPos-(2-2)]; $this->yyval = $this->yyastk[$this->stackPos-(2-1)]; 
    +    }
    +
    +    protected function yyn386($attributes) {
    +         $this->yyastk[$this->stackPos-(2-1)][] = $this->yyastk[$this->stackPos-(2-2)]; $this->yyval = $this->yyastk[$this->stackPos-(2-1)]; 
    +    }
    +
    +    protected function yyn387($attributes) {
    +         $this->yyval = array($this->yyastk[$this->stackPos-(1-1)]); 
    +    }
    +
    +    protected function yyn388($attributes) {
    +         $this->yyval = array($this->yyastk[$this->stackPos-(2-1)], $this->yyastk[$this->stackPos-(2-2)]); 
    +    }
    +
    +    protected function yyn389($attributes) {
    +         $this->yyval = new PHPParser_Node_Expr_Variable(substr($this->yyastk[$this->stackPos-(1-1)], 1), $attributes); 
    +    }
    +
    +    protected function yyn390($attributes) {
    +         $this->yyval = new PHPParser_Node_Expr_ArrayDimFetch(new PHPParser_Node_Expr_Variable(substr($this->yyastk[$this->stackPos-(4-1)], 1), $attributes), $this->yyastk[$this->stackPos-(4-3)], $attributes); 
    +    }
    +
    +    protected function yyn391($attributes) {
    +         $this->yyval = new PHPParser_Node_Expr_PropertyFetch(new PHPParser_Node_Expr_Variable(substr($this->yyastk[$this->stackPos-(3-1)], 1), $attributes), $this->yyastk[$this->stackPos-(3-3)], $attributes); 
    +    }
    +
    +    protected function yyn392($attributes) {
    +         $this->yyval = new PHPParser_Node_Expr_Variable($this->yyastk[$this->stackPos-(3-2)], $attributes); 
    +    }
    +
    +    protected function yyn393($attributes) {
    +         $this->yyval = new PHPParser_Node_Expr_Variable($this->yyastk[$this->stackPos-(3-2)], $attributes); 
    +    }
    +
    +    protected function yyn394($attributes) {
    +         $this->yyval = new PHPParser_Node_Expr_ArrayDimFetch(new PHPParser_Node_Expr_Variable($this->yyastk[$this->stackPos-(6-2)], $attributes), $this->yyastk[$this->stackPos-(6-4)], $attributes); 
    +    }
    +
    +    protected function yyn395($attributes) {
    +         $this->yyval = $this->yyastk[$this->stackPos-(3-2)]; 
    +    }
    +
    +    protected function yyn396($attributes) {
    +         $this->yyval = new PHPParser_Node_Scalar_String($this->yyastk[$this->stackPos-(1-1)], $attributes); 
    +    }
    +
    +    protected function yyn397($attributes) {
    +         $this->yyval = new PHPParser_Node_Scalar_String($this->yyastk[$this->stackPos-(1-1)], $attributes); 
    +    }
    +
    +    protected function yyn398($attributes) {
    +         $this->yyval = new PHPParser_Node_Expr_Variable(substr($this->yyastk[$this->stackPos-(1-1)], 1), $attributes); 
    +    }
    +}
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/PrettyPrinter/Default.php b/vendor/nikic/php-parser/lib/PHPParser/PrettyPrinter/Default.php
    new file mode 100755
    index 0000000..ad2b4b7
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/PrettyPrinter/Default.php
    @@ -0,0 +1,725 @@
    +type ? (is_string($node->type) ? $node->type : $this->p($node->type)) . ' ' : '')
    +             . ($node->byRef ? '&' : '')
    +             . '$' . $node->name
    +             . ($node->default ? ' = ' . $this->p($node->default) : '');
    +    }
    +
    +    public function pArg(PHPParser_Node_Arg $node) {
    +        return ($node->byRef ? '&' : '') . $this->p($node->value);
    +    }
    +
    +    public function pConst(PHPParser_Node_Const $node) {
    +        return $node->name . ' = ' . $this->p($node->value);
    +    }
    +
    +    // Names
    +
    +    public function pName(PHPParser_Node_Name $node) {
    +        return implode('\\', $node->parts);
    +    }
    +
    +    public function pName_FullyQualified(PHPParser_Node_Name_FullyQualified $node) {
    +        return '\\' . implode('\\', $node->parts);
    +    }
    +
    +    public function pName_Relative(PHPParser_Node_Name_Relative $node) {
    +        return 'namespace\\' . implode('\\', $node->parts);
    +    }
    +
    +    // Magic Constants
    +
    +    public function pScalar_ClassConst(PHPParser_Node_Scalar_ClassConst $node) {
    +        return '__CLASS__';
    +    }
    +
    +    public function pScalar_TraitConst(PHPParser_Node_Scalar_TraitConst $node) {
    +        return '__TRAIT__';
    +    }
    +
    +    public function pScalar_DirConst(PHPParser_Node_Scalar_DirConst $node) {
    +        return '__DIR__';
    +    }
    +
    +    public function pScalar_FileConst(PHPParser_Node_Scalar_FileConst $node) {
    +        return '__FILE__';
    +    }
    +
    +    public function pScalar_FuncConst(PHPParser_Node_Scalar_FuncConst $node) {
    +        return '__FUNCTION__';
    +    }
    +
    +    public function pScalar_LineConst(PHPParser_Node_Scalar_LineConst $node) {
    +        return '__LINE__';
    +    }
    +
    +    public function pScalar_MethodConst(PHPParser_Node_Scalar_MethodConst $node) {
    +        return '__METHOD__';
    +    }
    +
    +    public function pScalar_NSConst(PHPParser_Node_Scalar_NSConst $node) {
    +        return '__NAMESPACE__';
    +    }
    +
    +    // Scalars
    +
    +    public function pScalar_String(PHPParser_Node_Scalar_String $node) {
    +        return '\'' . $this->pNoIndent(addcslashes($node->value, '\'\\')) . '\'';
    +    }
    +
    +    public function pScalar_Encapsed(PHPParser_Node_Scalar_Encapsed $node) {
    +        return '"' . $this->pEncapsList($node->parts, '"') . '"';
    +    }
    +
    +    public function pScalar_LNumber(PHPParser_Node_Scalar_LNumber $node) {
    +        return (string) $node->value;
    +    }
    +
    +    public function pScalar_DNumber(PHPParser_Node_Scalar_DNumber $node) {
    +        $stringValue = (string) $node->value;
    +
    +        // ensure that number is really printed as float
    +        return ctype_digit($stringValue) ? $stringValue . '.0' : $stringValue;
    +    }
    +
    +    // Assignments
    +
    +    public function pExpr_Assign(PHPParser_Node_Expr_Assign $node) {
    +        return $this->pInfixOp('Expr_Assign', $node->var, ' = ', $node->expr);
    +    }
    +
    +    public function pExpr_AssignRef(PHPParser_Node_Expr_AssignRef $node) {
    +        return $this->pInfixOp('Expr_AssignRef', $node->var, ' =& ', $node->expr);
    +    }
    +
    +    public function pExpr_AssignPlus(PHPParser_Node_Expr_AssignPlus $node) {
    +        return $this->pInfixOp('Expr_AssignPlus', $node->var, ' += ', $node->expr);
    +    }
    +
    +    public function pExpr_AssignMinus(PHPParser_Node_Expr_AssignMinus $node) {
    +        return $this->pInfixOp('Expr_AssignMinus', $node->var, ' -= ', $node->expr);
    +    }
    +
    +    public function pExpr_AssignMul(PHPParser_Node_Expr_AssignMul $node) {
    +        return $this->pInfixOp('Expr_AssignMul', $node->var, ' *= ', $node->expr);
    +    }
    +
    +    public function pExpr_AssignDiv(PHPParser_Node_Expr_AssignDiv $node) {
    +        return $this->pInfixOp('Expr_AssignDiv', $node->var, ' /= ', $node->expr);
    +    }
    +
    +    public function pExpr_AssignConcat(PHPParser_Node_Expr_AssignConcat $node) {
    +        return $this->pInfixOp('Expr_AssignConcat', $node->var, ' .= ', $node->expr);
    +    }
    +
    +    public function pExpr_AssignMod(PHPParser_Node_Expr_AssignMod $node) {
    +        return $this->pInfixOp('Expr_AssignMod', $node->var, ' %= ', $node->expr);
    +    }
    +
    +    public function pExpr_AssignBitwiseAnd(PHPParser_Node_Expr_AssignBitwiseAnd $node) {
    +        return $this->pInfixOp('Expr_AssignBitwiseAnd', $node->var, ' &= ', $node->expr);
    +    }
    +
    +    public function pExpr_AssignBitwiseOr(PHPParser_Node_Expr_AssignBitwiseOr $node) {
    +        return $this->pInfixOp('Expr_AssignBitwiseOr', $node->var, ' |= ', $node->expr);
    +    }
    +
    +    public function pExpr_AssignBitwiseXor(PHPParser_Node_Expr_AssignBitwiseXor $node) {
    +        return $this->pInfixOp('Expr_AssignBitwiseXor', $node->var, ' ^= ', $node->expr);
    +    }
    +
    +    public function pExpr_AssignShiftLeft(PHPParser_Node_Expr_AssignShiftLeft $node) {
    +        return $this->pInfixOp('Expr_AssignShiftLeft', $node->var, ' <<= ', $node->expr);
    +    }
    +
    +    public function pExpr_AssignShiftRight(PHPParser_Node_Expr_AssignShiftRight $node) {
    +        return $this->pInfixOp('Expr_AssignShiftRight', $node->var, ' >>= ', $node->expr);
    +    }
    +
    +    // Binary expressions
    +
    +    public function pExpr_Plus(PHPParser_Node_Expr_Plus $node) {
    +        return $this->pInfixOp('Expr_Plus', $node->left, ' + ', $node->right);
    +    }
    +
    +    public function pExpr_Minus(PHPParser_Node_Expr_Minus $node) {
    +        return $this->pInfixOp('Expr_Minus', $node->left, ' - ', $node->right);
    +    }
    +
    +    public function pExpr_Mul(PHPParser_Node_Expr_Mul $node) {
    +        return $this->pInfixOp('Expr_Mul', $node->left, ' * ', $node->right);
    +    }
    +
    +    public function pExpr_Div(PHPParser_Node_Expr_Div $node) {
    +        return $this->pInfixOp('Expr_Div', $node->left, ' / ', $node->right);
    +    }
    +
    +    public function pExpr_Concat(PHPParser_Node_Expr_Concat $node) {
    +        return $this->pInfixOp('Expr_Concat', $node->left, ' . ', $node->right);
    +    }
    +
    +    public function pExpr_Mod(PHPParser_Node_Expr_Mod $node) {
    +        return $this->pInfixOp('Expr_Mod', $node->left, ' % ', $node->right);
    +    }
    +
    +    public function pExpr_BooleanAnd(PHPParser_Node_Expr_BooleanAnd $node) {
    +        return $this->pInfixOp('Expr_BooleanAnd', $node->left, ' && ', $node->right);
    +    }
    +
    +    public function pExpr_BooleanOr(PHPParser_Node_Expr_BooleanOr $node) {
    +        return $this->pInfixOp('Expr_BooleanOr', $node->left, ' || ', $node->right);
    +    }
    +
    +    public function pExpr_BitwiseAnd(PHPParser_Node_Expr_BitwiseAnd $node) {
    +        return $this->pInfixOp('Expr_BitwiseAnd', $node->left, ' & ', $node->right);
    +    }
    +
    +    public function pExpr_BitwiseOr(PHPParser_Node_Expr_BitwiseOr $node) {
    +        return $this->pInfixOp('Expr_BitwiseOr', $node->left, ' | ', $node->right);
    +    }
    +
    +    public function pExpr_BitwiseXor(PHPParser_Node_Expr_BitwiseXor $node) {
    +        return $this->pInfixOp('Expr_BitwiseXor', $node->left, ' ^ ', $node->right);
    +    }
    +
    +    public function pExpr_ShiftLeft(PHPParser_Node_Expr_ShiftLeft $node) {
    +        return $this->pInfixOp('Expr_ShiftLeft', $node->left, ' << ', $node->right);
    +    }
    +
    +    public function pExpr_ShiftRight(PHPParser_Node_Expr_ShiftRight $node) {
    +        return $this->pInfixOp('Expr_ShiftRight', $node->left, ' >> ', $node->right);
    +    }
    +
    +    public function pExpr_LogicalAnd(PHPParser_Node_Expr_LogicalAnd $node) {
    +        return $this->pInfixOp('Expr_LogicalAnd', $node->left, ' and ', $node->right);
    +    }
    +
    +    public function pExpr_LogicalOr(PHPParser_Node_Expr_LogicalOr $node) {
    +        return $this->pInfixOp('Expr_LogicalOr', $node->left, ' or ', $node->right);
    +    }
    +
    +    public function pExpr_LogicalXor(PHPParser_Node_Expr_LogicalXor $node) {
    +        return $this->pInfixOp('Expr_LogicalXor', $node->left, ' xor ', $node->right);
    +    }
    +
    +    public function pExpr_Equal(PHPParser_Node_Expr_Equal $node) {
    +        return $this->pInfixOp('Expr_Equal', $node->left, ' == ', $node->right);
    +    }
    +
    +    public function pExpr_NotEqual(PHPParser_Node_Expr_NotEqual $node) {
    +        return $this->pInfixOp('Expr_NotEqual', $node->left, ' != ', $node->right);
    +    }
    +
    +    public function pExpr_Identical(PHPParser_Node_Expr_Identical $node) {
    +        return $this->pInfixOp('Expr_Identical', $node->left, ' === ', $node->right);
    +    }
    +
    +    public function pExpr_NotIdentical(PHPParser_Node_Expr_NotIdentical $node) {
    +        return $this->pInfixOp('Expr_NotIdentical', $node->left, ' !== ', $node->right);
    +    }
    +
    +    public function pExpr_Greater(PHPParser_Node_Expr_Greater $node) {
    +        return $this->pInfixOp('Expr_Greater', $node->left, ' > ', $node->right);
    +    }
    +
    +    public function pExpr_GreaterOrEqual(PHPParser_Node_Expr_GreaterOrEqual $node) {
    +        return $this->pInfixOp('Expr_GreaterOrEqual', $node->left, ' >= ', $node->right);
    +    }
    +
    +    public function pExpr_Smaller(PHPParser_Node_Expr_Smaller $node) {
    +        return $this->pInfixOp('Expr_Smaller', $node->left, ' < ', $node->right);
    +    }
    +
    +    public function pExpr_SmallerOrEqual(PHPParser_Node_Expr_SmallerOrEqual $node) {
    +        return $this->pInfixOp('Expr_SmallerOrEqual', $node->left, ' <= ', $node->right);
    +    }
    +
    +    public function pExpr_Instanceof(PHPParser_Node_Expr_Instanceof $node) {
    +        return $this->pInfixOp('Expr_Instanceof', $node->expr, ' instanceof ', $node->class);
    +    }
    +
    +    // Unary expressions
    +
    +    public function pExpr_BooleanNot(PHPParser_Node_Expr_BooleanNot $node) {
    +        return $this->pPrefixOp('Expr_BooleanNot', '!', $node->expr);
    +    }
    +
    +    public function pExpr_BitwiseNot(PHPParser_Node_Expr_BitwiseNot $node) {
    +        return $this->pPrefixOp('Expr_BitwiseNot', '~', $node->expr);
    +    }
    +
    +    public function pExpr_UnaryMinus(PHPParser_Node_Expr_UnaryMinus $node) {
    +        return $this->pPrefixOp('Expr_UnaryMinus', '-', $node->expr);
    +    }
    +
    +    public function pExpr_UnaryPlus(PHPParser_Node_Expr_UnaryPlus $node) {
    +        return $this->pPrefixOp('Expr_UnaryPlus', '+', $node->expr);
    +    }
    +
    +    public function pExpr_PreInc(PHPParser_Node_Expr_PreInc $node) {
    +        return $this->pPrefixOp('Expr_PreInc', '++', $node->var);
    +    }
    +
    +    public function pExpr_PreDec(PHPParser_Node_Expr_PreDec $node) {
    +        return $this->pPrefixOp('Expr_PreDec', '--', $node->var);
    +    }
    +
    +    public function pExpr_PostInc(PHPParser_Node_Expr_PostInc $node) {
    +        return $this->pPostfixOp('Expr_PostInc', $node->var, '++');
    +    }
    +
    +    public function pExpr_PostDec(PHPParser_Node_Expr_PostDec $node) {
    +        return $this->pPostfixOp('Expr_PostDec', $node->var, '--');
    +    }
    +
    +    public function pExpr_ErrorSuppress(PHPParser_Node_Expr_ErrorSuppress $node) {
    +        return $this->pPrefixOp('Expr_ErrorSuppress', '@', $node->expr);
    +    }
    +
    +    // Casts
    +
    +    public function pExpr_Cast_Int(PHPParser_Node_Expr_Cast_Int $node) {
    +        return $this->pPrefixOp('Expr_Cast_Int', '(int) ', $node->expr);
    +    }
    +
    +    public function pExpr_Cast_Double(PHPParser_Node_Expr_Cast_Double $node) {
    +        return $this->pPrefixOp('Expr_Cast_Double', '(double) ', $node->expr);
    +    }
    +
    +    public function pExpr_Cast_String(PHPParser_Node_Expr_Cast_String $node) {
    +        return $this->pPrefixOp('Expr_Cast_String', '(string) ', $node->expr);
    +    }
    +
    +    public function pExpr_Cast_Array(PHPParser_Node_Expr_Cast_Array $node) {
    +        return $this->pPrefixOp('Expr_Cast_Array', '(array) ', $node->expr);
    +    }
    +
    +    public function pExpr_Cast_Object(PHPParser_Node_Expr_Cast_Object $node) {
    +        return $this->pPrefixOp('Expr_Cast_Object', '(object) ', $node->expr);
    +    }
    +
    +    public function pExpr_Cast_Bool(PHPParser_Node_Expr_Cast_Bool $node) {
    +        return $this->pPrefixOp('Expr_Cast_Bool', '(bool) ', $node->expr);
    +    }
    +
    +    public function pExpr_Cast_Unset(PHPParser_Node_Expr_Cast_Unset $node) {
    +        return $this->pPrefixOp('Expr_Cast_Unset', '(unset) ', $node->expr);
    +    }
    +
    +    // Function calls and similar constructs
    +
    +    public function pExpr_FuncCall(PHPParser_Node_Expr_FuncCall $node) {
    +        return $this->p($node->name) . '(' . $this->pCommaSeparated($node->args) . ')';
    +    }
    +
    +    public function pExpr_MethodCall(PHPParser_Node_Expr_MethodCall $node) {
    +        return $this->pVarOrNewExpr($node->var) . '->' . $this->pObjectProperty($node->name)
    +             . '(' . $this->pCommaSeparated($node->args) . ')';
    +    }
    +
    +    public function pExpr_StaticCall(PHPParser_Node_Expr_StaticCall $node) {
    +        return $this->p($node->class) . '::'
    +             . ($node->name instanceof PHPParser_Node_Expr
    +                ? ($node->name instanceof PHPParser_Node_Expr_Variable
    +                   || $node->name instanceof PHPParser_Node_Expr_ArrayDimFetch
    +                   ? $this->p($node->name)
    +                   : '{' . $this->p($node->name) . '}')
    +                : $node->name)
    +             . '(' . $this->pCommaSeparated($node->args) . ')';
    +    }
    +
    +    public function pExpr_Empty(PHPParser_Node_Expr_Empty $node) {
    +        return 'empty(' . $this->p($node->expr) . ')';
    +    }
    +
    +    public function pExpr_Isset(PHPParser_Node_Expr_Isset $node) {
    +        return 'isset(' . $this->pCommaSeparated($node->vars) . ')';
    +    }
    +
    +    public function pExpr_Print(PHPParser_Node_Expr_Print $node) {
    +        return 'print ' . $this->p($node->expr);
    +    }
    +
    +    public function pExpr_Eval(PHPParser_Node_Expr_Eval $node) {
    +        return 'eval(' . $this->p($node->expr) . ')';
    +    }
    +
    +    public function pExpr_Include(PHPParser_Node_Expr_Include $node) {
    +        static $map = array(
    +            PHPParser_Node_Expr_Include::TYPE_INCLUDE      => 'include',
    +            PHPParser_Node_Expr_Include::TYPE_INCLUDE_ONCE => 'include_once',
    +            PHPParser_Node_Expr_Include::TYPE_REQUIRE      => 'require',
    +            PHPParser_Node_Expr_Include::TYPE_REQUIRE_ONCE => 'require_once',
    +        );
    +
    +        return $map[$node->type] . ' ' . $this->p($node->expr);
    +    }
    +
    +    public function pExpr_List(PHPParser_Node_Expr_List $node) {
    +        $pList = array();
    +        foreach ($node->vars as $var) {
    +            if (null === $var) {
    +                $pList[] = '';
    +            } else {
    +                $pList[] = $this->p($var);
    +            }
    +        }
    +
    +        return 'list(' . implode(', ', $pList) . ')';
    +    }
    +
    +    // Other
    +
    +    public function pExpr_Variable(PHPParser_Node_Expr_Variable $node) {
    +        if ($node->name instanceof PHPParser_Node_Expr) {
    +            return '${' . $this->p($node->name) . '}';
    +        } else {
    +            return '$' . $node->name;
    +        }
    +    }
    +
    +    public function pExpr_Array(PHPParser_Node_Expr_Array $node) {
    +        return 'array(' . $this->pCommaSeparated($node->items) . ')';
    +    }
    +
    +    public function pExpr_ArrayItem(PHPParser_Node_Expr_ArrayItem $node) {
    +        return (null !== $node->key ? $this->p($node->key) . ' => ' : '')
    +             . ($node->byRef ? '&' : '') . $this->p($node->value);
    +    }
    +
    +    public function pExpr_ArrayDimFetch(PHPParser_Node_Expr_ArrayDimFetch $node) {
    +        return $this->pVarOrNewExpr($node->var)
    +             . '[' . (null !== $node->dim ? $this->p($node->dim) : '') . ']';
    +    }
    +
    +    public function pExpr_ConstFetch(PHPParser_Node_Expr_ConstFetch $node) {
    +        return $this->p($node->name);
    +    }
    +
    +    public function pExpr_ClassConstFetch(PHPParser_Node_Expr_ClassConstFetch $node) {
    +        return $this->p($node->class) . '::' . $node->name;
    +    }
    +
    +    public function pExpr_PropertyFetch(PHPParser_Node_Expr_PropertyFetch $node) {
    +        return $this->pVarOrNewExpr($node->var) . '->' . $this->pObjectProperty($node->name);
    +    }
    +
    +    public function pExpr_StaticPropertyFetch(PHPParser_Node_Expr_StaticPropertyFetch $node) {
    +        return $this->p($node->class) . '::$' . $this->pObjectProperty($node->name);
    +    }
    +
    +    public function pExpr_ShellExec(PHPParser_Node_Expr_ShellExec $node) {
    +        return '`' . $this->pEncapsList($node->parts, '`') . '`';
    +    }
    +
    +    public function pExpr_Closure(PHPParser_Node_Expr_Closure $node) {
    +        return ($node->static ? 'static ' : '')
    +             . 'function ' . ($node->byRef ? '&' : '')
    +             . '(' . $this->pCommaSeparated($node->params) . ')'
    +             . (!empty($node->uses) ? ' use(' . $this->pCommaSeparated($node->uses) . ')': '')
    +             . ' {' . "\n" . $this->pStmts($node->stmts) . "\n" . '}';
    +    }
    +
    +    public function pExpr_ClosureUse(PHPParser_Node_Expr_ClosureUse $node) {
    +        return ($node->byRef ? '&' : '') . '$' . $node->var;
    +    }
    +
    +    public function pExpr_New(PHPParser_Node_Expr_New $node) {
    +        return 'new ' . $this->p($node->class) . '(' . $this->pCommaSeparated($node->args) . ')';
    +    }
    +
    +    public function pExpr_Clone(PHPParser_Node_Expr_Clone $node) {
    +        return 'clone ' . $this->p($node->expr);
    +    }
    +
    +    public function pExpr_Ternary(PHPParser_Node_Expr_Ternary $node) {
    +        // a bit of cheating: we treat the ternary as a binary op where the ?...: part is the operator.
    +        // this is okay because the part between ? and : never needs parentheses.
    +        return $this->pInfixOp('Expr_Ternary',
    +            $node->cond, ' ?' . (null !== $node->if ? ' ' . $this->p($node->if) . ' ' : '') . ': ', $node->else
    +        );
    +    }
    +
    +    public function pExpr_Exit(PHPParser_Node_Expr_Exit $node) {
    +        return 'die' . (null !== $node->expr ? '(' . $this->p($node->expr) . ')' : '');
    +    }
    +
    +    public function pExpr_Yield(PHPParser_Node_Expr_Yield $node) {
    +        if ($node->value === null) {
    +            return 'yield';
    +        } else {
    +            // this is a bit ugly, but currently there is no way to detect whether the parentheses are necessary
    +            return '(yield '
    +                 . ($node->key !== null ? $this->p($node->key) . ' => ' : '')
    +                 . $this->p($node->value)
    +                 . ')';
    +        }
    +    }
    +
    +    // Declarations
    +
    +    public function pStmt_Namespace(PHPParser_Node_Stmt_Namespace $node) {
    +        if ($this->canUseSemicolonNamespaces) {
    +            return 'namespace ' . $this->p($node->name) . ';' . "\n\n" . $this->pStmts($node->stmts, false);
    +        } else {
    +            return 'namespace' . (null !== $node->name ? ' ' . $this->p($node->name) : '')
    +                 . ' {' . "\n" . $this->pStmts($node->stmts) . "\n" . '}';
    +        }
    +    }
    +
    +    public function pStmt_Use(PHPParser_Node_Stmt_Use $node) {
    +        return 'use ' . $this->pCommaSeparated($node->uses) . ';';
    +    }
    +
    +    public function pStmt_UseUse(PHPParser_Node_Stmt_UseUse $node) {
    +        return $this->p($node->name)
    +             . ($node->name->getLast() !== $node->alias ? ' as ' . $node->alias : '');
    +    }
    +
    +    public function pStmt_Interface(PHPParser_Node_Stmt_Interface $node) {
    +        return 'interface ' . $node->name
    +             . (!empty($node->extends) ? ' extends ' . $this->pCommaSeparated($node->extends) : '')
    +             . "\n" . '{' . "\n" . $this->pStmts($node->stmts) . "\n" . '}';
    +    }
    +
    +    public function pStmt_Class(PHPParser_Node_Stmt_Class $node) {
    +        return $this->pModifiers($node->type)
    +             . 'class ' . $node->name
    +             . (null !== $node->extends ? ' extends ' . $this->p($node->extends) : '')
    +             . (!empty($node->implements) ? ' implements ' . $this->pCommaSeparated($node->implements) : '')
    +             . "\n" . '{' . "\n" . $this->pStmts($node->stmts) . "\n" . '}';
    +    }
    +
    +    public function pStmt_Trait(PHPParser_Node_Stmt_Trait $node) {
    +        return 'trait ' . $node->name
    +             . "\n" . '{' . "\n" . $this->pStmts($node->stmts) . "\n" . '}';
    +    }
    +
    +    public function pStmt_TraitUse(PHPParser_Node_Stmt_TraitUse $node) {
    +        return 'use ' . $this->pCommaSeparated($node->traits)
    +             . (empty($node->adaptations)
    +                ? ';'
    +                : ' {' . "\n" . $this->pStmts($node->adaptations) . "\n" . '}');
    +    }
    +
    +    public function pStmt_TraitUseAdaptation_Precedence(PHPParser_Node_Stmt_TraitUseAdaptation_Precedence $node) {
    +        return $this->p($node->trait) . '::' . $node->method
    +             . ' insteadof ' . $this->pCommaSeparated($node->insteadof) . ';';
    +    }
    +
    +    public function pStmt_TraitUseAdaptation_Alias(PHPParser_Node_Stmt_TraitUseAdaptation_Alias $node) {
    +        return (null !== $node->trait ? $this->p($node->trait) . '::' : '')
    +             . $node->method . ' as'
    +             . (null !== $node->newModifier ? ' ' . $this->pModifiers($node->newModifier) : '')
    +             . (null !== $node->newName     ? ' ' . $node->newName                        : '')
    +             . ';';
    +    }
    +
    +    public function pStmt_Property(PHPParser_Node_Stmt_Property $node) {
    +        return $this->pModifiers($node->type) . $this->pCommaSeparated($node->props) . ';';
    +    }
    +
    +    public function pStmt_PropertyProperty(PHPParser_Node_Stmt_PropertyProperty $node) {
    +        return '$' . $node->name
    +             . (null !== $node->default ? ' = ' . $this->p($node->default) : '');
    +    }
    +
    +    public function pStmt_ClassMethod(PHPParser_Node_Stmt_ClassMethod $node) {
    +        return $this->pModifiers($node->type)
    +             . 'function ' . ($node->byRef ? '&' : '') . $node->name
    +             . '(' . $this->pCommaSeparated($node->params) . ')'
    +             . (null !== $node->stmts
    +                ? "\n" . '{' . "\n" . $this->pStmts($node->stmts) . "\n" . '}'
    +                : ';');
    +    }
    +
    +    public function pStmt_ClassConst(PHPParser_Node_Stmt_ClassConst $node) {
    +        return 'const ' . $this->pCommaSeparated($node->consts) . ';';
    +    }
    +
    +    public function pStmt_Function(PHPParser_Node_Stmt_Function $node) {
    +        return 'function ' . ($node->byRef ? '&' : '') . $node->name
    +             . '(' . $this->pCommaSeparated($node->params) . ')'
    +             . "\n" . '{' . "\n" . $this->pStmts($node->stmts) . "\n" . '}';
    +    }
    +
    +    public function pStmt_Const(PHPParser_Node_Stmt_Const $node) {
    +        return 'const ' . $this->pCommaSeparated($node->consts) . ';';
    +    }
    +
    +    public function pStmt_Declare(PHPParser_Node_Stmt_Declare $node) {
    +        return 'declare (' . $this->pCommaSeparated($node->declares) . ') {'
    +             . "\n" . $this->pStmts($node->stmts) . "\n" . '}';
    +    }
    +
    +    public function pStmt_DeclareDeclare(PHPParser_Node_Stmt_DeclareDeclare $node) {
    +        return $node->key . ' = ' . $this->p($node->value);
    +    }
    +
    +    // Control flow
    +
    +    public function pStmt_If(PHPParser_Node_Stmt_If $node) {
    +        return 'if (' . $this->p($node->cond) . ') {'
    +             . "\n" . $this->pStmts($node->stmts) . "\n" . '}'
    +             . $this->pImplode($node->elseifs)
    +             . (null !== $node->else ? $this->p($node->else) : '');
    +    }
    +
    +    public function pStmt_Elseif(PHPParser_Node_Stmt_Elseif $node) {
    +        return ' elseif (' . $this->p($node->cond) . ') {'
    +             . "\n" . $this->pStmts($node->stmts) . "\n" . '}';
    +    }
    +
    +    public function pStmt_Else(PHPParser_Node_Stmt_Else $node) {
    +        return ' else {' . "\n" . $this->pStmts($node->stmts) . "\n" . '}';
    +    }
    +
    +    public function pStmt_For(PHPParser_Node_Stmt_For $node) {
    +        return 'for ('
    +             . $this->pCommaSeparated($node->init) . ';' . (!empty($node->cond) ? ' ' : '')
    +             . $this->pCommaSeparated($node->cond) . ';' . (!empty($node->loop) ? ' ' : '')
    +             . $this->pCommaSeparated($node->loop)
    +             . ') {' . "\n" . $this->pStmts($node->stmts) . "\n" . '}';
    +    }
    +
    +    public function pStmt_Foreach(PHPParser_Node_Stmt_Foreach $node) {
    +        return 'foreach (' . $this->p($node->expr) . ' as '
    +             . (null !== $node->keyVar ? $this->p($node->keyVar) . ' => ' : '')
    +             . ($node->byRef ? '&' : '') . $this->p($node->valueVar) . ') {'
    +             . "\n" . $this->pStmts($node->stmts) . "\n" . '}';
    +    }
    +
    +    public function pStmt_While(PHPParser_Node_Stmt_While $node) {
    +        return 'while (' . $this->p($node->cond) . ') {'
    +             . "\n" . $this->pStmts($node->stmts) . "\n" . '}';
    +    }
    +
    +    public function pStmt_Do(PHPParser_Node_Stmt_Do $node) {
    +        return 'do {' . "\n" . $this->pStmts($node->stmts) . "\n"
    +             . '} while (' . $this->p($node->cond) . ');';
    +    }
    +
    +    public function pStmt_Switch(PHPParser_Node_Stmt_Switch $node) {
    +        return 'switch (' . $this->p($node->cond) . ') {'
    +             . "\n" . $this->pStmts($node->cases) . "\n" . '}';
    +    }
    +
    +    public function pStmt_Case(PHPParser_Node_Stmt_Case $node) {
    +        return (null !== $node->cond ? 'case ' . $this->p($node->cond) : 'default') . ':'
    +             . ($node->stmts ? "\n" . $this->pStmts($node->stmts) : '');
    +    }
    +
    +    public function pStmt_TryCatch(PHPParser_Node_Stmt_TryCatch $node) {
    +        return 'try {' . "\n" . $this->pStmts($node->stmts) . "\n" . '}'
    +             . $this->pImplode($node->catches)
    +             . ($node->finallyStmts !== null
    +                ? ' finally {' . "\n" . $this->pStmts($node->finallyStmts) . "\n" . '}'
    +                : '');
    +    }
    +
    +    public function pStmt_Catch(PHPParser_Node_Stmt_Catch $node) {
    +        return ' catch (' . $this->p($node->type) . ' $' . $node->var . ') {'
    +             . "\n" . $this->pStmts($node->stmts) . "\n" . '}';
    +    }
    +
    +    public function pStmt_Break(PHPParser_Node_Stmt_Break $node) {
    +        return 'break' . ($node->num !== null ? ' ' . $this->p($node->num) : '') . ';';
    +    }
    +
    +    public function pStmt_Continue(PHPParser_Node_Stmt_Continue $node) {
    +        return 'continue' . ($node->num !== null ? ' ' . $this->p($node->num) : '') . ';';
    +    }
    +
    +    public function pStmt_Return(PHPParser_Node_Stmt_Return $node) {
    +        return 'return' . (null !== $node->expr ? ' ' . $this->p($node->expr) : '') . ';';
    +    }
    +
    +    public function pStmt_Throw(PHPParser_Node_Stmt_Throw $node) {
    +        return 'throw ' . $this->p($node->expr) . ';';
    +    }
    +
    +    public function pStmt_Label(PHPParser_Node_Stmt_Label $node) {
    +        return $node->name . ':';
    +    }
    +
    +    public function pStmt_Goto(PHPParser_Node_Stmt_Goto $node) {
    +        return 'goto ' . $node->name . ';';
    +    }
    +
    +    // Other
    +
    +    public function pStmt_Echo(PHPParser_Node_Stmt_Echo $node) {
    +        return 'echo ' . $this->pCommaSeparated($node->exprs) . ';';
    +    }
    +
    +    public function pStmt_Static(PHPParser_Node_Stmt_Static $node) {
    +        return 'static ' . $this->pCommaSeparated($node->vars) . ';';
    +    }
    +
    +    public function pStmt_Global(PHPParser_Node_Stmt_Global $node) {
    +        return 'global ' . $this->pCommaSeparated($node->vars) . ';';
    +    }
    +
    +    public function pStmt_StaticVar(PHPParser_Node_Stmt_StaticVar $node) {
    +        return '$' . $node->name
    +             . (null !== $node->default ? ' = ' . $this->p($node->default) : '');
    +    }
    +
    +    public function pStmt_Unset(PHPParser_Node_Stmt_Unset $node) {
    +        return 'unset(' . $this->pCommaSeparated($node->vars) . ');';
    +    }
    +
    +    public function pStmt_InlineHTML(PHPParser_Node_Stmt_InlineHTML $node) {
    +        return '?>' . $this->pNoIndent("\n" . $node->value) . 'remaining;
    +    }
    +
    +    // Helpers
    +
    +    public function pObjectProperty($node) {
    +        if ($node instanceof PHPParser_Node_Expr) {
    +            return '{' . $this->p($node) . '}';
    +        } else {
    +            return $node;
    +        }
    +    }
    +
    +    public function pModifiers($modifiers) {
    +        return ($modifiers & PHPParser_Node_Stmt_Class::MODIFIER_PUBLIC    ? 'public '    : '')
    +             . ($modifiers & PHPParser_Node_Stmt_Class::MODIFIER_PROTECTED ? 'protected ' : '')
    +             . ($modifiers & PHPParser_Node_Stmt_Class::MODIFIER_PRIVATE   ? 'private '   : '')
    +             . ($modifiers & PHPParser_Node_Stmt_Class::MODIFIER_STATIC    ? 'static '    : '')
    +             . ($modifiers & PHPParser_Node_Stmt_Class::MODIFIER_ABSTRACT  ? 'abstract '  : '')
    +             . ($modifiers & PHPParser_Node_Stmt_Class::MODIFIER_FINAL     ? 'final '     : '');
    +    }
    +
    +    public function pEncapsList(array $encapsList, $quote) {
    +        $return = '';
    +        foreach ($encapsList as $element) {
    +            if (is_string($element)) {
    +                $return .= addcslashes($element, "\n\r\t\f\v$" . $quote . "\\");
    +            } else {
    +                $return .= '{' . $this->p($element) . '}';
    +            }
    +        }
    +
    +        return $return;
    +    }
    +
    +    public function pVarOrNewExpr(PHPParser_Node $node) {
    +        if ($node instanceof PHPParser_Node_Expr_New) {
    +            return '(' . $this->p($node) . ')';
    +        } else {
    +            return $this->p($node);
    +        }
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/PrettyPrinter/Zend.php b/vendor/nikic/php-parser/lib/PHPParser/PrettyPrinter/Zend.php
    new file mode 100755
    index 0000000..f9fd0c4
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/PrettyPrinter/Zend.php
    @@ -0,0 +1,10 @@
    + array( 1,  1),
    +        'Expr_PreInc'           => array( 1,  1),
    +        'Expr_PreDec'           => array( 1,  1),
    +        'Expr_PostInc'          => array( 1, -1),
    +        'Expr_PostDec'          => array( 1, -1),
    +        'Expr_UnaryPlus'        => array( 1,  1),
    +        'Expr_UnaryMinus'       => array( 1,  1),
    +        'Expr_Cast_Int'         => array( 1,  1),
    +        'Expr_Cast_Double'      => array( 1,  1),
    +        'Expr_Cast_String'      => array( 1,  1),
    +        'Expr_Cast_Array'       => array( 1,  1),
    +        'Expr_Cast_Object'      => array( 1,  1),
    +        'Expr_Cast_Bool'        => array( 1,  1),
    +        'Expr_Cast_Unset'       => array( 1,  1),
    +        'Expr_ErrorSuppress'    => array( 1,  1),
    +        'Expr_Instanceof'       => array( 2,  0),
    +        'Expr_BooleanNot'       => array( 3,  1),
    +        'Expr_Mul'              => array( 4, -1),
    +        'Expr_Div'              => array( 4, -1),
    +        'Expr_Mod'              => array( 4, -1),
    +        'Expr_Plus'             => array( 5, -1),
    +        'Expr_Minus'            => array( 5, -1),
    +        'Expr_Concat'           => array( 5, -1),
    +        'Expr_ShiftLeft'        => array( 6, -1),
    +        'Expr_ShiftRight'       => array( 6, -1),
    +        'Expr_Smaller'          => array( 7,  0),
    +        'Expr_SmallerOrEqual'   => array( 7,  0),
    +        'Expr_Greater'          => array( 7,  0),
    +        'Expr_GreaterOrEqual'   => array( 7,  0),
    +        'Expr_Equal'            => array( 8,  0),
    +        'Expr_NotEqual'         => array( 8,  0),
    +        'Expr_Identical'        => array( 8,  0),
    +        'Expr_NotIdentical'     => array( 8,  0),
    +        'Expr_BitwiseAnd'       => array( 9, -1),
    +        'Expr_BitwiseXor'       => array(10, -1),
    +        'Expr_BitwiseOr'        => array(11, -1),
    +        'Expr_BooleanAnd'       => array(12, -1),
    +        'Expr_BooleanOr'        => array(13, -1),
    +        'Expr_Ternary'          => array(14, -1),
    +        // parser uses %left for assignments, but they really behave as %right
    +        'Expr_Assign'           => array(15,  1),
    +        'Expr_AssignRef'        => array(15,  1),
    +        'Expr_AssignPlus'       => array(15,  1),
    +        'Expr_AssignMinus'      => array(15,  1),
    +        'Expr_AssignMul'        => array(15,  1),
    +        'Expr_AssignDiv'        => array(15,  1),
    +        'Expr_AssignConcat'     => array(15,  1),
    +        'Expr_AssignMod'        => array(15,  1),
    +        'Expr_AssignBitwiseAnd' => array(15,  1),
    +        'Expr_AssignBitwiseOr'  => array(15,  1),
    +        'Expr_AssignBitwiseXor' => array(15,  1),
    +        'Expr_AssignShiftLeft'  => array(15,  1),
    +        'Expr_AssignShiftRight' => array(15,  1),
    +        'Expr_LogicalAnd'       => array(16, -1),
    +        'Expr_LogicalXor'       => array(17, -1),
    +        'Expr_LogicalOr'        => array(18, -1),
    +        'Expr_Include'          => array(19, -1),
    +    );
    +
    +    protected $noIndentToken;
    +    protected $canUseSemicolonNamespaces;
    +
    +    public function __construct() {
    +        $this->noIndentToken = '_NO_INDENT_' . mt_rand();
    +    }
    +
    +    /**
    +     * Pretty prints an array of statements.
    +     *
    +     * @param PHPParser_Node[] $stmts Array of statements
    +     *
    +     * @return string Pretty printed statements
    +     */
    +    public function prettyPrint(array $stmts) {
    +        $this->preprocessNodes($stmts);
    +
    +        return str_replace("\n" . $this->noIndentToken, "\n", $this->pStmts($stmts, false));
    +    }
    +
    +    /**
    +     * Pretty prints an expression.
    +     *
    +     * @param PHPParser_Node_Expr $node Expression node
    +     *
    +     * @return string Pretty printed node
    +     */
    +    public function prettyPrintExpr(PHPParser_Node_Expr $node) {
    +        return str_replace("\n" . $this->noIndentToken, "\n", $this->p($node));
    +    }
    +
    +    /**
    +     * Pretty prints a file of statements (includes the opening prettyPrint($stmts));
    +
    +        $p = preg_replace('/^\?>\n?/', '', $p, -1, $count);
    +        $p = preg_replace('/<\?php$/', '', $p);
    +
    +        if (!$count) {
    +            $p = "canUseSemicolonNamespaces = true;
    +        foreach ($nodes as $node) {
    +            if ($node instanceof PHPParser_Node_Stmt_Namespace && null === $node->name) {
    +                $this->canUseSemicolonNamespaces = false;
    +            }
    +        }
    +    }
    +
    +    /**
    +     * Pretty prints an array of nodes (statements) and indents them optionally.
    +     *
    +     * @param PHPParser_Node[] $nodes  Array of nodes
    +     * @param bool             $indent Whether to indent the printed nodes
    +     *
    +     * @return string Pretty printed statements
    +     */
    +    protected function pStmts(array $nodes, $indent = true) {
    +        $pNodes = array();
    +        foreach ($nodes as $node) {
    +            $pNodes[] = $this->pComments($node->getAttribute('comments', array()))
    +                      . $this->p($node)
    +                      . ($node instanceof PHPParser_Node_Expr ? ';' : '');
    +        }
    +
    +        if ($indent) {
    +            return '    ' . preg_replace(
    +                '~\n(?!$|' . $this->noIndentToken . ')~',
    +                "\n" . '    ',
    +                implode("\n", $pNodes)
    +            );
    +        } else {
    +            return implode("\n", $pNodes);
    +        }
    +    }
    +
    +    /**
    +     * Pretty prints a node.
    +     *
    +     * @param PHPParser_Node $node Node to be pretty printed
    +     *
    +     * @return string Pretty printed node
    +     */
    +    protected function p(PHPParser_Node $node) {
    +        return $this->{'p' . $node->getType()}($node);
    +    }
    +
    +    protected function pInfixOp($type, PHPParser_Node $leftNode, $operatorString, PHPParser_Node $rightNode) {
    +        list($precedence, $associativity) = $this->precedenceMap[$type];
    +
    +        return $this->pPrec($leftNode, $precedence, $associativity, -1)
    +             . $operatorString
    +             . $this->pPrec($rightNode, $precedence, $associativity, 1);
    +    }
    +
    +    protected function pPrefixOp($type, $operatorString, PHPParser_Node $node) {
    +        list($precedence, $associativity) = $this->precedenceMap[$type];
    +        return $operatorString . $this->pPrec($node, $precedence, $associativity, 1);
    +    }
    +
    +    protected function pPostfixOp($type, PHPParser_Node $node, $operatorString) {
    +        list($precedence, $associativity) = $this->precedenceMap[$type];
    +        return $this->pPrec($node, $precedence, $associativity, -1) . $operatorString;
    +    }
    +
    +    /**
    +     * Prints an expression node with the least amount of parentheses necessary to preserve the meaning.
    +     *
    +     * @param PHPParser_Node $node                Node to pretty print
    +     * @param int            $parentPrecedence    Precedence of the parent operator
    +     * @param int            $parentAssociativity Associativity of parent operator
    +     *                                            (-1 is left, 0 is nonassoc, 1 is right)
    +     * @param int            $childPosition       Position of the node relative to the operator
    +     *                                            (-1 is left, 1 is right)
    +     *
    +     * @return string The pretty printed node
    +     */
    +    protected function pPrec(PHPParser_Node $node, $parentPrecedence, $parentAssociativity, $childPosition) {
    +        $type = $node->getType();
    +        if (isset($this->precedenceMap[$type])) {
    +            $childPrecedence = $this->precedenceMap[$type][0];
    +            if ($childPrecedence > $parentPrecedence
    +                || ($parentPrecedence == $childPrecedence && $parentAssociativity != $childPosition)
    +            ) {
    +                return '(' . $this->{'p' . $type}($node) . ')';
    +            }
    +        }
    +
    +        return $this->{'p' . $type}($node);
    +    }
    +
    +    /**
    +     * Pretty prints an array of nodes and implodes the printed values.
    +     *
    +     * @param PHPParser_Node[] $nodes Array of Nodes to be printed
    +     * @param string           $glue  Character to implode with
    +     *
    +     * @return string Imploded pretty printed nodes
    +     */
    +    protected function pImplode(array $nodes, $glue = '') {
    +        $pNodes = array();
    +        foreach ($nodes as $node) {
    +            $pNodes[] = $this->p($node);
    +        }
    +
    +        return implode($glue, $pNodes);
    +    }
    +
    +    /**
    +     * Pretty prints an array of nodes and implodes the printed values with commas.
    +     *
    +     * @param PHPParser_Node[] $nodes Array of Nodes to be printed
    +     *
    +     * @return string Comma separated pretty printed nodes
    +     */
    +    protected function pCommaSeparated(array $nodes) {
    +        return $this->pImplode($nodes, ', ');
    +    }
    +
    +    /**
    +     * Signals the pretty printer that a string shall not be indented.
    +     *
    +     * @param string $string Not to be indented string
    +     *
    +     * @return mixed String marked with $this->noIndentToken's.
    +     */
    +    protected function pNoIndent($string) {
    +        return str_replace("\n", "\n" . $this->noIndentToken, $string);
    +    }
    +
    +    protected function pComments(array $comments) {
    +        $result = '';
    +
    +        foreach ($comments as $comment) {
    +            $result .= $comment->getReformattedText() . "\n";
    +        }
    +
    +        return $result;
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/Serializer.php b/vendor/nikic/php-parser/lib/PHPParser/Serializer.php
    new file mode 100755
    index 0000000..e63decc
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/Serializer.php
    @@ -0,0 +1,13 @@
    +writer = new XMLWriter;
    +        $this->writer->openMemory();
    +        $this->writer->setIndent(true);
    +    }
    +
    +    public function serialize(array $nodes) {
    +        $this->writer->flush();
    +        $this->writer->startDocument('1.0', 'UTF-8');
    +
    +        $this->writer->startElement('AST');
    +        $this->writer->writeAttribute('xmlns:node',      'http://nikic.github.com/PHPParser/XML/node');
    +        $this->writer->writeAttribute('xmlns:subNode',   'http://nikic.github.com/PHPParser/XML/subNode');
    +        $this->writer->writeAttribute('xmlns:attribute', 'http://nikic.github.com/PHPParser/XML/attribute');
    +        $this->writer->writeAttribute('xmlns:scalar',    'http://nikic.github.com/PHPParser/XML/scalar');
    +
    +        $this->_serialize($nodes);
    +
    +        $this->writer->endElement();
    +
    +        return $this->writer->outputMemory();
    +    }
    +
    +    protected function _serialize($node) {
    +        if ($node instanceof PHPParser_Node) {
    +            $this->writer->startElement('node:' . $node->getType());
    +
    +            foreach ($node->getAttributes() as $name => $value) {
    +                $this->writer->startElement('attribute:' . $name);
    +                $this->_serialize($value);
    +                $this->writer->endElement();
    +            }
    +
    +            foreach ($node as $name => $subNode) {
    +                $this->writer->startElement('subNode:' . $name);
    +                $this->_serialize($subNode);
    +                $this->writer->endElement();
    +            }
    +
    +            $this->writer->endElement();
    +        } elseif ($node instanceof PHPParser_Comment) {
    +            $this->writer->startElement('comment');
    +            $this->writer->writeAttribute('isDocComment', $node instanceof PHPParser_Comment_Doc ? 'true' : 'false');
    +            $this->writer->writeAttribute('line', $node->getLine());
    +            $this->writer->text($node->getText());
    +            $this->writer->endElement();
    +        } elseif (is_array($node)) {
    +            $this->writer->startElement('scalar:array');
    +            foreach ($node as $subNode) {
    +                $this->_serialize($subNode);
    +            }
    +            $this->writer->endElement();
    +        } elseif (is_string($node)) {
    +            $this->writer->writeElement('scalar:string', $node);
    +        } elseif (is_int($node)) {
    +            $this->writer->writeElement('scalar:int', $node);
    +        } elseif (is_float($node)) {
    +            $this->writer->writeElement('scalar:float', $node);
    +        } elseif (true === $node) {
    +            $this->writer->writeElement('scalar:true');
    +        } elseif (false === $node) {
    +            $this->writer->writeElement('scalar:false');
    +        } elseif (null === $node) {
    +            $this->writer->writeElement('scalar:null');
    +        } else {
    +            throw new InvalidArgumentException('Unexpected node type');
    +        }
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/Template.php b/vendor/nikic/php-parser/lib/PHPParser/Template.php
    new file mode 100755
    index 0000000..506b0d5
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/Template.php
    @@ -0,0 +1,72 @@
    +parser   = $parser;
    +        $this->template = $template;
    +    }
    +
    +    /**
    +     * Get the statements of the template with the passed in placeholders
    +     * replaced.
    +     *
    +     * @param array $placeholders Placeholders
    +     *
    +     * @return PHPParser_Node[] Statements
    +     */
    +    public function getStmts(array $placeholders) {
    +        return $this->parser->parse(
    +            $this->getTemplateWithPlaceholdersReplaced($placeholders)
    +        );
    +    }
    +
    +    protected function getTemplateWithPlaceholdersReplaced(array $placeholders) {
    +        if (empty($placeholders)) {
    +            return $this->template;
    +        }
    +
    +        return strtr($this->template, $this->preparePlaceholders($placeholders));
    +    }
    +
    +    /*
    +     * Prepare the placeholders for replacement. This means that
    +     * a) all placeholders will be surrounded with __.
    +     * b) ucfirst/lcfirst variations of the placeholders are generated.
    +     *
    +     * E.g. for an input array of ['foo' => 'bar'] the result will be
    +     * ['__foo__' => 'bar', '__Foo__' => 'Bar'].
    +     */
    +    protected function preparePlaceholders(array $placeholders) {
    +        $preparedPlaceholders = array();
    +
    +        foreach ($placeholders as $name => $value) {
    +            $preparedPlaceholders['__' . $name . '__'] = $value;
    +
    +            if (ctype_lower($name[0])) {
    +                $ucfirstName = ucfirst($name);
    +                if (!isset($placeholders[$ucfirstName])) {
    +                    $preparedPlaceholders['__' . $ucfirstName . '__'] = ucfirst($value);
    +                }
    +            }
    +
    +            if (ctype_upper($name[0])) {
    +                $lcfirstName = lcfirst($name);
    +                if (!isset($placeholders[$lcfirstName])) {
    +                    $preparedPlaceholders['__' . $lcfirstName . '__'] = lcfirst($value);
    +                }
    +            }
    +        }
    +
    +        return $preparedPlaceholders;
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/TemplateLoader.php b/vendor/nikic/php-parser/lib/PHPParser/TemplateLoader.php
    new file mode 100755
    index 0000000..dc9d26d
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/TemplateLoader.php
    @@ -0,0 +1,48 @@
    +parser  = $parser;
    +        $this->baseDir = $baseDir;
    +        $this->suffix  = $suffix;
    +    }
    +
    +    /**
    +     * Loads the template with the specified name.
    +     *
    +     * @param string $name The name of template
    +     *
    +     * @return PHPParser_Template The loaded template
    +     */
    +    public function load($name) {
    +        $file = $this->baseDir . '/' . $name . $this->suffix;
    +
    +        if (!is_file($file)) {
    +            throw new InvalidArgumentException(
    +                sprintf('The file "%s" does not exist', $file)
    +            );
    +        }
    +
    +        return new PHPParser_Template($this->parser, file_get_contents($file));
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/lib/PHPParser/Unserializer.php b/vendor/nikic/php-parser/lib/PHPParser/Unserializer.php
    new file mode 100755
    index 0000000..34808c8
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/PHPParser/Unserializer.php
    @@ -0,0 +1,13 @@
    +reader = new XMLReader;
    +    }
    +
    +    public function unserialize($string) {
    +        $this->reader->XML($string);
    +
    +        $this->reader->read();
    +        if ('AST' !== $this->reader->name) {
    +            throw new DomainException('AST root element not found');
    +        }
    +
    +        return $this->read($this->reader->depth);
    +    }
    +
    +    protected function read($depthLimit, $throw = true, &$nodeFound = null) {
    +        $nodeFound = true;
    +        while ($this->reader->read() && $depthLimit < $this->reader->depth) {
    +            if (XMLReader::ELEMENT !== $this->reader->nodeType) {
    +                continue;
    +            }
    +
    +            if ('node' === $this->reader->prefix) {
    +                return $this->readNode();
    +            } elseif ('scalar' === $this->reader->prefix) {
    +                return $this->readScalar();
    +            } elseif ('comment' === $this->reader->name) {
    +                return $this->readComment();
    +            } else {
    +                throw new DomainException(sprintf('Unexpected node of type "%s"', $this->reader->name));
    +            }
    +        }
    +
    +        $nodeFound = false;
    +        if ($throw) {
    +            throw new DomainException('Expected node or scalar');
    +        }
    +    }
    +
    +    protected function readNode()
    +    {
    +        $className = 'PHPParser_Node_' . $this->reader->localName;
    +
    +        // create the node without calling it's constructor
    +        $node = unserialize(
    +            sprintf(
    +                "O:%d:\"%s\":2:{s:11:\"\0*\0subNodes\";a:0:{}s:13:\"\0*\0attributes\";a:0:{}}",
    +                strlen($className), $className
    +            )
    +        );
    +
    +        $depthLimit = $this->reader->depth;
    +        while ($this->reader->read() && $depthLimit < $this->reader->depth) {
    +            if (XMLReader::ELEMENT !== $this->reader->nodeType) {
    +                continue;
    +            }
    +
    +            $type = $this->reader->prefix;
    +            if ('subNode' !== $type && 'attribute' !== $type) {
    +                throw new DomainException(
    +                    sprintf('Expected sub node or attribute, got node of type "%s"', $this->reader->name)
    +                );
    +            }
    +
    +            $name = $this->reader->localName;
    +            $value = $this->read($this->reader->depth);
    +
    +            if ('subNode' === $type) {
    +                $node->$name = $value;
    +            } else {
    +                $node->setAttribute($name, $value);
    +            }
    +        }
    +
    +        return $node;
    +    }
    +
    +    protected function readScalar() {
    +        switch ($name = $this->reader->localName) {
    +            case 'array':
    +                $depth = $this->reader->depth;
    +                $array = array();
    +                while (true) {
    +                    $node = $this->read($depth, false, $nodeFound);
    +                    if (!$nodeFound) {
    +                        break;
    +                    }
    +                    $array[] = $node;
    +                }
    +                return $array;
    +            case 'string':
    +                return $this->reader->readString();
    +            case 'int':
    +                $text = $this->reader->readString();
    +                if (false === $int = filter_var($text, FILTER_VALIDATE_INT)) {
    +                    throw new DomainException(sprintf('"%s" is not a valid integer', $text));
    +                }
    +                return $int;
    +            case 'float':
    +                $text = $this->reader->readString();
    +                if (false === $float = filter_var($text, FILTER_VALIDATE_FLOAT)) {
    +                    throw new DomainException(sprintf('"%s" is not a valid float', $text));
    +                }
    +                return $float;
    +            case 'true':
    +            case 'false':
    +            case 'null':
    +                if (!$this->reader->isEmptyElement) {
    +                    throw new DomainException(sprintf('"%s" scalar must be empty', $name));
    +                }
    +                return constant($name);
    +            default:
    +                throw new DomainException(sprintf('Unknown scalar type "%s"', $name));
    +        }
    +    }
    +
    +    protected function readComment() {
    +        $className = $this->reader->getAttribute('isDocComment') === 'true'
    +            ? 'PHPParser_Comment_Doc'
    +            : 'PHPParser_Comment'
    +        ;
    +        return new $className(
    +            $this->reader->readString(),
    +            $this->reader->getAttribute('line')
    +        );
    +    }
    +}
    diff --git a/vendor/nikic/php-parser/lib/bootstrap.php b/vendor/nikic/php-parser/lib/bootstrap.php
    new file mode 100755
    index 0000000..5b812b4
    --- /dev/null
    +++ b/vendor/nikic/php-parser/lib/bootstrap.php
    @@ -0,0 +1,14 @@
    +
    +
    +
    +    
    +        
    +            ./test/
    +        
    +    
    +
    +    
    +        
    +            ./lib/PHPParser/
    +        
    +    
    +
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/test/PHPParser/Tests/Builder/ClassTest.php b/vendor/nikic/php-parser/test/PHPParser/Tests/Builder/ClassTest.php
    new file mode 100755
    index 0000000..6591ca7
    --- /dev/null
    +++ b/vendor/nikic/php-parser/test/PHPParser/Tests/Builder/ClassTest.php
    @@ -0,0 +1,91 @@
    +createClassBuilder('SomeLogger')
    +            ->extend('BaseLogger')
    +            ->implement('Namespaced\Logger', new PHPParser_Node_Name('SomeInterface'))
    +            ->getNode()
    +        ;
    +
    +        $this->assertEquals(
    +            new PHPParser_Node_Stmt_Class('SomeLogger', array(
    +                'extends' => new PHPParser_Node_Name('BaseLogger'),
    +                'implements' => array(
    +                    new PHPParser_Node_Name('Namespaced\Logger'),
    +                    new PHPParser_Node_Name('SomeInterface')
    +                ),
    +            )),
    +            $node
    +        );
    +    }
    +
    +    public function testAbstract() {
    +        $node = $this->createClassBuilder('Test')
    +            ->makeAbstract()
    +            ->getNode()
    +        ;
    +
    +        $this->assertEquals(
    +            new PHPParser_Node_Stmt_Class('Test', array(
    +                'type' => PHPParser_Node_Stmt_Class::MODIFIER_ABSTRACT
    +            )),
    +            $node
    +        );
    +    }
    +
    +    public function testFinal() {
    +        $node = $this->createClassBuilder('Test')
    +            ->makeFinal()
    +            ->getNode()
    +        ;
    +
    +        $this->assertEquals(
    +            new PHPParser_Node_Stmt_Class('Test', array(
    +                'type' => PHPParser_Node_Stmt_Class::MODIFIER_FINAL
    +            )),
    +            $node
    +        );
    +    }
    +
    +    public function testStatementOrder() {
    +        $method = new PHPParser_Node_Stmt_ClassMethod('testMethod');
    +        $property = new PHPParser_Node_Stmt_Property(
    +            PHPParser_Node_Stmt_Class::MODIFIER_PUBLIC,
    +            array(new PHPParser_Node_Stmt_PropertyProperty('testProperty'))
    +        );
    +        $const = new PHPParser_Node_Stmt_ClassConst(array(
    +            new PHPParser_Node_Const('TEST_CONST', new PHPParser_Node_Scalar_String('ABC'))
    +        ));
    +        $use = new PHPParser_Node_Stmt_TraitUse(array(new PHPParser_Node_Name('SomeTrait')));
    +
    +        $node = $this->createClassBuilder('Test')
    +            ->addStmt($method)
    +            ->addStmt($property)
    +            ->addStmts(array($const, $use))
    +            ->getNode()
    +        ;
    +
    +        $this->assertEquals(
    +            new PHPParser_Node_Stmt_Class('Test', array(
    +                'stmts' => array($use, $const, $property, $method)
    +            )),
    +            $node
    +        );
    +    }
    +
    +    /**
    +     * @expectedException LogicException
    +     * @expectedExceptionMessage Unexpected node of type "Stmt_Echo"
    +     */
    +    public function testInvalidStmtError() {
    +        $this->createClassBuilder('Test')
    +            ->addStmt(new PHPParser_Node_Stmt_Echo(array()))
    +        ;
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/test/PHPParser/Tests/Builder/FunctionTest.php b/vendor/nikic/php-parser/test/PHPParser/Tests/Builder/FunctionTest.php
    new file mode 100755
    index 0000000..2992f82
    --- /dev/null
    +++ b/vendor/nikic/php-parser/test/PHPParser/Tests/Builder/FunctionTest.php
    @@ -0,0 +1,70 @@
    +createFunctionBuilder('test')
    +            ->makeReturnByRef()
    +            ->getNode()
    +        ;
    +
    +        $this->assertEquals(
    +            new PHPParser_Node_Stmt_Function('test', array(
    +                'byRef' => true
    +            )),
    +            $node
    +        );
    +    }
    +
    +    public function testParams() {
    +        $param1 = new PHPParser_Node_Param('test1');
    +        $param2 = new PHPParser_Node_Param('test2');
    +        $param3 = new PHPParser_Node_Param('test3');
    +
    +        $node = $this->createFunctionBuilder('test')
    +            ->addParam($param1)
    +            ->addParams(array($param2, $param3))
    +            ->getNode()
    +        ;
    +
    +        $this->assertEquals(
    +            new PHPParser_Node_Stmt_Function('test', array(
    +                'params' => array($param1, $param2, $param3)
    +            )),
    +            $node
    +        );
    +    }
    +
    +    public function testStmts() {
    +        $stmt1 = new PHPParser_Node_Expr_Print(new PHPParser_Node_Scalar_String('test1'));
    +        $stmt2 = new PHPParser_Node_Expr_Print(new PHPParser_Node_Scalar_String('test2'));
    +        $stmt3 = new PHPParser_Node_Expr_Print(new PHPParser_Node_Scalar_String('test3'));
    +
    +        $node = $this->createFunctionBuilder('test')
    +            ->addStmt($stmt1)
    +            ->addStmts(array($stmt2, $stmt3))
    +            ->getNode()
    +        ;
    +
    +        $this->assertEquals(
    +            new PHPParser_Node_Stmt_Function('test', array(
    +                'stmts' => array($stmt1, $stmt2, $stmt3)
    +            )),
    +            $node
    +        );
    +    }
    +
    +    /**
    +     * @expectedException LogicException
    +     * @expectedExceptionMessage Expected parameter node, got "Name"
    +     */
    +    public function testInvalidParamError() {
    +        $this->createFunctionBuilder('test')
    +            ->addParam(new PHPParser_Node_Name('foo'))
    +        ;
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/test/PHPParser/Tests/Builder/InterfaceTest.php b/vendor/nikic/php-parser/test/PHPParser/Tests/Builder/InterfaceTest.php
    new file mode 100755
    index 0000000..fb36338
    --- /dev/null
    +++ b/vendor/nikic/php-parser/test/PHPParser/Tests/Builder/InterfaceTest.php
    @@ -0,0 +1,91 @@
    +builder = new PHPParser_Builder_Interface('Contract');
    +    }
    +
    +    private function dump($node) {
    +        $pp = new PHPParser_PrettyPrinter_Default();
    +        return $pp->prettyPrint(array($node));
    +    }
    +
    +    public function testEmpty() {
    +        $contract = $this->builder->getNode();
    +        $this->assertInstanceOf('PHPParser_Node_Stmt_Interface', $contract);
    +        $this->assertEquals('Contract', $contract->name);
    +    }
    +
    +    public function testExtending() {
    +        $contract = $this->builder->extend('Space\Root1', 'Root2')->getNode();
    +        $this->assertEquals(
    +            new PHPParser_Node_Stmt_Interface('Contract', array(
    +                'extends' => array(
    +                    new PHPParser_Node_Name('Space\Root1'),
    +                    new PHPParser_Node_Name('Root2')
    +                ),
    +            )), $contract
    +        );
    +    }
    +
    +    public function testAddMethod() {
    +        $method = new PHPParser_Node_Stmt_ClassMethod('doSomething');
    +        $contract = $this->builder->addStmt($method)->getNode();
    +        $this->assertEquals(array($method), $contract->stmts);
    +    }
    +
    +    public function testAddConst() {
    +        $const = new PHPParser_Node_Stmt_ClassConst(array(
    +            new PHPParser_Node_Const('SPEED_OF_LIGHT', new PHPParser_Node_Scalar_DNumber(299792458))
    +        ));
    +        $contract = $this->builder->addStmt($const)->getNode();
    +        $this->assertEquals(299792458, $contract->stmts[0]->consts[0]->value->value);
    +    }
    +
    +    public function testOrder() {
    +        $const = new PHPParser_Node_Stmt_ClassConst(array(
    +            new PHPParser_Node_Const('SPEED_OF_LIGHT', new PHPParser_Node_Scalar_DNumber(299792458))
    +        ));
    +        $method = new PHPParser_Node_Stmt_ClassMethod('doSomething');
    +        $contract = $this->builder
    +            ->addStmt($method)
    +            ->addStmt($const)
    +            ->getNode()
    +        ;
    +
    +        $this->assertInstanceOf('PHPParser_Node_Stmt_ClassConst', $contract->stmts[0]);
    +        $this->assertInstanceOf('PHPParser_Node_Stmt_ClassMethod', $contract->stmts[1]);
    +    }
    +
    +    /**
    +     * @expectedException LogicException
    +     * @expectedExceptionMessage Unexpected node of type "Stmt_PropertyProperty"
    +     */
    +    public function testInvalidStmtError() {
    +        $this->builder->addStmt(new PHPParser_Node_Stmt_PropertyProperty('invalid'));
    +    }
    +
    +    public function testFullFunctional() {
    +        $const = new PHPParser_Node_Stmt_ClassConst(array(
    +            new PHPParser_Node_Const('SPEED_OF_LIGHT', new PHPParser_Node_Scalar_DNumber(299792458))
    +        ));
    +        $method = new PHPParser_Node_Stmt_ClassMethod('doSomething');
    +        $contract = $this->builder
    +            ->addStmt($method)
    +            ->addStmt($const)
    +            ->getNode()
    +        ;
    +
    +        eval($this->dump($contract));
    +
    +        $this->assertTrue(interface_exists('Contract', false));
    +    }
    +}
    +
    diff --git a/vendor/nikic/php-parser/test/PHPParser/Tests/Builder/MethodTest.php b/vendor/nikic/php-parser/test/PHPParser/Tests/Builder/MethodTest.php
    new file mode 100755
    index 0000000..6f4624a
    --- /dev/null
    +++ b/vendor/nikic/php-parser/test/PHPParser/Tests/Builder/MethodTest.php
    @@ -0,0 +1,137 @@
    +createMethodBuilder('test')
    +            ->makePublic()
    +            ->makeAbstract()
    +            ->makeStatic()
    +            ->getNode()
    +        ;
    +
    +        $this->assertEquals(
    +            new PHPParser_Node_Stmt_ClassMethod('test', array(
    +                'type' => PHPParser_Node_Stmt_Class::MODIFIER_PUBLIC
    +                        | PHPParser_Node_Stmt_Class::MODIFIER_ABSTRACT
    +                        | PHPParser_Node_Stmt_Class::MODIFIER_STATIC,
    +                'stmts' => null,
    +            )),
    +            $node
    +        );
    +
    +        $node = $this->createMethodBuilder('test')
    +            ->makeProtected()
    +            ->makeFinal()
    +            ->getNode()
    +        ;
    +
    +        $this->assertEquals(
    +            new PHPParser_Node_Stmt_ClassMethod('test', array(
    +                'type' => PHPParser_Node_Stmt_Class::MODIFIER_PROTECTED
    +                        | PHPParser_Node_Stmt_Class::MODIFIER_FINAL
    +            )),
    +            $node
    +        );
    +
    +        $node = $this->createMethodBuilder('test')
    +            ->makePrivate()
    +            ->getNode()
    +        ;
    +
    +        $this->assertEquals(
    +            new PHPParser_Node_Stmt_ClassMethod('test', array(
    +                'type' => PHPParser_Node_Stmt_Class::MODIFIER_PRIVATE
    +            )),
    +            $node
    +        );
    +    }
    +
    +    public function testReturnByRef() {
    +        $node = $this->createMethodBuilder('test')
    +            ->makeReturnByRef()
    +            ->getNode()
    +        ;
    +
    +        $this->assertEquals(
    +            new PHPParser_Node_Stmt_ClassMethod('test', array(
    +                'byRef' => true
    +            )),
    +            $node
    +        );
    +    }
    +
    +    public function testParams() {
    +        $param1 = new PHPParser_Node_Param('test1');
    +        $param2 = new PHPParser_Node_Param('test2');
    +        $param3 = new PHPParser_Node_Param('test3');
    +
    +        $node = $this->createMethodBuilder('test')
    +            ->addParam($param1)
    +            ->addParams(array($param2, $param3))
    +            ->getNode()
    +        ;
    +
    +        $this->assertEquals(
    +            new PHPParser_Node_Stmt_ClassMethod('test', array(
    +                'params' => array($param1, $param2, $param3)
    +            )),
    +            $node
    +        );
    +    }
    +
    +    public function testStmts() {
    +        $stmt1 = new PHPParser_Node_Expr_Print(new PHPParser_Node_Scalar_String('test1'));
    +        $stmt2 = new PHPParser_Node_Expr_Print(new PHPParser_Node_Scalar_String('test2'));
    +        $stmt3 = new PHPParser_Node_Expr_Print(new PHPParser_Node_Scalar_String('test3'));
    +
    +        $node = $this->createMethodBuilder('test')
    +            ->addStmt($stmt1)
    +            ->addStmts(array($stmt2, $stmt3))
    +            ->getNode()
    +        ;
    +
    +        $this->assertEquals(
    +            new PHPParser_Node_Stmt_ClassMethod('test', array(
    +                'stmts' => array($stmt1, $stmt2, $stmt3)
    +            )),
    +            $node
    +        );
    +    }
    +
    +    /**
    +     * @expectedException LogicException
    +     * @expectedExceptionMessage Cannot add statements to an abstract method
    +     */
    +    public function testAddStmtToAbstractMethodError() {
    +        $this->createMethodBuilder('test')
    +            ->makeAbstract()
    +            ->addStmt(new PHPParser_Node_Expr_Print(new PHPParser_Node_Scalar_String('test')))
    +        ;
    +    }
    +
    +    /**
    +     * @expectedException LogicException
    +     * @expectedExceptionMessage Cannot make method with statements abstract
    +     */
    +    public function testMakeMethodWithStmtsAbstractError() {
    +        $this->createMethodBuilder('test')
    +            ->addStmt(new PHPParser_Node_Expr_Print(new PHPParser_Node_Scalar_String('test')))
    +            ->makeAbstract()
    +        ;
    +    }
    +
    +    /**
    +     * @expectedException LogicException
    +     * @expectedExceptionMessage Expected parameter node, got "Name"
    +     */
    +    public function testInvalidParamError() {
    +        $this->createMethodBuilder('test')
    +            ->addParam(new PHPParser_Node_Name('foo'))
    +        ;
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/test/PHPParser/Tests/Builder/ParamTest.php b/vendor/nikic/php-parser/test/PHPParser/Tests/Builder/ParamTest.php
    new file mode 100755
    index 0000000..4010ea8
    --- /dev/null
    +++ b/vendor/nikic/php-parser/test/PHPParser/Tests/Builder/ParamTest.php
    @@ -0,0 +1,118 @@
    +createParamBuilder('test')
    +            ->setDefault($value)
    +            ->getNode()
    +        ;
    +
    +        $this->assertEquals($expectedValueNode, $node->default);
    +    }
    +
    +    public function provideTestDefaultValues() {
    +        return array(
    +            array(
    +                null,
    +                new PHPParser_Node_Expr_ConstFetch(new PHPParser_Node_Name('null'))
    +            ),
    +            array(
    +                true,
    +                new PHPParser_Node_Expr_ConstFetch(new PHPParser_Node_Name('true'))
    +            ),
    +            array(
    +                false,
    +                new PHPParser_Node_Expr_ConstFetch(new PHPParser_Node_Name('false'))
    +            ),
    +            array(
    +                31415,
    +                new PHPParser_Node_Scalar_LNumber(31415)
    +            ),
    +            array(
    +                3.1415,
    +                new PHPParser_Node_Scalar_DNumber(3.1415)
    +            ),
    +            array(
    +                'Hallo World',
    +                new PHPParser_Node_Scalar_String('Hallo World')
    +            ),
    +            array(
    +                array(1, 2, 3),
    +                new PHPParser_Node_Expr_Array(array(
    +                    new PHPParser_Node_Expr_ArrayItem(new PHPParser_Node_Scalar_LNumber(1)),
    +                    new PHPParser_Node_Expr_ArrayItem(new PHPParser_Node_Scalar_LNumber(2)),
    +                    new PHPParser_Node_Expr_ArrayItem(new PHPParser_Node_Scalar_LNumber(3)),
    +                ))
    +            ),
    +            array(
    +                array('foo' => 'bar', 'bar' => 'foo'),
    +                new PHPParser_Node_Expr_Array(array(
    +                    new PHPParser_Node_Expr_ArrayItem(
    +                        new PHPParser_Node_Scalar_String('bar'),
    +                        new PHPParser_Node_Scalar_String('foo')
    +                    ),
    +                    new PHPParser_Node_Expr_ArrayItem(
    +                        new PHPParser_Node_Scalar_String('foo'),
    +                        new PHPParser_Node_Scalar_String('bar')
    +                    ),
    +                ))
    +            ),
    +            array(
    +                new PHPParser_Node_Scalar_DirConst,
    +                new PHPParser_Node_Scalar_DirConst
    +            )
    +        );
    +    }
    +
    +    public function testTypeHints() {
    +        $node = $this->createParamBuilder('test')
    +            ->setTypeHint('array')
    +            ->getNode()
    +        ;
    +
    +        $this->assertEquals(
    +            new PHPParser_Node_Param('test', null, 'array'),
    +            $node
    +        );
    +
    +        $node = $this->createParamBuilder('test')
    +            ->setTypeHint('callable')
    +            ->getNode()
    +        ;
    +
    +        $this->assertEquals(
    +            new PHPParser_Node_Param('test', null, 'callable'),
    +            $node
    +        );
    +
    +        $node = $this->createParamBuilder('test')
    +            ->setTypeHint('Some\Class')
    +            ->getNode()
    +        ;
    +
    +        $this->assertEquals(
    +            new PHPParser_Node_Param('test', null, new PHPParser_Node_Name('Some\Class')),
    +            $node
    +        );
    +    }
    +
    +    public function testByRef() {
    +        $node = $this->createParamBuilder('test')
    +            ->makeByRef()
    +            ->getNode()
    +        ;
    +
    +        $this->assertEquals(
    +            new PHPParser_Node_Param('test', null, null, true),
    +            $node
    +        );
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/test/PHPParser/Tests/Builder/PropertyTest.php b/vendor/nikic/php-parser/test/PHPParser/Tests/Builder/PropertyTest.php
    new file mode 100755
    index 0000000..fa880b2
    --- /dev/null
    +++ b/vendor/nikic/php-parser/test/PHPParser/Tests/Builder/PropertyTest.php
    @@ -0,0 +1,123 @@
    +createPropertyBuilder('test')
    +            ->makePrivate()
    +            ->makeStatic()
    +            ->getNode()
    +        ;
    +
    +        $this->assertEquals(
    +            new PHPParser_Node_Stmt_Property(
    +                PHPParser_Node_Stmt_Class::MODIFIER_PRIVATE
    +              | PHPParser_Node_Stmt_Class::MODIFIER_STATIC,
    +                array(
    +                    new PHPParser_Node_Stmt_PropertyProperty('test')
    +                )
    +            ),
    +            $node
    +        );
    +
    +        $node = $this->createPropertyBuilder('test')
    +            ->makeProtected()
    +            ->getNode()
    +        ;
    +
    +        $this->assertEquals(
    +            new PHPParser_Node_Stmt_Property(
    +                PHPParser_Node_Stmt_Class::MODIFIER_PROTECTED,
    +                array(
    +                    new PHPParser_Node_Stmt_PropertyProperty('test')
    +                )
    +            ),
    +            $node
    +        );
    +
    +        $node = $this->createPropertyBuilder('test')
    +            ->makePublic()
    +            ->getNode()
    +        ;
    +
    +        $this->assertEquals(
    +            new PHPParser_Node_Stmt_Property(
    +                PHPParser_Node_Stmt_Class::MODIFIER_PUBLIC,
    +                array(
    +                    new PHPParser_Node_Stmt_PropertyProperty('test')
    +                )
    +            ),
    +            $node
    +        );
    +    }
    +
    +    /**
    +     * @dataProvider provideTestDefaultValues
    +     */
    +    public function testDefaultValues($value, $expectedValueNode) {
    +        $node = $this->createPropertyBuilder('test')
    +            ->setDefault($value)
    +            ->getNode()
    +        ;
    +
    +        $this->assertEquals($expectedValueNode, $node->props[0]->default);
    +    }
    +
    +    public function provideTestDefaultValues() {
    +        return array(
    +            array(
    +                null,
    +                new PHPParser_Node_Expr_ConstFetch(new PHPParser_Node_Name('null'))
    +            ),
    +            array(
    +                true,
    +                new PHPParser_Node_Expr_ConstFetch(new PHPParser_Node_Name('true'))
    +            ),
    +            array(
    +                false,
    +                new PHPParser_Node_Expr_ConstFetch(new PHPParser_Node_Name('false'))
    +            ),
    +            array(
    +                31415,
    +                new PHPParser_Node_Scalar_LNumber(31415)
    +            ),
    +            array(
    +                3.1415,
    +                new PHPParser_Node_Scalar_DNumber(3.1415)
    +            ),
    +            array(
    +                'Hallo World',
    +                new PHPParser_Node_Scalar_String('Hallo World')
    +            ),
    +            array(
    +                array(1, 2, 3),
    +                new PHPParser_Node_Expr_Array(array(
    +                    new PHPParser_Node_Expr_ArrayItem(new PHPParser_Node_Scalar_LNumber(1)),
    +                    new PHPParser_Node_Expr_ArrayItem(new PHPParser_Node_Scalar_LNumber(2)),
    +                    new PHPParser_Node_Expr_ArrayItem(new PHPParser_Node_Scalar_LNumber(3)),
    +                ))
    +            ),
    +            array(
    +                array('foo' => 'bar', 'bar' => 'foo'),
    +                new PHPParser_Node_Expr_Array(array(
    +                    new PHPParser_Node_Expr_ArrayItem(
    +                        new PHPParser_Node_Scalar_String('bar'),
    +                        new PHPParser_Node_Scalar_String('foo')
    +                    ),
    +                    new PHPParser_Node_Expr_ArrayItem(
    +                        new PHPParser_Node_Scalar_String('foo'),
    +                        new PHPParser_Node_Scalar_String('bar')
    +                    ),
    +                ))
    +            ),
    +            array(
    +                new PHPParser_Node_Scalar_DirConst,
    +                new PHPParser_Node_Scalar_DirConst
    +            )
    +        );
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/test/PHPParser/Tests/BuilderFactoryTest.php b/vendor/nikic/php-parser/test/PHPParser/Tests/BuilderFactoryTest.php
    new file mode 100755
    index 0000000..0eaf8a9
    --- /dev/null
    +++ b/vendor/nikic/php-parser/test/PHPParser/Tests/BuilderFactoryTest.php
    @@ -0,0 +1,23 @@
    +assertInstanceOf($className, $factory->$methodName('test'));
    +    }
    +
    +    public function provideTestFactory() {
    +        return array(
    +            array('class',     'PHPParser_Builder_Class'),
    +            array('interface', 'PHPParser_Builder_Interface'),
    +            array('method',    'PHPParser_Builder_Method'),
    +            array('function',  'PHPParser_Builder_Function'),
    +            array('property',  'PHPParser_Builder_Property'),
    +            array('param',     'PHPParser_Builder_Param'),
    +        );
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/test/PHPParser/Tests/CodeTestAbstract.php b/vendor/nikic/php-parser/test/PHPParser/Tests/CodeTestAbstract.php
    new file mode 100755
    index 0000000..d315385
    --- /dev/null
    +++ b/vendor/nikic/php-parser/test/PHPParser/Tests/CodeTestAbstract.php
    @@ -0,0 +1,51 @@
    +assertEquals('/* Some comment */', $comment->getText());
    +        $this->assertEquals('/* Some comment */', (string) $comment);
    +        $this->assertEquals(1, $comment->getLine());
    +
    +        $comment->setText('/* Some other comment */');
    +        $comment->setLine(10);
    +
    +        $this->assertEquals('/* Some other comment */', $comment->getText());
    +        $this->assertEquals('/* Some other comment */', (string) $comment);
    +        $this->assertEquals(10, $comment->getLine());
    +    }
    +
    +    /**
    +     * @dataProvider provideTestReformatting
    +     */
    +    public function testReformatting($commentText, $reformattedText) {
    +        $comment = new PHPParser_Comment($commentText);
    +        $this->assertEquals($reformattedText, $comment->getReformattedText());
    +    }
    +
    +    public function provideTestReformatting() {
    +        return array(
    +            array('// Some text' . "\n", '// Some text'),
    +            array('/* Some text */', '/* Some text */'),
    +            array(
    +                '/**
    +     * Some text.
    +     * Some more text.
    +     */',
    +                '/**
    + * Some text.
    + * Some more text.
    + */'
    +            ),
    +            array(
    +                '/*
    +        Some text.
    +        Some more text.
    +    */',
    +                '/*
    +    Some text.
    +    Some more text.
    +*/'
    +            ),
    +            array(
    +                '/* Some text.
    +       More text.
    +       Even more text. */',
    +                '/* Some text.
    +   More text.
    +   Even more text. */'
    +            ),
    +            // invalid comment -> no reformatting
    +            array(
    +                'hallo
    +    world',
    +                'hallo
    +    world',
    +            ),
    +        );
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/test/PHPParser/Tests/ErrorTest.php b/vendor/nikic/php-parser/test/PHPParser/Tests/ErrorTest.php
    new file mode 100755
    index 0000000..de21cdd
    --- /dev/null
    +++ b/vendor/nikic/php-parser/test/PHPParser/Tests/ErrorTest.php
    @@ -0,0 +1,33 @@
    +assertEquals('Some error', $error->getRawMessage());
    +        $this->assertEquals(10, $error->getRawLine());
    +        $this->assertEquals('Some error on line 10', $error->getMessage());
    +
    +        return $error;
    +    }
    +
    +    /**
    +     * @depends testConstruct
    +     */
    +    public function testSetMessageAndLine(PHPParser_Error $error) {
    +        $error->setRawMessage('Some other error');
    +        $error->setRawLine(15);
    +
    +        $this->assertEquals('Some other error', $error->getRawMessage());
    +        $this->assertEquals(15, $error->getRawLine());
    +        $this->assertEquals('Some other error on line 15', $error->getMessage());
    +    }
    +
    +    public function testUnknownLine() {
    +        $error = new PHPParser_Error('Some error');
    +
    +        $this->assertEquals(-1, $error->getRawLine());
    +        $this->assertEquals('Some error on unknown line', $error->getMessage());
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/test/PHPParser/Tests/Lexer/EmulativeTest.php b/vendor/nikic/php-parser/test/PHPParser/Tests/Lexer/EmulativeTest.php
    new file mode 100755
    index 0000000..80468bc
    --- /dev/null
    +++ b/vendor/nikic/php-parser/test/PHPParser/Tests/Lexer/EmulativeTest.php
    @@ -0,0 +1,103 @@
    +lexer = new PHPParser_Lexer_Emulative;
    +    }
    +
    +    /**
    +     * @dataProvider provideTestReplaceKeywords
    +     */
    +    public function testReplaceKeywords($keyword, $expectedToken) {
    +        $this->lexer->startLexing('assertEquals($expectedToken, $this->lexer->getNextToken());
    +        $this->assertEquals(0, $this->lexer->getNextToken());
    +    }
    +
    +    /**
    +     * @dataProvider provideTestReplaceKeywords
    +     */
    +    public function testNoReplaceKeywordsAfterObjectOperator($keyword) {
    +        $this->lexer->startLexing('' . $keyword);
    +
    +        $this->assertEquals(PHPParser_Parser::T_OBJECT_OPERATOR, $this->lexer->getNextToken());
    +        $this->assertEquals(PHPParser_Parser::T_STRING, $this->lexer->getNextToken());
    +        $this->assertEquals(0, $this->lexer->getNextToken());
    +    }
    +
    +    public function provideTestReplaceKeywords() {
    +        return array(
    +            // PHP 5.5
    +            array('finally',       PHPParser_Parser::T_FINALLY),
    +            array('yield',         PHPParser_Parser::T_YIELD),
    +
    +            // PHP 5.4
    +            array('callable',      PHPParser_Parser::T_CALLABLE),
    +            array('insteadof',     PHPParser_Parser::T_INSTEADOF),
    +            array('trait',         PHPParser_Parser::T_TRAIT),
    +            array('__TRAIT__',     PHPParser_Parser::T_TRAIT_C),
    +
    +            // PHP 5.3
    +            array('__DIR__',       PHPParser_Parser::T_DIR),
    +            array('goto',          PHPParser_Parser::T_GOTO),
    +            array('namespace',     PHPParser_Parser::T_NAMESPACE),
    +            array('__NAMESPACE__', PHPParser_Parser::T_NS_C),
    +        );
    +    }
    +
    +    /**
    +     * @dataProvider provideTestLexNewFeatures
    +     */
    +    public function testLexNewFeatures($code, array $expectedTokens) {
    +        $this->lexer->startLexing('assertEquals($expectedTokenType, $this->lexer->getNextToken($text));
    +            $this->assertEquals($expectedTokenText, $text);
    +        }
    +        $this->assertEquals(0, $this->lexer->getNextToken());
    +    }
    +
    +    /**
    +     * @dataProvider provideTestLexNewFeatures
    +     */
    +    public function testLeaveStuffAloneInStrings($code) {
    +        $stringifiedToken = '"' . addcslashes($code, '"\\') . '"';
    +        $this->lexer->startLexing('assertEquals(PHPParser_Parser::T_CONSTANT_ENCAPSED_STRING, $this->lexer->getNextToken($text));
    +        $this->assertEquals($stringifiedToken, $text);
    +        $this->assertEquals(0, $this->lexer->getNextToken());
    +    }
    +
    +    public function provideTestLexNewFeatures() {
    +        return array(
    +            array('0b1010110', array(
    +                array(PHPParser_Parser::T_LNUMBER, '0b1010110'),
    +            )),
    +            array('0b1011010101001010110101010010101011010101010101101011001110111100', array(
    +                array(PHPParser_Parser::T_DNUMBER, '0b1011010101001010110101010010101011010101010101101011001110111100'),
    +            )),
    +            array('\\', array(
    +                array(PHPParser_Parser::T_NS_SEPARATOR, '\\'),
    +            )),
    +            array("<<<'NOWDOC'\nNOWDOC;\n", array(
    +                array(PHPParser_Parser::T_START_HEREDOC, "<<<'NOWDOC'\n"),
    +                array(PHPParser_Parser::T_END_HEREDOC, 'NOWDOC'),
    +                array(ord(';'), ';'),
    +            )),
    +            array("<<<'NOWDOC'\nFoobar\nNOWDOC;\n", array(
    +                array(PHPParser_Parser::T_START_HEREDOC, "<<<'NOWDOC'\n"),
    +                array(PHPParser_Parser::T_ENCAPSED_AND_WHITESPACE, "Foobar\n"),
    +                array(PHPParser_Parser::T_END_HEREDOC, 'NOWDOC'),
    +                array(ord(';'), ';'),
    +            )),
    +        );
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/test/PHPParser/Tests/LexerTest.php b/vendor/nikic/php-parser/test/PHPParser/Tests/LexerTest.php
    new file mode 100755
    index 0000000..9a983eb
    --- /dev/null
    +++ b/vendor/nikic/php-parser/test/PHPParser/Tests/LexerTest.php
    @@ -0,0 +1,145 @@
    +lexer = new PHPParser_Lexer;
    +    }
    +
    +    /**
    +     * @dataProvider provideTestError
    +     */
    +    public function testError($code, $message) {
    +        try {
    +            $this->lexer->startLexing($code);
    +        } catch (PHPParser_Error $e) {
    +            $this->assertEquals($message, $e->getMessage());
    +
    +            return;
    +        }
    +
    +        $this->fail('Expected PHPParser_Error');
    +    }
    +
    +    public function provideTestError() {
    +        return array(
    +            array('lexer->startLexing($code);
    +        while ($id = $this->lexer->getNextToken($value, $startAttributes, $endAttributes)) {
    +            $token = array_shift($tokens);
    +
    +            $this->assertEquals($token[0], $id);
    +            $this->assertEquals($token[1], $value);
    +            $this->assertEquals($token[2], $startAttributes);
    +            $this->assertEquals($token[3], $endAttributes);
    +        }
    +    }
    +
    +    public function provideTestLex() {
    +        return array(
    +            // tests conversion of closing PHP tag and drop of whitespace and opening tags
    +            array(
    +                'plaintext',
    +                array(
    +                    array(
    +                        PHPParser_Parser::T_STRING, 'tokens',
    +                        array('startLine' => 1), array('endLine' => 1)
    +                    ),
    +                    array(
    +                        ord(';'), '?>',
    +                        array('startLine' => 1), array('endLine' => 1)
    +                    ),
    +                    array(
    +                        PHPParser_Parser::T_INLINE_HTML, 'plaintext',
    +                        array('startLine' => 1), array('endLine' => 1)
    +                    ),
    +                )
    +            ),
    +            // tests line numbers
    +            array(
    +                ' 2), array('endLine' => 2)
    +                    ),
    +                    array(
    +                        PHPParser_Parser::T_STRING, 'token',
    +                        array('startLine' => 2), array('endLine' => 2)
    +                    ),
    +                    array(
    +                        ord('$'), '$',
    +                        array(
    +                            'startLine' => 3,
    +                            'comments' => array(new PHPParser_Comment_Doc('/** doc' . "\n" . 'comment */', 2))
    +                        ),
    +                        array('endLine' => 3)
    +                    ),
    +                )
    +            ),
    +            // tests comment extraction
    +            array(
    +                ' 2,
    +                            'comments' => array(
    +                                new PHPParser_Comment('/* comment */', 1),
    +                                new PHPParser_Comment('// comment' . "\n", 1),
    +                                new PHPParser_Comment_Doc('/** docComment 1 */', 2),
    +                                new PHPParser_Comment_Doc('/** docComment 2 */', 2),
    +                            ),
    +                        ),
    +                        array('endLine' => 2)
    +                    ),
    +                )
    +            ),
    +            // tests differing start and end line
    +            array(
    +                ' 1), array('endLine' => 2)
    +                    ),
    +                )
    +            ),
    +        );
    +    }
    +
    +    /**
    +     * @dataProvider provideTestHaltCompiler
    +     */
    +    public function testHandleHaltCompiler($code, $remaining) {
    +        $this->lexer->startLexing($code);
    +
    +        while (PHPParser_Parser::T_HALT_COMPILER !== $this->lexer->getNextToken());
    +
    +        $this->assertEquals($this->lexer->handleHaltCompiler(), $remaining);
    +        $this->assertEquals(0, $this->lexer->getNextToken());
    +    }
    +
    +    public function provideTestHaltCompiler() {
    +        return array(
    +            array('Remaining Text', 'Remaining Text'),
    +            //array('assertEquals(array('foo', 'bar'), $name->parts);
    +
    +        $name = new PHPParser_Node_Name('foo\bar');
    +        $this->assertEquals(array('foo', 'bar'), $name->parts);
    +    }
    +
    +    public function testGet() {
    +        $name = new PHPParser_Node_Name('foo');
    +        $this->assertEquals('foo', $name->getFirst());
    +        $this->assertEquals('foo', $name->getLast());
    +
    +        $name = new PHPParser_Node_Name('foo\bar');
    +        $this->assertEquals('foo', $name->getFirst());
    +        $this->assertEquals('bar', $name->getLast());
    +    }
    +
    +    public function testToString() {
    +        $name = new PHPParser_Node_Name('foo\bar');
    +
    +        $this->assertEquals('foo\bar', (string) $name);
    +        $this->assertEquals('foo\bar', $name->toString());
    +        $this->assertEquals('foo_bar', $name->toString('_'));
    +    }
    +
    +    public function testSet() {
    +        $name = new PHPParser_Node_Name('foo');
    +
    +        $name->set('foo\bar');
    +        $this->assertEquals('foo\bar', $name->toString());
    +
    +        $name->set(array('foo', 'bar'));
    +        $this->assertEquals('foo\bar', $name->toString());
    +
    +        $name->set(new PHPParser_Node_Name('foo\bar'));
    +        $this->assertEquals('foo\bar', $name->toString());
    +    }
    +
    +    public function testSetFirst() {
    +        $name = new PHPParser_Node_Name('foo');
    +
    +        $name->setFirst('bar');
    +        $this->assertEquals('bar', $name->toString());
    +
    +        $name->setFirst('A\B');
    +        $this->assertEquals('A\B', $name->toString());
    +
    +        $name->setFirst('C');
    +        $this->assertEquals('C\B', $name->toString());
    +
    +        $name->setFirst('D\E');
    +        $this->assertEquals('D\E\B', $name->toString());
    +    }
    +
    +    public function testSetLast() {
    +        $name = new PHPParser_Node_Name('foo');
    +
    +        $name->setLast('bar');
    +        $this->assertEquals('bar', $name->toString());
    +
    +        $name->setLast('A\B');
    +        $this->assertEquals('A\B', $name->toString());
    +
    +        $name->setLast('C');
    +        $this->assertEquals('A\C', $name->toString());
    +
    +        $name->setLast('D\E');
    +        $this->assertEquals('A\D\E', $name->toString());
    +    }
    +
    +    public function testAppend() {
    +        $name = new PHPParser_Node_Name('foo');
    +
    +        $name->append('bar');
    +        $this->assertEquals('foo\bar', $name->toString());
    +
    +        $name->append('bar\foo');
    +        $this->assertEquals('foo\bar\bar\foo', $name->toString());
    +    }
    +
    +    public function testPrepend() {
    +        $name = new PHPParser_Node_Name('foo');
    +
    +        $name->prepend('bar');
    +        $this->assertEquals('bar\foo', $name->toString());
    +
    +        $name->prepend('foo\bar');
    +        $this->assertEquals('foo\bar\bar\foo', $name->toString());
    +    }
    +
    +    public function testIs() {
    +        $name = new PHPParser_Node_Name('foo');
    +        $this->assertTrue ($name->isUnqualified());
    +        $this->assertFalse($name->isQualified());
    +        $this->assertFalse($name->isFullyQualified());
    +        $this->assertFalse($name->isRelative());
    +
    +        $name = new PHPParser_Node_Name('foo\bar');
    +        $this->assertFalse($name->isUnqualified());
    +        $this->assertTrue ($name->isQualified());
    +        $this->assertFalse($name->isFullyQualified());
    +        $this->assertFalse($name->isRelative());
    +
    +        $name = new PHPParser_Node_Name_FullyQualified('foo');
    +        $this->assertFalse($name->isUnqualified());
    +        $this->assertFalse($name->isQualified());
    +        $this->assertTrue ($name->isFullyQualified());
    +        $this->assertFalse($name->isRelative());
    +
    +        $name = new PHPParser_Node_Name_Relative('foo');
    +        $this->assertFalse($name->isUnqualified());
    +        $this->assertFalse($name->isQualified());
    +        $this->assertFalse($name->isFullyQualified());
    +        $this->assertTrue ($name->isRelative());
    +    }
    +
    +    /**
    +     * @expectedException        InvalidArgumentException
    +     * @expectedExceptionMessage When changing a name you need to pass either a string, an array or a Name node
    +     */
    +    public function testInvalidArg() {
    +        $name = new PHPParser_Node_Name('foo');
    +        $name->set(new stdClass);
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/test/PHPParser/Tests/Node/Scalar/StringTest.php b/vendor/nikic/php-parser/test/PHPParser/Tests/Node/Scalar/StringTest.php
    new file mode 100755
    index 0000000..04dd35b
    --- /dev/null
    +++ b/vendor/nikic/php-parser/test/PHPParser/Tests/Node/Scalar/StringTest.php
    @@ -0,0 +1,59 @@
    +assertEquals(
    +            $expected,
    +            PHPParser_Node_Scalar_String::parseEscapeSequences($string, $quote)
    +        );
    +    }
    +
    +    /**
    +     * @dataProvider provideTestParse
    +     */
    +    public function testCreate($expected, $string) {
    +        $this->assertEquals(
    +            $expected,
    +            PHPParser_Node_Scalar_String::parse($string)
    +        );
    +    }
    +
    +    public function provideTestParseEscapeSequences() {
    +        return array(
    +            array('"',              '\\"',              '"'),
    +            array('\\"',            '\\"',              '`'),
    +            array('\\"\\`',         '\\"\\`',           null),
    +            array("\\\$\n\r\t\f\v", '\\\\\$\n\r\t\f\v', null),
    +            array("\x1B",           '\e',               null),
    +            array(chr(255),         '\xFF',             null),
    +            array(chr(255),         '\377',             null),
    +            array(chr(0),           '\400',             null),
    +            array("\0",             '\0',               null),
    +            array('\xFF',           '\\\\xFF',          null),
    +        );
    +    }
    +
    +    public function provideTestParse() {
    +        $tests = array(
    +            array('A', '\'A\''),
    +            array('A', 'b\'A\''),
    +            array('A', '"A"'),
    +            array('A', 'b"A"'),
    +            array('\\', '\'\\\\\''),
    +            array('\'', '\'\\\'\''),
    +        );
    +
    +        foreach ($this->provideTestParseEscapeSequences() as $i => $test) {
    +            // skip second and third tests, they aren't for double quotes
    +            if ($i != 1 && $i != 2) {
    +                $tests[] = array($test[0], '"' . $test[1] . '"');
    +            }
    +        }
    +
    +        return $tests;
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/test/PHPParser/Tests/Node/Stmt/ClassMethodTest.php b/vendor/nikic/php-parser/test/PHPParser/Tests/Node/Stmt/ClassMethodTest.php
    new file mode 100755
    index 0000000..ddabe86
    --- /dev/null
    +++ b/vendor/nikic/php-parser/test/PHPParser/Tests/Node/Stmt/ClassMethodTest.php
    @@ -0,0 +1,35 @@
    + constant('PHPParser_Node_Stmt_Class::MODIFIER_' . strtoupper($modifier))
    +        ));
    +
    +        $this->assertTrue($node->{'is' . $modifier}());
    +    }
    +
    +    /**
    +     * @dataProvider provideModifiers
    +     */
    +    public function testNoModifiers($modifier) {
    +        $node = new PHPParser_Node_Stmt_ClassMethod('foo', array('type' => 0));
    +
    +        $this->assertFalse($node->{'is' . $modifier}());
    +    }
    +
    +    public function provideModifiers() {
    +        return array(
    +            array('public'),
    +            array('protected'),
    +            array('private'),
    +            array('abstract'),
    +            array('final'),
    +            array('static'),
    +        );
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/test/PHPParser/Tests/Node/Stmt/ClassTest.php b/vendor/nikic/php-parser/test/PHPParser/Tests/Node/Stmt/ClassTest.php
    new file mode 100755
    index 0000000..3904815
    --- /dev/null
    +++ b/vendor/nikic/php-parser/test/PHPParser/Tests/Node/Stmt/ClassTest.php
    @@ -0,0 +1,40 @@
    + PHPParser_Node_Stmt_Class::MODIFIER_ABSTRACT));
    +        $this->assertTrue($class->isAbstract());
    +
    +        $class = new PHPParser_Node_Stmt_Class('Foo');
    +        $this->assertFalse($class->isAbstract());
    +    }
    +
    +    public function testIsFinal() {
    +        $class = new PHPParser_Node_Stmt_Class('Foo', array('type' => PHPParser_Node_Stmt_Class::MODIFIER_FINAL));
    +        $this->assertTrue($class->isFinal());
    +
    +        $class = new PHPParser_Node_Stmt_Class('Foo');
    +        $this->assertFalse($class->isFinal());
    +    }
    +
    +    public function testGetMethods() {
    +        $methods = array(
    +            new PHPParser_Node_Stmt_ClassMethod('foo'),
    +            new PHPParser_Node_Stmt_ClassMethod('bar'),
    +            new PHPParser_Node_Stmt_ClassMethod('fooBar'),
    +        );
    +        $class = new PHPParser_Node_Stmt_Class('Foo', array(
    +            'stmts' => array(
    +                new PHPParser_Node_Stmt_TraitUse(array()),
    +                $methods[0],
    +                new PHPParser_Node_Stmt_Const(array()),
    +                $methods[1],
    +                new PHPParser_Node_Stmt_Property(0, array()),
    +                $methods[2],
    +            )
    +        ));
    +
    +        $this->assertEquals($methods, $class->getMethods());
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/test/PHPParser/Tests/Node/Stmt/PropertyTest.php b/vendor/nikic/php-parser/test/PHPParser/Tests/Node/Stmt/PropertyTest.php
    new file mode 100755
    index 0000000..6c3f38b
    --- /dev/null
    +++ b/vendor/nikic/php-parser/test/PHPParser/Tests/Node/Stmt/PropertyTest.php
    @@ -0,0 +1,34 @@
    +assertTrue($node->{'is' . $modifier}());
    +    }
    +
    +    /**
    +     * @dataProvider provideModifiers
    +     */
    +    public function testNoModifiers($modifier) {
    +        $node = new PHPParser_Node_Stmt_Property(0, array());
    +
    +        $this->assertFalse($node->{'is' . $modifier}());
    +    }
    +
    +    public function provideModifiers() {
    +        return array(
    +            array('public'),
    +            array('protected'),
    +            array('private'),
    +            array('static'),
    +        );
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/test/PHPParser/Tests/NodeAbstractTest.php b/vendor/nikic/php-parser/test/PHPParser/Tests/NodeAbstractTest.php
    new file mode 100755
    index 0000000..767340e
    --- /dev/null
    +++ b/vendor/nikic/php-parser/test/PHPParser/Tests/NodeAbstractTest.php
    @@ -0,0 +1,96 @@
    + 10,
    +            'comments'  => array(
    +                new PHPParser_Comment('// Comment' . "\n"),
    +                new PHPParser_Comment_Doc('/** doc comment */'),
    +            ),
    +        );
    +
    +        $node = $this->getMockForAbstractClass(
    +            'PHPParser_NodeAbstract',
    +            array(
    +                array(
    +                    'subNode' => 'value'
    +                ),
    +                $attributes
    +            ),
    +            'PHPParser_Node_Dummy'
    +        );
    +
    +        $this->assertEquals('Dummy', $node->getType());
    +        $this->assertEquals(array('subNode'), $node->getSubNodeNames());
    +        $this->assertEquals(10, $node->getLine());
    +        $this->assertEquals('/** doc comment */', $node->getDocComment());
    +        $this->assertEquals('value', $node->subNode);
    +        $this->assertTrue(isset($node->subNode));
    +        $this->assertEquals($attributes, $node->getAttributes());
    +
    +        return $node;
    +    }
    +
    +    /**
    +     * @depends testConstruct
    +     */
    +    public function testGetDocComment(PHPParser_Node $node) {
    +        $this->assertEquals('/** doc comment */', $node->getDocComment());
    +        array_pop($node->getAttribute('comments')); // remove doc comment
    +        $this->assertNull($node->getDocComment());
    +        array_pop($node->getAttribute('comments')); // remove comment
    +        $this->assertNull($node->getDocComment());
    +    }
    +
    +    /**
    +     * @depends testConstruct
    +     */
    +    public function testChange(PHPParser_Node $node) {
    +        // change of line
    +        $node->setLine(15);
    +        $this->assertEquals(15, $node->getLine());
    +
    +        // direct modification
    +        $node->subNode = 'newValue';
    +        $this->assertEquals('newValue', $node->subNode);
    +
    +        // indirect modification
    +        $subNode =& $node->subNode;
    +        $subNode = 'newNewValue';
    +        $this->assertEquals('newNewValue', $node->subNode);
    +
    +        // removal
    +        unset($node->subNode);
    +        $this->assertFalse(isset($node->subNode));
    +    }
    +
    +    public function testAttributes() {
    +        /** @var $node PHPParser_Node */
    +        $node = $this->getMockForAbstractClass('PHPParser_NodeAbstract');
    +
    +        $this->assertEmpty($node->getAttributes());
    +
    +        $node->setAttribute('key', 'value');
    +        $this->assertTrue($node->hasAttribute('key'));
    +        $this->assertEquals('value', $node->getAttribute('key'));
    +
    +        $this->assertFalse($node->hasAttribute('doesNotExist'));
    +        $this->assertNull($node->getAttribute('doesNotExist'));
    +        $this->assertEquals('default', $node->getAttribute('doesNotExist', 'default'));
    +
    +        $node->setAttribute('null', null);
    +        $this->assertTrue($node->hasAttribute('null'));
    +        $this->assertNull($node->getAttribute('null'));
    +        $this->assertNull($node->getAttribute('null', 'default'));
    +
    +        $this->assertEquals(
    +            array(
    +                'key'  => 'value',
    +                'null' => null,
    +            ),
    +            $node->getAttributes()
    +        );
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/test/PHPParser/Tests/NodeDumperTest.php b/vendor/nikic/php-parser/test/PHPParser/Tests/NodeDumperTest.php
    new file mode 100755
    index 0000000..5ea29d5
    --- /dev/null
    +++ b/vendor/nikic/php-parser/test/PHPParser/Tests/NodeDumperTest.php
    @@ -0,0 +1,66 @@
    +assertEquals($dump, $dumper->dump($node));
    +    }
    +
    +    public function provideTestDump() {
    +        return array(
    +            array(
    +                array(),
    +'array(
    +)'
    +            ),
    +            array(
    +                array('Foo', 'Bar', 'Key' => 'FooBar'),
    +'array(
    +    0: Foo
    +    1: Bar
    +    Key: FooBar
    +)'
    +            ),
    +            array(
    +                new PHPParser_Node_Name(array('Hallo', 'World')),
    +'Name(
    +    parts: array(
    +        0: Hallo
    +        1: World
    +    )
    +)'
    +            ),
    +            array(
    +                new PHPParser_Node_Expr_Array(array(
    +                    new PHPParser_Node_Expr_ArrayItem(new PHPParser_Node_Scalar_String('Foo'))
    +                )),
    +'Expr_Array(
    +    items: array(
    +        0: Expr_ArrayItem(
    +            key: null
    +            value: Scalar_String(
    +                value: Foo
    +            )
    +            byRef: false
    +        )
    +    )
    +)'
    +            ),
    +        );
    +    }
    +
    +    /**
    +     * @expectedException        InvalidArgumentException
    +     * @expectedExceptionMessage Can only dump nodes and arrays.
    +     */
    +    public function testError() {
    +        $dumper = new PHPParser_NodeDumper;
    +        $dumper->dump(new stdClass);
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/test/PHPParser/Tests/NodeTraverserTest.php b/vendor/nikic/php-parser/test/PHPParser/Tests/NodeTraverserTest.php
    new file mode 100755
    index 0000000..e072cb2
    --- /dev/null
    +++ b/vendor/nikic/php-parser/test/PHPParser/Tests/NodeTraverserTest.php
    @@ -0,0 +1,125 @@
    +getMock('PHPParser_NodeVisitor');
    +
    +        $visitor->expects($this->at(0))->method('beforeTraverse')->with($stmts);
    +        $visitor->expects($this->at(1))->method('enterNode')->with($echoNode);
    +        $visitor->expects($this->at(2))->method('enterNode')->with($str1Node);
    +        $visitor->expects($this->at(3))->method('leaveNode')->with($str1Node);
    +        $visitor->expects($this->at(4))->method('enterNode')->with($str2Node);
    +        $visitor->expects($this->at(5))->method('leaveNode')->with($str2Node);
    +        $visitor->expects($this->at(6))->method('leaveNode')->with($echoNode);
    +        $visitor->expects($this->at(7))->method('afterTraverse')->with($stmts);
    +
    +        $traverser = new PHPParser_NodeTraverser;
    +        $traverser->addVisitor($visitor);
    +
    +        $this->assertEquals($stmts, $traverser->traverse($stmts));
    +    }
    +
    +    public function testModifying() {
    +        $str1Node  = new PHPParser_Node_Scalar_String('Foo');
    +        $str2Node  = new PHPParser_Node_Scalar_String('Bar');
    +        $printNode = new PHPParser_Node_Expr_Print($str1Node);
    +
    +        // first visitor changes the node, second verifies the change
    +        $visitor1 = $this->getMock('PHPParser_NodeVisitor');
    +        $visitor2 = $this->getMock('PHPParser_NodeVisitor');
    +
    +        // replace empty statements with string1 node
    +        $visitor1->expects($this->at(0))->method('beforeTraverse')->with(array())
    +                 ->will($this->returnValue(array($str1Node)));
    +        $visitor2->expects($this->at(0))->method('beforeTraverse')->with(array($str1Node));
    +
    +        // replace string1 node with print node
    +        $visitor1->expects($this->at(1))->method('enterNode')->with($str1Node)
    +                 ->will($this->returnValue($printNode));
    +        $visitor2->expects($this->at(1))->method('enterNode')->with($printNode);
    +
    +        // replace string1 node with string2 node
    +        $visitor1->expects($this->at(2))->method('enterNode')->with($str1Node)
    +                 ->will($this->returnValue($str2Node));
    +        $visitor2->expects($this->at(2))->method('enterNode')->with($str2Node);
    +
    +        // replace string2 node with string1 node again
    +        $visitor1->expects($this->at(3))->method('leaveNode')->with($str2Node)
    +                 ->will($this->returnValue($str1Node));
    +        $visitor2->expects($this->at(3))->method('leaveNode')->with($str1Node);
    +
    +        // replace print node with string1 node again
    +        $visitor1->expects($this->at(4))->method('leaveNode')->with($printNode)
    +                 ->will($this->returnValue($str1Node));
    +        $visitor2->expects($this->at(4))->method('leaveNode')->with($str1Node);
    +
    +        // replace string1 node with empty statements again
    +        $visitor1->expects($this->at(5))->method('afterTraverse')->with(array($str1Node))
    +                 ->will($this->returnValue(array()));
    +        $visitor2->expects($this->at(5))->method('afterTraverse')->with(array());
    +
    +        $traverser = new PHPParser_NodeTraverser;
    +        $traverser->addVisitor($visitor1);
    +        $traverser->addVisitor($visitor2);
    +
    +        // as all operations are reversed we end where we start
    +        $this->assertEquals(array(), $traverser->traverse(array()));
    +    }
    +
    +    public function testRemove() {
    +        $str1Node = new PHPParser_Node_Scalar_String('Foo');
    +        $str2Node = new PHPParser_Node_Scalar_String('Bar');
    +
    +        $visitor = $this->getMock('PHPParser_NodeVisitor');
    +
    +        // remove the string1 node, leave the string2 node
    +        $visitor->expects($this->at(2))->method('leaveNode')->with($str1Node)
    +                ->will($this->returnValue(false));
    +
    +        $traverser = new PHPParser_NodeTraverser;
    +        $traverser->addVisitor($visitor);
    +
    +        $this->assertEquals(array($str2Node), $traverser->traverse(array($str1Node, $str2Node)));
    +    }
    +
    +    public function testMerge() {
    +        $strStart  = new PHPParser_Node_Scalar_String('Start');
    +        $strMiddle = new PHPParser_Node_Scalar_String('End');
    +        $strEnd    = new PHPParser_Node_Scalar_String('Middle');
    +        $strR1     = new PHPParser_Node_Scalar_String('Replacement 1');
    +        $strR2     = new PHPParser_Node_Scalar_String('Replacement 2');
    +
    +        $visitor = $this->getMock('PHPParser_NodeVisitor');
    +
    +        // replace strMiddle with strR1 and strR2 by merge
    +        $visitor->expects($this->at(4))->method('leaveNode')->with($strMiddle)
    +                ->will($this->returnValue(array($strR1, $strR2)));
    +
    +        $traverser = new PHPParser_NodeTraverser;
    +        $traverser->addVisitor($visitor);
    +
    +        $this->assertEquals(
    +            array($strStart, $strR1, $strR2, $strEnd),
    +            $traverser->traverse(array($strStart, $strMiddle, $strEnd))
    +        );
    +    }
    +
    +    public function testDeepArray() {
    +        $strNode = new PHPParser_Node_Scalar_String('Foo');
    +        $stmts = array(array(array($strNode)));
    +
    +        $visitor = $this->getMock('PHPParser_NodeVisitor');
    +        $visitor->expects($this->at(1))->method('enterNode')->with($strNode);
    +
    +        $traverser = new PHPParser_NodeTraverser;
    +        $traverser->addVisitor($visitor);
    +
    +        $this->assertEquals($stmts, $traverser->traverse($stmts));
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/test/PHPParser/Tests/NodeVisitor/NameResolverTest.php b/vendor/nikic/php-parser/test/PHPParser/Tests/NodeVisitor/NameResolverTest.php
    new file mode 100755
    index 0000000..49eaf69
    --- /dev/null
    +++ b/vendor/nikic/php-parser/test/PHPParser/Tests/NodeVisitor/NameResolverTest.php
    @@ -0,0 +1,225 @@
    +addVisitor(new PHPParser_NodeVisitor_NameResolver);
    +
    +        $stmts = $parser->parse($code);
    +        $stmts = $traverser->traverse($stmts);
    +
    +        $this->assertEquals($expectedCode, $prettyPrinter->prettyPrint($stmts));
    +    }
    +
    +    /**
    +     * @covers PHPParser_NodeVisitor_NameResolver
    +     */
    +    public function testResolveLocations() {
    +        $code = <<addVisitor(new PHPParser_NodeVisitor_NameResolver);
    +
    +        $stmts = $parser->parse($code);
    +        $stmts = $traverser->traverse($stmts);
    +
    +        $this->assertEquals($expectedCode, $prettyPrinter->prettyPrint($stmts));
    +    }
    +
    +    public function testNoResolveSpecialName() {
    +        $stmts = array(new PHPParser_Node_Expr_New(new PHPParser_Node_Name('self')));
    +
    +        $traverser = new PHPParser_NodeTraverser;
    +        $traverser->addVisitor(new PHPParser_NodeVisitor_NameResolver);
    +
    +        $this->assertEquals($stmts, $traverser->traverse($stmts));
    +    }
    +
    +    protected function createNamespacedAndNonNamespaced(array $stmts) {
    +        return array(
    +            new PHPParser_Node_Stmt_Namespace(new PHPParser_Node_Name('NS'), $stmts),
    +            new PHPParser_Node_Stmt_Namespace(null,                          $stmts),
    +        );
    +    }
    +
    +    public function testAddNamespacedName() {
    +        $stmts = $this->createNamespacedAndNonNamespaced(array(
    +            new PHPParser_Node_Stmt_Class('A'),
    +            new PHPParser_Node_Stmt_Interface('B'),
    +            new PHPParser_Node_Stmt_Function('C'),
    +            new PHPParser_Node_Stmt_Const(array(
    +                new PHPParser_Node_Const('D', new PHPParser_Node_Scalar_String('E'))
    +            )),
    +        ));
    +
    +        $traverser = new PHPParser_NodeTraverser;
    +        $traverser->addVisitor(new PHPParser_NodeVisitor_NameResolver);
    +
    +        $stmts = $traverser->traverse($stmts);
    +
    +        $this->assertEquals('NS\\A', (string) $stmts[0]->stmts[0]->namespacedName);
    +        $this->assertEquals('NS\\B', (string) $stmts[0]->stmts[1]->namespacedName);
    +        $this->assertEquals('NS\\C', (string) $stmts[0]->stmts[2]->namespacedName);
    +        $this->assertEquals('NS\\D', (string) $stmts[0]->stmts[3]->consts[0]->namespacedName);
    +        $this->assertEquals('A',     (string) $stmts[1]->stmts[0]->namespacedName);
    +        $this->assertEquals('B',     (string) $stmts[1]->stmts[1]->namespacedName);
    +        $this->assertEquals('C',     (string) $stmts[1]->stmts[2]->namespacedName);
    +        $this->assertEquals('D',     (string) $stmts[1]->stmts[3]->consts[0]->namespacedName);
    +    }
    +
    +    public function testAddTraitNamespacedName() {
    +        $stmts = $this->createNamespacedAndNonNamespaced(array(
    +            new PHPParser_Node_Stmt_Trait('A')
    +        ));
    +
    +        $traverser = new PHPParser_NodeTraverser;
    +        $traverser->addVisitor(new PHPParser_NodeVisitor_NameResolver);
    +
    +        $stmts = $traverser->traverse($stmts);
    +
    +        $this->assertEquals('NS\\A', (string) $stmts[0]->stmts[0]->namespacedName);
    +        $this->assertEquals('A',     (string) $stmts[1]->stmts[0]->namespacedName);
    +    }
    +
    +    /**
    +     * @expectedException        PHPParser_Error
    +     * @expectedExceptionMessage Cannot use "C" as "B" because the name is already in use on line 2
    +     */
    +    public function testAlreadyInUseError() {
    +        $stmts = array(
    +            new PHPParser_Node_Stmt_Use(array(
    +                new PHPParser_Node_Stmt_UseUse(new PHPParser_Node_Name('A\B'), 'B', array('startLine' => 1)),
    +                new PHPParser_Node_Stmt_UseUse(new PHPParser_Node_Name('C'),   'B', array('startLine' => 2)),
    +            ))
    +        );
    +
    +        $traverser = new PHPParser_NodeTraverser;
    +        $traverser->addVisitor(new PHPParser_NodeVisitor_NameResolver);
    +        $traverser->traverse($stmts);
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/test/PHPParser/Tests/ParserTest.php b/vendor/nikic/php-parser/test/PHPParser/Tests/ParserTest.php
    new file mode 100755
    index 0000000..cf45066
    --- /dev/null
    +++ b/vendor/nikic/php-parser/test/PHPParser/Tests/ParserTest.php
    @@ -0,0 +1,44 @@
    +parse($code);
    +        $this->assertEquals(
    +            $this->canonicalize($dump),
    +            $this->canonicalize($dumper->dump($stmts)),
    +            $name
    +        );
    +    }
    +
    +    public function provideTestParse() {
    +        return $this->getTests(dirname(__FILE__) . '/../../code/parser', 'test');
    +    }
    +
    +    /**
    +     * @dataProvider provideTestParseFail
    +     */
    +    public function testParseFail($name, $code, $msg) {
    +        $parser = new PHPParser_Parser(new PHPParser_Lexer_Emulative);
    +
    +        try {
    +            $parser->parse($code);
    +
    +            $this->fail(sprintf('"%s": Expected PHPParser_Error', $name));
    +        } catch (PHPParser_Error $e) {
    +            $this->assertEquals($msg, $e->getMessage(), $name);
    +        }
    +    }
    +
    +    public function provideTestParseFail() {
    +        return $this->getTests(dirname(__FILE__) . '/../../code/parser', 'test-fail');
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/test/PHPParser/Tests/PrettyPrinterTest.php b/vendor/nikic/php-parser/test/PHPParser/Tests/PrettyPrinterTest.php
    new file mode 100755
    index 0000000..11933e6
    --- /dev/null
    +++ b/vendor/nikic/php-parser/test/PHPParser/Tests/PrettyPrinterTest.php
    @@ -0,0 +1,42 @@
    +parse($code);
    +        $this->assertEquals(
    +            $this->canonicalize($dump),
    +            $this->canonicalize($prettyPrinter->$method($stmts)),
    +            $name
    +        );
    +    }
    +
    +    /**
    +     * @dataProvider provideTestPrettyPrint
    +     * @covers PHPParser_PrettyPrinter_Default
    +     */
    +    public function testPrettyPrint($name, $code, $dump) {
    +        $this->doTestPrettyPrintMethod('prettyPrint', $name, $code, $dump);
    +    }
    +
    +    /**
    +     * @dataProvider provideTestPrettyPrintFile
    +     * @covers PHPParser_PrettyPrinter_Default
    +     */
    +    public function testPrettyPrintFile($name, $code, $dump) {
    +        $this->doTestPrettyPrintMethod('prettyPrintFile', $name, $code, $dump);
    +    }
    +
    +    public function provideTestPrettyPrint() {
    +        return $this->getTests(dirname(__FILE__) . '/../../code/prettyPrinter', 'test');
    +    }
    +
    +    public function provideTestPrettyPrintFile() {
    +        return $this->getTests(dirname(__FILE__) . '/../../code/prettyPrinter', 'file-test');
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/test/PHPParser/Tests/Serializer/XMLTest.php b/vendor/nikic/php-parser/test/PHPParser/Tests/Serializer/XMLTest.php
    new file mode 100755
    index 0000000..9a0c191
    --- /dev/null
    +++ b/vendor/nikic/php-parser/test/PHPParser/Tests/Serializer/XMLTest.php
    @@ -0,0 +1,152 @@
    +
    +     */
    +    public function testSerialize() {
    +        $code = <<
    +
    + 
    +  
    +   
    +    
    +     // comment
    +
    +     /** doc comment */
    +    
    +   
    +   
    +    4
    +   
    +   
    +    6
    +   
    +   
    +    
    +   
    +   
    +    
    +     
    +      
    +       4
    +      
    +      
    +       4
    +      
    +      
    +       a
    +      
    +      
    +       
    +        
    +         4
    +        
    +        
    +         4
    +        
    +        
    +         0
    +        
    +       
    +      
    +      
    +       
    +      
    +      
    +       
    +      
    +     
    +     
    +      
    +       4
    +      
    +      
    +       4
    +      
    +      
    +       b
    +      
    +      
    +       
    +        
    +         4
    +        
    +        
    +         4
    +        
    +        
    +         1
    +        
    +       
    +      
    +      
    +       
    +      
    +      
    +       
    +      
    +     
    +    
    +   
    +   
    +    
    +     
    +      
    +       5
    +      
    +      
    +       5
    +      
    +      
    +       
    +        
    +         
    +          5
    +         
    +         
    +          5
    +         
    +         
    +          Foo
    +         
    +        
    +       
    +      
    +     
    +    
    +   
    +   
    +    functionName
    +   
    +  
    + 
    +
    +XML;
    +
    +        $parser     = new PHPParser_Parser(new PHPParser_Lexer);
    +        $serializer = new PHPParser_Serializer_XML;
    +
    +        $stmts = $parser->parse($code);
    +        $this->assertXmlStringEqualsXmlString($xml, $serializer->serialize($stmts));
    +    }
    +
    +    /**
    +     * @expectedException        InvalidArgumentException
    +     * @expectedExceptionMessage Unexpected node type
    +     */
    +    public function testError() {
    +        $serializer = new PHPParser_Serializer_XML;
    +        $serializer->serialize(array(new stdClass));
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/test/PHPParser/Tests/TemplateLoaderTest.php b/vendor/nikic/php-parser/test/PHPParser/Tests/TemplateLoaderTest.php
    new file mode 100755
    index 0000000..baa5735
    --- /dev/null
    +++ b/vendor/nikic/php-parser/test/PHPParser/Tests/TemplateLoaderTest.php
    @@ -0,0 +1,48 @@
    +load('TemplateLoaderTest.php');
    +        $this->assertInstanceOf('PHPParser_Template', $template);
    +    }
    +
    +    public function testLoadWithSuffix() {
    +        $templateLoader = new PHPParser_TemplateLoader(
    +            new PHPParser_Parser(new PHPParser_Lexer),
    +            dirname(__FILE__), '.php'
    +        );
    +
    +        // load this file as a template, as we don't really care about the contents
    +        $template = $templateLoader->load('TemplateLoaderTest');
    +        $this->assertInstanceOf('PHPParser_Template', $template);
    +    }
    +
    +    /**
    +     * @expectedException InvalidArgumentException
    +     */
    +    public function testNonexistentBaseDirectoryError() {
    +        new PHPParser_TemplateLoader(
    +            new PHPParser_Parser(new PHPParser_Lexer),
    +            dirname(__FILE__) . '/someDirectoryThatDoesNotExist'
    +        );
    +    }
    +
    +    /**
    +     * @expectedException InvalidArgumentException
    +     */
    +    public function testNonexistentFileError() {
    +        $templateLoader = new PHPParser_TemplateLoader(
    +            new PHPParser_Parser(new PHPParser_Lexer),
    +            dirname(__FILE__)
    +        );
    +
    +        $templateLoader->load('SomeTemplateThatDoesNotExist');
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/test/PHPParser/Tests/TemplateTest.php b/vendor/nikic/php-parser/test/PHPParser/Tests/TemplateTest.php
    new file mode 100755
    index 0000000..a926c5c
    --- /dev/null
    +++ b/vendor/nikic/php-parser/test/PHPParser/Tests/TemplateTest.php
    @@ -0,0 +1,59 @@
    +assertEquals(
    +            $expectedPrettyPrint,
    +            $prettyPrinter->prettyPrint($template->getStmts($placeholders))
    +        );
    +    }
    +
    +    public function provideTestPlaceholderReplacement() {
    +        return array(
    +            array(
    +                ' 'foo'),
    +                '$foo + $Foo;'
    +            ),
    +            array(
    +                ' 'Foo'),
    +                '$foo + $Foo;'
    +            ),
    +            array(
    +                ' 'foo', 'Name' => 'Bar'),
    +                '$foo + $Bar;'
    +            ),
    +            array(
    +                ' 'Bar', 'name' => 'foo'),
    +                '$foo + $Bar;'
    +            ),
    +            array(
    +                ' 'infix'),
    +                '$prefixInfixSuffix;'
    +            ),
    +            array(
    +                ' 'foo'),
    +                '$_foo_;'
    +            ),
    +            array(
    +                '
    +
    + 
    +  
    +   1
    +  
    +  
    +   
    +    // comment
    +
    +    /** doc comment */
    +   
    +  
    +  
    +   Test
    +  
    + 
    +
    +XML;
    +
    +        $unserializer  = new PHPParser_Unserializer_XML;
    +        $this->assertEquals(
    +            new PHPParser_Node_Scalar_String('Test', array(
    +                'startLine' => 1,
    +                'comments'  => array(
    +                    new PHPParser_Comment('// comment' . "\n", 2),
    +                    new PHPParser_Comment_Doc('/** doc comment */', 3),
    +                ),
    +            )),
    +            $unserializer->unserialize($xml)
    +        );
    +    }
    +
    +    public function testEmptyNode() {
    +        $xml = <<
    +
    + 
    +
    +XML;
    +
    +        $unserializer  = new PHPParser_Unserializer_XML;
    +
    +        $this->assertEquals(
    +            new PHPParser_Node_Scalar_ClassConst,
    +            $unserializer->unserialize($xml)
    +        );
    +    }
    +
    +    public function testScalars() {
    +        $xml = <<
    +
    + 
    +  
    +  
    +  test
    +  
    +  
    +  1
    +  1
    +  1.5
    +  
    +  
    +  
    + 
    +
    +XML;
    +        $result = array(
    +            array(), array(),
    +            'test', '', '',
    +            1,
    +            1, 1.5,
    +            true, false, null
    +        );
    +
    +        $unserializer  = new PHPParser_Unserializer_XML;
    +        $this->assertEquals($result, $unserializer->unserialize($xml));
    +    }
    +
    +    /**
    +     * @expectedException        DomainException
    +     * @expectedExceptionMessage AST root element not found
    +     */
    +    public function testWrongRootElementError() {
    +        $xml = <<
    +
    +XML;
    +
    +        $unserializer = new PHPParser_Unserializer_XML;
    +        $unserializer->unserialize($xml);
    +    }
    +
    +    /**
    +     * @dataProvider             provideTestErrors
    +     */
    +    public function testErrors($xml, $errorMsg) {
    +        $this->setExpectedException('DomainException', $errorMsg);
    +
    +        $xml = <<
    +
    + $xml
    +
    +XML;
    +
    +        $unserializer = new PHPParser_Unserializer_XML;
    +        $unserializer->unserialize($xml);
    +    }
    +
    +    public function provideTestErrors() {
    +        return array(
    +            array('test',   '"true" scalar must be empty'),
    +            array('test', '"false" scalar must be empty'),
    +            array('test',   '"null" scalar must be empty'),
    +            array('bar',      'Unknown scalar type "foo"'),
    +            array('x',        '"x" is not a valid int'),
    +            array('x',    '"x" is not a valid float'),
    +            array('',                                  'Expected node or scalar'),
    +            array('test',           'Unexpected node of type "foo:bar"'),
    +            array(
    +                'test',
    +                'Expected sub node or attribute, got node of type "foo:bar"'
    +            ),
    +            array(
    +                '',
    +                'Expected node or scalar'
    +            ),
    +        );
    +    }
    +}
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/test/code/parser/expr/arrayDef.test b/vendor/nikic/php-parser/test/code/parser/expr/arrayDef.test
    new file mode 100755
    index 0000000..7ea11c7
    --- /dev/null
    +++ b/vendor/nikic/php-parser/test/code/parser/expr/arrayDef.test
    @@ -0,0 +1,139 @@
    +Array definitions
    +-----
    + 'd', 'e' => &$f);
    +
    +// short array syntax
    +[];
    +[1, 2, 3];
    +['a' => 'b'];
    +-----
    +array(
    +    0: Expr_Array(
    +        items: array(
    +        )
    +    )
    +    1: Expr_Array(
    +        items: array(
    +            0: Expr_ArrayItem(
    +                key: null
    +                value: Scalar_String(
    +                    value: a
    +                )
    +                byRef: false
    +            )
    +        )
    +    )
    +    2: Expr_Array(
    +        items: array(
    +            0: Expr_ArrayItem(
    +                key: null
    +                value: Scalar_String(
    +                    value: a
    +                )
    +                byRef: false
    +            )
    +        )
    +    )
    +    3: Expr_Array(
    +        items: array(
    +            0: Expr_ArrayItem(
    +                key: null
    +                value: Scalar_String(
    +                    value: a
    +                )
    +                byRef: false
    +            )
    +            1: Expr_ArrayItem(
    +                key: null
    +                value: Scalar_String(
    +                    value: b
    +                )
    +                byRef: false
    +            )
    +        )
    +    )
    +    4: Expr_Array(
    +        items: array(
    +            0: Expr_ArrayItem(
    +                key: null
    +                value: Scalar_String(
    +                    value: a
    +                )
    +                byRef: false
    +            )
    +            1: Expr_ArrayItem(
    +                key: null
    +                value: Expr_Variable(
    +                    name: b
    +                )
    +                byRef: true
    +            )
    +            2: Expr_ArrayItem(
    +                key: Scalar_String(
    +                    value: c
    +                )
    +                value: Scalar_String(
    +                    value: d
    +                )
    +                byRef: false
    +            )
    +            3: Expr_ArrayItem(
    +                key: Scalar_String(
    +                    value: e
    +                )
    +                value: Expr_Variable(
    +                    name: f
    +                )
    +                byRef: true
    +            )
    +        )
    +    )
    +    5: Expr_Array(
    +        items: array(
    +        )
    +    )
    +    6: Expr_Array(
    +        items: array(
    +            0: Expr_ArrayItem(
    +                key: null
    +                value: Scalar_LNumber(
    +                    value: 1
    +                )
    +                byRef: false
    +            )
    +            1: Expr_ArrayItem(
    +                key: null
    +                value: Scalar_LNumber(
    +                    value: 2
    +                )
    +                byRef: false
    +            )
    +            2: Expr_ArrayItem(
    +                key: null
    +                value: Scalar_LNumber(
    +                    value: 3
    +                )
    +                byRef: false
    +            )
    +        )
    +    )
    +    7: Expr_Array(
    +        items: array(
    +            0: Expr_ArrayItem(
    +                key: Scalar_String(
    +                    value: a
    +                )
    +                value: Scalar_String(
    +                    value: b
    +                )
    +                byRef: false
    +            )
    +        )
    +    )
    +)
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/test/code/parser/expr/assign.test b/vendor/nikic/php-parser/test/code/parser/expr/assign.test
    new file mode 100755
    index 0000000..e6916ad
    --- /dev/null
    +++ b/vendor/nikic/php-parser/test/code/parser/expr/assign.test
    @@ -0,0 +1,225 @@
    +Assignments
    +-----
    +>= $b;
    +
    +// by ref assign
    +$a =& $b;
    +$a =& new B;
    +
    +// list() assign
    +list($a) = $b;
    +list($a, , $b) = $c;
    +list($a, list(, $c), $d) = $e;
    +
    +// inc/dec
    +++$a;
    +$a++;
    +--$a;
    +$a--;
    +-----
    +array(
    +    0: Expr_Assign(
    +        var: Expr_Variable(
    +            name: a
    +        )
    +        expr: Expr_Variable(
    +            name: b
    +        )
    +    )
    +    1: Expr_AssignBitwiseAnd(
    +        var: Expr_Variable(
    +            name: a
    +        )
    +        expr: Expr_Variable(
    +            name: b
    +        )
    +    )
    +    2: Expr_AssignBitwiseOr(
    +        var: Expr_Variable(
    +            name: a
    +        )
    +        expr: Expr_Variable(
    +            name: b
    +        )
    +    )
    +    3: Expr_AssignBitwiseXor(
    +        var: Expr_Variable(
    +            name: a
    +        )
    +        expr: Expr_Variable(
    +            name: b
    +        )
    +    )
    +    4: Expr_AssignConcat(
    +        var: Expr_Variable(
    +            name: a
    +        )
    +        expr: Expr_Variable(
    +            name: b
    +        )
    +    )
    +    5: Expr_AssignDiv(
    +        var: Expr_Variable(
    +            name: a
    +        )
    +        expr: Expr_Variable(
    +            name: b
    +        )
    +    )
    +    6: Expr_AssignMinus(
    +        var: Expr_Variable(
    +            name: a
    +        )
    +        expr: Expr_Variable(
    +            name: b
    +        )
    +    )
    +    7: Expr_AssignMod(
    +        var: Expr_Variable(
    +            name: a
    +        )
    +        expr: Expr_Variable(
    +            name: b
    +        )
    +    )
    +    8: Expr_AssignMul(
    +        var: Expr_Variable(
    +            name: a
    +        )
    +        expr: Expr_Variable(
    +            name: b
    +        )
    +    )
    +    9: Expr_AssignPlus(
    +        var: Expr_Variable(
    +            name: a
    +        )
    +        expr: Expr_Variable(
    +            name: b
    +        )
    +    )
    +    10: Expr_AssignShiftLeft(
    +        var: Expr_Variable(
    +            name: a
    +        )
    +        expr: Expr_Variable(
    +            name: b
    +        )
    +    )
    +    11: Expr_AssignShiftRight(
    +        var: Expr_Variable(
    +            name: a
    +        )
    +        expr: Expr_Variable(
    +            name: b
    +        )
    +    )
    +    12: Expr_AssignRef(
    +        var: Expr_Variable(
    +            name: a
    +        )
    +        expr: Expr_Variable(
    +            name: b
    +        )
    +    )
    +    13: Expr_AssignRef(
    +        var: Expr_Variable(
    +            name: a
    +        )
    +        expr: Expr_New(
    +            class: Name(
    +                parts: array(
    +                    0: B
    +                )
    +            )
    +            args: array(
    +            )
    +        )
    +    )
    +    14: Expr_Assign(
    +        var: Expr_List(
    +            vars: array(
    +                0: Expr_Variable(
    +                    name: a
    +                )
    +            )
    +        )
    +        expr: Expr_Variable(
    +            name: b
    +        )
    +    )
    +    15: Expr_Assign(
    +        var: Expr_List(
    +            vars: array(
    +                0: Expr_Variable(
    +                    name: a
    +                )
    +                1: null
    +                2: Expr_Variable(
    +                    name: b
    +                )
    +            )
    +        )
    +        expr: Expr_Variable(
    +            name: c
    +        )
    +    )
    +    16: Expr_Assign(
    +        var: Expr_List(
    +            vars: array(
    +                0: Expr_Variable(
    +                    name: a
    +                )
    +                1: Expr_List(
    +                    vars: array(
    +                        0: null
    +                        1: Expr_Variable(
    +                            name: c
    +                        )
    +                    )
    +                )
    +                2: Expr_Variable(
    +                    name: d
    +                )
    +            )
    +        )
    +        expr: Expr_Variable(
    +            name: e
    +        )
    +    )
    +    17: Expr_PreInc(
    +        var: Expr_Variable(
    +            name: a
    +        )
    +    )
    +    18: Expr_PostInc(
    +        var: Expr_Variable(
    +            name: a
    +        )
    +    )
    +    19: Expr_PreDec(
    +        var: Expr_Variable(
    +            name: a
    +        )
    +    )
    +    20: Expr_PostDec(
    +        var: Expr_Variable(
    +            name: a
    +        )
    +    )
    +)
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/test/code/parser/expr/cast.test b/vendor/nikic/php-parser/test/code/parser/expr/cast.test
    new file mode 100755
    index 0000000..3c54ba7
    --- /dev/null
    +++ b/vendor/nikic/php-parser/test/code/parser/expr/cast.test
    @@ -0,0 +1,72 @@
    +Casts
    +-----
    + $b;
    +$a >= $b;
    +$a == $b;
    +$a === $b;
    +$a != $b;
    +$a !== $b;
    +$a instanceof B;
    +$a instanceof $b;
    +-----
    +array(
    +    0: Expr_Smaller(
    +        left: Expr_Variable(
    +            name: a
    +        )
    +        right: Expr_Variable(
    +            name: b
    +        )
    +    )
    +    1: Expr_SmallerOrEqual(
    +        left: Expr_Variable(
    +            name: a
    +        )
    +        right: Expr_Variable(
    +            name: b
    +        )
    +    )
    +    2: Expr_Greater(
    +        left: Expr_Variable(
    +            name: a
    +        )
    +        right: Expr_Variable(
    +            name: b
    +        )
    +    )
    +    3: Expr_GreaterOrEqual(
    +        left: Expr_Variable(
    +            name: a
    +        )
    +        right: Expr_Variable(
    +            name: b
    +        )
    +    )
    +    4: Expr_Equal(
    +        left: Expr_Variable(
    +            name: a
    +        )
    +        right: Expr_Variable(
    +            name: b
    +        )
    +    )
    +    5: Expr_Identical(
    +        left: Expr_Variable(
    +            name: a
    +        )
    +        right: Expr_Variable(
    +            name: b
    +        )
    +    )
    +    6: Expr_NotEqual(
    +        left: Expr_Variable(
    +            name: a
    +        )
    +        right: Expr_Variable(
    +            name: b
    +        )
    +    )
    +    7: Expr_NotIdentical(
    +        left: Expr_Variable(
    +            name: a
    +        )
    +        right: Expr_Variable(
    +            name: b
    +        )
    +    )
    +    8: Expr_Instanceof(
    +        expr: Expr_Variable(
    +            name: a
    +        )
    +        class: Name(
    +            parts: array(
    +                0: B
    +            )
    +        )
    +    )
    +    9: Expr_Instanceof(
    +        expr: Expr_Variable(
    +            name: a
    +        )
    +        class: Expr_Variable(
    +            name: b
    +        )
    +    )
    +)
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/test/code/parser/expr/errorSuppress.test b/vendor/nikic/php-parser/test/code/parser/expr/errorSuppress.test
    new file mode 100755
    index 0000000..ce3fce9
    --- /dev/null
    +++ b/vendor/nikic/php-parser/test/code/parser/expr/errorSuppress.test
    @@ -0,0 +1,12 @@
    +Error suppression
    +-----
    +b['c']();
    +
    +// array dereferencing
    +a()['b'];
    +-----
    +array(
    +    0: Expr_FuncCall(
    +        name: Name(
    +            parts: array(
    +                0: a
    +            )
    +        )
    +        args: array(
    +        )
    +    )
    +    1: Expr_FuncCall(
    +        name: Expr_Variable(
    +            name: a
    +        )
    +        args: array(
    +        )
    +    )
    +    2: Expr_FuncCall(
    +        name: Expr_Variable(
    +            name: Scalar_String(
    +                value: a
    +            )
    +        )
    +        args: array(
    +        )
    +    )
    +    3: Expr_FuncCall(
    +        name: Expr_Variable(
    +            name: Expr_Variable(
    +                name: a
    +            )
    +        )
    +        args: array(
    +        )
    +    )
    +    4: Expr_FuncCall(
    +        name: Expr_Variable(
    +            name: Expr_Variable(
    +                name: Expr_Variable(
    +                    name: a
    +                )
    +            )
    +        )
    +        args: array(
    +        )
    +    )
    +    5: Expr_FuncCall(
    +        name: Expr_ArrayDimFetch(
    +            var: Expr_Variable(
    +                name: a
    +            )
    +            dim: Scalar_String(
    +                value: b
    +            )
    +        )
    +        args: array(
    +        )
    +    )
    +    6: Expr_FuncCall(
    +        name: Expr_ArrayDimFetch(
    +            var: Expr_Variable(
    +                name: a
    +            )
    +            dim: Scalar_String(
    +                value: b
    +            )
    +        )
    +        args: array(
    +        )
    +    )
    +    7: Expr_FuncCall(
    +        name: Expr_ArrayDimFetch(
    +            var: Expr_PropertyFetch(
    +                var: Expr_Variable(
    +                    name: a
    +                )
    +                name: b
    +            )
    +            dim: Scalar_String(
    +                value: c
    +            )
    +        )
    +        args: array(
    +        )
    +    )
    +    8: Expr_ArrayDimFetch(
    +        var: Expr_FuncCall(
    +            name: Name(
    +                parts: array(
    +                    0: a
    +                )
    +            )
    +            args: array(
    +            )
    +        )
    +        dim: Scalar_String(
    +            value: b
    +        )
    +    )
    +)
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/test/code/parser/expr/fetchAndCall/newDeref.test b/vendor/nikic/php-parser/test/code/parser/expr/fetchAndCall/newDeref.test
    new file mode 100755
    index 0000000..5e36ff8
    --- /dev/null
    +++ b/vendor/nikic/php-parser/test/code/parser/expr/fetchAndCall/newDeref.test
    @@ -0,0 +1,70 @@
    +New expression dereferencing
    +-----
    +b;
    +(new A)->b();
    +(new A)['b'];
    +(new A)['b']['c'];
    +-----
    +array(
    +    0: Expr_PropertyFetch(
    +        var: Expr_New(
    +            class: Name(
    +                parts: array(
    +                    0: A
    +                )
    +            )
    +            args: array(
    +            )
    +        )
    +        name: b
    +    )
    +    1: Expr_MethodCall(
    +        var: Expr_New(
    +            class: Name(
    +                parts: array(
    +                    0: A
    +                )
    +            )
    +            args: array(
    +            )
    +        )
    +        name: b
    +        args: array(
    +        )
    +    )
    +    2: Expr_ArrayDimFetch(
    +        var: Expr_New(
    +            class: Name(
    +                parts: array(
    +                    0: A
    +                )
    +            )
    +            args: array(
    +            )
    +        )
    +        dim: Scalar_String(
    +            value: b
    +        )
    +    )
    +    3: Expr_ArrayDimFetch(
    +        var: Expr_ArrayDimFetch(
    +            var: Expr_New(
    +                class: Name(
    +                    parts: array(
    +                        0: A
    +                    )
    +                )
    +                args: array(
    +                )
    +            )
    +            dim: Scalar_String(
    +                value: b
    +            )
    +        )
    +        dim: Scalar_String(
    +            value: c
    +        )
    +    )
    +)
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/test/code/parser/expr/fetchAndCall/objectAccess.test b/vendor/nikic/php-parser/test/code/parser/expr/fetchAndCall/objectAccess.test
    new file mode 100755
    index 0000000..9dd1858
    --- /dev/null
    +++ b/vendor/nikic/php-parser/test/code/parser/expr/fetchAndCall/objectAccess.test
    @@ -0,0 +1,118 @@
    +Object access
    +-----
    +b;
    +$a->b['c'];
    +$a->b{'c'};
    +
    +// method call variations
    +$a->b();
    +$a->{'b'}();
    +$a->$b();
    +$a->$b['c']();
    +
    +// array dereferencing
    +$a->b()['c'];
    +$a->b(){'c'}; // invalid PHP: drop Support?
    +-----
    +array(
    +    0: Expr_PropertyFetch(
    +        var: Expr_Variable(
    +            name: a
    +        )
    +        name: b
    +    )
    +    1: Expr_ArrayDimFetch(
    +        var: Expr_PropertyFetch(
    +            var: Expr_Variable(
    +                name: a
    +            )
    +            name: b
    +        )
    +        dim: Scalar_String(
    +            value: c
    +        )
    +    )
    +    2: Expr_ArrayDimFetch(
    +        var: Expr_PropertyFetch(
    +            var: Expr_Variable(
    +                name: a
    +            )
    +            name: b
    +        )
    +        dim: Scalar_String(
    +            value: c
    +        )
    +    )
    +    3: Expr_MethodCall(
    +        var: Expr_Variable(
    +            name: a
    +        )
    +        name: b
    +        args: array(
    +        )
    +    )
    +    4: Expr_MethodCall(
    +        var: Expr_Variable(
    +            name: a
    +        )
    +        name: Scalar_String(
    +            value: b
    +        )
    +        args: array(
    +        )
    +    )
    +    5: Expr_MethodCall(
    +        var: Expr_Variable(
    +            name: a
    +        )
    +        name: Expr_Variable(
    +            name: b
    +        )
    +        args: array(
    +        )
    +    )
    +    6: Expr_MethodCall(
    +        var: Expr_Variable(
    +            name: a
    +        )
    +        name: Expr_ArrayDimFetch(
    +            var: Expr_Variable(
    +                name: b
    +            )
    +            dim: Scalar_String(
    +                value: c
    +            )
    +        )
    +        args: array(
    +        )
    +    )
    +    7: Expr_ArrayDimFetch(
    +        var: Expr_MethodCall(
    +            var: Expr_Variable(
    +                name: a
    +            )
    +            name: b
    +            args: array(
    +            )
    +        )
    +        dim: Scalar_String(
    +            value: c
    +        )
    +    )
    +    8: Expr_ArrayDimFetch(
    +        var: Expr_MethodCall(
    +            var: Expr_Variable(
    +                name: a
    +            )
    +            name: b
    +            args: array(
    +            )
    +        )
    +        dim: Scalar_String(
    +            value: c
    +        )
    +    )
    +)
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/test/code/parser/expr/fetchAndCall/simpleArrayAccess.test b/vendor/nikic/php-parser/test/code/parser/expr/fetchAndCall/simpleArrayAccess.test
    new file mode 100755
    index 0000000..ea3f9ef
    --- /dev/null
    +++ b/vendor/nikic/php-parser/test/code/parser/expr/fetchAndCall/simpleArrayAccess.test
    @@ -0,0 +1,62 @@
    +Simple array access
    +-----
    +> $b;
    +
    +// associativity
    +$a * $b * $c;
    +$a * ($b * $c);
    +
    +// precedence
    +$a + $b * $c;
    +($a + $b) * $c;
    +-----
    +array(
    +    0: Expr_BitwiseNot(
    +        expr: Expr_Variable(
    +            name: a
    +        )
    +    )
    +    1: Expr_UnaryPlus(
    +        expr: Expr_Variable(
    +            name: a
    +        )
    +    )
    +    2: Expr_UnaryMinus(
    +        expr: Expr_Variable(
    +            name: a
    +        )
    +    )
    +    3: Expr_BitwiseAnd(
    +        left: Expr_Variable(
    +            name: a
    +        )
    +        right: Expr_Variable(
    +            name: b
    +        )
    +    )
    +    4: Expr_BitwiseOr(
    +        left: Expr_Variable(
    +            name: a
    +        )
    +        right: Expr_Variable(
    +            name: b
    +        )
    +    )
    +    5: Expr_BitwiseXor(
    +        left: Expr_Variable(
    +            name: a
    +        )
    +        right: Expr_Variable(
    +            name: b
    +        )
    +    )
    +    6: Expr_Concat(
    +        left: Expr_Variable(
    +            name: a
    +        )
    +        right: Expr_Variable(
    +            name: b
    +        )
    +    )
    +    7: Expr_Div(
    +        left: Expr_Variable(
    +            name: a
    +        )
    +        right: Expr_Variable(
    +            name: b
    +        )
    +    )
    +    8: Expr_Minus(
    +        left: Expr_Variable(
    +            name: a
    +        )
    +        right: Expr_Variable(
    +            name: b
    +        )
    +    )
    +    9: Expr_Mod(
    +        left: Expr_Variable(
    +            name: a
    +        )
    +        right: Expr_Variable(
    +            name: b
    +        )
    +    )
    +    10: Expr_Mul(
    +        left: Expr_Variable(
    +            name: a
    +        )
    +        right: Expr_Variable(
    +            name: b
    +        )
    +    )
    +    11: Expr_Plus(
    +        left: Expr_Variable(
    +            name: a
    +        )
    +        right: Expr_Variable(
    +            name: b
    +        )
    +    )
    +    12: Expr_ShiftLeft(
    +        left: Expr_Variable(
    +            name: a
    +        )
    +        right: Expr_Variable(
    +            name: b
    +        )
    +    )
    +    13: Expr_ShiftRight(
    +        left: Expr_Variable(
    +            name: a
    +        )
    +        right: Expr_Variable(
    +            name: b
    +        )
    +    )
    +    14: Expr_Mul(
    +        left: Expr_Mul(
    +            left: Expr_Variable(
    +                name: a
    +            )
    +            right: Expr_Variable(
    +                name: b
    +            )
    +        )
    +        right: Expr_Variable(
    +            name: c
    +        )
    +    )
    +    15: Expr_Mul(
    +        left: Expr_Variable(
    +            name: a
    +        )
    +        right: Expr_Mul(
    +            left: Expr_Variable(
    +                name: b
    +            )
    +            right: Expr_Variable(
    +                name: c
    +            )
    +        )
    +    )
    +    16: Expr_Plus(
    +        left: Expr_Variable(
    +            name: a
    +        )
    +        right: Expr_Mul(
    +            left: Expr_Variable(
    +                name: b
    +            )
    +            right: Expr_Variable(
    +                name: c
    +            )
    +        )
    +    )
    +    17: Expr_Mul(
    +        left: Expr_Plus(
    +            left: Expr_Variable(
    +                name: a
    +            )
    +            right: Expr_Variable(
    +                name: b
    +            )
    +        )
    +        right: Expr_Variable(
    +            name: c
    +        )
    +    )
    +)
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/test/code/parser/expr/new.test b/vendor/nikic/php-parser/test/code/parser/expr/new.test
    new file mode 100755
    index 0000000..daca29c
    --- /dev/null
    +++ b/vendor/nikic/php-parser/test/code/parser/expr/new.test
    @@ -0,0 +1,139 @@
    +New
    +-----
    +b();
    +new $a->b->c();
    +new $a->b['c']();
    +new $a->b{'c'}();
    +
    +// test regression introduces by new dereferencing syntax
    +(new A);
    +-----
    +array(
    +    0: Expr_New(
    +        class: Name(
    +            parts: array(
    +                0: A
    +            )
    +        )
    +        args: array(
    +        )
    +    )
    +    1: Expr_New(
    +        class: Name(
    +            parts: array(
    +                0: A
    +            )
    +        )
    +        args: array(
    +            0: Arg(
    +                value: Expr_Variable(
    +                    name: b
    +                )
    +                byRef: false
    +            )
    +        )
    +    )
    +    2: Expr_New(
    +        class: Expr_Variable(
    +            name: a
    +        )
    +        args: array(
    +        )
    +    )
    +    3: Expr_New(
    +        class: Expr_ArrayDimFetch(
    +            var: Expr_Variable(
    +                name: a
    +            )
    +            dim: Scalar_String(
    +                value: b
    +            )
    +        )
    +        args: array(
    +        )
    +    )
    +    4: Expr_New(
    +        class: Expr_StaticPropertyFetch(
    +            class: Name(
    +                parts: array(
    +                    0: A
    +                )
    +            )
    +            name: b
    +        )
    +        args: array(
    +        )
    +    )
    +    5: Expr_New(
    +        class: Expr_PropertyFetch(
    +            var: Expr_Variable(
    +                name: a
    +            )
    +            name: b
    +        )
    +        args: array(
    +        )
    +    )
    +    6: Expr_New(
    +        class: Expr_PropertyFetch(
    +            var: Expr_PropertyFetch(
    +                var: Expr_Variable(
    +                    name: a
    +                )
    +                name: b
    +            )
    +            name: c
    +        )
    +        args: array(
    +        )
    +    )
    +    7: Expr_New(
    +        class: Expr_ArrayDimFetch(
    +            var: Expr_PropertyFetch(
    +                var: Expr_Variable(
    +                    name: a
    +                )
    +                name: b
    +            )
    +            dim: Scalar_String(
    +                value: c
    +            )
    +        )
    +        args: array(
    +        )
    +    )
    +    8: Expr_New(
    +        class: Expr_ArrayDimFetch(
    +            var: Expr_PropertyFetch(
    +                var: Expr_Variable(
    +                    name: a
    +                )
    +                name: b
    +            )
    +            dim: Scalar_String(
    +                value: c
    +            )
    +        )
    +        args: array(
    +        )
    +    )
    +    9: Expr_New(
    +        class: Name(
    +            parts: array(
    +                0: A
    +            )
    +        )
    +        args: array(
    +        )
    +    )
    +)
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/test/code/parser/expr/print.test b/vendor/nikic/php-parser/test/code/parser/expr/print.test
    new file mode 100755
    index 0000000..d07afda
    --- /dev/null
    +++ b/vendor/nikic/php-parser/test/code/parser/expr/print.test
    @@ -0,0 +1,12 @@
    +Print
    +-----
    +c test
    +EOS;
    +
    +// comment to force line break before EOF
    +-----
    +array(
    +    0: Scalar_String(
    +        value:
    +    )
    +    1: Scalar_String(
    +        value:
    +    )
    +    2: Scalar_String(
    +        value: Test '" $a \n
    +    )
    +    3: Scalar_String(
    +        value: Test '" $a
    +
    +    )
    +    4: Scalar_Encapsed(
    +        parts: array(
    +            0: Test
    +            1: Expr_Variable(
    +                name: a
    +            )
    +        )
    +    )
    +    5: Scalar_Encapsed(
    +        parts: array(
    +            0: Test
    +            1: Expr_Variable(
    +                name: a
    +            )
    +            2:  and
    +            3: Expr_PropertyFetch(
    +                var: Expr_Variable(
    +                    name: b
    +                )
    +                name: c
    +            )
    +            4:  test
    +        )
    +    )
    +)
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/test/code/parser/scalar/encapsedString.test b/vendor/nikic/php-parser/test/code/parser/scalar/encapsedString.test
    new file mode 100755
    index 0000000..717f844
    --- /dev/null
    +++ b/vendor/nikic/php-parser/test/code/parser/scalar/encapsedString.test
    @@ -0,0 +1,148 @@
    +Encapsed strings
    +-----
    +B";
    +"$A[B]";
    +"$A[0]";
    +"$A[0x0]";
    +"$A[$B]";
    +"{$A}";
    +"{$A['B']}";
    +"${A}";
    +"${A['B']}";
    +"${$A}";
    +"A $B C";
    +b"$A";
    +-----
    +array(
    +    0: Scalar_Encapsed(
    +        parts: array(
    +            0: Expr_Variable(
    +                name: A
    +            )
    +        )
    +    )
    +    1: Scalar_Encapsed(
    +        parts: array(
    +            0: Expr_PropertyFetch(
    +                var: Expr_Variable(
    +                    name: A
    +                )
    +                name: B
    +            )
    +        )
    +    )
    +    2: Scalar_Encapsed(
    +        parts: array(
    +            0: Expr_ArrayDimFetch(
    +                var: Expr_Variable(
    +                    name: A
    +                )
    +                dim: Scalar_String(
    +                    value: B
    +                )
    +            )
    +        )
    +    )
    +    3: Scalar_Encapsed(
    +        parts: array(
    +            0: Expr_ArrayDimFetch(
    +                var: Expr_Variable(
    +                    name: A
    +                )
    +                dim: Scalar_String(
    +                    value: 0
    +                )
    +            )
    +        )
    +    )
    +    4: Scalar_Encapsed(
    +        parts: array(
    +            0: Expr_ArrayDimFetch(
    +                var: Expr_Variable(
    +                    name: A
    +                )
    +                dim: Scalar_String(
    +                    value: 0x0
    +                )
    +            )
    +        )
    +    )
    +    5: Scalar_Encapsed(
    +        parts: array(
    +            0: Expr_ArrayDimFetch(
    +                var: Expr_Variable(
    +                    name: A
    +                )
    +                dim: Expr_Variable(
    +                    name: B
    +                )
    +            )
    +        )
    +    )
    +    6: Scalar_Encapsed(
    +        parts: array(
    +            0: Expr_Variable(
    +                name: A
    +            )
    +        )
    +    )
    +    7: Scalar_Encapsed(
    +        parts: array(
    +            0: Expr_ArrayDimFetch(
    +                var: Expr_Variable(
    +                    name: A
    +                )
    +                dim: Scalar_String(
    +                    value: B
    +                )
    +            )
    +        )
    +    )
    +    8: Scalar_Encapsed(
    +        parts: array(
    +            0: Expr_Variable(
    +                name: A
    +            )
    +        )
    +    )
    +    9: Scalar_Encapsed(
    +        parts: array(
    +            0: Expr_ArrayDimFetch(
    +                var: Expr_Variable(
    +                    name: A
    +                )
    +                dim: Scalar_String(
    +                    value: B
    +                )
    +            )
    +        )
    +    )
    +    10: Scalar_Encapsed(
    +        parts: array(
    +            0: Expr_Variable(
    +                name: Expr_Variable(
    +                    name: A
    +                )
    +            )
    +        )
    +    )
    +    11: Scalar_Encapsed(
    +        parts: array(
    +            0: A
    +            1: Expr_Variable(
    +                name: B
    +            )
    +            2:  C
    +        )
    +    )
    +    12: Scalar_Encapsed(
    +        parts: array(
    +            0: Expr_Variable(
    +                name: A
    +            )
    +        )
    +    )
    +)
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/test/code/parser/scalar/float.test b/vendor/nikic/php-parser/test/code/parser/scalar/float.test
    new file mode 100755
    index 0000000..c91b7ac
    --- /dev/null
    +++ b/vendor/nikic/php-parser/test/code/parser/scalar/float.test
    @@ -0,0 +1,70 @@
    +Different float syntaxes
    +-----
    + float overflows
    +// (all are actually the same number, just in different representations)
    +18446744073709551615;
    +0xFFFFFFFFFFFFFFFF;
    +01777777777777777777777;
    +0177777777777777777777787;
    +0b1111111111111111111111111111111111111111111111111111111111111111;
    +-----
    +array(
    +    0: Scalar_DNumber(
    +        value: 0
    +    )
    +    1: Scalar_DNumber(
    +        value: 0
    +    )
    +    2: Scalar_DNumber(
    +        value: 0
    +    )
    +    3: Scalar_DNumber(
    +        value: 0
    +    )
    +    4: Scalar_DNumber(
    +        value: 0
    +    )
    +    5: Scalar_DNumber(
    +        value: 0
    +    )
    +    6: Scalar_DNumber(
    +        value: 0
    +    )
    +    7: Scalar_DNumber(
    +        value: 302000000000
    +    )
    +    8: Scalar_DNumber(
    +        value: 3.002E+102
    +    )
    +    9: Scalar_DNumber(
    +        value: INF
    +    )
    +    10: Scalar_DNumber(
    +        value: @@{ 0xFFFFFFFFFFFFFFFF }@@
    +    )
    +    11: Scalar_DNumber(
    +        value: @@{ 0xFFFFFFFFFFFFFFFF }@@
    +    )
    +    12: Scalar_DNumber(
    +        value: @@{ 0xFFFFFFFFFFFFFFFF }@@
    +    )
    +    13: Scalar_DNumber(
    +        value: @@{ 0xFFFFFFFFFFFFFFFF }@@
    +    )
    +    14: Scalar_DNumber(
    +        value: @@{ 0xFFFFFFFFFFFFFFFF }@@
    +    )
    +)
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/test/code/parser/scalar/int.test b/vendor/nikic/php-parser/test/code/parser/scalar/int.test
    new file mode 100755
    index 0000000..17a5785
    --- /dev/null
    +++ b/vendor/nikic/php-parser/test/code/parser/scalar/int.test
    @@ -0,0 +1,47 @@
    +Different integer syntaxes
    +-----
    + 'baz']
    +) {}
    +-----
    +array(
    +    0: Stmt_Function(
    +        byRef: false
    +        params: array(
    +            0: Param(
    +                name: b
    +                default: Expr_ConstFetch(
    +                    name: Name(
    +                        parts: array(
    +                            0: null
    +                        )
    +                    )
    +                )
    +                type: null
    +                byRef: false
    +            )
    +            1: Param(
    +                name: c
    +                default: Scalar_String(
    +                    value: foo
    +                )
    +                type: null
    +                byRef: false
    +            )
    +            2: Param(
    +                name: d
    +                default: Expr_ClassConstFetch(
    +                    class: Name(
    +                        parts: array(
    +                            0: A
    +                        )
    +                    )
    +                    name: B
    +                )
    +                type: null
    +                byRef: false
    +            )
    +            3: Param(
    +                name: f
    +                default: Expr_UnaryPlus(
    +                    expr: Scalar_LNumber(
    +                        value: 1
    +                    )
    +                )
    +                type: null
    +                byRef: false
    +            )
    +            4: Param(
    +                name: g
    +                default: Expr_UnaryMinus(
    +                    expr: Scalar_DNumber(
    +                        value: 1
    +                    )
    +                )
    +                type: null
    +                byRef: false
    +            )
    +            5: Param(
    +                name: h
    +                default: Expr_Array(
    +                    items: array(
    +                    )
    +                )
    +                type: null
    +                byRef: false
    +            )
    +            6: Param(
    +                name: i
    +                default: Expr_Array(
    +                    items: array(
    +                    )
    +                )
    +                type: null
    +                byRef: false
    +            )
    +            7: Param(
    +                name: j
    +                default: Expr_Array(
    +                    items: array(
    +                        0: Expr_ArrayItem(
    +                            key: null
    +                            value: Scalar_String(
    +                                value: foo
    +                            )
    +                            byRef: false
    +                        )
    +                    )
    +                )
    +                type: null
    +                byRef: false
    +            )
    +            8: Param(
    +                name: k
    +                default: Expr_Array(
    +                    items: array(
    +                        0: Expr_ArrayItem(
    +                            key: null
    +                            value: Scalar_String(
    +                                value: foo
    +                            )
    +                            byRef: false
    +                        )
    +                        1: Expr_ArrayItem(
    +                            key: Scalar_String(
    +                                value: bar
    +                            )
    +                            value: Scalar_String(
    +                                value: baz
    +                            )
    +                            byRef: false
    +                        )
    +                    )
    +                )
    +                type: null
    +                byRef: false
    +            )
    +        )
    +        stmts: array(
    +        )
    +        name: a
    +    )
    +)
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/test/code/parser/stmt/function/generator.test b/vendor/nikic/php-parser/test/code/parser/stmt/function/generator.test
    new file mode 100755
    index 0000000..e5a5716
    --- /dev/null
    +++ b/vendor/nikic/php-parser/test/code/parser/stmt/function/generator.test
    @@ -0,0 +1,227 @@
    +Generators (yield expression
    +-----
    + $value;
    +
    +    // expressions
    +    $data = yield;
    +    $data = (yield $value);
    +    $data = (yield $key => $value);
    +
    +    // yield in language constructs with their own parentheses
    +    if (yield $foo); elseif (yield $foo);
    +    if (yield $foo): elseif (yield $foo): endif;
    +    while (yield $foo);
    +    do {} while (yield $foo);
    +    switch (yield $foo) {}
    +    die(yield $foo);
    +
    +    // yield in function calls
    +    func(yield $foo);
    +    $foo->func(yield $foo);
    +    new Foo(yield $foo);
    +}
    +-----
    +array(
    +    0: Stmt_Function(
    +        byRef: false
    +        params: array(
    +        )
    +        stmts: array(
    +            0: Expr_Yield(
    +                key: null
    +                value: null
    +            )
    +            1: Expr_Yield(
    +                key: null
    +                value: Expr_Variable(
    +                    name: value
    +                )
    +            )
    +            2: Expr_Yield(
    +                key: Expr_Variable(
    +                    name: key
    +                )
    +                value: Expr_Variable(
    +                    name: value
    +                )
    +            )
    +            3: Expr_Assign(
    +                var: Expr_Variable(
    +                    name: data
    +                )
    +                expr: Expr_Yield(
    +                    key: null
    +                    value: null
    +                )
    +            )
    +            4: Expr_Assign(
    +                var: Expr_Variable(
    +                    name: data
    +                )
    +                expr: Expr_Yield(
    +                    key: null
    +                    value: Expr_Variable(
    +                        name: value
    +                    )
    +                )
    +            )
    +            5: Expr_Assign(
    +                var: Expr_Variable(
    +                    name: data
    +                )
    +                expr: Expr_Yield(
    +                    key: Expr_Variable(
    +                        name: key
    +                    )
    +                    value: Expr_Variable(
    +                        name: value
    +                    )
    +                )
    +            )
    +            6: Stmt_If(
    +                stmts: array(
    +                )
    +                elseifs: array(
    +                    0: Stmt_ElseIf(
    +                        cond: Expr_Yield(
    +                            key: null
    +                            value: Expr_Variable(
    +                                name: foo
    +                            )
    +                        )
    +                        stmts: array(
    +                        )
    +                    )
    +                )
    +                else: null
    +                cond: Expr_Yield(
    +                    key: null
    +                    value: Expr_Variable(
    +                        name: foo
    +                    )
    +                )
    +            )
    +            7: Stmt_If(
    +                stmts: array(
    +                )
    +                elseifs: array(
    +                    0: Stmt_ElseIf(
    +                        cond: Expr_Yield(
    +                            key: null
    +                            value: Expr_Variable(
    +                                name: foo
    +                            )
    +                        )
    +                        stmts: array(
    +                        )
    +                    )
    +                )
    +                else: null
    +                cond: Expr_Yield(
    +                    key: null
    +                    value: Expr_Variable(
    +                        name: foo
    +                    )
    +                )
    +            )
    +            8: Stmt_While(
    +                cond: Expr_Yield(
    +                    key: null
    +                    value: Expr_Variable(
    +                        name: foo
    +                    )
    +                )
    +                stmts: array(
    +                )
    +            )
    +            9: Stmt_Do(
    +                cond: Expr_Yield(
    +                    key: null
    +                    value: Expr_Variable(
    +                        name: foo
    +                    )
    +                )
    +                stmts: array(
    +                )
    +            )
    +            10: Stmt_Switch(
    +                cond: Expr_Yield(
    +                    key: null
    +                    value: Expr_Variable(
    +                        name: foo
    +                    )
    +                )
    +                cases: array(
    +                )
    +            )
    +            11: Expr_Exit(
    +                expr: Expr_Yield(
    +                    key: null
    +                    value: Expr_Variable(
    +                        name: foo
    +                    )
    +                )
    +            )
    +            12: Expr_FuncCall(
    +                name: Name(
    +                    parts: array(
    +                        0: func
    +                    )
    +                )
    +                args: array(
    +                    0: Arg(
    +                        value: Expr_Yield(
    +                            key: null
    +                            value: Expr_Variable(
    +                                name: foo
    +                            )
    +                        )
    +                        byRef: false
    +                    )
    +                )
    +            )
    +            13: Expr_MethodCall(
    +                var: Expr_Variable(
    +                    name: foo
    +                )
    +                name: func
    +                args: array(
    +                    0: Arg(
    +                        value: Expr_Yield(
    +                            key: null
    +                            value: Expr_Variable(
    +                                name: foo
    +                            )
    +                        )
    +                        byRef: false
    +                    )
    +                )
    +            )
    +            14: Expr_New(
    +                class: Name(
    +                    parts: array(
    +                        0: Foo
    +                    )
    +                )
    +                args: array(
    +                    0: Arg(
    +                        value: Expr_Yield(
    +                            key: null
    +                            value: Expr_Variable(
    +                                name: foo
    +                            )
    +                        )
    +                        byRef: false
    +                    )
    +                )
    +            )
    +        )
    +        name: gen
    +    )
    +)
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/test/code/parser/stmt/function/specialVars.test b/vendor/nikic/php-parser/test/code/parser/stmt/function/specialVars.test
    new file mode 100755
    index 0000000..3670e55
    --- /dev/null
    +++ b/vendor/nikic/php-parser/test/code/parser/stmt/function/specialVars.test
    @@ -0,0 +1,50 @@
    +Special function variables
    +-----
    +
    +Hallo World!
    +-----
    +array(
    +    0: Expr_Variable(
    +        name: a
    +    )
    +    1: Stmt_HaltCompiler(
    +        remaining: Hallo World!
    +    )
    +)
    +-----
    +
    +B
    +
    + $c) {}
    +foreach ($a as $b => &$c) {}
    +foreach ($a as list($a, $b)) {}
    +foreach ($a as $a => list($b, , $c)) {}
    +
    +// foreach on expression
    +foreach (array() as $b) {}
    +
    +// alternative syntax
    +foreach ($a as $b):
    +endforeach;
    +-----
    +array(
    +    0: Stmt_Foreach(
    +        keyVar: null
    +        byRef: false
    +        stmts: array(
    +        )
    +        expr: Expr_Variable(
    +            name: a
    +        )
    +        valueVar: Expr_Variable(
    +            name: b
    +        )
    +    )
    +    1: Stmt_Foreach(
    +        keyVar: null
    +        byRef: true
    +        stmts: array(
    +        )
    +        expr: Expr_Variable(
    +            name: a
    +        )
    +        valueVar: Expr_Variable(
    +            name: b
    +        )
    +    )
    +    2: Stmt_Foreach(
    +        keyVar: Expr_Variable(
    +            name: b
    +        )
    +        byRef: false
    +        stmts: array(
    +        )
    +        expr: Expr_Variable(
    +            name: a
    +        )
    +        valueVar: Expr_Variable(
    +            name: c
    +        )
    +    )
    +    3: Stmt_Foreach(
    +        keyVar: Expr_Variable(
    +            name: b
    +        )
    +        byRef: true
    +        stmts: array(
    +        )
    +        expr: Expr_Variable(
    +            name: a
    +        )
    +        valueVar: Expr_Variable(
    +            name: c
    +        )
    +    )
    +    4: Stmt_Foreach(
    +        keyVar: null
    +        byRef: false
    +        stmts: array(
    +        )
    +        expr: Expr_Variable(
    +            name: a
    +        )
    +        valueVar: Expr_List(
    +            vars: array(
    +                0: Expr_Variable(
    +                    name: a
    +                )
    +                1: Expr_Variable(
    +                    name: b
    +                )
    +            )
    +        )
    +    )
    +    5: Stmt_Foreach(
    +        keyVar: Expr_Variable(
    +            name: a
    +        )
    +        byRef: false
    +        stmts: array(
    +        )
    +        expr: Expr_Variable(
    +            name: a
    +        )
    +        valueVar: Expr_List(
    +            vars: array(
    +                0: Expr_Variable(
    +                    name: b
    +                )
    +                1: null
    +                2: Expr_Variable(
    +                    name: c
    +                )
    +            )
    +        )
    +    )
    +    6: Stmt_Foreach(
    +        keyVar: null
    +        byRef: false
    +        stmts: array(
    +        )
    +        expr: Expr_Array(
    +            items: array(
    +            )
    +        )
    +        valueVar: Expr_Variable(
    +            name: b
    +        )
    +    )
    +    7: Stmt_Foreach(
    +        keyVar: null
    +        byRef: false
    +        stmts: array(
    +        )
    +        expr: Expr_Variable(
    +            name: a
    +        )
    +        valueVar: Expr_Variable(
    +            name: b
    +        )
    +    )
    +)
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/test/code/parser/stmt/loop/while.test b/vendor/nikic/php-parser/test/code/parser/stmt/loop/while.test
    new file mode 100755
    index 0000000..65f6b23
    --- /dev/null
    +++ b/vendor/nikic/php-parser/test/code/parser/stmt/loop/while.test
    @@ -0,0 +1,25 @@
    +While loop
    +-----
    +
    +Hi!
    +-----
    +array(
    +    0: Stmt_Declare(
    +        declares: array(
    +            0: Stmt_DeclareDeclare(
    +                key: A
    +                value: Scalar_String(
    +                    value: B
    +                )
    +            )
    +        )
    +        stmts: array(
    +        )
    +    )
    +    1: Stmt_Namespace(
    +        name: Name(
    +            parts: array(
    +                0: B
    +            )
    +        )
    +        stmts: array(
    +        )
    +    )
    +    2: Stmt_HaltCompiler(
    +        remaining: Hi!
    +    )
    +)
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/test/code/parser/stmt/namespace/outsideStmt.test-fail b/vendor/nikic/php-parser/test/code/parser/stmt/namespace/outsideStmt.test-fail
    new file mode 100755
    index 0000000..98c0460
    --- /dev/null
    +++ b/vendor/nikic/php-parser/test/code/parser/stmt/namespace/outsideStmt.test-fail
    @@ -0,0 +1,13 @@
    +There (mostly) can't be statements outside of namespaces
    +-----
    +
    +HTML
    +-----
    +
    +HTML
    +-----
    +HTML
    +
    +HTML
    +-----
    +HTML
    +
    +HTML
    +-----
    +HTML
    +
    +HTML
    +
    +HTML
    +-----
    +HTML
    +
    +HTML
    +
    +HTML
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/test/code/prettyPrinter/namespaces.test b/vendor/nikic/php-parser/test/code/prettyPrinter/namespaces.test
    new file mode 100755
    index 0000000..82bbf6d
    --- /dev/null
    +++ b/vendor/nikic/php-parser/test/code/prettyPrinter/namespaces.test
    @@ -0,0 +1,58 @@
    +Namespaces
    +-----
    + 0) > (1 < 0);
    +
    +// this will currently unnecessarily print !($a = $b). This is correct as far as operator precedence is concerned, but
    +// the parentheses are not really necessary, because = takes only variables as the left hand side operator.
    +!$a = $b;
    +-----
    +echo 'abc' . 'cde' . 'fgh';
    +echo 'abc' . ('cde' . 'fgh');
    +echo 'abc' . 1 + 2 . 'fgh';
    +echo 'abc' . (1 + 2) . 'fgh';
    +echo 1 * 2 + 3 / 4 % 5 . 6;
    +echo 1 * (2 + 3) / (4 % (5 . 6));
    +$a = $b = $c = $d = $f && true;
    +($a = $b = $c = $d = $f) && true;
    +$a = $b = $c = $d = $f and true;
    +$a = $b = $c = $d = ($f and true);
    +$a ? $b : $c ? $d : $e ? $f : $g;
    +$a ? $b : ($c ? $d : ($e ? $f : $g));
    +$a ? $b ? $c : $d : $f;
    +(1 > 0) > (1 < 0);
    +// this will currently unnecessarily print !($a = $b). This is correct as far as operator precedence is concerned, but
    +// the parentheses are not really necessary, because = takes only variables as the left hand side operator.
    +!($a = $b);
    \ No newline at end of file
    diff --git a/vendor/nikic/php-parser/test/code/prettyPrinter/switch.test b/vendor/nikic/php-parser/test/code/prettyPrinter/switch.test
    new file mode 100755
    index 0000000..0733a48
    --- /dev/null
    +++ b/vendor/nikic/php-parser/test/code/prettyPrinter/switch.test
    @@ -0,0 +1,35 @@
    +switch/case/default
    +-----
    + 0) {
    +    if (count($options) === 1 && $options[0] === '--no-progress') {
    +        $SHOW_PROGRESS = false;
    +    } else {
    +        showHelp('Invalid option passed!');
    +    }
    +}
    +
    +$TEST_TYPE = $arguments[0];
    +$DIR       = $arguments[1];
    +
    +if ('Symfony' === $TEST_TYPE) {
    +    function filter_func($path) {
    +        return preg_match('~\.php(?:\.cache)?$~', $path) && false === strpos($path, 'skeleton');
    +    };
    +} elseif ('PHP' === $TEST_TYPE) {
    +    function filter_func($path) {
    +        return preg_match('~\.phpt$~', $path);
    +    };
    +} else {
    +    showHelp('Test type must be either "Symfony" or "PHP"!');
    +}
    +
    +require_once dirname(__FILE__) . '/../lib/PHPParser/Autoloader.php';
    +PHPParser_Autoloader::register();
    +
    +$parser        = new PHPParser_Parser(new PHPParser_Lexer_Emulative);
    +$prettyPrinter = new PHPParser_PrettyPrinter_Default;
    +$nodeDumper    = new PHPParser_NodeDumper;
    +
    +$parseFail = $ppFail = $compareFail = $count = 0;
    +
    +$readTime = $parseTime = $ppTime = $reparseTime = $compareTime = 0;
    +$totalStartTime = microtime(true);
    +
    +foreach (new RecursiveIteratorIterator(
    +             new RecursiveDirectoryIterator($DIR),
    +             RecursiveIteratorIterator::LEAVES_ONLY)
    +         as $file) {
    +    if (!filter_func($file)) {
    +        continue;
    +    }
    +
    +    $startTime = microtime(true);
    +    $code = file_get_contents($file);
    +    $readTime += microtime(true) - $startTime;
    +
    +    if ('PHP' === $TEST_TYPE) {
    +        if (preg_match('~(?:
    +# skeleton files
    +  ext.gmp.tests.001
    +| ext.skeleton.tests.001
    +# multibyte encoded files
    +| ext.mbstring.tests.zend_multibyte-01
    +| Zend.tests.multibyte.multibyte_encoding_001
    +| Zend.tests.multibyte.multibyte_encoding_004
    +| Zend.tests.multibyte.multibyte_encoding_005
    +# token_get_all bug (https://bugs.php.net/bug.php?id=60097)
    +| Zend.tests.bug47516
    +# pretty print difference due to INF vs 1e1000
    +| ext.standard.tests.general_functions.bug27678
    +| tests.lang.bug24640
    +)\.phpt$~x', $file)) {
    +            continue;
    +        }
    +
    +        if (!preg_match('~--FILE--\s*(.*?)--[A-Z]+--~s', $code, $matches)) {
    +            continue;
    +        }
    +        if (preg_match('~--EXPECT(?:F|REGEX)?--\s*(?:Parse|Fatal) error~', $code)) {
    +            continue;
    +        }
    +
    +        $code = $matches[1];
    +    }
    +
    +    set_time_limit(10);
    +
    +    ++$count;
    +
    +    if ($SHOW_PROGRESS) {
    +        echo substr(str_pad('Testing file ' . $count . ': ' . substr($file, strlen($DIR)), 79), 0, 79), "\r";
    +    }
    +
    +    try {
    +        $startTime = microtime(true);
    +        $stmts = $parser->parse($code);
    +        $parseTime += microtime(true) - $startTime;
    +
    +        $startTime = microtime(true);
    +        $code = 'prettyPrint($stmts);
    +        $ppTime += microtime(true) - $startTime;
    +
    +        try {
    +            $startTime = microtime(true);
    +            $ppStmts = $parser->parse($code);
    +            $reparseTime += microtime(true) - $startTime;
    +
    +            $startTime = microtime(true);
    +            $same = $nodeDumper->dump($stmts) == $nodeDumper->dump($ppStmts);
    +            $compareTime += microtime(true) - $startTime;
    +
    +            if (!$same) {
    +                echo $file, ":\n    Result of initial parse and parse after pretty print differ\n";
    +
    +                ++$compareFail;
    +            }
    +        } catch (PHPParser_Error $e) {
    +            echo $file, ":\n    Parse of pretty print failed with message: {$e->getMessage()}\n";
    +
    +            ++$ppFail;
    +        }
    +    } catch (PHPParser_Error $e) {
    +        echo $file, ":\n    Parse failed with message: {$e->getMessage()}\n";
    +
    +        ++$parseFail;
    +    }
    +}
    +
    +if (0 === $parseFail && 0 === $ppFail && 0 === $compareFail) {
    +    echo "\n\n", 'All tests passed.', "\n";
    +} else {
    +    echo "\n\n", '==========', "\n\n", 'There were: ', "\n";
    +    if (0 !== $parseFail) {
    +        echo '    ', $parseFail,   ' parse failures.',        "\n";
    +    }
    +    if (0 !== $ppFail) {
    +        echo '    ', $ppFail,      ' pretty print failures.', "\n";
    +    }
    +    if (0 !== $compareFail) {
    +        echo '    ', $compareFail, ' compare failures.',      "\n";
    +    }
    +}
    +
    +echo "\n",
    +     'Tested files:         ', $count,        "\n",
    +     "\n",
    +     'Reading files took:   ', $readTime,    "\n",
    +     'Parsing took:         ', $parseTime,   "\n",
    +     'Pretty printing took: ', $ppTime,      "\n",
    +     'Reparsing took:       ', $reparseTime, "\n",
    +     'Comparing took:       ', $compareTime, "\n",
    +     "\n",
    +     'Total time:           ', microtime(true) - $totalStartTime, "\n",
    +     'Maximum memory usage: ', memory_get_peak_usage(true), "\n";
    \ No newline at end of file
    diff --git a/vendor/patchwork/utf8/.travis.yml b/vendor/patchwork/utf8/.travis.yml
    new file mode 100755
    index 0000000..040cc22
    --- /dev/null
    +++ b/vendor/patchwork/utf8/.travis.yml
    @@ -0,0 +1,15 @@
    +language: php
    +
    +php:
    +  - 5.3
    +  - 5.4
    +  - 5.5
    +  - 5.6
    +  - hhvm-nightly
    +
    +script:
    +  - phpunit --coverage-text
    +  - phpunit --group unicode --coverage-text
    +
    +matrix:
    +  fast_finish: true
    diff --git a/vendor/patchwork/utf8/CHANGELOG.md b/vendor/patchwork/utf8/CHANGELOG.md
    new file mode 100755
    index 0000000..1b7efba
    --- /dev/null
    +++ b/vendor/patchwork/utf8/CHANGELOG.md
    @@ -0,0 +1,119 @@
    +## v1.1.23 (2014-05-22)
    +
    +- enable tests for PHP 5.6
    +- remove HHVM from allowed failures
    +
    +## v1.1.22 (2014-04-06)
    +
    +- fix #19: don't call ini_set() when not required and gain compat with PHP5.6
    +
    +## v1.1.21 (2014-03-26)
    +
    +- fix #18 u::wordwrap() now relies on native behavior
    +
    +## v1.1.20 (2014-03-01)
    +## v1.1.19 (2014-03-01)
    +
    +- fix mb_regex_encoding() being disabled on some hosting providers
    +
    +## v1.1.18 (2014-02-02)
    +
    +- require PCRE>=7.3, the first that correctly checks UTF-8 validity
    +- enable HHVM on Travis CI
    +
    +## v1.1.17 (2014-01-02)
    +
    +- enable Travis CI and SensioLabsInsight
    +- add shims for mb_check_encoding, mb_detect_encoding, mb_detect_order,
    +  mb_language and mb_encoding_aliases
    +- mbstring shim fix: alias UTF8 to UTF-8
    +- more tests
    +
    +## v1.1.16 (2013-12-06)
    +
    +- fix $_FILES bootup filtering
    +- fix mbstring shim behavior with invalid utf8 strings
    +
    +## v1.1.15 (2013-11-23)
    +
    +- u::toAscii() is now locale sensitive and allows a substitution character
    +- use LSB for more extension openness
    +- handle null for mb_substr() shim length as in PHP 5.4.8
    +- fix casts to string
    +- fix mbstring MB_CASE_TITLE shim on edge case
    +- small optimizations
    +- add a changelog
    +
    +## v1.1.14 (2013-11-04)
    +
    +- set default_charset to UTF-8 at bootup
    +- remove bootup PCRE warning
    +- fix iconv internal_encoding shim
    +- fix bootup dependencies
    +- add tests for normalizers consts
    +- readme update
    +
    +## v1.1.13 (2013-10-11)
    +
    +- new u::filter(): normalizes to UTF-8 NFC, converting from CP-1252 when needed
    +- new u::json_decode(), u::filter_input() and u::filter_input_array() for NFC safeness
    +- reference Unicode 6.3
    +- more tests
    +- readme update
    +
    +## v1.1.12 (2013-10-03)
    +
    +- new Patchwork\TurkishUtf8 class extends Patchwork\Utf8 with Turkish specifics
    +- expose Patchwork\Utf8\Bootup::filterString() for UF-8 NFC strings normalization
    +- normalize inputs EOL to work around https://bugs.php.net/65732
    +- update composer.json
    +
    +## v1.1.11 (2013-08-19)
    +
    +- updates related to PHP bugs 52211 and 61860
    +- fixes and tests for iconv shim
    +- fixes and tests for mbstring shim
    +
    +## v1.1.10 (2013-08-13)
    +
    +- update .gitattributes export-ignore
    +- fixes and tests for intl::grapheme_extract() shim
    +- fixes and tests for iconv shim
    +- fixes and tests for mbstring shim
    +
    +## v1.1.9 (2013-08-04)
    +
    +- know that PHP bug 61860 has been fixed in 5.5.1
    +- fix intl::grapheme_strlen() shim on edge case
    +- fix case sensitive encoding checks for mbstring shim
    +- some more fixes, tests and optimizations
    +
    +## v1.1.8 since v1.1.0 (2013-05-24)
    +
    +- filter leading combining chars in inputs for NFC safeness
    +- fixes, tests and optimizations
    +- readme update
    +
    +## v1.1.0 (2013-04-18)
    +
    +- PSR-0 autoloading and explicit bootup configuration is now required
    +
    +## v1.0.6 since v1.0.0 (2013-04-22)
    +
    +- add extra characters for ASCII transliterations
    +- move bootup stages in namespaced functions for greater modularity
    +- NFC normalization for autoglobal inputs
    +- better setlocale() initialization
    +- fix fatal error caused by multiple bootup inclusion
    +- fix bootup
    +
    +## v1.0.0 (2012-10-15)
    +
    +- first official release of a work started in 2007
    +- Apache v2.0 / GPL v2.0 dual-licensed
    +- PHP portability implementations for mbstring, iconv, intl grapheme_*() and utf8_encode/decode()
    +- Unicode compliant and portable Normalizer
    +- grapheme clusters aware UTF-8 handling string functions replica
    +- PHP runtime environment configuration for UTF-8
    +- extra functions for UTF-8 validity checks, transliterations and case folding
    +- covered by unit tests
    diff --git a/vendor/patchwork/utf8/README.md b/vendor/patchwork/utf8/README.md
    new file mode 100755
    index 0000000..b4735d1
    --- /dev/null
    +++ b/vendor/patchwork/utf8/README.md
    @@ -0,0 +1,145 @@
    +Patchwork UTF-8 for PHP
    +=======================
    +
    +[![Latest Stable Version](https://poser.pugx.org/patchwork/utf8/v/stable.png)](https://packagist.org/packages/patchwork/utf8)
    +[![Total Downloads](https://poser.pugx.org/patchwork/utf8/downloads.png)](https://packagist.org/packages/patchwork/utf8)
    +[![Build Status](https://secure.travis-ci.org/nicolas-grekas/Patchwork-UTF8.png?branch=master)](http://travis-ci.org/nicolas-grekas/Patchwork-UTF8)
    +[![SensioLabsInsight](https://insight.sensiolabs.com/projects/666c8ae7-0997-4d27-883a-6089ce3cc76b/mini.png)](https://insight.sensiolabs.com/projects/666c8ae7-0997-4d27-883a-6089ce3cc76b)
    +
    +Patchwork UTF-8 gives PHP developpers extensive, portable and performant
    +handling of UTF-8 and [grapheme clusters](http://unicode.org/reports/tr29/).
    +
    +It provides both :
    +
    +- a portability layer for `mbstring`, `iconv`, and intl `Normalizer` and
    +  `grapheme_*` functions,
    +- an UTF-8 grapheme clusters aware replica of native string functions.
    +
    +It can also serve as a documentation source referencing the practical problems
    +that arise when handling UTF-8 in PHP: Unicode concepts, related algorithms,
    +bugs in PHP core, workarounds, etc.
    +
    +Portability
    +-----------
    +
    +Unicode handling in PHP is best performed using a combo of `mbstring`, `iconv`,
    +`intl` and `pcre` with the `u` flag enabled. But when an application is expected
    +to run on many servers, you should be aware that these 4 extensions are not
    +always enabled.
    +
    +Patchwork UTF-8 provides pure PHP implementations for 3 of those 4 extensions.
    +`pcre` compiled with unicode support is required but is widely available.
    +The following set of portability-fallbacks allows an application to run on a
    +server even if one or more of those extensions are not enabled:
    +
    +- *utf8_encode, utf8_decode*,
    +- `mbstring`: *mb_check_encoding, mb_convert_case, mb_convert_encoding,
    +  mb_decode_mimeheader, mb_detect_encoding, mb_detect_order,
    +  mb_encode_mimeheader, mb_encoding_aliases, mb_internal_encoding, mb_language,
    +  mb_list_encodings, mb_strlen, mb_strpos, mb_strrpos, mb_strtolower,
    +  mb_strtoupper, mb_stripos, mb_stristr, mb_strrchr, mb_strrichr, mb_strripos,
    +  mb_strstr, mb_substitute_character, mb_substr*,
    +- `iconv`: *iconv, iconv_mime_decode, iconv_mime_decode_headers,
    +  iconv_get_encoding, iconv_set_encoding, iconv_mime_encode, ob_iconv_handler,
    +  iconv_strlen, iconv_strpos, iconv_strrpos, iconv_substr*,
    +- `intl`: *Normalizer, grapheme_extract, grapheme_stripos, grapheme_stristr,
    +  grapheme_strlen, grapheme_strpos, grapheme_strripos, grapheme_strrpos,
    +  grapheme_strstr, grapheme_substr, normalizer_is_normalized,
    +  normalizer_normalize*.
    +
    +Patchwork\Utf8
    +--------------
    +
    +[Grapheme clusters](http://unicode.org/reports/tr29/) should always be
    +considered when working with generic Unicode strings. The `Patchwork\Utf8`
    +class implements the quasi-complete set of native string functions that need
    +UTF-8 grapheme clusters awareness. Function names, arguments and behavior
    +carefully replicates native PHP string functions.
    +
    +Some more functions are also provided to help handling UTF-8 strings:
    +
    +- *filter()*: normalizes to UTF-8 NFC, converting from [CP-1252](http://wikipedia.org/wiki/CP-1252) when needed,
    +- *isUtf8()*: checks if a string contains well formed UTF-8 data,
    +- *toAscii()*: generic UTF-8 to ASCII transliteration,
    +- *strtocasefold()*: unicode transformation for caseless matching,
    +- *strtonatfold()*: generic case sensitive transformation for collation matching
    +
    +Mirrored string functions are:
    +*strlen, substr, strpos, stripos, strrpos, strripos, strstr, stristr, strrchr,
    +strrichr, strtolower, strtoupper, wordwrap, chr, count_chars, ltrim, ord, rtrim,
    +trim, str_ireplace, str_pad, str_shuffle, str_split, str_word_count, strcmp,
    +strnatcmp, strcasecmp, strnatcasecmp, strncasecmp, strncmp, strcspn, strpbrk,
    +strrev, strspn, strtr, substr_compare, substr_count, substr_replace, ucfirst,
    +lcfirst, ucwords, number_format, utf8_encode, utf8_decode, json_decode,
    +filter_input, filter_input_array*.
    +
    +Notably missing (but hard to replicate) are *printf*-family functions.
    +
    +The implementation favors performance over full edge cases handling.
    +It generally works on UTF-8 normalized strings and provides filters to get them.
    +
    +As the turkish locale requires special cares, a `Patchwork\TurkishUtf8` class
    +is provided for working with this locale. It clones all the features of
    +`Patchwork\Utf8` but knows about the turkish specifics.
    +
    +Usage
    +-----
    +
    +The recommended way to install Patchwork UTF-8 is [through
    +composer](http://getcomposer.org). Just create a `composer.json` file and run
    +the `php composer.phar install` command to install it:
    +
    +    {
    +        "require": {
    +            "patchwork/utf8": "1.1.*"
    +        }
    +    }
    +
    +Then, early in your bootstrap sequence, you have to configure your environment:
    +
    +```php
    +\Patchwork\Utf8\Bootup::initAll(); // Enables the portablity layer and configures PHP for UTF-8
    +\Patchwork\Utf8\Bootup::filterRequestUri(); // Redirects to an UTF-8 encoded URL if it's not already the case
    +\Patchwork\Utf8\Bootup::filterRequestInputs(); // Normalizes HTTP inputs to UTF-8 NFC
    +```
    +
    +Run `phpunit` to see the code in action.
    +
    +Make sure that you are confident about using UTF-8 by reading
    +[Character Sets / Character Encoding Issues](http://www.phpwact.org/php/i18n/charsets)
    +and [Handling UTF-8 with PHP](http://www.phpwact.org/php/i18n/utf-8),
    +or [PHP et UTF-8](http://julp.lescigales.org/articles/3-php-et-utf-8.html) for french readers.
    +
    +You should also get familiar with the concept of
    +[Unicode Normalization](http://en.wikipedia.org/wiki/Unicode_equivalence) and
    +[Grapheme Clusters](http://unicode.org/reports/tr29/).
    +
    +Do not blindly replace all use of PHP's string functions. Most of the time you
    +will not need to, and you will be introducing a significant performance overhead
    +to your application.
    +
    +Screen your input on the *outer perimeter* so that only well formed UTF-8 pass
    +through. When dealing with badly formed UTF-8, you should not try to fix it
    +(see [Unicode Security Considerations](http://www.unicode.org/reports/tr36/#Deletion_of_Noncharacters)).
    +Instead, consider it as [CP-1252](http://wikipedia.org/wiki/CP-1252) and use
    +`Patchwork\Utf8::utf8_encode()` to get an UTF-8 string. Don't forget also to
    +choose one unicode normalization form and stick to it. NFC is now the defacto
    +standard. `Patchwork\Utf8::filter()` implements this behavior.
    +
    +This library is orthogonal to `mbstring.func_overload` and will not work if the
    +php.ini setting is enabled.
    +
    +Licensing
    +---------
    +
    +Patchwork\Utf8 is free software; you can redistribute it and/or modify it under
    +the terms of the (at your option):
    +- [Apache License v2.0](http://apache.org/licenses/LICENSE-2.0.txt), or
    +- [GNU General Public License v2.0](http://gnu.org/licenses/gpl-2.0.txt).
    +
    +Unicode handling requires tedious work to be implemented and maintained on the
    +long run. As such, contributions such as unit tests, bug reports, comments or
    +patches licensed under both licenses are really welcomed.
    +
    +I hope many projects could adopt this code and together help solve the unicode
    +subject for PHP.
    diff --git a/vendor/patchwork/utf8/class/Normalizer.php b/vendor/patchwork/utf8/class/Normalizer.php
    new file mode 100755
    index 0000000..3acd5f3
    --- /dev/null
    +++ b/vendor/patchwork/utf8/class/Normalizer.php
    @@ -0,0 +1,17 @@
    + 'utf-8',
    +        'ascii' => 'us-ascii',
    +        'tis-620' => 'iso-8859-11',
    +        'cp1250' => 'windows-1250',
    +        'cp1251' => 'windows-1251',
    +        'cp1252' => 'windows-1252',
    +        'cp1253' => 'windows-1253',
    +        'cp1254' => 'windows-1254',
    +        'cp1255' => 'windows-1255',
    +        'cp1256' => 'windows-1256',
    +        'cp1257' => 'windows-1257',
    +        'cp1258' => 'windows-1258',
    +        'shift-jis' => 'cp932',
    +        'shift_jis' => 'cp932',
    +        'latin1' => 'iso-8859-1',
    +        'latin2' => 'iso-8859-2',
    +        'latin3' => 'iso-8859-3',
    +        'latin4' => 'iso-8859-4',
    +        'latin5' => 'iso-8859-9',
    +        'latin6' => 'iso-8859-10',
    +        'latin7' => 'iso-8859-13',
    +        'latin8' => 'iso-8859-14',
    +        'latin9' => 'iso-8859-15',
    +        'latin10' => 'iso-8859-16',
    +        'iso8859-1' => 'iso-8859-1',
    +        'iso8859-2' => 'iso-8859-2',
    +        'iso8859-3' => 'iso-8859-3',
    +        'iso8859-4' => 'iso-8859-4',
    +        'iso8859-5' => 'iso-8859-5',
    +        'iso8859-6' => 'iso-8859-6',
    +        'iso8859-7' => 'iso-8859-7',
    +        'iso8859-8' => 'iso-8859-8',
    +        'iso8859-9' => 'iso-8859-9',
    +        'iso8859-10' => 'iso-8859-10',
    +        'iso8859-11' => 'iso-8859-11',
    +        'iso8859-12' => 'iso-8859-12',
    +        'iso8859-13' => 'iso-8859-13',
    +        'iso8859-14' => 'iso-8859-14',
    +        'iso8859-15' => 'iso-8859-15',
    +        'iso8859-16' => 'iso-8859-16',
    +        'iso_8859-1' => 'iso-8859-1',
    +        'iso_8859-2' => 'iso-8859-2',
    +        'iso_8859-3' => 'iso-8859-3',
    +        'iso_8859-4' => 'iso-8859-4',
    +        'iso_8859-5' => 'iso-8859-5',
    +        'iso_8859-6' => 'iso-8859-6',
    +        'iso_8859-7' => 'iso-8859-7',
    +        'iso_8859-8' => 'iso-8859-8',
    +        'iso_8859-9' => 'iso-8859-9',
    +        'iso_8859-10' => 'iso-8859-10',
    +        'iso_8859-11' => 'iso-8859-11',
    +        'iso_8859-12' => 'iso-8859-12',
    +        'iso_8859-13' => 'iso-8859-13',
    +        'iso_8859-14' => 'iso-8859-14',
    +        'iso_8859-15' => 'iso-8859-15',
    +        'iso_8859-16' => 'iso-8859-16',
    +        'iso88591' => 'iso-8859-1',
    +        'iso88592' => 'iso-8859-2',
    +        'iso88593' => 'iso-8859-3',
    +        'iso88594' => 'iso-8859-4',
    +        'iso88595' => 'iso-8859-5',
    +        'iso88596' => 'iso-8859-6',
    +        'iso88597' => 'iso-8859-7',
    +        'iso88598' => 'iso-8859-8',
    +        'iso88599' => 'iso-8859-9',
    +        'iso885910' => 'iso-8859-10',
    +        'iso885911' => 'iso-8859-11',
    +        'iso885912' => 'iso-8859-12',
    +        'iso885913' => 'iso-8859-13',
    +        'iso885914' => 'iso-8859-14',
    +        'iso885915' => 'iso-8859-15',
    +        'iso885916' => 'iso-8859-16',
    +    ),
    +
    +    $translit_map = array(),
    +    $convert_map = array(),
    +    $error_handler,
    +    $last_error,
    +
    +    $ulen_mask = array("\xC0" => 2, "\xD0" => 2, "\xE0" => 3, "\xF0" => 4),
    +    $is_valid_utf8;
    +
    +
    +    static function iconv($in_charset, $out_charset, $str)
    +    {
    +        if ('' === $str .= '') return '';
    +
    +        // Prepare for //IGNORE and //TRANSLIT
    +
    +        $TRANSLIT = $IGNORE = '';
    +
    +        $out_charset = strtolower($out_charset);
    +        $in_charset  = strtolower($in_charset );
    +
    +        '' === $out_charset && $out_charset = 'iso-8859-1';
    +        '' ===  $in_charset &&  $in_charset = 'iso-8859-1';
    +
    +        if ('//translit' === substr($out_charset, -10))
    +        {
    +            $TRANSLIT = '//TRANSLIT';
    +            $out_charset = substr($out_charset, 0, -10);
    +        }
    +
    +        if ('//ignore' === substr($out_charset, -8))
    +        {
    +            $IGNORE = '//IGNORE';
    +            $out_charset = substr($out_charset, 0, -8);
    +        }
    +
    +        '//translit' === substr($in_charset, -10) && $in_charset = substr($in_charset, 0, -10);
    +        '//ignore'   === substr($in_charset,  -8) && $in_charset = substr($in_charset, 0,  -8);
    +
    +        isset(self::$alias[ $in_charset]) &&  $in_charset = self::$alias[ $in_charset];
    +        isset(self::$alias[$out_charset]) && $out_charset = self::$alias[$out_charset];
    +
    +
    +        // Load charset maps
    +
    +        if ( ('utf-8' !==  $in_charset && !static::loadMap('from.',  $in_charset,  $in_map))
    +          || ('utf-8' !== $out_charset && !static::loadMap(  'to.', $out_charset, $out_map)) )
    +        {
    +            user_error(sprintf(self::ERROR_WRONG_CHARSET, $in_charset, $out_charset));
    +            return false;
    +        }
    +
    +
    +        if ('utf-8' !== $in_charset)
    +        {
    +            // Convert input to UTF-8
    +            $result = '';
    +            if (self::map_to_utf8($result, $in_map, $str, $IGNORE)) $str = $result;
    +            else $str = false;
    +            self::$is_valid_utf8 = true;
    +        }
    +        else
    +        {
    +            self::$is_valid_utf8 = preg_match('//u', $str);
    +
    +            if (!self::$is_valid_utf8 && !$IGNORE)
    +            {
    +                user_error(self::ERROR_ILLEGAL_CHARACTER);
    +                return false;
    +            }
    +
    +            if ('utf-8' === $out_charset)
    +            {
    +                // UTF-8 validation
    +                $str = self::utf8_to_utf8($str, $IGNORE);
    +            }
    +        }
    +
    +        if ('utf-8' !== $out_charset && false !== $str)
    +        {
    +            // Convert output to UTF-8
    +            $result = '';
    +            if (self::map_from_utf8($result, $out_map, $str, $IGNORE, $TRANSLIT)) return $result;
    +            else return false;
    +        }
    +        else return $str;
    +    }
    +
    +    static function iconv_mime_decode_headers($str, $mode = 0, $charset = INF)
    +    {
    +        INF === $charset && $charset = self::$internal_encoding;
    +
    +        false !== strpos($str, "\r") && $str = strtr(str_replace("\r\n", "\n", $str), "\r", "\n");
    +        $str = explode("\n\n", $str, 2);
    +
    +        $headers = array();
    +
    +        $str = preg_split('/\n(?![ \t])/', $str[0]);
    +        foreach ($str as $str)
    +        {
    +            $str = self::iconv_mime_decode($str, $mode, $charset);
    +            if (false === $str) return false;
    +            $str = explode(':', $str, 2);
    +
    +            if (2 === count($str))
    +            {
    +                if (isset($headers[$str[0]]))
    +                {
    +                    is_array($headers[$str[0]]) || $headers[$str[0]] = array($headers[$str[0]]);
    +                    $headers[$str[0]][] = ltrim($str[1]);
    +                }
    +                else $headers[$str[0]] = ltrim($str[1]);
    +            }
    +        }
    +
    +        return $headers;
    +    }
    +
    +    static function iconv_mime_decode($str, $mode = 0, $charset = INF)
    +    {
    +        INF === $charset && $charset = self::$internal_encoding;
    +        if (ICONV_MIME_DECODE_CONTINUE_ON_ERROR & $mode) $charset .= '//IGNORE';
    +
    +        false !== strpos($str, "\r") && $str = strtr(str_replace("\r\n", "\n", $str), "\r", "\n");
    +        $str = preg_split('/\n(?![ \t])/', rtrim($str), 2);
    +        $str = preg_replace('/[ \t]*\n[ \t]+/', ' ', rtrim($str[0]));
    +        $str = preg_split('/=\?([^?]+)\?([bqBQ])\?(.*?)\?=/', $str, -1, PREG_SPLIT_DELIM_CAPTURE);
    +
    +        $result = self::iconv('utf-8', $charset, $str[0]);
    +        if (false === $result) return false;
    +
    +        $i = 1;
    +        $len = count($str);
    +
    +        while ($i < $len)
    +        {
    +            $c = strtolower($str[$i]);
    +            if ( (ICONV_MIME_DECODE_CONTINUE_ON_ERROR & $mode)
    +              && 'utf-8' !== $c
    +              && !isset(self::$alias[$c])
    +              && !static::loadMap('from.', $c,  $d) ) $d = false;
    +            else if ('B' === strtoupper($str[$i+1])) $d = base64_decode($str[$i+2]);
    +            else $d = rawurldecode(strtr(str_replace('%', '%25', $str[$i+2]), '=_', '% '));
    +
    +            if (false !== $d)
    +            {
    +                $result .= self::iconv($c, $charset, $d);
    +                $d = self::iconv('utf-8' , $charset, $str[$i+3]);
    +                if ('' !== trim($d)) $result .= $d;
    +            }
    +            else if (ICONV_MIME_DECODE_CONTINUE_ON_ERROR & $mode)
    +            {
    +                $result .= "=?{$str[$i]}?{$str[$i+1]}?{$str[$i+2]}?={$str[$i+3]}";
    +            }
    +            else
    +            {
    +                $result = false;
    +                break;
    +            }
    +
    +            $i += 4;
    +        }
    +
    +        return $result;
    +    }
    +
    +    static function iconv_get_encoding($type = 'all')
    +    {
    +        switch ($type)
    +        {
    +        case 'input_encoding'   : return self::$input_encoding;
    +        case 'output_encoding'  : return self::$output_encoding;
    +        case 'internal_encoding': return self::$internal_encoding;
    +        }
    +
    +        return array(
    +            'input_encoding'    => self::$input_encoding,
    +            'output_encoding'   => self::$output_encoding,
    +            'internal_encoding' => self::$internal_encoding
    +        );
    +    }
    +
    +    static function iconv_set_encoding($type, $charset)
    +    {
    +        switch ($type)
    +        {
    +        case 'input_encoding'   : self::$input_encoding    = $charset; break;
    +        case 'output_encoding'  : self::$output_encoding   = $charset; break;
    +        case 'internal_encoding': self::$internal_encoding = $charset; break;
    +
    +        default: return false;
    +        }
    +
    +        return true;
    +    }
    +
    +    static function iconv_mime_encode($field_name, $field_value, $pref = INF)
    +    {
    +        is_array($pref) || $pref = array();
    +
    +        $pref += array(
    +            'scheme'           => 'B',
    +            'input-charset'    => self::$internal_encoding,
    +            'output-charset'   => self::$internal_encoding,
    +            'line-length'      => 76,
    +            'line-break-chars' => "\r\n"
    +        );
    +
    +        preg_match('/[\x80-\xFF]/', $field_name) && $field_name = '';
    +
    +        $scheme = strtoupper(substr($pref['scheme'], 0, 1));
    +        $in  = strtolower($pref['input-charset']);
    +        $out = strtolower($pref['output-charset']);
    +
    +        if ('utf-8' !== $in && false === $field_value = self::iconv($in, 'utf-8', $field_value)) return false;
    +
    +        preg_match_all('/./us', $field_value, $chars);
    +
    +        $chars = isset($chars[0]) ? $chars[0] : array();
    +
    +        $line_break  = (int) $pref['line-length'];
    +        $line_start  = "=?{$pref['output-charset']}?{$scheme}?";
    +        $line_length = strlen($field_name) + 2 + strlen($line_start) + 2;
    +        $line_offset = strlen($line_start) + 3;
    +        $line_data   = '';
    +
    +        $field_value = array();
    +
    +        $Q = 'Q' === $scheme;
    +
    +        foreach ($chars as $c)
    +        {
    +            if ('utf-8' !== $out && false === $c = self::iconv('utf-8', $out, $c)) return false;
    +
    +            $o = $Q
    +                ? $c = preg_replace_callback(
    +                    '/[=_\?\x00-\x1F\x80-\xFF]/',
    +                    array(__CLASS__, 'qp_byte_callback'),
    +                    $c
    +                )
    +                : base64_encode($line_data . $c);
    +
    +            if (isset($o[$line_break - $line_length]))
    +            {
    +                $Q || $line_data = base64_encode($line_data);
    +                $field_value[] = $line_start . $line_data . '?=';
    +                $line_length = $line_offset;
    +                $line_data = '';
    +            }
    +
    +            $line_data .= $c;
    +            $Q && $line_length += strlen($c);
    +        }
    +
    +        if ('' !== $line_data)
    +        {
    +            $Q || $line_data = base64_encode($line_data);
    +            $field_value[] = $line_start . $line_data . '?=';
    +        }
    +
    +        return $field_name . ': ' . implode($pref['line-break-chars'] . ' ', $field_value);
    +    }
    +
    +    static function ob_iconv_handler($buffer, $mode)
    +    {
    +        return self::iconv(self::$internal_encoding, self::$output_encoding, $buffer);
    +    }
    +
    +    static function iconv_strlen($s, $encoding = INF)
    +    {
    +/**/    if (extension_loaded('xml'))
    +            return self::strlen1($s, $encoding);
    +/**/    else
    +            return self::strlen2($s, $encoding);
    +    }
    +
    +    static function strlen1($s, $encoding = INF)
    +    {
    +        INF === $encoding && $encoding = self::$internal_encoding;
    +        if (0 !== strncasecmp($encoding, 'utf-8', 5) && false === $s = self::iconv($encoding, 'utf-8', $s)) return false;
    +
    +        return strlen(utf8_decode($s));
    +    }
    +
    +    static function strlen2($s, $encoding = INF)
    +    {
    +        INF === $encoding && $encoding = self::$internal_encoding;
    +        if (0 !== strncasecmp($encoding, 'utf-8', 5) && false === $s = self::iconv($encoding, 'utf-8', $s)) return false;
    +
    +        $ulen_mask = self::$ulen_mask;
    +
    +        $i = 0; $j = 0;
    +        $len = strlen($s);
    +
    +        while ($i < $len)
    +        {
    +            $u = $s[$i] & "\xF0";
    +            $i += isset($ulen_mask[$u]) ? $ulen_mask[$u] : 1;
    +            ++$j;
    +        }
    +
    +        return $j;
    +    }
    +
    +    static function iconv_strpos($haystack, $needle, $offset = 0, $encoding = INF)
    +    {
    +        INF === $encoding && $encoding = self::$internal_encoding;
    +
    +        if (0 !== strncasecmp($encoding, 'utf-8', 5))
    +        {
    +            if (false === $haystack = self::iconv($encoding, 'utf-8', $haystack)) return false;
    +            if (false === $needle = self::iconv($encoding, 'utf-8', $needle)) return false;
    +        }
    +
    +        if ($offset = (int) $offset) $haystack = self::iconv_substr($haystack, $offset, 2147483647, 'utf-8');
    +        $pos = strpos($haystack, $needle);
    +        return false === $pos ? false : ($offset + ($pos ? self::iconv_strlen(substr($haystack, 0, $pos), 'utf-8') : 0));
    +    }
    +
    +    static function iconv_strrpos($haystack, $needle, $encoding = INF)
    +    {
    +        INF === $encoding && $encoding = self::$internal_encoding;
    +
    +        if (0 !== strncasecmp($encoding, 'utf-8', 5))
    +        {
    +            if (false === $haystack = self::iconv($encoding, 'utf-8', $haystack)) return false;
    +            if (false === $needle = self::iconv($encoding, 'utf-8', $needle)) return false;
    +        }
    +
    +        $pos = isset($needle[0]) ? strrpos($haystack, $needle) : false;
    +        return false === $pos ? false : self::iconv_strlen($pos ? substr($haystack, 0, $pos) : $haystack, 'utf-8');
    +    }
    +
    +    static function iconv_substr($s, $start, $length = 2147483647, $encoding = INF)
    +    {
    +        INF === $encoding && $encoding = self::$internal_encoding;
    +        if (0 === strncasecmp($encoding, 'utf-8', 5)) $encoding = INF;
    +        else if (false === $s = self::iconv($encoding, 'utf-8', $s)) return false;
    +
    +        $s .= '';
    +        $slen = self::iconv_strlen($s, 'utf-8');
    +        $start = (int) $start;
    +
    +        if (0 > $start) $start += $slen;
    +        if (0 > $start) return false;
    +        if ($start >= $slen) return false;
    +
    +        $rx = $slen - $start;
    +
    +        if (0 > $length) $length += $rx;
    +        if (0 === $length) return '';
    +        if (0 > $length) return false;
    +
    +        if ($length > $rx) $length = $rx;
    +
    +        $rx = '/^' . ($start ? self::preg_offset($start) : '') . '(' . self::preg_offset($length) . ')/u';
    +
    +        $s = preg_match($rx, $s, $s) ? $s[1] : '';
    +
    +        if (INF === $encoding) return $s;
    +        else return self::iconv('utf-8', $encoding, $s);
    +    }
    +
    +    protected static function loadMap($type, $charset, &$map)
    +    {
    +        if (!isset(self::$convert_map[$type . $charset]))
    +        {
    +            if (false === $map = static::getData($type . $charset))
    +            {
    +                if ('to.' === $type && static::loadMap('from.', $charset, $map)) $map = array_flip($map);
    +                else return false;
    +            }
    +
    +            self::$convert_map[$type . $charset] = $map;
    +        }
    +        else $map = self::$convert_map[$type . $charset];
    +
    +        return true;
    +    }
    +
    +    protected static function utf8_to_utf8($str, $IGNORE)
    +    {
    +        $ulen_mask = self::$ulen_mask;
    +        $valid     = self::$is_valid_utf8;
    +
    +        $u = $str;
    +        $i = $j = 0;
    +        $len = strlen($str);
    +
    +        while ($i < $len)
    +        {
    +            if ($str[$i] < "\x80") $u[$j++] = $str[$i++];
    +            else
    +            {
    +                $ulen = $str[$i] & "\xF0";
    +                $ulen = isset($ulen_mask[$ulen]) ? $ulen_mask[$ulen] : 1;
    +                $uchr = substr($str, $i, $ulen);
    +
    +                if (1 === $ulen || !($valid || preg_match('/^.$/us', $uchr)))
    +                {
    +                    if ($IGNORE)
    +                    {
    +                        ++$i;
    +                        continue;
    +                    }
    +
    +                    user_error(self::ERROR_ILLEGAL_CHARACTER);
    +                    return false;
    +                }
    +                else $i += $ulen;
    +
    +                $u[$j++] = $uchr[0];
    +
    +                   isset($uchr[1]) && 0 !== ($u[$j++] = $uchr[1])
    +                && isset($uchr[2]) && 0 !== ($u[$j++] = $uchr[2])
    +                && isset($uchr[3]) && 0 !== ($u[$j++] = $uchr[3]);
    +            }
    +        }
    +
    +        return substr($u, 0, $j);
    +    }
    +
    +    protected static function map_to_utf8(&$result, $map, $str, $IGNORE)
    +    {
    +        $len = strlen($str);
    +        for ($i = 0; $i < $len; ++$i)
    +        {
    +            if (isset($str[$i+1], $map[$str[$i] . $str[$i+1]])) $result .= $map[$str[$i] . $str[++$i]];
    +            else if (isset($map[$str[$i]])) $result .= $map[$str[$i]];
    +            else if (!$IGNORE)
    +            {
    +                user_error(self::ERROR_ILLEGAL_CHARACTER);
    +                return false;
    +            }
    +        }
    +
    +        return true;
    +    }
    +
    +    protected static function map_from_utf8(&$result, $map, $str, $IGNORE, $TRANSLIT)
    +    {
    +        $ulen_mask = self::$ulen_mask;
    +        $valid     = self::$is_valid_utf8;
    +
    +        if ($TRANSLIT) self::$translit_map or self::$translit_map = static::getData('translit');
    +
    +        $i = 0;
    +        $len = strlen($str);
    +
    +        while ($i < $len)
    +        {
    +            if ($str[$i] < "\x80") $uchr = $str[$i++];
    +            else
    +            {
    +                $ulen = $str[$i] & "\xF0";
    +                $ulen = isset($ulen_mask[$ulen]) ? $ulen_mask[$ulen] : 1;
    +                $uchr = substr($str, $i, $ulen);
    +
    +                if ($IGNORE && (1 === $ulen || !($valid || preg_match('/^.$/us', $uchr))))
    +                {
    +                    ++$i;
    +                    continue;
    +                }
    +                else $i += $ulen;
    +            }
    +
    +            if (isset($map[$uchr]))
    +            {
    +                $result .= $map[$uchr];
    +            }
    +            else if ($TRANSLIT)
    +            {
    +                if (isset(self::$translit_map[$uchr]))
    +                {
    +                    $uchr = self::$translit_map[$uchr];
    +                }
    +                else if ($uchr >= "\xC3\x80")
    +                {
    +                    $uchr = \Normalizer::normalize($uchr, \Normalizer::NFD);
    +
    +                    if ($uchr[0] < "\x80") $uchr = $uchr[0];
    +                    else if ($IGNORE) continue;
    +                    else return false;
    +                }
    +
    +                $str = $uchr . substr($str, $i);
    +                $len = strlen($str);
    +                $i = 0;
    +            }
    +            else if (!$IGNORE)
    +            {
    +                return false;
    +            }
    +        }
    +
    +        return true;
    +    }
    +
    +    protected static function qp_byte_callback($m)
    +    {
    +        return '=' . strtoupper(dechex(ord($m[0])));
    +    }
    +
    +    protected static function preg_offset($offset)
    +    {
    +        $rx = array();
    +        $offset = (int) $offset;
    +
    +        while ($offset > 65535)
    +        {
    +            $rx[] = '.{65535}';
    +            $offset -= 65535;
    +        }
    +
    +        return implode('', $rx) . '.{' . $offset . '}';
    +    }
    +
    +    protected static function getData($file)
    +    {
    +        $file = __DIR__ . '/charset/' . $file . '.ser';
    +        if (file_exists($file)) return unserialize(file_get_contents($file));
    +        else return false;
    +    }
    +}
    diff --git a/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/Intl.php b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/Intl.php
    new file mode 100755
    index 0000000..b728c12
    --- /dev/null
    +++ b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/Intl.php
    @@ -0,0 +1,152 @@
    + $size || 0 > $start || 0 > $type || 2 < $type) return false;
    +        if (0 === $size) return '';
    +
    +        $next = $start;
    +
    +        $s = preg_split('/(' . GRAPHEME_CLUSTER_RX . ')/u', "\r\n" .  $s, $size + 1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE);
    +
    +        if (!isset($s[1])) return false;
    +
    +        $i = 1;
    +        $ret = '';
    +
    +        do
    +        {
    +            if (GRAPHEME_EXTR_COUNT === $type) --$size;
    +            else if (GRAPHEME_EXTR_MAXBYTES === $type) $size -= strlen($s[$i]);
    +            else $size -= iconv_strlen($s[$i], 'UTF-8//IGNORE');
    +
    +            if ($size >= 0) $ret .= $s[$i];
    +        }
    +        while (isset($s[++$i]) && $size > 0);
    +
    +        $next += strlen($ret);
    +
    +        return $ret;
    +    }
    +
    +    static function grapheme_strlen($s)
    +    {
    +        preg_replace('/' . GRAPHEME_CLUSTER_RX . '/u', '', $s, -1, $len);
    +        return 0 === $len && '' !== $s ? null : $len;
    +    }
    +
    +    static function grapheme_substr($s, $start, $len = 2147483647)
    +    {
    +        preg_match_all('/' . GRAPHEME_CLUSTER_RX . '/u', $s, $s);
    +
    +        $slen = count($s[0]);
    +        $start = (int) $start;
    +
    +        if (0 > $start) $start += $slen;
    +        if (0 > $start) return false;
    +        if ($start >= $slen) return false;
    +
    +        $rem = $slen - $start;
    +
    +        if (0 > $len) $len += $rem;
    +        if (0 === $len) return '';
    +        if (0 > $len) return false;
    +        if ($len > $rem) $len = $rem;
    +
    +        return implode('', array_slice($s[0], $start, $len));
    +    }
    +
    +    static function grapheme_substr_workaround62759($s, $start, $len)
    +    {
    +        // Intl based http://bugs.php.net/62759 and 55562 workaround
    +
    +        if (2147483647 == $len) return grapheme_substr($s, $start);
    +
    +        $s .= '';
    +        $slen = grapheme_strlen($s);
    +        $start = (int) $start;
    +
    +        if (0 > $start) $start += $slen;
    +        if (0 > $start) return false;
    +        if ($start >= $slen) return false;
    +
    +        $rem = $slen - $start;
    +
    +        if (0 > $len) $len += $rem;
    +        if (0 === $len) return '';
    +        if (0 > $len) return false;
    +        if ($len > $rem) $len = $rem;
    +
    +        return grapheme_substr($s, $start, $len);
    +    }
    +
    +    static function grapheme_strpos  ($s, $needle, $offset = 0) {return self::grapheme_position($s, $needle, $offset, 0);}
    +    static function grapheme_stripos ($s, $needle, $offset = 0) {return self::grapheme_position($s, $needle, $offset, 1);}
    +    static function grapheme_strrpos ($s, $needle, $offset = 0) {return self::grapheme_position($s, $needle, $offset, 2);}
    +    static function grapheme_strripos($s, $needle, $offset = 0) {return self::grapheme_position($s, $needle, $offset, 3);}
    +    static function grapheme_stristr ($s, $needle, $before_needle = false) {return mb_stristr($s, $needle, $before_needle, 'UTF-8');}
    +    static function grapheme_strstr  ($s, $needle, $before_needle = false) {return mb_strstr ($s, $needle, $before_needle, 'UTF-8');}
    +
    +
    +    protected static function grapheme_position($s, $needle, $offset, $mode)
    +    {
    +        if (! preg_match('/./us', $needle .= '')) return false;
    +        if (! preg_match('/./us', $s .= '')) return false;
    +        if ($offset > 0) $s = self::grapheme_substr($s, $offset);
    +        else if ($offset < 0) $offset = 0;
    +
    +        switch ($mode)
    +        {
    +        case 0: $needle = iconv_strpos ($s, $needle, 0, 'UTF-8'); break;
    +        case 1: $needle = mb_stripos   ($s, $needle, 0, 'UTF-8'); break;
    +        case 2: $needle = iconv_strrpos($s, $needle,    'UTF-8'); break;
    +        default: $needle = mb_strripos ($s, $needle, 0, 'UTF-8'); break;
    +        }
    +
    +        return $needle ? self::grapheme_strlen(iconv_substr($s, 0, $needle, 'UTF-8')) + $offset : $needle;
    +    }
    +}
    diff --git a/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/Mbstring.php b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/Mbstring.php
    new file mode 100755
    index 0000000..85784b0
    --- /dev/null
    +++ b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/Mbstring.php
    @@ -0,0 +1,442 @@
    + 2, "\xD0" => 2, "\xE0" => 3, "\xF0" => 4);
    +
    +            $i = 0;
    +            $len = strlen($s);
    +
    +            while ($i < $len)
    +            {
    +                $ulen = $s[$i] < "\x80" ? 1 : $ulen_mask[$s[$i] & "\xF0"];
    +                $uchr = substr($s, $i, $ulen);
    +                $i += $ulen;
    +
    +                if (isset($map[$uchr]))
    +                {
    +                    $uchr = $map[$uchr];
    +                    $nlen = strlen($uchr);
    +
    +                    if ($nlen == $ulen)
    +                    {
    +                        $nlen = $i;
    +                        do $s[--$nlen] = $uchr[--$ulen];
    +                        while ($ulen);
    +                    }
    +                    else
    +                    {
    +                        $s = substr_replace($s, $uchr, $i - $ulen, $ulen);
    +                        $len += $nlen - $ulen;
    +                        $i   += $nlen - $ulen;
    +                    }
    +                }
    +            }
    +        }
    +
    +        if (INF === $encoding) return $s;
    +        else return iconv('UTF-8', $encoding, $s);
    +    }
    +
    +    static function mb_internal_encoding($encoding = INF)
    +    {
    +        if (INF === $encoding) return self::$internal_encoding;
    +        else $encoding = strtoupper($encoding);
    +
    +        if ('UTF-8' === $encoding || 'UTF8' === $encoding || false !== @iconv($encoding, $encoding, ' '))
    +        {
    +            self::$internal_encoding = 'UTF8' === $encoding ? 'UTF-8' : $encoding;
    +
    +            return true;
    +        }
    +
    +        return false;
    +    }
    +
    +    static function mb_language($lang = INF)
    +    {
    +        if (INF === $lang) return self::$language;
    +
    +        switch ($lang = strtolower($lang))
    +        {
    +        case 'uni':
    +        case 'neutral':
    +            self::$language = $lang;
    +            return true;
    +        }
    +
    +        return false;
    +    }
    +
    +    static function mb_list_encodings()
    +    {
    +        return array('UTF-8');
    +    }
    +
    +    static function mb_encoding_aliases($encoding)
    +    {
    +        switch (strtolower($encoding))
    +        {
    +        case 'utf8':
    +        case 'utf-8': return array('utf8');
    +        }
    +
    +        return false;
    +    }
    +
    +    static function mb_check_encoding($var = INF, $encoding = INF)
    +    {
    +        if (INF === $encoding)
    +        {
    +            if (INF === $var) return false;
    +            $encoding = self::$internal_encoding;
    +        }
    +
    +        return false !== mb_detect_encoding($var, array($encoding), true);
    +    }
    +
    +    static function mb_detect_encoding($str, $encoding_list = INF, $strict = false)
    +    {
    +        if (INF === $encoding_list) $encoding_list = self::$encoding_list;
    +        else
    +        {
    +            if (! is_array($encoding_list)) $encoding_list = array_map('trim', explode(',', $encoding_list));
    +            $encoding_list = array_map('strtoupper', $encoding_list);
    +        }
    +
    +        foreach ($encoding_list as $enc)
    +        {
    +            switch ($enc)
    +            {
    +            case 'ASCII':
    +                if (! preg_match('/[\x80-\xFF]/', $str)) return $enc;
    +                break;
    +
    +            case 'UTF8':
    +            case 'UTF-8':
    +                if (preg_match('//u', $str)) return $enc;
    +                break;
    +
    +            default:
    +                return strncmp($enc, 'ISO-8859-', 9) ? false : $enc;
    +            }
    +        }
    +
    +        return false;
    +    }
    +
    +    static function mb_detect_order($encoding_list = INF)
    +    {
    +        if (INF === $encoding_list) return self::$encoding_list;
    +
    +        if (! is_array($encoding_list)) $encoding_list = array_map('trim', explode(',', $encoding_list));
    +        $encoding_list = array_map('strtoupper', $encoding_list);
    +
    +        foreach ($encoding_list as $enc)
    +        {
    +            switch ($enc)
    +            {
    +            default: if (strncmp($enc, 'ISO-8859-', 9)) return false;
    +            case 'ASCII':
    +            case 'UTF8':
    +            case 'UTF-8':
    +            }
    +        }
    +
    +        self::$encoding_list = $encoding_list;
    +
    +        return true;
    +    }
    +
    +    static function mb_strlen($s, $encoding = INF)
    +    {
    +        INF === $encoding && $encoding = self::$internal_encoding;
    +        return iconv_strlen($s, $encoding . '//IGNORE');
    +    }
    +
    +    static function mb_strpos ($haystack, $needle, $offset = 0, $encoding = INF)
    +    {
    +        INF === $encoding && $encoding = self::$internal_encoding;
    +        if ('' === $needle .= '')
    +        {
    +            user_error(__METHOD__ . ': Empty delimiter', E_USER_WARNING);
    +            return false;
    +        }
    +        else return iconv_strpos($haystack, $needle, $offset, $encoding . '//IGNORE');
    +    }
    +
    +    static function mb_strrpos($haystack, $needle, $offset = 0, $encoding = INF)
    +    {
    +        INF === $encoding && $encoding = self::$internal_encoding;
    +
    +        if ($offset != (int) $offset)
    +        {
    +            $offset = 0;
    +        }
    +        else if ($offset = (int) $offset)
    +        {
    +            $haystack = self::mb_substr($haystack, $offset, 2147483647, $encoding);
    +        }
    +
    +        $pos = iconv_strrpos($haystack, $needle, $encoding . '//IGNORE');
    +
    +        return false !== $pos ? $offset + $pos : false;
    +    }
    +
    +    static function mb_strtolower($s, $encoding = INF)
    +    {
    +        return self::mb_convert_case($s, MB_CASE_LOWER, $encoding);
    +    }
    +
    +    static function mb_strtoupper($s, $encoding = INF)
    +    {
    +        return self::mb_convert_case($s, MB_CASE_UPPER, $encoding);
    +    }
    +
    +    static function mb_substitute_character($c = INF)
    +    {
    +        return INF !== $c ? false : 'none';
    +    }
    +
    +    static function mb_substr($s, $start, $length = null, $encoding = INF)
    +    {
    +        INF === $encoding && $encoding = self::$internal_encoding;
    +
    +        if ($start < 0)
    +        {
    +            $start = iconv_strlen($s, $encoding . '//IGNORE') + $start;
    +            if ($start < 0) $start = 0;
    +        }
    +
    +        if (null === $length) $length = 2147483647;
    +        else if ($length < 0)
    +        {
    +            $length = iconv_strlen($s, $encoding . '//IGNORE') + $length - $start;
    +            if ($length < 0) return '';
    +        }
    +
    +        return iconv_substr($s, $start, $length, $encoding . '//IGNORE') . '';
    +    }
    +
    +    static function mb_stripos($haystack, $needle, $offset = 0, $encoding = INF)
    +    {
    +        INF === $encoding && $encoding = self::$internal_encoding;
    +        $haystack = self::mb_convert_case($haystack, self::MB_CASE_FOLD, $encoding);
    +        $needle = self::mb_convert_case($needle, self::MB_CASE_FOLD, $encoding);
    +        return self::mb_strpos($haystack, $needle, $offset, $encoding);
    +    }
    +
    +    static function mb_stristr($haystack, $needle, $part = false, $encoding = INF)
    +    {
    +        $pos = self::mb_stripos($haystack, $needle, 0, $encoding);
    +        return self::getSubpart($pos, $part, $haystack, $encoding);
    +    }
    +
    +    static function mb_strrchr($haystack, $needle, $part = false, $encoding = INF)
    +    {
    +        INF === $encoding && $encoding = self::$internal_encoding;
    +        $needle = self::mb_substr($needle, 0, 1, $encoding);
    +        $pos = iconv_strrpos($haystack, $needle, $encoding);
    +        return self::getSubpart($pos, $part, $haystack, $encoding);
    +    }
    +
    +    static function mb_strrichr($haystack, $needle, $part = false, $encoding = INF)
    +    {
    +        $needle = self::mb_substr($needle, 0, 1, $encoding);
    +        $pos = self::mb_strripos($haystack, $needle, $encoding);
    +        return self::getSubpart($pos, $part, $haystack, $encoding);
    +    }
    +
    +    static function mb_strripos($haystack, $needle, $offset = 0, $encoding = INF)
    +    {
    +        INF === $encoding && $encoding = self::$internal_encoding;
    +        $haystack = self::mb_convert_case($haystack, self::MB_CASE_FOLD, $encoding);
    +        $needle = self::mb_convert_case($needle, self::MB_CASE_FOLD, $encoding);
    +        return self::mb_strrpos($haystack, $needle, $offset, $encoding);
    +    }
    +
    +    static function mb_strstr($haystack, $needle, $part = false, $encoding = INF)
    +    {
    +        $pos = strpos($haystack, $needle);
    +        if (false === $pos) return false;
    +        if ($part) return substr($haystack, 0, $pos);
    +        else return substr($haystack, $pos);
    +    }
    +
    +
    +    protected static function getSubpart($pos, $part, $haystack, $encoding)
    +    {
    +        INF === $encoding && $encoding = self::$internal_encoding;
    +
    +        if (false === $pos) return false;
    +        if ($part) return self::mb_substr($haystack, 0, $pos, $encoding);
    +        else return self::mb_substr($haystack, $pos, null, $encoding);
    +    }
    +
    +    protected static function html_encoding_callback($m)
    +    {
    +        return htmlentities($m[0], ENT_COMPAT, 'UTF-8');
    +    }
    +
    +    protected static function title_case_lower($s)
    +    {
    +        return self::mb_convert_case($s[0], MB_CASE_LOWER, 'UTF-8');
    +    }
    +
    +    protected static function title_case_upper($s)
    +    {
    +        return self::mb_convert_case($s[0], MB_CASE_UPPER, 'UTF-8');
    +    }
    +
    +    protected static function getData($file)
    +    {
    +        $file = __DIR__ . '/unidata/' . $file . '.ser';
    +        if (file_exists($file)) return unserialize(file_get_contents($file));
    +        else return false;
    +    }
    +}
    diff --git a/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/Normalizer.php b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/Normalizer.php
    new file mode 100755
    index 0000000..c296470
    --- /dev/null
    +++ b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/Normalizer.php
    @@ -0,0 +1,295 @@
    + 2, "\xD0" => 2, "\xE0" => 3, "\xF0" => 4),
    +    $ASCII = "\x20\x65\x69\x61\x73\x6E\x74\x72\x6F\x6C\x75\x64\x5D\x5B\x63\x6D\x70\x27\x0A\x67\x7C\x68\x76\x2E\x66\x62\x2C\x3A\x3D\x2D\x71\x31\x30\x43\x32\x2A\x79\x78\x29\x28\x4C\x39\x41\x53\x2F\x50\x22\x45\x6A\x4D\x49\x6B\x33\x3E\x35\x54\x3C\x44\x34\x7D\x42\x7B\x38\x46\x77\x52\x36\x37\x55\x47\x4E\x3B\x4A\x7A\x56\x23\x48\x4F\x57\x5F\x26\x21\x4B\x3F\x58\x51\x25\x59\x5C\x09\x5A\x2B\x7E\x5E\x24\x40\x60\x7F\x00\x01\x02\x03\x04\x05\x06\x07\x08\x0B\x0C\x0D\x0E\x0F\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F";
    +
    +
    +    static function isNormalized($s, $form = self::NFC)
    +    {
    +        if (strspn($s .= '', self::$ASCII) === strlen($s)) return true;
    +        if (self::NFC === $form && preg_match('//u', $s) && !preg_match('/[^\x00-\x{2FF}]/u', $s)) return true;
    +        return false; // Pretend false as quick checks implementented in PHP won't be so quick
    +    }
    +
    +    static function normalize($s, $form = self::NFC)
    +    {
    +        if (!preg_match('//u', $s .= '')) return false;
    +
    +        switch ($form)
    +        {
    +        case self::NONE: return $s;
    +        case self::NFC:  $C = true;  $K = false; break;
    +        case self::NFD:  $C = false; $K = false; break;
    +        case self::NFKC: $C = true;  $K = true;  break;
    +        case self::NFKD: $C = false; $K = true;  break;
    +        default: return false;
    +        }
    +
    +        if ('' === $s) return '';
    +
    +        if ($K && empty(self::$KD)) self::$KD = static::getData('compatibilityDecomposition');
    +
    +        if (empty(self::$D))
    +        {
    +            self::$D = static::getData('canonicalDecomposition');
    +            self::$cC = static::getData('combiningClass');
    +        }
    +
    +        if ($C)
    +        {
    +            if (empty(self::$C)) self::$C = static::getData('canonicalComposition');
    +            return self::recompose(self::decompose($s, $K));
    +        }
    +        else return self::decompose($s, $K);
    +    }
    +
    +    protected static function recompose($s)
    +    {
    +        $ASCII = self::$ASCII;
    +        $compMap = self::$C;
    +        $combClass = self::$cC;
    +        $ulen_mask = self::$ulen_mask;
    +
    +        $result = $tail = '';
    +
    +        $i = $s[0] < "\x80" ? 1 : $ulen_mask[$s[0] & "\xF0"];
    +        $len = strlen($s);
    +
    +        $last_uchr = substr($s, 0, $i);
    +        $last_ucls = isset($combClass[$last_uchr]) ? 256 : 0;
    +
    +        while ($i < $len)
    +        {
    +            if ($s[$i] < "\x80")
    +            {
    +                // ASCII chars
    +
    +                if ($tail)
    +                {
    +                    $last_uchr .= $tail;
    +                    $tail = '';
    +                }
    +
    +                if ($j = strspn($s, $ASCII, $i+1))
    +                {
    +                    $last_uchr .= substr($s, $i, $j);
    +                    $i += $j;
    +                }
    +
    +                $result .= $last_uchr;
    +                $last_uchr = $s[$i];
    +                ++$i;
    +            }
    +            else
    +            {
    +                $ulen = $ulen_mask[$s[$i] & "\xF0"];
    +                $uchr = substr($s, $i, $ulen);
    +
    +                if ($last_uchr < "\xE1\x84\x80" || "\xE1\x84\x92" < $last_uchr
    +                    ||   $uchr < "\xE1\x85\xA1" || "\xE1\x85\xB5" < $uchr
    +                    || $last_ucls)
    +                {
    +                    // Table lookup and combining chars composition
    +
    +                    $ucls = isset($combClass[$uchr]) ? $combClass[$uchr] : 0;
    +
    +                    if (isset($compMap[$last_uchr . $uchr]) && (!$last_ucls || $last_ucls < $ucls))
    +                    {
    +                        $last_uchr = $compMap[$last_uchr . $uchr];
    +                    }
    +                    else if ($last_ucls = $ucls) $tail .= $uchr;
    +                    else
    +                    {
    +                        if ($tail)
    +                        {
    +                            $last_uchr .= $tail;
    +                            $tail = '';
    +                        }
    +
    +                        $result .= $last_uchr;
    +                        $last_uchr = $uchr;
    +                    }
    +                }
    +                else
    +                {
    +                    // Hangul chars
    +
    +                    $L = ord($last_uchr[2]) - 0x80;
    +                    $V = ord($uchr[2]) - 0xA1;
    +                    $T = 0;
    +
    +                    $uchr = substr($s, $i + $ulen, 3);
    +
    +                    if ("\xE1\x86\xA7" <= $uchr && $uchr <= "\xE1\x87\x82")
    +                    {
    +                        $T = ord($uchr[2]) - 0xA7;
    +                        0 > $T && $T += 0x40;
    +                        $ulen += 3;
    +                    }
    +
    +                    $L = 0xAC00 + ($L * 21 + $V) * 28 + $T;
    +                    $last_uchr = chr(0xE0 | $L>>12) . chr(0x80 | $L>>6 & 0x3F) . chr(0x80 | $L & 0x3F);
    +                }
    +
    +                $i += $ulen;
    +            }
    +        }
    +
    +        return $result . $last_uchr . $tail;
    +    }
    +
    +    protected static function decompose($s, $c)
    +    {
    +        $result = '';
    +
    +        $ASCII = self::$ASCII;
    +        $decompMap = self::$D;
    +        $combClass = self::$cC;
    +        $ulen_mask = self::$ulen_mask;
    +        if ($c) $compatMap = self::$KD;
    +
    +        $c = array();
    +        $i = 0;
    +        $len = strlen($s);
    +
    +        while ($i < $len)
    +        {
    +            if ($s[$i] < "\x80")
    +            {
    +                // ASCII chars
    +
    +                if ($c)
    +                {
    +                    ksort($c);
    +                    $result .= implode('', $c);
    +                    $c = array();
    +                }
    +
    +                $j = 1 + strspn($s, $ASCII, $i+1);
    +                $result .= substr($s, $i, $j);
    +                $i += $j;
    +            }
    +            else
    +            {
    +                $ulen = $ulen_mask[$s[$i] & "\xF0"];
    +                $uchr = substr($s, $i, $ulen);
    +                $i += $ulen;
    +
    +                if (isset($combClass[$uchr]))
    +                {
    +                    // Combining chars, for sorting
    +
    +                    isset($c[$combClass[$uchr]]) || $c[$combClass[$uchr]] = '';
    +                    $c[$combClass[$uchr]] .= isset($compatMap[$uchr]) ? $compatMap[$uchr] : (isset($decompMap[$uchr]) ? $decompMap[$uchr] : $uchr);
    +                }
    +                else
    +                {
    +                    if ($c)
    +                    {
    +                        ksort($c);
    +                        $result .= implode('', $c);
    +                        $c = array();
    +                    }
    +
    +                    if ($uchr < "\xEA\xB0\x80" || "\xED\x9E\xA3" < $uchr)
    +                    {
    +                        // Table lookup
    +
    +                        $j = isset($compatMap[$uchr]) ? $compatMap[$uchr] : (isset($decompMap[$uchr]) ? $decompMap[$uchr] : $uchr);
    +
    +                        if ($uchr != $j)
    +                        {
    +                            $uchr = $j;
    +
    +                            $j = strlen($uchr);
    +                            $ulen = $uchr[0] < "\x80" ? 1 : $ulen_mask[$uchr[0] & "\xF0"];
    +
    +                            if ($ulen != $j)
    +                            {
    +                                // Put trailing chars in $s
    +
    +                                $j -= $ulen;
    +                                $i -= $j;
    +
    +                                if (0 > $i)
    +                                {
    +                                    $s = str_repeat(' ', -$i) . $s;
    +                                    $len -= $i;
    +                                    $i = 0;
    +                                }
    +
    +                                while ($j--) $s[$i+$j] = $uchr[$ulen+$j];
    +
    +                                $uchr = substr($uchr, 0, $ulen);
    +                            }
    +                        }
    +                    }
    +                    else
    +                    {
    +                        // Hangul chars
    +
    +                        $uchr = unpack('C*', $uchr);
    +                        $j = (($uchr[1]-224) << 12) + (($uchr[2]-128) << 6) + $uchr[3] - 0xAC80;
    +
    +                        $uchr = "\xE1\x84" . chr(0x80 + (int)  ($j / 588))
    +                              . "\xE1\x85" . chr(0xA1 + (int) (($j % 588) / 28));
    +
    +                        if ($j %= 28)
    +                        {
    +                            $uchr .= $j < 25
    +                                ? ("\xE1\x86" . chr(0xA7 + $j))
    +                                : ("\xE1\x87" . chr(0x67 + $j));
    +                        }
    +                    }
    +
    +                    $result .= $uchr;
    +                }
    +            }
    +        }
    +
    +        if ($c)
    +        {
    +            ksort($c);
    +            $result .= implode('', $c);
    +        }
    +
    +        return $result;
    +    }
    +
    +    protected static function getData($file)
    +    {
    +        $file = __DIR__ . '/unidata/' . $file . '.ser';
    +        if (file_exists($file)) return unserialize(file_get_contents($file));
    +        else return false;
    +    }
    +}
    diff --git a/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/Xml.php b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/Xml.php
    new file mode 100755
    index 0000000..6a44df8
    --- /dev/null
    +++ b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/Xml.php
    @@ -0,0 +1,61 @@
    +> 1, $j = 0; $i < $len; ++$i, ++$j) switch (true)
    +        {
    +        case $s[$i] < "\x80": $s[$j] = $s[$i]; break;
    +        case $s[$i] < "\xC0": $s[$j] = "\xC2"; $s[++$j] = $s[$i]; break;
    +        default:              $s[$j] = "\xC3"; $s[++$j] = chr(ord($s[$i]) - 64); break;
    +        }
    +
    +        return substr($s, 0, $j);
    +    }
    +
    +    static function utf8_decode($s)
    +    {
    +        $s .= '';
    +        $len = strlen($s);
    +
    +        for ($i = 0, $j = 0; $i < $len; ++$i, ++$j)
    +        {
    +            switch ($s[$i] & "\xF0")
    +            {
    +            case "\xC0":
    +            case "\xD0":
    +                $c = (ord($s[$i] & "\x1F") << 6) | ord($s[++$i] & "\x3F");
    +                $s[$j] = $c < 256 ? chr($c) : '?';
    +                break;
    +
    +            case "\xF0": ++$i;
    +            case "\xE0":
    +                $s[$j] = '?';
    +                $i += 2;
    +                break;
    +
    +            default:
    +                $s[$j] = $s[$i];
    +            }
    +        }
    +
    +        return substr($s, 0, $j);
    +    }
    +}
    diff --git a/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.big5.ser b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.big5.ser
    new file mode 100755
    index 0000000..379bc53
    --- /dev/null
    +++ b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.big5.ser
    @@ -0,0 +1 @@
    +a:13710:{s:2:"¡@";s:3:" ";s:2:"¡A";s:3:",";s:2:"¡B";s:3:"ã€";s:2:"¡C";s:3:"。";s:2:"¡D";s:3:".";s:2:"¡E";s:3:"•";s:2:"¡F";s:3:"ï¼›";s:2:"¡G";s:3:":";s:2:"¡H";s:3:"?";s:2:"¡I";s:3:"ï¼";s:2:"¡J";s:3:"︰";s:2:"¡K";s:3:"…";s:2:"¡L";s:3:"‥";s:2:"¡M";s:3:"ï¹";s:2:"¡N";s:3:"、";s:2:"¡O";s:3:"ï¹’";s:2:"¡P";s:2:"·";s:2:"¡Q";s:3:"ï¹”";s:2:"¡R";s:3:"﹕";s:2:"¡S";s:3:"ï¹–";s:2:"¡T";s:3:"ï¹—";s:2:"¡U";s:3:"|";s:2:"¡V";s:3:"–";s:2:"¡W";s:3:"︱";s:2:"¡X";s:3:"—";s:2:"¡Y";s:3:"︳";s:2:"¡Z";s:3:"�";s:2:"¡[";s:3:"︴";s:2:"¡\";s:3:"ï¹";s:2:"¡]";s:3:"(";s:2:"¡^";s:3:")";s:2:"¡_";s:3:"︵";s:2:"¡`";s:3:"︶";s:2:"¡a";s:3:"ï½›";s:2:"¡b";s:3:"ï½";s:2:"¡c";s:3:"︷";s:2:"¡d";s:3:"︸";s:2:"¡e";s:3:"〔";s:2:"¡f";s:3:"〕";s:2:"¡g";s:3:"︹";s:2:"¡h";s:3:"︺";s:2:"¡i";s:3:"ã€";s:2:"¡j";s:3:"】";s:2:"¡k";s:3:"︻";s:2:"¡l";s:3:"︼";s:2:"¡m";s:3:"《";s:2:"¡n";s:3:"》";s:2:"¡o";s:3:"︽";s:2:"¡p";s:3:"︾";s:2:"¡q";s:3:"〈";s:2:"¡r";s:3:"〉";s:2:"¡s";s:3:"︿";s:2:"¡t";s:3:"ï¹€";s:2:"¡u";s:3:"「";s:2:"¡v";s:3:"ã€";s:2:"¡w";s:3:"ï¹";s:2:"¡x";s:3:"﹂";s:2:"¡y";s:3:"『";s:2:"¡z";s:3:"ã€";s:2:"¡{";s:3:"﹃";s:2:"¡|";s:3:"﹄";s:2:"¡}";s:3:"ï¹™";s:2:"¡~";s:3:"﹚";s:2:"¡¡";s:3:"ï¹›";s:2:"¡¢";s:3:"﹜";s:2:"¡£";s:3:"ï¹";s:2:"¡¤";s:3:"﹞";s:2:"¡¥";s:3:"‘";s:2:"¡¦";s:3:"’";s:2:"¡§";s:3:"“";s:2:"¡¨";s:3:"â€";s:2:"¡©";s:3:"ã€";s:2:"¡ª";s:3:"〞";s:2:"¡«";s:3:"‵";s:2:"¡¬";s:3:"′";s:2:"¡­";s:3:"#";s:2:"¡®";s:3:"&";s:2:"¡¯";s:3:"*";s:2:"¡°";s:3:"※";s:2:"¡±";s:2:"§";s:2:"¡²";s:3:"〃";s:2:"¡³";s:3:"â—‹";s:2:"¡´";s:3:"â—";s:2:"¡µ";s:3:"â–³";s:2:"¡¶";s:3:"â–²";s:2:"¡·";s:3:"â—Ž";s:2:"¡¸";s:3:"☆";s:2:"¡¹";s:3:"★";s:2:"¡º";s:3:"â—‡";s:2:"¡»";s:3:"â—†";s:2:"¡¼";s:3:"â–¡";s:2:"¡½";s:3:"â– ";s:2:"¡¾";s:3:"â–½";s:2:"¡¿";s:3:"â–¼";s:2:"¡À";s:3:"㊣";s:2:"¡Á";s:3:"â„…";s:2:"¡Â";s:3:"‾";s:2:"¡Ã";s:3:"�";s:2:"¡Ä";s:3:"_";s:2:"¡Å";s:3:"�";s:2:"¡Æ";s:3:"﹉";s:2:"¡Ç";s:3:"﹊";s:2:"¡È";s:3:"ï¹";s:2:"¡É";s:3:"﹎";s:2:"¡Ê";s:3:"﹋";s:2:"¡Ë";s:3:"﹌";s:2:"¡Ì";s:3:"﹟";s:2:"¡Í";s:3:"ï¹ ";s:2:"¡Î";s:3:"﹡";s:2:"¡Ï";s:3:"+";s:2:"¡Ð";s:3:"ï¼";s:2:"¡Ñ";s:2:"×";s:2:"¡Ò";s:2:"÷";s:2:"¡Ó";s:2:"±";s:2:"¡Ô";s:3:"√";s:2:"¡Õ";s:3:"<";s:2:"¡Ö";s:3:">";s:2:"¡×";s:3:"ï¼";s:2:"¡Ø";s:3:"≦";s:2:"¡Ù";s:3:"≧";s:2:"¡Ú";s:3:"≠";s:2:"¡Û";s:3:"∞";s:2:"¡Ü";s:3:"≒";s:2:"¡Ý";s:3:"≡";s:2:"¡Þ";s:3:"ï¹¢";s:2:"¡ß";s:3:"ï¹£";s:2:"¡à";s:3:"﹤";s:2:"¡á";s:3:"ï¹¥";s:2:"¡â";s:3:"﹦";s:2:"¡ã";s:3:"∼";s:2:"¡ä";s:3:"∩";s:2:"¡å";s:3:"∪";s:2:"¡æ";s:3:"⊥";s:2:"¡ç";s:3:"∠";s:2:"¡è";s:3:"∟";s:2:"¡é";s:3:"⊿";s:2:"¡ê";s:3:"ã’";s:2:"¡ë";s:3:"ã‘";s:2:"¡ì";s:3:"∫";s:2:"¡í";s:3:"∮";s:2:"¡î";s:3:"∵";s:2:"¡ï";s:3:"∴";s:2:"¡ð";s:3:"♀";s:2:"¡ñ";s:3:"♂";s:2:"¡ò";s:3:"â™";s:2:"¡ó";s:3:"☉";s:2:"¡ô";s:3:"↑";s:2:"¡õ";s:3:"↓";s:2:"¡ö";s:3:"â†";s:2:"¡÷";s:3:"→";s:2:"¡ø";s:3:"↖";s:2:"¡ù";s:3:"↗";s:2:"¡ú";s:3:"↙";s:2:"¡û";s:3:"↘";s:2:"¡ü";s:3:"∥";s:2:"¡ý";s:3:"∣";s:2:"¡þ";s:3:"�";s:2:"¢@";s:3:"�";s:2:"¢A";s:3:"ï¼";s:2:"¢B";s:3:"ï¼¼";s:2:"¢C";s:3:"$";s:2:"¢D";s:2:"Â¥";s:2:"¢E";s:3:"〒";s:2:"¢F";s:2:"¢";s:2:"¢G";s:2:"£";s:2:"¢H";s:3:"ï¼…";s:2:"¢I";s:3:"ï¼ ";s:2:"¢J";s:3:"℃";s:2:"¢K";s:3:"℉";s:2:"¢L";s:3:"﹩";s:2:"¢M";s:3:"﹪";s:2:"¢N";s:3:"﹫";s:2:"¢O";s:3:"ã•";s:2:"¢P";s:3:"㎜";s:2:"¢Q";s:3:"ãŽ";s:2:"¢R";s:3:"㎞";s:2:"¢S";s:3:"ãŽ";s:2:"¢T";s:3:"㎡";s:2:"¢U";s:3:"㎎";s:2:"¢V";s:3:"ãŽ";s:2:"¢W";s:3:"ã„";s:2:"¢X";s:2:"°";s:2:"¢Y";s:3:"å…™";s:2:"¢Z";s:3:"å…›";s:2:"¢[";s:3:"å…ž";s:2:"¢\";s:3:"å…";s:2:"¢]";s:3:"å…¡";s:2:"¢^";s:3:"å…£";s:2:"¢_";s:3:"å—§";s:2:"¢`";s:3:"ç“©";s:2:"¢a";s:3:"糎";s:2:"¢b";s:3:"â–";s:2:"¢c";s:3:"â–‚";s:2:"¢d";s:3:"â–ƒ";s:2:"¢e";s:3:"â–„";s:2:"¢f";s:3:"â–…";s:2:"¢g";s:3:"â–†";s:2:"¢h";s:3:"â–‡";s:2:"¢i";s:3:"â–ˆ";s:2:"¢j";s:3:"â–";s:2:"¢k";s:3:"â–Ž";s:2:"¢l";s:3:"â–";s:2:"¢m";s:3:"â–Œ";s:2:"¢n";s:3:"â–‹";s:2:"¢o";s:3:"â–Š";s:2:"¢p";s:3:"â–‰";s:2:"¢q";s:3:"┼";s:2:"¢r";s:3:"â”´";s:2:"¢s";s:3:"┬";s:2:"¢t";s:3:"┤";s:2:"¢u";s:3:"├";s:2:"¢v";s:3:"â–”";s:2:"¢w";s:3:"─";s:2:"¢x";s:3:"│";s:2:"¢y";s:3:"â–•";s:2:"¢z";s:3:"┌";s:2:"¢{";s:3:"â”";s:2:"¢|";s:3:"â””";s:2:"¢}";s:3:"┘";s:2:"¢~";s:3:"â•­";s:2:"¢¡";s:3:"â•®";s:2:"¢¢";s:3:"â•°";s:2:"¢£";s:3:"╯";s:2:"¢¤";s:3:"â•";s:2:"¢¥";s:3:"â•ž";s:2:"¢¦";s:3:"╪";s:2:"¢§";s:3:"â•¡";s:2:"¢¨";s:3:"â—¢";s:2:"¢©";s:3:"â—£";s:2:"¢ª";s:3:"â—¥";s:2:"¢«";s:3:"â—¤";s:2:"¢¬";s:3:"╱";s:2:"¢­";s:3:"╲";s:2:"¢®";s:3:"╳";s:2:"¢¯";s:3:"ï¼";s:2:"¢°";s:3:"1";s:2:"¢±";s:3:"ï¼’";s:2:"¢²";s:3:"3";s:2:"¢³";s:3:"ï¼”";s:2:"¢´";s:3:"5";s:2:"¢µ";s:3:"ï¼–";s:2:"¢¶";s:3:"ï¼—";s:2:"¢·";s:3:"8";s:2:"¢¸";s:3:"ï¼™";s:2:"¢¹";s:3:"â… ";s:2:"¢º";s:3:"â…¡";s:2:"¢»";s:3:"â…¢";s:2:"¢¼";s:3:"â…£";s:2:"¢½";s:3:"â…¤";s:2:"¢¾";s:3:"â…¥";s:2:"¢¿";s:3:"â…¦";s:2:"¢À";s:3:"â…§";s:2:"¢Á";s:3:"â…¨";s:2:"¢Â";s:3:"â…©";s:2:"¢Ã";s:3:"〡";s:2:"¢Ä";s:3:"〢";s:2:"¢Å";s:3:"〣";s:2:"¢Æ";s:3:"〤";s:2:"¢Ç";s:3:"〥";s:2:"¢È";s:3:"〦";s:2:"¢É";s:3:"〧";s:2:"¢Ê";s:3:"〨";s:2:"¢Ë";s:3:"〩";s:2:"¢Ì";s:3:"�";s:2:"¢Í";s:3:"å„";s:2:"¢Î";s:3:"�";s:2:"¢Ï";s:3:"A";s:2:"¢Ð";s:3:"ï¼¢";s:2:"¢Ñ";s:3:"ï¼£";s:2:"¢Ò";s:3:"D";s:2:"¢Ó";s:3:"ï¼¥";s:2:"¢Ô";s:3:"F";s:2:"¢Õ";s:3:"G";s:2:"¢Ö";s:3:"H";s:2:"¢×";s:3:"I";s:2:"¢Ø";s:3:"J";s:2:"¢Ù";s:3:"K";s:2:"¢Ú";s:3:"L";s:2:"¢Û";s:3:"ï¼­";s:2:"¢Ü";s:3:"ï¼®";s:2:"¢Ý";s:3:"O";s:2:"¢Þ";s:3:"ï¼°";s:2:"¢ß";s:3:"ï¼±";s:2:"¢à";s:3:"ï¼²";s:2:"¢á";s:3:"ï¼³";s:2:"¢â";s:3:"ï¼´";s:2:"¢ã";s:3:"ï¼µ";s:2:"¢ä";s:3:"V";s:2:"¢å";s:3:"ï¼·";s:2:"¢æ";s:3:"X";s:2:"¢ç";s:3:"ï¼¹";s:2:"¢è";s:3:"Z";s:2:"¢é";s:3:"ï½";s:2:"¢ê";s:3:"b";s:2:"¢ë";s:3:"c";s:2:"¢ì";s:3:"d";s:2:"¢í";s:3:"ï½…";s:2:"¢î";s:3:"f";s:2:"¢ï";s:3:"g";s:2:"¢ð";s:3:"h";s:2:"¢ñ";s:3:"i";s:2:"¢ò";s:3:"j";s:2:"¢ó";s:3:"k";s:2:"¢ô";s:3:"l";s:2:"¢õ";s:3:"ï½";s:2:"¢ö";s:3:"n";s:2:"¢÷";s:3:"ï½";s:2:"¢ø";s:3:"ï½";s:2:"¢ù";s:3:"q";s:2:"¢ú";s:3:"ï½’";s:2:"¢û";s:3:"s";s:2:"¢ü";s:3:"ï½”";s:2:"¢ý";s:3:"u";s:2:"¢þ";s:3:"ï½–";s:2:"£@";s:3:"ï½—";s:2:"£A";s:3:"x";s:2:"£B";s:3:"ï½™";s:2:"£C";s:3:"z";s:2:"£D";s:2:"Α";s:2:"£E";s:2:"Î’";s:2:"£F";s:2:"Γ";s:2:"£G";s:2:"Δ";s:2:"£H";s:2:"Ε";s:2:"£I";s:2:"Ζ";s:2:"£J";s:2:"Η";s:2:"£K";s:2:"Θ";s:2:"£L";s:2:"Ι";s:2:"£M";s:2:"Κ";s:2:"£N";s:2:"Λ";s:2:"£O";s:2:"Îœ";s:2:"£P";s:2:"Î";s:2:"£Q";s:2:"Ξ";s:2:"£R";s:2:"Ο";s:2:"£S";s:2:"Π";s:2:"£T";s:2:"Ρ";s:2:"£U";s:2:"Σ";s:2:"£V";s:2:"Τ";s:2:"£W";s:2:"Î¥";s:2:"£X";s:2:"Φ";s:2:"£Y";s:2:"Χ";s:2:"£Z";s:2:"Ψ";s:2:"£[";s:2:"Ω";s:2:"£\";s:2:"α";s:2:"£]";s:2:"β";s:2:"£^";s:2:"γ";s:2:"£_";s:2:"δ";s:2:"£`";s:2:"ε";s:2:"£a";s:2:"ζ";s:2:"£b";s:2:"η";s:2:"£c";s:2:"θ";s:2:"£d";s:2:"ι";s:2:"£e";s:2:"κ";s:2:"£f";s:2:"λ";s:2:"£g";s:2:"μ";s:2:"£h";s:2:"ν";s:2:"£i";s:2:"ξ";s:2:"£j";s:2:"ο";s:2:"£k";s:2:"Ï€";s:2:"£l";s:2:"Ï";s:2:"£m";s:2:"σ";s:2:"£n";s:2:"Ï„";s:2:"£o";s:2:"Ï…";s:2:"£p";s:2:"φ";s:2:"£q";s:2:"χ";s:2:"£r";s:2:"ψ";s:2:"£s";s:2:"ω";s:2:"£t";s:3:"ã„…";s:2:"£u";s:3:"ㄆ";s:2:"£v";s:3:"ㄇ";s:2:"£w";s:3:"ㄈ";s:2:"£x";s:3:"ㄉ";s:2:"£y";s:3:"ã„Š";s:2:"£z";s:3:"ã„‹";s:2:"£{";s:3:"ã„Œ";s:2:"£|";s:3:"ã„";s:2:"£}";s:3:"ã„Ž";s:2:"£~";s:3:"ã„";s:2:"£¡";s:3:"ã„";s:2:"£¢";s:3:"ã„‘";s:2:"££";s:3:"ã„’";s:2:"£¤";s:3:"ã„“";s:2:"£¥";s:3:"ã„”";s:2:"£¦";s:3:"ã„•";s:2:"£§";s:3:"ã„–";s:2:"£¨";s:3:"ã„—";s:2:"£©";s:3:"ㄘ";s:2:"£ª";s:3:"ã„™";s:2:"£«";s:3:"ã„š";s:2:"£¬";s:3:"ã„›";s:2:"£­";s:3:"ã„œ";s:2:"£®";s:3:"ã„";s:2:"£¯";s:3:"ã„ž";s:2:"£°";s:3:"ã„Ÿ";s:2:"£±";s:3:"ã„ ";s:2:"£²";s:3:"ã„¡";s:2:"£³";s:3:"ã„¢";s:2:"£´";s:3:"ã„£";s:2:"£µ";s:3:"ㄤ";s:2:"£¶";s:3:"ã„¥";s:2:"£·";s:3:"ㄦ";s:2:"£¸";s:3:"ㄧ";s:2:"£¹";s:3:"ㄨ";s:2:"£º";s:3:"ã„©";s:2:"£»";s:2:"Ë™";s:2:"£¼";s:2:"ˉ";s:2:"£½";s:2:"ËŠ";s:2:"£¾";s:2:"ˇ";s:2:"£¿";s:2:"Ë‹";s:2:"¤@";s:3:"一";s:2:"¤A";s:3:"ä¹™";s:2:"¤B";s:3:"ä¸";s:2:"¤C";s:3:"七";s:2:"¤D";s:3:"乃";s:2:"¤E";s:3:"ä¹";s:2:"¤F";s:3:"了";s:2:"¤G";s:3:"二";s:2:"¤H";s:3:"人";s:2:"¤I";s:3:"å„¿";s:2:"¤J";s:3:"å…¥";s:2:"¤K";s:3:"å…«";s:2:"¤L";s:3:"几";s:2:"¤M";s:3:"刀";s:2:"¤N";s:3:"åˆ";s:2:"¤O";s:3:"力";s:2:"¤P";s:3:"匕";s:2:"¤Q";s:3:"å";s:2:"¤R";s:3:"åœ";s:2:"¤S";s:3:"åˆ";s:2:"¤T";s:3:"三";s:2:"¤U";s:3:"下";s:2:"¤V";s:3:"丈";s:2:"¤W";s:3:"上";s:2:"¤X";s:3:"丫";s:2:"¤Y";s:3:"丸";s:2:"¤Z";s:3:"凡";s:2:"¤[";s:3:"ä¹…";s:2:"¤\";s:3:"么";s:2:"¤]";s:3:"也";s:2:"¤^";s:3:"乞";s:2:"¤_";s:3:"于";s:2:"¤`";s:3:"亡";s:2:"¤a";s:3:"å…€";s:2:"¤b";s:3:"刃";s:2:"¤c";s:3:"勺";s:2:"¤d";s:3:"åƒ";s:2:"¤e";s:3:"å‰";s:2:"¤f";s:3:"å£";s:2:"¤g";s:3:"土";s:2:"¤h";s:3:"士";s:2:"¤i";s:3:"夕";s:2:"¤j";s:3:"大";s:2:"¤k";s:3:"女";s:2:"¤l";s:3:"å­";s:2:"¤m";s:3:"å­‘";s:2:"¤n";s:3:"å­“";s:2:"¤o";s:3:"寸";s:2:"¤p";s:3:"å°";s:2:"¤q";s:3:"å°¢";s:2:"¤r";s:3:"å°¸";s:2:"¤s";s:3:"å±±";s:2:"¤t";s:3:"å·";s:2:"¤u";s:3:"å·¥";s:2:"¤v";s:3:"å·±";s:2:"¤w";s:3:"å·²";s:2:"¤x";s:3:"å·³";s:2:"¤y";s:3:"å·¾";s:2:"¤z";s:3:"å¹²";s:2:"¤{";s:3:"廾";s:2:"¤|";s:3:"弋";s:2:"¤}";s:3:"弓";s:2:"¤~";s:3:"æ‰";s:2:"¤¡";s:3:"丑";s:2:"¤¢";s:3:"ä¸";s:2:"¤£";s:3:"ä¸";s:2:"¤¤";s:3:"中";s:2:"¤¥";s:3:"丰";s:2:"¤¦";s:3:"丹";s:2:"¤§";s:3:"之";s:2:"¤¨";s:3:"å°¹";s:2:"¤©";s:3:"予";s:2:"¤ª";s:3:"云";s:2:"¤«";s:3:"井";s:2:"¤¬";s:3:"互";s:2:"¤­";s:3:"五";s:2:"¤®";s:3:"亢";s:2:"¤¯";s:3:"ä»";s:2:"¤°";s:3:"什";s:2:"¤±";s:3:"仃";s:2:"¤²";s:3:"仆";s:2:"¤³";s:3:"仇";s:2:"¤´";s:3:"ä»";s:2:"¤µ";s:3:"今";s:2:"¤¶";s:3:"介";s:2:"¤·";s:3:"仄";s:2:"¤¸";s:3:"å…ƒ";s:2:"¤¹";s:3:"å…";s:2:"¤º";s:3:"å…§";s:2:"¤»";s:3:"å…­";s:2:"¤¼";s:3:"å…®";s:2:"¤½";s:3:"å…¬";s:2:"¤¾";s:3:"冗";s:2:"¤¿";s:3:"凶";s:2:"¤À";s:3:"分";s:2:"¤Á";s:3:"切";s:2:"¤Â";s:3:"刈";s:2:"¤Ã";s:3:"å‹»";s:2:"¤Ä";s:3:"勾";s:2:"¤Å";s:3:"å‹¿";s:2:"¤Æ";s:3:"化";s:2:"¤Ç";s:3:"匹";s:2:"¤È";s:3:"åˆ";s:2:"¤É";s:3:"å‡";s:2:"¤Ê";s:3:"å…";s:2:"¤Ë";s:3:"åž";s:2:"¤Ì";s:3:"厄";s:2:"¤Í";s:3:"å‹";s:2:"¤Î";s:3:"åŠ";s:2:"¤Ï";s:3:"å";s:2:"¤Ð";s:3:"壬";s:2:"¤Ñ";s:3:"天";s:2:"¤Ò";s:3:"夫";s:2:"¤Ó";s:3:"太";s:2:"¤Ô";s:3:"夭";s:2:"¤Õ";s:3:"å­”";s:2:"¤Ö";s:3:"å°‘";s:2:"¤×";s:3:"å°¤";s:2:"¤Ø";s:3:"å°º";s:2:"¤Ù";s:3:"屯";s:2:"¤Ú";s:3:"å·´";s:2:"¤Û";s:3:"å¹»";s:2:"¤Ü";s:3:"廿";s:2:"¤Ý";s:3:"å¼”";s:2:"¤Þ";s:3:"引";s:2:"¤ß";s:3:"心";s:2:"¤à";s:3:"戈";s:2:"¤á";s:3:"戶";s:2:"¤â";s:3:"手";s:2:"¤ã";s:3:"扎";s:2:"¤ä";s:3:"支";s:2:"¤å";s:3:"æ–‡";s:2:"¤æ";s:3:"æ–—";s:2:"¤ç";s:3:"æ–¤";s:2:"¤è";s:3:"æ–¹";s:2:"¤é";s:3:"æ—¥";s:2:"¤ê";s:3:"æ›°";s:2:"¤ë";s:3:"月";s:2:"¤ì";s:3:"木";s:2:"¤í";s:3:"欠";s:2:"¤î";s:3:"æ­¢";s:2:"¤ï";s:3:"æ­¹";s:2:"¤ð";s:3:"毋";s:2:"¤ñ";s:3:"比";s:2:"¤ò";s:3:"毛";s:2:"¤ó";s:3:"æ°";s:2:"¤ô";s:3:"æ°´";s:2:"¤õ";s:3:"ç«";s:2:"¤ö";s:3:"爪";s:2:"¤÷";s:3:"父";s:2:"¤ø";s:3:"爻";s:2:"¤ù";s:3:"片";s:2:"¤ú";s:3:"牙";s:2:"¤û";s:3:"牛";s:2:"¤ü";s:3:"犬";s:2:"¤ý";s:3:"王";s:2:"¤þ";s:3:"丙";s:2:"¥@";s:3:"世";s:2:"¥A";s:3:"丕";s:2:"¥B";s:3:"且";s:2:"¥C";s:3:"丘";s:2:"¥D";s:3:"主";s:2:"¥E";s:3:"ä¹";s:2:"¥F";s:3:"ä¹";s:2:"¥G";s:3:"乎";s:2:"¥H";s:3:"以";s:2:"¥I";s:3:"付";s:2:"¥J";s:3:"ä»”";s:2:"¥K";s:3:"仕";s:2:"¥L";s:3:"ä»–";s:2:"¥M";s:3:"ä»—";s:2:"¥N";s:3:"代";s:2:"¥O";s:3:"令";s:2:"¥P";s:3:"ä»™";s:2:"¥Q";s:3:"仞";s:2:"¥R";s:3:"å……";s:2:"¥S";s:3:"å…„";s:2:"¥T";s:3:"冉";s:2:"¥U";s:3:"冊";s:2:"¥V";s:3:"冬";s:2:"¥W";s:3:"凹";s:2:"¥X";s:3:"出";s:2:"¥Y";s:3:"凸";s:2:"¥Z";s:3:"刊";s:2:"¥[";s:3:"加";s:2:"¥\";s:3:"功";s:2:"¥]";s:3:"包";s:2:"¥^";s:3:"匆";s:2:"¥_";s:3:"北";s:2:"¥`";s:3:"åŒ";s:2:"¥a";s:3:"仟";s:2:"¥b";s:3:"åŠ";s:2:"¥c";s:3:"å‰";s:2:"¥d";s:3:"å¡";s:2:"¥e";s:3:"å ";s:2:"¥f";s:3:"å¯";s:2:"¥g";s:3:"å®";s:2:"¥h";s:3:"去";s:2:"¥i";s:3:"å¯";s:2:"¥j";s:3:"å¤";s:2:"¥k";s:3:"å³";s:2:"¥l";s:3:"å¬";s:2:"¥m";s:3:"å®";s:2:"¥n";s:3:"å©";s:2:"¥o";s:3:"å¨";s:2:"¥p";s:3:"å¼";s:2:"¥q";s:3:"å¸";s:2:"¥r";s:3:"åµ";s:2:"¥s";s:3:"å«";s:2:"¥t";s:3:"å¦";s:2:"¥u";s:3:"åª";s:2:"¥v";s:3:"å²";s:2:"¥w";s:3:"å±";s:2:"¥x";s:3:"å°";s:2:"¥y";s:3:"å¥";s:2:"¥z";s:3:"å­";s:2:"¥{";s:3:"å»";s:2:"¥|";s:3:"å››";s:2:"¥}";s:3:"囚";s:2:"¥~";s:3:"外";s:2:"¥¡";s:3:"央";s:2:"¥¢";s:3:"失";s:2:"¥£";s:3:"奴";s:2:"¥¤";s:3:"奶";s:2:"¥¥";s:3:"å­•";s:2:"¥¦";s:3:"它";s:2:"¥§";s:3:"å°¼";s:2:"¥¨";s:3:"å·¨";s:2:"¥©";s:3:"å·§";s:2:"¥ª";s:3:"å·¦";s:2:"¥«";s:3:"市";s:2:"¥¬";s:3:"布";s:2:"¥­";s:3:"å¹³";s:2:"¥®";s:3:"å¹¼";s:2:"¥¯";s:3:"å¼";s:2:"¥°";s:3:"弘";s:2:"¥±";s:3:"å¼—";s:2:"¥²";s:3:"å¿…";s:2:"¥³";s:3:"戊";s:2:"¥´";s:3:"打";s:2:"¥µ";s:3:"扔";s:2:"¥¶";s:3:"扒";s:2:"¥·";s:3:"扑";s:2:"¥¸";s:3:"æ–¥";s:2:"¥¹";s:3:"æ—¦";s:2:"¥º";s:3:"朮";s:2:"¥»";s:3:"本";s:2:"¥¼";s:3:"未";s:2:"¥½";s:3:"末";s:2:"¥¾";s:3:"札";s:2:"¥¿";s:3:"æ­£";s:2:"¥À";s:3:"æ¯";s:2:"¥Á";s:3:"æ°‘";s:2:"¥Â";s:3:"æ°";s:2:"¥Ã";s:3:"æ°¸";s:2:"¥Ä";s:3:"æ±";s:2:"¥Å";s:3:"æ±€";s:2:"¥Æ";s:3:"æ°¾";s:2:"¥Ç";s:3:"犯";s:2:"¥È";s:3:"玄";s:2:"¥É";s:3:"玉";s:2:"¥Ê";s:3:"ç“œ";s:2:"¥Ë";s:3:"瓦";s:2:"¥Ì";s:3:"甘";s:2:"¥Í";s:3:"生";s:2:"¥Î";s:3:"用";s:2:"¥Ï";s:3:"甩";s:2:"¥Ð";s:3:"ç”°";s:2:"¥Ñ";s:3:"ç”±";s:2:"¥Ò";s:3:"甲";s:2:"¥Ó";s:3:"申";s:2:"¥Ô";s:3:"ç–‹";s:2:"¥Õ";s:3:"白";s:2:"¥Ö";s:3:"çš®";s:2:"¥×";s:3:"çš¿";s:2:"¥Ø";s:3:"ç›®";s:2:"¥Ù";s:3:"矛";s:2:"¥Ú";s:3:"矢";s:2:"¥Û";s:3:"石";s:2:"¥Ü";s:3:"示";s:2:"¥Ý";s:3:"禾";s:2:"¥Þ";s:3:"ç©´";s:2:"¥ß";s:3:"ç«‹";s:2:"¥à";s:3:"丞";s:2:"¥á";s:3:"丟";s:2:"¥â";s:3:"ä¹’";s:2:"¥ã";s:3:"乓";s:2:"¥ä";s:3:"乩";s:2:"¥å";s:3:"亙";s:2:"¥æ";s:3:"交";s:2:"¥ç";s:3:"亦";s:2:"¥è";s:3:"亥";s:2:"¥é";s:3:"仿";s:2:"¥ê";s:3:"伉";s:2:"¥ë";s:3:"ä¼™";s:2:"¥ì";s:3:"伊";s:2:"¥í";s:3:"伕";s:2:"¥î";s:3:"ä¼";s:2:"¥ï";s:3:"ä¼";s:2:"¥ð";s:3:"休";s:2:"¥ñ";s:3:"ä¼";s:2:"¥ò";s:3:"仲";s:2:"¥ó";s:3:"件";s:2:"¥ô";s:3:"ä»»";s:2:"¥õ";s:3:"ä»°";s:2:"¥ö";s:3:"仳";s:2:"¥÷";s:3:"份";s:2:"¥ø";s:3:"ä¼";s:2:"¥ù";s:3:"伋";s:2:"¥ú";s:3:"å…‰";s:2:"¥û";s:3:"å…‡";s:2:"¥ü";s:3:"å…†";s:2:"¥ý";s:3:"å…ˆ";s:2:"¥þ";s:3:"å…¨";s:2:"¦@";s:3:"å…±";s:2:"¦A";s:3:"å†";s:2:"¦B";s:3:"冰";s:2:"¦C";s:3:"列";s:2:"¦D";s:3:"刑";s:2:"¦E";s:3:"划";s:2:"¦F";s:3:"刎";s:2:"¦G";s:3:"刖";s:2:"¦H";s:3:"劣";s:2:"¦I";s:3:"匈";s:2:"¦J";s:3:"匡";s:2:"¦K";s:3:"匠";s:2:"¦L";s:3:"å°";s:2:"¦M";s:3:"å±";s:2:"¦N";s:3:"å‰";s:2:"¦O";s:3:"å";s:2:"¦P";s:3:"åŒ";s:2:"¦Q";s:3:"åŠ";s:2:"¦R";s:3:"å";s:2:"¦S";s:3:"å";s:2:"¦T";s:3:"å‹";s:2:"¦U";s:3:"å„";s:2:"¦V";s:3:"å‘";s:2:"¦W";s:3:"å";s:2:"¦X";s:3:"åˆ";s:2:"¦Y";s:3:"åƒ";s:2:"¦Z";s:3:"åŽ";s:2:"¦[";s:3:"å†";s:2:"¦\";s:3:"å’";s:2:"¦]";s:3:"å› ";s:2:"¦^";s:3:"回";s:2:"¦_";s:3:"å›";s:2:"¦`";s:3:"圳";s:2:"¦a";s:3:"地";s:2:"¦b";s:3:"在";s:2:"¦c";s:3:"圭";s:2:"¦d";s:3:"圬";s:2:"¦e";s:3:"圯";s:2:"¦f";s:3:"圩";s:2:"¦g";s:3:"夙";s:2:"¦h";s:3:"多";s:2:"¦i";s:3:"夷";s:2:"¦j";s:3:"夸";s:2:"¦k";s:3:"妄";s:2:"¦l";s:3:"奸";s:2:"¦m";s:3:"妃";s:2:"¦n";s:3:"好";s:2:"¦o";s:3:"她";s:2:"¦p";s:3:"如";s:2:"¦q";s:3:"å¦";s:2:"¦r";s:3:"å­—";s:2:"¦s";s:3:"å­˜";s:2:"¦t";s:3:"宇";s:2:"¦u";s:3:"守";s:2:"¦v";s:3:"å®…";s:2:"¦w";s:3:"安";s:2:"¦x";s:3:"寺";s:2:"¦y";s:3:"å°–";s:2:"¦z";s:3:"å±¹";s:2:"¦{";s:3:"å·ž";s:2:"¦|";s:3:"帆";s:2:"¦}";s:3:"并";s:2:"¦~";s:3:"å¹´";s:2:"¦¡";s:3:"å¼";s:2:"¦¢";s:3:"å¼›";s:2:"¦£";s:3:"å¿™";s:2:"¦¤";s:3:"å¿–";s:2:"¦¥";s:3:"戎";s:2:"¦¦";s:3:"戌";s:2:"¦§";s:3:"æˆ";s:2:"¦¨";s:3:"æˆ";s:2:"¦©";s:3:"扣";s:2:"¦ª";s:3:"扛";s:2:"¦«";s:3:"托";s:2:"¦¬";s:3:"收";s:2:"¦­";s:3:"æ—©";s:2:"¦®";s:3:"æ—¨";s:2:"¦¯";s:3:"æ—¬";s:2:"¦°";s:3:"æ—­";s:2:"¦±";s:3:"曲";s:2:"¦²";s:3:"曳";s:2:"¦³";s:3:"有";s:2:"¦´";s:3:"朽";s:2:"¦µ";s:3:"朴";s:2:"¦¶";s:3:"朱";s:2:"¦·";s:3:"朵";s:2:"¦¸";s:3:"次";s:2:"¦¹";s:3:"æ­¤";s:2:"¦º";s:3:"æ­»";s:2:"¦»";s:3:"æ°–";s:2:"¦¼";s:3:"æ±";s:2:"¦½";s:3:"æ±—";s:2:"¦¾";s:3:"æ±™";s:2:"¦¿";s:3:"江";s:2:"¦À";s:3:"æ± ";s:2:"¦Á";s:3:"æ±";s:2:"¦Â";s:3:"汕";s:2:"¦Ã";s:3:"污";s:2:"¦Ä";s:3:"æ±›";s:2:"¦Å";s:3:"æ±";s:2:"¦Æ";s:3:"汎";s:2:"¦Ç";s:3:"ç°";s:2:"¦È";s:3:"牟";s:2:"¦É";s:3:"ç‰";s:2:"¦Ê";s:3:"百";s:2:"¦Ë";s:3:"竹";s:2:"¦Ì";s:3:"ç±³";s:2:"¦Í";s:3:"糸";s:2:"¦Î";s:3:"缶";s:2:"¦Ï";s:3:"羊";s:2:"¦Ð";s:3:"ç¾½";s:2:"¦Ñ";s:3:"è€";s:2:"¦Ò";s:3:"考";s:2:"¦Ó";s:3:"而";s:2:"¦Ô";s:3:"耒";s:2:"¦Õ";s:3:"耳";s:2:"¦Ö";s:3:"è¿";s:2:"¦×";s:3:"肉";s:2:"¦Ø";s:3:"è‚‹";s:2:"¦Ù";s:3:"è‚Œ";s:2:"¦Ú";s:3:"臣";s:2:"¦Û";s:3:"自";s:2:"¦Ü";s:3:"至";s:2:"¦Ý";s:3:"臼";s:2:"¦Þ";s:3:"舌";s:2:"¦ß";s:3:"舛";s:2:"¦à";s:3:"舟";s:2:"¦á";s:3:"艮";s:2:"¦â";s:3:"色";s:2:"¦ã";s:3:"艾";s:2:"¦ä";s:3:"虫";s:2:"¦å";s:3:"è¡€";s:2:"¦æ";s:3:"è¡Œ";s:2:"¦ç";s:3:"è¡£";s:2:"¦è";s:3:"西";s:2:"¦é";s:3:"阡";s:2:"¦ê";s:3:"串";s:2:"¦ë";s:3:"亨";s:2:"¦ì";s:3:"ä½";s:2:"¦í";s:3:"ä½";s:2:"¦î";s:3:"佇";s:2:"¦ï";s:3:"ä½—";s:2:"¦ð";s:3:"佞";s:2:"¦ñ";s:3:"ä¼´";s:2:"¦ò";s:3:"ä½›";s:2:"¦ó";s:3:"何";s:2:"¦ô";s:3:"ä¼°";s:2:"¦õ";s:3:"ä½";s:2:"¦ö";s:3:"佑";s:2:"¦÷";s:3:"ä¼½";s:2:"¦ø";s:3:"伺";s:2:"¦ù";s:3:"伸";s:2:"¦ú";s:3:"佃";s:2:"¦û";s:3:"ä½”";s:2:"¦ü";s:3:"ä¼¼";s:2:"¦ý";s:3:"但";s:2:"¦þ";s:3:"ä½£";s:2:"§@";s:3:"作";s:2:"§A";s:3:"ä½ ";s:2:"§B";s:3:"伯";s:2:"§C";s:3:"低";s:2:"§D";s:3:"伶";s:2:"§E";s:3:"ä½™";s:2:"§F";s:3:"ä½";s:2:"§G";s:3:"佈";s:2:"§H";s:3:"佚";s:2:"§I";s:3:"å…Œ";s:2:"§J";s:3:"å…‹";s:2:"§K";s:3:"å…";s:2:"§L";s:3:"å…µ";s:2:"§M";s:3:"冶";s:2:"§N";s:3:"冷";s:2:"§O";s:3:"別";s:2:"§P";s:3:"判";s:2:"§Q";s:3:"利";s:2:"§R";s:3:"刪";s:2:"§S";s:3:"刨";s:2:"§T";s:3:"劫";s:2:"§U";s:3:"助";s:2:"§V";s:3:"努";s:2:"§W";s:3:"劬";s:2:"§X";s:3:"匣";s:2:"§Y";s:3:"å³";s:2:"§Z";s:3:"åµ";s:2:"§[";s:3:"å";s:2:"§\";s:3:"å­";s:2:"§]";s:3:"åž";s:2:"§^";s:3:"å¾";s:2:"§_";s:3:"å¦";s:2:"§`";s:3:"å‘Ž";s:2:"§a";s:3:"å§";s:2:"§b";s:3:"呆";s:2:"§c";s:3:"呃";s:2:"§d";s:3:"å³";s:2:"§e";s:3:"呈";s:2:"§f";s:3:"å‘‚";s:2:"§g";s:3:"å›";s:2:"§h";s:3:"å©";s:2:"§i";s:3:"å‘Š";s:2:"§j";s:3:"å¹";s:2:"§k";s:3:"å»";s:2:"§l";s:3:"å¸";s:2:"§m";s:3:"å®";s:2:"§n";s:3:"åµ";s:2:"§o";s:3:"å¶";s:2:"§p";s:3:"å ";s:2:"§q";s:3:"å¼";s:2:"§r";s:3:"å‘€";s:2:"§s";s:3:"å±";s:2:"§t";s:3:"å«";s:2:"§u";s:3:"åŸ";s:2:"§v";s:3:"å¬";s:2:"§w";s:3:"囪";s:2:"§x";s:3:"å›°";s:2:"§y";s:3:"囤";s:2:"§z";s:3:"囫";s:2:"§{";s:3:"åŠ";s:2:"§|";s:3:"å‘";s:2:"§}";s:3:"å€";s:2:"§~";s:3:"å";s:2:"§¡";s:3:"å‡";s:2:"§¢";s:3:"åŽ";s:2:"§£";s:3:"圾";s:2:"§¤";s:3:"å";s:2:"§¥";s:3:"å";s:2:"§¦";s:3:"圻";s:2:"§§";s:3:"壯";s:2:"§¨";s:3:"夾";s:2:"§©";s:3:"å¦";s:2:"§ª";s:3:"妒";s:2:"§«";s:3:"妨";s:2:"§¬";s:3:"妞";s:2:"§­";s:3:"妣";s:2:"§®";s:3:"妙";s:2:"§¯";s:3:"妖";s:2:"§°";s:3:"å¦";s:2:"§±";s:3:"妤";s:2:"§²";s:3:"妓";s:2:"§³";s:3:"妊";s:2:"§´";s:3:"妥";s:2:"§µ";s:3:"å­";s:2:"§¶";s:3:"å­œ";s:2:"§·";s:3:"å­š";s:2:"§¸";s:3:"å­›";s:2:"§¹";s:3:"完";s:2:"§º";s:3:"宋";s:2:"§»";s:3:"å®";s:2:"§¼";s:3:"å°¬";s:2:"§½";s:3:"å±€";s:2:"§¾";s:3:"å±";s:2:"§¿";s:3:"å°¿";s:2:"§À";s:3:"å°¾";s:2:"§Á";s:3:"å²";s:2:"§Â";s:3:"岑";s:2:"§Ã";s:3:"å²”";s:2:"§Ä";s:3:"岌";s:2:"§Å";s:3:"å·«";s:2:"§Æ";s:3:"希";s:2:"§Ç";s:3:"åº";s:2:"§È";s:3:"庇";s:2:"§É";s:3:"床";s:2:"§Ê";s:3:"å»·";s:2:"§Ë";s:3:"弄";s:2:"§Ì";s:3:"弟";s:2:"§Í";s:3:"彤";s:2:"§Î";s:3:"å½¢";s:2:"§Ï";s:3:"å½·";s:2:"§Ð";s:3:"å½¹";s:2:"§Ñ";s:3:"忘";s:2:"§Ò";s:3:"å¿Œ";s:2:"§Ó";s:3:"å¿—";s:2:"§Ô";s:3:"å¿";s:2:"§Õ";s:3:"忱";s:2:"§Ö";s:3:"å¿«";s:2:"§×";s:3:"忸";s:2:"§Ø";s:3:"忪";s:2:"§Ù";s:3:"戒";s:2:"§Ú";s:3:"我";s:2:"§Û";s:3:"抄";s:2:"§Ü";s:3:"抗";s:2:"§Ý";s:3:"抖";s:2:"§Þ";s:3:"技";s:2:"§ß";s:3:"扶";s:2:"§à";s:3:"抉";s:2:"§á";s:3:"扭";s:2:"§â";s:3:"把";s:2:"§ã";s:3:"扼";s:2:"§ä";s:3:"找";s:2:"§å";s:3:"批";s:2:"§æ";s:3:"扳";s:2:"§ç";s:3:"抒";s:2:"§è";s:3:"扯";s:2:"§é";s:3:"折";s:2:"§ê";s:3:"扮";s:2:"§ë";s:3:"投";s:2:"§ì";s:3:"抓";s:2:"§í";s:3:"抑";s:2:"§î";s:3:"抆";s:2:"§ï";s:3:"改";s:2:"§ð";s:3:"æ”»";s:2:"§ñ";s:3:"攸";s:2:"§ò";s:3:"æ—±";s:2:"§ó";s:3:"æ›´";s:2:"§ô";s:3:"æŸ";s:2:"§õ";s:3:"æŽ";s:2:"§ö";s:3:"æ";s:2:"§÷";s:3:"æ";s:2:"§ø";s:3:"æ‘";s:2:"§ù";s:3:"æœ";s:2:"§ú";s:3:"æ–";s:2:"§û";s:3:"æž";s:2:"§ü";s:3:"æ‰";s:2:"§ý";s:3:"æ†";s:2:"§þ";s:3:"æ ";s:2:"¨@";s:3:"æ“";s:2:"¨A";s:3:"æ—";s:2:"¨B";s:3:"æ­¥";s:2:"¨C";s:3:"æ¯";s:2:"¨D";s:3:"求";s:2:"¨E";s:3:"汞";s:2:"¨F";s:3:"æ²™";s:2:"¨G";s:3:"æ²";s:2:"¨H";s:3:"沈";s:2:"¨I";s:3:"沉";s:2:"¨J";s:3:"æ²…";s:2:"¨K";s:3:"æ²›";s:2:"¨L";s:3:"汪";s:2:"¨M";s:3:"決";s:2:"¨N";s:3:"æ²";s:2:"¨O";s:3:"æ±°";s:2:"¨P";s:3:"沌";s:2:"¨Q";s:3:"汨";s:2:"¨R";s:3:"æ²–";s:2:"¨S";s:3:"æ²’";s:2:"¨T";s:3:"æ±½";s:2:"¨U";s:3:"沃";s:2:"¨V";s:3:"æ±²";s:2:"¨W";s:3:"æ±¾";s:2:"¨X";s:3:"æ±´";s:2:"¨Y";s:3:"沆";s:2:"¨Z";s:3:"汶";s:2:"¨[";s:3:"æ²";s:2:"¨\";s:3:"æ²”";s:2:"¨]";s:3:"沘";s:2:"¨^";s:3:"沂";s:2:"¨_";s:3:"ç¶";s:2:"¨`";s:3:"ç¼";s:2:"¨a";s:3:"ç½";s:2:"¨b";s:3:"ç¸";s:2:"¨c";s:3:"牢";s:2:"¨d";s:3:"牡";s:2:"¨e";s:3:"牠";s:2:"¨f";s:3:"ç‹„";s:2:"¨g";s:3:"ç‹‚";s:2:"¨h";s:3:"玖";s:2:"¨i";s:3:"甬";s:2:"¨j";s:3:"甫";s:2:"¨k";s:3:"ç”·";s:2:"¨l";s:3:"甸";s:2:"¨m";s:3:"çš‚";s:2:"¨n";s:3:"盯";s:2:"¨o";s:3:"矣";s:2:"¨p";s:3:"ç§";s:2:"¨q";s:3:"秀";s:2:"¨r";s:3:"禿";s:2:"¨s";s:3:"究";s:2:"¨t";s:3:"ç³»";s:2:"¨u";s:3:"罕";s:2:"¨v";s:3:"è‚–";s:2:"¨w";s:3:"è‚“";s:2:"¨x";s:3:"è‚";s:2:"¨y";s:3:"肘";s:2:"¨z";s:3:"è‚›";s:2:"¨{";s:3:"è‚š";s:2:"¨|";s:3:"育";s:2:"¨}";s:3:"良";s:2:"¨~";s:3:"芒";s:2:"¨¡";s:3:"芋";s:2:"¨¢";s:3:"èŠ";s:2:"¨£";s:3:"見";s:2:"¨¤";s:3:"角";s:2:"¨¥";s:3:"言";s:2:"¨¦";s:3:"è°·";s:2:"¨§";s:3:"豆";s:2:"¨¨";s:3:"豕";s:2:"¨©";s:3:"è²";s:2:"¨ª";s:3:"赤";s:2:"¨«";s:3:"èµ°";s:2:"¨¬";s:3:"足";s:2:"¨­";s:3:"身";s:2:"¨®";s:3:"車";s:2:"¨¯";s:3:"è¾›";s:2:"¨°";s:3:"è¾°";s:2:"¨±";s:3:"è¿‚";s:2:"¨²";s:3:"迆";s:2:"¨³";s:3:"è¿…";s:2:"¨´";s:3:"è¿„";s:2:"¨µ";s:3:"å·¡";s:2:"¨¶";s:3:"é‚‘";s:2:"¨·";s:3:"é‚¢";s:2:"¨¸";s:3:"邪";s:2:"¨¹";s:3:"邦";s:2:"¨º";s:3:"é‚£";s:2:"¨»";s:3:"é…‰";s:2:"¨¼";s:3:"釆";s:2:"¨½";s:3:"里";s:2:"¨¾";s:3:"防";s:2:"¨¿";s:3:"阮";s:2:"¨À";s:3:"阱";s:2:"¨Á";s:3:"阪";s:2:"¨Â";s:3:"阬";s:2:"¨Ã";s:3:"並";s:2:"¨Ä";s:3:"ä¹–";s:2:"¨Å";s:3:"ä¹³";s:2:"¨Æ";s:3:"事";s:2:"¨Ç";s:3:"些";s:2:"¨È";s:3:"亞";s:2:"¨É";s:3:"享";s:2:"¨Ê";s:3:"京";s:2:"¨Ë";s:3:"佯";s:2:"¨Ì";s:3:"ä¾";s:2:"¨Í";s:3:"ä¾";s:2:"¨Î";s:3:"ä½³";s:2:"¨Ï";s:3:"使";s:2:"¨Ð";s:3:"佬";s:2:"¨Ñ";s:3:"ä¾›";s:2:"¨Ò";s:3:"例";s:2:"¨Ó";s:3:"來";s:2:"¨Ô";s:3:"侃";s:2:"¨Õ";s:3:"ä½°";s:2:"¨Ö";s:3:"ä½µ";s:2:"¨×";s:3:"侈";s:2:"¨Ø";s:3:"佩";s:2:"¨Ù";s:3:"ä½»";s:2:"¨Ú";s:3:"ä¾–";s:2:"¨Û";s:3:"ä½¾";s:2:"¨Ü";s:3:"ä¾";s:2:"¨Ý";s:3:"侑";s:2:"¨Þ";s:3:"佺";s:2:"¨ß";s:3:"å…”";s:2:"¨à";s:3:"å…’";s:2:"¨á";s:3:"å…•";s:2:"¨â";s:3:"å…©";s:2:"¨ã";s:3:"å…·";s:2:"¨ä";s:3:"å…¶";s:2:"¨å";s:3:"å…¸";s:2:"¨æ";s:3:"冽";s:2:"¨ç";s:3:"函";s:2:"¨è";s:3:"刻";s:2:"¨é";s:3:"券";s:2:"¨ê";s:3:"刷";s:2:"¨ë";s:3:"刺";s:2:"¨ì";s:3:"到";s:2:"¨í";s:3:"刮";s:2:"¨î";s:3:"制";s:2:"¨ï";s:3:"å‰";s:2:"¨ð";s:3:"劾";s:2:"¨ñ";s:3:"劻";s:2:"¨ò";s:3:"å’";s:2:"¨ó";s:3:"å”";s:2:"¨ô";s:3:"å“";s:2:"¨õ";s:3:"å‘";s:2:"¨ö";s:3:"å¦";s:2:"¨÷";s:3:"å·";s:2:"¨ø";s:3:"å¸";s:2:"¨ù";s:3:"å¹";s:2:"¨ú";s:3:"å–";s:2:"¨û";s:3:"å”";s:2:"¨ü";s:3:"å—";s:2:"¨ý";s:3:"味";s:2:"¨þ";s:3:"呵";s:2:"©@";s:3:"å’–";s:2:"©A";s:3:"呸";s:2:"©B";s:3:"å’•";s:2:"©C";s:3:"å’€";s:2:"©D";s:3:"å‘»";s:2:"©E";s:3:"å‘·";s:2:"©F";s:3:"å’„";s:2:"©G";s:3:"å’’";s:2:"©H";s:3:"å’†";s:2:"©I";s:3:"呼";s:2:"©J";s:3:"å’";s:2:"©K";s:3:"呱";s:2:"©L";s:3:"呶";s:2:"©M";s:3:"å’Œ";s:2:"©N";s:3:"å’š";s:2:"©O";s:3:"å‘¢";s:2:"©P";s:3:"周";s:2:"©Q";s:3:"å’‹";s:2:"©R";s:3:"命";s:2:"©S";s:3:"å’Ž";s:2:"©T";s:3:"固";s:2:"©U";s:3:"垃";s:2:"©V";s:3:"å·";s:2:"©W";s:3:"åª";s:2:"©X";s:3:"å©";s:2:"©Y";s:3:"å¡";s:2:"©Z";s:3:"å¦";s:2:"©[";s:3:"å¤";s:2:"©\";s:3:"å¼";s:2:"©]";s:3:"夜";s:2:"©^";s:3:"奉";s:2:"©_";s:3:"奇";s:2:"©`";s:3:"奈";s:2:"©a";s:3:"奄";s:2:"©b";s:3:"奔";s:2:"©c";s:3:"妾";s:2:"©d";s:3:"妻";s:2:"©e";s:3:"委";s:2:"©f";s:3:"妹";s:2:"©g";s:3:"妮";s:2:"©h";s:3:"姑";s:2:"©i";s:3:"姆";s:2:"©j";s:3:"å§";s:2:"©k";s:3:"å§";s:2:"©l";s:3:"始";s:2:"©m";s:3:"姓";s:2:"©n";s:3:"姊";s:2:"©o";s:3:"妯";s:2:"©p";s:3:"妳";s:2:"©q";s:3:"姒";s:2:"©r";s:3:"姅";s:2:"©s";s:3:"å­Ÿ";s:2:"©t";s:3:"å­¤";s:2:"©u";s:3:"å­£";s:2:"©v";s:3:"å®—";s:2:"©w";s:3:"定";s:2:"©x";s:3:"官";s:2:"©y";s:3:"宜";s:2:"©z";s:3:"å®™";s:2:"©{";s:3:"å®›";s:2:"©|";s:3:"å°š";s:2:"©}";s:3:"屈";s:2:"©~";s:3:"å±…";s:2:"©¡";s:3:"屆";s:2:"©¢";s:3:"å²·";s:2:"©£";s:3:"岡";s:2:"©¤";s:3:"岸";s:2:"©¥";s:3:"岩";s:2:"©¦";s:3:"岫";s:2:"©§";s:3:"å²±";s:2:"©¨";s:3:"å²³";s:2:"©©";s:3:"帘";s:2:"©ª";s:3:"帚";s:2:"©«";s:3:"帖";s:2:"©¬";s:3:"帕";s:2:"©­";s:3:"帛";s:2:"©®";s:3:"帑";s:2:"©¯";s:3:"幸";s:2:"©°";s:3:"庚";s:2:"©±";s:3:"店";s:2:"©²";s:3:"府";s:2:"©³";s:3:"底";s:2:"©´";s:3:"庖";s:2:"©µ";s:3:"延";s:2:"©¶";s:3:"弦";s:2:"©·";s:3:"弧";s:2:"©¸";s:3:"弩";s:2:"©¹";s:3:"å¾€";s:2:"©º";s:3:"å¾";s:2:"©»";s:3:"彿";s:2:"©¼";s:3:"å½¼";s:2:"©½";s:3:"å¿";s:2:"©¾";s:3:"å¿ ";s:2:"©¿";s:3:"忽";s:2:"©À";s:3:"念";s:2:"©Á";s:3:"å¿¿";s:2:"©Â";s:3:"æ€";s:2:"©Ã";s:3:"怔";s:2:"©Ä";s:3:"怯";s:2:"©Å";s:3:"怵";s:2:"©Æ";s:3:"怖";s:2:"©Ç";s:3:"怪";s:2:"©È";s:3:"怕";s:2:"©É";s:3:"怡";s:2:"©Ê";s:3:"性";s:2:"©Ë";s:3:"怩";s:2:"©Ì";s:3:"怫";s:2:"©Í";s:3:"怛";s:2:"©Î";s:3:"或";s:2:"©Ï";s:3:"戕";s:2:"©Ð";s:3:"房";s:2:"©Ñ";s:3:"戾";s:2:"©Ò";s:3:"所";s:2:"©Ó";s:3:"承";s:2:"©Ô";s:3:"拉";s:2:"©Õ";s:3:"æ‹Œ";s:2:"©Ö";s:3:"æ‹„";s:2:"©×";s:3:"抿";s:2:"©Ø";s:3:"æ‹‚";s:2:"©Ù";s:3:"抹";s:2:"©Ú";s:3:"æ‹’";s:2:"©Û";s:3:"æ‹›";s:2:"©Ü";s:3:"披";s:2:"©Ý";s:3:"æ‹“";s:2:"©Þ";s:3:"æ‹”";s:2:"©ß";s:3:"æ‹‹";s:2:"©à";s:3:"拈";s:2:"©á";s:3:"抨";s:2:"©â";s:3:"抽";s:2:"©ã";s:3:"押";s:2:"©ä";s:3:"æ‹";s:2:"©å";s:3:"æ‹™";s:2:"©æ";s:3:"拇";s:2:"©ç";s:3:"æ‹";s:2:"©è";s:3:"抵";s:2:"©é";s:3:"æ‹š";s:2:"©ê";s:3:"抱";s:2:"©ë";s:3:"拘";s:2:"©ì";s:3:"æ‹–";s:2:"©í";s:3:"æ‹—";s:2:"©î";s:3:"拆";s:2:"©ï";s:3:"抬";s:2:"©ð";s:3:"æ‹Ž";s:2:"©ñ";s:3:"放";s:2:"©ò";s:3:"æ–§";s:2:"©ó";s:3:"æ–¼";s:2:"©ô";s:3:"æ—º";s:2:"©õ";s:3:"昔";s:2:"©ö";s:3:"易";s:2:"©÷";s:3:"昌";s:2:"©ø";s:3:"昆";s:2:"©ù";s:3:"昂";s:2:"©ú";s:3:"明";s:2:"©û";s:3:"昀";s:2:"©ü";s:3:"æ˜";s:2:"©ý";s:3:"昕";s:2:"©þ";s:3:"昊";s:2:"ª@";s:3:"昇";s:2:"ªA";s:3:"æœ";s:2:"ªB";s:3:"朋";s:2:"ªC";s:3:"æ­";s:2:"ªD";s:3:"æž‹";s:2:"ªE";s:3:"æž•";s:2:"ªF";s:3:"æ±";s:2:"ªG";s:3:"æžœ";s:2:"ªH";s:3:"æ³";s:2:"ªI";s:3:"æ·";s:2:"ªJ";s:3:"枇";s:2:"ªK";s:3:"æž";s:2:"ªL";s:3:"æž—";s:2:"ªM";s:3:"æ¯";s:2:"ªN";s:3:"æ°";s:2:"ªO";s:3:"æ¿";s:2:"ªP";s:3:"枉";s:2:"ªQ";s:3:"æ¾";s:2:"ªR";s:3:"æž";s:2:"ªS";s:3:"æµ";s:2:"ªT";s:3:"æžš";s:2:"ªU";s:3:"æž“";s:2:"ªV";s:3:"æ¼";s:2:"ªW";s:3:"æª";s:2:"ªX";s:3:"æ²";s:2:"ªY";s:3:"欣";s:2:"ªZ";s:3:"æ­¦";s:2:"ª[";s:3:"æ­§";s:2:"ª\";s:3:"æ­¿";s:2:"ª]";s:3:"æ°“";s:2:"ª^";s:3:"æ°›";s:2:"ª_";s:3:"æ³£";s:2:"ª`";s:3:"注";s:2:"ªa";s:3:"æ³³";s:2:"ªb";s:3:"æ²±";s:2:"ªc";s:3:"泌";s:2:"ªd";s:3:"æ³¥";s:2:"ªe";s:3:"æ²³";s:2:"ªf";s:3:"æ²½";s:2:"ªg";s:3:"æ²¾";s:2:"ªh";s:3:"æ²¼";s:2:"ªi";s:3:"æ³¢";s:2:"ªj";s:3:"沫";s:2:"ªk";s:3:"法";s:2:"ªl";s:3:"泓";s:2:"ªm";s:3:"沸";s:2:"ªn";s:3:"泄";s:2:"ªo";s:3:"æ²¹";s:2:"ªp";s:3:"æ³";s:2:"ªq";s:3:"æ²®";s:2:"ªr";s:3:"æ³—";s:2:"ªs";s:3:"æ³…";s:2:"ªt";s:3:"æ³±";s:2:"ªu";s:3:"沿";s:2:"ªv";s:3:"æ²»";s:2:"ªw";s:3:"泡";s:2:"ªx";s:3:"æ³›";s:2:"ªy";s:3:"泊";s:2:"ªz";s:3:"沬";s:2:"ª{";s:3:"泯";s:2:"ª|";s:3:"泜";s:2:"ª}";s:3:"æ³–";s:2:"ª~";s:3:"æ³ ";s:2:"ª¡";s:3:"ç‚•";s:2:"ª¢";s:3:"ç‚Ž";s:2:"ª£";s:3:"ç‚’";s:2:"ª¤";s:3:"ç‚Š";s:2:"ª¥";s:3:"ç‚™";s:2:"ª¦";s:3:"爬";s:2:"ª§";s:3:"爭";s:2:"ª¨";s:3:"爸";s:2:"ª©";s:3:"版";s:2:"ªª";s:3:"牧";s:2:"ª«";s:3:"物";s:2:"ª¬";s:3:"ç‹€";s:2:"ª­";s:3:"ç‹Ž";s:2:"ª®";s:3:"ç‹™";s:2:"ª¯";s:3:"ç‹—";s:2:"ª°";s:3:"ç‹";s:2:"ª±";s:3:"玩";s:2:"ª²";s:3:"玨";s:2:"ª³";s:3:"玟";s:2:"ª´";s:3:"玫";s:2:"ªµ";s:3:"玥";s:2:"ª¶";s:3:"甽";s:2:"ª·";s:3:"ç–";s:2:"ª¸";s:3:"ç–™";s:2:"ª¹";s:3:"ç–š";s:2:"ªº";s:3:"çš„";s:2:"ª»";s:3:"盂";s:2:"ª¼";s:3:"盲";s:2:"ª½";s:3:"ç›´";s:2:"ª¾";s:3:"知";s:2:"ª¿";s:3:"矽";s:2:"ªÀ";s:3:"社";s:2:"ªÁ";s:3:"祀";s:2:"ªÂ";s:3:"ç¥";s:2:"ªÃ";s:3:"秉";s:2:"ªÄ";s:3:"秈";s:2:"ªÅ";s:3:"空";s:2:"ªÆ";s:3:"穹";s:2:"ªÇ";s:3:"竺";s:2:"ªÈ";s:3:"ç³¾";s:2:"ªÉ";s:3:"ç½”";s:2:"ªÊ";s:3:"羌";s:2:"ªË";s:3:"羋";s:2:"ªÌ";s:3:"者";s:2:"ªÍ";s:3:"肺";s:2:"ªÎ";s:3:"è‚¥";s:2:"ªÏ";s:3:"è‚¢";s:2:"ªÐ";s:3:"肱";s:2:"ªÑ";s:3:"è‚¡";s:2:"ªÒ";s:3:"è‚«";s:2:"ªÓ";s:3:"è‚©";s:2:"ªÔ";s:3:"è‚´";s:2:"ªÕ";s:3:"肪";s:2:"ªÖ";s:3:"肯";s:2:"ª×";s:3:"臥";s:2:"ªØ";s:3:"臾";s:2:"ªÙ";s:3:"èˆ";s:2:"ªÚ";s:3:"芳";s:2:"ªÛ";s:3:"èŠ";s:2:"ªÜ";s:3:"芙";s:2:"ªÝ";s:3:"芭";s:2:"ªÞ";s:3:"芽";s:2:"ªß";s:3:"芟";s:2:"ªà";s:3:"芹";s:2:"ªá";s:3:"花";s:2:"ªâ";s:3:"芬";s:2:"ªã";s:3:"芥";s:2:"ªä";s:3:"芯";s:2:"ªå";s:3:"芸";s:2:"ªæ";s:3:"芣";s:2:"ªç";s:3:"芰";s:2:"ªè";s:3:"芾";s:2:"ªé";s:3:"芷";s:2:"ªê";s:3:"虎";s:2:"ªë";s:3:"è™±";s:2:"ªì";s:3:"åˆ";s:2:"ªí";s:3:"表";s:2:"ªî";s:3:"軋";s:2:"ªï";s:3:"è¿Ž";s:2:"ªð";s:3:"è¿”";s:2:"ªñ";s:3:"è¿‘";s:2:"ªò";s:3:"邵";s:2:"ªó";s:3:"邸";s:2:"ªô";s:3:"邱";s:2:"ªõ";s:3:"邶";s:2:"ªö";s:3:"采";s:2:"ª÷";s:3:"金";s:2:"ªø";s:3:"é•·";s:2:"ªù";s:3:"é–€";s:2:"ªú";s:3:"阜";s:2:"ªû";s:3:"陀";s:2:"ªü";s:3:"阿";s:2:"ªý";s:3:"阻";s:2:"ªþ";s:3:"附";s:2:"«@";s:3:"陂";s:2:"«A";s:3:"éš¹";s:2:"«B";s:3:"雨";s:2:"«C";s:3:"é’";s:2:"«D";s:3:"éž";s:2:"«E";s:3:"亟";s:2:"«F";s:3:"亭";s:2:"«G";s:3:"亮";s:2:"«H";s:3:"ä¿¡";s:2:"«I";s:3:"ä¾µ";s:2:"«J";s:3:"侯";s:2:"«K";s:3:"便";s:2:"«L";s:3:"ä¿ ";s:2:"«M";s:3:"ä¿‘";s:2:"«N";s:3:"ä¿";s:2:"«O";s:3:"ä¿";s:2:"«P";s:3:"促";s:2:"«Q";s:3:"侶";s:2:"«R";s:3:"俘";s:2:"«S";s:3:"ä¿Ÿ";s:2:"«T";s:3:"ä¿Š";s:2:"«U";s:3:"ä¿—";s:2:"«V";s:3:"ä¾®";s:2:"«W";s:3:"ä¿";s:2:"«X";s:3:"ä¿„";s:2:"«Y";s:3:"ä¿‚";s:2:"«Z";s:3:"ä¿š";s:2:"«[";s:3:"ä¿Ž";s:2:"«\";s:3:"ä¿ž";s:2:"«]";s:3:"ä¾·";s:2:"«^";s:3:"å…—";s:2:"«_";s:3:"冒";s:2:"«`";s:3:"冑";s:2:"«a";s:3:"冠";s:2:"«b";s:3:"剎";s:2:"«c";s:3:"剃";s:2:"«d";s:3:"削";s:2:"«e";s:3:"å‰";s:2:"«f";s:3:"剌";s:2:"«g";s:3:"剋";s:2:"«h";s:3:"則";s:2:"«i";s:3:"勇";s:2:"«j";s:3:"勉";s:2:"«k";s:3:"勃";s:2:"«l";s:3:"å‹";s:2:"«m";s:3:"åŒ";s:2:"«n";s:3:"å—";s:2:"«o";s:3:"å»";s:2:"«p";s:3:"厚";s:2:"«q";s:3:"å›";s:2:"«r";s:3:"å’¬";s:2:"«s";s:3:"å“€";s:2:"«t";s:3:"å’¨";s:2:"«u";s:3:"å“Ž";s:2:"«v";s:3:"哉";s:2:"«w";s:3:"å’¸";s:2:"«x";s:3:"å’¦";s:2:"«y";s:3:"å’³";s:2:"«z";s:3:"哇";s:2:"«{";s:3:"å“‚";s:2:"«|";s:3:"å’½";s:2:"«}";s:3:"å’ª";s:2:"«~";s:3:"å“";s:2:"«¡";s:3:"å“„";s:2:"«¢";s:3:"哈";s:2:"«£";s:3:"å’¯";s:2:"«¤";s:3:"å’«";s:2:"«¥";s:3:"å’±";s:2:"«¦";s:3:"å’»";s:2:"«§";s:3:"å’©";s:2:"«¨";s:3:"å’§";s:2:"«©";s:3:"å’¿";s:2:"«ª";s:3:"囿";s:2:"««";s:3:"åž‚";s:2:"«¬";s:3:"åž‹";s:2:"«­";s:3:"åž ";s:2:"«®";s:3:"垣";s:2:"«¯";s:3:"垢";s:2:"«°";s:3:"城";s:2:"«±";s:3:"åž®";s:2:"«²";s:3:"åž“";s:2:"«³";s:3:"奕";s:2:"«´";s:3:"契";s:2:"«µ";s:3:"å¥";s:2:"«¶";s:3:"奎";s:2:"«·";s:3:"å¥";s:2:"«¸";s:3:"姜";s:2:"«¹";s:3:"姘";s:2:"«º";s:3:"姿";s:2:"«»";s:3:"姣";s:2:"«¼";s:3:"姨";s:2:"«½";s:3:"娃";s:2:"«¾";s:3:"姥";s:2:"«¿";s:3:"姪";s:2:"«À";s:3:"姚";s:2:"«Á";s:3:"姦";s:2:"«Â";s:3:"å¨";s:2:"«Ã";s:3:"姻";s:2:"«Ä";s:3:"å­©";s:2:"«Å";s:3:"宣";s:2:"«Æ";s:3:"宦";s:2:"«Ç";s:3:"室";s:2:"«È";s:3:"客";s:2:"«É";s:3:"宥";s:2:"«Ê";s:3:"å°";s:2:"«Ë";s:3:"屎";s:2:"«Ì";s:3:"å±";s:2:"«Í";s:3:"å±";s:2:"«Î";s:3:"屋";s:2:"«Ï";s:3:"å³™";s:2:"«Ð";s:3:"å³’";s:2:"«Ñ";s:3:"å··";s:2:"«Ò";s:3:"å¸";s:2:"«Ó";s:3:"帥";s:2:"«Ô";s:3:"帟";s:2:"«Õ";s:3:"å¹½";s:2:"«Ö";s:3:"庠";s:2:"«×";s:3:"度";s:2:"«Ø";s:3:"建";s:2:"«Ù";s:3:"弈";s:2:"«Ú";s:3:"å¼­";s:2:"«Û";s:3:"å½¥";s:2:"«Ü";s:3:"很";s:2:"«Ý";s:3:"å¾…";s:2:"«Þ";s:3:"徊";s:2:"«ß";s:3:"律";s:2:"«à";s:3:"徇";s:2:"«á";s:3:"後";s:2:"«â";s:3:"徉";s:2:"«ã";s:3:"怒";s:2:"«ä";s:3:"æ€";s:2:"«å";s:3:"怠";s:2:"«æ";s:3:"急";s:2:"«ç";s:3:"怎";s:2:"«è";s:3:"怨";s:2:"«é";s:3:"æ";s:2:"«ê";s:3:"æ°";s:2:"«ë";s:3:"æ¨";s:2:"«ì";s:3:"æ¢";s:2:"«í";s:3:"æ†";s:2:"«î";s:3:"æƒ";s:2:"«ï";s:3:"æ¬";s:2:"«ð";s:3:"æ«";s:2:"«ñ";s:3:"æª";s:2:"«ò";s:3:"æ¤";s:2:"«ó";s:3:"æ‰";s:2:"«ô";s:3:"æ‹œ";s:2:"«õ";s:3:"挖";s:2:"«ö";s:3:"按";s:2:"«÷";s:3:"拼";s:2:"«ø";s:3:"æ‹­";s:2:"«ù";s:3:"æŒ";s:2:"«ú";s:3:"æ‹®";s:2:"«û";s:3:"拽";s:2:"«ü";s:3:"指";s:2:"«ý";s:3:"拱";s:2:"«þ";s:3:"æ‹·";s:2:"¬@";s:3:"拯";s:2:"¬A";s:3:"括";s:2:"¬B";s:3:"拾";s:2:"¬C";s:3:"æ‹´";s:2:"¬D";s:3:"挑";s:2:"¬E";s:3:"挂";s:2:"¬F";s:3:"政";s:2:"¬G";s:3:"æ•…";s:2:"¬H";s:3:"æ–«";s:2:"¬I";s:3:"æ–½";s:2:"¬J";s:3:"æ—¢";s:2:"¬K";s:3:"春";s:2:"¬L";s:3:"昭";s:2:"¬M";s:3:"映";s:2:"¬N";s:3:"昧";s:2:"¬O";s:3:"是";s:2:"¬P";s:3:"星";s:2:"¬Q";s:3:"昨";s:2:"¬R";s:3:"昱";s:2:"¬S";s:3:"昤";s:2:"¬T";s:3:"æ›·";s:2:"¬U";s:3:"柿";s:2:"¬V";s:3:"染";s:2:"¬W";s:3:"柱";s:2:"¬X";s:3:"柔";s:2:"¬Y";s:3:"æŸ";s:2:"¬Z";s:3:"柬";s:2:"¬[";s:3:"架";s:2:"¬\";s:3:"枯";s:2:"¬]";s:3:"柵";s:2:"¬^";s:3:"柩";s:2:"¬_";s:3:"柯";s:2:"¬`";s:3:"柄";s:2:"¬a";s:3:"柑";s:2:"¬b";s:3:"æž´";s:2:"¬c";s:3:"柚";s:2:"¬d";s:3:"查";s:2:"¬e";s:3:"枸";s:2:"¬f";s:3:"æŸ";s:2:"¬g";s:3:"柞";s:2:"¬h";s:3:"柳";s:2:"¬i";s:3:"æž°";s:2:"¬j";s:3:"柙";s:2:"¬k";s:3:"柢";s:2:"¬l";s:3:"æŸ";s:2:"¬m";s:3:"柒";s:2:"¬n";s:3:"æ­ª";s:2:"¬o";s:3:"殃";s:2:"¬p";s:3:"殆";s:2:"¬q";s:3:"段";s:2:"¬r";s:3:"毒";s:2:"¬s";s:3:"毗";s:2:"¬t";s:3:"æ°Ÿ";s:2:"¬u";s:3:"泉";s:2:"¬v";s:3:"æ´‹";s:2:"¬w";s:3:"æ´²";s:2:"¬x";s:3:"æ´ª";s:2:"¬y";s:3:"æµ";s:2:"¬z";s:3:"æ´¥";s:2:"¬{";s:3:"æ´Œ";s:2:"¬|";s:3:"æ´±";s:2:"¬}";s:3:"æ´ž";s:2:"¬~";s:3:"æ´—";s:2:"¬¡";s:3:"æ´»";s:2:"¬¢";s:3:"æ´½";s:2:"¬£";s:3:"æ´¾";s:2:"¬¤";s:3:"æ´¶";s:2:"¬¥";s:3:"æ´›";s:2:"¬¦";s:3:"æ³µ";s:2:"¬§";s:3:"æ´¹";s:2:"¬¨";s:3:"æ´§";s:2:"¬©";s:3:"æ´¸";s:2:"¬ª";s:3:"æ´©";s:2:"¬«";s:3:"æ´®";s:2:"¬¬";s:3:"æ´µ";s:2:"¬­";s:3:"æ´Ž";s:2:"¬®";s:3:"æ´«";s:2:"¬¯";s:3:"ç‚«";s:2:"¬°";s:3:"為";s:2:"¬±";s:3:"炳";s:2:"¬²";s:3:"炬";s:2:"¬³";s:3:"炯";s:2:"¬´";s:3:"ç‚­";s:2:"¬µ";s:3:"炸";s:2:"¬¶";s:3:"ç‚®";s:2:"¬·";s:3:"炤";s:2:"¬¸";s:3:"爰";s:2:"¬¹";s:3:"牲";s:2:"¬º";s:3:"牯";s:2:"¬»";s:3:"牴";s:2:"¬¼";s:3:"ç‹©";s:2:"¬½";s:3:"ç‹ ";s:2:"¬¾";s:3:"ç‹¡";s:2:"¬¿";s:3:"玷";s:2:"¬À";s:3:"çŠ";s:2:"¬Á";s:3:"玻";s:2:"¬Â";s:3:"玲";s:2:"¬Ã";s:3:"ç";s:2:"¬Ä";s:3:"ç€";s:2:"¬Å";s:3:"玳";s:2:"¬Æ";s:3:"甚";s:2:"¬Ç";s:3:"ç”­";s:2:"¬È";s:3:"ç•";s:2:"¬É";s:3:"ç•Œ";s:2:"¬Ê";s:3:"ç•Ž";s:2:"¬Ë";s:3:"ç•‹";s:2:"¬Ì";s:3:"ç–«";s:2:"¬Í";s:3:"ç–¤";s:2:"¬Î";s:3:"ç–¥";s:2:"¬Ï";s:3:"ç–¢";s:2:"¬Ð";s:3:"ç–£";s:2:"¬Ñ";s:3:"癸";s:2:"¬Ò";s:3:"皆";s:2:"¬Ó";s:3:"皇";s:2:"¬Ô";s:3:"皈";s:2:"¬Õ";s:3:"盈";s:2:"¬Ö";s:3:"盆";s:2:"¬×";s:3:"盃";s:2:"¬Ø";s:3:"ç›…";s:2:"¬Ù";s:3:"çœ";s:2:"¬Ú";s:3:"盹";s:2:"¬Û";s:3:"相";s:2:"¬Ü";s:3:"眉";s:2:"¬Ý";s:3:"看";s:2:"¬Þ";s:3:"盾";s:2:"¬ß";s:3:"盼";s:2:"¬à";s:3:"眇";s:2:"¬á";s:3:"矜";s:2:"¬â";s:3:"ç ‚";s:2:"¬ã";s:3:"ç ”";s:2:"¬ä";s:3:"ç Œ";s:2:"¬å";s:3:"ç ";s:2:"¬æ";s:3:"祆";s:2:"¬ç";s:3:"祉";s:2:"¬è";s:3:"祈";s:2:"¬é";s:3:"祇";s:2:"¬ê";s:3:"禹";s:2:"¬ë";s:3:"禺";s:2:"¬ì";s:3:"科";s:2:"¬í";s:3:"秒";s:2:"¬î";s:3:"秋";s:2:"¬ï";s:3:"ç©¿";s:2:"¬ð";s:3:"çª";s:2:"¬ñ";s:3:"ç«¿";s:2:"¬ò";s:3:"竽";s:2:"¬ó";s:3:"ç±½";s:2:"¬ô";s:3:"ç´‚";s:2:"¬õ";s:3:"ç´…";s:2:"¬ö";s:3:"ç´€";s:2:"¬÷";s:3:"ç´‰";s:2:"¬ø";s:3:"ç´‡";s:2:"¬ù";s:3:"ç´„";s:2:"¬ú";s:3:"ç´†";s:2:"¬û";s:3:"缸";s:2:"¬ü";s:3:"美";s:2:"¬ý";s:3:"羿";s:2:"¬þ";s:3:"耄";s:2:"­@";s:3:"è€";s:2:"­A";s:3:"è€";s:2:"­B";s:3:"耑";s:2:"­C";s:3:"耶";s:2:"­D";s:3:"胖";s:2:"­E";s:3:"胥";s:2:"­F";s:3:"胚";s:2:"­G";s:3:"胃";s:2:"­H";s:3:"胄";s:2:"­I";s:3:"背";s:2:"­J";s:3:"胡";s:2:"­K";s:3:"胛";s:2:"­L";s:3:"胎";s:2:"­M";s:3:"胞";s:2:"­N";s:3:"胤";s:2:"­O";s:3:"èƒ";s:2:"­P";s:3:"致";s:2:"­Q";s:3:"舢";s:2:"­R";s:3:"苧";s:2:"­S";s:3:"范";s:2:"­T";s:3:"茅";s:2:"­U";s:3:"è‹£";s:2:"­V";s:3:"è‹›";s:2:"­W";s:3:"苦";s:2:"­X";s:3:"茄";s:2:"­Y";s:3:"è‹¥";s:2:"­Z";s:3:"茂";s:2:"­[";s:3:"茉";s:2:"­\";s:3:"è‹’";s:2:"­]";s:3:"è‹—";s:2:"­^";s:3:"英";s:2:"­_";s:3:"èŒ";s:2:"­`";s:3:"è‹œ";s:2:"­a";s:3:"è‹”";s:2:"­b";s:3:"è‹‘";s:2:"­c";s:3:"è‹ž";s:2:"­d";s:3:"è‹“";s:2:"­e";s:3:"è‹Ÿ";s:2:"­f";s:3:"苯";s:2:"­g";s:3:"茆";s:2:"­h";s:3:"è™";s:2:"­i";s:3:"虹";s:2:"­j";s:3:"è™»";s:2:"­k";s:3:"虺";s:2:"­l";s:3:"è¡";s:2:"­m";s:3:"è¡«";s:2:"­n";s:3:"è¦";s:2:"­o";s:3:"觔";s:2:"­p";s:3:"計";s:2:"­q";s:3:"訂";s:2:"­r";s:3:"訃";s:2:"­s";s:3:"貞";s:2:"­t";s:3:"è² ";s:2:"­u";s:3:"èµ´";s:2:"­v";s:3:"èµ³";s:2:"­w";s:3:"趴";s:2:"­x";s:3:"è»";s:2:"­y";s:3:"軌";s:2:"­z";s:3:"è¿°";s:2:"­{";s:3:"迦";s:2:"­|";s:3:"è¿¢";s:2:"­}";s:3:"迪";s:2:"­~";s:3:"è¿¥";s:2:"­¡";s:3:"è¿­";s:2:"­¢";s:3:"è¿«";s:2:"­£";s:3:"迤";s:2:"­¤";s:3:"迨";s:2:"­¥";s:3:"郊";s:2:"­¦";s:3:"郎";s:2:"­§";s:3:"éƒ";s:2:"­¨";s:3:"郃";s:2:"­©";s:3:"é…‹";s:2:"­ª";s:3:"é…Š";s:2:"­«";s:3:"é‡";s:2:"­¬";s:3:"é–‚";s:2:"­­";s:3:"é™";s:2:"­®";s:3:"陋";s:2:"­¯";s:3:"陌";s:2:"­°";s:3:"é™";s:2:"­±";s:3:"é¢";s:2:"­²";s:3:"é©";s:2:"­³";s:3:"韋";s:2:"­´";s:3:"韭";s:2:"­µ";s:3:"音";s:2:"­¶";s:3:"é ";s:2:"­·";s:3:"風";s:2:"­¸";s:3:"飛";s:2:"­¹";s:3:"食";s:2:"­º";s:3:"首";s:2:"­»";s:3:"香";s:2:"­¼";s:3:"乘";s:2:"­½";s:3:"亳";s:2:"­¾";s:3:"倌";s:2:"­¿";s:3:"å€";s:2:"­À";s:3:"倣";s:2:"­Á";s:3:"俯";s:2:"­Â";s:3:"倦";s:2:"­Ã";s:3:"倥";s:2:"­Ä";s:3:"俸";s:2:"­Å";s:3:"倩";s:2:"­Æ";s:3:"倖";s:2:"­Ç";s:3:"倆";s:2:"­È";s:3:"值";s:2:"­É";s:3:"借";s:2:"­Ê";s:3:"倚";s:2:"­Ë";s:3:"倒";s:2:"­Ì";s:3:"們";s:2:"­Í";s:3:"俺";s:2:"­Î";s:3:"倀";s:2:"­Ï";s:3:"倔";s:2:"­Ð";s:3:"倨";s:2:"­Ñ";s:3:"俱";s:2:"­Ò";s:3:"倡";s:2:"­Ó";s:3:"個";s:2:"­Ô";s:3:"候";s:2:"­Õ";s:3:"倘";s:2:"­Ö";s:3:"俳";s:2:"­×";s:3:"ä¿®";s:2:"­Ø";s:3:"倭";s:2:"­Ù";s:3:"倪";s:2:"­Ú";s:3:"俾";s:2:"­Û";s:3:"倫";s:2:"­Ü";s:3:"倉";s:2:"­Ý";s:3:"å…¼";s:2:"­Þ";s:3:"冤";s:2:"­ß";s:3:"冥";s:2:"­à";s:3:"冢";s:2:"­á";s:3:"å‡";s:2:"­â";s:3:"凌";s:2:"­ã";s:3:"准";s:2:"­ä";s:3:"凋";s:2:"­å";s:3:"剖";s:2:"­æ";s:3:"剜";s:2:"­ç";s:3:"剔";s:2:"­è";s:3:"剛";s:2:"­é";s:3:"å‰";s:2:"­ê";s:3:"匪";s:2:"­ë";s:3:"å¿";s:2:"­ì";s:3:"原";s:2:"­í";s:3:"åŽ";s:2:"­î";s:3:"åŸ";s:2:"­ï";s:3:"哨";s:2:"­ð";s:3:"å”";s:2:"­ñ";s:3:"å”";s:2:"­ò";s:3:"å”·";s:2:"­ó";s:3:"哼";s:2:"­ô";s:3:"å“¥";s:2:"­õ";s:3:"哲";s:2:"­ö";s:3:"唆";s:2:"­÷";s:3:"哺";s:2:"­ø";s:3:"å””";s:2:"­ù";s:3:"å“©";s:2:"­ú";s:3:"å“­";s:2:"­û";s:3:"å“¡";s:2:"­ü";s:3:"唉";s:2:"­ý";s:3:"å“®";s:2:"­þ";s:3:"哪";s:2:"®@";s:3:"哦";s:2:"®A";s:3:"唧";s:2:"®B";s:3:"唇";s:2:"®C";s:3:"哽";s:2:"®D";s:3:"å”";s:2:"®E";s:3:"圃";s:2:"®F";s:3:"圄";s:2:"®G";s:3:"埂";s:2:"®H";s:3:"埔";s:2:"®I";s:3:"埋";s:2:"®J";s:3:"埃";s:2:"®K";s:3:"å ‰";s:2:"®L";s:3:"å¤";s:2:"®M";s:3:"套";s:2:"®N";s:3:"奘";s:2:"®O";s:3:"奚";s:2:"®P";s:3:"娑";s:2:"®Q";s:3:"娘";s:2:"®R";s:3:"娜";s:2:"®S";s:3:"娟";s:2:"®T";s:3:"娛";s:2:"®U";s:3:"娓";s:2:"®V";s:3:"姬";s:2:"®W";s:3:"娠";s:2:"®X";s:3:"娣";s:2:"®Y";s:3:"娩";s:2:"®Z";s:3:"娥";s:2:"®[";s:3:"娌";s:2:"®\";s:3:"娉";s:2:"®]";s:3:"å­«";s:2:"®^";s:3:"屘";s:2:"®_";s:3:"å®°";s:2:"®`";s:3:"害";s:2:"®a";s:3:"家";s:2:"®b";s:3:"å®´";s:2:"®c";s:3:"å®®";s:2:"®d";s:3:"宵";s:2:"®e";s:3:"容";s:2:"®f";s:3:"宸";s:2:"®g";s:3:"å°„";s:2:"®h";s:3:"屑";s:2:"®i";s:3:"展";s:2:"®j";s:3:"å±";s:2:"®k";s:3:"å³­";s:2:"®l";s:3:"å³½";s:2:"®m";s:3:"å³»";s:2:"®n";s:3:"峪";s:2:"®o";s:3:"峨";s:2:"®p";s:3:"å³°";s:2:"®q";s:3:"島";s:2:"®r";s:3:"å´";s:2:"®s";s:3:"å³´";s:2:"®t";s:3:"å·®";s:2:"®u";s:3:"席";s:2:"®v";s:3:"師";s:2:"®w";s:3:"庫";s:2:"®x";s:3:"庭";s:2:"®y";s:3:"座";s:2:"®z";s:3:"å¼±";s:2:"®{";s:3:"å¾’";s:2:"®|";s:3:"徑";s:2:"®}";s:3:"å¾";s:2:"®~";s:3:"æ™";s:2:"®¡";s:3:"æ£";s:2:"®¢";s:3:"æ¥";s:2:"®£";s:3:"æ";s:2:"®¤";s:3:"æ•";s:2:"®¥";s:3:"æ­";s:2:"®¦";s:3:"æ©";s:2:"®§";s:3:"æ¯";s:2:"®¨";s:3:"æ‚„";s:2:"®©";s:3:"æ‚Ÿ";s:2:"®ª";s:3:"æ‚š";s:2:"®«";s:3:"æ‚";s:2:"®¬";s:3:"æ‚”";s:2:"®­";s:3:"æ‚Œ";s:2:"®®";s:3:"æ‚…";s:2:"®¯";s:3:"æ‚–";s:2:"®°";s:3:"扇";s:2:"®±";s:3:"拳";s:2:"®²";s:3:"挈";s:2:"®³";s:3:"æ‹¿";s:2:"®´";s:3:"æŽ";s:2:"®µ";s:3:"挾";s:2:"®¶";s:3:"振";s:2:"®·";s:3:"æ•";s:2:"®¸";s:3:"æ‚";s:2:"®¹";s:3:"æ†";s:2:"®º";s:3:"æ";s:2:"®»";s:3:"æ‰";s:2:"®¼";s:3:"挺";s:2:"®½";s:3:"æ";s:2:"®¾";s:3:"挽";s:2:"®¿";s:3:"挪";s:2:"®À";s:3:"挫";s:2:"®Á";s:3:"挨";s:2:"®Â";s:3:"æ";s:2:"®Ã";s:3:"æŒ";s:2:"®Ä";s:3:"效";s:2:"®Å";s:3:"敉";s:2:"®Æ";s:3:"æ–™";s:2:"®Ç";s:3:"æ—";s:2:"®È";s:3:"æ—…";s:2:"®É";s:3:"時";s:2:"®Ê";s:3:"晉";s:2:"®Ë";s:3:"æ™";s:2:"®Ì";s:3:"晃";s:2:"®Í";s:3:"æ™’";s:2:"®Î";s:3:"晌";s:2:"®Ï";s:3:"æ™…";s:2:"®Ð";s:3:"æ™";s:2:"®Ñ";s:3:"書";s:2:"®Ò";s:3:"朔";s:2:"®Ó";s:3:"朕";s:2:"®Ô";s:3:"朗";s:2:"®Õ";s:3:"æ ¡";s:2:"®Ö";s:3:"æ ¸";s:2:"®×";s:3:"案";s:2:"®Ø";s:3:"框";s:2:"®Ù";s:3:"æ¡“";s:2:"®Ú";s:3:"æ ¹";s:2:"®Û";s:3:"æ¡‚";s:2:"®Ü";s:3:"æ¡”";s:2:"®Ý";s:3:"æ ©";s:2:"®Þ";s:3:"梳";s:2:"®ß";s:3:"æ —";s:2:"®à";s:3:"æ¡Œ";s:2:"®á";s:3:"æ¡‘";s:2:"®â";s:3:"æ ½";s:2:"®ã";s:3:"柴";s:2:"®ä";s:3:"æ¡";s:2:"®å";s:3:"æ¡€";s:2:"®æ";s:3:"æ ¼";s:2:"®ç";s:3:"桃";s:2:"®è";s:3:"æ ª";s:2:"®é";s:3:"æ¡…";s:2:"®ê";s:3:"æ “";s:2:"®ë";s:3:"æ ˜";s:2:"®ì";s:3:"æ¡";s:2:"®í";s:3:"殊";s:2:"®î";s:3:"殉";s:2:"®ï";s:3:"æ®·";s:2:"®ð";s:3:"æ°£";s:2:"®ñ";s:3:"æ°§";s:2:"®ò";s:3:"æ°¨";s:2:"®ó";s:3:"æ°¦";s:2:"®ô";s:3:"æ°¤";s:2:"®õ";s:3:"æ³°";s:2:"®ö";s:3:"浪";s:2:"®÷";s:3:"涕";s:2:"®ø";s:3:"消";s:2:"®ù";s:3:"涇";s:2:"®ú";s:3:"浦";s:2:"®û";s:3:"浸";s:2:"®ü";s:3:"æµ·";s:2:"®ý";s:3:"æµ™";s:2:"®þ";s:3:"涓";s:2:"¯@";s:3:"浬";s:2:"¯A";s:3:"涉";s:2:"¯B";s:3:"æµ®";s:2:"¯C";s:3:"浚";s:2:"¯D";s:3:"æµ´";s:2:"¯E";s:3:"浩";s:2:"¯F";s:3:"涌";s:2:"¯G";s:3:"涊";s:2:"¯H";s:3:"æµ¹";s:2:"¯I";s:3:"涅";s:2:"¯J";s:3:"æµ¥";s:2:"¯K";s:3:"涔";s:2:"¯L";s:3:"烊";s:2:"¯M";s:3:"烘";s:2:"¯N";s:3:"烤";s:2:"¯O";s:3:"烙";s:2:"¯P";s:3:"烈";s:2:"¯Q";s:3:"çƒ";s:2:"¯R";s:3:"爹";s:2:"¯S";s:3:"特";s:2:"¯T";s:3:"狼";s:2:"¯U";s:3:"狹";s:2:"¯V";s:3:"狽";s:2:"¯W";s:3:"狸";s:2:"¯X";s:3:"ç‹·";s:2:"¯Y";s:3:"玆";s:2:"¯Z";s:3:"ç­";s:2:"¯[";s:3:"ç‰";s:2:"¯\";s:3:"ç®";s:2:"¯]";s:3:"ç ";s:2:"¯^";s:3:"çª";s:2:"¯_";s:3:"çž";s:2:"¯`";s:3:"ç•”";s:2:"¯a";s:3:"ç•";s:2:"¯b";s:3:"ç•œ";s:2:"¯c";s:3:"ç•š";s:2:"¯d";s:3:"ç•™";s:2:"¯e";s:3:"ç–¾";s:2:"¯f";s:3:"ç—…";s:2:"¯g";s:3:"ç—‡";s:2:"¯h";s:3:"ç–²";s:2:"¯i";s:3:"ç–³";s:2:"¯j";s:3:"ç–½";s:2:"¯k";s:3:"ç–¼";s:2:"¯l";s:3:"ç–¹";s:2:"¯m";s:3:"ç—‚";s:2:"¯n";s:3:"ç–¸";s:2:"¯o";s:3:"çš‹";s:2:"¯p";s:3:"çš°";s:2:"¯q";s:3:"益";s:2:"¯r";s:3:"ç›";s:2:"¯s";s:3:"盎";s:2:"¯t";s:3:"眩";s:2:"¯u";s:3:"真";s:2:"¯v";s:3:"眠";s:2:"¯w";s:3:"眨";s:2:"¯x";s:3:"矩";s:2:"¯y";s:3:"ç °";s:2:"¯z";s:3:"ç §";s:2:"¯{";s:3:"ç ¸";s:2:"¯|";s:3:"ç ";s:2:"¯}";s:3:"ç ´";s:2:"¯~";s:3:"ç ·";s:2:"¯¡";s:3:"ç ¥";s:2:"¯¢";s:3:"ç ­";s:2:"¯£";s:3:"ç  ";s:2:"¯¤";s:3:"ç Ÿ";s:2:"¯¥";s:3:"ç ²";s:2:"¯¦";s:3:"祕";s:2:"¯§";s:3:"ç¥";s:2:"¯¨";s:3:"祠";s:2:"¯©";s:3:"祟";s:2:"¯ª";s:3:"祖";s:2:"¯«";s:3:"神";s:2:"¯¬";s:3:"ç¥";s:2:"¯­";s:3:"祗";s:2:"¯®";s:3:"祚";s:2:"¯¯";s:3:"秤";s:2:"¯°";s:3:"秣";s:2:"¯±";s:3:"秧";s:2:"¯²";s:3:"租";s:2:"¯³";s:3:"秦";s:2:"¯´";s:3:"秩";s:2:"¯µ";s:3:"秘";s:2:"¯¶";s:3:"窄";s:2:"¯·";s:3:"窈";s:2:"¯¸";s:3:"ç«™";s:2:"¯¹";s:3:"笆";s:2:"¯º";s:3:"笑";s:2:"¯»";s:3:"粉";s:2:"¯¼";s:3:"ç´¡";s:2:"¯½";s:3:"ç´—";s:2:"¯¾";s:3:"ç´‹";s:2:"¯¿";s:3:"ç´Š";s:2:"¯À";s:3:"ç´ ";s:2:"¯Á";s:3:"ç´¢";s:2:"¯Â";s:3:"ç´”";s:2:"¯Ã";s:3:"ç´";s:2:"¯Ä";s:3:"ç´•";s:2:"¯Å";s:3:"ç´š";s:2:"¯Æ";s:3:"ç´œ";s:2:"¯Ç";s:3:"ç´";s:2:"¯È";s:3:"ç´™";s:2:"¯É";s:3:"ç´›";s:2:"¯Ê";s:3:"缺";s:2:"¯Ë";s:3:"罟";s:2:"¯Ì";s:3:"ç¾”";s:2:"¯Í";s:3:"ç¿…";s:2:"¯Î";s:3:"ç¿";s:2:"¯Ï";s:3:"耆";s:2:"¯Ð";s:3:"耘";s:2:"¯Ñ";s:3:"耕";s:2:"¯Ò";s:3:"耙";s:2:"¯Ó";s:3:"耗";s:2:"¯Ô";s:3:"耽";s:2:"¯Õ";s:3:"耿";s:2:"¯Ö";s:3:"胱";s:2:"¯×";s:3:"è„‚";s:2:"¯Ø";s:3:"胰";s:2:"¯Ù";s:3:"è„…";s:2:"¯Ú";s:3:"胭";s:2:"¯Û";s:3:"胴";s:2:"¯Ü";s:3:"脆";s:2:"¯Ý";s:3:"胸";s:2:"¯Þ";s:3:"胳";s:2:"¯ß";s:3:"脈";s:2:"¯à";s:3:"能";s:2:"¯á";s:3:"è„Š";s:2:"¯â";s:3:"胼";s:2:"¯ã";s:3:"胯";s:2:"¯ä";s:3:"臭";s:2:"¯å";s:3:"臬";s:2:"¯æ";s:3:"舀";s:2:"¯ç";s:3:"èˆ";s:2:"¯è";s:3:"航";s:2:"¯é";s:3:"舫";s:2:"¯ê";s:3:"舨";s:2:"¯ë";s:3:"般";s:2:"¯ì";s:3:"芻";s:2:"¯í";s:3:"茫";s:2:"¯î";s:3:"è’";s:2:"¯ï";s:3:"è”";s:2:"¯ð";s:3:"èŠ";s:2:"¯ñ";s:3:"茸";s:2:"¯ò";s:3:"è";s:2:"¯ó";s:3:"è‰";s:2:"¯ô";s:3:"茵";s:2:"¯õ";s:3:"茴";s:2:"¯ö";s:3:"è";s:2:"¯÷";s:3:"茲";s:2:"¯ø";s:3:"茹";s:2:"¯ù";s:3:"茶";s:2:"¯ú";s:3:"茗";s:2:"¯û";s:3:"è€";s:2:"¯ü";s:3:"茱";s:2:"¯ý";s:3:"茨";s:2:"¯þ";s:3:"èƒ";s:2:"°@";s:3:"è™”";s:2:"°A";s:3:"蚊";s:2:"°B";s:3:"蚪";s:2:"°C";s:3:"èš“";s:2:"°D";s:3:"蚤";s:2:"°E";s:3:"èš©";s:2:"°F";s:3:"蚌";s:2:"°G";s:3:"蚣";s:2:"°H";s:3:"èšœ";s:2:"°I";s:3:"è¡°";s:2:"°J";s:3:"è¡·";s:2:"°K";s:3:"è¢";s:2:"°L";s:3:"袂";s:2:"°M";s:3:"衽";s:2:"°N";s:3:"衹";s:2:"°O";s:3:"記";s:2:"°P";s:3:"è¨";s:2:"°Q";s:3:"討";s:2:"°R";s:3:"訌";s:2:"°S";s:3:"訕";s:2:"°T";s:3:"訊";s:2:"°U";s:3:"託";s:2:"°V";s:3:"訓";s:2:"°W";s:3:"訖";s:2:"°X";s:3:"è¨";s:2:"°Y";s:3:"訑";s:2:"°Z";s:3:"豈";s:2:"°[";s:3:"豺";s:2:"°\";s:3:"è±¹";s:2:"°]";s:3:"財";s:2:"°^";s:3:"è²¢";s:2:"°_";s:3:"èµ·";s:2:"°`";s:3:"躬";s:2:"°a";s:3:"è»’";s:2:"°b";s:3:"è»”";s:2:"°c";s:3:"è»";s:2:"°d";s:3:"è¾±";s:2:"°e";s:3:"é€";s:2:"°f";s:3:"逆";s:2:"°g";s:3:"è¿·";s:2:"°h";s:3:"退";s:2:"°i";s:3:"迺";s:2:"°j";s:3:"è¿´";s:2:"°k";s:3:"逃";s:2:"°l";s:3:"追";s:2:"°m";s:3:"逅";s:2:"°n";s:3:"迸";s:2:"°o";s:3:"é‚•";s:2:"°p";s:3:"郡";s:2:"°q";s:3:"éƒ";s:2:"°r";s:3:"郢";s:2:"°s";s:3:"é…’";s:2:"°t";s:3:"é…";s:2:"°u";s:3:"é…Œ";s:2:"°v";s:3:"釘";s:2:"°w";s:3:"é‡";s:2:"°x";s:3:"釗";s:2:"°y";s:3:"釜";s:2:"°z";s:3:"釙";s:2:"°{";s:3:"é–ƒ";s:2:"°|";s:3:"院";s:2:"°}";s:3:"陣";s:2:"°~";s:3:"陡";s:2:"°¡";s:3:"é™›";s:2:"°¢";s:3:"é™";s:2:"°£";s:3:"除";s:2:"°¤";s:3:"陘";s:2:"°¥";s:3:"陞";s:2:"°¦";s:3:"éš»";s:2:"°§";s:3:"飢";s:2:"°¨";s:3:"馬";s:2:"°©";s:3:"骨";s:2:"°ª";s:3:"高";s:2:"°«";s:3:"鬥";s:2:"°¬";s:3:"鬲";s:2:"°­";s:3:"鬼";s:2:"°®";s:3:"ä¹¾";s:2:"°¯";s:3:"åº";s:2:"°°";s:3:"å½";s:2:"°±";s:3:"åœ";s:2:"°²";s:3:"å‡";s:2:"°³";s:3:"åƒ";s:2:"°´";s:3:"åŒ";s:2:"°µ";s:3:"åš";s:2:"°¶";s:3:"å‰";s:2:"°·";s:3:"å¥";s:2:"°¸";s:3:"å¶";s:2:"°¹";s:3:"åŽ";s:2:"°º";s:3:"å•";s:2:"°»";s:3:"åµ";s:2:"°¼";s:3:"å´";s:2:"°½";s:3:"å·";s:2:"°¾";s:3:"å";s:2:"°¿";s:3:"å€";s:2:"°À";s:3:"å¯";s:2:"°Á";s:3:"å­";s:2:"°Â";s:3:"å…œ";s:2:"°Ã";s:3:"冕";s:2:"°Ä";s:3:"凰";s:2:"°Å";s:3:"剪";s:2:"°Æ";s:3:"副";s:2:"°Ç";s:3:"å‹’";s:2:"°È";s:3:"å‹™";s:2:"°É";s:3:"勘";s:2:"°Ê";s:3:"å‹•";s:2:"°Ë";s:3:"åŒ";s:2:"°Ì";s:3:"åŒ";s:2:"°Í";s:3:"匙";s:2:"°Î";s:3:"匿";s:2:"°Ï";s:3:"å€";s:2:"°Ð";s:3:"匾";s:2:"°Ñ";s:3:"åƒ";s:2:"°Ò";s:3:"曼";s:2:"°Ó";s:3:"商";s:2:"°Ô";s:3:"啪";s:2:"°Õ";s:3:"啦";s:2:"°Ö";s:3:"å•„";s:2:"°×";s:3:"å•ž";s:2:"°Ø";s:3:"å•¡";s:2:"°Ù";s:3:"啃";s:2:"°Ú";s:3:"å•Š";s:2:"°Û";s:3:"å”±";s:2:"°Ü";s:3:"å•–";s:2:"°Ý";s:3:"å•";s:2:"°Þ";s:3:"å••";s:2:"°ß";s:3:"唯";s:2:"°à";s:3:"啤";s:2:"°á";s:3:"唸";s:2:"°â";s:3:"å”®";s:2:"°ã";s:3:"å•œ";s:2:"°ä";s:3:"唬";s:2:"°å";s:3:"å•£";s:2:"°æ";s:3:"唳";s:2:"°ç";s:3:"å•";s:2:"°è";s:3:"å•—";s:2:"°é";s:3:"圈";s:2:"°ê";s:3:"國";s:2:"°ë";s:3:"圉";s:2:"°ì";s:3:"域";s:2:"°í";s:3:"å …";s:2:"°î";s:3:"å Š";s:2:"°ï";s:3:"å †";s:2:"°ð";s:3:"埠";s:2:"°ñ";s:3:"埤";s:2:"°ò";s:3:"基";s:2:"°ó";s:3:"å ‚";s:2:"°ô";s:3:"å µ";s:2:"°õ";s:3:"執";s:2:"°ö";s:3:"培";s:2:"°÷";s:3:"夠";s:2:"°ø";s:3:"奢";s:2:"°ù";s:3:"娶";s:2:"°ú";s:3:"å©";s:2:"°û";s:3:"婉";s:2:"°ü";s:3:"婦";s:2:"°ý";s:3:"婪";s:2:"°þ";s:3:"å©€";s:2:"±@";s:3:"娼";s:2:"±A";s:3:"å©¢";s:2:"±B";s:3:"å©š";s:2:"±C";s:3:"婆";s:2:"±D";s:3:"å©Š";s:2:"±E";s:3:"å­°";s:2:"±F";s:3:"寇";s:2:"±G";s:3:"寅";s:2:"±H";s:3:"寄";s:2:"±I";s:3:"寂";s:2:"±J";s:3:"宿";s:2:"±K";s:3:"密";s:2:"±L";s:3:"å°‰";s:2:"±M";s:3:"å°ˆ";s:2:"±N";s:3:"å°‡";s:2:"±O";s:3:"å± ";s:2:"±P";s:3:"屜";s:2:"±Q";s:3:"å±";s:2:"±R";s:3:"å´‡";s:2:"±S";s:3:"å´†";s:2:"±T";s:3:"å´Ž";s:2:"±U";s:3:"å´›";s:2:"±V";s:3:"å´–";s:2:"±W";s:3:"å´¢";s:2:"±X";s:3:"å´‘";s:2:"±Y";s:3:"å´©";s:2:"±Z";s:3:"å´”";s:2:"±[";s:3:"å´™";s:2:"±\";s:3:"å´¤";s:2:"±]";s:3:"å´§";s:2:"±^";s:3:"å´—";s:2:"±_";s:3:"å·¢";s:2:"±`";s:3:"常";s:2:"±a";s:3:"帶";s:2:"±b";s:3:"帳";s:2:"±c";s:3:"帷";s:2:"±d";s:3:"康";s:2:"±e";s:3:"庸";s:2:"±f";s:3:"庶";s:2:"±g";s:3:"庵";s:2:"±h";s:3:"庾";s:2:"±i";s:3:"å¼µ";s:2:"±j";s:3:"å¼·";s:2:"±k";s:3:"å½—";s:2:"±l";s:3:"彬";s:2:"±m";s:3:"彩";s:2:"±n";s:3:"彫";s:2:"±o";s:3:"å¾—";s:2:"±p";s:3:"å¾™";s:2:"±q";s:3:"從";s:2:"±r";s:3:"徘";s:2:"±s";s:3:"御";s:2:"±t";s:3:"å¾ ";s:2:"±u";s:3:"徜";s:2:"±v";s:3:"æ¿";s:2:"±w";s:3:"æ‚£";s:2:"±x";s:3:"悉";s:2:"±y";s:3:"æ‚ ";s:2:"±z";s:3:"您";s:2:"±{";s:3:"惋";s:2:"±|";s:3:"æ‚´";s:2:"±}";s:3:"惦";s:2:"±~";s:3:"悽";s:2:"±¡";s:3:"情";s:2:"±¢";s:3:"æ‚»";s:2:"±£";s:3:"悵";s:2:"±¤";s:3:"惜";s:2:"±¥";s:3:"悼";s:2:"±¦";s:3:"惘";s:2:"±§";s:3:"惕";s:2:"±¨";s:3:"惆";s:2:"±©";s:3:"惟";s:2:"±ª";s:3:"悸";s:2:"±«";s:3:"惚";s:2:"±¬";s:3:"惇";s:2:"±­";s:3:"戚";s:2:"±®";s:3:"戛";s:2:"±¯";s:3:"扈";s:2:"±°";s:3:"掠";s:2:"±±";s:3:"控";s:2:"±²";s:3:"æ²";s:2:"±³";s:3:"掖";s:2:"±´";s:3:"探";s:2:"±µ";s:3:"接";s:2:"±¶";s:3:"æ·";s:2:"±·";s:3:"æ§";s:2:"±¸";s:3:"掘";s:2:"±¹";s:3:"措";s:2:"±º";s:3:"æ±";s:2:"±»";s:3:"掩";s:2:"±¼";s:3:"掉";s:2:"±½";s:3:"掃";s:2:"±¾";s:3:"掛";s:2:"±¿";s:3:"æ«";s:2:"±À";s:3:"推";s:2:"±Á";s:3:"掄";s:2:"±Â";s:3:"授";s:2:"±Ã";s:3:"掙";s:2:"±Ä";s:3:"採";s:2:"±Å";s:3:"掬";s:2:"±Æ";s:3:"排";s:2:"±Ç";s:3:"æŽ";s:2:"±È";s:3:"掀";s:2:"±É";s:3:"æ»";s:2:"±Ê";s:3:"æ©";s:2:"±Ë";s:3:"æ¨";s:2:"±Ì";s:3:"æº";s:2:"±Í";s:3:"æ•";s:2:"±Î";s:3:"æ•–";s:2:"±Ï";s:3:"æ•‘";s:2:"±Ð";s:3:"æ•™";s:2:"±Ñ";s:3:"æ•—";s:2:"±Ò";s:3:"å•Ÿ";s:2:"±Ó";s:3:"æ•";s:2:"±Ô";s:3:"敘";s:2:"±Õ";s:3:"æ••";s:2:"±Ö";s:3:"æ•”";s:2:"±×";s:3:"æ–œ";s:2:"±Ø";s:3:"æ–›";s:2:"±Ù";s:3:"æ–¬";s:2:"±Ú";s:3:"æ—";s:2:"±Û";s:3:"æ—‹";s:2:"±Ü";s:3:"æ—Œ";s:2:"±Ý";s:3:"æ—Ž";s:2:"±Þ";s:3:"æ™";s:2:"±ß";s:3:"晚";s:2:"±à";s:3:"晤";s:2:"±á";s:3:"晨";s:2:"±â";s:3:"晦";s:2:"±ã";s:3:"晞";s:2:"±ä";s:3:"曹";s:2:"±å";s:3:"å‹—";s:2:"±æ";s:3:"望";s:2:"±ç";s:3:"æ¢";s:2:"±è";s:3:"梯";s:2:"±é";s:3:"梢";s:2:"±ê";s:3:"梓";s:2:"±ë";s:3:"梵";s:2:"±ì";s:3:"æ¡¿";s:2:"±í";s:3:"桶";s:2:"±î";s:3:"梱";s:2:"±ï";s:3:"梧";s:2:"±ð";s:3:"梗";s:2:"±ñ";s:3:"械";s:2:"±ò";s:3:"梃";s:2:"±ó";s:3:"棄";s:2:"±ô";s:3:"梭";s:2:"±õ";s:3:"梆";s:2:"±ö";s:3:"梅";s:2:"±÷";s:3:"梔";s:2:"±ø";s:3:"æ¢";s:2:"±ù";s:3:"梨";s:2:"±ú";s:3:"梟";s:2:"±û";s:3:"梡";s:2:"±ü";s:3:"梂";s:2:"±ý";s:3:"欲";s:2:"±þ";s:3:"殺";s:2:"²@";s:3:"毫";s:2:"²A";s:3:"毬";s:2:"²B";s:3:"æ°«";s:2:"²C";s:3:"涎";s:2:"²D";s:3:"涼";s:2:"²E";s:3:"æ·³";s:2:"²F";s:3:"æ·™";s:2:"²G";s:3:"液";s:2:"²H";s:3:"æ·¡";s:2:"²I";s:3:"æ·Œ";s:2:"²J";s:3:"æ·¤";s:2:"²K";s:3:"æ·»";s:2:"²L";s:3:"æ·º";s:2:"²M";s:3:"清";s:2:"²N";s:3:"æ·‡";s:2:"²O";s:3:"æ·‹";s:2:"²P";s:3:"涯";s:2:"²Q";s:3:"æ·‘";s:2:"²R";s:3:"涮";s:2:"²S";s:3:"æ·ž";s:2:"²T";s:3:"æ·¹";s:2:"²U";s:3:"涸";s:2:"²V";s:3:"æ··";s:2:"²W";s:3:"æ·µ";s:2:"²X";s:3:"æ·…";s:2:"²Y";s:3:"æ·’";s:2:"²Z";s:3:"渚";s:2:"²[";s:3:"涵";s:2:"²\";s:3:"æ·š";s:2:"²]";s:3:"æ·«";s:2:"²^";s:3:"æ·˜";s:2:"²_";s:3:"æ·ª";s:2:"²`";s:3:"æ·±";s:2:"²a";s:3:"æ·®";s:2:"²b";s:3:"æ·¨";s:2:"²c";s:3:"æ·†";s:2:"²d";s:3:"æ·„";s:2:"²e";s:3:"涪";s:2:"²f";s:3:"æ·¬";s:2:"²g";s:3:"涿";s:2:"²h";s:3:"æ·¦";s:2:"²i";s:3:"烹";s:2:"²j";s:3:"焉";s:2:"²k";s:3:"ç„Š";s:2:"²l";s:3:"烽";s:2:"²m";s:3:"烯";s:2:"²n";s:3:"爽";s:2:"²o";s:3:"牽";s:2:"²p";s:3:"çŠ";s:2:"²q";s:3:"猜";s:2:"²r";s:3:"猛";s:2:"²s";s:3:"猖";s:2:"²t";s:3:"猓";s:2:"²u";s:3:"猙";s:2:"²v";s:3:"率";s:2:"²w";s:3:"ç…";s:2:"²x";s:3:"çŠ";s:2:"²y";s:3:"çƒ";s:2:"²z";s:3:"ç†";s:2:"²{";s:3:"ç¾";s:2:"²|";s:3:"ç";s:2:"²}";s:3:"ç“ ";s:2:"²~";s:3:"瓶";s:2:"²¡";s:3:"ç“·";s:2:"²¢";s:3:"甜";s:2:"²£";s:3:"產";s:2:"²¤";s:3:"ç•¥";s:2:"²¥";s:3:"畦";s:2:"²¦";s:3:"ç•¢";s:2:"²§";s:3:"ç•°";s:2:"²¨";s:3:"ç–";s:2:"²©";s:3:"ç—”";s:2:"²ª";s:3:"ç—•";s:2:"²«";s:3:"ç–µ";s:2:"²¬";s:3:"ç—Š";s:2:"²­";s:3:"ç—";s:2:"²®";s:3:"皎";s:2:"²¯";s:3:"ç›”";s:2:"²°";s:3:"ç›’";s:2:"²±";s:3:"ç››";s:2:"²²";s:3:"眷";s:2:"²³";s:3:"眾";s:2:"²´";s:3:"眼";s:2:"²µ";s:3:"眶";s:2:"²¶";s:3:"眸";s:2:"²·";s:3:"眺";s:2:"²¸";s:3:"ç¡«";s:2:"²¹";s:3:"硃";s:2:"²º";s:3:"ç¡Ž";s:2:"²»";s:3:"祥";s:2:"²¼";s:3:"票";s:2:"²½";s:3:"祭";s:2:"²¾";s:3:"移";s:2:"²¿";s:3:"窒";s:2:"²À";s:3:"窕";s:2:"²Á";s:3:"笠";s:2:"²Â";s:3:"笨";s:2:"²Ã";s:3:"笛";s:2:"²Ä";s:3:"第";s:2:"²Å";s:3:"符";s:2:"²Æ";s:3:"笙";s:2:"²Ç";s:3:"笞";s:2:"²È";s:3:"笮";s:2:"²É";s:3:"ç²’";s:2:"²Ê";s:3:"ç²—";s:2:"²Ë";s:3:"粕";s:2:"²Ì";s:3:"絆";s:2:"²Í";s:3:"絃";s:2:"²Î";s:3:"çµ±";s:2:"²Ï";s:3:"ç´®";s:2:"²Ð";s:3:"ç´¹";s:2:"²Ñ";s:3:"ç´¼";s:2:"²Ò";s:3:"çµ€";s:2:"²Ó";s:3:"ç´°";s:2:"²Ô";s:3:"ç´³";s:2:"²Õ";s:3:"組";s:2:"²Ö";s:3:"ç´¯";s:2:"²×";s:3:"終";s:2:"²Ø";s:3:"ç´²";s:2:"²Ù";s:3:"ç´±";s:2:"²Ú";s:3:"ç¼½";s:2:"²Û";s:3:"羞";s:2:"²Ü";s:3:"羚";s:2:"²Ý";s:3:"ç¿Œ";s:2:"²Þ";s:3:"ç¿Ž";s:2:"²ß";s:3:"ç¿’";s:2:"²à";s:3:"耜";s:2:"²á";s:3:"èŠ";s:2:"²â";s:3:"è†";s:2:"²ã";s:3:"脯";s:2:"²ä";s:3:"è„–";s:2:"²å";s:3:"è„£";s:2:"²æ";s:3:"è„«";s:2:"²ç";s:3:"è„©";s:2:"²è";s:3:"è„°";s:2:"²é";s:3:"脤";s:2:"²ê";s:3:"舂";s:2:"²ë";s:3:"舵";s:2:"²ì";s:3:"舷";s:2:"²í";s:3:"舶";s:2:"²î";s:3:"船";s:2:"²ï";s:3:"莎";s:2:"²ð";s:3:"莞";s:2:"²ñ";s:3:"莘";s:2:"²ò";s:3:"è¸";s:2:"²ó";s:3:"莢";s:2:"²ô";s:3:"莖";s:2:"²õ";s:3:"莽";s:2:"²ö";s:3:"莫";s:2:"²÷";s:3:"莒";s:2:"²ø";s:3:"莊";s:2:"²ù";s:3:"莓";s:2:"²ú";s:3:"莉";s:2:"²û";s:3:"莠";s:2:"²ü";s:3:"è·";s:2:"²ý";s:3:"è»";s:2:"²þ";s:3:"è¼";s:2:"³@";s:3:"莆";s:2:"³A";s:3:"莧";s:2:"³B";s:3:"處";s:2:"³C";s:3:"彪";s:2:"³D";s:3:"蛇";s:2:"³E";s:3:"蛀";s:2:"³F";s:3:"蚶";s:2:"³G";s:3:"蛄";s:2:"³H";s:3:"èšµ";s:2:"³I";s:3:"蛆";s:2:"³J";s:3:"蛋";s:2:"³K";s:3:"èš±";s:2:"³L";s:3:"蚯";s:2:"³M";s:3:"蛉";s:2:"³N";s:3:"è¡“";s:2:"³O";s:3:"袞";s:2:"³P";s:3:"袈";s:2:"³Q";s:3:"被";s:2:"³R";s:3:"袒";s:2:"³S";s:3:"袖";s:2:"³T";s:3:"è¢";s:2:"³U";s:3:"袋";s:2:"³V";s:3:"覓";s:2:"³W";s:3:"è¦";s:2:"³X";s:3:"訪";s:2:"³Y";s:3:"è¨";s:2:"³Z";s:3:"訣";s:2:"³[";s:3:"訥";s:2:"³\";s:3:"許";s:2:"³]";s:3:"設";s:2:"³^";s:3:"訟";s:2:"³_";s:3:"訛";s:2:"³`";s:3:"訢";s:2:"³a";s:3:"豉";s:2:"³b";s:3:"豚";s:2:"³c";s:3:"販";s:2:"³d";s:3:"責";s:2:"³e";s:3:"貫";s:2:"³f";s:3:"貨";s:2:"³g";s:3:"貪";s:2:"³h";s:3:"貧";s:2:"³i";s:3:"赧";s:2:"³j";s:3:"赦";s:2:"³k";s:3:"趾";s:2:"³l";s:3:"趺";s:2:"³m";s:3:"è»›";s:2:"³n";s:3:"軟";s:2:"³o";s:3:"這";s:2:"³p";s:3:"é€";s:2:"³q";s:3:"通";s:2:"³r";s:3:"逗";s:2:"³s";s:3:"連";s:2:"³t";s:3:"速";s:2:"³u";s:3:"é€";s:2:"³v";s:3:"é€";s:2:"³w";s:3:"逕";s:2:"³x";s:3:"逞";s:2:"³y";s:3:"造";s:2:"³z";s:3:"é€";s:2:"³{";s:3:"逢";s:2:"³|";s:3:"逖";s:2:"³}";s:3:"逛";s:2:"³~";s:3:"途";s:2:"³¡";s:3:"部";s:2:"³¢";s:3:"郭";s:2:"³£";s:3:"都";s:2:"³¤";s:3:"é…—";s:2:"³¥";s:3:"野";s:2:"³¦";s:3:"釵";s:2:"³§";s:3:"釦";s:2:"³¨";s:3:"釣";s:2:"³©";s:3:"釧";s:2:"³ª";s:3:"釭";s:2:"³«";s:3:"釩";s:2:"³¬";s:3:"é–‰";s:2:"³­";s:3:"陪";s:2:"³®";s:3:"陵";s:2:"³¯";s:3:"陳";s:2:"³°";s:3:"陸";s:2:"³±";s:3:"é™°";s:2:"³²";s:3:"é™´";s:2:"³³";s:3:"陶";s:2:"³´";s:3:"é™·";s:2:"³µ";s:3:"陬";s:2:"³¶";s:3:"雀";s:2:"³·";s:3:"雪";s:2:"³¸";s:3:"雩";s:2:"³¹";s:3:"ç« ";s:2:"³º";s:3:"ç«Ÿ";s:2:"³»";s:3:"é ‚";s:2:"³¼";s:3:"é ƒ";s:2:"³½";s:3:"é­š";s:2:"³¾";s:3:"é³¥";s:2:"³¿";s:3:"é¹µ";s:2:"³À";s:3:"鹿";s:2:"³Á";s:3:"麥";s:2:"³Â";s:3:"麻";s:2:"³Ã";s:3:"å‚¢";s:2:"³Ä";s:3:"å‚";s:2:"³Å";s:3:"å‚…";s:2:"³Æ";s:3:"å‚™";s:2:"³Ç";s:3:"å‚‘";s:2:"³È";s:3:"å‚€";s:2:"³É";s:3:"å‚–";s:2:"³Ê";s:3:"傘";s:2:"³Ë";s:3:"å‚š";s:2:"³Ì";s:3:"最";s:2:"³Í";s:3:"凱";s:2:"³Î";s:3:"割";s:2:"³Ï";s:3:"剴";s:2:"³Ð";s:3:"創";s:2:"³Ñ";s:3:"剩";s:2:"³Ò";s:3:"å‹ž";s:2:"³Ó";s:3:"å‹";s:2:"³Ô";s:3:"å‹›";s:2:"³Õ";s:3:"åš";s:2:"³Ö";s:3:"厥";s:2:"³×";s:3:"å•»";s:2:"³Ø";s:3:"å–€";s:2:"³Ù";s:3:"å–§";s:2:"³Ú";s:3:"啼";s:2:"³Û";s:3:"å–Š";s:2:"³Ü";s:3:"å–";s:2:"³Ý";s:3:"å–˜";s:2:"³Þ";s:3:"å–‚";s:2:"³ß";s:3:"å–œ";s:2:"³à";s:3:"å–ª";s:2:"³á";s:3:"å–”";s:2:"³â";s:3:"å–‡";s:2:"³ã";s:3:"å–‹";s:2:"³ä";s:3:"å–ƒ";s:2:"³å";s:3:"å–³";s:2:"³æ";s:3:"å–®";s:2:"³ç";s:3:"å–Ÿ";s:2:"³è";s:3:"唾";s:2:"³é";s:3:"å–²";s:2:"³ê";s:3:"å–š";s:2:"³ë";s:3:"å–»";s:2:"³ì";s:3:"å–¬";s:2:"³í";s:3:"å–±";s:2:"³î";s:3:"啾";s:2:"³ï";s:3:"å–‰";s:2:"³ð";s:3:"å–«";s:2:"³ñ";s:3:"å–™";s:2:"³ò";s:3:"åœ";s:2:"³ó";s:3:"å ¯";s:2:"³ô";s:3:"å ª";s:2:"³õ";s:3:"å ´";s:2:"³ö";s:3:"å ¤";s:2:"³÷";s:3:"å °";s:2:"³ø";s:3:"å ±";s:2:"³ù";s:3:"å ¡";s:2:"³ú";s:3:"å ";s:2:"³û";s:3:"å  ";s:2:"³ü";s:3:"壹";s:2:"³ý";s:3:"壺";s:2:"³þ";s:3:"奠";s:2:"´@";s:3:"å©·";s:2:"´A";s:3:"媚";s:2:"´B";s:3:"å©¿";s:2:"´C";s:3:"媒";s:2:"´D";s:3:"媛";s:2:"´E";s:3:"媧";s:2:"´F";s:3:"å­³";s:2:"´G";s:3:"å­±";s:2:"´H";s:3:"寒";s:2:"´I";s:3:"富";s:2:"´J";s:3:"寓";s:2:"´K";s:3:"å¯";s:2:"´L";s:3:"å°Š";s:2:"´M";s:3:"å°‹";s:2:"´N";s:3:"å°±";s:2:"´O";s:3:"嵌";s:2:"´P";s:3:"åµ";s:2:"´Q";s:3:"å´´";s:2:"´R";s:3:"嵇";s:2:"´S";s:3:"å·½";s:2:"´T";s:3:"å¹…";s:2:"´U";s:3:"帽";s:2:"´V";s:3:"å¹€";s:2:"´W";s:3:"幃";s:2:"´X";s:3:"å¹¾";s:2:"´Y";s:3:"廊";s:2:"´Z";s:3:"å»";s:2:"´[";s:3:"廂";s:2:"´\";s:3:"廄";s:2:"´]";s:3:"å¼¼";s:2:"´^";s:3:"å½­";s:2:"´_";s:3:"復";s:2:"´`";s:3:"循";s:2:"´a";s:3:"徨";s:2:"´b";s:3:"惑";s:2:"´c";s:3:"惡";s:2:"´d";s:3:"悲";s:2:"´e";s:3:"悶";s:2:"´f";s:3:"惠";s:2:"´g";s:3:"æ„œ";s:2:"´h";s:3:"æ„£";s:2:"´i";s:3:"惺";s:2:"´j";s:3:"æ„•";s:2:"´k";s:3:"惰";s:2:"´l";s:3:"惻";s:2:"´m";s:3:"惴";s:2:"´n";s:3:"æ…¨";s:2:"´o";s:3:"惱";s:2:"´p";s:3:"æ„Ž";s:2:"´q";s:3:"惶";s:2:"´r";s:3:"愉";s:2:"´s";s:3:"æ„€";s:2:"´t";s:3:"æ„’";s:2:"´u";s:3:"戟";s:2:"´v";s:3:"扉";s:2:"´w";s:3:"掣";s:2:"´x";s:3:"掌";s:2:"´y";s:3:"æ";s:2:"´z";s:3:"æ€";s:2:"´{";s:3:"æ©";s:2:"´|";s:3:"æ‰";s:2:"´}";s:3:"æ†";s:2:"´~";s:3:"æ";s:2:"´¡";s:3:"æ’";s:2:"´¢";s:3:"æ£";s:2:"´£";s:3:"æ";s:2:"´¤";s:3:"æ¡";s:2:"´¥";s:3:"æ–";s:2:"´¦";s:3:"æ­";s:2:"´§";s:3:"æ®";s:2:"´¨";s:3:"æ¶";s:2:"´©";s:3:"æ´";s:2:"´ª";s:3:"æª";s:2:"´«";s:3:"æ›";s:2:"´¬";s:3:"æ‘’";s:2:"´­";s:3:"æš";s:2:"´®";s:3:"æ¹";s:2:"´¯";s:3:"æ•ž";s:2:"´°";s:3:"敦";s:2:"´±";s:3:"æ•¢";s:2:"´²";s:3:"æ•£";s:2:"´³";s:3:"æ–‘";s:2:"´´";s:3:"æ–";s:2:"´µ";s:3:"æ–¯";s:2:"´¶";s:3:"æ™®";s:2:"´·";s:3:"æ™°";s:2:"´¸";s:3:"æ™´";s:2:"´¹";s:3:"晶";s:2:"´º";s:3:"景";s:2:"´»";s:3:"æš‘";s:2:"´¼";s:3:"智";s:2:"´½";s:3:"晾";s:2:"´¾";s:3:"æ™·";s:2:"´¿";s:3:"曾";s:2:"´À";s:3:"替";s:2:"´Á";s:3:"期";s:2:"´Â";s:3:"æœ";s:2:"´Ã";s:3:"棺";s:2:"´Ä";s:3:"棕";s:2:"´Å";s:3:"棠";s:2:"´Æ";s:3:"棘";s:2:"´Ç";s:3:"棗";s:2:"´È";s:3:"椅";s:2:"´É";s:3:"棟";s:2:"´Ê";s:3:"棵";s:2:"´Ë";s:3:"森";s:2:"´Ì";s:3:"棧";s:2:"´Í";s:3:"棹";s:2:"´Î";s:3:"棒";s:2:"´Ï";s:3:"棲";s:2:"´Ð";s:3:"棣";s:2:"´Ñ";s:3:"棋";s:2:"´Ò";s:3:"æ£";s:2:"´Ó";s:3:"æ¤";s:2:"´Ô";s:3:"椒";s:2:"´Õ";s:3:"椎";s:2:"´Ö";s:3:"棉";s:2:"´×";s:3:"棚";s:2:"´Ø";s:3:"楮";s:2:"´Ù";s:3:"棻";s:2:"´Ú";s:3:"款";s:2:"´Û";s:3:"欺";s:2:"´Ü";s:3:"欽";s:2:"´Ý";s:3:"殘";s:2:"´Þ";s:3:"æ®–";s:2:"´ß";s:3:"殼";s:2:"´à";s:3:"毯";s:2:"´á";s:3:"æ°®";s:2:"´â";s:3:"æ°¯";s:2:"´ã";s:3:"æ°¬";s:2:"´ä";s:3:"港";s:2:"´å";s:3:"游";s:2:"´æ";s:3:"æ¹”";s:2:"´ç";s:3:"渡";s:2:"´è";s:3:"渲";s:2:"´é";s:3:"湧";s:2:"´ê";s:3:"湊";s:2:"´ë";s:3:"渠";s:2:"´ì";s:3:"渥";s:2:"´í";s:3:"渣";s:2:"´î";s:3:"減";s:2:"´ï";s:3:"æ¹›";s:2:"´ð";s:3:"湘";s:2:"´ñ";s:3:"渤";s:2:"´ò";s:3:"æ¹–";s:2:"´ó";s:3:"æ¹®";s:2:"´ô";s:3:"渭";s:2:"´õ";s:3:"渦";s:2:"´ö";s:3:"湯";s:2:"´÷";s:3:"渴";s:2:"´ø";s:3:"æ¹";s:2:"´ù";s:3:"渺";s:2:"´ú";s:3:"測";s:2:"´û";s:3:"湃";s:2:"´ü";s:3:"æ¸";s:2:"´ý";s:3:"渾";s:2:"´þ";s:3:"滋";s:2:"µ@";s:3:"溉";s:2:"µA";s:3:"渙";s:2:"µB";s:3:"湎";s:2:"µC";s:3:"æ¹£";s:2:"µD";s:3:"湄";s:2:"µE";s:3:"æ¹²";s:2:"µF";s:3:"湩";s:2:"µG";s:3:"湟";s:2:"µH";s:3:"ç„™";s:2:"µI";s:3:"ç„š";s:2:"µJ";s:3:"焦";s:2:"µK";s:3:"ç„°";s:2:"µL";s:3:"ç„¡";s:2:"µM";s:3:"然";s:2:"µN";s:3:"ç…®";s:2:"µO";s:3:"ç„œ";s:2:"µP";s:3:"牌";s:2:"µQ";s:3:"犄";s:2:"µR";s:3:"犀";s:2:"µS";s:3:"猶";s:2:"µT";s:3:"猥";s:2:"µU";s:3:"猴";s:2:"µV";s:3:"猩";s:2:"µW";s:3:"çº";s:2:"µX";s:3:"çª";s:2:"µY";s:3:"ç³";s:2:"µZ";s:3:"ç¢";s:2:"µ[";s:3:"ç¥";s:2:"µ\";s:3:"çµ";s:2:"µ]";s:3:"ç¶";s:2:"µ^";s:3:"ç´";s:2:"µ_";s:3:"ç¯";s:2:"µ`";s:3:"ç›";s:2:"µa";s:3:"ç¦";s:2:"µb";s:3:"ç¨";s:2:"µc";s:3:"甥";s:2:"µd";s:3:"甦";s:2:"µe";s:3:"ç•«";s:2:"µf";s:3:"番";s:2:"µg";s:3:"ç—¢";s:2:"µh";s:3:"ç—›";s:2:"µi";s:3:"ç—£";s:2:"µj";s:3:"ç—™";s:2:"µk";s:3:"ç—˜";s:2:"µl";s:3:"ç—ž";s:2:"µm";s:3:"ç— ";s:2:"µn";s:3:"ç™»";s:2:"µo";s:3:"發";s:2:"µp";s:3:"çš–";s:2:"µq";s:3:"çš“";s:2:"µr";s:3:"çš´";s:2:"µs";s:3:"盜";s:2:"µt";s:3:"ç";s:2:"µu";s:3:"短";s:2:"µv";s:3:"ç¡";s:2:"µw";s:3:"硬";s:2:"µx";s:3:"硯";s:2:"µy";s:3:"ç¨";s:2:"µz";s:3:"稈";s:2:"µ{";s:3:"程";s:2:"µ|";s:3:"稅";s:2:"µ}";s:3:"稀";s:2:"µ~";s:3:"窘";s:2:"µ¡";s:3:"窗";s:2:"µ¢";s:3:"窖";s:2:"µ£";s:3:"ç«¥";s:2:"µ¤";s:3:"ç«£";s:2:"µ¥";s:3:"ç­‰";s:2:"µ¦";s:3:"ç­–";s:2:"µ§";s:3:"ç­†";s:2:"µ¨";s:3:"ç­";s:2:"µ©";s:3:"ç­’";s:2:"µª";s:3:"ç­”";s:2:"µ«";s:3:"ç­";s:2:"µ¬";s:3:"ç­‹";s:2:"µ­";s:3:"ç­";s:2:"µ®";s:3:"ç­‘";s:2:"µ¯";s:3:"粟";s:2:"µ°";s:3:"ç²¥";s:2:"µ±";s:3:"絞";s:2:"µ²";s:3:"çµ";s:2:"µ³";s:3:"絨";s:2:"µ´";s:3:"絕";s:2:"µµ";s:3:"ç´«";s:2:"µ¶";s:3:"çµ®";s:2:"µ·";s:3:"çµ²";s:2:"µ¸";s:3:"絡";s:2:"µ¹";s:3:"給";s:2:"µº";s:3:"çµ¢";s:2:"µ»";s:3:"çµ°";s:2:"µ¼";s:3:"çµ³";s:2:"µ½";s:3:"å–„";s:2:"µ¾";s:3:"ç¿”";s:2:"µ¿";s:3:"ç¿•";s:2:"µÀ";s:3:"耋";s:2:"µÁ";s:3:"è’";s:2:"µÂ";s:3:"è‚…";s:2:"µÃ";s:3:"è…•";s:2:"µÄ";s:3:"è…”";s:2:"µÅ";s:3:"è…‹";s:2:"µÆ";s:3:"è…‘";s:2:"µÇ";s:3:"è…Ž";s:2:"µÈ";s:3:"脹";s:2:"µÉ";s:3:"è…†";s:2:"µÊ";s:3:"脾";s:2:"µË";s:3:"è…Œ";s:2:"µÌ";s:3:"è…“";s:2:"µÍ";s:3:"è…´";s:2:"µÎ";s:3:"舒";s:2:"µÏ";s:3:"舜";s:2:"µÐ";s:3:"è©";s:2:"µÑ";s:3:"èƒ";s:2:"µÒ";s:3:"è¸";s:2:"µÓ";s:3:"è";s:2:"µÔ";s:3:"è ";s:2:"µÕ";s:3:"è…";s:2:"µÖ";s:3:"è‹";s:2:"µ×";s:3:"è";s:2:"µØ";s:3:"è¯";s:2:"µÙ";s:3:"è±";s:2:"µÚ";s:3:"è´";s:2:"µÛ";s:3:"è‘—";s:2:"µÜ";s:3:"èŠ";s:2:"µÝ";s:3:"è°";s:2:"µÞ";s:3:"èŒ";s:2:"µß";s:3:"èŒ";s:2:"µà";s:3:"è½";s:2:"µá";s:3:"è²";s:2:"µâ";s:3:"èŠ";s:2:"µã";s:3:"è¸";s:2:"µä";s:3:"èŽ";s:2:"µå";s:3:"è„";s:2:"µæ";s:3:"èœ";s:2:"µç";s:3:"è‡";s:2:"µè";s:3:"è”";s:2:"µé";s:3:"èŸ";s:2:"µê";s:3:"è™›";s:2:"µë";s:3:"蛟";s:2:"µì";s:3:"è›™";s:2:"µí";s:3:"è›­";s:2:"µî";s:3:"è›”";s:2:"µï";s:3:"è››";s:2:"µð";s:3:"蛤";s:2:"µñ";s:3:"è›";s:2:"µò";s:3:"蛞";s:2:"µó";s:3:"è¡—";s:2:"µô";s:3:"è£";s:2:"µõ";s:3:"裂";s:2:"µö";s:3:"袱";s:2:"µ÷";s:3:"覃";s:2:"µø";s:3:"視";s:2:"µù";s:3:"註";s:2:"µú";s:3:"è© ";s:2:"µû";s:3:"è©•";s:2:"µü";s:3:"è©ž";s:2:"µý";s:3:"証";s:2:"µþ";s:3:"è©";s:2:"¶@";s:3:"è©”";s:2:"¶A";s:3:"è©›";s:2:"¶B";s:3:"è©";s:2:"¶C";s:3:"詆";s:2:"¶D";s:3:"訴";s:2:"¶E";s:3:"診";s:2:"¶F";s:3:"訶";s:2:"¶G";s:3:"è©–";s:2:"¶H";s:3:"象";s:2:"¶I";s:3:"貂";s:2:"¶J";s:3:"貯";s:2:"¶K";s:3:"è²¼";s:2:"¶L";s:3:"è²³";s:2:"¶M";s:3:"è²½";s:2:"¶N";s:3:"è³";s:2:"¶O";s:3:"è²»";s:2:"¶P";s:3:"è³€";s:2:"¶Q";s:3:"è²´";s:2:"¶R";s:3:"è²·";s:2:"¶S";s:3:"貶";s:2:"¶T";s:3:"貿";s:2:"¶U";s:3:"貸";s:2:"¶V";s:3:"越";s:2:"¶W";s:3:"超";s:2:"¶X";s:3:"è¶";s:2:"¶Y";s:3:"è·Ž";s:2:"¶Z";s:3:"è·";s:2:"¶[";s:3:"è·‹";s:2:"¶\";s:3:"è·š";s:2:"¶]";s:3:"è·‘";s:2:"¶^";s:3:"è·Œ";s:2:"¶_";s:3:"è·›";s:2:"¶`";s:3:"è·†";s:2:"¶a";s:3:"è»»";s:2:"¶b";s:3:"軸";s:2:"¶c";s:3:"軼";s:2:"¶d";s:3:"辜";s:2:"¶e";s:3:"逮";s:2:"¶f";s:3:"逵";s:2:"¶g";s:3:"週";s:2:"¶h";s:3:"逸";s:2:"¶i";s:3:"進";s:2:"¶j";s:3:"逶";s:2:"¶k";s:3:"é„‚";s:2:"¶l";s:3:"郵";s:2:"¶m";s:3:"鄉";s:2:"¶n";s:3:"郾";s:2:"¶o";s:3:"é…£";s:2:"¶p";s:3:"é…¥";s:2:"¶q";s:3:"é‡";s:2:"¶r";s:3:"鈔";s:2:"¶s";s:3:"鈕";s:2:"¶t";s:3:"鈣";s:2:"¶u";s:3:"鈉";s:2:"¶v";s:3:"鈞";s:2:"¶w";s:3:"éˆ";s:2:"¶x";s:3:"éˆ";s:2:"¶y";s:3:"鈇";s:2:"¶z";s:3:"鈑";s:2:"¶{";s:3:"é–”";s:2:"¶|";s:3:"é–";s:2:"¶}";s:3:"é–‹";s:2:"¶~";s:3:"é–‘";s:2:"¶¡";s:3:"é–“";s:2:"¶¢";s:3:"é–’";s:2:"¶£";s:3:"é–Ž";s:2:"¶¤";s:3:"隊";s:2:"¶¥";s:3:"階";s:2:"¶¦";s:3:"éš‹";s:2:"¶§";s:3:"陽";s:2:"¶¨";s:3:"éš…";s:2:"¶©";s:3:"隆";s:2:"¶ª";s:3:"éš";s:2:"¶«";s:3:"陲";s:2:"¶¬";s:3:"éš„";s:2:"¶­";s:3:"é›";s:2:"¶®";s:3:"é›…";s:2:"¶¯";s:3:"雄";s:2:"¶°";s:3:"集";s:2:"¶±";s:3:"雇";s:2:"¶²";s:3:"雯";s:2:"¶³";s:3:"雲";s:2:"¶´";s:3:"韌";s:2:"¶µ";s:3:"é …";s:2:"¶¶";s:3:"é †";s:2:"¶·";s:3:"é ˆ";s:2:"¶¸";s:3:"飧";s:2:"¶¹";s:3:"飪";s:2:"¶º";s:3:"飯";s:2:"¶»";s:3:"飩";s:2:"¶¼";s:3:"飲";s:2:"¶½";s:3:"飭";s:2:"¶¾";s:3:"馮";s:2:"¶¿";s:3:"馭";s:2:"¶À";s:3:"黃";s:2:"¶Á";s:3:"é»";s:2:"¶Â";s:3:"黑";s:2:"¶Ã";s:3:"亂";s:2:"¶Ä";s:3:"å‚­";s:2:"¶Å";s:3:"債";s:2:"¶Æ";s:3:"傲";s:2:"¶Ç";s:3:"傳";s:2:"¶È";s:3:"僅";s:2:"¶É";s:3:"傾";s:2:"¶Ê";s:3:"催";s:2:"¶Ë";s:3:"å‚·";s:2:"¶Ì";s:3:"å‚»";s:2:"¶Í";s:3:"傯";s:2:"¶Î";s:3:"僇";s:2:"¶Ï";s:3:"剿";s:2:"¶Ð";s:3:"剷";s:2:"¶Ñ";s:3:"剽";s:2:"¶Ò";s:3:"å‹Ÿ";s:2:"¶Ó";s:3:"勦";s:2:"¶Ô";s:3:"勤";s:2:"¶Õ";s:3:"å‹¢";s:2:"¶Ö";s:3:"å‹£";s:2:"¶×";s:3:"匯";s:2:"¶Ø";s:3:"å—Ÿ";s:2:"¶Ù";s:3:"å—¨";s:2:"¶Ú";s:3:"å—“";s:2:"¶Û";s:3:"å—¦";s:2:"¶Ü";s:3:"å—Ž";s:2:"¶Ý";s:3:"å—œ";s:2:"¶Þ";s:3:"å—‡";s:2:"¶ß";s:3:"å—‘";s:2:"¶à";s:3:"å—£";s:2:"¶á";s:3:"å—¤";s:2:"¶â";s:3:"å—¯";s:2:"¶ã";s:3:"å—š";s:2:"¶ä";s:3:"å—¡";s:2:"¶å";s:3:"å—…";s:2:"¶æ";s:3:"å—†";s:2:"¶ç";s:3:"å—¥";s:2:"¶è";s:3:"å—‰";s:2:"¶é";s:3:"園";s:2:"¶ê";s:3:"圓";s:2:"¶ë";s:3:"å¡ž";s:2:"¶ì";s:3:"å¡‘";s:2:"¶í";s:3:"塘";s:2:"¶î";s:3:"å¡—";s:2:"¶ï";s:3:"å¡š";s:2:"¶ð";s:3:"å¡”";s:2:"¶ñ";s:3:"å¡«";s:2:"¶ò";s:3:"å¡Œ";s:2:"¶ó";s:3:"å¡­";s:2:"¶ô";s:3:"å¡Š";s:2:"¶õ";s:3:"å¡¢";s:2:"¶ö";s:3:"å¡’";s:2:"¶÷";s:3:"å¡‹";s:2:"¶ø";s:3:"奧";s:2:"¶ù";s:3:"å«";s:2:"¶ú";s:3:"嫉";s:2:"¶û";s:3:"å«Œ";s:2:"¶ü";s:3:"媾";s:2:"¶ý";s:3:"媽";s:2:"¶þ";s:3:"媼";s:2:"·@";s:3:"媳";s:2:"·A";s:3:"å«‚";s:2:"·B";s:3:"媲";s:2:"·C";s:3:"嵩";s:2:"·D";s:3:"嵯";s:2:"·E";s:3:"幌";s:2:"·F";s:3:"å¹¹";s:2:"·G";s:3:"廉";s:2:"·H";s:3:"廈";s:2:"·I";s:3:"å¼’";s:2:"·J";s:3:"å½™";s:2:"·K";s:3:"徬";s:2:"·L";s:3:"å¾®";s:2:"·M";s:3:"æ„š";s:2:"·N";s:3:"æ„";s:2:"·O";s:3:"æ…ˆ";s:2:"·P";s:3:"æ„Ÿ";s:2:"·Q";s:3:"想";s:2:"·R";s:3:"æ„›";s:2:"·S";s:3:"惹";s:2:"·T";s:3:"æ„";s:2:"·U";s:3:"愈";s:2:"·V";s:3:"æ…Ž";s:2:"·W";s:3:"æ…Œ";s:2:"·X";s:3:"æ…„";s:2:"·Y";s:3:"æ…";s:2:"·Z";s:3:"愾";s:2:"·[";s:3:"æ„´";s:2:"·\";s:3:"愧";s:2:"·]";s:3:"æ„";s:2:"·^";s:3:"愆";s:2:"·_";s:3:"æ„·";s:2:"·`";s:3:"戡";s:2:"·a";s:3:"戢";s:2:"·b";s:3:"æ“";s:2:"·c";s:3:"æ¾";s:2:"·d";s:3:"æž";s:2:"·e";s:3:"æª";s:2:"·f";s:3:"æ­";s:2:"·g";s:3:"æ½";s:2:"·h";s:3:"æ¬";s:2:"·i";s:3:"æ";s:2:"·j";s:3:"æœ";s:2:"·k";s:3:"æ”";s:2:"·l";s:3:"æ";s:2:"·m";s:3:"æ¶";s:2:"·n";s:3:"æ–";s:2:"·o";s:3:"æ—";s:2:"·p";s:3:"æ†";s:2:"·q";s:3:"敬";s:2:"·r";s:3:"æ–Ÿ";s:2:"·s";s:3:"æ–°";s:2:"·t";s:3:"æš—";s:2:"·u";s:3:"暉";s:2:"·v";s:3:"暇";s:2:"·w";s:3:"暈";s:2:"·x";s:3:"æš–";s:2:"·y";s:3:"æš„";s:2:"·z";s:3:"暘";s:2:"·{";s:3:"æš";s:2:"·|";s:3:"會";s:2:"·}";s:3:"榔";s:2:"·~";s:3:"業";s:2:"·¡";s:3:"楚";s:2:"·¢";s:3:"楷";s:2:"·£";s:3:"楠";s:2:"·¤";s:3:"楔";s:2:"·¥";s:3:"極";s:2:"·¦";s:3:"椰";s:2:"·§";s:3:"概";s:2:"·¨";s:3:"楊";s:2:"·©";s:3:"楨";s:2:"·ª";s:3:"楫";s:2:"·«";s:3:"楞";s:2:"·¬";s:3:"楓";s:2:"·­";s:3:"楹";s:2:"·®";s:3:"榆";s:2:"·¯";s:3:"æ¥";s:2:"·°";s:3:"楣";s:2:"·±";s:3:"楛";s:2:"·²";s:3:"æ­‡";s:2:"·³";s:3:"æ­²";s:2:"·´";s:3:"毀";s:2:"·µ";s:3:"殿";s:2:"·¶";s:3:"毓";s:2:"··";s:3:"毽";s:2:"·¸";s:3:"溢";s:2:"·¹";s:3:"溯";s:2:"·º";s:3:"滓";s:2:"·»";s:3:"溶";s:2:"·¼";s:3:"滂";s:2:"·½";s:3:"æº";s:2:"·¾";s:3:"æº";s:2:"·¿";s:3:"滇";s:2:"·À";s:3:"æ»…";s:2:"·Á";s:3:"溥";s:2:"·Â";s:3:"溘";s:2:"·Ã";s:3:"溼";s:2:"·Ä";s:3:"溺";s:2:"·Å";s:3:"溫";s:2:"·Æ";s:3:"滑";s:2:"·Ç";s:3:"準";s:2:"·È";s:3:"溜";s:2:"·É";s:3:"滄";s:2:"·Ê";s:3:"æ»”";s:2:"·Ë";s:3:"溪";s:2:"·Ì";s:3:"溧";s:2:"·Í";s:3:"溴";s:2:"·Î";s:3:"ç…Ž";s:2:"·Ï";s:3:"ç…™";s:2:"·Ð";s:3:"ç…©";s:2:"·Ñ";s:3:"ç…¤";s:2:"·Ò";s:3:"ç…‰";s:2:"·Ó";s:3:"ç…§";s:2:"·Ô";s:3:"ç…œ";s:2:"·Õ";s:3:"ç…¬";s:2:"·Ö";s:3:"ç…¦";s:2:"·×";s:3:"ç…Œ";s:2:"·Ø";s:3:"ç…¥";s:2:"·Ù";s:3:"ç…ž";s:2:"·Ú";s:3:"ç…†";s:2:"·Û";s:3:"ç…¨";s:2:"·Ü";s:3:"ç…–";s:2:"·Ý";s:3:"爺";s:2:"·Þ";s:3:"牒";s:2:"·ß";s:3:"猷";s:2:"·à";s:3:"ç…";s:2:"·á";s:3:"猿";s:2:"·â";s:3:"猾";s:2:"·ã";s:3:"瑯";s:2:"·ä";s:3:"ç‘š";s:2:"·å";s:3:"ç‘•";s:2:"·æ";s:3:"ç‘Ÿ";s:2:"·ç";s:3:"ç‘ž";s:2:"·è";s:3:"ç‘";s:2:"·é";s:3:"ç¿";s:2:"·ê";s:3:"ç‘™";s:2:"·ë";s:3:"ç‘›";s:2:"·ì";s:3:"ç‘œ";s:2:"·í";s:3:"當";s:2:"·î";s:3:"畸";s:2:"·ï";s:3:"瘀";s:2:"·ð";s:3:"ç—°";s:2:"·ñ";s:3:"ç˜";s:2:"·ò";s:3:"ç—²";s:2:"·ó";s:3:"ç—±";s:2:"·ô";s:3:"ç—º";s:2:"·õ";s:3:"ç—¿";s:2:"·ö";s:3:"ç—´";s:2:"·÷";s:3:"ç—³";s:2:"·ø";s:3:"盞";s:2:"·ù";s:3:"盟";s:2:"·ú";s:3:"ç›";s:2:"·û";s:3:"ç«";s:2:"·ü";s:3:"ç¦";s:2:"·ý";s:3:"çž";s:2:"·þ";s:3:"ç£";s:2:"¸@";s:3:"ç¹";s:2:"¸A";s:3:"çª";s:2:"¸B";s:3:"ç¬";s:2:"¸C";s:3:"çœ";s:2:"¸D";s:3:"ç¥";s:2:"¸E";s:3:"ç¨";s:2:"¸F";s:3:"ç¢";s:2:"¸G";s:3:"矮";s:2:"¸H";s:3:"碎";s:2:"¸I";s:3:"碰";s:2:"¸J";s:3:"碗";s:2:"¸K";s:3:"碘";s:2:"¸L";s:3:"碌";s:2:"¸M";s:3:"碉";s:2:"¸N";s:3:"硼";s:2:"¸O";s:3:"碑";s:2:"¸P";s:3:"碓";s:2:"¸Q";s:3:"ç¡¿";s:2:"¸R";s:3:"祺";s:2:"¸S";s:3:"祿";s:2:"¸T";s:3:"ç¦";s:2:"¸U";s:3:"è¬";s:2:"¸V";s:3:"禽";s:2:"¸W";s:3:"稜";s:2:"¸X";s:3:"稚";s:2:"¸Y";s:3:"稠";s:2:"¸Z";s:3:"稔";s:2:"¸[";s:3:"稟";s:2:"¸\";s:3:"稞";s:2:"¸]";s:3:"窟";s:2:"¸^";s:3:"窠";s:2:"¸_";s:3:"ç­·";s:2:"¸`";s:3:"節";s:2:"¸a";s:3:"ç­ ";s:2:"¸b";s:3:"ç­®";s:2:"¸c";s:3:"ç­§";s:2:"¸d";s:3:"ç²±";s:2:"¸e";s:3:"ç²³";s:2:"¸f";s:3:"ç²µ";s:2:"¸g";s:3:"經";s:2:"¸h";s:3:"çµ¹";s:2:"¸i";s:3:"綑";s:2:"¸j";s:3:"ç¶";s:2:"¸k";s:3:"ç¶";s:2:"¸l";s:3:"çµ›";s:2:"¸m";s:3:"ç½®";s:2:"¸n";s:3:"罩";s:2:"¸o";s:3:"罪";s:2:"¸p";s:3:"ç½²";s:2:"¸q";s:3:"義";s:2:"¸r";s:3:"羨";s:2:"¸s";s:3:"群";s:2:"¸t";s:3:"è–";s:2:"¸u";s:3:"è˜";s:2:"¸v";s:3:"肆";s:2:"¸w";s:3:"è‚„";s:2:"¸x";s:3:"è…±";s:2:"¸y";s:3:"è…°";s:2:"¸z";s:3:"è…¸";s:2:"¸{";s:3:"è…¥";s:2:"¸|";s:3:"è…®";s:2:"¸}";s:3:"è…³";s:2:"¸~";s:3:"è…«";s:2:"¸¡";s:3:"è…¹";s:2:"¸¢";s:3:"è…º";s:2:"¸£";s:3:"è…¦";s:2:"¸¤";s:3:"舅";s:2:"¸¥";s:3:"艇";s:2:"¸¦";s:3:"è’‚";s:2:"¸§";s:3:"è‘·";s:2:"¸¨";s:3:"è½";s:2:"¸©";s:3:"è±";s:2:"¸ª";s:3:"葵";s:2:"¸«";s:3:"葦";s:2:"¸¬";s:3:"è‘«";s:2:"¸­";s:3:"葉";s:2:"¸®";s:3:"葬";s:2:"¸¯";s:3:"è‘›";s:2:"¸°";s:3:"è¼";s:2:"¸±";s:3:"èµ";s:2:"¸²";s:3:"è‘¡";s:2:"¸³";s:3:"è‘£";s:2:"¸´";s:3:"è‘©";s:2:"¸µ";s:3:"è‘­";s:2:"¸¶";s:3:"葆";s:2:"¸·";s:3:"虞";s:2:"¸¸";s:3:"虜";s:2:"¸¹";s:3:"號";s:2:"¸º";s:3:"蛹";s:2:"¸»";s:3:"蜓";s:2:"¸¼";s:3:"蜈";s:2:"¸½";s:3:"蜇";s:2:"¸¾";s:3:"蜀";s:2:"¸¿";s:3:"蛾";s:2:"¸À";s:3:"è›»";s:2:"¸Á";s:3:"蜂";s:2:"¸Â";s:3:"蜃";s:2:"¸Ã";s:3:"蜆";s:2:"¸Ä";s:3:"蜊";s:2:"¸Å";s:3:"è¡™";s:2:"¸Æ";s:3:"裟";s:2:"¸Ç";s:3:"裔";s:2:"¸È";s:3:"裙";s:2:"¸É";s:3:"補";s:2:"¸Ê";s:3:"裘";s:2:"¸Ë";s:3:"è£";s:2:"¸Ì";s:3:"裡";s:2:"¸Í";s:3:"裊";s:2:"¸Î";s:3:"裕";s:2:"¸Ï";s:3:"裒";s:2:"¸Ð";s:3:"覜";s:2:"¸Ñ";s:3:"解";s:2:"¸Ò";s:3:"è©«";s:2:"¸Ó";s:3:"該";s:2:"¸Ô";s:3:"詳";s:2:"¸Õ";s:3:"試";s:2:"¸Ö";s:3:"è©©";s:2:"¸×";s:3:"è©°";s:2:"¸Ø";s:3:"誇";s:2:"¸Ù";s:3:"詼";s:2:"¸Ú";s:3:"è©£";s:2:"¸Û";s:3:"誠";s:2:"¸Ü";s:3:"話";s:2:"¸Ý";s:3:"誅";s:2:"¸Þ";s:3:"è©­";s:2:"¸ß";s:3:"è©¢";s:2:"¸à";s:3:"è©®";s:2:"¸á";s:3:"詬";s:2:"¸â";s:3:"詹";s:2:"¸ã";s:3:"è©»";s:2:"¸ä";s:3:"訾";s:2:"¸å";s:3:"詨";s:2:"¸æ";s:3:"è±¢";s:2:"¸ç";s:3:"貊";s:2:"¸è";s:3:"貉";s:2:"¸é";s:3:"賊";s:2:"¸ê";s:3:"資";s:2:"¸ë";s:3:"賈";s:2:"¸ì";s:3:"賄";s:2:"¸í";s:3:"è²²";s:2:"¸î";s:3:"賃";s:2:"¸ï";s:3:"賂";s:2:"¸ð";s:3:"è³…";s:2:"¸ñ";s:3:"è·¡";s:2:"¸ò";s:3:"è·Ÿ";s:2:"¸ó";s:3:"è·¨";s:2:"¸ô";s:3:"è·¯";s:2:"¸õ";s:3:"è·³";s:2:"¸ö";s:3:"è·º";s:2:"¸÷";s:3:"è·ª";s:2:"¸ø";s:3:"è·¤";s:2:"¸ù";s:3:"è·¦";s:2:"¸ú";s:3:"躲";s:2:"¸û";s:3:"較";s:2:"¸ü";s:3:"載";s:2:"¸ý";s:3:"軾";s:2:"¸þ";s:3:"輊";s:2:"¹@";s:3:"辟";s:2:"¹A";s:3:"è¾²";s:2:"¹B";s:3:"é‹";s:2:"¹C";s:3:"éŠ";s:2:"¹D";s:3:"é“";s:2:"¹E";s:3:"é‚";s:2:"¹F";s:3:"é”";s:2:"¹G";s:3:"逼";s:2:"¹H";s:3:"é•";s:2:"¹I";s:3:"é";s:2:"¹J";s:3:"é‡";s:2:"¹K";s:3:"é";s:2:"¹L";s:3:"éŽ";s:2:"¹M";s:3:"é";s:2:"¹N";s:3:"é‘";s:2:"¹O";s:3:"逾";s:2:"¹P";s:3:"é";s:2:"¹Q";s:3:"é„’";s:2:"¹R";s:3:"é„—";s:2:"¹S";s:3:"é…¬";s:2:"¹T";s:3:"é…ª";s:2:"¹U";s:3:"é…©";s:2:"¹V";s:3:"釉";s:2:"¹W";s:3:"鈷";s:2:"¹X";s:3:"鉗";s:2:"¹Y";s:3:"鈸";s:2:"¹Z";s:3:"鈽";s:2:"¹[";s:3:"鉀";s:2:"¹\";s:3:"鈾";s:2:"¹]";s:3:"鉛";s:2:"¹^";s:3:"鉋";s:2:"¹_";s:3:"鉤";s:2:"¹`";s:3:"鉑";s:2:"¹a";s:3:"鈴";s:2:"¹b";s:3:"鉉";s:2:"¹c";s:3:"é‰";s:2:"¹d";s:3:"鉅";s:2:"¹e";s:3:"鈹";s:2:"¹f";s:3:"鈿";s:2:"¹g";s:3:"鉚";s:2:"¹h";s:3:"é–˜";s:2:"¹i";s:3:"隘";s:2:"¹j";s:3:"éš”";s:2:"¹k";s:3:"éš•";s:2:"¹l";s:3:"é›";s:2:"¹m";s:3:"雋";s:2:"¹n";s:3:"雉";s:2:"¹o";s:3:"雊";s:2:"¹p";s:3:"é›·";s:2:"¹q";s:3:"é›»";s:2:"¹r";s:3:"雹";s:2:"¹s";s:3:"零";s:2:"¹t";s:3:"é–";s:2:"¹u";s:3:"é´";s:2:"¹v";s:3:"é¶";s:2:"¹w";s:3:"é ";s:2:"¹x";s:3:"é ‘";s:2:"¹y";s:3:"é “";s:2:"¹z";s:3:"é Š";s:2:"¹{";s:3:"é ’";s:2:"¹|";s:3:"é Œ";s:2:"¹}";s:3:"飼";s:2:"¹~";s:3:"飴";s:2:"¹¡";s:3:"飽";s:2:"¹¢";s:3:"飾";s:2:"¹£";s:3:"馳";s:2:"¹¤";s:3:"馱";s:2:"¹¥";s:3:"馴";s:2:"¹¦";s:3:"é«¡";s:2:"¹§";s:3:"鳩";s:2:"¹¨";s:3:"麂";s:2:"¹©";s:3:"鼎";s:2:"¹ª";s:3:"鼓";s:2:"¹«";s:3:"é¼ ";s:2:"¹¬";s:3:"僧";s:2:"¹­";s:3:"僮";s:2:"¹®";s:3:"僥";s:2:"¹¯";s:3:"僖";s:2:"¹°";s:3:"僭";s:2:"¹±";s:3:"僚";s:2:"¹²";s:3:"僕";s:2:"¹³";s:3:"åƒ";s:2:"¹´";s:3:"僑";s:2:"¹µ";s:3:"僱";s:2:"¹¶";s:3:"僎";s:2:"¹·";s:3:"僩";s:2:"¹¸";s:3:"å…¢";s:2:"¹¹";s:3:"凳";s:2:"¹º";s:3:"劃";s:2:"¹»";s:3:"劂";s:2:"¹¼";s:3:"匱";s:2:"¹½";s:3:"厭";s:2:"¹¾";s:3:"å—¾";s:2:"¹¿";s:3:"嘀";s:2:"¹À";s:3:"嘛";s:2:"¹Á";s:3:"嘗";s:2:"¹Â";s:3:"å—½";s:2:"¹Ã";s:3:"嘔";s:2:"¹Ä";s:3:"嘆";s:2:"¹Å";s:3:"嘉";s:2:"¹Æ";s:3:"å˜";s:2:"¹Ç";s:3:"嘎";s:2:"¹È";s:3:"å—·";s:2:"¹É";s:3:"嘖";s:2:"¹Ê";s:3:"嘟";s:2:"¹Ë";s:3:"嘈";s:2:"¹Ì";s:3:"å˜";s:2:"¹Í";s:3:"å—¶";s:2:"¹Î";s:3:"團";s:2:"¹Ï";s:3:"圖";s:2:"¹Ð";s:3:"塵";s:2:"¹Ñ";s:3:"塾";s:2:"¹Ò";s:3:"境";s:2:"¹Ó";s:3:"墓";s:2:"¹Ô";s:3:"墊";s:2:"¹Õ";s:3:"塹";s:2:"¹Ö";s:3:"墅";s:2:"¹×";s:3:"塽";s:2:"¹Ø";s:3:"壽";s:2:"¹Ù";s:3:"夥";s:2:"¹Ú";s:3:"夢";s:2:"¹Û";s:3:"夤";s:2:"¹Ü";s:3:"奪";s:2:"¹Ý";s:3:"奩";s:2:"¹Þ";s:3:"å«¡";s:2:"¹ß";s:3:"嫦";s:2:"¹à";s:3:"å«©";s:2:"¹á";s:3:"å«—";s:2:"¹â";s:3:"å«–";s:2:"¹ã";s:3:"嫘";s:2:"¹ä";s:3:"å«£";s:2:"¹å";s:3:"å­µ";s:2:"¹æ";s:3:"寞";s:2:"¹ç";s:3:"寧";s:2:"¹è";s:3:"寡";s:2:"¹é";s:3:"寥";s:2:"¹ê";s:3:"實";s:2:"¹ë";s:3:"寨";s:2:"¹ì";s:3:"寢";s:2:"¹í";s:3:"寤";s:2:"¹î";s:3:"察";s:2:"¹ï";s:3:"å°";s:2:"¹ð";s:3:"å±¢";s:2:"¹ñ";s:3:"嶄";s:2:"¹ò";s:3:"嶇";s:2:"¹ó";s:3:"å¹›";s:2:"¹ô";s:3:"å¹£";s:2:"¹õ";s:3:"幕";s:2:"¹ö";s:3:"å¹—";s:2:"¹÷";s:3:"å¹”";s:2:"¹ø";s:3:"廓";s:2:"¹ù";s:3:"å»–";s:2:"¹ú";s:3:"弊";s:2:"¹û";s:3:"彆";s:2:"¹ü";s:3:"å½°";s:2:"¹ý";s:3:"å¾¹";s:2:"¹þ";s:3:"æ…‡";s:2:"º@";s:3:"æ„¿";s:2:"ºA";s:3:"æ…‹";s:2:"ºB";s:3:"æ…·";s:2:"ºC";s:3:"æ…¢";s:2:"ºD";s:3:"æ…£";s:2:"ºE";s:3:"æ…Ÿ";s:2:"ºF";s:3:"æ…š";s:2:"ºG";s:3:"æ…˜";s:2:"ºH";s:3:"æ…µ";s:2:"ºI";s:3:"截";s:2:"ºJ";s:3:"æ’‡";s:2:"ºK";s:3:"摘";s:2:"ºL";s:3:"æ‘”";s:2:"ºM";s:3:"æ’¤";s:2:"ºN";s:3:"摸";s:2:"ºO";s:3:"æ‘Ÿ";s:2:"ºP";s:3:"摺";s:2:"ºQ";s:3:"æ‘‘";s:2:"ºR";s:3:"摧";s:2:"ºS";s:3:"æ´";s:2:"ºT";s:3:"æ‘­";s:2:"ºU";s:3:"æ‘»";s:2:"ºV";s:3:"敲";s:2:"ºW";s:3:"æ–¡";s:2:"ºX";s:3:"æ——";s:2:"ºY";s:3:"æ—–";s:2:"ºZ";s:3:"暢";s:2:"º[";s:3:"暨";s:2:"º\";s:3:"æš";s:2:"º]";s:3:"榜";s:2:"º^";s:3:"榨";s:2:"º_";s:3:"榕";s:2:"º`";s:3:"æ§";s:2:"ºa";s:3:"榮";s:2:"ºb";s:3:"槓";s:2:"ºc";s:3:"構";s:2:"ºd";s:3:"榛";s:2:"ºe";s:3:"榷";s:2:"ºf";s:3:"榻";s:2:"ºg";s:3:"榫";s:2:"ºh";s:3:"榴";s:2:"ºi";s:3:"æ§";s:2:"ºj";s:3:"æ§";s:2:"ºk";s:3:"榭";s:2:"ºl";s:3:"槌";s:2:"ºm";s:3:"榦";s:2:"ºn";s:3:"槃";s:2:"ºo";s:3:"榣";s:2:"ºp";s:3:"æ­‰";s:2:"ºq";s:3:"æ­Œ";s:2:"ºr";s:3:"æ°³";s:2:"ºs";s:3:"æ¼³";s:2:"ºt";s:3:"æ¼”";s:2:"ºu";s:3:"滾";s:2:"ºv";s:3:"漓";s:2:"ºw";s:3:"æ»´";s:2:"ºx";s:3:"漩";s:2:"ºy";s:3:"æ¼¾";s:2:"ºz";s:3:"æ¼ ";s:2:"º{";s:3:"漬";s:2:"º|";s:3:"æ¼";s:2:"º}";s:3:"漂";s:2:"º~";s:3:"æ¼¢";s:2:"º¡";s:3:"滿";s:2:"º¢";s:3:"滯";s:2:"º£";s:3:"漆";s:2:"º¤";s:3:"æ¼±";s:2:"º¥";s:3:"漸";s:2:"º¦";s:3:"æ¼²";s:2:"º§";s:3:"æ¼£";s:2:"º¨";s:3:"漕";s:2:"º©";s:3:"漫";s:2:"ºª";s:3:"漯";s:2:"º«";s:3:"澈";s:2:"º¬";s:3:"漪";s:2:"º­";s:3:"滬";s:2:"º®";s:3:"æ¼";s:2:"º¯";s:3:"滲";s:2:"º°";s:3:"滌";s:2:"º±";s:3:"æ»·";s:2:"º²";s:3:"熔";s:2:"º³";s:3:"熙";s:2:"º´";s:3:"ç…½";s:2:"ºµ";s:3:"熊";s:2:"º¶";s:3:"熄";s:2:"º·";s:3:"熒";s:2:"º¸";s:3:"爾";s:2:"º¹";s:3:"犒";s:2:"ºº";s:3:"犖";s:2:"º»";s:3:"ç„";s:2:"º¼";s:3:"ç";s:2:"º½";s:3:"瑤";s:2:"º¾";s:3:"ç‘£";s:2:"º¿";s:3:"瑪";s:2:"ºÀ";s:3:"ç‘°";s:2:"ºÁ";s:3:"ç‘­";s:2:"ºÂ";s:3:"甄";s:2:"ºÃ";s:3:"ç–‘";s:2:"ºÄ";s:3:"瘧";s:2:"ºÅ";s:3:"ç˜";s:2:"ºÆ";s:3:"瘋";s:2:"ºÇ";s:3:"瘉";s:2:"ºÈ";s:3:"瘓";s:2:"ºÉ";s:3:"盡";s:2:"ºÊ";s:3:"監";s:2:"ºË";s:3:"çž„";s:2:"ºÌ";s:3:"ç½";s:2:"ºÍ";s:3:"ç¿";s:2:"ºÎ";s:3:"ç¡";s:2:"ºÏ";s:3:"ç£";s:2:"ºÐ";s:3:"碟";s:2:"ºÑ";s:3:"碧";s:2:"ºÒ";s:3:"碳";s:2:"ºÓ";s:3:"碩";s:2:"ºÔ";s:3:"碣";s:2:"ºÕ";s:3:"禎";s:2:"ºÖ";s:3:"ç¦";s:2:"º×";s:3:"ç¦";s:2:"ºØ";s:3:"種";s:2:"ºÙ";s:3:"稱";s:2:"ºÚ";s:3:"窪";s:2:"ºÛ";s:3:"窩";s:2:"ºÜ";s:3:"ç«­";s:2:"ºÝ";s:3:"端";s:2:"ºÞ";s:3:"管";s:2:"ºß";s:3:"箕";s:2:"ºà";s:3:"箋";s:2:"ºá";s:3:"ç­µ";s:2:"ºâ";s:3:"ç®—";s:2:"ºã";s:3:"ç®";s:2:"ºä";s:3:"ç®”";s:2:"ºå";s:3:"ç®";s:2:"ºæ";s:3:"箸";s:2:"ºç";s:3:"箇";s:2:"ºè";s:3:"箄";s:2:"ºé";s:3:"ç²¹";s:2:"ºê";s:3:"ç²½";s:2:"ºë";s:3:"ç²¾";s:2:"ºì";s:3:"綻";s:2:"ºí";s:3:"綰";s:2:"ºî";s:3:"綜";s:2:"ºï";s:3:"綽";s:2:"ºð";s:3:"綾";s:2:"ºñ";s:3:"綠";s:2:"ºò";s:3:"ç·Š";s:2:"ºó";s:3:"綴";s:2:"ºô";s:3:"網";s:2:"ºõ";s:3:"綱";s:2:"ºö";s:3:"綺";s:2:"º÷";s:3:"綢";s:2:"ºø";s:3:"綿";s:2:"ºù";s:3:"綵";s:2:"ºú";s:3:"綸";s:2:"ºû";s:3:"維";s:2:"ºü";s:3:"ç·’";s:2:"ºý";s:3:"ç·‡";s:2:"ºþ";s:3:"綬";s:2:"»@";s:3:"ç½°";s:2:"»A";s:3:"ç¿ ";s:2:"»B";s:3:"ç¿¡";s:2:"»C";s:3:"ç¿Ÿ";s:2:"»D";s:3:"èž";s:2:"»E";s:3:"èš";s:2:"»F";s:3:"肇";s:2:"»G";s:3:"è…";s:2:"»H";s:3:"膀";s:2:"»I";s:3:"è†";s:2:"»J";s:3:"膈";s:2:"»K";s:3:"膊";s:2:"»L";s:3:"è…¿";s:2:"»M";s:3:"膂";s:2:"»N";s:3:"臧";s:2:"»O";s:3:"臺";s:2:"»P";s:3:"與";s:2:"»Q";s:3:"舔";s:2:"»R";s:3:"舞";s:2:"»S";s:3:"艋";s:2:"»T";s:3:"蓉";s:2:"»U";s:3:"è’¿";s:2:"»V";s:3:"蓆";s:2:"»W";s:3:"è“„";s:2:"»X";s:3:"è’™";s:2:"»Y";s:3:"è’ž";s:2:"»Z";s:3:"è’²";s:2:"»[";s:3:"è’œ";s:2:"»\";s:3:"è“‹";s:2:"»]";s:3:"è’¸";s:2:"»^";s:3:"è“€";s:2:"»_";s:3:"è““";s:2:"»`";s:3:"è’";s:2:"»a";s:3:"è’¼";s:2:"»b";s:3:"è“‘";s:2:"»c";s:3:"è“Š";s:2:"»d";s:3:"蜿";s:2:"»e";s:3:"蜜";s:2:"»f";s:3:"蜻";s:2:"»g";s:3:"蜢";s:2:"»h";s:3:"蜥";s:2:"»i";s:3:"蜴";s:2:"»j";s:3:"蜘";s:2:"»k";s:3:"è•";s:2:"»l";s:3:"蜷";s:2:"»m";s:3:"蜩";s:2:"»n";s:3:"裳";s:2:"»o";s:3:"褂";s:2:"»p";s:3:"裴";s:2:"»q";s:3:"裹";s:2:"»r";s:3:"裸";s:2:"»s";s:3:"製";s:2:"»t";s:3:"裨";s:2:"»u";s:3:"褚";s:2:"»v";s:3:"裯";s:2:"»w";s:3:"誦";s:2:"»x";s:3:"誌";s:2:"»y";s:3:"語";s:2:"»z";s:3:"誣";s:2:"»{";s:3:"èª";s:2:"»|";s:3:"誡";s:2:"»}";s:3:"誓";s:2:"»~";s:3:"誤";s:2:"»¡";s:3:"說";s:2:"»¢";s:3:"誥";s:2:"»£";s:3:"誨";s:2:"»¤";s:3:"誘";s:2:"»¥";s:3:"誑";s:2:"»¦";s:3:"誚";s:2:"»§";s:3:"誧";s:2:"»¨";s:3:"豪";s:2:"»©";s:3:"è²";s:2:"»ª";s:3:"貌";s:2:"»«";s:3:"賓";s:2:"»¬";s:3:"賑";s:2:"»­";s:3:"è³’";s:2:"»®";s:3:"赫";s:2:"»¯";s:3:"趙";s:2:"»°";s:3:"趕";s:2:"»±";s:3:"è·¼";s:2:"»²";s:3:"è¼”";s:2:"»³";s:3:"è¼’";s:2:"»´";s:3:"輕";s:2:"»µ";s:3:"輓";s:2:"»¶";s:3:"è¾£";s:2:"»·";s:3:"é ";s:2:"»¸";s:3:"é˜";s:2:"»¹";s:3:"éœ";s:2:"»º";s:3:"é£";s:2:"»»";s:3:"é™";s:2:"»¼";s:3:"éž";s:2:"»½";s:3:"é¢";s:2:"»¾";s:3:"é";s:2:"»¿";s:3:"é›";s:2:"»À";s:3:"é„™";s:2:"»Á";s:3:"鄘";s:2:"»Â";s:3:"é„ž";s:2:"»Ã";s:3:"é…µ";s:2:"»Ä";s:3:"é…¸";s:2:"»Å";s:3:"é…·";s:2:"»Æ";s:3:"é…´";s:2:"»Ç";s:3:"鉸";s:2:"»È";s:3:"銀";s:2:"»É";s:3:"銅";s:2:"»Ê";s:3:"銘";s:2:"»Ë";s:3:"銖";s:2:"»Ì";s:3:"鉻";s:2:"»Í";s:3:"銓";s:2:"»Î";s:3:"銜";s:2:"»Ï";s:3:"銨";s:2:"»Ð";s:3:"鉼";s:2:"»Ñ";s:3:"銑";s:2:"»Ò";s:3:"é–¡";s:2:"»Ó";s:3:"é–¨";s:2:"»Ô";s:3:"é–©";s:2:"»Õ";s:3:"é–£";s:2:"»Ö";s:3:"é–¥";s:2:"»×";s:3:"é–¤";s:2:"»Ø";s:3:"éš™";s:2:"»Ù";s:3:"éšœ";s:2:"»Ú";s:3:"éš›";s:2:"»Û";s:3:"雌";s:2:"»Ü";s:3:"é›’";s:2:"»Ý";s:3:"需";s:2:"»Þ";s:3:"é¼";s:2:"»ß";s:3:"éž…";s:2:"»à";s:3:"韶";s:2:"»á";s:3:"é —";s:2:"»â";s:3:"é ˜";s:2:"»ã";s:3:"颯";s:2:"»ä";s:3:"颱";s:2:"»å";s:3:"餃";s:2:"»æ";s:3:"餅";s:2:"»ç";s:3:"餌";s:2:"»è";s:3:"餉";s:2:"»é";s:3:"é§";s:2:"»ê";s:3:"骯";s:2:"»ë";s:3:"骰";s:2:"»ì";s:3:"髦";s:2:"»í";s:3:"é­";s:2:"»î";s:3:"é­‚";s:2:"»ï";s:3:"é³´";s:2:"»ð";s:3:"鳶";s:2:"»ñ";s:3:"é³³";s:2:"»ò";s:3:"麼";s:2:"»ó";s:3:"é¼»";s:2:"»ô";s:3:"齊";s:2:"»õ";s:3:"å„„";s:2:"»ö";s:3:"å„€";s:2:"»÷";s:3:"僻";s:2:"»ø";s:3:"僵";s:2:"»ù";s:3:"價";s:2:"»ú";s:3:"å„‚";s:2:"»û";s:3:"儈";s:2:"»ü";s:3:"儉";s:2:"»ý";s:3:"å„…";s:2:"»þ";s:3:"凜";s:2:"¼@";s:3:"劇";s:2:"¼A";s:3:"劈";s:2:"¼B";s:3:"劉";s:2:"¼C";s:3:"åŠ";s:2:"¼D";s:3:"劊";s:2:"¼E";s:3:"å‹°";s:2:"¼F";s:3:"厲";s:2:"¼G";s:3:"嘮";s:2:"¼H";s:3:"嘻";s:2:"¼I";s:3:"嘹";s:2:"¼J";s:3:"嘲";s:2:"¼K";s:3:"嘿";s:2:"¼L";s:3:"嘴";s:2:"¼M";s:3:"嘩";s:2:"¼N";s:3:"噓";s:2:"¼O";s:3:"噎";s:2:"¼P";s:3:"å™—";s:2:"¼Q";s:3:"å™´";s:2:"¼R";s:3:"嘶";s:2:"¼S";s:3:"嘯";s:2:"¼T";s:3:"嘰";s:2:"¼U";s:3:"墀";s:2:"¼V";s:3:"墟";s:2:"¼W";s:3:"增";s:2:"¼X";s:3:"墳";s:2:"¼Y";s:3:"墜";s:2:"¼Z";s:3:"墮";s:2:"¼[";s:3:"墩";s:2:"¼\";s:3:"墦";s:2:"¼]";s:3:"奭";s:2:"¼^";s:3:"嬉";s:2:"¼_";s:3:"å«»";s:2:"¼`";s:3:"嬋";s:2:"¼a";s:3:"嫵";s:2:"¼b";s:3:"嬌";s:2:"¼c";s:3:"嬈";s:2:"¼d";s:3:"寮";s:2:"¼e";s:3:"寬";s:2:"¼f";s:3:"審";s:2:"¼g";s:3:"寫";s:2:"¼h";s:3:"層";s:2:"¼i";s:3:"å±¥";s:2:"¼j";s:3:"å¶";s:2:"¼k";s:3:"嶔";s:2:"¼l";s:3:"å¹¢";s:2:"¼m";s:3:"幟";s:2:"¼n";s:3:"幡";s:2:"¼o";s:3:"廢";s:2:"¼p";s:3:"廚";s:2:"¼q";s:3:"廟";s:2:"¼r";s:3:"å»";s:2:"¼s";s:3:"廣";s:2:"¼t";s:3:"å» ";s:2:"¼u";s:3:"彈";s:2:"¼v";s:3:"å½±";s:2:"¼w";s:3:"å¾·";s:2:"¼x";s:3:"å¾µ";s:2:"¼y";s:3:"æ…¶";s:2:"¼z";s:3:"æ…§";s:2:"¼{";s:3:"æ…®";s:2:"¼|";s:3:"æ…";s:2:"¼}";s:3:"æ…•";s:2:"¼~";s:3:"憂";s:2:"¼¡";s:3:"æ…¼";s:2:"¼¢";s:3:"æ…°";s:2:"¼£";s:3:"æ…«";s:2:"¼¤";s:3:"æ…¾";s:2:"¼¥";s:3:"憧";s:2:"¼¦";s:3:"æ†";s:2:"¼§";s:3:"憫";s:2:"¼¨";s:3:"憎";s:2:"¼©";s:3:"憬";s:2:"¼ª";s:3:"憚";s:2:"¼«";s:3:"憤";s:2:"¼¬";s:3:"憔";s:2:"¼­";s:3:"憮";s:2:"¼®";s:3:"戮";s:2:"¼¯";s:3:"æ‘©";s:2:"¼°";s:3:"摯";s:2:"¼±";s:3:"摹";s:2:"¼²";s:3:"æ’ž";s:2:"¼³";s:3:"æ’²";s:2:"¼´";s:3:"æ’ˆ";s:2:"¼µ";s:3:"æ’";s:2:"¼¶";s:3:"æ’°";s:2:"¼·";s:3:"æ’¥";s:2:"¼¸";s:3:"æ’“";s:2:"¼¹";s:3:"æ’•";s:2:"¼º";s:3:"æ’©";s:2:"¼»";s:3:"æ’’";s:2:"¼¼";s:3:"æ’®";s:2:"¼½";s:3:"æ’­";s:2:"¼¾";s:3:"æ’«";s:2:"¼¿";s:3:"æ’š";s:2:"¼À";s:3:"æ’¬";s:2:"¼Á";s:3:"æ’™";s:2:"¼Â";s:3:"æ’¢";s:2:"¼Ã";s:3:"æ’³";s:2:"¼Ä";s:3:"敵";s:2:"¼Å";s:3:"æ•·";s:2:"¼Æ";s:3:"數";s:2:"¼Ç";s:3:"æš®";s:2:"¼È";s:3:"æš«";s:2:"¼É";s:3:"æš´";s:2:"¼Ê";s:3:"æš±";s:2:"¼Ë";s:3:"樣";s:2:"¼Ì";s:3:"樟";s:2:"¼Í";s:3:"槨";s:2:"¼Î";s:3:"æ¨";s:2:"¼Ï";s:3:"樞";s:2:"¼Ð";s:3:"標";s:2:"¼Ñ";s:3:"槽";s:2:"¼Ò";s:3:"模";s:2:"¼Ó";s:3:"樓";s:2:"¼Ô";s:3:"樊";s:2:"¼Õ";s:3:"槳";s:2:"¼Ö";s:3:"樂";s:2:"¼×";s:3:"樅";s:2:"¼Ø";s:3:"槭";s:2:"¼Ù";s:3:"樑";s:2:"¼Ú";s:3:"æ­";s:2:"¼Û";s:3:"æ­Ž";s:2:"¼Ü";s:3:"殤";s:2:"¼Ý";s:3:"毅";s:2:"¼Þ";s:3:"毆";s:2:"¼ß";s:3:"漿";s:2:"¼à";s:3:"æ½¼";s:2:"¼á";s:3:"澄";s:2:"¼â";s:3:"潑";s:2:"¼ã";s:3:"潦";s:2:"¼ä";s:3:"æ½”";s:2:"¼å";s:3:"澆";s:2:"¼æ";s:3:"æ½­";s:2:"¼ç";s:3:"æ½›";s:2:"¼è";s:3:"潸";s:2:"¼é";s:3:"æ½®";s:2:"¼ê";s:3:"澎";s:2:"¼ë";s:3:"潺";s:2:"¼ì";s:3:"æ½°";s:2:"¼í";s:3:"潤";s:2:"¼î";s:3:"æ¾—";s:2:"¼ï";s:3:"潘";s:2:"¼ð";s:3:"滕";s:2:"¼ñ";s:3:"潯";s:2:"¼ò";s:3:"æ½ ";s:2:"¼ó";s:3:"潟";s:2:"¼ô";s:3:"熟";s:2:"¼õ";s:3:"熬";s:2:"¼ö";s:3:"熱";s:2:"¼÷";s:3:"熨";s:2:"¼ø";s:3:"牖";s:2:"¼ù";s:3:"犛";s:2:"¼ú";s:3:"çŽ";s:2:"¼û";s:3:"ç—";s:2:"¼ü";s:3:"ç‘©";s:2:"¼ý";s:3:"ç’‹";s:2:"¼þ";s:3:"ç’ƒ";s:2:"½@";s:3:"瑾";s:2:"½A";s:3:"ç’€";s:2:"½B";s:3:"ç•¿";s:2:"½C";s:3:"瘠";s:2:"½D";s:3:"瘩";s:2:"½E";s:3:"瘟";s:2:"½F";s:3:"瘤";s:2:"½G";s:3:"瘦";s:2:"½H";s:3:"瘡";s:2:"½I";s:3:"瘢";s:2:"½J";s:3:"çšš";s:2:"½K";s:3:"皺";s:2:"½L";s:3:"盤";s:2:"½M";s:3:"瞎";s:2:"½N";s:3:"瞇";s:2:"½O";s:3:"瞌";s:2:"½P";s:3:"çž‘";s:2:"½Q";s:3:"çž‹";s:2:"½R";s:3:"磋";s:2:"½S";s:3:"磅";s:2:"½T";s:3:"確";s:2:"½U";s:3:"磊";s:2:"½V";s:3:"碾";s:2:"½W";s:3:"磕";s:2:"½X";s:3:"碼";s:2:"½Y";s:3:"ç£";s:2:"½Z";s:3:"稿";s:2:"½[";s:3:"稼";s:2:"½\";s:3:"ç©€";s:2:"½]";s:3:"稽";s:2:"½^";s:3:"稷";s:2:"½_";s:3:"稻";s:2:"½`";s:3:"窯";s:2:"½a";s:3:"窮";s:2:"½b";s:3:"ç®­";s:2:"½c";s:3:"ç®±";s:2:"½d";s:3:"範";s:2:"½e";s:3:"ç®´";s:2:"½f";s:3:"篆";s:2:"½g";s:3:"篇";s:2:"½h";s:3:"ç¯";s:2:"½i";s:3:"ç® ";s:2:"½j";s:3:"篌";s:2:"½k";s:3:"糊";s:2:"½l";s:3:"ç· ";s:2:"½m";s:3:"ç·´";s:2:"½n";s:3:"ç·¯";s:2:"½o";s:3:"ç·»";s:2:"½p";s:3:"ç·˜";s:2:"½q";s:3:"ç·¬";s:2:"½r";s:3:"ç·";s:2:"½s";s:3:"ç·¨";s:2:"½t";s:3:"ç·£";s:2:"½u";s:3:"ç·š";s:2:"½v";s:3:"ç·ž";s:2:"½w";s:3:"ç·©";s:2:"½x";s:3:"綞";s:2:"½y";s:3:"ç·™";s:2:"½z";s:3:"ç·²";s:2:"½{";s:3:"ç·¹";s:2:"½|";s:3:"ç½µ";s:2:"½}";s:3:"ç½·";s:2:"½~";s:3:"羯";s:2:"½¡";s:3:"ç¿©";s:2:"½¢";s:3:"耦";s:2:"½£";s:3:"膛";s:2:"½¤";s:3:"膜";s:2:"½¥";s:3:"è†";s:2:"½¦";s:3:"膠";s:2:"½§";s:3:"膚";s:2:"½¨";s:3:"膘";s:2:"½©";s:3:"è”—";s:2:"½ª";s:3:"蔽";s:2:"½«";s:3:"蔚";s:2:"½¬";s:3:"è“®";s:2:"½­";s:3:"蔬";s:2:"½®";s:3:"è”­";s:2:"½¯";s:3:"蔓";s:2:"½°";s:3:"蔑";s:2:"½±";s:3:"蔣";s:2:"½²";s:3:"蔡";s:2:"½³";s:3:"è””";s:2:"½´";s:3:"蓬";s:2:"½µ";s:3:"蔥";s:2:"½¶";s:3:"è“¿";s:2:"½·";s:3:"蔆";s:2:"½¸";s:3:"èž‚";s:2:"½¹";s:3:"è´";s:2:"½º";s:3:"è¶";s:2:"½»";s:3:"è ";s:2:"½¼";s:3:"è¦";s:2:"½½";s:3:"è¸";s:2:"½¾";s:3:"è¨";s:2:"½¿";s:3:"è™";s:2:"½À";s:3:"è—";s:2:"½Á";s:3:"èŒ";s:2:"½Â";s:3:"è“";s:2:"½Ã";s:3:"è¡›";s:2:"½Ä";s:3:"è¡";s:2:"½Å";s:3:"è¤";s:2:"½Æ";s:3:"複";s:2:"½Ç";s:3:"褒";s:2:"½È";s:3:"褓";s:2:"½É";s:3:"褕";s:2:"½Ê";s:3:"褊";s:2:"½Ë";s:3:"誼";s:2:"½Ì";s:3:"è«’";s:2:"½Í";s:3:"談";s:2:"½Î";s:3:"è«„";s:2:"½Ï";s:3:"誕";s:2:"½Ð";s:3:"è«‹";s:2:"½Ñ";s:3:"諸";s:2:"½Ò";s:3:"課";s:2:"½Ó";s:3:"諉";s:2:"½Ô";s:3:"è«‚";s:2:"½Õ";s:3:"調";s:2:"½Ö";s:3:"誰";s:2:"½×";s:3:"è«–";s:2:"½Ø";s:3:"è«";s:2:"½Ù";s:3:"誶";s:2:"½Ú";s:3:"誹";s:2:"½Û";s:3:"è«›";s:2:"½Ü";s:3:"豌";s:2:"½Ý";s:3:"豎";s:2:"½Þ";s:3:"豬";s:2:"½ß";s:3:"è³ ";s:2:"½à";s:3:"賞";s:2:"½á";s:3:"賦";s:2:"½â";s:3:"賤";s:2:"½ã";s:3:"賬";s:2:"½ä";s:3:"è³­";s:2:"½å";s:3:"è³¢";s:2:"½æ";s:3:"è³£";s:2:"½ç";s:3:"賜";s:2:"½è";s:3:"質";s:2:"½é";s:3:"賡";s:2:"½ê";s:3:"èµ­";s:2:"½ë";s:3:"趟";s:2:"½ì";s:3:"趣";s:2:"½í";s:3:"踫";s:2:"½î";s:3:"è¸";s:2:"½ï";s:3:"è¸";s:2:"½ð";s:3:"踢";s:2:"½ñ";s:3:"è¸";s:2:"½ò";s:3:"踩";s:2:"½ó";s:3:"踟";s:2:"½ô";s:3:"踡";s:2:"½õ";s:3:"踞";s:2:"½ö";s:3:"躺";s:2:"½÷";s:3:"è¼";s:2:"½ø";s:3:"è¼›";s:2:"½ù";s:3:"輟";s:2:"½ú";s:3:"輩";s:2:"½û";s:3:"輦";s:2:"½ü";s:3:"輪";s:2:"½ý";s:3:"輜";s:2:"½þ";s:3:"輞";s:2:"¾@";s:3:"è¼¥";s:2:"¾A";s:3:"é©";s:2:"¾B";s:3:"é®";s:2:"¾C";s:3:"é¨";s:2:"¾D";s:3:"é­";s:2:"¾E";s:3:"é·";s:2:"¾F";s:3:"é„°";s:2:"¾G";s:3:"é„­";s:2:"¾H";s:3:"鄧";s:2:"¾I";s:3:"鄱";s:2:"¾J";s:3:"醇";s:2:"¾K";s:3:"醉";s:2:"¾L";s:3:"醋";s:2:"¾M";s:3:"醃";s:2:"¾N";s:3:"é‹…";s:2:"¾O";s:3:"銻";s:2:"¾P";s:3:"銷";s:2:"¾Q";s:3:"鋪";s:2:"¾R";s:3:"銬";s:2:"¾S";s:3:"鋤";s:2:"¾T";s:3:"é‹";s:2:"¾U";s:3:"銳";s:2:"¾V";s:3:"銼";s:2:"¾W";s:3:"é‹’";s:2:"¾X";s:3:"鋇";s:2:"¾Y";s:3:"é‹°";s:2:"¾Z";s:3:"銲";s:2:"¾[";s:3:"é–­";s:2:"¾\";s:3:"é–±";s:2:"¾]";s:3:"霄";s:2:"¾^";s:3:"霆";s:2:"¾_";s:3:"震";s:2:"¾`";s:3:"霉";s:2:"¾a";s:3:"é ";s:2:"¾b";s:3:"éž";s:2:"¾c";s:3:"éž‹";s:2:"¾d";s:3:"éž";s:2:"¾e";s:3:"é ¡";s:2:"¾f";s:3:"é «";s:2:"¾g";s:3:"é œ";s:2:"¾h";s:3:"颳";s:2:"¾i";s:3:"養";s:2:"¾j";s:3:"餓";s:2:"¾k";s:3:"餒";s:2:"¾l";s:3:"餘";s:2:"¾m";s:3:"é§";s:2:"¾n";s:3:"é§";s:2:"¾o";s:3:"駟";s:2:"¾p";s:3:"駛";s:2:"¾q";s:3:"駑";s:2:"¾r";s:3:"駕";s:2:"¾s";s:3:"駒";s:2:"¾t";s:3:"駙";s:2:"¾u";s:3:"骷";s:2:"¾v";s:3:"é«®";s:2:"¾w";s:3:"髯";s:2:"¾x";s:3:"鬧";s:2:"¾y";s:3:"é­…";s:2:"¾z";s:3:"é­„";s:2:"¾{";s:3:"é­·";s:2:"¾|";s:3:"é­¯";s:2:"¾}";s:3:"é´†";s:2:"¾~";s:3:"é´‰";s:2:"¾¡";s:3:"é´ƒ";s:2:"¾¢";s:3:"麩";s:2:"¾£";s:3:"麾";s:2:"¾¤";s:3:"黎";s:2:"¾¥";s:3:"墨";s:2:"¾¦";s:3:"é½’";s:2:"¾§";s:3:"å„’";s:2:"¾¨";s:3:"儘";s:2:"¾©";s:3:"å„”";s:2:"¾ª";s:3:"å„";s:2:"¾«";s:3:"å„•";s:2:"¾¬";s:3:"冀";s:2:"¾­";s:3:"冪";s:2:"¾®";s:3:"å‡";s:2:"¾¯";s:3:"劑";s:2:"¾°";s:3:"劓";s:2:"¾±";s:3:"勳";s:2:"¾²";s:3:"å™™";s:2:"¾³";s:3:"噫";s:2:"¾´";s:3:"噹";s:2:"¾µ";s:3:"噩";s:2:"¾¶";s:3:"噤";s:2:"¾·";s:3:"噸";s:2:"¾¸";s:3:"噪";s:2:"¾¹";s:3:"器";s:2:"¾º";s:3:"噥";s:2:"¾»";s:3:"å™±";s:2:"¾¼";s:3:"噯";s:2:"¾½";s:3:"噬";s:2:"¾¾";s:3:"噢";s:2:"¾¿";s:3:"噶";s:2:"¾À";s:3:"å£";s:2:"¾Á";s:3:"墾";s:2:"¾Â";s:3:"壇";s:2:"¾Ã";s:3:"壅";s:2:"¾Ä";s:3:"奮";s:2:"¾Å";s:3:"å¬";s:2:"¾Æ";s:3:"嬴";s:2:"¾Ç";s:3:"å­¸";s:2:"¾È";s:3:"寰";s:2:"¾É";s:3:"å°Ž";s:2:"¾Ê";s:3:"彊";s:2:"¾Ë";s:3:"憲";s:2:"¾Ì";s:3:"憑";s:2:"¾Í";s:3:"憩";s:2:"¾Î";s:3:"憊";s:2:"¾Ï";s:3:"æ‡";s:2:"¾Ð";s:3:"憶";s:2:"¾Ñ";s:3:"憾";s:2:"¾Ò";s:3:"懊";s:2:"¾Ó";s:3:"懈";s:2:"¾Ô";s:3:"戰";s:2:"¾Õ";s:3:"æ“…";s:2:"¾Ö";s:3:"æ“";s:2:"¾×";s:3:"æ“‹";s:2:"¾Ø";s:3:"æ’»";s:2:"¾Ù";s:3:"æ’¼";s:2:"¾Ú";s:3:"æ“š";s:2:"¾Û";s:3:"æ“„";s:2:"¾Ü";s:3:"擇";s:2:"¾Ý";s:3:"æ“‚";s:2:"¾Þ";s:3:"æ“";s:2:"¾ß";s:3:"æ’¿";s:2:"¾à";s:3:"æ“’";s:2:"¾á";s:3:"æ“”";s:2:"¾â";s:3:"æ’¾";s:2:"¾ã";s:3:"æ•´";s:2:"¾ä";s:3:"曆";s:2:"¾å";s:3:"曉";s:2:"¾æ";s:3:"æš¹";s:2:"¾ç";s:3:"曄";s:2:"¾è";s:3:"曇";s:2:"¾é";s:3:"暸";s:2:"¾ê";s:3:"樽";s:2:"¾ë";s:3:"樸";s:2:"¾ì";s:3:"樺";s:2:"¾í";s:3:"æ©™";s:2:"¾î";s:3:"æ©«";s:2:"¾ï";s:3:"橘";s:2:"¾ð";s:3:"樹";s:2:"¾ñ";s:3:"æ©„";s:2:"¾ò";s:3:"æ©¢";s:2:"¾ó";s:3:"æ©¡";s:2:"¾ô";s:3:"æ©‹";s:2:"¾õ";s:3:"橇";s:2:"¾ö";s:3:"樵";s:2:"¾÷";s:3:"æ©Ÿ";s:2:"¾ø";s:3:"橈";s:2:"¾ù";s:3:"æ­™";s:2:"¾ú";s:3:"æ­·";s:2:"¾û";s:3:"æ°…";s:2:"¾ü";s:3:"æ¿‚";s:2:"¾ý";s:3:"æ¾±";s:2:"¾þ";s:3:"澡";s:2:"¿@";s:3:"濃";s:2:"¿A";s:3:"澤";s:2:"¿B";s:3:"æ¿";s:2:"¿C";s:3:"澧";s:2:"¿D";s:3:"æ¾³";s:2:"¿E";s:3:"æ¿€";s:2:"¿F";s:3:"æ¾¹";s:2:"¿G";s:3:"澶";s:2:"¿H";s:3:"澦";s:2:"¿I";s:3:"æ¾ ";s:2:"¿J";s:3:"æ¾´";s:2:"¿K";s:3:"熾";s:2:"¿L";s:3:"燉";s:2:"¿M";s:3:"ç‡";s:2:"¿N";s:3:"燒";s:2:"¿O";s:3:"燈";s:2:"¿P";s:3:"燕";s:2:"¿Q";s:3:"熹";s:2:"¿R";s:3:"燎";s:2:"¿S";s:3:"燙";s:2:"¿T";s:3:"燜";s:2:"¿U";s:3:"燃";s:2:"¿V";s:3:"燄";s:2:"¿W";s:3:"ç¨";s:2:"¿X";s:3:"ç’œ";s:2:"¿Y";s:3:"ç’£";s:2:"¿Z";s:3:"ç’˜";s:2:"¿[";s:3:"ç’Ÿ";s:2:"¿\";s:3:"ç’ž";s:2:"¿]";s:3:"ç“¢";s:2:"¿^";s:3:"甌";s:2:"¿_";s:3:"ç”";s:2:"¿`";s:3:"瘴";s:2:"¿a";s:3:"瘸";s:2:"¿b";s:3:"瘺";s:2:"¿c";s:3:"盧";s:2:"¿d";s:3:"盥";s:2:"¿e";s:3:"çž ";s:2:"¿f";s:3:"çžž";s:2:"¿g";s:3:"瞟";s:2:"¿h";s:3:"瞥";s:2:"¿i";s:3:"磨";s:2:"¿j";s:3:"磚";s:2:"¿k";s:3:"磬";s:2:"¿l";s:3:"磧";s:2:"¿m";s:3:"禦";s:2:"¿n";s:3:"ç©";s:2:"¿o";s:3:"ç©Ž";s:2:"¿p";s:3:"穆";s:2:"¿q";s:3:"ç©Œ";s:2:"¿r";s:3:"ç©‹";s:2:"¿s";s:3:"窺";s:2:"¿t";s:3:"篙";s:2:"¿u";s:3:"ç°‘";s:2:"¿v";s:3:"築";s:2:"¿w";s:3:"篤";s:2:"¿x";s:3:"篛";s:2:"¿y";s:3:"篡";s:2:"¿z";s:3:"篩";s:2:"¿{";s:3:"篦";s:2:"¿|";s:3:"糕";s:2:"¿}";s:3:"ç³–";s:2:"¿~";s:3:"縊";s:2:"¿¡";s:3:"縑";s:2:"¿¢";s:3:"縈";s:2:"¿£";s:3:"縛";s:2:"¿¤";s:3:"縣";s:2:"¿¥";s:3:"縞";s:2:"¿¦";s:3:"ç¸";s:2:"¿§";s:3:"縉";s:2:"¿¨";s:3:"ç¸";s:2:"¿©";s:3:"ç½¹";s:2:"¿ª";s:3:"ç¾²";s:2:"¿«";s:3:"ç¿°";s:2:"¿¬";s:3:"翱";s:2:"¿­";s:3:"ç¿®";s:2:"¿®";s:3:"耨";s:2:"¿¯";s:3:"膳";s:2:"¿°";s:3:"膩";s:2:"¿±";s:3:"膨";s:2:"¿²";s:3:"臻";s:2:"¿³";s:3:"興";s:2:"¿´";s:3:"艘";s:2:"¿µ";s:3:"艙";s:2:"¿¶";s:3:"è•Š";s:2:"¿·";s:3:"è•™";s:2:"¿¸";s:3:"蕈";s:2:"¿¹";s:3:"蕨";s:2:"¿º";s:3:"è•©";s:2:"¿»";s:3:"蕃";s:2:"¿¼";s:3:"蕉";s:2:"¿½";s:3:"è•­";s:2:"¿¾";s:3:"蕪";s:2:"¿¿";s:3:"è•ž";s:2:"¿À";s:3:"螃";s:2:"¿Á";s:3:"螟";s:2:"¿Â";s:3:"èžž";s:2:"¿Ã";s:3:"螢";s:2:"¿Ä";s:3:"èž";s:2:"¿Å";s:3:"è¡¡";s:2:"¿Æ";s:3:"褪";s:2:"¿Ç";s:3:"褲";s:2:"¿È";s:3:"褥";s:2:"¿É";s:3:"褫";s:2:"¿Ê";s:3:"褡";s:2:"¿Ë";s:3:"親";s:2:"¿Ì";s:3:"覦";s:2:"¿Í";s:3:"諦";s:2:"¿Î";s:3:"諺";s:2:"¿Ï";s:3:"è««";s:2:"¿Ð";s:3:"諱";s:2:"¿Ñ";s:3:"謀";s:2:"¿Ò";s:3:"è«œ";s:2:"¿Ó";s:3:"諧";s:2:"¿Ô";s:3:"è«®";s:2:"¿Õ";s:3:"諾";s:2:"¿Ö";s:3:"è¬";s:2:"¿×";s:3:"謂";s:2:"¿Ø";s:3:"è«·";s:2:"¿Ù";s:3:"è«­";s:2:"¿Ú";s:3:"諳";s:2:"¿Û";s:3:"諶";s:2:"¿Ü";s:3:"諼";s:2:"¿Ý";s:3:"豫";s:2:"¿Þ";s:3:"è±­";s:2:"¿ß";s:3:"貓";s:2:"¿à";s:3:"è³´";s:2:"¿á";s:3:"蹄";s:2:"¿â";s:3:"踱";s:2:"¿ã";s:3:"踴";s:2:"¿ä";s:3:"蹂";s:2:"¿å";s:3:"踹";s:2:"¿æ";s:3:"踵";s:2:"¿ç";s:3:"è¼»";s:2:"¿è";s:3:"輯";s:2:"¿é";s:3:"輸";s:2:"¿ê";s:3:"è¼³";s:2:"¿ë";s:3:"辨";s:2:"¿ì";s:3:"辦";s:2:"¿í";s:3:"éµ";s:2:"¿î";s:3:"é´";s:2:"¿ï";s:3:"é¸";s:2:"¿ð";s:3:"é²";s:2:"¿ñ";s:3:"é¼";s:2:"¿ò";s:3:"éº";s:2:"¿ó";s:3:"é„´";s:2:"¿ô";s:3:"醒";s:2:"¿õ";s:3:"錠";s:2:"¿ö";s:3:"錶";s:2:"¿÷";s:3:"鋸";s:2:"¿ø";s:3:"錳";s:2:"¿ù";s:3:"錯";s:2:"¿ú";s:3:"錢";s:2:"¿û";s:3:"鋼";s:2:"¿ü";s:3:"錫";s:2:"¿ý";s:3:"錄";s:2:"¿þ";s:3:"錚";s:2:"À@";s:3:"éŒ";s:2:"ÀA";s:3:"錦";s:2:"ÀB";s:3:"錡";s:2:"ÀC";s:3:"錕";s:2:"ÀD";s:3:"錮";s:2:"ÀE";s:3:"錙";s:2:"ÀF";s:3:"é–»";s:2:"ÀG";s:3:"隧";s:2:"ÀH";s:3:"隨";s:2:"ÀI";s:3:"險";s:2:"ÀJ";s:3:"雕";s:2:"ÀK";s:3:"霎";s:2:"ÀL";s:3:"霑";s:2:"ÀM";s:3:"霖";s:2:"ÀN";s:3:"éœ";s:2:"ÀO";s:3:"霓";s:2:"ÀP";s:3:"éœ";s:2:"ÀQ";s:3:"é›";s:2:"ÀR";s:3:"éœ";s:2:"ÀS";s:3:"é¦";s:2:"ÀT";s:3:"鞘";s:2:"ÀU";s:3:"é °";s:2:"ÀV";s:3:"é ¸";s:2:"ÀW";s:3:"é »";s:2:"ÀX";s:3:"é ·";s:2:"ÀY";s:3:"é ­";s:2:"ÀZ";s:3:"é ¹";s:2:"À[";s:3:"é ¤";s:2:"À\";s:3:"é¤";s:2:"À]";s:3:"館";s:2:"À^";s:3:"餞";s:2:"À_";s:3:"餛";s:2:"À`";s:3:"餡";s:2:"Àa";s:3:"餚";s:2:"Àb";s:3:"駭";s:2:"Àc";s:3:"駢";s:2:"Àd";s:3:"駱";s:2:"Àe";s:3:"骸";s:2:"Àf";s:3:"骼";s:2:"Àg";s:3:"é«»";s:2:"Àh";s:3:"é«­";s:2:"Ài";s:3:"鬨";s:2:"Àj";s:3:"鮑";s:2:"Àk";s:3:"é´•";s:2:"Àl";s:3:"é´£";s:2:"Àm";s:3:"é´¦";s:2:"Àn";s:3:"é´¨";s:2:"Ào";s:3:"é´’";s:2:"Àp";s:3:"é´›";s:2:"Àq";s:3:"默";s:2:"Àr";s:3:"é»”";s:2:"Às";s:3:"é¾";s:2:"Àt";s:3:"龜";s:2:"Àu";s:3:"優";s:2:"Àv";s:3:"å„Ÿ";s:2:"Àw";s:3:"å„¡";s:2:"Àx";s:3:"儲";s:2:"Ày";s:3:"勵";s:2:"Àz";s:3:"嚎";s:2:"À{";s:3:"嚀";s:2:"À|";s:3:"åš";s:2:"À}";s:3:"åš…";s:2:"À~";s:3:"嚇";s:2:"À¡";s:3:"åš";s:2:"À¢";s:3:"壕";s:2:"À£";s:3:"壓";s:2:"À¤";s:3:"壑";s:2:"À¥";s:3:"壎";s:2:"À¦";s:3:"嬰";s:2:"À§";s:3:"嬪";s:2:"À¨";s:3:"嬤";s:2:"À©";s:3:"å­º";s:2:"Àª";s:3:"å°·";s:2:"À«";s:3:"屨";s:2:"À¬";s:3:"嶼";s:2:"À­";s:3:"嶺";s:2:"À®";s:3:"嶽";s:2:"À¯";s:3:"嶸";s:2:"À°";s:3:"幫";s:2:"À±";s:3:"彌";s:2:"À²";s:3:"å¾½";s:2:"À³";s:3:"應";s:2:"À´";s:3:"懂";s:2:"Àµ";s:3:"懇";s:2:"À¶";s:3:"懦";s:2:"À·";s:3:"懋";s:2:"À¸";s:3:"戲";s:2:"À¹";s:3:"戴";s:2:"Àº";s:3:"æ“Ž";s:2:"À»";s:3:"æ“Š";s:2:"À¼";s:3:"擘";s:2:"À½";s:3:"æ“ ";s:2:"À¾";s:3:"æ“°";s:2:"À¿";s:3:"擦";s:2:"ÀÀ";s:3:"擬";s:2:"ÀÁ";s:3:"擱";s:2:"ÀÂ";s:3:"æ“¢";s:2:"ÀÃ";s:3:"æ“­";s:2:"ÀÄ";s:3:"æ–‚";s:2:"ÀÅ";s:3:"æ–ƒ";s:2:"ÀÆ";s:3:"æ›™";s:2:"ÀÇ";s:3:"æ›–";s:2:"ÀÈ";s:3:"檀";s:2:"ÀÉ";s:3:"檔";s:2:"ÀÊ";s:3:"檄";s:2:"ÀË";s:3:"檢";s:2:"ÀÌ";s:3:"檜";s:2:"ÀÍ";s:3:"æ«›";s:2:"ÀÎ";s:3:"檣";s:2:"ÀÏ";s:3:"橾";s:2:"ÀÐ";s:3:"檗";s:2:"ÀÑ";s:3:"æª";s:2:"ÀÒ";s:3:"檠";s:2:"ÀÓ";s:3:"æ­œ";s:2:"ÀÔ";s:3:"æ®®";s:2:"ÀÕ";s:3:"毚";s:2:"ÀÖ";s:3:"æ°ˆ";s:2:"À×";s:3:"濘";s:2:"ÀØ";s:3:"濱";s:2:"ÀÙ";s:3:"æ¿Ÿ";s:2:"ÀÚ";s:3:"æ¿ ";s:2:"ÀÛ";s:3:"æ¿›";s:2:"ÀÜ";s:3:"濤";s:2:"ÀÝ";s:3:"æ¿«";s:2:"ÀÞ";s:3:"濯";s:2:"Àß";s:3:"æ¾€";s:2:"Àà";s:3:"濬";s:2:"Àá";s:3:"æ¿¡";s:2:"Àâ";s:3:"æ¿©";s:2:"Àã";s:3:"æ¿•";s:2:"Àä";s:3:"æ¿®";s:2:"Àå";s:3:"æ¿°";s:2:"Àæ";s:3:"燧";s:2:"Àç";s:3:"營";s:2:"Àè";s:3:"燮";s:2:"Àé";s:3:"燦";s:2:"Àê";s:3:"燥";s:2:"Àë";s:3:"燭";s:2:"Àì";s:3:"燬";s:2:"Àí";s:3:"燴";s:2:"Àî";s:3:"燠";s:2:"Àï";s:3:"爵";s:2:"Àð";s:3:"牆";s:2:"Àñ";s:3:"ç°";s:2:"Àò";s:3:"ç²";s:2:"Àó";s:3:"ç’©";s:2:"Àô";s:3:"ç’°";s:2:"Àõ";s:3:"ç’¦";s:2:"Àö";s:3:"ç’¨";s:2:"À÷";s:3:"癆";s:2:"Àø";s:3:"療";s:2:"Àù";s:3:"癌";s:2:"Àú";s:3:"盪";s:2:"Àû";s:3:"çž³";s:2:"Àü";s:3:"瞪";s:2:"Àý";s:3:"çž°";s:2:"Àþ";s:3:"瞬";s:2:"Á@";s:3:"瞧";s:2:"ÁA";s:3:"çž­";s:2:"ÁB";s:3:"矯";s:2:"ÁC";s:3:"磷";s:2:"ÁD";s:3:"磺";s:2:"ÁE";s:3:"磴";s:2:"ÁF";s:3:"磯";s:2:"ÁG";s:3:"ç¤";s:2:"ÁH";s:3:"禧";s:2:"ÁI";s:3:"禪";s:2:"ÁJ";s:3:"ç©—";s:2:"ÁK";s:3:"窿";s:2:"ÁL";s:3:"ç°‡";s:2:"ÁM";s:3:"ç°";s:2:"ÁN";s:3:"篾";s:2:"ÁO";s:3:"篷";s:2:"ÁP";s:3:"ç°Œ";s:2:"ÁQ";s:3:"篠";s:2:"ÁR";s:3:"ç³ ";s:2:"ÁS";s:3:"糜";s:2:"ÁT";s:3:"糞";s:2:"ÁU";s:3:"ç³¢";s:2:"ÁV";s:3:"糟";s:2:"ÁW";s:3:"ç³™";s:2:"ÁX";s:3:"ç³";s:2:"ÁY";s:3:"縮";s:2:"ÁZ";s:3:"績";s:2:"Á[";s:3:"繆";s:2:"Á\";s:3:"縷";s:2:"Á]";s:3:"縲";s:2:"Á^";s:3:"繃";s:2:"Á_";s:3:"縫";s:2:"Á`";s:3:"總";s:2:"Áa";s:3:"縱";s:2:"Áb";s:3:"ç¹…";s:2:"Ác";s:3:"ç¹";s:2:"Ád";s:3:"縴";s:2:"Áe";s:3:"縹";s:2:"Áf";s:3:"繈";s:2:"Ág";s:3:"縵";s:2:"Áh";s:3:"縿";s:2:"Ái";s:3:"縯";s:2:"Áj";s:3:"罄";s:2:"Ák";s:3:"翳";s:2:"Ál";s:3:"翼";s:2:"Ám";s:3:"è±";s:2:"Án";s:3:"è²";s:2:"Áo";s:3:"è°";s:2:"Áp";s:3:"è¯";s:2:"Áq";s:3:"è³";s:2:"Ár";s:3:"臆";s:2:"Ás";s:3:"臃";s:2:"Át";s:3:"膺";s:2:"Áu";s:3:"臂";s:2:"Áv";s:3:"臀";s:2:"Áw";s:3:"膿";s:2:"Áx";s:3:"膽";s:2:"Áy";s:3:"臉";s:2:"Áz";s:3:"膾";s:2:"Á{";s:3:"臨";s:2:"Á|";s:3:"舉";s:2:"Á}";s:3:"艱";s:2:"Á~";s:3:"è–ª";s:2:"Á¡";s:3:"è–„";s:2:"Á¢";s:3:"蕾";s:2:"Á£";s:3:"è–œ";s:2:"Á¤";s:3:"è–‘";s:2:"Á¥";s:3:"è–”";s:2:"Á¦";s:3:"è–¯";s:2:"Á§";s:3:"è–›";s:2:"Á¨";s:3:"è–‡";s:2:"Á©";s:3:"è–¨";s:2:"Áª";s:3:"è–Š";s:2:"Á«";s:3:"虧";s:2:"Á¬";s:3:"蟀";s:2:"Á­";s:3:"蟑";s:2:"Á®";s:3:"èž³";s:2:"Á¯";s:3:"蟒";s:2:"Á°";s:3:"蟆";s:2:"Á±";s:3:"èž«";s:2:"Á²";s:3:"èž»";s:2:"Á³";s:3:"螺";s:2:"Á´";s:3:"蟈";s:2:"Áµ";s:3:"蟋";s:2:"Á¶";s:3:"褻";s:2:"Á·";s:3:"褶";s:2:"Á¸";s:3:"襄";s:2:"Á¹";s:3:"褸";s:2:"Áº";s:3:"褽";s:2:"Á»";s:3:"覬";s:2:"Á¼";s:3:"謎";s:2:"Á½";s:3:"謗";s:2:"Á¾";s:3:"謙";s:2:"Á¿";s:3:"講";s:2:"ÁÀ";s:3:"謊";s:2:"ÁÁ";s:3:"謠";s:2:"ÁÂ";s:3:"è¬";s:2:"ÁÃ";s:3:"謄";s:2:"ÁÄ";s:3:"è¬";s:2:"ÁÅ";s:3:"è±";s:2:"ÁÆ";s:3:"è°¿";s:2:"ÁÇ";s:3:"è±³";s:2:"ÁÈ";s:3:"賺";s:2:"ÁÉ";s:3:"è³½";s:2:"ÁÊ";s:3:"è³¼";s:2:"ÁË";s:3:"賸";s:2:"ÁÌ";s:3:"è³»";s:2:"ÁÍ";s:3:"趨";s:2:"ÁÎ";s:3:"蹉";s:2:"ÁÏ";s:3:"蹋";s:2:"ÁÐ";s:3:"蹈";s:2:"ÁÑ";s:3:"蹊";s:2:"ÁÒ";s:3:"轄";s:2:"ÁÓ";s:3:"è¼¾";s:2:"ÁÔ";s:3:"轂";s:2:"ÁÕ";s:3:"è½…";s:2:"ÁÖ";s:3:"輿";s:2:"Á×";s:3:"é¿";s:2:"ÁØ";s:3:"é½";s:2:"ÁÙ";s:3:"é‚„";s:2:"ÁÚ";s:3:"é‚";s:2:"ÁÛ";s:3:"é‚‚";s:2:"ÁÜ";s:3:"é‚€";s:2:"ÁÝ";s:3:"鄹";s:2:"ÁÞ";s:3:"醣";s:2:"Áß";s:3:"醞";s:2:"Áà";s:3:"醜";s:2:"Áá";s:3:"é";s:2:"Áâ";s:3:"鎂";s:2:"Áã";s:3:"錨";s:2:"Áä";s:3:"éµ";s:2:"Áå";s:3:"éŠ";s:2:"Áæ";s:3:"é¥";s:2:"Áç";s:3:"é‹";s:2:"Áè";s:3:"錘";s:2:"Áé";s:3:"é¾";s:2:"Áê";s:3:"é¬";s:2:"Áë";s:3:"é›";s:2:"Áì";s:3:"é°";s:2:"Áí";s:3:"éš";s:2:"Áî";s:3:"é”";s:2:"Áï";s:3:"é—Š";s:2:"Áð";s:3:"é—‹";s:2:"Áñ";s:3:"é—Œ";s:2:"Áò";s:3:"é—ˆ";s:2:"Áó";s:3:"é—†";s:2:"Áô";s:3:"éš±";s:2:"Áõ";s:3:"隸";s:2:"Áö";s:3:"é›–";s:2:"Á÷";s:3:"霜";s:2:"Áø";s:3:"霞";s:2:"Áù";s:3:"éž ";s:2:"Áú";s:3:"韓";s:2:"Áû";s:3:"顆";s:2:"Áü";s:3:"颶";s:2:"Áý";s:3:"餵";s:2:"Áþ";s:3:"é¨";s:2:"Â@";s:3:"駿";s:2:"ÂA";s:3:"é®®";s:2:"ÂB";s:3:"鮫";s:2:"ÂC";s:3:"鮪";s:2:"ÂD";s:3:"é®­";s:2:"ÂE";s:3:"é´»";s:2:"ÂF";s:3:"é´¿";s:2:"ÂG";s:3:"麋";s:2:"ÂH";s:3:"é»";s:2:"ÂI";s:3:"點";s:2:"ÂJ";s:3:"黜";s:2:"ÂK";s:3:"é»";s:2:"ÂL";s:3:"é»›";s:2:"ÂM";s:3:"é¼¾";s:2:"ÂN";s:3:"齋";s:2:"ÂO";s:3:"å¢";s:2:"ÂP";s:3:"åš•";s:2:"ÂQ";s:3:"åš®";s:2:"ÂR";s:3:"壙";s:2:"ÂS";s:3:"壘";s:2:"ÂT";s:3:"嬸";s:2:"ÂU";s:3:"å½";s:2:"ÂV";s:3:"懣";s:2:"ÂW";s:3:"戳";s:2:"ÂX";s:3:"æ“´";s:2:"ÂY";s:3:"擲";s:2:"ÂZ";s:3:"擾";s:2:"Â[";s:3:"攆";s:2:"Â\";s:3:"擺";s:2:"Â]";s:3:"æ“»";s:2:"Â^";s:3:"æ“·";s:2:"Â_";s:3:"æ–·";s:2:"Â`";s:3:"曜";s:2:"Âa";s:3:"朦";s:2:"Âb";s:3:"檳";s:2:"Âc";s:3:"檬";s:2:"Âd";s:3:"櫃";s:2:"Âe";s:3:"檻";s:2:"Âf";s:3:"檸";s:2:"Âg";s:3:"æ«‚";s:2:"Âh";s:3:"檮";s:2:"Âi";s:3:"檯";s:2:"Âj";s:3:"æ­Ÿ";s:2:"Âk";s:3:"æ­¸";s:2:"Âl";s:3:"殯";s:2:"Âm";s:3:"瀉";s:2:"Ân";s:3:"瀋";s:2:"Âo";s:3:"濾";s:2:"Âp";s:3:"瀆";s:2:"Âq";s:3:"濺";s:2:"Âr";s:3:"瀑";s:2:"Âs";s:3:"ç€";s:2:"Ât";s:3:"燻";s:2:"Âu";s:3:"燼";s:2:"Âv";s:3:"燾";s:2:"Âw";s:3:"燸";s:2:"Âx";s:3:"ç·";s:2:"Ây";s:3:"çµ";s:2:"Âz";s:3:"ç’§";s:2:"Â{";s:3:"ç’¿";s:2:"Â|";s:3:"甕";s:2:"Â}";s:3:"ç™–";s:2:"Â~";s:3:"癘";s:2:"¡";s:3:"ç™’";s:2:"¢";s:3:"çž½";s:2:"£";s:3:"çž¿";s:2:"¤";s:3:"çž»";s:2:"Â¥";s:3:"çž¼";s:2:"¦";s:3:"礎";s:2:"§";s:3:"禮";s:2:"¨";s:3:"ç©¡";s:2:"©";s:3:"ç©¢";s:2:"ª";s:3:"ç© ";s:2:"«";s:3:"ç«„";s:2:"¬";s:3:"ç«…";s:2:"­";s:3:"ç°«";s:2:"®";s:3:"ç°§";s:2:"¯";s:3:"ç°ª";s:2:"°";s:3:"ç°ž";s:2:"±";s:3:"ç°£";s:2:"²";s:3:"ç°¡";s:2:"³";s:3:"糧";s:2:"´";s:3:"ç¹”";s:2:"µ";s:3:"繕";s:2:"¶";s:3:"繞";s:2:"·";s:3:"繚";s:2:"¸";s:3:"繡";s:2:"¹";s:3:"ç¹’";s:2:"º";s:3:"ç¹™";s:2:"»";s:3:"罈";s:2:"¼";s:3:"翹";s:2:"½";s:3:"ç¿»";s:2:"¾";s:3:"è·";s:2:"¿";s:3:"è¶";s:2:"ÂÀ";s:3:"è‡";s:2:"ÂÁ";s:3:"è‡";s:2:"ÂÂ";s:3:"舊";s:2:"ÂÃ";s:3:"è—";s:2:"ÂÄ";s:3:"è–©";s:2:"ÂÅ";s:3:"è—";s:2:"ÂÆ";s:3:"è—";s:2:"ÂÇ";s:3:"è—‰";s:2:"ÂÈ";s:3:"è–°";s:2:"ÂÉ";s:3:"è–º";s:2:"ÂÊ";s:3:"è–¹";s:2:"ÂË";s:3:"è–¦";s:2:"ÂÌ";s:3:"蟯";s:2:"ÂÍ";s:3:"蟬";s:2:"ÂÎ";s:3:"蟲";s:2:"ÂÏ";s:3:"蟠";s:2:"ÂÐ";s:3:"覆";s:2:"ÂÑ";s:3:"覲";s:2:"ÂÒ";s:3:"觴";s:2:"ÂÓ";s:3:"謨";s:2:"ÂÔ";s:3:"謹";s:2:"ÂÕ";s:3:"謬";s:2:"ÂÖ";s:3:"謫";s:2:"Â×";s:3:"è±";s:2:"ÂØ";s:3:"è´…";s:2:"ÂÙ";s:3:"è¹™";s:2:"ÂÚ";s:3:"è¹£";s:2:"ÂÛ";s:3:"蹦";s:2:"ÂÜ";s:3:"蹤";s:2:"ÂÝ";s:3:"蹟";s:2:"ÂÞ";s:3:"蹕";s:2:"Âß";s:3:"軀";s:2:"Âà";s:3:"轉";s:2:"Âá";s:3:"è½";s:2:"Ââ";s:3:"邇";s:2:"Âã";s:3:"邃";s:2:"Âä";s:3:"邈";s:2:"Âå";s:3:"醫";s:2:"Âæ";s:3:"醬";s:2:"Âç";s:3:"é‡";s:2:"Âè";s:3:"鎔";s:2:"Âé";s:3:"鎊";s:2:"Âê";s:3:"鎖";s:2:"Âë";s:3:"鎢";s:2:"Âì";s:3:"鎳";s:2:"Âí";s:3:"鎮";s:2:"Âî";s:3:"鎬";s:2:"Âï";s:3:"鎰";s:2:"Âð";s:3:"鎘";s:2:"Âñ";s:3:"鎚";s:2:"Âò";s:3:"鎗";s:2:"Âó";s:3:"é—”";s:2:"Âô";s:3:"é—–";s:2:"Âõ";s:3:"é—";s:2:"Âö";s:3:"é—•";s:2:"Â÷";s:3:"離";s:2:"Âø";s:3:"雜";s:2:"Âù";s:3:"é›™";s:2:"Âú";s:3:"é››";s:2:"Âû";s:3:"雞";s:2:"Âü";s:3:"霤";s:2:"Âý";s:3:"鞣";s:2:"Âþ";s:3:"鞦";s:2:"Ã@";s:3:"éž­";s:2:"ÃA";s:3:"韹";s:2:"ÃB";s:3:"é¡";s:2:"ÃC";s:3:"é¡";s:2:"ÃD";s:3:"é¡Œ";s:2:"ÃE";s:3:"é¡Ž";s:2:"ÃF";s:3:"é¡“";s:2:"ÃG";s:3:"颺";s:2:"ÃH";s:3:"餾";s:2:"ÃI";s:3:"餿";s:2:"ÃJ";s:3:"餽";s:2:"ÃK";s:3:"餮";s:2:"ÃL";s:3:"馥";s:2:"ÃM";s:3:"騎";s:2:"ÃN";s:3:"é«";s:2:"ÃO";s:3:"鬃";s:2:"ÃP";s:3:"鬆";s:2:"ÃQ";s:3:"é­";s:2:"ÃR";s:3:"é­Ž";s:2:"ÃS";s:3:"é­";s:2:"ÃT";s:3:"鯊";s:2:"ÃU";s:3:"鯉";s:2:"ÃV";s:3:"鯽";s:2:"ÃW";s:3:"鯈";s:2:"ÃX";s:3:"鯀";s:2:"ÃY";s:3:"鵑";s:2:"ÃZ";s:3:"éµ";s:2:"Ã[";s:3:"éµ ";s:2:"Ã\";s:3:"é» ";s:2:"Ã]";s:3:"鼕";s:2:"Ã^";s:3:"鼬";s:2:"Ã_";s:3:"儳";s:2:"Ã`";s:3:"嚥";s:2:"Ãa";s:3:"壞";s:2:"Ãb";s:3:"壟";s:2:"Ãc";s:3:"壢";s:2:"Ãd";s:3:"寵";s:2:"Ãe";s:3:"é¾";s:2:"Ãf";s:3:"廬";s:2:"Ãg";s:3:"懲";s:2:"Ãh";s:3:"懷";s:2:"Ãi";s:3:"懶";s:2:"Ãj";s:3:"懵";s:2:"Ãk";s:3:"攀";s:2:"Ãl";s:3:"æ”";s:2:"Ãm";s:3:"æ› ";s:2:"Ãn";s:3:"æ›";s:2:"Ão";s:3:"æ«¥";s:2:"Ãp";s:3:"æ«";s:2:"Ãq";s:3:"æ«š";s:2:"Ãr";s:3:"æ«“";s:2:"Ãs";s:3:"瀛";s:2:"Ãt";s:3:"瀟";s:2:"Ãu";s:3:"瀨";s:2:"Ãv";s:3:"瀚";s:2:"Ãw";s:3:"ç€";s:2:"Ãx";s:3:"瀕";s:2:"Ãy";s:3:"瀘";s:2:"Ãz";s:3:"爆";s:2:"Ã{";s:3:"çˆ";s:2:"Ã|";s:3:"牘";s:2:"Ã}";s:3:"犢";s:2:"Ã~";s:3:"ç¸";s:2:"á";s:3:"çº";s:2:"â";s:3:"ç’½";s:2:"ã";s:3:"ç“Š";s:2:"ä";s:3:"ç“£";s:2:"Ã¥";s:3:"ç–‡";s:2:"æ";s:3:"ç–†";s:2:"ç";s:3:"癟";s:2:"è";s:3:"癡";s:2:"é";s:3:"矇";s:2:"ê";s:3:"礙";s:2:"ë";s:3:"禱";s:2:"ì";s:3:"ç©«";s:2:"í";s:3:"ç©©";s:2:"î";s:3:"ç°¾";s:2:"ï";s:3:"ç°¿";s:2:"ð";s:3:"ç°¸";s:2:"ñ";s:3:"ç°½";s:2:"ò";s:3:"ç°·";s:2:"ó";s:3:"ç±€";s:2:"ô";s:3:"繫";s:2:"õ";s:3:"ç¹­";s:2:"ö";s:3:"ç¹¹";s:2:"÷";s:3:"繩";s:2:"ø";s:3:"繪";s:2:"ù";s:3:"ç¾…";s:2:"ú";s:3:"ç¹³";s:2:"û";s:3:"羶";s:2:"ü";s:3:"ç¾¹";s:2:"ý";s:3:"羸";s:2:"þ";s:3:"臘";s:2:"ÿ";s:3:"è—©";s:2:"ÃÀ";s:3:"è—";s:2:"ÃÁ";s:3:"è—ª";s:2:"ÃÂ";s:3:"è—•";s:2:"ÃÃ";s:3:"è—¤";s:2:"ÃÄ";s:3:"è—¥";s:2:"ÃÅ";s:3:"è—·";s:2:"ÃÆ";s:3:"蟻";s:2:"ÃÇ";s:3:"è …";s:2:"ÃÈ";s:3:"è ";s:2:"ÃÉ";s:3:"蟹";s:2:"ÃÊ";s:3:"蟾";s:2:"ÃË";s:3:"襠";s:2:"ÃÌ";s:3:"襟";s:2:"ÃÍ";s:3:"襖";s:2:"ÃÎ";s:3:"襞";s:2:"ÃÏ";s:3:"è­";s:2:"ÃÐ";s:3:"è­œ";s:2:"ÃÑ";s:3:"è­˜";s:2:"ÃÒ";s:3:"è­‰";s:2:"ÃÓ";s:3:"è­š";s:2:"ÃÔ";s:3:"è­Ž";s:2:"ÃÕ";s:3:"è­";s:2:"ÃÖ";s:3:"è­†";s:2:"Ã×";s:3:"è­™";s:2:"ÃØ";s:3:"è´ˆ";s:2:"ÃÙ";s:3:"è´Š";s:2:"ÃÚ";s:3:"è¹¼";s:2:"ÃÛ";s:3:"è¹²";s:2:"ÃÜ";s:3:"躇";s:2:"ÃÝ";s:3:"蹶";s:2:"ÃÞ";s:3:"蹬";s:2:"Ãß";s:3:"蹺";s:2:"Ãà";s:3:"è¹´";s:2:"Ãá";s:3:"è½”";s:2:"Ãâ";s:3:"轎";s:2:"Ãã";s:3:"è¾­";s:2:"Ãä";s:3:"é‚Š";s:2:"Ãå";s:3:"é‚‹";s:2:"Ãæ";s:3:"醱";s:2:"Ãç";s:3:"醮";s:2:"Ãè";s:3:"é¡";s:2:"Ãé";s:3:"é‘";s:2:"Ãê";s:3:"éŸ";s:2:"Ãë";s:3:"éƒ";s:2:"Ãì";s:3:"éˆ";s:2:"Ãí";s:3:"éœ";s:2:"Ãî";s:3:"é";s:2:"Ãï";s:3:"é–";s:2:"Ãð";s:3:"é¢";s:2:"Ãñ";s:3:"é";s:2:"Ãò";s:3:"é˜";s:2:"Ãó";s:3:"é¤";s:2:"Ãô";s:3:"é—";s:2:"Ãõ";s:3:"é¨";s:2:"Ãö";s:3:"é—œ";s:2:"Ã÷";s:3:"éš´";s:2:"Ãø";s:3:"難";s:2:"Ãù";s:3:"霪";s:2:"Ãú";s:3:"霧";s:2:"Ãû";s:3:"é¡";s:2:"Ãü";s:3:"韜";s:2:"Ãý";s:3:"韻";s:2:"Ãþ";s:3:"é¡ž";s:2:"Ä@";s:3:"願";s:2:"ÄA";s:3:"é¡›";s:2:"ÄB";s:3:"颼";s:2:"ÄC";s:3:"饅";s:2:"ÄD";s:3:"饉";s:2:"ÄE";s:3:"騖";s:2:"ÄF";s:3:"騙";s:2:"ÄG";s:3:"é¬";s:2:"ÄH";s:3:"鯨";s:2:"ÄI";s:3:"鯧";s:2:"ÄJ";s:3:"鯖";s:2:"ÄK";s:3:"鯛";s:2:"ÄL";s:3:"鶉";s:2:"ÄM";s:3:"鵡";s:2:"ÄN";s:3:"éµ²";s:2:"ÄO";s:3:"鵪";s:2:"ÄP";s:3:"鵬";s:2:"ÄQ";s:3:"麒";s:2:"ÄR";s:3:"麗";s:2:"ÄS";s:3:"麓";s:2:"ÄT";s:3:"麴";s:2:"ÄU";s:3:"勸";s:2:"ÄV";s:3:"嚨";s:2:"ÄW";s:3:"åš·";s:2:"ÄX";s:3:"嚶";s:2:"ÄY";s:3:"åš´";s:2:"ÄZ";s:3:"åš¼";s:2:"Ä[";s:3:"壤";s:2:"Ä\";s:3:"å­€";s:2:"Ä]";s:3:"å­ƒ";s:2:"Ä^";s:3:"å­½";s:2:"Ä_";s:3:"寶";s:2:"Ä`";s:3:"å·‰";s:2:"Äa";s:3:"懸";s:2:"Äb";s:3:"懺";s:2:"Äc";s:3:"攘";s:2:"Äd";s:3:"æ””";s:2:"Äe";s:3:"æ”™";s:2:"Äf";s:3:"曦";s:2:"Äg";s:3:"朧";s:2:"Äh";s:3:"櫬";s:2:"Äi";s:3:"瀾";s:2:"Äj";s:3:"瀰";s:2:"Äk";s:3:"瀲";s:2:"Äl";s:3:"çˆ";s:2:"Äm";s:3:"ç»";s:2:"Än";s:3:"ç“";s:2:"Äo";s:3:"癢";s:2:"Äp";s:3:"癥";s:2:"Äq";s:3:"礦";s:2:"Är";s:3:"礪";s:2:"Äs";s:3:"礬";s:2:"Ät";s:3:"礫";s:2:"Äu";s:3:"竇";s:2:"Äv";s:3:"競";s:2:"Äw";s:3:"籌";s:2:"Äx";s:3:"籃";s:2:"Äy";s:3:"ç±";s:2:"Äz";s:3:"糯";s:2:"Ä{";s:3:"ç³°";s:2:"Ä|";s:3:"è¾®";s:2:"Ä}";s:3:"ç¹½";s:2:"Ä~";s:3:"ç¹¼";s:2:"Ä¡";s:3:"纂";s:2:"Ä¢";s:3:"罌";s:2:"Ä£";s:3:"耀";s:2:"Ĥ";s:3:"臚";s:2:"Ä¥";s:3:"艦";s:2:"Ħ";s:3:"è—»";s:2:"ħ";s:3:"è—¹";s:2:"Ĩ";s:3:"蘑";s:2:"Ä©";s:3:"è—º";s:2:"Ī";s:3:"蘆";s:2:"Ä«";s:3:"蘋";s:2:"Ĭ";s:3:"蘇";s:2:"Ä­";s:3:"蘊";s:2:"Ä®";s:3:"è ”";s:2:"į";s:3:"è •";s:2:"Ä°";s:3:"襤";s:2:"ı";s:3:"覺";s:2:"IJ";s:3:"觸";s:2:"ij";s:3:"è­°";s:2:"Ä´";s:3:"è­¬";s:2:"ĵ";s:3:"è­¦";s:2:"Ķ";s:3:"è­¯";s:2:"Ä·";s:3:"è­Ÿ";s:2:"ĸ";s:3:"è­«";s:2:"Ĺ";s:3:"è´";s:2:"ĺ";s:3:"è´";s:2:"Ä»";s:3:"躉";s:2:"ļ";s:3:"èº";s:2:"Ľ";s:3:"躅";s:2:"ľ";s:3:"躂";s:2:"Ä¿";s:3:"醴";s:2:"ÄÀ";s:3:"釋";s:2:"ÄÁ";s:3:"é˜";s:2:"ÄÂ";s:3:"éƒ";s:2:"ÄÃ";s:3:"é½";s:2:"ÄÄ";s:3:"é—¡";s:2:"ÄÅ";s:3:"霰";s:2:"ÄÆ";s:3:"飄";s:2:"ÄÇ";s:3:"饒";s:2:"ÄÈ";s:3:"饑";s:2:"ÄÉ";s:3:"馨";s:2:"ÄÊ";s:3:"騫";s:2:"ÄË";s:3:"騰";s:2:"ÄÌ";s:3:"騷";s:2:"ÄÍ";s:3:"騵";s:2:"ÄÎ";s:3:"é°“";s:2:"ÄÏ";s:3:"é°";s:2:"ÄÐ";s:3:"é¹¹";s:2:"ÄÑ";s:3:"麵";s:2:"ÄÒ";s:3:"黨";s:2:"ÄÓ";s:3:"鼯";s:2:"ÄÔ";s:3:"齟";s:2:"ÄÕ";s:3:"é½£";s:2:"ÄÖ";s:3:"齡";s:2:"Ä×";s:3:"å„·";s:2:"ÄØ";s:3:"儸";s:2:"ÄÙ";s:3:"å›";s:2:"ÄÚ";s:3:"囀";s:2:"ÄÛ";s:3:"囂";s:2:"ÄÜ";s:3:"夔";s:2:"ÄÝ";s:3:"屬";s:2:"ÄÞ";s:3:"å·";s:2:"Äß";s:3:"懼";s:2:"Äà";s:3:"懾";s:2:"Äá";s:3:"æ”";s:2:"Äâ";s:3:"攜";s:2:"Äã";s:3:"æ–•";s:2:"Ää";s:3:"曩";s:2:"Äå";s:3:"æ«»";s:2:"Äæ";s:3:"欄";s:2:"Äç";s:3:"櫺";s:2:"Äè";s:3:"殲";s:2:"Äé";s:3:"çŒ";s:2:"Äê";s:3:"爛";s:2:"Äë";s:3:"犧";s:2:"Äì";s:3:"ç“–";s:2:"Äí";s:3:"ç“”";s:2:"Äî";s:3:"癩";s:2:"Äï";s:3:"矓";s:2:"Äð";s:3:"ç±";s:2:"Äñ";s:3:"çº";s:2:"Äò";s:3:"續";s:2:"Äó";s:3:"ç¾¼";s:2:"Äô";s:3:"蘗";s:2:"Äõ";s:3:"蘭";s:2:"Äö";s:3:"蘚";s:2:"Ä÷";s:3:"è £";s:2:"Äø";s:3:"è ¢";s:2:"Äù";s:3:"è ¡";s:2:"Äú";s:3:"è Ÿ";s:2:"Äû";s:3:"襪";s:2:"Äü";s:3:"襬";s:2:"Äý";s:3:"覽";s:2:"Äþ";s:3:"è­´";s:2:"Å@";s:3:"è­·";s:2:"ÅA";s:3:"è­½";s:2:"ÅB";s:3:"è´“";s:2:"ÅC";s:3:"躊";s:2:"ÅD";s:3:"èº";s:2:"ÅE";s:3:"躋";s:2:"ÅF";s:3:"轟";s:2:"ÅG";s:3:"辯";s:2:"ÅH";s:3:"醺";s:2:"ÅI";s:3:"é®";s:2:"ÅJ";s:3:"é³";s:2:"ÅK";s:3:"éµ";s:2:"ÅL";s:3:"éº";s:2:"ÅM";s:3:"é¸";s:2:"ÅN";s:3:"é²";s:2:"ÅO";s:3:"é«";s:2:"ÅP";s:3:"é—¢";s:2:"ÅQ";s:3:"霸";s:2:"ÅR";s:3:"霹";s:2:"ÅS";s:3:"露";s:2:"ÅT";s:3:"響";s:2:"ÅU";s:3:"顧";s:2:"ÅV";s:3:"é¡¥";s:2:"ÅW";s:3:"饗";s:2:"ÅX";s:3:"é©…";s:2:"ÅY";s:3:"驃";s:2:"ÅZ";s:3:"é©€";s:2:"Å[";s:3:"騾";s:2:"Å\";s:3:"é«";s:2:"Å]";s:3:"é­”";s:2:"Å^";s:3:"é­‘";s:2:"Å_";s:3:"é°­";s:2:"Å`";s:3:"é°¥";s:2:"Åa";s:3:"鶯";s:2:"Åb";s:3:"鶴";s:2:"Åc";s:3:"é·‚";s:2:"Åd";s:3:"鶸";s:2:"Åe";s:3:"éº";s:2:"Åf";s:3:"黯";s:2:"Åg";s:3:"é¼™";s:2:"Åh";s:3:"齜";s:2:"Åi";s:3:"齦";s:2:"Åj";s:3:"齧";s:2:"Åk";s:3:"儼";s:2:"Ål";s:3:"å„»";s:2:"Åm";s:3:"囈";s:2:"Ån";s:3:"囊";s:2:"Åo";s:3:"囉";s:2:"Åp";s:3:"å­¿";s:2:"Åq";s:3:"å·”";s:2:"År";s:3:"å·’";s:2:"Ås";s:3:"彎";s:2:"Åt";s:3:"懿";s:2:"Åu";s:3:"攤";s:2:"Åv";s:3:"權";s:2:"Åw";s:3:"æ­¡";s:2:"Åx";s:3:"ç‘";s:2:"Åy";s:3:"ç˜";s:2:"Åz";s:3:"玀";s:2:"Å{";s:3:"瓤";s:2:"Å|";s:3:"ç–Š";s:2:"Å}";s:3:"ç™®";s:2:"Å~";s:3:"癬";s:2:"Å¡";s:3:"禳";s:2:"Å¢";s:3:"ç± ";s:2:"Å£";s:3:"籟";s:2:"Ť";s:3:"è¾";s:2:"Å¥";s:3:"è½";s:2:"Ŧ";s:3:"臟";s:2:"ŧ";s:3:"襲";s:2:"Ũ";s:3:"襯";s:2:"Å©";s:3:"觼";s:2:"Ū";s:3:"讀";s:2:"Å«";s:3:"è´–";s:2:"Ŭ";s:3:"è´—";s:2:"Å­";s:3:"躑";s:2:"Å®";s:3:"躓";s:2:"ů";s:3:"轡";s:2:"Å°";s:3:"é…ˆ";s:2:"ű";s:3:"é‘„";s:2:"Ų";s:3:"é‘‘";s:2:"ų";s:3:"é‘’";s:2:"Å´";s:3:"霽";s:2:"ŵ";s:3:"霾";s:2:"Ŷ";s:3:"韃";s:2:"Å·";s:3:"éŸ";s:2:"Ÿ";s:3:"é¡«";s:2:"Ź";s:3:"饕";s:2:"ź";s:3:"é©•";s:2:"Å»";s:3:"é©";s:2:"ż";s:3:"é«’";s:2:"Ž";s:3:"鬚";s:2:"ž";s:3:"鱉";s:2:"Å¿";s:3:"é°±";s:2:"ÅÀ";s:3:"é°¾";s:2:"ÅÁ";s:3:"é°»";s:2:"ÅÂ";s:3:"é·“";s:2:"ÅÃ";s:3:"é·—";s:2:"ÅÄ";s:3:"é¼´";s:2:"ÅÅ";s:3:"齬";s:2:"ÅÆ";s:3:"齪";s:2:"ÅÇ";s:3:"é¾”";s:2:"ÅÈ";s:3:"囌";s:2:"ÅÉ";s:3:"å·–";s:2:"ÅÊ";s:3:"戀";s:2:"ÅË";s:3:"攣";s:2:"ÅÌ";s:3:"攫";s:2:"ÅÍ";s:3:"攪";s:2:"ÅÎ";s:3:"曬";s:2:"ÅÏ";s:3:"æ¬";s:2:"ÅÐ";s:3:"ç“š";s:2:"ÅÑ";s:3:"ç«Š";s:2:"ÅÒ";s:3:"籤";s:2:"ÅÓ";s:3:"ç±£";s:2:"ÅÔ";s:3:"ç±¥";s:2:"ÅÕ";s:3:"纓";s:2:"ÅÖ";s:3:"纖";s:2:"Å×";s:3:"纔";s:2:"ÅØ";s:3:"臢";s:2:"ÅÙ";s:3:"蘸";s:2:"ÅÚ";s:3:"蘿";s:2:"ÅÛ";s:3:"è ±";s:2:"ÅÜ";s:3:"變";s:2:"ÅÝ";s:3:"é‚";s:2:"ÅÞ";s:3:"é‚";s:2:"Åß";s:3:"é‘£";s:2:"Åà";s:3:"é‘ ";s:2:"Åá";s:3:"鑤";s:2:"Åâ";s:3:"é¨";s:2:"Åã";s:3:"顯";s:2:"Åä";s:3:"饜";s:2:"Åå";s:3:"é©š";s:2:"Åæ";s:3:"é©›";s:2:"Åç";s:3:"é©—";s:2:"Åè";s:3:"é«“";s:2:"Åé";s:3:"é«”";s:2:"Åê";s:3:"é«‘";s:2:"Åë";s:3:"é±”";s:2:"Åì";s:3:"é±—";s:2:"Åí";s:3:"é±–";s:2:"Åî";s:3:"é·¥";s:2:"Åï";s:3:"麟";s:2:"Åð";s:3:"é»´";s:2:"Åñ";s:3:"囑";s:2:"Åò";s:3:"壩";s:2:"Åó";s:3:"攬";s:2:"Åô";s:3:"çž";s:2:"Åõ";s:3:"ç™±";s:2:"Åö";s:3:"癲";s:2:"Å÷";s:3:"矗";s:2:"Åø";s:3:"ç½";s:2:"Åù";s:3:"羈";s:2:"Åú";s:3:"è ¶";s:2:"Åû";s:3:"è ¹";s:2:"Åü";s:3:"è¡¢";s:2:"Åý";s:3:"讓";s:2:"Åþ";s:3:"è®’";s:2:"Æ@";s:3:"è®–";s:2:"ÆA";s:3:"艷";s:2:"ÆB";s:3:"è´›";s:2:"ÆC";s:3:"釀";s:2:"ÆD";s:3:"鑪";s:2:"ÆE";s:3:"é‚";s:2:"ÆF";s:3:"éˆ";s:2:"ÆG";s:3:"é„";s:2:"ÆH";s:3:"韆";s:2:"ÆI";s:3:"é¡°";s:2:"ÆJ";s:3:"é©Ÿ";s:2:"ÆK";s:3:"鬢";s:2:"ÆL";s:3:"é­˜";s:2:"ÆM";s:3:"鱟";s:2:"ÆN";s:3:"é·¹";s:2:"ÆO";s:3:"é·º";s:2:"ÆP";s:3:"é¹¼";s:2:"ÆQ";s:3:"é¹½";s:2:"ÆR";s:3:"鼇";s:2:"ÆS";s:3:"é½·";s:2:"ÆT";s:3:"é½²";s:2:"ÆU";s:3:"廳";s:2:"ÆV";s:3:"欖";s:2:"ÆW";s:3:"ç£";s:2:"ÆX";s:3:"籬";s:2:"ÆY";s:3:"ç±®";s:2:"ÆZ";s:3:"è »";s:2:"Æ[";s:3:"觀";s:2:"Æ\";s:3:"躡";s:2:"Æ]";s:3:"é‡";s:2:"Æ^";s:3:"鑲";s:2:"Æ_";s:3:"é‘°";s:2:"Æ`";s:3:"顱";s:2:"Æa";s:3:"饞";s:2:"Æb";s:3:"é«–";s:2:"Æc";s:3:"鬣";s:2:"Æd";s:3:"黌";s:2:"Æe";s:3:"ç¤";s:2:"Æf";s:3:"矚";s:2:"Æg";s:3:"讚";s:2:"Æh";s:3:"é‘·";s:2:"Æi";s:3:"韉";s:2:"Æj";s:3:"é©¢";s:2:"Æk";s:3:"é©¥";s:2:"Æl";s:3:"纜";s:2:"Æm";s:3:"讜";s:2:"Æn";s:3:"躪";s:2:"Æo";s:3:"釅";s:2:"Æp";s:3:"鑽";s:2:"Æq";s:3:"鑾";s:2:"Ær";s:3:"鑼";s:2:"Æs";s:3:"é±·";s:2:"Æt";s:3:"鱸";s:2:"Æu";s:3:"é»·";s:2:"Æv";s:3:"è±”";s:2:"Æw";s:3:"é‘¿";s:2:"Æx";s:3:"鸚";s:2:"Æy";s:3:"爨";s:2:"Æz";s:3:"驪";s:2:"Æ{";s:3:"鬱";s:2:"Æ|";s:3:"鸛";s:2:"Æ}";s:3:"鸞";s:2:"Æ~";s:3:"ç±²";s:2:"Æ¡";s:3:"ヾ";s:2:"Æ¢";s:3:"ã‚";s:2:"Æ£";s:3:"ã‚ž";s:2:"Ƥ";s:3:"々";s:2:"Æ¥";s:3:"ã";s:2:"Ʀ";s:3:"ã‚";s:2:"Ƨ";s:3:"ãƒ";s:2:"ƨ";s:3:"ã„";s:2:"Æ©";s:3:"ã…";s:2:"ƪ";s:3:"ã†";s:2:"Æ«";s:3:"ã‡";s:2:"Ƭ";s:3:"ãˆ";s:2:"Æ­";s:3:"ã‰";s:2:"Æ®";s:3:"ãŠ";s:2:"Ư";s:3:"ã‹";s:2:"Æ°";s:3:"ãŒ";s:2:"Ʊ";s:3:"ã";s:2:"Ʋ";s:3:"ãŽ";s:2:"Ƴ";s:3:"ã";s:2:"Æ´";s:3:"ã";s:2:"Ƶ";s:3:"ã‘";s:2:"ƶ";s:3:"ã’";s:2:"Æ·";s:3:"ã“";s:2:"Ƹ";s:3:"ã”";s:2:"ƹ";s:3:"ã•";s:2:"ƺ";s:3:"ã–";s:2:"Æ»";s:3:"ã—";s:2:"Ƽ";s:3:"ã˜";s:2:"ƽ";s:3:"ã™";s:2:"ƾ";s:3:"ãš";s:2:"Æ¿";s:3:"ã›";s:2:"ÆÀ";s:3:"ãœ";s:2:"ÆÁ";s:3:"ã";s:2:"ÆÂ";s:3:"ãž";s:2:"ÆÃ";s:3:"ãŸ";s:2:"ÆÄ";s:3:"ã ";s:2:"ÆÅ";s:3:"ã¡";s:2:"ÆÆ";s:3:"ã¢";s:2:"ÆÇ";s:3:"ã£";s:2:"ÆÈ";s:3:"ã¤";s:2:"ÆÉ";s:3:"ã¥";s:2:"ÆÊ";s:3:"ã¦";s:2:"ÆË";s:3:"ã§";s:2:"ÆÌ";s:3:"ã¨";s:2:"ÆÍ";s:3:"ã©";s:2:"ÆÎ";s:3:"ãª";s:2:"ÆÏ";s:3:"ã«";s:2:"ÆÐ";s:3:"ã¬";s:2:"ÆÑ";s:3:"ã­";s:2:"ÆÒ";s:3:"ã®";s:2:"ÆÓ";s:3:"ã¯";s:2:"ÆÔ";s:3:"ã°";s:2:"ÆÕ";s:3:"ã±";s:2:"ÆÖ";s:3:"ã²";s:2:"Æ×";s:3:"ã³";s:2:"ÆØ";s:3:"ã´";s:2:"ÆÙ";s:3:"ãµ";s:2:"ÆÚ";s:3:"ã¶";s:2:"ÆÛ";s:3:"ã·";s:2:"ÆÜ";s:3:"ã¸";s:2:"ÆÝ";s:3:"ã¹";s:2:"ÆÞ";s:3:"ãº";s:2:"Æß";s:3:"ã»";s:2:"Æà";s:3:"ã¼";s:2:"Æá";s:3:"ã½";s:2:"Æâ";s:3:"ã¾";s:2:"Æã";s:3:"ã¿";s:2:"Æä";s:3:"ã‚€";s:2:"Æå";s:3:"ã‚";s:2:"Ææ";s:3:"ã‚‚";s:2:"Æç";s:3:"ゃ";s:2:"Æè";s:3:"ã‚„";s:2:"Æé";s:3:"ã‚…";s:2:"Æê";s:3:"ゆ";s:2:"Æë";s:3:"ょ";s:2:"Æì";s:3:"よ";s:2:"Æí";s:3:"ら";s:2:"Æî";s:3:"ã‚Š";s:2:"Æï";s:3:"ã‚‹";s:2:"Æð";s:3:"ã‚Œ";s:2:"Æñ";s:3:"ã‚";s:2:"Æò";s:3:"ã‚Ž";s:2:"Æó";s:3:"ã‚";s:2:"Æô";s:3:"ã‚";s:2:"Æõ";s:3:"ã‚‘";s:2:"Æö";s:3:"ã‚’";s:2:"Æ÷";s:3:"ã‚“";s:2:"Æø";s:3:"ã‚¡";s:2:"Æù";s:3:"ã‚¢";s:2:"Æú";s:3:"ã‚£";s:2:"Æû";s:3:"イ";s:2:"Æü";s:3:"ã‚¥";s:2:"Æý";s:3:"ウ";s:2:"Æþ";s:3:"ェ";s:2:"Ç@";s:3:"エ";s:2:"ÇA";s:3:"ã‚©";s:2:"ÇB";s:3:"オ";s:2:"ÇC";s:3:"ã‚«";s:2:"ÇD";s:3:"ガ";s:2:"ÇE";s:3:"ã‚­";s:2:"ÇF";s:3:"ã‚®";s:2:"ÇG";s:3:"ク";s:2:"ÇH";s:3:"ã‚°";s:2:"ÇI";s:3:"ケ";s:2:"ÇJ";s:3:"ゲ";s:2:"ÇK";s:3:"コ";s:2:"ÇL";s:3:"ã‚´";s:2:"ÇM";s:3:"サ";s:2:"ÇN";s:3:"ザ";s:2:"ÇO";s:3:"ã‚·";s:2:"ÇP";s:3:"ジ";s:2:"ÇQ";s:3:"ス";s:2:"ÇR";s:3:"ズ";s:2:"ÇS";s:3:"ã‚»";s:2:"ÇT";s:3:"ゼ";s:2:"ÇU";s:3:"ソ";s:2:"ÇV";s:3:"ゾ";s:2:"ÇW";s:3:"ã‚¿";s:2:"ÇX";s:3:"ダ";s:2:"ÇY";s:3:"ãƒ";s:2:"ÇZ";s:3:"ヂ";s:2:"Ç[";s:3:"ッ";s:2:"Ç\";s:3:"ツ";s:2:"Ç]";s:3:"ヅ";s:2:"Ç^";s:3:"テ";s:2:"Ç_";s:3:"デ";s:2:"Ç`";s:3:"ト";s:2:"Ça";s:3:"ド";s:2:"Çb";s:3:"ナ";s:2:"Çc";s:3:"ニ";s:2:"Çd";s:3:"ヌ";s:2:"Çe";s:3:"ãƒ";s:2:"Çf";s:3:"ノ";s:2:"Çg";s:3:"ãƒ";s:2:"Çh";s:3:"ãƒ";s:2:"Çi";s:3:"パ";s:2:"Çj";s:3:"ヒ";s:2:"Çk";s:3:"ビ";s:2:"Çl";s:3:"ピ";s:2:"Çm";s:3:"フ";s:2:"Çn";s:3:"ブ";s:2:"Ço";s:3:"プ";s:2:"Çp";s:3:"ヘ";s:2:"Çq";s:3:"ベ";s:2:"Çr";s:3:"ペ";s:2:"Çs";s:3:"ホ";s:2:"Çt";s:3:"ボ";s:2:"Çu";s:3:"ãƒ";s:2:"Çv";s:3:"マ";s:2:"Çw";s:3:"ミ";s:2:"Çx";s:3:"ム";s:2:"Çy";s:3:"メ";s:2:"Çz";s:3:"モ";s:2:"Ç{";s:3:"ャ";s:2:"Ç|";s:3:"ヤ";s:2:"Ç}";s:3:"ュ";s:2:"Ç~";s:3:"ユ";s:2:"Ç¡";s:3:"ョ";s:2:"Ç¢";s:3:"ヨ";s:2:"Ç£";s:3:"ラ";s:2:"Ǥ";s:3:"リ";s:2:"Ç¥";s:3:"ル";s:2:"Ǧ";s:3:"レ";s:2:"ǧ";s:3:"ロ";s:2:"Ǩ";s:3:"ヮ";s:2:"Ç©";s:3:"ワ";s:2:"Ǫ";s:3:"ヰ";s:2:"Ç«";s:3:"ヱ";s:2:"Ǭ";s:3:"ヲ";s:2:"Ç­";s:3:"ン";s:2:"Ç®";s:3:"ヴ";s:2:"ǯ";s:3:"ヵ";s:2:"Ç°";s:3:"ヶ";s:2:"DZ";s:2:"Д";s:2:"Dz";s:2:"Е";s:2:"dz";s:2:"Ð";s:2:"Ç´";s:2:"Ж";s:2:"ǵ";s:2:"З";s:2:"Ƕ";s:2:"И";s:2:"Ç·";s:2:"Й";s:2:"Ǹ";s:2:"К";s:2:"ǹ";s:2:"Л";s:2:"Ǻ";s:2:"Ðœ";s:2:"Ç»";s:2:"У";s:2:"Ǽ";s:2:"Ф";s:2:"ǽ";s:2:"Ð¥";s:2:"Ǿ";s:2:"Ц";s:2:"Ç¿";s:2:"Ч";s:2:"ÇÀ";s:2:"Ш";s:2:"ÇÁ";s:2:"Щ";s:2:"ÇÂ";s:2:"Ъ";s:2:"ÇÃ";s:2:"Ы";s:2:"ÇÄ";s:2:"Ь";s:2:"ÇÅ";s:2:"Э";s:2:"ÇÆ";s:2:"Ю";s:2:"ÇÇ";s:2:"Я";s:2:"ÇÈ";s:2:"а";s:2:"ÇÉ";s:2:"б";s:2:"ÇÊ";s:2:"в";s:2:"ÇË";s:2:"г";s:2:"ÇÌ";s:2:"д";s:2:"ÇÍ";s:2:"е";s:2:"ÇÎ";s:2:"Ñ‘";s:2:"ÇÏ";s:2:"ж";s:2:"ÇÐ";s:2:"з";s:2:"ÇÑ";s:2:"и";s:2:"ÇÒ";s:2:"й";s:2:"ÇÓ";s:2:"к";s:2:"ÇÔ";s:2:"л";s:2:"ÇÕ";s:2:"м";s:2:"ÇÖ";s:2:"н";s:2:"Ç×";s:2:"о";s:2:"ÇØ";s:2:"п";s:2:"ÇÙ";s:2:"Ñ€";s:2:"ÇÚ";s:2:"Ñ";s:2:"ÇÛ";s:2:"Ñ‚";s:2:"ÇÜ";s:2:"у";s:2:"ÇÝ";s:2:"Ñ„";s:2:"ÇÞ";s:2:"Ñ…";s:2:"Çß";s:2:"ц";s:2:"Çà";s:2:"ч";s:2:"Çá";s:2:"ш";s:2:"Çâ";s:2:"щ";s:2:"Çã";s:2:"ÑŠ";s:2:"Çä";s:2:"Ñ‹";s:2:"Çå";s:2:"ÑŒ";s:2:"Çæ";s:2:"Ñ";s:2:"Çç";s:2:"ÑŽ";s:2:"Çè";s:2:"Ñ";s:2:"Çé";s:3:"â‘ ";s:2:"Çê";s:3:"â‘¡";s:2:"Çë";s:3:"â‘¢";s:2:"Çì";s:3:"â‘£";s:2:"Çí";s:3:"⑤";s:2:"Çî";s:3:"â‘¥";s:2:"Çï";s:3:"⑦";s:2:"Çð";s:3:"⑧";s:2:"Çñ";s:3:"⑨";s:2:"Çò";s:3:"â‘©";s:2:"Çó";s:3:"â‘´";s:2:"Çô";s:3:"⑵";s:2:"Çõ";s:3:"⑶";s:2:"Çö";s:3:"â‘·";s:2:"Ç÷";s:3:"⑸";s:2:"Çø";s:3:"⑹";s:2:"Çù";s:3:"⑺";s:2:"Çú";s:3:"â‘»";s:2:"Çû";s:3:"⑼";s:2:"Çü";s:3:"⑽";s:2:"É@";s:3:"乂";s:2:"ÉA";s:3:"乜";s:2:"ÉB";s:3:"凵";s:2:"ÉC";s:3:"匚";s:2:"ÉD";s:3:"厂";s:2:"ÉE";s:3:"万";s:2:"ÉF";s:3:"丌";s:2:"ÉG";s:3:"乇";s:2:"ÉH";s:3:"äº";s:2:"ÉI";s:3:"å›—";s:2:"ÉJ";s:3:"兀";s:2:"ÉK";s:3:"å±®";s:2:"ÉL";s:3:"å½³";s:2:"ÉM";s:3:"ä¸";s:2:"ÉN";s:3:"冇";s:2:"ÉO";s:3:"与";s:2:"ÉP";s:3:"丮";s:2:"ÉQ";s:3:"亓";s:2:"ÉR";s:3:"仂";s:2:"ÉS";s:3:"仉";s:2:"ÉT";s:3:"仈";s:2:"ÉU";s:3:"冘";s:2:"ÉV";s:3:"勼";s:2:"ÉW";s:3:"å¬";s:2:"ÉX";s:3:"厹";s:2:"ÉY";s:3:"圠";s:2:"ÉZ";s:3:"夃";s:2:"É[";s:3:"夬";s:2:"É\";s:3:"å°";s:2:"É]";s:3:"å·¿";s:2:"É^";s:3:"æ—¡";s:2:"É_";s:3:"殳";s:2:"É`";s:3:"毌";s:2:"Éa";s:3:"æ°”";s:2:"Éb";s:3:"爿";s:2:"Éc";s:3:"丱";s:2:"Éd";s:3:"丼";s:2:"Ée";s:3:"仨";s:2:"Éf";s:3:"仜";s:2:"Ég";s:3:"仩";s:2:"Éh";s:3:"仡";s:2:"Éi";s:3:"ä»";s:2:"Éj";s:3:"仚";s:2:"Ék";s:3:"刌";s:2:"Él";s:3:"匜";s:2:"Ém";s:3:"åŒ";s:2:"Én";s:3:"圢";s:2:"Éo";s:3:"圣";s:2:"Ép";s:3:"夗";s:2:"Éq";s:3:"夯";s:2:"Ér";s:3:"å®";s:2:"És";s:3:"宄";s:2:"Ét";s:3:"å°’";s:2:"Éu";s:3:"å°»";s:2:"Év";s:3:"å±´";s:2:"Éw";s:3:"å±³";s:2:"Éx";s:3:"帄";s:2:"Éy";s:3:"庀";s:2:"Éz";s:3:"庂";s:2:"É{";s:3:"忉";s:2:"É|";s:3:"戉";s:2:"É}";s:3:"æ‰";s:2:"É~";s:3:"æ°•";s:2:"É¡";s:3:"æ°¶";s:2:"É¢";s:3:"汃";s:2:"É£";s:3:"æ°¿";s:2:"ɤ";s:3:"æ°»";s:2:"É¥";s:3:"犮";s:2:"ɦ";s:3:"犰";s:2:"ɧ";s:3:"玊";s:2:"ɨ";s:3:"禸";s:2:"É©";s:3:"è‚Š";s:2:"ɪ";s:3:"阞";s:2:"É«";s:3:"伎";s:2:"ɬ";s:3:"优";s:2:"É­";s:3:"伬";s:2:"É®";s:3:"仵";s:2:"ɯ";s:3:"ä¼”";s:2:"É°";s:3:"ä»±";s:2:"ɱ";s:3:"ä¼€";s:2:"ɲ";s:3:"ä»·";s:2:"ɳ";s:3:"伈";s:2:"É´";s:3:"ä¼";s:2:"ɵ";s:3:"伂";s:2:"ɶ";s:3:"ä¼…";s:2:"É·";s:3:"ä¼¢";s:2:"ɸ";s:3:"伓";s:2:"ɹ";s:3:"伄";s:2:"ɺ";s:3:"ä»´";s:2:"É»";s:3:"ä¼’";s:2:"ɼ";s:3:"冱";s:2:"ɽ";s:3:"刓";s:2:"ɾ";s:3:"刉";s:2:"É¿";s:3:"åˆ";s:2:"ÉÀ";s:3:"劦";s:2:"ÉÁ";s:3:"匢";s:2:"ÉÂ";s:3:"匟";s:2:"ÉÃ";s:3:"å";s:2:"ÉÄ";s:3:"厊";s:2:"ÉÅ";s:3:"å‡";s:2:"ÉÆ";s:3:"囡";s:2:"ÉÇ";s:3:"囟";s:2:"ÉÈ";s:3:"圮";s:2:"ÉÉ";s:3:"圪";s:2:"ÉÊ";s:3:"圴";s:2:"ÉË";s:3:"夼";s:2:"ÉÌ";s:3:"妀";s:2:"ÉÍ";s:3:"奼";s:2:"ÉÎ";s:3:"妅";s:2:"ÉÏ";s:3:"奻";s:2:"ÉÐ";s:3:"奾";s:2:"ÉÑ";s:3:"奷";s:2:"ÉÒ";s:3:"奿";s:2:"ÉÓ";s:3:"å­–";s:2:"ÉÔ";s:3:"å°•";s:2:"ÉÕ";s:3:"å°¥";s:2:"ÉÖ";s:3:"å±¼";s:2:"É×";s:3:"屺";s:2:"ÉØ";s:3:"å±»";s:2:"ÉÙ";s:3:"å±¾";s:2:"ÉÚ";s:3:"å·Ÿ";s:2:"ÉÛ";s:3:"å¹µ";s:2:"ÉÜ";s:3:"庄";s:2:"ÉÝ";s:3:"异";s:2:"ÉÞ";s:3:"弚";s:2:"Éß";s:3:"å½´";s:2:"Éà";s:3:"å¿•";s:2:"Éá";s:3:"å¿”";s:2:"Éâ";s:3:"å¿";s:2:"Éã";s:3:"扜";s:2:"Éä";s:3:"扞";s:2:"Éå";s:3:"扤";s:2:"Éæ";s:3:"扡";s:2:"Éç";s:3:"扦";s:2:"Éè";s:3:"扢";s:2:"Éé";s:3:"扙";s:2:"Éê";s:3:"扠";s:2:"Éë";s:3:"扚";s:2:"Éì";s:3:"扥";s:2:"Éí";s:3:"æ—¯";s:2:"Éî";s:3:"æ—®";s:2:"Éï";s:3:"朾";s:2:"Éð";s:3:"朹";s:2:"Éñ";s:3:"朸";s:2:"Éò";s:3:"朻";s:2:"Éó";s:3:"机";s:2:"Éô";s:3:"朿";s:2:"Éõ";s:3:"朼";s:2:"Éö";s:3:"朳";s:2:"É÷";s:3:"æ°˜";s:2:"Éø";s:3:"汆";s:2:"Éù";s:3:"æ±’";s:2:"Éú";s:3:"汜";s:2:"Éû";s:3:"æ±";s:2:"Éü";s:3:"汊";s:2:"Éý";s:3:"æ±”";s:2:"Éþ";s:3:"汋";s:2:"Ê@";s:3:"汌";s:2:"ÊA";s:3:"ç±";s:2:"ÊB";s:3:"牞";s:2:"ÊC";s:3:"犴";s:2:"ÊD";s:3:"犵";s:2:"ÊE";s:3:"玎";s:2:"ÊF";s:3:"甪";s:2:"ÊG";s:3:"癿";s:2:"ÊH";s:3:"穵";s:2:"ÊI";s:3:"网";s:2:"ÊJ";s:3:"艸";s:2:"ÊK";s:3:"艼";s:2:"ÊL";s:3:"芀";s:2:"ÊM";s:3:"艽";s:2:"ÊN";s:3:"艿";s:2:"ÊO";s:3:"è™";s:2:"ÊP";s:3:"襾";s:2:"ÊQ";s:3:"é‚™";s:2:"ÊR";s:3:"é‚—";s:2:"ÊS";s:3:"邘";s:2:"ÊT";s:3:"é‚›";s:2:"ÊU";s:3:"é‚”";s:2:"ÊV";s:3:"阢";s:2:"ÊW";s:3:"阤";s:2:"ÊX";s:3:"阠";s:2:"ÊY";s:3:"阣";s:2:"ÊZ";s:3:"ä½–";s:2:"Ê[";s:3:"ä¼»";s:2:"Ê\";s:3:"ä½¢";s:2:"Ê]";s:3:"佉";s:2:"Ê^";s:3:"体";s:2:"Ê_";s:3:"佤";s:2:"Ê`";s:3:"ä¼¾";s:2:"Êa";s:3:"佧";s:2:"Êb";s:3:"ä½’";s:2:"Êc";s:3:"佟";s:2:"Êd";s:3:"ä½";s:2:"Êe";s:3:"佘";s:2:"Êf";s:3:"ä¼­";s:2:"Êg";s:3:"ä¼³";s:2:"Êh";s:3:"伿";s:2:"Êi";s:3:"佡";s:2:"Êj";s:3:"å†";s:2:"Êk";s:3:"冹";s:2:"Êl";s:3:"刜";s:2:"Êm";s:3:"刞";s:2:"Ên";s:3:"刡";s:2:"Êo";s:3:"劭";s:2:"Êp";s:3:"劮";s:2:"Êq";s:3:"匉";s:2:"Êr";s:3:"å£";s:2:"Ês";s:3:"å²";s:2:"Êt";s:3:"厎";s:2:"Êu";s:3:"åŽ";s:2:"Êv";s:3:"å°";s:2:"Êw";s:3:"å·";s:2:"Êx";s:3:"åª";s:2:"Êy";s:3:"å‘”";s:2:"Êz";s:3:"å‘…";s:2:"Ê{";s:3:"å™";s:2:"Ê|";s:3:"åœ";s:2:"Ê}";s:3:"å¥";s:2:"Ê~";s:3:"å˜";s:2:"Ê¡";s:3:"å½";s:2:"Ê¢";s:3:"å‘";s:2:"Ê£";s:3:"å‘";s:2:"ʤ";s:3:"å¨";s:2:"Ê¥";s:3:"å¤";s:2:"ʦ";s:3:"呇";s:2:"ʧ";s:3:"å›®";s:2:"ʨ";s:3:"囧";s:2:"Ê©";s:3:"囥";s:2:"ʪ";s:3:"å";s:2:"Ê«";s:3:"å…";s:2:"ʬ";s:3:"åŒ";s:2:"Ê­";s:3:"å‰";s:2:"Ê®";s:3:"å‹";s:2:"ʯ";s:3:"å’";s:2:"Ê°";s:3:"夆";s:2:"ʱ";s:3:"奀";s:2:"ʲ";s:3:"妦";s:2:"ʳ";s:3:"妘";s:2:"Ê´";s:3:"妠";s:2:"ʵ";s:3:"妗";s:2:"ʶ";s:3:"妎";s:2:"Ê·";s:3:"妢";s:2:"ʸ";s:3:"å¦";s:2:"ʹ";s:3:"å¦";s:2:"ʺ";s:3:"妧";s:2:"Ê»";s:3:"妡";s:2:"ʼ";s:3:"宎";s:2:"ʽ";s:3:"å®’";s:2:"ʾ";s:3:"å°¨";s:2:"Ê¿";s:3:"å°ª";s:2:"ÊÀ";s:3:"å²";s:2:"ÊÁ";s:3:"å²";s:2:"ÊÂ";s:3:"岈";s:2:"ÊÃ";s:3:"岋";s:2:"ÊÄ";s:3:"岉";s:2:"ÊÅ";s:3:"å²’";s:2:"ÊÆ";s:3:"岊";s:2:"ÊÇ";s:3:"岆";s:2:"ÊÈ";s:3:"岓";s:2:"ÊÉ";s:3:"岕";s:2:"ÊÊ";s:3:"å· ";s:2:"ÊË";s:3:"帊";s:2:"ÊÌ";s:3:"帎";s:2:"ÊÍ";s:3:"庋";s:2:"ÊÎ";s:3:"庉";s:2:"ÊÏ";s:3:"庌";s:2:"ÊÐ";s:3:"庈";s:2:"ÊÑ";s:3:"åº";s:2:"ÊÒ";s:3:"å¼…";s:2:"ÊÓ";s:3:"å¼";s:2:"ÊÔ";s:3:"彸";s:2:"ÊÕ";s:3:"彶";s:2:"ÊÖ";s:3:"å¿’";s:2:"Ê×";s:3:"å¿‘";s:2:"ÊØ";s:3:"å¿";s:2:"ÊÙ";s:3:"å¿­";s:2:"ÊÚ";s:3:"忨";s:2:"ÊÛ";s:3:"å¿®";s:2:"ÊÜ";s:3:"忳";s:2:"ÊÝ";s:3:"å¿¡";s:2:"ÊÞ";s:3:"忤";s:2:"Êß";s:3:"å¿£";s:2:"Êà";s:3:"忺";s:2:"Êá";s:3:"忯";s:2:"Êâ";s:3:"å¿·";s:2:"Êã";s:3:"å¿»";s:2:"Êä";s:3:"怀";s:2:"Êå";s:3:"å¿´";s:2:"Êæ";s:3:"戺";s:2:"Êç";s:3:"抃";s:2:"Êè";s:3:"抌";s:2:"Êé";s:3:"抎";s:2:"Êê";s:3:"æŠ";s:2:"Êë";s:3:"抔";s:2:"Êì";s:3:"抇";s:2:"Êí";s:3:"扱";s:2:"Êî";s:3:"扻";s:2:"Êï";s:3:"扺";s:2:"Êð";s:3:"扰";s:2:"Êñ";s:3:"æŠ";s:2:"Êò";s:3:"抈";s:2:"Êó";s:3:"扷";s:2:"Êô";s:3:"扽";s:2:"Êõ";s:3:"扲";s:2:"Êö";s:3:"扴";s:2:"Ê÷";s:3:"æ”·";s:2:"Êø";s:3:"æ—°";s:2:"Êù";s:3:"æ—´";s:2:"Êú";s:3:"æ—³";s:2:"Êû";s:3:"æ—²";s:2:"Êü";s:3:"æ—µ";s:2:"Êý";s:3:"æ…";s:2:"Êþ";s:3:"æ‡";s:2:"Ë@";s:3:"æ™";s:2:"ËA";s:3:"æ•";s:2:"ËB";s:3:"æŒ";s:2:"ËC";s:3:"æˆ";s:2:"ËD";s:3:"æ";s:2:"ËE";s:3:"æ";s:2:"ËF";s:3:"æš";s:2:"ËG";s:3:"æ‹";s:2:"ËH";s:3:"æ¯";s:2:"ËI";s:3:"æ°™";s:2:"ËJ";s:3:"æ°š";s:2:"ËK";s:3:"汸";s:2:"ËL";s:3:"汧";s:2:"ËM";s:3:"汫";s:2:"ËN";s:3:"沄";s:2:"ËO";s:3:"沋";s:2:"ËP";s:3:"æ²";s:2:"ËQ";s:3:"æ±±";s:2:"ËR";s:3:"汯";s:2:"ËS";s:3:"汩";s:2:"ËT";s:3:"沚";s:2:"ËU";s:3:"æ±­";s:2:"ËV";s:3:"沇";s:2:"ËW";s:3:"沕";s:2:"ËX";s:3:"沜";s:2:"ËY";s:3:"汦";s:2:"ËZ";s:3:"æ±³";s:2:"Ë[";s:3:"æ±¥";s:2:"Ë\";s:3:"æ±»";s:2:"Ë]";s:3:"沎";s:2:"Ë^";s:3:"ç´";s:2:"Ë_";s:3:"çº";s:2:"Ë`";s:3:"牣";s:2:"Ëa";s:3:"犿";s:2:"Ëb";s:3:"犽";s:2:"Ëc";s:3:"狃";s:2:"Ëd";s:3:"狆";s:2:"Ëe";s:3:"ç‹";s:2:"Ëf";s:3:"犺";s:2:"Ëg";s:3:"ç‹…";s:2:"Ëh";s:3:"玕";s:2:"Ëi";s:3:"玗";s:2:"Ëj";s:3:"玓";s:2:"Ëk";s:3:"玔";s:2:"Ël";s:3:"玒";s:2:"Ëm";s:3:"町";s:2:"Ën";s:3:"甹";s:2:"Ëo";s:3:"ç–”";s:2:"Ëp";s:3:"ç–•";s:2:"Ëq";s:3:"çš";s:2:"Ër";s:3:"礽";s:2:"Ës";s:3:"耴";s:2:"Ët";s:3:"è‚•";s:2:"Ëu";s:3:"è‚™";s:2:"Ëv";s:3:"è‚";s:2:"Ëw";s:3:"è‚’";s:2:"Ëx";s:3:"è‚œ";s:2:"Ëy";s:3:"èŠ";s:2:"Ëz";s:3:"èŠ";s:2:"Ë{";s:3:"芅";s:2:"Ë|";s:3:"芎";s:2:"Ë}";s:3:"芑";s:2:"Ë~";s:3:"芓";s:2:"Ë¡";s:3:"芊";s:2:"Ë¢";s:3:"芃";s:2:"Ë£";s:3:"芄";s:2:"ˤ";s:3:"豸";s:2:"Ë¥";s:3:"迉";s:2:"˦";s:3:"辿";s:2:"˧";s:3:"é‚Ÿ";s:2:"˨";s:3:"é‚¡";s:2:"Ë©";s:3:"é‚¥";s:2:"˪";s:3:"é‚ž";s:2:"Ë«";s:3:"邧";s:2:"ˬ";s:3:"é‚ ";s:2:"Ë­";s:3:"阰";s:2:"Ë®";s:3:"阨";s:2:"˯";s:3:"阯";s:2:"Ë°";s:3:"阭";s:2:"˱";s:3:"丳";s:2:"˲";s:3:"侘";s:2:"˳";s:3:"ä½¼";s:2:"Ë´";s:3:"ä¾…";s:2:"˵";s:3:"ä½½";s:2:"˶";s:3:"ä¾€";s:2:"Ë·";s:3:"侇";s:2:"˸";s:3:"佶";s:2:"˹";s:3:"ä½´";s:2:"˺";s:3:"侉";s:2:"Ë»";s:3:"侄";s:2:"˼";s:3:"ä½·";s:2:"˽";s:3:"佌";s:2:"˾";s:3:"ä¾—";s:2:"Ë¿";s:3:"佪";s:2:"ËÀ";s:3:"侚";s:2:"ËÁ";s:3:"ä½¹";s:2:"ËÂ";s:3:"ä¾";s:2:"ËÃ";s:3:"佸";s:2:"ËÄ";s:3:"ä¾";s:2:"ËÅ";s:3:"侜";s:2:"ËÆ";s:3:"ä¾”";s:2:"ËÇ";s:3:"侞";s:2:"ËÈ";s:3:"ä¾’";s:2:"ËÉ";s:3:"侂";s:2:"ËÊ";s:3:"侕";s:2:"ËË";s:3:"佫";s:2:"ËÌ";s:3:"ä½®";s:2:"ËÍ";s:3:"冞";s:2:"ËÎ";s:3:"冼";s:2:"ËÏ";s:3:"冾";s:2:"ËÐ";s:3:"刵";s:2:"ËÑ";s:3:"刲";s:2:"ËÒ";s:3:"刳";s:2:"ËÓ";s:3:"剆";s:2:"ËÔ";s:3:"刱";s:2:"ËÕ";s:3:"劼";s:2:"ËÖ";s:3:"匊";s:2:"Ë×";s:3:"匋";s:2:"ËØ";s:3:"匼";s:2:"ËÙ";s:3:"厒";s:2:"ËÚ";s:3:"厔";s:2:"ËÛ";s:3:"å’‡";s:2:"ËÜ";s:3:"å‘¿";s:2:"ËÝ";s:3:"å’";s:2:"ËÞ";s:3:"å’‘";s:2:"Ëß";s:3:"å’‚";s:2:"Ëà";s:3:"å’ˆ";s:2:"Ëá";s:3:"å‘«";s:2:"Ëâ";s:3:"呺";s:2:"Ëã";s:3:"呾";s:2:"Ëä";s:3:"å‘¥";s:2:"Ëå";s:3:"呬";s:2:"Ëæ";s:3:"å‘´";s:2:"Ëç";s:3:"呦";s:2:"Ëè";s:3:"å’";s:2:"Ëé";s:3:"呯";s:2:"Ëê";s:3:"å‘¡";s:2:"Ëë";s:3:"å‘ ";s:2:"Ëì";s:3:"å’˜";s:2:"Ëí";s:3:"å‘£";s:2:"Ëî";s:3:"呧";s:2:"Ëï";s:3:"呤";s:2:"Ëð";s:3:"å›·";s:2:"Ëñ";s:3:"囹";s:2:"Ëò";s:3:"å¯";s:2:"Ëó";s:3:"å²";s:2:"Ëô";s:3:"å­";s:2:"Ëõ";s:3:"å«";s:2:"Ëö";s:3:"å±";s:2:"Ë÷";s:3:"å°";s:2:"Ëø";s:3:"å¶";s:2:"Ëù";s:3:"垀";s:2:"Ëú";s:3:"åµ";s:2:"Ëû";s:3:"å»";s:2:"Ëü";s:3:"å³";s:2:"Ëý";s:3:"å´";s:2:"Ëþ";s:3:"å¢";s:2:"Ì@";s:3:"å¨";s:2:"ÌA";s:3:"å½";s:2:"ÌB";s:3:"夌";s:2:"ÌC";s:3:"奅";s:2:"ÌD";s:3:"妵";s:2:"ÌE";s:3:"妺";s:2:"ÌF";s:3:"å§";s:2:"ÌG";s:3:"姎";s:2:"ÌH";s:3:"妲";s:2:"ÌI";s:3:"姌";s:2:"ÌJ";s:3:"å§";s:2:"ÌK";s:3:"妶";s:2:"ÌL";s:3:"妼";s:2:"ÌM";s:3:"姃";s:2:"ÌN";s:3:"姖";s:2:"ÌO";s:3:"妱";s:2:"ÌP";s:3:"妽";s:2:"ÌQ";s:3:"姀";s:2:"ÌR";s:3:"姈";s:2:"ÌS";s:3:"妴";s:2:"ÌT";s:3:"姇";s:2:"ÌU";s:3:"å­¢";s:2:"ÌV";s:3:"å­¥";s:2:"ÌW";s:3:"宓";s:2:"ÌX";s:3:"宕";s:2:"ÌY";s:3:"屄";s:2:"ÌZ";s:3:"屇";s:2:"Ì[";s:3:"å²®";s:2:"Ì\";s:3:"岤";s:2:"Ì]";s:3:"å² ";s:2:"Ì^";s:3:"å²µ";s:2:"Ì_";s:3:"岯";s:2:"Ì`";s:3:"岨";s:2:"Ìa";s:3:"岬";s:2:"Ìb";s:3:"岟";s:2:"Ìc";s:3:"å²£";s:2:"Ìd";s:3:"å²­";s:2:"Ìe";s:3:"å²¢";s:2:"Ìf";s:3:"岪";s:2:"Ìg";s:3:"岧";s:2:"Ìh";s:3:"å²";s:2:"Ìi";s:3:"å²¥";s:2:"Ìj";s:3:"岶";s:2:"Ìk";s:3:"å²°";s:2:"Ìl";s:3:"岦";s:2:"Ìm";s:3:"帗";s:2:"Ìn";s:3:"帔";s:2:"Ìo";s:3:"帙";s:2:"Ìp";s:3:"弨";s:2:"Ìq";s:3:"å¼¢";s:2:"Ìr";s:3:"å¼£";s:2:"Ìs";s:3:"弤";s:2:"Ìt";s:3:"å½”";s:2:"Ìu";s:3:"徂";s:2:"Ìv";s:3:"å½¾";s:2:"Ìw";s:3:"å½½";s:2:"Ìx";s:3:"å¿ž";s:2:"Ìy";s:3:"å¿¥";s:2:"Ìz";s:3:"怭";s:2:"Ì{";s:3:"怦";s:2:"Ì|";s:3:"怙";s:2:"Ì}";s:3:"怲";s:2:"Ì~";s:3:"怋";s:2:"Ì¡";s:3:"怴";s:2:"Ì¢";s:3:"怊";s:2:"Ì£";s:3:"怗";s:2:"̤";s:3:"怳";s:2:"Ì¥";s:3:"怚";s:2:"̦";s:3:"怞";s:2:"̧";s:3:"怬";s:2:"̨";s:3:"怢";s:2:"Ì©";s:3:"æ€";s:2:"̪";s:3:"æ€";s:2:"Ì«";s:3:"怮";s:2:"̬";s:3:"怓";s:2:"Ì­";s:3:"怑";s:2:"Ì®";s:3:"怌";s:2:"̯";s:3:"怉";s:2:"Ì°";s:3:"怜";s:2:"̱";s:3:"戔";s:2:"̲";s:3:"戽";s:2:"̳";s:3:"抭";s:2:"Ì´";s:3:"抴";s:2:"̵";s:3:"æ‹‘";s:2:"̶";s:3:"抾";s:2:"Ì·";s:3:"抪";s:2:"̸";s:3:"抶";s:2:"̹";s:3:"æ‹Š";s:2:"̺";s:3:"抮";s:2:"Ì»";s:3:"抳";s:2:"̼";s:3:"抯";s:2:"̽";s:3:"抻";s:2:"̾";s:3:"抩";s:2:"Ì¿";s:3:"抰";s:2:"ÌÀ";s:3:"抸";s:2:"ÌÁ";s:3:"攽";s:2:"ÌÂ";s:3:"æ–¨";s:2:"ÌÃ";s:3:"æ–»";s:2:"ÌÄ";s:3:"昉";s:2:"ÌÅ";s:3:"æ—¼";s:2:"ÌÆ";s:3:"昄";s:2:"ÌÇ";s:3:"昒";s:2:"ÌÈ";s:3:"昈";s:2:"ÌÉ";s:3:"æ—»";s:2:"ÌÊ";s:3:"昃";s:2:"ÌË";s:3:"昋";s:2:"ÌÌ";s:3:"æ˜";s:2:"ÌÍ";s:3:"昅";s:2:"ÌÎ";s:3:"æ—½";s:2:"ÌÏ";s:3:"昑";s:2:"ÌÐ";s:3:"æ˜";s:2:"ÌÑ";s:3:"曶";s:2:"ÌÒ";s:3:"朊";s:2:"ÌÓ";s:3:"æž…";s:2:"ÌÔ";s:3:"æ¬";s:2:"ÌÕ";s:3:"枎";s:2:"ÌÖ";s:3:"æž’";s:2:"Ì×";s:3:"æ¶";s:2:"ÌØ";s:3:"æ»";s:2:"ÌÙ";s:3:"枘";s:2:"ÌÚ";s:3:"枆";s:2:"ÌÛ";s:3:"æž„";s:2:"ÌÜ";s:3:"æ´";s:2:"ÌÝ";s:3:"æž";s:2:"ÌÞ";s:3:"枌";s:2:"Ìß";s:3:"æº";s:2:"Ìà";s:3:"枟";s:2:"Ìá";s:3:"æž‘";s:2:"Ìâ";s:3:"æž™";s:2:"Ìã";s:3:"枃";s:2:"Ìä";s:3:"æ½";s:2:"Ìå";s:3:"æž";s:2:"Ìæ";s:3:"æ¸";s:2:"Ìç";s:3:"æ¹";s:2:"Ìè";s:3:"æž”";s:2:"Ìé";s:3:"欥";s:2:"Ìê";s:3:"殀";s:2:"Ìë";s:3:"æ­¾";s:2:"Ìì";s:3:"毞";s:2:"Ìí";s:3:"æ°";s:2:"Ìî";s:3:"沓";s:2:"Ìï";s:3:"泬";s:2:"Ìð";s:3:"泫";s:2:"Ìñ";s:3:"æ³®";s:2:"Ìò";s:3:"æ³™";s:2:"Ìó";s:3:"沶";s:2:"Ìô";s:3:"æ³”";s:2:"Ìõ";s:3:"æ²­";s:2:"Ìö";s:3:"泧";s:2:"Ì÷";s:3:"æ²·";s:2:"Ìø";s:3:"æ³";s:2:"Ìù";s:3:"泂";s:2:"Ìú";s:3:"沺";s:2:"Ìû";s:3:"泃";s:2:"Ìü";s:3:"泆";s:2:"Ìý";s:3:"æ³­";s:2:"Ìþ";s:3:"æ³²";s:2:"Í@";s:3:"æ³’";s:2:"ÍA";s:3:"æ³";s:2:"ÍB";s:3:"æ²´";s:2:"ÍC";s:3:"沊";s:2:"ÍD";s:3:"æ²";s:2:"ÍE";s:3:"æ²€";s:2:"ÍF";s:3:"泞";s:2:"ÍG";s:3:"æ³€";s:2:"ÍH";s:3:"æ´°";s:2:"ÍI";s:3:"æ³";s:2:"ÍJ";s:3:"泇";s:2:"ÍK";s:3:"æ²°";s:2:"ÍL";s:3:"æ³¹";s:2:"ÍM";s:3:"æ³";s:2:"ÍN";s:3:"泩";s:2:"ÍO";s:3:"泑";s:2:"ÍP";s:3:"ç‚”";s:2:"ÍQ";s:3:"炘";s:2:"ÍR";s:3:"ç‚…";s:2:"ÍS";s:3:"ç‚“";s:2:"ÍT";s:3:"炆";s:2:"ÍU";s:3:"ç‚„";s:2:"ÍV";s:3:"ç‚‘";s:2:"ÍW";s:3:"ç‚–";s:2:"ÍX";s:3:"ç‚‚";s:2:"ÍY";s:3:"ç‚š";s:2:"ÍZ";s:3:"炃";s:2:"Í[";s:3:"牪";s:2:"Í\";s:3:"ç‹–";s:2:"Í]";s:3:"ç‹‹";s:2:"Í^";s:3:"狘";s:2:"Í_";s:3:"狉";s:2:"Í`";s:3:"ç‹œ";s:2:"Ía";s:3:"ç‹’";s:2:"Íb";s:3:"ç‹”";s:2:"Íc";s:3:"ç‹š";s:2:"Íd";s:3:"ç‹Œ";s:2:"Íe";s:3:"ç‹‘";s:2:"Íf";s:3:"玤";s:2:"Íg";s:3:"玡";s:2:"Íh";s:3:"玭";s:2:"Íi";s:3:"玦";s:2:"Íj";s:3:"玢";s:2:"Ík";s:3:"玠";s:2:"Íl";s:3:"玬";s:2:"Ím";s:3:"çŽ";s:2:"Ín";s:3:"ç“";s:2:"Ío";s:3:"瓨";s:2:"Íp";s:3:"甿";s:2:"Íq";s:3:"ç•€";s:2:"Ír";s:3:"甾";s:2:"Ís";s:3:"ç–Œ";s:2:"Ít";s:3:"ç–˜";s:2:"Íu";s:3:"皯";s:2:"Ív";s:3:"盳";s:2:"Íw";s:3:"ç›±";s:2:"Íx";s:3:"ç›°";s:2:"Íy";s:3:"盵";s:2:"Íz";s:3:"矸";s:2:"Í{";s:3:"矼";s:2:"Í|";s:3:"矹";s:2:"Í}";s:3:"矻";s:2:"Í~";s:3:"矺";s:2:"Í¡";s:3:"矷";s:2:"Í¢";s:3:"祂";s:2:"Í£";s:3:"礿";s:2:"ͤ";s:3:"秅";s:2:"Í¥";s:3:"穸";s:2:"ͦ";s:3:"ç©»";s:2:"ͧ";s:3:"ç«»";s:2:"ͨ";s:3:"ç±µ";s:2:"Í©";s:3:"ç³½";s:2:"ͪ";s:3:"耵";s:2:"Í«";s:3:"è‚";s:2:"ͬ";s:3:"è‚®";s:2:"Í­";s:3:"è‚£";s:2:"Í®";s:3:"肸";s:2:"ͯ";s:3:"肵";s:2:"Í°";s:3:"è‚­";s:2:"ͱ";s:3:"舠";s:2:"Ͳ";s:3:"芠";s:2:"ͳ";s:3:"è‹€";s:2:"Í´";s:3:"芫";s:2:"͵";s:3:"芚";s:2:"Ͷ";s:3:"芘";s:2:"Í·";s:3:"芛";s:2:"͸";s:3:"芵";s:2:"͹";s:3:"芧";s:2:"ͺ";s:3:"芮";s:2:"Í»";s:3:"芼";s:2:"ͼ";s:3:"芞";s:2:"ͽ";s:3:"芺";s:2:";";s:3:"芴";s:2:"Í¿";s:3:"芨";s:2:"ÍÀ";s:3:"芡";s:2:"ÍÁ";s:3:"芩";s:2:"ÍÂ";s:3:"è‹‚";s:2:"ÍÃ";s:3:"芤";s:2:"ÍÄ";s:3:"苃";s:2:"ÍÅ";s:3:"芶";s:2:"ÍÆ";s:3:"芢";s:2:"ÍÇ";s:3:"è™°";s:2:"ÍÈ";s:3:"虯";s:2:"ÍÉ";s:3:"è™­";s:2:"ÍÊ";s:3:"è™®";s:2:"ÍË";s:3:"è±–";s:2:"ÍÌ";s:3:"è¿’";s:2:"ÍÍ";s:3:"è¿‹";s:2:"ÍÎ";s:3:"è¿“";s:2:"ÍÏ";s:3:"è¿";s:2:"ÍÐ";s:3:"è¿–";s:2:"ÍÑ";s:3:"è¿•";s:2:"ÍÒ";s:3:"è¿—";s:2:"ÍÓ";s:3:"邲";s:2:"ÍÔ";s:3:"é‚´";s:2:"ÍÕ";s:3:"邯";s:2:"ÍÖ";s:3:"邳";s:2:"Í×";s:3:"é‚°";s:2:"ÍØ";s:3:"阹";s:2:"ÍÙ";s:3:"阽";s:2:"ÍÚ";s:3:"阼";s:2:"ÍÛ";s:3:"阺";s:2:"ÍÜ";s:3:"陃";s:2:"ÍÝ";s:3:"ä¿";s:2:"ÍÞ";s:3:"ä¿…";s:2:"Íß";s:3:"ä¿“";s:2:"Íà";s:3:"ä¾²";s:2:"Íá";s:3:"俉";s:2:"Íâ";s:3:"ä¿‹";s:2:"Íã";s:3:"ä¿";s:2:"Íä";s:3:"ä¿”";s:2:"Íå";s:3:"ä¿œ";s:2:"Íæ";s:3:"ä¿™";s:2:"Íç";s:3:"ä¾»";s:2:"Íè";s:3:"ä¾³";s:2:"Íé";s:3:"ä¿›";s:2:"Íê";s:3:"俇";s:2:"Íë";s:3:"ä¿–";s:2:"Íì";s:3:"侺";s:2:"Íí";s:3:"ä¿€";s:2:"Íî";s:3:"ä¾¹";s:2:"Íï";s:3:"俬";s:2:"Íð";s:3:"剄";s:2:"Íñ";s:3:"剉";s:2:"Íò";s:3:"å‹€";s:2:"Íó";s:3:"å‹‚";s:2:"Íô";s:3:"匽";s:2:"Íõ";s:3:"å¼";s:2:"Íö";s:3:"厗";s:2:"Í÷";s:3:"厖";s:2:"Íø";s:3:"厙";s:2:"Íù";s:3:"厘";s:2:"Íú";s:3:"å’º";s:2:"Íû";s:3:"å’¡";s:2:"Íü";s:3:"å’­";s:2:"Íý";s:3:"å’¥";s:2:"Íþ";s:3:"å“";s:2:"Î@";s:3:"哃";s:2:"ÎA";s:3:"èŒ";s:2:"ÎB";s:3:"å’·";s:2:"ÎC";s:3:"å’®";s:2:"ÎD";s:3:"å“–";s:2:"ÎE";s:3:"å’¶";s:2:"ÎF";s:3:"å“…";s:2:"ÎG";s:3:"哆";s:2:"ÎH";s:3:"å’ ";s:2:"ÎI";s:3:"å‘°";s:2:"ÎJ";s:3:"å’¼";s:2:"ÎK";s:3:"å’¢";s:2:"ÎL";s:3:"å’¾";s:2:"ÎM";s:3:"呲";s:2:"ÎN";s:3:"å“ž";s:2:"ÎO";s:3:"å’°";s:2:"ÎP";s:3:"åžµ";s:2:"ÎQ";s:3:"åžž";s:2:"ÎR";s:3:"垟";s:2:"ÎS";s:3:"垤";s:2:"ÎT";s:3:"垌";s:2:"ÎU";s:3:"åž—";s:2:"ÎV";s:3:"åž";s:2:"ÎW";s:3:"åž›";s:2:"ÎX";s:3:"åž”";s:2:"ÎY";s:3:"垘";s:2:"ÎZ";s:3:"åž";s:2:"Î[";s:3:"åž™";s:2:"Î\";s:3:"垥";s:2:"Î]";s:3:"åžš";s:2:"Î^";s:3:"åž•";s:2:"Î_";s:3:"壴";s:2:"Î`";s:3:"å¤";s:2:"Îa";s:3:"奓";s:2:"Îb";s:3:"姡";s:2:"Îc";s:3:"姞";s:2:"Îd";s:3:"姮";s:2:"Îe";s:3:"娀";s:2:"Îf";s:3:"姱";s:2:"Îg";s:3:"å§";s:2:"Îh";s:3:"姺";s:2:"Îi";s:3:"姽";s:2:"Îj";s:3:"姼";s:2:"Îk";s:3:"姶";s:2:"Îl";s:3:"姤";s:2:"Îm";s:3:"姲";s:2:"În";s:3:"姷";s:2:"Îo";s:3:"姛";s:2:"Îp";s:3:"姩";s:2:"Îq";s:3:"姳";s:2:"Îr";s:3:"姵";s:2:"Îs";s:3:"姠";s:2:"Ît";s:3:"姾";s:2:"Îu";s:3:"姴";s:2:"Îv";s:3:"姭";s:2:"Îw";s:3:"宨";s:2:"Îx";s:3:"屌";s:2:"Îy";s:3:"å³";s:2:"Îz";s:3:"峘";s:2:"Î{";s:3:"峌";s:2:"Î|";s:3:"å³—";s:2:"Î}";s:3:"峋";s:2:"Î~";s:3:"å³›";s:2:"Ρ";s:3:"峞";s:2:"΢";s:3:"峚";s:2:"Σ";s:3:"峉";s:2:"Τ";s:3:"峇";s:2:"Î¥";s:3:"峊";s:2:"Φ";s:3:"å³–";s:2:"Χ";s:3:"峓";s:2:"Ψ";s:3:"å³”";s:2:"Ω";s:3:"å³";s:2:"Ϊ";s:3:"峈";s:2:"Ϋ";s:3:"峆";s:2:"ά";s:3:"峎";s:2:"έ";s:3:"峟";s:2:"ή";s:3:"峸";s:2:"ί";s:3:"å·¹";s:2:"ΰ";s:3:"帡";s:2:"α";s:3:"帢";s:2:"β";s:3:"帣";s:2:"γ";s:3:"帠";s:2:"δ";s:3:"帤";s:2:"ε";s:3:"庰";s:2:"ζ";s:3:"庤";s:2:"η";s:3:"庢";s:2:"θ";s:3:"庛";s:2:"ι";s:3:"庣";s:2:"κ";s:3:"庥";s:2:"λ";s:3:"弇";s:2:"μ";s:3:"å¼®";s:2:"ν";s:3:"å½–";s:2:"ξ";s:3:"徆";s:2:"ο";s:3:"怷";s:2:"ÎÀ";s:3:"怹";s:2:"ÎÁ";s:3:"æ”";s:2:"ÎÂ";s:3:"æ²";s:2:"ÎÃ";s:3:"æž";s:2:"ÎÄ";s:3:"æ…";s:2:"ÎÅ";s:3:"æ“";s:2:"ÎÆ";s:3:"æ‡";s:2:"ÎÇ";s:3:"æ‰";s:2:"ÎÈ";s:3:"æ›";s:2:"ÎÉ";s:3:"æŒ";s:2:"ÎÊ";s:3:"æ€";s:2:"ÎË";s:3:"æ‚";s:2:"ÎÌ";s:3:"æŸ";s:2:"ÎÍ";s:3:"怤";s:2:"ÎÎ";s:3:"æ„";s:2:"ÎÏ";s:3:"æ˜";s:2:"ÎÐ";s:3:"æ¦";s:2:"ÎÑ";s:3:"æ®";s:2:"ÎÒ";s:3:"扂";s:2:"ÎÓ";s:3:"扃";s:2:"ÎÔ";s:3:"æ‹";s:2:"ÎÕ";s:3:"æŒ";s:2:"ÎÖ";s:3:"挋";s:2:"Î×";s:3:"拵";s:2:"ÎØ";s:3:"挎";s:2:"ÎÙ";s:3:"挃";s:2:"ÎÚ";s:3:"æ‹«";s:2:"ÎÛ";s:3:"拹";s:2:"ÎÜ";s:3:"æŒ";s:2:"ÎÝ";s:3:"挌";s:2:"ÎÞ";s:3:"拸";s:2:"Îß";s:3:"拶";s:2:"Îà";s:3:"挀";s:2:"Îá";s:3:"挓";s:2:"Îâ";s:3:"挔";s:2:"Îã";s:3:"拺";s:2:"Îä";s:3:"挕";s:2:"Îå";s:3:"æ‹»";s:2:"Îæ";s:3:"æ‹°";s:2:"Îç";s:3:"æ•";s:2:"Îè";s:3:"敃";s:2:"Îé";s:3:"æ–ª";s:2:"Îê";s:3:"æ–¿";s:2:"Îë";s:3:"昶";s:2:"Îì";s:3:"昡";s:2:"Îí";s:3:"昲";s:2:"Îî";s:3:"昵";s:2:"Îï";s:3:"昜";s:2:"Îð";s:3:"昦";s:2:"Îñ";s:3:"昢";s:2:"Îò";s:3:"昳";s:2:"Îó";s:3:"昫";s:2:"Îô";s:3:"昺";s:2:"Îõ";s:3:"æ˜";s:2:"Îö";s:3:"昴";s:2:"Î÷";s:3:"昹";s:2:"Îø";s:3:"昮";s:2:"Îù";s:3:"æœ";s:2:"Îú";s:3:"æœ";s:2:"Îû";s:3:"æŸ";s:2:"Îü";s:3:"柲";s:2:"Îý";s:3:"柈";s:2:"Îþ";s:3:"枺";s:2:"Ï@";s:3:"柜";s:2:"ÏA";s:3:"æž»";s:2:"ÏB";s:3:"柸";s:2:"ÏC";s:3:"柘";s:2:"ÏD";s:3:"柀";s:2:"ÏE";s:3:"æž·";s:2:"ÏF";s:3:"柅";s:2:"ÏG";s:3:"柫";s:2:"ÏH";s:3:"柤";s:2:"ÏI";s:3:"柟";s:2:"ÏJ";s:3:"æžµ";s:2:"ÏK";s:3:"æŸ";s:2:"ÏL";s:3:"æž³";s:2:"ÏM";s:3:"柷";s:2:"ÏN";s:3:"柶";s:2:"ÏO";s:3:"柮";s:2:"ÏP";s:3:"柣";s:2:"ÏQ";s:3:"柂";s:2:"ÏR";s:3:"æž¹";s:2:"ÏS";s:3:"柎";s:2:"ÏT";s:3:"柧";s:2:"ÏU";s:3:"柰";s:2:"ÏV";s:3:"æž²";s:2:"ÏW";s:3:"柼";s:2:"ÏX";s:3:"柆";s:2:"ÏY";s:3:"柭";s:2:"ÏZ";s:3:"柌";s:2:"Ï[";s:3:"æž®";s:2:"Ï\";s:3:"柦";s:2:"Ï]";s:3:"柛";s:2:"Ï^";s:3:"柺";s:2:"Ï_";s:3:"柉";s:2:"Ï`";s:3:"柊";s:2:"Ïa";s:3:"柃";s:2:"Ïb";s:3:"柪";s:2:"Ïc";s:3:"柋";s:2:"Ïd";s:3:"欨";s:2:"Ïe";s:3:"殂";s:2:"Ïf";s:3:"殄";s:2:"Ïg";s:3:"殶";s:2:"Ïh";s:3:"毖";s:2:"Ïi";s:3:"毘";s:2:"Ïj";s:3:"毠";s:2:"Ïk";s:3:"æ° ";s:2:"Ïl";s:3:"æ°¡";s:2:"Ïm";s:3:"æ´¨";s:2:"Ïn";s:3:"æ´´";s:2:"Ïo";s:3:"æ´­";s:2:"Ïp";s:3:"æ´Ÿ";s:2:"Ïq";s:3:"æ´¼";s:2:"Ïr";s:3:"æ´¿";s:2:"Ïs";s:3:"æ´’";s:2:"Ït";s:3:"æ´Š";s:2:"Ïu";s:3:"泚";s:2:"Ïv";s:3:"æ´³";s:2:"Ïw";s:3:"æ´„";s:2:"Ïx";s:3:"æ´™";s:2:"Ïy";s:3:"æ´º";s:2:"Ïz";s:3:"æ´š";s:2:"Ï{";s:3:"æ´‘";s:2:"Ï|";s:3:"æ´€";s:2:"Ï}";s:3:"æ´";s:2:"Ï~";s:3:"浂";s:2:"Ï¡";s:3:"æ´";s:2:"Ï¢";s:3:"æ´˜";s:2:"Ï£";s:3:"æ´·";s:2:"Ϥ";s:3:"æ´ƒ";s:2:"Ï¥";s:3:"æ´";s:2:"Ϧ";s:3:"æµ€";s:2:"ϧ";s:3:"æ´‡";s:2:"Ϩ";s:3:"æ´ ";s:2:"Ï©";s:3:"æ´¬";s:2:"Ϫ";s:3:"æ´ˆ";s:2:"Ï«";s:3:"æ´¢";s:2:"Ϭ";s:3:"æ´‰";s:2:"Ï­";s:3:"æ´";s:2:"Ï®";s:3:"ç‚·";s:2:"ϯ";s:3:"ç‚Ÿ";s:2:"Ï°";s:3:"炾";s:2:"ϱ";s:3:"炱";s:2:"ϲ";s:3:"ç‚°";s:2:"ϳ";s:3:"ç‚¡";s:2:"Ï´";s:3:"ç‚´";s:2:"ϵ";s:3:"炵";s:2:"϶";s:3:"ç‚©";s:2:"Ï·";s:3:"ç‰";s:2:"ϸ";s:3:"牉";s:2:"Ϲ";s:3:"牊";s:2:"Ϻ";s:3:"牬";s:2:"Ï»";s:3:"牰";s:2:"ϼ";s:3:"牳";s:2:"Ͻ";s:3:"牮";s:2:"Ͼ";s:3:"ç‹Š";s:2:"Ï¿";s:3:"狤";s:2:"ÏÀ";s:3:"狨";s:2:"ÏÁ";s:3:"ç‹«";s:2:"ÏÂ";s:3:"ç‹Ÿ";s:2:"ÏÃ";s:3:"狪";s:2:"ÏÄ";s:3:"狦";s:2:"ÏÅ";s:3:"ç‹£";s:2:"ÏÆ";s:3:"玅";s:2:"ÏÇ";s:3:"çŒ";s:2:"ÏÈ";s:3:"ç‚";s:2:"ÏÉ";s:3:"çˆ";s:2:"ÏÊ";s:3:"ç…";s:2:"ÏË";s:3:"玹";s:2:"ÏÌ";s:3:"玶";s:2:"ÏÍ";s:3:"玵";s:2:"ÏÎ";s:3:"玴";s:2:"ÏÏ";s:3:"ç«";s:2:"ÏÐ";s:3:"玿";s:2:"ÏÑ";s:3:"ç‡";s:2:"ÏÒ";s:3:"玾";s:2:"ÏÓ";s:3:"çƒ";s:2:"ÏÔ";s:3:"ç†";s:2:"ÏÕ";s:3:"玸";s:2:"ÏÖ";s:3:"ç‹";s:2:"Ï×";s:3:"瓬";s:2:"ÏØ";s:3:"ç“®";s:2:"ÏÙ";s:3:"ç”®";s:2:"ÏÚ";s:3:"畇";s:2:"ÏÛ";s:3:"畈";s:2:"ÏÜ";s:3:"ç–§";s:2:"ÏÝ";s:3:"ç–ª";s:2:"ÏÞ";s:3:"癹";s:2:"Ïß";s:3:"盄";s:2:"Ïà";s:3:"眈";s:2:"Ïá";s:3:"眃";s:2:"Ïâ";s:3:"眄";s:2:"Ïã";s:3:"眅";s:2:"Ïä";s:3:"眊";s:2:"Ïå";s:3:"ç›·";s:2:"Ïæ";s:3:"ç›»";s:2:"Ïç";s:3:"盺";s:2:"Ïè";s:3:"矧";s:2:"Ïé";s:3:"矨";s:2:"Ïê";s:3:"ç †";s:2:"Ïë";s:3:"ç ‘";s:2:"Ïì";s:3:"ç ’";s:2:"Ïí";s:3:"ç …";s:2:"Ïî";s:3:"ç ";s:2:"Ïï";s:3:"ç ";s:2:"Ïð";s:3:"ç Ž";s:2:"Ïñ";s:3:"ç ‰";s:2:"Ïò";s:3:"ç ƒ";s:2:"Ïó";s:3:"ç “";s:2:"Ïô";s:3:"祊";s:2:"Ïõ";s:3:"祌";s:2:"Ïö";s:3:"祋";s:2:"Ï÷";s:3:"祅";s:2:"Ïø";s:3:"祄";s:2:"Ïù";s:3:"秕";s:2:"Ïú";s:3:"ç§";s:2:"Ïû";s:3:"ç§";s:2:"Ïü";s:3:"秖";s:2:"Ïý";s:3:"秎";s:2:"Ïþ";s:3:"窀";s:2:"Ð@";s:3:"穾";s:2:"ÐA";s:3:"ç«‘";s:2:"ÐB";s:3:"笀";s:2:"ÐC";s:3:"ç¬";s:2:"ÐD";s:3:"籺";s:2:"ÐE";s:3:"籸";s:2:"ÐF";s:3:"ç±¹";s:2:"ÐG";s:3:"籿";s:2:"ÐH";s:3:"ç²€";s:2:"ÐI";s:3:"ç²";s:2:"ÐJ";s:3:"ç´ƒ";s:2:"ÐK";s:3:"ç´ˆ";s:2:"ÐL";s:3:"ç´";s:2:"ÐM";s:3:"罘";s:2:"ÐN";s:3:"羑";s:2:"ÐO";s:3:"ç¾";s:2:"ÐP";s:3:"ç¾¾";s:2:"ÐQ";s:3:"耇";s:2:"ÐR";s:3:"耎";s:2:"ÐS";s:3:"è€";s:2:"ÐT";s:3:"耔";s:2:"ÐU";s:3:"耷";s:2:"ÐV";s:3:"胘";s:2:"ÐW";s:3:"胇";s:2:"ÐX";s:3:"胠";s:2:"ÐY";s:3:"胑";s:2:"ÐZ";s:3:"胈";s:2:"Ð[";s:3:"胂";s:2:"Ð\";s:3:"èƒ";s:2:"Ð]";s:3:"胅";s:2:"Ð^";s:3:"胣";s:2:"Ð_";s:3:"胙";s:2:"Ð`";s:3:"胜";s:2:"Ða";s:3:"胊";s:2:"Ðb";s:3:"胕";s:2:"Ðc";s:3:"胉";s:2:"Ðd";s:3:"èƒ";s:2:"Ðe";s:3:"胗";s:2:"Ðf";s:3:"胦";s:2:"Ðg";s:3:"èƒ";s:2:"Ðh";s:3:"臿";s:2:"Ði";s:3:"舡";s:2:"Ðj";s:3:"芔";s:2:"Ðk";s:3:"è‹™";s:2:"Ðl";s:3:"苾";s:2:"Ðm";s:3:"苹";s:2:"Ðn";s:3:"茇";s:2:"Ðo";s:3:"苨";s:2:"Ðp";s:3:"茀";s:2:"Ðq";s:3:"è‹•";s:2:"Ðr";s:3:"茺";s:2:"Ðs";s:3:"è‹«";s:2:"Ðt";s:3:"è‹–";s:2:"Ðu";s:3:"è‹´";s:2:"Ðv";s:3:"苬";s:2:"Ðw";s:3:"è‹¡";s:2:"Ðx";s:3:"苲";s:2:"Ðy";s:3:"苵";s:2:"Ðz";s:3:"茌";s:2:"Ð{";s:3:"è‹»";s:2:"Ð|";s:3:"苶";s:2:"Ð}";s:3:"è‹°";s:2:"Ð~";s:3:"苪";s:2:"С";s:3:"苤";s:2:"Т";s:3:"è‹ ";s:2:"У";s:3:"苺";s:2:"Ф";s:3:"苳";s:2:"Ð¥";s:3:"è‹­";s:2:"Ц";s:3:"è™·";s:2:"Ч";s:3:"è™´";s:2:"Ш";s:3:"虼";s:2:"Щ";s:3:"虳";s:2:"Ъ";s:3:"è¡";s:2:"Ы";s:3:"è¡Ž";s:2:"Ь";s:3:"衧";s:2:"Э";s:3:"衪";s:2:"Ю";s:3:"è¡©";s:2:"Я";s:3:"觓";s:2:"а";s:3:"訄";s:2:"б";s:3:"訇";s:2:"в";s:3:"èµ²";s:2:"г";s:3:"è¿£";s:2:"д";s:3:"è¿¡";s:2:"е";s:3:"è¿®";s:2:"ж";s:3:"è¿ ";s:2:"з";s:3:"郱";s:2:"и";s:3:"邽";s:2:"й";s:3:"é‚¿";s:2:"к";s:3:"郕";s:2:"л";s:3:"郅";s:2:"м";s:3:"邾";s:2:"н";s:3:"郇";s:2:"о";s:3:"郋";s:2:"п";s:3:"郈";s:2:"ÐÀ";s:3:"釔";s:2:"ÐÁ";s:3:"釓";s:2:"ÐÂ";s:3:"é™”";s:2:"ÐÃ";s:3:"é™";s:2:"ÐÄ";s:3:"陑";s:2:"ÐÅ";s:3:"陓";s:2:"ÐÆ";s:3:"陊";s:2:"ÐÇ";s:3:"陎";s:2:"ÐÈ";s:3:"倞";s:2:"ÐÉ";s:3:"倅";s:2:"ÐÊ";s:3:"倇";s:2:"ÐË";s:3:"倓";s:2:"ÐÌ";s:3:"倢";s:2:"ÐÍ";s:3:"倰";s:2:"ÐÎ";s:3:"倛";s:2:"ÐÏ";s:3:"俵";s:2:"ÐÐ";s:3:"ä¿´";s:2:"ÐÑ";s:3:"倳";s:2:"ÐÒ";s:3:"倷";s:2:"ÐÓ";s:3:"倬";s:2:"ÐÔ";s:3:"俶";s:2:"ÐÕ";s:3:"ä¿·";s:2:"ÐÖ";s:3:"倗";s:2:"Ð×";s:3:"倜";s:2:"ÐØ";s:3:"倠";s:2:"ÐÙ";s:3:"倧";s:2:"ÐÚ";s:3:"倵";s:2:"ÐÛ";s:3:"倯";s:2:"ÐÜ";s:3:"倱";s:2:"ÐÝ";s:3:"倎";s:2:"ÐÞ";s:3:"å…š";s:2:"Ðß";s:3:"冔";s:2:"Ðà";s:3:"冓";s:2:"Ðá";s:3:"凊";s:2:"Ðâ";s:3:"凄";s:2:"Ðã";s:3:"凅";s:2:"Ðä";s:3:"凈";s:2:"Ðå";s:3:"凎";s:2:"Ðæ";s:3:"剡";s:2:"Ðç";s:3:"剚";s:2:"Ðè";s:3:"剒";s:2:"Ðé";s:3:"剞";s:2:"Ðê";s:3:"剟";s:2:"Ðë";s:3:"剕";s:2:"Ðì";s:3:"剢";s:2:"Ðí";s:3:"å‹";s:2:"Ðî";s:3:"匎";s:2:"Ðï";s:3:"厞";s:2:"Ðð";s:3:"唦";s:2:"Ðñ";s:3:"å“¢";s:2:"Ðò";s:3:"å”—";s:2:"Ðó";s:3:"å”’";s:2:"Ðô";s:3:"哧";s:2:"Ðõ";s:3:"哳";s:2:"Ðö";s:3:"哤";s:2:"Ð÷";s:3:"唚";s:2:"Ðø";s:3:"å“¿";s:2:"Ðù";s:3:"唄";s:2:"Ðú";s:3:"唈";s:2:"Ðû";s:3:"å“«";s:2:"Ðü";s:3:"唑";s:2:"Ðý";s:3:"å”…";s:2:"Ðþ";s:3:"哱";s:2:"Ñ@";s:3:"唊";s:2:"ÑA";s:3:"å“»";s:2:"ÑB";s:3:"å“·";s:2:"ÑC";s:3:"哸";s:2:"ÑD";s:3:"å“ ";s:2:"ÑE";s:3:"唎";s:2:"ÑF";s:3:"唃";s:2:"ÑG";s:3:"唋";s:2:"ÑH";s:3:"åœ";s:2:"ÑI";s:3:"圂";s:2:"ÑJ";s:3:"埌";s:2:"ÑK";s:3:"å ²";s:2:"ÑL";s:3:"埕";s:2:"ÑM";s:3:"埒";s:2:"ÑN";s:3:"垺";s:2:"ÑO";s:3:"埆";s:2:"ÑP";s:3:"åž½";s:2:"ÑQ";s:3:"åž¼";s:2:"ÑR";s:3:"垸";s:2:"ÑS";s:3:"垶";s:2:"ÑT";s:3:"åž¿";s:2:"ÑU";s:3:"埇";s:2:"ÑV";s:3:"åŸ";s:2:"ÑW";s:3:"åž¹";s:2:"ÑX";s:3:"åŸ";s:2:"ÑY";s:3:"夎";s:2:"ÑZ";s:3:"奊";s:2:"Ñ[";s:3:"娙";s:2:"Ñ\";s:3:"娖";s:2:"Ñ]";s:3:"娭";s:2:"Ñ^";s:3:"娮";s:2:"Ñ_";s:3:"娕";s:2:"Ñ`";s:3:"å¨";s:2:"Ña";s:3:"娗";s:2:"Ñb";s:3:"娊";s:2:"Ñc";s:3:"娞";s:2:"Ñd";s:3:"娳";s:2:"Ñe";s:3:"å­¬";s:2:"Ñf";s:3:"宧";s:2:"Ñg";s:3:"å®­";s:2:"Ñh";s:3:"宬";s:2:"Ñi";s:3:"å°ƒ";s:2:"Ñj";s:3:"å±–";s:2:"Ñk";s:3:"å±”";s:2:"Ñl";s:3:"峬";s:2:"Ñm";s:3:"峿";s:2:"Ñn";s:3:"å³®";s:2:"Ño";s:3:"å³±";s:2:"Ñp";s:3:"å³·";s:2:"Ñq";s:3:"å´€";s:2:"Ñr";s:3:"å³¹";s:2:"Ñs";s:3:"帩";s:2:"Ñt";s:3:"帨";s:2:"Ñu";s:3:"庨";s:2:"Ñv";s:3:"庮";s:2:"Ñw";s:3:"庪";s:2:"Ñx";s:3:"庬";s:2:"Ñy";s:3:"å¼³";s:2:"Ñz";s:3:"å¼°";s:2:"Ñ{";s:3:"彧";s:2:"Ñ|";s:3:"æ";s:2:"Ñ}";s:3:"æš";s:2:"Ñ~";s:3:"æ§";s:2:"Ñ¡";s:3:"æ";s:2:"Ñ¢";s:3:"æ‚¢";s:2:"Ñ£";s:3:"悈";s:2:"Ѥ";s:3:"æ‚€";s:2:"Ñ¥";s:3:"æ‚’";s:2:"Ѧ";s:3:"æ‚";s:2:"ѧ";s:3:"æ‚";s:2:"Ѩ";s:3:"悃";s:2:"Ñ©";s:3:"æ‚•";s:2:"Ѫ";s:3:"æ‚›";s:2:"Ñ«";s:3:"æ‚—";s:2:"Ѭ";s:3:"悇";s:2:"Ñ­";s:3:"æ‚œ";s:2:"Ñ®";s:3:"æ‚Ž";s:2:"ѯ";s:3:"戙";s:2:"Ñ°";s:3:"扆";s:2:"ѱ";s:3:"拲";s:2:"Ѳ";s:3:"æŒ";s:2:"ѳ";s:3:"æ–";s:2:"Ñ´";s:3:"挬";s:2:"ѵ";s:3:"æ„";s:2:"Ѷ";s:3:"æ…";s:2:"Ñ·";s:3:"挶";s:2:"Ѹ";s:3:"æƒ";s:2:"ѹ";s:3:"æ¤";s:2:"Ѻ";s:3:"挹";s:2:"Ñ»";s:3:"æ‹";s:2:"Ѽ";s:3:"æŠ";s:2:"ѽ";s:3:"挼";s:2:"Ѿ";s:3:"挩";s:2:"Ñ¿";s:3:"æ";s:2:"ÑÀ";s:3:"挴";s:2:"ÑÁ";s:3:"æ˜";s:2:"ÑÂ";s:3:"æ”";s:2:"ÑÃ";s:3:"æ™";s:2:"ÑÄ";s:3:"挭";s:2:"ÑÅ";s:3:"æ‡";s:2:"ÑÆ";s:3:"挳";s:2:"ÑÇ";s:3:"æš";s:2:"ÑÈ";s:3:"æ‘";s:2:"ÑÉ";s:3:"挸";s:2:"ÑÊ";s:3:"æ—";s:2:"ÑË";s:3:"æ€";s:2:"ÑÌ";s:3:"æˆ";s:2:"ÑÍ";s:3:"æ•Š";s:2:"ÑÎ";s:3:"敆";s:2:"ÑÏ";s:3:"æ—†";s:2:"ÑÐ";s:3:"æ—ƒ";s:2:"ÑÑ";s:3:"æ—„";s:2:"ÑÒ";s:3:"æ—‚";s:2:"ÑÓ";s:3:"晊";s:2:"ÑÔ";s:3:"晟";s:2:"ÑÕ";s:3:"晇";s:2:"ÑÖ";s:3:"晑";s:2:"Ñ×";s:3:"朒";s:2:"ÑØ";s:3:"朓";s:2:"ÑÙ";s:3:"æ Ÿ";s:2:"ÑÚ";s:3:"æ š";s:2:"ÑÛ";s:3:"桉";s:2:"ÑÜ";s:3:"æ ²";s:2:"ÑÝ";s:3:"æ ³";s:2:"ÑÞ";s:3:"æ »";s:2:"Ñß";s:3:"æ¡‹";s:2:"Ñà";s:3:"æ¡";s:2:"Ñá";s:3:"æ –";s:2:"Ñâ";s:3:"æ ±";s:2:"Ñã";s:3:"æ œ";s:2:"Ñä";s:3:"æ µ";s:2:"Ñå";s:3:"æ «";s:2:"Ñæ";s:3:"æ ­";s:2:"Ñç";s:3:"æ ¯";s:2:"Ñè";s:3:"æ¡Ž";s:2:"Ñé";s:3:"æ¡„";s:2:"Ñê";s:3:"æ ´";s:2:"Ñë";s:3:"æ ";s:2:"Ñì";s:3:"æ ’";s:2:"Ñí";s:3:"æ ”";s:2:"Ñî";s:3:"æ ¦";s:2:"Ñï";s:3:"æ ¨";s:2:"Ñð";s:3:"æ ®";s:2:"Ññ";s:3:"æ¡";s:2:"Ñò";s:3:"æ º";s:2:"Ñó";s:3:"æ ¥";s:2:"Ñô";s:3:"æ  ";s:2:"Ñõ";s:3:"欬";s:2:"Ñö";s:3:"欯";s:2:"Ñ÷";s:3:"欭";s:2:"Ñø";s:3:"欱";s:2:"Ñù";s:3:"欴";s:2:"Ñú";s:3:"æ­­";s:2:"Ñû";s:3:"è‚‚";s:2:"Ñü";s:3:"殈";s:2:"Ñý";s:3:"毦";s:2:"Ñþ";s:3:"毤";s:2:"Ò@";s:3:"毨";s:2:"ÒA";s:3:"毣";s:2:"ÒB";s:3:"毢";s:2:"ÒC";s:3:"毧";s:2:"ÒD";s:3:"æ°¥";s:2:"ÒE";s:3:"浺";s:2:"ÒF";s:3:"æµ£";s:2:"ÒG";s:3:"浤";s:2:"ÒH";s:3:"浶";s:2:"ÒI";s:3:"æ´";s:2:"ÒJ";s:3:"浡";s:2:"ÒK";s:3:"涒";s:2:"ÒL";s:3:"浘";s:2:"ÒM";s:3:"æµ¢";s:2:"ÒN";s:3:"æµ­";s:2:"ÒO";s:3:"浯";s:2:"ÒP";s:3:"涑";s:2:"ÒQ";s:3:"æ¶";s:2:"ÒR";s:3:"æ·¯";s:2:"ÒS";s:3:"浿";s:2:"ÒT";s:3:"涆";s:2:"ÒU";s:3:"浞";s:2:"ÒV";s:3:"浧";s:2:"ÒW";s:3:"æµ ";s:2:"ÒX";s:3:"涗";s:2:"ÒY";s:3:"æµ°";s:2:"ÒZ";s:3:"æµ¼";s:2:"Ò[";s:3:"浟";s:2:"Ò\";s:3:"涂";s:2:"Ò]";s:3:"涘";s:2:"Ò^";s:3:"æ´¯";s:2:"Ò_";s:3:"浨";s:2:"Ò`";s:3:"涋";s:2:"Òa";s:3:"æµ¾";s:2:"Òb";s:3:"涀";s:2:"Òc";s:3:"涄";s:2:"Òd";s:3:"æ´–";s:2:"Òe";s:3:"涃";s:2:"Òf";s:3:"æµ»";s:2:"Òg";s:3:"æµ½";s:2:"Òh";s:3:"æµµ";s:2:"Òi";s:3:"æ¶";s:2:"Òj";s:3:"烜";s:2:"Òk";s:3:"烓";s:2:"Òl";s:3:"烑";s:2:"Òm";s:3:"çƒ";s:2:"Òn";s:3:"烋";s:2:"Òo";s:3:"ç¼¹";s:2:"Òp";s:3:"烢";s:2:"Òq";s:3:"烗";s:2:"Òr";s:3:"烒";s:2:"Òs";s:3:"烞";s:2:"Òt";s:3:"烠";s:2:"Òu";s:3:"烔";s:2:"Òv";s:3:"çƒ";s:2:"Òw";s:3:"烅";s:2:"Òx";s:3:"烆";s:2:"Òy";s:3:"烇";s:2:"Òz";s:3:"烚";s:2:"Ò{";s:3:"烎";s:2:"Ò|";s:3:"烡";s:2:"Ò}";s:3:"牂";s:2:"Ò~";s:3:"牸";s:2:"Ò¡";s:3:"牷";s:2:"Ò¢";s:3:"牶";s:2:"Ò£";s:3:"猀";s:2:"Ò¤";s:3:"狺";s:2:"Ò¥";s:3:"ç‹´";s:2:"Ò¦";s:3:"狾";s:2:"Ò§";s:3:"狶";s:2:"Ò¨";s:3:"狳";s:2:"Ò©";s:3:"ç‹»";s:2:"Òª";s:3:"çŒ";s:2:"Ò«";s:3:"ç“";s:2:"Ò¬";s:3:"ç™";s:2:"Ò­";s:3:"ç¥";s:2:"Ò®";s:3:"ç–";s:2:"Ò¯";s:3:"玼";s:2:"Ò°";s:3:"ç§";s:2:"Ò±";s:3:"ç£";s:2:"Ò²";s:3:"ç©";s:2:"Ò³";s:3:"çœ";s:2:"Ò´";s:3:"ç’";s:2:"Òµ";s:3:"ç›";s:2:"Ò¶";s:3:"ç”";s:2:"Ò·";s:3:"ç";s:2:"Ò¸";s:3:"çš";s:2:"Ò¹";s:3:"ç—";s:2:"Òº";s:3:"ç˜";s:2:"Ò»";s:3:"ç¨";s:2:"Ò¼";s:3:"ç“ž";s:2:"Ò½";s:3:"ç“Ÿ";s:2:"Ò¾";s:3:"ç“´";s:2:"Ò¿";s:3:"瓵";s:2:"ÒÀ";s:3:"甡";s:2:"ÒÁ";s:3:"ç•›";s:2:"ÒÂ";s:3:"ç•Ÿ";s:2:"ÒÃ";s:3:"ç–°";s:2:"ÒÄ";s:3:"ç—";s:2:"ÒÅ";s:3:"ç–»";s:2:"ÒÆ";s:3:"ç—„";s:2:"ÒÇ";s:3:"ç—€";s:2:"ÒÈ";s:3:"ç–¿";s:2:"ÒÉ";s:3:"ç–¶";s:2:"ÒÊ";s:3:"ç–º";s:2:"ÒË";s:3:"皊";s:2:"ÒÌ";s:3:"盉";s:2:"ÒÍ";s:3:"çœ";s:2:"ÒÎ";s:3:"眛";s:2:"ÒÏ";s:3:"çœ";s:2:"ÒÐ";s:3:"眓";s:2:"ÒÑ";s:3:"眒";s:2:"ÒÒ";s:3:"眣";s:2:"ÒÓ";s:3:"眑";s:2:"ÒÔ";s:3:"眕";s:2:"ÒÕ";s:3:"眙";s:2:"ÒÖ";s:3:"眚";s:2:"Ò×";s:3:"眢";s:2:"ÒØ";s:3:"眧";s:2:"ÒÙ";s:3:"ç £";s:2:"ÒÚ";s:3:"ç ¬";s:2:"ÒÛ";s:3:"ç ¢";s:2:"ÒÜ";s:3:"ç µ";s:2:"ÒÝ";s:3:"ç ¯";s:2:"ÒÞ";s:3:"ç ¨";s:2:"Òß";s:3:"ç ®";s:2:"Òà";s:3:"ç «";s:2:"Òá";s:3:"ç ¡";s:2:"Òâ";s:3:"ç ©";s:2:"Òã";s:3:"ç ³";s:2:"Òä";s:3:"ç ª";s:2:"Òå";s:3:"ç ±";s:2:"Òæ";s:3:"祔";s:2:"Òç";s:3:"祛";s:2:"Òè";s:3:"ç¥";s:2:"Òé";s:3:"祜";s:2:"Òê";s:3:"祓";s:2:"Òë";s:3:"祒";s:2:"Òì";s:3:"祑";s:2:"Òí";s:3:"秫";s:2:"Òî";s:3:"秬";s:2:"Òï";s:3:"秠";s:2:"Òð";s:3:"秮";s:2:"Òñ";s:3:"秭";s:2:"Òò";s:3:"秪";s:2:"Òó";s:3:"秜";s:2:"Òô";s:3:"秞";s:2:"Òõ";s:3:"ç§";s:2:"Òö";s:3:"窆";s:2:"Ò÷";s:3:"窉";s:2:"Òø";s:3:"窅";s:2:"Òù";s:3:"窋";s:2:"Òú";s:3:"窌";s:2:"Òû";s:3:"窊";s:2:"Òü";s:3:"窇";s:2:"Òý";s:3:"竘";s:2:"Òþ";s:3:"ç¬";s:2:"Ó@";s:3:"笄";s:2:"ÓA";s:3:"笓";s:2:"ÓB";s:3:"笅";s:2:"ÓC";s:3:"ç¬";s:2:"ÓD";s:3:"笈";s:2:"ÓE";s:3:"笊";s:2:"ÓF";s:3:"笎";s:2:"ÓG";s:3:"笉";s:2:"ÓH";s:3:"笒";s:2:"ÓI";s:3:"粄";s:2:"ÓJ";s:3:"粑";s:2:"ÓK";s:3:"粊";s:2:"ÓL";s:3:"粌";s:2:"ÓM";s:3:"粈";s:2:"ÓN";s:3:"ç²";s:2:"ÓO";s:3:"ç²…";s:2:"ÓP";s:3:"ç´ž";s:2:"ÓQ";s:3:"ç´";s:2:"ÓR";s:3:"ç´‘";s:2:"ÓS";s:3:"ç´Ž";s:2:"ÓT";s:3:"ç´˜";s:2:"ÓU";s:3:"ç´–";s:2:"ÓV";s:3:"ç´“";s:2:"ÓW";s:3:"ç´Ÿ";s:2:"ÓX";s:3:"ç´’";s:2:"ÓY";s:3:"ç´";s:2:"ÓZ";s:3:"ç´Œ";s:2:"Ó[";s:3:"罜";s:2:"Ó\";s:3:"罡";s:2:"Ó]";s:3:"罞";s:2:"Ó^";s:3:"ç½ ";s:2:"Ó_";s:3:"ç½";s:2:"Ó`";s:3:"ç½›";s:2:"Óa";s:3:"ç¾–";s:2:"Ób";s:3:"ç¾’";s:2:"Óc";s:3:"翃";s:2:"Ód";s:3:"ç¿‚";s:2:"Óe";s:3:"ç¿€";s:2:"Óf";s:3:"耖";s:2:"Óg";s:3:"耾";s:2:"Óh";s:3:"耹";s:2:"Ói";s:3:"胺";s:2:"Ój";s:3:"胲";s:2:"Ók";s:3:"胹";s:2:"Ól";s:3:"胵";s:2:"Óm";s:3:"è„";s:2:"Ón";s:3:"胻";s:2:"Óo";s:3:"è„€";s:2:"Óp";s:3:"èˆ";s:2:"Óq";s:3:"舯";s:2:"Ór";s:3:"舥";s:2:"Ós";s:3:"茳";s:2:"Ót";s:3:"茭";s:2:"Óu";s:3:"è„";s:2:"Óv";s:3:"茙";s:2:"Ów";s:3:"è‘";s:2:"Óx";s:3:"茥";s:2:"Óy";s:3:"è–";s:2:"Óz";s:3:"茿";s:2:"Ó{";s:3:"è";s:2:"Ó|";s:3:"茦";s:2:"Ó}";s:3:"茜";s:2:"Ó~";s:3:"茢";s:2:"Ó¡";s:3:"è‚";s:2:"Ó¢";s:3:"èŽ";s:2:"Ó£";s:3:"茛";s:2:"Ó¤";s:3:"茪";s:2:"Ó¥";s:3:"茈";s:2:"Ó¦";s:3:"茼";s:2:"Ó§";s:3:"è";s:2:"Ó¨";s:3:"茖";s:2:"Ó©";s:3:"茤";s:2:"Óª";s:3:"茠";s:2:"Ó«";s:3:"茷";s:2:"Ó¬";s:3:"茯";s:2:"Ó­";s:3:"茩";s:2:"Ó®";s:3:"è‡";s:2:"Ó¯";s:3:"è…";s:2:"Ó°";s:3:"èŒ";s:2:"Ó±";s:3:"è“";s:2:"Ó²";s:3:"茞";s:2:"Ó³";s:3:"茬";s:2:"Ó´";s:3:"è‹";s:2:"Óµ";s:3:"茧";s:2:"Ó¶";s:3:"èˆ";s:2:"Ó·";s:3:"虓";s:2:"Ó¸";s:3:"è™’";s:2:"Ó¹";s:3:"蚢";s:2:"Óº";s:3:"蚨";s:2:"Ó»";s:3:"èš–";s:2:"Ó¼";s:3:"èš";s:2:"Ó½";s:3:"èš‘";s:2:"Ó¾";s:3:"èšž";s:2:"Ó¿";s:3:"蚇";s:2:"ÓÀ";s:3:"èš—";s:2:"ÓÁ";s:3:"蚆";s:2:"ÓÂ";s:3:"èš‹";s:2:"ÓÃ";s:3:"èšš";s:2:"ÓÄ";s:3:"èš…";s:2:"ÓÅ";s:3:"蚥";s:2:"ÓÆ";s:3:"èš™";s:2:"ÓÇ";s:3:"èš¡";s:2:"ÓÈ";s:3:"蚧";s:2:"ÓÉ";s:3:"èš•";s:2:"ÓÊ";s:3:"蚘";s:2:"ÓË";s:3:"蚎";s:2:"ÓÌ";s:3:"èš";s:2:"ÓÍ";s:3:"èš";s:2:"ÓÎ";s:3:"èš”";s:2:"ÓÏ";s:3:"衃";s:2:"ÓÐ";s:3:"è¡„";s:2:"ÓÑ";s:3:"è¡­";s:2:"ÓÒ";s:3:"衵";s:2:"ÓÓ";s:3:"衶";s:2:"ÓÔ";s:3:"衲";s:2:"ÓÕ";s:3:"袀";s:2:"ÓÖ";s:3:"衱";s:2:"Ó×";s:3:"è¡¿";s:2:"ÓØ";s:3:"衯";s:2:"ÓÙ";s:3:"袃";s:2:"ÓÚ";s:3:"衾";s:2:"ÓÛ";s:3:"è¡´";s:2:"ÓÜ";s:3:"衼";s:2:"ÓÝ";s:3:"訒";s:2:"ÓÞ";s:3:"豇";s:2:"Óß";s:3:"è±—";s:2:"Óà";s:3:"è±»";s:2:"Óá";s:3:"貤";s:2:"Óâ";s:3:"è²£";s:2:"Óã";s:3:"赶";s:2:"Óä";s:3:"赸";s:2:"Óå";s:3:"趵";s:2:"Óæ";s:3:"趷";s:2:"Óç";s:3:"趶";s:2:"Óè";s:3:"軑";s:2:"Óé";s:3:"軓";s:2:"Óê";s:3:"迾";s:2:"Óë";s:3:"迵";s:2:"Óì";s:3:"适";s:2:"Óí";s:3:"è¿¿";s:2:"Óî";s:3:"è¿»";s:2:"Óï";s:3:"逄";s:2:"Óð";s:3:"迼";s:2:"Óñ";s:3:"迶";s:2:"Óò";s:3:"郖";s:2:"Óó";s:3:"郠";s:2:"Óô";s:3:"郙";s:2:"Óõ";s:3:"郚";s:2:"Óö";s:3:"郣";s:2:"Ó÷";s:3:"郟";s:2:"Óø";s:3:"郥";s:2:"Óù";s:3:"郘";s:2:"Óú";s:3:"郛";s:2:"Óû";s:3:"郗";s:2:"Óü";s:3:"郜";s:2:"Óý";s:3:"郤";s:2:"Óþ";s:3:"é…";s:2:"Ô@";s:3:"é…Ž";s:2:"ÔA";s:3:"é…";s:2:"ÔB";s:3:"釕";s:2:"ÔC";s:3:"釢";s:2:"ÔD";s:3:"釚";s:2:"ÔE";s:3:"陜";s:2:"ÔF";s:3:"陟";s:2:"ÔG";s:3:"éš¼";s:2:"ÔH";s:3:"飣";s:2:"ÔI";s:3:"é«Ÿ";s:2:"ÔJ";s:3:"鬯";s:2:"ÔK";s:3:"乿";s:2:"ÔL";s:3:"å°";s:2:"ÔM";s:3:"åª";s:2:"ÔN";s:3:"å¡";s:2:"ÔO";s:3:"åž";s:2:"ÔP";s:3:"å ";s:2:"ÔQ";s:3:"å“";s:2:"ÔR";s:3:"å‹";s:2:"ÔS";s:3:"å";s:2:"ÔT";s:3:"å²";s:2:"ÔU";s:3:"åˆ";s:2:"ÔV";s:3:"å";s:2:"ÔW";s:3:"å";s:2:"ÔX";s:3:"å›";s:2:"ÔY";s:3:"åŠ";s:2:"ÔZ";s:3:"å¢";s:2:"Ô[";s:3:"倕";s:2:"Ô\";s:3:"å…";s:2:"Ô]";s:3:"åŸ";s:2:"Ô^";s:3:"å©";s:2:"Ô_";s:3:"å«";s:2:"Ô`";s:3:"å£";s:2:"Ôa";s:3:"å¤";s:2:"Ôb";s:3:"å†";s:2:"Ôc";s:3:"å€";s:2:"Ôd";s:3:"å®";s:2:"Ôe";s:3:"å³";s:2:"Ôf";s:3:"å—";s:2:"Ôg";s:3:"å‘";s:2:"Ôh";s:3:"å‡";s:2:"Ôi";s:3:"剫";s:2:"Ôj";s:3:"剭";s:2:"Ôk";s:3:"剬";s:2:"Ôl";s:3:"剮";s:2:"Ôm";s:3:"å‹–";s:2:"Ôn";s:3:"å‹“";s:2:"Ôo";s:3:"匭";s:2:"Ôp";s:3:"厜";s:2:"Ôq";s:3:"啵";s:2:"Ôr";s:3:"啶";s:2:"Ôs";s:3:"唼";s:2:"Ôt";s:3:"å•";s:2:"Ôu";s:3:"å•";s:2:"Ôv";s:3:"å”´";s:2:"Ôw";s:3:"唪";s:2:"Ôx";s:3:"å•‘";s:2:"Ôy";s:3:"å•¢";s:2:"Ôz";s:3:"唶";s:2:"Ô{";s:3:"唵";s:2:"Ô|";s:3:"å”°";s:2:"Ô}";s:3:"å•’";s:2:"Ô~";s:3:"å•…";s:2:"Ô¡";s:3:"唌";s:2:"Ô¢";s:3:"唲";s:2:"Ô£";s:3:"å•¥";s:2:"Ô¤";s:3:"å•Ž";s:2:"Ô¥";s:3:"唹";s:2:"Ô¦";s:3:"啈";s:2:"Ô§";s:3:"å”­";s:2:"Ô¨";s:3:"å”»";s:2:"Ô©";s:3:"å•€";s:2:"Ôª";s:3:"å•‹";s:2:"Ô«";s:3:"圊";s:2:"Ô¬";s:3:"圇";s:2:"Ô­";s:3:"埻";s:2:"Ô®";s:3:"å ”";s:2:"Ô¯";s:3:"埢";s:2:"Ô°";s:3:"埶";s:2:"Ô±";s:3:"埜";s:2:"Ô²";s:3:"埴";s:2:"Ô³";s:3:"å €";s:2:"Ô´";s:3:"埭";s:2:"Ôµ";s:3:"埽";s:2:"Ô¶";s:3:"å ˆ";s:2:"Ô·";s:3:"埸";s:2:"Ô¸";s:3:"å ‹";s:2:"Ô¹";s:3:"埳";s:2:"Ôº";s:3:"åŸ";s:2:"Ô»";s:3:"å ‡";s:2:"Ô¼";s:3:"埮";s:2:"Ô½";s:3:"埣";s:2:"Ô¾";s:3:"埲";s:2:"Ô¿";s:3:"埥";s:2:"ÔÀ";s:3:"埬";s:2:"ÔÁ";s:3:"埡";s:2:"ÔÂ";s:3:"å Ž";s:2:"ÔÃ";s:3:"埼";s:2:"ÔÄ";s:3:"å ";s:2:"ÔÅ";s:3:"埧";s:2:"ÔÆ";s:3:"å ";s:2:"ÔÇ";s:3:"å Œ";s:2:"ÔÈ";s:3:"埱";s:2:"ÔÉ";s:3:"埩";s:2:"ÔÊ";s:3:"埰";s:2:"ÔË";s:3:"å ";s:2:"ÔÌ";s:3:"å „";s:2:"ÔÍ";s:3:"奜";s:2:"ÔÎ";s:3:"å© ";s:2:"ÔÏ";s:3:"婘";s:2:"ÔÐ";s:3:"å©•";s:2:"ÔÑ";s:3:"婧";s:2:"ÔÒ";s:3:"å©ž";s:2:"ÔÓ";s:3:"娸";s:2:"ÔÔ";s:3:"娵";s:2:"ÔÕ";s:3:"å©­";s:2:"ÔÖ";s:3:"å©";s:2:"Ô×";s:3:"å©Ÿ";s:2:"ÔØ";s:3:"å©¥";s:2:"ÔÙ";s:3:"婬";s:2:"ÔÚ";s:3:"å©“";s:2:"ÔÛ";s:3:"婤";s:2:"ÔÜ";s:3:"å©—";s:2:"ÔÝ";s:3:"婃";s:2:"ÔÞ";s:3:"å©";s:2:"Ôß";s:3:"å©’";s:2:"Ôà";s:3:"å©„";s:2:"Ôá";s:3:"å©›";s:2:"Ôâ";s:3:"婈";s:2:"Ôã";s:3:"媎";s:2:"Ôä";s:3:"娾";s:2:"Ôå";s:3:"å©";s:2:"Ôæ";s:3:"娹";s:2:"Ôç";s:3:"å©Œ";s:2:"Ôè";s:3:"å©°";s:2:"Ôé";s:3:"å©©";s:2:"Ôê";s:3:"婇";s:2:"Ôë";s:3:"å©‘";s:2:"Ôì";s:3:"å©–";s:2:"Ôí";s:3:"å©‚";s:2:"Ôî";s:3:"å©œ";s:2:"Ôï";s:3:"å­²";s:2:"Ôð";s:3:"å­®";s:2:"Ôñ";s:3:"å¯";s:2:"Ôò";s:3:"寀";s:2:"Ôó";s:3:"å±™";s:2:"Ôô";s:3:"å´ž";s:2:"Ôõ";s:3:"å´‹";s:2:"Ôö";s:3:"å´";s:2:"Ô÷";s:3:"å´š";s:2:"Ôø";s:3:"å´ ";s:2:"Ôù";s:3:"å´Œ";s:2:"Ôú";s:3:"å´¨";s:2:"Ôû";s:3:"å´";s:2:"Ôü";s:3:"å´¦";s:2:"Ôý";s:3:"å´¥";s:2:"Ôþ";s:3:"å´";s:2:"Õ@";s:3:"å´°";s:2:"ÕA";s:3:"å´’";s:2:"ÕB";s:3:"å´£";s:2:"ÕC";s:3:"å´Ÿ";s:2:"ÕD";s:3:"å´®";s:2:"ÕE";s:3:"帾";s:2:"ÕF";s:3:"帴";s:2:"ÕG";s:3:"庱";s:2:"ÕH";s:3:"庴";s:2:"ÕI";s:3:"庹";s:2:"ÕJ";s:3:"庲";s:2:"ÕK";s:3:"庳";s:2:"ÕL";s:3:"弶";s:2:"ÕM";s:3:"弸";s:2:"ÕN";s:3:"å¾›";s:2:"ÕO";s:3:"å¾–";s:2:"ÕP";s:3:"徟";s:2:"ÕQ";s:3:"æ‚Š";s:2:"ÕR";s:3:"æ‚";s:2:"ÕS";s:3:"悆";s:2:"ÕT";s:3:"悾";s:2:"ÕU";s:3:"æ‚°";s:2:"ÕV";s:3:"悺";s:2:"ÕW";s:3:"惓";s:2:"ÕX";s:3:"惔";s:2:"ÕY";s:3:"æƒ";s:2:"ÕZ";s:3:"惤";s:2:"Õ[";s:3:"惙";s:2:"Õ\";s:3:"æƒ";s:2:"Õ]";s:3:"惈";s:2:"Õ^";s:3:"悱";s:2:"Õ_";s:3:"惛";s:2:"Õ`";s:3:"æ‚·";s:2:"Õa";s:3:"惊";s:2:"Õb";s:3:"æ‚¿";s:2:"Õc";s:3:"惃";s:2:"Õd";s:3:"æƒ";s:2:"Õe";s:3:"惀";s:2:"Õf";s:3:"挲";s:2:"Õg";s:3:"æ¥";s:2:"Õh";s:3:"掊";s:2:"Õi";s:3:"掂";s:2:"Õj";s:3:"æ½";s:2:"Õk";s:3:"掽";s:2:"Õl";s:3:"掞";s:2:"Õm";s:3:"掭";s:2:"Õn";s:3:"æŽ";s:2:"Õo";s:3:"掗";s:2:"Õp";s:3:"掫";s:2:"Õq";s:3:"掎";s:2:"Õr";s:3:"æ¯";s:2:"Õs";s:3:"掇";s:2:"Õt";s:3:"æŽ";s:2:"Õu";s:3:"æ®";s:2:"Õv";s:3:"掯";s:2:"Õw";s:3:"æµ";s:2:"Õx";s:3:"掜";s:2:"Õy";s:3:"æ­";s:2:"Õz";s:3:"掮";s:2:"Õ{";s:3:"æ¼";s:2:"Õ|";s:3:"掤";s:2:"Õ}";s:3:"挻";s:2:"Õ~";s:3:"掟";s:2:"Õ¡";s:3:"æ¸";s:2:"Õ¢";s:3:"掅";s:2:"Õ£";s:3:"æŽ";s:2:"Õ¤";s:3:"掑";s:2:"Õ¥";s:3:"æŽ";s:2:"Õ¦";s:3:"æ°";s:2:"Õ§";s:3:"æ•“";s:2:"Õ¨";s:3:"æ—";s:2:"Õ©";s:3:"晥";s:2:"Õª";s:3:"晡";s:2:"Õ«";s:3:"æ™›";s:2:"Õ¬";s:3:"æ™™";s:2:"Õ­";s:3:"晜";s:2:"Õ®";s:3:"晢";s:2:"Õ¯";s:3:"朘";s:2:"Õ°";s:3:"桹";s:2:"Õ±";s:3:"梇";s:2:"Õ²";s:3:"æ¢";s:2:"Õ³";s:3:"梜";s:2:"Õ´";s:3:"æ¡­";s:2:"Õµ";s:3:"æ¡®";s:2:"Õ¶";s:3:"梮";s:2:"Õ·";s:3:"梫";s:2:"Õ¸";s:3:"楖";s:2:"Õ¹";s:3:"桯";s:2:"Õº";s:3:"梣";s:2:"Õ»";s:3:"梬";s:2:"Õ¼";s:3:"梩";s:2:"Õ½";s:3:"桵";s:2:"Õ¾";s:3:"æ¡´";s:2:"Õ¿";s:3:"梲";s:2:"ÕÀ";s:3:"æ¢";s:2:"ÕÁ";s:3:"æ¡·";s:2:"ÕÂ";s:3:"梒";s:2:"ÕÃ";s:3:"桼";s:2:"ÕÄ";s:3:"æ¡«";s:2:"ÕÅ";s:3:"桲";s:2:"ÕÆ";s:3:"梪";s:2:"ÕÇ";s:3:"梀";s:2:"ÕÈ";s:3:"桱";s:2:"ÕÉ";s:3:"桾";s:2:"ÕÊ";s:3:"梛";s:2:"ÕË";s:3:"梖";s:2:"ÕÌ";s:3:"梋";s:2:"ÕÍ";s:3:"梠";s:2:"ÕÎ";s:3:"梉";s:2:"ÕÏ";s:3:"梤";s:2:"ÕÐ";s:3:"桸";s:2:"ÕÑ";s:3:"æ¡»";s:2:"ÕÒ";s:3:"梑";s:2:"ÕÓ";s:3:"梌";s:2:"ÕÔ";s:3:"梊";s:2:"ÕÕ";s:3:"桽";s:2:"ÕÖ";s:3:"欶";s:2:"Õ×";s:3:"欳";s:2:"ÕØ";s:3:"欷";s:2:"ÕÙ";s:3:"欸";s:2:"ÕÚ";s:3:"殑";s:2:"ÕÛ";s:3:"æ®";s:2:"ÕÜ";s:3:"æ®";s:2:"ÕÝ";s:3:"殎";s:2:"ÕÞ";s:3:"殌";s:2:"Õß";s:3:"æ°ª";s:2:"Õà";s:3:"æ·€";s:2:"Õá";s:3:"涫";s:2:"Õâ";s:3:"涴";s:2:"Õã";s:3:"涳";s:2:"Õä";s:3:"æ¹´";s:2:"Õå";s:3:"涬";s:2:"Õæ";s:3:"æ·©";s:2:"Õç";s:3:"æ·¢";s:2:"Õè";s:3:"涷";s:2:"Õé";s:3:"æ·¶";s:2:"Õê";s:3:"æ·”";s:2:"Õë";s:3:"渀";s:2:"Õì";s:3:"æ·ˆ";s:2:"Õí";s:3:"æ· ";s:2:"Õî";s:3:"æ·Ÿ";s:2:"Õï";s:3:"æ·–";s:2:"Õð";s:3:"涾";s:2:"Õñ";s:3:"æ·¥";s:2:"Õò";s:3:"æ·œ";s:2:"Õó";s:3:"æ·";s:2:"Õô";s:3:"æ·›";s:2:"Õõ";s:3:"æ·´";s:2:"Õö";s:3:"æ·Š";s:2:"Õ÷";s:3:"涽";s:2:"Õø";s:3:"æ·­";s:2:"Õù";s:3:"æ·°";s:2:"Õú";s:3:"涺";s:2:"Õû";s:3:"æ·•";s:2:"Õü";s:3:"æ·‚";s:2:"Õý";s:3:"æ·";s:2:"Õþ";s:3:"æ·‰";s:2:"Ö@";s:3:"æ·";s:2:"ÖA";s:3:"æ·²";s:2:"ÖB";s:3:"æ·“";s:2:"ÖC";s:3:"æ·½";s:2:"ÖD";s:3:"æ·—";s:2:"ÖE";s:3:"æ·";s:2:"ÖF";s:3:"æ·£";s:2:"ÖG";s:3:"涻";s:2:"ÖH";s:3:"烺";s:2:"ÖI";s:3:"ç„";s:2:"ÖJ";s:3:"烷";s:2:"ÖK";s:3:"ç„—";s:2:"ÖL";s:3:"烴";s:2:"ÖM";s:3:"ç„Œ";s:2:"ÖN";s:3:"烰";s:2:"ÖO";s:3:"ç„„";s:2:"ÖP";s:3:"烳";s:2:"ÖQ";s:3:"ç„";s:2:"ÖR";s:3:"烼";s:2:"ÖS";s:3:"烿";s:2:"ÖT";s:3:"焆";s:2:"ÖU";s:3:"ç„“";s:2:"ÖV";s:3:"ç„€";s:2:"ÖW";s:3:"烸";s:2:"ÖX";s:3:"烶";s:2:"ÖY";s:3:"ç„‹";s:2:"ÖZ";s:3:"ç„‚";s:2:"Ö[";s:3:"ç„Ž";s:2:"Ö\";s:3:"牾";s:2:"Ö]";s:3:"牻";s:2:"Ö^";s:3:"牼";s:2:"Ö_";s:3:"牿";s:2:"Ö`";s:3:"çŒ";s:2:"Öa";s:3:"猗";s:2:"Öb";s:3:"猇";s:2:"Öc";s:3:"猑";s:2:"Öd";s:3:"猘";s:2:"Öe";s:3:"猊";s:2:"Öf";s:3:"猈";s:2:"Ög";s:3:"ç‹¿";s:2:"Öh";s:3:"çŒ";s:2:"Öi";s:3:"猞";s:2:"Öj";s:3:"玈";s:2:"Ök";s:3:"ç¶";s:2:"Öl";s:3:"ç¸";s:2:"Öm";s:3:"çµ";s:2:"Ön";s:3:"ç„";s:2:"Öo";s:3:"ç";s:2:"Öp";s:3:"ç½";s:2:"Öq";s:3:"ç‡";s:2:"Ör";s:3:"ç€";s:2:"Ös";s:3:"çº";s:2:"Öt";s:3:"ç¼";s:2:"Öu";s:3:"ç¿";s:2:"Öv";s:3:"çŒ";s:2:"Öw";s:3:"ç‹";s:2:"Öx";s:3:"ç´";s:2:"Öy";s:3:"çˆ";s:2:"Öz";s:3:"畤";s:2:"Ö{";s:3:"ç•£";s:2:"Ö|";s:3:"ç—Ž";s:2:"Ö}";s:3:"ç—’";s:2:"Ö~";s:3:"ç—";s:2:"Ö¡";s:3:"ç—‹";s:2:"Ö¢";s:3:"ç—Œ";s:2:"Ö£";s:3:"ç—‘";s:2:"Ö¤";s:3:"ç—";s:2:"Ö¥";s:3:"çš";s:2:"Ö¦";s:3:"皉";s:2:"Ö§";s:3:"盓";s:2:"Ö¨";s:3:"眹";s:2:"Ö©";s:3:"眯";s:2:"Öª";s:3:"眭";s:2:"Ö«";s:3:"眱";s:2:"Ö¬";s:3:"眲";s:2:"Ö­";s:3:"眴";s:2:"Ö®";s:3:"眳";s:2:"Ö¯";s:3:"眽";s:2:"Ö°";s:3:"眥";s:2:"Ö±";s:3:"眻";s:2:"Ö²";s:3:"眵";s:2:"Ö³";s:3:"硈";s:2:"Ö´";s:3:"ç¡’";s:2:"Öµ";s:3:"硉";s:2:"Ö¶";s:3:"ç¡";s:2:"Ö·";s:3:"ç¡Š";s:2:"Ö¸";s:3:"ç¡Œ";s:2:"Ö¹";s:3:"ç ¦";s:2:"Öº";s:3:"ç¡…";s:2:"Ö»";s:3:"ç¡";s:2:"Ö¼";s:3:"祤";s:2:"Ö½";s:3:"祧";s:2:"Ö¾";s:3:"祩";s:2:"Ö¿";s:3:"祪";s:2:"ÖÀ";s:3:"祣";s:2:"ÖÁ";s:3:"祫";s:2:"ÖÂ";s:3:"祡";s:2:"ÖÃ";s:3:"离";s:2:"ÖÄ";s:3:"秺";s:2:"ÖÅ";s:3:"秸";s:2:"ÖÆ";s:3:"秶";s:2:"ÖÇ";s:3:"秷";s:2:"ÖÈ";s:3:"çª";s:2:"ÖÉ";s:3:"窔";s:2:"ÖÊ";s:3:"çª";s:2:"ÖË";s:3:"笵";s:2:"ÖÌ";s:3:"ç­‡";s:2:"ÖÍ";s:3:"笴";s:2:"ÖÎ";s:3:"笥";s:2:"ÖÏ";s:3:"笰";s:2:"ÖÐ";s:3:"笢";s:2:"ÖÑ";s:3:"笤";s:2:"ÖÒ";s:3:"笳";s:2:"ÖÓ";s:3:"笘";s:2:"ÖÔ";s:3:"笪";s:2:"ÖÕ";s:3:"ç¬";s:2:"ÖÖ";s:3:"笱";s:2:"Ö×";s:3:"笫";s:2:"ÖØ";s:3:"笭";s:2:"ÖÙ";s:3:"笯";s:2:"ÖÚ";s:3:"笲";s:2:"ÖÛ";s:3:"笸";s:2:"ÖÜ";s:3:"笚";s:2:"ÖÝ";s:3:"笣";s:2:"ÖÞ";s:3:"ç²”";s:2:"Öß";s:3:"粘";s:2:"Öà";s:3:"ç²–";s:2:"Öá";s:3:"ç²£";s:2:"Öâ";s:3:"ç´µ";s:2:"Öã";s:3:"ç´½";s:2:"Öä";s:3:"ç´¸";s:2:"Öå";s:3:"ç´¶";s:2:"Öæ";s:3:"ç´º";s:2:"Öç";s:3:"çµ…";s:2:"Öè";s:3:"ç´¬";s:2:"Öé";s:3:"ç´©";s:2:"Öê";s:3:"çµ";s:2:"Öë";s:3:"絇";s:2:"Öì";s:3:"ç´¾";s:2:"Öí";s:3:"ç´¿";s:2:"Öî";s:3:"絊";s:2:"Öï";s:3:"ç´»";s:2:"Öð";s:3:"ç´¨";s:2:"Öñ";s:3:"ç½£";s:2:"Öò";s:3:"羕";s:2:"Öó";s:3:"羜";s:2:"Öô";s:3:"ç¾";s:2:"Öõ";s:3:"ç¾›";s:2:"Öö";s:3:"ç¿Š";s:2:"Ö÷";s:3:"ç¿‹";s:2:"Öø";s:3:"ç¿";s:2:"Öù";s:3:"ç¿";s:2:"Öú";s:3:"ç¿‘";s:2:"Öû";s:3:"翇";s:2:"Öü";s:3:"ç¿";s:2:"Öý";s:3:"翉";s:2:"Öþ";s:3:"耟";s:2:"×@";s:3:"耞";s:2:"×A";s:3:"耛";s:2:"×B";s:3:"è‡";s:2:"×C";s:3:"èƒ";s:2:"×D";s:3:"èˆ";s:2:"×E";s:3:"脘";s:2:"×F";s:3:"è„¥";s:2:"×G";s:3:"è„™";s:2:"×H";s:3:"è„›";s:2:"×I";s:3:"è„­";s:2:"×J";s:3:"è„Ÿ";s:2:"×K";s:3:"脬";s:2:"×L";s:3:"è„ž";s:2:"×M";s:3:"è„¡";s:2:"×N";s:3:"è„•";s:2:"×O";s:3:"脧";s:2:"×P";s:3:"è„";s:2:"×Q";s:3:"è„¢";s:2:"×R";s:3:"舑";s:2:"×S";s:3:"舸";s:2:"×T";s:3:"舳";s:2:"×U";s:3:"舺";s:2:"×V";s:3:"舴";s:2:"×W";s:3:"舲";s:2:"×X";s:3:"艴";s:2:"×Y";s:3:"èŽ";s:2:"×Z";s:3:"莣";s:2:"×[";s:3:"莨";s:2:"×\";s:3:"èŽ";s:2:"×]";s:3:"èº";s:2:"×^";s:3:"è³";s:2:"×_";s:3:"莤";s:2:"×`";s:3:"è´";s:2:"×a";s:3:"èŽ";s:2:"×b";s:3:"èŽ";s:2:"×c";s:3:"莕";s:2:"×d";s:3:"莙";s:2:"×e";s:3:"èµ";s:2:"×f";s:3:"莔";s:2:"×g";s:3:"莩";s:2:"×h";s:3:"è½";s:2:"×i";s:3:"莃";s:2:"×j";s:3:"莌";s:2:"×k";s:3:"èŽ";s:2:"×l";s:3:"莛";s:2:"×m";s:3:"莪";s:2:"×n";s:3:"莋";s:2:"×o";s:3:"è¾";s:2:"×p";s:3:"莥";s:2:"×q";s:3:"莯";s:2:"×r";s:3:"莈";s:2:"×s";s:3:"莗";s:2:"×t";s:3:"莰";s:2:"×u";s:3:"è¿";s:2:"×v";s:3:"莦";s:2:"×w";s:3:"莇";s:2:"×x";s:3:"莮";s:2:"×y";s:3:"è¶";s:2:"×z";s:3:"莚";s:2:"×{";s:3:"è™™";s:2:"×|";s:3:"è™–";s:2:"×}";s:3:"èš¿";s:2:"×~";s:3:"èš·";s:2:"ס";s:3:"蛂";s:2:"×¢";s:3:"è›";s:2:"×£";s:3:"è›…";s:2:"פ";s:3:"蚺";s:2:"×¥";s:3:"èš°";s:2:"צ";s:3:"蛈";s:2:"ק";s:3:"èš¹";s:2:"ר";s:3:"èš³";s:2:"ש";s:3:"蚸";s:2:"ת";s:3:"蛌";s:2:"׫";s:3:"èš´";s:2:"׬";s:3:"èš»";s:2:"×­";s:3:"èš¼";s:2:"×®";s:3:"蛃";s:2:"ׯ";s:3:"èš½";s:2:"×°";s:3:"èš¾";s:2:"×±";s:3:"è¡’";s:2:"ײ";s:3:"袉";s:2:"׳";s:3:"袕";s:2:"×´";s:3:"袨";s:2:"×µ";s:3:"袢";s:2:"׶";s:3:"袪";s:2:"×·";s:3:"袚";s:2:"׸";s:3:"袑";s:2:"×¹";s:3:"袡";s:2:"׺";s:3:"袟";s:2:"×»";s:3:"袘";s:2:"×¼";s:3:"袧";s:2:"×½";s:3:"袙";s:2:"×¾";s:3:"袛";s:2:"׿";s:3:"袗";s:2:"×À";s:3:"袤";s:2:"×Á";s:3:"袬";s:2:"×Â";s:3:"袌";s:2:"×Ã";s:3:"袓";s:2:"×Ä";s:3:"袎";s:2:"×Å";s:3:"覂";s:2:"×Æ";s:3:"觖";s:2:"×Ç";s:3:"觙";s:2:"×È";s:3:"觕";s:2:"×É";s:3:"訰";s:2:"×Ê";s:3:"訧";s:2:"×Ë";s:3:"訬";s:2:"×Ì";s:3:"訞";s:2:"×Í";s:3:"è°¹";s:2:"×Î";s:3:"è°»";s:2:"×Ï";s:3:"豜";s:2:"×Ð";s:3:"è±";s:2:"×Ñ";s:3:"è±½";s:2:"×Ò";s:3:"è²¥";s:2:"×Ó";s:3:"èµ½";s:2:"×Ô";s:3:"èµ»";s:2:"×Õ";s:3:"èµ¹";s:2:"×Ö";s:3:"趼";s:2:"××";s:3:"è·‚";s:2:"×Ø";s:3:"趹";s:2:"×Ù";s:3:"趿";s:2:"×Ú";s:3:"è·";s:2:"×Û";s:3:"軘";s:2:"×Ü";s:3:"軞";s:2:"×Ý";s:3:"è»";s:2:"×Þ";s:3:"軜";s:2:"×ß";s:3:"è»—";s:2:"×à";s:3:"è» ";s:2:"×á";s:3:"軡";s:2:"×â";s:3:"逤";s:2:"×ã";s:3:"逋";s:2:"×ä";s:3:"逑";s:2:"×å";s:3:"逜";s:2:"×æ";s:3:"逌";s:2:"×ç";s:3:"逡";s:2:"×è";s:3:"郯";s:2:"×é";s:3:"郪";s:2:"×ê";s:3:"郰";s:2:"×ë";s:3:"郴";s:2:"×ì";s:3:"郲";s:2:"×í";s:3:"郳";s:2:"×î";s:3:"郔";s:2:"×ï";s:3:"郫";s:2:"×ð";s:3:"郬";s:2:"×ñ";s:3:"郩";s:2:"×ò";s:3:"é…–";s:2:"×ó";s:3:"é…˜";s:2:"×ô";s:3:"é…š";s:2:"×õ";s:3:"é…“";s:2:"×ö";s:3:"é…•";s:2:"×÷";s:3:"釬";s:2:"×ø";s:3:"釴";s:2:"×ù";s:3:"釱";s:2:"×ú";s:3:"釳";s:2:"×û";s:3:"釸";s:2:"×ü";s:3:"釤";s:2:"×ý";s:3:"釹";s:2:"×þ";s:3:"釪";s:2:"Ø@";s:3:"釫";s:2:"ØA";s:3:"釷";s:2:"ØB";s:3:"釨";s:2:"ØC";s:3:"釮";s:2:"ØD";s:3:"镺";s:2:"ØE";s:3:"é–†";s:2:"ØF";s:3:"é–ˆ";s:2:"ØG";s:3:"陼";s:2:"ØH";s:3:"é™­";s:2:"ØI";s:3:"陫";s:2:"ØJ";s:3:"é™±";s:2:"ØK";s:3:"陯";s:2:"ØL";s:3:"éš¿";s:2:"ØM";s:3:"éª";s:2:"ØN";s:3:"é „";s:2:"ØO";s:3:"飥";s:2:"ØP";s:3:"馗";s:2:"ØQ";s:3:"å‚›";s:2:"ØR";s:3:"å‚•";s:2:"ØS";s:3:"å‚”";s:2:"ØT";s:3:"å‚ž";s:2:"ØU";s:3:"å‚‹";s:2:"ØV";s:3:"å‚£";s:2:"ØW";s:3:"傃";s:2:"ØX";s:3:"å‚Œ";s:2:"ØY";s:3:"å‚Ž";s:2:"ØZ";s:3:"å‚";s:2:"Ø[";s:3:"å¨";s:2:"Ø\";s:3:"å‚œ";s:2:"Ø]";s:3:"å‚’";s:2:"Ø^";s:3:"å‚‚";s:2:"Ø_";s:3:"傇";s:2:"Ø`";s:3:"å…Ÿ";s:2:"Øa";s:3:"凔";s:2:"Øb";s:3:"匒";s:2:"Øc";s:3:"匑";s:2:"Ød";s:3:"厤";s:2:"Øe";s:3:"厧";s:2:"Øf";s:3:"å–‘";s:2:"Øg";s:3:"å–¨";s:2:"Øh";s:3:"å–¥";s:2:"Øi";s:3:"å–­";s:2:"Øj";s:3:"å•·";s:2:"Øk";s:3:"å™…";s:2:"Øl";s:3:"å–¢";s:2:"Øm";s:3:"å–“";s:2:"Øn";s:3:"å–ˆ";s:2:"Øo";s:3:"å–";s:2:"Øp";s:3:"å–µ";s:2:"Øq";s:3:"å–";s:2:"Ør";s:3:"å–£";s:2:"Øs";s:3:"å–’";s:2:"Øt";s:3:"å–¤";s:2:"Øu";s:3:"啽";s:2:"Øv";s:3:"å–Œ";s:2:"Øw";s:3:"å–¦";s:2:"Øx";s:3:"å•¿";s:2:"Øy";s:3:"å–•";s:2:"Øz";s:3:"å–¡";s:2:"Ø{";s:3:"å–Ž";s:2:"Ø|";s:3:"圌";s:2:"Ø}";s:3:"å ©";s:2:"Ø~";s:3:"å ·";s:2:"Ø¡";s:3:"å ™";s:2:"Ø¢";s:3:"å ž";s:2:"Ø£";s:3:"å §";s:2:"ؤ";s:3:"å £";s:2:"Ø¥";s:3:"å ¨";s:2:"ئ";s:3:"埵";s:2:"ا";s:3:"塈";s:2:"ب";s:3:"å ¥";s:2:"Ø©";s:3:"å œ";s:2:"ت";s:3:"å ›";s:2:"Ø«";s:3:"å ³";s:2:"ج";s:3:"å ¿";s:2:"Ø­";s:3:"å ¶";s:2:"Ø®";s:3:"å ®";s:2:"د";s:3:"å ¹";s:2:"Ø°";s:3:"å ¸";s:2:"ر";s:3:"å ­";s:2:"ز";s:3:"å ¬";s:2:"س";s:3:"å »";s:2:"Ø´";s:3:"奡";s:2:"ص";s:3:"媯";s:2:"ض";s:3:"媔";s:2:"Ø·";s:3:"媟";s:2:"ظ";s:3:"婺";s:2:"ع";s:3:"媢";s:2:"غ";s:3:"媞";s:2:"Ø»";s:3:"婸";s:2:"ؼ";s:3:"媦";s:2:"ؽ";s:3:"婼";s:2:"ؾ";s:3:"媥";s:2:"Ø¿";s:3:"媬";s:2:"ØÀ";s:3:"媕";s:2:"ØÁ";s:3:"媮";s:2:"ØÂ";s:3:"娷";s:2:"ØÃ";s:3:"媄";s:2:"ØÄ";s:3:"媊";s:2:"ØÅ";s:3:"媗";s:2:"ØÆ";s:3:"媃";s:2:"ØÇ";s:3:"媋";s:2:"ØÈ";s:3:"媩";s:2:"ØÉ";s:3:"å©»";s:2:"ØÊ";s:3:"婽";s:2:"ØË";s:3:"媌";s:2:"ØÌ";s:3:"媜";s:2:"ØÍ";s:3:"åª";s:2:"ØÎ";s:3:"媓";s:2:"ØÏ";s:3:"åª";s:2:"ØÐ";s:3:"寪";s:2:"ØÑ";s:3:"å¯";s:2:"ØÒ";s:3:"寋";s:2:"ØÓ";s:3:"寔";s:2:"ØÔ";s:3:"寑";s:2:"ØÕ";s:3:"寊";s:2:"ØÖ";s:3:"寎";s:2:"Ø×";s:3:"å°Œ";s:2:"ØØ";s:3:"å°°";s:2:"ØÙ";s:3:"å´·";s:2:"ØÚ";s:3:"嵃";s:2:"ØÛ";s:3:"嵫";s:2:"ØÜ";s:3:"åµ";s:2:"ØÝ";s:3:"嵋";s:2:"ØÞ";s:3:"å´¿";s:2:"Øß";s:3:"å´µ";s:2:"Øà";s:3:"嵑";s:2:"Øá";s:3:"嵎";s:2:"Øâ";s:3:"嵕";s:2:"Øã";s:3:"å´³";s:2:"Øä";s:3:"å´º";s:2:"Øå";s:3:"åµ’";s:2:"Øæ";s:3:"å´½";s:2:"Øç";s:3:"å´±";s:2:"Øè";s:3:"åµ™";s:2:"Øé";s:3:"嵂";s:2:"Øê";s:3:"å´¹";s:2:"Øë";s:3:"嵉";s:2:"Øì";s:3:"å´¸";s:2:"Øí";s:3:"å´¼";s:2:"Øî";s:3:"å´²";s:2:"Øï";s:3:"å´¶";s:2:"Øð";s:3:"åµ€";s:2:"Øñ";s:3:"åµ…";s:2:"Øò";s:3:"幄";s:2:"Øó";s:3:"å¹";s:2:"Øô";s:3:"彘";s:2:"Øõ";s:3:"徦";s:2:"Øö";s:3:"å¾¥";s:2:"Ø÷";s:3:"徫";s:2:"Øø";s:3:"惉";s:2:"Øù";s:3:"悹";s:2:"Øú";s:3:"惌";s:2:"Øû";s:3:"惢";s:2:"Øü";s:3:"惎";s:2:"Øý";s:3:"惄";s:2:"Øþ";s:3:"æ„”";s:2:"Ù@";s:3:"惲";s:2:"ÙA";s:3:"æ„Š";s:2:"ÙB";s:3:"æ„–";s:2:"ÙC";s:3:"æ„…";s:2:"ÙD";s:3:"惵";s:2:"ÙE";s:3:"æ„“";s:2:"ÙF";s:3:"惸";s:2:"ÙG";s:3:"惼";s:2:"ÙH";s:3:"惾";s:2:"ÙI";s:3:"æƒ";s:2:"ÙJ";s:3:"愃";s:2:"ÙK";s:3:"愘";s:2:"ÙL";s:3:"æ„";s:2:"ÙM";s:3:"æ„";s:2:"ÙN";s:3:"惿";s:2:"ÙO";s:3:"æ„„";s:2:"ÙP";s:3:"æ„‹";s:2:"ÙQ";s:3:"扊";s:2:"ÙR";s:3:"掔";s:2:"ÙS";s:3:"掱";s:2:"ÙT";s:3:"掰";s:2:"ÙU";s:3:"æŽ";s:2:"ÙV";s:3:"æ¥";s:2:"ÙW";s:3:"æ¨";s:2:"ÙX";s:3:"æ¯";s:2:"ÙY";s:3:"æƒ";s:2:"ÙZ";s:3:"æ’";s:2:"Ù[";s:3:"æ³";s:2:"Ù\";s:3:"æŠ";s:2:"Ù]";s:3:"æ ";s:2:"Ù^";s:3:"æ¶";s:2:"Ù_";s:3:"æ•";s:2:"Ù`";s:3:"æ²";s:2:"Ùa";s:3:"æµ";s:2:"Ùb";s:3:"æ‘¡";s:2:"Ùc";s:3:"æŸ";s:2:"Ùd";s:3:"掾";s:2:"Ùe";s:3:"æ";s:2:"Ùf";s:3:"æœ";s:2:"Ùg";s:3:"æ„";s:2:"Ùh";s:3:"æ˜";s:2:"Ùi";s:3:"æ“";s:2:"Ùj";s:3:"æ‚";s:2:"Ùk";s:3:"æ‡";s:2:"Ùl";s:3:"æŒ";s:2:"Ùm";s:3:"æ‹";s:2:"Ùn";s:3:"æˆ";s:2:"Ùo";s:3:"æ°";s:2:"Ùp";s:3:"æ—";s:2:"Ùq";s:3:"æ™";s:2:"Ùr";s:3:"攲";s:2:"Ùs";s:3:"敧";s:2:"Ùt";s:3:"敪";s:2:"Ùu";s:3:"敤";s:2:"Ùv";s:3:"æ•œ";s:2:"Ùw";s:3:"敨";s:2:"Ùx";s:3:"æ•¥";s:2:"Ùy";s:3:"æ–Œ";s:2:"Ùz";s:3:"æ–";s:2:"Ù{";s:3:"æ–ž";s:2:"Ù|";s:3:"æ–®";s:2:"Ù}";s:3:"æ—";s:2:"Ù~";s:3:"æ—’";s:2:"Ù¡";s:3:"晼";s:2:"Ù¢";s:3:"晬";s:2:"Ù£";s:3:"æ™»";s:2:"Ù¤";s:3:"暀";s:2:"Ù¥";s:3:"æ™±";s:2:"Ù¦";s:3:"晹";s:2:"Ù§";s:3:"晪";s:2:"Ù¨";s:3:"晲";s:2:"Ù©";s:3:"æœ";s:2:"Ùª";s:3:"椌";s:2:"Ù«";s:3:"棓";s:2:"Ù¬";s:3:"椄";s:2:"Ù­";s:3:"棜";s:2:"Ù®";s:3:"椪";s:2:"Ù¯";s:3:"棬";s:2:"Ù°";s:3:"棪";s:2:"Ù±";s:3:"棱";s:2:"Ù²";s:3:"æ¤";s:2:"Ù³";s:3:"棖";s:2:"Ù´";s:3:"棷";s:2:"Ùµ";s:3:"棫";s:2:"Ù¶";s:3:"棤";s:2:"Ù·";s:3:"棶";s:2:"Ù¸";s:3:"椓";s:2:"Ù¹";s:3:"æ¤";s:2:"Ùº";s:3:"棳";s:2:"Ù»";s:3:"棡";s:2:"Ù¼";s:3:"椇";s:2:"Ù½";s:3:"棌";s:2:"Ù¾";s:3:"椈";s:2:"Ù¿";s:3:"楰";s:2:"ÙÀ";s:3:"梴";s:2:"ÙÁ";s:3:"椑";s:2:"ÙÂ";s:3:"棯";s:2:"ÙÃ";s:3:"棆";s:2:"ÙÄ";s:3:"椔";s:2:"ÙÅ";s:3:"棸";s:2:"ÙÆ";s:3:"æ£";s:2:"ÙÇ";s:3:"棽";s:2:"ÙÈ";s:3:"棼";s:2:"ÙÉ";s:3:"棨";s:2:"ÙÊ";s:3:"椋";s:2:"ÙË";s:3:"椊";s:2:"ÙÌ";s:3:"椗";s:2:"ÙÍ";s:3:"棎";s:2:"ÙÎ";s:3:"棈";s:2:"ÙÏ";s:3:"æ£";s:2:"ÙÐ";s:3:"棞";s:2:"ÙÑ";s:3:"棦";s:2:"ÙÒ";s:3:"棴";s:2:"ÙÓ";s:3:"棑";s:2:"ÙÔ";s:3:"椆";s:2:"ÙÕ";s:3:"棔";s:2:"ÙÖ";s:3:"棩";s:2:"Ù×";s:3:"椕";s:2:"ÙØ";s:3:"椥";s:2:"ÙÙ";s:3:"棇";s:2:"ÙÚ";s:3:"欹";s:2:"ÙÛ";s:3:"欻";s:2:"ÙÜ";s:3:"欿";s:2:"ÙÝ";s:3:"欼";s:2:"ÙÞ";s:3:"æ®”";s:2:"Ùß";s:3:"æ®—";s:2:"Ùà";s:3:"æ®™";s:2:"Ùá";s:3:"殕";s:2:"Ùâ";s:3:"殽";s:2:"Ùã";s:3:"毰";s:2:"Ùä";s:3:"毲";s:2:"Ùå";s:3:"毳";s:2:"Ùæ";s:3:"æ°°";s:2:"Ùç";s:3:"æ·¼";s:2:"Ùè";s:3:"湆";s:2:"Ùé";s:3:"湇";s:2:"Ùê";s:3:"渟";s:2:"Ùë";s:3:"湉";s:2:"Ùì";s:3:"溈";s:2:"Ùí";s:3:"渼";s:2:"Ùî";s:3:"渽";s:2:"Ùï";s:3:"æ¹…";s:2:"Ùð";s:3:"æ¹¢";s:2:"Ùñ";s:3:"渫";s:2:"Ùò";s:3:"渿";s:2:"Ùó";s:3:"æ¹";s:2:"Ùô";s:3:"æ¹";s:2:"Ùõ";s:3:"æ¹³";s:2:"Ùö";s:3:"渜";s:2:"Ù÷";s:3:"渳";s:2:"Ùø";s:3:"湋";s:2:"Ùù";s:3:"æ¹€";s:2:"Ùú";s:3:"湑";s:2:"Ùû";s:3:"渻";s:2:"Ùü";s:3:"渃";s:2:"Ùý";s:3:"渮";s:2:"Ùþ";s:3:"湞";s:2:"Ú@";s:3:"湨";s:2:"ÚA";s:3:"湜";s:2:"ÚB";s:3:"湡";s:2:"ÚC";s:3:"渱";s:2:"ÚD";s:3:"渨";s:2:"ÚE";s:3:"æ¹ ";s:2:"ÚF";s:3:"æ¹±";s:2:"ÚG";s:3:"湫";s:2:"ÚH";s:3:"渹";s:2:"ÚI";s:3:"渢";s:2:"ÚJ";s:3:"渰";s:2:"ÚK";s:3:"湓";s:2:"ÚL";s:3:"æ¹¥";s:2:"ÚM";s:3:"渧";s:2:"ÚN";s:3:"湸";s:2:"ÚO";s:3:"湤";s:2:"ÚP";s:3:"æ¹·";s:2:"ÚQ";s:3:"湕";s:2:"ÚR";s:3:"æ¹¹";s:2:"ÚS";s:3:"æ¹’";s:2:"ÚT";s:3:"湦";s:2:"ÚU";s:3:"渵";s:2:"ÚV";s:3:"渶";s:2:"ÚW";s:3:"湚";s:2:"ÚX";s:3:"ç„ ";s:2:"ÚY";s:3:"ç„ž";s:2:"ÚZ";s:3:"焯";s:2:"Ú[";s:3:"烻";s:2:"Ú\";s:3:"ç„®";s:2:"Ú]";s:3:"焱";s:2:"Ú^";s:3:"ç„£";s:2:"Ú_";s:3:"ç„¥";s:2:"Ú`";s:3:"ç„¢";s:2:"Úa";s:3:"焲";s:2:"Úb";s:3:"ç„Ÿ";s:2:"Úc";s:3:"焨";s:2:"Úd";s:3:"焺";s:2:"Úe";s:3:"ç„›";s:2:"Úf";s:3:"牋";s:2:"Úg";s:3:"牚";s:2:"Úh";s:3:"犈";s:2:"Úi";s:3:"犉";s:2:"Új";s:3:"犆";s:2:"Úk";s:3:"犅";s:2:"Úl";s:3:"犋";s:2:"Úm";s:3:"猒";s:2:"Ún";s:3:"猋";s:2:"Úo";s:3:"猰";s:2:"Úp";s:3:"猢";s:2:"Úq";s:3:"猱";s:2:"Úr";s:3:"猳";s:2:"Ús";s:3:"猧";s:2:"Út";s:3:"猲";s:2:"Úu";s:3:"猭";s:2:"Úv";s:3:"猦";s:2:"Úw";s:3:"猣";s:2:"Úx";s:3:"猵";s:2:"Úy";s:3:"猌";s:2:"Úz";s:3:"ç®";s:2:"Ú{";s:3:"ç¬";s:2:"Ú|";s:3:"ç°";s:2:"Ú}";s:3:"ç«";s:2:"Ú~";s:3:"ç–";s:2:"Ú¡";s:3:"çš";s:2:"Ú¢";s:3:"ç¡";s:2:"Ú£";s:3:"ç­";s:2:"Ú¤";s:3:"ç±";s:2:"Ú¥";s:3:"ç¤";s:2:"Ú¦";s:3:"ç£";s:2:"Ú§";s:3:"ç";s:2:"Ú¨";s:3:"ç©";s:2:"Ú©";s:3:"ç ";s:2:"Úª";s:3:"ç²";s:2:"Ú«";s:3:"ç“»";s:2:"Ú¬";s:3:"甯";s:2:"Ú­";s:3:"畯";s:2:"Ú®";s:3:"畬";s:2:"Ú¯";s:3:"ç—§";s:2:"Ú°";s:3:"ç—š";s:2:"Ú±";s:3:"ç—¡";s:2:"Ú²";s:3:"ç—¦";s:2:"Ú³";s:3:"ç—";s:2:"Ú´";s:3:"ç—Ÿ";s:2:"Úµ";s:3:"ç—¤";s:2:"Ú¶";s:3:"ç——";s:2:"Ú·";s:3:"çš•";s:2:"Ú¸";s:3:"çš’";s:2:"Ú¹";s:3:"盚";s:2:"Úº";s:3:"ç†";s:2:"Ú»";s:3:"ç‡";s:2:"Ú¼";s:3:"ç„";s:2:"Ú½";s:3:"ç";s:2:"Ú¾";s:3:"ç…";s:2:"Ú¿";s:3:"çŠ";s:2:"ÚÀ";s:3:"çŽ";s:2:"ÚÁ";s:3:"ç‹";s:2:"ÚÂ";s:3:"çŒ";s:2:"ÚÃ";s:3:"矞";s:2:"ÚÄ";s:3:"矬";s:2:"ÚÅ";s:3:"ç¡ ";s:2:"ÚÆ";s:3:"硤";s:2:"ÚÇ";s:3:"ç¡¥";s:2:"ÚÈ";s:3:"ç¡œ";s:2:"ÚÉ";s:3:"ç¡­";s:2:"ÚÊ";s:3:"硱";s:2:"ÚË";s:3:"硪";s:2:"ÚÌ";s:3:"ç¡®";s:2:"ÚÍ";s:3:"ç¡°";s:2:"ÚÎ";s:3:"ç¡©";s:2:"ÚÏ";s:3:"硨";s:2:"ÚÐ";s:3:"ç¡ž";s:2:"ÚÑ";s:3:"ç¡¢";s:2:"ÚÒ";s:3:"祴";s:2:"ÚÓ";s:3:"祳";s:2:"ÚÔ";s:3:"祲";s:2:"ÚÕ";s:3:"祰";s:2:"ÚÖ";s:3:"稂";s:2:"Ú×";s:3:"稊";s:2:"ÚØ";s:3:"稃";s:2:"ÚÙ";s:3:"稌";s:2:"ÚÚ";s:3:"稄";s:2:"ÚÛ";s:3:"窙";s:2:"ÚÜ";s:3:"竦";s:2:"ÚÝ";s:3:"竤";s:2:"ÚÞ";s:3:"ç­Š";s:2:"Úß";s:3:"笻";s:2:"Úà";s:3:"ç­„";s:2:"Úá";s:3:"ç­ˆ";s:2:"Úâ";s:3:"ç­Œ";s:2:"Úã";s:3:"ç­Ž";s:2:"Úä";s:3:"ç­€";s:2:"Úå";s:3:"ç­˜";s:2:"Úæ";s:3:"ç­…";s:2:"Úç";s:3:"ç²¢";s:2:"Úè";s:3:"粞";s:2:"Úé";s:3:"粨";s:2:"Úê";s:3:"粡";s:2:"Úë";s:3:"絘";s:2:"Úì";s:3:"絯";s:2:"Úí";s:3:"çµ£";s:2:"Úî";s:3:"絓";s:2:"Úï";s:3:"çµ–";s:2:"Úð";s:3:"絧";s:2:"Úñ";s:3:"絪";s:2:"Úò";s:3:"çµ";s:2:"Úó";s:3:"çµ­";s:2:"Úô";s:3:"絜";s:2:"Úõ";s:3:"絫";s:2:"Úö";s:3:"çµ’";s:2:"Ú÷";s:3:"çµ”";s:2:"Úø";s:3:"絩";s:2:"Úù";s:3:"絑";s:2:"Úú";s:3:"絟";s:2:"Úû";s:3:"絎";s:2:"Úü";s:3:"ç¼¾";s:2:"Úý";s:3:"缿";s:2:"Úþ";s:3:"ç½¥";s:2:"Û@";s:3:"罦";s:2:"ÛA";s:3:"ç¾¢";s:2:"ÛB";s:3:"ç¾ ";s:2:"ÛC";s:3:"羡";s:2:"ÛD";s:3:"ç¿—";s:2:"ÛE";s:3:"è‘";s:2:"ÛF";s:3:"è";s:2:"ÛG";s:3:"è";s:2:"ÛH";s:3:"胾";s:2:"ÛI";s:3:"胔";s:2:"ÛJ";s:3:"è…ƒ";s:2:"ÛK";s:3:"è…Š";s:2:"ÛL";s:3:"è…’";s:2:"ÛM";s:3:"è…";s:2:"ÛN";s:3:"è…‡";s:2:"ÛO";s:3:"脽";s:2:"ÛP";s:3:"è…";s:2:"ÛQ";s:3:"脺";s:2:"ÛR";s:3:"臦";s:2:"ÛS";s:3:"臮";s:2:"ÛT";s:3:"臷";s:2:"ÛU";s:3:"臸";s:2:"ÛV";s:3:"臹";s:2:"ÛW";s:3:"舄";s:2:"ÛX";s:3:"舼";s:2:"ÛY";s:3:"舽";s:2:"ÛZ";s:3:"舿";s:2:"Û[";s:3:"艵";s:2:"Û\";s:3:"茻";s:2:"Û]";s:3:"è";s:2:"Û^";s:3:"è¹";s:2:"Û_";s:3:"è£";s:2:"Û`";s:3:"è€";s:2:"Ûa";s:3:"è¨";s:2:"Ûb";s:3:"è’";s:2:"Ûc";s:3:"è§";s:2:"Ûd";s:3:"è¤";s:2:"Ûe";s:3:"è¼";s:2:"Ûf";s:3:"è¶";s:2:"Ûg";s:3:"è";s:2:"Ûh";s:3:"è†";s:2:"Ûi";s:3:"èˆ";s:2:"Ûj";s:3:"è«";s:2:"Ûk";s:3:"è£";s:2:"Ûl";s:3:"莿";s:2:"Ûm";s:3:"è";s:2:"Ûn";s:3:"è";s:2:"Ûo";s:3:"è¥";s:2:"Ûp";s:3:"è˜";s:2:"Ûq";s:3:"è¿";s:2:"Ûr";s:3:"è¡";s:2:"Ûs";s:3:"è‹";s:2:"Ût";s:3:"èŽ";s:2:"Ûu";s:3:"è–";s:2:"Ûv";s:3:"èµ";s:2:"Ûw";s:3:"è‰";s:2:"Ûx";s:3:"è‰";s:2:"Ûy";s:3:"è";s:2:"Ûz";s:3:"èž";s:2:"Û{";s:3:"è‘";s:2:"Û|";s:3:"è†";s:2:"Û}";s:3:"è‚";s:2:"Û~";s:3:"è³";s:2:"Û¡";s:3:"è•";s:2:"Û¢";s:3:"èº";s:2:"Û£";s:3:"è‡";s:2:"Û¤";s:3:"è‘";s:2:"Û¥";s:3:"èª";s:2:"Û¦";s:3:"è“";s:2:"Û§";s:3:"èƒ";s:2:"Û¨";s:3:"è¬";s:2:"Û©";s:3:"è®";s:2:"Ûª";s:3:"è„";s:2:"Û«";s:3:"è»";s:2:"Û¬";s:3:"è—";s:2:"Û­";s:3:"è¢";s:2:"Û®";s:3:"è›";s:2:"Û¯";s:3:"è›";s:2:"Û°";s:3:"è¾";s:2:"Û±";s:3:"蛘";s:2:"Û²";s:3:"蛢";s:2:"Û³";s:3:"蛦";s:2:"Û´";s:3:"蛓";s:2:"Ûµ";s:3:"蛣";s:2:"Û¶";s:3:"蛚";s:2:"Û·";s:3:"蛪";s:2:"Û¸";s:3:"è›";s:2:"Û¹";s:3:"蛫";s:2:"Ûº";s:3:"蛜";s:2:"Û»";s:3:"蛬";s:2:"Û¼";s:3:"蛩";s:2:"Û½";s:3:"è›—";s:2:"Û¾";s:3:"蛨";s:2:"Û¿";s:3:"蛑";s:2:"ÛÀ";s:3:"衈";s:2:"ÛÁ";s:3:"è¡–";s:2:"ÛÂ";s:3:"è¡•";s:2:"ÛÃ";s:3:"袺";s:2:"ÛÄ";s:3:"裗";s:2:"ÛÅ";s:3:"袹";s:2:"ÛÆ";s:3:"袸";s:2:"ÛÇ";s:3:"裀";s:2:"ÛÈ";s:3:"袾";s:2:"ÛÉ";s:3:"袶";s:2:"ÛÊ";s:3:"袼";s:2:"ÛË";s:3:"袷";s:2:"ÛÌ";s:3:"袽";s:2:"ÛÍ";s:3:"袲";s:2:"ÛÎ";s:3:"è¤";s:2:"ÛÏ";s:3:"裉";s:2:"ÛÐ";s:3:"覕";s:2:"ÛÑ";s:3:"覘";s:2:"ÛÒ";s:3:"覗";s:2:"ÛÓ";s:3:"è§";s:2:"ÛÔ";s:3:"觚";s:2:"ÛÕ";s:3:"觛";s:2:"ÛÖ";s:3:"è©Ž";s:2:"Û×";s:3:"è©";s:2:"ÛØ";s:3:"訹";s:2:"ÛÙ";s:3:"è©™";s:2:"ÛÚ";s:3:"è©€";s:2:"ÛÛ";s:3:"è©—";s:2:"ÛÜ";s:3:"詘";s:2:"ÛÝ";s:3:"è©„";s:2:"ÛÞ";s:3:"è©…";s:2:"Ûß";s:3:"è©’";s:2:"Ûà";s:3:"詈";s:2:"Ûá";s:3:"è©‘";s:2:"Ûâ";s:3:"è©Š";s:2:"Ûã";s:3:"è©Œ";s:2:"Ûä";s:3:"è©";s:2:"Ûå";s:3:"豟";s:2:"Ûæ";s:3:"è²";s:2:"Ûç";s:3:"è²€";s:2:"Ûè";s:3:"貺";s:2:"Ûé";s:3:"è²¾";s:2:"Ûê";s:3:"è²°";s:2:"Ûë";s:3:"è²¹";s:2:"Ûì";s:3:"è²µ";s:2:"Ûí";s:3:"趄";s:2:"Ûî";s:3:"趀";s:2:"Ûï";s:3:"趉";s:2:"Ûð";s:3:"è·˜";s:2:"Ûñ";s:3:"è·“";s:2:"Ûò";s:3:"è·";s:2:"Ûó";s:3:"è·‡";s:2:"Ûô";s:3:"è·–";s:2:"Ûõ";s:3:"è·œ";s:2:"Ûö";s:3:"è·";s:2:"Û÷";s:3:"è·•";s:2:"Ûø";s:3:"è·™";s:2:"Ûù";s:3:"è·ˆ";s:2:"Ûú";s:3:"è·—";s:2:"Ûû";s:3:"è·…";s:2:"Ûü";s:3:"軯";s:2:"Ûý";s:3:"è»·";s:2:"Ûþ";s:3:"軺";s:2:"Ü@";s:3:"軹";s:2:"ÜA";s:3:"軦";s:2:"ÜB";s:3:"è»®";s:2:"ÜC";s:3:"軥";s:2:"ÜD";s:3:"軵";s:2:"ÜE";s:3:"軧";s:2:"ÜF";s:3:"軨";s:2:"ÜG";s:3:"軶";s:2:"ÜH";s:3:"軫";s:2:"ÜI";s:3:"è»±";s:2:"ÜJ";s:3:"軬";s:2:"ÜK";s:3:"è»´";s:2:"ÜL";s:3:"軩";s:2:"ÜM";s:3:"逭";s:2:"ÜN";s:3:"逴";s:2:"ÜO";s:3:"逯";s:2:"ÜP";s:3:"鄆";s:2:"ÜQ";s:3:"鄬";s:2:"ÜR";s:3:"é„„";s:2:"ÜS";s:3:"郿";s:2:"ÜT";s:3:"郼";s:2:"ÜU";s:3:"鄈";s:2:"ÜV";s:3:"郹";s:2:"ÜW";s:3:"郻";s:2:"ÜX";s:3:"é„";s:2:"ÜY";s:3:"é„€";s:2:"ÜZ";s:3:"鄇";s:2:"Ü[";s:3:"é„…";s:2:"Ü\";s:3:"鄃";s:2:"Ü]";s:3:"é…¡";s:2:"Ü^";s:3:"é…¤";s:2:"Ü_";s:3:"é…Ÿ";s:2:"Ü`";s:3:"é…¢";s:2:"Üa";s:3:"é… ";s:2:"Üb";s:3:"éˆ";s:2:"Üc";s:3:"鈊";s:2:"Üd";s:3:"鈥";s:2:"Üe";s:3:"鈃";s:2:"Üf";s:3:"鈚";s:2:"Üg";s:3:"鈦";s:2:"Üh";s:3:"éˆ";s:2:"Üi";s:3:"鈌";s:2:"Üj";s:3:"鈀";s:2:"Ük";s:3:"鈒";s:2:"Ül";s:3:"釿";s:2:"Üm";s:3:"釽";s:2:"Ün";s:3:"鈆";s:2:"Üo";s:3:"鈄";s:2:"Üp";s:3:"鈧";s:2:"Üq";s:3:"鈂";s:2:"Ür";s:3:"鈜";s:2:"Üs";s:3:"鈤";s:2:"Üt";s:3:"鈙";s:2:"Üu";s:3:"鈗";s:2:"Üv";s:3:"鈅";s:2:"Üw";s:3:"鈖";s:2:"Üx";s:3:"é•»";s:2:"Üy";s:3:"é–";s:2:"Üz";s:3:"é–Œ";s:2:"Ü{";s:3:"é–";s:2:"Ü|";s:3:"隇";s:2:"Ü}";s:3:"陾";s:2:"Ü~";s:3:"隈";s:2:"Ü¡";s:3:"隉";s:2:"Ü¢";s:3:"隃";s:2:"Ü£";s:3:"隀";s:2:"ܤ";s:3:"雂";s:2:"Ü¥";s:3:"雈";s:2:"ܦ";s:3:"雃";s:2:"ܧ";s:3:"é›±";s:2:"ܨ";s:3:"é›°";s:2:"Ü©";s:3:"é¬";s:2:"ܪ";s:3:"é°";s:2:"Ü«";s:3:"é®";s:2:"ܬ";s:3:"é ‡";s:2:"Ü­";s:3:"颩";s:2:"Ü®";s:3:"飫";s:2:"ܯ";s:3:"鳦";s:2:"Ü°";s:3:"黹";s:2:"ܱ";s:3:"亃";s:2:"ܲ";s:3:"亄";s:2:"ܳ";s:3:"亶";s:2:"Ü´";s:3:"傽";s:2:"ܵ";s:3:"å‚¿";s:2:"ܶ";s:3:"僆";s:2:"Ü·";s:3:"å‚®";s:2:"ܸ";s:3:"僄";s:2:"ܹ";s:3:"僊";s:2:"ܺ";s:3:"å‚´";s:2:"Ü»";s:3:"僈";s:2:"ܼ";s:3:"僂";s:2:"ܽ";s:3:"å‚°";s:2:"ܾ";s:3:"åƒ";s:2:"Ü¿";s:3:"傺";s:2:"ÜÀ";s:3:"傱";s:2:"ÜÁ";s:3:"僋";s:2:"ÜÂ";s:3:"僉";s:2:"ÜÃ";s:3:"傶";s:2:"ÜÄ";s:3:"傸";s:2:"ÜÅ";s:3:"凗";s:2:"ÜÆ";s:3:"剺";s:2:"ÜÇ";s:3:"剸";s:2:"ÜÈ";s:3:"剻";s:2:"ÜÉ";s:3:"剼";s:2:"ÜÊ";s:3:"å—ƒ";s:2:"ÜË";s:3:"å—›";s:2:"ÜÌ";s:3:"å—Œ";s:2:"ÜÍ";s:3:"å—";s:2:"ÜÎ";s:3:"å—‹";s:2:"ÜÏ";s:3:"å—Š";s:2:"ÜÐ";s:3:"å—";s:2:"ÜÑ";s:3:"å—€";s:2:"ÜÒ";s:3:"å—”";s:2:"ÜÓ";s:3:"å—„";s:2:"ÜÔ";s:3:"å—©";s:2:"ÜÕ";s:3:"å–¿";s:2:"ÜÖ";s:3:"å—’";s:2:"Ü×";s:3:"å–";s:2:"ÜØ";s:3:"å—";s:2:"ÜÙ";s:3:"å—•";s:2:"ÜÚ";s:3:"å—¢";s:2:"ÜÛ";s:3:"å—–";s:2:"ÜÜ";s:3:"å—ˆ";s:2:"ÜÝ";s:3:"å—²";s:2:"ÜÞ";s:3:"å—";s:2:"Üß";s:3:"å—™";s:2:"Üà";s:3:"å—‚";s:2:"Üá";s:3:"圔";s:2:"Üâ";s:3:"å¡“";s:2:"Üã";s:3:"塨";s:2:"Üä";s:3:"塤";s:2:"Üå";s:3:"å¡";s:2:"Üæ";s:3:"å¡";s:2:"Üç";s:3:"塉";s:2:"Üè";s:3:"塯";s:2:"Üé";s:3:"å¡•";s:2:"Üê";s:3:"å¡Ž";s:2:"Üë";s:3:"å¡";s:2:"Üì";s:3:"å¡™";s:2:"Üí";s:3:"å¡¥";s:2:"Üî";s:3:"å¡›";s:2:"Üï";s:3:"å ½";s:2:"Üð";s:3:"å¡£";s:2:"Üñ";s:3:"塱";s:2:"Üò";s:3:"壼";s:2:"Üó";s:3:"嫇";s:2:"Üô";s:3:"å«„";s:2:"Üõ";s:3:"å«‹";s:2:"Üö";s:3:"媺";s:2:"Ü÷";s:3:"媸";s:2:"Üø";s:3:"媱";s:2:"Üù";s:3:"媵";s:2:"Üú";s:3:"媰";s:2:"Üû";s:3:"媿";s:2:"Üü";s:3:"嫈";s:2:"Üý";s:3:"媻";s:2:"Üþ";s:3:"嫆";s:2:"Ý@";s:3:"媷";s:2:"ÝA";s:3:"å«€";s:2:"ÝB";s:3:"å«Š";s:2:"ÝC";s:3:"媴";s:2:"ÝD";s:3:"媶";s:2:"ÝE";s:3:"å«";s:2:"ÝF";s:3:"媹";s:2:"ÝG";s:3:"åª";s:2:"ÝH";s:3:"寖";s:2:"ÝI";s:3:"寘";s:2:"ÝJ";s:3:"寙";s:2:"ÝK";s:3:"å°Ÿ";s:2:"ÝL";s:3:"å°³";s:2:"ÝM";s:3:"åµ±";s:2:"ÝN";s:3:"åµ£";s:2:"ÝO";s:3:"嵊";s:2:"ÝP";s:3:"åµ¥";s:2:"ÝQ";s:3:"åµ²";s:2:"ÝR";s:3:"嵬";s:2:"ÝS";s:3:"嵞";s:2:"ÝT";s:3:"嵨";s:2:"ÝU";s:3:"嵧";s:2:"ÝV";s:3:"åµ¢";s:2:"ÝW";s:3:"å·°";s:2:"ÝX";s:3:"å¹";s:2:"ÝY";s:3:"幎";s:2:"ÝZ";s:3:"幊";s:2:"Ý[";s:3:"å¹";s:2:"Ý\";s:3:"幋";s:2:"Ý]";s:3:"å»…";s:2:"Ý^";s:3:"廌";s:2:"Ý_";s:3:"廆";s:2:"Ý`";s:3:"廋";s:2:"Ýa";s:3:"廇";s:2:"Ýb";s:3:"å½€";s:2:"Ýc";s:3:"徯";s:2:"Ýd";s:3:"å¾­";s:2:"Ýe";s:3:"惷";s:2:"Ýf";s:3:"æ…‰";s:2:"Ýg";s:3:"æ…Š";s:2:"Ýh";s:3:"æ„«";s:2:"Ýi";s:3:"æ……";s:2:"Ýj";s:3:"愶";s:2:"Ýk";s:3:"愲";s:2:"Ýl";s:3:"æ„®";s:2:"Ým";s:3:"æ…†";s:2:"Ýn";s:3:"愯";s:2:"Ýo";s:3:"æ…";s:2:"Ýp";s:3:"æ„©";s:2:"Ýq";s:3:"æ…€";s:2:"Ýr";s:3:"戠";s:2:"Ýs";s:3:"é…¨";s:2:"Ýt";s:3:"戣";s:2:"Ýu";s:3:"戥";s:2:"Ýv";s:3:"戤";s:2:"Ýw";s:3:"æ…";s:2:"Ýx";s:3:"æ±";s:2:"Ýy";s:3:"æ«";s:2:"Ýz";s:3:"æ";s:2:"Ý{";s:3:"æ’";s:2:"Ý|";s:3:"æ‰";s:2:"Ý}";s:3:"æ ";s:2:"Ý~";s:3:"æ¤";s:2:"Ý¡";s:3:"æ³";s:2:"Ý¢";s:3:"摃";s:2:"Ý£";s:3:"æŸ";s:2:"ݤ";s:3:"æ•";s:2:"Ý¥";s:3:"æ˜";s:2:"ݦ";s:3:"æ¹";s:2:"ݧ";s:3:"æ·";s:2:"ݨ";s:3:"æ¢";s:2:"Ý©";s:3:"æ£";s:2:"ݪ";s:3:"æŒ";s:2:"Ý«";s:3:"æ¦";s:2:"ݬ";s:3:"æ°";s:2:"Ý­";s:3:"æ¨";s:2:"Ý®";s:3:"æ‘";s:2:"ݯ";s:3:"æµ";s:2:"Ý°";s:3:"æ¯";s:2:"ݱ";s:3:"æŠ";s:2:"ݲ";s:3:"æš";s:2:"ݳ";s:3:"æ‘€";s:2:"Ý´";s:3:"æ¥";s:2:"ݵ";s:3:"æ§";s:2:"ݶ";s:3:"æ‹";s:2:"Ý·";s:3:"æ§";s:2:"ݸ";s:3:"æ›";s:2:"ݹ";s:3:"æ®";s:2:"ݺ";s:3:"æ¡";s:2:"Ý»";s:3:"æŽ";s:2:"ݼ";s:3:"敯";s:2:"ݽ";s:3:"æ–’";s:2:"ݾ";s:3:"æ—“";s:2:"Ý¿";s:3:"暆";s:2:"ÝÀ";s:3:"暌";s:2:"ÝÁ";s:3:"æš•";s:2:"ÝÂ";s:3:"æš";s:2:"ÝÃ";s:3:"æš‹";s:2:"ÝÄ";s:3:"暊";s:2:"ÝÅ";s:3:"æš™";s:2:"ÝÆ";s:3:"æš”";s:2:"ÝÇ";s:3:"晸";s:2:"ÝÈ";s:3:"朠";s:2:"ÝÉ";s:3:"楦";s:2:"ÝÊ";s:3:"楟";s:2:"ÝË";s:3:"椸";s:2:"ÝÌ";s:3:"楎";s:2:"ÝÍ";s:3:"楢";s:2:"ÝÎ";s:3:"楱";s:2:"ÝÏ";s:3:"椿";s:2:"ÝÐ";s:3:"楅";s:2:"ÝÑ";s:3:"楪";s:2:"ÝÒ";s:3:"椹";s:2:"ÝÓ";s:3:"楂";s:2:"ÝÔ";s:3:"楗";s:2:"ÝÕ";s:3:"楙";s:2:"ÝÖ";s:3:"楺";s:2:"Ý×";s:3:"楈";s:2:"ÝØ";s:3:"楉";s:2:"ÝÙ";s:3:"椵";s:2:"ÝÚ";s:3:"楬";s:2:"ÝÛ";s:3:"椳";s:2:"ÝÜ";s:3:"椽";s:2:"ÝÝ";s:3:"楥";s:2:"ÝÞ";s:3:"棰";s:2:"Ýß";s:3:"楸";s:2:"Ýà";s:3:"椴";s:2:"Ýá";s:3:"楩";s:2:"Ýâ";s:3:"楀";s:2:"Ýã";s:3:"楯";s:2:"Ýä";s:3:"楄";s:2:"Ýå";s:3:"楶";s:2:"Ýæ";s:3:"楘";s:2:"Ýç";s:3:"æ¥";s:2:"Ýè";s:3:"楴";s:2:"Ýé";s:3:"楌";s:2:"Ýê";s:3:"椻";s:2:"Ýë";s:3:"楋";s:2:"Ýì";s:3:"椷";s:2:"Ýí";s:3:"楜";s:2:"Ýî";s:3:"æ¥";s:2:"Ýï";s:3:"楑";s:2:"Ýð";s:3:"椲";s:2:"Ýñ";s:3:"楒";s:2:"Ýò";s:3:"椯";s:2:"Ýó";s:3:"楻";s:2:"Ýô";s:3:"椼";s:2:"Ýõ";s:3:"æ­†";s:2:"Ýö";s:3:"æ­…";s:2:"Ý÷";s:3:"æ­ƒ";s:2:"Ýø";s:3:"æ­‚";s:2:"Ýù";s:3:"æ­ˆ";s:2:"Ýú";s:3:"æ­";s:2:"Ýû";s:3:"æ®›";s:2:"Ýü";s:3:"ï¨";s:2:"Ýý";s:3:"毻";s:2:"Ýþ";s:3:"毼";s:2:"Þ@";s:3:"毹";s:2:"ÞA";s:3:"毷";s:2:"ÞB";s:3:"毸";s:2:"ÞC";s:3:"溛";s:2:"ÞD";s:3:"æ»–";s:2:"ÞE";s:3:"滈";s:2:"ÞF";s:3:"æº";s:2:"ÞG";s:3:"滀";s:2:"ÞH";s:3:"溟";s:2:"ÞI";s:3:"溓";s:2:"ÞJ";s:3:"溔";s:2:"ÞK";s:3:"溠";s:2:"ÞL";s:3:"溱";s:2:"ÞM";s:3:"溹";s:2:"ÞN";s:3:"滆";s:2:"ÞO";s:3:"æ»’";s:2:"ÞP";s:3:"溽";s:2:"ÞQ";s:3:"æ»";s:2:"ÞR";s:3:"溞";s:2:"ÞS";s:3:"滉";s:2:"ÞT";s:3:"溷";s:2:"ÞU";s:3:"溰";s:2:"ÞV";s:3:"æ»";s:2:"ÞW";s:3:"溦";s:2:"ÞX";s:3:"æ»";s:2:"ÞY";s:3:"溲";s:2:"ÞZ";s:3:"溾";s:2:"Þ[";s:3:"滃";s:2:"Þ\";s:3:"滜";s:2:"Þ]";s:3:"滘";s:2:"Þ^";s:3:"溙";s:2:"Þ_";s:3:"溒";s:2:"Þ`";s:3:"溎";s:2:"Þa";s:3:"æº";s:2:"Þb";s:3:"溤";s:2:"Þc";s:3:"溡";s:2:"Þd";s:3:"溿";s:2:"Þe";s:3:"溳";s:2:"Þf";s:3:"æ»";s:2:"Þg";s:3:"滊";s:2:"Þh";s:3:"溗";s:2:"Þi";s:3:"溮";s:2:"Þj";s:3:"溣";s:2:"Þk";s:3:"ç…‡";s:2:"Þl";s:3:"ç…”";s:2:"Þm";s:3:"ç…’";s:2:"Þn";s:3:"ç…£";s:2:"Þo";s:3:"ç… ";s:2:"Þp";s:3:"ç…";s:2:"Þq";s:3:"ç…";s:2:"Þr";s:3:"ç…¢";s:2:"Þs";s:3:"ç…²";s:2:"Þt";s:3:"ç…¸";s:2:"Þu";s:3:"ç…ª";s:2:"Þv";s:3:"ç…¡";s:2:"Þw";s:3:"ç…‚";s:2:"Þx";s:3:"ç…˜";s:2:"Þy";s:3:"ç…ƒ";s:2:"Þz";s:3:"ç…‹";s:2:"Þ{";s:3:"ç…°";s:2:"Þ|";s:3:"ç…Ÿ";s:2:"Þ}";s:3:"ç…";s:2:"Þ~";s:3:"ç…“";s:2:"Þ¡";s:3:"ç…„";s:2:"Þ¢";s:3:"ç…";s:2:"Þ£";s:3:"ç…š";s:2:"Þ¤";s:3:"ç‰";s:2:"Þ¥";s:3:"çŠ";s:2:"Þ¦";s:3:"犌";s:2:"Þ§";s:3:"犑";s:2:"Þ¨";s:3:"çŠ";s:2:"Þ©";s:3:"犎";s:2:"Þª";s:3:"猼";s:2:"Þ«";s:3:"ç‚";s:2:"Þ¬";s:3:"猻";s:2:"Þ­";s:3:"猺";s:2:"Þ®";s:3:"ç€";s:2:"Þ¯";s:3:"çŠ";s:2:"Þ°";s:3:"ç‰";s:2:"Þ±";s:3:"ç‘„";s:2:"Þ²";s:3:"ç‘Š";s:2:"Þ³";s:3:"ç‘‹";s:2:"Þ´";s:3:"ç‘’";s:2:"Þµ";s:3:"ç‘‘";s:2:"Þ¶";s:3:"ç‘—";s:2:"Þ·";s:3:"ç‘€";s:2:"Þ¸";s:3:"ç‘";s:2:"Þ¹";s:3:"ç‘";s:2:"Þº";s:3:"ç‘Ž";s:2:"Þ»";s:3:"ç‘‚";s:2:"Þ¼";s:3:"瑆";s:2:"Þ½";s:3:"ç‘";s:2:"Þ¾";s:3:"ç‘”";s:2:"Þ¿";s:3:"ç“¡";s:2:"ÞÀ";s:3:"ç“¿";s:2:"ÞÁ";s:3:"瓾";s:2:"ÞÂ";s:3:"瓽";s:2:"ÞÃ";s:3:"ç”";s:2:"ÞÄ";s:3:"畹";s:2:"ÞÅ";s:3:"ç•·";s:2:"ÞÆ";s:3:"榃";s:2:"ÞÇ";s:3:"ç—¯";s:2:"ÞÈ";s:3:"ç˜";s:2:"ÞÉ";s:3:"瘃";s:2:"ÞÊ";s:3:"ç—·";s:2:"ÞË";s:3:"ç—¾";s:2:"ÞÌ";s:3:"ç—¼";s:2:"ÞÍ";s:3:"ç—¹";s:2:"ÞÎ";s:3:"ç—¸";s:2:"ÞÏ";s:3:"ç˜";s:2:"ÞÐ";s:3:"ç—»";s:2:"ÞÑ";s:3:"ç—¶";s:2:"ÞÒ";s:3:"ç—­";s:2:"ÞÓ";s:3:"ç—µ";s:2:"ÞÔ";s:3:"ç—½";s:2:"ÞÕ";s:3:"çš™";s:2:"ÞÖ";s:3:"çšµ";s:2:"Þ×";s:3:"ç›";s:2:"ÞØ";s:3:"ç•";s:2:"ÞÙ";s:3:"çŸ";s:2:"ÞÚ";s:3:"ç ";s:2:"ÞÛ";s:3:"ç’";s:2:"ÞÜ";s:3:"ç–";s:2:"ÞÝ";s:3:"çš";s:2:"ÞÞ";s:3:"ç©";s:2:"Þß";s:3:"ç§";s:2:"Þà";s:3:"ç”";s:2:"Þá";s:3:"ç™";s:2:"Þâ";s:3:"ç­";s:2:"Þã";s:3:"矠";s:2:"Þä";s:3:"碇";s:2:"Þå";s:3:"碚";s:2:"Þæ";s:3:"碔";s:2:"Þç";s:3:"ç¢";s:2:"Þè";s:3:"碄";s:2:"Þé";s:3:"碕";s:2:"Þê";s:3:"碅";s:2:"Þë";s:3:"碆";s:2:"Þì";s:3:"碡";s:2:"Þí";s:3:"碃";s:2:"Þî";s:3:"硹";s:2:"Þï";s:3:"碙";s:2:"Þð";s:3:"碀";s:2:"Þñ";s:3:"碖";s:2:"Þò";s:3:"ç¡»";s:2:"Þó";s:3:"祼";s:2:"Þô";s:3:"禂";s:2:"Þõ";s:3:"祽";s:2:"Þö";s:3:"祹";s:2:"Þ÷";s:3:"稑";s:2:"Þø";s:3:"稘";s:2:"Þù";s:3:"稙";s:2:"Þú";s:3:"稒";s:2:"Þû";s:3:"稗";s:2:"Þü";s:3:"稕";s:2:"Þý";s:3:"稢";s:2:"Þþ";s:3:"稓";s:2:"ß@";s:3:"稛";s:2:"ßA";s:3:"ç¨";s:2:"ßB";s:3:"窣";s:2:"ßC";s:3:"窢";s:2:"ßD";s:3:"窞";s:2:"ßE";s:3:"ç««";s:2:"ßF";s:3:"ç­¦";s:2:"ßG";s:3:"ç­¤";s:2:"ßH";s:3:"ç­­";s:2:"ßI";s:3:"ç­´";s:2:"ßJ";s:3:"ç­©";s:2:"ßK";s:3:"ç­²";s:2:"ßL";s:3:"ç­¥";s:2:"ßM";s:3:"ç­³";s:2:"ßN";s:3:"ç­±";s:2:"ßO";s:3:"ç­°";s:2:"ßP";s:3:"ç­¡";s:2:"ßQ";s:3:"ç­¸";s:2:"ßR";s:3:"ç­¶";s:2:"ßS";s:3:"ç­£";s:2:"ßT";s:3:"ç²²";s:2:"ßU";s:3:"ç²´";s:2:"ßV";s:3:"粯";s:2:"ßW";s:3:"綈";s:2:"ßX";s:3:"綆";s:2:"ßY";s:3:"綀";s:2:"ßZ";s:3:"ç¶";s:2:"ß[";s:3:"絿";s:2:"ß\";s:3:"綅";s:2:"ß]";s:3:"絺";s:2:"ß^";s:3:"綎";s:2:"ß_";s:3:"çµ»";s:2:"ß`";s:3:"綃";s:2:"ßa";s:3:"çµ¼";s:2:"ßb";s:3:"綌";s:2:"ßc";s:3:"綔";s:2:"ßd";s:3:"綄";s:2:"ße";s:3:"çµ½";s:2:"ßf";s:3:"綒";s:2:"ßg";s:3:"ç½­";s:2:"ßh";s:3:"罫";s:2:"ßi";s:3:"罧";s:2:"ßj";s:3:"罨";s:2:"ßk";s:3:"罬";s:2:"ßl";s:3:"羦";s:2:"ßm";s:3:"ç¾¥";s:2:"ßn";s:3:"羧";s:2:"ßo";s:3:"ç¿›";s:2:"ßp";s:3:"ç¿œ";s:2:"ßq";s:3:"耡";s:2:"ßr";s:3:"è…¤";s:2:"ßs";s:3:"è… ";s:2:"ßt";s:3:"è…·";s:2:"ßu";s:3:"è…œ";s:2:"ßv";s:3:"è…©";s:2:"ßw";s:3:"è…›";s:2:"ßx";s:3:"è…¢";s:2:"ßy";s:3:"è…²";s:2:"ßz";s:3:"朡";s:2:"ß{";s:3:"è…ž";s:2:"ß|";s:3:"è…¶";s:2:"ß}";s:3:"è…§";s:2:"ß~";s:3:"è…¯";s:2:"ß¡";s:3:"è…„";s:2:"ߢ";s:3:"è…¡";s:2:"ߣ";s:3:"èˆ";s:2:"ߤ";s:3:"艉";s:2:"ߥ";s:3:"艄";s:2:"ߦ";s:3:"艀";s:2:"ߧ";s:3:"艂";s:2:"ߨ";s:3:"艅";s:2:"ß©";s:3:"蓱";s:2:"ߪ";s:3:"è¿";s:2:"ß«";s:3:"è‘–";s:2:"߬";s:3:"葶";s:2:"ß­";s:3:"葹";s:2:"ß®";s:3:"è’";s:2:"߯";s:3:"è’";s:2:"ß°";s:3:"è‘¥";s:2:"ß±";s:3:"è‘‘";s:2:"ß²";s:3:"è‘€";s:2:"ß³";s:3:"è’†";s:2:"ß´";s:3:"葧";s:2:"ßµ";s:3:"è°";s:2:"߶";s:3:"è‘";s:2:"ß·";s:3:"葽";s:2:"߸";s:3:"è‘š";s:2:"ß¹";s:3:"è‘™";s:2:"ߺ";s:3:"è‘´";s:2:"ß»";s:3:"葳";s:2:"ß¼";s:3:"è‘";s:2:"ß½";s:3:"蔇";s:2:"ß¾";s:3:"è‘ž";s:2:"ß¿";s:3:"è·";s:2:"ßÀ";s:3:"èº";s:2:"ßÁ";s:3:"è´";s:2:"ßÂ";s:3:"葺";s:2:"ßÃ";s:3:"葃";s:2:"ßÄ";s:3:"葸";s:2:"ßÅ";s:3:"è²";s:2:"ßÆ";s:3:"è‘…";s:2:"ßÇ";s:3:"è©";s:2:"ßÈ";s:3:"è™";s:2:"ßÉ";s:3:"è‘‹";s:2:"ßÊ";s:3:"è¯";s:2:"ßË";s:3:"è‘‚";s:2:"ßÌ";s:3:"è­";s:2:"ßÍ";s:3:"è‘Ÿ";s:2:"ßÎ";s:3:"è‘°";s:2:"ßÏ";s:3:"è¹";s:2:"ßÐ";s:3:"è‘Ž";s:2:"ßÑ";s:3:"è‘Œ";s:2:"ßÒ";s:3:"è‘’";s:2:"ßÓ";s:3:"葯";s:2:"ßÔ";s:3:"è“…";s:2:"ßÕ";s:3:"è’Ž";s:2:"ßÖ";s:3:"è»";s:2:"ß×";s:3:"葇";s:2:"ßØ";s:3:"è¶";s:2:"ßÙ";s:3:"è³";s:2:"ßÚ";s:3:"葨";s:2:"ßÛ";s:3:"葾";s:2:"ßÜ";s:3:"è‘„";s:2:"ßÝ";s:3:"è«";s:2:"ßÞ";s:3:"è‘ ";s:2:"ßß";s:3:"è‘”";s:2:"ßà";s:3:"è‘®";s:2:"ßá";s:3:"è‘";s:2:"ßâ";s:3:"蜋";s:2:"ßã";s:3:"蜄";s:2:"ßä";s:3:"è›·";s:2:"ßå";s:3:"蜌";s:2:"ßæ";s:3:"蛺";s:2:"ßç";s:3:"è›–";s:2:"ßè";s:3:"蛵";s:2:"ßé";s:3:"è";s:2:"ßê";s:3:"蛸";s:2:"ßë";s:3:"蜎";s:2:"ßì";s:3:"蜉";s:2:"ßí";s:3:"èœ";s:2:"ßî";s:3:"蛶";s:2:"ßï";s:3:"èœ";s:2:"ßð";s:3:"蜅";s:2:"ßñ";s:3:"裖";s:2:"ßò";s:3:"裋";s:2:"ßó";s:3:"è£";s:2:"ßô";s:3:"裎";s:2:"ßõ";s:3:"裞";s:2:"ßö";s:3:"裛";s:2:"ß÷";s:3:"裚";s:2:"ßø";s:3:"裌";s:2:"ßù";s:3:"è£";s:2:"ßú";s:3:"覅";s:2:"ßû";s:3:"覛";s:2:"ßü";s:3:"觟";s:2:"ßý";s:3:"觥";s:2:"ßþ";s:3:"觤";s:2:"à@";s:3:"觡";s:2:"àA";s:3:"觠";s:2:"àB";s:3:"觢";s:2:"àC";s:3:"觜";s:2:"àD";s:3:"触";s:2:"àE";s:3:"詶";s:2:"àF";s:3:"誆";s:2:"àG";s:3:"è©¿";s:2:"àH";s:3:"è©¡";s:2:"àI";s:3:"訿";s:2:"àJ";s:3:"è©·";s:2:"àK";s:3:"誂";s:2:"àL";s:3:"誄";s:2:"àM";s:3:"詵";s:2:"àN";s:3:"誃";s:2:"àO";s:3:"èª";s:2:"àP";s:3:"è©´";s:2:"àQ";s:3:"詺";s:2:"àR";s:3:"è°¼";s:2:"àS";s:3:"豋";s:2:"àT";s:3:"豊";s:2:"àU";s:3:"è±¥";s:2:"àV";s:3:"豤";s:2:"àW";s:3:"豦";s:2:"àX";s:3:"貆";s:2:"àY";s:3:"貄";s:2:"àZ";s:3:"è²…";s:2:"à[";s:3:"賌";s:2:"à\";s:3:"赨";s:2:"à]";s:3:"赩";s:2:"à^";s:3:"趑";s:2:"à_";s:3:"趌";s:2:"à`";s:3:"趎";s:2:"àa";s:3:"è¶";s:2:"àb";s:3:"è¶";s:2:"àc";s:3:"趓";s:2:"àd";s:3:"趔";s:2:"àe";s:3:"è¶";s:2:"àf";s:3:"趒";s:2:"àg";s:3:"è·°";s:2:"àh";s:3:"è· ";s:2:"ài";s:3:"è·¬";s:2:"àj";s:3:"è·±";s:2:"àk";s:3:"è·®";s:2:"àl";s:3:"è·";s:2:"àm";s:3:"è·©";s:2:"àn";s:3:"è·£";s:2:"ào";s:3:"è·¢";s:2:"àp";s:3:"è·§";s:2:"àq";s:3:"è·²";s:2:"àr";s:3:"è·«";s:2:"às";s:3:"è·´";s:2:"àt";s:3:"輆";s:2:"àu";s:3:"軿";s:2:"àv";s:3:"è¼";s:2:"àw";s:3:"è¼€";s:2:"àx";s:3:"è¼…";s:2:"ày";s:3:"輇";s:2:"àz";s:3:"輈";s:2:"à{";s:3:"輂";s:2:"à|";s:3:"輋";s:2:"à}";s:3:"é’";s:2:"à~";s:3:"逿";s:2:"à¡";s:3:"é„";s:2:"à¢";s:3:"é‰";s:2:"à£";s:3:"逽";s:2:"à¤";s:3:"é„";s:2:"à¥";s:3:"é„";s:2:"à¦";s:3:"é„";s:2:"à§";s:3:"é„‘";s:2:"à¨";s:3:"é„–";s:2:"à©";s:3:"é„”";s:2:"àª";s:3:"é„‹";s:2:"à«";s:3:"é„Ž";s:2:"à¬";s:3:"é…®";s:2:"à­";s:3:"é…¯";s:2:"à®";s:3:"鉈";s:2:"à¯";s:3:"鉒";s:2:"à°";s:3:"鈰";s:2:"à±";s:3:"鈺";s:2:"à²";s:3:"鉦";s:2:"à³";s:3:"鈳";s:2:"à´";s:3:"鉥";s:2:"àµ";s:3:"鉞";s:2:"à¶";s:3:"銃";s:2:"à·";s:3:"鈮";s:2:"à¸";s:3:"鉊";s:2:"à¹";s:3:"鉆";s:2:"àº";s:3:"鉭";s:2:"à»";s:3:"鉬";s:2:"à¼";s:3:"é‰";s:2:"à½";s:3:"鉠";s:2:"à¾";s:3:"鉧";s:2:"à¿";s:3:"鉯";s:2:"àÀ";s:3:"鈶";s:2:"àÁ";s:3:"鉡";s:2:"àÂ";s:3:"鉰";s:2:"àÃ";s:3:"鈱";s:2:"àÄ";s:3:"鉔";s:2:"àÅ";s:3:"鉣";s:2:"àÆ";s:3:"é‰";s:2:"àÇ";s:3:"鉲";s:2:"àÈ";s:3:"鉎";s:2:"àÉ";s:3:"鉓";s:2:"àÊ";s:3:"鉌";s:2:"àË";s:3:"鉖";s:2:"àÌ";s:3:"鈲";s:2:"àÍ";s:3:"é–Ÿ";s:2:"àÎ";s:3:"é–œ";s:2:"àÏ";s:3:"é–ž";s:2:"àÐ";s:3:"é–›";s:2:"àÑ";s:3:"éš’";s:2:"àÒ";s:3:"éš“";s:2:"àÓ";s:3:"éš‘";s:2:"àÔ";s:3:"éš—";s:2:"àÕ";s:3:"雎";s:2:"àÖ";s:3:"雺";s:2:"à×";s:3:"雽";s:2:"àØ";s:3:"雸";s:2:"àÙ";s:3:"雵";s:2:"àÚ";s:3:"é³";s:2:"àÛ";s:3:"é·";s:2:"àÜ";s:3:"é¸";s:2:"àÝ";s:3:"é²";s:2:"àÞ";s:3:"é ";s:2:"àß";s:3:"é ";s:2:"àà";s:3:"é Ž";s:2:"àá";s:3:"颬";s:2:"àâ";s:3:"飶";s:2:"àã";s:3:"飹";s:2:"àä";s:3:"馯";s:2:"àå";s:3:"馲";s:2:"àæ";s:3:"馰";s:2:"àç";s:3:"馵";s:2:"àè";s:3:"骭";s:2:"àé";s:3:"骫";s:2:"àê";s:3:"é­›";s:2:"àë";s:3:"鳪";s:2:"àì";s:3:"é³­";s:2:"àí";s:3:"鳧";s:2:"àî";s:3:"麀";s:2:"àï";s:3:"黽";s:2:"àð";s:3:"僦";s:2:"àñ";s:3:"僔";s:2:"àò";s:3:"僗";s:2:"àó";s:3:"僨";s:2:"àô";s:3:"僳";s:2:"àõ";s:3:"僛";s:2:"àö";s:3:"僪";s:2:"à÷";s:3:"åƒ";s:2:"àø";s:3:"僤";s:2:"àù";s:3:"僓";s:2:"àú";s:3:"僬";s:2:"àû";s:3:"僰";s:2:"àü";s:3:"僯";s:2:"àý";s:3:"僣";s:2:"àþ";s:3:"僠";s:2:"á@";s:3:"凘";s:2:"áA";s:3:"劀";s:2:"áB";s:3:"åŠ";s:2:"áC";s:3:"å‹©";s:2:"áD";s:3:"å‹«";s:2:"áE";s:3:"匰";s:2:"áF";s:3:"厬";s:2:"áG";s:3:"嘧";s:2:"áH";s:3:"嘕";s:2:"áI";s:3:"嘌";s:2:"áJ";s:3:"嘒";s:2:"áK";s:3:"å—¼";s:2:"áL";s:3:"å˜";s:2:"áM";s:3:"嘜";s:2:"áN";s:3:"å˜";s:2:"áO";s:3:"嘓";s:2:"áP";s:3:"嘂";s:2:"áQ";s:3:"å—º";s:2:"áR";s:3:"å˜";s:2:"áS";s:3:"嘄";s:2:"áT";s:3:"å—¿";s:2:"áU";s:3:"å—¹";s:2:"áV";s:3:"墉";s:2:"áW";s:3:"塼";s:2:"áX";s:3:"å¢";s:2:"áY";s:3:"墘";s:2:"áZ";s:3:"墆";s:2:"á[";s:3:"å¢";s:2:"á\";s:3:"å¡¿";s:2:"á]";s:3:"å¡´";s:2:"á^";s:3:"墋";s:2:"á_";s:3:"塺";s:2:"á`";s:3:"墇";s:2:"áa";s:3:"墑";s:2:"áb";s:3:"墎";s:2:"ác";s:3:"塶";s:2:"ád";s:3:"墂";s:2:"áe";s:3:"墈";s:2:"áf";s:3:"å¡»";s:2:"ág";s:3:"墔";s:2:"áh";s:3:"å¢";s:2:"ái";s:3:"壾";s:2:"áj";s:3:"奫";s:2:"ák";s:3:"å«œ";s:2:"ál";s:3:"å«®";s:2:"ám";s:3:"å«¥";s:2:"án";s:3:"å«•";s:2:"áo";s:3:"嫪";s:2:"áp";s:3:"å«š";s:2:"áq";s:3:"å«­";s:2:"ár";s:3:"å««";s:2:"ás";s:3:"嫳";s:2:"át";s:3:"å«¢";s:2:"áu";s:3:"å« ";s:2:"áv";s:3:"å«›";s:2:"áw";s:3:"嫬";s:2:"áx";s:3:"å«ž";s:2:"áy";s:3:"å«";s:2:"áz";s:3:"å«™";s:2:"á{";s:3:"嫨";s:2:"á|";s:3:"å«Ÿ";s:2:"á}";s:3:"å­·";s:2:"á~";s:3:"寠";s:2:"á¡";s:3:"寣";s:2:"á¢";s:3:"å±£";s:2:"á£";s:3:"嶂";s:2:"á¤";s:3:"嶀";s:2:"á¥";s:3:"åµ½";s:2:"á¦";s:3:"嶆";s:2:"á§";s:3:"嵺";s:2:"á¨";s:3:"å¶";s:2:"á©";s:3:"åµ·";s:2:"áª";s:3:"嶊";s:2:"á«";s:3:"嶉";s:2:"á¬";s:3:"嶈";s:2:"á­";s:3:"åµ¾";s:2:"á®";s:3:"åµ¼";s:2:"á¯";s:3:"å¶";s:2:"á°";s:3:"åµ¹";s:2:"á±";s:3:"嵿";s:2:"á²";s:3:"幘";s:2:"á³";s:3:"å¹™";s:2:"á´";s:3:"幓";s:2:"áµ";s:3:"廘";s:2:"á¶";s:3:"廑";s:2:"á·";s:3:"å»—";s:2:"á¸";s:3:"廎";s:2:"á¹";s:3:"廜";s:2:"áº";s:3:"廕";s:2:"á»";s:3:"å»™";s:2:"á¼";s:3:"å»’";s:2:"á½";s:3:"å»”";s:2:"á¾";s:3:"彄";s:2:"á¿";s:3:"彃";s:2:"áÀ";s:3:"彯";s:2:"áÁ";s:3:"徶";s:2:"áÂ";s:3:"愬";s:2:"áÃ";s:3:"愨";s:2:"áÄ";s:3:"æ…";s:2:"áÅ";s:3:"æ…ž";s:2:"áÆ";s:3:"æ…±";s:2:"áÇ";s:3:"æ…³";s:2:"áÈ";s:3:"æ…’";s:2:"áÉ";s:3:"æ…“";s:2:"áÊ";s:3:"æ…²";s:2:"áË";s:3:"æ…¬";s:2:"áÌ";s:3:"憀";s:2:"áÍ";s:3:"æ…´";s:2:"áÎ";s:3:"æ…”";s:2:"áÏ";s:3:"æ…º";s:2:"áÐ";s:3:"æ…›";s:2:"áÑ";s:3:"æ…¥";s:2:"áÒ";s:3:"æ„»";s:2:"áÓ";s:3:"æ…ª";s:2:"áÔ";s:3:"æ…¡";s:2:"áÕ";s:3:"æ…–";s:2:"áÖ";s:3:"戩";s:2:"á×";s:3:"戧";s:2:"áØ";s:3:"戫";s:2:"áÙ";s:3:"æ«";s:2:"áÚ";s:3:"æ‘";s:2:"áÛ";s:3:"æ‘›";s:2:"áÜ";s:3:"æ‘";s:2:"áÝ";s:3:"æ‘´";s:2:"áÞ";s:3:"摶";s:2:"áß";s:3:"摲";s:2:"áà";s:3:"摳";s:2:"áá";s:3:"摽";s:2:"áâ";s:3:"摵";s:2:"áã";s:3:"摦";s:2:"áä";s:3:"æ’¦";s:2:"áå";s:3:"æ‘Ž";s:2:"áæ";s:3:"æ’‚";s:2:"áç";s:3:"æ‘ž";s:2:"áè";s:3:"æ‘œ";s:2:"áé";s:3:"æ‘‹";s:2:"áê";s:3:"æ‘“";s:2:"áë";s:3:"æ‘ ";s:2:"áì";s:3:"æ‘";s:2:"áí";s:3:"æ‘¿";s:2:"áî";s:3:"æ¿";s:2:"áï";s:3:"摬";s:2:"áð";s:3:"æ‘«";s:2:"áñ";s:3:"æ‘™";s:2:"áò";s:3:"æ‘¥";s:2:"áó";s:3:"æ‘·";s:2:"áô";s:3:"敳";s:2:"áõ";s:3:"æ– ";s:2:"áö";s:3:"æš¡";s:2:"á÷";s:3:"æš ";s:2:"áø";s:3:"暟";s:2:"áù";s:3:"朅";s:2:"áú";s:3:"朄";s:2:"áû";s:3:"朢";s:2:"áü";s:3:"榱";s:2:"áý";s:3:"榶";s:2:"áþ";s:3:"槉";s:2:"â@";s:3:"榠";s:2:"âA";s:3:"槎";s:2:"âB";s:3:"榖";s:2:"âC";s:3:"榰";s:2:"âD";s:3:"榬";s:2:"âE";s:3:"榼";s:2:"âF";s:3:"榑";s:2:"âG";s:3:"榙";s:2:"âH";s:3:"榎";s:2:"âI";s:3:"榧";s:2:"âJ";s:3:"æ¦";s:2:"âK";s:3:"榩";s:2:"âL";s:3:"榾";s:2:"âM";s:3:"榯";s:2:"âN";s:3:"榿";s:2:"âO";s:3:"槄";s:2:"âP";s:3:"榽";s:2:"âQ";s:3:"榤";s:2:"âR";s:3:"槔";s:2:"âS";s:3:"榹";s:2:"âT";s:3:"槊";s:2:"âU";s:3:"榚";s:2:"âV";s:3:"æ§";s:2:"âW";s:3:"榳";s:2:"âX";s:3:"榓";s:2:"âY";s:3:"榪";s:2:"âZ";s:3:"榡";s:2:"â[";s:3:"榞";s:2:"â\";s:3:"槙";s:2:"â]";s:3:"榗";s:2:"â^";s:3:"æ¦";s:2:"â_";s:3:"槂";s:2:"â`";s:3:"榵";s:2:"âa";s:3:"榥";s:2:"âb";s:3:"槆";s:2:"âc";s:3:"æ­Š";s:2:"âd";s:3:"æ­";s:2:"âe";s:3:"æ­‹";s:2:"âf";s:3:"殞";s:2:"âg";s:3:"殟";s:2:"âh";s:3:"æ® ";s:2:"âi";s:3:"毃";s:2:"âj";s:3:"毄";s:2:"âk";s:3:"毾";s:2:"âl";s:3:"滎";s:2:"âm";s:3:"滵";s:2:"ân";s:3:"æ»±";s:2:"âo";s:3:"漃";s:2:"âp";s:3:"æ¼¥";s:2:"âq";s:3:"滸";s:2:"âr";s:3:"æ¼·";s:2:"âs";s:3:"æ»»";s:2:"ât";s:3:"æ¼®";s:2:"âu";s:3:"漉";s:2:"âv";s:3:"潎";s:2:"âw";s:3:"æ¼™";s:2:"âx";s:3:"漚";s:2:"ây";s:3:"漧";s:2:"âz";s:3:"漘";s:2:"â{";s:3:"æ¼»";s:2:"â|";s:3:"æ¼’";s:2:"â}";s:3:"æ»­";s:2:"â~";s:3:"漊";s:2:"â¡";s:3:"漶";s:2:"â¢";s:3:"æ½³";s:2:"â£";s:3:"滹";s:2:"â¤";s:3:"æ»®";s:2:"â¥";s:3:"æ¼­";s:2:"â¦";s:3:"æ½€";s:2:"â§";s:3:"æ¼°";s:2:"â¨";s:3:"æ¼¼";s:2:"â©";s:3:"æ¼µ";s:2:"âª";s:3:"滫";s:2:"â«";s:3:"漇";s:2:"â¬";s:3:"漎";s:2:"â­";s:3:"潃";s:2:"â®";s:3:"æ¼…";s:2:"â¯";s:3:"滽";s:2:"â°";s:3:"滶";s:2:"â±";s:3:"æ¼¹";s:2:"â²";s:3:"漜";s:2:"â³";s:3:"滼";s:2:"â´";s:3:"漺";s:2:"âµ";s:3:"漟";s:2:"â¶";s:3:"æ¼";s:2:"â·";s:3:"漞";s:2:"â¸";s:3:"漈";s:2:"â¹";s:3:"漡";s:2:"âº";s:3:"熇";s:2:"â»";s:3:"ç†";s:2:"â¼";s:3:"熉";s:2:"â½";s:3:"熀";s:2:"â¾";s:3:"熅";s:2:"â¿";s:3:"熂";s:2:"âÀ";s:3:"ç†";s:2:"âÁ";s:3:"ç…»";s:2:"âÂ";s:3:"熆";s:2:"âÃ";s:3:"ç†";s:2:"âÄ";s:3:"熗";s:2:"âÅ";s:3:"牄";s:2:"âÆ";s:3:"牓";s:2:"âÇ";s:3:"犗";s:2:"âÈ";s:3:"犕";s:2:"âÉ";s:3:"犓";s:2:"âÊ";s:3:"çƒ";s:2:"âË";s:3:"ç";s:2:"âÌ";s:3:"ç‘";s:2:"âÍ";s:3:"çŒ";s:2:"âÎ";s:3:"ç‘¢";s:2:"âÏ";s:3:"瑳";s:2:"âÐ";s:3:"瑱";s:2:"âÑ";s:3:"瑵";s:2:"âÒ";s:3:"瑲";s:2:"âÓ";s:3:"瑧";s:2:"âÔ";s:3:"ç‘®";s:2:"âÕ";s:3:"甀";s:2:"âÖ";s:3:"甂";s:2:"â×";s:3:"甃";s:2:"âØ";s:3:"畽";s:2:"âÙ";s:3:"ç–";s:2:"âÚ";s:3:"瘖";s:2:"âÛ";s:3:"瘈";s:2:"âÜ";s:3:"瘌";s:2:"âÝ";s:3:"瘕";s:2:"âÞ";s:3:"瘑";s:2:"âß";s:3:"瘊";s:2:"âà";s:3:"瘔";s:2:"âá";s:3:"皸";s:2:"ââ";s:3:"çž";s:2:"âã";s:3:"ç¼";s:2:"âä";s:3:"çž…";s:2:"âå";s:3:"çž‚";s:2:"âæ";s:3:"ç®";s:2:"âç";s:3:"瞀";s:2:"âè";s:3:"ç¯";s:2:"âé";s:3:"ç¾";s:2:"âê";s:3:"瞃";s:2:"âë";s:3:"碲";s:2:"âì";s:3:"碪";s:2:"âí";s:3:"碴";s:2:"âî";s:3:"碭";s:2:"âï";s:3:"碨";s:2:"âð";s:3:"硾";s:2:"âñ";s:3:"碫";s:2:"âò";s:3:"碞";s:2:"âó";s:3:"碥";s:2:"âô";s:3:"碠";s:2:"âõ";s:3:"碬";s:2:"âö";s:3:"碢";s:2:"â÷";s:3:"碤";s:2:"âø";s:3:"禘";s:2:"âù";s:3:"禊";s:2:"âú";s:3:"禋";s:2:"âû";s:3:"禖";s:2:"âü";s:3:"禕";s:2:"âý";s:3:"禔";s:2:"âþ";s:3:"禓";s:2:"ã@";s:3:"禗";s:2:"ãA";s:3:"禈";s:2:"ãB";s:3:"禒";s:2:"ãC";s:3:"ç¦";s:2:"ãD";s:3:"稫";s:2:"ãE";s:3:"ç©Š";s:2:"ãF";s:3:"稰";s:2:"ãG";s:3:"稯";s:2:"ãH";s:3:"稨";s:2:"ãI";s:3:"稦";s:2:"ãJ";s:3:"窨";s:2:"ãK";s:3:"窫";s:2:"ãL";s:3:"窬";s:2:"ãM";s:3:"ç«®";s:2:"ãN";s:3:"箈";s:2:"ãO";s:3:"箜";s:2:"ãP";s:3:"箊";s:2:"ãQ";s:3:"箑";s:2:"ãR";s:3:"ç®";s:2:"ãS";s:3:"ç®–";s:2:"ãT";s:3:"ç®";s:2:"ãU";s:3:"箌";s:2:"ãV";s:3:"ç®›";s:2:"ãW";s:3:"箎";s:2:"ãX";s:3:"ç®…";s:2:"ãY";s:3:"箘";s:2:"ãZ";s:3:"劄";s:2:"ã[";s:3:"ç®™";s:2:"ã\";s:3:"箤";s:2:"ã]";s:3:"箂";s:2:"ã^";s:3:"ç²»";s:2:"ã_";s:3:"粿";s:2:"ã`";s:3:"ç²¼";s:2:"ãa";s:3:"粺";s:2:"ãb";s:3:"綧";s:2:"ãc";s:3:"綷";s:2:"ãd";s:3:"ç·‚";s:2:"ãe";s:3:"綣";s:2:"ãf";s:3:"綪";s:2:"ãg";s:3:"ç·";s:2:"ãh";s:3:"ç·€";s:2:"ãi";s:3:"ç·…";s:2:"ãj";s:3:"ç¶";s:2:"ãk";s:3:"ç·Ž";s:2:"ãl";s:3:"ç·„";s:2:"ãm";s:3:"ç·†";s:2:"ãn";s:3:"ç·‹";s:2:"ão";s:3:"ç·Œ";s:2:"ãp";s:3:"綯";s:2:"ãq";s:3:"綹";s:2:"ãr";s:3:"綖";s:2:"ãs";s:3:"綼";s:2:"ãt";s:3:"綟";s:2:"ãu";s:3:"綦";s:2:"ãv";s:3:"綮";s:2:"ãw";s:3:"綩";s:2:"ãx";s:3:"綡";s:2:"ãy";s:3:"ç·‰";s:2:"ãz";s:3:"ç½³";s:2:"ã{";s:3:"ç¿¢";s:2:"ã|";s:3:"ç¿£";s:2:"ã}";s:3:"ç¿¥";s:2:"ã~";s:3:"ç¿ž";s:2:"ã¡";s:3:"耤";s:2:"ã¢";s:3:"è";s:2:"ã£";s:3:"èœ";s:2:"ã¤";s:3:"膉";s:2:"ã¥";s:3:"膆";s:2:"ã¦";s:3:"膃";s:2:"ã§";s:3:"膇";s:2:"ã¨";s:3:"è†";s:2:"ã©";s:3:"膌";s:2:"ãª";s:3:"膋";s:2:"ã«";s:3:"舕";s:2:"ã¬";s:3:"è’—";s:2:"ã­";s:3:"è’¤";s:2:"ã®";s:3:"è’¡";s:2:"ã¯";s:3:"è’Ÿ";s:2:"ã°";s:3:"è’º";s:2:"ã±";s:3:"è“Ž";s:2:"ã²";s:3:"è“‚";s:2:"ã³";s:3:"è’¬";s:2:"ã´";s:3:"è’®";s:2:"ãµ";s:3:"è’«";s:2:"ã¶";s:3:"è’¹";s:2:"ã·";s:3:"è’´";s:2:"ã¸";s:3:"è“";s:2:"ã¹";s:3:"è“";s:2:"ãº";s:3:"è’ª";s:2:"ã»";s:3:"è’š";s:2:"ã¼";s:3:"è’±";s:2:"ã½";s:3:"è“";s:2:"ã¾";s:3:"è’";s:2:"ã¿";s:3:"è’§";s:2:"ãÀ";s:3:"è’»";s:2:"ãÁ";s:3:"è’¢";s:2:"ãÂ";s:3:"è’”";s:2:"ãÃ";s:3:"蓇";s:2:"ãÄ";s:3:"è“Œ";s:2:"ãÅ";s:3:"è’›";s:2:"ãÆ";s:3:"è’©";s:2:"ãÇ";s:3:"è’¯";s:2:"ãÈ";s:3:"è’¨";s:2:"ãÉ";s:3:"è“–";s:2:"ãÊ";s:3:"è’˜";s:2:"ãË";s:3:"è’¶";s:2:"ãÌ";s:3:"è“";s:2:"ãÍ";s:3:"è’ ";s:2:"ãÎ";s:3:"è“—";s:2:"ãÏ";s:3:"è“”";s:2:"ãÐ";s:3:"è“’";s:2:"ãÑ";s:3:"è“›";s:2:"ãÒ";s:3:"è’°";s:2:"ãÓ";s:3:"è’‘";s:2:"ãÔ";s:3:"虡";s:2:"ãÕ";s:3:"蜳";s:2:"ãÖ";s:3:"蜣";s:2:"ã×";s:3:"蜨";s:2:"ãØ";s:3:"è«";s:2:"ãÙ";s:3:"è€";s:2:"ãÚ";s:3:"蜮";s:2:"ãÛ";s:3:"蜞";s:2:"ãÜ";s:3:"蜡";s:2:"ãÝ";s:3:"蜙";s:2:"ãÞ";s:3:"蜛";s:2:"ãß";s:3:"èƒ";s:2:"ãà";s:3:"蜬";s:2:"ãá";s:3:"è";s:2:"ãâ";s:3:"蜾";s:2:"ãã";s:3:"è†";s:2:"ãä";s:3:"蜠";s:2:"ãå";s:3:"蜲";s:2:"ãæ";s:3:"蜪";s:2:"ãç";s:3:"蜭";s:2:"ãè";s:3:"蜼";s:2:"ãé";s:3:"蜒";s:2:"ãê";s:3:"蜺";s:2:"ãë";s:3:"蜱";s:2:"ãì";s:3:"蜵";s:2:"ãí";s:3:"è‚";s:2:"ãî";s:3:"蜦";s:2:"ãï";s:3:"蜧";s:2:"ãð";s:3:"蜸";s:2:"ãñ";s:3:"蜤";s:2:"ãò";s:3:"蜚";s:2:"ãó";s:3:"蜰";s:2:"ãô";s:3:"蜑";s:2:"ãõ";s:3:"裷";s:2:"ãö";s:3:"裧";s:2:"ã÷";s:3:"裱";s:2:"ãø";s:3:"裲";s:2:"ãù";s:3:"裺";s:2:"ãú";s:3:"裾";s:2:"ãû";s:3:"裮";s:2:"ãü";s:3:"裼";s:2:"ãý";s:3:"裶";s:2:"ãþ";s:3:"裻";s:2:"ä@";s:3:"裰";s:2:"äA";s:3:"裬";s:2:"äB";s:3:"裫";s:2:"äC";s:3:"è¦";s:2:"äD";s:3:"覡";s:2:"äE";s:3:"覟";s:2:"äF";s:3:"覞";s:2:"äG";s:3:"觩";s:2:"äH";s:3:"觫";s:2:"äI";s:3:"觨";s:2:"äJ";s:3:"誫";s:2:"äK";s:3:"誙";s:2:"äL";s:3:"誋";s:2:"äM";s:3:"誒";s:2:"äN";s:3:"èª";s:2:"äO";s:3:"誖";s:2:"äP";s:3:"è°½";s:2:"äQ";s:3:"豨";s:2:"äR";s:3:"豩";s:2:"äS";s:3:"賕";s:2:"äT";s:3:"è³";s:2:"äU";s:3:"è³—";s:2:"äV";s:3:"趖";s:2:"äW";s:3:"踉";s:2:"äX";s:3:"踂";s:2:"äY";s:3:"è·¿";s:2:"äZ";s:3:"è¸";s:2:"ä[";s:3:"è·½";s:2:"ä\";s:3:"踊";s:2:"ä]";s:3:"踃";s:2:"ä^";s:3:"踇";s:2:"ä_";s:3:"踆";s:2:"ä`";s:3:"踅";s:2:"äa";s:3:"è·¾";s:2:"äb";s:3:"踀";s:2:"äc";s:3:"踄";s:2:"äd";s:3:"è¼";s:2:"äe";s:3:"輑";s:2:"äf";s:3:"輎";s:2:"äg";s:3:"è¼";s:2:"äh";s:3:"é„£";s:2:"äi";s:3:"é„œ";s:2:"äj";s:3:"é„ ";s:2:"äk";s:3:"é„¢";s:2:"äl";s:3:"é„Ÿ";s:2:"äm";s:3:"é„";s:2:"än";s:3:"é„š";s:2:"äo";s:3:"鄤";s:2:"äp";s:3:"é„¡";s:2:"äq";s:3:"é„›";s:2:"är";s:3:"é…º";s:2:"äs";s:3:"é…²";s:2:"ät";s:3:"é…¹";s:2:"äu";s:3:"é…³";s:2:"äv";s:3:"銥";s:2:"äw";s:3:"銤";s:2:"äx";s:3:"鉶";s:2:"äy";s:3:"銛";s:2:"äz";s:3:"鉺";s:2:"ä{";s:3:"銠";s:2:"ä|";s:3:"銔";s:2:"ä}";s:3:"銪";s:2:"ä~";s:3:"éŠ";s:2:"ä¡";s:3:"銦";s:2:"ä¢";s:3:"銚";s:2:"ä£";s:3:"銫";s:2:"ä¤";s:3:"鉹";s:2:"ä¥";s:3:"銗";s:2:"ä¦";s:3:"鉿";s:2:"ä§";s:3:"銣";s:2:"ä¨";s:3:"é‹®";s:2:"ä©";s:3:"銎";s:2:"äª";s:3:"銂";s:2:"ä«";s:3:"銕";s:2:"ä¬";s:3:"銢";s:2:"ä­";s:3:"鉽";s:2:"ä®";s:3:"銈";s:2:"ä¯";s:3:"銡";s:2:"ä°";s:3:"銊";s:2:"ä±";s:3:"銆";s:2:"ä²";s:3:"銌";s:2:"ä³";s:3:"銙";s:2:"ä´";s:3:"銧";s:2:"äµ";s:3:"鉾";s:2:"ä¶";s:3:"銇";s:2:"ä·";s:3:"銩";s:2:"ä¸";s:3:"éŠ";s:2:"ä¹";s:3:"銋";s:2:"äº";s:3:"鈭";s:2:"ä»";s:3:"éšž";s:2:"ä¼";s:3:"éš¡";s:2:"ä½";s:3:"雿";s:2:"ä¾";s:3:"é˜";s:2:"ä¿";s:3:"é½";s:2:"äÀ";s:3:"éº";s:2:"äÁ";s:3:"é¾";s:2:"äÂ";s:3:"鞃";s:2:"äÃ";s:3:"鞀";s:2:"äÄ";s:3:"éž‚";s:2:"äÅ";s:3:"é»";s:2:"äÆ";s:3:"éž„";s:2:"äÇ";s:3:"éž";s:2:"äÈ";s:3:"é¿";s:2:"äÉ";s:3:"韎";s:2:"äÊ";s:3:"éŸ";s:2:"äË";s:3:"é –";s:2:"äÌ";s:3:"颭";s:2:"äÍ";s:3:"颮";s:2:"äÎ";s:3:"餂";s:2:"äÏ";s:3:"餀";s:2:"äÐ";s:3:"餇";s:2:"äÑ";s:3:"é¦";s:2:"äÒ";s:3:"馜";s:2:"äÓ";s:3:"駃";s:2:"äÔ";s:3:"馹";s:2:"äÕ";s:3:"馻";s:2:"äÖ";s:3:"馺";s:2:"ä×";s:3:"駂";s:2:"äØ";s:3:"馽";s:2:"äÙ";s:3:"駇";s:2:"äÚ";s:3:"骱";s:2:"äÛ";s:3:"é«£";s:2:"äÜ";s:3:"髧";s:2:"äÝ";s:3:"鬾";s:2:"äÞ";s:3:"鬿";s:2:"äß";s:3:"é­ ";s:2:"äà";s:3:"é­¡";s:2:"äá";s:3:"é­Ÿ";s:2:"äâ";s:3:"é³±";s:2:"äã";s:3:"é³²";s:2:"ää";s:3:"é³µ";s:2:"äå";s:3:"麧";s:2:"äæ";s:3:"僿";s:2:"äç";s:3:"儃";s:2:"äè";s:3:"å„°";s:2:"äé";s:3:"僸";s:2:"äê";s:3:"儆";s:2:"äë";s:3:"儇";s:2:"äì";s:3:"僶";s:2:"äí";s:3:"僾";s:2:"äî";s:3:"å„‹";s:2:"äï";s:3:"å„Œ";s:2:"äð";s:3:"僽";s:2:"äñ";s:3:"å„Š";s:2:"äò";s:3:"劋";s:2:"äó";s:3:"劌";s:2:"äô";s:3:"勱";s:2:"äõ";s:3:"勯";s:2:"äö";s:3:"噈";s:2:"ä÷";s:3:"噂";s:2:"äø";s:3:"噌";s:2:"äù";s:3:"嘵";s:2:"äú";s:3:"å™";s:2:"äû";s:3:"噊";s:2:"äü";s:3:"噉";s:2:"äý";s:3:"噆";s:2:"äþ";s:3:"噘";s:2:"å@";s:3:"噚";s:2:"åA";s:3:"噀";s:2:"åB";s:3:"嘳";s:2:"åC";s:3:"嘽";s:2:"åD";s:3:"嘬";s:2:"åE";s:3:"嘾";s:2:"åF";s:3:"嘸";s:2:"åG";s:3:"嘪";s:2:"åH";s:3:"嘺";s:2:"åI";s:3:"圚";s:2:"åJ";s:3:"墫";s:2:"åK";s:3:"å¢";s:2:"åL";s:3:"墱";s:2:"åM";s:3:"墠";s:2:"åN";s:3:"墣";s:2:"åO";s:3:"墯";s:2:"åP";s:3:"墬";s:2:"åQ";s:3:"墥";s:2:"åR";s:3:"墡";s:2:"åS";s:3:"壿";s:2:"åT";s:3:"å«¿";s:2:"åU";s:3:"å«´";s:2:"åV";s:3:"嫽";s:2:"åW";s:3:"å«·";s:2:"åX";s:3:"嫶";s:2:"åY";s:3:"嬃";s:2:"åZ";s:3:"嫸";s:2:"å[";s:3:"嬂";s:2:"å\";s:3:"嫹";s:2:"å]";s:3:"å¬";s:2:"å^";s:3:"嬇";s:2:"å_";s:3:"嬅";s:2:"å`";s:3:"å¬";s:2:"åa";s:3:"屧";s:2:"åb";s:3:"嶙";s:2:"åc";s:3:"嶗";s:2:"åd";s:3:"嶟";s:2:"åe";s:3:"嶒";s:2:"åf";s:3:"嶢";s:2:"åg";s:3:"嶓";s:2:"åh";s:3:"嶕";s:2:"åi";s:3:"嶠";s:2:"åj";s:3:"嶜";s:2:"åk";s:3:"嶡";s:2:"ål";s:3:"嶚";s:2:"åm";s:3:"嶞";s:2:"ån";s:3:"幩";s:2:"åo";s:3:"å¹";s:2:"åp";s:3:"å¹ ";s:2:"åq";s:3:"幜";s:2:"år";s:3:"ç·³";s:2:"ås";s:3:"å»›";s:2:"åt";s:3:"廞";s:2:"åu";s:3:"廡";s:2:"åv";s:3:"彉";s:2:"åw";s:3:"å¾²";s:2:"åx";s:3:"憋";s:2:"åy";s:3:"憃";s:2:"åz";s:3:"æ…¹";s:2:"å{";s:3:"憱";s:2:"å|";s:3:"憰";s:2:"å}";s:3:"憢";s:2:"å~";s:3:"憉";s:2:"å¡";s:3:"憛";s:2:"å¢";s:3:"憓";s:2:"å£";s:3:"憯";s:2:"å¤";s:3:"憭";s:2:"å¥";s:3:"憟";s:2:"å¦";s:3:"憒";s:2:"å§";s:3:"憪";s:2:"å¨";s:3:"憡";s:2:"å©";s:3:"æ†";s:2:"åª";s:3:"æ…¦";s:2:"å«";s:3:"憳";s:2:"å¬";s:3:"戭";s:2:"å­";s:3:"æ‘®";s:2:"å®";s:3:"æ‘°";s:2:"å¯";s:3:"æ’–";s:2:"å°";s:3:"æ’ ";s:2:"å±";s:3:"æ’…";s:2:"å²";s:3:"æ’—";s:2:"å³";s:3:"æ’œ";s:2:"å´";s:3:"æ’";s:2:"åµ";s:3:"æ’‹";s:2:"å¶";s:3:"æ’Š";s:2:"å·";s:3:"æ’Œ";s:2:"å¸";s:3:"æ’£";s:2:"å¹";s:3:"æ’Ÿ";s:2:"åº";s:3:"摨";s:2:"å»";s:3:"æ’±";s:2:"å¼";s:3:"æ’˜";s:2:"å½";s:3:"敶";s:2:"å¾";s:3:"敺";s:2:"å¿";s:3:"敹";s:2:"åÀ";s:3:"æ•»";s:2:"åÁ";s:3:"æ–²";s:2:"åÂ";s:3:"æ–³";s:2:"åÃ";s:3:"æšµ";s:2:"åÄ";s:3:"æš°";s:2:"åÅ";s:3:"æš©";s:2:"åÆ";s:3:"æš²";s:2:"åÇ";s:3:"æš·";s:2:"åÈ";s:3:"暪";s:2:"åÉ";s:3:"暯";s:2:"åÊ";s:3:"樀";s:2:"åË";s:3:"樆";s:2:"åÌ";s:3:"樗";s:2:"åÍ";s:3:"槥";s:2:"åÎ";s:3:"槸";s:2:"åÏ";s:3:"樕";s:2:"åÐ";s:3:"槱";s:2:"åÑ";s:3:"槤";s:2:"åÒ";s:3:"樠";s:2:"åÓ";s:3:"槿";s:2:"åÔ";s:3:"槬";s:2:"åÕ";s:3:"槢";s:2:"åÖ";s:3:"樛";s:2:"å×";s:3:"æ¨";s:2:"åØ";s:3:"槾";s:2:"åÙ";s:3:"樧";s:2:"åÚ";s:3:"槲";s:2:"åÛ";s:3:"槮";s:2:"åÜ";s:3:"樔";s:2:"åÝ";s:3:"槷";s:2:"åÞ";s:3:"槧";s:2:"åß";s:3:"æ©€";s:2:"åà";s:3:"樈";s:2:"åá";s:3:"槦";s:2:"åâ";s:3:"槻";s:2:"åã";s:3:"æ¨";s:2:"åä";s:3:"槼";s:2:"åå";s:3:"槫";s:2:"åæ";s:3:"樉";s:2:"åç";s:3:"樄";s:2:"åè";s:3:"樘";s:2:"åé";s:3:"樥";s:2:"åê";s:3:"æ¨";s:2:"åë";s:3:"槶";s:2:"åì";s:3:"樦";s:2:"åí";s:3:"樇";s:2:"åî";s:3:"槴";s:2:"åï";s:3:"樖";s:2:"åð";s:3:"æ­‘";s:2:"åñ";s:3:"殥";s:2:"åò";s:3:"殣";s:2:"åó";s:3:"殢";s:2:"åô";s:3:"殦";s:2:"åõ";s:3:"æ°";s:2:"åö";s:3:"æ°€";s:2:"å÷";s:3:"毿";s:2:"åø";s:3:"æ°‚";s:2:"åù";s:3:"æ½";s:2:"åú";s:3:"漦";s:2:"åû";s:3:"æ½¾";s:2:"åü";s:3:"澇";s:2:"åý";s:3:"濆";s:2:"åþ";s:3:"æ¾’";s:2:"æ@";s:3:"æ¾";s:2:"æA";s:3:"澉";s:2:"æB";s:3:"澌";s:2:"æC";s:3:"æ½¢";s:2:"æD";s:3:"æ½";s:2:"æE";s:3:"æ¾…";s:2:"æF";s:3:"潚";s:2:"æG";s:3:"æ¾–";s:2:"æH";s:3:"潶";s:2:"æI";s:3:"潬";s:2:"æJ";s:3:"澂";s:2:"æK";s:3:"潕";s:2:"æL";s:3:"æ½²";s:2:"æM";s:3:"æ½’";s:2:"æN";s:3:"æ½";s:2:"æO";s:3:"æ½—";s:2:"æP";s:3:"æ¾”";s:2:"æQ";s:3:"澓";s:2:"æR";s:3:"æ½";s:2:"æS";s:3:"æ¼€";s:2:"æT";s:3:"潡";s:2:"æU";s:3:"潫";s:2:"æV";s:3:"æ½½";s:2:"æW";s:3:"潧";s:2:"æX";s:3:"æ¾";s:2:"æY";s:3:"潓";s:2:"æZ";s:3:"澋";s:2:"æ[";s:3:"潩";s:2:"æ\";s:3:"潿";s:2:"æ]";s:3:"澕";s:2:"æ^";s:3:"æ½£";s:2:"æ_";s:3:"æ½·";s:2:"æ`";s:3:"潪";s:2:"æa";s:3:"æ½»";s:2:"æb";s:3:"熲";s:2:"æc";s:3:"熯";s:2:"æd";s:3:"熛";s:2:"æe";s:3:"熰";s:2:"æf";s:3:"熠";s:2:"æg";s:3:"熚";s:2:"æh";s:3:"熩";s:2:"æi";s:3:"熵";s:2:"æj";s:3:"ç†";s:2:"æk";s:3:"熥";s:2:"æl";s:3:"熞";s:2:"æm";s:3:"熤";s:2:"æn";s:3:"熡";s:2:"æo";s:3:"熪";s:2:"æp";s:3:"熜";s:2:"æq";s:3:"熧";s:2:"ær";s:3:"熳";s:2:"æs";s:3:"犘";s:2:"æt";s:3:"犚";s:2:"æu";s:3:"ç˜";s:2:"æv";s:3:"ç’";s:2:"æw";s:3:"çž";s:2:"æx";s:3:"çŸ";s:2:"æy";s:3:"ç ";s:2:"æz";s:3:"ç";s:2:"æ{";s:3:"ç›";s:2:"æ|";s:3:"ç¡";s:2:"æ}";s:3:"çš";s:2:"æ~";s:3:"ç™";s:2:"æ¡";s:3:"ç¢";s:2:"æ¢";s:3:"ç’‡";s:2:"æ£";s:3:"ç’‰";s:2:"æ¤";s:3:"ç’Š";s:2:"æ¥";s:3:"ç’†";s:2:"æ¦";s:3:"ç’";s:2:"æ§";s:3:"瑽";s:2:"æ¨";s:3:"ç’…";s:2:"æ©";s:3:"ç’ˆ";s:2:"æª";s:3:"瑼";s:2:"æ«";s:3:"瑹";s:2:"æ¬";s:3:"甈";s:2:"æ­";s:3:"甇";s:2:"æ®";s:3:"畾";s:2:"æ¯";s:3:"瘥";s:2:"æ°";s:3:"瘞";s:2:"æ±";s:3:"瘙";s:2:"æ²";s:3:"ç˜";s:2:"æ³";s:3:"瘜";s:2:"æ´";s:3:"瘣";s:2:"æµ";s:3:"瘚";s:2:"æ¶";s:3:"瘨";s:2:"æ·";s:3:"瘛";s:2:"æ¸";s:3:"çšœ";s:2:"æ¹";s:3:"çš";s:2:"æº";s:3:"çšž";s:2:"æ»";s:3:"çš›";s:2:"æ¼";s:3:"çž";s:2:"æ½";s:3:"çž";s:2:"æ¾";s:3:"瞉";s:2:"æ¿";s:3:"瞈";s:2:"æÀ";s:3:"ç£";s:2:"æÁ";s:3:"碻";s:2:"æÂ";s:3:"ç£";s:2:"æÃ";s:3:"磌";s:2:"æÄ";s:3:"磑";s:2:"æÅ";s:3:"磎";s:2:"æÆ";s:3:"磔";s:2:"æÇ";s:3:"磈";s:2:"æÈ";s:3:"磃";s:2:"æÉ";s:3:"磄";s:2:"æÊ";s:3:"磉";s:2:"æË";s:3:"禚";s:2:"æÌ";s:3:"禡";s:2:"æÍ";s:3:"禠";s:2:"æÎ";s:3:"禜";s:2:"æÏ";s:3:"禢";s:2:"æÐ";s:3:"禛";s:2:"æÑ";s:3:"æ­¶";s:2:"æÒ";s:3:"稹";s:2:"æÓ";s:3:"窲";s:2:"æÔ";s:3:"窴";s:2:"æÕ";s:3:"窳";s:2:"æÖ";s:3:"ç®·";s:2:"æ×";s:3:"篋";s:2:"æØ";s:3:"箾";s:2:"æÙ";s:3:"箬";s:2:"æÚ";s:3:"篎";s:2:"æÛ";s:3:"箯";s:2:"æÜ";s:3:"箹";s:2:"æÝ";s:3:"篊";s:2:"æÞ";s:3:"箵";s:2:"æß";s:3:"ç³…";s:2:"æà";s:3:"糈";s:2:"æá";s:3:"糌";s:2:"æâ";s:3:"糋";s:2:"æã";s:3:"ç··";s:2:"æä";s:3:"ç·›";s:2:"æå";s:3:"ç·ª";s:2:"ææ";s:3:"ç·§";s:2:"æç";s:3:"ç·—";s:2:"æè";s:3:"ç·¡";s:2:"æé";s:3:"縃";s:2:"æê";s:3:"ç·º";s:2:"æë";s:3:"ç·¦";s:2:"æì";s:3:"ç·¶";s:2:"æí";s:3:"ç·±";s:2:"æî";s:3:"ç·°";s:2:"æï";s:3:"ç·®";s:2:"æð";s:3:"ç·Ÿ";s:2:"æñ";s:3:"罶";s:2:"æò";s:3:"羬";s:2:"æó";s:3:"ç¾°";s:2:"æô";s:3:"ç¾­";s:2:"æõ";s:3:"ç¿­";s:2:"æö";s:3:"ç¿«";s:2:"æ÷";s:3:"翪";s:2:"æø";s:3:"翬";s:2:"æù";s:3:"翦";s:2:"æú";s:3:"翨";s:2:"æû";s:3:"è¤";s:2:"æü";s:3:"è§";s:2:"æý";s:3:"膣";s:2:"æþ";s:3:"膟";s:2:"ç@";s:3:"膞";s:2:"çA";s:3:"膕";s:2:"çB";s:3:"膢";s:2:"çC";s:3:"膙";s:2:"çD";s:3:"膗";s:2:"çE";s:3:"舖";s:2:"çF";s:3:"è‰";s:2:"çG";s:3:"艓";s:2:"çH";s:3:"艒";s:2:"çI";s:3:"è‰";s:2:"çJ";s:3:"艎";s:2:"çK";s:3:"艑";s:2:"çL";s:3:"蔤";s:2:"çM";s:3:"è”»";s:2:"çN";s:3:"è”";s:2:"çO";s:3:"蔀";s:2:"çP";s:3:"蔩";s:2:"çQ";s:3:"蔎";s:2:"çR";s:3:"蔉";s:2:"çS";s:3:"è”";s:2:"çT";s:3:"蔟";s:2:"çU";s:3:"蔊";s:2:"çV";s:3:"蔧";s:2:"çW";s:3:"蔜";s:2:"çX";s:3:"è“»";s:2:"çY";s:3:"蔫";s:2:"çZ";s:3:"蓺";s:2:"ç[";s:3:"蔈";s:2:"ç\";s:3:"蔌";s:2:"ç]";s:3:"è“´";s:2:"ç^";s:3:"蔪";s:2:"ç_";s:3:"蓲";s:2:"ç`";s:3:"蔕";s:2:"ça";s:3:"è“·";s:2:"çb";s:3:"è“«";s:2:"çc";s:3:"蓳";s:2:"çd";s:3:"蓼";s:2:"çe";s:3:"è”’";s:2:"çf";s:3:"蓪";s:2:"çg";s:3:"è“©";s:2:"çh";s:3:"è”–";s:2:"çi";s:3:"蓾";s:2:"çj";s:3:"蔨";s:2:"çk";s:3:"è”";s:2:"çl";s:3:"è”®";s:2:"çm";s:3:"蔂";s:2:"çn";s:3:"蓽";s:2:"ço";s:3:"蔞";s:2:"çp";s:3:"蓶";s:2:"çq";s:3:"è”±";s:2:"çr";s:3:"蔦";s:2:"çs";s:3:"蓧";s:2:"çt";s:3:"蓨";s:2:"çu";s:3:"è“°";s:2:"çv";s:3:"蓯";s:2:"çw";s:3:"蓹";s:2:"çx";s:3:"蔘";s:2:"çy";s:3:"è” ";s:2:"çz";s:3:"è”°";s:2:"ç{";s:3:"蔋";s:2:"ç|";s:3:"è”™";s:2:"ç}";s:3:"蔯";s:2:"ç~";s:3:"虢";s:2:"ç¡";s:3:"è–";s:2:"ç¢";s:3:"è£";s:2:"ç£";s:3:"è¤";s:2:"ç¤";s:3:"è·";s:2:"ç¥";s:3:"蟡";s:2:"ç¦";s:3:"è³";s:2:"ç§";s:3:"è˜";s:2:"ç¨";s:3:"è”";s:2:"ç©";s:3:"è›";s:2:"çª";s:3:"è’";s:2:"ç«";s:3:"è¡";s:2:"ç¬";s:3:"èš";s:2:"ç­";s:3:"è‘";s:2:"ç®";s:3:"èž";s:2:"ç¯";s:3:"è­";s:2:"ç°";s:3:"èª";s:2:"ç±";s:3:"è";s:2:"ç²";s:3:"èŽ";s:2:"ç³";s:3:"èŸ";s:2:"ç´";s:3:"è";s:2:"çµ";s:3:"è¯";s:2:"ç¶";s:3:"è¬";s:2:"ç·";s:3:"èº";s:2:"ç¸";s:3:"è®";s:2:"ç¹";s:3:"èœ";s:2:"çº";s:3:"è¥";s:2:"ç»";s:3:"è";s:2:"ç¼";s:3:"è»";s:2:"ç½";s:3:"èµ";s:2:"ç¾";s:3:"è¢";s:2:"ç¿";s:3:"è§";s:2:"çÀ";s:3:"è©";s:2:"çÁ";s:3:"è¡š";s:2:"çÂ";s:3:"褅";s:2:"çÃ";s:3:"褌";s:2:"çÄ";s:3:"褔";s:2:"çÅ";s:3:"褋";s:2:"çÆ";s:3:"褗";s:2:"çÇ";s:3:"褘";s:2:"çÈ";s:3:"褙";s:2:"çÉ";s:3:"褆";s:2:"çÊ";s:3:"褖";s:2:"çË";s:3:"褑";s:2:"çÌ";s:3:"褎";s:2:"çÍ";s:3:"褉";s:2:"çÎ";s:3:"覢";s:2:"çÏ";s:3:"覤";s:2:"çÐ";s:3:"覣";s:2:"çÑ";s:3:"觭";s:2:"çÒ";s:3:"觰";s:2:"çÓ";s:3:"觬";s:2:"çÔ";s:3:"è«";s:2:"çÕ";s:3:"諆";s:2:"çÖ";s:3:"誸";s:2:"ç×";s:3:"è«“";s:2:"çØ";s:3:"è«‘";s:2:"çÙ";s:3:"è«”";s:2:"çÚ";s:3:"è«•";s:2:"çÛ";s:3:"誻";s:2:"çÜ";s:3:"è«—";s:2:"çÝ";s:3:"誾";s:2:"çÞ";s:3:"è«€";s:2:"çß";s:3:"è«…";s:2:"çà";s:3:"諘";s:2:"çá";s:3:"諃";s:2:"çâ";s:3:"誺";s:2:"çã";s:3:"誽";s:2:"çä";s:3:"è«™";s:2:"çå";s:3:"è°¾";s:2:"çæ";s:3:"è±";s:2:"çç";s:3:"è²";s:2:"çè";s:3:"è³¥";s:2:"çé";s:3:"賟";s:2:"çê";s:3:"è³™";s:2:"çë";s:3:"賨";s:2:"çì";s:3:"賚";s:2:"çí";s:3:"è³";s:2:"çî";s:3:"賧";s:2:"çï";s:3:"趠";s:2:"çð";s:3:"趜";s:2:"çñ";s:3:"趡";s:2:"çò";s:3:"趛";s:2:"çó";s:3:"踠";s:2:"çô";s:3:"踣";s:2:"çõ";s:3:"踥";s:2:"çö";s:3:"踤";s:2:"ç÷";s:3:"踮";s:2:"çø";s:3:"踕";s:2:"çù";s:3:"踛";s:2:"çú";s:3:"踖";s:2:"çû";s:3:"踑";s:2:"çü";s:3:"踙";s:2:"çý";s:3:"踦";s:2:"çþ";s:3:"踧";s:2:"è@";s:3:"踔";s:2:"èA";s:3:"踒";s:2:"èB";s:3:"踘";s:2:"èC";s:3:"踓";s:2:"èD";s:3:"踜";s:2:"èE";s:3:"踗";s:2:"èF";s:3:"踚";s:2:"èG";s:3:"輬";s:2:"èH";s:3:"輤";s:2:"èI";s:3:"輘";s:2:"èJ";s:3:"輚";s:2:"èK";s:3:"è¼ ";s:2:"èL";s:3:"è¼£";s:2:"èM";s:3:"è¼–";s:2:"èN";s:3:"è¼—";s:2:"èO";s:3:"é³";s:2:"èP";s:3:"é°";s:2:"èQ";s:3:"é¯";s:2:"èR";s:3:"é§";s:2:"èS";s:3:"é«";s:2:"èT";s:3:"鄯";s:2:"èU";s:3:"é„«";s:2:"èV";s:3:"é„©";s:2:"èW";s:3:"鄪";s:2:"èX";s:3:"鄲";s:2:"èY";s:3:"鄦";s:2:"èZ";s:3:"é„®";s:2:"è[";s:3:"醅";s:2:"è\";s:3:"醆";s:2:"è]";s:3:"醊";s:2:"è^";s:3:"é†";s:2:"è_";s:3:"醂";s:2:"è`";s:3:"醄";s:2:"èa";s:3:"醀";s:2:"èb";s:3:"é‹";s:2:"èc";s:3:"鋃";s:2:"èd";s:3:"é‹„";s:2:"èe";s:3:"é‹€";s:2:"èf";s:3:"é‹™";s:2:"èg";s:3:"銶";s:2:"èh";s:3:"é‹";s:2:"èi";s:3:"鋱";s:2:"èj";s:3:"é‹Ÿ";s:2:"èk";s:3:"鋘";s:2:"èl";s:3:"é‹©";s:2:"èm";s:3:"é‹—";s:2:"èn";s:3:"é‹";s:2:"èo";s:3:"é‹Œ";s:2:"èp";s:3:"鋯";s:2:"èq";s:3:"é‹‚";s:2:"èr";s:3:"鋨";s:2:"ès";s:3:"é‹Š";s:2:"èt";s:3:"鋈";s:2:"èu";s:3:"é‹Ž";s:2:"èv";s:3:"鋦";s:2:"èw";s:3:"é‹";s:2:"èx";s:3:"é‹•";s:2:"èy";s:3:"鋉";s:2:"èz";s:3:"é‹ ";s:2:"è{";s:3:"é‹ž";s:2:"è|";s:3:"鋧";s:2:"è}";s:3:"é‹‘";s:2:"è~";s:3:"é‹“";s:2:"è¡";s:3:"銵";s:2:"è¢";s:3:"é‹¡";s:2:"è£";s:3:"鋆";s:2:"è¤";s:3:"銴";s:2:"è¥";s:3:"镼";s:2:"è¦";s:3:"é–¬";s:2:"è§";s:3:"é–«";s:2:"è¨";s:3:"é–®";s:2:"è©";s:3:"é–°";s:2:"èª";s:3:"隤";s:2:"è«";s:3:"隢";s:2:"è¬";s:3:"雓";s:2:"è­";s:3:"霅";s:2:"è®";s:3:"霈";s:2:"è¯";s:3:"霂";s:2:"è°";s:3:"éš";s:2:"è±";s:3:"鞊";s:2:"è²";s:3:"鞎";s:2:"è³";s:3:"鞈";s:2:"è´";s:3:"éŸ";s:2:"èµ";s:3:"éŸ";s:2:"è¶";s:3:"é ž";s:2:"è·";s:3:"é ";s:2:"è¸";s:3:"é ¦";s:2:"è¹";s:3:"é ©";s:2:"èº";s:3:"é ¨";s:2:"è»";s:3:"é  ";s:2:"è¼";s:3:"é ›";s:2:"è½";s:3:"é §";s:2:"è¾";s:3:"颲";s:2:"è¿";s:3:"餈";s:2:"èÀ";s:3:"飺";s:2:"èÁ";s:3:"餑";s:2:"èÂ";s:3:"餔";s:2:"èÃ";s:3:"餖";s:2:"èÄ";s:3:"餗";s:2:"èÅ";s:3:"餕";s:2:"èÆ";s:3:"駜";s:2:"èÇ";s:3:"é§";s:2:"èÈ";s:3:"é§";s:2:"èÉ";s:3:"駓";s:2:"èÊ";s:3:"駔";s:2:"èË";s:3:"駎";s:2:"èÌ";s:3:"駉";s:2:"èÍ";s:3:"駖";s:2:"èÎ";s:3:"駘";s:2:"èÏ";s:3:"駋";s:2:"èÐ";s:3:"駗";s:2:"èÑ";s:3:"駌";s:2:"èÒ";s:3:"骳";s:2:"èÓ";s:3:"髬";s:2:"èÔ";s:3:"é««";s:2:"èÕ";s:3:"髳";s:2:"èÖ";s:3:"髲";s:2:"è×";s:3:"髱";s:2:"èØ";s:3:"é­†";s:2:"èÙ";s:3:"é­ƒ";s:2:"èÚ";s:3:"é­§";s:2:"èÛ";s:3:"é­´";s:2:"èÜ";s:3:"é­±";s:2:"èÝ";s:3:"é­¦";s:2:"èÞ";s:3:"é­¶";s:2:"èß";s:3:"é­µ";s:2:"èà";s:3:"é­°";s:2:"èá";s:3:"é­¨";s:2:"èâ";s:3:"é­¤";s:2:"èã";s:3:"é­¬";s:2:"èä";s:3:"é³¼";s:2:"èå";s:3:"鳺";s:2:"èæ";s:3:"é³½";s:2:"èç";s:3:"鳿";s:2:"èè";s:3:"é³·";s:2:"èé";s:3:"é´‡";s:2:"èê";s:3:"é´€";s:2:"èë";s:3:"é³¹";s:2:"èì";s:3:"é³»";s:2:"èí";s:3:"é´ˆ";s:2:"èî";s:3:"é´…";s:2:"èï";s:3:"é´„";s:2:"èð";s:3:"麃";s:2:"èñ";s:3:"黓";s:2:"èò";s:3:"é¼";s:2:"èó";s:3:"é¼";s:2:"èô";s:3:"å„œ";s:2:"èõ";s:3:"å„“";s:2:"èö";s:3:"å„—";s:2:"è÷";s:3:"å„š";s:2:"èø";s:3:"å„‘";s:2:"èù";s:3:"凞";s:2:"èú";s:3:"匴";s:2:"èû";s:3:"å¡";s:2:"èü";s:3:"å™°";s:2:"èý";s:3:"å™ ";s:2:"èþ";s:3:"å™®";s:2:"é@";s:3:"噳";s:2:"éA";s:3:"噦";s:2:"éB";s:3:"噣";s:2:"éC";s:3:"å™­";s:2:"éD";s:3:"噲";s:2:"éE";s:3:"噞";s:2:"éF";s:3:"å™·";s:2:"éG";s:3:"圜";s:2:"éH";s:3:"圛";s:2:"éI";s:3:"壈";s:2:"éJ";s:3:"墽";s:2:"éK";s:3:"壉";s:2:"éL";s:3:"墿";s:2:"éM";s:3:"墺";s:2:"éN";s:3:"壂";s:2:"éO";s:3:"墼";s:2:"éP";s:3:"壆";s:2:"éQ";s:3:"嬗";s:2:"éR";s:3:"嬙";s:2:"éS";s:3:"嬛";s:2:"éT";s:3:"嬡";s:2:"éU";s:3:"嬔";s:2:"éV";s:3:"嬓";s:2:"éW";s:3:"å¬";s:2:"éX";s:3:"嬖";s:2:"éY";s:3:"嬨";s:2:"éZ";s:3:"嬚";s:2:"é[";s:3:"嬠";s:2:"é\";s:3:"嬞";s:2:"é]";s:3:"寯";s:2:"é^";s:3:"嶬";s:2:"é_";s:3:"嶱";s:2:"é`";s:3:"嶩";s:2:"éa";s:3:"嶧";s:2:"éb";s:3:"嶵";s:2:"éc";s:3:"嶰";s:2:"éd";s:3:"嶮";s:2:"ée";s:3:"嶪";s:2:"éf";s:3:"嶨";s:2:"ég";s:3:"嶲";s:2:"éh";s:3:"嶭";s:2:"éi";s:3:"嶯";s:2:"éj";s:3:"嶴";s:2:"ék";s:3:"幧";s:2:"él";s:3:"幨";s:2:"ém";s:3:"幦";s:2:"én";s:3:"幯";s:2:"éo";s:3:"廩";s:2:"ép";s:3:"廧";s:2:"éq";s:3:"廦";s:2:"ér";s:3:"廨";s:2:"és";s:3:"廥";s:2:"ét";s:3:"彋";s:2:"éu";s:3:"å¾¼";s:2:"év";s:3:"æ†";s:2:"éw";s:3:"憨";s:2:"éx";s:3:"憖";s:2:"éy";s:3:"懅";s:2:"éz";s:3:"憴";s:2:"é{";s:3:"懆";s:2:"é|";s:3:"æ‡";s:2:"é}";s:3:"懌";s:2:"é~";s:3:"憺";s:2:"é¡";s:3:"憿";s:2:"é¢";s:3:"憸";s:2:"é£";s:3:"憌";s:2:"é¤";s:3:"æ“—";s:2:"é¥";s:3:"æ“–";s:2:"é¦";s:3:"æ“";s:2:"é§";s:3:"æ“";s:2:"é¨";s:3:"擉";s:2:"é©";s:3:"æ’½";s:2:"éª";s:3:"æ’‰";s:2:"é«";s:3:"擃";s:2:"é¬";s:3:"æ“›";s:2:"é­";s:3:"擳";s:2:"é®";s:3:"æ“™";s:2:"é¯";s:3:"攳";s:2:"é°";s:3:"æ•¿";s:2:"é±";s:3:"敼";s:2:"é²";s:3:"æ–¢";s:2:"é³";s:3:"曈";s:2:"é´";s:3:"æš¾";s:2:"éµ";s:3:"曀";s:2:"é¶";s:3:"曊";s:2:"é·";s:3:"曋";s:2:"é¸";s:3:"æ›";s:2:"é¹";s:3:"æš½";s:2:"éº";s:3:"æš»";s:2:"é»";s:3:"暺";s:2:"é¼";s:3:"曌";s:2:"é½";s:3:"朣";s:2:"é¾";s:3:"樴";s:2:"é¿";s:3:"橦";s:2:"éÀ";s:3:"橉";s:2:"éÁ";s:3:"橧";s:2:"éÂ";s:3:"樲";s:2:"éÃ";s:3:"橨";s:2:"éÄ";s:3:"樾";s:2:"éÅ";s:3:"æ©";s:2:"éÆ";s:3:"æ©­";s:2:"éÇ";s:3:"橶";s:2:"éÈ";s:3:"æ©›";s:2:"éÉ";s:3:"æ©‘";s:2:"éÊ";s:3:"樨";s:2:"éË";s:3:"æ©š";s:2:"éÌ";s:3:"樻";s:2:"éÍ";s:3:"樿";s:2:"éÎ";s:3:"æ©";s:2:"éÏ";s:3:"橪";s:2:"éÐ";s:3:"橤";s:2:"éÑ";s:3:"æ©";s:2:"éÒ";s:3:"æ©";s:2:"éÓ";s:3:"æ©”";s:2:"éÔ";s:3:"橯";s:2:"éÕ";s:3:"æ©©";s:2:"éÖ";s:3:"æ© ";s:2:"é×";s:3:"樼";s:2:"éØ";s:3:"æ©ž";s:2:"éÙ";s:3:"æ©–";s:2:"éÚ";s:3:"æ©•";s:2:"éÛ";s:3:"æ©";s:2:"éÜ";s:3:"æ©Ž";s:2:"éÝ";s:3:"橆";s:2:"éÞ";s:3:"æ­•";s:2:"éß";s:3:"æ­”";s:2:"éà";s:3:"æ­–";s:2:"éá";s:3:"殧";s:2:"éâ";s:3:"殪";s:2:"éã";s:3:"殫";s:2:"éä";s:3:"毈";s:2:"éå";s:3:"毇";s:2:"éæ";s:3:"æ°„";s:2:"éç";s:3:"æ°ƒ";s:2:"éè";s:3:"æ°†";s:2:"éé";s:3:"æ¾­";s:2:"éê";s:3:"æ¿‹";s:2:"éë";s:3:"æ¾£";s:2:"éì";s:3:"濇";s:2:"éí";s:3:"æ¾¼";s:2:"éî";s:3:"æ¿Ž";s:2:"éï";s:3:"濈";s:2:"éð";s:3:"潞";s:2:"éñ";s:3:"æ¿„";s:2:"éò";s:3:"æ¾½";s:2:"éó";s:3:"澞";s:2:"éô";s:3:"æ¿Š";s:2:"éõ";s:3:"澨";s:2:"éö";s:3:"瀄";s:2:"é÷";s:3:"æ¾¥";s:2:"éø";s:3:"æ¾®";s:2:"éù";s:3:"澺";s:2:"éú";s:3:"澬";s:2:"éû";s:3:"澪";s:2:"éü";s:3:"æ¿";s:2:"éý";s:3:"澿";s:2:"éþ";s:3:"澸";s:2:"ê@";s:3:"æ¾¢";s:2:"êA";s:3:"濉";s:2:"êB";s:3:"澫";s:2:"êC";s:3:"æ¿";s:2:"êD";s:3:"澯";s:2:"êE";s:3:"æ¾²";s:2:"êF";s:3:"æ¾°";s:2:"êG";s:3:"燅";s:2:"êH";s:3:"燂";s:2:"êI";s:3:"熿";s:2:"êJ";s:3:"熸";s:2:"êK";s:3:"燖";s:2:"êL";s:3:"燀";s:2:"êM";s:3:"ç‡";s:2:"êN";s:3:"燋";s:2:"êO";s:3:"燔";s:2:"êP";s:3:"燊";s:2:"êQ";s:3:"燇";s:2:"êR";s:3:"ç‡";s:2:"êS";s:3:"熽";s:2:"êT";s:3:"燘";s:2:"êU";s:3:"熼";s:2:"êV";s:3:"燆";s:2:"êW";s:3:"燚";s:2:"êX";s:3:"燛";s:2:"êY";s:3:"çŠ";s:2:"êZ";s:3:"犞";s:2:"ê[";s:3:"ç©";s:2:"ê\";s:3:"ç¦";s:2:"ê]";s:3:"ç§";s:2:"ê^";s:3:"ç¬";s:2:"ê_";s:3:"ç¥";s:2:"ê`";s:3:"ç«";s:2:"êa";s:3:"çª";s:2:"êb";s:3:"ç‘¿";s:2:"êc";s:3:"ç’š";s:2:"êd";s:3:"ç’ ";s:2:"êe";s:3:"ç’”";s:2:"êf";s:3:"ç’’";s:2:"êg";s:3:"ç’•";s:2:"êh";s:3:"ç’¡";s:2:"êi";s:3:"甋";s:2:"êj";s:3:"ç–€";s:2:"êk";s:3:"瘯";s:2:"êl";s:3:"瘭";s:2:"êm";s:3:"瘱";s:2:"ên";s:3:"瘽";s:2:"êo";s:3:"瘳";s:2:"êp";s:3:"瘼";s:2:"êq";s:3:"瘵";s:2:"êr";s:3:"瘲";s:2:"ês";s:3:"瘰";s:2:"êt";s:3:"çš»";s:2:"êu";s:3:"盦";s:2:"êv";s:3:"çžš";s:2:"êw";s:3:"çž";s:2:"êx";s:3:"çž¡";s:2:"êy";s:3:"çžœ";s:2:"êz";s:3:"çž›";s:2:"ê{";s:3:"瞢";s:2:"ê|";s:3:"瞣";s:2:"ê}";s:3:"çž•";s:2:"ê~";s:3:"çž™";s:2:"ê¡";s:3:"çž—";s:2:"ê¢";s:3:"ç£";s:2:"ê£";s:3:"磩";s:2:"ê¤";s:3:"磥";s:2:"ê¥";s:3:"磪";s:2:"ê¦";s:3:"磞";s:2:"ê§";s:3:"磣";s:2:"ê¨";s:3:"磛";s:2:"ê©";s:3:"磡";s:2:"êª";s:3:"磢";s:2:"ê«";s:3:"磭";s:2:"ê¬";s:3:"磟";s:2:"ê­";s:3:"磠";s:2:"ê®";s:3:"禤";s:2:"ê¯";s:3:"ç©„";s:2:"ê°";s:3:"穈";s:2:"ê±";s:3:"穇";s:2:"ê²";s:3:"窶";s:2:"ê³";s:3:"窸";s:2:"ê´";s:3:"窵";s:2:"êµ";s:3:"窱";s:2:"ê¶";s:3:"窷";s:2:"ê·";s:3:"篞";s:2:"ê¸";s:3:"篣";s:2:"ê¹";s:3:"篧";s:2:"êº";s:3:"ç¯";s:2:"ê»";s:3:"篕";s:2:"ê¼";s:3:"篥";s:2:"ê½";s:3:"篚";s:2:"ê¾";s:3:"篨";s:2:"ê¿";s:3:"篹";s:2:"êÀ";s:3:"篔";s:2:"êÁ";s:3:"篪";s:2:"êÂ";s:3:"篢";s:2:"êÃ";s:3:"篜";s:2:"êÄ";s:3:"篫";s:2:"êÅ";s:3:"篘";s:2:"êÆ";s:3:"篟";s:2:"êÇ";s:3:"ç³’";s:2:"êÈ";s:3:"ç³”";s:2:"êÉ";s:3:"ç³—";s:2:"êÊ";s:3:"ç³";s:2:"êË";s:3:"糑";s:2:"êÌ";s:3:"縒";s:2:"êÍ";s:3:"縡";s:2:"êÎ";s:3:"縗";s:2:"êÏ";s:3:"縌";s:2:"êÐ";s:3:"縟";s:2:"êÑ";s:3:"縠";s:2:"êÒ";s:3:"縓";s:2:"êÓ";s:3:"縎";s:2:"êÔ";s:3:"縜";s:2:"êÕ";s:3:"縕";s:2:"êÖ";s:3:"縚";s:2:"ê×";s:3:"縢";s:2:"êØ";s:3:"縋";s:2:"êÙ";s:3:"ç¸";s:2:"êÚ";s:3:"縖";s:2:"êÛ";s:3:"ç¸";s:2:"êÜ";s:3:"縔";s:2:"êÝ";s:3:"縥";s:2:"êÞ";s:3:"縤";s:2:"êß";s:3:"罃";s:2:"êà";s:3:"ç½»";s:2:"êá";s:3:"ç½¼";s:2:"êâ";s:3:"罺";s:2:"êã";s:3:"ç¾±";s:2:"êä";s:3:"翯";s:2:"êå";s:3:"耪";s:2:"êæ";s:3:"耩";s:2:"êç";s:3:"è¬";s:2:"êè";s:3:"膱";s:2:"êé";s:3:"膦";s:2:"êê";s:3:"膮";s:2:"êë";s:3:"膹";s:2:"êì";s:3:"膵";s:2:"êí";s:3:"膫";s:2:"êî";s:3:"膰";s:2:"êï";s:3:"膬";s:2:"êð";s:3:"膴";s:2:"êñ";s:3:"膲";s:2:"êò";s:3:"膷";s:2:"êó";s:3:"膧";s:2:"êô";s:3:"臲";s:2:"êõ";s:3:"艕";s:2:"êö";s:3:"艖";s:2:"ê÷";s:3:"艗";s:2:"êø";s:3:"è•–";s:2:"êù";s:3:"è•…";s:2:"êú";s:3:"è•«";s:2:"êû";s:3:"è•";s:2:"êü";s:3:"è•“";s:2:"êý";s:3:"è•¡";s:2:"êþ";s:3:"蕘";s:2:"ë@";s:3:"è•€";s:2:"ëA";s:3:"蕆";s:2:"ëB";s:3:"蕤";s:2:"ëC";s:3:"è•";s:2:"ëD";s:3:"è•¢";s:2:"ëE";s:3:"è•„";s:2:"ëF";s:3:"è•‘";s:2:"ëG";s:3:"蕇";s:2:"ëH";s:3:"è•£";s:2:"ëI";s:3:"蔾";s:2:"ëJ";s:3:"è•›";s:2:"ëK";s:3:"蕱";s:2:"ëL";s:3:"è•Ž";s:2:"ëM";s:3:"è•®";s:2:"ëN";s:3:"蕵";s:2:"ëO";s:3:"è••";s:2:"ëP";s:3:"蕧";s:2:"ëQ";s:3:"è• ";s:2:"ëR";s:3:"è–Œ";s:2:"ëS";s:3:"蕦";s:2:"ëT";s:3:"è•";s:2:"ëU";s:3:"è•”";s:2:"ëV";s:3:"è•¥";s:2:"ëW";s:3:"蕬";s:2:"ëX";s:3:"虣";s:2:"ëY";s:3:"虥";s:2:"ëZ";s:3:"虤";s:2:"ë[";s:3:"èž›";s:2:"ë\";s:3:"èž";s:2:"ë]";s:3:"èž—";s:2:"ë^";s:3:"èž“";s:2:"ë_";s:3:"èž’";s:2:"ë`";s:3:"螈";s:2:"ëa";s:3:"èž";s:2:"ëb";s:3:"èž–";s:2:"ëc";s:3:"螘";s:2:"ëd";s:3:"è¹";s:2:"ëe";s:3:"螇";s:2:"ëf";s:3:"螣";s:2:"ëg";s:3:"èž…";s:2:"ëh";s:3:"èž";s:2:"ëi";s:3:"èž‘";s:2:"ëj";s:3:"èž";s:2:"ëk";s:3:"èž„";s:2:"ël";s:3:"èž”";s:2:"ëm";s:3:"èžœ";s:2:"ën";s:3:"èžš";s:2:"ëo";s:3:"螉";s:2:"ëp";s:3:"褞";s:2:"ëq";s:3:"褦";s:2:"ër";s:3:"褰";s:2:"ës";s:3:"褭";s:2:"ët";s:3:"褮";s:2:"ëu";s:3:"褧";s:2:"ëv";s:3:"褱";s:2:"ëw";s:3:"褢";s:2:"ëx";s:3:"褩";s:2:"ëy";s:3:"褣";s:2:"ëz";s:3:"褯";s:2:"ë{";s:3:"褬";s:2:"ë|";s:3:"褟";s:2:"ë}";s:3:"觱";s:2:"ë~";s:3:"è« ";s:2:"ë¡";s:3:"è«¢";s:2:"ë¢";s:3:"諲";s:2:"ë£";s:3:"è«´";s:2:"ë¤";s:3:"諵";s:2:"ë¥";s:3:"è«";s:2:"ë¦";s:3:"謔";s:2:"ë§";s:3:"諤";s:2:"ë¨";s:3:"è«Ÿ";s:2:"ë©";s:3:"è«°";s:2:"ëª";s:3:"諈";s:2:"ë«";s:3:"è«ž";s:2:"ë¬";s:3:"è«¡";s:2:"ë­";s:3:"諨";s:2:"ë®";s:3:"è«¿";s:2:"ë¯";s:3:"諯";s:2:"ë°";s:3:"è«»";s:2:"ë±";s:3:"貑";s:2:"ë²";s:3:"è²’";s:2:"ë³";s:3:"è²";s:2:"ë´";s:3:"è³µ";s:2:"ëµ";s:3:"è³®";s:2:"ë¶";s:3:"è³±";s:2:"ë·";s:3:"è³°";s:2:"ë¸";s:3:"è³³";s:2:"ë¹";s:3:"赬";s:2:"ëº";s:3:"èµ®";s:2:"ë»";s:3:"趥";s:2:"ë¼";s:3:"趧";s:2:"ë½";s:3:"踳";s:2:"ë¾";s:3:"踾";s:2:"ë¿";s:3:"踸";s:2:"ëÀ";s:3:"è¹€";s:2:"ëÁ";s:3:"è¹…";s:2:"ëÂ";s:3:"踶";s:2:"ëÃ";s:3:"踼";s:2:"ëÄ";s:3:"踽";s:2:"ëÅ";s:3:"è¹";s:2:"ëÆ";s:3:"踰";s:2:"ëÇ";s:3:"踿";s:2:"ëÈ";s:3:"躽";s:2:"ëÉ";s:3:"輶";s:2:"ëÊ";s:3:"è¼®";s:2:"ëË";s:3:"è¼µ";s:2:"ëÌ";s:3:"è¼²";s:2:"ëÍ";s:3:"è¼¹";s:2:"ëÎ";s:3:"è¼·";s:2:"ëÏ";s:3:"è¼´";s:2:"ëÐ";s:3:"é¶";s:2:"ëÑ";s:3:"é¹";s:2:"ëÒ";s:3:"é»";s:2:"ëÓ";s:3:"邆";s:2:"ëÔ";s:3:"郺";s:2:"ëÕ";s:3:"鄳";s:2:"ëÖ";s:3:"鄵";s:2:"ë×";s:3:"鄶";s:2:"ëØ";s:3:"醓";s:2:"ëÙ";s:3:"é†";s:2:"ëÚ";s:3:"醑";s:2:"ëÛ";s:3:"é†";s:2:"ëÜ";s:3:"é†";s:2:"ëÝ";s:3:"錧";s:2:"ëÞ";s:3:"錞";s:2:"ëß";s:3:"錈";s:2:"ëà";s:3:"錟";s:2:"ëá";s:3:"錆";s:2:"ëâ";s:3:"éŒ";s:2:"ëã";s:3:"éº";s:2:"ëä";s:3:"錸";s:2:"ëå";s:3:"錼";s:2:"ëæ";s:3:"錛";s:2:"ëç";s:3:"錣";s:2:"ëè";s:3:"錒";s:2:"ëé";s:3:"éŒ";s:2:"ëê";s:3:"é†";s:2:"ëë";s:3:"錭";s:2:"ëì";s:3:"錎";s:2:"ëí";s:3:"éŒ";s:2:"ëî";s:3:"é‹‹";s:2:"ëï";s:3:"éŒ";s:2:"ëð";s:3:"鋺";s:2:"ëñ";s:3:"錥";s:2:"ëò";s:3:"錓";s:2:"ëó";s:3:"鋹";s:2:"ëô";s:3:"é‹·";s:2:"ëõ";s:3:"錴";s:2:"ëö";s:3:"錂";s:2:"ë÷";s:3:"錤";s:2:"ëø";s:3:"é‹¿";s:2:"ëù";s:3:"錩";s:2:"ëú";s:3:"錹";s:2:"ëû";s:3:"錵";s:2:"ëü";s:3:"錪";s:2:"ëý";s:3:"錔";s:2:"ëþ";s:3:"錌";s:2:"ì@";s:3:"錋";s:2:"ìA";s:3:"鋾";s:2:"ìB";s:3:"錉";s:2:"ìC";s:3:"錀";s:2:"ìD";s:3:"é‹»";s:2:"ìE";s:3:"錖";s:2:"ìF";s:3:"é–¼";s:2:"ìG";s:3:"é—";s:2:"ìH";s:3:"é–¾";s:2:"ìI";s:3:"é–¹";s:2:"ìJ";s:3:"é–º";s:2:"ìK";s:3:"é–¶";s:2:"ìL";s:3:"é–¿";s:2:"ìM";s:3:"é–µ";s:2:"ìN";s:3:"é–½";s:2:"ìO";s:3:"éš©";s:2:"ìP";s:3:"é›”";s:2:"ìQ";s:3:"霋";s:2:"ìR";s:3:"霒";s:2:"ìS";s:3:"éœ";s:2:"ìT";s:3:"éž™";s:2:"ìU";s:3:"éž—";s:2:"ìV";s:3:"éž”";s:2:"ìW";s:3:"韰";s:2:"ìX";s:3:"韸";s:2:"ìY";s:3:"é µ";s:2:"ìZ";s:3:"é ¯";s:2:"ì[";s:3:"é ²";s:2:"ì\";s:3:"餤";s:2:"ì]";s:3:"餟";s:2:"ì^";s:3:"餧";s:2:"ì_";s:3:"餩";s:2:"ì`";s:3:"馞";s:2:"ìa";s:3:"駮";s:2:"ìb";s:3:"駬";s:2:"ìc";s:3:"駥";s:2:"ìd";s:3:"駤";s:2:"ìe";s:3:"駰";s:2:"ìf";s:3:"駣";s:2:"ìg";s:3:"駪";s:2:"ìh";s:3:"駩";s:2:"ìi";s:3:"駧";s:2:"ìj";s:3:"骹";s:2:"ìk";s:3:"骿";s:2:"ìl";s:3:"骴";s:2:"ìm";s:3:"骻";s:2:"ìn";s:3:"髶";s:2:"ìo";s:3:"髺";s:2:"ìp";s:3:"髹";s:2:"ìq";s:3:"é«·";s:2:"ìr";s:3:"鬳";s:2:"ìs";s:3:"鮀";s:2:"ìt";s:3:"é®…";s:2:"ìu";s:3:"鮇";s:2:"ìv";s:3:"é­¼";s:2:"ìw";s:3:"é­¾";s:2:"ìx";s:3:"é­»";s:2:"ìy";s:3:"鮂";s:2:"ìz";s:3:"鮓";s:2:"ì{";s:3:"é®’";s:2:"ì|";s:3:"é®";s:2:"ì}";s:3:"é­º";s:2:"ì~";s:3:"鮕";s:2:"ì¡";s:3:"é­½";s:2:"ì¢";s:3:"鮈";s:2:"ì£";s:3:"é´¥";s:2:"ì¤";s:3:"é´—";s:2:"ì¥";s:3:"é´ ";s:2:"ì¦";s:3:"é´ž";s:2:"ì§";s:3:"é´”";s:2:"ì¨";s:3:"é´©";s:2:"ì©";s:3:"é´";s:2:"ìª";s:3:"é´˜";s:2:"ì«";s:3:"é´¢";s:2:"ì¬";s:3:"é´";s:2:"ì­";s:3:"é´™";s:2:"ì®";s:3:"é´Ÿ";s:2:"ì¯";s:3:"麈";s:2:"ì°";s:3:"麆";s:2:"ì±";s:3:"麇";s:2:"ì²";s:3:"麮";s:2:"ì³";s:3:"麭";s:2:"ì´";s:3:"黕";s:2:"ìµ";s:3:"é»–";s:2:"ì¶";s:3:"黺";s:2:"ì·";s:3:"é¼’";s:2:"ì¸";s:3:"é¼½";s:2:"ì¹";s:3:"儦";s:2:"ìº";s:3:"å„¥";s:2:"ì»";s:3:"å„¢";s:2:"ì¼";s:3:"儤";s:2:"ì½";s:3:"å„ ";s:2:"ì¾";s:3:"å„©";s:2:"ì¿";s:3:"å‹´";s:2:"ìÀ";s:3:"åš“";s:2:"ìÁ";s:3:"嚌";s:2:"ìÂ";s:3:"åš";s:2:"ìÃ";s:3:"嚆";s:2:"ìÄ";s:3:"åš„";s:2:"ìÅ";s:3:"嚃";s:2:"ìÆ";s:3:"噾";s:2:"ìÇ";s:3:"åš‚";s:2:"ìÈ";s:3:"噿";s:2:"ìÉ";s:3:"åš";s:2:"ìÊ";s:3:"壖";s:2:"ìË";s:3:"壔";s:2:"ìÌ";s:3:"å£";s:2:"ìÍ";s:3:"壒";s:2:"ìÎ";s:3:"嬭";s:2:"ìÏ";s:3:"嬥";s:2:"ìÐ";s:3:"嬲";s:2:"ìÑ";s:3:"嬣";s:2:"ìÒ";s:3:"嬬";s:2:"ìÓ";s:3:"嬧";s:2:"ìÔ";s:3:"嬦";s:2:"ìÕ";s:3:"嬯";s:2:"ìÖ";s:3:"嬮";s:2:"ì×";s:3:"å­»";s:2:"ìØ";s:3:"寱";s:2:"ìÙ";s:3:"寲";s:2:"ìÚ";s:3:"嶷";s:2:"ìÛ";s:3:"幬";s:2:"ìÜ";s:3:"幪";s:2:"ìÝ";s:3:"å¾¾";s:2:"ìÞ";s:3:"å¾»";s:2:"ìß";s:3:"懃";s:2:"ìà";s:3:"憵";s:2:"ìá";s:3:"憼";s:2:"ìâ";s:3:"懧";s:2:"ìã";s:3:"懠";s:2:"ìä";s:3:"懥";s:2:"ìå";s:3:"懤";s:2:"ìæ";s:3:"懨";s:2:"ìç";s:3:"懞";s:2:"ìè";s:3:"擯";s:2:"ìé";s:3:"æ“©";s:2:"ìê";s:3:"æ“£";s:2:"ìë";s:3:"æ“«";s:2:"ìì";s:3:"擤";s:2:"ìí";s:3:"擨";s:2:"ìî";s:3:"æ–";s:2:"ìï";s:3:"æ–€";s:2:"ìð";s:3:"æ–¶";s:2:"ìñ";s:3:"æ—š";s:2:"ìò";s:3:"æ›’";s:2:"ìó";s:3:"æª";s:2:"ìô";s:3:"檖";s:2:"ìõ";s:3:"æª";s:2:"ìö";s:3:"檥";s:2:"ì÷";s:3:"檉";s:2:"ìø";s:3:"檟";s:2:"ìù";s:3:"檛";s:2:"ìú";s:3:"檡";s:2:"ìû";s:3:"檞";s:2:"ìü";s:3:"檇";s:2:"ìý";s:3:"檓";s:2:"ìþ";s:3:"檎";s:2:"í@";s:3:"檕";s:2:"íA";s:3:"檃";s:2:"íB";s:3:"檨";s:2:"íC";s:3:"檤";s:2:"íD";s:3:"檑";s:2:"íE";s:3:"æ©¿";s:2:"íF";s:3:"檦";s:2:"íG";s:3:"檚";s:2:"íH";s:3:"檅";s:2:"íI";s:3:"檌";s:2:"íJ";s:3:"檒";s:2:"íK";s:3:"æ­›";s:2:"íL";s:3:"æ®­";s:2:"íM";s:3:"æ°‰";s:2:"íN";s:3:"æ¿Œ";s:2:"íO";s:3:"澩";s:2:"íP";s:3:"æ¿´";s:2:"íQ";s:3:"æ¿”";s:2:"íR";s:3:"æ¿£";s:2:"íS";s:3:"æ¿œ";s:2:"íT";s:3:"æ¿­";s:2:"íU";s:3:"濧";s:2:"íV";s:3:"濦";s:2:"íW";s:3:"æ¿ž";s:2:"íX";s:3:"濲";s:2:"íY";s:3:"æ¿";s:2:"íZ";s:3:"æ¿¢";s:2:"í[";s:3:"濨";s:2:"í\";s:3:"燡";s:2:"í]";s:3:"燱";s:2:"í^";s:3:"燨";s:2:"í_";s:3:"燲";s:2:"í`";s:3:"燤";s:2:"ía";s:3:"燰";s:2:"íb";s:3:"燢";s:2:"íc";s:3:"ç³";s:2:"íd";s:3:"ç®";s:2:"íe";s:3:"ç¯";s:2:"íf";s:3:"ç’—";s:2:"íg";s:3:"ç’²";s:2:"íh";s:3:"ç’«";s:2:"íi";s:3:"ç’";s:2:"íj";s:3:"ç’ª";s:2:"ík";s:3:"ç’­";s:2:"íl";s:3:"ç’±";s:2:"ím";s:3:"ç’¥";s:2:"ín";s:3:"ç’¯";s:2:"ío";s:3:"ç”";s:2:"íp";s:3:"甑";s:2:"íq";s:3:"ç”’";s:2:"ír";s:3:"ç”";s:2:"ís";s:3:"ç–„";s:2:"ít";s:3:"癃";s:2:"íu";s:3:"癈";s:2:"ív";s:3:"癉";s:2:"íw";s:3:"癇";s:2:"íx";s:3:"皤";s:2:"íy";s:3:"盩";s:2:"íz";s:3:"çžµ";s:2:"í{";s:3:"çž«";s:2:"í|";s:3:"çž²";s:2:"í}";s:3:"çž·";s:2:"í~";s:3:"瞶";s:2:"í¡";s:3:"çž´";s:2:"í¢";s:3:"çž±";s:2:"í£";s:3:"瞨";s:2:"í¤";s:3:"矰";s:2:"í¥";s:3:"磳";s:2:"í¦";s:3:"磽";s:2:"í§";s:3:"礂";s:2:"í¨";s:3:"磻";s:2:"í©";s:3:"磼";s:2:"íª";s:3:"磲";s:2:"í«";s:3:"礅";s:2:"í¬";s:3:"磹";s:2:"í­";s:3:"磾";s:2:"í®";s:3:"礄";s:2:"í¯";s:3:"禫";s:2:"í°";s:3:"禨";s:2:"í±";s:3:"ç©œ";s:2:"í²";s:3:"ç©›";s:2:"í³";s:3:"ç©–";s:2:"í´";s:3:"穘";s:2:"íµ";s:3:"ç©”";s:2:"í¶";s:3:"ç©š";s:2:"í·";s:3:"窾";s:2:"í¸";s:3:"ç«€";s:2:"í¹";s:3:"ç«";s:2:"íº";s:3:"ç°…";s:2:"í»";s:3:"ç°";s:2:"í¼";s:3:"篲";s:2:"í½";s:3:"ç°€";s:2:"í¾";s:3:"篿";s:2:"í¿";s:3:"篻";s:2:"íÀ";s:3:"ç°Ž";s:2:"íÁ";s:3:"篴";s:2:"íÂ";s:3:"ç°‹";s:2:"íÃ";s:3:"篳";s:2:"íÄ";s:3:"ç°‚";s:2:"íÅ";s:3:"ç°‰";s:2:"íÆ";s:3:"ç°ƒ";s:2:"íÇ";s:3:"ç°";s:2:"íÈ";s:3:"篸";s:2:"íÉ";s:3:"篽";s:2:"íÊ";s:3:"ç°†";s:2:"íË";s:3:"篰";s:2:"íÌ";s:3:"篱";s:2:"íÍ";s:3:"ç°";s:2:"íÎ";s:3:"ç°Š";s:2:"íÏ";s:3:"糨";s:2:"íÐ";s:3:"縭";s:2:"íÑ";s:3:"縼";s:2:"íÒ";s:3:"繂";s:2:"íÓ";s:3:"縳";s:2:"íÔ";s:3:"顈";s:2:"íÕ";s:3:"縸";s:2:"íÖ";s:3:"縪";s:2:"í×";s:3:"繉";s:2:"íØ";s:3:"ç¹€";s:2:"íÙ";s:3:"繇";s:2:"íÚ";s:3:"縩";s:2:"íÛ";s:3:"繌";s:2:"íÜ";s:3:"縰";s:2:"íÝ";s:3:"縻";s:2:"íÞ";s:3:"縶";s:2:"íß";s:3:"繄";s:2:"íà";s:3:"縺";s:2:"íá";s:3:"ç½…";s:2:"íâ";s:3:"罿";s:2:"íã";s:3:"ç½¾";s:2:"íä";s:3:"ç½½";s:2:"íå";s:3:"ç¿´";s:2:"íæ";s:3:"翲";s:2:"íç";s:3:"耬";s:2:"íè";s:3:"膻";s:2:"íé";s:3:"臄";s:2:"íê";s:3:"臌";s:2:"íë";s:3:"臊";s:2:"íì";s:3:"臅";s:2:"íí";s:3:"臇";s:2:"íî";s:3:"膼";s:2:"íï";s:3:"臩";s:2:"íð";s:3:"艛";s:2:"íñ";s:3:"艚";s:2:"íò";s:3:"艜";s:2:"íó";s:3:"è–ƒ";s:2:"íô";s:3:"è–€";s:2:"íõ";s:3:"è–";s:2:"íö";s:3:"è–§";s:2:"í÷";s:3:"è–•";s:2:"íø";s:3:"è– ";s:2:"íù";s:3:"è–‹";s:2:"íú";s:3:"è–£";s:2:"íû";s:3:"è•»";s:2:"íü";s:3:"è–¤";s:2:"íý";s:3:"è–š";s:2:"íþ";s:3:"è–ž";s:2:"î@";s:3:"è•·";s:2:"îA";s:3:"蕼";s:2:"îB";s:3:"è–‰";s:2:"îC";s:3:"è–¡";s:2:"îD";s:3:"蕺";s:2:"îE";s:3:"蕸";s:2:"îF";s:3:"è•—";s:2:"îG";s:3:"è–Ž";s:2:"îH";s:3:"è––";s:2:"îI";s:3:"è–†";s:2:"îJ";s:3:"è–";s:2:"îK";s:3:"è–™";s:2:"îL";s:3:"è–";s:2:"îM";s:3:"è–";s:2:"îN";s:3:"è–¢";s:2:"îO";s:3:"è–‚";s:2:"îP";s:3:"è–ˆ";s:2:"îQ";s:3:"è–…";s:2:"îR";s:3:"蕹";s:2:"îS";s:3:"蕶";s:2:"îT";s:3:"è–˜";s:2:"îU";s:3:"è–";s:2:"îV";s:3:"è–Ÿ";s:2:"îW";s:3:"虨";s:2:"îX";s:3:"èž¾";s:2:"îY";s:3:"螪";s:2:"îZ";s:3:"èž­";s:2:"î[";s:3:"蟅";s:2:"î\";s:3:"èž°";s:2:"î]";s:3:"螬";s:2:"î^";s:3:"èž¹";s:2:"î_";s:3:"èžµ";s:2:"î`";s:3:"èž¼";s:2:"îa";s:3:"èž®";s:2:"îb";s:3:"蟉";s:2:"îc";s:3:"蟃";s:2:"îd";s:3:"蟂";s:2:"îe";s:3:"蟌";s:2:"îf";s:3:"èž·";s:2:"îg";s:3:"螯";s:2:"îh";s:3:"蟄";s:2:"îi";s:3:"蟊";s:2:"îj";s:3:"èž´";s:2:"îk";s:3:"螶";s:2:"îl";s:3:"èž¿";s:2:"îm";s:3:"螸";s:2:"în";s:3:"èž½";s:2:"îo";s:3:"蟞";s:2:"îp";s:3:"èž²";s:2:"îq";s:3:"褵";s:2:"îr";s:3:"褳";s:2:"îs";s:3:"褼";s:2:"ît";s:3:"褾";s:2:"îu";s:3:"è¥";s:2:"îv";s:3:"襒";s:2:"îw";s:3:"褷";s:2:"îx";s:3:"襂";s:2:"îy";s:3:"覭";s:2:"îz";s:3:"覯";s:2:"î{";s:3:"覮";s:2:"î|";s:3:"觲";s:2:"î}";s:3:"觳";s:2:"î~";s:3:"謞";s:2:"î¡";s:3:"謘";s:2:"î¢";s:3:"謖";s:2:"î£";s:3:"謑";s:2:"î¤";s:3:"謅";s:2:"î¥";s:3:"謋";s:2:"î¦";s:3:"謢";s:2:"î§";s:3:"è¬";s:2:"î¨";s:3:"謒";s:2:"î©";s:3:"謕";s:2:"îª";s:3:"謇";s:2:"î«";s:3:"è¬";s:2:"î¬";s:3:"謈";s:2:"î­";s:3:"謆";s:2:"î®";s:3:"謜";s:2:"î¯";s:3:"謓";s:2:"î°";s:3:"謚";s:2:"î±";s:3:"è±";s:2:"î²";s:3:"è±°";s:2:"î³";s:3:"è±²";s:2:"î´";s:3:"è±±";s:2:"îµ";s:3:"豯";s:2:"î¶";s:3:"貕";s:2:"î·";s:3:"è²”";s:2:"î¸";s:3:"è³¹";s:2:"î¹";s:3:"赯";s:2:"îº";s:3:"蹎";s:2:"î»";s:3:"è¹";s:2:"î¼";s:3:"蹓";s:2:"î½";s:3:"è¹";s:2:"î¾";s:3:"蹌";s:2:"î¿";s:3:"蹇";s:2:"îÀ";s:3:"轃";s:2:"îÁ";s:3:"è½€";s:2:"îÂ";s:3:"é‚…";s:2:"îÃ";s:3:"é¾";s:2:"îÄ";s:3:"鄸";s:2:"îÅ";s:3:"醚";s:2:"îÆ";s:3:"醢";s:2:"îÇ";s:3:"醛";s:2:"îÈ";s:3:"醙";s:2:"îÉ";s:3:"醟";s:2:"îÊ";s:3:"醡";s:2:"îË";s:3:"é†";s:2:"îÌ";s:3:"醠";s:2:"îÍ";s:3:"鎡";s:2:"îÎ";s:3:"鎃";s:2:"îÏ";s:3:"鎯";s:2:"îÐ";s:3:"é¤";s:2:"îÑ";s:3:"é–";s:2:"îÒ";s:3:"é‡";s:2:"îÓ";s:3:"é¼";s:2:"îÔ";s:3:"é˜";s:2:"îÕ";s:3:"éœ";s:2:"îÖ";s:3:"é¶";s:2:"î×";s:3:"é‰";s:2:"îØ";s:3:"é";s:2:"îÙ";s:3:"é‘";s:2:"îÚ";s:3:"é ";s:2:"îÛ";s:3:"é­";s:2:"îÜ";s:3:"éŽ";s:2:"îÝ";s:3:"éŒ";s:2:"îÞ";s:3:"éª";s:2:"îß";s:3:"é¹";s:2:"îà";s:3:"é—";s:2:"îá";s:3:"é•";s:2:"îâ";s:3:"é’";s:2:"îã";s:3:"é";s:2:"îä";s:3:"é±";s:2:"îå";s:3:"é·";s:2:"îæ";s:3:"é»";s:2:"îç";s:3:"é¡";s:2:"îè";s:3:"éž";s:2:"îé";s:3:"é£";s:2:"îê";s:3:"é§";s:2:"îë";s:3:"鎀";s:2:"îì";s:3:"éŽ";s:2:"îí";s:3:"é™";s:2:"îî";s:3:"é—‡";s:2:"îï";s:3:"é—€";s:2:"îð";s:3:"é—‰";s:2:"îñ";s:3:"é—ƒ";s:2:"îò";s:3:"é—…";s:2:"îó";s:3:"é–·";s:2:"îô";s:3:"éš®";s:2:"îõ";s:3:"éš°";s:2:"îö";s:3:"隬";s:2:"î÷";s:3:"霠";s:2:"îø";s:3:"霟";s:2:"îù";s:3:"霘";s:2:"îú";s:3:"éœ";s:2:"îû";s:3:"霙";s:2:"îü";s:3:"éžš";s:2:"îý";s:3:"éž¡";s:2:"îþ";s:3:"éžœ";s:2:"ï@";s:3:"éžž";s:2:"ïA";s:3:"éž";s:2:"ïB";s:3:"韕";s:2:"ïC";s:3:"韔";s:2:"ïD";s:3:"韱";s:2:"ïE";s:3:"é¡";s:2:"ïF";s:3:"é¡„";s:2:"ïG";s:3:"é¡Š";s:2:"ïH";s:3:"顉";s:2:"ïI";s:3:"é¡…";s:2:"ïJ";s:3:"顃";s:2:"ïK";s:3:"餥";s:2:"ïL";s:3:"餫";s:2:"ïM";s:3:"餬";s:2:"ïN";s:3:"餪";s:2:"ïO";s:3:"餳";s:2:"ïP";s:3:"餲";s:2:"ïQ";s:3:"餯";s:2:"ïR";s:3:"餭";s:2:"ïS";s:3:"餱";s:2:"ïT";s:3:"餰";s:2:"ïU";s:3:"馘";s:2:"ïV";s:3:"馣";s:2:"ïW";s:3:"馡";s:2:"ïX";s:3:"騂";s:2:"ïY";s:3:"駺";s:2:"ïZ";s:3:"駴";s:2:"ï[";s:3:"駷";s:2:"ï\";s:3:"駹";s:2:"ï]";s:3:"駸";s:2:"ï^";s:3:"駶";s:2:"ï_";s:3:"駻";s:2:"ï`";s:3:"駽";s:2:"ïa";s:3:"駾";s:2:"ïb";s:3:"駼";s:2:"ïc";s:3:"騃";s:2:"ïd";s:3:"骾";s:2:"ïe";s:3:"髾";s:2:"ïf";s:3:"髽";s:2:"ïg";s:3:"é¬";s:2:"ïh";s:3:"髼";s:2:"ïi";s:3:"é­ˆ";s:2:"ïj";s:3:"鮚";s:2:"ïk";s:3:"鮨";s:2:"ïl";s:3:"鮞";s:2:"ïm";s:3:"é®›";s:2:"ïn";s:3:"鮦";s:2:"ïo";s:3:"鮡";s:2:"ïp";s:3:"鮥";s:2:"ïq";s:3:"鮤";s:2:"ïr";s:3:"鮆";s:2:"ïs";s:3:"鮢";s:2:"ït";s:3:"é® ";s:2:"ïu";s:3:"鮯";s:2:"ïv";s:3:"é´³";s:2:"ïw";s:3:"éµ";s:2:"ïx";s:3:"鵧";s:2:"ïy";s:3:"é´¶";s:2:"ïz";s:3:"é´®";s:2:"ï{";s:3:"é´¯";s:2:"ï|";s:3:"é´±";s:2:"ï}";s:3:"é´¸";s:2:"ï~";s:3:"é´°";s:2:"ï¡";s:3:"éµ…";s:2:"ï¢";s:3:"鵂";s:2:"ï£";s:3:"鵃";s:2:"ï¤";s:3:"é´¾";s:2:"ï¥";s:3:"é´·";s:2:"ï¦";s:3:"éµ€";s:2:"ï§";s:3:"é´½";s:2:"ï¨";s:3:"翵";s:2:"ï©";s:3:"é´­";s:2:"ïª";s:3:"麊";s:2:"ï«";s:3:"麉";s:2:"ï¬";s:3:"éº";s:2:"ï­";s:3:"麰";s:2:"ï®";s:3:"黈";s:2:"ï¯";s:3:"黚";s:2:"ï°";s:3:"é»»";s:2:"ï±";s:3:"黿";s:2:"ï²";s:3:"鼤";s:2:"ï³";s:3:"é¼£";s:2:"ï´";s:3:"é¼¢";s:2:"ïµ";s:3:"é½”";s:2:"ï¶";s:3:"é¾ ";s:2:"ï·";s:3:"儱";s:2:"ï¸";s:3:"å„­";s:2:"ï¹";s:3:"å„®";s:2:"ïº";s:3:"嚘";s:2:"ï»";s:3:"åšœ";s:2:"ï¼";s:3:"åš—";s:2:"ï½";s:3:"åšš";s:2:"ï¾";s:3:"åš";s:2:"ï¿";s:3:"åš™";s:2:"ïÀ";s:3:"奰";s:2:"ïÁ";s:3:"嬼";s:2:"ïÂ";s:3:"屩";s:2:"ïÃ";s:3:"屪";s:2:"ïÄ";s:3:"å·€";s:2:"ïÅ";s:3:"å¹­";s:2:"ïÆ";s:3:"å¹®";s:2:"ïÇ";s:3:"懘";s:2:"ïÈ";s:3:"懟";s:2:"ïÉ";s:3:"懭";s:2:"ïÊ";s:3:"懮";s:2:"ïË";s:3:"懱";s:2:"ïÌ";s:3:"懪";s:2:"ïÍ";s:3:"懰";s:2:"ïÎ";s:3:"懫";s:2:"ïÏ";s:3:"懖";s:2:"ïÐ";s:3:"懩";s:2:"ïÑ";s:3:"æ“¿";s:2:"ïÒ";s:3:"攄";s:2:"ïÓ";s:3:"擽";s:2:"ïÔ";s:3:"擸";s:2:"ïÕ";s:3:"æ”";s:2:"ïÖ";s:3:"攃";s:2:"ï×";s:3:"擼";s:2:"ïØ";s:3:"æ–”";s:2:"ïÙ";s:3:"æ—›";s:2:"ïÚ";s:3:"曚";s:2:"ïÛ";s:3:"æ››";s:2:"ïÜ";s:3:"曘";s:2:"ïÝ";s:3:"æ«…";s:2:"ïÞ";s:3:"檹";s:2:"ïß";s:3:"檽";s:2:"ïà";s:3:"æ«¡";s:2:"ïá";s:3:"櫆";s:2:"ïâ";s:3:"檺";s:2:"ïã";s:3:"檶";s:2:"ïä";s:3:"檷";s:2:"ïå";s:3:"櫇";s:2:"ïæ";s:3:"檴";s:2:"ïç";s:3:"檭";s:2:"ïè";s:3:"æ­ž";s:2:"ïé";s:3:"毉";s:2:"ïê";s:3:"æ°‹";s:2:"ïë";s:3:"瀇";s:2:"ïì";s:3:"瀌";s:2:"ïí";s:3:"ç€";s:2:"ïî";s:3:"ç€";s:2:"ïï";s:3:"瀅";s:2:"ïð";s:3:"瀔";s:2:"ïñ";s:3:"瀎";s:2:"ïò";s:3:"æ¿¿";s:2:"ïó";s:3:"瀀";s:2:"ïô";s:3:"æ¿»";s:2:"ïõ";s:3:"瀦";s:2:"ïö";s:3:"濼";s:2:"ï÷";s:3:"æ¿·";s:2:"ïø";s:3:"瀊";s:2:"ïù";s:3:"çˆ";s:2:"ïú";s:3:"燿";s:2:"ïû";s:3:"燹";s:2:"ïü";s:3:"爃";s:2:"ïý";s:3:"燽";s:2:"ïþ";s:3:"ç¶";s:2:"ð@";s:3:"ç’¸";s:2:"ðA";s:3:"ç“€";s:2:"ðB";s:3:"ç’µ";s:2:"ðC";s:3:"ç“";s:2:"ðD";s:3:"ç’¾";s:2:"ðE";s:3:"ç’¶";s:2:"ðF";s:3:"ç’»";s:2:"ðG";s:3:"ç“‚";s:2:"ðH";s:3:"ç””";s:2:"ðI";s:3:"甓";s:2:"ðJ";s:3:"癜";s:2:"ðK";s:3:"癤";s:2:"ðL";s:3:"ç™™";s:2:"ðM";s:3:"ç™";s:2:"ðN";s:3:"癓";s:2:"ðO";s:3:"ç™—";s:2:"ðP";s:3:"癚";s:2:"ðQ";s:3:"皦";s:2:"ðR";s:3:"çš½";s:2:"ðS";s:3:"盬";s:2:"ðT";s:3:"矂";s:2:"ðU";s:3:"瞺";s:2:"ðV";s:3:"磿";s:2:"ðW";s:3:"礌";s:2:"ðX";s:3:"礓";s:2:"ðY";s:3:"礔";s:2:"ðZ";s:3:"礉";s:2:"ð[";s:3:"ç¤";s:2:"ð\";s:3:"礒";s:2:"ð]";s:3:"礑";s:2:"ð^";s:3:"禭";s:2:"ð_";s:3:"禬";s:2:"ð`";s:3:"ç©Ÿ";s:2:"ða";s:3:"ç°œ";s:2:"ðb";s:3:"ç°©";s:2:"ðc";s:3:"ç°™";s:2:"ðd";s:3:"ç° ";s:2:"ðe";s:3:"ç°Ÿ";s:2:"ðf";s:3:"ç°­";s:2:"ðg";s:3:"ç°";s:2:"ðh";s:3:"ç°¦";s:2:"ði";s:3:"ç°¨";s:2:"ðj";s:3:"ç°¢";s:2:"ðk";s:3:"ç°¥";s:2:"ðl";s:3:"ç°°";s:2:"ðm";s:3:"繜";s:2:"ðn";s:3:"ç¹";s:2:"ðo";s:3:"ç¹–";s:2:"ðp";s:3:"ç¹£";s:2:"ðq";s:3:"繘";s:2:"ðr";s:3:"ç¹¢";s:2:"ðs";s:3:"繟";s:2:"ðt";s:3:"繑";s:2:"ðu";s:3:"ç¹ ";s:2:"ðv";s:3:"ç¹—";s:2:"ðw";s:3:"繓";s:2:"ðx";s:3:"ç¾µ";s:2:"ðy";s:3:"ç¾³";s:2:"ðz";s:3:"ç¿·";s:2:"ð{";s:3:"翸";s:2:"ð|";s:3:"èµ";s:2:"ð}";s:3:"臑";s:2:"ð~";s:3:"臒";s:2:"ð¡";s:3:"è‡";s:2:"ð¢";s:3:"艟";s:2:"ð£";s:3:"艞";s:2:"ð¤";s:3:"è–´";s:2:"ð¥";s:3:"è—†";s:2:"ð¦";s:3:"è—€";s:2:"ð§";s:3:"è—ƒ";s:2:"ð¨";s:3:"è—‚";s:2:"ð©";s:3:"è–³";s:2:"ðª";s:3:"è–µ";s:2:"ð«";s:3:"è–½";s:2:"ð¬";s:3:"è—‡";s:2:"ð­";s:3:"è—„";s:2:"ð®";s:3:"è–¿";s:2:"ð¯";s:3:"è—‹";s:2:"ð°";s:3:"è—Ž";s:2:"ð±";s:3:"è—ˆ";s:2:"ð²";s:3:"è—…";s:2:"ð³";s:3:"è–±";s:2:"ð´";s:3:"è–¶";s:2:"ðµ";s:3:"è—’";s:2:"ð¶";s:3:"蘤";s:2:"ð·";s:3:"è–¸";s:2:"ð¸";s:3:"è–·";s:2:"ð¹";s:3:"è–¾";s:2:"ðº";s:3:"虩";s:2:"ð»";s:3:"蟧";s:2:"ð¼";s:3:"蟦";s:2:"ð½";s:3:"蟢";s:2:"ð¾";s:3:"蟛";s:2:"ð¿";s:3:"蟫";s:2:"ðÀ";s:3:"蟪";s:2:"ðÁ";s:3:"蟥";s:2:"ðÂ";s:3:"蟟";s:2:"ðÃ";s:3:"蟳";s:2:"ðÄ";s:3:"蟤";s:2:"ðÅ";s:3:"蟔";s:2:"ðÆ";s:3:"蟜";s:2:"ðÇ";s:3:"蟓";s:2:"ðÈ";s:3:"蟭";s:2:"ðÉ";s:3:"蟘";s:2:"ðÊ";s:3:"蟣";s:2:"ðË";s:3:"螤";s:2:"ðÌ";s:3:"蟗";s:2:"ðÍ";s:3:"蟙";s:2:"ðÎ";s:3:"è ";s:2:"ðÏ";s:3:"蟴";s:2:"ðÐ";s:3:"蟨";s:2:"ðÑ";s:3:"èŸ";s:2:"ðÒ";s:3:"襓";s:2:"ðÓ";s:3:"襋";s:2:"ðÔ";s:3:"è¥";s:2:"ðÕ";s:3:"襌";s:2:"ðÖ";s:3:"襆";s:2:"ð×";s:3:"è¥";s:2:"ðØ";s:3:"襑";s:2:"ðÙ";s:3:"襉";s:2:"ðÚ";s:3:"謪";s:2:"ðÛ";s:3:"謧";s:2:"ðÜ";s:3:"謣";s:2:"ðÝ";s:3:"謳";s:2:"ðÞ";s:3:"謰";s:2:"ðß";s:3:"謵";s:2:"ðà";s:3:"è­‡";s:2:"ðá";s:3:"謯";s:2:"ðâ";s:3:"謼";s:2:"ðã";s:3:"謾";s:2:"ðä";s:3:"謱";s:2:"ðå";s:3:"謥";s:2:"ðæ";s:3:"謷";s:2:"ðç";s:3:"謦";s:2:"ðè";s:3:"謶";s:2:"ðé";s:3:"謮";s:2:"ðê";s:3:"謤";s:2:"ðë";s:3:"謻";s:2:"ðì";s:3:"謽";s:2:"ðí";s:3:"謺";s:2:"ðî";s:3:"豂";s:2:"ðï";s:3:"è±µ";s:2:"ðð";s:3:"è²™";s:2:"ðñ";s:3:"貘";s:2:"ðò";s:3:"è²—";s:2:"ðó";s:3:"è³¾";s:2:"ðô";s:3:"è´„";s:2:"ðõ";s:3:"è´‚";s:2:"ðö";s:3:"è´€";s:2:"ð÷";s:3:"蹜";s:2:"ðø";s:3:"è¹¢";s:2:"ðù";s:3:"è¹ ";s:2:"ðú";s:3:"è¹—";s:2:"ðû";s:3:"è¹–";s:2:"ðü";s:3:"蹞";s:2:"ðý";s:3:"è¹¥";s:2:"ðþ";s:3:"蹧";s:2:"ñ@";s:3:"è¹›";s:2:"ñA";s:3:"蹚";s:2:"ñB";s:3:"蹡";s:2:"ñC";s:3:"è¹";s:2:"ñD";s:3:"蹩";s:2:"ñE";s:3:"è¹”";s:2:"ñF";s:3:"轆";s:2:"ñG";s:3:"轇";s:2:"ñH";s:3:"轈";s:2:"ñI";s:3:"轋";s:2:"ñJ";s:3:"鄨";s:2:"ñK";s:3:"鄺";s:2:"ñL";s:3:"é„»";s:2:"ñM";s:3:"鄾";s:2:"ñN";s:3:"醨";s:2:"ñO";s:3:"醥";s:2:"ñP";s:3:"醧";s:2:"ñQ";s:3:"醯";s:2:"ñR";s:3:"醪";s:2:"ñS";s:3:"鎵";s:2:"ñT";s:3:"鎌";s:2:"ñU";s:3:"鎒";s:2:"ñV";s:3:"鎷";s:2:"ñW";s:3:"鎛";s:2:"ñX";s:3:"éŽ";s:2:"ñY";s:3:"鎉";s:2:"ñZ";s:3:"鎧";s:2:"ñ[";s:3:"鎎";s:2:"ñ\";s:3:"鎪";s:2:"ñ]";s:3:"鎞";s:2:"ñ^";s:3:"鎦";s:2:"ñ_";s:3:"鎕";s:2:"ñ`";s:3:"鎈";s:2:"ña";s:3:"鎙";s:2:"ñb";s:3:"鎟";s:2:"ñc";s:3:"éŽ";s:2:"ñd";s:3:"鎱";s:2:"ñe";s:3:"鎑";s:2:"ñf";s:3:"鎲";s:2:"ñg";s:3:"鎤";s:2:"ñh";s:3:"鎨";s:2:"ñi";s:3:"鎴";s:2:"ñj";s:3:"鎣";s:2:"ñk";s:3:"鎥";s:2:"ñl";s:3:"é—’";s:2:"ñm";s:3:"é—“";s:2:"ñn";s:3:"é—‘";s:2:"ño";s:3:"éš³";s:2:"ñp";s:3:"é›—";s:2:"ñq";s:3:"雚";s:2:"ñr";s:3:"å·‚";s:2:"ñs";s:3:"雟";s:2:"ñt";s:3:"雘";s:2:"ñu";s:3:"é›";s:2:"ñv";s:3:"霣";s:2:"ñw";s:3:"霢";s:2:"ñx";s:3:"霥";s:2:"ñy";s:3:"鞬";s:2:"ñz";s:3:"éž®";s:2:"ñ{";s:3:"鞨";s:2:"ñ|";s:3:"éž«";s:2:"ñ}";s:3:"鞤";s:2:"ñ~";s:3:"鞪";s:2:"ñ¡";s:3:"鞢";s:2:"ñ¢";s:3:"鞥";s:2:"ñ£";s:3:"韗";s:2:"ñ¤";s:3:"韙";s:2:"ñ¥";s:3:"韖";s:2:"ñ¦";s:3:"韘";s:2:"ñ§";s:3:"韺";s:2:"ñ¨";s:3:"é¡";s:2:"ñ©";s:3:"é¡‘";s:2:"ñª";s:3:"é¡’";s:2:"ñ«";s:3:"颸";s:2:"ñ¬";s:3:"é¥";s:2:"ñ­";s:3:"餼";s:2:"ñ®";s:3:"餺";s:2:"ñ¯";s:3:"é¨";s:2:"ñ°";s:3:"騋";s:2:"ñ±";s:3:"騉";s:2:"ñ²";s:3:"é¨";s:2:"ñ³";s:3:"騄";s:2:"ñ´";s:3:"騑";s:2:"ñµ";s:3:"騊";s:2:"ñ¶";s:3:"騅";s:2:"ñ·";s:3:"騇";s:2:"ñ¸";s:3:"騆";s:2:"ñ¹";s:3:"é«€";s:2:"ñº";s:3:"é«œ";s:2:"ñ»";s:3:"鬈";s:2:"ñ¼";s:3:"鬄";s:2:"ñ½";s:3:"鬅";s:2:"ñ¾";s:3:"鬩";s:2:"ñ¿";s:3:"鬵";s:2:"ñÀ";s:3:"é­Š";s:2:"ñÁ";s:3:"é­Œ";s:2:"ñÂ";s:3:"é­‹";s:2:"ñÃ";s:3:"鯇";s:2:"ñÄ";s:3:"鯆";s:2:"ñÅ";s:3:"鯃";s:2:"ñÆ";s:3:"鮿";s:2:"ñÇ";s:3:"é¯";s:2:"ñÈ";s:3:"鮵";s:2:"ñÉ";s:3:"鮸";s:2:"ñÊ";s:3:"鯓";s:2:"ñË";s:3:"鮶";s:2:"ñÌ";s:3:"鯄";s:2:"ñÍ";s:3:"鮹";s:2:"ñÎ";s:3:"鮽";s:2:"ñÏ";s:3:"鵜";s:2:"ñÐ";s:3:"鵓";s:2:"ñÑ";s:3:"éµ";s:2:"ñÒ";s:3:"鵊";s:2:"ñÓ";s:3:"éµ›";s:2:"ñÔ";s:3:"鵋";s:2:"ñÕ";s:3:"éµ™";s:2:"ñÖ";s:3:"éµ–";s:2:"ñ×";s:3:"鵌";s:2:"ñØ";s:3:"éµ—";s:2:"ñÙ";s:3:"éµ’";s:2:"ñÚ";s:3:"éµ”";s:2:"ñÛ";s:3:"鵟";s:2:"ñÜ";s:3:"鵘";s:2:"ñÝ";s:3:"鵚";s:2:"ñÞ";s:3:"麎";s:2:"ñß";s:3:"麌";s:2:"ñà";s:3:"黟";s:2:"ñá";s:3:"é¼";s:2:"ñâ";s:3:"é¼€";s:2:"ñã";s:3:"é¼–";s:2:"ñä";s:3:"é¼¥";s:2:"ñå";s:3:"鼫";s:2:"ñæ";s:3:"鼪";s:2:"ñç";s:3:"鼩";s:2:"ñè";s:3:"鼨";s:2:"ñé";s:3:"齌";s:2:"ñê";s:3:"齕";s:2:"ñë";s:3:"å„´";s:2:"ñì";s:3:"儵";s:2:"ñí";s:3:"劖";s:2:"ñî";s:3:"å‹·";s:2:"ñï";s:3:"厴";s:2:"ñð";s:3:"åš«";s:2:"ññ";s:3:"åš­";s:2:"ñò";s:3:"嚦";s:2:"ñó";s:3:"嚧";s:2:"ñô";s:3:"嚪";s:2:"ñõ";s:3:"嚬";s:2:"ñö";s:3:"壚";s:2:"ñ÷";s:3:"å£";s:2:"ñø";s:3:"壛";s:2:"ñù";s:3:"夒";s:2:"ñú";s:3:"嬽";s:2:"ñû";s:3:"嬾";s:2:"ñü";s:3:"嬿";s:2:"ñý";s:3:"å·ƒ";s:2:"ñþ";s:3:"å¹°";s:2:"ò@";s:3:"徿";s:2:"òA";s:3:"懻";s:2:"òB";s:3:"攇";s:2:"òC";s:3:"æ”";s:2:"òD";s:3:"æ”";s:2:"òE";s:3:"攉";s:2:"òF";s:3:"攌";s:2:"òG";s:3:"攎";s:2:"òH";s:3:"æ–„";s:2:"òI";s:3:"æ—ž";s:2:"òJ";s:3:"æ—";s:2:"òK";s:3:"曞";s:2:"òL";s:3:"櫧";s:2:"òM";s:3:"æ« ";s:2:"òN";s:3:"æ«Œ";s:2:"òO";s:3:"æ«‘";s:2:"òP";s:3:"æ«™";s:2:"òQ";s:3:"æ«‹";s:2:"òR";s:3:"æ«Ÿ";s:2:"òS";s:3:"æ«œ";s:2:"òT";s:3:"æ«";s:2:"òU";s:3:"æ««";s:2:"òV";s:3:"æ«";s:2:"òW";s:3:"æ«";s:2:"òX";s:3:"æ«ž";s:2:"òY";s:3:"æ­ ";s:2:"òZ";s:3:"æ®°";s:2:"ò[";s:3:"æ°Œ";s:2:"ò\";s:3:"瀙";s:2:"ò]";s:3:"瀧";s:2:"ò^";s:3:"瀠";s:2:"ò_";s:3:"瀖";s:2:"ò`";s:3:"瀫";s:2:"òa";s:3:"瀡";s:2:"òb";s:3:"瀢";s:2:"òc";s:3:"瀣";s:2:"òd";s:3:"瀩";s:2:"òe";s:3:"瀗";s:2:"òf";s:3:"瀤";s:2:"òg";s:3:"瀜";s:2:"òh";s:3:"瀪";s:2:"òi";s:3:"爌";s:2:"òj";s:3:"爊";s:2:"òk";s:3:"爇";s:2:"òl";s:3:"爂";s:2:"òm";s:3:"爅";s:2:"òn";s:3:"犥";s:2:"òo";s:3:"犦";s:2:"òp";s:3:"犤";s:2:"òq";s:3:"犣";s:2:"òr";s:3:"犡";s:2:"òs";s:3:"ç“‹";s:2:"òt";s:3:"ç“…";s:2:"òu";s:3:"ç’·";s:2:"òv";s:3:"瓃";s:2:"òw";s:3:"ç”–";s:2:"òx";s:3:"ç™ ";s:2:"òy";s:3:"矉";s:2:"òz";s:3:"矊";s:2:"ò{";s:3:"矄";s:2:"ò|";s:3:"矱";s:2:"ò}";s:3:"ç¤";s:2:"ò~";s:3:"礛";s:2:"ò¡";s:3:"礡";s:2:"ò¢";s:3:"礜";s:2:"ò£";s:3:"礗";s:2:"ò¤";s:3:"礞";s:2:"ò¥";s:3:"禰";s:2:"ò¦";s:3:"穧";s:2:"ò§";s:3:"穨";s:2:"ò¨";s:3:"ç°³";s:2:"ò©";s:3:"ç°¼";s:2:"òª";s:3:"ç°¹";s:2:"ò«";s:3:"ç°¬";s:2:"ò¬";s:3:"ç°»";s:2:"ò­";s:3:"糬";s:2:"ò®";s:3:"糪";s:2:"ò¯";s:3:"繶";s:2:"ò°";s:3:"ç¹µ";s:2:"ò±";s:3:"繸";s:2:"ò²";s:3:"ç¹°";s:2:"ò³";s:3:"ç¹·";s:2:"ò´";s:3:"繯";s:2:"òµ";s:3:"繺";s:2:"ò¶";s:3:"ç¹²";s:2:"ò·";s:3:"ç¹´";s:2:"ò¸";s:3:"繨";s:2:"ò¹";s:3:"罋";s:2:"òº";s:3:"罊";s:2:"ò»";s:3:"羃";s:2:"ò¼";s:3:"羆";s:2:"ò½";s:3:"ç¾·";s:2:"ò¾";s:3:"翽";s:2:"ò¿";s:3:"翾";s:2:"òÀ";s:3:"è¸";s:2:"òÁ";s:3:"臗";s:2:"òÂ";s:3:"臕";s:2:"òÃ";s:3:"艤";s:2:"òÄ";s:3:"艡";s:2:"òÅ";s:3:"艣";s:2:"òÆ";s:3:"è—«";s:2:"òÇ";s:3:"è—±";s:2:"òÈ";s:3:"è—­";s:2:"òÉ";s:3:"è—™";s:2:"òÊ";s:3:"è—¡";s:2:"òË";s:3:"è—¨";s:2:"òÌ";s:3:"è—š";s:2:"òÍ";s:3:"è——";s:2:"òÎ";s:3:"è—¬";s:2:"òÏ";s:3:"è—²";s:2:"òÐ";s:3:"è—¸";s:2:"òÑ";s:3:"è—˜";s:2:"òÒ";s:3:"è—Ÿ";s:2:"òÓ";s:3:"è—£";s:2:"òÔ";s:3:"è—œ";s:2:"òÕ";s:3:"è—‘";s:2:"òÖ";s:3:"è—°";s:2:"ò×";s:3:"è—¦";s:2:"òØ";s:3:"è—¯";s:2:"òÙ";s:3:"è—ž";s:2:"òÚ";s:3:"è—¢";s:2:"òÛ";s:3:"è €";s:2:"òÜ";s:3:"蟺";s:2:"òÝ";s:3:"è ƒ";s:2:"òÞ";s:3:"蟶";s:2:"òß";s:3:"蟷";s:2:"òà";s:3:"è ‰";s:2:"òá";s:3:"è Œ";s:2:"òâ";s:3:"è ‹";s:2:"òã";s:3:"è †";s:2:"òä";s:3:"蟼";s:2:"òå";s:3:"è ˆ";s:2:"òæ";s:3:"蟿";s:2:"òç";s:3:"è Š";s:2:"òè";s:3:"è ‚";s:2:"òé";s:3:"襢";s:2:"òê";s:3:"襚";s:2:"òë";s:3:"襛";s:2:"òì";s:3:"襗";s:2:"òí";s:3:"襡";s:2:"òî";s:3:"襜";s:2:"òï";s:3:"襘";s:2:"òð";s:3:"è¥";s:2:"òñ";s:3:"襙";s:2:"òò";s:3:"覈";s:2:"òó";s:3:"覷";s:2:"òô";s:3:"覶";s:2:"òõ";s:3:"觶";s:2:"òö";s:3:"è­";s:2:"ò÷";s:3:"è­ˆ";s:2:"òø";s:3:"è­Š";s:2:"òù";s:3:"è­€";s:2:"òú";s:3:"è­“";s:2:"òû";s:3:"è­–";s:2:"òü";s:3:"è­”";s:2:"òý";s:3:"è­‹";s:2:"òþ";s:3:"è­•";s:2:"ó@";s:3:"è­‘";s:2:"óA";s:3:"è­‚";s:2:"óB";s:3:"è­’";s:2:"óC";s:3:"è­—";s:2:"óD";s:3:"豃";s:2:"óE";s:3:"è±·";s:2:"óF";s:3:"豶";s:2:"óG";s:3:"貚";s:2:"óH";s:3:"è´†";s:2:"óI";s:3:"è´‡";s:2:"óJ";s:3:"è´‰";s:2:"óK";s:3:"趬";s:2:"óL";s:3:"趪";s:2:"óM";s:3:"趭";s:2:"óN";s:3:"趫";s:2:"óO";s:3:"è¹­";s:2:"óP";s:3:"蹸";s:2:"óQ";s:3:"è¹³";s:2:"óR";s:3:"蹪";s:2:"óS";s:3:"蹯";s:2:"óT";s:3:"è¹»";s:2:"óU";s:3:"軂";s:2:"óV";s:3:"è½’";s:2:"óW";s:3:"轑";s:2:"óX";s:3:"è½";s:2:"óY";s:3:"è½";s:2:"óZ";s:3:"轓";s:2:"ó[";s:3:"è¾´";s:2:"ó\";s:3:"é…€";s:2:"ó]";s:3:"é„¿";s:2:"ó^";s:3:"醰";s:2:"ó_";s:3:"醭";s:2:"ó`";s:3:"éž";s:2:"óa";s:3:"é‡";s:2:"ób";s:3:"é";s:2:"óc";s:3:"é‚";s:2:"ód";s:3:"éš";s:2:"óe";s:3:"é";s:2:"óf";s:3:"é¹";s:2:"óg";s:3:"é¬";s:2:"óh";s:3:"éŒ";s:2:"ói";s:3:"é™";s:2:"ój";s:3:"鎩";s:2:"ók";s:3:"é¦";s:2:"ól";s:3:"éŠ";s:2:"óm";s:3:"é”";s:2:"ón";s:3:"é®";s:2:"óo";s:3:"é£";s:2:"óp";s:3:"é•";s:2:"óq";s:3:"é„";s:2:"ór";s:3:"éŽ";s:2:"ós";s:3:"é€";s:2:"ót";s:3:"é’";s:2:"óu";s:3:"é§";s:2:"óv";s:3:"镽";s:2:"ów";s:3:"é—š";s:2:"óx";s:3:"é—›";s:2:"óy";s:3:"雡";s:2:"óz";s:3:"霩";s:2:"ó{";s:3:"霫";s:2:"ó|";s:3:"霬";s:2:"ó}";s:3:"霨";s:2:"ó~";s:3:"霦";s:2:"ó¡";s:3:"éž³";s:2:"ó¢";s:3:"éž·";s:2:"ó£";s:3:"鞶";s:2:"ó¤";s:3:"éŸ";s:2:"ó¥";s:3:"韞";s:2:"ó¦";s:3:"韟";s:2:"ó§";s:3:"é¡œ";s:2:"ó¨";s:3:"é¡™";s:2:"ó©";s:3:"é¡";s:2:"óª";s:3:"é¡—";s:2:"ó«";s:3:"颿";s:2:"ó¬";s:3:"颽";s:2:"ó­";s:3:"颻";s:2:"ó®";s:3:"颾";s:2:"ó¯";s:3:"饈";s:2:"ó°";s:3:"饇";s:2:"ó±";s:3:"饃";s:2:"ó²";s:3:"馦";s:2:"ó³";s:3:"馧";s:2:"ó´";s:3:"騚";s:2:"óµ";s:3:"騕";s:2:"ó¶";s:3:"騥";s:2:"ó·";s:3:"é¨";s:2:"ó¸";s:3:"騤";s:2:"ó¹";s:3:"騛";s:2:"óº";s:3:"騢";s:2:"ó»";s:3:"騠";s:2:"ó¼";s:3:"騧";s:2:"ó½";s:3:"騣";s:2:"ó¾";s:3:"騞";s:2:"ó¿";s:3:"騜";s:2:"óÀ";s:3:"騔";s:2:"óÁ";s:3:"é«‚";s:2:"óÂ";s:3:"鬋";s:2:"óÃ";s:3:"鬊";s:2:"óÄ";s:3:"鬎";s:2:"óÅ";s:3:"鬌";s:2:"óÆ";s:3:"鬷";s:2:"óÇ";s:3:"鯪";s:2:"óÈ";s:3:"鯫";s:2:"óÉ";s:3:"鯠";s:2:"óÊ";s:3:"鯞";s:2:"óË";s:3:"鯤";s:2:"óÌ";s:3:"鯦";s:2:"óÍ";s:3:"鯢";s:2:"óÎ";s:3:"鯰";s:2:"óÏ";s:3:"鯔";s:2:"óÐ";s:3:"鯗";s:2:"óÑ";s:3:"鯬";s:2:"óÒ";s:3:"鯜";s:2:"óÓ";s:3:"鯙";s:2:"óÔ";s:3:"鯥";s:2:"óÕ";s:3:"鯕";s:2:"óÖ";s:3:"鯡";s:2:"ó×";s:3:"鯚";s:2:"óØ";s:3:"éµ·";s:2:"óÙ";s:3:"é¶";s:2:"óÚ";s:3:"鶊";s:2:"óÛ";s:3:"鶄";s:2:"óÜ";s:3:"鶈";s:2:"óÝ";s:3:"éµ±";s:2:"óÞ";s:3:"鶀";s:2:"óß";s:3:"鵸";s:2:"óà";s:3:"鶆";s:2:"óá";s:3:"鶋";s:2:"óâ";s:3:"鶌";s:2:"óã";s:3:"éµ½";s:2:"óä";s:3:"鵫";s:2:"óå";s:3:"éµ´";s:2:"óæ";s:3:"éµµ";s:2:"óç";s:3:"éµ°";s:2:"óè";s:3:"鵩";s:2:"óé";s:3:"鶅";s:2:"óê";s:3:"éµ³";s:2:"óë";s:3:"éµ»";s:2:"óì";s:3:"鶂";s:2:"óí";s:3:"鵯";s:2:"óî";s:3:"éµ¹";s:2:"óï";s:3:"鵿";s:2:"óð";s:3:"鶇";s:2:"óñ";s:3:"鵨";s:2:"óò";s:3:"麔";s:2:"óó";s:3:"麑";s:2:"óô";s:3:"黀";s:2:"óõ";s:3:"黼";s:2:"óö";s:3:"é¼­";s:2:"ó÷";s:3:"é½€";s:2:"óø";s:3:"é½";s:2:"óù";s:3:"é½";s:2:"óú";s:3:"é½–";s:2:"óû";s:3:"é½—";s:2:"óü";s:3:"齘";s:2:"óý";s:3:"匷";s:2:"óþ";s:3:"åš²";s:2:"ô@";s:3:"åšµ";s:2:"ôA";s:3:"åš³";s:2:"ôB";s:3:"壣";s:2:"ôC";s:3:"å­…";s:2:"ôD";s:3:"å·†";s:2:"ôE";s:3:"å·‡";s:2:"ôF";s:3:"å»®";s:2:"ôG";s:3:"廯";s:2:"ôH";s:3:"å¿€";s:2:"ôI";s:3:"å¿";s:2:"ôJ";s:3:"懹";s:2:"ôK";s:3:"æ”—";s:2:"ôL";s:3:"æ”–";s:2:"ôM";s:3:"攕";s:2:"ôN";s:3:"攓";s:2:"ôO";s:3:"æ—Ÿ";s:2:"ôP";s:3:"曨";s:2:"ôQ";s:3:"曣";s:2:"ôR";s:3:"曤";s:2:"ôS";s:3:"櫳";s:2:"ôT";s:3:"æ«°";s:2:"ôU";s:3:"櫪";s:2:"ôV";s:3:"櫨";s:2:"ôW";s:3:"櫹";s:2:"ôX";s:3:"櫱";s:2:"ôY";s:3:"æ«®";s:2:"ôZ";s:3:"櫯";s:2:"ô[";s:3:"瀼";s:2:"ô\";s:3:"瀵";s:2:"ô]";s:3:"瀯";s:2:"ô^";s:3:"瀷";s:2:"ô_";s:3:"瀴";s:2:"ô`";s:3:"瀱";s:2:"ôa";s:3:"ç‚";s:2:"ôb";s:3:"瀸";s:2:"ôc";s:3:"瀿";s:2:"ôd";s:3:"瀺";s:2:"ôe";s:3:"瀹";s:2:"ôf";s:3:"ç€";s:2:"ôg";s:3:"瀻";s:2:"ôh";s:3:"瀳";s:2:"ôi";s:3:"ç";s:2:"ôj";s:3:"爓";s:2:"ôk";s:3:"爔";s:2:"ôl";s:3:"犨";s:2:"ôm";s:3:"ç½";s:2:"ôn";s:3:"ç¼";s:2:"ôo";s:3:"ç’º";s:2:"ôp";s:3:"çš«";s:2:"ôq";s:3:"皪";s:2:"ôr";s:3:"çš¾";s:2:"ôs";s:3:"ç›­";s:2:"ôt";s:3:"矌";s:2:"ôu";s:3:"矎";s:2:"ôv";s:3:"çŸ";s:2:"ôw";s:3:"çŸ";s:2:"ôx";s:3:"矲";s:2:"ôy";s:3:"礥";s:2:"ôz";s:3:"礣";s:2:"ô{";s:3:"礧";s:2:"ô|";s:3:"礨";s:2:"ô}";s:3:"礤";s:2:"ô~";s:3:"礩";s:2:"ô¡";s:3:"禲";s:2:"ô¢";s:3:"ç©®";s:2:"ô£";s:3:"穬";s:2:"ô¤";s:3:"ç©­";s:2:"ô¥";s:3:"ç«·";s:2:"ô¦";s:3:"籉";s:2:"ô§";s:3:"籈";s:2:"ô¨";s:3:"籊";s:2:"ô©";s:3:"籇";s:2:"ôª";s:3:"ç±…";s:2:"ô«";s:3:"ç³®";s:2:"ô¬";s:3:"ç¹»";s:2:"ô­";s:3:"ç¹¾";s:2:"ô®";s:3:"çº";s:2:"ô¯";s:3:"纀";s:2:"ô°";s:3:"羺";s:2:"ô±";s:3:"ç¿¿";s:2:"ô²";s:3:"è¹";s:2:"ô³";s:3:"臛";s:2:"ô´";s:3:"臙";s:2:"ôµ";s:3:"舋";s:2:"ô¶";s:3:"艨";s:2:"ô·";s:3:"艩";s:2:"ô¸";s:3:"蘢";s:2:"ô¹";s:3:"è—¿";s:2:"ôº";s:3:"è˜";s:2:"ô»";s:3:"è—¾";s:2:"ô¼";s:3:"蘛";s:2:"ô½";s:3:"蘀";s:2:"ô¾";s:3:"è—¶";s:2:"ô¿";s:3:"蘄";s:2:"ôÀ";s:3:"蘉";s:2:"ôÁ";s:3:"蘅";s:2:"ôÂ";s:3:"蘌";s:2:"ôÃ";s:3:"è—½";s:2:"ôÄ";s:3:"è ™";s:2:"ôÅ";s:3:"è ";s:2:"ôÆ";s:3:"è ‘";s:2:"ôÇ";s:3:"è —";s:2:"ôÈ";s:3:"è “";s:2:"ôÉ";s:3:"è –";s:2:"ôÊ";s:3:"襣";s:2:"ôË";s:3:"襦";s:2:"ôÌ";s:3:"覹";s:2:"ôÍ";s:3:"觷";s:2:"ôÎ";s:3:"è­ ";s:2:"ôÏ";s:3:"è­ª";s:2:"ôÐ";s:3:"è­";s:2:"ôÑ";s:3:"è­¨";s:2:"ôÒ";s:3:"è­£";s:2:"ôÓ";s:3:"è­¥";s:2:"ôÔ";s:3:"è­§";s:2:"ôÕ";s:3:"è­­";s:2:"ôÖ";s:3:"趮";s:2:"ô×";s:3:"躆";s:2:"ôØ";s:3:"躈";s:2:"ôÙ";s:3:"躄";s:2:"ôÚ";s:3:"è½™";s:2:"ôÛ";s:3:"è½–";s:2:"ôÜ";s:3:"è½—";s:2:"ôÝ";s:3:"轕";s:2:"ôÞ";s:3:"轘";s:2:"ôß";s:3:"轚";s:2:"ôà";s:3:"é‚";s:2:"ôá";s:3:"é…ƒ";s:2:"ôâ";s:3:"é…";s:2:"ôã";s:3:"醷";s:2:"ôä";s:3:"醵";s:2:"ôå";s:3:"醲";s:2:"ôæ";s:3:"醳";s:2:"ôç";s:3:"é‹";s:2:"ôè";s:3:"é“";s:2:"ôé";s:3:"é»";s:2:"ôê";s:3:"é ";s:2:"ôë";s:3:"é";s:2:"ôì";s:3:"é”";s:2:"ôí";s:3:"é¾";s:2:"ôî";s:3:"é•";s:2:"ôï";s:3:"é";s:2:"ôð";s:3:"é¨";s:2:"ôñ";s:3:"é™";s:2:"ôò";s:3:"é";s:2:"ôó";s:3:"éµ";s:2:"ôô";s:3:"é€";s:2:"ôõ";s:3:"é·";s:2:"ôö";s:3:"é‡";s:2:"ô÷";s:3:"éŽ";s:2:"ôø";s:3:"é–";s:2:"ôù";s:3:"é’";s:2:"ôú";s:3:"éº";s:2:"ôû";s:3:"é‰";s:2:"ôü";s:3:"é¸";s:2:"ôý";s:3:"éŠ";s:2:"ôþ";s:3:"é¿";s:2:"õ@";s:3:"é¼";s:2:"õA";s:3:"éŒ";s:2:"õB";s:3:"é¶";s:2:"õC";s:3:"é‘";s:2:"õD";s:3:"é†";s:2:"õE";s:3:"é—ž";s:2:"õF";s:3:"é— ";s:2:"õG";s:3:"é—Ÿ";s:2:"õH";s:3:"霮";s:2:"õI";s:3:"霯";s:2:"õJ";s:3:"éž¹";s:2:"õK";s:3:"éž»";s:2:"õL";s:3:"韽";s:2:"õM";s:3:"韾";s:2:"õN";s:3:"é¡ ";s:2:"õO";s:3:"é¡¢";s:2:"õP";s:3:"é¡£";s:2:"õQ";s:3:"é¡Ÿ";s:2:"õR";s:3:"é£";s:2:"õS";s:3:"飂";s:2:"õT";s:3:"é¥";s:2:"õU";s:3:"饎";s:2:"õV";s:3:"饙";s:2:"õW";s:3:"饌";s:2:"õX";s:3:"饋";s:2:"õY";s:3:"饓";s:2:"õZ";s:3:"騲";s:2:"õ[";s:3:"騴";s:2:"õ\";s:3:"騱";s:2:"õ]";s:3:"騬";s:2:"õ^";s:3:"騪";s:2:"õ_";s:3:"騶";s:2:"õ`";s:3:"騩";s:2:"õa";s:3:"騮";s:2:"õb";s:3:"騸";s:2:"õc";s:3:"騭";s:2:"õd";s:3:"髇";s:2:"õe";s:3:"é«Š";s:2:"õf";s:3:"髆";s:2:"õg";s:3:"é¬";s:2:"õh";s:3:"鬒";s:2:"õi";s:3:"鬑";s:2:"õj";s:3:"é°‹";s:2:"õk";s:3:"é°ˆ";s:2:"õl";s:3:"鯷";s:2:"õm";s:3:"é°…";s:2:"õn";s:3:"é°’";s:2:"õo";s:3:"鯸";s:2:"õp";s:3:"é±€";s:2:"õq";s:3:"é°‡";s:2:"õr";s:3:"é°Ž";s:2:"õs";s:3:"é°†";s:2:"õt";s:3:"é°—";s:2:"õu";s:3:"é°”";s:2:"õv";s:3:"é°‰";s:2:"õw";s:3:"鶟";s:2:"õx";s:3:"鶙";s:2:"õy";s:3:"鶤";s:2:"õz";s:3:"é¶";s:2:"õ{";s:3:"鶒";s:2:"õ|";s:3:"鶘";s:2:"õ}";s:3:"é¶";s:2:"õ~";s:3:"鶛";s:2:"õ¡";s:3:"鶠";s:2:"õ¢";s:3:"鶔";s:2:"õ£";s:3:"鶜";s:2:"õ¤";s:3:"鶪";s:2:"õ¥";s:3:"鶗";s:2:"õ¦";s:3:"鶡";s:2:"õ§";s:3:"鶚";s:2:"õ¨";s:3:"鶢";s:2:"õ©";s:3:"鶨";s:2:"õª";s:3:"鶞";s:2:"õ«";s:3:"鶣";s:2:"õ¬";s:3:"鶿";s:2:"õ­";s:3:"鶩";s:2:"õ®";s:3:"鶖";s:2:"õ¯";s:3:"鶦";s:2:"õ°";s:3:"鶧";s:2:"õ±";s:3:"麙";s:2:"õ²";s:3:"麛";s:2:"õ³";s:3:"麚";s:2:"õ´";s:3:"黥";s:2:"õµ";s:3:"黤";s:2:"õ¶";s:3:"黧";s:2:"õ·";s:3:"黦";s:2:"õ¸";s:3:"é¼°";s:2:"õ¹";s:3:"é¼®";s:2:"õº";s:3:"é½›";s:2:"õ»";s:3:"é½ ";s:2:"õ¼";s:3:"齞";s:2:"õ½";s:3:"é½";s:2:"õ¾";s:3:"é½™";s:2:"õ¿";s:3:"龑";s:2:"õÀ";s:3:"儺";s:2:"õÁ";s:3:"儹";s:2:"õÂ";s:3:"劘";s:2:"õÃ";s:3:"劗";s:2:"õÄ";s:3:"囃";s:2:"õÅ";s:3:"åš½";s:2:"õÆ";s:3:"åš¾";s:2:"õÇ";s:3:"å­ˆ";s:2:"õÈ";s:3:"å­‡";s:2:"õÉ";s:3:"å·‹";s:2:"õÊ";s:3:"å·";s:2:"õË";s:3:"å»±";s:2:"õÌ";s:3:"懽";s:2:"õÍ";s:3:"æ”›";s:2:"õÎ";s:3:"欂";s:2:"õÏ";s:3:"櫼";s:2:"õÐ";s:3:"欃";s:2:"õÑ";s:3:"櫸";s:2:"õÒ";s:3:"欀";s:2:"õÓ";s:3:"çƒ";s:2:"õÔ";s:3:"ç„";s:2:"õÕ";s:3:"çŠ";s:2:"õÖ";s:3:"çˆ";s:2:"õ×";s:3:"ç‰";s:2:"õØ";s:3:"ç…";s:2:"õÙ";s:3:"ç†";s:2:"õÚ";s:3:"çˆ";s:2:"õÛ";s:3:"爚";s:2:"õÜ";s:3:"爙";s:2:"õÝ";s:3:"ç¾";s:2:"õÞ";s:3:"ç”—";s:2:"õß";s:3:"癪";s:2:"õà";s:3:"çŸ";s:2:"õá";s:3:"礭";s:2:"õâ";s:3:"礱";s:2:"õã";s:3:"礯";s:2:"õä";s:3:"ç±”";s:2:"õå";s:3:"籓";s:2:"õæ";s:3:"ç³²";s:2:"õç";s:3:"纊";s:2:"õè";s:3:"纇";s:2:"õé";s:3:"纈";s:2:"õê";s:3:"纋";s:2:"õë";s:3:"纆";s:2:"õì";s:3:"çº";s:2:"õí";s:3:"ç½";s:2:"õî";s:3:"ç¾»";s:2:"õï";s:3:"耰";s:2:"õð";s:3:"è‡";s:2:"õñ";s:3:"蘘";s:2:"õò";s:3:"蘪";s:2:"õó";s:3:"蘦";s:2:"õô";s:3:"蘟";s:2:"õõ";s:3:"蘣";s:2:"õö";s:3:"蘜";s:2:"õ÷";s:3:"蘙";s:2:"õø";s:3:"蘧";s:2:"õù";s:3:"蘮";s:2:"õú";s:3:"蘡";s:2:"õû";s:3:"蘠";s:2:"õü";s:3:"蘩";s:2:"õý";s:3:"蘞";s:2:"õþ";s:3:"蘥";s:2:"ö@";s:3:"è ©";s:2:"öA";s:3:"è ";s:2:"öB";s:3:"è ›";s:2:"öC";s:3:"è  ";s:2:"öD";s:3:"è ¤";s:2:"öE";s:3:"è œ";s:2:"öF";s:3:"è «";s:2:"öG";s:3:"è¡Š";s:2:"öH";s:3:"襭";s:2:"öI";s:3:"襩";s:2:"öJ";s:3:"襮";s:2:"öK";s:3:"襫";s:2:"öL";s:3:"觺";s:2:"öM";s:3:"è­¹";s:2:"öN";s:3:"è­¸";s:2:"öO";s:3:"è­…";s:2:"öP";s:3:"è­º";s:2:"öQ";s:3:"è­»";s:2:"öR";s:3:"è´";s:2:"öS";s:3:"è´”";s:2:"öT";s:3:"趯";s:2:"öU";s:3:"躎";s:2:"öV";s:3:"躌";s:2:"öW";s:3:"轞";s:2:"öX";s:3:"è½›";s:2:"öY";s:3:"è½";s:2:"öZ";s:3:"é…†";s:2:"ö[";s:3:"é…„";s:2:"ö\";s:3:"é……";s:2:"ö]";s:3:"醹";s:2:"ö^";s:3:"é¿";s:2:"ö_";s:3:"é»";s:2:"ö`";s:3:"é¶";s:2:"öa";s:3:"é©";s:2:"öb";s:3:"é½";s:2:"öc";s:3:"é¼";s:2:"öd";s:3:"é°";s:2:"öe";s:3:"é¹";s:2:"öf";s:3:"éª";s:2:"ög";s:3:"é·";s:2:"öh";s:3:"é¬";s:2:"öi";s:3:"é‘€";s:2:"öj";s:3:"é±";s:2:"ök";s:3:"é—¥";s:2:"öl";s:3:"é—¤";s:2:"öm";s:3:"é—£";s:2:"ön";s:3:"霵";s:2:"öo";s:3:"霺";s:2:"öp";s:3:"éž¿";s:2:"öq";s:3:"韡";s:2:"ör";s:3:"顤";s:2:"ös";s:3:"飉";s:2:"öt";s:3:"飆";s:2:"öu";s:3:"飀";s:2:"öv";s:3:"饘";s:2:"öw";s:3:"饖";s:2:"öx";s:3:"騹";s:2:"öy";s:3:"騽";s:2:"öz";s:3:"驆";s:2:"ö{";s:3:"é©„";s:2:"ö|";s:3:"é©‚";s:2:"ö}";s:3:"é©";s:2:"ö~";s:3:"騺";s:2:"ö¡";s:3:"騿";s:2:"ö¢";s:3:"é«";s:2:"ö£";s:3:"鬕";s:2:"ö¤";s:3:"鬗";s:2:"ö¥";s:3:"鬘";s:2:"ö¦";s:3:"鬖";s:2:"ö§";s:3:"鬺";s:2:"ö¨";s:3:"é­’";s:2:"ö©";s:3:"é°«";s:2:"öª";s:3:"é°";s:2:"ö«";s:3:"é°œ";s:2:"ö¬";s:3:"é°¬";s:2:"ö­";s:3:"é°£";s:2:"ö®";s:3:"é°¨";s:2:"ö¯";s:3:"é°©";s:2:"ö°";s:3:"é°¤";s:2:"ö±";s:3:"é°¡";s:2:"ö²";s:3:"鶷";s:2:"ö³";s:3:"鶶";s:2:"ö´";s:3:"鶼";s:2:"öµ";s:3:"é·";s:2:"ö¶";s:3:"é·‡";s:2:"ö·";s:3:"é·Š";s:2:"ö¸";s:3:"é·";s:2:"ö¹";s:3:"鶾";s:2:"öº";s:3:"é·…";s:2:"ö»";s:3:"é·ƒ";s:2:"ö¼";s:3:"鶻";s:2:"ö½";s:3:"鶵";s:2:"ö¾";s:3:"é·Ž";s:2:"ö¿";s:3:"鶹";s:2:"öÀ";s:3:"鶺";s:2:"öÁ";s:3:"鶬";s:2:"öÂ";s:3:"é·ˆ";s:2:"öÃ";s:3:"鶱";s:2:"öÄ";s:3:"鶭";s:2:"öÅ";s:3:"é·Œ";s:2:"öÆ";s:3:"鶳";s:2:"öÇ";s:3:"é·";s:2:"öÈ";s:3:"鶲";s:2:"öÉ";s:3:"鹺";s:2:"öÊ";s:3:"麜";s:2:"öË";s:3:"黫";s:2:"öÌ";s:3:"é»®";s:2:"öÍ";s:3:"é»­";s:2:"öÎ";s:3:"é¼›";s:2:"öÏ";s:3:"鼘";s:2:"öÐ";s:3:"鼚";s:2:"öÑ";s:3:"é¼±";s:2:"öÒ";s:3:"齎";s:2:"öÓ";s:3:"é½¥";s:2:"öÔ";s:3:"齤";s:2:"öÕ";s:3:"é¾’";s:2:"öÖ";s:3:"亹";s:2:"ö×";s:3:"囆";s:2:"öØ";s:3:"å›…";s:2:"öÙ";s:3:"囋";s:2:"öÚ";s:3:"奱";s:2:"öÛ";s:3:"å­‹";s:2:"öÜ";s:3:"å­Œ";s:2:"öÝ";s:3:"å·•";s:2:"öÞ";s:3:"å·‘";s:2:"öß";s:3:"廲";s:2:"öà";s:3:"攡";s:2:"öá";s:3:"æ” ";s:2:"öâ";s:3:"攦";s:2:"öã";s:3:"攢";s:2:"öä";s:3:"欋";s:2:"öå";s:3:"欈";s:2:"öæ";s:3:"欉";s:2:"öç";s:3:"æ°";s:2:"öè";s:3:"ç•";s:2:"öé";s:3:"ç–";s:2:"öê";s:3:"ç—";s:2:"öë";s:3:"ç’";s:2:"öì";s:3:"爞";s:2:"öí";s:3:"爟";s:2:"öî";s:3:"犩";s:2:"öï";s:3:"ç¿";s:2:"öð";s:3:"瓘";s:2:"öñ";s:3:"ç“•";s:2:"öò";s:3:"ç“™";s:2:"öó";s:3:"ç“—";s:2:"öô";s:3:"ç™­";s:2:"öõ";s:3:"çš­";s:2:"öö";s:3:"礵";s:2:"ö÷";s:3:"禴";s:2:"öø";s:3:"ç©°";s:2:"öù";s:3:"穱";s:2:"öú";s:3:"ç±—";s:2:"öû";s:3:"籜";s:2:"öü";s:3:"ç±™";s:2:"öý";s:3:"ç±›";s:2:"öþ";s:3:"籚";s:2:"÷@";s:3:"ç³´";s:2:"÷A";s:3:"ç³±";s:2:"÷B";s:3:"纑";s:2:"÷C";s:3:"ç½";s:2:"÷D";s:3:"羇";s:2:"÷E";s:3:"臞";s:2:"÷F";s:3:"艫";s:2:"÷G";s:3:"蘴";s:2:"÷H";s:3:"蘵";s:2:"÷I";s:3:"蘳";s:2:"÷J";s:3:"蘬";s:2:"÷K";s:3:"蘲";s:2:"÷L";s:3:"蘶";s:2:"÷M";s:3:"è ¬";s:2:"÷N";s:3:"è ¨";s:2:"÷O";s:3:"è ¦";s:2:"÷P";s:3:"è ª";s:2:"÷Q";s:3:"è ¥";s:2:"÷R";s:3:"襱";s:2:"÷S";s:3:"覿";s:2:"÷T";s:3:"覾";s:2:"÷U";s:3:"觻";s:2:"÷V";s:3:"è­¾";s:2:"÷W";s:3:"讄";s:2:"÷X";s:3:"讂";s:2:"÷Y";s:3:"讆";s:2:"÷Z";s:3:"è®…";s:2:"÷[";s:3:"è­¿";s:2:"÷\";s:3:"è´•";s:2:"÷]";s:3:"躕";s:2:"÷^";s:3:"躔";s:2:"÷_";s:3:"躚";s:2:"÷`";s:3:"躒";s:2:"÷a";s:3:"èº";s:2:"÷b";s:3:"躖";s:2:"÷c";s:3:"躗";s:2:"÷d";s:3:"è½ ";s:2:"÷e";s:3:"è½¢";s:2:"÷f";s:3:"é…‡";s:2:"÷g";s:3:"é‘Œ";s:2:"÷h";s:3:"é‘";s:2:"÷i";s:3:"é‘Š";s:2:"÷j";s:3:"é‘‹";s:2:"÷k";s:3:"é‘";s:2:"÷l";s:3:"鑇";s:2:"÷m";s:3:"é‘…";s:2:"÷n";s:3:"鑈";s:2:"÷o";s:3:"鑉";s:2:"÷p";s:3:"鑆";s:2:"÷q";s:3:"霿";s:2:"÷r";s:3:"韣";s:2:"÷s";s:3:"顪";s:2:"÷t";s:3:"é¡©";s:2:"÷u";s:3:"飋";s:2:"÷v";s:3:"饔";s:2:"÷w";s:3:"饛";s:2:"÷x";s:3:"é©Ž";s:2:"÷y";s:3:"é©“";s:2:"÷z";s:3:"é©”";s:2:"÷{";s:3:"é©Œ";s:2:"÷|";s:3:"é©";s:2:"÷}";s:3:"驈";s:2:"÷~";s:3:"é©Š";s:2:"÷¡";s:3:"驉";s:2:"÷¢";s:3:"é©’";s:2:"÷£";s:3:"é©";s:2:"÷¤";s:3:"é«";s:2:"÷¥";s:3:"鬙";s:2:"÷¦";s:3:"鬫";s:2:"÷§";s:3:"鬻";s:2:"÷¨";s:3:"é­–";s:2:"÷©";s:3:"é­•";s:2:"÷ª";s:3:"鱆";s:2:"÷«";s:3:"鱈";s:2:"÷¬";s:3:"é°¿";s:2:"÷­";s:3:"鱄";s:2:"÷®";s:3:"é°¹";s:2:"÷¯";s:3:"é°³";s:2:"÷°";s:3:"é±";s:2:"÷±";s:3:"é°¼";s:2:"÷²";s:3:"é°·";s:2:"÷³";s:3:"é°´";s:2:"÷´";s:3:"é°²";s:2:"÷µ";s:3:"é°½";s:2:"÷¶";s:3:"é°¶";s:2:"÷·";s:3:"é·›";s:2:"÷¸";s:3:"é·’";s:2:"÷¹";s:3:"é·ž";s:2:"÷º";s:3:"é·š";s:2:"÷»";s:3:"é·‹";s:2:"÷¼";s:3:"é·";s:2:"÷½";s:3:"é·œ";s:2:"÷¾";s:3:"é·‘";s:2:"÷¿";s:3:"é·Ÿ";s:2:"÷À";s:3:"é·©";s:2:"÷Á";s:3:"é·™";s:2:"÷Â";s:3:"é·˜";s:2:"÷Ã";s:3:"é·–";s:2:"÷Ä";s:3:"é·µ";s:2:"÷Å";s:3:"é·•";s:2:"÷Æ";s:3:"é·";s:2:"÷Ç";s:3:"麶";s:2:"÷È";s:3:"é»°";s:2:"÷É";s:3:"é¼µ";s:2:"÷Ê";s:3:"é¼³";s:2:"÷Ë";s:3:"é¼²";s:2:"÷Ì";s:3:"齂";s:2:"÷Í";s:3:"齫";s:2:"÷Î";s:3:"龕";s:2:"÷Ï";s:3:"é¾¢";s:2:"÷Ð";s:3:"儽";s:2:"÷Ñ";s:3:"劙";s:2:"÷Ò";s:3:"壨";s:2:"÷Ó";s:3:"壧";s:2:"÷Ô";s:3:"奲";s:2:"÷Õ";s:3:"å­";s:2:"÷Ö";s:3:"å·˜";s:2:"÷×";s:3:"è ¯";s:2:"÷Ø";s:3:"å½";s:2:"÷Ù";s:3:"æˆ";s:2:"÷Ú";s:3:"戃";s:2:"÷Û";s:3:"戄";s:2:"÷Ü";s:3:"攩";s:2:"÷Ý";s:3:"攥";s:2:"÷Þ";s:3:"æ––";s:2:"÷ß";s:3:"曫";s:2:"÷à";s:3:"欑";s:2:"÷á";s:3:"欒";s:2:"÷â";s:3:"æ¬";s:2:"÷ã";s:3:"毊";s:2:"÷ä";s:3:"ç›";s:2:"÷å";s:3:"çš";s:2:"÷æ";s:3:"爢";s:2:"÷ç";s:3:"玂";s:2:"÷è";s:3:"çŽ";s:2:"÷é";s:3:"玃";s:2:"÷ê";s:3:"ç™°";s:2:"÷ë";s:3:"矔";s:2:"÷ì";s:3:"籧";s:2:"÷í";s:3:"籦";s:2:"÷î";s:3:"纕";s:2:"÷ï";s:3:"艬";s:2:"÷ð";s:3:"蘺";s:2:"÷ñ";s:3:"虀";s:2:"÷ò";s:3:"蘹";s:2:"÷ó";s:3:"蘼";s:2:"÷ô";s:3:"蘱";s:2:"÷õ";s:3:"蘻";s:2:"÷ö";s:3:"蘾";s:2:"÷÷";s:3:"è °";s:2:"÷ø";s:3:"è ²";s:2:"÷ù";s:3:"è ®";s:2:"÷ú";s:3:"è ³";s:2:"÷û";s:3:"襶";s:2:"÷ü";s:3:"襴";s:2:"÷ý";s:3:"襳";s:2:"÷þ";s:3:"觾";s:2:"ø@";s:3:"讌";s:2:"øA";s:3:"讎";s:2:"øB";s:3:"讋";s:2:"øC";s:3:"讈";s:2:"øD";s:3:"è±…";s:2:"øE";s:3:"è´™";s:2:"øF";s:3:"躘";s:2:"øG";s:3:"轤";s:2:"øH";s:3:"è½£";s:2:"øI";s:3:"醼";s:2:"øJ";s:3:"é‘¢";s:2:"øK";s:3:"é‘•";s:2:"øL";s:3:"é‘";s:2:"øM";s:3:"é‘—";s:2:"øN";s:3:"é‘ž";s:2:"øO";s:3:"韄";s:2:"øP";s:3:"韅";s:2:"øQ";s:3:"é €";s:2:"øR";s:3:"é©–";s:2:"øS";s:3:"é©™";s:2:"øT";s:3:"鬞";s:2:"øU";s:3:"鬟";s:2:"øV";s:3:"鬠";s:2:"øW";s:3:"é±’";s:2:"øX";s:3:"鱘";s:2:"øY";s:3:"é±";s:2:"øZ";s:3:"鱊";s:2:"ø[";s:3:"é±";s:2:"ø\";s:3:"鱋";s:2:"ø]";s:3:"鱕";s:2:"ø^";s:3:"é±™";s:2:"ø_";s:3:"鱌";s:2:"ø`";s:3:"鱎";s:2:"øa";s:3:"é·»";s:2:"øb";s:3:"é··";s:2:"øc";s:3:"é·¯";s:2:"ød";s:3:"é·£";s:2:"øe";s:3:"é·«";s:2:"øf";s:3:"é·¸";s:2:"øg";s:3:"é·¤";s:2:"øh";s:3:"é·¶";s:2:"øi";s:3:"é·¡";s:2:"øj";s:3:"é·®";s:2:"øk";s:3:"é·¦";s:2:"øl";s:3:"é·²";s:2:"øm";s:3:"é·°";s:2:"øn";s:3:"é·¢";s:2:"øo";s:3:"é·¬";s:2:"øp";s:3:"é·´";s:2:"øq";s:3:"é·³";s:2:"ør";s:3:"é·¨";s:2:"øs";s:3:"é·­";s:2:"øt";s:3:"黂";s:2:"øu";s:3:"é»";s:2:"øv";s:3:"黲";s:2:"øw";s:3:"黳";s:2:"øx";s:3:"鼆";s:2:"øy";s:3:"鼜";s:2:"øz";s:3:"鼸";s:2:"ø{";s:3:"é¼·";s:2:"ø|";s:3:"鼶";s:2:"ø}";s:3:"齃";s:2:"ø~";s:3:"é½";s:2:"ø¡";s:3:"é½±";s:2:"ø¢";s:3:"é½°";s:2:"ø£";s:3:"é½®";s:2:"ø¤";s:3:"齯";s:2:"ø¥";s:3:"囓";s:2:"ø¦";s:3:"å›";s:2:"ø§";s:3:"å­Ž";s:2:"ø¨";s:3:"å±­";s:2:"ø©";s:3:"æ”­";s:2:"øª";s:3:"æ›­";s:2:"ø«";s:3:"æ›®";s:2:"ø¬";s:3:"欓";s:2:"ø­";s:3:"çŸ";s:2:"ø®";s:3:"ç¡";s:2:"ø¯";s:3:"ç";s:2:"ø°";s:3:"ç ";s:2:"ø±";s:3:"爣";s:2:"ø²";s:3:"ç“›";s:2:"ø³";s:3:"ç“¥";s:2:"ø´";s:3:"矕";s:2:"øµ";s:3:"礸";s:2:"ø¶";s:3:"禷";s:2:"ø·";s:3:"禶";s:2:"ø¸";s:3:"籪";s:2:"ø¹";s:3:"纗";s:2:"øº";s:3:"羉";s:2:"ø»";s:3:"艭";s:2:"ø¼";s:3:"虃";s:2:"ø½";s:3:"è ¸";s:2:"ø¾";s:3:"è ·";s:2:"ø¿";s:3:"è µ";s:2:"øÀ";s:3:"è¡‹";s:2:"øÁ";s:3:"è®”";s:2:"øÂ";s:3:"讕";s:2:"øÃ";s:3:"躞";s:2:"øÄ";s:3:"躟";s:2:"øÅ";s:3:"躠";s:2:"øÆ";s:3:"èº";s:2:"øÇ";s:3:"醾";s:2:"øÈ";s:3:"醽";s:2:"øÉ";s:3:"釂";s:2:"øÊ";s:3:"é‘«";s:2:"øË";s:3:"鑨";s:2:"øÌ";s:3:"é‘©";s:2:"øÍ";s:3:"雥";s:2:"øÎ";s:3:"é†";s:2:"øÏ";s:3:"éƒ";s:2:"øÐ";s:3:"é‡";s:2:"øÑ";s:3:"韇";s:2:"øÒ";s:3:"韥";s:2:"øÓ";s:3:"é©ž";s:2:"øÔ";s:3:"é«•";s:2:"øÕ";s:3:"é­™";s:2:"øÖ";s:3:"é±£";s:2:"ø×";s:3:"鱧";s:2:"øØ";s:3:"鱦";s:2:"øÙ";s:3:"é±¢";s:2:"øÚ";s:3:"鱞";s:2:"øÛ";s:3:"é± ";s:2:"øÜ";s:3:"鸂";s:2:"øÝ";s:3:"é·¾";s:2:"øÞ";s:3:"鸇";s:2:"øß";s:3:"鸃";s:2:"øà";s:3:"鸆";s:2:"øá";s:3:"鸅";s:2:"øâ";s:3:"鸀";s:2:"øã";s:3:"é¸";s:2:"øä";s:3:"鸉";s:2:"øå";s:3:"é·¿";s:2:"øæ";s:3:"é·½";s:2:"øç";s:3:"鸄";s:2:"øè";s:3:"麠";s:2:"øé";s:3:"鼞";s:2:"øê";s:3:"齆";s:2:"øë";s:3:"é½´";s:2:"øì";s:3:"é½µ";s:2:"øí";s:3:"齶";s:2:"øî";s:3:"å›”";s:2:"øï";s:3:"æ”®";s:2:"øð";s:3:"æ–¸";s:2:"øñ";s:3:"欘";s:2:"øò";s:3:"欙";s:2:"øó";s:3:"欗";s:2:"øô";s:3:"欚";s:2:"øõ";s:3:"ç¢";s:2:"øö";s:3:"爦";s:2:"ø÷";s:3:"犪";s:2:"øø";s:3:"矘";s:2:"øù";s:3:"矙";s:2:"øú";s:3:"礹";s:2:"øû";s:3:"籩";s:2:"øü";s:3:"籫";s:2:"øý";s:3:"糶";s:2:"øþ";s:3:"纚";s:2:"ù@";s:3:"纘";s:2:"ùA";s:3:"纛";s:2:"ùB";s:3:"纙";s:2:"ùC";s:3:"臠";s:2:"ùD";s:3:"臡";s:2:"ùE";s:3:"虆";s:2:"ùF";s:3:"虇";s:2:"ùG";s:3:"虈";s:2:"ùH";s:3:"襹";s:2:"ùI";s:3:"襺";s:2:"ùJ";s:3:"襼";s:2:"ùK";s:3:"襻";s:2:"ùL";s:3:"觿";s:2:"ùM";s:3:"讘";s:2:"ùN";s:3:"è®™";s:2:"ùO";s:3:"躥";s:2:"ùP";s:3:"躤";s:2:"ùQ";s:3:"躣";s:2:"ùR";s:3:"é‘®";s:2:"ùS";s:3:"é‘­";s:2:"ùT";s:3:"鑯";s:2:"ùU";s:3:"鑱";s:2:"ùV";s:3:"鑳";s:2:"ùW";s:3:"é‰";s:2:"ùX";s:3:"顲";s:2:"ùY";s:3:"饟";s:2:"ùZ";s:3:"鱨";s:2:"ù[";s:3:"é±®";s:2:"ù\";s:3:"é±­";s:2:"ù]";s:3:"鸋";s:2:"ù^";s:3:"é¸";s:2:"ù_";s:3:"é¸";s:2:"ù`";s:3:"é¸";s:2:"ùa";s:3:"鸒";s:2:"ùb";s:3:"鸑";s:2:"ùc";s:3:"麡";s:2:"ùd";s:3:"黵";s:2:"ùe";s:3:"鼉";s:2:"ùf";s:3:"齇";s:2:"ùg";s:3:"齸";s:2:"ùh";s:3:"é½»";s:2:"ùi";s:3:"齺";s:2:"ùj";s:3:"é½¹";s:2:"ùk";s:3:"圞";s:2:"ùl";s:3:"ç¦";s:2:"ùm";s:3:"籯";s:2:"ùn";s:3:"è ¼";s:2:"ùo";s:3:"趲";s:2:"ùp";s:3:"躦";s:2:"ùq";s:3:"釃";s:2:"ùr";s:3:"é‘´";s:2:"ùs";s:3:"鑸";s:2:"ùt";s:3:"鑶";s:2:"ùu";s:3:"鑵";s:2:"ùv";s:3:"é© ";s:2:"ùw";s:3:"é±´";s:2:"ùx";s:3:"é±³";s:2:"ùy";s:3:"é±±";s:2:"ùz";s:3:"é±µ";s:2:"ù{";s:3:"鸔";s:2:"ù|";s:3:"鸓";s:2:"ù}";s:3:"黶";s:2:"ù~";s:3:"鼊";s:2:"ù¡";s:3:"龤";s:2:"ù¢";s:3:"ç¨";s:2:"ù£";s:3:"ç¥";s:2:"ù¤";s:3:"ç³·";s:2:"ù¥";s:3:"虪";s:2:"ù¦";s:3:"è ¾";s:2:"ù§";s:3:"è ½";s:2:"ù¨";s:3:"è ¿";s:2:"ù©";s:3:"讞";s:2:"ùª";s:3:"貜";s:2:"ù«";s:3:"躩";s:2:"ù¬";s:3:"軉";s:2:"ù­";s:3:"é‹";s:2:"ù®";s:3:"顳";s:2:"ù¯";s:3:"é¡´";s:2:"ù°";s:3:"飌";s:2:"ù±";s:3:"饡";s:2:"ù²";s:3:"馫";s:2:"ù³";s:3:"驤";s:2:"ù´";s:3:"驦";s:2:"ùµ";s:3:"驧";s:2:"ù¶";s:3:"鬤";s:2:"ù·";s:3:"鸕";s:2:"ù¸";s:3:"鸗";s:2:"ù¹";s:3:"齈";s:2:"ùº";s:3:"戇";s:2:"ù»";s:3:"欞";s:2:"ù¼";s:3:"爧";s:2:"ù½";s:3:"虌";s:2:"ù¾";s:3:"躨";s:2:"ù¿";s:3:"é’‚";s:2:"ùÀ";s:3:"é’€";s:2:"ùÁ";s:3:"é’";s:2:"ùÂ";s:3:"é©©";s:2:"ùÃ";s:3:"驨";s:2:"ùÄ";s:3:"鬮";s:2:"ùÅ";s:3:"鸙";s:2:"ùÆ";s:3:"爩";s:2:"ùÇ";s:3:"虋";s:2:"ùÈ";s:3:"讟";s:2:"ùÉ";s:3:"é’ƒ";s:2:"ùÊ";s:3:"é±¹";s:2:"ùË";s:3:"麷";s:2:"ùÌ";s:3:"癵";s:2:"ùÍ";s:3:"é©«";s:2:"ùÎ";s:3:"鱺";s:2:"ùÏ";s:3:"é¸";s:2:"ùÐ";s:3:"ç©";s:2:"ùÑ";s:3:"çª";s:2:"ùÒ";s:3:"麤";s:2:"ùÓ";s:3:"é½¾";s:2:"ùÔ";s:3:"齉";s:2:"ùÕ";s:3:"龘";}
    \ No newline at end of file
    diff --git a/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.cp037.ser b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.cp037.ser
    new file mode 100755
    index 0000000..a629eb4
    Binary files /dev/null and b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.cp037.ser differ
    diff --git a/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.cp1006.ser b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.cp1006.ser
    new file mode 100755
    index 0000000..d3a6c4c
    Binary files /dev/null and b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.cp1006.ser differ
    diff --git a/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.cp1026.ser b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.cp1026.ser
    new file mode 100755
    index 0000000..8ec9bea
    Binary files /dev/null and b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.cp1026.ser differ
    diff --git a/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.cp424.ser b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.cp424.ser
    new file mode 100755
    index 0000000..5e1168e
    Binary files /dev/null and b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.cp424.ser differ
    diff --git a/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.cp437.ser b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.cp437.ser
    new file mode 100755
    index 0000000..aa20fd8
    Binary files /dev/null and b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.cp437.ser differ
    diff --git a/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.cp500.ser b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.cp500.ser
    new file mode 100755
    index 0000000..9bdfdfb
    Binary files /dev/null and b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.cp500.ser differ
    diff --git a/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.cp737.ser b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.cp737.ser
    new file mode 100755
    index 0000000..d586ac9
    Binary files /dev/null and b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.cp737.ser differ
    diff --git a/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.cp775.ser b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.cp775.ser
    new file mode 100755
    index 0000000..c993ef5
    Binary files /dev/null and b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.cp775.ser differ
    diff --git a/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.cp850.ser b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.cp850.ser
    new file mode 100755
    index 0000000..8035a91
    Binary files /dev/null and b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.cp850.ser differ
    diff --git a/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.cp852.ser b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.cp852.ser
    new file mode 100755
    index 0000000..83d6b3c
    Binary files /dev/null and b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.cp852.ser differ
    diff --git a/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.cp855.ser b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.cp855.ser
    new file mode 100755
    index 0000000..2b99b4c
    Binary files /dev/null and b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.cp855.ser differ
    diff --git a/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.cp856.ser b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.cp856.ser
    new file mode 100755
    index 0000000..bcc21fe
    Binary files /dev/null and b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.cp856.ser differ
    diff --git a/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.cp857.ser b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.cp857.ser
    new file mode 100755
    index 0000000..a7074a4
    Binary files /dev/null and b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.cp857.ser differ
    diff --git a/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.cp860.ser b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.cp860.ser
    new file mode 100755
    index 0000000..848d9fe
    Binary files /dev/null and b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.cp860.ser differ
    diff --git a/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.cp861.ser b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.cp861.ser
    new file mode 100755
    index 0000000..e0469a6
    Binary files /dev/null and b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.cp861.ser differ
    diff --git a/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.cp862.ser b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.cp862.ser
    new file mode 100755
    index 0000000..eabcebf
    Binary files /dev/null and b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.cp862.ser differ
    diff --git a/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.cp863.ser b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.cp863.ser
    new file mode 100755
    index 0000000..a64d70a
    Binary files /dev/null and b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.cp863.ser differ
    diff --git a/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.cp864.ser b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.cp864.ser
    new file mode 100755
    index 0000000..1d9c371
    Binary files /dev/null and b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.cp864.ser differ
    diff --git a/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.cp865.ser b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.cp865.ser
    new file mode 100755
    index 0000000..816ddf3
    Binary files /dev/null and b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.cp865.ser differ
    diff --git a/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.cp866.ser b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.cp866.ser
    new file mode 100755
    index 0000000..8e0f7dc
    Binary files /dev/null and b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.cp866.ser differ
    diff --git a/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.cp869.ser b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.cp869.ser
    new file mode 100755
    index 0000000..32de1f2
    Binary files /dev/null and b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.cp869.ser differ
    diff --git a/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.cp874.ser b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.cp874.ser
    new file mode 100755
    index 0000000..030ce15
    Binary files /dev/null and b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.cp874.ser differ
    diff --git a/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.cp875.ser b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.cp875.ser
    new file mode 100755
    index 0000000..e42792a
    Binary files /dev/null and b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.cp875.ser differ
    diff --git a/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.cp932.ser b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.cp932.ser
    new file mode 100755
    index 0000000..5861d4c
    Binary files /dev/null and b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.cp932.ser differ
    diff --git a/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.cp936.ser b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.cp936.ser
    new file mode 100755
    index 0000000..8fc183b
    Binary files /dev/null and b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.cp936.ser differ
    diff --git a/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.cp949.ser b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.cp949.ser
    new file mode 100755
    index 0000000..4447cdb
    Binary files /dev/null and b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.cp949.ser differ
    diff --git a/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.cp950.ser b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.cp950.ser
    new file mode 100755
    index 0000000..b2f11df
    Binary files /dev/null and b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.cp950.ser differ
    diff --git a/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.gsm0338.ser b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.gsm0338.ser
    new file mode 100755
    index 0000000..a877b83
    Binary files /dev/null and b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.gsm0338.ser differ
    diff --git a/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.iso-8859-1.ser b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.iso-8859-1.ser
    new file mode 100755
    index 0000000..5fecd4c
    Binary files /dev/null and b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.iso-8859-1.ser differ
    diff --git a/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.iso-8859-10.ser b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.iso-8859-10.ser
    new file mode 100755
    index 0000000..3f0cce1
    Binary files /dev/null and b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.iso-8859-10.ser differ
    diff --git a/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.iso-8859-11.ser b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.iso-8859-11.ser
    new file mode 100755
    index 0000000..2757b1c
    Binary files /dev/null and b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.iso-8859-11.ser differ
    diff --git a/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.iso-8859-13.ser b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.iso-8859-13.ser
    new file mode 100755
    index 0000000..55a7a3e
    Binary files /dev/null and b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.iso-8859-13.ser differ
    diff --git a/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.iso-8859-14.ser b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.iso-8859-14.ser
    new file mode 100755
    index 0000000..7b963ae
    Binary files /dev/null and b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.iso-8859-14.ser differ
    diff --git a/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.iso-8859-15.ser b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.iso-8859-15.ser
    new file mode 100755
    index 0000000..2ce20a1
    Binary files /dev/null and b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.iso-8859-15.ser differ
    diff --git a/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.iso-8859-16.ser b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.iso-8859-16.ser
    new file mode 100755
    index 0000000..8da2482
    Binary files /dev/null and b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.iso-8859-16.ser differ
    diff --git a/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.iso-8859-2.ser b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.iso-8859-2.ser
    new file mode 100755
    index 0000000..7dbeb25
    Binary files /dev/null and b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.iso-8859-2.ser differ
    diff --git a/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.iso-8859-3.ser b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.iso-8859-3.ser
    new file mode 100755
    index 0000000..626fffe
    Binary files /dev/null and b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.iso-8859-3.ser differ
    diff --git a/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.iso-8859-4.ser b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.iso-8859-4.ser
    new file mode 100755
    index 0000000..f750169
    Binary files /dev/null and b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.iso-8859-4.ser differ
    diff --git a/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.iso-8859-5.ser b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.iso-8859-5.ser
    new file mode 100755
    index 0000000..d89cc06
    Binary files /dev/null and b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.iso-8859-5.ser differ
    diff --git a/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.iso-8859-6.ser b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.iso-8859-6.ser
    new file mode 100755
    index 0000000..2dcfeb8
    Binary files /dev/null and b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.iso-8859-6.ser differ
    diff --git a/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.iso-8859-7.ser b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.iso-8859-7.ser
    new file mode 100755
    index 0000000..a137558
    Binary files /dev/null and b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.iso-8859-7.ser differ
    diff --git a/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.iso-8859-8.ser b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.iso-8859-8.ser
    new file mode 100755
    index 0000000..4179e15
    Binary files /dev/null and b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.iso-8859-8.ser differ
    diff --git a/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.iso-8859-9.ser b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.iso-8859-9.ser
    new file mode 100755
    index 0000000..be4c816
    Binary files /dev/null and b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.iso-8859-9.ser differ
    diff --git a/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.koi8-r.ser b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.koi8-r.ser
    new file mode 100755
    index 0000000..c46860b
    Binary files /dev/null and b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.koi8-r.ser differ
    diff --git a/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.koi8-u.ser b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.koi8-u.ser
    new file mode 100755
    index 0000000..6e5af63
    Binary files /dev/null and b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.koi8-u.ser differ
    diff --git a/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.mazovia.ser b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.mazovia.ser
    new file mode 100755
    index 0000000..05fa2bd
    Binary files /dev/null and b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.mazovia.ser differ
    diff --git a/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.nextstep.ser b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.nextstep.ser
    new file mode 100755
    index 0000000..476da9c
    Binary files /dev/null and b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.nextstep.ser differ
    diff --git a/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.stdenc.ser b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.stdenc.ser
    new file mode 100755
    index 0000000..81edeb0
    --- /dev/null
    +++ b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.stdenc.ser
    @@ -0,0 +1 @@
    +a:149:{s:1:" ";s:1:" ";s:1:"!";s:1:"!";s:1:""";s:1:""";s:1:"#";s:1:"#";s:1:"$";s:1:"$";s:1:"%";s:1:"%";s:1:"&";s:1:"&";s:1:"'";s:3:"’";s:1:"(";s:1:"(";s:1:")";s:1:")";s:1:"*";s:1:"*";s:1:"+";s:1:"+";s:1:",";s:1:",";s:1:"-";s:1:"-";s:1:".";s:1:".";s:1:"/";s:1:"/";i:0;s:1:"0";i:1;s:1:"1";i:2;s:1:"2";i:3;s:1:"3";i:4;s:1:"4";i:5;s:1:"5";i:6;s:1:"6";i:7;s:1:"7";i:8;s:1:"8";i:9;s:1:"9";s:1:":";s:1:":";s:1:";";s:1:";";s:1:"<";s:1:"<";s:1:"=";s:1:"=";s:1:">";s:1:">";s:1:"?";s:1:"?";s:1:"@";s:1:"@";s:1:"A";s:1:"A";s:1:"B";s:1:"B";s:1:"C";s:1:"C";s:1:"D";s:1:"D";s:1:"E";s:1:"E";s:1:"F";s:1:"F";s:1:"G";s:1:"G";s:1:"H";s:1:"H";s:1:"I";s:1:"I";s:1:"J";s:1:"J";s:1:"K";s:1:"K";s:1:"L";s:1:"L";s:1:"M";s:1:"M";s:1:"N";s:1:"N";s:1:"O";s:1:"O";s:1:"P";s:1:"P";s:1:"Q";s:1:"Q";s:1:"R";s:1:"R";s:1:"S";s:1:"S";s:1:"T";s:1:"T";s:1:"U";s:1:"U";s:1:"V";s:1:"V";s:1:"W";s:1:"W";s:1:"X";s:1:"X";s:1:"Y";s:1:"Y";s:1:"Z";s:1:"Z";s:1:"[";s:1:"[";s:1:"\";s:1:"\";s:1:"]";s:1:"]";s:1:"^";s:1:"^";s:1:"_";s:1:"_";s:1:"`";s:3:"‘";s:1:"a";s:1:"a";s:1:"b";s:1:"b";s:1:"c";s:1:"c";s:1:"d";s:1:"d";s:1:"e";s:1:"e";s:1:"f";s:1:"f";s:1:"g";s:1:"g";s:1:"h";s:1:"h";s:1:"i";s:1:"i";s:1:"j";s:1:"j";s:1:"k";s:1:"k";s:1:"l";s:1:"l";s:1:"m";s:1:"m";s:1:"n";s:1:"n";s:1:"o";s:1:"o";s:1:"p";s:1:"p";s:1:"q";s:1:"q";s:1:"r";s:1:"r";s:1:"s";s:1:"s";s:1:"t";s:1:"t";s:1:"u";s:1:"u";s:1:"v";s:1:"v";s:1:"w";s:1:"w";s:1:"x";s:1:"x";s:1:"y";s:1:"y";s:1:"z";s:1:"z";s:1:"{";s:1:"{";s:1:"|";s:1:"|";s:1:"}";s:1:"}";s:1:"~";s:1:"~";s:1:"¡";s:2:"¡";s:1:"¢";s:2:"¢";s:1:"£";s:2:"£";s:1:"¤";s:3:"â„";s:1:"¥";s:2:"Â¥";s:1:"¦";s:2:"Æ’";s:1:"§";s:2:"§";s:1:"¨";s:2:"¤";s:1:"©";s:1:"'";s:1:"ª";s:3:"“";s:1:"«";s:2:"«";s:1:"¬";s:3:"‹";s:1:"­";s:3:"›";s:1:"®";s:3:"ï¬";s:1:"¯";s:3:"fl";s:1:"±";s:3:"–";s:1:"²";s:3:"†";s:1:"³";s:3:"‡";s:1:"´";s:2:"·";s:1:"¶";s:2:"¶";s:1:"·";s:3:"•";s:1:"¸";s:3:"‚";s:1:"¹";s:3:"„";s:1:"º";s:3:"â€";s:1:"»";s:2:"»";s:1:"¼";s:3:"…";s:1:"½";s:3:"‰";s:1:"¿";s:2:"¿";s:1:"Á";s:1:"`";s:1:"Â";s:2:"´";s:1:"Ã";s:2:"ˆ";s:1:"Ä";s:2:"Ëœ";s:1:"Å";s:2:"¯";s:1:"Æ";s:2:"˘";s:1:"Ç";s:2:"Ë™";s:1:"È";s:2:"¨";s:1:"Ê";s:2:"Ëš";s:1:"Ë";s:2:"¸";s:1:"Í";s:2:"Ë";s:1:"Î";s:2:"Ë›";s:1:"Ï";s:2:"ˇ";s:1:"Ð";s:3:"—";s:1:"á";s:2:"Æ";s:1:"ã";s:2:"ª";s:1:"è";s:2:"Å";s:1:"é";s:2:"Ø";s:1:"ê";s:2:"Å’";s:1:"ë";s:2:"º";s:1:"ñ";s:2:"æ";s:1:"õ";s:2:"ı";s:1:"ø";s:2:"Å‚";s:1:"ù";s:2:"ø";s:1:"ú";s:2:"Å“";s:1:"û";s:2:"ß";}
    \ No newline at end of file
    diff --git a/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.symbol.ser b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.symbol.ser
    new file mode 100755
    index 0000000..889217b
    --- /dev/null
    +++ b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.symbol.ser
    @@ -0,0 +1 @@
    +a:189:{s:1:" ";s:1:" ";s:1:"!";s:1:"!";s:1:""";s:3:"∀";s:1:"#";s:1:"#";s:1:"$";s:3:"∃";s:1:"%";s:1:"%";s:1:"&";s:1:"&";s:1:"'";s:3:"∋";s:1:"(";s:1:"(";s:1:")";s:1:")";s:1:"*";s:3:"∗";s:1:"+";s:1:"+";s:1:",";s:1:",";s:1:"-";s:3:"−";s:1:".";s:1:".";s:1:"/";s:1:"/";i:0;s:1:"0";i:1;s:1:"1";i:2;s:1:"2";i:3;s:1:"3";i:4;s:1:"4";i:5;s:1:"5";i:6;s:1:"6";i:7;s:1:"7";i:8;s:1:"8";i:9;s:1:"9";s:1:":";s:1:":";s:1:";";s:1:";";s:1:"<";s:1:"<";s:1:"=";s:1:"=";s:1:">";s:1:">";s:1:"?";s:1:"?";s:1:"@";s:3:"≅";s:1:"A";s:2:"Α";s:1:"B";s:2:"Î’";s:1:"C";s:2:"Χ";s:1:"D";s:2:"Δ";s:1:"E";s:2:"Ε";s:1:"F";s:2:"Φ";s:1:"G";s:2:"Γ";s:1:"H";s:2:"Η";s:1:"I";s:2:"Ι";s:1:"J";s:2:"Ï‘";s:1:"K";s:2:"Κ";s:1:"L";s:2:"Λ";s:1:"M";s:2:"Îœ";s:1:"N";s:2:"Î";s:1:"O";s:2:"Ο";s:1:"P";s:2:"Π";s:1:"Q";s:2:"Θ";s:1:"R";s:2:"Ρ";s:1:"S";s:2:"Σ";s:1:"T";s:2:"Τ";s:1:"U";s:2:"Î¥";s:1:"V";s:2:"Ï‚";s:1:"W";s:2:"Ω";s:1:"X";s:2:"Ξ";s:1:"Y";s:2:"Ψ";s:1:"Z";s:2:"Ζ";s:1:"[";s:1:"[";s:1:"\";s:3:"∴";s:1:"]";s:1:"]";s:1:"^";s:3:"⊥";s:1:"_";s:1:"_";s:1:"`";s:3:"";s:1:"a";s:2:"α";s:1:"b";s:2:"β";s:1:"c";s:2:"χ";s:1:"d";s:2:"δ";s:1:"e";s:2:"ε";s:1:"f";s:2:"φ";s:1:"g";s:2:"γ";s:1:"h";s:2:"η";s:1:"i";s:2:"ι";s:1:"j";s:2:"Ï•";s:1:"k";s:2:"κ";s:1:"l";s:2:"λ";s:1:"m";s:2:"µ";s:1:"n";s:2:"ν";s:1:"o";s:2:"ο";s:1:"p";s:2:"Ï€";s:1:"q";s:2:"θ";s:1:"r";s:2:"Ï";s:1:"s";s:2:"σ";s:1:"t";s:2:"Ï„";s:1:"u";s:2:"Ï…";s:1:"v";s:2:"Ï–";s:1:"w";s:2:"ω";s:1:"x";s:2:"ξ";s:1:"y";s:2:"ψ";s:1:"z";s:2:"ζ";s:1:"{";s:1:"{";s:1:"|";s:1:"|";s:1:"}";s:1:"}";s:1:"~";s:3:"∼";s:1:" ";s:3:"€";s:1:"¡";s:2:"Ï’";s:1:"¢";s:3:"′";s:1:"£";s:3:"≤";s:1:"¤";s:3:"â„";s:1:"¥";s:3:"∞";s:1:"¦";s:2:"Æ’";s:1:"§";s:3:"♣";s:1:"¨";s:3:"♦";s:1:"©";s:3:"♥";s:1:"ª";s:3:"â™ ";s:1:"«";s:3:"↔";s:1:"¬";s:3:"â†";s:1:"­";s:3:"↑";s:1:"®";s:3:"→";s:1:"¯";s:3:"↓";s:1:"°";s:2:"°";s:1:"±";s:2:"±";s:1:"²";s:3:"″";s:1:"³";s:3:"≥";s:1:"´";s:2:"×";s:1:"µ";s:3:"âˆ";s:1:"¶";s:3:"∂";s:1:"·";s:3:"•";s:1:"¸";s:2:"÷";s:1:"¹";s:3:"≠";s:1:"º";s:3:"≡";s:1:"»";s:3:"≈";s:1:"¼";s:3:"…";s:1:"½";s:3:"";s:1:"¾";s:3:"";s:1:"¿";s:3:"↵";s:1:"À";s:3:"ℵ";s:1:"Á";s:3:"â„‘";s:1:"Â";s:3:"â„œ";s:1:"Ã";s:3:"℘";s:1:"Ä";s:3:"⊗";s:1:"Å";s:3:"⊕";s:1:"Æ";s:3:"∅";s:1:"Ç";s:3:"∩";s:1:"È";s:3:"∪";s:1:"É";s:3:"⊃";s:1:"Ê";s:3:"⊇";s:1:"Ë";s:3:"⊄";s:1:"Ì";s:3:"⊂";s:1:"Í";s:3:"⊆";s:1:"Î";s:3:"∈";s:1:"Ï";s:3:"∉";s:1:"Ð";s:3:"∠";s:1:"Ñ";s:3:"∇";s:1:"Ò";s:3:"";s:1:"Ó";s:3:"ï›™";s:1:"Ô";s:3:"ï››";s:1:"Õ";s:3:"âˆ";s:1:"Ö";s:3:"√";s:1:"×";s:3:"â‹…";s:1:"Ø";s:2:"¬";s:1:"Ù";s:3:"∧";s:1:"Ú";s:3:"∨";s:1:"Û";s:3:"⇔";s:1:"Ü";s:3:"â‡";s:1:"Ý";s:3:"⇑";s:1:"Þ";s:3:"⇒";s:1:"ß";s:3:"⇓";s:1:"à";s:3:"â—Š";s:1:"á";s:3:"〈";s:1:"â";s:3:"";s:1:"ã";s:3:"";s:1:"ä";s:3:"";s:1:"å";s:3:"∑";s:1:"æ";s:3:"";s:1:"ç";s:3:"";s:1:"è";s:3:"";s:1:"é";s:3:"";s:1:"ê";s:3:"";s:1:"ë";s:3:"";s:1:"ì";s:3:"";s:1:"í";s:3:"";s:1:"î";s:3:"";s:1:"ï";s:3:"";s:1:"ñ";s:3:"〉";s:1:"ò";s:3:"∫";s:1:"ó";s:3:"⌠";s:1:"ô";s:3:"";s:1:"õ";s:3:"⌡";s:1:"ö";s:3:"";s:1:"÷";s:3:"";s:1:"ø";s:3:"";s:1:"ù";s:3:"";s:1:"ú";s:3:"";s:1:"û";s:3:"";s:1:"ü";s:3:"";s:1:"ý";s:3:"";s:1:"þ";s:3:"";}
    \ No newline at end of file
    diff --git a/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.turkish.ser b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.turkish.ser
    new file mode 100755
    index 0000000..a3651e6
    Binary files /dev/null and b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.turkish.ser differ
    diff --git a/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.us-ascii-quotes.ser b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.us-ascii-quotes.ser
    new file mode 100755
    index 0000000..f10af33
    Binary files /dev/null and b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.us-ascii-quotes.ser differ
    diff --git a/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.us-ascii.ser b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.us-ascii.ser
    new file mode 100755
    index 0000000..3a2f7e4
    Binary files /dev/null and b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.us-ascii.ser differ
    diff --git a/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.windows-1250.ser b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.windows-1250.ser
    new file mode 100755
    index 0000000..9e799cb
    Binary files /dev/null and b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.windows-1250.ser differ
    diff --git a/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.windows-1251.ser b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.windows-1251.ser
    new file mode 100755
    index 0000000..6592885
    Binary files /dev/null and b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.windows-1251.ser differ
    diff --git a/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.windows-1252.ser b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.windows-1252.ser
    new file mode 100755
    index 0000000..cccc26c
    Binary files /dev/null and b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.windows-1252.ser differ
    diff --git a/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.windows-1253.ser b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.windows-1253.ser
    new file mode 100755
    index 0000000..13c5a0b
    Binary files /dev/null and b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.windows-1253.ser differ
    diff --git a/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.windows-1254.ser b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.windows-1254.ser
    new file mode 100755
    index 0000000..96d6972
    Binary files /dev/null and b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.windows-1254.ser differ
    diff --git a/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.windows-1255.ser b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.windows-1255.ser
    new file mode 100755
    index 0000000..c366bfd
    Binary files /dev/null and b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.windows-1255.ser differ
    diff --git a/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.windows-1256.ser b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.windows-1256.ser
    new file mode 100755
    index 0000000..cc98d2c
    Binary files /dev/null and b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.windows-1256.ser differ
    diff --git a/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.windows-1257.ser b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.windows-1257.ser
    new file mode 100755
    index 0000000..2a52206
    Binary files /dev/null and b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.windows-1257.ser differ
    diff --git a/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.windows-1258.ser b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.windows-1258.ser
    new file mode 100755
    index 0000000..114dd84
    Binary files /dev/null and b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.windows-1258.ser differ
    diff --git a/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.x-mac-ce.ser b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.x-mac-ce.ser
    new file mode 100755
    index 0000000..246603d
    Binary files /dev/null and b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.x-mac-ce.ser differ
    diff --git a/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.x-mac-cyrillic.ser b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.x-mac-cyrillic.ser
    new file mode 100755
    index 0000000..3f606d6
    Binary files /dev/null and b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.x-mac-cyrillic.ser differ
    diff --git a/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.x-mac-greek.ser b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.x-mac-greek.ser
    new file mode 100755
    index 0000000..c4b66d9
    Binary files /dev/null and b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.x-mac-greek.ser differ
    diff --git a/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.x-mac-icelandic.ser b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.x-mac-icelandic.ser
    new file mode 100755
    index 0000000..15b35b1
    Binary files /dev/null and b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.x-mac-icelandic.ser differ
    diff --git a/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.x-mac-roman.ser b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.x-mac-roman.ser
    new file mode 100755
    index 0000000..a39e96a
    Binary files /dev/null and b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.x-mac-roman.ser differ
    diff --git a/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.zdingbat.ser b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.zdingbat.ser
    new file mode 100755
    index 0000000..3a894d2
    --- /dev/null
    +++ b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/from.zdingbat.ser
    @@ -0,0 +1 @@
    +a:202:{s:1:" ";s:1:" ";s:1:"!";s:3:"âœ";s:1:""";s:3:"✂";s:1:"#";s:3:"✃";s:1:"$";s:3:"✄";s:1:"%";s:3:"☎";s:1:"&";s:3:"✆";s:1:"'";s:3:"✇";s:1:"(";s:3:"✈";s:1:")";s:3:"✉";s:1:"*";s:3:"☛";s:1:"+";s:3:"☞";s:1:",";s:3:"✌";s:1:"-";s:3:"âœ";s:1:".";s:3:"✎";s:1:"/";s:3:"âœ";i:0;s:3:"âœ";i:1;s:3:"✑";i:2;s:3:"✒";i:3;s:3:"✓";i:4;s:3:"✔";i:5;s:3:"✕";i:6;s:3:"✖";i:7;s:3:"✗";i:8;s:3:"✘";i:9;s:3:"✙";s:1:":";s:3:"✚";s:1:";";s:3:"✛";s:1:"<";s:3:"✜";s:1:"=";s:3:"âœ";s:1:">";s:3:"✞";s:1:"?";s:3:"✟";s:1:"@";s:3:"✠";s:1:"A";s:3:"✡";s:1:"B";s:3:"✢";s:1:"C";s:3:"✣";s:1:"D";s:3:"✤";s:1:"E";s:3:"✥";s:1:"F";s:3:"✦";s:1:"G";s:3:"✧";s:1:"H";s:3:"★";s:1:"I";s:3:"✩";s:1:"J";s:3:"✪";s:1:"K";s:3:"✫";s:1:"L";s:3:"✬";s:1:"M";s:3:"✭";s:1:"N";s:3:"✮";s:1:"O";s:3:"✯";s:1:"P";s:3:"✰";s:1:"Q";s:3:"✱";s:1:"R";s:3:"✲";s:1:"S";s:3:"✳";s:1:"T";s:3:"✴";s:1:"U";s:3:"✵";s:1:"V";s:3:"✶";s:1:"W";s:3:"✷";s:1:"X";s:3:"✸";s:1:"Y";s:3:"✹";s:1:"Z";s:3:"✺";s:1:"[";s:3:"✻";s:1:"\";s:3:"✼";s:1:"]";s:3:"✽";s:1:"^";s:3:"✾";s:1:"_";s:3:"✿";s:1:"`";s:3:"â€";s:1:"a";s:3:"â";s:1:"b";s:3:"â‚";s:1:"c";s:3:"âƒ";s:1:"d";s:3:"â„";s:1:"e";s:3:"â…";s:1:"f";s:3:"â†";s:1:"g";s:3:"â‡";s:1:"h";s:3:"âˆ";s:1:"i";s:3:"â‰";s:1:"j";s:3:"âŠ";s:1:"k";s:3:"â‹";s:1:"l";s:3:"â—";s:1:"m";s:3:"â";s:1:"n";s:3:"â– ";s:1:"o";s:3:"â";s:1:"p";s:3:"â";s:1:"q";s:3:"â‘";s:1:"r";s:3:"â’";s:1:"s";s:3:"â–²";s:1:"t";s:3:"â–¼";s:1:"u";s:3:"â—†";s:1:"v";s:3:"â–";s:1:"w";s:3:"â——";s:1:"x";s:3:"â˜";s:1:"y";s:3:"â™";s:1:"z";s:3:"âš";s:1:"{";s:3:"â›";s:1:"|";s:3:"âœ";s:1:"}";s:3:"â";s:1:"~";s:3:"âž";s:1:"€";s:3:"";s:1:"";s:3:"";s:1:"‚";s:3:"";s:1:"ƒ";s:3:"";s:1:"„";s:3:"";s:1:"…";s:3:"";s:1:"†";s:3:"ï£";s:1:"‡";s:3:"";s:1:"ˆ";s:3:"";s:1:"‰";s:3:"";s:1:"Š";s:3:"";s:1:"‹";s:3:"";s:1:"Œ";s:3:"";s:1:"";s:3:"";s:1:"¡";s:3:"â¡";s:1:"¢";s:3:"â¢";s:1:"£";s:3:"â£";s:1:"¤";s:3:"â¤";s:1:"¥";s:3:"â¥";s:1:"¦";s:3:"â¦";s:1:"§";s:3:"â§";s:1:"¨";s:3:"♣";s:1:"©";s:3:"♦";s:1:"ª";s:3:"♥";s:1:"«";s:3:"â™ ";s:1:"¬";s:3:"â‘ ";s:1:"­";s:3:"â‘¡";s:1:"®";s:3:"â‘¢";s:1:"¯";s:3:"â‘£";s:1:"°";s:3:"⑤";s:1:"±";s:3:"â‘¥";s:1:"²";s:3:"⑦";s:1:"³";s:3:"⑧";s:1:"´";s:3:"⑨";s:1:"µ";s:3:"â‘©";s:1:"¶";s:3:"â¶";s:1:"·";s:3:"â·";s:1:"¸";s:3:"â¸";s:1:"¹";s:3:"â¹";s:1:"º";s:3:"âº";s:1:"»";s:3:"â»";s:1:"¼";s:3:"â¼";s:1:"½";s:3:"â½";s:1:"¾";s:3:"â¾";s:1:"¿";s:3:"â¿";s:1:"À";s:3:"➀";s:1:"Á";s:3:"âž";s:1:"Â";s:3:"âž‚";s:1:"Ã";s:3:"➃";s:1:"Ä";s:3:"âž„";s:1:"Å";s:3:"âž…";s:1:"Æ";s:3:"➆";s:1:"Ç";s:3:"➇";s:1:"È";s:3:"➈";s:1:"É";s:3:"➉";s:1:"Ê";s:3:"➊";s:1:"Ë";s:3:"âž‹";s:1:"Ì";s:3:"➌";s:1:"Í";s:3:"âž";s:1:"Î";s:3:"➎";s:1:"Ï";s:3:"âž";s:1:"Ð";s:3:"âž";s:1:"Ñ";s:3:"âž‘";s:1:"Ò";s:3:"âž’";s:1:"Ó";s:3:"âž“";s:1:"Ô";s:3:"âž”";s:1:"Õ";s:3:"→";s:1:"Ö";s:3:"↔";s:1:"×";s:3:"↕";s:1:"Ø";s:3:"➘";s:1:"Ù";s:3:"âž™";s:1:"Ú";s:3:"âžš";s:1:"Û";s:3:"âž›";s:1:"Ü";s:3:"âžœ";s:1:"Ý";s:3:"âž";s:1:"Þ";s:3:"âžž";s:1:"ß";s:3:"➟";s:1:"à";s:3:"âž ";s:1:"á";s:3:"âž¡";s:1:"â";s:3:"➢";s:1:"ã";s:3:"➣";s:1:"ä";s:3:"➤";s:1:"å";s:3:"➥";s:1:"æ";s:3:"➦";s:1:"ç";s:3:"➧";s:1:"è";s:3:"➨";s:1:"é";s:3:"âž©";s:1:"ê";s:3:"➪";s:1:"ë";s:3:"âž«";s:1:"ì";s:3:"➬";s:1:"í";s:3:"âž­";s:1:"î";s:3:"âž®";s:1:"ï";s:3:"➯";s:1:"ñ";s:3:"âž±";s:1:"ò";s:3:"âž²";s:1:"ó";s:3:"âž³";s:1:"ô";s:3:"âž´";s:1:"õ";s:3:"âžµ";s:1:"ö";s:3:"➶";s:1:"÷";s:3:"âž·";s:1:"ø";s:3:"➸";s:1:"ù";s:3:"âž¹";s:1:"ú";s:3:"➺";s:1:"û";s:3:"âž»";s:1:"ü";s:3:"âž¼";s:1:"ý";s:3:"âž½";s:1:"þ";s:3:"âž¾";}
    \ No newline at end of file
    diff --git a/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/to.gsm0338.ser b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/to.gsm0338.ser
    new file mode 100755
    index 0000000..e675fc3
    Binary files /dev/null and b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/to.gsm0338.ser differ
    diff --git a/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/to.mazovia.ser b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/to.mazovia.ser
    new file mode 100755
    index 0000000..70a534f
    Binary files /dev/null and b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/to.mazovia.ser differ
    diff --git a/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/to.stdenc.ser b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/to.stdenc.ser
    new file mode 100755
    index 0000000..0cb4628
    --- /dev/null
    +++ b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/to.stdenc.ser
    @@ -0,0 +1 @@
    +a:154:{s:2:" ";s:1:" ";s:2:"­";s:1:"-";s:3:"∕";s:1:"¤";s:3:"∙";s:1:"´";s:2:"ˉ";s:1:"Å";s:1:" ";s:1:" ";s:1:"!";s:1:"!";s:1:""";s:1:""";s:1:"#";s:1:"#";s:1:"$";s:1:"$";s:1:"%";s:1:"%";s:1:"&";s:1:"&";s:3:"’";s:1:"'";s:1:"(";s:1:"(";s:1:")";s:1:")";s:1:"*";s:1:"*";s:1:"+";s:1:"+";s:1:",";s:1:",";s:1:"-";s:1:"-";s:1:".";s:1:".";s:1:"/";s:1:"/";i:0;i:0;i:1;i:1;i:2;i:2;i:3;i:3;i:4;i:4;i:5;i:5;i:6;i:6;i:7;i:7;i:8;i:8;i:9;i:9;s:1:":";s:1:":";s:1:";";s:1:";";s:1:"<";s:1:"<";s:1:"=";s:1:"=";s:1:">";s:1:">";s:1:"?";s:1:"?";s:1:"@";s:1:"@";s:1:"A";s:1:"A";s:1:"B";s:1:"B";s:1:"C";s:1:"C";s:1:"D";s:1:"D";s:1:"E";s:1:"E";s:1:"F";s:1:"F";s:1:"G";s:1:"G";s:1:"H";s:1:"H";s:1:"I";s:1:"I";s:1:"J";s:1:"J";s:1:"K";s:1:"K";s:1:"L";s:1:"L";s:1:"M";s:1:"M";s:1:"N";s:1:"N";s:1:"O";s:1:"O";s:1:"P";s:1:"P";s:1:"Q";s:1:"Q";s:1:"R";s:1:"R";s:1:"S";s:1:"S";s:1:"T";s:1:"T";s:1:"U";s:1:"U";s:1:"V";s:1:"V";s:1:"W";s:1:"W";s:1:"X";s:1:"X";s:1:"Y";s:1:"Y";s:1:"Z";s:1:"Z";s:1:"[";s:1:"[";s:1:"\";s:1:"\";s:1:"]";s:1:"]";s:1:"^";s:1:"^";s:1:"_";s:1:"_";s:3:"‘";s:1:"`";s:1:"a";s:1:"a";s:1:"b";s:1:"b";s:1:"c";s:1:"c";s:1:"d";s:1:"d";s:1:"e";s:1:"e";s:1:"f";s:1:"f";s:1:"g";s:1:"g";s:1:"h";s:1:"h";s:1:"i";s:1:"i";s:1:"j";s:1:"j";s:1:"k";s:1:"k";s:1:"l";s:1:"l";s:1:"m";s:1:"m";s:1:"n";s:1:"n";s:1:"o";s:1:"o";s:1:"p";s:1:"p";s:1:"q";s:1:"q";s:1:"r";s:1:"r";s:1:"s";s:1:"s";s:1:"t";s:1:"t";s:1:"u";s:1:"u";s:1:"v";s:1:"v";s:1:"w";s:1:"w";s:1:"x";s:1:"x";s:1:"y";s:1:"y";s:1:"z";s:1:"z";s:1:"{";s:1:"{";s:1:"|";s:1:"|";s:1:"}";s:1:"}";s:1:"~";s:1:"~";s:2:"¡";s:1:"¡";s:2:"¢";s:1:"¢";s:2:"£";s:1:"£";s:3:"â„";s:1:"¤";s:2:"Â¥";s:1:"¥";s:2:"Æ’";s:1:"¦";s:2:"§";s:1:"§";s:2:"¤";s:1:"¨";s:1:"'";s:1:"©";s:3:"“";s:1:"ª";s:2:"«";s:1:"«";s:3:"‹";s:1:"¬";s:3:"›";s:1:"­";s:3:"ï¬";s:1:"®";s:3:"fl";s:1:"¯";s:3:"–";s:1:"±";s:3:"†";s:1:"²";s:3:"‡";s:1:"³";s:2:"·";s:1:"´";s:2:"¶";s:1:"¶";s:3:"•";s:1:"·";s:3:"‚";s:1:"¸";s:3:"„";s:1:"¹";s:3:"â€";s:1:"º";s:2:"»";s:1:"»";s:3:"…";s:1:"¼";s:3:"‰";s:1:"½";s:2:"¿";s:1:"¿";s:1:"`";s:1:"Á";s:2:"´";s:1:"Â";s:2:"ˆ";s:1:"Ã";s:2:"Ëœ";s:1:"Ä";s:2:"¯";s:1:"Å";s:2:"˘";s:1:"Æ";s:2:"Ë™";s:1:"Ç";s:2:"¨";s:1:"È";s:2:"Ëš";s:1:"Ê";s:2:"¸";s:1:"Ë";s:2:"Ë";s:1:"Í";s:2:"Ë›";s:1:"Î";s:2:"ˇ";s:1:"Ï";s:3:"—";s:1:"Ð";s:2:"Æ";s:1:"á";s:2:"ª";s:1:"ã";s:2:"Å";s:1:"è";s:2:"Ø";s:1:"é";s:2:"Å’";s:1:"ê";s:2:"º";s:1:"ë";s:2:"æ";s:1:"ñ";s:2:"ı";s:1:"õ";s:2:"Å‚";s:1:"ø";s:2:"ø";s:1:"ù";s:2:"Å“";s:1:"ú";s:2:"ß";s:1:"û";}
    \ No newline at end of file
    diff --git a/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/to.symbol.ser b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/to.symbol.ser
    new file mode 100755
    index 0000000..fc61505
    --- /dev/null
    +++ b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/to.symbol.ser
    @@ -0,0 +1 @@
    +a:194:{s:2:" ";s:1:" ";s:3:"∆";s:1:"D";s:3:"Ω";s:1:"W";s:2:"μ";s:1:"m";s:3:"∕";s:1:"¤";s:1:" ";s:1:" ";s:1:"!";s:1:"!";s:3:"∀";s:1:""";s:1:"#";s:1:"#";s:3:"∃";s:1:"$";s:1:"%";s:1:"%";s:1:"&";s:1:"&";s:3:"∋";s:1:"'";s:1:"(";s:1:"(";s:1:")";s:1:")";s:3:"∗";s:1:"*";s:1:"+";s:1:"+";s:1:",";s:1:",";s:3:"−";s:1:"-";s:1:".";s:1:".";s:1:"/";s:1:"/";i:0;i:0;i:1;i:1;i:2;i:2;i:3;i:3;i:4;i:4;i:5;i:5;i:6;i:6;i:7;i:7;i:8;i:8;i:9;i:9;s:1:":";s:1:":";s:1:";";s:1:";";s:1:"<";s:1:"<";s:1:"=";s:1:"=";s:1:">";s:1:">";s:1:"?";s:1:"?";s:3:"≅";s:1:"@";s:2:"Α";s:1:"A";s:2:"Î’";s:1:"B";s:2:"Χ";s:1:"C";s:2:"Δ";s:1:"D";s:2:"Ε";s:1:"E";s:2:"Φ";s:1:"F";s:2:"Γ";s:1:"G";s:2:"Η";s:1:"H";s:2:"Ι";s:1:"I";s:2:"Ï‘";s:1:"J";s:2:"Κ";s:1:"K";s:2:"Λ";s:1:"L";s:2:"Îœ";s:1:"M";s:2:"Î";s:1:"N";s:2:"Ο";s:1:"O";s:2:"Π";s:1:"P";s:2:"Θ";s:1:"Q";s:2:"Ρ";s:1:"R";s:2:"Σ";s:1:"S";s:2:"Τ";s:1:"T";s:2:"Î¥";s:1:"U";s:2:"Ï‚";s:1:"V";s:2:"Ω";s:1:"W";s:2:"Ξ";s:1:"X";s:2:"Ψ";s:1:"Y";s:2:"Ζ";s:1:"Z";s:1:"[";s:1:"[";s:3:"∴";s:1:"\";s:1:"]";s:1:"]";s:3:"⊥";s:1:"^";s:1:"_";s:1:"_";s:3:"";s:1:"`";s:2:"α";s:1:"a";s:2:"β";s:1:"b";s:2:"χ";s:1:"c";s:2:"δ";s:1:"d";s:2:"ε";s:1:"e";s:2:"φ";s:1:"f";s:2:"γ";s:1:"g";s:2:"η";s:1:"h";s:2:"ι";s:1:"i";s:2:"Ï•";s:1:"j";s:2:"κ";s:1:"k";s:2:"λ";s:1:"l";s:2:"µ";s:1:"m";s:2:"ν";s:1:"n";s:2:"ο";s:1:"o";s:2:"Ï€";s:1:"p";s:2:"θ";s:1:"q";s:2:"Ï";s:1:"r";s:2:"σ";s:1:"s";s:2:"Ï„";s:1:"t";s:2:"Ï…";s:1:"u";s:2:"Ï–";s:1:"v";s:2:"ω";s:1:"w";s:2:"ξ";s:1:"x";s:2:"ψ";s:1:"y";s:2:"ζ";s:1:"z";s:1:"{";s:1:"{";s:1:"|";s:1:"|";s:1:"}";s:1:"}";s:3:"∼";s:1:"~";s:3:"€";s:1:" ";s:2:"Ï’";s:1:"¡";s:3:"′";s:1:"¢";s:3:"≤";s:1:"£";s:3:"â„";s:1:"¤";s:3:"∞";s:1:"¥";s:2:"Æ’";s:1:"¦";s:3:"♣";s:1:"§";s:3:"♦";s:1:"¨";s:3:"♥";s:1:"©";s:3:"â™ ";s:1:"ª";s:3:"↔";s:1:"«";s:3:"â†";s:1:"¬";s:3:"↑";s:1:"­";s:3:"→";s:1:"®";s:3:"↓";s:1:"¯";s:2:"°";s:1:"°";s:2:"±";s:1:"±";s:3:"″";s:1:"²";s:3:"≥";s:1:"³";s:2:"×";s:1:"´";s:3:"âˆ";s:1:"µ";s:3:"∂";s:1:"¶";s:3:"•";s:1:"·";s:2:"÷";s:1:"¸";s:3:"≠";s:1:"¹";s:3:"≡";s:1:"º";s:3:"≈";s:1:"»";s:3:"…";s:1:"¼";s:3:"";s:1:"½";s:3:"";s:1:"¾";s:3:"↵";s:1:"¿";s:3:"ℵ";s:1:"À";s:3:"â„‘";s:1:"Á";s:3:"â„œ";s:1:"Â";s:3:"℘";s:1:"Ã";s:3:"⊗";s:1:"Ä";s:3:"⊕";s:1:"Å";s:3:"∅";s:1:"Æ";s:3:"∩";s:1:"Ç";s:3:"∪";s:1:"È";s:3:"⊃";s:1:"É";s:3:"⊇";s:1:"Ê";s:3:"⊄";s:1:"Ë";s:3:"⊂";s:1:"Ì";s:3:"⊆";s:1:"Í";s:3:"∈";s:1:"Î";s:3:"∉";s:1:"Ï";s:3:"∠";s:1:"Ð";s:3:"∇";s:1:"Ñ";s:3:"";s:1:"Ò";s:3:"ï›™";s:1:"Ó";s:3:"ï››";s:1:"Ô";s:3:"âˆ";s:1:"Õ";s:3:"√";s:1:"Ö";s:3:"â‹…";s:1:"×";s:2:"¬";s:1:"Ø";s:3:"∧";s:1:"Ù";s:3:"∨";s:1:"Ú";s:3:"⇔";s:1:"Û";s:3:"â‡";s:1:"Ü";s:3:"⇑";s:1:"Ý";s:3:"⇒";s:1:"Þ";s:3:"⇓";s:1:"ß";s:3:"â—Š";s:1:"à";s:3:"〈";s:1:"á";s:3:"";s:1:"â";s:3:"";s:1:"ã";s:3:"";s:1:"ä";s:3:"∑";s:1:"å";s:3:"";s:1:"æ";s:3:"";s:1:"ç";s:3:"";s:1:"è";s:3:"";s:1:"é";s:3:"";s:1:"ê";s:3:"";s:1:"ë";s:3:"";s:1:"ì";s:3:"";s:1:"í";s:3:"";s:1:"î";s:3:"";s:1:"ï";s:3:"〉";s:1:"ñ";s:3:"∫";s:1:"ò";s:3:"⌠";s:1:"ó";s:3:"";s:1:"ô";s:3:"⌡";s:1:"õ";s:3:"";s:1:"ö";s:3:"";s:1:"÷";s:3:"";s:1:"ø";s:3:"";s:1:"ù";s:3:"";s:1:"ú";s:3:"";s:1:"û";s:3:"";s:1:"ü";s:3:"";s:1:"ý";s:3:"";s:1:"þ";}
    \ No newline at end of file
    diff --git a/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/to.zdingbat.ser b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/to.zdingbat.ser
    new file mode 100755
    index 0000000..1f293bf
    --- /dev/null
    +++ b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/to.zdingbat.ser
    @@ -0,0 +1 @@
    +a:203:{s:2:" ";s:1:" ";s:1:" ";s:1:" ";s:3:"âœ";s:1:"!";s:3:"✂";s:1:""";s:3:"✃";s:1:"#";s:3:"✄";s:1:"$";s:3:"☎";s:1:"%";s:3:"✆";s:1:"&";s:3:"✇";s:1:"'";s:3:"✈";s:1:"(";s:3:"✉";s:1:")";s:3:"☛";s:1:"*";s:3:"☞";s:1:"+";s:3:"✌";s:1:",";s:3:"âœ";s:1:"-";s:3:"✎";s:1:".";s:3:"âœ";s:1:"/";s:3:"âœ";i:0;s:3:"✑";i:1;s:3:"✒";i:2;s:3:"✓";i:3;s:3:"✔";i:4;s:3:"✕";i:5;s:3:"✖";i:6;s:3:"✗";i:7;s:3:"✘";i:8;s:3:"✙";i:9;s:3:"✚";s:1:":";s:3:"✛";s:1:";";s:3:"✜";s:1:"<";s:3:"âœ";s:1:"=";s:3:"✞";s:1:">";s:3:"✟";s:1:"?";s:3:"✠";s:1:"@";s:3:"✡";s:1:"A";s:3:"✢";s:1:"B";s:3:"✣";s:1:"C";s:3:"✤";s:1:"D";s:3:"✥";s:1:"E";s:3:"✦";s:1:"F";s:3:"✧";s:1:"G";s:3:"★";s:1:"H";s:3:"✩";s:1:"I";s:3:"✪";s:1:"J";s:3:"✫";s:1:"K";s:3:"✬";s:1:"L";s:3:"✭";s:1:"M";s:3:"✮";s:1:"N";s:3:"✯";s:1:"O";s:3:"✰";s:1:"P";s:3:"✱";s:1:"Q";s:3:"✲";s:1:"R";s:3:"✳";s:1:"S";s:3:"✴";s:1:"T";s:3:"✵";s:1:"U";s:3:"✶";s:1:"V";s:3:"✷";s:1:"W";s:3:"✸";s:1:"X";s:3:"✹";s:1:"Y";s:3:"✺";s:1:"Z";s:3:"✻";s:1:"[";s:3:"✼";s:1:"\";s:3:"✽";s:1:"]";s:3:"✾";s:1:"^";s:3:"✿";s:1:"_";s:3:"â€";s:1:"`";s:3:"â";s:1:"a";s:3:"â‚";s:1:"b";s:3:"âƒ";s:1:"c";s:3:"â„";s:1:"d";s:3:"â…";s:1:"e";s:3:"â†";s:1:"f";s:3:"â‡";s:1:"g";s:3:"âˆ";s:1:"h";s:3:"â‰";s:1:"i";s:3:"âŠ";s:1:"j";s:3:"â‹";s:1:"k";s:3:"â—";s:1:"l";s:3:"â";s:1:"m";s:3:"â– ";s:1:"n";s:3:"â";s:1:"o";s:3:"â";s:1:"p";s:3:"â‘";s:1:"q";s:3:"â’";s:1:"r";s:3:"â–²";s:1:"s";s:3:"â–¼";s:1:"t";s:3:"â—†";s:1:"u";s:3:"â–";s:1:"v";s:3:"â——";s:1:"w";s:3:"â˜";s:1:"x";s:3:"â™";s:1:"y";s:3:"âš";s:1:"z";s:3:"â›";s:1:"{";s:3:"âœ";s:1:"|";s:3:"â";s:1:"}";s:3:"âž";s:1:"~";s:3:"";s:1:"€";s:3:"";s:1:"";s:3:"";s:1:"‚";s:3:"";s:1:"ƒ";s:3:"";s:1:"„";s:3:"";s:1:"…";s:3:"ï£";s:1:"†";s:3:"";s:1:"‡";s:3:"";s:1:"ˆ";s:3:"";s:1:"‰";s:3:"";s:1:"Š";s:3:"";s:1:"‹";s:3:"";s:1:"Œ";s:3:"";s:1:"";s:3:"â¡";s:1:"¡";s:3:"â¢";s:1:"¢";s:3:"â£";s:1:"£";s:3:"â¤";s:1:"¤";s:3:"â¥";s:1:"¥";s:3:"â¦";s:1:"¦";s:3:"â§";s:1:"§";s:3:"♣";s:1:"¨";s:3:"♦";s:1:"©";s:3:"♥";s:1:"ª";s:3:"â™ ";s:1:"«";s:3:"â‘ ";s:1:"¬";s:3:"â‘¡";s:1:"­";s:3:"â‘¢";s:1:"®";s:3:"â‘£";s:1:"¯";s:3:"⑤";s:1:"°";s:3:"â‘¥";s:1:"±";s:3:"⑦";s:1:"²";s:3:"⑧";s:1:"³";s:3:"⑨";s:1:"´";s:3:"â‘©";s:1:"µ";s:3:"â¶";s:1:"¶";s:3:"â·";s:1:"·";s:3:"â¸";s:1:"¸";s:3:"â¹";s:1:"¹";s:3:"âº";s:1:"º";s:3:"â»";s:1:"»";s:3:"â¼";s:1:"¼";s:3:"â½";s:1:"½";s:3:"â¾";s:1:"¾";s:3:"â¿";s:1:"¿";s:3:"➀";s:1:"À";s:3:"âž";s:1:"Á";s:3:"âž‚";s:1:"Â";s:3:"➃";s:1:"Ã";s:3:"âž„";s:1:"Ä";s:3:"âž…";s:1:"Å";s:3:"➆";s:1:"Æ";s:3:"➇";s:1:"Ç";s:3:"➈";s:1:"È";s:3:"➉";s:1:"É";s:3:"➊";s:1:"Ê";s:3:"âž‹";s:1:"Ë";s:3:"➌";s:1:"Ì";s:3:"âž";s:1:"Í";s:3:"➎";s:1:"Î";s:3:"âž";s:1:"Ï";s:3:"âž";s:1:"Ð";s:3:"âž‘";s:1:"Ñ";s:3:"âž’";s:1:"Ò";s:3:"âž“";s:1:"Ó";s:3:"âž”";s:1:"Ô";s:3:"→";s:1:"Õ";s:3:"↔";s:1:"Ö";s:3:"↕";s:1:"×";s:3:"➘";s:1:"Ø";s:3:"âž™";s:1:"Ù";s:3:"âžš";s:1:"Ú";s:3:"âž›";s:1:"Û";s:3:"âžœ";s:1:"Ü";s:3:"âž";s:1:"Ý";s:3:"âžž";s:1:"Þ";s:3:"➟";s:1:"ß";s:3:"âž ";s:1:"à";s:3:"âž¡";s:1:"á";s:3:"➢";s:1:"â";s:3:"➣";s:1:"ã";s:3:"➤";s:1:"ä";s:3:"➥";s:1:"å";s:3:"➦";s:1:"æ";s:3:"➧";s:1:"ç";s:3:"➨";s:1:"è";s:3:"âž©";s:1:"é";s:3:"➪";s:1:"ê";s:3:"âž«";s:1:"ë";s:3:"➬";s:1:"ì";s:3:"âž­";s:1:"í";s:3:"âž®";s:1:"î";s:3:"➯";s:1:"ï";s:3:"âž±";s:1:"ñ";s:3:"âž²";s:1:"ò";s:3:"âž³";s:1:"ó";s:3:"âž´";s:1:"ô";s:3:"âžµ";s:1:"õ";s:3:"➶";s:1:"ö";s:3:"âž·";s:1:"÷";s:3:"➸";s:1:"ø";s:3:"âž¹";s:1:"ù";s:3:"➺";s:1:"ú";s:3:"âž»";s:1:"û";s:3:"âž¼";s:1:"ü";s:3:"âž½";s:1:"ý";s:3:"âž¾";s:1:"þ";}
    \ No newline at end of file
    diff --git a/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/translit.ser b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/translit.ser
    new file mode 100755
    index 0000000..3fd8411
    --- /dev/null
    +++ b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/charset/translit.ser
    @@ -0,0 +1 @@
    +a:3959:{s:2:"µ";s:2:"μ";s:2:"¼";s:7:" 1â„4 ";s:2:"½";s:7:" 1â„2 ";s:2:"¾";s:7:" 3â„4 ";s:2:"IJ";s:2:"IJ";s:2:"ij";s:2:"ij";s:2:"Ä¿";s:3:"L·";s:2:"Å€";s:3:"l·";s:2:"ʼn";s:3:"ʼn";s:2:"Å¿";s:1:"s";s:2:"Ç„";s:3:"DŽ";s:2:"Ç…";s:3:"Dž";s:2:"dž";s:3:"dž";s:2:"LJ";s:2:"LJ";s:2:"Lj";s:2:"Lj";s:2:"lj";s:2:"lj";s:2:"ÇŠ";s:2:"NJ";s:2:"Ç‹";s:2:"Nj";s:2:"ÇŒ";s:2:"nj";s:2:"DZ";s:2:"DZ";s:2:"Dz";s:2:"Dz";s:2:"dz";s:2:"dz";s:2:"Ï";s:2:"β";s:2:"Ï‘";s:2:"θ";s:2:"Ï’";s:2:"Î¥";s:2:"Ï•";s:2:"φ";s:2:"Ï–";s:2:"Ï€";s:2:"Ï°";s:2:"κ";s:2:"ϱ";s:2:"Ï";s:2:"ϲ";s:2:"Ï‚";s:2:"Ï´";s:2:"Θ";s:2:"ϵ";s:2:"ε";s:2:"Ϲ";s:2:"Σ";s:2:"Ö‡";s:4:"Õ¥Ö‚";s:2:"Ùµ";s:4:"اٴ";s:2:"Ù¶";s:4:"وٴ";s:2:"Ù·";s:4:"Û‡Ù´";s:2:"Ù¸";s:4:"يٴ";s:3:"ำ";s:6:"à¹à¸²";s:3:"ຳ";s:6:"à»àº²";s:3:"ໜ";s:6:"ຫນ";s:3:"à»";s:6:"ຫມ";s:3:"ཷ";s:6:"ྲà¾";s:3:"ཹ";s:6:"ླà¾";s:3:"ẚ";s:3:"aʾ";s:3:"․";s:1:".";s:3:"‥";s:2:"..";s:3:"…";s:3:"...";s:3:"″";s:6:"′′";s:3:"‴";s:9:"′′′";s:3:"‶";s:6:"‵‵";s:3:"‷";s:9:"‵‵‵";s:3:"‼";s:2:"!!";s:3:"â‡";s:2:"??";s:3:"âˆ";s:2:"?!";s:3:"â‰";s:2:"!?";s:3:"â—";s:12:"′′′′";s:3:"₨";s:2:"Rs";s:3:"â„€";s:3:"a/c";s:3:"â„";s:3:"a/s";s:3:"â„‚";s:1:"C";s:3:"℃";s:3:"°C";s:3:"â„…";s:3:"c/o";s:3:"℆";s:3:"c/u";s:3:"ℇ";s:2:"Æ";s:3:"℉";s:3:"°F";s:3:"â„Š";s:1:"g";s:3:"â„‹";s:1:"H";s:3:"â„Œ";s:1:"H";s:3:"â„";s:1:"H";s:3:"â„Ž";s:1:"h";s:3:"â„";s:2:"ħ";s:3:"â„";s:1:"I";s:3:"â„‘";s:1:"I";s:3:"â„’";s:1:"L";s:3:"â„“";s:1:"l";s:3:"â„•";s:1:"N";s:3:"â„–";s:2:"No";s:3:"â„™";s:1:"P";s:3:"â„š";s:1:"Q";s:3:"â„›";s:1:"R";s:3:"â„œ";s:1:"R";s:3:"â„";s:1:"R";s:3:"â„¡";s:3:"TEL";s:3:"ℤ";s:1:"Z";s:3:"ℨ";s:1:"Z";s:3:"ℬ";s:1:"B";s:3:"â„­";s:1:"C";s:3:"ℯ";s:1:"e";s:3:"â„°";s:1:"E";s:3:"ℱ";s:1:"F";s:3:"ℳ";s:1:"M";s:3:"â„´";s:1:"o";s:3:"ℵ";s:2:"×";s:3:"ℶ";s:2:"ב";s:3:"â„·";s:2:"×’";s:3:"ℸ";s:2:"ד";s:3:"ℹ";s:1:"i";s:3:"â„»";s:3:"FAX";s:3:"ℼ";s:2:"Ï€";s:3:"ℽ";s:2:"γ";s:3:"ℾ";s:2:"Γ";s:3:"â„¿";s:2:"Π";s:3:"â…€";s:3:"∑";s:3:"â……";s:1:"D";s:3:"â…†";s:1:"d";s:3:"â…‡";s:1:"e";s:3:"â…ˆ";s:1:"i";s:3:"â…‰";s:1:"j";s:3:"â…";s:7:" 1â„7 ";s:3:"â…‘";s:7:" 1â„9 ";s:3:"â…’";s:8:" 1â„10 ";s:3:"â…“";s:7:" 1â„3 ";s:3:"â…”";s:7:" 2â„3 ";s:3:"â…•";s:7:" 1â„5 ";s:3:"â…–";s:7:" 2â„5 ";s:3:"â…—";s:7:" 3â„5 ";s:3:"â…˜";s:7:" 4â„5 ";s:3:"â…™";s:7:" 1â„6 ";s:3:"â…š";s:7:" 5â„6 ";s:3:"â…›";s:7:" 1â„8 ";s:3:"â…œ";s:7:" 3â„8 ";s:3:"â…";s:7:" 5â„8 ";s:3:"â…ž";s:7:" 7â„8 ";s:3:"â…Ÿ";s:6:" 1â„ ";s:3:"â… ";s:1:"I";s:3:"â…¡";s:2:"II";s:3:"â…¢";s:3:"III";s:3:"â…£";s:2:"IV";s:3:"â…¤";s:1:"V";s:3:"â…¥";s:2:"VI";s:3:"â…¦";s:3:"VII";s:3:"â…§";s:4:"VIII";s:3:"â…¨";s:2:"IX";s:3:"â…©";s:1:"X";s:3:"â…ª";s:2:"XI";s:3:"â…«";s:3:"XII";s:3:"â…¬";s:1:"L";s:3:"â…­";s:1:"C";s:3:"â…®";s:1:"D";s:3:"â…¯";s:1:"M";s:3:"â…°";s:1:"i";s:3:"â…±";s:2:"ii";s:3:"â…²";s:3:"iii";s:3:"â…³";s:2:"iv";s:3:"â…´";s:1:"v";s:3:"â…µ";s:2:"vi";s:3:"â…¶";s:3:"vii";s:3:"â…·";s:4:"viii";s:3:"â…¸";s:2:"ix";s:3:"â…¹";s:1:"x";s:3:"â…º";s:2:"xi";s:3:"â…»";s:3:"xii";s:3:"â…¼";s:1:"l";s:3:"â…½";s:1:"c";s:3:"â…¾";s:1:"d";s:3:"â…¿";s:1:"m";s:3:"↉";s:7:" 0â„3 ";s:3:"∬";s:6:"∫∫";s:3:"∭";s:9:"∫∫∫";s:3:"∯";s:6:"∮∮";s:3:"∰";s:9:"∮∮∮";s:3:"â‘ ";s:3:"(1)";s:3:"â‘¡";s:3:"(2)";s:3:"â‘¢";s:3:"(3)";s:3:"â‘£";s:3:"(4)";s:3:"⑤";s:3:"(5)";s:3:"â‘¥";s:3:"(6)";s:3:"⑦";s:3:"(7)";s:3:"⑧";s:3:"(8)";s:3:"⑨";s:3:"(9)";s:3:"â‘©";s:4:"(10)";s:3:"⑪";s:4:"(11)";s:3:"â‘«";s:4:"(12)";s:3:"⑬";s:4:"(13)";s:3:"â‘­";s:4:"(14)";s:3:"â‘®";s:4:"(15)";s:3:"⑯";s:4:"(16)";s:3:"â‘°";s:4:"(17)";s:3:"⑱";s:4:"(18)";s:3:"⑲";s:4:"(19)";s:3:"⑳";s:4:"(20)";s:3:"â‘´";s:3:"(1)";s:3:"⑵";s:3:"(2)";s:3:"⑶";s:3:"(3)";s:3:"â‘·";s:3:"(4)";s:3:"⑸";s:3:"(5)";s:3:"⑹";s:3:"(6)";s:3:"⑺";s:3:"(7)";s:3:"â‘»";s:3:"(8)";s:3:"⑼";s:3:"(9)";s:3:"⑽";s:4:"(10)";s:3:"⑾";s:4:"(11)";s:3:"â‘¿";s:4:"(12)";s:3:"â’€";s:4:"(13)";s:3:"â’";s:4:"(14)";s:3:"â’‚";s:4:"(15)";s:3:"â’ƒ";s:4:"(16)";s:3:"â’„";s:4:"(17)";s:3:"â’…";s:4:"(18)";s:3:"â’†";s:4:"(19)";s:3:"â’‡";s:4:"(20)";s:3:"â’ˆ";s:2:"1.";s:3:"â’‰";s:2:"2.";s:3:"â’Š";s:2:"3.";s:3:"â’‹";s:2:"4.";s:3:"â’Œ";s:2:"5.";s:3:"â’";s:2:"6.";s:3:"â’Ž";s:2:"7.";s:3:"â’";s:2:"8.";s:3:"â’";s:2:"9.";s:3:"â’‘";s:3:"10.";s:3:"â’’";s:3:"11.";s:3:"â’“";s:3:"12.";s:3:"â’”";s:3:"13.";s:3:"â’•";s:3:"14.";s:3:"â’–";s:3:"15.";s:3:"â’—";s:3:"16.";s:3:"â’˜";s:3:"17.";s:3:"â’™";s:3:"18.";s:3:"â’š";s:3:"19.";s:3:"â’›";s:3:"20.";s:3:"â’œ";s:3:"(a)";s:3:"â’";s:3:"(b)";s:3:"â’ž";s:3:"(c)";s:3:"â’Ÿ";s:3:"(d)";s:3:"â’ ";s:3:"(e)";s:3:"â’¡";s:3:"(f)";s:3:"â’¢";s:3:"(g)";s:3:"â’£";s:3:"(h)";s:3:"â’¤";s:3:"(i)";s:3:"â’¥";s:3:"(j)";s:3:"â’¦";s:3:"(k)";s:3:"â’§";s:3:"(l)";s:3:"â’¨";s:3:"(m)";s:3:"â’©";s:3:"(n)";s:3:"â’ª";s:3:"(o)";s:3:"â’«";s:3:"(p)";s:3:"â’¬";s:3:"(q)";s:3:"â’­";s:3:"(r)";s:3:"â’®";s:3:"(s)";s:3:"â’¯";s:3:"(t)";s:3:"â’°";s:3:"(u)";s:3:"â’±";s:3:"(v)";s:3:"â’²";s:3:"(w)";s:3:"â’³";s:3:"(x)";s:3:"â’´";s:3:"(y)";s:3:"â’µ";s:3:"(z)";s:3:"â’¶";s:3:"(A)";s:3:"â’·";s:3:"(B)";s:3:"â’¸";s:3:"(C)";s:3:"â’¹";s:3:"(D)";s:3:"â’º";s:3:"(E)";s:3:"â’»";s:3:"(F)";s:3:"â’¼";s:3:"(G)";s:3:"â’½";s:3:"(H)";s:3:"â’¾";s:3:"(I)";s:3:"â’¿";s:3:"(J)";s:3:"â“€";s:3:"(K)";s:3:"â“";s:3:"(L)";s:3:"â“‚";s:3:"(M)";s:3:"Ⓝ";s:3:"(N)";s:3:"â“„";s:3:"(O)";s:3:"â“…";s:3:"(P)";s:3:"Ⓠ";s:3:"(Q)";s:3:"Ⓡ";s:3:"(R)";s:3:"Ⓢ";s:3:"(S)";s:3:"Ⓣ";s:3:"(T)";s:3:"â“Š";s:3:"(U)";s:3:"â“‹";s:3:"(V)";s:3:"â“Œ";s:3:"(W)";s:3:"â“";s:3:"(X)";s:3:"â“Ž";s:3:"(Y)";s:3:"â“";s:3:"(Z)";s:3:"â“";s:3:"(a)";s:3:"â“‘";s:3:"(b)";s:3:"â“’";s:3:"(c)";s:3:"â““";s:3:"(d)";s:3:"â“”";s:3:"(e)";s:3:"â“•";s:3:"(f)";s:3:"â“–";s:3:"(g)";s:3:"â“—";s:3:"(h)";s:3:"ⓘ";s:3:"(i)";s:3:"â“™";s:3:"(j)";s:3:"â“š";s:3:"(k)";s:3:"â“›";s:3:"(l)";s:3:"â“œ";s:3:"(m)";s:3:"â“";s:3:"(n)";s:3:"â“ž";s:3:"(o)";s:3:"â“Ÿ";s:3:"(p)";s:3:"â“ ";s:3:"(q)";s:3:"â“¡";s:3:"(r)";s:3:"â“¢";s:3:"(s)";s:3:"â“£";s:3:"(t)";s:3:"ⓤ";s:3:"(u)";s:3:"â“¥";s:3:"(v)";s:3:"ⓦ";s:3:"(w)";s:3:"ⓧ";s:3:"(x)";s:3:"ⓨ";s:3:"(y)";s:3:"â“©";s:3:"(z)";s:3:"⓪";s:3:"(0)";s:3:"⨌";s:12:"∫∫∫∫";s:3:"â©´";s:3:"::=";s:3:"⩵";s:2:"==";s:3:"⩶";s:3:"===";s:3:"⺟";s:3:"æ¯";s:3:"⻳";s:3:"龟";s:3:"â¼€";s:3:"一";s:3:"â¼";s:3:"丨";s:3:"⼂";s:3:"丶";s:3:"⼃";s:3:"丿";s:3:"⼄";s:3:"ä¹™";s:3:"â¼…";s:3:"亅";s:3:"⼆";s:3:"二";s:3:"⼇";s:3:"亠";s:3:"⼈";s:3:"人";s:3:"⼉";s:3:"å„¿";s:3:"⼊";s:3:"å…¥";s:3:"⼋";s:3:"å…«";s:3:"⼌";s:3:"冂";s:3:"â¼";s:3:"冖";s:3:"⼎";s:3:"冫";s:3:"â¼";s:3:"几";s:3:"â¼";s:3:"凵";s:3:"⼑";s:3:"刀";s:3:"â¼’";s:3:"力";s:3:"⼓";s:3:"勹";s:3:"â¼”";s:3:"匕";s:3:"⼕";s:3:"匚";s:3:"â¼–";s:3:"匸";s:3:"â¼—";s:3:"å";s:3:"⼘";s:3:"åœ";s:3:"â¼™";s:3:"å©";s:3:"⼚";s:3:"厂";s:3:"â¼›";s:3:"厶";s:3:"⼜";s:3:"åˆ";s:3:"â¼";s:3:"å£";s:3:"⼞";s:3:"å›—";s:3:"⼟";s:3:"土";s:3:"â¼ ";s:3:"士";s:3:"⼡";s:3:"夂";s:3:"â¼¢";s:3:"夊";s:3:"â¼£";s:3:"夕";s:3:"⼤";s:3:"大";s:3:"â¼¥";s:3:"女";s:3:"⼦";s:3:"å­";s:3:"⼧";s:3:"宀";s:3:"⼨";s:3:"寸";s:3:"⼩";s:3:"å°";s:3:"⼪";s:3:"å°¢";s:3:"⼫";s:3:"å°¸";s:3:"⼬";s:3:"å±®";s:3:"â¼­";s:3:"å±±";s:3:"â¼®";s:3:"å·›";s:3:"⼯";s:3:"å·¥";s:3:"â¼°";s:3:"å·±";s:3:"â¼±";s:3:"å·¾";s:3:"â¼²";s:3:"å¹²";s:3:"â¼³";s:3:"幺";s:3:"â¼´";s:3:"广";s:3:"â¼µ";s:3:"å»´";s:3:"⼶";s:3:"廾";s:3:"â¼·";s:3:"弋";s:3:"⼸";s:3:"弓";s:3:"â¼¹";s:3:"å½";s:3:"⼺";s:3:"彡";s:3:"â¼»";s:3:"å½³";s:3:"â¼¼";s:3:"心";s:3:"â¼½";s:3:"戈";s:3:"â¼¾";s:3:"戶";s:3:"⼿";s:3:"手";s:3:"â½€";s:3:"支";s:3:"â½";s:3:"æ”´";s:3:"⽂";s:3:"æ–‡";s:3:"⽃";s:3:"æ–—";s:3:"⽄";s:3:"æ–¤";s:3:"â½…";s:3:"æ–¹";s:3:"⽆";s:3:"æ— ";s:3:"⽇";s:3:"æ—¥";s:3:"⽈";s:3:"æ›°";s:3:"⽉";s:3:"月";s:3:"⽊";s:3:"木";s:3:"⽋";s:3:"欠";s:3:"⽌";s:3:"æ­¢";s:3:"â½";s:3:"æ­¹";s:3:"⽎";s:3:"殳";s:3:"â½";s:3:"毋";s:3:"â½";s:3:"比";s:3:"⽑";s:3:"毛";s:3:"â½’";s:3:"æ°";s:3:"⽓";s:3:"æ°”";s:3:"â½”";s:3:"æ°´";s:3:"⽕";s:3:"ç«";s:3:"â½–";s:3:"爪";s:3:"â½—";s:3:"父";s:3:"⽘";s:3:"爻";s:3:"â½™";s:3:"爿";s:3:"⽚";s:3:"片";s:3:"â½›";s:3:"牙";s:3:"⽜";s:3:"牛";s:3:"â½";s:3:"犬";s:3:"⽞";s:3:"玄";s:3:"⽟";s:3:"玉";s:3:"â½ ";s:3:"ç“œ";s:3:"⽡";s:3:"瓦";s:3:"â½¢";s:3:"甘";s:3:"â½£";s:3:"生";s:3:"⽤";s:3:"用";s:3:"â½¥";s:3:"ç”°";s:3:"⽦";s:3:"ç–‹";s:3:"⽧";s:3:"ç–’";s:3:"⽨";s:3:"癶";s:3:"⽩";s:3:"白";s:3:"⽪";s:3:"çš®";s:3:"⽫";s:3:"çš¿";s:3:"⽬";s:3:"ç›®";s:3:"â½­";s:3:"矛";s:3:"â½®";s:3:"矢";s:3:"⽯";s:3:"石";s:3:"â½°";s:3:"示";s:3:"â½±";s:3:"禸";s:3:"â½²";s:3:"禾";s:3:"â½³";s:3:"ç©´";s:3:"â½´";s:3:"ç«‹";s:3:"â½µ";s:3:"竹";s:3:"⽶";s:3:"ç±³";s:3:"â½·";s:3:"糸";s:3:"⽸";s:3:"缶";s:3:"â½¹";s:3:"网";s:3:"⽺";s:3:"羊";s:3:"â½»";s:3:"ç¾½";s:3:"â½¼";s:3:"è€";s:3:"â½½";s:3:"而";s:3:"â½¾";s:3:"耒";s:3:"⽿";s:3:"耳";s:3:"â¾€";s:3:"è¿";s:3:"â¾";s:3:"肉";s:3:"⾂";s:3:"臣";s:3:"⾃";s:3:"自";s:3:"⾄";s:3:"至";s:3:"â¾…";s:3:"臼";s:3:"⾆";s:3:"舌";s:3:"⾇";s:3:"舛";s:3:"⾈";s:3:"舟";s:3:"⾉";s:3:"艮";s:3:"⾊";s:3:"色";s:3:"⾋";s:3:"艸";s:3:"⾌";s:3:"è™";s:3:"â¾";s:3:"虫";s:3:"⾎";s:3:"è¡€";s:3:"â¾";s:3:"è¡Œ";s:3:"â¾";s:3:"è¡£";s:3:"⾑";s:3:"襾";s:3:"â¾’";s:3:"見";s:3:"⾓";s:3:"角";s:3:"â¾”";s:3:"言";s:3:"⾕";s:3:"è°·";s:3:"â¾–";s:3:"豆";s:3:"â¾—";s:3:"豕";s:3:"⾘";s:3:"豸";s:3:"â¾™";s:3:"è²";s:3:"⾚";s:3:"赤";s:3:"â¾›";s:3:"èµ°";s:3:"⾜";s:3:"足";s:3:"â¾";s:3:"身";s:3:"⾞";s:3:"車";s:3:"⾟";s:3:"è¾›";s:3:"â¾ ";s:3:"è¾°";s:3:"⾡";s:3:"è¾µ";s:3:"â¾¢";s:3:"é‚‘";s:3:"â¾£";s:3:"é…‰";s:3:"⾤";s:3:"釆";s:3:"â¾¥";s:3:"里";s:3:"⾦";s:3:"金";s:3:"⾧";s:3:"é•·";s:3:"⾨";s:3:"é–€";s:3:"⾩";s:3:"阜";s:3:"⾪";s:3:"隶";s:3:"⾫";s:3:"éš¹";s:3:"⾬";s:3:"雨";s:3:"â¾­";s:3:"é‘";s:3:"â¾®";s:3:"éž";s:3:"⾯";s:3:"é¢";s:3:"â¾°";s:3:"é©";s:3:"â¾±";s:3:"韋";s:3:"â¾²";s:3:"韭";s:3:"â¾³";s:3:"音";s:3:"â¾´";s:3:"é ";s:3:"â¾µ";s:3:"風";s:3:"⾶";s:3:"飛";s:3:"â¾·";s:3:"食";s:3:"⾸";s:3:"首";s:3:"â¾¹";s:3:"香";s:3:"⾺";s:3:"馬";s:3:"â¾»";s:3:"骨";s:3:"â¾¼";s:3:"高";s:3:"â¾½";s:3:"é«Ÿ";s:3:"â¾¾";s:3:"鬥";s:3:"⾿";s:3:"鬯";s:3:"â¿€";s:3:"鬲";s:3:"â¿";s:3:"鬼";s:3:"â¿‚";s:3:"é­š";s:3:"⿃";s:3:"é³¥";s:3:"â¿„";s:3:"é¹µ";s:3:"â¿…";s:3:"鹿";s:3:"⿆";s:3:"麥";s:3:"⿇";s:3:"麻";s:3:"⿈";s:3:"黃";s:3:"⿉";s:3:"é»";s:3:"â¿Š";s:3:"黑";s:3:"â¿‹";s:3:"黹";s:3:"â¿Œ";s:3:"黽";s:3:"â¿";s:3:"鼎";s:3:"â¿Ž";s:3:"鼓";s:3:"â¿";s:3:"é¼ ";s:3:"â¿";s:3:"é¼»";s:3:"â¿‘";s:3:"齊";s:3:"â¿’";s:3:"é½’";s:3:"â¿“";s:3:"é¾";s:3:"â¿”";s:3:"龜";s:3:"â¿•";s:3:"é¾ ";s:3:" ";s:1:" ";s:3:"〶";s:3:"〒";s:3:"〸";s:3:"å";s:3:"〹";s:3:"å„";s:3:"〺";s:3:"å…";s:3:"ㄱ";s:3:"á„€";s:3:"ㄲ";s:3:"á„";s:3:"ㄳ";s:3:"ᆪ";s:3:"ã„´";s:3:"á„‚";s:3:"ㄵ";s:3:"ᆬ";s:3:"ㄶ";s:3:"ᆭ";s:3:"ã„·";s:3:"ᄃ";s:3:"ㄸ";s:3:"á„„";s:3:"ㄹ";s:3:"á„…";s:3:"ㄺ";s:3:"ᆰ";s:3:"ã„»";s:3:"ᆱ";s:3:"ㄼ";s:3:"ᆲ";s:3:"ㄽ";s:3:"ᆳ";s:3:"ㄾ";s:3:"ᆴ";s:3:"ã„¿";s:3:"ᆵ";s:3:"ã…€";s:3:"á„š";s:3:"ã…";s:3:"ᄆ";s:3:"ã…‚";s:3:"ᄇ";s:3:"ã…ƒ";s:3:"ᄈ";s:3:"ã…„";s:3:"á„¡";s:3:"ã……";s:3:"ᄉ";s:3:"ã…†";s:3:"á„Š";s:3:"ã…‡";s:3:"á„‹";s:3:"ã…ˆ";s:3:"á„Œ";s:3:"ã…‰";s:3:"á„";s:3:"ã…Š";s:3:"á„Ž";s:3:"ã…‹";s:3:"á„";s:3:"ã…Œ";s:3:"á„";s:3:"ã…";s:3:"á„‘";s:3:"ã…Ž";s:3:"á„’";s:3:"ã…";s:3:"á…¡";s:3:"ã…";s:3:"á…¢";s:3:"ã…‘";s:3:"á…£";s:3:"ã…’";s:3:"á…¤";s:3:"ã…“";s:3:"á…¥";s:3:"ã…”";s:3:"á…¦";s:3:"ã…•";s:3:"á…§";s:3:"ã…–";s:3:"á…¨";s:3:"ã…—";s:3:"á…©";s:3:"ã…˜";s:3:"á…ª";s:3:"ã…™";s:3:"á…«";s:3:"ã…š";s:3:"á…¬";s:3:"ã…›";s:3:"á…­";s:3:"ã…œ";s:3:"á…®";s:3:"ã…";s:3:"á…¯";s:3:"ã…ž";s:3:"á…°";s:3:"ã…Ÿ";s:3:"á…±";s:3:"ã… ";s:3:"á…²";s:3:"ã…¡";s:3:"á…³";s:3:"ã…¢";s:3:"á…´";s:3:"ã…£";s:3:"á…µ";s:3:"ã…¤";s:3:"á… ";s:3:"ã…¥";s:3:"á„”";s:3:"ã…¦";s:3:"á„•";s:3:"ã…§";s:3:"ᇇ";s:3:"ã…¨";s:3:"ᇈ";s:3:"ã…©";s:3:"ᇌ";s:3:"ã…ª";s:3:"ᇎ";s:3:"ã…«";s:3:"ᇓ";s:3:"ã…¬";s:3:"ᇗ";s:3:"ã…­";s:3:"ᇙ";s:3:"ã…®";s:3:"á„œ";s:3:"ã…¯";s:3:"á‡";s:3:"ã…°";s:3:"ᇟ";s:3:"ã…±";s:3:"á„";s:3:"ã…²";s:3:"á„ž";s:3:"ã…³";s:3:"á„ ";s:3:"ã…´";s:3:"á„¢";s:3:"ã…µ";s:3:"á„£";s:3:"ã…¶";s:3:"ᄧ";s:3:"ã…·";s:3:"á„©";s:3:"ã…¸";s:3:"á„«";s:3:"ã…¹";s:3:"ᄬ";s:3:"ã…º";s:3:"á„­";s:3:"ã…»";s:3:"á„®";s:3:"ã…¼";s:3:"ᄯ";s:3:"ã…½";s:3:"ᄲ";s:3:"ã…¾";s:3:"ᄶ";s:3:"ã…¿";s:3:"á…€";s:3:"ㆀ";s:3:"á…‡";s:3:"ã†";s:3:"á…Œ";s:3:"ㆂ";s:3:"ᇱ";s:3:"ㆃ";s:3:"ᇲ";s:3:"ㆄ";s:3:"á…—";s:3:"ㆅ";s:3:"á…˜";s:3:"ㆆ";s:3:"á…™";s:3:"ㆇ";s:3:"ᆄ";s:3:"ㆈ";s:3:"ᆅ";s:3:"ㆉ";s:3:"ᆈ";s:3:"ㆊ";s:3:"ᆑ";s:3:"ㆋ";s:3:"ᆒ";s:3:"ㆌ";s:3:"ᆔ";s:3:"ã†";s:3:"ᆞ";s:3:"ㆎ";s:3:"ᆡ";s:3:"㈀";s:5:"(á„€)";s:3:"ãˆ";s:5:"(á„‚)";s:3:"㈂";s:5:"(ᄃ)";s:3:"㈃";s:5:"(á„…)";s:3:"㈄";s:5:"(ᄆ)";s:3:"㈅";s:5:"(ᄇ)";s:3:"㈆";s:5:"(ᄉ)";s:3:"㈇";s:5:"(á„‹)";s:3:"㈈";s:5:"(á„Œ)";s:3:"㈉";s:5:"(á„Ž)";s:3:"㈊";s:5:"(á„)";s:3:"㈋";s:5:"(á„)";s:3:"㈌";s:5:"(á„‘)";s:3:"ãˆ";s:5:"(á„’)";s:3:"㈎";s:8:"(가)";s:3:"ãˆ";s:8:"(á„‚á…¡)";s:3:"ãˆ";s:8:"(다)";s:3:"㈑";s:8:"(á„…á…¡)";s:3:"㈒";s:8:"(마)";s:3:"㈓";s:8:"(바)";s:3:"㈔";s:8:"(사)";s:3:"㈕";s:8:"(á„‹á…¡)";s:3:"㈖";s:8:"(자)";s:3:"㈗";s:8:"(á„Žá…¡)";s:3:"㈘";s:8:"(á„á…¡)";s:3:"㈙";s:8:"(á„á…¡)";s:3:"㈚";s:8:"(á„‘á…¡)";s:3:"㈛";s:8:"(á„’á…¡)";s:3:"㈜";s:8:"(주)";s:3:"ãˆ";s:17:"(오전)";s:3:"㈞";s:14:"(á„‹á…©á„’á…®)";s:3:"㈠";s:5:"(一)";s:3:"㈡";s:5:"(二)";s:3:"㈢";s:5:"(三)";s:3:"㈣";s:5:"(å››)";s:3:"㈤";s:5:"(五)";s:3:"㈥";s:5:"(å…­)";s:3:"㈦";s:5:"(七)";s:3:"㈧";s:5:"(å…«)";s:3:"㈨";s:5:"(ä¹)";s:3:"㈩";s:5:"(å)";s:3:"㈪";s:5:"(月)";s:3:"㈫";s:5:"(ç«)";s:3:"㈬";s:5:"(æ°´)";s:3:"㈭";s:5:"(木)";s:3:"㈮";s:5:"(金)";s:3:"㈯";s:5:"(土)";s:3:"㈰";s:5:"(æ—¥)";s:3:"㈱";s:5:"(æ ª)";s:3:"㈲";s:5:"(有)";s:3:"㈳";s:5:"(社)";s:3:"㈴";s:5:"(å)";s:3:"㈵";s:5:"(特)";s:3:"㈶";s:5:"(財)";s:3:"㈷";s:5:"(ç¥)";s:3:"㈸";s:5:"(労)";s:3:"㈹";s:5:"(代)";s:3:"㈺";s:5:"(呼)";s:3:"㈻";s:5:"(å­¦)";s:3:"㈼";s:5:"(監)";s:3:"㈽";s:5:"(ä¼)";s:3:"㈾";s:5:"(資)";s:3:"㈿";s:5:"(å”)";s:3:"㉀";s:5:"(祭)";s:3:"ã‰";s:5:"(休)";s:3:"㉂";s:5:"(自)";s:3:"㉃";s:5:"(至)";s:3:"㉄";s:5:"(å•)";s:3:"㉅";s:5:"(å¹¼)";s:3:"㉆";s:5:"(æ–‡)";s:3:"㉇";s:5:"(ç®)";s:3:"ã‰";s:3:"PTE";s:3:"㉑";s:4:"(21)";s:3:"㉒";s:4:"(22)";s:3:"㉓";s:4:"(23)";s:3:"㉔";s:4:"(24)";s:3:"㉕";s:4:"(25)";s:3:"㉖";s:4:"(26)";s:3:"㉗";s:4:"(27)";s:3:"㉘";s:4:"(28)";s:3:"㉙";s:4:"(29)";s:3:"㉚";s:4:"(30)";s:3:"㉛";s:4:"(31)";s:3:"㉜";s:4:"(32)";s:3:"ã‰";s:4:"(33)";s:3:"㉞";s:4:"(34)";s:3:"㉟";s:4:"(35)";s:3:"㉠";s:5:"(á„€)";s:3:"㉡";s:5:"(á„‚)";s:3:"㉢";s:5:"(ᄃ)";s:3:"㉣";s:5:"(á„…)";s:3:"㉤";s:5:"(ᄆ)";s:3:"㉥";s:5:"(ᄇ)";s:3:"㉦";s:5:"(ᄉ)";s:3:"㉧";s:5:"(á„‹)";s:3:"㉨";s:5:"(á„Œ)";s:3:"㉩";s:5:"(á„Ž)";s:3:"㉪";s:5:"(á„)";s:3:"㉫";s:5:"(á„)";s:3:"㉬";s:5:"(á„‘)";s:3:"㉭";s:5:"(á„’)";s:3:"㉮";s:8:"(가)";s:3:"㉯";s:8:"(á„‚á…¡)";s:3:"㉰";s:8:"(다)";s:3:"㉱";s:8:"(á„…á…¡)";s:3:"㉲";s:8:"(마)";s:3:"㉳";s:8:"(바)";s:3:"㉴";s:8:"(사)";s:3:"㉵";s:8:"(á„‹á…¡)";s:3:"㉶";s:8:"(자)";s:3:"㉷";s:8:"(á„Žá…¡)";s:3:"㉸";s:8:"(á„á…¡)";s:3:"㉹";s:8:"(á„á…¡)";s:3:"㉺";s:8:"(á„‘á…¡)";s:3:"㉻";s:8:"(á„’á…¡)";s:3:"㉼";s:17:"(참고)";s:3:"㉽";s:14:"(주의)";s:3:"㉾";s:8:"(á„‹á…®)";s:3:"㊀";s:5:"(一)";s:3:"ãŠ";s:5:"(二)";s:3:"㊂";s:5:"(三)";s:3:"㊃";s:5:"(å››)";s:3:"㊄";s:5:"(五)";s:3:"㊅";s:5:"(å…­)";s:3:"㊆";s:5:"(七)";s:3:"㊇";s:5:"(å…«)";s:3:"㊈";s:5:"(ä¹)";s:3:"㊉";s:5:"(å)";s:3:"㊊";s:5:"(月)";s:3:"㊋";s:5:"(ç«)";s:3:"㊌";s:5:"(æ°´)";s:3:"ãŠ";s:5:"(木)";s:3:"㊎";s:5:"(金)";s:3:"ãŠ";s:5:"(土)";s:3:"ãŠ";s:5:"(æ—¥)";s:3:"㊑";s:5:"(æ ª)";s:3:"㊒";s:5:"(有)";s:3:"㊓";s:5:"(社)";s:3:"㊔";s:5:"(å)";s:3:"㊕";s:5:"(特)";s:3:"㊖";s:5:"(財)";s:3:"㊗";s:5:"(ç¥)";s:3:"㊘";s:5:"(労)";s:3:"㊙";s:5:"(秘)";s:3:"㊚";s:5:"(ç”·)";s:3:"㊛";s:5:"(女)";s:3:"㊜";s:5:"(é©)";s:3:"ãŠ";s:5:"(優)";s:3:"㊞";s:5:"(å°)";s:3:"㊟";s:5:"(注)";s:3:"㊠";s:5:"(é …)";s:3:"㊡";s:5:"(休)";s:3:"㊢";s:5:"(写)";s:3:"㊣";s:5:"(æ­£)";s:3:"㊤";s:5:"(上)";s:3:"㊥";s:5:"(中)";s:3:"㊦";s:5:"(下)";s:3:"㊧";s:5:"(å·¦)";s:3:"㊨";s:5:"(å³)";s:3:"㊩";s:5:"(医)";s:3:"㊪";s:5:"(å®—)";s:3:"㊫";s:5:"(å­¦)";s:3:"㊬";s:5:"(監)";s:3:"㊭";s:5:"(ä¼)";s:3:"㊮";s:5:"(資)";s:3:"㊯";s:5:"(å”)";s:3:"㊰";s:5:"(夜)";s:3:"㊱";s:4:"(36)";s:3:"㊲";s:4:"(37)";s:3:"㊳";s:4:"(38)";s:3:"㊴";s:4:"(39)";s:3:"㊵";s:4:"(40)";s:3:"㊶";s:4:"(41)";s:3:"㊷";s:4:"(42)";s:3:"㊸";s:4:"(43)";s:3:"㊹";s:4:"(44)";s:3:"㊺";s:4:"(45)";s:3:"㊻";s:4:"(46)";s:3:"㊼";s:4:"(47)";s:3:"㊽";s:4:"(48)";s:3:"㊾";s:4:"(49)";s:3:"㊿";s:4:"(50)";s:3:"ã‹€";s:4:"1月";s:3:"ã‹";s:4:"2月";s:3:"ã‹‚";s:4:"3月";s:3:"㋃";s:4:"4月";s:3:"ã‹„";s:4:"5月";s:3:"ã‹…";s:4:"6月";s:3:"㋆";s:4:"7月";s:3:"㋇";s:4:"8月";s:3:"㋈";s:4:"9月";s:3:"㋉";s:5:"10月";s:3:"ã‹Š";s:5:"11月";s:3:"ã‹‹";s:5:"12月";s:3:"ã‹Œ";s:2:"Hg";s:3:"ã‹";s:3:"erg";s:3:"ã‹Ž";s:2:"eV";s:3:"ã‹";s:3:"LTD";s:3:"ã‹";s:5:"(ã‚¢)";s:3:"ã‹‘";s:5:"(イ)";s:3:"ã‹’";s:5:"(ウ)";s:3:"ã‹“";s:5:"(エ)";s:3:"ã‹”";s:5:"(オ)";s:3:"ã‹•";s:5:"(ã‚«)";s:3:"ã‹–";s:5:"(ã‚­)";s:3:"ã‹—";s:5:"(ク)";s:3:"㋘";s:5:"(ケ)";s:3:"ã‹™";s:5:"(コ)";s:3:"ã‹š";s:5:"(サ)";s:3:"ã‹›";s:5:"(ã‚·)";s:3:"ã‹œ";s:5:"(ス)";s:3:"ã‹";s:5:"(ã‚»)";s:3:"ã‹ž";s:5:"(ソ)";s:3:"ã‹Ÿ";s:5:"(ã‚¿)";s:3:"ã‹ ";s:5:"(ãƒ)";s:3:"ã‹¡";s:5:"(ツ)";s:3:"ã‹¢";s:5:"(テ)";s:3:"ã‹£";s:5:"(ト)";s:3:"㋤";s:5:"(ナ)";s:3:"ã‹¥";s:5:"(ニ)";s:3:"㋦";s:5:"(ヌ)";s:3:"㋧";s:5:"(ãƒ)";s:3:"㋨";s:5:"(ノ)";s:3:"ã‹©";s:5:"(ãƒ)";s:3:"㋪";s:5:"(ヒ)";s:3:"ã‹«";s:5:"(フ)";s:3:"㋬";s:5:"(ヘ)";s:3:"ã‹­";s:5:"(ホ)";s:3:"ã‹®";s:5:"(マ)";s:3:"㋯";s:5:"(ミ)";s:3:"ã‹°";s:5:"(ム)";s:3:"㋱";s:5:"(メ)";s:3:"㋲";s:5:"(モ)";s:3:"㋳";s:5:"(ヤ)";s:3:"ã‹´";s:5:"(ユ)";s:3:"㋵";s:5:"(ヨ)";s:3:"㋶";s:5:"(ラ)";s:3:"ã‹·";s:5:"(リ)";s:3:"㋸";s:5:"(ル)";s:3:"㋹";s:5:"(レ)";s:3:"㋺";s:5:"(ロ)";s:3:"ã‹»";s:5:"(ワ)";s:3:"㋼";s:5:"(ヰ)";s:3:"㋽";s:5:"(ヱ)";s:3:"㋾";s:5:"(ヲ)";s:3:"㌀";s:12:"アパート";s:3:"ãŒ";s:12:"アルファ";s:3:"㌂";s:12:"アンペア";s:3:"㌃";s:9:"アール";s:3:"㌄";s:12:"イニング";s:3:"㌅";s:9:"インãƒ";s:3:"㌆";s:9:"ウォン";s:3:"㌇";s:15:"エスクード";s:3:"㌈";s:12:"エーカー";s:3:"㌉";s:9:"オンス";s:3:"㌊";s:9:"オーム";s:3:"㌋";s:9:"カイリ";s:3:"㌌";s:12:"カラット";s:3:"ãŒ";s:12:"カロリー";s:3:"㌎";s:9:"ガロン";s:3:"ãŒ";s:9:"ガンマ";s:3:"ãŒ";s:6:"ギガ";s:3:"㌑";s:9:"ギニー";s:3:"㌒";s:12:"キュリー";s:3:"㌓";s:12:"ギルダー";s:3:"㌔";s:6:"キロ";s:3:"㌕";s:15:"キログラム";s:3:"㌖";s:18:"キロメートル";s:3:"㌗";s:15:"キロワット";s:3:"㌘";s:9:"グラム";s:3:"㌙";s:15:"グラムトン";s:3:"㌚";s:15:"クルゼイロ";s:3:"㌛";s:12:"クローãƒ";s:3:"㌜";s:9:"ケース";s:3:"ãŒ";s:9:"コルナ";s:3:"㌞";s:9:"コーãƒ";s:3:"㌟";s:12:"サイクル";s:3:"㌠";s:15:"サンãƒãƒ¼ãƒ ";s:3:"㌡";s:12:"シリング";s:3:"㌢";s:9:"センãƒ";s:3:"㌣";s:9:"セント";s:3:"㌤";s:9:"ダース";s:3:"㌥";s:6:"デシ";s:3:"㌦";s:6:"ドル";s:3:"㌧";s:6:"トン";s:3:"㌨";s:6:"ナノ";s:3:"㌩";s:9:"ノット";s:3:"㌪";s:9:"ãƒã‚¤ãƒ„";s:3:"㌫";s:15:"パーセント";s:3:"㌬";s:9:"パーツ";s:3:"㌭";s:12:"ãƒãƒ¼ãƒ¬ãƒ«";s:3:"㌮";s:15:"ピアストル";s:3:"㌯";s:9:"ピクル";s:3:"㌰";s:6:"ピコ";s:3:"㌱";s:6:"ビル";s:3:"㌲";s:15:"ファラッド";s:3:"㌳";s:12:"フィート";s:3:"㌴";s:15:"ブッシェル";s:3:"㌵";s:9:"フラン";s:3:"㌶";s:15:"ヘクタール";s:3:"㌷";s:6:"ペソ";s:3:"㌸";s:9:"ペニヒ";s:3:"㌹";s:9:"ヘルツ";s:3:"㌺";s:9:"ペンス";s:3:"㌻";s:9:"ページ";s:3:"㌼";s:9:"ベータ";s:3:"㌽";s:12:"ãƒã‚¤ãƒ³ãƒˆ";s:3:"㌾";s:9:"ボルト";s:3:"㌿";s:6:"ホン";s:3:"ã€";s:9:"ãƒãƒ³ãƒ‰";s:3:"ã";s:9:"ホール";s:3:"ã‚";s:9:"ホーン";s:3:"ãƒ";s:12:"マイクロ";s:3:"ã„";s:9:"マイル";s:3:"ã…";s:9:"マッãƒ";s:3:"ã†";s:9:"マルク";s:3:"ã‡";s:15:"マンション";s:3:"ãˆ";s:12:"ミクロン";s:3:"ã‰";s:6:"ミリ";s:3:"ãŠ";s:15:"ミリãƒãƒ¼ãƒ«";s:3:"ã‹";s:6:"メガ";s:3:"ãŒ";s:12:"メガトン";s:3:"ã";s:12:"メートル";s:3:"ãŽ";s:9:"ヤード";s:3:"ã";s:9:"ヤール";s:3:"ã";s:9:"ユアン";s:3:"ã‘";s:12:"リットル";s:3:"ã’";s:6:"リラ";s:3:"ã“";s:9:"ルピー";s:3:"ã”";s:12:"ルーブル";s:3:"ã•";s:6:"レム";s:3:"ã–";s:15:"レントゲン";s:3:"ã—";s:9:"ワット";s:3:"ã˜";s:4:"0点";s:3:"ã™";s:4:"1点";s:3:"ãš";s:4:"2点";s:3:"ã›";s:4:"3点";s:3:"ãœ";s:4:"4点";s:3:"ã";s:4:"5点";s:3:"ãž";s:4:"6点";s:3:"ãŸ";s:4:"7点";s:3:"ã ";s:4:"8点";s:3:"ã¡";s:4:"9点";s:3:"ã¢";s:5:"10点";s:3:"ã£";s:5:"11点";s:3:"ã¤";s:5:"12点";s:3:"ã¥";s:5:"13点";s:3:"ã¦";s:5:"14点";s:3:"ã§";s:5:"15点";s:3:"ã¨";s:5:"16点";s:3:"ã©";s:5:"17点";s:3:"ãª";s:5:"18点";s:3:"ã«";s:5:"19点";s:3:"ã¬";s:5:"20点";s:3:"ã­";s:5:"21点";s:3:"ã®";s:5:"22点";s:3:"ã¯";s:5:"23点";s:3:"ã°";s:5:"24点";s:3:"ã±";s:3:"hPa";s:3:"ã²";s:2:"da";s:3:"ã³";s:2:"AU";s:3:"ã´";s:3:"bar";s:3:"ãµ";s:2:"oV";s:3:"ã¶";s:2:"pc";s:3:"ã·";s:2:"dm";s:3:"ã¸";s:4:"dm²";s:3:"ã¹";s:4:"dm³";s:3:"ãº";s:2:"IU";s:3:"ã»";s:6:"å¹³æˆ";s:3:"ã¼";s:6:"昭和";s:3:"ã½";s:6:"大正";s:3:"ã¾";s:6:"明治";s:3:"ã¿";s:12:"æ ªå¼ä¼šç¤¾";s:3:"㎀";s:2:"pA";s:3:"ãŽ";s:2:"nA";s:3:"㎂";s:3:"μA";s:3:"㎃";s:2:"mA";s:3:"㎄";s:2:"kA";s:3:"㎅";s:2:"KB";s:3:"㎆";s:2:"MB";s:3:"㎇";s:2:"GB";s:3:"㎈";s:3:"cal";s:3:"㎉";s:4:"kcal";s:3:"㎊";s:2:"pF";s:3:"㎋";s:2:"nF";s:3:"㎌";s:3:"μF";s:3:"ãŽ";s:3:"μg";s:3:"㎎";s:2:"mg";s:3:"ãŽ";s:2:"kg";s:3:"ãŽ";s:2:"Hz";s:3:"㎑";s:3:"kHz";s:3:"㎒";s:3:"MHz";s:3:"㎓";s:3:"GHz";s:3:"㎔";s:3:"THz";s:3:"㎕";s:5:"μℓ";s:3:"㎖";s:4:"mâ„“";s:3:"㎗";s:4:"dâ„“";s:3:"㎘";s:4:"kâ„“";s:3:"㎙";s:2:"fm";s:3:"㎚";s:2:"nm";s:3:"㎛";s:3:"μm";s:3:"㎜";s:2:"mm";s:3:"ãŽ";s:2:"cm";s:3:"㎞";s:2:"km";s:3:"㎟";s:4:"mm²";s:3:"㎠";s:4:"cm²";s:3:"㎡";s:3:"m²";s:3:"㎢";s:4:"km²";s:3:"㎣";s:4:"mm³";s:3:"㎤";s:4:"cm³";s:3:"㎥";s:3:"m³";s:3:"㎦";s:4:"km³";s:3:"㎧";s:5:"m∕s";s:3:"㎨";s:7:"m∕s²";s:3:"㎩";s:2:"Pa";s:3:"㎪";s:3:"kPa";s:3:"㎫";s:3:"MPa";s:3:"㎬";s:3:"GPa";s:3:"㎭";s:3:"rad";s:3:"㎮";s:7:"rad∕s";s:3:"㎯";s:9:"rad∕s²";s:3:"㎰";s:2:"ps";s:3:"㎱";s:2:"ns";s:3:"㎲";s:3:"μs";s:3:"㎳";s:2:"ms";s:3:"㎴";s:2:"pV";s:3:"㎵";s:2:"nV";s:3:"㎶";s:3:"μV";s:3:"㎷";s:2:"mV";s:3:"㎸";s:2:"kV";s:3:"㎹";s:2:"MV";s:3:"㎺";s:2:"pW";s:3:"㎻";s:2:"nW";s:3:"㎼";s:3:"μW";s:3:"㎽";s:2:"mW";s:3:"㎾";s:2:"kW";s:3:"㎿";s:2:"MW";s:3:"ã€";s:3:"kΩ";s:3:"ã";s:3:"MΩ";s:3:"ã‚";s:4:"a.m.";s:3:"ãƒ";s:2:"Bq";s:3:"ã„";s:2:"cc";s:3:"ã…";s:2:"cd";s:3:"ã†";s:6:"C∕kg";s:3:"ã‡";s:3:"Co.";s:3:"ãˆ";s:2:"dB";s:3:"ã‰";s:2:"Gy";s:3:"ãŠ";s:2:"ha";s:3:"ã‹";s:2:"HP";s:3:"ãŒ";s:2:"in";s:3:"ã";s:2:"KK";s:3:"ãŽ";s:2:"KM";s:3:"ã";s:2:"kt";s:3:"ã";s:2:"lm";s:3:"ã‘";s:2:"ln";s:3:"ã’";s:3:"log";s:3:"ã“";s:2:"lx";s:3:"ã”";s:2:"mb";s:3:"ã•";s:3:"mil";s:3:"ã–";s:3:"mol";s:3:"ã—";s:2:"PH";s:3:"ã˜";s:4:"p.m.";s:3:"ã™";s:3:"PPM";s:3:"ãš";s:2:"PR";s:3:"ã›";s:2:"sr";s:3:"ãœ";s:2:"Sv";s:3:"ã";s:2:"Wb";s:3:"ãž";s:5:"V∕m";s:3:"ãŸ";s:5:"A∕m";s:3:"ã ";s:4:"1æ—¥";s:3:"ã¡";s:4:"2æ—¥";s:3:"ã¢";s:4:"3æ—¥";s:3:"ã£";s:4:"4æ—¥";s:3:"ã¤";s:4:"5æ—¥";s:3:"ã¥";s:4:"6æ—¥";s:3:"ã¦";s:4:"7æ—¥";s:3:"ã§";s:4:"8æ—¥";s:3:"ã¨";s:4:"9æ—¥";s:3:"ã©";s:5:"10æ—¥";s:3:"ãª";s:5:"11æ—¥";s:3:"ã«";s:5:"12æ—¥";s:3:"ã¬";s:5:"13æ—¥";s:3:"ã­";s:5:"14æ—¥";s:3:"ã®";s:5:"15æ—¥";s:3:"ã¯";s:5:"16æ—¥";s:3:"ã°";s:5:"17æ—¥";s:3:"ã±";s:5:"18æ—¥";s:3:"ã²";s:5:"19æ—¥";s:3:"ã³";s:5:"20æ—¥";s:3:"ã´";s:5:"21æ—¥";s:3:"ãµ";s:5:"22æ—¥";s:3:"ã¶";s:5:"23æ—¥";s:3:"ã·";s:5:"24æ—¥";s:3:"ã¸";s:5:"25æ—¥";s:3:"ã¹";s:5:"26æ—¥";s:3:"ãº";s:5:"27æ—¥";s:3:"ã»";s:5:"28æ—¥";s:3:"ã¼";s:5:"29æ—¥";s:3:"ã½";s:5:"30æ—¥";s:3:"ã¾";s:5:"31æ—¥";s:3:"ã¿";s:3:"gal";s:3:"豈";s:3:"豈";s:3:"ï¤";s:3:"æ›´";s:3:"車";s:3:"車";s:3:"賈";s:3:"賈";s:3:"滑";s:3:"滑";s:3:"串";s:3:"串";s:3:"句";s:3:"å¥";s:3:"龜";s:3:"龜";s:3:"龜";s:3:"龜";s:3:"契";s:3:"契";s:3:"金";s:3:"金";s:3:"喇";s:3:"å–‡";s:3:"奈";s:3:"奈";s:3:"ï¤";s:3:"懶";s:3:"癩";s:3:"癩";s:3:"ï¤";s:3:"ç¾…";s:3:"ï¤";s:3:"蘿";s:3:"螺";s:3:"螺";s:3:"裸";s:3:"裸";s:3:"邏";s:3:"é‚";s:3:"樂";s:3:"樂";s:3:"洛";s:3:"æ´›";s:3:"烙";s:3:"烙";s:3:"珞";s:3:"çž";s:3:"落";s:3:"è½";s:3:"酪";s:3:"é…ª";s:3:"駱";s:3:"駱";s:3:"亂";s:3:"亂";s:3:"卵";s:3:"åµ";s:3:"ï¤";s:3:"欄";s:3:"爛";s:3:"爛";s:3:"蘭";s:3:"蘭";s:3:"鸞";s:3:"鸞";s:3:"嵐";s:3:"åµ";s:3:"濫";s:3:"æ¿«";s:3:"藍";s:3:"è—";s:3:"襤";s:3:"襤";s:3:"拉";s:3:"拉";s:3:"臘";s:3:"臘";s:3:"蠟";s:3:"è Ÿ";s:3:"廊";s:3:"廊";s:3:"朗";s:3:"朗";s:3:"浪";s:3:"浪";s:3:"狼";s:3:"狼";s:3:"郎";s:3:"郎";s:3:"來";s:3:"來";s:3:"冷";s:3:"冷";s:3:"勞";s:3:"å‹ž";s:3:"擄";s:3:"æ“„";s:3:"櫓";s:3:"æ«“";s:3:"爐";s:3:"çˆ";s:3:"盧";s:3:"盧";s:3:"老";s:3:"è€";s:3:"蘆";s:3:"蘆";s:3:"虜";s:3:"虜";s:3:"路";s:3:"è·¯";s:3:"露";s:3:"露";s:3:"魯";s:3:"é­¯";s:3:"鷺";s:3:"é·º";s:3:"碌";s:3:"碌";s:3:"祿";s:3:"祿";s:3:"綠";s:3:"綠";s:3:"菉";s:3:"è‰";s:3:"錄";s:3:"錄";s:3:"鹿";s:3:"鹿";s:3:"ï¥";s:3:"è«–";s:3:"壟";s:3:"壟";s:3:"弄";s:3:"弄";s:3:"籠";s:3:"ç± ";s:3:"聾";s:3:"è¾";s:3:"牢";s:3:"牢";s:3:"磊";s:3:"磊";s:3:"賂";s:3:"賂";s:3:"雷";s:3:"é›·";s:3:"壘";s:3:"壘";s:3:"屢";s:3:"å±¢";s:3:"樓";s:3:"樓";s:3:"ï¥";s:3:"æ·š";s:3:"漏";s:3:"æ¼";s:3:"ï¥";s:3:"ç´¯";s:3:"ï¥";s:3:"縷";s:3:"陋";s:3:"陋";s:3:"勒";s:3:"å‹’";s:3:"肋";s:3:"è‚‹";s:3:"凜";s:3:"凜";s:3:"凌";s:3:"凌";s:3:"稜";s:3:"稜";s:3:"綾";s:3:"綾";s:3:"菱";s:3:"è±";s:3:"陵";s:3:"陵";s:3:"讀";s:3:"讀";s:3:"拏";s:3:"æ‹";s:3:"樂";s:3:"樂";s:3:"ï¥";s:3:"諾";s:3:"丹";s:3:"丹";s:3:"寧";s:3:"寧";s:3:"怒";s:3:"怒";s:3:"率";s:3:"率";s:3:"異";s:3:"ç•°";s:3:"北";s:3:"北";s:3:"磻";s:3:"磻";s:3:"便";s:3:"便";s:3:"復";s:3:"復";s:3:"不";s:3:"ä¸";s:3:"泌";s:3:"泌";s:3:"數";s:3:"數";s:3:"索";s:3:"ç´¢";s:3:"參";s:3:"åƒ";s:3:"塞";s:3:"å¡ž";s:3:"省";s:3:"çœ";s:3:"葉";s:3:"葉";s:3:"說";s:3:"說";s:3:"殺";s:3:"殺";s:3:"辰";s:3:"è¾°";s:3:"沈";s:3:"沈";s:3:"拾";s:3:"拾";s:3:"若";s:3:"è‹¥";s:3:"掠";s:3:"掠";s:3:"略";s:3:"ç•¥";s:3:"亮";s:3:"亮";s:3:"兩";s:3:"å…©";s:3:"凉";s:3:"凉";s:3:"梁";s:3:"æ¢";s:3:"糧";s:3:"糧";s:3:"良";s:3:"良";s:3:"諒";s:3:"è«’";s:3:"量";s:3:"é‡";s:3:"勵";s:3:"勵";s:3:"呂";s:3:"å‘‚";s:3:"ï¦";s:3:"女";s:3:"廬";s:3:"廬";s:3:"旅";s:3:"æ—…";s:3:"濾";s:3:"濾";s:3:"礪";s:3:"礪";s:3:"閭";s:3:"é–­";s:3:"驪";s:3:"驪";s:3:"麗";s:3:"麗";s:3:"黎";s:3:"黎";s:3:"力";s:3:"力";s:3:"曆";s:3:"曆";s:3:"歷";s:3:"æ­·";s:3:"ï¦";s:3:"è½¢";s:3:"年";s:3:"å¹´";s:3:"ï¦";s:3:"æ†";s:3:"ï¦";s:3:"戀";s:3:"撚";s:3:"æ’š";s:3:"漣";s:3:"æ¼£";s:3:"煉";s:3:"ç…‰";s:3:"璉";s:3:"ç’‰";s:3:"秊";s:3:"秊";s:3:"練";s:3:"ç·´";s:3:"聯";s:3:"è¯";s:3:"輦";s:3:"輦";s:3:"蓮";s:3:"è“®";s:3:"連";s:3:"連";s:3:"鍊";s:3:"éŠ";s:3:"列";s:3:"列";s:3:"ï¦";s:3:"劣";s:3:"咽";s:3:"å’½";s:3:"烈";s:3:"烈";s:3:"裂";s:3:"裂";s:3:"說";s:3:"說";s:3:"廉";s:3:"廉";s:3:"念";s:3:"念";s:3:"捻";s:3:"æ»";s:3:"殮";s:3:"æ®®";s:3:"簾";s:3:"ç°¾";s:3:"獵";s:3:"çµ";s:3:"令";s:3:"令";s:3:"囹";s:3:"囹";s:3:"寧";s:3:"寧";s:3:"嶺";s:3:"嶺";s:3:"怜";s:3:"怜";s:3:"玲";s:3:"玲";s:3:"瑩";s:3:"ç‘©";s:3:"羚";s:3:"羚";s:3:"聆";s:3:"è†";s:3:"鈴";s:3:"鈴";s:3:"零";s:3:"零";s:3:"靈";s:3:"éˆ";s:3:"領";s:3:"é ˜";s:3:"例";s:3:"例";s:3:"禮";s:3:"禮";s:3:"醴";s:3:"醴";s:3:"隸";s:3:"隸";s:3:"惡";s:3:"惡";s:3:"了";s:3:"了";s:3:"僚";s:3:"僚";s:3:"寮";s:3:"寮";s:3:"尿";s:3:"å°¿";s:3:"料";s:3:"æ–™";s:3:"樂";s:3:"樂";s:3:"燎";s:3:"燎";s:3:"ï§";s:3:"療";s:3:"蓼";s:3:"蓼";s:3:"遼";s:3:"é¼";s:3:"龍";s:3:"é¾";s:3:"暈";s:3:"暈";s:3:"阮";s:3:"阮";s:3:"劉";s:3:"劉";s:3:"杻";s:3:"æ»";s:3:"柳";s:3:"柳";s:3:"流";s:3:"æµ";s:3:"溜";s:3:"溜";s:3:"琉";s:3:"ç‰";s:3:"ï§";s:3:"ç•™";s:3:"硫";s:3:"ç¡«";s:3:"ï§";s:3:"ç´";s:3:"ï§";s:3:"é¡ž";s:3:"六";s:3:"å…­";s:3:"戮";s:3:"戮";s:3:"陸";s:3:"陸";s:3:"倫";s:3:"倫";s:3:"崙";s:3:"å´™";s:3:"淪";s:3:"æ·ª";s:3:"輪";s:3:"輪";s:3:"律";s:3:"律";s:3:"慄";s:3:"æ…„";s:3:"栗";s:3:"æ —";s:3:"率";s:3:"率";s:3:"隆";s:3:"隆";s:3:"ï§";s:3:"利";s:3:"吏";s:3:"å";s:3:"履";s:3:"å±¥";s:3:"易";s:3:"易";s:3:"李";s:3:"æŽ";s:3:"梨";s:3:"梨";s:3:"泥";s:3:"æ³¥";s:3:"理";s:3:"ç†";s:3:"痢";s:3:"ç—¢";s:3:"罹";s:3:"ç½¹";s:3:"裏";s:3:"è£";s:3:"裡";s:3:"裡";s:3:"里";s:3:"里";s:3:"離";s:3:"離";s:3:"匿";s:3:"匿";s:3:"溺";s:3:"溺";s:3:"吝";s:3:"å";s:3:"燐";s:3:"ç‡";s:3:"璘";s:3:"ç’˜";s:3:"藺";s:3:"è—º";s:3:"隣";s:3:"隣";s:3:"鱗";s:3:"é±—";s:3:"麟";s:3:"麟";s:3:"林";s:3:"æž—";s:3:"淋";s:3:"æ·‹";s:3:"臨";s:3:"臨";s:3:"立";s:3:"ç«‹";s:3:"笠";s:3:"笠";s:3:"粒";s:3:"ç²’";s:3:"狀";s:3:"ç‹€";s:3:"炙";s:3:"ç‚™";s:3:"識";s:3:"è­˜";s:3:"什";s:3:"什";s:3:"茶";s:3:"茶";s:3:"刺";s:3:"刺";s:3:"切";s:3:"切";s:3:"ï¨";s:3:"度";s:3:"拓";s:3:"æ‹“";s:3:"糖";s:3:"ç³–";s:3:"宅";s:3:"å®…";s:3:"洞";s:3:"æ´ž";s:3:"暴";s:3:"æš´";s:3:"輻";s:3:"è¼»";s:3:"行";s:3:"è¡Œ";s:3:"降";s:3:"é™";s:3:"見";s:3:"見";s:3:"廓";s:3:"廓";s:3:"兀";s:3:"å…€";s:3:"ï¨";s:3:"å—€";s:3:"﨎";s:1:"";s:3:"ï¨";s:1:"";s:3:"ï¨";s:3:"å¡š";s:3:"﨑";s:1:"";s:3:"晴";s:3:"æ™´";s:3:"﨓";s:1:"";s:3:"﨔";s:1:"";s:3:"凞";s:3:"凞";s:3:"猪";s:3:"猪";s:3:"益";s:3:"益";s:3:"礼";s:3:"礼";s:3:"神";s:3:"神";s:3:"祥";s:3:"祥";s:3:"福";s:3:"ç¦";s:3:"靖";s:3:"é–";s:3:"ï¨";s:3:"ç²¾";s:3:"羽";s:3:"ç¾½";s:3:"﨟";s:1:"";s:3:"蘒";s:3:"蘒";s:3:"﨡";s:1:"";s:3:"諸";s:3:"諸";s:3:"﨣";s:1:"";s:3:"﨤";s:1:"";s:3:"逸";s:3:"逸";s:3:"都";s:3:"都";s:3:"﨧";s:1:"";s:3:"﨨";s:1:"";s:3:"﨩";s:1:"";s:3:"飯";s:3:"飯";s:3:"飼";s:3:"飼";s:3:"館";s:3:"館";s:3:"鶴";s:3:"鶴";s:3:"郞";s:3:"郞";s:3:"隷";s:3:"éš·";s:3:"侮";s:3:"ä¾®";s:3:"僧";s:3:"僧";s:3:"免";s:3:"å…";s:3:"勉";s:3:"勉";s:3:"勤";s:3:"勤";s:3:"卑";s:3:"å‘";s:3:"喝";s:3:"å–";s:3:"嘆";s:3:"嘆";s:3:"器";s:3:"器";s:3:"塀";s:3:"å¡€";s:3:"墨";s:3:"墨";s:3:"層";s:3:"層";s:3:"屮";s:3:"å±®";s:3:"悔";s:3:"æ‚”";s:3:"慨";s:3:"æ…¨";s:3:"憎";s:3:"憎";s:3:"ï©€";s:3:"懲";s:3:"ï©";s:3:"æ•";s:3:"ï©‚";s:3:"æ—¢";s:3:"暑";s:3:"æš‘";s:3:"ï©„";s:3:"梅";s:3:"ï©…";s:3:"æµ·";s:3:"渚";s:3:"渚";s:3:"漢";s:3:"æ¼¢";s:3:"煮";s:3:"ç…®";s:3:"爫";s:3:"爫";s:3:"ï©Š";s:3:"ç¢";s:3:"ï©‹";s:3:"碑";s:3:"ï©Œ";s:3:"社";s:3:"ï©";s:3:"祉";s:3:"ï©Ž";s:3:"祈";s:3:"ï©";s:3:"ç¥";s:3:"ï©";s:3:"祖";s:3:"ï©‘";s:3:"ç¥";s:3:"ï©’";s:3:"ç¦";s:3:"ï©“";s:3:"禎";s:3:"ï©”";s:3:"ç©€";s:3:"ï©•";s:3:"çª";s:3:"ï©–";s:3:"節";s:3:"ï©—";s:3:"ç·´";s:3:"縉";s:3:"縉";s:3:"ï©™";s:3:"ç¹";s:3:"ï©š";s:3:"ç½²";s:3:"ï©›";s:3:"者";s:3:"ï©œ";s:3:"臭";s:3:"ï©";s:3:"艹";s:3:"ï©ž";s:3:"艹";s:3:"ï©Ÿ";s:3:"è‘—";s:3:"ï© ";s:3:"è¤";s:3:"ï©¡";s:3:"視";s:3:"ï©¢";s:3:"è¬";s:3:"ï©£";s:3:"謹";s:3:"賓";s:3:"賓";s:3:"ï©¥";s:3:"è´ˆ";s:3:"辶";s:3:"辶";s:3:"逸";s:3:"逸";s:3:"難";s:3:"難";s:3:"ï©©";s:3:"響";s:3:"頻";s:3:"é »";s:3:"ï©«";s:3:"æµ";s:3:"𤋮";s:4:"𤋮";s:3:"ï©­";s:3:"舘";s:3:"ï©°";s:3:"並";s:3:"况";s:3:"况";s:3:"全";s:3:"å…¨";s:3:"侀";s:3:"ä¾€";s:3:"ï©´";s:3:"å……";s:3:"冀";s:3:"冀";s:3:"勇";s:3:"勇";s:3:"ï©·";s:3:"勺";s:3:"喝";s:3:"å–";s:3:"啕";s:3:"å••";s:3:"喙";s:3:"å–™";s:3:"ï©»";s:3:"å—¢";s:3:"塚";s:3:"å¡š";s:3:"墳";s:3:"墳";s:3:"奄";s:3:"奄";s:3:"ï©¿";s:3:"奔";s:3:"婢";s:3:"å©¢";s:3:"ïª";s:3:"嬨";s:3:"廒";s:3:"å»’";s:3:"廙";s:3:"å»™";s:3:"彩";s:3:"彩";s:3:"徭";s:3:"å¾­";s:3:"惘";s:3:"惘";s:3:"慎";s:3:"æ…Ž";s:3:"愈";s:3:"愈";s:3:"憎";s:3:"憎";s:3:"慠";s:3:"æ… ";s:3:"懲";s:3:"懲";s:3:"戴";s:3:"戴";s:3:"ïª";s:3:"æ„";s:3:"搜";s:3:"æœ";s:3:"ïª";s:3:"æ‘’";s:3:"ïª";s:3:"æ•–";s:3:"晴";s:3:"æ™´";s:3:"朗";s:3:"朗";s:3:"望";s:3:"望";s:3:"杖";s:3:"æ–";s:3:"歹";s:3:"æ­¹";s:3:"殺";s:3:"殺";s:3:"流";s:3:"æµ";s:3:"滛";s:3:"æ»›";s:3:"滋";s:3:"滋";s:3:"漢";s:3:"æ¼¢";s:3:"瀞";s:3:"瀞";s:3:"煮";s:3:"ç…®";s:3:"ïª";s:3:"瞧";s:3:"爵";s:3:"爵";s:3:"犯";s:3:"犯";s:3:"猪";s:3:"猪";s:3:"瑱";s:3:"瑱";s:3:"甆";s:3:"甆";s:3:"画";s:3:"ç”»";s:3:"瘝";s:3:"ç˜";s:3:"瘟";s:3:"瘟";s:3:"益";s:3:"益";s:3:"盛";s:3:"ç››";s:3:"直";s:3:"ç›´";s:3:"睊";s:3:"çŠ";s:3:"着";s:3:"ç€";s:3:"磌";s:3:"磌";s:3:"窱";s:3:"窱";s:3:"節";s:3:"節";s:3:"类";s:3:"ç±»";s:3:"絛";s:3:"çµ›";s:3:"練";s:3:"ç·´";s:3:"缾";s:3:"ç¼¾";s:3:"者";s:3:"者";s:3:"荒";s:3:"è’";s:3:"華";s:3:"è¯";s:3:"蝹";s:3:"è¹";s:3:"襁";s:3:"è¥";s:3:"覆";s:3:"覆";s:3:"視";s:3:"視";s:3:"調";s:3:"調";s:3:"諸";s:3:"諸";s:3:"請";s:3:"è«‹";s:3:"謁";s:3:"è¬";s:3:"諾";s:3:"諾";s:3:"諭";s:3:"è«­";s:3:"謹";s:3:"謹";s:3:"ï«€";s:3:"變";s:3:"ï«";s:3:"è´ˆ";s:3:"ï«‚";s:3:"輸";s:3:"遲";s:3:"é²";s:3:"ï«„";s:3:"醙";s:3:"ï«…";s:3:"鉶";s:3:"陼";s:3:"陼";s:3:"難";s:3:"難";s:3:"靖";s:3:"é–";s:3:"韛";s:3:"韛";s:3:"ï«Š";s:3:"響";s:3:"ï«‹";s:3:"é ‹";s:3:"ï«Œ";s:3:"é »";s:3:"ï«";s:3:"鬒";s:3:"ï«Ž";s:3:"龜";s:3:"ï«";s:4:"𢡊";s:3:"ï«";s:4:"𢡄";s:3:"ï«‘";s:4:"ð£•";s:3:"ï«’";s:3:"ã®";s:3:"ï«“";s:3:"䀘";s:3:"ï«”";s:3:"䀹";s:3:"ï«•";s:4:"𥉉";s:3:"ï«–";s:4:"ð¥³";s:3:"ï«—";s:4:"𧻓";s:3:"齃";s:3:"齃";s:3:"ï«™";s:3:"龎";s:3:"ff";s:2:"ff";s:3:"ï¬";s:2:"fi";s:3:"fl";s:2:"fl";s:3:"ffi";s:3:"ffi";s:3:"ffl";s:3:"ffl";s:3:"ſt";s:3:"Å¿t";s:3:"st";s:2:"st";s:3:"ﬓ";s:4:"Õ´Õ¶";s:3:"ﬔ";s:4:"Õ´Õ¥";s:3:"ﬕ";s:4:"Õ´Õ«";s:3:"ﬖ";s:4:"Õ¾Õ¶";s:3:"ﬗ";s:4:"Õ´Õ­";s:3:"ﬠ";s:2:"×¢";s:3:"ﬡ";s:2:"×";s:3:"ﬢ";s:2:"ד";s:3:"ﬣ";s:2:"×”";s:3:"ﬤ";s:2:"×›";s:3:"ﬥ";s:2:"ל";s:3:"ﬦ";s:2:"×";s:3:"ﬧ";s:2:"ר";s:3:"ﬨ";s:2:"ת";s:3:"﬩";s:1:"+";s:3:"ï­";s:4:"×ל";s:3:"﹉";s:3:"‾";s:3:"﹊";s:3:"‾";s:3:"﹋";s:3:"‾";s:3:"﹌";s:3:"‾";s:3:"ï¹";s:1:"_";s:3:"﹎";s:1:"_";s:3:"ï¹";s:1:"_";s:3:"ï¹";s:1:",";s:3:"﹑";s:3:"ã€";s:3:"ï¹’";s:1:".";s:3:"ï¹”";s:1:";";s:3:"﹕";s:1:":";s:3:"ï¹–";s:1:"?";s:3:"ï¹—";s:1:"!";s:3:"﹘";s:3:"—";s:3:"ï¹™";s:1:"(";s:3:"﹚";s:1:")";s:3:"ï¹›";s:1:"{";s:3:"﹜";s:1:"}";s:3:"ï¹";s:3:"〔";s:3:"﹞";s:3:"〕";s:3:"﹟";s:1:"#";s:3:"ï¹ ";s:1:"&";s:3:"﹡";s:1:"*";s:3:"ï¹¢";s:1:"+";s:3:"ï¹£";s:1:"-";s:3:"﹤";s:1:"<";s:3:"ï¹¥";s:1:">";s:3:"﹦";s:1:"=";s:3:"﹨";s:1:"\";s:3:"﹩";s:1:"$";s:3:"﹪";s:1:"%";s:3:"﹫";s:1:"@";s:3:"ï¼";s:1:"!";s:3:""";s:1:""";s:3:"#";s:1:"#";s:3:"$";s:1:"$";s:3:"ï¼…";s:1:"%";s:3:"&";s:1:"&";s:3:"'";s:1:"'";s:3:"(";s:1:"(";s:3:")";s:1:")";s:3:"*";s:1:"*";s:3:"+";s:1:"+";s:3:",";s:1:",";s:3:"ï¼";s:1:"-";s:3:".";s:1:".";s:3:"ï¼";s:1:"/";s:3:"ï¼";s:1:"0";s:3:"1";s:1:"1";s:3:"ï¼’";s:1:"2";s:3:"3";s:1:"3";s:3:"ï¼”";s:1:"4";s:3:"5";s:1:"5";s:3:"ï¼–";s:1:"6";s:3:"ï¼—";s:1:"7";s:3:"8";s:1:"8";s:3:"ï¼™";s:1:"9";s:3:":";s:1:":";s:3:"ï¼›";s:1:";";s:3:"<";s:1:"<";s:3:"ï¼";s:1:"=";s:3:">";s:1:">";s:3:"?";s:1:"?";s:3:"ï¼ ";s:1:"@";s:3:"A";s:1:"A";s:3:"ï¼¢";s:1:"B";s:3:"ï¼£";s:1:"C";s:3:"D";s:1:"D";s:3:"ï¼¥";s:1:"E";s:3:"F";s:1:"F";s:3:"G";s:1:"G";s:3:"H";s:1:"H";s:3:"I";s:1:"I";s:3:"J";s:1:"J";s:3:"K";s:1:"K";s:3:"L";s:1:"L";s:3:"ï¼­";s:1:"M";s:3:"ï¼®";s:1:"N";s:3:"O";s:1:"O";s:3:"ï¼°";s:1:"P";s:3:"ï¼±";s:1:"Q";s:3:"ï¼²";s:1:"R";s:3:"ï¼³";s:1:"S";s:3:"ï¼´";s:1:"T";s:3:"ï¼µ";s:1:"U";s:3:"V";s:1:"V";s:3:"ï¼·";s:1:"W";s:3:"X";s:1:"X";s:3:"ï¼¹";s:1:"Y";s:3:"Z";s:1:"Z";s:3:"ï¼»";s:1:"[";s:3:"ï¼¼";s:1:"\";s:3:"ï¼½";s:1:"]";s:3:"ï¼¾";s:1:"^";s:3:"_";s:1:"_";s:3:"ï½€";s:1:"`";s:3:"ï½";s:1:"a";s:3:"b";s:1:"b";s:3:"c";s:1:"c";s:3:"d";s:1:"d";s:3:"ï½…";s:1:"e";s:3:"f";s:1:"f";s:3:"g";s:1:"g";s:3:"h";s:1:"h";s:3:"i";s:1:"i";s:3:"j";s:1:"j";s:3:"k";s:1:"k";s:3:"l";s:1:"l";s:3:"ï½";s:1:"m";s:3:"n";s:1:"n";s:3:"ï½";s:1:"o";s:3:"ï½";s:1:"p";s:3:"q";s:1:"q";s:3:"ï½’";s:1:"r";s:3:"s";s:1:"s";s:3:"ï½”";s:1:"t";s:3:"u";s:1:"u";s:3:"ï½–";s:1:"v";s:3:"ï½—";s:1:"w";s:3:"x";s:1:"x";s:3:"ï½™";s:1:"y";s:3:"z";s:1:"z";s:3:"ï½›";s:1:"{";s:3:"|";s:1:"|";s:3:"ï½";s:1:"}";s:3:"~";s:1:"~";s:3:"⦅";s:3:"⦅";s:3:"ï½ ";s:3:"⦆";s:3:"。";s:3:"。";s:3:"ï½¢";s:3:"「";s:3:"ï½£";s:3:"ã€";s:3:"、";s:3:"ã€";s:3:"ï½¥";s:3:"・";s:3:"ヲ";s:3:"ヲ";s:3:"ァ";s:3:"ã‚¡";s:3:"ィ";s:3:"ã‚£";s:3:"ゥ";s:3:"ã‚¥";s:3:"ェ";s:3:"ェ";s:3:"ォ";s:3:"ã‚©";s:3:"ャ";s:3:"ャ";s:3:"ï½­";s:3:"ュ";s:3:"ï½®";s:3:"ョ";s:3:"ッ";s:3:"ッ";s:3:"ï½°";s:3:"ー";s:3:"ï½±";s:3:"ã‚¢";s:3:"ï½²";s:3:"イ";s:3:"ï½³";s:3:"ウ";s:3:"ï½´";s:3:"エ";s:3:"ï½µ";s:3:"オ";s:3:"カ";s:3:"ã‚«";s:3:"ï½·";s:3:"ã‚­";s:3:"ク";s:3:"ク";s:3:"ï½¹";s:3:"ケ";s:3:"コ";s:3:"コ";s:3:"ï½»";s:3:"サ";s:3:"ï½¼";s:3:"ã‚·";s:3:"ï½½";s:3:"ス";s:3:"ï½¾";s:3:"ã‚»";s:3:"ソ";s:3:"ソ";s:3:"ï¾€";s:3:"ã‚¿";s:3:"ï¾";s:3:"ãƒ";s:3:"ツ";s:3:"ツ";s:3:"テ";s:3:"テ";s:3:"ト";s:3:"ト";s:3:"ï¾…";s:3:"ナ";s:3:"ニ";s:3:"ニ";s:3:"ヌ";s:3:"ヌ";s:3:"ネ";s:3:"ãƒ";s:3:"ノ";s:3:"ノ";s:3:"ハ";s:3:"ãƒ";s:3:"ヒ";s:3:"ヒ";s:3:"フ";s:3:"フ";s:3:"ï¾";s:3:"ヘ";s:3:"ホ";s:3:"ホ";s:3:"ï¾";s:3:"マ";s:3:"ï¾";s:3:"ミ";s:3:"ム";s:3:"ム";s:3:"ï¾’";s:3:"メ";s:3:"モ";s:3:"モ";s:3:"ï¾”";s:3:"ヤ";s:3:"ユ";s:3:"ユ";s:3:"ï¾–";s:3:"ヨ";s:3:"ï¾—";s:3:"ラ";s:3:"リ";s:3:"リ";s:3:"ï¾™";s:3:"ル";s:3:"レ";s:3:"レ";s:3:"ï¾›";s:3:"ロ";s:3:"ワ";s:3:"ワ";s:3:"ï¾";s:3:"ン";s:3:"゙";s:3:"ã‚™";s:3:"゚";s:3:"ã‚š";s:3:"ï¾ ";s:3:"ã…¤";s:3:"ᄀ";s:3:"ㄱ";s:3:"ï¾¢";s:3:"ㄲ";s:3:"ï¾£";s:3:"ㄳ";s:3:"ᄂ";s:3:"ã„´";s:3:"ï¾¥";s:3:"ㄵ";s:3:"ᆭ";s:3:"ㄶ";s:3:"ᄃ";s:3:"ã„·";s:3:"ᄄ";s:3:"ㄸ";s:3:"ᄅ";s:3:"ㄹ";s:3:"ᆰ";s:3:"ㄺ";s:3:"ᆱ";s:3:"ã„»";s:3:"ᆲ";s:3:"ㄼ";s:3:"ï¾­";s:3:"ㄽ";s:3:"ï¾®";s:3:"ㄾ";s:3:"ᆵ";s:3:"ã„¿";s:3:"ï¾°";s:3:"ã…€";s:3:"ï¾±";s:3:"ã…";s:3:"ï¾²";s:3:"ã…‚";s:3:"ï¾³";s:3:"ã…ƒ";s:3:"ï¾´";s:3:"ã…„";s:3:"ï¾µ";s:3:"ã……";s:3:"ᄊ";s:3:"ã…†";s:3:"ï¾·";s:3:"ã…‡";s:3:"ᄌ";s:3:"ã…ˆ";s:3:"ï¾¹";s:3:"ã…‰";s:3:"ᄎ";s:3:"ã…Š";s:3:"ï¾»";s:3:"ã…‹";s:3:"ï¾¼";s:3:"ã…Œ";s:3:"ï¾½";s:3:"ã…";s:3:"ï¾¾";s:3:"ã…Ž";s:3:"ï¿‚";s:3:"ã…";s:3:"ᅢ";s:3:"ã…";s:3:"ï¿„";s:3:"ã…‘";s:3:"ï¿…";s:3:"ã…’";s:3:"ᅥ";s:3:"ã…“";s:3:"ᅦ";s:3:"ã…”";s:3:"ï¿Š";s:3:"ã…•";s:3:"ï¿‹";s:3:"ã…–";s:3:"ï¿Œ";s:3:"ã…—";s:3:"ï¿";s:3:"ã…˜";s:3:"ï¿Ž";s:3:"ã…™";s:3:"ï¿";s:3:"ã…š";s:3:"ï¿’";s:3:"ã…›";s:3:"ï¿“";s:3:"ã…œ";s:3:"ï¿”";s:3:"ã…";s:3:"ï¿•";s:3:"ã…ž";s:3:"ï¿–";s:3:"ã…Ÿ";s:3:"ï¿—";s:3:"ã… ";s:3:"ï¿š";s:3:"ã…¡";s:3:"ï¿›";s:3:"ã…¢";s:3:"ï¿œ";s:3:"ã…£";s:3:"ï¿ ";s:2:"¢";s:3:"ï¿¡";s:2:"£";s:3:"ï¿¢";s:2:"¬";s:3:"ï¿£";s:2:"¯";s:3:"¦";s:2:"¦";s:3:"ï¿¥";s:2:"Â¥";s:3:"₩";s:3:"â‚©";s:3:"│";s:3:"│";s:3:"ï¿©";s:3:"â†";s:3:"↑";s:3:"↑";s:3:"ï¿«";s:3:"→";s:3:"↓";s:3:"↓";s:3:"ï¿­";s:3:"â– ";s:3:"ï¿®";s:3:"â—‹";s:4:"ð€";s:1:"A";s:4:"ð";s:1:"B";s:4:"ð‚";s:1:"C";s:4:"ðƒ";s:1:"D";s:4:"ð„";s:1:"E";s:4:"ð…";s:1:"F";s:4:"ð†";s:1:"G";s:4:"ð‡";s:1:"H";s:4:"ðˆ";s:1:"I";s:4:"ð‰";s:1:"J";s:4:"ðŠ";s:1:"K";s:4:"ð‹";s:1:"L";s:4:"ðŒ";s:1:"M";s:4:"ð";s:1:"N";s:4:"ðŽ";s:1:"O";s:4:"ð";s:1:"P";s:4:"ð";s:1:"Q";s:4:"ð‘";s:1:"R";s:4:"ð’";s:1:"S";s:4:"ð“";s:1:"T";s:4:"ð”";s:1:"U";s:4:"ð•";s:1:"V";s:4:"ð–";s:1:"W";s:4:"ð—";s:1:"X";s:4:"ð˜";s:1:"Y";s:4:"ð™";s:1:"Z";s:4:"ðš";s:1:"a";s:4:"ð›";s:1:"b";s:4:"ðœ";s:1:"c";s:4:"ð";s:1:"d";s:4:"ðž";s:1:"e";s:4:"ðŸ";s:1:"f";s:4:"ð ";s:1:"g";s:4:"ð¡";s:1:"h";s:4:"ð¢";s:1:"i";s:4:"ð£";s:1:"j";s:4:"ð¤";s:1:"k";s:4:"ð¥";s:1:"l";s:4:"ð¦";s:1:"m";s:4:"ð§";s:1:"n";s:4:"ð¨";s:1:"o";s:4:"ð©";s:1:"p";s:4:"ðª";s:1:"q";s:4:"ð«";s:1:"r";s:4:"ð¬";s:1:"s";s:4:"ð­";s:1:"t";s:4:"ð®";s:1:"u";s:4:"ð¯";s:1:"v";s:4:"ð°";s:1:"w";s:4:"ð±";s:1:"x";s:4:"ð²";s:1:"y";s:4:"ð³";s:1:"z";s:4:"ð´";s:1:"A";s:4:"ðµ";s:1:"B";s:4:"ð¶";s:1:"C";s:4:"ð·";s:1:"D";s:4:"ð¸";s:1:"E";s:4:"ð¹";s:1:"F";s:4:"ðº";s:1:"G";s:4:"ð»";s:1:"H";s:4:"ð¼";s:1:"I";s:4:"ð½";s:1:"J";s:4:"ð¾";s:1:"K";s:4:"ð¿";s:1:"L";s:4:"ð‘€";s:1:"M";s:4:"ð‘";s:1:"N";s:4:"ð‘‚";s:1:"O";s:4:"ð‘ƒ";s:1:"P";s:4:"ð‘„";s:1:"Q";s:4:"ð‘…";s:1:"R";s:4:"ð‘†";s:1:"S";s:4:"ð‘‡";s:1:"T";s:4:"ð‘ˆ";s:1:"U";s:4:"ð‘‰";s:1:"V";s:4:"ð‘Š";s:1:"W";s:4:"ð‘‹";s:1:"X";s:4:"ð‘Œ";s:1:"Y";s:4:"ð‘";s:1:"Z";s:4:"ð‘Ž";s:1:"a";s:4:"ð‘";s:1:"b";s:4:"ð‘";s:1:"c";s:4:"ð‘‘";s:1:"d";s:4:"ð‘’";s:1:"e";s:4:"ð‘“";s:1:"f";s:4:"ð‘”";s:1:"g";s:4:"ð‘–";s:1:"i";s:4:"ð‘—";s:1:"j";s:4:"ð‘˜";s:1:"k";s:4:"ð‘™";s:1:"l";s:4:"ð‘š";s:1:"m";s:4:"ð‘›";s:1:"n";s:4:"ð‘œ";s:1:"o";s:4:"ð‘";s:1:"p";s:4:"ð‘ž";s:1:"q";s:4:"ð‘Ÿ";s:1:"r";s:4:"ð‘ ";s:1:"s";s:4:"ð‘¡";s:1:"t";s:4:"ð‘¢";s:1:"u";s:4:"ð‘£";s:1:"v";s:4:"ð‘¤";s:1:"w";s:4:"ð‘¥";s:1:"x";s:4:"ð‘¦";s:1:"y";s:4:"ð‘§";s:1:"z";s:4:"ð‘¨";s:1:"A";s:4:"ð‘©";s:1:"B";s:4:"ð‘ª";s:1:"C";s:4:"ð‘«";s:1:"D";s:4:"ð‘¬";s:1:"E";s:4:"ð‘­";s:1:"F";s:4:"ð‘®";s:1:"G";s:4:"ð‘¯";s:1:"H";s:4:"ð‘°";s:1:"I";s:4:"ð‘±";s:1:"J";s:4:"ð‘²";s:1:"K";s:4:"ð‘³";s:1:"L";s:4:"ð‘´";s:1:"M";s:4:"ð‘µ";s:1:"N";s:4:"ð‘¶";s:1:"O";s:4:"ð‘·";s:1:"P";s:4:"ð‘¸";s:1:"Q";s:4:"ð‘¹";s:1:"R";s:4:"ð‘º";s:1:"S";s:4:"ð‘»";s:1:"T";s:4:"ð‘¼";s:1:"U";s:4:"ð‘½";s:1:"V";s:4:"ð‘¾";s:1:"W";s:4:"ð‘¿";s:1:"X";s:4:"ð’€";s:1:"Y";s:4:"ð’";s:1:"Z";s:4:"ð’‚";s:1:"a";s:4:"ð’ƒ";s:1:"b";s:4:"ð’„";s:1:"c";s:4:"ð’…";s:1:"d";s:4:"ð’†";s:1:"e";s:4:"ð’‡";s:1:"f";s:4:"ð’ˆ";s:1:"g";s:4:"ð’‰";s:1:"h";s:4:"ð’Š";s:1:"i";s:4:"ð’‹";s:1:"j";s:4:"ð’Œ";s:1:"k";s:4:"ð’";s:1:"l";s:4:"ð’Ž";s:1:"m";s:4:"ð’";s:1:"n";s:4:"ð’";s:1:"o";s:4:"ð’‘";s:1:"p";s:4:"ð’’";s:1:"q";s:4:"ð’“";s:1:"r";s:4:"ð’”";s:1:"s";s:4:"ð’•";s:1:"t";s:4:"ð’–";s:1:"u";s:4:"ð’—";s:1:"v";s:4:"ð’˜";s:1:"w";s:4:"ð’™";s:1:"x";s:4:"ð’š";s:1:"y";s:4:"ð’›";s:1:"z";s:4:"ð’œ";s:1:"A";s:4:"ð’ž";s:1:"C";s:4:"ð’Ÿ";s:1:"D";s:4:"ð’¢";s:1:"G";s:4:"ð’¥";s:1:"J";s:4:"ð’¦";s:1:"K";s:4:"ð’©";s:1:"N";s:4:"ð’ª";s:1:"O";s:4:"ð’«";s:1:"P";s:4:"ð’¬";s:1:"Q";s:4:"ð’®";s:1:"S";s:4:"ð’¯";s:1:"T";s:4:"ð’°";s:1:"U";s:4:"ð’±";s:1:"V";s:4:"ð’²";s:1:"W";s:4:"ð’³";s:1:"X";s:4:"ð’´";s:1:"Y";s:4:"ð’µ";s:1:"Z";s:4:"ð’¶";s:1:"a";s:4:"ð’·";s:1:"b";s:4:"ð’¸";s:1:"c";s:4:"ð’¹";s:1:"d";s:4:"ð’»";s:1:"f";s:4:"ð’½";s:1:"h";s:4:"ð’¾";s:1:"i";s:4:"ð’¿";s:1:"j";s:4:"ð“€";s:1:"k";s:4:"ð“";s:1:"l";s:4:"ð“‚";s:1:"m";s:4:"ð“ƒ";s:1:"n";s:4:"ð“…";s:1:"p";s:4:"ð“†";s:1:"q";s:4:"ð“‡";s:1:"r";s:4:"ð“ˆ";s:1:"s";s:4:"ð“‰";s:1:"t";s:4:"ð“Š";s:1:"u";s:4:"ð“‹";s:1:"v";s:4:"ð“Œ";s:1:"w";s:4:"ð“";s:1:"x";s:4:"ð“Ž";s:1:"y";s:4:"ð“";s:1:"z";s:4:"ð“";s:1:"A";s:4:"ð“‘";s:1:"B";s:4:"ð“’";s:1:"C";s:4:"ð““";s:1:"D";s:4:"ð“”";s:1:"E";s:4:"ð“•";s:1:"F";s:4:"ð“–";s:1:"G";s:4:"ð“—";s:1:"H";s:4:"ð“˜";s:1:"I";s:4:"ð“™";s:1:"J";s:4:"ð“š";s:1:"K";s:4:"ð“›";s:1:"L";s:4:"ð“œ";s:1:"M";s:4:"ð“";s:1:"N";s:4:"ð“ž";s:1:"O";s:4:"ð“Ÿ";s:1:"P";s:4:"ð“ ";s:1:"Q";s:4:"ð“¡";s:1:"R";s:4:"ð“¢";s:1:"S";s:4:"ð“£";s:1:"T";s:4:"ð“¤";s:1:"U";s:4:"ð“¥";s:1:"V";s:4:"ð“¦";s:1:"W";s:4:"ð“§";s:1:"X";s:4:"ð“¨";s:1:"Y";s:4:"ð“©";s:1:"Z";s:4:"ð“ª";s:1:"a";s:4:"ð“«";s:1:"b";s:4:"ð“¬";s:1:"c";s:4:"ð“­";s:1:"d";s:4:"ð“®";s:1:"e";s:4:"ð“¯";s:1:"f";s:4:"ð“°";s:1:"g";s:4:"ð“±";s:1:"h";s:4:"ð“²";s:1:"i";s:4:"ð“³";s:1:"j";s:4:"ð“´";s:1:"k";s:4:"ð“µ";s:1:"l";s:4:"ð“¶";s:1:"m";s:4:"ð“·";s:1:"n";s:4:"ð“¸";s:1:"o";s:4:"ð“¹";s:1:"p";s:4:"ð“º";s:1:"q";s:4:"ð“»";s:1:"r";s:4:"ð“¼";s:1:"s";s:4:"ð“½";s:1:"t";s:4:"ð“¾";s:1:"u";s:4:"ð“¿";s:1:"v";s:4:"ð”€";s:1:"w";s:4:"ð”";s:1:"x";s:4:"ð”‚";s:1:"y";s:4:"ð”ƒ";s:1:"z";s:4:"ð”„";s:1:"A";s:4:"ð”…";s:1:"B";s:4:"ð”‡";s:1:"D";s:4:"ð”ˆ";s:1:"E";s:4:"ð”‰";s:1:"F";s:4:"ð”Š";s:1:"G";s:4:"ð”";s:1:"J";s:4:"ð”Ž";s:1:"K";s:4:"ð”";s:1:"L";s:4:"ð”";s:1:"M";s:4:"ð”‘";s:1:"N";s:4:"ð”’";s:1:"O";s:4:"ð”“";s:1:"P";s:4:"ð””";s:1:"Q";s:4:"ð”–";s:1:"S";s:4:"ð”—";s:1:"T";s:4:"ð”˜";s:1:"U";s:4:"ð”™";s:1:"V";s:4:"ð”š";s:1:"W";s:4:"ð”›";s:1:"X";s:4:"ð”œ";s:1:"Y";s:4:"ð”ž";s:1:"a";s:4:"ð”Ÿ";s:1:"b";s:4:"ð” ";s:1:"c";s:4:"ð”¡";s:1:"d";s:4:"ð”¢";s:1:"e";s:4:"ð”£";s:1:"f";s:4:"ð”¤";s:1:"g";s:4:"ð”¥";s:1:"h";s:4:"ð”¦";s:1:"i";s:4:"ð”§";s:1:"j";s:4:"ð”¨";s:1:"k";s:4:"ð”©";s:1:"l";s:4:"ð”ª";s:1:"m";s:4:"ð”«";s:1:"n";s:4:"ð”¬";s:1:"o";s:4:"ð”­";s:1:"p";s:4:"ð”®";s:1:"q";s:4:"ð”¯";s:1:"r";s:4:"ð”°";s:1:"s";s:4:"ð”±";s:1:"t";s:4:"ð”²";s:1:"u";s:4:"ð”³";s:1:"v";s:4:"ð”´";s:1:"w";s:4:"ð”µ";s:1:"x";s:4:"ð”¶";s:1:"y";s:4:"ð”·";s:1:"z";s:4:"ð”¸";s:1:"A";s:4:"ð”¹";s:1:"B";s:4:"ð”»";s:1:"D";s:4:"ð”¼";s:1:"E";s:4:"ð”½";s:1:"F";s:4:"ð”¾";s:1:"G";s:4:"ð•€";s:1:"I";s:4:"ð•";s:1:"J";s:4:"ð•‚";s:1:"K";s:4:"ð•ƒ";s:1:"L";s:4:"ð•„";s:1:"M";s:4:"ð•†";s:1:"O";s:4:"ð•Š";s:1:"S";s:4:"ð•‹";s:1:"T";s:4:"ð•Œ";s:1:"U";s:4:"ð•";s:1:"V";s:4:"ð•Ž";s:1:"W";s:4:"ð•";s:1:"X";s:4:"ð•";s:1:"Y";s:4:"ð•’";s:1:"a";s:4:"ð•“";s:1:"b";s:4:"ð•”";s:1:"c";s:4:"ð••";s:1:"d";s:4:"ð•–";s:1:"e";s:4:"ð•—";s:1:"f";s:4:"ð•˜";s:1:"g";s:4:"ð•™";s:1:"h";s:4:"ð•š";s:1:"i";s:4:"ð•›";s:1:"j";s:4:"ð•œ";s:1:"k";s:4:"ð•";s:1:"l";s:4:"ð•ž";s:1:"m";s:4:"ð•Ÿ";s:1:"n";s:4:"ð• ";s:1:"o";s:4:"ð•¡";s:1:"p";s:4:"ð•¢";s:1:"q";s:4:"ð•£";s:1:"r";s:4:"ð•¤";s:1:"s";s:4:"ð•¥";s:1:"t";s:4:"ð•¦";s:1:"u";s:4:"ð•§";s:1:"v";s:4:"ð•¨";s:1:"w";s:4:"ð•©";s:1:"x";s:4:"ð•ª";s:1:"y";s:4:"ð•«";s:1:"z";s:4:"ð•¬";s:1:"A";s:4:"ð•­";s:1:"B";s:4:"ð•®";s:1:"C";s:4:"ð•¯";s:1:"D";s:4:"ð•°";s:1:"E";s:4:"ð•±";s:1:"F";s:4:"ð•²";s:1:"G";s:4:"ð•³";s:1:"H";s:4:"ð•´";s:1:"I";s:4:"ð•µ";s:1:"J";s:4:"ð•¶";s:1:"K";s:4:"ð•·";s:1:"L";s:4:"ð•¸";s:1:"M";s:4:"ð•¹";s:1:"N";s:4:"ð•º";s:1:"O";s:4:"ð•»";s:1:"P";s:4:"ð•¼";s:1:"Q";s:4:"ð•½";s:1:"R";s:4:"ð•¾";s:1:"S";s:4:"ð•¿";s:1:"T";s:4:"ð–€";s:1:"U";s:4:"ð–";s:1:"V";s:4:"ð–‚";s:1:"W";s:4:"ð–ƒ";s:1:"X";s:4:"ð–„";s:1:"Y";s:4:"ð–…";s:1:"Z";s:4:"ð–†";s:1:"a";s:4:"ð–‡";s:1:"b";s:4:"ð–ˆ";s:1:"c";s:4:"ð–‰";s:1:"d";s:4:"ð–Š";s:1:"e";s:4:"ð–‹";s:1:"f";s:4:"ð–Œ";s:1:"g";s:4:"ð–";s:1:"h";s:4:"ð–Ž";s:1:"i";s:4:"ð–";s:1:"j";s:4:"ð–";s:1:"k";s:4:"ð–‘";s:1:"l";s:4:"ð–’";s:1:"m";s:4:"ð–“";s:1:"n";s:4:"ð–”";s:1:"o";s:4:"ð–•";s:1:"p";s:4:"ð––";s:1:"q";s:4:"ð–—";s:1:"r";s:4:"ð–˜";s:1:"s";s:4:"ð–™";s:1:"t";s:4:"ð–š";s:1:"u";s:4:"ð–›";s:1:"v";s:4:"ð–œ";s:1:"w";s:4:"ð–";s:1:"x";s:4:"ð–ž";s:1:"y";s:4:"ð–Ÿ";s:1:"z";s:4:"ð– ";s:1:"A";s:4:"ð–¡";s:1:"B";s:4:"ð–¢";s:1:"C";s:4:"ð–£";s:1:"D";s:4:"ð–¤";s:1:"E";s:4:"ð–¥";s:1:"F";s:4:"ð–¦";s:1:"G";s:4:"ð–§";s:1:"H";s:4:"ð–¨";s:1:"I";s:4:"ð–©";s:1:"J";s:4:"ð–ª";s:1:"K";s:4:"ð–«";s:1:"L";s:4:"ð–¬";s:1:"M";s:4:"ð–­";s:1:"N";s:4:"ð–®";s:1:"O";s:4:"ð–¯";s:1:"P";s:4:"ð–°";s:1:"Q";s:4:"ð–±";s:1:"R";s:4:"ð–²";s:1:"S";s:4:"ð–³";s:1:"T";s:4:"ð–´";s:1:"U";s:4:"ð–µ";s:1:"V";s:4:"ð–¶";s:1:"W";s:4:"ð–·";s:1:"X";s:4:"ð–¸";s:1:"Y";s:4:"ð–¹";s:1:"Z";s:4:"ð–º";s:1:"a";s:4:"ð–»";s:1:"b";s:4:"ð–¼";s:1:"c";s:4:"ð–½";s:1:"d";s:4:"ð–¾";s:1:"e";s:4:"ð–¿";s:1:"f";s:4:"ð—€";s:1:"g";s:4:"ð—";s:1:"h";s:4:"ð—‚";s:1:"i";s:4:"ð—ƒ";s:1:"j";s:4:"ð—„";s:1:"k";s:4:"ð—…";s:1:"l";s:4:"ð—†";s:1:"m";s:4:"ð—‡";s:1:"n";s:4:"ð—ˆ";s:1:"o";s:4:"ð—‰";s:1:"p";s:4:"ð—Š";s:1:"q";s:4:"ð—‹";s:1:"r";s:4:"ð—Œ";s:1:"s";s:4:"ð—";s:1:"t";s:4:"ð—Ž";s:1:"u";s:4:"ð—";s:1:"v";s:4:"ð—";s:1:"w";s:4:"ð—‘";s:1:"x";s:4:"ð—’";s:1:"y";s:4:"ð—“";s:1:"z";s:4:"ð—”";s:1:"A";s:4:"ð—•";s:1:"B";s:4:"ð—–";s:1:"C";s:4:"ð——";s:1:"D";s:4:"ð—˜";s:1:"E";s:4:"ð—™";s:1:"F";s:4:"ð—š";s:1:"G";s:4:"ð—›";s:1:"H";s:4:"ð—œ";s:1:"I";s:4:"ð—";s:1:"J";s:4:"ð—ž";s:1:"K";s:4:"ð—Ÿ";s:1:"L";s:4:"ð— ";s:1:"M";s:4:"ð—¡";s:1:"N";s:4:"ð—¢";s:1:"O";s:4:"ð—£";s:1:"P";s:4:"ð—¤";s:1:"Q";s:4:"ð—¥";s:1:"R";s:4:"ð—¦";s:1:"S";s:4:"ð—§";s:1:"T";s:4:"ð—¨";s:1:"U";s:4:"ð—©";s:1:"V";s:4:"ð—ª";s:1:"W";s:4:"ð—«";s:1:"X";s:4:"ð—¬";s:1:"Y";s:4:"ð—­";s:1:"Z";s:4:"ð—®";s:1:"a";s:4:"ð—¯";s:1:"b";s:4:"ð—°";s:1:"c";s:4:"ð—±";s:1:"d";s:4:"ð—²";s:1:"e";s:4:"ð—³";s:1:"f";s:4:"ð—´";s:1:"g";s:4:"ð—µ";s:1:"h";s:4:"ð—¶";s:1:"i";s:4:"ð—·";s:1:"j";s:4:"ð—¸";s:1:"k";s:4:"ð—¹";s:1:"l";s:4:"ð—º";s:1:"m";s:4:"ð—»";s:1:"n";s:4:"ð—¼";s:1:"o";s:4:"ð—½";s:1:"p";s:4:"ð—¾";s:1:"q";s:4:"ð—¿";s:1:"r";s:4:"ð˜€";s:1:"s";s:4:"ð˜";s:1:"t";s:4:"ð˜‚";s:1:"u";s:4:"ð˜ƒ";s:1:"v";s:4:"ð˜„";s:1:"w";s:4:"ð˜…";s:1:"x";s:4:"ð˜†";s:1:"y";s:4:"ð˜‡";s:1:"z";s:4:"ð˜ˆ";s:1:"A";s:4:"ð˜‰";s:1:"B";s:4:"ð˜Š";s:1:"C";s:4:"ð˜‹";s:1:"D";s:4:"ð˜Œ";s:1:"E";s:4:"ð˜";s:1:"F";s:4:"ð˜Ž";s:1:"G";s:4:"ð˜";s:1:"H";s:4:"ð˜";s:1:"I";s:4:"ð˜‘";s:1:"J";s:4:"ð˜’";s:1:"K";s:4:"ð˜“";s:1:"L";s:4:"ð˜”";s:1:"M";s:4:"ð˜•";s:1:"N";s:4:"ð˜–";s:1:"O";s:4:"ð˜—";s:1:"P";s:4:"ð˜˜";s:1:"Q";s:4:"ð˜™";s:1:"R";s:4:"ð˜š";s:1:"S";s:4:"ð˜›";s:1:"T";s:4:"ð˜œ";s:1:"U";s:4:"ð˜";s:1:"V";s:4:"ð˜ž";s:1:"W";s:4:"ð˜Ÿ";s:1:"X";s:4:"ð˜ ";s:1:"Y";s:4:"ð˜¡";s:1:"Z";s:4:"ð˜¢";s:1:"a";s:4:"ð˜£";s:1:"b";s:4:"ð˜¤";s:1:"c";s:4:"ð˜¥";s:1:"d";s:4:"ð˜¦";s:1:"e";s:4:"ð˜§";s:1:"f";s:4:"ð˜¨";s:1:"g";s:4:"ð˜©";s:1:"h";s:4:"ð˜ª";s:1:"i";s:4:"ð˜«";s:1:"j";s:4:"ð˜¬";s:1:"k";s:4:"ð˜­";s:1:"l";s:4:"ð˜®";s:1:"m";s:4:"ð˜¯";s:1:"n";s:4:"ð˜°";s:1:"o";s:4:"ð˜±";s:1:"p";s:4:"ð˜²";s:1:"q";s:4:"ð˜³";s:1:"r";s:4:"ð˜´";s:1:"s";s:4:"ð˜µ";s:1:"t";s:4:"ð˜¶";s:1:"u";s:4:"ð˜·";s:1:"v";s:4:"ð˜¸";s:1:"w";s:4:"ð˜¹";s:1:"x";s:4:"ð˜º";s:1:"y";s:4:"ð˜»";s:1:"z";s:4:"ð˜¼";s:1:"A";s:4:"ð˜½";s:1:"B";s:4:"ð˜¾";s:1:"C";s:4:"ð˜¿";s:1:"D";s:4:"ð™€";s:1:"E";s:4:"ð™";s:1:"F";s:4:"ð™‚";s:1:"G";s:4:"ð™ƒ";s:1:"H";s:4:"ð™„";s:1:"I";s:4:"ð™…";s:1:"J";s:4:"ð™†";s:1:"K";s:4:"ð™‡";s:1:"L";s:4:"ð™ˆ";s:1:"M";s:4:"ð™‰";s:1:"N";s:4:"ð™Š";s:1:"O";s:4:"ð™‹";s:1:"P";s:4:"ð™Œ";s:1:"Q";s:4:"ð™";s:1:"R";s:4:"ð™Ž";s:1:"S";s:4:"ð™";s:1:"T";s:4:"ð™";s:1:"U";s:4:"ð™‘";s:1:"V";s:4:"ð™’";s:1:"W";s:4:"ð™“";s:1:"X";s:4:"ð™”";s:1:"Y";s:4:"ð™•";s:1:"Z";s:4:"ð™–";s:1:"a";s:4:"ð™—";s:1:"b";s:4:"ð™˜";s:1:"c";s:4:"ð™™";s:1:"d";s:4:"ð™š";s:1:"e";s:4:"ð™›";s:1:"f";s:4:"ð™œ";s:1:"g";s:4:"ð™";s:1:"h";s:4:"ð™ž";s:1:"i";s:4:"ð™Ÿ";s:1:"j";s:4:"ð™ ";s:1:"k";s:4:"ð™¡";s:1:"l";s:4:"ð™¢";s:1:"m";s:4:"ð™£";s:1:"n";s:4:"ð™¤";s:1:"o";s:4:"ð™¥";s:1:"p";s:4:"ð™¦";s:1:"q";s:4:"ð™§";s:1:"r";s:4:"ð™¨";s:1:"s";s:4:"ð™©";s:1:"t";s:4:"ð™ª";s:1:"u";s:4:"ð™«";s:1:"v";s:4:"ð™¬";s:1:"w";s:4:"ð™­";s:1:"x";s:4:"ð™®";s:1:"y";s:4:"ð™¯";s:1:"z";s:4:"ð™°";s:1:"A";s:4:"ð™±";s:1:"B";s:4:"ð™²";s:1:"C";s:4:"ð™³";s:1:"D";s:4:"ð™´";s:1:"E";s:4:"ð™µ";s:1:"F";s:4:"ð™¶";s:1:"G";s:4:"ð™·";s:1:"H";s:4:"ð™¸";s:1:"I";s:4:"ð™¹";s:1:"J";s:4:"ð™º";s:1:"K";s:4:"ð™»";s:1:"L";s:4:"ð™¼";s:1:"M";s:4:"ð™½";s:1:"N";s:4:"ð™¾";s:1:"O";s:4:"ð™¿";s:1:"P";s:4:"ðš€";s:1:"Q";s:4:"ðš";s:1:"R";s:4:"ðš‚";s:1:"S";s:4:"ðšƒ";s:1:"T";s:4:"ðš„";s:1:"U";s:4:"ðš…";s:1:"V";s:4:"ðš†";s:1:"W";s:4:"ðš‡";s:1:"X";s:4:"ðšˆ";s:1:"Y";s:4:"ðš‰";s:1:"Z";s:4:"ðšŠ";s:1:"a";s:4:"ðš‹";s:1:"b";s:4:"ðšŒ";s:1:"c";s:4:"ðš";s:1:"d";s:4:"ðšŽ";s:1:"e";s:4:"ðš";s:1:"f";s:4:"ðš";s:1:"g";s:4:"ðš‘";s:1:"h";s:4:"ðš’";s:1:"i";s:4:"ðš“";s:1:"j";s:4:"ðš”";s:1:"k";s:4:"ðš•";s:1:"l";s:4:"ðš–";s:1:"m";s:4:"ðš—";s:1:"n";s:4:"ðš˜";s:1:"o";s:4:"ðš™";s:1:"p";s:4:"ðšš";s:1:"q";s:4:"ðš›";s:1:"r";s:4:"ðšœ";s:1:"s";s:4:"ðš";s:1:"t";s:4:"ðšž";s:1:"u";s:4:"ðšŸ";s:1:"v";s:4:"ðš ";s:1:"w";s:4:"ðš¡";s:1:"x";s:4:"ðš¢";s:1:"y";s:4:"ðš£";s:1:"z";s:4:"ðš¤";s:2:"ı";s:4:"ðš¥";s:2:"È·";s:4:"ðš¨";s:2:"Α";s:4:"ðš©";s:2:"Î’";s:4:"ðšª";s:2:"Γ";s:4:"ðš«";s:2:"Δ";s:4:"ðš¬";s:2:"Ε";s:4:"ðš­";s:2:"Ζ";s:4:"ðš®";s:2:"Η";s:4:"ðš¯";s:2:"Θ";s:4:"ðš°";s:2:"Ι";s:4:"ðš±";s:2:"Κ";s:4:"ðš²";s:2:"Λ";s:4:"ðš³";s:2:"Îœ";s:4:"ðš´";s:2:"Î";s:4:"ðšµ";s:2:"Ξ";s:4:"ðš¶";s:2:"Ο";s:4:"ðš·";s:2:"Π";s:4:"ðš¸";s:2:"Ρ";s:4:"ðš¹";s:2:"Ï´";s:4:"ðšº";s:2:"Σ";s:4:"ðš»";s:2:"Τ";s:4:"ðš¼";s:2:"Î¥";s:4:"ðš½";s:2:"Φ";s:4:"ðš¾";s:2:"Χ";s:4:"ðš¿";s:2:"Ψ";s:4:"ð›€";s:2:"Ω";s:4:"ð›";s:3:"∇";s:4:"ð›‚";s:2:"α";s:4:"ð›ƒ";s:2:"β";s:4:"ð›„";s:2:"γ";s:4:"ð›…";s:2:"δ";s:4:"ð›†";s:2:"ε";s:4:"ð›‡";s:2:"ζ";s:4:"ð›ˆ";s:2:"η";s:4:"ð›‰";s:2:"θ";s:4:"ð›Š";s:2:"ι";s:4:"ð›‹";s:2:"κ";s:4:"ð›Œ";s:2:"λ";s:4:"ð›";s:2:"μ";s:4:"ð›Ž";s:2:"ν";s:4:"ð›";s:2:"ξ";s:4:"ð›";s:2:"ο";s:4:"ð›‘";s:2:"Ï€";s:4:"ð›’";s:2:"Ï";s:4:"ð›“";s:2:"Ï‚";s:4:"ð›”";s:2:"σ";s:4:"ð›•";s:2:"Ï„";s:4:"ð›–";s:2:"Ï…";s:4:"ð›—";s:2:"φ";s:4:"ð›˜";s:2:"χ";s:4:"ð›™";s:2:"ψ";s:4:"ð›š";s:2:"ω";s:4:"ð››";s:3:"∂";s:4:"ð›œ";s:2:"ϵ";s:4:"ð›";s:2:"Ï‘";s:4:"ð›ž";s:2:"Ï°";s:4:"ð›Ÿ";s:2:"Ï•";s:4:"ð› ";s:2:"ϱ";s:4:"ð›¡";s:2:"Ï–";s:4:"ð›¢";s:2:"Α";s:4:"ð›£";s:2:"Î’";s:4:"ð›¤";s:2:"Γ";s:4:"ð›¥";s:2:"Δ";s:4:"ð›¦";s:2:"Ε";s:4:"ð›§";s:2:"Ζ";s:4:"ð›¨";s:2:"Η";s:4:"ð›©";s:2:"Θ";s:4:"ð›ª";s:2:"Ι";s:4:"ð›«";s:2:"Κ";s:4:"ð›¬";s:2:"Λ";s:4:"ð›­";s:2:"Îœ";s:4:"ð›®";s:2:"Î";s:4:"ð›¯";s:2:"Ξ";s:4:"ð›°";s:2:"Ο";s:4:"ð›±";s:2:"Π";s:4:"ð›²";s:2:"Ρ";s:4:"ð›³";s:2:"Ï´";s:4:"ð›´";s:2:"Σ";s:4:"ð›µ";s:2:"Τ";s:4:"ð›¶";s:2:"Î¥";s:4:"ð›·";s:2:"Φ";s:4:"ð›¸";s:2:"Χ";s:4:"ð›¹";s:2:"Ψ";s:4:"ð›º";s:2:"Ω";s:4:"ð›»";s:3:"∇";s:4:"ð›¼";s:2:"α";s:4:"ð›½";s:2:"β";s:4:"ð›¾";s:2:"γ";s:4:"ð›¿";s:2:"δ";s:4:"ðœ€";s:2:"ε";s:4:"ðœ";s:2:"ζ";s:4:"ðœ‚";s:2:"η";s:4:"ðœƒ";s:2:"θ";s:4:"ðœ„";s:2:"ι";s:4:"ðœ…";s:2:"κ";s:4:"ðœ†";s:2:"λ";s:4:"ðœ‡";s:2:"μ";s:4:"ðœˆ";s:2:"ν";s:4:"ðœ‰";s:2:"ξ";s:4:"ðœŠ";s:2:"ο";s:4:"ðœ‹";s:2:"Ï€";s:4:"ðœŒ";s:2:"Ï";s:4:"ðœ";s:2:"Ï‚";s:4:"ðœŽ";s:2:"σ";s:4:"ðœ";s:2:"Ï„";s:4:"ðœ";s:2:"Ï…";s:4:"ðœ‘";s:2:"φ";s:4:"ðœ’";s:2:"χ";s:4:"ðœ“";s:2:"ψ";s:4:"ðœ”";s:2:"ω";s:4:"ðœ•";s:3:"∂";s:4:"ðœ–";s:2:"ϵ";s:4:"ðœ—";s:2:"Ï‘";s:4:"ðœ˜";s:2:"Ï°";s:4:"ðœ™";s:2:"Ï•";s:4:"ðœš";s:2:"ϱ";s:4:"ðœ›";s:2:"Ï–";s:4:"ðœœ";s:2:"Α";s:4:"ðœ";s:2:"Î’";s:4:"ðœž";s:2:"Γ";s:4:"ðœŸ";s:2:"Δ";s:4:"ðœ ";s:2:"Ε";s:4:"ðœ¡";s:2:"Ζ";s:4:"ðœ¢";s:2:"Η";s:4:"ðœ£";s:2:"Θ";s:4:"ðœ¤";s:2:"Ι";s:4:"ðœ¥";s:2:"Κ";s:4:"ðœ¦";s:2:"Λ";s:4:"ðœ§";s:2:"Îœ";s:4:"ðœ¨";s:2:"Î";s:4:"ðœ©";s:2:"Ξ";s:4:"ðœª";s:2:"Ο";s:4:"ðœ«";s:2:"Π";s:4:"ðœ¬";s:2:"Ρ";s:4:"ðœ­";s:2:"Ï´";s:4:"ðœ®";s:2:"Σ";s:4:"ðœ¯";s:2:"Τ";s:4:"ðœ°";s:2:"Î¥";s:4:"ðœ±";s:2:"Φ";s:4:"ðœ²";s:2:"Χ";s:4:"ðœ³";s:2:"Ψ";s:4:"ðœ´";s:2:"Ω";s:4:"ðœµ";s:3:"∇";s:4:"ðœ¶";s:2:"α";s:4:"ðœ·";s:2:"β";s:4:"ðœ¸";s:2:"γ";s:4:"ðœ¹";s:2:"δ";s:4:"ðœº";s:2:"ε";s:4:"ðœ»";s:2:"ζ";s:4:"ðœ¼";s:2:"η";s:4:"ðœ½";s:2:"θ";s:4:"ðœ¾";s:2:"ι";s:4:"ðœ¿";s:2:"κ";s:4:"ð€";s:2:"λ";s:4:"ð";s:2:"μ";s:4:"ð‚";s:2:"ν";s:4:"ðƒ";s:2:"ξ";s:4:"ð„";s:2:"ο";s:4:"ð…";s:2:"Ï€";s:4:"ð†";s:2:"Ï";s:4:"ð‡";s:2:"Ï‚";s:4:"ðˆ";s:2:"σ";s:4:"ð‰";s:2:"Ï„";s:4:"ðŠ";s:2:"Ï…";s:4:"ð‹";s:2:"φ";s:4:"ðŒ";s:2:"χ";s:4:"ð";s:2:"ψ";s:4:"ðŽ";s:2:"ω";s:4:"ð";s:3:"∂";s:4:"ð";s:2:"ϵ";s:4:"ð‘";s:2:"Ï‘";s:4:"ð’";s:2:"Ï°";s:4:"ð“";s:2:"Ï•";s:4:"ð”";s:2:"ϱ";s:4:"ð•";s:2:"Ï–";s:4:"ð–";s:2:"Α";s:4:"ð—";s:2:"Î’";s:4:"ð˜";s:2:"Γ";s:4:"ð™";s:2:"Δ";s:4:"ðš";s:2:"Ε";s:4:"ð›";s:2:"Ζ";s:4:"ðœ";s:2:"Η";s:4:"ð";s:2:"Θ";s:4:"ðž";s:2:"Ι";s:4:"ðŸ";s:2:"Κ";s:4:"ð ";s:2:"Λ";s:4:"ð¡";s:2:"Îœ";s:4:"ð¢";s:2:"Î";s:4:"ð£";s:2:"Ξ";s:4:"ð¤";s:2:"Ο";s:4:"ð¥";s:2:"Π";s:4:"ð¦";s:2:"Ρ";s:4:"ð§";s:2:"Ï´";s:4:"ð¨";s:2:"Σ";s:4:"ð©";s:2:"Τ";s:4:"ðª";s:2:"Î¥";s:4:"ð«";s:2:"Φ";s:4:"ð¬";s:2:"Χ";s:4:"ð­";s:2:"Ψ";s:4:"ð®";s:2:"Ω";s:4:"ð¯";s:3:"∇";s:4:"ð°";s:2:"α";s:4:"ð±";s:2:"β";s:4:"ð²";s:2:"γ";s:4:"ð³";s:2:"δ";s:4:"ð´";s:2:"ε";s:4:"ðµ";s:2:"ζ";s:4:"ð¶";s:2:"η";s:4:"ð·";s:2:"θ";s:4:"ð¸";s:2:"ι";s:4:"ð¹";s:2:"κ";s:4:"ðº";s:2:"λ";s:4:"ð»";s:2:"μ";s:4:"ð¼";s:2:"ν";s:4:"ð½";s:2:"ξ";s:4:"ð¾";s:2:"ο";s:4:"ð¿";s:2:"Ï€";s:4:"ðž€";s:2:"Ï";s:4:"ðž";s:2:"Ï‚";s:4:"ðž‚";s:2:"σ";s:4:"ðžƒ";s:2:"Ï„";s:4:"ðž„";s:2:"Ï…";s:4:"ðž…";s:2:"φ";s:4:"ðž†";s:2:"χ";s:4:"ðž‡";s:2:"ψ";s:4:"ðžˆ";s:2:"ω";s:4:"ðž‰";s:3:"∂";s:4:"ðžŠ";s:2:"ϵ";s:4:"ðž‹";s:2:"Ï‘";s:4:"ðžŒ";s:2:"Ï°";s:4:"ðž";s:2:"Ï•";s:4:"ðžŽ";s:2:"ϱ";s:4:"ðž";s:2:"Ï–";s:4:"ðž";s:2:"Α";s:4:"ðž‘";s:2:"Î’";s:4:"ðž’";s:2:"Γ";s:4:"ðž“";s:2:"Δ";s:4:"ðž”";s:2:"Ε";s:4:"ðž•";s:2:"Ζ";s:4:"ðž–";s:2:"Η";s:4:"ðž—";s:2:"Θ";s:4:"ðž˜";s:2:"Ι";s:4:"ðž™";s:2:"Κ";s:4:"ðžš";s:2:"Λ";s:4:"ðž›";s:2:"Îœ";s:4:"ðžœ";s:2:"Î";s:4:"ðž";s:2:"Ξ";s:4:"ðžž";s:2:"Ο";s:4:"ðžŸ";s:2:"Π";s:4:"ðž ";s:2:"Ρ";s:4:"ðž¡";s:2:"Ï´";s:4:"ðž¢";s:2:"Σ";s:4:"ðž£";s:2:"Τ";s:4:"ðž¤";s:2:"Î¥";s:4:"ðž¥";s:2:"Φ";s:4:"ðž¦";s:2:"Χ";s:4:"ðž§";s:2:"Ψ";s:4:"ðž¨";s:2:"Ω";s:4:"ðž©";s:3:"∇";s:4:"ðžª";s:2:"α";s:4:"ðž«";s:2:"β";s:4:"ðž¬";s:2:"γ";s:4:"ðž­";s:2:"δ";s:4:"ðž®";s:2:"ε";s:4:"ðž¯";s:2:"ζ";s:4:"ðž°";s:2:"η";s:4:"ðž±";s:2:"θ";s:4:"ðž²";s:2:"ι";s:4:"ðž³";s:2:"κ";s:4:"ðž´";s:2:"λ";s:4:"ðžµ";s:2:"μ";s:4:"ðž¶";s:2:"ν";s:4:"ðž·";s:2:"ξ";s:4:"ðž¸";s:2:"ο";s:4:"ðž¹";s:2:"Ï€";s:4:"ðžº";s:2:"Ï";s:4:"ðž»";s:2:"Ï‚";s:4:"ðž¼";s:2:"σ";s:4:"ðž½";s:2:"Ï„";s:4:"ðž¾";s:2:"Ï…";s:4:"ðž¿";s:2:"φ";s:4:"ðŸ€";s:2:"χ";s:4:"ðŸ";s:2:"ψ";s:4:"ðŸ‚";s:2:"ω";s:4:"ðŸƒ";s:3:"∂";s:4:"ðŸ„";s:2:"ϵ";s:4:"ðŸ…";s:2:"Ï‘";s:4:"ðŸ†";s:2:"Ï°";s:4:"ðŸ‡";s:2:"Ï•";s:4:"ðŸˆ";s:2:"ϱ";s:4:"ðŸ‰";s:2:"Ï–";s:4:"ðŸŠ";s:2:"Ïœ";s:4:"ðŸ‹";s:2:"Ï";s:4:"ðŸŽ";s:1:"0";s:4:"ðŸ";s:1:"1";s:4:"ðŸ";s:1:"2";s:4:"ðŸ‘";s:1:"3";s:4:"ðŸ’";s:1:"4";s:4:"ðŸ“";s:1:"5";s:4:"ðŸ”";s:1:"6";s:4:"ðŸ•";s:1:"7";s:4:"ðŸ–";s:1:"8";s:4:"ðŸ—";s:1:"9";s:4:"ðŸ˜";s:1:"0";s:4:"ðŸ™";s:1:"1";s:4:"ðŸš";s:1:"2";s:4:"ðŸ›";s:1:"3";s:4:"ðŸœ";s:1:"4";s:4:"ðŸ";s:1:"5";s:4:"ðŸž";s:1:"6";s:4:"ðŸŸ";s:1:"7";s:4:"ðŸ ";s:1:"8";s:4:"ðŸ¡";s:1:"9";s:4:"ðŸ¢";s:1:"0";s:4:"ðŸ£";s:1:"1";s:4:"ðŸ¤";s:1:"2";s:4:"ðŸ¥";s:1:"3";s:4:"ðŸ¦";s:1:"4";s:4:"ðŸ§";s:1:"5";s:4:"ðŸ¨";s:1:"6";s:4:"ðŸ©";s:1:"7";s:4:"ðŸª";s:1:"8";s:4:"ðŸ«";s:1:"9";s:4:"ðŸ¬";s:1:"0";s:4:"ðŸ­";s:1:"1";s:4:"ðŸ®";s:1:"2";s:4:"ðŸ¯";s:1:"3";s:4:"ðŸ°";s:1:"4";s:4:"ðŸ±";s:1:"5";s:4:"ðŸ²";s:1:"6";s:4:"ðŸ³";s:1:"7";s:4:"ðŸ´";s:1:"8";s:4:"ðŸµ";s:1:"9";s:4:"ðŸ¶";s:1:"0";s:4:"ðŸ·";s:1:"1";s:4:"ðŸ¸";s:1:"2";s:4:"ðŸ¹";s:1:"3";s:4:"ðŸº";s:1:"4";s:4:"ðŸ»";s:1:"5";s:4:"ðŸ¼";s:1:"6";s:4:"ðŸ½";s:1:"7";s:4:"ðŸ¾";s:1:"8";s:4:"ðŸ¿";s:1:"9";s:4:"𞸀";s:2:"ا";s:4:"ðž¸";s:2:"ب";s:4:"𞸂";s:2:"ج";s:4:"𞸃";s:2:"د";s:4:"𞸅";s:2:"Ùˆ";s:4:"𞸆";s:2:"ز";s:4:"𞸇";s:2:"Ø­";s:4:"𞸈";s:2:"Ø·";s:4:"𞸉";s:2:"ÙŠ";s:4:"𞸊";s:2:"Ùƒ";s:4:"𞸋";s:2:"Ù„";s:4:"𞸌";s:2:"Ù…";s:4:"ðž¸";s:2:"Ù†";s:4:"𞸎";s:2:"س";s:4:"ðž¸";s:2:"ع";s:4:"ðž¸";s:2:"Ù";s:4:"𞸑";s:2:"ص";s:4:"𞸒";s:2:"Ù‚";s:4:"𞸓";s:2:"ر";s:4:"𞸔";s:2:"Ø´";s:4:"𞸕";s:2:"ت";s:4:"𞸖";s:2:"Ø«";s:4:"𞸗";s:2:"Ø®";s:4:"𞸘";s:2:"Ø°";s:4:"𞸙";s:2:"ض";s:4:"𞸚";s:2:"ظ";s:4:"𞸛";s:2:"غ";s:4:"𞸜";s:2:"Ù®";s:4:"ðž¸";s:2:"Úº";s:4:"𞸞";s:2:"Ú¡";s:4:"𞸟";s:2:"Ù¯";s:4:"𞸡";s:2:"ب";s:4:"𞸢";s:2:"ج";s:4:"𞸤";s:2:"Ù‡";s:4:"𞸧";s:2:"Ø­";s:4:"𞸩";s:2:"ÙŠ";s:4:"𞸪";s:2:"Ùƒ";s:4:"𞸫";s:2:"Ù„";s:4:"𞸬";s:2:"Ù…";s:4:"𞸭";s:2:"Ù†";s:4:"𞸮";s:2:"س";s:4:"𞸯";s:2:"ع";s:4:"𞸰";s:2:"Ù";s:4:"𞸱";s:2:"ص";s:4:"𞸲";s:2:"Ù‚";s:4:"𞸴";s:2:"Ø´";s:4:"𞸵";s:2:"ت";s:4:"𞸶";s:2:"Ø«";s:4:"𞸷";s:2:"Ø®";s:4:"𞸹";s:2:"ض";s:4:"𞸻";s:2:"غ";s:4:"𞹂";s:2:"ج";s:4:"𞹇";s:2:"Ø­";s:4:"𞹉";s:2:"ÙŠ";s:4:"𞹋";s:2:"Ù„";s:4:"ðž¹";s:2:"Ù†";s:4:"𞹎";s:2:"س";s:4:"ðž¹";s:2:"ع";s:4:"𞹑";s:2:"ص";s:4:"ðž¹’";s:2:"Ù‚";s:4:"ðž¹”";s:2:"Ø´";s:4:"ðž¹—";s:2:"Ø®";s:4:"ðž¹™";s:2:"ض";s:4:"ðž¹›";s:2:"غ";s:4:"ðž¹";s:2:"Úº";s:4:"𞹟";s:2:"Ù¯";s:4:"𞹡";s:2:"ب";s:4:"ðž¹¢";s:2:"ج";s:4:"𞹤";s:2:"Ù‡";s:4:"𞹧";s:2:"Ø­";s:4:"𞹨";s:2:"Ø·";s:4:"𞹩";s:2:"ÙŠ";s:4:"𞹪";s:2:"Ùƒ";s:4:"𞹬";s:2:"Ù…";s:4:"ðž¹­";s:2:"Ù†";s:4:"ðž¹®";s:2:"س";s:4:"𞹯";s:2:"ع";s:4:"ðž¹°";s:2:"Ù";s:4:"ðž¹±";s:2:"ص";s:4:"ðž¹²";s:2:"Ù‚";s:4:"ðž¹´";s:2:"Ø´";s:4:"ðž¹µ";s:2:"ت";s:4:"𞹶";s:2:"Ø«";s:4:"ðž¹·";s:2:"Ø®";s:4:"ðž¹¹";s:2:"ض";s:4:"𞹺";s:2:"ظ";s:4:"ðž¹»";s:2:"غ";s:4:"ðž¹¼";s:2:"Ù®";s:4:"ðž¹¾";s:2:"Ú¡";s:4:"𞺀";s:2:"ا";s:4:"ðžº";s:2:"ب";s:4:"𞺂";s:2:"ج";s:4:"𞺃";s:2:"د";s:4:"𞺄";s:2:"Ù‡";s:4:"𞺅";s:2:"Ùˆ";s:4:"𞺆";s:2:"ز";s:4:"𞺇";s:2:"Ø­";s:4:"𞺈";s:2:"Ø·";s:4:"𞺉";s:2:"ÙŠ";s:4:"𞺋";s:2:"Ù„";s:4:"𞺌";s:2:"Ù…";s:4:"ðžº";s:2:"Ù†";s:4:"𞺎";s:2:"س";s:4:"ðžº";s:2:"ع";s:4:"ðžº";s:2:"Ù";s:4:"𞺑";s:2:"ص";s:4:"𞺒";s:2:"Ù‚";s:4:"𞺓";s:2:"ر";s:4:"𞺔";s:2:"Ø´";s:4:"𞺕";s:2:"ت";s:4:"𞺖";s:2:"Ø«";s:4:"𞺗";s:2:"Ø®";s:4:"𞺘";s:2:"Ø°";s:4:"𞺙";s:2:"ض";s:4:"𞺚";s:2:"ظ";s:4:"𞺛";s:2:"غ";s:4:"𞺡";s:2:"ب";s:4:"𞺢";s:2:"ج";s:4:"𞺣";s:2:"د";s:4:"𞺥";s:2:"Ùˆ";s:4:"𞺦";s:2:"ز";s:4:"𞺧";s:2:"Ø­";s:4:"𞺨";s:2:"Ø·";s:4:"𞺩";s:2:"ÙŠ";s:4:"𞺫";s:2:"Ù„";s:4:"𞺬";s:2:"Ù…";s:4:"𞺭";s:2:"Ù†";s:4:"𞺮";s:2:"س";s:4:"𞺯";s:2:"ع";s:4:"𞺰";s:2:"Ù";s:4:"𞺱";s:2:"ص";s:4:"𞺲";s:2:"Ù‚";s:4:"𞺳";s:2:"ر";s:4:"𞺴";s:2:"Ø´";s:4:"𞺵";s:2:"ت";s:4:"𞺶";s:2:"Ø«";s:4:"𞺷";s:2:"Ø®";s:4:"𞺸";s:2:"Ø°";s:4:"𞺹";s:2:"ض";s:4:"𞺺";s:2:"ظ";s:4:"𞺻";s:2:"غ";s:4:"🄀";s:2:"0.";s:4:"ðŸ„";s:2:"0,";s:4:"🄂";s:2:"1,";s:4:"🄃";s:2:"2,";s:4:"🄄";s:2:"3,";s:4:"🄅";s:2:"4,";s:4:"🄆";s:2:"5,";s:4:"🄇";s:2:"6,";s:4:"🄈";s:2:"7,";s:4:"🄉";s:2:"8,";s:4:"🄊";s:2:"9,";s:4:"ðŸ„";s:3:"(A)";s:4:"🄑";s:3:"(B)";s:4:"🄒";s:3:"(C)";s:4:"🄓";s:3:"(D)";s:4:"🄔";s:3:"(E)";s:4:"🄕";s:3:"(F)";s:4:"🄖";s:3:"(G)";s:4:"🄗";s:3:"(H)";s:4:"🄘";s:3:"(I)";s:4:"🄙";s:3:"(J)";s:4:"🄚";s:3:"(K)";s:4:"🄛";s:3:"(L)";s:4:"🄜";s:3:"(M)";s:4:"ðŸ„";s:3:"(N)";s:4:"🄞";s:3:"(O)";s:4:"🄟";s:3:"(P)";s:4:"🄠";s:3:"(Q)";s:4:"🄡";s:3:"(R)";s:4:"🄢";s:3:"(S)";s:4:"🄣";s:3:"(T)";s:4:"🄤";s:3:"(U)";s:4:"🄥";s:3:"(V)";s:4:"🄦";s:3:"(W)";s:4:"🄧";s:3:"(X)";s:4:"🄨";s:3:"(Y)";s:4:"🄩";s:3:"(Z)";s:4:"🄪";s:7:"〔S〕";s:4:"🄫";s:3:"(C)";s:4:"🄬";s:3:"(R)";s:4:"🄭";s:4:"(CD)";s:4:"🄮";s:4:"(WZ)";s:4:"🄰";s:1:"A";s:4:"🄱";s:1:"B";s:4:"🄲";s:1:"C";s:4:"🄳";s:1:"D";s:4:"🄴";s:1:"E";s:4:"🄵";s:1:"F";s:4:"🄶";s:1:"G";s:4:"🄷";s:1:"H";s:4:"🄸";s:1:"I";s:4:"🄹";s:1:"J";s:4:"🄺";s:1:"K";s:4:"🄻";s:1:"L";s:4:"🄼";s:1:"M";s:4:"🄽";s:1:"N";s:4:"🄾";s:1:"O";s:4:"🄿";s:1:"P";s:4:"🅀";s:1:"Q";s:4:"ðŸ…";s:1:"R";s:4:"🅂";s:1:"S";s:4:"🅃";s:1:"T";s:4:"🅄";s:1:"U";s:4:"🅅";s:1:"V";s:4:"🅆";s:1:"W";s:4:"🅇";s:1:"X";s:4:"🅈";s:1:"Y";s:4:"🅉";s:1:"Z";s:4:"🅊";s:2:"HV";s:4:"🅋";s:2:"MV";s:4:"🅌";s:2:"SD";s:4:"ðŸ…";s:2:"SS";s:4:"🅎";s:3:"PPV";s:4:"ðŸ…";s:2:"WC";s:4:"ðŸ†";s:2:"DJ";s:4:"🈀";s:6:"ã»ã‹";s:4:"ðŸˆ";s:6:"ココ";s:4:"🈂";s:3:"サ";s:4:"ðŸˆ";s:3:"手";s:4:"🈑";s:3:"å­—";s:4:"🈒";s:3:"åŒ";s:4:"🈓";s:3:"デ";s:4:"🈔";s:3:"二";s:4:"🈕";s:3:"多";s:4:"🈖";s:3:"解";s:4:"🈗";s:3:"天";s:4:"🈘";s:3:"交";s:4:"🈙";s:3:"映";s:4:"🈚";s:3:"ç„¡";s:4:"🈛";s:3:"æ–™";s:4:"🈜";s:3:"å‰";s:4:"ðŸˆ";s:3:"後";s:4:"🈞";s:3:"å†";s:4:"🈟";s:3:"æ–°";s:4:"🈠";s:3:"åˆ";s:4:"🈡";s:3:"終";s:4:"🈢";s:3:"生";s:4:"🈣";s:3:"販";s:4:"🈤";s:3:"声";s:4:"🈥";s:3:"å¹";s:4:"🈦";s:3:"æ¼”";s:4:"🈧";s:3:"投";s:4:"🈨";s:3:"æ•";s:4:"🈩";s:3:"一";s:4:"🈪";s:3:"三";s:4:"🈫";s:3:"éŠ";s:4:"🈬";s:3:"å·¦";s:4:"🈭";s:3:"中";s:4:"🈮";s:3:"å³";s:4:"🈯";s:3:"指";s:4:"🈰";s:3:"èµ°";s:4:"🈱";s:3:"打";s:4:"🈲";s:3:"ç¦";s:4:"🈳";s:3:"空";s:4:"🈴";s:3:"åˆ";s:4:"🈵";s:3:"満";s:4:"🈶";s:3:"有";s:4:"🈷";s:3:"月";s:4:"🈸";s:3:"申";s:4:"🈹";s:3:"割";s:4:"🈺";s:3:"å–¶";s:4:"🉀";s:9:"〔本〕";s:4:"ðŸ‰";s:9:"〔三〕";s:4:"🉂";s:9:"〔二〕";s:4:"🉃";s:9:"〔安〕";s:4:"🉄";s:9:"〔点〕";s:4:"🉅";s:9:"〔打〕";s:4:"🉆";s:9:"〔盗〕";s:4:"🉇";s:9:"〔å‹ã€•";s:4:"🉈";s:9:"〔敗〕";s:4:"ðŸ‰";s:5:"(å¾—)";s:4:"🉑";s:5:"(å¯)";s:4:"丽";s:3:"丽";s:4:"ð¯ ";s:3:"丸";s:4:"乁";s:3:"ä¹";s:4:"𠄢";s:4:"ð „¢";s:4:"你";s:3:"ä½ ";s:4:"侮";s:3:"ä¾®";s:4:"侻";s:3:"ä¾»";s:4:"倂";s:3:"倂";s:4:"偺";s:3:"åº";s:4:"備";s:3:"å‚™";s:4:"僧";s:3:"僧";s:4:"像";s:3:"åƒ";s:4:"㒞";s:3:"ã’ž";s:4:"ð¯ ";s:4:"𠘺";s:4:"免";s:3:"å…";s:4:"ð¯ ";s:3:"å…”";s:4:"ð¯ ";s:3:"å…¤";s:4:"具";s:3:"å…·";s:4:"𠔜";s:4:"𠔜";s:4:"㒹";s:3:"ã’¹";s:4:"內";s:3:"å…§";s:4:"再";s:3:"å†";s:4:"𠕋";s:4:"ð •‹";s:4:"冗";s:3:"冗";s:4:"冤";s:3:"冤";s:4:"仌";s:3:"仌";s:4:"冬";s:3:"冬";s:4:"况";s:3:"况";s:4:"𩇟";s:4:"𩇟";s:4:"ð¯ ";s:3:"凵";s:4:"刃";s:3:"刃";s:4:"㓟";s:3:"ã“Ÿ";s:4:"刻";s:3:"刻";s:4:"剆";s:3:"剆";s:4:"割";s:3:"割";s:4:"剷";s:3:"剷";s:4:"㔕";s:3:"㔕";s:4:"勇";s:3:"勇";s:4:"勉";s:3:"勉";s:4:"勤";s:3:"勤";s:4:"勺";s:3:"勺";s:4:"包";s:3:"包";s:4:"匆";s:3:"匆";s:4:"北";s:3:"北";s:4:"卉";s:3:"å‰";s:4:"卑";s:3:"å‘";s:4:"博";s:3:"åš";s:4:"即";s:3:"å³";s:4:"卽";s:3:"å½";s:4:"卿";s:3:"å¿";s:4:"卿";s:3:"å¿";s:4:"卿";s:3:"å¿";s:4:"𠨬";s:4:"𠨬";s:4:"灰";s:3:"ç°";s:4:"及";s:3:"åŠ";s:4:"叟";s:3:"åŸ";s:4:"𠭣";s:4:"ð ­£";s:4:"叫";s:3:"å«";s:4:"叱";s:3:"å±";s:4:"吆";s:3:"å†";s:4:"咞";s:3:"å’ž";s:4:"吸";s:3:"å¸";s:4:"呈";s:3:"呈";s:4:"周";s:3:"周";s:4:"咢";s:3:"å’¢";s:4:"ð¯¡";s:3:"哶";s:4:"唐";s:3:"å”";s:4:"啓";s:3:"å•“";s:4:"啣";s:3:"å•£";s:4:"善";s:3:"å–„";s:4:"善";s:3:"å–„";s:4:"喙";s:3:"å–™";s:4:"喫";s:3:"å–«";s:4:"喳";s:3:"å–³";s:4:"嗂";s:3:"å—‚";s:4:"圖";s:3:"圖";s:4:"嘆";s:3:"嘆";s:4:"ð¯¡";s:3:"圗";s:4:"噑";s:3:"噑";s:4:"ð¯¡";s:3:"å™´";s:4:"ð¯¡";s:3:"切";s:4:"壮";s:3:"壮";s:4:"城";s:3:"城";s:4:"埴";s:3:"埴";s:4:"堍";s:3:"å ";s:4:"型";s:3:"åž‹";s:4:"堲";s:3:"å ²";s:4:"報";s:3:"å ±";s:4:"墬";s:3:"墬";s:4:"𡓤";s:4:"𡓤";s:4:"売";s:3:"売";s:4:"壷";s:3:"壷";s:4:"夆";s:3:"夆";s:4:"ð¯¡";s:3:"多";s:4:"夢";s:3:"夢";s:4:"奢";s:3:"奢";s:4:"𡚨";s:4:"𡚨";s:4:"𡛪";s:4:"𡛪";s:4:"姬";s:3:"姬";s:4:"娛";s:3:"娛";s:4:"娧";s:3:"娧";s:4:"姘";s:3:"姘";s:4:"婦";s:3:"婦";s:4:"㛮";s:3:"ã›®";s:4:"㛼";s:3:"㛼";s:4:"嬈";s:3:"嬈";s:4:"嬾";s:3:"嬾";s:4:"嬾";s:3:"嬾";s:4:"𡧈";s:4:"𡧈";s:4:"寃";s:3:"寃";s:4:"寘";s:3:"寘";s:4:"寧";s:3:"寧";s:4:"寳";s:3:"寳";s:4:"𡬘";s:4:"𡬘";s:4:"寿";s:3:"寿";s:4:"将";s:3:"å°†";s:4:"当";s:3:"当";s:4:"尢";s:3:"å°¢";s:4:"㞁";s:3:"ãž";s:4:"屠";s:3:"å± ";s:4:"屮";s:3:"å±®";s:4:"峀";s:3:"å³€";s:4:"岍";s:3:"å²";s:4:"𡷤";s:4:"ð¡·¤";s:4:"嵃";s:3:"嵃";s:4:"𡷦";s:4:"ð¡·¦";s:4:"嵮";s:3:"åµ®";s:4:"嵫";s:3:"嵫";s:4:"嵼";s:3:"åµ¼";s:4:"ð¯¢";s:3:"å·¡";s:4:"巢";s:3:"å·¢";s:4:"㠯";s:3:"ã ¯";s:4:"巽";s:3:"å·½";s:4:"帨";s:3:"帨";s:4:"帽";s:3:"帽";s:4:"幩";s:3:"幩";s:4:"㡢";s:3:"ã¡¢";s:4:"𢆃";s:4:"𢆃";s:4:"㡼";s:3:"㡼";s:4:"庰";s:3:"庰";s:4:"庳";s:3:"庳";s:4:"ð¯¢";s:3:"庶";s:4:"廊";s:3:"廊";s:4:"ð¯¢";s:4:"𪎒";s:4:"ð¯¢";s:3:"廾";s:4:"𢌱";s:4:"𢌱";s:4:"𢌱";s:4:"𢌱";s:4:"舁";s:3:"èˆ";s:4:"弢";s:3:"å¼¢";s:4:"弢";s:3:"å¼¢";s:4:"㣇";s:3:"㣇";s:4:"𣊸";s:4:"𣊸";s:4:"𦇚";s:4:"𦇚";s:4:"形";s:3:"å½¢";s:4:"彫";s:3:"彫";s:4:"㣣";s:3:"㣣";s:4:"徚";s:3:"徚";s:4:"ð¯¢";s:3:"å¿";s:4:"志";s:3:"å¿—";s:4:"忹";s:3:"忹";s:4:"悁";s:3:"æ‚";s:4:"㤺";s:3:"㤺";s:4:"㤜";s:3:"㤜";s:4:"悔";s:3:"æ‚”";s:4:"𢛔";s:4:"𢛔";s:4:"惇";s:3:"惇";s:4:"慈";s:3:"æ…ˆ";s:4:"慌";s:3:"æ…Œ";s:4:"慎";s:3:"æ…Ž";s:4:"慌";s:3:"æ…Œ";s:4:"慺";s:3:"æ…º";s:4:"憎";s:3:"憎";s:4:"憲";s:3:"憲";s:4:"憤";s:3:"憤";s:4:"憯";s:3:"憯";s:4:"懞";s:3:"懞";s:4:"懲";s:3:"懲";s:4:"懶";s:3:"懶";s:4:"成";s:3:"æˆ";s:4:"戛";s:3:"戛";s:4:"扝";s:3:"æ‰";s:4:"抱";s:3:"抱";s:4:"拔";s:3:"æ‹”";s:4:"捐";s:3:"æ";s:4:"𢬌";s:4:"𢬌";s:4:"挽";s:3:"挽";s:4:"拼";s:3:"拼";s:4:"捨";s:3:"æ¨";s:4:"掃";s:3:"掃";s:4:"揤";s:3:"æ¤";s:4:"𢯱";s:4:"𢯱";s:4:"搢";s:3:"æ¢";s:4:"揅";s:3:"æ…";s:4:"ð¯£";s:3:"掩";s:4:"㨮";s:3:"㨮";s:4:"摩";s:3:"æ‘©";s:4:"摾";s:3:"摾";s:4:"撝";s:3:"æ’";s:4:"摷";s:3:"æ‘·";s:4:"㩬";s:3:"㩬";s:4:"敏";s:3:"æ•";s:4:"敬";s:3:"敬";s:4:"𣀊";s:4:"𣀊";s:4:"旣";s:3:"æ—£";s:4:"書";s:3:"書";s:4:"ð¯£";s:3:"晉";s:4:"㬙";s:3:"㬙";s:4:"ð¯£";s:3:"æš‘";s:4:"ð¯£";s:3:"㬈";s:4:"㫤";s:3:"㫤";s:4:"冒";s:3:"冒";s:4:"冕";s:3:"冕";s:4:"最";s:3:"最";s:4:"暜";s:3:"æšœ";s:4:"肭";s:3:"è‚­";s:4:"䏙";s:3:"ä™";s:4:"朗";s:3:"朗";s:4:"望";s:3:"望";s:4:"朡";s:3:"朡";s:4:"杞";s:3:"æž";s:4:"杓";s:3:"æ“";s:4:"ð¯£";s:4:"ð£ƒ";s:4:"㭉";s:3:"ã­‰";s:4:"柺";s:3:"柺";s:4:"枅";s:3:"æž…";s:4:"桒";s:3:"æ¡’";s:4:"梅";s:3:"梅";s:4:"𣑭";s:4:"𣑭";s:4:"梎";s:3:"梎";s:4:"栟";s:3:"æ Ÿ";s:4:"椔";s:3:"椔";s:4:"㮝";s:3:"ã®";s:4:"楂";s:3:"楂";s:4:"榣";s:3:"榣";s:4:"槪";s:3:"槪";s:4:"檨";s:3:"檨";s:4:"𣚣";s:4:"𣚣";s:4:"櫛";s:3:"æ«›";s:4:"㰘";s:3:"ã°˜";s:4:"次";s:3:"次";s:4:"𣢧";s:4:"𣢧";s:4:"歔";s:3:"æ­”";s:4:"㱎";s:3:"㱎";s:4:"歲";s:3:"æ­²";s:4:"殟";s:3:"殟";s:4:"殺";s:3:"殺";s:4:"殻";s:3:"æ®»";s:4:"𣪍";s:4:"ð£ª";s:4:"𡴋";s:4:"ð¡´‹";s:4:"𣫺";s:4:"𣫺";s:4:"汎";s:3:"汎";s:4:"𣲼";s:4:"𣲼";s:4:"沿";s:3:"沿";s:4:"泍";s:3:"æ³";s:4:"汧";s:3:"汧";s:4:"洖";s:3:"æ´–";s:4:"派";s:3:"æ´¾";s:4:"ð¯¤";s:3:"æµ·";s:4:"流";s:3:"æµ";s:4:"浩";s:3:"浩";s:4:"浸";s:3:"浸";s:4:"涅";s:3:"涅";s:4:"𣴞";s:4:"𣴞";s:4:"洴";s:3:"æ´´";s:4:"港";s:3:"港";s:4:"湮";s:3:"æ¹®";s:4:"㴳";s:3:"ã´³";s:4:"滋";s:3:"滋";s:4:"滇";s:3:"滇";s:4:"ð¯¤";s:4:"𣻑";s:4:"淹";s:3:"æ·¹";s:4:"ð¯¤";s:3:"æ½®";s:4:"ð¯¤";s:4:"𣽞";s:4:"𣾎";s:4:"𣾎";s:4:"濆";s:3:"濆";s:4:"瀹";s:3:"瀹";s:4:"瀞";s:3:"瀞";s:4:"瀛";s:3:"瀛";s:4:"㶖";s:3:"㶖";s:4:"灊";s:3:"çŠ";s:4:"災";s:3:"ç½";s:4:"灷";s:3:"ç·";s:4:"炭";s:3:"ç‚­";s:4:"𠔥";s:4:"𠔥";s:4:"煅";s:3:"ç……";s:4:"ð¯¤";s:4:"𤉣";s:4:"熜";s:3:"熜";s:4:"𤎫";s:4:"𤎫";s:4:"爨";s:3:"爨";s:4:"爵";s:3:"爵";s:4:"牐";s:3:"ç‰";s:4:"𤘈";s:4:"𤘈";s:4:"犀";s:3:"犀";s:4:"犕";s:3:"犕";s:4:"𤜵";s:4:"𤜵";s:4:"𤠔";s:4:"𤠔";s:4:"獺";s:3:"çº";s:4:"王";s:3:"王";s:4:"㺬";s:3:"㺬";s:4:"玥";s:3:"玥";s:4:"㺸";s:3:"㺸";s:4:"㺸";s:3:"㺸";s:4:"瑇";s:3:"瑇";s:4:"瑜";s:3:"ç‘œ";s:4:"瑱";s:3:"瑱";s:4:"璅";s:3:"ç’…";s:4:"瓊";s:3:"ç“Š";s:4:"㼛";s:3:"ã¼›";s:4:"甤";s:3:"甤";s:4:"𤰶";s:4:"𤰶";s:4:"甾";s:3:"甾";s:4:"𤲒";s:4:"𤲒";s:4:"異";s:3:"ç•°";s:4:"𢆟";s:4:"𢆟";s:4:"瘐";s:3:"ç˜";s:4:"𤾡";s:4:"𤾡";s:4:"𤾸";s:4:"𤾸";s:4:"𥁄";s:4:"ð¥„";s:4:"㿼";s:3:"㿼";s:4:"䀈";s:3:"䀈";s:4:"直";s:3:"ç›´";s:4:"ð¯¥";s:4:"𥃳";s:4:"𥃲";s:4:"𥃲";s:4:"𥄙";s:4:"𥄙";s:4:"𥄳";s:4:"𥄳";s:4:"眞";s:3:"眞";s:4:"真";s:3:"真";s:4:"真";s:3:"真";s:4:"睊";s:3:"çŠ";s:4:"䀹";s:3:"䀹";s:4:"瞋";s:3:"çž‹";s:4:"䁆";s:3:"ä†";s:4:"䂖";s:3:"ä‚–";s:4:"ð¯¥";s:4:"ð¥";s:4:"硎";s:3:"ç¡Ž";s:4:"ð¯¥";s:3:"碌";s:4:"ð¯¥";s:3:"磌";s:4:"䃣";s:3:"䃣";s:4:"𥘦";s:4:"𥘦";s:4:"祖";s:3:"祖";s:4:"𥚚";s:4:"𥚚";s:4:"𥛅";s:4:"𥛅";s:4:"福";s:3:"ç¦";s:4:"秫";s:3:"秫";s:4:"䄯";s:3:"䄯";s:4:"穀";s:3:"ç©€";s:4:"穊";s:3:"ç©Š";s:4:"穏";s:3:"ç©";s:4:"𥥼";s:4:"𥥼";s:4:"ð¯¥";s:4:"𥪧";s:4:"𥪧";s:4:"𥪧";s:4:"竮";s:3:"ç«®";s:4:"䈂";s:3:"䈂";s:4:"𥮫";s:4:"𥮫";s:4:"篆";s:3:"篆";s:4:"築";s:3:"築";s:4:"䈧";s:3:"䈧";s:4:"𥲀";s:4:"𥲀";s:4:"糒";s:3:"ç³’";s:4:"䊠";s:3:"䊠";s:4:"糨";s:3:"糨";s:4:"糣";s:3:"ç³£";s:4:"紀";s:3:"ç´€";s:4:"𥾆";s:4:"𥾆";s:4:"絣";s:3:"çµ£";s:4:"䌁";s:3:"äŒ";s:4:"緇";s:3:"ç·‡";s:4:"縂";s:3:"縂";s:4:"繅";s:3:"ç¹…";s:4:"䌴";s:3:"䌴";s:4:"𦈨";s:4:"𦈨";s:4:"𦉇";s:4:"𦉇";s:4:"䍙";s:3:"ä™";s:4:"𦋙";s:4:"𦋙";s:4:"罺";s:3:"罺";s:4:"𦌾";s:4:"𦌾";s:4:"羕";s:3:"羕";s:4:"翺";s:3:"翺";s:4:"者";s:3:"者";s:4:"𦓚";s:4:"𦓚";s:4:"𦔣";s:4:"𦔣";s:4:"聠";s:3:"è ";s:4:"𦖨";s:4:"𦖨";s:4:"聰";s:3:"è°";s:4:"𣍟";s:4:"ð£Ÿ";s:4:"ð¯¦";s:3:"ä•";s:4:"育";s:3:"育";s:4:"脃";s:3:"脃";s:4:"䐋";s:3:"ä‹";s:4:"脾";s:3:"脾";s:4:"媵";s:3:"媵";s:4:"𦞧";s:4:"𦞧";s:4:"𦞵";s:4:"𦞵";s:4:"𣎓";s:4:"𣎓";s:4:"𣎜";s:4:"𣎜";s:4:"舁";s:3:"èˆ";s:4:"舄";s:3:"舄";s:4:"ð¯¦";s:3:"辞";s:4:"䑫";s:3:"ä‘«";s:4:"ð¯¦";s:3:"芑";s:4:"ð¯¦";s:3:"芋";s:4:"芝";s:3:"èŠ";s:4:"劳";s:3:"劳";s:4:"花";s:3:"花";s:4:"芳";s:3:"芳";s:4:"芽";s:3:"芽";s:4:"苦";s:3:"苦";s:4:"𦬼";s:4:"𦬼";s:4:"若";s:3:"è‹¥";s:4:"茝";s:3:"èŒ";s:4:"荣";s:3:"è£";s:4:"莭";s:3:"莭";s:4:"茣";s:3:"茣";s:4:"ð¯¦";s:3:"莽";s:4:"菧";s:3:"è§";s:4:"著";s:3:"è‘—";s:4:"荓";s:3:"è“";s:4:"菊";s:3:"èŠ";s:4:"菌";s:3:"èŒ";s:4:"菜";s:3:"èœ";s:4:"𦰶";s:4:"𦰶";s:4:"𦵫";s:4:"𦵫";s:4:"𦳕";s:4:"𦳕";s:4:"䔫";s:3:"䔫";s:4:"蓱";s:3:"蓱";s:4:"蓳";s:3:"蓳";s:4:"蔖";s:3:"è”–";s:4:"𧏊";s:4:"ð§Š";s:4:"蕤";s:3:"蕤";s:4:"𦼬";s:4:"𦼬";s:4:"䕝";s:3:"ä•";s:4:"䕡";s:3:"ä•¡";s:4:"𦾱";s:4:"𦾱";s:4:"𧃒";s:4:"𧃒";s:4:"䕫";s:3:"ä•«";s:4:"虐";s:3:"è™";s:4:"虜";s:3:"虜";s:4:"虧";s:3:"虧";s:4:"虩";s:3:"虩";s:4:"蚩";s:3:"èš©";s:4:"蚈";s:3:"蚈";s:4:"蜎";s:3:"蜎";s:4:"蛢";s:3:"蛢";s:4:"蝹";s:3:"è¹";s:4:"蜨";s:3:"蜨";s:4:"蝫";s:3:"è«";s:4:"螆";s:3:"螆";s:4:"䗗";s:3:"ä——";s:4:"蟡";s:3:"蟡";s:4:"ð¯§";s:3:"è ";s:4:"䗹";s:3:"ä—¹";s:4:"衠";s:3:"è¡ ";s:4:"衣";s:3:"è¡£";s:4:"𧙧";s:4:"𧙧";s:4:"裗";s:3:"裗";s:4:"裞";s:3:"裞";s:4:"䘵";s:3:"䘵";s:4:"裺";s:3:"裺";s:4:"㒻";s:3:"ã’»";s:4:"𧢮";s:4:"𧢮";s:4:"𧥦";s:4:"𧥦";s:4:"ð¯§";s:3:"äš¾";s:4:"䛇";s:3:"䛇";s:4:"ð¯§";s:3:"誠";s:4:"ð¯§";s:3:"è«­";s:4:"變";s:3:"變";s:4:"豕";s:3:"豕";s:4:"𧲨";s:4:"𧲨";s:4:"貫";s:3:"貫";s:4:"賁";s:3:"è³";s:4:"贛";s:3:"è´›";s:4:"起";s:3:"èµ·";s:4:"𧼯";s:4:"𧼯";s:4:"𠠄";s:4:"ð  „";s:4:"跋";s:3:"è·‹";s:4:"趼";s:3:"趼";s:4:"跰";s:3:"è·°";s:4:"ð¯§";s:4:"𠣞";s:4:"軔";s:3:"è»”";s:4:"輸";s:3:"輸";s:4:"𨗒";s:4:"𨗒";s:4:"𨗭";s:4:"𨗭";s:4:"邔";s:3:"é‚”";s:4:"郱";s:3:"郱";s:4:"鄑";s:3:"é„‘";s:4:"𨜮";s:4:"𨜮";s:4:"鄛";s:3:"é„›";s:4:"鈸";s:3:"鈸";s:4:"鋗";s:3:"é‹—";s:4:"鋘";s:3:"鋘";s:4:"鉼";s:3:"鉼";s:4:"鏹";s:3:"é¹";s:4:"鐕";s:3:"é•";s:4:"𨯺";s:4:"𨯺";s:4:"開";s:3:"é–‹";s:4:"䦕";s:3:"䦕";s:4:"閷";s:3:"é–·";s:4:"𨵷";s:4:"𨵷";s:4:"䧦";s:3:"䧦";s:4:"雃";s:3:"雃";s:4:"嶲";s:3:"嶲";s:4:"霣";s:3:"霣";s:4:"𩅅";s:4:"ð©……";s:4:"𩈚";s:4:"𩈚";s:4:"䩮";s:3:"ä©®";s:4:"䩶";s:3:"䩶";s:4:"韠";s:3:"韠";s:4:"𩐊";s:4:"ð©Š";s:4:"䪲";s:3:"䪲";s:4:"𩒖";s:4:"ð©’–";s:4:"頋";s:3:"é ‹";s:4:"頋";s:3:"é ‹";s:4:"頩";s:3:"é ©";s:4:"ð¯¨";s:4:"ð©–¶";s:4:"飢";s:3:"飢";s:4:"䬳";s:3:"䬳";s:4:"餩";s:3:"餩";s:4:"馧";s:3:"馧";s:4:"駂";s:3:"駂";s:4:"駾";s:3:"駾";s:4:"䯎";s:3:"䯎";s:4:"𩬰";s:4:"𩬰";s:4:"鬒";s:3:"鬒";s:4:"鱀";s:3:"é±€";s:4:"鳽";s:3:"é³½";s:4:"ð¯¨";s:3:"䳎";s:4:"䳭";s:3:"ä³­";s:4:"ð¯¨";s:3:"鵧";s:4:"ð¯¨";s:4:"𪃎";s:4:"䳸";s:3:"䳸";s:4:"𪄅";s:4:"𪄅";s:4:"𪈎";s:4:"𪈎";s:4:"𪊑";s:4:"𪊑";s:4:"麻";s:3:"麻";s:4:"䵖";s:3:"äµ–";s:4:"黹";s:3:"黹";s:4:"黾";s:3:"黾";s:4:"鼅";s:3:"é¼…";s:4:"鼏";s:3:"é¼";s:4:"鼖";s:3:"é¼–";s:4:"鼻";s:3:"é¼»";s:4:"ð¯¨";s:4:"𪘀";s:2:"Æ";s:2:"AE";s:2:"Ã";s:1:"D";s:2:"Ø";s:1:"O";s:2:"Þ";s:2:"TH";s:2:"ß";s:2:"ss";s:2:"æ";s:2:"ae";s:2:"ð";s:1:"d";s:2:"ø";s:1:"o";s:2:"þ";s:2:"th";s:2:"Ä";s:1:"D";s:2:"Ä‘";s:1:"d";s:2:"Ħ";s:1:"H";s:2:"ħ";s:1:"h";s:2:"ı";s:1:"i";s:2:"ĸ";s:1:"q";s:2:"Å";s:1:"L";s:2:"Å‚";s:1:"l";s:2:"ÅŠ";s:1:"N";s:2:"Å‹";s:1:"n";s:2:"Å’";s:2:"OE";s:2:"Å“";s:2:"oe";s:2:"Ŧ";s:1:"T";s:2:"ŧ";s:1:"t";s:2:"Æ€";s:1:"b";s:2:"Æ";s:1:"B";s:2:"Æ‚";s:1:"B";s:2:"ƃ";s:1:"b";s:2:"Ƈ";s:1:"C";s:2:"ƈ";s:1:"c";s:2:"Ɖ";s:1:"D";s:2:"ÆŠ";s:1:"D";s:2:"Æ‹";s:1:"D";s:2:"ÆŒ";s:1:"d";s:2:"Æ";s:1:"E";s:2:"Æ‘";s:1:"F";s:2:"Æ’";s:1:"f";s:2:"Æ“";s:1:"G";s:2:"Æ•";s:2:"hv";s:2:"Æ–";s:1:"I";s:2:"Æ—";s:1:"I";s:2:"Ƙ";s:1:"K";s:2:"Æ™";s:1:"k";s:2:"Æš";s:1:"l";s:2:"Æ";s:1:"N";s:2:"Æž";s:1:"n";s:2:"Æ¢";s:2:"OI";s:2:"Æ£";s:2:"oi";s:2:"Ƥ";s:1:"P";s:2:"Æ¥";s:1:"p";s:2:"Æ«";s:1:"t";s:2:"Ƭ";s:1:"T";s:2:"Æ­";s:1:"t";s:2:"Æ®";s:1:"T";s:2:"Ʋ";s:1:"V";s:2:"Ƴ";s:1:"Y";s:2:"Æ´";s:1:"y";s:2:"Ƶ";s:1:"Z";s:2:"ƶ";s:1:"z";s:2:"Ǥ";s:1:"G";s:2:"Ç¥";s:1:"g";s:2:"È¡";s:1:"d";s:2:"Ȥ";s:1:"Z";s:2:"È¥";s:1:"z";s:2:"È´";s:1:"l";s:2:"ȵ";s:1:"n";s:2:"ȶ";s:1:"t";s:2:"È·";s:1:"j";s:2:"ȸ";s:2:"db";s:2:"ȹ";s:2:"qp";s:2:"Ⱥ";s:1:"A";s:2:"È»";s:1:"C";s:2:"ȼ";s:1:"c";s:2:"Ƚ";s:1:"L";s:2:"Ⱦ";s:1:"T";s:2:"È¿";s:1:"s";s:2:"É€";s:1:"z";s:2:"Ƀ";s:1:"B";s:2:"É„";s:1:"U";s:2:"Ɇ";s:1:"E";s:2:"ɇ";s:1:"e";s:2:"Ɉ";s:1:"J";s:2:"ɉ";s:1:"j";s:2:"ÉŒ";s:1:"R";s:2:"É";s:1:"r";s:2:"ÉŽ";s:1:"Y";s:2:"É";s:1:"y";s:2:"É“";s:1:"b";s:2:"É•";s:1:"c";s:2:"É–";s:1:"d";s:2:"É—";s:1:"d";s:2:"É›";s:1:"e";s:2:"ÉŸ";s:1:"j";s:2:"É ";s:1:"g";s:2:"É¡";s:1:"g";s:2:"É¢";s:1:"G";s:2:"ɦ";s:1:"h";s:2:"ɧ";s:1:"h";s:2:"ɨ";s:1:"i";s:2:"ɪ";s:1:"I";s:2:"É«";s:1:"l";s:2:"ɬ";s:1:"l";s:2:"É­";s:1:"l";s:2:"ɱ";s:1:"m";s:2:"ɲ";s:1:"n";s:2:"ɳ";s:1:"n";s:2:"É´";s:1:"N";s:2:"ɶ";s:2:"OE";s:2:"ɼ";s:1:"r";s:2:"ɽ";s:1:"r";s:2:"ɾ";s:1:"r";s:2:"Ê€";s:1:"R";s:2:"Ê‚";s:1:"s";s:2:"ʈ";s:1:"t";s:2:"ʉ";s:1:"u";s:2:"Ê‹";s:1:"v";s:2:"Ê";s:1:"Y";s:2:"Ê";s:1:"z";s:2:"Ê‘";s:1:"z";s:2:"Ê™";s:1:"B";s:2:"Ê›";s:1:"G";s:2:"Êœ";s:1:"H";s:2:"Ê";s:1:"j";s:2:"ÊŸ";s:1:"L";s:2:"Ê ";s:1:"q";s:2:"Ê£";s:2:"dz";s:2:"Ê¥";s:2:"dz";s:2:"ʦ";s:2:"ts";s:2:"ʪ";s:2:"ls";s:2:"Ê«";s:2:"lz";s:3:"á´€";s:1:"A";s:3:"á´";s:2:"AE";s:3:"á´ƒ";s:1:"B";s:3:"á´„";s:1:"C";s:3:"á´…";s:1:"D";s:3:"á´†";s:1:"D";s:3:"á´‡";s:1:"E";s:3:"á´Š";s:1:"J";s:3:"á´‹";s:1:"K";s:3:"á´Œ";s:1:"L";s:3:"á´";s:1:"M";s:3:"á´";s:1:"O";s:3:"á´˜";s:1:"P";s:3:"á´›";s:1:"T";s:3:"á´œ";s:1:"U";s:3:"á´ ";s:1:"V";s:3:"á´¡";s:1:"W";s:3:"á´¢";s:1:"Z";s:3:"ᵫ";s:2:"ue";s:3:"ᵬ";s:1:"b";s:3:"áµ­";s:1:"d";s:3:"áµ®";s:1:"f";s:3:"ᵯ";s:1:"m";s:3:"áµ°";s:1:"n";s:3:"áµ±";s:1:"p";s:3:"áµ²";s:1:"r";s:3:"áµ³";s:1:"r";s:3:"áµ´";s:1:"s";s:3:"áµµ";s:1:"t";s:3:"ᵶ";s:1:"z";s:3:"ᵺ";s:2:"th";s:3:"áµ»";s:1:"I";s:3:"áµ½";s:1:"p";s:3:"áµ¾";s:1:"U";s:3:"ᶀ";s:1:"b";s:3:"á¶";s:1:"d";s:3:"ᶂ";s:1:"f";s:3:"ᶃ";s:1:"g";s:3:"ᶄ";s:1:"k";s:3:"ᶅ";s:1:"l";s:3:"ᶆ";s:1:"m";s:3:"ᶇ";s:1:"n";s:3:"ᶈ";s:1:"p";s:3:"ᶉ";s:1:"r";s:3:"ᶊ";s:1:"s";s:3:"ᶌ";s:1:"v";s:3:"á¶";s:1:"x";s:3:"ᶎ";s:1:"z";s:3:"á¶";s:1:"a";s:3:"ᶑ";s:1:"d";s:3:"ᶒ";s:1:"e";s:3:"ᶓ";s:1:"e";s:3:"ᶖ";s:1:"i";s:3:"ᶙ";s:1:"u";s:3:"ẜ";s:1:"s";s:3:"áº";s:1:"s";s:3:"ẞ";s:2:"SS";s:3:"Ỻ";s:2:"LL";s:3:"á»»";s:2:"ll";s:3:"Ỽ";s:1:"V";s:3:"ỽ";s:1:"v";s:3:"Ỿ";s:1:"Y";s:3:"ỿ";s:1:"y";s:2:"©";s:3:"(C)";s:2:"®";s:3:"(R)";s:3:"â‚ ";s:2:"CE";s:3:"â‚¢";s:2:"Cr";s:3:"â‚£";s:3:"Fr.";s:3:"₤";s:2:"L.";s:3:"₧";s:3:"Pts";s:3:"₹";s:2:"Rs";s:3:"â„ž";s:2:"Rx";s:3:"〇";s:1:"0";s:3:"‘";s:1:"'";s:3:"’";s:1:"'";s:3:"‚";s:1:",";s:3:"‛";s:1:"'";s:3:"“";s:1:""";s:3:"â€";s:1:""";s:3:"„";s:2:",,";s:3:"‟";s:1:""";s:3:"′";s:1:"'";s:3:"ã€";s:1:""";s:3:"〞";s:1:""";s:2:"«";s:2:"<<";s:2:"»";s:2:">>";s:3:"‹";s:1:"<";s:3:"›";s:1:">";s:3:"â€";s:1:"-";s:3:"‑";s:1:"-";s:3:"‒";s:1:"-";s:3:"–";s:1:"-";s:3:"—";s:1:"-";s:3:"―";s:1:"-";s:3:"︱";s:1:"-";s:3:"︲";s:1:"-";s:3:"‖";s:2:"||";s:3:"â„";s:1:"/";s:3:"â…";s:1:"[";s:3:"â†";s:1:"]";s:3:"âŽ";s:1:"*";s:3:"ã€";s:1:",";s:3:"。";s:1:".";s:3:"〈";s:1:"<";s:3:"〉";s:1:">";s:3:"《";s:2:"<<";s:3:"》";s:2:">>";s:3:"〔";s:1:"[";s:3:"〕";s:1:"]";s:3:"〘";s:1:"[";s:3:"〙";s:1:"]";s:3:"〚";s:1:"[";s:3:"〛";s:1:"]";s:3:"ï¸";s:1:",";s:3:"︑";s:1:",";s:3:"︒";s:1:".";s:3:"︓";s:1:":";s:3:"︔";s:1:";";s:3:"︕";s:1:"!";s:3:"︖";s:1:"?";s:3:"︙";s:3:"...";s:3:"︰";s:2:"..";s:3:"︵";s:1:"(";s:3:"︶";s:1:")";s:3:"︷";s:1:"{";s:3:"︸";s:1:"}";s:3:"︹";s:1:"[";s:3:"︺";s:1:"]";s:3:"︽";s:2:"<<";s:3:"︾";s:2:">>";s:3:"︿";s:1:"<";s:3:"ï¹€";s:1:">";s:3:"﹇";s:1:"[";s:3:"﹈";s:1:"]";s:2:"×";s:1:"*";s:2:"÷";s:1:"/";s:3:"−";s:1:"-";s:3:"∕";s:1:"/";s:3:"∖";s:1:"\";s:3:"∣";s:1:"|";s:3:"∥";s:2:"||";s:3:"≪";s:2:"<<";s:3:"≫";s:2:">>";s:3:"⦅";s:2:"((";s:3:"⦆";s:2:"))";}
    \ No newline at end of file
    diff --git a/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/unidata/canonicalComposition.ser b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/unidata/canonicalComposition.ser
    new file mode 100755
    index 0000000..e75cfcf
    --- /dev/null
    +++ b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/unidata/canonicalComposition.ser
    @@ -0,0 +1 @@
    +a:933:{s:3:"AÌ€";s:2:"À";s:3:"AÌ";s:2:"Ã";s:3:"AÌ‚";s:2:"Â";s:3:"Ã";s:2:"Ã";s:3:"Ä";s:2:"Ä";s:3:"AÌŠ";s:2:"Ã…";s:3:"Ç";s:2:"Ç";s:3:"EÌ€";s:2:"È";s:3:"EÌ";s:2:"É";s:3:"EÌ‚";s:2:"Ê";s:3:"Ë";s:2:"Ë";s:3:"IÌ€";s:2:"ÃŒ";s:3:"IÌ";s:2:"Ã";s:3:"IÌ‚";s:2:"ÃŽ";s:3:"Ï";s:2:"Ã";s:3:"Ñ";s:2:"Ñ";s:3:"OÌ€";s:2:"Ã’";s:3:"OÌ";s:2:"Ó";s:3:"OÌ‚";s:2:"Ô";s:3:"Õ";s:2:"Õ";s:3:"Ö";s:2:"Ö";s:3:"UÌ€";s:2:"Ù";s:3:"UÌ";s:2:"Ú";s:3:"UÌ‚";s:2:"Û";s:3:"Ü";s:2:"Ãœ";s:3:"YÌ";s:2:"Ã";s:3:"aÌ€";s:2:"à";s:3:"aÌ";s:2:"á";s:3:"aÌ‚";s:2:"â";s:3:"ã";s:2:"ã";s:3:"ä";s:2:"ä";s:3:"aÌŠ";s:2:"Ã¥";s:3:"ç";s:2:"ç";s:3:"eÌ€";s:2:"è";s:3:"eÌ";s:2:"é";s:3:"eÌ‚";s:2:"ê";s:3:"ë";s:2:"ë";s:3:"iÌ€";s:2:"ì";s:3:"iÌ";s:2:"í";s:3:"iÌ‚";s:2:"î";s:3:"ï";s:2:"ï";s:3:"ñ";s:2:"ñ";s:3:"oÌ€";s:2:"ò";s:3:"oÌ";s:2:"ó";s:3:"oÌ‚";s:2:"ô";s:3:"õ";s:2:"õ";s:3:"ö";s:2:"ö";s:3:"uÌ€";s:2:"ù";s:3:"uÌ";s:2:"ú";s:3:"uÌ‚";s:2:"û";s:3:"ü";s:2:"ü";s:3:"yÌ";s:2:"ý";s:3:"ÿ";s:2:"ÿ";s:3:"AÌ„";s:2:"Ä€";s:3:"aÌ„";s:2:"Ä";s:3:"Ă";s:2:"Ä‚";s:3:"ă";s:2:"ă";s:3:"Ą";s:2:"Ä„";s:3:"ą";s:2:"Ä…";s:3:"CÌ";s:2:"Ć";s:3:"cÌ";s:2:"ć";s:3:"CÌ‚";s:2:"Ĉ";s:3:"cÌ‚";s:2:"ĉ";s:3:"Ċ";s:2:"ÄŠ";s:3:"ċ";s:2:"Ä‹";s:3:"CÌŒ";s:2:"ÄŒ";s:3:"cÌŒ";s:2:"Ä";s:3:"DÌŒ";s:2:"ÄŽ";s:3:"dÌŒ";s:2:"Ä";s:3:"EÌ„";s:2:"Ä’";s:3:"eÌ„";s:2:"Ä“";s:3:"Ĕ";s:2:"Ä”";s:3:"ĕ";s:2:"Ä•";s:3:"Ė";s:2:"Ä–";s:3:"ė";s:2:"Ä—";s:3:"Ę";s:2:"Ę";s:3:"ę";s:2:"Ä™";s:3:"EÌŒ";s:2:"Äš";s:3:"eÌŒ";s:2:"Ä›";s:3:"GÌ‚";s:2:"Äœ";s:3:"gÌ‚";s:2:"Ä";s:3:"Ğ";s:2:"Äž";s:3:"ğ";s:2:"ÄŸ";s:3:"Ġ";s:2:"Ä ";s:3:"ġ";s:2:"Ä¡";s:3:"Ģ";s:2:"Ä¢";s:3:"ģ";s:2:"Ä£";s:3:"HÌ‚";s:2:"Ĥ";s:3:"hÌ‚";s:2:"Ä¥";s:3:"Ĩ";s:2:"Ĩ";s:3:"ĩ";s:2:"Ä©";s:3:"IÌ„";s:2:"Ī";s:3:"iÌ„";s:2:"Ä«";s:3:"Ĭ";s:2:"Ĭ";s:3:"ĭ";s:2:"Ä­";s:3:"Į";s:2:"Ä®";s:3:"į";s:2:"į";s:3:"İ";s:2:"Ä°";s:3:"JÌ‚";s:2:"Ä´";s:3:"jÌ‚";s:2:"ĵ";s:3:"Ķ";s:2:"Ķ";s:3:"ķ";s:2:"Ä·";s:3:"LÌ";s:2:"Ĺ";s:3:"lÌ";s:2:"ĺ";s:3:"Ļ";s:2:"Ä»";s:3:"ļ";s:2:"ļ";s:3:"LÌŒ";s:2:"Ľ";s:3:"lÌŒ";s:2:"ľ";s:3:"NÌ";s:2:"Ń";s:3:"nÌ";s:2:"Å„";s:3:"Ņ";s:2:"Å…";s:3:"ņ";s:2:"ņ";s:3:"NÌŒ";s:2:"Ň";s:3:"nÌŒ";s:2:"ň";s:3:"OÌ„";s:2:"ÅŒ";s:3:"oÌ„";s:2:"Å";s:3:"Ŏ";s:2:"ÅŽ";s:3:"ŏ";s:2:"Å";s:3:"OÌ‹";s:2:"Å";s:3:"oÌ‹";s:2:"Å‘";s:3:"RÌ";s:2:"Å”";s:3:"rÌ";s:2:"Å•";s:3:"Ŗ";s:2:"Å–";s:3:"ŗ";s:2:"Å—";s:3:"RÌŒ";s:2:"Ř";s:3:"rÌŒ";s:2:"Å™";s:3:"SÌ";s:2:"Åš";s:3:"sÌ";s:2:"Å›";s:3:"SÌ‚";s:2:"Åœ";s:3:"sÌ‚";s:2:"Å";s:3:"Ş";s:2:"Åž";s:3:"ş";s:2:"ÅŸ";s:3:"SÌŒ";s:2:"Å ";s:3:"sÌŒ";s:2:"Å¡";s:3:"Ţ";s:2:"Å¢";s:3:"ţ";s:2:"Å£";s:3:"TÌŒ";s:2:"Ť";s:3:"tÌŒ";s:2:"Å¥";s:3:"Ũ";s:2:"Ũ";s:3:"ũ";s:2:"Å©";s:3:"UÌ„";s:2:"Ū";s:3:"uÌ„";s:2:"Å«";s:3:"Ŭ";s:2:"Ŭ";s:3:"ŭ";s:2:"Å­";s:3:"UÌŠ";s:2:"Å®";s:3:"uÌŠ";s:2:"ů";s:3:"UÌ‹";s:2:"Å°";s:3:"uÌ‹";s:2:"ű";s:3:"Ų";s:2:"Ų";s:3:"ų";s:2:"ų";s:3:"WÌ‚";s:2:"Å´";s:3:"wÌ‚";s:2:"ŵ";s:3:"YÌ‚";s:2:"Ŷ";s:3:"yÌ‚";s:2:"Å·";s:3:"Ÿ";s:2:"Ÿ";s:3:"ZÌ";s:2:"Ź";s:3:"zÌ";s:2:"ź";s:3:"Ż";s:2:"Å»";s:3:"ż";s:2:"ż";s:3:"ZÌŒ";s:2:"Ž";s:3:"zÌŒ";s:2:"ž";s:3:"OÌ›";s:2:"Æ ";s:3:"oÌ›";s:2:"Æ¡";s:3:"UÌ›";s:2:"Ư";s:3:"uÌ›";s:2:"Æ°";s:3:"AÌŒ";s:2:"Ç";s:3:"aÌŒ";s:2:"ÇŽ";s:3:"IÌŒ";s:2:"Ç";s:3:"iÌŒ";s:2:"Ç";s:3:"OÌŒ";s:2:"Ç‘";s:3:"oÌŒ";s:2:"Ç’";s:3:"UÌŒ";s:2:"Ç“";s:3:"uÌŒ";s:2:"Ç”";s:4:"Ǖ";s:2:"Ç•";s:4:"ǖ";s:2:"Ç–";s:4:"ÃœÌ";s:2:"Ç—";s:4:"üÌ";s:2:"ǘ";s:4:"Ǚ";s:2:"Ç™";s:4:"ǚ";s:2:"Çš";s:4:"Ǜ";s:2:"Ç›";s:4:"ǜ";s:2:"Çœ";s:4:"Ǟ";s:2:"Çž";s:4:"ǟ";s:2:"ÇŸ";s:4:"Ǡ";s:2:"Ç ";s:4:"ǡ";s:2:"Ç¡";s:4:"Ǣ";s:2:"Ç¢";s:4:"ǣ";s:2:"Ç£";s:3:"GÌŒ";s:2:"Ǧ";s:3:"gÌŒ";s:2:"ǧ";s:3:"KÌŒ";s:2:"Ǩ";s:3:"kÌŒ";s:2:"Ç©";s:3:"Ǫ";s:2:"Ǫ";s:3:"ǫ";s:2:"Ç«";s:4:"Ǭ";s:2:"Ǭ";s:4:"Ç«Ì„";s:2:"Ç­";s:4:"Æ·ÌŒ";s:2:"Ç®";s:4:"Ê’ÌŒ";s:2:"ǯ";s:3:"jÌŒ";s:2:"Ç°";s:3:"GÌ";s:2:"Ç´";s:3:"gÌ";s:2:"ǵ";s:3:"NÌ€";s:2:"Ǹ";s:3:"nÌ€";s:2:"ǹ";s:4:"Ã…Ì";s:2:"Ǻ";s:4:"Ã¥Ì";s:2:"Ç»";s:4:"ÆÌ";s:2:"Ǽ";s:4:"æÌ";s:2:"ǽ";s:4:"ØÌ";s:2:"Ǿ";s:4:"øÌ";s:2:"Ç¿";s:3:"AÌ";s:2:"È€";s:3:"aÌ";s:2:"È";s:3:"AÌ‘";s:2:"È‚";s:3:"aÌ‘";s:2:"ȃ";s:3:"EÌ";s:2:"È„";s:3:"eÌ";s:2:"È…";s:3:"EÌ‘";s:2:"Ȇ";s:3:"eÌ‘";s:2:"ȇ";s:3:"IÌ";s:2:"Ȉ";s:3:"iÌ";s:2:"ȉ";s:3:"IÌ‘";s:2:"ÈŠ";s:3:"iÌ‘";s:2:"È‹";s:3:"OÌ";s:2:"ÈŒ";s:3:"oÌ";s:2:"È";s:3:"OÌ‘";s:2:"ÈŽ";s:3:"oÌ‘";s:2:"È";s:3:"RÌ";s:2:"È";s:3:"rÌ";s:2:"È‘";s:3:"RÌ‘";s:2:"È’";s:3:"rÌ‘";s:2:"È“";s:3:"UÌ";s:2:"È”";s:3:"uÌ";s:2:"È•";s:3:"UÌ‘";s:2:"È–";s:3:"uÌ‘";s:2:"È—";s:3:"Ș";s:2:"Ș";s:3:"ș";s:2:"È™";s:3:"Ț";s:2:"Èš";s:3:"ț";s:2:"È›";s:3:"HÌŒ";s:2:"Èž";s:3:"hÌŒ";s:2:"ÈŸ";s:3:"Ȧ";s:2:"Ȧ";s:3:"ȧ";s:2:"ȧ";s:3:"Ȩ";s:2:"Ȩ";s:3:"ȩ";s:2:"È©";s:4:"Ȫ";s:2:"Ȫ";s:4:"ȫ";s:2:"È«";s:4:"Ȭ";s:2:"Ȭ";s:4:"ȭ";s:2:"È­";s:3:"Ȯ";s:2:"È®";s:3:"ȯ";s:2:"ȯ";s:4:"Ȱ";s:2:"È°";s:4:"ȱ";s:2:"ȱ";s:3:"YÌ„";s:2:"Ȳ";s:3:"yÌ„";s:2:"ȳ";s:4:"¨Ì";s:2:"Î…";s:4:"ΑÌ";s:2:"Ά";s:4:"ΕÌ";s:2:"Έ";s:4:"ΗÌ";s:2:"Ή";s:4:"ΙÌ";s:2:"Ί";s:4:"ΟÌ";s:2:"ÎŒ";s:4:"Î¥Ì";s:2:"ÎŽ";s:4:"ΩÌ";s:2:"Î";s:4:"ÏŠÌ";s:2:"Î";s:4:"Ϊ";s:2:"Ϊ";s:4:"Ϋ";s:2:"Ϋ";s:4:"αÌ";s:2:"ά";s:4:"εÌ";s:2:"έ";s:4:"ηÌ";s:2:"ή";s:4:"ιÌ";s:2:"ί";s:4:"Ï‹Ì";s:2:"ΰ";s:4:"ϊ";s:2:"ÏŠ";s:4:"ϋ";s:2:"Ï‹";s:4:"οÌ";s:2:"ÏŒ";s:4:"Ï…Ì";s:2:"Ï";s:4:"ωÌ";s:2:"ÏŽ";s:4:"Ï’Ì";s:2:"Ï“";s:4:"ϔ";s:2:"Ï”";s:4:"Ѐ";s:2:"Ѐ";s:4:"Ё";s:2:"Ð";s:4:"ГÌ";s:2:"Ѓ";s:4:"Ї";s:2:"Ї";s:4:"КÌ";s:2:"ÐŒ";s:4:"Ѝ";s:2:"Ð";s:4:"Ў";s:2:"ÐŽ";s:4:"Й";s:2:"Й";s:4:"й";s:2:"й";s:4:"ѐ";s:2:"Ñ";s:4:"ё";s:2:"Ñ‘";s:4:"гÌ";s:2:"Ñ“";s:4:"ї";s:2:"Ñ—";s:4:"кÌ";s:2:"Ñœ";s:4:"ѝ";s:2:"Ñ";s:4:"ў";s:2:"Ñž";s:4:"Ñ´Ì";s:2:"Ѷ";s:4:"ѵÌ";s:2:"Ñ·";s:4:"Ӂ";s:2:"Ó";s:4:"ӂ";s:2:"Ó‚";s:4:"Ð̆";s:2:"Ó";s:4:"ӑ";s:2:"Ó‘";s:4:"Ð̈";s:2:"Ó’";s:4:"ӓ";s:2:"Ó“";s:4:"Ӗ";s:2:"Ó–";s:4:"ӗ";s:2:"Ó—";s:4:"Ӛ";s:2:"Óš";s:4:"ӛ";s:2:"Ó›";s:4:"Ӝ";s:2:"Óœ";s:4:"ӝ";s:2:"Ó";s:4:"Ӟ";s:2:"Óž";s:4:"ӟ";s:2:"ÓŸ";s:4:"Ӣ";s:2:"Ó¢";s:4:"ӣ";s:2:"Ó£";s:4:"Ӥ";s:2:"Ó¤";s:4:"ӥ";s:2:"Ó¥";s:4:"Ӧ";s:2:"Ó¦";s:4:"ӧ";s:2:"Ó§";s:4:"Ӫ";s:2:"Óª";s:4:"ӫ";s:2:"Ó«";s:4:"Ӭ";s:2:"Ó¬";s:4:"Ñ̈";s:2:"Ó­";s:4:"Ӯ";s:2:"Ó®";s:4:"ӯ";s:2:"Ó¯";s:4:"Ӱ";s:2:"Ó°";s:4:"ӱ";s:2:"Ó±";s:4:"Ӳ";s:2:"Ó²";s:4:"ӳ";s:2:"Ó³";s:4:"Ӵ";s:2:"Ó´";s:4:"ӵ";s:2:"Óµ";s:4:"Ӹ";s:2:"Ó¸";s:4:"ӹ";s:2:"Ó¹";s:4:"آ";s:2:"Ø¢";s:4:"أ";s:2:"Ø£";s:4:"ÙˆÙ”";s:2:"ؤ";s:4:"إ";s:2:"Ø¥";s:4:"ÙŠÙ”";s:2:"ئ";s:4:"Û•Ù”";s:2:"Û€";s:4:"ÛÙ”";s:2:"Û‚";s:4:"Û’Ù”";s:2:"Û“";s:6:"ऩ";s:3:"ऩ";s:6:"ऱ";s:3:"ऱ";s:6:"ऴ";s:3:"ऴ";s:6:"ো";s:3:"ো";s:6:"ৌ";s:3:"ৌ";s:6:"ୈ";s:3:"à­ˆ";s:6:"ୋ";s:3:"à­‹";s:6:"ୌ";s:3:"à­Œ";s:6:"ஔ";s:3:"à®”";s:6:"ொ";s:3:"ொ";s:6:"ோ";s:3:"ோ";s:6:"ௌ";s:3:"ௌ";s:6:"ై";s:3:"ై";s:6:"ೀ";s:3:"à³€";s:6:"ೇ";s:3:"ೇ";s:6:"ೈ";s:3:"ೈ";s:6:"ೊ";s:3:"ೊ";s:6:"ೋ";s:3:"ೋ";s:6:"ൊ";s:3:"ൊ";s:6:"ോ";s:3:"ോ";s:6:"ൌ";s:3:"ൌ";s:6:"ේ";s:3:"à·š";s:6:"à·™à·";s:3:"à·œ";s:6:"ෝ";s:3:"à·";s:6:"ෞ";s:3:"à·ž";s:6:"ဦ";s:3:"ဦ";s:6:"ᬆ";s:3:"ᬆ";s:6:"ᬈ";s:3:"ᬈ";s:6:"ᬊ";s:3:"ᬊ";s:6:"ᬌ";s:3:"ᬌ";s:6:"á¬á¬µ";s:3:"ᬎ";s:6:"ᬒ";s:3:"ᬒ";s:6:"ᬻ";s:3:"ᬻ";s:6:"ᬽ";s:3:"ᬽ";s:6:"ᭀ";s:3:"á­€";s:6:"ᭁ";s:3:"á­";s:6:"ᭃ";s:3:"á­ƒ";s:3:"AÌ¥";s:3:"Ḁ";s:3:"aÌ¥";s:3:"á¸";s:3:"Ḃ";s:3:"Ḃ";s:3:"ḃ";s:3:"ḃ";s:3:"BÌ£";s:3:"Ḅ";s:3:"bÌ£";s:3:"ḅ";s:3:"Ḇ";s:3:"Ḇ";s:3:"ḇ";s:3:"ḇ";s:4:"ÇÌ";s:3:"Ḉ";s:4:"çÌ";s:3:"ḉ";s:3:"Ḋ";s:3:"Ḋ";s:3:"ḋ";s:3:"ḋ";s:3:"DÌ£";s:3:"Ḍ";s:3:"dÌ£";s:3:"á¸";s:3:"Ḏ";s:3:"Ḏ";s:3:"ḏ";s:3:"á¸";s:3:"Ḑ";s:3:"á¸";s:3:"ḑ";s:3:"ḑ";s:3:"DÌ­";s:3:"Ḓ";s:3:"dÌ­";s:3:"ḓ";s:4:"Ä’Ì€";s:3:"Ḕ";s:4:"Ä“Ì€";s:3:"ḕ";s:4:"Ä’Ì";s:3:"Ḗ";s:4:"Ä“Ì";s:3:"ḗ";s:3:"EÌ­";s:3:"Ḙ";s:3:"eÌ­";s:3:"ḙ";s:3:"EÌ°";s:3:"Ḛ";s:3:"eÌ°";s:3:"ḛ";s:4:"Ḝ";s:3:"Ḝ";s:4:"ḝ";s:3:"á¸";s:3:"Ḟ";s:3:"Ḟ";s:3:"ḟ";s:3:"ḟ";s:3:"GÌ„";s:3:"Ḡ";s:3:"gÌ„";s:3:"ḡ";s:3:"Ḣ";s:3:"Ḣ";s:3:"ḣ";s:3:"ḣ";s:3:"HÌ£";s:3:"Ḥ";s:3:"hÌ£";s:3:"ḥ";s:3:"Ḧ";s:3:"Ḧ";s:3:"ḧ";s:3:"ḧ";s:3:"Ḩ";s:3:"Ḩ";s:3:"ḩ";s:3:"ḩ";s:3:"HÌ®";s:3:"Ḫ";s:3:"hÌ®";s:3:"ḫ";s:3:"IÌ°";s:3:"Ḭ";s:3:"iÌ°";s:3:"ḭ";s:4:"ÃÌ";s:3:"Ḯ";s:4:"ïÌ";s:3:"ḯ";s:3:"KÌ";s:3:"Ḱ";s:3:"kÌ";s:3:"ḱ";s:3:"KÌ£";s:3:"Ḳ";s:3:"kÌ£";s:3:"ḳ";s:3:"Ḵ";s:3:"Ḵ";s:3:"ḵ";s:3:"ḵ";s:3:"LÌ£";s:3:"Ḷ";s:3:"lÌ£";s:3:"ḷ";s:5:"Ḹ";s:3:"Ḹ";s:5:"ḹ";s:3:"ḹ";s:3:"Ḻ";s:3:"Ḻ";s:3:"ḻ";s:3:"ḻ";s:3:"LÌ­";s:3:"Ḽ";s:3:"lÌ­";s:3:"ḽ";s:3:"MÌ";s:3:"Ḿ";s:3:"mÌ";s:3:"ḿ";s:3:"Ṁ";s:3:"á¹€";s:3:"ṁ";s:3:"á¹";s:3:"MÌ£";s:3:"Ṃ";s:3:"mÌ£";s:3:"ṃ";s:3:"Ṅ";s:3:"Ṅ";s:3:"ṅ";s:3:"á¹…";s:3:"NÌ£";s:3:"Ṇ";s:3:"nÌ£";s:3:"ṇ";s:3:"Ṉ";s:3:"Ṉ";s:3:"ṉ";s:3:"ṉ";s:3:"NÌ­";s:3:"Ṋ";s:3:"nÌ­";s:3:"ṋ";s:4:"ÕÌ";s:3:"Ṍ";s:4:"õÌ";s:3:"á¹";s:4:"Ṏ";s:3:"Ṏ";s:4:"ṏ";s:3:"á¹";s:4:"Ṑ";s:3:"á¹";s:4:"ÅÌ€";s:3:"ṑ";s:4:"ÅŒÌ";s:3:"á¹’";s:4:"ÅÌ";s:3:"ṓ";s:3:"PÌ";s:3:"á¹”";s:3:"pÌ";s:3:"ṕ";s:3:"Ṗ";s:3:"á¹–";s:3:"ṗ";s:3:"á¹—";s:3:"Ṙ";s:3:"Ṙ";s:3:"ṙ";s:3:"á¹™";s:3:"RÌ£";s:3:"Ṛ";s:3:"rÌ£";s:3:"á¹›";s:5:"Ṝ";s:3:"Ṝ";s:5:"ṝ";s:3:"á¹";s:3:"Ṟ";s:3:"Ṟ";s:3:"ṟ";s:3:"ṟ";s:3:"Ṡ";s:3:"á¹ ";s:3:"ṡ";s:3:"ṡ";s:3:"SÌ£";s:3:"á¹¢";s:3:"sÌ£";s:3:"á¹£";s:4:"Ṥ";s:3:"Ṥ";s:4:"ṥ";s:3:"á¹¥";s:4:"Ṧ";s:3:"Ṧ";s:4:"ṧ";s:3:"ṧ";s:5:"Ṩ";s:3:"Ṩ";s:5:"ṩ";s:3:"ṩ";s:3:"Ṫ";s:3:"Ṫ";s:3:"ṫ";s:3:"ṫ";s:3:"TÌ£";s:3:"Ṭ";s:3:"tÌ£";s:3:"á¹­";s:3:"Ṯ";s:3:"á¹®";s:3:"ṯ";s:3:"ṯ";s:3:"TÌ­";s:3:"á¹°";s:3:"tÌ­";s:3:"á¹±";s:3:"Ṳ";s:3:"á¹²";s:3:"ṳ";s:3:"á¹³";s:3:"UÌ°";s:3:"á¹´";s:3:"uÌ°";s:3:"á¹µ";s:3:"UÌ­";s:3:"Ṷ";s:3:"uÌ­";s:3:"á¹·";s:4:"ŨÌ";s:3:"Ṹ";s:4:"Å©Ì";s:3:"á¹¹";s:4:"Ṻ";s:3:"Ṻ";s:4:"ṻ";s:3:"á¹»";s:3:"Ṽ";s:3:"á¹¼";s:3:"ṽ";s:3:"á¹½";s:3:"VÌ£";s:3:"á¹¾";s:3:"vÌ£";s:3:"ṿ";s:3:"WÌ€";s:3:"Ẁ";s:3:"wÌ€";s:3:"áº";s:3:"WÌ";s:3:"Ẃ";s:3:"wÌ";s:3:"ẃ";s:3:"Ẅ";s:3:"Ẅ";s:3:"ẅ";s:3:"ẅ";s:3:"Ẇ";s:3:"Ẇ";s:3:"ẇ";s:3:"ẇ";s:3:"WÌ£";s:3:"Ẉ";s:3:"wÌ£";s:3:"ẉ";s:3:"Ẋ";s:3:"Ẋ";s:3:"ẋ";s:3:"ẋ";s:3:"Ẍ";s:3:"Ẍ";s:3:"ẍ";s:3:"áº";s:3:"Ẏ";s:3:"Ẏ";s:3:"ẏ";s:3:"áº";s:3:"ZÌ‚";s:3:"áº";s:3:"zÌ‚";s:3:"ẑ";s:3:"ZÌ£";s:3:"Ẓ";s:3:"zÌ£";s:3:"ẓ";s:3:"Ẕ";s:3:"Ẕ";s:3:"ẕ";s:3:"ẕ";s:3:"ẖ";s:3:"ẖ";s:3:"ẗ";s:3:"ẗ";s:3:"wÌŠ";s:3:"ẘ";s:3:"yÌŠ";s:3:"ẙ";s:4:"ẛ";s:3:"ẛ";s:3:"AÌ£";s:3:"Ạ";s:3:"aÌ£";s:3:"ạ";s:3:"Ả";s:3:"Ả";s:3:"ả";s:3:"ả";s:4:"ÂÌ";s:3:"Ấ";s:4:"âÌ";s:3:"ấ";s:4:"Ầ";s:3:"Ầ";s:4:"ầ";s:3:"ầ";s:4:"Ẩ";s:3:"Ẩ";s:4:"ẩ";s:3:"ẩ";s:4:"Ẫ";s:3:"Ẫ";s:4:"ẫ";s:3:"ẫ";s:5:"Ậ";s:3:"Ậ";s:5:"ậ";s:3:"ậ";s:4:"Ä‚Ì";s:3:"Ắ";s:4:"ăÌ";s:3:"ắ";s:4:"Ä‚Ì€";s:3:"Ằ";s:4:"ằ";s:3:"ằ";s:4:"Ẳ";s:3:"Ẳ";s:4:"ẳ";s:3:"ẳ";s:4:"Ẵ";s:3:"Ẵ";s:4:"ẵ";s:3:"ẵ";s:5:"Ặ";s:3:"Ặ";s:5:"ặ";s:3:"ặ";s:3:"EÌ£";s:3:"Ẹ";s:3:"eÌ£";s:3:"ẹ";s:3:"Ẻ";s:3:"Ẻ";s:3:"ẻ";s:3:"ẻ";s:3:"Ẽ";s:3:"Ẽ";s:3:"ẽ";s:3:"ẽ";s:4:"ÊÌ";s:3:"Ế";s:4:"êÌ";s:3:"ế";s:4:"Ề";s:3:"Ề";s:4:"ề";s:3:"á»";s:4:"Ể";s:3:"Ể";s:4:"ể";s:3:"ể";s:4:"Ễ";s:3:"Ễ";s:4:"ễ";s:3:"á»…";s:5:"Ệ";s:3:"Ệ";s:5:"ệ";s:3:"ệ";s:3:"Ỉ";s:3:"Ỉ";s:3:"ỉ";s:3:"ỉ";s:3:"IÌ£";s:3:"Ị";s:3:"iÌ£";s:3:"ị";s:3:"OÌ£";s:3:"Ọ";s:3:"oÌ£";s:3:"á»";s:3:"Ỏ";s:3:"Ỏ";s:3:"ỏ";s:3:"á»";s:4:"ÔÌ";s:3:"á»";s:4:"ôÌ";s:3:"ố";s:4:"Ồ";s:3:"á»’";s:4:"ồ";s:3:"ồ";s:4:"Ổ";s:3:"á»”";s:4:"ổ";s:3:"ổ";s:4:"Ỗ";s:3:"á»–";s:4:"ỗ";s:3:"á»—";s:5:"Ộ";s:3:"Ộ";s:5:"á»Ì‚";s:3:"á»™";s:4:"Æ Ì";s:3:"Ớ";s:4:"Æ¡Ì";s:3:"á»›";s:4:"Ờ";s:3:"Ờ";s:4:"Æ¡Ì€";s:3:"á»";s:4:"Ở";s:3:"Ở";s:4:"ở";s:3:"ở";s:4:"Ỡ";s:3:"á» ";s:4:"ỡ";s:3:"ỡ";s:4:"Ợ";s:3:"Ợ";s:4:"Æ¡Ì£";s:3:"ợ";s:3:"UÌ£";s:3:"Ụ";s:3:"uÌ£";s:3:"ụ";s:3:"Ủ";s:3:"Ủ";s:3:"ủ";s:3:"ủ";s:4:"ƯÌ";s:3:"Ứ";s:4:"Æ°Ì";s:3:"ứ";s:4:"Ừ";s:3:"Ừ";s:4:"Æ°Ì€";s:3:"ừ";s:4:"Ử";s:3:"Ử";s:4:"ử";s:3:"á»­";s:4:"Ữ";s:3:"á»®";s:4:"ữ";s:3:"ữ";s:4:"Ự";s:3:"á»°";s:4:"Æ°Ì£";s:3:"á»±";s:3:"YÌ€";s:3:"Ỳ";s:3:"yÌ€";s:3:"ỳ";s:3:"YÌ£";s:3:"á»´";s:3:"yÌ£";s:3:"ỵ";s:3:"Ỷ";s:3:"Ỷ";s:3:"ỷ";s:3:"á»·";s:3:"Ỹ";s:3:"Ỹ";s:3:"ỹ";s:3:"ỹ";s:4:"ἀ";s:3:"á¼€";s:4:"ἁ";s:3:"á¼";s:5:"ἂ";s:3:"ἂ";s:5:"á¼Ì€";s:3:"ἃ";s:5:"á¼€Ì";s:3:"ἄ";s:5:"á¼Ì";s:3:"á¼…";s:5:"ἆ";s:3:"ἆ";s:5:"á¼Í‚";s:3:"ἇ";s:4:"Ἀ";s:3:"Ἀ";s:4:"Ἁ";s:3:"Ἁ";s:5:"Ἂ";s:3:"Ἂ";s:5:"Ἃ";s:3:"Ἃ";s:5:"ἈÌ";s:3:"Ἄ";s:5:"ἉÌ";s:3:"á¼";s:5:"Ἆ";s:3:"Ἆ";s:5:"Ἇ";s:3:"á¼";s:4:"ἐ";s:3:"á¼";s:4:"ἑ";s:3:"ἑ";s:5:"á¼Ì€";s:3:"á¼’";s:5:"ἓ";s:3:"ἓ";s:5:"á¼Ì";s:3:"á¼”";s:5:"ἑÌ";s:3:"ἕ";s:4:"Ἐ";s:3:"Ἐ";s:4:"Ἑ";s:3:"á¼™";s:5:"Ἒ";s:3:"Ἒ";s:5:"Ἓ";s:3:"á¼›";s:5:"ἘÌ";s:3:"Ἔ";s:5:"á¼™Ì";s:3:"á¼";s:4:"ἠ";s:3:"á¼ ";s:4:"ἡ";s:3:"ἡ";s:5:"ἢ";s:3:"á¼¢";s:5:"ἣ";s:3:"á¼£";s:5:"á¼ Ì";s:3:"ἤ";s:5:"ἡÌ";s:3:"á¼¥";s:5:"á¼ Í‚";s:3:"ἦ";s:5:"ἧ";s:3:"ἧ";s:4:"Ἠ";s:3:"Ἠ";s:4:"Ἡ";s:3:"Ἡ";s:5:"Ἢ";s:3:"Ἢ";s:5:"Ἣ";s:3:"Ἣ";s:5:"ἨÌ";s:3:"Ἤ";s:5:"ἩÌ";s:3:"á¼­";s:5:"Ἦ";s:3:"á¼®";s:5:"Ἧ";s:3:"Ἧ";s:4:"ἰ";s:3:"á¼°";s:4:"ἱ";s:3:"á¼±";s:5:"á¼°Ì€";s:3:"á¼²";s:5:"ἳ";s:3:"á¼³";s:5:"á¼°Ì";s:3:"á¼´";s:5:"á¼±Ì";s:3:"á¼µ";s:5:"á¼°Í‚";s:3:"ἶ";s:5:"ἷ";s:3:"á¼·";s:4:"Ἰ";s:3:"Ἰ";s:4:"Ἱ";s:3:"á¼¹";s:5:"Ἲ";s:3:"Ἲ";s:5:"Ἳ";s:3:"á¼»";s:5:"ἸÌ";s:3:"á¼¼";s:5:"á¼¹Ì";s:3:"á¼½";s:5:"Ἶ";s:3:"á¼¾";s:5:"Ἷ";s:3:"Ἷ";s:4:"ὀ";s:3:"á½€";s:4:"ὁ";s:3:"á½";s:5:"ὂ";s:3:"ὂ";s:5:"á½Ì€";s:3:"ὃ";s:5:"á½€Ì";s:3:"ὄ";s:5:"á½Ì";s:3:"á½…";s:4:"Ὀ";s:3:"Ὀ";s:4:"Ὁ";s:3:"Ὁ";s:5:"Ὂ";s:3:"Ὂ";s:5:"Ὃ";s:3:"Ὃ";s:5:"ὈÌ";s:3:"Ὄ";s:5:"ὉÌ";s:3:"á½";s:4:"Ï…Ì“";s:3:"á½";s:4:"Ï…Ì”";s:3:"ὑ";s:5:"á½Ì€";s:3:"á½’";s:5:"ὓ";s:3:"ὓ";s:5:"á½Ì";s:3:"á½”";s:5:"ὑÌ";s:3:"ὕ";s:5:"á½Í‚";s:3:"á½–";s:5:"ὗ";s:3:"á½—";s:4:"Ὑ";s:3:"á½™";s:5:"Ὓ";s:3:"á½›";s:5:"á½™Ì";s:3:"á½";s:5:"Ὗ";s:3:"Ὗ";s:4:"ὠ";s:3:"á½ ";s:4:"ὡ";s:3:"ὡ";s:5:"ὢ";s:3:"á½¢";s:5:"ὣ";s:3:"á½£";s:5:"á½ Ì";s:3:"ὤ";s:5:"ὡÌ";s:3:"á½¥";s:5:"á½ Í‚";s:3:"ὦ";s:5:"ὧ";s:3:"ὧ";s:4:"Ὠ";s:3:"Ὠ";s:4:"Ὡ";s:3:"Ὡ";s:5:"Ὢ";s:3:"Ὢ";s:5:"Ὣ";s:3:"Ὣ";s:5:"ὨÌ";s:3:"Ὤ";s:5:"ὩÌ";s:3:"á½­";s:5:"Ὦ";s:3:"á½®";s:5:"Ὧ";s:3:"Ὧ";s:4:"ὰ";s:3:"á½°";s:4:"ὲ";s:3:"á½²";s:4:"ὴ";s:3:"á½´";s:4:"ὶ";s:3:"ὶ";s:4:"ὸ";s:3:"ὸ";s:4:"Ï…Ì€";s:3:"ὺ";s:4:"ὼ";s:3:"á½¼";s:5:"ᾀ";s:3:"á¾€";s:5:"á¼Í…";s:3:"á¾";s:5:"ᾂ";s:3:"ᾂ";s:5:"ᾃ";s:3:"ᾃ";s:5:"ᾄ";s:3:"ᾄ";s:5:"á¼…Í…";s:3:"á¾…";s:5:"ᾆ";s:3:"ᾆ";s:5:"ᾇ";s:3:"ᾇ";s:5:"ᾈ";s:3:"ᾈ";s:5:"ᾉ";s:3:"ᾉ";s:5:"ᾊ";s:3:"ᾊ";s:5:"ᾋ";s:3:"ᾋ";s:5:"ᾌ";s:3:"ᾌ";s:5:"á¼Í…";s:3:"á¾";s:5:"ᾎ";s:3:"ᾎ";s:5:"á¼Í…";s:3:"á¾";s:5:"á¼ Í…";s:3:"á¾";s:5:"ᾑ";s:3:"ᾑ";s:5:"ᾒ";s:3:"á¾’";s:5:"ᾓ";s:3:"ᾓ";s:5:"ᾔ";s:3:"á¾”";s:5:"ᾕ";s:3:"ᾕ";s:5:"ᾖ";s:3:"á¾–";s:5:"ᾗ";s:3:"á¾—";s:5:"ᾘ";s:3:"ᾘ";s:5:"ᾙ";s:3:"á¾™";s:5:"ᾚ";s:3:"ᾚ";s:5:"ᾛ";s:3:"á¾›";s:5:"ᾜ";s:3:"ᾜ";s:5:"á¼­Í…";s:3:"á¾";s:5:"ᾞ";s:3:"ᾞ";s:5:"ᾟ";s:3:"ᾟ";s:5:"á½ Í…";s:3:"á¾ ";s:5:"ᾡ";s:3:"ᾡ";s:5:"ᾢ";s:3:"á¾¢";s:5:"ᾣ";s:3:"á¾£";s:5:"ᾤ";s:3:"ᾤ";s:5:"ᾥ";s:3:"á¾¥";s:5:"ᾦ";s:3:"ᾦ";s:5:"ᾧ";s:3:"ᾧ";s:5:"ᾨ";s:3:"ᾨ";s:5:"ᾩ";s:3:"ᾩ";s:5:"ᾪ";s:3:"ᾪ";s:5:"ᾫ";s:3:"ᾫ";s:5:"ᾬ";s:3:"ᾬ";s:5:"á½­Í…";s:3:"á¾­";s:5:"ᾮ";s:3:"á¾®";s:5:"ᾯ";s:3:"ᾯ";s:4:"ᾰ";s:3:"á¾°";s:4:"ᾱ";s:3:"á¾±";s:5:"á½°Í…";s:3:"á¾²";s:4:"ᾳ";s:3:"á¾³";s:4:"ᾴ";s:3:"á¾´";s:4:"ᾶ";s:3:"ᾶ";s:5:"ᾷ";s:3:"á¾·";s:4:"Ᾰ";s:3:"Ᾰ";s:4:"Ᾱ";s:3:"á¾¹";s:4:"Ὰ";s:3:"Ὰ";s:4:"ᾼ";s:3:"á¾¼";s:4:"῁";s:3:"á¿";s:5:"á½´Í…";s:3:"á¿‚";s:4:"ῃ";s:3:"ῃ";s:4:"ῄ";s:3:"á¿„";s:4:"ῆ";s:3:"ῆ";s:5:"ῇ";s:3:"ῇ";s:4:"Ὲ";s:3:"Ὲ";s:4:"Ὴ";s:3:"á¿Š";s:4:"ῌ";s:3:"á¿Œ";s:5:"῍";s:3:"á¿";s:5:"᾿Ì";s:3:"á¿Ž";s:5:"῏";s:3:"á¿";s:4:"ῐ";s:3:"á¿";s:4:"ῑ";s:3:"á¿‘";s:4:"ÏŠÌ€";s:3:"á¿’";s:4:"ῖ";s:3:"á¿–";s:4:"ÏŠÍ‚";s:3:"á¿—";s:4:"Ῐ";s:3:"Ῐ";s:4:"Ῑ";s:3:"á¿™";s:4:"Ὶ";s:3:"á¿š";s:5:"῝";s:3:"á¿";s:5:"῾Ì";s:3:"á¿ž";s:5:"῟";s:3:"á¿Ÿ";s:4:"ῠ";s:3:"á¿ ";s:4:"Ï…Ì„";s:3:"á¿¡";s:4:"Ï‹Ì€";s:3:"á¿¢";s:4:"ÏÌ“";s:3:"ῤ";s:4:"ÏÌ”";s:3:"á¿¥";s:4:"Ï…Í‚";s:3:"ῦ";s:4:"Ï‹Í‚";s:3:"ῧ";s:4:"Ῠ";s:3:"Ῠ";s:4:"Ῡ";s:3:"á¿©";s:4:"Ὺ";s:3:"Ὺ";s:4:"Ῥ";s:3:"Ῥ";s:4:"῭";s:3:"á¿­";s:5:"ῲ";s:3:"ῲ";s:4:"ῳ";s:3:"ῳ";s:4:"ÏŽÍ…";s:3:"á¿´";s:4:"ῶ";s:3:"ῶ";s:5:"ῷ";s:3:"á¿·";s:4:"Ὸ";s:3:"Ὸ";s:4:"Ὼ";s:3:"Ὼ";s:4:"ῼ";s:3:"ῼ";s:5:"â†Ì¸";s:3:"↚";s:5:"↛";s:3:"↛";s:5:"↮";s:3:"↮";s:5:"â‡Ì¸";s:3:"â‡";s:5:"⇎";s:3:"⇎";s:5:"⇏";s:3:"â‡";s:5:"∄";s:3:"∄";s:5:"∉";s:3:"∉";s:5:"∌";s:3:"∌";s:5:"∤";s:3:"∤";s:5:"∦";s:3:"∦";s:5:"≁";s:3:"â‰";s:5:"≄";s:3:"≄";s:5:"≇";s:3:"≇";s:5:"≉";s:3:"≉";s:3:"≠";s:3:"≠";s:5:"≢";s:3:"≢";s:5:"â‰Ì¸";s:3:"≭";s:3:"≮";s:3:"≮";s:3:"≯";s:3:"≯";s:5:"≰";s:3:"≰";s:5:"≱";s:3:"≱";s:5:"≴";s:3:"≴";s:5:"≵";s:3:"≵";s:5:"≸";s:3:"≸";s:5:"≹";s:3:"≹";s:5:"⊀";s:3:"⊀";s:5:"⊁";s:3:"âŠ";s:5:"⊄";s:3:"⊄";s:5:"⊅";s:3:"⊅";s:5:"⊈";s:3:"⊈";s:5:"⊉";s:3:"⊉";s:5:"⊬";s:3:"⊬";s:5:"⊭";s:3:"⊭";s:5:"⊮";s:3:"⊮";s:5:"⊯";s:3:"⊯";s:5:"⋠";s:3:"â‹ ";s:5:"⋡";s:3:"â‹¡";s:5:"⋢";s:3:"â‹¢";s:5:"⋣";s:3:"â‹£";s:5:"⋪";s:3:"⋪";s:5:"⋫";s:3:"â‹«";s:5:"⋬";s:3:"⋬";s:5:"⋭";s:3:"â‹­";s:6:"ã‹ã‚™";s:3:"ãŒ";s:6:"ãã‚™";s:3:"ãŽ";s:6:"ãã‚™";s:3:"ã";s:6:"ã‘ã‚™";s:3:"ã’";s:6:"ã“ã‚™";s:3:"ã”";s:6:"ã•ã‚™";s:3:"ã–";s:6:"ã—ã‚™";s:3:"ã˜";s:6:"ã™ã‚™";s:3:"ãš";s:6:"ã›ã‚™";s:3:"ãœ";s:6:"ãã‚™";s:3:"ãž";s:6:"ãŸã‚™";s:3:"ã ";s:6:"ã¡ã‚™";s:3:"ã¢";s:6:"ã¤ã‚™";s:3:"ã¥";s:6:"ã¦ã‚™";s:3:"ã§";s:6:"ã¨ã‚™";s:3:"ã©";s:6:"ã¯ã‚™";s:3:"ã°";s:6:"ã¯ã‚š";s:3:"ã±";s:6:"ã²ã‚™";s:3:"ã³";s:6:"ã²ã‚š";s:3:"ã´";s:6:"ãµã‚™";s:3:"ã¶";s:6:"ãµã‚š";s:3:"ã·";s:6:"ã¸ã‚™";s:3:"ã¹";s:6:"ã¸ã‚š";s:3:"ãº";s:6:"ã»ã‚™";s:3:"ã¼";s:6:"ã»ã‚š";s:3:"ã½";s:6:"ã†ã‚™";s:3:"ã‚”";s:6:"ã‚ã‚™";s:3:"ã‚ž";s:6:"ã‚«ã‚™";s:3:"ガ";s:6:"ã‚­ã‚™";s:3:"ã‚®";s:6:"グ";s:3:"ã‚°";s:6:"ゲ";s:3:"ゲ";s:6:"ゴ";s:3:"ã‚´";s:6:"ザ";s:3:"ザ";s:6:"ã‚·ã‚™";s:3:"ジ";s:6:"ズ";s:3:"ズ";s:6:"ゼ";s:3:"ゼ";s:6:"ゾ";s:3:"ゾ";s:6:"ã‚¿ã‚™";s:3:"ダ";s:6:"ãƒã‚™";s:3:"ヂ";s:6:"ヅ";s:3:"ヅ";s:6:"デ";s:3:"デ";s:6:"ド";s:3:"ド";s:6:"ãƒã‚™";s:3:"ãƒ";s:6:"ãƒã‚š";s:3:"パ";s:6:"ビ";s:3:"ビ";s:6:"ピ";s:3:"ピ";s:6:"ブ";s:3:"ブ";s:6:"プ";s:3:"プ";s:6:"ベ";s:3:"ベ";s:6:"ペ";s:3:"ペ";s:6:"ボ";s:3:"ボ";s:6:"ポ";s:3:"ãƒ";s:6:"ヴ";s:3:"ヴ";s:6:"ヷ";s:3:"ヷ";s:6:"ヸ";s:3:"ヸ";s:6:"ヹ";s:3:"ヹ";s:6:"ヺ";s:3:"ヺ";s:6:"ヾ";s:3:"ヾ";s:8:"𑂚";s:4:"ð‘‚š";s:8:"𑂜";s:4:"ð‘‚œ";s:8:"𑂫";s:4:"ð‘‚«";s:8:"𑄮";s:4:"ð‘„®";s:8:"𑄯";s:4:"𑄯";}
    \ No newline at end of file
    diff --git a/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/unidata/canonicalDecomposition.ser b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/unidata/canonicalDecomposition.ser
    new file mode 100755
    index 0000000..c1ee2b6
    --- /dev/null
    +++ b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/unidata/canonicalDecomposition.ser
    @@ -0,0 +1 @@
    +a:2053:{s:2:"À";s:3:"AÌ€";s:2:"Ã";s:3:"AÌ";s:2:"Â";s:3:"AÌ‚";s:2:"Ã";s:3:"Ã";s:2:"Ä";s:3:"Ä";s:2:"Ã…";s:3:"AÌŠ";s:2:"Ç";s:3:"Ç";s:2:"È";s:3:"EÌ€";s:2:"É";s:3:"EÌ";s:2:"Ê";s:3:"EÌ‚";s:2:"Ë";s:3:"Ë";s:2:"ÃŒ";s:3:"IÌ€";s:2:"Ã";s:3:"IÌ";s:2:"ÃŽ";s:3:"IÌ‚";s:2:"Ã";s:3:"Ï";s:2:"Ñ";s:3:"Ñ";s:2:"Ã’";s:3:"OÌ€";s:2:"Ó";s:3:"OÌ";s:2:"Ô";s:3:"OÌ‚";s:2:"Õ";s:3:"Õ";s:2:"Ö";s:3:"Ö";s:2:"Ù";s:3:"UÌ€";s:2:"Ú";s:3:"UÌ";s:2:"Û";s:3:"UÌ‚";s:2:"Ãœ";s:3:"Ü";s:2:"Ã";s:3:"YÌ";s:2:"à";s:3:"aÌ€";s:2:"á";s:3:"aÌ";s:2:"â";s:3:"aÌ‚";s:2:"ã";s:3:"ã";s:2:"ä";s:3:"ä";s:2:"Ã¥";s:3:"aÌŠ";s:2:"ç";s:3:"ç";s:2:"è";s:3:"eÌ€";s:2:"é";s:3:"eÌ";s:2:"ê";s:3:"eÌ‚";s:2:"ë";s:3:"ë";s:2:"ì";s:3:"iÌ€";s:2:"í";s:3:"iÌ";s:2:"î";s:3:"iÌ‚";s:2:"ï";s:3:"ï";s:2:"ñ";s:3:"ñ";s:2:"ò";s:3:"oÌ€";s:2:"ó";s:3:"oÌ";s:2:"ô";s:3:"oÌ‚";s:2:"õ";s:3:"õ";s:2:"ö";s:3:"ö";s:2:"ù";s:3:"uÌ€";s:2:"ú";s:3:"uÌ";s:2:"û";s:3:"uÌ‚";s:2:"ü";s:3:"ü";s:2:"ý";s:3:"yÌ";s:2:"ÿ";s:3:"ÿ";s:2:"Ä€";s:3:"AÌ„";s:2:"Ä";s:3:"aÌ„";s:2:"Ä‚";s:3:"Ă";s:2:"ă";s:3:"ă";s:2:"Ä„";s:3:"Ą";s:2:"Ä…";s:3:"ą";s:2:"Ć";s:3:"CÌ";s:2:"ć";s:3:"cÌ";s:2:"Ĉ";s:3:"CÌ‚";s:2:"ĉ";s:3:"cÌ‚";s:2:"ÄŠ";s:3:"Ċ";s:2:"Ä‹";s:3:"ċ";s:2:"ÄŒ";s:3:"CÌŒ";s:2:"Ä";s:3:"cÌŒ";s:2:"ÄŽ";s:3:"DÌŒ";s:2:"Ä";s:3:"dÌŒ";s:2:"Ä’";s:3:"EÌ„";s:2:"Ä“";s:3:"eÌ„";s:2:"Ä”";s:3:"Ĕ";s:2:"Ä•";s:3:"ĕ";s:2:"Ä–";s:3:"Ė";s:2:"Ä—";s:3:"ė";s:2:"Ę";s:3:"Ę";s:2:"Ä™";s:3:"ę";s:2:"Äš";s:3:"EÌŒ";s:2:"Ä›";s:3:"eÌŒ";s:2:"Äœ";s:3:"GÌ‚";s:2:"Ä";s:3:"gÌ‚";s:2:"Äž";s:3:"Ğ";s:2:"ÄŸ";s:3:"ğ";s:2:"Ä ";s:3:"Ġ";s:2:"Ä¡";s:3:"ġ";s:2:"Ä¢";s:3:"Ģ";s:2:"Ä£";s:3:"ģ";s:2:"Ĥ";s:3:"HÌ‚";s:2:"Ä¥";s:3:"hÌ‚";s:2:"Ĩ";s:3:"Ĩ";s:2:"Ä©";s:3:"ĩ";s:2:"Ī";s:3:"IÌ„";s:2:"Ä«";s:3:"iÌ„";s:2:"Ĭ";s:3:"Ĭ";s:2:"Ä­";s:3:"ĭ";s:2:"Ä®";s:3:"Į";s:2:"į";s:3:"į";s:2:"Ä°";s:3:"İ";s:2:"Ä´";s:3:"JÌ‚";s:2:"ĵ";s:3:"jÌ‚";s:2:"Ķ";s:3:"Ķ";s:2:"Ä·";s:3:"ķ";s:2:"Ĺ";s:3:"LÌ";s:2:"ĺ";s:3:"lÌ";s:2:"Ä»";s:3:"Ļ";s:2:"ļ";s:3:"ļ";s:2:"Ľ";s:3:"LÌŒ";s:2:"ľ";s:3:"lÌŒ";s:2:"Ń";s:3:"NÌ";s:2:"Å„";s:3:"nÌ";s:2:"Å…";s:3:"Ņ";s:2:"ņ";s:3:"ņ";s:2:"Ň";s:3:"NÌŒ";s:2:"ň";s:3:"nÌŒ";s:2:"ÅŒ";s:3:"OÌ„";s:2:"Å";s:3:"oÌ„";s:2:"ÅŽ";s:3:"Ŏ";s:2:"Å";s:3:"ŏ";s:2:"Å";s:3:"OÌ‹";s:2:"Å‘";s:3:"oÌ‹";s:2:"Å”";s:3:"RÌ";s:2:"Å•";s:3:"rÌ";s:2:"Å–";s:3:"Ŗ";s:2:"Å—";s:3:"ŗ";s:2:"Ř";s:3:"RÌŒ";s:2:"Å™";s:3:"rÌŒ";s:2:"Åš";s:3:"SÌ";s:2:"Å›";s:3:"sÌ";s:2:"Åœ";s:3:"SÌ‚";s:2:"Å";s:3:"sÌ‚";s:2:"Åž";s:3:"Ş";s:2:"ÅŸ";s:3:"ş";s:2:"Å ";s:3:"SÌŒ";s:2:"Å¡";s:3:"sÌŒ";s:2:"Å¢";s:3:"Ţ";s:2:"Å£";s:3:"ţ";s:2:"Ť";s:3:"TÌŒ";s:2:"Å¥";s:3:"tÌŒ";s:2:"Ũ";s:3:"Ũ";s:2:"Å©";s:3:"ũ";s:2:"Ū";s:3:"UÌ„";s:2:"Å«";s:3:"uÌ„";s:2:"Ŭ";s:3:"Ŭ";s:2:"Å­";s:3:"ŭ";s:2:"Å®";s:3:"UÌŠ";s:2:"ů";s:3:"uÌŠ";s:2:"Å°";s:3:"UÌ‹";s:2:"ű";s:3:"uÌ‹";s:2:"Ų";s:3:"Ų";s:2:"ų";s:3:"ų";s:2:"Å´";s:3:"WÌ‚";s:2:"ŵ";s:3:"wÌ‚";s:2:"Ŷ";s:3:"YÌ‚";s:2:"Å·";s:3:"yÌ‚";s:2:"Ÿ";s:3:"Ÿ";s:2:"Ź";s:3:"ZÌ";s:2:"ź";s:3:"zÌ";s:2:"Å»";s:3:"Ż";s:2:"ż";s:3:"ż";s:2:"Ž";s:3:"ZÌŒ";s:2:"ž";s:3:"zÌŒ";s:2:"Æ ";s:3:"OÌ›";s:2:"Æ¡";s:3:"oÌ›";s:2:"Ư";s:3:"UÌ›";s:2:"Æ°";s:3:"uÌ›";s:2:"Ç";s:3:"AÌŒ";s:2:"ÇŽ";s:3:"aÌŒ";s:2:"Ç";s:3:"IÌŒ";s:2:"Ç";s:3:"iÌŒ";s:2:"Ç‘";s:3:"OÌŒ";s:2:"Ç’";s:3:"oÌŒ";s:2:"Ç“";s:3:"UÌŒ";s:2:"Ç”";s:3:"uÌŒ";s:2:"Ç•";s:5:"Ǖ";s:2:"Ç–";s:5:"ǖ";s:2:"Ç—";s:5:"ÜÌ";s:2:"ǘ";s:5:"üÌ";s:2:"Ç™";s:5:"Ǚ";s:2:"Çš";s:5:"ǚ";s:2:"Ç›";s:5:"Ǜ";s:2:"Çœ";s:5:"ǜ";s:2:"Çž";s:5:"Ǟ";s:2:"ÇŸ";s:5:"ǟ";s:2:"Ç ";s:5:"Ǡ";s:2:"Ç¡";s:5:"ǡ";s:2:"Ç¢";s:4:"Ǣ";s:2:"Ç£";s:4:"ǣ";s:2:"Ǧ";s:3:"GÌŒ";s:2:"ǧ";s:3:"gÌŒ";s:2:"Ǩ";s:3:"KÌŒ";s:2:"Ç©";s:3:"kÌŒ";s:2:"Ǫ";s:3:"Ǫ";s:2:"Ç«";s:3:"ǫ";s:2:"Ǭ";s:5:"Ǭ";s:2:"Ç­";s:5:"ǭ";s:2:"Ç®";s:4:"Æ·ÌŒ";s:2:"ǯ";s:4:"Ê’ÌŒ";s:2:"Ç°";s:3:"jÌŒ";s:2:"Ç´";s:3:"GÌ";s:2:"ǵ";s:3:"gÌ";s:2:"Ǹ";s:3:"NÌ€";s:2:"ǹ";s:3:"nÌ€";s:2:"Ǻ";s:5:"AÌŠÌ";s:2:"Ç»";s:5:"aÌŠÌ";s:2:"Ǽ";s:4:"ÆÌ";s:2:"ǽ";s:4:"æÌ";s:2:"Ǿ";s:4:"ØÌ";s:2:"Ç¿";s:4:"øÌ";s:2:"È€";s:3:"AÌ";s:2:"È";s:3:"aÌ";s:2:"È‚";s:3:"AÌ‘";s:2:"ȃ";s:3:"aÌ‘";s:2:"È„";s:3:"EÌ";s:2:"È…";s:3:"eÌ";s:2:"Ȇ";s:3:"EÌ‘";s:2:"ȇ";s:3:"eÌ‘";s:2:"Ȉ";s:3:"IÌ";s:2:"ȉ";s:3:"iÌ";s:2:"ÈŠ";s:3:"IÌ‘";s:2:"È‹";s:3:"iÌ‘";s:2:"ÈŒ";s:3:"OÌ";s:2:"È";s:3:"oÌ";s:2:"ÈŽ";s:3:"OÌ‘";s:2:"È";s:3:"oÌ‘";s:2:"È";s:3:"RÌ";s:2:"È‘";s:3:"rÌ";s:2:"È’";s:3:"RÌ‘";s:2:"È“";s:3:"rÌ‘";s:2:"È”";s:3:"UÌ";s:2:"È•";s:3:"uÌ";s:2:"È–";s:3:"UÌ‘";s:2:"È—";s:3:"uÌ‘";s:2:"Ș";s:3:"Ș";s:2:"È™";s:3:"ș";s:2:"Èš";s:3:"Ț";s:2:"È›";s:3:"ț";s:2:"Èž";s:3:"HÌŒ";s:2:"ÈŸ";s:3:"hÌŒ";s:2:"Ȧ";s:3:"Ȧ";s:2:"ȧ";s:3:"ȧ";s:2:"Ȩ";s:3:"Ȩ";s:2:"È©";s:3:"ȩ";s:2:"Ȫ";s:5:"Ȫ";s:2:"È«";s:5:"ȫ";s:2:"Ȭ";s:5:"Ȭ";s:2:"È­";s:5:"ȭ";s:2:"È®";s:3:"Ȯ";s:2:"ȯ";s:3:"ȯ";s:2:"È°";s:5:"Ȱ";s:2:"ȱ";s:5:"ȱ";s:2:"Ȳ";s:3:"YÌ„";s:2:"ȳ";s:3:"yÌ„";s:2:"Í€";s:2:"Ì€";s:2:"Í";s:2:"Ì";s:2:"̓";s:2:"Ì“";s:2:"Í„";s:4:"̈Ì";s:2:"Í´";s:2:"ʹ";s:2:";";s:1:";";s:2:"Î…";s:4:"¨Ì";s:2:"Ά";s:4:"ΑÌ";s:2:"·";s:2:"·";s:2:"Έ";s:4:"ΕÌ";s:2:"Ή";s:4:"ΗÌ";s:2:"Ί";s:4:"ΙÌ";s:2:"ÎŒ";s:4:"ΟÌ";s:2:"ÎŽ";s:4:"Î¥Ì";s:2:"Î";s:4:"ΩÌ";s:2:"Î";s:6:"ϊÌ";s:2:"Ϊ";s:4:"Ϊ";s:2:"Ϋ";s:4:"Ϋ";s:2:"ά";s:4:"αÌ";s:2:"έ";s:4:"εÌ";s:2:"ή";s:4:"ηÌ";s:2:"ί";s:4:"ιÌ";s:2:"ΰ";s:6:"ϋÌ";s:2:"ÏŠ";s:4:"ϊ";s:2:"Ï‹";s:4:"ϋ";s:2:"ÏŒ";s:4:"οÌ";s:2:"Ï";s:4:"Ï…Ì";s:2:"ÏŽ";s:4:"ωÌ";s:2:"Ï“";s:4:"Ï’Ì";s:2:"Ï”";s:4:"ϔ";s:2:"Ѐ";s:4:"Ѐ";s:2:"Ð";s:4:"Ё";s:2:"Ѓ";s:4:"ГÌ";s:2:"Ї";s:4:"Ї";s:2:"ÐŒ";s:4:"КÌ";s:2:"Ð";s:4:"Ѝ";s:2:"ÐŽ";s:4:"Ў";s:2:"Й";s:4:"Й";s:2:"й";s:4:"й";s:2:"Ñ";s:4:"ѐ";s:2:"Ñ‘";s:4:"ё";s:2:"Ñ“";s:4:"гÌ";s:2:"Ñ—";s:4:"ї";s:2:"Ñœ";s:4:"кÌ";s:2:"Ñ";s:4:"ѝ";s:2:"Ñž";s:4:"ў";s:2:"Ѷ";s:4:"Ñ´Ì";s:2:"Ñ·";s:4:"ѵÌ";s:2:"Ó";s:4:"Ӂ";s:2:"Ó‚";s:4:"ӂ";s:2:"Ó";s:4:"Ð̆";s:2:"Ó‘";s:4:"ӑ";s:2:"Ó’";s:4:"Ð̈";s:2:"Ó“";s:4:"ӓ";s:2:"Ó–";s:4:"Ӗ";s:2:"Ó—";s:4:"ӗ";s:2:"Óš";s:4:"Ӛ";s:2:"Ó›";s:4:"ӛ";s:2:"Óœ";s:4:"Ӝ";s:2:"Ó";s:4:"ӝ";s:2:"Óž";s:4:"Ӟ";s:2:"ÓŸ";s:4:"ӟ";s:2:"Ó¢";s:4:"Ӣ";s:2:"Ó£";s:4:"ӣ";s:2:"Ó¤";s:4:"Ӥ";s:2:"Ó¥";s:4:"ӥ";s:2:"Ó¦";s:4:"Ӧ";s:2:"Ó§";s:4:"ӧ";s:2:"Óª";s:4:"Ӫ";s:2:"Ó«";s:4:"ӫ";s:2:"Ó¬";s:4:"Ӭ";s:2:"Ó­";s:4:"Ñ̈";s:2:"Ó®";s:4:"Ӯ";s:2:"Ó¯";s:4:"ӯ";s:2:"Ó°";s:4:"Ӱ";s:2:"Ó±";s:4:"ӱ";s:2:"Ó²";s:4:"Ӳ";s:2:"Ó³";s:4:"ӳ";s:2:"Ó´";s:4:"Ӵ";s:2:"Óµ";s:4:"ӵ";s:2:"Ó¸";s:4:"Ӹ";s:2:"Ó¹";s:4:"ӹ";s:2:"Ø¢";s:4:"آ";s:2:"Ø£";s:4:"أ";s:2:"ؤ";s:4:"ÙˆÙ”";s:2:"Ø¥";s:4:"إ";s:2:"ئ";s:4:"ÙŠÙ”";s:2:"Û€";s:4:"Û•Ù”";s:2:"Û‚";s:4:"ÛÙ”";s:2:"Û“";s:4:"Û’Ù”";s:3:"ऩ";s:6:"ऩ";s:3:"ऱ";s:6:"ऱ";s:3:"ऴ";s:6:"ऴ";s:3:"क़";s:6:"क़";s:3:"ख़";s:6:"ख़";s:3:"ग़";s:6:"ग़";s:3:"ज़";s:6:"ज़";s:3:"ड़";s:6:"ड़";s:3:"à¥";s:6:"ढ़";s:3:"फ़";s:6:"फ़";s:3:"य़";s:6:"य़";s:3:"ো";s:6:"ো";s:3:"ৌ";s:6:"ৌ";s:3:"ড়";s:6:"ড়";s:3:"à§";s:6:"ঢ়";s:3:"য়";s:6:"য়";s:3:"ਲ਼";s:6:"ਲ਼";s:3:"ਸ਼";s:6:"ਸ਼";s:3:"à©™";s:6:"ਖ਼";s:3:"à©š";s:6:"ਗ਼";s:3:"à©›";s:6:"ਜ਼";s:3:"à©ž";s:6:"ਫ਼";s:3:"à­ˆ";s:6:"ୈ";s:3:"à­‹";s:6:"ୋ";s:3:"à­Œ";s:6:"ୌ";s:3:"à­œ";s:6:"ଡ଼";s:3:"à­";s:6:"ଢ଼";s:3:"à®”";s:6:"ஔ";s:3:"ொ";s:6:"ொ";s:3:"ோ";s:6:"ோ";s:3:"ௌ";s:6:"ௌ";s:3:"ై";s:6:"ై";s:3:"à³€";s:6:"ೀ";s:3:"ೇ";s:6:"ೇ";s:3:"ೈ";s:6:"ೈ";s:3:"ೊ";s:6:"ೊ";s:3:"ೋ";s:9:"ೋ";s:3:"ൊ";s:6:"ൊ";s:3:"ോ";s:6:"ോ";s:3:"ൌ";s:6:"ൌ";s:3:"à·š";s:6:"ේ";s:3:"à·œ";s:6:"à·™à·";s:3:"à·";s:9:"à·™à·à·Š";s:3:"à·ž";s:6:"ෞ";s:3:"གྷ";s:6:"གྷ";s:3:"à½";s:6:"ཌྷ";s:3:"དྷ";s:6:"དྷ";s:3:"བྷ";s:6:"བྷ";s:3:"ཛྷ";s:6:"ཛྷ";s:3:"ཀྵ";s:6:"ཀྵ";s:3:"ཱི";s:6:"ཱི";s:3:"ཱུ";s:6:"ཱུ";s:3:"ྲྀ";s:6:"ྲྀ";s:3:"ླྀ";s:6:"ླྀ";s:3:"à¾";s:6:"ཱྀ";s:3:"ྒྷ";s:6:"ྒྷ";s:3:"à¾";s:6:"ྜྷ";s:3:"ྡྷ";s:6:"ྡྷ";s:3:"ྦྷ";s:6:"ྦྷ";s:3:"ྫྷ";s:6:"ྫྷ";s:3:"ྐྵ";s:6:"à¾à¾µ";s:3:"ဦ";s:6:"ဦ";s:3:"ᬆ";s:6:"ᬆ";s:3:"ᬈ";s:6:"ᬈ";s:3:"ᬊ";s:6:"ᬊ";s:3:"ᬌ";s:6:"ᬌ";s:3:"ᬎ";s:6:"á¬á¬µ";s:3:"ᬒ";s:6:"ᬒ";s:3:"ᬻ";s:6:"ᬻ";s:3:"ᬽ";s:6:"ᬽ";s:3:"á­€";s:6:"ᭀ";s:3:"á­";s:6:"ᭁ";s:3:"á­ƒ";s:6:"ᭃ";s:3:"Ḁ";s:3:"AÌ¥";s:3:"á¸";s:3:"aÌ¥";s:3:"Ḃ";s:3:"Ḃ";s:3:"ḃ";s:3:"ḃ";s:3:"Ḅ";s:3:"BÌ£";s:3:"ḅ";s:3:"bÌ£";s:3:"Ḇ";s:3:"Ḇ";s:3:"ḇ";s:3:"ḇ";s:3:"Ḉ";s:5:"ÇÌ";s:3:"ḉ";s:5:"çÌ";s:3:"Ḋ";s:3:"Ḋ";s:3:"ḋ";s:3:"ḋ";s:3:"Ḍ";s:3:"DÌ£";s:3:"á¸";s:3:"dÌ£";s:3:"Ḏ";s:3:"Ḏ";s:3:"á¸";s:3:"ḏ";s:3:"á¸";s:3:"Ḑ";s:3:"ḑ";s:3:"ḑ";s:3:"Ḓ";s:3:"DÌ­";s:3:"ḓ";s:3:"dÌ­";s:3:"Ḕ";s:5:"EÌ„Ì€";s:3:"ḕ";s:5:"eÌ„Ì€";s:3:"Ḗ";s:5:"EÌ„Ì";s:3:"ḗ";s:5:"eÌ„Ì";s:3:"Ḙ";s:3:"EÌ­";s:3:"ḙ";s:3:"eÌ­";s:3:"Ḛ";s:3:"EÌ°";s:3:"ḛ";s:3:"eÌ°";s:3:"Ḝ";s:5:"Ḝ";s:3:"á¸";s:5:"ḝ";s:3:"Ḟ";s:3:"Ḟ";s:3:"ḟ";s:3:"ḟ";s:3:"Ḡ";s:3:"GÌ„";s:3:"ḡ";s:3:"gÌ„";s:3:"Ḣ";s:3:"Ḣ";s:3:"ḣ";s:3:"ḣ";s:3:"Ḥ";s:3:"HÌ£";s:3:"ḥ";s:3:"hÌ£";s:3:"Ḧ";s:3:"Ḧ";s:3:"ḧ";s:3:"ḧ";s:3:"Ḩ";s:3:"Ḩ";s:3:"ḩ";s:3:"ḩ";s:3:"Ḫ";s:3:"HÌ®";s:3:"ḫ";s:3:"hÌ®";s:3:"Ḭ";s:3:"IÌ°";s:3:"ḭ";s:3:"iÌ°";s:3:"Ḯ";s:5:"ÏÌ";s:3:"ḯ";s:5:"ïÌ";s:3:"Ḱ";s:3:"KÌ";s:3:"ḱ";s:3:"kÌ";s:3:"Ḳ";s:3:"KÌ£";s:3:"ḳ";s:3:"kÌ£";s:3:"Ḵ";s:3:"Ḵ";s:3:"ḵ";s:3:"ḵ";s:3:"Ḷ";s:3:"LÌ£";s:3:"ḷ";s:3:"lÌ£";s:3:"Ḹ";s:5:"Ḹ";s:3:"ḹ";s:5:"ḹ";s:3:"Ḻ";s:3:"Ḻ";s:3:"ḻ";s:3:"ḻ";s:3:"Ḽ";s:3:"LÌ­";s:3:"ḽ";s:3:"lÌ­";s:3:"Ḿ";s:3:"MÌ";s:3:"ḿ";s:3:"mÌ";s:3:"á¹€";s:3:"Ṁ";s:3:"á¹";s:3:"ṁ";s:3:"Ṃ";s:3:"MÌ£";s:3:"ṃ";s:3:"mÌ£";s:3:"Ṅ";s:3:"Ṅ";s:3:"á¹…";s:3:"ṅ";s:3:"Ṇ";s:3:"NÌ£";s:3:"ṇ";s:3:"nÌ£";s:3:"Ṉ";s:3:"Ṉ";s:3:"ṉ";s:3:"ṉ";s:3:"Ṋ";s:3:"NÌ­";s:3:"ṋ";s:3:"nÌ­";s:3:"Ṍ";s:5:"ÕÌ";s:3:"á¹";s:5:"õÌ";s:3:"Ṏ";s:5:"Ṏ";s:3:"á¹";s:5:"ṏ";s:3:"á¹";s:5:"OÌ„Ì€";s:3:"ṑ";s:5:"oÌ„Ì€";s:3:"á¹’";s:5:"OÌ„Ì";s:3:"ṓ";s:5:"oÌ„Ì";s:3:"á¹”";s:3:"PÌ";s:3:"ṕ";s:3:"pÌ";s:3:"á¹–";s:3:"Ṗ";s:3:"á¹—";s:3:"ṗ";s:3:"Ṙ";s:3:"Ṙ";s:3:"á¹™";s:3:"ṙ";s:3:"Ṛ";s:3:"RÌ£";s:3:"á¹›";s:3:"rÌ£";s:3:"Ṝ";s:5:"Ṝ";s:3:"á¹";s:5:"ṝ";s:3:"Ṟ";s:3:"Ṟ";s:3:"ṟ";s:3:"ṟ";s:3:"á¹ ";s:3:"Ṡ";s:3:"ṡ";s:3:"ṡ";s:3:"á¹¢";s:3:"SÌ£";s:3:"á¹£";s:3:"sÌ£";s:3:"Ṥ";s:5:"SÌ̇";s:3:"á¹¥";s:5:"sÌ̇";s:3:"Ṧ";s:5:"Ṧ";s:3:"ṧ";s:5:"ṧ";s:3:"Ṩ";s:5:"Ṩ";s:3:"ṩ";s:5:"ṩ";s:3:"Ṫ";s:3:"Ṫ";s:3:"ṫ";s:3:"ṫ";s:3:"Ṭ";s:3:"TÌ£";s:3:"á¹­";s:3:"tÌ£";s:3:"á¹®";s:3:"Ṯ";s:3:"ṯ";s:3:"ṯ";s:3:"á¹°";s:3:"TÌ­";s:3:"á¹±";s:3:"tÌ­";s:3:"á¹²";s:3:"Ṳ";s:3:"á¹³";s:3:"ṳ";s:3:"á¹´";s:3:"UÌ°";s:3:"á¹µ";s:3:"uÌ°";s:3:"Ṷ";s:3:"UÌ­";s:3:"á¹·";s:3:"uÌ­";s:3:"Ṹ";s:5:"ŨÌ";s:3:"á¹¹";s:5:"ũÌ";s:3:"Ṻ";s:5:"Ṻ";s:3:"á¹»";s:5:"ṻ";s:3:"á¹¼";s:3:"Ṽ";s:3:"á¹½";s:3:"ṽ";s:3:"á¹¾";s:3:"VÌ£";s:3:"ṿ";s:3:"vÌ£";s:3:"Ẁ";s:3:"WÌ€";s:3:"áº";s:3:"wÌ€";s:3:"Ẃ";s:3:"WÌ";s:3:"ẃ";s:3:"wÌ";s:3:"Ẅ";s:3:"Ẅ";s:3:"ẅ";s:3:"ẅ";s:3:"Ẇ";s:3:"Ẇ";s:3:"ẇ";s:3:"ẇ";s:3:"Ẉ";s:3:"WÌ£";s:3:"ẉ";s:3:"wÌ£";s:3:"Ẋ";s:3:"Ẋ";s:3:"ẋ";s:3:"ẋ";s:3:"Ẍ";s:3:"Ẍ";s:3:"áº";s:3:"ẍ";s:3:"Ẏ";s:3:"Ẏ";s:3:"áº";s:3:"ẏ";s:3:"áº";s:3:"ZÌ‚";s:3:"ẑ";s:3:"zÌ‚";s:3:"Ẓ";s:3:"ZÌ£";s:3:"ẓ";s:3:"zÌ£";s:3:"Ẕ";s:3:"Ẕ";s:3:"ẕ";s:3:"ẕ";s:3:"ẖ";s:3:"ẖ";s:3:"ẗ";s:3:"ẗ";s:3:"ẘ";s:3:"wÌŠ";s:3:"ẙ";s:3:"yÌŠ";s:3:"ẛ";s:4:"ẛ";s:3:"Ạ";s:3:"AÌ£";s:3:"ạ";s:3:"aÌ£";s:3:"Ả";s:3:"Ả";s:3:"ả";s:3:"ả";s:3:"Ấ";s:5:"AÌ‚Ì";s:3:"ấ";s:5:"aÌ‚Ì";s:3:"Ầ";s:5:"AÌ‚Ì€";s:3:"ầ";s:5:"aÌ‚Ì€";s:3:"Ẩ";s:5:"Ẩ";s:3:"ẩ";s:5:"ẩ";s:3:"Ẫ";s:5:"Ẫ";s:3:"ẫ";s:5:"ẫ";s:3:"Ậ";s:5:"Ậ";s:3:"ậ";s:5:"ậ";s:3:"Ắ";s:5:"ĂÌ";s:3:"ắ";s:5:"ăÌ";s:3:"Ằ";s:5:"Ằ";s:3:"ằ";s:5:"ằ";s:3:"Ẳ";s:5:"Ẳ";s:3:"ẳ";s:5:"ẳ";s:3:"Ẵ";s:5:"Ẵ";s:3:"ẵ";s:5:"ẵ";s:3:"Ặ";s:5:"Ặ";s:3:"ặ";s:5:"ặ";s:3:"Ẹ";s:3:"EÌ£";s:3:"ẹ";s:3:"eÌ£";s:3:"Ẻ";s:3:"Ẻ";s:3:"ẻ";s:3:"ẻ";s:3:"Ẽ";s:3:"Ẽ";s:3:"ẽ";s:3:"ẽ";s:3:"Ế";s:5:"EÌ‚Ì";s:3:"ế";s:5:"eÌ‚Ì";s:3:"Ề";s:5:"EÌ‚Ì€";s:3:"á»";s:5:"eÌ‚Ì€";s:3:"Ể";s:5:"Ể";s:3:"ể";s:5:"ể";s:3:"Ễ";s:5:"Ễ";s:3:"á»…";s:5:"ễ";s:3:"Ệ";s:5:"Ệ";s:3:"ệ";s:5:"ệ";s:3:"Ỉ";s:3:"Ỉ";s:3:"ỉ";s:3:"ỉ";s:3:"Ị";s:3:"IÌ£";s:3:"ị";s:3:"iÌ£";s:3:"Ọ";s:3:"OÌ£";s:3:"á»";s:3:"oÌ£";s:3:"Ỏ";s:3:"Ỏ";s:3:"á»";s:3:"ỏ";s:3:"á»";s:5:"OÌ‚Ì";s:3:"ố";s:5:"oÌ‚Ì";s:3:"á»’";s:5:"OÌ‚Ì€";s:3:"ồ";s:5:"oÌ‚Ì€";s:3:"á»”";s:5:"Ổ";s:3:"ổ";s:5:"ổ";s:3:"á»–";s:5:"Ỗ";s:3:"á»—";s:5:"ỗ";s:3:"Ộ";s:5:"Ộ";s:3:"á»™";s:5:"ộ";s:3:"Ớ";s:5:"OÌ›Ì";s:3:"á»›";s:5:"oÌ›Ì";s:3:"Ờ";s:5:"Ờ";s:3:"á»";s:5:"ờ";s:3:"Ở";s:5:"Ở";s:3:"ở";s:5:"ở";s:3:"á» ";s:5:"Ỡ";s:3:"ỡ";s:5:"ỡ";s:3:"Ợ";s:5:"Ợ";s:3:"ợ";s:5:"ợ";s:3:"Ụ";s:3:"UÌ£";s:3:"ụ";s:3:"uÌ£";s:3:"Ủ";s:3:"Ủ";s:3:"ủ";s:3:"ủ";s:3:"Ứ";s:5:"UÌ›Ì";s:3:"ứ";s:5:"uÌ›Ì";s:3:"Ừ";s:5:"Ừ";s:3:"ừ";s:5:"ừ";s:3:"Ử";s:5:"Ử";s:3:"á»­";s:5:"ử";s:3:"á»®";s:5:"Ữ";s:3:"ữ";s:5:"ữ";s:3:"á»°";s:5:"Ự";s:3:"á»±";s:5:"ự";s:3:"Ỳ";s:3:"YÌ€";s:3:"ỳ";s:3:"yÌ€";s:3:"á»´";s:3:"YÌ£";s:3:"ỵ";s:3:"yÌ£";s:3:"Ỷ";s:3:"Ỷ";s:3:"á»·";s:3:"ỷ";s:3:"Ỹ";s:3:"Ỹ";s:3:"ỹ";s:3:"ỹ";s:3:"á¼€";s:4:"ἀ";s:3:"á¼";s:4:"ἁ";s:3:"ἂ";s:6:"ἂ";s:3:"ἃ";s:6:"ἃ";s:3:"ἄ";s:6:"ἀÌ";s:3:"á¼…";s:6:"ἁÌ";s:3:"ἆ";s:6:"ἆ";s:3:"ἇ";s:6:"ἇ";s:3:"Ἀ";s:4:"Ἀ";s:3:"Ἁ";s:4:"Ἁ";s:3:"Ἂ";s:6:"Ἂ";s:3:"Ἃ";s:6:"Ἃ";s:3:"Ἄ";s:6:"ἈÌ";s:3:"á¼";s:6:"ἉÌ";s:3:"Ἆ";s:6:"Ἆ";s:3:"á¼";s:6:"Ἇ";s:3:"á¼";s:4:"ἐ";s:3:"ἑ";s:4:"ἑ";s:3:"á¼’";s:6:"ἒ";s:3:"ἓ";s:6:"ἓ";s:3:"á¼”";s:6:"ἐÌ";s:3:"ἕ";s:6:"ἑÌ";s:3:"Ἐ";s:4:"Ἐ";s:3:"á¼™";s:4:"Ἑ";s:3:"Ἒ";s:6:"Ἒ";s:3:"á¼›";s:6:"Ἓ";s:3:"Ἔ";s:6:"ἘÌ";s:3:"á¼";s:6:"ἙÌ";s:3:"á¼ ";s:4:"ἠ";s:3:"ἡ";s:4:"ἡ";s:3:"á¼¢";s:6:"ἢ";s:3:"á¼£";s:6:"ἣ";s:3:"ἤ";s:6:"ἠÌ";s:3:"á¼¥";s:6:"ἡÌ";s:3:"ἦ";s:6:"ἦ";s:3:"ἧ";s:6:"ἧ";s:3:"Ἠ";s:4:"Ἠ";s:3:"Ἡ";s:4:"Ἡ";s:3:"Ἢ";s:6:"Ἢ";s:3:"Ἣ";s:6:"Ἣ";s:3:"Ἤ";s:6:"ἨÌ";s:3:"á¼­";s:6:"ἩÌ";s:3:"á¼®";s:6:"Ἦ";s:3:"Ἧ";s:6:"Ἧ";s:3:"á¼°";s:4:"ἰ";s:3:"á¼±";s:4:"ἱ";s:3:"á¼²";s:6:"ἲ";s:3:"á¼³";s:6:"ἳ";s:3:"á¼´";s:6:"ἰÌ";s:3:"á¼µ";s:6:"ἱÌ";s:3:"ἶ";s:6:"ἶ";s:3:"á¼·";s:6:"ἷ";s:3:"Ἰ";s:4:"Ἰ";s:3:"á¼¹";s:4:"Ἱ";s:3:"Ἲ";s:6:"Ἲ";s:3:"á¼»";s:6:"Ἳ";s:3:"á¼¼";s:6:"ἸÌ";s:3:"á¼½";s:6:"ἹÌ";s:3:"á¼¾";s:6:"Ἶ";s:3:"Ἷ";s:6:"Ἷ";s:3:"á½€";s:4:"ὀ";s:3:"á½";s:4:"ὁ";s:3:"ὂ";s:6:"ὂ";s:3:"ὃ";s:6:"ὃ";s:3:"ὄ";s:6:"ὀÌ";s:3:"á½…";s:6:"ὁÌ";s:3:"Ὀ";s:4:"Ὀ";s:3:"Ὁ";s:4:"Ὁ";s:3:"Ὂ";s:6:"Ὂ";s:3:"Ὃ";s:6:"Ὃ";s:3:"Ὄ";s:6:"ὈÌ";s:3:"á½";s:6:"ὉÌ";s:3:"á½";s:4:"Ï…Ì“";s:3:"ὑ";s:4:"Ï…Ì”";s:3:"á½’";s:6:"Ï…Ì“Ì€";s:3:"ὓ";s:6:"ὓ";s:3:"á½”";s:6:"Ï…Ì“Ì";s:3:"ὕ";s:6:"Ï…Ì”Ì";s:3:"á½–";s:6:"Ï…Ì“Í‚";s:3:"á½—";s:6:"ὗ";s:3:"á½™";s:4:"Ὑ";s:3:"á½›";s:6:"Ὓ";s:3:"á½";s:6:"ὙÌ";s:3:"Ὗ";s:6:"Ὗ";s:3:"á½ ";s:4:"ὠ";s:3:"ὡ";s:4:"ὡ";s:3:"á½¢";s:6:"ὢ";s:3:"á½£";s:6:"ὣ";s:3:"ὤ";s:6:"ὠÌ";s:3:"á½¥";s:6:"ὡÌ";s:3:"ὦ";s:6:"ὦ";s:3:"ὧ";s:6:"ὧ";s:3:"Ὠ";s:4:"Ὠ";s:3:"Ὡ";s:4:"Ὡ";s:3:"Ὢ";s:6:"Ὢ";s:3:"Ὣ";s:6:"Ὣ";s:3:"Ὤ";s:6:"ὨÌ";s:3:"á½­";s:6:"ὩÌ";s:3:"á½®";s:6:"Ὦ";s:3:"Ὧ";s:6:"Ὧ";s:3:"á½°";s:4:"ὰ";s:3:"á½±";s:4:"αÌ";s:3:"á½²";s:4:"ὲ";s:3:"á½³";s:4:"εÌ";s:3:"á½´";s:4:"ὴ";s:3:"á½µ";s:4:"ηÌ";s:3:"ὶ";s:4:"ὶ";s:3:"á½·";s:4:"ιÌ";s:3:"ὸ";s:4:"ὸ";s:3:"á½¹";s:4:"οÌ";s:3:"ὺ";s:4:"Ï…Ì€";s:3:"á½»";s:4:"Ï…Ì";s:3:"á½¼";s:4:"ὼ";s:3:"á½½";s:4:"ωÌ";s:3:"á¾€";s:6:"ᾀ";s:3:"á¾";s:6:"ᾁ";s:3:"ᾂ";s:8:"ᾂ";s:3:"ᾃ";s:8:"ᾃ";s:3:"ᾄ";s:8:"ἀÌÍ…";s:3:"á¾…";s:8:"ἁÌÍ…";s:3:"ᾆ";s:8:"ᾆ";s:3:"ᾇ";s:8:"ᾇ";s:3:"ᾈ";s:6:"ᾈ";s:3:"ᾉ";s:6:"ᾉ";s:3:"ᾊ";s:8:"ᾊ";s:3:"ᾋ";s:8:"ᾋ";s:3:"ᾌ";s:8:"ἈÌÍ…";s:3:"á¾";s:8:"ἉÌÍ…";s:3:"ᾎ";s:8:"ᾎ";s:3:"á¾";s:8:"ᾏ";s:3:"á¾";s:6:"ᾐ";s:3:"ᾑ";s:6:"ᾑ";s:3:"á¾’";s:8:"ᾒ";s:3:"ᾓ";s:8:"ᾓ";s:3:"á¾”";s:8:"ἠÌÍ…";s:3:"ᾕ";s:8:"ἡÌÍ…";s:3:"á¾–";s:8:"ᾖ";s:3:"á¾—";s:8:"ᾗ";s:3:"ᾘ";s:6:"ᾘ";s:3:"á¾™";s:6:"ᾙ";s:3:"ᾚ";s:8:"ᾚ";s:3:"á¾›";s:8:"ᾛ";s:3:"ᾜ";s:8:"ἨÌÍ…";s:3:"á¾";s:8:"ἩÌÍ…";s:3:"ᾞ";s:8:"ᾞ";s:3:"ᾟ";s:8:"ᾟ";s:3:"á¾ ";s:6:"ᾠ";s:3:"ᾡ";s:6:"ᾡ";s:3:"á¾¢";s:8:"ᾢ";s:3:"á¾£";s:8:"ᾣ";s:3:"ᾤ";s:8:"ὠÌÍ…";s:3:"á¾¥";s:8:"ὡÌÍ…";s:3:"ᾦ";s:8:"ᾦ";s:3:"ᾧ";s:8:"ᾧ";s:3:"ᾨ";s:6:"ᾨ";s:3:"ᾩ";s:6:"ᾩ";s:3:"ᾪ";s:8:"ᾪ";s:3:"ᾫ";s:8:"ᾫ";s:3:"ᾬ";s:8:"ὨÌÍ…";s:3:"á¾­";s:8:"ὩÌÍ…";s:3:"á¾®";s:8:"ᾮ";s:3:"ᾯ";s:8:"ᾯ";s:3:"á¾°";s:4:"ᾰ";s:3:"á¾±";s:4:"ᾱ";s:3:"á¾²";s:6:"ᾲ";s:3:"á¾³";s:4:"ᾳ";s:3:"á¾´";s:6:"αÌÍ…";s:3:"ᾶ";s:4:"ᾶ";s:3:"á¾·";s:6:"ᾷ";s:3:"Ᾰ";s:4:"Ᾰ";s:3:"á¾¹";s:4:"Ᾱ";s:3:"Ὰ";s:4:"Ὰ";s:3:"á¾»";s:4:"ΑÌ";s:3:"á¾¼";s:4:"ᾼ";s:3:"á¾¾";s:2:"ι";s:3:"á¿";s:4:"῁";s:3:"á¿‚";s:6:"ῂ";s:3:"ῃ";s:4:"ῃ";s:3:"á¿„";s:6:"ηÌÍ…";s:3:"ῆ";s:4:"ῆ";s:3:"ῇ";s:6:"ῇ";s:3:"Ὲ";s:4:"Ὲ";s:3:"Έ";s:4:"ΕÌ";s:3:"á¿Š";s:4:"Ὴ";s:3:"á¿‹";s:4:"ΗÌ";s:3:"á¿Œ";s:4:"ῌ";s:3:"á¿";s:5:"῍";s:3:"á¿Ž";s:5:"᾿Ì";s:3:"á¿";s:5:"῏";s:3:"á¿";s:4:"ῐ";s:3:"á¿‘";s:4:"ῑ";s:3:"á¿’";s:6:"ῒ";s:3:"á¿“";s:6:"ϊÌ";s:3:"á¿–";s:4:"ῖ";s:3:"á¿—";s:6:"ῗ";s:3:"Ῐ";s:4:"Ῐ";s:3:"á¿™";s:4:"Ῑ";s:3:"á¿š";s:4:"Ὶ";s:3:"á¿›";s:4:"ΙÌ";s:3:"á¿";s:5:"῝";s:3:"á¿ž";s:5:"῾Ì";s:3:"á¿Ÿ";s:5:"῟";s:3:"á¿ ";s:4:"ῠ";s:3:"á¿¡";s:4:"Ï…Ì„";s:3:"á¿¢";s:6:"ῢ";s:3:"á¿£";s:6:"ϋÌ";s:3:"ῤ";s:4:"ÏÌ“";s:3:"á¿¥";s:4:"ÏÌ”";s:3:"ῦ";s:4:"Ï…Í‚";s:3:"ῧ";s:6:"ῧ";s:3:"Ῠ";s:4:"Ῠ";s:3:"á¿©";s:4:"Ῡ";s:3:"Ὺ";s:4:"Ὺ";s:3:"á¿«";s:4:"Î¥Ì";s:3:"Ῥ";s:4:"Ῥ";s:3:"á¿­";s:4:"῭";s:3:"á¿®";s:4:"¨Ì";s:3:"`";s:1:"`";s:3:"ῲ";s:6:"ῲ";s:3:"ῳ";s:4:"ῳ";s:3:"á¿´";s:6:"ωÌÍ…";s:3:"ῶ";s:4:"ῶ";s:3:"á¿·";s:6:"ῷ";s:3:"Ὸ";s:4:"Ὸ";s:3:"Ό";s:4:"ΟÌ";s:3:"Ὼ";s:4:"Ὼ";s:3:"á¿»";s:4:"ΩÌ";s:3:"ῼ";s:4:"ῼ";s:3:"´";s:2:"´";s:3:" ";s:3:" ";s:3:"â€";s:3:" ";s:3:"Ω";s:2:"Ω";s:3:"K";s:1:"K";s:3:"â„«";s:3:"AÌŠ";s:3:"↚";s:5:"â†Ì¸";s:3:"↛";s:5:"↛";s:3:"↮";s:5:"↮";s:3:"â‡";s:5:"â‡Ì¸";s:3:"⇎";s:5:"⇎";s:3:"â‡";s:5:"⇏";s:3:"∄";s:5:"∄";s:3:"∉";s:5:"∉";s:3:"∌";s:5:"∌";s:3:"∤";s:5:"∤";s:3:"∦";s:5:"∦";s:3:"â‰";s:5:"≁";s:3:"≄";s:5:"≄";s:3:"≇";s:5:"≇";s:3:"≉";s:5:"≉";s:3:"≠";s:3:"≠";s:3:"≢";s:5:"≢";s:3:"≭";s:5:"â‰Ì¸";s:3:"≮";s:3:"≮";s:3:"≯";s:3:"≯";s:3:"≰";s:5:"≰";s:3:"≱";s:5:"≱";s:3:"≴";s:5:"≴";s:3:"≵";s:5:"≵";s:3:"≸";s:5:"≸";s:3:"≹";s:5:"≹";s:3:"⊀";s:5:"⊀";s:3:"âŠ";s:5:"⊁";s:3:"⊄";s:5:"⊄";s:3:"⊅";s:5:"⊅";s:3:"⊈";s:5:"⊈";s:3:"⊉";s:5:"⊉";s:3:"⊬";s:5:"⊬";s:3:"⊭";s:5:"⊭";s:3:"⊮";s:5:"⊮";s:3:"⊯";s:5:"⊯";s:3:"â‹ ";s:5:"⋠";s:3:"â‹¡";s:5:"⋡";s:3:"â‹¢";s:5:"⋢";s:3:"â‹£";s:5:"⋣";s:3:"⋪";s:5:"⋪";s:3:"â‹«";s:5:"⋫";s:3:"⋬";s:5:"⋬";s:3:"â‹­";s:5:"⋭";s:3:"〈";s:3:"〈";s:3:"〉";s:3:"〉";s:3:"â«œ";s:5:"â«Ì¸";s:3:"ãŒ";s:6:"ã‹ã‚™";s:3:"ãŽ";s:6:"ãã‚™";s:3:"ã";s:6:"ãã‚™";s:3:"ã’";s:6:"ã‘ã‚™";s:3:"ã”";s:6:"ã“ã‚™";s:3:"ã–";s:6:"ã•ã‚™";s:3:"ã˜";s:6:"ã—ã‚™";s:3:"ãš";s:6:"ã™ã‚™";s:3:"ãœ";s:6:"ã›ã‚™";s:3:"ãž";s:6:"ãã‚™";s:3:"ã ";s:6:"ãŸã‚™";s:3:"ã¢";s:6:"ã¡ã‚™";s:3:"ã¥";s:6:"ã¤ã‚™";s:3:"ã§";s:6:"ã¦ã‚™";s:3:"ã©";s:6:"ã¨ã‚™";s:3:"ã°";s:6:"ã¯ã‚™";s:3:"ã±";s:6:"ã¯ã‚š";s:3:"ã³";s:6:"ã²ã‚™";s:3:"ã´";s:6:"ã²ã‚š";s:3:"ã¶";s:6:"ãµã‚™";s:3:"ã·";s:6:"ãµã‚š";s:3:"ã¹";s:6:"ã¸ã‚™";s:3:"ãº";s:6:"ã¸ã‚š";s:3:"ã¼";s:6:"ã»ã‚™";s:3:"ã½";s:6:"ã»ã‚š";s:3:"ã‚”";s:6:"ã†ã‚™";s:3:"ã‚ž";s:6:"ã‚ã‚™";s:3:"ガ";s:6:"ã‚«ã‚™";s:3:"ã‚®";s:6:"ã‚­ã‚™";s:3:"ã‚°";s:6:"グ";s:3:"ゲ";s:6:"ゲ";s:3:"ã‚´";s:6:"ゴ";s:3:"ザ";s:6:"ザ";s:3:"ジ";s:6:"ã‚·ã‚™";s:3:"ズ";s:6:"ズ";s:3:"ゼ";s:6:"ゼ";s:3:"ゾ";s:6:"ゾ";s:3:"ダ";s:6:"ã‚¿ã‚™";s:3:"ヂ";s:6:"ãƒã‚™";s:3:"ヅ";s:6:"ヅ";s:3:"デ";s:6:"デ";s:3:"ド";s:6:"ド";s:3:"ãƒ";s:6:"ãƒã‚™";s:3:"パ";s:6:"ãƒã‚š";s:3:"ビ";s:6:"ビ";s:3:"ピ";s:6:"ピ";s:3:"ブ";s:6:"ブ";s:3:"プ";s:6:"プ";s:3:"ベ";s:6:"ベ";s:3:"ペ";s:6:"ペ";s:3:"ボ";s:6:"ボ";s:3:"ãƒ";s:6:"ポ";s:3:"ヴ";s:6:"ヴ";s:3:"ヷ";s:6:"ヷ";s:3:"ヸ";s:6:"ヸ";s:3:"ヹ";s:6:"ヹ";s:3:"ヺ";s:6:"ヺ";s:3:"ヾ";s:6:"ヾ";s:3:"豈";s:3:"豈";s:3:"ï¤";s:3:"æ›´";s:3:"車";s:3:"車";s:3:"賈";s:3:"賈";s:3:"滑";s:3:"滑";s:3:"串";s:3:"串";s:3:"句";s:3:"å¥";s:3:"龜";s:3:"龜";s:3:"龜";s:3:"龜";s:3:"契";s:3:"契";s:3:"金";s:3:"金";s:3:"喇";s:3:"å–‡";s:3:"奈";s:3:"奈";s:3:"ï¤";s:3:"懶";s:3:"癩";s:3:"癩";s:3:"ï¤";s:3:"ç¾…";s:3:"ï¤";s:3:"蘿";s:3:"螺";s:3:"螺";s:3:"裸";s:3:"裸";s:3:"邏";s:3:"é‚";s:3:"樂";s:3:"樂";s:3:"洛";s:3:"æ´›";s:3:"烙";s:3:"烙";s:3:"珞";s:3:"çž";s:3:"落";s:3:"è½";s:3:"酪";s:3:"é…ª";s:3:"駱";s:3:"駱";s:3:"亂";s:3:"亂";s:3:"卵";s:3:"åµ";s:3:"ï¤";s:3:"欄";s:3:"爛";s:3:"爛";s:3:"蘭";s:3:"蘭";s:3:"鸞";s:3:"鸞";s:3:"嵐";s:3:"åµ";s:3:"濫";s:3:"æ¿«";s:3:"藍";s:3:"è—";s:3:"襤";s:3:"襤";s:3:"拉";s:3:"拉";s:3:"臘";s:3:"臘";s:3:"蠟";s:3:"è Ÿ";s:3:"廊";s:3:"廊";s:3:"朗";s:3:"朗";s:3:"浪";s:3:"浪";s:3:"狼";s:3:"狼";s:3:"郎";s:3:"郎";s:3:"來";s:3:"來";s:3:"冷";s:3:"冷";s:3:"勞";s:3:"å‹ž";s:3:"擄";s:3:"æ“„";s:3:"櫓";s:3:"æ«“";s:3:"爐";s:3:"çˆ";s:3:"盧";s:3:"盧";s:3:"老";s:3:"è€";s:3:"蘆";s:3:"蘆";s:3:"虜";s:3:"虜";s:3:"路";s:3:"è·¯";s:3:"露";s:3:"露";s:3:"魯";s:3:"é­¯";s:3:"鷺";s:3:"é·º";s:3:"碌";s:3:"碌";s:3:"祿";s:3:"祿";s:3:"綠";s:3:"綠";s:3:"菉";s:3:"è‰";s:3:"錄";s:3:"錄";s:3:"鹿";s:3:"鹿";s:3:"ï¥";s:3:"è«–";s:3:"壟";s:3:"壟";s:3:"弄";s:3:"弄";s:3:"籠";s:3:"ç± ";s:3:"聾";s:3:"è¾";s:3:"牢";s:3:"牢";s:3:"磊";s:3:"磊";s:3:"賂";s:3:"賂";s:3:"雷";s:3:"é›·";s:3:"壘";s:3:"壘";s:3:"屢";s:3:"å±¢";s:3:"樓";s:3:"樓";s:3:"ï¥";s:3:"æ·š";s:3:"漏";s:3:"æ¼";s:3:"ï¥";s:3:"ç´¯";s:3:"ï¥";s:3:"縷";s:3:"陋";s:3:"陋";s:3:"勒";s:3:"å‹’";s:3:"肋";s:3:"è‚‹";s:3:"凜";s:3:"凜";s:3:"凌";s:3:"凌";s:3:"稜";s:3:"稜";s:3:"綾";s:3:"綾";s:3:"菱";s:3:"è±";s:3:"陵";s:3:"陵";s:3:"讀";s:3:"讀";s:3:"拏";s:3:"æ‹";s:3:"樂";s:3:"樂";s:3:"ï¥";s:3:"諾";s:3:"丹";s:3:"丹";s:3:"寧";s:3:"寧";s:3:"怒";s:3:"怒";s:3:"率";s:3:"率";s:3:"異";s:3:"ç•°";s:3:"北";s:3:"北";s:3:"磻";s:3:"磻";s:3:"便";s:3:"便";s:3:"復";s:3:"復";s:3:"不";s:3:"ä¸";s:3:"泌";s:3:"泌";s:3:"數";s:3:"數";s:3:"索";s:3:"ç´¢";s:3:"參";s:3:"åƒ";s:3:"塞";s:3:"å¡ž";s:3:"省";s:3:"çœ";s:3:"葉";s:3:"葉";s:3:"說";s:3:"說";s:3:"殺";s:3:"殺";s:3:"辰";s:3:"è¾°";s:3:"沈";s:3:"沈";s:3:"拾";s:3:"拾";s:3:"若";s:3:"è‹¥";s:3:"掠";s:3:"掠";s:3:"略";s:3:"ç•¥";s:3:"亮";s:3:"亮";s:3:"兩";s:3:"å…©";s:3:"凉";s:3:"凉";s:3:"梁";s:3:"æ¢";s:3:"糧";s:3:"糧";s:3:"良";s:3:"良";s:3:"諒";s:3:"è«’";s:3:"量";s:3:"é‡";s:3:"勵";s:3:"勵";s:3:"呂";s:3:"å‘‚";s:3:"ï¦";s:3:"女";s:3:"廬";s:3:"廬";s:3:"旅";s:3:"æ—…";s:3:"濾";s:3:"濾";s:3:"礪";s:3:"礪";s:3:"閭";s:3:"é–­";s:3:"驪";s:3:"驪";s:3:"麗";s:3:"麗";s:3:"黎";s:3:"黎";s:3:"力";s:3:"力";s:3:"曆";s:3:"曆";s:3:"歷";s:3:"æ­·";s:3:"ï¦";s:3:"è½¢";s:3:"年";s:3:"å¹´";s:3:"ï¦";s:3:"æ†";s:3:"ï¦";s:3:"戀";s:3:"撚";s:3:"æ’š";s:3:"漣";s:3:"æ¼£";s:3:"煉";s:3:"ç…‰";s:3:"璉";s:3:"ç’‰";s:3:"秊";s:3:"秊";s:3:"練";s:3:"ç·´";s:3:"聯";s:3:"è¯";s:3:"輦";s:3:"輦";s:3:"蓮";s:3:"è“®";s:3:"連";s:3:"連";s:3:"鍊";s:3:"éŠ";s:3:"列";s:3:"列";s:3:"ï¦";s:3:"劣";s:3:"咽";s:3:"å’½";s:3:"烈";s:3:"烈";s:3:"裂";s:3:"裂";s:3:"說";s:3:"說";s:3:"廉";s:3:"廉";s:3:"念";s:3:"念";s:3:"捻";s:3:"æ»";s:3:"殮";s:3:"æ®®";s:3:"簾";s:3:"ç°¾";s:3:"獵";s:3:"çµ";s:3:"令";s:3:"令";s:3:"囹";s:3:"囹";s:3:"寧";s:3:"寧";s:3:"嶺";s:3:"嶺";s:3:"怜";s:3:"怜";s:3:"玲";s:3:"玲";s:3:"瑩";s:3:"ç‘©";s:3:"羚";s:3:"羚";s:3:"聆";s:3:"è†";s:3:"鈴";s:3:"鈴";s:3:"零";s:3:"零";s:3:"靈";s:3:"éˆ";s:3:"領";s:3:"é ˜";s:3:"例";s:3:"例";s:3:"禮";s:3:"禮";s:3:"醴";s:3:"醴";s:3:"隸";s:3:"隸";s:3:"惡";s:3:"惡";s:3:"了";s:3:"了";s:3:"僚";s:3:"僚";s:3:"寮";s:3:"寮";s:3:"尿";s:3:"å°¿";s:3:"料";s:3:"æ–™";s:3:"樂";s:3:"樂";s:3:"燎";s:3:"燎";s:3:"ï§";s:3:"療";s:3:"蓼";s:3:"蓼";s:3:"遼";s:3:"é¼";s:3:"龍";s:3:"é¾";s:3:"暈";s:3:"暈";s:3:"阮";s:3:"阮";s:3:"劉";s:3:"劉";s:3:"杻";s:3:"æ»";s:3:"柳";s:3:"柳";s:3:"流";s:3:"æµ";s:3:"溜";s:3:"溜";s:3:"琉";s:3:"ç‰";s:3:"ï§";s:3:"ç•™";s:3:"硫";s:3:"ç¡«";s:3:"ï§";s:3:"ç´";s:3:"ï§";s:3:"é¡ž";s:3:"六";s:3:"å…­";s:3:"戮";s:3:"戮";s:3:"陸";s:3:"陸";s:3:"倫";s:3:"倫";s:3:"崙";s:3:"å´™";s:3:"淪";s:3:"æ·ª";s:3:"輪";s:3:"輪";s:3:"律";s:3:"律";s:3:"慄";s:3:"æ…„";s:3:"栗";s:3:"æ —";s:3:"率";s:3:"率";s:3:"隆";s:3:"隆";s:3:"ï§";s:3:"利";s:3:"吏";s:3:"å";s:3:"履";s:3:"å±¥";s:3:"易";s:3:"易";s:3:"李";s:3:"æŽ";s:3:"梨";s:3:"梨";s:3:"泥";s:3:"æ³¥";s:3:"理";s:3:"ç†";s:3:"痢";s:3:"ç—¢";s:3:"罹";s:3:"ç½¹";s:3:"裏";s:3:"è£";s:3:"裡";s:3:"裡";s:3:"里";s:3:"里";s:3:"離";s:3:"離";s:3:"匿";s:3:"匿";s:3:"溺";s:3:"溺";s:3:"吝";s:3:"å";s:3:"燐";s:3:"ç‡";s:3:"璘";s:3:"ç’˜";s:3:"藺";s:3:"è—º";s:3:"隣";s:3:"隣";s:3:"鱗";s:3:"é±—";s:3:"麟";s:3:"麟";s:3:"林";s:3:"æž—";s:3:"淋";s:3:"æ·‹";s:3:"臨";s:3:"臨";s:3:"立";s:3:"ç«‹";s:3:"笠";s:3:"笠";s:3:"粒";s:3:"ç²’";s:3:"狀";s:3:"ç‹€";s:3:"炙";s:3:"ç‚™";s:3:"識";s:3:"è­˜";s:3:"什";s:3:"什";s:3:"茶";s:3:"茶";s:3:"刺";s:3:"刺";s:3:"切";s:3:"切";s:3:"ï¨";s:3:"度";s:3:"拓";s:3:"æ‹“";s:3:"糖";s:3:"ç³–";s:3:"宅";s:3:"å®…";s:3:"洞";s:3:"æ´ž";s:3:"暴";s:3:"æš´";s:3:"輻";s:3:"è¼»";s:3:"行";s:3:"è¡Œ";s:3:"降";s:3:"é™";s:3:"見";s:3:"見";s:3:"廓";s:3:"廓";s:3:"兀";s:3:"å…€";s:3:"ï¨";s:3:"å—€";s:3:"ï¨";s:3:"å¡š";s:3:"晴";s:3:"æ™´";s:3:"凞";s:3:"凞";s:3:"猪";s:3:"猪";s:3:"益";s:3:"益";s:3:"礼";s:3:"礼";s:3:"神";s:3:"神";s:3:"祥";s:3:"祥";s:3:"福";s:3:"ç¦";s:3:"靖";s:3:"é–";s:3:"ï¨";s:3:"ç²¾";s:3:"羽";s:3:"ç¾½";s:3:"蘒";s:3:"蘒";s:3:"諸";s:3:"諸";s:3:"逸";s:3:"逸";s:3:"都";s:3:"都";s:3:"飯";s:3:"飯";s:3:"飼";s:3:"飼";s:3:"館";s:3:"館";s:3:"鶴";s:3:"鶴";s:3:"郞";s:3:"郞";s:3:"隷";s:3:"éš·";s:3:"侮";s:3:"ä¾®";s:3:"僧";s:3:"僧";s:3:"免";s:3:"å…";s:3:"勉";s:3:"勉";s:3:"勤";s:3:"勤";s:3:"卑";s:3:"å‘";s:3:"喝";s:3:"å–";s:3:"嘆";s:3:"嘆";s:3:"器";s:3:"器";s:3:"塀";s:3:"å¡€";s:3:"墨";s:3:"墨";s:3:"層";s:3:"層";s:3:"屮";s:3:"å±®";s:3:"悔";s:3:"æ‚”";s:3:"慨";s:3:"æ…¨";s:3:"憎";s:3:"憎";s:3:"ï©€";s:3:"懲";s:3:"ï©";s:3:"æ•";s:3:"ï©‚";s:3:"æ—¢";s:3:"暑";s:3:"æš‘";s:3:"ï©„";s:3:"梅";s:3:"ï©…";s:3:"æµ·";s:3:"渚";s:3:"渚";s:3:"漢";s:3:"æ¼¢";s:3:"煮";s:3:"ç…®";s:3:"爫";s:3:"爫";s:3:"ï©Š";s:3:"ç¢";s:3:"ï©‹";s:3:"碑";s:3:"ï©Œ";s:3:"社";s:3:"ï©";s:3:"祉";s:3:"ï©Ž";s:3:"祈";s:3:"ï©";s:3:"ç¥";s:3:"ï©";s:3:"祖";s:3:"ï©‘";s:3:"ç¥";s:3:"ï©’";s:3:"ç¦";s:3:"ï©“";s:3:"禎";s:3:"ï©”";s:3:"ç©€";s:3:"ï©•";s:3:"çª";s:3:"ï©–";s:3:"節";s:3:"ï©—";s:3:"ç·´";s:3:"縉";s:3:"縉";s:3:"ï©™";s:3:"ç¹";s:3:"ï©š";s:3:"ç½²";s:3:"ï©›";s:3:"者";s:3:"ï©œ";s:3:"臭";s:3:"ï©";s:3:"艹";s:3:"ï©ž";s:3:"艹";s:3:"ï©Ÿ";s:3:"è‘—";s:3:"ï© ";s:3:"è¤";s:3:"ï©¡";s:3:"視";s:3:"ï©¢";s:3:"è¬";s:3:"ï©£";s:3:"謹";s:3:"賓";s:3:"賓";s:3:"ï©¥";s:3:"è´ˆ";s:3:"辶";s:3:"辶";s:3:"逸";s:3:"逸";s:3:"難";s:3:"難";s:3:"ï©©";s:3:"響";s:3:"頻";s:3:"é »";s:3:"ï©«";s:3:"æµ";s:3:"𤋮";s:4:"𤋮";s:3:"ï©­";s:3:"舘";s:3:"ï©°";s:3:"並";s:3:"况";s:3:"况";s:3:"全";s:3:"å…¨";s:3:"侀";s:3:"ä¾€";s:3:"ï©´";s:3:"å……";s:3:"冀";s:3:"冀";s:3:"勇";s:3:"勇";s:3:"ï©·";s:3:"勺";s:3:"喝";s:3:"å–";s:3:"啕";s:3:"å••";s:3:"喙";s:3:"å–™";s:3:"ï©»";s:3:"å—¢";s:3:"塚";s:3:"å¡š";s:3:"墳";s:3:"墳";s:3:"奄";s:3:"奄";s:3:"ï©¿";s:3:"奔";s:3:"婢";s:3:"å©¢";s:3:"ïª";s:3:"嬨";s:3:"廒";s:3:"å»’";s:3:"廙";s:3:"å»™";s:3:"彩";s:3:"彩";s:3:"徭";s:3:"å¾­";s:3:"惘";s:3:"惘";s:3:"慎";s:3:"æ…Ž";s:3:"愈";s:3:"愈";s:3:"憎";s:3:"憎";s:3:"慠";s:3:"æ… ";s:3:"懲";s:3:"懲";s:3:"戴";s:3:"戴";s:3:"ïª";s:3:"æ„";s:3:"搜";s:3:"æœ";s:3:"ïª";s:3:"æ‘’";s:3:"ïª";s:3:"æ•–";s:3:"晴";s:3:"æ™´";s:3:"朗";s:3:"朗";s:3:"望";s:3:"望";s:3:"杖";s:3:"æ–";s:3:"歹";s:3:"æ­¹";s:3:"殺";s:3:"殺";s:3:"流";s:3:"æµ";s:3:"滛";s:3:"æ»›";s:3:"滋";s:3:"滋";s:3:"漢";s:3:"æ¼¢";s:3:"瀞";s:3:"瀞";s:3:"煮";s:3:"ç…®";s:3:"ïª";s:3:"瞧";s:3:"爵";s:3:"爵";s:3:"犯";s:3:"犯";s:3:"猪";s:3:"猪";s:3:"瑱";s:3:"瑱";s:3:"甆";s:3:"甆";s:3:"画";s:3:"ç”»";s:3:"瘝";s:3:"ç˜";s:3:"瘟";s:3:"瘟";s:3:"益";s:3:"益";s:3:"盛";s:3:"ç››";s:3:"直";s:3:"ç›´";s:3:"睊";s:3:"çŠ";s:3:"着";s:3:"ç€";s:3:"磌";s:3:"磌";s:3:"窱";s:3:"窱";s:3:"節";s:3:"節";s:3:"类";s:3:"ç±»";s:3:"絛";s:3:"çµ›";s:3:"練";s:3:"ç·´";s:3:"缾";s:3:"ç¼¾";s:3:"者";s:3:"者";s:3:"荒";s:3:"è’";s:3:"華";s:3:"è¯";s:3:"蝹";s:3:"è¹";s:3:"襁";s:3:"è¥";s:3:"覆";s:3:"覆";s:3:"視";s:3:"視";s:3:"調";s:3:"調";s:3:"諸";s:3:"諸";s:3:"請";s:3:"è«‹";s:3:"謁";s:3:"è¬";s:3:"諾";s:3:"諾";s:3:"諭";s:3:"è«­";s:3:"謹";s:3:"謹";s:3:"ï«€";s:3:"變";s:3:"ï«";s:3:"è´ˆ";s:3:"ï«‚";s:3:"輸";s:3:"遲";s:3:"é²";s:3:"ï«„";s:3:"醙";s:3:"ï«…";s:3:"鉶";s:3:"陼";s:3:"陼";s:3:"難";s:3:"難";s:3:"靖";s:3:"é–";s:3:"韛";s:3:"韛";s:3:"ï«Š";s:3:"響";s:3:"ï«‹";s:3:"é ‹";s:3:"ï«Œ";s:3:"é »";s:3:"ï«";s:3:"鬒";s:3:"ï«Ž";s:3:"龜";s:3:"ï«";s:4:"𢡊";s:3:"ï«";s:4:"𢡄";s:3:"ï«‘";s:4:"ð£•";s:3:"ï«’";s:3:"ã®";s:3:"ï«“";s:3:"䀘";s:3:"ï«”";s:3:"䀹";s:3:"ï«•";s:4:"𥉉";s:3:"ï«–";s:4:"ð¥³";s:3:"ï«—";s:4:"𧻓";s:3:"齃";s:3:"齃";s:3:"ï«™";s:3:"龎";s:3:"ï¬";s:4:"×™Ö´";s:3:"ײַ";s:4:"ײַ";s:3:"שׁ";s:4:"ש×";s:3:"שׂ";s:4:"שׂ";s:3:"שּׁ";s:6:"שּ×";s:3:"שּׂ";s:6:"שּׂ";s:3:"אַ";s:4:"×Ö·";s:3:"אָ";s:4:"×Ö¸";s:3:"אּ";s:4:"×Ö¼";s:3:"בּ";s:4:"בּ";s:3:"גּ";s:4:"×’Ö¼";s:3:"דּ";s:4:"דּ";s:3:"הּ";s:4:"×”Ö¼";s:3:"וּ";s:4:"וּ";s:3:"זּ";s:4:"×–Ö¼";s:3:"טּ";s:4:"טּ";s:3:"יּ";s:4:"×™Ö¼";s:3:"ךּ";s:4:"ךּ";s:3:"כּ";s:4:"×›Ö¼";s:3:"לּ";s:4:"לּ";s:3:"מּ";s:4:"מּ";s:3:"ï­€";s:4:"× Ö¼";s:3:"ï­";s:4:"סּ";s:3:"ï­ƒ";s:4:"×£Ö¼";s:3:"ï­„";s:4:"פּ";s:3:"ï­†";s:4:"צּ";s:3:"ï­‡";s:4:"קּ";s:3:"ï­ˆ";s:4:"רּ";s:3:"ï­‰";s:4:"שּ";s:3:"ï­Š";s:4:"תּ";s:3:"ï­‹";s:4:"וֹ";s:3:"ï­Œ";s:4:"בֿ";s:3:"ï­";s:4:"×›Ö¿";s:3:"ï­Ž";s:4:"פֿ";s:4:"ð‘‚š";s:8:"𑂚";s:4:"ð‘‚œ";s:8:"𑂜";s:4:"ð‘‚«";s:8:"𑂫";s:4:"ð‘„®";s:8:"𑄮";s:4:"𑄯";s:8:"𑄯";s:4:"ð…ž";s:8:"ð…—ð…¥";s:4:"ð…Ÿ";s:8:"ð…˜ð…¥";s:4:"ð… ";s:12:"ð…˜ð…¥ð…®";s:4:"ð…¡";s:12:"ð…˜ð…¥ð…¯";s:4:"ð…¢";s:12:"ð…˜ð…¥ð…°";s:4:"ð…£";s:12:"ð…˜ð…¥ð…±";s:4:"ð…¤";s:12:"ð…˜ð…¥ð…²";s:4:"ð†»";s:8:"ð†¹ð…¥";s:4:"ð†¼";s:8:"ð†ºð…¥";s:4:"ð†½";s:12:"ð†¹ð…¥ð…®";s:4:"ð†¾";s:12:"ð†ºð…¥ð…®";s:4:"ð†¿";s:12:"ð†¹ð…¥ð…¯";s:4:"ð‡€";s:12:"ð†ºð…¥ð…¯";s:4:"丽";s:3:"丽";s:4:"ð¯ ";s:3:"丸";s:4:"乁";s:3:"ä¹";s:4:"𠄢";s:4:"ð „¢";s:4:"你";s:3:"ä½ ";s:4:"侮";s:3:"ä¾®";s:4:"侻";s:3:"ä¾»";s:4:"倂";s:3:"倂";s:4:"偺";s:3:"åº";s:4:"備";s:3:"å‚™";s:4:"僧";s:3:"僧";s:4:"像";s:3:"åƒ";s:4:"㒞";s:3:"ã’ž";s:4:"ð¯ ";s:4:"𠘺";s:4:"免";s:3:"å…";s:4:"ð¯ ";s:3:"å…”";s:4:"ð¯ ";s:3:"å…¤";s:4:"具";s:3:"å…·";s:4:"𠔜";s:4:"𠔜";s:4:"㒹";s:3:"ã’¹";s:4:"內";s:3:"å…§";s:4:"再";s:3:"å†";s:4:"𠕋";s:4:"ð •‹";s:4:"冗";s:3:"冗";s:4:"冤";s:3:"冤";s:4:"仌";s:3:"仌";s:4:"冬";s:3:"冬";s:4:"况";s:3:"况";s:4:"𩇟";s:4:"𩇟";s:4:"ð¯ ";s:3:"凵";s:4:"刃";s:3:"刃";s:4:"㓟";s:3:"ã“Ÿ";s:4:"刻";s:3:"刻";s:4:"剆";s:3:"剆";s:4:"割";s:3:"割";s:4:"剷";s:3:"剷";s:4:"㔕";s:3:"㔕";s:4:"勇";s:3:"勇";s:4:"勉";s:3:"勉";s:4:"勤";s:3:"勤";s:4:"勺";s:3:"勺";s:4:"包";s:3:"包";s:4:"匆";s:3:"匆";s:4:"北";s:3:"北";s:4:"卉";s:3:"å‰";s:4:"卑";s:3:"å‘";s:4:"博";s:3:"åš";s:4:"即";s:3:"å³";s:4:"卽";s:3:"å½";s:4:"卿";s:3:"å¿";s:4:"卿";s:3:"å¿";s:4:"卿";s:3:"å¿";s:4:"𠨬";s:4:"𠨬";s:4:"灰";s:3:"ç°";s:4:"及";s:3:"åŠ";s:4:"叟";s:3:"åŸ";s:4:"𠭣";s:4:"ð ­£";s:4:"叫";s:3:"å«";s:4:"叱";s:3:"å±";s:4:"吆";s:3:"å†";s:4:"咞";s:3:"å’ž";s:4:"吸";s:3:"å¸";s:4:"呈";s:3:"呈";s:4:"周";s:3:"周";s:4:"咢";s:3:"å’¢";s:4:"ð¯¡";s:3:"哶";s:4:"唐";s:3:"å”";s:4:"啓";s:3:"å•“";s:4:"啣";s:3:"å•£";s:4:"善";s:3:"å–„";s:4:"善";s:3:"å–„";s:4:"喙";s:3:"å–™";s:4:"喫";s:3:"å–«";s:4:"喳";s:3:"å–³";s:4:"嗂";s:3:"å—‚";s:4:"圖";s:3:"圖";s:4:"嘆";s:3:"嘆";s:4:"ð¯¡";s:3:"圗";s:4:"噑";s:3:"噑";s:4:"ð¯¡";s:3:"å™´";s:4:"ð¯¡";s:3:"切";s:4:"壮";s:3:"壮";s:4:"城";s:3:"城";s:4:"埴";s:3:"埴";s:4:"堍";s:3:"å ";s:4:"型";s:3:"åž‹";s:4:"堲";s:3:"å ²";s:4:"報";s:3:"å ±";s:4:"墬";s:3:"墬";s:4:"𡓤";s:4:"𡓤";s:4:"売";s:3:"売";s:4:"壷";s:3:"壷";s:4:"夆";s:3:"夆";s:4:"ð¯¡";s:3:"多";s:4:"夢";s:3:"夢";s:4:"奢";s:3:"奢";s:4:"𡚨";s:4:"𡚨";s:4:"𡛪";s:4:"𡛪";s:4:"姬";s:3:"姬";s:4:"娛";s:3:"娛";s:4:"娧";s:3:"娧";s:4:"姘";s:3:"姘";s:4:"婦";s:3:"婦";s:4:"㛮";s:3:"ã›®";s:4:"㛼";s:3:"㛼";s:4:"嬈";s:3:"嬈";s:4:"嬾";s:3:"嬾";s:4:"嬾";s:3:"嬾";s:4:"𡧈";s:4:"𡧈";s:4:"寃";s:3:"寃";s:4:"寘";s:3:"寘";s:4:"寧";s:3:"寧";s:4:"寳";s:3:"寳";s:4:"𡬘";s:4:"𡬘";s:4:"寿";s:3:"寿";s:4:"将";s:3:"å°†";s:4:"当";s:3:"当";s:4:"尢";s:3:"å°¢";s:4:"㞁";s:3:"ãž";s:4:"屠";s:3:"å± ";s:4:"屮";s:3:"å±®";s:4:"峀";s:3:"å³€";s:4:"岍";s:3:"å²";s:4:"𡷤";s:4:"ð¡·¤";s:4:"嵃";s:3:"嵃";s:4:"𡷦";s:4:"ð¡·¦";s:4:"嵮";s:3:"åµ®";s:4:"嵫";s:3:"嵫";s:4:"嵼";s:3:"åµ¼";s:4:"ð¯¢";s:3:"å·¡";s:4:"巢";s:3:"å·¢";s:4:"㠯";s:3:"ã ¯";s:4:"巽";s:3:"å·½";s:4:"帨";s:3:"帨";s:4:"帽";s:3:"帽";s:4:"幩";s:3:"幩";s:4:"㡢";s:3:"ã¡¢";s:4:"𢆃";s:4:"𢆃";s:4:"㡼";s:3:"㡼";s:4:"庰";s:3:"庰";s:4:"庳";s:3:"庳";s:4:"ð¯¢";s:3:"庶";s:4:"廊";s:3:"廊";s:4:"ð¯¢";s:4:"𪎒";s:4:"ð¯¢";s:3:"廾";s:4:"𢌱";s:4:"𢌱";s:4:"𢌱";s:4:"𢌱";s:4:"舁";s:3:"èˆ";s:4:"弢";s:3:"å¼¢";s:4:"弢";s:3:"å¼¢";s:4:"㣇";s:3:"㣇";s:4:"𣊸";s:4:"𣊸";s:4:"𦇚";s:4:"𦇚";s:4:"形";s:3:"å½¢";s:4:"彫";s:3:"彫";s:4:"㣣";s:3:"㣣";s:4:"徚";s:3:"徚";s:4:"ð¯¢";s:3:"å¿";s:4:"志";s:3:"å¿—";s:4:"忹";s:3:"忹";s:4:"悁";s:3:"æ‚";s:4:"㤺";s:3:"㤺";s:4:"㤜";s:3:"㤜";s:4:"悔";s:3:"æ‚”";s:4:"𢛔";s:4:"𢛔";s:4:"惇";s:3:"惇";s:4:"慈";s:3:"æ…ˆ";s:4:"慌";s:3:"æ…Œ";s:4:"慎";s:3:"æ…Ž";s:4:"慌";s:3:"æ…Œ";s:4:"慺";s:3:"æ…º";s:4:"憎";s:3:"憎";s:4:"憲";s:3:"憲";s:4:"憤";s:3:"憤";s:4:"憯";s:3:"憯";s:4:"懞";s:3:"懞";s:4:"懲";s:3:"懲";s:4:"懶";s:3:"懶";s:4:"成";s:3:"æˆ";s:4:"戛";s:3:"戛";s:4:"扝";s:3:"æ‰";s:4:"抱";s:3:"抱";s:4:"拔";s:3:"æ‹”";s:4:"捐";s:3:"æ";s:4:"𢬌";s:4:"𢬌";s:4:"挽";s:3:"挽";s:4:"拼";s:3:"拼";s:4:"捨";s:3:"æ¨";s:4:"掃";s:3:"掃";s:4:"揤";s:3:"æ¤";s:4:"𢯱";s:4:"𢯱";s:4:"搢";s:3:"æ¢";s:4:"揅";s:3:"æ…";s:4:"ð¯£";s:3:"掩";s:4:"㨮";s:3:"㨮";s:4:"摩";s:3:"æ‘©";s:4:"摾";s:3:"摾";s:4:"撝";s:3:"æ’";s:4:"摷";s:3:"æ‘·";s:4:"㩬";s:3:"㩬";s:4:"敏";s:3:"æ•";s:4:"敬";s:3:"敬";s:4:"𣀊";s:4:"𣀊";s:4:"旣";s:3:"æ—£";s:4:"書";s:3:"書";s:4:"ð¯£";s:3:"晉";s:4:"㬙";s:3:"㬙";s:4:"ð¯£";s:3:"æš‘";s:4:"ð¯£";s:3:"㬈";s:4:"㫤";s:3:"㫤";s:4:"冒";s:3:"冒";s:4:"冕";s:3:"冕";s:4:"最";s:3:"最";s:4:"暜";s:3:"æšœ";s:4:"肭";s:3:"è‚­";s:4:"䏙";s:3:"ä™";s:4:"朗";s:3:"朗";s:4:"望";s:3:"望";s:4:"朡";s:3:"朡";s:4:"杞";s:3:"æž";s:4:"杓";s:3:"æ“";s:4:"ð¯£";s:4:"ð£ƒ";s:4:"㭉";s:3:"ã­‰";s:4:"柺";s:3:"柺";s:4:"枅";s:3:"æž…";s:4:"桒";s:3:"æ¡’";s:4:"梅";s:3:"梅";s:4:"𣑭";s:4:"𣑭";s:4:"梎";s:3:"梎";s:4:"栟";s:3:"æ Ÿ";s:4:"椔";s:3:"椔";s:4:"㮝";s:3:"ã®";s:4:"楂";s:3:"楂";s:4:"榣";s:3:"榣";s:4:"槪";s:3:"槪";s:4:"檨";s:3:"檨";s:4:"𣚣";s:4:"𣚣";s:4:"櫛";s:3:"æ«›";s:4:"㰘";s:3:"ã°˜";s:4:"次";s:3:"次";s:4:"𣢧";s:4:"𣢧";s:4:"歔";s:3:"æ­”";s:4:"㱎";s:3:"㱎";s:4:"歲";s:3:"æ­²";s:4:"殟";s:3:"殟";s:4:"殺";s:3:"殺";s:4:"殻";s:3:"æ®»";s:4:"𣪍";s:4:"ð£ª";s:4:"𡴋";s:4:"ð¡´‹";s:4:"𣫺";s:4:"𣫺";s:4:"汎";s:3:"汎";s:4:"𣲼";s:4:"𣲼";s:4:"沿";s:3:"沿";s:4:"泍";s:3:"æ³";s:4:"汧";s:3:"汧";s:4:"洖";s:3:"æ´–";s:4:"派";s:3:"æ´¾";s:4:"ð¯¤";s:3:"æµ·";s:4:"流";s:3:"æµ";s:4:"浩";s:3:"浩";s:4:"浸";s:3:"浸";s:4:"涅";s:3:"涅";s:4:"𣴞";s:4:"𣴞";s:4:"洴";s:3:"æ´´";s:4:"港";s:3:"港";s:4:"湮";s:3:"æ¹®";s:4:"㴳";s:3:"ã´³";s:4:"滋";s:3:"滋";s:4:"滇";s:3:"滇";s:4:"ð¯¤";s:4:"𣻑";s:4:"淹";s:3:"æ·¹";s:4:"ð¯¤";s:3:"æ½®";s:4:"ð¯¤";s:4:"𣽞";s:4:"𣾎";s:4:"𣾎";s:4:"濆";s:3:"濆";s:4:"瀹";s:3:"瀹";s:4:"瀞";s:3:"瀞";s:4:"瀛";s:3:"瀛";s:4:"㶖";s:3:"㶖";s:4:"灊";s:3:"çŠ";s:4:"災";s:3:"ç½";s:4:"灷";s:3:"ç·";s:4:"炭";s:3:"ç‚­";s:4:"𠔥";s:4:"𠔥";s:4:"煅";s:3:"ç……";s:4:"ð¯¤";s:4:"𤉣";s:4:"熜";s:3:"熜";s:4:"𤎫";s:4:"𤎫";s:4:"爨";s:3:"爨";s:4:"爵";s:3:"爵";s:4:"牐";s:3:"ç‰";s:4:"𤘈";s:4:"𤘈";s:4:"犀";s:3:"犀";s:4:"犕";s:3:"犕";s:4:"𤜵";s:4:"𤜵";s:4:"𤠔";s:4:"𤠔";s:4:"獺";s:3:"çº";s:4:"王";s:3:"王";s:4:"㺬";s:3:"㺬";s:4:"玥";s:3:"玥";s:4:"㺸";s:3:"㺸";s:4:"㺸";s:3:"㺸";s:4:"瑇";s:3:"瑇";s:4:"瑜";s:3:"ç‘œ";s:4:"瑱";s:3:"瑱";s:4:"璅";s:3:"ç’…";s:4:"瓊";s:3:"ç“Š";s:4:"㼛";s:3:"ã¼›";s:4:"甤";s:3:"甤";s:4:"𤰶";s:4:"𤰶";s:4:"甾";s:3:"甾";s:4:"𤲒";s:4:"𤲒";s:4:"異";s:3:"ç•°";s:4:"𢆟";s:4:"𢆟";s:4:"瘐";s:3:"ç˜";s:4:"𤾡";s:4:"𤾡";s:4:"𤾸";s:4:"𤾸";s:4:"𥁄";s:4:"ð¥„";s:4:"㿼";s:3:"㿼";s:4:"䀈";s:3:"䀈";s:4:"直";s:3:"ç›´";s:4:"ð¯¥";s:4:"𥃳";s:4:"𥃲";s:4:"𥃲";s:4:"𥄙";s:4:"𥄙";s:4:"𥄳";s:4:"𥄳";s:4:"眞";s:3:"眞";s:4:"真";s:3:"真";s:4:"真";s:3:"真";s:4:"睊";s:3:"çŠ";s:4:"䀹";s:3:"䀹";s:4:"瞋";s:3:"çž‹";s:4:"䁆";s:3:"ä†";s:4:"䂖";s:3:"ä‚–";s:4:"ð¯¥";s:4:"ð¥";s:4:"硎";s:3:"ç¡Ž";s:4:"ð¯¥";s:3:"碌";s:4:"ð¯¥";s:3:"磌";s:4:"䃣";s:3:"䃣";s:4:"𥘦";s:4:"𥘦";s:4:"祖";s:3:"祖";s:4:"𥚚";s:4:"𥚚";s:4:"𥛅";s:4:"𥛅";s:4:"福";s:3:"ç¦";s:4:"秫";s:3:"秫";s:4:"䄯";s:3:"䄯";s:4:"穀";s:3:"ç©€";s:4:"穊";s:3:"ç©Š";s:4:"穏";s:3:"ç©";s:4:"𥥼";s:4:"𥥼";s:4:"ð¯¥";s:4:"𥪧";s:4:"𥪧";s:4:"𥪧";s:4:"竮";s:3:"ç«®";s:4:"䈂";s:3:"䈂";s:4:"𥮫";s:4:"𥮫";s:4:"篆";s:3:"篆";s:4:"築";s:3:"築";s:4:"䈧";s:3:"䈧";s:4:"𥲀";s:4:"𥲀";s:4:"糒";s:3:"ç³’";s:4:"䊠";s:3:"䊠";s:4:"糨";s:3:"糨";s:4:"糣";s:3:"ç³£";s:4:"紀";s:3:"ç´€";s:4:"𥾆";s:4:"𥾆";s:4:"絣";s:3:"çµ£";s:4:"䌁";s:3:"äŒ";s:4:"緇";s:3:"ç·‡";s:4:"縂";s:3:"縂";s:4:"繅";s:3:"ç¹…";s:4:"䌴";s:3:"䌴";s:4:"𦈨";s:4:"𦈨";s:4:"𦉇";s:4:"𦉇";s:4:"䍙";s:3:"ä™";s:4:"𦋙";s:4:"𦋙";s:4:"罺";s:3:"罺";s:4:"𦌾";s:4:"𦌾";s:4:"羕";s:3:"羕";s:4:"翺";s:3:"翺";s:4:"者";s:3:"者";s:4:"𦓚";s:4:"𦓚";s:4:"𦔣";s:4:"𦔣";s:4:"聠";s:3:"è ";s:4:"𦖨";s:4:"𦖨";s:4:"聰";s:3:"è°";s:4:"𣍟";s:4:"ð£Ÿ";s:4:"ð¯¦";s:3:"ä•";s:4:"育";s:3:"育";s:4:"脃";s:3:"脃";s:4:"䐋";s:3:"ä‹";s:4:"脾";s:3:"脾";s:4:"媵";s:3:"媵";s:4:"𦞧";s:4:"𦞧";s:4:"𦞵";s:4:"𦞵";s:4:"𣎓";s:4:"𣎓";s:4:"𣎜";s:4:"𣎜";s:4:"舁";s:3:"èˆ";s:4:"舄";s:3:"舄";s:4:"ð¯¦";s:3:"辞";s:4:"䑫";s:3:"ä‘«";s:4:"ð¯¦";s:3:"芑";s:4:"ð¯¦";s:3:"芋";s:4:"芝";s:3:"èŠ";s:4:"劳";s:3:"劳";s:4:"花";s:3:"花";s:4:"芳";s:3:"芳";s:4:"芽";s:3:"芽";s:4:"苦";s:3:"苦";s:4:"𦬼";s:4:"𦬼";s:4:"若";s:3:"è‹¥";s:4:"茝";s:3:"èŒ";s:4:"荣";s:3:"è£";s:4:"莭";s:3:"莭";s:4:"茣";s:3:"茣";s:4:"ð¯¦";s:3:"莽";s:4:"菧";s:3:"è§";s:4:"著";s:3:"è‘—";s:4:"荓";s:3:"è“";s:4:"菊";s:3:"èŠ";s:4:"菌";s:3:"èŒ";s:4:"菜";s:3:"èœ";s:4:"𦰶";s:4:"𦰶";s:4:"𦵫";s:4:"𦵫";s:4:"𦳕";s:4:"𦳕";s:4:"䔫";s:3:"䔫";s:4:"蓱";s:3:"蓱";s:4:"蓳";s:3:"蓳";s:4:"蔖";s:3:"è”–";s:4:"𧏊";s:4:"ð§Š";s:4:"蕤";s:3:"蕤";s:4:"𦼬";s:4:"𦼬";s:4:"䕝";s:3:"ä•";s:4:"䕡";s:3:"ä•¡";s:4:"𦾱";s:4:"𦾱";s:4:"𧃒";s:4:"𧃒";s:4:"䕫";s:3:"ä•«";s:4:"虐";s:3:"è™";s:4:"虜";s:3:"虜";s:4:"虧";s:3:"虧";s:4:"虩";s:3:"虩";s:4:"蚩";s:3:"èš©";s:4:"蚈";s:3:"蚈";s:4:"蜎";s:3:"蜎";s:4:"蛢";s:3:"蛢";s:4:"蝹";s:3:"è¹";s:4:"蜨";s:3:"蜨";s:4:"蝫";s:3:"è«";s:4:"螆";s:3:"螆";s:4:"䗗";s:3:"ä——";s:4:"蟡";s:3:"蟡";s:4:"ð¯§";s:3:"è ";s:4:"䗹";s:3:"ä—¹";s:4:"衠";s:3:"è¡ ";s:4:"衣";s:3:"è¡£";s:4:"𧙧";s:4:"𧙧";s:4:"裗";s:3:"裗";s:4:"裞";s:3:"裞";s:4:"䘵";s:3:"䘵";s:4:"裺";s:3:"裺";s:4:"㒻";s:3:"ã’»";s:4:"𧢮";s:4:"𧢮";s:4:"𧥦";s:4:"𧥦";s:4:"ð¯§";s:3:"äš¾";s:4:"䛇";s:3:"䛇";s:4:"ð¯§";s:3:"誠";s:4:"ð¯§";s:3:"è«­";s:4:"變";s:3:"變";s:4:"豕";s:3:"豕";s:4:"𧲨";s:4:"𧲨";s:4:"貫";s:3:"貫";s:4:"賁";s:3:"è³";s:4:"贛";s:3:"è´›";s:4:"起";s:3:"èµ·";s:4:"𧼯";s:4:"𧼯";s:4:"𠠄";s:4:"ð  „";s:4:"跋";s:3:"è·‹";s:4:"趼";s:3:"趼";s:4:"跰";s:3:"è·°";s:4:"ð¯§";s:4:"𠣞";s:4:"軔";s:3:"è»”";s:4:"輸";s:3:"輸";s:4:"𨗒";s:4:"𨗒";s:4:"𨗭";s:4:"𨗭";s:4:"邔";s:3:"é‚”";s:4:"郱";s:3:"郱";s:4:"鄑";s:3:"é„‘";s:4:"𨜮";s:4:"𨜮";s:4:"鄛";s:3:"é„›";s:4:"鈸";s:3:"鈸";s:4:"鋗";s:3:"é‹—";s:4:"鋘";s:3:"鋘";s:4:"鉼";s:3:"鉼";s:4:"鏹";s:3:"é¹";s:4:"鐕";s:3:"é•";s:4:"𨯺";s:4:"𨯺";s:4:"開";s:3:"é–‹";s:4:"䦕";s:3:"䦕";s:4:"閷";s:3:"é–·";s:4:"𨵷";s:4:"𨵷";s:4:"䧦";s:3:"䧦";s:4:"雃";s:3:"雃";s:4:"嶲";s:3:"嶲";s:4:"霣";s:3:"霣";s:4:"𩅅";s:4:"ð©……";s:4:"𩈚";s:4:"𩈚";s:4:"䩮";s:3:"ä©®";s:4:"䩶";s:3:"䩶";s:4:"韠";s:3:"韠";s:4:"𩐊";s:4:"ð©Š";s:4:"䪲";s:3:"䪲";s:4:"𩒖";s:4:"ð©’–";s:4:"頋";s:3:"é ‹";s:4:"頋";s:3:"é ‹";s:4:"頩";s:3:"é ©";s:4:"ð¯¨";s:4:"ð©–¶";s:4:"飢";s:3:"飢";s:4:"䬳";s:3:"䬳";s:4:"餩";s:3:"餩";s:4:"馧";s:3:"馧";s:4:"駂";s:3:"駂";s:4:"駾";s:3:"駾";s:4:"䯎";s:3:"䯎";s:4:"𩬰";s:4:"𩬰";s:4:"鬒";s:3:"鬒";s:4:"鱀";s:3:"é±€";s:4:"鳽";s:3:"é³½";s:4:"ð¯¨";s:3:"䳎";s:4:"䳭";s:3:"ä³­";s:4:"ð¯¨";s:3:"鵧";s:4:"ð¯¨";s:4:"𪃎";s:4:"䳸";s:3:"䳸";s:4:"𪄅";s:4:"𪄅";s:4:"𪈎";s:4:"𪈎";s:4:"𪊑";s:4:"𪊑";s:4:"麻";s:3:"麻";s:4:"䵖";s:3:"äµ–";s:4:"黹";s:3:"黹";s:4:"黾";s:3:"黾";s:4:"鼅";s:3:"é¼…";s:4:"鼏";s:3:"é¼";s:4:"鼖";s:3:"é¼–";s:4:"鼻";s:3:"é¼»";s:4:"ð¯¨";s:4:"𪘀";}
    \ No newline at end of file
    diff --git a/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/unidata/combiningClass.ser b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/unidata/combiningClass.ser
    new file mode 100755
    index 0000000..6812d01
    --- /dev/null
    +++ b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/unidata/combiningClass.ser
    @@ -0,0 +1 @@
    +a:653:{s:2:"Ì€";i:230;s:2:"Ì";i:230;s:2:"Ì‚";i:230;s:2:"̃";i:230;s:2:"Ì„";i:230;s:2:"Ì…";i:230;s:2:"̆";i:230;s:2:"̇";i:230;s:2:"̈";i:230;s:2:"̉";i:230;s:2:"ÌŠ";i:230;s:2:"Ì‹";i:230;s:2:"ÌŒ";i:230;s:2:"Ì";i:230;s:2:"ÌŽ";i:230;s:2:"Ì";i:230;s:2:"Ì";i:230;s:2:"Ì‘";i:230;s:2:"Ì’";i:230;s:2:"Ì“";i:230;s:2:"Ì”";i:230;s:2:"Ì•";i:232;s:2:"Ì–";i:220;s:2:"Ì—";i:220;s:2:"̘";i:220;s:2:"Ì™";i:220;s:2:"Ìš";i:232;s:2:"Ì›";i:216;s:2:"Ìœ";i:220;s:2:"Ì";i:220;s:2:"Ìž";i:220;s:2:"ÌŸ";i:220;s:2:"Ì ";i:220;s:2:"Ì¡";i:202;s:2:"Ì¢";i:202;s:2:"Ì£";i:220;s:2:"̤";i:220;s:2:"Ì¥";i:220;s:2:"̦";i:220;s:2:"̧";i:202;s:2:"̨";i:202;s:2:"Ì©";i:220;s:2:"̪";i:220;s:2:"Ì«";i:220;s:2:"̬";i:220;s:2:"Ì­";i:220;s:2:"Ì®";i:220;s:2:"̯";i:220;s:2:"Ì°";i:220;s:2:"̱";i:220;s:2:"̲";i:220;s:2:"̳";i:220;s:2:"Ì´";i:1;s:2:"̵";i:1;s:2:"̶";i:1;s:2:"Ì·";i:1;s:2:"̸";i:1;s:2:"̹";i:220;s:2:"̺";i:220;s:2:"Ì»";i:220;s:2:"̼";i:220;s:2:"̽";i:230;s:2:"̾";i:230;s:2:"Ì¿";i:230;s:2:"Í€";i:230;s:2:"Í";i:230;s:2:"Í‚";i:230;s:2:"̓";i:230;s:2:"Í„";i:230;s:2:"Í…";i:240;s:2:"͆";i:230;s:2:"͇";i:220;s:2:"͈";i:220;s:2:"͉";i:220;s:2:"ÍŠ";i:230;s:2:"Í‹";i:230;s:2:"ÍŒ";i:230;s:2:"Í";i:220;s:2:"ÍŽ";i:220;s:2:"Í";i:230;s:2:"Í‘";i:230;s:2:"Í’";i:230;s:2:"Í“";i:220;s:2:"Í”";i:220;s:2:"Í•";i:220;s:2:"Í–";i:220;s:2:"Í—";i:230;s:2:"͘";i:232;s:2:"Í™";i:220;s:2:"Íš";i:220;s:2:"Í›";i:230;s:2:"Íœ";i:233;s:2:"Í";i:234;s:2:"Íž";i:234;s:2:"ÍŸ";i:233;s:2:"Í ";i:234;s:2:"Í¡";i:234;s:2:"Í¢";i:233;s:2:"Í£";i:230;s:2:"ͤ";i:230;s:2:"Í¥";i:230;s:2:"ͦ";i:230;s:2:"ͧ";i:230;s:2:"ͨ";i:230;s:2:"Í©";i:230;s:2:"ͪ";i:230;s:2:"Í«";i:230;s:2:"ͬ";i:230;s:2:"Í­";i:230;s:2:"Í®";i:230;s:2:"ͯ";i:230;s:2:"Òƒ";i:230;s:2:"Ò„";i:230;s:2:"Ò…";i:230;s:2:"Ò†";i:230;s:2:"Ò‡";i:230;s:2:"Ö‘";i:220;s:2:"Ö’";i:230;s:2:"Ö“";i:230;s:2:"Ö”";i:230;s:2:"Ö•";i:230;s:2:"Ö–";i:220;s:2:"Ö—";i:230;s:2:"Ö˜";i:230;s:2:"Ö™";i:230;s:2:"Öš";i:222;s:2:"Ö›";i:220;s:2:"Öœ";i:230;s:2:"Ö";i:230;s:2:"Öž";i:230;s:2:"ÖŸ";i:230;s:2:"Ö ";i:230;s:2:"Ö¡";i:230;s:2:"Ö¢";i:220;s:2:"Ö£";i:220;s:2:"Ö¤";i:220;s:2:"Ö¥";i:220;s:2:"Ö¦";i:220;s:2:"Ö§";i:220;s:2:"Ö¨";i:230;s:2:"Ö©";i:230;s:2:"Öª";i:220;s:2:"Ö«";i:230;s:2:"Ö¬";i:230;s:2:"Ö­";i:222;s:2:"Ö®";i:228;s:2:"Ö¯";i:230;s:2:"Ö°";i:10;s:2:"Ö±";i:11;s:2:"Ö²";i:12;s:2:"Ö³";i:13;s:2:"Ö´";i:14;s:2:"Öµ";i:15;s:2:"Ö¶";i:16;s:2:"Ö·";i:17;s:2:"Ö¸";i:18;s:2:"Ö¹";i:19;s:2:"Öº";i:19;s:2:"Ö»";i:20;s:2:"Ö¼";i:21;s:2:"Ö½";i:22;s:2:"Ö¿";i:23;s:2:"×";i:24;s:2:"ׂ";i:25;s:2:"ׄ";i:230;s:2:"×…";i:220;s:2:"ׇ";i:18;s:2:"Ø";i:230;s:2:"Ø‘";i:230;s:2:"Ø’";i:230;s:2:"Ø“";i:230;s:2:"Ø”";i:230;s:2:"Ø•";i:230;s:2:"Ø–";i:230;s:2:"Ø—";i:230;s:2:"ؘ";i:30;s:2:"Ø™";i:31;s:2:"Øš";i:32;s:2:"Ù‹";i:27;s:2:"ÙŒ";i:28;s:2:"Ù";i:29;s:2:"ÙŽ";i:30;s:2:"Ù";i:31;s:2:"Ù";i:32;s:2:"Ù‘";i:33;s:2:"Ù’";i:34;s:2:"Ù“";i:230;s:2:"Ù”";i:230;s:2:"Ù•";i:220;s:2:"Ù–";i:220;s:2:"Ù—";i:230;s:2:"Ù˜";i:230;s:2:"Ù™";i:230;s:2:"Ùš";i:230;s:2:"Ù›";i:230;s:2:"Ùœ";i:220;s:2:"Ù";i:230;s:2:"Ùž";i:230;s:2:"ÙŸ";i:220;s:2:"Ù°";i:35;s:2:"Û–";i:230;s:2:"Û—";i:230;s:2:"Û˜";i:230;s:2:"Û™";i:230;s:2:"Ûš";i:230;s:2:"Û›";i:230;s:2:"Ûœ";i:230;s:2:"ÛŸ";i:230;s:2:"Û ";i:230;s:2:"Û¡";i:230;s:2:"Û¢";i:230;s:2:"Û£";i:220;s:2:"Û¤";i:230;s:2:"Û§";i:230;s:2:"Û¨";i:230;s:2:"Ûª";i:220;s:2:"Û«";i:230;s:2:"Û¬";i:230;s:2:"Û­";i:220;s:2:"Ü‘";i:36;s:2:"Ü°";i:230;s:2:"ܱ";i:220;s:2:"ܲ";i:230;s:2:"ܳ";i:230;s:2:"Ü´";i:220;s:2:"ܵ";i:230;s:2:"ܶ";i:230;s:2:"Ü·";i:220;s:2:"ܸ";i:220;s:2:"ܹ";i:220;s:2:"ܺ";i:230;s:2:"Ü»";i:220;s:2:"ܼ";i:220;s:2:"ܽ";i:230;s:2:"ܾ";i:220;s:2:"Ü¿";i:230;s:2:"Ý€";i:230;s:2:"Ý";i:230;s:2:"Ý‚";i:220;s:2:"݃";i:230;s:2:"Ý„";i:220;s:2:"Ý…";i:230;s:2:"݆";i:220;s:2:"݇";i:230;s:2:"݈";i:220;s:2:"݉";i:230;s:2:"ÝŠ";i:230;s:2:"ß«";i:230;s:2:"߬";i:230;s:2:"ß­";i:230;s:2:"ß®";i:230;s:2:"߯";i:230;s:2:"ß°";i:230;s:2:"ß±";i:230;s:2:"ß²";i:220;s:2:"ß³";i:230;s:3:"à –";i:230;s:3:"à —";i:230;s:3:"à ˜";i:230;s:3:"à ™";i:230;s:3:"à ›";i:230;s:3:"à œ";i:230;s:3:"à ";i:230;s:3:"à ž";i:230;s:3:"à Ÿ";i:230;s:3:"à  ";i:230;s:3:"à ¡";i:230;s:3:"à ¢";i:230;s:3:"à £";i:230;s:3:"à ¥";i:230;s:3:"à ¦";i:230;s:3:"à §";i:230;s:3:"à ©";i:230;s:3:"à ª";i:230;s:3:"à «";i:230;s:3:"à ¬";i:230;s:3:"à ­";i:230;s:3:"à¡™";i:220;s:3:"à¡š";i:220;s:3:"à¡›";i:220;s:3:"ࣤ";i:230;s:3:"ࣥ";i:230;s:3:"ࣦ";i:220;s:3:"ࣧ";i:230;s:3:"ࣨ";i:230;s:3:"ࣩ";i:220;s:3:"࣪";i:230;s:3:"࣫";i:230;s:3:"࣬";i:230;s:3:"࣭";i:220;s:3:"࣮";i:220;s:3:"࣯";i:220;s:3:"ࣰ";i:27;s:3:"ࣱ";i:28;s:3:"ࣲ";i:29;s:3:"ࣳ";i:230;s:3:"ࣴ";i:230;s:3:"ࣵ";i:230;s:3:"ࣶ";i:220;s:3:"ࣷ";i:230;s:3:"ࣸ";i:230;s:3:"ࣹ";i:220;s:3:"ࣺ";i:220;s:3:"ࣻ";i:230;s:3:"ࣼ";i:230;s:3:"ࣽ";i:230;s:3:"ࣾ";i:230;s:3:"़";i:7;s:3:"à¥";i:9;s:3:"॑";i:230;s:3:"॒";i:220;s:3:"॓";i:230;s:3:"॔";i:230;s:3:"়";i:7;s:3:"à§";i:9;s:3:"਼";i:7;s:3:"à©";i:9;s:3:"઼";i:7;s:3:"à«";i:9;s:3:"଼";i:7;s:3:"à­";i:9;s:3:"à¯";i:9;s:3:"à±";i:9;s:3:"ౕ";i:84;s:3:"à±–";i:91;s:3:"಼";i:7;s:3:"à³";i:9;s:3:"àµ";i:9;s:3:"à·Š";i:9;s:3:"ุ";i:103;s:3:"ู";i:103;s:3:"ฺ";i:9;s:3:"่";i:107;s:3:"้";i:107;s:3:"๊";i:107;s:3:"๋";i:107;s:3:"ຸ";i:118;s:3:"ູ";i:118;s:3:"່";i:122;s:3:"້";i:122;s:3:"໊";i:122;s:3:"໋";i:122;s:3:"༘";i:220;s:3:"༙";i:220;s:3:"༵";i:220;s:3:"༷";i:220;s:3:"༹";i:216;s:3:"ཱ";i:129;s:3:"ི";i:130;s:3:"ུ";i:132;s:3:"ེ";i:130;s:3:"ཻ";i:130;s:3:"ོ";i:130;s:3:"ཽ";i:130;s:3:"ྀ";i:130;s:3:"ྂ";i:230;s:3:"ྃ";i:230;s:3:"྄";i:9;s:3:"྆";i:230;s:3:"྇";i:230;s:3:"࿆";i:220;s:3:"့";i:7;s:3:"္";i:9;s:3:"်";i:9;s:3:"á‚";i:220;s:3:"á";i:230;s:3:"áž";i:230;s:3:"áŸ";i:230;s:3:"᜔";i:9;s:3:"᜴";i:9;s:3:"្";i:9;s:3:"áŸ";i:230;s:3:"ᢩ";i:228;s:3:"᤹";i:222;s:3:"᤺";i:230;s:3:"᤻";i:220;s:3:"ᨗ";i:230;s:3:"ᨘ";i:220;s:3:"á© ";i:9;s:3:"᩵";i:230;s:3:"᩶";i:230;s:3:"á©·";i:230;s:3:"᩸";i:230;s:3:"᩹";i:230;s:3:"᩺";i:230;s:3:"á©»";i:230;s:3:"᩼";i:230;s:3:"á©¿";i:220;s:3:"᬴";i:7;s:3:"á­„";i:9;s:3:"á­«";i:230;s:3:"á­¬";i:220;s:3:"á­­";i:230;s:3:"á­®";i:230;s:3:"á­¯";i:230;s:3:"á­°";i:230;s:3:"á­±";i:230;s:3:"á­²";i:230;s:3:"á­³";i:230;s:3:"᮪";i:9;s:3:"᮫";i:9;s:3:"᯦";i:7;s:3:"᯲";i:9;s:3:"᯳";i:9;s:3:"á°·";i:7;s:3:"á³";i:230;s:3:"᳑";i:230;s:3:"á³’";i:230;s:3:"á³”";i:1;s:3:"᳕";i:220;s:3:"á³–";i:220;s:3:"á³—";i:220;s:3:"᳘";i:220;s:3:"á³™";i:220;s:3:"᳚";i:230;s:3:"á³›";i:230;s:3:"᳜";i:220;s:3:"á³";i:220;s:3:"᳞";i:220;s:3:"᳟";i:220;s:3:"á³ ";i:230;s:3:"á³¢";i:1;s:3:"á³£";i:1;s:3:"᳤";i:1;s:3:"á³¥";i:1;s:3:"᳦";i:1;s:3:"᳧";i:1;s:3:"᳨";i:1;s:3:"á³­";i:220;s:3:"á³´";i:230;s:3:"á·€";i:230;s:3:"á·";i:230;s:3:"á·‚";i:220;s:3:"á·ƒ";i:230;s:3:"á·„";i:230;s:3:"á·…";i:230;s:3:"á·†";i:230;s:3:"á·‡";i:230;s:3:"á·ˆ";i:230;s:3:"á·‰";i:230;s:3:"á·Š";i:220;s:3:"á·‹";i:230;s:3:"á·Œ";i:230;s:3:"á·";i:234;s:3:"á·Ž";i:214;s:3:"á·";i:220;s:3:"á·";i:202;s:3:"á·‘";i:230;s:3:"á·’";i:230;s:3:"á·“";i:230;s:3:"á·”";i:230;s:3:"á·•";i:230;s:3:"á·–";i:230;s:3:"á·—";i:230;s:3:"á·˜";i:230;s:3:"á·™";i:230;s:3:"á·š";i:230;s:3:"á·›";i:230;s:3:"á·œ";i:230;s:3:"á·";i:230;s:3:"á·ž";i:230;s:3:"á·Ÿ";i:230;s:3:"á· ";i:230;s:3:"á·¡";i:230;s:3:"á·¢";i:230;s:3:"á·£";i:230;s:3:"á·¤";i:230;s:3:"á·¥";i:230;s:3:"á·¦";i:230;s:3:"á·¼";i:233;s:3:"á·½";i:220;s:3:"á·¾";i:230;s:3:"á·¿";i:220;s:3:"âƒ";i:230;s:3:"⃑";i:230;s:3:"⃒";i:1;s:3:"⃓";i:1;s:3:"⃔";i:230;s:3:"⃕";i:230;s:3:"⃖";i:230;s:3:"⃗";i:230;s:3:"⃘";i:1;s:3:"⃙";i:1;s:3:"⃚";i:1;s:3:"⃛";i:230;s:3:"⃜";i:230;s:3:"⃡";i:230;s:3:"⃥";i:1;s:3:"⃦";i:1;s:3:"⃧";i:230;s:3:"⃨";i:220;s:3:"⃩";i:230;s:3:"⃪";i:1;s:3:"⃫";i:1;s:3:"⃬";i:220;s:3:"⃭";i:220;s:3:"⃮";i:220;s:3:"⃯";i:220;s:3:"⃰";i:230;s:3:"⳯";i:230;s:3:"â³°";i:230;s:3:"â³±";i:230;s:3:"⵿";i:9;s:3:"â· ";i:230;s:3:"â·¡";i:230;s:3:"â·¢";i:230;s:3:"â·£";i:230;s:3:"â·¤";i:230;s:3:"â·¥";i:230;s:3:"â·¦";i:230;s:3:"â·§";i:230;s:3:"â·¨";i:230;s:3:"â·©";i:230;s:3:"â·ª";i:230;s:3:"â·«";i:230;s:3:"â·¬";i:230;s:3:"â·­";i:230;s:3:"â·®";i:230;s:3:"â·¯";i:230;s:3:"â·°";i:230;s:3:"â·±";i:230;s:3:"â·²";i:230;s:3:"â·³";i:230;s:3:"â·´";i:230;s:3:"â·µ";i:230;s:3:"â·¶";i:230;s:3:"â··";i:230;s:3:"â·¸";i:230;s:3:"â·¹";i:230;s:3:"â·º";i:230;s:3:"â·»";i:230;s:3:"â·¼";i:230;s:3:"â·½";i:230;s:3:"â·¾";i:230;s:3:"â·¿";i:230;s:3:"〪";i:218;s:3:"〫";i:228;s:3:"〬";i:232;s:3:"〭";i:222;s:3:"〮";i:224;s:3:"〯";i:224;s:3:"ã‚™";i:8;s:3:"ã‚š";i:8;s:3:"꙯";i:230;s:3:"ê™´";i:230;s:3:"ꙵ";i:230;s:3:"ꙶ";i:230;s:3:"ê™·";i:230;s:3:"ꙸ";i:230;s:3:"ꙹ";i:230;s:3:"ꙺ";i:230;s:3:"ê™»";i:230;s:3:"꙼";i:230;s:3:"꙽";i:230;s:3:"ꚟ";i:230;s:3:"ê›°";i:230;s:3:"ê›±";i:230;s:3:"ê †";i:9;s:3:"꣄";i:9;s:3:"꣠";i:230;s:3:"꣡";i:230;s:3:"꣢";i:230;s:3:"꣣";i:230;s:3:"꣤";i:230;s:3:"꣥";i:230;s:3:"꣦";i:230;s:3:"꣧";i:230;s:3:"꣨";i:230;s:3:"꣩";i:230;s:3:"꣪";i:230;s:3:"꣫";i:230;s:3:"꣬";i:230;s:3:"꣭";i:230;s:3:"꣮";i:230;s:3:"꣯";i:230;s:3:"꣰";i:230;s:3:"꣱";i:230;s:3:"꤫";i:220;s:3:"꤬";i:220;s:3:"꤭";i:220;s:3:"꥓";i:9;s:3:"꦳";i:7;s:3:"꧀";i:9;s:3:"ꪰ";i:230;s:3:"ꪲ";i:230;s:3:"ꪳ";i:230;s:3:"ꪴ";i:220;s:3:"ꪷ";i:230;s:3:"ꪸ";i:230;s:3:"ꪾ";i:230;s:3:"꪿";i:230;s:3:"ê«";i:230;s:3:"꫶";i:9;s:3:"꯭";i:9;s:3:"ﬞ";i:26;s:3:"︠";i:230;s:3:"︡";i:230;s:3:"︢";i:230;s:3:"︣";i:230;s:3:"︤";i:230;s:3:"︥";i:230;s:3:"︦";i:230;s:4:"ð‡½";i:220;s:4:"ð¨";i:220;s:4:"ð¨";i:230;s:4:"ð¨¸";i:230;s:4:"ð¨¹";i:1;s:4:"ð¨º";i:220;s:4:"ð¨¿";i:9;s:4:"ð‘†";i:9;s:4:"ð‘‚¹";i:9;s:4:"𑂺";i:7;s:4:"ð‘„€";i:230;s:4:"ð‘„";i:230;s:4:"ð‘„‚";i:230;s:4:"ð‘„³";i:9;s:4:"ð‘„´";i:9;s:4:"𑇀";i:9;s:4:"𑚶";i:9;s:4:"ð‘š·";i:7;s:4:"ð…¥";i:216;s:4:"ð…¦";i:216;s:4:"ð…§";i:1;s:4:"ð…¨";i:1;s:4:"ð…©";i:1;s:4:"ð…­";i:226;s:4:"ð…®";i:216;s:4:"ð…¯";i:216;s:4:"ð…°";i:216;s:4:"ð…±";i:216;s:4:"ð…²";i:216;s:4:"ð…»";i:220;s:4:"ð…¼";i:220;s:4:"ð…½";i:220;s:4:"ð…¾";i:220;s:4:"ð…¿";i:220;s:4:"ð†€";i:220;s:4:"ð†";i:220;s:4:"ð†‚";i:220;s:4:"ð†…";i:230;s:4:"ð††";i:230;s:4:"ð†‡";i:230;s:4:"ð†ˆ";i:230;s:4:"ð†‰";i:230;s:4:"ð†Š";i:220;s:4:"ð†‹";i:220;s:4:"ð†ª";i:230;s:4:"ð†«";i:230;s:4:"ð†¬";i:230;s:4:"ð†­";i:230;s:4:"ð‰‚";i:230;s:4:"ð‰ƒ";i:230;s:4:"ð‰„";i:230;}
    \ No newline at end of file
    diff --git a/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/unidata/compatibilityDecomposition.ser b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/unidata/compatibilityDecomposition.ser
    new file mode 100755
    index 0000000..24482dd
    --- /dev/null
    +++ b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/unidata/compatibilityDecomposition.ser
    @@ -0,0 +1 @@
    +a:3671:{s:2:" ";s:1:" ";s:2:"¨";s:3:" ̈";s:2:"ª";s:1:"a";s:2:"¯";s:3:" Ì„";s:2:"²";s:1:"2";s:2:"³";s:1:"3";s:2:"´";s:3:" Ì";s:2:"µ";s:2:"μ";s:2:"¸";s:3:" ̧";s:2:"¹";s:1:"1";s:2:"º";s:1:"o";s:2:"¼";s:5:"1â„4";s:2:"½";s:5:"1â„2";s:2:"¾";s:5:"3â„4";s:2:"IJ";s:2:"IJ";s:2:"ij";s:2:"ij";s:2:"Ä¿";s:3:"L·";s:2:"Å€";s:3:"l·";s:2:"ʼn";s:3:"ʼn";s:2:"Å¿";s:1:"s";s:2:"Ç„";s:4:"DZÌŒ";s:2:"Ç…";s:4:"DzÌŒ";s:2:"dž";s:4:"dzÌŒ";s:2:"LJ";s:2:"LJ";s:2:"Lj";s:2:"Lj";s:2:"lj";s:2:"lj";s:2:"ÇŠ";s:2:"NJ";s:2:"Ç‹";s:2:"Nj";s:2:"ÇŒ";s:2:"nj";s:2:"DZ";s:2:"DZ";s:2:"Dz";s:2:"Dz";s:2:"dz";s:2:"dz";s:2:"Ê°";s:1:"h";s:2:"ʱ";s:2:"ɦ";s:2:"ʲ";s:1:"j";s:2:"ʳ";s:1:"r";s:2:"Ê´";s:2:"ɹ";s:2:"ʵ";s:2:"É»";s:2:"ʶ";s:2:"Ê";s:2:"Ê·";s:1:"w";s:2:"ʸ";s:1:"y";s:2:"˘";s:3:" ̆";s:2:"Ë™";s:3:" ̇";s:2:"Ëš";s:3:" ÌŠ";s:2:"Ë›";s:3:" ̨";s:2:"Ëœ";s:3:" ̃";s:2:"Ë";s:3:" Ì‹";s:2:"Ë ";s:2:"É£";s:2:"Ë¡";s:1:"l";s:2:"Ë¢";s:1:"s";s:2:"Ë£";s:1:"x";s:2:"ˤ";s:2:"Ê•";s:2:"ͺ";s:3:" Í…";s:2:"΄";s:3:" Ì";s:2:"Î…";s:5:" ̈Ì";s:2:"Ï";s:2:"β";s:2:"Ï‘";s:2:"θ";s:2:"Ï’";s:2:"Î¥";s:2:"Ï“";s:4:"Î¥Ì";s:2:"Ï”";s:4:"Ϋ";s:2:"Ï•";s:2:"φ";s:2:"Ï–";s:2:"Ï€";s:2:"Ï°";s:2:"κ";s:2:"ϱ";s:2:"Ï";s:2:"ϲ";s:2:"Ï‚";s:2:"Ï´";s:2:"Θ";s:2:"ϵ";s:2:"ε";s:2:"Ϲ";s:2:"Σ";s:2:"Ö‡";s:4:"Õ¥Ö‚";s:2:"Ùµ";s:4:"اٴ";s:2:"Ù¶";s:4:"وٴ";s:2:"Ù·";s:4:"Û‡Ù´";s:2:"Ù¸";s:4:"يٴ";s:3:"ำ";s:6:"à¹à¸²";s:3:"ຳ";s:6:"à»àº²";s:3:"ໜ";s:6:"ຫນ";s:3:"à»";s:6:"ຫມ";s:3:"༌";s:3:"་";s:3:"ཷ";s:9:"ྲཱྀ";s:3:"ཹ";s:9:"ླཱྀ";s:3:"ჼ";s:3:"ნ";s:3:"á´¬";s:1:"A";s:3:"á´­";s:2:"Æ";s:3:"á´®";s:1:"B";s:3:"á´°";s:1:"D";s:3:"á´±";s:1:"E";s:3:"á´²";s:2:"ÆŽ";s:3:"á´³";s:1:"G";s:3:"á´´";s:1:"H";s:3:"á´µ";s:1:"I";s:3:"á´¶";s:1:"J";s:3:"á´·";s:1:"K";s:3:"á´¸";s:1:"L";s:3:"á´¹";s:1:"M";s:3:"á´º";s:1:"N";s:3:"á´¼";s:1:"O";s:3:"á´½";s:2:"È¢";s:3:"á´¾";s:1:"P";s:3:"á´¿";s:1:"R";s:3:"áµ€";s:1:"T";s:3:"áµ";s:1:"U";s:3:"ᵂ";s:1:"W";s:3:"ᵃ";s:1:"a";s:3:"ᵄ";s:2:"É";s:3:"áµ…";s:2:"É‘";s:3:"ᵆ";s:3:"á´‚";s:3:"ᵇ";s:1:"b";s:3:"ᵈ";s:1:"d";s:3:"ᵉ";s:1:"e";s:3:"ᵊ";s:2:"É™";s:3:"ᵋ";s:2:"É›";s:3:"ᵌ";s:2:"Éœ";s:3:"áµ";s:1:"g";s:3:"áµ";s:1:"k";s:3:"áµ";s:1:"m";s:3:"ᵑ";s:2:"Å‹";s:3:"áµ’";s:1:"o";s:3:"ᵓ";s:2:"É”";s:3:"áµ”";s:3:"á´–";s:3:"ᵕ";s:3:"á´—";s:3:"áµ–";s:1:"p";s:3:"áµ—";s:1:"t";s:3:"ᵘ";s:1:"u";s:3:"áµ™";s:3:"á´";s:3:"ᵚ";s:2:"ɯ";s:3:"áµ›";s:1:"v";s:3:"ᵜ";s:3:"á´¥";s:3:"áµ";s:2:"β";s:3:"ᵞ";s:2:"γ";s:3:"ᵟ";s:2:"δ";s:3:"áµ ";s:2:"φ";s:3:"ᵡ";s:2:"χ";s:3:"áµ¢";s:1:"i";s:3:"áµ£";s:1:"r";s:3:"ᵤ";s:1:"u";s:3:"áµ¥";s:1:"v";s:3:"ᵦ";s:2:"β";s:3:"ᵧ";s:2:"γ";s:3:"ᵨ";s:2:"Ï";s:3:"ᵩ";s:2:"φ";s:3:"ᵪ";s:2:"χ";s:3:"ᵸ";s:2:"н";s:3:"ᶛ";s:2:"É’";s:3:"ᶜ";s:1:"c";s:3:"á¶";s:2:"É•";s:3:"ᶞ";s:2:"ð";s:3:"ᶟ";s:2:"Éœ";s:3:"ᶠ";s:1:"f";s:3:"ᶡ";s:2:"ÉŸ";s:3:"ᶢ";s:2:"É¡";s:3:"ᶣ";s:2:"É¥";s:3:"ᶤ";s:2:"ɨ";s:3:"ᶥ";s:2:"É©";s:3:"ᶦ";s:2:"ɪ";s:3:"ᶧ";s:3:"áµ»";s:3:"ᶨ";s:2:"Ê";s:3:"ᶩ";s:2:"É­";s:3:"ᶪ";s:3:"ᶅ";s:3:"ᶫ";s:2:"ÊŸ";s:3:"ᶬ";s:2:"ɱ";s:3:"ᶭ";s:2:"É°";s:3:"ᶮ";s:2:"ɲ";s:3:"ᶯ";s:2:"ɳ";s:3:"ᶰ";s:2:"É´";s:3:"ᶱ";s:2:"ɵ";s:3:"ᶲ";s:2:"ɸ";s:3:"ᶳ";s:2:"Ê‚";s:3:"ᶴ";s:2:"ʃ";s:3:"ᶵ";s:2:"Æ«";s:3:"ᶶ";s:2:"ʉ";s:3:"ᶷ";s:2:"ÊŠ";s:3:"ᶸ";s:3:"á´œ";s:3:"ᶹ";s:2:"Ê‹";s:3:"ᶺ";s:2:"ÊŒ";s:3:"ᶻ";s:1:"z";s:3:"ᶼ";s:2:"Ê";s:3:"ᶽ";s:2:"Ê‘";s:3:"ᶾ";s:2:"Ê’";s:3:"ᶿ";s:2:"θ";s:3:"ẚ";s:3:"aʾ";s:3:"ẛ";s:3:"ṡ";s:3:"á¾½";s:3:" Ì“";s:3:"᾿";s:3:" Ì“";s:3:"á¿€";s:3:" Í‚";s:3:"á¿";s:5:" ̈͂";s:3:"á¿";s:5:" Ì“Ì€";s:3:"á¿Ž";s:5:" Ì“Ì";s:3:"á¿";s:5:" Ì“Í‚";s:3:"á¿";s:5:" ̔̀";s:3:"á¿ž";s:5:" Ì”Ì";s:3:"á¿Ÿ";s:5:" ̔͂";s:3:"á¿­";s:5:" ̈̀";s:3:"á¿®";s:5:" ̈Ì";s:3:"´";s:3:" Ì";s:3:"῾";s:3:" Ì”";s:3:" ";s:1:" ";s:3:"â€";s:1:" ";s:3:" ";s:1:" ";s:3:" ";s:1:" ";s:3:" ";s:1:" ";s:3:" ";s:1:" ";s:3:" ";s:1:" ";s:3:" ";s:1:" ";s:3:" ";s:1:" ";s:3:" ";s:1:" ";s:3:" ";s:1:" ";s:3:"‑";s:3:"â€";s:3:"‗";s:3:" ̳";s:3:"․";s:1:".";s:3:"‥";s:2:"..";s:3:"…";s:3:"...";s:3:" ";s:1:" ";s:3:"″";s:6:"′′";s:3:"‴";s:9:"′′′";s:3:"‶";s:6:"‵‵";s:3:"‷";s:9:"‵‵‵";s:3:"‼";s:2:"!!";s:3:"‾";s:3:" Ì…";s:3:"â‡";s:2:"??";s:3:"âˆ";s:2:"?!";s:3:"â‰";s:2:"!?";s:3:"â—";s:12:"′′′′";s:3:"âŸ";s:1:" ";s:3:"â°";s:1:"0";s:3:"â±";s:1:"i";s:3:"â´";s:1:"4";s:3:"âµ";s:1:"5";s:3:"â¶";s:1:"6";s:3:"â·";s:1:"7";s:3:"â¸";s:1:"8";s:3:"â¹";s:1:"9";s:3:"âº";s:1:"+";s:3:"â»";s:3:"−";s:3:"â¼";s:1:"=";s:3:"â½";s:1:"(";s:3:"â¾";s:1:")";s:3:"â¿";s:1:"n";s:3:"â‚€";s:1:"0";s:3:"â‚";s:1:"1";s:3:"â‚‚";s:1:"2";s:3:"₃";s:1:"3";s:3:"â‚„";s:1:"4";s:3:"â‚…";s:1:"5";s:3:"₆";s:1:"6";s:3:"₇";s:1:"7";s:3:"₈";s:1:"8";s:3:"₉";s:1:"9";s:3:"â‚Š";s:1:"+";s:3:"â‚‹";s:3:"−";s:3:"â‚Œ";s:1:"=";s:3:"â‚";s:1:"(";s:3:"â‚Ž";s:1:")";s:3:"â‚";s:1:"a";s:3:"â‚‘";s:1:"e";s:3:"â‚’";s:1:"o";s:3:"â‚“";s:1:"x";s:3:"â‚”";s:2:"É™";s:3:"â‚•";s:1:"h";s:3:"â‚–";s:1:"k";s:3:"â‚—";s:1:"l";s:3:"ₘ";s:1:"m";s:3:"â‚™";s:1:"n";s:3:"â‚š";s:1:"p";s:3:"â‚›";s:1:"s";s:3:"â‚œ";s:1:"t";s:3:"₨";s:2:"Rs";s:3:"â„€";s:3:"a/c";s:3:"â„";s:3:"a/s";s:3:"â„‚";s:1:"C";s:3:"℃";s:3:"°C";s:3:"â„…";s:3:"c/o";s:3:"℆";s:3:"c/u";s:3:"ℇ";s:2:"Æ";s:3:"℉";s:3:"°F";s:3:"â„Š";s:1:"g";s:3:"â„‹";s:1:"H";s:3:"â„Œ";s:1:"H";s:3:"â„";s:1:"H";s:3:"â„Ž";s:1:"h";s:3:"â„";s:2:"ħ";s:3:"â„";s:1:"I";s:3:"â„‘";s:1:"I";s:3:"â„’";s:1:"L";s:3:"â„“";s:1:"l";s:3:"â„•";s:1:"N";s:3:"â„–";s:2:"No";s:3:"â„™";s:1:"P";s:3:"â„š";s:1:"Q";s:3:"â„›";s:1:"R";s:3:"â„œ";s:1:"R";s:3:"â„";s:1:"R";s:3:"â„ ";s:2:"SM";s:3:"â„¡";s:3:"TEL";s:3:"â„¢";s:2:"TM";s:3:"ℤ";s:1:"Z";s:3:"ℨ";s:1:"Z";s:3:"ℬ";s:1:"B";s:3:"â„­";s:1:"C";s:3:"ℯ";s:1:"e";s:3:"â„°";s:1:"E";s:3:"ℱ";s:1:"F";s:3:"ℳ";s:1:"M";s:3:"â„´";s:1:"o";s:3:"ℵ";s:2:"×";s:3:"ℶ";s:2:"ב";s:3:"â„·";s:2:"×’";s:3:"ℸ";s:2:"ד";s:3:"ℹ";s:1:"i";s:3:"â„»";s:3:"FAX";s:3:"ℼ";s:2:"Ï€";s:3:"ℽ";s:2:"γ";s:3:"ℾ";s:2:"Γ";s:3:"â„¿";s:2:"Π";s:3:"â…€";s:3:"∑";s:3:"â……";s:1:"D";s:3:"â…†";s:1:"d";s:3:"â…‡";s:1:"e";s:3:"â…ˆ";s:1:"i";s:3:"â…‰";s:1:"j";s:3:"â…";s:5:"1â„7";s:3:"â…‘";s:5:"1â„9";s:3:"â…’";s:6:"1â„10";s:3:"â…“";s:5:"1â„3";s:3:"â…”";s:5:"2â„3";s:3:"â…•";s:5:"1â„5";s:3:"â…–";s:5:"2â„5";s:3:"â…—";s:5:"3â„5";s:3:"â…˜";s:5:"4â„5";s:3:"â…™";s:5:"1â„6";s:3:"â…š";s:5:"5â„6";s:3:"â…›";s:5:"1â„8";s:3:"â…œ";s:5:"3â„8";s:3:"â…";s:5:"5â„8";s:3:"â…ž";s:5:"7â„8";s:3:"â…Ÿ";s:4:"1â„";s:3:"â… ";s:1:"I";s:3:"â…¡";s:2:"II";s:3:"â…¢";s:3:"III";s:3:"â…£";s:2:"IV";s:3:"â…¤";s:1:"V";s:3:"â…¥";s:2:"VI";s:3:"â…¦";s:3:"VII";s:3:"â…§";s:4:"VIII";s:3:"â…¨";s:2:"IX";s:3:"â…©";s:1:"X";s:3:"â…ª";s:2:"XI";s:3:"â…«";s:3:"XII";s:3:"â…¬";s:1:"L";s:3:"â…­";s:1:"C";s:3:"â…®";s:1:"D";s:3:"â…¯";s:1:"M";s:3:"â…°";s:1:"i";s:3:"â…±";s:2:"ii";s:3:"â…²";s:3:"iii";s:3:"â…³";s:2:"iv";s:3:"â…´";s:1:"v";s:3:"â…µ";s:2:"vi";s:3:"â…¶";s:3:"vii";s:3:"â…·";s:4:"viii";s:3:"â…¸";s:2:"ix";s:3:"â…¹";s:1:"x";s:3:"â…º";s:2:"xi";s:3:"â…»";s:3:"xii";s:3:"â…¼";s:1:"l";s:3:"â…½";s:1:"c";s:3:"â…¾";s:1:"d";s:3:"â…¿";s:1:"m";s:3:"↉";s:5:"0â„3";s:3:"∬";s:6:"∫∫";s:3:"∭";s:9:"∫∫∫";s:3:"∯";s:6:"∮∮";s:3:"∰";s:9:"∮∮∮";s:3:"â‘ ";s:1:"1";s:3:"â‘¡";s:1:"2";s:3:"â‘¢";s:1:"3";s:3:"â‘£";s:1:"4";s:3:"⑤";s:1:"5";s:3:"â‘¥";s:1:"6";s:3:"⑦";s:1:"7";s:3:"⑧";s:1:"8";s:3:"⑨";s:1:"9";s:3:"â‘©";s:2:"10";s:3:"⑪";s:2:"11";s:3:"â‘«";s:2:"12";s:3:"⑬";s:2:"13";s:3:"â‘­";s:2:"14";s:3:"â‘®";s:2:"15";s:3:"⑯";s:2:"16";s:3:"â‘°";s:2:"17";s:3:"⑱";s:2:"18";s:3:"⑲";s:2:"19";s:3:"⑳";s:2:"20";s:3:"â‘´";s:3:"(1)";s:3:"⑵";s:3:"(2)";s:3:"⑶";s:3:"(3)";s:3:"â‘·";s:3:"(4)";s:3:"⑸";s:3:"(5)";s:3:"⑹";s:3:"(6)";s:3:"⑺";s:3:"(7)";s:3:"â‘»";s:3:"(8)";s:3:"⑼";s:3:"(9)";s:3:"⑽";s:4:"(10)";s:3:"⑾";s:4:"(11)";s:3:"â‘¿";s:4:"(12)";s:3:"â’€";s:4:"(13)";s:3:"â’";s:4:"(14)";s:3:"â’‚";s:4:"(15)";s:3:"â’ƒ";s:4:"(16)";s:3:"â’„";s:4:"(17)";s:3:"â’…";s:4:"(18)";s:3:"â’†";s:4:"(19)";s:3:"â’‡";s:4:"(20)";s:3:"â’ˆ";s:2:"1.";s:3:"â’‰";s:2:"2.";s:3:"â’Š";s:2:"3.";s:3:"â’‹";s:2:"4.";s:3:"â’Œ";s:2:"5.";s:3:"â’";s:2:"6.";s:3:"â’Ž";s:2:"7.";s:3:"â’";s:2:"8.";s:3:"â’";s:2:"9.";s:3:"â’‘";s:3:"10.";s:3:"â’’";s:3:"11.";s:3:"â’“";s:3:"12.";s:3:"â’”";s:3:"13.";s:3:"â’•";s:3:"14.";s:3:"â’–";s:3:"15.";s:3:"â’—";s:3:"16.";s:3:"â’˜";s:3:"17.";s:3:"â’™";s:3:"18.";s:3:"â’š";s:3:"19.";s:3:"â’›";s:3:"20.";s:3:"â’œ";s:3:"(a)";s:3:"â’";s:3:"(b)";s:3:"â’ž";s:3:"(c)";s:3:"â’Ÿ";s:3:"(d)";s:3:"â’ ";s:3:"(e)";s:3:"â’¡";s:3:"(f)";s:3:"â’¢";s:3:"(g)";s:3:"â’£";s:3:"(h)";s:3:"â’¤";s:3:"(i)";s:3:"â’¥";s:3:"(j)";s:3:"â’¦";s:3:"(k)";s:3:"â’§";s:3:"(l)";s:3:"â’¨";s:3:"(m)";s:3:"â’©";s:3:"(n)";s:3:"â’ª";s:3:"(o)";s:3:"â’«";s:3:"(p)";s:3:"â’¬";s:3:"(q)";s:3:"â’­";s:3:"(r)";s:3:"â’®";s:3:"(s)";s:3:"â’¯";s:3:"(t)";s:3:"â’°";s:3:"(u)";s:3:"â’±";s:3:"(v)";s:3:"â’²";s:3:"(w)";s:3:"â’³";s:3:"(x)";s:3:"â’´";s:3:"(y)";s:3:"â’µ";s:3:"(z)";s:3:"â’¶";s:1:"A";s:3:"â’·";s:1:"B";s:3:"â’¸";s:1:"C";s:3:"â’¹";s:1:"D";s:3:"â’º";s:1:"E";s:3:"â’»";s:1:"F";s:3:"â’¼";s:1:"G";s:3:"â’½";s:1:"H";s:3:"â’¾";s:1:"I";s:3:"â’¿";s:1:"J";s:3:"â“€";s:1:"K";s:3:"â“";s:1:"L";s:3:"â“‚";s:1:"M";s:3:"Ⓝ";s:1:"N";s:3:"â“„";s:1:"O";s:3:"â“…";s:1:"P";s:3:"Ⓠ";s:1:"Q";s:3:"Ⓡ";s:1:"R";s:3:"Ⓢ";s:1:"S";s:3:"Ⓣ";s:1:"T";s:3:"â“Š";s:1:"U";s:3:"â“‹";s:1:"V";s:3:"â“Œ";s:1:"W";s:3:"â“";s:1:"X";s:3:"â“Ž";s:1:"Y";s:3:"â“";s:1:"Z";s:3:"â“";s:1:"a";s:3:"â“‘";s:1:"b";s:3:"â“’";s:1:"c";s:3:"â““";s:1:"d";s:3:"â“”";s:1:"e";s:3:"â“•";s:1:"f";s:3:"â“–";s:1:"g";s:3:"â“—";s:1:"h";s:3:"ⓘ";s:1:"i";s:3:"â“™";s:1:"j";s:3:"â“š";s:1:"k";s:3:"â“›";s:1:"l";s:3:"â“œ";s:1:"m";s:3:"â“";s:1:"n";s:3:"â“ž";s:1:"o";s:3:"â“Ÿ";s:1:"p";s:3:"â“ ";s:1:"q";s:3:"â“¡";s:1:"r";s:3:"â“¢";s:1:"s";s:3:"â“£";s:1:"t";s:3:"ⓤ";s:1:"u";s:3:"â“¥";s:1:"v";s:3:"ⓦ";s:1:"w";s:3:"ⓧ";s:1:"x";s:3:"ⓨ";s:1:"y";s:3:"â“©";s:1:"z";s:3:"⓪";s:1:"0";s:3:"⨌";s:12:"∫∫∫∫";s:3:"â©´";s:3:"::=";s:3:"⩵";s:2:"==";s:3:"⩶";s:3:"===";s:3:"â±¼";s:1:"j";s:3:"â±½";s:1:"V";s:3:"ⵯ";s:3:"ⵡ";s:3:"⺟";s:3:"æ¯";s:3:"⻳";s:3:"龟";s:3:"â¼€";s:3:"一";s:3:"â¼";s:3:"丨";s:3:"⼂";s:3:"丶";s:3:"⼃";s:3:"丿";s:3:"⼄";s:3:"ä¹™";s:3:"â¼…";s:3:"亅";s:3:"⼆";s:3:"二";s:3:"⼇";s:3:"亠";s:3:"⼈";s:3:"人";s:3:"⼉";s:3:"å„¿";s:3:"⼊";s:3:"å…¥";s:3:"⼋";s:3:"å…«";s:3:"⼌";s:3:"冂";s:3:"â¼";s:3:"冖";s:3:"⼎";s:3:"冫";s:3:"â¼";s:3:"几";s:3:"â¼";s:3:"凵";s:3:"⼑";s:3:"刀";s:3:"â¼’";s:3:"力";s:3:"⼓";s:3:"勹";s:3:"â¼”";s:3:"匕";s:3:"⼕";s:3:"匚";s:3:"â¼–";s:3:"匸";s:3:"â¼—";s:3:"å";s:3:"⼘";s:3:"åœ";s:3:"â¼™";s:3:"å©";s:3:"⼚";s:3:"厂";s:3:"â¼›";s:3:"厶";s:3:"⼜";s:3:"åˆ";s:3:"â¼";s:3:"å£";s:3:"⼞";s:3:"å›—";s:3:"⼟";s:3:"土";s:3:"â¼ ";s:3:"士";s:3:"⼡";s:3:"夂";s:3:"â¼¢";s:3:"夊";s:3:"â¼£";s:3:"夕";s:3:"⼤";s:3:"大";s:3:"â¼¥";s:3:"女";s:3:"⼦";s:3:"å­";s:3:"⼧";s:3:"宀";s:3:"⼨";s:3:"寸";s:3:"⼩";s:3:"å°";s:3:"⼪";s:3:"å°¢";s:3:"⼫";s:3:"å°¸";s:3:"⼬";s:3:"å±®";s:3:"â¼­";s:3:"å±±";s:3:"â¼®";s:3:"å·›";s:3:"⼯";s:3:"å·¥";s:3:"â¼°";s:3:"å·±";s:3:"â¼±";s:3:"å·¾";s:3:"â¼²";s:3:"å¹²";s:3:"â¼³";s:3:"幺";s:3:"â¼´";s:3:"广";s:3:"â¼µ";s:3:"å»´";s:3:"⼶";s:3:"廾";s:3:"â¼·";s:3:"弋";s:3:"⼸";s:3:"弓";s:3:"â¼¹";s:3:"å½";s:3:"⼺";s:3:"彡";s:3:"â¼»";s:3:"å½³";s:3:"â¼¼";s:3:"心";s:3:"â¼½";s:3:"戈";s:3:"â¼¾";s:3:"戶";s:3:"⼿";s:3:"手";s:3:"â½€";s:3:"支";s:3:"â½";s:3:"æ”´";s:3:"⽂";s:3:"æ–‡";s:3:"⽃";s:3:"æ–—";s:3:"⽄";s:3:"æ–¤";s:3:"â½…";s:3:"æ–¹";s:3:"⽆";s:3:"æ— ";s:3:"⽇";s:3:"æ—¥";s:3:"⽈";s:3:"æ›°";s:3:"⽉";s:3:"月";s:3:"⽊";s:3:"木";s:3:"⽋";s:3:"欠";s:3:"⽌";s:3:"æ­¢";s:3:"â½";s:3:"æ­¹";s:3:"⽎";s:3:"殳";s:3:"â½";s:3:"毋";s:3:"â½";s:3:"比";s:3:"⽑";s:3:"毛";s:3:"â½’";s:3:"æ°";s:3:"⽓";s:3:"æ°”";s:3:"â½”";s:3:"æ°´";s:3:"⽕";s:3:"ç«";s:3:"â½–";s:3:"爪";s:3:"â½—";s:3:"父";s:3:"⽘";s:3:"爻";s:3:"â½™";s:3:"爿";s:3:"⽚";s:3:"片";s:3:"â½›";s:3:"牙";s:3:"⽜";s:3:"牛";s:3:"â½";s:3:"犬";s:3:"⽞";s:3:"玄";s:3:"⽟";s:3:"玉";s:3:"â½ ";s:3:"ç“œ";s:3:"⽡";s:3:"瓦";s:3:"â½¢";s:3:"甘";s:3:"â½£";s:3:"生";s:3:"⽤";s:3:"用";s:3:"â½¥";s:3:"ç”°";s:3:"⽦";s:3:"ç–‹";s:3:"⽧";s:3:"ç–’";s:3:"⽨";s:3:"癶";s:3:"⽩";s:3:"白";s:3:"⽪";s:3:"çš®";s:3:"⽫";s:3:"çš¿";s:3:"⽬";s:3:"ç›®";s:3:"â½­";s:3:"矛";s:3:"â½®";s:3:"矢";s:3:"⽯";s:3:"石";s:3:"â½°";s:3:"示";s:3:"â½±";s:3:"禸";s:3:"â½²";s:3:"禾";s:3:"â½³";s:3:"ç©´";s:3:"â½´";s:3:"ç«‹";s:3:"â½µ";s:3:"竹";s:3:"⽶";s:3:"ç±³";s:3:"â½·";s:3:"糸";s:3:"⽸";s:3:"缶";s:3:"â½¹";s:3:"网";s:3:"⽺";s:3:"羊";s:3:"â½»";s:3:"ç¾½";s:3:"â½¼";s:3:"è€";s:3:"â½½";s:3:"而";s:3:"â½¾";s:3:"耒";s:3:"⽿";s:3:"耳";s:3:"â¾€";s:3:"è¿";s:3:"â¾";s:3:"肉";s:3:"⾂";s:3:"臣";s:3:"⾃";s:3:"自";s:3:"⾄";s:3:"至";s:3:"â¾…";s:3:"臼";s:3:"⾆";s:3:"舌";s:3:"⾇";s:3:"舛";s:3:"⾈";s:3:"舟";s:3:"⾉";s:3:"艮";s:3:"⾊";s:3:"色";s:3:"⾋";s:3:"艸";s:3:"⾌";s:3:"è™";s:3:"â¾";s:3:"虫";s:3:"⾎";s:3:"è¡€";s:3:"â¾";s:3:"è¡Œ";s:3:"â¾";s:3:"è¡£";s:3:"⾑";s:3:"襾";s:3:"â¾’";s:3:"見";s:3:"⾓";s:3:"角";s:3:"â¾”";s:3:"言";s:3:"⾕";s:3:"è°·";s:3:"â¾–";s:3:"豆";s:3:"â¾—";s:3:"豕";s:3:"⾘";s:3:"豸";s:3:"â¾™";s:3:"è²";s:3:"⾚";s:3:"赤";s:3:"â¾›";s:3:"èµ°";s:3:"⾜";s:3:"足";s:3:"â¾";s:3:"身";s:3:"⾞";s:3:"車";s:3:"⾟";s:3:"è¾›";s:3:"â¾ ";s:3:"è¾°";s:3:"⾡";s:3:"è¾µ";s:3:"â¾¢";s:3:"é‚‘";s:3:"â¾£";s:3:"é…‰";s:3:"⾤";s:3:"釆";s:3:"â¾¥";s:3:"里";s:3:"⾦";s:3:"金";s:3:"⾧";s:3:"é•·";s:3:"⾨";s:3:"é–€";s:3:"⾩";s:3:"阜";s:3:"⾪";s:3:"隶";s:3:"⾫";s:3:"éš¹";s:3:"⾬";s:3:"雨";s:3:"â¾­";s:3:"é‘";s:3:"â¾®";s:3:"éž";s:3:"⾯";s:3:"é¢";s:3:"â¾°";s:3:"é©";s:3:"â¾±";s:3:"韋";s:3:"â¾²";s:3:"韭";s:3:"â¾³";s:3:"音";s:3:"â¾´";s:3:"é ";s:3:"â¾µ";s:3:"風";s:3:"⾶";s:3:"飛";s:3:"â¾·";s:3:"食";s:3:"⾸";s:3:"首";s:3:"â¾¹";s:3:"香";s:3:"⾺";s:3:"馬";s:3:"â¾»";s:3:"骨";s:3:"â¾¼";s:3:"高";s:3:"â¾½";s:3:"é«Ÿ";s:3:"â¾¾";s:3:"鬥";s:3:"⾿";s:3:"鬯";s:3:"â¿€";s:3:"鬲";s:3:"â¿";s:3:"鬼";s:3:"â¿‚";s:3:"é­š";s:3:"⿃";s:3:"é³¥";s:3:"â¿„";s:3:"é¹µ";s:3:"â¿…";s:3:"鹿";s:3:"⿆";s:3:"麥";s:3:"⿇";s:3:"麻";s:3:"⿈";s:3:"黃";s:3:"⿉";s:3:"é»";s:3:"â¿Š";s:3:"黑";s:3:"â¿‹";s:3:"黹";s:3:"â¿Œ";s:3:"黽";s:3:"â¿";s:3:"鼎";s:3:"â¿Ž";s:3:"鼓";s:3:"â¿";s:3:"é¼ ";s:3:"â¿";s:3:"é¼»";s:3:"â¿‘";s:3:"齊";s:3:"â¿’";s:3:"é½’";s:3:"â¿“";s:3:"é¾";s:3:"â¿”";s:3:"龜";s:3:"â¿•";s:3:"é¾ ";s:3:" ";s:1:" ";s:3:"〶";s:3:"〒";s:3:"〸";s:3:"å";s:3:"〹";s:3:"å„";s:3:"〺";s:3:"å…";s:3:"ã‚›";s:4:" ã‚™";s:3:"ã‚œ";s:4:" ã‚š";s:3:"ã‚Ÿ";s:6:"より";s:3:"ヿ";s:6:"コト";s:3:"ㄱ";s:3:"á„€";s:3:"ㄲ";s:3:"á„";s:3:"ㄳ";s:3:"ᆪ";s:3:"ã„´";s:3:"á„‚";s:3:"ㄵ";s:3:"ᆬ";s:3:"ㄶ";s:3:"ᆭ";s:3:"ã„·";s:3:"ᄃ";s:3:"ㄸ";s:3:"á„„";s:3:"ㄹ";s:3:"á„…";s:3:"ㄺ";s:3:"ᆰ";s:3:"ã„»";s:3:"ᆱ";s:3:"ㄼ";s:3:"ᆲ";s:3:"ㄽ";s:3:"ᆳ";s:3:"ㄾ";s:3:"ᆴ";s:3:"ã„¿";s:3:"ᆵ";s:3:"ã…€";s:3:"á„š";s:3:"ã…";s:3:"ᄆ";s:3:"ã…‚";s:3:"ᄇ";s:3:"ã…ƒ";s:3:"ᄈ";s:3:"ã…„";s:3:"á„¡";s:3:"ã……";s:3:"ᄉ";s:3:"ã…†";s:3:"á„Š";s:3:"ã…‡";s:3:"á„‹";s:3:"ã…ˆ";s:3:"á„Œ";s:3:"ã…‰";s:3:"á„";s:3:"ã…Š";s:3:"á„Ž";s:3:"ã…‹";s:3:"á„";s:3:"ã…Œ";s:3:"á„";s:3:"ã…";s:3:"á„‘";s:3:"ã…Ž";s:3:"á„’";s:3:"ã…";s:3:"á…¡";s:3:"ã…";s:3:"á…¢";s:3:"ã…‘";s:3:"á…£";s:3:"ã…’";s:3:"á…¤";s:3:"ã…“";s:3:"á…¥";s:3:"ã…”";s:3:"á…¦";s:3:"ã…•";s:3:"á…§";s:3:"ã…–";s:3:"á…¨";s:3:"ã…—";s:3:"á…©";s:3:"ã…˜";s:3:"á…ª";s:3:"ã…™";s:3:"á…«";s:3:"ã…š";s:3:"á…¬";s:3:"ã…›";s:3:"á…­";s:3:"ã…œ";s:3:"á…®";s:3:"ã…";s:3:"á…¯";s:3:"ã…ž";s:3:"á…°";s:3:"ã…Ÿ";s:3:"á…±";s:3:"ã… ";s:3:"á…²";s:3:"ã…¡";s:3:"á…³";s:3:"ã…¢";s:3:"á…´";s:3:"ã…£";s:3:"á…µ";s:3:"ã…¤";s:3:"á… ";s:3:"ã…¥";s:3:"á„”";s:3:"ã…¦";s:3:"á„•";s:3:"ã…§";s:3:"ᇇ";s:3:"ã…¨";s:3:"ᇈ";s:3:"ã…©";s:3:"ᇌ";s:3:"ã…ª";s:3:"ᇎ";s:3:"ã…«";s:3:"ᇓ";s:3:"ã…¬";s:3:"ᇗ";s:3:"ã…­";s:3:"ᇙ";s:3:"ã…®";s:3:"á„œ";s:3:"ã…¯";s:3:"á‡";s:3:"ã…°";s:3:"ᇟ";s:3:"ã…±";s:3:"á„";s:3:"ã…²";s:3:"á„ž";s:3:"ã…³";s:3:"á„ ";s:3:"ã…´";s:3:"á„¢";s:3:"ã…µ";s:3:"á„£";s:3:"ã…¶";s:3:"ᄧ";s:3:"ã…·";s:3:"á„©";s:3:"ã…¸";s:3:"á„«";s:3:"ã…¹";s:3:"ᄬ";s:3:"ã…º";s:3:"á„­";s:3:"ã…»";s:3:"á„®";s:3:"ã…¼";s:3:"ᄯ";s:3:"ã…½";s:3:"ᄲ";s:3:"ã…¾";s:3:"ᄶ";s:3:"ã…¿";s:3:"á…€";s:3:"ㆀ";s:3:"á…‡";s:3:"ã†";s:3:"á…Œ";s:3:"ㆂ";s:3:"ᇱ";s:3:"ㆃ";s:3:"ᇲ";s:3:"ㆄ";s:3:"á…—";s:3:"ㆅ";s:3:"á…˜";s:3:"ㆆ";s:3:"á…™";s:3:"ㆇ";s:3:"ᆄ";s:3:"ㆈ";s:3:"ᆅ";s:3:"ㆉ";s:3:"ᆈ";s:3:"ㆊ";s:3:"ᆑ";s:3:"ㆋ";s:3:"ᆒ";s:3:"ㆌ";s:3:"ᆔ";s:3:"ã†";s:3:"ᆞ";s:3:"ㆎ";s:3:"ᆡ";s:3:"㆒";s:3:"一";s:3:"㆓";s:3:"二";s:3:"㆔";s:3:"三";s:3:"㆕";s:3:"å››";s:3:"㆖";s:3:"上";s:3:"㆗";s:3:"中";s:3:"㆘";s:3:"下";s:3:"㆙";s:3:"甲";s:3:"㆚";s:3:"ä¹™";s:3:"㆛";s:3:"丙";s:3:"㆜";s:3:"ä¸";s:3:"ã†";s:3:"天";s:3:"㆞";s:3:"地";s:3:"㆟";s:3:"人";s:3:"㈀";s:5:"(á„€)";s:3:"ãˆ";s:5:"(á„‚)";s:3:"㈂";s:5:"(ᄃ)";s:3:"㈃";s:5:"(á„…)";s:3:"㈄";s:5:"(ᄆ)";s:3:"㈅";s:5:"(ᄇ)";s:3:"㈆";s:5:"(ᄉ)";s:3:"㈇";s:5:"(á„‹)";s:3:"㈈";s:5:"(á„Œ)";s:3:"㈉";s:5:"(á„Ž)";s:3:"㈊";s:5:"(á„)";s:3:"㈋";s:5:"(á„)";s:3:"㈌";s:5:"(á„‘)";s:3:"ãˆ";s:5:"(á„’)";s:3:"㈎";s:8:"(가)";s:3:"ãˆ";s:8:"(á„‚á…¡)";s:3:"ãˆ";s:8:"(다)";s:3:"㈑";s:8:"(á„…á…¡)";s:3:"㈒";s:8:"(마)";s:3:"㈓";s:8:"(바)";s:3:"㈔";s:8:"(사)";s:3:"㈕";s:8:"(á„‹á…¡)";s:3:"㈖";s:8:"(자)";s:3:"㈗";s:8:"(á„Žá…¡)";s:3:"㈘";s:8:"(á„á…¡)";s:3:"㈙";s:8:"(á„á…¡)";s:3:"㈚";s:8:"(á„‘á…¡)";s:3:"㈛";s:8:"(á„’á…¡)";s:3:"㈜";s:8:"(주)";s:3:"ãˆ";s:17:"(오전)";s:3:"㈞";s:14:"(á„‹á…©á„’á…®)";s:3:"㈠";s:5:"(一)";s:3:"㈡";s:5:"(二)";s:3:"㈢";s:5:"(三)";s:3:"㈣";s:5:"(å››)";s:3:"㈤";s:5:"(五)";s:3:"㈥";s:5:"(å…­)";s:3:"㈦";s:5:"(七)";s:3:"㈧";s:5:"(å…«)";s:3:"㈨";s:5:"(ä¹)";s:3:"㈩";s:5:"(å)";s:3:"㈪";s:5:"(月)";s:3:"㈫";s:5:"(ç«)";s:3:"㈬";s:5:"(æ°´)";s:3:"㈭";s:5:"(木)";s:3:"㈮";s:5:"(金)";s:3:"㈯";s:5:"(土)";s:3:"㈰";s:5:"(æ—¥)";s:3:"㈱";s:5:"(æ ª)";s:3:"㈲";s:5:"(有)";s:3:"㈳";s:5:"(社)";s:3:"㈴";s:5:"(å)";s:3:"㈵";s:5:"(特)";s:3:"㈶";s:5:"(財)";s:3:"㈷";s:5:"(ç¥)";s:3:"㈸";s:5:"(労)";s:3:"㈹";s:5:"(代)";s:3:"㈺";s:5:"(呼)";s:3:"㈻";s:5:"(å­¦)";s:3:"㈼";s:5:"(監)";s:3:"㈽";s:5:"(ä¼)";s:3:"㈾";s:5:"(資)";s:3:"㈿";s:5:"(å”)";s:3:"㉀";s:5:"(祭)";s:3:"ã‰";s:5:"(休)";s:3:"㉂";s:5:"(自)";s:3:"㉃";s:5:"(至)";s:3:"㉄";s:3:"å•";s:3:"㉅";s:3:"å¹¼";s:3:"㉆";s:3:"æ–‡";s:3:"㉇";s:3:"ç®";s:3:"ã‰";s:3:"PTE";s:3:"㉑";s:2:"21";s:3:"㉒";s:2:"22";s:3:"㉓";s:2:"23";s:3:"㉔";s:2:"24";s:3:"㉕";s:2:"25";s:3:"㉖";s:2:"26";s:3:"㉗";s:2:"27";s:3:"㉘";s:2:"28";s:3:"㉙";s:2:"29";s:3:"㉚";s:2:"30";s:3:"㉛";s:2:"31";s:3:"㉜";s:2:"32";s:3:"ã‰";s:2:"33";s:3:"㉞";s:2:"34";s:3:"㉟";s:2:"35";s:3:"㉠";s:3:"á„€";s:3:"㉡";s:3:"á„‚";s:3:"㉢";s:3:"ᄃ";s:3:"㉣";s:3:"á„…";s:3:"㉤";s:3:"ᄆ";s:3:"㉥";s:3:"ᄇ";s:3:"㉦";s:3:"ᄉ";s:3:"㉧";s:3:"á„‹";s:3:"㉨";s:3:"á„Œ";s:3:"㉩";s:3:"á„Ž";s:3:"㉪";s:3:"á„";s:3:"㉫";s:3:"á„";s:3:"㉬";s:3:"á„‘";s:3:"㉭";s:3:"á„’";s:3:"㉮";s:6:"가";s:3:"㉯";s:6:"á„‚á…¡";s:3:"㉰";s:6:"다";s:3:"㉱";s:6:"á„…á…¡";s:3:"㉲";s:6:"마";s:3:"㉳";s:6:"바";s:3:"㉴";s:6:"사";s:3:"㉵";s:6:"á„‹á…¡";s:3:"㉶";s:6:"자";s:3:"㉷";s:6:"á„Žá…¡";s:3:"㉸";s:6:"á„á…¡";s:3:"㉹";s:6:"á„á…¡";s:3:"㉺";s:6:"á„‘á…¡";s:3:"㉻";s:6:"á„’á…¡";s:3:"㉼";s:15:"참고";s:3:"㉽";s:12:"주의";s:3:"㉾";s:6:"á„‹á…®";s:3:"㊀";s:3:"一";s:3:"ãŠ";s:3:"二";s:3:"㊂";s:3:"三";s:3:"㊃";s:3:"å››";s:3:"㊄";s:3:"五";s:3:"㊅";s:3:"å…­";s:3:"㊆";s:3:"七";s:3:"㊇";s:3:"å…«";s:3:"㊈";s:3:"ä¹";s:3:"㊉";s:3:"å";s:3:"㊊";s:3:"月";s:3:"㊋";s:3:"ç«";s:3:"㊌";s:3:"æ°´";s:3:"ãŠ";s:3:"木";s:3:"㊎";s:3:"金";s:3:"ãŠ";s:3:"土";s:3:"ãŠ";s:3:"æ—¥";s:3:"㊑";s:3:"æ ª";s:3:"㊒";s:3:"有";s:3:"㊓";s:3:"社";s:3:"㊔";s:3:"å";s:3:"㊕";s:3:"特";s:3:"㊖";s:3:"財";s:3:"㊗";s:3:"ç¥";s:3:"㊘";s:3:"労";s:3:"㊙";s:3:"秘";s:3:"㊚";s:3:"ç”·";s:3:"㊛";s:3:"女";s:3:"㊜";s:3:"é©";s:3:"ãŠ";s:3:"優";s:3:"㊞";s:3:"å°";s:3:"㊟";s:3:"注";s:3:"㊠";s:3:"é …";s:3:"㊡";s:3:"休";s:3:"㊢";s:3:"写";s:3:"㊣";s:3:"æ­£";s:3:"㊤";s:3:"上";s:3:"㊥";s:3:"中";s:3:"㊦";s:3:"下";s:3:"㊧";s:3:"å·¦";s:3:"㊨";s:3:"å³";s:3:"㊩";s:3:"医";s:3:"㊪";s:3:"å®—";s:3:"㊫";s:3:"å­¦";s:3:"㊬";s:3:"監";s:3:"㊭";s:3:"ä¼";s:3:"㊮";s:3:"資";s:3:"㊯";s:3:"å”";s:3:"㊰";s:3:"夜";s:3:"㊱";s:2:"36";s:3:"㊲";s:2:"37";s:3:"㊳";s:2:"38";s:3:"㊴";s:2:"39";s:3:"㊵";s:2:"40";s:3:"㊶";s:2:"41";s:3:"㊷";s:2:"42";s:3:"㊸";s:2:"43";s:3:"㊹";s:2:"44";s:3:"㊺";s:2:"45";s:3:"㊻";s:2:"46";s:3:"㊼";s:2:"47";s:3:"㊽";s:2:"48";s:3:"㊾";s:2:"49";s:3:"㊿";s:2:"50";s:3:"ã‹€";s:4:"1月";s:3:"ã‹";s:4:"2月";s:3:"ã‹‚";s:4:"3月";s:3:"㋃";s:4:"4月";s:3:"ã‹„";s:4:"5月";s:3:"ã‹…";s:4:"6月";s:3:"㋆";s:4:"7月";s:3:"㋇";s:4:"8月";s:3:"㋈";s:4:"9月";s:3:"㋉";s:5:"10月";s:3:"ã‹Š";s:5:"11月";s:3:"ã‹‹";s:5:"12月";s:3:"ã‹Œ";s:2:"Hg";s:3:"ã‹";s:3:"erg";s:3:"ã‹Ž";s:2:"eV";s:3:"ã‹";s:3:"LTD";s:3:"ã‹";s:3:"ã‚¢";s:3:"ã‹‘";s:3:"イ";s:3:"ã‹’";s:3:"ウ";s:3:"ã‹“";s:3:"エ";s:3:"ã‹”";s:3:"オ";s:3:"ã‹•";s:3:"ã‚«";s:3:"ã‹–";s:3:"ã‚­";s:3:"ã‹—";s:3:"ク";s:3:"㋘";s:3:"ケ";s:3:"ã‹™";s:3:"コ";s:3:"ã‹š";s:3:"サ";s:3:"ã‹›";s:3:"ã‚·";s:3:"ã‹œ";s:3:"ス";s:3:"ã‹";s:3:"ã‚»";s:3:"ã‹ž";s:3:"ソ";s:3:"ã‹Ÿ";s:3:"ã‚¿";s:3:"ã‹ ";s:3:"ãƒ";s:3:"ã‹¡";s:3:"ツ";s:3:"ã‹¢";s:3:"テ";s:3:"ã‹£";s:3:"ト";s:3:"㋤";s:3:"ナ";s:3:"ã‹¥";s:3:"ニ";s:3:"㋦";s:3:"ヌ";s:3:"㋧";s:3:"ãƒ";s:3:"㋨";s:3:"ノ";s:3:"ã‹©";s:3:"ãƒ";s:3:"㋪";s:3:"ヒ";s:3:"ã‹«";s:3:"フ";s:3:"㋬";s:3:"ヘ";s:3:"ã‹­";s:3:"ホ";s:3:"ã‹®";s:3:"マ";s:3:"㋯";s:3:"ミ";s:3:"ã‹°";s:3:"ム";s:3:"㋱";s:3:"メ";s:3:"㋲";s:3:"モ";s:3:"㋳";s:3:"ヤ";s:3:"ã‹´";s:3:"ユ";s:3:"㋵";s:3:"ヨ";s:3:"㋶";s:3:"ラ";s:3:"ã‹·";s:3:"リ";s:3:"㋸";s:3:"ル";s:3:"㋹";s:3:"レ";s:3:"㋺";s:3:"ロ";s:3:"ã‹»";s:3:"ワ";s:3:"㋼";s:3:"ヰ";s:3:"㋽";s:3:"ヱ";s:3:"㋾";s:3:"ヲ";s:3:"㌀";s:15:"ã‚¢ãƒã‚šãƒ¼ãƒˆ";s:3:"ãŒ";s:12:"アルファ";s:3:"㌂";s:15:"アンペア";s:3:"㌃";s:9:"アール";s:3:"㌄";s:15:"イニング";s:3:"㌅";s:9:"インãƒ";s:3:"㌆";s:9:"ウォン";s:3:"㌇";s:18:"エスクード";s:3:"㌈";s:12:"エーカー";s:3:"㌉";s:9:"オンス";s:3:"㌊";s:9:"オーム";s:3:"㌋";s:9:"カイリ";s:3:"㌌";s:12:"カラット";s:3:"ãŒ";s:12:"カロリー";s:3:"㌎";s:12:"ガロン";s:3:"ãŒ";s:12:"ガンマ";s:3:"ãŒ";s:12:"ギガ";s:3:"㌑";s:12:"ギニー";s:3:"㌒";s:12:"キュリー";s:3:"㌓";s:18:"ギルダー";s:3:"㌔";s:6:"キロ";s:3:"㌕";s:18:"キログラム";s:3:"㌖";s:18:"キロメートル";s:3:"㌗";s:15:"キロワット";s:3:"㌘";s:12:"グラム";s:3:"㌙";s:18:"グラムトン";s:3:"㌚";s:18:"クルゼイロ";s:3:"㌛";s:12:"クローãƒ";s:3:"㌜";s:9:"ケース";s:3:"ãŒ";s:9:"コルナ";s:3:"㌞";s:12:"コーポ";s:3:"㌟";s:12:"サイクル";s:3:"㌠";s:15:"サンãƒãƒ¼ãƒ ";s:3:"㌡";s:15:"シリング";s:3:"㌢";s:9:"センãƒ";s:3:"㌣";s:9:"セント";s:3:"㌤";s:12:"ダース";s:3:"㌥";s:9:"デシ";s:3:"㌦";s:9:"ドル";s:3:"㌧";s:6:"トン";s:3:"㌨";s:6:"ナノ";s:3:"㌩";s:9:"ノット";s:3:"㌪";s:9:"ãƒã‚¤ãƒ„";s:3:"㌫";s:18:"ãƒã‚šãƒ¼ã‚»ãƒ³ãƒˆ";s:3:"㌬";s:12:"ãƒã‚šãƒ¼ãƒ„";s:3:"㌭";s:15:"ãƒã‚™ãƒ¼ãƒ¬ãƒ«";s:3:"㌮";s:18:"ピアストル";s:3:"㌯";s:12:"ピクル";s:3:"㌰";s:9:"ピコ";s:3:"㌱";s:9:"ビル";s:3:"㌲";s:18:"ファラッド";s:3:"㌳";s:12:"フィート";s:3:"㌴";s:18:"ブッシェル";s:3:"㌵";s:9:"フラン";s:3:"㌶";s:15:"ヘクタール";s:3:"㌷";s:9:"ペソ";s:3:"㌸";s:12:"ペニヒ";s:3:"㌹";s:9:"ヘルツ";s:3:"㌺";s:12:"ペンス";s:3:"㌻";s:15:"ページ";s:3:"㌼";s:12:"ベータ";s:3:"㌽";s:15:"ポイント";s:3:"㌾";s:12:"ボルト";s:3:"㌿";s:6:"ホン";s:3:"ã€";s:15:"ポンド";s:3:"ã";s:9:"ホール";s:3:"ã‚";s:9:"ホーン";s:3:"ãƒ";s:12:"マイクロ";s:3:"ã„";s:9:"マイル";s:3:"ã…";s:9:"マッãƒ";s:3:"ã†";s:9:"マルク";s:3:"ã‡";s:15:"マンション";s:3:"ãˆ";s:12:"ミクロン";s:3:"ã‰";s:6:"ミリ";s:3:"ãŠ";s:18:"ミリãƒã‚™ãƒ¼ãƒ«";s:3:"ã‹";s:9:"メガ";s:3:"ãŒ";s:15:"メガトン";s:3:"ã";s:12:"メートル";s:3:"ãŽ";s:12:"ヤード";s:3:"ã";s:9:"ヤール";s:3:"ã";s:9:"ユアン";s:3:"ã‘";s:12:"リットル";s:3:"ã’";s:6:"リラ";s:3:"ã“";s:12:"ルピー";s:3:"ã”";s:15:"ルーブル";s:3:"ã•";s:6:"レム";s:3:"ã–";s:18:"レントゲン";s:3:"ã—";s:9:"ワット";s:3:"ã˜";s:4:"0点";s:3:"ã™";s:4:"1点";s:3:"ãš";s:4:"2点";s:3:"ã›";s:4:"3点";s:3:"ãœ";s:4:"4点";s:3:"ã";s:4:"5点";s:3:"ãž";s:4:"6点";s:3:"ãŸ";s:4:"7点";s:3:"ã ";s:4:"8点";s:3:"ã¡";s:4:"9点";s:3:"ã¢";s:5:"10点";s:3:"ã£";s:5:"11点";s:3:"ã¤";s:5:"12点";s:3:"ã¥";s:5:"13点";s:3:"ã¦";s:5:"14点";s:3:"ã§";s:5:"15点";s:3:"ã¨";s:5:"16点";s:3:"ã©";s:5:"17点";s:3:"ãª";s:5:"18点";s:3:"ã«";s:5:"19点";s:3:"ã¬";s:5:"20点";s:3:"ã­";s:5:"21点";s:3:"ã®";s:5:"22点";s:3:"ã¯";s:5:"23点";s:3:"ã°";s:5:"24点";s:3:"ã±";s:3:"hPa";s:3:"ã²";s:2:"da";s:3:"ã³";s:2:"AU";s:3:"ã´";s:3:"bar";s:3:"ãµ";s:2:"oV";s:3:"ã¶";s:2:"pc";s:3:"ã·";s:2:"dm";s:3:"ã¸";s:3:"dm2";s:3:"ã¹";s:3:"dm3";s:3:"ãº";s:2:"IU";s:3:"ã»";s:6:"å¹³æˆ";s:3:"ã¼";s:6:"昭和";s:3:"ã½";s:6:"大正";s:3:"ã¾";s:6:"明治";s:3:"ã¿";s:12:"æ ªå¼ä¼šç¤¾";s:3:"㎀";s:2:"pA";s:3:"ãŽ";s:2:"nA";s:3:"㎂";s:3:"μA";s:3:"㎃";s:2:"mA";s:3:"㎄";s:2:"kA";s:3:"㎅";s:2:"KB";s:3:"㎆";s:2:"MB";s:3:"㎇";s:2:"GB";s:3:"㎈";s:3:"cal";s:3:"㎉";s:4:"kcal";s:3:"㎊";s:2:"pF";s:3:"㎋";s:2:"nF";s:3:"㎌";s:3:"μF";s:3:"ãŽ";s:3:"μg";s:3:"㎎";s:2:"mg";s:3:"ãŽ";s:2:"kg";s:3:"ãŽ";s:2:"Hz";s:3:"㎑";s:3:"kHz";s:3:"㎒";s:3:"MHz";s:3:"㎓";s:3:"GHz";s:3:"㎔";s:3:"THz";s:3:"㎕";s:3:"μl";s:3:"㎖";s:2:"ml";s:3:"㎗";s:2:"dl";s:3:"㎘";s:2:"kl";s:3:"㎙";s:2:"fm";s:3:"㎚";s:2:"nm";s:3:"㎛";s:3:"μm";s:3:"㎜";s:2:"mm";s:3:"ãŽ";s:2:"cm";s:3:"㎞";s:2:"km";s:3:"㎟";s:3:"mm2";s:3:"㎠";s:3:"cm2";s:3:"㎡";s:2:"m2";s:3:"㎢";s:3:"km2";s:3:"㎣";s:3:"mm3";s:3:"㎤";s:3:"cm3";s:3:"㎥";s:2:"m3";s:3:"㎦";s:3:"km3";s:3:"㎧";s:5:"m∕s";s:3:"㎨";s:6:"m∕s2";s:3:"㎩";s:2:"Pa";s:3:"㎪";s:3:"kPa";s:3:"㎫";s:3:"MPa";s:3:"㎬";s:3:"GPa";s:3:"㎭";s:3:"rad";s:3:"㎮";s:7:"rad∕s";s:3:"㎯";s:8:"rad∕s2";s:3:"㎰";s:2:"ps";s:3:"㎱";s:2:"ns";s:3:"㎲";s:3:"μs";s:3:"㎳";s:2:"ms";s:3:"㎴";s:2:"pV";s:3:"㎵";s:2:"nV";s:3:"㎶";s:3:"μV";s:3:"㎷";s:2:"mV";s:3:"㎸";s:2:"kV";s:3:"㎹";s:2:"MV";s:3:"㎺";s:2:"pW";s:3:"㎻";s:2:"nW";s:3:"㎼";s:3:"μW";s:3:"㎽";s:2:"mW";s:3:"㎾";s:2:"kW";s:3:"㎿";s:2:"MW";s:3:"ã€";s:3:"kΩ";s:3:"ã";s:3:"MΩ";s:3:"ã‚";s:4:"a.m.";s:3:"ãƒ";s:2:"Bq";s:3:"ã„";s:2:"cc";s:3:"ã…";s:2:"cd";s:3:"ã†";s:6:"C∕kg";s:3:"ã‡";s:3:"Co.";s:3:"ãˆ";s:2:"dB";s:3:"ã‰";s:2:"Gy";s:3:"ãŠ";s:2:"ha";s:3:"ã‹";s:2:"HP";s:3:"ãŒ";s:2:"in";s:3:"ã";s:2:"KK";s:3:"ãŽ";s:2:"KM";s:3:"ã";s:2:"kt";s:3:"ã";s:2:"lm";s:3:"ã‘";s:2:"ln";s:3:"ã’";s:3:"log";s:3:"ã“";s:2:"lx";s:3:"ã”";s:2:"mb";s:3:"ã•";s:3:"mil";s:3:"ã–";s:3:"mol";s:3:"ã—";s:2:"PH";s:3:"ã˜";s:4:"p.m.";s:3:"ã™";s:3:"PPM";s:3:"ãš";s:2:"PR";s:3:"ã›";s:2:"sr";s:3:"ãœ";s:2:"Sv";s:3:"ã";s:2:"Wb";s:3:"ãž";s:5:"V∕m";s:3:"ãŸ";s:5:"A∕m";s:3:"ã ";s:4:"1æ—¥";s:3:"ã¡";s:4:"2æ—¥";s:3:"ã¢";s:4:"3æ—¥";s:3:"ã£";s:4:"4æ—¥";s:3:"ã¤";s:4:"5æ—¥";s:3:"ã¥";s:4:"6æ—¥";s:3:"ã¦";s:4:"7æ—¥";s:3:"ã§";s:4:"8æ—¥";s:3:"ã¨";s:4:"9æ—¥";s:3:"ã©";s:5:"10æ—¥";s:3:"ãª";s:5:"11æ—¥";s:3:"ã«";s:5:"12æ—¥";s:3:"ã¬";s:5:"13æ—¥";s:3:"ã­";s:5:"14æ—¥";s:3:"ã®";s:5:"15æ—¥";s:3:"ã¯";s:5:"16æ—¥";s:3:"ã°";s:5:"17æ—¥";s:3:"ã±";s:5:"18æ—¥";s:3:"ã²";s:5:"19æ—¥";s:3:"ã³";s:5:"20æ—¥";s:3:"ã´";s:5:"21æ—¥";s:3:"ãµ";s:5:"22æ—¥";s:3:"ã¶";s:5:"23æ—¥";s:3:"ã·";s:5:"24æ—¥";s:3:"ã¸";s:5:"25æ—¥";s:3:"ã¹";s:5:"26æ—¥";s:3:"ãº";s:5:"27æ—¥";s:3:"ã»";s:5:"28æ—¥";s:3:"ã¼";s:5:"29æ—¥";s:3:"ã½";s:5:"30æ—¥";s:3:"ã¾";s:5:"31æ—¥";s:3:"ã¿";s:3:"gal";s:3:"ê°";s:3:"ê¯";s:3:"ꟸ";s:2:"Ħ";s:3:"ꟹ";s:2:"Å“";s:3:"ff";s:2:"ff";s:3:"ï¬";s:2:"fi";s:3:"fl";s:2:"fl";s:3:"ffi";s:3:"ffi";s:3:"ffl";s:3:"ffl";s:3:"ſt";s:2:"st";s:3:"st";s:2:"st";s:3:"ﬓ";s:4:"Õ´Õ¶";s:3:"ﬔ";s:4:"Õ´Õ¥";s:3:"ﬕ";s:4:"Õ´Õ«";s:3:"ﬖ";s:4:"Õ¾Õ¶";s:3:"ﬗ";s:4:"Õ´Õ­";s:3:"ﬠ";s:2:"×¢";s:3:"ﬡ";s:2:"×";s:3:"ﬢ";s:2:"ד";s:3:"ﬣ";s:2:"×”";s:3:"ﬤ";s:2:"×›";s:3:"ﬥ";s:2:"ל";s:3:"ﬦ";s:2:"×";s:3:"ﬧ";s:2:"ר";s:3:"ﬨ";s:2:"ת";s:3:"﬩";s:1:"+";s:3:"ï­";s:4:"×ל";s:3:"ï­";s:2:"Ù±";s:3:"ï­‘";s:2:"Ù±";s:3:"ï­’";s:2:"Ù»";s:3:"ï­“";s:2:"Ù»";s:3:"ï­”";s:2:"Ù»";s:3:"ï­•";s:2:"Ù»";s:3:"ï­–";s:2:"Ù¾";s:3:"ï­—";s:2:"Ù¾";s:3:"ï­˜";s:2:"Ù¾";s:3:"ï­™";s:2:"Ù¾";s:3:"ï­š";s:2:"Ú€";s:3:"ï­›";s:2:"Ú€";s:3:"ï­œ";s:2:"Ú€";s:3:"ï­";s:2:"Ú€";s:3:"ï­ž";s:2:"Ùº";s:3:"ï­Ÿ";s:2:"Ùº";s:3:"ï­ ";s:2:"Ùº";s:3:"ï­¡";s:2:"Ùº";s:3:"ï­¢";s:2:"Ù¿";s:3:"ï­£";s:2:"Ù¿";s:3:"ï­¤";s:2:"Ù¿";s:3:"ï­¥";s:2:"Ù¿";s:3:"ï­¦";s:2:"Ù¹";s:3:"ï­§";s:2:"Ù¹";s:3:"ï­¨";s:2:"Ù¹";s:3:"ï­©";s:2:"Ù¹";s:3:"ï­ª";s:2:"Ú¤";s:3:"ï­«";s:2:"Ú¤";s:3:"ï­¬";s:2:"Ú¤";s:3:"ï­­";s:2:"Ú¤";s:3:"ï­®";s:2:"Ú¦";s:3:"ï­¯";s:2:"Ú¦";s:3:"ï­°";s:2:"Ú¦";s:3:"ï­±";s:2:"Ú¦";s:3:"ï­²";s:2:"Ú„";s:3:"ï­³";s:2:"Ú„";s:3:"ï­´";s:2:"Ú„";s:3:"ï­µ";s:2:"Ú„";s:3:"ï­¶";s:2:"Úƒ";s:3:"ï­·";s:2:"Úƒ";s:3:"ï­¸";s:2:"Úƒ";s:3:"ï­¹";s:2:"Úƒ";s:3:"ï­º";s:2:"Ú†";s:3:"ï­»";s:2:"Ú†";s:3:"ï­¼";s:2:"Ú†";s:3:"ï­½";s:2:"Ú†";s:3:"ï­¾";s:2:"Ú‡";s:3:"ï­¿";s:2:"Ú‡";s:3:"ﮀ";s:2:"Ú‡";s:3:"ï®";s:2:"Ú‡";s:3:"ﮂ";s:2:"Ú";s:3:"ﮃ";s:2:"Ú";s:3:"ﮄ";s:2:"ÚŒ";s:3:"ï®…";s:2:"ÚŒ";s:3:"ﮆ";s:2:"ÚŽ";s:3:"ﮇ";s:2:"ÚŽ";s:3:"ﮈ";s:2:"Úˆ";s:3:"ﮉ";s:2:"Úˆ";s:3:"ﮊ";s:2:"Ú˜";s:3:"ﮋ";s:2:"Ú˜";s:3:"ﮌ";s:2:"Ú‘";s:3:"ï®";s:2:"Ú‘";s:3:"ﮎ";s:2:"Ú©";s:3:"ï®";s:2:"Ú©";s:3:"ï®";s:2:"Ú©";s:3:"ﮑ";s:2:"Ú©";s:3:"ï®’";s:2:"Ú¯";s:3:"ﮓ";s:2:"Ú¯";s:3:"ï®”";s:2:"Ú¯";s:3:"ﮕ";s:2:"Ú¯";s:3:"ï®–";s:2:"Ú³";s:3:"ï®—";s:2:"Ú³";s:3:"ﮘ";s:2:"Ú³";s:3:"ï®™";s:2:"Ú³";s:3:"ﮚ";s:2:"Ú±";s:3:"ï®›";s:2:"Ú±";s:3:"ﮜ";s:2:"Ú±";s:3:"ï®";s:2:"Ú±";s:3:"ﮞ";s:2:"Úº";s:3:"ﮟ";s:2:"Úº";s:3:"ï® ";s:2:"Ú»";s:3:"ﮡ";s:2:"Ú»";s:3:"ﮢ";s:2:"Ú»";s:3:"ﮣ";s:2:"Ú»";s:3:"ﮤ";s:4:"Û•Ù”";s:3:"ﮥ";s:4:"Û•Ù”";s:3:"ﮦ";s:2:"Û";s:3:"ﮧ";s:2:"Û";s:3:"ﮨ";s:2:"Û";s:3:"ﮩ";s:2:"Û";s:3:"ﮪ";s:2:"Ú¾";s:3:"ﮫ";s:2:"Ú¾";s:3:"ﮬ";s:2:"Ú¾";s:3:"ï®­";s:2:"Ú¾";s:3:"ï®®";s:2:"Û’";s:3:"ﮯ";s:2:"Û’";s:3:"ï®°";s:4:"Û’Ù”";s:3:"ï®±";s:4:"Û’Ù”";s:3:"ﯓ";s:2:"Ú­";s:3:"ﯔ";s:2:"Ú­";s:3:"ﯕ";s:2:"Ú­";s:3:"ﯖ";s:2:"Ú­";s:3:"ﯗ";s:2:"Û‡";s:3:"ﯘ";s:2:"Û‡";s:3:"ﯙ";s:2:"Û†";s:3:"ﯚ";s:2:"Û†";s:3:"ﯛ";s:2:"Ûˆ";s:3:"ﯜ";s:2:"Ûˆ";s:3:"ï¯";s:4:"Û‡Ù´";s:3:"ﯞ";s:2:"Û‹";s:3:"ﯟ";s:2:"Û‹";s:3:"ﯠ";s:2:"Û…";s:3:"ﯡ";s:2:"Û…";s:3:"ﯢ";s:2:"Û‰";s:3:"ﯣ";s:2:"Û‰";s:3:"ﯤ";s:2:"Û";s:3:"ﯥ";s:2:"Û";s:3:"ﯦ";s:2:"Û";s:3:"ﯧ";s:2:"Û";s:3:"ﯨ";s:2:"Ù‰";s:3:"ﯩ";s:2:"Ù‰";s:3:"ﯪ";s:6:"ئا";s:3:"ﯫ";s:6:"ئا";s:3:"ﯬ";s:6:"ÙŠÙ”Û•";s:3:"ﯭ";s:6:"ÙŠÙ”Û•";s:3:"ﯮ";s:6:"ÙŠÙ”Ùˆ";s:3:"ﯯ";s:6:"ÙŠÙ”Ùˆ";s:3:"ﯰ";s:6:"ÙŠÙ”Û‡";s:3:"ﯱ";s:6:"ÙŠÙ”Û‡";s:3:"ﯲ";s:6:"ÙŠÙ”Û†";s:3:"ﯳ";s:6:"ÙŠÙ”Û†";s:3:"ﯴ";s:6:"ÙŠÙ”Ûˆ";s:3:"ﯵ";s:6:"ÙŠÙ”Ûˆ";s:3:"ﯶ";s:6:"ÙŠÙ”Û";s:3:"ﯷ";s:6:"ÙŠÙ”Û";s:3:"ﯸ";s:6:"ÙŠÙ”Û";s:3:"ﯹ";s:6:"ÙŠÙ”Ù‰";s:3:"ﯺ";s:6:"ÙŠÙ”Ù‰";s:3:"ﯻ";s:6:"ÙŠÙ”Ù‰";s:3:"ﯼ";s:2:"ÛŒ";s:3:"ﯽ";s:2:"ÛŒ";s:3:"ﯾ";s:2:"ÛŒ";s:3:"ﯿ";s:2:"ÛŒ";s:3:"ï°€";s:6:"ئج";s:3:"ï°";s:6:"ئح";s:3:"ï°‚";s:6:"ÙŠÙ”Ù…";s:3:"ï°ƒ";s:6:"ÙŠÙ”Ù‰";s:3:"ï°„";s:6:"ÙŠÙ”ÙŠ";s:3:"ï°…";s:4:"بج";s:3:"ï°†";s:4:"بح";s:3:"ï°‡";s:4:"بخ";s:3:"ï°ˆ";s:4:"بم";s:3:"ï°‰";s:4:"بى";s:3:"ï°Š";s:4:"بي";s:3:"ï°‹";s:4:"تج";s:3:"ï°Œ";s:4:"تح";s:3:"ï°";s:4:"تخ";s:3:"ï°Ž";s:4:"تم";s:3:"ï°";s:4:"تى";s:3:"ï°";s:4:"تي";s:3:"ï°‘";s:4:"ثج";s:3:"ï°’";s:4:"ثم";s:3:"ï°“";s:4:"ثى";s:3:"ï°”";s:4:"ثي";s:3:"ï°•";s:4:"جح";s:3:"ï°–";s:4:"جم";s:3:"ï°—";s:4:"حج";s:3:"ï°˜";s:4:"حم";s:3:"ï°™";s:4:"خج";s:3:"ï°š";s:4:"خح";s:3:"ï°›";s:4:"خم";s:3:"ï°œ";s:4:"سج";s:3:"ï°";s:4:"سح";s:3:"ï°ž";s:4:"سخ";s:3:"ï°Ÿ";s:4:"سم";s:3:"ï° ";s:4:"صح";s:3:"ï°¡";s:4:"صم";s:3:"ï°¢";s:4:"ضج";s:3:"ï°£";s:4:"ضح";s:3:"ï°¤";s:4:"ضخ";s:3:"ï°¥";s:4:"ضم";s:3:"ï°¦";s:4:"طح";s:3:"ï°§";s:4:"طم";s:3:"ï°¨";s:4:"ظم";s:3:"ï°©";s:4:"عج";s:3:"ï°ª";s:4:"عم";s:3:"ï°«";s:4:"غج";s:3:"ï°¬";s:4:"غم";s:3:"ï°­";s:4:"Ùج";s:3:"ï°®";s:4:"ÙØ­";s:3:"ï°¯";s:4:"ÙØ®";s:3:"ï°°";s:4:"ÙÙ…";s:3:"ï°±";s:4:"ÙÙ‰";s:3:"ï°²";s:4:"ÙÙŠ";s:3:"ï°³";s:4:"قح";s:3:"ï°´";s:4:"قم";s:3:"ï°µ";s:4:"قى";s:3:"ï°¶";s:4:"قي";s:3:"ï°·";s:4:"كا";s:3:"ï°¸";s:4:"كج";s:3:"ï°¹";s:4:"كح";s:3:"ï°º";s:4:"كخ";s:3:"ï°»";s:4:"كل";s:3:"ï°¼";s:4:"كم";s:3:"ï°½";s:4:"كى";s:3:"ï°¾";s:4:"كي";s:3:"ï°¿";s:4:"لج";s:3:"ï±€";s:4:"لح";s:3:"ï±";s:4:"لخ";s:3:"ﱂ";s:4:"لم";s:3:"ﱃ";s:4:"لى";s:3:"ﱄ";s:4:"لي";s:3:"ï±…";s:4:"مج";s:3:"ﱆ";s:4:"مح";s:3:"ﱇ";s:4:"مخ";s:3:"ﱈ";s:4:"مم";s:3:"ﱉ";s:4:"مى";s:3:"ﱊ";s:4:"مي";s:3:"ﱋ";s:4:"نج";s:3:"ﱌ";s:4:"نح";s:3:"ï±";s:4:"نخ";s:3:"ﱎ";s:4:"نم";s:3:"ï±";s:4:"نى";s:3:"ï±";s:4:"ني";s:3:"ﱑ";s:4:"هج";s:3:"ï±’";s:4:"هم";s:3:"ﱓ";s:4:"هى";s:3:"ï±”";s:4:"هي";s:3:"ﱕ";s:4:"يج";s:3:"ï±–";s:4:"يح";s:3:"ï±—";s:4:"يخ";s:3:"ﱘ";s:4:"يم";s:3:"ï±™";s:4:"يى";s:3:"ﱚ";s:4:"يي";s:3:"ï±›";s:4:"ذٰ";s:3:"ﱜ";s:4:"رٰ";s:3:"ï±";s:4:"ىٰ";s:3:"ﱞ";s:5:" ٌّ";s:3:"ﱟ";s:5:" ÙÙ‘";s:3:"ï± ";s:5:" ÙŽÙ‘";s:3:"ﱡ";s:5:" ÙÙ‘";s:3:"ï±¢";s:5:" ÙÙ‘";s:3:"ï±£";s:5:" ّٰ";s:3:"ﱤ";s:6:"ئر";s:3:"ï±¥";s:6:"ئز";s:3:"ﱦ";s:6:"ÙŠÙ”Ù…";s:3:"ﱧ";s:6:"ÙŠÙ”Ù†";s:3:"ﱨ";s:6:"ÙŠÙ”Ù‰";s:3:"ﱩ";s:6:"ÙŠÙ”ÙŠ";s:3:"ﱪ";s:4:"بر";s:3:"ﱫ";s:4:"بز";s:3:"ﱬ";s:4:"بم";s:3:"ï±­";s:4:"بن";s:3:"ï±®";s:4:"بى";s:3:"ﱯ";s:4:"بي";s:3:"ï±°";s:4:"تر";s:3:"ï±±";s:4:"تز";s:3:"ï±²";s:4:"تم";s:3:"ï±³";s:4:"تن";s:3:"ï±´";s:4:"تى";s:3:"ï±µ";s:4:"تي";s:3:"ﱶ";s:4:"ثر";s:3:"ï±·";s:4:"ثز";s:3:"ﱸ";s:4:"ثم";s:3:"ï±¹";s:4:"ثن";s:3:"ﱺ";s:4:"ثى";s:3:"ï±»";s:4:"ثي";s:3:"ï±¼";s:4:"ÙÙ‰";s:3:"ï±½";s:4:"ÙÙŠ";s:3:"ï±¾";s:4:"قى";s:3:"ﱿ";s:4:"قي";s:3:"ï²€";s:4:"كا";s:3:"ï²";s:4:"كل";s:3:"ﲂ";s:4:"كم";s:3:"ﲃ";s:4:"كى";s:3:"ﲄ";s:4:"كي";s:3:"ï²…";s:4:"لم";s:3:"ﲆ";s:4:"لى";s:3:"ﲇ";s:4:"لي";s:3:"ﲈ";s:4:"ما";s:3:"ﲉ";s:4:"مم";s:3:"ﲊ";s:4:"نر";s:3:"ﲋ";s:4:"نز";s:3:"ﲌ";s:4:"نم";s:3:"ï²";s:4:"نن";s:3:"ﲎ";s:4:"نى";s:3:"ï²";s:4:"ني";s:3:"ï²";s:4:"ىٰ";s:3:"ﲑ";s:4:"ير";s:3:"ï²’";s:4:"يز";s:3:"ﲓ";s:4:"يم";s:3:"ï²”";s:4:"ين";s:3:"ﲕ";s:4:"يى";s:3:"ï²–";s:4:"يي";s:3:"ï²—";s:6:"ئج";s:3:"ﲘ";s:6:"ئح";s:3:"ï²™";s:6:"ئخ";s:3:"ﲚ";s:6:"ÙŠÙ”Ù…";s:3:"ï²›";s:6:"ÙŠÙ”Ù‡";s:3:"ﲜ";s:4:"بج";s:3:"ï²";s:4:"بح";s:3:"ﲞ";s:4:"بخ";s:3:"ﲟ";s:4:"بم";s:3:"ï² ";s:4:"به";s:3:"ﲡ";s:4:"تج";s:3:"ï²¢";s:4:"تح";s:3:"ï²£";s:4:"تخ";s:3:"ﲤ";s:4:"تم";s:3:"ï²¥";s:4:"ته";s:3:"ﲦ";s:4:"ثم";s:3:"ﲧ";s:4:"جح";s:3:"ﲨ";s:4:"جم";s:3:"ﲩ";s:4:"حج";s:3:"ﲪ";s:4:"حم";s:3:"ﲫ";s:4:"خج";s:3:"ﲬ";s:4:"خم";s:3:"ï²­";s:4:"سج";s:3:"ï²®";s:4:"سح";s:3:"ﲯ";s:4:"سخ";s:3:"ï²°";s:4:"سم";s:3:"ï²±";s:4:"صح";s:3:"ï²²";s:4:"صخ";s:3:"ï²³";s:4:"صم";s:3:"ï²´";s:4:"ضج";s:3:"ï²µ";s:4:"ضح";s:3:"ﲶ";s:4:"ضخ";s:3:"ï²·";s:4:"ضم";s:3:"ﲸ";s:4:"طح";s:3:"ï²¹";s:4:"ظم";s:3:"ﲺ";s:4:"عج";s:3:"ï²»";s:4:"عم";s:3:"ï²¼";s:4:"غج";s:3:"ï²½";s:4:"غم";s:3:"ï²¾";s:4:"Ùج";s:3:"ﲿ";s:4:"ÙØ­";s:3:"ï³€";s:4:"ÙØ®";s:3:"ï³";s:4:"ÙÙ…";s:3:"ﳂ";s:4:"قح";s:3:"ﳃ";s:4:"قم";s:3:"ﳄ";s:4:"كج";s:3:"ï³…";s:4:"كح";s:3:"ﳆ";s:4:"كخ";s:3:"ﳇ";s:4:"كل";s:3:"ﳈ";s:4:"كم";s:3:"ﳉ";s:4:"لج";s:3:"ﳊ";s:4:"لح";s:3:"ﳋ";s:4:"لخ";s:3:"ﳌ";s:4:"لم";s:3:"ï³";s:4:"له";s:3:"ﳎ";s:4:"مج";s:3:"ï³";s:4:"مح";s:3:"ï³";s:4:"مخ";s:3:"ﳑ";s:4:"مم";s:3:"ï³’";s:4:"نج";s:3:"ﳓ";s:4:"نح";s:3:"ï³”";s:4:"نخ";s:3:"ﳕ";s:4:"نم";s:3:"ï³–";s:4:"نه";s:3:"ï³—";s:4:"هج";s:3:"ﳘ";s:4:"هم";s:3:"ï³™";s:4:"هٰ";s:3:"ﳚ";s:4:"يج";s:3:"ï³›";s:4:"يح";s:3:"ﳜ";s:4:"يخ";s:3:"ï³";s:4:"يم";s:3:"ﳞ";s:4:"يه";s:3:"ﳟ";s:6:"ÙŠÙ”Ù…";s:3:"ï³ ";s:6:"ÙŠÙ”Ù‡";s:3:"ﳡ";s:4:"بم";s:3:"ï³¢";s:4:"به";s:3:"ï³£";s:4:"تم";s:3:"ﳤ";s:4:"ته";s:3:"ï³¥";s:4:"ثم";s:3:"ﳦ";s:4:"ثه";s:3:"ﳧ";s:4:"سم";s:3:"ﳨ";s:4:"سه";s:3:"ﳩ";s:4:"شم";s:3:"ﳪ";s:4:"شه";s:3:"ﳫ";s:4:"كل";s:3:"ﳬ";s:4:"كم";s:3:"ï³­";s:4:"لم";s:3:"ï³®";s:4:"نم";s:3:"ﳯ";s:4:"نه";s:3:"ï³°";s:4:"يم";s:3:"ï³±";s:4:"يه";s:3:"ï³²";s:6:"Ù€ÙŽÙ‘";s:3:"ï³³";s:6:"Ù€ÙÙ‘";s:3:"ï³´";s:6:"Ù€ÙÙ‘";s:3:"ï³µ";s:4:"طى";s:3:"ﳶ";s:4:"طي";s:3:"ï³·";s:4:"عى";s:3:"ﳸ";s:4:"عي";s:3:"ï³¹";s:4:"غى";s:3:"ﳺ";s:4:"غي";s:3:"ï³»";s:4:"سى";s:3:"ï³¼";s:4:"سي";s:3:"ï³½";s:4:"شى";s:3:"ï³¾";s:4:"شي";s:3:"ﳿ";s:4:"حى";s:3:"ï´€";s:4:"حي";s:3:"ï´";s:4:"جى";s:3:"ï´‚";s:4:"جي";s:3:"ï´ƒ";s:4:"خى";s:3:"ï´„";s:4:"خي";s:3:"ï´…";s:4:"صى";s:3:"ï´†";s:4:"صي";s:3:"ï´‡";s:4:"ضى";s:3:"ï´ˆ";s:4:"ضي";s:3:"ï´‰";s:4:"شج";s:3:"ï´Š";s:4:"شح";s:3:"ï´‹";s:4:"شخ";s:3:"ï´Œ";s:4:"شم";s:3:"ï´";s:4:"شر";s:3:"ï´Ž";s:4:"سر";s:3:"ï´";s:4:"صر";s:3:"ï´";s:4:"ضر";s:3:"ï´‘";s:4:"طى";s:3:"ï´’";s:4:"طي";s:3:"ï´“";s:4:"عى";s:3:"ï´”";s:4:"عي";s:3:"ï´•";s:4:"غى";s:3:"ï´–";s:4:"غي";s:3:"ï´—";s:4:"سى";s:3:"ï´˜";s:4:"سي";s:3:"ï´™";s:4:"شى";s:3:"ï´š";s:4:"شي";s:3:"ï´›";s:4:"حى";s:3:"ï´œ";s:4:"حي";s:3:"ï´";s:4:"جى";s:3:"ï´ž";s:4:"جي";s:3:"ï´Ÿ";s:4:"خى";s:3:"ï´ ";s:4:"خي";s:3:"ï´¡";s:4:"صى";s:3:"ï´¢";s:4:"صي";s:3:"ï´£";s:4:"ضى";s:3:"ï´¤";s:4:"ضي";s:3:"ï´¥";s:4:"شج";s:3:"ï´¦";s:4:"شح";s:3:"ï´§";s:4:"شخ";s:3:"ï´¨";s:4:"شم";s:3:"ï´©";s:4:"شر";s:3:"ï´ª";s:4:"سر";s:3:"ï´«";s:4:"صر";s:3:"ï´¬";s:4:"ضر";s:3:"ï´­";s:4:"شج";s:3:"ï´®";s:4:"شح";s:3:"ï´¯";s:4:"شخ";s:3:"ï´°";s:4:"شم";s:3:"ï´±";s:4:"سه";s:3:"ï´²";s:4:"شه";s:3:"ï´³";s:4:"طم";s:3:"ï´´";s:4:"سج";s:3:"ï´µ";s:4:"سح";s:3:"ï´¶";s:4:"سخ";s:3:"ï´·";s:4:"شج";s:3:"ï´¸";s:4:"شح";s:3:"ï´¹";s:4:"شخ";s:3:"ï´º";s:4:"طم";s:3:"ï´»";s:4:"ظم";s:3:"ï´¼";s:4:"اً";s:3:"ï´½";s:4:"اً";s:3:"ïµ";s:6:"تجم";s:3:"ﵑ";s:6:"تحج";s:3:"ïµ’";s:6:"تحج";s:3:"ﵓ";s:6:"تحم";s:3:"ïµ”";s:6:"تخم";s:3:"ﵕ";s:6:"تمج";s:3:"ïµ–";s:6:"تمح";s:3:"ïµ—";s:6:"تمخ";s:3:"ﵘ";s:6:"جمح";s:3:"ïµ™";s:6:"جمح";s:3:"ﵚ";s:6:"حمي";s:3:"ïµ›";s:6:"حمى";s:3:"ﵜ";s:6:"سحج";s:3:"ïµ";s:6:"سجح";s:3:"ﵞ";s:6:"سجى";s:3:"ﵟ";s:6:"سمح";s:3:"ïµ ";s:6:"سمح";s:3:"ﵡ";s:6:"سمج";s:3:"ïµ¢";s:6:"سمم";s:3:"ïµ£";s:6:"سمم";s:3:"ﵤ";s:6:"صحح";s:3:"ïµ¥";s:6:"صحح";s:3:"ﵦ";s:6:"صمم";s:3:"ﵧ";s:6:"شحم";s:3:"ﵨ";s:6:"شحم";s:3:"ﵩ";s:6:"شجي";s:3:"ﵪ";s:6:"شمخ";s:3:"ﵫ";s:6:"شمخ";s:3:"ﵬ";s:6:"شمم";s:3:"ïµ­";s:6:"شمم";s:3:"ïµ®";s:6:"ضحى";s:3:"ﵯ";s:6:"ضخم";s:3:"ïµ°";s:6:"ضخم";s:3:"ïµ±";s:6:"طمح";s:3:"ïµ²";s:6:"طمح";s:3:"ïµ³";s:6:"طمم";s:3:"ïµ´";s:6:"طمي";s:3:"ïµµ";s:6:"عجم";s:3:"ﵶ";s:6:"عمم";s:3:"ïµ·";s:6:"عمم";s:3:"ﵸ";s:6:"عمى";s:3:"ïµ¹";s:6:"غمم";s:3:"ﵺ";s:6:"غمي";s:3:"ïµ»";s:6:"غمى";s:3:"ïµ¼";s:6:"Ùخم";s:3:"ïµ½";s:6:"Ùخم";s:3:"ïµ¾";s:6:"قمح";s:3:"ﵿ";s:6:"قمم";s:3:"ﶀ";s:6:"لحم";s:3:"ï¶";s:6:"لحي";s:3:"ﶂ";s:6:"لحى";s:3:"ﶃ";s:6:"لجج";s:3:"ﶄ";s:6:"لجج";s:3:"ﶅ";s:6:"لخم";s:3:"ﶆ";s:6:"لخم";s:3:"ﶇ";s:6:"لمح";s:3:"ﶈ";s:6:"لمح";s:3:"ﶉ";s:6:"محج";s:3:"ﶊ";s:6:"محم";s:3:"ﶋ";s:6:"محي";s:3:"ﶌ";s:6:"مجح";s:3:"ï¶";s:6:"مجم";s:3:"ﶎ";s:6:"مخج";s:3:"ï¶";s:6:"مخم";s:3:"ﶒ";s:6:"مجخ";s:3:"ﶓ";s:6:"همج";s:3:"ﶔ";s:6:"همم";s:3:"ﶕ";s:6:"نحم";s:3:"ﶖ";s:6:"نحى";s:3:"ﶗ";s:6:"نجم";s:3:"ﶘ";s:6:"نجم";s:3:"ﶙ";s:6:"نجى";s:3:"ﶚ";s:6:"نمي";s:3:"ﶛ";s:6:"نمى";s:3:"ﶜ";s:6:"يمم";s:3:"ï¶";s:6:"يمم";s:3:"ﶞ";s:6:"بخي";s:3:"ﶟ";s:6:"تجي";s:3:"ﶠ";s:6:"تجى";s:3:"ﶡ";s:6:"تخي";s:3:"ﶢ";s:6:"تخى";s:3:"ﶣ";s:6:"تمي";s:3:"ﶤ";s:6:"تمى";s:3:"ﶥ";s:6:"جمي";s:3:"ﶦ";s:6:"جحى";s:3:"ﶧ";s:6:"جمى";s:3:"ﶨ";s:6:"سخى";s:3:"ﶩ";s:6:"صحي";s:3:"ﶪ";s:6:"شحي";s:3:"ﶫ";s:6:"ضحي";s:3:"ﶬ";s:6:"لجي";s:3:"ﶭ";s:6:"لمي";s:3:"ﶮ";s:6:"يحي";s:3:"ﶯ";s:6:"يجي";s:3:"ﶰ";s:6:"يمي";s:3:"ﶱ";s:6:"ممي";s:3:"ﶲ";s:6:"قمي";s:3:"ﶳ";s:6:"نحي";s:3:"ﶴ";s:6:"قمح";s:3:"ﶵ";s:6:"لحم";s:3:"ﶶ";s:6:"عمي";s:3:"ﶷ";s:6:"كمي";s:3:"ﶸ";s:6:"نجح";s:3:"ﶹ";s:6:"مخي";s:3:"ﶺ";s:6:"لجم";s:3:"ﶻ";s:6:"كمم";s:3:"ﶼ";s:6:"لجم";s:3:"ﶽ";s:6:"نجح";s:3:"ﶾ";s:6:"جحي";s:3:"ﶿ";s:6:"حجي";s:3:"ï·€";s:6:"مجي";s:3:"ï·";s:6:"Ùمي";s:3:"ï·‚";s:6:"بحي";s:3:"ï·ƒ";s:6:"كمم";s:3:"ï·„";s:6:"عجم";s:3:"ï·…";s:6:"صمم";s:3:"ï·†";s:6:"سخي";s:3:"ï·‡";s:6:"نجي";s:3:"ï·°";s:6:"صلے";s:3:"ï·±";s:6:"قلے";s:3:"ï·²";s:8:"الله";s:3:"ï·³";s:8:"اكبر";s:3:"ï·´";s:8:"محمد";s:3:"ï·µ";s:8:"صلعم";s:3:"ï·¶";s:8:"رسول";s:3:"ï··";s:8:"عليه";s:3:"ï·¸";s:8:"وسلم";s:3:"ï·¹";s:6:"صلى";s:3:"ï·º";s:33:"صلى الله عليه وسلم";s:3:"ï·»";s:15:"جل جلاله";s:3:"ï·¼";s:8:"ریال";s:3:"ï¸";s:1:",";s:3:"︑";s:3:"ã€";s:3:"︒";s:3:"。";s:3:"︓";s:1:":";s:3:"︔";s:1:";";s:3:"︕";s:1:"!";s:3:"︖";s:1:"?";s:3:"︗";s:3:"〖";s:3:"︘";s:3:"〗";s:3:"︙";s:3:"...";s:3:"︰";s:2:"..";s:3:"︱";s:3:"—";s:3:"︲";s:3:"–";s:3:"︳";s:1:"_";s:3:"︴";s:1:"_";s:3:"︵";s:1:"(";s:3:"︶";s:1:")";s:3:"︷";s:1:"{";s:3:"︸";s:1:"}";s:3:"︹";s:3:"〔";s:3:"︺";s:3:"〕";s:3:"︻";s:3:"ã€";s:3:"︼";s:3:"】";s:3:"︽";s:3:"《";s:3:"︾";s:3:"》";s:3:"︿";s:3:"〈";s:3:"ï¹€";s:3:"〉";s:3:"ï¹";s:3:"「";s:3:"﹂";s:3:"ã€";s:3:"﹃";s:3:"『";s:3:"﹄";s:3:"ã€";s:3:"﹇";s:1:"[";s:3:"﹈";s:1:"]";s:3:"﹉";s:3:" Ì…";s:3:"﹊";s:3:" Ì…";s:3:"﹋";s:3:" Ì…";s:3:"﹌";s:3:" Ì…";s:3:"ï¹";s:1:"_";s:3:"﹎";s:1:"_";s:3:"ï¹";s:1:"_";s:3:"ï¹";s:1:",";s:3:"﹑";s:3:"ã€";s:3:"ï¹’";s:1:".";s:3:"ï¹”";s:1:";";s:3:"﹕";s:1:":";s:3:"ï¹–";s:1:"?";s:3:"ï¹—";s:1:"!";s:3:"﹘";s:3:"—";s:3:"ï¹™";s:1:"(";s:3:"﹚";s:1:")";s:3:"ï¹›";s:1:"{";s:3:"﹜";s:1:"}";s:3:"ï¹";s:3:"〔";s:3:"﹞";s:3:"〕";s:3:"﹟";s:1:"#";s:3:"ï¹ ";s:1:"&";s:3:"﹡";s:1:"*";s:3:"ï¹¢";s:1:"+";s:3:"ï¹£";s:1:"-";s:3:"﹤";s:1:"<";s:3:"ï¹¥";s:1:">";s:3:"﹦";s:1:"=";s:3:"﹨";s:1:"\";s:3:"﹩";s:1:"$";s:3:"﹪";s:1:"%";s:3:"﹫";s:1:"@";s:3:"ï¹°";s:3:" Ù‹";s:3:"ï¹±";s:4:"ـً";s:3:"ï¹²";s:3:" ÙŒ";s:3:"ï¹´";s:3:" Ù";s:3:"ﹶ";s:3:" ÙŽ";s:3:"ï¹·";s:4:"Ù€ÙŽ";s:3:"ﹸ";s:3:" Ù";s:3:"ï¹¹";s:4:"Ù€Ù";s:3:"ﹺ";s:3:" Ù";s:3:"ï¹»";s:4:"Ù€Ù";s:3:"ï¹¼";s:3:" Ù‘";s:3:"ï¹½";s:4:"ـّ";s:3:"ï¹¾";s:3:" Ù’";s:3:"ﹿ";s:4:"ـْ";s:3:"ﺀ";s:2:"Ø¡";s:3:"ïº";s:4:"آ";s:3:"ﺂ";s:4:"آ";s:3:"ﺃ";s:4:"أ";s:3:"ﺄ";s:4:"أ";s:3:"ﺅ";s:4:"ÙˆÙ”";s:3:"ﺆ";s:4:"ÙˆÙ”";s:3:"ﺇ";s:4:"إ";s:3:"ﺈ";s:4:"إ";s:3:"ﺉ";s:4:"ÙŠÙ”";s:3:"ﺊ";s:4:"ÙŠÙ”";s:3:"ﺋ";s:4:"ÙŠÙ”";s:3:"ﺌ";s:4:"ÙŠÙ”";s:3:"ïº";s:2:"ا";s:3:"ﺎ";s:2:"ا";s:3:"ïº";s:2:"ب";s:3:"ïº";s:2:"ب";s:3:"ﺑ";s:2:"ب";s:3:"ﺒ";s:2:"ب";s:3:"ﺓ";s:2:"Ø©";s:3:"ﺔ";s:2:"Ø©";s:3:"ﺕ";s:2:"ت";s:3:"ﺖ";s:2:"ت";s:3:"ﺗ";s:2:"ت";s:3:"ﺘ";s:2:"ت";s:3:"ﺙ";s:2:"Ø«";s:3:"ﺚ";s:2:"Ø«";s:3:"ﺛ";s:2:"Ø«";s:3:"ﺜ";s:2:"Ø«";s:3:"ïº";s:2:"ج";s:3:"ﺞ";s:2:"ج";s:3:"ﺟ";s:2:"ج";s:3:"ﺠ";s:2:"ج";s:3:"ﺡ";s:2:"Ø­";s:3:"ﺢ";s:2:"Ø­";s:3:"ﺣ";s:2:"Ø­";s:3:"ﺤ";s:2:"Ø­";s:3:"ﺥ";s:2:"Ø®";s:3:"ﺦ";s:2:"Ø®";s:3:"ﺧ";s:2:"Ø®";s:3:"ﺨ";s:2:"Ø®";s:3:"ﺩ";s:2:"د";s:3:"ﺪ";s:2:"د";s:3:"ﺫ";s:2:"Ø°";s:3:"ﺬ";s:2:"Ø°";s:3:"ﺭ";s:2:"ر";s:3:"ﺮ";s:2:"ر";s:3:"ﺯ";s:2:"ز";s:3:"ﺰ";s:2:"ز";s:3:"ﺱ";s:2:"س";s:3:"ﺲ";s:2:"س";s:3:"ﺳ";s:2:"س";s:3:"ﺴ";s:2:"س";s:3:"ﺵ";s:2:"Ø´";s:3:"ﺶ";s:2:"Ø´";s:3:"ﺷ";s:2:"Ø´";s:3:"ﺸ";s:2:"Ø´";s:3:"ﺹ";s:2:"ص";s:3:"ﺺ";s:2:"ص";s:3:"ﺻ";s:2:"ص";s:3:"ﺼ";s:2:"ص";s:3:"ﺽ";s:2:"ض";s:3:"ﺾ";s:2:"ض";s:3:"ﺿ";s:2:"ض";s:3:"ﻀ";s:2:"ض";s:3:"ï»";s:2:"Ø·";s:3:"ﻂ";s:2:"Ø·";s:3:"ﻃ";s:2:"Ø·";s:3:"ﻄ";s:2:"Ø·";s:3:"ï»…";s:2:"ظ";s:3:"ﻆ";s:2:"ظ";s:3:"ﻇ";s:2:"ظ";s:3:"ﻈ";s:2:"ظ";s:3:"ﻉ";s:2:"ع";s:3:"ﻊ";s:2:"ع";s:3:"ﻋ";s:2:"ع";s:3:"ﻌ";s:2:"ع";s:3:"ï»";s:2:"غ";s:3:"ﻎ";s:2:"غ";s:3:"ï»";s:2:"غ";s:3:"ï»";s:2:"غ";s:3:"ﻑ";s:2:"Ù";s:3:"ï»’";s:2:"Ù";s:3:"ﻓ";s:2:"Ù";s:3:"ï»”";s:2:"Ù";s:3:"ﻕ";s:2:"Ù‚";s:3:"ï»–";s:2:"Ù‚";s:3:"ï»—";s:2:"Ù‚";s:3:"ﻘ";s:2:"Ù‚";s:3:"ï»™";s:2:"Ùƒ";s:3:"ﻚ";s:2:"Ùƒ";s:3:"ï»›";s:2:"Ùƒ";s:3:"ﻜ";s:2:"Ùƒ";s:3:"ï»";s:2:"Ù„";s:3:"ﻞ";s:2:"Ù„";s:3:"ﻟ";s:2:"Ù„";s:3:"ï» ";s:2:"Ù„";s:3:"ﻡ";s:2:"Ù…";s:3:"ﻢ";s:2:"Ù…";s:3:"ﻣ";s:2:"Ù…";s:3:"ﻤ";s:2:"Ù…";s:3:"ﻥ";s:2:"Ù†";s:3:"ﻦ";s:2:"Ù†";s:3:"ﻧ";s:2:"Ù†";s:3:"ﻨ";s:2:"Ù†";s:3:"ﻩ";s:2:"Ù‡";s:3:"ﻪ";s:2:"Ù‡";s:3:"ﻫ";s:2:"Ù‡";s:3:"ﻬ";s:2:"Ù‡";s:3:"ï»­";s:2:"Ùˆ";s:3:"ï»®";s:2:"Ùˆ";s:3:"ﻯ";s:2:"Ù‰";s:3:"ï»°";s:2:"Ù‰";s:3:"ï»±";s:2:"ÙŠ";s:3:"ﻲ";s:2:"ÙŠ";s:3:"ﻳ";s:2:"ÙŠ";s:3:"ï»´";s:2:"ÙŠ";s:3:"ﻵ";s:6:"لآ";s:3:"ﻶ";s:6:"لآ";s:3:"ï»·";s:6:"لأ";s:3:"ﻸ";s:6:"لأ";s:3:"ﻹ";s:6:"لإ";s:3:"ﻺ";s:6:"لإ";s:3:"ï»»";s:4:"لا";s:3:"ﻼ";s:4:"لا";s:3:"ï¼";s:1:"!";s:3:""";s:1:""";s:3:"#";s:1:"#";s:3:"$";s:1:"$";s:3:"ï¼…";s:1:"%";s:3:"&";s:1:"&";s:3:"'";s:1:"'";s:3:"(";s:1:"(";s:3:")";s:1:")";s:3:"*";s:1:"*";s:3:"+";s:1:"+";s:3:",";s:1:",";s:3:"ï¼";s:1:"-";s:3:".";s:1:".";s:3:"ï¼";s:1:"/";s:3:"ï¼";s:1:"0";s:3:"1";s:1:"1";s:3:"ï¼’";s:1:"2";s:3:"3";s:1:"3";s:3:"ï¼”";s:1:"4";s:3:"5";s:1:"5";s:3:"ï¼–";s:1:"6";s:3:"ï¼—";s:1:"7";s:3:"8";s:1:"8";s:3:"ï¼™";s:1:"9";s:3:":";s:1:":";s:3:"ï¼›";s:1:";";s:3:"<";s:1:"<";s:3:"ï¼";s:1:"=";s:3:">";s:1:">";s:3:"?";s:1:"?";s:3:"ï¼ ";s:1:"@";s:3:"A";s:1:"A";s:3:"ï¼¢";s:1:"B";s:3:"ï¼£";s:1:"C";s:3:"D";s:1:"D";s:3:"ï¼¥";s:1:"E";s:3:"F";s:1:"F";s:3:"G";s:1:"G";s:3:"H";s:1:"H";s:3:"I";s:1:"I";s:3:"J";s:1:"J";s:3:"K";s:1:"K";s:3:"L";s:1:"L";s:3:"ï¼­";s:1:"M";s:3:"ï¼®";s:1:"N";s:3:"O";s:1:"O";s:3:"ï¼°";s:1:"P";s:3:"ï¼±";s:1:"Q";s:3:"ï¼²";s:1:"R";s:3:"ï¼³";s:1:"S";s:3:"ï¼´";s:1:"T";s:3:"ï¼µ";s:1:"U";s:3:"V";s:1:"V";s:3:"ï¼·";s:1:"W";s:3:"X";s:1:"X";s:3:"ï¼¹";s:1:"Y";s:3:"Z";s:1:"Z";s:3:"ï¼»";s:1:"[";s:3:"ï¼¼";s:1:"\";s:3:"ï¼½";s:1:"]";s:3:"ï¼¾";s:1:"^";s:3:"_";s:1:"_";s:3:"ï½€";s:1:"`";s:3:"ï½";s:1:"a";s:3:"b";s:1:"b";s:3:"c";s:1:"c";s:3:"d";s:1:"d";s:3:"ï½…";s:1:"e";s:3:"f";s:1:"f";s:3:"g";s:1:"g";s:3:"h";s:1:"h";s:3:"i";s:1:"i";s:3:"j";s:1:"j";s:3:"k";s:1:"k";s:3:"l";s:1:"l";s:3:"ï½";s:1:"m";s:3:"n";s:1:"n";s:3:"ï½";s:1:"o";s:3:"ï½";s:1:"p";s:3:"q";s:1:"q";s:3:"ï½’";s:1:"r";s:3:"s";s:1:"s";s:3:"ï½”";s:1:"t";s:3:"u";s:1:"u";s:3:"ï½–";s:1:"v";s:3:"ï½—";s:1:"w";s:3:"x";s:1:"x";s:3:"ï½™";s:1:"y";s:3:"z";s:1:"z";s:3:"ï½›";s:1:"{";s:3:"|";s:1:"|";s:3:"ï½";s:1:"}";s:3:"~";s:1:"~";s:3:"⦅";s:3:"⦅";s:3:"ï½ ";s:3:"⦆";s:3:"。";s:3:"。";s:3:"ï½¢";s:3:"「";s:3:"ï½£";s:3:"ã€";s:3:"、";s:3:"ã€";s:3:"ï½¥";s:3:"・";s:3:"ヲ";s:3:"ヲ";s:3:"ァ";s:3:"ã‚¡";s:3:"ィ";s:3:"ã‚£";s:3:"ゥ";s:3:"ã‚¥";s:3:"ェ";s:3:"ェ";s:3:"ォ";s:3:"ã‚©";s:3:"ャ";s:3:"ャ";s:3:"ï½­";s:3:"ュ";s:3:"ï½®";s:3:"ョ";s:3:"ッ";s:3:"ッ";s:3:"ï½°";s:3:"ー";s:3:"ï½±";s:3:"ã‚¢";s:3:"ï½²";s:3:"イ";s:3:"ï½³";s:3:"ウ";s:3:"ï½´";s:3:"エ";s:3:"ï½µ";s:3:"オ";s:3:"カ";s:3:"ã‚«";s:3:"ï½·";s:3:"ã‚­";s:3:"ク";s:3:"ク";s:3:"ï½¹";s:3:"ケ";s:3:"コ";s:3:"コ";s:3:"ï½»";s:3:"サ";s:3:"ï½¼";s:3:"ã‚·";s:3:"ï½½";s:3:"ス";s:3:"ï½¾";s:3:"ã‚»";s:3:"ソ";s:3:"ソ";s:3:"ï¾€";s:3:"ã‚¿";s:3:"ï¾";s:3:"ãƒ";s:3:"ツ";s:3:"ツ";s:3:"テ";s:3:"テ";s:3:"ト";s:3:"ト";s:3:"ï¾…";s:3:"ナ";s:3:"ニ";s:3:"ニ";s:3:"ヌ";s:3:"ヌ";s:3:"ネ";s:3:"ãƒ";s:3:"ノ";s:3:"ノ";s:3:"ハ";s:3:"ãƒ";s:3:"ヒ";s:3:"ヒ";s:3:"フ";s:3:"フ";s:3:"ï¾";s:3:"ヘ";s:3:"ホ";s:3:"ホ";s:3:"ï¾";s:3:"マ";s:3:"ï¾";s:3:"ミ";s:3:"ム";s:3:"ム";s:3:"ï¾’";s:3:"メ";s:3:"モ";s:3:"モ";s:3:"ï¾”";s:3:"ヤ";s:3:"ユ";s:3:"ユ";s:3:"ï¾–";s:3:"ヨ";s:3:"ï¾—";s:3:"ラ";s:3:"リ";s:3:"リ";s:3:"ï¾™";s:3:"ル";s:3:"レ";s:3:"レ";s:3:"ï¾›";s:3:"ロ";s:3:"ワ";s:3:"ワ";s:3:"ï¾";s:3:"ン";s:3:"゙";s:3:"ã‚™";s:3:"゚";s:3:"ã‚š";s:3:"ï¾ ";s:3:"á… ";s:3:"ᄀ";s:3:"á„€";s:3:"ï¾¢";s:3:"á„";s:3:"ï¾£";s:3:"ᆪ";s:3:"ᄂ";s:3:"á„‚";s:3:"ï¾¥";s:3:"ᆬ";s:3:"ᆭ";s:3:"ᆭ";s:3:"ᄃ";s:3:"ᄃ";s:3:"ᄄ";s:3:"á„„";s:3:"ᄅ";s:3:"á„…";s:3:"ᆰ";s:3:"ᆰ";s:3:"ᆱ";s:3:"ᆱ";s:3:"ᆲ";s:3:"ᆲ";s:3:"ï¾­";s:3:"ᆳ";s:3:"ï¾®";s:3:"ᆴ";s:3:"ᆵ";s:3:"ᆵ";s:3:"ï¾°";s:3:"á„š";s:3:"ï¾±";s:3:"ᄆ";s:3:"ï¾²";s:3:"ᄇ";s:3:"ï¾³";s:3:"ᄈ";s:3:"ï¾´";s:3:"á„¡";s:3:"ï¾µ";s:3:"ᄉ";s:3:"ᄊ";s:3:"á„Š";s:3:"ï¾·";s:3:"á„‹";s:3:"ᄌ";s:3:"á„Œ";s:3:"ï¾¹";s:3:"á„";s:3:"ᄎ";s:3:"á„Ž";s:3:"ï¾»";s:3:"á„";s:3:"ï¾¼";s:3:"á„";s:3:"ï¾½";s:3:"á„‘";s:3:"ï¾¾";s:3:"á„’";s:3:"ï¿‚";s:3:"á…¡";s:3:"ᅢ";s:3:"á…¢";s:3:"ï¿„";s:3:"á…£";s:3:"ï¿…";s:3:"á…¤";s:3:"ᅥ";s:3:"á…¥";s:3:"ᅦ";s:3:"á…¦";s:3:"ï¿Š";s:3:"á…§";s:3:"ï¿‹";s:3:"á…¨";s:3:"ï¿Œ";s:3:"á…©";s:3:"ï¿";s:3:"á…ª";s:3:"ï¿Ž";s:3:"á…«";s:3:"ï¿";s:3:"á…¬";s:3:"ï¿’";s:3:"á…­";s:3:"ï¿“";s:3:"á…®";s:3:"ï¿”";s:3:"á…¯";s:3:"ï¿•";s:3:"á…°";s:3:"ï¿–";s:3:"á…±";s:3:"ï¿—";s:3:"á…²";s:3:"ï¿š";s:3:"á…³";s:3:"ï¿›";s:3:"á…´";s:3:"ï¿œ";s:3:"á…µ";s:3:"ï¿ ";s:2:"¢";s:3:"ï¿¡";s:2:"£";s:3:"ï¿¢";s:2:"¬";s:3:"ï¿£";s:3:" Ì„";s:3:"¦";s:2:"¦";s:3:"ï¿¥";s:2:"Â¥";s:3:"₩";s:3:"â‚©";s:3:"│";s:3:"│";s:3:"ï¿©";s:3:"â†";s:3:"↑";s:3:"↑";s:3:"ï¿«";s:3:"→";s:3:"↓";s:3:"↓";s:3:"ï¿­";s:3:"â– ";s:3:"ï¿®";s:3:"â—‹";s:4:"ð€";s:1:"A";s:4:"ð";s:1:"B";s:4:"ð‚";s:1:"C";s:4:"ðƒ";s:1:"D";s:4:"ð„";s:1:"E";s:4:"ð…";s:1:"F";s:4:"ð†";s:1:"G";s:4:"ð‡";s:1:"H";s:4:"ðˆ";s:1:"I";s:4:"ð‰";s:1:"J";s:4:"ðŠ";s:1:"K";s:4:"ð‹";s:1:"L";s:4:"ðŒ";s:1:"M";s:4:"ð";s:1:"N";s:4:"ðŽ";s:1:"O";s:4:"ð";s:1:"P";s:4:"ð";s:1:"Q";s:4:"ð‘";s:1:"R";s:4:"ð’";s:1:"S";s:4:"ð“";s:1:"T";s:4:"ð”";s:1:"U";s:4:"ð•";s:1:"V";s:4:"ð–";s:1:"W";s:4:"ð—";s:1:"X";s:4:"ð˜";s:1:"Y";s:4:"ð™";s:1:"Z";s:4:"ðš";s:1:"a";s:4:"ð›";s:1:"b";s:4:"ðœ";s:1:"c";s:4:"ð";s:1:"d";s:4:"ðž";s:1:"e";s:4:"ðŸ";s:1:"f";s:4:"ð ";s:1:"g";s:4:"ð¡";s:1:"h";s:4:"ð¢";s:1:"i";s:4:"ð£";s:1:"j";s:4:"ð¤";s:1:"k";s:4:"ð¥";s:1:"l";s:4:"ð¦";s:1:"m";s:4:"ð§";s:1:"n";s:4:"ð¨";s:1:"o";s:4:"ð©";s:1:"p";s:4:"ðª";s:1:"q";s:4:"ð«";s:1:"r";s:4:"ð¬";s:1:"s";s:4:"ð­";s:1:"t";s:4:"ð®";s:1:"u";s:4:"ð¯";s:1:"v";s:4:"ð°";s:1:"w";s:4:"ð±";s:1:"x";s:4:"ð²";s:1:"y";s:4:"ð³";s:1:"z";s:4:"ð´";s:1:"A";s:4:"ðµ";s:1:"B";s:4:"ð¶";s:1:"C";s:4:"ð·";s:1:"D";s:4:"ð¸";s:1:"E";s:4:"ð¹";s:1:"F";s:4:"ðº";s:1:"G";s:4:"ð»";s:1:"H";s:4:"ð¼";s:1:"I";s:4:"ð½";s:1:"J";s:4:"ð¾";s:1:"K";s:4:"ð¿";s:1:"L";s:4:"ð‘€";s:1:"M";s:4:"ð‘";s:1:"N";s:4:"ð‘‚";s:1:"O";s:4:"ð‘ƒ";s:1:"P";s:4:"ð‘„";s:1:"Q";s:4:"ð‘…";s:1:"R";s:4:"ð‘†";s:1:"S";s:4:"ð‘‡";s:1:"T";s:4:"ð‘ˆ";s:1:"U";s:4:"ð‘‰";s:1:"V";s:4:"ð‘Š";s:1:"W";s:4:"ð‘‹";s:1:"X";s:4:"ð‘Œ";s:1:"Y";s:4:"ð‘";s:1:"Z";s:4:"ð‘Ž";s:1:"a";s:4:"ð‘";s:1:"b";s:4:"ð‘";s:1:"c";s:4:"ð‘‘";s:1:"d";s:4:"ð‘’";s:1:"e";s:4:"ð‘“";s:1:"f";s:4:"ð‘”";s:1:"g";s:4:"ð‘–";s:1:"i";s:4:"ð‘—";s:1:"j";s:4:"ð‘˜";s:1:"k";s:4:"ð‘™";s:1:"l";s:4:"ð‘š";s:1:"m";s:4:"ð‘›";s:1:"n";s:4:"ð‘œ";s:1:"o";s:4:"ð‘";s:1:"p";s:4:"ð‘ž";s:1:"q";s:4:"ð‘Ÿ";s:1:"r";s:4:"ð‘ ";s:1:"s";s:4:"ð‘¡";s:1:"t";s:4:"ð‘¢";s:1:"u";s:4:"ð‘£";s:1:"v";s:4:"ð‘¤";s:1:"w";s:4:"ð‘¥";s:1:"x";s:4:"ð‘¦";s:1:"y";s:4:"ð‘§";s:1:"z";s:4:"ð‘¨";s:1:"A";s:4:"ð‘©";s:1:"B";s:4:"ð‘ª";s:1:"C";s:4:"ð‘«";s:1:"D";s:4:"ð‘¬";s:1:"E";s:4:"ð‘­";s:1:"F";s:4:"ð‘®";s:1:"G";s:4:"ð‘¯";s:1:"H";s:4:"ð‘°";s:1:"I";s:4:"ð‘±";s:1:"J";s:4:"ð‘²";s:1:"K";s:4:"ð‘³";s:1:"L";s:4:"ð‘´";s:1:"M";s:4:"ð‘µ";s:1:"N";s:4:"ð‘¶";s:1:"O";s:4:"ð‘·";s:1:"P";s:4:"ð‘¸";s:1:"Q";s:4:"ð‘¹";s:1:"R";s:4:"ð‘º";s:1:"S";s:4:"ð‘»";s:1:"T";s:4:"ð‘¼";s:1:"U";s:4:"ð‘½";s:1:"V";s:4:"ð‘¾";s:1:"W";s:4:"ð‘¿";s:1:"X";s:4:"ð’€";s:1:"Y";s:4:"ð’";s:1:"Z";s:4:"ð’‚";s:1:"a";s:4:"ð’ƒ";s:1:"b";s:4:"ð’„";s:1:"c";s:4:"ð’…";s:1:"d";s:4:"ð’†";s:1:"e";s:4:"ð’‡";s:1:"f";s:4:"ð’ˆ";s:1:"g";s:4:"ð’‰";s:1:"h";s:4:"ð’Š";s:1:"i";s:4:"ð’‹";s:1:"j";s:4:"ð’Œ";s:1:"k";s:4:"ð’";s:1:"l";s:4:"ð’Ž";s:1:"m";s:4:"ð’";s:1:"n";s:4:"ð’";s:1:"o";s:4:"ð’‘";s:1:"p";s:4:"ð’’";s:1:"q";s:4:"ð’“";s:1:"r";s:4:"ð’”";s:1:"s";s:4:"ð’•";s:1:"t";s:4:"ð’–";s:1:"u";s:4:"ð’—";s:1:"v";s:4:"ð’˜";s:1:"w";s:4:"ð’™";s:1:"x";s:4:"ð’š";s:1:"y";s:4:"ð’›";s:1:"z";s:4:"ð’œ";s:1:"A";s:4:"ð’ž";s:1:"C";s:4:"ð’Ÿ";s:1:"D";s:4:"ð’¢";s:1:"G";s:4:"ð’¥";s:1:"J";s:4:"ð’¦";s:1:"K";s:4:"ð’©";s:1:"N";s:4:"ð’ª";s:1:"O";s:4:"ð’«";s:1:"P";s:4:"ð’¬";s:1:"Q";s:4:"ð’®";s:1:"S";s:4:"ð’¯";s:1:"T";s:4:"ð’°";s:1:"U";s:4:"ð’±";s:1:"V";s:4:"ð’²";s:1:"W";s:4:"ð’³";s:1:"X";s:4:"ð’´";s:1:"Y";s:4:"ð’µ";s:1:"Z";s:4:"ð’¶";s:1:"a";s:4:"ð’·";s:1:"b";s:4:"ð’¸";s:1:"c";s:4:"ð’¹";s:1:"d";s:4:"ð’»";s:1:"f";s:4:"ð’½";s:1:"h";s:4:"ð’¾";s:1:"i";s:4:"ð’¿";s:1:"j";s:4:"ð“€";s:1:"k";s:4:"ð“";s:1:"l";s:4:"ð“‚";s:1:"m";s:4:"ð“ƒ";s:1:"n";s:4:"ð“…";s:1:"p";s:4:"ð“†";s:1:"q";s:4:"ð“‡";s:1:"r";s:4:"ð“ˆ";s:1:"s";s:4:"ð“‰";s:1:"t";s:4:"ð“Š";s:1:"u";s:4:"ð“‹";s:1:"v";s:4:"ð“Œ";s:1:"w";s:4:"ð“";s:1:"x";s:4:"ð“Ž";s:1:"y";s:4:"ð“";s:1:"z";s:4:"ð“";s:1:"A";s:4:"ð“‘";s:1:"B";s:4:"ð“’";s:1:"C";s:4:"ð““";s:1:"D";s:4:"ð“”";s:1:"E";s:4:"ð“•";s:1:"F";s:4:"ð“–";s:1:"G";s:4:"ð“—";s:1:"H";s:4:"ð“˜";s:1:"I";s:4:"ð“™";s:1:"J";s:4:"ð“š";s:1:"K";s:4:"ð“›";s:1:"L";s:4:"ð“œ";s:1:"M";s:4:"ð“";s:1:"N";s:4:"ð“ž";s:1:"O";s:4:"ð“Ÿ";s:1:"P";s:4:"ð“ ";s:1:"Q";s:4:"ð“¡";s:1:"R";s:4:"ð“¢";s:1:"S";s:4:"ð“£";s:1:"T";s:4:"ð“¤";s:1:"U";s:4:"ð“¥";s:1:"V";s:4:"ð“¦";s:1:"W";s:4:"ð“§";s:1:"X";s:4:"ð“¨";s:1:"Y";s:4:"ð“©";s:1:"Z";s:4:"ð“ª";s:1:"a";s:4:"ð“«";s:1:"b";s:4:"ð“¬";s:1:"c";s:4:"ð“­";s:1:"d";s:4:"ð“®";s:1:"e";s:4:"ð“¯";s:1:"f";s:4:"ð“°";s:1:"g";s:4:"ð“±";s:1:"h";s:4:"ð“²";s:1:"i";s:4:"ð“³";s:1:"j";s:4:"ð“´";s:1:"k";s:4:"ð“µ";s:1:"l";s:4:"ð“¶";s:1:"m";s:4:"ð“·";s:1:"n";s:4:"ð“¸";s:1:"o";s:4:"ð“¹";s:1:"p";s:4:"ð“º";s:1:"q";s:4:"ð“»";s:1:"r";s:4:"ð“¼";s:1:"s";s:4:"ð“½";s:1:"t";s:4:"ð“¾";s:1:"u";s:4:"ð“¿";s:1:"v";s:4:"ð”€";s:1:"w";s:4:"ð”";s:1:"x";s:4:"ð”‚";s:1:"y";s:4:"ð”ƒ";s:1:"z";s:4:"ð”„";s:1:"A";s:4:"ð”…";s:1:"B";s:4:"ð”‡";s:1:"D";s:4:"ð”ˆ";s:1:"E";s:4:"ð”‰";s:1:"F";s:4:"ð”Š";s:1:"G";s:4:"ð”";s:1:"J";s:4:"ð”Ž";s:1:"K";s:4:"ð”";s:1:"L";s:4:"ð”";s:1:"M";s:4:"ð”‘";s:1:"N";s:4:"ð”’";s:1:"O";s:4:"ð”“";s:1:"P";s:4:"ð””";s:1:"Q";s:4:"ð”–";s:1:"S";s:4:"ð”—";s:1:"T";s:4:"ð”˜";s:1:"U";s:4:"ð”™";s:1:"V";s:4:"ð”š";s:1:"W";s:4:"ð”›";s:1:"X";s:4:"ð”œ";s:1:"Y";s:4:"ð”ž";s:1:"a";s:4:"ð”Ÿ";s:1:"b";s:4:"ð” ";s:1:"c";s:4:"ð”¡";s:1:"d";s:4:"ð”¢";s:1:"e";s:4:"ð”£";s:1:"f";s:4:"ð”¤";s:1:"g";s:4:"ð”¥";s:1:"h";s:4:"ð”¦";s:1:"i";s:4:"ð”§";s:1:"j";s:4:"ð”¨";s:1:"k";s:4:"ð”©";s:1:"l";s:4:"ð”ª";s:1:"m";s:4:"ð”«";s:1:"n";s:4:"ð”¬";s:1:"o";s:4:"ð”­";s:1:"p";s:4:"ð”®";s:1:"q";s:4:"ð”¯";s:1:"r";s:4:"ð”°";s:1:"s";s:4:"ð”±";s:1:"t";s:4:"ð”²";s:1:"u";s:4:"ð”³";s:1:"v";s:4:"ð”´";s:1:"w";s:4:"ð”µ";s:1:"x";s:4:"ð”¶";s:1:"y";s:4:"ð”·";s:1:"z";s:4:"ð”¸";s:1:"A";s:4:"ð”¹";s:1:"B";s:4:"ð”»";s:1:"D";s:4:"ð”¼";s:1:"E";s:4:"ð”½";s:1:"F";s:4:"ð”¾";s:1:"G";s:4:"ð•€";s:1:"I";s:4:"ð•";s:1:"J";s:4:"ð•‚";s:1:"K";s:4:"ð•ƒ";s:1:"L";s:4:"ð•„";s:1:"M";s:4:"ð•†";s:1:"O";s:4:"ð•Š";s:1:"S";s:4:"ð•‹";s:1:"T";s:4:"ð•Œ";s:1:"U";s:4:"ð•";s:1:"V";s:4:"ð•Ž";s:1:"W";s:4:"ð•";s:1:"X";s:4:"ð•";s:1:"Y";s:4:"ð•’";s:1:"a";s:4:"ð•“";s:1:"b";s:4:"ð•”";s:1:"c";s:4:"ð••";s:1:"d";s:4:"ð•–";s:1:"e";s:4:"ð•—";s:1:"f";s:4:"ð•˜";s:1:"g";s:4:"ð•™";s:1:"h";s:4:"ð•š";s:1:"i";s:4:"ð•›";s:1:"j";s:4:"ð•œ";s:1:"k";s:4:"ð•";s:1:"l";s:4:"ð•ž";s:1:"m";s:4:"ð•Ÿ";s:1:"n";s:4:"ð• ";s:1:"o";s:4:"ð•¡";s:1:"p";s:4:"ð•¢";s:1:"q";s:4:"ð•£";s:1:"r";s:4:"ð•¤";s:1:"s";s:4:"ð•¥";s:1:"t";s:4:"ð•¦";s:1:"u";s:4:"ð•§";s:1:"v";s:4:"ð•¨";s:1:"w";s:4:"ð•©";s:1:"x";s:4:"ð•ª";s:1:"y";s:4:"ð•«";s:1:"z";s:4:"ð•¬";s:1:"A";s:4:"ð•­";s:1:"B";s:4:"ð•®";s:1:"C";s:4:"ð•¯";s:1:"D";s:4:"ð•°";s:1:"E";s:4:"ð•±";s:1:"F";s:4:"ð•²";s:1:"G";s:4:"ð•³";s:1:"H";s:4:"ð•´";s:1:"I";s:4:"ð•µ";s:1:"J";s:4:"ð•¶";s:1:"K";s:4:"ð•·";s:1:"L";s:4:"ð•¸";s:1:"M";s:4:"ð•¹";s:1:"N";s:4:"ð•º";s:1:"O";s:4:"ð•»";s:1:"P";s:4:"ð•¼";s:1:"Q";s:4:"ð•½";s:1:"R";s:4:"ð•¾";s:1:"S";s:4:"ð•¿";s:1:"T";s:4:"ð–€";s:1:"U";s:4:"ð–";s:1:"V";s:4:"ð–‚";s:1:"W";s:4:"ð–ƒ";s:1:"X";s:4:"ð–„";s:1:"Y";s:4:"ð–…";s:1:"Z";s:4:"ð–†";s:1:"a";s:4:"ð–‡";s:1:"b";s:4:"ð–ˆ";s:1:"c";s:4:"ð–‰";s:1:"d";s:4:"ð–Š";s:1:"e";s:4:"ð–‹";s:1:"f";s:4:"ð–Œ";s:1:"g";s:4:"ð–";s:1:"h";s:4:"ð–Ž";s:1:"i";s:4:"ð–";s:1:"j";s:4:"ð–";s:1:"k";s:4:"ð–‘";s:1:"l";s:4:"ð–’";s:1:"m";s:4:"ð–“";s:1:"n";s:4:"ð–”";s:1:"o";s:4:"ð–•";s:1:"p";s:4:"ð––";s:1:"q";s:4:"ð–—";s:1:"r";s:4:"ð–˜";s:1:"s";s:4:"ð–™";s:1:"t";s:4:"ð–š";s:1:"u";s:4:"ð–›";s:1:"v";s:4:"ð–œ";s:1:"w";s:4:"ð–";s:1:"x";s:4:"ð–ž";s:1:"y";s:4:"ð–Ÿ";s:1:"z";s:4:"ð– ";s:1:"A";s:4:"ð–¡";s:1:"B";s:4:"ð–¢";s:1:"C";s:4:"ð–£";s:1:"D";s:4:"ð–¤";s:1:"E";s:4:"ð–¥";s:1:"F";s:4:"ð–¦";s:1:"G";s:4:"ð–§";s:1:"H";s:4:"ð–¨";s:1:"I";s:4:"ð–©";s:1:"J";s:4:"ð–ª";s:1:"K";s:4:"ð–«";s:1:"L";s:4:"ð–¬";s:1:"M";s:4:"ð–­";s:1:"N";s:4:"ð–®";s:1:"O";s:4:"ð–¯";s:1:"P";s:4:"ð–°";s:1:"Q";s:4:"ð–±";s:1:"R";s:4:"ð–²";s:1:"S";s:4:"ð–³";s:1:"T";s:4:"ð–´";s:1:"U";s:4:"ð–µ";s:1:"V";s:4:"ð–¶";s:1:"W";s:4:"ð–·";s:1:"X";s:4:"ð–¸";s:1:"Y";s:4:"ð–¹";s:1:"Z";s:4:"ð–º";s:1:"a";s:4:"ð–»";s:1:"b";s:4:"ð–¼";s:1:"c";s:4:"ð–½";s:1:"d";s:4:"ð–¾";s:1:"e";s:4:"ð–¿";s:1:"f";s:4:"ð—€";s:1:"g";s:4:"ð—";s:1:"h";s:4:"ð—‚";s:1:"i";s:4:"ð—ƒ";s:1:"j";s:4:"ð—„";s:1:"k";s:4:"ð—…";s:1:"l";s:4:"ð—†";s:1:"m";s:4:"ð—‡";s:1:"n";s:4:"ð—ˆ";s:1:"o";s:4:"ð—‰";s:1:"p";s:4:"ð—Š";s:1:"q";s:4:"ð—‹";s:1:"r";s:4:"ð—Œ";s:1:"s";s:4:"ð—";s:1:"t";s:4:"ð—Ž";s:1:"u";s:4:"ð—";s:1:"v";s:4:"ð—";s:1:"w";s:4:"ð—‘";s:1:"x";s:4:"ð—’";s:1:"y";s:4:"ð—“";s:1:"z";s:4:"ð—”";s:1:"A";s:4:"ð—•";s:1:"B";s:4:"ð—–";s:1:"C";s:4:"ð——";s:1:"D";s:4:"ð—˜";s:1:"E";s:4:"ð—™";s:1:"F";s:4:"ð—š";s:1:"G";s:4:"ð—›";s:1:"H";s:4:"ð—œ";s:1:"I";s:4:"ð—";s:1:"J";s:4:"ð—ž";s:1:"K";s:4:"ð—Ÿ";s:1:"L";s:4:"ð— ";s:1:"M";s:4:"ð—¡";s:1:"N";s:4:"ð—¢";s:1:"O";s:4:"ð—£";s:1:"P";s:4:"ð—¤";s:1:"Q";s:4:"ð—¥";s:1:"R";s:4:"ð—¦";s:1:"S";s:4:"ð—§";s:1:"T";s:4:"ð—¨";s:1:"U";s:4:"ð—©";s:1:"V";s:4:"ð—ª";s:1:"W";s:4:"ð—«";s:1:"X";s:4:"ð—¬";s:1:"Y";s:4:"ð—­";s:1:"Z";s:4:"ð—®";s:1:"a";s:4:"ð—¯";s:1:"b";s:4:"ð—°";s:1:"c";s:4:"ð—±";s:1:"d";s:4:"ð—²";s:1:"e";s:4:"ð—³";s:1:"f";s:4:"ð—´";s:1:"g";s:4:"ð—µ";s:1:"h";s:4:"ð—¶";s:1:"i";s:4:"ð—·";s:1:"j";s:4:"ð—¸";s:1:"k";s:4:"ð—¹";s:1:"l";s:4:"ð—º";s:1:"m";s:4:"ð—»";s:1:"n";s:4:"ð—¼";s:1:"o";s:4:"ð—½";s:1:"p";s:4:"ð—¾";s:1:"q";s:4:"ð—¿";s:1:"r";s:4:"ð˜€";s:1:"s";s:4:"ð˜";s:1:"t";s:4:"ð˜‚";s:1:"u";s:4:"ð˜ƒ";s:1:"v";s:4:"ð˜„";s:1:"w";s:4:"ð˜…";s:1:"x";s:4:"ð˜†";s:1:"y";s:4:"ð˜‡";s:1:"z";s:4:"ð˜ˆ";s:1:"A";s:4:"ð˜‰";s:1:"B";s:4:"ð˜Š";s:1:"C";s:4:"ð˜‹";s:1:"D";s:4:"ð˜Œ";s:1:"E";s:4:"ð˜";s:1:"F";s:4:"ð˜Ž";s:1:"G";s:4:"ð˜";s:1:"H";s:4:"ð˜";s:1:"I";s:4:"ð˜‘";s:1:"J";s:4:"ð˜’";s:1:"K";s:4:"ð˜“";s:1:"L";s:4:"ð˜”";s:1:"M";s:4:"ð˜•";s:1:"N";s:4:"ð˜–";s:1:"O";s:4:"ð˜—";s:1:"P";s:4:"ð˜˜";s:1:"Q";s:4:"ð˜™";s:1:"R";s:4:"ð˜š";s:1:"S";s:4:"ð˜›";s:1:"T";s:4:"ð˜œ";s:1:"U";s:4:"ð˜";s:1:"V";s:4:"ð˜ž";s:1:"W";s:4:"ð˜Ÿ";s:1:"X";s:4:"ð˜ ";s:1:"Y";s:4:"ð˜¡";s:1:"Z";s:4:"ð˜¢";s:1:"a";s:4:"ð˜£";s:1:"b";s:4:"ð˜¤";s:1:"c";s:4:"ð˜¥";s:1:"d";s:4:"ð˜¦";s:1:"e";s:4:"ð˜§";s:1:"f";s:4:"ð˜¨";s:1:"g";s:4:"ð˜©";s:1:"h";s:4:"ð˜ª";s:1:"i";s:4:"ð˜«";s:1:"j";s:4:"ð˜¬";s:1:"k";s:4:"ð˜­";s:1:"l";s:4:"ð˜®";s:1:"m";s:4:"ð˜¯";s:1:"n";s:4:"ð˜°";s:1:"o";s:4:"ð˜±";s:1:"p";s:4:"ð˜²";s:1:"q";s:4:"ð˜³";s:1:"r";s:4:"ð˜´";s:1:"s";s:4:"ð˜µ";s:1:"t";s:4:"ð˜¶";s:1:"u";s:4:"ð˜·";s:1:"v";s:4:"ð˜¸";s:1:"w";s:4:"ð˜¹";s:1:"x";s:4:"ð˜º";s:1:"y";s:4:"ð˜»";s:1:"z";s:4:"ð˜¼";s:1:"A";s:4:"ð˜½";s:1:"B";s:4:"ð˜¾";s:1:"C";s:4:"ð˜¿";s:1:"D";s:4:"ð™€";s:1:"E";s:4:"ð™";s:1:"F";s:4:"ð™‚";s:1:"G";s:4:"ð™ƒ";s:1:"H";s:4:"ð™„";s:1:"I";s:4:"ð™…";s:1:"J";s:4:"ð™†";s:1:"K";s:4:"ð™‡";s:1:"L";s:4:"ð™ˆ";s:1:"M";s:4:"ð™‰";s:1:"N";s:4:"ð™Š";s:1:"O";s:4:"ð™‹";s:1:"P";s:4:"ð™Œ";s:1:"Q";s:4:"ð™";s:1:"R";s:4:"ð™Ž";s:1:"S";s:4:"ð™";s:1:"T";s:4:"ð™";s:1:"U";s:4:"ð™‘";s:1:"V";s:4:"ð™’";s:1:"W";s:4:"ð™“";s:1:"X";s:4:"ð™”";s:1:"Y";s:4:"ð™•";s:1:"Z";s:4:"ð™–";s:1:"a";s:4:"ð™—";s:1:"b";s:4:"ð™˜";s:1:"c";s:4:"ð™™";s:1:"d";s:4:"ð™š";s:1:"e";s:4:"ð™›";s:1:"f";s:4:"ð™œ";s:1:"g";s:4:"ð™";s:1:"h";s:4:"ð™ž";s:1:"i";s:4:"ð™Ÿ";s:1:"j";s:4:"ð™ ";s:1:"k";s:4:"ð™¡";s:1:"l";s:4:"ð™¢";s:1:"m";s:4:"ð™£";s:1:"n";s:4:"ð™¤";s:1:"o";s:4:"ð™¥";s:1:"p";s:4:"ð™¦";s:1:"q";s:4:"ð™§";s:1:"r";s:4:"ð™¨";s:1:"s";s:4:"ð™©";s:1:"t";s:4:"ð™ª";s:1:"u";s:4:"ð™«";s:1:"v";s:4:"ð™¬";s:1:"w";s:4:"ð™­";s:1:"x";s:4:"ð™®";s:1:"y";s:4:"ð™¯";s:1:"z";s:4:"ð™°";s:1:"A";s:4:"ð™±";s:1:"B";s:4:"ð™²";s:1:"C";s:4:"ð™³";s:1:"D";s:4:"ð™´";s:1:"E";s:4:"ð™µ";s:1:"F";s:4:"ð™¶";s:1:"G";s:4:"ð™·";s:1:"H";s:4:"ð™¸";s:1:"I";s:4:"ð™¹";s:1:"J";s:4:"ð™º";s:1:"K";s:4:"ð™»";s:1:"L";s:4:"ð™¼";s:1:"M";s:4:"ð™½";s:1:"N";s:4:"ð™¾";s:1:"O";s:4:"ð™¿";s:1:"P";s:4:"ðš€";s:1:"Q";s:4:"ðš";s:1:"R";s:4:"ðš‚";s:1:"S";s:4:"ðšƒ";s:1:"T";s:4:"ðš„";s:1:"U";s:4:"ðš…";s:1:"V";s:4:"ðš†";s:1:"W";s:4:"ðš‡";s:1:"X";s:4:"ðšˆ";s:1:"Y";s:4:"ðš‰";s:1:"Z";s:4:"ðšŠ";s:1:"a";s:4:"ðš‹";s:1:"b";s:4:"ðšŒ";s:1:"c";s:4:"ðš";s:1:"d";s:4:"ðšŽ";s:1:"e";s:4:"ðš";s:1:"f";s:4:"ðš";s:1:"g";s:4:"ðš‘";s:1:"h";s:4:"ðš’";s:1:"i";s:4:"ðš“";s:1:"j";s:4:"ðš”";s:1:"k";s:4:"ðš•";s:1:"l";s:4:"ðš–";s:1:"m";s:4:"ðš—";s:1:"n";s:4:"ðš˜";s:1:"o";s:4:"ðš™";s:1:"p";s:4:"ðšš";s:1:"q";s:4:"ðš›";s:1:"r";s:4:"ðšœ";s:1:"s";s:4:"ðš";s:1:"t";s:4:"ðšž";s:1:"u";s:4:"ðšŸ";s:1:"v";s:4:"ðš ";s:1:"w";s:4:"ðš¡";s:1:"x";s:4:"ðš¢";s:1:"y";s:4:"ðš£";s:1:"z";s:4:"ðš¤";s:2:"ı";s:4:"ðš¥";s:2:"È·";s:4:"ðš¨";s:2:"Α";s:4:"ðš©";s:2:"Î’";s:4:"ðšª";s:2:"Γ";s:4:"ðš«";s:2:"Δ";s:4:"ðš¬";s:2:"Ε";s:4:"ðš­";s:2:"Ζ";s:4:"ðš®";s:2:"Η";s:4:"ðš¯";s:2:"Θ";s:4:"ðš°";s:2:"Ι";s:4:"ðš±";s:2:"Κ";s:4:"ðš²";s:2:"Λ";s:4:"ðš³";s:2:"Îœ";s:4:"ðš´";s:2:"Î";s:4:"ðšµ";s:2:"Ξ";s:4:"ðš¶";s:2:"Ο";s:4:"ðš·";s:2:"Π";s:4:"ðš¸";s:2:"Ρ";s:4:"ðš¹";s:2:"Θ";s:4:"ðšº";s:2:"Σ";s:4:"ðš»";s:2:"Τ";s:4:"ðš¼";s:2:"Î¥";s:4:"ðš½";s:2:"Φ";s:4:"ðš¾";s:2:"Χ";s:4:"ðš¿";s:2:"Ψ";s:4:"ð›€";s:2:"Ω";s:4:"ð›";s:3:"∇";s:4:"ð›‚";s:2:"α";s:4:"ð›ƒ";s:2:"β";s:4:"ð›„";s:2:"γ";s:4:"ð›…";s:2:"δ";s:4:"ð›†";s:2:"ε";s:4:"ð›‡";s:2:"ζ";s:4:"ð›ˆ";s:2:"η";s:4:"ð›‰";s:2:"θ";s:4:"ð›Š";s:2:"ι";s:4:"ð›‹";s:2:"κ";s:4:"ð›Œ";s:2:"λ";s:4:"ð›";s:2:"μ";s:4:"ð›Ž";s:2:"ν";s:4:"ð›";s:2:"ξ";s:4:"ð›";s:2:"ο";s:4:"ð›‘";s:2:"Ï€";s:4:"ð›’";s:2:"Ï";s:4:"ð›“";s:2:"Ï‚";s:4:"ð›”";s:2:"σ";s:4:"ð›•";s:2:"Ï„";s:4:"ð›–";s:2:"Ï…";s:4:"ð›—";s:2:"φ";s:4:"ð›˜";s:2:"χ";s:4:"ð›™";s:2:"ψ";s:4:"ð›š";s:2:"ω";s:4:"ð››";s:3:"∂";s:4:"ð›œ";s:2:"ε";s:4:"ð›";s:2:"θ";s:4:"ð›ž";s:2:"κ";s:4:"ð›Ÿ";s:2:"φ";s:4:"ð› ";s:2:"Ï";s:4:"ð›¡";s:2:"Ï€";s:4:"ð›¢";s:2:"Α";s:4:"ð›£";s:2:"Î’";s:4:"ð›¤";s:2:"Γ";s:4:"ð›¥";s:2:"Δ";s:4:"ð›¦";s:2:"Ε";s:4:"ð›§";s:2:"Ζ";s:4:"ð›¨";s:2:"Η";s:4:"ð›©";s:2:"Θ";s:4:"ð›ª";s:2:"Ι";s:4:"ð›«";s:2:"Κ";s:4:"ð›¬";s:2:"Λ";s:4:"ð›­";s:2:"Îœ";s:4:"ð›®";s:2:"Î";s:4:"ð›¯";s:2:"Ξ";s:4:"ð›°";s:2:"Ο";s:4:"ð›±";s:2:"Π";s:4:"ð›²";s:2:"Ρ";s:4:"ð›³";s:2:"Θ";s:4:"ð›´";s:2:"Σ";s:4:"ð›µ";s:2:"Τ";s:4:"ð›¶";s:2:"Î¥";s:4:"ð›·";s:2:"Φ";s:4:"ð›¸";s:2:"Χ";s:4:"ð›¹";s:2:"Ψ";s:4:"ð›º";s:2:"Ω";s:4:"ð›»";s:3:"∇";s:4:"ð›¼";s:2:"α";s:4:"ð›½";s:2:"β";s:4:"ð›¾";s:2:"γ";s:4:"ð›¿";s:2:"δ";s:4:"ðœ€";s:2:"ε";s:4:"ðœ";s:2:"ζ";s:4:"ðœ‚";s:2:"η";s:4:"ðœƒ";s:2:"θ";s:4:"ðœ„";s:2:"ι";s:4:"ðœ…";s:2:"κ";s:4:"ðœ†";s:2:"λ";s:4:"ðœ‡";s:2:"μ";s:4:"ðœˆ";s:2:"ν";s:4:"ðœ‰";s:2:"ξ";s:4:"ðœŠ";s:2:"ο";s:4:"ðœ‹";s:2:"Ï€";s:4:"ðœŒ";s:2:"Ï";s:4:"ðœ";s:2:"Ï‚";s:4:"ðœŽ";s:2:"σ";s:4:"ðœ";s:2:"Ï„";s:4:"ðœ";s:2:"Ï…";s:4:"ðœ‘";s:2:"φ";s:4:"ðœ’";s:2:"χ";s:4:"ðœ“";s:2:"ψ";s:4:"ðœ”";s:2:"ω";s:4:"ðœ•";s:3:"∂";s:4:"ðœ–";s:2:"ε";s:4:"ðœ—";s:2:"θ";s:4:"ðœ˜";s:2:"κ";s:4:"ðœ™";s:2:"φ";s:4:"ðœš";s:2:"Ï";s:4:"ðœ›";s:2:"Ï€";s:4:"ðœœ";s:2:"Α";s:4:"ðœ";s:2:"Î’";s:4:"ðœž";s:2:"Γ";s:4:"ðœŸ";s:2:"Δ";s:4:"ðœ ";s:2:"Ε";s:4:"ðœ¡";s:2:"Ζ";s:4:"ðœ¢";s:2:"Η";s:4:"ðœ£";s:2:"Θ";s:4:"ðœ¤";s:2:"Ι";s:4:"ðœ¥";s:2:"Κ";s:4:"ðœ¦";s:2:"Λ";s:4:"ðœ§";s:2:"Îœ";s:4:"ðœ¨";s:2:"Î";s:4:"ðœ©";s:2:"Ξ";s:4:"ðœª";s:2:"Ο";s:4:"ðœ«";s:2:"Π";s:4:"ðœ¬";s:2:"Ρ";s:4:"ðœ­";s:2:"Θ";s:4:"ðœ®";s:2:"Σ";s:4:"ðœ¯";s:2:"Τ";s:4:"ðœ°";s:2:"Î¥";s:4:"ðœ±";s:2:"Φ";s:4:"ðœ²";s:2:"Χ";s:4:"ðœ³";s:2:"Ψ";s:4:"ðœ´";s:2:"Ω";s:4:"ðœµ";s:3:"∇";s:4:"ðœ¶";s:2:"α";s:4:"ðœ·";s:2:"β";s:4:"ðœ¸";s:2:"γ";s:4:"ðœ¹";s:2:"δ";s:4:"ðœº";s:2:"ε";s:4:"ðœ»";s:2:"ζ";s:4:"ðœ¼";s:2:"η";s:4:"ðœ½";s:2:"θ";s:4:"ðœ¾";s:2:"ι";s:4:"ðœ¿";s:2:"κ";s:4:"ð€";s:2:"λ";s:4:"ð";s:2:"μ";s:4:"ð‚";s:2:"ν";s:4:"ðƒ";s:2:"ξ";s:4:"ð„";s:2:"ο";s:4:"ð…";s:2:"Ï€";s:4:"ð†";s:2:"Ï";s:4:"ð‡";s:2:"Ï‚";s:4:"ðˆ";s:2:"σ";s:4:"ð‰";s:2:"Ï„";s:4:"ðŠ";s:2:"Ï…";s:4:"ð‹";s:2:"φ";s:4:"ðŒ";s:2:"χ";s:4:"ð";s:2:"ψ";s:4:"ðŽ";s:2:"ω";s:4:"ð";s:3:"∂";s:4:"ð";s:2:"ε";s:4:"ð‘";s:2:"θ";s:4:"ð’";s:2:"κ";s:4:"ð“";s:2:"φ";s:4:"ð”";s:2:"Ï";s:4:"ð•";s:2:"Ï€";s:4:"ð–";s:2:"Α";s:4:"ð—";s:2:"Î’";s:4:"ð˜";s:2:"Γ";s:4:"ð™";s:2:"Δ";s:4:"ðš";s:2:"Ε";s:4:"ð›";s:2:"Ζ";s:4:"ðœ";s:2:"Η";s:4:"ð";s:2:"Θ";s:4:"ðž";s:2:"Ι";s:4:"ðŸ";s:2:"Κ";s:4:"ð ";s:2:"Λ";s:4:"ð¡";s:2:"Îœ";s:4:"ð¢";s:2:"Î";s:4:"ð£";s:2:"Ξ";s:4:"ð¤";s:2:"Ο";s:4:"ð¥";s:2:"Π";s:4:"ð¦";s:2:"Ρ";s:4:"ð§";s:2:"Θ";s:4:"ð¨";s:2:"Σ";s:4:"ð©";s:2:"Τ";s:4:"ðª";s:2:"Î¥";s:4:"ð«";s:2:"Φ";s:4:"ð¬";s:2:"Χ";s:4:"ð­";s:2:"Ψ";s:4:"ð®";s:2:"Ω";s:4:"ð¯";s:3:"∇";s:4:"ð°";s:2:"α";s:4:"ð±";s:2:"β";s:4:"ð²";s:2:"γ";s:4:"ð³";s:2:"δ";s:4:"ð´";s:2:"ε";s:4:"ðµ";s:2:"ζ";s:4:"ð¶";s:2:"η";s:4:"ð·";s:2:"θ";s:4:"ð¸";s:2:"ι";s:4:"ð¹";s:2:"κ";s:4:"ðº";s:2:"λ";s:4:"ð»";s:2:"μ";s:4:"ð¼";s:2:"ν";s:4:"ð½";s:2:"ξ";s:4:"ð¾";s:2:"ο";s:4:"ð¿";s:2:"Ï€";s:4:"ðž€";s:2:"Ï";s:4:"ðž";s:2:"Ï‚";s:4:"ðž‚";s:2:"σ";s:4:"ðžƒ";s:2:"Ï„";s:4:"ðž„";s:2:"Ï…";s:4:"ðž…";s:2:"φ";s:4:"ðž†";s:2:"χ";s:4:"ðž‡";s:2:"ψ";s:4:"ðžˆ";s:2:"ω";s:4:"ðž‰";s:3:"∂";s:4:"ðžŠ";s:2:"ε";s:4:"ðž‹";s:2:"θ";s:4:"ðžŒ";s:2:"κ";s:4:"ðž";s:2:"φ";s:4:"ðžŽ";s:2:"Ï";s:4:"ðž";s:2:"Ï€";s:4:"ðž";s:2:"Α";s:4:"ðž‘";s:2:"Î’";s:4:"ðž’";s:2:"Γ";s:4:"ðž“";s:2:"Δ";s:4:"ðž”";s:2:"Ε";s:4:"ðž•";s:2:"Ζ";s:4:"ðž–";s:2:"Η";s:4:"ðž—";s:2:"Θ";s:4:"ðž˜";s:2:"Ι";s:4:"ðž™";s:2:"Κ";s:4:"ðžš";s:2:"Λ";s:4:"ðž›";s:2:"Îœ";s:4:"ðžœ";s:2:"Î";s:4:"ðž";s:2:"Ξ";s:4:"ðžž";s:2:"Ο";s:4:"ðžŸ";s:2:"Π";s:4:"ðž ";s:2:"Ρ";s:4:"ðž¡";s:2:"Θ";s:4:"ðž¢";s:2:"Σ";s:4:"ðž£";s:2:"Τ";s:4:"ðž¤";s:2:"Î¥";s:4:"ðž¥";s:2:"Φ";s:4:"ðž¦";s:2:"Χ";s:4:"ðž§";s:2:"Ψ";s:4:"ðž¨";s:2:"Ω";s:4:"ðž©";s:3:"∇";s:4:"ðžª";s:2:"α";s:4:"ðž«";s:2:"β";s:4:"ðž¬";s:2:"γ";s:4:"ðž­";s:2:"δ";s:4:"ðž®";s:2:"ε";s:4:"ðž¯";s:2:"ζ";s:4:"ðž°";s:2:"η";s:4:"ðž±";s:2:"θ";s:4:"ðž²";s:2:"ι";s:4:"ðž³";s:2:"κ";s:4:"ðž´";s:2:"λ";s:4:"ðžµ";s:2:"μ";s:4:"ðž¶";s:2:"ν";s:4:"ðž·";s:2:"ξ";s:4:"ðž¸";s:2:"ο";s:4:"ðž¹";s:2:"Ï€";s:4:"ðžº";s:2:"Ï";s:4:"ðž»";s:2:"Ï‚";s:4:"ðž¼";s:2:"σ";s:4:"ðž½";s:2:"Ï„";s:4:"ðž¾";s:2:"Ï…";s:4:"ðž¿";s:2:"φ";s:4:"ðŸ€";s:2:"χ";s:4:"ðŸ";s:2:"ψ";s:4:"ðŸ‚";s:2:"ω";s:4:"ðŸƒ";s:3:"∂";s:4:"ðŸ„";s:2:"ε";s:4:"ðŸ…";s:2:"θ";s:4:"ðŸ†";s:2:"κ";s:4:"ðŸ‡";s:2:"φ";s:4:"ðŸˆ";s:2:"Ï";s:4:"ðŸ‰";s:2:"Ï€";s:4:"ðŸŠ";s:2:"Ïœ";s:4:"ðŸ‹";s:2:"Ï";s:4:"ðŸŽ";s:1:"0";s:4:"ðŸ";s:1:"1";s:4:"ðŸ";s:1:"2";s:4:"ðŸ‘";s:1:"3";s:4:"ðŸ’";s:1:"4";s:4:"ðŸ“";s:1:"5";s:4:"ðŸ”";s:1:"6";s:4:"ðŸ•";s:1:"7";s:4:"ðŸ–";s:1:"8";s:4:"ðŸ—";s:1:"9";s:4:"ðŸ˜";s:1:"0";s:4:"ðŸ™";s:1:"1";s:4:"ðŸš";s:1:"2";s:4:"ðŸ›";s:1:"3";s:4:"ðŸœ";s:1:"4";s:4:"ðŸ";s:1:"5";s:4:"ðŸž";s:1:"6";s:4:"ðŸŸ";s:1:"7";s:4:"ðŸ ";s:1:"8";s:4:"ðŸ¡";s:1:"9";s:4:"ðŸ¢";s:1:"0";s:4:"ðŸ£";s:1:"1";s:4:"ðŸ¤";s:1:"2";s:4:"ðŸ¥";s:1:"3";s:4:"ðŸ¦";s:1:"4";s:4:"ðŸ§";s:1:"5";s:4:"ðŸ¨";s:1:"6";s:4:"ðŸ©";s:1:"7";s:4:"ðŸª";s:1:"8";s:4:"ðŸ«";s:1:"9";s:4:"ðŸ¬";s:1:"0";s:4:"ðŸ­";s:1:"1";s:4:"ðŸ®";s:1:"2";s:4:"ðŸ¯";s:1:"3";s:4:"ðŸ°";s:1:"4";s:4:"ðŸ±";s:1:"5";s:4:"ðŸ²";s:1:"6";s:4:"ðŸ³";s:1:"7";s:4:"ðŸ´";s:1:"8";s:4:"ðŸµ";s:1:"9";s:4:"ðŸ¶";s:1:"0";s:4:"ðŸ·";s:1:"1";s:4:"ðŸ¸";s:1:"2";s:4:"ðŸ¹";s:1:"3";s:4:"ðŸº";s:1:"4";s:4:"ðŸ»";s:1:"5";s:4:"ðŸ¼";s:1:"6";s:4:"ðŸ½";s:1:"7";s:4:"ðŸ¾";s:1:"8";s:4:"ðŸ¿";s:1:"9";s:4:"𞸀";s:2:"ا";s:4:"ðž¸";s:2:"ب";s:4:"𞸂";s:2:"ج";s:4:"𞸃";s:2:"د";s:4:"𞸅";s:2:"Ùˆ";s:4:"𞸆";s:2:"ز";s:4:"𞸇";s:2:"Ø­";s:4:"𞸈";s:2:"Ø·";s:4:"𞸉";s:2:"ÙŠ";s:4:"𞸊";s:2:"Ùƒ";s:4:"𞸋";s:2:"Ù„";s:4:"𞸌";s:2:"Ù…";s:4:"ðž¸";s:2:"Ù†";s:4:"𞸎";s:2:"س";s:4:"ðž¸";s:2:"ع";s:4:"ðž¸";s:2:"Ù";s:4:"𞸑";s:2:"ص";s:4:"𞸒";s:2:"Ù‚";s:4:"𞸓";s:2:"ر";s:4:"𞸔";s:2:"Ø´";s:4:"𞸕";s:2:"ت";s:4:"𞸖";s:2:"Ø«";s:4:"𞸗";s:2:"Ø®";s:4:"𞸘";s:2:"Ø°";s:4:"𞸙";s:2:"ض";s:4:"𞸚";s:2:"ظ";s:4:"𞸛";s:2:"غ";s:4:"𞸜";s:2:"Ù®";s:4:"ðž¸";s:2:"Úº";s:4:"𞸞";s:2:"Ú¡";s:4:"𞸟";s:2:"Ù¯";s:4:"𞸡";s:2:"ب";s:4:"𞸢";s:2:"ج";s:4:"𞸤";s:2:"Ù‡";s:4:"𞸧";s:2:"Ø­";s:4:"𞸩";s:2:"ÙŠ";s:4:"𞸪";s:2:"Ùƒ";s:4:"𞸫";s:2:"Ù„";s:4:"𞸬";s:2:"Ù…";s:4:"𞸭";s:2:"Ù†";s:4:"𞸮";s:2:"س";s:4:"𞸯";s:2:"ع";s:4:"𞸰";s:2:"Ù";s:4:"𞸱";s:2:"ص";s:4:"𞸲";s:2:"Ù‚";s:4:"𞸴";s:2:"Ø´";s:4:"𞸵";s:2:"ت";s:4:"𞸶";s:2:"Ø«";s:4:"𞸷";s:2:"Ø®";s:4:"𞸹";s:2:"ض";s:4:"𞸻";s:2:"غ";s:4:"𞹂";s:2:"ج";s:4:"𞹇";s:2:"Ø­";s:4:"𞹉";s:2:"ÙŠ";s:4:"𞹋";s:2:"Ù„";s:4:"ðž¹";s:2:"Ù†";s:4:"𞹎";s:2:"س";s:4:"ðž¹";s:2:"ع";s:4:"𞹑";s:2:"ص";s:4:"ðž¹’";s:2:"Ù‚";s:4:"ðž¹”";s:2:"Ø´";s:4:"ðž¹—";s:2:"Ø®";s:4:"ðž¹™";s:2:"ض";s:4:"ðž¹›";s:2:"غ";s:4:"ðž¹";s:2:"Úº";s:4:"𞹟";s:2:"Ù¯";s:4:"𞹡";s:2:"ب";s:4:"ðž¹¢";s:2:"ج";s:4:"𞹤";s:2:"Ù‡";s:4:"𞹧";s:2:"Ø­";s:4:"𞹨";s:2:"Ø·";s:4:"𞹩";s:2:"ÙŠ";s:4:"𞹪";s:2:"Ùƒ";s:4:"𞹬";s:2:"Ù…";s:4:"ðž¹­";s:2:"Ù†";s:4:"ðž¹®";s:2:"س";s:4:"𞹯";s:2:"ع";s:4:"ðž¹°";s:2:"Ù";s:4:"ðž¹±";s:2:"ص";s:4:"ðž¹²";s:2:"Ù‚";s:4:"ðž¹´";s:2:"Ø´";s:4:"ðž¹µ";s:2:"ت";s:4:"𞹶";s:2:"Ø«";s:4:"ðž¹·";s:2:"Ø®";s:4:"ðž¹¹";s:2:"ض";s:4:"𞹺";s:2:"ظ";s:4:"ðž¹»";s:2:"غ";s:4:"ðž¹¼";s:2:"Ù®";s:4:"ðž¹¾";s:2:"Ú¡";s:4:"𞺀";s:2:"ا";s:4:"ðžº";s:2:"ب";s:4:"𞺂";s:2:"ج";s:4:"𞺃";s:2:"د";s:4:"𞺄";s:2:"Ù‡";s:4:"𞺅";s:2:"Ùˆ";s:4:"𞺆";s:2:"ز";s:4:"𞺇";s:2:"Ø­";s:4:"𞺈";s:2:"Ø·";s:4:"𞺉";s:2:"ÙŠ";s:4:"𞺋";s:2:"Ù„";s:4:"𞺌";s:2:"Ù…";s:4:"ðžº";s:2:"Ù†";s:4:"𞺎";s:2:"س";s:4:"ðžº";s:2:"ع";s:4:"ðžº";s:2:"Ù";s:4:"𞺑";s:2:"ص";s:4:"𞺒";s:2:"Ù‚";s:4:"𞺓";s:2:"ر";s:4:"𞺔";s:2:"Ø´";s:4:"𞺕";s:2:"ت";s:4:"𞺖";s:2:"Ø«";s:4:"𞺗";s:2:"Ø®";s:4:"𞺘";s:2:"Ø°";s:4:"𞺙";s:2:"ض";s:4:"𞺚";s:2:"ظ";s:4:"𞺛";s:2:"غ";s:4:"𞺡";s:2:"ب";s:4:"𞺢";s:2:"ج";s:4:"𞺣";s:2:"د";s:4:"𞺥";s:2:"Ùˆ";s:4:"𞺦";s:2:"ز";s:4:"𞺧";s:2:"Ø­";s:4:"𞺨";s:2:"Ø·";s:4:"𞺩";s:2:"ÙŠ";s:4:"𞺫";s:2:"Ù„";s:4:"𞺬";s:2:"Ù…";s:4:"𞺭";s:2:"Ù†";s:4:"𞺮";s:2:"س";s:4:"𞺯";s:2:"ع";s:4:"𞺰";s:2:"Ù";s:4:"𞺱";s:2:"ص";s:4:"𞺲";s:2:"Ù‚";s:4:"𞺳";s:2:"ر";s:4:"𞺴";s:2:"Ø´";s:4:"𞺵";s:2:"ت";s:4:"𞺶";s:2:"Ø«";s:4:"𞺷";s:2:"Ø®";s:4:"𞺸";s:2:"Ø°";s:4:"𞺹";s:2:"ض";s:4:"𞺺";s:2:"ظ";s:4:"𞺻";s:2:"غ";s:4:"🄀";s:2:"0.";s:4:"ðŸ„";s:2:"0,";s:4:"🄂";s:2:"1,";s:4:"🄃";s:2:"2,";s:4:"🄄";s:2:"3,";s:4:"🄅";s:2:"4,";s:4:"🄆";s:2:"5,";s:4:"🄇";s:2:"6,";s:4:"🄈";s:2:"7,";s:4:"🄉";s:2:"8,";s:4:"🄊";s:2:"9,";s:4:"ðŸ„";s:3:"(A)";s:4:"🄑";s:3:"(B)";s:4:"🄒";s:3:"(C)";s:4:"🄓";s:3:"(D)";s:4:"🄔";s:3:"(E)";s:4:"🄕";s:3:"(F)";s:4:"🄖";s:3:"(G)";s:4:"🄗";s:3:"(H)";s:4:"🄘";s:3:"(I)";s:4:"🄙";s:3:"(J)";s:4:"🄚";s:3:"(K)";s:4:"🄛";s:3:"(L)";s:4:"🄜";s:3:"(M)";s:4:"ðŸ„";s:3:"(N)";s:4:"🄞";s:3:"(O)";s:4:"🄟";s:3:"(P)";s:4:"🄠";s:3:"(Q)";s:4:"🄡";s:3:"(R)";s:4:"🄢";s:3:"(S)";s:4:"🄣";s:3:"(T)";s:4:"🄤";s:3:"(U)";s:4:"🄥";s:3:"(V)";s:4:"🄦";s:3:"(W)";s:4:"🄧";s:3:"(X)";s:4:"🄨";s:3:"(Y)";s:4:"🄩";s:3:"(Z)";s:4:"🄪";s:7:"〔S〕";s:4:"🄫";s:1:"C";s:4:"🄬";s:1:"R";s:4:"🄭";s:2:"CD";s:4:"🄮";s:2:"WZ";s:4:"🄰";s:1:"A";s:4:"🄱";s:1:"B";s:4:"🄲";s:1:"C";s:4:"🄳";s:1:"D";s:4:"🄴";s:1:"E";s:4:"🄵";s:1:"F";s:4:"🄶";s:1:"G";s:4:"🄷";s:1:"H";s:4:"🄸";s:1:"I";s:4:"🄹";s:1:"J";s:4:"🄺";s:1:"K";s:4:"🄻";s:1:"L";s:4:"🄼";s:1:"M";s:4:"🄽";s:1:"N";s:4:"🄾";s:1:"O";s:4:"🄿";s:1:"P";s:4:"🅀";s:1:"Q";s:4:"ðŸ…";s:1:"R";s:4:"🅂";s:1:"S";s:4:"🅃";s:1:"T";s:4:"🅄";s:1:"U";s:4:"🅅";s:1:"V";s:4:"🅆";s:1:"W";s:4:"🅇";s:1:"X";s:4:"🅈";s:1:"Y";s:4:"🅉";s:1:"Z";s:4:"🅊";s:2:"HV";s:4:"🅋";s:2:"MV";s:4:"🅌";s:2:"SD";s:4:"ðŸ…";s:2:"SS";s:4:"🅎";s:3:"PPV";s:4:"ðŸ…";s:2:"WC";s:4:"🅪";s:2:"MC";s:4:"🅫";s:2:"MD";s:4:"ðŸ†";s:2:"DJ";s:4:"🈀";s:6:"ã»ã‹";s:4:"ðŸˆ";s:6:"ココ";s:4:"🈂";s:3:"サ";s:4:"ðŸˆ";s:3:"手";s:4:"🈑";s:3:"å­—";s:4:"🈒";s:3:"åŒ";s:4:"🈓";s:6:"デ";s:4:"🈔";s:3:"二";s:4:"🈕";s:3:"多";s:4:"🈖";s:3:"解";s:4:"🈗";s:3:"天";s:4:"🈘";s:3:"交";s:4:"🈙";s:3:"映";s:4:"🈚";s:3:"ç„¡";s:4:"🈛";s:3:"æ–™";s:4:"🈜";s:3:"å‰";s:4:"ðŸˆ";s:3:"後";s:4:"🈞";s:3:"å†";s:4:"🈟";s:3:"æ–°";s:4:"🈠";s:3:"åˆ";s:4:"🈡";s:3:"終";s:4:"🈢";s:3:"生";s:4:"🈣";s:3:"販";s:4:"🈤";s:3:"声";s:4:"🈥";s:3:"å¹";s:4:"🈦";s:3:"æ¼”";s:4:"🈧";s:3:"投";s:4:"🈨";s:3:"æ•";s:4:"🈩";s:3:"一";s:4:"🈪";s:3:"三";s:4:"🈫";s:3:"éŠ";s:4:"🈬";s:3:"å·¦";s:4:"🈭";s:3:"中";s:4:"🈮";s:3:"å³";s:4:"🈯";s:3:"指";s:4:"🈰";s:3:"èµ°";s:4:"🈱";s:3:"打";s:4:"🈲";s:3:"ç¦";s:4:"🈳";s:3:"空";s:4:"🈴";s:3:"åˆ";s:4:"🈵";s:3:"満";s:4:"🈶";s:3:"有";s:4:"🈷";s:3:"月";s:4:"🈸";s:3:"申";s:4:"🈹";s:3:"割";s:4:"🈺";s:3:"å–¶";s:4:"🉀";s:9:"〔本〕";s:4:"ðŸ‰";s:9:"〔三〕";s:4:"🉂";s:9:"〔二〕";s:4:"🉃";s:9:"〔安〕";s:4:"🉄";s:9:"〔点〕";s:4:"🉅";s:9:"〔打〕";s:4:"🉆";s:9:"〔盗〕";s:4:"🉇";s:9:"〔å‹ã€•";s:4:"🉈";s:9:"〔敗〕";s:4:"ðŸ‰";s:3:"å¾—";s:4:"🉑";s:3:"å¯";}
    \ No newline at end of file
    diff --git a/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/unidata/lowerCase.ser b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/unidata/lowerCase.ser
    new file mode 100755
    index 0000000..bfe7c4a
    --- /dev/null
    +++ b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/unidata/lowerCase.ser
    @@ -0,0 +1 @@
    +a:1043:{s:1:"A";s:1:"a";s:1:"B";s:1:"b";s:1:"C";s:1:"c";s:1:"D";s:1:"d";s:1:"E";s:1:"e";s:1:"F";s:1:"f";s:1:"G";s:1:"g";s:1:"H";s:1:"h";s:1:"I";s:1:"i";s:1:"J";s:1:"j";s:1:"K";s:1:"k";s:1:"L";s:1:"l";s:1:"M";s:1:"m";s:1:"N";s:1:"n";s:1:"O";s:1:"o";s:1:"P";s:1:"p";s:1:"Q";s:1:"q";s:1:"R";s:1:"r";s:1:"S";s:1:"s";s:1:"T";s:1:"t";s:1:"U";s:1:"u";s:1:"V";s:1:"v";s:1:"W";s:1:"w";s:1:"X";s:1:"x";s:1:"Y";s:1:"y";s:1:"Z";s:1:"z";s:2:"À";s:2:"à";s:2:"Ã";s:2:"á";s:2:"Â";s:2:"â";s:2:"Ã";s:2:"ã";s:2:"Ä";s:2:"ä";s:2:"Ã…";s:2:"Ã¥";s:2:"Æ";s:2:"æ";s:2:"Ç";s:2:"ç";s:2:"È";s:2:"è";s:2:"É";s:2:"é";s:2:"Ê";s:2:"ê";s:2:"Ë";s:2:"ë";s:2:"ÃŒ";s:2:"ì";s:2:"Ã";s:2:"í";s:2:"ÃŽ";s:2:"î";s:2:"Ã";s:2:"ï";s:2:"Ã";s:2:"ð";s:2:"Ñ";s:2:"ñ";s:2:"Ã’";s:2:"ò";s:2:"Ó";s:2:"ó";s:2:"Ô";s:2:"ô";s:2:"Õ";s:2:"õ";s:2:"Ö";s:2:"ö";s:2:"Ø";s:2:"ø";s:2:"Ù";s:2:"ù";s:2:"Ú";s:2:"ú";s:2:"Û";s:2:"û";s:2:"Ãœ";s:2:"ü";s:2:"Ã";s:2:"ý";s:2:"Þ";s:2:"þ";s:2:"Ä€";s:2:"Ä";s:2:"Ä‚";s:2:"ă";s:2:"Ä„";s:2:"Ä…";s:2:"Ć";s:2:"ć";s:2:"Ĉ";s:2:"ĉ";s:2:"ÄŠ";s:2:"Ä‹";s:2:"ÄŒ";s:2:"Ä";s:2:"ÄŽ";s:2:"Ä";s:2:"Ä";s:2:"Ä‘";s:2:"Ä’";s:2:"Ä“";s:2:"Ä”";s:2:"Ä•";s:2:"Ä–";s:2:"Ä—";s:2:"Ę";s:2:"Ä™";s:2:"Äš";s:2:"Ä›";s:2:"Äœ";s:2:"Ä";s:2:"Äž";s:2:"ÄŸ";s:2:"Ä ";s:2:"Ä¡";s:2:"Ä¢";s:2:"Ä£";s:2:"Ĥ";s:2:"Ä¥";s:2:"Ħ";s:2:"ħ";s:2:"Ĩ";s:2:"Ä©";s:2:"Ī";s:2:"Ä«";s:2:"Ĭ";s:2:"Ä­";s:2:"Ä®";s:2:"į";s:2:"Ä°";s:1:"i";s:2:"IJ";s:2:"ij";s:2:"Ä´";s:2:"ĵ";s:2:"Ķ";s:2:"Ä·";s:2:"Ĺ";s:2:"ĺ";s:2:"Ä»";s:2:"ļ";s:2:"Ľ";s:2:"ľ";s:2:"Ä¿";s:2:"Å€";s:2:"Å";s:2:"Å‚";s:2:"Ń";s:2:"Å„";s:2:"Å…";s:2:"ņ";s:2:"Ň";s:2:"ň";s:2:"ÅŠ";s:2:"Å‹";s:2:"ÅŒ";s:2:"Å";s:2:"ÅŽ";s:2:"Å";s:2:"Å";s:2:"Å‘";s:2:"Å’";s:2:"Å“";s:2:"Å”";s:2:"Å•";s:2:"Å–";s:2:"Å—";s:2:"Ř";s:2:"Å™";s:2:"Åš";s:2:"Å›";s:2:"Åœ";s:2:"Å";s:2:"Åž";s:2:"ÅŸ";s:2:"Å ";s:2:"Å¡";s:2:"Å¢";s:2:"Å£";s:2:"Ť";s:2:"Å¥";s:2:"Ŧ";s:2:"ŧ";s:2:"Ũ";s:2:"Å©";s:2:"Ū";s:2:"Å«";s:2:"Ŭ";s:2:"Å­";s:2:"Å®";s:2:"ů";s:2:"Å°";s:2:"ű";s:2:"Ų";s:2:"ų";s:2:"Å´";s:2:"ŵ";s:2:"Ŷ";s:2:"Å·";s:2:"Ÿ";s:2:"ÿ";s:2:"Ź";s:2:"ź";s:2:"Å»";s:2:"ż";s:2:"Ž";s:2:"ž";s:2:"Æ";s:2:"É“";s:2:"Æ‚";s:2:"ƃ";s:2:"Æ„";s:2:"Æ…";s:2:"Ɔ";s:2:"É”";s:2:"Ƈ";s:2:"ƈ";s:2:"Ɖ";s:2:"É–";s:2:"ÆŠ";s:2:"É—";s:2:"Æ‹";s:2:"ÆŒ";s:2:"ÆŽ";s:2:"Ç";s:2:"Æ";s:2:"É™";s:2:"Æ";s:2:"É›";s:2:"Æ‘";s:2:"Æ’";s:2:"Æ“";s:2:"É ";s:2:"Æ”";s:2:"É£";s:2:"Æ–";s:2:"É©";s:2:"Æ—";s:2:"ɨ";s:2:"Ƙ";s:2:"Æ™";s:2:"Æœ";s:2:"ɯ";s:2:"Æ";s:2:"ɲ";s:2:"ÆŸ";s:2:"ɵ";s:2:"Æ ";s:2:"Æ¡";s:2:"Æ¢";s:2:"Æ£";s:2:"Ƥ";s:2:"Æ¥";s:2:"Ʀ";s:2:"Ê€";s:2:"Ƨ";s:2:"ƨ";s:2:"Æ©";s:2:"ʃ";s:2:"Ƭ";s:2:"Æ­";s:2:"Æ®";s:2:"ʈ";s:2:"Ư";s:2:"Æ°";s:2:"Ʊ";s:2:"ÊŠ";s:2:"Ʋ";s:2:"Ê‹";s:2:"Ƴ";s:2:"Æ´";s:2:"Ƶ";s:2:"ƶ";s:2:"Æ·";s:2:"Ê’";s:2:"Ƹ";s:2:"ƹ";s:2:"Ƽ";s:2:"ƽ";s:2:"Ç„";s:2:"dž";s:2:"Ç…";s:2:"dž";s:2:"LJ";s:2:"lj";s:2:"Lj";s:2:"lj";s:2:"ÇŠ";s:2:"ÇŒ";s:2:"Ç‹";s:2:"ÇŒ";s:2:"Ç";s:2:"ÇŽ";s:2:"Ç";s:2:"Ç";s:2:"Ç‘";s:2:"Ç’";s:2:"Ç“";s:2:"Ç”";s:2:"Ç•";s:2:"Ç–";s:2:"Ç—";s:2:"ǘ";s:2:"Ç™";s:2:"Çš";s:2:"Ç›";s:2:"Çœ";s:2:"Çž";s:2:"ÇŸ";s:2:"Ç ";s:2:"Ç¡";s:2:"Ç¢";s:2:"Ç£";s:2:"Ǥ";s:2:"Ç¥";s:2:"Ǧ";s:2:"ǧ";s:2:"Ǩ";s:2:"Ç©";s:2:"Ǫ";s:2:"Ç«";s:2:"Ǭ";s:2:"Ç­";s:2:"Ç®";s:2:"ǯ";s:2:"DZ";s:2:"dz";s:2:"Dz";s:2:"dz";s:2:"Ç´";s:2:"ǵ";s:2:"Ƕ";s:2:"Æ•";s:2:"Ç·";s:2:"Æ¿";s:2:"Ǹ";s:2:"ǹ";s:2:"Ǻ";s:2:"Ç»";s:2:"Ǽ";s:2:"ǽ";s:2:"Ǿ";s:2:"Ç¿";s:2:"È€";s:2:"È";s:2:"È‚";s:2:"ȃ";s:2:"È„";s:2:"È…";s:2:"Ȇ";s:2:"ȇ";s:2:"Ȉ";s:2:"ȉ";s:2:"ÈŠ";s:2:"È‹";s:2:"ÈŒ";s:2:"È";s:2:"ÈŽ";s:2:"È";s:2:"È";s:2:"È‘";s:2:"È’";s:2:"È“";s:2:"È”";s:2:"È•";s:2:"È–";s:2:"È—";s:2:"Ș";s:2:"È™";s:2:"Èš";s:2:"È›";s:2:"Èœ";s:2:"È";s:2:"Èž";s:2:"ÈŸ";s:2:"È ";s:2:"Æž";s:2:"È¢";s:2:"È£";s:2:"Ȥ";s:2:"È¥";s:2:"Ȧ";s:2:"ȧ";s:2:"Ȩ";s:2:"È©";s:2:"Ȫ";s:2:"È«";s:2:"Ȭ";s:2:"È­";s:2:"È®";s:2:"ȯ";s:2:"È°";s:2:"ȱ";s:2:"Ȳ";s:2:"ȳ";s:2:"Ⱥ";s:3:"â±¥";s:2:"È»";s:2:"ȼ";s:2:"Ƚ";s:2:"Æš";s:2:"Ⱦ";s:3:"ⱦ";s:2:"É";s:2:"É‚";s:2:"Ƀ";s:2:"Æ€";s:2:"É„";s:2:"ʉ";s:2:"É…";s:2:"ÊŒ";s:2:"Ɇ";s:2:"ɇ";s:2:"Ɉ";s:2:"ɉ";s:2:"ÉŠ";s:2:"É‹";s:2:"ÉŒ";s:2:"É";s:2:"ÉŽ";s:2:"É";s:2:"Í°";s:2:"ͱ";s:2:"Ͳ";s:2:"ͳ";s:2:"Ͷ";s:2:"Í·";s:2:"Ά";s:2:"ά";s:2:"Έ";s:2:"έ";s:2:"Ή";s:2:"ή";s:2:"Ί";s:2:"ί";s:2:"ÎŒ";s:2:"ÏŒ";s:2:"ÎŽ";s:2:"Ï";s:2:"Î";s:2:"ÏŽ";s:2:"Α";s:2:"α";s:2:"Î’";s:2:"β";s:2:"Γ";s:2:"γ";s:2:"Δ";s:2:"δ";s:2:"Ε";s:2:"ε";s:2:"Ζ";s:2:"ζ";s:2:"Η";s:2:"η";s:2:"Θ";s:2:"θ";s:2:"Ι";s:2:"ι";s:2:"Κ";s:2:"κ";s:2:"Λ";s:2:"λ";s:2:"Îœ";s:2:"μ";s:2:"Î";s:2:"ν";s:2:"Ξ";s:2:"ξ";s:2:"Ο";s:2:"ο";s:2:"Π";s:2:"Ï€";s:2:"Ρ";s:2:"Ï";s:2:"Σ";s:2:"σ";s:2:"Τ";s:2:"Ï„";s:2:"Î¥";s:2:"Ï…";s:2:"Φ";s:2:"φ";s:2:"Χ";s:2:"χ";s:2:"Ψ";s:2:"ψ";s:2:"Ω";s:2:"ω";s:2:"Ϊ";s:2:"ÏŠ";s:2:"Ϋ";s:2:"Ï‹";s:2:"Ï";s:2:"Ï—";s:2:"Ϙ";s:2:"Ï™";s:2:"Ïš";s:2:"Ï›";s:2:"Ïœ";s:2:"Ï";s:2:"Ïž";s:2:"ÏŸ";s:2:"Ï ";s:2:"Ï¡";s:2:"Ï¢";s:2:"Ï£";s:2:"Ϥ";s:2:"Ï¥";s:2:"Ϧ";s:2:"ϧ";s:2:"Ϩ";s:2:"Ï©";s:2:"Ϫ";s:2:"Ï«";s:2:"Ϭ";s:2:"Ï­";s:2:"Ï®";s:2:"ϯ";s:2:"Ï´";s:2:"θ";s:2:"Ï·";s:2:"ϸ";s:2:"Ϲ";s:2:"ϲ";s:2:"Ϻ";s:2:"Ï»";s:2:"Ͻ";s:2:"Í»";s:2:"Ͼ";s:2:"ͼ";s:2:"Ï¿";s:2:"ͽ";s:2:"Ѐ";s:2:"Ñ";s:2:"Ð";s:2:"Ñ‘";s:2:"Ђ";s:2:"Ñ’";s:2:"Ѓ";s:2:"Ñ“";s:2:"Є";s:2:"Ñ”";s:2:"Ð…";s:2:"Ñ•";s:2:"І";s:2:"Ñ–";s:2:"Ї";s:2:"Ñ—";s:2:"Ј";s:2:"ј";s:2:"Љ";s:2:"Ñ™";s:2:"Њ";s:2:"Ñš";s:2:"Ћ";s:2:"Ñ›";s:2:"ÐŒ";s:2:"Ñœ";s:2:"Ð";s:2:"Ñ";s:2:"ÐŽ";s:2:"Ñž";s:2:"Ð";s:2:"ÑŸ";s:2:"Ð";s:2:"а";s:2:"Б";s:2:"б";s:2:"Ð’";s:2:"в";s:2:"Г";s:2:"г";s:2:"Д";s:2:"д";s:2:"Е";s:2:"е";s:2:"Ж";s:2:"ж";s:2:"З";s:2:"з";s:2:"И";s:2:"и";s:2:"Й";s:2:"й";s:2:"К";s:2:"к";s:2:"Л";s:2:"л";s:2:"Ðœ";s:2:"м";s:2:"Ð";s:2:"н";s:2:"О";s:2:"о";s:2:"П";s:2:"п";s:2:"Р";s:2:"Ñ€";s:2:"С";s:2:"Ñ";s:2:"Т";s:2:"Ñ‚";s:2:"У";s:2:"у";s:2:"Ф";s:2:"Ñ„";s:2:"Ð¥";s:2:"Ñ…";s:2:"Ц";s:2:"ц";s:2:"Ч";s:2:"ч";s:2:"Ш";s:2:"ш";s:2:"Щ";s:2:"щ";s:2:"Ъ";s:2:"ÑŠ";s:2:"Ы";s:2:"Ñ‹";s:2:"Ь";s:2:"ÑŒ";s:2:"Э";s:2:"Ñ";s:2:"Ю";s:2:"ÑŽ";s:2:"Я";s:2:"Ñ";s:2:"Ñ ";s:2:"Ñ¡";s:2:"Ñ¢";s:2:"Ñ£";s:2:"Ѥ";s:2:"Ñ¥";s:2:"Ѧ";s:2:"ѧ";s:2:"Ѩ";s:2:"Ñ©";s:2:"Ѫ";s:2:"Ñ«";s:2:"Ѭ";s:2:"Ñ­";s:2:"Ñ®";s:2:"ѯ";s:2:"Ñ°";s:2:"ѱ";s:2:"Ѳ";s:2:"ѳ";s:2:"Ñ´";s:2:"ѵ";s:2:"Ѷ";s:2:"Ñ·";s:2:"Ѹ";s:2:"ѹ";s:2:"Ѻ";s:2:"Ñ»";s:2:"Ѽ";s:2:"ѽ";s:2:"Ѿ";s:2:"Ñ¿";s:2:"Ò€";s:2:"Ò";s:2:"ÒŠ";s:2:"Ò‹";s:2:"ÒŒ";s:2:"Ò";s:2:"ÒŽ";s:2:"Ò";s:2:"Ò";s:2:"Ò‘";s:2:"Ò’";s:2:"Ò“";s:2:"Ò”";s:2:"Ò•";s:2:"Ò–";s:2:"Ò—";s:2:"Ò˜";s:2:"Ò™";s:2:"Òš";s:2:"Ò›";s:2:"Òœ";s:2:"Ò";s:2:"Òž";s:2:"ÒŸ";s:2:"Ò ";s:2:"Ò¡";s:2:"Ò¢";s:2:"Ò£";s:2:"Ò¤";s:2:"Ò¥";s:2:"Ò¦";s:2:"Ò§";s:2:"Ò¨";s:2:"Ò©";s:2:"Òª";s:2:"Ò«";s:2:"Ò¬";s:2:"Ò­";s:2:"Ò®";s:2:"Ò¯";s:2:"Ò°";s:2:"Ò±";s:2:"Ò²";s:2:"Ò³";s:2:"Ò´";s:2:"Òµ";s:2:"Ò¶";s:2:"Ò·";s:2:"Ò¸";s:2:"Ò¹";s:2:"Òº";s:2:"Ò»";s:2:"Ò¼";s:2:"Ò½";s:2:"Ò¾";s:2:"Ò¿";s:2:"Ó€";s:2:"Ó";s:2:"Ó";s:2:"Ó‚";s:2:"Óƒ";s:2:"Ó„";s:2:"Ó…";s:2:"Ó†";s:2:"Ó‡";s:2:"Óˆ";s:2:"Ó‰";s:2:"ÓŠ";s:2:"Ó‹";s:2:"ÓŒ";s:2:"Ó";s:2:"ÓŽ";s:2:"Ó";s:2:"Ó‘";s:2:"Ó’";s:2:"Ó“";s:2:"Ó”";s:2:"Ó•";s:2:"Ó–";s:2:"Ó—";s:2:"Ó˜";s:2:"Ó™";s:2:"Óš";s:2:"Ó›";s:2:"Óœ";s:2:"Ó";s:2:"Óž";s:2:"ÓŸ";s:2:"Ó ";s:2:"Ó¡";s:2:"Ó¢";s:2:"Ó£";s:2:"Ó¤";s:2:"Ó¥";s:2:"Ó¦";s:2:"Ó§";s:2:"Ó¨";s:2:"Ó©";s:2:"Óª";s:2:"Ó«";s:2:"Ó¬";s:2:"Ó­";s:2:"Ó®";s:2:"Ó¯";s:2:"Ó°";s:2:"Ó±";s:2:"Ó²";s:2:"Ó³";s:2:"Ó´";s:2:"Óµ";s:2:"Ó¶";s:2:"Ó·";s:2:"Ó¸";s:2:"Ó¹";s:2:"Óº";s:2:"Ó»";s:2:"Ó¼";s:2:"Ó½";s:2:"Ó¾";s:2:"Ó¿";s:2:"Ô€";s:2:"Ô";s:2:"Ô‚";s:2:"Ôƒ";s:2:"Ô„";s:2:"Ô…";s:2:"Ô†";s:2:"Ô‡";s:2:"Ôˆ";s:2:"Ô‰";s:2:"ÔŠ";s:2:"Ô‹";s:2:"ÔŒ";s:2:"Ô";s:2:"ÔŽ";s:2:"Ô";s:2:"Ô";s:2:"Ô‘";s:2:"Ô’";s:2:"Ô“";s:2:"Ô”";s:2:"Ô•";s:2:"Ô–";s:2:"Ô—";s:2:"Ô˜";s:2:"Ô™";s:2:"Ôš";s:2:"Ô›";s:2:"Ôœ";s:2:"Ô";s:2:"Ôž";s:2:"ÔŸ";s:2:"Ô ";s:2:"Ô¡";s:2:"Ô¢";s:2:"Ô£";s:2:"Ô¤";s:2:"Ô¥";s:2:"Ô¦";s:2:"Ô§";s:2:"Ô±";s:2:"Õ¡";s:2:"Ô²";s:2:"Õ¢";s:2:"Ô³";s:2:"Õ£";s:2:"Ô´";s:2:"Õ¤";s:2:"Ôµ";s:2:"Õ¥";s:2:"Ô¶";s:2:"Õ¦";s:2:"Ô·";s:2:"Õ§";s:2:"Ô¸";s:2:"Õ¨";s:2:"Ô¹";s:2:"Õ©";s:2:"Ôº";s:2:"Õª";s:2:"Ô»";s:2:"Õ«";s:2:"Ô¼";s:2:"Õ¬";s:2:"Ô½";s:2:"Õ­";s:2:"Ô¾";s:2:"Õ®";s:2:"Ô¿";s:2:"Õ¯";s:2:"Õ€";s:2:"Õ°";s:2:"Õ";s:2:"Õ±";s:2:"Õ‚";s:2:"Õ²";s:2:"Õƒ";s:2:"Õ³";s:2:"Õ„";s:2:"Õ´";s:2:"Õ…";s:2:"Õµ";s:2:"Õ†";s:2:"Õ¶";s:2:"Õ‡";s:2:"Õ·";s:2:"Õˆ";s:2:"Õ¸";s:2:"Õ‰";s:2:"Õ¹";s:2:"ÕŠ";s:2:"Õº";s:2:"Õ‹";s:2:"Õ»";s:2:"ÕŒ";s:2:"Õ¼";s:2:"Õ";s:2:"Õ½";s:2:"ÕŽ";s:2:"Õ¾";s:2:"Õ";s:2:"Õ¿";s:2:"Õ";s:2:"Ö€";s:2:"Õ‘";s:2:"Ö";s:2:"Õ’";s:2:"Ö‚";s:2:"Õ“";s:2:"Öƒ";s:2:"Õ”";s:2:"Ö„";s:2:"Õ•";s:2:"Ö…";s:2:"Õ–";s:2:"Ö†";s:3:"á‚ ";s:3:"â´€";s:3:"á‚¡";s:3:"â´";s:3:"á‚¢";s:3:"â´‚";s:3:"á‚£";s:3:"â´ƒ";s:3:"Ⴄ";s:3:"â´„";s:3:"á‚¥";s:3:"â´…";s:3:"Ⴆ";s:3:"â´†";s:3:"Ⴇ";s:3:"â´‡";s:3:"Ⴈ";s:3:"â´ˆ";s:3:"á‚©";s:3:"â´‰";s:3:"Ⴊ";s:3:"â´Š";s:3:"á‚«";s:3:"â´‹";s:3:"Ⴌ";s:3:"â´Œ";s:3:"á‚­";s:3:"â´";s:3:"á‚®";s:3:"â´Ž";s:3:"Ⴏ";s:3:"â´";s:3:"á‚°";s:3:"â´";s:3:"Ⴑ";s:3:"â´‘";s:3:"Ⴒ";s:3:"â´’";s:3:"Ⴓ";s:3:"â´“";s:3:"á‚´";s:3:"â´”";s:3:"Ⴕ";s:3:"â´•";s:3:"Ⴖ";s:3:"â´–";s:3:"á‚·";s:3:"â´—";s:3:"Ⴘ";s:3:"â´˜";s:3:"Ⴙ";s:3:"â´™";s:3:"Ⴚ";s:3:"â´š";s:3:"á‚»";s:3:"â´›";s:3:"Ⴜ";s:3:"â´œ";s:3:"Ⴝ";s:3:"â´";s:3:"Ⴞ";s:3:"â´ž";s:3:"á‚¿";s:3:"â´Ÿ";s:3:"Ⴠ";s:3:"â´ ";s:3:"áƒ";s:3:"â´¡";s:3:"Ⴢ";s:3:"â´¢";s:3:"Ⴣ";s:3:"â´£";s:3:"Ⴤ";s:3:"â´¤";s:3:"Ⴥ";s:3:"â´¥";s:3:"Ⴧ";s:3:"â´§";s:3:"áƒ";s:3:"â´­";s:3:"Ḁ";s:3:"á¸";s:3:"Ḃ";s:3:"ḃ";s:3:"Ḅ";s:3:"ḅ";s:3:"Ḇ";s:3:"ḇ";s:3:"Ḉ";s:3:"ḉ";s:3:"Ḋ";s:3:"ḋ";s:3:"Ḍ";s:3:"á¸";s:3:"Ḏ";s:3:"á¸";s:3:"á¸";s:3:"ḑ";s:3:"Ḓ";s:3:"ḓ";s:3:"Ḕ";s:3:"ḕ";s:3:"Ḗ";s:3:"ḗ";s:3:"Ḙ";s:3:"ḙ";s:3:"Ḛ";s:3:"ḛ";s:3:"Ḝ";s:3:"á¸";s:3:"Ḟ";s:3:"ḟ";s:3:"Ḡ";s:3:"ḡ";s:3:"Ḣ";s:3:"ḣ";s:3:"Ḥ";s:3:"ḥ";s:3:"Ḧ";s:3:"ḧ";s:3:"Ḩ";s:3:"ḩ";s:3:"Ḫ";s:3:"ḫ";s:3:"Ḭ";s:3:"ḭ";s:3:"Ḯ";s:3:"ḯ";s:3:"Ḱ";s:3:"ḱ";s:3:"Ḳ";s:3:"ḳ";s:3:"Ḵ";s:3:"ḵ";s:3:"Ḷ";s:3:"ḷ";s:3:"Ḹ";s:3:"ḹ";s:3:"Ḻ";s:3:"ḻ";s:3:"Ḽ";s:3:"ḽ";s:3:"Ḿ";s:3:"ḿ";s:3:"á¹€";s:3:"á¹";s:3:"Ṃ";s:3:"ṃ";s:3:"Ṅ";s:3:"á¹…";s:3:"Ṇ";s:3:"ṇ";s:3:"Ṉ";s:3:"ṉ";s:3:"Ṋ";s:3:"ṋ";s:3:"Ṍ";s:3:"á¹";s:3:"Ṏ";s:3:"á¹";s:3:"á¹";s:3:"ṑ";s:3:"á¹’";s:3:"ṓ";s:3:"á¹”";s:3:"ṕ";s:3:"á¹–";s:3:"á¹—";s:3:"Ṙ";s:3:"á¹™";s:3:"Ṛ";s:3:"á¹›";s:3:"Ṝ";s:3:"á¹";s:3:"Ṟ";s:3:"ṟ";s:3:"á¹ ";s:3:"ṡ";s:3:"á¹¢";s:3:"á¹£";s:3:"Ṥ";s:3:"á¹¥";s:3:"Ṧ";s:3:"ṧ";s:3:"Ṩ";s:3:"ṩ";s:3:"Ṫ";s:3:"ṫ";s:3:"Ṭ";s:3:"á¹­";s:3:"á¹®";s:3:"ṯ";s:3:"á¹°";s:3:"á¹±";s:3:"á¹²";s:3:"á¹³";s:3:"á¹´";s:3:"á¹µ";s:3:"Ṷ";s:3:"á¹·";s:3:"Ṹ";s:3:"á¹¹";s:3:"Ṻ";s:3:"á¹»";s:3:"á¹¼";s:3:"á¹½";s:3:"á¹¾";s:3:"ṿ";s:3:"Ẁ";s:3:"áº";s:3:"Ẃ";s:3:"ẃ";s:3:"Ẅ";s:3:"ẅ";s:3:"Ẇ";s:3:"ẇ";s:3:"Ẉ";s:3:"ẉ";s:3:"Ẋ";s:3:"ẋ";s:3:"Ẍ";s:3:"áº";s:3:"Ẏ";s:3:"áº";s:3:"áº";s:3:"ẑ";s:3:"Ẓ";s:3:"ẓ";s:3:"Ẕ";s:3:"ẕ";s:3:"ẞ";s:2:"ß";s:3:"Ạ";s:3:"ạ";s:3:"Ả";s:3:"ả";s:3:"Ấ";s:3:"ấ";s:3:"Ầ";s:3:"ầ";s:3:"Ẩ";s:3:"ẩ";s:3:"Ẫ";s:3:"ẫ";s:3:"Ậ";s:3:"ậ";s:3:"Ắ";s:3:"ắ";s:3:"Ằ";s:3:"ằ";s:3:"Ẳ";s:3:"ẳ";s:3:"Ẵ";s:3:"ẵ";s:3:"Ặ";s:3:"ặ";s:3:"Ẹ";s:3:"ẹ";s:3:"Ẻ";s:3:"ẻ";s:3:"Ẽ";s:3:"ẽ";s:3:"Ế";s:3:"ế";s:3:"Ề";s:3:"á»";s:3:"Ể";s:3:"ể";s:3:"Ễ";s:3:"á»…";s:3:"Ệ";s:3:"ệ";s:3:"Ỉ";s:3:"ỉ";s:3:"Ị";s:3:"ị";s:3:"Ọ";s:3:"á»";s:3:"Ỏ";s:3:"á»";s:3:"á»";s:3:"ố";s:3:"á»’";s:3:"ồ";s:3:"á»”";s:3:"ổ";s:3:"á»–";s:3:"á»—";s:3:"Ộ";s:3:"á»™";s:3:"Ớ";s:3:"á»›";s:3:"Ờ";s:3:"á»";s:3:"Ở";s:3:"ở";s:3:"á» ";s:3:"ỡ";s:3:"Ợ";s:3:"ợ";s:3:"Ụ";s:3:"ụ";s:3:"Ủ";s:3:"ủ";s:3:"Ứ";s:3:"ứ";s:3:"Ừ";s:3:"ừ";s:3:"Ử";s:3:"á»­";s:3:"á»®";s:3:"ữ";s:3:"á»°";s:3:"á»±";s:3:"Ỳ";s:3:"ỳ";s:3:"á»´";s:3:"ỵ";s:3:"Ỷ";s:3:"á»·";s:3:"Ỹ";s:3:"ỹ";s:3:"Ỻ";s:3:"á»»";s:3:"Ỽ";s:3:"ỽ";s:3:"Ỿ";s:3:"ỿ";s:3:"Ἀ";s:3:"á¼€";s:3:"Ἁ";s:3:"á¼";s:3:"Ἂ";s:3:"ἂ";s:3:"Ἃ";s:3:"ἃ";s:3:"Ἄ";s:3:"ἄ";s:3:"á¼";s:3:"á¼…";s:3:"Ἆ";s:3:"ἆ";s:3:"á¼";s:3:"ἇ";s:3:"Ἐ";s:3:"á¼";s:3:"á¼™";s:3:"ἑ";s:3:"Ἒ";s:3:"á¼’";s:3:"á¼›";s:3:"ἓ";s:3:"Ἔ";s:3:"á¼”";s:3:"á¼";s:3:"ἕ";s:3:"Ἠ";s:3:"á¼ ";s:3:"Ἡ";s:3:"ἡ";s:3:"Ἢ";s:3:"á¼¢";s:3:"Ἣ";s:3:"á¼£";s:3:"Ἤ";s:3:"ἤ";s:3:"á¼­";s:3:"á¼¥";s:3:"á¼®";s:3:"ἦ";s:3:"Ἧ";s:3:"ἧ";s:3:"Ἰ";s:3:"á¼°";s:3:"á¼¹";s:3:"á¼±";s:3:"Ἲ";s:3:"á¼²";s:3:"á¼»";s:3:"á¼³";s:3:"á¼¼";s:3:"á¼´";s:3:"á¼½";s:3:"á¼µ";s:3:"á¼¾";s:3:"ἶ";s:3:"Ἷ";s:3:"á¼·";s:3:"Ὀ";s:3:"á½€";s:3:"Ὁ";s:3:"á½";s:3:"Ὂ";s:3:"ὂ";s:3:"Ὃ";s:3:"ὃ";s:3:"Ὄ";s:3:"ὄ";s:3:"á½";s:3:"á½…";s:3:"á½™";s:3:"ὑ";s:3:"á½›";s:3:"ὓ";s:3:"á½";s:3:"ὕ";s:3:"Ὗ";s:3:"á½—";s:3:"Ὠ";s:3:"á½ ";s:3:"Ὡ";s:3:"ὡ";s:3:"Ὢ";s:3:"á½¢";s:3:"Ὣ";s:3:"á½£";s:3:"Ὤ";s:3:"ὤ";s:3:"á½­";s:3:"á½¥";s:3:"á½®";s:3:"ὦ";s:3:"Ὧ";s:3:"ὧ";s:3:"ᾈ";s:3:"á¾€";s:3:"ᾉ";s:3:"á¾";s:3:"ᾊ";s:3:"ᾂ";s:3:"ᾋ";s:3:"ᾃ";s:3:"ᾌ";s:3:"ᾄ";s:3:"á¾";s:3:"á¾…";s:3:"ᾎ";s:3:"ᾆ";s:3:"á¾";s:3:"ᾇ";s:3:"ᾘ";s:3:"á¾";s:3:"á¾™";s:3:"ᾑ";s:3:"ᾚ";s:3:"á¾’";s:3:"á¾›";s:3:"ᾓ";s:3:"ᾜ";s:3:"á¾”";s:3:"á¾";s:3:"ᾕ";s:3:"ᾞ";s:3:"á¾–";s:3:"ᾟ";s:3:"á¾—";s:3:"ᾨ";s:3:"á¾ ";s:3:"ᾩ";s:3:"ᾡ";s:3:"ᾪ";s:3:"á¾¢";s:3:"ᾫ";s:3:"á¾£";s:3:"ᾬ";s:3:"ᾤ";s:3:"á¾­";s:3:"á¾¥";s:3:"á¾®";s:3:"ᾦ";s:3:"ᾯ";s:3:"ᾧ";s:3:"Ᾰ";s:3:"á¾°";s:3:"á¾¹";s:3:"á¾±";s:3:"Ὰ";s:3:"á½°";s:3:"á¾»";s:3:"á½±";s:3:"á¾¼";s:3:"á¾³";s:3:"Ὲ";s:3:"á½²";s:3:"Έ";s:3:"á½³";s:3:"á¿Š";s:3:"á½´";s:3:"á¿‹";s:3:"á½µ";s:3:"á¿Œ";s:3:"ῃ";s:3:"Ῐ";s:3:"á¿";s:3:"á¿™";s:3:"á¿‘";s:3:"á¿š";s:3:"ὶ";s:3:"á¿›";s:3:"á½·";s:3:"Ῠ";s:3:"á¿ ";s:3:"á¿©";s:3:"á¿¡";s:3:"Ὺ";s:3:"ὺ";s:3:"á¿«";s:3:"á½»";s:3:"Ῥ";s:3:"á¿¥";s:3:"Ὸ";s:3:"ὸ";s:3:"Ό";s:3:"á½¹";s:3:"Ὼ";s:3:"á½¼";s:3:"á¿»";s:3:"á½½";s:3:"ῼ";s:3:"ῳ";s:3:"Ω";s:2:"ω";s:3:"K";s:1:"k";s:3:"â„«";s:2:"Ã¥";s:3:"Ⅎ";s:3:"â…Ž";s:3:"â… ";s:3:"â…°";s:3:"â…¡";s:3:"â…±";s:3:"â…¢";s:3:"â…²";s:3:"â…£";s:3:"â…³";s:3:"â…¤";s:3:"â…´";s:3:"â…¥";s:3:"â…µ";s:3:"â…¦";s:3:"â…¶";s:3:"â…§";s:3:"â…·";s:3:"â…¨";s:3:"â…¸";s:3:"â…©";s:3:"â…¹";s:3:"â…ª";s:3:"â…º";s:3:"â…«";s:3:"â…»";s:3:"â…¬";s:3:"â…¼";s:3:"â…­";s:3:"â…½";s:3:"â…®";s:3:"â…¾";s:3:"â…¯";s:3:"â…¿";s:3:"Ↄ";s:3:"ↄ";s:3:"â’¶";s:3:"â“";s:3:"â’·";s:3:"â“‘";s:3:"â’¸";s:3:"â“’";s:3:"â’¹";s:3:"â““";s:3:"â’º";s:3:"â“”";s:3:"â’»";s:3:"â“•";s:3:"â’¼";s:3:"â“–";s:3:"â’½";s:3:"â“—";s:3:"â’¾";s:3:"ⓘ";s:3:"â’¿";s:3:"â“™";s:3:"â“€";s:3:"â“š";s:3:"â“";s:3:"â“›";s:3:"â“‚";s:3:"â“œ";s:3:"Ⓝ";s:3:"â“";s:3:"â“„";s:3:"â“ž";s:3:"â“…";s:3:"â“Ÿ";s:3:"Ⓠ";s:3:"â“ ";s:3:"Ⓡ";s:3:"â“¡";s:3:"Ⓢ";s:3:"â“¢";s:3:"Ⓣ";s:3:"â“£";s:3:"â“Š";s:3:"ⓤ";s:3:"â“‹";s:3:"â“¥";s:3:"â“Œ";s:3:"ⓦ";s:3:"â“";s:3:"ⓧ";s:3:"â“Ž";s:3:"ⓨ";s:3:"â“";s:3:"â“©";s:3:"â°€";s:3:"â°°";s:3:"â°";s:3:"â°±";s:3:"â°‚";s:3:"â°²";s:3:"â°ƒ";s:3:"â°³";s:3:"â°„";s:3:"â°´";s:3:"â°…";s:3:"â°µ";s:3:"â°†";s:3:"â°¶";s:3:"â°‡";s:3:"â°·";s:3:"â°ˆ";s:3:"â°¸";s:3:"â°‰";s:3:"â°¹";s:3:"â°Š";s:3:"â°º";s:3:"â°‹";s:3:"â°»";s:3:"â°Œ";s:3:"â°¼";s:3:"â°";s:3:"â°½";s:3:"â°Ž";s:3:"â°¾";s:3:"â°";s:3:"â°¿";s:3:"â°";s:3:"â±€";s:3:"â°‘";s:3:"â±";s:3:"â°’";s:3:"ⱂ";s:3:"â°“";s:3:"ⱃ";s:3:"â°”";s:3:"ⱄ";s:3:"â°•";s:3:"â±…";s:3:"â°–";s:3:"ⱆ";s:3:"â°—";s:3:"ⱇ";s:3:"â°˜";s:3:"ⱈ";s:3:"â°™";s:3:"ⱉ";s:3:"â°š";s:3:"ⱊ";s:3:"â°›";s:3:"ⱋ";s:3:"â°œ";s:3:"ⱌ";s:3:"â°";s:3:"â±";s:3:"â°ž";s:3:"ⱎ";s:3:"â°Ÿ";s:3:"â±";s:3:"â° ";s:3:"â±";s:3:"â°¡";s:3:"ⱑ";s:3:"â°¢";s:3:"â±’";s:3:"â°£";s:3:"ⱓ";s:3:"â°¤";s:3:"â±”";s:3:"â°¥";s:3:"ⱕ";s:3:"â°¦";s:3:"â±–";s:3:"â°§";s:3:"â±—";s:3:"â°¨";s:3:"ⱘ";s:3:"â°©";s:3:"â±™";s:3:"â°ª";s:3:"ⱚ";s:3:"â°«";s:3:"â±›";s:3:"â°¬";s:3:"ⱜ";s:3:"â°­";s:3:"â±";s:3:"â°®";s:3:"ⱞ";s:3:"â± ";s:3:"ⱡ";s:3:"â±¢";s:2:"É«";s:3:"â±£";s:3:"áµ½";s:3:"Ɽ";s:2:"ɽ";s:3:"Ⱨ";s:3:"ⱨ";s:3:"Ⱪ";s:3:"ⱪ";s:3:"Ⱬ";s:3:"ⱬ";s:3:"â±­";s:2:"É‘";s:3:"â±®";s:2:"ɱ";s:3:"Ɐ";s:2:"É";s:3:"â±°";s:2:"É’";s:3:"â±²";s:3:"â±³";s:3:"â±µ";s:3:"ⱶ";s:3:"â±¾";s:2:"È¿";s:3:"Ɀ";s:2:"É€";s:3:"â²€";s:3:"â²";s:3:"Ⲃ";s:3:"ⲃ";s:3:"Ⲅ";s:3:"â²…";s:3:"Ⲇ";s:3:"ⲇ";s:3:"Ⲉ";s:3:"ⲉ";s:3:"Ⲋ";s:3:"ⲋ";s:3:"Ⲍ";s:3:"â²";s:3:"Ⲏ";s:3:"â²";s:3:"â²";s:3:"ⲑ";s:3:"â²’";s:3:"ⲓ";s:3:"â²”";s:3:"ⲕ";s:3:"â²–";s:3:"â²—";s:3:"Ⲙ";s:3:"â²™";s:3:"Ⲛ";s:3:"â²›";s:3:"Ⲝ";s:3:"â²";s:3:"Ⲟ";s:3:"ⲟ";s:3:"â² ";s:3:"ⲡ";s:3:"â²¢";s:3:"â²£";s:3:"Ⲥ";s:3:"â²¥";s:3:"Ⲧ";s:3:"ⲧ";s:3:"Ⲩ";s:3:"ⲩ";s:3:"Ⲫ";s:3:"ⲫ";s:3:"Ⲭ";s:3:"â²­";s:3:"â²®";s:3:"ⲯ";s:3:"â²°";s:3:"â²±";s:3:"â²²";s:3:"â²³";s:3:"â²´";s:3:"â²µ";s:3:"Ⲷ";s:3:"â²·";s:3:"Ⲹ";s:3:"â²¹";s:3:"Ⲻ";s:3:"â²»";s:3:"â²¼";s:3:"â²½";s:3:"â²¾";s:3:"ⲿ";s:3:"â³€";s:3:"â³";s:3:"Ⳃ";s:3:"ⳃ";s:3:"Ⳅ";s:3:"â³…";s:3:"Ⳇ";s:3:"ⳇ";s:3:"Ⳉ";s:3:"ⳉ";s:3:"Ⳋ";s:3:"ⳋ";s:3:"Ⳍ";s:3:"â³";s:3:"Ⳏ";s:3:"â³";s:3:"â³";s:3:"ⳑ";s:3:"â³’";s:3:"ⳓ";s:3:"â³”";s:3:"ⳕ";s:3:"â³–";s:3:"â³—";s:3:"Ⳙ";s:3:"â³™";s:3:"Ⳛ";s:3:"â³›";s:3:"Ⳝ";s:3:"â³";s:3:"Ⳟ";s:3:"ⳟ";s:3:"â³ ";s:3:"ⳡ";s:3:"â³¢";s:3:"â³£";s:3:"Ⳬ";s:3:"ⳬ";s:3:"â³­";s:3:"â³®";s:3:"â³²";s:3:"â³³";s:3:"Ꙁ";s:3:"ê™";s:3:"Ꙃ";s:3:"ꙃ";s:3:"Ꙅ";s:3:"ê™…";s:3:"Ꙇ";s:3:"ꙇ";s:3:"Ꙉ";s:3:"ꙉ";s:3:"Ꙋ";s:3:"ꙋ";s:3:"Ꙍ";s:3:"ê™";s:3:"Ꙏ";s:3:"ê™";s:3:"ê™";s:3:"ꙑ";s:3:"ê™’";s:3:"ꙓ";s:3:"ê™”";s:3:"ꙕ";s:3:"ê™–";s:3:"ê™—";s:3:"Ꙙ";s:3:"ê™™";s:3:"Ꙛ";s:3:"ê™›";s:3:"Ꙝ";s:3:"ê™";s:3:"Ꙟ";s:3:"ꙟ";s:3:"ê™ ";s:3:"ꙡ";s:3:"Ꙣ";s:3:"ꙣ";s:3:"Ꙥ";s:3:"ꙥ";s:3:"Ꙧ";s:3:"ꙧ";s:3:"Ꙩ";s:3:"ꙩ";s:3:"Ꙫ";s:3:"ꙫ";s:3:"Ꙭ";s:3:"ê™­";s:3:"Ꚁ";s:3:"êš";s:3:"êš‚";s:3:"ꚃ";s:3:"êš„";s:3:"êš…";s:3:"Ꚇ";s:3:"ꚇ";s:3:"Ꚉ";s:3:"ꚉ";s:3:"Ꚋ";s:3:"êš‹";s:3:"Ꚍ";s:3:"êš";s:3:"Ꚏ";s:3:"êš";s:3:"êš";s:3:"êš‘";s:3:"êš’";s:3:"êš“";s:3:"êš”";s:3:"êš•";s:3:"êš–";s:3:"êš—";s:3:"Ꜣ";s:3:"ꜣ";s:3:"Ꜥ";s:3:"ꜥ";s:3:"Ꜧ";s:3:"ꜧ";s:3:"Ꜩ";s:3:"ꜩ";s:3:"Ꜫ";s:3:"ꜫ";s:3:"Ꜭ";s:3:"ꜭ";s:3:"Ꜯ";s:3:"ꜯ";s:3:"Ꜳ";s:3:"ꜳ";s:3:"Ꜵ";s:3:"ꜵ";s:3:"Ꜷ";s:3:"ꜷ";s:3:"Ꜹ";s:3:"ꜹ";s:3:"Ꜻ";s:3:"ꜻ";s:3:"Ꜽ";s:3:"ꜽ";s:3:"Ꜿ";s:3:"ꜿ";s:3:"ê€";s:3:"ê";s:3:"ê‚";s:3:"êƒ";s:3:"ê„";s:3:"ê…";s:3:"ê†";s:3:"ê‡";s:3:"êˆ";s:3:"ê‰";s:3:"êŠ";s:3:"ê‹";s:3:"êŒ";s:3:"ê";s:3:"êŽ";s:3:"ê";s:3:"ê";s:3:"ê‘";s:3:"ê’";s:3:"ê“";s:3:"ê”";s:3:"ê•";s:3:"ê–";s:3:"ê—";s:3:"ê˜";s:3:"ê™";s:3:"êš";s:3:"ê›";s:3:"êœ";s:3:"ê";s:3:"êž";s:3:"êŸ";s:3:"ê ";s:3:"ê¡";s:3:"ê¢";s:3:"ê£";s:3:"ê¤";s:3:"ê¥";s:3:"ê¦";s:3:"ê§";s:3:"ê¨";s:3:"ê©";s:3:"êª";s:3:"ê«";s:3:"ê¬";s:3:"ê­";s:3:"ê®";s:3:"ê¯";s:3:"ê¹";s:3:"êº";s:3:"ê»";s:3:"ê¼";s:3:"ê½";s:3:"áµ¹";s:3:"ê¾";s:3:"ê¿";s:3:"Ꞁ";s:3:"êž";s:3:"êž‚";s:3:"ꞃ";s:3:"êž„";s:3:"êž…";s:3:"Ꞇ";s:3:"ꞇ";s:3:"êž‹";s:3:"ꞌ";s:3:"êž";s:2:"É¥";s:3:"êž";s:3:"êž‘";s:3:"êž’";s:3:"êž“";s:3:"êž ";s:3:"êž¡";s:3:"Ꞣ";s:3:"ꞣ";s:3:"Ꞥ";s:3:"ꞥ";s:3:"Ꞧ";s:3:"ꞧ";s:3:"Ꞩ";s:3:"êž©";s:3:"Ɦ";s:2:"ɦ";s:3:"A";s:3:"ï½";s:3:"ï¼¢";s:3:"b";s:3:"ï¼£";s:3:"c";s:3:"D";s:3:"d";s:3:"ï¼¥";s:3:"ï½…";s:3:"F";s:3:"f";s:3:"G";s:3:"g";s:3:"H";s:3:"h";s:3:"I";s:3:"i";s:3:"J";s:3:"j";s:3:"K";s:3:"k";s:3:"L";s:3:"l";s:3:"ï¼­";s:3:"ï½";s:3:"ï¼®";s:3:"n";s:3:"O";s:3:"ï½";s:3:"ï¼°";s:3:"ï½";s:3:"ï¼±";s:3:"q";s:3:"ï¼²";s:3:"ï½’";s:3:"ï¼³";s:3:"s";s:3:"ï¼´";s:3:"ï½”";s:3:"ï¼µ";s:3:"u";s:3:"V";s:3:"ï½–";s:3:"ï¼·";s:3:"ï½—";s:3:"X";s:3:"x";s:3:"ï¼¹";s:3:"ï½™";s:3:"Z";s:3:"z";s:4:"ð€";s:4:"ð¨";s:4:"ð";s:4:"ð©";s:4:"ð‚";s:4:"ðª";s:4:"ðƒ";s:4:"ð«";s:4:"ð„";s:4:"ð¬";s:4:"ð…";s:4:"ð­";s:4:"ð†";s:4:"ð®";s:4:"ð‡";s:4:"ð¯";s:4:"ðˆ";s:4:"ð°";s:4:"ð‰";s:4:"ð±";s:4:"ðŠ";s:4:"ð²";s:4:"ð‹";s:4:"ð³";s:4:"ðŒ";s:4:"ð´";s:4:"ð";s:4:"ðµ";s:4:"ðŽ";s:4:"ð¶";s:4:"ð";s:4:"ð·";s:4:"ð";s:4:"ð¸";s:4:"ð‘";s:4:"ð¹";s:4:"ð’";s:4:"ðº";s:4:"ð“";s:4:"ð»";s:4:"ð”";s:4:"ð¼";s:4:"ð•";s:4:"ð½";s:4:"ð–";s:4:"ð¾";s:4:"ð—";s:4:"ð¿";s:4:"ð˜";s:4:"ð‘€";s:4:"ð™";s:4:"ð‘";s:4:"ðš";s:4:"ð‘‚";s:4:"ð›";s:4:"ð‘ƒ";s:4:"ðœ";s:4:"ð‘„";s:4:"ð";s:4:"ð‘…";s:4:"ðž";s:4:"ð‘†";s:4:"ðŸ";s:4:"ð‘‡";s:4:"ð ";s:4:"ð‘ˆ";s:4:"ð¡";s:4:"ð‘‰";s:4:"ð¢";s:4:"ð‘Š";s:4:"ð£";s:4:"ð‘‹";s:4:"ð¤";s:4:"ð‘Œ";s:4:"ð¥";s:4:"ð‘";s:4:"ð¦";s:4:"ð‘Ž";s:4:"ð§";s:4:"ð‘";}
    \ No newline at end of file
    diff --git a/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/unidata/upperCase.ser b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/unidata/upperCase.ser
    new file mode 100755
    index 0000000..a3182d4
    --- /dev/null
    +++ b/vendor/patchwork/utf8/class/Patchwork/PHP/Shim/unidata/upperCase.ser
    @@ -0,0 +1 @@
    +a:1051:{s:1:"a";s:1:"A";s:1:"b";s:1:"B";s:1:"c";s:1:"C";s:1:"d";s:1:"D";s:1:"e";s:1:"E";s:1:"f";s:1:"F";s:1:"g";s:1:"G";s:1:"h";s:1:"H";s:1:"i";s:1:"I";s:1:"j";s:1:"J";s:1:"k";s:1:"K";s:1:"l";s:1:"L";s:1:"m";s:1:"M";s:1:"n";s:1:"N";s:1:"o";s:1:"O";s:1:"p";s:1:"P";s:1:"q";s:1:"Q";s:1:"r";s:1:"R";s:1:"s";s:1:"S";s:1:"t";s:1:"T";s:1:"u";s:1:"U";s:1:"v";s:1:"V";s:1:"w";s:1:"W";s:1:"x";s:1:"X";s:1:"y";s:1:"Y";s:1:"z";s:1:"Z";s:2:"µ";s:2:"Îœ";s:2:"à";s:2:"À";s:2:"á";s:2:"Ã";s:2:"â";s:2:"Â";s:2:"ã";s:2:"Ã";s:2:"ä";s:2:"Ä";s:2:"Ã¥";s:2:"Ã…";s:2:"æ";s:2:"Æ";s:2:"ç";s:2:"Ç";s:2:"è";s:2:"È";s:2:"é";s:2:"É";s:2:"ê";s:2:"Ê";s:2:"ë";s:2:"Ë";s:2:"ì";s:2:"ÃŒ";s:2:"í";s:2:"Ã";s:2:"î";s:2:"ÃŽ";s:2:"ï";s:2:"Ã";s:2:"ð";s:2:"Ã";s:2:"ñ";s:2:"Ñ";s:2:"ò";s:2:"Ã’";s:2:"ó";s:2:"Ó";s:2:"ô";s:2:"Ô";s:2:"õ";s:2:"Õ";s:2:"ö";s:2:"Ö";s:2:"ø";s:2:"Ø";s:2:"ù";s:2:"Ù";s:2:"ú";s:2:"Ú";s:2:"û";s:2:"Û";s:2:"ü";s:2:"Ãœ";s:2:"ý";s:2:"Ã";s:2:"þ";s:2:"Þ";s:2:"ÿ";s:2:"Ÿ";s:2:"Ä";s:2:"Ä€";s:2:"ă";s:2:"Ä‚";s:2:"Ä…";s:2:"Ä„";s:2:"ć";s:2:"Ć";s:2:"ĉ";s:2:"Ĉ";s:2:"Ä‹";s:2:"ÄŠ";s:2:"Ä";s:2:"ÄŒ";s:2:"Ä";s:2:"ÄŽ";s:2:"Ä‘";s:2:"Ä";s:2:"Ä“";s:2:"Ä’";s:2:"Ä•";s:2:"Ä”";s:2:"Ä—";s:2:"Ä–";s:2:"Ä™";s:2:"Ę";s:2:"Ä›";s:2:"Äš";s:2:"Ä";s:2:"Äœ";s:2:"ÄŸ";s:2:"Äž";s:2:"Ä¡";s:2:"Ä ";s:2:"Ä£";s:2:"Ä¢";s:2:"Ä¥";s:2:"Ĥ";s:2:"ħ";s:2:"Ħ";s:2:"Ä©";s:2:"Ĩ";s:2:"Ä«";s:2:"Ī";s:2:"Ä­";s:2:"Ĭ";s:2:"į";s:2:"Ä®";s:2:"ı";s:1:"I";s:2:"ij";s:2:"IJ";s:2:"ĵ";s:2:"Ä´";s:2:"Ä·";s:2:"Ķ";s:2:"ĺ";s:2:"Ĺ";s:2:"ļ";s:2:"Ä»";s:2:"ľ";s:2:"Ľ";s:2:"Å€";s:2:"Ä¿";s:2:"Å‚";s:2:"Å";s:2:"Å„";s:2:"Ń";s:2:"ņ";s:2:"Å…";s:2:"ň";s:2:"Ň";s:2:"Å‹";s:2:"ÅŠ";s:2:"Å";s:2:"ÅŒ";s:2:"Å";s:2:"ÅŽ";s:2:"Å‘";s:2:"Å";s:2:"Å“";s:2:"Å’";s:2:"Å•";s:2:"Å”";s:2:"Å—";s:2:"Å–";s:2:"Å™";s:2:"Ř";s:2:"Å›";s:2:"Åš";s:2:"Å";s:2:"Åœ";s:2:"ÅŸ";s:2:"Åž";s:2:"Å¡";s:2:"Å ";s:2:"Å£";s:2:"Å¢";s:2:"Å¥";s:2:"Ť";s:2:"ŧ";s:2:"Ŧ";s:2:"Å©";s:2:"Ũ";s:2:"Å«";s:2:"Ū";s:2:"Å­";s:2:"Ŭ";s:2:"ů";s:2:"Å®";s:2:"ű";s:2:"Å°";s:2:"ų";s:2:"Ų";s:2:"ŵ";s:2:"Å´";s:2:"Å·";s:2:"Ŷ";s:2:"ź";s:2:"Ź";s:2:"ż";s:2:"Å»";s:2:"ž";s:2:"Ž";s:2:"Å¿";s:1:"S";s:2:"Æ€";s:2:"Ƀ";s:2:"ƃ";s:2:"Æ‚";s:2:"Æ…";s:2:"Æ„";s:2:"ƈ";s:2:"Ƈ";s:2:"ÆŒ";s:2:"Æ‹";s:2:"Æ’";s:2:"Æ‘";s:2:"Æ•";s:2:"Ƕ";s:2:"Æ™";s:2:"Ƙ";s:2:"Æš";s:2:"Ƚ";s:2:"Æž";s:2:"È ";s:2:"Æ¡";s:2:"Æ ";s:2:"Æ£";s:2:"Æ¢";s:2:"Æ¥";s:2:"Ƥ";s:2:"ƨ";s:2:"Ƨ";s:2:"Æ­";s:2:"Ƭ";s:2:"Æ°";s:2:"Ư";s:2:"Æ´";s:2:"Ƴ";s:2:"ƶ";s:2:"Ƶ";s:2:"ƹ";s:2:"Ƹ";s:2:"ƽ";s:2:"Ƽ";s:2:"Æ¿";s:2:"Ç·";s:2:"Ç…";s:2:"Ç„";s:2:"dž";s:2:"Ç„";s:2:"Lj";s:2:"LJ";s:2:"lj";s:2:"LJ";s:2:"Ç‹";s:2:"ÇŠ";s:2:"ÇŒ";s:2:"ÇŠ";s:2:"ÇŽ";s:2:"Ç";s:2:"Ç";s:2:"Ç";s:2:"Ç’";s:2:"Ç‘";s:2:"Ç”";s:2:"Ç“";s:2:"Ç–";s:2:"Ç•";s:2:"ǘ";s:2:"Ç—";s:2:"Çš";s:2:"Ç™";s:2:"Çœ";s:2:"Ç›";s:2:"Ç";s:2:"ÆŽ";s:2:"ÇŸ";s:2:"Çž";s:2:"Ç¡";s:2:"Ç ";s:2:"Ç£";s:2:"Ç¢";s:2:"Ç¥";s:2:"Ǥ";s:2:"ǧ";s:2:"Ǧ";s:2:"Ç©";s:2:"Ǩ";s:2:"Ç«";s:2:"Ǫ";s:2:"Ç­";s:2:"Ǭ";s:2:"ǯ";s:2:"Ç®";s:2:"Dz";s:2:"DZ";s:2:"dz";s:2:"DZ";s:2:"ǵ";s:2:"Ç´";s:2:"ǹ";s:2:"Ǹ";s:2:"Ç»";s:2:"Ǻ";s:2:"ǽ";s:2:"Ǽ";s:2:"Ç¿";s:2:"Ǿ";s:2:"È";s:2:"È€";s:2:"ȃ";s:2:"È‚";s:2:"È…";s:2:"È„";s:2:"ȇ";s:2:"Ȇ";s:2:"ȉ";s:2:"Ȉ";s:2:"È‹";s:2:"ÈŠ";s:2:"È";s:2:"ÈŒ";s:2:"È";s:2:"ÈŽ";s:2:"È‘";s:2:"È";s:2:"È“";s:2:"È’";s:2:"È•";s:2:"È”";s:2:"È—";s:2:"È–";s:2:"È™";s:2:"Ș";s:2:"È›";s:2:"Èš";s:2:"È";s:2:"Èœ";s:2:"ÈŸ";s:2:"Èž";s:2:"È£";s:2:"È¢";s:2:"È¥";s:2:"Ȥ";s:2:"ȧ";s:2:"Ȧ";s:2:"È©";s:2:"Ȩ";s:2:"È«";s:2:"Ȫ";s:2:"È­";s:2:"Ȭ";s:2:"ȯ";s:2:"È®";s:2:"ȱ";s:2:"È°";s:2:"ȳ";s:2:"Ȳ";s:2:"ȼ";s:2:"È»";s:2:"È¿";s:3:"â±¾";s:2:"É€";s:3:"Ɀ";s:2:"É‚";s:2:"É";s:2:"ɇ";s:2:"Ɇ";s:2:"ɉ";s:2:"Ɉ";s:2:"É‹";s:2:"ÉŠ";s:2:"É";s:2:"ÉŒ";s:2:"É";s:2:"ÉŽ";s:2:"É";s:3:"Ɐ";s:2:"É‘";s:3:"â±­";s:2:"É’";s:3:"â±°";s:2:"É“";s:2:"Æ";s:2:"É”";s:2:"Ɔ";s:2:"É–";s:2:"Ɖ";s:2:"É—";s:2:"ÆŠ";s:2:"É™";s:2:"Æ";s:2:"É›";s:2:"Æ";s:2:"É ";s:2:"Æ“";s:2:"É£";s:2:"Æ”";s:2:"É¥";s:3:"êž";s:2:"ɦ";s:3:"Ɦ";s:2:"ɨ";s:2:"Æ—";s:2:"É©";s:2:"Æ–";s:2:"É«";s:3:"â±¢";s:2:"ɯ";s:2:"Æœ";s:2:"ɱ";s:3:"â±®";s:2:"ɲ";s:2:"Æ";s:2:"ɵ";s:2:"ÆŸ";s:2:"ɽ";s:3:"Ɽ";s:2:"Ê€";s:2:"Ʀ";s:2:"ʃ";s:2:"Æ©";s:2:"ʈ";s:2:"Æ®";s:2:"ʉ";s:2:"É„";s:2:"ÊŠ";s:2:"Ʊ";s:2:"Ê‹";s:2:"Ʋ";s:2:"ÊŒ";s:2:"É…";s:2:"Ê’";s:2:"Æ·";s:2:"Í…";s:2:"Ι";s:2:"ͱ";s:2:"Í°";s:2:"ͳ";s:2:"Ͳ";s:2:"Í·";s:2:"Ͷ";s:2:"Í»";s:2:"Ͻ";s:2:"ͼ";s:2:"Ͼ";s:2:"ͽ";s:2:"Ï¿";s:2:"ά";s:2:"Ά";s:2:"έ";s:2:"Έ";s:2:"ή";s:2:"Ή";s:2:"ί";s:2:"Ί";s:2:"α";s:2:"Α";s:2:"β";s:2:"Î’";s:2:"γ";s:2:"Γ";s:2:"δ";s:2:"Δ";s:2:"ε";s:2:"Ε";s:2:"ζ";s:2:"Ζ";s:2:"η";s:2:"Η";s:2:"θ";s:2:"Θ";s:2:"ι";s:2:"Ι";s:2:"κ";s:2:"Κ";s:2:"λ";s:2:"Λ";s:2:"μ";s:2:"Îœ";s:2:"ν";s:2:"Î";s:2:"ξ";s:2:"Ξ";s:2:"ο";s:2:"Ο";s:2:"Ï€";s:2:"Π";s:2:"Ï";s:2:"Ρ";s:2:"Ï‚";s:2:"Σ";s:2:"σ";s:2:"Σ";s:2:"Ï„";s:2:"Τ";s:2:"Ï…";s:2:"Î¥";s:2:"φ";s:2:"Φ";s:2:"χ";s:2:"Χ";s:2:"ψ";s:2:"Ψ";s:2:"ω";s:2:"Ω";s:2:"ÏŠ";s:2:"Ϊ";s:2:"Ï‹";s:2:"Ϋ";s:2:"ÏŒ";s:2:"ÎŒ";s:2:"Ï";s:2:"ÎŽ";s:2:"ÏŽ";s:2:"Î";s:2:"Ï";s:2:"Î’";s:2:"Ï‘";s:2:"Θ";s:2:"Ï•";s:2:"Φ";s:2:"Ï–";s:2:"Π";s:2:"Ï—";s:2:"Ï";s:2:"Ï™";s:2:"Ϙ";s:2:"Ï›";s:2:"Ïš";s:2:"Ï";s:2:"Ïœ";s:2:"ÏŸ";s:2:"Ïž";s:2:"Ï¡";s:2:"Ï ";s:2:"Ï£";s:2:"Ï¢";s:2:"Ï¥";s:2:"Ϥ";s:2:"ϧ";s:2:"Ϧ";s:2:"Ï©";s:2:"Ϩ";s:2:"Ï«";s:2:"Ϫ";s:2:"Ï­";s:2:"Ϭ";s:2:"ϯ";s:2:"Ï®";s:2:"Ï°";s:2:"Κ";s:2:"ϱ";s:2:"Ρ";s:2:"ϲ";s:2:"Ϲ";s:2:"ϵ";s:2:"Ε";s:2:"ϸ";s:2:"Ï·";s:2:"Ï»";s:2:"Ϻ";s:2:"а";s:2:"Ð";s:2:"б";s:2:"Б";s:2:"в";s:2:"Ð’";s:2:"г";s:2:"Г";s:2:"д";s:2:"Д";s:2:"е";s:2:"Е";s:2:"ж";s:2:"Ж";s:2:"з";s:2:"З";s:2:"и";s:2:"И";s:2:"й";s:2:"Й";s:2:"к";s:2:"К";s:2:"л";s:2:"Л";s:2:"м";s:2:"Ðœ";s:2:"н";s:2:"Ð";s:2:"о";s:2:"О";s:2:"п";s:2:"П";s:2:"Ñ€";s:2:"Р";s:2:"Ñ";s:2:"С";s:2:"Ñ‚";s:2:"Т";s:2:"у";s:2:"У";s:2:"Ñ„";s:2:"Ф";s:2:"Ñ…";s:2:"Ð¥";s:2:"ц";s:2:"Ц";s:2:"ч";s:2:"Ч";s:2:"ш";s:2:"Ш";s:2:"щ";s:2:"Щ";s:2:"ÑŠ";s:2:"Ъ";s:2:"Ñ‹";s:2:"Ы";s:2:"ÑŒ";s:2:"Ь";s:2:"Ñ";s:2:"Э";s:2:"ÑŽ";s:2:"Ю";s:2:"Ñ";s:2:"Я";s:2:"Ñ";s:2:"Ѐ";s:2:"Ñ‘";s:2:"Ð";s:2:"Ñ’";s:2:"Ђ";s:2:"Ñ“";s:2:"Ѓ";s:2:"Ñ”";s:2:"Є";s:2:"Ñ•";s:2:"Ð…";s:2:"Ñ–";s:2:"І";s:2:"Ñ—";s:2:"Ї";s:2:"ј";s:2:"Ј";s:2:"Ñ™";s:2:"Љ";s:2:"Ñš";s:2:"Њ";s:2:"Ñ›";s:2:"Ћ";s:2:"Ñœ";s:2:"ÐŒ";s:2:"Ñ";s:2:"Ð";s:2:"Ñž";s:2:"ÐŽ";s:2:"ÑŸ";s:2:"Ð";s:2:"Ñ¡";s:2:"Ñ ";s:2:"Ñ£";s:2:"Ñ¢";s:2:"Ñ¥";s:2:"Ѥ";s:2:"ѧ";s:2:"Ѧ";s:2:"Ñ©";s:2:"Ѩ";s:2:"Ñ«";s:2:"Ѫ";s:2:"Ñ­";s:2:"Ѭ";s:2:"ѯ";s:2:"Ñ®";s:2:"ѱ";s:2:"Ñ°";s:2:"ѳ";s:2:"Ѳ";s:2:"ѵ";s:2:"Ñ´";s:2:"Ñ·";s:2:"Ѷ";s:2:"ѹ";s:2:"Ѹ";s:2:"Ñ»";s:2:"Ѻ";s:2:"ѽ";s:2:"Ѽ";s:2:"Ñ¿";s:2:"Ѿ";s:2:"Ò";s:2:"Ò€";s:2:"Ò‹";s:2:"ÒŠ";s:2:"Ò";s:2:"ÒŒ";s:2:"Ò";s:2:"ÒŽ";s:2:"Ò‘";s:2:"Ò";s:2:"Ò“";s:2:"Ò’";s:2:"Ò•";s:2:"Ò”";s:2:"Ò—";s:2:"Ò–";s:2:"Ò™";s:2:"Ò˜";s:2:"Ò›";s:2:"Òš";s:2:"Ò";s:2:"Òœ";s:2:"ÒŸ";s:2:"Òž";s:2:"Ò¡";s:2:"Ò ";s:2:"Ò£";s:2:"Ò¢";s:2:"Ò¥";s:2:"Ò¤";s:2:"Ò§";s:2:"Ò¦";s:2:"Ò©";s:2:"Ò¨";s:2:"Ò«";s:2:"Òª";s:2:"Ò­";s:2:"Ò¬";s:2:"Ò¯";s:2:"Ò®";s:2:"Ò±";s:2:"Ò°";s:2:"Ò³";s:2:"Ò²";s:2:"Òµ";s:2:"Ò´";s:2:"Ò·";s:2:"Ò¶";s:2:"Ò¹";s:2:"Ò¸";s:2:"Ò»";s:2:"Òº";s:2:"Ò½";s:2:"Ò¼";s:2:"Ò¿";s:2:"Ò¾";s:2:"Ó‚";s:2:"Ó";s:2:"Ó„";s:2:"Óƒ";s:2:"Ó†";s:2:"Ó…";s:2:"Óˆ";s:2:"Ó‡";s:2:"ÓŠ";s:2:"Ó‰";s:2:"ÓŒ";s:2:"Ó‹";s:2:"ÓŽ";s:2:"Ó";s:2:"Ó";s:2:"Ó€";s:2:"Ó‘";s:2:"Ó";s:2:"Ó“";s:2:"Ó’";s:2:"Ó•";s:2:"Ó”";s:2:"Ó—";s:2:"Ó–";s:2:"Ó™";s:2:"Ó˜";s:2:"Ó›";s:2:"Óš";s:2:"Ó";s:2:"Óœ";s:2:"ÓŸ";s:2:"Óž";s:2:"Ó¡";s:2:"Ó ";s:2:"Ó£";s:2:"Ó¢";s:2:"Ó¥";s:2:"Ó¤";s:2:"Ó§";s:2:"Ó¦";s:2:"Ó©";s:2:"Ó¨";s:2:"Ó«";s:2:"Óª";s:2:"Ó­";s:2:"Ó¬";s:2:"Ó¯";s:2:"Ó®";s:2:"Ó±";s:2:"Ó°";s:2:"Ó³";s:2:"Ó²";s:2:"Óµ";s:2:"Ó´";s:2:"Ó·";s:2:"Ó¶";s:2:"Ó¹";s:2:"Ó¸";s:2:"Ó»";s:2:"Óº";s:2:"Ó½";s:2:"Ó¼";s:2:"Ó¿";s:2:"Ó¾";s:2:"Ô";s:2:"Ô€";s:2:"Ôƒ";s:2:"Ô‚";s:2:"Ô…";s:2:"Ô„";s:2:"Ô‡";s:2:"Ô†";s:2:"Ô‰";s:2:"Ôˆ";s:2:"Ô‹";s:2:"ÔŠ";s:2:"Ô";s:2:"ÔŒ";s:2:"Ô";s:2:"ÔŽ";s:2:"Ô‘";s:2:"Ô";s:2:"Ô“";s:2:"Ô’";s:2:"Ô•";s:2:"Ô”";s:2:"Ô—";s:2:"Ô–";s:2:"Ô™";s:2:"Ô˜";s:2:"Ô›";s:2:"Ôš";s:2:"Ô";s:2:"Ôœ";s:2:"ÔŸ";s:2:"Ôž";s:2:"Ô¡";s:2:"Ô ";s:2:"Ô£";s:2:"Ô¢";s:2:"Ô¥";s:2:"Ô¤";s:2:"Ô§";s:2:"Ô¦";s:2:"Õ¡";s:2:"Ô±";s:2:"Õ¢";s:2:"Ô²";s:2:"Õ£";s:2:"Ô³";s:2:"Õ¤";s:2:"Ô´";s:2:"Õ¥";s:2:"Ôµ";s:2:"Õ¦";s:2:"Ô¶";s:2:"Õ§";s:2:"Ô·";s:2:"Õ¨";s:2:"Ô¸";s:2:"Õ©";s:2:"Ô¹";s:2:"Õª";s:2:"Ôº";s:2:"Õ«";s:2:"Ô»";s:2:"Õ¬";s:2:"Ô¼";s:2:"Õ­";s:2:"Ô½";s:2:"Õ®";s:2:"Ô¾";s:2:"Õ¯";s:2:"Ô¿";s:2:"Õ°";s:2:"Õ€";s:2:"Õ±";s:2:"Õ";s:2:"Õ²";s:2:"Õ‚";s:2:"Õ³";s:2:"Õƒ";s:2:"Õ´";s:2:"Õ„";s:2:"Õµ";s:2:"Õ…";s:2:"Õ¶";s:2:"Õ†";s:2:"Õ·";s:2:"Õ‡";s:2:"Õ¸";s:2:"Õˆ";s:2:"Õ¹";s:2:"Õ‰";s:2:"Õº";s:2:"ÕŠ";s:2:"Õ»";s:2:"Õ‹";s:2:"Õ¼";s:2:"ÕŒ";s:2:"Õ½";s:2:"Õ";s:2:"Õ¾";s:2:"ÕŽ";s:2:"Õ¿";s:2:"Õ";s:2:"Ö€";s:2:"Õ";s:2:"Ö";s:2:"Õ‘";s:2:"Ö‚";s:2:"Õ’";s:2:"Öƒ";s:2:"Õ“";s:2:"Ö„";s:2:"Õ”";s:2:"Ö…";s:2:"Õ•";s:2:"Ö†";s:2:"Õ–";s:3:"áµ¹";s:3:"ê½";s:3:"áµ½";s:3:"â±£";s:3:"á¸";s:3:"Ḁ";s:3:"ḃ";s:3:"Ḃ";s:3:"ḅ";s:3:"Ḅ";s:3:"ḇ";s:3:"Ḇ";s:3:"ḉ";s:3:"Ḉ";s:3:"ḋ";s:3:"Ḋ";s:3:"á¸";s:3:"Ḍ";s:3:"á¸";s:3:"Ḏ";s:3:"ḑ";s:3:"á¸";s:3:"ḓ";s:3:"Ḓ";s:3:"ḕ";s:3:"Ḕ";s:3:"ḗ";s:3:"Ḗ";s:3:"ḙ";s:3:"Ḙ";s:3:"ḛ";s:3:"Ḛ";s:3:"á¸";s:3:"Ḝ";s:3:"ḟ";s:3:"Ḟ";s:3:"ḡ";s:3:"Ḡ";s:3:"ḣ";s:3:"Ḣ";s:3:"ḥ";s:3:"Ḥ";s:3:"ḧ";s:3:"Ḧ";s:3:"ḩ";s:3:"Ḩ";s:3:"ḫ";s:3:"Ḫ";s:3:"ḭ";s:3:"Ḭ";s:3:"ḯ";s:3:"Ḯ";s:3:"ḱ";s:3:"Ḱ";s:3:"ḳ";s:3:"Ḳ";s:3:"ḵ";s:3:"Ḵ";s:3:"ḷ";s:3:"Ḷ";s:3:"ḹ";s:3:"Ḹ";s:3:"ḻ";s:3:"Ḻ";s:3:"ḽ";s:3:"Ḽ";s:3:"ḿ";s:3:"Ḿ";s:3:"á¹";s:3:"á¹€";s:3:"ṃ";s:3:"Ṃ";s:3:"á¹…";s:3:"Ṅ";s:3:"ṇ";s:3:"Ṇ";s:3:"ṉ";s:3:"Ṉ";s:3:"ṋ";s:3:"Ṋ";s:3:"á¹";s:3:"Ṍ";s:3:"á¹";s:3:"Ṏ";s:3:"ṑ";s:3:"á¹";s:3:"ṓ";s:3:"á¹’";s:3:"ṕ";s:3:"á¹”";s:3:"á¹—";s:3:"á¹–";s:3:"á¹™";s:3:"Ṙ";s:3:"á¹›";s:3:"Ṛ";s:3:"á¹";s:3:"Ṝ";s:3:"ṟ";s:3:"Ṟ";s:3:"ṡ";s:3:"á¹ ";s:3:"á¹£";s:3:"á¹¢";s:3:"á¹¥";s:3:"Ṥ";s:3:"ṧ";s:3:"Ṧ";s:3:"ṩ";s:3:"Ṩ";s:3:"ṫ";s:3:"Ṫ";s:3:"á¹­";s:3:"Ṭ";s:3:"ṯ";s:3:"á¹®";s:3:"á¹±";s:3:"á¹°";s:3:"á¹³";s:3:"á¹²";s:3:"á¹µ";s:3:"á¹´";s:3:"á¹·";s:3:"Ṷ";s:3:"á¹¹";s:3:"Ṹ";s:3:"á¹»";s:3:"Ṻ";s:3:"á¹½";s:3:"á¹¼";s:3:"ṿ";s:3:"á¹¾";s:3:"áº";s:3:"Ẁ";s:3:"ẃ";s:3:"Ẃ";s:3:"ẅ";s:3:"Ẅ";s:3:"ẇ";s:3:"Ẇ";s:3:"ẉ";s:3:"Ẉ";s:3:"ẋ";s:3:"Ẋ";s:3:"áº";s:3:"Ẍ";s:3:"áº";s:3:"Ẏ";s:3:"ẑ";s:3:"áº";s:3:"ẓ";s:3:"Ẓ";s:3:"ẕ";s:3:"Ẕ";s:3:"ẛ";s:3:"á¹ ";s:3:"ạ";s:3:"Ạ";s:3:"ả";s:3:"Ả";s:3:"ấ";s:3:"Ấ";s:3:"ầ";s:3:"Ầ";s:3:"ẩ";s:3:"Ẩ";s:3:"ẫ";s:3:"Ẫ";s:3:"ậ";s:3:"Ậ";s:3:"ắ";s:3:"Ắ";s:3:"ằ";s:3:"Ằ";s:3:"ẳ";s:3:"Ẳ";s:3:"ẵ";s:3:"Ẵ";s:3:"ặ";s:3:"Ặ";s:3:"ẹ";s:3:"Ẹ";s:3:"ẻ";s:3:"Ẻ";s:3:"ẽ";s:3:"Ẽ";s:3:"ế";s:3:"Ế";s:3:"á»";s:3:"Ề";s:3:"ể";s:3:"Ể";s:3:"á»…";s:3:"Ễ";s:3:"ệ";s:3:"Ệ";s:3:"ỉ";s:3:"Ỉ";s:3:"ị";s:3:"Ị";s:3:"á»";s:3:"Ọ";s:3:"á»";s:3:"Ỏ";s:3:"ố";s:3:"á»";s:3:"ồ";s:3:"á»’";s:3:"ổ";s:3:"á»”";s:3:"á»—";s:3:"á»–";s:3:"á»™";s:3:"Ộ";s:3:"á»›";s:3:"Ớ";s:3:"á»";s:3:"Ờ";s:3:"ở";s:3:"Ở";s:3:"ỡ";s:3:"á» ";s:3:"ợ";s:3:"Ợ";s:3:"ụ";s:3:"Ụ";s:3:"ủ";s:3:"Ủ";s:3:"ứ";s:3:"Ứ";s:3:"ừ";s:3:"Ừ";s:3:"á»­";s:3:"Ử";s:3:"ữ";s:3:"á»®";s:3:"á»±";s:3:"á»°";s:3:"ỳ";s:3:"Ỳ";s:3:"ỵ";s:3:"á»´";s:3:"á»·";s:3:"Ỷ";s:3:"ỹ";s:3:"Ỹ";s:3:"á»»";s:3:"Ỻ";s:3:"ỽ";s:3:"Ỽ";s:3:"ỿ";s:3:"Ỿ";s:3:"á¼€";s:3:"Ἀ";s:3:"á¼";s:3:"Ἁ";s:3:"ἂ";s:3:"Ἂ";s:3:"ἃ";s:3:"Ἃ";s:3:"ἄ";s:3:"Ἄ";s:3:"á¼…";s:3:"á¼";s:3:"ἆ";s:3:"Ἆ";s:3:"ἇ";s:3:"á¼";s:3:"á¼";s:3:"Ἐ";s:3:"ἑ";s:3:"á¼™";s:3:"á¼’";s:3:"Ἒ";s:3:"ἓ";s:3:"á¼›";s:3:"á¼”";s:3:"Ἔ";s:3:"ἕ";s:3:"á¼";s:3:"á¼ ";s:3:"Ἠ";s:3:"ἡ";s:3:"Ἡ";s:3:"á¼¢";s:3:"Ἢ";s:3:"á¼£";s:3:"Ἣ";s:3:"ἤ";s:3:"Ἤ";s:3:"á¼¥";s:3:"á¼­";s:3:"ἦ";s:3:"á¼®";s:3:"ἧ";s:3:"Ἧ";s:3:"á¼°";s:3:"Ἰ";s:3:"á¼±";s:3:"á¼¹";s:3:"á¼²";s:3:"Ἲ";s:3:"á¼³";s:3:"á¼»";s:3:"á¼´";s:3:"á¼¼";s:3:"á¼µ";s:3:"á¼½";s:3:"ἶ";s:3:"á¼¾";s:3:"á¼·";s:3:"Ἷ";s:3:"á½€";s:3:"Ὀ";s:3:"á½";s:3:"Ὁ";s:3:"ὂ";s:3:"Ὂ";s:3:"ὃ";s:3:"Ὃ";s:3:"ὄ";s:3:"Ὄ";s:3:"á½…";s:3:"á½";s:3:"ὑ";s:3:"á½™";s:3:"ὓ";s:3:"á½›";s:3:"ὕ";s:3:"á½";s:3:"á½—";s:3:"Ὗ";s:3:"á½ ";s:3:"Ὠ";s:3:"ὡ";s:3:"Ὡ";s:3:"á½¢";s:3:"Ὢ";s:3:"á½£";s:3:"Ὣ";s:3:"ὤ";s:3:"Ὤ";s:3:"á½¥";s:3:"á½­";s:3:"ὦ";s:3:"á½®";s:3:"ὧ";s:3:"Ὧ";s:3:"á½°";s:3:"Ὰ";s:3:"á½±";s:3:"á¾»";s:3:"á½²";s:3:"Ὲ";s:3:"á½³";s:3:"Έ";s:3:"á½´";s:3:"á¿Š";s:3:"á½µ";s:3:"á¿‹";s:3:"ὶ";s:3:"á¿š";s:3:"á½·";s:3:"á¿›";s:3:"ὸ";s:3:"Ὸ";s:3:"á½¹";s:3:"Ό";s:3:"ὺ";s:3:"Ὺ";s:3:"á½»";s:3:"á¿«";s:3:"á½¼";s:3:"Ὼ";s:3:"á½½";s:3:"á¿»";s:3:"á¾€";s:3:"ᾈ";s:3:"á¾";s:3:"ᾉ";s:3:"ᾂ";s:3:"ᾊ";s:3:"ᾃ";s:3:"ᾋ";s:3:"ᾄ";s:3:"ᾌ";s:3:"á¾…";s:3:"á¾";s:3:"ᾆ";s:3:"ᾎ";s:3:"ᾇ";s:3:"á¾";s:3:"á¾";s:3:"ᾘ";s:3:"ᾑ";s:3:"á¾™";s:3:"á¾’";s:3:"ᾚ";s:3:"ᾓ";s:3:"á¾›";s:3:"á¾”";s:3:"ᾜ";s:3:"ᾕ";s:3:"á¾";s:3:"á¾–";s:3:"ᾞ";s:3:"á¾—";s:3:"ᾟ";s:3:"á¾ ";s:3:"ᾨ";s:3:"ᾡ";s:3:"ᾩ";s:3:"á¾¢";s:3:"ᾪ";s:3:"á¾£";s:3:"ᾫ";s:3:"ᾤ";s:3:"ᾬ";s:3:"á¾¥";s:3:"á¾­";s:3:"ᾦ";s:3:"á¾®";s:3:"ᾧ";s:3:"ᾯ";s:3:"á¾°";s:3:"Ᾰ";s:3:"á¾±";s:3:"á¾¹";s:3:"á¾³";s:3:"á¾¼";s:3:"á¾¾";s:2:"Ι";s:3:"ῃ";s:3:"á¿Œ";s:3:"á¿";s:3:"Ῐ";s:3:"á¿‘";s:3:"á¿™";s:3:"á¿ ";s:3:"Ῠ";s:3:"á¿¡";s:3:"á¿©";s:3:"á¿¥";s:3:"Ῥ";s:3:"ῳ";s:3:"ῼ";s:3:"â…Ž";s:3:"Ⅎ";s:3:"â…°";s:3:"â… ";s:3:"â…±";s:3:"â…¡";s:3:"â…²";s:3:"â…¢";s:3:"â…³";s:3:"â…£";s:3:"â…´";s:3:"â…¤";s:3:"â…µ";s:3:"â…¥";s:3:"â…¶";s:3:"â…¦";s:3:"â…·";s:3:"â…§";s:3:"â…¸";s:3:"â…¨";s:3:"â…¹";s:3:"â…©";s:3:"â…º";s:3:"â…ª";s:3:"â…»";s:3:"â…«";s:3:"â…¼";s:3:"â…¬";s:3:"â…½";s:3:"â…­";s:3:"â…¾";s:3:"â…®";s:3:"â…¿";s:3:"â…¯";s:3:"ↄ";s:3:"Ↄ";s:3:"â“";s:3:"â’¶";s:3:"â“‘";s:3:"â’·";s:3:"â“’";s:3:"â’¸";s:3:"â““";s:3:"â’¹";s:3:"â“”";s:3:"â’º";s:3:"â“•";s:3:"â’»";s:3:"â“–";s:3:"â’¼";s:3:"â“—";s:3:"â’½";s:3:"ⓘ";s:3:"â’¾";s:3:"â“™";s:3:"â’¿";s:3:"â“š";s:3:"â“€";s:3:"â“›";s:3:"â“";s:3:"â“œ";s:3:"â“‚";s:3:"â“";s:3:"Ⓝ";s:3:"â“ž";s:3:"â“„";s:3:"â“Ÿ";s:3:"â“…";s:3:"â“ ";s:3:"Ⓠ";s:3:"â“¡";s:3:"Ⓡ";s:3:"â“¢";s:3:"Ⓢ";s:3:"â“£";s:3:"Ⓣ";s:3:"ⓤ";s:3:"â“Š";s:3:"â“¥";s:3:"â“‹";s:3:"ⓦ";s:3:"â“Œ";s:3:"ⓧ";s:3:"â“";s:3:"ⓨ";s:3:"â“Ž";s:3:"â“©";s:3:"â“";s:3:"â°°";s:3:"â°€";s:3:"â°±";s:3:"â°";s:3:"â°²";s:3:"â°‚";s:3:"â°³";s:3:"â°ƒ";s:3:"â°´";s:3:"â°„";s:3:"â°µ";s:3:"â°…";s:3:"â°¶";s:3:"â°†";s:3:"â°·";s:3:"â°‡";s:3:"â°¸";s:3:"â°ˆ";s:3:"â°¹";s:3:"â°‰";s:3:"â°º";s:3:"â°Š";s:3:"â°»";s:3:"â°‹";s:3:"â°¼";s:3:"â°Œ";s:3:"â°½";s:3:"â°";s:3:"â°¾";s:3:"â°Ž";s:3:"â°¿";s:3:"â°";s:3:"â±€";s:3:"â°";s:3:"â±";s:3:"â°‘";s:3:"ⱂ";s:3:"â°’";s:3:"ⱃ";s:3:"â°“";s:3:"ⱄ";s:3:"â°”";s:3:"â±…";s:3:"â°•";s:3:"ⱆ";s:3:"â°–";s:3:"ⱇ";s:3:"â°—";s:3:"ⱈ";s:3:"â°˜";s:3:"ⱉ";s:3:"â°™";s:3:"ⱊ";s:3:"â°š";s:3:"ⱋ";s:3:"â°›";s:3:"ⱌ";s:3:"â°œ";s:3:"â±";s:3:"â°";s:3:"ⱎ";s:3:"â°ž";s:3:"â±";s:3:"â°Ÿ";s:3:"â±";s:3:"â° ";s:3:"ⱑ";s:3:"â°¡";s:3:"â±’";s:3:"â°¢";s:3:"ⱓ";s:3:"â°£";s:3:"â±”";s:3:"â°¤";s:3:"ⱕ";s:3:"â°¥";s:3:"â±–";s:3:"â°¦";s:3:"â±—";s:3:"â°§";s:3:"ⱘ";s:3:"â°¨";s:3:"â±™";s:3:"â°©";s:3:"ⱚ";s:3:"â°ª";s:3:"â±›";s:3:"â°«";s:3:"ⱜ";s:3:"â°¬";s:3:"â±";s:3:"â°­";s:3:"ⱞ";s:3:"â°®";s:3:"ⱡ";s:3:"â± ";s:3:"â±¥";s:2:"Ⱥ";s:3:"ⱦ";s:2:"Ⱦ";s:3:"ⱨ";s:3:"Ⱨ";s:3:"ⱪ";s:3:"Ⱪ";s:3:"ⱬ";s:3:"Ⱬ";s:3:"â±³";s:3:"â±²";s:3:"ⱶ";s:3:"â±µ";s:3:"â²";s:3:"â²€";s:3:"ⲃ";s:3:"Ⲃ";s:3:"â²…";s:3:"Ⲅ";s:3:"ⲇ";s:3:"Ⲇ";s:3:"ⲉ";s:3:"Ⲉ";s:3:"ⲋ";s:3:"Ⲋ";s:3:"â²";s:3:"Ⲍ";s:3:"â²";s:3:"Ⲏ";s:3:"ⲑ";s:3:"â²";s:3:"ⲓ";s:3:"â²’";s:3:"ⲕ";s:3:"â²”";s:3:"â²—";s:3:"â²–";s:3:"â²™";s:3:"Ⲙ";s:3:"â²›";s:3:"Ⲛ";s:3:"â²";s:3:"Ⲝ";s:3:"ⲟ";s:3:"Ⲟ";s:3:"ⲡ";s:3:"â² ";s:3:"â²£";s:3:"â²¢";s:3:"â²¥";s:3:"Ⲥ";s:3:"ⲧ";s:3:"Ⲧ";s:3:"ⲩ";s:3:"Ⲩ";s:3:"ⲫ";s:3:"Ⲫ";s:3:"â²­";s:3:"Ⲭ";s:3:"ⲯ";s:3:"â²®";s:3:"â²±";s:3:"â²°";s:3:"â²³";s:3:"â²²";s:3:"â²µ";s:3:"â²´";s:3:"â²·";s:3:"Ⲷ";s:3:"â²¹";s:3:"Ⲹ";s:3:"â²»";s:3:"Ⲻ";s:3:"â²½";s:3:"â²¼";s:3:"ⲿ";s:3:"â²¾";s:3:"â³";s:3:"â³€";s:3:"ⳃ";s:3:"Ⳃ";s:3:"â³…";s:3:"Ⳅ";s:3:"ⳇ";s:3:"Ⳇ";s:3:"ⳉ";s:3:"Ⳉ";s:3:"ⳋ";s:3:"Ⳋ";s:3:"â³";s:3:"Ⳍ";s:3:"â³";s:3:"Ⳏ";s:3:"ⳑ";s:3:"â³";s:3:"ⳓ";s:3:"â³’";s:3:"ⳕ";s:3:"â³”";s:3:"â³—";s:3:"â³–";s:3:"â³™";s:3:"Ⳙ";s:3:"â³›";s:3:"Ⳛ";s:3:"â³";s:3:"Ⳝ";s:3:"ⳟ";s:3:"Ⳟ";s:3:"ⳡ";s:3:"â³ ";s:3:"â³£";s:3:"â³¢";s:3:"ⳬ";s:3:"Ⳬ";s:3:"â³®";s:3:"â³­";s:3:"â³³";s:3:"â³²";s:3:"â´€";s:3:"á‚ ";s:3:"â´";s:3:"á‚¡";s:3:"â´‚";s:3:"á‚¢";s:3:"â´ƒ";s:3:"á‚£";s:3:"â´„";s:3:"Ⴄ";s:3:"â´…";s:3:"á‚¥";s:3:"â´†";s:3:"Ⴆ";s:3:"â´‡";s:3:"Ⴇ";s:3:"â´ˆ";s:3:"Ⴈ";s:3:"â´‰";s:3:"á‚©";s:3:"â´Š";s:3:"Ⴊ";s:3:"â´‹";s:3:"á‚«";s:3:"â´Œ";s:3:"Ⴌ";s:3:"â´";s:3:"á‚­";s:3:"â´Ž";s:3:"á‚®";s:3:"â´";s:3:"Ⴏ";s:3:"â´";s:3:"á‚°";s:3:"â´‘";s:3:"Ⴑ";s:3:"â´’";s:3:"Ⴒ";s:3:"â´“";s:3:"Ⴓ";s:3:"â´”";s:3:"á‚´";s:3:"â´•";s:3:"Ⴕ";s:3:"â´–";s:3:"Ⴖ";s:3:"â´—";s:3:"á‚·";s:3:"â´˜";s:3:"Ⴘ";s:3:"â´™";s:3:"Ⴙ";s:3:"â´š";s:3:"Ⴚ";s:3:"â´›";s:3:"á‚»";s:3:"â´œ";s:3:"Ⴜ";s:3:"â´";s:3:"Ⴝ";s:3:"â´ž";s:3:"Ⴞ";s:3:"â´Ÿ";s:3:"á‚¿";s:3:"â´ ";s:3:"Ⴠ";s:3:"â´¡";s:3:"áƒ";s:3:"â´¢";s:3:"Ⴢ";s:3:"â´£";s:3:"Ⴣ";s:3:"â´¤";s:3:"Ⴤ";s:3:"â´¥";s:3:"Ⴥ";s:3:"â´§";s:3:"Ⴧ";s:3:"â´­";s:3:"áƒ";s:3:"ê™";s:3:"Ꙁ";s:3:"ꙃ";s:3:"Ꙃ";s:3:"ê™…";s:3:"Ꙅ";s:3:"ꙇ";s:3:"Ꙇ";s:3:"ꙉ";s:3:"Ꙉ";s:3:"ꙋ";s:3:"Ꙋ";s:3:"ê™";s:3:"Ꙍ";s:3:"ê™";s:3:"Ꙏ";s:3:"ꙑ";s:3:"ê™";s:3:"ꙓ";s:3:"ê™’";s:3:"ꙕ";s:3:"ê™”";s:3:"ê™—";s:3:"ê™–";s:3:"ê™™";s:3:"Ꙙ";s:3:"ê™›";s:3:"Ꙛ";s:3:"ê™";s:3:"Ꙝ";s:3:"ꙟ";s:3:"Ꙟ";s:3:"ꙡ";s:3:"ê™ ";s:3:"ꙣ";s:3:"Ꙣ";s:3:"ꙥ";s:3:"Ꙥ";s:3:"ꙧ";s:3:"Ꙧ";s:3:"ꙩ";s:3:"Ꙩ";s:3:"ꙫ";s:3:"Ꙫ";s:3:"ê™­";s:3:"Ꙭ";s:3:"êš";s:3:"Ꚁ";s:3:"ꚃ";s:3:"êš‚";s:3:"êš…";s:3:"êš„";s:3:"ꚇ";s:3:"Ꚇ";s:3:"ꚉ";s:3:"Ꚉ";s:3:"êš‹";s:3:"Ꚋ";s:3:"êš";s:3:"Ꚍ";s:3:"êš";s:3:"Ꚏ";s:3:"êš‘";s:3:"êš";s:3:"êš“";s:3:"êš’";s:3:"êš•";s:3:"êš”";s:3:"êš—";s:3:"êš–";s:3:"ꜣ";s:3:"Ꜣ";s:3:"ꜥ";s:3:"Ꜥ";s:3:"ꜧ";s:3:"Ꜧ";s:3:"ꜩ";s:3:"Ꜩ";s:3:"ꜫ";s:3:"Ꜫ";s:3:"ꜭ";s:3:"Ꜭ";s:3:"ꜯ";s:3:"Ꜯ";s:3:"ꜳ";s:3:"Ꜳ";s:3:"ꜵ";s:3:"Ꜵ";s:3:"ꜷ";s:3:"Ꜷ";s:3:"ꜹ";s:3:"Ꜹ";s:3:"ꜻ";s:3:"Ꜻ";s:3:"ꜽ";s:3:"Ꜽ";s:3:"ꜿ";s:3:"Ꜿ";s:3:"ê";s:3:"ê€";s:3:"êƒ";s:3:"ê‚";s:3:"ê…";s:3:"ê„";s:3:"ê‡";s:3:"ê†";s:3:"ê‰";s:3:"êˆ";s:3:"ê‹";s:3:"êŠ";s:3:"ê";s:3:"êŒ";s:3:"ê";s:3:"êŽ";s:3:"ê‘";s:3:"ê";s:3:"ê“";s:3:"ê’";s:3:"ê•";s:3:"ê”";s:3:"ê—";s:3:"ê–";s:3:"ê™";s:3:"ê˜";s:3:"ê›";s:3:"êš";s:3:"ê";s:3:"êœ";s:3:"êŸ";s:3:"êž";s:3:"ê¡";s:3:"ê ";s:3:"ê£";s:3:"ê¢";s:3:"ê¥";s:3:"ê¤";s:3:"ê§";s:3:"ê¦";s:3:"ê©";s:3:"ê¨";s:3:"ê«";s:3:"êª";s:3:"ê­";s:3:"ê¬";s:3:"ê¯";s:3:"ê®";s:3:"êº";s:3:"ê¹";s:3:"ê¼";s:3:"ê»";s:3:"ê¿";s:3:"ê¾";s:3:"êž";s:3:"Ꞁ";s:3:"ꞃ";s:3:"êž‚";s:3:"êž…";s:3:"êž„";s:3:"ꞇ";s:3:"Ꞇ";s:3:"ꞌ";s:3:"êž‹";s:3:"êž‘";s:3:"êž";s:3:"êž“";s:3:"êž’";s:3:"êž¡";s:3:"êž ";s:3:"ꞣ";s:3:"Ꞣ";s:3:"ꞥ";s:3:"Ꞥ";s:3:"ꞧ";s:3:"Ꞧ";s:3:"êž©";s:3:"Ꞩ";s:3:"ï½";s:3:"A";s:3:"b";s:3:"ï¼¢";s:3:"c";s:3:"ï¼£";s:3:"d";s:3:"D";s:3:"ï½…";s:3:"ï¼¥";s:3:"f";s:3:"F";s:3:"g";s:3:"G";s:3:"h";s:3:"H";s:3:"i";s:3:"I";s:3:"j";s:3:"J";s:3:"k";s:3:"K";s:3:"l";s:3:"L";s:3:"ï½";s:3:"ï¼­";s:3:"n";s:3:"ï¼®";s:3:"ï½";s:3:"O";s:3:"ï½";s:3:"ï¼°";s:3:"q";s:3:"ï¼±";s:3:"ï½’";s:3:"ï¼²";s:3:"s";s:3:"ï¼³";s:3:"ï½”";s:3:"ï¼´";s:3:"u";s:3:"ï¼µ";s:3:"ï½–";s:3:"V";s:3:"ï½—";s:3:"ï¼·";s:3:"x";s:3:"X";s:3:"ï½™";s:3:"ï¼¹";s:3:"z";s:3:"Z";s:4:"ð¨";s:4:"ð€";s:4:"ð©";s:4:"ð";s:4:"ðª";s:4:"ð‚";s:4:"ð«";s:4:"ðƒ";s:4:"ð¬";s:4:"ð„";s:4:"ð­";s:4:"ð…";s:4:"ð®";s:4:"ð†";s:4:"ð¯";s:4:"ð‡";s:4:"ð°";s:4:"ðˆ";s:4:"ð±";s:4:"ð‰";s:4:"ð²";s:4:"ðŠ";s:4:"ð³";s:4:"ð‹";s:4:"ð´";s:4:"ðŒ";s:4:"ðµ";s:4:"ð";s:4:"ð¶";s:4:"ðŽ";s:4:"ð·";s:4:"ð";s:4:"ð¸";s:4:"ð";s:4:"ð¹";s:4:"ð‘";s:4:"ðº";s:4:"ð’";s:4:"ð»";s:4:"ð“";s:4:"ð¼";s:4:"ð”";s:4:"ð½";s:4:"ð•";s:4:"ð¾";s:4:"ð–";s:4:"ð¿";s:4:"ð—";s:4:"ð‘€";s:4:"ð˜";s:4:"ð‘";s:4:"ð™";s:4:"ð‘‚";s:4:"ðš";s:4:"ð‘ƒ";s:4:"ð›";s:4:"ð‘„";s:4:"ðœ";s:4:"ð‘…";s:4:"ð";s:4:"ð‘†";s:4:"ðž";s:4:"ð‘‡";s:4:"ðŸ";s:4:"ð‘ˆ";s:4:"ð ";s:4:"ð‘‰";s:4:"ð¡";s:4:"ð‘Š";s:4:"ð¢";s:4:"ð‘‹";s:4:"ð£";s:4:"ð‘Œ";s:4:"ð¤";s:4:"ð‘";s:4:"ð¥";s:4:"ð‘Ž";s:4:"ð¦";s:4:"ð‘";s:4:"ð§";}
    \ No newline at end of file
    diff --git a/vendor/patchwork/utf8/class/Patchwork/TurkishUtf8.php b/vendor/patchwork/utf8/class/Patchwork/TurkishUtf8.php
    new file mode 100755
    index 0000000..ef61ea9
    --- /dev/null
    +++ b/vendor/patchwork/utf8/class/Patchwork/TurkishUtf8.php
    @@ -0,0 +1,112 @@
    + $s)
    +        {
    +            if ('' === $s .= '') $s = '/^(?<=.)$/';
    +            else
    +            {
    +                $s = preg_quote($s, '/');
    +                $s = strtr($s, array(
    +                    'i' => '(?-i:[iÄ°])',
    +                    'Ä°' => '(?-i:[iÄ°])',
    +                    'ı' => '(?-i:[ıI])',
    +                    'I' => '(?-i:[ıI])',
    +                ));
    +                $s = "/{$s}/ui";
    +            }
    +
    +            $search[$i] = $s;
    +        }
    +
    +        $subject = preg_replace($search, $replace, $subject, -1, $replace);
    +        $count = $replace;
    +
    +        return $subject;
    +    }
    +
    +    static function ucfirst($s)
    +    {
    +        if ('i' === substr($s, 0, 1)) return 'Ä°' . substr($s, 1);
    +        else return parent::ucfirst($s);
    +    }
    +
    +    static function ucwords($s)
    +    {
    +        if (false !== strpos($s, 'i')) $s = preg_replace('/\bi/u', 'Ä°', $s);
    +        return parent::ucwords($s);
    +    }
    +}
    diff --git a/vendor/patchwork/utf8/class/Patchwork/Utf8.php b/vendor/patchwork/utf8/class/Patchwork/Utf8.php
    new file mode 100755
    index 0000000..61abfe8
    --- /dev/null
    +++ b/vendor/patchwork/utf8/class/Patchwork/Utf8.php
    @@ -0,0 +1,602 @@
    + $v) $var[$k] = static::filter($v, $normalization_form, $leading_combining);
    +            break;
    +
    +        case 'object':
    +            foreach ($var as $k => $v) $var->$k = static::filter($v, $normalization_form, $leading_combining);
    +            break;
    +
    +        case 'string':
    +            if (false !== strpos($var, "\r"))
    +            {
    +                // Workaround https://bugs.php.net/65732
    +                $var = str_replace("\r\n", "\n", $var);
    +                $var = strtr($var, "\r", "\n");
    +            }
    +
    +            if (preg_match('/[\x80-\xFF]/', $var))
    +            {
    +                if (n::isNormalized($var, $normalization_form)) $n = '-';
    +                else
    +                {
    +                    $n = n::normalize($var, $normalization_form);
    +                    if (isset($n[0])) $var = $n;
    +                    else $var = static::utf8_encode($var);
    +                }
    +
    +                if ($var[0] >= "\x80" && isset($n[0], $leading_combining[0]) && preg_match('/^\p{Mn}/u', $var))
    +                {
    +                    // Prevent leading combining chars
    +                    // for NFC-safe concatenations.
    +                    $var = $leading_combining . $var;
    +                }
    +            }
    +            break;
    +        }
    +
    +        return $var;
    +    }
    +
    +    // Unicode transformation for caseless matching
    +    // see http://unicode.org/reports/tr21/tr21-5.html
    +
    +    static function strtocasefold($s, $full = true)
    +    {
    +        $s = str_replace(self::$commonCaseFold[0], self::$commonCaseFold[1], $s);
    +
    +        if ($full)
    +        {
    +            static $fullCaseFold = false;
    +            $fullCaseFold || $fullCaseFold = static::getData('caseFolding_full');
    +
    +            $s = str_replace($fullCaseFold[0], $fullCaseFold[1], $s);
    +        }
    +
    +        return static::strtolower($s);
    +    }
    +
    +    // Generic case sensitive collation support for self::strnatcmp()
    +
    +    static function strtonatfold($s)
    +    {
    +        $s = n::normalize($s, n::NFD);
    +        return preg_replace('/\p{Mn}+/u', '', $s);
    +    }
    +
    +    // PHP string functions that need UTF-8 awareness
    +
    +    static function filter_input($type, $var, $filter = FILTER_DEFAULT, $option = null)
    +    {
    +        if (4 > func_num_args()) $var = filter_input($type, $var, $filter);
    +        else $var = filter_input($type, $var, $filter, $option);
    +
    +        return static::filter($var);
    +    }
    +
    +    static function filter_input_array($type, $def = null, $add_empty = true)
    +    {
    +        if (2 > func_num_args()) $a = filter_input_array($type);
    +        else $a = filter_input_array($type, $def, $add_empty);
    +
    +        return static::filter($a);
    +    }
    +
    +    static function json_decode($json, $assoc = false, $depth = 512, $options = 0)
    +    {
    +/**/    if (PHP_VERSION_ID < 50400)
    +/**/    {
    +            $json = json_decode($json, $assoc, $depth);
    +/**/    }
    +/**/    else
    +/**/    {
    +            $json = json_decode($json, $assoc, $depth, $options);
    +/**/    }
    +
    +        return static::filter($json);
    +    }
    +
    +    static function substr($s, $start, $len = 2147483647)
    +    {
    +/**/    static $bug62759;
    +
    +/**/    isset($bug62759) or $bug62759 = extension_loaded('intl') && 'à' === grapheme_substr('éà', 1, -2);
    +
    +/**/    if ($bug62759)
    +/**/    {
    +            return PHP\Shim\Intl::grapheme_substr_workaround62759($s, $start, $len);
    +/**/    }
    +/**/    else
    +/**/    {
    +            return grapheme_substr($s, $start, $len);
    +/**/    }
    +    }
    +
    +    static function strlen($s) {return grapheme_strlen($s);}
    +    static function strpos ($s, $needle, $offset = 0) {return grapheme_strpos ($s, $needle, $offset);}
    +    static function strrpos($s, $needle, $offset = 0) {return grapheme_strrpos($s, $needle, $offset);}
    +
    +    static function stripos($s, $needle, $offset = 0)
    +    {
    +/**/    if (50418 > PHP_VERSION_ID || 50500 == PHP_VERSION_ID)
    +/**/    {
    +            // Don't use grapheme_stripos because of https://bugs.php.net/61860
    +            if (! preg_match('//u', $s .= '')) return false;
    +            if ($offset < 0) $offset = 0;
    +            if (! $needle = mb_stripos($s, $needle .= '', $offset, 'UTF-8')) return $needle;
    +            return grapheme_strlen(iconv_substr($s, 0, $needle, 'UTF-8'));
    +/**/    }
    +/**/    else
    +/**/    {
    +            return grapheme_stripos($s, $needle, $offset);
    +/**/    }
    +    }
    +
    +    static function strripos($s, $needle, $offset = 0)
    +    {
    +/**/    if (50418 > PHP_VERSION_ID || 50500 == PHP_VERSION_ID)
    +/**/    {
    +            // Don't use grapheme_strripos because of https://bugs.php.net/61860
    +            if (! preg_match('//u', $s .= '')) return false;
    +            if ($offset < 0) $offset = 0;
    +            if (! $needle = mb_strripos($s, $needle .= '', $offset, 'UTF-8')) return $needle;
    +            return grapheme_strlen(iconv_substr($s, 0, $needle, 'UTF-8'));
    +/**/    }
    +/**/    else
    +/**/    {
    +            return grapheme_strripos($s, $needle, $offset);
    +/**/    }
    +    }
    +
    +    static function stristr($s, $needle, $before_needle = false)
    +    {
    +        if ('' === $needle .= '') return false;
    +        return mb_stristr($s, $needle, $before_needle, 'UTF-8');
    +    }
    +
    +    static function strstr  ($s, $needle, $before_needle = false) {return grapheme_strstr($s, $needle, $before_needle);}
    +    static function strrchr ($s, $needle, $before_needle = false) {return mb_strrchr ($s, $needle, $before_needle, 'UTF-8');}
    +    static function strrichr($s, $needle, $before_needle = false) {return mb_strrichr($s, $needle, $before_needle, 'UTF-8');}
    +
    +    static function strtolower($s) {return mb_strtolower($s, 'UTF-8');}
    +    static function strtoupper($s) {return mb_strtoupper($s, 'UTF-8');}
    +
    +    static function wordwrap($s, $width = 75, $break = "\n", $cut = false)
    +    {
    +        if (false === wordwrap('-', $width, $break, $cut)) return false;
    +
    +        is_string($break) or $break = (string) $break;
    +
    +        $w = '';
    +        $s = explode($break, $s);
    +        $iLen = count($s);
    +        $chars = array();
    +
    +        if (1 === $iLen && '' === $s[0])
    +            return '';
    +
    +        for ($i = 0; $i < $iLen; ++$i)
    +        {
    +            if ($i)
    +            {
    +                $chars[] = $break;
    +                $w .= '#';
    +            }
    +
    +            $c = $s[$i];
    +            unset($s[$i]);
    +
    +            foreach (self::str_split($c) as $c)
    +            {
    +                $chars[] = $c;
    +                $w .= ' ' === $c ? ' ' : '?';
    +            }
    +        }
    +
    +        $s = '';
    +        $j = 0;
    +        $b = $i = -1;
    +        $w = wordwrap($w, $width, '#', $cut);
    +
    +        while (false !== $b = strpos($w, '#', $b+1))
    +        {
    +            for (++$i; $i < $b; ++$i)
    +            {
    +                $s .= $chars[$j];
    +                unset($chars[$j++]);
    +            }
    +
    +            if ($break === $chars[$j] || ' ' === $chars[$j]) unset($chars[$j++]);
    +            $s .= $break;
    +        }
    +
    +        return $s . implode('', $chars);
    +    }
    +
    +    static function chr($c)
    +    {
    +        if (0x80 > $c %= 0x200000) return chr($c);
    +        if (0x800 > $c) return chr(0xC0 | $c>>6) . chr(0x80 | $c & 0x3F);
    +        if (0x10000 > $c) return chr(0xE0 | $c>>12) . chr(0x80 | $c>>6 & 0x3F) . chr(0x80 | $c & 0x3F);
    +        return chr(0xF0 | $c>>18) . chr(0x80 | $c>>12 & 0x3F) . chr(0x80 | $c>>6 & 0x3F) . chr(0x80 | $c & 0x3F);
    +    }
    +
    +    static function count_chars($s, $mode = 0)
    +    {
    +        if (1 != $mode) user_error(__METHOD__ . '(): the only allowed $mode is 1', E_USER_WARNING);
    +        $s = self::str_split($s);
    +        return array_count_values($s);
    +    }
    +
    +    static function ltrim($s, $charlist = INF)
    +    {
    +        $charlist = INF === $charlist ? '\s' : self::rxClass($charlist);
    +        return preg_replace("/^{$charlist}+/u", '', $s);
    +    }
    +
    +    static function ord($s)
    +    {
    +        $a = ($s = unpack('C*', substr($s, 0, 4))) ? $s[1] : 0;
    +        if (0xF0 <= $a) return (($a - 0xF0)<<18) + (($s[2] - 0x80)<<12) + (($s[3] - 0x80)<<6) + $s[4] - 0x80;
    +        if (0xE0 <= $a) return (($a - 0xE0)<<12) + (($s[2] - 0x80)<<6) + $s[3] - 0x80;
    +        if (0xC0 <= $a) return (($a - 0xC0)<<6) + $s[2] - 0x80;
    +        return $a;
    +    }
    +
    +    static function rtrim($s, $charlist = INF)
    +    {
    +        $charlist = INF === $charlist ? '\s' : self::rxClass($charlist);
    +        return preg_replace("/{$charlist}+$/u", '', $s);
    +    }
    +
    +    static function trim($s, $charlist = INF) {return self::rtrim(self::ltrim($s, $charlist), $charlist);}
    +
    +    static function str_ireplace($search, $replace, $subject, &$count = null)
    +    {
    +        $search = (array) $search;
    +
    +        foreach ($search as $i => $s)
    +        {
    +            if ('' === $s .= '') $s = '/^(?<=.)$/';
    +            else $s = '/' . preg_quote($s, '/') . '/ui';
    +
    +            $search[$i] = $s;
    +        }
    +
    +        $subject = preg_replace($search, $replace, $subject, -1, $replace);
    +        $count = $replace;
    +
    +        return $subject;
    +    }
    +
    +    static function str_pad($s, $len, $pad = ' ', $type = STR_PAD_RIGHT)
    +    {
    +        $slen = grapheme_strlen($s);
    +        if ($len <= $slen) return $s;
    +
    +        $padlen = grapheme_strlen($pad);
    +        $freelen = $len - $slen;
    +        $len = $freelen % $padlen;
    +
    +        if (STR_PAD_RIGHT == $type) return $s . str_repeat($pad, $freelen / $padlen) . ($len ? grapheme_substr($pad, 0, $len) : '');
    +        if (STR_PAD_LEFT  == $type) return      str_repeat($pad, $freelen / $padlen) . ($len ? grapheme_substr($pad, 0, $len) : '') . $s;
    +        if (STR_PAD_BOTH  == $type)
    +        {
    +            $freelen /= 2;
    +
    +            $type = ceil($freelen);
    +            $len = $type % $padlen;
    +            $s .= str_repeat($pad, $type / $padlen) . ($len ? grapheme_substr($pad, 0, $len) : '');
    +
    +            $type = floor($freelen);
    +            $len = $type % $padlen;
    +            return str_repeat($pad, $type / $padlen) . ($len ? grapheme_substr($pad, 0, $len) : '') . $s;
    +        }
    +
    +        user_error(__METHOD__ . '(): Padding type has to be STR_PAD_LEFT, STR_PAD_RIGHT, or STR_PAD_BOTH', E_USER_WARNING);
    +    }
    +
    +    static function str_shuffle($s)
    +    {
    +        $s = self::str_split($s);
    +        shuffle($s);
    +        return implode('', $s);
    +    }
    +
    +    static function str_split($s, $len = 1)
    +    {
    +        if (1 > $len = (int) $len)
    +        {
    +            $len = func_get_arg(1);
    +            return str_split($s, $len);
    +        }
    +
    +/**/    if (extension_loaded('intl'))
    +/**/    {
    +            $a = array();
    +            $p = 0;
    +            $l = strlen($s);
    +
    +            while ($p < $l) $a[] = grapheme_extract($s, 1, GRAPHEME_EXTR_COUNT, $p, $p);
    +/**/    }
    +/**/    else
    +/**/    {
    +            preg_match_all('/' . GRAPHEME_CLUSTER_RX . '/u', $s, $a);
    +            $a = $a[0];
    +/**/    }
    +
    +        if (1 == $len) return $a;
    +
    +        $s = array();
    +        $p = -1;
    +
    +        foreach ($a as $l => $a)
    +        {
    +            if ($l % $len) $s[$p] .= $a;
    +            else $s[++$p] = $a;
    +        }
    +
    +        return $s;
    +    }
    +
    +    static function str_word_count($s, $format = 0, $charlist = '')
    +    {
    +        $charlist = self::rxClass($charlist, '\pL');
    +        $s = preg_split("/({$charlist}+(?:[\p{Pd}’']{$charlist}+)*)/u", $s, -1, PREG_SPLIT_DELIM_CAPTURE);
    +
    +        $charlist = array();
    +        $len = count($s);
    +
    +        if (1 == $format) for ($i = 1; $i < $len; $i+=2) $charlist[] = $s[$i];
    +        else if (2 == $format)
    +        {
    +            $offset = grapheme_strlen($s[0]);
    +            for ($i = 1; $i < $len; $i+=2)
    +            {
    +                $charlist[$offset] = $s[$i];
    +                $offset += grapheme_strlen($s[$i]) + grapheme_strlen($s[$i+1]);
    +            }
    +        }
    +        else $charlist = ($len - 1) / 2;
    +
    +        return $charlist;
    +    }
    +
    +    static function strcmp       ($a, $b) {return $a . '' === $b . '' ? 0 : strcmp(n::normalize($a, n::NFD), n::normalize($b, n::NFD));}
    +    static function strnatcmp    ($a, $b) {return $a . '' === $b . '' ? 0 : strnatcmp(self::strtonatfold($a), self::strtonatfold($b));}
    +    static function strcasecmp   ($a, $b) {return self::strcmp   (static::strtocasefold($a), static::strtocasefold($b));}
    +    static function strnatcasecmp($a, $b) {return self::strnatcmp(static::strtocasefold($a), static::strtocasefold($b));}
    +    static function strncasecmp  ($a, $b, $len) {return self::strncmp(static::strtocasefold($a), static::strtocasefold($b), $len);}
    +    static function strncmp      ($a, $b, $len) {return self::strcmp(self::substr($a, 0, $len), self::substr($b, 0, $len));}
    +
    +    static function strcspn($s, $charlist, $start = 0, $len = 2147483647)
    +    {
    +        if ('' === $charlist .= '') return null;
    +        if ($start || 2147483647 != $len) $s = self::substr($s, $start, $len);
    +
    +        return preg_match('/^(.*?)' . self::rxClass($charlist) . '/us', $s, $len) ? grapheme_strlen($len[1]) : grapheme_strlen($s);
    +    }
    +
    +    static function strpbrk($s, $charlist)
    +    {
    +        if (preg_match('/' . self::rxClass($charlist) . '/us', $s, $m)) return substr($s, strpos($s, $m[0]));
    +        else return false;
    +    }
    +
    +    static function strrev($s)
    +    {
    +        $s = self::str_split($s);
    +        return implode('', array_reverse($s));
    +    }
    +
    +    static function strspn($s, $mask, $start = 0, $len = 2147483647)
    +    {
    +        if ($start || 2147483647 != $len) $s = self::substr($s, $start, $len);
    +        return preg_match('/^' . self::rxClass($mask) . '+/u', $s, $s) ? grapheme_strlen($s[0]) : 0;
    +    }
    +
    +    static function strtr($s, $from, $to = INF)
    +    {
    +        if (INF !== $to)
    +        {
    +            $from = self::str_split($from);
    +            $to   = self::str_split($to);
    +
    +            $a = count($from);
    +            $b = count($to);
    +
    +                 if ($a > $b) $from = array_slice($from, 0, $b);
    +            else if ($a < $b) $to   = array_slice($to  , 0, $a);
    +
    +            $from = array_combine($from, $to);
    +        }
    +
    +        return strtr($s, $from);
    +    }
    +
    +    static function substr_compare($a, $b, $offset, $len = 2147483647, $i = 0)
    +    {
    +        $a = self::substr($a, $offset, $len);
    +        return $i ? static::strcasecmp($a, $b) : self::strcmp($a, $b);
    +    }
    +
    +    static function substr_count($s, $needle, $offset = 0, $len = 2147483647)
    +    {
    +        return substr_count(self::substr($s, $offset, $len), $needle);
    +    }
    +
    +    static function substr_replace($s, $replace, $start, $len = 2147483647)
    +    {
    +        $s       = self::str_split($s);
    +        $replace = self::str_split($replace);
    +        array_splice($s, $start, $len, $replace);
    +        return implode('', $s);
    +    }
    +
    +    static function ucfirst($s)
    +    {
    +        $c = iconv_substr($s, 0, 1, 'UTF-8');
    +        return static::ucwords($c) . substr($s, strlen($c));
    +    }
    +
    +    static function lcfirst($s)
    +    {
    +        $c = iconv_substr($s, 0, 1, 'UTF-8');
    +        return static::strtolower($c) . substr($s, strlen($c));
    +    }
    +
    +    static function ucwords($s)
    +    {
    +        return mb_convert_case($s, MB_CASE_TITLE, 'UTF-8');
    +    }
    +
    +    static function number_format($number, $decimals = 0, $dec_point = '.', $thousands_sep = ',')
    +    {
    +/**/    if (PHP_VERSION_ID < 50400)
    +/**/    {
    +            if (isset($thousands_sep[1]) || isset($dec_point[1]))
    +            {
    +                return str_replace(
    +                    array('.', ','),
    +                    array($dec_point, $thousands_sep),
    +                    number_format($number, $decimals, '.', ',')
    +                );
    +            }
    +/**/    }
    +
    +        return number_format($number, $decimals, $dec_point, $thousands_sep);
    +    }
    +
    +    static function utf8_encode($s)
    +    {
    +        $s = utf8_encode($s);
    +        if (false === strpos($s, "\xC2")) return $s;
    +        else return str_replace(self::$cp1252, self::$utf8, $s);
    +    }
    +
    +    static function utf8_decode($s)
    +    {
    +        $s = str_replace(self::$utf8, self::$cp1252, $s);
    +        return utf8_decode($s);
    +    }
    +
    +
    +    protected static function rxClass($s, $class = '')
    +    {
    +        $class = array($class);
    +
    +        foreach (self::str_split($s) as $s)
    +        {
    +            if ('-' === $s) $class[0] = '-' . $class[0];
    +            else if (!isset($s[2])) $class[0] .= preg_quote($s, '/');
    +            else if (1 === iconv_strlen($s, 'UTF-8')) $class[0] .= $s;
    +            else $class[] = $s;
    +        }
    +
    +        $class[0] = '[' . $class[0] . ']';
    +
    +        if (1 === count($class)) return $class[0];
    +        else return '(?:' . implode('|', $class) . ')';
    +    }
    +
    +    protected static function getData($file)
    +    {
    +        $file = __DIR__ . '/Utf8/data/' . $file . '.ser';
    +        if (file_exists($file)) return unserialize(file_get_contents($file));
    +        else return false;
    +    }
    +}
    diff --git a/vendor/patchwork/utf8/class/Patchwork/Utf8/Bootup.php b/vendor/patchwork/utf8/class/Patchwork/Utf8/Bootup.php
    new file mode 100755
    index 0000000..4fe5688
    --- /dev/null
    +++ b/vendor/patchwork/utf8/class/Patchwork/Utf8/Bootup.php
    @@ -0,0 +1,253 @@
    += "\x80" && isset($n[0], $leading_combining[0]) && preg_match('/^\p{Mn}/u', $s))
    +            {
    +                // Prevent leading combining chars
    +                // for NFC-safe concatenations.
    +                $s = $leading_combining . $s;
    +            }
    +        }
    +
    +        return $s;
    +    }
    +}
    diff --git a/vendor/patchwork/utf8/class/Patchwork/Utf8/Bootup/iconv.php b/vendor/patchwork/utf8/class/Patchwork/Utf8/Bootup/iconv.php
    new file mode 100755
    index 0000000..cd29d86
    --- /dev/null
    +++ b/vendor/patchwork/utf8/class/Patchwork/Utf8/Bootup/iconv.php
    @@ -0,0 +1,48 @@
    +";s:3:"《";s:2:"<<";s:3:"》";s:2:">>";s:3:"〔";s:1:"[";s:3:"〕";s:1:"]";s:3:"〘";s:1:"[";s:3:"〙";s:1:"]";s:3:"〚";s:1:"[";s:3:"〛";s:1:"]";s:3:"︑";s:1:",";s:3:"︒";s:1:".";s:3:"︹";s:1:"[";s:3:"︺";s:1:"]";s:3:"︽";s:2:"<<";s:3:"︾";s:2:">>";s:3:"︿";s:1:"<";s:3:"﹀";s:1:">";s:2:"÷";s:1:"/";s:3:"∥";s:2:"||";s:3:"⦅";s:2:"((";s:3:"⦆";s:2:"))";}
    \ No newline at end of file
    diff --git a/vendor/patchwork/utf8/composer.json b/vendor/patchwork/utf8/composer.json
    new file mode 100755
    index 0000000..2d8efa3
    --- /dev/null
    +++ b/vendor/patchwork/utf8/composer.json
    @@ -0,0 +1,30 @@
    +{
    +    "name": "patchwork/utf8",
    +    "type": "library",
    +    "description": "Extensive, portable and performant handling of UTF-8 and grapheme clusters for PHP",
    +    "keywords": ["utf8","utf-8","unicode","i18n"],
    +    "homepage": "https://github.com/nicolas-grekas/Patchwork-UTF8",
    +    "license": "(Apache-2.0 or GPL-2.0)",
    +    "authors": [
    +        {
    +            "name": "Nicolas Grekas",
    +            "email": "p@tchwork.com",
    +            "role": "Developer"
    +        }
    +    ],
    +    "require": {
    +        "php": ">=5.3.0",
    +        "lib-pcre": ">=7.3"
    +    },
    +    "suggest": {
    +        "ext-intl": "Use Intl for best performance",
    +        "ext-iconv": "Use iconv for best performance",
    +        "ext-mbstring": "Use Mbstring for best performance"
    +    },
    +    "autoload": {
    +        "psr-0": {
    +            "Patchwork": "class/",
    +            "Normalizer": "class/"
    +        }
    +    }
    +}
    diff --git a/vendor/patchwork/utf8/phpunit.xml.dist b/vendor/patchwork/utf8/phpunit.xml.dist
    new file mode 100755
    index 0000000..b73ebd8
    --- /dev/null
    +++ b/vendor/patchwork/utf8/phpunit.xml.dist
    @@ -0,0 +1,21 @@
    +
    +
    +
    +
    +    
    +        
    +            ./tests/Patchwork/
    +            ./tests/php-utf8/
    +            ./tests/unicode/
    +        
    +    
    +
    +    
    +        
    +            unicode
    +        
    +    
    +
    +
    diff --git a/vendor/phpseclib/phpseclib/.gitattributes b/vendor/phpseclib/phpseclib/.gitattributes
    new file mode 100755
    index 0000000..176a458
    --- /dev/null
    +++ b/vendor/phpseclib/phpseclib/.gitattributes
    @@ -0,0 +1 @@
    +* text=auto
    diff --git a/vendor/phpseclib/phpseclib/.gitignore b/vendor/phpseclib/phpseclib/.gitignore
    new file mode 100755
    index 0000000..1469fe6
    --- /dev/null
    +++ b/vendor/phpseclib/phpseclib/.gitignore
    @@ -0,0 +1,2 @@
    +/vendor
    +/composer.phar
    diff --git a/vendor/phpseclib/phpseclib/.travis.yml b/vendor/phpseclib/phpseclib/.travis.yml
    new file mode 100755
    index 0000000..76fae1c
    --- /dev/null
    +++ b/vendor/phpseclib/phpseclib/.travis.yml
    @@ -0,0 +1,28 @@
    +language: php
    +
    +php:
    +  - 5.2
    +  - 5.3.3
    +  - 5.3
    +  - 5.4
    +  - 5.5
    +  - 5.6
    +  - hhvm
    +
    +env:
    +  global:
    +    # Defines CODE_COVERAGE_PASSPHRASE which is the passphrase for unlocking
    +    # the travis/code_coverage_id_rsa RSA private key.
    +    - secure: "jtQTZKQBnzUlp/jz7NlM6470ZDnLGVAs53sgvIm4tcYqf9TWSXSXjIYvFsrS\nKPR2eyZaAevYysUkIGRFTUXTlG6tC36YngMp9+6FPxASl8mnGXsTbKcm613B\n59vD3242pgIgqhhmgFQ0c8gbvnE8PuF2aS4/hluP3r+AxhWN56E="
    +
    +before_script:
    +  - sh -c "if [ '$TRAVIS_PHP_VERSION' != 'hhvm' ]; then travis/install-php-extensions.sh; fi"
    +  - sh -c "if [ '$TRAVIS_PHP_VERSION' = '5.5' ]; then composer install --dev --no-interaction; fi"
    +
    +script:
    +  - sh -c "if [ '$TRAVIS_PHP_VERSION' = '5.5' ]; then vendor/bin/phpcs -s --extensions=php --standard=build/code-sniffer-ruleset.xml phpseclib/; fi"
    +  - sh -c "if [ '$TRAVIS_PHP_VERSION' = '5.5' ]; then vendor/bin/phpcs -s --extensions=php --standard=build/code-sniffer-ruleset-tests.xml tests/; fi"
    +  - phpunit --verbose --coverage-text --coverage-html code_coverage/
    +
    +after_success:
    +  - sh -c "if $TRAVIS_SECURE_ENV_VARS; then travis/upload-code-coverage.sh; fi"
    diff --git a/vendor/phpseclib/phpseclib/AUTHORS b/vendor/phpseclib/phpseclib/AUTHORS
    new file mode 100755
    index 0000000..e175f9f
    --- /dev/null
    +++ b/vendor/phpseclib/phpseclib/AUTHORS
    @@ -0,0 +1,5 @@
    +phpseclib Lead Developer:  TerraFrost (Jim Wigginton)
    +
    +phpseclib Developers:      monnerat (Patrick Monnerat)
    +                           bantu (Andreas Fischer)
    +                           petrich (Hans-Jürgen Petrich)
    diff --git a/vendor/phpseclib/phpseclib/LICENSE b/vendor/phpseclib/phpseclib/LICENSE
    new file mode 100755
    index 0000000..75f6b20
    --- /dev/null
    +++ b/vendor/phpseclib/phpseclib/LICENSE
    @@ -0,0 +1,21 @@
    +Copyright 2007-2013 TerraFrost and other contributors
    +http://phpseclib.sourceforge.net/
    +
    +Permission is hereby granted, free of charge, to any person obtaining
    +a copy of this software and associated documentation files (the
    +"Software"), to deal in the Software without restriction, including
    +without limitation the rights to use, copy, modify, merge, publish,
    +distribute, sublicense, and/or sell copies of the Software, and to
    +permit persons to whom the Software is furnished to do so, subject to
    +the following conditions:
    +
    +The above copyright notice and this permission notice shall be
    +included in all copies or substantial portions of the Software.
    +
    +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
    +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
    +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
    +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
    +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
    +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
    +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
    diff --git a/vendor/phpseclib/phpseclib/README.md b/vendor/phpseclib/phpseclib/README.md
    new file mode 100755
    index 0000000..de52823
    --- /dev/null
    +++ b/vendor/phpseclib/phpseclib/README.md
    @@ -0,0 +1,16 @@
    +# phpseclib - PHP Secure Communications Library
    +
    +[![Build Status](https://secure.travis-ci.org/phpseclib/phpseclib.png?branch=master)](http://travis-ci.org/phpseclib/phpseclib)
    +
    +MIT-licensed pure-PHP implementations of an arbitrary-precision integer
    +arithmetic library, fully PKCS#1 (v2.1) compliant RSA, DES, 3DES, RC4, Rijndael,
    +AES, Blowfish, Twofish, SSH-1, SSH-2, SFTP, and X.509
    +
    +* [Download (0.3.6)](http://sourceforge.net/projects/phpseclib/files/phpseclib0.3.6.zip/download)
    +* [Browse Git](https://github.com/phpseclib/phpseclib)
    +* [Documentation](http://phpseclib.sourceforge.net/)
    +* [Support](http://www.frostjedi.com/phpbb/viewforum.php?f=46)
    +* [Code Coverage Report](http://phpseclib.bantux.org/code_coverage/master/latest/)
    +
    +PEAR Channel
    +PEAR Channel: [phpseclib.sourceforge.net](http://phpseclib.sourceforge.net/pear.htm)
    diff --git a/vendor/phpseclib/phpseclib/build/code-sniffer-ruleset-tests.xml b/vendor/phpseclib/phpseclib/build/code-sniffer-ruleset-tests.xml
    new file mode 100755
    index 0000000..c369425
    --- /dev/null
    +++ b/vendor/phpseclib/phpseclib/build/code-sniffer-ruleset-tests.xml
    @@ -0,0 +1,21 @@
    +
    +
    +
    + phpseclib coding standard for tests
    +
    + 
    + 
    +   
    +
    +   
    +   
    +   
    +   
    +   
    +   
    + 
    +
    +
    diff --git a/vendor/phpseclib/phpseclib/build/code-sniffer-ruleset.xml b/vendor/phpseclib/phpseclib/build/code-sniffer-ruleset.xml
    new file mode 100755
    index 0000000..9da1625
    --- /dev/null
    +++ b/vendor/phpseclib/phpseclib/build/code-sniffer-ruleset.xml
    @@ -0,0 +1,76 @@
    +
    +
    +
    + phpseclib coding standard
    +
    + 
    + 
    +   
    +   
    +   
    +   
    +   
    +   
    +   
    +   
    +   
    +   
    +   
    +   
    +   
    +   
    +   
    +   
    +   
    +   
    +   
    +   
    +   
    +   
    +   
    +   
    +   
    +   
    +   
    +   
    + 
    +
    + 
    +
    + 
    + 
    +
    + 
    + 
    +
    + 
    + 
    +
    + 
    + 
    +
    + 
    + 
    +  
    +   
    +  
    + 
    + 
    +
    + 
    + 
    +
    + 
    + 
    +
    + 
    + 
    +
    + 
    + 
    +
    + 
    + 
    +
    +
    diff --git a/vendor/phpseclib/phpseclib/composer.json b/vendor/phpseclib/phpseclib/composer.json
    new file mode 100755
    index 0000000..70f4f7c
    --- /dev/null
    +++ b/vendor/phpseclib/phpseclib/composer.json
    @@ -0,0 +1,77 @@
    +{
    +    "name": "phpseclib/phpseclib",
    +    "type": "library",
    +    "description": "PHP Secure Communications Library - Pure-PHP implementations of RSA, AES, SSH2, SFTP, X.509 etc.",
    +    "keywords": [
    +        "security",
    +        "crypto",
    +        "cryptography",
    +        "encryption",
    +        "signature",
    +        "signing",
    +        "rsa",
    +        "aes",
    +        "blowfish",
    +        "twofish",
    +        "ssh",
    +        "sftp",
    +        "x509",
    +        "x.509",
    +        "asn1",
    +        "asn.1",
    +        "BigInteger"
    +        ],
    +    "homepage": "http://phpseclib.sourceforge.net",
    +    "license": "MIT",
    +    "authors": [
    +        {
    +            "name": "Jim Wigginton",
    +            "email": "terrafrost@php.net",
    +            "role": "Lead Developer"
    +        },
    +        {
    +            "name": "Patrick Monnerat",
    +            "email": "pm@datasphere.ch",
    +            "role": "Developer"
    +        },
    +        {
    +            "name": "Andreas Fischer",
    +            "email": "bantu@phpbb.com",
    +            "role": "Developer"
    +        },
    +        {
    +            "name": "Hans-Jürgen Petrich",
    +            "email": "petrich@tronic-media.com",
    +            "role": "Developer"
    +        }
    +    ],
    +    "require": {
    +        "php": ">=5.0.0"
    +    },
    +    "require-dev": {
    +        "squizlabs/php_codesniffer": "1.*"
    +    },
    +    "suggest": {
    +        "ext-mcrypt": "Install the Mcrypt extension in order to speed up a wide variety of cryptographic operations.",
    +        "ext-gmp": "Install the GMP (GNU Multiple Precision) extension in order to speed up arbitrary precision integer arithmetic operations.",
    +        "pear-pear/PHP_Compat": "Install PHP_Compat to get phpseclib working on PHP < 4.3.3."
    +    },
    +    "include-path": ["phpseclib/"],
    +    "autoload": {
    +        "psr-0": {
    +            "Crypt": "phpseclib/",
    +            "File": "phpseclib/",
    +            "Math": "phpseclib/",
    +            "Net": "phpseclib/",
    +            "System": "phpseclib/"
    +        },
    +        "files": [
    +            "phpseclib/Crypt/Random.php"
    +        ]
    +    },
    +    "extra": {
    +        "branch-alias": {
    +            "dev-master": "0.3-dev"
    +        }
    +    }
    +}
    diff --git a/vendor/phpseclib/phpseclib/composer.lock b/vendor/phpseclib/phpseclib/composer.lock
    new file mode 100755
    index 0000000..1b5ff07
    --- /dev/null
    +++ b/vendor/phpseclib/phpseclib/composer.lock
    @@ -0,0 +1,95 @@
    +{
    +    "_readme": [
    +        "This file locks the dependencies of your project to a known state",
    +        "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file"
    +    ],
    +    "hash": "4975b8cde04a99d6e78e108753845af6",
    +    "packages": [
    +
    +    ],
    +    "packages-dev": [
    +        {
    +            "name": "squizlabs/php_codesniffer",
    +            "version": "1.5.2",
    +            "source": {
    +                "type": "git",
    +                "url": "https://github.com/squizlabs/PHP_CodeSniffer.git",
    +                "reference": "a76a39b317ce8106abe6264daa505e24e1731860"
    +            },
    +            "dist": {
    +                "type": "zip",
    +                "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/a76a39b317ce8106abe6264daa505e24e1731860",
    +                "reference": "a76a39b317ce8106abe6264daa505e24e1731860",
    +                "shasum": ""
    +            },
    +            "require": {
    +                "ext-tokenizer": "*",
    +                "php": ">=5.1.2"
    +            },
    +            "suggest": {
    +                "phpunit/php-timer": "dev-master"
    +            },
    +            "bin": [
    +                "scripts/phpcs"
    +            ],
    +            "type": "library",
    +            "autoload": {
    +                "classmap": [
    +                    "CodeSniffer.php",
    +                    "CodeSniffer/CLI.php",
    +                    "CodeSniffer/Exception.php",
    +                    "CodeSniffer/File.php",
    +                    "CodeSniffer/Report.php",
    +                    "CodeSniffer/Reporting.php",
    +                    "CodeSniffer/Sniff.php",
    +                    "CodeSniffer/Tokens.php",
    +                    "CodeSniffer/Reports/",
    +                    "CodeSniffer/CommentParser/",
    +                    "CodeSniffer/Tokenizers/",
    +                    "CodeSniffer/DocGenerators/",
    +                    "CodeSniffer/Standards/AbstractPatternSniff.php",
    +                    "CodeSniffer/Standards/AbstractScopeSniff.php",
    +                    "CodeSniffer/Standards/AbstractVariableSniff.php",
    +                    "CodeSniffer/Standards/IncorrectPatternException.php",
    +                    "CodeSniffer/Standards/Generic/Sniffs/",
    +                    "CodeSniffer/Standards/MySource/Sniffs/",
    +                    "CodeSniffer/Standards/PEAR/Sniffs/",
    +                    "CodeSniffer/Standards/PSR1/Sniffs/",
    +                    "CodeSniffer/Standards/PSR2/Sniffs/",
    +                    "CodeSniffer/Standards/Squiz/Sniffs/",
    +                    "CodeSniffer/Standards/Zend/Sniffs/"
    +                ]
    +            },
    +            "notification-url": "https://packagist.org/downloads/",
    +            "license": [
    +                "BSD-3-Clause"
    +            ],
    +            "authors": [
    +                {
    +                    "name": "Greg Sherwood",
    +                    "role": "lead"
    +                }
    +            ],
    +            "description": "PHP_CodeSniffer tokenises PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.",
    +            "homepage": "http://www.squizlabs.com/php-codesniffer",
    +            "keywords": [
    +                "phpcs",
    +                "standards"
    +            ],
    +            "time": "2014-02-04 23:49:58"
    +        }
    +    ],
    +    "aliases": [
    +
    +    ],
    +    "minimum-stability": "stable",
    +    "stability-flags": [
    +
    +    ],
    +    "platform": {
    +        "php": ">=5.0.0"
    +    },
    +    "platform-dev": [
    +
    +    ]
    +}
    diff --git a/vendor/phpseclib/phpseclib/phpseclib/Crypt/AES.php b/vendor/phpseclib/phpseclib/phpseclib/Crypt/AES.php
    new file mode 100755
    index 0000000..cf8c050
    --- /dev/null
    +++ b/vendor/phpseclib/phpseclib/phpseclib/Crypt/AES.php
    @@ -0,0 +1,185 @@
    +
    + * setKey('abcdefghijklmnop');
    + *
    + *    $size = 10 * 1024;
    + *    $plaintext = '';
    + *    for ($i = 0; $i < $size; $i++) {
    + *        $plaintext.= 'a';
    + *    }
    + *
    + *    echo $aes->decrypt($aes->encrypt($plaintext));
    + * ?>
    + * 
    + *
    + * LICENSE: Permission is hereby granted, free of charge, to any person obtaining a copy
    + * of this software and associated documentation files (the "Software"), to deal
    + * in the Software without restriction, including without limitation the rights
    + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    + * copies of the Software, and to permit persons to whom the Software is
    + * furnished to do so, subject to the following conditions:
    + *
    + * The above copyright notice and this permission notice shall be included in
    + * all copies or substantial portions of the Software.
    + *
    + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
    + * THE SOFTWARE.
    + *
    + * @category  Crypt
    + * @package   Crypt_AES
    + * @author    Jim Wigginton 
    + * @copyright MMVIII Jim Wigginton
    + * @license   http://www.opensource.org/licenses/mit-license.html  MIT License
    + * @link      http://phpseclib.sourceforge.net
    + */
    +
    +/**
    + * Include Crypt_Rijndael
    + */
    +if (!class_exists('Crypt_Rijndael')) {
    +    include_once 'Rijndael.php';
    +}
    +
    +/**#@+
    + * @access public
    + * @see Crypt_AES::encrypt()
    + * @see Crypt_AES::decrypt()
    + */
    +/**
    + * Encrypt / decrypt using the Counter mode.
    + *
    + * Set to -1 since that's what Crypt/Random.php uses to index the CTR mode.
    + *
    + * @link http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation#Counter_.28CTR.29
    + */
    +define('CRYPT_AES_MODE_CTR', CRYPT_MODE_CTR);
    +/**
    + * Encrypt / decrypt using the Electronic Code Book mode.
    + *
    + * @link http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation#Electronic_codebook_.28ECB.29
    + */
    +define('CRYPT_AES_MODE_ECB', CRYPT_MODE_ECB);
    +/**
    + * Encrypt / decrypt using the Code Book Chaining mode.
    + *
    + * @link http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation#Cipher-block_chaining_.28CBC.29
    + */
    +define('CRYPT_AES_MODE_CBC', CRYPT_MODE_CBC);
    +/**
    + * Encrypt / decrypt using the Cipher Feedback mode.
    + *
    + * @link http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation#Cipher_feedback_.28CFB.29
    + */
    +define('CRYPT_AES_MODE_CFB', CRYPT_MODE_CFB);
    +/**
    + * Encrypt / decrypt using the Cipher Feedback mode.
    + *
    + * @link http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation#Output_feedback_.28OFB.29
    + */
    +define('CRYPT_AES_MODE_OFB', CRYPT_MODE_OFB);
    +/**#@-*/
    +
    +/**#@+
    + * @access private
    + * @see Crypt_AES::Crypt_AES()
    + */
    +/**
    + * Toggles the internal implementation
    + */
    +define('CRYPT_AES_MODE_INTERNAL', CRYPT_MODE_INTERNAL);
    +/**
    + * Toggles the mcrypt implementation
    + */
    +define('CRYPT_AES_MODE_MCRYPT', CRYPT_MODE_MCRYPT);
    +/**#@-*/
    +
    +/**
    + * Pure-PHP implementation of AES.
    + *
    + * @package Crypt_AES
    + * @author  Jim Wigginton 
    + * @version 0.1.0
    + * @access  public
    + */
    +class Crypt_AES extends Crypt_Rijndael
    +{
    +    /**
    +     * The namespace used by the cipher for its constants.
    +     *
    +     * @see Crypt_Base::const_namespace
    +     * @var String
    +     * @access private
    +     */
    +    var $const_namespace = 'AES';
    +
    +    /**
    +     * Default Constructor.
    +     *
    +     * Determines whether or not the mcrypt extension should be used.
    +     *
    +     * $mode could be:
    +     *
    +     * - CRYPT_AES_MODE_ECB
    +     *
    +     * - CRYPT_AES_MODE_CBC
    +     *
    +     * - CRYPT_AES_MODE_CTR
    +     *
    +     * - CRYPT_AES_MODE_CFB
    +     *
    +     * - CRYPT_AES_MODE_OFB
    +     *
    +     * If not explictly set, CRYPT_AES_MODE_CBC will be used.
    +     *
    +     * @see Crypt_Rijndael::Crypt_Rijndael()
    +     * @see Crypt_Base::Crypt_Base()
    +     * @param optional Integer $mode
    +     * @access public
    +     */
    +    function Crypt_AES($mode = CRYPT_AES_MODE_CBC)
    +    {
    +        parent::Crypt_Rijndael($mode);
    +    }
    +
    +    /**
    +     * Dummy function
    +     *
    +     * Since Crypt_AES extends Crypt_Rijndael, this function is, technically, available, but it doesn't do anything.
    +     *
    +     * @see Crypt_Rijndael::setBlockLength()
    +     * @access public
    +     * @param Integer $length
    +     */
    +    function setBlockLength($length)
    +    {
    +        return;
    +    }
    +}
    diff --git a/vendor/phpseclib/phpseclib/phpseclib/Crypt/Base.php b/vendor/phpseclib/phpseclib/phpseclib/Crypt/Base.php
    new file mode 100755
    index 0000000..f08529b
    --- /dev/null
    +++ b/vendor/phpseclib/phpseclib/phpseclib/Crypt/Base.php
    @@ -0,0 +1,1986 @@
    +
    + * @author    Hans-Juergen Petrich 
    + * @copyright MMVII Jim Wigginton
    + * @license   http://www.opensource.org/licenses/mit-license.html  MIT License
    + * @version   1.0.1
    + * @link      http://phpseclib.sourceforge.net
    + */
    +
    +/**#@+
    + * @access public
    + * @see Crypt_Base::encrypt()
    + * @see Crypt_Base::decrypt()
    + */
    +/**
    + * Encrypt / decrypt using the Counter mode.
    + *
    + * Set to -1 since that's what Crypt/Random.php uses to index the CTR mode.
    + *
    + * @link http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation#Counter_.28CTR.29
    + */
    +define('CRYPT_MODE_CTR', -1);
    +/**
    + * Encrypt / decrypt using the Electronic Code Book mode.
    + *
    + * @link http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation#Electronic_codebook_.28ECB.29
    + */
    +define('CRYPT_MODE_ECB', 1);
    +/**
    + * Encrypt / decrypt using the Code Book Chaining mode.
    + *
    + * @link http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation#Cipher-block_chaining_.28CBC.29
    + */
    +define('CRYPT_MODE_CBC', 2);
    +/**
    + * Encrypt / decrypt using the Cipher Feedback mode.
    + *
    + * @link http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation#Cipher_feedback_.28CFB.29
    + */
    +define('CRYPT_MODE_CFB', 3);
    +/**
    + * Encrypt / decrypt using the Output Feedback mode.
    + *
    + * @link http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation#Output_feedback_.28OFB.29
    + */
    +define('CRYPT_MODE_OFB', 4);
    +/**
    + * Encrypt / decrypt using streaming mode.
    + *
    + */
    +define('CRYPT_MODE_STREAM', 5);
    +/**#@-*/
    +
    +/**#@+
    + * @access private
    + * @see Crypt_Base::Crypt_Base()
    + */
    +/**
    + * Base value for the internal implementation $engine switch
    + */
    +define('CRYPT_MODE_INTERNAL', 1);
    +/**
    + * Base value for the mcrypt implementation $engine switch
    + */
    +define('CRYPT_MODE_MCRYPT', 2);
    +/**#@-*/
    +
    +/**
    + * Base Class for all Crypt_* cipher classes
    + *
    + * @package Crypt_Base
    + * @author  Jim Wigginton 
    + * @author  Hans-Juergen Petrich 
    + * @version 1.0.0
    + * @access  public
    + */
    +class Crypt_Base
    +{
    +    /**
    +     * The Encryption Mode
    +     *
    +     * @see Crypt_Base::Crypt_Base()
    +     * @var Integer
    +     * @access private
    +     */
    +    var $mode;
    +
    +    /**
    +     * The Block Length of the block cipher
    +     *
    +     * @var Integer
    +     * @access private
    +     */
    +    var $block_size = 16;
    +
    +    /**
    +     * The Key
    +     *
    +     * @see Crypt_Base::setKey()
    +     * @var String
    +     * @access private
    +     */
    +    var $key = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0";
    +
    +    /**
    +     * The Initialization Vector
    +     *
    +     * @see Crypt_Base::setIV()
    +     * @var String
    +     * @access private
    +     */
    +    var $iv;
    +
    +    /**
    +     * A "sliding" Initialization Vector
    +     *
    +     * @see Crypt_Base::enableContinuousBuffer()
    +     * @see Crypt_Base::_clearBuffers()
    +     * @var String
    +     * @access private
    +     */
    +    var $encryptIV;
    +
    +    /**
    +     * A "sliding" Initialization Vector
    +     *
    +     * @see Crypt_Base::enableContinuousBuffer()
    +     * @see Crypt_Base::_clearBuffers()
    +     * @var String
    +     * @access private
    +     */
    +    var $decryptIV;
    +
    +    /**
    +     * Continuous Buffer status
    +     *
    +     * @see Crypt_Base::enableContinuousBuffer()
    +     * @var Boolean
    +     * @access private
    +     */
    +    var $continuousBuffer = false;
    +
    +    /**
    +     * Encryption buffer for CTR, OFB and CFB modes
    +     *
    +     * @see Crypt_Base::encrypt()
    +     * @see Crypt_Base::_clearBuffers()
    +     * @var Array
    +     * @access private
    +     */
    +    var $enbuffer;
    +
    +    /**
    +     * Decryption buffer for CTR, OFB and CFB modes
    +     *
    +     * @see Crypt_Base::decrypt()
    +     * @see Crypt_Base::_clearBuffers()
    +     * @var Array
    +     * @access private
    +     */
    +    var $debuffer;
    +
    +    /**
    +     * mcrypt resource for encryption
    +     *
    +     * The mcrypt resource can be recreated every time something needs to be created or it can be created just once.
    +     * Since mcrypt operates in continuous mode, by default, it'll need to be recreated when in non-continuous mode.
    +     *
    +     * @see Crypt_Base::encrypt()
    +     * @var Resource
    +     * @access private
    +     */
    +    var $enmcrypt;
    +
    +    /**
    +     * mcrypt resource for decryption
    +     *
    +     * The mcrypt resource can be recreated every time something needs to be created or it can be created just once.
    +     * Since mcrypt operates in continuous mode, by default, it'll need to be recreated when in non-continuous mode.
    +     *
    +     * @see Crypt_Base::decrypt()
    +     * @var Resource
    +     * @access private
    +     */
    +    var $demcrypt;
    +
    +    /**
    +     * Does the enmcrypt resource need to be (re)initialized?
    +     *
    +     * @see Crypt_Twofish::setKey()
    +     * @see Crypt_Twofish::setIV()
    +     * @var Boolean
    +     * @access private
    +     */
    +    var $enchanged = true;
    +
    +    /**
    +     * Does the demcrypt resource need to be (re)initialized?
    +     *
    +     * @see Crypt_Twofish::setKey()
    +     * @see Crypt_Twofish::setIV()
    +     * @var Boolean
    +     * @access private
    +     */
    +    var $dechanged = true;
    +
    +    /**
    +     * mcrypt resource for CFB mode
    +     *
    +     * mcrypt's CFB mode, in (and only in) buffered context,
    +     * is broken, so phpseclib implements the CFB mode by it self,
    +     * even when the mcrypt php extension is available.
    +     *
    +     * In order to do the CFB-mode work (fast) phpseclib
    +     * use a separate ECB-mode mcrypt resource.
    +     *
    +     * @link http://phpseclib.sourceforge.net/cfb-demo.phps
    +     * @see Crypt_Base::encrypt()
    +     * @see Crypt_Base::decrypt()
    +     * @see Crypt_Base::_setupMcrypt()
    +     * @var Resource
    +     * @access private
    +     */
    +    var $ecb;
    +
    +    /**
    +     * Optimizing value while CFB-encrypting
    +     *
    +     * Only relevant if $continuousBuffer enabled
    +     * and $engine == CRYPT_MODE_MCRYPT
    +     *
    +     * It's faster to re-init $enmcrypt if
    +     * $buffer bytes > $cfb_init_len than
    +     * using the $ecb resource furthermore.
    +     *
    +     * This value depends of the choosen cipher
    +     * and the time it would be needed for it's
    +     * initialization [by mcrypt_generic_init()]
    +     * which, typically, depends on the complexity
    +     * on its internaly Key-expanding algorithm.
    +     *
    +     * @see Crypt_Base::encrypt()
    +     * @var Integer
    +     * @access private
    +     */
    +    var $cfb_init_len = 600;
    +
    +    /**
    +     * Does internal cipher state need to be (re)initialized?
    +     *
    +     * @see setKey()
    +     * @see setIV()
    +     * @see disableContinuousBuffer()
    +     * @var Boolean
    +     * @access private
    +     */
    +    var $changed = true;
    +
    +    /**
    +     * Padding status
    +     *
    +     * @see Crypt_Base::enablePadding()
    +     * @var Boolean
    +     * @access private
    +     */
    +    var $padding = true;
    +
    +    /**
    +     * Is the mode one that is paddable?
    +     *
    +     * @see Crypt_Base::Crypt_Base()
    +     * @var Boolean
    +     * @access private
    +     */
    +    var $paddable = false;
    +
    +    /**
    +     * Holds which crypt engine internaly should be use,
    +     * which will be determined automatically on __construct()
    +     *
    +     * Currently available $engines are:
    +     * - CRYPT_MODE_MCRYPT   (fast, php-extension: mcrypt, extension_loaded('mcrypt') required)
    +     * - CRYPT_MODE_INTERNAL (slower, pure php-engine, no php-extension required)
    +     *
    +     * In the pipeline... maybe. But currently not available:
    +     * - CRYPT_MODE_OPENSSL  (very fast, php-extension: openssl, extension_loaded('openssl') required)
    +     *
    +     * If possible, CRYPT_MODE_MCRYPT will be used for each cipher.
    +     * Otherwise CRYPT_MODE_INTERNAL
    +     *
    +     * @see Crypt_Base::encrypt()
    +     * @see Crypt_Base::decrypt()
    +     * @var Integer
    +     * @access private
    +     */
    +    var $engine;
    +
    +    /**
    +     * The mcrypt specific name of the cipher
    +     *
    +     * Only used if $engine == CRYPT_MODE_MCRYPT
    +     *
    +     * @link http://www.php.net/mcrypt_module_open
    +     * @link http://www.php.net/mcrypt_list_algorithms
    +     * @see Crypt_Base::_setupMcrypt()
    +     * @var String
    +     * @access private
    +     */
    +    var $cipher_name_mcrypt;
    +
    +    /**
    +     * The default password key_size used by setPassword()
    +     *
    +     * @see Crypt_Base::setPassword()
    +     * @var Integer
    +     * @access private
    +     */
    +    var $password_key_size = 32;
    +
    +    /**
    +     * The default salt used by setPassword()
    +     *
    +     * @see Crypt_Base::setPassword()
    +     * @var String
    +     * @access private
    +     */
    +    var $password_default_salt = 'phpseclib/salt';
    +
    +    /**
    +     * The namespace used by the cipher for its constants.
    +     *
    +     * ie: AES.php is using CRYPT_AES_MODE_* for its constants
    +     *     so $const_namespace is AES
    +     *
    +     *     DES.php is using CRYPT_DES_MODE_* for its constants
    +     *     so $const_namespace is DES... and so on
    +     *
    +     * All CRYPT_<$const_namespace>_MODE_* are aliases of
    +     * the generic CRYPT_MODE_* constants, so both could be used
    +     * for each cipher.
    +     *
    +     * Example:
    +     * $aes = new Crypt_AES(CRYPT_AES_MODE_CFB); // $aes will operate in cfb mode
    +     * $aes = new Crypt_AES(CRYPT_MODE_CFB);     // identical
    +     *
    +     * @see Crypt_Base::Crypt_Base()
    +     * @var String
    +     * @access private
    +     */
    +    var $const_namespace;
    +
    +    /**
    +     * The name of the performance-optimized callback function
    +     *
    +     * Used by encrypt() / decrypt()
    +     * only if $engine == CRYPT_MODE_INTERNAL
    +     *
    +     * @see Crypt_Base::encrypt()
    +     * @see Crypt_Base::decrypt()
    +     * @see Crypt_Base::_setupInlineCrypt()
    +     * @see Crypt_Base::$use_inline_crypt
    +     * @var Callback
    +     * @access private
    +     */
    +    var $inline_crypt;
    +
    +    /**
    +     * Holds whether performance-optimized $inline_crypt() can/should be used.
    +     *
    +     * @see Crypt_Base::encrypt()
    +     * @see Crypt_Base::decrypt()
    +     * @see Crypt_Base::inline_crypt
    +     * @var mixed
    +     * @access private
    +     */
    +    var $use_inline_crypt;
    +
    +    /**
    +     * Default Constructor.
    +     *
    +     * Determines whether or not the mcrypt extension should be used.
    +     *
    +     * $mode could be:
    +     *
    +     * - CRYPT_MODE_ECB
    +     *
    +     * - CRYPT_MODE_CBC
    +     *
    +     * - CRYPT_MODE_CTR
    +     *
    +     * - CRYPT_MODE_CFB
    +     *
    +     * - CRYPT_MODE_OFB
    +     *
    +     * (or the alias constants of the choosen cipher, for example for AES: CRYPT_AES_MODE_ECB or CRYPT_AES_MODE_CBC ...)
    +     *
    +     * If not explictly set, CRYPT_MODE_CBC will be used.
    +     *
    +     * @param optional Integer $mode
    +     * @access public
    +     */
    +    function Crypt_Base($mode = CRYPT_MODE_CBC)
    +    {
    +        $const_crypt_mode = 'CRYPT_' . $this->const_namespace . '_MODE';
    +
    +        // Determining the availibility of mcrypt support for the cipher
    +        if (!defined($const_crypt_mode)) {
    +            switch (true) {
    +                case extension_loaded('mcrypt') && in_array($this->cipher_name_mcrypt, mcrypt_list_algorithms()):
    +                    define($const_crypt_mode, CRYPT_MODE_MCRYPT);
    +                    break;
    +                default:
    +                    define($const_crypt_mode, CRYPT_MODE_INTERNAL);
    +            }
    +        }
    +
    +        // Determining which internal $engine should be used.
    +        // The fastes possible first.
    +        switch (true) {
    +            case empty($this->cipher_name_mcrypt): // The cipher module has no mcrypt-engine support at all so we force CRYPT_MODE_INTERNAL
    +                $this->engine = CRYPT_MODE_INTERNAL;
    +                break;
    +            case constant($const_crypt_mode) == CRYPT_MODE_MCRYPT:
    +                $this->engine = CRYPT_MODE_MCRYPT;
    +                break;
    +            default:
    +                $this->engine = CRYPT_MODE_INTERNAL;
    +        }
    +
    +        // $mode dependent settings
    +        switch ($mode) {
    +            case CRYPT_MODE_ECB:
    +                $this->paddable = true;
    +                $this->mode = $mode;
    +                break;
    +            case CRYPT_MODE_CTR:
    +            case CRYPT_MODE_CFB:
    +            case CRYPT_MODE_OFB:
    +            case CRYPT_MODE_STREAM:
    +                $this->mode = $mode;
    +                break;
    +            case CRYPT_MODE_CBC:
    +            default:
    +                $this->paddable = true;
    +                $this->mode = CRYPT_MODE_CBC;
    +        }
    +
    +        // Determining whether inline crypting can be used by the cipher
    +        if ($this->use_inline_crypt !== false && function_exists('create_function')) {
    +            $this->use_inline_crypt = true;
    +        }
    +    }
    +
    +    /**
    +     * Sets the initialization vector. (optional)
    +     *
    +     * SetIV is not required when CRYPT_MODE_ECB (or ie for AES: CRYPT_AES_MODE_ECB) is being used.  If not explictly set, it'll be assumed
    +     * to be all zero's.
    +     *
    +     * Note: Could, but not must, extend by the child Crypt_* class
    +     *
    +     * @access public
    +     * @param String $iv
    +     */
    +    function setIV($iv)
    +    {
    +        if ($this->mode == CRYPT_MODE_ECB) {
    +            return;
    +        }
    +
    +        $this->iv = $iv;
    +        $this->changed = true;
    +    }
    +
    +    /**
    +     * Sets the key.
    +     *
    +     * The min/max length(s) of the key depends on the cipher which is used.
    +     * If the key not fits the length(s) of the cipher it will paded with null bytes
    +     * up to the closest valid key length.  If the key is more than max length,
    +     * we trim the excess bits.
    +     *
    +     * If the key is not explicitly set, it'll be assumed to be all null bytes.
    +     *
    +     * Note: Could, but not must, extend by the child Crypt_* class
    +     *
    +     * @access public
    +     * @param String $key
    +     */
    +    function setKey($key)
    +    {
    +        $this->key = $key;
    +        $this->changed = true;
    +    }
    +
    +    /**
    +     * Sets the password.
    +     *
    +     * Depending on what $method is set to, setPassword()'s (optional) parameters are as follows:
    +     *     {@link http://en.wikipedia.org/wiki/PBKDF2 pbkdf2}:
    +     *         $hash, $salt, $count, $dkLen
    +     *
    +     *         Where $hash (default = sha1) currently supports the following hashes: see: Crypt/Hash.php
    +     *
    +     * Note: Could, but not must, extend by the child Crypt_* class
    +     *
    +     * @see Crypt/Hash.php
    +     * @param String $password
    +     * @param optional String $method
    +     * @access public
    +     */
    +    function setPassword($password, $method = 'pbkdf2')
    +    {
    +        $key = '';
    +
    +        switch ($method) {
    +            default: // 'pbkdf2'
    +                $func_args = func_get_args();
    +
    +                // Hash function
    +                $hash = isset($func_args[2]) ? $func_args[2] : 'sha1';
    +
    +                // WPA and WPA2 use the SSID as the salt
    +                $salt = isset($func_args[3]) ? $func_args[3] : $this->password_default_salt;
    +
    +                // RFC2898#section-4.2 uses 1,000 iterations by default
    +                // WPA and WPA2 use 4,096.
    +                $count = isset($func_args[4]) ? $func_args[4] : 1000;
    +
    +                // Keylength
    +                $dkLen = isset($func_args[5]) ? $func_args[5] : $this->password_key_size;
    +
    +                // Determining if php[>=5.5.0]'s hash_pbkdf2() function avail- and useable
    +                switch (true) {
    +                    case !function_exists('hash_pbkdf2'):
    +                    case !function_exists('hash_algos'):
    +                    case !in_array($hash, hash_algos()):
    +                        if (!class_exists('Crypt_Hash')) {
    +                            include_once 'Crypt/Hash.php';
    +                        }
    +                        $i = 1;
    +                        while (strlen($key) < $dkLen) {
    +                            $hmac = new Crypt_Hash();
    +                            $hmac->setHash($hash);
    +                            $hmac->setKey($password);
    +                            $f = $u = $hmac->hash($salt . pack('N', $i++));
    +                            for ($j = 2; $j <= $count; ++$j) {
    +                                $u = $hmac->hash($u);
    +                                $f^= $u;
    +                            }
    +                            $key.= $f;
    +                        }
    +                        $key = substr($key, 0, $dkLen);
    +                        break;
    +                    default:
    +                        $key = hash_pbkdf2($hash, $password, $salt, $count, $dkLen, true);
    +                }
    +        }
    +
    +        $this->setKey($key);
    +    }
    +
    +    /**
    +     * Encrypts a message.
    +     *
    +     * $plaintext will be padded with additional bytes such that it's length is a multiple of the block size. Other cipher
    +     * implementations may or may not pad in the same manner.  Other common approaches to padding and the reasons why it's
    +     * necessary are discussed in the following
    +     * URL:
    +     *
    +     * {@link http://www.di-mgt.com.au/cryptopad.html http://www.di-mgt.com.au/cryptopad.html}
    +     *
    +     * An alternative to padding is to, separately, send the length of the file.  This is what SSH, in fact, does.
    +     * strlen($plaintext) will still need to be a multiple of the block size, however, arbitrary values can be added to make it that
    +     * length.
    +     *
    +     * Note: Could, but not must, extend by the child Crypt_* class
    +     *
    +     * @see Crypt_Base::decrypt()
    +     * @access public
    +     * @param String $plaintext
    +     * @return String $cipertext
    +     */
    +    function encrypt($plaintext)
    +    {
    +        if ($this->engine == CRYPT_MODE_MCRYPT) {
    +            if ($this->changed) {
    +                $this->_setupMcrypt();
    +                $this->changed = false;
    +            }
    +            if ($this->enchanged) {
    +                mcrypt_generic_init($this->enmcrypt, $this->key, $this->encryptIV);
    +                $this->enchanged = false;
    +            }
    +
    +            // re: {@link http://phpseclib.sourceforge.net/cfb-demo.phps}
    +            // using mcrypt's default handing of CFB the above would output two different things.  using phpseclib's
    +            // rewritten CFB implementation the above outputs the same thing twice.
    +            if ($this->mode == CRYPT_MODE_CFB && $this->continuousBuffer) {
    +                $block_size = $this->block_size;
    +                $iv = &$this->encryptIV;
    +                $pos = &$this->enbuffer['pos'];
    +                $len = strlen($plaintext);
    +                $ciphertext = '';
    +                $i = 0;
    +                if ($pos) {
    +                    $orig_pos = $pos;
    +                    $max = $block_size - $pos;
    +                    if ($len >= $max) {
    +                        $i = $max;
    +                        $len-= $max;
    +                        $pos = 0;
    +                    } else {
    +                        $i = $len;
    +                        $pos+= $len;
    +                        $len = 0;
    +                    }
    +                    $ciphertext = substr($iv, $orig_pos) ^ $plaintext;
    +                    $iv = substr_replace($iv, $ciphertext, $orig_pos, $i);
    +                    $this->enbuffer['enmcrypt_init'] = true;
    +                }
    +                if ($len >= $block_size) {
    +                    if ($this->enbuffer['enmcrypt_init'] === false || $len > $this->cfb_init_len) {
    +                        if ($this->enbuffer['enmcrypt_init'] === true) {
    +                            mcrypt_generic_init($this->enmcrypt, $this->key, $iv);
    +                            $this->enbuffer['enmcrypt_init'] = false;
    +                        }
    +                        $ciphertext.= mcrypt_generic($this->enmcrypt, substr($plaintext, $i, $len - $len % $block_size));
    +                        $iv = substr($ciphertext, -$block_size);
    +                        $len%= $block_size;
    +                    } else {
    +                        while ($len >= $block_size) {
    +                            $iv = mcrypt_generic($this->ecb, $iv) ^ substr($plaintext, $i, $block_size);
    +                            $ciphertext.= $iv;
    +                            $len-= $block_size;
    +                            $i+= $block_size;
    +                        }
    +                    }
    +                }
    +
    +                if ($len) {
    +                    $iv = mcrypt_generic($this->ecb, $iv);
    +                    $block = $iv ^ substr($plaintext, -$len);
    +                    $iv = substr_replace($iv, $block, 0, $len);
    +                    $ciphertext.= $block;
    +                    $pos = $len;
    +                }
    +
    +                return $ciphertext;
    +            }
    +
    +            if ($this->paddable) {
    +                $plaintext = $this->_pad($plaintext);
    +            }
    +
    +            $ciphertext = mcrypt_generic($this->enmcrypt, $plaintext);
    +
    +            if (!$this->continuousBuffer) {
    +                mcrypt_generic_init($this->enmcrypt, $this->key, $this->encryptIV);
    +            }
    +
    +            return $ciphertext;
    +        }
    +
    +        if ($this->changed) {
    +            $this->_setup();
    +            $this->changed = false;
    +        }
    +        if ($this->use_inline_crypt) {
    +            $inline = $this->inline_crypt;
    +            return $inline('encrypt', $this, $plaintext);
    +        }
    +        if ($this->paddable) {
    +            $plaintext = $this->_pad($plaintext);
    +        }
    +
    +        $buffer = &$this->enbuffer;
    +        $block_size = $this->block_size;
    +        $ciphertext = '';
    +        switch ($this->mode) {
    +            case CRYPT_MODE_ECB:
    +                for ($i = 0; $i < strlen($plaintext); $i+=$block_size) {
    +                    $ciphertext.= $this->_encryptBlock(substr($plaintext, $i, $block_size));
    +                }
    +                break;
    +            case CRYPT_MODE_CBC:
    +                $xor = $this->encryptIV;
    +                for ($i = 0; $i < strlen($plaintext); $i+=$block_size) {
    +                    $block = substr($plaintext, $i, $block_size);
    +                    $block = $this->_encryptBlock($block ^ $xor);
    +                    $xor = $block;
    +                    $ciphertext.= $block;
    +                }
    +                if ($this->continuousBuffer) {
    +                    $this->encryptIV = $xor;
    +                }
    +                break;
    +            case CRYPT_MODE_CTR:
    +                $xor = $this->encryptIV;
    +                if (strlen($buffer['encrypted'])) {
    +                    for ($i = 0; $i < strlen($plaintext); $i+=$block_size) {
    +                        $block = substr($plaintext, $i, $block_size);
    +                        if (strlen($block) > strlen($buffer['encrypted'])) {
    +                            $buffer['encrypted'].= $this->_encryptBlock($this->_generateXor($xor, $block_size));
    +                        }
    +                        $key = $this->_stringShift($buffer['encrypted'], $block_size);
    +                        $ciphertext.= $block ^ $key;
    +                    }
    +                } else {
    +                    for ($i = 0; $i < strlen($plaintext); $i+=$block_size) {
    +                        $block = substr($plaintext, $i, $block_size);
    +                        $key = $this->_encryptBlock($this->_generateXor($xor, $block_size));
    +                        $ciphertext.= $block ^ $key;
    +                    }
    +                }
    +                if ($this->continuousBuffer) {
    +                    $this->encryptIV = $xor;
    +                    if ($start = strlen($plaintext) % $block_size) {
    +                        $buffer['encrypted'] = substr($key, $start) . $buffer['encrypted'];
    +                    }
    +                }
    +                break;
    +            case CRYPT_MODE_CFB:
    +                // cfb loosely routines inspired by openssl's:
    +                // {@link http://cvs.openssl.org/fileview?f=openssl/crypto/modes/cfb128.c&v=1.3.2.2.2.1}
    +                if ($this->continuousBuffer) {
    +                    $iv = &$this->encryptIV;
    +                    $pos = &$buffer['pos'];
    +                } else {
    +                    $iv = $this->encryptIV;
    +                    $pos = 0;
    +                }
    +                $len = strlen($plaintext);
    +                $i = 0;
    +                if ($pos) {
    +                    $orig_pos = $pos;
    +                    $max = $block_size - $pos;
    +                    if ($len >= $max) {
    +                        $i = $max;
    +                        $len-= $max;
    +                        $pos = 0;
    +                    } else {
    +                        $i = $len;
    +                        $pos+= $len;
    +                        $len = 0;
    +                    }
    +                    // ie. $i = min($max, $len), $len-= $i, $pos+= $i, $pos%= $blocksize
    +                    $ciphertext = substr($iv, $orig_pos) ^ $plaintext;
    +                    $iv = substr_replace($iv, $ciphertext, $orig_pos, $i);
    +                }
    +                while ($len >= $block_size) {
    +                    $iv = $this->_encryptBlock($iv) ^ substr($plaintext, $i, $block_size);
    +                    $ciphertext.= $iv;
    +                    $len-= $block_size;
    +                    $i+= $block_size;
    +                }
    +                if ($len) {
    +                    $iv = $this->_encryptBlock($iv);
    +                    $block = $iv ^ substr($plaintext, $i);
    +                    $iv = substr_replace($iv, $block, 0, $len);
    +                    $ciphertext.= $block;
    +                    $pos = $len;
    +                }
    +                break;
    +            case CRYPT_MODE_OFB:
    +                $xor = $this->encryptIV;
    +                if (strlen($buffer['xor'])) {
    +                    for ($i = 0; $i < strlen($plaintext); $i+=$block_size) {
    +                        $block = substr($plaintext, $i, $block_size);
    +                        if (strlen($block) > strlen($buffer['xor'])) {
    +                            $xor = $this->_encryptBlock($xor);
    +                            $buffer['xor'].= $xor;
    +                        }
    +                        $key = $this->_stringShift($buffer['xor'], $block_size);
    +                        $ciphertext.= $block ^ $key;
    +                    }
    +                } else {
    +                    for ($i = 0; $i < strlen($plaintext); $i+=$block_size) {
    +                        $xor = $this->_encryptBlock($xor);
    +                        $ciphertext.= substr($plaintext, $i, $block_size) ^ $xor;
    +                    }
    +                    $key = $xor;
    +                }
    +                if ($this->continuousBuffer) {
    +                    $this->encryptIV = $xor;
    +                    if ($start = strlen($plaintext) % $block_size) {
    +                         $buffer['xor'] = substr($key, $start) . $buffer['xor'];
    +                    }
    +                }
    +                break;
    +            case CRYPT_MODE_STREAM:
    +                $ciphertext = $this->_encryptBlock($plaintext);
    +                break;
    +        }
    +
    +        return $ciphertext;
    +    }
    +
    +    /**
    +     * Decrypts a message.
    +     *
    +     * If strlen($ciphertext) is not a multiple of the block size, null bytes will be added to the end of the string until
    +     * it is.
    +     *
    +     * Note: Could, but not must, extend by the child Crypt_* class
    +     *
    +     * @see Crypt_Base::encrypt()
    +     * @access public
    +     * @param String $ciphertext
    +     * @return String $plaintext
    +     */
    +    function decrypt($ciphertext)
    +    {
    +        if ($this->engine == CRYPT_MODE_MCRYPT) {
    +            $block_size = $this->block_size;
    +            if ($this->changed) {
    +                $this->_setupMcrypt();
    +                $this->changed = false;
    +            }
    +            if ($this->dechanged) {
    +                mcrypt_generic_init($this->demcrypt, $this->key, $this->decryptIV);
    +                $this->dechanged = false;
    +            }
    +
    +            if ($this->mode == CRYPT_MODE_CFB && $this->continuousBuffer) {
    +                $iv = &$this->decryptIV;
    +                $pos = &$this->debuffer['pos'];
    +                $len = strlen($ciphertext);
    +                $plaintext = '';
    +                $i = 0;
    +                if ($pos) {
    +                    $orig_pos = $pos;
    +                    $max = $block_size - $pos;
    +                    if ($len >= $max) {
    +                        $i = $max;
    +                        $len-= $max;
    +                        $pos = 0;
    +                    } else {
    +                        $i = $len;
    +                        $pos+= $len;
    +                        $len = 0;
    +                    }
    +                    // ie. $i = min($max, $len), $len-= $i, $pos+= $i, $pos%= $blocksize
    +                    $plaintext = substr($iv, $orig_pos) ^ $ciphertext;
    +                    $iv = substr_replace($iv, substr($ciphertext, 0, $i), $orig_pos, $i);
    +                }
    +                if ($len >= $block_size) {
    +                    $cb = substr($ciphertext, $i, $len - $len % $block_size);
    +                    $plaintext.= mcrypt_generic($this->ecb, $iv . $cb) ^ $cb;
    +                    $iv = substr($cb, -$block_size);
    +                    $len%= $block_size;
    +                }
    +                if ($len) {
    +                    $iv = mcrypt_generic($this->ecb, $iv);
    +                    $plaintext.= $iv ^ substr($ciphertext, -$len);
    +                    $iv = substr_replace($iv, substr($ciphertext, -$len), 0, $len);
    +                    $pos = $len;
    +                }
    +
    +                return $plaintext;
    +            }
    +
    +            if ($this->paddable) {
    +                // we pad with chr(0) since that's what mcrypt_generic does.  to quote from {@link http://www.php.net/function.mcrypt-generic}:
    +                // "The data is padded with "\0" to make sure the length of the data is n * blocksize."
    +                $ciphertext = str_pad($ciphertext, strlen($ciphertext) + ($block_size - strlen($ciphertext) % $block_size) % $block_size, chr(0));
    +            }
    +
    +            $plaintext = mdecrypt_generic($this->demcrypt, $ciphertext);
    +
    +            if (!$this->continuousBuffer) {
    +                mcrypt_generic_init($this->demcrypt, $this->key, $this->decryptIV);
    +            }
    +
    +            return $this->paddable ? $this->_unpad($plaintext) : $plaintext;
    +        }
    +
    +        if ($this->changed) {
    +            $this->_setup();
    +            $this->changed = false;
    +        }
    +        if ($this->use_inline_crypt) {
    +            $inline = $this->inline_crypt;
    +            return $inline('decrypt', $this, $ciphertext);
    +        }
    +
    +        $block_size = $this->block_size;
    +        if ($this->paddable) {
    +            // we pad with chr(0) since that's what mcrypt_generic does [...]
    +            $ciphertext = str_pad($ciphertext, strlen($ciphertext) + ($block_size - strlen($ciphertext) % $block_size) % $block_size, chr(0));
    +        }
    +
    +        $buffer = &$this->debuffer;
    +        $plaintext = '';
    +        switch ($this->mode) {
    +            case CRYPT_MODE_ECB:
    +                for ($i = 0; $i < strlen($ciphertext); $i+=$block_size) {
    +                    $plaintext.= $this->_decryptBlock(substr($ciphertext, $i, $block_size));
    +                }
    +                break;
    +            case CRYPT_MODE_CBC:
    +                $xor = $this->decryptIV;
    +                for ($i = 0; $i < strlen($ciphertext); $i+=$block_size) {
    +                    $block = substr($ciphertext, $i, $block_size);
    +                    $plaintext.= $this->_decryptBlock($block) ^ $xor;
    +                    $xor = $block;
    +                }
    +                if ($this->continuousBuffer) {
    +                    $this->decryptIV = $xor;
    +                }
    +                break;
    +            case CRYPT_MODE_CTR:
    +                $xor = $this->decryptIV;
    +                if (strlen($buffer['ciphertext'])) {
    +                    for ($i = 0; $i < strlen($ciphertext); $i+=$block_size) {
    +                        $block = substr($ciphertext, $i, $block_size);
    +                        if (strlen($block) > strlen($buffer['ciphertext'])) {
    +                            $buffer['ciphertext'].= $this->_encryptBlock($this->_generateXor($xor, $block_size));
    +                        }
    +                        $key = $this->_stringShift($buffer['ciphertext'], $block_size);
    +                        $plaintext.= $block ^ $key;
    +                    }
    +                } else {
    +                    for ($i = 0; $i < strlen($ciphertext); $i+=$block_size) {
    +                        $block = substr($ciphertext, $i, $block_size);
    +                        $key = $this->_encryptBlock($this->_generateXor($xor, $block_size));
    +                        $plaintext.= $block ^ $key;
    +                    }
    +                }
    +                if ($this->continuousBuffer) {
    +                    $this->decryptIV = $xor;
    +                    if ($start = strlen($ciphertext) % $block_size) {
    +                        $buffer['ciphertext'] = substr($key, $start) . $buffer['ciphertext'];
    +                    }
    +                }
    +                break;
    +            case CRYPT_MODE_CFB:
    +                if ($this->continuousBuffer) {
    +                    $iv = &$this->decryptIV;
    +                    $pos = &$buffer['pos'];
    +                } else {
    +                    $iv = $this->decryptIV;
    +                    $pos = 0;
    +                }
    +                $len = strlen($ciphertext);
    +                $i = 0;
    +                if ($pos) {
    +                    $orig_pos = $pos;
    +                    $max = $block_size - $pos;
    +                    if ($len >= $max) {
    +                        $i = $max;
    +                        $len-= $max;
    +                        $pos = 0;
    +                    } else {
    +                        $i = $len;
    +                        $pos+= $len;
    +                        $len = 0;
    +                    }
    +                    // ie. $i = min($max, $len), $len-= $i, $pos+= $i, $pos%= $blocksize
    +                    $plaintext = substr($iv, $orig_pos) ^ $ciphertext;
    +                    $iv = substr_replace($iv, substr($ciphertext, 0, $i), $orig_pos, $i);
    +                }
    +                while ($len >= $block_size) {
    +                    $iv = $this->_encryptBlock($iv);
    +                    $cb = substr($ciphertext, $i, $block_size);
    +                    $plaintext.= $iv ^ $cb;
    +                    $iv = $cb;
    +                    $len-= $block_size;
    +                    $i+= $block_size;
    +                }
    +                if ($len) {
    +                    $iv = $this->_encryptBlock($iv);
    +                    $plaintext.= $iv ^ substr($ciphertext, $i);
    +                    $iv = substr_replace($iv, substr($ciphertext, $i), 0, $len);
    +                    $pos = $len;
    +                }
    +                break;
    +            case CRYPT_MODE_OFB:
    +                $xor = $this->decryptIV;
    +                if (strlen($buffer['xor'])) {
    +                    for ($i = 0; $i < strlen($ciphertext); $i+=$block_size) {
    +                        $block = substr($ciphertext, $i, $block_size);
    +                        if (strlen($block) > strlen($buffer['xor'])) {
    +                            $xor = $this->_encryptBlock($xor);
    +                            $buffer['xor'].= $xor;
    +                        }
    +                        $key = $this->_stringShift($buffer['xor'], $block_size);
    +                        $plaintext.= $block ^ $key;
    +                    }
    +                } else {
    +                    for ($i = 0; $i < strlen($ciphertext); $i+=$block_size) {
    +                        $xor = $this->_encryptBlock($xor);
    +                        $plaintext.= substr($ciphertext, $i, $block_size) ^ $xor;
    +                    }
    +                    $key = $xor;
    +                }
    +                if ($this->continuousBuffer) {
    +                    $this->decryptIV = $xor;
    +                    if ($start = strlen($ciphertext) % $block_size) {
    +                         $buffer['xor'] = substr($key, $start) . $buffer['xor'];
    +                    }
    +                }
    +                break;
    +            case CRYPT_MODE_STREAM:
    +                $plaintext = $this->_decryptBlock($ciphertext);
    +                break;
    +        }
    +        return $this->paddable ? $this->_unpad($plaintext) : $plaintext;
    +    }
    +
    +    /**
    +     * Pad "packets".
    +     *
    +     * Block ciphers working by encrypting between their specified [$this->]block_size at a time
    +     * If you ever need to encrypt or decrypt something that isn't of the proper length, it becomes necessary to
    +     * pad the input so that it is of the proper length.
    +     *
    +     * Padding is enabled by default.  Sometimes, however, it is undesirable to pad strings.  Such is the case in SSH,
    +     * where "packets" are padded with random bytes before being encrypted.  Unpad these packets and you risk stripping
    +     * away characters that shouldn't be stripped away. (SSH knows how many bytes are added because the length is
    +     * transmitted separately)
    +     *
    +     * @see Crypt_Base::disablePadding()
    +     * @access public
    +     */
    +    function enablePadding()
    +    {
    +        $this->padding = true;
    +    }
    +
    +    /**
    +     * Do not pad packets.
    +     *
    +     * @see Crypt_Base::enablePadding()
    +     * @access public
    +     */
    +    function disablePadding()
    +    {
    +        $this->padding = false;
    +    }
    +
    +    /**
    +     * Treat consecutive "packets" as if they are a continuous buffer.
    +     *
    +     * Say you have a 32-byte plaintext $plaintext.  Using the default behavior, the two following code snippets
    +     * will yield different outputs:
    +     *
    +     * 
    +     *    echo $rijndael->encrypt(substr($plaintext,  0, 16));
    +     *    echo $rijndael->encrypt(substr($plaintext, 16, 16));
    +     * 
    +     * 
    +     *    echo $rijndael->encrypt($plaintext);
    +     * 
    +     *
    +     * The solution is to enable the continuous buffer.  Although this will resolve the above discrepancy, it creates
    +     * another, as demonstrated with the following:
    +     *
    +     * 
    +     *    $rijndael->encrypt(substr($plaintext, 0, 16));
    +     *    echo $rijndael->decrypt($rijndael->encrypt(substr($plaintext, 16, 16)));
    +     * 
    +     * 
    +     *    echo $rijndael->decrypt($rijndael->encrypt(substr($plaintext, 16, 16)));
    +     * 
    +     *
    +     * With the continuous buffer disabled, these would yield the same output.  With it enabled, they yield different
    +     * outputs.  The reason is due to the fact that the initialization vector's change after every encryption /
    +     * decryption round when the continuous buffer is enabled.  When it's disabled, they remain constant.
    +     *
    +     * Put another way, when the continuous buffer is enabled, the state of the Crypt_*() object changes after each
    +     * encryption / decryption round, whereas otherwise, it'd remain constant.  For this reason, it's recommended that
    +     * continuous buffers not be used.  They do offer better security and are, in fact, sometimes required (SSH uses them),
    +     * however, they are also less intuitive and more likely to cause you problems.
    +     *
    +     * Note: Could, but not must, extend by the child Crypt_* class
    +     *
    +     * @see Crypt_Base::disableContinuousBuffer()
    +     * @access public
    +     */
    +    function enableContinuousBuffer()
    +    {
    +        if ($this->mode == CRYPT_MODE_ECB) {
    +            return;
    +        }
    +
    +        $this->continuousBuffer = true;
    +    }
    +
    +    /**
    +     * Treat consecutive packets as if they are a discontinuous buffer.
    +     *
    +     * The default behavior.
    +     *
    +     * Note: Could, but not must, extend by the child Crypt_* class
    +     *
    +     * @see Crypt_Base::enableContinuousBuffer()
    +     * @access public
    +     */
    +    function disableContinuousBuffer()
    +    {
    +        if ($this->mode == CRYPT_MODE_ECB) {
    +            return;
    +        }
    +        if (!$this->continuousBuffer) {
    +            return;
    +        }
    +
    +        $this->continuousBuffer = false;
    +        $this->changed = true;
    +    }
    +
    +    /**
    +     * Encrypts a block
    +     *
    +     * Note: Must extend by the child Crypt_* class
    +     *
    +     * @access private
    +     * @param String $in
    +     * @return String
    +     */
    +    function _encryptBlock($in)
    +    {
    +        user_error((version_compare(PHP_VERSION, '5.0.0', '>=')  ? __METHOD__ : __FUNCTION__)  . '() must extend by class ' . get_class($this), E_USER_ERROR);
    +    }
    +
    +    /**
    +     * Decrypts a block
    +     *
    +     * Note: Must extend by the child Crypt_* class
    +     *
    +     * @access private
    +     * @param String $in
    +     * @return String
    +     */
    +    function _decryptBlock($in)
    +    {
    +        user_error((version_compare(PHP_VERSION, '5.0.0', '>=')  ? __METHOD__ : __FUNCTION__)  . '() must extend by class ' . get_class($this), E_USER_ERROR);
    +    }
    +
    +    /**
    +     * Setup the key (expansion)
    +     *
    +     * Only used if $engine == CRYPT_MODE_INTERNAL
    +     *
    +     * Note: Must extend by the child Crypt_* class
    +     *
    +     * @see Crypt_Base::_setup()
    +     * @access private
    +     */
    +    function _setupKey()
    +    {
    +        user_error((version_compare(PHP_VERSION, '5.0.0', '>=')  ? __METHOD__ : __FUNCTION__)  . '() must extend by class ' . get_class($this), E_USER_ERROR);
    +    }
    +
    +    /**
    +     * Setup the CRYPT_MODE_INTERNAL $engine
    +     *
    +     * (re)init, if necessary, the internal cipher $engine and flush all $buffers
    +     * Used (only) if $engine == CRYPT_MODE_INTERNAL
    +     *
    +     * _setup() will be called each time if $changed === true
    +     * typically this happens when using one or more of following public methods:
    +     *
    +     * - setKey()
    +     *
    +     * - setIV()
    +     *
    +     * - disableContinuousBuffer()
    +     *
    +     * - First run of encrypt() / decrypt() with no init-settings
    +     *
    +     * Internally: _setup() is called always before(!) en/decryption.
    +     *
    +     * Note: Could, but not must, extend by the child Crypt_* class
    +     *
    +     * @see setKey()
    +     * @see setIV()
    +     * @see disableContinuousBuffer()
    +     * @access private
    +     */
    +    function _setup()
    +    {
    +        $this->_clearBuffers();
    +        $this->_setupKey();
    +
    +        if ($this->use_inline_crypt) {
    +            $this->_setupInlineCrypt();
    +        }
    +    }
    +
    +    /**
    +     * Setup the CRYPT_MODE_MCRYPT $engine
    +     *
    +     * (re)init, if necessary, the (ext)mcrypt resources and flush all $buffers
    +     * Used (only) if $engine = CRYPT_MODE_MCRYPT
    +     *
    +     * _setupMcrypt() will be called each time if $changed === true
    +     * typically this happens when using one or more of following public methods:
    +     *
    +     * - setKey()
    +     *
    +     * - setIV()
    +     *
    +     * - disableContinuousBuffer()
    +     *
    +     * - First run of encrypt() / decrypt()
    +     *
    +     *
    +     * Note: Could, but not must, extend by the child Crypt_* class
    +     *
    +     * @see setKey()
    +     * @see setIV()
    +     * @see disableContinuousBuffer()
    +     * @access private
    +     */
    +    function _setupMcrypt()
    +    {
    +        $this->_clearBuffers();
    +        $this->enchanged = $this->dechanged = true;
    +
    +        if (!isset($this->enmcrypt)) {
    +            static $mcrypt_modes = array(
    +                CRYPT_MODE_CTR    => 'ctr',
    +                CRYPT_MODE_ECB    => MCRYPT_MODE_ECB,
    +                CRYPT_MODE_CBC    => MCRYPT_MODE_CBC,
    +                CRYPT_MODE_CFB    => 'ncfb',
    +                CRYPT_MODE_OFB    => MCRYPT_MODE_NOFB,
    +                CRYPT_MODE_STREAM => MCRYPT_MODE_STREAM,
    +            );
    +
    +            $this->demcrypt = mcrypt_module_open($this->cipher_name_mcrypt, '', $mcrypt_modes[$this->mode], '');
    +            $this->enmcrypt = mcrypt_module_open($this->cipher_name_mcrypt, '', $mcrypt_modes[$this->mode], '');
    +
    +            // we need the $ecb mcrypt resource (only) in MODE_CFB with enableContinuousBuffer()
    +            // to workaround mcrypt's broken ncfb implementation in buffered mode
    +            // see: {@link http://phpseclib.sourceforge.net/cfb-demo.phps}
    +            if ($this->mode == CRYPT_MODE_CFB) {
    +                $this->ecb = mcrypt_module_open($this->cipher_name_mcrypt, '', MCRYPT_MODE_ECB, '');
    +            }
    +
    +        } // else should mcrypt_generic_deinit be called?
    +
    +        if ($this->mode == CRYPT_MODE_CFB) {
    +            mcrypt_generic_init($this->ecb, $this->key, str_repeat("\0", $this->block_size));
    +        }
    +    }
    +
    +    /**
    +     * Pads a string
    +     *
    +     * Pads a string using the RSA PKCS padding standards so that its length is a multiple of the blocksize.
    +     * $this->block_size - (strlen($text) % $this->block_size) bytes are added, each of which is equal to
    +     * chr($this->block_size - (strlen($text) % $this->block_size)
    +     *
    +     * If padding is disabled and $text is not a multiple of the blocksize, the string will be padded regardless
    +     * and padding will, hence forth, be enabled.
    +     *
    +     * @see Crypt_Base::_unpad()
    +     * @param String $text
    +     * @access private
    +     * @return String
    +     */
    +    function _pad($text)
    +    {
    +        $length = strlen($text);
    +
    +        if (!$this->padding) {
    +            if ($length % $this->block_size == 0) {
    +                return $text;
    +            } else {
    +                user_error("The plaintext's length ($length) is not a multiple of the block size ({$this->block_size})");
    +                $this->padding = true;
    +            }
    +        }
    +
    +        $pad = $this->block_size - ($length % $this->block_size);
    +
    +        return str_pad($text, $length + $pad, chr($pad));
    +    }
    +
    +    /**
    +     * Unpads a string.
    +     *
    +     * If padding is enabled and the reported padding length is invalid the encryption key will be assumed to be wrong
    +     * and false will be returned.
    +     *
    +     * @see Crypt_Base::_pad()
    +     * @param String $text
    +     * @access private
    +     * @return String
    +     */
    +    function _unpad($text)
    +    {
    +        if (!$this->padding) {
    +            return $text;
    +        }
    +
    +        $length = ord($text[strlen($text) - 1]);
    +
    +        if (!$length || $length > $this->block_size) {
    +            return false;
    +        }
    +
    +        return substr($text, 0, -$length);
    +    }
    +
    +    /**
    +     * Clears internal buffers
    +     *
    +     * Clearing/resetting the internal buffers is done everytime
    +     * after disableContinuousBuffer() or on cipher $engine (re)init
    +     * ie after setKey() or setIV()
    +     *
    +     * Note: Could, but not must, extend by the child Crypt_* class
    +     *
    +     * @access public
    +     */
    +    function _clearBuffers()
    +    {
    +        $this->enbuffer = array('encrypted'  => '', 'xor' => '', 'pos' => 0, 'enmcrypt_init' => true);
    +        $this->debuffer = array('ciphertext' => '', 'xor' => '', 'pos' => 0, 'demcrypt_init' => true);
    +
    +        // mcrypt's handling of invalid's $iv:
    +        // $this->encryptIV = $this->decryptIV = strlen($this->iv) == $this->block_size ? $this->iv : str_repeat("\0", $this->block_size);
    +        $this->encryptIV = $this->decryptIV = str_pad(substr($this->iv, 0, $this->block_size), $this->block_size, "\0");
    +    }
    +
    +    /**
    +     * String Shift
    +     *
    +     * Inspired by array_shift
    +     *
    +     * @param String $string
    +     * @param optional Integer $index
    +     * @access private
    +     * @return String
    +     */
    +    function _stringShift(&$string, $index = 1)
    +    {
    +        $substr = substr($string, 0, $index);
    +        $string = substr($string, $index);
    +        return $substr;
    +    }
    +
    +    /**
    +     * Generate CTR XOR encryption key
    +     *
    +     * Encrypt the output of this and XOR it against the ciphertext / plaintext to get the
    +     * plaintext / ciphertext in CTR mode.
    +     *
    +     * @see Crypt_Base::decrypt()
    +     * @see Crypt_Base::encrypt()
    +     * @param String $iv
    +     * @param Integer $length
    +     * @access private
    +     * @return String $xor
    +     */
    +    function _generateXor(&$iv, $length)
    +    {
    +        $xor = '';
    +        $block_size = $this->block_size;
    +        $num_blocks = floor(($length + ($block_size - 1)) / $block_size);
    +        for ($i = 0; $i < $num_blocks; $i++) {
    +            $xor.= $iv;
    +            for ($j = 4; $j <= $block_size; $j+= 4) {
    +                $temp = substr($iv, -$j, 4);
    +                switch ($temp) {
    +                    case "\xFF\xFF\xFF\xFF":
    +                        $iv = substr_replace($iv, "\x00\x00\x00\x00", -$j, 4);
    +                        break;
    +                    case "\x7F\xFF\xFF\xFF":
    +                        $iv = substr_replace($iv, "\x80\x00\x00\x00", -$j, 4);
    +                        break 2;
    +                    default:
    +                        extract(unpack('Ncount', $temp));
    +                        $iv = substr_replace($iv, pack('N', $count + 1), -$j, 4);
    +                        break 2;
    +                }
    +            }
    +        }
    +
    +        return $xor;
    +    }
    +
    +    /**
    +     * Setup the performance-optimized function for de/encrypt()
    +     *
    +     * Stores the created (or existing) callback function-name
    +     * in $this->inline_crypt
    +     *
    +     * Internally for phpseclib developers:
    +     *
    +     *     _setupInlineCrypt() would be called only if:
    +     *
    +     *     - $engine == CRYPT_MODE_INTERNAL and
    +     *
    +     *     - $use_inline_crypt === true
    +     *
    +     *     - each time on _setup(), after(!) _setupKey()
    +     *
    +     *
    +     *     This ensures that _setupInlineCrypt() has allways a
    +     *     full ready2go initializated internal cipher $engine state
    +     *     where, for example, the keys allready expanded,
    +     *     keys/block_size calculated and such.
    +     *
    +     *     It is, each time if called, the responsibility of _setupInlineCrypt():
    +     *
    +     *     - to set $this->inline_crypt to a valid and fully working callback function
    +     *       as a (faster) replacement for encrypt() / decrypt()
    +     *
    +     *     - NOT to create unlimited callback functions (for memory reasons!)
    +     *       no matter how often _setupInlineCrypt() would be called. At some
    +     *       point of amount they must be generic re-useable.
    +     *
    +     *     - the code of _setupInlineCrypt() it self,
    +     *       and the generated callback code,
    +     *       must be, in following order:
    +     *       - 100% safe
    +     *       - 100% compatible to encrypt()/decrypt()
    +     *       - using only php5+ features/lang-constructs/php-extensions if
    +     *         compatibility (down to php4) or fallback is provided
    +     *       - readable/maintainable/understandable/commented and... not-cryptic-styled-code :-)
    +     *       - >= 10% faster than encrypt()/decrypt() [which is, by the way,
    +     *         the reason for the existence of _setupInlineCrypt() :-)]
    +     *       - memory-nice
    +     *       - short (as good as possible)
    +     *
    +     * Note: - _setupInlineCrypt() is using _createInlineCryptFunction() to create the full callback function code.
    +     *       - In case of using inline crypting, _setupInlineCrypt() must extend by the child Crypt_* class.
    +     *       - The following variable names are reserved:
    +     *         - $_*  (all variable names prefixed with an underscore)
    +     *         - $self (object reference to it self. Do not use $this, but $self instead)
    +     *         - $in (the content of $in has to en/decrypt by the generated code)
    +     *       - The callback function should not use the 'return' statement, but en/decrypt'ing the content of $in only
    +     *
    +     *
    +     * @see Crypt_Base::_setup()
    +     * @see Crypt_Base::_createInlineCryptFunction()
    +     * @see Crypt_Base::encrypt()
    +     * @see Crypt_Base::decrypt()
    +     * @access private
    +     */
    +    function _setupInlineCrypt()
    +    {
    +        // If a Crypt_* class providing inline crypting it must extend _setupInlineCrypt()
    +
    +        // If, for any reason, an extending Crypt_Base() Crypt_* class
    +        // not using inline crypting then it must be ensured that: $this->use_inline_crypt = false
    +        // ie in the class var declaration of $use_inline_crypt in general for the Crypt_* class,
    +        // in the constructor at object instance-time
    +        // or, if it's runtime-specific, at runtime
    +
    +        $this->use_inline_crypt = false;
    +    }
    +
    +    /**
    +     * Creates the performance-optimized function for en/decrypt()
    +     *
    +     * Internally for phpseclib developers:
    +     *
    +     *    _createInlineCryptFunction():
    +     *
    +     *    - merge the $cipher_code [setup'ed by _setupInlineCrypt()]
    +     *      with the current [$this->]mode of operation code
    +     *
    +     *    - create the $inline function, which called by encrypt() / decrypt()
    +     *      as its replacement to speed up the en/decryption operations.
    +     *
    +     *    - return the name of the created $inline callback function
    +     *
    +     *    - used to speed up en/decryption
    +     *
    +     *
    +     *
    +     *    The main reason why can speed up things [up to 50%] this way are:
    +     *
    +     *    - using variables more effective then regular.
    +     *      (ie no use of expensive arrays but integers $k_0, $k_1 ...
    +     *      or even, for example, the pure $key[] values hardcoded)
    +     *
    +     *    - avoiding 1000's of function calls of ie _encryptBlock()
    +     *      but inlining the crypt operations.
    +     *      in the mode of operation for() loop.
    +     *
    +     *    - full loop unroll the (sometimes key-dependent) rounds
    +     *      avoiding this way ++$i counters and runtime-if's etc...
    +     *
    +     *    The basic code architectur of the generated $inline en/decrypt()
    +     *    lambda function, in pseudo php, is:
    +     *
    +     *    
    +     *    +----------------------------------------------------------------------------------------------+
    +     *    | callback $inline = create_function:                                                          |
    +     *    | lambda_function_0001_crypt_ECB($action, $text)                                               |
    +     *    | {                                                                                            |
    +     *    |     INSERT PHP CODE OF:                                                                      |
    +     *    |     $cipher_code['init_crypt'];                  // general init code.                       |
    +     *    |                                                  // ie: $sbox'es declarations used for       |
    +     *    |                                                  //     encrypt and decrypt'ing.             |
    +     *    |                                                                                              |
    +     *    |     switch ($action) {                                                                       |
    +     *    |         case 'encrypt':                                                                      |
    +     *    |             INSERT PHP CODE OF:                                                              |
    +     *    |             $cipher_code['init_encrypt'];       // encrypt sepcific init code.               |
    +     *    |                                                    ie: specified $key or $box                |
    +     *    |                                                        declarations for encrypt'ing.         |
    +     *    |                                                                                              |
    +     *    |             foreach ($ciphertext) {                                                          |
    +     *    |                 $in = $block_size of $ciphertext;                                            |
    +     *    |                                                                                              |
    +     *    |                 INSERT PHP CODE OF:                                                          |
    +     *    |                 $cipher_code['encrypt_block'];  // encrypt's (string) $in, which is always:  |
    +     *    |                                                 // strlen($in) == $this->block_size          |
    +     *    |                                                 // here comes the cipher algorithm in action |
    +     *    |                                                 // for encryption.                           |
    +     *    |                                                 // $cipher_code['encrypt_block'] has to      |
    +     *    |                                                 // encrypt the content of the $in variable   |
    +     *    |                                                                                              |
    +     *    |                 $plaintext .= $in;                                                           |
    +     *    |             }                                                                                |
    +     *    |             return $plaintext;                                                               |
    +     *    |                                                                                              |
    +     *    |         case 'decrypt':                                                                      |
    +     *    |             INSERT PHP CODE OF:                                                              |
    +     *    |             $cipher_code['init_decrypt'];       // decrypt sepcific init code                |
    +     *    |                                                    ie: specified $key or $box                |
    +     *    |                                                        declarations for decrypt'ing.         |
    +     *    |             foreach ($plaintext) {                                                           |
    +     *    |                 $in = $block_size of $plaintext;                                             |
    +     *    |                                                                                              |
    +     *    |                 INSERT PHP CODE OF:                                                          |
    +     *    |                 $cipher_code['decrypt_block'];  // decrypt's (string) $in, which is always   |
    +     *    |                                                 // strlen($in) == $this->block_size          |
    +     *    |                                                 // here comes the cipher algorithm in action |
    +     *    |                                                 // for decryption.                           |
    +     *    |                                                 // $cipher_code['decrypt_block'] has to      |
    +     *    |                                                 // decrypt the content of the $in variable   |
    +     *    |                 $ciphertext .= $in;                                                          |
    +     *    |             }                                                                                |
    +     *    |             return $ciphertext;                                                              |
    +     *    |     }                                                                                        |
    +     *    | }                                                                                            |
    +     *    +----------------------------------------------------------------------------------------------+
    +     *    
    +     *
    +     *    See also the Crypt_*::_setupInlineCrypt()'s for
    +     *    productive inline $cipher_code's how they works.
    +     *
    +     *    Structure of:
    +     *    
    +     *    $cipher_code = array(
    +     *        'init_crypt'    => (string) '', // optional
    +     *        'init_encrypt'  => (string) '', // optional
    +     *        'init_decrypt'  => (string) '', // optional
    +     *        'encrypt_block' => (string) '', // required
    +     *        'decrypt_block' => (string) ''  // required
    +     *    );
    +     *    
    +     *
    +     * @see Crypt_Base::_setupInlineCrypt()
    +     * @see Crypt_Base::encrypt()
    +     * @see Crypt_Base::decrypt()
    +     * @param Array $cipher_code
    +     * @access private
    +     * @return String (the name of the created callback function)
    +     */
    +    function _createInlineCryptFunction($cipher_code)
    +    {
    +        $block_size = $this->block_size;
    +
    +        // optional
    +        $init_crypt    = isset($cipher_code['init_crypt'])    ? $cipher_code['init_crypt']    : '';
    +        $init_encrypt  = isset($cipher_code['init_encrypt'])  ? $cipher_code['init_encrypt']  : '';
    +        $init_decrypt  = isset($cipher_code['init_decrypt'])  ? $cipher_code['init_decrypt']  : '';
    +        // required
    +        $encrypt_block = $cipher_code['encrypt_block'];
    +        $decrypt_block = $cipher_code['decrypt_block'];
    +
    +        // Generating mode of operation inline code,
    +        // merged with the $cipher_code algorithm
    +        // for encrypt- and decryption.
    +        switch ($this->mode) {
    +            case CRYPT_MODE_ECB:
    +                $encrypt = $init_encrypt . '
    +                    $_ciphertext = "";
    +                    $_text = $self->_pad($_text);
    +                    $_plaintext_len = strlen($_text);
    +
    +                    for ($_i = 0; $_i < $_plaintext_len; $_i+= '.$block_size.') {
    +                        $in = substr($_text, $_i, '.$block_size.');
    +                        '.$encrypt_block.'
    +                        $_ciphertext.= $in;
    +                    }
    +
    +                    return $_ciphertext;
    +                    ';
    +
    +                $decrypt = $init_decrypt . '
    +                    $_plaintext = "";
    +                    $_text = str_pad($_text, strlen($_text) + ('.$block_size.' - strlen($_text) % '.$block_size.') % '.$block_size.', chr(0));
    +                    $_ciphertext_len = strlen($_text);
    +
    +                    for ($_i = 0; $_i < $_ciphertext_len; $_i+= '.$block_size.') {
    +                        $in = substr($_text, $_i, '.$block_size.');
    +                        '.$decrypt_block.'
    +                        $_plaintext.= $in;
    +                    }
    +
    +                    return $self->_unpad($_plaintext);
    +                    ';
    +                break;
    +            case CRYPT_MODE_CTR:
    +                $encrypt = $init_encrypt . '
    +                    $_ciphertext = "";
    +                    $_plaintext_len = strlen($_text);
    +                    $_xor = $self->encryptIV;
    +                    $_buffer = &$self->enbuffer;
    +
    +                    if (strlen($_buffer["encrypted"])) {
    +                        for ($_i = 0; $_i < $_plaintext_len; $_i+= '.$block_size.') {
    +                            $_block = substr($_text, $_i, '.$block_size.');
    +                            if (strlen($_block) > strlen($_buffer["encrypted"])) {
    +                                $in = $self->_generateXor($_xor, '.$block_size.');
    +                                '.$encrypt_block.'
    +                                $_buffer["encrypted"].= $in;
    +                            }
    +                            $_key = $self->_stringShift($_buffer["encrypted"], '.$block_size.');
    +                            $_ciphertext.= $_block ^ $_key;
    +                        }
    +                    } else {
    +                        for ($_i = 0; $_i < $_plaintext_len; $_i+= '.$block_size.') {
    +                            $_block = substr($_text, $_i, '.$block_size.');
    +                            $in = $self->_generateXor($_xor, '.$block_size.');
    +                            '.$encrypt_block.'
    +                            $_key = $in;
    +                            $_ciphertext.= $_block ^ $_key;
    +                        }
    +                    }
    +                    if ($self->continuousBuffer) {
    +                        $self->encryptIV = $_xor;
    +                        if ($_start = $_plaintext_len % '.$block_size.') {
    +                            $_buffer["encrypted"] = substr($_key, $_start) . $_buffer["encrypted"];
    +                        }
    +                    }
    +
    +                    return $_ciphertext;
    +                ';
    +
    +                $decrypt = $init_encrypt . '
    +                    $_plaintext = "";
    +                    $_ciphertext_len = strlen($_text);
    +                    $_xor = $self->decryptIV;
    +                    $_buffer = &$self->debuffer;
    +
    +                    if (strlen($_buffer["ciphertext"])) {
    +                        for ($_i = 0; $_i < $_ciphertext_len; $_i+= '.$block_size.') {
    +                            $_block = substr($_text, $_i, '.$block_size.');
    +                            if (strlen($_block) > strlen($_buffer["ciphertext"])) {
    +                                $in = $self->_generateXor($_xor, '.$block_size.');
    +                                '.$encrypt_block.'
    +                                $_buffer["ciphertext"].= $in;
    +                            }
    +                            $_key = $self->_stringShift($_buffer["ciphertext"], '.$block_size.');
    +                            $_plaintext.= $_block ^ $_key;
    +                        }
    +                    } else {
    +                        for ($_i = 0; $_i < $_ciphertext_len; $_i+= '.$block_size.') {
    +                            $_block = substr($_text, $_i, '.$block_size.');
    +                            $in = $self->_generateXor($_xor, '.$block_size.');
    +                            '.$encrypt_block.'
    +                            $_key = $in;
    +                            $_plaintext.= $_block ^ $_key;
    +                        }
    +                    }
    +                    if ($self->continuousBuffer) {
    +                        $self->decryptIV = $_xor;
    +                        if ($_start = $_ciphertext_len % '.$block_size.') {
    +                            $_buffer["ciphertext"] = substr($_key, $_start) . $_buffer["ciphertext"];
    +                        }
    +                    }
    +
    +                    return $_plaintext;
    +                    ';
    +                break;
    +            case CRYPT_MODE_CFB:
    +                $encrypt = $init_encrypt . '
    +                    $_ciphertext = "";
    +                    $_buffer = &$self->enbuffer;
    +
    +                    if ($self->continuousBuffer) {
    +                        $_iv = &$self->encryptIV;
    +                        $_pos = &$_buffer["pos"];
    +                    } else {
    +                        $_iv = $self->encryptIV;
    +                        $_pos = 0;
    +                    }
    +                    $_len = strlen($_text);
    +                    $_i = 0;
    +                    if ($_pos) {
    +                        $_orig_pos = $_pos;
    +                        $_max = '.$block_size.' - $_pos;
    +                        if ($_len >= $_max) {
    +                            $_i = $_max;
    +                            $_len-= $_max;
    +                            $_pos = 0;
    +                        } else {
    +                            $_i = $_len;
    +                            $_pos+= $_len;
    +                            $_len = 0;
    +                        }
    +                        $_ciphertext = substr($_iv, $_orig_pos) ^ $_text;
    +                        $_iv = substr_replace($_iv, $_ciphertext, $_orig_pos, $_i);
    +                    }
    +                    while ($_len >= '.$block_size.') {
    +                        $in = $_iv;
    +                        '.$encrypt_block.';
    +                        $_iv = $in ^ substr($_text, $_i, '.$block_size.');
    +                        $_ciphertext.= $_iv;
    +                        $_len-= '.$block_size.';
    +                        $_i+= '.$block_size.';
    +                    }
    +                    if ($_len) {
    +                        $in = $_iv;
    +                        '.$encrypt_block.'
    +                        $_iv = $in;
    +                        $_block = $_iv ^ substr($_text, $_i);
    +                        $_iv = substr_replace($_iv, $_block, 0, $_len);
    +                        $_ciphertext.= $_block;
    +                        $_pos = $_len;
    +                    }
    +                    return $_ciphertext;
    +                ';
    +
    +                $decrypt = $init_encrypt . '
    +                    $_plaintext = "";
    +                    $_buffer = &$self->debuffer;
    +
    +                    if ($self->continuousBuffer) {
    +                        $_iv = &$self->decryptIV;
    +                        $_pos = &$_buffer["pos"];
    +                    } else {
    +                        $_iv = $self->decryptIV;
    +                        $_pos = 0;
    +                    }
    +                    $_len = strlen($_text);
    +                    $_i = 0;
    +                    if ($_pos) {
    +                        $_orig_pos = $_pos;
    +                        $_max = '.$block_size.' - $_pos;
    +                        if ($_len >= $_max) {
    +                            $_i = $_max;
    +                            $_len-= $_max;
    +                            $_pos = 0;
    +                        } else {
    +                            $_i = $_len;
    +                            $_pos+= $_len;
    +                            $_len = 0;
    +                        }
    +                        $_plaintext = substr($_iv, $_orig_pos) ^ $_text;
    +                        $_iv = substr_replace($_iv, substr($_text, 0, $_i), $_orig_pos, $_i);
    +                    }
    +                    while ($_len >= '.$block_size.') {
    +                        $in = $_iv;
    +                        '.$encrypt_block.'
    +                        $_iv = $in;
    +                        $cb = substr($_text, $_i, '.$block_size.');
    +                        $_plaintext.= $_iv ^ $cb;
    +                        $_iv = $cb;
    +                        $_len-= '.$block_size.';
    +                        $_i+= '.$block_size.';
    +                    }
    +                    if ($_len) {
    +                        $in = $_iv;
    +                        '.$encrypt_block.'
    +                        $_iv = $in;
    +                        $_plaintext.= $_iv ^ substr($_text, $_i);
    +                        $_iv = substr_replace($_iv, substr($_text, $_i), 0, $_len);
    +                        $_pos = $_len;
    +                    }
    +
    +                    return $_plaintext;
    +                    ';
    +                break;
    +            case CRYPT_MODE_OFB:
    +                $encrypt = $init_encrypt . '
    +                    $_ciphertext = "";
    +                    $_plaintext_len = strlen($_text);
    +                    $_xor = $self->encryptIV;
    +                    $_buffer = &$self->enbuffer;
    +
    +                    if (strlen($_buffer["xor"])) {
    +                        for ($_i = 0; $_i < $_plaintext_len; $_i+= '.$block_size.') {
    +                            $_block = substr($_text, $_i, '.$block_size.');
    +                            if (strlen($_block) > strlen($_buffer["xor"])) {
    +                                $in = $_xor;
    +                                '.$encrypt_block.'
    +                                $_xor = $in;
    +                                $_buffer["xor"].= $_xor;
    +                            }
    +                            $_key = $self->_stringShift($_buffer["xor"], '.$block_size.');
    +                            $_ciphertext.= $_block ^ $_key;
    +                        }
    +                    } else {
    +                        for ($_i = 0; $_i < $_plaintext_len; $_i+= '.$block_size.') {
    +                            $in = $_xor;
    +                            '.$encrypt_block.'
    +                            $_xor = $in;
    +                            $_ciphertext.= substr($_text, $_i, '.$block_size.') ^ $_xor;
    +                        }
    +                        $_key = $_xor;
    +                    }
    +                    if ($self->continuousBuffer) {
    +                        $self->encryptIV = $_xor;
    +                        if ($_start = $_plaintext_len % '.$block_size.') {
    +                             $_buffer["xor"] = substr($_key, $_start) . $_buffer["xor"];
    +                        }
    +                    }
    +                    return $_ciphertext;
    +                    ';
    +
    +                $decrypt = $init_encrypt . '
    +                    $_plaintext = "";
    +                    $_ciphertext_len = strlen($_text);
    +                    $_xor = $self->decryptIV;
    +                    $_buffer = &$self->debuffer;
    +
    +                    if (strlen($_buffer["xor"])) {
    +                        for ($_i = 0; $_i < $_ciphertext_len; $_i+= '.$block_size.') {
    +                            $_block = substr($_text, $_i, '.$block_size.');
    +                            if (strlen($_block) > strlen($_buffer["xor"])) {
    +                                $in = $_xor;
    +                                '.$encrypt_block.'
    +                                $_xor = $in;
    +                                $_buffer["xor"].= $_xor;
    +                            }
    +                            $_key = $self->_stringShift($_buffer["xor"], '.$block_size.');
    +                            $_plaintext.= $_block ^ $_key;
    +                        }
    +                    } else {
    +                        for ($_i = 0; $_i < $_ciphertext_len; $_i+= '.$block_size.') {
    +                            $in = $_xor;
    +                            '.$encrypt_block.'
    +                            $_xor = $in;
    +                            $_plaintext.= substr($_text, $_i, '.$block_size.') ^ $_xor;
    +                        }
    +                        $_key = $_xor;
    +                    }
    +                    if ($self->continuousBuffer) {
    +                        $self->decryptIV = $_xor;
    +                        if ($_start = $_ciphertext_len % '.$block_size.') {
    +                             $_buffer["xor"] = substr($_key, $_start) . $_buffer["xor"];
    +                        }
    +                    }
    +                    return $_plaintext;
    +                    ';
    +                break;
    +            case CRYPT_MODE_STREAM:
    +                $encrypt = $init_encrypt . '
    +                    $_ciphertext = "";
    +                    '.$encrypt_block.'
    +                    return $_ciphertext;
    +                    ';
    +                $decrypt = $init_decrypt . '
    +                    $_plaintext = "";
    +                    '.$decrypt_block.'
    +                    return $_plaintext;
    +                    ';
    +                break;
    +            // case CRYPT_MODE_CBC:
    +            default:
    +                $encrypt = $init_encrypt . '
    +                    $_ciphertext = "";
    +                    $_text = $self->_pad($_text);
    +                    $_plaintext_len = strlen($_text);
    +
    +                    $in = $self->encryptIV;
    +
    +                    for ($_i = 0; $_i < $_plaintext_len; $_i+= '.$block_size.') {
    +                        $in = substr($_text, $_i, '.$block_size.') ^ $in;
    +                        '.$encrypt_block.'
    +                        $_ciphertext.= $in;
    +                    }
    +
    +                    if ($self->continuousBuffer) {
    +                        $self->encryptIV = $in;
    +                    }
    +
    +                    return $_ciphertext;
    +                    ';
    +
    +                $decrypt = $init_decrypt . '
    +                    $_plaintext = "";
    +                    $_text = str_pad($_text, strlen($_text) + ('.$block_size.' - strlen($_text) % '.$block_size.') % '.$block_size.', chr(0));
    +                    $_ciphertext_len = strlen($_text);
    +
    +                    $_iv = $self->decryptIV;
    +
    +                    for ($_i = 0; $_i < $_ciphertext_len; $_i+= '.$block_size.') {
    +                        $in = $_block = substr($_text, $_i, '.$block_size.');
    +                        '.$decrypt_block.'
    +                        $_plaintext.= $in ^ $_iv;
    +                        $_iv = $_block;
    +                    }
    +
    +                    if ($self->continuousBuffer) {
    +                        $self->decryptIV = $_iv;
    +                    }
    +
    +                    return $self->_unpad($_plaintext);
    +                    ';
    +                break;
    +        }
    +
    +        // Create the $inline function and return its name as string. Ready to run!
    +        return create_function('$_action, &$self, $_text', $init_crypt . 'if ($_action == "encrypt") { ' . $encrypt . ' } else { ' . $decrypt . ' }');
    +    }
    +
    +    /**
    +     * Holds the lambda_functions table (classwide)
    +     *
    +     * Each name of the lambda function, created from
    +     * _setupInlineCrypt() && _createInlineCryptFunction()
    +     * is stored, classwide (!), here for reusing.
    +     *
    +     * The string-based index of $function is a classwide
    +     * uniqe value representing, at least, the $mode of
    +     * operation (or more... depends of the optimizing level)
    +     * for which $mode the lambda function was created.
    +     *
    +     * @access private
    +     * @return &Array
    +     */
    +    function &_getLambdaFunctions()
    +    {
    +        static $functions = array();
    +        return $functions;
    +    }
    +}
    diff --git a/vendor/phpseclib/phpseclib/phpseclib/Crypt/Blowfish.php b/vendor/phpseclib/phpseclib/phpseclib/Crypt/Blowfish.php
    new file mode 100755
    index 0000000..b352e7c
    --- /dev/null
    +++ b/vendor/phpseclib/phpseclib/phpseclib/Crypt/Blowfish.php
    @@ -0,0 +1,674 @@
    +
    + * setKey('12345678901234567890123456789012');
    + *
    + *    $plaintext = str_repeat('a', 1024);
    + *
    + *    echo $blowfish->decrypt($blowfish->encrypt($plaintext));
    + * ?>
    + * 
    + *
    + * LICENSE: Permission is hereby granted, free of charge, to any person obtaining a copy
    + * of this software and associated documentation files (the "Software"), to deal
    + * in the Software without restriction, including without limitation the rights
    + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    + * copies of the Software, and to permit persons to whom the Software is
    + * furnished to do so, subject to the following conditions:
    + *
    + * The above copyright notice and this permission notice shall be included in
    + * all copies or substantial portions of the Software.
    + *
    + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
    + * THE SOFTWARE.
    + *
    + * @category  Crypt
    + * @package   Crypt_Blowfish
    + * @author    Jim Wigginton 
    + * @author    Hans-Juergen Petrich 
    + * @copyright MMVII Jim Wigginton
    + * @license   http://www.opensource.org/licenses/mit-license.html  MIT License
    + * @version   1.0
    + * @link      http://phpseclib.sourceforge.net
    + */
    +
    +/**
    + * Include Crypt_Base
    + *
    + * Base cipher class
    + */
    +if (!class_exists('Crypt_Base')) {
    +    include_once 'Base.php';
    +}
    +
    +/**#@+
    + * @access public
    + * @see Crypt_Blowfish::encrypt()
    + * @see Crypt_Blowfish::decrypt()
    + */
    +/**
    + * Encrypt / decrypt using the Counter mode.
    + *
    + * Set to -1 since that's what Crypt/Random.php uses to index the CTR mode.
    + *
    + * @link http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation#Counter_.28CTR.29
    + */
    +define('CRYPT_BLOWFISH_MODE_CTR', CRYPT_MODE_CTR);
    +/**
    + * Encrypt / decrypt using the Electronic Code Book mode.
    + *
    + * @link http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation#Electronic_codebook_.28ECB.29
    + */
    +define('CRYPT_BLOWFISH_MODE_ECB', CRYPT_MODE_ECB);
    +/**
    + * Encrypt / decrypt using the Code Book Chaining mode.
    + *
    + * @link http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation#Cipher-block_chaining_.28CBC.29
    + */
    +define('CRYPT_BLOWFISH_MODE_CBC', CRYPT_MODE_CBC);
    +/**
    + * Encrypt / decrypt using the Cipher Feedback mode.
    + *
    + * @link http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation#Cipher_feedback_.28CFB.29
    + */
    +define('CRYPT_BLOWFISH_MODE_CFB', CRYPT_MODE_CFB);
    +/**
    + * Encrypt / decrypt using the Cipher Feedback mode.
    + *
    + * @link http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation#Output_feedback_.28OFB.29
    + */
    +define('CRYPT_BLOWFISH_MODE_OFB', CRYPT_MODE_OFB);
    +/**#@-*/
    +
    +/**#@+
    + * @access private
    + * @see Crypt_Blowfish::Crypt_Blowfish()
    + */
    +/**
    + * Toggles the internal implementation
    + */
    +define('CRYPT_BLOWFISH_MODE_INTERNAL', CRYPT_MODE_INTERNAL);
    +/**
    + * Toggles the mcrypt implementation
    + */
    +define('CRYPT_BLOWFISH_MODE_MCRYPT', CRYPT_MODE_MCRYPT);
    +/**#@-*/
    +
    +/**
    + * Pure-PHP implementation of Blowfish.
    + *
    + * @package Crypt_Blowfish
    + * @author  Jim Wigginton 
    + * @author  Hans-Juergen Petrich 
    + * @version 1.0
    + * @access  public
    + */
    +class Crypt_Blowfish extends Crypt_Base
    +{
    +    /**
    +     * Block Length of the cipher
    +     *
    +     * @see Crypt_Base::block_size
    +     * @var Integer
    +     * @access private
    +     */
    +    var $block_size = 8;
    +
    +    /**
    +     * The default password key_size used by setPassword()
    +     *
    +     * @see Crypt_Base::password_key_size
    +     * @see Crypt_Base::setPassword()
    +     * @var Integer
    +     * @access private
    +     */
    +    var $password_key_size = 56;
    +
    +    /**
    +     * The namespace used by the cipher for its constants.
    +     *
    +     * @see Crypt_Base::const_namespace
    +     * @var String
    +     * @access private
    +     */
    +    var $const_namespace = 'BLOWFISH';
    +
    +    /**
    +     * The mcrypt specific name of the cipher
    +     *
    +     * @see Crypt_Base::cipher_name_mcrypt
    +     * @var String
    +     * @access private
    +     */
    +    var $cipher_name_mcrypt = 'blowfish';
    +
    +    /**
    +     * Optimizing value while CFB-encrypting
    +     *
    +     * @see Crypt_Base::cfb_init_len
    +     * @var Integer
    +     * @access private
    +     */
    +    var $cfb_init_len = 500;
    +
    +    /**
    +     * The fixed subkeys boxes ($sbox0 - $sbox3) with 256 entries each
    +     *
    +     * S-Box 1
    +     *
    +     * @access private
    +     * @var    array
    +     */
    +    var $sbox0 = array (
    +        0xd1310ba6, 0x98dfb5ac, 0x2ffd72db, 0xd01adfb7, 0xb8e1afed, 0x6a267e96, 0xba7c9045, 0xf12c7f99,
    +        0x24a19947, 0xb3916cf7, 0x0801f2e2, 0x858efc16, 0x636920d8, 0x71574e69, 0xa458fea3, 0xf4933d7e,
    +        0x0d95748f, 0x728eb658, 0x718bcd58, 0x82154aee, 0x7b54a41d, 0xc25a59b5, 0x9c30d539, 0x2af26013,
    +        0xc5d1b023, 0x286085f0, 0xca417918, 0xb8db38ef, 0x8e79dcb0, 0x603a180e, 0x6c9e0e8b, 0xb01e8a3e,
    +        0xd71577c1, 0xbd314b27, 0x78af2fda, 0x55605c60, 0xe65525f3, 0xaa55ab94, 0x57489862, 0x63e81440,
    +        0x55ca396a, 0x2aab10b6, 0xb4cc5c34, 0x1141e8ce, 0xa15486af, 0x7c72e993, 0xb3ee1411, 0x636fbc2a,
    +        0x2ba9c55d, 0x741831f6, 0xce5c3e16, 0x9b87931e, 0xafd6ba33, 0x6c24cf5c, 0x7a325381, 0x28958677,
    +        0x3b8f4898, 0x6b4bb9af, 0xc4bfe81b, 0x66282193, 0x61d809cc, 0xfb21a991, 0x487cac60, 0x5dec8032,
    +        0xef845d5d, 0xe98575b1, 0xdc262302, 0xeb651b88, 0x23893e81, 0xd396acc5, 0x0f6d6ff3, 0x83f44239,
    +        0x2e0b4482, 0xa4842004, 0x69c8f04a, 0x9e1f9b5e, 0x21c66842, 0xf6e96c9a, 0x670c9c61, 0xabd388f0,
    +        0x6a51a0d2, 0xd8542f68, 0x960fa728, 0xab5133a3, 0x6eef0b6c, 0x137a3be4, 0xba3bf050, 0x7efb2a98,
    +        0xa1f1651d, 0x39af0176, 0x66ca593e, 0x82430e88, 0x8cee8619, 0x456f9fb4, 0x7d84a5c3, 0x3b8b5ebe,
    +        0xe06f75d8, 0x85c12073, 0x401a449f, 0x56c16aa6, 0x4ed3aa62, 0x363f7706, 0x1bfedf72, 0x429b023d,
    +        0x37d0d724, 0xd00a1248, 0xdb0fead3, 0x49f1c09b, 0x075372c9, 0x80991b7b, 0x25d479d8, 0xf6e8def7,
    +        0xe3fe501a, 0xb6794c3b, 0x976ce0bd, 0x04c006ba, 0xc1a94fb6, 0x409f60c4, 0x5e5c9ec2, 0x196a2463,
    +        0x68fb6faf, 0x3e6c53b5, 0x1339b2eb, 0x3b52ec6f, 0x6dfc511f, 0x9b30952c, 0xcc814544, 0xaf5ebd09,
    +        0xbee3d004, 0xde334afd, 0x660f2807, 0x192e4bb3, 0xc0cba857, 0x45c8740f, 0xd20b5f39, 0xb9d3fbdb,
    +        0x5579c0bd, 0x1a60320a, 0xd6a100c6, 0x402c7279, 0x679f25fe, 0xfb1fa3cc, 0x8ea5e9f8, 0xdb3222f8,
    +        0x3c7516df, 0xfd616b15, 0x2f501ec8, 0xad0552ab, 0x323db5fa, 0xfd238760, 0x53317b48, 0x3e00df82,
    +        0x9e5c57bb, 0xca6f8ca0, 0x1a87562e, 0xdf1769db, 0xd542a8f6, 0x287effc3, 0xac6732c6, 0x8c4f5573,
    +        0x695b27b0, 0xbbca58c8, 0xe1ffa35d, 0xb8f011a0, 0x10fa3d98, 0xfd2183b8, 0x4afcb56c, 0x2dd1d35b,
    +        0x9a53e479, 0xb6f84565, 0xd28e49bc, 0x4bfb9790, 0xe1ddf2da, 0xa4cb7e33, 0x62fb1341, 0xcee4c6e8,
    +        0xef20cada, 0x36774c01, 0xd07e9efe, 0x2bf11fb4, 0x95dbda4d, 0xae909198, 0xeaad8e71, 0x6b93d5a0,
    +        0xd08ed1d0, 0xafc725e0, 0x8e3c5b2f, 0x8e7594b7, 0x8ff6e2fb, 0xf2122b64, 0x8888b812, 0x900df01c,
    +        0x4fad5ea0, 0x688fc31c, 0xd1cff191, 0xb3a8c1ad, 0x2f2f2218, 0xbe0e1777, 0xea752dfe, 0x8b021fa1,
    +        0xe5a0cc0f, 0xb56f74e8, 0x18acf3d6, 0xce89e299, 0xb4a84fe0, 0xfd13e0b7, 0x7cc43b81, 0xd2ada8d9,
    +        0x165fa266, 0x80957705, 0x93cc7314, 0x211a1477, 0xe6ad2065, 0x77b5fa86, 0xc75442f5, 0xfb9d35cf,
    +        0xebcdaf0c, 0x7b3e89a0, 0xd6411bd3, 0xae1e7e49, 0x00250e2d, 0x2071b35e, 0x226800bb, 0x57b8e0af,
    +        0x2464369b, 0xf009b91e, 0x5563911d, 0x59dfa6aa, 0x78c14389, 0xd95a537f, 0x207d5ba2, 0x02e5b9c5,
    +        0x83260376, 0x6295cfa9, 0x11c81968, 0x4e734a41, 0xb3472dca, 0x7b14a94a, 0x1b510052, 0x9a532915,
    +        0xd60f573f, 0xbc9bc6e4, 0x2b60a476, 0x81e67400, 0x08ba6fb5, 0x571be91f, 0xf296ec6b, 0x2a0dd915,
    +        0xb6636521, 0xe7b9f9b6, 0xff34052e, 0xc5855664, 0x53b02d5d, 0xa99f8fa1, 0x08ba4799, 0x6e85076a
    +    );
    +
    +    /**
    +     * S-Box 1
    +     *
    +     * @access private
    +     * @var    array
    +     */
    +    var $sbox1 = array(
    +        0x4b7a70e9, 0xb5b32944, 0xdb75092e, 0xc4192623, 0xad6ea6b0, 0x49a7df7d, 0x9cee60b8, 0x8fedb266,
    +        0xecaa8c71, 0x699a17ff, 0x5664526c, 0xc2b19ee1, 0x193602a5, 0x75094c29, 0xa0591340, 0xe4183a3e,
    +        0x3f54989a, 0x5b429d65, 0x6b8fe4d6, 0x99f73fd6, 0xa1d29c07, 0xefe830f5, 0x4d2d38e6, 0xf0255dc1,
    +        0x4cdd2086, 0x8470eb26, 0x6382e9c6, 0x021ecc5e, 0x09686b3f, 0x3ebaefc9, 0x3c971814, 0x6b6a70a1,
    +        0x687f3584, 0x52a0e286, 0xb79c5305, 0xaa500737, 0x3e07841c, 0x7fdeae5c, 0x8e7d44ec, 0x5716f2b8,
    +        0xb03ada37, 0xf0500c0d, 0xf01c1f04, 0x0200b3ff, 0xae0cf51a, 0x3cb574b2, 0x25837a58, 0xdc0921bd,
    +        0xd19113f9, 0x7ca92ff6, 0x94324773, 0x22f54701, 0x3ae5e581, 0x37c2dadc, 0xc8b57634, 0x9af3dda7,
    +        0xa9446146, 0x0fd0030e, 0xecc8c73e, 0xa4751e41, 0xe238cd99, 0x3bea0e2f, 0x3280bba1, 0x183eb331,
    +        0x4e548b38, 0x4f6db908, 0x6f420d03, 0xf60a04bf, 0x2cb81290, 0x24977c79, 0x5679b072, 0xbcaf89af,
    +        0xde9a771f, 0xd9930810, 0xb38bae12, 0xdccf3f2e, 0x5512721f, 0x2e6b7124, 0x501adde6, 0x9f84cd87,
    +        0x7a584718, 0x7408da17, 0xbc9f9abc, 0xe94b7d8c, 0xec7aec3a, 0xdb851dfa, 0x63094366, 0xc464c3d2,
    +        0xef1c1847, 0x3215d908, 0xdd433b37, 0x24c2ba16, 0x12a14d43, 0x2a65c451, 0x50940002, 0x133ae4dd,
    +        0x71dff89e, 0x10314e55, 0x81ac77d6, 0x5f11199b, 0x043556f1, 0xd7a3c76b, 0x3c11183b, 0x5924a509,
    +        0xf28fe6ed, 0x97f1fbfa, 0x9ebabf2c, 0x1e153c6e, 0x86e34570, 0xeae96fb1, 0x860e5e0a, 0x5a3e2ab3,
    +        0x771fe71c, 0x4e3d06fa, 0x2965dcb9, 0x99e71d0f, 0x803e89d6, 0x5266c825, 0x2e4cc978, 0x9c10b36a,
    +        0xc6150eba, 0x94e2ea78, 0xa5fc3c53, 0x1e0a2df4, 0xf2f74ea7, 0x361d2b3d, 0x1939260f, 0x19c27960,
    +        0x5223a708, 0xf71312b6, 0xebadfe6e, 0xeac31f66, 0xe3bc4595, 0xa67bc883, 0xb17f37d1, 0x018cff28,
    +        0xc332ddef, 0xbe6c5aa5, 0x65582185, 0x68ab9802, 0xeecea50f, 0xdb2f953b, 0x2aef7dad, 0x5b6e2f84,
    +        0x1521b628, 0x29076170, 0xecdd4775, 0x619f1510, 0x13cca830, 0xeb61bd96, 0x0334fe1e, 0xaa0363cf,
    +        0xb5735c90, 0x4c70a239, 0xd59e9e0b, 0xcbaade14, 0xeecc86bc, 0x60622ca7, 0x9cab5cab, 0xb2f3846e,
    +        0x648b1eaf, 0x19bdf0ca, 0xa02369b9, 0x655abb50, 0x40685a32, 0x3c2ab4b3, 0x319ee9d5, 0xc021b8f7,
    +        0x9b540b19, 0x875fa099, 0x95f7997e, 0x623d7da8, 0xf837889a, 0x97e32d77, 0x11ed935f, 0x16681281,
    +        0x0e358829, 0xc7e61fd6, 0x96dedfa1, 0x7858ba99, 0x57f584a5, 0x1b227263, 0x9b83c3ff, 0x1ac24696,
    +        0xcdb30aeb, 0x532e3054, 0x8fd948e4, 0x6dbc3128, 0x58ebf2ef, 0x34c6ffea, 0xfe28ed61, 0xee7c3c73,
    +        0x5d4a14d9, 0xe864b7e3, 0x42105d14, 0x203e13e0, 0x45eee2b6, 0xa3aaabea, 0xdb6c4f15, 0xfacb4fd0,
    +        0xc742f442, 0xef6abbb5, 0x654f3b1d, 0x41cd2105, 0xd81e799e, 0x86854dc7, 0xe44b476a, 0x3d816250,
    +        0xcf62a1f2, 0x5b8d2646, 0xfc8883a0, 0xc1c7b6a3, 0x7f1524c3, 0x69cb7492, 0x47848a0b, 0x5692b285,
    +        0x095bbf00, 0xad19489d, 0x1462b174, 0x23820e00, 0x58428d2a, 0x0c55f5ea, 0x1dadf43e, 0x233f7061,
    +        0x3372f092, 0x8d937e41, 0xd65fecf1, 0x6c223bdb, 0x7cde3759, 0xcbee7460, 0x4085f2a7, 0xce77326e,
    +        0xa6078084, 0x19f8509e, 0xe8efd855, 0x61d99735, 0xa969a7aa, 0xc50c06c2, 0x5a04abfc, 0x800bcadc,
    +        0x9e447a2e, 0xc3453484, 0xfdd56705, 0x0e1e9ec9, 0xdb73dbd3, 0x105588cd, 0x675fda79, 0xe3674340,
    +        0xc5c43465, 0x713e38d8, 0x3d28f89e, 0xf16dff20, 0x153e21e7, 0x8fb03d4a, 0xe6e39f2b, 0xdb83adf7
    +    );
    +
    +    /**
    +     * S-Box 2
    +     *
    +     * @access private
    +     * @var    array
    +     */
    +    var $sbox2 = array(
    +        0xe93d5a68, 0x948140f7, 0xf64c261c, 0x94692934, 0x411520f7, 0x7602d4f7, 0xbcf46b2e, 0xd4a20068,
    +        0xd4082471, 0x3320f46a, 0x43b7d4b7, 0x500061af, 0x1e39f62e, 0x97244546, 0x14214f74, 0xbf8b8840,
    +        0x4d95fc1d, 0x96b591af, 0x70f4ddd3, 0x66a02f45, 0xbfbc09ec, 0x03bd9785, 0x7fac6dd0, 0x31cb8504,
    +        0x96eb27b3, 0x55fd3941, 0xda2547e6, 0xabca0a9a, 0x28507825, 0x530429f4, 0x0a2c86da, 0xe9b66dfb,
    +        0x68dc1462, 0xd7486900, 0x680ec0a4, 0x27a18dee, 0x4f3ffea2, 0xe887ad8c, 0xb58ce006, 0x7af4d6b6,
    +        0xaace1e7c, 0xd3375fec, 0xce78a399, 0x406b2a42, 0x20fe9e35, 0xd9f385b9, 0xee39d7ab, 0x3b124e8b,
    +        0x1dc9faf7, 0x4b6d1856, 0x26a36631, 0xeae397b2, 0x3a6efa74, 0xdd5b4332, 0x6841e7f7, 0xca7820fb,
    +        0xfb0af54e, 0xd8feb397, 0x454056ac, 0xba489527, 0x55533a3a, 0x20838d87, 0xfe6ba9b7, 0xd096954b,
    +        0x55a867bc, 0xa1159a58, 0xcca92963, 0x99e1db33, 0xa62a4a56, 0x3f3125f9, 0x5ef47e1c, 0x9029317c,
    +        0xfdf8e802, 0x04272f70, 0x80bb155c, 0x05282ce3, 0x95c11548, 0xe4c66d22, 0x48c1133f, 0xc70f86dc,
    +        0x07f9c9ee, 0x41041f0f, 0x404779a4, 0x5d886e17, 0x325f51eb, 0xd59bc0d1, 0xf2bcc18f, 0x41113564,
    +        0x257b7834, 0x602a9c60, 0xdff8e8a3, 0x1f636c1b, 0x0e12b4c2, 0x02e1329e, 0xaf664fd1, 0xcad18115,
    +        0x6b2395e0, 0x333e92e1, 0x3b240b62, 0xeebeb922, 0x85b2a20e, 0xe6ba0d99, 0xde720c8c, 0x2da2f728,
    +        0xd0127845, 0x95b794fd, 0x647d0862, 0xe7ccf5f0, 0x5449a36f, 0x877d48fa, 0xc39dfd27, 0xf33e8d1e,
    +        0x0a476341, 0x992eff74, 0x3a6f6eab, 0xf4f8fd37, 0xa812dc60, 0xa1ebddf8, 0x991be14c, 0xdb6e6b0d,
    +        0xc67b5510, 0x6d672c37, 0x2765d43b, 0xdcd0e804, 0xf1290dc7, 0xcc00ffa3, 0xb5390f92, 0x690fed0b,
    +        0x667b9ffb, 0xcedb7d9c, 0xa091cf0b, 0xd9155ea3, 0xbb132f88, 0x515bad24, 0x7b9479bf, 0x763bd6eb,
    +        0x37392eb3, 0xcc115979, 0x8026e297, 0xf42e312d, 0x6842ada7, 0xc66a2b3b, 0x12754ccc, 0x782ef11c,
    +        0x6a124237, 0xb79251e7, 0x06a1bbe6, 0x4bfb6350, 0x1a6b1018, 0x11caedfa, 0x3d25bdd8, 0xe2e1c3c9,
    +        0x44421659, 0x0a121386, 0xd90cec6e, 0xd5abea2a, 0x64af674e, 0xda86a85f, 0xbebfe988, 0x64e4c3fe,
    +        0x9dbc8057, 0xf0f7c086, 0x60787bf8, 0x6003604d, 0xd1fd8346, 0xf6381fb0, 0x7745ae04, 0xd736fccc,
    +        0x83426b33, 0xf01eab71, 0xb0804187, 0x3c005e5f, 0x77a057be, 0xbde8ae24, 0x55464299, 0xbf582e61,
    +        0x4e58f48f, 0xf2ddfda2, 0xf474ef38, 0x8789bdc2, 0x5366f9c3, 0xc8b38e74, 0xb475f255, 0x46fcd9b9,
    +        0x7aeb2661, 0x8b1ddf84, 0x846a0e79, 0x915f95e2, 0x466e598e, 0x20b45770, 0x8cd55591, 0xc902de4c,
    +        0xb90bace1, 0xbb8205d0, 0x11a86248, 0x7574a99e, 0xb77f19b6, 0xe0a9dc09, 0x662d09a1, 0xc4324633,
    +        0xe85a1f02, 0x09f0be8c, 0x4a99a025, 0x1d6efe10, 0x1ab93d1d, 0x0ba5a4df, 0xa186f20f, 0x2868f169,
    +        0xdcb7da83, 0x573906fe, 0xa1e2ce9b, 0x4fcd7f52, 0x50115e01, 0xa70683fa, 0xa002b5c4, 0x0de6d027,
    +        0x9af88c27, 0x773f8641, 0xc3604c06, 0x61a806b5, 0xf0177a28, 0xc0f586e0, 0x006058aa, 0x30dc7d62,
    +        0x11e69ed7, 0x2338ea63, 0x53c2dd94, 0xc2c21634, 0xbbcbee56, 0x90bcb6de, 0xebfc7da1, 0xce591d76,
    +        0x6f05e409, 0x4b7c0188, 0x39720a3d, 0x7c927c24, 0x86e3725f, 0x724d9db9, 0x1ac15bb4, 0xd39eb8fc,
    +        0xed545578, 0x08fca5b5, 0xd83d7cd3, 0x4dad0fc4, 0x1e50ef5e, 0xb161e6f8, 0xa28514d9, 0x6c51133c,
    +        0x6fd5c7e7, 0x56e14ec4, 0x362abfce, 0xddc6c837, 0xd79a3234, 0x92638212, 0x670efa8e, 0x406000e0
    +    );
    +
    +    /**
    +     * S-Box 3
    +     *
    +     * @access private
    +     * @var    array
    +     */
    +    var $sbox3 = array(
    +        0x3a39ce37, 0xd3faf5cf, 0xabc27737, 0x5ac52d1b, 0x5cb0679e, 0x4fa33742, 0xd3822740, 0x99bc9bbe,
    +        0xd5118e9d, 0xbf0f7315, 0xd62d1c7e, 0xc700c47b, 0xb78c1b6b, 0x21a19045, 0xb26eb1be, 0x6a366eb4,
    +        0x5748ab2f, 0xbc946e79, 0xc6a376d2, 0x6549c2c8, 0x530ff8ee, 0x468dde7d, 0xd5730a1d, 0x4cd04dc6,
    +        0x2939bbdb, 0xa9ba4650, 0xac9526e8, 0xbe5ee304, 0xa1fad5f0, 0x6a2d519a, 0x63ef8ce2, 0x9a86ee22,
    +        0xc089c2b8, 0x43242ef6, 0xa51e03aa, 0x9cf2d0a4, 0x83c061ba, 0x9be96a4d, 0x8fe51550, 0xba645bd6,
    +        0x2826a2f9, 0xa73a3ae1, 0x4ba99586, 0xef5562e9, 0xc72fefd3, 0xf752f7da, 0x3f046f69, 0x77fa0a59,
    +        0x80e4a915, 0x87b08601, 0x9b09e6ad, 0x3b3ee593, 0xe990fd5a, 0x9e34d797, 0x2cf0b7d9, 0x022b8b51,
    +        0x96d5ac3a, 0x017da67d, 0xd1cf3ed6, 0x7c7d2d28, 0x1f9f25cf, 0xadf2b89b, 0x5ad6b472, 0x5a88f54c,
    +        0xe029ac71, 0xe019a5e6, 0x47b0acfd, 0xed93fa9b, 0xe8d3c48d, 0x283b57cc, 0xf8d56629, 0x79132e28,
    +        0x785f0191, 0xed756055, 0xf7960e44, 0xe3d35e8c, 0x15056dd4, 0x88f46dba, 0x03a16125, 0x0564f0bd,
    +        0xc3eb9e15, 0x3c9057a2, 0x97271aec, 0xa93a072a, 0x1b3f6d9b, 0x1e6321f5, 0xf59c66fb, 0x26dcf319,
    +        0x7533d928, 0xb155fdf5, 0x03563482, 0x8aba3cbb, 0x28517711, 0xc20ad9f8, 0xabcc5167, 0xccad925f,
    +        0x4de81751, 0x3830dc8e, 0x379d5862, 0x9320f991, 0xea7a90c2, 0xfb3e7bce, 0x5121ce64, 0x774fbe32,
    +        0xa8b6e37e, 0xc3293d46, 0x48de5369, 0x6413e680, 0xa2ae0810, 0xdd6db224, 0x69852dfd, 0x09072166,
    +        0xb39a460a, 0x6445c0dd, 0x586cdecf, 0x1c20c8ae, 0x5bbef7dd, 0x1b588d40, 0xccd2017f, 0x6bb4e3bb,
    +        0xdda26a7e, 0x3a59ff45, 0x3e350a44, 0xbcb4cdd5, 0x72eacea8, 0xfa6484bb, 0x8d6612ae, 0xbf3c6f47,
    +        0xd29be463, 0x542f5d9e, 0xaec2771b, 0xf64e6370, 0x740e0d8d, 0xe75b1357, 0xf8721671, 0xaf537d5d,
    +        0x4040cb08, 0x4eb4e2cc, 0x34d2466a, 0x0115af84, 0xe1b00428, 0x95983a1d, 0x06b89fb4, 0xce6ea048,
    +        0x6f3f3b82, 0x3520ab82, 0x011a1d4b, 0x277227f8, 0x611560b1, 0xe7933fdc, 0xbb3a792b, 0x344525bd,
    +        0xa08839e1, 0x51ce794b, 0x2f32c9b7, 0xa01fbac9, 0xe01cc87e, 0xbcc7d1f6, 0xcf0111c3, 0xa1e8aac7,
    +        0x1a908749, 0xd44fbd9a, 0xd0dadecb, 0xd50ada38, 0x0339c32a, 0xc6913667, 0x8df9317c, 0xe0b12b4f,
    +        0xf79e59b7, 0x43f5bb3a, 0xf2d519ff, 0x27d9459c, 0xbf97222c, 0x15e6fc2a, 0x0f91fc71, 0x9b941525,
    +        0xfae59361, 0xceb69ceb, 0xc2a86459, 0x12baa8d1, 0xb6c1075e, 0xe3056a0c, 0x10d25065, 0xcb03a442,
    +        0xe0ec6e0e, 0x1698db3b, 0x4c98a0be, 0x3278e964, 0x9f1f9532, 0xe0d392df, 0xd3a0342b, 0x8971f21e,
    +        0x1b0a7441, 0x4ba3348c, 0xc5be7120, 0xc37632d8, 0xdf359f8d, 0x9b992f2e, 0xe60b6f47, 0x0fe3f11d,
    +        0xe54cda54, 0x1edad891, 0xce6279cf, 0xcd3e7e6f, 0x1618b166, 0xfd2c1d05, 0x848fd2c5, 0xf6fb2299,
    +        0xf523f357, 0xa6327623, 0x93a83531, 0x56cccd02, 0xacf08162, 0x5a75ebb5, 0x6e163697, 0x88d273cc,
    +        0xde966292, 0x81b949d0, 0x4c50901b, 0x71c65614, 0xe6c6c7bd, 0x327a140a, 0x45e1d006, 0xc3f27b9a,
    +        0xc9aa53fd, 0x62a80f00, 0xbb25bfe2, 0x35bdd2f6, 0x71126905, 0xb2040222, 0xb6cbcf7c, 0xcd769c2b,
    +        0x53113ec0, 0x1640e3d3, 0x38abbd60, 0x2547adf0, 0xba38209c, 0xf746ce76, 0x77afa1c5, 0x20756060,
    +        0x85cbfe4e, 0x8ae88dd8, 0x7aaaf9b0, 0x4cf9aa7e, 0x1948c25c, 0x02fb8a8c, 0x01c36ae4, 0xd6ebe1f9,
    +        0x90d4f869, 0xa65cdea0, 0x3f09252d, 0xc208e69f, 0xb74e6132, 0xce77e25b, 0x578fdfe3, 0x3ac372e6
    +    );
    +
    +    /**
    +     * P-Array consists of 18 32-bit subkeys
    +     *
    +     * @var array $parray
    +     * @access private
    +     */
    +    var $parray = array(
    +        0x243f6a88, 0x85a308d3, 0x13198a2e, 0x03707344, 0xa4093822, 0x299f31d0,
    +        0x082efa98, 0xec4e6c89, 0x452821e6, 0x38d01377, 0xbe5466cf, 0x34e90c6c,
    +        0xc0ac29b7, 0xc97c50dd, 0x3f84d5b5, 0xb5470917, 0x9216d5d9, 0x8979fb1b
    +    );
    +
    +    /**
    +     * The BCTX-working Array
    +     *
    +     * Holds the expanded key [p] and the key-depended s-boxes [sb]
    +     *
    +     * @var array $bctx
    +     * @access private
    +     */
    +    var $bctx;
    +
    +    /**
    +     * Holds the last used key
    +     *
    +     * @var Array
    +     * @access private
    +     */
    +    var $kl;
    +
    +    /**
    +     * Default Constructor.
    +     *
    +     * Determines whether or not the mcrypt extension should be used.
    +     *
    +     * $mode could be:
    +     *
    +     * - CRYPT_BLOWFISH_MODE_ECB
    +     *
    +     * - CRYPT_BLOWFISH_MODE_CBC
    +     *
    +     * - CRYPT_BLOWFISH_MODE_CTR
    +     *
    +     * - CRYPT_BLOWFISH_MODE_CFB
    +     *
    +     * - CRYPT_BLOWFISH_MODE_OFB
    +     *
    +     * If not explictly set, CRYPT_BLOWFISH_MODE_CBC will be used.
    +     *
    +     * @see Crypt_Base::Crypt_Base()
    +     * @param optional Integer $mode
    +     * @access public
    +     */
    +    function Crypt_Blowfish($mode = CRYPT_BLOWFISH_MODE_CBC)
    +    {
    +        parent::Crypt_Base($mode);
    +    }
    +
    +    /**
    +     * Sets the key.
    +     *
    +     * Keys can be of any length.  Blowfish, itself, requires the use of a key between 32 and max. 448-bits long.
    +     * If the key is less than 32-bits we NOT fill the key to 32bit but let the key as it is to be compatible
    +     * with mcrypt because mcrypt act this way with blowfish key's < 32 bits.
    +     *
    +     * If the key is more than 448-bits, we trim the excess bits.
    +     *
    +     * If the key is not explicitly set, or empty, it'll be assumed a 128 bits key to be all null bytes.
    +     *
    +     * @access public
    +     * @see Crypt_Base::setKey()
    +     * @param String $key
    +     */
    +    function setKey($key)
    +    {
    +        $keylength = strlen($key);
    +
    +        if (!$keylength) {
    +            $key = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0";
    +        } elseif ($keylength > 56) {
    +            $key = substr($key, 0, 56);
    +        }
    +
    +        parent::setKey($key);
    +    }
    +
    +    /**
    +     * Setup the key (expansion)
    +     *
    +     * @see Crypt_Base::_setupKey()
    +     * @access private
    +     */
    +    function _setupKey()
    +    {
    +        if (isset($this->kl['key']) && $this->key === $this->kl['key']) {
    +            // already expanded
    +            return;
    +        }
    +        $this->kl = array('key' => $this->key);
    +
    +        /* key-expanding p[] and S-Box building sb[] */
    +        $this->bctx = array(
    +            'p'  => array(),
    +            'sb' => array(
    +                $this->sbox0,
    +                $this->sbox1,
    +                $this->sbox2,
    +                $this->sbox3
    +            )
    +        );
    +
    +        // unpack binary string in unsigned chars
    +        $key  = array_values(unpack('C*', $this->key));
    +        $keyl = count($key);
    +        for ($j = 0, $i = 0; $i < 18; ++$i) {
    +            // xor P1 with the first 32-bits of the key, xor P2 with the second 32-bits ...
    +            for ($data = 0, $k = 0; $k < 4; ++$k) {
    +                $data = ($data << 8) | $key[$j];
    +                if (++$j >= $keyl) {
    +                    $j = 0;
    +                }
    +            }
    +            $this->bctx['p'][] = $this->parray[$i] ^ $data;
    +        }
    +
    +        // encrypt the zero-string, replace P1 and P2 with the encrypted data,
    +        // encrypt P3 and P4 with the new P1 and P2, do it with all P-array and subkeys
    +        $data = "\0\0\0\0\0\0\0\0";
    +        for ($i = 0; $i < 18; $i += 2) {
    +            list($l, $r) = array_values(unpack('N*', $data = $this->_encryptBlock($data)));
    +            $this->bctx['p'][$i    ] = $l;
    +            $this->bctx['p'][$i + 1] = $r;
    +        }
    +        for ($i = 0; $i < 4; ++$i) {
    +            for ($j = 0; $j < 256; $j += 2) {
    +                list($l, $r) = array_values(unpack('N*', $data = $this->_encryptBlock($data)));
    +                $this->bctx['sb'][$i][$j    ] = $l;
    +                $this->bctx['sb'][$i][$j + 1] = $r;
    +            }
    +        }
    +    }
    +
    +    /**
    +     * Encrypts a block
    +     *
    +     * @access private
    +     * @param String $in
    +     * @return String
    +     */
    +    function _encryptBlock($in)
    +    {
    +        $p = $this->bctx["p"];
    +        // extract($this->bctx["sb"], EXTR_PREFIX_ALL, "sb"); // slower
    +        $sb_0 = $this->bctx["sb"][0];
    +        $sb_1 = $this->bctx["sb"][1];
    +        $sb_2 = $this->bctx["sb"][2];
    +        $sb_3 = $this->bctx["sb"][3];
    +
    +        $in = unpack("N*", $in);
    +        $l = $in[1];
    +        $r = $in[2];
    +
    +        for ($i = 0; $i < 16; $i+= 2) {
    +                $l^= $p[$i];
    +                $r^= ($sb_0[$l >> 24 & 0xff]  +
    +                      $sb_1[$l >> 16 & 0xff]  ^
    +                      $sb_2[$l >>  8 & 0xff]) +
    +                      $sb_3[$l       & 0xff];
    +
    +                $r^= $p[$i + 1];
    +                $l^= ($sb_0[$r >> 24 & 0xff]  +
    +                      $sb_1[$r >> 16 & 0xff]  ^
    +                      $sb_2[$r >>  8 & 0xff]) +
    +                      $sb_3[$r       & 0xff];
    +        }
    +        return pack("N*", $r ^ $p[17], $l ^ $p[16]);
    +    }
    +
    +    /**
    +     * Decrypts a block
    +     *
    +     * @access private
    +     * @param String $in
    +     * @return String
    +     */
    +    function _decryptBlock($in)
    +    {
    +        $p = $this->bctx["p"];
    +        $sb_0 = $this->bctx["sb"][0];
    +        $sb_1 = $this->bctx["sb"][1];
    +        $sb_2 = $this->bctx["sb"][2];
    +        $sb_3 = $this->bctx["sb"][3];
    +
    +        $in = unpack("N*", $in);
    +        $l = $in[1];
    +        $r = $in[2];
    +
    +        for ($i = 17; $i > 2; $i-= 2) {
    +            $l^= $p[$i];
    +            $r^= ($sb_0[$l >> 24 & 0xff]  +
    +                  $sb_1[$l >> 16 & 0xff]  ^
    +                  $sb_2[$l >>  8 & 0xff]) +
    +                  $sb_3[$l       & 0xff];
    +
    +            $r^= $p[$i - 1];
    +            $l^= ($sb_0[$r >> 24 & 0xff]  +
    +                  $sb_1[$r >> 16 & 0xff]  ^
    +                  $sb_2[$r >>  8 & 0xff]) +
    +                  $sb_3[$r       & 0xff];
    +        }
    +
    +        return pack("N*", $r ^ $p[0], $l ^ $p[1]);
    +    }
    +
    +    /**
    +     * Setup the performance-optimized function for de/encrypt()
    +     *
    +     * @see Crypt_Base::_setupInlineCrypt()
    +     * @access private
    +     */
    +    function _setupInlineCrypt()
    +    {
    +        $lambda_functions =& Crypt_Blowfish::_getLambdaFunctions();
    +
    +        // We create max. 10 hi-optimized code for memory reason. Means: For each $key one ultra fast inline-crypt function.
    +        // After that, we'll still create very fast optimized code but not the hi-ultimative code, for each $mode one.
    +        $gen_hi_opt_code = (bool)( count($lambda_functions) < 10);
    +
    +        switch (true) {
    +            case $gen_hi_opt_code:
    +                $code_hash = md5(str_pad("Crypt_Blowfish, {$this->mode}, ", 32, "\0") . $this->key);
    +                break;
    +            default:
    +                $code_hash = "Crypt_Blowfish, {$this->mode}";
    +        }
    +
    +        if (!isset($lambda_functions[$code_hash])) {
    +            switch (true) {
    +                case $gen_hi_opt_code:
    +                    $p = $this->bctx['p'];
    +                    $init_crypt = '
    +                        static $sb_0, $sb_1, $sb_2, $sb_3;
    +                        if (!$sb_0) {
    +                            $sb_0 = $self->bctx["sb"][0];
    +                            $sb_1 = $self->bctx["sb"][1];
    +                            $sb_2 = $self->bctx["sb"][2];
    +                            $sb_3 = $self->bctx["sb"][3];
    +                        }
    +                    ';
    +                    break;
    +                default:
    +                    $p   = array();
    +                    for ($i = 0; $i < 18; ++$i) {
    +                        $p[] = '$p_' . $i;
    +                    }
    +                    $init_crypt = '
    +                        list($sb_0, $sb_1, $sb_2, $sb_3) = $self->bctx["sb"];
    +                        list(' . implode(',', $p) . ') = $self->bctx["p"];
    +
    +                    ';
    +            }
    +
    +            // Generating encrypt code:
    +            $encrypt_block = '
    +                $in = unpack("N*", $in);
    +                $l = $in[1];
    +                $r = $in[2];
    +            ';
    +            for ($i = 0; $i < 16; $i+= 2) {
    +                $encrypt_block.= '
    +                    $l^= ' . $p[$i] . ';
    +                    $r^= ($sb_0[$l >> 24 & 0xff]  +
    +                          $sb_1[$l >> 16 & 0xff]  ^
    +                          $sb_2[$l >>  8 & 0xff]) +
    +                          $sb_3[$l       & 0xff];
    +
    +                    $r^= ' . $p[$i + 1] . ';
    +                    $l^= ($sb_0[$r >> 24 & 0xff]  +
    +                          $sb_1[$r >> 16 & 0xff]  ^
    +                          $sb_2[$r >>  8 & 0xff]) +
    +                          $sb_3[$r       & 0xff];
    +                ';
    +            }
    +            $encrypt_block.= '
    +                $in = pack("N*",
    +                    $r ^ ' . $p[17] . ',
    +                    $l ^ ' . $p[16] . '
    +                );
    +            ';
    +
    +            // Generating decrypt code:
    +            $decrypt_block = '
    +                $in = unpack("N*", $in);
    +                $l = $in[1];
    +                $r = $in[2];
    +            ';
    +
    +            for ($i = 17; $i > 2; $i-= 2) {
    +                $decrypt_block.= '
    +                    $l^= ' . $p[$i] . ';
    +                    $r^= ($sb_0[$l >> 24 & 0xff]  +
    +                          $sb_1[$l >> 16 & 0xff]  ^
    +                          $sb_2[$l >>  8 & 0xff]) +
    +                          $sb_3[$l       & 0xff];
    +
    +                    $r^= ' . $p[$i - 1] . ';
    +                    $l^= ($sb_0[$r >> 24 & 0xff]  +
    +                          $sb_1[$r >> 16 & 0xff]  ^
    +                          $sb_2[$r >>  8 & 0xff]) +
    +                          $sb_3[$r       & 0xff];
    +                ';
    +            }
    +
    +            $decrypt_block.= '
    +                $in = pack("N*",
    +                    $r ^ ' . $p[0] . ',
    +                    $l ^ ' . $p[1] . '
    +                );
    +            ';
    +
    +            $lambda_functions[$code_hash] = $this->_createInlineCryptFunction(
    +                array(
    +                   'init_crypt'    => $init_crypt,
    +                   'init_encrypt'  => '',
    +                   'init_decrypt'  => '',
    +                   'encrypt_block' => $encrypt_block,
    +                   'decrypt_block' => $decrypt_block
    +                )
    +            );
    +        }
    +        $this->inline_crypt = $lambda_functions[$code_hash];
    +    }
    +}
    diff --git a/vendor/phpseclib/phpseclib/phpseclib/Crypt/DES.php b/vendor/phpseclib/phpseclib/phpseclib/Crypt/DES.php
    new file mode 100755
    index 0000000..fcbf019
    --- /dev/null
    +++ b/vendor/phpseclib/phpseclib/phpseclib/Crypt/DES.php
    @@ -0,0 +1,1535 @@
    +
    + * setKey('abcdefgh');
    + *
    + *    $size = 10 * 1024;
    + *    $plaintext = '';
    + *    for ($i = 0; $i < $size; $i++) {
    + *        $plaintext.= 'a';
    + *    }
    + *
    + *    echo $des->decrypt($des->encrypt($plaintext));
    + * ?>
    + * 
    + *
    + * LICENSE: Permission is hereby granted, free of charge, to any person obtaining a copy
    + * of this software and associated documentation files (the "Software"), to deal
    + * in the Software without restriction, including without limitation the rights
    + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    + * copies of the Software, and to permit persons to whom the Software is
    + * furnished to do so, subject to the following conditions:
    + *
    + * The above copyright notice and this permission notice shall be included in
    + * all copies or substantial portions of the Software.
    + *
    + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
    + * THE SOFTWARE.
    + *
    + * @category  Crypt
    + * @package   Crypt_DES
    + * @author    Jim Wigginton 
    + * @copyright MMVII Jim Wigginton
    + * @license   http://www.opensource.org/licenses/mit-license.html  MIT License
    + * @link      http://phpseclib.sourceforge.net
    + */
    +
    +/**
    + * Include Crypt_Base
    + *
    + * Base cipher class
    + */
    +if (!class_exists('Crypt_Base')) {
    +    include_once 'Base.php';
    +}
    +
    +/**#@+
    + * @access private
    + * @see Crypt_DES::_setupKey()
    + * @see Crypt_DES::_processBlock()
    + */
    +/**
    + * Contains $keys[CRYPT_DES_ENCRYPT]
    + */
    +define('CRYPT_DES_ENCRYPT', 0);
    +/**
    + * Contains $keys[CRYPT_DES_DECRYPT]
    + */
    +define('CRYPT_DES_DECRYPT', 1);
    +/**#@-*/
    +
    +/**#@+
    + * @access public
    + * @see Crypt_DES::encrypt()
    + * @see Crypt_DES::decrypt()
    + */
    +/**
    + * Encrypt / decrypt using the Counter mode.
    + *
    + * Set to -1 since that's what Crypt/Random.php uses to index the CTR mode.
    + *
    + * @link http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation#Counter_.28CTR.29
    + */
    +define('CRYPT_DES_MODE_CTR', CRYPT_MODE_CTR);
    +/**
    + * Encrypt / decrypt using the Electronic Code Book mode.
    + *
    + * @link http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation#Electronic_codebook_.28ECB.29
    + */
    +define('CRYPT_DES_MODE_ECB', CRYPT_MODE_ECB);
    +/**
    + * Encrypt / decrypt using the Code Book Chaining mode.
    + *
    + * @link http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation#Cipher-block_chaining_.28CBC.29
    + */
    +define('CRYPT_DES_MODE_CBC', CRYPT_MODE_CBC);
    +/**
    + * Encrypt / decrypt using the Cipher Feedback mode.
    + *
    + * @link http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation#Cipher_feedback_.28CFB.29
    + */
    +define('CRYPT_DES_MODE_CFB', CRYPT_MODE_CFB);
    +/**
    + * Encrypt / decrypt using the Cipher Feedback mode.
    + *
    + * @link http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation#Output_feedback_.28OFB.29
    + */
    +define('CRYPT_DES_MODE_OFB', CRYPT_MODE_OFB);
    +/**#@-*/
    +
    +/**#@+
    + * @access private
    + * @see Crypt_DES::Crypt_DES()
    + */
    +/**
    + * Toggles the internal implementation
    + */
    +define('CRYPT_DES_MODE_INTERNAL', CRYPT_MODE_INTERNAL);
    +/**
    + * Toggles the mcrypt implementation
    + */
    +define('CRYPT_DES_MODE_MCRYPT', CRYPT_MODE_MCRYPT);
    +/**#@-*/
    +
    +/**
    + * Pure-PHP implementation of DES.
    + *
    + * @package Crypt_DES
    + * @author  Jim Wigginton 
    + * @version 0.1.0
    + * @access  public
    + */
    +class Crypt_DES extends Crypt_Base
    +{
    +    /**
    +     * Block Length of the cipher
    +     *
    +     * @see Crypt_Base::block_size
    +     * @var Integer
    +     * @access private
    +     */
    +    var $block_size = 8;
    +
    +    /**
    +     * The Key
    +     *
    +     * @see Crypt_Base::key
    +     * @see setKey()
    +     * @var String
    +     * @access private
    +     */
    +    var $key = "\0\0\0\0\0\0\0\0";
    +
    +    /**
    +     * The default password key_size used by setPassword()
    +     *
    +     * @see Crypt_Base::password_key_size
    +     * @see Crypt_Base::setPassword()
    +     * @var Integer
    +     * @access private
    +     */
    +    var $password_key_size = 8;
    +
    +    /**
    +     * The namespace used by the cipher for its constants.
    +     *
    +     * @see Crypt_Base::const_namespace
    +     * @var String
    +     * @access private
    +     */
    +    var $const_namespace = 'DES';
    +
    +    /**
    +     * The mcrypt specific name of the cipher
    +     *
    +     * @see Crypt_Base::cipher_name_mcrypt
    +     * @var String
    +     * @access private
    +     */
    +    var $cipher_name_mcrypt = 'des';
    +
    +    /**
    +     * Optimizing value while CFB-encrypting
    +     *
    +     * @see Crypt_Base::cfb_init_len
    +     * @var Integer
    +     * @access private
    +     */
    +    var $cfb_init_len = 500;
    +
    +    /**
    +     * Switch for DES/3DES encryption
    +     *
    +     * Used only if $engine == CRYPT_DES_MODE_INTERNAL
    +     *
    +     * @see Crypt_DES::_setupKey()
    +     * @see Crypt_DES::_processBlock()
    +     * @var Integer
    +     * @access private
    +     */
    +    var $des_rounds = 1;
    +
    +    /**
    +     * max possible size of $key
    +     *
    +     * @see Crypt_DES::setKey()
    +     * @var String
    +     * @access private
    +     */
    +    var $key_size_max = 8;
    +
    +    /**
    +     * The Key Schedule
    +     *
    +     * @see Crypt_DES::_setupKey()
    +     * @var Array
    +     * @access private
    +     */
    +    var $keys;
    +
    +    /**
    +     * Shuffle table.
    +     *
    +     * For each byte value index, the entry holds an 8-byte string
    +     * with each byte containing all bits in the same state as the
    +     * corresponding bit in the index value.
    +     *
    +     * @see Crypt_DES::_processBlock()
    +     * @see Crypt_DES::_setupKey()
    +     * @var Array
    +     * @access private
    +     */
    +    var $shuffle = array(
    +        "\x00\x00\x00\x00\x00\x00\x00\x00", "\x00\x00\x00\x00\x00\x00\x00\xFF",
    +        "\x00\x00\x00\x00\x00\x00\xFF\x00", "\x00\x00\x00\x00\x00\x00\xFF\xFF",
    +        "\x00\x00\x00\x00\x00\xFF\x00\x00", "\x00\x00\x00\x00\x00\xFF\x00\xFF",
    +        "\x00\x00\x00\x00\x00\xFF\xFF\x00", "\x00\x00\x00\x00\x00\xFF\xFF\xFF",
    +        "\x00\x00\x00\x00\xFF\x00\x00\x00", "\x00\x00\x00\x00\xFF\x00\x00\xFF",
    +        "\x00\x00\x00\x00\xFF\x00\xFF\x00", "\x00\x00\x00\x00\xFF\x00\xFF\xFF",
    +        "\x00\x00\x00\x00\xFF\xFF\x00\x00", "\x00\x00\x00\x00\xFF\xFF\x00\xFF",
    +        "\x00\x00\x00\x00\xFF\xFF\xFF\x00", "\x00\x00\x00\x00\xFF\xFF\xFF\xFF",
    +        "\x00\x00\x00\xFF\x00\x00\x00\x00", "\x00\x00\x00\xFF\x00\x00\x00\xFF",
    +        "\x00\x00\x00\xFF\x00\x00\xFF\x00", "\x00\x00\x00\xFF\x00\x00\xFF\xFF",
    +        "\x00\x00\x00\xFF\x00\xFF\x00\x00", "\x00\x00\x00\xFF\x00\xFF\x00\xFF",
    +        "\x00\x00\x00\xFF\x00\xFF\xFF\x00", "\x00\x00\x00\xFF\x00\xFF\xFF\xFF",
    +        "\x00\x00\x00\xFF\xFF\x00\x00\x00", "\x00\x00\x00\xFF\xFF\x00\x00\xFF",
    +        "\x00\x00\x00\xFF\xFF\x00\xFF\x00", "\x00\x00\x00\xFF\xFF\x00\xFF\xFF",
    +        "\x00\x00\x00\xFF\xFF\xFF\x00\x00", "\x00\x00\x00\xFF\xFF\xFF\x00\xFF",
    +        "\x00\x00\x00\xFF\xFF\xFF\xFF\x00", "\x00\x00\x00\xFF\xFF\xFF\xFF\xFF",
    +        "\x00\x00\xFF\x00\x00\x00\x00\x00", "\x00\x00\xFF\x00\x00\x00\x00\xFF",
    +        "\x00\x00\xFF\x00\x00\x00\xFF\x00", "\x00\x00\xFF\x00\x00\x00\xFF\xFF",
    +        "\x00\x00\xFF\x00\x00\xFF\x00\x00", "\x00\x00\xFF\x00\x00\xFF\x00\xFF",
    +        "\x00\x00\xFF\x00\x00\xFF\xFF\x00", "\x00\x00\xFF\x00\x00\xFF\xFF\xFF",
    +        "\x00\x00\xFF\x00\xFF\x00\x00\x00", "\x00\x00\xFF\x00\xFF\x00\x00\xFF",
    +        "\x00\x00\xFF\x00\xFF\x00\xFF\x00", "\x00\x00\xFF\x00\xFF\x00\xFF\xFF",
    +        "\x00\x00\xFF\x00\xFF\xFF\x00\x00", "\x00\x00\xFF\x00\xFF\xFF\x00\xFF",
    +        "\x00\x00\xFF\x00\xFF\xFF\xFF\x00", "\x00\x00\xFF\x00\xFF\xFF\xFF\xFF",
    +        "\x00\x00\xFF\xFF\x00\x00\x00\x00", "\x00\x00\xFF\xFF\x00\x00\x00\xFF",
    +        "\x00\x00\xFF\xFF\x00\x00\xFF\x00", "\x00\x00\xFF\xFF\x00\x00\xFF\xFF",
    +        "\x00\x00\xFF\xFF\x00\xFF\x00\x00", "\x00\x00\xFF\xFF\x00\xFF\x00\xFF",
    +        "\x00\x00\xFF\xFF\x00\xFF\xFF\x00", "\x00\x00\xFF\xFF\x00\xFF\xFF\xFF",
    +        "\x00\x00\xFF\xFF\xFF\x00\x00\x00", "\x00\x00\xFF\xFF\xFF\x00\x00\xFF",
    +        "\x00\x00\xFF\xFF\xFF\x00\xFF\x00", "\x00\x00\xFF\xFF\xFF\x00\xFF\xFF",
    +        "\x00\x00\xFF\xFF\xFF\xFF\x00\x00", "\x00\x00\xFF\xFF\xFF\xFF\x00\xFF",
    +        "\x00\x00\xFF\xFF\xFF\xFF\xFF\x00", "\x00\x00\xFF\xFF\xFF\xFF\xFF\xFF",
    +        "\x00\xFF\x00\x00\x00\x00\x00\x00", "\x00\xFF\x00\x00\x00\x00\x00\xFF",
    +        "\x00\xFF\x00\x00\x00\x00\xFF\x00", "\x00\xFF\x00\x00\x00\x00\xFF\xFF",
    +        "\x00\xFF\x00\x00\x00\xFF\x00\x00", "\x00\xFF\x00\x00\x00\xFF\x00\xFF",
    +        "\x00\xFF\x00\x00\x00\xFF\xFF\x00", "\x00\xFF\x00\x00\x00\xFF\xFF\xFF",
    +        "\x00\xFF\x00\x00\xFF\x00\x00\x00", "\x00\xFF\x00\x00\xFF\x00\x00\xFF",
    +        "\x00\xFF\x00\x00\xFF\x00\xFF\x00", "\x00\xFF\x00\x00\xFF\x00\xFF\xFF",
    +        "\x00\xFF\x00\x00\xFF\xFF\x00\x00", "\x00\xFF\x00\x00\xFF\xFF\x00\xFF",
    +        "\x00\xFF\x00\x00\xFF\xFF\xFF\x00", "\x00\xFF\x00\x00\xFF\xFF\xFF\xFF",
    +        "\x00\xFF\x00\xFF\x00\x00\x00\x00", "\x00\xFF\x00\xFF\x00\x00\x00\xFF",
    +        "\x00\xFF\x00\xFF\x00\x00\xFF\x00", "\x00\xFF\x00\xFF\x00\x00\xFF\xFF",
    +        "\x00\xFF\x00\xFF\x00\xFF\x00\x00", "\x00\xFF\x00\xFF\x00\xFF\x00\xFF",
    +        "\x00\xFF\x00\xFF\x00\xFF\xFF\x00", "\x00\xFF\x00\xFF\x00\xFF\xFF\xFF",
    +        "\x00\xFF\x00\xFF\xFF\x00\x00\x00", "\x00\xFF\x00\xFF\xFF\x00\x00\xFF",
    +        "\x00\xFF\x00\xFF\xFF\x00\xFF\x00", "\x00\xFF\x00\xFF\xFF\x00\xFF\xFF",
    +        "\x00\xFF\x00\xFF\xFF\xFF\x00\x00", "\x00\xFF\x00\xFF\xFF\xFF\x00\xFF",
    +        "\x00\xFF\x00\xFF\xFF\xFF\xFF\x00", "\x00\xFF\x00\xFF\xFF\xFF\xFF\xFF",
    +        "\x00\xFF\xFF\x00\x00\x00\x00\x00", "\x00\xFF\xFF\x00\x00\x00\x00\xFF",
    +        "\x00\xFF\xFF\x00\x00\x00\xFF\x00", "\x00\xFF\xFF\x00\x00\x00\xFF\xFF",
    +        "\x00\xFF\xFF\x00\x00\xFF\x00\x00", "\x00\xFF\xFF\x00\x00\xFF\x00\xFF",
    +        "\x00\xFF\xFF\x00\x00\xFF\xFF\x00", "\x00\xFF\xFF\x00\x00\xFF\xFF\xFF",
    +        "\x00\xFF\xFF\x00\xFF\x00\x00\x00", "\x00\xFF\xFF\x00\xFF\x00\x00\xFF",
    +        "\x00\xFF\xFF\x00\xFF\x00\xFF\x00", "\x00\xFF\xFF\x00\xFF\x00\xFF\xFF",
    +        "\x00\xFF\xFF\x00\xFF\xFF\x00\x00", "\x00\xFF\xFF\x00\xFF\xFF\x00\xFF",
    +        "\x00\xFF\xFF\x00\xFF\xFF\xFF\x00", "\x00\xFF\xFF\x00\xFF\xFF\xFF\xFF",
    +        "\x00\xFF\xFF\xFF\x00\x00\x00\x00", "\x00\xFF\xFF\xFF\x00\x00\x00\xFF",
    +        "\x00\xFF\xFF\xFF\x00\x00\xFF\x00", "\x00\xFF\xFF\xFF\x00\x00\xFF\xFF",
    +        "\x00\xFF\xFF\xFF\x00\xFF\x00\x00", "\x00\xFF\xFF\xFF\x00\xFF\x00\xFF",
    +        "\x00\xFF\xFF\xFF\x00\xFF\xFF\x00", "\x00\xFF\xFF\xFF\x00\xFF\xFF\xFF",
    +        "\x00\xFF\xFF\xFF\xFF\x00\x00\x00", "\x00\xFF\xFF\xFF\xFF\x00\x00\xFF",
    +        "\x00\xFF\xFF\xFF\xFF\x00\xFF\x00", "\x00\xFF\xFF\xFF\xFF\x00\xFF\xFF",
    +        "\x00\xFF\xFF\xFF\xFF\xFF\x00\x00", "\x00\xFF\xFF\xFF\xFF\xFF\x00\xFF",
    +        "\x00\xFF\xFF\xFF\xFF\xFF\xFF\x00", "\x00\xFF\xFF\xFF\xFF\xFF\xFF\xFF",
    +        "\xFF\x00\x00\x00\x00\x00\x00\x00", "\xFF\x00\x00\x00\x00\x00\x00\xFF",
    +        "\xFF\x00\x00\x00\x00\x00\xFF\x00", "\xFF\x00\x00\x00\x00\x00\xFF\xFF",
    +        "\xFF\x00\x00\x00\x00\xFF\x00\x00", "\xFF\x00\x00\x00\x00\xFF\x00\xFF",
    +        "\xFF\x00\x00\x00\x00\xFF\xFF\x00", "\xFF\x00\x00\x00\x00\xFF\xFF\xFF",
    +        "\xFF\x00\x00\x00\xFF\x00\x00\x00", "\xFF\x00\x00\x00\xFF\x00\x00\xFF",
    +        "\xFF\x00\x00\x00\xFF\x00\xFF\x00", "\xFF\x00\x00\x00\xFF\x00\xFF\xFF",
    +        "\xFF\x00\x00\x00\xFF\xFF\x00\x00", "\xFF\x00\x00\x00\xFF\xFF\x00\xFF",
    +        "\xFF\x00\x00\x00\xFF\xFF\xFF\x00", "\xFF\x00\x00\x00\xFF\xFF\xFF\xFF",
    +        "\xFF\x00\x00\xFF\x00\x00\x00\x00", "\xFF\x00\x00\xFF\x00\x00\x00\xFF",
    +        "\xFF\x00\x00\xFF\x00\x00\xFF\x00", "\xFF\x00\x00\xFF\x00\x00\xFF\xFF",
    +        "\xFF\x00\x00\xFF\x00\xFF\x00\x00", "\xFF\x00\x00\xFF\x00\xFF\x00\xFF",
    +        "\xFF\x00\x00\xFF\x00\xFF\xFF\x00", "\xFF\x00\x00\xFF\x00\xFF\xFF\xFF",
    +        "\xFF\x00\x00\xFF\xFF\x00\x00\x00", "\xFF\x00\x00\xFF\xFF\x00\x00\xFF",
    +        "\xFF\x00\x00\xFF\xFF\x00\xFF\x00", "\xFF\x00\x00\xFF\xFF\x00\xFF\xFF",
    +        "\xFF\x00\x00\xFF\xFF\xFF\x00\x00", "\xFF\x00\x00\xFF\xFF\xFF\x00\xFF",
    +        "\xFF\x00\x00\xFF\xFF\xFF\xFF\x00", "\xFF\x00\x00\xFF\xFF\xFF\xFF\xFF",
    +        "\xFF\x00\xFF\x00\x00\x00\x00\x00", "\xFF\x00\xFF\x00\x00\x00\x00\xFF",
    +        "\xFF\x00\xFF\x00\x00\x00\xFF\x00", "\xFF\x00\xFF\x00\x00\x00\xFF\xFF",
    +        "\xFF\x00\xFF\x00\x00\xFF\x00\x00", "\xFF\x00\xFF\x00\x00\xFF\x00\xFF",
    +        "\xFF\x00\xFF\x00\x00\xFF\xFF\x00", "\xFF\x00\xFF\x00\x00\xFF\xFF\xFF",
    +        "\xFF\x00\xFF\x00\xFF\x00\x00\x00", "\xFF\x00\xFF\x00\xFF\x00\x00\xFF",
    +        "\xFF\x00\xFF\x00\xFF\x00\xFF\x00", "\xFF\x00\xFF\x00\xFF\x00\xFF\xFF",
    +        "\xFF\x00\xFF\x00\xFF\xFF\x00\x00", "\xFF\x00\xFF\x00\xFF\xFF\x00\xFF",
    +        "\xFF\x00\xFF\x00\xFF\xFF\xFF\x00", "\xFF\x00\xFF\x00\xFF\xFF\xFF\xFF",
    +        "\xFF\x00\xFF\xFF\x00\x00\x00\x00", "\xFF\x00\xFF\xFF\x00\x00\x00\xFF",
    +        "\xFF\x00\xFF\xFF\x00\x00\xFF\x00", "\xFF\x00\xFF\xFF\x00\x00\xFF\xFF",
    +        "\xFF\x00\xFF\xFF\x00\xFF\x00\x00", "\xFF\x00\xFF\xFF\x00\xFF\x00\xFF",
    +        "\xFF\x00\xFF\xFF\x00\xFF\xFF\x00", "\xFF\x00\xFF\xFF\x00\xFF\xFF\xFF",
    +        "\xFF\x00\xFF\xFF\xFF\x00\x00\x00", "\xFF\x00\xFF\xFF\xFF\x00\x00\xFF",
    +        "\xFF\x00\xFF\xFF\xFF\x00\xFF\x00", "\xFF\x00\xFF\xFF\xFF\x00\xFF\xFF",
    +        "\xFF\x00\xFF\xFF\xFF\xFF\x00\x00", "\xFF\x00\xFF\xFF\xFF\xFF\x00\xFF",
    +        "\xFF\x00\xFF\xFF\xFF\xFF\xFF\x00", "\xFF\x00\xFF\xFF\xFF\xFF\xFF\xFF",
    +        "\xFF\xFF\x00\x00\x00\x00\x00\x00", "\xFF\xFF\x00\x00\x00\x00\x00\xFF",
    +        "\xFF\xFF\x00\x00\x00\x00\xFF\x00", "\xFF\xFF\x00\x00\x00\x00\xFF\xFF",
    +        "\xFF\xFF\x00\x00\x00\xFF\x00\x00", "\xFF\xFF\x00\x00\x00\xFF\x00\xFF",
    +        "\xFF\xFF\x00\x00\x00\xFF\xFF\x00", "\xFF\xFF\x00\x00\x00\xFF\xFF\xFF",
    +        "\xFF\xFF\x00\x00\xFF\x00\x00\x00", "\xFF\xFF\x00\x00\xFF\x00\x00\xFF",
    +        "\xFF\xFF\x00\x00\xFF\x00\xFF\x00", "\xFF\xFF\x00\x00\xFF\x00\xFF\xFF",
    +        "\xFF\xFF\x00\x00\xFF\xFF\x00\x00", "\xFF\xFF\x00\x00\xFF\xFF\x00\xFF",
    +        "\xFF\xFF\x00\x00\xFF\xFF\xFF\x00", "\xFF\xFF\x00\x00\xFF\xFF\xFF\xFF",
    +        "\xFF\xFF\x00\xFF\x00\x00\x00\x00", "\xFF\xFF\x00\xFF\x00\x00\x00\xFF",
    +        "\xFF\xFF\x00\xFF\x00\x00\xFF\x00", "\xFF\xFF\x00\xFF\x00\x00\xFF\xFF",
    +        "\xFF\xFF\x00\xFF\x00\xFF\x00\x00", "\xFF\xFF\x00\xFF\x00\xFF\x00\xFF",
    +        "\xFF\xFF\x00\xFF\x00\xFF\xFF\x00", "\xFF\xFF\x00\xFF\x00\xFF\xFF\xFF",
    +        "\xFF\xFF\x00\xFF\xFF\x00\x00\x00", "\xFF\xFF\x00\xFF\xFF\x00\x00\xFF",
    +        "\xFF\xFF\x00\xFF\xFF\x00\xFF\x00", "\xFF\xFF\x00\xFF\xFF\x00\xFF\xFF",
    +        "\xFF\xFF\x00\xFF\xFF\xFF\x00\x00", "\xFF\xFF\x00\xFF\xFF\xFF\x00\xFF",
    +        "\xFF\xFF\x00\xFF\xFF\xFF\xFF\x00", "\xFF\xFF\x00\xFF\xFF\xFF\xFF\xFF",
    +        "\xFF\xFF\xFF\x00\x00\x00\x00\x00", "\xFF\xFF\xFF\x00\x00\x00\x00\xFF",
    +        "\xFF\xFF\xFF\x00\x00\x00\xFF\x00", "\xFF\xFF\xFF\x00\x00\x00\xFF\xFF",
    +        "\xFF\xFF\xFF\x00\x00\xFF\x00\x00", "\xFF\xFF\xFF\x00\x00\xFF\x00\xFF",
    +        "\xFF\xFF\xFF\x00\x00\xFF\xFF\x00", "\xFF\xFF\xFF\x00\x00\xFF\xFF\xFF",
    +        "\xFF\xFF\xFF\x00\xFF\x00\x00\x00", "\xFF\xFF\xFF\x00\xFF\x00\x00\xFF",
    +        "\xFF\xFF\xFF\x00\xFF\x00\xFF\x00", "\xFF\xFF\xFF\x00\xFF\x00\xFF\xFF",
    +        "\xFF\xFF\xFF\x00\xFF\xFF\x00\x00", "\xFF\xFF\xFF\x00\xFF\xFF\x00\xFF",
    +        "\xFF\xFF\xFF\x00\xFF\xFF\xFF\x00", "\xFF\xFF\xFF\x00\xFF\xFF\xFF\xFF",
    +        "\xFF\xFF\xFF\xFF\x00\x00\x00\x00", "\xFF\xFF\xFF\xFF\x00\x00\x00\xFF",
    +        "\xFF\xFF\xFF\xFF\x00\x00\xFF\x00", "\xFF\xFF\xFF\xFF\x00\x00\xFF\xFF",
    +        "\xFF\xFF\xFF\xFF\x00\xFF\x00\x00", "\xFF\xFF\xFF\xFF\x00\xFF\x00\xFF",
    +        "\xFF\xFF\xFF\xFF\x00\xFF\xFF\x00", "\xFF\xFF\xFF\xFF\x00\xFF\xFF\xFF",
    +        "\xFF\xFF\xFF\xFF\xFF\x00\x00\x00", "\xFF\xFF\xFF\xFF\xFF\x00\x00\xFF",
    +        "\xFF\xFF\xFF\xFF\xFF\x00\xFF\x00", "\xFF\xFF\xFF\xFF\xFF\x00\xFF\xFF",
    +        "\xFF\xFF\xFF\xFF\xFF\xFF\x00\x00", "\xFF\xFF\xFF\xFF\xFF\xFF\x00\xFF",
    +        "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\x00", "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF"
    +    );
    +
    +    /**
    +     * IP mapping helper table.
    +     *
    +     * Indexing this table with each source byte performs the initial bit permutation.
    +     *
    +     * @var Array
    +     * @access private
    +     */
    +    var $ipmap = array(
    +        0x00, 0x10, 0x01, 0x11, 0x20, 0x30, 0x21, 0x31,
    +        0x02, 0x12, 0x03, 0x13, 0x22, 0x32, 0x23, 0x33,
    +        0x40, 0x50, 0x41, 0x51, 0x60, 0x70, 0x61, 0x71,
    +        0x42, 0x52, 0x43, 0x53, 0x62, 0x72, 0x63, 0x73,
    +        0x04, 0x14, 0x05, 0x15, 0x24, 0x34, 0x25, 0x35,
    +        0x06, 0x16, 0x07, 0x17, 0x26, 0x36, 0x27, 0x37,
    +        0x44, 0x54, 0x45, 0x55, 0x64, 0x74, 0x65, 0x75,
    +        0x46, 0x56, 0x47, 0x57, 0x66, 0x76, 0x67, 0x77,
    +        0x80, 0x90, 0x81, 0x91, 0xA0, 0xB0, 0xA1, 0xB1,
    +        0x82, 0x92, 0x83, 0x93, 0xA2, 0xB2, 0xA3, 0xB3,
    +        0xC0, 0xD0, 0xC1, 0xD1, 0xE0, 0xF0, 0xE1, 0xF1,
    +        0xC2, 0xD2, 0xC3, 0xD3, 0xE2, 0xF2, 0xE3, 0xF3,
    +        0x84, 0x94, 0x85, 0x95, 0xA4, 0xB4, 0xA5, 0xB5,
    +        0x86, 0x96, 0x87, 0x97, 0xA6, 0xB6, 0xA7, 0xB7,
    +        0xC4, 0xD4, 0xC5, 0xD5, 0xE4, 0xF4, 0xE5, 0xF5,
    +        0xC6, 0xD6, 0xC7, 0xD7, 0xE6, 0xF6, 0xE7, 0xF7,
    +        0x08, 0x18, 0x09, 0x19, 0x28, 0x38, 0x29, 0x39,
    +        0x0A, 0x1A, 0x0B, 0x1B, 0x2A, 0x3A, 0x2B, 0x3B,
    +        0x48, 0x58, 0x49, 0x59, 0x68, 0x78, 0x69, 0x79,
    +        0x4A, 0x5A, 0x4B, 0x5B, 0x6A, 0x7A, 0x6B, 0x7B,
    +        0x0C, 0x1C, 0x0D, 0x1D, 0x2C, 0x3C, 0x2D, 0x3D,
    +        0x0E, 0x1E, 0x0F, 0x1F, 0x2E, 0x3E, 0x2F, 0x3F,
    +        0x4C, 0x5C, 0x4D, 0x5D, 0x6C, 0x7C, 0x6D, 0x7D,
    +        0x4E, 0x5E, 0x4F, 0x5F, 0x6E, 0x7E, 0x6F, 0x7F,
    +        0x88, 0x98, 0x89, 0x99, 0xA8, 0xB8, 0xA9, 0xB9,
    +        0x8A, 0x9A, 0x8B, 0x9B, 0xAA, 0xBA, 0xAB, 0xBB,
    +        0xC8, 0xD8, 0xC9, 0xD9, 0xE8, 0xF8, 0xE9, 0xF9,
    +        0xCA, 0xDA, 0xCB, 0xDB, 0xEA, 0xFA, 0xEB, 0xFB,
    +        0x8C, 0x9C, 0x8D, 0x9D, 0xAC, 0xBC, 0xAD, 0xBD,
    +        0x8E, 0x9E, 0x8F, 0x9F, 0xAE, 0xBE, 0xAF, 0xBF,
    +        0xCC, 0xDC, 0xCD, 0xDD, 0xEC, 0xFC, 0xED, 0xFD,
    +        0xCE, 0xDE, 0xCF, 0xDF, 0xEE, 0xFE, 0xEF, 0xFF
    +    );
    +
    +    /**
    +     * Inverse IP mapping helper table.
    +     * Indexing this table with a byte value reverses the bit order.
    +     *
    +     * @var Array
    +     * @access private
    +     */
    +    var $invipmap = array(
    +        0x00, 0x80, 0x40, 0xC0, 0x20, 0xA0, 0x60, 0xE0,
    +        0x10, 0x90, 0x50, 0xD0, 0x30, 0xB0, 0x70, 0xF0,
    +        0x08, 0x88, 0x48, 0xC8, 0x28, 0xA8, 0x68, 0xE8,
    +        0x18, 0x98, 0x58, 0xD8, 0x38, 0xB8, 0x78, 0xF8,
    +        0x04, 0x84, 0x44, 0xC4, 0x24, 0xA4, 0x64, 0xE4,
    +        0x14, 0x94, 0x54, 0xD4, 0x34, 0xB4, 0x74, 0xF4,
    +        0x0C, 0x8C, 0x4C, 0xCC, 0x2C, 0xAC, 0x6C, 0xEC,
    +        0x1C, 0x9C, 0x5C, 0xDC, 0x3C, 0xBC, 0x7C, 0xFC,
    +        0x02, 0x82, 0x42, 0xC2, 0x22, 0xA2, 0x62, 0xE2,
    +        0x12, 0x92, 0x52, 0xD2, 0x32, 0xB2, 0x72, 0xF2,
    +        0x0A, 0x8A, 0x4A, 0xCA, 0x2A, 0xAA, 0x6A, 0xEA,
    +        0x1A, 0x9A, 0x5A, 0xDA, 0x3A, 0xBA, 0x7A, 0xFA,
    +        0x06, 0x86, 0x46, 0xC6, 0x26, 0xA6, 0x66, 0xE6,
    +        0x16, 0x96, 0x56, 0xD6, 0x36, 0xB6, 0x76, 0xF6,
    +        0x0E, 0x8E, 0x4E, 0xCE, 0x2E, 0xAE, 0x6E, 0xEE,
    +        0x1E, 0x9E, 0x5E, 0xDE, 0x3E, 0xBE, 0x7E, 0xFE,
    +        0x01, 0x81, 0x41, 0xC1, 0x21, 0xA1, 0x61, 0xE1,
    +        0x11, 0x91, 0x51, 0xD1, 0x31, 0xB1, 0x71, 0xF1,
    +        0x09, 0x89, 0x49, 0xC9, 0x29, 0xA9, 0x69, 0xE9,
    +        0x19, 0x99, 0x59, 0xD9, 0x39, 0xB9, 0x79, 0xF9,
    +        0x05, 0x85, 0x45, 0xC5, 0x25, 0xA5, 0x65, 0xE5,
    +        0x15, 0x95, 0x55, 0xD5, 0x35, 0xB5, 0x75, 0xF5,
    +        0x0D, 0x8D, 0x4D, 0xCD, 0x2D, 0xAD, 0x6D, 0xED,
    +        0x1D, 0x9D, 0x5D, 0xDD, 0x3D, 0xBD, 0x7D, 0xFD,
    +        0x03, 0x83, 0x43, 0xC3, 0x23, 0xA3, 0x63, 0xE3,
    +        0x13, 0x93, 0x53, 0xD3, 0x33, 0xB3, 0x73, 0xF3,
    +        0x0B, 0x8B, 0x4B, 0xCB, 0x2B, 0xAB, 0x6B, 0xEB,
    +        0x1B, 0x9B, 0x5B, 0xDB, 0x3B, 0xBB, 0x7B, 0xFB,
    +        0x07, 0x87, 0x47, 0xC7, 0x27, 0xA7, 0x67, 0xE7,
    +        0x17, 0x97, 0x57, 0xD7, 0x37, 0xB7, 0x77, 0xF7,
    +        0x0F, 0x8F, 0x4F, 0xCF, 0x2F, 0xAF, 0x6F, 0xEF,
    +        0x1F, 0x9F, 0x5F, 0xDF, 0x3F, 0xBF, 0x7F, 0xFF
    +    );
    +
    +    /**
    +     * Pre-permuted S-box1
    +     *
    +     * Each box ($sbox1-$sbox8) has been vectorized, then each value pre-permuted using the
    +     * P table: concatenation can then be replaced by exclusive ORs.
    +     *
    +     * @var Array
    +     * @access private
    +     */
    +    var $sbox1 = array(
    +        0x00808200, 0x00000000, 0x00008000, 0x00808202,
    +        0x00808002, 0x00008202, 0x00000002, 0x00008000,
    +        0x00000200, 0x00808200, 0x00808202, 0x00000200,
    +        0x00800202, 0x00808002, 0x00800000, 0x00000002,
    +        0x00000202, 0x00800200, 0x00800200, 0x00008200,
    +        0x00008200, 0x00808000, 0x00808000, 0x00800202,
    +        0x00008002, 0x00800002, 0x00800002, 0x00008002,
    +        0x00000000, 0x00000202, 0x00008202, 0x00800000,
    +        0x00008000, 0x00808202, 0x00000002, 0x00808000,
    +        0x00808200, 0x00800000, 0x00800000, 0x00000200,
    +        0x00808002, 0x00008000, 0x00008200, 0x00800002,
    +        0x00000200, 0x00000002, 0x00800202, 0x00008202,
    +        0x00808202, 0x00008002, 0x00808000, 0x00800202,
    +        0x00800002, 0x00000202, 0x00008202, 0x00808200,
    +        0x00000202, 0x00800200, 0x00800200, 0x00000000,
    +        0x00008002, 0x00008200, 0x00000000, 0x00808002
    +    );
    +
    +    /**
    +     * Pre-permuted S-box2
    +     *
    +     * @var Array
    +     * @access private
    +     */
    +    var $sbox2 = array(
    +        0x40084010, 0x40004000, 0x00004000, 0x00084010,
    +        0x00080000, 0x00000010, 0x40080010, 0x40004010,
    +        0x40000010, 0x40084010, 0x40084000, 0x40000000,
    +        0x40004000, 0x00080000, 0x00000010, 0x40080010,
    +        0x00084000, 0x00080010, 0x40004010, 0x00000000,
    +        0x40000000, 0x00004000, 0x00084010, 0x40080000,
    +        0x00080010, 0x40000010, 0x00000000, 0x00084000,
    +        0x00004010, 0x40084000, 0x40080000, 0x00004010,
    +        0x00000000, 0x00084010, 0x40080010, 0x00080000,
    +        0x40004010, 0x40080000, 0x40084000, 0x00004000,
    +        0x40080000, 0x40004000, 0x00000010, 0x40084010,
    +        0x00084010, 0x00000010, 0x00004000, 0x40000000,
    +        0x00004010, 0x40084000, 0x00080000, 0x40000010,
    +        0x00080010, 0x40004010, 0x40000010, 0x00080010,
    +        0x00084000, 0x00000000, 0x40004000, 0x00004010,
    +        0x40000000, 0x40080010, 0x40084010, 0x00084000
    +    );
    +
    +    /**
    +     * Pre-permuted S-box3
    +     *
    +     * @var Array
    +     * @access private
    +     */
    +    var $sbox3 = array(
    +        0x00000104, 0x04010100, 0x00000000, 0x04010004,
    +        0x04000100, 0x00000000, 0x00010104, 0x04000100,
    +        0x00010004, 0x04000004, 0x04000004, 0x00010000,
    +        0x04010104, 0x00010004, 0x04010000, 0x00000104,
    +        0x04000000, 0x00000004, 0x04010100, 0x00000100,
    +        0x00010100, 0x04010000, 0x04010004, 0x00010104,
    +        0x04000104, 0x00010100, 0x00010000, 0x04000104,
    +        0x00000004, 0x04010104, 0x00000100, 0x04000000,
    +        0x04010100, 0x04000000, 0x00010004, 0x00000104,
    +        0x00010000, 0x04010100, 0x04000100, 0x00000000,
    +        0x00000100, 0x00010004, 0x04010104, 0x04000100,
    +        0x04000004, 0x00000100, 0x00000000, 0x04010004,
    +        0x04000104, 0x00010000, 0x04000000, 0x04010104,
    +        0x00000004, 0x00010104, 0x00010100, 0x04000004,
    +        0x04010000, 0x04000104, 0x00000104, 0x04010000,
    +        0x00010104, 0x00000004, 0x04010004, 0x00010100
    +    );
    +
    +    /**
    +     * Pre-permuted S-box4
    +     *
    +     * @var Array
    +     * @access private
    +     */
    +    var $sbox4 = array(
    +        0x80401000, 0x80001040, 0x80001040, 0x00000040,
    +        0x00401040, 0x80400040, 0x80400000, 0x80001000,
    +        0x00000000, 0x00401000, 0x00401000, 0x80401040,
    +        0x80000040, 0x00000000, 0x00400040, 0x80400000,
    +        0x80000000, 0x00001000, 0x00400000, 0x80401000,
    +        0x00000040, 0x00400000, 0x80001000, 0x00001040,
    +        0x80400040, 0x80000000, 0x00001040, 0x00400040,
    +        0x00001000, 0x00401040, 0x80401040, 0x80000040,
    +        0x00400040, 0x80400000, 0x00401000, 0x80401040,
    +        0x80000040, 0x00000000, 0x00000000, 0x00401000,
    +        0x00001040, 0x00400040, 0x80400040, 0x80000000,
    +        0x80401000, 0x80001040, 0x80001040, 0x00000040,
    +        0x80401040, 0x80000040, 0x80000000, 0x00001000,
    +        0x80400000, 0x80001000, 0x00401040, 0x80400040,
    +        0x80001000, 0x00001040, 0x00400000, 0x80401000,
    +        0x00000040, 0x00400000, 0x00001000, 0x00401040
    +    );
    +
    +    /**
    +     * Pre-permuted S-box5
    +     *
    +     * @var Array
    +     * @access private
    +     */
    +    var $sbox5 = array(
    +        0x00000080, 0x01040080, 0x01040000, 0x21000080,
    +        0x00040000, 0x00000080, 0x20000000, 0x01040000,
    +        0x20040080, 0x00040000, 0x01000080, 0x20040080,
    +        0x21000080, 0x21040000, 0x00040080, 0x20000000,
    +        0x01000000, 0x20040000, 0x20040000, 0x00000000,
    +        0x20000080, 0x21040080, 0x21040080, 0x01000080,
    +        0x21040000, 0x20000080, 0x00000000, 0x21000000,
    +        0x01040080, 0x01000000, 0x21000000, 0x00040080,
    +        0x00040000, 0x21000080, 0x00000080, 0x01000000,
    +        0x20000000, 0x01040000, 0x21000080, 0x20040080,
    +        0x01000080, 0x20000000, 0x21040000, 0x01040080,
    +        0x20040080, 0x00000080, 0x01000000, 0x21040000,
    +        0x21040080, 0x00040080, 0x21000000, 0x21040080,
    +        0x01040000, 0x00000000, 0x20040000, 0x21000000,
    +        0x00040080, 0x01000080, 0x20000080, 0x00040000,
    +        0x00000000, 0x20040000, 0x01040080, 0x20000080
    +    );
    +
    +    /**
    +     * Pre-permuted S-box6
    +     *
    +     * @var Array
    +     * @access private
    +     */
    +    var $sbox6 = array(
    +        0x10000008, 0x10200000, 0x00002000, 0x10202008,
    +        0x10200000, 0x00000008, 0x10202008, 0x00200000,
    +        0x10002000, 0x00202008, 0x00200000, 0x10000008,
    +        0x00200008, 0x10002000, 0x10000000, 0x00002008,
    +        0x00000000, 0x00200008, 0x10002008, 0x00002000,
    +        0x00202000, 0x10002008, 0x00000008, 0x10200008,
    +        0x10200008, 0x00000000, 0x00202008, 0x10202000,
    +        0x00002008, 0x00202000, 0x10202000, 0x10000000,
    +        0x10002000, 0x00000008, 0x10200008, 0x00202000,
    +        0x10202008, 0x00200000, 0x00002008, 0x10000008,
    +        0x00200000, 0x10002000, 0x10000000, 0x00002008,
    +        0x10000008, 0x10202008, 0x00202000, 0x10200000,
    +        0x00202008, 0x10202000, 0x00000000, 0x10200008,
    +        0x00000008, 0x00002000, 0x10200000, 0x00202008,
    +        0x00002000, 0x00200008, 0x10002008, 0x00000000,
    +        0x10202000, 0x10000000, 0x00200008, 0x10002008
    +    );
    +
    +    /**
    +     * Pre-permuted S-box7
    +     *
    +     * @var Array
    +     * @access private
    +     */
    +    var $sbox7 = array(
    +        0x00100000, 0x02100001, 0x02000401, 0x00000000,
    +        0x00000400, 0x02000401, 0x00100401, 0x02100400,
    +        0x02100401, 0x00100000, 0x00000000, 0x02000001,
    +        0x00000001, 0x02000000, 0x02100001, 0x00000401,
    +        0x02000400, 0x00100401, 0x00100001, 0x02000400,
    +        0x02000001, 0x02100000, 0x02100400, 0x00100001,
    +        0x02100000, 0x00000400, 0x00000401, 0x02100401,
    +        0x00100400, 0x00000001, 0x02000000, 0x00100400,
    +        0x02000000, 0x00100400, 0x00100000, 0x02000401,
    +        0x02000401, 0x02100001, 0x02100001, 0x00000001,
    +        0x00100001, 0x02000000, 0x02000400, 0x00100000,
    +        0x02100400, 0x00000401, 0x00100401, 0x02100400,
    +        0x00000401, 0x02000001, 0x02100401, 0x02100000,
    +        0x00100400, 0x00000000, 0x00000001, 0x02100401,
    +        0x00000000, 0x00100401, 0x02100000, 0x00000400,
    +        0x02000001, 0x02000400, 0x00000400, 0x00100001
    +    );
    +
    +    /**
    +     * Pre-permuted S-box8
    +     *
    +     * @var Array
    +     * @access private
    +     */
    +    var $sbox8 = array(
    +        0x08000820, 0x00000800, 0x00020000, 0x08020820,
    +        0x08000000, 0x08000820, 0x00000020, 0x08000000,
    +        0x00020020, 0x08020000, 0x08020820, 0x00020800,
    +        0x08020800, 0x00020820, 0x00000800, 0x00000020,
    +        0x08020000, 0x08000020, 0x08000800, 0x00000820,
    +        0x00020800, 0x00020020, 0x08020020, 0x08020800,
    +        0x00000820, 0x00000000, 0x00000000, 0x08020020,
    +        0x08000020, 0x08000800, 0x00020820, 0x00020000,
    +        0x00020820, 0x00020000, 0x08020800, 0x00000800,
    +        0x00000020, 0x08020020, 0x00000800, 0x00020820,
    +        0x08000800, 0x00000020, 0x08000020, 0x08020000,
    +        0x08020020, 0x08000000, 0x00020000, 0x08000820,
    +        0x00000000, 0x08020820, 0x00020020, 0x08000020,
    +        0x08020000, 0x08000800, 0x08000820, 0x00000000,
    +        0x08020820, 0x00020800, 0x00020800, 0x00000820,
    +        0x00000820, 0x00020020, 0x08000000, 0x08020800
    +    );
    +
    +    /**
    +     * Default Constructor.
    +     *
    +     * Determines whether or not the mcrypt extension should be used.
    +     *
    +     * $mode could be:
    +     *
    +     * - CRYPT_DES_MODE_ECB
    +     *
    +     * - CRYPT_DES_MODE_CBC
    +     *
    +     * - CRYPT_DES_MODE_CTR
    +     *
    +     * - CRYPT_DES_MODE_CFB
    +     *
    +     * - CRYPT_DES_MODE_OFB
    +     *
    +     * If not explictly set, CRYPT_DES_MODE_CBC will be used.
    +     *
    +     * @see Crypt_Base::Crypt_Base()
    +     * @param optional Integer $mode
    +     * @access public
    +     */
    +    function Crypt_DES($mode = CRYPT_DES_MODE_CBC)
    +    {
    +        parent::Crypt_Base($mode);
    +    }
    +
    +    /**
    +     * Sets the key.
    +     *
    +     * Keys can be of any length.  DES, itself, uses 64-bit keys (eg. strlen($key) == 8), however, we
    +     * only use the first eight, if $key has more then eight characters in it, and pad $key with the
    +     * null byte if it is less then eight characters long.
    +     *
    +     * DES also requires that every eighth bit be a parity bit, however, we'll ignore that.
    +     *
    +     * If the key is not explicitly set, it'll be assumed to be all zero's.
    +     *
    +     * @see Crypt_Base::setKey()
    +     * @access public
    +     * @param String $key
    +     */
    +    function setKey($key)
    +    {
    +        // We check/cut here only up to max length of the key.
    +        // Key padding to the proper length will be done in _setupKey()
    +        if (strlen($key) > $this->key_size_max) {
    +            $key = substr($key, 0, $this->key_size_max);
    +        }
    +
    +        // Sets the key
    +        parent::setKey($key);
    +    }
    +
    +    /**
    +     * Encrypts a block
    +     *
    +     * @see Crypt_Base::_encryptBlock()
    +     * @see Crypt_Base::encrypt()
    +     * @see Crypt_DES::encrypt()
    +     * @access private
    +     * @param String $in
    +     * @return String
    +     */
    +    function _encryptBlock($in)
    +    {
    +        return $this->_processBlock($in, CRYPT_DES_ENCRYPT);
    +    }
    +
    +    /**
    +     * Decrypts a block
    +     *
    +     * @see Crypt_Base::_decryptBlock()
    +     * @see Crypt_Base::decrypt()
    +     * @see Crypt_DES::decrypt()
    +     * @access private
    +     * @param String $in
    +     * @return String
    +     */
    +    function _decryptBlock($in)
    +    {
    +        return $this->_processBlock($in, CRYPT_DES_DECRYPT);
    +    }
    +
    +    /**
    +     * Encrypts or decrypts a 64-bit block
    +     *
    +     * $mode should be either CRYPT_DES_ENCRYPT or CRYPT_DES_DECRYPT.  See
    +     * {@link http://en.wikipedia.org/wiki/Image:Feistel.png Feistel.png} to get a general
    +     * idea of what this function does.
    +     *
    +     * @see Crypt_DES::_encryptBlock()
    +     * @see Crypt_DES::_decryptBlock()
    +     * @access private
    +     * @param String $block
    +     * @param Integer $mode
    +     * @return String
    +     */
    +    function _processBlock($block, $mode)
    +    {
    +        static $sbox1, $sbox2, $sbox3, $sbox4, $sbox5, $sbox6, $sbox7, $sbox8, $shuffleip, $shuffleinvip;
    +        if (!$sbox1) {
    +            $sbox1 = array_map("intval", $this->sbox1);
    +            $sbox2 = array_map("intval", $this->sbox2);
    +            $sbox3 = array_map("intval", $this->sbox3);
    +            $sbox4 = array_map("intval", $this->sbox4);
    +            $sbox5 = array_map("intval", $this->sbox5);
    +            $sbox6 = array_map("intval", $this->sbox6);
    +            $sbox7 = array_map("intval", $this->sbox7);
    +            $sbox8 = array_map("intval", $this->sbox8);
    +            /* Merge $shuffle with $[inv]ipmap */
    +            for ($i = 0; $i < 256; ++$i) {
    +                $shuffleip[]    =  $this->shuffle[$this->ipmap[$i]];
    +                $shuffleinvip[] =  $this->shuffle[$this->invipmap[$i]];
    +            }
    +        }
    +
    +        $keys  = $this->keys[$mode];
    +        $ki    = -1;
    +
    +        // Do the initial IP permutation.
    +        $t = unpack('Nl/Nr', $block);
    +        list($l, $r) = array($t['l'], $t['r']);
    +        $block = ($shuffleip[ $r        & 0xFF] & "\x80\x80\x80\x80\x80\x80\x80\x80") |
    +                 ($shuffleip[($r >>  8) & 0xFF] & "\x40\x40\x40\x40\x40\x40\x40\x40") |
    +                 ($shuffleip[($r >> 16) & 0xFF] & "\x20\x20\x20\x20\x20\x20\x20\x20") |
    +                 ($shuffleip[($r >> 24) & 0xFF] & "\x10\x10\x10\x10\x10\x10\x10\x10") |
    +                 ($shuffleip[ $l        & 0xFF] & "\x08\x08\x08\x08\x08\x08\x08\x08") |
    +                 ($shuffleip[($l >>  8) & 0xFF] & "\x04\x04\x04\x04\x04\x04\x04\x04") |
    +                 ($shuffleip[($l >> 16) & 0xFF] & "\x02\x02\x02\x02\x02\x02\x02\x02") |
    +                 ($shuffleip[($l >> 24) & 0xFF] & "\x01\x01\x01\x01\x01\x01\x01\x01");
    +
    +        // Extract L0 and R0.
    +        $t = unpack('Nl/Nr', $block);
    +        list($l, $r) = array($t['l'], $t['r']);
    +
    +        for ($des_round = 0; $des_round < $this->des_rounds; ++$des_round) {
    +            // Perform the 16 steps.
    +            for ($i = 0; $i < 16; $i++) {
    +                // start of "the Feistel (F) function" - see the following URL:
    +                // http://en.wikipedia.org/wiki/Image:Data_Encryption_Standard_InfoBox_Diagram.png
    +                // Merge key schedule.
    +                $b1 = (($r >>  3) & 0x1FFFFFFF) ^ ($r << 29) ^ $keys[++$ki];
    +                $b2 = (($r >> 31) & 0x00000001) ^ ($r <<  1) ^ $keys[++$ki];
    +
    +                // S-box indexing.
    +                $t = $sbox1[($b1 >> 24) & 0x3F] ^ $sbox2[($b2 >> 24) & 0x3F] ^
    +                     $sbox3[($b1 >> 16) & 0x3F] ^ $sbox4[($b2 >> 16) & 0x3F] ^
    +                     $sbox5[($b1 >>  8) & 0x3F] ^ $sbox6[($b2 >>  8) & 0x3F] ^
    +                     $sbox7[ $b1        & 0x3F] ^ $sbox8[ $b2        & 0x3F] ^ $l;
    +                // end of "the Feistel (F) function"
    +
    +                $l = $r;
    +                $r = $t;
    +            }
    +
    +            // Last step should not permute L & R.
    +            $t = $l;
    +            $l = $r;
    +            $r = $t;
    +        }
    +
    +        // Perform the inverse IP permutation.
    +        return ($shuffleinvip[($r >> 24) & 0xFF] & "\x80\x80\x80\x80\x80\x80\x80\x80") |
    +               ($shuffleinvip[($l >> 24) & 0xFF] & "\x40\x40\x40\x40\x40\x40\x40\x40") |
    +               ($shuffleinvip[($r >> 16) & 0xFF] & "\x20\x20\x20\x20\x20\x20\x20\x20") |
    +               ($shuffleinvip[($l >> 16) & 0xFF] & "\x10\x10\x10\x10\x10\x10\x10\x10") |
    +               ($shuffleinvip[($r >>  8) & 0xFF] & "\x08\x08\x08\x08\x08\x08\x08\x08") |
    +               ($shuffleinvip[($l >>  8) & 0xFF] & "\x04\x04\x04\x04\x04\x04\x04\x04") |
    +               ($shuffleinvip[ $r        & 0xFF] & "\x02\x02\x02\x02\x02\x02\x02\x02") |
    +               ($shuffleinvip[ $l        & 0xFF] & "\x01\x01\x01\x01\x01\x01\x01\x01");
    +    }
    +
    +    /**
    +     * Creates the key schedule
    +     *
    +     * @see Crypt_Base::_setupKey()
    +     * @access private
    +     */
    +    function _setupKey()
    +    {
    +        if (isset($this->kl['key']) && $this->key === $this->kl['key'] && $this->des_rounds === $this->kl['des_rounds']) {
    +            // already expanded
    +            return;
    +        }
    +        $this->kl = array('key' => $this->key, 'des_rounds' => $this->des_rounds);
    +
    +        static $shifts = array( // number of key bits shifted per round
    +            1, 1, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 1
    +        );
    +
    +        static $pc1map = array(
    +            0x00, 0x00, 0x08, 0x08, 0x04, 0x04, 0x0C, 0x0C,
    +            0x02, 0x02, 0x0A, 0x0A, 0x06, 0x06, 0x0E, 0x0E,
    +            0x10, 0x10, 0x18, 0x18, 0x14, 0x14, 0x1C, 0x1C,
    +            0x12, 0x12, 0x1A, 0x1A, 0x16, 0x16, 0x1E, 0x1E,
    +            0x20, 0x20, 0x28, 0x28, 0x24, 0x24, 0x2C, 0x2C,
    +            0x22, 0x22, 0x2A, 0x2A, 0x26, 0x26, 0x2E, 0x2E,
    +            0x30, 0x30, 0x38, 0x38, 0x34, 0x34, 0x3C, 0x3C,
    +            0x32, 0x32, 0x3A, 0x3A, 0x36, 0x36, 0x3E, 0x3E,
    +            0x40, 0x40, 0x48, 0x48, 0x44, 0x44, 0x4C, 0x4C,
    +            0x42, 0x42, 0x4A, 0x4A, 0x46, 0x46, 0x4E, 0x4E,
    +            0x50, 0x50, 0x58, 0x58, 0x54, 0x54, 0x5C, 0x5C,
    +            0x52, 0x52, 0x5A, 0x5A, 0x56, 0x56, 0x5E, 0x5E,
    +            0x60, 0x60, 0x68, 0x68, 0x64, 0x64, 0x6C, 0x6C,
    +            0x62, 0x62, 0x6A, 0x6A, 0x66, 0x66, 0x6E, 0x6E,
    +            0x70, 0x70, 0x78, 0x78, 0x74, 0x74, 0x7C, 0x7C,
    +            0x72, 0x72, 0x7A, 0x7A, 0x76, 0x76, 0x7E, 0x7E,
    +            0x80, 0x80, 0x88, 0x88, 0x84, 0x84, 0x8C, 0x8C,
    +            0x82, 0x82, 0x8A, 0x8A, 0x86, 0x86, 0x8E, 0x8E,
    +            0x90, 0x90, 0x98, 0x98, 0x94, 0x94, 0x9C, 0x9C,
    +            0x92, 0x92, 0x9A, 0x9A, 0x96, 0x96, 0x9E, 0x9E,
    +            0xA0, 0xA0, 0xA8, 0xA8, 0xA4, 0xA4, 0xAC, 0xAC,
    +            0xA2, 0xA2, 0xAA, 0xAA, 0xA6, 0xA6, 0xAE, 0xAE,
    +            0xB0, 0xB0, 0xB8, 0xB8, 0xB4, 0xB4, 0xBC, 0xBC,
    +            0xB2, 0xB2, 0xBA, 0xBA, 0xB6, 0xB6, 0xBE, 0xBE,
    +            0xC0, 0xC0, 0xC8, 0xC8, 0xC4, 0xC4, 0xCC, 0xCC,
    +            0xC2, 0xC2, 0xCA, 0xCA, 0xC6, 0xC6, 0xCE, 0xCE,
    +            0xD0, 0xD0, 0xD8, 0xD8, 0xD4, 0xD4, 0xDC, 0xDC,
    +            0xD2, 0xD2, 0xDA, 0xDA, 0xD6, 0xD6, 0xDE, 0xDE,
    +            0xE0, 0xE0, 0xE8, 0xE8, 0xE4, 0xE4, 0xEC, 0xEC,
    +            0xE2, 0xE2, 0xEA, 0xEA, 0xE6, 0xE6, 0xEE, 0xEE,
    +            0xF0, 0xF0, 0xF8, 0xF8, 0xF4, 0xF4, 0xFC, 0xFC,
    +            0xF2, 0xF2, 0xFA, 0xFA, 0xF6, 0xF6, 0xFE, 0xFE
    +        );
    +
    +        // Mapping tables for the PC-2 transformation.
    +        static $pc2mapc1 = array(
    +            0x00000000, 0x00000400, 0x00200000, 0x00200400,
    +            0x00000001, 0x00000401, 0x00200001, 0x00200401,
    +            0x02000000, 0x02000400, 0x02200000, 0x02200400,
    +            0x02000001, 0x02000401, 0x02200001, 0x02200401
    +        );
    +        static $pc2mapc2 = array(
    +            0x00000000, 0x00000800, 0x08000000, 0x08000800,
    +            0x00010000, 0x00010800, 0x08010000, 0x08010800,
    +            0x00000000, 0x00000800, 0x08000000, 0x08000800,
    +            0x00010000, 0x00010800, 0x08010000, 0x08010800,
    +            0x00000100, 0x00000900, 0x08000100, 0x08000900,
    +            0x00010100, 0x00010900, 0x08010100, 0x08010900,
    +            0x00000100, 0x00000900, 0x08000100, 0x08000900,
    +            0x00010100, 0x00010900, 0x08010100, 0x08010900,
    +            0x00000010, 0x00000810, 0x08000010, 0x08000810,
    +            0x00010010, 0x00010810, 0x08010010, 0x08010810,
    +            0x00000010, 0x00000810, 0x08000010, 0x08000810,
    +            0x00010010, 0x00010810, 0x08010010, 0x08010810,
    +            0x00000110, 0x00000910, 0x08000110, 0x08000910,
    +            0x00010110, 0x00010910, 0x08010110, 0x08010910,
    +            0x00000110, 0x00000910, 0x08000110, 0x08000910,
    +            0x00010110, 0x00010910, 0x08010110, 0x08010910,
    +            0x00040000, 0x00040800, 0x08040000, 0x08040800,
    +            0x00050000, 0x00050800, 0x08050000, 0x08050800,
    +            0x00040000, 0x00040800, 0x08040000, 0x08040800,
    +            0x00050000, 0x00050800, 0x08050000, 0x08050800,
    +            0x00040100, 0x00040900, 0x08040100, 0x08040900,
    +            0x00050100, 0x00050900, 0x08050100, 0x08050900,
    +            0x00040100, 0x00040900, 0x08040100, 0x08040900,
    +            0x00050100, 0x00050900, 0x08050100, 0x08050900,
    +            0x00040010, 0x00040810, 0x08040010, 0x08040810,
    +            0x00050010, 0x00050810, 0x08050010, 0x08050810,
    +            0x00040010, 0x00040810, 0x08040010, 0x08040810,
    +            0x00050010, 0x00050810, 0x08050010, 0x08050810,
    +            0x00040110, 0x00040910, 0x08040110, 0x08040910,
    +            0x00050110, 0x00050910, 0x08050110, 0x08050910,
    +            0x00040110, 0x00040910, 0x08040110, 0x08040910,
    +            0x00050110, 0x00050910, 0x08050110, 0x08050910,
    +            0x01000000, 0x01000800, 0x09000000, 0x09000800,
    +            0x01010000, 0x01010800, 0x09010000, 0x09010800,
    +            0x01000000, 0x01000800, 0x09000000, 0x09000800,
    +            0x01010000, 0x01010800, 0x09010000, 0x09010800,
    +            0x01000100, 0x01000900, 0x09000100, 0x09000900,
    +            0x01010100, 0x01010900, 0x09010100, 0x09010900,
    +            0x01000100, 0x01000900, 0x09000100, 0x09000900,
    +            0x01010100, 0x01010900, 0x09010100, 0x09010900,
    +            0x01000010, 0x01000810, 0x09000010, 0x09000810,
    +            0x01010010, 0x01010810, 0x09010010, 0x09010810,
    +            0x01000010, 0x01000810, 0x09000010, 0x09000810,
    +            0x01010010, 0x01010810, 0x09010010, 0x09010810,
    +            0x01000110, 0x01000910, 0x09000110, 0x09000910,
    +            0x01010110, 0x01010910, 0x09010110, 0x09010910,
    +            0x01000110, 0x01000910, 0x09000110, 0x09000910,
    +            0x01010110, 0x01010910, 0x09010110, 0x09010910,
    +            0x01040000, 0x01040800, 0x09040000, 0x09040800,
    +            0x01050000, 0x01050800, 0x09050000, 0x09050800,
    +            0x01040000, 0x01040800, 0x09040000, 0x09040800,
    +            0x01050000, 0x01050800, 0x09050000, 0x09050800,
    +            0x01040100, 0x01040900, 0x09040100, 0x09040900,
    +            0x01050100, 0x01050900, 0x09050100, 0x09050900,
    +            0x01040100, 0x01040900, 0x09040100, 0x09040900,
    +            0x01050100, 0x01050900, 0x09050100, 0x09050900,
    +            0x01040010, 0x01040810, 0x09040010, 0x09040810,
    +            0x01050010, 0x01050810, 0x09050010, 0x09050810,
    +            0x01040010, 0x01040810, 0x09040010, 0x09040810,
    +            0x01050010, 0x01050810, 0x09050010, 0x09050810,
    +            0x01040110, 0x01040910, 0x09040110, 0x09040910,
    +            0x01050110, 0x01050910, 0x09050110, 0x09050910,
    +            0x01040110, 0x01040910, 0x09040110, 0x09040910,
    +            0x01050110, 0x01050910, 0x09050110, 0x09050910
    +        );
    +        static $pc2mapc3 = array(
    +            0x00000000, 0x00000004, 0x00001000, 0x00001004,
    +            0x00000000, 0x00000004, 0x00001000, 0x00001004,
    +            0x10000000, 0x10000004, 0x10001000, 0x10001004,
    +            0x10000000, 0x10000004, 0x10001000, 0x10001004,
    +            0x00000020, 0x00000024, 0x00001020, 0x00001024,
    +            0x00000020, 0x00000024, 0x00001020, 0x00001024,
    +            0x10000020, 0x10000024, 0x10001020, 0x10001024,
    +            0x10000020, 0x10000024, 0x10001020, 0x10001024,
    +            0x00080000, 0x00080004, 0x00081000, 0x00081004,
    +            0x00080000, 0x00080004, 0x00081000, 0x00081004,
    +            0x10080000, 0x10080004, 0x10081000, 0x10081004,
    +            0x10080000, 0x10080004, 0x10081000, 0x10081004,
    +            0x00080020, 0x00080024, 0x00081020, 0x00081024,
    +            0x00080020, 0x00080024, 0x00081020, 0x00081024,
    +            0x10080020, 0x10080024, 0x10081020, 0x10081024,
    +            0x10080020, 0x10080024, 0x10081020, 0x10081024,
    +            0x20000000, 0x20000004, 0x20001000, 0x20001004,
    +            0x20000000, 0x20000004, 0x20001000, 0x20001004,
    +            0x30000000, 0x30000004, 0x30001000, 0x30001004,
    +            0x30000000, 0x30000004, 0x30001000, 0x30001004,
    +            0x20000020, 0x20000024, 0x20001020, 0x20001024,
    +            0x20000020, 0x20000024, 0x20001020, 0x20001024,
    +            0x30000020, 0x30000024, 0x30001020, 0x30001024,
    +            0x30000020, 0x30000024, 0x30001020, 0x30001024,
    +            0x20080000, 0x20080004, 0x20081000, 0x20081004,
    +            0x20080000, 0x20080004, 0x20081000, 0x20081004,
    +            0x30080000, 0x30080004, 0x30081000, 0x30081004,
    +            0x30080000, 0x30080004, 0x30081000, 0x30081004,
    +            0x20080020, 0x20080024, 0x20081020, 0x20081024,
    +            0x20080020, 0x20080024, 0x20081020, 0x20081024,
    +            0x30080020, 0x30080024, 0x30081020, 0x30081024,
    +            0x30080020, 0x30080024, 0x30081020, 0x30081024,
    +            0x00000002, 0x00000006, 0x00001002, 0x00001006,
    +            0x00000002, 0x00000006, 0x00001002, 0x00001006,
    +            0x10000002, 0x10000006, 0x10001002, 0x10001006,
    +            0x10000002, 0x10000006, 0x10001002, 0x10001006,
    +            0x00000022, 0x00000026, 0x00001022, 0x00001026,
    +            0x00000022, 0x00000026, 0x00001022, 0x00001026,
    +            0x10000022, 0x10000026, 0x10001022, 0x10001026,
    +            0x10000022, 0x10000026, 0x10001022, 0x10001026,
    +            0x00080002, 0x00080006, 0x00081002, 0x00081006,
    +            0x00080002, 0x00080006, 0x00081002, 0x00081006,
    +            0x10080002, 0x10080006, 0x10081002, 0x10081006,
    +            0x10080002, 0x10080006, 0x10081002, 0x10081006,
    +            0x00080022, 0x00080026, 0x00081022, 0x00081026,
    +            0x00080022, 0x00080026, 0x00081022, 0x00081026,
    +            0x10080022, 0x10080026, 0x10081022, 0x10081026,
    +            0x10080022, 0x10080026, 0x10081022, 0x10081026,
    +            0x20000002, 0x20000006, 0x20001002, 0x20001006,
    +            0x20000002, 0x20000006, 0x20001002, 0x20001006,
    +            0x30000002, 0x30000006, 0x30001002, 0x30001006,
    +            0x30000002, 0x30000006, 0x30001002, 0x30001006,
    +            0x20000022, 0x20000026, 0x20001022, 0x20001026,
    +            0x20000022, 0x20000026, 0x20001022, 0x20001026,
    +            0x30000022, 0x30000026, 0x30001022, 0x30001026,
    +            0x30000022, 0x30000026, 0x30001022, 0x30001026,
    +            0x20080002, 0x20080006, 0x20081002, 0x20081006,
    +            0x20080002, 0x20080006, 0x20081002, 0x20081006,
    +            0x30080002, 0x30080006, 0x30081002, 0x30081006,
    +            0x30080002, 0x30080006, 0x30081002, 0x30081006,
    +            0x20080022, 0x20080026, 0x20081022, 0x20081026,
    +            0x20080022, 0x20080026, 0x20081022, 0x20081026,
    +            0x30080022, 0x30080026, 0x30081022, 0x30081026,
    +            0x30080022, 0x30080026, 0x30081022, 0x30081026
    +        );
    +        static $pc2mapc4 = array(
    +            0x00000000, 0x00100000, 0x00000008, 0x00100008,
    +            0x00000200, 0x00100200, 0x00000208, 0x00100208,
    +            0x00000000, 0x00100000, 0x00000008, 0x00100008,
    +            0x00000200, 0x00100200, 0x00000208, 0x00100208,
    +            0x04000000, 0x04100000, 0x04000008, 0x04100008,
    +            0x04000200, 0x04100200, 0x04000208, 0x04100208,
    +            0x04000000, 0x04100000, 0x04000008, 0x04100008,
    +            0x04000200, 0x04100200, 0x04000208, 0x04100208,
    +            0x00002000, 0x00102000, 0x00002008, 0x00102008,
    +            0x00002200, 0x00102200, 0x00002208, 0x00102208,
    +            0x00002000, 0x00102000, 0x00002008, 0x00102008,
    +            0x00002200, 0x00102200, 0x00002208, 0x00102208,
    +            0x04002000, 0x04102000, 0x04002008, 0x04102008,
    +            0x04002200, 0x04102200, 0x04002208, 0x04102208,
    +            0x04002000, 0x04102000, 0x04002008, 0x04102008,
    +            0x04002200, 0x04102200, 0x04002208, 0x04102208,
    +            0x00000000, 0x00100000, 0x00000008, 0x00100008,
    +            0x00000200, 0x00100200, 0x00000208, 0x00100208,
    +            0x00000000, 0x00100000, 0x00000008, 0x00100008,
    +            0x00000200, 0x00100200, 0x00000208, 0x00100208,
    +            0x04000000, 0x04100000, 0x04000008, 0x04100008,
    +            0x04000200, 0x04100200, 0x04000208, 0x04100208,
    +            0x04000000, 0x04100000, 0x04000008, 0x04100008,
    +            0x04000200, 0x04100200, 0x04000208, 0x04100208,
    +            0x00002000, 0x00102000, 0x00002008, 0x00102008,
    +            0x00002200, 0x00102200, 0x00002208, 0x00102208,
    +            0x00002000, 0x00102000, 0x00002008, 0x00102008,
    +            0x00002200, 0x00102200, 0x00002208, 0x00102208,
    +            0x04002000, 0x04102000, 0x04002008, 0x04102008,
    +            0x04002200, 0x04102200, 0x04002208, 0x04102208,
    +            0x04002000, 0x04102000, 0x04002008, 0x04102008,
    +            0x04002200, 0x04102200, 0x04002208, 0x04102208,
    +            0x00020000, 0x00120000, 0x00020008, 0x00120008,
    +            0x00020200, 0x00120200, 0x00020208, 0x00120208,
    +            0x00020000, 0x00120000, 0x00020008, 0x00120008,
    +            0x00020200, 0x00120200, 0x00020208, 0x00120208,
    +            0x04020000, 0x04120000, 0x04020008, 0x04120008,
    +            0x04020200, 0x04120200, 0x04020208, 0x04120208,
    +            0x04020000, 0x04120000, 0x04020008, 0x04120008,
    +            0x04020200, 0x04120200, 0x04020208, 0x04120208,
    +            0x00022000, 0x00122000, 0x00022008, 0x00122008,
    +            0x00022200, 0x00122200, 0x00022208, 0x00122208,
    +            0x00022000, 0x00122000, 0x00022008, 0x00122008,
    +            0x00022200, 0x00122200, 0x00022208, 0x00122208,
    +            0x04022000, 0x04122000, 0x04022008, 0x04122008,
    +            0x04022200, 0x04122200, 0x04022208, 0x04122208,
    +            0x04022000, 0x04122000, 0x04022008, 0x04122008,
    +            0x04022200, 0x04122200, 0x04022208, 0x04122208,
    +            0x00020000, 0x00120000, 0x00020008, 0x00120008,
    +            0x00020200, 0x00120200, 0x00020208, 0x00120208,
    +            0x00020000, 0x00120000, 0x00020008, 0x00120008,
    +            0x00020200, 0x00120200, 0x00020208, 0x00120208,
    +            0x04020000, 0x04120000, 0x04020008, 0x04120008,
    +            0x04020200, 0x04120200, 0x04020208, 0x04120208,
    +            0x04020000, 0x04120000, 0x04020008, 0x04120008,
    +            0x04020200, 0x04120200, 0x04020208, 0x04120208,
    +            0x00022000, 0x00122000, 0x00022008, 0x00122008,
    +            0x00022200, 0x00122200, 0x00022208, 0x00122208,
    +            0x00022000, 0x00122000, 0x00022008, 0x00122008,
    +            0x00022200, 0x00122200, 0x00022208, 0x00122208,
    +            0x04022000, 0x04122000, 0x04022008, 0x04122008,
    +            0x04022200, 0x04122200, 0x04022208, 0x04122208,
    +            0x04022000, 0x04122000, 0x04022008, 0x04122008,
    +            0x04022200, 0x04122200, 0x04022208, 0x04122208
    +        );
    +        static $pc2mapd1 = array(
    +            0x00000000, 0x00000001, 0x08000000, 0x08000001,
    +            0x00200000, 0x00200001, 0x08200000, 0x08200001,
    +            0x00000002, 0x00000003, 0x08000002, 0x08000003,
    +            0x00200002, 0x00200003, 0x08200002, 0x08200003
    +        );
    +        static $pc2mapd2 = array(
    +            0x00000000, 0x00100000, 0x00000800, 0x00100800,
    +            0x00000000, 0x00100000, 0x00000800, 0x00100800,
    +            0x04000000, 0x04100000, 0x04000800, 0x04100800,
    +            0x04000000, 0x04100000, 0x04000800, 0x04100800,
    +            0x00000004, 0x00100004, 0x00000804, 0x00100804,
    +            0x00000004, 0x00100004, 0x00000804, 0x00100804,
    +            0x04000004, 0x04100004, 0x04000804, 0x04100804,
    +            0x04000004, 0x04100004, 0x04000804, 0x04100804,
    +            0x00000000, 0x00100000, 0x00000800, 0x00100800,
    +            0x00000000, 0x00100000, 0x00000800, 0x00100800,
    +            0x04000000, 0x04100000, 0x04000800, 0x04100800,
    +            0x04000000, 0x04100000, 0x04000800, 0x04100800,
    +            0x00000004, 0x00100004, 0x00000804, 0x00100804,
    +            0x00000004, 0x00100004, 0x00000804, 0x00100804,
    +            0x04000004, 0x04100004, 0x04000804, 0x04100804,
    +            0x04000004, 0x04100004, 0x04000804, 0x04100804,
    +            0x00000200, 0x00100200, 0x00000A00, 0x00100A00,
    +            0x00000200, 0x00100200, 0x00000A00, 0x00100A00,
    +            0x04000200, 0x04100200, 0x04000A00, 0x04100A00,
    +            0x04000200, 0x04100200, 0x04000A00, 0x04100A00,
    +            0x00000204, 0x00100204, 0x00000A04, 0x00100A04,
    +            0x00000204, 0x00100204, 0x00000A04, 0x00100A04,
    +            0x04000204, 0x04100204, 0x04000A04, 0x04100A04,
    +            0x04000204, 0x04100204, 0x04000A04, 0x04100A04,
    +            0x00000200, 0x00100200, 0x00000A00, 0x00100A00,
    +            0x00000200, 0x00100200, 0x00000A00, 0x00100A00,
    +            0x04000200, 0x04100200, 0x04000A00, 0x04100A00,
    +            0x04000200, 0x04100200, 0x04000A00, 0x04100A00,
    +            0x00000204, 0x00100204, 0x00000A04, 0x00100A04,
    +            0x00000204, 0x00100204, 0x00000A04, 0x00100A04,
    +            0x04000204, 0x04100204, 0x04000A04, 0x04100A04,
    +            0x04000204, 0x04100204, 0x04000A04, 0x04100A04,
    +            0x00020000, 0x00120000, 0x00020800, 0x00120800,
    +            0x00020000, 0x00120000, 0x00020800, 0x00120800,
    +            0x04020000, 0x04120000, 0x04020800, 0x04120800,
    +            0x04020000, 0x04120000, 0x04020800, 0x04120800,
    +            0x00020004, 0x00120004, 0x00020804, 0x00120804,
    +            0x00020004, 0x00120004, 0x00020804, 0x00120804,
    +            0x04020004, 0x04120004, 0x04020804, 0x04120804,
    +            0x04020004, 0x04120004, 0x04020804, 0x04120804,
    +            0x00020000, 0x00120000, 0x00020800, 0x00120800,
    +            0x00020000, 0x00120000, 0x00020800, 0x00120800,
    +            0x04020000, 0x04120000, 0x04020800, 0x04120800,
    +            0x04020000, 0x04120000, 0x04020800, 0x04120800,
    +            0x00020004, 0x00120004, 0x00020804, 0x00120804,
    +            0x00020004, 0x00120004, 0x00020804, 0x00120804,
    +            0x04020004, 0x04120004, 0x04020804, 0x04120804,
    +            0x04020004, 0x04120004, 0x04020804, 0x04120804,
    +            0x00020200, 0x00120200, 0x00020A00, 0x00120A00,
    +            0x00020200, 0x00120200, 0x00020A00, 0x00120A00,
    +            0x04020200, 0x04120200, 0x04020A00, 0x04120A00,
    +            0x04020200, 0x04120200, 0x04020A00, 0x04120A00,
    +            0x00020204, 0x00120204, 0x00020A04, 0x00120A04,
    +            0x00020204, 0x00120204, 0x00020A04, 0x00120A04,
    +            0x04020204, 0x04120204, 0x04020A04, 0x04120A04,
    +            0x04020204, 0x04120204, 0x04020A04, 0x04120A04,
    +            0x00020200, 0x00120200, 0x00020A00, 0x00120A00,
    +            0x00020200, 0x00120200, 0x00020A00, 0x00120A00,
    +            0x04020200, 0x04120200, 0x04020A00, 0x04120A00,
    +            0x04020200, 0x04120200, 0x04020A00, 0x04120A00,
    +            0x00020204, 0x00120204, 0x00020A04, 0x00120A04,
    +            0x00020204, 0x00120204, 0x00020A04, 0x00120A04,
    +            0x04020204, 0x04120204, 0x04020A04, 0x04120A04,
    +            0x04020204, 0x04120204, 0x04020A04, 0x04120A04
    +        );
    +        static $pc2mapd3 = array(
    +            0x00000000, 0x00010000, 0x02000000, 0x02010000,
    +            0x00000020, 0x00010020, 0x02000020, 0x02010020,
    +            0x00040000, 0x00050000, 0x02040000, 0x02050000,
    +            0x00040020, 0x00050020, 0x02040020, 0x02050020,
    +            0x00002000, 0x00012000, 0x02002000, 0x02012000,
    +            0x00002020, 0x00012020, 0x02002020, 0x02012020,
    +            0x00042000, 0x00052000, 0x02042000, 0x02052000,
    +            0x00042020, 0x00052020, 0x02042020, 0x02052020,
    +            0x00000000, 0x00010000, 0x02000000, 0x02010000,
    +            0x00000020, 0x00010020, 0x02000020, 0x02010020,
    +            0x00040000, 0x00050000, 0x02040000, 0x02050000,
    +            0x00040020, 0x00050020, 0x02040020, 0x02050020,
    +            0x00002000, 0x00012000, 0x02002000, 0x02012000,
    +            0x00002020, 0x00012020, 0x02002020, 0x02012020,
    +            0x00042000, 0x00052000, 0x02042000, 0x02052000,
    +            0x00042020, 0x00052020, 0x02042020, 0x02052020,
    +            0x00000010, 0x00010010, 0x02000010, 0x02010010,
    +            0x00000030, 0x00010030, 0x02000030, 0x02010030,
    +            0x00040010, 0x00050010, 0x02040010, 0x02050010,
    +            0x00040030, 0x00050030, 0x02040030, 0x02050030,
    +            0x00002010, 0x00012010, 0x02002010, 0x02012010,
    +            0x00002030, 0x00012030, 0x02002030, 0x02012030,
    +            0x00042010, 0x00052010, 0x02042010, 0x02052010,
    +            0x00042030, 0x00052030, 0x02042030, 0x02052030,
    +            0x00000010, 0x00010010, 0x02000010, 0x02010010,
    +            0x00000030, 0x00010030, 0x02000030, 0x02010030,
    +            0x00040010, 0x00050010, 0x02040010, 0x02050010,
    +            0x00040030, 0x00050030, 0x02040030, 0x02050030,
    +            0x00002010, 0x00012010, 0x02002010, 0x02012010,
    +            0x00002030, 0x00012030, 0x02002030, 0x02012030,
    +            0x00042010, 0x00052010, 0x02042010, 0x02052010,
    +            0x00042030, 0x00052030, 0x02042030, 0x02052030,
    +            0x20000000, 0x20010000, 0x22000000, 0x22010000,
    +            0x20000020, 0x20010020, 0x22000020, 0x22010020,
    +            0x20040000, 0x20050000, 0x22040000, 0x22050000,
    +            0x20040020, 0x20050020, 0x22040020, 0x22050020,
    +            0x20002000, 0x20012000, 0x22002000, 0x22012000,
    +            0x20002020, 0x20012020, 0x22002020, 0x22012020,
    +            0x20042000, 0x20052000, 0x22042000, 0x22052000,
    +            0x20042020, 0x20052020, 0x22042020, 0x22052020,
    +            0x20000000, 0x20010000, 0x22000000, 0x22010000,
    +            0x20000020, 0x20010020, 0x22000020, 0x22010020,
    +            0x20040000, 0x20050000, 0x22040000, 0x22050000,
    +            0x20040020, 0x20050020, 0x22040020, 0x22050020,
    +            0x20002000, 0x20012000, 0x22002000, 0x22012000,
    +            0x20002020, 0x20012020, 0x22002020, 0x22012020,
    +            0x20042000, 0x20052000, 0x22042000, 0x22052000,
    +            0x20042020, 0x20052020, 0x22042020, 0x22052020,
    +            0x20000010, 0x20010010, 0x22000010, 0x22010010,
    +            0x20000030, 0x20010030, 0x22000030, 0x22010030,
    +            0x20040010, 0x20050010, 0x22040010, 0x22050010,
    +            0x20040030, 0x20050030, 0x22040030, 0x22050030,
    +            0x20002010, 0x20012010, 0x22002010, 0x22012010,
    +            0x20002030, 0x20012030, 0x22002030, 0x22012030,
    +            0x20042010, 0x20052010, 0x22042010, 0x22052010,
    +            0x20042030, 0x20052030, 0x22042030, 0x22052030,
    +            0x20000010, 0x20010010, 0x22000010, 0x22010010,
    +            0x20000030, 0x20010030, 0x22000030, 0x22010030,
    +            0x20040010, 0x20050010, 0x22040010, 0x22050010,
    +            0x20040030, 0x20050030, 0x22040030, 0x22050030,
    +            0x20002010, 0x20012010, 0x22002010, 0x22012010,
    +            0x20002030, 0x20012030, 0x22002030, 0x22012030,
    +            0x20042010, 0x20052010, 0x22042010, 0x22052010,
    +            0x20042030, 0x20052030, 0x22042030, 0x22052030
    +        );
    +        static $pc2mapd4 = array(
    +            0x00000000, 0x00000400, 0x01000000, 0x01000400,
    +            0x00000000, 0x00000400, 0x01000000, 0x01000400,
    +            0x00000100, 0x00000500, 0x01000100, 0x01000500,
    +            0x00000100, 0x00000500, 0x01000100, 0x01000500,
    +            0x10000000, 0x10000400, 0x11000000, 0x11000400,
    +            0x10000000, 0x10000400, 0x11000000, 0x11000400,
    +            0x10000100, 0x10000500, 0x11000100, 0x11000500,
    +            0x10000100, 0x10000500, 0x11000100, 0x11000500,
    +            0x00080000, 0x00080400, 0x01080000, 0x01080400,
    +            0x00080000, 0x00080400, 0x01080000, 0x01080400,
    +            0x00080100, 0x00080500, 0x01080100, 0x01080500,
    +            0x00080100, 0x00080500, 0x01080100, 0x01080500,
    +            0x10080000, 0x10080400, 0x11080000, 0x11080400,
    +            0x10080000, 0x10080400, 0x11080000, 0x11080400,
    +            0x10080100, 0x10080500, 0x11080100, 0x11080500,
    +            0x10080100, 0x10080500, 0x11080100, 0x11080500,
    +            0x00000008, 0x00000408, 0x01000008, 0x01000408,
    +            0x00000008, 0x00000408, 0x01000008, 0x01000408,
    +            0x00000108, 0x00000508, 0x01000108, 0x01000508,
    +            0x00000108, 0x00000508, 0x01000108, 0x01000508,
    +            0x10000008, 0x10000408, 0x11000008, 0x11000408,
    +            0x10000008, 0x10000408, 0x11000008, 0x11000408,
    +            0x10000108, 0x10000508, 0x11000108, 0x11000508,
    +            0x10000108, 0x10000508, 0x11000108, 0x11000508,
    +            0x00080008, 0x00080408, 0x01080008, 0x01080408,
    +            0x00080008, 0x00080408, 0x01080008, 0x01080408,
    +            0x00080108, 0x00080508, 0x01080108, 0x01080508,
    +            0x00080108, 0x00080508, 0x01080108, 0x01080508,
    +            0x10080008, 0x10080408, 0x11080008, 0x11080408,
    +            0x10080008, 0x10080408, 0x11080008, 0x11080408,
    +            0x10080108, 0x10080508, 0x11080108, 0x11080508,
    +            0x10080108, 0x10080508, 0x11080108, 0x11080508,
    +            0x00001000, 0x00001400, 0x01001000, 0x01001400,
    +            0x00001000, 0x00001400, 0x01001000, 0x01001400,
    +            0x00001100, 0x00001500, 0x01001100, 0x01001500,
    +            0x00001100, 0x00001500, 0x01001100, 0x01001500,
    +            0x10001000, 0x10001400, 0x11001000, 0x11001400,
    +            0x10001000, 0x10001400, 0x11001000, 0x11001400,
    +            0x10001100, 0x10001500, 0x11001100, 0x11001500,
    +            0x10001100, 0x10001500, 0x11001100, 0x11001500,
    +            0x00081000, 0x00081400, 0x01081000, 0x01081400,
    +            0x00081000, 0x00081400, 0x01081000, 0x01081400,
    +            0x00081100, 0x00081500, 0x01081100, 0x01081500,
    +            0x00081100, 0x00081500, 0x01081100, 0x01081500,
    +            0x10081000, 0x10081400, 0x11081000, 0x11081400,
    +            0x10081000, 0x10081400, 0x11081000, 0x11081400,
    +            0x10081100, 0x10081500, 0x11081100, 0x11081500,
    +            0x10081100, 0x10081500, 0x11081100, 0x11081500,
    +            0x00001008, 0x00001408, 0x01001008, 0x01001408,
    +            0x00001008, 0x00001408, 0x01001008, 0x01001408,
    +            0x00001108, 0x00001508, 0x01001108, 0x01001508,
    +            0x00001108, 0x00001508, 0x01001108, 0x01001508,
    +            0x10001008, 0x10001408, 0x11001008, 0x11001408,
    +            0x10001008, 0x10001408, 0x11001008, 0x11001408,
    +            0x10001108, 0x10001508, 0x11001108, 0x11001508,
    +            0x10001108, 0x10001508, 0x11001108, 0x11001508,
    +            0x00081008, 0x00081408, 0x01081008, 0x01081408,
    +            0x00081008, 0x00081408, 0x01081008, 0x01081408,
    +            0x00081108, 0x00081508, 0x01081108, 0x01081508,
    +            0x00081108, 0x00081508, 0x01081108, 0x01081508,
    +            0x10081008, 0x10081408, 0x11081008, 0x11081408,
    +            0x10081008, 0x10081408, 0x11081008, 0x11081408,
    +            0x10081108, 0x10081508, 0x11081108, 0x11081508,
    +            0x10081108, 0x10081508, 0x11081108, 0x11081508
    +        );
    +
    +        $keys = array();
    +        for ($des_round = 0; $des_round < $this->des_rounds; ++$des_round) {
    +            // pad the key and remove extra characters as appropriate.
    +            $key = str_pad(substr($this->key, $des_round * 8, 8), 8, "\0");
    +
    +            // Perform the PC/1 transformation and compute C and D.
    +            $t = unpack('Nl/Nr', $key);
    +            list($l, $r) = array($t['l'], $t['r']);
    +            $key = ($this->shuffle[$pc1map[ $r        & 0xFF]] & "\x80\x80\x80\x80\x80\x80\x80\x00") |
    +                   ($this->shuffle[$pc1map[($r >>  8) & 0xFF]] & "\x40\x40\x40\x40\x40\x40\x40\x00") |
    +                   ($this->shuffle[$pc1map[($r >> 16) & 0xFF]] & "\x20\x20\x20\x20\x20\x20\x20\x00") |
    +                   ($this->shuffle[$pc1map[($r >> 24) & 0xFF]] & "\x10\x10\x10\x10\x10\x10\x10\x00") |
    +                   ($this->shuffle[$pc1map[ $l        & 0xFF]] & "\x08\x08\x08\x08\x08\x08\x08\x00") |
    +                   ($this->shuffle[$pc1map[($l >>  8) & 0xFF]] & "\x04\x04\x04\x04\x04\x04\x04\x00") |
    +                   ($this->shuffle[$pc1map[($l >> 16) & 0xFF]] & "\x02\x02\x02\x02\x02\x02\x02\x00") |
    +                   ($this->shuffle[$pc1map[($l >> 24) & 0xFF]] & "\x01\x01\x01\x01\x01\x01\x01\x00");
    +            $key = unpack('Nc/Nd', $key);
    +            $c = ( $key['c'] >> 4) & 0x0FFFFFFF;
    +            $d = (($key['d'] >> 4) & 0x0FFFFFF0) | ($key['c'] & 0x0F);
    +
    +            $keys[$des_round] = array(
    +                CRYPT_DES_ENCRYPT => array(),
    +                CRYPT_DES_DECRYPT => array_fill(0, 32, 0)
    +            );
    +            for ($i = 0, $ki = 31; $i < 16; ++$i, $ki-= 2) {
    +                $c <<= $shifts[$i];
    +                $c = ($c | ($c >> 28)) & 0x0FFFFFFF;
    +                $d <<= $shifts[$i];
    +                $d = ($d | ($d >> 28)) & 0x0FFFFFFF;
    +
    +                // Perform the PC-2 transformation.
    +                $cp = $pc2mapc1[ $c >> 24        ] | $pc2mapc2[($c >> 16) & 0xFF] |
    +                      $pc2mapc3[($c >>  8) & 0xFF] | $pc2mapc4[ $c        & 0xFF];
    +                $dp = $pc2mapd1[ $d >> 24        ] | $pc2mapd2[($d >> 16) & 0xFF] |
    +                      $pc2mapd3[($d >>  8) & 0xFF] | $pc2mapd4[ $d        & 0xFF];
    +
    +                // Reorder: odd bytes/even bytes. Push the result in key schedule.
    +                $val1 = ( $cp        & 0xFF000000) | (($cp <<  8) & 0x00FF0000) |
    +                        (($dp >> 16) & 0x0000FF00) | (($dp >>  8) & 0x000000FF);
    +                $val2 = (($cp <<  8) & 0xFF000000) | (($cp << 16) & 0x00FF0000) |
    +                        (($dp >>  8) & 0x0000FF00) | ( $dp        & 0x000000FF);
    +                $keys[$des_round][CRYPT_DES_ENCRYPT][       ] = $val1;
    +                $keys[$des_round][CRYPT_DES_DECRYPT][$ki - 1] = $val1;
    +                $keys[$des_round][CRYPT_DES_ENCRYPT][       ] = $val2;
    +                $keys[$des_round][CRYPT_DES_DECRYPT][$ki    ] = $val2;
    +            }
    +        }
    +
    +        switch ($this->des_rounds) {
    +            case 3: // 3DES keys
    +                $this->keys = array(
    +                    CRYPT_DES_ENCRYPT => array_merge(
    +                        $keys[0][CRYPT_DES_ENCRYPT],
    +                        $keys[1][CRYPT_DES_DECRYPT],
    +                        $keys[2][CRYPT_DES_ENCRYPT]
    +                    ),
    +                    CRYPT_DES_DECRYPT => array_merge(
    +                        $keys[2][CRYPT_DES_DECRYPT],
    +                        $keys[1][CRYPT_DES_ENCRYPT],
    +                        $keys[0][CRYPT_DES_DECRYPT]
    +                    )
    +                );
    +                break;
    +            // case 1: // DES keys
    +            default:
    +                $this->keys = array(
    +                    CRYPT_DES_ENCRYPT => $keys[0][CRYPT_DES_ENCRYPT],
    +                    CRYPT_DES_DECRYPT => $keys[0][CRYPT_DES_DECRYPT]
    +                );
    +        }
    +    }
    +
    +    /**
    +     * Setup the performance-optimized function for de/encrypt()
    +     *
    +     * @see Crypt_Base::_setupInlineCrypt()
    +     * @access private
    +     */
    +    function _setupInlineCrypt()
    +    {
    +        $lambda_functions =& Crypt_DES::_getLambdaFunctions();
    +
    +        // Engine configuration for:
    +        // -  DES ($des_rounds == 1) or
    +        // - 3DES ($des_rounds == 3)
    +        $des_rounds = $this->des_rounds;
    +
    +        // We create max. 10 hi-optimized code for memory reason. Means: For each $key one ultra fast inline-crypt function.
    +        // After that, we'll still create very fast optimized code but not the hi-ultimative code, for each $mode one
    +        $gen_hi_opt_code = (bool)( count($lambda_functions) < 10 );
    +
    +        // Generation of a uniqe hash for our generated code
    +        switch (true) {
    +            case $gen_hi_opt_code:
    +                // For hi-optimized code, we create for each combination of
    +                // $mode, $des_rounds and $this->key its own encrypt/decrypt function.
    +                $code_hash = md5(str_pad("Crypt_DES, $des_rounds, {$this->mode}, ", 32, "\0") . $this->key);
    +                break;
    +            default:
    +                // After max 10 hi-optimized functions, we create generic
    +                // (still very fast.. but not ultra) functions for each $mode/$des_rounds
    +                // Currently 2 * 5 generic functions will be then max. possible.
    +                $code_hash = "Crypt_DES, $des_rounds, {$this->mode}";
    +        }
    +
    +        // Is there a re-usable $lambda_functions in there? If not, we have to create it.
    +        if (!isset($lambda_functions[$code_hash])) {
    +            // Init code for both, encrypt and decrypt.
    +            $init_crypt = 'static $sbox1, $sbox2, $sbox3, $sbox4, $sbox5, $sbox6, $sbox7, $sbox8, $shuffleip, $shuffleinvip;
    +                if (!$sbox1) {
    +                    $sbox1 = array_map("intval", $self->sbox1);
    +                    $sbox2 = array_map("intval", $self->sbox2);
    +                    $sbox3 = array_map("intval", $self->sbox3);
    +                    $sbox4 = array_map("intval", $self->sbox4);
    +                    $sbox5 = array_map("intval", $self->sbox5);
    +                    $sbox6 = array_map("intval", $self->sbox6);
    +                    $sbox7 = array_map("intval", $self->sbox7);
    +                    $sbox8 = array_map("intval", $self->sbox8);'
    +                    /* Merge $shuffle with $[inv]ipmap */ . '
    +                    for ($i = 0; $i < 256; ++$i) {
    +                        $shuffleip[]    =  $self->shuffle[$self->ipmap[$i]];
    +                        $shuffleinvip[] =  $self->shuffle[$self->invipmap[$i]];
    +                    }
    +                }
    +            ';
    +
    +            switch (true) {
    +                case $gen_hi_opt_code:
    +                    // In Hi-optimized code mode, we use our [3]DES key schedule as hardcoded integers.
    +                    // No futher initialisation of the $keys schedule is necessary.
    +                    // That is the extra performance boost.
    +                    $k = array(
    +                        CRYPT_DES_ENCRYPT => $this->keys[CRYPT_DES_ENCRYPT],
    +                        CRYPT_DES_DECRYPT => $this->keys[CRYPT_DES_DECRYPT]
    +                    );
    +                    $init_encrypt = '';
    +                    $init_decrypt = '';
    +                    break;
    +                default:
    +                    // In generic optimized code mode, we have to use, as the best compromise [currently],
    +                    // our key schedule as $ke/$kd arrays. (with hardcoded indexes...)
    +                    $k = array(
    +                        CRYPT_DES_ENCRYPT => array(),
    +                        CRYPT_DES_DECRYPT => array()
    +                    );
    +                    for ($i = 0, $c = count($this->keys[CRYPT_DES_ENCRYPT]); $i < $c; ++$i) {
    +                        $k[CRYPT_DES_ENCRYPT][$i] = '$ke[' . $i . ']';
    +                        $k[CRYPT_DES_DECRYPT][$i] = '$kd[' . $i . ']';
    +                    }
    +                    $init_encrypt = '$ke = $self->keys[CRYPT_DES_ENCRYPT];';
    +                    $init_decrypt = '$kd = $self->keys[CRYPT_DES_DECRYPT];';
    +                    break;
    +            }
    +
    +            // Creating code for en- and decryption.
    +            $crypt_block = array();
    +            foreach (array(CRYPT_DES_ENCRYPT, CRYPT_DES_DECRYPT) as $c) {
    +
    +                /* Do the initial IP permutation. */
    +                $crypt_block[$c] = '
    +                    $in = unpack("N*", $in);
    +                    $l  = $in[1];
    +                    $r  = $in[2];
    +                    $in = unpack("N*",
    +                        ($shuffleip[ $r        & 0xFF] & "\x80\x80\x80\x80\x80\x80\x80\x80") |
    +                        ($shuffleip[($r >>  8) & 0xFF] & "\x40\x40\x40\x40\x40\x40\x40\x40") |
    +                        ($shuffleip[($r >> 16) & 0xFF] & "\x20\x20\x20\x20\x20\x20\x20\x20") |
    +                        ($shuffleip[($r >> 24) & 0xFF] & "\x10\x10\x10\x10\x10\x10\x10\x10") |
    +                        ($shuffleip[ $l        & 0xFF] & "\x08\x08\x08\x08\x08\x08\x08\x08") |
    +                        ($shuffleip[($l >>  8) & 0xFF] & "\x04\x04\x04\x04\x04\x04\x04\x04") |
    +                        ($shuffleip[($l >> 16) & 0xFF] & "\x02\x02\x02\x02\x02\x02\x02\x02") |
    +                        ($shuffleip[($l >> 24) & 0xFF] & "\x01\x01\x01\x01\x01\x01\x01\x01")
    +                    );
    +                    ' . /* Extract L0 and R0 */ '
    +                    $l = $in[1];
    +                    $r = $in[2];
    +                ';
    +
    +                $l = '$l';
    +                $r = '$r';
    +
    +                // Perform DES or 3DES.
    +                for ($ki = -1, $des_round = 0; $des_round < $des_rounds; ++$des_round) {
    +                    // Perform the 16 steps.
    +                    for ($i = 0; $i < 16; ++$i) {
    +                        // start of "the Feistel (F) function" - see the following URL:
    +                        // http://en.wikipedia.org/wiki/Image:Data_Encryption_Standard_InfoBox_Diagram.png
    +                        // Merge key schedule.
    +                        $crypt_block[$c].= '
    +                            $b1 = ((' . $r . ' >>  3) & 0x1FFFFFFF)  ^ (' . $r . ' << 29) ^ ' . $k[$c][++$ki] . ';
    +                            $b2 = ((' . $r . ' >> 31) & 0x00000001)  ^ (' . $r . ' <<  1) ^ ' . $k[$c][++$ki] . ';' .
    +                            /* S-box indexing. */
    +                            $l . ' = $sbox1[($b1 >> 24) & 0x3F] ^ $sbox2[($b2 >> 24) & 0x3F] ^
    +                                     $sbox3[($b1 >> 16) & 0x3F] ^ $sbox4[($b2 >> 16) & 0x3F] ^
    +                                     $sbox5[($b1 >>  8) & 0x3F] ^ $sbox6[($b2 >>  8) & 0x3F] ^
    +                                     $sbox7[ $b1        & 0x3F] ^ $sbox8[ $b2        & 0x3F] ^ ' . $l . ';
    +                        ';
    +                        // end of "the Feistel (F) function"
    +
    +                        // swap L & R
    +                        list($l, $r) = array($r, $l);
    +                    }
    +                    list($l, $r) = array($r, $l);
    +                }
    +
    +                // Perform the inverse IP permutation.
    +                $crypt_block[$c].= '$in =
    +                    ($shuffleinvip[($l >> 24) & 0xFF] & "\x80\x80\x80\x80\x80\x80\x80\x80") |
    +                    ($shuffleinvip[($r >> 24) & 0xFF] & "\x40\x40\x40\x40\x40\x40\x40\x40") |
    +                    ($shuffleinvip[($l >> 16) & 0xFF] & "\x20\x20\x20\x20\x20\x20\x20\x20") |
    +                    ($shuffleinvip[($r >> 16) & 0xFF] & "\x10\x10\x10\x10\x10\x10\x10\x10") |
    +                    ($shuffleinvip[($l >>  8) & 0xFF] & "\x08\x08\x08\x08\x08\x08\x08\x08") |
    +                    ($shuffleinvip[($r >>  8) & 0xFF] & "\x04\x04\x04\x04\x04\x04\x04\x04") |
    +                    ($shuffleinvip[ $l        & 0xFF] & "\x02\x02\x02\x02\x02\x02\x02\x02") |
    +                    ($shuffleinvip[ $r        & 0xFF] & "\x01\x01\x01\x01\x01\x01\x01\x01");
    +                ';
    +            }
    +
    +            // Creates the inline-crypt function
    +            $lambda_functions[$code_hash] = $this->_createInlineCryptFunction(
    +                array(
    +                   'init_crypt'    => $init_crypt,
    +                   'init_encrypt'  => $init_encrypt,
    +                   'init_decrypt'  => $init_decrypt,
    +                   'encrypt_block' => $crypt_block[CRYPT_DES_ENCRYPT],
    +                   'decrypt_block' => $crypt_block[CRYPT_DES_DECRYPT]
    +                )
    +            );
    +        }
    +
    +        // Set the inline-crypt function as callback in: $this->inline_crypt
    +        $this->inline_crypt = $lambda_functions[$code_hash];
    +    }
    +}
    diff --git a/vendor/phpseclib/phpseclib/phpseclib/Crypt/Hash.php b/vendor/phpseclib/phpseclib/phpseclib/Crypt/Hash.php
    new file mode 100755
    index 0000000..b156169
    --- /dev/null
    +++ b/vendor/phpseclib/phpseclib/phpseclib/Crypt/Hash.php
    @@ -0,0 +1,845 @@
    +
    + * setKey('abcdefg');
    + *
    + *    echo base64_encode($hash->hash('abcdefg'));
    + * ?>
    + * 
    + *
    + * LICENSE: Permission is hereby granted, free of charge, to any person obtaining a copy
    + * of this software and associated documentation files (the "Software"), to deal
    + * in the Software without restriction, including without limitation the rights
    + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    + * copies of the Software, and to permit persons to whom the Software is
    + * furnished to do so, subject to the following conditions:
    + *
    + * The above copyright notice and this permission notice shall be included in
    + * all copies or substantial portions of the Software.
    + *
    + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
    + * THE SOFTWARE.
    + *
    + * @category  Crypt
    + * @package   Crypt_Hash
    + * @author    Jim Wigginton 
    + * @copyright MMVII Jim Wigginton
    + * @license   http://www.opensource.org/licenses/mit-license.html  MIT License
    + * @link      http://phpseclib.sourceforge.net
    + */
    +
    +/**#@+
    + * @access private
    + * @see Crypt_Hash::Crypt_Hash()
    + */
    +/**
    + * Toggles the internal implementation
    + */
    +define('CRYPT_HASH_MODE_INTERNAL', 1);
    +/**
    + * Toggles the mhash() implementation, which has been deprecated on PHP 5.3.0+.
    + */
    +define('CRYPT_HASH_MODE_MHASH',    2);
    +/**
    + * Toggles the hash() implementation, which works on PHP 5.1.2+.
    + */
    +define('CRYPT_HASH_MODE_HASH',     3);
    +/**#@-*/
    +
    +/**
    + * Pure-PHP implementations of keyed-hash message authentication codes (HMACs) and various cryptographic hashing functions.
    + *
    + * @package Crypt_Hash
    + * @author  Jim Wigginton 
    + * @version 0.1.0
    + * @access  public
    + */
    +class Crypt_Hash
    +{
    +    /**
    +     * Hash Parameter
    +     *
    +     * @see Crypt_Hash::setHash()
    +     * @var Integer
    +     * @access private
    +     */
    +    var $hashParam;
    +
    +    /**
    +     * Byte-length of compression blocks / key (Internal HMAC)
    +     *
    +     * @see Crypt_Hash::setAlgorithm()
    +     * @var Integer
    +     * @access private
    +     */
    +    var $b;
    +
    +    /**
    +     * Byte-length of hash output (Internal HMAC)
    +     *
    +     * @see Crypt_Hash::setHash()
    +     * @var Integer
    +     * @access private
    +     */
    +    var $l = false;
    +
    +    /**
    +     * Hash Algorithm
    +     *
    +     * @see Crypt_Hash::setHash()
    +     * @var String
    +     * @access private
    +     */
    +    var $hash;
    +
    +    /**
    +     * Key
    +     *
    +     * @see Crypt_Hash::setKey()
    +     * @var String
    +     * @access private
    +     */
    +    var $key = false;
    +
    +    /**
    +     * Outer XOR (Internal HMAC)
    +     *
    +     * @see Crypt_Hash::setKey()
    +     * @var String
    +     * @access private
    +     */
    +    var $opad;
    +
    +    /**
    +     * Inner XOR (Internal HMAC)
    +     *
    +     * @see Crypt_Hash::setKey()
    +     * @var String
    +     * @access private
    +     */
    +    var $ipad;
    +
    +    /**
    +     * Default Constructor.
    +     *
    +     * @param optional String $hash
    +     * @return Crypt_Hash
    +     * @access public
    +     */
    +    function Crypt_Hash($hash = 'sha1')
    +    {
    +        if ( !defined('CRYPT_HASH_MODE') ) {
    +            switch (true) {
    +                case extension_loaded('hash'):
    +                    define('CRYPT_HASH_MODE', CRYPT_HASH_MODE_HASH);
    +                    break;
    +                case extension_loaded('mhash'):
    +                    define('CRYPT_HASH_MODE', CRYPT_HASH_MODE_MHASH);
    +                    break;
    +                default:
    +                    define('CRYPT_HASH_MODE', CRYPT_HASH_MODE_INTERNAL);
    +            }
    +        }
    +
    +        $this->setHash($hash);
    +    }
    +
    +    /**
    +     * Sets the key for HMACs
    +     *
    +     * Keys can be of any length.
    +     *
    +     * @access public
    +     * @param optional String $key
    +     */
    +    function setKey($key = false)
    +    {
    +        $this->key = $key;
    +    }
    +
    +    /**
    +     * Gets the hash function.
    +     *
    +     * As set by the constructor or by the setHash() method.
    +     *
    +     * @access public
    +     * @return String
    +     */
    +    function getHash()
    +    {
    +        return $this->hashParam;
    +    }
    +
    +    /**
    +     * Sets the hash function.
    +     *
    +     * @access public
    +     * @param String $hash
    +     */
    +    function setHash($hash)
    +    {
    +        $this->hashParam = $hash = strtolower($hash);
    +        switch ($hash) {
    +            case 'md5-96':
    +            case 'sha1-96':
    +                $this->l = 12; // 96 / 8 = 12
    +                break;
    +            case 'md2':
    +            case 'md5':
    +                $this->l = 16;
    +                break;
    +            case 'sha1':
    +                $this->l = 20;
    +                break;
    +            case 'sha256':
    +                $this->l = 32;
    +                break;
    +            case 'sha384':
    +                $this->l = 48;
    +                break;
    +            case 'sha512':
    +                $this->l = 64;
    +        }
    +
    +        switch ($hash) {
    +            case 'md2':
    +                $mode = CRYPT_HASH_MODE == CRYPT_HASH_MODE_HASH && in_array('md2', hash_algos()) ?
    +                    CRYPT_HASH_MODE_HASH : CRYPT_HASH_MODE_INTERNAL;
    +                break;
    +            case 'sha384':
    +            case 'sha512':
    +                $mode = CRYPT_HASH_MODE == CRYPT_HASH_MODE_MHASH ? CRYPT_HASH_MODE_INTERNAL : CRYPT_HASH_MODE;
    +                break;
    +            default:
    +                $mode = CRYPT_HASH_MODE;
    +        }
    +
    +        switch ( $mode ) {
    +            case CRYPT_HASH_MODE_MHASH:
    +                switch ($hash) {
    +                    case 'md5':
    +                    case 'md5-96':
    +                        $this->hash = MHASH_MD5;
    +                        break;
    +                    case 'sha256':
    +                        $this->hash = MHASH_SHA256;
    +                        break;
    +                    case 'sha1':
    +                    case 'sha1-96':
    +                    default:
    +                        $this->hash = MHASH_SHA1;
    +                }
    +                return;
    +            case CRYPT_HASH_MODE_HASH:
    +                switch ($hash) {
    +                    case 'md5':
    +                    case 'md5-96':
    +                        $this->hash = 'md5';
    +                        return;
    +                    case 'md2':
    +                    case 'sha256':
    +                    case 'sha384':
    +                    case 'sha512':
    +                        $this->hash = $hash;
    +                        return;
    +                    case 'sha1':
    +                    case 'sha1-96':
    +                    default:
    +                        $this->hash = 'sha1';
    +                }
    +                return;
    +        }
    +
    +        switch ($hash) {
    +            case 'md2':
    +                 $this->b = 16;
    +                 $this->hash = array($this, '_md2');
    +                 break;
    +            case 'md5':
    +            case 'md5-96':
    +                 $this->b = 64;
    +                 $this->hash = array($this, '_md5');
    +                 break;
    +            case 'sha256':
    +                 $this->b = 64;
    +                 $this->hash = array($this, '_sha256');
    +                 break;
    +            case 'sha384':
    +            case 'sha512':
    +                 $this->b = 128;
    +                 $this->hash = array($this, '_sha512');
    +                 break;
    +            case 'sha1':
    +            case 'sha1-96':
    +            default:
    +                 $this->b = 64;
    +                 $this->hash = array($this, '_sha1');
    +        }
    +
    +        $this->ipad = str_repeat(chr(0x36), $this->b);
    +        $this->opad = str_repeat(chr(0x5C), $this->b);
    +    }
    +
    +    /**
    +     * Compute the HMAC.
    +     *
    +     * @access public
    +     * @param String $text
    +     * @return String
    +     */
    +    function hash($text)
    +    {
    +        $mode = is_array($this->hash) ? CRYPT_HASH_MODE_INTERNAL : CRYPT_HASH_MODE;
    +
    +        if (!empty($this->key) || is_string($this->key)) {
    +            switch ( $mode ) {
    +                case CRYPT_HASH_MODE_MHASH:
    +                    $output = mhash($this->hash, $text, $this->key);
    +                    break;
    +                case CRYPT_HASH_MODE_HASH:
    +                    $output = hash_hmac($this->hash, $text, $this->key, true);
    +                    break;
    +                case CRYPT_HASH_MODE_INTERNAL:
    +                    /* "Applications that use keys longer than B bytes will first hash the key using H and then use the
    +                        resultant L byte string as the actual key to HMAC."
    +
    +                        -- http://tools.ietf.org/html/rfc2104#section-2 */
    +                    $key = strlen($this->key) > $this->b ? call_user_func($this->hash, $this->key) : $this->key;
    +
    +                    $key    = str_pad($key, $this->b, chr(0));      // step 1
    +                    $temp   = $this->ipad ^ $key;                   // step 2
    +                    $temp  .= $text;                                // step 3
    +                    $temp   = call_user_func($this->hash, $temp);   // step 4
    +                    $output = $this->opad ^ $key;                   // step 5
    +                    $output.= $temp;                                // step 6
    +                    $output = call_user_func($this->hash, $output); // step 7
    +            }
    +        } else {
    +            switch ( $mode ) {
    +                case CRYPT_HASH_MODE_MHASH:
    +                    $output = mhash($this->hash, $text);
    +                    break;
    +                case CRYPT_HASH_MODE_HASH:
    +                    $output = hash($this->hash, $text, true);
    +                    break;
    +                case CRYPT_HASH_MODE_INTERNAL:
    +                    $output = call_user_func($this->hash, $text);
    +            }
    +        }
    +
    +        return substr($output, 0, $this->l);
    +    }
    +
    +    /**
    +     * Returns the hash length (in bytes)
    +     *
    +     * @access public
    +     * @return Integer
    +     */
    +    function getLength()
    +    {
    +        return $this->l;
    +    }
    +
    +    /**
    +     * Wrapper for MD5
    +     *
    +     * @access private
    +     * @param String $m
    +     */
    +    function _md5($m)
    +    {
    +        return pack('H*', md5($m));
    +    }
    +
    +    /**
    +     * Wrapper for SHA1
    +     *
    +     * @access private
    +     * @param String $m
    +     */
    +    function _sha1($m)
    +    {
    +        return pack('H*', sha1($m));
    +    }
    +
    +    /**
    +     * Pure-PHP implementation of MD2
    +     *
    +     * See {@link http://tools.ietf.org/html/rfc1319 RFC1319}.
    +     *
    +     * @access private
    +     * @param String $m
    +     */
    +    function _md2($m)
    +    {
    +        static $s = array(
    +             41,  46,  67, 201, 162, 216, 124,   1,  61,  54,  84, 161, 236, 240, 6,
    +             19,  98, 167,   5, 243, 192, 199, 115, 140, 152, 147,  43, 217, 188,
    +             76, 130, 202,  30, 155,  87,  60, 253, 212, 224,  22, 103,  66, 111, 24,
    +            138,  23, 229,  18, 190,  78, 196, 214, 218, 158, 222,  73, 160, 251,
    +            245, 142, 187,  47, 238, 122, 169, 104, 121, 145,  21, 178,   7,  63,
    +            148, 194,  16, 137,  11,  34,  95,  33, 128, 127,  93, 154,  90, 144, 50,
    +             39,  53,  62, 204, 231, 191, 247, 151,   3, 255,  25,  48, 179,  72, 165,
    +            181, 209, 215,  94, 146,  42, 172,  86, 170, 198,  79, 184,  56, 210,
    +            150, 164, 125, 182, 118, 252, 107, 226, 156, 116,   4, 241,  69, 157,
    +            112,  89, 100, 113, 135,  32, 134,  91, 207, 101, 230,  45, 168,   2, 27,
    +             96,  37, 173, 174, 176, 185, 246,  28,  70,  97, 105,  52,  64, 126, 15,
    +             85,  71, 163,  35, 221,  81, 175,  58, 195,  92, 249, 206, 186, 197,
    +            234,  38,  44,  83,  13, 110, 133,  40, 132,   9, 211, 223, 205, 244, 65,
    +            129,  77,  82, 106, 220,  55, 200, 108, 193, 171, 250,  36, 225, 123,
    +              8,  12, 189, 177,  74, 120, 136, 149, 139, 227,  99, 232, 109, 233,
    +            203, 213, 254,  59,   0,  29,  57, 242, 239, 183,  14, 102,  88, 208, 228,
    +            166, 119, 114, 248, 235, 117,  75,  10,  49,  68,  80, 180, 143, 237,
    +             31,  26, 219, 153, 141,  51, 159,  17, 131, 20
    +        );
    +
    +        // Step 1. Append Padding Bytes
    +        $pad = 16 - (strlen($m) & 0xF);
    +        $m.= str_repeat(chr($pad), $pad);
    +
    +        $length = strlen($m);
    +
    +        // Step 2. Append Checksum
    +        $c = str_repeat(chr(0), 16);
    +        $l = chr(0);
    +        for ($i = 0; $i < $length; $i+= 16) {
    +            for ($j = 0; $j < 16; $j++) {
    +                // RFC1319 incorrectly states that C[j] should be set to S[c xor L]
    +                //$c[$j] = chr($s[ord($m[$i + $j] ^ $l)]);
    +                // per , however, C[j] should be set to S[c xor L] xor C[j]
    +                $c[$j] = chr($s[ord($m[$i + $j] ^ $l)] ^ ord($c[$j]));
    +                $l = $c[$j];
    +            }
    +        }
    +        $m.= $c;
    +
    +        $length+= 16;
    +
    +        // Step 3. Initialize MD Buffer
    +        $x = str_repeat(chr(0), 48);
    +
    +        // Step 4. Process Message in 16-Byte Blocks
    +        for ($i = 0; $i < $length; $i+= 16) {
    +            for ($j = 0; $j < 16; $j++) {
    +                $x[$j + 16] = $m[$i + $j];
    +                $x[$j + 32] = $x[$j + 16] ^ $x[$j];
    +            }
    +            $t = chr(0);
    +            for ($j = 0; $j < 18; $j++) {
    +                for ($k = 0; $k < 48; $k++) {
    +                    $x[$k] = $t = $x[$k] ^ chr($s[ord($t)]);
    +                    //$t = $x[$k] = $x[$k] ^ chr($s[ord($t)]);
    +                }
    +                $t = chr(ord($t) + $j);
    +            }
    +        }
    +
    +        // Step 5. Output
    +        return substr($x, 0, 16);
    +    }
    +
    +    /**
    +     * Pure-PHP implementation of SHA256
    +     *
    +     * See {@link http://en.wikipedia.org/wiki/SHA_hash_functions#SHA-256_.28a_SHA-2_variant.29_pseudocode SHA-256 (a SHA-2 variant) pseudocode - Wikipedia}.
    +     *
    +     * @access private
    +     * @param String $m
    +     */
    +    function _sha256($m)
    +    {
    +        if (extension_loaded('suhosin')) {
    +            return pack('H*', sha256($m));
    +        }
    +
    +        // Initialize variables
    +        $hash = array(
    +            0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19
    +        );
    +        // Initialize table of round constants
    +        // (first 32 bits of the fractional parts of the cube roots of the first 64 primes 2..311)
    +        static $k = array(
    +            0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
    +            0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
    +            0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
    +            0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
    +            0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
    +            0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
    +            0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
    +            0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2
    +        );
    +
    +        // Pre-processing
    +        $length = strlen($m);
    +        // to round to nearest 56 mod 64, we'll add 64 - (length + (64 - 56)) % 64
    +        $m.= str_repeat(chr(0), 64 - (($length + 8) & 0x3F));
    +        $m[$length] = chr(0x80);
    +        // we don't support hashing strings 512MB long
    +        $m.= pack('N2', 0, $length << 3);
    +
    +        // Process the message in successive 512-bit chunks
    +        $chunks = str_split($m, 64);
    +        foreach ($chunks as $chunk) {
    +            $w = array();
    +            for ($i = 0; $i < 16; $i++) {
    +                extract(unpack('Ntemp', $this->_string_shift($chunk, 4)));
    +                $w[] = $temp;
    +            }
    +
    +            // Extend the sixteen 32-bit words into sixty-four 32-bit words
    +            for ($i = 16; $i < 64; $i++) {
    +                $s0 = $this->_rightRotate($w[$i - 15],  7) ^
    +                      $this->_rightRotate($w[$i - 15], 18) ^
    +                      $this->_rightShift( $w[$i - 15],  3);
    +                $s1 = $this->_rightRotate($w[$i - 2], 17) ^
    +                      $this->_rightRotate($w[$i - 2], 19) ^
    +                      $this->_rightShift( $w[$i - 2], 10);
    +                $w[$i] = $this->_add($w[$i - 16], $s0, $w[$i - 7], $s1);
    +
    +            }
    +
    +            // Initialize hash value for this chunk
    +            list($a, $b, $c, $d, $e, $f, $g, $h) = $hash;
    +
    +            // Main loop
    +            for ($i = 0; $i < 64; $i++) {
    +                $s0 = $this->_rightRotate($a,  2) ^
    +                      $this->_rightRotate($a, 13) ^
    +                      $this->_rightRotate($a, 22);
    +                $maj = ($a & $b) ^
    +                       ($a & $c) ^
    +                       ($b & $c);
    +                $t2 = $this->_add($s0, $maj);
    +
    +                $s1 = $this->_rightRotate($e,  6) ^
    +                      $this->_rightRotate($e, 11) ^
    +                      $this->_rightRotate($e, 25);
    +                $ch = ($e & $f) ^
    +                      ($this->_not($e) & $g);
    +                $t1 = $this->_add($h, $s1, $ch, $k[$i], $w[$i]);
    +
    +                $h = $g;
    +                $g = $f;
    +                $f = $e;
    +                $e = $this->_add($d, $t1);
    +                $d = $c;
    +                $c = $b;
    +                $b = $a;
    +                $a = $this->_add($t1, $t2);
    +            }
    +
    +            // Add this chunk's hash to result so far
    +            $hash = array(
    +                $this->_add($hash[0], $a),
    +                $this->_add($hash[1], $b),
    +                $this->_add($hash[2], $c),
    +                $this->_add($hash[3], $d),
    +                $this->_add($hash[4], $e),
    +                $this->_add($hash[5], $f),
    +                $this->_add($hash[6], $g),
    +                $this->_add($hash[7], $h)
    +            );
    +        }
    +
    +        // Produce the final hash value (big-endian)
    +        return pack('N8', $hash[0], $hash[1], $hash[2], $hash[3], $hash[4], $hash[5], $hash[6], $hash[7]);
    +    }
    +
    +    /**
    +     * Pure-PHP implementation of SHA384 and SHA512
    +     *
    +     * @access private
    +     * @param String $m
    +     */
    +    function _sha512($m)
    +    {
    +        if (!class_exists('Math_BigInteger')) {
    +            include_once 'Math/BigInteger.php';
    +        }
    +
    +        static $init384, $init512, $k;
    +
    +        if (!isset($k)) {
    +            // Initialize variables
    +            $init384 = array( // initial values for SHA384
    +                'cbbb9d5dc1059ed8', '629a292a367cd507', '9159015a3070dd17', '152fecd8f70e5939',
    +                '67332667ffc00b31', '8eb44a8768581511', 'db0c2e0d64f98fa7', '47b5481dbefa4fa4'
    +            );
    +            $init512 = array( // initial values for SHA512
    +                '6a09e667f3bcc908', 'bb67ae8584caa73b', '3c6ef372fe94f82b', 'a54ff53a5f1d36f1',
    +                '510e527fade682d1', '9b05688c2b3e6c1f', '1f83d9abfb41bd6b', '5be0cd19137e2179'
    +            );
    +
    +            for ($i = 0; $i < 8; $i++) {
    +                $init384[$i] = new Math_BigInteger($init384[$i], 16);
    +                $init384[$i]->setPrecision(64);
    +                $init512[$i] = new Math_BigInteger($init512[$i], 16);
    +                $init512[$i]->setPrecision(64);
    +            }
    +
    +            // Initialize table of round constants
    +            // (first 64 bits of the fractional parts of the cube roots of the first 80 primes 2..409)
    +            $k = array(
    +                '428a2f98d728ae22', '7137449123ef65cd', 'b5c0fbcfec4d3b2f', 'e9b5dba58189dbbc',
    +                '3956c25bf348b538', '59f111f1b605d019', '923f82a4af194f9b', 'ab1c5ed5da6d8118',
    +                'd807aa98a3030242', '12835b0145706fbe', '243185be4ee4b28c', '550c7dc3d5ffb4e2',
    +                '72be5d74f27b896f', '80deb1fe3b1696b1', '9bdc06a725c71235', 'c19bf174cf692694',
    +                'e49b69c19ef14ad2', 'efbe4786384f25e3', '0fc19dc68b8cd5b5', '240ca1cc77ac9c65',
    +                '2de92c6f592b0275', '4a7484aa6ea6e483', '5cb0a9dcbd41fbd4', '76f988da831153b5',
    +                '983e5152ee66dfab', 'a831c66d2db43210', 'b00327c898fb213f', 'bf597fc7beef0ee4',
    +                'c6e00bf33da88fc2', 'd5a79147930aa725', '06ca6351e003826f', '142929670a0e6e70',
    +                '27b70a8546d22ffc', '2e1b21385c26c926', '4d2c6dfc5ac42aed', '53380d139d95b3df',
    +                '650a73548baf63de', '766a0abb3c77b2a8', '81c2c92e47edaee6', '92722c851482353b',
    +                'a2bfe8a14cf10364', 'a81a664bbc423001', 'c24b8b70d0f89791', 'c76c51a30654be30',
    +                'd192e819d6ef5218', 'd69906245565a910', 'f40e35855771202a', '106aa07032bbd1b8',
    +                '19a4c116b8d2d0c8', '1e376c085141ab53', '2748774cdf8eeb99', '34b0bcb5e19b48a8',
    +                '391c0cb3c5c95a63', '4ed8aa4ae3418acb', '5b9cca4f7763e373', '682e6ff3d6b2b8a3',
    +                '748f82ee5defb2fc', '78a5636f43172f60', '84c87814a1f0ab72', '8cc702081a6439ec',
    +                '90befffa23631e28', 'a4506cebde82bde9', 'bef9a3f7b2c67915', 'c67178f2e372532b',
    +                'ca273eceea26619c', 'd186b8c721c0c207', 'eada7dd6cde0eb1e', 'f57d4f7fee6ed178',
    +                '06f067aa72176fba', '0a637dc5a2c898a6', '113f9804bef90dae', '1b710b35131c471b',
    +                '28db77f523047d84', '32caab7b40c72493', '3c9ebe0a15c9bebc', '431d67c49c100d4c',
    +                '4cc5d4becb3e42b6', '597f299cfc657e2a', '5fcb6fab3ad6faec', '6c44198c4a475817'
    +            );
    +
    +            for ($i = 0; $i < 80; $i++) {
    +                $k[$i] = new Math_BigInteger($k[$i], 16);
    +            }
    +        }
    +
    +        $hash = $this->l == 48 ? $init384 : $init512;
    +
    +        // Pre-processing
    +        $length = strlen($m);
    +        // to round to nearest 112 mod 128, we'll add 128 - (length + (128 - 112)) % 128
    +        $m.= str_repeat(chr(0), 128 - (($length + 16) & 0x7F));
    +        $m[$length] = chr(0x80);
    +        // we don't support hashing strings 512MB long
    +        $m.= pack('N4', 0, 0, 0, $length << 3);
    +
    +        // Process the message in successive 1024-bit chunks
    +        $chunks = str_split($m, 128);
    +        foreach ($chunks as $chunk) {
    +            $w = array();
    +            for ($i = 0; $i < 16; $i++) {
    +                $temp = new Math_BigInteger($this->_string_shift($chunk, 8), 256);
    +                $temp->setPrecision(64);
    +                $w[] = $temp;
    +            }
    +
    +            // Extend the sixteen 32-bit words into eighty 32-bit words
    +            for ($i = 16; $i < 80; $i++) {
    +                $temp = array(
    +                          $w[$i - 15]->bitwise_rightRotate(1),
    +                          $w[$i - 15]->bitwise_rightRotate(8),
    +                          $w[$i - 15]->bitwise_rightShift(7)
    +                );
    +                $s0 = $temp[0]->bitwise_xor($temp[1]);
    +                $s0 = $s0->bitwise_xor($temp[2]);
    +                $temp = array(
    +                          $w[$i - 2]->bitwise_rightRotate(19),
    +                          $w[$i - 2]->bitwise_rightRotate(61),
    +                          $w[$i - 2]->bitwise_rightShift(6)
    +                );
    +                $s1 = $temp[0]->bitwise_xor($temp[1]);
    +                $s1 = $s1->bitwise_xor($temp[2]);
    +                $w[$i] = $w[$i - 16]->copy();
    +                $w[$i] = $w[$i]->add($s0);
    +                $w[$i] = $w[$i]->add($w[$i - 7]);
    +                $w[$i] = $w[$i]->add($s1);
    +            }
    +
    +            // Initialize hash value for this chunk
    +            $a = $hash[0]->copy();
    +            $b = $hash[1]->copy();
    +            $c = $hash[2]->copy();
    +            $d = $hash[3]->copy();
    +            $e = $hash[4]->copy();
    +            $f = $hash[5]->copy();
    +            $g = $hash[6]->copy();
    +            $h = $hash[7]->copy();
    +
    +            // Main loop
    +            for ($i = 0; $i < 80; $i++) {
    +                $temp = array(
    +                    $a->bitwise_rightRotate(28),
    +                    $a->bitwise_rightRotate(34),
    +                    $a->bitwise_rightRotate(39)
    +                );
    +                $s0 = $temp[0]->bitwise_xor($temp[1]);
    +                $s0 = $s0->bitwise_xor($temp[2]);
    +                $temp = array(
    +                    $a->bitwise_and($b),
    +                    $a->bitwise_and($c),
    +                    $b->bitwise_and($c)
    +                );
    +                $maj = $temp[0]->bitwise_xor($temp[1]);
    +                $maj = $maj->bitwise_xor($temp[2]);
    +                $t2 = $s0->add($maj);
    +
    +                $temp = array(
    +                    $e->bitwise_rightRotate(14),
    +                    $e->bitwise_rightRotate(18),
    +                    $e->bitwise_rightRotate(41)
    +                );
    +                $s1 = $temp[0]->bitwise_xor($temp[1]);
    +                $s1 = $s1->bitwise_xor($temp[2]);
    +                $temp = array(
    +                    $e->bitwise_and($f),
    +                    $g->bitwise_and($e->bitwise_not())
    +                );
    +                $ch = $temp[0]->bitwise_xor($temp[1]);
    +                $t1 = $h->add($s1);
    +                $t1 = $t1->add($ch);
    +                $t1 = $t1->add($k[$i]);
    +                $t1 = $t1->add($w[$i]);
    +
    +                $h = $g->copy();
    +                $g = $f->copy();
    +                $f = $e->copy();
    +                $e = $d->add($t1);
    +                $d = $c->copy();
    +                $c = $b->copy();
    +                $b = $a->copy();
    +                $a = $t1->add($t2);
    +            }
    +
    +            // Add this chunk's hash to result so far
    +            $hash = array(
    +                $hash[0]->add($a),
    +                $hash[1]->add($b),
    +                $hash[2]->add($c),
    +                $hash[3]->add($d),
    +                $hash[4]->add($e),
    +                $hash[5]->add($f),
    +                $hash[6]->add($g),
    +                $hash[7]->add($h)
    +            );
    +        }
    +
    +        // Produce the final hash value (big-endian)
    +        // (Crypt_Hash::hash() trims the output for hashes but not for HMACs.  as such, we trim the output here)
    +        $temp = $hash[0]->toBytes() . $hash[1]->toBytes() . $hash[2]->toBytes() . $hash[3]->toBytes() .
    +                $hash[4]->toBytes() . $hash[5]->toBytes();
    +        if ($this->l != 48) {
    +            $temp.= $hash[6]->toBytes() . $hash[7]->toBytes();
    +        }
    +
    +        return $temp;
    +    }
    +
    +    /**
    +     * Right Rotate
    +     *
    +     * @access private
    +     * @param Integer $int
    +     * @param Integer $amt
    +     * @see _sha256()
    +     * @return Integer
    +     */
    +    function _rightRotate($int, $amt)
    +    {
    +        $invamt = 32 - $amt;
    +        $mask = (1 << $invamt) - 1;
    +        return (($int << $invamt) & 0xFFFFFFFF) | (($int >> $amt) & $mask);
    +    }
    +
    +    /**
    +     * Right Shift
    +     *
    +     * @access private
    +     * @param Integer $int
    +     * @param Integer $amt
    +     * @see _sha256()
    +     * @return Integer
    +     */
    +    function _rightShift($int, $amt)
    +    {
    +        $mask = (1 << (32 - $amt)) - 1;
    +        return ($int >> $amt) & $mask;
    +    }
    +
    +    /**
    +     * Not
    +     *
    +     * @access private
    +     * @param Integer $int
    +     * @see _sha256()
    +     * @return Integer
    +     */
    +    function _not($int)
    +    {
    +        return ~$int & 0xFFFFFFFF;
    +    }
    +
    +    /**
    +     * Add
    +     *
    +     * _sha256() adds multiple unsigned 32-bit integers.  Since PHP doesn't support unsigned integers and since the
    +     * possibility of overflow exists, care has to be taken.  Math_BigInteger() could be used but this should be faster.
    +     *
    +     * @param Integer $...
    +     * @return Integer
    +     * @see _sha256()
    +     * @access private
    +     */
    +    function _add()
    +    {
    +        static $mod;
    +        if (!isset($mod)) {
    +            $mod = pow(2, 32);
    +        }
    +
    +        $result = 0;
    +        $arguments = func_get_args();
    +        foreach ($arguments as $argument) {
    +            $result+= $argument < 0 ? ($argument & 0x7FFFFFFF) + 0x80000000 : $argument;
    +        }
    +
    +        return fmod($result, $mod);
    +    }
    +
    +    /**
    +     * String Shift
    +     *
    +     * Inspired by array_shift
    +     *
    +     * @param String $string
    +     * @param optional Integer $index
    +     * @return String
    +     * @access private
    +     */
    +    function _string_shift(&$string, $index = 1)
    +    {
    +        $substr = substr($string, 0, $index);
    +        $string = substr($string, $index);
    +        return $substr;
    +    }
    +}
    diff --git a/vendor/phpseclib/phpseclib/phpseclib/Crypt/RC2.php b/vendor/phpseclib/phpseclib/phpseclib/Crypt/RC2.php
    new file mode 100755
    index 0000000..de22d63
    --- /dev/null
    +++ b/vendor/phpseclib/phpseclib/phpseclib/Crypt/RC2.php
    @@ -0,0 +1,653 @@
    +
    + * setKey('abcdefgh');
    + *
    + *    $plaintext = str_repeat('a', 1024);
    + *
    + *    echo $rc2->decrypt($rc2->encrypt($plaintext));
    + * ?>
    + * 
    + *
    + * LICENSE: Permission is hereby granted, free of charge, to any person obtaining a copy
    + * of this software and associated documentation files (the "Software"), to deal
    + * in the Software without restriction, including without limitation the rights
    + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    + * copies of the Software, and to permit persons to whom the Software is
    + * furnished to do so, subject to the following conditions:
    + *
    + * The above copyright notice and this permission notice shall be included in
    + * all copies or substantial portions of the Software.
    + *
    + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
    + * THE SOFTWARE.
    + *
    + * @category Crypt
    + * @package  Crypt_RC2
    + * @author   Patrick Monnerat 
    + * @license  http://www.opensource.org/licenses/mit-license.html  MIT License
    + * @link     http://phpseclib.sourceforge.net
    + */
    +
    +/**
    + * Include Crypt_Base
    + *
    + * Base cipher class
    + */
    +if (!class_exists('Crypt_Base')) {
    +    include_once 'Base.php';
    +}
    +
    +/**#@+
    + * @access public
    + * @see Crypt_RC2::encrypt()
    + * @see Crypt_RC2::decrypt()
    + */
    +/**
    + * Encrypt / decrypt using the Counter mode.
    + *
    + * Set to -1 since that's what Crypt/Random.php uses to index the CTR mode.
    + *
    + * @link http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation#Counter_.28CTR.29
    + */
    +define('CRYPT_RC2_MODE_CTR', CRYPT_MODE_CTR);
    +/**
    + * Encrypt / decrypt using the Electronic Code Book mode.
    + *
    + * @link http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation#Electronic_codebook_.28ECB.29
    + */
    +define('CRYPT_RC2_MODE_ECB', CRYPT_MODE_ECB);
    +/**
    + * Encrypt / decrypt using the Code Book Chaining mode.
    + *
    + * @link http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation#Cipher-block_chaining_.28CBC.29
    + */
    +define('CRYPT_RC2_MODE_CBC', CRYPT_MODE_CBC);
    +/**
    + * Encrypt / decrypt using the Cipher Feedback mode.
    + *
    + * @link http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation#Cipher_feedback_.28CFB.29
    + */
    +define('CRYPT_RC2_MODE_CFB', CRYPT_MODE_CFB);
    +/**
    + * Encrypt / decrypt using the Cipher Feedback mode.
    + *
    + * @link http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation#Output_feedback_.28OFB.29
    + */
    +define('CRYPT_RC2_MODE_OFB', CRYPT_MODE_OFB);
    +/**#@-*/
    +
    +/**#@+
    + * @access private
    + * @see Crypt_RC2::Crypt_RC2()
    + */
    +/**
    + * Toggles the internal implementation
    + */
    +define('CRYPT_RC2_MODE_INTERNAL', CRYPT_MODE_INTERNAL);
    +/**
    + * Toggles the mcrypt implementation
    + */
    +define('CRYPT_RC2_MODE_MCRYPT', CRYPT_MODE_MCRYPT);
    +/**#@-*/
    +
    +/**
    + * Pure-PHP implementation of RC2.
    + *
    + * @package Crypt_RC2
    + * @version 0.1.1
    + * @access  public
    + */
    +class Crypt_RC2 extends Crypt_Base
    +{
    +    /**
    +     * Block Length of the cipher
    +     *
    +     * @see Crypt_Base::block_size
    +     * @var Integer
    +     * @access private
    +     */
    +    var $block_size = 8;
    +
    +    /**
    +     * The Key
    +     *
    +     * @see Crypt_Base::key
    +     * @see setKey()
    +     * @var String
    +     * @access private
    +     */
    +    var $key = "\0";
    +
    +    /**
    +     * The default password key_size used by setPassword()
    +     *
    +     * @see Crypt_Base::password_key_size
    +     * @see Crypt_Base::setPassword()
    +     * @var Integer
    +     * @access private
    +     */
    +    var $password_key_size = 16; // = 128 bits
    +
    +    /**
    +     * The namespace used by the cipher for its constants.
    +     *
    +     * @see Crypt_Base::const_namespace
    +     * @var String
    +     * @access private
    +     */
    +    var $const_namespace = 'RC2';
    +
    +    /**
    +     * The mcrypt specific name of the cipher
    +     *
    +     * @see Crypt_Base::cipher_name_mcrypt
    +     * @var String
    +     * @access private
    +     */
    +    var $cipher_name_mcrypt = 'rc2';
    +
    +    /**
    +     * Optimizing value while CFB-encrypting
    +     *
    +     * @see Crypt_Base::cfb_init_len
    +     * @var Integer
    +     * @access private
    +     */
    +    var $cfb_init_len = 500;
    +
    +/**
    +     * The key length in bits.
    +     *
    +     * @see Crypt_RC2::setKeyLength()
    +     * @see Crypt_RC2::setKey()
    +     * @var Integer
    +     * @access private
    +     * @internal Should be in range [1..1024].
    +     * @internal Changing this value after setting the key has no effect.
    +     */
    +    var $default_key_length = 1024;
    +
    +    /**
    +     * The Key Schedule
    +     *
    +     * @see Crypt_RC2::_setupKey()
    +     * @var Array
    +     * @access private
    +     */
    +    var $keys;
    +
    +    /**
    +     * Key expansion randomization table.
    +     * Twice the same 256-value sequence to save a modulus in key expansion.
    +     *
    +     * @see Crypt_RC2::setKey()
    +     * @var Array
    +     * @access private
    +     */
    +    var $pitable = array(
    +        0xD9, 0x78, 0xF9, 0xC4, 0x19, 0xDD, 0xB5, 0xED,
    +        0x28, 0xE9, 0xFD, 0x79, 0x4A, 0xA0, 0xD8, 0x9D,
    +        0xC6, 0x7E, 0x37, 0x83, 0x2B, 0x76, 0x53, 0x8E,
    +        0x62, 0x4C, 0x64, 0x88, 0x44, 0x8B, 0xFB, 0xA2,
    +        0x17, 0x9A, 0x59, 0xF5, 0x87, 0xB3, 0x4F, 0x13,
    +        0x61, 0x45, 0x6D, 0x8D, 0x09, 0x81, 0x7D, 0x32,
    +        0xBD, 0x8F, 0x40, 0xEB, 0x86, 0xB7, 0x7B, 0x0B,
    +        0xF0, 0x95, 0x21, 0x22, 0x5C, 0x6B, 0x4E, 0x82,
    +        0x54, 0xD6, 0x65, 0x93, 0xCE, 0x60, 0xB2, 0x1C,
    +        0x73, 0x56, 0xC0, 0x14, 0xA7, 0x8C, 0xF1, 0xDC,
    +        0x12, 0x75, 0xCA, 0x1F, 0x3B, 0xBE, 0xE4, 0xD1,
    +        0x42, 0x3D, 0xD4, 0x30, 0xA3, 0x3C, 0xB6, 0x26,
    +        0x6F, 0xBF, 0x0E, 0xDA, 0x46, 0x69, 0x07, 0x57,
    +        0x27, 0xF2, 0x1D, 0x9B, 0xBC, 0x94, 0x43, 0x03,
    +        0xF8, 0x11, 0xC7, 0xF6, 0x90, 0xEF, 0x3E, 0xE7,
    +        0x06, 0xC3, 0xD5, 0x2F, 0xC8, 0x66, 0x1E, 0xD7,
    +        0x08, 0xE8, 0xEA, 0xDE, 0x80, 0x52, 0xEE, 0xF7,
    +        0x84, 0xAA, 0x72, 0xAC, 0x35, 0x4D, 0x6A, 0x2A,
    +        0x96, 0x1A, 0xD2, 0x71, 0x5A, 0x15, 0x49, 0x74,
    +        0x4B, 0x9F, 0xD0, 0x5E, 0x04, 0x18, 0xA4, 0xEC,
    +        0xC2, 0xE0, 0x41, 0x6E, 0x0F, 0x51, 0xCB, 0xCC,
    +        0x24, 0x91, 0xAF, 0x50, 0xA1, 0xF4, 0x70, 0x39,
    +        0x99, 0x7C, 0x3A, 0x85, 0x23, 0xB8, 0xB4, 0x7A,
    +        0xFC, 0x02, 0x36, 0x5B, 0x25, 0x55, 0x97, 0x31,
    +        0x2D, 0x5D, 0xFA, 0x98, 0xE3, 0x8A, 0x92, 0xAE,
    +        0x05, 0xDF, 0x29, 0x10, 0x67, 0x6C, 0xBA, 0xC9,
    +        0xD3, 0x00, 0xE6, 0xCF, 0xE1, 0x9E, 0xA8, 0x2C,
    +        0x63, 0x16, 0x01, 0x3F, 0x58, 0xE2, 0x89, 0xA9,
    +        0x0D, 0x38, 0x34, 0x1B, 0xAB, 0x33, 0xFF, 0xB0,
    +        0xBB, 0x48, 0x0C, 0x5F, 0xB9, 0xB1, 0xCD, 0x2E,
    +        0xC5, 0xF3, 0xDB, 0x47, 0xE5, 0xA5, 0x9C, 0x77,
    +        0x0A, 0xA6, 0x20, 0x68, 0xFE, 0x7F, 0xC1, 0xAD,
    +        0xD9, 0x78, 0xF9, 0xC4, 0x19, 0xDD, 0xB5, 0xED,
    +        0x28, 0xE9, 0xFD, 0x79, 0x4A, 0xA0, 0xD8, 0x9D,
    +        0xC6, 0x7E, 0x37, 0x83, 0x2B, 0x76, 0x53, 0x8E,
    +        0x62, 0x4C, 0x64, 0x88, 0x44, 0x8B, 0xFB, 0xA2,
    +        0x17, 0x9A, 0x59, 0xF5, 0x87, 0xB3, 0x4F, 0x13,
    +        0x61, 0x45, 0x6D, 0x8D, 0x09, 0x81, 0x7D, 0x32,
    +        0xBD, 0x8F, 0x40, 0xEB, 0x86, 0xB7, 0x7B, 0x0B,
    +        0xF0, 0x95, 0x21, 0x22, 0x5C, 0x6B, 0x4E, 0x82,
    +        0x54, 0xD6, 0x65, 0x93, 0xCE, 0x60, 0xB2, 0x1C,
    +        0x73, 0x56, 0xC0, 0x14, 0xA7, 0x8C, 0xF1, 0xDC,
    +        0x12, 0x75, 0xCA, 0x1F, 0x3B, 0xBE, 0xE4, 0xD1,
    +        0x42, 0x3D, 0xD4, 0x30, 0xA3, 0x3C, 0xB6, 0x26,
    +        0x6F, 0xBF, 0x0E, 0xDA, 0x46, 0x69, 0x07, 0x57,
    +        0x27, 0xF2, 0x1D, 0x9B, 0xBC, 0x94, 0x43, 0x03,
    +        0xF8, 0x11, 0xC7, 0xF6, 0x90, 0xEF, 0x3E, 0xE7,
    +        0x06, 0xC3, 0xD5, 0x2F, 0xC8, 0x66, 0x1E, 0xD7,
    +        0x08, 0xE8, 0xEA, 0xDE, 0x80, 0x52, 0xEE, 0xF7,
    +        0x84, 0xAA, 0x72, 0xAC, 0x35, 0x4D, 0x6A, 0x2A,
    +        0x96, 0x1A, 0xD2, 0x71, 0x5A, 0x15, 0x49, 0x74,
    +        0x4B, 0x9F, 0xD0, 0x5E, 0x04, 0x18, 0xA4, 0xEC,
    +        0xC2, 0xE0, 0x41, 0x6E, 0x0F, 0x51, 0xCB, 0xCC,
    +        0x24, 0x91, 0xAF, 0x50, 0xA1, 0xF4, 0x70, 0x39,
    +        0x99, 0x7C, 0x3A, 0x85, 0x23, 0xB8, 0xB4, 0x7A,
    +        0xFC, 0x02, 0x36, 0x5B, 0x25, 0x55, 0x97, 0x31,
    +        0x2D, 0x5D, 0xFA, 0x98, 0xE3, 0x8A, 0x92, 0xAE,
    +        0x05, 0xDF, 0x29, 0x10, 0x67, 0x6C, 0xBA, 0xC9,
    +        0xD3, 0x00, 0xE6, 0xCF, 0xE1, 0x9E, 0xA8, 0x2C,
    +        0x63, 0x16, 0x01, 0x3F, 0x58, 0xE2, 0x89, 0xA9,
    +        0x0D, 0x38, 0x34, 0x1B, 0xAB, 0x33, 0xFF, 0xB0,
    +        0xBB, 0x48, 0x0C, 0x5F, 0xB9, 0xB1, 0xCD, 0x2E,
    +        0xC5, 0xF3, 0xDB, 0x47, 0xE5, 0xA5, 0x9C, 0x77,
    +        0x0A, 0xA6, 0x20, 0x68, 0xFE, 0x7F, 0xC1, 0xAD
    +    );
    +
    +    /**
    +     * Inverse key expansion randomization table.
    +     *
    +     * @see Crypt_RC2::setKey()
    +     * @var Array
    +     * @access private
    +     */
    +    var $invpitable = array(
    +        0xD1, 0xDA, 0xB9, 0x6F, 0x9C, 0xC8, 0x78, 0x66,
    +        0x80, 0x2C, 0xF8, 0x37, 0xEA, 0xE0, 0x62, 0xA4,
    +        0xCB, 0x71, 0x50, 0x27, 0x4B, 0x95, 0xD9, 0x20,
    +        0x9D, 0x04, 0x91, 0xE3, 0x47, 0x6A, 0x7E, 0x53,
    +        0xFA, 0x3A, 0x3B, 0xB4, 0xA8, 0xBC, 0x5F, 0x68,
    +        0x08, 0xCA, 0x8F, 0x14, 0xD7, 0xC0, 0xEF, 0x7B,
    +        0x5B, 0xBF, 0x2F, 0xE5, 0xE2, 0x8C, 0xBA, 0x12,
    +        0xE1, 0xAF, 0xB2, 0x54, 0x5D, 0x59, 0x76, 0xDB,
    +        0x32, 0xA2, 0x58, 0x6E, 0x1C, 0x29, 0x64, 0xF3,
    +        0xE9, 0x96, 0x0C, 0x98, 0x19, 0x8D, 0x3E, 0x26,
    +        0xAB, 0xA5, 0x85, 0x16, 0x40, 0xBD, 0x49, 0x67,
    +        0xDC, 0x22, 0x94, 0xBB, 0x3C, 0xC1, 0x9B, 0xEB,
    +        0x45, 0x28, 0x18, 0xD8, 0x1A, 0x42, 0x7D, 0xCC,
    +        0xFB, 0x65, 0x8E, 0x3D, 0xCD, 0x2A, 0xA3, 0x60,
    +        0xAE, 0x93, 0x8A, 0x48, 0x97, 0x51, 0x15, 0xF7,
    +        0x01, 0x0B, 0xB7, 0x36, 0xB1, 0x2E, 0x11, 0xFD,
    +        0x84, 0x2D, 0x3F, 0x13, 0x88, 0xB3, 0x34, 0x24,
    +        0x1B, 0xDE, 0xC5, 0x1D, 0x4D, 0x2B, 0x17, 0x31,
    +        0x74, 0xA9, 0xC6, 0x43, 0x6D, 0x39, 0x90, 0xBE,
    +        0xC3, 0xB0, 0x21, 0x6B, 0xF6, 0x0F, 0xD5, 0x99,
    +        0x0D, 0xAC, 0x1F, 0x5C, 0x9E, 0xF5, 0xF9, 0x4C,
    +        0xD6, 0xDF, 0x89, 0xE4, 0x8B, 0xFF, 0xC7, 0xAA,
    +        0xE7, 0xED, 0x46, 0x25, 0xB6, 0x06, 0x5E, 0x35,
    +        0xB5, 0xEC, 0xCE, 0xE8, 0x6C, 0x30, 0x55, 0x61,
    +        0x4A, 0xFE, 0xA0, 0x79, 0x03, 0xF0, 0x10, 0x72,
    +        0x7C, 0xCF, 0x52, 0xA6, 0xA7, 0xEE, 0x44, 0xD3,
    +        0x9A, 0x57, 0x92, 0xD0, 0x5A, 0x7A, 0x41, 0x7F,
    +        0x0E, 0x00, 0x63, 0xF2, 0x4F, 0x05, 0x83, 0xC9,
    +        0xA1, 0xD4, 0xDD, 0xC4, 0x56, 0xF4, 0xD2, 0x77,
    +        0x81, 0x09, 0x82, 0x33, 0x9F, 0x07, 0x86, 0x75,
    +        0x38, 0x4E, 0x69, 0xF1, 0xAD, 0x23, 0x73, 0x87,
    +        0x70, 0x02, 0xC2, 0x1E, 0xB8, 0x0A, 0xFC, 0xE6
    +    );
    +
    +    /**
    +     * Default Constructor.
    +     *
    +     * Determines whether or not the mcrypt extension should be used.
    +     *
    +     * $mode could be:
    +     *
    +     * - CRYPT_RC2_MODE_ECB
    +     *
    +     * - CRYPT_RC2_MODE_CBC
    +     *
    +     * - CRYPT_RC2_MODE_CTR
    +     *
    +     * - CRYPT_RC2_MODE_CFB
    +     *
    +     * - CRYPT_RC2_MODE_OFB
    +     *
    +     * If not explictly set, CRYPT_RC2_MODE_CBC will be used.
    +     *
    +     * @see Crypt_Base::Crypt_Base()
    +     * @param optional Integer $mode
    +     * @access public
    +     */
    +    function Crypt_RC2($mode = CRYPT_RC2_MODE_CBC)
    +    {
    +        parent::Crypt_Base($mode);
    +        $this->setKey('');
    +    }
    +
    +    /**
    +     * Sets the key length
    +     *
    +     * Valid key lengths are 1 to 1024.
    +     * Calling this function after setting the key has no effect until the next
    +     *  Crypt_RC2::setKey() call.
    +     *
    +     * @access public
    +     * @param Integer $length in bits
    +     */
    +    function setKeyLength($length)
    +    {
    +        if ($length >= 1 && $length <= 1024) {
    +            $this->default_key_length = $length;
    +        }
    +    }
    +
    +    /**
    +     * Sets the key.
    +     *
    +     * Keys can be of any length. RC2, itself, uses 1 to 1024 bit keys (eg.
    +     * strlen($key) <= 128), however, we only use the first 128 bytes if $key
    +     * has more then 128 bytes in it, and set $key to a single null byte if
    +     * it is empty.
    +     *
    +     * If the key is not explicitly set, it'll be assumed to be a single
    +     * null byte.
    +     *
    +     * @see Crypt_Base::setKey()
    +     * @access public
    +     * @param String $key
    +     * @param Integer $t1 optional          Effective key length in bits.
    +     */
    +    function setKey($key, $t1 = 0)
    +    {
    +        if ($t1 <= 0) {
    +            $t1 = $this->default_key_length;
    +        } else if ($t1 > 1024) {
    +            $t1 = 1024;
    +        }
    +        // Key byte count should be 1..128.
    +        $key = strlen($key) ? substr($key, 0, 128): "\x00";
    +        $t = strlen($key);
    +
    +        // The mcrypt RC2 implementation only supports effective key length
    +        // of 1024 bits. It is however possible to handle effective key
    +        // lengths in range 1..1024 by expanding the key and applying
    +        // inverse pitable mapping to the first byte before submitting it
    +        // to mcrypt.
    +
    +        // Key expansion.
    +        $l = array_values(unpack('C*', $key));
    +        $t8 = ($t1 + 7) >> 3;
    +        $tm = 0xFF >> (8 * $t8 - $t1);
    +
    +        // Expand key.
    +        $pitable = $this->pitable;
    +        for ($i = $t; $i < 128; $i++) {
    +            $l[$i] = $pitable[$l[$i - 1] + $l[$i - $t]];
    +        }
    +        $i = 128 - $t8;
    +        $l[$i] = $pitable[$l[$i] & $tm];
    +        while ($i--) {
    +            $l[$i] = $pitable[$l[$i + 1] ^ $l[$i + $t8]];
    +        }
    +
    +        // Prepare the key for mcrypt.
    +        $l[0] = $this->invpitable[$l[0]];
    +        array_unshift($l, 'C*');
    +        parent::setKey(call_user_func_array('pack', $l));
    +    }
    +
    +    /**
    +     * Encrypts a block
    +     *
    +     * @see Crypt_Base::_encryptBlock()
    +     * @see Crypt_Base::encrypt()
    +     * @access private
    +     * @param String $in
    +     * @return String
    +     */
    +    function _encryptBlock($in)
    +    {
    +        list($r0, $r1, $r2, $r3) = array_values(unpack('v*', $in));
    +        $keys = $this->keys;
    +        $limit = 20;
    +        $actions = array($limit => 44, 44 => 64);
    +        $j = 0;
    +
    +        for (;;) {
    +            // Mixing round.
    +            $r0 = (($r0 + $keys[$j++] + ((($r1 ^ $r2) & $r3) ^ $r1)) & 0xFFFF) << 1;
    +            $r0 |= $r0 >> 16;
    +            $r1 = (($r1 + $keys[$j++] + ((($r2 ^ $r3) & $r0) ^ $r2)) & 0xFFFF) << 2;
    +            $r1 |= $r1 >> 16;
    +            $r2 = (($r2 + $keys[$j++] + ((($r3 ^ $r0) & $r1) ^ $r3)) & 0xFFFF) << 3;
    +            $r2 |= $r2 >> 16;
    +            $r3 = (($r3 + $keys[$j++] + ((($r0 ^ $r1) & $r2) ^ $r0)) & 0xFFFF) << 5;
    +            $r3 |= $r3 >> 16;
    +
    +            if ($j == $limit) {
    +                if ($limit == 64) {
    +                    break;
    +                }
    +
    +                // Mashing round.
    +                $r0 += $keys[$r3 & 0x3F];
    +                $r1 += $keys[$r0 & 0x3F];
    +                $r2 += $keys[$r1 & 0x3F];
    +                $r3 += $keys[$r2 & 0x3F];
    +                $limit = $actions[$limit];
    +            }
    +        }
    +
    +        return pack('vvvv', $r0, $r1, $r2, $r3);
    +    }
    +
    +    /**
    +     * Decrypts a block
    +     *
    +     * @see Crypt_Base::_decryptBlock()
    +     * @see Crypt_Base::decrypt()
    +     * @access private
    +     * @param String $in
    +     * @return String
    +     */
    +    function _decryptBlock($in)
    +    {
    +        list($r0, $r1, $r2, $r3) = array_values(unpack('v*', $in));
    +        $keys = $this->keys;
    +        $limit = 44;
    +        $actions = array($limit => 20, 20 => 0);
    +        $j = 64;
    +
    +        for (;;) {
    +            // R-mixing round.
    +            $r3 = ($r3 | ($r3 << 16)) >> 5;
    +            $r3 = ($r3 - $keys[--$j] - ((($r0 ^ $r1) & $r2) ^ $r0)) & 0xFFFF;
    +            $r2 = ($r2 | ($r2 << 16)) >> 3;
    +            $r2 = ($r2 - $keys[--$j] - ((($r3 ^ $r0) & $r1) ^ $r3)) & 0xFFFF;
    +            $r1 = ($r1 | ($r1 << 16)) >> 2;
    +            $r1 = ($r1 - $keys[--$j] - ((($r2 ^ $r3) & $r0) ^ $r2)) & 0xFFFF;
    +            $r0 = ($r0 | ($r0 << 16)) >> 1;
    +            $r0 = ($r0 - $keys[--$j] - ((($r1 ^ $r2) & $r3) ^ $r1)) & 0xFFFF;
    +
    +            if ($j == $limit) {
    +                if (!$limit) {
    +                    break;
    +                }
    +
    +                // R-mashing round.
    +                $r3 = ($r3 - $keys[$r2 & 0x3F]) & 0xFFFF;
    +                $r2 = ($r2 - $keys[$r1 & 0x3F]) & 0xFFFF;
    +                $r1 = ($r1 - $keys[$r0 & 0x3F]) & 0xFFFF;
    +                $r0 = ($r0 - $keys[$r3 & 0x3F]) & 0xFFFF;
    +                $limit = $actions[$limit];
    +            }
    +        }
    +
    +        return pack('vvvv', $r0, $r1, $r2, $r3);
    +    }
    +
    +    /**
    +     * Creates the key schedule
    +     *
    +     * @see Crypt_Base::_setupKey()
    +     * @access private
    +     */
    +    function _setupKey()
    +    {
    +        // Key has already been expanded in Crypt_RC2::setKey():
    +        // Only the first value must be altered.
    +        $l = unpack('Ca/Cb/v*', $this->key);
    +        array_unshift($l, $this->pitable[$l['a']] | ($l['b'] << 8));
    +        unset($l['a']);
    +        unset($l['b']);
    +        $this->keys = $l;
    +    }
    +
    +    /**
    +     * Setup the performance-optimized function for de/encrypt()
    +     *
    +     * @see Crypt_Base::_setupInlineCrypt()
    +     * @access private
    +     */
    +    function _setupInlineCrypt()
    +    {
    +        $lambda_functions = &Crypt_RC2::_getLambdaFunctions();
    +
    +        // The first 10 generated $lambda_functions will use the $keys hardcoded as integers
    +        // for the mixing rounds, for better inline crypt performance [~20% faster].
    +        // But for memory reason we have to limit those ultra-optimized $lambda_functions to an amount of 10.
    +        $keys = $this->keys;
    +        if (count($lambda_functions) >= 10) {
    +            foreach ($this->keys as $k => $v) {
    +                $keys[$k] = '$keys[' . $k . ']';
    +            }
    +        }
    +
    +        $code_hash = md5(str_pad("Crypt_RC2, {$this->mode}, ", 32, "\0") . implode(',', $keys));
    +
    +        // Is there a re-usable $lambda_functions in there?
    +        // If not, we have to create it.
    +        if (!isset($lambda_functions[$code_hash])) {
    +            // Init code for both, encrypt and decrypt.
    +            $init_crypt = '$keys = $self->keys;';
    +
    +            // $in is the current 8 bytes block which has to be en/decrypt
    +            $encrypt_block = $decrypt_block = '
    +                $in = unpack("v4", $in);
    +                $r0 = $in[1];
    +                $r1 = $in[2];
    +                $r2 = $in[3];
    +                $r3 = $in[4];
    +            ';
    +
    +            // Create code for encryption.
    +            $limit = 20;
    +            $actions = array($limit => 44, 44 => 64);
    +            $j = 0;
    +
    +            for (;;) {
    +                // Mixing round.
    +                $encrypt_block .= '
    +                    $r0 = (($r0 + ' . $keys[$j++] . ' +
    +                           ((($r1 ^ $r2) & $r3) ^ $r1)) & 0xFFFF) << 1;
    +                    $r0 |= $r0 >> 16;
    +                    $r1 = (($r1 + ' . $keys[$j++] . ' +
    +                           ((($r2 ^ $r3) & $r0) ^ $r2)) & 0xFFFF) << 2;
    +                    $r1 |= $r1 >> 16;
    +                    $r2 = (($r2 + ' . $keys[$j++] . ' +
    +                           ((($r3 ^ $r0) & $r1) ^ $r3)) & 0xFFFF) << 3;
    +                    $r2 |= $r2 >> 16;
    +                    $r3 = (($r3 + ' . $keys[$j++] . ' +
    +                           ((($r0 ^ $r1) & $r2) ^ $r0)) & 0xFFFF) << 5;
    +                    $r3 |= $r3 >> 16;';
    +
    +                if ($j == $limit) {
    +                    if ($limit == 64) {
    +                        break;
    +                    }
    +
    +                    // Mashing round.
    +                    $encrypt_block .= '
    +                        $r0 += $keys[$r3 & 0x3F];
    +                        $r1 += $keys[$r0 & 0x3F];
    +                        $r2 += $keys[$r1 & 0x3F];
    +                        $r3 += $keys[$r2 & 0x3F];';
    +                    $limit = $actions[$limit];
    +                }
    +            }
    +
    +            $encrypt_block .= '$in = pack("v4", $r0, $r1, $r2, $r3);';
    +
    +            // Create code for decryption.
    +            $limit = 44;
    +            $actions = array($limit => 20, 20 => 0);
    +            $j = 64;
    +
    +            for (;;) {
    +                // R-mixing round.
    +                $decrypt_block .= '
    +                    $r3 = ($r3 | ($r3 << 16)) >> 5;
    +                    $r3 = ($r3 - ' . $keys[--$j] . ' -
    +                           ((($r0 ^ $r1) & $r2) ^ $r0)) & 0xFFFF;
    +                    $r2 = ($r2 | ($r2 << 16)) >> 3;
    +                    $r2 = ($r2 - ' . $keys[--$j] . ' -
    +                           ((($r3 ^ $r0) & $r1) ^ $r3)) & 0xFFFF;
    +                    $r1 = ($r1 | ($r1 << 16)) >> 2;
    +                    $r1 = ($r1 - ' . $keys[--$j] . ' -
    +                           ((($r2 ^ $r3) & $r0) ^ $r2)) & 0xFFFF;
    +                    $r0 = ($r0 | ($r0 << 16)) >> 1;
    +                    $r0 = ($r0 - ' . $keys[--$j] . ' -
    +                           ((($r1 ^ $r2) & $r3) ^ $r1)) & 0xFFFF;';
    +
    +                if ($j == $limit) {
    +                    if (!$limit) {
    +                        break;
    +                    }
    +
    +                    // R-mashing round.
    +                    $decrypt_block .= '
    +                        $r3 = ($r3 - $keys[$r2 & 0x3F]) & 0xFFFF;
    +                        $r2 = ($r2 - $keys[$r1 & 0x3F]) & 0xFFFF;
    +                        $r1 = ($r1 - $keys[$r0 & 0x3F]) & 0xFFFF;
    +                        $r0 = ($r0 - $keys[$r3 & 0x3F]) & 0xFFFF;';
    +                    $limit = $actions[$limit];
    +                }
    +            }
    +
    +            $decrypt_block .= '$in = pack("v4", $r0, $r1, $r2, $r3);';
    +
    +            // Creates the inline-crypt function
    +            $lambda_functions[$code_hash] = $this->_createInlineCryptFunction(
    +                array(
    +                   'init_crypt'    => $init_crypt,
    +                   'encrypt_block' => $encrypt_block,
    +                   'decrypt_block' => $decrypt_block
    +                )
    +            );
    +        }
    +
    +        // Set the inline-crypt function as callback in: $this->inline_crypt
    +        $this->inline_crypt = $lambda_functions[$code_hash];
    +    }
    +}
    diff --git a/vendor/phpseclib/phpseclib/phpseclib/Crypt/RC4.php b/vendor/phpseclib/phpseclib/phpseclib/Crypt/RC4.php
    new file mode 100755
    index 0000000..d062be2
    --- /dev/null
    +++ b/vendor/phpseclib/phpseclib/phpseclib/Crypt/RC4.php
    @@ -0,0 +1,333 @@
    +
    + * setKey('abcdefgh');
    + *
    + *    $size = 10 * 1024;
    + *    $plaintext = '';
    + *    for ($i = 0; $i < $size; $i++) {
    + *        $plaintext.= 'a';
    + *    }
    + *
    + *    echo $rc4->decrypt($rc4->encrypt($plaintext));
    + * ?>
    + * 
    + *
    + * LICENSE: Permission is hereby granted, free of charge, to any person obtaining a copy
    + * of this software and associated documentation files (the "Software"), to deal
    + * in the Software without restriction, including without limitation the rights
    + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    + * copies of the Software, and to permit persons to whom the Software is
    + * furnished to do so, subject to the following conditions:
    + *
    + * The above copyright notice and this permission notice shall be included in
    + * all copies or substantial portions of the Software.
    + *
    + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
    + * THE SOFTWARE.
    + *
    + * @category  Crypt
    + * @package   Crypt_RC4
    + * @author    Jim Wigginton 
    + * @copyright MMVII Jim Wigginton
    + * @license   http://www.opensource.org/licenses/mit-license.html  MIT License
    + * @link      http://phpseclib.sourceforge.net
    + */
    +
    +/**
    + * Include Crypt_Base
    + *
    + * Base cipher class
    + */
    +if (!class_exists('Crypt_Base')) {
    +    include_once 'Base.php';
    +}
    +
    +/**#@+
    + * @access private
    + * @see Crypt_RC4::Crypt_RC4()
    + */
    +/**
    + * Toggles the internal implementation
    + */
    +define('CRYPT_RC4_MODE_INTERNAL', CRYPT_MODE_INTERNAL);
    +/**
    + * Toggles the mcrypt implementation
    + */
    +define('CRYPT_RC4_MODE_MCRYPT', CRYPT_MODE_MCRYPT);
    +/**#@-*/
    +
    +/**#@+
    + * @access private
    + * @see Crypt_RC4::_crypt()
    + */
    +define('CRYPT_RC4_ENCRYPT', 0);
    +define('CRYPT_RC4_DECRYPT', 1);
    +/**#@-*/
    +
    +/**
    + * Pure-PHP implementation of RC4.
    + *
    + * @package Crypt_RC4
    + * @author  Jim Wigginton 
    + * @version 0.1.0
    + * @access  public
    + */
    +class Crypt_RC4 extends Crypt_Base
    +{
    +    /**
    +     * Block Length of the cipher
    +     *
    +     * RC4 is a stream cipher
    +     * so we the block_size to 0
    +     *
    +     * @see Crypt_Base::block_size
    +     * @var Integer
    +     * @access private
    +     */
    +    var $block_size = 0;
    +
    +    /**
    +     * The default password key_size used by setPassword()
    +     *
    +     * @see Crypt_Base::password_key_size
    +     * @see Crypt_Base::setPassword()
    +     * @var Integer
    +     * @access private
    +     */
    +    var $password_key_size = 128; // = 1024 bits
    +
    +    /**
    +     * The namespace used by the cipher for its constants.
    +     *
    +     * @see Crypt_Base::const_namespace
    +     * @var String
    +     * @access private
    +     */
    +    var $const_namespace = 'RC4';
    +
    +    /**
    +     * The mcrypt specific name of the cipher
    +     *
    +     * @see Crypt_Base::cipher_name_mcrypt
    +     * @var String
    +     * @access private
    +     */
    +    var $cipher_name_mcrypt = 'arcfour';
    +
    +    /**
    +     * Holds whether performance-optimized $inline_crypt() can/should be used.
    +     *
    +     * @see Crypt_Base::inline_crypt
    +     * @var mixed
    +     * @access private
    +     */
    +    var $use_inline_crypt = false; // currently not available
    +
    +    /**
    +     * The Key
    +     *
    +     * @see Crypt_RC4::setKey()
    +     * @var String
    +     * @access private
    +     */
    +    var $key = "\0";
    +
    +    /**
    +     * The Key Stream for decryption and encryption
    +     *
    +     * @see Crypt_RC4::setKey()
    +     * @var Array
    +     * @access private
    +     */
    +    var $stream;
    +
    +    /**
    +     * Default Constructor.
    +     *
    +     * Determines whether or not the mcrypt extension should be used.
    +     *
    +     * @see Crypt_Base::Crypt_Base()
    +     * @return Crypt_RC4
    +     * @access public
    +     */
    +    function Crypt_RC4()
    +    {
    +        parent::Crypt_Base(CRYPT_MODE_STREAM);
    +    }
    +
    +    /**
    +     * Dummy function.
    +     *
    +     * Some protocols, such as WEP, prepend an "initialization vector" to the key, effectively creating a new key [1].
    +     * If you need to use an initialization vector in this manner, feel free to prepend it to the key, yourself, before
    +     * calling setKey().
    +     *
    +     * [1] WEP's initialization vectors (IV's) are used in a somewhat insecure way.  Since, in that protocol,
    +     * the IV's are relatively easy to predict, an attack described by
    +     * {@link http://www.drizzle.com/~aboba/IEEE/rc4_ksaproc.pdf Scott Fluhrer, Itsik Mantin, and Adi Shamir}
    +     * can be used to quickly guess at the rest of the key.  The following links elaborate:
    +     *
    +     * {@link http://www.rsa.com/rsalabs/node.asp?id=2009 http://www.rsa.com/rsalabs/node.asp?id=2009}
    +     * {@link http://en.wikipedia.org/wiki/Related_key_attack http://en.wikipedia.org/wiki/Related_key_attack}
    +     *
    +     * @param String $iv
    +     * @see Crypt_RC4::setKey()
    +     * @access public
    +     */
    +    function setIV($iv)
    +    {
    +    }
    +
    +    /**
    +     * Sets the key.
    +     *
    +     * Keys can be between 1 and 256 bytes long.  If they are longer then 256 bytes, the first 256 bytes will
    +     * be used.  If no key is explicitly set, it'll be assumed to be a single null byte.
    +     *
    +     * @access public
    +     * @see Crypt_Base::setKey()
    +     * @param String $key
    +     */
    +    function setKey($key)
    +    {
    +        parent::setKey(substr($key, 0, 256));
    +    }
    +
    +    /**
    +     * Encrypts a message.
    +     *
    +     * @see Crypt_Base::decrypt()
    +     * @see Crypt_RC4::_crypt()
    +     * @access public
    +     * @param String $plaintext
    +     * @return String $ciphertext
    +     */
    +    function encrypt($plaintext)
    +    {
    +        if ($this->engine == CRYPT_MODE_MCRYPT) {
    +            return parent::encrypt($plaintext);
    +        }
    +        return $this->_crypt($plaintext, CRYPT_RC4_ENCRYPT);
    +    }
    +
    +    /**
    +     * Decrypts a message.
    +     *
    +     * $this->decrypt($this->encrypt($plaintext)) == $this->encrypt($this->encrypt($plaintext)).
    +     * Atleast if the continuous buffer is disabled.
    +     *
    +     * @see Crypt_Base::encrypt()
    +     * @see Crypt_RC4::_crypt()
    +     * @access public
    +     * @param String $ciphertext
    +     * @return String $plaintext
    +     */
    +    function decrypt($ciphertext)
    +    {
    +        if ($this->engine == CRYPT_MODE_MCRYPT) {
    +            return parent::decrypt($ciphertext);
    +        }
    +        return $this->_crypt($ciphertext, CRYPT_RC4_DECRYPT);
    +    }
    +
    +
    +    /**
    +     * Setup the key (expansion)
    +     *
    +     * @see Crypt_Base::_setupKey()
    +     * @access private
    +     */
    +    function _setupKey()
    +    {
    +        $key = $this->key;
    +        $keyLength = strlen($key);
    +        $keyStream = array();
    +        for ($i = 0; $i < 256; $i++) {
    +            $keyStream[$i] = $i;
    +        }
    +        $j = 0;
    +        for ($i = 0; $i < 256; $i++) {
    +            $j = ($j + $keyStream[$i] + ord($key[$i % $keyLength])) & 255;
    +            $temp = $keyStream[$i];
    +            $keyStream[$i] = $keyStream[$j];
    +            $keyStream[$j] = $temp;
    +        }
    +
    +        $this->stream = array();
    +        $this->stream[CRYPT_RC4_DECRYPT] = $this->stream[CRYPT_RC4_ENCRYPT] = array(
    +            0, // index $i
    +            0, // index $j
    +            $keyStream
    +        );
    +    }
    +
    +    /**
    +     * Encrypts or decrypts a message.
    +     *
    +     * @see Crypt_RC4::encrypt()
    +     * @see Crypt_RC4::decrypt()
    +     * @access private
    +     * @param String $text
    +     * @param Integer $mode
    +     * @return String $text
    +     */
    +    function _crypt($text, $mode)
    +    {
    +        if ($this->changed) {
    +            $this->_setup();
    +            $this->changed = false;
    +        }
    +
    +        $stream = &$this->stream[$mode];
    +        if ($this->continuousBuffer) {
    +            $i = &$stream[0];
    +            $j = &$stream[1];
    +            $keyStream = &$stream[2];
    +        } else {
    +            $i = $stream[0];
    +            $j = $stream[1];
    +            $keyStream = $stream[2];
    +        }
    +
    +        $len = strlen($text);
    +        for ($k = 0; $k < $len; ++$k) {
    +            $i = ($i + 1) & 255;
    +            $ksi = $keyStream[$i];
    +            $j = ($j + $ksi) & 255;
    +            $ksj = $keyStream[$j];
    +
    +            $keyStream[$i] = $ksj;
    +            $keyStream[$j] = $ksi;
    +            $text[$k] = chr(ord($text[$k]) ^ $keyStream[($ksj + $ksi) & 255]);
    +        }
    +
    +        return $text;
    +    }
    +}
    diff --git a/vendor/phpseclib/phpseclib/phpseclib/Crypt/RSA.php b/vendor/phpseclib/phpseclib/phpseclib/Crypt/RSA.php
    new file mode 100755
    index 0000000..feb887c
    --- /dev/null
    +++ b/vendor/phpseclib/phpseclib/phpseclib/Crypt/RSA.php
    @@ -0,0 +1,2811 @@
    +
    + * createKey());
    + *
    + *    $plaintext = 'terrafrost';
    + *
    + *    $rsa->loadKey($privatekey);
    + *    $ciphertext = $rsa->encrypt($plaintext);
    + *
    + *    $rsa->loadKey($publickey);
    + *    echo $rsa->decrypt($ciphertext);
    + * ?>
    + * 
    + *
    + * Here's an example of how to create signatures and verify signatures with this library:
    + * 
    + * createKey());
    + *
    + *    $plaintext = 'terrafrost';
    + *
    + *    $rsa->loadKey($privatekey);
    + *    $signature = $rsa->sign($plaintext);
    + *
    + *    $rsa->loadKey($publickey);
    + *    echo $rsa->verify($plaintext, $signature) ? 'verified' : 'unverified';
    + * ?>
    + * 
    + *
    + * LICENSE: Permission is hereby granted, free of charge, to any person obtaining a copy
    + * of this software and associated documentation files (the "Software"), to deal
    + * in the Software without restriction, including without limitation the rights
    + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    + * copies of the Software, and to permit persons to whom the Software is
    + * furnished to do so, subject to the following conditions:
    + *
    + * The above copyright notice and this permission notice shall be included in
    + * all copies or substantial portions of the Software.
    + *
    + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
    + * THE SOFTWARE.
    + *
    + * @category  Crypt
    + * @package   Crypt_RSA
    + * @author    Jim Wigginton 
    + * @copyright MMIX Jim Wigginton
    + * @license   http://www.opensource.org/licenses/mit-license.html  MIT License
    + * @link      http://phpseclib.sourceforge.net
    + */
    +
    +/**
    + * Include Crypt_Random
    + */
    +// the class_exists() will only be called if the crypt_random_string function hasn't been defined and
    +// will trigger a call to __autoload() if you're wanting to auto-load classes
    +// call function_exists() a second time to stop the include_once from being called outside
    +// of the auto loader
    +if (!function_exists('crypt_random_string')) {
    +    include_once 'Random.php';
    +}
    +
    +/**
    + * Include Crypt_Hash
    + */
    +if (!class_exists('Crypt_Hash')) {
    +    include_once 'Hash.php';
    +}
    +
    +/**#@+
    + * @access public
    + * @see Crypt_RSA::encrypt()
    + * @see Crypt_RSA::decrypt()
    + */
    +/**
    + * Use {@link http://en.wikipedia.org/wiki/Optimal_Asymmetric_Encryption_Padding Optimal Asymmetric Encryption Padding}
    + * (OAEP) for encryption / decryption.
    + *
    + * Uses sha1 by default.
    + *
    + * @see Crypt_RSA::setHash()
    + * @see Crypt_RSA::setMGFHash()
    + */
    +define('CRYPT_RSA_ENCRYPTION_OAEP',  1);
    +/**
    + * Use PKCS#1 padding.
    + *
    + * Although CRYPT_RSA_ENCRYPTION_OAEP offers more security, including PKCS#1 padding is necessary for purposes of backwards
    + * compatability with protocols (like SSH-1) written before OAEP's introduction.
    + */
    +define('CRYPT_RSA_ENCRYPTION_PKCS1', 2);
    +/**#@-*/
    +
    +/**#@+
    + * @access public
    + * @see Crypt_RSA::sign()
    + * @see Crypt_RSA::verify()
    + * @see Crypt_RSA::setHash()
    + */
    +/**
    + * Use the Probabilistic Signature Scheme for signing
    + *
    + * Uses sha1 by default.
    + *
    + * @see Crypt_RSA::setSaltLength()
    + * @see Crypt_RSA::setMGFHash()
    + */
    +define('CRYPT_RSA_SIGNATURE_PSS',  1);
    +/**
    + * Use the PKCS#1 scheme by default.
    + *
    + * Although CRYPT_RSA_SIGNATURE_PSS offers more security, including PKCS#1 signing is necessary for purposes of backwards
    + * compatability with protocols (like SSH-2) written before PSS's introduction.
    + */
    +define('CRYPT_RSA_SIGNATURE_PKCS1', 2);
    +/**#@-*/
    +
    +/**#@+
    + * @access private
    + * @see Crypt_RSA::createKey()
    + */
    +/**
    + * ASN1 Integer
    + */
    +define('CRYPT_RSA_ASN1_INTEGER',   2);
    +/**
    + * ASN1 Bit String
    + */
    +define('CRYPT_RSA_ASN1_BITSTRING', 3);
    +/**
    + * ASN1 Sequence (with the constucted bit set)
    + */
    +define('CRYPT_RSA_ASN1_SEQUENCE', 48);
    +/**#@-*/
    +
    +/**#@+
    + * @access private
    + * @see Crypt_RSA::Crypt_RSA()
    + */
    +/**
    + * To use the pure-PHP implementation
    + */
    +define('CRYPT_RSA_MODE_INTERNAL', 1);
    +/**
    + * To use the OpenSSL library
    + *
    + * (if enabled; otherwise, the internal implementation will be used)
    + */
    +define('CRYPT_RSA_MODE_OPENSSL', 2);
    +/**#@-*/
    +
    +/**
    + * Default openSSL configuration file.
    + */
    +define('CRYPT_RSA_OPENSSL_CONFIG', dirname(__FILE__) . '/../openssl.cnf');
    +
    +/**#@+
    + * @access public
    + * @see Crypt_RSA::createKey()
    + * @see Crypt_RSA::setPrivateKeyFormat()
    + */
    +/**
    + * PKCS#1 formatted private key
    + *
    + * Used by OpenSSH
    + */
    +define('CRYPT_RSA_PRIVATE_FORMAT_PKCS1', 0);
    +/**
    + * PuTTY formatted private key
    + */
    +define('CRYPT_RSA_PRIVATE_FORMAT_PUTTY', 1);
    +/**
    + * XML formatted private key
    + */
    +define('CRYPT_RSA_PRIVATE_FORMAT_XML', 2);
    +/**#@-*/
    +
    +/**#@+
    + * @access public
    + * @see Crypt_RSA::createKey()
    + * @see Crypt_RSA::setPublicKeyFormat()
    + */
    +/**
    + * Raw public key
    + *
    + * An array containing two Math_BigInteger objects.
    + *
    + * The exponent can be indexed with any of the following:
    + *
    + * 0, e, exponent, publicExponent
    + *
    + * The modulus can be indexed with any of the following:
    + *
    + * 1, n, modulo, modulus
    + */
    +define('CRYPT_RSA_PUBLIC_FORMAT_RAW', 3);
    +/**
    + * PKCS#1 formatted public key (raw)
    + *
    + * Used by File/X509.php
    + */
    +define('CRYPT_RSA_PUBLIC_FORMAT_PKCS1_RAW', 4);
    +/**
    + * XML formatted public key
    + */
    +define('CRYPT_RSA_PUBLIC_FORMAT_XML', 5);
    +/**
    + * OpenSSH formatted public key
    + *
    + * Place in $HOME/.ssh/authorized_keys
    + */
    +define('CRYPT_RSA_PUBLIC_FORMAT_OPENSSH', 6);
    +/**
    + * PKCS#1 formatted public key (encapsulated)
    + *
    + * Used by PHP's openssl_public_encrypt() and openssl's rsautl (when -pubin is set)
    + */
    +define('CRYPT_RSA_PUBLIC_FORMAT_PKCS1', 7);
    +/**#@-*/
    +
    +/**
    + * Pure-PHP PKCS#1 compliant implementation of RSA.
    + *
    + * @package Crypt_RSA
    + * @author  Jim Wigginton 
    + * @version 0.1.0
    + * @access  public
    + */
    +class Crypt_RSA
    +{
    +    /**
    +     * Precomputed Zero
    +     *
    +     * @var Array
    +     * @access private
    +     */
    +    var $zero;
    +
    +    /**
    +     * Precomputed One
    +     *
    +     * @var Array
    +     * @access private
    +     */
    +    var $one;
    +
    +    /**
    +     * Private Key Format
    +     *
    +     * @var Integer
    +     * @access private
    +     */
    +    var $privateKeyFormat = CRYPT_RSA_PRIVATE_FORMAT_PKCS1;
    +
    +    /**
    +     * Public Key Format
    +     *
    +     * @var Integer
    +     * @access public
    +     */
    +    var $publicKeyFormat = CRYPT_RSA_PUBLIC_FORMAT_PKCS1;
    +
    +    /**
    +     * Modulus (ie. n)
    +     *
    +     * @var Math_BigInteger
    +     * @access private
    +     */
    +    var $modulus;
    +
    +    /**
    +     * Modulus length
    +     *
    +     * @var Math_BigInteger
    +     * @access private
    +     */
    +    var $k;
    +
    +    /**
    +     * Exponent (ie. e or d)
    +     *
    +     * @var Math_BigInteger
    +     * @access private
    +     */
    +    var $exponent;
    +
    +    /**
    +     * Primes for Chinese Remainder Theorem (ie. p and q)
    +     *
    +     * @var Array
    +     * @access private
    +     */
    +    var $primes;
    +
    +    /**
    +     * Exponents for Chinese Remainder Theorem (ie. dP and dQ)
    +     *
    +     * @var Array
    +     * @access private
    +     */
    +    var $exponents;
    +
    +    /**
    +     * Coefficients for Chinese Remainder Theorem (ie. qInv)
    +     *
    +     * @var Array
    +     * @access private
    +     */
    +    var $coefficients;
    +
    +    /**
    +     * Hash name
    +     *
    +     * @var String
    +     * @access private
    +     */
    +    var $hashName;
    +
    +    /**
    +     * Hash function
    +     *
    +     * @var Crypt_Hash
    +     * @access private
    +     */
    +    var $hash;
    +
    +    /**
    +     * Length of hash function output
    +     *
    +     * @var Integer
    +     * @access private
    +     */
    +    var $hLen;
    +
    +    /**
    +     * Length of salt
    +     *
    +     * @var Integer
    +     * @access private
    +     */
    +    var $sLen;
    +
    +    /**
    +     * Hash function for the Mask Generation Function
    +     *
    +     * @var Crypt_Hash
    +     * @access private
    +     */
    +    var $mgfHash;
    +
    +    /**
    +     * Length of MGF hash function output
    +     *
    +     * @var Integer
    +     * @access private
    +     */
    +    var $mgfHLen;
    +
    +    /**
    +     * Encryption mode
    +     *
    +     * @var Integer
    +     * @access private
    +     */
    +    var $encryptionMode = CRYPT_RSA_ENCRYPTION_OAEP;
    +
    +    /**
    +     * Signature mode
    +     *
    +     * @var Integer
    +     * @access private
    +     */
    +    var $signatureMode = CRYPT_RSA_SIGNATURE_PSS;
    +
    +    /**
    +     * Public Exponent
    +     *
    +     * @var Mixed
    +     * @access private
    +     */
    +    var $publicExponent = false;
    +
    +    /**
    +     * Password
    +     *
    +     * @var String
    +     * @access private
    +     */
    +    var $password = false;
    +
    +    /**
    +     * Components
    +     *
    +     * For use with parsing XML formatted keys.  PHP's XML Parser functions use utilized - instead of PHP's DOM functions -
    +     * because PHP's XML Parser functions work on PHP4 whereas PHP's DOM functions - although surperior - don't.
    +     *
    +     * @see Crypt_RSA::_start_element_handler()
    +     * @var Array
    +     * @access private
    +     */
    +    var $components = array();
    +
    +    /**
    +     * Current String
    +     *
    +     * For use with parsing XML formatted keys.
    +     *
    +     * @see Crypt_RSA::_character_handler()
    +     * @see Crypt_RSA::_stop_element_handler()
    +     * @var Mixed
    +     * @access private
    +     */
    +    var $current;
    +
    +    /**
    +     * OpenSSL configuration file name.
    +     *
    +     * Set to null to use system configuration file.
    +     * @see Crypt_RSA::createKey()
    +     * @var Mixed
    +     * @Access public
    +     */
    +    var $configFile;
    +
    +    /**
    +     * Public key comment field.
    +     *
    +     * @var String
    +     * @access private
    +     */
    +    var $comment = 'phpseclib-generated-key';
    +
    +    /**
    +     * The constructor
    +     *
    +     * If you want to make use of the openssl extension, you'll need to set the mode manually, yourself.  The reason
    +     * Crypt_RSA doesn't do it is because OpenSSL doesn't fail gracefully.  openssl_pkey_new(), in particular, requires
    +     * openssl.cnf be present somewhere and, unfortunately, the only real way to find out is too late.
    +     *
    +     * @return Crypt_RSA
    +     * @access public
    +     */
    +    function Crypt_RSA()
    +    {
    +        if (!class_exists('Math_BigInteger')) {
    +            include_once 'Math/BigInteger.php';
    +        }
    +
    +        $this->configFile = CRYPT_RSA_OPENSSL_CONFIG;
    +
    +        if ( !defined('CRYPT_RSA_MODE') ) {
    +            // Math/BigInteger's openssl requirements are a little less stringent than Crypt/RSA's. in particular,
    +            // Math/BigInteger doesn't require an openssl.cfg file whereas Crypt/RSA does. so if Math/BigInteger
    +            // can't use OpenSSL it can be pretty trivially assumed, then, that Crypt/RSA can't either.
    +            if ( defined('MATH_BIGINTEGER_OPENSSL_DISABLE') ) {
    +                define('CRYPT_RSA_MODE', CRYPT_RSA_MODE_INTERNAL);
    +            }
    +
    +            switch ( !defined('CRYPT_RSA_MODE') ) { // ie. only run this if the above didn't set CRYPT_RSA_MODE already
    +                case extension_loaded('openssl') && version_compare(PHP_VERSION, '4.2.0', '>=') && file_exists($this->configFile):
    +                    // some versions of XAMPP have mismatched versions of OpenSSL which causes it not to work
    +                    ob_start();
    +                    phpinfo();
    +                    $content = ob_get_contents();
    +                    ob_end_clean();
    +
    +                    preg_match_all('#OpenSSL (Header|Library) Version(.*)#im', $content, $matches);
    +
    +                    $versions = array();
    +                    if (!empty($matches[1])) {
    +                       for ($i = 0; $i < count($matches[1]); $i++) {
    +                          $versions[$matches[1][$i]] = trim(str_replace('=>', '', strip_tags($matches[2][$i])));
    +                       }
    +                    }
    +
    +                    // it doesn't appear that OpenSSL versions were reported upon until PHP 5.3+
    +                    switch (true) {
    +                        case !isset($versions['Header']):
    +                        case !isset($versions['Library']):
    +                        case $versions['Header'] == $versions['Library']:
    +                            define('CRYPT_RSA_MODE', CRYPT_RSA_MODE_OPENSSL);
    +                            break;
    +                        default:
    +                            define('CRYPT_RSA_MODE', CRYPT_RSA_MODE_INTERNAL);
    +                            define('MATH_BIGINTEGER_OPENSSL_DISABLE', true);
    +                    }
    +                    break;
    +                case true:
    +                    define('CRYPT_RSA_MODE', CRYPT_RSA_MODE_INTERNAL);
    +            }
    +        }
    +
    +        $this->zero = new Math_BigInteger();
    +        $this->one = new Math_BigInteger(1);
    +
    +        $this->hash = new Crypt_Hash('sha1');
    +        $this->hLen = $this->hash->getLength();
    +        $this->hashName = 'sha1';
    +        $this->mgfHash = new Crypt_Hash('sha1');
    +        $this->mgfHLen = $this->mgfHash->getLength();
    +    }
    +
    +    /**
    +     * Create public / private key pair
    +     *
    +     * Returns an array with the following three elements:
    +     *  - 'privatekey': The private key.
    +     *  - 'publickey':  The public key.
    +     *  - 'partialkey': A partially computed key (if the execution time exceeded $timeout).
    +     *                  Will need to be passed back to Crypt_RSA::createKey() as the third parameter for further processing.
    +     *
    +     * @access public
    +     * @param optional Integer $bits
    +     * @param optional Integer $timeout
    +     * @param optional Math_BigInteger $p
    +     */
    +    function createKey($bits = 1024, $timeout = false, $partial = array())
    +    {
    +        if (!defined('CRYPT_RSA_EXPONENT')) {
    +            // http://en.wikipedia.org/wiki/65537_%28number%29
    +            define('CRYPT_RSA_EXPONENT', '65537');
    +        }
    +        // per , this number ought not result in primes smaller
    +        // than 256 bits. as a consequence if the key you're trying to create is 1024 bits and you've set CRYPT_RSA_SMALLEST_PRIME
    +        // to 384 bits then you're going to get a 384 bit prime and a 640 bit prime (384 + 1024 % 384). at least if
    +        // CRYPT_RSA_MODE is set to CRYPT_RSA_MODE_INTERNAL. if CRYPT_RSA_MODE is set to CRYPT_RSA_MODE_OPENSSL then
    +        // CRYPT_RSA_SMALLEST_PRIME is ignored (ie. multi-prime RSA support is more intended as a way to speed up RSA key
    +        // generation when there's a chance neither gmp nor OpenSSL are installed)
    +        if (!defined('CRYPT_RSA_SMALLEST_PRIME')) {
    +            define('CRYPT_RSA_SMALLEST_PRIME', 4096);
    +        }
    +
    +        // OpenSSL uses 65537 as the exponent and requires RSA keys be 384 bits minimum
    +        if ( CRYPT_RSA_MODE == CRYPT_RSA_MODE_OPENSSL && $bits >= 384 && CRYPT_RSA_EXPONENT == 65537) {
    +            $config = array();
    +            if (isset($this->configFile)) {
    +                $config['config'] = $this->configFile;
    +            }
    +            $rsa = openssl_pkey_new(array('private_key_bits' => $bits) + $config);
    +            openssl_pkey_export($rsa, $privatekey, null, $config);
    +            $publickey = openssl_pkey_get_details($rsa);
    +            $publickey = $publickey['key'];
    +
    +            $privatekey = call_user_func_array(array($this, '_convertPrivateKey'), array_values($this->_parseKey($privatekey, CRYPT_RSA_PRIVATE_FORMAT_PKCS1)));
    +            $publickey = call_user_func_array(array($this, '_convertPublicKey'), array_values($this->_parseKey($publickey, CRYPT_RSA_PUBLIC_FORMAT_PKCS1)));
    +
    +            // clear the buffer of error strings stemming from a minimalistic openssl.cnf
    +            while (openssl_error_string() !== false);
    +
    +            return array(
    +                'privatekey' => $privatekey,
    +                'publickey' => $publickey,
    +                'partialkey' => false
    +            );
    +        }
    +
    +        static $e;
    +        if (!isset($e)) {
    +            $e = new Math_BigInteger(CRYPT_RSA_EXPONENT);
    +        }
    +
    +        extract($this->_generateMinMax($bits));
    +        $absoluteMin = $min;
    +        $temp = $bits >> 1; // divide by two to see how many bits P and Q would be
    +        if ($temp > CRYPT_RSA_SMALLEST_PRIME) {
    +            $num_primes = floor($bits / CRYPT_RSA_SMALLEST_PRIME);
    +            $temp = CRYPT_RSA_SMALLEST_PRIME;
    +        } else {
    +            $num_primes = 2;
    +        }
    +        extract($this->_generateMinMax($temp + $bits % $temp));
    +        $finalMax = $max;
    +        extract($this->_generateMinMax($temp));
    +
    +        $generator = new Math_BigInteger();
    +
    +        $n = $this->one->copy();
    +        if (!empty($partial)) {
    +            extract(unserialize($partial));
    +        } else {
    +            $exponents = $coefficients = $primes = array();
    +            $lcm = array(
    +                'top' => $this->one->copy(),
    +                'bottom' => false
    +            );
    +        }
    +
    +        $start = time();
    +        $i0 = count($primes) + 1;
    +
    +        do {
    +            for ($i = $i0; $i <= $num_primes; $i++) {
    +                if ($timeout !== false) {
    +                    $timeout-= time() - $start;
    +                    $start = time();
    +                    if ($timeout <= 0) {
    +                        return array(
    +                            'privatekey' => '',
    +                            'publickey'  => '',
    +                            'partialkey' => serialize(array(
    +                                'primes' => $primes,
    +                                'coefficients' => $coefficients,
    +                                'lcm' => $lcm,
    +                                'exponents' => $exponents
    +                            ))
    +                        );
    +                    }
    +                }
    +
    +                if ($i == $num_primes) {
    +                    list($min, $temp) = $absoluteMin->divide($n);
    +                    if (!$temp->equals($this->zero)) {
    +                        $min = $min->add($this->one); // ie. ceil()
    +                    }
    +                    $primes[$i] = $generator->randomPrime($min, $finalMax, $timeout);
    +                } else {
    +                    $primes[$i] = $generator->randomPrime($min, $max, $timeout);
    +                }
    +
    +                if ($primes[$i] === false) { // if we've reached the timeout
    +                    if (count($primes) > 1) {
    +                        $partialkey = '';
    +                    } else {
    +                        array_pop($primes);
    +                        $partialkey = serialize(array(
    +                            'primes' => $primes,
    +                            'coefficients' => $coefficients,
    +                            'lcm' => $lcm,
    +                            'exponents' => $exponents
    +                        ));
    +                    }
    +
    +                    return array(
    +                        'privatekey' => '',
    +                        'publickey'  => '',
    +                        'partialkey' => $partialkey
    +                    );
    +                }
    +
    +                // the first coefficient is calculated differently from the rest
    +                // ie. instead of being $primes[1]->modInverse($primes[2]), it's $primes[2]->modInverse($primes[1])
    +                if ($i > 2) {
    +                    $coefficients[$i] = $n->modInverse($primes[$i]);
    +                }
    +
    +                $n = $n->multiply($primes[$i]);
    +
    +                $temp = $primes[$i]->subtract($this->one);
    +
    +                // textbook RSA implementations use Euler's totient function instead of the least common multiple.
    +                // see http://en.wikipedia.org/wiki/Euler%27s_totient_function
    +                $lcm['top'] = $lcm['top']->multiply($temp);
    +                $lcm['bottom'] = $lcm['bottom'] === false ? $temp : $lcm['bottom']->gcd($temp);
    +
    +                $exponents[$i] = $e->modInverse($temp);
    +            }
    +
    +            list($temp) = $lcm['top']->divide($lcm['bottom']);
    +            $gcd = $temp->gcd($e);
    +            $i0 = 1;
    +        } while (!$gcd->equals($this->one));
    +
    +        $d = $e->modInverse($temp);
    +
    +        $coefficients[2] = $primes[2]->modInverse($primes[1]);
    +
    +        // from :
    +        // RSAPrivateKey ::= SEQUENCE {
    +        //     version           Version,
    +        //     modulus           INTEGER,  -- n
    +        //     publicExponent    INTEGER,  -- e
    +        //     privateExponent   INTEGER,  -- d
    +        //     prime1            INTEGER,  -- p
    +        //     prime2            INTEGER,  -- q
    +        //     exponent1         INTEGER,  -- d mod (p-1)
    +        //     exponent2         INTEGER,  -- d mod (q-1)
    +        //     coefficient       INTEGER,  -- (inverse of q) mod p
    +        //     otherPrimeInfos   OtherPrimeInfos OPTIONAL
    +        // }
    +
    +        return array(
    +            'privatekey' => $this->_convertPrivateKey($n, $e, $d, $primes, $exponents, $coefficients),
    +            'publickey'  => $this->_convertPublicKey($n, $e),
    +            'partialkey' => false
    +        );
    +    }
    +
    +    /**
    +     * Convert a private key to the appropriate format.
    +     *
    +     * @access private
    +     * @see setPrivateKeyFormat()
    +     * @param String $RSAPrivateKey
    +     * @return String
    +     */
    +    function _convertPrivateKey($n, $e, $d, $primes, $exponents, $coefficients)
    +    {
    +        $num_primes = count($primes);
    +        $raw = array(
    +            'version' => $num_primes == 2 ? chr(0) : chr(1), // two-prime vs. multi
    +            'modulus' => $n->toBytes(true),
    +            'publicExponent' => $e->toBytes(true),
    +            'privateExponent' => $d->toBytes(true),
    +            'prime1' => $primes[1]->toBytes(true),
    +            'prime2' => $primes[2]->toBytes(true),
    +            'exponent1' => $exponents[1]->toBytes(true),
    +            'exponent2' => $exponents[2]->toBytes(true),
    +            'coefficient' => $coefficients[2]->toBytes(true)
    +        );
    +
    +        // if the format in question does not support multi-prime rsa and multi-prime rsa was used,
    +        // call _convertPublicKey() instead.
    +        switch ($this->privateKeyFormat) {
    +            case CRYPT_RSA_PRIVATE_FORMAT_XML:
    +                if ($num_primes != 2) {
    +                    return false;
    +                }
    +                return "\r\n" .
    +                       '  ' . base64_encode($raw['modulus']) . "\r\n" .
    +                       '  ' . base64_encode($raw['publicExponent']) . "\r\n" .
    +                       '  

    ' . base64_encode($raw['prime1']) . "

    \r\n" . + ' ' . base64_encode($raw['prime2']) . "\r\n" . + ' ' . base64_encode($raw['exponent1']) . "\r\n" . + ' ' . base64_encode($raw['exponent2']) . "\r\n" . + ' ' . base64_encode($raw['coefficient']) . "\r\n" . + ' ' . base64_encode($raw['privateExponent']) . "\r\n" . + '
    '; + break; + case CRYPT_RSA_PRIVATE_FORMAT_PUTTY: + if ($num_primes != 2) { + return false; + } + $key = "PuTTY-User-Key-File-2: ssh-rsa\r\nEncryption: "; + $encryption = (!empty($this->password) || is_string($this->password)) ? 'aes256-cbc' : 'none'; + $key.= $encryption; + $key.= "\r\nComment: " . $this->comment . "\r\n"; + $public = pack('Na*Na*Na*', + strlen('ssh-rsa'), 'ssh-rsa', strlen($raw['publicExponent']), $raw['publicExponent'], strlen($raw['modulus']), $raw['modulus'] + ); + $source = pack('Na*Na*Na*Na*', + strlen('ssh-rsa'), 'ssh-rsa', strlen($encryption), $encryption, + strlen($this->comment), $this->comment, strlen($public), $public + ); + $public = base64_encode($public); + $key.= "Public-Lines: " . ((strlen($public) + 63) >> 6) . "\r\n"; + $key.= chunk_split($public, 64); + $private = pack('Na*Na*Na*Na*', + strlen($raw['privateExponent']), $raw['privateExponent'], strlen($raw['prime1']), $raw['prime1'], + strlen($raw['prime2']), $raw['prime2'], strlen($raw['coefficient']), $raw['coefficient'] + ); + if (empty($this->password) && !is_string($this->password)) { + $source.= pack('Na*', strlen($private), $private); + $hashkey = 'putty-private-key-file-mac-key'; + } else { + $private.= crypt_random_string(16 - (strlen($private) & 15)); + $source.= pack('Na*', strlen($private), $private); + if (!class_exists('Crypt_AES')) { + include_once 'Crypt/AES.php'; + } + $sequence = 0; + $symkey = ''; + while (strlen($symkey) < 32) { + $temp = pack('Na*', $sequence++, $this->password); + $symkey.= pack('H*', sha1($temp)); + } + $symkey = substr($symkey, 0, 32); + $crypto = new Crypt_AES(); + + $crypto->setKey($symkey); + $crypto->disablePadding(); + $private = $crypto->encrypt($private); + $hashkey = 'putty-private-key-file-mac-key' . $this->password; + } + + $private = base64_encode($private); + $key.= 'Private-Lines: ' . ((strlen($private) + 63) >> 6) . "\r\n"; + $key.= chunk_split($private, 64); + if (!class_exists('Crypt_Hash')) { + include_once 'Crypt/Hash.php'; + } + $hash = new Crypt_Hash('sha1'); + $hash->setKey(pack('H*', sha1($hashkey))); + $key.= 'Private-MAC: ' . bin2hex($hash->hash($source)) . "\r\n"; + + return $key; + default: // eg. CRYPT_RSA_PRIVATE_FORMAT_PKCS1 + $components = array(); + foreach ($raw as $name => $value) { + $components[$name] = pack('Ca*a*', CRYPT_RSA_ASN1_INTEGER, $this->_encodeLength(strlen($value)), $value); + } + + $RSAPrivateKey = implode('', $components); + + if ($num_primes > 2) { + $OtherPrimeInfos = ''; + for ($i = 3; $i <= $num_primes; $i++) { + // OtherPrimeInfos ::= SEQUENCE SIZE(1..MAX) OF OtherPrimeInfo + // + // OtherPrimeInfo ::= SEQUENCE { + // prime INTEGER, -- ri + // exponent INTEGER, -- di + // coefficient INTEGER -- ti + // } + $OtherPrimeInfo = pack('Ca*a*', CRYPT_RSA_ASN1_INTEGER, $this->_encodeLength(strlen($primes[$i]->toBytes(true))), $primes[$i]->toBytes(true)); + $OtherPrimeInfo.= pack('Ca*a*', CRYPT_RSA_ASN1_INTEGER, $this->_encodeLength(strlen($exponents[$i]->toBytes(true))), $exponents[$i]->toBytes(true)); + $OtherPrimeInfo.= pack('Ca*a*', CRYPT_RSA_ASN1_INTEGER, $this->_encodeLength(strlen($coefficients[$i]->toBytes(true))), $coefficients[$i]->toBytes(true)); + $OtherPrimeInfos.= pack('Ca*a*', CRYPT_RSA_ASN1_SEQUENCE, $this->_encodeLength(strlen($OtherPrimeInfo)), $OtherPrimeInfo); + } + $RSAPrivateKey.= pack('Ca*a*', CRYPT_RSA_ASN1_SEQUENCE, $this->_encodeLength(strlen($OtherPrimeInfos)), $OtherPrimeInfos); + } + + $RSAPrivateKey = pack('Ca*a*', CRYPT_RSA_ASN1_SEQUENCE, $this->_encodeLength(strlen($RSAPrivateKey)), $RSAPrivateKey); + + if (!empty($this->password) || is_string($this->password)) { + $iv = crypt_random_string(8); + $symkey = pack('H*', md5($this->password . $iv)); // symkey is short for symmetric key + $symkey.= substr(pack('H*', md5($symkey . $this->password . $iv)), 0, 8); + if (!class_exists('Crypt_TripleDES')) { + include_once 'Crypt/TripleDES.php'; + } + $des = new Crypt_TripleDES(); + $des->setKey($symkey); + $des->setIV($iv); + $iv = strtoupper(bin2hex($iv)); + $RSAPrivateKey = "-----BEGIN RSA PRIVATE KEY-----\r\n" . + "Proc-Type: 4,ENCRYPTED\r\n" . + "DEK-Info: DES-EDE3-CBC,$iv\r\n" . + "\r\n" . + chunk_split(base64_encode($des->encrypt($RSAPrivateKey)), 64) . + '-----END RSA PRIVATE KEY-----'; + } else { + $RSAPrivateKey = "-----BEGIN RSA PRIVATE KEY-----\r\n" . + chunk_split(base64_encode($RSAPrivateKey), 64) . + '-----END RSA PRIVATE KEY-----'; + } + + return $RSAPrivateKey; + } + } + + /** + * Convert a public key to the appropriate format + * + * @access private + * @see setPublicKeyFormat() + * @param String $RSAPrivateKey + * @return String + */ + function _convertPublicKey($n, $e) + { + $modulus = $n->toBytes(true); + $publicExponent = $e->toBytes(true); + + switch ($this->publicKeyFormat) { + case CRYPT_RSA_PUBLIC_FORMAT_RAW: + return array('e' => $e->copy(), 'n' => $n->copy()); + case CRYPT_RSA_PUBLIC_FORMAT_XML: + return "\r\n" . + ' ' . base64_encode($modulus) . "\r\n" . + ' ' . base64_encode($publicExponent) . "\r\n" . + ''; + break; + case CRYPT_RSA_PUBLIC_FORMAT_OPENSSH: + // from : + // string "ssh-rsa" + // mpint e + // mpint n + $RSAPublicKey = pack('Na*Na*Na*', strlen('ssh-rsa'), 'ssh-rsa', strlen($publicExponent), $publicExponent, strlen($modulus), $modulus); + $RSAPublicKey = 'ssh-rsa ' . base64_encode($RSAPublicKey) . ' ' . $this->comment; + + return $RSAPublicKey; + default: // eg. CRYPT_RSA_PUBLIC_FORMAT_PKCS1_RAW or CRYPT_RSA_PUBLIC_FORMAT_PKCS1 + // from : + // RSAPublicKey ::= SEQUENCE { + // modulus INTEGER, -- n + // publicExponent INTEGER -- e + // } + $components = array( + 'modulus' => pack('Ca*a*', CRYPT_RSA_ASN1_INTEGER, $this->_encodeLength(strlen($modulus)), $modulus), + 'publicExponent' => pack('Ca*a*', CRYPT_RSA_ASN1_INTEGER, $this->_encodeLength(strlen($publicExponent)), $publicExponent) + ); + + $RSAPublicKey = pack('Ca*a*a*', + CRYPT_RSA_ASN1_SEQUENCE, $this->_encodeLength(strlen($components['modulus']) + strlen($components['publicExponent'])), + $components['modulus'], $components['publicExponent'] + ); + + if ($this->publicKeyFormat == CRYPT_RSA_PUBLIC_FORMAT_PKCS1) { + // sequence(oid(1.2.840.113549.1.1.1), null)) = rsaEncryption. + $rsaOID = pack('H*', '300d06092a864886f70d0101010500'); // hex version of MA0GCSqGSIb3DQEBAQUA + $RSAPublicKey = chr(0) . $RSAPublicKey; + $RSAPublicKey = chr(3) . $this->_encodeLength(strlen($RSAPublicKey)) . $RSAPublicKey; + + $RSAPublicKey = pack('Ca*a*', + CRYPT_RSA_ASN1_SEQUENCE, $this->_encodeLength(strlen($rsaOID . $RSAPublicKey)), $rsaOID . $RSAPublicKey + ); + } + + $RSAPublicKey = "-----BEGIN PUBLIC KEY-----\r\n" . + chunk_split(base64_encode($RSAPublicKey), 64) . + '-----END PUBLIC KEY-----'; + + return $RSAPublicKey; + } + } + + /** + * Break a public or private key down into its constituant components + * + * @access private + * @see _convertPublicKey() + * @see _convertPrivateKey() + * @param String $key + * @param Integer $type + * @return Array + */ + function _parseKey($key, $type) + { + if ($type != CRYPT_RSA_PUBLIC_FORMAT_RAW && !is_string($key)) { + return false; + } + + switch ($type) { + case CRYPT_RSA_PUBLIC_FORMAT_RAW: + if (!is_array($key)) { + return false; + } + $components = array(); + switch (true) { + case isset($key['e']): + $components['publicExponent'] = $key['e']->copy(); + break; + case isset($key['exponent']): + $components['publicExponent'] = $key['exponent']->copy(); + break; + case isset($key['publicExponent']): + $components['publicExponent'] = $key['publicExponent']->copy(); + break; + case isset($key[0]): + $components['publicExponent'] = $key[0]->copy(); + } + switch (true) { + case isset($key['n']): + $components['modulus'] = $key['n']->copy(); + break; + case isset($key['modulo']): + $components['modulus'] = $key['modulo']->copy(); + break; + case isset($key['modulus']): + $components['modulus'] = $key['modulus']->copy(); + break; + case isset($key[1]): + $components['modulus'] = $key[1]->copy(); + } + return isset($components['modulus']) && isset($components['publicExponent']) ? $components : false; + case CRYPT_RSA_PRIVATE_FORMAT_PKCS1: + case CRYPT_RSA_PUBLIC_FORMAT_PKCS1: + /* Although PKCS#1 proposes a format that public and private keys can use, encrypting them is + "outside the scope" of PKCS#1. PKCS#1 then refers you to PKCS#12 and PKCS#15 if you're wanting to + protect private keys, however, that's not what OpenSSL* does. OpenSSL protects private keys by adding + two new "fields" to the key - DEK-Info and Proc-Type. These fields are discussed here: + + http://tools.ietf.org/html/rfc1421#section-4.6.1.1 + http://tools.ietf.org/html/rfc1421#section-4.6.1.3 + + DES-EDE3-CBC as an algorithm, however, is not discussed anywhere, near as I can tell. + DES-CBC and DES-EDE are discussed in RFC1423, however, DES-EDE3-CBC isn't, nor is its key derivation + function. As is, the definitive authority on this encoding scheme isn't the IETF but rather OpenSSL's + own implementation. ie. the implementation *is* the standard and any bugs that may exist in that + implementation are part of the standard, as well. + + * OpenSSL is the de facto standard. It's utilized by OpenSSH and other projects */ + if (preg_match('#DEK-Info: (.+),(.+)#', $key, $matches)) { + $iv = pack('H*', trim($matches[2])); + $symkey = pack('H*', md5($this->password . substr($iv, 0, 8))); // symkey is short for symmetric key + $symkey.= pack('H*', md5($symkey . $this->password . substr($iv, 0, 8))); + // remove the Proc-Type / DEK-Info sections as they're no longer needed + $key = preg_replace('#^(?:Proc-Type|DEK-Info): .*#m', '', $key); + $ciphertext = $this->_extractBER($key); + if ($ciphertext === false) { + $ciphertext = $key; + } + switch ($matches[1]) { + case 'AES-256-CBC': + if (!class_exists('Crypt_AES')) { + include_once 'Crypt/AES.php'; + } + $crypto = new Crypt_AES(); + break; + case 'AES-128-CBC': + if (!class_exists('Crypt_AES')) { + include_once 'Crypt/AES.php'; + } + $symkey = substr($symkey, 0, 16); + $crypto = new Crypt_AES(); + break; + case 'DES-EDE3-CFB': + if (!class_exists('Crypt_TripleDES')) { + include_once 'Crypt/TripleDES.php'; + } + $crypto = new Crypt_TripleDES(CRYPT_DES_MODE_CFB); + break; + case 'DES-EDE3-CBC': + if (!class_exists('Crypt_TripleDES')) { + include_once 'Crypt/TripleDES.php'; + } + $symkey = substr($symkey, 0, 24); + $crypto = new Crypt_TripleDES(); + break; + case 'DES-CBC': + if (!class_exists('Crypt_DES')) { + include_once 'Crypt/DES.php'; + } + $crypto = new Crypt_DES(); + break; + default: + return false; + } + $crypto->setKey($symkey); + $crypto->setIV($iv); + $decoded = $crypto->decrypt($ciphertext); + } else { + $decoded = $this->_extractBER($key); + } + + if ($decoded !== false) { + $key = $decoded; + } + + $components = array(); + + if (ord($this->_string_shift($key)) != CRYPT_RSA_ASN1_SEQUENCE) { + return false; + } + if ($this->_decodeLength($key) != strlen($key)) { + return false; + } + + $tag = ord($this->_string_shift($key)); + /* intended for keys for which OpenSSL's asn1parse returns the following: + + 0:d=0 hl=4 l= 631 cons: SEQUENCE + 4:d=1 hl=2 l= 1 prim: INTEGER :00 + 7:d=1 hl=2 l= 13 cons: SEQUENCE + 9:d=2 hl=2 l= 9 prim: OBJECT :rsaEncryption + 20:d=2 hl=2 l= 0 prim: NULL + 22:d=1 hl=4 l= 609 prim: OCTET STRING */ + + if ($tag == CRYPT_RSA_ASN1_INTEGER && substr($key, 0, 3) == "\x01\x00\x30") { + $this->_string_shift($key, 3); + $tag = CRYPT_RSA_ASN1_SEQUENCE; + } + + if ($tag == CRYPT_RSA_ASN1_SEQUENCE) { + /* intended for keys for which OpenSSL's asn1parse returns the following: + + 0:d=0 hl=4 l= 290 cons: SEQUENCE + 4:d=1 hl=2 l= 13 cons: SEQUENCE + 6:d=2 hl=2 l= 9 prim: OBJECT :rsaEncryption + 17:d=2 hl=2 l= 0 prim: NULL + 19:d=1 hl=4 l= 271 prim: BIT STRING */ + $this->_string_shift($key, $this->_decodeLength($key)); + $tag = ord($this->_string_shift($key)); // skip over the BIT STRING / OCTET STRING tag + $this->_decodeLength($key); // skip over the BIT STRING / OCTET STRING length + // "The initial octet shall encode, as an unsigned binary integer wtih bit 1 as the least significant bit, the number of + // unused bits in the final subsequent octet. The number shall be in the range zero to seven." + // -- http://www.itu.int/ITU-T/studygroups/com17/languages/X.690-0207.pdf (section 8.6.2.2) + if ($tag == CRYPT_RSA_ASN1_BITSTRING) { + $this->_string_shift($key); + } + if (ord($this->_string_shift($key)) != CRYPT_RSA_ASN1_SEQUENCE) { + return false; + } + if ($this->_decodeLength($key) != strlen($key)) { + return false; + } + $tag = ord($this->_string_shift($key)); + } + if ($tag != CRYPT_RSA_ASN1_INTEGER) { + return false; + } + + $length = $this->_decodeLength($key); + $temp = $this->_string_shift($key, $length); + if (strlen($temp) != 1 || ord($temp) > 2) { + $components['modulus'] = new Math_BigInteger($temp, 256); + $this->_string_shift($key); // skip over CRYPT_RSA_ASN1_INTEGER + $length = $this->_decodeLength($key); + $components[$type == CRYPT_RSA_PUBLIC_FORMAT_PKCS1 ? 'publicExponent' : 'privateExponent'] = new Math_BigInteger($this->_string_shift($key, $length), 256); + + return $components; + } + if (ord($this->_string_shift($key)) != CRYPT_RSA_ASN1_INTEGER) { + return false; + } + $length = $this->_decodeLength($key); + $components['modulus'] = new Math_BigInteger($this->_string_shift($key, $length), 256); + $this->_string_shift($key); + $length = $this->_decodeLength($key); + $components['publicExponent'] = new Math_BigInteger($this->_string_shift($key, $length), 256); + $this->_string_shift($key); + $length = $this->_decodeLength($key); + $components['privateExponent'] = new Math_BigInteger($this->_string_shift($key, $length), 256); + $this->_string_shift($key); + $length = $this->_decodeLength($key); + $components['primes'] = array(1 => new Math_BigInteger($this->_string_shift($key, $length), 256)); + $this->_string_shift($key); + $length = $this->_decodeLength($key); + $components['primes'][] = new Math_BigInteger($this->_string_shift($key, $length), 256); + $this->_string_shift($key); + $length = $this->_decodeLength($key); + $components['exponents'] = array(1 => new Math_BigInteger($this->_string_shift($key, $length), 256)); + $this->_string_shift($key); + $length = $this->_decodeLength($key); + $components['exponents'][] = new Math_BigInteger($this->_string_shift($key, $length), 256); + $this->_string_shift($key); + $length = $this->_decodeLength($key); + $components['coefficients'] = array(2 => new Math_BigInteger($this->_string_shift($key, $length), 256)); + + if (!empty($key)) { + if (ord($this->_string_shift($key)) != CRYPT_RSA_ASN1_SEQUENCE) { + return false; + } + $this->_decodeLength($key); + while (!empty($key)) { + if (ord($this->_string_shift($key)) != CRYPT_RSA_ASN1_SEQUENCE) { + return false; + } + $this->_decodeLength($key); + $key = substr($key, 1); + $length = $this->_decodeLength($key); + $components['primes'][] = new Math_BigInteger($this->_string_shift($key, $length), 256); + $this->_string_shift($key); + $length = $this->_decodeLength($key); + $components['exponents'][] = new Math_BigInteger($this->_string_shift($key, $length), 256); + $this->_string_shift($key); + $length = $this->_decodeLength($key); + $components['coefficients'][] = new Math_BigInteger($this->_string_shift($key, $length), 256); + } + } + + return $components; + case CRYPT_RSA_PUBLIC_FORMAT_OPENSSH: + $parts = explode(' ', $key, 3); + + $key = isset($parts[1]) ? base64_decode($parts[1]) : false; + if ($key === false) { + return false; + } + + $comment = isset($parts[2]) ? $parts[2] : false; + + $cleanup = substr($key, 0, 11) == "\0\0\0\7ssh-rsa"; + + if (strlen($key) <= 4) { + return false; + } + extract(unpack('Nlength', $this->_string_shift($key, 4))); + $publicExponent = new Math_BigInteger($this->_string_shift($key, $length), -256); + if (strlen($key) <= 4) { + return false; + } + extract(unpack('Nlength', $this->_string_shift($key, 4))); + $modulus = new Math_BigInteger($this->_string_shift($key, $length), -256); + + if ($cleanup && strlen($key)) { + if (strlen($key) <= 4) { + return false; + } + extract(unpack('Nlength', $this->_string_shift($key, 4))); + $realModulus = new Math_BigInteger($this->_string_shift($key, $length), -256); + return strlen($key) ? false : array( + 'modulus' => $realModulus, + 'publicExponent' => $modulus, + 'comment' => $comment + ); + } else { + return strlen($key) ? false : array( + 'modulus' => $modulus, + 'publicExponent' => $publicExponent, + 'comment' => $comment + ); + } + // http://www.w3.org/TR/xmldsig-core/#sec-RSAKeyValue + // http://en.wikipedia.org/wiki/XML_Signature + case CRYPT_RSA_PRIVATE_FORMAT_XML: + case CRYPT_RSA_PUBLIC_FORMAT_XML: + $this->components = array(); + + $xml = xml_parser_create('UTF-8'); + xml_set_object($xml, $this); + xml_set_element_handler($xml, '_start_element_handler', '_stop_element_handler'); + xml_set_character_data_handler($xml, '_data_handler'); + // add to account for "dangling" tags like ... that are sometimes added + if (!xml_parse($xml, '' . $key . '')) { + return false; + } + + return isset($this->components['modulus']) && isset($this->components['publicExponent']) ? $this->components : false; + // from PuTTY's SSHPUBK.C + case CRYPT_RSA_PRIVATE_FORMAT_PUTTY: + $components = array(); + $key = preg_split('#\r\n|\r|\n#', $key); + $type = trim(preg_replace('#PuTTY-User-Key-File-2: (.+)#', '$1', $key[0])); + if ($type != 'ssh-rsa') { + return false; + } + $encryption = trim(preg_replace('#Encryption: (.+)#', '$1', $key[1])); + $comment = trim(preg_replace('#Comment: (.+)#', '$1', $key[2])); + + $publicLength = trim(preg_replace('#Public-Lines: (\d+)#', '$1', $key[3])); + $public = base64_decode(implode('', array_map('trim', array_slice($key, 4, $publicLength)))); + $public = substr($public, 11); + extract(unpack('Nlength', $this->_string_shift($public, 4))); + $components['publicExponent'] = new Math_BigInteger($this->_string_shift($public, $length), -256); + extract(unpack('Nlength', $this->_string_shift($public, 4))); + $components['modulus'] = new Math_BigInteger($this->_string_shift($public, $length), -256); + + $privateLength = trim(preg_replace('#Private-Lines: (\d+)#', '$1', $key[$publicLength + 4])); + $private = base64_decode(implode('', array_map('trim', array_slice($key, $publicLength + 5, $privateLength)))); + + switch ($encryption) { + case 'aes256-cbc': + if (!class_exists('Crypt_AES')) { + include_once 'Crypt/AES.php'; + } + $symkey = ''; + $sequence = 0; + while (strlen($symkey) < 32) { + $temp = pack('Na*', $sequence++, $this->password); + $symkey.= pack('H*', sha1($temp)); + } + $symkey = substr($symkey, 0, 32); + $crypto = new Crypt_AES(); + } + + if ($encryption != 'none') { + $crypto->setKey($symkey); + $crypto->disablePadding(); + $private = $crypto->decrypt($private); + if ($private === false) { + return false; + } + } + + extract(unpack('Nlength', $this->_string_shift($private, 4))); + if (strlen($private) < $length) { + return false; + } + $components['privateExponent'] = new Math_BigInteger($this->_string_shift($private, $length), -256); + extract(unpack('Nlength', $this->_string_shift($private, 4))); + if (strlen($private) < $length) { + return false; + } + $components['primes'] = array(1 => new Math_BigInteger($this->_string_shift($private, $length), -256)); + extract(unpack('Nlength', $this->_string_shift($private, 4))); + if (strlen($private) < $length) { + return false; + } + $components['primes'][] = new Math_BigInteger($this->_string_shift($private, $length), -256); + + $temp = $components['primes'][1]->subtract($this->one); + $components['exponents'] = array(1 => $components['publicExponent']->modInverse($temp)); + $temp = $components['primes'][2]->subtract($this->one); + $components['exponents'][] = $components['publicExponent']->modInverse($temp); + + extract(unpack('Nlength', $this->_string_shift($private, 4))); + if (strlen($private) < $length) { + return false; + } + $components['coefficients'] = array(2 => new Math_BigInteger($this->_string_shift($private, $length), -256)); + + return $components; + } + } + + /** + * Returns the key size + * + * More specifically, this returns the size of the modulo in bits. + * + * @access public + * @return Integer + */ + function getSize() + { + return !isset($this->modulus) ? 0 : strlen($this->modulus->toBits()); + } + + /** + * Start Element Handler + * + * Called by xml_set_element_handler() + * + * @access private + * @param Resource $parser + * @param String $name + * @param Array $attribs + */ + function _start_element_handler($parser, $name, $attribs) + { + //$name = strtoupper($name); + switch ($name) { + case 'MODULUS': + $this->current = &$this->components['modulus']; + break; + case 'EXPONENT': + $this->current = &$this->components['publicExponent']; + break; + case 'P': + $this->current = &$this->components['primes'][1]; + break; + case 'Q': + $this->current = &$this->components['primes'][2]; + break; + case 'DP': + $this->current = &$this->components['exponents'][1]; + break; + case 'DQ': + $this->current = &$this->components['exponents'][2]; + break; + case 'INVERSEQ': + $this->current = &$this->components['coefficients'][2]; + break; + case 'D': + $this->current = &$this->components['privateExponent']; + } + $this->current = ''; + } + + /** + * Stop Element Handler + * + * Called by xml_set_element_handler() + * + * @access private + * @param Resource $parser + * @param String $name + */ + function _stop_element_handler($parser, $name) + { + if (isset($this->current)) { + $this->current = new Math_BigInteger(base64_decode($this->current), 256); + unset($this->current); + } + } + + /** + * Data Handler + * + * Called by xml_set_character_data_handler() + * + * @access private + * @param Resource $parser + * @param String $data + */ + function _data_handler($parser, $data) + { + if (!isset($this->current) || is_object($this->current)) { + return; + } + $this->current.= trim($data); + } + + /** + * Loads a public or private key + * + * Returns true on success and false on failure (ie. an incorrect password was provided or the key was malformed) + * + * @access public + * @param String $key + * @param Integer $type optional + */ + function loadKey($key, $type = false) + { + if (is_object($key) && strtolower(get_class($key)) == 'crypt_rsa') { + $this->privateKeyFormat = $key->privateKeyFormat; + $this->publicKeyFormat = $key->publicKeyFormat; + $this->k = $key->k; + $this->hLen = $key->hLen; + $this->sLen = $key->sLen; + $this->mgfHLen = $key->mgfHLen; + $this->encryptionMode = $key->encryptionMode; + $this->signatureMode = $key->signatureMode; + $this->password = $key->password; + $this->configFile = $key->configFile; + $this->comment = $key->comment; + + if (is_object($key->hash)) { + $this->hash = new Crypt_Hash($key->hash->getHash()); + } + if (is_object($key->mgfHash)) { + $this->mgfHash = new Crypt_Hash($key->mgfHash->getHash()); + } + + if (is_object($key->modulus)) { + $this->modulus = $key->modulus->copy(); + } + if (is_object($key->exponent)) { + $this->exponent = $key->exponent->copy(); + } + if (is_object($key->publicExponent)) { + $this->publicExponent = $key->publicExponent->copy(); + } + + $this->primes = array(); + $this->exponents = array(); + $this->coefficients = array(); + + foreach ($this->primes as $prime) { + $this->primes[] = $prime->copy(); + } + foreach ($this->exponents as $exponent) { + $this->exponents[] = $exponent->copy(); + } + foreach ($this->coefficients as $coefficient) { + $this->coefficients[] = $coefficient->copy(); + } + + return true; + } + + if ($type === false) { + $types = array( + CRYPT_RSA_PUBLIC_FORMAT_RAW, + CRYPT_RSA_PRIVATE_FORMAT_PKCS1, + CRYPT_RSA_PRIVATE_FORMAT_XML, + CRYPT_RSA_PRIVATE_FORMAT_PUTTY, + CRYPT_RSA_PUBLIC_FORMAT_OPENSSH + ); + foreach ($types as $type) { + $components = $this->_parseKey($key, $type); + if ($components !== false) { + break; + } + } + + } else { + $components = $this->_parseKey($key, $type); + } + + if ($components === false) { + return false; + } + + if (isset($components['comment']) && $components['comment'] !== false) { + $this->comment = $components['comment']; + } + $this->modulus = $components['modulus']; + $this->k = strlen($this->modulus->toBytes()); + $this->exponent = isset($components['privateExponent']) ? $components['privateExponent'] : $components['publicExponent']; + if (isset($components['primes'])) { + $this->primes = $components['primes']; + $this->exponents = $components['exponents']; + $this->coefficients = $components['coefficients']; + $this->publicExponent = $components['publicExponent']; + } else { + $this->primes = array(); + $this->exponents = array(); + $this->coefficients = array(); + $this->publicExponent = false; + } + + return true; + } + + /** + * Sets the password + * + * Private keys can be encrypted with a password. To unset the password, pass in the empty string or false. + * Or rather, pass in $password such that empty($password) && !is_string($password) is true. + * + * @see createKey() + * @see loadKey() + * @access public + * @param String $password + */ + function setPassword($password = false) + { + $this->password = $password; + } + + /** + * Defines the public key + * + * Some private key formats define the public exponent and some don't. Those that don't define it are problematic when + * used in certain contexts. For example, in SSH-2, RSA authentication works by sending the public key along with a + * message signed by the private key to the server. The SSH-2 server looks the public key up in an index of public keys + * and if it's present then proceeds to verify the signature. Problem is, if your private key doesn't include the public + * exponent this won't work unless you manually add the public exponent. + * + * Do note that when a new key is loaded the index will be cleared. + * + * Returns true on success, false on failure + * + * @see getPublicKey() + * @access public + * @param String $key optional + * @param Integer $type optional + * @return Boolean + */ + function setPublicKey($key = false, $type = false) + { + // if a public key has already been loaded return false + if (!empty($this->publicExponent)) { + return false; + } + + if ($key === false && !empty($this->modulus)) { + $this->publicExponent = $this->exponent; + return true; + } + + if ($type === false) { + $types = array( + CRYPT_RSA_PUBLIC_FORMAT_RAW, + CRYPT_RSA_PUBLIC_FORMAT_PKCS1, + CRYPT_RSA_PUBLIC_FORMAT_XML, + CRYPT_RSA_PUBLIC_FORMAT_OPENSSH + ); + foreach ($types as $type) { + $components = $this->_parseKey($key, $type); + if ($components !== false) { + break; + } + } + } else { + $components = $this->_parseKey($key, $type); + } + + if ($components === false) { + return false; + } + + if (empty($this->modulus) || !$this->modulus->equals($components['modulus'])) { + $this->modulus = $components['modulus']; + $this->exponent = $this->publicExponent = $components['publicExponent']; + return true; + } + + $this->publicExponent = $components['publicExponent']; + + return true; + } + + /** + * Returns the public key + * + * The public key is only returned under two circumstances - if the private key had the public key embedded within it + * or if the public key was set via setPublicKey(). If the currently loaded key is supposed to be the public key this + * function won't return it since this library, for the most part, doesn't distinguish between public and private keys. + * + * @see getPublicKey() + * @access public + * @param String $key + * @param Integer $type optional + */ + function getPublicKey($type = CRYPT_RSA_PUBLIC_FORMAT_PKCS1) + { + if (empty($this->modulus) || empty($this->publicExponent)) { + return false; + } + + $oldFormat = $this->publicKeyFormat; + $this->publicKeyFormat = $type; + $temp = $this->_convertPublicKey($this->modulus, $this->publicExponent); + $this->publicKeyFormat = $oldFormat; + return $temp; + } + + /** + * Returns the private key + * + * The private key is only returned if the currently loaded key contains the constituent prime numbers. + * + * @see getPublicKey() + * @access public + * @param String $key + * @param Integer $type optional + */ + function getPrivateKey($type = CRYPT_RSA_PUBLIC_FORMAT_PKCS1) + { + if (empty($this->primes)) { + return false; + } + + $oldFormat = $this->privateKeyFormat; + $this->privateKeyFormat = $type; + $temp = $this->_convertPrivateKey($this->modulus, $this->publicExponent, $this->exponent, $this->primes, $this->exponents, $this->coefficients); + $this->privateKeyFormat = $oldFormat; + return $temp; + } + + /** + * Returns a minimalistic private key + * + * Returns the private key without the prime number constituants. Structurally identical to a public key that + * hasn't been set as the public key + * + * @see getPrivateKey() + * @access private + * @param String $key + * @param Integer $type optional + */ + function _getPrivatePublicKey($mode = CRYPT_RSA_PUBLIC_FORMAT_PKCS1) + { + if (empty($this->modulus) || empty($this->exponent)) { + return false; + } + + $oldFormat = $this->publicKeyFormat; + $this->publicKeyFormat = $mode; + $temp = $this->_convertPublicKey($this->modulus, $this->exponent); + $this->publicKeyFormat = $oldFormat; + return $temp; + } + + /** + * __toString() magic method + * + * @access public + */ + function __toString() + { + $key = $this->getPrivateKey($this->privateKeyFormat); + if ($key !== false) { + return $key; + } + $key = $this->_getPrivatePublicKey($this->publicKeyFormat); + return $key !== false ? $key : ''; + } + + /** + * __clone() magic method + * + * @access public + */ + function __clone() + { + $key = new Crypt_RSA(); + $key->loadKey($this); + return $key; + } + + /** + * Generates the smallest and largest numbers requiring $bits bits + * + * @access private + * @param Integer $bits + * @return Array + */ + function _generateMinMax($bits) + { + $bytes = $bits >> 3; + $min = str_repeat(chr(0), $bytes); + $max = str_repeat(chr(0xFF), $bytes); + $msb = $bits & 7; + if ($msb) { + $min = chr(1 << ($msb - 1)) . $min; + $max = chr((1 << $msb) - 1) . $max; + } else { + $min[0] = chr(0x80); + } + + return array( + 'min' => new Math_BigInteger($min, 256), + 'max' => new Math_BigInteger($max, 256) + ); + } + + /** + * DER-decode the length + * + * DER supports lengths up to (2**8)**127, however, we'll only support lengths up to (2**8)**4. See + * {@link http://itu.int/ITU-T/studygroups/com17/languages/X.690-0207.pdf#p=13 X.690 paragraph 8.1.3} for more information. + * + * @access private + * @param String $string + * @return Integer + */ + function _decodeLength(&$string) + { + $length = ord($this->_string_shift($string)); + if ( $length & 0x80 ) { // definite length, long form + $length&= 0x7F; + $temp = $this->_string_shift($string, $length); + list(, $length) = unpack('N', substr(str_pad($temp, 4, chr(0), STR_PAD_LEFT), -4)); + } + return $length; + } + + /** + * DER-encode the length + * + * DER supports lengths up to (2**8)**127, however, we'll only support lengths up to (2**8)**4. See + * {@link http://itu.int/ITU-T/studygroups/com17/languages/X.690-0207.pdf#p=13 X.690 paragraph 8.1.3} for more information. + * + * @access private + * @param Integer $length + * @return String + */ + function _encodeLength($length) + { + if ($length <= 0x7F) { + return chr($length); + } + + $temp = ltrim(pack('N', $length), chr(0)); + return pack('Ca*', 0x80 | strlen($temp), $temp); + } + + /** + * String Shift + * + * Inspired by array_shift + * + * @param String $string + * @param optional Integer $index + * @return String + * @access private + */ + function _string_shift(&$string, $index = 1) + { + $substr = substr($string, 0, $index); + $string = substr($string, $index); + return $substr; + } + + /** + * Determines the private key format + * + * @see createKey() + * @access public + * @param Integer $format + */ + function setPrivateKeyFormat($format) + { + $this->privateKeyFormat = $format; + } + + /** + * Determines the public key format + * + * @see createKey() + * @access public + * @param Integer $format + */ + function setPublicKeyFormat($format) + { + $this->publicKeyFormat = $format; + } + + /** + * Determines which hashing function should be used + * + * Used with signature production / verification and (if the encryption mode is CRYPT_RSA_ENCRYPTION_OAEP) encryption and + * decryption. If $hash isn't supported, sha1 is used. + * + * @access public + * @param String $hash + */ + function setHash($hash) + { + // Crypt_Hash supports algorithms that PKCS#1 doesn't support. md5-96 and sha1-96, for example. + switch ($hash) { + case 'md2': + case 'md5': + case 'sha1': + case 'sha256': + case 'sha384': + case 'sha512': + $this->hash = new Crypt_Hash($hash); + $this->hashName = $hash; + break; + default: + $this->hash = new Crypt_Hash('sha1'); + $this->hashName = 'sha1'; + } + $this->hLen = $this->hash->getLength(); + } + + /** + * Determines which hashing function should be used for the mask generation function + * + * The mask generation function is used by CRYPT_RSA_ENCRYPTION_OAEP and CRYPT_RSA_SIGNATURE_PSS and although it's + * best if Hash and MGFHash are set to the same thing this is not a requirement. + * + * @access public + * @param String $hash + */ + function setMGFHash($hash) + { + // Crypt_Hash supports algorithms that PKCS#1 doesn't support. md5-96 and sha1-96, for example. + switch ($hash) { + case 'md2': + case 'md5': + case 'sha1': + case 'sha256': + case 'sha384': + case 'sha512': + $this->mgfHash = new Crypt_Hash($hash); + break; + default: + $this->mgfHash = new Crypt_Hash('sha1'); + } + $this->mgfHLen = $this->mgfHash->getLength(); + } + + /** + * Determines the salt length + * + * To quote from {@link http://tools.ietf.org/html/rfc3447#page-38 RFC3447#page-38}: + * + * Typical salt lengths in octets are hLen (the length of the output + * of the hash function Hash) and 0. + * + * @access public + * @param Integer $format + */ + function setSaltLength($sLen) + { + $this->sLen = $sLen; + } + + /** + * Integer-to-Octet-String primitive + * + * See {@link http://tools.ietf.org/html/rfc3447#section-4.1 RFC3447#section-4.1}. + * + * @access private + * @param Math_BigInteger $x + * @param Integer $xLen + * @return String + */ + function _i2osp($x, $xLen) + { + $x = $x->toBytes(); + if (strlen($x) > $xLen) { + user_error('Integer too large'); + return false; + } + return str_pad($x, $xLen, chr(0), STR_PAD_LEFT); + } + + /** + * Octet-String-to-Integer primitive + * + * See {@link http://tools.ietf.org/html/rfc3447#section-4.2 RFC3447#section-4.2}. + * + * @access private + * @param String $x + * @return Math_BigInteger + */ + function _os2ip($x) + { + return new Math_BigInteger($x, 256); + } + + /** + * Exponentiate with or without Chinese Remainder Theorem + * + * See {@link http://tools.ietf.org/html/rfc3447#section-5.1.1 RFC3447#section-5.1.2}. + * + * @access private + * @param Math_BigInteger $x + * @return Math_BigInteger + */ + function _exponentiate($x) + { + if (empty($this->primes) || empty($this->coefficients) || empty($this->exponents)) { + return $x->modPow($this->exponent, $this->modulus); + } + + $num_primes = count($this->primes); + + if (defined('CRYPT_RSA_DISABLE_BLINDING')) { + $m_i = array( + 1 => $x->modPow($this->exponents[1], $this->primes[1]), + 2 => $x->modPow($this->exponents[2], $this->primes[2]) + ); + $h = $m_i[1]->subtract($m_i[2]); + $h = $h->multiply($this->coefficients[2]); + list(, $h) = $h->divide($this->primes[1]); + $m = $m_i[2]->add($h->multiply($this->primes[2])); + + $r = $this->primes[1]; + for ($i = 3; $i <= $num_primes; $i++) { + $m_i = $x->modPow($this->exponents[$i], $this->primes[$i]); + + $r = $r->multiply($this->primes[$i - 1]); + + $h = $m_i->subtract($m); + $h = $h->multiply($this->coefficients[$i]); + list(, $h) = $h->divide($this->primes[$i]); + + $m = $m->add($r->multiply($h)); + } + } else { + $smallest = $this->primes[1]; + for ($i = 2; $i <= $num_primes; $i++) { + if ($smallest->compare($this->primes[$i]) > 0) { + $smallest = $this->primes[$i]; + } + } + + $one = new Math_BigInteger(1); + + $r = $one->random($one, $smallest->subtract($one)); + + $m_i = array( + 1 => $this->_blind($x, $r, 1), + 2 => $this->_blind($x, $r, 2) + ); + $h = $m_i[1]->subtract($m_i[2]); + $h = $h->multiply($this->coefficients[2]); + list(, $h) = $h->divide($this->primes[1]); + $m = $m_i[2]->add($h->multiply($this->primes[2])); + + $r = $this->primes[1]; + for ($i = 3; $i <= $num_primes; $i++) { + $m_i = $this->_blind($x, $r, $i); + + $r = $r->multiply($this->primes[$i - 1]); + + $h = $m_i->subtract($m); + $h = $h->multiply($this->coefficients[$i]); + list(, $h) = $h->divide($this->primes[$i]); + + $m = $m->add($r->multiply($h)); + } + } + + return $m; + } + + /** + * Performs RSA Blinding + * + * Protects against timing attacks by employing RSA Blinding. + * Returns $x->modPow($this->exponents[$i], $this->primes[$i]) + * + * @access private + * @param Math_BigInteger $x + * @param Math_BigInteger $r + * @param Integer $i + * @return Math_BigInteger + */ + function _blind($x, $r, $i) + { + $x = $x->multiply($r->modPow($this->publicExponent, $this->primes[$i])); + $x = $x->modPow($this->exponents[$i], $this->primes[$i]); + + $r = $r->modInverse($this->primes[$i]); + $x = $x->multiply($r); + list(, $x) = $x->divide($this->primes[$i]); + + return $x; + } + + /** + * Performs blinded RSA equality testing + * + * Protects against a particular type of timing attack described. + * + * See {@link http://codahale.com/a-lesson-in-timing-attacks/ A Lesson In Timing Attacks (or, Don't use MessageDigest.isEquals)} + * + * Thanks for the heads up singpolyma! + * + * @access private + * @param String $x + * @param String $y + * @return Boolean + */ + function _equals($x, $y) + { + if (strlen($x) != strlen($y)) { + return false; + } + + $result = 0; + for ($i = 0; $i < strlen($x); $i++) { + $result |= ord($x[$i]) ^ ord($y[$i]); + } + + return $result == 0; + } + + /** + * RSAEP + * + * See {@link http://tools.ietf.org/html/rfc3447#section-5.1.1 RFC3447#section-5.1.1}. + * + * @access private + * @param Math_BigInteger $m + * @return Math_BigInteger + */ + function _rsaep($m) + { + if ($m->compare($this->zero) < 0 || $m->compare($this->modulus) > 0) { + user_error('Message representative out of range'); + return false; + } + return $this->_exponentiate($m); + } + + /** + * RSADP + * + * See {@link http://tools.ietf.org/html/rfc3447#section-5.1.2 RFC3447#section-5.1.2}. + * + * @access private + * @param Math_BigInteger $c + * @return Math_BigInteger + */ + function _rsadp($c) + { + if ($c->compare($this->zero) < 0 || $c->compare($this->modulus) > 0) { + user_error('Ciphertext representative out of range'); + return false; + } + return $this->_exponentiate($c); + } + + /** + * RSASP1 + * + * See {@link http://tools.ietf.org/html/rfc3447#section-5.2.1 RFC3447#section-5.2.1}. + * + * @access private + * @param Math_BigInteger $m + * @return Math_BigInteger + */ + function _rsasp1($m) + { + if ($m->compare($this->zero) < 0 || $m->compare($this->modulus) > 0) { + user_error('Message representative out of range'); + return false; + } + return $this->_exponentiate($m); + } + + /** + * RSAVP1 + * + * See {@link http://tools.ietf.org/html/rfc3447#section-5.2.2 RFC3447#section-5.2.2}. + * + * @access private + * @param Math_BigInteger $s + * @return Math_BigInteger + */ + function _rsavp1($s) + { + if ($s->compare($this->zero) < 0 || $s->compare($this->modulus) > 0) { + user_error('Signature representative out of range'); + return false; + } + return $this->_exponentiate($s); + } + + /** + * MGF1 + * + * See {@link http://tools.ietf.org/html/rfc3447#appendix-B.2.1 RFC3447#appendix-B.2.1}. + * + * @access private + * @param String $mgfSeed + * @param Integer $mgfLen + * @return String + */ + function _mgf1($mgfSeed, $maskLen) + { + // if $maskLen would yield strings larger than 4GB, PKCS#1 suggests a "Mask too long" error be output. + + $t = ''; + $count = ceil($maskLen / $this->mgfHLen); + for ($i = 0; $i < $count; $i++) { + $c = pack('N', $i); + $t.= $this->mgfHash->hash($mgfSeed . $c); + } + + return substr($t, 0, $maskLen); + } + + /** + * RSAES-OAEP-ENCRYPT + * + * See {@link http://tools.ietf.org/html/rfc3447#section-7.1.1 RFC3447#section-7.1.1} and + * {http://en.wikipedia.org/wiki/Optimal_Asymmetric_Encryption_Padding OAES}. + * + * @access private + * @param String $m + * @param String $l + * @return String + */ + function _rsaes_oaep_encrypt($m, $l = '') + { + $mLen = strlen($m); + + // Length checking + + // if $l is larger than two million terrabytes and you're using sha1, PKCS#1 suggests a "Label too long" error + // be output. + + if ($mLen > $this->k - 2 * $this->hLen - 2) { + user_error('Message too long'); + return false; + } + + // EME-OAEP encoding + + $lHash = $this->hash->hash($l); + $ps = str_repeat(chr(0), $this->k - $mLen - 2 * $this->hLen - 2); + $db = $lHash . $ps . chr(1) . $m; + $seed = crypt_random_string($this->hLen); + $dbMask = $this->_mgf1($seed, $this->k - $this->hLen - 1); + $maskedDB = $db ^ $dbMask; + $seedMask = $this->_mgf1($maskedDB, $this->hLen); + $maskedSeed = $seed ^ $seedMask; + $em = chr(0) . $maskedSeed . $maskedDB; + + // RSA encryption + + $m = $this->_os2ip($em); + $c = $this->_rsaep($m); + $c = $this->_i2osp($c, $this->k); + + // Output the ciphertext C + + return $c; + } + + /** + * RSAES-OAEP-DECRYPT + * + * See {@link http://tools.ietf.org/html/rfc3447#section-7.1.2 RFC3447#section-7.1.2}. The fact that the error + * messages aren't distinguishable from one another hinders debugging, but, to quote from RFC3447#section-7.1.2: + * + * Note. Care must be taken to ensure that an opponent cannot + * distinguish the different error conditions in Step 3.g, whether by + * error message or timing, or, more generally, learn partial + * information about the encoded message EM. Otherwise an opponent may + * be able to obtain useful information about the decryption of the + * ciphertext C, leading to a chosen-ciphertext attack such as the one + * observed by Manger [36]. + * + * As for $l... to quote from {@link http://tools.ietf.org/html/rfc3447#page-17 RFC3447#page-17}: + * + * Both the encryption and the decryption operations of RSAES-OAEP take + * the value of a label L as input. In this version of PKCS #1, L is + * the empty string; other uses of the label are outside the scope of + * this document. + * + * @access private + * @param String $c + * @param String $l + * @return String + */ + function _rsaes_oaep_decrypt($c, $l = '') + { + // Length checking + + // if $l is larger than two million terrabytes and you're using sha1, PKCS#1 suggests a "Label too long" error + // be output. + + if (strlen($c) != $this->k || $this->k < 2 * $this->hLen + 2) { + user_error('Decryption error'); + return false; + } + + // RSA decryption + + $c = $this->_os2ip($c); + $m = $this->_rsadp($c); + if ($m === false) { + user_error('Decryption error'); + return false; + } + $em = $this->_i2osp($m, $this->k); + + // EME-OAEP decoding + + $lHash = $this->hash->hash($l); + $y = ord($em[0]); + $maskedSeed = substr($em, 1, $this->hLen); + $maskedDB = substr($em, $this->hLen + 1); + $seedMask = $this->_mgf1($maskedDB, $this->hLen); + $seed = $maskedSeed ^ $seedMask; + $dbMask = $this->_mgf1($seed, $this->k - $this->hLen - 1); + $db = $maskedDB ^ $dbMask; + $lHash2 = substr($db, 0, $this->hLen); + $m = substr($db, $this->hLen); + if ($lHash != $lHash2) { + user_error('Decryption error'); + return false; + } + $m = ltrim($m, chr(0)); + if (ord($m[0]) != 1) { + user_error('Decryption error'); + return false; + } + + // Output the message M + + return substr($m, 1); + } + + /** + * RSAES-PKCS1-V1_5-ENCRYPT + * + * See {@link http://tools.ietf.org/html/rfc3447#section-7.2.1 RFC3447#section-7.2.1}. + * + * @access private + * @param String $m + * @return String + */ + function _rsaes_pkcs1_v1_5_encrypt($m) + { + $mLen = strlen($m); + + // Length checking + + if ($mLen > $this->k - 11) { + user_error('Message too long'); + return false; + } + + // EME-PKCS1-v1_5 encoding + + $psLen = $this->k - $mLen - 3; + $ps = ''; + while (strlen($ps) != $psLen) { + $temp = crypt_random_string($psLen - strlen($ps)); + $temp = str_replace("\x00", '', $temp); + $ps.= $temp; + } + $type = 2; + // see the comments of _rsaes_pkcs1_v1_5_decrypt() to understand why this is being done + if (defined('CRYPT_RSA_PKCS15_COMPAT') && (!isset($this->publicExponent) || $this->exponent !== $this->publicExponent)) { + $type = 1; + // "The padding string PS shall consist of k-3-||D|| octets. ... for block type 01, they shall have value FF" + $ps = str_repeat("\xFF", $psLen); + } + $em = chr(0) . chr($type) . $ps . chr(0) . $m; + + // RSA encryption + $m = $this->_os2ip($em); + $c = $this->_rsaep($m); + $c = $this->_i2osp($c, $this->k); + + // Output the ciphertext C + + return $c; + } + + /** + * RSAES-PKCS1-V1_5-DECRYPT + * + * See {@link http://tools.ietf.org/html/rfc3447#section-7.2.2 RFC3447#section-7.2.2}. + * + * For compatability purposes, this function departs slightly from the description given in RFC3447. + * The reason being that RFC2313#section-8.1 (PKCS#1 v1.5) states that ciphertext's encrypted by the + * private key should have the second byte set to either 0 or 1 and that ciphertext's encrypted by the + * public key should have the second byte set to 2. In RFC3447 (PKCS#1 v2.1), the second byte is supposed + * to be 2 regardless of which key is used. For compatability purposes, we'll just check to make sure the + * second byte is 2 or less. If it is, we'll accept the decrypted string as valid. + * + * As a consequence of this, a private key encrypted ciphertext produced with Crypt_RSA may not decrypt + * with a strictly PKCS#1 v1.5 compliant RSA implementation. Public key encrypted ciphertext's should but + * not private key encrypted ciphertext's. + * + * @access private + * @param String $c + * @return String + */ + function _rsaes_pkcs1_v1_5_decrypt($c) + { + // Length checking + + if (strlen($c) != $this->k) { // or if k < 11 + user_error('Decryption error'); + return false; + } + + // RSA decryption + + $c = $this->_os2ip($c); + $m = $this->_rsadp($c); + + if ($m === false) { + user_error('Decryption error'); + return false; + } + $em = $this->_i2osp($m, $this->k); + + // EME-PKCS1-v1_5 decoding + + if (ord($em[0]) != 0 || ord($em[1]) > 2) { + user_error('Decryption error'); + return false; + } + + $ps = substr($em, 2, strpos($em, chr(0), 2) - 2); + $m = substr($em, strlen($ps) + 3); + + if (strlen($ps) < 8) { + user_error('Decryption error'); + return false; + } + + // Output M + + return $m; + } + + /** + * EMSA-PSS-ENCODE + * + * See {@link http://tools.ietf.org/html/rfc3447#section-9.1.1 RFC3447#section-9.1.1}. + * + * @access private + * @param String $m + * @param Integer $emBits + */ + function _emsa_pss_encode($m, $emBits) + { + // if $m is larger than two million terrabytes and you're using sha1, PKCS#1 suggests a "Label too long" error + // be output. + + $emLen = ($emBits + 1) >> 3; // ie. ceil($emBits / 8) + $sLen = $this->sLen == false ? $this->hLen : $this->sLen; + + $mHash = $this->hash->hash($m); + if ($emLen < $this->hLen + $sLen + 2) { + user_error('Encoding error'); + return false; + } + + $salt = crypt_random_string($sLen); + $m2 = "\0\0\0\0\0\0\0\0" . $mHash . $salt; + $h = $this->hash->hash($m2); + $ps = str_repeat(chr(0), $emLen - $sLen - $this->hLen - 2); + $db = $ps . chr(1) . $salt; + $dbMask = $this->_mgf1($h, $emLen - $this->hLen - 1); + $maskedDB = $db ^ $dbMask; + $maskedDB[0] = ~chr(0xFF << ($emBits & 7)) & $maskedDB[0]; + $em = $maskedDB . $h . chr(0xBC); + + return $em; + } + + /** + * EMSA-PSS-VERIFY + * + * See {@link http://tools.ietf.org/html/rfc3447#section-9.1.2 RFC3447#section-9.1.2}. + * + * @access private + * @param String $m + * @param String $em + * @param Integer $emBits + * @return String + */ + function _emsa_pss_verify($m, $em, $emBits) + { + // if $m is larger than two million terrabytes and you're using sha1, PKCS#1 suggests a "Label too long" error + // be output. + + $emLen = ($emBits + 1) >> 3; // ie. ceil($emBits / 8); + $sLen = $this->sLen == false ? $this->hLen : $this->sLen; + + $mHash = $this->hash->hash($m); + if ($emLen < $this->hLen + $sLen + 2) { + return false; + } + + if ($em[strlen($em) - 1] != chr(0xBC)) { + return false; + } + + $maskedDB = substr($em, 0, -$this->hLen - 1); + $h = substr($em, -$this->hLen - 1, $this->hLen); + $temp = chr(0xFF << ($emBits & 7)); + if ((~$maskedDB[0] & $temp) != $temp) { + return false; + } + $dbMask = $this->_mgf1($h, $emLen - $this->hLen - 1); + $db = $maskedDB ^ $dbMask; + $db[0] = ~chr(0xFF << ($emBits & 7)) & $db[0]; + $temp = $emLen - $this->hLen - $sLen - 2; + if (substr($db, 0, $temp) != str_repeat(chr(0), $temp) || ord($db[$temp]) != 1) { + return false; + } + $salt = substr($db, $temp + 1); // should be $sLen long + $m2 = "\0\0\0\0\0\0\0\0" . $mHash . $salt; + $h2 = $this->hash->hash($m2); + return $this->_equals($h, $h2); + } + + /** + * RSASSA-PSS-SIGN + * + * See {@link http://tools.ietf.org/html/rfc3447#section-8.1.1 RFC3447#section-8.1.1}. + * + * @access private + * @param String $m + * @return String + */ + function _rsassa_pss_sign($m) + { + // EMSA-PSS encoding + + $em = $this->_emsa_pss_encode($m, 8 * $this->k - 1); + + // RSA signature + + $m = $this->_os2ip($em); + $s = $this->_rsasp1($m); + $s = $this->_i2osp($s, $this->k); + + // Output the signature S + + return $s; + } + + /** + * RSASSA-PSS-VERIFY + * + * See {@link http://tools.ietf.org/html/rfc3447#section-8.1.2 RFC3447#section-8.1.2}. + * + * @access private + * @param String $m + * @param String $s + * @return String + */ + function _rsassa_pss_verify($m, $s) + { + // Length checking + + if (strlen($s) != $this->k) { + user_error('Invalid signature'); + return false; + } + + // RSA verification + + $modBits = 8 * $this->k; + + $s2 = $this->_os2ip($s); + $m2 = $this->_rsavp1($s2); + if ($m2 === false) { + user_error('Invalid signature'); + return false; + } + $em = $this->_i2osp($m2, $modBits >> 3); + if ($em === false) { + user_error('Invalid signature'); + return false; + } + + // EMSA-PSS verification + + return $this->_emsa_pss_verify($m, $em, $modBits - 1); + } + + /** + * EMSA-PKCS1-V1_5-ENCODE + * + * See {@link http://tools.ietf.org/html/rfc3447#section-9.2 RFC3447#section-9.2}. + * + * @access private + * @param String $m + * @param Integer $emLen + * @return String + */ + function _emsa_pkcs1_v1_5_encode($m, $emLen) + { + $h = $this->hash->hash($m); + if ($h === false) { + return false; + } + + // see http://tools.ietf.org/html/rfc3447#page-43 + switch ($this->hashName) { + case 'md2': + $t = pack('H*', '3020300c06082a864886f70d020205000410'); + break; + case 'md5': + $t = pack('H*', '3020300c06082a864886f70d020505000410'); + break; + case 'sha1': + $t = pack('H*', '3021300906052b0e03021a05000414'); + break; + case 'sha256': + $t = pack('H*', '3031300d060960864801650304020105000420'); + break; + case 'sha384': + $t = pack('H*', '3041300d060960864801650304020205000430'); + break; + case 'sha512': + $t = pack('H*', '3051300d060960864801650304020305000440'); + } + $t.= $h; + $tLen = strlen($t); + + if ($emLen < $tLen + 11) { + user_error('Intended encoded message length too short'); + return false; + } + + $ps = str_repeat(chr(0xFF), $emLen - $tLen - 3); + + $em = "\0\1$ps\0$t"; + + return $em; + } + + /** + * RSASSA-PKCS1-V1_5-SIGN + * + * See {@link http://tools.ietf.org/html/rfc3447#section-8.2.1 RFC3447#section-8.2.1}. + * + * @access private + * @param String $m + * @return String + */ + function _rsassa_pkcs1_v1_5_sign($m) + { + // EMSA-PKCS1-v1_5 encoding + + $em = $this->_emsa_pkcs1_v1_5_encode($m, $this->k); + if ($em === false) { + user_error('RSA modulus too short'); + return false; + } + + // RSA signature + + $m = $this->_os2ip($em); + $s = $this->_rsasp1($m); + $s = $this->_i2osp($s, $this->k); + + // Output the signature S + + return $s; + } + + /** + * RSASSA-PKCS1-V1_5-VERIFY + * + * See {@link http://tools.ietf.org/html/rfc3447#section-8.2.2 RFC3447#section-8.2.2}. + * + * @access private + * @param String $m + * @return String + */ + function _rsassa_pkcs1_v1_5_verify($m, $s) + { + // Length checking + + if (strlen($s) != $this->k) { + user_error('Invalid signature'); + return false; + } + + // RSA verification + + $s = $this->_os2ip($s); + $m2 = $this->_rsavp1($s); + if ($m2 === false) { + user_error('Invalid signature'); + return false; + } + $em = $this->_i2osp($m2, $this->k); + if ($em === false) { + user_error('Invalid signature'); + return false; + } + + // EMSA-PKCS1-v1_5 encoding + + $em2 = $this->_emsa_pkcs1_v1_5_encode($m, $this->k); + if ($em2 === false) { + user_error('RSA modulus too short'); + return false; + } + + // Compare + return $this->_equals($em, $em2); + } + + /** + * Set Encryption Mode + * + * Valid values include CRYPT_RSA_ENCRYPTION_OAEP and CRYPT_RSA_ENCRYPTION_PKCS1. + * + * @access public + * @param Integer $mode + */ + function setEncryptionMode($mode) + { + $this->encryptionMode = $mode; + } + + /** + * Set Signature Mode + * + * Valid values include CRYPT_RSA_SIGNATURE_PSS and CRYPT_RSA_SIGNATURE_PKCS1 + * + * @access public + * @param Integer $mode + */ + function setSignatureMode($mode) + { + $this->signatureMode = $mode; + } + + /** + * Set public key comment. + * + * @access public + * @param String $comment + */ + function setComment($comment) + { + $this->comment = $comment; + } + + /** + * Get public key comment. + * + * @access public + * @return String + */ + function getComment() + { + return $this->comment; + } + + /** + * Encryption + * + * Both CRYPT_RSA_ENCRYPTION_OAEP and CRYPT_RSA_ENCRYPTION_PKCS1 both place limits on how long $plaintext can be. + * If $plaintext exceeds those limits it will be broken up so that it does and the resultant ciphertext's will + * be concatenated together. + * + * @see decrypt() + * @access public + * @param String $plaintext + * @return String + */ + function encrypt($plaintext) + { + switch ($this->encryptionMode) { + case CRYPT_RSA_ENCRYPTION_PKCS1: + $length = $this->k - 11; + if ($length <= 0) { + return false; + } + + $plaintext = str_split($plaintext, $length); + $ciphertext = ''; + foreach ($plaintext as $m) { + $ciphertext.= $this->_rsaes_pkcs1_v1_5_encrypt($m); + } + return $ciphertext; + //case CRYPT_RSA_ENCRYPTION_OAEP: + default: + $length = $this->k - 2 * $this->hLen - 2; + if ($length <= 0) { + return false; + } + + $plaintext = str_split($plaintext, $length); + $ciphertext = ''; + foreach ($plaintext as $m) { + $ciphertext.= $this->_rsaes_oaep_encrypt($m); + } + return $ciphertext; + } + } + + /** + * Decryption + * + * @see encrypt() + * @access public + * @param String $plaintext + * @return String + */ + function decrypt($ciphertext) + { + if ($this->k <= 0) { + return false; + } + + $ciphertext = str_split($ciphertext, $this->k); + $ciphertext[count($ciphertext) - 1] = str_pad($ciphertext[count($ciphertext) - 1], $this->k, chr(0), STR_PAD_LEFT); + + $plaintext = ''; + + switch ($this->encryptionMode) { + case CRYPT_RSA_ENCRYPTION_PKCS1: + $decrypt = '_rsaes_pkcs1_v1_5_decrypt'; + break; + //case CRYPT_RSA_ENCRYPTION_OAEP: + default: + $decrypt = '_rsaes_oaep_decrypt'; + } + + foreach ($ciphertext as $c) { + $temp = $this->$decrypt($c); + if ($temp === false) { + return false; + } + $plaintext.= $temp; + } + + return $plaintext; + } + + /** + * Create a signature + * + * @see verify() + * @access public + * @param String $message + * @return String + */ + function sign($message) + { + if (empty($this->modulus) || empty($this->exponent)) { + return false; + } + + switch ($this->signatureMode) { + case CRYPT_RSA_SIGNATURE_PKCS1: + return $this->_rsassa_pkcs1_v1_5_sign($message); + //case CRYPT_RSA_SIGNATURE_PSS: + default: + return $this->_rsassa_pss_sign($message); + } + } + + /** + * Verifies a signature + * + * @see sign() + * @access public + * @param String $message + * @param String $signature + * @return Boolean + */ + function verify($message, $signature) + { + if (empty($this->modulus) || empty($this->exponent)) { + return false; + } + + switch ($this->signatureMode) { + case CRYPT_RSA_SIGNATURE_PKCS1: + return $this->_rsassa_pkcs1_v1_5_verify($message, $signature); + //case CRYPT_RSA_SIGNATURE_PSS: + default: + return $this->_rsassa_pss_verify($message, $signature); + } + } + + /** + * Extract raw BER from Base64 encoding + * + * @access private + * @param String $str + * @return String + */ + function _extractBER($str) + { + /* X.509 certs are assumed to be base64 encoded but sometimes they'll have additional things in them + * above and beyond the ceritificate. + * ie. some may have the following preceding the -----BEGIN CERTIFICATE----- line: + * + * Bag Attributes + * localKeyID: 01 00 00 00 + * subject=/O=organization/OU=org unit/CN=common name + * issuer=/O=organization/CN=common name + */ + $temp = preg_replace('#.*?^-+[^-]+-+#ms', '', $str, 1); + // remove the -----BEGIN CERTIFICATE----- and -----END CERTIFICATE----- stuff + $temp = preg_replace('#-+[^-]+-+#', '', $temp); + // remove new lines + $temp = str_replace(array("\r", "\n", ' '), '', $temp); + $temp = preg_match('#^[a-zA-Z\d/+]*={0,2}$#', $temp) ? base64_decode($temp) : false; + return $temp != false ? $temp : $str; + } +} diff --git a/vendor/phpseclib/phpseclib/phpseclib/Crypt/Random.php b/vendor/phpseclib/phpseclib/phpseclib/Crypt/Random.php new file mode 100755 index 0000000..977ec79 --- /dev/null +++ b/vendor/phpseclib/phpseclib/phpseclib/Crypt/Random.php @@ -0,0 +1,246 @@ + + * + * + * + * LICENSE: Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * @category Crypt + * @package Crypt_Random + * @author Jim Wigginton + * @copyright MMVII Jim Wigginton + * @license http://www.opensource.org/licenses/mit-license.html MIT License + * @link http://phpseclib.sourceforge.net + */ + +/** + * "Is Windows" test + * + * @access private + */ +define('CRYPT_RANDOM_IS_WINDOWS', strtoupper(substr(PHP_OS, 0, 3)) === 'WIN'); + +/** + * Generate a random string. + * + * Although microoptimizations are generally discouraged as they impair readability this function is ripe with + * microoptimizations because this function has the potential of being called a huge number of times. + * eg. for RSA key generation. + * + * @param Integer $length + * @return String + * @access public + */ +function crypt_random_string($length) +{ + if (CRYPT_RANDOM_IS_WINDOWS) { + // method 1. prior to PHP 5.3 this would call rand() on windows hence the function_exists('class_alias') call. + // ie. class_alias is a function that was introduced in PHP 5.3 + if (function_exists('mcrypt_create_iv') && function_exists('class_alias')) { + return mcrypt_create_iv($length); + } + // method 2. openssl_random_pseudo_bytes was introduced in PHP 5.3.0 but prior to PHP 5.3.4 there was, + // to quote , "possible blocking behavior". as of 5.3.4 + // openssl_random_pseudo_bytes and mcrypt_create_iv do the exact same thing on Windows. ie. they both + // call php_win32_get_random_bytes(): + // + // https://github.com/php/php-src/blob/7014a0eb6d1611151a286c0ff4f2238f92c120d6/ext/openssl/openssl.c#L5008 + // https://github.com/php/php-src/blob/7014a0eb6d1611151a286c0ff4f2238f92c120d6/ext/mcrypt/mcrypt.c#L1392 + // + // php_win32_get_random_bytes() is defined thusly: + // + // https://github.com/php/php-src/blob/7014a0eb6d1611151a286c0ff4f2238f92c120d6/win32/winutil.c#L80 + // + // we're calling it, all the same, in the off chance that the mcrypt extension is not available + if (function_exists('openssl_random_pseudo_bytes') && version_compare(PHP_VERSION, '5.3.4', '>=')) { + return openssl_random_pseudo_bytes($length); + } + } else { + // method 1. the fastest + if (function_exists('openssl_random_pseudo_bytes')) { + return openssl_random_pseudo_bytes($length); + } + // method 2 + static $fp = true; + if ($fp === true) { + // warning's will be output unles the error suppression operator is used. errors such as + // "open_basedir restriction in effect", "Permission denied", "No such file or directory", etc. + $fp = @fopen('/dev/urandom', 'rb'); + } + if ($fp !== true && $fp !== false) { // surprisingly faster than !is_bool() or is_resource() + return fread($fp, $length); + } + // method 3. pretty much does the same thing as method 2 per the following url: + // https://github.com/php/php-src/blob/7014a0eb6d1611151a286c0ff4f2238f92c120d6/ext/mcrypt/mcrypt.c#L1391 + // surprisingly slower than method 2. maybe that's because mcrypt_create_iv does a bunch of error checking that we're + // not doing. regardless, this'll only be called if this PHP script couldn't open /dev/urandom due to open_basedir + // restrictions or some such + if (function_exists('mcrypt_create_iv')) { + return mcrypt_create_iv($length, MCRYPT_DEV_URANDOM); + } + } + // at this point we have no choice but to use a pure-PHP CSPRNG + + // cascade entropy across multiple PHP instances by fixing the session and collecting all + // environmental variables, including the previous session data and the current session + // data. + // + // mt_rand seeds itself by looking at the PID and the time, both of which are (relatively) + // easy to guess at. linux uses mouse clicks, keyboard timings, etc, as entropy sources, but + // PHP isn't low level to be able to use those as sources and on a web server there's not likely + // going to be a ton of keyboard or mouse action. web servers do have one thing that we can use + // however. a ton of people visiting the website. obviously you don't want to base your seeding + // soley on parameters a potential attacker sends but (1) not everything in $_SERVER is controlled + // by the user and (2) this isn't just looking at the data sent by the current user - it's based + // on the data sent by all users. one user requests the page and a hash of their info is saved. + // another user visits the page and the serialization of their data is utilized along with the + // server envirnment stuff and a hash of the previous http request data (which itself utilizes + // a hash of the session data before that). certainly an attacker should be assumed to have + // full control over his own http requests. he, however, is not going to have control over + // everyone's http requests. + static $crypto = false, $v; + if ($crypto === false) { + // save old session data + $old_session_id = session_id(); + $old_use_cookies = ini_get('session.use_cookies'); + $old_session_cache_limiter = session_cache_limiter(); + $_OLD_SESSION = isset($_SESSION) ? $_SESSION : false; + if ($old_session_id != '') { + session_write_close(); + } + + session_id(1); + ini_set('session.use_cookies', 0); + session_cache_limiter(''); + session_start(); + + $v = $seed = $_SESSION['seed'] = pack('H*', sha1( + serialize($_SERVER) . + serialize($_POST) . + serialize($_GET) . + serialize($_COOKIE) . + serialize($GLOBALS) . + serialize($_SESSION) . + serialize($_OLD_SESSION) + )); + if (!isset($_SESSION['count'])) { + $_SESSION['count'] = 0; + } + $_SESSION['count']++; + + session_write_close(); + + // restore old session data + if ($old_session_id != '') { + session_id($old_session_id); + session_start(); + ini_set('session.use_cookies', $old_use_cookies); + session_cache_limiter($old_session_cache_limiter); + } else { + if ($_OLD_SESSION !== false) { + $_SESSION = $_OLD_SESSION; + unset($_OLD_SESSION); + } else { + unset($_SESSION); + } + } + + // in SSH2 a shared secret and an exchange hash are generated through the key exchange process. + // the IV client to server is the hash of that "nonce" with the letter A and for the encryption key it's the letter C. + // if the hash doesn't produce enough a key or an IV that's long enough concat successive hashes of the + // original hash and the current hash. we'll be emulating that. for more info see the following URL: + // + // http://tools.ietf.org/html/rfc4253#section-7.2 + // + // see the is_string($crypto) part for an example of how to expand the keys + $key = pack('H*', sha1($seed . 'A')); + $iv = pack('H*', sha1($seed . 'C')); + + // ciphers are used as per the nist.gov link below. also, see this link: + // + // http://en.wikipedia.org/wiki/Cryptographically_secure_pseudorandom_number_generator#Designs_based_on_cryptographic_primitives + switch (true) { + case class_exists('Crypt_AES'): + $crypto = new Crypt_AES(CRYPT_AES_MODE_CTR); + break; + case class_exists('Crypt_TripleDES'): + $crypto = new Crypt_TripleDES(CRYPT_DES_MODE_CTR); + break; + case class_exists('Crypt_DES'): + $crypto = new Crypt_DES(CRYPT_DES_MODE_CTR); + break; + case class_exists('Crypt_RC4'): + $crypto = new Crypt_RC4(); + break; + default: + $crypto = $seed; + return crypt_random_string($length); + } + + $crypto->setKey($key); + $crypto->setIV($iv); + $crypto->enableContinuousBuffer(); + } + + if (is_string($crypto)) { + // the following is based off of ANSI X9.31: + // + // http://csrc.nist.gov/groups/STM/cavp/documents/rng/931rngext.pdf + // + // OpenSSL uses that same standard for it's random numbers: + // + // http://www.opensource.apple.com/source/OpenSSL/OpenSSL-38/openssl/fips-1.0/rand/fips_rand.c + // (do a search for "ANS X9.31 A.2.4") + // + // ANSI X9.31 recommends ciphers be used and phpseclib does use them if they're available (see + // later on in the code) but if they're not we'll use sha1 + $result = ''; + while (strlen($result) < $length) { // each loop adds 20 bytes + // microtime() isn't packed as "densely" as it could be but then neither is that the idea. + // the idea is simply to ensure that each "block" has a unique element to it. + $i = pack('H*', sha1(microtime())); + $r = pack('H*', sha1($i ^ $v)); + $v = pack('H*', sha1($r ^ $i)); + $result.= $r; + } + return substr($result, 0, $length); + } + + //return $crypto->encrypt(str_repeat("\0", $length)); + + $result = ''; + while (strlen($result) < $length) { + $i = $crypto->encrypt(microtime()); + $r = $crypto->encrypt($i ^ $v); + $v = $crypto->encrypt($r ^ $i); + $result.= $r; + } + return substr($result, 0, $length); +} diff --git a/vendor/phpseclib/phpseclib/phpseclib/Crypt/Rijndael.php b/vendor/phpseclib/phpseclib/phpseclib/Crypt/Rijndael.php new file mode 100755 index 0000000..4253151 --- /dev/null +++ b/vendor/phpseclib/phpseclib/phpseclib/Crypt/Rijndael.php @@ -0,0 +1,1371 @@ + + * setKey('abcdefghijklmnop'); + * + * $size = 10 * 1024; + * $plaintext = ''; + * for ($i = 0; $i < $size; $i++) { + * $plaintext.= 'a'; + * } + * + * echo $rijndael->decrypt($rijndael->encrypt($plaintext)); + * ?> + * + * + * LICENSE: Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * @category Crypt + * @package Crypt_Rijndael + * @author Jim Wigginton + * @copyright MMVIII Jim Wigginton + * @license http://www.opensource.org/licenses/mit-license.html MIT License + * @link http://phpseclib.sourceforge.net + */ + +/** + * Include Crypt_Base + * + * Base cipher class + */ +if (!class_exists('Crypt_Base')) { + include_once 'Base.php'; +} + +/**#@+ + * @access public + * @see Crypt_Rijndael::encrypt() + * @see Crypt_Rijndael::decrypt() + */ +/** + * Encrypt / decrypt using the Counter mode. + * + * Set to -1 since that's what Crypt/Random.php uses to index the CTR mode. + * + * @link http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation#Counter_.28CTR.29 + */ +define('CRYPT_RIJNDAEL_MODE_CTR', CRYPT_MODE_CTR); +/** + * Encrypt / decrypt using the Electronic Code Book mode. + * + * @link http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation#Electronic_codebook_.28ECB.29 + */ +define('CRYPT_RIJNDAEL_MODE_ECB', CRYPT_MODE_ECB); +/** + * Encrypt / decrypt using the Code Book Chaining mode. + * + * @link http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation#Cipher-block_chaining_.28CBC.29 + */ +define('CRYPT_RIJNDAEL_MODE_CBC', CRYPT_MODE_CBC); +/** + * Encrypt / decrypt using the Cipher Feedback mode. + * + * @link http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation#Cipher_feedback_.28CFB.29 + */ +define('CRYPT_RIJNDAEL_MODE_CFB', CRYPT_MODE_CFB); +/** + * Encrypt / decrypt using the Cipher Feedback mode. + * + * @link http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation#Output_feedback_.28OFB.29 + */ +define('CRYPT_RIJNDAEL_MODE_OFB', CRYPT_MODE_OFB); +/**#@-*/ + +/**#@+ + * @access private + * @see Crypt_Rijndael::Crypt_Rijndael() + */ +/** + * Toggles the internal implementation + */ +define('CRYPT_RIJNDAEL_MODE_INTERNAL', CRYPT_MODE_INTERNAL); +/** + * Toggles the mcrypt implementation + */ +define('CRYPT_RIJNDAEL_MODE_MCRYPT', CRYPT_MODE_MCRYPT); +/**#@-*/ + +/** + * Pure-PHP implementation of Rijndael. + * + * @package Crypt_Rijndael + * @author Jim Wigginton + * @version 0.1.0 + * @access public + */ +class Crypt_Rijndael extends Crypt_Base +{ + /** + * The default password key_size used by setPassword() + * + * @see Crypt_Base::password_key_size + * @see Crypt_Base::setPassword() + * @var Integer + * @access private + */ + var $password_key_size = 16; + + /** + * The namespace used by the cipher for its constants. + * + * @see Crypt_Base::const_namespace + * @var String + * @access private + */ + var $const_namespace = 'RIJNDAEL'; + + /** + * The mcrypt specific name of the cipher + * + * Mcrypt is useable for 128/192/256-bit $block_size/$key_size. For 160/224 not. + * Crypt_Rijndael determines automatically whether mcrypt is useable + * or not for the current $block_size/$key_size. + * In case of, $cipher_name_mcrypt will be set dynamicaly at run time accordingly. + * + * @see Crypt_Base::cipher_name_mcrypt + * @see Crypt_Base::engine + * @see _setupEngine() + * @var String + * @access private + */ + var $cipher_name_mcrypt = 'rijndael-128'; + + /** + * The default salt used by setPassword() + * + * @see Crypt_Base::password_default_salt + * @see Crypt_Base::setPassword() + * @var String + * @access private + */ + var $password_default_salt = 'phpseclib'; + + /** + * Has the key length explicitly been set or should it be derived from the key, itself? + * + * @see setKeyLength() + * @var Boolean + * @access private + */ + var $explicit_key_length = false; + + /** + * The Key Schedule + * + * @see _setup() + * @var Array + * @access private + */ + var $w; + + /** + * The Inverse Key Schedule + * + * @see _setup() + * @var Array + * @access private + */ + var $dw; + + /** + * The Block Length divided by 32 + * + * @see setBlockLength() + * @var Integer + * @access private + * @internal The max value is 256 / 32 = 8, the min value is 128 / 32 = 4. Exists in conjunction with $block_size + * because the encryption / decryption / key schedule creation requires this number and not $block_size. We could + * derive this from $block_size or vice versa, but that'd mean we'd have to do multiple shift operations, so in lieu + * of that, we'll just precompute it once. + * + */ + var $Nb = 4; + + /** + * The Key Length + * + * @see setKeyLength() + * @var Integer + * @access private + * @internal The max value is 256 / 8 = 32, the min value is 128 / 8 = 16. Exists in conjunction with $Nk + * because the encryption / decryption / key schedule creation requires this number and not $key_size. We could + * derive this from $key_size or vice versa, but that'd mean we'd have to do multiple shift operations, so in lieu + * of that, we'll just precompute it once. + */ + var $key_size = 16; + + /** + * The Key Length divided by 32 + * + * @see setKeyLength() + * @var Integer + * @access private + * @internal The max value is 256 / 32 = 8, the min value is 128 / 32 = 4 + */ + var $Nk = 4; + + /** + * The Number of Rounds + * + * @var Integer + * @access private + * @internal The max value is 14, the min value is 10. + */ + var $Nr; + + /** + * Shift offsets + * + * @var Array + * @access private + */ + var $c; + + /** + * Holds the last used key- and block_size information + * + * @var Array + * @access private + */ + var $kl; + + /** + * Precomputed mixColumns table + * + * According to (section 5.2.1), + * precomputed tables can be used in the mixColumns phase. in that example, they're assigned t0...t3, so + * those are the names we'll use. + * + * @see Crypt_Rijndael:_encryptBlock() + * @see Crypt_Rijndael:_decryptBlock() + * @var Array + * @access private + */ + var $t0 = array( + 0xC66363A5, 0xF87C7C84, 0xEE777799, 0xF67B7B8D, 0xFFF2F20D, 0xD66B6BBD, 0xDE6F6FB1, 0x91C5C554, + 0x60303050, 0x02010103, 0xCE6767A9, 0x562B2B7D, 0xE7FEFE19, 0xB5D7D762, 0x4DABABE6, 0xEC76769A, + 0x8FCACA45, 0x1F82829D, 0x89C9C940, 0xFA7D7D87, 0xEFFAFA15, 0xB25959EB, 0x8E4747C9, 0xFBF0F00B, + 0x41ADADEC, 0xB3D4D467, 0x5FA2A2FD, 0x45AFAFEA, 0x239C9CBF, 0x53A4A4F7, 0xE4727296, 0x9BC0C05B, + 0x75B7B7C2, 0xE1FDFD1C, 0x3D9393AE, 0x4C26266A, 0x6C36365A, 0x7E3F3F41, 0xF5F7F702, 0x83CCCC4F, + 0x6834345C, 0x51A5A5F4, 0xD1E5E534, 0xF9F1F108, 0xE2717193, 0xABD8D873, 0x62313153, 0x2A15153F, + 0x0804040C, 0x95C7C752, 0x46232365, 0x9DC3C35E, 0x30181828, 0x379696A1, 0x0A05050F, 0x2F9A9AB5, + 0x0E070709, 0x24121236, 0x1B80809B, 0xDFE2E23D, 0xCDEBEB26, 0x4E272769, 0x7FB2B2CD, 0xEA75759F, + 0x1209091B, 0x1D83839E, 0x582C2C74, 0x341A1A2E, 0x361B1B2D, 0xDC6E6EB2, 0xB45A5AEE, 0x5BA0A0FB, + 0xA45252F6, 0x763B3B4D, 0xB7D6D661, 0x7DB3B3CE, 0x5229297B, 0xDDE3E33E, 0x5E2F2F71, 0x13848497, + 0xA65353F5, 0xB9D1D168, 0x00000000, 0xC1EDED2C, 0x40202060, 0xE3FCFC1F, 0x79B1B1C8, 0xB65B5BED, + 0xD46A6ABE, 0x8DCBCB46, 0x67BEBED9, 0x7239394B, 0x944A4ADE, 0x984C4CD4, 0xB05858E8, 0x85CFCF4A, + 0xBBD0D06B, 0xC5EFEF2A, 0x4FAAAAE5, 0xEDFBFB16, 0x864343C5, 0x9A4D4DD7, 0x66333355, 0x11858594, + 0x8A4545CF, 0xE9F9F910, 0x04020206, 0xFE7F7F81, 0xA05050F0, 0x783C3C44, 0x259F9FBA, 0x4BA8A8E3, + 0xA25151F3, 0x5DA3A3FE, 0x804040C0, 0x058F8F8A, 0x3F9292AD, 0x219D9DBC, 0x70383848, 0xF1F5F504, + 0x63BCBCDF, 0x77B6B6C1, 0xAFDADA75, 0x42212163, 0x20101030, 0xE5FFFF1A, 0xFDF3F30E, 0xBFD2D26D, + 0x81CDCD4C, 0x180C0C14, 0x26131335, 0xC3ECEC2F, 0xBE5F5FE1, 0x359797A2, 0x884444CC, 0x2E171739, + 0x93C4C457, 0x55A7A7F2, 0xFC7E7E82, 0x7A3D3D47, 0xC86464AC, 0xBA5D5DE7, 0x3219192B, 0xE6737395, + 0xC06060A0, 0x19818198, 0x9E4F4FD1, 0xA3DCDC7F, 0x44222266, 0x542A2A7E, 0x3B9090AB, 0x0B888883, + 0x8C4646CA, 0xC7EEEE29, 0x6BB8B8D3, 0x2814143C, 0xA7DEDE79, 0xBC5E5EE2, 0x160B0B1D, 0xADDBDB76, + 0xDBE0E03B, 0x64323256, 0x743A3A4E, 0x140A0A1E, 0x924949DB, 0x0C06060A, 0x4824246C, 0xB85C5CE4, + 0x9FC2C25D, 0xBDD3D36E, 0x43ACACEF, 0xC46262A6, 0x399191A8, 0x319595A4, 0xD3E4E437, 0xF279798B, + 0xD5E7E732, 0x8BC8C843, 0x6E373759, 0xDA6D6DB7, 0x018D8D8C, 0xB1D5D564, 0x9C4E4ED2, 0x49A9A9E0, + 0xD86C6CB4, 0xAC5656FA, 0xF3F4F407, 0xCFEAEA25, 0xCA6565AF, 0xF47A7A8E, 0x47AEAEE9, 0x10080818, + 0x6FBABAD5, 0xF0787888, 0x4A25256F, 0x5C2E2E72, 0x381C1C24, 0x57A6A6F1, 0x73B4B4C7, 0x97C6C651, + 0xCBE8E823, 0xA1DDDD7C, 0xE874749C, 0x3E1F1F21, 0x964B4BDD, 0x61BDBDDC, 0x0D8B8B86, 0x0F8A8A85, + 0xE0707090, 0x7C3E3E42, 0x71B5B5C4, 0xCC6666AA, 0x904848D8, 0x06030305, 0xF7F6F601, 0x1C0E0E12, + 0xC26161A3, 0x6A35355F, 0xAE5757F9, 0x69B9B9D0, 0x17868691, 0x99C1C158, 0x3A1D1D27, 0x279E9EB9, + 0xD9E1E138, 0xEBF8F813, 0x2B9898B3, 0x22111133, 0xD26969BB, 0xA9D9D970, 0x078E8E89, 0x339494A7, + 0x2D9B9BB6, 0x3C1E1E22, 0x15878792, 0xC9E9E920, 0x87CECE49, 0xAA5555FF, 0x50282878, 0xA5DFDF7A, + 0x038C8C8F, 0x59A1A1F8, 0x09898980, 0x1A0D0D17, 0x65BFBFDA, 0xD7E6E631, 0x844242C6, 0xD06868B8, + 0x824141C3, 0x299999B0, 0x5A2D2D77, 0x1E0F0F11, 0x7BB0B0CB, 0xA85454FC, 0x6DBBBBD6, 0x2C16163A + ); + + /** + * Precomputed mixColumns table + * + * @see Crypt_Rijndael:_encryptBlock() + * @see Crypt_Rijndael:_decryptBlock() + * @var Array + * @access private + */ + var $t1 = array( + 0xA5C66363, 0x84F87C7C, 0x99EE7777, 0x8DF67B7B, 0x0DFFF2F2, 0xBDD66B6B, 0xB1DE6F6F, 0x5491C5C5, + 0x50603030, 0x03020101, 0xA9CE6767, 0x7D562B2B, 0x19E7FEFE, 0x62B5D7D7, 0xE64DABAB, 0x9AEC7676, + 0x458FCACA, 0x9D1F8282, 0x4089C9C9, 0x87FA7D7D, 0x15EFFAFA, 0xEBB25959, 0xC98E4747, 0x0BFBF0F0, + 0xEC41ADAD, 0x67B3D4D4, 0xFD5FA2A2, 0xEA45AFAF, 0xBF239C9C, 0xF753A4A4, 0x96E47272, 0x5B9BC0C0, + 0xC275B7B7, 0x1CE1FDFD, 0xAE3D9393, 0x6A4C2626, 0x5A6C3636, 0x417E3F3F, 0x02F5F7F7, 0x4F83CCCC, + 0x5C683434, 0xF451A5A5, 0x34D1E5E5, 0x08F9F1F1, 0x93E27171, 0x73ABD8D8, 0x53623131, 0x3F2A1515, + 0x0C080404, 0x5295C7C7, 0x65462323, 0x5E9DC3C3, 0x28301818, 0xA1379696, 0x0F0A0505, 0xB52F9A9A, + 0x090E0707, 0x36241212, 0x9B1B8080, 0x3DDFE2E2, 0x26CDEBEB, 0x694E2727, 0xCD7FB2B2, 0x9FEA7575, + 0x1B120909, 0x9E1D8383, 0x74582C2C, 0x2E341A1A, 0x2D361B1B, 0xB2DC6E6E, 0xEEB45A5A, 0xFB5BA0A0, + 0xF6A45252, 0x4D763B3B, 0x61B7D6D6, 0xCE7DB3B3, 0x7B522929, 0x3EDDE3E3, 0x715E2F2F, 0x97138484, + 0xF5A65353, 0x68B9D1D1, 0x00000000, 0x2CC1EDED, 0x60402020, 0x1FE3FCFC, 0xC879B1B1, 0xEDB65B5B, + 0xBED46A6A, 0x468DCBCB, 0xD967BEBE, 0x4B723939, 0xDE944A4A, 0xD4984C4C, 0xE8B05858, 0x4A85CFCF, + 0x6BBBD0D0, 0x2AC5EFEF, 0xE54FAAAA, 0x16EDFBFB, 0xC5864343, 0xD79A4D4D, 0x55663333, 0x94118585, + 0xCF8A4545, 0x10E9F9F9, 0x06040202, 0x81FE7F7F, 0xF0A05050, 0x44783C3C, 0xBA259F9F, 0xE34BA8A8, + 0xF3A25151, 0xFE5DA3A3, 0xC0804040, 0x8A058F8F, 0xAD3F9292, 0xBC219D9D, 0x48703838, 0x04F1F5F5, + 0xDF63BCBC, 0xC177B6B6, 0x75AFDADA, 0x63422121, 0x30201010, 0x1AE5FFFF, 0x0EFDF3F3, 0x6DBFD2D2, + 0x4C81CDCD, 0x14180C0C, 0x35261313, 0x2FC3ECEC, 0xE1BE5F5F, 0xA2359797, 0xCC884444, 0x392E1717, + 0x5793C4C4, 0xF255A7A7, 0x82FC7E7E, 0x477A3D3D, 0xACC86464, 0xE7BA5D5D, 0x2B321919, 0x95E67373, + 0xA0C06060, 0x98198181, 0xD19E4F4F, 0x7FA3DCDC, 0x66442222, 0x7E542A2A, 0xAB3B9090, 0x830B8888, + 0xCA8C4646, 0x29C7EEEE, 0xD36BB8B8, 0x3C281414, 0x79A7DEDE, 0xE2BC5E5E, 0x1D160B0B, 0x76ADDBDB, + 0x3BDBE0E0, 0x56643232, 0x4E743A3A, 0x1E140A0A, 0xDB924949, 0x0A0C0606, 0x6C482424, 0xE4B85C5C, + 0x5D9FC2C2, 0x6EBDD3D3, 0xEF43ACAC, 0xA6C46262, 0xA8399191, 0xA4319595, 0x37D3E4E4, 0x8BF27979, + 0x32D5E7E7, 0x438BC8C8, 0x596E3737, 0xB7DA6D6D, 0x8C018D8D, 0x64B1D5D5, 0xD29C4E4E, 0xE049A9A9, + 0xB4D86C6C, 0xFAAC5656, 0x07F3F4F4, 0x25CFEAEA, 0xAFCA6565, 0x8EF47A7A, 0xE947AEAE, 0x18100808, + 0xD56FBABA, 0x88F07878, 0x6F4A2525, 0x725C2E2E, 0x24381C1C, 0xF157A6A6, 0xC773B4B4, 0x5197C6C6, + 0x23CBE8E8, 0x7CA1DDDD, 0x9CE87474, 0x213E1F1F, 0xDD964B4B, 0xDC61BDBD, 0x860D8B8B, 0x850F8A8A, + 0x90E07070, 0x427C3E3E, 0xC471B5B5, 0xAACC6666, 0xD8904848, 0x05060303, 0x01F7F6F6, 0x121C0E0E, + 0xA3C26161, 0x5F6A3535, 0xF9AE5757, 0xD069B9B9, 0x91178686, 0x5899C1C1, 0x273A1D1D, 0xB9279E9E, + 0x38D9E1E1, 0x13EBF8F8, 0xB32B9898, 0x33221111, 0xBBD26969, 0x70A9D9D9, 0x89078E8E, 0xA7339494, + 0xB62D9B9B, 0x223C1E1E, 0x92158787, 0x20C9E9E9, 0x4987CECE, 0xFFAA5555, 0x78502828, 0x7AA5DFDF, + 0x8F038C8C, 0xF859A1A1, 0x80098989, 0x171A0D0D, 0xDA65BFBF, 0x31D7E6E6, 0xC6844242, 0xB8D06868, + 0xC3824141, 0xB0299999, 0x775A2D2D, 0x111E0F0F, 0xCB7BB0B0, 0xFCA85454, 0xD66DBBBB, 0x3A2C1616 + ); + + /** + * Precomputed mixColumns table + * + * @see Crypt_Rijndael:_encryptBlock() + * @see Crypt_Rijndael:_decryptBlock() + * @var Array + * @access private + */ + var $t2 = array( + 0x63A5C663, 0x7C84F87C, 0x7799EE77, 0x7B8DF67B, 0xF20DFFF2, 0x6BBDD66B, 0x6FB1DE6F, 0xC55491C5, + 0x30506030, 0x01030201, 0x67A9CE67, 0x2B7D562B, 0xFE19E7FE, 0xD762B5D7, 0xABE64DAB, 0x769AEC76, + 0xCA458FCA, 0x829D1F82, 0xC94089C9, 0x7D87FA7D, 0xFA15EFFA, 0x59EBB259, 0x47C98E47, 0xF00BFBF0, + 0xADEC41AD, 0xD467B3D4, 0xA2FD5FA2, 0xAFEA45AF, 0x9CBF239C, 0xA4F753A4, 0x7296E472, 0xC05B9BC0, + 0xB7C275B7, 0xFD1CE1FD, 0x93AE3D93, 0x266A4C26, 0x365A6C36, 0x3F417E3F, 0xF702F5F7, 0xCC4F83CC, + 0x345C6834, 0xA5F451A5, 0xE534D1E5, 0xF108F9F1, 0x7193E271, 0xD873ABD8, 0x31536231, 0x153F2A15, + 0x040C0804, 0xC75295C7, 0x23654623, 0xC35E9DC3, 0x18283018, 0x96A13796, 0x050F0A05, 0x9AB52F9A, + 0x07090E07, 0x12362412, 0x809B1B80, 0xE23DDFE2, 0xEB26CDEB, 0x27694E27, 0xB2CD7FB2, 0x759FEA75, + 0x091B1209, 0x839E1D83, 0x2C74582C, 0x1A2E341A, 0x1B2D361B, 0x6EB2DC6E, 0x5AEEB45A, 0xA0FB5BA0, + 0x52F6A452, 0x3B4D763B, 0xD661B7D6, 0xB3CE7DB3, 0x297B5229, 0xE33EDDE3, 0x2F715E2F, 0x84971384, + 0x53F5A653, 0xD168B9D1, 0x00000000, 0xED2CC1ED, 0x20604020, 0xFC1FE3FC, 0xB1C879B1, 0x5BEDB65B, + 0x6ABED46A, 0xCB468DCB, 0xBED967BE, 0x394B7239, 0x4ADE944A, 0x4CD4984C, 0x58E8B058, 0xCF4A85CF, + 0xD06BBBD0, 0xEF2AC5EF, 0xAAE54FAA, 0xFB16EDFB, 0x43C58643, 0x4DD79A4D, 0x33556633, 0x85941185, + 0x45CF8A45, 0xF910E9F9, 0x02060402, 0x7F81FE7F, 0x50F0A050, 0x3C44783C, 0x9FBA259F, 0xA8E34BA8, + 0x51F3A251, 0xA3FE5DA3, 0x40C08040, 0x8F8A058F, 0x92AD3F92, 0x9DBC219D, 0x38487038, 0xF504F1F5, + 0xBCDF63BC, 0xB6C177B6, 0xDA75AFDA, 0x21634221, 0x10302010, 0xFF1AE5FF, 0xF30EFDF3, 0xD26DBFD2, + 0xCD4C81CD, 0x0C14180C, 0x13352613, 0xEC2FC3EC, 0x5FE1BE5F, 0x97A23597, 0x44CC8844, 0x17392E17, + 0xC45793C4, 0xA7F255A7, 0x7E82FC7E, 0x3D477A3D, 0x64ACC864, 0x5DE7BA5D, 0x192B3219, 0x7395E673, + 0x60A0C060, 0x81981981, 0x4FD19E4F, 0xDC7FA3DC, 0x22664422, 0x2A7E542A, 0x90AB3B90, 0x88830B88, + 0x46CA8C46, 0xEE29C7EE, 0xB8D36BB8, 0x143C2814, 0xDE79A7DE, 0x5EE2BC5E, 0x0B1D160B, 0xDB76ADDB, + 0xE03BDBE0, 0x32566432, 0x3A4E743A, 0x0A1E140A, 0x49DB9249, 0x060A0C06, 0x246C4824, 0x5CE4B85C, + 0xC25D9FC2, 0xD36EBDD3, 0xACEF43AC, 0x62A6C462, 0x91A83991, 0x95A43195, 0xE437D3E4, 0x798BF279, + 0xE732D5E7, 0xC8438BC8, 0x37596E37, 0x6DB7DA6D, 0x8D8C018D, 0xD564B1D5, 0x4ED29C4E, 0xA9E049A9, + 0x6CB4D86C, 0x56FAAC56, 0xF407F3F4, 0xEA25CFEA, 0x65AFCA65, 0x7A8EF47A, 0xAEE947AE, 0x08181008, + 0xBAD56FBA, 0x7888F078, 0x256F4A25, 0x2E725C2E, 0x1C24381C, 0xA6F157A6, 0xB4C773B4, 0xC65197C6, + 0xE823CBE8, 0xDD7CA1DD, 0x749CE874, 0x1F213E1F, 0x4BDD964B, 0xBDDC61BD, 0x8B860D8B, 0x8A850F8A, + 0x7090E070, 0x3E427C3E, 0xB5C471B5, 0x66AACC66, 0x48D89048, 0x03050603, 0xF601F7F6, 0x0E121C0E, + 0x61A3C261, 0x355F6A35, 0x57F9AE57, 0xB9D069B9, 0x86911786, 0xC15899C1, 0x1D273A1D, 0x9EB9279E, + 0xE138D9E1, 0xF813EBF8, 0x98B32B98, 0x11332211, 0x69BBD269, 0xD970A9D9, 0x8E89078E, 0x94A73394, + 0x9BB62D9B, 0x1E223C1E, 0x87921587, 0xE920C9E9, 0xCE4987CE, 0x55FFAA55, 0x28785028, 0xDF7AA5DF, + 0x8C8F038C, 0xA1F859A1, 0x89800989, 0x0D171A0D, 0xBFDA65BF, 0xE631D7E6, 0x42C68442, 0x68B8D068, + 0x41C38241, 0x99B02999, 0x2D775A2D, 0x0F111E0F, 0xB0CB7BB0, 0x54FCA854, 0xBBD66DBB, 0x163A2C16 + ); + + /** + * Precomputed mixColumns table + * + * @see Crypt_Rijndael:_encryptBlock() + * @see Crypt_Rijndael:_decryptBlock() + * @var Array + * @access private + */ + var $t3 = array( + 0x6363A5C6, 0x7C7C84F8, 0x777799EE, 0x7B7B8DF6, 0xF2F20DFF, 0x6B6BBDD6, 0x6F6FB1DE, 0xC5C55491, + 0x30305060, 0x01010302, 0x6767A9CE, 0x2B2B7D56, 0xFEFE19E7, 0xD7D762B5, 0xABABE64D, 0x76769AEC, + 0xCACA458F, 0x82829D1F, 0xC9C94089, 0x7D7D87FA, 0xFAFA15EF, 0x5959EBB2, 0x4747C98E, 0xF0F00BFB, + 0xADADEC41, 0xD4D467B3, 0xA2A2FD5F, 0xAFAFEA45, 0x9C9CBF23, 0xA4A4F753, 0x727296E4, 0xC0C05B9B, + 0xB7B7C275, 0xFDFD1CE1, 0x9393AE3D, 0x26266A4C, 0x36365A6C, 0x3F3F417E, 0xF7F702F5, 0xCCCC4F83, + 0x34345C68, 0xA5A5F451, 0xE5E534D1, 0xF1F108F9, 0x717193E2, 0xD8D873AB, 0x31315362, 0x15153F2A, + 0x04040C08, 0xC7C75295, 0x23236546, 0xC3C35E9D, 0x18182830, 0x9696A137, 0x05050F0A, 0x9A9AB52F, + 0x0707090E, 0x12123624, 0x80809B1B, 0xE2E23DDF, 0xEBEB26CD, 0x2727694E, 0xB2B2CD7F, 0x75759FEA, + 0x09091B12, 0x83839E1D, 0x2C2C7458, 0x1A1A2E34, 0x1B1B2D36, 0x6E6EB2DC, 0x5A5AEEB4, 0xA0A0FB5B, + 0x5252F6A4, 0x3B3B4D76, 0xD6D661B7, 0xB3B3CE7D, 0x29297B52, 0xE3E33EDD, 0x2F2F715E, 0x84849713, + 0x5353F5A6, 0xD1D168B9, 0x00000000, 0xEDED2CC1, 0x20206040, 0xFCFC1FE3, 0xB1B1C879, 0x5B5BEDB6, + 0x6A6ABED4, 0xCBCB468D, 0xBEBED967, 0x39394B72, 0x4A4ADE94, 0x4C4CD498, 0x5858E8B0, 0xCFCF4A85, + 0xD0D06BBB, 0xEFEF2AC5, 0xAAAAE54F, 0xFBFB16ED, 0x4343C586, 0x4D4DD79A, 0x33335566, 0x85859411, + 0x4545CF8A, 0xF9F910E9, 0x02020604, 0x7F7F81FE, 0x5050F0A0, 0x3C3C4478, 0x9F9FBA25, 0xA8A8E34B, + 0x5151F3A2, 0xA3A3FE5D, 0x4040C080, 0x8F8F8A05, 0x9292AD3F, 0x9D9DBC21, 0x38384870, 0xF5F504F1, + 0xBCBCDF63, 0xB6B6C177, 0xDADA75AF, 0x21216342, 0x10103020, 0xFFFF1AE5, 0xF3F30EFD, 0xD2D26DBF, + 0xCDCD4C81, 0x0C0C1418, 0x13133526, 0xECEC2FC3, 0x5F5FE1BE, 0x9797A235, 0x4444CC88, 0x1717392E, + 0xC4C45793, 0xA7A7F255, 0x7E7E82FC, 0x3D3D477A, 0x6464ACC8, 0x5D5DE7BA, 0x19192B32, 0x737395E6, + 0x6060A0C0, 0x81819819, 0x4F4FD19E, 0xDCDC7FA3, 0x22226644, 0x2A2A7E54, 0x9090AB3B, 0x8888830B, + 0x4646CA8C, 0xEEEE29C7, 0xB8B8D36B, 0x14143C28, 0xDEDE79A7, 0x5E5EE2BC, 0x0B0B1D16, 0xDBDB76AD, + 0xE0E03BDB, 0x32325664, 0x3A3A4E74, 0x0A0A1E14, 0x4949DB92, 0x06060A0C, 0x24246C48, 0x5C5CE4B8, + 0xC2C25D9F, 0xD3D36EBD, 0xACACEF43, 0x6262A6C4, 0x9191A839, 0x9595A431, 0xE4E437D3, 0x79798BF2, + 0xE7E732D5, 0xC8C8438B, 0x3737596E, 0x6D6DB7DA, 0x8D8D8C01, 0xD5D564B1, 0x4E4ED29C, 0xA9A9E049, + 0x6C6CB4D8, 0x5656FAAC, 0xF4F407F3, 0xEAEA25CF, 0x6565AFCA, 0x7A7A8EF4, 0xAEAEE947, 0x08081810, + 0xBABAD56F, 0x787888F0, 0x25256F4A, 0x2E2E725C, 0x1C1C2438, 0xA6A6F157, 0xB4B4C773, 0xC6C65197, + 0xE8E823CB, 0xDDDD7CA1, 0x74749CE8, 0x1F1F213E, 0x4B4BDD96, 0xBDBDDC61, 0x8B8B860D, 0x8A8A850F, + 0x707090E0, 0x3E3E427C, 0xB5B5C471, 0x6666AACC, 0x4848D890, 0x03030506, 0xF6F601F7, 0x0E0E121C, + 0x6161A3C2, 0x35355F6A, 0x5757F9AE, 0xB9B9D069, 0x86869117, 0xC1C15899, 0x1D1D273A, 0x9E9EB927, + 0xE1E138D9, 0xF8F813EB, 0x9898B32B, 0x11113322, 0x6969BBD2, 0xD9D970A9, 0x8E8E8907, 0x9494A733, + 0x9B9BB62D, 0x1E1E223C, 0x87879215, 0xE9E920C9, 0xCECE4987, 0x5555FFAA, 0x28287850, 0xDFDF7AA5, + 0x8C8C8F03, 0xA1A1F859, 0x89898009, 0x0D0D171A, 0xBFBFDA65, 0xE6E631D7, 0x4242C684, 0x6868B8D0, + 0x4141C382, 0x9999B029, 0x2D2D775A, 0x0F0F111E, 0xB0B0CB7B, 0x5454FCA8, 0xBBBBD66D, 0x16163A2C + ); + + /** + * Precomputed invMixColumns table + * + * @see Crypt_Rijndael:_encryptBlock() + * @see Crypt_Rijndael:_decryptBlock() + * @var Array + * @access private + */ + var $dt0 = array( + 0x51F4A750, 0x7E416553, 0x1A17A4C3, 0x3A275E96, 0x3BAB6BCB, 0x1F9D45F1, 0xACFA58AB, 0x4BE30393, + 0x2030FA55, 0xAD766DF6, 0x88CC7691, 0xF5024C25, 0x4FE5D7FC, 0xC52ACBD7, 0x26354480, 0xB562A38F, + 0xDEB15A49, 0x25BA1B67, 0x45EA0E98, 0x5DFEC0E1, 0xC32F7502, 0x814CF012, 0x8D4697A3, 0x6BD3F9C6, + 0x038F5FE7, 0x15929C95, 0xBF6D7AEB, 0x955259DA, 0xD4BE832D, 0x587421D3, 0x49E06929, 0x8EC9C844, + 0x75C2896A, 0xF48E7978, 0x99583E6B, 0x27B971DD, 0xBEE14FB6, 0xF088AD17, 0xC920AC66, 0x7DCE3AB4, + 0x63DF4A18, 0xE51A3182, 0x97513360, 0x62537F45, 0xB16477E0, 0xBB6BAE84, 0xFE81A01C, 0xF9082B94, + 0x70486858, 0x8F45FD19, 0x94DE6C87, 0x527BF8B7, 0xAB73D323, 0x724B02E2, 0xE31F8F57, 0x6655AB2A, + 0xB2EB2807, 0x2FB5C203, 0x86C57B9A, 0xD33708A5, 0x302887F2, 0x23BFA5B2, 0x02036ABA, 0xED16825C, + 0x8ACF1C2B, 0xA779B492, 0xF307F2F0, 0x4E69E2A1, 0x65DAF4CD, 0x0605BED5, 0xD134621F, 0xC4A6FE8A, + 0x342E539D, 0xA2F355A0, 0x058AE132, 0xA4F6EB75, 0x0B83EC39, 0x4060EFAA, 0x5E719F06, 0xBD6E1051, + 0x3E218AF9, 0x96DD063D, 0xDD3E05AE, 0x4DE6BD46, 0x91548DB5, 0x71C45D05, 0x0406D46F, 0x605015FF, + 0x1998FB24, 0xD6BDE997, 0x894043CC, 0x67D99E77, 0xB0E842BD, 0x07898B88, 0xE7195B38, 0x79C8EEDB, + 0xA17C0A47, 0x7C420FE9, 0xF8841EC9, 0x00000000, 0x09808683, 0x322BED48, 0x1E1170AC, 0x6C5A724E, + 0xFD0EFFFB, 0x0F853856, 0x3DAED51E, 0x362D3927, 0x0A0FD964, 0x685CA621, 0x9B5B54D1, 0x24362E3A, + 0x0C0A67B1, 0x9357E70F, 0xB4EE96D2, 0x1B9B919E, 0x80C0C54F, 0x61DC20A2, 0x5A774B69, 0x1C121A16, + 0xE293BA0A, 0xC0A02AE5, 0x3C22E043, 0x121B171D, 0x0E090D0B, 0xF28BC7AD, 0x2DB6A8B9, 0x141EA9C8, + 0x57F11985, 0xAF75074C, 0xEE99DDBB, 0xA37F60FD, 0xF701269F, 0x5C72F5BC, 0x44663BC5, 0x5BFB7E34, + 0x8B432976, 0xCB23C6DC, 0xB6EDFC68, 0xB8E4F163, 0xD731DCCA, 0x42638510, 0x13972240, 0x84C61120, + 0x854A247D, 0xD2BB3DF8, 0xAEF93211, 0xC729A16D, 0x1D9E2F4B, 0xDCB230F3, 0x0D8652EC, 0x77C1E3D0, + 0x2BB3166C, 0xA970B999, 0x119448FA, 0x47E96422, 0xA8FC8CC4, 0xA0F03F1A, 0x567D2CD8, 0x223390EF, + 0x87494EC7, 0xD938D1C1, 0x8CCAA2FE, 0x98D40B36, 0xA6F581CF, 0xA57ADE28, 0xDAB78E26, 0x3FADBFA4, + 0x2C3A9DE4, 0x5078920D, 0x6A5FCC9B, 0x547E4662, 0xF68D13C2, 0x90D8B8E8, 0x2E39F75E, 0x82C3AFF5, + 0x9F5D80BE, 0x69D0937C, 0x6FD52DA9, 0xCF2512B3, 0xC8AC993B, 0x10187DA7, 0xE89C636E, 0xDB3BBB7B, + 0xCD267809, 0x6E5918F4, 0xEC9AB701, 0x834F9AA8, 0xE6956E65, 0xAAFFE67E, 0x21BCCF08, 0xEF15E8E6, + 0xBAE79BD9, 0x4A6F36CE, 0xEA9F09D4, 0x29B07CD6, 0x31A4B2AF, 0x2A3F2331, 0xC6A59430, 0x35A266C0, + 0x744EBC37, 0xFC82CAA6, 0xE090D0B0, 0x33A7D815, 0xF104984A, 0x41ECDAF7, 0x7FCD500E, 0x1791F62F, + 0x764DD68D, 0x43EFB04D, 0xCCAA4D54, 0xE49604DF, 0x9ED1B5E3, 0x4C6A881B, 0xC12C1FB8, 0x4665517F, + 0x9D5EEA04, 0x018C355D, 0xFA877473, 0xFB0B412E, 0xB3671D5A, 0x92DBD252, 0xE9105633, 0x6DD64713, + 0x9AD7618C, 0x37A10C7A, 0x59F8148E, 0xEB133C89, 0xCEA927EE, 0xB761C935, 0xE11CE5ED, 0x7A47B13C, + 0x9CD2DF59, 0x55F2733F, 0x1814CE79, 0x73C737BF, 0x53F7CDEA, 0x5FFDAA5B, 0xDF3D6F14, 0x7844DB86, + 0xCAAFF381, 0xB968C43E, 0x3824342C, 0xC2A3405F, 0x161DC372, 0xBCE2250C, 0x283C498B, 0xFF0D9541, + 0x39A80171, 0x080CB3DE, 0xD8B4E49C, 0x6456C190, 0x7BCB8461, 0xD532B670, 0x486C5C74, 0xD0B85742 + ); + + /** + * Precomputed invMixColumns table + * + * @see Crypt_Rijndael:_encryptBlock() + * @see Crypt_Rijndael:_decryptBlock() + * @var Array + * @access private + */ + var $dt1 = array( + 0x5051F4A7, 0x537E4165, 0xC31A17A4, 0x963A275E, 0xCB3BAB6B, 0xF11F9D45, 0xABACFA58, 0x934BE303, + 0x552030FA, 0xF6AD766D, 0x9188CC76, 0x25F5024C, 0xFC4FE5D7, 0xD7C52ACB, 0x80263544, 0x8FB562A3, + 0x49DEB15A, 0x6725BA1B, 0x9845EA0E, 0xE15DFEC0, 0x02C32F75, 0x12814CF0, 0xA38D4697, 0xC66BD3F9, + 0xE7038F5F, 0x9515929C, 0xEBBF6D7A, 0xDA955259, 0x2DD4BE83, 0xD3587421, 0x2949E069, 0x448EC9C8, + 0x6A75C289, 0x78F48E79, 0x6B99583E, 0xDD27B971, 0xB6BEE14F, 0x17F088AD, 0x66C920AC, 0xB47DCE3A, + 0x1863DF4A, 0x82E51A31, 0x60975133, 0x4562537F, 0xE0B16477, 0x84BB6BAE, 0x1CFE81A0, 0x94F9082B, + 0x58704868, 0x198F45FD, 0x8794DE6C, 0xB7527BF8, 0x23AB73D3, 0xE2724B02, 0x57E31F8F, 0x2A6655AB, + 0x07B2EB28, 0x032FB5C2, 0x9A86C57B, 0xA5D33708, 0xF2302887, 0xB223BFA5, 0xBA02036A, 0x5CED1682, + 0x2B8ACF1C, 0x92A779B4, 0xF0F307F2, 0xA14E69E2, 0xCD65DAF4, 0xD50605BE, 0x1FD13462, 0x8AC4A6FE, + 0x9D342E53, 0xA0A2F355, 0x32058AE1, 0x75A4F6EB, 0x390B83EC, 0xAA4060EF, 0x065E719F, 0x51BD6E10, + 0xF93E218A, 0x3D96DD06, 0xAEDD3E05, 0x464DE6BD, 0xB591548D, 0x0571C45D, 0x6F0406D4, 0xFF605015, + 0x241998FB, 0x97D6BDE9, 0xCC894043, 0x7767D99E, 0xBDB0E842, 0x8807898B, 0x38E7195B, 0xDB79C8EE, + 0x47A17C0A, 0xE97C420F, 0xC9F8841E, 0x00000000, 0x83098086, 0x48322BED, 0xAC1E1170, 0x4E6C5A72, + 0xFBFD0EFF, 0x560F8538, 0x1E3DAED5, 0x27362D39, 0x640A0FD9, 0x21685CA6, 0xD19B5B54, 0x3A24362E, + 0xB10C0A67, 0x0F9357E7, 0xD2B4EE96, 0x9E1B9B91, 0x4F80C0C5, 0xA261DC20, 0x695A774B, 0x161C121A, + 0x0AE293BA, 0xE5C0A02A, 0x433C22E0, 0x1D121B17, 0x0B0E090D, 0xADF28BC7, 0xB92DB6A8, 0xC8141EA9, + 0x8557F119, 0x4CAF7507, 0xBBEE99DD, 0xFDA37F60, 0x9FF70126, 0xBC5C72F5, 0xC544663B, 0x345BFB7E, + 0x768B4329, 0xDCCB23C6, 0x68B6EDFC, 0x63B8E4F1, 0xCAD731DC, 0x10426385, 0x40139722, 0x2084C611, + 0x7D854A24, 0xF8D2BB3D, 0x11AEF932, 0x6DC729A1, 0x4B1D9E2F, 0xF3DCB230, 0xEC0D8652, 0xD077C1E3, + 0x6C2BB316, 0x99A970B9, 0xFA119448, 0x2247E964, 0xC4A8FC8C, 0x1AA0F03F, 0xD8567D2C, 0xEF223390, + 0xC787494E, 0xC1D938D1, 0xFE8CCAA2, 0x3698D40B, 0xCFA6F581, 0x28A57ADE, 0x26DAB78E, 0xA43FADBF, + 0xE42C3A9D, 0x0D507892, 0x9B6A5FCC, 0x62547E46, 0xC2F68D13, 0xE890D8B8, 0x5E2E39F7, 0xF582C3AF, + 0xBE9F5D80, 0x7C69D093, 0xA96FD52D, 0xB3CF2512, 0x3BC8AC99, 0xA710187D, 0x6EE89C63, 0x7BDB3BBB, + 0x09CD2678, 0xF46E5918, 0x01EC9AB7, 0xA8834F9A, 0x65E6956E, 0x7EAAFFE6, 0x0821BCCF, 0xE6EF15E8, + 0xD9BAE79B, 0xCE4A6F36, 0xD4EA9F09, 0xD629B07C, 0xAF31A4B2, 0x312A3F23, 0x30C6A594, 0xC035A266, + 0x37744EBC, 0xA6FC82CA, 0xB0E090D0, 0x1533A7D8, 0x4AF10498, 0xF741ECDA, 0x0E7FCD50, 0x2F1791F6, + 0x8D764DD6, 0x4D43EFB0, 0x54CCAA4D, 0xDFE49604, 0xE39ED1B5, 0x1B4C6A88, 0xB8C12C1F, 0x7F466551, + 0x049D5EEA, 0x5D018C35, 0x73FA8774, 0x2EFB0B41, 0x5AB3671D, 0x5292DBD2, 0x33E91056, 0x136DD647, + 0x8C9AD761, 0x7A37A10C, 0x8E59F814, 0x89EB133C, 0xEECEA927, 0x35B761C9, 0xEDE11CE5, 0x3C7A47B1, + 0x599CD2DF, 0x3F55F273, 0x791814CE, 0xBF73C737, 0xEA53F7CD, 0x5B5FFDAA, 0x14DF3D6F, 0x867844DB, + 0x81CAAFF3, 0x3EB968C4, 0x2C382434, 0x5FC2A340, 0x72161DC3, 0x0CBCE225, 0x8B283C49, 0x41FF0D95, + 0x7139A801, 0xDE080CB3, 0x9CD8B4E4, 0x906456C1, 0x617BCB84, 0x70D532B6, 0x74486C5C, 0x42D0B857 + ); + + /** + * Precomputed invMixColumns table + * + * @see Crypt_Rijndael:_encryptBlock() + * @see Crypt_Rijndael:_decryptBlock() + * @var Array + * @access private + */ + var $dt2 = array( + 0xA75051F4, 0x65537E41, 0xA4C31A17, 0x5E963A27, 0x6BCB3BAB, 0x45F11F9D, 0x58ABACFA, 0x03934BE3, + 0xFA552030, 0x6DF6AD76, 0x769188CC, 0x4C25F502, 0xD7FC4FE5, 0xCBD7C52A, 0x44802635, 0xA38FB562, + 0x5A49DEB1, 0x1B6725BA, 0x0E9845EA, 0xC0E15DFE, 0x7502C32F, 0xF012814C, 0x97A38D46, 0xF9C66BD3, + 0x5FE7038F, 0x9C951592, 0x7AEBBF6D, 0x59DA9552, 0x832DD4BE, 0x21D35874, 0x692949E0, 0xC8448EC9, + 0x896A75C2, 0x7978F48E, 0x3E6B9958, 0x71DD27B9, 0x4FB6BEE1, 0xAD17F088, 0xAC66C920, 0x3AB47DCE, + 0x4A1863DF, 0x3182E51A, 0x33609751, 0x7F456253, 0x77E0B164, 0xAE84BB6B, 0xA01CFE81, 0x2B94F908, + 0x68587048, 0xFD198F45, 0x6C8794DE, 0xF8B7527B, 0xD323AB73, 0x02E2724B, 0x8F57E31F, 0xAB2A6655, + 0x2807B2EB, 0xC2032FB5, 0x7B9A86C5, 0x08A5D337, 0x87F23028, 0xA5B223BF, 0x6ABA0203, 0x825CED16, + 0x1C2B8ACF, 0xB492A779, 0xF2F0F307, 0xE2A14E69, 0xF4CD65DA, 0xBED50605, 0x621FD134, 0xFE8AC4A6, + 0x539D342E, 0x55A0A2F3, 0xE132058A, 0xEB75A4F6, 0xEC390B83, 0xEFAA4060, 0x9F065E71, 0x1051BD6E, + 0x8AF93E21, 0x063D96DD, 0x05AEDD3E, 0xBD464DE6, 0x8DB59154, 0x5D0571C4, 0xD46F0406, 0x15FF6050, + 0xFB241998, 0xE997D6BD, 0x43CC8940, 0x9E7767D9, 0x42BDB0E8, 0x8B880789, 0x5B38E719, 0xEEDB79C8, + 0x0A47A17C, 0x0FE97C42, 0x1EC9F884, 0x00000000, 0x86830980, 0xED48322B, 0x70AC1E11, 0x724E6C5A, + 0xFFFBFD0E, 0x38560F85, 0xD51E3DAE, 0x3927362D, 0xD9640A0F, 0xA621685C, 0x54D19B5B, 0x2E3A2436, + 0x67B10C0A, 0xE70F9357, 0x96D2B4EE, 0x919E1B9B, 0xC54F80C0, 0x20A261DC, 0x4B695A77, 0x1A161C12, + 0xBA0AE293, 0x2AE5C0A0, 0xE0433C22, 0x171D121B, 0x0D0B0E09, 0xC7ADF28B, 0xA8B92DB6, 0xA9C8141E, + 0x198557F1, 0x074CAF75, 0xDDBBEE99, 0x60FDA37F, 0x269FF701, 0xF5BC5C72, 0x3BC54466, 0x7E345BFB, + 0x29768B43, 0xC6DCCB23, 0xFC68B6ED, 0xF163B8E4, 0xDCCAD731, 0x85104263, 0x22401397, 0x112084C6, + 0x247D854A, 0x3DF8D2BB, 0x3211AEF9, 0xA16DC729, 0x2F4B1D9E, 0x30F3DCB2, 0x52EC0D86, 0xE3D077C1, + 0x166C2BB3, 0xB999A970, 0x48FA1194, 0x642247E9, 0x8CC4A8FC, 0x3F1AA0F0, 0x2CD8567D, 0x90EF2233, + 0x4EC78749, 0xD1C1D938, 0xA2FE8CCA, 0x0B3698D4, 0x81CFA6F5, 0xDE28A57A, 0x8E26DAB7, 0xBFA43FAD, + 0x9DE42C3A, 0x920D5078, 0xCC9B6A5F, 0x4662547E, 0x13C2F68D, 0xB8E890D8, 0xF75E2E39, 0xAFF582C3, + 0x80BE9F5D, 0x937C69D0, 0x2DA96FD5, 0x12B3CF25, 0x993BC8AC, 0x7DA71018, 0x636EE89C, 0xBB7BDB3B, + 0x7809CD26, 0x18F46E59, 0xB701EC9A, 0x9AA8834F, 0x6E65E695, 0xE67EAAFF, 0xCF0821BC, 0xE8E6EF15, + 0x9BD9BAE7, 0x36CE4A6F, 0x09D4EA9F, 0x7CD629B0, 0xB2AF31A4, 0x23312A3F, 0x9430C6A5, 0x66C035A2, + 0xBC37744E, 0xCAA6FC82, 0xD0B0E090, 0xD81533A7, 0x984AF104, 0xDAF741EC, 0x500E7FCD, 0xF62F1791, + 0xD68D764D, 0xB04D43EF, 0x4D54CCAA, 0x04DFE496, 0xB5E39ED1, 0x881B4C6A, 0x1FB8C12C, 0x517F4665, + 0xEA049D5E, 0x355D018C, 0x7473FA87, 0x412EFB0B, 0x1D5AB367, 0xD25292DB, 0x5633E910, 0x47136DD6, + 0x618C9AD7, 0x0C7A37A1, 0x148E59F8, 0x3C89EB13, 0x27EECEA9, 0xC935B761, 0xE5EDE11C, 0xB13C7A47, + 0xDF599CD2, 0x733F55F2, 0xCE791814, 0x37BF73C7, 0xCDEA53F7, 0xAA5B5FFD, 0x6F14DF3D, 0xDB867844, + 0xF381CAAF, 0xC43EB968, 0x342C3824, 0x405FC2A3, 0xC372161D, 0x250CBCE2, 0x498B283C, 0x9541FF0D, + 0x017139A8, 0xB3DE080C, 0xE49CD8B4, 0xC1906456, 0x84617BCB, 0xB670D532, 0x5C74486C, 0x5742D0B8 + ); + + /** + * Precomputed invMixColumns table + * + * @see Crypt_Rijndael:_encryptBlock() + * @see Crypt_Rijndael:_decryptBlock() + * @var Array + * @access private + */ + var $dt3 = array( + 0xF4A75051, 0x4165537E, 0x17A4C31A, 0x275E963A, 0xAB6BCB3B, 0x9D45F11F, 0xFA58ABAC, 0xE303934B, + 0x30FA5520, 0x766DF6AD, 0xCC769188, 0x024C25F5, 0xE5D7FC4F, 0x2ACBD7C5, 0x35448026, 0x62A38FB5, + 0xB15A49DE, 0xBA1B6725, 0xEA0E9845, 0xFEC0E15D, 0x2F7502C3, 0x4CF01281, 0x4697A38D, 0xD3F9C66B, + 0x8F5FE703, 0x929C9515, 0x6D7AEBBF, 0x5259DA95, 0xBE832DD4, 0x7421D358, 0xE0692949, 0xC9C8448E, + 0xC2896A75, 0x8E7978F4, 0x583E6B99, 0xB971DD27, 0xE14FB6BE, 0x88AD17F0, 0x20AC66C9, 0xCE3AB47D, + 0xDF4A1863, 0x1A3182E5, 0x51336097, 0x537F4562, 0x6477E0B1, 0x6BAE84BB, 0x81A01CFE, 0x082B94F9, + 0x48685870, 0x45FD198F, 0xDE6C8794, 0x7BF8B752, 0x73D323AB, 0x4B02E272, 0x1F8F57E3, 0x55AB2A66, + 0xEB2807B2, 0xB5C2032F, 0xC57B9A86, 0x3708A5D3, 0x2887F230, 0xBFA5B223, 0x036ABA02, 0x16825CED, + 0xCF1C2B8A, 0x79B492A7, 0x07F2F0F3, 0x69E2A14E, 0xDAF4CD65, 0x05BED506, 0x34621FD1, 0xA6FE8AC4, + 0x2E539D34, 0xF355A0A2, 0x8AE13205, 0xF6EB75A4, 0x83EC390B, 0x60EFAA40, 0x719F065E, 0x6E1051BD, + 0x218AF93E, 0xDD063D96, 0x3E05AEDD, 0xE6BD464D, 0x548DB591, 0xC45D0571, 0x06D46F04, 0x5015FF60, + 0x98FB2419, 0xBDE997D6, 0x4043CC89, 0xD99E7767, 0xE842BDB0, 0x898B8807, 0x195B38E7, 0xC8EEDB79, + 0x7C0A47A1, 0x420FE97C, 0x841EC9F8, 0x00000000, 0x80868309, 0x2BED4832, 0x1170AC1E, 0x5A724E6C, + 0x0EFFFBFD, 0x8538560F, 0xAED51E3D, 0x2D392736, 0x0FD9640A, 0x5CA62168, 0x5B54D19B, 0x362E3A24, + 0x0A67B10C, 0x57E70F93, 0xEE96D2B4, 0x9B919E1B, 0xC0C54F80, 0xDC20A261, 0x774B695A, 0x121A161C, + 0x93BA0AE2, 0xA02AE5C0, 0x22E0433C, 0x1B171D12, 0x090D0B0E, 0x8BC7ADF2, 0xB6A8B92D, 0x1EA9C814, + 0xF1198557, 0x75074CAF, 0x99DDBBEE, 0x7F60FDA3, 0x01269FF7, 0x72F5BC5C, 0x663BC544, 0xFB7E345B, + 0x4329768B, 0x23C6DCCB, 0xEDFC68B6, 0xE4F163B8, 0x31DCCAD7, 0x63851042, 0x97224013, 0xC6112084, + 0x4A247D85, 0xBB3DF8D2, 0xF93211AE, 0x29A16DC7, 0x9E2F4B1D, 0xB230F3DC, 0x8652EC0D, 0xC1E3D077, + 0xB3166C2B, 0x70B999A9, 0x9448FA11, 0xE9642247, 0xFC8CC4A8, 0xF03F1AA0, 0x7D2CD856, 0x3390EF22, + 0x494EC787, 0x38D1C1D9, 0xCAA2FE8C, 0xD40B3698, 0xF581CFA6, 0x7ADE28A5, 0xB78E26DA, 0xADBFA43F, + 0x3A9DE42C, 0x78920D50, 0x5FCC9B6A, 0x7E466254, 0x8D13C2F6, 0xD8B8E890, 0x39F75E2E, 0xC3AFF582, + 0x5D80BE9F, 0xD0937C69, 0xD52DA96F, 0x2512B3CF, 0xAC993BC8, 0x187DA710, 0x9C636EE8, 0x3BBB7BDB, + 0x267809CD, 0x5918F46E, 0x9AB701EC, 0x4F9AA883, 0x956E65E6, 0xFFE67EAA, 0xBCCF0821, 0x15E8E6EF, + 0xE79BD9BA, 0x6F36CE4A, 0x9F09D4EA, 0xB07CD629, 0xA4B2AF31, 0x3F23312A, 0xA59430C6, 0xA266C035, + 0x4EBC3774, 0x82CAA6FC, 0x90D0B0E0, 0xA7D81533, 0x04984AF1, 0xECDAF741, 0xCD500E7F, 0x91F62F17, + 0x4DD68D76, 0xEFB04D43, 0xAA4D54CC, 0x9604DFE4, 0xD1B5E39E, 0x6A881B4C, 0x2C1FB8C1, 0x65517F46, + 0x5EEA049D, 0x8C355D01, 0x877473FA, 0x0B412EFB, 0x671D5AB3, 0xDBD25292, 0x105633E9, 0xD647136D, + 0xD7618C9A, 0xA10C7A37, 0xF8148E59, 0x133C89EB, 0xA927EECE, 0x61C935B7, 0x1CE5EDE1, 0x47B13C7A, + 0xD2DF599C, 0xF2733F55, 0x14CE7918, 0xC737BF73, 0xF7CDEA53, 0xFDAA5B5F, 0x3D6F14DF, 0x44DB8678, + 0xAFF381CA, 0x68C43EB9, 0x24342C38, 0xA3405FC2, 0x1DC37216, 0xE2250CBC, 0x3C498B28, 0x0D9541FF, + 0xA8017139, 0x0CB3DE08, 0xB4E49CD8, 0x56C19064, 0xCB84617B, 0x32B670D5, 0x6C5C7448, 0xB85742D0 + ); + + /** + * The SubByte S-Box + * + * @see Crypt_Rijndael::_encryptBlock() + * @var Array + * @access private + */ + var $sbox = array( + 0x63, 0x7C, 0x77, 0x7B, 0xF2, 0x6B, 0x6F, 0xC5, 0x30, 0x01, 0x67, 0x2B, 0xFE, 0xD7, 0xAB, 0x76, + 0xCA, 0x82, 0xC9, 0x7D, 0xFA, 0x59, 0x47, 0xF0, 0xAD, 0xD4, 0xA2, 0xAF, 0x9C, 0xA4, 0x72, 0xC0, + 0xB7, 0xFD, 0x93, 0x26, 0x36, 0x3F, 0xF7, 0xCC, 0x34, 0xA5, 0xE5, 0xF1, 0x71, 0xD8, 0x31, 0x15, + 0x04, 0xC7, 0x23, 0xC3, 0x18, 0x96, 0x05, 0x9A, 0x07, 0x12, 0x80, 0xE2, 0xEB, 0x27, 0xB2, 0x75, + 0x09, 0x83, 0x2C, 0x1A, 0x1B, 0x6E, 0x5A, 0xA0, 0x52, 0x3B, 0xD6, 0xB3, 0x29, 0xE3, 0x2F, 0x84, + 0x53, 0xD1, 0x00, 0xED, 0x20, 0xFC, 0xB1, 0x5B, 0x6A, 0xCB, 0xBE, 0x39, 0x4A, 0x4C, 0x58, 0xCF, + 0xD0, 0xEF, 0xAA, 0xFB, 0x43, 0x4D, 0x33, 0x85, 0x45, 0xF9, 0x02, 0x7F, 0x50, 0x3C, 0x9F, 0xA8, + 0x51, 0xA3, 0x40, 0x8F, 0x92, 0x9D, 0x38, 0xF5, 0xBC, 0xB6, 0xDA, 0x21, 0x10, 0xFF, 0xF3, 0xD2, + 0xCD, 0x0C, 0x13, 0xEC, 0x5F, 0x97, 0x44, 0x17, 0xC4, 0xA7, 0x7E, 0x3D, 0x64, 0x5D, 0x19, 0x73, + 0x60, 0x81, 0x4F, 0xDC, 0x22, 0x2A, 0x90, 0x88, 0x46, 0xEE, 0xB8, 0x14, 0xDE, 0x5E, 0x0B, 0xDB, + 0xE0, 0x32, 0x3A, 0x0A, 0x49, 0x06, 0x24, 0x5C, 0xC2, 0xD3, 0xAC, 0x62, 0x91, 0x95, 0xE4, 0x79, + 0xE7, 0xC8, 0x37, 0x6D, 0x8D, 0xD5, 0x4E, 0xA9, 0x6C, 0x56, 0xF4, 0xEA, 0x65, 0x7A, 0xAE, 0x08, + 0xBA, 0x78, 0x25, 0x2E, 0x1C, 0xA6, 0xB4, 0xC6, 0xE8, 0xDD, 0x74, 0x1F, 0x4B, 0xBD, 0x8B, 0x8A, + 0x70, 0x3E, 0xB5, 0x66, 0x48, 0x03, 0xF6, 0x0E, 0x61, 0x35, 0x57, 0xB9, 0x86, 0xC1, 0x1D, 0x9E, + 0xE1, 0xF8, 0x98, 0x11, 0x69, 0xD9, 0x8E, 0x94, 0x9B, 0x1E, 0x87, 0xE9, 0xCE, 0x55, 0x28, 0xDF, + 0x8C, 0xA1, 0x89, 0x0D, 0xBF, 0xE6, 0x42, 0x68, 0x41, 0x99, 0x2D, 0x0F, 0xB0, 0x54, 0xBB, 0x16 + ); + + /** + * The inverse SubByte S-Box + * + * @see Crypt_Rijndael::_decryptBlock() + * @var Array + * @access private + */ + var $isbox = array( + 0x52, 0x09, 0x6A, 0xD5, 0x30, 0x36, 0xA5, 0x38, 0xBF, 0x40, 0xA3, 0x9E, 0x81, 0xF3, 0xD7, 0xFB, + 0x7C, 0xE3, 0x39, 0x82, 0x9B, 0x2F, 0xFF, 0x87, 0x34, 0x8E, 0x43, 0x44, 0xC4, 0xDE, 0xE9, 0xCB, + 0x54, 0x7B, 0x94, 0x32, 0xA6, 0xC2, 0x23, 0x3D, 0xEE, 0x4C, 0x95, 0x0B, 0x42, 0xFA, 0xC3, 0x4E, + 0x08, 0x2E, 0xA1, 0x66, 0x28, 0xD9, 0x24, 0xB2, 0x76, 0x5B, 0xA2, 0x49, 0x6D, 0x8B, 0xD1, 0x25, + 0x72, 0xF8, 0xF6, 0x64, 0x86, 0x68, 0x98, 0x16, 0xD4, 0xA4, 0x5C, 0xCC, 0x5D, 0x65, 0xB6, 0x92, + 0x6C, 0x70, 0x48, 0x50, 0xFD, 0xED, 0xB9, 0xDA, 0x5E, 0x15, 0x46, 0x57, 0xA7, 0x8D, 0x9D, 0x84, + 0x90, 0xD8, 0xAB, 0x00, 0x8C, 0xBC, 0xD3, 0x0A, 0xF7, 0xE4, 0x58, 0x05, 0xB8, 0xB3, 0x45, 0x06, + 0xD0, 0x2C, 0x1E, 0x8F, 0xCA, 0x3F, 0x0F, 0x02, 0xC1, 0xAF, 0xBD, 0x03, 0x01, 0x13, 0x8A, 0x6B, + 0x3A, 0x91, 0x11, 0x41, 0x4F, 0x67, 0xDC, 0xEA, 0x97, 0xF2, 0xCF, 0xCE, 0xF0, 0xB4, 0xE6, 0x73, + 0x96, 0xAC, 0x74, 0x22, 0xE7, 0xAD, 0x35, 0x85, 0xE2, 0xF9, 0x37, 0xE8, 0x1C, 0x75, 0xDF, 0x6E, + 0x47, 0xF1, 0x1A, 0x71, 0x1D, 0x29, 0xC5, 0x89, 0x6F, 0xB7, 0x62, 0x0E, 0xAA, 0x18, 0xBE, 0x1B, + 0xFC, 0x56, 0x3E, 0x4B, 0xC6, 0xD2, 0x79, 0x20, 0x9A, 0xDB, 0xC0, 0xFE, 0x78, 0xCD, 0x5A, 0xF4, + 0x1F, 0xDD, 0xA8, 0x33, 0x88, 0x07, 0xC7, 0x31, 0xB1, 0x12, 0x10, 0x59, 0x27, 0x80, 0xEC, 0x5F, + 0x60, 0x51, 0x7F, 0xA9, 0x19, 0xB5, 0x4A, 0x0D, 0x2D, 0xE5, 0x7A, 0x9F, 0x93, 0xC9, 0x9C, 0xEF, + 0xA0, 0xE0, 0x3B, 0x4D, 0xAE, 0x2A, 0xF5, 0xB0, 0xC8, 0xEB, 0xBB, 0x3C, 0x83, 0x53, 0x99, 0x61, + 0x17, 0x2B, 0x04, 0x7E, 0xBA, 0x77, 0xD6, 0x26, 0xE1, 0x69, 0x14, 0x63, 0x55, 0x21, 0x0C, 0x7D + ); + + /** + * Default Constructor. + * + * Determines whether or not the mcrypt extension should be used. + * + * $mode could be: + * + * - CRYPT_RIJNDAEL_MODE_ECB + * + * - CRYPT_RIJNDAEL_MODE_CBC + * + * - CRYPT_RIJNDAEL_MODE_CTR + * + * - CRYPT_RIJNDAEL_MODE_CFB + * + * - CRYPT_RIJNDAEL_MODE_OFB + * + * If not explictly set, CRYPT_RIJNDAEL_MODE_CBC will be used. + * + * @see Crypt_Base::Crypt_Base() + * @param optional Integer $mode + * @access public + */ + function Crypt_Rijndael($mode = CRYPT_RIJNDAEL_MODE_CBC) + { + parent::Crypt_Base($mode); + } + + /** + * Sets the key. + * + * Keys can be of any length. Rijndael, itself, requires the use of a key that's between 128-bits and 256-bits long and + * whose length is a multiple of 32. If the key is less than 256-bits and the key length isn't set, we round the length + * up to the closest valid key length, padding $key with null bytes. If the key is more than 256-bits, we trim the + * excess bits. + * + * If the key is not explicitly set, it'll be assumed to be all null bytes. + * + * Note: 160/224-bit keys must explicitly set by setKeyLength(), otherwise they will be round/pad up to 192/256 bits. + * + * @see Crypt_Base:setKey() + * @see setKeyLength() + * @access public + * @param String $key + */ + function setKey($key) + { + parent::setKey($key); + + if (!$this->explicit_key_length) { + $length = strlen($key); + switch (true) { + case $length <= 16: + $this->key_size = 16; + break; + case $length <= 24: + $this->key_size = 24; + break; + default: + $this->key_size = 32; + } + $this->_setupEngine(); + } + } + + /** + * Sets the key length + * + * Valid key lengths are 128, 160, 192, 224, and 256. If the length is less than 128, it will be rounded up to + * 128. If the length is greater than 128 and invalid, it will be rounded down to the closest valid amount. + * + * Note: phpseclib extends Rijndael (and AES) for using 160- and 224-bit keys but they are officially not defined + * and the most (if not all) implementations are not able using 160/224-bit keys but round/pad them up to + * 192/256 bits as, for example, mcrypt will do. + * + * That said, if you want be compatible with other Rijndael and AES implementations, + * you should not setKeyLength(160) or setKeyLength(224). + * + * Additional: In case of 160- and 224-bit keys, phpseclib will/can, for that reason, not use + * the mcrypt php extention, even if available. + * This results then in slower encryption. + * + * @access public + * @param Integer $length + */ + function setKeyLength($length) + { + switch (true) { + case $length == 160: + $this->key_size = 20; + break; + case $length == 224: + $this->key_size = 28; + break; + case $length <= 128: + $this->key_size = 16; + break; + case $length <= 192: + $this->key_size = 24; + break; + default: + $this->key_size = 32; + } + + $this->explicit_key_length = true; + $this->changed = true; + $this->_setupEngine(); + } + + /** + * Sets the block length + * + * Valid block lengths are 128, 160, 192, 224, and 256. If the length is less than 128, it will be rounded up to + * 128. If the length is greater than 128 and invalid, it will be rounded down to the closest valid amount. + * + * @access public + * @param Integer $length + */ + function setBlockLength($length) + { + $length >>= 5; + if ($length > 8) { + $length = 8; + } else if ($length < 4) { + $length = 4; + } + $this->Nb = $length; + $this->block_size = $length << 2; + $this->changed = true; + $this->_setupEngine(); + } + + /** + * Setup the fastest possible $engine + * + * Determines if the mcrypt (MODE_MCRYPT) $engine available + * and usable for the current $block_size and $key_size. + * + * If not, the slower MODE_INTERNAL $engine will be set. + * + * @see setKey() + * @see setKeyLength() + * @see setBlockLength() + * @access private + */ + function _setupEngine() + { + if (constant('CRYPT_' . $this->const_namespace . '_MODE') == CRYPT_MODE_INTERNAL) { + // No mcrypt support at all for rijndael + return; + } + + // The required mcrypt module name for the current $block_size of rijndael + $cipher_name_mcrypt = 'rijndael-' . ($this->block_size << 3); + + // Determining the availibility/usability of $cipher_name_mcrypt + switch (true) { + case $this->key_size % 8: // mcrypt is not usable for 160/224-bit keys, only for 128/192/256-bit keys + case !in_array($cipher_name_mcrypt, mcrypt_list_algorithms()): // $cipher_name_mcrypt is not available for the current $block_size + $engine = CRYPT_MODE_INTERNAL; + break; + default: + $engine = CRYPT_MODE_MCRYPT; + } + + if ($this->engine == $engine && $this->cipher_name_mcrypt == $cipher_name_mcrypt) { + // allready set, so we not unnecessary close $this->enmcrypt/demcrypt/ecb + return; + } + + // Set the $engine + $this->engine = $engine; + $this->cipher_name_mcrypt = $cipher_name_mcrypt; + + if ($this->enmcrypt) { + // Closing the current mcrypt resource(s). _mcryptSetup() will, if needed, + // (re)open them with the module named in $this->cipher_name_mcrypt + mcrypt_module_close($this->enmcrypt); + mcrypt_module_close($this->demcrypt); + $this->enmcrypt = null; + $this->demcrypt = null; + + if ($this->ecb) { + mcrypt_module_close($this->ecb); + $this->ecb = null; + } + } + } + + /** + * Setup the CRYPT_MODE_MCRYPT $engine + * + * @see Crypt_Base::_setupMcrypt() + * @access private + */ + function _setupMcrypt() + { + $this->key = str_pad(substr($this->key, 0, $this->key_size), $this->key_size, "\0"); + parent::_setupMcrypt(); + } + + /** + * Encrypts a block + * + * @access private + * @param String $in + * @return String + */ + function _encryptBlock($in) + { + static $t0, $t1, $t2, $t3, $sbox; + if (!$t0) { + for ($i = 0; $i < 256; ++$i) { + $t0[] = (int)$this->t0[$i]; + $t1[] = (int)$this->t1[$i]; + $t2[] = (int)$this->t2[$i]; + $t3[] = (int)$this->t3[$i]; + $sbox[] = (int)$this->sbox[$i]; + } + } + + $state = array(); + $words = unpack('N*', $in); + + $c = $this->c; + $w = $this->w; + $Nb = $this->Nb; + $Nr = $this->Nr; + + // addRoundKey + $i = -1; + foreach ($words as $word) { + $state[] = $word ^ $w[0][++$i]; + } + + // fips-197.pdf#page=19, "Figure 5. Pseudo Code for the Cipher", states that this loop has four components - + // subBytes, shiftRows, mixColumns, and addRoundKey. fips-197.pdf#page=30, "Implementation Suggestions Regarding + // Various Platforms" suggests that performs enhanced implementations are described in Rijndael-ammended.pdf. + // Rijndael-ammended.pdf#page=20, "Implementation aspects / 32-bit processor", discusses such an optimization. + // Unfortunately, the description given there is not quite correct. Per aes.spec.v316.pdf#page=19 [1], + // equation (7.4.7) is supposed to use addition instead of subtraction, so we'll do that here, as well. + + // [1] http://fp.gladman.plus.com/cryptography_technology/rijndael/aes.spec.v316.pdf + $temp = array(); + for ($round = 1; $round < $Nr; ++$round) { + $i = 0; // $c[0] == 0 + $j = $c[1]; + $k = $c[2]; + $l = $c[3]; + + while ($i < $Nb) { + $temp[$i] = $t0[$state[$i] >> 24 & 0x000000FF] ^ + $t1[$state[$j] >> 16 & 0x000000FF] ^ + $t2[$state[$k] >> 8 & 0x000000FF] ^ + $t3[$state[$l] & 0x000000FF] ^ + $w[$round][$i]; + ++$i; + $j = ($j + 1) % $Nb; + $k = ($k + 1) % $Nb; + $l = ($l + 1) % $Nb; + } + $state = $temp; + } + + // subWord + for ($i = 0; $i < $Nb; ++$i) { + $state[$i] = $sbox[$state[$i] & 0x000000FF] | + ($sbox[$state[$i] >> 8 & 0x000000FF] << 8) | + ($sbox[$state[$i] >> 16 & 0x000000FF] << 16) | + ($sbox[$state[$i] >> 24 & 0x000000FF] << 24); + } + + // shiftRows + addRoundKey + $i = 0; // $c[0] == 0 + $j = $c[1]; + $k = $c[2]; + $l = $c[3]; + while ($i < $Nb) { + $temp[$i] = ($state[$i] & 0xFF000000) ^ + ($state[$j] & 0x00FF0000) ^ + ($state[$k] & 0x0000FF00) ^ + ($state[$l] & 0x000000FF) ^ + $w[$Nr][$i]; + ++$i; + $j = ($j + 1) % $Nb; + $k = ($k + 1) % $Nb; + $l = ($l + 1) % $Nb; + } + + switch ($Nb) { + case 8: + return pack('N*', $temp[0], $temp[1], $temp[2], $temp[3], $temp[4], $temp[5], $temp[6], $temp[7]); + case 7: + return pack('N*', $temp[0], $temp[1], $temp[2], $temp[3], $temp[4], $temp[5], $temp[6]); + case 6: + return pack('N*', $temp[0], $temp[1], $temp[2], $temp[3], $temp[4], $temp[5]); + case 5: + return pack('N*', $temp[0], $temp[1], $temp[2], $temp[3], $temp[4]); + default: + return pack('N*', $temp[0], $temp[1], $temp[2], $temp[3]); + } + } + + /** + * Decrypts a block + * + * @access private + * @param String $in + * @return String + */ + function _decryptBlock($in) + { + static $dt0, $dt1, $dt2, $dt3, $isbox; + if (!$dt0) { + for ($i = 0; $i < 256; ++$i) { + $dt0[] = (int)$this->dt0[$i]; + $dt1[] = (int)$this->dt1[$i]; + $dt2[] = (int)$this->dt2[$i]; + $dt3[] = (int)$this->dt3[$i]; + $isbox[] = (int)$this->isbox[$i]; + } + } + + $state = array(); + $words = unpack('N*', $in); + + $c = $this->c; + $dw = $this->dw; + $Nb = $this->Nb; + $Nr = $this->Nr; + + // addRoundKey + $i = -1; + foreach ($words as $word) { + $state[] = $word ^ $dw[$Nr][++$i]; + } + + $temp = array(); + for ($round = $Nr - 1; $round > 0; --$round) { + $i = 0; // $c[0] == 0 + $j = $Nb - $c[1]; + $k = $Nb - $c[2]; + $l = $Nb - $c[3]; + + while ($i < $Nb) { + $temp[$i] = $dt0[$state[$i] >> 24 & 0x000000FF] ^ + $dt1[$state[$j] >> 16 & 0x000000FF] ^ + $dt2[$state[$k] >> 8 & 0x000000FF] ^ + $dt3[$state[$l] & 0x000000FF] ^ + $dw[$round][$i]; + ++$i; + $j = ($j + 1) % $Nb; + $k = ($k + 1) % $Nb; + $l = ($l + 1) % $Nb; + } + $state = $temp; + } + + // invShiftRows + invSubWord + addRoundKey + $i = 0; // $c[0] == 0 + $j = $Nb - $c[1]; + $k = $Nb - $c[2]; + $l = $Nb - $c[3]; + + while ($i < $Nb) { + $word = ($state[$i] & 0xFF000000) | + ($state[$j] & 0x00FF0000) | + ($state[$k] & 0x0000FF00) | + ($state[$l] & 0x000000FF); + + $temp[$i] = $dw[0][$i] ^ ($isbox[$word & 0x000000FF] | + ($isbox[$word >> 8 & 0x000000FF] << 8) | + ($isbox[$word >> 16 & 0x000000FF] << 16) | + ($isbox[$word >> 24 & 0x000000FF] << 24)); + ++$i; + $j = ($j + 1) % $Nb; + $k = ($k + 1) % $Nb; + $l = ($l + 1) % $Nb; + } + + switch ($Nb) { + case 8: + return pack('N*', $temp[0], $temp[1], $temp[2], $temp[3], $temp[4], $temp[5], $temp[6], $temp[7]); + case 7: + return pack('N*', $temp[0], $temp[1], $temp[2], $temp[3], $temp[4], $temp[5], $temp[6]); + case 6: + return pack('N*', $temp[0], $temp[1], $temp[2], $temp[3], $temp[4], $temp[5]); + case 5: + return pack('N*', $temp[0], $temp[1], $temp[2], $temp[3], $temp[4]); + default: + return pack('N*', $temp[0], $temp[1], $temp[2], $temp[3]); + } + } + + /** + * Setup the key (expansion) + * + * @see Crypt_Base::_setupKey() + * @access private + */ + function _setupKey() + { + // Each number in $rcon is equal to the previous number multiplied by two in Rijndael's finite field. + // See http://en.wikipedia.org/wiki/Finite_field_arithmetic#Multiplicative_inverse + static $rcon = array(0, + 0x01000000, 0x02000000, 0x04000000, 0x08000000, 0x10000000, + 0x20000000, 0x40000000, 0x80000000, 0x1B000000, 0x36000000, + 0x6C000000, 0xD8000000, 0xAB000000, 0x4D000000, 0x9A000000, + 0x2F000000, 0x5E000000, 0xBC000000, 0x63000000, 0xC6000000, + 0x97000000, 0x35000000, 0x6A000000, 0xD4000000, 0xB3000000, + 0x7D000000, 0xFA000000, 0xEF000000, 0xC5000000, 0x91000000 + ); + + $this->key = str_pad(substr($this->key, 0, $this->key_size), $this->key_size, "\0"); + + if (isset($this->kl['key']) && $this->key === $this->kl['key'] && $this->key_size === $this->kl['key_size'] && $this->block_size === $this->kl['block_size']) { + // already expanded + return; + } + $this->kl = array('key' => $this->key, 'key_size' => $this->key_size, 'block_size' => $this->block_size); + + $this->Nk = $this->key_size >> 2; + // see Rijndael-ammended.pdf#page=44 + $this->Nr = max($this->Nk, $this->Nb) + 6; + + // shift offsets for Nb = 5, 7 are defined in Rijndael-ammended.pdf#page=44, + // "Table 8: Shift offsets in Shiftrow for the alternative block lengths" + // shift offsets for Nb = 4, 6, 8 are defined in Rijndael-ammended.pdf#page=14, + // "Table 2: Shift offsets for different block lengths" + switch ($this->Nb) { + case 4: + case 5: + case 6: + $this->c = array(0, 1, 2, 3); + break; + case 7: + $this->c = array(0, 1, 2, 4); + break; + case 8: + $this->c = array(0, 1, 3, 4); + } + + $w = array_values(unpack('N*words', $this->key)); + + $length = $this->Nb * ($this->Nr + 1); + for ($i = $this->Nk; $i < $length; $i++) { + $temp = $w[$i - 1]; + if ($i % $this->Nk == 0) { + // according to , "the size of an integer is platform-dependent". + // on a 32-bit machine, it's 32-bits, and on a 64-bit machine, it's 64-bits. on a 32-bit machine, + // 0xFFFFFFFF << 8 == 0xFFFFFF00, but on a 64-bit machine, it equals 0xFFFFFFFF00. as such, doing 'and' + // with 0xFFFFFFFF (or 0xFFFFFF00) on a 32-bit machine is unnecessary, but on a 64-bit machine, it is. + $temp = (($temp << 8) & 0xFFFFFF00) | (($temp >> 24) & 0x000000FF); // rotWord + $temp = $this->_subWord($temp) ^ $rcon[$i / $this->Nk]; + } else if ($this->Nk > 6 && $i % $this->Nk == 4) { + $temp = $this->_subWord($temp); + } + $w[$i] = $w[$i - $this->Nk] ^ $temp; + } + + // convert the key schedule from a vector of $Nb * ($Nr + 1) length to a matrix with $Nr + 1 rows and $Nb columns + // and generate the inverse key schedule. more specifically, + // according to (section 5.3.3), + // "The key expansion for the Inverse Cipher is defined as follows: + // 1. Apply the Key Expansion. + // 2. Apply InvMixColumn to all Round Keys except the first and the last one." + // also, see fips-197.pdf#page=27, "5.3.5 Equivalent Inverse Cipher" + $temp = $this->w = $this->dw = array(); + for ($i = $row = $col = 0; $i < $length; $i++, $col++) { + if ($col == $this->Nb) { + if ($row == 0) { + $this->dw[0] = $this->w[0]; + } else { + // subWord + invMixColumn + invSubWord = invMixColumn + $j = 0; + while ($j < $this->Nb) { + $dw = $this->_subWord($this->w[$row][$j]); + $temp[$j] = $this->dt0[$dw >> 24 & 0x000000FF] ^ + $this->dt1[$dw >> 16 & 0x000000FF] ^ + $this->dt2[$dw >> 8 & 0x000000FF] ^ + $this->dt3[$dw & 0x000000FF]; + $j++; + } + $this->dw[$row] = $temp; + } + + $col = 0; + $row++; + } + $this->w[$row][$col] = $w[$i]; + } + + $this->dw[$row] = $this->w[$row]; + + // In case of $this->use_inline_crypt === true we have to use 1-dim key arrays (both ascending) + if ($this->use_inline_crypt) { + $this->dw = array_reverse($this->dw); + $w = array_pop($this->w); + $dw = array_pop($this->dw); + foreach ($this->w as $r => $wr) { + foreach ($wr as $c => $wc) { + $w[] = $wc; + $dw[] = $this->dw[$r][$c]; + } + } + $this->w = $w; + $this->dw = $dw; + } + } + + /** + * Performs S-Box substitutions + * + * @access private + * @param Integer $word + */ + function _subWord($word) + { + $sbox = $this->sbox; + + return $sbox[$word & 0x000000FF] | + ($sbox[$word >> 8 & 0x000000FF] << 8) | + ($sbox[$word >> 16 & 0x000000FF] << 16) | + ($sbox[$word >> 24 & 0x000000FF] << 24); + } + + /** + * Setup the performance-optimized function for de/encrypt() + * + * @see Crypt_Base::_setupInlineCrypt() + * @access private + */ + function _setupInlineCrypt() + { + // Note: _setupInlineCrypt() will be called only if $this->changed === true + // So here we are'nt under the same heavy timing-stress as we are in _de/encryptBlock() or de/encrypt(). + // However...the here generated function- $code, stored as php callback in $this->inline_crypt, must work as fast as even possible. + + $lambda_functions =& Crypt_Rijndael::_getLambdaFunctions(); + + // The first 10 generated $lambda_functions will use the key-words hardcoded for better performance. + // For memory reason we limit those ultra-optimized functions. + // After that, we use pure (extracted) integer vars for the key-words which is faster than accessing them via array. + if (count($lambda_functions) < 10) { + $w = $this->w; + $dw = $this->dw; + $init_encrypt = ''; + $init_decrypt = ''; + } else { + for ($i = 0, $cw = count($this->w); $i < $cw; ++$i) { + $w[] = '$w[' . $i . ']'; + $dw[] = '$dw[' . $i . ']'; + } + $init_encrypt = '$w = $self->w;'; + $init_decrypt = '$dw = $self->dw;'; + } + + $code_hash = md5(str_pad("Crypt_Rijndael, {$this->mode}, {$this->block_size}, ", 32, "\0") . implode(',', $w)); + + if (!isset($lambda_functions[$code_hash])) { + $Nr = $this->Nr; + $Nb = $this->Nb; + $c = $this->c; + + // Generating encrypt code: + $init_encrypt.= ' + static $t0, $t1, $t2, $t3, $sbox; + if (!$t0) { + for ($i = 0; $i < 256; ++$i) { + $t0[$i] = (int)$self->t0[$i]; + $t1[$i] = (int)$self->t1[$i]; + $t2[$i] = (int)$self->t2[$i]; + $t3[$i] = (int)$self->t3[$i]; + $sbox[$i] = (int)$self->sbox[$i]; + } + } + '; + + $s = 'e'; + $e = 's'; + $wc = $Nb - 1; + + // Preround: addRoundKey + $encrypt_block = '$in = unpack("N*", $in);'."\n"; + for ($i = 0; $i < $Nb; ++$i) { + $encrypt_block .= '$s'.$i.' = $in['.($i + 1).'] ^ '.$w[++$wc].";\n"; + } + + // Mainrounds: shiftRows + subWord + mixColumns + addRoundKey + for ($round = 1; $round < $Nr; ++$round) { + list($s, $e) = array($e, $s); + for ($i = 0; $i < $Nb; ++$i) { + $encrypt_block.= + '$'.$e.$i.' = + $t0[($'.$s.$i .' >> 24) & 0xff] ^ + $t1[($'.$s.(($i + $c[1]) % $Nb).' >> 16) & 0xff] ^ + $t2[($'.$s.(($i + $c[2]) % $Nb).' >> 8) & 0xff] ^ + $t3[ $'.$s.(($i + $c[3]) % $Nb).' & 0xff] ^ + '.$w[++$wc].";\n"; + } + } + + // Finalround: subWord + shiftRows + addRoundKey + for ($i = 0; $i < $Nb; ++$i) { + $encrypt_block.= + '$'.$e.$i.' = + $sbox[ $'.$e.$i.' & 0xff] | + ($sbox[($'.$e.$i.' >> 8) & 0xff] << 8) | + ($sbox[($'.$e.$i.' >> 16) & 0xff] << 16) | + ($sbox[($'.$e.$i.' >> 24) & 0xff] << 24);'."\n"; + } + $encrypt_block .= '$in = pack("N*"'."\n"; + for ($i = 0; $i < $Nb; ++$i) { + $encrypt_block.= ', + ($'.$e.$i .' & 0xFF000000) ^ + ($'.$e.(($i + $c[1]) % $Nb).' & 0x00FF0000) ^ + ($'.$e.(($i + $c[2]) % $Nb).' & 0x0000FF00) ^ + ($'.$e.(($i + $c[3]) % $Nb).' & 0x000000FF) ^ + '.$w[$i]."\n"; + } + $encrypt_block .= ');'; + + // Generating decrypt code: + $init_decrypt.= ' + static $dt0, $dt1, $dt2, $dt3, $isbox; + if (!$dt0) { + for ($i = 0; $i < 256; ++$i) { + $dt0[$i] = (int)$self->dt0[$i]; + $dt1[$i] = (int)$self->dt1[$i]; + $dt2[$i] = (int)$self->dt2[$i]; + $dt3[$i] = (int)$self->dt3[$i]; + $isbox[$i] = (int)$self->isbox[$i]; + } + } + '; + + $s = 'e'; + $e = 's'; + $wc = $Nb - 1; + + // Preround: addRoundKey + $decrypt_block = '$in = unpack("N*", $in);'."\n"; + for ($i = 0; $i < $Nb; ++$i) { + $decrypt_block .= '$s'.$i.' = $in['.($i + 1).'] ^ '.$dw[++$wc].';'."\n"; + } + + // Mainrounds: shiftRows + subWord + mixColumns + addRoundKey + for ($round = 1; $round < $Nr; ++$round) { + list($s, $e) = array($e, $s); + for ($i = 0; $i < $Nb; ++$i) { + $decrypt_block.= + '$'.$e.$i.' = + $dt0[($'.$s.$i .' >> 24) & 0xff] ^ + $dt1[($'.$s.(($Nb + $i - $c[1]) % $Nb).' >> 16) & 0xff] ^ + $dt2[($'.$s.(($Nb + $i - $c[2]) % $Nb).' >> 8) & 0xff] ^ + $dt3[ $'.$s.(($Nb + $i - $c[3]) % $Nb).' & 0xff] ^ + '.$dw[++$wc].";\n"; + } + } + + // Finalround: subWord + shiftRows + addRoundKey + for ($i = 0; $i < $Nb; ++$i) { + $decrypt_block.= + '$'.$e.$i.' = + $isbox[ $'.$e.$i.' & 0xff] | + ($isbox[($'.$e.$i.' >> 8) & 0xff] << 8) | + ($isbox[($'.$e.$i.' >> 16) & 0xff] << 16) | + ($isbox[($'.$e.$i.' >> 24) & 0xff] << 24);'."\n"; + } + $decrypt_block .= '$in = pack("N*"'."\n"; + for ($i = 0; $i < $Nb; ++$i) { + $decrypt_block.= ', + ($'.$e.$i. ' & 0xFF000000) ^ + ($'.$e.(($Nb + $i - $c[1]) % $Nb).' & 0x00FF0000) ^ + ($'.$e.(($Nb + $i - $c[2]) % $Nb).' & 0x0000FF00) ^ + ($'.$e.(($Nb + $i - $c[3]) % $Nb).' & 0x000000FF) ^ + '.$dw[$i]."\n"; + } + $decrypt_block .= ');'; + + $lambda_functions[$code_hash] = $this->_createInlineCryptFunction( + array( + 'init_crypt' => '', + 'init_encrypt' => $init_encrypt, + 'init_decrypt' => $init_decrypt, + 'encrypt_block' => $encrypt_block, + 'decrypt_block' => $decrypt_block + ) + ); + } + $this->inline_crypt = $lambda_functions[$code_hash]; + } +} diff --git a/vendor/phpseclib/phpseclib/phpseclib/Crypt/TripleDES.php b/vendor/phpseclib/phpseclib/phpseclib/Crypt/TripleDES.php new file mode 100755 index 0000000..2131820 --- /dev/null +++ b/vendor/phpseclib/phpseclib/phpseclib/Crypt/TripleDES.php @@ -0,0 +1,419 @@ + + * setKey('abcdefghijklmnopqrstuvwx'); + * + * $size = 10 * 1024; + * $plaintext = ''; + * for ($i = 0; $i < $size; $i++) { + * $plaintext.= 'a'; + * } + * + * echo $des->decrypt($des->encrypt($plaintext)); + * ?> + * + * + * LICENSE: Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * @category Crypt + * @package Crypt_TripleDES + * @author Jim Wigginton + * @copyright MMVII Jim Wigginton + * @license http://www.opensource.org/licenses/mit-license.html MIT License + * @link http://phpseclib.sourceforge.net + */ + +/** + * Include Crypt_DES + */ +if (!class_exists('Crypt_DES')) { + include_once 'DES.php'; +} + +/** + * Encrypt / decrypt using inner chaining + * + * Inner chaining is used by SSH-1 and is generally considered to be less secure then outer chaining (CRYPT_DES_MODE_CBC3). + */ +define('CRYPT_DES_MODE_3CBC', -2); + +/** + * Encrypt / decrypt using outer chaining + * + * Outer chaining is used by SSH-2 and when the mode is set to CRYPT_DES_MODE_CBC. + */ +define('CRYPT_DES_MODE_CBC3', CRYPT_DES_MODE_CBC); + +/** + * Pure-PHP implementation of Triple DES. + * + * @package Crypt_TripleDES + * @author Jim Wigginton + * @version 0.1.0 + * @access public + */ +class Crypt_TripleDES extends Crypt_DES +{ + /** + * The default password key_size used by setPassword() + * + * @see Crypt_DES::password_key_size + * @see Crypt_Base::password_key_size + * @see Crypt_Base::setPassword() + * @var Integer + * @access private + */ + var $password_key_size = 24; + + /** + * The default salt used by setPassword() + * + * @see Crypt_Base::password_default_salt + * @see Crypt_Base::setPassword() + * @var String + * @access private + */ + var $password_default_salt = 'phpseclib'; + + /** + * The namespace used by the cipher for its constants. + * + * @see Crypt_DES::const_namespace + * @see Crypt_Base::const_namespace + * @var String + * @access private + */ + var $const_namespace = 'DES'; + + /** + * The mcrypt specific name of the cipher + * + * @see Crypt_DES::cipher_name_mcrypt + * @see Crypt_Base::cipher_name_mcrypt + * @var String + * @access private + */ + var $cipher_name_mcrypt = 'tripledes'; + + /** + * Optimizing value while CFB-encrypting + * + * @see Crypt_Base::cfb_init_len + * @var Integer + * @access private + */ + var $cfb_init_len = 750; + + /** + * max possible size of $key + * + * @see Crypt_TripleDES::setKey() + * @see Crypt_DES::setKey() + * @var String + * @access private + */ + var $key_size_max = 24; + + /** + * Internal flag whether using CRYPT_DES_MODE_3CBC or not + * + * @var Boolean + * @access private + */ + var $mode_3cbc; + + /** + * The Crypt_DES objects + * + * Used only if $mode_3cbc === true + * + * @var Array + * @access private + */ + var $des; + + /** + * Default Constructor. + * + * Determines whether or not the mcrypt extension should be used. + * + * $mode could be: + * + * - CRYPT_DES_MODE_ECB + * + * - CRYPT_DES_MODE_CBC + * + * - CRYPT_DES_MODE_CTR + * + * - CRYPT_DES_MODE_CFB + * + * - CRYPT_DES_MODE_OFB + * + * - CRYPT_DES_MODE_3CBC + * + * If not explictly set, CRYPT_DES_MODE_CBC will be used. + * + * @see Crypt_DES::Crypt_DES() + * @see Crypt_Base::Crypt_Base() + * @param optional Integer $mode + * @access public + */ + function Crypt_TripleDES($mode = CRYPT_DES_MODE_CBC) + { + switch ($mode) { + // In case of CRYPT_DES_MODE_3CBC, we init as CRYPT_DES_MODE_CBC + // and additional flag us internally as 3CBC + case CRYPT_DES_MODE_3CBC: + parent::Crypt_DES(CRYPT_DES_MODE_CBC); + $this->mode_3cbc = true; + + // This three $des'es will do the 3CBC work (if $key > 64bits) + $this->des = array( + new Crypt_DES(CRYPT_DES_MODE_CBC), + new Crypt_DES(CRYPT_DES_MODE_CBC), + new Crypt_DES(CRYPT_DES_MODE_CBC), + ); + + // we're going to be doing the padding, ourselves, so disable it in the Crypt_DES objects + $this->des[0]->disablePadding(); + $this->des[1]->disablePadding(); + $this->des[2]->disablePadding(); + break; + // If not 3CBC, we init as usual + default: + parent::Crypt_DES($mode); + } + } + + /** + * Sets the initialization vector. (optional) + * + * SetIV is not required when CRYPT_DES_MODE_ECB is being used. If not explictly set, it'll be assumed + * to be all zero's. + * + * @see Crypt_Base::setIV() + * @access public + * @param String $iv + */ + function setIV($iv) + { + parent::setIV($iv); + if ($this->mode_3cbc) { + $this->des[0]->setIV($iv); + $this->des[1]->setIV($iv); + $this->des[2]->setIV($iv); + } + } + + /** + * Sets the key. + * + * Keys can be of any length. Triple DES, itself, can use 128-bit (eg. strlen($key) == 16) or + * 192-bit (eg. strlen($key) == 24) keys. This function pads and truncates $key as appropriate. + * + * DES also requires that every eighth bit be a parity bit, however, we'll ignore that. + * + * If the key is not explicitly set, it'll be assumed to be all null bytes. + * + * @access public + * @see Crypt_DES::setKey() + * @see Crypt_Base::setKey() + * @param String $key + */ + function setKey($key) + { + $length = strlen($key); + if ($length > 8) { + $key = str_pad(substr($key, 0, 24), 24, chr(0)); + // if $key is between 64 and 128-bits, use the first 64-bits as the last, per this: + // http://php.net/function.mcrypt-encrypt#47973 + //$key = $length <= 16 ? substr_replace($key, substr($key, 0, 8), 16) : substr($key, 0, 24); + } else { + $key = str_pad($key, 8, chr(0)); + } + parent::setKey($key); + + // And in case of CRYPT_DES_MODE_3CBC: + // if key <= 64bits we not need the 3 $des to work, + // because we will then act as regular DES-CBC with just a <= 64bit key. + // So only if the key > 64bits (> 8 bytes) we will call setKey() for the 3 $des. + if ($this->mode_3cbc && $length > 8) { + $this->des[0]->setKey(substr($key, 0, 8)); + $this->des[1]->setKey(substr($key, 8, 8)); + $this->des[2]->setKey(substr($key, 16, 8)); + } + } + + /** + * Encrypts a message. + * + * @see Crypt_Base::encrypt() + * @access public + * @param String $plaintext + * @return String $cipertext + */ + function encrypt($plaintext) + { + // parent::en/decrypt() is able to do all the work for all modes and keylengths, + // except for: CRYPT_DES_MODE_3CBC (inner chaining CBC) with a key > 64bits + + // if the key is smaller then 8, do what we'd normally do + if ($this->mode_3cbc && strlen($this->key) > 8) { + return $this->des[2]->encrypt( + $this->des[1]->decrypt( + $this->des[0]->encrypt($this->_pad($plaintext)))); + } + + return parent::encrypt($plaintext); + } + + /** + * Decrypts a message. + * + * @see Crypt_Base::decrypt() + * @access public + * @param String $ciphertext + * @return String $plaintext + */ + function decrypt($ciphertext) + { + if ($this->mode_3cbc && strlen($this->key) > 8) { + return $this->_unpad($this->des[0]->decrypt( + $this->des[1]->encrypt( + $this->des[2]->decrypt(str_pad($ciphertext, (strlen($ciphertext) + 7) & 0xFFFFFFF8, "\0"))))); + } + + return parent::decrypt($ciphertext); + } + + /** + * Treat consecutive "packets" as if they are a continuous buffer. + * + * Say you have a 16-byte plaintext $plaintext. Using the default behavior, the two following code snippets + * will yield different outputs: + * + * + * echo $des->encrypt(substr($plaintext, 0, 8)); + * echo $des->encrypt(substr($plaintext, 8, 8)); + * + * + * echo $des->encrypt($plaintext); + * + * + * The solution is to enable the continuous buffer. Although this will resolve the above discrepancy, it creates + * another, as demonstrated with the following: + * + * + * $des->encrypt(substr($plaintext, 0, 8)); + * echo $des->decrypt($des->encrypt(substr($plaintext, 8, 8))); + * + * + * echo $des->decrypt($des->encrypt(substr($plaintext, 8, 8))); + * + * + * With the continuous buffer disabled, these would yield the same output. With it enabled, they yield different + * outputs. The reason is due to the fact that the initialization vector's change after every encryption / + * decryption round when the continuous buffer is enabled. When it's disabled, they remain constant. + * + * Put another way, when the continuous buffer is enabled, the state of the Crypt_DES() object changes after each + * encryption / decryption round, whereas otherwise, it'd remain constant. For this reason, it's recommended that + * continuous buffers not be used. They do offer better security and are, in fact, sometimes required (SSH uses them), + * however, they are also less intuitive and more likely to cause you problems. + * + * @see Crypt_Base::enableContinuousBuffer() + * @see Crypt_TripleDES::disableContinuousBuffer() + * @access public + */ + function enableContinuousBuffer() + { + parent::enableContinuousBuffer(); + if ($this->mode_3cbc) { + $this->des[0]->enableContinuousBuffer(); + $this->des[1]->enableContinuousBuffer(); + $this->des[2]->enableContinuousBuffer(); + } + } + + /** + * Treat consecutive packets as if they are a discontinuous buffer. + * + * The default behavior. + * + * @see Crypt_Base::disableContinuousBuffer() + * @see Crypt_TripleDES::enableContinuousBuffer() + * @access public + */ + function disableContinuousBuffer() + { + parent::disableContinuousBuffer(); + if ($this->mode_3cbc) { + $this->des[0]->disableContinuousBuffer(); + $this->des[1]->disableContinuousBuffer(); + $this->des[2]->disableContinuousBuffer(); + } + } + + /** + * Creates the key schedule + * + * @see Crypt_DES::_setupKey() + * @see Crypt_Base::_setupKey() + * @access private + */ + function _setupKey() + { + switch (true) { + // if $key <= 64bits we configure our internal pure-php cipher engine + // to act as regular [1]DES, not as 3DES. mcrypt.so::tripledes does the same. + case strlen($this->key) <= 8: + $this->des_rounds = 1; + break; + + // otherwise, if $key > 64bits, we configure our engine to work as 3DES. + default: + $this->des_rounds = 3; + + // (only) if 3CBC is used we have, of course, to setup the $des[0-2] keys also separately. + if ($this->mode_3cbc) { + $this->des[0]->_setupKey(); + $this->des[1]->_setupKey(); + $this->des[2]->_setupKey(); + + // because $des[0-2] will, now, do all the work we can return here + // not need unnecessary stress parent::_setupKey() with our, now unused, $key. + return; + } + } + // setup our key + parent::_setupKey(); + } +} diff --git a/vendor/phpseclib/phpseclib/phpseclib/Crypt/Twofish.php b/vendor/phpseclib/phpseclib/phpseclib/Crypt/Twofish.php new file mode 100755 index 0000000..9be5fd1 --- /dev/null +++ b/vendor/phpseclib/phpseclib/phpseclib/Crypt/Twofish.php @@ -0,0 +1,921 @@ + + * setKey('12345678901234567890123456789012'); + * + * $plaintext = str_repeat('a', 1024); + * + * echo $twofish->decrypt($twofish->encrypt($plaintext)); + * ?> + * + * + * LICENSE: Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * @category Crypt + * @package Crypt_Twofish + * @author Jim Wigginton + * @author Hans-Juergen Petrich + * @copyright MMVII Jim Wigginton + * @license http://www.opensource.org/licenses/mit-license.html MIT License + * @version 1.0 + * @link http://phpseclib.sourceforge.net + */ + +/** + * Include Crypt_Base + * + * Base cipher class + */ +if (!class_exists('Crypt_Base')) { + include_once 'Base.php'; +} + +/**#@+ + * @access public + * @see Crypt_Twofish::encrypt() + * @see Crypt_Twofish::decrypt() + */ +/** + * Encrypt / decrypt using the Counter mode. + * + * Set to -1 since that's what Crypt/Random.php uses to index the CTR mode. + * + * @link http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation#Counter_.28CTR.29 + */ +define('CRYPT_TWOFISH_MODE_CTR', CRYPT_MODE_CTR); +/** + * Encrypt / decrypt using the Electronic Code Book mode. + * + * @link http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation#Electronic_codebook_.28ECB.29 + */ +define('CRYPT_TWOFISH_MODE_ECB', CRYPT_MODE_ECB); +/** + * Encrypt / decrypt using the Code Book Chaining mode. + * + * @link http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation#Cipher-block_chaining_.28CBC.29 + */ +define('CRYPT_TWOFISH_MODE_CBC', CRYPT_MODE_CBC); +/** + * Encrypt / decrypt using the Cipher Feedback mode. + * + * @link http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation#Cipher_feedback_.28CFB.29 + */ +define('CRYPT_TWOFISH_MODE_CFB', CRYPT_MODE_CFB); +/** + * Encrypt / decrypt using the Cipher Feedback mode. + * + * @link http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation#Output_feedback_.28OFB.29 + */ +define('CRYPT_TWOFISH_MODE_OFB', CRYPT_MODE_OFB); +/**#@-*/ + +/**#@+ + * @access private + * @see Crypt_Twofish::Crypt_Twofish() + */ +/** + * Toggles the internal implementation + */ +define('CRYPT_TWOFISH_MODE_INTERNAL', CRYPT_MODE_INTERNAL); +/** + * Toggles the mcrypt implementation + */ +define('CRYPT_TWOFISH_MODE_MCRYPT', CRYPT_MODE_MCRYPT); +/**#@-*/ + +/** + * Pure-PHP implementation of Twofish. + * + * @package Crypt_Twofish + * @author Jim Wigginton + * @author Hans-Juergen Petrich + * @version 1.0 + * @access public + */ +class Crypt_Twofish extends Crypt_Base +{ + /** + * The namespace used by the cipher for its constants. + * + * @see Crypt_Base::const_namespace + * @var String + * @access private + */ + var $const_namespace = 'TWOFISH'; + + /** + * The mcrypt specific name of the cipher + * + * @see Crypt_Base::cipher_name_mcrypt + * @var String + * @access private + */ + var $cipher_name_mcrypt = 'twofish'; + + /** + * Optimizing value while CFB-encrypting + * + * @see Crypt_Base::cfb_init_len + * @var Integer + * @access private + */ + var $cfb_init_len = 800; + + /** + * Q-Table + * + * @var Array + * @access private + */ + var $q0 = array ( + 0xA9, 0x67, 0xB3, 0xE8, 0x04, 0xFD, 0xA3, 0x76, + 0x9A, 0x92, 0x80, 0x78, 0xE4, 0xDD, 0xD1, 0x38, + 0x0D, 0xC6, 0x35, 0x98, 0x18, 0xF7, 0xEC, 0x6C, + 0x43, 0x75, 0x37, 0x26, 0xFA, 0x13, 0x94, 0x48, + 0xF2, 0xD0, 0x8B, 0x30, 0x84, 0x54, 0xDF, 0x23, + 0x19, 0x5B, 0x3D, 0x59, 0xF3, 0xAE, 0xA2, 0x82, + 0x63, 0x01, 0x83, 0x2E, 0xD9, 0x51, 0x9B, 0x7C, + 0xA6, 0xEB, 0xA5, 0xBE, 0x16, 0x0C, 0xE3, 0x61, + 0xC0, 0x8C, 0x3A, 0xF5, 0x73, 0x2C, 0x25, 0x0B, + 0xBB, 0x4E, 0x89, 0x6B, 0x53, 0x6A, 0xB4, 0xF1, + 0xE1, 0xE6, 0xBD, 0x45, 0xE2, 0xF4, 0xB6, 0x66, + 0xCC, 0x95, 0x03, 0x56, 0xD4, 0x1C, 0x1E, 0xD7, + 0xFB, 0xC3, 0x8E, 0xB5, 0xE9, 0xCF, 0xBF, 0xBA, + 0xEA, 0x77, 0x39, 0xAF, 0x33, 0xC9, 0x62, 0x71, + 0x81, 0x79, 0x09, 0xAD, 0x24, 0xCD, 0xF9, 0xD8, + 0xE5, 0xC5, 0xB9, 0x4D, 0x44, 0x08, 0x86, 0xE7, + 0xA1, 0x1D, 0xAA, 0xED, 0x06, 0x70, 0xB2, 0xD2, + 0x41, 0x7B, 0xA0, 0x11, 0x31, 0xC2, 0x27, 0x90, + 0x20, 0xF6, 0x60, 0xFF, 0x96, 0x5C, 0xB1, 0xAB, + 0x9E, 0x9C, 0x52, 0x1B, 0x5F, 0x93, 0x0A, 0xEF, + 0x91, 0x85, 0x49, 0xEE, 0x2D, 0x4F, 0x8F, 0x3B, + 0x47, 0x87, 0x6D, 0x46, 0xD6, 0x3E, 0x69, 0x64, + 0x2A, 0xCE, 0xCB, 0x2F, 0xFC, 0x97, 0x05, 0x7A, + 0xAC, 0x7F, 0xD5, 0x1A, 0x4B, 0x0E, 0xA7, 0x5A, + 0x28, 0x14, 0x3F, 0x29, 0x88, 0x3C, 0x4C, 0x02, + 0xB8, 0xDA, 0xB0, 0x17, 0x55, 0x1F, 0x8A, 0x7D, + 0x57, 0xC7, 0x8D, 0x74, 0xB7, 0xC4, 0x9F, 0x72, + 0x7E, 0x15, 0x22, 0x12, 0x58, 0x07, 0x99, 0x34, + 0x6E, 0x50, 0xDE, 0x68, 0x65, 0xBC, 0xDB, 0xF8, + 0xC8, 0xA8, 0x2B, 0x40, 0xDC, 0xFE, 0x32, 0xA4, + 0xCA, 0x10, 0x21, 0xF0, 0xD3, 0x5D, 0x0F, 0x00, + 0x6F, 0x9D, 0x36, 0x42, 0x4A, 0x5E, 0xC1, 0xE0 + ); + + /** + * Q-Table + * + * @var Array + * @access private + */ + var $q1 = array ( + 0x75, 0xF3, 0xC6, 0xF4, 0xDB, 0x7B, 0xFB, 0xC8, + 0x4A, 0xD3, 0xE6, 0x6B, 0x45, 0x7D, 0xE8, 0x4B, + 0xD6, 0x32, 0xD8, 0xFD, 0x37, 0x71, 0xF1, 0xE1, + 0x30, 0x0F, 0xF8, 0x1B, 0x87, 0xFA, 0x06, 0x3F, + 0x5E, 0xBA, 0xAE, 0x5B, 0x8A, 0x00, 0xBC, 0x9D, + 0x6D, 0xC1, 0xB1, 0x0E, 0x80, 0x5D, 0xD2, 0xD5, + 0xA0, 0x84, 0x07, 0x14, 0xB5, 0x90, 0x2C, 0xA3, + 0xB2, 0x73, 0x4C, 0x54, 0x92, 0x74, 0x36, 0x51, + 0x38, 0xB0, 0xBD, 0x5A, 0xFC, 0x60, 0x62, 0x96, + 0x6C, 0x42, 0xF7, 0x10, 0x7C, 0x28, 0x27, 0x8C, + 0x13, 0x95, 0x9C, 0xC7, 0x24, 0x46, 0x3B, 0x70, + 0xCA, 0xE3, 0x85, 0xCB, 0x11, 0xD0, 0x93, 0xB8, + 0xA6, 0x83, 0x20, 0xFF, 0x9F, 0x77, 0xC3, 0xCC, + 0x03, 0x6F, 0x08, 0xBF, 0x40, 0xE7, 0x2B, 0xE2, + 0x79, 0x0C, 0xAA, 0x82, 0x41, 0x3A, 0xEA, 0xB9, + 0xE4, 0x9A, 0xA4, 0x97, 0x7E, 0xDA, 0x7A, 0x17, + 0x66, 0x94, 0xA1, 0x1D, 0x3D, 0xF0, 0xDE, 0xB3, + 0x0B, 0x72, 0xA7, 0x1C, 0xEF, 0xD1, 0x53, 0x3E, + 0x8F, 0x33, 0x26, 0x5F, 0xEC, 0x76, 0x2A, 0x49, + 0x81, 0x88, 0xEE, 0x21, 0xC4, 0x1A, 0xEB, 0xD9, + 0xC5, 0x39, 0x99, 0xCD, 0xAD, 0x31, 0x8B, 0x01, + 0x18, 0x23, 0xDD, 0x1F, 0x4E, 0x2D, 0xF9, 0x48, + 0x4F, 0xF2, 0x65, 0x8E, 0x78, 0x5C, 0x58, 0x19, + 0x8D, 0xE5, 0x98, 0x57, 0x67, 0x7F, 0x05, 0x64, + 0xAF, 0x63, 0xB6, 0xFE, 0xF5, 0xB7, 0x3C, 0xA5, + 0xCE, 0xE9, 0x68, 0x44, 0xE0, 0x4D, 0x43, 0x69, + 0x29, 0x2E, 0xAC, 0x15, 0x59, 0xA8, 0x0A, 0x9E, + 0x6E, 0x47, 0xDF, 0x34, 0x35, 0x6A, 0xCF, 0xDC, + 0x22, 0xC9, 0xC0, 0x9B, 0x89, 0xD4, 0xED, 0xAB, + 0x12, 0xA2, 0x0D, 0x52, 0xBB, 0x02, 0x2F, 0xA9, + 0xD7, 0x61, 0x1E, 0xB4, 0x50, 0x04, 0xF6, 0xC2, + 0x16, 0x25, 0x86, 0x56, 0x55, 0x09, 0xBE, 0x91 + ); + + /** + * M-Table + * + * @var Array + * @access private + */ + var $m0 = array ( + 0xBCBC3275, 0xECEC21F3, 0x202043C6, 0xB3B3C9F4, 0xDADA03DB, 0x02028B7B, 0xE2E22BFB, 0x9E9EFAC8, + 0xC9C9EC4A, 0xD4D409D3, 0x18186BE6, 0x1E1E9F6B, 0x98980E45, 0xB2B2387D, 0xA6A6D2E8, 0x2626B74B, + 0x3C3C57D6, 0x93938A32, 0x8282EED8, 0x525298FD, 0x7B7BD437, 0xBBBB3771, 0x5B5B97F1, 0x474783E1, + 0x24243C30, 0x5151E20F, 0xBABAC6F8, 0x4A4AF31B, 0xBFBF4887, 0x0D0D70FA, 0xB0B0B306, 0x7575DE3F, + 0xD2D2FD5E, 0x7D7D20BA, 0x666631AE, 0x3A3AA35B, 0x59591C8A, 0x00000000, 0xCDCD93BC, 0x1A1AE09D, + 0xAEAE2C6D, 0x7F7FABC1, 0x2B2BC7B1, 0xBEBEB90E, 0xE0E0A080, 0x8A8A105D, 0x3B3B52D2, 0x6464BAD5, + 0xD8D888A0, 0xE7E7A584, 0x5F5FE807, 0x1B1B1114, 0x2C2CC2B5, 0xFCFCB490, 0x3131272C, 0x808065A3, + 0x73732AB2, 0x0C0C8173, 0x79795F4C, 0x6B6B4154, 0x4B4B0292, 0x53536974, 0x94948F36, 0x83831F51, + 0x2A2A3638, 0xC4C49CB0, 0x2222C8BD, 0xD5D5F85A, 0xBDBDC3FC, 0x48487860, 0xFFFFCE62, 0x4C4C0796, + 0x4141776C, 0xC7C7E642, 0xEBEB24F7, 0x1C1C1410, 0x5D5D637C, 0x36362228, 0x6767C027, 0xE9E9AF8C, + 0x4444F913, 0x1414EA95, 0xF5F5BB9C, 0xCFCF18C7, 0x3F3F2D24, 0xC0C0E346, 0x7272DB3B, 0x54546C70, + 0x29294CCA, 0xF0F035E3, 0x0808FE85, 0xC6C617CB, 0xF3F34F11, 0x8C8CE4D0, 0xA4A45993, 0xCACA96B8, + 0x68683BA6, 0xB8B84D83, 0x38382820, 0xE5E52EFF, 0xADAD569F, 0x0B0B8477, 0xC8C81DC3, 0x9999FFCC, + 0x5858ED03, 0x19199A6F, 0x0E0E0A08, 0x95957EBF, 0x70705040, 0xF7F730E7, 0x6E6ECF2B, 0x1F1F6EE2, + 0xB5B53D79, 0x09090F0C, 0x616134AA, 0x57571682, 0x9F9F0B41, 0x9D9D803A, 0x111164EA, 0x2525CDB9, + 0xAFAFDDE4, 0x4545089A, 0xDFDF8DA4, 0xA3A35C97, 0xEAEAD57E, 0x353558DA, 0xEDEDD07A, 0x4343FC17, + 0xF8F8CB66, 0xFBFBB194, 0x3737D3A1, 0xFAFA401D, 0xC2C2683D, 0xB4B4CCF0, 0x32325DDE, 0x9C9C71B3, + 0x5656E70B, 0xE3E3DA72, 0x878760A7, 0x15151B1C, 0xF9F93AEF, 0x6363BFD1, 0x3434A953, 0x9A9A853E, + 0xB1B1428F, 0x7C7CD133, 0x88889B26, 0x3D3DA65F, 0xA1A1D7EC, 0xE4E4DF76, 0x8181942A, 0x91910149, + 0x0F0FFB81, 0xEEEEAA88, 0x161661EE, 0xD7D77321, 0x9797F5C4, 0xA5A5A81A, 0xFEFE3FEB, 0x6D6DB5D9, + 0x7878AEC5, 0xC5C56D39, 0x1D1DE599, 0x7676A4CD, 0x3E3EDCAD, 0xCBCB6731, 0xB6B6478B, 0xEFEF5B01, + 0x12121E18, 0x6060C523, 0x6A6AB0DD, 0x4D4DF61F, 0xCECEE94E, 0xDEDE7C2D, 0x55559DF9, 0x7E7E5A48, + 0x2121B24F, 0x03037AF2, 0xA0A02665, 0x5E5E198E, 0x5A5A6678, 0x65654B5C, 0x62624E58, 0xFDFD4519, + 0x0606F48D, 0x404086E5, 0xF2F2BE98, 0x3333AC57, 0x17179067, 0x05058E7F, 0xE8E85E05, 0x4F4F7D64, + 0x89896AAF, 0x10109563, 0x74742FB6, 0x0A0A75FE, 0x5C5C92F5, 0x9B9B74B7, 0x2D2D333C, 0x3030D6A5, + 0x2E2E49CE, 0x494989E9, 0x46467268, 0x77775544, 0xA8A8D8E0, 0x9696044D, 0x2828BD43, 0xA9A92969, + 0xD9D97929, 0x8686912E, 0xD1D187AC, 0xF4F44A15, 0x8D8D1559, 0xD6D682A8, 0xB9B9BC0A, 0x42420D9E, + 0xF6F6C16E, 0x2F2FB847, 0xDDDD06DF, 0x23233934, 0xCCCC6235, 0xF1F1C46A, 0xC1C112CF, 0x8585EBDC, + 0x8F8F9E22, 0x7171A1C9, 0x9090F0C0, 0xAAAA539B, 0x0101F189, 0x8B8BE1D4, 0x4E4E8CED, 0x8E8E6FAB, + 0xABABA212, 0x6F6F3EA2, 0xE6E6540D, 0xDBDBF252, 0x92927BBB, 0xB7B7B602, 0x6969CA2F, 0x3939D9A9, + 0xD3D30CD7, 0xA7A72361, 0xA2A2AD1E, 0xC3C399B4, 0x6C6C4450, 0x07070504, 0x04047FF6, 0x272746C2, + 0xACACA716, 0xD0D07625, 0x50501386, 0xDCDCF756, 0x84841A55, 0xE1E15109, 0x7A7A25BE, 0x1313EF91 + ); + + /** + * M-Table + * + * @var Array + * @access private + */ + var $m1 = array ( + 0xA9D93939, 0x67901717, 0xB3719C9C, 0xE8D2A6A6, 0x04050707, 0xFD985252, 0xA3658080, 0x76DFE4E4, + 0x9A084545, 0x92024B4B, 0x80A0E0E0, 0x78665A5A, 0xE4DDAFAF, 0xDDB06A6A, 0xD1BF6363, 0x38362A2A, + 0x0D54E6E6, 0xC6432020, 0x3562CCCC, 0x98BEF2F2, 0x181E1212, 0xF724EBEB, 0xECD7A1A1, 0x6C774141, + 0x43BD2828, 0x7532BCBC, 0x37D47B7B, 0x269B8888, 0xFA700D0D, 0x13F94444, 0x94B1FBFB, 0x485A7E7E, + 0xF27A0303, 0xD0E48C8C, 0x8B47B6B6, 0x303C2424, 0x84A5E7E7, 0x54416B6B, 0xDF06DDDD, 0x23C56060, + 0x1945FDFD, 0x5BA33A3A, 0x3D68C2C2, 0x59158D8D, 0xF321ECEC, 0xAE316666, 0xA23E6F6F, 0x82165757, + 0x63951010, 0x015BEFEF, 0x834DB8B8, 0x2E918686, 0xD9B56D6D, 0x511F8383, 0x9B53AAAA, 0x7C635D5D, + 0xA63B6868, 0xEB3FFEFE, 0xA5D63030, 0xBE257A7A, 0x16A7ACAC, 0x0C0F0909, 0xE335F0F0, 0x6123A7A7, + 0xC0F09090, 0x8CAFE9E9, 0x3A809D9D, 0xF5925C5C, 0x73810C0C, 0x2C273131, 0x2576D0D0, 0x0BE75656, + 0xBB7B9292, 0x4EE9CECE, 0x89F10101, 0x6B9F1E1E, 0x53A93434, 0x6AC4F1F1, 0xB499C3C3, 0xF1975B5B, + 0xE1834747, 0xE66B1818, 0xBDC82222, 0x450E9898, 0xE26E1F1F, 0xF4C9B3B3, 0xB62F7474, 0x66CBF8F8, + 0xCCFF9999, 0x95EA1414, 0x03ED5858, 0x56F7DCDC, 0xD4E18B8B, 0x1C1B1515, 0x1EADA2A2, 0xD70CD3D3, + 0xFB2BE2E2, 0xC31DC8C8, 0x8E195E5E, 0xB5C22C2C, 0xE9894949, 0xCF12C1C1, 0xBF7E9595, 0xBA207D7D, + 0xEA641111, 0x77840B0B, 0x396DC5C5, 0xAF6A8989, 0x33D17C7C, 0xC9A17171, 0x62CEFFFF, 0x7137BBBB, + 0x81FB0F0F, 0x793DB5B5, 0x0951E1E1, 0xADDC3E3E, 0x242D3F3F, 0xCDA47676, 0xF99D5555, 0xD8EE8282, + 0xE5864040, 0xC5AE7878, 0xB9CD2525, 0x4D049696, 0x44557777, 0x080A0E0E, 0x86135050, 0xE730F7F7, + 0xA1D33737, 0x1D40FAFA, 0xAA346161, 0xED8C4E4E, 0x06B3B0B0, 0x706C5454, 0xB22A7373, 0xD2523B3B, + 0x410B9F9F, 0x7B8B0202, 0xA088D8D8, 0x114FF3F3, 0x3167CBCB, 0xC2462727, 0x27C06767, 0x90B4FCFC, + 0x20283838, 0xF67F0404, 0x60784848, 0xFF2EE5E5, 0x96074C4C, 0x5C4B6565, 0xB1C72B2B, 0xAB6F8E8E, + 0x9E0D4242, 0x9CBBF5F5, 0x52F2DBDB, 0x1BF34A4A, 0x5FA63D3D, 0x9359A4A4, 0x0ABCB9B9, 0xEF3AF9F9, + 0x91EF1313, 0x85FE0808, 0x49019191, 0xEE611616, 0x2D7CDEDE, 0x4FB22121, 0x8F42B1B1, 0x3BDB7272, + 0x47B82F2F, 0x8748BFBF, 0x6D2CAEAE, 0x46E3C0C0, 0xD6573C3C, 0x3E859A9A, 0x6929A9A9, 0x647D4F4F, + 0x2A948181, 0xCE492E2E, 0xCB17C6C6, 0x2FCA6969, 0xFCC3BDBD, 0x975CA3A3, 0x055EE8E8, 0x7AD0EDED, + 0xAC87D1D1, 0x7F8E0505, 0xD5BA6464, 0x1AA8A5A5, 0x4BB72626, 0x0EB9BEBE, 0xA7608787, 0x5AF8D5D5, + 0x28223636, 0x14111B1B, 0x3FDE7575, 0x2979D9D9, 0x88AAEEEE, 0x3C332D2D, 0x4C5F7979, 0x02B6B7B7, + 0xB896CACA, 0xDA583535, 0xB09CC4C4, 0x17FC4343, 0x551A8484, 0x1FF64D4D, 0x8A1C5959, 0x7D38B2B2, + 0x57AC3333, 0xC718CFCF, 0x8DF40606, 0x74695353, 0xB7749B9B, 0xC4F59797, 0x9F56ADAD, 0x72DAE3E3, + 0x7ED5EAEA, 0x154AF4F4, 0x229E8F8F, 0x12A2ABAB, 0x584E6262, 0x07E85F5F, 0x99E51D1D, 0x34392323, + 0x6EC1F6F6, 0x50446C6C, 0xDE5D3232, 0x68724646, 0x6526A0A0, 0xBC93CDCD, 0xDB03DADA, 0xF8C6BABA, + 0xC8FA9E9E, 0xA882D6D6, 0x2BCF6E6E, 0x40507070, 0xDCEB8585, 0xFE750A0A, 0x328A9393, 0xA48DDFDF, + 0xCA4C2929, 0x10141C1C, 0x2173D7D7, 0xF0CCB4B4, 0xD309D4D4, 0x5D108A8A, 0x0FE25151, 0x00000000, + 0x6F9A1919, 0x9DE01A1A, 0x368F9494, 0x42E6C7C7, 0x4AECC9C9, 0x5EFDD2D2, 0xC1AB7F7F, 0xE0D8A8A8 + ); + + /** + * M-Table + * + * @var Array + * @access private + */ + var $m2 = array ( + 0xBC75BC32, 0xECF3EC21, 0x20C62043, 0xB3F4B3C9, 0xDADBDA03, 0x027B028B, 0xE2FBE22B, 0x9EC89EFA, + 0xC94AC9EC, 0xD4D3D409, 0x18E6186B, 0x1E6B1E9F, 0x9845980E, 0xB27DB238, 0xA6E8A6D2, 0x264B26B7, + 0x3CD63C57, 0x9332938A, 0x82D882EE, 0x52FD5298, 0x7B377BD4, 0xBB71BB37, 0x5BF15B97, 0x47E14783, + 0x2430243C, 0x510F51E2, 0xBAF8BAC6, 0x4A1B4AF3, 0xBF87BF48, 0x0DFA0D70, 0xB006B0B3, 0x753F75DE, + 0xD25ED2FD, 0x7DBA7D20, 0x66AE6631, 0x3A5B3AA3, 0x598A591C, 0x00000000, 0xCDBCCD93, 0x1A9D1AE0, + 0xAE6DAE2C, 0x7FC17FAB, 0x2BB12BC7, 0xBE0EBEB9, 0xE080E0A0, 0x8A5D8A10, 0x3BD23B52, 0x64D564BA, + 0xD8A0D888, 0xE784E7A5, 0x5F075FE8, 0x1B141B11, 0x2CB52CC2, 0xFC90FCB4, 0x312C3127, 0x80A38065, + 0x73B2732A, 0x0C730C81, 0x794C795F, 0x6B546B41, 0x4B924B02, 0x53745369, 0x9436948F, 0x8351831F, + 0x2A382A36, 0xC4B0C49C, 0x22BD22C8, 0xD55AD5F8, 0xBDFCBDC3, 0x48604878, 0xFF62FFCE, 0x4C964C07, + 0x416C4177, 0xC742C7E6, 0xEBF7EB24, 0x1C101C14, 0x5D7C5D63, 0x36283622, 0x672767C0, 0xE98CE9AF, + 0x441344F9, 0x149514EA, 0xF59CF5BB, 0xCFC7CF18, 0x3F243F2D, 0xC046C0E3, 0x723B72DB, 0x5470546C, + 0x29CA294C, 0xF0E3F035, 0x088508FE, 0xC6CBC617, 0xF311F34F, 0x8CD08CE4, 0xA493A459, 0xCAB8CA96, + 0x68A6683B, 0xB883B84D, 0x38203828, 0xE5FFE52E, 0xAD9FAD56, 0x0B770B84, 0xC8C3C81D, 0x99CC99FF, + 0x580358ED, 0x196F199A, 0x0E080E0A, 0x95BF957E, 0x70407050, 0xF7E7F730, 0x6E2B6ECF, 0x1FE21F6E, + 0xB579B53D, 0x090C090F, 0x61AA6134, 0x57825716, 0x9F419F0B, 0x9D3A9D80, 0x11EA1164, 0x25B925CD, + 0xAFE4AFDD, 0x459A4508, 0xDFA4DF8D, 0xA397A35C, 0xEA7EEAD5, 0x35DA3558, 0xED7AEDD0, 0x431743FC, + 0xF866F8CB, 0xFB94FBB1, 0x37A137D3, 0xFA1DFA40, 0xC23DC268, 0xB4F0B4CC, 0x32DE325D, 0x9CB39C71, + 0x560B56E7, 0xE372E3DA, 0x87A78760, 0x151C151B, 0xF9EFF93A, 0x63D163BF, 0x345334A9, 0x9A3E9A85, + 0xB18FB142, 0x7C337CD1, 0x8826889B, 0x3D5F3DA6, 0xA1ECA1D7, 0xE476E4DF, 0x812A8194, 0x91499101, + 0x0F810FFB, 0xEE88EEAA, 0x16EE1661, 0xD721D773, 0x97C497F5, 0xA51AA5A8, 0xFEEBFE3F, 0x6DD96DB5, + 0x78C578AE, 0xC539C56D, 0x1D991DE5, 0x76CD76A4, 0x3EAD3EDC, 0xCB31CB67, 0xB68BB647, 0xEF01EF5B, + 0x1218121E, 0x602360C5, 0x6ADD6AB0, 0x4D1F4DF6, 0xCE4ECEE9, 0xDE2DDE7C, 0x55F9559D, 0x7E487E5A, + 0x214F21B2, 0x03F2037A, 0xA065A026, 0x5E8E5E19, 0x5A785A66, 0x655C654B, 0x6258624E, 0xFD19FD45, + 0x068D06F4, 0x40E54086, 0xF298F2BE, 0x335733AC, 0x17671790, 0x057F058E, 0xE805E85E, 0x4F644F7D, + 0x89AF896A, 0x10631095, 0x74B6742F, 0x0AFE0A75, 0x5CF55C92, 0x9BB79B74, 0x2D3C2D33, 0x30A530D6, + 0x2ECE2E49, 0x49E94989, 0x46684672, 0x77447755, 0xA8E0A8D8, 0x964D9604, 0x284328BD, 0xA969A929, + 0xD929D979, 0x862E8691, 0xD1ACD187, 0xF415F44A, 0x8D598D15, 0xD6A8D682, 0xB90AB9BC, 0x429E420D, + 0xF66EF6C1, 0x2F472FB8, 0xDDDFDD06, 0x23342339, 0xCC35CC62, 0xF16AF1C4, 0xC1CFC112, 0x85DC85EB, + 0x8F228F9E, 0x71C971A1, 0x90C090F0, 0xAA9BAA53, 0x018901F1, 0x8BD48BE1, 0x4EED4E8C, 0x8EAB8E6F, + 0xAB12ABA2, 0x6FA26F3E, 0xE60DE654, 0xDB52DBF2, 0x92BB927B, 0xB702B7B6, 0x692F69CA, 0x39A939D9, + 0xD3D7D30C, 0xA761A723, 0xA21EA2AD, 0xC3B4C399, 0x6C506C44, 0x07040705, 0x04F6047F, 0x27C22746, + 0xAC16ACA7, 0xD025D076, 0x50865013, 0xDC56DCF7, 0x8455841A, 0xE109E151, 0x7ABE7A25, 0x139113EF + ); + + /** + * M-Table + * + * @var Array + * @access private + */ + var $m3 = array ( + 0xD939A9D9, 0x90176790, 0x719CB371, 0xD2A6E8D2, 0x05070405, 0x9852FD98, 0x6580A365, 0xDFE476DF, + 0x08459A08, 0x024B9202, 0xA0E080A0, 0x665A7866, 0xDDAFE4DD, 0xB06ADDB0, 0xBF63D1BF, 0x362A3836, + 0x54E60D54, 0x4320C643, 0x62CC3562, 0xBEF298BE, 0x1E12181E, 0x24EBF724, 0xD7A1ECD7, 0x77416C77, + 0xBD2843BD, 0x32BC7532, 0xD47B37D4, 0x9B88269B, 0x700DFA70, 0xF94413F9, 0xB1FB94B1, 0x5A7E485A, + 0x7A03F27A, 0xE48CD0E4, 0x47B68B47, 0x3C24303C, 0xA5E784A5, 0x416B5441, 0x06DDDF06, 0xC56023C5, + 0x45FD1945, 0xA33A5BA3, 0x68C23D68, 0x158D5915, 0x21ECF321, 0x3166AE31, 0x3E6FA23E, 0x16578216, + 0x95106395, 0x5BEF015B, 0x4DB8834D, 0x91862E91, 0xB56DD9B5, 0x1F83511F, 0x53AA9B53, 0x635D7C63, + 0x3B68A63B, 0x3FFEEB3F, 0xD630A5D6, 0x257ABE25, 0xA7AC16A7, 0x0F090C0F, 0x35F0E335, 0x23A76123, + 0xF090C0F0, 0xAFE98CAF, 0x809D3A80, 0x925CF592, 0x810C7381, 0x27312C27, 0x76D02576, 0xE7560BE7, + 0x7B92BB7B, 0xE9CE4EE9, 0xF10189F1, 0x9F1E6B9F, 0xA93453A9, 0xC4F16AC4, 0x99C3B499, 0x975BF197, + 0x8347E183, 0x6B18E66B, 0xC822BDC8, 0x0E98450E, 0x6E1FE26E, 0xC9B3F4C9, 0x2F74B62F, 0xCBF866CB, + 0xFF99CCFF, 0xEA1495EA, 0xED5803ED, 0xF7DC56F7, 0xE18BD4E1, 0x1B151C1B, 0xADA21EAD, 0x0CD3D70C, + 0x2BE2FB2B, 0x1DC8C31D, 0x195E8E19, 0xC22CB5C2, 0x8949E989, 0x12C1CF12, 0x7E95BF7E, 0x207DBA20, + 0x6411EA64, 0x840B7784, 0x6DC5396D, 0x6A89AF6A, 0xD17C33D1, 0xA171C9A1, 0xCEFF62CE, 0x37BB7137, + 0xFB0F81FB, 0x3DB5793D, 0x51E10951, 0xDC3EADDC, 0x2D3F242D, 0xA476CDA4, 0x9D55F99D, 0xEE82D8EE, + 0x8640E586, 0xAE78C5AE, 0xCD25B9CD, 0x04964D04, 0x55774455, 0x0A0E080A, 0x13508613, 0x30F7E730, + 0xD337A1D3, 0x40FA1D40, 0x3461AA34, 0x8C4EED8C, 0xB3B006B3, 0x6C54706C, 0x2A73B22A, 0x523BD252, + 0x0B9F410B, 0x8B027B8B, 0x88D8A088, 0x4FF3114F, 0x67CB3167, 0x4627C246, 0xC06727C0, 0xB4FC90B4, + 0x28382028, 0x7F04F67F, 0x78486078, 0x2EE5FF2E, 0x074C9607, 0x4B655C4B, 0xC72BB1C7, 0x6F8EAB6F, + 0x0D429E0D, 0xBBF59CBB, 0xF2DB52F2, 0xF34A1BF3, 0xA63D5FA6, 0x59A49359, 0xBCB90ABC, 0x3AF9EF3A, + 0xEF1391EF, 0xFE0885FE, 0x01914901, 0x6116EE61, 0x7CDE2D7C, 0xB2214FB2, 0x42B18F42, 0xDB723BDB, + 0xB82F47B8, 0x48BF8748, 0x2CAE6D2C, 0xE3C046E3, 0x573CD657, 0x859A3E85, 0x29A96929, 0x7D4F647D, + 0x94812A94, 0x492ECE49, 0x17C6CB17, 0xCA692FCA, 0xC3BDFCC3, 0x5CA3975C, 0x5EE8055E, 0xD0ED7AD0, + 0x87D1AC87, 0x8E057F8E, 0xBA64D5BA, 0xA8A51AA8, 0xB7264BB7, 0xB9BE0EB9, 0x6087A760, 0xF8D55AF8, + 0x22362822, 0x111B1411, 0xDE753FDE, 0x79D92979, 0xAAEE88AA, 0x332D3C33, 0x5F794C5F, 0xB6B702B6, + 0x96CAB896, 0x5835DA58, 0x9CC4B09C, 0xFC4317FC, 0x1A84551A, 0xF64D1FF6, 0x1C598A1C, 0x38B27D38, + 0xAC3357AC, 0x18CFC718, 0xF4068DF4, 0x69537469, 0x749BB774, 0xF597C4F5, 0x56AD9F56, 0xDAE372DA, + 0xD5EA7ED5, 0x4AF4154A, 0x9E8F229E, 0xA2AB12A2, 0x4E62584E, 0xE85F07E8, 0xE51D99E5, 0x39233439, + 0xC1F66EC1, 0x446C5044, 0x5D32DE5D, 0x72466872, 0x26A06526, 0x93CDBC93, 0x03DADB03, 0xC6BAF8C6, + 0xFA9EC8FA, 0x82D6A882, 0xCF6E2BCF, 0x50704050, 0xEB85DCEB, 0x750AFE75, 0x8A93328A, 0x8DDFA48D, + 0x4C29CA4C, 0x141C1014, 0x73D72173, 0xCCB4F0CC, 0x09D4D309, 0x108A5D10, 0xE2510FE2, 0x00000000, + 0x9A196F9A, 0xE01A9DE0, 0x8F94368F, 0xE6C742E6, 0xECC94AEC, 0xFDD25EFD, 0xAB7FC1AB, 0xD8A8E0D8 + ); + + /** + * The Key Schedule Array + * + * @var Array + * @access private + */ + var $K = array(); + + /** + * The Key depended S-Table 0 + * + * @var Array + * @access private + */ + var $S0 = array(); + + /** + * The Key depended S-Table 1 + * + * @var Array + * @access private + */ + var $S1 = array(); + + /** + * The Key depended S-Table 2 + * + * @var Array + * @access private + */ + var $S2 = array(); + + /** + * The Key depended S-Table 3 + * + * @var Array + * @access private + */ + var $S3 = array(); + + /** + * Holds the last used key + * + * @var Array + * @access private + */ + var $kl; + + /** + * Default Constructor. + * + * Determines whether or not the mcrypt extension should be used. + * + * $mode could be: + * + * - CRYPT_TWOFISH_MODE_ECB + * + * - CRYPT_TWOFISH_MODE_CBC + * + * - CRYPT_TWOFISH_MODE_CTR + * + * - CRYPT_TWOFISH_MODE_CFB + * + * - CRYPT_TWOFISH_MODE_OFB + * + * If not explictly set, CRYPT_TWOFISH_MODE_CBC will be used. + * + * @see Crypt_Base::Crypt_Base() + * @param optional Integer $mode + * @access public + */ + function Crypt_Twofish($mode = CRYPT_TWOFISH_MODE_CBC) + { + parent::Crypt_Base($mode); + } + + /** + * Sets the key. + * + * Keys can be of any length. Twofish, itself, requires the use of a key that's 128, 192 or 256-bits long. + * If the key is less than 256-bits we round the length up to the closest valid key length, + * padding $key with null bytes. If the key is more than 256-bits, we trim the excess bits. + * + * If the key is not explicitly set, it'll be assumed a 128 bits key to be all null bytes. + * + * @access public + * @see Crypt_Base::setKey() + * @param String $key + */ + function setKey($key) + { + $keylength = strlen($key); + switch (true) { + case $keylength <= 16: + $key = str_pad($key, 16, "\0"); + break; + case $keylength <= 24: + $key = str_pad($key, 24, "\0"); + break; + case $keylength < 32: + $key = str_pad($key, 32, "\0"); + break; + case $keylength > 32: + $key = substr($key, 0, 32); + } + parent::setKey($key); + } + + /** + * Setup the key (expansion) + * + * @see Crypt_Base::_setupKey() + * @access private + */ + function _setupKey() + { + if (isset($this->kl['key']) && $this->key === $this->kl['key']) { + // already expanded + return; + } + $this->kl = array('key' => $this->key); + + /* Key expanding and generating the key-depended s-boxes */ + $le_longs = unpack('V*', $this->key); + $key = unpack('C*', $this->key); + $m0 = $this->m0; + $m1 = $this->m1; + $m2 = $this->m2; + $m3 = $this->m3; + $q0 = $this->q0; + $q1 = $this->q1; + + $K = $S0 = $S1 = $S2 = $S3 = array(); + + switch (strlen($this->key)) { + case 16: + list ($s7, $s6, $s5, $s4) = $this->_mdsrem($le_longs[1], $le_longs[2]); + list ($s3, $s2, $s1, $s0) = $this->_mdsrem($le_longs[3], $le_longs[4]); + for ($i = 0, $j = 1; $i < 40; $i+= 2,$j+= 2) { + $A = $m0[$q0[$q0[$i] ^ $key[ 9]] ^ $key[1]] ^ + $m1[$q0[$q1[$i] ^ $key[10]] ^ $key[2]] ^ + $m2[$q1[$q0[$i] ^ $key[11]] ^ $key[3]] ^ + $m3[$q1[$q1[$i] ^ $key[12]] ^ $key[4]]; + $B = $m0[$q0[$q0[$j] ^ $key[13]] ^ $key[5]] ^ + $m1[$q0[$q1[$j] ^ $key[14]] ^ $key[6]] ^ + $m2[$q1[$q0[$j] ^ $key[15]] ^ $key[7]] ^ + $m3[$q1[$q1[$j] ^ $key[16]] ^ $key[8]]; + $B = ($B << 8) | ($B >> 24 & 0xff); + $K[] = $A+= $B; + $K[] = (($A+= $B) << 9 | $A >> 23 & 0x1ff); + } + for ($i = 0; $i < 256; ++$i) { + $S0[$i] = $m0[$q0[$q0[$i] ^ $s4] ^ $s0]; + $S1[$i] = $m1[$q0[$q1[$i] ^ $s5] ^ $s1]; + $S2[$i] = $m2[$q1[$q0[$i] ^ $s6] ^ $s2]; + $S3[$i] = $m3[$q1[$q1[$i] ^ $s7] ^ $s3]; + } + break; + case 24: + list ($sb, $sa, $s9, $s8) = $this->_mdsrem($le_longs[1], $le_longs[2]); + list ($s7, $s6, $s5, $s4) = $this->_mdsrem($le_longs[3], $le_longs[4]); + list ($s3, $s2, $s1, $s0) = $this->_mdsrem($le_longs[5], $le_longs[6]); + for ($i = 0, $j = 1; $i < 40; $i+= 2, $j+= 2) { + $A = $m0[$q0[$q0[$q1[$i] ^ $key[17]] ^ $key[ 9]] ^ $key[1]] ^ + $m1[$q0[$q1[$q1[$i] ^ $key[18]] ^ $key[10]] ^ $key[2]] ^ + $m2[$q1[$q0[$q0[$i] ^ $key[19]] ^ $key[11]] ^ $key[3]] ^ + $m3[$q1[$q1[$q0[$i] ^ $key[20]] ^ $key[12]] ^ $key[4]]; + $B = $m0[$q0[$q0[$q1[$j] ^ $key[21]] ^ $key[13]] ^ $key[5]] ^ + $m1[$q0[$q1[$q1[$j] ^ $key[22]] ^ $key[14]] ^ $key[6]] ^ + $m2[$q1[$q0[$q0[$j] ^ $key[23]] ^ $key[15]] ^ $key[7]] ^ + $m3[$q1[$q1[$q0[$j] ^ $key[24]] ^ $key[16]] ^ $key[8]]; + $B = ($B << 8) | ($B >> 24 & 0xff); + $K[] = $A+= $B; + $K[] = (($A+= $B) << 9 | $A >> 23 & 0x1ff); + } + for ($i = 0; $i < 256; ++$i) { + $S0[$i] = $m0[$q0[$q0[$q1[$i] ^ $s8] ^ $s4] ^ $s0]; + $S1[$i] = $m1[$q0[$q1[$q1[$i] ^ $s9] ^ $s5] ^ $s1]; + $S2[$i] = $m2[$q1[$q0[$q0[$i] ^ $sa] ^ $s6] ^ $s2]; + $S3[$i] = $m3[$q1[$q1[$q0[$i] ^ $sb] ^ $s7] ^ $s3]; + } + break; + default: // 32 + list ($sf, $se, $sd, $sc) = $this->_mdsrem($le_longs[1], $le_longs[2]); + list ($sb, $sa, $s9, $s8) = $this->_mdsrem($le_longs[3], $le_longs[4]); + list ($s7, $s6, $s5, $s4) = $this->_mdsrem($le_longs[5], $le_longs[6]); + list ($s3, $s2, $s1, $s0) = $this->_mdsrem($le_longs[7], $le_longs[8]); + for ($i = 0, $j = 1; $i < 40; $i+= 2, $j+= 2) { + $A = $m0[$q0[$q0[$q1[$q1[$i] ^ $key[25]] ^ $key[17]] ^ $key[ 9]] ^ $key[1]] ^ + $m1[$q0[$q1[$q1[$q0[$i] ^ $key[26]] ^ $key[18]] ^ $key[10]] ^ $key[2]] ^ + $m2[$q1[$q0[$q0[$q0[$i] ^ $key[27]] ^ $key[19]] ^ $key[11]] ^ $key[3]] ^ + $m3[$q1[$q1[$q0[$q1[$i] ^ $key[28]] ^ $key[20]] ^ $key[12]] ^ $key[4]]; + $B = $m0[$q0[$q0[$q1[$q1[$j] ^ $key[29]] ^ $key[21]] ^ $key[13]] ^ $key[5]] ^ + $m1[$q0[$q1[$q1[$q0[$j] ^ $key[30]] ^ $key[22]] ^ $key[14]] ^ $key[6]] ^ + $m2[$q1[$q0[$q0[$q0[$j] ^ $key[31]] ^ $key[23]] ^ $key[15]] ^ $key[7]] ^ + $m3[$q1[$q1[$q0[$q1[$j] ^ $key[32]] ^ $key[24]] ^ $key[16]] ^ $key[8]]; + $B = ($B << 8) | ($B >> 24 & 0xff); + $K[] = $A+= $B; + $K[] = (($A+= $B) << 9 | $A >> 23 & 0x1ff); + } + for ($i = 0; $i < 256; ++$i) { + $S0[$i] = $m0[$q0[$q0[$q1[$q1[$i] ^ $sc] ^ $s8] ^ $s4] ^ $s0]; + $S1[$i] = $m1[$q0[$q1[$q1[$q0[$i] ^ $sd] ^ $s9] ^ $s5] ^ $s1]; + $S2[$i] = $m2[$q1[$q0[$q0[$q0[$i] ^ $se] ^ $sa] ^ $s6] ^ $s2]; + $S3[$i] = $m3[$q1[$q1[$q0[$q1[$i] ^ $sf] ^ $sb] ^ $s7] ^ $s3]; + } + } + + $this->K = $K; + $this->S0 = $S0; + $this->S1 = $S1; + $this->S2 = $S2; + $this->S3 = $S3; + } + + /** + * _mdsrem function using by the twofish cipher algorithm + * + * @access private + * @param String $A + * @param String $B + * @return Array + */ + function _mdsrem($A, $B) + { + // No gain by unrolling this loop. + for ($i = 0; $i < 8; ++$i) { + // Get most significant coefficient. + $t = 0xff & ($B >> 24); + + // Shift the others up. + $B = ($B << 8) | (0xff & ($A >> 24)); + $A<<= 8; + + $u = $t << 1; + + // Subtract the modular polynomial on overflow. + if ($t & 0x80) { + $u^= 0x14d; + } + + // Remove t * (a * x^2 + 1). + $B ^= $t ^ ($u << 16); + + // Form u = a*t + t/a = t*(a + 1/a). + $u^= 0x7fffffff & ($t >> 1); + + // Add the modular polynomial on underflow. + if ($t & 0x01) $u^= 0xa6 ; + + // Remove t * (a + 1/a) * (x^3 + x). + $B^= ($u << 24) | ($u << 8); + } + + return array( + 0xff & $B >> 24, + 0xff & $B >> 16, + 0xff & $B >> 8, + 0xff & $B); + } + + /** + * Encrypts a block + * + * @access private + * @param String $in + * @return String + */ + function _encryptBlock($in) + { + $S0 = $this->S0; + $S1 = $this->S1; + $S2 = $this->S2; + $S3 = $this->S3; + $K = $this->K; + + $in = unpack("V4", $in); + $R0 = $K[0] ^ $in[1]; + $R1 = $K[1] ^ $in[2]; + $R2 = $K[2] ^ $in[3]; + $R3 = $K[3] ^ $in[4]; + + $ki = 7; + while ($ki < 39) { + $t0 = $S0[ $R0 & 0xff] ^ + $S1[($R0 >> 8) & 0xff] ^ + $S2[($R0 >> 16) & 0xff] ^ + $S3[($R0 >> 24) & 0xff]; + $t1 = $S0[($R1 >> 24) & 0xff] ^ + $S1[ $R1 & 0xff] ^ + $S2[($R1 >> 8) & 0xff] ^ + $S3[($R1 >> 16) & 0xff]; + $R2^= $t0 + $t1 + $K[++$ki]; + $R2 = ($R2 >> 1 & 0x7fffffff) | ($R2 << 31); + $R3 = ((($R3 >> 31) & 1) | ($R3 << 1)) ^ ($t0 + ($t1 << 1) + $K[++$ki]); + + $t0 = $S0[ $R2 & 0xff] ^ + $S1[($R2 >> 8) & 0xff] ^ + $S2[($R2 >> 16) & 0xff] ^ + $S3[($R2 >> 24) & 0xff]; + $t1 = $S0[($R3 >> 24) & 0xff] ^ + $S1[ $R3 & 0xff] ^ + $S2[($R3 >> 8) & 0xff] ^ + $S3[($R3 >> 16) & 0xff]; + $R0^= ($t0 + $t1 + $K[++$ki]); + $R0 = ($R0 >> 1 & 0x7fffffff) | ($R0 << 31); + $R1 = ((($R1 >> 31) & 1) | ($R1 << 1)) ^ ($t0 + ($t1 << 1) + $K[++$ki]); + } + + return pack("V4", $K[4] ^ $R2, + $K[5] ^ $R3, + $K[6] ^ $R0, + $K[7] ^ $R1); + } + + /** + * Decrypts a block + * + * @access private + * @param String $in + * @return String + */ + function _decryptBlock($in) + { + $S0 = $this->S0; + $S1 = $this->S1; + $S2 = $this->S2; + $S3 = $this->S3; + $K = $this->K; + + $in = unpack("V4", $in); + $R0 = $K[4] ^ $in[1]; + $R1 = $K[5] ^ $in[2]; + $R2 = $K[6] ^ $in[3]; + $R3 = $K[7] ^ $in[4]; + + $ki = 40; + while ($ki > 8) { + $t0 = $S0[$R0 & 0xff] ^ + $S1[$R0 >> 8 & 0xff] ^ + $S2[$R0 >> 16 & 0xff] ^ + $S3[$R0 >> 24 & 0xff]; + $t1 = $S0[$R1 >> 24 & 0xff] ^ + $S1[$R1 & 0xff] ^ + $S2[$R1 >> 8 & 0xff] ^ + $S3[$R1 >> 16 & 0xff]; + $R3^= $t0 + ($t1 << 1) + $K[--$ki]; + $R3 = $R3 >> 1 & 0x7fffffff | $R3 << 31; + $R2 = ($R2 >> 31 & 0x1 | $R2 << 1) ^ ($t0 + $t1 + $K[--$ki]); + + $t0 = $S0[$R2 & 0xff] ^ + $S1[$R2 >> 8 & 0xff] ^ + $S2[$R2 >> 16 & 0xff] ^ + $S3[$R2 >> 24 & 0xff]; + $t1 = $S0[$R3 >> 24 & 0xff] ^ + $S1[$R3 & 0xff] ^ + $S2[$R3 >> 8 & 0xff] ^ + $S3[$R3 >> 16 & 0xff]; + $R1^= $t0 + ($t1 << 1) + $K[--$ki]; + $R1 = $R1 >> 1 & 0x7fffffff | $R1 << 31; + $R0 = ($R0 >> 31 & 0x1 | $R0 << 1) ^ ($t0 + $t1 + $K[--$ki]); + } + + return pack("V4", $K[0] ^ $R2, + $K[1] ^ $R3, + $K[2] ^ $R0, + $K[3] ^ $R1); + } + + /** + * Setup the performance-optimized function for de/encrypt() + * + * @see Crypt_Base::_setupInlineCrypt() + * @access private + */ + function _setupInlineCrypt() + { + $lambda_functions =& Crypt_Twofish::_getLambdaFunctions(); + + // Max. 10 Ultra-Hi-optimized inline-crypt functions. After that, we'll (still) create very fast code, but not the ultimate fast one. + $gen_hi_opt_code = (bool)( count($lambda_functions) < 10 ); + + switch (true) { + case $gen_hi_opt_code: + $code_hash = md5(str_pad("Crypt_Twofish, {$this->mode}, ", 32, "\0") . $this->key); + break; + default: + $code_hash = "Crypt_Twofish, {$this->mode}"; + } + + if (!isset($lambda_functions[$code_hash])) { + switch (true) { + case $gen_hi_opt_code: + $K = $this->K; + + $init_crypt = ' + static $S0, $S1, $S2, $S3; + if (!$S0) { + for ($i = 0; $i < 256; ++$i) { + $S0[] = (int)$self->S0[$i]; + $S1[] = (int)$self->S1[$i]; + $S2[] = (int)$self->S2[$i]; + $S3[] = (int)$self->S3[$i]; + } + } + '; + break; + default: + $K = array(); + for ($i = 0; $i < 40; ++$i) { + $K[] = '$K_' . $i; + } + + $init_crypt = ' + $S0 = $self->S0; + $S1 = $self->S1; + $S2 = $self->S2; + $S3 = $self->S3; + list(' . implode(',', $K) . ') = $self->K; + '; + } + + // Generating encrypt code: + $encrypt_block = ' + $in = unpack("V4", $in); + $R0 = '.$K[0].' ^ $in[1]; + $R1 = '.$K[1].' ^ $in[2]; + $R2 = '.$K[2].' ^ $in[3]; + $R3 = '.$K[3].' ^ $in[4]; + '; + for ($ki = 7, $i = 0; $i < 8; ++$i) { + $encrypt_block.= ' + $t0 = $S0[ $R0 & 0xff] ^ + $S1[($R0 >> 8) & 0xff] ^ + $S2[($R0 >> 16) & 0xff] ^ + $S3[($R0 >> 24) & 0xff]; + $t1 = $S0[($R1 >> 24) & 0xff] ^ + $S1[ $R1 & 0xff] ^ + $S2[($R1 >> 8) & 0xff] ^ + $S3[($R1 >> 16) & 0xff]; + $R2^= ($t0 + $t1 + '.$K[++$ki].'); + $R2 = ($R2 >> 1 & 0x7fffffff) | ($R2 << 31); + $R3 = ((($R3 >> 31) & 1) | ($R3 << 1)) ^ ($t0 + ($t1 << 1) + '.$K[++$ki].'); + + $t0 = $S0[ $R2 & 0xff] ^ + $S1[($R2 >> 8) & 0xff] ^ + $S2[($R2 >> 16) & 0xff] ^ + $S3[($R2 >> 24) & 0xff]; + $t1 = $S0[($R3 >> 24) & 0xff] ^ + $S1[ $R3 & 0xff] ^ + $S2[($R3 >> 8) & 0xff] ^ + $S3[($R3 >> 16) & 0xff]; + $R0^= ($t0 + $t1 + '.$K[++$ki].'); + $R0 = ($R0 >> 1 & 0x7fffffff) | ($R0 << 31); + $R1 = ((($R1 >> 31) & 1) | ($R1 << 1)) ^ ($t0 + ($t1 << 1) + '.$K[++$ki].'); + '; + } + $encrypt_block.= ' + $in = pack("V4", '.$K[4].' ^ $R2, + '.$K[5].' ^ $R3, + '.$K[6].' ^ $R0, + '.$K[7].' ^ $R1); + '; + + // Generating decrypt code: + $decrypt_block = ' + $in = unpack("V4", $in); + $R0 = '.$K[4].' ^ $in[1]; + $R1 = '.$K[5].' ^ $in[2]; + $R2 = '.$K[6].' ^ $in[3]; + $R3 = '.$K[7].' ^ $in[4]; + '; + for ($ki = 40, $i = 0; $i < 8; ++$i) { + $decrypt_block.= ' + $t0 = $S0[$R0 & 0xff] ^ + $S1[$R0 >> 8 & 0xff] ^ + $S2[$R0 >> 16 & 0xff] ^ + $S3[$R0 >> 24 & 0xff]; + $t1 = $S0[$R1 >> 24 & 0xff] ^ + $S1[$R1 & 0xff] ^ + $S2[$R1 >> 8 & 0xff] ^ + $S3[$R1 >> 16 & 0xff]; + $R3^= $t0 + ($t1 << 1) + '.$K[--$ki].'; + $R3 = $R3 >> 1 & 0x7fffffff | $R3 << 31; + $R2 = ($R2 >> 31 & 0x1 | $R2 << 1) ^ ($t0 + $t1 + '.$K[--$ki].'); + + $t0 = $S0[$R2 & 0xff] ^ + $S1[$R2 >> 8 & 0xff] ^ + $S2[$R2 >> 16 & 0xff] ^ + $S3[$R2 >> 24 & 0xff]; + $t1 = $S0[$R3 >> 24 & 0xff] ^ + $S1[$R3 & 0xff] ^ + $S2[$R3 >> 8 & 0xff] ^ + $S3[$R3 >> 16 & 0xff]; + $R1^= $t0 + ($t1 << 1) + '.$K[--$ki].'; + $R1 = $R1 >> 1 & 0x7fffffff | $R1 << 31; + $R0 = ($R0 >> 31 & 0x1 | $R0 << 1) ^ ($t0 + $t1 + '.$K[--$ki].'); + '; + } + $decrypt_block.= ' + $in = pack("V4", '.$K[0].' ^ $R2, + '.$K[1].' ^ $R3, + '.$K[2].' ^ $R0, + '.$K[3].' ^ $R1); + '; + + $lambda_functions[$code_hash] = $this->_createInlineCryptFunction( + array( + 'init_crypt' => $init_crypt, + 'init_encrypt' => '', + 'init_decrypt' => '', + 'encrypt_block' => $encrypt_block, + 'decrypt_block' => $decrypt_block + ) + ); + } + $this->inline_crypt = $lambda_functions[$code_hash]; + } +} diff --git a/vendor/phpseclib/phpseclib/phpseclib/File/ANSI.php b/vendor/phpseclib/phpseclib/phpseclib/File/ANSI.php new file mode 100755 index 0000000..0e0004c --- /dev/null +++ b/vendor/phpseclib/phpseclib/phpseclib/File/ANSI.php @@ -0,0 +1,560 @@ + + * @copyright MMXII Jim Wigginton + * @license http://www.opensource.org/licenses/mit-license.html MIT License + * @link http://phpseclib.sourceforge.net + */ + +/** + * Pure-PHP ANSI Decoder + * + * @package File_ANSI + * @author Jim Wigginton + * @version 0.3.0 + * @access public + */ +class File_ANSI +{ + /** + * Max Width + * + * @var Integer + * @access private + */ + var $max_x; + + /** + * Max Height + * + * @var Integer + * @access private + */ + var $max_y; + + /** + * Max History + * + * @var Integer + * @access private + */ + var $max_history; + + /** + * History + * + * @var Array + * @access private + */ + var $history; + + /** + * History Attributes + * + * @var Array + * @access private + */ + var $history_attrs; + + /** + * Current Column + * + * @var Integer + * @access private + */ + var $x; + + /** + * Current Row + * + * @var Integer + * @access private + */ + var $y; + + /** + * Old Column + * + * @var Integer + * @access private + */ + var $old_x; + + /** + * Old Row + * + * @var Integer + * @access private + */ + var $old_y; + + /** + * An empty attribute row + * + * @var Array + * @access private + */ + var $attr_row; + + /** + * The current screen text + * + * @var Array + * @access private + */ + var $screen; + + /** + * The current screen attributes + * + * @var Array + * @access private + */ + var $attrs; + + /** + * The current foreground color + * + * @var String + * @access private + */ + var $foreground; + + /** + * The current background color + * + * @var String + * @access private + */ + var $background; + + /** + * Bold flag + * + * @var Boolean + * @access private + */ + var $bold; + + /** + * Underline flag + * + * @var Boolean + * @access private + */ + var $underline; + + /** + * Blink flag + * + * @var Boolean + * @access private + */ + var $blink; + + /** + * Reverse flag + * + * @var Boolean + * @access private + */ + var $reverse; + + /** + * Color flag + * + * @var Boolean + * @access private + */ + var $color; + + /** + * Current ANSI code + * + * @var String + * @access private + */ + var $ansi; + + /** + * Default Constructor. + * + * @return File_ANSI + * @access public + */ + function File_ANSI() + { + $this->setHistory(200); + $this->setDimensions(80, 24); + } + + /** + * Set terminal width and height + * + * Resets the screen as well + * + * @param Integer $x + * @param Integer $y + * @access public + */ + function setDimensions($x, $y) + { + $this->max_x = $x - 1; + $this->max_y = $y - 1; + $this->x = $this->y = 0; + $this->history = $this->history_attrs = array(); + $this->attr_row = array_fill(0, $this->max_x + 1, ''); + $this->screen = array_fill(0, $this->max_y + 1, ''); + $this->attrs = array_fill(0, $this->max_y + 1, $this->attr_row); + $this->foreground = 'white'; + $this->background = 'black'; + $this->bold = false; + $this->underline = false; + $this->blink = false; + $this->reverse = false; + $this->color = false; + + $this->ansi = ''; + } + + /** + * Set the number of lines that should be logged past the terminal height + * + * @param Integer $x + * @param Integer $y + * @access public + */ + function setHistory($history) + { + $this->max_history = $history; + } + + /** + * Load a string + * + * @param String $source + * @access public + */ + function loadString($source) + { + $this->setDimensions($this->max_x + 1, $this->max_y + 1); + $this->appendString($source); + } + + /** + * Appdend a string + * + * @param String $source + * @access public + */ + function appendString($source) + { + for ($i = 0; $i < strlen($source); $i++) { + if (strlen($this->ansi)) { + $this->ansi.= $source[$i]; + $chr = ord($source[$i]); + // http://en.wikipedia.org/wiki/ANSI_escape_code#Sequence_elements + // single character CSI's not currently supported + switch (true) { + case $this->ansi == "\x1B=": + $this->ansi = ''; + continue 2; + case strlen($this->ansi) == 2 && $chr >= 64 && $chr <= 95 && $chr != ord('['): + case strlen($this->ansi) > 2 && $chr >= 64 && $chr <= 126: + break; + default: + continue 2; + } + // http://ascii-table.com/ansi-escape-sequences-vt-100.php + switch ($this->ansi) { + case "\x1B[H": // Move cursor to upper left corner + $this->old_x = $this->x; + $this->old_y = $this->y; + $this->x = $this->y = 0; + break; + case "\x1B[J": // Clear screen from cursor down + $this->history = array_merge($this->history, array_slice(array_splice($this->screen, $this->y + 1), 0, $this->old_y)); + $this->screen = array_merge($this->screen, array_fill($this->y, $this->max_y, '')); + + $this->history_attrs = array_merge($this->history_attrs, array_slice(array_splice($this->attrs, $this->y + 1), 0, $this->old_y)); + $this->attrs = array_merge($this->attrs, array_fill($this->y, $this->max_y, $this->attr_row)); + + if (count($this->history) == $this->max_history) { + array_shift($this->history); + array_shift($this->history_attrs); + } + case "\x1B[K": // Clear screen from cursor right + $this->screen[$this->y] = substr($this->screen[$this->y], 0, $this->x); + + array_splice($this->attrs[$this->y], $this->x + 1); + break; + case "\x1B[2K": // Clear entire line + $this->screen[$this->y] = str_repeat(' ', $this->x); + $this->attrs[$this->y] = $this->attr_row; + break; + case "\x1B[?1h": // set cursor key to application + case "\x1B[?25h": // show the cursor + break; + case "\x1BE": // Move to next line + $this->_newLine(); + $this->x = 0; + break; + default: + switch (true) { + case preg_match('#\x1B\[(\d+);(\d+)H#', $this->ansi, $match): // Move cursor to screen location v,h + $this->old_x = $this->x; + $this->old_y = $this->y; + $this->x = $match[2] - 1; + $this->y = $match[1] - 1; + break; + case preg_match('#\x1B\[(\d+)C#', $this->ansi, $match): // Move cursor right n lines + $this->old_x = $this->x; + $x = $match[1] - 1; + break; + case preg_match('#\x1B\[(\d+);(\d+)r#', $this->ansi, $match): // Set top and bottom lines of a window + break; + case preg_match('#\x1B\[(\d*(?:;\d*)*)m#', $this->ansi, $match): // character attributes + $mods = explode(';', $match[1]); + foreach ($mods as $mod) { + switch ($mod) { + case 0: // Turn off character attributes + $this->attrs[$this->y][$this->x] = ''; + + if ($this->bold) $this->attrs[$this->y][$this->x].= ''; + if ($this->underline) $this->attrs[$this->y][$this->x].= ''; + if ($this->blink) $this->attrs[$this->y][$this->x].= ''; + if ($this->color) $this->attrs[$this->y][$this->x].= ''; + + if ($this->reverse) { + $temp = $this->background; + $this->background = $this->foreground; + $this->foreground = $temp; + } + + $this->bold = $this->underline = $this->blink = $this->color = $this->reverse = false; + break; + case 1: // Turn bold mode on + if (!$this->bold) { + $this->attrs[$this->y][$this->x] = ''; + $this->bold = true; + } + break; + case 4: // Turn underline mode on + if (!$this->underline) { + $this->attrs[$this->y][$this->x] = ''; + $this->underline = true; + } + break; + case 5: // Turn blinking mode on + if (!$this->blink) { + $this->attrs[$this->y][$this->x] = ''; + $this->blink = true; + } + break; + case 7: // Turn reverse video on + $this->reverse = !$this->reverse; + $temp = $this->background; + $this->background = $this->foreground; + $this->foreground = $temp; + $this->attrs[$this->y][$this->x] = ''; + if ($this->color) { + $this->attrs[$this->y][$this->x] = '' . $this->attrs[$this->y][$this->x]; + } + $this->color = true; + break; + default: // set colors + //$front = $this->reverse ? &$this->background : &$this->foreground; + $front = &$this->{ $this->reverse ? 'background' : 'foreground' }; + //$back = $this->reverse ? &$this->foreground : &$this->background; + $back = &$this->{ $this->reverse ? 'foreground' : 'background' }; + switch ($mod) { + case 30: $front = 'black'; break; + case 31: $front = 'red'; break; + case 32: $front = 'green'; break; + case 33: $front = 'yellow'; break; + case 34: $front = 'blue'; break; + case 35: $front = 'magenta'; break; + case 36: $front = 'cyan'; break; + case 37: $front = 'white'; break; + + case 40: $back = 'black'; break; + case 41: $back = 'red'; break; + case 42: $back = 'green'; break; + case 43: $back = 'yellow'; break; + case 44: $back = 'blue'; break; + case 45: $back = 'magenta'; break; + case 46: $back = 'cyan'; break; + case 47: $back = 'white'; break; + + default: + user_error('Unsupported attribute: ' . $mod); + $this->ansi = ''; + break 2; + } + + unset($temp); + $this->attrs[$this->y][$this->x] = ''; + if ($this->color) { + $this->attrs[$this->y][$this->x] = '' . $this->attrs[$this->y][$this->x]; + } + $this->color = true; + } + } + break; + default: + user_error("{$this->ansi} unsupported\r\n"); + } + } + $this->ansi = ''; + continue; + } + + switch ($source[$i]) { + case "\r": + $this->x = 0; + break; + case "\n": + $this->_newLine(); + break; + case "\x0F": // shift + break; + case "\x1B": // start ANSI escape code + $this->ansi.= "\x1B"; + break; + default: + $this->screen[$this->y] = substr_replace( + $this->screen[$this->y], + $source[$i], + $this->x, + 1 + ); + + if ($this->x > $this->max_x) { + $this->x = 0; + $this->y++; + } else { + $this->x++; + } + } + } + } + + /** + * Add a new line + * + * Also update the $this->screen and $this->history buffers + * + * @access private + */ + function _newLine() + { + //if ($this->y < $this->max_y) { + // $this->y++; + //} + + while ($this->y >= $this->max_y) { + $this->history = array_merge($this->history, array(array_shift($this->screen))); + $this->screen[] = ''; + + $this->history_attrs = array_merge($this->history_attrs, array(array_shift($this->attrs))); + $this->attrs[] = $this->attr_row; + + if (count($this->history) >= $this->max_history) { + array_shift($this->history); + array_shift($this->history_attrs); + } + + $this->y--; + } + $this->y++; + } + + /** + * Returns the current screen without preformating + * + * @access private + * @return String + */ + function _getScreen() + { + $output = ''; + for ($i = 0; $i <= $this->max_y; $i++) { + for ($j = 0; $j <= $this->max_x + 1; $j++) { + if (isset($this->attrs[$i][$j])) { + $output.= $this->attrs[$i][$j]; + } + if (isset($this->screen[$i][$j])) { + $output.= htmlspecialchars($this->screen[$i][$j]); + } + } + $output.= "\r\n"; + } + return rtrim($output); + } + + /** + * Returns the current screen + * + * @access public + * @return String + */ + function getScreen() + { + return '
    ' . $this->_getScreen() . '
    '; + } + + /** + * Returns the current screen and the x previous lines + * + * @access public + * @return String + */ + function getHistory() + { + $scrollback = ''; + for ($i = 0; $i < count($this->history); $i++) { + for ($j = 0; $j <= $this->max_x + 1; $j++) { + if (isset($this->history_attrs[$i][$j])) { + $scrollback.= $this->history_attrs[$i][$j]; + } + if (isset($this->history[$i][$j])) { + $scrollback.= htmlspecialchars($this->history[$i][$j]); + } + } + $scrollback.= "\r\n"; + } + $scrollback.= $this->_getScreen(); + + return '
    ' . $scrollback . '
    '; + } +} diff --git a/vendor/phpseclib/phpseclib/phpseclib/File/ASN1.php b/vendor/phpseclib/phpseclib/phpseclib/File/ASN1.php new file mode 100755 index 0000000..67d1f6d --- /dev/null +++ b/vendor/phpseclib/phpseclib/phpseclib/File/ASN1.php @@ -0,0 +1,1319 @@ + + * @copyright MMXII Jim Wigginton + * @license http://www.opensource.org/licenses/mit-license.html MIT License + * @link http://phpseclib.sourceforge.net + */ + +/**#@+ + * Tag Classes + * + * @access private + * @link http://www.itu.int/ITU-T/studygroups/com17/languages/X.690-0207.pdf#page=12 + */ +define('FILE_ASN1_CLASS_UNIVERSAL', 0); +define('FILE_ASN1_CLASS_APPLICATION', 1); +define('FILE_ASN1_CLASS_CONTEXT_SPECIFIC', 2); +define('FILE_ASN1_CLASS_PRIVATE', 3); +/**#@-*/ + +/**#@+ + * Tag Classes + * + * @access private + * @link http://www.obj-sys.com/asn1tutorial/node124.html + */ +define('FILE_ASN1_TYPE_BOOLEAN', 1); +define('FILE_ASN1_TYPE_INTEGER', 2); +define('FILE_ASN1_TYPE_BIT_STRING', 3); +define('FILE_ASN1_TYPE_OCTET_STRING', 4); +define('FILE_ASN1_TYPE_NULL', 5); +define('FILE_ASN1_TYPE_OBJECT_IDENTIFIER', 6); +//define('FILE_ASN1_TYPE_OBJECT_DESCRIPTOR', 7); +//define('FILE_ASN1_TYPE_INSTANCE_OF', 8); // EXTERNAL +define('FILE_ASN1_TYPE_REAL', 9); +define('FILE_ASN1_TYPE_ENUMERATED', 10); +//define('FILE_ASN1_TYPE_EMBEDDED', 11); +define('FILE_ASN1_TYPE_UTF8_STRING', 12); +//define('FILE_ASN1_TYPE_RELATIVE_OID', 13); +define('FILE_ASN1_TYPE_SEQUENCE', 16); // SEQUENCE OF +define('FILE_ASN1_TYPE_SET', 17); // SET OF +/**#@-*/ +/**#@+ + * More Tag Classes + * + * @access private + * @link http://www.obj-sys.com/asn1tutorial/node10.html + */ +define('FILE_ASN1_TYPE_NUMERIC_STRING', 18); +define('FILE_ASN1_TYPE_PRINTABLE_STRING', 19); +define('FILE_ASN1_TYPE_TELETEX_STRING', 20); // T61String +define('FILE_ASN1_TYPE_VIDEOTEX_STRING', 21); +define('FILE_ASN1_TYPE_IA5_STRING', 22); +define('FILE_ASN1_TYPE_UTC_TIME', 23); +define('FILE_ASN1_TYPE_GENERALIZED_TIME', 24); +define('FILE_ASN1_TYPE_GRAPHIC_STRING', 25); +define('FILE_ASN1_TYPE_VISIBLE_STRING', 26); // ISO646String +define('FILE_ASN1_TYPE_GENERAL_STRING', 27); +define('FILE_ASN1_TYPE_UNIVERSAL_STRING', 28); +//define('FILE_ASN1_TYPE_CHARACTER_STRING', 29); +define('FILE_ASN1_TYPE_BMP_STRING', 30); +/**#@-*/ + +/**#@+ + * Tag Aliases + * + * These tags are kinda place holders for other tags. + * + * @access private + */ +define('FILE_ASN1_TYPE_CHOICE', -1); +define('FILE_ASN1_TYPE_ANY', -2); +/**#@-*/ + +/** + * ASN.1 Element + * + * Bypass normal encoding rules in File_ASN1::encodeDER() + * + * @package File_ASN1 + * @author Jim Wigginton + * @version 0.3.0 + * @access public + */ +class File_ASN1_Element +{ + /** + * Raw element value + * + * @var String + * @access private + */ + var $element; + + /** + * Constructor + * + * @param String $encoded + * @return File_ASN1_Element + * @access public + */ + function File_ASN1_Element($encoded) + { + $this->element = $encoded; + } +} + +/** + * Pure-PHP ASN.1 Parser + * + * @package File_ASN1 + * @author Jim Wigginton + * @version 0.3.0 + * @access public + */ +class File_ASN1 +{ + /** + * ASN.1 object identifier + * + * @var Array + * @access private + * @link http://en.wikipedia.org/wiki/Object_identifier + */ + var $oids = array(); + + /** + * Default date format + * + * @var String + * @access private + * @link http://php.net/class.datetime + */ + var $format = 'D, d M y H:i:s O'; + + /** + * Default date format + * + * @var Array + * @access private + * @see File_ASN1::setTimeFormat() + * @see File_ASN1::asn1map() + * @link http://php.net/class.datetime + */ + var $encoded; + + /** + * Filters + * + * If the mapping type is FILE_ASN1_TYPE_ANY what do we actually encode it as? + * + * @var Array + * @access private + * @see File_ASN1::_encode_der() + */ + var $filters; + + /** + * Type mapping table for the ANY type. + * + * Structured or unknown types are mapped to a FILE_ASN1_Element. + * Unambiguous types get the direct mapping (int/real/bool). + * Others are mapped as a choice, with an extra indexing level. + * + * @var Array + * @access public + */ + var $ANYmap = array( + FILE_ASN1_TYPE_BOOLEAN => true, + FILE_ASN1_TYPE_INTEGER => true, + FILE_ASN1_TYPE_BIT_STRING => 'bitString', + FILE_ASN1_TYPE_OCTET_STRING => 'octetString', + FILE_ASN1_TYPE_NULL => 'null', + FILE_ASN1_TYPE_OBJECT_IDENTIFIER => 'objectIdentifier', + FILE_ASN1_TYPE_REAL => true, + FILE_ASN1_TYPE_ENUMERATED => 'enumerated', + FILE_ASN1_TYPE_UTF8_STRING => 'utf8String', + FILE_ASN1_TYPE_NUMERIC_STRING => 'numericString', + FILE_ASN1_TYPE_PRINTABLE_STRING => 'printableString', + FILE_ASN1_TYPE_TELETEX_STRING => 'teletexString', + FILE_ASN1_TYPE_VIDEOTEX_STRING => 'videotexString', + FILE_ASN1_TYPE_IA5_STRING => 'ia5String', + FILE_ASN1_TYPE_UTC_TIME => 'utcTime', + FILE_ASN1_TYPE_GENERALIZED_TIME => 'generalTime', + FILE_ASN1_TYPE_GRAPHIC_STRING => 'graphicString', + FILE_ASN1_TYPE_VISIBLE_STRING => 'visibleString', + FILE_ASN1_TYPE_GENERAL_STRING => 'generalString', + FILE_ASN1_TYPE_UNIVERSAL_STRING => 'universalString', + //FILE_ASN1_TYPE_CHARACTER_STRING => 'characterString', + FILE_ASN1_TYPE_BMP_STRING => 'bmpString' + ); + + /** + * String type to character size mapping table. + * + * Non-convertable types are absent from this table. + * size == 0 indicates variable length encoding. + * + * @var Array + * @access public + */ + var $stringTypeSize = array( + FILE_ASN1_TYPE_UTF8_STRING => 0, + FILE_ASN1_TYPE_BMP_STRING => 2, + FILE_ASN1_TYPE_UNIVERSAL_STRING => 4, + FILE_ASN1_TYPE_PRINTABLE_STRING => 1, + FILE_ASN1_TYPE_TELETEX_STRING => 1, + FILE_ASN1_TYPE_IA5_STRING => 1, + FILE_ASN1_TYPE_VISIBLE_STRING => 1, + ); + + /** + * Default Constructor. + * + * @access public + */ + function File_ASN1() + { + static $static_init = null; + if (!$static_init) { + $static_init = true; + if (!class_exists('Math_BigInteger')) { + include_once 'Math/BigInteger.php'; + } + } + } + + /** + * Parse BER-encoding + * + * Serves a similar purpose to openssl's asn1parse + * + * @param String $encoded + * @return Array + * @access public + */ + function decodeBER($encoded) + { + if (is_object($encoded) && strtolower(get_class($encoded)) == 'file_asn1_element') { + $encoded = $encoded->element; + } + + $this->encoded = $encoded; + return $this->_decode_ber($encoded); + } + + /** + * Parse BER-encoding (Helper function) + * + * Sometimes we want to get the BER encoding of a particular tag. $start lets us do that without having to reencode. + * $encoded is passed by reference for the recursive calls done for FILE_ASN1_TYPE_BIT_STRING and + * FILE_ASN1_TYPE_OCTET_STRING. In those cases, the indefinite length is used. + * + * @param String $encoded + * @param Integer $start + * @return Array + * @access private + */ + function _decode_ber(&$encoded, $start = 0) + { + $decoded = array(); + + while ( strlen($encoded) ) { + $current = array('start' => $start); + + $type = ord($this->_string_shift($encoded)); + $start++; + + $constructed = ($type >> 5) & 1; + + $tag = $type & 0x1F; + if ($tag == 0x1F) { + $tag = 0; + // process septets (since the eighth bit is ignored, it's not an octet) + do { + $loop = ord($encoded[0]) >> 7; + $tag <<= 7; + $tag |= ord($this->_string_shift($encoded)) & 0x7F; + $start++; + } while ( $loop ); + } + + // Length, as discussed in paragraph 8.1.3 of X.690-0207.pdf#page=13 + $length = ord($this->_string_shift($encoded)); + $start++; + if ( $length == 0x80 ) { // indefinite length + // "[A sender shall] use the indefinite form (see 8.1.3.6) if the encoding is constructed and is not all + // immediately available." -- paragraph 8.1.3.2.c + //if ( !$constructed ) { + // return false; + //} + $length = strlen($encoded); + } elseif ( $length & 0x80 ) { // definite length, long form + // technically, the long form of the length can be represented by up to 126 octets (bytes), but we'll only + // support it up to four. + $length&= 0x7F; + $temp = $this->_string_shift($encoded, $length); + // tags of indefinite length don't really have a header length; this length includes the tag + $current+= array('headerlength' => $length + 2); + $start+= $length; + extract(unpack('Nlength', substr(str_pad($temp, 4, chr(0), STR_PAD_LEFT), -4))); + } else { + $current+= array('headerlength' => 2); + } + + // End-of-content, see paragraphs 8.1.1.3, 8.1.3.2, 8.1.3.6, 8.1.5, and (for an example) 8.6.4.2 + if (!$type && !$length) { + return $decoded; + } + $content = $this->_string_shift($encoded, $length); + + /* Class is UNIVERSAL, APPLICATION, PRIVATE, or CONTEXT-SPECIFIC. The UNIVERSAL class is restricted to the ASN.1 + built-in types. It defines an application-independent data type that must be distinguishable from all other + data types. The other three classes are user defined. The APPLICATION class distinguishes data types that + have a wide, scattered use within a particular presentation context. PRIVATE distinguishes data types within + a particular organization or country. CONTEXT-SPECIFIC distinguishes members of a sequence or set, the + alternatives of a CHOICE, or universally tagged set members. Only the class number appears in braces for this + data type; the term CONTEXT-SPECIFIC does not appear. + + -- http://www.obj-sys.com/asn1tutorial/node12.html */ + $class = ($type >> 6) & 3; + switch ($class) { + case FILE_ASN1_CLASS_APPLICATION: + case FILE_ASN1_CLASS_PRIVATE: + case FILE_ASN1_CLASS_CONTEXT_SPECIFIC: + $decoded[] = array( + 'type' => $class, + 'constant' => $tag, + 'content' => $constructed ? $this->_decode_ber($content, $start) : $content, + 'length' => $length + $start - $current['start'] + ) + $current; + $start+= $length; + continue 2; + } + + $current+= array('type' => $tag); + + // decode UNIVERSAL tags + switch ($tag) { + case FILE_ASN1_TYPE_BOOLEAN: + // "The contents octets shall consist of a single octet." -- paragraph 8.2.1 + //if (strlen($content) != 1) { + // return false; + //} + $current['content'] = (bool) ord($content[0]); + break; + case FILE_ASN1_TYPE_INTEGER: + case FILE_ASN1_TYPE_ENUMERATED: + $current['content'] = new Math_BigInteger($content, -256); + break; + case FILE_ASN1_TYPE_REAL: // not currently supported + return false; + case FILE_ASN1_TYPE_BIT_STRING: + // The initial octet shall encode, as an unsigned binary integer with bit 1 as the least significant bit, + // the number of unused bits in the final subsequent octet. The number shall be in the range zero to + // seven. + if (!$constructed) { + $current['content'] = $content; + } else { + $temp = $this->_decode_ber($content, $start); + $length-= strlen($content); + $last = count($temp) - 1; + for ($i = 0; $i < $last; $i++) { + // all subtags should be bit strings + //if ($temp[$i]['type'] != FILE_ASN1_TYPE_BIT_STRING) { + // return false; + //} + $current['content'].= substr($temp[$i]['content'], 1); + } + // all subtags should be bit strings + //if ($temp[$last]['type'] != FILE_ASN1_TYPE_BIT_STRING) { + // return false; + //} + $current['content'] = $temp[$last]['content'][0] . $current['content'] . substr($temp[$i]['content'], 1); + } + break; + case FILE_ASN1_TYPE_OCTET_STRING: + if (!$constructed) { + $current['content'] = $content; + } else { + $temp = $this->_decode_ber($content, $start); + $length-= strlen($content); + for ($i = 0, $size = count($temp); $i < $size; $i++) { + // all subtags should be octet strings + //if ($temp[$i]['type'] != FILE_ASN1_TYPE_OCTET_STRING) { + // return false; + //} + $current['content'].= $temp[$i]['content']; + } + // $length = + } + break; + case FILE_ASN1_TYPE_NULL: + // "The contents octets shall not contain any octets." -- paragraph 8.8.2 + //if (strlen($content)) { + // return false; + //} + break; + case FILE_ASN1_TYPE_SEQUENCE: + case FILE_ASN1_TYPE_SET: + $current['content'] = $this->_decode_ber($content, $start); + break; + case FILE_ASN1_TYPE_OBJECT_IDENTIFIER: + $temp = ord($this->_string_shift($content)); + $current['content'] = sprintf('%d.%d', floor($temp / 40), $temp % 40); + $valuen = 0; + // process septets + while (strlen($content)) { + $temp = ord($this->_string_shift($content)); + $valuen <<= 7; + $valuen |= $temp & 0x7F; + if (~$temp & 0x80) { + $current['content'].= ".$valuen"; + $valuen = 0; + } + } + // the eighth bit of the last byte should not be 1 + //if ($temp >> 7) { + // return false; + //} + break; + /* Each character string type shall be encoded as if it had been declared: + [UNIVERSAL x] IMPLICIT OCTET STRING + + -- X.690-0207.pdf#page=23 (paragraph 8.21.3) + + Per that, we're not going to do any validation. If there are any illegal characters in the string, + we don't really care */ + case FILE_ASN1_TYPE_NUMERIC_STRING: + // 0,1,2,3,4,5,6,7,8,9, and space + case FILE_ASN1_TYPE_PRINTABLE_STRING: + // Upper and lower case letters, digits, space, apostrophe, left/right parenthesis, plus sign, comma, + // hyphen, full stop, solidus, colon, equal sign, question mark + case FILE_ASN1_TYPE_TELETEX_STRING: + // The Teletex character set in CCITT's T61, space, and delete + // see http://en.wikipedia.org/wiki/Teletex#Character_sets + case FILE_ASN1_TYPE_VIDEOTEX_STRING: + // The Videotex character set in CCITT's T.100 and T.101, space, and delete + case FILE_ASN1_TYPE_VISIBLE_STRING: + // Printing character sets of international ASCII, and space + case FILE_ASN1_TYPE_IA5_STRING: + // International Alphabet 5 (International ASCII) + case FILE_ASN1_TYPE_GRAPHIC_STRING: + // All registered G sets, and space + case FILE_ASN1_TYPE_GENERAL_STRING: + // All registered C and G sets, space and delete + case FILE_ASN1_TYPE_UTF8_STRING: + // ???? + case FILE_ASN1_TYPE_BMP_STRING: + $current['content'] = $content; + break; + case FILE_ASN1_TYPE_UTC_TIME: + case FILE_ASN1_TYPE_GENERALIZED_TIME: + $current['content'] = $this->_decodeTime($content, $tag); + default: + + } + + $start+= $length; + $decoded[] = $current + array('length' => $start - $current['start']); + } + + return $decoded; + } + + /** + * ASN.1 Decode + * + * Provides an ASN.1 semantic mapping ($mapping) from a parsed BER-encoding to a human readable format. + * + * "Special" mappings may be applied on a per tag-name basis via $special. + * + * @param Array $decoded + * @param Array $mapping + * @param Array $special + * @return Array + * @access public + */ + function asn1map($decoded, $mapping, $special = array()) + { + if (isset($mapping['explicit'])) { + $decoded = $decoded['content'][0]; + } + + switch (true) { + case $mapping['type'] == FILE_ASN1_TYPE_ANY: + $intype = $decoded['type']; + if (isset($decoded['constant']) || !isset($this->ANYmap[$intype]) || ($this->encoded[$decoded['start']] & 0x20)) { + return new File_ASN1_Element(substr($this->encoded, $decoded['start'], $decoded['length'])); + } + $inmap = $this->ANYmap[$intype]; + if (is_string($inmap)) { + return array($inmap => $this->asn1map($decoded, array('type' => $intype) + $mapping, $special)); + } + break; + case $mapping['type'] == FILE_ASN1_TYPE_CHOICE: + foreach ($mapping['children'] as $key => $option) { + switch (true) { + case isset($option['constant']) && $option['constant'] == $decoded['constant']: + case !isset($option['constant']) && $option['type'] == $decoded['type']: + $value = $this->asn1map($decoded, $option, $special); + break; + case !isset($option['constant']) && $option['type'] == FILE_ASN1_TYPE_CHOICE: + $v = $this->asn1map($decoded, $option, $special); + if (isset($v)) { + $value = $v; + } + } + if (isset($value)) { + if (isset($special[$key])) { + $value = call_user_func($special[$key], $value); + } + return array($key => $value); + } + } + return null; + case isset($mapping['implicit']): + case isset($mapping['explicit']): + case $decoded['type'] == $mapping['type']: + break; + default: + return null; + } + + if (isset($mapping['implicit'])) { + $decoded['type'] = $mapping['type']; + } + + switch ($decoded['type']) { + case FILE_ASN1_TYPE_SEQUENCE: + $map = array(); + + // ignore the min and max + if (isset($mapping['min']) && isset($mapping['max'])) { + $child = $mapping['children']; + foreach ($decoded['content'] as $content) { + if (($map[] = $this->asn1map($content, $child, $special)) === null) { + return null; + } + } + + return $map; + } + + $n = count($decoded['content']); + $i = 0; + + foreach ($mapping['children'] as $key => $child) { + $maymatch = $i < $n; // Match only existing input. + if ($maymatch) { + $temp = $decoded['content'][$i]; + + if ($child['type'] != FILE_ASN1_TYPE_CHOICE) { + // Get the mapping and input class & constant. + $childClass = $tempClass = FILE_ASN1_CLASS_UNIVERSAL; + $constant = null; + if (isset($temp['constant'])) { + $tempClass = isset($temp['class']) ? $temp['class'] : FILE_ASN1_CLASS_CONTEXT_SPECIFIC; + } + if (isset($child['class'])) { + $childClass = $child['class']; + $constant = $child['cast']; + } elseif (isset($child['constant'])) { + $childClass = FILE_ASN1_CLASS_CONTEXT_SPECIFIC; + $constant = $child['constant']; + } + + if (isset($constant) && isset($temp['constant'])) { + // Can only match if constants and class match. + $maymatch = $constant == $temp['constant'] && $childClass == $tempClass; + } else { + // Can only match if no constant expected and type matches or is generic. + $maymatch = !isset($child['constant']) && array_search($child['type'], array($temp['type'], FILE_ASN1_TYPE_ANY, FILE_ASN1_TYPE_CHOICE)) !== false; + } + } + } + + if ($maymatch) { + // Attempt submapping. + $candidate = $this->asn1map($temp, $child, $special); + $maymatch = $candidate !== null; + } + + if ($maymatch) { + // Got the match: use it. + if (isset($special[$key])) { + $candidate = call_user_func($special[$key], $candidate); + } + $map[$key] = $candidate; + $i++; + } elseif (isset($child['default'])) { + $map[$key] = $child['default']; // Use default. + } elseif (!isset($child['optional'])) { + return null; // Syntax error. + } + } + + // Fail mapping if all input items have not been consumed. + return $i < $n? null: $map; + + // the main diff between sets and sequences is the encapsulation of the foreach in another for loop + case FILE_ASN1_TYPE_SET: + $map = array(); + + // ignore the min and max + if (isset($mapping['min']) && isset($mapping['max'])) { + $child = $mapping['children']; + foreach ($decoded['content'] as $content) { + if (($map[] = $this->asn1map($content, $child, $special)) === null) { + return null; + } + } + + return $map; + } + + for ($i = 0; $i < count($decoded['content']); $i++) { + $temp = $decoded['content'][$i]; + $tempClass = FILE_ASN1_CLASS_UNIVERSAL; + if (isset($temp['constant'])) { + $tempClass = isset($temp['class']) ? $temp['class'] : FILE_ASN1_CLASS_CONTEXT_SPECIFIC; + } + + foreach ($mapping['children'] as $key => $child) { + if (isset($map[$key])) { + continue; + } + $maymatch = true; + if ($child['type'] != FILE_ASN1_TYPE_CHOICE) { + $childClass = FILE_ASN1_CLASS_UNIVERSAL; + $constant = null; + if (isset($child['class'])) { + $childClass = $child['class']; + $constant = $child['cast']; + } elseif (isset($child['constant'])) { + $childClass = FILE_ASN1_CLASS_CONTEXT_SPECIFIC; + $constant = $child['constant']; + } + + if (isset($constant) && isset($temp['constant'])) { + // Can only match if constants and class match. + $maymatch = $constant == $temp['constant'] && $childClass == $tempClass; + } else { + // Can only match if no constant expected and type matches or is generic. + $maymatch = !isset($child['constant']) && array_search($child['type'], array($temp['type'], FILE_ASN1_TYPE_ANY, FILE_ASN1_TYPE_CHOICE)) !== false; + } + } + + if ($maymatch) { + // Attempt submapping. + $candidate = $this->asn1map($temp, $child, $special); + $maymatch = $candidate !== null; + } + + if (!$maymatch) { + break; + } + + // Got the match: use it. + if (isset($special[$key])) { + $candidate = call_user_func($special[$key], $candidate); + } + $map[$key] = $candidate; + break; + } + } + + foreach ($mapping['children'] as $key => $child) { + if (!isset($map[$key])) { + if (isset($child['default'])) { + $map[$key] = $child['default']; + } elseif (!isset($child['optional'])) { + return null; + } + } + } + return $map; + case FILE_ASN1_TYPE_OBJECT_IDENTIFIER: + return isset($this->oids[$decoded['content']]) ? $this->oids[$decoded['content']] : $decoded['content']; + case FILE_ASN1_TYPE_UTC_TIME: + case FILE_ASN1_TYPE_GENERALIZED_TIME: + if (isset($mapping['implicit'])) { + $decoded['content'] = $this->_decodeTime($decoded['content'], $decoded['type']); + } + return @date($this->format, $decoded['content']); + case FILE_ASN1_TYPE_BIT_STRING: + if (isset($mapping['mapping'])) { + $offset = ord($decoded['content'][0]); + $size = (strlen($decoded['content']) - 1) * 8 - $offset; + /* + From X.680-0207.pdf#page=46 (21.7): + + "When a "NamedBitList" is used in defining a bitstring type ASN.1 encoding rules are free to add (or remove) + arbitrarily any trailing 0 bits to (or from) values that are being encoded or decoded. Application designers should + therefore ensure that different semantics are not associated with such values which differ only in the number of trailing + 0 bits." + */ + $bits = count($mapping['mapping']) == $size ? array() : array_fill(0, count($mapping['mapping']) - $size, false); + for ($i = strlen($decoded['content']) - 1; $i > 0; $i--) { + $current = ord($decoded['content'][$i]); + for ($j = $offset; $j < 8; $j++) { + $bits[] = (bool) ($current & (1 << $j)); + } + $offset = 0; + } + $values = array(); + $map = array_reverse($mapping['mapping']); + foreach ($map as $i => $value) { + if ($bits[$i]) { + $values[] = $value; + } + } + return $values; + } + case FILE_ASN1_TYPE_OCTET_STRING: + return base64_encode($decoded['content']); + case FILE_ASN1_TYPE_NULL: + return ''; + case FILE_ASN1_TYPE_BOOLEAN: + return $decoded['content']; + case FILE_ASN1_TYPE_NUMERIC_STRING: + case FILE_ASN1_TYPE_PRINTABLE_STRING: + case FILE_ASN1_TYPE_TELETEX_STRING: + case FILE_ASN1_TYPE_VIDEOTEX_STRING: + case FILE_ASN1_TYPE_IA5_STRING: + case FILE_ASN1_TYPE_GRAPHIC_STRING: + case FILE_ASN1_TYPE_VISIBLE_STRING: + case FILE_ASN1_TYPE_GENERAL_STRING: + case FILE_ASN1_TYPE_UNIVERSAL_STRING: + case FILE_ASN1_TYPE_UTF8_STRING: + case FILE_ASN1_TYPE_BMP_STRING: + return $decoded['content']; + case FILE_ASN1_TYPE_INTEGER: + case FILE_ASN1_TYPE_ENUMERATED: + $temp = $decoded['content']; + if (isset($mapping['implicit'])) { + $temp = new Math_BigInteger($decoded['content'], -256); + } + if (isset($mapping['mapping'])) { + $temp = (int) $temp->toString(); + return isset($mapping['mapping'][$temp]) ? + $mapping['mapping'][$temp] : + false; + } + return $temp; + } + } + + /** + * ASN.1 Encode + * + * DER-encodes an ASN.1 semantic mapping ($mapping). Some libraries would probably call this function + * an ASN.1 compiler. + * + * "Special" mappings can be applied via $special. + * + * @param String $source + * @param String $mapping + * @param Integer $idx + * @return String + * @access public + */ + function encodeDER($source, $mapping, $special = array()) + { + $this->location = array(); + return $this->_encode_der($source, $mapping, null, $special); + } + + /** + * ASN.1 Encode (Helper function) + * + * @param String $source + * @param Array $mapping + * @param Integer $idx + * @param Array $special + * @return String + * @access private + */ + /** + * ASN.1 Encode (Helper function) + * + * @param String $source + * @param String $mapping + * @param Integer $idx + * @return String + * @access private + */ + function _encode_der($source, $mapping, $idx = null, $special = array()) + { + if (is_object($source) && strtolower(get_class($source)) == 'file_asn1_element') { + return $source->element; + } + + // do not encode (implicitly optional) fields with value set to default + if (isset($mapping['default']) && $source === $mapping['default']) { + return ''; + } + + if (isset($idx)) { + if (isset($special[$idx])) { + $source = call_user_func($special[$idx], $source); + } + $this->location[] = $idx; + } + + $tag = $mapping['type']; + + switch ($tag) { + case FILE_ASN1_TYPE_SET: // Children order is not important, thus process in sequence. + case FILE_ASN1_TYPE_SEQUENCE: + $tag|= 0x20; // set the constructed bit + $value = ''; + + // ignore the min and max + if (isset($mapping['min']) && isset($mapping['max'])) { + $child = $mapping['children']; + + foreach ($source as $content) { + $temp = $this->_encode_der($content, $child, null, $special); + if ($temp === false) { + return false; + } + $value.= $temp; + } + break; + } + + foreach ($mapping['children'] as $key => $child) { + if (!isset($source[$key])) { + if (!isset($child['optional'])) { + return false; + } + continue; + } + + $temp = $this->_encode_der($source[$key], $child, $key, $special); + if ($temp === false) { + return false; + } + + // An empty child encoding means it has been optimized out. + // Else we should have at least one tag byte. + if ($temp === '') { + continue; + } + + // if isset($child['constant']) is true then isset($child['optional']) should be true as well + if (isset($child['constant'])) { + /* + From X.680-0207.pdf#page=58 (30.6): + + "The tagging construction specifies explicit tagging if any of the following holds: + ... + c) the "Tag Type" alternative is used and the value of "TagDefault" for the module is IMPLICIT TAGS or + AUTOMATIC TAGS, but the type defined by "Type" is an untagged choice type, an untagged open type, or + an untagged "DummyReference" (see ITU-T Rec. X.683 | ISO/IEC 8824-4, 8.3)." + */ + if (isset($child['explicit']) || $child['type'] == FILE_ASN1_TYPE_CHOICE) { + $subtag = chr((FILE_ASN1_CLASS_CONTEXT_SPECIFIC << 6) | 0x20 | $child['constant']); + $temp = $subtag . $this->_encodeLength(strlen($temp)) . $temp; + } else { + $subtag = chr((FILE_ASN1_CLASS_CONTEXT_SPECIFIC << 6) | (ord($temp[0]) & 0x20) | $child['constant']); + $temp = $subtag . substr($temp, 1); + } + } + $value.= $temp; + } + break; + case FILE_ASN1_TYPE_CHOICE: + $temp = false; + + foreach ($mapping['children'] as $key => $child) { + if (!isset($source[$key])) { + continue; + } + + $temp = $this->_encode_der($source[$key], $child, $key, $special); + if ($temp === false) { + return false; + } + + // An empty child encoding means it has been optimized out. + // Else we should have at least one tag byte. + if ($temp === '') { + continue; + } + + $tag = ord($temp[0]); + + // if isset($child['constant']) is true then isset($child['optional']) should be true as well + if (isset($child['constant'])) { + if (isset($child['explicit']) || $child['type'] == FILE_ASN1_TYPE_CHOICE) { + $subtag = chr((FILE_ASN1_CLASS_CONTEXT_SPECIFIC << 6) | 0x20 | $child['constant']); + $temp = $subtag . $this->_encodeLength(strlen($temp)) . $temp; + } else { + $subtag = chr((FILE_ASN1_CLASS_CONTEXT_SPECIFIC << 6) | (ord($temp[0]) & 0x20) | $child['constant']); + $temp = $subtag . substr($temp, 1); + } + } + } + + if (isset($idx)) { + array_pop($this->location); + } + + if ($temp && isset($mapping['cast'])) { + $temp[0] = chr(($mapping['class'] << 6) | ($tag & 0x20) | $mapping['cast']); + } + + return $temp; + case FILE_ASN1_TYPE_INTEGER: + case FILE_ASN1_TYPE_ENUMERATED: + if (!isset($mapping['mapping'])) { + $value = $source->toBytes(true); + } else { + $value = array_search($source, $mapping['mapping']); + if ($value === false) { + return false; + } + $value = new Math_BigInteger($value); + $value = $value->toBytes(true); + } + if (!strlen($value)) { + $value = chr(0); + } + break; + case FILE_ASN1_TYPE_UTC_TIME: + case FILE_ASN1_TYPE_GENERALIZED_TIME: + $format = $mapping['type'] == FILE_ASN1_TYPE_UTC_TIME ? 'y' : 'Y'; + $format.= 'mdHis'; + $value = @gmdate($format, strtotime($source)) . 'Z'; + break; + case FILE_ASN1_TYPE_BIT_STRING: + if (isset($mapping['mapping'])) { + $bits = array_fill(0, count($mapping['mapping']), 0); + $size = 0; + for ($i = 0; $i < count($mapping['mapping']); $i++) { + if (in_array($mapping['mapping'][$i], $source)) { + $bits[$i] = 1; + $size = $i; + } + } + + $offset = 8 - (($size + 1) & 7); + $offset = $offset !== 8 ? $offset : 0; + + $value = chr($offset); + + for ($i = $size + 1; $i < count($mapping['mapping']); $i++) { + unset($bits[$i]); + } + + $bits = implode('', array_pad($bits, $size + $offset + 1, 0)); + $bytes = explode(' ', rtrim(chunk_split($bits, 8, ' '))); + foreach ($bytes as $byte) { + $value.= chr(bindec($byte)); + } + + break; + } + case FILE_ASN1_TYPE_OCTET_STRING: + /* The initial octet shall encode, as an unsigned binary integer with bit 1 as the least significant bit, + the number of unused bits in the final subsequent octet. The number shall be in the range zero to seven. + + -- http://www.itu.int/ITU-T/studygroups/com17/languages/X.690-0207.pdf#page=16 */ + $value = base64_decode($source); + break; + case FILE_ASN1_TYPE_OBJECT_IDENTIFIER: + $oid = preg_match('#(?:\d+\.)+#', $source) ? $source : array_search($source, $this->oids); + if ($oid === false) { + user_error('Invalid OID'); + return false; + } + $value = ''; + $parts = explode('.', $oid); + $value = chr(40 * $parts[0] + $parts[1]); + for ($i = 2; $i < count($parts); $i++) { + $temp = ''; + if (!$parts[$i]) { + $temp = "\0"; + } else { + while ($parts[$i]) { + $temp = chr(0x80 | ($parts[$i] & 0x7F)) . $temp; + $parts[$i] >>= 7; + } + $temp[strlen($temp) - 1] = $temp[strlen($temp) - 1] & chr(0x7F); + } + $value.= $temp; + } + break; + case FILE_ASN1_TYPE_ANY: + $loc = $this->location; + if (isset($idx)) { + array_pop($this->location); + } + + switch (true) { + case !isset($source): + return $this->_encode_der(null, array('type' => FILE_ASN1_TYPE_NULL) + $mapping, null, $special); + case is_int($source): + case is_object($source) && strtolower(get_class($source)) == 'math_biginteger': + return $this->_encode_der($source, array('type' => FILE_ASN1_TYPE_INTEGER) + $mapping, null, $special); + case is_float($source): + return $this->_encode_der($source, array('type' => FILE_ASN1_TYPE_REAL) + $mapping, null, $special); + case is_bool($source): + return $this->_encode_der($source, array('type' => FILE_ASN1_TYPE_BOOLEAN) + $mapping, null, $special); + case is_array($source) && count($source) == 1: + $typename = implode('', array_keys($source)); + $outtype = array_search($typename, $this->ANYmap, true); + if ($outtype !== false) { + return $this->_encode_der($source[$typename], array('type' => $outtype) + $mapping, null, $special); + } + } + + $filters = $this->filters; + foreach ($loc as $part) { + if (!isset($filters[$part])) { + $filters = false; + break; + } + $filters = $filters[$part]; + } + if ($filters === false) { + user_error('No filters defined for ' . implode('/', $loc)); + return false; + } + return $this->_encode_der($source, $filters + $mapping, null, $special); + case FILE_ASN1_TYPE_NULL: + $value = ''; + break; + case FILE_ASN1_TYPE_NUMERIC_STRING: + case FILE_ASN1_TYPE_TELETEX_STRING: + case FILE_ASN1_TYPE_PRINTABLE_STRING: + case FILE_ASN1_TYPE_UNIVERSAL_STRING: + case FILE_ASN1_TYPE_UTF8_STRING: + case FILE_ASN1_TYPE_BMP_STRING: + case FILE_ASN1_TYPE_IA5_STRING: + case FILE_ASN1_TYPE_VISIBLE_STRING: + case FILE_ASN1_TYPE_VIDEOTEX_STRING: + case FILE_ASN1_TYPE_GRAPHIC_STRING: + case FILE_ASN1_TYPE_GENERAL_STRING: + $value = $source; + break; + case FILE_ASN1_TYPE_BOOLEAN: + $value = $source ? "\xFF" : "\x00"; + break; + default: + user_error('Mapping provides no type definition for ' . implode('/', $this->location)); + return false; + } + + if (isset($idx)) { + array_pop($this->location); + } + + if (isset($mapping['cast'])) { + $tag = ($mapping['class'] << 6) | ($tag & 0x20) | $mapping['cast']; + } + + return chr($tag) . $this->_encodeLength(strlen($value)) . $value; + } + + /** + * DER-encode the length + * + * DER supports lengths up to (2**8)**127, however, we'll only support lengths up to (2**8)**4. See + * {@link http://itu.int/ITU-T/studygroups/com17/languages/X.690-0207.pdf#p=13 X.690 paragraph 8.1.3} for more information. + * + * @access private + * @param Integer $length + * @return String + */ + function _encodeLength($length) + { + if ($length <= 0x7F) { + return chr($length); + } + + $temp = ltrim(pack('N', $length), chr(0)); + return pack('Ca*', 0x80 | strlen($temp), $temp); + } + + /** + * BER-decode the time + * + * Called by _decode_ber() and in the case of implicit tags asn1map(). + * + * @access private + * @param String $content + * @param Integer $tag + * @return String + */ + function _decodeTime($content, $tag) + { + /* UTCTime: + http://tools.ietf.org/html/rfc5280#section-4.1.2.5.1 + http://www.obj-sys.com/asn1tutorial/node15.html + + GeneralizedTime: + http://tools.ietf.org/html/rfc5280#section-4.1.2.5.2 + http://www.obj-sys.com/asn1tutorial/node14.html */ + + $pattern = $tag == FILE_ASN1_TYPE_UTC_TIME ? + '#(..)(..)(..)(..)(..)(..)(.*)#' : + '#(....)(..)(..)(..)(..)(..).*([Z+-].*)$#'; + + preg_match($pattern, $content, $matches); + + list(, $year, $month, $day, $hour, $minute, $second, $timezone) = $matches; + + if ($tag == FILE_ASN1_TYPE_UTC_TIME) { + $year = $year >= 50 ? "19$year" : "20$year"; + } + + if ($timezone == 'Z') { + $mktime = 'gmmktime'; + $timezone = 0; + } elseif (preg_match('#([+-])(\d\d)(\d\d)#', $timezone, $matches)) { + $mktime = 'gmmktime'; + $timezone = 60 * $matches[3] + 3600 * $matches[2]; + if ($matches[1] == '-') { + $timezone = -$timezone; + } + } else { + $mktime = 'mktime'; + $timezone = 0; + } + + return @$mktime($hour, $minute, $second, $month, $day, $year) + $timezone; + } + + /** + * Set the time format + * + * Sets the time / date format for asn1map(). + * + * @access public + * @param String $format + */ + function setTimeFormat($format) + { + $this->format = $format; + } + + /** + * Load OIDs + * + * Load the relevant OIDs for a particular ASN.1 semantic mapping. + * + * @access public + * @param Array $oids + */ + function loadOIDs($oids) + { + $this->oids = $oids; + } + + /** + * Load filters + * + * See File_X509, etc, for an example. + * + * @access public + * @param Array $filters + */ + function loadFilters($filters) + { + $this->filters = $filters; + } + + /** + * String Shift + * + * Inspired by array_shift + * + * @param String $string + * @param optional Integer $index + * @return String + * @access private + */ + function _string_shift(&$string, $index = 1) + { + $substr = substr($string, 0, $index); + $string = substr($string, $index); + return $substr; + } + + /** + * String type conversion + * + * This is a lazy conversion, dealing only with character size. + * No real conversion table is used. + * + * @param String $in + * @param optional Integer $from + * @param optional Integer $to + * @return String + * @access public + */ + function convert($in, $from = FILE_ASN1_TYPE_UTF8_STRING, $to = FILE_ASN1_TYPE_UTF8_STRING) + { + if (!isset($this->stringTypeSize[$from]) || !isset($this->stringTypeSize[$to])) { + return false; + } + $insize = $this->stringTypeSize[$from]; + $outsize = $this->stringTypeSize[$to]; + $inlength = strlen($in); + $out = ''; + + for ($i = 0; $i < $inlength;) { + if ($inlength - $i < $insize) { + return false; + } + + // Get an input character as a 32-bit value. + $c = ord($in[$i++]); + switch (true) { + case $insize == 4: + $c = ($c << 8) | ord($in[$i++]); + $c = ($c << 8) | ord($in[$i++]); + case $insize == 2: + $c = ($c << 8) | ord($in[$i++]); + case $insize == 1: + break; + case ($c & 0x80) == 0x00: + break; + case ($c & 0x40) == 0x00: + return false; + default: + $bit = 6; + do { + if ($bit > 25 || $i >= $inlength || (ord($in[$i]) & 0xC0) != 0x80) { + return false; + } + $c = ($c << 6) | (ord($in[$i++]) & 0x3F); + $bit += 5; + $mask = 1 << $bit; + } while ($c & $bit); + $c &= $mask - 1; + break; + } + + // Convert and append the character to output string. + $v = ''; + switch (true) { + case $outsize == 4: + $v .= chr($c & 0xFF); + $c >>= 8; + $v .= chr($c & 0xFF); + $c >>= 8; + case $outsize == 2: + $v .= chr($c & 0xFF); + $c >>= 8; + case $outsize == 1: + $v .= chr($c & 0xFF); + $c >>= 8; + if ($c) { + return false; + } + break; + case ($c & 0x80000000) != 0: + return false; + case $c >= 0x04000000: + $v .= chr(0x80 | ($c & 0x3F)); + $c = ($c >> 6) | 0x04000000; + case $c >= 0x00200000: + $v .= chr(0x80 | ($c & 0x3F)); + $c = ($c >> 6) | 0x00200000; + case $c >= 0x00010000: + $v .= chr(0x80 | ($c & 0x3F)); + $c = ($c >> 6) | 0x00010000; + case $c >= 0x00000800: + $v .= chr(0x80 | ($c & 0x3F)); + $c = ($c >> 6) | 0x00000800; + case $c >= 0x00000080: + $v .= chr(0x80 | ($c & 0x3F)); + $c = ($c >> 6) | 0x000000C0; + default: + $v .= chr($c); + break; + } + $out .= strrev($v); + } + return $out; + } +} diff --git a/vendor/phpseclib/phpseclib/phpseclib/File/X509.php b/vendor/phpseclib/phpseclib/phpseclib/File/X509.php new file mode 100755 index 0000000..9e7b0b3 --- /dev/null +++ b/vendor/phpseclib/phpseclib/phpseclib/File/X509.php @@ -0,0 +1,4433 @@ + + * @copyright MMXII Jim Wigginton + * @license http://www.opensource.org/licenses/mit-license.html MIT License + * @link http://phpseclib.sourceforge.net + */ + +/** + * Include File_ASN1 + */ +if (!class_exists('File_ASN1')) { + include_once 'ASN1.php'; +} + +/** + * Flag to only accept signatures signed by certificate authorities + * + * Not really used anymore but retained all the same to suppress E_NOTICEs from old installs + * + * @access public + */ +define('FILE_X509_VALIDATE_SIGNATURE_BY_CA', 1); + +/**#@+ + * @access public + * @see File_X509::getDN() + */ +/** + * Return internal array representation + */ +define('FILE_X509_DN_ARRAY', 0); +/** + * Return string + */ +define('FILE_X509_DN_STRING', 1); +/** + * Return ASN.1 name string + */ +define('FILE_X509_DN_ASN1', 2); +/** + * Return OpenSSL compatible array + */ +define('FILE_X509_DN_OPENSSL', 3); +/** + * Return canonical ASN.1 RDNs string + */ +define('FILE_X509_DN_CANON', 4); +/** + * Return name hash for file indexing + */ +define('FILE_X509_DN_HASH', 5); +/**#@-*/ + +/**#@+ + * @access public + * @see File_X509::saveX509() + * @see File_X509::saveCSR() + * @see File_X509::saveCRL() + */ +/** + * Save as PEM + * + * ie. a base64-encoded PEM with a header and a footer + */ +define('FILE_X509_FORMAT_PEM', 0); +/** + * Save as DER + */ +define('FILE_X509_FORMAT_DER', 1); +/** + * Save as a SPKAC + * + * Only works on CSRs. Not currently supported. + */ +define('FILE_X509_FORMAT_SPKAC', 2); +/**#@-*/ + +/** + * Attribute value disposition. + * If disposition is >= 0, this is the index of the target value. + */ +define('FILE_X509_ATTR_ALL', -1); // All attribute values (array). +define('FILE_X509_ATTR_APPEND', -2); // Add a value. +define('FILE_X509_ATTR_REPLACE', -3); // Clear first, then add a value. + +/** + * Pure-PHP X.509 Parser + * + * @package File_X509 + * @author Jim Wigginton + * @version 0.3.1 + * @access public + */ +class File_X509 +{ + /** + * ASN.1 syntax for X.509 certificates + * + * @var Array + * @access private + */ + var $Certificate; + + /**#@+ + * ASN.1 syntax for various extensions + * + * @access private + */ + var $DirectoryString; + var $PKCS9String; + var $AttributeValue; + var $Extensions; + var $KeyUsage; + var $ExtKeyUsageSyntax; + var $BasicConstraints; + var $KeyIdentifier; + var $CRLDistributionPoints; + var $AuthorityKeyIdentifier; + var $CertificatePolicies; + var $AuthorityInfoAccessSyntax; + var $SubjectAltName; + var $PrivateKeyUsagePeriod; + var $IssuerAltName; + var $PolicyMappings; + var $NameConstraints; + + var $CPSuri; + var $UserNotice; + + var $netscape_cert_type; + var $netscape_comment; + var $netscape_ca_policy_url; + + var $Name; + var $RelativeDistinguishedName; + var $CRLNumber; + var $CRLReason; + var $IssuingDistributionPoint; + var $InvalidityDate; + var $CertificateIssuer; + var $HoldInstructionCode; + var $SignedPublicKeyAndChallenge; + /**#@-*/ + + /** + * ASN.1 syntax for Certificate Signing Requests (RFC2986) + * + * @var Array + * @access private + */ + var $CertificationRequest; + + /** + * ASN.1 syntax for Certificate Revocation Lists (RFC5280) + * + * @var Array + * @access private + */ + var $CertificateList; + + /** + * Distinguished Name + * + * @var Array + * @access private + */ + var $dn; + + /** + * Public key + * + * @var String + * @access private + */ + var $publicKey; + + /** + * Private key + * + * @var String + * @access private + */ + var $privateKey; + + /** + * Object identifiers for X.509 certificates + * + * @var Array + * @access private + * @link http://en.wikipedia.org/wiki/Object_identifier + */ + var $oids; + + /** + * The certificate authorities + * + * @var Array + * @access private + */ + var $CAs; + + /** + * The currently loaded certificate + * + * @var Array + * @access private + */ + var $currentCert; + + /** + * The signature subject + * + * There's no guarantee File_X509 is going to reencode an X.509 cert in the same way it was originally + * encoded so we take save the portion of the original cert that the signature would have made for. + * + * @var String + * @access private + */ + var $signatureSubject; + + /** + * Certificate Start Date + * + * @var String + * @access private + */ + var $startDate; + + /** + * Certificate End Date + * + * @var String + * @access private + */ + var $endDate; + + /** + * Serial Number + * + * @var String + * @access private + */ + var $serialNumber; + + /** + * Key Identifier + * + * See {@link http://tools.ietf.org/html/rfc5280#section-4.2.1.1 RFC5280#section-4.2.1.1} and + * {@link http://tools.ietf.org/html/rfc5280#section-4.2.1.2 RFC5280#section-4.2.1.2}. + * + * @var String + * @access private + */ + var $currentKeyIdentifier; + + /** + * CA Flag + * + * @var Boolean + * @access private + */ + var $caFlag = false; + + /** + * Default Constructor. + * + * @return File_X509 + * @access public + */ + function File_X509() + { + if (!class_exists('Math_BigInteger')) { + include_once 'Math/BigInteger.php'; + } + + // Explicitly Tagged Module, 1988 Syntax + // http://tools.ietf.org/html/rfc5280#appendix-A.1 + + $this->DirectoryString = array( + 'type' => FILE_ASN1_TYPE_CHOICE, + 'children' => array( + 'teletexString' => array('type' => FILE_ASN1_TYPE_TELETEX_STRING), + 'printableString' => array('type' => FILE_ASN1_TYPE_PRINTABLE_STRING), + 'universalString' => array('type' => FILE_ASN1_TYPE_UNIVERSAL_STRING), + 'utf8String' => array('type' => FILE_ASN1_TYPE_UTF8_STRING), + 'bmpString' => array('type' => FILE_ASN1_TYPE_BMP_STRING) + ) + ); + + $this->PKCS9String = array( + 'type' => FILE_ASN1_TYPE_CHOICE, + 'children' => array( + 'ia5String' => array('type' => FILE_ASN1_TYPE_IA5_STRING), + 'directoryString' => $this->DirectoryString + ) + ); + + $this->AttributeValue = array('type' => FILE_ASN1_TYPE_ANY); + + $AttributeType = array('type' => FILE_ASN1_TYPE_OBJECT_IDENTIFIER); + + $AttributeTypeAndValue = array( + 'type' => FILE_ASN1_TYPE_SEQUENCE, + 'children' => array( + 'type' => $AttributeType, + 'value'=> $this->AttributeValue + ) + ); + + /* + In practice, RDNs containing multiple name-value pairs (called "multivalued RDNs") are rare, + but they can be useful at times when either there is no unique attribute in the entry or you + want to ensure that the entry's DN contains some useful identifying information. + + - https://www.opends.org/wiki/page/DefinitionRelativeDistinguishedName + */ + $this->RelativeDistinguishedName = array( + 'type' => FILE_ASN1_TYPE_SET, + 'min' => 1, + 'max' => -1, + 'children' => $AttributeTypeAndValue + ); + + // http://tools.ietf.org/html/rfc5280#section-4.1.2.4 + $RDNSequence = array( + 'type' => FILE_ASN1_TYPE_SEQUENCE, + // RDNSequence does not define a min or a max, which means it doesn't have one + 'min' => 0, + 'max' => -1, + 'children' => $this->RelativeDistinguishedName + ); + + $this->Name = array( + 'type' => FILE_ASN1_TYPE_CHOICE, + 'children' => array( + 'rdnSequence' => $RDNSequence + ) + ); + + // http://tools.ietf.org/html/rfc5280#section-4.1.1.2 + $AlgorithmIdentifier = array( + 'type' => FILE_ASN1_TYPE_SEQUENCE, + 'children' => array( + 'algorithm' => array('type' => FILE_ASN1_TYPE_OBJECT_IDENTIFIER), + 'parameters' => array( + 'type' => FILE_ASN1_TYPE_ANY, + 'optional' => true + ) + ) + ); + + /* + A certificate using system MUST reject the certificate if it encounters + a critical extension it does not recognize; however, a non-critical + extension may be ignored if it is not recognized. + + http://tools.ietf.org/html/rfc5280#section-4.2 + */ + $Extension = array( + 'type' => FILE_ASN1_TYPE_SEQUENCE, + 'children' => array( + 'extnId' => array('type' => FILE_ASN1_TYPE_OBJECT_IDENTIFIER), + 'critical' => array( + 'type' => FILE_ASN1_TYPE_BOOLEAN, + 'optional' => true, + 'default' => false + ), + 'extnValue' => array('type' => FILE_ASN1_TYPE_OCTET_STRING) + ) + ); + + $this->Extensions = array( + 'type' => FILE_ASN1_TYPE_SEQUENCE, + 'min' => 1, + // technically, it's MAX, but we'll assume anything < 0 is MAX + 'max' => -1, + // if 'children' isn't an array then 'min' and 'max' must be defined + 'children' => $Extension + ); + + $SubjectPublicKeyInfo = array( + 'type' => FILE_ASN1_TYPE_SEQUENCE, + 'children' => array( + 'algorithm' => $AlgorithmIdentifier, + 'subjectPublicKey' => array('type' => FILE_ASN1_TYPE_BIT_STRING) + ) + ); + + $UniqueIdentifier = array('type' => FILE_ASN1_TYPE_BIT_STRING); + + $Time = array( + 'type' => FILE_ASN1_TYPE_CHOICE, + 'children' => array( + 'utcTime' => array('type' => FILE_ASN1_TYPE_UTC_TIME), + 'generalTime' => array('type' => FILE_ASN1_TYPE_GENERALIZED_TIME) + ) + ); + + // http://tools.ietf.org/html/rfc5280#section-4.1.2.5 + $Validity = array( + 'type' => FILE_ASN1_TYPE_SEQUENCE, + 'children' => array( + 'notBefore' => $Time, + 'notAfter' => $Time + ) + ); + + $CertificateSerialNumber = array('type' => FILE_ASN1_TYPE_INTEGER); + + $Version = array( + 'type' => FILE_ASN1_TYPE_INTEGER, + 'mapping' => array('v1', 'v2', 'v3') + ); + + // assert($TBSCertificate['children']['signature'] == $Certificate['children']['signatureAlgorithm']) + $TBSCertificate = array( + 'type' => FILE_ASN1_TYPE_SEQUENCE, + 'children' => array( + // technically, default implies optional, but we'll define it as being optional, none-the-less, just to + // reenforce that fact + 'version' => array( + 'constant' => 0, + 'optional' => true, + 'explicit' => true, + 'default' => 'v1' + ) + $Version, + 'serialNumber' => $CertificateSerialNumber, + 'signature' => $AlgorithmIdentifier, + 'issuer' => $this->Name, + 'validity' => $Validity, + 'subject' => $this->Name, + 'subjectPublicKeyInfo' => $SubjectPublicKeyInfo, + // implicit means that the T in the TLV structure is to be rewritten, regardless of the type + 'issuerUniqueID' => array( + 'constant' => 1, + 'optional' => true, + 'implicit' => true + ) + $UniqueIdentifier, + 'subjectUniqueID' => array( + 'constant' => 2, + 'optional' => true, + 'implicit' => true + ) + $UniqueIdentifier, + // doesn't use the EXPLICIT keyword but if + // it's not IMPLICIT, it's EXPLICIT + 'extensions' => array( + 'constant' => 3, + 'optional' => true, + 'explicit' => true + ) + $this->Extensions + ) + ); + + $this->Certificate = array( + 'type' => FILE_ASN1_TYPE_SEQUENCE, + 'children' => array( + 'tbsCertificate' => $TBSCertificate, + 'signatureAlgorithm' => $AlgorithmIdentifier, + 'signature' => array('type' => FILE_ASN1_TYPE_BIT_STRING) + ) + ); + + $this->KeyUsage = array( + 'type' => FILE_ASN1_TYPE_BIT_STRING, + 'mapping' => array( + 'digitalSignature', + 'nonRepudiation', + 'keyEncipherment', + 'dataEncipherment', + 'keyAgreement', + 'keyCertSign', + 'cRLSign', + 'encipherOnly', + 'decipherOnly' + ) + ); + + $this->BasicConstraints = array( + 'type' => FILE_ASN1_TYPE_SEQUENCE, + 'children' => array( + 'cA' => array( + 'type' => FILE_ASN1_TYPE_BOOLEAN, + 'optional' => true, + 'default' => false + ), + 'pathLenConstraint' => array( + 'type' => FILE_ASN1_TYPE_INTEGER, + 'optional' => true + ) + ) + ); + + $this->KeyIdentifier = array('type' => FILE_ASN1_TYPE_OCTET_STRING); + + $OrganizationalUnitNames = array( + 'type' => FILE_ASN1_TYPE_SEQUENCE, + 'min' => 1, + 'max' => 4, // ub-organizational-units + 'children' => array('type' => FILE_ASN1_TYPE_PRINTABLE_STRING) + ); + + $PersonalName = array( + 'type' => FILE_ASN1_TYPE_SET, + 'children' => array( + 'surname' => array( + 'type' => FILE_ASN1_TYPE_PRINTABLE_STRING, + 'constant' => 0, + 'optional' => true, + 'implicit' => true + ), + 'given-name' => array( + 'type' => FILE_ASN1_TYPE_PRINTABLE_STRING, + 'constant' => 1, + 'optional' => true, + 'implicit' => true + ), + 'initials' => array( + 'type' => FILE_ASN1_TYPE_PRINTABLE_STRING, + 'constant' => 2, + 'optional' => true, + 'implicit' => true + ), + 'generation-qualifier' => array( + 'type' => FILE_ASN1_TYPE_PRINTABLE_STRING, + 'constant' => 3, + 'optional' => true, + 'implicit' => true + ) + ) + ); + + $NumericUserIdentifier = array('type' => FILE_ASN1_TYPE_NUMERIC_STRING); + + $OrganizationName = array('type' => FILE_ASN1_TYPE_PRINTABLE_STRING); + + $PrivateDomainName = array( + 'type' => FILE_ASN1_TYPE_CHOICE, + 'children' => array( + 'numeric' => array('type' => FILE_ASN1_TYPE_NUMERIC_STRING), + 'printable' => array('type' => FILE_ASN1_TYPE_PRINTABLE_STRING) + ) + ); + + $TerminalIdentifier = array('type' => FILE_ASN1_TYPE_PRINTABLE_STRING); + + $NetworkAddress = array('type' => FILE_ASN1_TYPE_NUMERIC_STRING); + + $AdministrationDomainName = array( + 'type' => FILE_ASN1_TYPE_CHOICE, + // if class isn't present it's assumed to be FILE_ASN1_CLASS_UNIVERSAL or + // (if constant is present) FILE_ASN1_CLASS_CONTEXT_SPECIFIC + 'class' => FILE_ASN1_CLASS_APPLICATION, + 'cast' => 2, + 'children' => array( + 'numeric' => array('type' => FILE_ASN1_TYPE_NUMERIC_STRING), + 'printable' => array('type' => FILE_ASN1_TYPE_PRINTABLE_STRING) + ) + ); + + $CountryName = array( + 'type' => FILE_ASN1_TYPE_CHOICE, + // if class isn't present it's assumed to be FILE_ASN1_CLASS_UNIVERSAL or + // (if constant is present) FILE_ASN1_CLASS_CONTEXT_SPECIFIC + 'class' => FILE_ASN1_CLASS_APPLICATION, + 'cast' => 1, + 'children' => array( + 'x121-dcc-code' => array('type' => FILE_ASN1_TYPE_NUMERIC_STRING), + 'iso-3166-alpha2-code' => array('type' => FILE_ASN1_TYPE_PRINTABLE_STRING) + ) + ); + + $AnotherName = array( + 'type' => FILE_ASN1_TYPE_SEQUENCE, + 'children' => array( + 'type-id' => array('type' => FILE_ASN1_TYPE_OBJECT_IDENTIFIER), + 'value' => array( + 'type' => FILE_ASN1_TYPE_ANY, + 'constant' => 0, + 'optional' => true, + 'explicit' => true + ) + ) + ); + + $ExtensionAttribute = array( + 'type' => FILE_ASN1_TYPE_SEQUENCE, + 'children' => array( + 'extension-attribute-type' => array( + 'type' => FILE_ASN1_TYPE_PRINTABLE_STRING, + 'constant' => 0, + 'optional' => true, + 'implicit' => true + ), + 'extension-attribute-value' => array( + 'type' => FILE_ASN1_TYPE_ANY, + 'constant' => 1, + 'optional' => true, + 'explicit' => true + ) + ) + ); + + $ExtensionAttributes = array( + 'type' => FILE_ASN1_TYPE_SET, + 'min' => 1, + 'max' => 256, // ub-extension-attributes + 'children' => $ExtensionAttribute + ); + + $BuiltInDomainDefinedAttribute = array( + 'type' => FILE_ASN1_TYPE_SEQUENCE, + 'children' => array( + 'type' => array('type' => FILE_ASN1_TYPE_PRINTABLE_STRING), + 'value' => array('type' => FILE_ASN1_TYPE_PRINTABLE_STRING) + ) + ); + + $BuiltInDomainDefinedAttributes = array( + 'type' => FILE_ASN1_TYPE_SEQUENCE, + 'min' => 1, + 'max' => 4, // ub-domain-defined-attributes + 'children' => $BuiltInDomainDefinedAttribute + ); + + $BuiltInStandardAttributes = array( + 'type' => FILE_ASN1_TYPE_SEQUENCE, + 'children' => array( + 'country-name' => array('optional' => true) + $CountryName, + 'administration-domain-name' => array('optional' => true) + $AdministrationDomainName, + 'network-address' => array( + 'constant' => 0, + 'optional' => true, + 'implicit' => true + ) + $NetworkAddress, + 'terminal-identifier' => array( + 'constant' => 1, + 'optional' => true, + 'implicit' => true + ) + $TerminalIdentifier, + 'private-domain-name' => array( + 'constant' => 2, + 'optional' => true, + 'explicit' => true + ) + $PrivateDomainName, + 'organization-name' => array( + 'constant' => 3, + 'optional' => true, + 'implicit' => true + ) + $OrganizationName, + 'numeric-user-identifier' => array( + 'constant' => 4, + 'optional' => true, + 'implicit' => true + ) + $NumericUserIdentifier, + 'personal-name' => array( + 'constant' => 5, + 'optional' => true, + 'implicit' => true + ) + $PersonalName, + 'organizational-unit-names' => array( + 'constant' => 6, + 'optional' => true, + 'implicit' => true + ) + $OrganizationalUnitNames + ) + ); + + $ORAddress = array( + 'type' => FILE_ASN1_TYPE_SEQUENCE, + 'children' => array( + 'built-in-standard-attributes' => $BuiltInStandardAttributes, + 'built-in-domain-defined-attributes' => array('optional' => true) + $BuiltInDomainDefinedAttributes, + 'extension-attributes' => array('optional' => true) + $ExtensionAttributes + ) + ); + + $EDIPartyName = array( + 'type' => FILE_ASN1_TYPE_SEQUENCE, + 'children' => array( + 'nameAssigner' => array( + 'constant' => 0, + 'optional' => true, + 'implicit' => true + ) + $this->DirectoryString, + // partyName is technically required but File_ASN1 doesn't currently support non-optional constants and + // setting it to optional gets the job done in any event. + 'partyName' => array( + 'constant' => 1, + 'optional' => true, + 'implicit' => true + ) + $this->DirectoryString + ) + ); + + $GeneralName = array( + 'type' => FILE_ASN1_TYPE_CHOICE, + 'children' => array( + 'otherName' => array( + 'constant' => 0, + 'optional' => true, + 'implicit' => true + ) + $AnotherName, + 'rfc822Name' => array( + 'type' => FILE_ASN1_TYPE_IA5_STRING, + 'constant' => 1, + 'optional' => true, + 'implicit' => true + ), + 'dNSName' => array( + 'type' => FILE_ASN1_TYPE_IA5_STRING, + 'constant' => 2, + 'optional' => true, + 'implicit' => true + ), + 'x400Address' => array( + 'constant' => 3, + 'optional' => true, + 'implicit' => true + ) + $ORAddress, + 'directoryName' => array( + 'constant' => 4, + 'optional' => true, + 'explicit' => true + ) + $this->Name, + 'ediPartyName' => array( + 'constant' => 5, + 'optional' => true, + 'implicit' => true + ) + $EDIPartyName, + 'uniformResourceIdentifier' => array( + 'type' => FILE_ASN1_TYPE_IA5_STRING, + 'constant' => 6, + 'optional' => true, + 'implicit' => true + ), + 'iPAddress' => array( + 'type' => FILE_ASN1_TYPE_OCTET_STRING, + 'constant' => 7, + 'optional' => true, + 'implicit' => true + ), + 'registeredID' => array( + 'type' => FILE_ASN1_TYPE_OBJECT_IDENTIFIER, + 'constant' => 8, + 'optional' => true, + 'implicit' => true + ) + ) + ); + + $GeneralNames = array( + 'type' => FILE_ASN1_TYPE_SEQUENCE, + 'min' => 1, + 'max' => -1, + 'children' => $GeneralName + ); + + $this->IssuerAltName = $GeneralNames; + + $ReasonFlags = array( + 'type' => FILE_ASN1_TYPE_BIT_STRING, + 'mapping' => array( + 'unused', + 'keyCompromise', + 'cACompromise', + 'affiliationChanged', + 'superseded', + 'cessationOfOperation', + 'certificateHold', + 'privilegeWithdrawn', + 'aACompromise' + ) + ); + + $DistributionPointName = array( + 'type' => FILE_ASN1_TYPE_CHOICE, + 'children' => array( + 'fullName' => array( + 'constant' => 0, + 'optional' => true, + 'implicit' => true + ) + $GeneralNames, + 'nameRelativeToCRLIssuer' => array( + 'constant' => 1, + 'optional' => true, + 'implicit' => true + ) + $this->RelativeDistinguishedName + ) + ); + + $DistributionPoint = array( + 'type' => FILE_ASN1_TYPE_SEQUENCE, + 'children' => array( + 'distributionPoint' => array( + 'constant' => 0, + 'optional' => true, + 'explicit' => true + ) + $DistributionPointName, + 'reasons' => array( + 'constant' => 1, + 'optional' => true, + 'implicit' => true + ) + $ReasonFlags, + 'cRLIssuer' => array( + 'constant' => 2, + 'optional' => true, + 'implicit' => true + ) + $GeneralNames + ) + ); + + $this->CRLDistributionPoints = array( + 'type' => FILE_ASN1_TYPE_SEQUENCE, + 'min' => 1, + 'max' => -1, + 'children' => $DistributionPoint + ); + + $this->AuthorityKeyIdentifier = array( + 'type' => FILE_ASN1_TYPE_SEQUENCE, + 'children' => array( + 'keyIdentifier' => array( + 'constant' => 0, + 'optional' => true, + 'implicit' => true + ) + $this->KeyIdentifier, + 'authorityCertIssuer' => array( + 'constant' => 1, + 'optional' => true, + 'implicit' => true + ) + $GeneralNames, + 'authorityCertSerialNumber' => array( + 'constant' => 2, + 'optional' => true, + 'implicit' => true + ) + $CertificateSerialNumber + ) + ); + + $PolicyQualifierId = array('type' => FILE_ASN1_TYPE_OBJECT_IDENTIFIER); + + $PolicyQualifierInfo = array( + 'type' => FILE_ASN1_TYPE_SEQUENCE, + 'children' => array( + 'policyQualifierId' => $PolicyQualifierId, + 'qualifier' => array('type' => FILE_ASN1_TYPE_ANY) + ) + ); + + $CertPolicyId = array('type' => FILE_ASN1_TYPE_OBJECT_IDENTIFIER); + + $PolicyInformation = array( + 'type' => FILE_ASN1_TYPE_SEQUENCE, + 'children' => array( + 'policyIdentifier' => $CertPolicyId, + 'policyQualifiers' => array( + 'type' => FILE_ASN1_TYPE_SEQUENCE, + 'min' => 0, + 'max' => -1, + 'optional' => true, + 'children' => $PolicyQualifierInfo + ) + ) + ); + + $this->CertificatePolicies = array( + 'type' => FILE_ASN1_TYPE_SEQUENCE, + 'min' => 1, + 'max' => -1, + 'children' => $PolicyInformation + ); + + $this->PolicyMappings = array( + 'type' => FILE_ASN1_TYPE_SEQUENCE, + 'min' => 1, + 'max' => -1, + 'children' => array( + 'type' => FILE_ASN1_TYPE_SEQUENCE, + 'children' => array( + 'issuerDomainPolicy' => $CertPolicyId, + 'subjectDomainPolicy' => $CertPolicyId + ) + ) + ); + + $KeyPurposeId = array('type' => FILE_ASN1_TYPE_OBJECT_IDENTIFIER); + + $this->ExtKeyUsageSyntax = array( + 'type' => FILE_ASN1_TYPE_SEQUENCE, + 'min' => 1, + 'max' => -1, + 'children' => $KeyPurposeId + ); + + $AccessDescription = array( + 'type' => FILE_ASN1_TYPE_SEQUENCE, + 'children' => array( + 'accessMethod' => array('type' => FILE_ASN1_TYPE_OBJECT_IDENTIFIER), + 'accessLocation' => $GeneralName + ) + ); + + $this->AuthorityInfoAccessSyntax = array( + 'type' => FILE_ASN1_TYPE_SEQUENCE, + 'min' => 1, + 'max' => -1, + 'children' => $AccessDescription + ); + + $this->SubjectAltName = $GeneralNames; + + $this->PrivateKeyUsagePeriod = array( + 'type' => FILE_ASN1_TYPE_SEQUENCE, + 'children' => array( + 'notBefore' => array( + 'constant' => 0, + 'optional' => true, + 'implicit' => true, + 'type' => FILE_ASN1_TYPE_GENERALIZED_TIME), + 'notAfter' => array( + 'constant' => 1, + 'optional' => true, + 'implicit' => true, + 'type' => FILE_ASN1_TYPE_GENERALIZED_TIME) + ) + ); + + $BaseDistance = array('type' => FILE_ASN1_TYPE_INTEGER); + + $GeneralSubtree = array( + 'type' => FILE_ASN1_TYPE_SEQUENCE, + 'children' => array( + 'base' => $GeneralName, + 'minimum' => array( + 'constant' => 0, + 'optional' => true, + 'implicit' => true, + 'default' => new Math_BigInteger(0) + ) + $BaseDistance, + 'maximum' => array( + 'constant' => 1, + 'optional' => true, + 'implicit' => true, + ) + $BaseDistance + ) + ); + + $GeneralSubtrees = array( + 'type' => FILE_ASN1_TYPE_SEQUENCE, + 'min' => 1, + 'max' => -1, + 'children' => $GeneralSubtree + ); + + $this->NameConstraints = array( + 'type' => FILE_ASN1_TYPE_SEQUENCE, + 'children' => array( + 'permittedSubtrees' => array( + 'constant' => 0, + 'optional' => true, + 'implicit' => true + ) + $GeneralSubtrees, + 'excludedSubtrees' => array( + 'constant' => 1, + 'optional' => true, + 'implicit' => true + ) + $GeneralSubtrees + ) + ); + + $this->CPSuri = array('type' => FILE_ASN1_TYPE_IA5_STRING); + + $DisplayText = array( + 'type' => FILE_ASN1_TYPE_CHOICE, + 'children' => array( + 'ia5String' => array('type' => FILE_ASN1_TYPE_IA5_STRING), + 'visibleString' => array('type' => FILE_ASN1_TYPE_VISIBLE_STRING), + 'bmpString' => array('type' => FILE_ASN1_TYPE_BMP_STRING), + 'utf8String' => array('type' => FILE_ASN1_TYPE_UTF8_STRING) + ) + ); + + $NoticeReference = array( + 'type' => FILE_ASN1_TYPE_SEQUENCE, + 'children' => array( + 'organization' => $DisplayText, + 'noticeNumbers' => array( + 'type' => FILE_ASN1_TYPE_SEQUENCE, + 'min' => 1, + 'max' => 200, + 'children' => array('type' => FILE_ASN1_TYPE_INTEGER) + ) + ) + ); + + $this->UserNotice = array( + 'type' => FILE_ASN1_TYPE_SEQUENCE, + 'children' => array( + 'noticeRef' => array( + 'optional' => true, + 'implicit' => true + ) + $NoticeReference, + 'explicitText' => array( + 'optional' => true, + 'implicit' => true + ) + $DisplayText + ) + ); + + // mapping is from + $this->netscape_cert_type = array( + 'type' => FILE_ASN1_TYPE_BIT_STRING, + 'mapping' => array( + 'SSLClient', + 'SSLServer', + 'Email', + 'ObjectSigning', + 'Reserved', + 'SSLCA', + 'EmailCA', + 'ObjectSigningCA' + ) + ); + + $this->netscape_comment = array('type' => FILE_ASN1_TYPE_IA5_STRING); + $this->netscape_ca_policy_url = array('type' => FILE_ASN1_TYPE_IA5_STRING); + + // attribute is used in RFC2986 but we're using the RFC5280 definition + + $Attribute = array( + 'type' => FILE_ASN1_TYPE_SEQUENCE, + 'children' => array( + 'type' => $AttributeType, + 'value'=> array( + 'type' => FILE_ASN1_TYPE_SET, + 'min' => 1, + 'max' => -1, + 'children' => $this->AttributeValue + ) + ) + ); + + // adapted from + + $Attributes = array( + 'type' => FILE_ASN1_TYPE_SET, + 'min' => 1, + 'max' => -1, + 'children' => $Attribute + ); + + $CertificationRequestInfo = array( + 'type' => FILE_ASN1_TYPE_SEQUENCE, + 'children' => array( + 'version' => array( + 'type' => FILE_ASN1_TYPE_INTEGER, + 'mapping' => array('v1') + ), + 'subject' => $this->Name, + 'subjectPKInfo' => $SubjectPublicKeyInfo, + 'attributes' => array( + 'constant' => 0, + 'optional' => true, + 'implicit' => true + ) + $Attributes, + ) + ); + + $this->CertificationRequest = array( + 'type' => FILE_ASN1_TYPE_SEQUENCE, + 'children' => array( + 'certificationRequestInfo' => $CertificationRequestInfo, + 'signatureAlgorithm' => $AlgorithmIdentifier, + 'signature' => array('type' => FILE_ASN1_TYPE_BIT_STRING) + ) + ); + + $RevokedCertificate = array( + 'type' => FILE_ASN1_TYPE_SEQUENCE, + 'children' => array( + 'userCertificate' => $CertificateSerialNumber, + 'revocationDate' => $Time, + 'crlEntryExtensions' => array( + 'optional' => true + ) + $this->Extensions + ) + ); + + $TBSCertList = array( + 'type' => FILE_ASN1_TYPE_SEQUENCE, + 'children' => array( + 'version' => array( + 'optional' => true, + 'default' => 'v1' + ) + $Version, + 'signature' => $AlgorithmIdentifier, + 'issuer' => $this->Name, + 'thisUpdate' => $Time, + 'nextUpdate' => array( + 'optional' => true + ) + $Time, + 'revokedCertificates' => array( + 'type' => FILE_ASN1_TYPE_SEQUENCE, + 'optional' => true, + 'min' => 0, + 'max' => -1, + 'children' => $RevokedCertificate + ), + 'crlExtensions' => array( + 'constant' => 0, + 'optional' => true, + 'explicit' => true + ) + $this->Extensions + ) + ); + + $this->CertificateList = array( + 'type' => FILE_ASN1_TYPE_SEQUENCE, + 'children' => array( + 'tbsCertList' => $TBSCertList, + 'signatureAlgorithm' => $AlgorithmIdentifier, + 'signature' => array('type' => FILE_ASN1_TYPE_BIT_STRING) + ) + ); + + $this->CRLNumber = array('type' => FILE_ASN1_TYPE_INTEGER); + + $this->CRLReason = array('type' => FILE_ASN1_TYPE_ENUMERATED, + 'mapping' => array( + 'unspecified', + 'keyCompromise', + 'cACompromise', + 'affiliationChanged', + 'superseded', + 'cessationOfOperation', + 'certificateHold', + // Value 7 is not used. + 8 => 'removeFromCRL', + 'privilegeWithdrawn', + 'aACompromise' + ) + ); + + $this->IssuingDistributionPoint = array('type' => FILE_ASN1_TYPE_SEQUENCE, + 'children' => array( + 'distributionPoint' => array( + 'constant' => 0, + 'optional' => true, + 'explicit' => true + ) + $DistributionPointName, + 'onlyContainsUserCerts' => array( + 'type' => FILE_ASN1_TYPE_BOOLEAN, + 'constant' => 1, + 'optional' => true, + 'default' => false, + 'implicit' => true + ), + 'onlyContainsCACerts' => array( + 'type' => FILE_ASN1_TYPE_BOOLEAN, + 'constant' => 2, + 'optional' => true, + 'default' => false, + 'implicit' => true + ), + 'onlySomeReasons' => array( + 'constant' => 3, + 'optional' => true, + 'implicit' => true + ) + $ReasonFlags, + 'indirectCRL' => array( + 'type' => FILE_ASN1_TYPE_BOOLEAN, + 'constant' => 4, + 'optional' => true, + 'default' => false, + 'implicit' => true + ), + 'onlyContainsAttributeCerts' => array( + 'type' => FILE_ASN1_TYPE_BOOLEAN, + 'constant' => 5, + 'optional' => true, + 'default' => false, + 'implicit' => true + ) + ) + ); + + $this->InvalidityDate = array('type' => FILE_ASN1_TYPE_GENERALIZED_TIME); + + $this->CertificateIssuer = $GeneralNames; + + $this->HoldInstructionCode = array('type' => FILE_ASN1_TYPE_OBJECT_IDENTIFIER); + + $PublicKeyAndChallenge = array( + 'type' => FILE_ASN1_TYPE_SEQUENCE, + 'children' => array( + 'spki' => $SubjectPublicKeyInfo, + 'challenge' => array('type' => FILE_ASN1_TYPE_IA5_STRING) + ) + ); + + $this->SignedPublicKeyAndChallenge = array( + 'type' => FILE_ASN1_TYPE_SEQUENCE, + 'children' => array( + 'publicKeyAndChallenge' => $PublicKeyAndChallenge, + 'signatureAlgorithm' => $AlgorithmIdentifier, + 'signature' => array('type' => FILE_ASN1_TYPE_BIT_STRING) + ) + ); + + // OIDs from RFC5280 and those RFCs mentioned in RFC5280#section-4.1.1.2 + $this->oids = array( + '1.3.6.1.5.5.7' => 'id-pkix', + '1.3.6.1.5.5.7.1' => 'id-pe', + '1.3.6.1.5.5.7.2' => 'id-qt', + '1.3.6.1.5.5.7.3' => 'id-kp', + '1.3.6.1.5.5.7.48' => 'id-ad', + '1.3.6.1.5.5.7.2.1' => 'id-qt-cps', + '1.3.6.1.5.5.7.2.2' => 'id-qt-unotice', + '1.3.6.1.5.5.7.48.1' =>'id-ad-ocsp', + '1.3.6.1.5.5.7.48.2' => 'id-ad-caIssuers', + '1.3.6.1.5.5.7.48.3' => 'id-ad-timeStamping', + '1.3.6.1.5.5.7.48.5' => 'id-ad-caRepository', + '2.5.4' => 'id-at', + '2.5.4.41' => 'id-at-name', + '2.5.4.4' => 'id-at-surname', + '2.5.4.42' => 'id-at-givenName', + '2.5.4.43' => 'id-at-initials', + '2.5.4.44' => 'id-at-generationQualifier', + '2.5.4.3' => 'id-at-commonName', + '2.5.4.7' => 'id-at-localityName', + '2.5.4.8' => 'id-at-stateOrProvinceName', + '2.5.4.10' => 'id-at-organizationName', + '2.5.4.11' => 'id-at-organizationalUnitName', + '2.5.4.12' => 'id-at-title', + '2.5.4.13' => 'id-at-description', + '2.5.4.46' => 'id-at-dnQualifier', + '2.5.4.6' => 'id-at-countryName', + '2.5.4.5' => 'id-at-serialNumber', + '2.5.4.65' => 'id-at-pseudonym', + '2.5.4.17' => 'id-at-postalCode', + '2.5.4.9' => 'id-at-streetAddress', + '2.5.4.45' => 'id-at-uniqueIdentifier', + '2.5.4.72' => 'id-at-role', + + '0.9.2342.19200300.100.1.25' => 'id-domainComponent', + '1.2.840.113549.1.9' => 'pkcs-9', + '1.2.840.113549.1.9.1' => 'pkcs-9-at-emailAddress', + '2.5.29' => 'id-ce', + '2.5.29.35' => 'id-ce-authorityKeyIdentifier', + '2.5.29.14' => 'id-ce-subjectKeyIdentifier', + '2.5.29.15' => 'id-ce-keyUsage', + '2.5.29.16' => 'id-ce-privateKeyUsagePeriod', + '2.5.29.32' => 'id-ce-certificatePolicies', + '2.5.29.32.0' => 'anyPolicy', + + '2.5.29.33' => 'id-ce-policyMappings', + '2.5.29.17' => 'id-ce-subjectAltName', + '2.5.29.18' => 'id-ce-issuerAltName', + '2.5.29.9' => 'id-ce-subjectDirectoryAttributes', + '2.5.29.19' => 'id-ce-basicConstraints', + '2.5.29.30' => 'id-ce-nameConstraints', + '2.5.29.36' => 'id-ce-policyConstraints', + '2.5.29.31' => 'id-ce-cRLDistributionPoints', + '2.5.29.37' => 'id-ce-extKeyUsage', + '2.5.29.37.0' => 'anyExtendedKeyUsage', + '1.3.6.1.5.5.7.3.1' => 'id-kp-serverAuth', + '1.3.6.1.5.5.7.3.2' => 'id-kp-clientAuth', + '1.3.6.1.5.5.7.3.3' => 'id-kp-codeSigning', + '1.3.6.1.5.5.7.3.4' => 'id-kp-emailProtection', + '1.3.6.1.5.5.7.3.8' => 'id-kp-timeStamping', + '1.3.6.1.5.5.7.3.9' => 'id-kp-OCSPSigning', + '2.5.29.54' => 'id-ce-inhibitAnyPolicy', + '2.5.29.46' => 'id-ce-freshestCRL', + '1.3.6.1.5.5.7.1.1' => 'id-pe-authorityInfoAccess', + '1.3.6.1.5.5.7.1.11' => 'id-pe-subjectInfoAccess', + '2.5.29.20' => 'id-ce-cRLNumber', + '2.5.29.28' => 'id-ce-issuingDistributionPoint', + '2.5.29.27' => 'id-ce-deltaCRLIndicator', + '2.5.29.21' => 'id-ce-cRLReasons', + '2.5.29.29' => 'id-ce-certificateIssuer', + '2.5.29.23' => 'id-ce-holdInstructionCode', + '1.2.840.10040.2' => 'holdInstruction', + '1.2.840.10040.2.1' => 'id-holdinstruction-none', + '1.2.840.10040.2.2' => 'id-holdinstruction-callissuer', + '1.2.840.10040.2.3' => 'id-holdinstruction-reject', + '2.5.29.24' => 'id-ce-invalidityDate', + + '1.2.840.113549.2.2' => 'md2', + '1.2.840.113549.2.5' => 'md5', + '1.3.14.3.2.26' => 'id-sha1', + '1.2.840.10040.4.1' => 'id-dsa', + '1.2.840.10040.4.3' => 'id-dsa-with-sha1', + '1.2.840.113549.1.1' => 'pkcs-1', + '1.2.840.113549.1.1.1' => 'rsaEncryption', + '1.2.840.113549.1.1.2' => 'md2WithRSAEncryption', + '1.2.840.113549.1.1.4' => 'md5WithRSAEncryption', + '1.2.840.113549.1.1.5' => 'sha1WithRSAEncryption', + '1.2.840.10046.2.1' => 'dhpublicnumber', + '2.16.840.1.101.2.1.1.22' => 'id-keyExchangeAlgorithm', + '1.2.840.10045' => 'ansi-X9-62', + '1.2.840.10045.4' => 'id-ecSigType', + '1.2.840.10045.4.1' => 'ecdsa-with-SHA1', + '1.2.840.10045.1' => 'id-fieldType', + '1.2.840.10045.1.1' => 'prime-field', + '1.2.840.10045.1.2' => 'characteristic-two-field', + '1.2.840.10045.1.2.3' => 'id-characteristic-two-basis', + '1.2.840.10045.1.2.3.1' => 'gnBasis', + '1.2.840.10045.1.2.3.2' => 'tpBasis', + '1.2.840.10045.1.2.3.3' => 'ppBasis', + '1.2.840.10045.2' => 'id-publicKeyType', + '1.2.840.10045.2.1' => 'id-ecPublicKey', + '1.2.840.10045.3' => 'ellipticCurve', + '1.2.840.10045.3.0' => 'c-TwoCurve', + '1.2.840.10045.3.0.1' => 'c2pnb163v1', + '1.2.840.10045.3.0.2' => 'c2pnb163v2', + '1.2.840.10045.3.0.3' => 'c2pnb163v3', + '1.2.840.10045.3.0.4' => 'c2pnb176w1', + '1.2.840.10045.3.0.5' => 'c2pnb191v1', + '1.2.840.10045.3.0.6' => 'c2pnb191v2', + '1.2.840.10045.3.0.7' => 'c2pnb191v3', + '1.2.840.10045.3.0.8' => 'c2pnb191v4', + '1.2.840.10045.3.0.9' => 'c2pnb191v5', + '1.2.840.10045.3.0.10' => 'c2pnb208w1', + '1.2.840.10045.3.0.11' => 'c2pnb239v1', + '1.2.840.10045.3.0.12' => 'c2pnb239v2', + '1.2.840.10045.3.0.13' => 'c2pnb239v3', + '1.2.840.10045.3.0.14' => 'c2pnb239v4', + '1.2.840.10045.3.0.15' => 'c2pnb239v5', + '1.2.840.10045.3.0.16' => 'c2pnb272w1', + '1.2.840.10045.3.0.17' => 'c2pnb304w1', + '1.2.840.10045.3.0.18' => 'c2pnb359v1', + '1.2.840.10045.3.0.19' => 'c2pnb368w1', + '1.2.840.10045.3.0.20' => 'c2pnb431r1', + '1.2.840.10045.3.1' => 'primeCurve', + '1.2.840.10045.3.1.1' => 'prime192v1', + '1.2.840.10045.3.1.2' => 'prime192v2', + '1.2.840.10045.3.1.3' => 'prime192v3', + '1.2.840.10045.3.1.4' => 'prime239v1', + '1.2.840.10045.3.1.5' => 'prime239v2', + '1.2.840.10045.3.1.6' => 'prime239v3', + '1.2.840.10045.3.1.7' => 'prime256v1', + '1.2.840.113549.1.1.7' => 'id-RSAES-OAEP', + '1.2.840.113549.1.1.9' => 'id-pSpecified', + '1.2.840.113549.1.1.10' => 'id-RSASSA-PSS', + '1.2.840.113549.1.1.8' => 'id-mgf1', + '1.2.840.113549.1.1.14' => 'sha224WithRSAEncryption', + '1.2.840.113549.1.1.11' => 'sha256WithRSAEncryption', + '1.2.840.113549.1.1.12' => 'sha384WithRSAEncryption', + '1.2.840.113549.1.1.13' => 'sha512WithRSAEncryption', + '2.16.840.1.101.3.4.2.4' => 'id-sha224', + '2.16.840.1.101.3.4.2.1' => 'id-sha256', + '2.16.840.1.101.3.4.2.2' => 'id-sha384', + '2.16.840.1.101.3.4.2.3' => 'id-sha512', + '1.2.643.2.2.4' => 'id-GostR3411-94-with-GostR3410-94', + '1.2.643.2.2.3' => 'id-GostR3411-94-with-GostR3410-2001', + '1.2.643.2.2.20' => 'id-GostR3410-2001', + '1.2.643.2.2.19' => 'id-GostR3410-94', + // Netscape Object Identifiers from "Netscape Certificate Extensions" + '2.16.840.1.113730' => 'netscape', + '2.16.840.1.113730.1' => 'netscape-cert-extension', + '2.16.840.1.113730.1.1' => 'netscape-cert-type', + '2.16.840.1.113730.1.13' => 'netscape-comment', + '2.16.840.1.113730.1.8' => 'netscape-ca-policy-url', + // the following are X.509 extensions not supported by phpseclib + '1.3.6.1.5.5.7.1.12' => 'id-pe-logotype', + '1.2.840.113533.7.65.0' => 'entrustVersInfo', + '2.16.840.1.113733.1.6.9' => 'verisignPrivate', + // for Certificate Signing Requests + // see http://tools.ietf.org/html/rfc2985 + '1.2.840.113549.1.9.2' => 'pkcs-9-at-unstructuredName', // PKCS #9 unstructured name + '1.2.840.113549.1.9.7' => 'pkcs-9-at-challengePassword', // Challenge password for certificate revocations + '1.2.840.113549.1.9.14' => 'pkcs-9-at-extensionRequest' // Certificate extension request + ); + } + + /** + * Load X.509 certificate + * + * Returns an associative array describing the X.509 cert or a false if the cert failed to load + * + * @param String $cert + * @access public + * @return Mixed + */ + function loadX509($cert) + { + if (is_array($cert) && isset($cert['tbsCertificate'])) { + unset($this->currentCert); + unset($this->currentKeyIdentifier); + $this->dn = $cert['tbsCertificate']['subject']; + if (!isset($this->dn)) { + return false; + } + $this->currentCert = $cert; + + $currentKeyIdentifier = $this->getExtension('id-ce-subjectKeyIdentifier'); + $this->currentKeyIdentifier = is_string($currentKeyIdentifier) ? $currentKeyIdentifier : null; + + unset($this->signatureSubject); + + return $cert; + } + + $asn1 = new File_ASN1(); + + $cert = $this->_extractBER($cert); + + if ($cert === false) { + $this->currentCert = false; + return false; + } + + $asn1->loadOIDs($this->oids); + $decoded = $asn1->decodeBER($cert); + + if (!empty($decoded)) { + $x509 = $asn1->asn1map($decoded[0], $this->Certificate); + } + if (!isset($x509) || $x509 === false) { + $this->currentCert = false; + return false; + } + + $this->signatureSubject = substr($cert, $decoded[0]['content'][0]['start'], $decoded[0]['content'][0]['length']); + + $this->_mapInExtensions($x509, 'tbsCertificate/extensions', $asn1); + + $key = &$x509['tbsCertificate']['subjectPublicKeyInfo']['subjectPublicKey']; + $key = $this->_reformatKey($x509['tbsCertificate']['subjectPublicKeyInfo']['algorithm']['algorithm'], $key); + + $this->currentCert = $x509; + $this->dn = $x509['tbsCertificate']['subject']; + + $currentKeyIdentifier = $this->getExtension('id-ce-subjectKeyIdentifier'); + $this->currentKeyIdentifier = is_string($currentKeyIdentifier) ? $currentKeyIdentifier : null; + + return $x509; + } + + /** + * Save X.509 certificate + * + * @param Array $cert + * @param Integer $format optional + * @access public + * @return String + */ + function saveX509($cert, $format = FILE_X509_FORMAT_PEM) + { + if (!is_array($cert) || !isset($cert['tbsCertificate'])) { + return false; + } + + switch (true) { + // "case !$a: case !$b: break; default: whatever();" is the same thing as "if ($a && $b) whatever()" + case !($algorithm = $this->_subArray($cert, 'tbsCertificate/subjectPublicKeyInfo/algorithm/algorithm')): + case is_object($cert['tbsCertificate']['subjectPublicKeyInfo']['subjectPublicKey']): + break; + default: + switch ($algorithm) { + case 'rsaEncryption': + $cert['tbsCertificate']['subjectPublicKeyInfo']['subjectPublicKey'] + = base64_encode("\0" . base64_decode(preg_replace('#-.+-|[\r\n]#', '', $cert['tbsCertificate']['subjectPublicKeyInfo']['subjectPublicKey']))); + } + } + + $asn1 = new File_ASN1(); + $asn1->loadOIDs($this->oids); + + $filters = array(); + $type_utf8_string = array('type' => FILE_ASN1_TYPE_UTF8_STRING); + $filters['tbsCertificate']['signature']['parameters'] = $type_utf8_string; + $filters['tbsCertificate']['signature']['issuer']['rdnSequence']['value'] = $type_utf8_string; + $filters['tbsCertificate']['issuer']['rdnSequence']['value'] = $type_utf8_string; + $filters['tbsCertificate']['subject']['rdnSequence']['value'] = $type_utf8_string; + $filters['tbsCertificate']['subjectPublicKeyInfo']['algorithm']['parameters'] = $type_utf8_string; + $filters['signatureAlgorithm']['parameters'] = $type_utf8_string; + $filters['authorityCertIssuer']['directoryName']['rdnSequence']['value'] = $type_utf8_string; + //$filters['policyQualifiers']['qualifier'] = $type_utf8_string; + $filters['distributionPoint']['fullName']['directoryName']['rdnSequence']['value'] = $type_utf8_string; + $filters['directoryName']['rdnSequence']['value'] = $type_utf8_string; + + /* in the case of policyQualifiers/qualifier, the type has to be FILE_ASN1_TYPE_IA5_STRING. + FILE_ASN1_TYPE_PRINTABLE_STRING will cause OpenSSL's X.509 parser to spit out random + characters. + */ + $filters['policyQualifiers']['qualifier'] + = array('type' => FILE_ASN1_TYPE_IA5_STRING); + + $asn1->loadFilters($filters); + + $this->_mapOutExtensions($cert, 'tbsCertificate/extensions', $asn1); + + $cert = $asn1->encodeDER($cert, $this->Certificate); + + switch ($format) { + case FILE_X509_FORMAT_DER: + return $cert; + // case FILE_X509_FORMAT_PEM: + default: + return "-----BEGIN CERTIFICATE-----\r\n" . chunk_split(base64_encode($cert), 64) . '-----END CERTIFICATE-----'; + } + } + + /** + * Map extension values from octet string to extension-specific internal + * format. + * + * @param Array ref $root + * @param String $path + * @param Object $asn1 + * @access private + */ + function _mapInExtensions(&$root, $path, $asn1) + { + $extensions = &$this->_subArray($root, $path); + + if (is_array($extensions)) { + for ($i = 0; $i < count($extensions); $i++) { + $id = $extensions[$i]['extnId']; + $value = &$extensions[$i]['extnValue']; + $value = base64_decode($value); + $decoded = $asn1->decodeBER($value); + /* [extnValue] contains the DER encoding of an ASN.1 value + corresponding to the extension type identified by extnID */ + $map = $this->_getMapping($id); + if (!is_bool($map)) { + $mapped = $asn1->asn1map($decoded[0], $map, array('iPAddress' => array($this, '_decodeIP'))); + $value = $mapped === false ? $decoded[0] : $mapped; + + if ($id == 'id-ce-certificatePolicies') { + for ($j = 0; $j < count($value); $j++) { + if (!isset($value[$j]['policyQualifiers'])) { + continue; + } + for ($k = 0; $k < count($value[$j]['policyQualifiers']); $k++) { + $subid = $value[$j]['policyQualifiers'][$k]['policyQualifierId']; + $map = $this->_getMapping($subid); + $subvalue = &$value[$j]['policyQualifiers'][$k]['qualifier']; + if ($map !== false) { + $decoded = $asn1->decodeBER($subvalue); + $mapped = $asn1->asn1map($decoded[0], $map); + $subvalue = $mapped === false ? $decoded[0] : $mapped; + } + } + } + } + } elseif ($map) { + $value = base64_encode($value); + } + } + } + } + + /** + * Map extension values from extension-specific internal format to + * octet string. + * + * @param Array ref $root + * @param String $path + * @param Object $asn1 + * @access private + */ + function _mapOutExtensions(&$root, $path, $asn1) + { + $extensions = &$this->_subArray($root, $path); + + if (is_array($extensions)) { + $size = count($extensions); + for ($i = 0; $i < $size; $i++) { + $id = $extensions[$i]['extnId']; + $value = &$extensions[$i]['extnValue']; + + switch ($id) { + case 'id-ce-certificatePolicies': + for ($j = 0; $j < count($value); $j++) { + if (!isset($value[$j]['policyQualifiers'])) { + continue; + } + for ($k = 0; $k < count($value[$j]['policyQualifiers']); $k++) { + $subid = $value[$j]['policyQualifiers'][$k]['policyQualifierId']; + $map = $this->_getMapping($subid); + $subvalue = &$value[$j]['policyQualifiers'][$k]['qualifier']; + if ($map !== false) { + // by default File_ASN1 will try to render qualifier as a FILE_ASN1_TYPE_IA5_STRING since it's + // actual type is FILE_ASN1_TYPE_ANY + $subvalue = new File_ASN1_Element($asn1->encodeDER($subvalue, $map)); + } + } + } + break; + case 'id-ce-authorityKeyIdentifier': // use 00 as the serial number instead of an empty string + if (isset($value['authorityCertSerialNumber'])) { + if ($value['authorityCertSerialNumber']->toBytes() == '') { + $temp = chr((FILE_ASN1_CLASS_CONTEXT_SPECIFIC << 6) | 2) . "\1\0"; + $value['authorityCertSerialNumber'] = new File_ASN1_Element($temp); + } + } + } + + /* [extnValue] contains the DER encoding of an ASN.1 value + corresponding to the extension type identified by extnID */ + $map = $this->_getMapping($id); + if (is_bool($map)) { + if (!$map) { + user_error($id . ' is not a currently supported extension'); + unset($extensions[$i]); + } + } else { + $temp = $asn1->encodeDER($value, $map, array('iPAddress' => array($this, '_encodeIP'))); + $value = base64_encode($temp); + } + } + } + } + + /** + * Map attribute values from ANY type to attribute-specific internal + * format. + * + * @param Array ref $root + * @param String $path + * @param Object $asn1 + * @access private + */ + function _mapInAttributes(&$root, $path, $asn1) + { + $attributes = &$this->_subArray($root, $path); + + if (is_array($attributes)) { + for ($i = 0; $i < count($attributes); $i++) { + $id = $attributes[$i]['type']; + /* $value contains the DER encoding of an ASN.1 value + corresponding to the attribute type identified by type */ + $map = $this->_getMapping($id); + if (is_array($attributes[$i]['value'])) { + $values = &$attributes[$i]['value']; + for ($j = 0; $j < count($values); $j++) { + $value = $asn1->encodeDER($values[$j], $this->AttributeValue); + $decoded = $asn1->decodeBER($value); + if (!is_bool($map)) { + $mapped = $asn1->asn1map($decoded[0], $map); + if ($mapped !== false) { + $values[$j] = $mapped; + } + if ($id == 'pkcs-9-at-extensionRequest') { + $this->_mapInExtensions($values, $j, $asn1); + } + } elseif ($map) { + $values[$j] = base64_encode($value); + } + } + } + } + } + } + + /** + * Map attribute values from attribute-specific internal format to + * ANY type. + * + * @param Array ref $root + * @param String $path + * @param Object $asn1 + * @access private + */ + function _mapOutAttributes(&$root, $path, $asn1) + { + $attributes = &$this->_subArray($root, $path); + + if (is_array($attributes)) { + $size = count($attributes); + for ($i = 0; $i < $size; $i++) { + /* [value] contains the DER encoding of an ASN.1 value + corresponding to the attribute type identified by type */ + $id = $attributes[$i]['type']; + $map = $this->_getMapping($id); + if ($map === false) { + user_error($id . ' is not a currently supported attribute', E_USER_NOTICE); + unset($attributes[$i]); + } elseif (is_array($attributes[$i]['value'])) { + $values = &$attributes[$i]['value']; + for ($j = 0; $j < count($values); $j++) { + switch ($id) { + case 'pkcs-9-at-extensionRequest': + $this->_mapOutExtensions($values, $j, $asn1); + break; + } + + if (!is_bool($map)) { + $temp = $asn1->encodeDER($values[$j], $map); + $decoded = $asn1->decodeBER($temp); + $values[$j] = $asn1->asn1map($decoded[0], $this->AttributeValue); + } + } + } + } + } + } + + /** + * Associate an extension ID to an extension mapping + * + * @param String $extnId + * @access private + * @return Mixed + */ + function _getMapping($extnId) + { + if (!is_string($extnId)) { // eg. if it's a File_ASN1_Element object + return true; + } + + switch ($extnId) { + case 'id-ce-keyUsage': + return $this->KeyUsage; + case 'id-ce-basicConstraints': + return $this->BasicConstraints; + case 'id-ce-subjectKeyIdentifier': + return $this->KeyIdentifier; + case 'id-ce-cRLDistributionPoints': + return $this->CRLDistributionPoints; + case 'id-ce-authorityKeyIdentifier': + return $this->AuthorityKeyIdentifier; + case 'id-ce-certificatePolicies': + return $this->CertificatePolicies; + case 'id-ce-extKeyUsage': + return $this->ExtKeyUsageSyntax; + case 'id-pe-authorityInfoAccess': + return $this->AuthorityInfoAccessSyntax; + case 'id-ce-subjectAltName': + return $this->SubjectAltName; + case 'id-ce-privateKeyUsagePeriod': + return $this->PrivateKeyUsagePeriod; + case 'id-ce-issuerAltName': + return $this->IssuerAltName; + case 'id-ce-policyMappings': + return $this->PolicyMappings; + case 'id-ce-nameConstraints': + return $this->NameConstraints; + + case 'netscape-cert-type': + return $this->netscape_cert_type; + case 'netscape-comment': + return $this->netscape_comment; + case 'netscape-ca-policy-url': + return $this->netscape_ca_policy_url; + + // since id-qt-cps isn't a constructed type it will have already been decoded as a string by the time it gets + // back around to asn1map() and we don't want it decoded again. + //case 'id-qt-cps': + // return $this->CPSuri; + case 'id-qt-unotice': + return $this->UserNotice; + + // the following OIDs are unsupported but we don't want them to give notices when calling saveX509(). + case 'id-pe-logotype': // http://www.ietf.org/rfc/rfc3709.txt + case 'entrustVersInfo': + // http://support.microsoft.com/kb/287547 + case '1.3.6.1.4.1.311.20.2': // szOID_ENROLL_CERTTYPE_EXTENSION + case '1.3.6.1.4.1.311.21.1': // szOID_CERTSRV_CA_VERSION + // "SET Secure Electronic Transaction Specification" + // http://www.maithean.com/docs/set_bk3.pdf + case '2.23.42.7.0': // id-set-hashedRootKey + return true; + + // CSR attributes + case 'pkcs-9-at-unstructuredName': + return $this->PKCS9String; + case 'pkcs-9-at-challengePassword': + return $this->DirectoryString; + case 'pkcs-9-at-extensionRequest': + return $this->Extensions; + + // CRL extensions. + case 'id-ce-cRLNumber': + return $this->CRLNumber; + case 'id-ce-deltaCRLIndicator': + return $this->CRLNumber; + case 'id-ce-issuingDistributionPoint': + return $this->IssuingDistributionPoint; + case 'id-ce-freshestCRL': + return $this->CRLDistributionPoints; + case 'id-ce-cRLReasons': + return $this->CRLReason; + case 'id-ce-invalidityDate': + return $this->InvalidityDate; + case 'id-ce-certificateIssuer': + return $this->CertificateIssuer; + case 'id-ce-holdInstructionCode': + return $this->HoldInstructionCode; + } + + return false; + } + + /** + * Load an X.509 certificate as a certificate authority + * + * @param String $cert + * @access public + * @return Boolean + */ + function loadCA($cert) + { + $olddn = $this->dn; + $oldcert = $this->currentCert; + $oldsigsubj = $this->signatureSubject; + $oldkeyid = $this->currentKeyIdentifier; + + $cert = $this->loadX509($cert); + if (!$cert) { + $this->dn = $olddn; + $this->currentCert = $oldcert; + $this->signatureSubject = $oldsigsubj; + $this->currentKeyIdentifier = $oldkeyid; + + return false; + } + + /* From RFC5280 "PKIX Certificate and CRL Profile": + + If the keyUsage extension is present, then the subject public key + MUST NOT be used to verify signatures on certificates or CRLs unless + the corresponding keyCertSign or cRLSign bit is set. */ + //$keyUsage = $this->getExtension('id-ce-keyUsage'); + //if ($keyUsage && !in_array('keyCertSign', $keyUsage)) { + // return false; + //} + + /* From RFC5280 "PKIX Certificate and CRL Profile": + + The cA boolean indicates whether the certified public key may be used + to verify certificate signatures. If the cA boolean is not asserted, + then the keyCertSign bit in the key usage extension MUST NOT be + asserted. If the basic constraints extension is not present in a + version 3 certificate, or the extension is present but the cA boolean + is not asserted, then the certified public key MUST NOT be used to + verify certificate signatures. */ + //$basicConstraints = $this->getExtension('id-ce-basicConstraints'); + //if (!$basicConstraints || !$basicConstraints['cA']) { + // return false; + //} + + $this->CAs[] = $cert; + + $this->dn = $olddn; + $this->currentCert = $oldcert; + $this->signatureSubject = $oldsigsubj; + + return true; + } + + /** + * Validate an X.509 certificate against a URL + * + * From RFC2818 "HTTP over TLS": + * + * Matching is performed using the matching rules specified by + * [RFC2459]. If more than one identity of a given type is present in + * the certificate (e.g., more than one dNSName name, a match in any one + * of the set is considered acceptable.) Names may contain the wildcard + * character * which is considered to match any single domain name + * component or component fragment. E.g., *.a.com matches foo.a.com but + * not bar.foo.a.com. f*.com matches foo.com but not bar.com. + * + * @param String $url + * @access public + * @return Boolean + */ + function validateURL($url) + { + if (!is_array($this->currentCert) || !isset($this->currentCert['tbsCertificate'])) { + return false; + } + + $components = parse_url($url); + if (!isset($components['host'])) { + return false; + } + + if ($names = $this->getExtension('id-ce-subjectAltName')) { + foreach ($names as $key => $value) { + $value = str_replace(array('.', '*'), array('\.', '[^.]*'), $value); + switch ($key) { + case 'dNSName': + /* From RFC2818 "HTTP over TLS": + + If a subjectAltName extension of type dNSName is present, that MUST + be used as the identity. Otherwise, the (most specific) Common Name + field in the Subject field of the certificate MUST be used. Although + the use of the Common Name is existing practice, it is deprecated and + Certification Authorities are encouraged to use the dNSName instead. */ + if (preg_match('#^' . $value . '$#', $components['host'])) { + return true; + } + break; + case 'iPAddress': + /* From RFC2818 "HTTP over TLS": + + In some cases, the URI is specified as an IP address rather than a + hostname. In this case, the iPAddress subjectAltName must be present + in the certificate and must exactly match the IP in the URI. */ + if (preg_match('#(?:\d{1-3}\.){4}#', $components['host'] . '.') && preg_match('#^' . $value . '$#', $components['host'])) { + return true; + } + } + } + return false; + } + + if ($value = $this->getDNProp('id-at-commonName')) { + $value = str_replace(array('.', '*'), array('\.', '[^.]*'), $value[0]); + return preg_match('#^' . $value . '$#', $components['host']); + } + + return false; + } + + /** + * Validate a date + * + * If $date isn't defined it is assumed to be the current date. + * + * @param Integer $date optional + * @access public + */ + function validateDate($date = null) + { + if (!is_array($this->currentCert) || !isset($this->currentCert['tbsCertificate'])) { + return false; + } + + if (!isset($date)) { + $date = time(); + } + + $notBefore = $this->currentCert['tbsCertificate']['validity']['notBefore']; + $notBefore = isset($notBefore['generalTime']) ? $notBefore['generalTime'] : $notBefore['utcTime']; + + $notAfter = $this->currentCert['tbsCertificate']['validity']['notAfter']; + $notAfter = isset($notAfter['generalTime']) ? $notAfter['generalTime'] : $notAfter['utcTime']; + + switch (true) { + case $date < @strtotime($notBefore): + case $date > @strtotime($notAfter): + return false; + } + + return true; + } + + /** + * Validate a signature + * + * Works on X.509 certs, CSR's and CRL's. + * Returns true if the signature is verified, false if it is not correct or null on error + * + * By default returns false for self-signed certs. Call validateSignature(false) to make this support + * self-signed. + * + * The behavior of this function is inspired by {@link http://php.net/openssl-verify openssl_verify}. + * + * @param Boolean $caonly optional + * @access public + * @return Mixed + */ + function validateSignature($caonly = true) + { + if (!is_array($this->currentCert) || !isset($this->signatureSubject)) { + return null; + } + + /* TODO: + "emailAddress attribute values are not case-sensitive (e.g., "subscriber@example.com" is the same as "SUBSCRIBER@EXAMPLE.COM")." + -- http://tools.ietf.org/html/rfc5280#section-4.1.2.6 + + implement pathLenConstraint in the id-ce-basicConstraints extension */ + + switch (true) { + case isset($this->currentCert['tbsCertificate']): + // self-signed cert + if ($this->currentCert['tbsCertificate']['issuer'] === $this->currentCert['tbsCertificate']['subject']) { + $authorityKey = $this->getExtension('id-ce-authorityKeyIdentifier'); + $subjectKeyID = $this->getExtension('id-ce-subjectKeyIdentifier'); + switch (true) { + case !is_array($authorityKey): + case is_array($authorityKey) && isset($authorityKey['keyIdentifier']) && $authorityKey['keyIdentifier'] === $subjectKeyID: + $signingCert = $this->currentCert; // working cert + } + } + + if (!empty($this->CAs)) { + for ($i = 0; $i < count($this->CAs); $i++) { + // even if the cert is a self-signed one we still want to see if it's a CA; + // if not, we'll conditionally return an error + $ca = $this->CAs[$i]; + if ($this->currentCert['tbsCertificate']['issuer'] === $ca['tbsCertificate']['subject']) { + $authorityKey = $this->getExtension('id-ce-authorityKeyIdentifier'); + $subjectKeyID = $this->getExtension('id-ce-subjectKeyIdentifier', $ca); + switch (true) { + case !is_array($authorityKey): + case is_array($authorityKey) && isset($authorityKey['keyIdentifier']) && $authorityKey['keyIdentifier'] === $subjectKeyID: + $signingCert = $ca; // working cert + break 2; + } + } + } + if (count($this->CAs) == $i && $caonly) { + return false; + } + } elseif (!isset($signingCert) || $caonly) { + return false; + } + return $this->_validateSignature( + $signingCert['tbsCertificate']['subjectPublicKeyInfo']['algorithm']['algorithm'], + $signingCert['tbsCertificate']['subjectPublicKeyInfo']['subjectPublicKey'], + $this->currentCert['signatureAlgorithm']['algorithm'], + substr(base64_decode($this->currentCert['signature']), 1), + $this->signatureSubject + ); + case isset($this->currentCert['certificationRequestInfo']): + return $this->_validateSignature( + $this->currentCert['certificationRequestInfo']['subjectPKInfo']['algorithm']['algorithm'], + $this->currentCert['certificationRequestInfo']['subjectPKInfo']['subjectPublicKey'], + $this->currentCert['signatureAlgorithm']['algorithm'], + substr(base64_decode($this->currentCert['signature']), 1), + $this->signatureSubject + ); + case isset($this->currentCert['publicKeyAndChallenge']): + return $this->_validateSignature( + $this->currentCert['publicKeyAndChallenge']['spki']['algorithm']['algorithm'], + $this->currentCert['publicKeyAndChallenge']['spki']['subjectPublicKey'], + $this->currentCert['signatureAlgorithm']['algorithm'], + substr(base64_decode($this->currentCert['signature']), 1), + $this->signatureSubject + ); + case isset($this->currentCert['tbsCertList']): + if (!empty($this->CAs)) { + for ($i = 0; $i < count($this->CAs); $i++) { + $ca = $this->CAs[$i]; + if ($this->currentCert['tbsCertList']['issuer'] === $ca['tbsCertificate']['subject']) { + $authorityKey = $this->getExtension('id-ce-authorityKeyIdentifier'); + $subjectKeyID = $this->getExtension('id-ce-subjectKeyIdentifier', $ca); + switch (true) { + case !is_array($authorityKey): + case is_array($authorityKey) && isset($authorityKey['keyIdentifier']) && $authorityKey['keyIdentifier'] === $subjectKeyID: + $signingCert = $ca; // working cert + break 2; + } + } + } + } + if (!isset($signingCert)) { + return false; + } + return $this->_validateSignature( + $signingCert['tbsCertificate']['subjectPublicKeyInfo']['algorithm']['algorithm'], + $signingCert['tbsCertificate']['subjectPublicKeyInfo']['subjectPublicKey'], + $this->currentCert['signatureAlgorithm']['algorithm'], + substr(base64_decode($this->currentCert['signature']), 1), + $this->signatureSubject + ); + default: + return false; + } + } + + /** + * Validates a signature + * + * Returns true if the signature is verified, false if it is not correct or null on error + * + * @param String $publicKeyAlgorithm + * @param String $publicKey + * @param String $signatureAlgorithm + * @param String $signature + * @param String $signatureSubject + * @access private + * @return Integer + */ + function _validateSignature($publicKeyAlgorithm, $publicKey, $signatureAlgorithm, $signature, $signatureSubject) + { + switch ($publicKeyAlgorithm) { + case 'rsaEncryption': + if (!class_exists('Crypt_RSA')) { + include_once 'Crypt/RSA.php'; + } + $rsa = new Crypt_RSA(); + $rsa->loadKey($publicKey); + + switch ($signatureAlgorithm) { + case 'md2WithRSAEncryption': + case 'md5WithRSAEncryption': + case 'sha1WithRSAEncryption': + case 'sha224WithRSAEncryption': + case 'sha256WithRSAEncryption': + case 'sha384WithRSAEncryption': + case 'sha512WithRSAEncryption': + $rsa->setHash(preg_replace('#WithRSAEncryption$#', '', $signatureAlgorithm)); + $rsa->setSignatureMode(CRYPT_RSA_SIGNATURE_PKCS1); + if (!@$rsa->verify($signatureSubject, $signature)) { + return false; + } + break; + default: + return null; + } + break; + default: + return null; + } + + return true; + } + + /** + * Reformat public keys + * + * Reformats a public key to a format supported by phpseclib (if applicable) + * + * @param String $algorithm + * @param String $key + * @access private + * @return String + */ + function _reformatKey($algorithm, $key) + { + switch ($algorithm) { + case 'rsaEncryption': + return + "-----BEGIN PUBLIC KEY-----\r\n" . + // subjectPublicKey is stored as a bit string in X.509 certs. the first byte of a bit string represents how many bits + // in the last byte should be ignored. the following only supports non-zero stuff but as none of the X.509 certs Firefox + // uses as a cert authority actually use a non-zero bit I think it's safe to assume that none do. + chunk_split(base64_encode(substr(base64_decode($key), 1)), 64) . + '-----END PUBLIC KEY-----'; + default: + return $key; + } + } + + /** + * Decodes an IP address + * + * Takes in a base64 encoded "blob" and returns a human readable IP address + * + * @param String $ip + * @access private + * @return String + */ + function _decodeIP($ip) + { + $ip = base64_decode($ip); + list(, $ip) = unpack('N', $ip); + return long2ip($ip); + } + + /** + * Encodes an IP address + * + * Takes a human readable IP address into a base64-encoded "blob" + * + * @param String $ip + * @access private + * @return String + */ + function _encodeIP($ip) + { + return base64_encode(pack('N', ip2long($ip))); + } + + /** + * "Normalizes" a Distinguished Name property + * + * @param String $propName + * @access private + * @return Mixed + */ + function _translateDNProp($propName) + { + switch (strtolower($propName)) { + case 'id-at-countryname': + case 'countryname': + case 'c': + return 'id-at-countryName'; + case 'id-at-organizationname': + case 'organizationname': + case 'o': + return 'id-at-organizationName'; + case 'id-at-dnqualifier': + case 'dnqualifier': + return 'id-at-dnQualifier'; + case 'id-at-commonname': + case 'commonname': + case 'cn': + return 'id-at-commonName'; + case 'id-at-stateorprovincename': + case 'stateorprovincename': + case 'state': + case 'province': + case 'provincename': + case 'st': + return 'id-at-stateOrProvinceName'; + case 'id-at-localityname': + case 'localityname': + case 'l': + return 'id-at-localityName'; + case 'id-emailaddress': + case 'emailaddress': + return 'pkcs-9-at-emailAddress'; + case 'id-at-serialnumber': + case 'serialnumber': + return 'id-at-serialNumber'; + case 'id-at-postalcode': + case 'postalcode': + return 'id-at-postalCode'; + case 'id-at-streetaddress': + case 'streetaddress': + return 'id-at-streetAddress'; + case 'id-at-name': + case 'name': + return 'id-at-name'; + case 'id-at-givenname': + case 'givenname': + return 'id-at-givenName'; + case 'id-at-surname': + case 'surname': + case 'sn': + return 'id-at-surname'; + case 'id-at-initials': + case 'initials': + return 'id-at-initials'; + case 'id-at-generationqualifier': + case 'generationqualifier': + return 'id-at-generationQualifier'; + case 'id-at-organizationalunitname': + case 'organizationalunitname': + case 'ou': + return 'id-at-organizationalUnitName'; + case 'id-at-pseudonym': + case 'pseudonym': + return 'id-at-pseudonym'; + case 'id-at-title': + case 'title': + return 'id-at-title'; + case 'id-at-description': + case 'description': + return 'id-at-description'; + case 'id-at-role': + case 'role': + return 'id-at-role'; + case 'id-at-uniqueidentifier': + case 'uniqueidentifier': + case 'x500uniqueidentifier': + return 'id-at-uniqueIdentifier'; + default: + return false; + } + } + + /** + * Set a Distinguished Name property + * + * @param String $propName + * @param Mixed $propValue + * @param String $type optional + * @access public + * @return Boolean + */ + function setDNProp($propName, $propValue, $type = 'utf8String') + { + if (empty($this->dn)) { + $this->dn = array('rdnSequence' => array()); + } + + if (($propName = $this->_translateDNProp($propName)) === false) { + return false; + } + + foreach ((array) $propValue as $v) { + if (!is_array($v) && isset($type)) { + $v = array($type => $v); + } + $this->dn['rdnSequence'][] = array( + array( + 'type' => $propName, + 'value'=> $v + ) + ); + } + + return true; + } + + /** + * Remove Distinguished Name properties + * + * @param String $propName + * @access public + */ + function removeDNProp($propName) + { + if (empty($this->dn)) { + return; + } + + if (($propName = $this->_translateDNProp($propName)) === false) { + return; + } + + $dn = &$this->dn['rdnSequence']; + $size = count($dn); + for ($i = 0; $i < $size; $i++) { + if ($dn[$i][0]['type'] == $propName) { + unset($dn[$i]); + } + } + + $dn = array_values($dn); + } + + /** + * Get Distinguished Name properties + * + * @param String $propName + * @param Array $dn optional + * @param Boolean $withType optional + * @return Mixed + * @access public + */ + function getDNProp($propName, $dn = null, $withType = false) + { + if (!isset($dn)) { + $dn = $this->dn; + } + + if (empty($dn)) { + return false; + } + + if (($propName = $this->_translateDNProp($propName)) === false) { + return false; + } + + $dn = $dn['rdnSequence']; + $result = array(); + $asn1 = new File_ASN1(); + for ($i = 0; $i < count($dn); $i++) { + if ($dn[$i][0]['type'] == $propName) { + $v = $dn[$i][0]['value']; + if (!$withType && is_array($v)) { + foreach ($v as $type => $s) { + $type = array_search($type, $asn1->ANYmap, true); + if ($type !== false && isset($asn1->stringTypeSize[$type])) { + $s = $asn1->convert($s, $type); + if ($s !== false) { + $v = $s; + break; + } + } + } + if (is_array($v)) { + $v = array_pop($v); // Always strip data type. + } + } + $result[] = $v; + } + } + + return $result; + } + + /** + * Set a Distinguished Name + * + * @param Mixed $dn + * @param Boolean $merge optional + * @param String $type optional + * @access public + * @return Boolean + */ + function setDN($dn, $merge = false, $type = 'utf8String') + { + if (!$merge) { + $this->dn = null; + } + + if (is_array($dn)) { + if (isset($dn['rdnSequence'])) { + $this->dn = $dn; // No merge here. + return true; + } + + // handles stuff generated by openssl_x509_parse() + foreach ($dn as $prop => $value) { + if (!$this->setDNProp($prop, $value, $type)) { + return false; + } + } + return true; + } + + // handles everything else + $results = preg_split('#((?:^|, *|/)(?:C=|O=|OU=|CN=|L=|ST=|SN=|postalCode=|streetAddress=|emailAddress=|serialNumber=|organizationalUnitName=|title=|description=|role=|x500UniqueIdentifier=))#', $dn, -1, PREG_SPLIT_DELIM_CAPTURE); + for ($i = 1; $i < count($results); $i+=2) { + $prop = trim($results[$i], ', =/'); + $value = $results[$i + 1]; + if (!$this->setDNProp($prop, $value, $type)) { + return false; + } + } + + return true; + } + + /** + * Get the Distinguished Name for a certificates subject + * + * @param Mixed $format optional + * @param Array $dn optional + * @access public + * @return Boolean + */ + function getDN($format = FILE_X509_DN_ARRAY, $dn = null) + { + if (!isset($dn)) { + $dn = isset($this->currentCert['tbsCertList']) ? $this->currentCert['tbsCertList']['issuer'] : $this->dn; + } + + switch ((int) $format) { + case FILE_X509_DN_ARRAY: + return $dn; + case FILE_X509_DN_ASN1: + $asn1 = new File_ASN1(); + $asn1->loadOIDs($this->oids); + $filters = array(); + $filters['rdnSequence']['value'] = array('type' => FILE_ASN1_TYPE_UTF8_STRING); + $asn1->loadFilters($filters); + return $asn1->encodeDER($dn, $this->Name); + case FILE_X509_DN_OPENSSL: + $dn = $this->getDN(FILE_X509_DN_STRING, $dn); + if ($dn === false) { + return false; + } + $attrs = preg_split('#((?:^|, *|/)[a-z][a-z0-9]*=)#i', $dn, -1, PREG_SPLIT_DELIM_CAPTURE); + $dn = array(); + for ($i = 1; $i < count($attrs); $i += 2) { + $prop = trim($attrs[$i], ', =/'); + $value = $attrs[$i + 1]; + if (!isset($dn[$prop])) { + $dn[$prop] = $value; + } else { + $dn[$prop] = array_merge((array) $dn[$prop], array($value)); + } + } + return $dn; + case FILE_X509_DN_CANON: + // No SEQUENCE around RDNs and all string values normalized as + // trimmed lowercase UTF-8 with all spacing as one blank. + $asn1 = new File_ASN1(); + $asn1->loadOIDs($this->oids); + $filters = array(); + $filters['value'] = array('type' => FILE_ASN1_TYPE_UTF8_STRING); + $asn1->loadFilters($filters); + $result = ''; + foreach ($dn['rdnSequence'] as $rdn) { + foreach ($rdn as &$attr) { + if (is_array($attr['value'])) { + foreach ($attr['value'] as $type => $v) { + $type = array_search($type, $asn1->ANYmap, true); + if ($type !== false && isset($asn1->stringTypeSize[$type])) { + $v = $asn1->convert($v, $type); + if ($v !== false) { + $v = preg_replace('/\s+/', ' ', $v); + $attr['value'] = strtolower(trim($v)); + break; + } + } + } + } + } + $result .= $asn1->encodeDER($rdn, $this->RelativeDistinguishedName); + } + return $result; + case FILE_X509_DN_HASH: + $dn = $this->getDN(FILE_X509_DN_CANON, $dn); + if (!class_exists('Crypt_Hash')) { + include_once 'Crypt/Hash.php'; + } + $hash = new Crypt_Hash('sha1'); + $hash = $hash->hash($dn); + extract(unpack('Vhash', $hash)); + return strtolower(bin2hex(pack('N', $hash))); + } + + // Defaut is to return a string. + $start = true; + $output = ''; + $asn1 = new File_ASN1(); + foreach ($dn['rdnSequence'] as $field) { + $prop = $field[0]['type']; + $value = $field[0]['value']; + + $delim = ', '; + switch ($prop) { + case 'id-at-countryName': + $desc = 'C='; + break; + case 'id-at-stateOrProvinceName': + $desc = 'ST='; + break; + case 'id-at-organizationName': + $desc = 'O='; + break; + case 'id-at-organizationalUnitName': + $desc = 'OU='; + break; + case 'id-at-commonName': + $desc = 'CN='; + break; + case 'id-at-localityName': + $desc = 'L='; + break; + case 'id-at-surname': + $desc = 'SN='; + break; + case 'id-at-uniqueIdentifier': + $delim = '/'; + $desc = 'x500UniqueIdentifier='; + break; + default: + $delim = '/'; + $desc = preg_replace('#.+-([^-]+)$#', '$1', $prop) . '='; + } + + if (!$start) { + $output.= $delim; + } + if (is_array($value)) { + foreach ($value as $type => $v) { + $type = array_search($type, $asn1->ANYmap, true); + if ($type !== false && isset($asn1->stringTypeSize[$type])) { + $v = $asn1->convert($v, $type); + if ($v !== false) { + $value = $v; + break; + } + } + } + if (is_array($value)) { + $value = array_pop($value); // Always strip data type. + } + } + $output.= $desc . $value; + $start = false; + } + + return $output; + } + + /** + * Get the Distinguished Name for a certificate/crl issuer + * + * @param Integer $format optional + * @access public + * @return Mixed + */ + function getIssuerDN($format = FILE_X509_DN_ARRAY) + { + switch (true) { + case !isset($this->currentCert) || !is_array($this->currentCert): + break; + case isset($this->currentCert['tbsCertificate']): + return $this->getDN($format, $this->currentCert['tbsCertificate']['issuer']); + case isset($this->currentCert['tbsCertList']): + return $this->getDN($format, $this->currentCert['tbsCertList']['issuer']); + } + + return false; + } + + /** + * Get the Distinguished Name for a certificate/csr subject + * Alias of getDN() + * + * @param Integer $format optional + * @access public + * @return Mixed + */ + function getSubjectDN($format = FILE_X509_DN_ARRAY) + { + switch (true) { + case !empty($this->dn): + return $this->getDN($format); + case !isset($this->currentCert) || !is_array($this->currentCert): + break; + case isset($this->currentCert['tbsCertificate']): + return $this->getDN($format, $this->currentCert['tbsCertificate']['subject']); + case isset($this->currentCert['certificationRequestInfo']): + return $this->getDN($format, $this->currentCert['certificationRequestInfo']['subject']); + } + + return false; + } + + /** + * Get an individual Distinguished Name property for a certificate/crl issuer + * + * @param String $propName + * @param Boolean $withType optional + * @access public + * @return Mixed + */ + function getIssuerDNProp($propName, $withType = false) + { + switch (true) { + case !isset($this->currentCert) || !is_array($this->currentCert): + break; + case isset($this->currentCert['tbsCertificate']): + return $this->getDNProp($propName, $this->currentCert['tbsCertificate']['issuer'], $withType); + case isset($this->currentCert['tbsCertList']): + return $this->getDNProp($propName, $this->currentCert['tbsCertList']['issuer'], $withType); + } + + return false; + } + + /** + * Get an individual Distinguished Name property for a certificate/csr subject + * + * @param String $propName + * @param Boolean $withType optional + * @access public + * @return Mixed + */ + function getSubjectDNProp($propName, $withType = false) + { + switch (true) { + case !empty($this->dn): + return $this->getDNProp($propName, null, $withType); + case !isset($this->currentCert) || !is_array($this->currentCert): + break; + case isset($this->currentCert['tbsCertificate']): + return $this->getDNProp($propName, $this->currentCert['tbsCertificate']['subject'], $withType); + case isset($this->currentCert['certificationRequestInfo']): + return $this->getDNProp($propName, $this->currentCert['certificationRequestInfo']['subject'], $withType); + } + + return false; + } + + /** + * Get the certificate chain for the current cert + * + * @access public + * @return Mixed + */ + function getChain() + { + $chain = array($this->currentCert); + + if (!is_array($this->currentCert) || !isset($this->currentCert['tbsCertificate'])) { + return false; + } + if (empty($this->CAs)) { + return $chain; + } + while (true) { + $currentCert = $chain[count($chain) - 1]; + for ($i = 0; $i < count($this->CAs); $i++) { + $ca = $this->CAs[$i]; + if ($currentCert['tbsCertificate']['issuer'] === $ca['tbsCertificate']['subject']) { + $authorityKey = $this->getExtension('id-ce-authorityKeyIdentifier', $currentCert); + $subjectKeyID = $this->getExtension('id-ce-subjectKeyIdentifier', $ca); + switch (true) { + case !is_array($authorityKey): + case is_array($authorityKey) && isset($authorityKey['keyIdentifier']) && $authorityKey['keyIdentifier'] === $subjectKeyID: + if ($currentCert === $ca) { + break 3; + } + $chain[] = $ca; + break 2; + } + } + } + if ($i == count($this->CAs)) { + break; + } + } + foreach ($chain as $key=>$value) { + $chain[$key] = new File_X509(); + $chain[$key]->loadX509($value); + } + return $chain; + } + + /** + * Set public key + * + * Key needs to be a Crypt_RSA object + * + * @param Object $key + * @access public + * @return Boolean + */ + function setPublicKey($key) + { + $key->setPublicKey(); + $this->publicKey = $key; + } + + /** + * Set private key + * + * Key needs to be a Crypt_RSA object + * + * @param Object $key + * @access public + */ + function setPrivateKey($key) + { + $this->privateKey = $key; + } + + /** + * Gets the public key + * + * Returns a Crypt_RSA object or a false. + * + * @access public + * @return Mixed + */ + function getPublicKey() + { + if (isset($this->publicKey)) { + return $this->publicKey; + } + + if (isset($this->currentCert) && is_array($this->currentCert)) { + foreach (array('tbsCertificate/subjectPublicKeyInfo', 'certificationRequestInfo/subjectPKInfo') as $path) { + $keyinfo = $this->_subArray($this->currentCert, $path); + if (!empty($keyinfo)) { + break; + } + } + } + if (empty($keyinfo)) { + return false; + } + + $key = $keyinfo['subjectPublicKey']; + + switch ($keyinfo['algorithm']['algorithm']) { + case 'rsaEncryption': + if (!class_exists('Crypt_RSA')) { + include_once 'Crypt/RSA.php'; + } + $publicKey = new Crypt_RSA(); + $publicKey->loadKey($key); + $publicKey->setPublicKey(); + break; + default: + return false; + } + + return $publicKey; + } + + /** + * Load a Certificate Signing Request + * + * @param String $csr + * @access public + * @return Mixed + */ + function loadCSR($csr) + { + if (is_array($csr) && isset($csr['certificationRequestInfo'])) { + unset($this->currentCert); + unset($this->currentKeyIdentifier); + unset($this->signatureSubject); + $this->dn = $csr['certificationRequestInfo']['subject']; + if (!isset($this->dn)) { + return false; + } + + $this->currentCert = $csr; + return $csr; + } + + // see http://tools.ietf.org/html/rfc2986 + + $asn1 = new File_ASN1(); + + $csr = $this->_extractBER($csr); + $orig = $csr; + + if ($csr === false) { + $this->currentCert = false; + return false; + } + + $asn1->loadOIDs($this->oids); + $decoded = $asn1->decodeBER($csr); + + if (empty($decoded)) { + $this->currentCert = false; + return false; + } + + $csr = $asn1->asn1map($decoded[0], $this->CertificationRequest); + if (!isset($csr) || $csr === false) { + $this->currentCert = false; + return false; + } + + $this->dn = $csr['certificationRequestInfo']['subject']; + $this->_mapInAttributes($csr, 'certificationRequestInfo/attributes', $asn1); + + $this->signatureSubject = substr($orig, $decoded[0]['content'][0]['start'], $decoded[0]['content'][0]['length']); + + $algorithm = &$csr['certificationRequestInfo']['subjectPKInfo']['algorithm']['algorithm']; + $key = &$csr['certificationRequestInfo']['subjectPKInfo']['subjectPublicKey']; + $key = $this->_reformatKey($algorithm, $key); + + switch ($algorithm) { + case 'rsaEncryption': + if (!class_exists('Crypt_RSA')) { + include_once 'Crypt/RSA.php'; + } + $this->publicKey = new Crypt_RSA(); + $this->publicKey->loadKey($key); + $this->publicKey->setPublicKey(); + break; + default: + $this->publicKey = null; + } + + $this->currentKeyIdentifier = null; + $this->currentCert = $csr; + + return $csr; + } + + /** + * Save CSR request + * + * @param Array $csr + * @param Integer $format optional + * @access public + * @return String + */ + function saveCSR($csr, $format = FILE_X509_FORMAT_PEM) + { + if (!is_array($csr) || !isset($csr['certificationRequestInfo'])) { + return false; + } + + switch (true) { + case !($algorithm = $this->_subArray($csr, 'certificationRequestInfo/subjectPKInfo/algorithm/algorithm')): + case is_object($csr['certificationRequestInfo']['subjectPKInfo']['subjectPublicKey']); + break; + default: + switch ($algorithm) { + case 'rsaEncryption': + $csr['certificationRequestInfo']['subjectPKInfo']['subjectPublicKey'] + = base64_encode("\0" . base64_decode(preg_replace('#-.+-|[\r\n]#', '', $csr['certificationRequestInfo']['subjectPKInfo']['subjectPublicKey']))); + } + } + + $asn1 = new File_ASN1(); + + $asn1->loadOIDs($this->oids); + + $filters = array(); + $filters['certificationRequestInfo']['subject']['rdnSequence']['value'] + = array('type' => FILE_ASN1_TYPE_UTF8_STRING); + + $asn1->loadFilters($filters); + + $this->_mapOutAttributes($csr, 'certificationRequestInfo/attributes', $asn1); + $csr = $asn1->encodeDER($csr, $this->CertificationRequest); + + switch ($format) { + case FILE_X509_FORMAT_DER: + return $csr; + // case FILE_X509_FORMAT_PEM: + default: + return "-----BEGIN CERTIFICATE REQUEST-----\r\n" . chunk_split(base64_encode($csr), 64) . '-----END CERTIFICATE REQUEST-----'; + } + } + + /** + * Load a SPKAC CSR + * + * SPKAC's are produced by the HTML5 keygen element: + * + * https://developer.mozilla.org/en-US/docs/HTML/Element/keygen + * + * @param String $csr + * @access public + * @return Mixed + */ + function loadSPKAC($spkac) + { + if (is_array($spkac) && isset($spkac['publicKeyAndChallenge'])) { + unset($this->currentCert); + unset($this->currentKeyIdentifier); + unset($this->signatureSubject); + $this->currentCert = $spkac; + return $spkac; + } + + // see http://www.w3.org/html/wg/drafts/html/master/forms.html#signedpublickeyandchallenge + + $asn1 = new File_ASN1(); + + $temp = preg_replace('#(?:^[^=]+=)|[\r\n\\\]#', '', $spkac); + $temp = preg_match('#^[a-zA-Z\d/+]*={0,2}$#', $temp) ? base64_decode($temp) : false; + if ($temp != false) { + $spkac = $temp; + } + $orig = $spkac; + + if ($spkac === false) { + $this->currentCert = false; + return false; + } + + $asn1->loadOIDs($this->oids); + $decoded = $asn1->decodeBER($spkac); + + if (empty($decoded)) { + $this->currentCert = false; + return false; + } + + $spkac = $asn1->asn1map($decoded[0], $this->SignedPublicKeyAndChallenge); + + if (!isset($spkac) || $spkac === false) { + $this->currentCert = false; + return false; + } + + $this->signatureSubject = substr($orig, $decoded[0]['content'][0]['start'], $decoded[0]['content'][0]['length']); + + $algorithm = &$spkac['publicKeyAndChallenge']['spki']['algorithm']['algorithm']; + $key = &$spkac['publicKeyAndChallenge']['spki']['subjectPublicKey']; + $key = $this->_reformatKey($algorithm, $key); + + switch ($algorithm) { + case 'rsaEncryption': + if (!class_exists('Crypt_RSA')) { + include_once 'Crypt/RSA.php'; + } + $this->publicKey = new Crypt_RSA(); + $this->publicKey->loadKey($key); + $this->publicKey->setPublicKey(); + break; + default: + $this->publicKey = null; + } + + $this->currentKeyIdentifier = null; + $this->currentCert = $spkac; + + return $spkac; + } + + /** + * Load a Certificate Revocation List + * + * @param String $crl + * @access public + * @return Mixed + */ + function loadCRL($crl) + { + if (is_array($crl) && isset($crl['tbsCertList'])) { + $this->currentCert = $crl; + unset($this->signatureSubject); + return $crl; + } + + $asn1 = new File_ASN1(); + + $crl = $this->_extractBER($crl); + $orig = $crl; + + if ($crl === false) { + $this->currentCert = false; + return false; + } + + $asn1->loadOIDs($this->oids); + $decoded = $asn1->decodeBER($crl); + + if (empty($decoded)) { + $this->currentCert = false; + return false; + } + + $crl = $asn1->asn1map($decoded[0], $this->CertificateList); + if (!isset($crl) || $crl === false) { + $this->currentCert = false; + return false; + } + + $this->signatureSubject = substr($orig, $decoded[0]['content'][0]['start'], $decoded[0]['content'][0]['length']); + + $this->_mapInExtensions($crl, 'tbsCertList/crlExtensions', $asn1); + $rclist = &$this->_subArray($crl, 'tbsCertList/revokedCertificates'); + if (is_array($rclist)) { + foreach ($rclist as $i => $extension) { + $this->_mapInExtensions($rclist, "$i/crlEntryExtensions", $asn1); + } + } + + $this->currentKeyIdentifier = null; + $this->currentCert = $crl; + + return $crl; + } + + /** + * Save Certificate Revocation List. + * + * @param Array $crl + * @param Integer $format optional + * @access public + * @return String + */ + function saveCRL($crl, $format = FILE_X509_FORMAT_PEM) + { + if (!is_array($crl) || !isset($crl['tbsCertList'])) { + return false; + } + + $asn1 = new File_ASN1(); + + $asn1->loadOIDs($this->oids); + + $filters = array(); + $filters['tbsCertList']['issuer']['rdnSequence']['value'] + = array('type' => FILE_ASN1_TYPE_UTF8_STRING); + $filters['tbsCertList']['signature']['parameters'] + = array('type' => FILE_ASN1_TYPE_UTF8_STRING); + $filters['signatureAlgorithm']['parameters'] + = array('type' => FILE_ASN1_TYPE_UTF8_STRING); + + if (empty($crl['tbsCertList']['signature']['parameters'])) { + $filters['tbsCertList']['signature']['parameters'] + = array('type' => FILE_ASN1_TYPE_NULL); + } + + if (empty($crl['signatureAlgorithm']['parameters'])) { + $filters['signatureAlgorithm']['parameters'] + = array('type' => FILE_ASN1_TYPE_NULL); + } + + $asn1->loadFilters($filters); + + $this->_mapOutExtensions($crl, 'tbsCertList/crlExtensions', $asn1); + $rclist = &$this->_subArray($crl, 'tbsCertList/revokedCertificates'); + if (is_array($rclist)) { + foreach ($rclist as $i => $extension) { + $this->_mapOutExtensions($rclist, "$i/crlEntryExtensions", $asn1); + } + } + + $crl = $asn1->encodeDER($crl, $this->CertificateList); + + switch ($format) { + case FILE_X509_FORMAT_DER: + return $crl; + // case FILE_X509_FORMAT_PEM: + default: + return "-----BEGIN X509 CRL-----\r\n" . chunk_split(base64_encode($crl), 64) . '-----END X509 CRL-----'; + } + } + + /** + * Sign an X.509 certificate + * + * $issuer's private key needs to be loaded. + * $subject can be either an existing X.509 cert (if you want to resign it), + * a CSR or something with the DN and public key explicitly set. + * + * @param File_X509 $issuer + * @param File_X509 $subject + * @param String $signatureAlgorithm optional + * @access public + * @return Mixed + */ + function sign($issuer, $subject, $signatureAlgorithm = 'sha1WithRSAEncryption') + { + if (!is_object($issuer->privateKey) || empty($issuer->dn)) { + return false; + } + + if (isset($subject->publicKey) && !($subjectPublicKey = $subject->_formatSubjectPublicKey())) { + return false; + } + + $currentCert = isset($this->currentCert) ? $this->currentCert : null; + $signatureSubject = isset($this->signatureSubject) ? $this->signatureSubject: null; + + if (isset($subject->currentCert) && is_array($subject->currentCert) && isset($subject->currentCert['tbsCertificate'])) { + $this->currentCert = $subject->currentCert; + $this->currentCert['tbsCertificate']['signature']['algorithm'] = $signatureAlgorithm; + $this->currentCert['signatureAlgorithm']['algorithm'] = $signatureAlgorithm; + + if (!empty($this->startDate)) { + $this->currentCert['tbsCertificate']['validity']['notBefore']['generalTime'] = $this->startDate; + unset($this->currentCert['tbsCertificate']['validity']['notBefore']['utcTime']); + } + if (!empty($this->endDate)) { + $this->currentCert['tbsCertificate']['validity']['notAfter']['generalTime'] = $this->endDate; + unset($this->currentCert['tbsCertificate']['validity']['notAfter']['utcTime']); + } + if (!empty($this->serialNumber)) { + $this->currentCert['tbsCertificate']['serialNumber'] = $this->serialNumber; + } + if (!empty($subject->dn)) { + $this->currentCert['tbsCertificate']['subject'] = $subject->dn; + } + if (!empty($subject->publicKey)) { + $this->currentCert['tbsCertificate']['subjectPublicKeyInfo'] = $subjectPublicKey; + } + $this->removeExtension('id-ce-authorityKeyIdentifier'); + if (isset($subject->domains)) { + $this->removeExtension('id-ce-subjectAltName'); + } + } else if (isset($subject->currentCert) && is_array($subject->currentCert) && isset($subject->currentCert['tbsCertList'])) { + return false; + } else { + if (!isset($subject->publicKey)) { + return false; + } + + $startDate = !empty($this->startDate) ? $this->startDate : @date('D, d M y H:i:s O'); + $endDate = !empty($this->endDate) ? $this->endDate : @date('D, d M y H:i:s O', strtotime('+1 year')); + $serialNumber = !empty($this->serialNumber) ? $this->serialNumber : new Math_BigInteger(); + + $this->currentCert = array( + 'tbsCertificate' => + array( + 'version' => 'v3', + 'serialNumber' => $serialNumber, // $this->setserialNumber() + 'signature' => array('algorithm' => $signatureAlgorithm), + 'issuer' => false, // this is going to be overwritten later + 'validity' => array( + 'notBefore' => array('generalTime' => $startDate), // $this->setStartDate() + 'notAfter' => array('generalTime' => $endDate) // $this->setEndDate() + ), + 'subject' => $subject->dn, + 'subjectPublicKeyInfo' => $subjectPublicKey + ), + 'signatureAlgorithm' => array('algorithm' => $signatureAlgorithm), + 'signature' => false // this is going to be overwritten later + ); + + // Copy extensions from CSR. + $csrexts = $subject->getAttribute('pkcs-9-at-extensionRequest', 0); + + if (!empty($csrexts)) { + $this->currentCert['tbsCertificate']['extensions'] = $csrexts; + } + } + + $this->currentCert['tbsCertificate']['issuer'] = $issuer->dn; + + if (isset($issuer->currentKeyIdentifier)) { + $this->setExtension('id-ce-authorityKeyIdentifier', array( + //'authorityCertIssuer' => array( + // array( + // 'directoryName' => $issuer->dn + // ) + //), + 'keyIdentifier' => $issuer->currentKeyIdentifier + ) + ); + //$extensions = &$this->currentCert['tbsCertificate']['extensions']; + //if (isset($issuer->serialNumber)) { + // $extensions[count($extensions) - 1]['authorityCertSerialNumber'] = $issuer->serialNumber; + //} + //unset($extensions); + } + + if (isset($subject->currentKeyIdentifier)) { + $this->setExtension('id-ce-subjectKeyIdentifier', $subject->currentKeyIdentifier); + } + + $altName = array(); + + if (isset($subject->domains) && count($subject->domains) > 1) { + $altName = array_map(array('File_X509', '_dnsName'), $subject->domains); + } + + if (isset($subject->ipAddresses) && count($subject->ipAddresses)) { + // should an IP address appear as the CN if no domain name is specified? idk + //$ips = count($subject->domains) ? $subject->ipAddresses : array_slice($subject->ipAddresses, 1); + $ipAddresses = array(); + foreach ($subject->ipAddresses as $ipAddress) { + $encoded = $subject->_ipAddress($ipAddress); + if ($encoded !== false) { + $ipAddresses[] = $encoded; + } + } + if (count($ipAddresses)) { + $altName = array_merge($altName, $ipAddresses); + } + } + + if (!empty($altName)) { + $this->setExtension('id-ce-subjectAltName', $altName); + } + + if ($this->caFlag) { + $keyUsage = $this->getExtension('id-ce-keyUsage'); + if (!$keyUsage) { + $keyUsage = array(); + } + + $this->setExtension('id-ce-keyUsage', + array_values(array_unique(array_merge($keyUsage, array('cRLSign', 'keyCertSign')))) + ); + + $basicConstraints = $this->getExtension('id-ce-basicConstraints'); + if (!$basicConstraints) { + $basicConstraints = array(); + } + + $this->setExtension('id-ce-basicConstraints', + array_unique(array_merge(array('cA' => true), $basicConstraints)), true); + + if (!isset($subject->currentKeyIdentifier)) { + $this->setExtension('id-ce-subjectKeyIdentifier', base64_encode($this->computeKeyIdentifier($this->currentCert)), false, false); + } + } + + // resync $this->signatureSubject + // save $tbsCertificate in case there are any File_ASN1_Element objects in it + $tbsCertificate = $this->currentCert['tbsCertificate']; + $this->loadX509($this->saveX509($this->currentCert)); + + $result = $this->_sign($issuer->privateKey, $signatureAlgorithm); + $result['tbsCertificate'] = $tbsCertificate; + + $this->currentCert = $currentCert; + $this->signatureSubject = $signatureSubject; + + return $result; + } + + /** + * Sign a CSR + * + * @access public + * @return Mixed + */ + function signCSR($signatureAlgorithm = 'sha1WithRSAEncryption') + { + if (!is_object($this->privateKey) || empty($this->dn)) { + return false; + } + + $origPublicKey = $this->publicKey; + $class = get_class($this->privateKey); + $this->publicKey = new $class(); + $this->publicKey->loadKey($this->privateKey->getPublicKey()); + $this->publicKey->setPublicKey(); + if (!($publicKey = $this->_formatSubjectPublicKey())) { + return false; + } + $this->publicKey = $origPublicKey; + + $currentCert = isset($this->currentCert) ? $this->currentCert : null; + $signatureSubject = isset($this->signatureSubject) ? $this->signatureSubject: null; + + if (isset($this->currentCert) && is_array($this->currentCert) && isset($this->currentCert['certificationRequestInfo'])) { + $this->currentCert['signatureAlgorithm']['algorithm'] = $signatureAlgorithm; + if (!empty($this->dn)) { + $this->currentCert['certificationRequestInfo']['subject'] = $this->dn; + } + $this->currentCert['certificationRequestInfo']['subjectPKInfo'] = $publicKey; + } else { + $this->currentCert = array( + 'certificationRequestInfo' => + array( + 'version' => 'v1', + 'subject' => $this->dn, + 'subjectPKInfo' => $publicKey + ), + 'signatureAlgorithm' => array('algorithm' => $signatureAlgorithm), + 'signature' => false // this is going to be overwritten later + ); + } + + // resync $this->signatureSubject + // save $certificationRequestInfo in case there are any File_ASN1_Element objects in it + $certificationRequestInfo = $this->currentCert['certificationRequestInfo']; + $this->loadCSR($this->saveCSR($this->currentCert)); + + $result = $this->_sign($this->privateKey, $signatureAlgorithm); + $result['certificationRequestInfo'] = $certificationRequestInfo; + + $this->currentCert = $currentCert; + $this->signatureSubject = $signatureSubject; + + return $result; + } + + /** + * Sign a CRL + * + * $issuer's private key needs to be loaded. + * + * @param File_X509 $issuer + * @param File_X509 $crl + * @param String $signatureAlgorithm optional + * @access public + * @return Mixed + */ + function signCRL($issuer, $crl, $signatureAlgorithm = 'sha1WithRSAEncryption') + { + if (!is_object($issuer->privateKey) || empty($issuer->dn)) { + return false; + } + + $currentCert = isset($this->currentCert) ? $this->currentCert : null; + $signatureSubject = isset($this->signatureSubject) ? $this->signatureSubject : null; + $thisUpdate = !empty($this->startDate) ? $this->startDate : @date('D, d M y H:i:s O'); + + if (isset($crl->currentCert) && is_array($crl->currentCert) && isset($crl->currentCert['tbsCertList'])) { + $this->currentCert = $crl->currentCert; + $this->currentCert['tbsCertList']['signature']['algorithm'] = $signatureAlgorithm; + $this->currentCert['signatureAlgorithm']['algorithm'] = $signatureAlgorithm; + } else { + $this->currentCert = array( + 'tbsCertList' => + array( + 'version' => 'v2', + 'signature' => array('algorithm' => $signatureAlgorithm), + 'issuer' => false, // this is going to be overwritten later + 'thisUpdate' => array('generalTime' => $thisUpdate) // $this->setStartDate() + ), + 'signatureAlgorithm' => array('algorithm' => $signatureAlgorithm), + 'signature' => false // this is going to be overwritten later + ); + } + + $tbsCertList = &$this->currentCert['tbsCertList']; + $tbsCertList['issuer'] = $issuer->dn; + $tbsCertList['thisUpdate'] = array('generalTime' => $thisUpdate); + + if (!empty($this->endDate)) { + $tbsCertList['nextUpdate'] = array('generalTime' => $this->endDate); // $this->setEndDate() + } else { + unset($tbsCertList['nextUpdate']); + } + + if (!empty($this->serialNumber)) { + $crlNumber = $this->serialNumber; + } else { + $crlNumber = $this->getExtension('id-ce-cRLNumber'); + $crlNumber = $crlNumber !== false ? $crlNumber->add(new Math_BigInteger(1)) : null; + } + + $this->removeExtension('id-ce-authorityKeyIdentifier'); + $this->removeExtension('id-ce-issuerAltName'); + + // Be sure version >= v2 if some extension found. + $version = isset($tbsCertList['version']) ? $tbsCertList['version'] : 0; + if (!$version) { + if (!empty($tbsCertList['crlExtensions'])) { + $version = 1; // v2. + } elseif (!empty($tbsCertList['revokedCertificates'])) { + foreach ($tbsCertList['revokedCertificates'] as $cert) { + if (!empty($cert['crlEntryExtensions'])) { + $version = 1; // v2. + } + } + } + + if ($version) { + $tbsCertList['version'] = $version; + } + } + + // Store additional extensions. + if (!empty($tbsCertList['version'])) { // At least v2. + if (!empty($crlNumber)) { + $this->setExtension('id-ce-cRLNumber', $crlNumber); + } + + if (isset($issuer->currentKeyIdentifier)) { + $this->setExtension('id-ce-authorityKeyIdentifier', array( + //'authorityCertIssuer' => array( + // array( + // 'directoryName' => $issuer->dn + // ) + //), + 'keyIdentifier' => $issuer->currentKeyIdentifier + ) + ); + //$extensions = &$tbsCertList['crlExtensions']; + //if (isset($issuer->serialNumber)) { + // $extensions[count($extensions) - 1]['authorityCertSerialNumber'] = $issuer->serialNumber; + //} + //unset($extensions); + } + + $issuerAltName = $this->getExtension('id-ce-subjectAltName', $issuer->currentCert); + + if ($issuerAltName !== false) { + $this->setExtension('id-ce-issuerAltName', $issuerAltName); + } + } + + if (empty($tbsCertList['revokedCertificates'])) { + unset($tbsCertList['revokedCertificates']); + } + + unset($tbsCertList); + + // resync $this->signatureSubject + // save $tbsCertList in case there are any File_ASN1_Element objects in it + $tbsCertList = $this->currentCert['tbsCertList']; + $this->loadCRL($this->saveCRL($this->currentCert)); + + $result = $this->_sign($issuer->privateKey, $signatureAlgorithm); + $result['tbsCertList'] = $tbsCertList; + + $this->currentCert = $currentCert; + $this->signatureSubject = $signatureSubject; + + return $result; + } + + /** + * X.509 certificate signing helper function. + * + * @param Object $key + * @param File_X509 $subject + * @param String $signatureAlgorithm + * @access public + * @return Mixed + */ + function _sign($key, $signatureAlgorithm) + { + switch (strtolower(get_class($key))) { + case 'crypt_rsa': + switch ($signatureAlgorithm) { + case 'md2WithRSAEncryption': + case 'md5WithRSAEncryption': + case 'sha1WithRSAEncryption': + case 'sha224WithRSAEncryption': + case 'sha256WithRSAEncryption': + case 'sha384WithRSAEncryption': + case 'sha512WithRSAEncryption': + $key->setHash(preg_replace('#WithRSAEncryption$#', '', $signatureAlgorithm)); + $key->setSignatureMode(CRYPT_RSA_SIGNATURE_PKCS1); + + $this->currentCert['signature'] = base64_encode("\0" . $key->sign($this->signatureSubject)); + return $this->currentCert; + } + default: + return false; + } + } + + /** + * Set certificate start date + * + * @param String $date + * @access public + */ + function setStartDate($date) + { + $this->startDate = @date('D, d M y H:i:s O', @strtotime($date)); + } + + /** + * Set certificate end date + * + * @param String $date + * @access public + */ + function setEndDate($date) + { + /* + To indicate that a certificate has no well-defined expiration date, + the notAfter SHOULD be assigned the GeneralizedTime value of + 99991231235959Z. + + -- http://tools.ietf.org/html/rfc5280#section-4.1.2.5 + */ + if (strtolower($date) == 'lifetime') { + $temp = '99991231235959Z'; + $asn1 = new File_ASN1(); + $temp = chr(FILE_ASN1_TYPE_GENERALIZED_TIME) . $asn1->_encodeLength(strlen($temp)) . $temp; + $this->endDate = new File_ASN1_Element($temp); + } else { + $this->endDate = @date('D, d M y H:i:s O', @strtotime($date)); + } + } + + /** + * Set Serial Number + * + * @param String $serial + * @param $base optional + * @access public + */ + function setSerialNumber($serial, $base = -256) + { + $this->serialNumber = new Math_BigInteger($serial, $base); + } + + /** + * Turns the certificate into a certificate authority + * + * @access public + */ + function makeCA() + { + $this->caFlag = true; + } + + /** + * Get a reference to a subarray + * + * @param array $root + * @param String $path absolute path with / as component separator + * @param Boolean $create optional + * @access private + * @return array item ref or false + */ + function &_subArray(&$root, $path, $create = false) + { + $false = false; + + if (!is_array($root)) { + return $false; + } + + foreach (explode('/', $path) as $i) { + if (!is_array($root)) { + return $false; + } + + if (!isset($root[$i])) { + if (!$create) { + return $false; + } + + $root[$i] = array(); + } + + $root = &$root[$i]; + } + + return $root; + } + + /** + * Get a reference to an extension subarray + * + * @param array $root + * @param String $path optional absolute path with / as component separator + * @param Boolean $create optional + * @access private + * @return array ref or false + */ + function &_extensions(&$root, $path = null, $create = false) + { + if (!isset($root)) { + $root = $this->currentCert; + } + + switch (true) { + case !empty($path): + case !is_array($root): + break; + case isset($root['tbsCertificate']): + $path = 'tbsCertificate/extensions'; + break; + case isset($root['tbsCertList']): + $path = 'tbsCertList/crlExtensions'; + break; + case isset($root['certificationRequestInfo']): + $pth = 'certificationRequestInfo/attributes'; + $attributes = &$this->_subArray($root, $pth, $create); + + if (is_array($attributes)) { + foreach ($attributes as $key => $value) { + if ($value['type'] == 'pkcs-9-at-extensionRequest') { + $path = "$pth/$key/value/0"; + break 2; + } + } + if ($create) { + $key = count($attributes); + $attributes[] = array('type' => 'pkcs-9-at-extensionRequest', 'value' => array()); + $path = "$pth/$key/value/0"; + } + } + break; + } + + $extensions = &$this->_subArray($root, $path, $create); + + if (!is_array($extensions)) { + $false = false; + return $false; + } + + return $extensions; + } + + /** + * Remove an Extension + * + * @param String $id + * @param String $path optional + * @access private + * @return Boolean + */ + function _removeExtension($id, $path = null) + { + $extensions = &$this->_extensions($this->currentCert, $path); + + if (!is_array($extensions)) { + return false; + } + + $result = false; + foreach ($extensions as $key => $value) { + if ($value['extnId'] == $id) { + unset($extensions[$key]); + $result = true; + } + } + + $extensions = array_values($extensions); + return $result; + } + + /** + * Get an Extension + * + * Returns the extension if it exists and false if not + * + * @param String $id + * @param Array $cert optional + * @param String $path optional + * @access private + * @return Mixed + */ + function _getExtension($id, $cert = null, $path = null) + { + $extensions = $this->_extensions($cert, $path); + + if (!is_array($extensions)) { + return false; + } + + foreach ($extensions as $key => $value) { + if ($value['extnId'] == $id) { + return $value['extnValue']; + } + } + + return false; + } + + /** + * Returns a list of all extensions in use + * + * @param array $cert optional + * @param String $path optional + * @access private + * @return Array + */ + function _getExtensions($cert = null, $path = null) + { + $exts = $this->_extensions($cert, $path); + $extensions = array(); + + if (is_array($exts)) { + foreach ($exts as $extension) { + $extensions[] = $extension['extnId']; + } + } + + return $extensions; + } + + /** + * Set an Extension + * + * @param String $id + * @param Mixed $value + * @param Boolean $critical optional + * @param Boolean $replace optional + * @param String $path optional + * @access private + * @return Boolean + */ + function _setExtension($id, $value, $critical = false, $replace = true, $path = null) + { + $extensions = &$this->_extensions($this->currentCert, $path, true); + + if (!is_array($extensions)) { + return false; + } + + $newext = array('extnId' => $id, 'critical' => $critical, 'extnValue' => $value); + + foreach ($extensions as $key => $value) { + if ($value['extnId'] == $id) { + if (!$replace) { + return false; + } + + $extensions[$key] = $newext; + return true; + } + } + + $extensions[] = $newext; + return true; + } + + /** + * Remove a certificate, CSR or CRL Extension + * + * @param String $id + * @access public + * @return Boolean + */ + function removeExtension($id) + { + return $this->_removeExtension($id); + } + + /** + * Get a certificate, CSR or CRL Extension + * + * Returns the extension if it exists and false if not + * + * @param String $id + * @param Array $cert optional + * @access public + * @return Mixed + */ + function getExtension($id, $cert = null) + { + return $this->_getExtension($id, $cert); + } + + /** + * Returns a list of all extensions in use in certificate, CSR or CRL + * + * @param array $cert optional + * @access public + * @return Array + */ + function getExtensions($cert = null) + { + return $this->_getExtensions($cert); + } + + /** + * Set a certificate, CSR or CRL Extension + * + * @param String $id + * @param Mixed $value + * @param Boolean $critical optional + * @param Boolean $replace optional + * @access public + * @return Boolean + */ + function setExtension($id, $value, $critical = false, $replace = true) + { + return $this->_setExtension($id, $value, $critical, $replace); + } + + /** + * Remove a CSR attribute. + * + * @param String $id + * @param Integer $disposition optional + * @access public + * @return Boolean + */ + function removeAttribute($id, $disposition = FILE_X509_ATTR_ALL) + { + $attributes = &$this->_subArray($this->currentCert, 'certificationRequestInfo/attributes'); + + if (!is_array($attributes)) { + return false; + } + + $result = false; + foreach ($attributes as $key => $attribute) { + if ($attribute['type'] == $id) { + $n = count($attribute['value']); + switch (true) { + case $disposition == FILE_X509_ATTR_APPEND: + case $disposition == FILE_X509_ATTR_REPLACE: + return false; + case $disposition >= $n: + $disposition -= $n; + break; + case $disposition == FILE_X509_ATTR_ALL: + case $n == 1: + unset($attributes[$key]); + $result = true; + break; + default: + unset($attributes[$key]['value'][$disposition]); + $attributes[$key]['value'] = array_values($attributes[$key]['value']); + $result = true; + break; + } + if ($result && $disposition != FILE_X509_ATTR_ALL) { + break; + } + } + } + + $attributes = array_values($attributes); + return $result; + } + + /** + * Get a CSR attribute + * + * Returns the attribute if it exists and false if not + * + * @param String $id + * @param Integer $disposition optional + * @param Array $csr optional + * @access public + * @return Mixed + */ + function getAttribute($id, $disposition = FILE_X509_ATTR_ALL, $csr = null) + { + if (empty($csr)) { + $csr = $this->currentCert; + } + + $attributes = $this->_subArray($csr, 'certificationRequestInfo/attributes'); + + if (!is_array($attributes)) { + return false; + } + + foreach ($attributes as $key => $attribute) { + if ($attribute['type'] == $id) { + $n = count($attribute['value']); + switch (true) { + case $disposition == FILE_X509_ATTR_APPEND: + case $disposition == FILE_X509_ATTR_REPLACE: + return false; + case $disposition == FILE_X509_ATTR_ALL: + return $attribute['value']; + case $disposition >= $n: + $disposition -= $n; + break; + default: + return $attribute['value'][$disposition]; + } + } + } + + return false; + } + + /** + * Returns a list of all CSR attributes in use + * + * @param array $csr optional + * @access public + * @return Array + */ + function getAttributes($csr = null) + { + if (empty($csr)) { + $csr = $this->currentCert; + } + + $attributes = $this->_subArray($csr, 'certificationRequestInfo/attributes'); + $attrs = array(); + + if (is_array($attributes)) { + foreach ($attributes as $attribute) { + $attrs[] = $attribute['type']; + } + } + + return $attrs; + } + + /** + * Set a CSR attribute + * + * @param String $id + * @param Mixed $value + * @param Boolean $disposition optional + * @access public + * @return Boolean + */ + function setAttribute($id, $value, $disposition = FILE_X509_ATTR_ALL) + { + $attributes = &$this->_subArray($this->currentCert, 'certificationRequestInfo/attributes', true); + + if (!is_array($attributes)) { + return false; + } + + switch ($disposition) { + case FILE_X509_ATTR_REPLACE: + $disposition = FILE_X509_ATTR_APPEND; + case FILE_X509_ATTR_ALL: + $this->removeAttribute($id); + break; + } + + foreach ($attributes as $key => $attribute) { + if ($attribute['type'] == $id) { + $n = count($attribute['value']); + switch (true) { + case $disposition == FILE_X509_ATTR_APPEND: + $last = $key; + break; + case $disposition >= $n; + $disposition -= $n; + break; + default: + $attributes[$key]['value'][$disposition] = $value; + return true; + } + } + } + + switch (true) { + case $disposition >= 0: + return false; + case isset($last): + $attributes[$last]['value'][] = $value; + break; + default: + $attributes[] = array('type' => $id, 'value' => $disposition == FILE_X509_ATTR_ALL ? $value: array($value)); + break; + } + + return true; + } + + /** + * Sets the subject key identifier + * + * This is used by the id-ce-authorityKeyIdentifier and the id-ce-subjectKeyIdentifier extensions. + * + * @param String $value + * @access public + */ + function setKeyIdentifier($value) + { + if (empty($value)) { + unset($this->currentKeyIdentifier); + } else { + $this->currentKeyIdentifier = base64_encode($value); + } + } + + /** + * Compute a public key identifier. + * + * Although key identifiers may be set to any unique value, this function + * computes key identifiers from public key according to the two + * recommended methods (4.2.1.2 RFC 3280). + * Highly polymorphic: try to accept all possible forms of key: + * - Key object + * - File_X509 object with public or private key defined + * - Certificate or CSR array + * - File_ASN1_Element object + * - PEM or DER string + * + * @param Mixed $key optional + * @param Integer $method optional + * @access public + * @return String binary key identifier + */ + function computeKeyIdentifier($key = null, $method = 1) + { + if (is_null($key)) { + $key = $this; + } + + switch (true) { + case is_string($key): + break; + case is_array($key) && isset($key['tbsCertificate']['subjectPublicKeyInfo']['subjectPublicKey']): + return $this->computeKeyIdentifier($key['tbsCertificate']['subjectPublicKeyInfo']['subjectPublicKey'], $method); + case is_array($key) && isset($key['certificationRequestInfo']['subjectPKInfo']['subjectPublicKey']): + return $this->computeKeyIdentifier($key['certificationRequestInfo']['subjectPKInfo']['subjectPublicKey'], $method); + case !is_object($key): + return false; + case strtolower(get_class($key)) == 'file_asn1_element': + // Assume the element is a bitstring-packed key. + $asn1 = new File_ASN1(); + $decoded = $asn1->decodeBER($key->element); + if (empty($decoded)) { + return false; + } + $raw = $asn1->asn1map($decoded[0], array('type' => FILE_ASN1_TYPE_BIT_STRING)); + if (empty($raw)) { + return false; + } + $raw = base64_decode($raw); + // If the key is private, compute identifier from its corresponding public key. + if (!class_exists('Crypt_RSA')) { + include_once 'Crypt/RSA.php'; + } + $key = new Crypt_RSA(); + if (!$key->loadKey($raw)) { + return false; // Not an unencrypted RSA key. + } + if ($key->getPrivateKey() !== false) { // If private. + return $this->computeKeyIdentifier($key, $method); + } + $key = $raw; // Is a public key. + break; + case strtolower(get_class($key)) == 'file_x509': + if (isset($key->publicKey)) { + return $this->computeKeyIdentifier($key->publicKey, $method); + } + if (isset($key->privateKey)) { + return $this->computeKeyIdentifier($key->privateKey, $method); + } + if (isset($key->currentCert['tbsCertificate']) || isset($key->currentCert['certificationRequestInfo'])) { + return $this->computeKeyIdentifier($key->currentCert, $method); + } + return false; + default: // Should be a key object (i.e.: Crypt_RSA). + $key = $key->getPublicKey(CRYPT_RSA_PUBLIC_FORMAT_PKCS1_RAW); + break; + } + + // If in PEM format, convert to binary. + $key = $this->_extractBER($key); + + // Now we have the key string: compute its sha-1 sum. + if (!class_exists('Crypt_Hash')) { + include_once 'Crypt/Hash.php'; + } + $hash = new Crypt_Hash('sha1'); + $hash = $hash->hash($key); + + if ($method == 2) { + $hash = substr($hash, -8); + $hash[0] = chr((ord($hash[0]) & 0x0F) | 0x40); + } + + return $hash; + } + + /** + * Format a public key as appropriate + * + * @access private + * @return Array + */ + function _formatSubjectPublicKey() + { + if (!isset($this->publicKey) || !is_object($this->publicKey)) { + return false; + } + + switch (strtolower(get_class($this->publicKey))) { + case 'crypt_rsa': + // the following two return statements do the same thing. i dunno.. i just prefer the later for some reason. + // the former is a good example of how to do fuzzing on the public key + //return new File_ASN1_Element(base64_decode(preg_replace('#-.+-|[\r\n]#', '', $this->publicKey->getPublicKey()))); + return array( + 'algorithm' => array('algorithm' => 'rsaEncryption'), + 'subjectPublicKey' => $this->publicKey->getPublicKey(CRYPT_RSA_PUBLIC_FORMAT_PKCS1_RAW) + ); + default: + return false; + } + } + + /** + * Set the domain name's which the cert is to be valid for + * + * @access public + * @return Array + */ + function setDomain() + { + $this->domains = func_get_args(); + $this->removeDNProp('id-at-commonName'); + $this->setDNProp('id-at-commonName', $this->domains[0]); + } + + /** + * Set the IP Addresses's which the cert is to be valid for + * + * @access public + * @param String $ipAddress optional + */ + function setIPAddress() + { + $this->ipAddresses = func_get_args(); + /* + if (!isset($this->domains)) { + $this->removeDNProp('id-at-commonName'); + $this->setDNProp('id-at-commonName', $this->ipAddresses[0]); + } + */ + } + + /** + * Helper function to build domain array + * + * @access private + * @param String $domain + * @return Array + */ + function _dnsName($domain) + { + return array('dNSName' => $domain); + } + + /** + * Helper function to build IP Address array + * + * (IPv6 is not currently supported) + * + * @access private + * @param String $address + * @return Array + */ + function _iPAddress($address) + { + return array('iPAddress' => $address); + } + + /** + * Get the index of a revoked certificate. + * + * @param array $rclist + * @param String $serial + * @param Boolean $create optional + * @access private + * @return Integer or false + */ + function _revokedCertificate(&$rclist, $serial, $create = false) + { + $serial = new Math_BigInteger($serial); + + foreach ($rclist as $i => $rc) { + if (!($serial->compare($rc['userCertificate']))) { + return $i; + } + } + + if (!$create) { + return false; + } + + $i = count($rclist); + $rclist[] = array('userCertificate' => $serial, + 'revocationDate' => array('generalTime' => @date('D, d M y H:i:s O'))); + return $i; + } + + /** + * Revoke a certificate. + * + * @param String $serial + * @param String $date optional + * @access public + * @return Boolean + */ + function revoke($serial, $date = null) + { + if (isset($this->currentCert['tbsCertList'])) { + if (is_array($rclist = &$this->_subArray($this->currentCert, 'tbsCertList/revokedCertificates', true))) { + if ($this->_revokedCertificate($rclist, $serial) === false) { // If not yet revoked + if (($i = $this->_revokedCertificate($rclist, $serial, true)) !== false) { + + if (!empty($date)) { + $rclist[$i]['revocationDate'] = array('generalTime' => $date); + } + + return true; + } + } + } + } + + return false; + } + + /** + * Unrevoke a certificate. + * + * @param String $serial + * @access public + * @return Boolean + */ + function unrevoke($serial) + { + if (is_array($rclist = &$this->_subArray($this->currentCert, 'tbsCertList/revokedCertificates'))) { + if (($i = $this->_revokedCertificate($rclist, $serial)) !== false) { + unset($rclist[$i]); + $rclist = array_values($rclist); + return true; + } + } + + return false; + } + + /** + * Get a revoked certificate. + * + * @param String $serial + * @access public + * @return Mixed + */ + function getRevoked($serial) + { + if (is_array($rclist = $this->_subArray($this->currentCert, 'tbsCertList/revokedCertificates'))) { + if (($i = $this->_revokedCertificate($rclist, $serial)) !== false) { + return $rclist[$i]; + } + } + + return false; + } + + /** + * List revoked certificates + * + * @param array $crl optional + * @access public + * @return array + */ + function listRevoked($crl = null) + { + if (!isset($crl)) { + $crl = $this->currentCert; + } + + if (!isset($crl['tbsCertList'])) { + return false; + } + + $result = array(); + + if (is_array($rclist = $this->_subArray($crl, 'tbsCertList/revokedCertificates'))) { + foreach ($rclist as $rc) { + $result[] = $rc['userCertificate']->toString(); + } + } + + return $result; + } + + /** + * Remove a Revoked Certificate Extension + * + * @param String $serial + * @param String $id + * @access public + * @return Boolean + */ + function removeRevokedCertificateExtension($serial, $id) + { + if (is_array($rclist = &$this->_subArray($this->currentCert, 'tbsCertList/revokedCertificates'))) { + if (($i = $this->_revokedCertificate($rclist, $serial)) !== false) { + return $this->_removeExtension($id, "tbsCertList/revokedCertificates/$i/crlEntryExtensions"); + } + } + + return false; + } + + /** + * Get a Revoked Certificate Extension + * + * Returns the extension if it exists and false if not + * + * @param String $serial + * @param String $id + * @param Array $crl optional + * @access public + * @return Mixed + */ + function getRevokedCertificateExtension($serial, $id, $crl = null) + { + if (!isset($crl)) { + $crl = $this->currentCert; + } + + if (is_array($rclist = $this->_subArray($crl, 'tbsCertList/revokedCertificates'))) { + if (($i = $this->_revokedCertificate($rclist, $serial)) !== false) { + return $this->_getExtension($id, $crl, "tbsCertList/revokedCertificates/$i/crlEntryExtensions"); + } + } + + return false; + } + + /** + * Returns a list of all extensions in use for a given revoked certificate + * + * @param String $serial + * @param array $crl optional + * @access public + * @return Array + */ + function getRevokedCertificateExtensions($serial, $crl = null) + { + if (!isset($crl)) { + $crl = $this->currentCert; + } + + if (is_array($rclist = $this->_subArray($crl, 'tbsCertList/revokedCertificates'))) { + if (($i = $this->_revokedCertificate($rclist, $serial)) !== false) { + return $this->_getExtensions($crl, "tbsCertList/revokedCertificates/$i/crlEntryExtensions"); + } + } + + return false; + } + + /** + * Set a Revoked Certificate Extension + * + * @param String $serial + * @param String $id + * @param Mixed $value + * @param Boolean $critical optional + * @param Boolean $replace optional + * @access public + * @return Boolean + */ + function setRevokedCertificateExtension($serial, $id, $value, $critical = false, $replace = true) + { + if (isset($this->currentCert['tbsCertList'])) { + if (is_array($rclist = &$this->_subArray($this->currentCert, 'tbsCertList/revokedCertificates', true))) { + if (($i = $this->_revokedCertificate($rclist, $serial, true)) !== false) { + return $this->_setExtension($id, $value, $critical, $replace, "tbsCertList/revokedCertificates/$i/crlEntryExtensions"); + } + } + } + + return false; + } + + /** + * Extract raw BER from Base64 encoding + * + * @access private + * @param String $str + * @return String + */ + function _extractBER($str) + { + /* X.509 certs are assumed to be base64 encoded but sometimes they'll have additional things in them + * above and beyond the ceritificate. + * ie. some may have the following preceding the -----BEGIN CERTIFICATE----- line: + * + * Bag Attributes + * localKeyID: 01 00 00 00 + * subject=/O=organization/OU=org unit/CN=common name + * issuer=/O=organization/CN=common name + */ + $temp = preg_replace('#.*?^-+[^-]+-+#ms', '', $str, 1); + // remove the -----BEGIN CERTIFICATE----- and -----END CERTIFICATE----- stuff + $temp = preg_replace('#-+[^-]+-+#', '', $temp); + // remove new lines + $temp = str_replace(array("\r", "\n", ' '), '', $temp); + $temp = preg_match('#^[a-zA-Z\d/+]*={0,2}$#', $temp) ? base64_decode($temp) : false; + return $temp != false ? $temp : $str; + } +} diff --git a/vendor/phpseclib/phpseclib/phpseclib/Math/BigInteger.php b/vendor/phpseclib/phpseclib/phpseclib/Math/BigInteger.php new file mode 100755 index 0000000..1b4ea67 --- /dev/null +++ b/vendor/phpseclib/phpseclib/phpseclib/Math/BigInteger.php @@ -0,0 +1,3706 @@ +> and << cannot be used, nor can the modulo operator %, + * which only supports integers. Although this fact will slow this library down, the fact that such a high + * base is being used should more than compensate. + * + * When PHP version 6 is officially released, we'll be able to use 64-bit integers. This should, once again, + * allow bitwise operators, and will increase the maximum possible base to 2**31 (or 2**62 for addition / + * subtraction). + * + * Numbers are stored in {@link http://en.wikipedia.org/wiki/Endianness little endian} format. ie. + * (new Math_BigInteger(pow(2, 26)))->value = array(0, 1) + * + * Useful resources are as follows: + * + * - {@link http://www.cacr.math.uwaterloo.ca/hac/about/chap14.pdf Handbook of Applied Cryptography (HAC)} + * - {@link http://math.libtomcrypt.com/files/tommath.pdf Multi-Precision Math (MPM)} + * - Java's BigInteger classes. See /j2se/src/share/classes/java/math in jdk-1_5_0-src-jrl.zip + * + * Here's an example of how to use this library: + * + * add($b); + * + * echo $c->toString(); // outputs 5 + * ?> + * + * + * LICENSE: Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * @category Math + * @package Math_BigInteger + * @author Jim Wigginton + * @copyright MMVI Jim Wigginton + * @license http://www.opensource.org/licenses/mit-license.html MIT License + * @link http://pear.php.net/package/Math_BigInteger + */ + +/**#@+ + * Reduction constants + * + * @access private + * @see Math_BigInteger::_reduce() + */ +/** + * @see Math_BigInteger::_montgomery() + * @see Math_BigInteger::_prepMontgomery() + */ +define('MATH_BIGINTEGER_MONTGOMERY', 0); +/** + * @see Math_BigInteger::_barrett() + */ +define('MATH_BIGINTEGER_BARRETT', 1); +/** + * @see Math_BigInteger::_mod2() + */ +define('MATH_BIGINTEGER_POWEROF2', 2); +/** + * @see Math_BigInteger::_remainder() + */ +define('MATH_BIGINTEGER_CLASSIC', 3); +/** + * @see Math_BigInteger::__clone() + */ +define('MATH_BIGINTEGER_NONE', 4); +/**#@-*/ + +/**#@+ + * Array constants + * + * Rather than create a thousands and thousands of new Math_BigInteger objects in repeated function calls to add() and + * multiply() or whatever, we'll just work directly on arrays, taking them in as parameters and returning them. + * + * @access private + */ +/** + * $result[MATH_BIGINTEGER_VALUE] contains the value. + */ +define('MATH_BIGINTEGER_VALUE', 0); +/** + * $result[MATH_BIGINTEGER_SIGN] contains the sign. + */ +define('MATH_BIGINTEGER_SIGN', 1); +/**#@-*/ + +/**#@+ + * @access private + * @see Math_BigInteger::_montgomery() + * @see Math_BigInteger::_barrett() + */ +/** + * Cache constants + * + * $cache[MATH_BIGINTEGER_VARIABLE] tells us whether or not the cached data is still valid. + */ +define('MATH_BIGINTEGER_VARIABLE', 0); +/** + * $cache[MATH_BIGINTEGER_DATA] contains the cached data. + */ +define('MATH_BIGINTEGER_DATA', 1); +/**#@-*/ + +/**#@+ + * Mode constants. + * + * @access private + * @see Math_BigInteger::Math_BigInteger() + */ +/** + * To use the pure-PHP implementation + */ +define('MATH_BIGINTEGER_MODE_INTERNAL', 1); +/** + * To use the BCMath library + * + * (if enabled; otherwise, the internal implementation will be used) + */ +define('MATH_BIGINTEGER_MODE_BCMATH', 2); +/** + * To use the GMP library + * + * (if present; otherwise, either the BCMath or the internal implementation will be used) + */ +define('MATH_BIGINTEGER_MODE_GMP', 3); +/**#@-*/ + +/** + * Karatsuba Cutoff + * + * At what point do we switch between Karatsuba multiplication and schoolbook long multiplication? + * + * @access private + */ +define('MATH_BIGINTEGER_KARATSUBA_CUTOFF', 25); + +/** + * Pure-PHP arbitrary precision integer arithmetic library. Supports base-2, base-10, base-16, and base-256 + * numbers. + * + * @package Math_BigInteger + * @author Jim Wigginton + * @version 1.0.0RC4 + * @access public + */ +class Math_BigInteger +{ + /** + * Holds the BigInteger's value. + * + * @var Array + * @access private + */ + var $value; + + /** + * Holds the BigInteger's magnitude. + * + * @var Boolean + * @access private + */ + var $is_negative = false; + + /** + * Random number generator function + * + * @see setRandomGenerator() + * @access private + */ + var $generator = 'mt_rand'; + + /** + * Precision + * + * @see setPrecision() + * @access private + */ + var $precision = -1; + + /** + * Precision Bitmask + * + * @see setPrecision() + * @access private + */ + var $bitmask = false; + + /** + * Mode independent value used for serialization. + * + * If the bcmath or gmp extensions are installed $this->value will be a non-serializable resource, hence the need for + * a variable that'll be serializable regardless of whether or not extensions are being used. Unlike $this->value, + * however, $this->hex is only calculated when $this->__sleep() is called. + * + * @see __sleep() + * @see __wakeup() + * @var String + * @access private + */ + var $hex; + + /** + * Converts base-2, base-10, base-16, and binary strings (base-256) to BigIntegers. + * + * If the second parameter - $base - is negative, then it will be assumed that the number's are encoded using + * two's compliment. The sole exception to this is -10, which is treated the same as 10 is. + * + * Here's an example: + * + * <?php + * include('Math/BigInteger.php'); + * + * $a = new Math_BigInteger('0x32', 16); // 50 in base-16 + * + * echo $a->toString(); // outputs 50 + * ?> + * + * + * @param optional $x base-10 number or base-$base number if $base set. + * @param optional integer $base + * @return Math_BigInteger + * @access public + */ + function Math_BigInteger($x = 0, $base = 10) + { + if ( !defined('MATH_BIGINTEGER_MODE') ) { + switch (true) { + case extension_loaded('gmp'): + define('MATH_BIGINTEGER_MODE', MATH_BIGINTEGER_MODE_GMP); + break; + case extension_loaded('bcmath'): + define('MATH_BIGINTEGER_MODE', MATH_BIGINTEGER_MODE_BCMATH); + break; + default: + define('MATH_BIGINTEGER_MODE', MATH_BIGINTEGER_MODE_INTERNAL); + } + } + + if (function_exists('openssl_public_encrypt') && !defined('MATH_BIGINTEGER_OPENSSL_DISABLE') && !defined('MATH_BIGINTEGER_OPENSSL_ENABLED')) { + // some versions of XAMPP have mismatched versions of OpenSSL which causes it not to work + ob_start(); + phpinfo(); + $content = ob_get_contents(); + ob_end_clean(); + + preg_match_all('#OpenSSL (Header|Library) Version(.*)#im', $content, $matches); + + $versions = array(); + if (!empty($matches[1])) { + for ($i = 0; $i < count($matches[1]); $i++) { + $versions[$matches[1][$i]] = trim(str_replace('=>', '', strip_tags($matches[2][$i]))); + } + } + + // it doesn't appear that OpenSSL versions were reported upon until PHP 5.3+ + switch (true) { + case !isset($versions['Header']): + case !isset($versions['Library']): + case $versions['Header'] == $versions['Library']: + define('MATH_BIGINTEGER_OPENSSL_ENABLED', true); + break; + default: + define('MATH_BIGINTEGER_OPENSSL_DISABLE', true); + } + } + + if (!defined('PHP_INT_SIZE')) { + define('PHP_INT_SIZE', 4); + } + + if (!defined('MATH_BIGINTEGER_BASE') && MATH_BIGINTEGER_MODE == MATH_BIGINTEGER_MODE_INTERNAL) { + switch (PHP_INT_SIZE) { + case 8: // use 64-bit integers if int size is 8 bytes + define('MATH_BIGINTEGER_BASE', 31); + define('MATH_BIGINTEGER_BASE_FULL', 0x80000000); + define('MATH_BIGINTEGER_MAX_DIGIT', 0x7FFFFFFF); + define('MATH_BIGINTEGER_MSB', 0x40000000); + // 10**9 is the closest we can get to 2**31 without passing it + define('MATH_BIGINTEGER_MAX10', 1000000000); + define('MATH_BIGINTEGER_MAX10_LEN', 9); + // the largest digit that may be used in addition / subtraction + define('MATH_BIGINTEGER_MAX_DIGIT2', pow(2, 62)); + break; + //case 4: // use 64-bit floats if int size is 4 bytes + default: + define('MATH_BIGINTEGER_BASE', 26); + define('MATH_BIGINTEGER_BASE_FULL', 0x4000000); + define('MATH_BIGINTEGER_MAX_DIGIT', 0x3FFFFFF); + define('MATH_BIGINTEGER_MSB', 0x2000000); + // 10**7 is the closest to 2**26 without passing it + define('MATH_BIGINTEGER_MAX10', 10000000); + define('MATH_BIGINTEGER_MAX10_LEN', 7); + // the largest digit that may be used in addition / subtraction + // we do pow(2, 52) instead of using 4503599627370496 directly because some + // PHP installations will truncate 4503599627370496. + define('MATH_BIGINTEGER_MAX_DIGIT2', pow(2, 52)); + } + } + + switch ( MATH_BIGINTEGER_MODE ) { + case MATH_BIGINTEGER_MODE_GMP: + if (is_resource($x) && get_resource_type($x) == 'GMP integer') { + $this->value = $x; + return; + } + $this->value = gmp_init(0); + break; + case MATH_BIGINTEGER_MODE_BCMATH: + $this->value = '0'; + break; + default: + $this->value = array(); + } + + // '0' counts as empty() but when the base is 256 '0' is equal to ord('0') or 48 + // '0' is the only value like this per http://php.net/empty + if (empty($x) && (abs($base) != 256 || $x !== '0')) { + return; + } + + switch ($base) { + case -256: + if (ord($x[0]) & 0x80) { + $x = ~$x; + $this->is_negative = true; + } + case 256: + switch ( MATH_BIGINTEGER_MODE ) { + case MATH_BIGINTEGER_MODE_GMP: + $sign = $this->is_negative ? '-' : ''; + $this->value = gmp_init($sign . '0x' . bin2hex($x)); + break; + case MATH_BIGINTEGER_MODE_BCMATH: + // round $len to the nearest 4 (thanks, DavidMJ!) + $len = (strlen($x) + 3) & 0xFFFFFFFC; + + $x = str_pad($x, $len, chr(0), STR_PAD_LEFT); + + for ($i = 0; $i < $len; $i+= 4) { + $this->value = bcmul($this->value, '4294967296', 0); // 4294967296 == 2**32 + $this->value = bcadd($this->value, 0x1000000 * ord($x[$i]) + ((ord($x[$i + 1]) << 16) | (ord($x[$i + 2]) << 8) | ord($x[$i + 3])), 0); + } + + if ($this->is_negative) { + $this->value = '-' . $this->value; + } + + break; + // converts a base-2**8 (big endian / msb) number to base-2**26 (little endian / lsb) + default: + while (strlen($x)) { + $this->value[] = $this->_bytes2int($this->_base256_rshift($x, MATH_BIGINTEGER_BASE)); + } + } + + if ($this->is_negative) { + if (MATH_BIGINTEGER_MODE != MATH_BIGINTEGER_MODE_INTERNAL) { + $this->is_negative = false; + } + $temp = $this->add(new Math_BigInteger('-1')); + $this->value = $temp->value; + } + break; + case 16: + case -16: + if ($base > 0 && $x[0] == '-') { + $this->is_negative = true; + $x = substr($x, 1); + } + + $x = preg_replace('#^(?:0x)?([A-Fa-f0-9]*).*#', '$1', $x); + + $is_negative = false; + if ($base < 0 && hexdec($x[0]) >= 8) { + $this->is_negative = $is_negative = true; + $x = bin2hex(~pack('H*', $x)); + } + + switch ( MATH_BIGINTEGER_MODE ) { + case MATH_BIGINTEGER_MODE_GMP: + $temp = $this->is_negative ? '-0x' . $x : '0x' . $x; + $this->value = gmp_init($temp); + $this->is_negative = false; + break; + case MATH_BIGINTEGER_MODE_BCMATH: + $x = ( strlen($x) & 1 ) ? '0' . $x : $x; + $temp = new Math_BigInteger(pack('H*', $x), 256); + $this->value = $this->is_negative ? '-' . $temp->value : $temp->value; + $this->is_negative = false; + break; + default: + $x = ( strlen($x) & 1 ) ? '0' . $x : $x; + $temp = new Math_BigInteger(pack('H*', $x), 256); + $this->value = $temp->value; + } + + if ($is_negative) { + $temp = $this->add(new Math_BigInteger('-1')); + $this->value = $temp->value; + } + break; + case 10: + case -10: + // (?value = gmp_init($x); + break; + case MATH_BIGINTEGER_MODE_BCMATH: + // explicitly casting $x to a string is necessary, here, since doing $x[0] on -1 yields different + // results then doing it on '-1' does (modInverse does $x[0]) + $this->value = $x === '-' ? '0' : (string) $x; + break; + default: + $temp = new Math_BigInteger(); + + $multiplier = new Math_BigInteger(); + $multiplier->value = array(MATH_BIGINTEGER_MAX10); + + if ($x[0] == '-') { + $this->is_negative = true; + $x = substr($x, 1); + } + + $x = str_pad($x, strlen($x) + ((MATH_BIGINTEGER_MAX10_LEN - 1) * strlen($x)) % MATH_BIGINTEGER_MAX10_LEN, 0, STR_PAD_LEFT); + while (strlen($x)) { + $temp = $temp->multiply($multiplier); + $temp = $temp->add(new Math_BigInteger($this->_int2bytes(substr($x, 0, MATH_BIGINTEGER_MAX10_LEN)), 256)); + $x = substr($x, MATH_BIGINTEGER_MAX10_LEN); + } + + $this->value = $temp->value; + } + break; + case 2: // base-2 support originally implemented by Lluis Pamies - thanks! + case -2: + if ($base > 0 && $x[0] == '-') { + $this->is_negative = true; + $x = substr($x, 1); + } + + $x = preg_replace('#^([01]*).*#', '$1', $x); + $x = str_pad($x, strlen($x) + (3 * strlen($x)) % 4, 0, STR_PAD_LEFT); + + $str = '0x'; + while (strlen($x)) { + $part = substr($x, 0, 4); + $str.= dechex(bindec($part)); + $x = substr($x, 4); + } + + if ($this->is_negative) { + $str = '-' . $str; + } + + $temp = new Math_BigInteger($str, 8 * $base); // ie. either -16 or +16 + $this->value = $temp->value; + $this->is_negative = $temp->is_negative; + + break; + default: + // base not supported, so we'll let $this == 0 + } + } + + /** + * Converts a BigInteger to a byte string (eg. base-256). + * + * Negative numbers are saved as positive numbers, unless $twos_compliment is set to true, at which point, they're + * saved as two's compliment. + * + * Here's an example: + * + * toBytes(); // outputs chr(65) + * ?> + * + * + * @param Boolean $twos_compliment + * @return String + * @access public + * @internal Converts a base-2**26 number to base-2**8 + */ + function toBytes($twos_compliment = false) + { + if ($twos_compliment) { + $comparison = $this->compare(new Math_BigInteger()); + if ($comparison == 0) { + return $this->precision > 0 ? str_repeat(chr(0), ($this->precision + 1) >> 3) : ''; + } + + $temp = $comparison < 0 ? $this->add(new Math_BigInteger(1)) : $this->copy(); + $bytes = $temp->toBytes(); + + if (empty($bytes)) { // eg. if the number we're trying to convert is -1 + $bytes = chr(0); + } + + if (ord($bytes[0]) & 0x80) { + $bytes = chr(0) . $bytes; + } + + return $comparison < 0 ? ~$bytes : $bytes; + } + + switch ( MATH_BIGINTEGER_MODE ) { + case MATH_BIGINTEGER_MODE_GMP: + if (gmp_cmp($this->value, gmp_init(0)) == 0) { + return $this->precision > 0 ? str_repeat(chr(0), ($this->precision + 1) >> 3) : ''; + } + + $temp = gmp_strval(gmp_abs($this->value), 16); + $temp = ( strlen($temp) & 1 ) ? '0' . $temp : $temp; + $temp = pack('H*', $temp); + + return $this->precision > 0 ? + substr(str_pad($temp, $this->precision >> 3, chr(0), STR_PAD_LEFT), -($this->precision >> 3)) : + ltrim($temp, chr(0)); + case MATH_BIGINTEGER_MODE_BCMATH: + if ($this->value === '0') { + return $this->precision > 0 ? str_repeat(chr(0), ($this->precision + 1) >> 3) : ''; + } + + $value = ''; + $current = $this->value; + + if ($current[0] == '-') { + $current = substr($current, 1); + } + + while (bccomp($current, '0', 0) > 0) { + $temp = bcmod($current, '16777216'); + $value = chr($temp >> 16) . chr($temp >> 8) . chr($temp) . $value; + $current = bcdiv($current, '16777216', 0); + } + + return $this->precision > 0 ? + substr(str_pad($value, $this->precision >> 3, chr(0), STR_PAD_LEFT), -($this->precision >> 3)) : + ltrim($value, chr(0)); + } + + if (!count($this->value)) { + return $this->precision > 0 ? str_repeat(chr(0), ($this->precision + 1) >> 3) : ''; + } + $result = $this->_int2bytes($this->value[count($this->value) - 1]); + + $temp = $this->copy(); + + for ($i = count($temp->value) - 2; $i >= 0; --$i) { + $temp->_base256_lshift($result, MATH_BIGINTEGER_BASE); + $result = $result | str_pad($temp->_int2bytes($temp->value[$i]), strlen($result), chr(0), STR_PAD_LEFT); + } + + return $this->precision > 0 ? + str_pad(substr($result, -(($this->precision + 7) >> 3)), ($this->precision + 7) >> 3, chr(0), STR_PAD_LEFT) : + $result; + } + + /** + * Converts a BigInteger to a hex string (eg. base-16)). + * + * Negative numbers are saved as positive numbers, unless $twos_compliment is set to true, at which point, they're + * saved as two's compliment. + * + * Here's an example: + * + * toHex(); // outputs '41' + * ?> + * + * + * @param Boolean $twos_compliment + * @return String + * @access public + * @internal Converts a base-2**26 number to base-2**8 + */ + function toHex($twos_compliment = false) + { + return bin2hex($this->toBytes($twos_compliment)); + } + + /** + * Converts a BigInteger to a bit string (eg. base-2). + * + * Negative numbers are saved as positive numbers, unless $twos_compliment is set to true, at which point, they're + * saved as two's compliment. + * + * Here's an example: + * + * toBits(); // outputs '1000001' + * ?> + * + * + * @param Boolean $twos_compliment + * @return String + * @access public + * @internal Converts a base-2**26 number to base-2**2 + */ + function toBits($twos_compliment = false) + { + $hex = $this->toHex($twos_compliment); + $bits = ''; + for ($i = strlen($hex) - 8, $start = strlen($hex) & 7; $i >= $start; $i-=8) { + $bits = str_pad(decbin(hexdec(substr($hex, $i, 8))), 32, '0', STR_PAD_LEFT) . $bits; + } + if ($start) { // hexdec('') == 0 + $bits = str_pad(decbin(hexdec(substr($hex, 0, $start))), 8, '0', STR_PAD_LEFT) . $bits; + } + $result = $this->precision > 0 ? substr($bits, -$this->precision) : ltrim($bits, '0'); + + if ($twos_compliment && $this->compare(new Math_BigInteger()) > 0 && $this->precision <= 0) { + return '0' . $result; + } + + return $result; + } + + /** + * Converts a BigInteger to a base-10 number. + * + * Here's an example: + * + * toString(); // outputs 50 + * ?> + * + * + * @return String + * @access public + * @internal Converts a base-2**26 number to base-10**7 (which is pretty much base-10) + */ + function toString() + { + switch ( MATH_BIGINTEGER_MODE ) { + case MATH_BIGINTEGER_MODE_GMP: + return gmp_strval($this->value); + case MATH_BIGINTEGER_MODE_BCMATH: + if ($this->value === '0') { + return '0'; + } + + return ltrim($this->value, '0'); + } + + if (!count($this->value)) { + return '0'; + } + + $temp = $this->copy(); + $temp->is_negative = false; + + $divisor = new Math_BigInteger(); + $divisor->value = array(MATH_BIGINTEGER_MAX10); + $result = ''; + while (count($temp->value)) { + list($temp, $mod) = $temp->divide($divisor); + $result = str_pad(isset($mod->value[0]) ? $mod->value[0] : '', MATH_BIGINTEGER_MAX10_LEN, '0', STR_PAD_LEFT) . $result; + } + $result = ltrim($result, '0'); + if (empty($result)) { + $result = '0'; + } + + if ($this->is_negative) { + $result = '-' . $result; + } + + return $result; + } + + /** + * Copy an object + * + * PHP5 passes objects by reference while PHP4 passes by value. As such, we need a function to guarantee + * that all objects are passed by value, when appropriate. More information can be found here: + * + * {@link http://php.net/language.oop5.basic#51624} + * + * @access public + * @see __clone() + * @return Math_BigInteger + */ + function copy() + { + $temp = new Math_BigInteger(); + $temp->value = $this->value; + $temp->is_negative = $this->is_negative; + $temp->generator = $this->generator; + $temp->precision = $this->precision; + $temp->bitmask = $this->bitmask; + return $temp; + } + + /** + * __toString() magic method + * + * Will be called, automatically, if you're supporting just PHP5. If you're supporting PHP4, you'll need to call + * toString(). + * + * @access public + * @internal Implemented per a suggestion by Techie-Michael - thanks! + */ + function __toString() + { + return $this->toString(); + } + + /** + * __clone() magic method + * + * Although you can call Math_BigInteger::__toString() directly in PHP5, you cannot call Math_BigInteger::__clone() + * directly in PHP5. You can in PHP4 since it's not a magic method, but in PHP5, you have to call it by using the PHP5 + * only syntax of $y = clone $x. As such, if you're trying to write an application that works on both PHP4 and PHP5, + * call Math_BigInteger::copy(), instead. + * + * @access public + * @see copy() + * @return Math_BigInteger + */ + function __clone() + { + return $this->copy(); + } + + /** + * __sleep() magic method + * + * Will be called, automatically, when serialize() is called on a Math_BigInteger object. + * + * @see __wakeup() + * @access public + */ + function __sleep() + { + $this->hex = $this->toHex(true); + $vars = array('hex'); + if ($this->generator != 'mt_rand') { + $vars[] = 'generator'; + } + if ($this->precision > 0) { + $vars[] = 'precision'; + } + return $vars; + + } + + /** + * __wakeup() magic method + * + * Will be called, automatically, when unserialize() is called on a Math_BigInteger object. + * + * @see __sleep() + * @access public + */ + function __wakeup() + { + $temp = new Math_BigInteger($this->hex, -16); + $this->value = $temp->value; + $this->is_negative = $temp->is_negative; + $this->setRandomGenerator($this->generator); + if ($this->precision > 0) { + // recalculate $this->bitmask + $this->setPrecision($this->precision); + } + } + + /** + * Adds two BigIntegers. + * + * Here's an example: + * + * add($b); + * + * echo $c->toString(); // outputs 30 + * ?> + * + * + * @param Math_BigInteger $y + * @return Math_BigInteger + * @access public + * @internal Performs base-2**52 addition + */ + function add($y) + { + switch ( MATH_BIGINTEGER_MODE ) { + case MATH_BIGINTEGER_MODE_GMP: + $temp = new Math_BigInteger(); + $temp->value = gmp_add($this->value, $y->value); + + return $this->_normalize($temp); + case MATH_BIGINTEGER_MODE_BCMATH: + $temp = new Math_BigInteger(); + $temp->value = bcadd($this->value, $y->value, 0); + + return $this->_normalize($temp); + } + + $temp = $this->_add($this->value, $this->is_negative, $y->value, $y->is_negative); + + $result = new Math_BigInteger(); + $result->value = $temp[MATH_BIGINTEGER_VALUE]; + $result->is_negative = $temp[MATH_BIGINTEGER_SIGN]; + + return $this->_normalize($result); + } + + /** + * Performs addition. + * + * @param Array $x_value + * @param Boolean $x_negative + * @param Array $y_value + * @param Boolean $y_negative + * @return Array + * @access private + */ + function _add($x_value, $x_negative, $y_value, $y_negative) + { + $x_size = count($x_value); + $y_size = count($y_value); + + if ($x_size == 0) { + return array( + MATH_BIGINTEGER_VALUE => $y_value, + MATH_BIGINTEGER_SIGN => $y_negative + ); + } else if ($y_size == 0) { + return array( + MATH_BIGINTEGER_VALUE => $x_value, + MATH_BIGINTEGER_SIGN => $x_negative + ); + } + + // subtract, if appropriate + if ( $x_negative != $y_negative ) { + if ( $x_value == $y_value ) { + return array( + MATH_BIGINTEGER_VALUE => array(), + MATH_BIGINTEGER_SIGN => false + ); + } + + $temp = $this->_subtract($x_value, false, $y_value, false); + $temp[MATH_BIGINTEGER_SIGN] = $this->_compare($x_value, false, $y_value, false) > 0 ? + $x_negative : $y_negative; + + return $temp; + } + + if ($x_size < $y_size) { + $size = $x_size; + $value = $y_value; + } else { + $size = $y_size; + $value = $x_value; + } + + $value[] = 0; // just in case the carry adds an extra digit + + $carry = 0; + for ($i = 0, $j = 1; $j < $size; $i+=2, $j+=2) { + $sum = $x_value[$j] * MATH_BIGINTEGER_BASE_FULL + $x_value[$i] + $y_value[$j] * MATH_BIGINTEGER_BASE_FULL + $y_value[$i] + $carry; + $carry = $sum >= MATH_BIGINTEGER_MAX_DIGIT2; // eg. floor($sum / 2**52); only possible values (in any base) are 0 and 1 + $sum = $carry ? $sum - MATH_BIGINTEGER_MAX_DIGIT2 : $sum; + + $temp = (int) ($sum / MATH_BIGINTEGER_BASE_FULL); + + $value[$i] = (int) ($sum - MATH_BIGINTEGER_BASE_FULL * $temp); // eg. a faster alternative to fmod($sum, 0x4000000) + $value[$j] = $temp; + } + + if ($j == $size) { // ie. if $y_size is odd + $sum = $x_value[$i] + $y_value[$i] + $carry; + $carry = $sum >= MATH_BIGINTEGER_BASE_FULL; + $value[$i] = $carry ? $sum - MATH_BIGINTEGER_BASE_FULL : $sum; + ++$i; // ie. let $i = $j since we've just done $value[$i] + } + + if ($carry) { + for (; $value[$i] == MATH_BIGINTEGER_MAX_DIGIT; ++$i) { + $value[$i] = 0; + } + ++$value[$i]; + } + + return array( + MATH_BIGINTEGER_VALUE => $this->_trim($value), + MATH_BIGINTEGER_SIGN => $x_negative + ); + } + + /** + * Subtracts two BigIntegers. + * + * Here's an example: + * + * subtract($b); + * + * echo $c->toString(); // outputs -10 + * ?> + * + * + * @param Math_BigInteger $y + * @return Math_BigInteger + * @access public + * @internal Performs base-2**52 subtraction + */ + function subtract($y) + { + switch ( MATH_BIGINTEGER_MODE ) { + case MATH_BIGINTEGER_MODE_GMP: + $temp = new Math_BigInteger(); + $temp->value = gmp_sub($this->value, $y->value); + + return $this->_normalize($temp); + case MATH_BIGINTEGER_MODE_BCMATH: + $temp = new Math_BigInteger(); + $temp->value = bcsub($this->value, $y->value, 0); + + return $this->_normalize($temp); + } + + $temp = $this->_subtract($this->value, $this->is_negative, $y->value, $y->is_negative); + + $result = new Math_BigInteger(); + $result->value = $temp[MATH_BIGINTEGER_VALUE]; + $result->is_negative = $temp[MATH_BIGINTEGER_SIGN]; + + return $this->_normalize($result); + } + + /** + * Performs subtraction. + * + * @param Array $x_value + * @param Boolean $x_negative + * @param Array $y_value + * @param Boolean $y_negative + * @return Array + * @access private + */ + function _subtract($x_value, $x_negative, $y_value, $y_negative) + { + $x_size = count($x_value); + $y_size = count($y_value); + + if ($x_size == 0) { + return array( + MATH_BIGINTEGER_VALUE => $y_value, + MATH_BIGINTEGER_SIGN => !$y_negative + ); + } else if ($y_size == 0) { + return array( + MATH_BIGINTEGER_VALUE => $x_value, + MATH_BIGINTEGER_SIGN => $x_negative + ); + } + + // add, if appropriate (ie. -$x - +$y or +$x - -$y) + if ( $x_negative != $y_negative ) { + $temp = $this->_add($x_value, false, $y_value, false); + $temp[MATH_BIGINTEGER_SIGN] = $x_negative; + + return $temp; + } + + $diff = $this->_compare($x_value, $x_negative, $y_value, $y_negative); + + if ( !$diff ) { + return array( + MATH_BIGINTEGER_VALUE => array(), + MATH_BIGINTEGER_SIGN => false + ); + } + + // switch $x and $y around, if appropriate. + if ( (!$x_negative && $diff < 0) || ($x_negative && $diff > 0) ) { + $temp = $x_value; + $x_value = $y_value; + $y_value = $temp; + + $x_negative = !$x_negative; + + $x_size = count($x_value); + $y_size = count($y_value); + } + + // at this point, $x_value should be at least as big as - if not bigger than - $y_value + + $carry = 0; + for ($i = 0, $j = 1; $j < $y_size; $i+=2, $j+=2) { + $sum = $x_value[$j] * MATH_BIGINTEGER_BASE_FULL + $x_value[$i] - $y_value[$j] * MATH_BIGINTEGER_BASE_FULL - $y_value[$i] - $carry; + $carry = $sum < 0; // eg. floor($sum / 2**52); only possible values (in any base) are 0 and 1 + $sum = $carry ? $sum + MATH_BIGINTEGER_MAX_DIGIT2 : $sum; + + $temp = (int) ($sum / MATH_BIGINTEGER_BASE_FULL); + + $x_value[$i] = (int) ($sum - MATH_BIGINTEGER_BASE_FULL * $temp); + $x_value[$j] = $temp; + } + + if ($j == $y_size) { // ie. if $y_size is odd + $sum = $x_value[$i] - $y_value[$i] - $carry; + $carry = $sum < 0; + $x_value[$i] = $carry ? $sum + MATH_BIGINTEGER_BASE_FULL : $sum; + ++$i; + } + + if ($carry) { + for (; !$x_value[$i]; ++$i) { + $x_value[$i] = MATH_BIGINTEGER_MAX_DIGIT; + } + --$x_value[$i]; + } + + return array( + MATH_BIGINTEGER_VALUE => $this->_trim($x_value), + MATH_BIGINTEGER_SIGN => $x_negative + ); + } + + /** + * Multiplies two BigIntegers + * + * Here's an example: + * + * multiply($b); + * + * echo $c->toString(); // outputs 200 + * ?> + * + * + * @param Math_BigInteger $x + * @return Math_BigInteger + * @access public + */ + function multiply($x) + { + switch ( MATH_BIGINTEGER_MODE ) { + case MATH_BIGINTEGER_MODE_GMP: + $temp = new Math_BigInteger(); + $temp->value = gmp_mul($this->value, $x->value); + + return $this->_normalize($temp); + case MATH_BIGINTEGER_MODE_BCMATH: + $temp = new Math_BigInteger(); + $temp->value = bcmul($this->value, $x->value, 0); + + return $this->_normalize($temp); + } + + $temp = $this->_multiply($this->value, $this->is_negative, $x->value, $x->is_negative); + + $product = new Math_BigInteger(); + $product->value = $temp[MATH_BIGINTEGER_VALUE]; + $product->is_negative = $temp[MATH_BIGINTEGER_SIGN]; + + return $this->_normalize($product); + } + + /** + * Performs multiplication. + * + * @param Array $x_value + * @param Boolean $x_negative + * @param Array $y_value + * @param Boolean $y_negative + * @return Array + * @access private + */ + function _multiply($x_value, $x_negative, $y_value, $y_negative) + { + //if ( $x_value == $y_value ) { + // return array( + // MATH_BIGINTEGER_VALUE => $this->_square($x_value), + // MATH_BIGINTEGER_SIGN => $x_sign != $y_value + // ); + //} + + $x_length = count($x_value); + $y_length = count($y_value); + + if ( !$x_length || !$y_length ) { // a 0 is being multiplied + return array( + MATH_BIGINTEGER_VALUE => array(), + MATH_BIGINTEGER_SIGN => false + ); + } + + return array( + MATH_BIGINTEGER_VALUE => min($x_length, $y_length) < 2 * MATH_BIGINTEGER_KARATSUBA_CUTOFF ? + $this->_trim($this->_regularMultiply($x_value, $y_value)) : + $this->_trim($this->_karatsuba($x_value, $y_value)), + MATH_BIGINTEGER_SIGN => $x_negative != $y_negative + ); + } + + /** + * Performs long multiplication on two BigIntegers + * + * Modeled after 'multiply' in MutableBigInteger.java. + * + * @param Array $x_value + * @param Array $y_value + * @return Array + * @access private + */ + function _regularMultiply($x_value, $y_value) + { + $x_length = count($x_value); + $y_length = count($y_value); + + if ( !$x_length || !$y_length ) { // a 0 is being multiplied + return array(); + } + + if ( $x_length < $y_length ) { + $temp = $x_value; + $x_value = $y_value; + $y_value = $temp; + + $x_length = count($x_value); + $y_length = count($y_value); + } + + $product_value = $this->_array_repeat(0, $x_length + $y_length); + + // the following for loop could be removed if the for loop following it + // (the one with nested for loops) initially set $i to 0, but + // doing so would also make the result in one set of unnecessary adds, + // since on the outermost loops first pass, $product->value[$k] is going + // to always be 0 + + $carry = 0; + + for ($j = 0; $j < $x_length; ++$j) { // ie. $i = 0 + $temp = $x_value[$j] * $y_value[0] + $carry; // $product_value[$k] == 0 + $carry = (int) ($temp / MATH_BIGINTEGER_BASE_FULL); + $product_value[$j] = (int) ($temp - MATH_BIGINTEGER_BASE_FULL * $carry); + } + + $product_value[$j] = $carry; + + // the above for loop is what the previous comment was talking about. the + // following for loop is the "one with nested for loops" + for ($i = 1; $i < $y_length; ++$i) { + $carry = 0; + + for ($j = 0, $k = $i; $j < $x_length; ++$j, ++$k) { + $temp = $product_value[$k] + $x_value[$j] * $y_value[$i] + $carry; + $carry = (int) ($temp / MATH_BIGINTEGER_BASE_FULL); + $product_value[$k] = (int) ($temp - MATH_BIGINTEGER_BASE_FULL * $carry); + } + + $product_value[$k] = $carry; + } + + return $product_value; + } + + /** + * Performs Karatsuba multiplication on two BigIntegers + * + * See {@link http://en.wikipedia.org/wiki/Karatsuba_algorithm Karatsuba algorithm} and + * {@link http://math.libtomcrypt.com/files/tommath.pdf#page=120 MPM 5.2.3}. + * + * @param Array $x_value + * @param Array $y_value + * @return Array + * @access private + */ + function _karatsuba($x_value, $y_value) + { + $m = min(count($x_value) >> 1, count($y_value) >> 1); + + if ($m < MATH_BIGINTEGER_KARATSUBA_CUTOFF) { + return $this->_regularMultiply($x_value, $y_value); + } + + $x1 = array_slice($x_value, $m); + $x0 = array_slice($x_value, 0, $m); + $y1 = array_slice($y_value, $m); + $y0 = array_slice($y_value, 0, $m); + + $z2 = $this->_karatsuba($x1, $y1); + $z0 = $this->_karatsuba($x0, $y0); + + $z1 = $this->_add($x1, false, $x0, false); + $temp = $this->_add($y1, false, $y0, false); + $z1 = $this->_karatsuba($z1[MATH_BIGINTEGER_VALUE], $temp[MATH_BIGINTEGER_VALUE]); + $temp = $this->_add($z2, false, $z0, false); + $z1 = $this->_subtract($z1, false, $temp[MATH_BIGINTEGER_VALUE], false); + + $z2 = array_merge(array_fill(0, 2 * $m, 0), $z2); + $z1[MATH_BIGINTEGER_VALUE] = array_merge(array_fill(0, $m, 0), $z1[MATH_BIGINTEGER_VALUE]); + + $xy = $this->_add($z2, false, $z1[MATH_BIGINTEGER_VALUE], $z1[MATH_BIGINTEGER_SIGN]); + $xy = $this->_add($xy[MATH_BIGINTEGER_VALUE], $xy[MATH_BIGINTEGER_SIGN], $z0, false); + + return $xy[MATH_BIGINTEGER_VALUE]; + } + + /** + * Performs squaring + * + * @param Array $x + * @return Array + * @access private + */ + function _square($x = false) + { + return count($x) < 2 * MATH_BIGINTEGER_KARATSUBA_CUTOFF ? + $this->_trim($this->_baseSquare($x)) : + $this->_trim($this->_karatsubaSquare($x)); + } + + /** + * Performs traditional squaring on two BigIntegers + * + * Squaring can be done faster than multiplying a number by itself can be. See + * {@link http://www.cacr.math.uwaterloo.ca/hac/about/chap14.pdf#page=7 HAC 14.2.4} / + * {@link http://math.libtomcrypt.com/files/tommath.pdf#page=141 MPM 5.3} for more information. + * + * @param Array $value + * @return Array + * @access private + */ + function _baseSquare($value) + { + if ( empty($value) ) { + return array(); + } + $square_value = $this->_array_repeat(0, 2 * count($value)); + + for ($i = 0, $max_index = count($value) - 1; $i <= $max_index; ++$i) { + $i2 = $i << 1; + + $temp = $square_value[$i2] + $value[$i] * $value[$i]; + $carry = (int) ($temp / MATH_BIGINTEGER_BASE_FULL); + $square_value[$i2] = (int) ($temp - MATH_BIGINTEGER_BASE_FULL * $carry); + + // note how we start from $i+1 instead of 0 as we do in multiplication. + for ($j = $i + 1, $k = $i2 + 1; $j <= $max_index; ++$j, ++$k) { + $temp = $square_value[$k] + 2 * $value[$j] * $value[$i] + $carry; + $carry = (int) ($temp / MATH_BIGINTEGER_BASE_FULL); + $square_value[$k] = (int) ($temp - MATH_BIGINTEGER_BASE_FULL * $carry); + } + + // the following line can yield values larger 2**15. at this point, PHP should switch + // over to floats. + $square_value[$i + $max_index + 1] = $carry; + } + + return $square_value; + } + + /** + * Performs Karatsuba "squaring" on two BigIntegers + * + * See {@link http://en.wikipedia.org/wiki/Karatsuba_algorithm Karatsuba algorithm} and + * {@link http://math.libtomcrypt.com/files/tommath.pdf#page=151 MPM 5.3.4}. + * + * @param Array $value + * @return Array + * @access private + */ + function _karatsubaSquare($value) + { + $m = count($value) >> 1; + + if ($m < MATH_BIGINTEGER_KARATSUBA_CUTOFF) { + return $this->_baseSquare($value); + } + + $x1 = array_slice($value, $m); + $x0 = array_slice($value, 0, $m); + + $z2 = $this->_karatsubaSquare($x1); + $z0 = $this->_karatsubaSquare($x0); + + $z1 = $this->_add($x1, false, $x0, false); + $z1 = $this->_karatsubaSquare($z1[MATH_BIGINTEGER_VALUE]); + $temp = $this->_add($z2, false, $z0, false); + $z1 = $this->_subtract($z1, false, $temp[MATH_BIGINTEGER_VALUE], false); + + $z2 = array_merge(array_fill(0, 2 * $m, 0), $z2); + $z1[MATH_BIGINTEGER_VALUE] = array_merge(array_fill(0, $m, 0), $z1[MATH_BIGINTEGER_VALUE]); + + $xx = $this->_add($z2, false, $z1[MATH_BIGINTEGER_VALUE], $z1[MATH_BIGINTEGER_SIGN]); + $xx = $this->_add($xx[MATH_BIGINTEGER_VALUE], $xx[MATH_BIGINTEGER_SIGN], $z0, false); + + return $xx[MATH_BIGINTEGER_VALUE]; + } + + /** + * Divides two BigIntegers. + * + * Returns an array whose first element contains the quotient and whose second element contains the + * "common residue". If the remainder would be positive, the "common residue" and the remainder are the + * same. If the remainder would be negative, the "common residue" is equal to the sum of the remainder + * and the divisor (basically, the "common residue" is the first positive modulo). + * + * Here's an example: + * + * divide($b); + * + * echo $quotient->toString(); // outputs 0 + * echo "\r\n"; + * echo $remainder->toString(); // outputs 10 + * ?> + * + * + * @param Math_BigInteger $y + * @return Array + * @access public + * @internal This function is based off of {@link http://www.cacr.math.uwaterloo.ca/hac/about/chap14.pdf#page=9 HAC 14.20}. + */ + function divide($y) + { + switch ( MATH_BIGINTEGER_MODE ) { + case MATH_BIGINTEGER_MODE_GMP: + $quotient = new Math_BigInteger(); + $remainder = new Math_BigInteger(); + + list($quotient->value, $remainder->value) = gmp_div_qr($this->value, $y->value); + + if (gmp_sign($remainder->value) < 0) { + $remainder->value = gmp_add($remainder->value, gmp_abs($y->value)); + } + + return array($this->_normalize($quotient), $this->_normalize($remainder)); + case MATH_BIGINTEGER_MODE_BCMATH: + $quotient = new Math_BigInteger(); + $remainder = new Math_BigInteger(); + + $quotient->value = bcdiv($this->value, $y->value, 0); + $remainder->value = bcmod($this->value, $y->value); + + if ($remainder->value[0] == '-') { + $remainder->value = bcadd($remainder->value, $y->value[0] == '-' ? substr($y->value, 1) : $y->value, 0); + } + + return array($this->_normalize($quotient), $this->_normalize($remainder)); + } + + if (count($y->value) == 1) { + list($q, $r) = $this->_divide_digit($this->value, $y->value[0]); + $quotient = new Math_BigInteger(); + $remainder = new Math_BigInteger(); + $quotient->value = $q; + $remainder->value = array($r); + $quotient->is_negative = $this->is_negative != $y->is_negative; + return array($this->_normalize($quotient), $this->_normalize($remainder)); + } + + static $zero; + if ( !isset($zero) ) { + $zero = new Math_BigInteger(); + } + + $x = $this->copy(); + $y = $y->copy(); + + $x_sign = $x->is_negative; + $y_sign = $y->is_negative; + + $x->is_negative = $y->is_negative = false; + + $diff = $x->compare($y); + + if ( !$diff ) { + $temp = new Math_BigInteger(); + $temp->value = array(1); + $temp->is_negative = $x_sign != $y_sign; + return array($this->_normalize($temp), $this->_normalize(new Math_BigInteger())); + } + + if ( $diff < 0 ) { + // if $x is negative, "add" $y. + if ( $x_sign ) { + $x = $y->subtract($x); + } + return array($this->_normalize(new Math_BigInteger()), $this->_normalize($x)); + } + + // normalize $x and $y as described in HAC 14.23 / 14.24 + $msb = $y->value[count($y->value) - 1]; + for ($shift = 0; !($msb & MATH_BIGINTEGER_MSB); ++$shift) { + $msb <<= 1; + } + $x->_lshift($shift); + $y->_lshift($shift); + $y_value = &$y->value; + + $x_max = count($x->value) - 1; + $y_max = count($y->value) - 1; + + $quotient = new Math_BigInteger(); + $quotient_value = &$quotient->value; + $quotient_value = $this->_array_repeat(0, $x_max - $y_max + 1); + + static $temp, $lhs, $rhs; + if (!isset($temp)) { + $temp = new Math_BigInteger(); + $lhs = new Math_BigInteger(); + $rhs = new Math_BigInteger(); + } + $temp_value = &$temp->value; + $rhs_value = &$rhs->value; + + // $temp = $y << ($x_max - $y_max-1) in base 2**26 + $temp_value = array_merge($this->_array_repeat(0, $x_max - $y_max), $y_value); + + while ( $x->compare($temp) >= 0 ) { + // calculate the "common residue" + ++$quotient_value[$x_max - $y_max]; + $x = $x->subtract($temp); + $x_max = count($x->value) - 1; + } + + for ($i = $x_max; $i >= $y_max + 1; --$i) { + $x_value = &$x->value; + $x_window = array( + isset($x_value[$i]) ? $x_value[$i] : 0, + isset($x_value[$i - 1]) ? $x_value[$i - 1] : 0, + isset($x_value[$i - 2]) ? $x_value[$i - 2] : 0 + ); + $y_window = array( + $y_value[$y_max], + ( $y_max > 0 ) ? $y_value[$y_max - 1] : 0 + ); + + $q_index = $i - $y_max - 1; + if ($x_window[0] == $y_window[0]) { + $quotient_value[$q_index] = MATH_BIGINTEGER_MAX_DIGIT; + } else { + $quotient_value[$q_index] = (int) ( + ($x_window[0] * MATH_BIGINTEGER_BASE_FULL + $x_window[1]) + / + $y_window[0] + ); + } + + $temp_value = array($y_window[1], $y_window[0]); + + $lhs->value = array($quotient_value[$q_index]); + $lhs = $lhs->multiply($temp); + + $rhs_value = array($x_window[2], $x_window[1], $x_window[0]); + + while ( $lhs->compare($rhs) > 0 ) { + --$quotient_value[$q_index]; + + $lhs->value = array($quotient_value[$q_index]); + $lhs = $lhs->multiply($temp); + } + + $adjust = $this->_array_repeat(0, $q_index); + $temp_value = array($quotient_value[$q_index]); + $temp = $temp->multiply($y); + $temp_value = &$temp->value; + $temp_value = array_merge($adjust, $temp_value); + + $x = $x->subtract($temp); + + if ($x->compare($zero) < 0) { + $temp_value = array_merge($adjust, $y_value); + $x = $x->add($temp); + + --$quotient_value[$q_index]; + } + + $x_max = count($x_value) - 1; + } + + // unnormalize the remainder + $x->_rshift($shift); + + $quotient->is_negative = $x_sign != $y_sign; + + // calculate the "common residue", if appropriate + if ( $x_sign ) { + $y->_rshift($shift); + $x = $y->subtract($x); + } + + return array($this->_normalize($quotient), $this->_normalize($x)); + } + + /** + * Divides a BigInteger by a regular integer + * + * abc / x = a00 / x + b0 / x + c / x + * + * @param Array $dividend + * @param Array $divisor + * @return Array + * @access private + */ + function _divide_digit($dividend, $divisor) + { + $carry = 0; + $result = array(); + + for ($i = count($dividend) - 1; $i >= 0; --$i) { + $temp = MATH_BIGINTEGER_BASE_FULL * $carry + $dividend[$i]; + $result[$i] = (int) ($temp / $divisor); + $carry = (int) ($temp - $divisor * $result[$i]); + } + + return array($result, $carry); + } + + /** + * Performs modular exponentiation. + * + * Here's an example: + * + * modPow($b, $c); + * + * echo $c->toString(); // outputs 10 + * ?> + * + * + * @param Math_BigInteger $e + * @param Math_BigInteger $n + * @return Math_BigInteger + * @access public + * @internal The most naive approach to modular exponentiation has very unreasonable requirements, and + * and although the approach involving repeated squaring does vastly better, it, too, is impractical + * for our purposes. The reason being that division - by far the most complicated and time-consuming + * of the basic operations (eg. +,-,*,/) - occurs multiple times within it. + * + * Modular reductions resolve this issue. Although an individual modular reduction takes more time + * then an individual division, when performed in succession (with the same modulo), they're a lot faster. + * + * The two most commonly used modular reductions are Barrett and Montgomery reduction. Montgomery reduction, + * although faster, only works when the gcd of the modulo and of the base being used is 1. In RSA, when the + * base is a power of two, the modulo - a product of two primes - is always going to have a gcd of 1 (because + * the product of two odd numbers is odd), but what about when RSA isn't used? + * + * In contrast, Barrett reduction has no such constraint. As such, some bigint implementations perform a + * Barrett reduction after every operation in the modpow function. Others perform Barrett reductions when the + * modulo is even and Montgomery reductions when the modulo is odd. BigInteger.java's modPow method, however, + * uses a trick involving the Chinese Remainder Theorem to factor the even modulo into two numbers - one odd and + * the other, a power of two - and recombine them, later. This is the method that this modPow function uses. + * {@link http://islab.oregonstate.edu/papers/j34monex.pdf Montgomery Reduction with Even Modulus} elaborates. + */ + function modPow($e, $n) + { + $n = $this->bitmask !== false && $this->bitmask->compare($n) < 0 ? $this->bitmask : $n->abs(); + + if ($e->compare(new Math_BigInteger()) < 0) { + $e = $e->abs(); + + $temp = $this->modInverse($n); + if ($temp === false) { + return false; + } + + return $this->_normalize($temp->modPow($e, $n)); + } + + if ( MATH_BIGINTEGER_MODE == MATH_BIGINTEGER_MODE_GMP ) { + $temp = new Math_BigInteger(); + $temp->value = gmp_powm($this->value, $e->value, $n->value); + + return $this->_normalize($temp); + } + + if ($this->compare(new Math_BigInteger()) < 0 || $this->compare($n) > 0) { + list(, $temp) = $this->divide($n); + return $temp->modPow($e, $n); + } + + if (defined('MATH_BIGINTEGER_OPENSSL_ENABLED')) { + $components = array( + 'modulus' => $n->toBytes(true), + 'publicExponent' => $e->toBytes(true) + ); + + $components = array( + 'modulus' => pack('Ca*a*', 2, $this->_encodeASN1Length(strlen($components['modulus'])), $components['modulus']), + 'publicExponent' => pack('Ca*a*', 2, $this->_encodeASN1Length(strlen($components['publicExponent'])), $components['publicExponent']) + ); + + $RSAPublicKey = pack('Ca*a*a*', + 48, $this->_encodeASN1Length(strlen($components['modulus']) + strlen($components['publicExponent'])), + $components['modulus'], $components['publicExponent'] + ); + + $rsaOID = pack('H*', '300d06092a864886f70d0101010500'); // hex version of MA0GCSqGSIb3DQEBAQUA + $RSAPublicKey = chr(0) . $RSAPublicKey; + $RSAPublicKey = chr(3) . $this->_encodeASN1Length(strlen($RSAPublicKey)) . $RSAPublicKey; + + $encapsulated = pack('Ca*a*', + 48, $this->_encodeASN1Length(strlen($rsaOID . $RSAPublicKey)), $rsaOID . $RSAPublicKey + ); + + $RSAPublicKey = "-----BEGIN PUBLIC KEY-----\r\n" . + chunk_split(base64_encode($encapsulated)) . + '-----END PUBLIC KEY-----'; + + $plaintext = str_pad($this->toBytes(), strlen($n->toBytes(true)) - 1, "\0", STR_PAD_LEFT); + + if (openssl_public_encrypt($plaintext, $result, $RSAPublicKey, OPENSSL_NO_PADDING)) { + return new Math_BigInteger($result, 256); + } + } + + if ( MATH_BIGINTEGER_MODE == MATH_BIGINTEGER_MODE_BCMATH ) { + $temp = new Math_BigInteger(); + $temp->value = bcpowmod($this->value, $e->value, $n->value, 0); + + return $this->_normalize($temp); + } + + if ( empty($e->value) ) { + $temp = new Math_BigInteger(); + $temp->value = array(1); + return $this->_normalize($temp); + } + + if ( $e->value == array(1) ) { + list(, $temp) = $this->divide($n); + return $this->_normalize($temp); + } + + if ( $e->value == array(2) ) { + $temp = new Math_BigInteger(); + $temp->value = $this->_square($this->value); + list(, $temp) = $temp->divide($n); + return $this->_normalize($temp); + } + + return $this->_normalize($this->_slidingWindow($e, $n, MATH_BIGINTEGER_BARRETT)); + + // is the modulo odd? + if ( $n->value[0] & 1 ) { + return $this->_normalize($this->_slidingWindow($e, $n, MATH_BIGINTEGER_MONTGOMERY)); + } + // if it's not, it's even + + // find the lowest set bit (eg. the max pow of 2 that divides $n) + for ($i = 0; $i < count($n->value); ++$i) { + if ( $n->value[$i] ) { + $temp = decbin($n->value[$i]); + $j = strlen($temp) - strrpos($temp, '1') - 1; + $j+= 26 * $i; + break; + } + } + // at this point, 2^$j * $n/(2^$j) == $n + + $mod1 = $n->copy(); + $mod1->_rshift($j); + $mod2 = new Math_BigInteger(); + $mod2->value = array(1); + $mod2->_lshift($j); + + $part1 = ( $mod1->value != array(1) ) ? $this->_slidingWindow($e, $mod1, MATH_BIGINTEGER_MONTGOMERY) : new Math_BigInteger(); + $part2 = $this->_slidingWindow($e, $mod2, MATH_BIGINTEGER_POWEROF2); + + $y1 = $mod2->modInverse($mod1); + $y2 = $mod1->modInverse($mod2); + + $result = $part1->multiply($mod2); + $result = $result->multiply($y1); + + $temp = $part2->multiply($mod1); + $temp = $temp->multiply($y2); + + $result = $result->add($temp); + list(, $result) = $result->divide($n); + + return $this->_normalize($result); + } + + /** + * Performs modular exponentiation. + * + * Alias for Math_BigInteger::modPow() + * + * @param Math_BigInteger $e + * @param Math_BigInteger $n + * @return Math_BigInteger + * @access public + */ + function powMod($e, $n) + { + return $this->modPow($e, $n); + } + + /** + * Sliding Window k-ary Modular Exponentiation + * + * Based on {@link http://www.cacr.math.uwaterloo.ca/hac/about/chap14.pdf#page=27 HAC 14.85} / + * {@link http://math.libtomcrypt.com/files/tommath.pdf#page=210 MPM 7.7}. In a departure from those algorithims, + * however, this function performs a modular reduction after every multiplication and squaring operation. + * As such, this function has the same preconditions that the reductions being used do. + * + * @param Math_BigInteger $e + * @param Math_BigInteger $n + * @param Integer $mode + * @return Math_BigInteger + * @access private + */ + function _slidingWindow($e, $n, $mode) + { + static $window_ranges = array(7, 25, 81, 241, 673, 1793); // from BigInteger.java's oddModPow function + //static $window_ranges = array(0, 7, 36, 140, 450, 1303, 3529); // from MPM 7.3.1 + + $e_value = $e->value; + $e_length = count($e_value) - 1; + $e_bits = decbin($e_value[$e_length]); + for ($i = $e_length - 1; $i >= 0; --$i) { + $e_bits.= str_pad(decbin($e_value[$i]), MATH_BIGINTEGER_BASE, '0', STR_PAD_LEFT); + } + + $e_length = strlen($e_bits); + + // calculate the appropriate window size. + // $window_size == 3 if $window_ranges is between 25 and 81, for example. + for ($i = 0, $window_size = 1; $e_length > $window_ranges[$i] && $i < count($window_ranges); ++$window_size, ++$i); + + $n_value = $n->value; + + // precompute $this^0 through $this^$window_size + $powers = array(); + $powers[1] = $this->_prepareReduce($this->value, $n_value, $mode); + $powers[2] = $this->_squareReduce($powers[1], $n_value, $mode); + + // we do every other number since substr($e_bits, $i, $j+1) (see below) is supposed to end + // in a 1. ie. it's supposed to be odd. + $temp = 1 << ($window_size - 1); + for ($i = 1; $i < $temp; ++$i) { + $i2 = $i << 1; + $powers[$i2 + 1] = $this->_multiplyReduce($powers[$i2 - 1], $powers[2], $n_value, $mode); + } + + $result = array(1); + $result = $this->_prepareReduce($result, $n_value, $mode); + + for ($i = 0; $i < $e_length; ) { + if ( !$e_bits[$i] ) { + $result = $this->_squareReduce($result, $n_value, $mode); + ++$i; + } else { + for ($j = $window_size - 1; $j > 0; --$j) { + if ( !empty($e_bits[$i + $j]) ) { + break; + } + } + + for ($k = 0; $k <= $j; ++$k) {// eg. the length of substr($e_bits, $i, $j+1) + $result = $this->_squareReduce($result, $n_value, $mode); + } + + $result = $this->_multiplyReduce($result, $powers[bindec(substr($e_bits, $i, $j + 1))], $n_value, $mode); + + $i+=$j + 1; + } + } + + $temp = new Math_BigInteger(); + $temp->value = $this->_reduce($result, $n_value, $mode); + + return $temp; + } + + /** + * Modular reduction + * + * For most $modes this will return the remainder. + * + * @see _slidingWindow() + * @access private + * @param Array $x + * @param Array $n + * @param Integer $mode + * @return Array + */ + function _reduce($x, $n, $mode) + { + switch ($mode) { + case MATH_BIGINTEGER_MONTGOMERY: + return $this->_montgomery($x, $n); + case MATH_BIGINTEGER_BARRETT: + return $this->_barrett($x, $n); + case MATH_BIGINTEGER_POWEROF2: + $lhs = new Math_BigInteger(); + $lhs->value = $x; + $rhs = new Math_BigInteger(); + $rhs->value = $n; + return $x->_mod2($n); + case MATH_BIGINTEGER_CLASSIC: + $lhs = new Math_BigInteger(); + $lhs->value = $x; + $rhs = new Math_BigInteger(); + $rhs->value = $n; + list(, $temp) = $lhs->divide($rhs); + return $temp->value; + case MATH_BIGINTEGER_NONE: + return $x; + default: + // an invalid $mode was provided + } + } + + /** + * Modular reduction preperation + * + * @see _slidingWindow() + * @access private + * @param Array $x + * @param Array $n + * @param Integer $mode + * @return Array + */ + function _prepareReduce($x, $n, $mode) + { + if ($mode == MATH_BIGINTEGER_MONTGOMERY) { + return $this->_prepMontgomery($x, $n); + } + return $this->_reduce($x, $n, $mode); + } + + /** + * Modular multiply + * + * @see _slidingWindow() + * @access private + * @param Array $x + * @param Array $y + * @param Array $n + * @param Integer $mode + * @return Array + */ + function _multiplyReduce($x, $y, $n, $mode) + { + if ($mode == MATH_BIGINTEGER_MONTGOMERY) { + return $this->_montgomeryMultiply($x, $y, $n); + } + $temp = $this->_multiply($x, false, $y, false); + return $this->_reduce($temp[MATH_BIGINTEGER_VALUE], $n, $mode); + } + + /** + * Modular square + * + * @see _slidingWindow() + * @access private + * @param Array $x + * @param Array $n + * @param Integer $mode + * @return Array + */ + function _squareReduce($x, $n, $mode) + { + if ($mode == MATH_BIGINTEGER_MONTGOMERY) { + return $this->_montgomeryMultiply($x, $x, $n); + } + return $this->_reduce($this->_square($x), $n, $mode); + } + + /** + * Modulos for Powers of Two + * + * Calculates $x%$n, where $n = 2**$e, for some $e. Since this is basically the same as doing $x & ($n-1), + * we'll just use this function as a wrapper for doing that. + * + * @see _slidingWindow() + * @access private + * @param Math_BigInteger + * @return Math_BigInteger + */ + function _mod2($n) + { + $temp = new Math_BigInteger(); + $temp->value = array(1); + return $this->bitwise_and($n->subtract($temp)); + } + + /** + * Barrett Modular Reduction + * + * See {@link http://www.cacr.math.uwaterloo.ca/hac/about/chap14.pdf#page=14 HAC 14.3.3} / + * {@link http://math.libtomcrypt.com/files/tommath.pdf#page=165 MPM 6.2.5} for more information. Modified slightly, + * so as not to require negative numbers (initially, this script didn't support negative numbers). + * + * Employs "folding", as described at + * {@link http://www.cosic.esat.kuleuven.be/publications/thesis-149.pdf#page=66 thesis-149.pdf#page=66}. To quote from + * it, "the idea [behind folding] is to find a value x' such that x (mod m) = x' (mod m), with x' being smaller than x." + * + * Unfortunately, the "Barrett Reduction with Folding" algorithm described in thesis-149.pdf is not, as written, all that + * usable on account of (1) its not using reasonable radix points as discussed in + * {@link http://math.libtomcrypt.com/files/tommath.pdf#page=162 MPM 6.2.2} and (2) the fact that, even with reasonable + * radix points, it only works when there are an even number of digits in the denominator. The reason for (2) is that + * (x >> 1) + (x >> 1) != x / 2 + x / 2. If x is even, they're the same, but if x is odd, they're not. See the in-line + * comments for details. + * + * @see _slidingWindow() + * @access private + * @param Array $n + * @param Array $m + * @return Array + */ + function _barrett($n, $m) + { + static $cache = array( + MATH_BIGINTEGER_VARIABLE => array(), + MATH_BIGINTEGER_DATA => array() + ); + + $m_length = count($m); + + // if ($this->_compare($n, $this->_square($m)) >= 0) { + if (count($n) > 2 * $m_length) { + $lhs = new Math_BigInteger(); + $rhs = new Math_BigInteger(); + $lhs->value = $n; + $rhs->value = $m; + list(, $temp) = $lhs->divide($rhs); + return $temp->value; + } + + // if (m.length >> 1) + 2 <= m.length then m is too small and n can't be reduced + if ($m_length < 5) { + return $this->_regularBarrett($n, $m); + } + + // n = 2 * m.length + + if ( ($key = array_search($m, $cache[MATH_BIGINTEGER_VARIABLE])) === false ) { + $key = count($cache[MATH_BIGINTEGER_VARIABLE]); + $cache[MATH_BIGINTEGER_VARIABLE][] = $m; + + $lhs = new Math_BigInteger(); + $lhs_value = &$lhs->value; + $lhs_value = $this->_array_repeat(0, $m_length + ($m_length >> 1)); + $lhs_value[] = 1; + $rhs = new Math_BigInteger(); + $rhs->value = $m; + + list($u, $m1) = $lhs->divide($rhs); + $u = $u->value; + $m1 = $m1->value; + + $cache[MATH_BIGINTEGER_DATA][] = array( + 'u' => $u, // m.length >> 1 (technically (m.length >> 1) + 1) + 'm1'=> $m1 // m.length + ); + } else { + extract($cache[MATH_BIGINTEGER_DATA][$key]); + } + + $cutoff = $m_length + ($m_length >> 1); + $lsd = array_slice($n, 0, $cutoff); // m.length + (m.length >> 1) + $msd = array_slice($n, $cutoff); // m.length >> 1 + $lsd = $this->_trim($lsd); + $temp = $this->_multiply($msd, false, $m1, false); + $n = $this->_add($lsd, false, $temp[MATH_BIGINTEGER_VALUE], false); // m.length + (m.length >> 1) + 1 + + if ($m_length & 1) { + return $this->_regularBarrett($n[MATH_BIGINTEGER_VALUE], $m); + } + + // (m.length + (m.length >> 1) + 1) - (m.length - 1) == (m.length >> 1) + 2 + $temp = array_slice($n[MATH_BIGINTEGER_VALUE], $m_length - 1); + // if even: ((m.length >> 1) + 2) + (m.length >> 1) == m.length + 2 + // if odd: ((m.length >> 1) + 2) + (m.length >> 1) == (m.length - 1) + 2 == m.length + 1 + $temp = $this->_multiply($temp, false, $u, false); + // if even: (m.length + 2) - ((m.length >> 1) + 1) = m.length - (m.length >> 1) + 1 + // if odd: (m.length + 1) - ((m.length >> 1) + 1) = m.length - (m.length >> 1) + $temp = array_slice($temp[MATH_BIGINTEGER_VALUE], ($m_length >> 1) + 1); + // if even: (m.length - (m.length >> 1) + 1) + m.length = 2 * m.length - (m.length >> 1) + 1 + // if odd: (m.length - (m.length >> 1)) + m.length = 2 * m.length - (m.length >> 1) + $temp = $this->_multiply($temp, false, $m, false); + + // at this point, if m had an odd number of digits, we'd be subtracting a 2 * m.length - (m.length >> 1) digit + // number from a m.length + (m.length >> 1) + 1 digit number. ie. there'd be an extra digit and the while loop + // following this comment would loop a lot (hence our calling _regularBarrett() in that situation). + + $result = $this->_subtract($n[MATH_BIGINTEGER_VALUE], false, $temp[MATH_BIGINTEGER_VALUE], false); + + while ($this->_compare($result[MATH_BIGINTEGER_VALUE], $result[MATH_BIGINTEGER_SIGN], $m, false) >= 0) { + $result = $this->_subtract($result[MATH_BIGINTEGER_VALUE], $result[MATH_BIGINTEGER_SIGN], $m, false); + } + + return $result[MATH_BIGINTEGER_VALUE]; + } + + /** + * (Regular) Barrett Modular Reduction + * + * For numbers with more than four digits Math_BigInteger::_barrett() is faster. The difference between that and this + * is that this function does not fold the denominator into a smaller form. + * + * @see _slidingWindow() + * @access private + * @param Array $x + * @param Array $n + * @return Array + */ + function _regularBarrett($x, $n) + { + static $cache = array( + MATH_BIGINTEGER_VARIABLE => array(), + MATH_BIGINTEGER_DATA => array() + ); + + $n_length = count($n); + + if (count($x) > 2 * $n_length) { + $lhs = new Math_BigInteger(); + $rhs = new Math_BigInteger(); + $lhs->value = $x; + $rhs->value = $n; + list(, $temp) = $lhs->divide($rhs); + return $temp->value; + } + + if ( ($key = array_search($n, $cache[MATH_BIGINTEGER_VARIABLE])) === false ) { + $key = count($cache[MATH_BIGINTEGER_VARIABLE]); + $cache[MATH_BIGINTEGER_VARIABLE][] = $n; + $lhs = new Math_BigInteger(); + $lhs_value = &$lhs->value; + $lhs_value = $this->_array_repeat(0, 2 * $n_length); + $lhs_value[] = 1; + $rhs = new Math_BigInteger(); + $rhs->value = $n; + list($temp, ) = $lhs->divide($rhs); // m.length + $cache[MATH_BIGINTEGER_DATA][] = $temp->value; + } + + // 2 * m.length - (m.length - 1) = m.length + 1 + $temp = array_slice($x, $n_length - 1); + // (m.length + 1) + m.length = 2 * m.length + 1 + $temp = $this->_multiply($temp, false, $cache[MATH_BIGINTEGER_DATA][$key], false); + // (2 * m.length + 1) - (m.length - 1) = m.length + 2 + $temp = array_slice($temp[MATH_BIGINTEGER_VALUE], $n_length + 1); + + // m.length + 1 + $result = array_slice($x, 0, $n_length + 1); + // m.length + 1 + $temp = $this->_multiplyLower($temp, false, $n, false, $n_length + 1); + // $temp == array_slice($temp->_multiply($temp, false, $n, false)->value, 0, $n_length + 1) + + if ($this->_compare($result, false, $temp[MATH_BIGINTEGER_VALUE], $temp[MATH_BIGINTEGER_SIGN]) < 0) { + $corrector_value = $this->_array_repeat(0, $n_length + 1); + $corrector_value[] = 1; + $result = $this->_add($result, false, $corrector_value, false); + $result = $result[MATH_BIGINTEGER_VALUE]; + } + + // at this point, we're subtracting a number with m.length + 1 digits from another number with m.length + 1 digits + $result = $this->_subtract($result, false, $temp[MATH_BIGINTEGER_VALUE], $temp[MATH_BIGINTEGER_SIGN]); + while ($this->_compare($result[MATH_BIGINTEGER_VALUE], $result[MATH_BIGINTEGER_SIGN], $n, false) > 0) { + $result = $this->_subtract($result[MATH_BIGINTEGER_VALUE], $result[MATH_BIGINTEGER_SIGN], $n, false); + } + + return $result[MATH_BIGINTEGER_VALUE]; + } + + /** + * Performs long multiplication up to $stop digits + * + * If you're going to be doing array_slice($product->value, 0, $stop), some cycles can be saved. + * + * @see _regularBarrett() + * @param Array $x_value + * @param Boolean $x_negative + * @param Array $y_value + * @param Boolean $y_negative + * @param Integer $stop + * @return Array + * @access private + */ + function _multiplyLower($x_value, $x_negative, $y_value, $y_negative, $stop) + { + $x_length = count($x_value); + $y_length = count($y_value); + + if ( !$x_length || !$y_length ) { // a 0 is being multiplied + return array( + MATH_BIGINTEGER_VALUE => array(), + MATH_BIGINTEGER_SIGN => false + ); + } + + if ( $x_length < $y_length ) { + $temp = $x_value; + $x_value = $y_value; + $y_value = $temp; + + $x_length = count($x_value); + $y_length = count($y_value); + } + + $product_value = $this->_array_repeat(0, $x_length + $y_length); + + // the following for loop could be removed if the for loop following it + // (the one with nested for loops) initially set $i to 0, but + // doing so would also make the result in one set of unnecessary adds, + // since on the outermost loops first pass, $product->value[$k] is going + // to always be 0 + + $carry = 0; + + for ($j = 0; $j < $x_length; ++$j) { // ie. $i = 0, $k = $i + $temp = $x_value[$j] * $y_value[0] + $carry; // $product_value[$k] == 0 + $carry = (int) ($temp / MATH_BIGINTEGER_BASE_FULL); + $product_value[$j] = (int) ($temp - MATH_BIGINTEGER_BASE_FULL * $carry); + } + + if ($j < $stop) { + $product_value[$j] = $carry; + } + + // the above for loop is what the previous comment was talking about. the + // following for loop is the "one with nested for loops" + + for ($i = 1; $i < $y_length; ++$i) { + $carry = 0; + + for ($j = 0, $k = $i; $j < $x_length && $k < $stop; ++$j, ++$k) { + $temp = $product_value[$k] + $x_value[$j] * $y_value[$i] + $carry; + $carry = (int) ($temp / MATH_BIGINTEGER_BASE_FULL); + $product_value[$k] = (int) ($temp - MATH_BIGINTEGER_BASE_FULL * $carry); + } + + if ($k < $stop) { + $product_value[$k] = $carry; + } + } + + return array( + MATH_BIGINTEGER_VALUE => $this->_trim($product_value), + MATH_BIGINTEGER_SIGN => $x_negative != $y_negative + ); + } + + /** + * Montgomery Modular Reduction + * + * ($x->_prepMontgomery($n))->_montgomery($n) yields $x % $n. + * {@link http://math.libtomcrypt.com/files/tommath.pdf#page=170 MPM 6.3} provides insights on how this can be + * improved upon (basically, by using the comba method). gcd($n, 2) must be equal to one for this function + * to work correctly. + * + * @see _prepMontgomery() + * @see _slidingWindow() + * @access private + * @param Array $x + * @param Array $n + * @return Array + */ + function _montgomery($x, $n) + { + static $cache = array( + MATH_BIGINTEGER_VARIABLE => array(), + MATH_BIGINTEGER_DATA => array() + ); + + if ( ($key = array_search($n, $cache[MATH_BIGINTEGER_VARIABLE])) === false ) { + $key = count($cache[MATH_BIGINTEGER_VARIABLE]); + $cache[MATH_BIGINTEGER_VARIABLE][] = $x; + $cache[MATH_BIGINTEGER_DATA][] = $this->_modInverse67108864($n); + } + + $k = count($n); + + $result = array(MATH_BIGINTEGER_VALUE => $x); + + for ($i = 0; $i < $k; ++$i) { + $temp = $result[MATH_BIGINTEGER_VALUE][$i] * $cache[MATH_BIGINTEGER_DATA][$key]; + $temp = (int) ($temp - MATH_BIGINTEGER_BASE_FULL * ((int) ($temp / MATH_BIGINTEGER_BASE_FULL))); + $temp = $this->_regularMultiply(array($temp), $n); + $temp = array_merge($this->_array_repeat(0, $i), $temp); + $result = $this->_add($result[MATH_BIGINTEGER_VALUE], false, $temp, false); + } + + $result[MATH_BIGINTEGER_VALUE] = array_slice($result[MATH_BIGINTEGER_VALUE], $k); + + if ($this->_compare($result, false, $n, false) >= 0) { + $result = $this->_subtract($result[MATH_BIGINTEGER_VALUE], false, $n, false); + } + + return $result[MATH_BIGINTEGER_VALUE]; + } + + /** + * Montgomery Multiply + * + * Interleaves the montgomery reduction and long multiplication algorithms together as described in + * {@link http://www.cacr.math.uwaterloo.ca/hac/about/chap14.pdf#page=13 HAC 14.36} + * + * @see _prepMontgomery() + * @see _montgomery() + * @access private + * @param Array $x + * @param Array $y + * @param Array $m + * @return Array + */ + function _montgomeryMultiply($x, $y, $m) + { + $temp = $this->_multiply($x, false, $y, false); + return $this->_montgomery($temp[MATH_BIGINTEGER_VALUE], $m); + + static $cache = array( + MATH_BIGINTEGER_VARIABLE => array(), + MATH_BIGINTEGER_DATA => array() + ); + + if ( ($key = array_search($m, $cache[MATH_BIGINTEGER_VARIABLE])) === false ) { + $key = count($cache[MATH_BIGINTEGER_VARIABLE]); + $cache[MATH_BIGINTEGER_VARIABLE][] = $m; + $cache[MATH_BIGINTEGER_DATA][] = $this->_modInverse67108864($m); + } + + $n = max(count($x), count($y), count($m)); + $x = array_pad($x, $n, 0); + $y = array_pad($y, $n, 0); + $m = array_pad($m, $n, 0); + $a = array(MATH_BIGINTEGER_VALUE => $this->_array_repeat(0, $n + 1)); + for ($i = 0; $i < $n; ++$i) { + $temp = $a[MATH_BIGINTEGER_VALUE][0] + $x[$i] * $y[0]; + $temp = (int) ($temp - MATH_BIGINTEGER_BASE_FULL * ((int) ($temp / MATH_BIGINTEGER_BASE_FULL))); + $temp = $temp * $cache[MATH_BIGINTEGER_DATA][$key]; + $temp = (int) ($temp - MATH_BIGINTEGER_BASE_FULL * ((int) ($temp / MATH_BIGINTEGER_BASE_FULL))); + $temp = $this->_add($this->_regularMultiply(array($x[$i]), $y), false, $this->_regularMultiply(array($temp), $m), false); + $a = $this->_add($a[MATH_BIGINTEGER_VALUE], false, $temp[MATH_BIGINTEGER_VALUE], false); + $a[MATH_BIGINTEGER_VALUE] = array_slice($a[MATH_BIGINTEGER_VALUE], 1); + } + if ($this->_compare($a[MATH_BIGINTEGER_VALUE], false, $m, false) >= 0) { + $a = $this->_subtract($a[MATH_BIGINTEGER_VALUE], false, $m, false); + } + return $a[MATH_BIGINTEGER_VALUE]; + } + + /** + * Prepare a number for use in Montgomery Modular Reductions + * + * @see _montgomery() + * @see _slidingWindow() + * @access private + * @param Array $x + * @param Array $n + * @return Array + */ + function _prepMontgomery($x, $n) + { + $lhs = new Math_BigInteger(); + $lhs->value = array_merge($this->_array_repeat(0, count($n)), $x); + $rhs = new Math_BigInteger(); + $rhs->value = $n; + + list(, $temp) = $lhs->divide($rhs); + return $temp->value; + } + + /** + * Modular Inverse of a number mod 2**26 (eg. 67108864) + * + * Based off of the bnpInvDigit function implemented and justified in the following URL: + * + * {@link http://www-cs-students.stanford.edu/~tjw/jsbn/jsbn.js} + * + * The following URL provides more info: + * + * {@link http://groups.google.com/group/sci.crypt/msg/7a137205c1be7d85} + * + * As for why we do all the bitmasking... strange things can happen when converting from floats to ints. For + * instance, on some computers, var_dump((int) -4294967297) yields int(-1) and on others, it yields + * int(-2147483648). To avoid problems stemming from this, we use bitmasks to guarantee that ints aren't + * auto-converted to floats. The outermost bitmask is present because without it, there's no guarantee that + * the "residue" returned would be the so-called "common residue". We use fmod, in the last step, because the + * maximum possible $x is 26 bits and the maximum $result is 16 bits. Thus, we have to be able to handle up to + * 40 bits, which only 64-bit floating points will support. + * + * Thanks to Pedro Gimeno Fortea for input! + * + * @see _montgomery() + * @access private + * @param Array $x + * @return Integer + */ + function _modInverse67108864($x) // 2**26 == 67,108,864 + { + $x = -$x[0]; + $result = $x & 0x3; // x**-1 mod 2**2 + $result = ($result * (2 - $x * $result)) & 0xF; // x**-1 mod 2**4 + $result = ($result * (2 - ($x & 0xFF) * $result)) & 0xFF; // x**-1 mod 2**8 + $result = ($result * ((2 - ($x & 0xFFFF) * $result) & 0xFFFF)) & 0xFFFF; // x**-1 mod 2**16 + $result = fmod($result * (2 - fmod($x * $result, MATH_BIGINTEGER_BASE_FULL)), MATH_BIGINTEGER_BASE_FULL); // x**-1 mod 2**26 + return $result & MATH_BIGINTEGER_MAX_DIGIT; + } + + /** + * Calculates modular inverses. + * + * Say you have (30 mod 17 * x mod 17) mod 17 == 1. x can be found using modular inverses. + * + * Here's an example: + * + * modInverse($b); + * echo $c->toString(); // outputs 4 + * + * echo "\r\n"; + * + * $d = $a->multiply($c); + * list(, $d) = $d->divide($b); + * echo $d; // outputs 1 (as per the definition of modular inverse) + * ?> + * + * + * @param Math_BigInteger $n + * @return mixed false, if no modular inverse exists, Math_BigInteger, otherwise. + * @access public + * @internal See {@link http://www.cacr.math.uwaterloo.ca/hac/about/chap14.pdf#page=21 HAC 14.64} for more information. + */ + function modInverse($n) + { + switch ( MATH_BIGINTEGER_MODE ) { + case MATH_BIGINTEGER_MODE_GMP: + $temp = new Math_BigInteger(); + $temp->value = gmp_invert($this->value, $n->value); + + return ( $temp->value === false ) ? false : $this->_normalize($temp); + } + + static $zero, $one; + if (!isset($zero)) { + $zero = new Math_BigInteger(); + $one = new Math_BigInteger(1); + } + + // $x mod -$n == $x mod $n. + $n = $n->abs(); + + if ($this->compare($zero) < 0) { + $temp = $this->abs(); + $temp = $temp->modInverse($n); + return $this->_normalize($n->subtract($temp)); + } + + extract($this->extendedGCD($n)); + + if (!$gcd->equals($one)) { + return false; + } + + $x = $x->compare($zero) < 0 ? $x->add($n) : $x; + + return $this->compare($zero) < 0 ? $this->_normalize($n->subtract($x)) : $this->_normalize($x); + } + + /** + * Calculates the greatest common divisor and Bezout's identity. + * + * Say you have 693 and 609. The GCD is 21. Bezout's identity states that there exist integers x and y such that + * 693*x + 609*y == 21. In point of fact, there are actually an infinite number of x and y combinations and which + * combination is returned is dependant upon which mode is in use. See + * {@link http://en.wikipedia.org/wiki/B%C3%A9zout%27s_identity Bezout's identity - Wikipedia} for more information. + * + * Here's an example: + * + * extendedGCD($b)); + * + * echo $gcd->toString() . "\r\n"; // outputs 21 + * echo $a->toString() * $x->toString() + $b->toString() * $y->toString(); // outputs 21 + * ?> + * + * + * @param Math_BigInteger $n + * @return Math_BigInteger + * @access public + * @internal Calculates the GCD using the binary xGCD algorithim described in + * {@link http://www.cacr.math.uwaterloo.ca/hac/about/chap14.pdf#page=19 HAC 14.61}. As the text above 14.61 notes, + * the more traditional algorithim requires "relatively costly multiple-precision divisions". + */ + function extendedGCD($n) + { + switch ( MATH_BIGINTEGER_MODE ) { + case MATH_BIGINTEGER_MODE_GMP: + extract(gmp_gcdext($this->value, $n->value)); + + return array( + 'gcd' => $this->_normalize(new Math_BigInteger($g)), + 'x' => $this->_normalize(new Math_BigInteger($s)), + 'y' => $this->_normalize(new Math_BigInteger($t)) + ); + case MATH_BIGINTEGER_MODE_BCMATH: + // it might be faster to use the binary xGCD algorithim here, as well, but (1) that algorithim works + // best when the base is a power of 2 and (2) i don't think it'd make much difference, anyway. as is, + // the basic extended euclidean algorithim is what we're using. + + $u = $this->value; + $v = $n->value; + + $a = '1'; + $b = '0'; + $c = '0'; + $d = '1'; + + while (bccomp($v, '0', 0) != 0) { + $q = bcdiv($u, $v, 0); + + $temp = $u; + $u = $v; + $v = bcsub($temp, bcmul($v, $q, 0), 0); + + $temp = $a; + $a = $c; + $c = bcsub($temp, bcmul($a, $q, 0), 0); + + $temp = $b; + $b = $d; + $d = bcsub($temp, bcmul($b, $q, 0), 0); + } + + return array( + 'gcd' => $this->_normalize(new Math_BigInteger($u)), + 'x' => $this->_normalize(new Math_BigInteger($a)), + 'y' => $this->_normalize(new Math_BigInteger($b)) + ); + } + + $y = $n->copy(); + $x = $this->copy(); + $g = new Math_BigInteger(); + $g->value = array(1); + + while ( !(($x->value[0] & 1)|| ($y->value[0] & 1)) ) { + $x->_rshift(1); + $y->_rshift(1); + $g->_lshift(1); + } + + $u = $x->copy(); + $v = $y->copy(); + + $a = new Math_BigInteger(); + $b = new Math_BigInteger(); + $c = new Math_BigInteger(); + $d = new Math_BigInteger(); + + $a->value = $d->value = $g->value = array(1); + $b->value = $c->value = array(); + + while ( !empty($u->value) ) { + while ( !($u->value[0] & 1) ) { + $u->_rshift(1); + if ( (!empty($a->value) && ($a->value[0] & 1)) || (!empty($b->value) && ($b->value[0] & 1)) ) { + $a = $a->add($y); + $b = $b->subtract($x); + } + $a->_rshift(1); + $b->_rshift(1); + } + + while ( !($v->value[0] & 1) ) { + $v->_rshift(1); + if ( (!empty($d->value) && ($d->value[0] & 1)) || (!empty($c->value) && ($c->value[0] & 1)) ) { + $c = $c->add($y); + $d = $d->subtract($x); + } + $c->_rshift(1); + $d->_rshift(1); + } + + if ($u->compare($v) >= 0) { + $u = $u->subtract($v); + $a = $a->subtract($c); + $b = $b->subtract($d); + } else { + $v = $v->subtract($u); + $c = $c->subtract($a); + $d = $d->subtract($b); + } + } + + return array( + 'gcd' => $this->_normalize($g->multiply($v)), + 'x' => $this->_normalize($c), + 'y' => $this->_normalize($d) + ); + } + + /** + * Calculates the greatest common divisor + * + * Say you have 693 and 609. The GCD is 21. + * + * Here's an example: + * + * extendedGCD($b); + * + * echo $gcd->toString() . "\r\n"; // outputs 21 + * ?> + * + * + * @param Math_BigInteger $n + * @return Math_BigInteger + * @access public + */ + function gcd($n) + { + extract($this->extendedGCD($n)); + return $gcd; + } + + /** + * Absolute value. + * + * @return Math_BigInteger + * @access public + */ + function abs() + { + $temp = new Math_BigInteger(); + + switch ( MATH_BIGINTEGER_MODE ) { + case MATH_BIGINTEGER_MODE_GMP: + $temp->value = gmp_abs($this->value); + break; + case MATH_BIGINTEGER_MODE_BCMATH: + $temp->value = (bccomp($this->value, '0', 0) < 0) ? substr($this->value, 1) : $this->value; + break; + default: + $temp->value = $this->value; + } + + return $temp; + } + + /** + * Compares two numbers. + * + * Although one might think !$x->compare($y) means $x != $y, it, in fact, means the opposite. The reason for this is + * demonstrated thusly: + * + * $x > $y: $x->compare($y) > 0 + * $x < $y: $x->compare($y) < 0 + * $x == $y: $x->compare($y) == 0 + * + * Note how the same comparison operator is used. If you want to test for equality, use $x->equals($y). + * + * @param Math_BigInteger $y + * @return Integer < 0 if $this is less than $y; > 0 if $this is greater than $y, and 0 if they are equal. + * @access public + * @see equals() + * @internal Could return $this->subtract($x), but that's not as fast as what we do do. + */ + function compare($y) + { + switch ( MATH_BIGINTEGER_MODE ) { + case MATH_BIGINTEGER_MODE_GMP: + return gmp_cmp($this->value, $y->value); + case MATH_BIGINTEGER_MODE_BCMATH: + return bccomp($this->value, $y->value, 0); + } + + return $this->_compare($this->value, $this->is_negative, $y->value, $y->is_negative); + } + + /** + * Compares two numbers. + * + * @param Array $x_value + * @param Boolean $x_negative + * @param Array $y_value + * @param Boolean $y_negative + * @return Integer + * @see compare() + * @access private + */ + function _compare($x_value, $x_negative, $y_value, $y_negative) + { + if ( $x_negative != $y_negative ) { + return ( !$x_negative && $y_negative ) ? 1 : -1; + } + + $result = $x_negative ? -1 : 1; + + if ( count($x_value) != count($y_value) ) { + return ( count($x_value) > count($y_value) ) ? $result : -$result; + } + $size = max(count($x_value), count($y_value)); + + $x_value = array_pad($x_value, $size, 0); + $y_value = array_pad($y_value, $size, 0); + + for ($i = count($x_value) - 1; $i >= 0; --$i) { + if ($x_value[$i] != $y_value[$i]) { + return ( $x_value[$i] > $y_value[$i] ) ? $result : -$result; + } + } + + return 0; + } + + /** + * Tests the equality of two numbers. + * + * If you need to see if one number is greater than or less than another number, use Math_BigInteger::compare() + * + * @param Math_BigInteger $x + * @return Boolean + * @access public + * @see compare() + */ + function equals($x) + { + switch ( MATH_BIGINTEGER_MODE ) { + case MATH_BIGINTEGER_MODE_GMP: + return gmp_cmp($this->value, $x->value) == 0; + default: + return $this->value === $x->value && $this->is_negative == $x->is_negative; + } + } + + /** + * Set Precision + * + * Some bitwise operations give different results depending on the precision being used. Examples include left + * shift, not, and rotates. + * + * @param Integer $bits + * @access public + */ + function setPrecision($bits) + { + $this->precision = $bits; + if ( MATH_BIGINTEGER_MODE != MATH_BIGINTEGER_MODE_BCMATH ) { + $this->bitmask = new Math_BigInteger(chr((1 << ($bits & 0x7)) - 1) . str_repeat(chr(0xFF), $bits >> 3), 256); + } else { + $this->bitmask = new Math_BigInteger(bcpow('2', $bits, 0)); + } + + $temp = $this->_normalize($this); + $this->value = $temp->value; + } + + /** + * Logical And + * + * @param Math_BigInteger $x + * @access public + * @internal Implemented per a request by Lluis Pamies i Juarez + * @return Math_BigInteger + */ + function bitwise_and($x) + { + switch ( MATH_BIGINTEGER_MODE ) { + case MATH_BIGINTEGER_MODE_GMP: + $temp = new Math_BigInteger(); + $temp->value = gmp_and($this->value, $x->value); + + return $this->_normalize($temp); + case MATH_BIGINTEGER_MODE_BCMATH: + $left = $this->toBytes(); + $right = $x->toBytes(); + + $length = max(strlen($left), strlen($right)); + + $left = str_pad($left, $length, chr(0), STR_PAD_LEFT); + $right = str_pad($right, $length, chr(0), STR_PAD_LEFT); + + return $this->_normalize(new Math_BigInteger($left & $right, 256)); + } + + $result = $this->copy(); + + $length = min(count($x->value), count($this->value)); + + $result->value = array_slice($result->value, 0, $length); + + for ($i = 0; $i < $length; ++$i) { + $result->value[$i]&= $x->value[$i]; + } + + return $this->_normalize($result); + } + + /** + * Logical Or + * + * @param Math_BigInteger $x + * @access public + * @internal Implemented per a request by Lluis Pamies i Juarez + * @return Math_BigInteger + */ + function bitwise_or($x) + { + switch ( MATH_BIGINTEGER_MODE ) { + case MATH_BIGINTEGER_MODE_GMP: + $temp = new Math_BigInteger(); + $temp->value = gmp_or($this->value, $x->value); + + return $this->_normalize($temp); + case MATH_BIGINTEGER_MODE_BCMATH: + $left = $this->toBytes(); + $right = $x->toBytes(); + + $length = max(strlen($left), strlen($right)); + + $left = str_pad($left, $length, chr(0), STR_PAD_LEFT); + $right = str_pad($right, $length, chr(0), STR_PAD_LEFT); + + return $this->_normalize(new Math_BigInteger($left | $right, 256)); + } + + $length = max(count($this->value), count($x->value)); + $result = $this->copy(); + $result->value = array_pad($result->value, $length, 0); + $x->value = array_pad($x->value, $length, 0); + + for ($i = 0; $i < $length; ++$i) { + $result->value[$i]|= $x->value[$i]; + } + + return $this->_normalize($result); + } + + /** + * Logical Exclusive-Or + * + * @param Math_BigInteger $x + * @access public + * @internal Implemented per a request by Lluis Pamies i Juarez + * @return Math_BigInteger + */ + function bitwise_xor($x) + { + switch ( MATH_BIGINTEGER_MODE ) { + case MATH_BIGINTEGER_MODE_GMP: + $temp = new Math_BigInteger(); + $temp->value = gmp_xor($this->value, $x->value); + + return $this->_normalize($temp); + case MATH_BIGINTEGER_MODE_BCMATH: + $left = $this->toBytes(); + $right = $x->toBytes(); + + $length = max(strlen($left), strlen($right)); + + $left = str_pad($left, $length, chr(0), STR_PAD_LEFT); + $right = str_pad($right, $length, chr(0), STR_PAD_LEFT); + + return $this->_normalize(new Math_BigInteger($left ^ $right, 256)); + } + + $length = max(count($this->value), count($x->value)); + $result = $this->copy(); + $result->value = array_pad($result->value, $length, 0); + $x->value = array_pad($x->value, $length, 0); + + for ($i = 0; $i < $length; ++$i) { + $result->value[$i]^= $x->value[$i]; + } + + return $this->_normalize($result); + } + + /** + * Logical Not + * + * @access public + * @internal Implemented per a request by Lluis Pamies i Juarez + * @return Math_BigInteger + */ + function bitwise_not() + { + // calculuate "not" without regard to $this->precision + // (will always result in a smaller number. ie. ~1 isn't 1111 1110 - it's 0) + $temp = $this->toBytes(); + $pre_msb = decbin(ord($temp[0])); + $temp = ~$temp; + $msb = decbin(ord($temp[0])); + if (strlen($msb) == 8) { + $msb = substr($msb, strpos($msb, '0')); + } + $temp[0] = chr(bindec($msb)); + + // see if we need to add extra leading 1's + $current_bits = strlen($pre_msb) + 8 * strlen($temp) - 8; + $new_bits = $this->precision - $current_bits; + if ($new_bits <= 0) { + return $this->_normalize(new Math_BigInteger($temp, 256)); + } + + // generate as many leading 1's as we need to. + $leading_ones = chr((1 << ($new_bits & 0x7)) - 1) . str_repeat(chr(0xFF), $new_bits >> 3); + $this->_base256_lshift($leading_ones, $current_bits); + + $temp = str_pad($temp, ceil($this->bits / 8), chr(0), STR_PAD_LEFT); + + return $this->_normalize(new Math_BigInteger($leading_ones | $temp, 256)); + } + + /** + * Logical Right Shift + * + * Shifts BigInteger's by $shift bits, effectively dividing by 2**$shift. + * + * @param Integer $shift + * @return Math_BigInteger + * @access public + * @internal The only version that yields any speed increases is the internal version. + */ + function bitwise_rightShift($shift) + { + $temp = new Math_BigInteger(); + + switch ( MATH_BIGINTEGER_MODE ) { + case MATH_BIGINTEGER_MODE_GMP: + static $two; + + if (!isset($two)) { + $two = gmp_init('2'); + } + + $temp->value = gmp_div_q($this->value, gmp_pow($two, $shift)); + + break; + case MATH_BIGINTEGER_MODE_BCMATH: + $temp->value = bcdiv($this->value, bcpow('2', $shift, 0), 0); + + break; + default: // could just replace _lshift with this, but then all _lshift() calls would need to be rewritten + // and I don't want to do that... + $temp->value = $this->value; + $temp->_rshift($shift); + } + + return $this->_normalize($temp); + } + + /** + * Logical Left Shift + * + * Shifts BigInteger's by $shift bits, effectively multiplying by 2**$shift. + * + * @param Integer $shift + * @return Math_BigInteger + * @access public + * @internal The only version that yields any speed increases is the internal version. + */ + function bitwise_leftShift($shift) + { + $temp = new Math_BigInteger(); + + switch ( MATH_BIGINTEGER_MODE ) { + case MATH_BIGINTEGER_MODE_GMP: + static $two; + + if (!isset($two)) { + $two = gmp_init('2'); + } + + $temp->value = gmp_mul($this->value, gmp_pow($two, $shift)); + + break; + case MATH_BIGINTEGER_MODE_BCMATH: + $temp->value = bcmul($this->value, bcpow('2', $shift, 0), 0); + + break; + default: // could just replace _rshift with this, but then all _lshift() calls would need to be rewritten + // and I don't want to do that... + $temp->value = $this->value; + $temp->_lshift($shift); + } + + return $this->_normalize($temp); + } + + /** + * Logical Left Rotate + * + * Instead of the top x bits being dropped they're appended to the shifted bit string. + * + * @param Integer $shift + * @return Math_BigInteger + * @access public + */ + function bitwise_leftRotate($shift) + { + $bits = $this->toBytes(); + + if ($this->precision > 0) { + $precision = $this->precision; + if ( MATH_BIGINTEGER_MODE == MATH_BIGINTEGER_MODE_BCMATH ) { + $mask = $this->bitmask->subtract(new Math_BigInteger(1)); + $mask = $mask->toBytes(); + } else { + $mask = $this->bitmask->toBytes(); + } + } else { + $temp = ord($bits[0]); + for ($i = 0; $temp >> $i; ++$i); + $precision = 8 * strlen($bits) - 8 + $i; + $mask = chr((1 << ($precision & 0x7)) - 1) . str_repeat(chr(0xFF), $precision >> 3); + } + + if ($shift < 0) { + $shift+= $precision; + } + $shift%= $precision; + + if (!$shift) { + return $this->copy(); + } + + $left = $this->bitwise_leftShift($shift); + $left = $left->bitwise_and(new Math_BigInteger($mask, 256)); + $right = $this->bitwise_rightShift($precision - $shift); + $result = MATH_BIGINTEGER_MODE != MATH_BIGINTEGER_MODE_BCMATH ? $left->bitwise_or($right) : $left->add($right); + return $this->_normalize($result); + } + + /** + * Logical Right Rotate + * + * Instead of the bottom x bits being dropped they're prepended to the shifted bit string. + * + * @param Integer $shift + * @return Math_BigInteger + * @access public + */ + function bitwise_rightRotate($shift) + { + return $this->bitwise_leftRotate(-$shift); + } + + /** + * Set random number generator function + * + * This function is deprecated. + * + * @param String $generator + * @access public + */ + function setRandomGenerator($generator) + { + } + + /** + * Generates a random BigInteger + * + * Byte length is equal to $length. Uses crypt_random if it's loaded and mt_rand if it's not. + * + * @param Integer $length + * @return Math_BigInteger + * @access private + */ + function _random_number_helper($size) + { + $crypt_random = function_exists('crypt_random_string') || (!class_exists('Crypt_Random') && function_exists('crypt_random_string')); + if ($crypt_random) { + $random = crypt_random_string($size); + } else { + $random = ''; + + if ($size & 1) { + $random.= chr(mt_rand(0, 255)); + } + + $blocks = $size >> 1; + for ($i = 0; $i < $blocks; ++$i) { + // mt_rand(-2147483648, 0x7FFFFFFF) always produces -2147483648 on some systems + $random.= pack('n', mt_rand(0, 0xFFFF)); + } + } + + return new Math_BigInteger($random, 256); + } + + /** + * Generate a random number + * + * @param optional Integer $min + * @param optional Integer $max + * @return Math_BigInteger + * @access public + */ + function random($min = false, $max = false) + { + if ($min === false) { + $min = new Math_BigInteger(0); + } + + if ($max === false) { + $max = new Math_BigInteger(0x7FFFFFFF); + } + + $compare = $max->compare($min); + + if (!$compare) { + return $this->_normalize($min); + } else if ($compare < 0) { + // if $min is bigger then $max, swap $min and $max + $temp = $max; + $max = $min; + $min = $temp; + } + + static $one; + if (!isset($one)) { + $one = new Math_BigInteger(1); + } + + $max = $max->subtract($min->subtract($one)); + $size = strlen(ltrim($max->toBytes(), chr(0))); + + /* + doing $random % $max doesn't work because some numbers will be more likely to occur than others. + eg. if $max is 140 and $random's max is 255 then that'd mean both $random = 5 and $random = 145 + would produce 5 whereas the only value of random that could produce 139 would be 139. ie. + not all numbers would be equally likely. some would be more likely than others. + + creating a whole new random number until you find one that is within the range doesn't work + because, for sufficiently small ranges, the likelihood that you'd get a number within that range + would be pretty small. eg. with $random's max being 255 and if your $max being 1 the probability + would be pretty high that $random would be greater than $max. + + phpseclib works around this using the technique described here: + + http://crypto.stackexchange.com/questions/5708/creating-a-small-number-from-a-cryptographically-secure-random-string + */ + $random_max = new Math_BigInteger(chr(1) . str_repeat("\0", $size), 256); + $random = $this->_random_number_helper($size); + + list($max_multiple) = $random_max->divide($max); + $max_multiple = $max_multiple->multiply($max); + + while ($random->compare($max_multiple) >= 0) { + $random = $random->subtract($max_multiple); + $random_max = $random_max->subtract($max_multiple); + $random = $random->bitwise_leftShift(8); + $random = $random->add($this->_random_number_helper(1)); + $random_max = $random_max->bitwise_leftShift(8); + list($max_multiple) = $random_max->divide($max); + $max_multiple = $max_multiple->multiply($max); + } + list(, $random) = $random->divide($max); + + return $this->_normalize($random->add($min)); + } + + /** + * Generate a random prime number. + * + * If there's not a prime within the given range, false will be returned. If more than $timeout seconds have elapsed, + * give up and return false. + * + * @param optional Integer $min + * @param optional Integer $max + * @param optional Integer $timeout + * @return Math_BigInteger + * @access public + * @internal See {@link http://www.cacr.math.uwaterloo.ca/hac/about/chap4.pdf#page=15 HAC 4.44}. + */ + function randomPrime($min = false, $max = false, $timeout = false) + { + if ($min === false) { + $min = new Math_BigInteger(0); + } + + if ($max === false) { + $max = new Math_BigInteger(0x7FFFFFFF); + } + + $compare = $max->compare($min); + + if (!$compare) { + return $min->isPrime() ? $min : false; + } else if ($compare < 0) { + // if $min is bigger then $max, swap $min and $max + $temp = $max; + $max = $min; + $min = $temp; + } + + static $one, $two; + if (!isset($one)) { + $one = new Math_BigInteger(1); + $two = new Math_BigInteger(2); + } + + $start = time(); + + $x = $this->random($min, $max); + + // gmp_nextprime() requires PHP 5 >= 5.2.0 per . + if ( MATH_BIGINTEGER_MODE == MATH_BIGINTEGER_MODE_GMP && function_exists('gmp_nextprime') ) { + $p = new Math_BigInteger(); + $p->value = gmp_nextprime($x->value); + + if ($p->compare($max) <= 0) { + return $p; + } + + if (!$min->equals($x)) { + $x = $x->subtract($one); + } + + return $x->randomPrime($min, $x); + } + + if ($x->equals($two)) { + return $x; + } + + $x->_make_odd(); + if ($x->compare($max) > 0) { + // if $x > $max then $max is even and if $min == $max then no prime number exists between the specified range + if ($min->equals($max)) { + return false; + } + $x = $min->copy(); + $x->_make_odd(); + } + + $initial_x = $x->copy(); + + while (true) { + if ($timeout !== false && time() - $start > $timeout) { + return false; + } + + if ($x->isPrime()) { + return $x; + } + + $x = $x->add($two); + + if ($x->compare($max) > 0) { + $x = $min->copy(); + if ($x->equals($two)) { + return $x; + } + $x->_make_odd(); + } + + if ($x->equals($initial_x)) { + return false; + } + } + } + + /** + * Make the current number odd + * + * If the current number is odd it'll be unchanged. If it's even, one will be added to it. + * + * @see randomPrime() + * @access private + */ + function _make_odd() + { + switch ( MATH_BIGINTEGER_MODE ) { + case MATH_BIGINTEGER_MODE_GMP: + gmp_setbit($this->value, 0); + break; + case MATH_BIGINTEGER_MODE_BCMATH: + if ($this->value[strlen($this->value) - 1] % 2 == 0) { + $this->value = bcadd($this->value, '1'); + } + break; + default: + $this->value[0] |= 1; + } + } + + /** + * Checks a numer to see if it's prime + * + * Assuming the $t parameter is not set, this function has an error rate of 2**-80. The main motivation for the + * $t parameter is distributability. Math_BigInteger::randomPrime() can be distributed accross multiple pageloads + * on a website instead of just one. + * + * @param optional Integer $t + * @return Boolean + * @access public + * @internal Uses the + * {@link http://en.wikipedia.org/wiki/Miller%E2%80%93Rabin_primality_test Miller-Rabin primality test}. See + * {@link http://www.cacr.math.uwaterloo.ca/hac/about/chap4.pdf#page=8 HAC 4.24}. + */ + function isPrime($t = false) + { + $length = strlen($this->toBytes()); + + if (!$t) { + // see HAC 4.49 "Note (controlling the error probability)" + // @codingStandardsIgnoreStart + if ($length >= 163) { $t = 2; } // floor(1300 / 8) + else if ($length >= 106) { $t = 3; } // floor( 850 / 8) + else if ($length >= 81 ) { $t = 4; } // floor( 650 / 8) + else if ($length >= 68 ) { $t = 5; } // floor( 550 / 8) + else if ($length >= 56 ) { $t = 6; } // floor( 450 / 8) + else if ($length >= 50 ) { $t = 7; } // floor( 400 / 8) + else if ($length >= 43 ) { $t = 8; } // floor( 350 / 8) + else if ($length >= 37 ) { $t = 9; } // floor( 300 / 8) + else if ($length >= 31 ) { $t = 12; } // floor( 250 / 8) + else if ($length >= 25 ) { $t = 15; } // floor( 200 / 8) + else if ($length >= 18 ) { $t = 18; } // floor( 150 / 8) + else { $t = 27; } + // @codingStandardsIgnoreEnd + } + + // ie. gmp_testbit($this, 0) + // ie. isEven() or !isOdd() + switch ( MATH_BIGINTEGER_MODE ) { + case MATH_BIGINTEGER_MODE_GMP: + return gmp_prob_prime($this->value, $t) != 0; + case MATH_BIGINTEGER_MODE_BCMATH: + if ($this->value === '2') { + return true; + } + if ($this->value[strlen($this->value) - 1] % 2 == 0) { + return false; + } + break; + default: + if ($this->value == array(2)) { + return true; + } + if (~$this->value[0] & 1) { + return false; + } + } + + static $primes, $zero, $one, $two; + + if (!isset($primes)) { + $primes = array( + 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, + 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, + 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, + 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, + 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, + 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, + 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, + 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, + 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, + 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, + 953, 967, 971, 977, 983, 991, 997 + ); + + if ( MATH_BIGINTEGER_MODE != MATH_BIGINTEGER_MODE_INTERNAL ) { + for ($i = 0; $i < count($primes); ++$i) { + $primes[$i] = new Math_BigInteger($primes[$i]); + } + } + + $zero = new Math_BigInteger(); + $one = new Math_BigInteger(1); + $two = new Math_BigInteger(2); + } + + if ($this->equals($one)) { + return false; + } + + // see HAC 4.4.1 "Random search for probable primes" + if ( MATH_BIGINTEGER_MODE != MATH_BIGINTEGER_MODE_INTERNAL ) { + foreach ($primes as $prime) { + list(, $r) = $this->divide($prime); + if ($r->equals($zero)) { + return $this->equals($prime); + } + } + } else { + $value = $this->value; + foreach ($primes as $prime) { + list(, $r) = $this->_divide_digit($value, $prime); + if (!$r) { + return count($value) == 1 && $value[0] == $prime; + } + } + } + + $n = $this->copy(); + $n_1 = $n->subtract($one); + $n_2 = $n->subtract($two); + + $r = $n_1->copy(); + $r_value = $r->value; + // ie. $s = gmp_scan1($n, 0) and $r = gmp_div_q($n, gmp_pow(gmp_init('2'), $s)); + if ( MATH_BIGINTEGER_MODE == MATH_BIGINTEGER_MODE_BCMATH ) { + $s = 0; + // if $n was 1, $r would be 0 and this would be an infinite loop, hence our $this->equals($one) check earlier + while ($r->value[strlen($r->value) - 1] % 2 == 0) { + $r->value = bcdiv($r->value, '2', 0); + ++$s; + } + } else { + for ($i = 0, $r_length = count($r_value); $i < $r_length; ++$i) { + $temp = ~$r_value[$i] & 0xFFFFFF; + for ($j = 1; ($temp >> $j) & 1; ++$j); + if ($j != 25) { + break; + } + } + $s = 26 * $i + $j - 1; + $r->_rshift($s); + } + + for ($i = 0; $i < $t; ++$i) { + $a = $this->random($two, $n_2); + $y = $a->modPow($r, $n); + + if (!$y->equals($one) && !$y->equals($n_1)) { + for ($j = 1; $j < $s && !$y->equals($n_1); ++$j) { + $y = $y->modPow($two, $n); + if ($y->equals($one)) { + return false; + } + } + + if (!$y->equals($n_1)) { + return false; + } + } + } + return true; + } + + /** + * Logical Left Shift + * + * Shifts BigInteger's by $shift bits. + * + * @param Integer $shift + * @access private + */ + function _lshift($shift) + { + if ( $shift == 0 ) { + return; + } + + $num_digits = (int) ($shift / MATH_BIGINTEGER_BASE); + $shift %= MATH_BIGINTEGER_BASE; + $shift = 1 << $shift; + + $carry = 0; + + for ($i = 0; $i < count($this->value); ++$i) { + $temp = $this->value[$i] * $shift + $carry; + $carry = (int) ($temp / MATH_BIGINTEGER_BASE_FULL); + $this->value[$i] = (int) ($temp - $carry * MATH_BIGINTEGER_BASE_FULL); + } + + if ( $carry ) { + $this->value[] = $carry; + } + + while ($num_digits--) { + array_unshift($this->value, 0); + } + } + + /** + * Logical Right Shift + * + * Shifts BigInteger's by $shift bits. + * + * @param Integer $shift + * @access private + */ + function _rshift($shift) + { + if ($shift == 0) { + return; + } + + $num_digits = (int) ($shift / MATH_BIGINTEGER_BASE); + $shift %= MATH_BIGINTEGER_BASE; + $carry_shift = MATH_BIGINTEGER_BASE - $shift; + $carry_mask = (1 << $shift) - 1; + + if ( $num_digits ) { + $this->value = array_slice($this->value, $num_digits); + } + + $carry = 0; + + for ($i = count($this->value) - 1; $i >= 0; --$i) { + $temp = $this->value[$i] >> $shift | $carry; + $carry = ($this->value[$i] & $carry_mask) << $carry_shift; + $this->value[$i] = $temp; + } + + $this->value = $this->_trim($this->value); + } + + /** + * Normalize + * + * Removes leading zeros and truncates (if necessary) to maintain the appropriate precision + * + * @param Math_BigInteger + * @return Math_BigInteger + * @see _trim() + * @access private + */ + function _normalize($result) + { + $result->precision = $this->precision; + $result->bitmask = $this->bitmask; + + switch ( MATH_BIGINTEGER_MODE ) { + case MATH_BIGINTEGER_MODE_GMP: + if (!empty($result->bitmask->value)) { + $result->value = gmp_and($result->value, $result->bitmask->value); + } + + return $result; + case MATH_BIGINTEGER_MODE_BCMATH: + if (!empty($result->bitmask->value)) { + $result->value = bcmod($result->value, $result->bitmask->value); + } + + return $result; + } + + $value = &$result->value; + + if ( !count($value) ) { + return $result; + } + + $value = $this->_trim($value); + + if (!empty($result->bitmask->value)) { + $length = min(count($value), count($this->bitmask->value)); + $value = array_slice($value, 0, $length); + + for ($i = 0; $i < $length; ++$i) { + $value[$i] = $value[$i] & $this->bitmask->value[$i]; + } + } + + return $result; + } + + /** + * Trim + * + * Removes leading zeros + * + * @param Array $value + * @return Math_BigInteger + * @access private + */ + function _trim($value) + { + for ($i = count($value) - 1; $i >= 0; --$i) { + if ( $value[$i] ) { + break; + } + unset($value[$i]); + } + + return $value; + } + + /** + * Array Repeat + * + * @param $input Array + * @param $multiplier mixed + * @return Array + * @access private + */ + function _array_repeat($input, $multiplier) + { + return ($multiplier) ? array_fill(0, $multiplier, $input) : array(); + } + + /** + * Logical Left Shift + * + * Shifts binary strings $shift bits, essentially multiplying by 2**$shift. + * + * @param $x String + * @param $shift Integer + * @return String + * @access private + */ + function _base256_lshift(&$x, $shift) + { + if ($shift == 0) { + return; + } + + $num_bytes = $shift >> 3; // eg. floor($shift/8) + $shift &= 7; // eg. $shift % 8 + + $carry = 0; + for ($i = strlen($x) - 1; $i >= 0; --$i) { + $temp = ord($x[$i]) << $shift | $carry; + $x[$i] = chr($temp); + $carry = $temp >> 8; + } + $carry = ($carry != 0) ? chr($carry) : ''; + $x = $carry . $x . str_repeat(chr(0), $num_bytes); + } + + /** + * Logical Right Shift + * + * Shifts binary strings $shift bits, essentially dividing by 2**$shift and returning the remainder. + * + * @param $x String + * @param $shift Integer + * @return String + * @access private + */ + function _base256_rshift(&$x, $shift) + { + if ($shift == 0) { + $x = ltrim($x, chr(0)); + return ''; + } + + $num_bytes = $shift >> 3; // eg. floor($shift/8) + $shift &= 7; // eg. $shift % 8 + + $remainder = ''; + if ($num_bytes) { + $start = $num_bytes > strlen($x) ? -strlen($x) : -$num_bytes; + $remainder = substr($x, $start); + $x = substr($x, 0, -$num_bytes); + } + + $carry = 0; + $carry_shift = 8 - $shift; + for ($i = 0; $i < strlen($x); ++$i) { + $temp = (ord($x[$i]) >> $shift) | $carry; + $carry = (ord($x[$i]) << $carry_shift) & 0xFF; + $x[$i] = chr($temp); + } + $x = ltrim($x, chr(0)); + + $remainder = chr($carry >> $carry_shift) . $remainder; + + return ltrim($remainder, chr(0)); + } + + // one quirk about how the following functions are implemented is that PHP defines N to be an unsigned long + // at 32-bits, while java's longs are 64-bits. + + /** + * Converts 32-bit integers to bytes. + * + * @param Integer $x + * @return String + * @access private + */ + function _int2bytes($x) + { + return ltrim(pack('N', $x), chr(0)); + } + + /** + * Converts bytes to 32-bit integers + * + * @param String $x + * @return Integer + * @access private + */ + function _bytes2int($x) + { + $temp = unpack('Nint', str_pad($x, 4, chr(0), STR_PAD_LEFT)); + return $temp['int']; + } + + /** + * DER-encode an integer + * + * The ability to DER-encode integers is needed to create RSA public keys for use with OpenSSL + * + * @see modPow() + * @access private + * @param Integer $length + * @return String + */ + function _encodeASN1Length($length) + { + if ($length <= 0x7F) { + return chr($length); + } + + $temp = ltrim(pack('N', $length), chr(0)); + return pack('Ca*', 0x80 | strlen($temp), $temp); + } +} diff --git a/vendor/phpseclib/phpseclib/phpseclib/Net/SCP.php b/vendor/phpseclib/phpseclib/phpseclib/Net/SCP.php new file mode 100755 index 0000000..4cfa357 --- /dev/null +++ b/vendor/phpseclib/phpseclib/phpseclib/Net/SCP.php @@ -0,0 +1,362 @@ + + * login('username', 'password')) { + * exit('bad login'); + * } + + * $scp = new Net_SCP($ssh); + * $scp->put('abcd', str_repeat('x', 1024*1024)); + * ?> + * + * + * LICENSE: Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * @category Net + * @package Net_SCP + * @author Jim Wigginton + * @copyright MMX Jim Wigginton + * @license http://www.opensource.org/licenses/mit-license.html MIT License + * @link http://phpseclib.sourceforge.net + */ + +/**#@+ + * @access public + * @see Net_SCP::put() + */ +/** + * Reads data from a local file. + */ +define('NET_SCP_LOCAL_FILE', 1); +/** + * Reads data from a string. + */ +define('NET_SCP_STRING', 2); +/**#@-*/ + +/**#@+ + * @access private + * @see Net_SCP::_send() + * @see Net_SCP::_receive() + */ +/** + * SSH1 is being used. + */ +define('NET_SCP_SSH1', 1); +/** + * SSH2 is being used. + */ +define('NET_SCP_SSH2', 2); +/**#@-*/ + +/** + * Pure-PHP implementations of SCP. + * + * @package Net_SCP + * @author Jim Wigginton + * @version 0.1.0 + * @access public + */ +class Net_SCP +{ + /** + * SSH Object + * + * @var Object + * @access private + */ + var $ssh; + + /** + * Packet Size + * + * @var Integer + * @access private + */ + var $packet_size; + + /** + * Mode + * + * @var Integer + * @access private + */ + var $mode; + + /** + * Default Constructor. + * + * Connects to an SSH server + * + * @param String $host + * @param optional Integer $port + * @param optional Integer $timeout + * @return Net_SCP + * @access public + */ + function Net_SCP($ssh) + { + if (!is_object($ssh)) { + return; + } + + switch (strtolower(get_class($ssh))) { + case'net_ssh2': + $this->mode = NET_SCP_SSH2; + break; + case 'net_ssh1': + $this->packet_size = 50000; + $this->mode = NET_SCP_SSH1; + break; + default: + return; + } + + $this->ssh = $ssh; + } + + /** + * Uploads a file to the SCP server. + * + * By default, Net_SCP::put() does not read from the local filesystem. $data is dumped directly into $remote_file. + * So, for example, if you set $data to 'filename.ext' and then do Net_SCP::get(), you will get a file, twelve bytes + * long, containing 'filename.ext' as its contents. + * + * Setting $mode to NET_SCP_LOCAL_FILE will change the above behavior. With NET_SCP_LOCAL_FILE, $remote_file will + * contain as many bytes as filename.ext does on your local filesystem. If your filename.ext is 1MB then that is how + * large $remote_file will be, as well. + * + * Currently, only binary mode is supported. As such, if the line endings need to be adjusted, you will need to take + * care of that, yourself. + * + * @param String $remote_file + * @param String $data + * @param optional Integer $mode + * @param optional Callable $callback + * @return Boolean + * @access public + */ + function put($remote_file, $data, $mode = NET_SCP_STRING, $callback = null) + { + if (!isset($this->ssh)) { + return false; + } + + if (!$this->ssh->exec('scp -t ' . $remote_file, false)) { // -t = to + return false; + } + + $temp = $this->_receive(); + if ($temp !== chr(0)) { + return false; + } + + if ($this->mode == NET_SCP_SSH2) { + $this->packet_size = $this->ssh->packet_size_client_to_server[NET_SSH2_CHANNEL_EXEC] - 4; + } + + $remote_file = basename($remote_file); + + if ($mode == NET_SCP_STRING) { + $size = strlen($data); + } else { + if (!is_file($data)) { + user_error("$data is not a valid file", E_USER_NOTICE); + return false; + } + + $fp = @fopen($data, 'rb'); + if (!$fp) { + fclose($fp); + return false; + } + $size = filesize($data); + } + + $this->_send('C0644 ' . $size . ' ' . $remote_file . "\n"); + + $temp = $this->_receive(); + if ($temp !== chr(0)) { + return false; + } + + $sent = 0; + while ($sent < $size) { + $temp = $mode & NET_SCP_STRING ? substr($data, $sent, $this->packet_size) : fread($fp, $this->packet_size); + $this->_send($temp); + $sent+= strlen($temp); + + if (is_callable($callback)) { + $callback($sent); + } + } + $this->_close(); + + if ($mode != NET_SCP_STRING) { + fclose($fp); + } + + return true; + } + + /** + * Downloads a file from the SCP server. + * + * Returns a string containing the contents of $remote_file if $local_file is left undefined or a boolean false if + * the operation was unsuccessful. If $local_file is defined, returns true or false depending on the success of the + * operation + * + * @param String $remote_file + * @param optional String $local_file + * @return Mixed + * @access public + */ + function get($remote_file, $local_file = false) + { + if (!isset($this->ssh)) { + return false; + } + + if (!$this->ssh->exec('scp -f ' . $remote_file, false)) { // -f = from + return false; + } + + $this->_send("\0"); + + if (!preg_match('#(?[^ ]+) (?\d+) (?.+)#', rtrim($this->_receive()), $info)) { + return false; + } + + $this->_send("\0"); + + $size = 0; + + if ($local_file !== false) { + $fp = @fopen($local_file, 'wb'); + if (!$fp) { + return false; + } + } + + $content = ''; + while ($size < $info['size']) { + $data = $this->_receive(); + // SCP usually seems to split stuff out into 16k chunks + $size+= strlen($data); + + if ($local_file === false) { + $content.= $data; + } else { + fputs($fp, $data); + } + } + + $this->_close(); + + if ($local_file !== false) { + fclose($fp); + return true; + } + + return $content; + } + + /** + * Sends a packet to an SSH server + * + * @param String $data + * @access private + */ + function _send($data) + { + switch ($this->mode) { + case NET_SCP_SSH2: + $this->ssh->_send_channel_packet(NET_SSH2_CHANNEL_EXEC, $data); + break; + case NET_SCP_SSH1: + $data = pack('CNa*', NET_SSH1_CMSG_STDIN_DATA, strlen($data), $data); + $this->ssh->_send_binary_packet($data); + } + } + + /** + * Receives a packet from an SSH server + * + * @return String + * @access private + */ + function _receive() + { + switch ($this->mode) { + case NET_SCP_SSH2: + return $this->ssh->_get_channel_packet(NET_SSH2_CHANNEL_EXEC, true); + case NET_SCP_SSH1: + if (!$this->ssh->bitmap) { + return false; + } + while (true) { + $response = $this->ssh->_get_binary_packet(); + switch ($response[NET_SSH1_RESPONSE_TYPE]) { + case NET_SSH1_SMSG_STDOUT_DATA: + extract(unpack('Nlength', $response[NET_SSH1_RESPONSE_DATA])); + return $this->ssh->_string_shift($response[NET_SSH1_RESPONSE_DATA], $length); + case NET_SSH1_SMSG_STDERR_DATA: + break; + case NET_SSH1_SMSG_EXITSTATUS: + $this->ssh->_send_binary_packet(chr(NET_SSH1_CMSG_EXIT_CONFIRMATION)); + fclose($this->ssh->fsock); + $this->ssh->bitmap = 0; + return false; + default: + user_error('Unknown packet received', E_USER_NOTICE); + return false; + } + } + } + } + + /** + * Closes the connection to an SSH server + * + * @access private + */ + function _close() + { + switch ($this->mode) { + case NET_SCP_SSH2: + $this->ssh->_close_channel(NET_SSH2_CHANNEL_EXEC, true); + break; + case NET_SCP_SSH1: + $this->ssh->disconnect(); + } + } +} diff --git a/vendor/phpseclib/phpseclib/phpseclib/Net/SFTP.php b/vendor/phpseclib/phpseclib/phpseclib/Net/SFTP.php new file mode 100755 index 0000000..68d944f --- /dev/null +++ b/vendor/phpseclib/phpseclib/phpseclib/Net/SFTP.php @@ -0,0 +1,2226 @@ + + * login('username', 'password')) { + * exit('Login Failed'); + * } + * + * echo $sftp->pwd() . "\r\n"; + * $sftp->put('filename.ext', 'hello, world!'); + * print_r($sftp->nlist()); + * ?> + * + * + * LICENSE: Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * @category Net + * @package Net_SFTP + * @author Jim Wigginton + * @copyright MMIX Jim Wigginton + * @license http://www.opensource.org/licenses/mit-license.html MIT License + * @link http://phpseclib.sourceforge.net + */ + +/** + * Include Net_SSH2 + */ +if (!class_exists('Net_SSH2')) { + include_once 'SSH2.php'; +} + +/**#@+ + * @access public + * @see Net_SFTP::getLog() + */ +/** + * Returns the message numbers + */ +define('NET_SFTP_LOG_SIMPLE', NET_SSH2_LOG_SIMPLE); +/** + * Returns the message content + */ +define('NET_SFTP_LOG_COMPLEX', NET_SSH2_LOG_COMPLEX); +/** + * Outputs the message content in real-time. + */ +define('NET_SFTP_LOG_REALTIME', 3); +/**#@-*/ + +/** + * SFTP channel constant + * + * Net_SSH2::exec() uses 0 and Net_SSH2::read() / Net_SSH2::write() use 1. + * + * @see Net_SSH2::_send_channel_packet() + * @see Net_SSH2::_get_channel_packet() + * @access private + */ +define('NET_SFTP_CHANNEL', 0x100); + +/**#@+ + * @access public + * @see Net_SFTP::put() + */ +/** + * Reads data from a local file. + */ +define('NET_SFTP_LOCAL_FILE', 1); +/** + * Reads data from a string. + */ +// this value isn't really used anymore but i'm keeping it reserved for historical reasons +define('NET_SFTP_STRING', 2); +/** + * Resumes an upload + */ +define('NET_SFTP_RESUME', 4); +/** + * Append a local file to an already existing remote file + */ +define('NET_SFTP_RESUME_START', 8); +/**#@-*/ + +/** + * Pure-PHP implementations of SFTP. + * + * @package Net_SFTP + * @author Jim Wigginton + * @version 0.1.0 + * @access public + */ +class Net_SFTP extends Net_SSH2 +{ + /** + * Packet Types + * + * @see Net_SFTP::Net_SFTP() + * @var Array + * @access private + */ + var $packet_types = array(); + + /** + * Status Codes + * + * @see Net_SFTP::Net_SFTP() + * @var Array + * @access private + */ + var $status_codes = array(); + + /** + * The Request ID + * + * The request ID exists in the off chance that a packet is sent out-of-order. Of course, this library doesn't support + * concurrent actions, so it's somewhat academic, here. + * + * @var Integer + * @see Net_SFTP::_send_sftp_packet() + * @access private + */ + var $request_id = false; + + /** + * The Packet Type + * + * The request ID exists in the off chance that a packet is sent out-of-order. Of course, this library doesn't support + * concurrent actions, so it's somewhat academic, here. + * + * @var Integer + * @see Net_SFTP::_get_sftp_packet() + * @access private + */ + var $packet_type = -1; + + /** + * Packet Buffer + * + * @var String + * @see Net_SFTP::_get_sftp_packet() + * @access private + */ + var $packet_buffer = ''; + + /** + * Extensions supported by the server + * + * @var Array + * @see Net_SFTP::_initChannel() + * @access private + */ + var $extensions = array(); + + /** + * Server SFTP version + * + * @var Integer + * @see Net_SFTP::_initChannel() + * @access private + */ + var $version; + + /** + * Current working directory + * + * @var String + * @see Net_SFTP::_realpath() + * @see Net_SFTP::chdir() + * @access private + */ + var $pwd = false; + + /** + * Packet Type Log + * + * @see Net_SFTP::getLog() + * @var Array + * @access private + */ + var $packet_type_log = array(); + + /** + * Packet Log + * + * @see Net_SFTP::getLog() + * @var Array + * @access private + */ + var $packet_log = array(); + + /** + * Error information + * + * @see Net_SFTP::getSFTPErrors() + * @see Net_SFTP::getLastSFTPError() + * @var String + * @access private + */ + var $sftp_errors = array(); + + /** + * Directory Cache + * + * Rather than always having to open a directory and close it immediately there after to see if a file is a directory or + * rather than always + * + * @see Net_SFTP::_save_dir() + * @see Net_SFTP::_remove_dir() + * @see Net_SFTP::_is_dir() + * @var Array + * @access private + */ + var $dirs = array(); + + /** + * Max SFTP Packet Size + * + * @see Net_SFTP::Net_SFTP() + * @see Net_SFTP::get() + * @var Array + * @access private + */ + var $max_sftp_packet; + + /** + * Default Constructor. + * + * Connects to an SFTP server + * + * @param String $host + * @param optional Integer $port + * @param optional Integer $timeout + * @return Net_SFTP + * @access public + */ + function Net_SFTP($host, $port = 22, $timeout = 10) + { + parent::Net_SSH2($host, $port, $timeout); + + $this->max_sftp_packet = 1 << 15; + + $this->packet_types = array( + 1 => 'NET_SFTP_INIT', + 2 => 'NET_SFTP_VERSION', + /* the format of SSH_FXP_OPEN changed between SFTPv4 and SFTPv5+: + SFTPv5+: http://tools.ietf.org/html/draft-ietf-secsh-filexfer-13#section-8.1.1 + pre-SFTPv5 : http://tools.ietf.org/html/draft-ietf-secsh-filexfer-04#section-6.3 */ + 3 => 'NET_SFTP_OPEN', + 4 => 'NET_SFTP_CLOSE', + 5 => 'NET_SFTP_READ', + 6 => 'NET_SFTP_WRITE', + 7 => 'NET_SFTP_LSTAT', + 9 => 'NET_SFTP_SETSTAT', + 11 => 'NET_SFTP_OPENDIR', + 12 => 'NET_SFTP_READDIR', + 13 => 'NET_SFTP_REMOVE', + 14 => 'NET_SFTP_MKDIR', + 15 => 'NET_SFTP_RMDIR', + 16 => 'NET_SFTP_REALPATH', + 17 => 'NET_SFTP_STAT', + /* the format of SSH_FXP_RENAME changed between SFTPv4 and SFTPv5+: + SFTPv5+: http://tools.ietf.org/html/draft-ietf-secsh-filexfer-13#section-8.3 + pre-SFTPv5 : http://tools.ietf.org/html/draft-ietf-secsh-filexfer-04#section-6.5 */ + 18 => 'NET_SFTP_RENAME', + + 101=> 'NET_SFTP_STATUS', + 102=> 'NET_SFTP_HANDLE', + /* the format of SSH_FXP_NAME changed between SFTPv3 and SFTPv4+: + SFTPv4+: http://tools.ietf.org/html/draft-ietf-secsh-filexfer-13#section-9.4 + pre-SFTPv4 : http://tools.ietf.org/html/draft-ietf-secsh-filexfer-02#section-7 */ + 103=> 'NET_SFTP_DATA', + 104=> 'NET_SFTP_NAME', + 105=> 'NET_SFTP_ATTRS', + + 200=> 'NET_SFTP_EXTENDED' + ); + $this->status_codes = array( + 0 => 'NET_SFTP_STATUS_OK', + 1 => 'NET_SFTP_STATUS_EOF', + 2 => 'NET_SFTP_STATUS_NO_SUCH_FILE', + 3 => 'NET_SFTP_STATUS_PERMISSION_DENIED', + 4 => 'NET_SFTP_STATUS_FAILURE', + 5 => 'NET_SFTP_STATUS_BAD_MESSAGE', + 6 => 'NET_SFTP_STATUS_NO_CONNECTION', + 7 => 'NET_SFTP_STATUS_CONNECTION_LOST', + 8 => 'NET_SFTP_STATUS_OP_UNSUPPORTED', + 9 => 'NET_SFTP_STATUS_INVALID_HANDLE', + 10 => 'NET_SFTP_STATUS_NO_SUCH_PATH', + 11 => 'NET_SFTP_STATUS_FILE_ALREADY_EXISTS', + 12 => 'NET_SFTP_STATUS_WRITE_PROTECT', + 13 => 'NET_SFTP_STATUS_NO_MEDIA', + 14 => 'NET_SFTP_STATUS_NO_SPACE_ON_FILESYSTEM', + 15 => 'NET_SFTP_STATUS_QUOTA_EXCEEDED', + 16 => 'NET_SFTP_STATUS_UNKNOWN_PRINCIPAL', + 17 => 'NET_SFTP_STATUS_LOCK_CONFLICT', + 18 => 'NET_SFTP_STATUS_DIR_NOT_EMPTY', + 19 => 'NET_SFTP_STATUS_NOT_A_DIRECTORY', + 20 => 'NET_SFTP_STATUS_INVALID_FILENAME', + 21 => 'NET_SFTP_STATUS_LINK_LOOP', + 22 => 'NET_SFTP_STATUS_CANNOT_DELETE', + 23 => 'NET_SFTP_STATUS_INVALID_PARAMETER', + 24 => 'NET_SFTP_STATUS_FILE_IS_A_DIRECTORY', + 25 => 'NET_SFTP_STATUS_BYTE_RANGE_LOCK_CONFLICT', + 26 => 'NET_SFTP_STATUS_BYTE_RANGE_LOCK_REFUSED', + 27 => 'NET_SFTP_STATUS_DELETE_PENDING', + 28 => 'NET_SFTP_STATUS_FILE_CORRUPT', + 29 => 'NET_SFTP_STATUS_OWNER_INVALID', + 30 => 'NET_SFTP_STATUS_GROUP_INVALID', + 31 => 'NET_SFTP_STATUS_NO_MATCHING_BYTE_RANGE_LOCK' + ); + // http://tools.ietf.org/html/draft-ietf-secsh-filexfer-13#section-7.1 + // the order, in this case, matters quite a lot - see Net_SFTP::_parseAttributes() to understand why + $this->attributes = array( + 0x00000001 => 'NET_SFTP_ATTR_SIZE', + 0x00000002 => 'NET_SFTP_ATTR_UIDGID', // defined in SFTPv3, removed in SFTPv4+ + 0x00000004 => 'NET_SFTP_ATTR_PERMISSIONS', + 0x00000008 => 'NET_SFTP_ATTR_ACCESSTIME', + // 0x80000000 will yield a floating point on 32-bit systems and converting floating points to integers + // yields inconsistent behavior depending on how php is compiled. so we left shift -1 (which, in + // two's compliment, consists of all 1 bits) by 31. on 64-bit systems this'll yield 0xFFFFFFFF80000000. + // that's not a problem, however, and 'anded' and a 32-bit number, as all the leading 1 bits are ignored. + -1 << 31 => 'NET_SFTP_ATTR_EXTENDED' + ); + // http://tools.ietf.org/html/draft-ietf-secsh-filexfer-04#section-6.3 + // the flag definitions change somewhat in SFTPv5+. if SFTPv5+ support is added to this library, maybe name + // the array for that $this->open5_flags and similarily alter the constant names. + $this->open_flags = array( + 0x00000001 => 'NET_SFTP_OPEN_READ', + 0x00000002 => 'NET_SFTP_OPEN_WRITE', + 0x00000004 => 'NET_SFTP_OPEN_APPEND', + 0x00000008 => 'NET_SFTP_OPEN_CREATE', + 0x00000010 => 'NET_SFTP_OPEN_TRUNCATE', + 0x00000020 => 'NET_SFTP_OPEN_EXCL' + ); + // http://tools.ietf.org/html/draft-ietf-secsh-filexfer-04#section-5.2 + // see Net_SFTP::_parseLongname() for an explanation + $this->file_types = array( + 1 => 'NET_SFTP_TYPE_REGULAR', + 2 => 'NET_SFTP_TYPE_DIRECTORY', + 3 => 'NET_SFTP_TYPE_SYMLINK', + 4 => 'NET_SFTP_TYPE_SPECIAL', + 5 => 'NET_SFTP_TYPE_UNKNOWN', + // the followin types were first defined for use in SFTPv5+ + // http://tools.ietf.org/html/draft-ietf-secsh-filexfer-05#section-5.2 + 6 => 'NET_SFTP_TYPE_SOCKET', + 7 => 'NET_SFTP_TYPE_CHAR_DEVICE', + 8 => 'NET_SFTP_TYPE_BLOCK_DEVICE', + 9 => 'NET_SFTP_TYPE_FIFO' + ); + $this->_define_array( + $this->packet_types, + $this->status_codes, + $this->attributes, + $this->open_flags, + $this->file_types + ); + + if (!defined('NET_SFTP_QUEUE_SIZE')) { + define('NET_SFTP_QUEUE_SIZE', 50); + } + } + + /** + * Login + * + * @param String $username + * @param optional String $password + * @return Boolean + * @access public + */ + function login($username) + { + $args = func_get_args(); + if (!call_user_func_array(array(&$this, '_login'), $args)) { + return false; + } + + $this->window_size_server_to_client[NET_SFTP_CHANNEL] = $this->window_size; + + $packet = pack('CNa*N3', + NET_SSH2_MSG_CHANNEL_OPEN, strlen('session'), 'session', NET_SFTP_CHANNEL, $this->window_size, 0x4000); + + if (!$this->_send_binary_packet($packet)) { + return false; + } + + $this->channel_status[NET_SFTP_CHANNEL] = NET_SSH2_MSG_CHANNEL_OPEN; + + $response = $this->_get_channel_packet(NET_SFTP_CHANNEL); + if ($response === false) { + return false; + } + + $packet = pack('CNNa*CNa*', + NET_SSH2_MSG_CHANNEL_REQUEST, $this->server_channels[NET_SFTP_CHANNEL], strlen('subsystem'), 'subsystem', 1, strlen('sftp'), 'sftp'); + if (!$this->_send_binary_packet($packet)) { + return false; + } + + $this->channel_status[NET_SFTP_CHANNEL] = NET_SSH2_MSG_CHANNEL_REQUEST; + + $response = $this->_get_channel_packet(NET_SFTP_CHANNEL); + if ($response === false) { + // from PuTTY's psftp.exe + $command = "test -x /usr/lib/sftp-server && exec /usr/lib/sftp-server\n" . + "test -x /usr/local/lib/sftp-server && exec /usr/local/lib/sftp-server\n" . + "exec sftp-server"; + // we don't do $this->exec($command, false) because exec() operates on a different channel and plus the SSH_MSG_CHANNEL_OPEN that exec() does + // is redundant + $packet = pack('CNNa*CNa*', + NET_SSH2_MSG_CHANNEL_REQUEST, $this->server_channels[NET_SFTP_CHANNEL], strlen('exec'), 'exec', 1, strlen($command), $command); + if (!$this->_send_binary_packet($packet)) { + return false; + } + + $this->channel_status[NET_SFTP_CHANNEL] = NET_SSH2_MSG_CHANNEL_REQUEST; + + $response = $this->_get_channel_packet(NET_SFTP_CHANNEL); + if ($response === false) { + return false; + } + } + + $this->channel_status[NET_SFTP_CHANNEL] = NET_SSH2_MSG_CHANNEL_DATA; + + if (!$this->_send_sftp_packet(NET_SFTP_INIT, "\0\0\0\3")) { + return false; + } + + $response = $this->_get_sftp_packet(); + if ($this->packet_type != NET_SFTP_VERSION) { + user_error('Expected SSH_FXP_VERSION'); + return false; + } + + extract(unpack('Nversion', $this->_string_shift($response, 4))); + $this->version = $version; + while (!empty($response)) { + extract(unpack('Nlength', $this->_string_shift($response, 4))); + $key = $this->_string_shift($response, $length); + extract(unpack('Nlength', $this->_string_shift($response, 4))); + $value = $this->_string_shift($response, $length); + $this->extensions[$key] = $value; + } + + /* + SFTPv4+ defines a 'newline' extension. SFTPv3 seems to have unofficial support for it via 'newline@vandyke.com', + however, I'm not sure what 'newline@vandyke.com' is supposed to do (the fact that it's unofficial means that it's + not in the official SFTPv3 specs) and 'newline@vandyke.com' / 'newline' are likely not drop-in substitutes for + one another due to the fact that 'newline' comes with a SSH_FXF_TEXT bitmask whereas it seems unlikely that + 'newline@vandyke.com' would. + */ + /* + if (isset($this->extensions['newline@vandyke.com'])) { + $this->extensions['newline'] = $this->extensions['newline@vandyke.com']; + unset($this->extensions['newline@vandyke.com']); + } + */ + + $this->request_id = 1; + + /* + A Note on SFTPv4/5/6 support: + states the following: + + "If the client wishes to interoperate with servers that support noncontiguous version + numbers it SHOULD send '3'" + + Given that the server only sends its version number after the client has already done so, the above + seems to be suggesting that v3 should be the default version. This makes sense given that v3 is the + most popular. + + states the following; + + "If the server did not send the "versions" extension, or the version-from-list was not included, the + server MAY send a status response describing the failure, but MUST then close the channel without + processing any further requests." + + So what do you do if you have a client whose initial SSH_FXP_INIT packet says it implements v3 and + a server whose initial SSH_FXP_VERSION reply says it implements v4 and only v4? If it only implements + v4, the "versions" extension is likely not going to have been sent so version re-negotiation as discussed + in draft-ietf-secsh-filexfer-13 would be quite impossible. As such, what Net_SFTP would do is close the + channel and reopen it with a new and updated SSH_FXP_INIT packet. + */ + switch ($this->version) { + case 2: + case 3: + break; + default: + return false; + } + + $this->pwd = $this->_realpath('.'); + + $this->_save_dir($this->pwd); + + return true; + } + + /** + * Returns the current directory name + * + * @return Mixed + * @access public + */ + function pwd() + { + return $this->pwd; + } + + /** + * Logs errors + * + * @param String $response + * @param optional Integer $status + * @access public + */ + function _logError($response, $status = -1) + { + if ($status == -1) { + extract(unpack('Nstatus', $this->_string_shift($response, 4))); + } + + $error = $this->status_codes[$status]; + + if ($this->version > 2) { + extract(unpack('Nlength', $this->_string_shift($response, 4))); + $this->sftp_errors[] = $error . ': ' . $this->_string_shift($response, $length); + } else { + $this->sftp_errors[] = $error; + } + } + + /** + * Canonicalize the Server-Side Path Name + * + * SFTP doesn't provide a mechanism by which the current working directory can be changed, so we'll emulate it. Returns + * the absolute (canonicalized) path. + * + * @see Net_SFTP::chdir() + * @param String $path + * @return Mixed + * @access private + */ + function _realpath($path) + { + if ($this->pwd === false) { + // http://tools.ietf.org/html/draft-ietf-secsh-filexfer-13#section-8.9 + if (!$this->_send_sftp_packet(NET_SFTP_REALPATH, pack('Na*', strlen($path), $path))) { + return false; + } + + $response = $this->_get_sftp_packet(); + switch ($this->packet_type) { + case NET_SFTP_NAME: + // although SSH_FXP_NAME is implemented differently in SFTPv3 than it is in SFTPv4+, the following + // should work on all SFTP versions since the only part of the SSH_FXP_NAME packet the following looks + // at is the first part and that part is defined the same in SFTP versions 3 through 6. + $this->_string_shift($response, 4); // skip over the count - it should be 1, anyway + extract(unpack('Nlength', $this->_string_shift($response, 4))); + return $this->_string_shift($response, $length); + case NET_SFTP_STATUS: + $this->_logError($response); + return false; + default: + user_error('Expected SSH_FXP_NAME or SSH_FXP_STATUS'); + return false; + } + } + + if ($path[0] != '/') { + $path = $this->pwd . '/' . $path; + } + + $path = explode('/', $path); + $new = array(); + foreach ($path as $dir) { + if (!strlen($dir)) { + continue; + } + switch ($dir) { + case '..': + array_pop($new); + case '.': + break; + default: + $new[] = $dir; + } + } + + return '/' . implode('/', $new); + } + + /** + * Changes the current directory + * + * @param String $dir + * @return Boolean + * @access public + */ + function chdir($dir) + { + if (!($this->bitmap & NET_SSH2_MASK_LOGIN)) { + return false; + } + + // assume current dir if $dir is empty + if ($dir === '') { + $dir = './'; + // suffix a slash if needed + } elseif ($dir[strlen($dir) - 1] != '/') { + $dir.= '/'; + } + + $dir = $this->_realpath($dir); + + // confirm that $dir is, in fact, a valid directory + if ($this->_is_dir($dir)) { + $this->pwd = $dir; + return true; + } + + // we could do a stat on the alleged $dir to see if it's a directory but that doesn't tell us + // the currently logged in user has the appropriate permissions or not. maybe you could see if + // the file's uid / gid match the currently logged in user's uid / gid but how there's no easy + // way to get those with SFTP + + if (!$this->_send_sftp_packet(NET_SFTP_OPENDIR, pack('Na*', strlen($dir), $dir))) { + return false; + } + + // see Net_SFTP::nlist() for a more thorough explanation of the following + $response = $this->_get_sftp_packet(); + switch ($this->packet_type) { + case NET_SFTP_HANDLE: + $handle = substr($response, 4); + break; + case NET_SFTP_STATUS: + $this->_logError($response); + return false; + default: + user_error('Expected SSH_FXP_HANDLE or SSH_FXP_STATUS'); + return false; + } + + if (!$this->_close_handle($handle)) { + return false; + } + + $this->_save_dir($dir); + + $this->pwd = $dir; + return true; + } + + /** + * Returns a list of files in the given directory + * + * @param optional String $dir + * @return Mixed + * @access public + */ + function nlist($dir = '.') + { + return $this->_list($dir, false); + } + + /** + * Returns a detailed list of files in the given directory + * + * @param optional String $dir + * @return Mixed + * @access public + */ + function rawlist($dir = '.') + { + return $this->_list($dir, true); + } + + /** + * Reads a list, be it detailed or not, of files in the given directory + * + * $realpath exists because, in the case of the recursive deletes and recursive chmod's $realpath has already + * been calculated. + * + * @param String $dir + * @param optional Boolean $raw + * @param optional Boolean $realpath + * @return Mixed + * @access private + */ + function _list($dir, $raw = true, $realpath = true) + { + if (!($this->bitmap & NET_SSH2_MASK_LOGIN)) { + return false; + } + + $dir = $this->_realpath($dir . '/'); + if ($dir === false) { + return false; + } + + // http://tools.ietf.org/html/draft-ietf-secsh-filexfer-13#section-8.1.2 + if (!$this->_send_sftp_packet(NET_SFTP_OPENDIR, pack('Na*', strlen($dir), $dir))) { + return false; + } + + $response = $this->_get_sftp_packet(); + switch ($this->packet_type) { + case NET_SFTP_HANDLE: + // http://tools.ietf.org/html/draft-ietf-secsh-filexfer-13#section-9.2 + // since 'handle' is the last field in the SSH_FXP_HANDLE packet, we'll just remove the first four bytes that + // represent the length of the string and leave it at that + $handle = substr($response, 4); + break; + case NET_SFTP_STATUS: + // presumably SSH_FX_NO_SUCH_FILE or SSH_FX_PERMISSION_DENIED + $this->_logError($response); + return false; + default: + user_error('Expected SSH_FXP_HANDLE or SSH_FXP_STATUS'); + return false; + } + + $this->_save_dir($dir); + + $contents = array(); + while (true) { + // http://tools.ietf.org/html/draft-ietf-secsh-filexfer-13#section-8.2.2 + // why multiple SSH_FXP_READDIR packets would be sent when the response to a single one can span arbitrarily many + // SSH_MSG_CHANNEL_DATA messages is not known to me. + if (!$this->_send_sftp_packet(NET_SFTP_READDIR, pack('Na*', strlen($handle), $handle))) { + return false; + } + + $response = $this->_get_sftp_packet(); + switch ($this->packet_type) { + case NET_SFTP_NAME: + extract(unpack('Ncount', $this->_string_shift($response, 4))); + for ($i = 0; $i < $count; $i++) { + extract(unpack('Nlength', $this->_string_shift($response, 4))); + $shortname = $this->_string_shift($response, $length); + extract(unpack('Nlength', $this->_string_shift($response, 4))); + $longname = $this->_string_shift($response, $length); + $attributes = $this->_parseAttributes($response); + if (!isset($attributes['type'])) { + $fileType = $this->_parseLongname($longname); + if ($fileType) { + $attributes['type'] = $fileType; + } + } + if (!$raw) { + $contents[] = $shortname; + } else { + $contents[$shortname] = $attributes; + } + + if (isset($attributes['type']) && $attributes['type'] == NET_SFTP_TYPE_DIRECTORY && ($shortname != '.' && $shortname != '..')) { + $this->_save_dir($dir . '/' . $shortname); + } + // SFTPv6 has an optional boolean end-of-list field, but we'll ignore that, since the + // final SSH_FXP_STATUS packet should tell us that, already. + } + break; + case NET_SFTP_STATUS: + extract(unpack('Nstatus', $this->_string_shift($response, 4))); + if ($status != NET_SFTP_STATUS_EOF) { + $this->_logError($response, $status); + return false; + } + break 2; + default: + user_error('Expected SSH_FXP_NAME or SSH_FXP_STATUS'); + return false; + } + } + + if (!$this->_close_handle($handle)) { + return false; + } + + return $contents; + } + + /** + * Returns the file size, in bytes, or false, on failure + * + * Files larger than 4GB will show up as being exactly 4GB. + * + * @param String $filename + * @return Mixed + * @access public + */ + function size($filename) + { + if (!($this->bitmap & NET_SSH2_MASK_LOGIN)) { + return false; + } + + $filename = $this->_realpath($filename); + if ($filename === false) { + return false; + } + + return $this->_size($filename); + } + + /** + * Save directories to cache + * + * @param String $dir + * @access private + */ + function _save_dir($dir) + { + // preg_replace('#^/|/(?=/)|/$#', '', $dir) == str_replace('//', '/', trim($dir, '/')) + $dirs = explode('/', preg_replace('#^/|/(?=/)|/$#', '', $dir)); + + $temp = &$this->dirs; + foreach ($dirs as $dir) { + if (!isset($temp[$dir])) { + $temp[$dir] = array(); + } + $temp = &$temp[$dir]; + } + } + + /** + * Remove directories from cache + * + * @param String $dir + * @access private + */ + function _remove_dir($dir) + { + $dirs = explode('/', preg_replace('#^/|/(?=/)|/$#', '', $dir)); + + $temp = &$this->dirs; + foreach ($dirs as $dir) { + if ($dir == end($dirs)) { + unset($temp[$dir]); + return true; + } + if (!isset($temp[$dir])) { + return false; + } + $temp = &$temp[$dir]; + } + } + + /** + * Checks cache for directory + * + * Mainly used by chdir, which is, in turn, also used for determining whether or not an individual + * file is a directory or not by stat() and lstat() + * + * @param String $dir + * @access private + */ + function _is_dir($dir) + { + $dirs = explode('/', preg_replace('#^/|/(?=/)|/$#', '', $dir)); + + $temp = &$this->dirs; + foreach ($dirs as $dir) { + if (!isset($temp[$dir])) { + return false; + } + $temp = &$temp[$dir]; + } + return true; + } + + /** + * Returns general information about a file. + * + * Returns an array on success and false otherwise. + * + * @param String $filename + * @return Mixed + * @access public + */ + function stat($filename) + { + if (!($this->bitmap & NET_SSH2_MASK_LOGIN)) { + return false; + } + + $filename = $this->_realpath($filename); + if ($filename === false) { + return false; + } + + $stat = $this->_stat($filename, NET_SFTP_STAT); + if ($stat === false) { + return false; + } + if (isset($stat['type'])) { + return $stat; + } + + $pwd = $this->pwd; + $stat['type'] = $this->chdir($filename) ? + NET_SFTP_TYPE_DIRECTORY : + NET_SFTP_TYPE_REGULAR; + $this->pwd = $pwd; + + return $stat; + } + + /** + * Returns general information about a file or symbolic link. + * + * Returns an array on success and false otherwise. + * + * @param String $filename + * @return Mixed + * @access public + */ + function lstat($filename) + { + if (!($this->bitmap & NET_SSH2_MASK_LOGIN)) { + return false; + } + + $filename = $this->_realpath($filename); + if ($filename === false) { + return false; + } + + $lstat = $this->_stat($filename, NET_SFTP_LSTAT); + if ($lstat === false) { + return false; + } + if (isset($lstat['type'])) { + return $lstat; + } + + $stat = $this->_stat($filename, NET_SFTP_STAT); + + if ($lstat != $stat) { + return array_merge($lstat, array('type' => NET_SFTP_TYPE_SYMLINK)); + } + + $pwd = $this->pwd; + $lstat['type'] = $this->chdir($filename) ? + NET_SFTP_TYPE_DIRECTORY : + NET_SFTP_TYPE_REGULAR; + $this->pwd = $pwd; + + return $lstat; + } + + /** + * Returns general information about a file or symbolic link + * + * Determines information without calling Net_SFTP::_realpath(). + * The second parameter can be either NET_SFTP_STAT or NET_SFTP_LSTAT. + * + * @param String $filename + * @param Integer $type + * @return Mixed + * @access private + */ + function _stat($filename, $type) + { + // SFTPv4+ adds an additional 32-bit integer field - flags - to the following: + $packet = pack('Na*', strlen($filename), $filename); + if (!$this->_send_sftp_packet($type, $packet)) { + return false; + } + + $response = $this->_get_sftp_packet(); + switch ($this->packet_type) { + case NET_SFTP_ATTRS: + return $this->_parseAttributes($response); + case NET_SFTP_STATUS: + $this->_logError($response); + return false; + } + + user_error('Expected SSH_FXP_ATTRS or SSH_FXP_STATUS'); + return false; + } + + /** + * Returns the file size, in bytes, or false, on failure + * + * Determines the size without calling Net_SFTP::_realpath() + * + * @param String $filename + * @return Mixed + * @access private + */ + function _size($filename) + { + $result = $this->_stat($filename, NET_SFTP_STAT); + if ($result === false) { + return false; + } + return isset($result['size']) ? $result['size'] : -1; + } + + /** + * Truncates a file to a given length + * + * @param String $filename + * @param Integer $new_size + * @return Boolean + * @access public + */ + function truncate($filename, $new_size) + { + $attr = pack('N3', NET_SFTP_ATTR_SIZE, $new_size / 4294967296, $new_size); // 4294967296 == 0x100000000 == 1<<32 + + return $this->_setstat($filename, $attr, false); + } + + /** + * Sets access and modification time of file. + * + * If the file does not exist, it will be created. + * + * @param String $filename + * @param optional Integer $time + * @param optional Integer $atime + * @return Boolean + * @access public + */ + function touch($filename, $time = null, $atime = null) + { + if (!($this->bitmap & NET_SSH2_MASK_LOGIN)) { + return false; + } + + $filename = $this->_realpath($filename); + if ($filename === false) { + return false; + } + + if (!isset($time)) { + $time = time(); + } + if (!isset($atime)) { + $atime = $time; + } + + $flags = NET_SFTP_OPEN_WRITE | NET_SFTP_OPEN_CREATE | NET_SFTP_OPEN_EXCL; + $attr = pack('N3', NET_SFTP_ATTR_ACCESSTIME, $time, $atime); + $packet = pack('Na*Na*', strlen($filename), $filename, $flags, $attr); + if (!$this->_send_sftp_packet(NET_SFTP_OPEN, $packet)) { + return false; + } + + $response = $this->_get_sftp_packet(); + switch ($this->packet_type) { + case NET_SFTP_HANDLE: + return $this->_close_handle(substr($response, 4)); + case NET_SFTP_STATUS: + $this->_logError($response); + break; + default: + user_error('Expected SSH_FXP_HANDLE or SSH_FXP_STATUS'); + return false; + } + + return $this->_setstat($filename, $attr, false); + } + + /** + * Changes file or directory owner + * + * Returns true on success or false on error. + * + * @param String $filename + * @param Integer $uid + * @param optional Boolean $recursive + * @return Boolean + * @access public + */ + function chown($filename, $uid, $recursive = false) + { + // quoting from , + // "if the owner or group is specified as -1, then that ID is not changed" + $attr = pack('N3', NET_SFTP_ATTR_UIDGID, $uid, -1); + + return $this->_setstat($filename, $attr, $recursive); + } + + /** + * Changes file or directory group + * + * Returns true on success or false on error. + * + * @param String $filename + * @param Integer $gid + * @param optional Boolean $recursive + * @return Boolean + * @access public + */ + function chgrp($filename, $gid, $recursive = false) + { + $attr = pack('N3', NET_SFTP_ATTR_UIDGID, -1, $gid); + + return $this->_setstat($filename, $attr, $recursive); + } + + /** + * Set permissions on a file. + * + * Returns the new file permissions on success or false on error. + * If $recursive is true than this just returns true or false. + * + * @param Integer $mode + * @param String $filename + * @param optional Boolean $recursive + * @return Mixed + * @access public + */ + function chmod($mode, $filename, $recursive = false) + { + if (is_string($mode) && is_int($filename)) { + $temp = $mode; + $mode = $filename; + $filename = $temp; + } + + $attr = pack('N2', NET_SFTP_ATTR_PERMISSIONS, $mode & 07777); + if (!$this->_setstat($filename, $attr, $recursive)) { + return false; + } + if ($recursive) { + return true; + } + + // rather than return what the permissions *should* be, we'll return what they actually are. this will also + // tell us if the file actually exists. + // incidentally, SFTPv4+ adds an additional 32-bit integer field - flags - to the following: + $packet = pack('Na*', strlen($filename), $filename); + if (!$this->_send_sftp_packet(NET_SFTP_STAT, $packet)) { + return false; + } + + $response = $this->_get_sftp_packet(); + switch ($this->packet_type) { + case NET_SFTP_ATTRS: + $attrs = $this->_parseAttributes($response); + return $attrs['permissions']; + case NET_SFTP_STATUS: + $this->_logError($response); + return false; + } + + user_error('Expected SSH_FXP_ATTRS or SSH_FXP_STATUS'); + return false; + } + + /** + * Sets information about a file + * + * @param String $filename + * @param String $attr + * @param Boolean $recursive + * @return Boolean + * @access private + */ + function _setstat($filename, $attr, $recursive) + { + if (!($this->bitmap & NET_SSH2_MASK_LOGIN)) { + return false; + } + + $filename = $this->_realpath($filename); + if ($filename === false) { + return false; + } + + if ($recursive) { + $i = 0; + $result = $this->_setstat_recursive($filename, $attr, $i); + $this->_read_put_responses($i); + return $result; + } + + // SFTPv4+ has an additional byte field - type - that would need to be sent, as well. setting it to + // SSH_FILEXFER_TYPE_UNKNOWN might work. if not, we'd have to do an SSH_FXP_STAT before doing an SSH_FXP_SETSTAT. + if (!$this->_send_sftp_packet(NET_SFTP_SETSTAT, pack('Na*a*', strlen($filename), $filename, $attr))) { + return false; + } + + /* + "Because some systems must use separate system calls to set various attributes, it is possible that a failure + response will be returned, but yet some of the attributes may be have been successfully modified. If possible, + servers SHOULD avoid this situation; however, clients MUST be aware that this is possible." + + -- http://tools.ietf.org/html/draft-ietf-secsh-filexfer-13#section-8.6 + */ + $response = $this->_get_sftp_packet(); + if ($this->packet_type != NET_SFTP_STATUS) { + user_error('Expected SSH_FXP_STATUS'); + return false; + } + + extract(unpack('Nstatus', $this->_string_shift($response, 4))); + if ($status != NET_SFTP_STATUS_OK) { + $this->_logError($response, $status); + return false; + } + + return true; + } + + /** + * Recursively sets information on directories on the SFTP server + * + * Minimizes directory lookups and SSH_FXP_STATUS requests for speed. + * + * @param String $path + * @param String $attr + * @param Integer $i + * @return Boolean + * @access private + */ + function _setstat_recursive($path, $attr, &$i) + { + if (!$this->_read_put_responses($i)) { + return false; + } + $i = 0; + $entries = $this->_list($path, true, false); + + if ($entries === false) { + return $this->_setstat($path, $attr, false); + } + + // normally $entries would have at least . and .. but it might not if the directories + // permissions didn't allow reading + if (empty($entries)) { + return false; + } + + foreach ($entries as $filename=>$props) { + if ($filename == '.' || $filename == '..') { + continue; + } + + if (!isset($props['type'])) { + return false; + } + + $temp = $path . '/' . $filename; + if ($props['type'] == NET_SFTP_TYPE_DIRECTORY) { + if (!$this->_setstat_recursive($temp, $attr, $i)) { + return false; + } + } else { + if (!$this->_send_sftp_packet(NET_SFTP_SETSTAT, pack('Na*a*', strlen($temp), $temp, $attr))) { + return false; + } + + $i++; + + if ($i >= NET_SFTP_QUEUE_SIZE) { + if (!$this->_read_put_responses($i)) { + return false; + } + $i = 0; + } + } + } + + if (!$this->_send_sftp_packet(NET_SFTP_SETSTAT, pack('Na*a*', strlen($path), $path, $attr))) { + return false; + } + + $i++; + + if ($i >= NET_SFTP_QUEUE_SIZE) { + if (!$this->_read_put_responses($i)) { + return false; + } + $i = 0; + } + + return true; + } + + /** + * Creates a directory. + * + * @param String $dir + * @return Boolean + * @access public + */ + function mkdir($dir, $mode = -1, $recursive = false) + { + if (!($this->bitmap & NET_SSH2_MASK_LOGIN)) { + return false; + } + + $dir = $this->_realpath($dir); + // by not providing any permissions, hopefully the server will use the logged in users umask - their + // default permissions. + $attr = $mode == -1 ? "\0\0\0\0" : pack('N2', NET_SFTP_ATTR_PERMISSIONS, $mode & 07777); + + if ($recursive) { + $dirs = explode('/', preg_replace('#/(?=/)|/$#', '', $dir)); + if (empty($dirs[0])) { + array_shift($dirs); + $dirs[0] = '/' . $dirs[0]; + } + for ($i = 0; $i < count($dirs); $i++) { + $temp = array_slice($dirs, 0, $i + 1); + $temp = implode('/', $temp); + $result = $this->_mkdir_helper($temp, $attr); + } + return $result; + } + + return $this->_mkdir_helper($dir, $attr); + } + + /** + * Helper function for directory creation + * + * @param String $dir + * @return Boolean + * @access private + */ + function _mkdir_helper($dir, $attr) + { + if (!$this->_send_sftp_packet(NET_SFTP_MKDIR, pack('Na*a*', strlen($dir), $dir, $attr))) { + return false; + } + + $response = $this->_get_sftp_packet(); + if ($this->packet_type != NET_SFTP_STATUS) { + user_error('Expected SSH_FXP_STATUS'); + return false; + } + + extract(unpack('Nstatus', $this->_string_shift($response, 4))); + if ($status != NET_SFTP_STATUS_OK) { + $this->_logError($response, $status); + return false; + } + + $this->_save_dir($dir); + + return true; + } + + /** + * Removes a directory. + * + * @param String $dir + * @return Boolean + * @access public + */ + function rmdir($dir) + { + if (!($this->bitmap & NET_SSH2_MASK_LOGIN)) { + return false; + } + + $dir = $this->_realpath($dir); + if ($dir === false) { + return false; + } + + if (!$this->_send_sftp_packet(NET_SFTP_RMDIR, pack('Na*', strlen($dir), $dir))) { + return false; + } + + $response = $this->_get_sftp_packet(); + if ($this->packet_type != NET_SFTP_STATUS) { + user_error('Expected SSH_FXP_STATUS'); + return false; + } + + extract(unpack('Nstatus', $this->_string_shift($response, 4))); + if ($status != NET_SFTP_STATUS_OK) { + // presumably SSH_FX_NO_SUCH_FILE or SSH_FX_PERMISSION_DENIED? + $this->_logError($response, $status); + return false; + } + + $this->_remove_dir($dir); + + return true; + } + + /** + * Uploads a file to the SFTP server. + * + * By default, Net_SFTP::put() does not read from the local filesystem. $data is dumped directly into $remote_file. + * So, for example, if you set $data to 'filename.ext' and then do Net_SFTP::get(), you will get a file, twelve bytes + * long, containing 'filename.ext' as its contents. + * + * Setting $mode to NET_SFTP_LOCAL_FILE will change the above behavior. With NET_SFTP_LOCAL_FILE, $remote_file will + * contain as many bytes as filename.ext does on your local filesystem. If your filename.ext is 1MB then that is how + * large $remote_file will be, as well. + * + * Currently, only binary mode is supported. As such, if the line endings need to be adjusted, you will need to take + * care of that, yourself. + * + * $mode can take an additional two parameters - NET_SFTP_RESUME and NET_SFTP_RESUME_START. These are bitwise AND'd with + * $mode. So if you want to resume upload of a 300mb file on the local file system you'd set $mode to the following: + * + * NET_SFTP_LOCAL_FILE | NET_SFTP_RESUME + * + * If you wanted to simply append the full contents of a local file to the full contents of a remote file you'd replace + * NET_SFTP_RESUME with NET_SFTP_RESUME_START. + * + * If $mode & (NET_SFTP_RESUME | NET_SFTP_RESUME_START) then NET_SFTP_RESUME_START will be assumed. + * + * $start and $local_start give you more fine grained control over this process and take precident over NET_SFTP_RESUME + * when they're non-negative. ie. $start could let you write at the end of a file (like NET_SFTP_RESUME) or in the middle + * of one. $local_start could let you start your reading from the end of a file (like NET_SFTP_RESUME_START) or in the + * middle of one. + * + * Setting $local_start to > 0 or $mode | NET_SFTP_RESUME_START doesn't do anything unless $mode | NET_SFTP_LOCAL_FILE. + * + * @param String $remote_file + * @param String $data + * @param optional Integer $mode + * @param optional Integer $start + * @param optional Integer $local_start + * @return Boolean + * @access public + * @internal ASCII mode for SFTPv4/5/6 can be supported by adding a new function - Net_SFTP::setMode(). + */ + function put($remote_file, $data, $mode = NET_SFTP_STRING, $start = -1, $local_start = -1) + { + if (!($this->bitmap & NET_SSH2_MASK_LOGIN)) { + return false; + } + + $remote_file = $this->_realpath($remote_file); + if ($remote_file === false) { + return false; + } + + $flags = NET_SFTP_OPEN_WRITE | NET_SFTP_OPEN_CREATE; + // according to the SFTP specs, NET_SFTP_OPEN_APPEND should "force all writes to append data at the end of the file." + // in practice, it doesn't seem to do that. + //$flags|= ($mode & NET_SFTP_RESUME) ? NET_SFTP_OPEN_APPEND : NET_SFTP_OPEN_TRUNCATE; + + if ($start >= 0) { + $offset = $start; + } elseif ($mode & NET_SFTP_RESUME) { + // if NET_SFTP_OPEN_APPEND worked as it should _size() wouldn't need to be called + $size = $this->_size($remote_file); + $offset = $size !== false ? $size : 0; + } else { + $offset = 0; + $flags|= NET_SFTP_OPEN_TRUNCATE; + } + + $packet = pack('Na*N2', strlen($remote_file), $remote_file, $flags, 0); + if (!$this->_send_sftp_packet(NET_SFTP_OPEN, $packet)) { + return false; + } + + $response = $this->_get_sftp_packet(); + switch ($this->packet_type) { + case NET_SFTP_HANDLE: + $handle = substr($response, 4); + break; + case NET_SFTP_STATUS: + $this->_logError($response); + return false; + default: + user_error('Expected SSH_FXP_HANDLE or SSH_FXP_STATUS'); + return false; + } + + // http://tools.ietf.org/html/draft-ietf-secsh-filexfer-13#section-8.2.3 + if ($mode & NET_SFTP_LOCAL_FILE) { + if (!is_file($data)) { + user_error("$data is not a valid file"); + return false; + } + $fp = @fopen($data, 'rb'); + if (!$fp) { + return false; + } + $size = filesize($data); + + if ($local_start >= 0) { + fseek($fp, $local_start); + } elseif ($mode & NET_SFTP_RESUME_START) { + // do nothing + } else { + fseek($fp, $offset); + } + } else { + $size = strlen($data); + } + + $sent = 0; + $size = $size < 0 ? ($size & 0x7FFFFFFF) + 0x80000000 : $size; + + $sftp_packet_size = 4096; // PuTTY uses 4096 + // make the SFTP packet be exactly 4096 bytes by including the bytes in the NET_SFTP_WRITE packets "header" + $sftp_packet_size-= strlen($handle) + 25; + $i = 0; + while ($sent < $size) { + $temp = $mode & NET_SFTP_LOCAL_FILE ? fread($fp, $sftp_packet_size) : substr($data, $sent, $sftp_packet_size); + $subtemp = $offset + $sent; + $packet = pack('Na*N3a*', strlen($handle), $handle, $subtemp / 4294967296, $subtemp, strlen($temp), $temp); + if (!$this->_send_sftp_packet(NET_SFTP_WRITE, $packet)) { + fclose($fp); + return false; + } + $sent+= strlen($temp); + + $i++; + + if ($i == NET_SFTP_QUEUE_SIZE) { + if (!$this->_read_put_responses($i)) { + $i = 0; + break; + } + $i = 0; + } + } + + if (!$this->_read_put_responses($i)) { + if ($mode & NET_SFTP_LOCAL_FILE) { + fclose($fp); + } + $this->_close_handle($handle); + return false; + } + + if ($mode & NET_SFTP_LOCAL_FILE) { + fclose($fp); + } + + return $this->_close_handle($handle); + } + + /** + * Reads multiple successive SSH_FXP_WRITE responses + * + * Sending an SSH_FXP_WRITE packet and immediately reading its response isn't as efficient as blindly sending out $i + * SSH_FXP_WRITEs, in succession, and then reading $i responses. + * + * @param Integer $i + * @return Boolean + * @access private + */ + function _read_put_responses($i) + { + while ($i--) { + $response = $this->_get_sftp_packet(); + if ($this->packet_type != NET_SFTP_STATUS) { + user_error('Expected SSH_FXP_STATUS'); + return false; + } + + extract(unpack('Nstatus', $this->_string_shift($response, 4))); + if ($status != NET_SFTP_STATUS_OK) { + $this->_logError($response, $status); + break; + } + } + + return $i < 0; + } + + /** + * Close handle + * + * @param String $handle + * @return Boolean + * @access private + */ + function _close_handle($handle) + { + if (!$this->_send_sftp_packet(NET_SFTP_CLOSE, pack('Na*', strlen($handle), $handle))) { + return false; + } + + // "The client MUST release all resources associated with the handle regardless of the status." + // -- http://tools.ietf.org/html/draft-ietf-secsh-filexfer-13#section-8.1.3 + $response = $this->_get_sftp_packet(); + if ($this->packet_type != NET_SFTP_STATUS) { + user_error('Expected SSH_FXP_STATUS'); + return false; + } + + extract(unpack('Nstatus', $this->_string_shift($response, 4))); + if ($status != NET_SFTP_STATUS_OK) { + $this->_logError($response, $status); + return false; + } + + return true; + } + + /** + * Downloads a file from the SFTP server. + * + * Returns a string containing the contents of $remote_file if $local_file is left undefined or a boolean false if + * the operation was unsuccessful. If $local_file is defined, returns true or false depending on the success of the + * operation. + * + * $offset and $length can be used to download files in chunks. + * + * @param String $remote_file + * @param optional String $local_file + * @param optional Integer $offset + * @param optional Integer $length + * @return Mixed + * @access public + */ + function get($remote_file, $local_file = false, $offset = 0, $length = -1) + { + if (!($this->bitmap & NET_SSH2_MASK_LOGIN)) { + return false; + } + + $remote_file = $this->_realpath($remote_file); + if ($remote_file === false) { + return false; + } + + $packet = pack('Na*N2', strlen($remote_file), $remote_file, NET_SFTP_OPEN_READ, 0); + if (!$this->_send_sftp_packet(NET_SFTP_OPEN, $packet)) { + return false; + } + + $response = $this->_get_sftp_packet(); + switch ($this->packet_type) { + case NET_SFTP_HANDLE: + $handle = substr($response, 4); + break; + case NET_SFTP_STATUS: // presumably SSH_FX_NO_SUCH_FILE or SSH_FX_PERMISSION_DENIED + $this->_logError($response); + return false; + default: + user_error('Expected SSH_FXP_HANDLE or SSH_FXP_STATUS'); + return false; + } + + if ($local_file !== false) { + $fp = fopen($local_file, 'wb'); + if (!$fp) { + return false; + } + } else { + $content = ''; + } + + $start = $offset; + $size = $this->max_sftp_packet < $length || $length < 0 ? $this->max_sftp_packet : $length; + while (true) { + $packet = pack('Na*N3', strlen($handle), $handle, $offset / 4294967296, $offset, $size); + if (!$this->_send_sftp_packet(NET_SFTP_READ, $packet)) { + if ($local_file !== false) { + fclose($fp); + } + return false; + } + + $response = $this->_get_sftp_packet(); + switch ($this->packet_type) { + case NET_SFTP_DATA: + $temp = substr($response, 4); + $offset+= strlen($temp); + if ($local_file === false) { + $content.= $temp; + } else { + fputs($fp, $temp); + } + break; + case NET_SFTP_STATUS: + // could, in theory, return false if !strlen($content) but we'll hold off for the time being + $this->_logError($response); + break 2; + default: + user_error('Expected SSH_FXP_DATA or SSH_FXP_STATUS'); + if ($local_file !== false) { + fclose($fp); + } + return false; + } + + if ($length > 0 && $length <= $offset - $start) { + break; + } + } + + if ($length > 0 && $length <= $offset - $start) { + if ($local_file === false) { + $content = substr($content, 0, $length); + } else { + ftruncate($fp, $length); + } + } + + if ($local_file !== false) { + fclose($fp); + } + + if (!$this->_close_handle($handle)) { + return false; + } + + // if $content isn't set that means a file was written to + return isset($content) ? $content : true; + } + + /** + * Deletes a file on the SFTP server. + * + * @param String $path + * @param Boolean $recursive + * @return Boolean + * @access public + */ + function delete($path, $recursive = true) + { + if (!($this->bitmap & NET_SSH2_MASK_LOGIN)) { + return false; + } + + $path = $this->_realpath($path); + if ($path === false) { + return false; + } + + // http://tools.ietf.org/html/draft-ietf-secsh-filexfer-13#section-8.3 + if (!$this->_send_sftp_packet(NET_SFTP_REMOVE, pack('Na*', strlen($path), $path))) { + return false; + } + + $response = $this->_get_sftp_packet(); + if ($this->packet_type != NET_SFTP_STATUS) { + user_error('Expected SSH_FXP_STATUS'); + return false; + } + + // if $status isn't SSH_FX_OK it's probably SSH_FX_NO_SUCH_FILE or SSH_FX_PERMISSION_DENIED + extract(unpack('Nstatus', $this->_string_shift($response, 4))); + if ($status != NET_SFTP_STATUS_OK) { + $this->_logError($response, $status); + if (!$recursive) { + return false; + } + $i = 0; + $result = $this->_delete_recursive($path, $i); + $this->_read_put_responses($i); + return $result; + } + + return true; + } + + /** + * Recursively deletes directories on the SFTP server + * + * Minimizes directory lookups and SSH_FXP_STATUS requests for speed. + * + * @param String $path + * @param Integer $i + * @return Boolean + * @access private + */ + function _delete_recursive($path, &$i) + { + if (!$this->_read_put_responses($i)) { + return false; + } + $i = 0; + $entries = $this->_list($path, true, false); + + // normally $entries would have at least . and .. but it might not if the directories + // permissions didn't allow reading + if (empty($entries)) { + return false; + } + + foreach ($entries as $filename=>$props) { + if ($filename == '.' || $filename == '..') { + continue; + } + + if (!isset($props['type'])) { + return false; + } + + $temp = $path . '/' . $filename; + if ($props['type'] == NET_SFTP_TYPE_DIRECTORY) { + if (!$this->_delete_recursive($temp, $i)) { + return false; + } + } else { + if (!$this->_send_sftp_packet(NET_SFTP_REMOVE, pack('Na*', strlen($temp), $temp))) { + return false; + } + + $i++; + + if ($i >= NET_SFTP_QUEUE_SIZE) { + if (!$this->_read_put_responses($i)) { + return false; + } + $i = 0; + } + } + } + + if (!$this->_send_sftp_packet(NET_SFTP_RMDIR, pack('Na*', strlen($path), $path))) { + return false; + } + $this->_remove_dir($path); + + $i++; + + if ($i >= NET_SFTP_QUEUE_SIZE) { + if (!$this->_read_put_responses($i)) { + return false; + } + $i = 0; + } + + return true; + } + + /** + * Renames a file or a directory on the SFTP server + * + * @param String $oldname + * @param String $newname + * @return Boolean + * @access public + */ + function rename($oldname, $newname) + { + if (!($this->bitmap & NET_SSH2_MASK_LOGIN)) { + return false; + } + + $oldname = $this->_realpath($oldname); + $newname = $this->_realpath($newname); + if ($oldname === false || $newname === false) { + return false; + } + + // http://tools.ietf.org/html/draft-ietf-secsh-filexfer-13#section-8.3 + $packet = pack('Na*Na*', strlen($oldname), $oldname, strlen($newname), $newname); + if (!$this->_send_sftp_packet(NET_SFTP_RENAME, $packet)) { + return false; + } + + $response = $this->_get_sftp_packet(); + if ($this->packet_type != NET_SFTP_STATUS) { + user_error('Expected SSH_FXP_STATUS'); + return false; + } + + // if $status isn't SSH_FX_OK it's probably SSH_FX_NO_SUCH_FILE or SSH_FX_PERMISSION_DENIED + extract(unpack('Nstatus', $this->_string_shift($response, 4))); + if ($status != NET_SFTP_STATUS_OK) { + $this->_logError($response, $status); + return false; + } + + return true; + } + + /** + * Parse Attributes + * + * See '7. File Attributes' of draft-ietf-secsh-filexfer-13 for more info. + * + * @param String $response + * @return Array + * @access private + */ + function _parseAttributes(&$response) + { + $attr = array(); + extract(unpack('Nflags', $this->_string_shift($response, 4))); + // SFTPv4+ have a type field (a byte) that follows the above flag field + foreach ($this->attributes as $key => $value) { + switch ($flags & $key) { + case NET_SFTP_ATTR_SIZE: // 0x00000001 + // size is represented by a 64-bit integer, so we perhaps ought to be doing the following: + // $attr['size'] = new Math_BigInteger($this->_string_shift($response, 8), 256); + // of course, you shouldn't be using Net_SFTP to transfer files that are in excess of 4GB + // (0xFFFFFFFF bytes), anyway. as such, we'll just represent all file sizes that are bigger than + // 4GB as being 4GB. + extract(unpack('Nupper/Nsize', $this->_string_shift($response, 8))); + $attr['size'] = $upper ? 4294967296 * $upper : 0; + $attr['size']+= $size < 0 ? ($size & 0x7FFFFFFF) + 0x80000000 : $size; + break; + case NET_SFTP_ATTR_UIDGID: // 0x00000002 (SFTPv3 only) + $attr+= unpack('Nuid/Ngid', $this->_string_shift($response, 8)); + break; + case NET_SFTP_ATTR_PERMISSIONS: // 0x00000004 + $attr+= unpack('Npermissions', $this->_string_shift($response, 4)); + // mode == permissions; permissions was the original array key and is retained for bc purposes. + // mode was added because that's the more industry standard terminology + $attr+= array('mode' => $attr['permissions']); + $fileType = $this->_parseMode($attr['permissions']); + if ($fileType !== false) { + $attr+= array('type' => $fileType); + } + break; + case NET_SFTP_ATTR_ACCESSTIME: // 0x00000008 + $attr+= unpack('Natime/Nmtime', $this->_string_shift($response, 8)); + break; + case NET_SFTP_ATTR_EXTENDED: // 0x80000000 + extract(unpack('Ncount', $this->_string_shift($response, 4))); + for ($i = 0; $i < $count; $i++) { + extract(unpack('Nlength', $this->_string_shift($response, 4))); + $key = $this->_string_shift($response, $length); + extract(unpack('Nlength', $this->_string_shift($response, 4))); + $attr[$key] = $this->_string_shift($response, $length); + } + } + } + return $attr; + } + + /** + * Attempt to identify the file type + * + * Quoting the SFTP RFC, "Implementations MUST NOT send bits that are not defined" but they seem to anyway + * + * @param Integer $mode + * @return Integer + * @access private + */ + function _parseMode($mode) + { + // values come from http://lxr.free-electrons.com/source/include/uapi/linux/stat.h#L12 + // see, also, http://linux.die.net/man/2/stat + switch ($mode & 0170000) {// ie. 1111 0000 0000 0000 + case 0000000: // no file type specified - figure out the file type using alternative means + return false; + case 0040000: + return NET_SFTP_TYPE_DIRECTORY; + case 0100000: + return NET_SFTP_TYPE_REGULAR; + case 0120000: + return NET_SFTP_TYPE_SYMLINK; + // new types introduced in SFTPv5+ + // http://tools.ietf.org/html/draft-ietf-secsh-filexfer-05#section-5.2 + case 0010000: // named pipe (fifo) + return NET_SFTP_TYPE_FIFO; + case 0020000: // character special + return NET_SFTP_TYPE_CHAR_DEVICE; + case 0060000: // block special + return NET_SFTP_BLOCK_DEVICE; + case 0140000: // socket + return NET_SFTP_TYPE_SOCKET; + case 0160000: // whiteout + // "SPECIAL should be used for files that are of + // a known type which cannot be expressed in the protocol" + return NET_SFTP_TYPE_SPECIAL; + default: + return NET_SFTP_TYPE_UNKNOWN; + } + } + + /** + * Parse Longname + * + * SFTPv3 doesn't provide any easy way of identifying a file type. You could try to open + * a file as a directory and see if an error is returned or you could try to parse the + * SFTPv3-specific longname field of the SSH_FXP_NAME packet. That's what this function does. + * The result is returned using the + * {@link http://tools.ietf.org/html/draft-ietf-secsh-filexfer-04#section-5.2 SFTPv4 type constants}. + * + * If the longname is in an unrecognized format bool(false) is returned. + * + * @param String $longname + * @return Mixed + * @access private + */ + function _parseLongname($longname) + { + // http://en.wikipedia.org/wiki/Unix_file_types + // http://en.wikipedia.org/wiki/Filesystem_permissions#Notation_of_traditional_Unix_permissions + if (preg_match('#^[^/]([r-][w-][xstST-]){3}#', $longname)) { + switch ($longname[0]) { + case '-': + return NET_SFTP_TYPE_REGULAR; + case 'd': + return NET_SFTP_TYPE_DIRECTORY; + case 'l': + return NET_SFTP_TYPE_SYMLINK; + default: + return NET_SFTP_TYPE_SPECIAL; + } + } + + return false; + } + + /** + * Sends SFTP Packets + * + * See '6. General Packet Format' of draft-ietf-secsh-filexfer-13 for more info. + * + * @param Integer $type + * @param String $data + * @see Net_SFTP::_get_sftp_packet() + * @see Net_SSH2::_send_channel_packet() + * @return Boolean + * @access private + */ + function _send_sftp_packet($type, $data) + { + $packet = $this->request_id !== false ? + pack('NCNa*', strlen($data) + 5, $type, $this->request_id, $data) : + pack('NCa*', strlen($data) + 1, $type, $data); + + $start = strtok(microtime(), ' ') + strtok(''); // http://php.net/microtime#61838 + $result = $this->_send_channel_packet(NET_SFTP_CHANNEL, $packet); + $stop = strtok(microtime(), ' ') + strtok(''); + + if (defined('NET_SFTP_LOGGING')) { + $packet_type = '-> ' . $this->packet_types[$type] . + ' (' . round($stop - $start, 4) . 's)'; + if (NET_SFTP_LOGGING == NET_SFTP_LOG_REALTIME) { + echo "
    \r\n" . $this->_format_log(array($data), array($packet_type)) . "\r\n
    \r\n"; + flush(); + ob_flush(); + } else { + $this->packet_type_log[] = $packet_type; + if (NET_SFTP_LOGGING == NET_SFTP_LOG_COMPLEX) { + $this->packet_log[] = $data; + } + } + } + + return $result; + } + + /** + * Receives SFTP Packets + * + * See '6. General Packet Format' of draft-ietf-secsh-filexfer-13 for more info. + * + * Incidentally, the number of SSH_MSG_CHANNEL_DATA messages has no bearing on the number of SFTP packets present. + * There can be one SSH_MSG_CHANNEL_DATA messages containing two SFTP packets or there can be two SSH_MSG_CHANNEL_DATA + * messages containing one SFTP packet. + * + * @see Net_SFTP::_send_sftp_packet() + * @return String + * @access private + */ + function _get_sftp_packet() + { + $this->curTimeout = false; + + $start = strtok(microtime(), ' ') + strtok(''); // http://php.net/microtime#61838 + + // SFTP packet length + while (strlen($this->packet_buffer) < 4) { + $temp = $this->_get_channel_packet(NET_SFTP_CHANNEL); + if (is_bool($temp)) { + $this->packet_type = false; + $this->packet_buffer = ''; + return false; + } + $this->packet_buffer.= $temp; + } + extract(unpack('Nlength', $this->_string_shift($this->packet_buffer, 4))); + $tempLength = $length; + $tempLength-= strlen($this->packet_buffer); + + // SFTP packet type and data payload + while ($tempLength > 0) { + $temp = $this->_get_channel_packet(NET_SFTP_CHANNEL); + if (is_bool($temp)) { + $this->packet_type = false; + $this->packet_buffer = ''; + return false; + } + $this->packet_buffer.= $temp; + $tempLength-= strlen($temp); + } + + $stop = strtok(microtime(), ' ') + strtok(''); + + $this->packet_type = ord($this->_string_shift($this->packet_buffer)); + + if ($this->request_id !== false) { + $this->_string_shift($this->packet_buffer, 4); // remove the request id + $length-= 5; // account for the request id and the packet type + } else { + $length-= 1; // account for the packet type + } + + $packet = $this->_string_shift($this->packet_buffer, $length); + + if (defined('NET_SFTP_LOGGING')) { + $packet_type = '<- ' . $this->packet_types[$this->packet_type] . + ' (' . round($stop - $start, 4) . 's)'; + if (NET_SFTP_LOGGING == NET_SFTP_LOG_REALTIME) { + echo "
    \r\n" . $this->_format_log(array($packet), array($packet_type)) . "\r\n
    \r\n"; + flush(); + ob_flush(); + } else { + $this->packet_type_log[] = $packet_type; + if (NET_SFTP_LOGGING == NET_SFTP_LOG_COMPLEX) { + $this->packet_log[] = $packet; + } + } + } + + return $packet; + } + + /** + * Returns a log of the packets that have been sent and received. + * + * Returns a string if NET_SFTP_LOGGING == NET_SFTP_LOG_COMPLEX, an array if NET_SFTP_LOGGING == NET_SFTP_LOG_SIMPLE and false if !defined('NET_SFTP_LOGGING') + * + * @access public + * @return String or Array + */ + function getSFTPLog() + { + if (!defined('NET_SFTP_LOGGING')) { + return false; + } + + switch (NET_SFTP_LOGGING) { + case NET_SFTP_LOG_COMPLEX: + return $this->_format_log($this->packet_log, $this->packet_type_log); + break; + //case NET_SFTP_LOG_SIMPLE: + default: + return $this->packet_type_log; + } + } + + /** + * Returns all errors + * + * @return String + * @access public + */ + function getSFTPErrors() + { + return $this->sftp_errors; + } + + /** + * Returns the last error + * + * @return String + * @access public + */ + function getLastSFTPError() + { + return count($this->sftp_errors) ? $this->sftp_errors[count($this->sftp_errors) - 1] : ''; + } + + /** + * Get supported SFTP versions + * + * @return Array + * @access public + */ + function getSupportedVersions() + { + $temp = array('version' => $this->version); + if (isset($this->extensions['versions'])) { + $temp['extensions'] = $this->extensions['versions']; + } + return $temp; + } + + /** + * Disconnect + * + * @param Integer $reason + * @return Boolean + * @access private + */ + function _disconnect($reason) + { + $this->pwd = false; + parent::_disconnect($reason); + } +} diff --git a/vendor/phpseclib/phpseclib/phpseclib/Net/SFTP/Stream.php b/vendor/phpseclib/phpseclib/phpseclib/Net/SFTP/Stream.php new file mode 100755 index 0000000..48b79b3 --- /dev/null +++ b/vendor/phpseclib/phpseclib/phpseclib/Net/SFTP/Stream.php @@ -0,0 +1,775 @@ + + * @copyright MMXIII Jim Wigginton + * @license http://www.opensource.org/licenses/mit-license.html MIT License + * @link http://phpseclib.sourceforge.net + */ + +/** + * SFTP Stream Wrapper + * + * @package Net_SFTP_Stream + * @author Jim Wigginton + * @version 0.3.2 + * @access public + */ +class Net_SFTP_Stream +{ + /** + * SFTP instances + * + * Rather than re-create the connection we re-use instances if possible + * + * @var Array + * @access static + */ + static $instances; + + /** + * SFTP instance + * + * @var Object + * @access private + */ + var $sftp; + + /** + * Path + * + * @var String + * @access private + */ + var $path; + + /** + * Mode + * + * @var String + * @access private + */ + var $mode; + + /** + * Position + * + * @var Integer + * @access private + */ + var $pos; + + /** + * Size + * + * @var Integer + * @access private + */ + var $size; + + /** + * Directory entries + * + * @var Array + * @access private + */ + var $entries; + + /** + * EOF flag + * + * @var Boolean + * @access private + */ + var $eof; + + /** + * Context resource + * + * Technically this needs to be publically accessible so PHP can set it directly + * + * @var Resource + * @access public + */ + var $context; + + /** + * Notification callback function + * + * @var Callable + * @access public + */ + var $notification; + + /** + * The Constructor + * + * @access public + */ + function Net_SFTP_Stream() + { + if (defined('NET_SFTP_STREAM_LOGGING')) { + echo "__construct()\r\n"; + } + + if (!class_exists('Net_SFTP')) { + include_once 'Net/SFTP.php'; + } + } + + /** + * Path Parser + * + * Extract a path from a URI and actually connect to an SSH server if appropriate + * + * If "notification" is set as a context parameter the message code for successful login is + * NET_SSH2_MSG_USERAUTH_SUCCESS. For a failed login it's NET_SSH2_MSG_USERAUTH_FAILURE. + * + * @param String $path + * @return String + * @access private + */ + function _parse_path($path) + { + extract(parse_url($path) + array('port' => 22)); + + if (!isset($host)) { + return false; + } + + if (isset($this->context)) { + $context = stream_context_get_params($this->context); + if (isset($context['notification'])) { + $this->notification = $context['notification']; + } + } + + if ($host[0] == '$') { + $host = substr($host, 1); + global $$host; + if (!is_object($$host) || get_class($$host) != 'Net_SFTP') { + return false; + } + $this->sftp = $$host; + } else { + if (isset($this->context)) { + $context = stream_context_get_options($this->context); + } + if (isset($context['sftp']['session'])) { + $sftp = $context['sftp']['session']; + } + if (isset($context['sftp']['sftp'])) { + $sftp = $context['sftp']['sftp']; + } + if (isset($sftp) && is_object($sftp) && get_class($sftp) == 'Net_SFTP') { + $this->sftp = $sftp; + return $path; + } + if (isset($context['sftp']['username'])) { + $user = $context['sftp']['username']; + } + if (isset($context['sftp']['password'])) { + $pass = $context['sftp']['password']; + } + if (isset($context['sftp']['privkey']) && is_object($context['sftp']['privkey']) && get_Class($context['sftp']['privkey']) == 'Crypt_RSA') { + $pass = $context['sftp']['privkey']; + } + + if (!isset($user) || !isset($pass)) { + return false; + } + + // casting $pass to a string is necessary in the event that it's a Crypt_RSA object + if (isset(self::$instances[$host][$port][$user][(string) $pass])) { + $this->sftp = self::$instances[$host][$port][$user][(string) $pass]; + } else { + $this->sftp = new Net_SFTP($host, $port); + if (isset($this->notification) && is_callable($this->notification)) { + /* if !is_callable($this->notification) we could do this: + + user_error('fopen(): failed to call user notifier', E_USER_WARNING); + + the ftp wrapper gives errors like that when the notifier isn't callable. + i've opted not to do that, however, since the ftp wrapper gives the line + on which the fopen occurred as the line number - not the line that the + user_error is on. + */ + call_user_func($this->notification, STREAM_NOTIFY_CONNECT, STREAM_NOTIFY_SEVERITY_INFO, '', 0, 0, 0); + call_user_func($this->notification, STREAM_NOTIFY_AUTH_REQUIRED, STREAM_NOTIFY_SEVERITY_INFO, '', 0, 0, 0); + if (!$this->sftp->login($user, $pass)) { + call_user_func($this->notification, STREAM_NOTIFY_AUTH_RESULT, STREAM_NOTIFY_SEVERITY_ERR, 'Login Failure', NET_SSH2_MSG_USERAUTH_FAILURE, 0, 0); + return false; + } + call_user_func($this->notification, STREAM_NOTIFY_AUTH_RESULT, STREAM_NOTIFY_SEVERITY_INFO, 'Login Success', NET_SSH2_MSG_USERAUTH_SUCCESS, 0, 0); + } else { + if (!$this->sftp->login($user, $pass)) { + return false; + } + } + self::$instances[$host][$port][$user][(string) $pass] = $this->sftp; + } + } + + return $path; + } + + /** + * Opens file or URL + * + * @param String $path + * @param String $mode + * @param Integer $options + * @param String $opened_path + * @return Boolean + * @access public + */ + function _stream_open($path, $mode, $options, &$opened_path) + { + $path = $this->_parse_path($path); + + if ($path === false) { + return false; + } + $this->path = $path; + + $this->size = $this->sftp->size($path); + $this->mode = preg_replace('#[bt]$#', '', $mode); + $this->eof = false; + + if ($this->size === false) { + if ($this->mode[0] == 'r') { + return false; + } + } else { + switch ($this->mode[0]) { + case 'x': + return false; + case 'w': + case 'c': + $this->sftp->truncate($path, 0); + } + } + + $this->pos = $this->mode[0] != 'a' ? 0 : $this->size; + + return true; + } + + /** + * Read from stream + * + * @param Integer $count + * @return Mixed + * @access public + */ + function _stream_read($count) + { + switch ($this->mode) { + case 'w': + case 'a': + case 'x': + case 'c': + return false; + } + + // commented out because some files - eg. /dev/urandom - will say their size is 0 when in fact it's kinda infinite + //if ($this->pos >= $this->size) { + // $this->eof = true; + // return false; + //} + + $result = $this->sftp->get($this->path, false, $this->pos, $count); + if (isset($this->notification) && is_callable($this->notification)) { + if ($result === false) { + call_user_func($this->notification, STREAM_NOTIFY_FAILURE, STREAM_NOTIFY_SEVERITY_ERR, $this->sftp->getLastSFTPError(), NET_SFTP_OPEN, 0, 0); + return 0; + } + // seems that PHP calls stream_read in 8k chunks + call_user_func($this->notification, STREAM_NOTIFY_PROGRESS, STREAM_NOTIFY_SEVERITY_INFO, '', 0, strlen($result), $this->size); + } + + if (empty($result)) { // ie. false or empty string + $this->eof = true; + return false; + } + $this->pos+= strlen($result); + + return $result; + } + + /** + * Write to stream + * + * @param String $data + * @return Mixed + * @access public + */ + function _stream_write($data) + { + switch ($this->mode) { + case 'r': + return false; + } + + $result = $this->sftp->put($this->path, $data, NET_SFTP_STRING, $this->pos); + if (isset($this->notification) && is_callable($this->notification)) { + if (!$result) { + call_user_func($this->notification, STREAM_NOTIFY_FAILURE, STREAM_NOTIFY_SEVERITY_ERR, $this->sftp->getLastSFTPError(), NET_SFTP_OPEN, 0, 0); + return 0; + } + // seems that PHP splits up strings into 8k blocks before calling stream_write + call_user_func($this->notification, STREAM_NOTIFY_PROGRESS, STREAM_NOTIFY_SEVERITY_INFO, '', 0, strlen($data), strlen($data)); + } + + if ($result === false) { + return false; + } + $this->pos+= strlen($data); + if ($this->pos > $this->size) { + $this->size = $this->pos; + } + $this->eof = false; + return strlen($data); + } + + /** + * Retrieve the current position of a stream + * + * @return Integer + * @access public + */ + function _stream_tell() + { + return $this->pos; + } + + /** + * Tests for end-of-file on a file pointer + * + * In my testing there are four classes functions that normally effect the pointer: + * fseek, fputs / fwrite, fgets / fread and ftruncate. + * + * Only fgets / fread, however, results in feof() returning true. do fputs($fp, 'aaa') on a blank file and feof() + * will return false. do fread($fp, 1) and feof() will then return true. do fseek($fp, 10) on ablank file and feof() + * will return false. do fread($fp, 1) and feof() will then return true. + * + * @return Boolean + * @access public + */ + function _stream_eof() + { + return $this->eof; + } + + /** + * Seeks to specific location in a stream + * + * @param Integer $offset + * @param Integer $whence + * @return Boolean + * @access public + */ + function _stream_seek($offset, $whence) + { + switch ($whence) { + case SEEK_SET: + if ($offset >= $this->size || $offset < 0) { + return false; + } + break; + case SEEK_CUR: + $offset+= $this->pos; + break; + case SEEK_END: + $offset+= $this->size; + } + + $this->pos = $offset; + $this->eof = false; + return true; + } + + /** + * Change stream options + * + * @param String $path + * @param Integer $option + * @param Mixed $var + * @return Boolean + * @access public + */ + function _stream_metadata($path, $option, $var) + { + $path = $this->_parse_path($path); + if ($path === false) { + return false; + } + + // stream_metadata was introduced in PHP 5.4.0 but as of 5.4.11 the constants haven't been defined + // see http://www.php.net/streamwrapper.stream-metadata and https://bugs.php.net/64246 + // and https://github.com/php/php-src/blob/master/main/php_streams.h#L592 + switch ($option) { + case 1: // PHP_STREAM_META_TOUCH + return $this->sftp->touch($path, $var[0], $var[1]); + case 2: // PHP_STREAM_OWNER_NAME + case 3: // PHP_STREAM_GROUP_NAME + return false; + case 4: // PHP_STREAM_META_OWNER + return $this->sftp->chown($path, $var); + case 5: // PHP_STREAM_META_GROUP + return $this->sftp->chgrp($path, $var); + case 6: // PHP_STREAM_META_ACCESS + return $this->sftp->chmod($path, $var) !== false; + } + } + + /** + * Retrieve the underlaying resource + * + * @param Integer $cast_as + * @return Resource + * @access public + */ + function _stream_cast($cast_as) + { + return $this->sftp->fsock; + } + + /** + * Advisory file locking + * + * @param Integer $operation + * @return Boolean + * @access public + */ + function _stream_lock($operation) + { + return false; + } + + /** + * Renames a file or directory + * + * Attempts to rename oldname to newname, moving it between directories if necessary. + * If newname exists, it will be overwritten. This is a departure from what Net_SFTP + * does. + * + * @param String $path_from + * @param String $path_to + * @return Boolean + * @access public + */ + function _rename($path_from, $path_to) + { + $path1 = parse_url($path_from); + $path2 = parse_url($path_to); + unset($path1['path'], $path2['path']); + if ($path1 != $path2) { + return false; + } + + $path_from = $this->_parse_path($path_from); + $path_to = parse_url($path_to); + if ($path_from == false) { + return false; + } + + $path_to = $path_to['path']; // the $component part of parse_url() was added in PHP 5.1.2 + // "It is an error if there already exists a file with the name specified by newpath." + // -- http://tools.ietf.org/html/draft-ietf-secsh-filexfer-02#section-6.5 + if (!$this->sftp->rename($path_from, $path_to)) { + if ($this->sftp->stat($path_to)) { + return $this->sftp->delete($path_to, true) && $this->sftp->rename($path_from, $path_to); + } + return false; + } + + return true; + } + + /** + * Open directory handle + * + * The only $options is "whether or not to enforce safe_mode (0x04)". Since safe mode was deprecated in 5.3 and + * removed in 5.4 I'm just going to ignore it + * + * @param String $path + * @param Integer $options + * @return Boolean + * @access public + */ + function _dir_opendir($path, $options) + { + $path = $this->_parse_path($path); + if ($path === false) { + return false; + } + $this->pos = 0; + $this->entries = $this->sftp->nlist($path); + return $this->entries !== false; + } + + /** + * Read entry from directory handle + * + * @return Mixed + * @access public + */ + function _dir_readdir() + { + if (isset($this->entries[$this->pos])) { + return $this->entries[$this->pos++]; + } + return false; + } + + /** + * Rewind directory handle + * + * @return Boolean + * @access public + */ + function _dir_rewinddir() + { + $this->pos = 0; + return true; + } + + /** + * Close directory handle + * + * @return Boolean + * @access public + */ + function _dir_closedir() + { + return true; + } + + /** + * Create a directory + * + * Only valid $options is STREAM_MKDIR_RECURSIVE + * + * @param String $path + * @param Integer $mode + * @param Integer $options + * @return Boolean + * @access public + */ + function _mkdir($path, $mode, $options) + { + $path = $this->_parse_path($path); + if ($path === false) { + return false; + } + + return $this->sftp->mkdir($path, $mode, $options & STREAM_MKDIR_RECURSIVE); + } + + /** + * Removes a directory + * + * Only valid $options is STREAM_MKDIR_RECURSIVE per , however, + * does not have a $recursive parameter as mkdir() does so I don't know how + * STREAM_MKDIR_RECURSIVE is supposed to be set. Also, when I try it out with rmdir() I get 8 as + * $options. What does 8 correspond to? + * + * @param String $path + * @param Integer $mode + * @param Integer $options + * @return Boolean + * @access public + */ + function _rmdir($path, $options) + { + $path = $this->_parse_path($path); + if ($path === false) { + return false; + } + + return $this->sftp->rmdir($path); + } + + /** + * Flushes the output + * + * See . Always returns true because Net_SFTP doesn't cache stuff before writing + * + * @return Boolean + * @access public + */ + function _stream_flush() + { + return true; + } + + /** + * Retrieve information about a file resource + * + * @return Mixed + * @access public + */ + function _stream_stat() + { + $results = $this->sftp->stat($this->path); + if ($results === false) { + return false; + } + return $results; + } + + /** + * Delete a file + * + * @param String $path + * @return Boolean + * @access public + */ + function _unlink($path) + { + $path = $this->_parse_path($path); + if ($path === false) { + return false; + } + + return $this->sftp->delete($path, false); + } + + /** + * Retrieve information about a file + * + * Ignores the STREAM_URL_STAT_QUIET flag because the entirety of Net_SFTP_Stream is quiet by default + * might be worthwhile to reconstruct bits 12-16 (ie. the file type) if mode doesn't have them but we'll + * cross that bridge when and if it's reached + * + * @param String $path + * @param Integer $flags + * @return Mixed + * @access public + */ + function _url_stat($path, $flags) + { + $path = $this->_parse_path($path); + if ($path === false) { + return false; + } + + $results = $flags & STREAM_URL_STAT_LINK ? $this->sftp->lstat($path) : $this->sftp->stat($path); + if ($results === false) { + return false; + } + + return $results; + } + + /** + * Truncate stream + * + * @param Integer $new_size + * @return Boolean + * @access public + */ + function _stream_truncate($new_size) + { + if (!$this->sftp->truncate($this->path, $new_size)) { + return false; + } + + $this->eof = false; + $this->size = $new_size; + + return true; + } + + /** + * Change stream options + * + * STREAM_OPTION_WRITE_BUFFER isn't supported for the same reason stream_flush isn't. + * The other two aren't supported because of limitations in Net_SFTP. + * + * @param Integer $option + * @param Integer $arg1 + * @param Integer $arg2 + * @return Boolean + * @access public + */ + function _stream_set_option($option, $arg1, $arg2) + { + return false; + } + + /** + * Close an resource + * + * @access public + */ + function _stream_close() + { + } + + /** + * __call Magic Method + * + * When you're utilizing an SFTP stream you're not calling the methods in this class directly - PHP is calling them for you. + * Which kinda begs the question... what methods is PHP calling and what parameters is it passing to them? This function + * lets you figure that out. + * + * If NET_SFTP_STREAM_LOGGING is defined all calls will be output on the screen and then (regardless of whether or not + * NET_SFTP_STREAM_LOGGING is enabled) the parameters will be passed through to the appropriate method. + * + * @param String + * @param Array + * @return Mixed + * @access public + */ + function __call($name, $arguments) + { + if (defined('NET_SFTP_STREAM_LOGGING')) { + echo $name . '('; + $last = count($arguments) - 1; + foreach ($arguments as $i => $argument) { + var_export($argument); + if ($i != $last) { + echo ','; + } + } + echo ")\r\n"; + } + $name = '_' . $name; + if (!method_exists($this, $name)) { + return false; + } + return call_user_func_array(array($this, $name), $arguments); + } +} + +if (function_exists('stream_wrapper_register')) { + stream_wrapper_register('sftp', 'Net_SFTP_Stream'); +} diff --git a/vendor/phpseclib/phpseclib/phpseclib/Net/SSH1.php b/vendor/phpseclib/phpseclib/phpseclib/Net/SSH1.php new file mode 100755 index 0000000..0a6aa90 --- /dev/null +++ b/vendor/phpseclib/phpseclib/phpseclib/Net/SSH1.php @@ -0,0 +1,1582 @@ + + * login('username', 'password')) { + * exit('Login Failed'); + * } + * + * echo $ssh->exec('ls -la'); + * ?> + * + * + * Here's another short example: + * + * login('username', 'password')) { + * exit('Login Failed'); + * } + * + * echo $ssh->read('username@username:~$'); + * $ssh->write("ls -la\n"); + * echo $ssh->read('username@username:~$'); + * ?> + * + * + * More information on the SSHv1 specification can be found by reading + * {@link http://www.snailbook.com/docs/protocol-1.5.txt protocol-1.5.txt}. + * + * LICENSE: Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * @category Net + * @package Net_SSH1 + * @author Jim Wigginton + * @copyright MMVII Jim Wigginton + * @license http://www.opensource.org/licenses/mit-license.html MIT License + * @link http://phpseclib.sourceforge.net + */ + +/**#@+ + * Encryption Methods + * + * @see Net_SSH1::getSupportedCiphers() + * @access public + */ +/** + * No encryption + * + * Not supported. + */ +define('NET_SSH1_CIPHER_NONE', 0); +/** + * IDEA in CFB mode + * + * Not supported. + */ +define('NET_SSH1_CIPHER_IDEA', 1); +/** + * DES in CBC mode + */ +define('NET_SSH1_CIPHER_DES', 2); +/** + * Triple-DES in CBC mode + * + * All implementations are required to support this + */ +define('NET_SSH1_CIPHER_3DES', 3); +/** + * TRI's Simple Stream encryption CBC + * + * Not supported nor is it defined in the official SSH1 specs. OpenSSH, however, does define it (see cipher.h), + * although it doesn't use it (see cipher.c) + */ +define('NET_SSH1_CIPHER_BROKEN_TSS', 4); +/** + * RC4 + * + * Not supported. + * + * @internal According to the SSH1 specs: + * + * "The first 16 bytes of the session key are used as the key for + * the server to client direction. The remaining 16 bytes are used + * as the key for the client to server direction. This gives + * independent 128-bit keys for each direction." + * + * This library currently only supports encryption when the same key is being used for both directions. This is + * because there's only one $crypto object. Two could be added ($encrypt and $decrypt, perhaps). + */ +define('NET_SSH1_CIPHER_RC4', 5); +/** + * Blowfish + * + * Not supported nor is it defined in the official SSH1 specs. OpenSSH, however, defines it (see cipher.h) and + * uses it (see cipher.c) + */ +define('NET_SSH1_CIPHER_BLOWFISH', 6); +/**#@-*/ + +/**#@+ + * Authentication Methods + * + * @see Net_SSH1::getSupportedAuthentications() + * @access public + */ +/** + * .rhosts or /etc/hosts.equiv + */ +define('NET_SSH1_AUTH_RHOSTS', 1); +/** + * pure RSA authentication + */ +define('NET_SSH1_AUTH_RSA', 2); +/** + * password authentication + * + * This is the only method that is supported by this library. + */ +define('NET_SSH1_AUTH_PASSWORD', 3); +/** + * .rhosts with RSA host authentication + */ +define('NET_SSH1_AUTH_RHOSTS_RSA', 4); +/**#@-*/ + +/**#@+ + * Terminal Modes + * + * @link http://3sp.com/content/developer/maverick-net/docs/Maverick.SSH.PseudoTerminalModesMembers.html + * @access private + */ +define('NET_SSH1_TTY_OP_END', 0); +/**#@-*/ + +/** + * The Response Type + * + * @see Net_SSH1::_get_binary_packet() + * @access private + */ +define('NET_SSH1_RESPONSE_TYPE', 1); + +/** + * The Response Data + * + * @see Net_SSH1::_get_binary_packet() + * @access private + */ +define('NET_SSH1_RESPONSE_DATA', 2); + +/**#@+ + * Execution Bitmap Masks + * + * @see Net_SSH1::bitmap + * @access private + */ +define('NET_SSH1_MASK_CONSTRUCTOR', 0x00000001); +define('NET_SSH1_MASK_LOGIN', 0x00000002); +define('NET_SSH1_MASK_SHELL', 0x00000004); +/**#@-*/ + +/**#@+ + * @access public + * @see Net_SSH1::getLog() + */ +/** + * Returns the message numbers + */ +define('NET_SSH1_LOG_SIMPLE', 1); +/** + * Returns the message content + */ +define('NET_SSH1_LOG_COMPLEX', 2); +/** + * Outputs the content real-time + */ +define('NET_SSH1_LOG_REALTIME', 3); +/** + * Dumps the content real-time to a file + */ +define('NET_SSH1_LOG_REALTIME_FILE', 4); +/**#@-*/ + +/**#@+ + * @access public + * @see Net_SSH1::read() + */ +/** + * Returns when a string matching $expect exactly is found + */ +define('NET_SSH1_READ_SIMPLE', 1); +/** + * Returns when a string matching the regular expression $expect is found + */ +define('NET_SSH1_READ_REGEX', 2); +/**#@-*/ + +/** + * Pure-PHP implementation of SSHv1. + * + * @package Net_SSH1 + * @author Jim Wigginton + * @version 0.1.0 + * @access public + */ +class Net_SSH1 +{ + /** + * The SSH identifier + * + * @var String + * @access private + */ + var $identifier = 'SSH-1.5-phpseclib'; + + /** + * The Socket Object + * + * @var Object + * @access private + */ + var $fsock; + + /** + * The cryptography object + * + * @var Object + * @access private + */ + var $crypto = false; + + /** + * Execution Bitmap + * + * The bits that are set represent functions that have been called already. This is used to determine + * if a requisite function has been successfully executed. If not, an error should be thrown. + * + * @var Integer + * @access private + */ + var $bitmap = 0; + + /** + * The Server Key Public Exponent + * + * Logged for debug purposes + * + * @see Net_SSH1::getServerKeyPublicExponent() + * @var String + * @access private + */ + var $server_key_public_exponent; + + /** + * The Server Key Public Modulus + * + * Logged for debug purposes + * + * @see Net_SSH1::getServerKeyPublicModulus() + * @var String + * @access private + */ + var $server_key_public_modulus; + + /** + * The Host Key Public Exponent + * + * Logged for debug purposes + * + * @see Net_SSH1::getHostKeyPublicExponent() + * @var String + * @access private + */ + var $host_key_public_exponent; + + /** + * The Host Key Public Modulus + * + * Logged for debug purposes + * + * @see Net_SSH1::getHostKeyPublicModulus() + * @var String + * @access private + */ + var $host_key_public_modulus; + + /** + * Supported Ciphers + * + * Logged for debug purposes + * + * @see Net_SSH1::getSupportedCiphers() + * @var Array + * @access private + */ + var $supported_ciphers = array( + NET_SSH1_CIPHER_NONE => 'No encryption', + NET_SSH1_CIPHER_IDEA => 'IDEA in CFB mode', + NET_SSH1_CIPHER_DES => 'DES in CBC mode', + NET_SSH1_CIPHER_3DES => 'Triple-DES in CBC mode', + NET_SSH1_CIPHER_BROKEN_TSS => 'TRI\'s Simple Stream encryption CBC', + NET_SSH1_CIPHER_RC4 => 'RC4', + NET_SSH1_CIPHER_BLOWFISH => 'Blowfish' + ); + + /** + * Supported Authentications + * + * Logged for debug purposes + * + * @see Net_SSH1::getSupportedAuthentications() + * @var Array + * @access private + */ + var $supported_authentications = array( + NET_SSH1_AUTH_RHOSTS => '.rhosts or /etc/hosts.equiv', + NET_SSH1_AUTH_RSA => 'pure RSA authentication', + NET_SSH1_AUTH_PASSWORD => 'password authentication', + NET_SSH1_AUTH_RHOSTS_RSA => '.rhosts with RSA host authentication' + ); + + /** + * Server Identification + * + * @see Net_SSH1::getServerIdentification() + * @var String + * @access private + */ + var $server_identification = ''; + + /** + * Protocol Flags + * + * @see Net_SSH1::Net_SSH1() + * @var Array + * @access private + */ + var $protocol_flags = array(); + + /** + * Protocol Flag Log + * + * @see Net_SSH1::getLog() + * @var Array + * @access private + */ + var $protocol_flag_log = array(); + + /** + * Message Log + * + * @see Net_SSH1::getLog() + * @var Array + * @access private + */ + var $message_log = array(); + + /** + * Real-time log file pointer + * + * @see Net_SSH1::_append_log() + * @var Resource + * @access private + */ + var $realtime_log_file; + + /** + * Real-time log file size + * + * @see Net_SSH1::_append_log() + * @var Integer + * @access private + */ + var $realtime_log_size; + + /** + * Real-time log file wrap boolean + * + * @see Net_SSH1::_append_log() + * @var Boolean + * @access private + */ + var $realtime_log_wrap; + + /** + * Interactive Buffer + * + * @see Net_SSH1::read() + * @var Array + * @access private + */ + var $interactiveBuffer = ''; + + /** + * Timeout + * + * @see Net_SSH1::setTimeout() + * @access private + */ + var $timeout; + + /** + * Current Timeout + * + * @see Net_SSH1::_get_channel_packet() + * @access private + */ + var $curTimeout; + + /** + * Log Boundary + * + * @see Net_SSH1::_format_log + * @access private + */ + var $log_boundary = ':'; + + /** + * Log Long Width + * + * @see Net_SSH1::_format_log + * @access private + */ + var $log_long_width = 65; + + /** + * Log Short Width + * + * @see Net_SSH1::_format_log + * @access private + */ + var $log_short_width = 16; + + /** + * Default Constructor. + * + * Connects to an SSHv1 server + * + * @param String $host + * @param optional Integer $port + * @param optional Integer $timeout + * @param optional Integer $cipher + * @return Net_SSH1 + * @access public + */ + function Net_SSH1($host, $port = 22, $timeout = 10, $cipher = NET_SSH1_CIPHER_3DES) + { + if (!class_exists('Math_BigInteger')) { + include_once 'Math/BigInteger.php'; + } + + // Include Crypt_Random + // the class_exists() will only be called if the crypt_random_string function hasn't been defined and + // will trigger a call to __autoload() if you're wanting to auto-load classes + // call function_exists() a second time to stop the include_once from being called outside + // of the auto loader + if (!function_exists('crypt_random_string') && !class_exists('Crypt_Random') && !function_exists('crypt_random_string')) { + include_once 'Crypt/Random.php'; + } + + $this->protocol_flags = array( + 1 => 'NET_SSH1_MSG_DISCONNECT', + 2 => 'NET_SSH1_SMSG_PUBLIC_KEY', + 3 => 'NET_SSH1_CMSG_SESSION_KEY', + 4 => 'NET_SSH1_CMSG_USER', + 9 => 'NET_SSH1_CMSG_AUTH_PASSWORD', + 10 => 'NET_SSH1_CMSG_REQUEST_PTY', + 12 => 'NET_SSH1_CMSG_EXEC_SHELL', + 13 => 'NET_SSH1_CMSG_EXEC_CMD', + 14 => 'NET_SSH1_SMSG_SUCCESS', + 15 => 'NET_SSH1_SMSG_FAILURE', + 16 => 'NET_SSH1_CMSG_STDIN_DATA', + 17 => 'NET_SSH1_SMSG_STDOUT_DATA', + 18 => 'NET_SSH1_SMSG_STDERR_DATA', + 19 => 'NET_SSH1_CMSG_EOF', + 20 => 'NET_SSH1_SMSG_EXITSTATUS', + 33 => 'NET_SSH1_CMSG_EXIT_CONFIRMATION' + ); + + $this->_define_array($this->protocol_flags); + + $this->fsock = @fsockopen($host, $port, $errno, $errstr, $timeout); + if (!$this->fsock) { + user_error(rtrim("Cannot connect to $host. Error $errno. $errstr")); + return; + } + + $this->server_identification = $init_line = fgets($this->fsock, 255); + + if (defined('NET_SSH1_LOGGING')) { + $this->_append_log('<-', $this->server_identification); + $this->_append_log('->', $this->identifier . "\r\n"); + } + + if (!preg_match('#SSH-([0-9\.]+)-(.+)#', $init_line, $parts)) { + user_error('Can only connect to SSH servers'); + return; + } + if ($parts[1][0] != 1) { + user_error("Cannot connect to SSH $parts[1] servers"); + return; + } + + fputs($this->fsock, $this->identifier."\r\n"); + + $response = $this->_get_binary_packet(); + if ($response[NET_SSH1_RESPONSE_TYPE] != NET_SSH1_SMSG_PUBLIC_KEY) { + user_error('Expected SSH_SMSG_PUBLIC_KEY'); + return; + } + + $anti_spoofing_cookie = $this->_string_shift($response[NET_SSH1_RESPONSE_DATA], 8); + + $this->_string_shift($response[NET_SSH1_RESPONSE_DATA], 4); + + $temp = unpack('nlen', $this->_string_shift($response[NET_SSH1_RESPONSE_DATA], 2)); + $server_key_public_exponent = new Math_BigInteger($this->_string_shift($response[NET_SSH1_RESPONSE_DATA], ceil($temp['len'] / 8)), 256); + $this->server_key_public_exponent = $server_key_public_exponent; + + $temp = unpack('nlen', $this->_string_shift($response[NET_SSH1_RESPONSE_DATA], 2)); + $server_key_public_modulus = new Math_BigInteger($this->_string_shift($response[NET_SSH1_RESPONSE_DATA], ceil($temp['len'] / 8)), 256); + $this->server_key_public_modulus = $server_key_public_modulus; + + $this->_string_shift($response[NET_SSH1_RESPONSE_DATA], 4); + + $temp = unpack('nlen', $this->_string_shift($response[NET_SSH1_RESPONSE_DATA], 2)); + $host_key_public_exponent = new Math_BigInteger($this->_string_shift($response[NET_SSH1_RESPONSE_DATA], ceil($temp['len'] / 8)), 256); + $this->host_key_public_exponent = $host_key_public_exponent; + + $temp = unpack('nlen', $this->_string_shift($response[NET_SSH1_RESPONSE_DATA], 2)); + $host_key_public_modulus = new Math_BigInteger($this->_string_shift($response[NET_SSH1_RESPONSE_DATA], ceil($temp['len'] / 8)), 256); + $this->host_key_public_modulus = $host_key_public_modulus; + + $this->_string_shift($response[NET_SSH1_RESPONSE_DATA], 4); + + // get a list of the supported ciphers + extract(unpack('Nsupported_ciphers_mask', $this->_string_shift($response[NET_SSH1_RESPONSE_DATA], 4))); + foreach ($this->supported_ciphers as $mask=>$name) { + if (($supported_ciphers_mask & (1 << $mask)) == 0) { + unset($this->supported_ciphers[$mask]); + } + } + + // get a list of the supported authentications + extract(unpack('Nsupported_authentications_mask', $this->_string_shift($response[NET_SSH1_RESPONSE_DATA], 4))); + foreach ($this->supported_authentications as $mask=>$name) { + if (($supported_authentications_mask & (1 << $mask)) == 0) { + unset($this->supported_authentications[$mask]); + } + } + + $session_id = pack('H*', md5($host_key_public_modulus->toBytes() . $server_key_public_modulus->toBytes() . $anti_spoofing_cookie)); + + $session_key = crypt_random_string(32); + $double_encrypted_session_key = $session_key ^ str_pad($session_id, 32, chr(0)); + + if ($server_key_public_modulus->compare($host_key_public_modulus) < 0) { + $double_encrypted_session_key = $this->_rsa_crypt( + $double_encrypted_session_key, + array( + $server_key_public_exponent, + $server_key_public_modulus + ) + ); + $double_encrypted_session_key = $this->_rsa_crypt( + $double_encrypted_session_key, + array( + $host_key_public_exponent, + $host_key_public_modulus + ) + ); + } else { + $double_encrypted_session_key = $this->_rsa_crypt( + $double_encrypted_session_key, + array( + $host_key_public_exponent, + $host_key_public_modulus + ) + ); + $double_encrypted_session_key = $this->_rsa_crypt( + $double_encrypted_session_key, + array( + $server_key_public_exponent, + $server_key_public_modulus + ) + ); + } + + $cipher = isset($this->supported_ciphers[$cipher]) ? $cipher : NET_SSH1_CIPHER_3DES; + $data = pack('C2a*na*N', NET_SSH1_CMSG_SESSION_KEY, $cipher, $anti_spoofing_cookie, 8 * strlen($double_encrypted_session_key), $double_encrypted_session_key, 0); + + if (!$this->_send_binary_packet($data)) { + user_error('Error sending SSH_CMSG_SESSION_KEY'); + return; + } + + switch ($cipher) { + //case NET_SSH1_CIPHER_NONE: + // $this->crypto = new Crypt_Null(); + // break; + case NET_SSH1_CIPHER_DES: + if (!class_exists('Crypt_DES')) { + include_once 'Crypt/DES.php'; + } + $this->crypto = new Crypt_DES(); + $this->crypto->disablePadding(); + $this->crypto->enableContinuousBuffer(); + $this->crypto->setKey(substr($session_key, 0, 8)); + break; + case NET_SSH1_CIPHER_3DES: + if (!class_exists('Crypt_TripleDES')) { + include_once 'Crypt/TripleDES.php'; + } + $this->crypto = new Crypt_TripleDES(CRYPT_DES_MODE_3CBC); + $this->crypto->disablePadding(); + $this->crypto->enableContinuousBuffer(); + $this->crypto->setKey(substr($session_key, 0, 24)); + break; + //case NET_SSH1_CIPHER_RC4: + // if (!class_exists('Crypt_RC4')) { + // include_once('Crypt/RC4.php'); + // } + // $this->crypto = new Crypt_RC4(); + // $this->crypto->enableContinuousBuffer(); + // $this->crypto->setKey(substr($session_key, 0, 16)); + // break; + } + + $response = $this->_get_binary_packet(); + + if ($response[NET_SSH1_RESPONSE_TYPE] != NET_SSH1_SMSG_SUCCESS) { + user_error('Expected SSH_SMSG_SUCCESS'); + return; + } + + $this->bitmap = NET_SSH1_MASK_CONSTRUCTOR; + } + + /** + * Login + * + * @param String $username + * @param optional String $password + * @return Boolean + * @access public + */ + function login($username, $password = '') + { + if (!($this->bitmap & NET_SSH1_MASK_CONSTRUCTOR)) { + return false; + } + + $data = pack('CNa*', NET_SSH1_CMSG_USER, strlen($username), $username); + + if (!$this->_send_binary_packet($data)) { + user_error('Error sending SSH_CMSG_USER'); + return false; + } + + $response = $this->_get_binary_packet(); + + if ($response === true) { + return false; + } + if ($response[NET_SSH1_RESPONSE_TYPE] == NET_SSH1_SMSG_SUCCESS) { + $this->bitmap |= NET_SSH1_MASK_LOGIN; + return true; + } else if ($response[NET_SSH1_RESPONSE_TYPE] != NET_SSH1_SMSG_FAILURE) { + user_error('Expected SSH_SMSG_SUCCESS or SSH_SMSG_FAILURE'); + return false; + } + + $data = pack('CNa*', NET_SSH1_CMSG_AUTH_PASSWORD, strlen($password), $password); + + if (!$this->_send_binary_packet($data)) { + user_error('Error sending SSH_CMSG_AUTH_PASSWORD'); + return false; + } + + // remove the username and password from the last logged packet + if (defined('NET_SSH1_LOGGING') && NET_SSH1_LOGGING == NET_SSH1_LOG_COMPLEX) { + $data = pack('CNa*', NET_SSH1_CMSG_AUTH_PASSWORD, strlen('password'), 'password'); + $this->message_log[count($this->message_log) - 1] = $data; + } + + $response = $this->_get_binary_packet(); + + if ($response === true) { + return false; + } + if ($response[NET_SSH1_RESPONSE_TYPE] == NET_SSH1_SMSG_SUCCESS) { + $this->bitmap |= NET_SSH1_MASK_LOGIN; + return true; + } else if ($response[NET_SSH1_RESPONSE_TYPE] == NET_SSH1_SMSG_FAILURE) { + return false; + } else { + user_error('Expected SSH_SMSG_SUCCESS or SSH_SMSG_FAILURE'); + return false; + } + } + + /** + * Set Timeout + * + * $ssh->exec('ping 127.0.0.1'); on a Linux host will never return and will run indefinitely. setTimeout() makes it so it'll timeout. + * Setting $timeout to false or 0 will mean there is no timeout. + * + * @param Mixed $timeout + */ + function setTimeout($timeout) + { + $this->timeout = $this->curTimeout = $timeout; + } + + /** + * Executes a command on a non-interactive shell, returns the output, and quits. + * + * An SSH1 server will close the connection after a command has been executed on a non-interactive shell. SSH2 + * servers don't, however, this isn't an SSH2 client. The way this works, on the server, is by initiating a + * shell with the -s option, as discussed in the following links: + * + * {@link http://www.faqs.org/docs/bashman/bashref_65.html http://www.faqs.org/docs/bashman/bashref_65.html} + * {@link http://www.faqs.org/docs/bashman/bashref_62.html http://www.faqs.org/docs/bashman/bashref_62.html} + * + * To execute further commands, a new Net_SSH1 object will need to be created. + * + * Returns false on failure and the output, otherwise. + * + * @see Net_SSH1::interactiveRead() + * @see Net_SSH1::interactiveWrite() + * @param String $cmd + * @return mixed + * @access public + */ + function exec($cmd, $block = true) + { + if (!($this->bitmap & NET_SSH1_MASK_LOGIN)) { + user_error('Operation disallowed prior to login()'); + return false; + } + + $data = pack('CNa*', NET_SSH1_CMSG_EXEC_CMD, strlen($cmd), $cmd); + + if (!$this->_send_binary_packet($data)) { + user_error('Error sending SSH_CMSG_EXEC_CMD'); + return false; + } + + if (!$block) { + return true; + } + + $output = ''; + $response = $this->_get_binary_packet(); + + if ($response !== false) { + do { + $output.= substr($response[NET_SSH1_RESPONSE_DATA], 4); + $response = $this->_get_binary_packet(); + } while (is_array($response) && $response[NET_SSH1_RESPONSE_TYPE] != NET_SSH1_SMSG_EXITSTATUS); + } + + $data = pack('C', NET_SSH1_CMSG_EXIT_CONFIRMATION); + + // i don't think it's really all that important if this packet gets sent or not. + $this->_send_binary_packet($data); + + fclose($this->fsock); + + // reset the execution bitmap - a new Net_SSH1 object needs to be created. + $this->bitmap = 0; + + return $output; + } + + /** + * Creates an interactive shell + * + * @see Net_SSH1::interactiveRead() + * @see Net_SSH1::interactiveWrite() + * @return Boolean + * @access private + */ + function _initShell() + { + // connect using the sample parameters in protocol-1.5.txt. + // according to wikipedia.org's entry on text terminals, "the fundamental type of application running on a text + // terminal is a command line interpreter or shell". thus, opening a terminal session to run the shell. + $data = pack('CNa*N4C', NET_SSH1_CMSG_REQUEST_PTY, strlen('vt100'), 'vt100', 24, 80, 0, 0, NET_SSH1_TTY_OP_END); + + if (!$this->_send_binary_packet($data)) { + user_error('Error sending SSH_CMSG_REQUEST_PTY'); + return false; + } + + $response = $this->_get_binary_packet(); + + if ($response === true) { + return false; + } + if ($response[NET_SSH1_RESPONSE_TYPE] != NET_SSH1_SMSG_SUCCESS) { + user_error('Expected SSH_SMSG_SUCCESS'); + return false; + } + + $data = pack('C', NET_SSH1_CMSG_EXEC_SHELL); + + if (!$this->_send_binary_packet($data)) { + user_error('Error sending SSH_CMSG_EXEC_SHELL'); + return false; + } + + $this->bitmap |= NET_SSH1_MASK_SHELL; + + //stream_set_blocking($this->fsock, 0); + + return true; + } + + /** + * Inputs a command into an interactive shell. + * + * @see Net_SSH1::interactiveWrite() + * @param String $cmd + * @return Boolean + * @access public + */ + function write($cmd) + { + return $this->interactiveWrite($cmd); + } + + /** + * Returns the output of an interactive shell when there's a match for $expect + * + * $expect can take the form of a string literal or, if $mode == NET_SSH1_READ_REGEX, + * a regular expression. + * + * @see Net_SSH1::write() + * @param String $expect + * @param Integer $mode + * @return Boolean + * @access public + */ + function read($expect, $mode = NET_SSH1_READ_SIMPLE) + { + if (!($this->bitmap & NET_SSH1_MASK_LOGIN)) { + user_error('Operation disallowed prior to login()'); + return false; + } + + if (!($this->bitmap & NET_SSH1_MASK_SHELL) && !$this->_initShell()) { + user_error('Unable to initiate an interactive shell session'); + return false; + } + + $match = $expect; + while (true) { + if ($mode == NET_SSH1_READ_REGEX) { + preg_match($expect, $this->interactiveBuffer, $matches); + $match = isset($matches[0]) ? $matches[0] : ''; + } + $pos = strlen($match) ? strpos($this->interactiveBuffer, $match) : false; + if ($pos !== false) { + return $this->_string_shift($this->interactiveBuffer, $pos + strlen($match)); + } + $response = $this->_get_binary_packet(); + + if ($response === true) { + return $this->_string_shift($this->interactiveBuffer, strlen($this->interactiveBuffer)); + } + $this->interactiveBuffer.= substr($response[NET_SSH1_RESPONSE_DATA], 4); + } + } + + /** + * Inputs a command into an interactive shell. + * + * @see Net_SSH1::interactiveRead() + * @param String $cmd + * @return Boolean + * @access public + */ + function interactiveWrite($cmd) + { + if (!($this->bitmap & NET_SSH1_MASK_LOGIN)) { + user_error('Operation disallowed prior to login()'); + return false; + } + + if (!($this->bitmap & NET_SSH1_MASK_SHELL) && !$this->_initShell()) { + user_error('Unable to initiate an interactive shell session'); + return false; + } + + $data = pack('CNa*', NET_SSH1_CMSG_STDIN_DATA, strlen($cmd), $cmd); + + if (!$this->_send_binary_packet($data)) { + user_error('Error sending SSH_CMSG_STDIN'); + return false; + } + + return true; + } + + /** + * Returns the output of an interactive shell when no more output is available. + * + * Requires PHP 4.3.0 or later due to the use of the stream_select() function. If you see stuff like + * "^[[00m", you're seeing ANSI escape codes. According to + * {@link http://support.microsoft.com/kb/101875 How to Enable ANSI.SYS in a Command Window}, "Windows NT + * does not support ANSI escape sequences in Win32 Console applications", so if you're a Windows user, + * there's not going to be much recourse. + * + * @see Net_SSH1::interactiveRead() + * @return String + * @access public + */ + function interactiveRead() + { + if (!($this->bitmap & NET_SSH1_MASK_LOGIN)) { + user_error('Operation disallowed prior to login()'); + return false; + } + + if (!($this->bitmap & NET_SSH1_MASK_SHELL) && !$this->_initShell()) { + user_error('Unable to initiate an interactive shell session'); + return false; + } + + $read = array($this->fsock); + $write = $except = null; + if (stream_select($read, $write, $except, 0)) { + $response = $this->_get_binary_packet(); + return substr($response[NET_SSH1_RESPONSE_DATA], 4); + } else { + return ''; + } + } + + /** + * Disconnect + * + * @access public + */ + function disconnect() + { + $this->_disconnect(); + } + + /** + * Destructor. + * + * Will be called, automatically, if you're supporting just PHP5. If you're supporting PHP4, you'll need to call + * disconnect(). + * + * @access public + */ + function __destruct() + { + $this->_disconnect(); + } + + /** + * Disconnect + * + * @param String $msg + * @access private + */ + function _disconnect($msg = 'Client Quit') + { + if ($this->bitmap) { + $data = pack('C', NET_SSH1_CMSG_EOF); + $this->_send_binary_packet($data); + /* + $response = $this->_get_binary_packet(); + if ($response === true) { + $response = array(NET_SSH1_RESPONSE_TYPE => -1); + } + switch ($response[NET_SSH1_RESPONSE_TYPE]) { + case NET_SSH1_SMSG_EXITSTATUS: + $data = pack('C', NET_SSH1_CMSG_EXIT_CONFIRMATION); + break; + default: + $data = pack('CNa*', NET_SSH1_MSG_DISCONNECT, strlen($msg), $msg); + } + */ + $data = pack('CNa*', NET_SSH1_MSG_DISCONNECT, strlen($msg), $msg); + + $this->_send_binary_packet($data); + fclose($this->fsock); + $this->bitmap = 0; + } + } + + /** + * Gets Binary Packets + * + * See 'The Binary Packet Protocol' of protocol-1.5.txt for more info. + * + * Also, this function could be improved upon by adding detection for the following exploit: + * http://www.securiteam.com/securitynews/5LP042K3FY.html + * + * @see Net_SSH1::_send_binary_packet() + * @return Array + * @access private + */ + function _get_binary_packet() + { + if (feof($this->fsock)) { + //user_error('connection closed prematurely'); + return false; + } + + if ($this->curTimeout) { + $read = array($this->fsock); + $write = $except = null; + + $start = strtok(microtime(), ' ') + strtok(''); // http://php.net/microtime#61838 + $sec = floor($this->curTimeout); + $usec = 1000000 * ($this->curTimeout - $sec); + // on windows this returns a "Warning: Invalid CRT parameters detected" error + if (!@stream_select($read, $write, $except, $sec, $usec) && !count($read)) { + //$this->_disconnect('Timeout'); + return true; + } + $elapsed = strtok(microtime(), ' ') + strtok('') - $start; + $this->curTimeout-= $elapsed; + } + + $start = strtok(microtime(), ' ') + strtok(''); // http://php.net/microtime#61838 + $temp = unpack('Nlength', fread($this->fsock, 4)); + + $padding_length = 8 - ($temp['length'] & 7); + $length = $temp['length'] + $padding_length; + + while ($length > 0) { + $temp = fread($this->fsock, $length); + $raw.= $temp; + $length-= strlen($temp); + } + $stop = strtok(microtime(), ' ') + strtok(''); + + if (strlen($raw) && $this->crypto !== false) { + $raw = $this->crypto->decrypt($raw); + } + + $padding = substr($raw, 0, $padding_length); + $type = $raw[$padding_length]; + $data = substr($raw, $padding_length + 1, -4); + + $temp = unpack('Ncrc', substr($raw, -4)); + + //if ( $temp['crc'] != $this->_crc($padding . $type . $data) ) { + // user_error('Bad CRC in packet from server'); + // return false; + //} + + $type = ord($type); + + if (defined('NET_SSH1_LOGGING')) { + $temp = isset($this->protocol_flags[$type]) ? $this->protocol_flags[$type] : 'UNKNOWN'; + $temp = '<- ' . $temp . + ' (' . round($stop - $start, 4) . 's)'; + $this->_append_log($temp, $data); + } + + return array( + NET_SSH1_RESPONSE_TYPE => $type, + NET_SSH1_RESPONSE_DATA => $data + ); + } + + /** + * Sends Binary Packets + * + * Returns true on success, false on failure. + * + * @see Net_SSH1::_get_binary_packet() + * @param String $data + * @return Boolean + * @access private + */ + function _send_binary_packet($data) + { + if (feof($this->fsock)) { + //user_error('connection closed prematurely'); + return false; + } + + $length = strlen($data) + 4; + + $padding = crypt_random_string(8 - ($length & 7)); + + $orig = $data; + $data = $padding . $data; + $data.= pack('N', $this->_crc($data)); + + if ($this->crypto !== false) { + $data = $this->crypto->encrypt($data); + } + + $packet = pack('Na*', $length, $data); + + $start = strtok(microtime(), ' ') + strtok(''); // http://php.net/microtime#61838 + $result = strlen($packet) == fputs($this->fsock, $packet); + $stop = strtok(microtime(), ' ') + strtok(''); + + if (defined('NET_SSH1_LOGGING')) { + $temp = isset($this->protocol_flags[ord($orig[0])]) ? $this->protocol_flags[ord($orig[0])] : 'UNKNOWN'; + $temp = '-> ' . $temp . + ' (' . round($stop - $start, 4) . 's)'; + $this->_append_log($temp, $orig); + } + + return $result; + } + + /** + * Cyclic Redundancy Check (CRC) + * + * PHP's crc32 function is implemented slightly differently than the one that SSH v1 uses, so + * we've reimplemented it. A more detailed discussion of the differences can be found after + * $crc_lookup_table's initialization. + * + * @see Net_SSH1::_get_binary_packet() + * @see Net_SSH1::_send_binary_packet() + * @param String $data + * @return Integer + * @access private + */ + function _crc($data) + { + static $crc_lookup_table = array( + 0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA, + 0x076DC419, 0x706AF48F, 0xE963A535, 0x9E6495A3, + 0x0EDB8832, 0x79DCB8A4, 0xE0D5E91E, 0x97D2D988, + 0x09B64C2B, 0x7EB17CBD, 0xE7B82D07, 0x90BF1D91, + 0x1DB71064, 0x6AB020F2, 0xF3B97148, 0x84BE41DE, + 0x1ADAD47D, 0x6DDDE4EB, 0xF4D4B551, 0x83D385C7, + 0x136C9856, 0x646BA8C0, 0xFD62F97A, 0x8A65C9EC, + 0x14015C4F, 0x63066CD9, 0xFA0F3D63, 0x8D080DF5, + 0x3B6E20C8, 0x4C69105E, 0xD56041E4, 0xA2677172, + 0x3C03E4D1, 0x4B04D447, 0xD20D85FD, 0xA50AB56B, + 0x35B5A8FA, 0x42B2986C, 0xDBBBC9D6, 0xACBCF940, + 0x32D86CE3, 0x45DF5C75, 0xDCD60DCF, 0xABD13D59, + 0x26D930AC, 0x51DE003A, 0xC8D75180, 0xBFD06116, + 0x21B4F4B5, 0x56B3C423, 0xCFBA9599, 0xB8BDA50F, + 0x2802B89E, 0x5F058808, 0xC60CD9B2, 0xB10BE924, + 0x2F6F7C87, 0x58684C11, 0xC1611DAB, 0xB6662D3D, + 0x76DC4190, 0x01DB7106, 0x98D220BC, 0xEFD5102A, + 0x71B18589, 0x06B6B51F, 0x9FBFE4A5, 0xE8B8D433, + 0x7807C9A2, 0x0F00F934, 0x9609A88E, 0xE10E9818, + 0x7F6A0DBB, 0x086D3D2D, 0x91646C97, 0xE6635C01, + 0x6B6B51F4, 0x1C6C6162, 0x856530D8, 0xF262004E, + 0x6C0695ED, 0x1B01A57B, 0x8208F4C1, 0xF50FC457, + 0x65B0D9C6, 0x12B7E950, 0x8BBEB8EA, 0xFCB9887C, + 0x62DD1DDF, 0x15DA2D49, 0x8CD37CF3, 0xFBD44C65, + 0x4DB26158, 0x3AB551CE, 0xA3BC0074, 0xD4BB30E2, + 0x4ADFA541, 0x3DD895D7, 0xA4D1C46D, 0xD3D6F4FB, + 0x4369E96A, 0x346ED9FC, 0xAD678846, 0xDA60B8D0, + 0x44042D73, 0x33031DE5, 0xAA0A4C5F, 0xDD0D7CC9, + 0x5005713C, 0x270241AA, 0xBE0B1010, 0xC90C2086, + 0x5768B525, 0x206F85B3, 0xB966D409, 0xCE61E49F, + 0x5EDEF90E, 0x29D9C998, 0xB0D09822, 0xC7D7A8B4, + 0x59B33D17, 0x2EB40D81, 0xB7BD5C3B, 0xC0BA6CAD, + 0xEDB88320, 0x9ABFB3B6, 0x03B6E20C, 0x74B1D29A, + 0xEAD54739, 0x9DD277AF, 0x04DB2615, 0x73DC1683, + 0xE3630B12, 0x94643B84, 0x0D6D6A3E, 0x7A6A5AA8, + 0xE40ECF0B, 0x9309FF9D, 0x0A00AE27, 0x7D079EB1, + 0xF00F9344, 0x8708A3D2, 0x1E01F268, 0x6906C2FE, + 0xF762575D, 0x806567CB, 0x196C3671, 0x6E6B06E7, + 0xFED41B76, 0x89D32BE0, 0x10DA7A5A, 0x67DD4ACC, + 0xF9B9DF6F, 0x8EBEEFF9, 0x17B7BE43, 0x60B08ED5, + 0xD6D6A3E8, 0xA1D1937E, 0x38D8C2C4, 0x4FDFF252, + 0xD1BB67F1, 0xA6BC5767, 0x3FB506DD, 0x48B2364B, + 0xD80D2BDA, 0xAF0A1B4C, 0x36034AF6, 0x41047A60, + 0xDF60EFC3, 0xA867DF55, 0x316E8EEF, 0x4669BE79, + 0xCB61B38C, 0xBC66831A, 0x256FD2A0, 0x5268E236, + 0xCC0C7795, 0xBB0B4703, 0x220216B9, 0x5505262F, + 0xC5BA3BBE, 0xB2BD0B28, 0x2BB45A92, 0x5CB36A04, + 0xC2D7FFA7, 0xB5D0CF31, 0x2CD99E8B, 0x5BDEAE1D, + 0x9B64C2B0, 0xEC63F226, 0x756AA39C, 0x026D930A, + 0x9C0906A9, 0xEB0E363F, 0x72076785, 0x05005713, + 0x95BF4A82, 0xE2B87A14, 0x7BB12BAE, 0x0CB61B38, + 0x92D28E9B, 0xE5D5BE0D, 0x7CDCEFB7, 0x0BDBDF21, + 0x86D3D2D4, 0xF1D4E242, 0x68DDB3F8, 0x1FDA836E, + 0x81BE16CD, 0xF6B9265B, 0x6FB077E1, 0x18B74777, + 0x88085AE6, 0xFF0F6A70, 0x66063BCA, 0x11010B5C, + 0x8F659EFF, 0xF862AE69, 0x616BFFD3, 0x166CCF45, + 0xA00AE278, 0xD70DD2EE, 0x4E048354, 0x3903B3C2, + 0xA7672661, 0xD06016F7, 0x4969474D, 0x3E6E77DB, + 0xAED16A4A, 0xD9D65ADC, 0x40DF0B66, 0x37D83BF0, + 0xA9BCAE53, 0xDEBB9EC5, 0x47B2CF7F, 0x30B5FFE9, + 0xBDBDF21C, 0xCABAC28A, 0x53B39330, 0x24B4A3A6, + 0xBAD03605, 0xCDD70693, 0x54DE5729, 0x23D967BF, + 0xB3667A2E, 0xC4614AB8, 0x5D681B02, 0x2A6F2B94, + 0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, 0x2D02EF8D + ); + + // For this function to yield the same output as PHP's crc32 function, $crc would have to be + // set to 0xFFFFFFFF, initially - not 0x00000000 as it currently is. + $crc = 0x00000000; + $length = strlen($data); + + for ($i=0;$i<$length;$i++) { + // We AND $crc >> 8 with 0x00FFFFFF because we want the eight newly added bits to all + // be zero. PHP, unfortunately, doesn't always do this. 0x80000000 >> 8, as an example, + // yields 0xFF800000 - not 0x00800000. The following link elaborates: + // http://www.php.net/manual/en/language.operators.bitwise.php#57281 + $crc = (($crc >> 8) & 0x00FFFFFF) ^ $crc_lookup_table[($crc & 0xFF) ^ ord($data[$i])]; + } + + // In addition to having to set $crc to 0xFFFFFFFF, initially, the return value must be XOR'd with + // 0xFFFFFFFF for this function to return the same thing that PHP's crc32 function would. + return $crc; + } + + /** + * String Shift + * + * Inspired by array_shift + * + * @param String $string + * @param optional Integer $index + * @return String + * @access private + */ + function _string_shift(&$string, $index = 1) + { + $substr = substr($string, 0, $index); + $string = substr($string, $index); + return $substr; + } + + /** + * RSA Encrypt + * + * Returns mod(pow($m, $e), $n), where $n should be the product of two (large) primes $p and $q and where $e + * should be a number with the property that gcd($e, ($p - 1) * ($q - 1)) == 1. Could just make anything that + * calls this call modexp, instead, but I think this makes things clearer, maybe... + * + * @see Net_SSH1::Net_SSH1() + * @param Math_BigInteger $m + * @param Array $key + * @return Math_BigInteger + * @access private + */ + function _rsa_crypt($m, $key) + { + /* + if (!class_exists('Crypt_RSA')) { + include_once 'Crypt/RSA.php'; + } + + $rsa = new Crypt_RSA(); + $rsa->loadKey($key, CRYPT_RSA_PUBLIC_FORMAT_RAW); + $rsa->setEncryptionMode(CRYPT_RSA_ENCRYPTION_PKCS1); + return $rsa->encrypt($m); + */ + + // To quote from protocol-1.5.txt: + // The most significant byte (which is only partial as the value must be + // less than the public modulus, which is never a power of two) is zero. + // + // The next byte contains the value 2 (which stands for public-key + // encrypted data in the PKCS standard [PKCS#1]). Then, there are non- + // zero random bytes to fill any unused space, a zero byte, and the data + // to be encrypted in the least significant bytes, the last byte of the + // data in the least significant byte. + + // Presumably the part of PKCS#1 they're refering to is "Section 7.2.1 Encryption Operation", + // under "7.2 RSAES-PKCS1-v1.5" and "7 Encryption schemes" of the following URL: + // ftp://ftp.rsasecurity.com/pub/pkcs/pkcs-1/pkcs-1v2-1.pdf + $modulus = $key[1]->toBytes(); + $length = strlen($modulus) - strlen($m) - 3; + $random = ''; + while (strlen($random) != $length) { + $block = crypt_random_string($length - strlen($random)); + $block = str_replace("\x00", '', $block); + $random.= $block; + } + $temp = chr(0) . chr(2) . $random . chr(0) . $m; + + $m = new Math_BigInteger($temp, 256); + $m = $m->modPow($key[0], $key[1]); + + return $m->toBytes(); + } + + /** + * Define Array + * + * Takes any number of arrays whose indices are integers and whose values are strings and defines a bunch of + * named constants from it, using the value as the name of the constant and the index as the value of the constant. + * If any of the constants that would be defined already exists, none of the constants will be defined. + * + * @param Array $array + * @access private + */ + function _define_array() + { + $args = func_get_args(); + foreach ($args as $arg) { + foreach ($arg as $key=>$value) { + if (!defined($value)) { + define($value, $key); + } else { + break 2; + } + } + } + } + + /** + * Returns a log of the packets that have been sent and received. + * + * Returns a string if NET_SSH1_LOGGING == NET_SSH1_LOG_COMPLEX, an array if NET_SSH1_LOGGING == NET_SSH1_LOG_SIMPLE and false if !defined('NET_SSH1_LOGGING') + * + * @access public + * @return String or Array + */ + function getLog() + { + if (!defined('NET_SSH1_LOGGING')) { + return false; + } + + switch (NET_SSH1_LOGGING) { + case NET_SSH1_LOG_SIMPLE: + return $this->message_number_log; + break; + case NET_SSH1_LOG_COMPLEX: + return $this->_format_log($this->message_log, $this->protocol_flags_log); + break; + default: + return false; + } + } + + /** + * Formats a log for printing + * + * @param Array $message_log + * @param Array $message_number_log + * @access private + * @return String + */ + function _format_log($message_log, $message_number_log) + { + $output = ''; + for ($i = 0; $i < count($message_log); $i++) { + $output.= $message_number_log[$i] . "\r\n"; + $current_log = $message_log[$i]; + $j = 0; + do { + if (strlen($current_log)) { + $output.= str_pad(dechex($j), 7, '0', STR_PAD_LEFT) . '0 '; + } + $fragment = $this->_string_shift($current_log, $this->log_short_width); + $hex = substr(preg_replace_callback('#.#s', array($this, '_format_log_helper'), $fragment), strlen($this->log_boundary)); + // replace non ASCII printable characters with dots + // http://en.wikipedia.org/wiki/ASCII#ASCII_printable_characters + // also replace < with a . since < messes up the output on web browsers + $raw = preg_replace('#[^\x20-\x7E]|<#', '.', $fragment); + $output.= str_pad($hex, $this->log_long_width - $this->log_short_width, ' ') . $raw . "\r\n"; + $j++; + } while (strlen($current_log)); + $output.= "\r\n"; + } + + return $output; + } + + /** + * Helper function for _format_log + * + * For use with preg_replace_callback() + * + * @param Array $matches + * @access private + * @return String + */ + function _format_log_helper($matches) + { + return $this->log_boundary . str_pad(dechex(ord($matches[0])), 2, '0', STR_PAD_LEFT); + } + + /** + * Return the server key public exponent + * + * Returns, by default, the base-10 representation. If $raw_output is set to true, returns, instead, + * the raw bytes. This behavior is similar to PHP's md5() function. + * + * @param optional Boolean $raw_output + * @return String + * @access public + */ + function getServerKeyPublicExponent($raw_output = false) + { + return $raw_output ? $this->server_key_public_exponent->toBytes() : $this->server_key_public_exponent->toString(); + } + + /** + * Return the server key public modulus + * + * Returns, by default, the base-10 representation. If $raw_output is set to true, returns, instead, + * the raw bytes. This behavior is similar to PHP's md5() function. + * + * @param optional Boolean $raw_output + * @return String + * @access public + */ + function getServerKeyPublicModulus($raw_output = false) + { + return $raw_output ? $this->server_key_public_modulus->toBytes() : $this->server_key_public_modulus->toString(); + } + + /** + * Return the host key public exponent + * + * Returns, by default, the base-10 representation. If $raw_output is set to true, returns, instead, + * the raw bytes. This behavior is similar to PHP's md5() function. + * + * @param optional Boolean $raw_output + * @return String + * @access public + */ + function getHostKeyPublicExponent($raw_output = false) + { + return $raw_output ? $this->host_key_public_exponent->toBytes() : $this->host_key_public_exponent->toString(); + } + + /** + * Return the host key public modulus + * + * Returns, by default, the base-10 representation. If $raw_output is set to true, returns, instead, + * the raw bytes. This behavior is similar to PHP's md5() function. + * + * @param optional Boolean $raw_output + * @return String + * @access public + */ + function getHostKeyPublicModulus($raw_output = false) + { + return $raw_output ? $this->host_key_public_modulus->toBytes() : $this->host_key_public_modulus->toString(); + } + + /** + * Return a list of ciphers supported by SSH1 server. + * + * Just because a cipher is supported by an SSH1 server doesn't mean it's supported by this library. If $raw_output + * is set to true, returns, instead, an array of constants. ie. instead of array('Triple-DES in CBC mode'), you'll + * get array(NET_SSH1_CIPHER_3DES). + * + * @param optional Boolean $raw_output + * @return Array + * @access public + */ + function getSupportedCiphers($raw_output = false) + { + return $raw_output ? array_keys($this->supported_ciphers) : array_values($this->supported_ciphers); + } + + /** + * Return a list of authentications supported by SSH1 server. + * + * Just because a cipher is supported by an SSH1 server doesn't mean it's supported by this library. If $raw_output + * is set to true, returns, instead, an array of constants. ie. instead of array('password authentication'), you'll + * get array(NET_SSH1_AUTH_PASSWORD). + * + * @param optional Boolean $raw_output + * @return Array + * @access public + */ + function getSupportedAuthentications($raw_output = false) + { + return $raw_output ? array_keys($this->supported_authentications) : array_values($this->supported_authentications); + } + + /** + * Return the server identification. + * + * @return String + * @access public + */ + function getServerIdentification() + { + return rtrim($this->server_identification); + } + + /** + * Logs data packets + * + * Makes sure that only the last 1MB worth of packets will be logged + * + * @param String $data + * @access private + */ + function _append_log($protocol_flags, $message) + { + switch (NET_SSH1_LOGGING) { + // useful for benchmarks + case NET_SSH1_LOG_SIMPLE: + $this->protocol_flags_log[] = $protocol_flags; + break; + // the most useful log for SSH1 + case NET_SSH1_LOG_COMPLEX: + $this->protocol_flags_log[] = $protocol_flags; + $this->_string_shift($message); + $this->log_size+= strlen($message); + $this->message_log[] = $message; + while ($this->log_size > NET_SSH1_LOG_MAX_SIZE) { + $this->log_size-= strlen(array_shift($this->message_log)); + array_shift($this->protocol_flags_log); + } + break; + // dump the output out realtime; packets may be interspersed with non packets, + // passwords won't be filtered out and select other packets may not be correctly + // identified + case NET_SSH1_LOG_REALTIME: + echo "
    \r\n" . $this->_format_log(array($message), array($protocol_flags)) . "\r\n
    \r\n"; + @flush(); + @ob_flush(); + break; + // basically the same thing as NET_SSH1_LOG_REALTIME with the caveat that NET_SSH1_LOG_REALTIME_FILE + // needs to be defined and that the resultant log file will be capped out at NET_SSH1_LOG_MAX_SIZE. + // the earliest part of the log file is denoted by the first <<< START >>> and is not going to necessarily + // at the beginning of the file + case NET_SSH1_LOG_REALTIME_FILE: + if (!isset($this->realtime_log_file)) { + // PHP doesn't seem to like using constants in fopen() + $filename = NET_SSH1_LOG_REALTIME_FILE; + $fp = fopen($filename, 'w'); + $this->realtime_log_file = $fp; + } + if (!is_resource($this->realtime_log_file)) { + break; + } + $entry = $this->_format_log(array($message), array($protocol_flags)); + if ($this->realtime_log_wrap) { + $temp = "<<< START >>>\r\n"; + $entry.= $temp; + fseek($this->realtime_log_file, ftell($this->realtime_log_file) - strlen($temp)); + } + $this->realtime_log_size+= strlen($entry); + if ($this->realtime_log_size > NET_SSH1_LOG_MAX_SIZE) { + fseek($this->realtime_log_file, 0); + $this->realtime_log_size = strlen($entry); + $this->realtime_log_wrap = true; + } + fputs($this->realtime_log_file, $entry); + } + } +} diff --git a/vendor/phpseclib/phpseclib/phpseclib/Net/SSH2.php b/vendor/phpseclib/phpseclib/phpseclib/Net/SSH2.php new file mode 100755 index 0000000..2fddb68 --- /dev/null +++ b/vendor/phpseclib/phpseclib/phpseclib/Net/SSH2.php @@ -0,0 +1,3686 @@ + + * login('username', 'password')) { + * exit('Login Failed'); + * } + * + * echo $ssh->exec('pwd'); + * echo $ssh->exec('ls -la'); + * ?> + * + * + * + * setPassword('whatever'); + * $key->loadKey(file_get_contents('privatekey')); + * + * $ssh = new Net_SSH2('www.domain.tld'); + * if (!$ssh->login('username', $key)) { + * exit('Login Failed'); + * } + * + * echo $ssh->read('username@username:~$'); + * $ssh->write("ls -la\n"); + * echo $ssh->read('username@username:~$'); + * ?> + * + * + * LICENSE: Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * @category Net + * @package Net_SSH2 + * @author Jim Wigginton + * @copyright MMVII Jim Wigginton + * @license http://www.opensource.org/licenses/mit-license.html MIT License + * @link http://phpseclib.sourceforge.net + */ + +/**#@+ + * Execution Bitmap Masks + * + * @see Net_SSH2::bitmap + * @access private + */ +define('NET_SSH2_MASK_CONSTRUCTOR', 0x00000001); +define('NET_SSH2_MASK_LOGIN_REQ', 0x00000002); +define('NET_SSH2_MASK_LOGIN', 0x00000004); +define('NET_SSH2_MASK_SHELL', 0x00000008); +define('NET_SSH2_MASK_WINDOW_ADJUST', 0X00000010); +/**#@-*/ + +/**#@+ + * Channel constants + * + * RFC4254 refers not to client and server channels but rather to sender and recipient channels. we don't refer + * to them in that way because RFC4254 toggles the meaning. the client sends a SSH_MSG_CHANNEL_OPEN message with + * a sender channel and the server sends a SSH_MSG_CHANNEL_OPEN_CONFIRMATION in response, with a sender and a + * recepient channel. at first glance, you might conclude that SSH_MSG_CHANNEL_OPEN_CONFIRMATION's sender channel + * would be the same thing as SSH_MSG_CHANNEL_OPEN's sender channel, but it's not, per this snipet: + * The 'recipient channel' is the channel number given in the original + * open request, and 'sender channel' is the channel number allocated by + * the other side. + * + * @see Net_SSH2::_send_channel_packet() + * @see Net_SSH2::_get_channel_packet() + * @access private + */ +define('NET_SSH2_CHANNEL_EXEC', 0); // PuTTy uses 0x100 +define('NET_SSH2_CHANNEL_SHELL', 1); +define('NET_SSH2_CHANNEL_SUBSYSTEM', 2); +/**#@-*/ + +/**#@+ + * @access public + * @see Net_SSH2::getLog() + */ +/** + * Returns the message numbers + */ +define('NET_SSH2_LOG_SIMPLE', 1); +/** + * Returns the message content + */ +define('NET_SSH2_LOG_COMPLEX', 2); +/** + * Outputs the content real-time + */ +define('NET_SSH2_LOG_REALTIME', 3); +/** + * Dumps the content real-time to a file + */ +define('NET_SSH2_LOG_REALTIME_FILE', 4); +/**#@-*/ + +/**#@+ + * @access public + * @see Net_SSH2::read() + */ +/** + * Returns when a string matching $expect exactly is found + */ +define('NET_SSH2_READ_SIMPLE', 1); +/** + * Returns when a string matching the regular expression $expect is found + */ +define('NET_SSH2_READ_REGEX', 2); +/** + * Make sure that the log never gets larger than this + */ +define('NET_SSH2_LOG_MAX_SIZE', 1024 * 1024); +/**#@-*/ + +/** + * Pure-PHP implementation of SSHv2. + * + * @package Net_SSH2 + * @author Jim Wigginton + * @version 0.1.0 + * @access public + */ +class Net_SSH2 +{ + /** + * The SSH identifier + * + * @var String + * @access private + */ + var $identifier; + + /** + * The Socket Object + * + * @var Object + * @access private + */ + var $fsock; + + /** + * Execution Bitmap + * + * The bits that are set represent functions that have been called already. This is used to determine + * if a requisite function has been successfully executed. If not, an error should be thrown. + * + * @var Integer + * @access private + */ + var $bitmap = 0; + + /** + * Error information + * + * @see Net_SSH2::getErrors() + * @see Net_SSH2::getLastError() + * @var String + * @access private + */ + var $errors = array(); + + /** + * Server Identifier + * + * @see Net_SSH2::getServerIdentification() + * @var String + * @access private + */ + var $server_identifier = ''; + + /** + * Key Exchange Algorithms + * + * @see Net_SSH2::getKexAlgorithims() + * @var Array + * @access private + */ + var $kex_algorithms; + + /** + * Server Host Key Algorithms + * + * @see Net_SSH2::getServerHostKeyAlgorithms() + * @var Array + * @access private + */ + var $server_host_key_algorithms; + + /** + * Encryption Algorithms: Client to Server + * + * @see Net_SSH2::getEncryptionAlgorithmsClient2Server() + * @var Array + * @access private + */ + var $encryption_algorithms_client_to_server; + + /** + * Encryption Algorithms: Server to Client + * + * @see Net_SSH2::getEncryptionAlgorithmsServer2Client() + * @var Array + * @access private + */ + var $encryption_algorithms_server_to_client; + + /** + * MAC Algorithms: Client to Server + * + * @see Net_SSH2::getMACAlgorithmsClient2Server() + * @var Array + * @access private + */ + var $mac_algorithms_client_to_server; + + /** + * MAC Algorithms: Server to Client + * + * @see Net_SSH2::getMACAlgorithmsServer2Client() + * @var Array + * @access private + */ + var $mac_algorithms_server_to_client; + + /** + * Compression Algorithms: Client to Server + * + * @see Net_SSH2::getCompressionAlgorithmsClient2Server() + * @var Array + * @access private + */ + var $compression_algorithms_client_to_server; + + /** + * Compression Algorithms: Server to Client + * + * @see Net_SSH2::getCompressionAlgorithmsServer2Client() + * @var Array + * @access private + */ + var $compression_algorithms_server_to_client; + + /** + * Languages: Server to Client + * + * @see Net_SSH2::getLanguagesServer2Client() + * @var Array + * @access private + */ + var $languages_server_to_client; + + /** + * Languages: Client to Server + * + * @see Net_SSH2::getLanguagesClient2Server() + * @var Array + * @access private + */ + var $languages_client_to_server; + + /** + * Block Size for Server to Client Encryption + * + * "Note that the length of the concatenation of 'packet_length', + * 'padding_length', 'payload', and 'random padding' MUST be a multiple + * of the cipher block size or 8, whichever is larger. This constraint + * MUST be enforced, even when using stream ciphers." + * + * -- http://tools.ietf.org/html/rfc4253#section-6 + * + * @see Net_SSH2::Net_SSH2() + * @see Net_SSH2::_send_binary_packet() + * @var Integer + * @access private + */ + var $encrypt_block_size = 8; + + /** + * Block Size for Client to Server Encryption + * + * @see Net_SSH2::Net_SSH2() + * @see Net_SSH2::_get_binary_packet() + * @var Integer + * @access private + */ + var $decrypt_block_size = 8; + + /** + * Server to Client Encryption Object + * + * @see Net_SSH2::_get_binary_packet() + * @var Object + * @access private + */ + var $decrypt = false; + + /** + * Client to Server Encryption Object + * + * @see Net_SSH2::_send_binary_packet() + * @var Object + * @access private + */ + var $encrypt = false; + + /** + * Client to Server HMAC Object + * + * @see Net_SSH2::_send_binary_packet() + * @var Object + * @access private + */ + var $hmac_create = false; + + /** + * Server to Client HMAC Object + * + * @see Net_SSH2::_get_binary_packet() + * @var Object + * @access private + */ + var $hmac_check = false; + + /** + * Size of server to client HMAC + * + * We need to know how big the HMAC will be for the server to client direction so that we know how many bytes to read. + * For the client to server side, the HMAC object will make the HMAC as long as it needs to be. All we need to do is + * append it. + * + * @see Net_SSH2::_get_binary_packet() + * @var Integer + * @access private + */ + var $hmac_size = false; + + /** + * Server Public Host Key + * + * @see Net_SSH2::getServerPublicHostKey() + * @var String + * @access private + */ + var $server_public_host_key; + + /** + * Session identifer + * + * "The exchange hash H from the first key exchange is additionally + * used as the session identifier, which is a unique identifier for + * this connection." + * + * -- http://tools.ietf.org/html/rfc4253#section-7.2 + * + * @see Net_SSH2::_key_exchange() + * @var String + * @access private + */ + var $session_id = false; + + /** + * Exchange hash + * + * The current exchange hash + * + * @see Net_SSH2::_key_exchange() + * @var String + * @access private + */ + var $exchange_hash = false; + + /** + * Message Numbers + * + * @see Net_SSH2::Net_SSH2() + * @var Array + * @access private + */ + var $message_numbers = array(); + + /** + * Disconnection Message 'reason codes' defined in RFC4253 + * + * @see Net_SSH2::Net_SSH2() + * @var Array + * @access private + */ + var $disconnect_reasons = array(); + + /** + * SSH_MSG_CHANNEL_OPEN_FAILURE 'reason codes', defined in RFC4254 + * + * @see Net_SSH2::Net_SSH2() + * @var Array + * @access private + */ + var $channel_open_failure_reasons = array(); + + /** + * Terminal Modes + * + * @link http://tools.ietf.org/html/rfc4254#section-8 + * @see Net_SSH2::Net_SSH2() + * @var Array + * @access private + */ + var $terminal_modes = array(); + + /** + * SSH_MSG_CHANNEL_EXTENDED_DATA's data_type_codes + * + * @link http://tools.ietf.org/html/rfc4254#section-5.2 + * @see Net_SSH2::Net_SSH2() + * @var Array + * @access private + */ + var $channel_extended_data_type_codes = array(); + + /** + * Send Sequence Number + * + * See 'Section 6.4. Data Integrity' of rfc4253 for more info. + * + * @see Net_SSH2::_send_binary_packet() + * @var Integer + * @access private + */ + var $send_seq_no = 0; + + /** + * Get Sequence Number + * + * See 'Section 6.4. Data Integrity' of rfc4253 for more info. + * + * @see Net_SSH2::_get_binary_packet() + * @var Integer + * @access private + */ + var $get_seq_no = 0; + + /** + * Server Channels + * + * Maps client channels to server channels + * + * @see Net_SSH2::_get_channel_packet() + * @see Net_SSH2::exec() + * @var Array + * @access private + */ + var $server_channels = array(); + + /** + * Channel Buffers + * + * If a client requests a packet from one channel but receives two packets from another those packets should + * be placed in a buffer + * + * @see Net_SSH2::_get_channel_packet() + * @see Net_SSH2::exec() + * @var Array + * @access private + */ + var $channel_buffers = array(); + + /** + * Channel Status + * + * Contains the type of the last sent message + * + * @see Net_SSH2::_get_channel_packet() + * @var Array + * @access private + */ + var $channel_status = array(); + + /** + * Packet Size + * + * Maximum packet size indexed by channel + * + * @see Net_SSH2::_send_channel_packet() + * @var Array + * @access private + */ + var $packet_size_client_to_server = array(); + + /** + * Message Number Log + * + * @see Net_SSH2::getLog() + * @var Array + * @access private + */ + var $message_number_log = array(); + + /** + * Message Log + * + * @see Net_SSH2::getLog() + * @var Array + * @access private + */ + var $message_log = array(); + + /** + * The Window Size + * + * Bytes the other party can send before it must wait for the window to be adjusted (0x7FFFFFFF = 2GB) + * + * @var Integer + * @see Net_SSH2::_send_channel_packet() + * @see Net_SSH2::exec() + * @access private + */ + var $window_size = 0x7FFFFFFF; + + /** + * Window size, server to client + * + * Window size indexed by channel + * + * @see Net_SSH2::_send_channel_packet() + * @var Array + * @access private + */ + var $window_size_server_to_client = array(); + + /** + * Window size, client to server + * + * Window size indexed by channel + * + * @see Net_SSH2::_get_channel_packet() + * @var Array + * @access private + */ + var $window_size_client_to_server = array(); + + /** + * Server signature + * + * Verified against $this->session_id + * + * @see Net_SSH2::getServerPublicHostKey() + * @var String + * @access private + */ + var $signature = ''; + + /** + * Server signature format + * + * ssh-rsa or ssh-dss. + * + * @see Net_SSH2::getServerPublicHostKey() + * @var String + * @access private + */ + var $signature_format = ''; + + /** + * Interactive Buffer + * + * @see Net_SSH2::read() + * @var Array + * @access private + */ + var $interactiveBuffer = ''; + + /** + * Current log size + * + * Should never exceed NET_SSH2_LOG_MAX_SIZE + * + * @see Net_SSH2::_send_binary_packet() + * @see Net_SSH2::_get_binary_packet() + * @var Integer + * @access private + */ + var $log_size; + + /** + * Timeout + * + * @see Net_SSH2::setTimeout() + * @access private + */ + var $timeout; + + /** + * Current Timeout + * + * @see Net_SSH2::_get_channel_packet() + * @access private + */ + var $curTimeout; + + /** + * Real-time log file pointer + * + * @see Net_SSH2::_append_log() + * @var Resource + * @access private + */ + var $realtime_log_file; + + /** + * Real-time log file size + * + * @see Net_SSH2::_append_log() + * @var Integer + * @access private + */ + var $realtime_log_size; + + /** + * Has the signature been validated? + * + * @see Net_SSH2::getServerPublicHostKey() + * @var Boolean + * @access private + */ + var $signature_validated = false; + + /** + * Real-time log file wrap boolean + * + * @see Net_SSH2::_append_log() + * @access private + */ + var $realtime_log_wrap; + + /** + * Flag to suppress stderr from output + * + * @see Net_SSH2::enableQuietMode() + * @access private + */ + var $quiet_mode = false; + + /** + * Time of first network activity + * + * @access private + */ + var $last_packet; + + /** + * Exit status returned from ssh if any + * + * @var Integer + * @access private + */ + var $exit_status; + + /** + * Flag to request a PTY when using exec() + * + * @see Net_SSH2::enablePTY() + * @access private + */ + var $request_pty = false; + + /** + * Flag set while exec() is running when using enablePTY() + * + * @access private + */ + var $in_request_pty_exec = false; + + /** + * Flag set after startSubsystem() is called + * + * @access private + */ + var $in_subsystem; + + /** + * Contents of stdError + * + * @access private + */ + var $stdErrorLog; + + /** + * The Last Interactive Response + * + * @see Net_SSH2::_keyboard_interactive_process() + * @access private + */ + var $last_interactive_response = ''; + + /** + * Keyboard Interactive Request / Responses + * + * @see Net_SSH2::_keyboard_interactive_process() + * @access private + */ + var $keyboard_requests_responses = array(); + + /** + * Banner Message + * + * Quoting from the RFC, "in some jurisdictions, sending a warning message before + * authentication may be relevant for getting legal protection." + * + * @see Net_SSH2::_filter() + * @see Net_SSH2::getBannerMessage() + * @access private + */ + var $banner_message = ''; + + /** + * Did read() timeout or return normally? + * + * @see Net_SSH2::isTimeout + * @access private + */ + var $is_timeout = false; + + /** + * Log Boundary + * + * @see Net_SSH2::_format_log + * @access private + */ + var $log_boundary = ':'; + + /** + * Log Long Width + * + * @see Net_SSH2::_format_log + * @access private + */ + var $log_long_width = 65; + + /** + * Log Short Width + * + * @see Net_SSH2::_format_log + * @access private + */ + var $log_short_width = 16; + + /** + * Default Constructor. + * + * Connects to an SSHv2 server + * + * @param String $host + * @param optional Integer $port + * @param optional Integer $timeout + * @return Net_SSH2 + * @access public + */ + function Net_SSH2($host, $port = 22, $timeout = 10) + { + // Include Math_BigInteger + // Used to do Diffie-Hellman key exchange and DSA/RSA signature verification. + if (!class_exists('Math_BigInteger')) { + include_once 'Math/BigInteger.php'; + } + + if (!function_exists('crypt_random_string')) { + include_once 'Crypt/Random.php'; + } + + if (!class_exists('Crypt_Hash')) { + include_once 'Crypt/Hash.php'; + } + + $this->last_packet = strtok(microtime(), ' ') + strtok(''); // == microtime(true) in PHP5 + $this->message_numbers = array( + 1 => 'NET_SSH2_MSG_DISCONNECT', + 2 => 'NET_SSH2_MSG_IGNORE', + 3 => 'NET_SSH2_MSG_UNIMPLEMENTED', + 4 => 'NET_SSH2_MSG_DEBUG', + 5 => 'NET_SSH2_MSG_SERVICE_REQUEST', + 6 => 'NET_SSH2_MSG_SERVICE_ACCEPT', + 20 => 'NET_SSH2_MSG_KEXINIT', + 21 => 'NET_SSH2_MSG_NEWKEYS', + 30 => 'NET_SSH2_MSG_KEXDH_INIT', + 31 => 'NET_SSH2_MSG_KEXDH_REPLY', + 50 => 'NET_SSH2_MSG_USERAUTH_REQUEST', + 51 => 'NET_SSH2_MSG_USERAUTH_FAILURE', + 52 => 'NET_SSH2_MSG_USERAUTH_SUCCESS', + 53 => 'NET_SSH2_MSG_USERAUTH_BANNER', + + 80 => 'NET_SSH2_MSG_GLOBAL_REQUEST', + 81 => 'NET_SSH2_MSG_REQUEST_SUCCESS', + 82 => 'NET_SSH2_MSG_REQUEST_FAILURE', + 90 => 'NET_SSH2_MSG_CHANNEL_OPEN', + 91 => 'NET_SSH2_MSG_CHANNEL_OPEN_CONFIRMATION', + 92 => 'NET_SSH2_MSG_CHANNEL_OPEN_FAILURE', + 93 => 'NET_SSH2_MSG_CHANNEL_WINDOW_ADJUST', + 94 => 'NET_SSH2_MSG_CHANNEL_DATA', + 95 => 'NET_SSH2_MSG_CHANNEL_EXTENDED_DATA', + 96 => 'NET_SSH2_MSG_CHANNEL_EOF', + 97 => 'NET_SSH2_MSG_CHANNEL_CLOSE', + 98 => 'NET_SSH2_MSG_CHANNEL_REQUEST', + 99 => 'NET_SSH2_MSG_CHANNEL_SUCCESS', + 100 => 'NET_SSH2_MSG_CHANNEL_FAILURE' + ); + $this->disconnect_reasons = array( + 1 => 'NET_SSH2_DISCONNECT_HOST_NOT_ALLOWED_TO_CONNECT', + 2 => 'NET_SSH2_DISCONNECT_PROTOCOL_ERROR', + 3 => 'NET_SSH2_DISCONNECT_KEY_EXCHANGE_FAILED', + 4 => 'NET_SSH2_DISCONNECT_RESERVED', + 5 => 'NET_SSH2_DISCONNECT_MAC_ERROR', + 6 => 'NET_SSH2_DISCONNECT_COMPRESSION_ERROR', + 7 => 'NET_SSH2_DISCONNECT_SERVICE_NOT_AVAILABLE', + 8 => 'NET_SSH2_DISCONNECT_PROTOCOL_VERSION_NOT_SUPPORTED', + 9 => 'NET_SSH2_DISCONNECT_HOST_KEY_NOT_VERIFIABLE', + 10 => 'NET_SSH2_DISCONNECT_CONNECTION_LOST', + 11 => 'NET_SSH2_DISCONNECT_BY_APPLICATION', + 12 => 'NET_SSH2_DISCONNECT_TOO_MANY_CONNECTIONS', + 13 => 'NET_SSH2_DISCONNECT_AUTH_CANCELLED_BY_USER', + 14 => 'NET_SSH2_DISCONNECT_NO_MORE_AUTH_METHODS_AVAILABLE', + 15 => 'NET_SSH2_DISCONNECT_ILLEGAL_USER_NAME' + ); + $this->channel_open_failure_reasons = array( + 1 => 'NET_SSH2_OPEN_ADMINISTRATIVELY_PROHIBITED' + ); + $this->terminal_modes = array( + 0 => 'NET_SSH2_TTY_OP_END' + ); + $this->channel_extended_data_type_codes = array( + 1 => 'NET_SSH2_EXTENDED_DATA_STDERR' + ); + + $this->_define_array( + $this->message_numbers, + $this->disconnect_reasons, + $this->channel_open_failure_reasons, + $this->terminal_modes, + $this->channel_extended_data_type_codes, + array(60 => 'NET_SSH2_MSG_USERAUTH_PASSWD_CHANGEREQ'), + array(60 => 'NET_SSH2_MSG_USERAUTH_PK_OK'), + array(60 => 'NET_SSH2_MSG_USERAUTH_INFO_REQUEST', + 61 => 'NET_SSH2_MSG_USERAUTH_INFO_RESPONSE') + ); + + $start = strtok(microtime(), ' ') + strtok(''); // http://php.net/microtime#61838 + $this->fsock = @fsockopen($host, $port, $errno, $errstr, $timeout); + if (!$this->fsock) { + user_error(rtrim("Cannot connect to $host. Error $errno. $errstr")); + return; + } + $elapsed = strtok(microtime(), ' ') + strtok('') - $start; + + $timeout-= $elapsed; + + if ($timeout <= 0) { + user_error(rtrim("Cannot connect to $host. Timeout error")); + return; + } + + $read = array($this->fsock); + $write = $except = null; + + $sec = floor($timeout); + $usec = 1000000 * ($timeout - $sec); + + // on windows this returns a "Warning: Invalid CRT parameters detected" error + // the !count() is done as a workaround for + if (!@stream_select($read, $write, $except, $sec, $usec) && !count($read)) { + user_error(rtrim("Cannot connect to $host. Banner timeout")); + return; + } + + /* According to the SSH2 specs, + + "The server MAY send other lines of data before sending the version + string. Each line SHOULD be terminated by a Carriage Return and Line + Feed. Such lines MUST NOT begin with "SSH-", and SHOULD be encoded + in ISO-10646 UTF-8 [RFC3629] (language is not specified). Clients + MUST be able to process such lines." */ + $temp = ''; + $extra = ''; + while (!feof($this->fsock) && !preg_match('#^SSH-(\d\.\d+)#', $temp, $matches)) { + if (substr($temp, -2) == "\r\n") { + $extra.= $temp; + $temp = ''; + } + $temp.= fgets($this->fsock, 255); + } + + if (feof($this->fsock)) { + user_error('Connection closed by server'); + return false; + } + + $this->identifier = $this->_generate_identifier(); + + if (defined('NET_SSH2_LOGGING')) { + $this->_append_log('<-', $extra . $temp); + $this->_append_log('->', $this->identifier . "\r\n"); + } + + $this->server_identifier = trim($temp, "\r\n"); + if (strlen($extra)) { + $this->errors[] = utf8_decode($extra); + } + + if ($matches[1] != '1.99' && $matches[1] != '2.0') { + user_error("Cannot connect to SSH $matches[1] servers"); + return; + } + + fputs($this->fsock, $this->identifier . "\r\n"); + + $response = $this->_get_binary_packet(); + if ($response === false) { + user_error('Connection closed by server'); + return; + } + + if (ord($response[0]) != NET_SSH2_MSG_KEXINIT) { + user_error('Expected SSH_MSG_KEXINIT'); + return; + } + + if (!$this->_key_exchange($response)) { + return; + } + + $this->bitmap = NET_SSH2_MASK_CONSTRUCTOR; + } + + /** + * Generates the SSH identifier + * + * You should overwrite this method in your own class if you want to use another identifier + * + * @access protected + * @return String + */ + function _generate_identifier() + { + $identifier = 'SSH-2.0-phpseclib_0.3'; + + $ext = array(); + if (extension_loaded('mcrypt')) { + $ext[] = 'mcrypt'; + } + + if (extension_loaded('gmp')) { + $ext[] = 'gmp'; + } elseif (extension_loaded('bcmath')) { + $ext[] = 'bcmath'; + } + + if (!empty($ext)) { + $identifier .= ' (' . implode(', ', $ext) . ')'; + } + + return $identifier; + } + + /** + * Key Exchange + * + * @param String $kexinit_payload_server + * @access private + */ + function _key_exchange($kexinit_payload_server) + { + static $kex_algorithms = array( + 'diffie-hellman-group1-sha1', // REQUIRED + 'diffie-hellman-group14-sha1' // REQUIRED + ); + + static $server_host_key_algorithms = array( + 'ssh-rsa', // RECOMMENDED sign Raw RSA Key + 'ssh-dss' // REQUIRED sign Raw DSS Key + ); + + static $encryption_algorithms = false; + if ($encryption_algorithms === false) { + $encryption_algorithms = array( + // from : + 'arcfour256', + 'arcfour128', + + 'arcfour', // OPTIONAL the ARCFOUR stream cipher with a 128-bit key + + // CTR modes from : + 'aes128-ctr', // RECOMMENDED AES (Rijndael) in SDCTR mode, with 128-bit key + 'aes192-ctr', // RECOMMENDED AES with 192-bit key + 'aes256-ctr', // RECOMMENDED AES with 256-bit key + + 'twofish128-ctr', // OPTIONAL Twofish in SDCTR mode, with 128-bit key + 'twofish192-ctr', // OPTIONAL Twofish with 192-bit key + 'twofish256-ctr', // OPTIONAL Twofish with 256-bit key + + 'aes128-cbc', // RECOMMENDED AES with a 128-bit key + 'aes192-cbc', // OPTIONAL AES with a 192-bit key + 'aes256-cbc', // OPTIONAL AES in CBC mode, with a 256-bit key + + 'twofish128-cbc', // OPTIONAL Twofish with a 128-bit key + 'twofish192-cbc', // OPTIONAL Twofish with a 192-bit key + 'twofish256-cbc', + 'twofish-cbc', // OPTIONAL alias for "twofish256-cbc" + // (this is being retained for historical reasons) + + 'blowfish-ctr', // OPTIONAL Blowfish in SDCTR mode + + 'blowfish-cbc', // OPTIONAL Blowfish in CBC mode + + '3des-ctr', // RECOMMENDED Three-key 3DES in SDCTR mode + + '3des-cbc', // REQUIRED three-key 3DES in CBC mode + 'none' // OPTIONAL no encryption; NOT RECOMMENDED + ); + + if (!$this->_is_includable('Crypt/RC4.php')) { + $encryption_algorithms = array_diff( + $encryption_algorithms, + array('arcfour256', 'arcfour128', 'arcfour') + ); + } + if (!$this->_is_includable('Crypt/Rijndael.php')) { + $encryption_algorithms = array_diff( + $encryption_algorithms, + array('aes128-ctr', 'aes192-ctr', 'aes256-ctr', 'aes128-cbc', 'aes192-cbc', 'aes256-cbc') + ); + } + if (!$this->_is_includable('Crypt/Twofish.php')) { + $encryption_algorithms = array_diff( + $encryption_algorithms, + array('twofish128-ctr', 'twofish192-ctr', 'twofish256-ctr', 'twofish128-cbc', 'twofish192-cbc', 'twofish256-cbc', 'twofish-cbc') + ); + } + if (!$this->_is_includable('Crypt/Blowfish.php')) { + $encryption_algorithms = array_diff( + $encryption_algorithms, + array('blowfish-ctr', 'blowfish-cbc') + ); + } + if (!$this->_is_includable('Crypt/TripleDES.php')) { + $encryption_algorithms = array_diff( + $encryption_algorithms, + array('3des-ctr', '3des-cbc') + ); + } + $encryption_algorithms = array_values($encryption_algorithms); + } + + static $mac_algorithms = array( + 'hmac-sha1-96', // RECOMMENDED first 96 bits of HMAC-SHA1 (digest length = 12, key length = 20) + 'hmac-sha1', // REQUIRED HMAC-SHA1 (digest length = key length = 20) + 'hmac-md5-96', // OPTIONAL first 96 bits of HMAC-MD5 (digest length = 12, key length = 16) + 'hmac-md5', // OPTIONAL HMAC-MD5 (digest length = key length = 16) + 'none' // OPTIONAL no MAC; NOT RECOMMENDED + ); + + static $compression_algorithms = array( + 'none' // REQUIRED no compression + //'zlib' // OPTIONAL ZLIB (LZ77) compression + ); + + // some SSH servers have buggy implementations of some of the above algorithms + switch ($this->server_identifier) { + case 'SSH-2.0-SSHD': + $mac_algorithms = array_values(array_diff( + $mac_algorithms, + array('hmac-sha1-96', 'hmac-md5-96') + )); + } + + static $str_kex_algorithms, $str_server_host_key_algorithms, + $encryption_algorithms_server_to_client, $mac_algorithms_server_to_client, $compression_algorithms_server_to_client, + $encryption_algorithms_client_to_server, $mac_algorithms_client_to_server, $compression_algorithms_client_to_server; + + if (empty($str_kex_algorithms)) { + $str_kex_algorithms = implode(',', $kex_algorithms); + $str_server_host_key_algorithms = implode(',', $server_host_key_algorithms); + $encryption_algorithms_server_to_client = $encryption_algorithms_client_to_server = implode(',', $encryption_algorithms); + $mac_algorithms_server_to_client = $mac_algorithms_client_to_server = implode(',', $mac_algorithms); + $compression_algorithms_server_to_client = $compression_algorithms_client_to_server = implode(',', $compression_algorithms); + } + + $client_cookie = crypt_random_string(16); + + $response = $kexinit_payload_server; + $this->_string_shift($response, 1); // skip past the message number (it should be SSH_MSG_KEXINIT) + $server_cookie = $this->_string_shift($response, 16); + + $temp = unpack('Nlength', $this->_string_shift($response, 4)); + $this->kex_algorithms = explode(',', $this->_string_shift($response, $temp['length'])); + + $temp = unpack('Nlength', $this->_string_shift($response, 4)); + $this->server_host_key_algorithms = explode(',', $this->_string_shift($response, $temp['length'])); + + $temp = unpack('Nlength', $this->_string_shift($response, 4)); + $this->encryption_algorithms_client_to_server = explode(',', $this->_string_shift($response, $temp['length'])); + + $temp = unpack('Nlength', $this->_string_shift($response, 4)); + $this->encryption_algorithms_server_to_client = explode(',', $this->_string_shift($response, $temp['length'])); + + $temp = unpack('Nlength', $this->_string_shift($response, 4)); + $this->mac_algorithms_client_to_server = explode(',', $this->_string_shift($response, $temp['length'])); + + $temp = unpack('Nlength', $this->_string_shift($response, 4)); + $this->mac_algorithms_server_to_client = explode(',', $this->_string_shift($response, $temp['length'])); + + $temp = unpack('Nlength', $this->_string_shift($response, 4)); + $this->compression_algorithms_client_to_server = explode(',', $this->_string_shift($response, $temp['length'])); + + $temp = unpack('Nlength', $this->_string_shift($response, 4)); + $this->compression_algorithms_server_to_client = explode(',', $this->_string_shift($response, $temp['length'])); + + $temp = unpack('Nlength', $this->_string_shift($response, 4)); + $this->languages_client_to_server = explode(',', $this->_string_shift($response, $temp['length'])); + + $temp = unpack('Nlength', $this->_string_shift($response, 4)); + $this->languages_server_to_client = explode(',', $this->_string_shift($response, $temp['length'])); + + extract(unpack('Cfirst_kex_packet_follows', $this->_string_shift($response, 1))); + $first_kex_packet_follows = $first_kex_packet_follows != 0; + + // the sending of SSH2_MSG_KEXINIT could go in one of two places. this is the second place. + $kexinit_payload_client = pack('Ca*Na*Na*Na*Na*Na*Na*Na*Na*Na*Na*CN', + NET_SSH2_MSG_KEXINIT, $client_cookie, strlen($str_kex_algorithms), $str_kex_algorithms, + strlen($str_server_host_key_algorithms), $str_server_host_key_algorithms, strlen($encryption_algorithms_client_to_server), + $encryption_algorithms_client_to_server, strlen($encryption_algorithms_server_to_client), $encryption_algorithms_server_to_client, + strlen($mac_algorithms_client_to_server), $mac_algorithms_client_to_server, strlen($mac_algorithms_server_to_client), + $mac_algorithms_server_to_client, strlen($compression_algorithms_client_to_server), $compression_algorithms_client_to_server, + strlen($compression_algorithms_server_to_client), $compression_algorithms_server_to_client, 0, '', 0, '', + 0, 0 + ); + + if (!$this->_send_binary_packet($kexinit_payload_client)) { + return false; + } + // here ends the second place. + + // we need to decide upon the symmetric encryption algorithms before we do the diffie-hellman key exchange + for ($i = 0; $i < count($encryption_algorithms) && !in_array($encryption_algorithms[$i], $this->encryption_algorithms_server_to_client); $i++); + if ($i == count($encryption_algorithms)) { + user_error('No compatible server to client encryption algorithms found'); + return $this->_disconnect(NET_SSH2_DISCONNECT_KEY_EXCHANGE_FAILED); + } + + // we don't initialize any crypto-objects, yet - we do that, later. for now, we need the lengths to make the + // diffie-hellman key exchange as fast as possible + $decrypt = $encryption_algorithms[$i]; + switch ($decrypt) { + case '3des-cbc': + case '3des-ctr': + $decryptKeyLength = 24; // eg. 192 / 8 + break; + case 'aes256-cbc': + case 'aes256-ctr': + case 'twofish-cbc': + case 'twofish256-cbc': + case 'twofish256-ctr': + $decryptKeyLength = 32; // eg. 256 / 8 + break; + case 'aes192-cbc': + case 'aes192-ctr': + case 'twofish192-cbc': + case 'twofish192-ctr': + $decryptKeyLength = 24; // eg. 192 / 8 + break; + case 'aes128-cbc': + case 'aes128-ctr': + case 'twofish128-cbc': + case 'twofish128-ctr': + case 'blowfish-cbc': + case 'blowfish-ctr': + $decryptKeyLength = 16; // eg. 128 / 8 + break; + case 'arcfour': + case 'arcfour128': + $decryptKeyLength = 16; // eg. 128 / 8 + break; + case 'arcfour256': + $decryptKeyLength = 32; // eg. 128 / 8 + break; + case 'none'; + $decryptKeyLength = 0; + } + + for ($i = 0; $i < count($encryption_algorithms) && !in_array($encryption_algorithms[$i], $this->encryption_algorithms_client_to_server); $i++); + if ($i == count($encryption_algorithms)) { + user_error('No compatible client to server encryption algorithms found'); + return $this->_disconnect(NET_SSH2_DISCONNECT_KEY_EXCHANGE_FAILED); + } + + $encrypt = $encryption_algorithms[$i]; + switch ($encrypt) { + case '3des-cbc': + case '3des-ctr': + $encryptKeyLength = 24; + break; + case 'aes256-cbc': + case 'aes256-ctr': + case 'twofish-cbc': + case 'twofish256-cbc': + case 'twofish256-ctr': + $encryptKeyLength = 32; + break; + case 'aes192-cbc': + case 'aes192-ctr': + case 'twofish192-cbc': + case 'twofish192-ctr': + $encryptKeyLength = 24; + break; + case 'aes128-cbc': + case 'aes128-ctr': + case 'twofish128-cbc': + case 'twofish128-ctr': + case 'blowfish-cbc': + case 'blowfish-ctr': + $encryptKeyLength = 16; + break; + case 'arcfour': + case 'arcfour128': + $encryptKeyLength = 16; + break; + case 'arcfour256': + $encryptKeyLength = 32; + break; + case 'none'; + $encryptKeyLength = 0; + } + + $keyLength = $decryptKeyLength > $encryptKeyLength ? $decryptKeyLength : $encryptKeyLength; + + // through diffie-hellman key exchange a symmetric key is obtained + for ($i = 0; $i < count($kex_algorithms) && !in_array($kex_algorithms[$i], $this->kex_algorithms); $i++); + if ($i == count($kex_algorithms)) { + user_error('No compatible key exchange algorithms found'); + return $this->_disconnect(NET_SSH2_DISCONNECT_KEY_EXCHANGE_FAILED); + } + + switch ($kex_algorithms[$i]) { + // see http://tools.ietf.org/html/rfc2409#section-6.2 and + // http://tools.ietf.org/html/rfc2412, appendex E + case 'diffie-hellman-group1-sha1': + $prime = 'FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E088A67CC74' . + '020BBEA63B139B22514A08798E3404DDEF9519B3CD3A431B302B0A6DF25F1437' . + '4FE1356D6D51C245E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7ED' . + 'EE386BFB5A899FA5AE9F24117C4B1FE649286651ECE65381FFFFFFFFFFFFFFFF'; + break; + // see http://tools.ietf.org/html/rfc3526#section-3 + case 'diffie-hellman-group14-sha1': + $prime = 'FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E088A67CC74' . + '020BBEA63B139B22514A08798E3404DDEF9519B3CD3A431B302B0A6DF25F1437' . + '4FE1356D6D51C245E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7ED' . + 'EE386BFB5A899FA5AE9F24117C4B1FE649286651ECE45B3DC2007CB8A163BF05' . + '98DA48361C55D39A69163FA8FD24CF5F83655D23DCA3AD961C62F356208552BB' . + '9ED529077096966D670C354E4ABC9804F1746C08CA18217C32905E462E36CE3B' . + 'E39E772C180E86039B2783A2EC07A28FB5C55DF06F4C52C9DE2BCBF695581718' . + '3995497CEA956AE515D2261898FA051015728E5A8AACAA68FFFFFFFFFFFFFFFF'; + break; + } + + // For both diffie-hellman-group1-sha1 and diffie-hellman-group14-sha1 + // the generator field element is 2 (decimal) and the hash function is sha1. + $g = new Math_BigInteger(2); + $prime = new Math_BigInteger($prime, 16); + $kexHash = new Crypt_Hash('sha1'); + //$q = $p->bitwise_rightShift(1); + + /* To increase the speed of the key exchange, both client and server may + reduce the size of their private exponents. It should be at least + twice as long as the key material that is generated from the shared + secret. For more details, see the paper by van Oorschot and Wiener + [VAN-OORSCHOT]. + + -- http://tools.ietf.org/html/rfc4419#section-6.2 */ + $one = new Math_BigInteger(1); + $keyLength = min($keyLength, $kexHash->getLength()); + $max = $one->bitwise_leftShift(16 * $keyLength); // 2 * 8 * $keyLength + $max = $max->subtract($one); + + $x = $one->random($one, $max); + $e = $g->modPow($x, $prime); + + $eBytes = $e->toBytes(true); + $data = pack('CNa*', NET_SSH2_MSG_KEXDH_INIT, strlen($eBytes), $eBytes); + + if (!$this->_send_binary_packet($data)) { + user_error('Connection closed by server'); + return false; + } + + $response = $this->_get_binary_packet(); + if ($response === false) { + user_error('Connection closed by server'); + return false; + } + extract(unpack('Ctype', $this->_string_shift($response, 1))); + + if ($type != NET_SSH2_MSG_KEXDH_REPLY) { + user_error('Expected SSH_MSG_KEXDH_REPLY'); + return false; + } + + $temp = unpack('Nlength', $this->_string_shift($response, 4)); + $this->server_public_host_key = $server_public_host_key = $this->_string_shift($response, $temp['length']); + + $temp = unpack('Nlength', $this->_string_shift($server_public_host_key, 4)); + $public_key_format = $this->_string_shift($server_public_host_key, $temp['length']); + + $temp = unpack('Nlength', $this->_string_shift($response, 4)); + $fBytes = $this->_string_shift($response, $temp['length']); + $f = new Math_BigInteger($fBytes, -256); + + $temp = unpack('Nlength', $this->_string_shift($response, 4)); + $this->signature = $this->_string_shift($response, $temp['length']); + + $temp = unpack('Nlength', $this->_string_shift($this->signature, 4)); + $this->signature_format = $this->_string_shift($this->signature, $temp['length']); + + $key = $f->modPow($x, $prime); + $keyBytes = $key->toBytes(true); + + $this->exchange_hash = pack('Na*Na*Na*Na*Na*Na*Na*Na*', + strlen($this->identifier), $this->identifier, strlen($this->server_identifier), $this->server_identifier, + strlen($kexinit_payload_client), $kexinit_payload_client, strlen($kexinit_payload_server), + $kexinit_payload_server, strlen($this->server_public_host_key), $this->server_public_host_key, strlen($eBytes), + $eBytes, strlen($fBytes), $fBytes, strlen($keyBytes), $keyBytes + ); + + $this->exchange_hash = $kexHash->hash($this->exchange_hash); + + if ($this->session_id === false) { + $this->session_id = $this->exchange_hash; + } + + for ($i = 0; $i < count($server_host_key_algorithms) && !in_array($server_host_key_algorithms[$i], $this->server_host_key_algorithms); $i++); + if ($i == count($server_host_key_algorithms)) { + user_error('No compatible server host key algorithms found'); + return $this->_disconnect(NET_SSH2_DISCONNECT_KEY_EXCHANGE_FAILED); + } + + if ($public_key_format != $server_host_key_algorithms[$i] || $this->signature_format != $server_host_key_algorithms[$i]) { + user_error('Server Host Key Algorithm Mismatch'); + return $this->_disconnect(NET_SSH2_DISCONNECT_KEY_EXCHANGE_FAILED); + } + + $packet = pack('C', + NET_SSH2_MSG_NEWKEYS + ); + + if (!$this->_send_binary_packet($packet)) { + return false; + } + + $response = $this->_get_binary_packet(); + + if ($response === false) { + user_error('Connection closed by server'); + return false; + } + + extract(unpack('Ctype', $this->_string_shift($response, 1))); + + if ($type != NET_SSH2_MSG_NEWKEYS) { + user_error('Expected SSH_MSG_NEWKEYS'); + return false; + } + + switch ($encrypt) { + case '3des-cbc': + if (!class_exists('Crypt_TripleDES')) { + include_once 'Crypt/TripleDES.php'; + } + $this->encrypt = new Crypt_TripleDES(); + // $this->encrypt_block_size = 64 / 8 == the default + break; + case '3des-ctr': + if (!class_exists('Crypt_TripleDES')) { + include_once 'Crypt/TripleDES.php'; + } + $this->encrypt = new Crypt_TripleDES(CRYPT_DES_MODE_CTR); + // $this->encrypt_block_size = 64 / 8 == the default + break; + case 'aes256-cbc': + case 'aes192-cbc': + case 'aes128-cbc': + if (!class_exists('Crypt_Rijndael')) { + include_once 'Crypt/Rijndael.php'; + } + $this->encrypt = new Crypt_Rijndael(); + $this->encrypt_block_size = 16; // eg. 128 / 8 + break; + case 'aes256-ctr': + case 'aes192-ctr': + case 'aes128-ctr': + if (!class_exists('Crypt_Rijndael')) { + include_once 'Crypt/Rijndael.php'; + } + $this->encrypt = new Crypt_Rijndael(CRYPT_RIJNDAEL_MODE_CTR); + $this->encrypt_block_size = 16; // eg. 128 / 8 + break; + case 'blowfish-cbc': + if (!class_exists('Crypt_Blowfish')) { + include_once 'Crypt/Blowfish.php'; + } + $this->encrypt = new Crypt_Blowfish(); + $this->encrypt_block_size = 8; + break; + case 'blowfish-ctr': + if (!class_exists('Crypt_Blowfish')) { + include_once 'Crypt/Blowfish.php'; + } + $this->encrypt = new Crypt_Blowfish(CRYPT_BLOWFISH_MODE_CTR); + $this->encrypt_block_size = 8; + break; + case 'twofish128-cbc': + case 'twofish192-cbc': + case 'twofish256-cbc': + case 'twofish-cbc': + if (!class_exists('Crypt_Twofish')) { + include_once 'Crypt/Twofish.php'; + } + $this->encrypt = new Crypt_Twofish(); + $this->encrypt_block_size = 16; + break; + case 'twofish128-ctr': + case 'twofish192-ctr': + case 'twofish256-ctr': + if (!class_exists('Crypt_Twofish')) { + include_once 'Crypt/Twofish.php'; + } + $this->encrypt = new Crypt_Twofish(CRYPT_TWOFISH_MODE_CTR); + $this->encrypt_block_size = 16; + break; + case 'arcfour': + case 'arcfour128': + case 'arcfour256': + if (!class_exists('Crypt_RC4')) { + include_once 'Crypt/RC4.php'; + } + $this->encrypt = new Crypt_RC4(); + break; + case 'none'; + //$this->encrypt = new Crypt_Null(); + } + + switch ($decrypt) { + case '3des-cbc': + if (!class_exists('Crypt_TripleDES')) { + include_once 'Crypt/TripleDES.php'; + } + $this->decrypt = new Crypt_TripleDES(); + break; + case '3des-ctr': + if (!class_exists('Crypt_TripleDES')) { + include_once 'Crypt/TripleDES.php'; + } + $this->decrypt = new Crypt_TripleDES(CRYPT_DES_MODE_CTR); + break; + case 'aes256-cbc': + case 'aes192-cbc': + case 'aes128-cbc': + if (!class_exists('Crypt_Rijndael')) { + include_once 'Crypt/Rijndael.php'; + } + $this->decrypt = new Crypt_Rijndael(); + $this->decrypt_block_size = 16; + break; + case 'aes256-ctr': + case 'aes192-ctr': + case 'aes128-ctr': + if (!class_exists('Crypt_Rijndael')) { + include_once 'Crypt/Rijndael.php'; + } + $this->decrypt = new Crypt_Rijndael(CRYPT_RIJNDAEL_MODE_CTR); + $this->decrypt_block_size = 16; + break; + case 'blowfish-cbc': + if (!class_exists('Crypt_Blowfish')) { + include_once 'Crypt/Blowfish.php'; + } + $this->decrypt = new Crypt_Blowfish(); + $this->decrypt_block_size = 8; + break; + case 'blowfish-ctr': + if (!class_exists('Crypt_Blowfish')) { + include_once 'Crypt/Blowfish.php'; + } + $this->decrypt = new Crypt_Blowfish(CRYPT_BLOWFISH_MODE_CTR); + $this->decrypt_block_size = 8; + break; + case 'twofish128-cbc': + case 'twofish192-cbc': + case 'twofish256-cbc': + case 'twofish-cbc': + if (!class_exists('Crypt_Twofish')) { + include_once 'Crypt/Twofish.php'; + } + $this->decrypt = new Crypt_Twofish(); + $this->decrypt_block_size = 16; + break; + case 'twofish128-ctr': + case 'twofish192-ctr': + case 'twofish256-ctr': + if (!class_exists('Crypt_Twofish')) { + include_once 'Crypt/Twofish.php'; + } + $this->decrypt = new Crypt_Twofish(CRYPT_TWOFISH_MODE_CTR); + $this->decrypt_block_size = 16; + break; + case 'arcfour': + case 'arcfour128': + case 'arcfour256': + if (!class_exists('Crypt_RC4')) { + include_once 'Crypt/RC4.php'; + } + $this->decrypt = new Crypt_RC4(); + break; + case 'none'; + //$this->decrypt = new Crypt_Null(); + } + + $keyBytes = pack('Na*', strlen($keyBytes), $keyBytes); + + if ($this->encrypt) { + $this->encrypt->enableContinuousBuffer(); + $this->encrypt->disablePadding(); + + $iv = $kexHash->hash($keyBytes . $this->exchange_hash . 'A' . $this->session_id); + while ($this->encrypt_block_size > strlen($iv)) { + $iv.= $kexHash->hash($keyBytes . $this->exchange_hash . $iv); + } + $this->encrypt->setIV(substr($iv, 0, $this->encrypt_block_size)); + + $key = $kexHash->hash($keyBytes . $this->exchange_hash . 'C' . $this->session_id); + while ($encryptKeyLength > strlen($key)) { + $key.= $kexHash->hash($keyBytes . $this->exchange_hash . $key); + } + $this->encrypt->setKey(substr($key, 0, $encryptKeyLength)); + } + + if ($this->decrypt) { + $this->decrypt->enableContinuousBuffer(); + $this->decrypt->disablePadding(); + + $iv = $kexHash->hash($keyBytes . $this->exchange_hash . 'B' . $this->session_id); + while ($this->decrypt_block_size > strlen($iv)) { + $iv.= $kexHash->hash($keyBytes . $this->exchange_hash . $iv); + } + $this->decrypt->setIV(substr($iv, 0, $this->decrypt_block_size)); + + $key = $kexHash->hash($keyBytes . $this->exchange_hash . 'D' . $this->session_id); + while ($decryptKeyLength > strlen($key)) { + $key.= $kexHash->hash($keyBytes . $this->exchange_hash . $key); + } + $this->decrypt->setKey(substr($key, 0, $decryptKeyLength)); + } + + /* The "arcfour128" algorithm is the RC4 cipher, as described in + [SCHNEIER], using a 128-bit key. The first 1536 bytes of keystream + generated by the cipher MUST be discarded, and the first byte of the + first encrypted packet MUST be encrypted using the 1537th byte of + keystream. + + -- http://tools.ietf.org/html/rfc4345#section-4 */ + if ($encrypt == 'arcfour128' || $encrypt == 'arcfour256') { + $this->encrypt->encrypt(str_repeat("\0", 1536)); + } + if ($decrypt == 'arcfour128' || $decrypt == 'arcfour256') { + $this->decrypt->decrypt(str_repeat("\0", 1536)); + } + + for ($i = 0; $i < count($mac_algorithms) && !in_array($mac_algorithms[$i], $this->mac_algorithms_client_to_server); $i++); + if ($i == count($mac_algorithms)) { + user_error('No compatible client to server message authentication algorithms found'); + return $this->_disconnect(NET_SSH2_DISCONNECT_KEY_EXCHANGE_FAILED); + } + + $createKeyLength = 0; // ie. $mac_algorithms[$i] == 'none' + switch ($mac_algorithms[$i]) { + case 'hmac-sha1': + $this->hmac_create = new Crypt_Hash('sha1'); + $createKeyLength = 20; + break; + case 'hmac-sha1-96': + $this->hmac_create = new Crypt_Hash('sha1-96'); + $createKeyLength = 20; + break; + case 'hmac-md5': + $this->hmac_create = new Crypt_Hash('md5'); + $createKeyLength = 16; + break; + case 'hmac-md5-96': + $this->hmac_create = new Crypt_Hash('md5-96'); + $createKeyLength = 16; + } + + for ($i = 0; $i < count($mac_algorithms) && !in_array($mac_algorithms[$i], $this->mac_algorithms_server_to_client); $i++); + if ($i == count($mac_algorithms)) { + user_error('No compatible server to client message authentication algorithms found'); + return $this->_disconnect(NET_SSH2_DISCONNECT_KEY_EXCHANGE_FAILED); + } + + $checkKeyLength = 0; + $this->hmac_size = 0; + switch ($mac_algorithms[$i]) { + case 'hmac-sha1': + $this->hmac_check = new Crypt_Hash('sha1'); + $checkKeyLength = 20; + $this->hmac_size = 20; + break; + case 'hmac-sha1-96': + $this->hmac_check = new Crypt_Hash('sha1-96'); + $checkKeyLength = 20; + $this->hmac_size = 12; + break; + case 'hmac-md5': + $this->hmac_check = new Crypt_Hash('md5'); + $checkKeyLength = 16; + $this->hmac_size = 16; + break; + case 'hmac-md5-96': + $this->hmac_check = new Crypt_Hash('md5-96'); + $checkKeyLength = 16; + $this->hmac_size = 12; + } + + $key = $kexHash->hash($keyBytes . $this->exchange_hash . 'E' . $this->session_id); + while ($createKeyLength > strlen($key)) { + $key.= $kexHash->hash($keyBytes . $this->exchange_hash . $key); + } + $this->hmac_create->setKey(substr($key, 0, $createKeyLength)); + + $key = $kexHash->hash($keyBytes . $this->exchange_hash . 'F' . $this->session_id); + while ($checkKeyLength > strlen($key)) { + $key.= $kexHash->hash($keyBytes . $this->exchange_hash . $key); + } + $this->hmac_check->setKey(substr($key, 0, $checkKeyLength)); + + for ($i = 0; $i < count($compression_algorithms) && !in_array($compression_algorithms[$i], $this->compression_algorithms_server_to_client); $i++); + if ($i == count($compression_algorithms)) { + user_error('No compatible server to client compression algorithms found'); + return $this->_disconnect(NET_SSH2_DISCONNECT_KEY_EXCHANGE_FAILED); + } + $this->decompress = $compression_algorithms[$i] == 'zlib'; + + for ($i = 0; $i < count($compression_algorithms) && !in_array($compression_algorithms[$i], $this->compression_algorithms_client_to_server); $i++); + if ($i == count($compression_algorithms)) { + user_error('No compatible client to server compression algorithms found'); + return $this->_disconnect(NET_SSH2_DISCONNECT_KEY_EXCHANGE_FAILED); + } + $this->compress = $compression_algorithms[$i] == 'zlib'; + + return true; + } + + /** + * Login + * + * The $password parameter can be a plaintext password, a Crypt_RSA object or an array + * + * @param String $username + * @param Mixed $password + * @param Mixed $... + * @return Boolean + * @see _login + * @access public + */ + function login($username) + { + $args = func_get_args(); + return call_user_func_array(array(&$this, '_login'), $args); + } + + /** + * Login Helper + * + * @param String $username + * @param Mixed $password + * @param Mixed $... + * @return Boolean + * @see _login_helper + * @access private + */ + function _login($username) + { + $args = array_slice(func_get_args(), 1); + if (empty($args)) { + return $this->_login_helper($username); + } + + foreach ($args as $arg) { + if ($this->_login_helper($username, $arg)) { + return true; + } + } + return false; + } + + /** + * Login Helper + * + * @param String $username + * @param optional String $password + * @return Boolean + * @access private + * @internal It might be worthwhile, at some point, to protect against {@link http://tools.ietf.org/html/rfc4251#section-9.3.9 traffic analysis} + * by sending dummy SSH_MSG_IGNORE messages. + */ + function _login_helper($username, $password = null) + { + if (!($this->bitmap & NET_SSH2_MASK_CONSTRUCTOR)) { + return false; + } + + if (!($this->bitmap & NET_SSH2_MASK_LOGIN_REQ)) { + $packet = pack('CNa*', + NET_SSH2_MSG_SERVICE_REQUEST, strlen('ssh-userauth'), 'ssh-userauth' + ); + + if (!$this->_send_binary_packet($packet)) { + return false; + } + + $response = $this->_get_binary_packet(); + if ($response === false) { + user_error('Connection closed by server'); + return false; + } + + extract(unpack('Ctype', $this->_string_shift($response, 1))); + + if ($type != NET_SSH2_MSG_SERVICE_ACCEPT) { + user_error('Expected SSH_MSG_SERVICE_ACCEPT'); + return false; + } + $this->bitmap |= NET_SSH2_MASK_LOGIN_REQ; + } + + if (strlen($this->last_interactive_response)) { + return !is_string($password) && !is_array($password) ? false : $this->_keyboard_interactive_process($password); + } + + // although PHP5's get_class() preserves the case, PHP4's does not + if (is_object($password)) { + switch (strtolower(get_class($password))) { + case 'crypt_rsa': + return $this->_privatekey_login($username, $password); + case 'system_ssh_agent': + return $this->_ssh_agent_login($username, $password); + } + } + + if (is_array($password)) { + if ($this->_keyboard_interactive_login($username, $password)) { + $this->bitmap |= NET_SSH2_MASK_LOGIN; + return true; + } + return false; + } + + if (!isset($password)) { + $packet = pack('CNa*Na*Na*', + NET_SSH2_MSG_USERAUTH_REQUEST, strlen($username), $username, strlen('ssh-connection'), 'ssh-connection', + strlen('none'), 'none' + ); + + if (!$this->_send_binary_packet($packet)) { + return false; + } + + $response = $this->_get_binary_packet(); + if ($response === false) { + user_error('Connection closed by server'); + return false; + } + + extract(unpack('Ctype', $this->_string_shift($response, 1))); + + switch ($type) { + case NET_SSH2_MSG_USERAUTH_SUCCESS: + $this->bitmap |= NET_SSH2_MASK_LOGIN; + return true; + //case NET_SSH2_MSG_USERAUTH_FAILURE: + default: + return false; + } + } + + $packet = pack('CNa*Na*Na*CNa*', + NET_SSH2_MSG_USERAUTH_REQUEST, strlen($username), $username, strlen('ssh-connection'), 'ssh-connection', + strlen('password'), 'password', 0, strlen($password), $password + ); + + // remove the username and password from the logged packet + if (!defined('NET_SSH2_LOGGING')) { + $logged = null; + } else { + $logged = pack('CNa*Na*Na*CNa*', + NET_SSH2_MSG_USERAUTH_REQUEST, strlen('username'), 'username', strlen('ssh-connection'), 'ssh-connection', + strlen('password'), 'password', 0, strlen('password'), 'password' + ); + } + + if (!$this->_send_binary_packet($packet, $logged)) { + return false; + } + + $response = $this->_get_binary_packet(); + if ($response === false) { + user_error('Connection closed by server'); + return false; + } + + extract(unpack('Ctype', $this->_string_shift($response, 1))); + + switch ($type) { + case NET_SSH2_MSG_USERAUTH_PASSWD_CHANGEREQ: // in theory, the password can be changed + if (defined('NET_SSH2_LOGGING')) { + $this->message_number_log[count($this->message_number_log) - 1] = 'NET_SSH2_MSG_USERAUTH_PASSWD_CHANGEREQ'; + } + extract(unpack('Nlength', $this->_string_shift($response, 4))); + $this->errors[] = 'SSH_MSG_USERAUTH_PASSWD_CHANGEREQ: ' . utf8_decode($this->_string_shift($response, $length)); + return $this->_disconnect(NET_SSH2_DISCONNECT_AUTH_CANCELLED_BY_USER); + case NET_SSH2_MSG_USERAUTH_FAILURE: + // can we use keyboard-interactive authentication? if not then either the login is bad or the server employees + // multi-factor authentication + extract(unpack('Nlength', $this->_string_shift($response, 4))); + $auth_methods = explode(',', $this->_string_shift($response, $length)); + extract(unpack('Cpartial_success', $this->_string_shift($response, 1))); + $partial_success = $partial_success != 0; + + if (!$partial_success && in_array('keyboard-interactive', $auth_methods)) { + if ($this->_keyboard_interactive_login($username, $password)) { + $this->bitmap |= NET_SSH2_MASK_LOGIN; + return true; + } + return false; + } + return false; + case NET_SSH2_MSG_USERAUTH_SUCCESS: + $this->bitmap |= NET_SSH2_MASK_LOGIN; + return true; + } + + return false; + } + + /** + * Login via keyboard-interactive authentication + * + * See {@link http://tools.ietf.org/html/rfc4256 RFC4256} for details. This is not a full-featured keyboard-interactive authenticator. + * + * @param String $username + * @param String $password + * @return Boolean + * @access private + */ + function _keyboard_interactive_login($username, $password) + { + $packet = pack('CNa*Na*Na*Na*Na*', + NET_SSH2_MSG_USERAUTH_REQUEST, strlen($username), $username, strlen('ssh-connection'), 'ssh-connection', + strlen('keyboard-interactive'), 'keyboard-interactive', 0, '', 0, '' + ); + + if (!$this->_send_binary_packet($packet)) { + return false; + } + + return $this->_keyboard_interactive_process($password); + } + + /** + * Handle the keyboard-interactive requests / responses. + * + * @param String $responses... + * @return Boolean + * @access private + */ + function _keyboard_interactive_process() + { + $responses = func_get_args(); + + if (strlen($this->last_interactive_response)) { + $response = $this->last_interactive_response; + } else { + $orig = $response = $this->_get_binary_packet(); + if ($response === false) { + user_error('Connection closed by server'); + return false; + } + } + + extract(unpack('Ctype', $this->_string_shift($response, 1))); + + switch ($type) { + case NET_SSH2_MSG_USERAUTH_INFO_REQUEST: + extract(unpack('Nlength', $this->_string_shift($response, 4))); + $this->_string_shift($response, $length); // name; may be empty + extract(unpack('Nlength', $this->_string_shift($response, 4))); + $this->_string_shift($response, $length); // instruction; may be empty + extract(unpack('Nlength', $this->_string_shift($response, 4))); + $this->_string_shift($response, $length); // language tag; may be empty + extract(unpack('Nnum_prompts', $this->_string_shift($response, 4))); + + for ($i = 0; $i < count($responses); $i++) { + if (is_array($responses[$i])) { + foreach ($responses[$i] as $key => $value) { + $this->keyboard_requests_responses[$key] = $value; + } + unset($responses[$i]); + } + } + $responses = array_values($responses); + + if (isset($this->keyboard_requests_responses)) { + for ($i = 0; $i < $num_prompts; $i++) { + extract(unpack('Nlength', $this->_string_shift($response, 4))); + // prompt - ie. "Password: "; must not be empty + $prompt = $this->_string_shift($response, $length); + //$echo = $this->_string_shift($response) != chr(0); + foreach ($this->keyboard_requests_responses as $key => $value) { + if (substr($prompt, 0, strlen($key)) == $key) { + $responses[] = $value; + break; + } + } + } + } + + // see http://tools.ietf.org/html/rfc4256#section-3.2 + if (strlen($this->last_interactive_response)) { + $this->last_interactive_response = ''; + } else if (defined('NET_SSH2_LOGGING')) { + $this->message_number_log[count($this->message_number_log) - 1] = str_replace( + 'UNKNOWN', + 'NET_SSH2_MSG_USERAUTH_INFO_REQUEST', + $this->message_number_log[count($this->message_number_log) - 1] + ); + } + + if (!count($responses) && $num_prompts) { + $this->last_interactive_response = $orig; + $this->bitmap |= NET_SSH_MASK_LOGIN_INTERACTIVE; + return false; + } + + /* + After obtaining the requested information from the user, the client + MUST respond with an SSH_MSG_USERAUTH_INFO_RESPONSE message. + */ + // see http://tools.ietf.org/html/rfc4256#section-3.4 + $packet = $logged = pack('CN', NET_SSH2_MSG_USERAUTH_INFO_RESPONSE, count($responses)); + for ($i = 0; $i < count($responses); $i++) { + $packet.= pack('Na*', strlen($responses[$i]), $responses[$i]); + $logged.= pack('Na*', strlen('dummy-answer'), 'dummy-answer'); + } + + if (!$this->_send_binary_packet($packet, $logged)) { + return false; + } + + if (defined('NET_SSH2_LOGGING') && NET_SSH2_LOGGING == NET_SSH2_LOG_COMPLEX) { + $this->message_number_log[count($this->message_number_log) - 1] = str_replace( + 'UNKNOWN', + 'NET_SSH2_MSG_USERAUTH_INFO_RESPONSE', + $this->message_number_log[count($this->message_number_log) - 1] + ); + } + + /* + After receiving the response, the server MUST send either an + SSH_MSG_USERAUTH_SUCCESS, SSH_MSG_USERAUTH_FAILURE, or another + SSH_MSG_USERAUTH_INFO_REQUEST message. + */ + // maybe phpseclib should force close the connection after x request / responses? unless something like that is done + // there could be an infinite loop of request / responses. + return $this->_keyboard_interactive_process(); + case NET_SSH2_MSG_USERAUTH_SUCCESS: + return true; + case NET_SSH2_MSG_USERAUTH_FAILURE: + return false; + } + + return false; + } + + /** + * Login with an ssh-agent provided key + * + * @param String $username + * @param System_SSH_Agent $agent + * @return Boolean + * @access private + */ + function _ssh_agent_login($username, $agent) + { + $keys = $agent->requestIdentities(); + foreach ($keys as $key) { + if ($this->_privatekey_login($username, $key)) { + return true; + } + } + + return false; + } + + /** + * Login with an RSA private key + * + * @param String $username + * @param Crypt_RSA $password + * @return Boolean + * @access private + * @internal It might be worthwhile, at some point, to protect against {@link http://tools.ietf.org/html/rfc4251#section-9.3.9 traffic analysis} + * by sending dummy SSH_MSG_IGNORE messages. + */ + function _privatekey_login($username, $privatekey) + { + // see http://tools.ietf.org/html/rfc4253#page-15 + $publickey = $privatekey->getPublicKey(CRYPT_RSA_PUBLIC_FORMAT_RAW); + if ($publickey === false) { + return false; + } + + $publickey = array( + 'e' => $publickey['e']->toBytes(true), + 'n' => $publickey['n']->toBytes(true) + ); + $publickey = pack('Na*Na*Na*', + strlen('ssh-rsa'), 'ssh-rsa', strlen($publickey['e']), $publickey['e'], strlen($publickey['n']), $publickey['n'] + ); + + $part1 = pack('CNa*Na*Na*', + NET_SSH2_MSG_USERAUTH_REQUEST, strlen($username), $username, strlen('ssh-connection'), 'ssh-connection', + strlen('publickey'), 'publickey' + ); + $part2 = pack('Na*Na*', strlen('ssh-rsa'), 'ssh-rsa', strlen($publickey), $publickey); + + $packet = $part1 . chr(0) . $part2; + if (!$this->_send_binary_packet($packet)) { + return false; + } + + $response = $this->_get_binary_packet(); + if ($response === false) { + user_error('Connection closed by server'); + return false; + } + + extract(unpack('Ctype', $this->_string_shift($response, 1))); + + switch ($type) { + case NET_SSH2_MSG_USERAUTH_FAILURE: + extract(unpack('Nlength', $this->_string_shift($response, 4))); + $this->errors[] = 'SSH_MSG_USERAUTH_FAILURE: ' . $this->_string_shift($response, $length); + return false; + case NET_SSH2_MSG_USERAUTH_PK_OK: + // we'll just take it on faith that the public key blob and the public key algorithm name are as + // they should be + if (defined('NET_SSH2_LOGGING') && NET_SSH2_LOGGING == NET_SSH2_LOG_COMPLEX) { + $this->message_number_log[count($this->message_number_log) - 1] = str_replace( + 'UNKNOWN', + 'NET_SSH2_MSG_USERAUTH_PK_OK', + $this->message_number_log[count($this->message_number_log) - 1] + ); + } + } + + $packet = $part1 . chr(1) . $part2; + $privatekey->setSignatureMode(CRYPT_RSA_SIGNATURE_PKCS1); + $signature = $privatekey->sign(pack('Na*a*', strlen($this->session_id), $this->session_id, $packet)); + $signature = pack('Na*Na*', strlen('ssh-rsa'), 'ssh-rsa', strlen($signature), $signature); + $packet.= pack('Na*', strlen($signature), $signature); + + if (!$this->_send_binary_packet($packet)) { + return false; + } + + $response = $this->_get_binary_packet(); + if ($response === false) { + user_error('Connection closed by server'); + return false; + } + + extract(unpack('Ctype', $this->_string_shift($response, 1))); + + switch ($type) { + case NET_SSH2_MSG_USERAUTH_FAILURE: + // either the login is bad or the server employs multi-factor authentication + return false; + case NET_SSH2_MSG_USERAUTH_SUCCESS: + $this->bitmap |= NET_SSH2_MASK_LOGIN; + return true; + } + + return false; + } + + /** + * Set Timeout + * + * $ssh->exec('ping 127.0.0.1'); on a Linux host will never return and will run indefinitely. setTimeout() makes it so it'll timeout. + * Setting $timeout to false or 0 will mean there is no timeout. + * + * @param Mixed $timeout + * @access public + */ + function setTimeout($timeout) + { + $this->timeout = $this->curTimeout = $timeout; + } + + /** + * Get the output from stdError + * + * @access public + */ + function getStdError() + { + return $this->stdErrorLog; + } + + /** + * Execute Command + * + * If $block is set to false then Net_SSH2::_get_channel_packet(NET_SSH2_CHANNEL_EXEC) will need to be called manually. + * In all likelihood, this is not a feature you want to be taking advantage of. + * + * @param String $command + * @param optional Boolean $block + * @return String + * @access public + */ + function exec($command, $callback = null) + { + $this->curTimeout = $this->timeout; + $this->is_timeout = false; + $this->stdErrorLog = ''; + + if (!($this->bitmap & NET_SSH2_MASK_LOGIN)) { + return false; + } + + // RFC4254 defines the (client) window size as "bytes the other party can send before it must wait for the window to + // be adjusted". 0x7FFFFFFF is, at 2GB, the max size. technically, it should probably be decremented, but, + // honestly, if you're transfering more than 2GB, you probably shouldn't be using phpseclib, anyway. + // see http://tools.ietf.org/html/rfc4254#section-5.2 for more info + $this->window_size_server_to_client[NET_SSH2_CHANNEL_EXEC] = 0x7FFFFFFF; + // 0x8000 is the maximum max packet size, per http://tools.ietf.org/html/rfc4253#section-6.1, although since PuTTy + // uses 0x4000, that's what will be used here, as well. + $packet_size = 0x4000; + + $packet = pack('CNa*N3', + NET_SSH2_MSG_CHANNEL_OPEN, strlen('session'), 'session', NET_SSH2_CHANNEL_EXEC, $this->window_size_server_to_client[NET_SSH2_CHANNEL_EXEC], $packet_size); + + if (!$this->_send_binary_packet($packet)) { + return false; + } + + $this->channel_status[NET_SSH2_CHANNEL_EXEC] = NET_SSH2_MSG_CHANNEL_OPEN; + + $response = $this->_get_channel_packet(NET_SSH2_CHANNEL_EXEC); + if ($response === false) { + return false; + } + + if ($this->request_pty === true) { + $terminal_modes = pack('C', NET_SSH2_TTY_OP_END); + $packet = pack('CNNa*CNa*N5a*', + NET_SSH2_MSG_CHANNEL_REQUEST, $this->server_channels[NET_SSH2_CHANNEL_EXEC], strlen('pty-req'), 'pty-req', 1, strlen('vt100'), 'vt100', + 80, 24, 0, 0, strlen($terminal_modes), $terminal_modes); + + if (!$this->_send_binary_packet($packet)) { + return false; + } + $response = $this->_get_binary_packet(); + if ($response === false) { + user_error('Connection closed by server'); + return false; + } + + list(, $type) = unpack('C', $this->_string_shift($response, 1)); + + switch ($type) { + case NET_SSH2_MSG_CHANNEL_SUCCESS: + break; + case NET_SSH2_MSG_CHANNEL_FAILURE: + default: + user_error('Unable to request pseudo-terminal'); + return $this->_disconnect(NET_SSH2_DISCONNECT_BY_APPLICATION); + } + $this->in_request_pty_exec = true; + } + + // sending a pty-req SSH_MSG_CHANNEL_REQUEST message is unnecessary and, in fact, in most cases, slows things + // down. the one place where it might be desirable is if you're doing something like Net_SSH2::exec('ping localhost &'). + // with a pty-req SSH_MSG_CHANNEL_REQUEST, exec() will return immediately and the ping process will then + // then immediately terminate. without such a request exec() will loop indefinitely. the ping process won't end but + // neither will your script. + + // although, in theory, the size of SSH_MSG_CHANNEL_REQUEST could exceed the maximum packet size established by + // SSH_MSG_CHANNEL_OPEN_CONFIRMATION, RFC4254#section-5.1 states that the "maximum packet size" refers to the + // "maximum size of an individual data packet". ie. SSH_MSG_CHANNEL_DATA. RFC4254#section-5.2 corroborates. + $packet = pack('CNNa*CNa*', + NET_SSH2_MSG_CHANNEL_REQUEST, $this->server_channels[NET_SSH2_CHANNEL_EXEC], strlen('exec'), 'exec', 1, strlen($command), $command); + if (!$this->_send_binary_packet($packet)) { + return false; + } + + $this->channel_status[NET_SSH2_CHANNEL_EXEC] = NET_SSH2_MSG_CHANNEL_REQUEST; + + $response = $this->_get_channel_packet(NET_SSH2_CHANNEL_EXEC); + if ($response === false) { + return false; + } + + $this->channel_status[NET_SSH2_CHANNEL_EXEC] = NET_SSH2_MSG_CHANNEL_DATA; + + if ($callback === false || $this->in_request_pty_exec) { + return true; + } + + $output = ''; + while (true) { + $temp = $this->_get_channel_packet(NET_SSH2_CHANNEL_EXEC); + switch (true) { + case $temp === true: + return is_callable($callback) ? true : $output; + case $temp === false: + return false; + default: + if (is_callable($callback)) { + $callback($temp); + } else { + $output.= $temp; + } + } + } + } + + /** + * Creates an interactive shell + * + * @see Net_SSH2::read() + * @see Net_SSH2::write() + * @return Boolean + * @access private + */ + function _initShell() + { + if ($this->in_request_pty_exec === true) { + return true; + } + + $this->window_size_server_to_client[NET_SSH2_CHANNEL_SHELL] = 0x7FFFFFFF; + $packet_size = 0x4000; + + $packet = pack('CNa*N3', + NET_SSH2_MSG_CHANNEL_OPEN, strlen('session'), 'session', NET_SSH2_CHANNEL_SHELL, $this->window_size_server_to_client[NET_SSH2_CHANNEL_SHELL], $packet_size); + + if (!$this->_send_binary_packet($packet)) { + return false; + } + + $this->channel_status[NET_SSH2_CHANNEL_SHELL] = NET_SSH2_MSG_CHANNEL_OPEN; + + $response = $this->_get_channel_packet(NET_SSH2_CHANNEL_SHELL); + if ($response === false) { + return false; + } + + $terminal_modes = pack('C', NET_SSH2_TTY_OP_END); + $packet = pack('CNNa*CNa*N5a*', + NET_SSH2_MSG_CHANNEL_REQUEST, $this->server_channels[NET_SSH2_CHANNEL_SHELL], strlen('pty-req'), 'pty-req', 1, strlen('vt100'), 'vt100', + 80, 24, 0, 0, strlen($terminal_modes), $terminal_modes); + + if (!$this->_send_binary_packet($packet)) { + return false; + } + + $response = $this->_get_binary_packet(); + if ($response === false) { + user_error('Connection closed by server'); + return false; + } + + list(, $type) = unpack('C', $this->_string_shift($response, 1)); + + switch ($type) { + case NET_SSH2_MSG_CHANNEL_SUCCESS: + // if a pty can't be opened maybe commands can still be executed + case NET_SSH2_MSG_CHANNEL_FAILURE: + break; + default: + user_error('Unable to request pseudo-terminal'); + return $this->_disconnect(NET_SSH2_DISCONNECT_BY_APPLICATION); + } + + $packet = pack('CNNa*C', + NET_SSH2_MSG_CHANNEL_REQUEST, $this->server_channels[NET_SSH2_CHANNEL_SHELL], strlen('shell'), 'shell', 1); + if (!$this->_send_binary_packet($packet)) { + return false; + } + + $this->channel_status[NET_SSH2_CHANNEL_SHELL] = NET_SSH2_MSG_CHANNEL_REQUEST; + + $response = $this->_get_channel_packet(NET_SSH2_CHANNEL_SHELL); + if ($response === false) { + return false; + } + + $this->channel_status[NET_SSH2_CHANNEL_SHELL] = NET_SSH2_MSG_CHANNEL_DATA; + + $this->bitmap |= NET_SSH2_MASK_SHELL; + + return true; + } + + /** + * Return the channel to be used with read() / write() + * + * @see Net_SSH2::read() + * @see Net_SSH2::write() + * @return Integer + * @access public + */ + function _get_interactive_channel() + { + switch (true) { + case $this->in_subsystem: + return NET_SSH2_CHANNEL_SUBSYSTEM; + case $this->in_request_pty_exec: + return NET_SSH2_CHANNEL_EXEC; + default: + return NET_SSH2_CHANNEL_SHELL; + } + } + + /** + * Returns the output of an interactive shell + * + * Returns when there's a match for $expect, which can take the form of a string literal or, + * if $mode == NET_SSH2_READ_REGEX, a regular expression. + * + * @see Net_SSH2::write() + * @param String $expect + * @param Integer $mode + * @return String + * @access public + */ + function read($expect = '', $mode = NET_SSH2_READ_SIMPLE) + { + $this->curTimeout = $this->timeout; + $this->is_timeout = false; + + if (!($this->bitmap & NET_SSH2_MASK_LOGIN)) { + user_error('Operation disallowed prior to login()'); + return false; + } + + if (!($this->bitmap & NET_SSH2_MASK_SHELL) && !$this->_initShell()) { + user_error('Unable to initiate an interactive shell session'); + return false; + } + + $channel = $this->_get_interactive_channel(); + + $match = $expect; + while (true) { + if ($mode == NET_SSH2_READ_REGEX) { + preg_match($expect, $this->interactiveBuffer, $matches); + $match = isset($matches[0]) ? $matches[0] : ''; + } + $pos = strlen($match) ? strpos($this->interactiveBuffer, $match) : false; + if ($pos !== false) { + return $this->_string_shift($this->interactiveBuffer, $pos + strlen($match)); + } + $response = $this->_get_channel_packet($channel); + if (is_bool($response)) { + $this->in_request_pty_exec = false; + return $response ? $this->_string_shift($this->interactiveBuffer, strlen($this->interactiveBuffer)) : false; + } + + $this->interactiveBuffer.= $response; + } + } + + /** + * Inputs a command into an interactive shell. + * + * @see Net_SSH2::read() + * @param String $cmd + * @return Boolean + * @access public + */ + function write($cmd) + { + if (!($this->bitmap & NET_SSH2_MASK_LOGIN)) { + user_error('Operation disallowed prior to login()'); + return false; + } + + if (!($this->bitmap & NET_SSH2_MASK_SHELL) && !$this->_initShell()) { + user_error('Unable to initiate an interactive shell session'); + return false; + } + + return $this->_send_channel_packet($this->_get_interactive_channel(), $cmd); + } + + /** + * Start a subsystem. + * + * Right now only one subsystem at a time is supported. To support multiple subsystem's stopSubsystem() could accept + * a string that contained the name of the subsystem, but at that point, only one subsystem of each type could be opened. + * To support multiple subsystem's of the same name maybe it'd be best if startSubsystem() generated a new channel id and + * returns that and then that that was passed into stopSubsystem() but that'll be saved for a future date and implemented + * if there's sufficient demand for such a feature. + * + * @see Net_SSH2::stopSubsystem() + * @param String $subsystem + * @return Boolean + * @access public + */ + function startSubsystem($subsystem) + { + $this->window_size_server_to_client[NET_SSH2_CHANNEL_SUBSYSTEM] = $this->window_size; + + $packet = pack('CNa*N3', + NET_SSH2_MSG_CHANNEL_OPEN, strlen('session'), 'session', NET_SSH2_CHANNEL_SUBSYSTEM, $this->window_size, 0x4000); + + if (!$this->_send_binary_packet($packet)) { + return false; + } + + $this->channel_status[NET_SSH2_CHANNEL_SUBSYSTEM] = NET_SSH2_MSG_CHANNEL_OPEN; + + $response = $this->_get_channel_packet(NET_SSH2_CHANNEL_SUBSYSTEM); + if ($response === false) { + return false; + } + + $packet = pack('CNNa*CNa*', + NET_SSH2_MSG_CHANNEL_REQUEST, $this->server_channels[NET_SSH2_CHANNEL_SUBSYSTEM], strlen('subsystem'), 'subsystem', 1, strlen($subsystem), $subsystem); + if (!$this->_send_binary_packet($packet)) { + return false; + } + + $this->channel_status[NET_SSH2_CHANNEL_SUBSYSTEM] = NET_SSH2_MSG_CHANNEL_REQUEST; + + $response = $this->_get_channel_packet(NET_SSH2_CHANNEL_SUBSYSTEM); + + if ($response === false) { + return false; + } + + $this->channel_status[NET_SSH2_CHANNEL_SUBSYSTEM] = NET_SSH2_MSG_CHANNEL_DATA; + + $this->bitmap |= NET_SSH2_MASK_SHELL; + $this->in_subsystem = true; + + return true; + } + + /** + * Stops a subsystem. + * + * @see Net_SSH2::startSubsystem() + * @return Boolean + * @access public + */ + function stopSubsystem() + { + $this->in_subsystem = false; + $this->_close_channel(NET_SSH2_CHANNEL_SUBSYSTEM); + return true; + } + + /** + * Closes a channel + * + * If read() timed out you might want to just close the channel and have it auto-restart on the next read() call + * + * @access public + */ + function reset() + { + $this->_close_channel($this->_get_interactive_channel()); + } + + /** + * Is timeout? + * + * Did exec() or read() return because they timed out or because they encountered the end? + * + * @access public + */ + function isTimeout() + { + return $this->is_timeout; + } + + /** + * Disconnect + * + * @access public + */ + function disconnect() + { + $this->_disconnect(NET_SSH2_DISCONNECT_BY_APPLICATION); + if (isset($this->realtime_log_file) && is_resource($this->realtime_log_file)) { + fclose($this->realtime_log_file); + } + } + + /** + * Destructor. + * + * Will be called, automatically, if you're supporting just PHP5. If you're supporting PHP4, you'll need to call + * disconnect(). + * + * @access public + */ + function __destruct() + { + $this->disconnect(); + } + + /** + * Is the connection still active? + * + * @access public + */ + function isConnected() + { + return $this->bitmap & NET_SSH2_MASK_LOGIN; + } + + /** + * Gets Binary Packets + * + * See '6. Binary Packet Protocol' of rfc4253 for more info. + * + * @see Net_SSH2::_send_binary_packet() + * @return String + * @access private + */ + function _get_binary_packet() + { + if (!is_resource($this->fsock) || feof($this->fsock)) { + user_error('Connection closed prematurely'); + $this->bitmap = 0; + return false; + } + + $start = strtok(microtime(), ' ') + strtok(''); // http://php.net/microtime#61838 + $raw = fread($this->fsock, $this->decrypt_block_size); + + if (!strlen($raw)) { + return ''; + } + + if ($this->decrypt !== false) { + $raw = $this->decrypt->decrypt($raw); + } + if ($raw === false) { + user_error('Unable to decrypt content'); + return false; + } + + extract(unpack('Npacket_length/Cpadding_length', $this->_string_shift($raw, 5))); + + $remaining_length = $packet_length + 4 - $this->decrypt_block_size; + + // quoting , + // "implementations SHOULD check that the packet length is reasonable" + // PuTTY uses 0x9000 as the actual max packet size and so to shall we + if ($remaining_length < -$this->decrypt_block_size || $remaining_length > 0x9000 || $remaining_length % $this->decrypt_block_size != 0) { + user_error('Invalid size'); + return false; + } + + $buffer = ''; + while ($remaining_length > 0) { + $temp = fread($this->fsock, $remaining_length); + $buffer.= $temp; + $remaining_length-= strlen($temp); + } + $stop = strtok(microtime(), ' ') + strtok(''); + if (strlen($buffer)) { + $raw.= $this->decrypt !== false ? $this->decrypt->decrypt($buffer) : $buffer; + } + + $payload = $this->_string_shift($raw, $packet_length - $padding_length - 1); + $padding = $this->_string_shift($raw, $padding_length); // should leave $raw empty + + if ($this->hmac_check !== false) { + $hmac = fread($this->fsock, $this->hmac_size); + if ($hmac != $this->hmac_check->hash(pack('NNCa*', $this->get_seq_no, $packet_length, $padding_length, $payload . $padding))) { + user_error('Invalid HMAC'); + return false; + } + } + + //if ($this->decompress) { + // $payload = gzinflate(substr($payload, 2)); + //} + + $this->get_seq_no++; + + if (defined('NET_SSH2_LOGGING')) { + $current = strtok(microtime(), ' ') + strtok(''); + $message_number = isset($this->message_numbers[ord($payload[0])]) ? $this->message_numbers[ord($payload[0])] : 'UNKNOWN (' . ord($payload[0]) . ')'; + $message_number = '<- ' . $message_number . + ' (since last: ' . round($current - $this->last_packet, 4) . ', network: ' . round($stop - $start, 4) . 's)'; + $this->_append_log($message_number, $payload); + $this->last_packet = $current; + } + + return $this->_filter($payload); + } + + /** + * Filter Binary Packets + * + * Because some binary packets need to be ignored... + * + * @see Net_SSH2::_get_binary_packet() + * @return String + * @access private + */ + function _filter($payload) + { + switch (ord($payload[0])) { + case NET_SSH2_MSG_DISCONNECT: + $this->_string_shift($payload, 1); + extract(unpack('Nreason_code/Nlength', $this->_string_shift($payload, 8))); + $this->errors[] = 'SSH_MSG_DISCONNECT: ' . $this->disconnect_reasons[$reason_code] . "\r\n" . utf8_decode($this->_string_shift($payload, $length)); + $this->bitmap = 0; + return false; + case NET_SSH2_MSG_IGNORE: + $payload = $this->_get_binary_packet(); + break; + case NET_SSH2_MSG_DEBUG: + $this->_string_shift($payload, 2); + extract(unpack('Nlength', $this->_string_shift($payload, 4))); + $this->errors[] = 'SSH_MSG_DEBUG: ' . utf8_decode($this->_string_shift($payload, $length)); + $payload = $this->_get_binary_packet(); + break; + case NET_SSH2_MSG_UNIMPLEMENTED: + return false; + case NET_SSH2_MSG_KEXINIT: + if ($this->session_id !== false) { + if (!$this->_key_exchange($payload)) { + $this->bitmap = 0; + return false; + } + $payload = $this->_get_binary_packet(); + } + } + + // see http://tools.ietf.org/html/rfc4252#section-5.4; only called when the encryption has been activated and when we haven't already logged in + if (($this->bitmap & NET_SSH2_MASK_CONSTRUCTOR) && !($this->bitmap & NET_SSH2_MASK_LOGIN) && ord($payload[0]) == NET_SSH2_MSG_USERAUTH_BANNER) { + $this->_string_shift($payload, 1); + extract(unpack('Nlength', $this->_string_shift($payload, 4))); + $this->banner_message = utf8_decode($this->_string_shift($payload, $length)); + $payload = $this->_get_binary_packet(); + } + + // only called when we've already logged in + if (($this->bitmap & NET_SSH2_MASK_CONSTRUCTOR) && ($this->bitmap & NET_SSH2_MASK_LOGIN)) { + switch (ord($payload[0])) { + case NET_SSH2_MSG_GLOBAL_REQUEST: // see http://tools.ietf.org/html/rfc4254#section-4 + $this->_string_shift($payload, 1); + extract(unpack('Nlength', $this->_string_shift($payload))); + $this->errors[] = 'SSH_MSG_GLOBAL_REQUEST: ' . utf8_decode($this->_string_shift($payload, $length)); + + if (!$this->_send_binary_packet(pack('C', NET_SSH2_MSG_REQUEST_FAILURE))) { + return $this->_disconnect(NET_SSH2_DISCONNECT_BY_APPLICATION); + } + + $payload = $this->_get_binary_packet(); + break; + case NET_SSH2_MSG_CHANNEL_OPEN: // see http://tools.ietf.org/html/rfc4254#section-5.1 + $this->_string_shift($payload, 1); + extract(unpack('Nlength', $this->_string_shift($payload, 4))); + $this->errors[] = 'SSH_MSG_CHANNEL_OPEN: ' . utf8_decode($this->_string_shift($payload, $length)); + + $this->_string_shift($payload, 4); // skip over client channel + extract(unpack('Nserver_channel', $this->_string_shift($payload, 4))); + + $packet = pack('CN3a*Na*', + NET_SSH2_MSG_REQUEST_FAILURE, $server_channel, NET_SSH2_OPEN_ADMINISTRATIVELY_PROHIBITED, 0, '', 0, ''); + + if (!$this->_send_binary_packet($packet)) { + return $this->_disconnect(NET_SSH2_DISCONNECT_BY_APPLICATION); + } + + $payload = $this->_get_binary_packet(); + break; + case NET_SSH2_MSG_CHANNEL_WINDOW_ADJUST: + $this->_string_shift($payload, 1); + extract(unpack('Nchannel', $this->_string_shift($payload, 4))); + extract(unpack('Nwindow_size', $this->_string_shift($payload, 4))); + $this->window_size_client_to_server[$channel]+= $window_size; + + $payload = ($this->bitmap & NET_SSH2_MASK_WINDOW_ADJUST) ? true : $this->_get_binary_packet(); + } + } + + return $payload; + } + + /** + * Enable Quiet Mode + * + * Suppress stderr from output + * + * @access public + */ + function enableQuietMode() + { + $this->quiet_mode = true; + } + + /** + * Disable Quiet Mode + * + * Show stderr in output + * + * @access public + */ + function disableQuietMode() + { + $this->quiet_mode = false; + } + + /** + * Enable request-pty when using exec() + * + * @access public + */ + function enablePTY() + { + $this->request_pty = true; + } + + /** + * Disable request-pty when using exec() + * + * @access public + */ + function disablePTY() + { + $this->request_pty = false; + } + + /** + * Gets channel data + * + * Returns the data as a string if it's available and false if not. + * + * @param $client_channel + * @return Mixed + * @access private + */ + function _get_channel_packet($client_channel, $skip_extended = false) + { + if (!empty($this->channel_buffers[$client_channel])) { + return array_shift($this->channel_buffers[$client_channel]); + } + + while (true) { + if ($this->curTimeout) { + if ($this->curTimeout < 0) { + $this->is_timeout = true; + return true; + } + + $read = array($this->fsock); + $write = $except = null; + + $start = strtok(microtime(), ' ') + strtok(''); // http://php.net/microtime#61838 + $sec = floor($this->curTimeout); + $usec = 1000000 * ($this->curTimeout - $sec); + // on windows this returns a "Warning: Invalid CRT parameters detected" error + if (!@stream_select($read, $write, $except, $sec, $usec) && !count($read)) { + $this->is_timeout = true; + return true; + } + $elapsed = strtok(microtime(), ' ') + strtok('') - $start; + $this->curTimeout-= $elapsed; + } + + $response = $this->_get_binary_packet(); + if ($response === false) { + user_error('Connection closed by server'); + return false; + } + if ($client_channel == -1 && $response === true) { + return true; + } + if (!strlen($response)) { + return ''; + } + + extract(unpack('Ctype/Nchannel', $this->_string_shift($response, 5))); + + $this->window_size_server_to_client[$channel]-= strlen($response) + 4; + + // resize the window, if appropriate + if ($this->window_size_server_to_client[$channel] < 0) { + $packet = pack('CNN', NET_SSH2_MSG_CHANNEL_WINDOW_ADJUST, $this->server_channels[$channel], $this->window_size); + if (!$this->_send_binary_packet($packet)) { + return false; + } + $this->window_size_server_to_client[$channel]+= $this->window_size; + } + + switch ($this->channel_status[$channel]) { + case NET_SSH2_MSG_CHANNEL_OPEN: + switch ($type) { + case NET_SSH2_MSG_CHANNEL_OPEN_CONFIRMATION: + extract(unpack('Nserver_channel', $this->_string_shift($response, 4))); + $this->server_channels[$channel] = $server_channel; + extract(unpack('Nwindow_size', $this->_string_shift($response, 4))); + $this->window_size_client_to_server[$channel] = $window_size; + $temp = unpack('Npacket_size_client_to_server', $this->_string_shift($response, 4)); + $this->packet_size_client_to_server[$channel] = $temp['packet_size_client_to_server']; + return $client_channel == $channel ? true : $this->_get_channel_packet($client_channel, $skip_extended); + //case NET_SSH2_MSG_CHANNEL_OPEN_FAILURE: + default: + user_error('Unable to open channel'); + return $this->_disconnect(NET_SSH2_DISCONNECT_BY_APPLICATION); + } + break; + case NET_SSH2_MSG_CHANNEL_REQUEST: + switch ($type) { + case NET_SSH2_MSG_CHANNEL_SUCCESS: + return true; + case NET_SSH2_MSG_CHANNEL_FAILURE: + return false; + default: + user_error('Unable to fulfill channel request'); + return $this->_disconnect(NET_SSH2_DISCONNECT_BY_APPLICATION); + } + case NET_SSH2_MSG_CHANNEL_CLOSE: + return $type == NET_SSH2_MSG_CHANNEL_CLOSE ? true : $this->_get_channel_packet($client_channel, $skip_extended); + } + + // ie. $this->channel_status[$channel] == NET_SSH2_MSG_CHANNEL_DATA + + switch ($type) { + case NET_SSH2_MSG_CHANNEL_DATA: + /* + if ($channel == NET_SSH2_CHANNEL_EXEC) { + // SCP requires null packets, such as this, be sent. further, in the case of the ssh.com SSH server + // this actually seems to make things twice as fast. more to the point, the message right after + // SSH_MSG_CHANNEL_DATA (usually SSH_MSG_IGNORE) won't block for as long as it would have otherwise. + // in OpenSSH it slows things down but only by a couple thousandths of a second. + $this->_send_channel_packet($channel, chr(0)); + } + */ + extract(unpack('Nlength', $this->_string_shift($response, 4))); + $data = $this->_string_shift($response, $length); + if ($client_channel == $channel) { + return $data; + } + if (!isset($this->channel_buffers[$channel])) { + $this->channel_buffers[$channel] = array(); + } + $this->channel_buffers[$channel][] = $data; + break; + case NET_SSH2_MSG_CHANNEL_EXTENDED_DATA: + /* + if ($client_channel == NET_SSH2_CHANNEL_EXEC) { + $this->_send_channel_packet($client_channel, chr(0)); + } + */ + // currently, there's only one possible value for $data_type_code: NET_SSH2_EXTENDED_DATA_STDERR + extract(unpack('Ndata_type_code/Nlength', $this->_string_shift($response, 8))); + $data = $this->_string_shift($response, $length); + $this->stdErrorLog .= $data; + if ($skip_extended || $this->quiet_mode) { + break; + } + if ($client_channel == $channel) { + return $data; + } + if (!isset($this->channel_buffers[$channel])) { + $this->channel_buffers[$channel] = array(); + } + $this->channel_buffers[$channel][] = $data; + break; + case NET_SSH2_MSG_CHANNEL_REQUEST: + extract(unpack('Nlength', $this->_string_shift($response, 4))); + $value = $this->_string_shift($response, $length); + switch ($value) { + case 'exit-signal': + $this->_string_shift($response, 1); + extract(unpack('Nlength', $this->_string_shift($response, 4))); + $this->errors[] = 'SSH_MSG_CHANNEL_REQUEST (exit-signal): ' . $this->_string_shift($response, $length); + $this->_string_shift($response, 1); + extract(unpack('Nlength', $this->_string_shift($response, 4))); + if ($length) { + $this->errors[count($this->errors)].= "\r\n" . $this->_string_shift($response, $length); + } + + $this->_send_binary_packet(pack('CN', NET_SSH2_MSG_CHANNEL_EOF, $this->server_channels[$client_channel])); + $this->_send_binary_packet(pack('CN', NET_SSH2_MSG_CHANNEL_CLOSE, $this->server_channels[$channel])); + + $this->channel_status[$channel] = NET_SSH2_MSG_CHANNEL_EOF; + + break; + case 'exit-status': + extract(unpack('Cfalse/Nexit_status', $this->_string_shift($response, 5))); + $this->exit_status = $exit_status; + + // "The client MAY ignore these messages." + // -- http://tools.ietf.org/html/rfc4254#section-6.10 + + break; + default: + // "Some systems may not implement signals, in which case they SHOULD ignore this message." + // -- http://tools.ietf.org/html/rfc4254#section-6.9 + break; + } + break; + case NET_SSH2_MSG_CHANNEL_CLOSE: + $this->curTimeout = 0; + + if ($this->bitmap & NET_SSH2_MASK_SHELL) { + $this->bitmap&= ~NET_SSH2_MASK_SHELL; + } + if ($this->channel_status[$channel] != NET_SSH2_MSG_CHANNEL_EOF) { + $this->_send_binary_packet(pack('CN', NET_SSH2_MSG_CHANNEL_CLOSE, $this->server_channels[$channel])); + } + + $this->channel_status[$channel] = NET_SSH2_MSG_CHANNEL_CLOSE; + return true; + case NET_SSH2_MSG_CHANNEL_EOF: + break; + default: + user_error('Error reading channel data'); + return $this->_disconnect(NET_SSH2_DISCONNECT_BY_APPLICATION); + } + } + } + + /** + * Sends Binary Packets + * + * See '6. Binary Packet Protocol' of rfc4253 for more info. + * + * @param String $data + * @param optional String $logged + * @see Net_SSH2::_get_binary_packet() + * @return Boolean + * @access private + */ + function _send_binary_packet($data, $logged = null) + { + if (!is_resource($this->fsock) || feof($this->fsock)) { + user_error('Connection closed prematurely'); + $this->bitmap = 0; + return false; + } + + //if ($this->compress) { + // // the -4 removes the checksum: + // // http://php.net/function.gzcompress#57710 + // $data = substr(gzcompress($data), 0, -4); + //} + + // 4 (packet length) + 1 (padding length) + 4 (minimal padding amount) == 9 + $packet_length = strlen($data) + 9; + // round up to the nearest $this->encrypt_block_size + $packet_length+= (($this->encrypt_block_size - 1) * $packet_length) % $this->encrypt_block_size; + // subtracting strlen($data) is obvious - subtracting 5 is necessary because of packet_length and padding_length + $padding_length = $packet_length - strlen($data) - 5; + $padding = crypt_random_string($padding_length); + + // we subtract 4 from packet_length because the packet_length field isn't supposed to include itself + $packet = pack('NCa*', $packet_length - 4, $padding_length, $data . $padding); + + $hmac = $this->hmac_create !== false ? $this->hmac_create->hash(pack('Na*', $this->send_seq_no, $packet)) : ''; + $this->send_seq_no++; + + if ($this->encrypt !== false) { + $packet = $this->encrypt->encrypt($packet); + } + + $packet.= $hmac; + + $start = strtok(microtime(), ' ') + strtok(''); // http://php.net/microtime#61838 + $result = strlen($packet) == fputs($this->fsock, $packet); + $stop = strtok(microtime(), ' ') + strtok(''); + + if (defined('NET_SSH2_LOGGING')) { + $current = strtok(microtime(), ' ') + strtok(''); + $message_number = isset($this->message_numbers[ord($data[0])]) ? $this->message_numbers[ord($data[0])] : 'UNKNOWN (' . ord($data[0]) . ')'; + $message_number = '-> ' . $message_number . + ' (since last: ' . round($current - $this->last_packet, 4) . ', network: ' . round($stop - $start, 4) . 's)'; + $this->_append_log($message_number, isset($logged) ? $logged : $data); + $this->last_packet = $current; + } + + return $result; + } + + /** + * Logs data packets + * + * Makes sure that only the last 1MB worth of packets will be logged + * + * @param String $data + * @access private + */ + function _append_log($message_number, $message) + { + // remove the byte identifying the message type from all but the first two messages (ie. the identification strings) + if (strlen($message_number) > 2) { + $this->_string_shift($message); + } + + switch (NET_SSH2_LOGGING) { + // useful for benchmarks + case NET_SSH2_LOG_SIMPLE: + $this->message_number_log[] = $message_number; + break; + // the most useful log for SSH2 + case NET_SSH2_LOG_COMPLEX: + $this->message_number_log[] = $message_number; + $this->log_size+= strlen($message); + $this->message_log[] = $message; + while ($this->log_size > NET_SSH2_LOG_MAX_SIZE) { + $this->log_size-= strlen(array_shift($this->message_log)); + array_shift($this->message_number_log); + } + break; + // dump the output out realtime; packets may be interspersed with non packets, + // passwords won't be filtered out and select other packets may not be correctly + // identified + case NET_SSH2_LOG_REALTIME: + switch (PHP_SAPI) { + case 'cli': + $start = $stop = "\r\n"; + break; + default: + $start = '
    ';
    +                        $stop = '
    '; + } + echo $start . $this->_format_log(array($message), array($message_number)) . $stop; + @flush(); + @ob_flush(); + break; + // basically the same thing as NET_SSH2_LOG_REALTIME with the caveat that NET_SSH2_LOG_REALTIME_FILE + // needs to be defined and that the resultant log file will be capped out at NET_SSH2_LOG_MAX_SIZE. + // the earliest part of the log file is denoted by the first <<< START >>> and is not going to necessarily + // at the beginning of the file + case NET_SSH2_LOG_REALTIME_FILE: + if (!isset($this->realtime_log_file)) { + // PHP doesn't seem to like using constants in fopen() + $filename = NET_SSH2_LOG_REALTIME_FILENAME; + $fp = fopen($filename, 'w'); + $this->realtime_log_file = $fp; + } + if (!is_resource($this->realtime_log_file)) { + break; + } + $entry = $this->_format_log(array($message), array($message_number)); + if ($this->realtime_log_wrap) { + $temp = "<<< START >>>\r\n"; + $entry.= $temp; + fseek($this->realtime_log_file, ftell($this->realtime_log_file) - strlen($temp)); + } + $this->realtime_log_size+= strlen($entry); + if ($this->realtime_log_size > NET_SSH2_LOG_MAX_SIZE) { + fseek($this->realtime_log_file, 0); + $this->realtime_log_size = strlen($entry); + $this->realtime_log_wrap = true; + } + fputs($this->realtime_log_file, $entry); + } + } + + /** + * Sends channel data + * + * Spans multiple SSH_MSG_CHANNEL_DATAs if appropriate + * + * @param Integer $client_channel + * @param String $data + * @return Boolean + * @access private + */ + function _send_channel_packet($client_channel, $data) + { + /* The maximum amount of data allowed is determined by the maximum + packet size for the channel, and the current window size, whichever + is smaller. + + -- http://tools.ietf.org/html/rfc4254#section-5.2 */ + $max_size = min( + $this->packet_size_client_to_server[$client_channel], + $this->window_size_client_to_server[$client_channel] + ) - 4; + while (strlen($data) > $max_size) { + if (!$this->window_size_client_to_server[$client_channel]) { + $this->bitmap^= NET_SSH2_MASK_WINDOW_ADJUST; + // using an invalid channel will let the buffers be built up for the valid channels + $output = $this->_get_channel_packet(-1); + $this->bitmap^= NET_SSH2_MASK_WINDOW_ADJUST; + $max_size = min( + $this->packet_size_client_to_server[$client_channel], + $this->window_size_client_to_server[$client_channel] + ) - 4; + } + + $packet = pack('CN2a*', + NET_SSH2_MSG_CHANNEL_DATA, + $this->server_channels[$client_channel], + $max_size, + $this->_string_shift($data, $max_size) + ); + + $this->window_size_client_to_server[$client_channel]-= $max_size + 4; + + if (!$this->_send_binary_packet($packet)) { + return false; + } + } + + if (strlen($data) >= $this->window_size_client_to_server[$client_channel] - 4) { + $this->bitmap^= NET_SSH2_MASK_WINDOW_ADJUST; + $this->_get_channel_packet(-1); + $this->bitmap^= NET_SSH2_MASK_WINDOW_ADJUST; + } + + $this->window_size_client_to_server[$client_channel]-= strlen($data) + 4; + + return $this->_send_binary_packet(pack('CN2a*', + NET_SSH2_MSG_CHANNEL_DATA, + $this->server_channels[$client_channel], + strlen($data), + $data)); + } + + /** + * Closes and flushes a channel + * + * Net_SSH2 doesn't properly close most channels. For exec() channels are normally closed by the server + * and for SFTP channels are presumably closed when the client disconnects. This functions is intended + * for SCP more than anything. + * + * @param Integer $client_channel + * @param Boolean $want_reply + * @return Boolean + * @access private + */ + function _close_channel($client_channel, $want_reply = false) + { + // see http://tools.ietf.org/html/rfc4254#section-5.3 + + $this->_send_binary_packet(pack('CN', NET_SSH2_MSG_CHANNEL_EOF, $this->server_channels[$client_channel])); + + if (!$want_reply) { + $this->_send_binary_packet(pack('CN', NET_SSH2_MSG_CHANNEL_CLOSE, $this->server_channels[$client_channel])); + } + + $this->channel_status[$client_channel] = NET_SSH2_MSG_CHANNEL_CLOSE; + + $this->curTimeout = 0; + + while (!is_bool($this->_get_channel_packet($client_channel))); + + if ($want_reply) { + $this->_send_binary_packet(pack('CN', NET_SSH2_MSG_CHANNEL_CLOSE, $this->server_channels[$client_channel])); + } + + if ($this->bitmap & NET_SSH2_MASK_SHELL) { + $this->bitmap&= ~NET_SSH2_MASK_SHELL; + } + } + + /** + * Disconnect + * + * @param Integer $reason + * @return Boolean + * @access private + */ + function _disconnect($reason) + { + if ($this->bitmap) { + $data = pack('CNNa*Na*', NET_SSH2_MSG_DISCONNECT, $reason, 0, '', 0, ''); + $this->_send_binary_packet($data); + $this->bitmap = 0; + fclose($this->fsock); + return false; + } + } + + /** + * String Shift + * + * Inspired by array_shift + * + * @param String $string + * @param optional Integer $index + * @return String + * @access private + */ + function _string_shift(&$string, $index = 1) + { + $substr = substr($string, 0, $index); + $string = substr($string, $index); + return $substr; + } + + /** + * Define Array + * + * Takes any number of arrays whose indices are integers and whose values are strings and defines a bunch of + * named constants from it, using the value as the name of the constant and the index as the value of the constant. + * If any of the constants that would be defined already exists, none of the constants will be defined. + * + * @param Array $array + * @access private + */ + function _define_array() + { + $args = func_get_args(); + foreach ($args as $arg) { + foreach ($arg as $key=>$value) { + if (!defined($value)) { + define($value, $key); + } else { + break 2; + } + } + } + } + + /** + * Returns a log of the packets that have been sent and received. + * + * Returns a string if NET_SSH2_LOGGING == NET_SSH2_LOG_COMPLEX, an array if NET_SSH2_LOGGING == NET_SSH2_LOG_SIMPLE and false if !defined('NET_SSH2_LOGGING') + * + * @access public + * @return String or Array + */ + function getLog() + { + if (!defined('NET_SSH2_LOGGING')) { + return false; + } + + switch (NET_SSH2_LOGGING) { + case NET_SSH2_LOG_SIMPLE: + return $this->message_number_log; + break; + case NET_SSH2_LOG_COMPLEX: + return $this->_format_log($this->message_log, $this->message_number_log); + break; + default: + return false; + } + } + + /** + * Formats a log for printing + * + * @param Array $message_log + * @param Array $message_number_log + * @access private + * @return String + */ + function _format_log($message_log, $message_number_log) + { + $output = ''; + for ($i = 0; $i < count($message_log); $i++) { + $output.= $message_number_log[$i] . "\r\n"; + $current_log = $message_log[$i]; + $j = 0; + do { + if (strlen($current_log)) { + $output.= str_pad(dechex($j), 7, '0', STR_PAD_LEFT) . '0 '; + } + $fragment = $this->_string_shift($current_log, $this->log_short_width); + $hex = substr(preg_replace_callback('#.#s', array($this, '_format_log_helper'), $fragment), strlen($this->log_boundary)); + // replace non ASCII printable characters with dots + // http://en.wikipedia.org/wiki/ASCII#ASCII_printable_characters + // also replace < with a . since < messes up the output on web browsers + $raw = preg_replace('#[^\x20-\x7E]|<#', '.', $fragment); + $output.= str_pad($hex, $this->log_long_width - $this->log_short_width, ' ') . $raw . "\r\n"; + $j++; + } while (strlen($current_log)); + $output.= "\r\n"; + } + + return $output; + } + + /** + * Helper function for _format_log + * + * For use with preg_replace_callback() + * + * @param Array $matches + * @access private + * @return String + */ + function _format_log_helper($matches) + { + return $this->log_boundary . str_pad(dechex(ord($matches[0])), 2, '0', STR_PAD_LEFT); + } + + /** + * Returns all errors + * + * @return String + * @access public + */ + function getErrors() + { + return $this->errors; + } + + /** + * Returns the last error + * + * @return String + * @access public + */ + function getLastError() + { + return $this->errors[count($this->errors) - 1]; + } + + /** + * Return the server identification. + * + * @return String + * @access public + */ + function getServerIdentification() + { + return $this->server_identifier; + } + + /** + * Return a list of the key exchange algorithms the server supports. + * + * @return Array + * @access public + */ + function getKexAlgorithms() + { + return $this->kex_algorithms; + } + + /** + * Return a list of the host key (public key) algorithms the server supports. + * + * @return Array + * @access public + */ + function getServerHostKeyAlgorithms() + { + return $this->server_host_key_algorithms; + } + + /** + * Return a list of the (symmetric key) encryption algorithms the server supports, when receiving stuff from the client. + * + * @return Array + * @access public + */ + function getEncryptionAlgorithmsClient2Server() + { + return $this->encryption_algorithms_client_to_server; + } + + /** + * Return a list of the (symmetric key) encryption algorithms the server supports, when sending stuff to the client. + * + * @return Array + * @access public + */ + function getEncryptionAlgorithmsServer2Client() + { + return $this->encryption_algorithms_server_to_client; + } + + /** + * Return a list of the MAC algorithms the server supports, when receiving stuff from the client. + * + * @return Array + * @access public + */ + function getMACAlgorithmsClient2Server() + { + return $this->mac_algorithms_client_to_server; + } + + /** + * Return a list of the MAC algorithms the server supports, when sending stuff to the client. + * + * @return Array + * @access public + */ + function getMACAlgorithmsServer2Client() + { + return $this->mac_algorithms_server_to_client; + } + + /** + * Return a list of the compression algorithms the server supports, when receiving stuff from the client. + * + * @return Array + * @access public + */ + function getCompressionAlgorithmsClient2Server() + { + return $this->compression_algorithms_client_to_server; + } + + /** + * Return a list of the compression algorithms the server supports, when sending stuff to the client. + * + * @return Array + * @access public + */ + function getCompressionAlgorithmsServer2Client() + { + return $this->compression_algorithms_server_to_client; + } + + /** + * Return a list of the languages the server supports, when sending stuff to the client. + * + * @return Array + * @access public + */ + function getLanguagesServer2Client() + { + return $this->languages_server_to_client; + } + + /** + * Return a list of the languages the server supports, when receiving stuff from the client. + * + * @return Array + * @access public + */ + function getLanguagesClient2Server() + { + return $this->languages_client_to_server; + } + + /** + * Returns the banner message. + * + * Quoting from the RFC, "in some jurisdictions, sending a warning message before + * authentication may be relevant for getting legal protection." + * + * @return String + * @access public + */ + function getBannerMessage() + { + return $this->banner_message; + } + + /** + * Returns the server public host key. + * + * Caching this the first time you connect to a server and checking the result on subsequent connections + * is recommended. Returns false if the server signature is not signed correctly with the public host key. + * + * @return Mixed + * @access public + */ + function getServerPublicHostKey() + { + $signature = $this->signature; + $server_public_host_key = $this->server_public_host_key; + + extract(unpack('Nlength', $this->_string_shift($server_public_host_key, 4))); + $this->_string_shift($server_public_host_key, $length); + + if ($this->signature_validated) { + return $this->bitmap ? + $this->signature_format . ' ' . base64_encode($this->server_public_host_key) : + false; + } + + $this->signature_validated = true; + + switch ($this->signature_format) { + case 'ssh-dss': + $zero = new Math_BigInteger(); + + $temp = unpack('Nlength', $this->_string_shift($server_public_host_key, 4)); + $p = new Math_BigInteger($this->_string_shift($server_public_host_key, $temp['length']), -256); + + $temp = unpack('Nlength', $this->_string_shift($server_public_host_key, 4)); + $q = new Math_BigInteger($this->_string_shift($server_public_host_key, $temp['length']), -256); + + $temp = unpack('Nlength', $this->_string_shift($server_public_host_key, 4)); + $g = new Math_BigInteger($this->_string_shift($server_public_host_key, $temp['length']), -256); + + $temp = unpack('Nlength', $this->_string_shift($server_public_host_key, 4)); + $y = new Math_BigInteger($this->_string_shift($server_public_host_key, $temp['length']), -256); + + /* The value for 'dss_signature_blob' is encoded as a string containing + r, followed by s (which are 160-bit integers, without lengths or + padding, unsigned, and in network byte order). */ + $temp = unpack('Nlength', $this->_string_shift($signature, 4)); + if ($temp['length'] != 40) { + user_error('Invalid signature'); + return $this->_disconnect(NET_SSH2_DISCONNECT_KEY_EXCHANGE_FAILED); + } + + $r = new Math_BigInteger($this->_string_shift($signature, 20), 256); + $s = new Math_BigInteger($this->_string_shift($signature, 20), 256); + + switch (true) { + case $r->equals($zero): + case $r->compare($q) >= 0: + case $s->equals($zero): + case $s->compare($q) >= 0: + user_error('Invalid signature'); + return $this->_disconnect(NET_SSH2_DISCONNECT_KEY_EXCHANGE_FAILED); + } + + $w = $s->modInverse($q); + + $u1 = $w->multiply(new Math_BigInteger(sha1($this->exchange_hash), 16)); + list(, $u1) = $u1->divide($q); + + $u2 = $w->multiply($r); + list(, $u2) = $u2->divide($q); + + $g = $g->modPow($u1, $p); + $y = $y->modPow($u2, $p); + + $v = $g->multiply($y); + list(, $v) = $v->divide($p); + list(, $v) = $v->divide($q); + + if (!$v->equals($r)) { + user_error('Bad server signature'); + return $this->_disconnect(NET_SSH2_DISCONNECT_HOST_KEY_NOT_VERIFIABLE); + } + + break; + case 'ssh-rsa': + $temp = unpack('Nlength', $this->_string_shift($server_public_host_key, 4)); + $e = new Math_BigInteger($this->_string_shift($server_public_host_key, $temp['length']), -256); + + $temp = unpack('Nlength', $this->_string_shift($server_public_host_key, 4)); + $n = new Math_BigInteger($this->_string_shift($server_public_host_key, $temp['length']), -256); + $nLength = $temp['length']; + + /* + $temp = unpack('Nlength', $this->_string_shift($signature, 4)); + $signature = $this->_string_shift($signature, $temp['length']); + + if (!class_exists('Crypt_RSA')) { + include_once 'Crypt/RSA.php'; + } + + $rsa = new Crypt_RSA(); + $rsa->setSignatureMode(CRYPT_RSA_SIGNATURE_PKCS1); + $rsa->loadKey(array('e' => $e, 'n' => $n), CRYPT_RSA_PUBLIC_FORMAT_RAW); + if (!$rsa->verify($this->exchange_hash, $signature)) { + user_error('Bad server signature'); + return $this->_disconnect(NET_SSH2_DISCONNECT_HOST_KEY_NOT_VERIFIABLE); + } + */ + + $temp = unpack('Nlength', $this->_string_shift($signature, 4)); + $s = new Math_BigInteger($this->_string_shift($signature, $temp['length']), 256); + + // validate an RSA signature per "8.2 RSASSA-PKCS1-v1_5", "5.2.2 RSAVP1", and "9.1 EMSA-PSS" in the + // following URL: + // ftp://ftp.rsasecurity.com/pub/pkcs/pkcs-1/pkcs-1v2-1.pdf + + // also, see SSHRSA.c (rsa2_verifysig) in PuTTy's source. + + if ($s->compare(new Math_BigInteger()) < 0 || $s->compare($n->subtract(new Math_BigInteger(1))) > 0) { + user_error('Invalid signature'); + return $this->_disconnect(NET_SSH2_DISCONNECT_KEY_EXCHANGE_FAILED); + } + + $s = $s->modPow($e, $n); + $s = $s->toBytes(); + + $h = pack('N4H*', 0x00302130, 0x0906052B, 0x0E03021A, 0x05000414, sha1($this->exchange_hash)); + $h = chr(0x01) . str_repeat(chr(0xFF), $nLength - 3 - strlen($h)) . $h; + + if ($s != $h) { + user_error('Bad server signature'); + return $this->_disconnect(NET_SSH2_DISCONNECT_HOST_KEY_NOT_VERIFIABLE); + } + break; + default: + user_error('Unsupported signature format'); + return $this->_disconnect(NET_SSH2_DISCONNECT_HOST_KEY_NOT_VERIFIABLE); + } + + return $this->signature_format . ' ' . base64_encode($this->server_public_host_key); + } + + /** + * Returns the exit status of an SSH command or false. + * + * @return Integer or false + * @access public + */ + function getExitStatus() + { + if (is_null($this->exit_status)) { + return false; + } + return $this->exit_status; + } + + /** + * Is a path includable? + * + * @return Boolean + * @access private + */ + function _is_includable($suffix) + { + // stream_resolve_include_path was introduced in PHP 5.3.2 + if (function_exists('stream_resolve_include_path')) { + return stream_resolve_include_path($suffix) !== false; + } + + $paths = PATH_SEPARATOR == ':' ? + preg_split('#(? + * login('username', $agent)) { + * exit('Login Failed'); + * } + * + * echo $ssh->exec('pwd'); + * echo $ssh->exec('ls -la'); + * ?> + * + * + * LICENSE: Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * @category System + * @package System_SSH_Agent + * @author Jim Wigginton + * @copyright MMXIV Jim Wigginton + * @license http://www.opensource.org/licenses/mit-license.html MIT License + * @link http://phpseclib.sourceforge.net + * @internal See http://api.libssh.org/rfc/PROTOCOL.agent + */ + +/**#@+ + * Message numbers + * + * @access private + */ +// to request SSH1 keys you have to use SSH_AGENTC_REQUEST_RSA_IDENTITIES (1) +define('SYSTEM_SSH_AGENTC_REQUEST_IDENTITIES', 11); +// this is the SSH2 response; the SSH1 response is SSH_AGENT_RSA_IDENTITIES_ANSWER (2). +define('SYSTEM_SSH_AGENT_IDENTITIES_ANSWER', 12); +define('SYSTEM_SSH_AGENT_FAILURE', 5); +// the SSH1 request is SSH_AGENTC_RSA_CHALLENGE (3) +define('SYSTEM_SSH_AGENTC_SIGN_REQUEST', 13); +// the SSH1 response is SSH_AGENT_RSA_RESPONSE (4) +define('SYSTEM_SSH_AGENT_SIGN_RESPONSE', 14); +/**#@-*/ + +/** + * Pure-PHP ssh-agent client identity object + * + * Instantiation should only be performed by System_SSH_Agent class. + * This could be thought of as implementing an interface that Crypt_RSA + * implements. ie. maybe a Net_SSH_Auth_PublicKey interface or something. + * The methods in this interface would be getPublicKey, setSignatureMode + * and sign since those are the methods phpseclib looks for to perform + * public key authentication. + * + * @package System_SSH_Agent + * @author Jim Wigginton + * @version 0.1.0 + * @access internal + */ +class System_SSH_Agent_Identity +{ + /** + * Key Object + * + * @var Crypt_RSA + * @access private + * @see System_SSH_Agent_Identity::getPublicKey() + */ + var $key; + + /** + * Key Blob + * + * @var String + * @access private + * @see System_SSH_Agent_Identity::sign() + */ + var $key_blob; + + /** + * Socket Resource + * + * @var Resource + * @access private + * @see System_SSH_Agent_Identity::sign() + */ + var $fsock; + + /** + * Default Constructor. + * + * @param Resource $fsock + * @return System_SSH_Agent_Identity + * @access private + */ + function System_SSH_Agent_Identity($fsock) + { + $this->fsock = $fsock; + } + + /** + * Set Public Key + * + * Called by System_SSH_Agent::requestIdentities() + * + * @param Crypt_RSA $key + * @access private + */ + function setPublicKey($key) + { + $this->key = $key; + $this->key->setPublicKey(); + } + + /** + * Set Public Key + * + * Called by System_SSH_Agent::requestIdentities(). The key blob could be extracted from $this->key + * but this saves a small amount of computation. + * + * @param String $key_blob + * @access private + */ + function setPublicKeyBlob($key_blob) + { + $this->key_blob = $key_blob; + } + + /** + * Get Public Key + * + * Wrapper for $this->key->getPublicKey() + * + * @param Integer $format optional + * @return Mixed + * @access public + */ + function getPublicKey($format = null) + { + return !isset($format) ? $this->key->getPublicKey() : $this->key->getPublicKey($format); + } + + /** + * Set Signature Mode + * + * Doesn't do anything as ssh-agent doesn't let you pick and choose the signature mode. ie. + * ssh-agent's only supported mode is CRYPT_RSA_SIGNATURE_PKCS1 + * + * @param Integer $mode + * @access public + */ + function setSignatureMode($mode) + { + } + + /** + * Create a signature + * + * See "2.6.2 Protocol 2 private key signature request" + * + * @param String $message + * @return String + * @access public + */ + function sign($message) + { + // the last parameter (currently 0) is for flags and ssh-agent only defines one flag (for ssh-dss): SSH_AGENT_OLD_SIGNATURE + $packet = pack('CNa*Na*N', SYSTEM_SSH_AGENTC_SIGN_REQUEST, strlen($this->key_blob), $this->key_blob, strlen($message), $message, 0); + $packet = pack('Na*', strlen($packet), $packet); + if (strlen($packet) != fputs($this->fsock, $packet)) { + user_error('Connection closed during signing'); + } + + $length = current(unpack('N', fread($this->fsock, 4))); + $type = ord(fread($this->fsock, 1)); + if ($type != SYSTEM_SSH_AGENT_SIGN_RESPONSE) { + user_error('Unable to retreive signature'); + } + + $signature_blob = fread($this->fsock, $length - 1); + // the only other signature format defined - ssh-dss - is the same length as ssh-rsa + // the + 12 is for the other various SSH added length fields + return substr($signature_blob, strlen('ssh-rsa') + 12); + } +} + +/** + * Pure-PHP ssh-agent client identity factory + * + * requestIdentities() method pumps out System_SSH_Agent_Identity objects + * + * @package System_SSH_Agent + * @author Jim Wigginton + * @version 0.1.0 + * @access internal + */ +class System_SSH_Agent +{ + /** + * Socket Resource + * + * @var Resource + * @access private + */ + var $fsock; + + /** + * Default Constructor + * + * @return System_SSH_Agent + * @access public + */ + function System_SSH_Agent() + { + switch (true) { + case isset($_SERVER['SSH_AUTH_SOCK']): + $address = $_SERVER['SSH_AUTH_SOCK']; + break; + case isset($_ENV['SSH_AUTH_SOCK']): + $address = $_ENV['SSH_AUTH_SOCK']; + break; + default: + user_error('SSH_AUTH_SOCK not found'); + return false; + } + + $this->fsock = fsockopen('unix://' . $address, 0, $errno, $errstr); + if (!$this->fsock) { + user_error("Unable to connect to ssh-agent (Error $errno: $errstr)"); + } + } + + /** + * Request Identities + * + * See "2.5.2 Requesting a list of protocol 2 keys" + * Returns an array containing zero or more System_SSH_Agent_Identity objects + * + * @return Array + * @access public + */ + function requestIdentities() + { + if (!$this->fsock) { + return array(); + } + + $packet = pack('NC', 1, SYSTEM_SSH_AGENTC_REQUEST_IDENTITIES); + if (strlen($packet) != fputs($this->fsock, $packet)) { + user_error('Connection closed while requesting identities'); + } + + $length = current(unpack('N', fread($this->fsock, 4))); + $type = ord(fread($this->fsock, 1)); + if ($type != SYSTEM_SSH_AGENT_IDENTITIES_ANSWER) { + user_error('Unable to request identities'); + } + + $identities = array(); + $keyCount = current(unpack('N', fread($this->fsock, 4))); + for ($i = 0; $i < $keyCount; $i++) { + $length = current(unpack('N', fread($this->fsock, 4))); + $key_blob = fread($this->fsock, $length); + $length = current(unpack('N', fread($this->fsock, 4))); + $key_comment = fread($this->fsock, $length); + $length = current(unpack('N', substr($key_blob, 0, 4))); + $key_type = substr($key_blob, 4, $length); + switch ($key_type) { + case 'ssh-rsa': + if (!class_exists('Crypt_RSA')) { + include_once 'Crypt/RSA.php'; + } + $key = new Crypt_RSA(); + $key->loadKey('ssh-rsa ' . base64_encode($key_blob) . ' ' . $key_comment); + break; + case 'ssh-dss': + // not currently supported + break; + } + // resources are passed by reference by default + if (isset($key)) { + $identity = new System_SSH_Agent_Identity($this->fsock); + $identity->setPublicKey($key); + $identity->setPublicKeyBlob($key_blob); + $identities[] = $identity; + unset($key); + } + } + + return $identities; + } +} diff --git a/vendor/phpseclib/phpseclib/phpseclib/openssl.cnf b/vendor/phpseclib/phpseclib/phpseclib/openssl.cnf new file mode 100755 index 0000000..2b8b52f --- /dev/null +++ b/vendor/phpseclib/phpseclib/phpseclib/openssl.cnf @@ -0,0 +1,6 @@ +# minimalist openssl.cnf file for use with phpseclib + +HOME = . +RANDFILE = $ENV::HOME/.rnd + +[ v3_ca ] diff --git a/vendor/phpseclib/phpseclib/phpunit.xml.dist b/vendor/phpseclib/phpseclib/phpunit.xml.dist new file mode 100755 index 0000000..f579ab4 --- /dev/null +++ b/vendor/phpseclib/phpseclib/phpunit.xml.dist @@ -0,0 +1,18 @@ + + + + + + ./tests/ + + + + + + + ./phpseclib/ + + + diff --git a/vendor/phpseclib/phpseclib/tests/Crypt/AES/ContinuousBufferTest.php b/vendor/phpseclib/phpseclib/tests/Crypt/AES/ContinuousBufferTest.php new file mode 100755 index 0000000..1d71259 --- /dev/null +++ b/vendor/phpseclib/phpseclib/tests/Crypt/AES/ContinuousBufferTest.php @@ -0,0 +1,72 @@ + + * @copyright MMXIII Andreas Fischer + * @license http://www.opensource.org/licenses/mit-license.html MIT License + */ + +class Crypt_AES_ContinuousBufferTest extends Crypt_AES_TestCase +{ + // String intented + protected $modes = array( + 'CRYPT_AES_MODE_CTR', + 'CRYPT_AES_MODE_OFB', + 'CRYPT_AES_MODE_CFB', + ); + + protected $plaintexts = array( + '', + '12345678901234567', // https://github.com/phpseclib/phpseclib/issues/39 + "\xDE\xAD\xBE\xAF", + ':-):-):-):-):-):-)', // https://github.com/phpseclib/phpseclib/pull/43 + ); + + protected $ivs = array( + '', + 'test123', + ); + + protected $keys = array( + '', + ':-8', // https://github.com/phpseclib/phpseclib/pull/43 + 'FOOBARZ', + ); + + /** + * Produces all combinations of test values. + * + * @return array + */ + public function allCombinations() + { + $result = array(); + + // @codingStandardsIgnoreStart + foreach ($this->modes as $mode) + foreach ($this->plaintexts as $plaintext) + foreach ($this->ivs as $iv) + foreach ($this->keys as $key) + $result[] = array($mode, $plaintext, $iv, $key); + // @codingStandardsIgnoreEnd + + return $result; + } + + /** + * @dataProvider allCombinations + */ + public function testEncryptDecrypt($mode, $plaintext, $iv, $key) + { + $aes = new Crypt_AES(constant($mode)); + $aes->enableContinuousBuffer(); + $aes->setIV($iv); + $aes->setKey($key); + + $actual = ''; + for ($i = 0, $strlen = strlen($plaintext); $i < $strlen; ++$i) { + $actual .= $aes->decrypt($aes->encrypt($plaintext[$i])); + } + + $this->assertEquals($plaintext, $actual); + } +} diff --git a/vendor/phpseclib/phpseclib/tests/Crypt/AES/TestCase.php b/vendor/phpseclib/phpseclib/tests/Crypt/AES/TestCase.php new file mode 100755 index 0000000..317f1e5 --- /dev/null +++ b/vendor/phpseclib/phpseclib/tests/Crypt/AES/TestCase.php @@ -0,0 +1,27 @@ + + * @copyright MMXIII Andreas Fischer + * @license http://www.opensource.org/licenses/mit-license.html MIT License + */ + +require_once 'Crypt/AES.php'; + +abstract class Crypt_AES_TestCase extends PhpseclibTestCase +{ + static public function setUpBeforeClass() + { + if (!defined('CRYPT_AES_MODE')) { + define('CRYPT_AES_MODE', CRYPT_AES_MODE_INTERNAL); + } + } + + public function setUp() + { + if (defined('CRYPT_AES_MODE') && CRYPT_AES_MODE !== CRYPT_AES_MODE_INTERNAL) { + $this->markTestSkipped( + 'Skipping test because CRYPT_AES_MODE is not defined as CRYPT_AES_MODE_INTERNAL.' + ); + } + } +} diff --git a/vendor/phpseclib/phpseclib/tests/Crypt/Hash/MD5Test.php b/vendor/phpseclib/phpseclib/tests/Crypt/Hash/MD5Test.php new file mode 100755 index 0000000..4b0635d --- /dev/null +++ b/vendor/phpseclib/phpseclib/tests/Crypt/Hash/MD5Test.php @@ -0,0 +1,47 @@ + + * @copyright MMXII Andreas Fischer + * @license http://www.opensource.org/licenses/mit-license.html MIT License + */ + +class Crypt_Hash_MD5Test extends Crypt_Hash_TestCase +{ + public function getInstance() + { + return new Crypt_Hash('md5'); + } + + /** + * @dataProvider hashData() + */ + public function testHash($message, $result) + { + $this->assertHashesTo($this->getInstance(), $message, $result); + } + + static public function hashData() + { + return array( + array('', 'd41d8cd98f00b204e9800998ecf8427e'), + array('The quick brown fox jumps over the lazy dog', '9e107d9d372bb6826bd81d3542a419d6'), + array('The quick brown fox jumps over the lazy dog.', 'e4d909c290d0fb1ca068ffaddf22cbd0'), + ); + } + + /** + * @dataProvider hmacData() + */ + public function testHMAC($key, $message, $result) + { + $this->assertHMACsTo($this->getInstance(), $key, $message, $result); + } + + static public function hmacData() + { + return array( + array('', '', '74e6f7298a9c2d168935f58c001bad88'), + array('key', 'The quick brown fox jumps over the lazy dog', '80070713463e7749b90c2dc24911e275'), + ); + } +} diff --git a/vendor/phpseclib/phpseclib/tests/Crypt/Hash/TestCase.php b/vendor/phpseclib/phpseclib/tests/Crypt/Hash/TestCase.php new file mode 100755 index 0000000..5f46975 --- /dev/null +++ b/vendor/phpseclib/phpseclib/tests/Crypt/Hash/TestCase.php @@ -0,0 +1,52 @@ + + * @copyright MMXII Andreas Fischer + * @license http://www.opensource.org/licenses/mit-license.html MIT License + */ + +require_once 'Crypt/Hash.php'; + +abstract class Crypt_Hash_TestCase extends PhpseclibTestCase +{ + static public function setUpBeforeClass() + { + if (!defined('CRYPT_HASH_MODE')) { + define('CRYPT_HASH_MODE', CRYPT_HASH_MODE_INTERNAL); + } + } + + public function setUp() + { + if (defined('CRYPT_HASH_MODE') && CRYPT_HASH_MODE !== CRYPT_HASH_MODE_INTERNAL) { + $this->markTestSkipped( + 'Skipping test because CRYPT_HASH_MODE is not defined as CRYPT_HASH_MODE_INTERNAL.' + ); + } + } + + protected function assertHashesTo(Crypt_Hash $hash, $message, $expected) + { + $this->assertEquals( + strtolower($expected), + bin2hex($hash->hash($message)), + sprintf("Failed asserting that '%s' hashes to '%s'.", $message, $expected) + ); + } + + protected function assertHMACsTo(Crypt_Hash $hash, $key, $message, $expected) + { + $hash->setKey($key); + + $this->assertEquals( + strtolower($expected), + bin2hex($hash->hash($message)), + sprintf( + "Failed asserting that '%s' HMACs to '%s' with key '%s'.", + $message, + $expected, + $key + ) + ); + } +} diff --git a/vendor/phpseclib/phpseclib/tests/Crypt/RSA/LoadKeyTest.php b/vendor/phpseclib/phpseclib/tests/Crypt/RSA/LoadKeyTest.php new file mode 100755 index 0000000..95239d8 --- /dev/null +++ b/vendor/phpseclib/phpseclib/tests/Crypt/RSA/LoadKeyTest.php @@ -0,0 +1,120 @@ + + * @copyright MMXIII Jim Wigginton + * @license http://www.opensource.org/licenses/mit-license.html MIT License + */ + +require_once 'Crypt/RSA.php' ; + +class Crypt_RSA_LoadKeyTest extends PhpseclibTestCase +{ + public function testBadKey() + { + $rsa = new Crypt_RSA(); + + $key = 'zzzzzzzzzzzzzz'; + + $this->assertFalse($rsa->loadKey($key)); + } + + public function testPKCS1Key() + { + $rsa = new Crypt_RSA(); + + $key = '-----BEGIN RSA PRIVATE KEY----- +MIICXAIBAAKBgQCqGKukO1De7zhZj6+H0qtjTkVxwTCpvKe4eCZ0FPqri0cb2JZfXJ/DgYSF6vUp +wmJG8wVQZKjeGcjDOL5UlsuusFncCzWBQ7RKNUSesmQRMSGkVb1/3j+skZ6UtW+5u09lHNsj6tQ5 +1s1SPrCBkedbNf0Tp0GbMJDyR4e9T04ZZwIDAQABAoGAFijko56+qGyN8M0RVyaRAXz++xTqHBLh +3tx4VgMtrQ+WEgCjhoTwo23KMBAuJGSYnRmoBZM3lMfTKevIkAidPExvYCdm5dYq3XToLkkLv5L2 +pIIVOFMDG+KESnAFV7l2c+cnzRMW0+b6f8mR1CJzZuxVLL6Q02fvLi55/mbSYxECQQDeAw6fiIQX +GukBI4eMZZt4nscy2o12KyYner3VpoeE+Np2q+Z3pvAMd/aNzQ/W9WaI+NRfcxUJrmfPwIGm63il +AkEAxCL5HQb2bQr4ByorcMWm/hEP2MZzROV73yF41hPsRC9m66KrheO9HPTJuo3/9s5p+sqGxOlF +L0NDt4SkosjgGwJAFklyR1uZ/wPJjj611cdBcztlPdqoxssQGnh85BzCj/u3WqBpE2vjvyyvyI5k +X6zk7S0ljKtt2jny2+00VsBerQJBAJGC1Mg5Oydo5NwD6BiROrPxGo2bpTbu/fhrT8ebHkTz2epl +U9VQQSQzY1oZMVX8i1m5WUTLPz2yLJIBQVdXqhMCQBGoiuSoSjafUhV7i1cEGpb88h5NBYZzWXGZ +37sJ5QsW+sJyoNde3xH8vdXhzU7eT82D6X/scw9RZz+/6rCJ4p0= +-----END RSA PRIVATE KEY-----'; + + $this->assertTrue($rsa->loadKey($key)); + } + + public function testPKCS1SpacesKey() + { + $rsa = new Crypt_RSA(); + + $key = '-----BEGIN RSA PRIVATE KEY----- +MIICXAIBAAKBgQCqGKukO1De7zhZj6+H0qtjTkVxwTCpvKe4eCZ0FPqri0cb2JZfXJ/DgYSF6vUp +wmJG8wVQZKjeGcjDOL5UlsuusFncCzWBQ7RKNUSesmQRMSGkVb1/3j+skZ6UtW+5u09lHNsj6tQ5 +1s1SPrCBkedbNf0Tp0GbMJDyR4e9T04ZZwIDAQABAoGAFijko56+qGyN8M0RVyaRAXz++xTqHBLh +3tx4VgMtrQ+WEgCjhoTwo23KMBAuJGSYnRmoBZM3lMfTKevIkAidPExvYCdm5dYq3XToLkkLv5L2 +pIIVOFMDG+KESnAFV7l2c+cnzRMW0+b6f8mR1CJzZuxVLL6Q02fvLi55/mbSYxECQQDeAw6fiIQX +GukBI4eMZZt4nscy2o12KyYner3VpoeE+Np2q+Z3pvAMd/aNzQ/W9WaI+NRfcxUJrmfPwIGm63il +AkEAxCL5HQb2bQr4ByorcMWm/hEP2MZzROV73yF41hPsRC9m66KrheO9HPTJuo3/9s5p+sqGxOlF +L0NDt4SkosjgGwJAFklyR1uZ/wPJjj611cdBcztlPdqoxssQGnh85BzCj/u3WqBpE2vjvyyvyI5k +X6zk7S0ljKtt2jny2+00VsBerQJBAJGC1Mg5Oydo5NwD6BiROrPxGo2bpTbu/fhrT8ebHkTz2epl +U9VQQSQzY1oZMVX8i1m5WUTLPz2yLJIBQVdXqhMCQBGoiuSoSjafUhV7i1cEGpb88h5NBYZzWXGZ +37sJ5QsW+sJyoNde3xH8vdXhzU7eT82D6X/scw9RZz+/6rCJ4p0= +-----END RSA PRIVATE KEY-----'; + $key = str_replace(array("\r", "\n", "\r\n"), ' ', $key); + + $this->assertTrue($rsa->loadKey($key)); + } + + public function testPKCS1NoHeaderKey() + { + $rsa = new Crypt_RSA(); + + $key = 'MIICXAIBAAKBgQCqGKukO1De7zhZj6+H0qtjTkVxwTCpvKe4eCZ0FPqri0cb2JZfXJ/DgYSF6vUp +wmJG8wVQZKjeGcjDOL5UlsuusFncCzWBQ7RKNUSesmQRMSGkVb1/3j+skZ6UtW+5u09lHNsj6tQ5 +1s1SPrCBkedbNf0Tp0GbMJDyR4e9T04ZZwIDAQABAoGAFijko56+qGyN8M0RVyaRAXz++xTqHBLh +3tx4VgMtrQ+WEgCjhoTwo23KMBAuJGSYnRmoBZM3lMfTKevIkAidPExvYCdm5dYq3XToLkkLv5L2 +pIIVOFMDG+KESnAFV7l2c+cnzRMW0+b6f8mR1CJzZuxVLL6Q02fvLi55/mbSYxECQQDeAw6fiIQX +GukBI4eMZZt4nscy2o12KyYner3VpoeE+Np2q+Z3pvAMd/aNzQ/W9WaI+NRfcxUJrmfPwIGm63il +AkEAxCL5HQb2bQr4ByorcMWm/hEP2MZzROV73yF41hPsRC9m66KrheO9HPTJuo3/9s5p+sqGxOlF +L0NDt4SkosjgGwJAFklyR1uZ/wPJjj611cdBcztlPdqoxssQGnh85BzCj/u3WqBpE2vjvyyvyI5k +X6zk7S0ljKtt2jny2+00VsBerQJBAJGC1Mg5Oydo5NwD6BiROrPxGo2bpTbu/fhrT8ebHkTz2epl +U9VQQSQzY1oZMVX8i1m5WUTLPz2yLJIBQVdXqhMCQBGoiuSoSjafUhV7i1cEGpb88h5NBYZzWXGZ +37sJ5QsW+sJyoNde3xH8vdXhzU7eT82D6X/scw9RZz+/6rCJ4p0='; + + $this->assertTrue($rsa->loadKey($key)); + } + + public function testPKCS1NoWhitespaceNoHeaderKey() + { + $rsa = new Crypt_RSA(); + + $key = 'MIICXAIBAAKBgQCqGKukO1De7zhZj6+H0qtjTkVxwTCpvKe4eCZ0FPqri0cb2JZfXJ/DgYSF6vUp' . + 'wmJG8wVQZKjeGcjDOL5UlsuusFncCzWBQ7RKNUSesmQRMSGkVb1/3j+skZ6UtW+5u09lHNsj6tQ5' . + '1s1SPrCBkedbNf0Tp0GbMJDyR4e9T04ZZwIDAQABAoGAFijko56+qGyN8M0RVyaRAXz++xTqHBLh' . + '3tx4VgMtrQ+WEgCjhoTwo23KMBAuJGSYnRmoBZM3lMfTKevIkAidPExvYCdm5dYq3XToLkkLv5L2' . + 'pIIVOFMDG+KESnAFV7l2c+cnzRMW0+b6f8mR1CJzZuxVLL6Q02fvLi55/mbSYxECQQDeAw6fiIQX' . + 'GukBI4eMZZt4nscy2o12KyYner3VpoeE+Np2q+Z3pvAMd/aNzQ/W9WaI+NRfcxUJrmfPwIGm63il' . + 'AkEAxCL5HQb2bQr4ByorcMWm/hEP2MZzROV73yF41hPsRC9m66KrheO9HPTJuo3/9s5p+sqGxOlF' . + 'L0NDt4SkosjgGwJAFklyR1uZ/wPJjj611cdBcztlPdqoxssQGnh85BzCj/u3WqBpE2vjvyyvyI5k' . + 'X6zk7S0ljKtt2jny2+00VsBerQJBAJGC1Mg5Oydo5NwD6BiROrPxGo2bpTbu/fhrT8ebHkTz2epl' . + 'U9VQQSQzY1oZMVX8i1m5WUTLPz2yLJIBQVdXqhMCQBGoiuSoSjafUhV7i1cEGpb88h5NBYZzWXGZ' . + '37sJ5QsW+sJyoNde3xH8vdXhzU7eT82D6X/scw9RZz+/6rCJ4p0='; + $this->assertTrue($rsa->loadKey($key)); + } + + public function testRawPKCS1Key() + { + $rsa = new Crypt_RSA(); + + $key = 'MIICXAIBAAKBgQCqGKukO1De7zhZj6+H0qtjTkVxwTCpvKe4eCZ0FPqri0cb2JZfXJ/DgYSF6vUp' . + 'wmJG8wVQZKjeGcjDOL5UlsuusFncCzWBQ7RKNUSesmQRMSGkVb1/3j+skZ6UtW+5u09lHNsj6tQ5' . + '1s1SPrCBkedbNf0Tp0GbMJDyR4e9T04ZZwIDAQABAoGAFijko56+qGyN8M0RVyaRAXz++xTqHBLh' . + '3tx4VgMtrQ+WEgCjhoTwo23KMBAuJGSYnRmoBZM3lMfTKevIkAidPExvYCdm5dYq3XToLkkLv5L2' . + 'pIIVOFMDG+KESnAFV7l2c+cnzRMW0+b6f8mR1CJzZuxVLL6Q02fvLi55/mbSYxECQQDeAw6fiIQX' . + 'GukBI4eMZZt4nscy2o12KyYner3VpoeE+Np2q+Z3pvAMd/aNzQ/W9WaI+NRfcxUJrmfPwIGm63il' . + 'AkEAxCL5HQb2bQr4ByorcMWm/hEP2MZzROV73yF41hPsRC9m66KrheO9HPTJuo3/9s5p+sqGxOlF' . + 'L0NDt4SkosjgGwJAFklyR1uZ/wPJjj611cdBcztlPdqoxssQGnh85BzCj/u3WqBpE2vjvyyvyI5k' . + 'X6zk7S0ljKtt2jny2+00VsBerQJBAJGC1Mg5Oydo5NwD6BiROrPxGo2bpTbu/fhrT8ebHkTz2epl' . + 'U9VQQSQzY1oZMVX8i1m5WUTLPz2yLJIBQVdXqhMCQBGoiuSoSjafUhV7i1cEGpb88h5NBYZzWXGZ' . + '37sJ5QsW+sJyoNde3xH8vdXhzU7eT82D6X/scw9RZz+/6rCJ4p0='; + $key = base64_decode($key); + + $this->assertTrue($rsa->loadKey($key)); + } +} diff --git a/vendor/phpseclib/phpseclib/tests/Math/BigInteger/BCMathTest.php b/vendor/phpseclib/phpseclib/tests/Math/BigInteger/BCMathTest.php new file mode 100755 index 0000000..72c574d --- /dev/null +++ b/vendor/phpseclib/phpseclib/tests/Math/BigInteger/BCMathTest.php @@ -0,0 +1,20 @@ + + * @copyright MMXIII Andreas Fischer + * @license http://www.opensource.org/licenses/mit-license.html MIT License + */ + +class Math_BigInteger_BCMathTest extends Math_BigInteger_TestCase +{ + static public function setUpBeforeClass() + { + if (!extension_loaded('bcmath')) { + self::markTestSkipped('BCMath extension is not available.'); + } + + parent::setUpBeforeClass(); + + self::ensureConstant('MATH_BIGINTEGER_MODE', MATH_BIGINTEGER_MODE_BCMATH); + } +} diff --git a/vendor/phpseclib/phpseclib/tests/Math/BigInteger/GMPTest.php b/vendor/phpseclib/phpseclib/tests/Math/BigInteger/GMPTest.php new file mode 100755 index 0000000..27c7a6a --- /dev/null +++ b/vendor/phpseclib/phpseclib/tests/Math/BigInteger/GMPTest.php @@ -0,0 +1,20 @@ + + * @copyright MMXIII Andreas Fischer + * @license http://www.opensource.org/licenses/mit-license.html MIT License + */ + +class Math_BigInteger_GMPTest extends Math_BigInteger_TestCase +{ + static public function setUpBeforeClass() + { + if (!extension_loaded('gmp')) { + self::markTestSkipped('GNU Multiple Precision (GMP) extension is not available.'); + } + + parent::setUpBeforeClass(); + + self::ensureConstant('MATH_BIGINTEGER_MODE', MATH_BIGINTEGER_MODE_GMP); + } +} diff --git a/vendor/phpseclib/phpseclib/tests/Math/BigInteger/InternalOpenSSLTest.php b/vendor/phpseclib/phpseclib/tests/Math/BigInteger/InternalOpenSSLTest.php new file mode 100755 index 0000000..378caac --- /dev/null +++ b/vendor/phpseclib/phpseclib/tests/Math/BigInteger/InternalOpenSSLTest.php @@ -0,0 +1,20 @@ + + * @copyright MMXIII Andreas Fischer + * @license http://www.opensource.org/licenses/mit-license.html MIT License + */ + +class Math_BigInteger_InternalOpenSSLTest extends Math_BigInteger_TestCase +{ + static public function setUpBeforeClass() + { + if (!function_exists('openssl_public_encrypt')) { + self::markTestSkipped('openssl_public_encrypt() function is not available.'); + } + + parent::setUpBeforeClass(); + + self::ensureConstant('MATH_BIGINTEGER_MODE', MATH_BIGINTEGER_MODE_INTERNAL); + } +} diff --git a/vendor/phpseclib/phpseclib/tests/Math/BigInteger/InternalTest.php b/vendor/phpseclib/phpseclib/tests/Math/BigInteger/InternalTest.php new file mode 100755 index 0000000..b029231 --- /dev/null +++ b/vendor/phpseclib/phpseclib/tests/Math/BigInteger/InternalTest.php @@ -0,0 +1,17 @@ + + * @copyright MMXIII Andreas Fischer + * @license http://www.opensource.org/licenses/mit-license.html MIT License + */ + +class Math_BigInteger_InternalTest extends Math_BigInteger_TestCase +{ + static public function setUpBeforeClass() + { + parent::setUpBeforeClass(); + + self::ensureConstant('MATH_BIGINTEGER_MODE', MATH_BIGINTEGER_MODE_INTERNAL); + self::ensureConstant('MATH_BIGINTEGER_OPENSSL_DISABLE', true); + } +} diff --git a/vendor/phpseclib/phpseclib/tests/Math/BigInteger/TestCase.php b/vendor/phpseclib/phpseclib/tests/Math/BigInteger/TestCase.php new file mode 100755 index 0000000..ea9d4e2 --- /dev/null +++ b/vendor/phpseclib/phpseclib/tests/Math/BigInteger/TestCase.php @@ -0,0 +1,268 @@ + + * @copyright MMXII Andreas Fischer + * @license http://www.opensource.org/licenses/mit-license.html MIT License + */ + +require_once 'Math/BigInteger.php'; + +abstract class Math_BigInteger_TestCase extends PhpseclibTestCase +{ + static public function setUpBeforeClass() + { + parent::setUpBeforeClass(); + + self::reRequireFile('Math/BigInteger.php'); + } + + public function getInstance($x = 0, $base = 10) + { + return new Math_BigInteger($x, $base); + } + + public function testConstructorBase2() + { + // 2**65 = 36893488147419103232 + $this->assertSame('36893488147419103232', (string) $this->getInstance('1' . str_repeat('0', 65), 2)); + } + + public function testConstructorBase10() + { + $this->assertSame('18446744073709551616', (string) $this->getInstance('18446744073709551616')); + } + + public function testConstructorBase16() + { + $this->assertSame('50', (string) $this->getInstance('0x32', 16)); + $this->assertSame('12345678910', (string) $this->getInstance('0x2DFDC1C3E', 16)); + $this->assertSame('18446744073709551615', (string) $this->getInstance('0xFFFFFFFFFFFFFFFF', 16)); + $this->assertSame('18446744073709551616', (string) $this->getInstance('0x10000000000000000', 16)); + } + + public function testToBytes() + { + $this->assertSame(chr(65), $this->getInstance('65')->toBytes()); + } + + public function testToBytesTwosCompliment() + { + $this->assertSame(chr(126), $this->getInstance('01111110', 2)->toBytes(true)); + } + + public function testToHex() + { + $this->assertSame('41', $this->getInstance('65')->toHex()); + } + + public function testToBits() + { + $this->assertSame('1000001', $this->getInstance('65')->toBits()); + } + + public function testAdd() + { + $x = $this->getInstance('18446744073709551615'); + $y = $this->getInstance( '100000000000'); + + $a = $x->add($y); + $b = $y->add($x); + + $this->assertTrue($a->equals($b)); + $this->assertTrue($b->equals($a)); + + $this->assertSame('18446744173709551615', (string) $a); + $this->assertSame('18446744173709551615', (string) $b); + } + + public function testSubtract() + { + $x = $this->getInstance('18446744073709551618'); + $y = $this->getInstance( '4000000000000'); + $this->assertSame('18446740073709551618', (string) $x->subtract($y)); + } + + public function testMultiply() + { + $x = $this->getInstance('8589934592'); // 2**33 + $y = $this->getInstance('36893488147419103232'); // 2**65 + + $a = $x->multiply($y); // 2**98 + $b = $y->multiply($x); // 2**98 + + $this->assertTrue($a->equals($b)); + $this->assertTrue($b->equals($a)); + + $this->assertSame('316912650057057350374175801344', (string) $a); + $this->assertSame('316912650057057350374175801344', (string) $b); + } + + public function testDivide() + { + $x = $this->getInstance('1180591620717411303425'); // 2**70 + 1 + $y = $this->getInstance('12345678910'); + + list($q, $r) = $x->divide($y); + + $this->assertSame('95627922070', (string) $q); + $this->assertSame('10688759725', (string) $r); + } + + public function testModPow() + { + $a = $this->getInstance('10'); + $b = $this->getInstance('20'); + $c = $this->getInstance('30'); + $d = $a->modPow($b, $c); + + $this->assertSame('10', (string) $d); + } + + public function testModInverse() + { + $a = $this->getInstance(30); + $b = $this->getInstance(17); + + $c = $a->modInverse($b); + $this->assertSame('4', (string) $c); + + $d = $a->multiply($c); + list($q, $r) = $d->divide($b); + $this->assertSame('1', (string) $r); + } + + public function testExtendedGCD() + { + $a = $this->getInstance(693); + $b = $this->getInstance(609); + + $arr = $a->extendedGCD($b); + + $this->assertSame('21', (string) $arr['gcd']); + $this->assertSame(21, $a->toString() * $arr['x']->toString() + $b->toString() * $arr['y']->toString()); + } + + public function testGCD() + { + $x = $this->getInstance(693); + $y = $this->getInstance(609); + $this->assertSame('21', (string) $x->gcd($y)); + } + + public function testAbs() + { + $x = $this->getInstance('-18446744073709551617'); + $y = $x->abs(); + + $this->assertSame('-18446744073709551617', (string) $x); + $this->assertSame('18446744073709551617', (string) $y); + } + + public function testEquals() + { + $x = $this->getInstance('18446744073709551616'); + $y = $this->getInstance('18446744073709551616'); + + $this->assertTrue($x->equals($y)); + $this->assertTrue($y->equals($x)); + } + + public function testCompare() + { + $a = $this->getInstance('-18446744073709551616'); + $b = $this->getInstance('36893488147419103232'); + $c = $this->getInstance('36893488147419103232'); + $d = $this->getInstance('316912650057057350374175801344'); + + // a < b + $this->assertLessThan(0, $a->compare($b)); + $this->assertGreaterThan(0, $b->compare($a)); + + // b = c + $this->assertSame(0, $b->compare($c)); + $this->assertSame(0, $c->compare($b)); + + // c < d + $this->assertLessThan(0, $c->compare($d)); + $this->assertGreaterThan(0, $d->compare($c)); + } + + public function testBitwiseAND() + { + $x = $this->getInstance('66666666666666666666666', 16); + $y = $this->getInstance('33333333333333333333333', 16); + $z = $this->getInstance('22222222222222222222222', 16); + + $this->assertSame($z->toHex(), $x->bitwise_AND($y)->toHex()); + } + + public function testBitwiseOR() + { + $x = $this->getInstance('11111111111111111111111', 16); + $y = $this->getInstance('EEEEEEEEEEEEEEEEEEEEEEE', 16); + $z = $this->getInstance('FFFFFFFFFFFFFFFFFFFFFFF', 16); + + $this->assertSame($z->toHex(), $x->bitwise_OR($y)->toHex()); + } + + public function testBitwiseXOR() + { + $x = $this->getInstance('AFAFAFAFAFAFAFAFAFAFAFAF', 16); + $y = $this->getInstance('133713371337133713371337', 16); + $z = $this->getInstance('BC98BC98BC98BC98BC98BC98', 16); + + $this->assertSame($z->toHex(), $x->bitwise_XOR($y)->toHex()); + } + + public function testBitwiseNOT() + { + $x = $this->getInstance('EEEEEEEEEEEEEEEEEEEEEEE', 16); + $z = $this->getInstance('11111111111111111111111', 16); + + $this->assertSame($z->toHex(), $x->bitwise_NOT()->toHex()); + } + + public function testBitwiseLeftShift() + { + $x = $this->getInstance('0x0000000FF0000000', 16); + $y = $this->getInstance('0x000FF00000000000', 16); + + $this->assertSame($y->toHex(), $x->bitwise_LeftShift(16)->toHex()); + } + + public function testBitwiseRightShift() + { + $x = $this->getInstance('0x0000000FF0000000', 16); + $y = $this->getInstance('0x00000000000FF000', 16); + $z = $this->getInstance('0x000000000000000F', 16); + $n = $this->getInstance(0); + + $this->assertSame($y->toHex(), $x->bitwise_RightShift(16)->toHex()); + $this->assertSame($z->toHex(), $x->bitwise_RightShift(32)->toHex()); + $this->assertSame($n->toHex(), $x->bitwise_RightShift(36)->toHex()); + } + + public function testSerializable() + { + $x = $this->getInstance('18446744073709551616'); + $y = unserialize(serialize($x)); + + $this->assertTrue($x->equals($y)); + $this->assertTrue($y->equals($x)); + + $this->assertSame('18446744073709551616', (string) $x); + $this->assertSame('18446744073709551616', (string) $y); + } + + public function testClone() + { + $x = $this->getInstance('18446744073709551616'); + $y = clone $x; + + $this->assertTrue($x->equals($y)); + $this->assertTrue($y->equals($x)); + + $this->assertSame('18446744073709551616', (string) $x); + $this->assertSame('18446744073709551616', (string) $y); + } +} diff --git a/vendor/phpseclib/phpseclib/tests/Net/SSH1Test.php b/vendor/phpseclib/phpseclib/tests/Net/SSH1Test.php new file mode 100755 index 0000000..7c58ceb --- /dev/null +++ b/vendor/phpseclib/phpseclib/tests/Net/SSH1Test.php @@ -0,0 +1,41 @@ + + * @copyright MMXIII Marc Scholten + * @license http://www.opensource.org/licenses/mit-license.html MIT License + */ + +class Net_SSH1Test extends PhpseclibTestCase +{ + public function formatLogDataProvider() + { + return array( + array( + array('hello world'), + array('<--'), + "<--\r\n00000000 68:65:6c:6c:6f:20:77:6f:72:6c:64 hello world\r\n\r\n" + ), + array( + array('hello', 'world'), + array('<--', '<--'), + "<--\r\n00000000 68:65:6c:6c:6f hello\r\n\r\n" . + "<--\r\n00000000 77:6f:72:6c:64 world\r\n\r\n" + ), + ); + } + + /** + * @dataProvider formatLogDataProvider + */ + public function testFormatLog(array $message_log, array $message_number_log, $expected) + { + $ssh = $this->getMockBuilder('Net_SSH1') + ->disableOriginalConstructor() + ->setMethods(null) + ->getMock(); + + $result = $ssh->_format_log($message_log, $message_number_log); + + $this->assertEquals($expected, $result); + } +} diff --git a/vendor/phpseclib/phpseclib/tests/Net/SSH2Test.php b/vendor/phpseclib/phpseclib/tests/Net/SSH2Test.php new file mode 100755 index 0000000..a6f0f9b --- /dev/null +++ b/vendor/phpseclib/phpseclib/tests/Net/SSH2Test.php @@ -0,0 +1,83 @@ + + * @copyright MMXIII Marc Scholten + * @license http://www.opensource.org/licenses/mit-license.html MIT License + */ + +class Net_SSH2Test extends PhpseclibTestCase +{ + public function formatLogDataProvider() + { + return array( + array( + array('hello world'), + array('<--'), + "<--\r\n00000000 68:65:6c:6c:6f:20:77:6f:72:6c:64 hello world\r\n\r\n" + ), + array( + array('hello', 'world'), + array('<--', '<--'), + "<--\r\n00000000 68:65:6c:6c:6f hello\r\n\r\n" . + "<--\r\n00000000 77:6f:72:6c:64 world\r\n\r\n" + ), + ); + } + + /** + * @dataProvider formatLogDataProvider + */ + public function testFormatLog(array $message_log, array $message_number_log, $expected) + { + $ssh = $this->createSSHMock(); + + $result = $ssh->_format_log($message_log, $message_number_log); + $this->assertEquals($expected, $result); + } + + public function generateIdentifierProvider() + { + return array( + array('SSH-2.0-phpseclib_0.3', array()), + array('SSH-2.0-phpseclib_0.3 (gmp)', array('gmp')), + array('SSH-2.0-phpseclib_0.3 (bcmath)', array('bcmath')), + array('SSH-2.0-phpseclib_0.3 (mcrypt)', array('mcrypt')), + array('SSH-2.0-phpseclib_0.3 (mcrypt, gmp)', array('mcrypt', 'gmp')), + array('SSH-2.0-phpseclib_0.3 (mcrypt, bcmath)', array('mcrypt', 'bcmath')), + ); + } + + /** + * @dataProvider generateIdentifierProvider + */ + public function testGenerateIdentifier($expected, array $requiredExtensions) + { + $notAllowed = array('gmp', 'bcmath', 'mcrypt', 'gmp'); + foreach ($notAllowed as $notAllowedExtension) { + if (in_array($notAllowedExtension, $requiredExtensions)) { + continue; + } + + if (extension_loaded($notAllowedExtension)) { + $this->markTestSkipped('Extension ' . $notAllowedExtension . ' is not allowed for this data-set'); + } + } + + $ssh = $this->createSSHMock(); + $identifier = $ssh->_generate_identifier(); + + $this->assertEquals($expected, $identifier); + } + + /** + * @return Net_SSH2 + */ + protected function createSSHMock() + { + return $this->getMockBuilder('Net_SSH2') + ->disableOriginalConstructor() + ->setMethods(array('__destruct')) + ->getMock(); + } +} diff --git a/vendor/phpseclib/phpseclib/tests/PhpseclibTestCase.php b/vendor/phpseclib/phpseclib/tests/PhpseclibTestCase.php new file mode 100755 index 0000000..3369ad1 --- /dev/null +++ b/vendor/phpseclib/phpseclib/tests/PhpseclibTestCase.php @@ -0,0 +1,64 @@ + + * @copyright MMXIII Andreas Fischer + * @license http://www.opensource.org/licenses/mit-license.html MIT License + */ + +abstract class PhpseclibTestCase extends PHPUnit_Framework_TestCase +{ + /** + * @param string $constant + * @param mixed $expected + * + * @return null + */ + static protected function ensureConstant($constant, $expected) + { + if (defined($constant)) { + $value = constant($constant); + + if ($value !== $expected) { + if (function_exists('runkit_constant_redefine')) { + if (!runkit_constant_redefine($constant, $expected)) { + self::markTestSkipped(sprintf( + "Failed to redefine constant %s to %s", + $constant, + $expected + )); + } + } else { + self::markTestSkipped(sprintf( + "Skipping test because constant %s is %s instead of %s", + $constant, + $value, + $expected + )); + } + } + } else { + define($constant, $expected); + } + } + + /** + * @param string $filename + * + * @return null + */ + static protected function reRequireFile($filename) + { + if (function_exists('runkit_import')) { + $result = runkit_import( + $filename, + RUNKIT_IMPORT_FUNCTIONS | + RUNKIT_IMPORT_CLASS_METHODS | + RUNKIT_IMPORT_OVERRIDE + ); + + if (!$result) { + self::markTestSkipped("Failed to reimport file $filename"); + } + } + } +} diff --git a/vendor/phpseclib/phpseclib/tests/bootstrap.php b/vendor/phpseclib/phpseclib/tests/bootstrap.php new file mode 100755 index 0000000..cb9fc61 --- /dev/null +++ b/vendor/phpseclib/phpseclib/tests/bootstrap.php @@ -0,0 +1,43 @@ + +# +# For the full copyright and license information, please view the LICENSE +# file that was distributed with this source code. +# +set -e + +function install_php_extension +{ + cd "$1" + phpize + ./configure + make + make install + cd .. + echo "extension=$1.so" >> `php --ini | grep "Loaded Configuration" | sed -e "s|.*:\s*||"` +} + +# runkit +git clone git://github.com/zenovich/runkit.git +install_php_extension 'runkit' diff --git a/vendor/phpseclib/phpseclib/travis/upload-code-coverage.sh b/vendor/phpseclib/phpseclib/travis/upload-code-coverage.sh new file mode 100755 index 0000000..668fb6a --- /dev/null +++ b/vendor/phpseclib/phpseclib/travis/upload-code-coverage.sh @@ -0,0 +1,50 @@ +#!/bin/sh +# +# This file is part of the phpseclib project. +# +# (c) Andreas Fischer +# +# For the full copyright and license information, please view the LICENSE +# file that was distributed with this source code. +# + +USERNAME='phpseclib' +HOSTNAME='phpseclib.bantux.org' +HOSTRSAF='09:40:96:14:6a:cd:67:46:17:e5:b4:39:24:24:6e:9d' +LDIRNAME='code_coverage' +RDIRNAME='code_coverage' +ID_RSA='travis/code_coverage_id_rsa' + +# Install expect if necessary +if ! which expect > /dev/null +then + sudo apt-get update -qq + sudo apt-get install -qq expect +fi + +# Workaround for rsync not creating target directories with depth > 1 +mv "$LDIRNAME" "x$LDIRNAME" +RROOT="$RDIRNAME/$TRAVIS_BRANCH/$TRAVIS_BUILD_NUMBER" +mkdir -p "$RROOT" +mv "x$LDIRNAME" "$RROOT/PHP-$TRAVIS_PHP_VERSION/" + +# Update latest symlink +ln -s "$TRAVIS_BUILD_NUMBER" "$RDIRNAME/$TRAVIS_BRANCH/latest" + +# Stop complaints about world-readable key file. +chmod 600 "$ID_RSA" + +export RSYNC_RSH="ssh -4 -i $ID_RSA -o ConnectTimeout=5" +RSYNC_OPT="--recursive --times --links --progress" + +expect << EOF + spawn rsync $RSYNC_OPT "$RDIRNAME/" "$USERNAME@$HOSTNAME:$RDIRNAME/" + + expect "RSA key fingerprint is $HOSTRSAF." + send "yes\n" + + expect "Enter passphrase for key '$ID_RSA':" + send "$CODE_COVERAGE_PASSPHRASE\n" + + expect eof +EOF diff --git a/vendor/predis/predis/.gitignore b/vendor/predis/predis/.gitignore new file mode 100755 index 0000000..dacaf3a --- /dev/null +++ b/vendor/predis/predis/.gitignore @@ -0,0 +1,7 @@ +*.tgz +*.phar +phpunit.xml +package.xml +composer.lock +experiments/ +vendor/ diff --git a/vendor/predis/predis/.travis.yml b/vendor/predis/predis/.travis.yml new file mode 100755 index 0000000..0842b04 --- /dev/null +++ b/vendor/predis/predis/.travis.yml @@ -0,0 +1,13 @@ +language: php +php: + - 5.3 + - 5.4 + - 5.5 +branches: + except: + - v0.5 + - v0.6 + - php5.2_backport + - documentation +services: redis-server +script: phpunit -c phpunit.xml.travisci diff --git a/vendor/predis/predis/CHANGELOG.NAMING.md b/vendor/predis/predis/CHANGELOG.NAMING.md new file mode 100755 index 0000000..2edcaa2 --- /dev/null +++ b/vendor/predis/predis/CHANGELOG.NAMING.md @@ -0,0 +1,53 @@ +# Namespaces, interfaces and classes renamed in Predis v0.8 # +____________________________________________ + +Some namespaces, interfaces and classes in Predis v0.8 have been renamed to follow a common rule inspired +by the naming conventions adopted by the Symfony2 project. This is a list of all the changes: + +### Renamed namespaces ### + + - `Predis\Network` => `Predis\Connection` + - `Predis\Profiles` => `Predis\Profile` + - `Predis\Iterators` => `Predis\Iterator` + - `Predis\Options` => `Predis\Option` + - `Predis\Commands` => `Predis\Command` + - `Predis\Commands\Processors` => `Predis\Command\Processor` + +### Renamed interfaces ### + + - `Predis\IReplyObject` => `Predis\ResponseObjectInterface` + - `Predis\IRedisServerError` => `Predis\ResponseErrorInterface` + - `Predis\Options\IOption` => `Predis\Option\OptionInterface` + - `Predis\Options\IClientOptions` => `Predis\Option\ClientOptionsInterface` + - `Predis\Profile\IServerProfile` => `Predis\Profile\ServerProfileInterface` + - `Predis\Pipeline\IPipelineExecutor` => `Predis\Pipeline\PipelineExecutorInterface` + - `Predis\Distribution\INodeKeyGenerator` => `Predis\Distribution\HashGeneratorInterface` + - `Predis\Distribution\IDistributionStrategy` => `Predis\Distribution\DistributionStrategyInterface` + - `Predis\Protocol\IProtocolProcessor` => `Predis\Protocol\ProtocolInterface` + - `Predis\Protocol\IResponseReader` => `Predis\Protocol\ResponseReaderInterface` + - `Predis\Protocol\IResponseHandler` => `Predis\Protocol\ResponseHandlerInterface` + - `Predis\Protocol\ICommandSerializer` => `Predis\Protocol\CommandSerializerInterface` + - `Predis\Protocol\IComposableProtocolProcessor` => `Predis\Protocol\ComposableProtocolInterface` + - `Predis\Network\IConnection` => `Predis\Connection\ConnectionInterface` + - `Predis\Network\IConnectionSingle` => `Predis\Connection\SingleConnectionInterface` + - `Predis\Network\IConnectionComposable` => `Predis\Connection\ComposableConnectionInterface` + - `Predis\Network\IConnectionCluster` => `Predis\Connection\ClusterConnectionInterface` + - `Predis\Network\IConnectionReplication` => `Predis\Connection\ReplicationConnectionInterface` + - `Predis\Commands\ICommand` => `Predis\Command\CommandInterface` + - `Predis\Commands\IPrefixable` => `Predis\Command\PrefixableCommandInterface` + - `Predis\Command\Processor\ICommandProcessor` => `Predis\Command\Processor\CommandProcessorInterface` + - `Predis\Command\Processor\ICommandProcessorChain` => `Predis\Command\Processor\CommandProcessorChainInterface` + - `Predis\Command\Processor\IProcessingSupport` => `Predis\Command\Processor\CommandProcessingInterface` + +### Renamed classes ### + + - `Predis\Commands\Command` => `Predis\Command\AbstractCommand` + - `Predis\Network\ConnectionBase` => `Predis\Connection\AbstractConnection` + +### Classes or interfaces moved to different namespaces ### + + - `Predis\MonitorContext` => `Predis\Monitor\MonitorContext` + - `Predis\ConnectionParameters` => `Predis\Connection\ConnectionParameters` + - `Predis\ConnectionParametersInterface` => `Predis\Connection\ConnectionParametersInterface` + - `Predis\ConnectionFactory` => `Predis\Connection\ConnectionFactory` + - `Predis\ConnectionFactoryInterface` => `Predis\Connection\ConnectionFactoryInterface` diff --git a/vendor/predis/predis/CHANGELOG.md b/vendor/predis/predis/CHANGELOG.md new file mode 100755 index 0000000..6b161a2 --- /dev/null +++ b/vendor/predis/predis/CHANGELOG.md @@ -0,0 +1,620 @@ +v0.8.5 (2014-01-16) +================================================================================ + +- Added `2.8` in the server profiles aliases list for Redis 2.8. `2.6` is still + the default server profile and `dev` now targets Redis 3.0. + +- Added `SCAN`, `SSCAN`, `ZSCAN`, `HSCAN` to the server profile for Redis 2.8. + +- Implemented PHP iterators for incremental iterations over Redis collections: + + - keyspace (cursor-based iterator using `SCAN`) + - sets (cursor-based iterator using `SSCAN`) + - sorted sets (cursor-based iterator using `ZSCAN`) + - hashes (cursor-based iterator using `HSCAN`) + - lists (plain iterator using `LRANGE`) + +- It is now possible to execute "raw commands" using `Predis\Command\RawCommand` + and a variable list of command arguments. Input arguments are not filtered and + responses are not parsed, which means arguments must follow the signature of + the command as defined by Redis and complex responses are left untouched. + +- URI parsing for connection parameters has been improved and has slightly less + overhead when the number of fields in the querystring grows. New features are: + + - Parsing does not break when value of a field contains one or more "=". + - Repeated fieldnames using [] produce an array of values. + - Empty or incomplete "key=value" pairs result in an empty string for "key". + +- Various improvements and fixes to the redis-cluster connection backend: + + - __FIX__: the `ASKING` command is sent upon -ASK redirections. + - An updated slots-map can be fetched from nodes using the `CLUSTER NODES` + command. By default this is a manual operation but can be enabled to get + automatically done upon -MOVED redirections. + - It is possible to specify a common set of connection parameters that are + applied to connections created on the fly upon redirections to nodes not + part of the initial pool. + +- List of deprecated methods: + + - `Predis\Client::multiExec()`: superseded by `Predis\Client::transaction()` + and to be removed in the next major release. + - `Predis\Client::pubSub()`: superseded by `Predis\Client::pubSubLoop()` and + to be removed in the next major release. This change was needed due to the + recently introduced `PUBSUB` command in Redis 2.8. + + +v0.8.4 (2013-07-27) +================================================================================ + +- Added `DUMP` and `RESTORE` to the server profile for Redis 2.6. + +- Connection exceptions now report basic host details in their messages. + +- Allow `Predis\Connection\PhpiredisConnection` to use a random IP when a host + actually has several IPs (ISSUE #116). + +- __FIX__: allow `HMSET` when using a cluster of Redis nodes with client-side + sharding or redis-cluster (ISSUE #106). + +- __FIX__: set `WITHSCORES` modifer for `ZRANGE`, `ZREVRANGE`, `ZRANGEBYSCORE` + and `ZREVRANGEBYSCORE` only when the options array passed to these commands + has `WITHSCORES` set to `true` (ISSUE #107). + +- __FIX__: scripted commands falling back from `EVALSHA` to `EVAL` resulted in + PHP errors when using a prefixed client (ISSUE #109). + +- __FIX__: `Predis\PubSub\DispatcherLoop` now works properly when using key + prefixing (ISSUE #114). + + +v0.8.3 (2013-02-18) +================================================================================ + +- Added `CLIENT SETNAME` and `CLIENT GETNAME` (ISSUE #102). + +- Implemented the `Predis\Connection\PhpiredisStreamConnection` class using the + `phpiredis` extension like `Predis\Connection\PhpiredisStreamConnection`, but + without requiring the `socket` extension since it relies on PHP's streams. + +- Added support for the TCP_NODELAY flag via the `tcp_nodelay` parameter for + stream-based connections, namely `Predis\Connection\StreamConnection` and + `Predis\Connection\PhpiredisStreamConnection` (requires PHP >= 5.4.0). + +- Updated the aggregated connection class for redis-cluster to work with 16384 + hash slots instead of 4096 to reflect the recent change from redis unstable + ([see this commit](https://github.com/antirez/redis/commit/ebd666d)). + +- The constructor of `Predis\Client` now accepts a callable as first argument + returning `Predis\Connection\ConnectionInterface`. Users can create their + own self-contained strategies to create and set up the underlying connection. + +- Users should return `0` from `Predis\Command\ScriptedCommand::getKeysCount()` + instead of `FALSE` to indicate that all of the arguments of a Lua script must + be used to populate `ARGV[]`. This does not represent a breaking change. + +- The `Predis\Helpers` class has been deprecated and it will be removed in + future releases. + + +v0.8.2 (2013-02-03) +================================================================================ + +- Added `Predis\Session\SessionHandler` to make it easy to store PHP sessions + on Redis using Predis. Please note that this class needs either PHP >= 5.4.0 + or a polyfill for PHP's `SessionHandlerInterface`. + +- Added the ability to get the default value of a client option directly from + `Predis\Option\ClientOption` using the `getDefault()` method by passing the + option name or its instance. + +- __FIX__: the standard pipeline executor was not using the response parser + methods associated to commands to process raw responses (ISSUE #101). + + +v0.8.1 (2013-01-19) +================================================================================ + +- The `connections` client option can now accept a callable object returning + an instance of `Predis\Connection\ConnectionFactoryInterface`. + +- Client options accepting callable objects as factories now pass their actual + instance to the callable as the second argument. + +- `Predis\Command\Processor\KeyPrefixProcessor` can now be directly casted to + string to obtain the current prefix, useful with string interpolation. + +- Added an optional callable argument to `Predis\Cluster\Distribution\HashRing` + and `Predis\Cluster\Distribution\KetamaPureRing` constructor that can be used + to customize how the distributor should extract the connection hash when + initializing the nodes distribution (ISSUE #36). + +- Correctly handle `TTL` and `PTTL` returning -2 on non existing keys starting + with Redis 2.8. + +- __FIX__: a missing use directive in `Predis\Transaction\MultiExecContext` + caused PHP errors when Redis did not return `+QUEUED` replies to commands + when inside a MULTI / EXEC context. + +- __FIX__: the `parseResponse()` method implemented for a scripted command was + ignored when retrying to execute a Lua script by falling back to `EVAL` after + a `-NOSCRIPT` error (ISSUE #94). + +- __FIX__: when subclassing `Predis\Client` the `getClientFor()` method returns + a new instance of the subclass instead of a new instance of `Predis\Client`. + + +v0.8.0 (2012-10-23) +================================================================================ + +- The default server profile for Redis is now `2.6`. + +- Certain connection parameters have been renamed: + + - `connection_async` is now `async_connect` + - `connection_timeout` is now `timeout` + - `connection_persistent` is now `persistent` + +- The `throw_errors` connection parameter has been removed and replaced by the + new `exceptions` client option since exceptions on `-ERR` replies returned by + Redis are not generated by connection classes anymore but instead are thrown + by the client class and other abstractions such as pipeline contexts. + +- Added smart support for redis-cluster (Redis v3.0) in addition to the usual + cluster implementation that uses client-side sharding. + +- Various namespaces and classes have been renamed to follow rules inspired by + the Symfony2 naming conventions. + +- The second argument of the constructor of `Predis\Client` does not accept + strings or instances of `Predis\Profile\ServerProfileInterface` anymore. + To specify a server profile you must explicitly set `profile` in the array + of client options. + +- `Predis\Command\ScriptedCommand` internally relies on `EVALSHA` instead of + `EVAL` thus avoiding to send Lua scripts bodies on each request. The client + automatically resends the command falling back to `EVAL` when Redis returns a + `-NOSCRIPT` error. Automatic fallback to `EVAL` does not work with pipelines, + inside a `MULTI / EXEC` context or with plain `EVALSHA` commands. + +- Complex responses are no more parsed by connection classes as they must be + processed by consumer classes using the handler associated to the issued + command. This means that executing commands directly on connections only + returns simple Redis types, but nothing changes when using `Predis\Client` + or the provided abstractions for pipelines and transactions. + +- Iterators for multi-bulk replies now skip the response parsing method of the + command that generated the response and are passed directly to user code. + Pipeline and transaction objects still consume automatically iterators. + +- Cluster and replication connections now extend a new common interface, + `Predis\Connection\AggregatedConnectionInterface`. + +- `Predis\Connection\MasterSlaveReplication` now uses an external strategy + class to handle the logic for checking readable / writable commands and Lua + scripts. + +- Command pipelines have been optimized for both speed and code cleanness, but + at the cost of bringing a breaking change in the signature of the interface + for pipeline executors. + +- Added a new pipeline executor that sends commands wrapped in a MULTI / EXEC + context to make the execution atomic: if a pipeline fails at a certain point + then the whole pipeline is discarded. + +- The key-hashing mechanism for commands is now handled externally and is no + more a competence of each command class. This change is neeeded to support + both client-side sharding and Redis cluster. + +- `Predis\Options\Option` is now abstract, see `Predis\Option\AbstractOption`. + + +v0.7.3 (2012-06-01) +================================================================================ + +- New commands available in the Redis v2.6 profile (dev): `BITOP`, `BITCOUNT`. + +- When the number of keys `Predis\Commands\ScriptedCommand` is negative, Predis + will count from the end of the arguments list to calculate the actual number + of keys that will be interpreted as elements for `KEYS` by the underlying + `EVAL` command. + +- __FIX__: `examples\CustomDistributionStrategy.php` had a mistyped constructor + call and produced a bad distribution due to an error as pointed in ISSUE #63. + This bug is limited to the above mentioned example and does not affect the + classes implemented in the `Predis\Distribution` namespace. + +- __FIX__: `Predis\Commands\ServerEvalSHA::getScriptHash()` was calculating the + hash while it just needs to return the first argument of the command. + +- __FIX__: `Predis\Autoloader` has been modified to allow cascading autoloaders + for the `Predis` namespace. + + +v0.7.2 (2012-04-01) +================================================================================ + +- Added `2.6` in the server profiles aliases list for the upcoming Redis 2.6. + `2.4` is still the default server profile. `dev` now targets Redis 2.8. + +- Connection instances can be serialized and unserialized using `serialize()` + and `unserialize()`. This is handy in certain scenarios such as client-side + clustering or replication to lower the overhead of initializing a connection + object with many sub-connections since unserializing them can be up to 5x + times faster. + +- Reworked the default autoloader to make it faster. It is also possible to + prepend it in PHP's autoload stack. + +- __FIX__: fixed parsing of the payload returned by `MONITOR` with Redis 2.6. + + +v0.7.1 (2011-12-27) +================================================================================ + +- The PEAR channel on PearHub has been deprecated in favour of `pear.nrk.io`. + +- Miscellaneous minor fixes. + +- Added transparent support for master / slave replication configurations where + write operations are performed on the master server and read operations are + routed to one of the slaves. Please refer to ISSUE #21 for a bit of history + and more details about replication support in Predis. + +- The `profile` client option now accepts a callable object used to initialize + a new instance of `Predis\Profiles\IServerProfile`. + +- Exposed a method for MULTI / EXEC contexts that adds the ability to execute + instances of Redis commands against transaction objects. + + +v0.7.0 (2011-12-11) +================================================================================ + +- Predis now adheres to the PSR-0 standard which means that there is no more a + single file holding all the classes of the library, but multiple files (one + for each class). You can use any PSR-0 compatible autoloader to load Predis + or just leverage the default one shipped with the library by requiring the + `Predis/Autoloader.php` and call `Predis\Autoloader::register()`. + +- The default server profile for Redis is now 2.4. The `dev` profile supports + all the features of Redis 2.6 (currently unstable) such as Lua scripting. + +- Support for long aliases (method names) for Redis commands has been dropped. + +- Redis 1.0 is no more supported. From now on Predis will use only the unified + protocol to serialize commands. + +- It is possible to prefix keys transparently on a client-level basis with the + new `prefix` client option. + +- An external connection factory is used to initialize new connection instances + and developers can now register their own connection classes using the new + `connections` client option. + +- It is possible to connect locally to Redis using UNIX domain sockets. Just + use `unix:///path/to/redis.sock` or a named array just like in the following + example: `array('scheme' => 'unix', 'path' => '/path/to/redis.sock');`. + +- If the `phpiredis` extension is loaded by PHP, it is now possible to use an + alternative connection class that leverages it to make Predis faster on many + cases, especially when dealing with big multibulk replies, with the the only + downside that persistent connections are not supported. Please refer to the + documentation to see how to activate this class using the new `connections` + client option. + +- Predis is capable to talk with Webdis, albeit with some limitations such as + the lack of pipelining and transactions, just by using the `http` scheme in + in the connection parameters. All is needed is PHP with the `curl` and the + `phpiredis` extensions loaded. + +- Way too many changes in the public API to make a list here, we just tried to + make all the Redis commands compatible with previous releases of v0.6 so that + you do not have to worry if you are simply using Predis as a client. Probably + the only breaking changes that should be mentioned here are: + + - `throw_on_error` has been renamed to `throw_errors` and it is a connection + parameter instead of a client option, along with `iterable_multibulk`. + + - `key_distribution` has been removed from the client options. To customize + the distribution strategy you must provide a callable object to the new + `cluster` client option to configure and then return a new instance of + `Predis\Network\IConnectionCluster`. + + - `Predis\Client::create()` has been removed. Just use the constructor to set + up a new instance of `Predis\Client`. + + - `Predis\Client::pipelineSafe()` was deprecated in Predis v0.6.1 and now has + finally removed. Use `Predis\Client::pipeline(array('safe' => true))`. + + - `Predis\Client::rawCommand()` has been removed due to inconsistencies with + the underlying connection abstractions. You can still get the raw resource + out of a connection with `Predis\Network\IConnectionSingle::getResource()` + so that you can talk directly with Redis. + +- The `Predis\MultiBulkCommand` class has been merged into `Predis\Command` and + thus removed. Serialization of commands is now a competence of connections. + +- The `Predis\IConnection` interface has been splitted into two new interfaces: + `Predis\Network\IConnectionSingle` and `Predis\Network\IConnectionCluster`. + +- The constructor of `Predis\Client` now accepts more type of arguments such as + instances of `Predis\IConnectionParameters` and `Predis\Network\IConnection`. + + +v0.6.6 (2011-04-01) +================================================================================ + +- Switched to Redis 2.2 as the default server profile (there are no changes + that would break compatibility with previous releases). Long command names + are no more supported by default but if you need them you can still require + `Predis_Compatibility.php` to avoid breaking compatibility. + +- Added a `VERSION` constant to `Predis\Client`. + +- Some performance improvements for multibulk replies (parsing them is about + 16% faster than the previous version). A few core classes have been heavily + optimized to reduce overhead when creating new instances. + +- Predis now uses by default a new protocol reader, more lightweight and + faster than the default handler-based one. Users can revert to the old + protocol reader with the `reader` client option set to `composable`. + This client option can also accept custom reader classes implementing the + new `Predis\IResponseReader` interface. + +- Added support for connecting to Redis using UNIX domain sockets (ISSUE #25). + +- The `read_write_timeout` connection parameter can now be set to 0 or false + to disable read and write timeouts on connections. The old behaviour of -1 + is still intact. + +- `ZUNIONSTORE` and `ZINTERSTORE` can accept an array to specify a list of the + source keys to be used to populate the destination key. + +- `MGET`, `SINTER`, `SUNION` and `SDIFF` can accept an array to specify a list + of keys. `SINTERSTORE`, `SUNIONSTORE` and `SDIFFSTORE` can also accept an + array to specify the list of source keys. + +- `SUBSCRIBE` and `PSUBSCRIBE` can accept a list of channels for subscription. + +- __FIX__: some client-side clean-ups for `MULTI/EXEC` were handled incorrectly + in a couple of corner cases (ISSUE #27). + + +v0.6.5 (2011-02-12) +================================================================================ + +- __FIX__: due to an untested internal change introduced in v0.6.4, a wrong + handling of bulk reads of zero-length values was producing protocol + desynchronization errors (ISSUE #20). + + +v0.6.4 (2011-02-12) +================================================================================ + +- Various performance improvements (15% ~ 25%) especially when dealing with + long multibulk replies or when using clustered connections. + +- Added the `on_retry` option to `Predis\MultiExecBlock` that can be used to + specify an external callback (or any callable object) that gets invoked + whenever a transaction is aborted by the server. + +- Added inline (p)subscribtion via options when initializing an instance of + `Predis\PubSubContext`. + + +v0.6.3 (2011-01-01) +================================================================================ + +- New commands available in the Redis v2.2 profile (dev): + - Strings: `SETRANGE`, `GETRANGE`, `SETBIT`, `GETBIT` + - Lists : `BRPOPLPUSH` + +- The abstraction for `MULTI/EXEC` transactions has been dramatically improved + by providing support for check-and-set (CAS) operations when using Redis >= + 2.2. Aborted transactions can also be optionally replayed in automatic up + to a user-defined number of times, after which a `Predis\AbortedMultiExec` + exception is thrown. + + +v0.6.2 (2010-11-28) +================================================================================ + +- Minor internal improvements and clean ups. + +- New commands available in the Redis v2.2 profile (dev): + - Strings: `STRLEN` + - Lists : `LINSERT`, `RPUSHX`, `LPUSHX` + - ZSets : `ZREVRANGEBYSCORE` + - Misc. : `PERSIST` + +- WATCH also accepts a single array parameter with the keys that should be + monitored during a transaction. + +- Improved the behaviour of `Predis\MultiExecBlock` in certain corner cases. + +- Improved parameters checking for the SORT command. + +- __FIX__: the `STORE` parameter for the `SORT` command didn't work correctly + when using `0` as the target key (ISSUE #13). + +- __FIX__: the methods for `UNWATCH` and `DISCARD` do not break anymore method + chaining with `Predis\MultiExecBlock`. + + +v0.6.1 (2010-07-11) +================================================================================ + +- Minor internal improvements and clean ups. + +- New commands available in the Redis v2.2 profile (dev): + - Misc. : `WATCH`, `UNWATCH` + +- Optional modifiers for `ZRANGE`, `ZREVRANGE` and `ZRANGEBYSCORE` queries are + supported using an associative array passed as the last argument of their + respective methods. + +- The `LIMIT` modifier for `ZRANGEBYSCORE` can be specified using either: + - an indexed array: `array($offset, $count)` + - an associative array: `array('offset' => $offset, 'count' => $count)` + +- The method `Predis\Client::__construct()` now accepts also instances of + `Predis\ConnectionParameters`. + +- `Predis\MultiExecBlock` and `Predis\PubSubContext` now throw an exception + when trying to create their instances using a profile that does not + support the required Redis commands or when the client is connected to + a cluster of connections. + +- Various improvements to `Predis\MultiExecBlock`: + - fixes and more consistent behaviour across various usage cases. + - support for `WATCH` and `UNWATCH` when using the current development + profile (Redis v2.2) and aborted transactions. + +- New signature for `Predis\Client::multiExec()` which is now able to accept + an array of options for the underlying instance of `Predis\MultiExecBlock`. + Backwards compatibility with previous releases of Predis is ensured. + +- New signature for `Predis\Client::pipeline()` which is now able to accept + an array of options for the underlying instance of Predis\CommandPipeline. + Backwards compatibility with previous releases of Predis is ensured. + The method `Predis\Client::pipelineSafe()` is to be considered deprecated. + +- __FIX__: The `WEIGHT` modifier for `ZUNIONSTORE` and `ZINTERSTORE` was + handled incorrectly with more than two weights specified. + + +v0.6.0 (2010-05-24) +================================================================================ + +- Switched to the new multi-bulk request protocol for all of the commands + in the Redis 1.2 and Redis 2.0 profiles. Inline and bulk requests are now + deprecated as they will be removed in future releases of Redis. + +- The default server profile is `2.0` (targeting Redis 2.0.x). If you are + using older versions of Redis, it is highly recommended that you specify + which server profile the client should use (e.g. `1.2` when connecting + to instances of Redis 1.2.x). + +- Support for Redis 1.0 is now optional and it is provided by requiring + 'Predis_Compatibility.php' before creating an instance of `Predis\Client`. + +- New commands added to the Redis 2.0 profile since Predis 0.5.1: + - Strings: `SETEX`, `APPEND`, `SUBSTR` + - ZSets : `ZCOUNT`, `ZRANK`, `ZUNIONSTORE`, `ZINTERSTORE`, `ZREMBYRANK`, + `ZREVRANK` + - Hashes : `HSET`, `HSETNX`, `HMSET`, `HINCRBY`, `HGET`, `HMGET`, `HDEL`, + `HEXISTS`, `HLEN`, `HKEYS`, `HVALS`, `HGETALL` + - PubSub : `PUBLISH`, `SUBSCRIBE`, `UNSUBSCRIBE` + - Misc. : `DISCARD`, `CONFIG` + +- Introduced client-level options with the new `Predis\ClientOptions` class. + Options can be passed to the constructor of `Predis\Client` in its second + argument as an array or an instance of `Predis\ClientOptions`. For brevity's + sake and compatibility with older versions, the constructor still accepts + an instance of `Predis\RedisServerProfile` in its second argument. The + currently supported client options are: + + - `profile` [default: `2.0` as of Predis 0.6.0]: specifies which server + profile to use when connecting to Redis. This option accepts an instance + of `Predis\RedisServerProfile` or a string that indicates the version. + + - `key_distribution` [default: `Predis\Distribution\HashRing`]: specifies + which key distribution strategy to use to distribute keys among the + servers that compose a cluster. This option accepts an instance of + `Predis\Distribution\IDistributionStrategy` so that users can implement + their own key distribution strategy. `Predis\Distribution\KetamaPureRing` + is an alternative distribution strategy providing a pure-PHP implementation + of the same algorithm used by libketama. + + - `throw_on_error` [default: `TRUE`]: server errors can optionally be handled + "silently": instead of throwing an exception, the client returns an error + response type. + + - `iterable_multibulk` [EXPERIMENTAL - default: `FALSE`]: in addition to the + classic way of fetching a whole multibulk reply into an array, the client + can now optionally stream a multibulk reply down to the user code by using + PHP iterators. It is just a little bit slower, but it can save a lot of + memory in certain scenarios. + +- New parameters for connections: + + - `alias` [default: not set]: every connection can now be identified by an + alias that is useful to get a specific connections when connected to a + cluster of Redis servers. + - `weight` [default: not set]: allows to balance keys asymmetrically across + multiple servers. This is useful when you have servers with different + amounts of memory to distribute the load of your keys accordingly. + - `connection_async` [default: `FALSE`]: estabilish connections to servers + in a non-blocking way, so that the client is not blocked while the socket + resource performs the actual connection. + - `connection_persistent` [default: `FALSE`]: the underlying socket resource + is left open when a script ends its lifecycle. Persistent connections can + lead to unpredictable or strange behaviours, so they should be used with + extreme care. + +- Introduced the `Predis\Pipeline\IPipelineExecutor` interface. Classes that + implements this interface are used internally by the `Predis\CommandPipeline` + class to change the behaviour of the pipeline when writing/reading commands + from one or multiple servers. Here is the list of the default executors: + + - `Predis\Pipeline\StandardExecutor`: exceptions generated by server errors + might be thrown depending on the options passed to the client (see the + `throw_on_error` client option). Instead, protocol or network errors always + throw exceptions. This is the default executor for single and clustered + connections and shares the same behaviour of Predis 0.5.x. + - `Predis\Pipeline\SafeExecutor`: exceptions generated by server, protocol + or network errors are not thrown but returned in the response array as + instances of `Predis\ResponseError` or `Predis\CommunicationException`. + - `Predis\Pipeline\SafeClusterExecutor`: this executor shares the same + behaviour of `Predis\Pipeline\SafeExecutor` but it is geared towards + clustered connections. + +- Support for PUB/SUB is handled by the new `Predis\PubSubContext` class, which + could also be used to build a callback dispatcher for PUB/SUB scenarios. + +- When connected to a cluster of connections, it is now possible to get a + new `Predis\Client` instance for a single connection of the cluster by + passing its alias/index to the new `Predis\Client::getClientFor()` method. + +- `Predis\CommandPipeline` and `Predis\MultiExecBlock` return their instances + when invokink commands, thus allowing method chaining in pipelines and + multi-exec blocks. + +- `Predis\MultiExecBlock` can handle the new `DISCARD` command. + +- Connections now support float values for the `connection_timeout` parameter + to express timeouts with a microsecond resolution. + +- __FIX__: TCP connections now respect the read/write timeout parameter when + reading the payload of server responses. Previously, `stream_get_contents()` + was being used internally to read data from a connection but it looks like + PHP does not honour the specified timeout for socket streams when inside + this function. + +- __FIX__: The `GET` parameter for the `SORT` command now accepts also multiple + key patterns by passing an array of strings. (ISSUE #1). + +* __FIX__: Replies to the `DEL` command return the number of elements deleted + by the server and not 0 or 1 interpreted as a boolean response. (ISSUE #4). + + +v0.5.1 (2010-01-23) +================================================================================ + +* `RPOPLPUSH` has been changed from bulk command to inline command in Redis + 1.2.1, so `ListPopLastPushHead` now extends `InlineCommand`. The old behavior + is still available via the `ListPopLastPushHeadBulk` class so that you can + override the server profile if you need the old (and uncorrect) behaviour + when connecting to a Redis 1.2.0 instance. + +* Added missing support for `BGREWRITEAOF` for Redis >= 1.2.0. + +* Implemented a factory method for the `RedisServerProfile` class to ease the + creation of new server profile instances based on a version string. + + +v0.5.0 (2010-01-09) +================================================================================ +* First versioned release of Predis diff --git a/vendor/predis/predis/CONTRIBUTING.md b/vendor/predis/predis/CONTRIBUTING.md new file mode 100755 index 0000000..8da3339 --- /dev/null +++ b/vendor/predis/predis/CONTRIBUTING.md @@ -0,0 +1,44 @@ +## Filing bug reports ## + +Bugs or feature requests can be posted on the [GitHub issues](http://github.com/nrk/predis/issues) +section of the project. + +When reporting bugs, in addition to the obvious description of your issue you __must__ always provide +some essential information about your environment such as: + + 1. version of Predis (check the `VERSION` file or the `Predis\Client::VERSION` constant). + 2. version of Redis (check `redis_version` returned by [`INFO`](http://redis.io/commands/info)). + 3. version of PHP. + 4. name and version of the operating system. + 5. when possible, a small snippet of code that reproduces the issue. + +__Think about it__: we do not have a crystal ball and cannot predict things or peer into the unknown +so please provide as much details as possible to help us isolating issues and fix them. + +__Never__ use GitHub issues to post generic questions about Predis! When you have questions about +how Predis works or how it can be used, please just hop me an email and I will get back to you as +soon as possible. + + +## Contributing code ## + +If you want to work on Predis, it is highly recommended that you first run the test suite in order +to check that everything is OK and report strange behaviours or bugs. When modifying Predis please +make sure that no warnings or notices are emitted by PHP running the interpreter in your development +environment with the `error_reporting` variable set to `E_ALL | E_STRICT`. + +The recommended way to contribute to Predis is to fork the project on GitHub, create topic branches +on your newly created repository to fix bugs or add new features (possibly with tests covering your +modifications) and then open a pull request with a description of the applied changes. Obviously you +can use any other Git hosting provider of your preference. + +We always aim for consistency in our code base so you should follow basic coding rules as defined by +[PSR-1](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-1-basic-coding-standard.md) +and [PSR-2](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md) +and stick with the conventions used in Predis to name classes and interfaces. Indentation should be +done with 4 spaces and code should be wrapped at 100 columns (please try to stay within this limit +even if the above mentioned official coding guidelines set the soft limit to 120 columns). + +Please follow these [commit guidelines](http://git-scm.com/book/ch5-2.html#Commit-Guidelines) when +committing your code to Git and always write a meaningful (not necessarily extended) description of +your changes before opening pull requests. diff --git a/vendor/predis/predis/FAQ.md b/vendor/predis/predis/FAQ.md new file mode 100755 index 0000000..607a42c --- /dev/null +++ b/vendor/predis/predis/FAQ.md @@ -0,0 +1,169 @@ +# Some frequently asked questions about Predis # +________________________________________________ + +### What is the point of Predis? ### + +The main point of Predis is about offering a highly customizable and extensible client for Redis, +that can be easily extended by developers while still being reasonabily fast. With Predis you can +swap almost any class with your own custom implementation: you can have custom connection classes, +new distribution strategies for client-side sharding, or handlers to replace or add Redis commands. +All of this can be achieved without messing with the source code of the library and directly in your +own application. Given the fast pace at which Redis is developed and adds new features, this can be +a great asset since it allows developers to add new and still missing features or commands or change +the standard behaviour of the library without the need to break dependencies in production code (at +least to some degree). + +### Does Predis support UNIX domain sockets and persistent connections? ### + +Yes. Obviously persistent connections actually work only when using PHP configured as a persistent +process reused by the web server (see [PHP-FPM](http://php-fpm.org)). + +### Does Predis support transparent (de)serialization of values? ### + +No and it will not ever do that by default. The reason behind this decision is that serialization is +usually something that developers prefer to customize depending on their needs and can not be easily +generalized when using Redis because of the many possible access patterns for your data. This does +not mean that it is impossible to have such a feature since you can leverage the extensibility of +this library to define your own serialization-aware commands. You can find more details about how to +do that [on this issue](http://github.com/nrk/predis/issues/29#issuecomment-1202624). + +### How can I force Predis to connect to Redis before sending any command? ### + +Explicitly connecting to Redis is usually not needed since the client initializes connections lazily +only when they are needed. Admittedly, this behavior can be inconvenient in certain scenarios when +you absolutely need to perform an upfront check to determine if the server is up and running and +eventually catch exceptions on failures. Forcing the client to open the underlying connection can be +done by invoking `Predis\Client::connect()`: + +```php +$client = new Predis\Client(); + +try { + $client->connect(); +} catch (Predis\Connection\ConnectionException $exception) { + // We could not connect to Redis! Your handling code goes here. +} + +$client->info(); +``` + +### How Predis abstracts Redis commands? ### + +The approach used to implement Redis commands is quite simple: by default each command follows the +same signature as defined on the [Redis documentation](http://redis.io/commands) which makes things +pretty easy if you already know how Redis works or you need to look up how to use certain commands. +Alternatively, variadic commands can accept an array for keys or values (depending on the command) +instead of a list of arguments. Commands such as [`RPUSH`](http://redis.io/commands/rpush) and +[`HMSET`](http://redis.io/commands/hmset) are great examples: + +```php +$client->rpush('my:list', 'value1', 'value2', 'value3'); // plain method arguments +$client->rpush('my:list', ['value1', 'value2', 'value3']); // single argument array + +$client->hmset('my:hash', 'field1', 'value1', 'field2', 'value2'); // plain method arguments +$client->hmset('my:hash', ['field1'=>'value1', 'field2'=>'value2']); // single named array +``` + +An exception to this rule is [`SORT`](http://redis.io/commands/sort) for which modifiers are passed +[using a named array](tests/Predis/Command/KeySortTest.php#L54-L75). + + +# Speaking about performances... # +_________________________________________________ + + +### Predis is a pure-PHP implementation: it can not be fast enough! ### + +It really depends, but most of the times the answer is: _yes, it is fast enough_. I will give you a +couple of easy numbers with a simple test that uses a single client and is executed by PHP 5.5.6 +against a local instance of Redis 2.8 that runs under Ubuntu 13.10 on a Intel Q6600: + +``` +21000 SET/sec using 12 bytes for both key and value. +21000 GET/sec while retrieving the very same values. +0.130 seconds to fetch 30000 keys using _KEYS *_. +``` + +How does it compare with [__phpredis__](http://github.com/nicolasff/phpredis), a nice C extension +providing an efficient client for Redis? + +``` +30100 SET/sec using 12 bytes for both key and value +29400 GET/sec while retrieving the very same values +0.035 seconds to fetch 30000 keys using "KEYS *"". +``` + +Wow __phpredis__ seems much faster! Well, we are comparing a C extension with a pure-PHP library so +lower numbers are quite expected but there is a fundamental flaw in them: is this really how you are +going to use Redis in your application? Are you really going to send thousands of commands using a +for-loop on each page request using a single client instance? If so... well I guess you are probably +doing something wrong. Also, if you need to `SET` or `GET` multiple keys you should definitely use +commands such as `MSET` and `MGET`. You can also use pipelining to get more performances when this +technique can be used. + +There is one more thing: we have tested the overhead of Predis by connecting on a localhost instance +of Redis but how these numbers change when we hit the physical network by connecting to remote Redis +instances? + +``` +Using Predis: +3200 SET/sec using 12 bytes for both key and value +3200 GET/sec while retrieving the very same values +0.132 seconds to fetch 30000 keys using "KEYS *". + +Using phpredis: +3500 SET/sec using 12 bytes for both key and value +3500 GET/sec while retrieving the very same values +0.045 seconds to fetch 30000 keys using "KEYS *". +``` + +There you go, you get almost the same average numbers and the reason is simple: network latency is a +real performance killer and you cannot do (almost) anything about that. As a disclaimer, remember +that we are measuring the overhead of client libraries implementations and the effects of network +round-trip times, so we are not really measuring how fast Redis is. Redis shines best with thousands +of concurrent clients doing requests! Also, actual performances should be measured according to how +your application will use Redis. + +### I am convinced, but performances for multi-bulk responses are still worse ### + +Fair enough, but there is an option available if you need even more speed and consists on installing +__[phpiredis](http://github.com/nrk/phpiredis)__ (note the additional _i_ in the name) and let the +client use it. __phpiredis__ is another C extension that wraps __hiredis__ (the official C client +library for Redis) with a thin layer exposing its features to PHP. You can then choose between two +different connection classes: + + - `Predis\Connection\PhpiredisStreamConnection` (using native PHP streams). + - `Predis\Connection\PhpiredisConnection` (requires `ext-socket`). + +You will now get the benefits of a faster protocol serializer and parser just by adding a couple of +lines of code: + +```php +$client = new Predis\Client('tcp://127.0.0.1', array( + 'connections' => array( + 'tcp' => 'Predis\Connection\PhpiredisStreamConnection', + 'unix' => 'Predis\Connection\PhpiredisConnection', + ), +)); +``` + +Dead simple. Nothing changes in the way you use the library in your application. So how fast is it +our basic benchmark script now? There are not much improvements for inline or short bulk responses +like the ones returned by `SET` and `GET`, but the speed for parsing multi-bulk responses is now on +par with phpredis: + +``` +Fatching 30000 keys with _KEYS *_ using Predis paired with phpiredis:: + +0.035 seconds from a local Redis instance +0.047 seconds from a remote Redis instance +``` + +### If I need an extension to get better performances, why not using phpredis? ### + +Good question. Generically speaking if you need absolute uber-speed using Redis on the localhost and +you do not care about abstractions built around some Redis features such as MULTI / EXEC, or if you +do not need any kind of extensibility or guaranteed backwards compatibility with different versions +of Redis (Predis currently supports from 1.2 up to 2.8 and the current development version), then +using __phpredis__ makes absolutely sense. Otherwise, Predis is perfect for the job and by adding +__phpiredis__ you can get a nice speed bump almost for free. diff --git a/vendor/predis/predis/LICENSE b/vendor/predis/predis/LICENSE new file mode 100755 index 0000000..dd35c23 --- /dev/null +++ b/vendor/predis/predis/LICENSE @@ -0,0 +1,22 @@ +Copyright (c) 2009-2014 Daniele Alessandri + +Permission is hereby granted, free of charge, to any person +obtaining a copy of this software and associated documentation +files (the "Software"), to deal in the Software without +restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. diff --git a/vendor/predis/predis/README.md b/vendor/predis/predis/README.md new file mode 100755 index 0000000..f502aa0 --- /dev/null +++ b/vendor/predis/predis/README.md @@ -0,0 +1,325 @@ +# Predis # + +[![Latest Stable Version](https://poser.pugx.org/predis/predis/v/stable.png)](https://packagist.org/packages/predis/predis) +[![Total Downloads](https://poser.pugx.org/predis/predis/downloads.png)](https://packagist.org/packages/predis/predis) + +Predis is a flexible and feature-complete [Redis](http://redis.io) client library for PHP >= 5.3. + +By default Predis does not require any additional C extension, but it can be optionally paired with +[phpiredis](https://github.com/nrk/phpiredis) to lower the overhead of serializing and parsing the +Redis protocol. An asynchronous implementation of the client, albeit experimental, is also available +through [Predis\Async](https://github.com/nrk/predis-async). + +More details about the project can be found in our [frequently asked questions](FAQ.md) section or +on the online [wiki](https://github.com/nrk/predis/wiki). + + +## Main features ## + +- Wide range of Redis versions supported (from __1.2__ to __2.8__ and unstable) using profiles. +- Clustering via client-side sharding using consistent hashing or custom distributors. +- Smart support for [redis-cluster](http://redis.io/topics/cluster-spec) (Redis >= 3.0). +- Support for master-slave replication configurations (write on master, read from slaves). +- Transparent key prefixing for all Redis commands. +- Command pipelining (works on both single and aggregate connections). +- Abstraction for Redis transactions (Redis >= 2.0) supporting CAS operations (Redis >= 2.2). +- Abstraction for Lua scripting (Redis >= 2.6) with automatic switching between `EVALSHA` or `EVAL`. +- Abstraction for `SCAN`, `SSCAN`, `ZSCAN` and `HSCAN` (Redis >= 2.8) based on PHP iterators. +- Connections to Redis are established lazily by the client upon the first command. +- Support for both TCP/IP and UNIX domain sockets and persistent connections. +- Support for [Webdis](http://webd.is) (both `ext-curl` and `ext-phpiredis` are needed). +- Support for custom connection classes for providing different network or protocol backends. +- Flexible system for defining and registering custom sets of supported commands or profiles. + + +## How to use Predis ## + +Predis is available on [Packagist](http://packagist.org/packages/predis/predis) which allows a quick +installation using [Composer](http://packagist.org/about-composer). Alternatively, the library can +be found on our [own PEAR channel](http://pear.nrk.io) for a more traditional installation via PEAR. +Ultimately, archives of each release are [available on GitHub](https://github.com/nrk/predis/tags). + + +### Loading the library ### + +Predis relies on the autoloading features of PHP to load its files when needed and complies with the +[PSR-0 standard](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-0.md) which makes +it compatible with most PHP frameworks. Autoloading is handled automatically when dependencies are +managed using Composer, but you can also leverage its own autoloader if you are going to use it in a +project or script without any PSR-0 compliant autoloading facility: + +```php +// Prepend a base path if Predis is not available in your "include_path". +require 'Predis/Autoloader.php'; + +Predis\Autoloader::register(); +``` + +It is possible to easily create a [phar](http://www.php.net/manual/en/intro.phar.php) archive from +the repository just by launching `bin/create-phar`. The generated phar contains a stub defining an +autoloader function for Predis, so you just need to require the phar to start using the library. +Alternatively, it is also possible to generate one single PHP file that holds every class like older +versions of Predis by launching `bin/create-single-file`, but this practice __is not__ encouraged. + + +### Connecting to Redis ### + +When not specifying any connection parameter to create a new client, Predis assumes `127.0.0.1` and +`6379` as the default host and port and uses a connection timeout of 5 seconds: + +```php +$client = new Predis\Client(); +$client->set('foo', 'bar'); +$value = $client->get('foo'); +``` + +Connection parameters can be supplied either in the form of URI strings or named arrays. While the +latter is the preferred way to supply parameters, URI strings can be useful for quick configurations +or when parameters are read from a non-structured source: + +```php +// Named array of connection parameters: +$client = new Predis\Client([ + 'scheme' => 'tcp', + 'host' => '10.0.0.1', + 'port' => 6379, +]); + +// Same set of parameters, but using an URI string: +$client = new Predis\Client('tcp://10.0.0.1:6379'); +``` + +When an array of connections parameters is provided, Predis automatically works in clustering mode +using client-side sharding. Both named arrays and URI strings can be mixed for providing each node +configuration: + +```php +$client = new Predis\Client([ + 'tcp://10.0.0.1?alias=first-node', + ['host' => '10.0.0.2', 'alias' => 'second-node'], +]); +``` + +The actual list of supported connection parameters can vary depending on each connection backend so +it is recommended to refer to their specific documentation for details. + + +### Client configuration ### + +Various aspects of the client can be easily configured by passing options to the second argument of +`Predis\Client::__construct()`. Options are managed using a mini DI-alike container and their values +are usually lazily initialized only when needed. Predis by default supports the following options: + + - `profile`: which profile to use in order to match a specific version of Redis. + - `prefix`: a prefix string that is automatically applied to keys found in commands. + - `exceptions`: whether the client should throw or return responses upon Redis errors. + - `connections`: connection backends or a connection factory to be used by the client. + - `cluster`: which backend to use for clustering (predis, redis or custom configuration). + - `replication`: which backend to use for replication (predis or custom configuration). + +Users can provide custom option values, they are stored in the options container and can be accessed +later through the library. + + +### Aggregate connections ### + +Predis is able to aggregate multiple connections which is the base for clustering and replication. +By default the client implements clustering using either client-side sharding (default) or a Redis +backed solution using [redis-cluster](http://redis.io/topics/cluster-tutorial). As for replication, +Predis can handle single-master and multiple-slaves setups by executing read operations on slaves +and switching to the master for write operations. The replication behaviour is fully configurable. + + +### Command pipelines ### + +Pipelining can help with performances when many commands need to be sent to a server by reducing the +latency introduced by network round-trip timings. Pipelining also works with aggregate connections. +The client can execute the pipeline inside a callable block or return a pipeline instance with the +ability to chain commands thanks to its fluent interface: + +```php +// Executes a pipeline inside a given callable block: +$responses = $client->pipeline(function ($pipe) { + for ($i = 0; $i < 1000; $i++) { + $pipe->set("key:$i", str_pad($i, 4, '0', 0)); + $pipe->get("key:$i"); + } +}); + +// Returns a pipeline instance with fluent interface: +$responses = $client->pipeline()->set('foo', 'bar')->get('foo')->execute(); +``` + + +### Transactions ### + +The client provides an abstraction for Redis transactions based on `MULTI` and `EXEC` with a similar +interface to command pipelines: + +```php +// Executes a transaction inside a given callable block: +$responses = $client->transaction(function ($tx) { + $tx->set('foo', 'bar'); + $tx->get('foo'); +}); + +// Returns a transaction instance with fluent interface: +$responses = $client->transaction()->set('foo', 'bar')->get('foo')->execute(); +``` + +This abstraction can perform check-and-set operations thanks to `WATCH` and `UNWATCH` and provides +automatic retries of transactions aborted by Redis when `WATCH`ed keys are touched. For an example +of a transaction using CAS you can see [the following example](examples/TransactionWithCAS.php). + +__NOTE__: the method `transaction()` is available since `v0.8.5`, older versions used `multiExec()` +for the same purpose but it has been deprecated and will be removed in the next major release. + + +### Customizable connection backends ### + +Predis can use different connection backends to connect to Redis. Two of them leverage a third party +extension such as [phpiredis](https://github.com/nrk/phpiredis) resulting in major performance gains +especially when dealing with big multibulk responses. While one is based on PHP streams, the other +is based on socket resources provided by `ext-socket`. Both support TCP/IP or UNIX domain sockets: + +```php +$client = new Predis\Client('tcp://127.0.0.1', [ + 'connections' => [ + 'tcp' => 'Predis\Connection\PhpiredisStreamConnection', // PHP streams + 'unix' => 'Predis\Connection\PhpiredisConnection', // ext-socket + ], +]); +``` + +Developers can create their own connection classes to add support for new network backends, extend +existing ones or provide completely different implementations. Connection classes must implement +`Predis\Connection\SingleConnectionInterface` or extend `Predis\Connection\AbstractConnection`: + +```php +class MyConnectionClass implements Predis\Connection\SingleConnectionInterface +{ + // Implementation goes here... +} + +// Use MyConnectionClass to handle connections for the `tcp` scheme: +$client = new Predis\Client('tcp://127.0.0.1', [ + 'connections' => ['tcp' => 'MyConnectionClass'], +]); +``` + +For a more in-depth insight on how to create new connection backends you can refer to the actual +implementation of the standard connection classes available in the `Predis\Connection` namespace. + + +### Adding support for new commands ### + +While we try to update Predis to stay up to date with all the commands available in Redis, you might +prefer to stick with an older version of the library or provide a different way to filter arguments +or parse responses for specific commands. To achieve that, Predis provides the ability to implement +new command classes to define or override commands in the server profiles used by the client: + +```php +// Define a new command by extending Predis\Command\AbstractCommand: +class BrandNewRedisCommand extends Predis\Command\AbstractCommand +{ + public function getId() + { + return 'NEWCMD'; + } +} + +// Inject your command in the current profile: +$client = new Predis\Client(); +$client->getProfile()->defineCommand('newcmd', 'BrandNewRedisCommand'); + +$response = $client->newcmd(); +``` + + +### Scriptable commands ### + +A scriptable command is just an abstraction for [Lua scripting](http://redis.io/commands/eval) that +aims to simplify the usage of scripting with Redis >= 2.6. Scriptable commands can be registered in +the server profile used by the client and are accessible as if they were plain Redis commands, but +they define a Lua script that gets transmitted to Redis for remote execution. Internally, scriptable +commands use by default [EVALSHA](http://redis.io/commands/evalsha) and identify a Lua script by its +SHA1 hash to save bandwidth but [EVAL](http://redis.io/commands/eval) is automatically preferred as +a fall back when needed: + +```php +// Define a new scriptable command by extending Predis\Command\ScriptedCommand: +class ListPushRandomValue extends Predis\Command\ScriptedCommand +{ + public function getKeysCount() + { + return 1; + } + + public function getScript() + { + return <<getProfile()->defineCommand('lpushrand', 'ListPushRandomValue'); + +$response = $client->lpushrand('random_values', $seed = mt_rand()); +``` + + +## Development ## + + +### Reporting bugs and contributing code ### + +Contributions to Predis are highly appreciated either in the form of pull requests for new features, +bug fixes, or just bug reports. We only ask you to adhere to a [basic set of rules](CONTRIBUTING.md) +before submitting your changes or filing bugs on the issue tracker to make it easier for everyone to +stay consistent while working on the project. + + +### Test suite ### + +__ATTENTION__: Do not ever run the test suite shipped with Predis against instances of Redis running +in production environments or containing data you are interested in! + +Predis has a comprehensive test suite covering every aspect of the library. This test suite performs +integration tests against a running instance of Redis (>= 2.4.0 is required) to verify the correct +behaviour of the implementation of each command and automatically skips commands not defined in the +specified Redis profile. If you do not have Redis up and running, integration tests can be disabled. +By default the test suite is configured to execute integration tests using the profile for Redis 2.6 +but can optionally target a Redis instance built from `2.8` or `unstable` branches by modifying the +`phpunit.xml` file and setting `REDIS_SERVER_VERSION` respectively to `2.8` or `dev` so that the +correct server profile will be used. You can refer to [the tests README](tests/README.md) for more +detailed information about testing Predis. + +Predis uses Travis CI for continuous integration and the history for past and current builds can be +found [on its project page](http://travis-ci.org/nrk/predis). + + +## Other ## + + +### Project related links ### + +- [Source code](https://github.com/nrk/predis) +- [Wiki](https://wiki.github.com/nrk/predis) +- [Issue tracker](https://github.com/nrk/predis/issues) +- [PEAR channel](http://pear.nrk.io) + + +### Author ### + +- [Daniele Alessandri](mailto:suppakilla@gmail.com) ([twitter](http://twitter.com/JoL1hAHN)) + + +### License ### + +The code for Predis is distributed under the terms of the MIT license (see [LICENSE](LICENSE)). diff --git a/vendor/predis/predis/VERSION b/vendor/predis/predis/VERSION new file mode 100755 index 0000000..7ada0d3 --- /dev/null +++ b/vendor/predis/predis/VERSION @@ -0,0 +1 @@ +0.8.5 diff --git a/vendor/predis/predis/autoload.php b/vendor/predis/predis/autoload.php new file mode 100755 index 0000000..be08eb1 --- /dev/null +++ b/vendor/predis/predis/autoload.php @@ -0,0 +1,14 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +require __DIR__.'/lib/Predis/Autoloader.php'; + +Predis\Autoloader::register(); diff --git a/vendor/predis/predis/bin/create-command-test b/vendor/predis/predis/bin/create-command-test new file mode 100755 index 0000000..f69b072 --- /dev/null +++ b/vendor/predis/predis/bin/create-command-test @@ -0,0 +1,271 @@ +#!/usr/bin/env php + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +// -------------------------------------------------------------------------- // +// This script can be used to automatically generate a file with the scheleton +// of a test case to test a Redis command by specifying the name of the class +// in the Predis\Command namespace (only classes in this namespace are valid). +// For example, to generate a test case for SET (which is represented by the +// Predis\Command\StringSet class): +// +// $ ./bin/generate-command-test.php --class=StringSet +// +// Here is a list of optional arguments: +// +// --realm: each command has its own realm (commands that operate on strings, +// lists, sets and such) but while this realm is usually inferred from the name +// of the specified class, sometimes it can be useful to override it with a +// custom one. +// +// --output: write the generated test case to the specified path instead of +// the default one. +// +// --overwrite: pre-existing test files are not overwritten unless this option +// is explicitly specified. +// -------------------------------------------------------------------------- // + +use Predis\Command\CommandInterface; +use Predis\Command\PrefixableCommandInterface; + +class CommandTestCaseGenerator +{ + private $options; + + public function __construct(Array $options) + { + if (!isset($options['class'])) { + throw new RuntimeException("Missing 'class' option."); + } + $this->options = $options; + } + + public static function fromCommandLine() + { + $parameters = array( + 'c:' => 'class:', + 'r::' => 'realm::', + 'o::' => 'output::', + 'x::' => 'overwrite::' + ); + + $getops = getopt(implode(array_keys($parameters)), $parameters); + + $options = array( + 'overwrite' => false, + 'tests' => __DIR__.'/../tests', + ); + + foreach ($getops as $option => $value) { + switch ($option) { + case 'c': + case 'class': + $options['class'] = $value; + break; + + case 'r': + case 'realm': + $options['realm'] = $value; + break; + + case 'o': + case 'output': + $options['output'] = $value; + break; + + case 'x': + case 'overwrite': + $options['overwrite'] = true; + break; + } + } + + if (!isset($options['class'])) { + throw new RuntimeException("Missing 'class' option."); + } + + $options['fqn'] = "Predis\\Command\\{$options['class']}"; + $options['path'] = "Predis/Command/{$options['class']}.php"; + + $source = __DIR__.'/../lib/'.$options['path']; + if (!file_exists($source)) { + throw new RuntimeException("Cannot find class file for {$options['fqn']} in $source."); + } + + if (!isset($options['output'])) { + $options['output'] = sprintf("%s/%s", $options['tests'], str_replace('.php', 'Test.php', $options['path'])); + } + + return new self($options); + } + + protected function getTestRealm() + { + if (isset($this->options['realm'])) { + if (!$this->options['realm']) { + throw new RuntimeException('Invalid value for realm has been sepcified (empty).'); + } + return $this->options['realm']; + } + + $fqnParts = explode('\\', $this->options['fqn']); + $class = array_pop($fqnParts); + list($realm,) = preg_split('/([[:upper:]][[:lower:]]+)/', $class, 2, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); + + return strtolower($realm); + } + + public function generate() + { + $reflection = new ReflectionClass($class = $this->options['fqn']); + + if (!$reflection->isInstantiable()) { + throw new RuntimeException("Class $class must be instantiable, abstract classes or interfaces are not allowed."); + } + if (!$reflection->implementsInterface('Predis\Command\CommandInterface')) { + throw new RuntimeException("Class $class must implement Predis\Command\CommandInterface."); + } + + $instance = $reflection->newInstance(); + $buffer = $this->getTestCaseBuffer($instance); + + return $buffer; + } + + public function save() + { + $options = $this->options; + if (file_exists($options['output']) && !$options['overwrite']) { + throw new RuntimeException("File {$options['output']} already exist. Specify the --overwrite option to overwrite the existing file."); + } + file_put_contents($options['output'], $this->generate()); + } + + protected function getTestCaseBuffer(CommandInterface $instance) + { + $id = $instance->getId(); + $fqn = get_class($instance); + $fqnParts = explode('\\', $fqn); + $class = array_pop($fqnParts) . "Test"; + $realm = $this->getTestRealm(); + + $buffer =<< + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @group commands + * @group realm-$realm + */ +class $class extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return '$fqn'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return '$id'; + } + + /** + * @group disconnected + */ + public function testFilterArguments() + { + \$this->markTestIncomplete('This test has not been implemented yet.'); + + \$arguments = array(/* add arguments */); + \$expected = array(/* add arguments */); + + \$command = \$this->getCommand(); + \$command->setArguments(\$arguments); + + \$this->assertSame(\$expected, \$command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse() + { + \$this->markTestIncomplete('This test has not been implemented yet.'); + + \$raw = null; + \$expected = null; + + \$command = \$this->getCommand(); + + \$this->assertSame(\$expected, \$command->parseResponse(\$raw)); + } + +PHP; + + if ($instance instanceof PrefixableCommandInterface) { + $buffer .=<<markTestIncomplete('This test has not been implemented yet.'); + + \$arguments = array(/* add arguments */); + \$expected = array(/* add arguments */); + + \$command = \$this->getCommandWithArgumentsArray(\$arguments); + \$command->prefixKeys('prefix:'); + + \$this->assertSame(\$expected, \$command->getArguments()); + } + + /** + * @group disconnected + */ + public function testPrefixKeysIgnoredOnEmptyArguments() + { + \$command = \$this->getCommand(); + \$command->prefixKeys('prefix:'); + + \$this->assertSame(array(), \$command->getArguments()); + } + +PHP; + } + + return "$buffer}\n"; + } +} + +// ------------------------------------------------------------------------- // + +require __DIR__.'/../autoload.php'; + +$generator = CommandTestCaseGenerator::fromCommandLine(); +$generator->save(); diff --git a/vendor/predis/predis/bin/create-pear b/vendor/predis/predis/bin/create-pear new file mode 100755 index 0000000..9d989e1 --- /dev/null +++ b/vendor/predis/predis/bin/create-pear @@ -0,0 +1,53 @@ +#!/usr/bin/env php + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +// -------------------------------------------------------------------------- // +// In order to be able to execute this script to create a PEAR package of Predis +// both `onion` and `pear` must be available and executable in your $PATH. +// -------------------------------------------------------------------------- // + +function executeWithBackup($file, $callback) +{ + $exception = null; + $backup = "$file.backup"; + + copy($file, $backup); + + try { + call_user_func($callback, $file); + } catch (Exception $exception) { + // NOOP + } + + unlink($file); + rename($backup, $file); + + if ($exception) { + throw $exception; + } +} + +function buildPackage() +{ + passthru('onion build && pear -q package && rm package.xml'); +} + +executeWithBackup(__DIR__.'/../phpunit.xml.dist', function ($file) { + $cfg = new SimpleXMLElement($file, null, true); + + $cfg[0]['bootstrap'] = str_replace('tests/', '', $cfg[0]['bootstrap']); + $cfg->testsuites->testsuite->directory = str_replace('tests/', '', $cfg->testsuites->testsuite->directory); + + $cfg->saveXml($file); + + buildPackage(); +}); diff --git a/vendor/predis/predis/bin/create-phar b/vendor/predis/predis/bin/create-phar new file mode 100755 index 0000000..fe0d31b --- /dev/null +++ b/vendor/predis/predis/bin/create-phar @@ -0,0 +1,71 @@ +#!/usr/bin/env php + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +// -------------------------------------------------------------------------- // +// In order to be able to execute this script to create a Phar archive of Predis, +// the Phar module must be loaded and the "phar.readonly" directive php.ini must +// be set to "off". You can change the values in the $options array to customize +// the creation of the Phar archive to better suit your needs. +// -------------------------------------------------------------------------- // + +$options = array( + 'name' => 'predis', + 'project_path' => __DIR__ . '/../lib/', + 'compression' => Phar::NONE, + 'append_version' => true, +); + +function getPharFilename($options) +{ + $filename = $options['name']; + + // NOTE: do not consider "append_version" with Phar compression do to a bug in + // Phar::compress() when renaming phar archives containing dots in their name. + if ($options['append_version'] && $options['compression'] === Phar::NONE) { + $versionFile = @fopen(__DIR__ . '/../VERSION', 'r'); + + if ($versionFile === false) { + throw new Exception("Could not locate the VERSION file."); + } + + $version = trim(fgets($versionFile)); + fclose($versionFile); + $filename .= "_$version"; + } + + return "$filename.phar"; +} + +function getPharStub($options) +{ + return <<compress($options['compression']); +$phar->setStub(getPharStub($options)); +$phar->buildFromDirectory($options['project_path']); diff --git a/vendor/predis/predis/bin/create-single-file b/vendor/predis/predis/bin/create-single-file new file mode 100755 index 0000000..8a79988 --- /dev/null +++ b/vendor/predis/predis/bin/create-single-file @@ -0,0 +1,663 @@ +#!/usr/bin/env php + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +// -------------------------------------------------------------------------- // +// This script can be used to automatically glue all the .php files of Predis +// into a single monolithic script file that can be used without an autoloader, +// just like the other previous versions of the library. +// +// Much of its complexity is due to the fact that we cannot simply join PHP +// files, but namespaces and classes definitions must follow a precise order +// when dealing with subclassing and inheritance. +// +// The current implementation is pretty naïve, but it should do for now. +// -------------------------------------------------------------------------- // + +class CommandLine +{ + public static function getOptions() + { + $parameters = array( + 's:' => 'source:', + 'o:' => 'output:', + 'e:' => 'exclude:', + 'E:' => 'exclude-classes:', + ); + + $getops = getopt(implode(array_keys($parameters)), $parameters); + + $options = array( + 'source' => __DIR__ . "/../lib/", + 'output' => PredisFile::NS_ROOT . '.php', + 'exclude' => array(), + ); + + foreach ($getops as $option => $value) { + switch ($option) { + case 's': + case 'source': + $options['source'] = $value; + break; + + case 'o': + case 'output': + $options['output'] = $value; + break; + + case 'E': + case 'exclude-classes': + $options['exclude'] = @file($value, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES) ?: $value; + break; + + case 'e': + case 'exclude': + $options['exclude'] = is_array($value) ? $value : array($value); + break; + } + } + + return $options; + } +} + +class PredisFile +{ + const NS_ROOT = 'Predis'; + + private $namespaces; + + public function __construct() + { + $this->namespaces = array(); + } + + public static function from($libraryPath, Array $exclude = array()) + { + $nsroot = self::NS_ROOT; + $predisFile = new PredisFile(); + $libIterator = new RecursiveDirectoryIterator("$libraryPath$nsroot"); + + foreach (new RecursiveIteratorIterator($libIterator) as $classFile) + { + if (!$classFile->isFile()) { + continue; + } + + $namespace = strtr(str_replace($libraryPath, '', $classFile->getPath()), '/', '\\'); + + if (in_array(sprintf('%s\\%s', $namespace, $classFile->getBasename('.php')), $exclude)) { + continue; + } + + $phpNamespace = $predisFile->getNamespace($namespace); + + if ($phpNamespace === false) { + $phpNamespace = new PhpNamespace($namespace); + $predisFile->addNamespace($phpNamespace); + } + + $phpClass = new PhpClass($phpNamespace, $classFile); + } + + return $predisFile; + } + + public function addNamespace(PhpNamespace $namespace) + { + if (isset($this->namespaces[(string)$namespace])) { + throw new InvalidArgumentException("Duplicated namespace"); + } + $this->namespaces[(string)$namespace] = $namespace; + } + + public function getNamespaces() + { + return $this->namespaces; + } + + public function getNamespace($namespace) + { + if (!isset($this->namespaces[$namespace])) { + return false; + } + + return $this->namespaces[$namespace]; + } + + public function getClassByFQN($classFqn) + { + if (($nsLastPos = strrpos($classFqn, '\\')) !== false) { + $namespace = $this->getNamespace(substr($classFqn, 0, $nsLastPos)); + if ($namespace === false) { + return null; + } + $className = substr($classFqn, $nsLastPos + 1); + + return $namespace->getClass($className); + } + + return null; + } + + private function calculateDependencyScores(&$classes, $fqn) + { + if (!isset($classes[$fqn])) { + $classes[$fqn] = 0; + } + + $classes[$fqn] += 1; + + if (($phpClass = $this->getClassByFQN($fqn)) === null) { + throw new RuntimeException( + "Cannot found the class $fqn which is required by other subclasses. Are you missing a file?" + ); + } + + foreach ($phpClass->getDependencies() as $fqn) { + $this->calculateDependencyScores($classes, $fqn); + } + } + + private function getDependencyScores() + { + $classes = array(); + + foreach ($this->getNamespaces() as $phpNamespace) { + foreach ($phpNamespace->getClasses() as $phpClass) { + $this->calculateDependencyScores($classes, $phpClass->getFQN()); + } + } + + return $classes; + } + + private function getOrderedNamespaces($dependencyScores) + { + $namespaces = array_fill_keys(array_unique( + array_map( + function ($fqn) { return PhpNamespace::extractName($fqn); }, + array_keys($dependencyScores) + ) + ), 0); + + foreach ($dependencyScores as $classFqn => $score) { + $namespaces[PhpNamespace::extractName($classFqn)] += $score; + } + + arsort($namespaces); + + return array_keys($namespaces); + } + + private function getOrderedClasses(PhpNamespace $phpNamespace, $classes) + { + $nsClassesFQNs = array_map(function ($cl) { return $cl->getFQN(); }, $phpNamespace->getClasses()); + $nsOrderedClasses = array(); + + foreach ($nsClassesFQNs as $nsClassFQN) { + $nsOrderedClasses[$nsClassFQN] = $classes[$nsClassFQN]; + } + + arsort($nsOrderedClasses); + + return array_keys($nsOrderedClasses); + } + + public function getPhpCode() + { + $buffer = array("getDependencyScores(); + $namespaces = $this->getOrderedNamespaces($classes); + + foreach ($namespaces as $namespace) { + $phpNamespace = $this->getNamespace($namespace); + + // generate namespace directive + $buffer[] = $phpNamespace->getPhpCode(); + $buffer[] = "\n"; + + // generate use directives + $useDirectives = $phpNamespace->getUseDirectives(); + if (count($useDirectives) > 0) { + $buffer[] = $useDirectives->getPhpCode(); + $buffer[] = "\n"; + } + + // generate classes bodies + $nsClasses = $this->getOrderedClasses($phpNamespace, $classes); + foreach ($nsClasses as $classFQN) { + $buffer[] = $this->getClassByFQN($classFQN)->getPhpCode(); + $buffer[] = "\n\n"; + } + + $buffer[] = "/* " . str_repeat("-", 75) . " */"; + $buffer[] = "\n\n"; + } + + return implode($buffer); + } + + public function saveTo($outputFile) + { + // TODO: add more sanity checks + if ($outputFile === null || $outputFile === '') { + throw new InvalidArgumentException('You must specify a valid output file'); + } + file_put_contents($outputFile, $this->getPhpCode()); + } +} + +class PhpNamespace implements IteratorAggregate +{ + private $namespace; + private $classes; + + public function __construct($namespace) + { + $this->namespace = $namespace; + $this->classes = array(); + $this->useDirectives = new PhpUseDirectives($this); + } + + public static function extractName($fqn) + { + $nsSepLast = strrpos($fqn, '\\'); + if ($nsSepLast === false) { + return $fqn; + } + $ns = substr($fqn, 0, $nsSepLast); + + return $ns !== '' ? $ns : null; + } + + public function addClass(PhpClass $class) + { + $this->classes[$class->getName()] = $class; + } + + public function getClass($className) + { + if (isset($this->classes[$className])) { + return $this->classes[$className]; + } + } + + public function getClasses() + { + return array_values($this->classes); + } + + public function getIterator() + { + return new \ArrayIterator($this->getClasses()); + } + + public function getUseDirectives() + { + return $this->useDirectives; + } + + public function getPhpCode() + { + return "namespace $this->namespace;\n"; + } + + public function __toString() + { + return $this->namespace; + } +} + +class PhpUseDirectives implements Countable, IteratorAggregate +{ + private $use; + private $aliases; + private $reverseAliases; + private $namespace; + + public function __construct(PhpNamespace $namespace) + { + $this->namespace = $namespace; + $this->use = array(); + $this->aliases = array(); + $this->reverseAliases = array(); + } + + public function add($use, $as = null) + { + if (in_array($use, $this->use)) { + return; + } + + $rename = null; + $this->use[] = $use; + $aliasedClassName = $as ?: PhpClass::extractName($use); + + if (isset($this->aliases[$aliasedClassName])) { + $parentNs = $this->getParentNamespace(); + + if ($parentNs && false !== $pos = strrpos($parentNs, '\\')) { + $parentNs = substr($parentNs, $pos); + } + + $newAlias = "{$parentNs}_{$aliasedClassName}"; + $rename = (object) array( + 'namespace' => $this->namespace, + 'from' => $aliasedClassName, + 'to' => $newAlias, + ); + + $this->aliases[$newAlias] = $use; + $as = $newAlias; + } else { + $this->aliases[$aliasedClassName] = $use; + } + + if ($as !== null) { + $this->reverseAliases[$use] = $as; + } + + return $rename; + } + + public function getList() + { + return $this->use; + } + + public function getIterator() + { + return new \ArrayIterator($this->getList()); + } + + public function getPhpCode() + { + $reverseAliases = $this->reverseAliases; + + $reducer = function ($str, $use) use ($reverseAliases) { + if (isset($reverseAliases[$use])) { + return $str .= "use $use as {$reverseAliases[$use]};\n"; + } else { + return $str .= "use $use;\n"; + } + }; + + return array_reduce($this->getList(), $reducer, ''); + } + + public function getNamespace() + { + return $this->namespace; + } + + public function getParentNamespace() + { + if (false !== $pos = strrpos($this->namespace, '\\')) { + return substr($this->namespace, 0, $pos); + } + + return ''; + } + + public function getFQN($className) + { + if (($nsSepFirst = strpos($className, '\\')) === false) { + if (isset($this->aliases[$className])) { + return $this->aliases[$className]; + } + + return (string)$this->getNamespace() . "\\$className"; + } + + if ($nsSepFirst != 0) { + throw new InvalidArgumentException("Partially qualified names are not supported"); + } + + return $className; + } + + public function count() + { + return count($this->use); + } +} + +class PhpClass +{ + const LICENSE_HEADER = << + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ +LICENSE; + + private $namespace; + private $file; + private $body; + private $implements; + private $extends; + private $name; + + public function __construct(PhpNamespace $namespace, SplFileInfo $classFile) + { + $this->namespace = $namespace; + $this->file = $classFile; + $this->implements = array(); + $this->extends = array(); + + $this->extractData(); + $namespace->addClass($this); + } + + public static function extractName($fqn) + { + $nsSepLast = strrpos($fqn, '\\'); + if ($nsSepLast === false) { + return $fqn; + } + + return substr($fqn, $nsSepLast + 1); + } + + private function extractData() + { + $renames = array(); + $useDirectives = $this->getNamespace()->getUseDirectives(); + + $useExtractor = function ($m) use ($useDirectives, &$renames) { + array_shift($m); + + if (isset($m[1])) { + $m[1] = str_replace(" as ", '', $m[1]); + } + + if ($rename = call_user_func_array(array($useDirectives, 'add'), $m)) { + $renames[] = $rename; + } + }; + + $classBuffer = stream_get_contents(fopen($this->getFile()->getPathname(), 'r')); + + $classBuffer = str_replace(self::LICENSE_HEADER, '', $classBuffer); + + $classBuffer = preg_replace('/<\?php\s?\\n\s?/', '', $classBuffer); + $classBuffer = preg_replace('/\s?\?>\n?/ms', '', $classBuffer); + $classBuffer = preg_replace('/namespace\s+[\w\d_\\\\]+;\s?/', '', $classBuffer); + $classBuffer = preg_replace_callback('/use\s+([\w\d_\\\\]+)(\s+as\s+.*)?;\s?\n?/', $useExtractor, $classBuffer); + + foreach ($renames as $rename) { + $classBuffer = str_replace($rename->from, $rename->to, $classBuffer); + } + + $this->body = trim($classBuffer); + + $this->extractHierarchy(); + } + + private function extractHierarchy() + { + $implements = array(); + $extends = array(); + + $extractor = function ($iterator, $callback) { + $className = ''; + $iterator->seek($iterator->key() + 1); + + while ($iterator->valid()) { + $token = $iterator->current(); + + if (is_string($token)) { + if (preg_match('/\s?,\s?/', $token)) { + $callback(trim($className)); + $className = ''; + } else if ($token == '{') { + $callback(trim($className)); + return; + } + } + + switch ($token[0]) { + case T_NS_SEPARATOR: + $className .= '\\'; + break; + + case T_STRING: + $className .= $token[1]; + break; + + case T_IMPLEMENTS: + case T_EXTENDS: + $callback(trim($className)); + $iterator->seek($iterator->key() - 1); + return; + } + + $iterator->next(); + } + }; + + $tokens = token_get_all("getPhpCode())); + $iterator = new ArrayIterator($tokens); + + while ($iterator->valid()) { + $token = $iterator->current(); + if (is_string($token)) { + $iterator->next(); + continue; + } + + switch ($token[0]) { + case T_CLASS: + case T_INTERFACE: + $iterator->seek($iterator->key() + 2); + $tk = $iterator->current(); + $this->name = $tk[1]; + break; + + case T_IMPLEMENTS: + $extractor($iterator, function ($fqn) use (&$implements) { + $implements[] = $fqn; + }); + break; + + case T_EXTENDS: + $extractor($iterator, function ($fqn) use (&$extends) { + $extends[] = $fqn; + }); + break; + } + + $iterator->next(); + } + + $this->implements = $this->guessFQN($implements); + $this->extends = $this->guessFQN($extends); + } + + public function guessFQN($classes) + { + $useDirectives = $this->getNamespace()->getUseDirectives(); + return array_map(array($useDirectives, 'getFQN'), $classes); + } + + public function getImplementedInterfaces($all = false) + { + if ($all) { + return $this->implements; + } + + return array_filter( + $this->implements, + function ($cn) { return strpos($cn, 'Predis\\') === 0; } + ); + } + + public function getExtendedClasses($all = false) + { + if ($all) { + return $this->extemds; + } + + return array_filter( + $this->extends, + function ($cn) { return strpos($cn, 'Predis\\') === 0; } + ); + } + + public function getDependencies($all = false) + { + return array_merge( + $this->getImplementedInterfaces($all), + $this->getExtendedClasses($all) + ); + } + + public function getNamespace() + { + return $this->namespace; + } + + public function getFile() + { + return $this->file; + } + + public function getName() + { + return $this->name; + } + + public function getFQN() + { + return (string)$this->getNamespace() . '\\' . $this->name; + } + + public function getPhpCode() + { + return $this->body; + } + + public function __toString() + { + return "class " . $this->getName() . '{ ... }'; + } +} + +/* -------------------------------------------------------------------------- */ + +$options = CommandLine::getOptions(); +$predisFile = PredisFile::from($options['source'], $options['exclude']); +$predisFile->saveTo($options['output']); diff --git a/vendor/predis/predis/composer.json b/vendor/predis/predis/composer.json new file mode 100755 index 0000000..3b1c2fd --- /dev/null +++ b/vendor/predis/predis/composer.json @@ -0,0 +1,25 @@ +{ + "name": "predis/predis", + "type": "library", + "description": "Flexible and feature-complete PHP client library for Redis", + "keywords": ["nosql", "redis", "predis"], + "homepage": "http://github.com/nrk/predis", + "license": "MIT", + "authors": [ + { + "name": "Daniele Alessandri", + "email": "suppakilla@gmail.com", + "homepage": "http://clorophilla.net" + } + ], + "require": { + "php": ">=5.3.2" + }, + "suggest": { + "ext-phpiredis": "Allows faster serialization and deserialization of the Redis protocol", + "ext-curl": "Allows access to Webdis when paired with phpiredis" + }, + "autoload": { + "psr-0": {"Predis": "lib/"} + } +} diff --git a/vendor/predis/predis/examples/CustomDistributionStrategy.php b/vendor/predis/predis/examples/CustomDistributionStrategy.php new file mode 100755 index 0000000..052b6c0 --- /dev/null +++ b/vendor/predis/predis/examples/CustomDistributionStrategy.php @@ -0,0 +1,89 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +require 'SharedConfigurations.php'; + +// Developers can customize the distribution strategy used by the client +// to distribute keys among a cluster of servers simply by creating a class +// that implements Predis\Distribution\DistributionStrategyInterface. + +use Predis\Connection\PredisCluster; +use Predis\Cluster\Distribution\DistributionStrategyInterface; +use Predis\Cluster\Hash\HashGeneratorInterface; + +class NaiveDistributionStrategy implements DistributionStrategyInterface, HashGeneratorInterface +{ + private $nodes; + private $nodesCount; + + public function __construct() + { + $this->nodes = array(); + $this->nodesCount = 0; + } + + public function add($node, $weight = null) + { + $this->nodes[] = $node; + $this->nodesCount++; + } + + public function remove($node) + { + $this->nodes = array_filter($this->nodes, function ($n) use ($node) { + return $n !== $node; + }); + + $this->nodesCount = count($this->nodes); + } + + public function get($key) + { + if (0 === $count = $this->nodesCount) { + throw new RuntimeException('No connections'); + } + + return $this->nodes[$count > 1 ? abs($key % $count) : 0]; + } + + public function hash($value) + { + return crc32($value); + } + + public function getHashGenerator() + { + return $this; + } +} + +$options = array( + 'cluster' => function () { + $distributor = new NaiveDistributionStrategy(); + $cluster = new PredisCluster($distributor); + + return $cluster; + }, +); + +$client = new Predis\Client($multiple_servers, $options); + +for ($i = 0; $i < 100; $i++) { + $client->set("key:$i", str_pad($i, 4, '0', 0)); + $client->get("key:$i"); +} + +$server1 = $client->getClientFor('first')->info(); +$server2 = $client->getClientFor('second')->info(); + +printf("Server '%s' has %d keys while server '%s' has %d keys.\n", + 'first', $server1['db15']['keys'], 'second', $server2['db15']['keys'] +); diff --git a/vendor/predis/predis/examples/DispatcherLoop.php b/vendor/predis/predis/examples/DispatcherLoop.php new file mode 100755 index 0000000..f5b8a99 --- /dev/null +++ b/vendor/predis/predis/examples/DispatcherLoop.php @@ -0,0 +1,78 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +require 'SharedConfigurations.php'; + +/* +This is a basic example on how to use the Predis\DispatcherLoop class. + +To see this example in action you can just use redis-cli and publish some +messages to the 'events' and 'control' channel, e.g.: + +./redis-cli +PUBLISH events first +PUBLISH events second +PUBLISH events third +PUBLISH control terminate_dispatcher +*/ + +// Create a client and disable r/w timeout on the socket +$client = new Predis\Client($single_server + array('read_write_timeout' => 0)); + +// Create a Predis\DispatcherLoop instance and attach a bunch of callbacks. +$dispatcher = new Predis\PubSub\DispatcherLoop($client); + +// Demonstrate how to use a callable class as a callback for Predis\DispatcherLoop. +class EventsListener implements Countable +{ + private $events; + + public function __construct() + { + $this->events = array(); + } + + public function count() + { + return count($this->events); + } + + public function getEvents() + { + return $this->events; + } + + public function __invoke($payload) + { + $this->events[] = $payload; + } +} + +// Attach our callable class to the dispatcher. +$dispatcher->attachCallback('events', ($events = new EventsListener())); + +// Attach a function to control the dispatcher loop termination with a message. +$dispatcher->attachCallback('control', function ($payload) use ($dispatcher) { + if ($payload === 'terminate_dispatcher') { + $dispatcher->stop(); + } +}); + +// Run the dispatcher loop until the callback attached to the 'control' channel +// receives 'terminate_dispatcher' as a message. +$dispatcher->run(); + +// Display our achievements! +echo "We received {$events->count()} messages!\n"; + +// Say goodbye :-) +$info = $client->info(); +print_r("Goodbye from Redis v{$info['redis_version']}!\n"); diff --git a/vendor/predis/predis/examples/KeyPrefixes.php b/vendor/predis/predis/examples/KeyPrefixes.php new file mode 100755 index 0000000..4979676 --- /dev/null +++ b/vendor/predis/predis/examples/KeyPrefixes.php @@ -0,0 +1,37 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +require 'SharedConfigurations.php'; + +// Predis ships with a KeyPrefixProcessor class that is used to transparently +// prefix each key before sending commands to Redis, even for complex commands +// such as SORT, ZUNIONSTORE and ZINTERSTORE. Key prefixes are useful to create +// user-level namespaces for you keyspace, thus eliminating the need for separate +// logical databases. + +$client = new Predis\Client($single_server, array('prefix' => 'nrk:')); + +$client->mset(array('foo' => 'bar', 'lol' => 'wut')); +var_dump($client->mget('foo', 'lol')); +/* +array(2) { + [0]=> string(3) "bar" + [1]=> string(3) "wut" +} +*/ + +var_dump($client->keys('*')); +/* +array(2) { + [0]=> string(7) "nrk:foo" + [1]=> string(7) "nrk:lol" +} +*/ diff --git a/vendor/predis/predis/examples/MasterSlaveReplication.php b/vendor/predis/predis/examples/MasterSlaveReplication.php new file mode 100755 index 0000000..df7e16c --- /dev/null +++ b/vendor/predis/predis/examples/MasterSlaveReplication.php @@ -0,0 +1,52 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +require 'SharedConfigurations.php'; + +// Predis supports master / slave replication scenarios where write operations are +// performed on the master server and read operations are executed against one of +// the slaves. The behaviour of commands or EVAL scripts can be customized at will. +// As soon as a write operation is performed, all the subsequent requests (reads +// or writes) will be served by the master server. +// +// This example must be executed with the second Redis server acting as the slave +// of the first one using the SLAVEOF command. +// + +$parameters = array( + 'tcp://127.0.0.1:6379?database=15&alias=master', + 'tcp://127.0.0.1:6380?database=15&alias=slave', +); + +$options = array('replication' => true); + +$client = new Predis\Client($parameters, $options); + +// Read operation. +$exists = $client->exists('foo') ? 'yes' : 'no'; +$current = $client->getConnection()->getCurrent()->getParameters(); +echo "Does 'foo' exist on {$current->alias}? $exists.\n"; + +// Write operation. +$client->set('foo', 'bar'); +$current = $client->getConnection()->getCurrent()->getParameters(); +echo "Now 'foo' has been set to 'bar' on {$current->alias}!\n"; + +// Read operation. +$bar = $client->get('foo'); +$current = $client->getConnection()->getCurrent()->getParameters(); +echo "We just fetched 'foo' from {$current->alias} and its value is '$bar'.\n"; + +/* OUTPUT: +Does 'foo' exist on slave? yes. +Now 'foo' has been set to 'bar' on master! +We just fetched 'foo' from master and its value is 'bar'. +*/ diff --git a/vendor/predis/predis/examples/MasterSlaveReplicationComplex.php b/vendor/predis/predis/examples/MasterSlaveReplicationComplex.php new file mode 100755 index 0000000..786d595 --- /dev/null +++ b/vendor/predis/predis/examples/MasterSlaveReplicationComplex.php @@ -0,0 +1,84 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +require 'SharedConfigurations.php'; + +// Predis allows to set Lua scripts as read-only operations in the context of +// replication. This works for both EVAL and EVALSHA and also for the client-side +// abstraction built upon them (Predis\Command\ScriptedCommand). This example +// shows a slightly more complex configuration that injects a new scripted command +// in the server profile used by the new client instance and marks it marks it as +// a read-only operation for replication so that it will be executed on slaves. + +use Predis\Command\ScriptedCommand; +use Predis\Connection\MasterSlaveReplication; +use Predis\Profile\ServerProfile; +use Predis\Replication\ReplicationStrategy; + +// ------------------------------------------------------------------------- // + +// Define a new scripted command that returns all the fields +// of a variable number of hashes with a single roundtrip. + +class HashMultipleGetAll extends ScriptedCommand { + const BODY = << function ($options, $option) { + $profile = $options->getDefault($option); + $profile->defineCommand('hmgetall', 'HashMultipleGetAll'); + + return $profile; + }, + 'replication' => function ($options) { + $strategy = new ReplicationStrategy(); + $strategy->setScriptReadOnly(HashMultipleGetAll::BODY); + + $replication = new MasterSlaveReplication($strategy); + + return $replication; + }, +); + +// ------------------------------------------------------------------------- // + +$client = new Predis\Client($parameters, $options); + +// Execute the following commands on the master server using redis-cli: +// $ ./redis-cli HMSET metavars foo bar hoge piyo +// $ ./redis-cli HMSET servers master host1 slave host2 + +$hashes = $client->hmgetall('metavars', 'servers'); + +$replication = $client->getConnection(); +$stillOnSlave = $replication->getCurrent() === $replication->getConnectionById('slave'); + +echo "Is still on slave? ", $stillOnSlave ? 'YES' : 'NO', "!\n"; +var_export($hashes); diff --git a/vendor/predis/predis/examples/MonitorContext.php b/vendor/predis/predis/examples/MonitorContext.php new file mode 100755 index 0000000..e1cad74 --- /dev/null +++ b/vendor/predis/predis/examples/MonitorContext.php @@ -0,0 +1,44 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +require 'SharedConfigurations.php'; + +// This is a basic example on how to use the Predis\MonitorContext class. +// You can use redis-cli to send commands to the same Redis instance your client is +// connected to, and then type "ECHO QUIT_MONITOR" in redis-cli when you want to +// exit the monitor loop and terminate this script in a graceful way. + +// Create a client and disable r/w timeout on the socket. +$client = new Predis\Client($single_server + array('read_write_timeout' => 0)); + +// Use only one instance of DateTime, we will update the timestamp later. +$timestamp = new DateTime(); + +foreach (($monitor = $client->monitor()) as $event) { + $timestamp->setTimestamp((int) $event->timestamp); + + // If we notice a ECHO command with the message QUIT_MONITOR, we close the + // monitor context and then break the loop. + if ($event->command === 'ECHO' && $event->arguments === '"QUIT_MONITOR"') { + echo "Exiting the monitor loop...\n"; + $monitor->closeContext(); + break; + } + + echo "* Received {$event->command} on DB {$event->database} at {$timestamp->format(DateTime::W3C)}\n"; + if (isset($event->arguments)) { + echo " Arguments: {$event->arguments}\n"; + } +} + +// Say goodbye :-) +$info = $client->info(); +print_r("Goodbye from Redis v{$info['redis_version']}!\n"); diff --git a/vendor/predis/predis/examples/MultiBulkReplyIterators.php b/vendor/predis/predis/examples/MultiBulkReplyIterators.php new file mode 100755 index 0000000..27c51b9 --- /dev/null +++ b/vendor/predis/predis/examples/MultiBulkReplyIterators.php @@ -0,0 +1,56 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +require 'SharedConfigurations.php'; + +// Operations such as LRANGE, ZRANGE and others can potentially generate replies +// containing a huge number of items. In some corner cases, such replies might +// end up exhausting the maximum allowed memory allocated for a PHP process. +// Multibulk iterators can be handy because they allow you to stream multibulk +// replies using plain old PHP iterators, making it possible to iterate them with +// a classic `foreach` loop and avoiding to consume an excessive amount of memory. +// +// PS: please note that multibulk iterators are supported only by the standard +// connection backend class (Predis\Connection\StreamConnection) and not the +// phpiredis-based one (Predis\Connection\PhpiredisConnection). + +// Create a client and force the connection to use iterable multibulk responses. +$client = new Predis\Client($single_server + array('iterable_multibulk' => true)); + +// Prepare an hash with some fields and their respective values. +$client->hmset('metavars', array('foo' => 'bar', 'hoge' => 'piyo', 'lol' => 'wut')); + +// By default multibulk iterators iterate over the reply as a list of items... +foreach ($client->hgetall('metavars') as $index => $item) { + echo "[$index] $item\n"; +} + +/* OUTPUT: +[0] foo +[1] bar +[2] hoge +[3] piyo +[4] lol +[5] wut +*/ + +// ... but certain multibulk replies are better represented as lists of tuples. +foreach ($client->hgetall('metavars')->asTuple() as $index => $kv) { + list($key, $value) = $kv; + + echo "[$index] $key => $value\n"; +} + +/* OUTPUT: +[0] foo => bar +[1] hoge => piyo +[2] lol => wut +*/ diff --git a/vendor/predis/predis/examples/MultipleSetAndGet.php b/vendor/predis/predis/examples/MultipleSetAndGet.php new file mode 100755 index 0000000..864f827 --- /dev/null +++ b/vendor/predis/predis/examples/MultipleSetAndGet.php @@ -0,0 +1,38 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +require 'SharedConfigurations.php'; + +// redis can set keys and their relative values in one go +// using MSET, then the same values can be retrieved with +// a single command using MGET. + +$mkv = array( + 'usr:0001' => 'First user', + 'usr:0002' => 'Second user', + 'usr:0003' => 'Third user' +); + +$client = new Predis\Client($single_server); + +$client->mset($mkv); +$retval = $client->mget(array_keys($mkv)); + +print_r($retval); + +/* OUTPUT: +Array +( + [0] => First user + [1] => Second user + [2] => Third user +) +*/ diff --git a/vendor/predis/predis/examples/PipelineContext.php b/vendor/predis/predis/examples/PipelineContext.php new file mode 100755 index 0000000..57fa638 --- /dev/null +++ b/vendor/predis/predis/examples/PipelineContext.php @@ -0,0 +1,47 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +require 'SharedConfigurations.php'; + +// When you have a whole set of consecutive commands to send to +// a redis server, you can use a pipeline to improve performances. + +$client = new Predis\Client($single_server); + +$replies = $client->pipeline(function ($pipe) { + $pipe->ping(); + $pipe->flushdb(); + $pipe->incrby('counter', 10); + $pipe->incrby('counter', 30); + $pipe->exists('counter'); + $pipe->get('counter'); + $pipe->mget('does_not_exist', 'counter'); +}); + +print_r($replies); + +/* OUTPUT: +Array +( + [0] => 1 + [1] => 1 + [2] => 10 + [3] => 40 + [4] => 1 + [5] => 40 + [6] => Array + ( + [0] => + [1] => 40 + ) + +) +*/ diff --git a/vendor/predis/predis/examples/PubSubContext.php b/vendor/predis/predis/examples/PubSubContext.php new file mode 100755 index 0000000..42428c3 --- /dev/null +++ b/vendor/predis/predis/examples/PubSubContext.php @@ -0,0 +1,59 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +require 'SharedConfigurations.php'; + +// Redis 2.0 features new commands that allow clients to subscribe for +// events published on certain channels (PUBSUB). + +// Create a client and disable r/w timeout on the socket +$client = new Predis\Client($single_server + array('read_write_timeout' => 0)); + +// Initialize a new pubsub context +$pubsub = $client->pubSubLoop(); + +// Subscribe to your channels +$pubsub->subscribe('control_channel', 'notifications'); + +// Start processing the pubsup messages. Open a terminal and use redis-cli +// to push messages to the channels. Examples: +// ./redis-cli PUBLISH notifications "this is a test" +// ./redis-cli PUBLISH control_channel quit_loop +foreach ($pubsub as $message) { + switch ($message->kind) { + case 'subscribe': + echo "Subscribed to {$message->channel}\n"; + break; + + case 'message': + if ($message->channel == 'control_channel') { + if ($message->payload == 'quit_loop') { + echo "Aborting pubsub loop...\n"; + $pubsub->unsubscribe(); + } else { + echo "Received an unrecognized command: {$message->payload}.\n"; + } + } else { + echo "Received the following message from {$message->channel}:\n", + " {$message->payload}\n\n"; + } + break; + } +} + +// Always unset the pubsub context instance when you are done! The +// class destructor will take care of cleanups and prevent protocol +// desynchronizations between the client and the server. +unset($pubsub); + +// Say goodbye :-) +$info = $client->info(); +print_r("Goodbye from Redis v{$info['redis_version']}!\n"); diff --git a/vendor/predis/predis/examples/RedisCollectionsIterators.php b/vendor/predis/predis/examples/RedisCollectionsIterators.php new file mode 100755 index 0000000..c3278c2 --- /dev/null +++ b/vendor/predis/predis/examples/RedisCollectionsIterators.php @@ -0,0 +1,96 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +require 'SharedConfigurations.php'; + +use Predis\Collection\Iterator; + +// Redis 2.8 features new commands allowing clients to incrementally +// iterate over collections without blocking the server like it happens +// when a command such as KEYS is executed on a Redis instance storing +// millions of keys. These commands are SCAN (iterates over the keyspace), +// SSCAN (iterates over members of a set), ZSCAN (iterates over members +// and ranks of a sorted set) and HSCAN (iterates over fields and values +// of an hash). Predis provides a specialized abstraction for each command +// based on SPL iterators making it possible to easily consume SCAN-based +// iterations in your PHP code. +// +// See http://redis.io/commands/scan for more details. +// + +// Create a client using `2.8` as a server profile (needs Redis 2.8!) +$client = new Predis\Client($single_server, array('profile' => '2.8')); + +// Prepare some keys for our example +$client->del('predis:set', 'predis:zset', 'predis:hash'); +for ($i = 0; $i < 5; $i++) { + $client->sadd('predis:set', "member:$i"); + $client->zadd('predis:zset', -$i, "member:$i"); + $client->hset('predis:hash', "field:$i", "value:$i"); +} + +// === Keyspace iterator based on SCAN === +echo 'Scan the keyspace matching only our prefixed keys:', PHP_EOL; +foreach (new Iterator\Keyspace($client, 'predis:*') as $key) { + echo " - $key", PHP_EOL; +} + +/* OUTPUT +Scan the keyspace matching only our prefixed keys: + - predis:zset + - predis:set + - predis:hash +*/ + +// === Set iterator based on SSCAN === +echo 'Scan members of `predis:set`:', PHP_EOL; +foreach (new Iterator\SetKey($client, 'predis:set') as $member) { + echo " - $member", PHP_EOL; +} + +/* OUTPUT +Scan members of `predis:set`: + - member:1 + - member:4 + - member:0 + - member:3 + - member:2 +*/ + +// === Sorted set iterator based on ZSCAN === +echo 'Scan members and ranks of `predis:zset`:', PHP_EOL; +foreach (new Iterator\SortedSetKey($client, 'predis:zset') as $member => $rank) { + echo " - $member [rank: $rank]", PHP_EOL; +} + +/* OUTPUT +Scan members and ranks of `predis:zset`: + - member:4 [rank: -4] + - member:3 [rank: -3] + - member:2 [rank: -2] + - member:1 [rank: -1] + - member:0 [rank: 0] +*/ + +// === Hash iterator based on HSCAN === +echo 'Scan fields and values of `predis:hash`:', PHP_EOL; +foreach (new Iterator\HashKey($client, 'predis:hash') as $field => $value) { + echo " - $field => $value", PHP_EOL; +} + +/* OUTPUT +Scan fields and values of `predis:hash`: + - field:0 => value:0 + - field:1 => value:1 + - field:2 => value:2 + - field:3 => value:3 + - field:4 => value:4 +*/ diff --git a/vendor/predis/predis/examples/ServerSideScripting.php b/vendor/predis/predis/examples/ServerSideScripting.php new file mode 100755 index 0000000..ac236e6 --- /dev/null +++ b/vendor/predis/predis/examples/ServerSideScripting.php @@ -0,0 +1,66 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +require 'SharedConfigurations.php'; + +// This example will not work with versions of Redis < 2.6. +// +// Additionally to the EVAL command defined in the current development profile, the new +// Predis\Command\ScriptedCommand base class can be used to build an higher abstraction +// for our "scripted" commands so that they will appear just like any other command on +// the client-side. This is a quick example used to implement INCREX. + +use Predis\Command\ScriptedCommand; + +class IncrementExistingKeysBy extends ScriptedCommand +{ + public function getKeysCount() + { + // Tell Predis to use all the arguments but the last one as arguments + // for KEYS. The last one will be used to populate ARGV. + return -1; + } + + public function getScript() + { + return +<<getProfile()->defineCommand('increxby', 'IncrementExistingKeysBy'); + +$client->mset('foo', 10, 'foobar', 100); + +var_export($client->increxby('foo', 'foofoo', 'foobar', 50)); + +/* +array ( + 0 => 60, + 1 => NULL, + 2 => 150, +) +*/ diff --git a/vendor/predis/predis/examples/SessionHandler.php b/vendor/predis/predis/examples/SessionHandler.php new file mode 100755 index 0000000..0ff6c95 --- /dev/null +++ b/vendor/predis/predis/examples/SessionHandler.php @@ -0,0 +1,39 @@ += 5.4 but can be used on PHP 5.3 if a polyfill for +// SessionHandlerInterface (see http://www.php.net/class.sessionhandlerinterface.php) +// is provided either by you or an external package like `symfony/http-foundation`. + +if (!interface_exists('SessionHandlerInterface')) { + die("ATTENTION: the session handler implemented by Predis needs PHP >= 5.4.0 or a polyfill ". + "for \SessionHandlerInterface either provided by you or an external package.\n"); +} + +// Instantiate a new client just like you would normally do. We'll prefix our session keys here. +$client = new Predis\Client($single_server, array('prefix' => 'sessions:')); + +// Set `gc_maxlifetime` so that a session will be expired after 5 seconds since last access. +$handler = new Predis\Session\SessionHandler($client, array('gc_maxlifetime' => 5)); + +// Register our session handler (it uses `session_set_save_handler()` internally). +$handler->register(); + +// Set a fixed session ID just for the sake of our example. +session_id('example_session_id'); + +session_start(); + +if (isset($_SESSION['foo'])) { + echo "Session has `foo` set to {$_SESSION['foo']}\n"; +} else { + $_SESSION['foo'] = $value = mt_rand(); + echo "Empty session, `foo` has been set with $value\n"; +} diff --git a/vendor/predis/predis/examples/SharedConfigurations.php b/vendor/predis/predis/examples/SharedConfigurations.php new file mode 100755 index 0000000..20ca6b5 --- /dev/null +++ b/vendor/predis/predis/examples/SharedConfigurations.php @@ -0,0 +1,33 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +require __DIR__.'/../autoload.php'; + +$single_server = array( + 'host' => '127.0.0.1', + 'port' => 6379, + 'database' => 15 +); + +$multiple_servers = array( + array( + 'host' => '127.0.0.1', + 'port' => 6379, + 'database' => 15, + 'alias' => 'first', + ), + array( + 'host' => '127.0.0.1', + 'port' => 6380, + 'database' => 15, + 'alias' => 'second', + ), +); diff --git a/vendor/predis/predis/examples/SimpleDebuggableConnection.php b/vendor/predis/predis/examples/SimpleDebuggableConnection.php new file mode 100755 index 0000000..0d9e4b5 --- /dev/null +++ b/vendor/predis/predis/examples/SimpleDebuggableConnection.php @@ -0,0 +1,88 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +require 'SharedConfigurations.php'; + +use Predis\Command\CommandInterface; +use Predis\Connection\StreamConnection; + +class SimpleDebuggableConnection extends StreamConnection +{ + private $tstart = 0; + private $debugBuffer = array(); + + public function connect() + { + $this->tstart = microtime(true); + + parent::connect(); + } + + private function storeDebug(CommandInterface $command, $direction) + { + $firtsArg = $command->getArgument(0); + $timestamp = round(microtime(true) - $this->tstart, 4); + + $debug = $command->getId(); + $debug .= isset($firtsArg) ? " $firtsArg " : ' '; + $debug .= "$direction $this"; + $debug .= " [{$timestamp}s]"; + + $this->debugBuffer[] = $debug; + } + + public function writeCommand(CommandInterface $command) + { + parent::writeCommand($command); + + $this->storeDebug($command, '->'); + } + + public function readResponse(CommandInterface $command) + { + $reply = parent::readResponse($command); + $this->storeDebug($command, '<-'); + + return $reply; + } + + public function getDebugBuffer() + { + return $this->debugBuffer; + } +} + +$options = array( + 'connections' => array( + 'tcp' => 'SimpleDebuggableConnection', + ), +); + +$client = new Predis\Client($single_server, $options); +$client->set('foo', 'bar'); +$client->get('foo'); +$client->info(); + +print_r($client->getConnection()->getDebugBuffer()); + +/* OUTPUT: +Array +( + [0] => SELECT 15 -> 127.0.0.1:6379 [0.0008s] + [1] => SELECT 15 <- 127.0.0.1:6379 [0.0012s] + [2] => SET foo -> 127.0.0.1:6379 [0.0014s] + [3] => SET foo <- 127.0.0.1:6379 [0.0014s] + [4] => GET foo -> 127.0.0.1:6379 [0.0016s] + [5] => GET foo <- 127.0.0.1:6379 [0.0018s] + [6] => INFO -> 127.0.0.1:6379 [0.002s] + [7] => INFO <- 127.0.0.1:6379 [0.0025s] +) +*/ diff --git a/vendor/predis/predis/examples/SimpleSetAndGet.php b/vendor/predis/predis/examples/SimpleSetAndGet.php new file mode 100755 index 0000000..3082053 --- /dev/null +++ b/vendor/predis/predis/examples/SimpleSetAndGet.php @@ -0,0 +1,25 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +require 'SharedConfigurations.php'; + +// simple set and get scenario + +$client = new Predis\Client($single_server); + +$client->set('library', 'predis'); +$retval = $client->get('library'); + +var_dump($retval); + +/* OUTPUT +string(6) "predis" +*/ diff --git a/vendor/predis/predis/examples/TransactionWithCAS.php b/vendor/predis/predis/examples/TransactionWithCAS.php new file mode 100755 index 0000000..785a9db --- /dev/null +++ b/vendor/predis/predis/examples/TransactionWithCAS.php @@ -0,0 +1,51 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +require 'SharedConfigurations.php'; + +// This is an implementation of an atomic client-side ZPOP using the support for +// check-and-set (CAS) operations with MULTI/EXEC transactions, as described in +// "WATCH explained" from http://redis.io/topics/transactions +// +// First, populate your database with a tiny sample data set: +// +// ./redis-cli +// SELECT 15 +// ZADD zset 1 a +// ZADD zset 2 b +// ZADD zset 3 c + +function zpop($client, $key) +{ + $element = null; + $options = array( + 'cas' => true, // Initialize with support for CAS operations + 'watch' => $key, // Key that needs to be WATCHed to detect changes + 'retry' => 3, // Number of retries on aborted transactions, after + // which the client bails out with an exception. + ); + + $client->transaction($options, function ($tx) use ($key, &$element) { + @list($element) = $tx->zrange($key, 0, 0); + + if (isset($element)) { + $tx->multi(); // With CAS, MULTI *must* be explicitly invoked. + $tx->zrem($key, $element); + } + }); + + return $element; +} + +$client = new Predis\Client($single_server); +$zpopped = zpop($client, 'zset'); + +echo isset($zpopped) ? "ZPOPed $zpopped" : "Nothing to ZPOP!", "\n"; diff --git a/vendor/predis/predis/lib/Predis/Autoloader.php b/vendor/predis/predis/lib/Predis/Autoloader.php new file mode 100755 index 0000000..ff5c1ef --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Autoloader.php @@ -0,0 +1,62 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis; + +/** + * Implements a lightweight PSR-0 compliant autoloader. + * + * @author Eric Naeseth + * @author Daniele Alessandri + */ +class Autoloader +{ + private $directory; + private $prefix; + private $prefixLength; + + /** + * @param string $baseDirectory Base directory where the source files are located. + */ + public function __construct($baseDirectory = __DIR__) + { + $this->directory = $baseDirectory; + $this->prefix = __NAMESPACE__ . '\\'; + $this->prefixLength = strlen($this->prefix); + } + + /** + * Registers the autoloader class with the PHP SPL autoloader. + * + * @param bool $prepend Prepend the autoloader on the stack instead of appending it. + */ + public static function register($prepend = false) + { + spl_autoload_register(array(new self, 'autoload'), true, $prepend); + } + + /** + * Loads a class from a file using its fully qualified name. + * + * @param string $className Fully qualified name of a class. + */ + public function autoload($className) + { + if (0 === strpos($className, $this->prefix)) { + $parts = explode('\\', substr($className, $this->prefixLength)); + $filepath = $this->directory.DIRECTORY_SEPARATOR.implode(DIRECTORY_SEPARATOR, $parts).'.php'; + + if (is_file($filepath)) { + require($filepath); + } + } + } +} diff --git a/vendor/predis/predis/lib/Predis/BasicClientInterface.php b/vendor/predis/predis/lib/Predis/BasicClientInterface.php new file mode 100755 index 0000000..625f5dc --- /dev/null +++ b/vendor/predis/predis/lib/Predis/BasicClientInterface.php @@ -0,0 +1,31 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis; + +use Predis\Command\CommandInterface; + +/** + * Defines the interface of a basic client object or abstraction that + * can send commands to Redis. + * + * @author Daniele Alessandri + */ +interface BasicClientInterface +{ + /** + * Executes the specified Redis command. + * + * @param CommandInterface $command A Redis command. + * @return mixed + */ + public function executeCommand(CommandInterface $command); +} diff --git a/vendor/predis/predis/lib/Predis/Client.php b/vendor/predis/predis/lib/Predis/Client.php new file mode 100755 index 0000000..d501df9 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Client.php @@ -0,0 +1,465 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis; + +use Predis\Command\CommandInterface; +use Predis\Command\ScriptedCommand; +use Predis\Connection\AggregatedConnectionInterface; +use Predis\Connection\ConnectionInterface; +use Predis\Connection\ConnectionFactoryInterface; +use Predis\Monitor\MonitorContext; +use Predis\Option\ClientOptions; +use Predis\Option\ClientOptionsInterface; +use Predis\Pipeline\PipelineContext; +use Predis\PubSub\PubSubContext; +use Predis\Transaction\MultiExecContext; + +/** + * Main class that exposes the most high-level interface to interact with Redis. + * + * @author Daniele Alessandri + */ +class Client implements ClientInterface +{ + const VERSION = '0.8.5'; + + private $options; + private $profile; + private $connection; + + /** + * Initializes a new client with optional connection parameters and client options. + * + * @param mixed $parameters Connection parameters for one or multiple servers. + * @param mixed $options Options that specify certain behaviours for the client. + */ + public function __construct($parameters = null, $options = null) + { + $this->options = $this->filterOptions($options); + $this->profile = $this->options->profile; + $this->connection = $this->initializeConnection($parameters); + } + + /** + * Creates an instance of Predis\Option\ClientOptions from various types of + * arguments (string, array, Predis\Profile\ServerProfile) or returns the + * passed object if it is an instance of Predis\Option\ClientOptions. + * + * @param mixed $options Client options. + * @return ClientOptions + */ + protected function filterOptions($options) + { + if (!isset($options)) { + return new ClientOptions(); + } + + if (is_array($options)) { + return new ClientOptions($options); + } + + if ($options instanceof ClientOptionsInterface) { + return $options; + } + + throw new \InvalidArgumentException("Invalid type for client options"); + } + + /** + * Initializes one or multiple connection (cluster) objects from various + * types of arguments (string, array) or returns the passed object if it + * implements Predis\Connection\ConnectionInterface. + * + * @param mixed $parameters Connection parameters or instance. + * @return ConnectionInterface + */ + protected function initializeConnection($parameters) + { + if ($parameters instanceof ConnectionInterface) { + return $parameters; + } + + if (is_array($parameters) && isset($parameters[0])) { + $options = $this->options; + $replication = isset($options->replication) && $options->replication; + $connection = $options->{$replication ? 'replication' : 'cluster'}; + + return $options->connections->createAggregated($connection, $parameters); + } + + if (is_callable($parameters)) { + $connection = call_user_func($parameters, $this->options); + + if (!$connection instanceof ConnectionInterface) { + throw new \InvalidArgumentException( + 'Callable parameters must return instances of Predis\Connection\ConnectionInterface' + ); + } + + return $connection; + } + + return $this->options->connections->create($parameters); + } + + /** + * {@inheritdoc} + */ + public function getProfile() + { + return $this->profile; + } + + /** + * {@inheritdoc} + */ + public function getOptions() + { + return $this->options; + } + + /** + * Returns the connection factory object used by the client. + * + * @return ConnectionFactoryInterface + */ + public function getConnectionFactory() + { + return $this->options->connections; + } + + /** + * Returns a new instance of a client for the specified connection when the + * client is connected to a cluster. The new instance will use the same + * options of the original client. + * + * @param string $connectionID Identifier for the connection. + * @return Client + */ + public function getClientFor($connectionID) + { + if (!$connection = $this->getConnectionById($connectionID)) { + throw new \InvalidArgumentException("Invalid connection ID: '$connectionID'"); + } + + return new static($connection, $this->options); + } + + /** + * Opens the connection to the server. + */ + public function connect() + { + $this->connection->connect(); + } + + /** + * Disconnects from the server. + */ + public function disconnect() + { + $this->connection->disconnect(); + } + + /** + * Disconnects from the server. + * + * This method is an alias of disconnect(). + */ + public function quit() + { + $this->disconnect(); + } + + /** + * Checks if the underlying connection is connected to Redis. + * + * @return bool True means that the connection is open. + * False means that the connection is closed. + */ + public function isConnected() + { + return $this->connection->isConnected(); + } + + /** + * {@inheritdoc} + */ + public function getConnection() + { + return $this->connection; + } + + /** + * Retrieves a single connection out of an aggregated connections instance. + * + * @param string $connectionId Index or alias of the single connection. + * @return Connection\SingleConnectionInterface + */ + public function getConnectionById($connectionId) + { + if (!$this->connection instanceof AggregatedConnectionInterface) { + throw new NotSupportedException('Retrieving connections by ID is supported only when using aggregated connections'); + } + + return $this->connection->getConnectionById($connectionId); + } + + /** + * Creates a Redis command with the specified arguments and sends a request + * to the server. + * + * @param string $commandID Command ID. + * @param array $arguments Arguments for the command. + * @return mixed + */ + public function __call($commandID, $arguments) + { + $command = $this->createCommand($commandID, $arguments); + $response = $this->executeCommand($command); + + return $response; + } + + /** + * {@inheritdoc} + */ + public function createCommand($commandID, $arguments = array()) + { + return $this->profile->createCommand($commandID, $arguments); + } + + /** + * {@inheritdoc} + */ + public function executeCommand(CommandInterface $command) + { + $response = $this->connection->executeCommand($command); + + if ($response instanceof ResponseObjectInterface) { + if ($response instanceof ResponseErrorInterface) { + $response = $this->onResponseError($command, $response); + } + + return $response; + } + + return $command->parseResponse($response); + } + + /** + * Handles -ERR responses returned by Redis. + * + * @param CommandInterface $command The command that generated the error. + * @param ResponseErrorInterface $response The error response instance. + * @return mixed + */ + protected function onResponseError(CommandInterface $command, ResponseErrorInterface $response) + { + if ($command instanceof ScriptedCommand && $response->getErrorType() === 'NOSCRIPT') { + $eval = $this->createCommand('eval'); + $eval->setRawArguments($command->getEvalArguments()); + + $response = $this->executeCommand($eval); + + if (!$response instanceof ResponseObjectInterface) { + $response = $command->parseResponse($response); + } + + return $response; + } + + if ($this->options->exceptions) { + throw new ServerException($response->getMessage()); + } + + return $response; + } + + /** + * Calls the specified initializer method on $this with 0, 1 or 2 arguments. + * + * TODO: Invert $argv and $initializer. + * + * @param array $argv Arguments for the initializer. + * @param string $initializer The initializer method. + * @return mixed + */ + private function sharedInitializer($argv, $initializer) + { + switch (count($argv)) { + case 0: + return $this->$initializer(); + + case 1: + list($arg0) = $argv; + + return is_array($arg0) ? $this->$initializer($arg0) : $this->$initializer(null, $arg0); + + case 2: + list($arg0, $arg1) = $argv; + + return $this->$initializer($arg0, $arg1); + + default: + return $this->$initializer($this, $argv); + } + } + + /** + * Creates a new pipeline context and returns it, or returns the results of + * a pipeline executed inside the optionally provided callable object. + * + * @param mixed ... Options for the context, a callable object, or both. + * @return PipelineContext|array + */ + public function pipeline(/* arguments */) + { + return $this->sharedInitializer(func_get_args(), 'initPipeline'); + } + + /** + * Pipeline context initializer. + * + * @param array $options Options for the context. + * @param mixed $callable Optional callable object used to execute the context. + * @return PipelineContext|array + */ + protected function initPipeline(Array $options = null, $callable = null) + { + $executor = isset($options['executor']) ? $options['executor'] : null; + + if (is_callable($executor)) { + $executor = call_user_func($executor, $this, $options); + } + + $pipeline = new PipelineContext($this, $executor); + $replies = $this->pipelineExecute($pipeline, $callable); + + return $replies; + } + + /** + * Executes a pipeline context when a callable object is passed. + * + * @param PipelineContext $pipeline Pipeline context instance. + * @param mixed $callable Optional callable object used to execute the context. + * @return PipelineContext|array + */ + private function pipelineExecute(PipelineContext $pipeline, $callable) + { + return isset($callable) ? $pipeline->execute($callable) : $pipeline; + } + + /** + * Creates a new transaction context and returns it, or returns the results of + * a transaction executed inside the optionally provided callable object. + * + * @deprecated You should start using the new Client::transaction() method + * as it will replace Client::multiExec() in the next major + * version of the library. + * + * @param mixed ... Options for the context, a callable object, or both. + * @return MultiExecContext|array + */ + public function multiExec(/* arguments */) + { + return $this->sharedInitializer(func_get_args(), 'initMultiExec'); + } + + /** + * Creates a new transaction context and returns it, or returns the results of + * a transaction executed inside the optionally provided callable object. + * + * @param mixed ... Options for the context, a callable object, or both. + * @return MultiExecContext|array + */ + public function transaction(/* arguments */) + { + return $this->sharedInitializer(func_get_args(), 'initMultiExec'); + } + + /** + * Transaction context initializer. + * + * @param array $options Options for the context. + * @param mixed $callable Optional callable object used to execute the context. + * @return MultiExecContext|array + */ + protected function initMultiExec(Array $options = null, $callable = null) + { + $transaction = new MultiExecContext($this, $options ?: array()); + + return isset($callable) ? $transaction->execute($callable) : $transaction; + } + + /** + * Creates a new Publish / Subscribe context and returns it, or executes it + * inside the optionally provided callable object. + * + * @deprecated This method will change in the next major release to support + * the new PUBSUB command introduced in Redis 2.8. Please use + * Client::pubSubLoop() to create Predis\PubSub\PubSubContext + * instances from now on. + * + * @param mixed ... Options for the context, a callable object, or both. + * @return PubSubContext|array + */ + public function pubSub(/* arguments */) + { + return call_user_func_array(array($this, 'pubSubLoop'), func_get_args()); + } + + /** + * Creates a new Publish / Subscribe context and returns it, or executes it + * inside the optionally provided callable object. + * + * @param mixed ... Options for the context, a callable object, or both. + * @return PubSubContext|array + */ + public function pubSubLoop(/* arguments */) + { + return $this->sharedInitializer(func_get_args(), 'initPubSub'); + } + + /** + * Publish / Subscribe context initializer. + * + * @param array $options Options for the context. + * @param mixed $callable Optional callable object used to execute the context. + * @return PubSubContext + */ + protected function initPubSub(Array $options = null, $callable = null) + { + $pubsub = new PubSubContext($this, $options); + + if (!isset($callable)) { + return $pubsub; + } + + foreach ($pubsub as $message) { + if (call_user_func($callable, $pubsub, $message) === false) { + $pubsub->closeContext(); + } + } + } + + /** + * Returns a new monitor context. + * + * @return MonitorContext + */ + public function monitor() + { + return new MonitorContext($this); + } +} diff --git a/vendor/predis/predis/lib/Predis/ClientException.php b/vendor/predis/predis/lib/Predis/ClientException.php new file mode 100755 index 0000000..6c07aaf --- /dev/null +++ b/vendor/predis/predis/lib/Predis/ClientException.php @@ -0,0 +1,21 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis; + +/** + * Exception class that identifies client-side errors. + * + * @author Daniele Alessandri + */ +class ClientException extends PredisException +{ +} diff --git a/vendor/predis/predis/lib/Predis/ClientInterface.php b/vendor/predis/predis/lib/Predis/ClientInterface.php new file mode 100755 index 0000000..b4b3d47 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/ClientInterface.php @@ -0,0 +1,66 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis; + +use Predis\Connection\ConnectionInterface; +use Predis\Option\ClientOptionsInterface; +use Predis\Profile\ServerProfileInterface; + +/** + * Interface defining the most important parts needed to create an + * high-level Redis client object that can interact with other + * building blocks of Predis. + * + * @author Daniele Alessandri + */ +interface ClientInterface extends BasicClientInterface +{ + /** + * Returns the server profile used by the client. + * + * @return ServerProfileInterface + */ + public function getProfile(); + + /** + * Returns the client options specified upon initialization. + * + * @return ClientOptionsInterface + */ + public function getOptions(); + + /** + * Opens the connection to the server. + */ + public function connect(); + + /** + * Disconnects from the server. + */ + public function disconnect(); + + /** + * Returns the underlying connection instance. + * + * @return ConnectionInterface + */ + public function getConnection(); + + /** + * Creates a new instance of the specified Redis command. + * + * @param string $method The name of a Redis command. + * @param array $arguments The arguments for the command. + * @return Command\CommandInterface + */ + public function createCommand($method, $arguments = array()); +} diff --git a/vendor/predis/predis/lib/Predis/Cluster/CommandHashStrategyInterface.php b/vendor/predis/predis/lib/Predis/Cluster/CommandHashStrategyInterface.php new file mode 100755 index 0000000..810700b --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Cluster/CommandHashStrategyInterface.php @@ -0,0 +1,42 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Cluster; + +use Predis\Command\CommandInterface; + +/** + * Interface for classes defining the strategy used to calculate an hash + * out of keys extracted from supported commands. + * + * This is mostly useful to support clustering via client-side sharding. + * + * @author Daniele Alessandri + */ +interface CommandHashStrategyInterface +{ + /** + * Returns the hash for the given command using the specified algorithm, or null + * if the command cannot be hashed. + * + * @param CommandInterface $command Command to be hashed. + * @return int + */ + public function getHash(CommandInterface $command); + + /** + * Returns the hash for the given key using the specified algorithm. + * + * @param string $key Key to be hashed. + * @return string + */ + public function getKeyHash($key); +} diff --git a/vendor/predis/predis/lib/Predis/Cluster/Distribution/DistributionStrategyInterface.php b/vendor/predis/predis/lib/Predis/Cluster/Distribution/DistributionStrategyInterface.php new file mode 100755 index 0000000..6395412 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Cluster/Distribution/DistributionStrategyInterface.php @@ -0,0 +1,53 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Cluster\Distribution; + +use Predis\Cluster\Hash\HashGeneratorInterface; + +/** + * A distributor implements the logic to automatically distribute + * keys among several nodes for client-side sharding. + * + * @author Daniele Alessandri + */ +interface DistributionStrategyInterface +{ + /** + * Adds a node to the distributor with an optional weight. + * + * @param mixed $node Node object. + * @param int $weight Weight for the node. + */ + public function add($node, $weight = null); + + /** + * Removes a node from the distributor. + * + * @param mixed $node Node object. + */ + public function remove($node); + + /** + * Gets a node from the distributor using the computed hash of a key. + * + * @param mixed $key + * @return mixed + */ + public function get($key); + + /** + * Returns the underlying hash generator instance. + * + * @return HashGeneratorInterface + */ + public function getHashGenerator(); +} diff --git a/vendor/predis/predis/lib/Predis/Cluster/Distribution/EmptyRingException.php b/vendor/predis/predis/lib/Predis/Cluster/Distribution/EmptyRingException.php new file mode 100755 index 0000000..ed08ca3 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Cluster/Distribution/EmptyRingException.php @@ -0,0 +1,21 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Cluster\Distribution; + +/** + * Exception class that identifies empty rings. + * + * @author Daniele Alessandri + */ +class EmptyRingException extends \Exception +{ +} diff --git a/vendor/predis/predis/lib/Predis/Cluster/Distribution/HashRing.php b/vendor/predis/predis/lib/Predis/Cluster/Distribution/HashRing.php new file mode 100755 index 0000000..b8dd12a --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Cluster/Distribution/HashRing.php @@ -0,0 +1,246 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Cluster\Distribution; + +use Predis\Cluster\Hash\HashGeneratorInterface; + +/** + * This class implements an hashring-based distributor that uses the same + * algorithm of memcache to distribute keys in a cluster using client-side + * sharding. + * + * @author Daniele Alessandri + * @author Lorenzo Castelli + */ +class HashRing implements DistributionStrategyInterface, HashGeneratorInterface +{ + const DEFAULT_REPLICAS = 128; + const DEFAULT_WEIGHT = 100; + + private $ring; + private $ringKeys; + private $ringKeysCount; + private $replicas; + private $nodeHashCallback; + private $nodes = array(); + + /** + * @param int $replicas Number of replicas in the ring. + * @param mixed $nodeHashCallback Callback returning the string used to calculate the hash of a node. + */ + public function __construct($replicas = self::DEFAULT_REPLICAS, $nodeHashCallback = null) + { + $this->replicas = $replicas; + $this->nodeHashCallback = $nodeHashCallback; + } + + /** + * Adds a node to the ring with an optional weight. + * + * @param mixed $node Node object. + * @param int $weight Weight for the node. + */ + public function add($node, $weight = null) + { + // In case of collisions in the hashes of the nodes, the node added + // last wins, thus the order in which nodes are added is significant. + $this->nodes[] = array('object' => $node, 'weight' => (int) $weight ?: $this::DEFAULT_WEIGHT); + $this->reset(); + } + + /** + * {@inheritdoc} + */ + public function remove($node) + { + // A node is removed by resetting the ring so that it's recreated from + // scratch, in order to reassign possible hashes with collisions to the + // right node according to the order in which they were added in the + // first place. + for ($i = 0; $i < count($this->nodes); ++$i) { + if ($this->nodes[$i]['object'] === $node) { + array_splice($this->nodes, $i, 1); + $this->reset(); + break; + } + } + } + + /** + * Resets the distributor. + */ + private function reset() + { + unset( + $this->ring, + $this->ringKeys, + $this->ringKeysCount + ); + } + + /** + * Returns the initialization status of the distributor. + * + * @return bool + */ + private function isInitialized() + { + return isset($this->ringKeys); + } + + /** + * Calculates the total weight of all the nodes in the distributor. + * + * @return int + */ + private function computeTotalWeight() + { + $totalWeight = 0; + + foreach ($this->nodes as $node) { + $totalWeight += $node['weight']; + } + + return $totalWeight; + } + + /** + * Initializes the distributor. + */ + private function initialize() + { + if ($this->isInitialized()) { + return; + } + + if (!$this->nodes) { + throw new EmptyRingException('Cannot initialize empty hashring'); + } + + $this->ring = array(); + $totalWeight = $this->computeTotalWeight(); + $nodesCount = count($this->nodes); + + foreach ($this->nodes as $node) { + $weightRatio = $node['weight'] / $totalWeight; + $this->addNodeToRing($this->ring, $node, $nodesCount, $this->replicas, $weightRatio); + } + + ksort($this->ring, SORT_NUMERIC); + $this->ringKeys = array_keys($this->ring); + $this->ringKeysCount = count($this->ringKeys); + } + + /** + * Implements the logic needed to add a node to the hashring. + * + * @param array $ring Source hashring. + * @param mixed $node Node object to be added. + * @param int $totalNodes Total number of nodes. + * @param int $replicas Number of replicas in the ring. + * @param float $weightRatio Weight ratio for the node. + */ + protected function addNodeToRing(&$ring, $node, $totalNodes, $replicas, $weightRatio) + { + $nodeObject = $node['object']; + $nodeHash = $this->getNodeHash($nodeObject); + $replicas = (int) round($weightRatio * $totalNodes * $replicas); + + for ($i = 0; $i < $replicas; $i++) { + $key = crc32("$nodeHash:$i"); + $ring[$key] = $nodeObject; + } + } + + /** + * {@inheritdoc} + */ + protected function getNodeHash($nodeObject) + { + if ($this->nodeHashCallback === null) { + return (string) $nodeObject; + } + + return call_user_func($this->nodeHashCallback, $nodeObject); + } + + /** + * Calculates the hash for the specified value. + * + * @param string $value Input value. + * @return int + */ + public function hash($value) + { + return crc32($value); + } + + /** + * {@inheritdoc} + */ + public function get($key) + { + return $this->ring[$this->getNodeKey($key)]; + } + + /** + * Calculates the corrisponding key of a node distributed in the hashring. + * + * @param int $key Computed hash of a key. + * @return int + */ + private function getNodeKey($key) + { + $this->initialize(); + $ringKeys = $this->ringKeys; + $upper = $this->ringKeysCount - 1; + $lower = 0; + + while ($lower <= $upper) { + $index = ($lower + $upper) >> 1; + $item = $ringKeys[$index]; + + if ($item > $key) { + $upper = $index - 1; + } elseif ($item < $key) { + $lower = $index + 1; + } else { + return $item; + } + } + + return $ringKeys[$this->wrapAroundStrategy($upper, $lower, $this->ringKeysCount)]; + } + + /** + * Implements a strategy to deal with wrap-around errors during binary searches. + * + * @param int $upper + * @param int $lower + * @param int $ringKeysCount + * @return int + */ + protected function wrapAroundStrategy($upper, $lower, $ringKeysCount) + { + // Binary search for the last item in ringkeys with a value less or + // equal to the key. If no such item exists, return the last item. + return $upper >= 0 ? $upper : $ringKeysCount - 1; + } + + /** + * {@inheritdoc} + */ + public function getHashGenerator() + { + return $this; + } +} diff --git a/vendor/predis/predis/lib/Predis/Cluster/Distribution/KetamaPureRing.php b/vendor/predis/predis/lib/Predis/Cluster/Distribution/KetamaPureRing.php new file mode 100755 index 0000000..9edbe4d --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Cluster/Distribution/KetamaPureRing.php @@ -0,0 +1,71 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Cluster\Distribution; + +/** + * This class implements an hashring-based distributor that uses the same + * algorithm of libketama to distribute keys in a cluster using client-side + * sharding. + * + * @author Daniele Alessandri + * @author Lorenzo Castelli + */ +class KetamaPureRing extends HashRing +{ + const DEFAULT_REPLICAS = 160; + + /** + * @param mixed $nodeHashCallback Callback returning the string used to calculate the hash of a node. + */ + public function __construct($nodeHashCallback = null) + { + parent::__construct($this::DEFAULT_REPLICAS, $nodeHashCallback); + } + + /** + * {@inheritdoc} + */ + protected function addNodeToRing(&$ring, $node, $totalNodes, $replicas, $weightRatio) + { + $nodeObject = $node['object']; + $nodeHash = $this->getNodeHash($nodeObject); + $replicas = (int) floor($weightRatio * $totalNodes * ($replicas / 4)); + + for ($i = 0; $i < $replicas; $i++) { + $unpackedDigest = unpack('V4', md5("$nodeHash-$i", true)); + + foreach ($unpackedDigest as $key) { + $ring[$key] = $nodeObject; + } + } + } + + /** + * {@inheritdoc} + */ + public function hash($value) + { + $hash = unpack('V', md5($value, true)); + + return $hash[1]; + } + + /** + * {@inheritdoc} + */ + protected function wrapAroundStrategy($upper, $lower, $ringKeysCount) + { + // Binary search for the first item in _ringkeys with a value greater + // or equal to the key. If no such item exists, return the first item. + return $lower < $ringKeysCount ? $lower : 0; + } +} diff --git a/vendor/predis/predis/lib/Predis/Cluster/Hash/CRC16HashGenerator.php b/vendor/predis/predis/lib/Predis/Cluster/Hash/CRC16HashGenerator.php new file mode 100755 index 0000000..f4c17f2 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Cluster/Hash/CRC16HashGenerator.php @@ -0,0 +1,72 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Cluster\Hash; + +/** + * This class implements the CRC-CCITT-16 algorithm used by redis-cluster. + * + * @author Daniele Alessandri + */ +class CRC16HashGenerator implements HashGeneratorInterface +{ + private static $CCITT_16 = array( + 0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50A5, 0x60C6, 0x70E7, + 0x8108, 0x9129, 0xA14A, 0xB16B, 0xC18C, 0xD1AD, 0xE1CE, 0xF1EF, + 0x1231, 0x0210, 0x3273, 0x2252, 0x52B5, 0x4294, 0x72F7, 0x62D6, + 0x9339, 0x8318, 0xB37B, 0xA35A, 0xD3BD, 0xC39C, 0xF3FF, 0xE3DE, + 0x2462, 0x3443, 0x0420, 0x1401, 0x64E6, 0x74C7, 0x44A4, 0x5485, + 0xA56A, 0xB54B, 0x8528, 0x9509, 0xE5EE, 0xF5CF, 0xC5AC, 0xD58D, + 0x3653, 0x2672, 0x1611, 0x0630, 0x76D7, 0x66F6, 0x5695, 0x46B4, + 0xB75B, 0xA77A, 0x9719, 0x8738, 0xF7DF, 0xE7FE, 0xD79D, 0xC7BC, + 0x48C4, 0x58E5, 0x6886, 0x78A7, 0x0840, 0x1861, 0x2802, 0x3823, + 0xC9CC, 0xD9ED, 0xE98E, 0xF9AF, 0x8948, 0x9969, 0xA90A, 0xB92B, + 0x5AF5, 0x4AD4, 0x7AB7, 0x6A96, 0x1A71, 0x0A50, 0x3A33, 0x2A12, + 0xDBFD, 0xCBDC, 0xFBBF, 0xEB9E, 0x9B79, 0x8B58, 0xBB3B, 0xAB1A, + 0x6CA6, 0x7C87, 0x4CE4, 0x5CC5, 0x2C22, 0x3C03, 0x0C60, 0x1C41, + 0xEDAE, 0xFD8F, 0xCDEC, 0xDDCD, 0xAD2A, 0xBD0B, 0x8D68, 0x9D49, + 0x7E97, 0x6EB6, 0x5ED5, 0x4EF4, 0x3E13, 0x2E32, 0x1E51, 0x0E70, + 0xFF9F, 0xEFBE, 0xDFDD, 0xCFFC, 0xBF1B, 0xAF3A, 0x9F59, 0x8F78, + 0x9188, 0x81A9, 0xB1CA, 0xA1EB, 0xD10C, 0xC12D, 0xF14E, 0xE16F, + 0x1080, 0x00A1, 0x30C2, 0x20E3, 0x5004, 0x4025, 0x7046, 0x6067, + 0x83B9, 0x9398, 0xA3FB, 0xB3DA, 0xC33D, 0xD31C, 0xE37F, 0xF35E, + 0x02B1, 0x1290, 0x22F3, 0x32D2, 0x4235, 0x5214, 0x6277, 0x7256, + 0xB5EA, 0xA5CB, 0x95A8, 0x8589, 0xF56E, 0xE54F, 0xD52C, 0xC50D, + 0x34E2, 0x24C3, 0x14A0, 0x0481, 0x7466, 0x6447, 0x5424, 0x4405, + 0xA7DB, 0xB7FA, 0x8799, 0x97B8, 0xE75F, 0xF77E, 0xC71D, 0xD73C, + 0x26D3, 0x36F2, 0x0691, 0x16B0, 0x6657, 0x7676, 0x4615, 0x5634, + 0xD94C, 0xC96D, 0xF90E, 0xE92F, 0x99C8, 0x89E9, 0xB98A, 0xA9AB, + 0x5844, 0x4865, 0x7806, 0x6827, 0x18C0, 0x08E1, 0x3882, 0x28A3, + 0xCB7D, 0xDB5C, 0xEB3F, 0xFB1E, 0x8BF9, 0x9BD8, 0xABBB, 0xBB9A, + 0x4A75, 0x5A54, 0x6A37, 0x7A16, 0x0AF1, 0x1AD0, 0x2AB3, 0x3A92, + 0xFD2E, 0xED0F, 0xDD6C, 0xCD4D, 0xBDAA, 0xAD8B, 0x9DE8, 0x8DC9, + 0x7C26, 0x6C07, 0x5C64, 0x4C45, 0x3CA2, 0x2C83, 0x1CE0, 0x0CC1, + 0xEF1F, 0xFF3E, 0xCF5D, 0xDF7C, 0xAF9B, 0xBFBA, 0x8FD9, 0x9FF8, + 0x6E17, 0x7E36, 0x4E55, 0x5E74, 0x2E93, 0x3EB2, 0x0ED1, 0x1EF0, + ); + + /** + * {@inheritdoc} + */ + public function hash($value) + { + // CRC-CCITT-16 algorithm + $crc = 0; + $CCITT_16 = self::$CCITT_16; + $strlen = strlen($value); + + for ($i = 0; $i < $strlen; $i++) { + $crc = (($crc << 8) ^ $CCITT_16[($crc >> 8) ^ ord($value[$i])]) & 0xFFFF; + } + + return $crc; + } +} diff --git a/vendor/predis/predis/lib/Predis/Cluster/Hash/HashGeneratorInterface.php b/vendor/predis/predis/lib/Predis/Cluster/Hash/HashGeneratorInterface.php new file mode 100755 index 0000000..62e46cf --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Cluster/Hash/HashGeneratorInterface.php @@ -0,0 +1,29 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Cluster\Hash; + +/** + * A generator of node keys implements the logic used to calculate the hash of + * a key to distribute the respective operations among nodes. + * + * @author Daniele Alessandri + */ +interface HashGeneratorInterface +{ + /** + * Generates an hash that is used by the distributor algorithm + * + * @param string $value Value used to generate the hash. + * @return int + */ + public function hash($value); +} diff --git a/vendor/predis/predis/lib/Predis/Cluster/PredisClusterHashStrategy.php b/vendor/predis/predis/lib/Predis/Cluster/PredisClusterHashStrategy.php new file mode 100755 index 0000000..46d8f1a --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Cluster/PredisClusterHashStrategy.php @@ -0,0 +1,389 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Cluster; + +use Predis\Cluster\Hash\HashGeneratorInterface; +use Predis\Command\CommandInterface; +use Predis\Command\ScriptedCommand; + +/** + * Default class used by Predis for client-side sharding to calculate + * hashes out of keys of supported commands. + * + * @author Daniele Alessandri + */ +class PredisClusterHashStrategy implements CommandHashStrategyInterface +{ + private $commands; + private $hashGenerator; + + /** + * @param HashGeneratorInterface $hashGenerator Hash generator instance. + */ + public function __construct(HashGeneratorInterface $hashGenerator) + { + $this->commands = $this->getDefaultCommands(); + $this->hashGenerator = $hashGenerator; + } + + /** + * Returns the default map of supported commands with their handlers. + * + * @return array + */ + protected function getDefaultCommands() + { + $keyIsFirstArgument = array($this, 'getKeyFromFirstArgument'); + $keysAreAllArguments = array($this, 'getKeyFromAllArguments'); + + return array( + /* commands operating on the key space */ + 'EXISTS' => $keyIsFirstArgument, + 'DEL' => $keysAreAllArguments, + 'TYPE' => $keyIsFirstArgument, + 'EXPIRE' => $keyIsFirstArgument, + 'EXPIREAT' => $keyIsFirstArgument, + 'PERSIST' => $keyIsFirstArgument, + 'PEXPIRE' => $keyIsFirstArgument, + 'PEXPIREAT' => $keyIsFirstArgument, + 'TTL' => $keyIsFirstArgument, + 'PTTL' => $keyIsFirstArgument, + 'SORT' => $keyIsFirstArgument, // TODO + 'DUMP' => $keyIsFirstArgument, + 'RESTORE' => $keyIsFirstArgument, + + /* commands operating on string values */ + 'APPEND' => $keyIsFirstArgument, + 'DECR' => $keyIsFirstArgument, + 'DECRBY' => $keyIsFirstArgument, + 'GET' => $keyIsFirstArgument, + 'GETBIT' => $keyIsFirstArgument, + 'MGET' => $keysAreAllArguments, + 'SET' => $keyIsFirstArgument, + 'GETRANGE' => $keyIsFirstArgument, + 'GETSET' => $keyIsFirstArgument, + 'INCR' => $keyIsFirstArgument, + 'INCRBY' => $keyIsFirstArgument, + 'SETBIT' => $keyIsFirstArgument, + 'SETEX' => $keyIsFirstArgument, + 'MSET' => array($this, 'getKeyFromInterleavedArguments'), + 'MSETNX' => array($this, 'getKeyFromInterleavedArguments'), + 'SETNX' => $keyIsFirstArgument, + 'SETRANGE' => $keyIsFirstArgument, + 'STRLEN' => $keyIsFirstArgument, + 'SUBSTR' => $keyIsFirstArgument, + 'BITOP' => array($this, 'getKeyFromBitOp'), + 'BITCOUNT' => $keyIsFirstArgument, + + /* commands operating on lists */ + 'LINSERT' => $keyIsFirstArgument, + 'LINDEX' => $keyIsFirstArgument, + 'LLEN' => $keyIsFirstArgument, + 'LPOP' => $keyIsFirstArgument, + 'RPOP' => $keyIsFirstArgument, + 'RPOPLPUSH' => $keysAreAllArguments, + 'BLPOP' => array($this, 'getKeyFromBlockingListCommands'), + 'BRPOP' => array($this, 'getKeyFromBlockingListCommands'), + 'BRPOPLPUSH' => array($this, 'getKeyFromBlockingListCommands'), + 'LPUSH' => $keyIsFirstArgument, + 'LPUSHX' => $keyIsFirstArgument, + 'RPUSH' => $keyIsFirstArgument, + 'RPUSHX' => $keyIsFirstArgument, + 'LRANGE' => $keyIsFirstArgument, + 'LREM' => $keyIsFirstArgument, + 'LSET' => $keyIsFirstArgument, + 'LTRIM' => $keyIsFirstArgument, + + /* commands operating on sets */ + 'SADD' => $keyIsFirstArgument, + 'SCARD' => $keyIsFirstArgument, + 'SDIFF' => $keysAreAllArguments, + 'SDIFFSTORE' => $keysAreAllArguments, + 'SINTER' => $keysAreAllArguments, + 'SINTERSTORE' => $keysAreAllArguments, + 'SUNION' => $keysAreAllArguments, + 'SUNIONSTORE' => $keysAreAllArguments, + 'SISMEMBER' => $keyIsFirstArgument, + 'SMEMBERS' => $keyIsFirstArgument, + 'SSCAN' => $keyIsFirstArgument, + 'SPOP' => $keyIsFirstArgument, + 'SRANDMEMBER' => $keyIsFirstArgument, + 'SREM' => $keyIsFirstArgument, + + /* commands operating on sorted sets */ + 'ZADD' => $keyIsFirstArgument, + 'ZCARD' => $keyIsFirstArgument, + 'ZCOUNT' => $keyIsFirstArgument, + 'ZINCRBY' => $keyIsFirstArgument, + 'ZINTERSTORE' => array($this, 'getKeyFromZsetAggregationCommands'), + 'ZRANGE' => $keyIsFirstArgument, + 'ZRANGEBYSCORE' => $keyIsFirstArgument, + 'ZRANK' => $keyIsFirstArgument, + 'ZREM' => $keyIsFirstArgument, + 'ZREMRANGEBYRANK' => $keyIsFirstArgument, + 'ZREMRANGEBYSCORE' => $keyIsFirstArgument, + 'ZREVRANGE' => $keyIsFirstArgument, + 'ZREVRANGEBYSCORE' => $keyIsFirstArgument, + 'ZREVRANK' => $keyIsFirstArgument, + 'ZSCORE' => $keyIsFirstArgument, + 'ZUNIONSTORE' => array($this, 'getKeyFromZsetAggregationCommands'), + 'ZSCAN' => $keyIsFirstArgument, + + /* commands operating on hashes */ + 'HDEL' => $keyIsFirstArgument, + 'HEXISTS' => $keyIsFirstArgument, + 'HGET' => $keyIsFirstArgument, + 'HGETALL' => $keyIsFirstArgument, + 'HMGET' => $keyIsFirstArgument, + 'HMSET' => $keyIsFirstArgument, + 'HINCRBY' => $keyIsFirstArgument, + 'HINCRBYFLOAT' => $keyIsFirstArgument, + 'HKEYS' => $keyIsFirstArgument, + 'HLEN' => $keyIsFirstArgument, + 'HSET' => $keyIsFirstArgument, + 'HSETNX' => $keyIsFirstArgument, + 'HVALS' => $keyIsFirstArgument, + 'HSCAN' => $keyIsFirstArgument, + + /* scripting */ + 'EVAL' => array($this, 'getKeyFromScriptingCommands'), + 'EVALSHA' => array($this, 'getKeyFromScriptingCommands'), + ); + } + + /** + * Returns the list of IDs for the supported commands. + * + * @return array + */ + public function getSupportedCommands() + { + return array_keys($this->commands); + } + + /** + * Sets an handler for the specified command ID. + * + * The signature of the callback must have a single parameter + * of type Predis\Command\CommandInterface. + * + * When the callback argument is omitted or NULL, the previously + * associated handler for the specified command ID is removed. + * + * @param string $commandId The ID of the command to be handled. + * @param mixed $callback A valid callable object or NULL. + */ + public function setCommandHandler($commandId, $callback = null) + { + $commandId = strtoupper($commandId); + + if (!isset($callback)) { + unset($this->commands[$commandId]); + + return; + } + + if (!is_callable($callback)) { + throw new \InvalidArgumentException("Callback must be a valid callable object or NULL"); + } + + $this->commands[$commandId] = $callback; + } + + /** + * Extracts the key from the first argument of a command instance. + * + * @param CommandInterface $command Command instance. + * @return string + */ + protected function getKeyFromFirstArgument(CommandInterface $command) + { + return $command->getArgument(0); + } + + /** + * Extracts the key from a command with multiple keys only when all keys + * in the arguments array produce the same hash. + * + * @param CommandInterface $command Command instance. + * @return string + */ + protected function getKeyFromAllArguments(CommandInterface $command) + { + $arguments = $command->getArguments(); + + if ($this->checkSameHashForKeys($arguments)) { + return $arguments[0]; + } + } + + /** + * Extracts the key from a command with multiple keys only when all keys + * in the arguments array produce the same hash. + * + * @param CommandInterface $command Command instance. + * @return string + */ + protected function getKeyFromInterleavedArguments(CommandInterface $command) + { + $arguments = $command->getArguments(); + $keys = array(); + + for ($i = 0; $i < count($arguments); $i += 2) { + $keys[] = $arguments[$i]; + } + + if ($this->checkSameHashForKeys($keys)) { + return $arguments[0]; + } + } + + /** + * Extracts the key from BLPOP and BRPOP commands. + * + * @param CommandInterface $command Command instance. + * @return string + */ + protected function getKeyFromBlockingListCommands(CommandInterface $command) + { + $arguments = $command->getArguments(); + + if ($this->checkSameHashForKeys(array_slice($arguments, 0, count($arguments) - 1))) { + return $arguments[0]; + } + } + + /** + * Extracts the key from BITOP command. + * + * @param CommandInterface $command Command instance. + * @return string + */ + protected function getKeyFromBitOp(CommandInterface $command) + { + $arguments = $command->getArguments(); + + if ($this->checkSameHashForKeys(array_slice($arguments, 1, count($arguments)))) { + return $arguments[1]; + } + } + + /** + * Extracts the key from ZINTERSTORE and ZUNIONSTORE commands. + * + * @param CommandInterface $command Command instance. + * @return string + */ + protected function getKeyFromZsetAggregationCommands(CommandInterface $command) + { + $arguments = $command->getArguments(); + $keys = array_merge(array($arguments[0]), array_slice($arguments, 2, $arguments[1])); + + if ($this->checkSameHashForKeys($keys)) { + return $arguments[0]; + } + } + + /** + * Extracts the key from EVAL and EVALSHA commands. + * + * @param CommandInterface $command Command instance. + * @return string + */ + protected function getKeyFromScriptingCommands(CommandInterface $command) + { + if ($command instanceof ScriptedCommand) { + $keys = $command->getKeys(); + } else { + $keys = array_slice($args = $command->getArguments(), 2, $args[1]); + } + + if ($keys && $this->checkSameHashForKeys($keys)) { + return $keys[0]; + } + } + + /** + * {@inheritdoc} + */ + public function getHash(CommandInterface $command) + { + $hash = $command->getHash(); + + if (!isset($hash) && isset($this->commands[$cmdID = $command->getId()])) { + $key = call_user_func($this->commands[$cmdID], $command); + + if (isset($key)) { + $hash = $this->getKeyHash($key); + $command->setHash($hash); + } + } + + return $hash; + } + + /** + * {@inheritdoc} + */ + public function getKeyHash($key) + { + $key = $this->extractKeyTag($key); + $hash = $this->hashGenerator->hash($key); + + return $hash; + } + + /** + * Checks if the specified array of keys will generate the same hash. + * + * @param array $keys Array of keys. + * @return bool + */ + protected function checkSameHashForKeys(Array $keys) + { + if (!$count = count($keys)) { + return false; + } + + $currentKey = $this->extractKeyTag($keys[0]); + + for ($i = 1; $i < $count; $i++) { + $nextKey = $this->extractKeyTag($keys[$i]); + + if ($currentKey !== $nextKey) { + return false; + } + + $currentKey = $nextKey; + } + + return true; + } + + /** + * Returns only the hashable part of a key (delimited by "{...}"), or the + * whole key if a key tag is not found in the string. + * + * @param string $key A key. + * @return string + */ + protected function extractKeyTag($key) + { + if (false !== $start = strpos($key, '{')) { + if (false !== $end = strpos($key, '}', $start)) { + $key = substr($key, ++$start, $end - $start); + } + } + + return $key; + } +} diff --git a/vendor/predis/predis/lib/Predis/Cluster/RedisClusterHashStrategy.php b/vendor/predis/predis/lib/Predis/Cluster/RedisClusterHashStrategy.php new file mode 100755 index 0000000..a048c4a --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Cluster/RedisClusterHashStrategy.php @@ -0,0 +1,292 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Cluster; + +use Predis\Cluster\Hash\CRC16HashGenerator; +use Predis\Command\CommandInterface; +use Predis\Command\ScriptedCommand; + +/** + * Default class used by Predis to calculate hashes out of keys of + * commands supported by redis-cluster. + * + * @author Daniele Alessandri + */ +class RedisClusterHashStrategy implements CommandHashStrategyInterface +{ + private $commands; + private $hashGenerator; + + /** + * + */ + public function __construct() + { + $this->commands = $this->getDefaultCommands(); + $this->hashGenerator = new CRC16HashGenerator(); + } + + /** + * Returns the default map of supported commands with their handlers. + * + * @return array + */ + protected function getDefaultCommands() + { + $keyIsFirstArgument = array($this, 'getKeyFromFirstArgument'); + + return array( + /* commands operating on the key space */ + 'EXISTS' => $keyIsFirstArgument, + 'DEL' => array($this, 'getKeyFromAllArguments'), + 'TYPE' => $keyIsFirstArgument, + 'EXPIRE' => $keyIsFirstArgument, + 'EXPIREAT' => $keyIsFirstArgument, + 'PERSIST' => $keyIsFirstArgument, + 'PEXPIRE' => $keyIsFirstArgument, + 'PEXPIREAT' => $keyIsFirstArgument, + 'TTL' => $keyIsFirstArgument, + 'PTTL' => $keyIsFirstArgument, + 'SORT' => $keyIsFirstArgument, // TODO + + /* commands operating on string values */ + 'APPEND' => $keyIsFirstArgument, + 'DECR' => $keyIsFirstArgument, + 'DECRBY' => $keyIsFirstArgument, + 'GET' => $keyIsFirstArgument, + 'GETBIT' => $keyIsFirstArgument, + 'MGET' => array($this, 'getKeyFromAllArguments'), + 'SET' => $keyIsFirstArgument, + 'GETRANGE' => $keyIsFirstArgument, + 'GETSET' => $keyIsFirstArgument, + 'INCR' => $keyIsFirstArgument, + 'INCRBY' => $keyIsFirstArgument, + 'SETBIT' => $keyIsFirstArgument, + 'SETEX' => $keyIsFirstArgument, + 'MSET' => array($this, 'getKeyFromInterleavedArguments'), + 'MSETNX' => array($this, 'getKeyFromInterleavedArguments'), + 'SETNX' => $keyIsFirstArgument, + 'SETRANGE' => $keyIsFirstArgument, + 'STRLEN' => $keyIsFirstArgument, + 'SUBSTR' => $keyIsFirstArgument, + 'BITCOUNT' => $keyIsFirstArgument, + + /* commands operating on lists */ + 'LINSERT' => $keyIsFirstArgument, + 'LINDEX' => $keyIsFirstArgument, + 'LLEN' => $keyIsFirstArgument, + 'LPOP' => $keyIsFirstArgument, + 'RPOP' => $keyIsFirstArgument, + 'BLPOP' => array($this, 'getKeyFromBlockingListCommands'), + 'BRPOP' => array($this, 'getKeyFromBlockingListCommands'), + 'LPUSH' => $keyIsFirstArgument, + 'LPUSHX' => $keyIsFirstArgument, + 'RPUSH' => $keyIsFirstArgument, + 'RPUSHX' => $keyIsFirstArgument, + 'LRANGE' => $keyIsFirstArgument, + 'LREM' => $keyIsFirstArgument, + 'LSET' => $keyIsFirstArgument, + 'LTRIM' => $keyIsFirstArgument, + + /* commands operating on sets */ + 'SADD' => $keyIsFirstArgument, + 'SCARD' => $keyIsFirstArgument, + 'SISMEMBER' => $keyIsFirstArgument, + 'SMEMBERS' => $keyIsFirstArgument, + 'SSCAN' => $keyIsFirstArgument, + 'SPOP' => $keyIsFirstArgument, + 'SRANDMEMBER' => $keyIsFirstArgument, + 'SREM' => $keyIsFirstArgument, + + /* commands operating on sorted sets */ + 'ZADD' => $keyIsFirstArgument, + 'ZCARD' => $keyIsFirstArgument, + 'ZCOUNT' => $keyIsFirstArgument, + 'ZINCRBY' => $keyIsFirstArgument, + 'ZRANGE' => $keyIsFirstArgument, + 'ZRANGEBYSCORE' => $keyIsFirstArgument, + 'ZRANK' => $keyIsFirstArgument, + 'ZREM' => $keyIsFirstArgument, + 'ZREMRANGEBYRANK' => $keyIsFirstArgument, + 'ZREMRANGEBYSCORE' => $keyIsFirstArgument, + 'ZREVRANGE' => $keyIsFirstArgument, + 'ZREVRANGEBYSCORE' => $keyIsFirstArgument, + 'ZREVRANK' => $keyIsFirstArgument, + 'ZSCORE' => $keyIsFirstArgument, + 'ZSCAN' => $keyIsFirstArgument, + + /* commands operating on hashes */ + 'HDEL' => $keyIsFirstArgument, + 'HEXISTS' => $keyIsFirstArgument, + 'HGET' => $keyIsFirstArgument, + 'HGETALL' => $keyIsFirstArgument, + 'HMGET' => $keyIsFirstArgument, + 'HMSET' => $keyIsFirstArgument, + 'HINCRBY' => $keyIsFirstArgument, + 'HINCRBYFLOAT' => $keyIsFirstArgument, + 'HKEYS' => $keyIsFirstArgument, + 'HLEN' => $keyIsFirstArgument, + 'HSET' => $keyIsFirstArgument, + 'HSETNX' => $keyIsFirstArgument, + 'HVALS' => $keyIsFirstArgument, + 'HSCAN' => $keyIsFirstArgument, + + /* scripting */ + 'EVAL' => array($this, 'getKeyFromScriptingCommands'), + 'EVALSHA' => array($this, 'getKeyFromScriptingCommands'), + ); + } + + /** + * Returns the list of IDs for the supported commands. + * + * @return array + */ + public function getSupportedCommands() + { + return array_keys($this->commands); + } + + /** + * Sets an handler for the specified command ID. + * + * The signature of the callback must have a single parameter + * of type Predis\Command\CommandInterface. + * + * When the callback argument is omitted or NULL, the previously + * associated handler for the specified command ID is removed. + * + * @param string $commandId The ID of the command to be handled. + * @param mixed $callback A valid callable object or NULL. + */ + public function setCommandHandler($commandId, $callback = null) + { + $commandId = strtoupper($commandId); + + if (!isset($callback)) { + unset($this->commands[$commandId]); + + return; + } + + if (!is_callable($callback)) { + throw new \InvalidArgumentException("Callback must be a valid callable object or NULL"); + } + + $this->commands[$commandId] = $callback; + } + + /** + * Extracts the key from the first argument of a command instance. + * + * @param CommandInterface $command Command instance. + * @return string + */ + protected function getKeyFromFirstArgument(CommandInterface $command) + { + return $command->getArgument(0); + } + + /** + * Extracts the key from a command that can accept multiple keys ensuring + * that only one key is actually specified to comply with redis-cluster. + * + * @param CommandInterface $command Command instance. + * @return string + */ + protected function getKeyFromAllArguments(CommandInterface $command) + { + $arguments = $command->getArguments(); + + if (count($arguments) === 1) { + return $arguments[0]; + } + } + + /** + * Extracts the key from a command that can accept multiple keys ensuring + * that only one key is actually specified to comply with redis-cluster. + * + * @param CommandInterface $command Command instance. + * @return string + */ + protected function getKeyFromInterleavedArguments(CommandInterface $command) + { + $arguments = $command->getArguments(); + + if (count($arguments) === 2) { + return $arguments[0]; + } + } + + /** + * Extracts the key from BLPOP and BRPOP commands ensuring that only one key + * is actually specified to comply with redis-cluster. + * + * @param CommandInterface $command Command instance. + * @return string + */ + protected function getKeyFromBlockingListCommands(CommandInterface $command) + { + $arguments = $command->getArguments(); + + if (count($arguments) === 2) { + return $arguments[0]; + } + } + + /** + * Extracts the key from EVAL and EVALSHA commands. + * + * @param CommandInterface $command Command instance. + * @return string + */ + protected function getKeyFromScriptingCommands(CommandInterface $command) + { + if ($command instanceof ScriptedCommand) { + $keys = $command->getKeys(); + } else { + $keys = array_slice($args = $command->getArguments(), 2, $args[1]); + } + + if (count($keys) === 1) { + return $keys[0]; + } + } + + /** + * {@inheritdoc} + */ + public function getHash(CommandInterface $command) + { + $hash = $command->getHash(); + + if (!isset($hash) && isset($this->commands[$cmdID = $command->getId()])) { + $key = call_user_func($this->commands[$cmdID], $command); + + if (isset($key)) { + $hash = $this->hashGenerator->hash($key); + $command->setHash($hash); + } + } + + return $hash; + } + + /** + * {@inheritdoc} + */ + public function getKeyHash($key) + { + return $this->hashGenerator->hash($key); + } +} diff --git a/vendor/predis/predis/lib/Predis/Collection/Iterator/CursorBasedIterator.php b/vendor/predis/predis/lib/Predis/Collection/Iterator/CursorBasedIterator.php new file mode 100755 index 0000000..787cd17 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Collection/Iterator/CursorBasedIterator.php @@ -0,0 +1,189 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Collection\Iterator; + +use Iterator; +use Predis\ClientInterface; +use Predis\NotSupportedException; + +/** + * Provides the base implementation for a fully-rewindable PHP iterator + * that can incrementally iterate over cursor-based collections stored + * on Redis using commands in the `SCAN` family. + * + * Given their incremental nature with multiple fetches, these kind of + * iterators offer limited guarantees about the returned elements because + * the collection can change several times during the iteration process. + * + * @see http://redis.io/commands/scan + * + * @author Daniele Alessandri + */ +abstract class CursorBasedIterator implements Iterator +{ + protected $client; + protected $match; + protected $count; + + protected $valid; + protected $fetchmore; + protected $elements; + protected $cursor; + protected $position; + protected $current; + + /** + * @param ClientInterface $client Client connected to Redis. + * @param string $match Pattern to match during the server-side iteration. + * @param int $count Hints used by Redis to compute the number of results per iteration. + */ + public function __construct(ClientInterface $client, $match = null, $count = null) + { + $this->client = $client; + $this->match = $match; + $this->count = $count; + + $this->reset(); + } + + /** + * Ensures that the client instance supports the specified Redis + * command required to fetch elements from the server to perform + * the iteration. + * + * @param ClientInterface $client Client connected to Redis. + * @param string $commandID Command ID. + */ + protected function requiredCommand(ClientInterface $client, $commandID) + { + if (!$client->getProfile()->supportsCommand($commandID)) { + throw new NotSupportedException("The specified server profile does not support the `$commandID` command."); + } + } + + /** + * Resets the inner state of the iterator. + */ + protected function reset() + { + $this->valid = true; + $this->fetchmore = true; + $this->elements = array(); + $this->cursor = 0; + $this->position = -1; + $this->current = null; + } + + /** + * Returns an array of options for the `SCAN` command. + * + * @return array + */ + protected function getScanOptions() + { + $options = array(); + + if (strlen($this->match) > 0) { + $options['MATCH'] = $this->match; + } + + if ($this->count > 0) { + $options['COUNT'] = $this->count; + } + + return $options; + } + + /** + * Fetches a new set of elements from the remote collection, + * effectively advancing the iteration process. + * + * @return array + */ + abstract protected function executeCommand(); + + /** + * Populates the local buffer of elements fetched from the + * server during the iteration. + */ + protected function fetch() + { + list($cursor, $elements) = $this->executeCommand(); + + if (!$cursor) { + $this->fetchmore = false; + } + + $this->cursor = $cursor; + $this->elements = $elements; + } + + /** + * Extracts next values for key() and current(). + */ + protected function extractNext() + { + $this->position++; + $this->current = array_shift($this->elements); + } + + /** + * {@inheritdoc} + */ + public function rewind() + { + $this->reset(); + $this->next(); + } + + /** + * {@inheritdoc} + */ + public function current() + { + return $this->current; + } + + /** + * {@inheritdoc} + */ + public function key() + { + return $this->position; + } + + /** + * {@inheritdoc} + */ + public function next() + { + if (!$this->elements && $this->fetchmore) { + $this->fetch(); + } + + if ($this->elements) { + $this->extractNext(); + } elseif ($this->cursor) { + $this->next(); + } else { + $this->valid = false; + } + } + + /** + * {@inheritdoc} + */ + public function valid() + { + return $this->valid; + } +} diff --git a/vendor/predis/predis/lib/Predis/Collection/Iterator/HashKey.php b/vendor/predis/predis/lib/Predis/Collection/Iterator/HashKey.php new file mode 100755 index 0000000..6fa3d9b --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Collection/Iterator/HashKey.php @@ -0,0 +1,56 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Collection\Iterator; + +use Predis\ClientInterface; + +/** + * Abstracts the iteration of fields and values of an hash + * by leveraging the HSCAN command (Redis >= 2.8) wrapped + * in a fully-rewindable PHP iterator. + * + * @author Daniele Alessandri + * @link http://redis.io/commands/scan + */ +class HashKey extends CursorBasedIterator +{ + protected $key; + + /** + * {@inheritdoc} + */ + public function __construct(ClientInterface $client, $key, $match = null, $count = null) + { + $this->requiredCommand($client, 'HSCAN'); + + parent::__construct($client, $match, $count); + + $this->key = $key; + } + + /** + * {@inheritdoc} + */ + protected function executeCommand() + { + return $this->client->hscan($this->key, $this->cursor, $this->getScanOptions()); + } + + /** + * {@inheritdoc} + */ + protected function extractNext() + { + $this->position = key($this->elements); + $this->current = array_shift($this->elements); + } +} diff --git a/vendor/predis/predis/lib/Predis/Collection/Iterator/Keyspace.php b/vendor/predis/predis/lib/Predis/Collection/Iterator/Keyspace.php new file mode 100755 index 0000000..8000063 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Collection/Iterator/Keyspace.php @@ -0,0 +1,43 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Collection\Iterator; + +use Predis\ClientInterface; + +/** + * Abstracts the iteration of the keyspace on a Redis instance + * by leveraging the SCAN command (Redis >= 2.8) wrapped in a + * fully-rewindable PHP iterator. + * + * @author Daniele Alessandri + * @link http://redis.io/commands/scan + */ +class Keyspace extends CursorBasedIterator +{ + /** + * {@inheritdoc} + */ + public function __construct(ClientInterface $client, $match = null, $count = null) + { + $this->requiredCommand($client, 'SCAN'); + + parent::__construct($client, $match, $count); + } + + /** + * {@inheritdoc} + */ + protected function executeCommand() + { + return $this->client->scan($this->cursor, $this->getScanOptions()); + } +} diff --git a/vendor/predis/predis/lib/Predis/Collection/Iterator/ListKey.php b/vendor/predis/predis/lib/Predis/Collection/Iterator/ListKey.php new file mode 100755 index 0000000..8e3a76d --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Collection/Iterator/ListKey.php @@ -0,0 +1,174 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Collection\Iterator; + +use InvalidArgumentException; +use Iterator; +use Predis\ClientInterface; +use Predis\NotSupportedException; + +/** + * Abstracts the iteration of items stored in a list by leveraging the LRANGE + * command wrapped in a fully-rewindable PHP iterator. + * + * This iterator tries to emulate the behaviour of cursor-based iterators based + * on the SCAN-family of commands introduced in Redis <= 2.8, meaning that due + * to its incremental nature with multiple fetches it can only offer limited + * guarantees on the returned elements because the collection can change several + * times (trimmed, deleted, overwritten) during the iteration process. + * + * @author Daniele Alessandri + * @link http://redis.io/commands/lrange + */ +class ListKey implements Iterator +{ + protected $client; + protected $count; + protected $key; + + protected $valid; + protected $fetchmore; + protected $elements; + protected $position; + protected $current; + + /** + * @param ClientInterface $client Client connected to Redis. + * @param string $key Redis list key. + * @param int $count Number of items retrieved on each fetch operation. + */ + public function __construct(ClientInterface $client, $key, $count = 10) + { + $this->requiredCommand($client, 'LRANGE'); + + if ((false === $count = filter_var($count, FILTER_VALIDATE_INT)) || $count < 0) { + throw new InvalidArgumentException('The $count argument must be a positive integer.'); + } + + $this->client = $client; + $this->key = $key; + $this->count = $count; + + $this->reset(); + } + + /** + * Ensures that the client instance supports the specified Redis + * command required to fetch elements from the server to perform + * the iteration. + * + * @param ClientInterface $client Client connected to Redis. + * @param string $commandID Command ID. + */ + protected function requiredCommand(ClientInterface $client, $commandID) + { + if (!$client->getProfile()->supportsCommand($commandID)) { + throw new NotSupportedException("The specified server profile does not support the `$commandID` command."); + } + } + + /** + * Resets the inner state of the iterator. + */ + protected function reset() + { + $this->valid = true; + $this->fetchmore = true; + $this->elements = array(); + $this->position = -1; + $this->current = null; + } + + /** + * Fetches a new set of elements from the remote collection, + * effectively advancing the iteration process. + * + * @return array + */ + protected function executeCommand() + { + return $this->client->lrange($this->key, $this->position + 1, $this->position + $this->count); + } + + /** + * Populates the local buffer of elements fetched from the + * server during the iteration. + */ + protected function fetch() + { + $elements = $this->executeCommand(); + + if (count($elements) < $this->count) { + $this->fetchmore = false; + } + + $this->elements = $elements; + } + + /** + * Extracts next values for key() and current(). + */ + protected function extractNext() + { + $this->position++; + $this->current = array_shift($this->elements); + } + + /** + * {@inheritdoc} + */ + public function rewind() + { + $this->reset(); + $this->next(); + } + + /** + * {@inheritdoc} + */ + public function current() + { + return $this->current; + } + + /** + * {@inheritdoc} + */ + public function key() + { + return $this->position; + } + + /** + * {@inheritdoc} + */ + public function next() + { + if (!$this->elements && $this->fetchmore) { + $this->fetch(); + } + + if ($this->elements) { + $this->extractNext(); + } else { + $this->valid = false; + } + } + + /** + * {@inheritdoc} + */ + public function valid() + { + return $this->valid; + } +} diff --git a/vendor/predis/predis/lib/Predis/Collection/Iterator/SetKey.php b/vendor/predis/predis/lib/Predis/Collection/Iterator/SetKey.php new file mode 100755 index 0000000..224c24f --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Collection/Iterator/SetKey.php @@ -0,0 +1,47 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Collection\Iterator; + +use Predis\ClientInterface; + +/** + * Abstracts the iteration of members stored in a set by + * leveraging the SSCAN command (Redis >= 2.8) wrapped in + * a fully-rewindable PHP iterator. + * + * @author Daniele Alessandri + * @link http://redis.io/commands/scan + */ +class SetKey extends CursorBasedIterator +{ + protected $key; + + /** + * {@inheritdoc} + */ + public function __construct(ClientInterface $client, $key, $match = null, $count = null) + { + $this->requiredCommand($client, 'SSCAN'); + + parent::__construct($client, $match, $count); + + $this->key = $key; + } + + /** + * {@inheritdoc} + */ + protected function executeCommand() + { + return $this->client->sscan($this->key, $this->cursor, $this->getScanOptions()); + } +} diff --git a/vendor/predis/predis/lib/Predis/Collection/Iterator/SortedSetKey.php b/vendor/predis/predis/lib/Predis/Collection/Iterator/SortedSetKey.php new file mode 100755 index 0000000..a774813 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Collection/Iterator/SortedSetKey.php @@ -0,0 +1,58 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Collection\Iterator; + +use Predis\ClientInterface; + +/** + * Abstracts the iteration of members stored in a sorted set + * by leveraging the ZSCAN command (Redis >= 2.8) wrapped in + * a fully-rewindable PHP iterator. + * + * @author Daniele Alessandri + * @link http://redis.io/commands/scan + */ +class SortedSetKey extends CursorBasedIterator +{ + protected $key; + + /** + * {@inheritdoc} + */ + public function __construct(ClientInterface $client, $key, $match = null, $count = null) + { + $this->requiredCommand($client, 'ZSCAN'); + + parent::__construct($client, $match, $count); + + $this->key = $key; + } + + /** + * {@inheritdoc} + */ + protected function executeCommand() + { + return $this->client->zscan($this->key, $this->cursor, $this->getScanOptions()); + } + + /** + * {@inheritdoc} + */ + protected function extractNext() + { + $element = array_shift($this->elements); + + $this->position = $element[0]; + $this->current = $element[1]; + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/AbstractCommand.php b/vendor/predis/predis/lib/Predis/Command/AbstractCommand.php new file mode 100755 index 0000000..5bd2a19 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/AbstractCommand.php @@ -0,0 +1,158 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * Base class for Redis commands. + * + * @author Daniele Alessandri + */ +abstract class AbstractCommand implements CommandInterface +{ + private $hash; + private $arguments = array(); + + /** + * Returns a filtered array of the arguments. + * + * @param array $arguments List of arguments. + * @return array + */ + protected function filterArguments(Array $arguments) + { + return $arguments; + } + + /** + * {@inheritdoc} + */ + public function setArguments(Array $arguments) + { + $this->arguments = $this->filterArguments($arguments); + unset($this->hash); + } + + /** + * {@inheritdoc} + */ + public function setRawArguments(Array $arguments) + { + $this->arguments = $arguments; + unset($this->hash); + } + + /** + * {@inheritdoc} + */ + public function getArguments() + { + return $this->arguments; + } + + /** + * {@inheritdoc} + */ + public function getArgument($index) + { + if (isset($this->arguments[$index])) { + return $this->arguments[$index]; + } + } + + /** + * {@inheritdoc} + */ + public function setHash($hash) + { + $this->hash = $hash; + } + + /** + * {@inheritdoc} + */ + public function getHash() + { + if (isset($this->hash)) { + return $this->hash; + } + } + + /** + * {@inheritdoc} + */ + public function parseResponse($data) + { + return $data; + } + + /** + * Helper function used to reduce a list of arguments to a string. + * + * @param string $accumulator Temporary string. + * @param string $argument Current argument. + * @return string + */ + protected function toStringArgumentReducer($accumulator, $argument) + { + if (strlen($argument) > 32) { + $argument = substr($argument, 0, 32) . '[...]'; + } + + $accumulator .= " $argument"; + + return $accumulator; + } + + /** + * Returns a partial string representation of the command with its arguments. + * + * @return string + */ + public function __toString() + { + return array_reduce( + $this->getArguments(), + array($this, 'toStringArgumentReducer'), + $this->getId() + ); + } + + /** + * Normalizes the arguments array passed to a Redis command. + * + * @param array $arguments Arguments for a command. + * @return array + */ + public static function normalizeArguments(Array $arguments) + { + if (count($arguments) === 1 && is_array($arguments[0])) { + return $arguments[0]; + } + + return $arguments; + } + + /** + * Normalizes the arguments array passed to a variadic Redis command. + * + * @param array $arguments Arguments for a command. + * @return array + */ + public static function normalizeVariadic(Array $arguments) + { + if (count($arguments) === 2 && is_array($arguments[1])) { + return array_merge(array($arguments[0]), $arguments[1]); + } + + return $arguments; + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/CommandInterface.php b/vendor/predis/predis/lib/Predis/Command/CommandInterface.php new file mode 100755 index 0000000..ae62f01 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/CommandInterface.php @@ -0,0 +1,77 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * Defines an abstraction representing a Redis command. + * @author Daniele Alessandri + */ +interface CommandInterface +{ + /** + * Gets the ID of a Redis command. + * + * @return string + */ + public function getId(); + + /** + * Set the hash for the command. + * + * @param int $hash Calculated hash. + */ + public function setHash($hash); + + /** + * Returns the hash of the command. + * + * @return int + */ + public function getHash(); + + /** + * Sets the arguments for the command. + * + * @param array $arguments List of arguments. + */ + public function setArguments(Array $arguments); + + /** + * Sets the raw arguments for the command without processing them. + * + * @param array $arguments List of arguments. + */ + public function setRawArguments(Array $arguments); + + /** + * Gets the arguments of the command. + * + * @return array + */ + public function getArguments(); + + /** + * Gets the argument of the command at the specified index. + * + * @param int $index Index of the desired argument. + * @return mixed + */ + public function getArgument($index); + + /** + * Parses a reply buffer and returns a PHP object. + * + * @param string $data Binary string containing the whole reply. + * @return mixed + */ + public function parseResponse($data); +} diff --git a/vendor/predis/predis/lib/Predis/Command/ConnectionAuth.php b/vendor/predis/predis/lib/Predis/Command/ConnectionAuth.php new file mode 100755 index 0000000..de0d3ee --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/ConnectionAuth.php @@ -0,0 +1,27 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @link http://redis.io/commands/auth + * @author Daniele Alessandri + */ +class ConnectionAuth extends AbstractCommand +{ + /** + * {@inheritdoc} + */ + public function getId() + { + return 'AUTH'; + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/ConnectionEcho.php b/vendor/predis/predis/lib/Predis/Command/ConnectionEcho.php new file mode 100755 index 0000000..dd9d072 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/ConnectionEcho.php @@ -0,0 +1,27 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @link http://redis.io/commands/echo + * @author Daniele Alessandri + */ +class ConnectionEcho extends AbstractCommand +{ + /** + * {@inheritdoc} + */ + public function getId() + { + return 'ECHO'; + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/ConnectionPing.php b/vendor/predis/predis/lib/Predis/Command/ConnectionPing.php new file mode 100755 index 0000000..cf29416 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/ConnectionPing.php @@ -0,0 +1,35 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @link http://redis.io/commands/ping + * @author Daniele Alessandri + */ +class ConnectionPing extends AbstractCommand +{ + /** + * {@inheritdoc} + */ + public function getId() + { + return 'PING'; + } + + /** + * {@inheritdoc} + */ + public function parseResponse($data) + { + return $data === 'PONG' ? true : false; + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/ConnectionQuit.php b/vendor/predis/predis/lib/Predis/Command/ConnectionQuit.php new file mode 100755 index 0000000..641cc35 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/ConnectionQuit.php @@ -0,0 +1,27 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @link http://redis.io/commands/quit + * @author Daniele Alessandri + */ +class ConnectionQuit extends AbstractCommand +{ + /** + * {@inheritdoc} + */ + public function getId() + { + return 'QUIT'; + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/ConnectionSelect.php b/vendor/predis/predis/lib/Predis/Command/ConnectionSelect.php new file mode 100755 index 0000000..51b96b7 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/ConnectionSelect.php @@ -0,0 +1,27 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @link http://redis.io/commands/select + * @author Daniele Alessandri + */ +class ConnectionSelect extends AbstractCommand +{ + /** + * {@inheritdoc} + */ + public function getId() + { + return 'SELECT'; + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/HashDelete.php b/vendor/predis/predis/lib/Predis/Command/HashDelete.php new file mode 100755 index 0000000..9584678 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/HashDelete.php @@ -0,0 +1,35 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @link http://redis.io/commands/hdel + * @author Daniele Alessandri + */ +class HashDelete extends PrefixableCommand +{ + /** + * {@inheritdoc} + */ + public function getId() + { + return 'HDEL'; + } + + /** + * {@inheritdoc} + */ + protected function filterArguments(Array $arguments) + { + return self::normalizeVariadic($arguments); + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/HashExists.php b/vendor/predis/predis/lib/Predis/Command/HashExists.php new file mode 100755 index 0000000..a9d620a --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/HashExists.php @@ -0,0 +1,35 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @link http://redis.io/commands/hexists + * @author Daniele Alessandri + */ +class HashExists extends PrefixableCommand +{ + /** + * {@inheritdoc} + */ + public function getId() + { + return 'HEXISTS'; + } + + /** + * {@inheritdoc} + */ + public function parseResponse($data) + { + return (bool) $data; + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/HashGet.php b/vendor/predis/predis/lib/Predis/Command/HashGet.php new file mode 100755 index 0000000..b18583a --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/HashGet.php @@ -0,0 +1,27 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @link http://redis.io/commands/hget + * @author Daniele Alessandri + */ +class HashGet extends PrefixableCommand +{ + /** + * {@inheritdoc} + */ + public function getId() + { + return 'HGET'; + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/HashGetAll.php b/vendor/predis/predis/lib/Predis/Command/HashGetAll.php new file mode 100755 index 0000000..51a745f --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/HashGetAll.php @@ -0,0 +1,41 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @link http://redis.io/commands/hgetall + * @author Daniele Alessandri + */ +class HashGetAll extends PrefixableCommand +{ + /** + * {@inheritdoc} + */ + public function getId() + { + return 'HGETALL'; + } + + /** + * {@inheritdoc} + */ + public function parseResponse($data) + { + $result = array(); + + for ($i = 0; $i < count($data); $i++) { + $result[$data[$i]] = $data[++$i]; + } + + return $result; + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/HashGetMultiple.php b/vendor/predis/predis/lib/Predis/Command/HashGetMultiple.php new file mode 100755 index 0000000..d533489 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/HashGetMultiple.php @@ -0,0 +1,35 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @link http://redis.io/commands/hmget + * @author Daniele Alessandri + */ +class HashGetMultiple extends PrefixableCommand +{ + /** + * {@inheritdoc} + */ + public function getId() + { + return 'HMGET'; + } + + /** + * {@inheritdoc} + */ + protected function filterArguments(Array $arguments) + { + return self::normalizeVariadic($arguments); + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/HashIncrementBy.php b/vendor/predis/predis/lib/Predis/Command/HashIncrementBy.php new file mode 100755 index 0000000..1c43e63 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/HashIncrementBy.php @@ -0,0 +1,27 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @link http://redis.io/commands/hincrby + * @author Daniele Alessandri + */ +class HashIncrementBy extends PrefixableCommand +{ + /** + * {@inheritdoc} + */ + public function getId() + { + return 'HINCRBY'; + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/HashIncrementByFloat.php b/vendor/predis/predis/lib/Predis/Command/HashIncrementByFloat.php new file mode 100755 index 0000000..7597058 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/HashIncrementByFloat.php @@ -0,0 +1,27 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @link http://redis.io/commands/hincrbyfloat + * @author Daniele Alessandri + */ +class HashIncrementByFloat extends PrefixableCommand +{ + /** + * {@inheritdoc} + */ + public function getId() + { + return 'HINCRBYFLOAT'; + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/HashKeys.php b/vendor/predis/predis/lib/Predis/Command/HashKeys.php new file mode 100755 index 0000000..279f09a --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/HashKeys.php @@ -0,0 +1,27 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @link http://redis.io/commands/hkeys + * @author Daniele Alessandri + */ +class HashKeys extends PrefixableCommand +{ + /** + * {@inheritdoc} + */ + public function getId() + { + return 'HKEYS'; + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/HashLength.php b/vendor/predis/predis/lib/Predis/Command/HashLength.php new file mode 100755 index 0000000..b2a59c0 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/HashLength.php @@ -0,0 +1,27 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @link http://redis.io/commands/hlen + * @author Daniele Alessandri + */ +class HashLength extends PrefixableCommand +{ + /** + * {@inheritdoc} + */ + public function getId() + { + return 'HLEN'; + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/HashScan.php b/vendor/predis/predis/lib/Predis/Command/HashScan.php new file mode 100755 index 0000000..d1efc25 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/HashScan.php @@ -0,0 +1,84 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @link http://redis.io/commands/hscan + * @author Daniele Alessandri + */ +class HashScan extends PrefixableCommand +{ + /** + * {@inheritdoc} + */ + public function getId() + { + return 'HSCAN'; + } + + /** + * {@inheritdoc} + */ + protected function filterArguments(Array $arguments) + { + if (count($arguments) === 3 && is_array($arguments[2])) { + $options = $this->prepareOptions(array_pop($arguments)); + $arguments = array_merge($arguments, $options); + } + + return $arguments; + } + + /** + * Returns a list of options and modifiers compatible with Redis. + * + * @param array $options List of options. + * @return array + */ + protected function prepareOptions($options) + { + $options = array_change_key_case($options, CASE_UPPER); + $normalized = array(); + + if (!empty($options['MATCH'])) { + $normalized[] = 'MATCH'; + $normalized[] = $options['MATCH']; + } + + if (!empty($options['COUNT'])) { + $normalized[] = 'COUNT'; + $normalized[] = $options['COUNT']; + } + + return $normalized; + } + + /** + * {@inheritdoc} + */ + public function parseResponse($data) + { + if (is_array($data)) { + $data[0] = (int) $data[0]; + $fields = $data[1]; + $result = array(); + + for ($i = 0; $i < count($fields); $i++) { + $result[$fields[$i]] = $fields[++$i]; + } + + $data[1] = $result; + } + + return $data; + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/HashSet.php b/vendor/predis/predis/lib/Predis/Command/HashSet.php new file mode 100755 index 0000000..588afc4 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/HashSet.php @@ -0,0 +1,35 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @link http://redis.io/commands/hset + * @author Daniele Alessandri + */ +class HashSet extends PrefixableCommand +{ + /** + * {@inheritdoc} + */ + public function getId() + { + return 'HSET'; + } + + /** + * {@inheritdoc} + */ + public function parseResponse($data) + { + return (bool) $data; + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/HashSetMultiple.php b/vendor/predis/predis/lib/Predis/Command/HashSetMultiple.php new file mode 100755 index 0000000..f84485f --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/HashSetMultiple.php @@ -0,0 +1,47 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @link http://redis.io/commands/hmset + * @author Daniele Alessandri + */ +class HashSetMultiple extends PrefixableCommand +{ + /** + * {@inheritdoc} + */ + public function getId() + { + return 'HMSET'; + } + + /** + * {@inheritdoc} + */ + protected function filterArguments(Array $arguments) + { + if (count($arguments) === 2 && is_array($arguments[1])) { + $flattenedKVs = array($arguments[0]); + $args = $arguments[1]; + + foreach ($args as $k => $v) { + $flattenedKVs[] = $k; + $flattenedKVs[] = $v; + } + + return $flattenedKVs; + } + + return $arguments; + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/HashSetPreserve.php b/vendor/predis/predis/lib/Predis/Command/HashSetPreserve.php new file mode 100755 index 0000000..3e9890a --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/HashSetPreserve.php @@ -0,0 +1,35 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @link http://redis.io/commands/hsetnx + * @author Daniele Alessandri + */ +class HashSetPreserve extends PrefixableCommand +{ + /** + * {@inheritdoc} + */ + public function getId() + { + return 'HSETNX'; + } + + /** + * {@inheritdoc} + */ + public function parseResponse($data) + { + return (bool) $data; + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/HashValues.php b/vendor/predis/predis/lib/Predis/Command/HashValues.php new file mode 100755 index 0000000..fec3116 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/HashValues.php @@ -0,0 +1,27 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @link http://redis.io/commands/hvals + * @author Daniele Alessandri + */ +class HashValues extends PrefixableCommand +{ + /** + * {@inheritdoc} + */ + public function getId() + { + return 'HVALS'; + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/KeyDelete.php b/vendor/predis/predis/lib/Predis/Command/KeyDelete.php new file mode 100755 index 0000000..4e43141 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/KeyDelete.php @@ -0,0 +1,43 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @link http://redis.io/commands/del + * @author Daniele Alessandri + */ +class KeyDelete extends AbstractCommand implements PrefixableCommandInterface +{ + /** + * {@inheritdoc} + */ + public function getId() + { + return 'DEL'; + } + + /** + * {@inheritdoc} + */ + protected function filterArguments(Array $arguments) + { + return self::normalizeArguments($arguments); + } + + /** + * {@inheritdoc} + */ + public function prefixKeys($prefix) + { + PrefixHelpers::all($this, $prefix); + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/KeyDump.php b/vendor/predis/predis/lib/Predis/Command/KeyDump.php new file mode 100755 index 0000000..55cb90b --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/KeyDump.php @@ -0,0 +1,27 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @link http://redis.io/commands/dump + * @author Daniele Alessandri + */ +class KeyDump extends PrefixableCommand +{ + /** + * {@inheritdoc} + */ + public function getId() + { + return 'DUMP'; + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/KeyExists.php b/vendor/predis/predis/lib/Predis/Command/KeyExists.php new file mode 100755 index 0000000..7f877cd --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/KeyExists.php @@ -0,0 +1,35 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @link http://redis.io/commands/exists + * @author Daniele Alessandri + */ +class KeyExists extends PrefixableCommand +{ + /** + * {@inheritdoc} + */ + public function getId() + { + return 'EXISTS'; + } + + /** + * {@inheritdoc} + */ + public function parseResponse($data) + { + return (bool) $data; + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/KeyExpire.php b/vendor/predis/predis/lib/Predis/Command/KeyExpire.php new file mode 100755 index 0000000..9db8e02 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/KeyExpire.php @@ -0,0 +1,35 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @link http://redis.io/commands/expire + * @author Daniele Alessandri + */ +class KeyExpire extends PrefixableCommand +{ + /** + * {@inheritdoc} + */ + public function getId() + { + return 'EXPIRE'; + } + + /** + * {@inheritdoc} + */ + public function parseResponse($data) + { + return (bool) $data; + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/KeyExpireAt.php b/vendor/predis/predis/lib/Predis/Command/KeyExpireAt.php new file mode 100755 index 0000000..1f6db38 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/KeyExpireAt.php @@ -0,0 +1,35 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @link http://redis.io/commands/expireat + * @author Daniele Alessandri + */ +class KeyExpireAt extends PrefixableCommand +{ + /** + * {@inheritdoc} + */ + public function getId() + { + return 'EXPIREAT'; + } + + /** + * {@inheritdoc} + */ + public function parseResponse($data) + { + return (bool) $data; + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/KeyKeys.php b/vendor/predis/predis/lib/Predis/Command/KeyKeys.php new file mode 100755 index 0000000..3b973ed --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/KeyKeys.php @@ -0,0 +1,27 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @link http://redis.io/commands/keys + * @author Daniele Alessandri + */ +class KeyKeys extends PrefixableCommand +{ + /** + * {@inheritdoc} + */ + public function getId() + { + return 'KEYS'; + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/KeyKeysV12x.php b/vendor/predis/predis/lib/Predis/Command/KeyKeysV12x.php new file mode 100755 index 0000000..2e0d3c9 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/KeyKeysV12x.php @@ -0,0 +1,28 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @link http://redis.io/commands/keys + * @author Daniele Alessandri + * @deprecated + */ +class KeyKeysV12x extends KeyKeys +{ + /** + * {@inheritdoc} + */ + public function parseResponse($data) + { + return explode(' ', $data); + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/KeyMove.php b/vendor/predis/predis/lib/Predis/Command/KeyMove.php new file mode 100755 index 0000000..9e2a64d --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/KeyMove.php @@ -0,0 +1,35 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @link http://redis.io/commands/move + * @author Daniele Alessandri + */ +class KeyMove extends PrefixableCommand +{ + /** + * {@inheritdoc} + */ + public function getId() + { + return 'MOVE'; + } + + /** + * {@inheritdoc} + */ + public function parseResponse($data) + { + return (bool) $data; + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/KeyPersist.php b/vendor/predis/predis/lib/Predis/Command/KeyPersist.php new file mode 100755 index 0000000..5c6b23c --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/KeyPersist.php @@ -0,0 +1,35 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @link http://redis.io/commands/persist + * @author Daniele Alessandri + */ +class KeyPersist extends PrefixableCommand +{ + /** + * {@inheritdoc} + */ + public function getId() + { + return 'PERSIST'; + } + + /** + * {@inheritdoc} + */ + public function parseResponse($data) + { + return (bool) $data; + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/KeyPreciseExpire.php b/vendor/predis/predis/lib/Predis/Command/KeyPreciseExpire.php new file mode 100755 index 0000000..3fb8678 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/KeyPreciseExpire.php @@ -0,0 +1,27 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @link http://redis.io/commands/pexpire + * @author Daniele Alessandri + */ +class KeyPreciseExpire extends KeyExpire +{ + /** + * {@inheritdoc} + */ + public function getId() + { + return 'PEXPIRE'; + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/KeyPreciseExpireAt.php b/vendor/predis/predis/lib/Predis/Command/KeyPreciseExpireAt.php new file mode 100755 index 0000000..14697f2 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/KeyPreciseExpireAt.php @@ -0,0 +1,27 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @link http://redis.io/commands/pexpireat + * @author Daniele Alessandri + */ +class KeyPreciseExpireAt extends KeyExpireAt +{ + /** + * {@inheritdoc} + */ + public function getId() + { + return 'PEXPIREAT'; + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/KeyPreciseTimeToLive.php b/vendor/predis/predis/lib/Predis/Command/KeyPreciseTimeToLive.php new file mode 100755 index 0000000..92e3a02 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/KeyPreciseTimeToLive.php @@ -0,0 +1,27 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @link http://redis.io/commands/pttl + * @author Daniele Alessandri + */ +class KeyPreciseTimeToLive extends KeyTimeToLive +{ + /** + * {@inheritdoc} + */ + public function getId() + { + return 'PTTL'; + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/KeyRandom.php b/vendor/predis/predis/lib/Predis/Command/KeyRandom.php new file mode 100755 index 0000000..520a368 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/KeyRandom.php @@ -0,0 +1,35 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @link http://redis.io/commands/randomkey + * @author Daniele Alessandri + */ +class KeyRandom extends AbstractCommand +{ + /** + * {@inheritdoc} + */ + public function getId() + { + return 'RANDOMKEY'; + } + + /** + * {@inheritdoc} + */ + public function parseResponse($data) + { + return $data !== '' ? $data : null; + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/KeyRename.php b/vendor/predis/predis/lib/Predis/Command/KeyRename.php new file mode 100755 index 0000000..49af1ff --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/KeyRename.php @@ -0,0 +1,35 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @link http://redis.io/commands/rename + * @author Daniele Alessandri + */ +class KeyRename extends AbstractCommand implements PrefixableCommandInterface +{ + /** + * {@inheritdoc} + */ + public function getId() + { + return 'RENAME'; + } + + /** + * {@inheritdoc} + */ + public function prefixKeys($prefix) + { + PrefixHelpers::all($this, $prefix); + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/KeyRenamePreserve.php b/vendor/predis/predis/lib/Predis/Command/KeyRenamePreserve.php new file mode 100755 index 0000000..1db8b7d --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/KeyRenamePreserve.php @@ -0,0 +1,35 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @link http://redis.io/commands/renamenx + * @author Daniele Alessandri + */ +class KeyRenamePreserve extends KeyRename +{ + /** + * {@inheritdoc} + */ + public function getId() + { + return 'RENAMENX'; + } + + /** + * {@inheritdoc} + */ + public function parseResponse($data) + { + return (bool) $data; + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/KeyRestore.php b/vendor/predis/predis/lib/Predis/Command/KeyRestore.php new file mode 100755 index 0000000..623cef6 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/KeyRestore.php @@ -0,0 +1,27 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @link http://redis.io/commands/restore + * @author Daniele Alessandri + */ +class KeyRestore extends PrefixableCommand +{ + /** + * {@inheritdoc} + */ + public function getId() + { + return 'RESTORE'; + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/KeyScan.php b/vendor/predis/predis/lib/Predis/Command/KeyScan.php new file mode 100755 index 0000000..8b68bae --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/KeyScan.php @@ -0,0 +1,76 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @link http://redis.io/commands/scan + * @author Daniele Alessandri + */ +class KeyScan extends AbstractCommand +{ + /** + * {@inheritdoc} + */ + public function getId() + { + return 'SCAN'; + } + + /** + * {@inheritdoc} + */ + protected function filterArguments(Array $arguments) + { + if (count($arguments) === 2 && is_array($arguments[1])) { + $options = $this->prepareOptions(array_pop($arguments)); + $arguments = array_merge($arguments, $options); + } + + return $arguments; + } + + /** + * Returns a list of options and modifiers compatible with Redis. + * + * @param array $options List of options. + * @return array + */ + protected function prepareOptions($options) + { + $options = array_change_key_case($options, CASE_UPPER); + $normalized = array(); + + if (!empty($options['MATCH'])) { + $normalized[] = 'MATCH'; + $normalized[] = $options['MATCH']; + } + + if (!empty($options['COUNT'])) { + $normalized[] = 'COUNT'; + $normalized[] = $options['COUNT']; + } + + return $normalized; + } + + /** + * {@inheritdoc} + */ + public function parseResponse($data) + { + if (is_array($data)) { + $data[0] = (int) $data[0]; + } + + return $data; + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/KeySort.php b/vendor/predis/predis/lib/Predis/Command/KeySort.php new file mode 100755 index 0000000..549469a --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/KeySort.php @@ -0,0 +1,117 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @link http://redis.io/commands/sort + * @author Daniele Alessandri + */ +class KeySort extends AbstractCommand implements PrefixableCommandInterface +{ + /** + * {@inheritdoc} + */ + public function getId() + { + return 'SORT'; + } + + /** + * {@inheritdoc} + */ + protected function filterArguments(Array $arguments) + { + if (count($arguments) === 1) { + return $arguments; + } + + $query = array($arguments[0]); + $sortParams = array_change_key_case($arguments[1], CASE_UPPER); + + if (isset($sortParams['BY'])) { + $query[] = 'BY'; + $query[] = $sortParams['BY']; + } + + if (isset($sortParams['GET'])) { + $getargs = $sortParams['GET']; + + if (is_array($getargs)) { + foreach ($getargs as $getarg) { + $query[] = 'GET'; + $query[] = $getarg; + } + } else { + $query[] = 'GET'; + $query[] = $getargs; + } + } + + if (isset($sortParams['LIMIT']) && + is_array($sortParams['LIMIT']) && + count($sortParams['LIMIT']) == 2) { + + $query[] = 'LIMIT'; + $query[] = $sortParams['LIMIT'][0]; + $query[] = $sortParams['LIMIT'][1]; + } + + if (isset($sortParams['SORT'])) { + $query[] = strtoupper($sortParams['SORT']); + } + + if (isset($sortParams['ALPHA']) && $sortParams['ALPHA'] == true) { + $query[] = 'ALPHA'; + } + + if (isset($sortParams['STORE'])) { + $query[] = 'STORE'; + $query[] = $sortParams['STORE']; + } + + return $query; + } + + /** + * {@inheritdoc} + */ + public function prefixKeys($prefix) + { + if ($arguments = $this->getArguments()) { + $arguments[0] = "$prefix{$arguments[0]}"; + + if (($count = count($arguments)) > 1) { + for ($i = 1; $i < $count; $i++) { + switch ($arguments[$i]) { + case 'BY': + case 'STORE': + $arguments[$i] = "$prefix{$arguments[++$i]}"; + break; + + case 'GET': + $value = $arguments[++$i]; + if ($value !== '#') { + $arguments[$i] = "$prefix$value"; + } + break; + + case 'LIMIT'; + $i += 2; + break; + } + } + } + + $this->setRawArguments($arguments); + } + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/KeyTimeToLive.php b/vendor/predis/predis/lib/Predis/Command/KeyTimeToLive.php new file mode 100755 index 0000000..103885a --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/KeyTimeToLive.php @@ -0,0 +1,27 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @link http://redis.io/commands/ttl + * @author Daniele Alessandri + */ +class KeyTimeToLive extends PrefixableCommand +{ + /** + * {@inheritdoc} + */ + public function getId() + { + return 'TTL'; + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/KeyType.php b/vendor/predis/predis/lib/Predis/Command/KeyType.php new file mode 100755 index 0000000..b2baf9b --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/KeyType.php @@ -0,0 +1,27 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @link http://redis.io/commands/type + * @author Daniele Alessandri + */ +class KeyType extends PrefixableCommand +{ + /** + * {@inheritdoc} + */ + public function getId() + { + return 'TYPE'; + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/ListIndex.php b/vendor/predis/predis/lib/Predis/Command/ListIndex.php new file mode 100755 index 0000000..9762ebf --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/ListIndex.php @@ -0,0 +1,27 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @link http://redis.io/commands/lindex + * @author Daniele Alessandri + */ +class ListIndex extends PrefixableCommand +{ + /** + * {@inheritdoc} + */ + public function getId() + { + return 'LINDEX'; + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/ListInsert.php b/vendor/predis/predis/lib/Predis/Command/ListInsert.php new file mode 100755 index 0000000..289f9b4 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/ListInsert.php @@ -0,0 +1,27 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @link http://redis.io/commands/linsert + * @author Daniele Alessandri + */ +class ListInsert extends PrefixableCommand +{ + /** + * {@inheritdoc} + */ + public function getId() + { + return 'LINSERT'; + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/ListLength.php b/vendor/predis/predis/lib/Predis/Command/ListLength.php new file mode 100755 index 0000000..c46dad4 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/ListLength.php @@ -0,0 +1,27 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @link http://redis.io/commands/llen + * @author Daniele Alessandri + */ +class ListLength extends PrefixableCommand +{ + /** + * {@inheritdoc} + */ + public function getId() + { + return 'LLEN'; + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/ListPopFirst.php b/vendor/predis/predis/lib/Predis/Command/ListPopFirst.php new file mode 100755 index 0000000..f1afc4e --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/ListPopFirst.php @@ -0,0 +1,27 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @link http://redis.io/commands/lpop + * @author Daniele Alessandri + */ +class ListPopFirst extends PrefixableCommand +{ + /** + * {@inheritdoc} + */ + public function getId() + { + return 'LPOP'; + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/ListPopFirstBlocking.php b/vendor/predis/predis/lib/Predis/Command/ListPopFirstBlocking.php new file mode 100755 index 0000000..0ada467 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/ListPopFirstBlocking.php @@ -0,0 +1,48 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @link http://redis.io/commands/blpop + * @author Daniele Alessandri + */ +class ListPopFirstBlocking extends AbstractCommand implements PrefixableCommandInterface +{ + /** + * {@inheritdoc} + */ + public function getId() + { + return 'BLPOP'; + } + + /** + * {@inheritdoc} + */ + protected function filterArguments(Array $arguments) + { + if (count($arguments) === 2 && is_array($arguments[0])) { + list($arguments, $timeout) = $arguments; + array_push($arguments, $timeout); + } + + return $arguments; + } + + /** + * {@inheritdoc} + */ + public function prefixKeys($prefix) + { + PrefixHelpers::skipLast($this, $prefix); + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/ListPopLast.php b/vendor/predis/predis/lib/Predis/Command/ListPopLast.php new file mode 100755 index 0000000..a161f90 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/ListPopLast.php @@ -0,0 +1,27 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @link http://redis.io/commands/rpop + * @author Daniele Alessandri + */ +class ListPopLast extends PrefixableCommand +{ + /** + * {@inheritdoc} + */ + public function getId() + { + return 'RPOP'; + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/ListPopLastBlocking.php b/vendor/predis/predis/lib/Predis/Command/ListPopLastBlocking.php new file mode 100755 index 0000000..fc3d421 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/ListPopLastBlocking.php @@ -0,0 +1,27 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @link http://redis.io/commands/brpop + * @author Daniele Alessandri + */ +class ListPopLastBlocking extends ListPopFirstBlocking +{ + /** + * {@inheritdoc} + */ + public function getId() + { + return 'BRPOP'; + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/ListPopLastPushHead.php b/vendor/predis/predis/lib/Predis/Command/ListPopLastPushHead.php new file mode 100755 index 0000000..761b612 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/ListPopLastPushHead.php @@ -0,0 +1,35 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @link http://redis.io/commands/rpoplpush + * @author Daniele Alessandri + */ +class ListPopLastPushHead extends AbstractCommand implements PrefixableCommandInterface +{ + /** + * {@inheritdoc} + */ + public function getId() + { + return 'RPOPLPUSH'; + } + + /** + * {@inheritdoc} + */ + public function prefixKeys($prefix) + { + PrefixHelpers::all($this, $prefix); + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/ListPopLastPushHeadBlocking.php b/vendor/predis/predis/lib/Predis/Command/ListPopLastPushHeadBlocking.php new file mode 100755 index 0000000..3ef1407 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/ListPopLastPushHeadBlocking.php @@ -0,0 +1,35 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @link http://redis.io/commands/brpoplpush + * @author Daniele Alessandri + */ +class ListPopLastPushHeadBlocking extends AbstractCommand implements PrefixableCommandInterface +{ + /** + * {@inheritdoc} + */ + public function getId() + { + return 'BRPOPLPUSH'; + } + + /** + * {@inheritdoc} + */ + public function prefixKeys($prefix) + { + PrefixHelpers::skipLast($this, $prefix); + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/ListPushHead.php b/vendor/predis/predis/lib/Predis/Command/ListPushHead.php new file mode 100755 index 0000000..6dcb61b --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/ListPushHead.php @@ -0,0 +1,27 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @link http://redis.io/commands/lpush + * @author Daniele Alessandri + */ +class ListPushHead extends ListPushTail +{ + /** + * {@inheritdoc} + */ + public function getId() + { + return 'LPUSH'; + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/ListPushHeadX.php b/vendor/predis/predis/lib/Predis/Command/ListPushHeadX.php new file mode 100755 index 0000000..2cb671e --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/ListPushHeadX.php @@ -0,0 +1,27 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @link http://redis.io/commands/lpushx + * @author Daniele Alessandri + */ +class ListPushHeadX extends PrefixableCommand +{ + /** + * {@inheritdoc} + */ + public function getId() + { + return 'LPUSHX'; + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/ListPushTail.php b/vendor/predis/predis/lib/Predis/Command/ListPushTail.php new file mode 100755 index 0000000..6a0f2e0 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/ListPushTail.php @@ -0,0 +1,35 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @link http://redis.io/commands/rpush + * @author Daniele Alessandri + */ +class ListPushTail extends PrefixableCommand +{ + /** + * {@inheritdoc} + */ + public function getId() + { + return 'RPUSH'; + } + + /** + * {@inheritdoc} + */ + protected function filterArguments(Array $arguments) + { + return self::normalizeVariadic($arguments); + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/ListPushTailX.php b/vendor/predis/predis/lib/Predis/Command/ListPushTailX.php new file mode 100755 index 0000000..af42a52 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/ListPushTailX.php @@ -0,0 +1,27 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @link http://redis.io/commands/rpushx + * @author Daniele Alessandri + */ +class ListPushTailX extends PrefixableCommand +{ + /** + * {@inheritdoc} + */ + public function getId() + { + return 'RPUSHX'; + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/ListRange.php b/vendor/predis/predis/lib/Predis/Command/ListRange.php new file mode 100755 index 0000000..2b2e945 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/ListRange.php @@ -0,0 +1,27 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @link http://redis.io/commands/lrange + * @author Daniele Alessandri + */ +class ListRange extends PrefixableCommand +{ + /** + * {@inheritdoc} + */ + public function getId() + { + return 'LRANGE'; + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/ListRemove.php b/vendor/predis/predis/lib/Predis/Command/ListRemove.php new file mode 100755 index 0000000..98f8854 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/ListRemove.php @@ -0,0 +1,27 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @link http://redis.io/commands/lrem + * @author Daniele Alessandri + */ +class ListRemove extends PrefixableCommand +{ + /** + * {@inheritdoc} + */ + public function getId() + { + return 'LREM'; + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/ListSet.php b/vendor/predis/predis/lib/Predis/Command/ListSet.php new file mode 100755 index 0000000..0ea1ee7 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/ListSet.php @@ -0,0 +1,27 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @link http://redis.io/commands/lset + * @author Daniele Alessandri + */ +class ListSet extends PrefixableCommand +{ + /** + * {@inheritdoc} + */ + public function getId() + { + return 'LSET'; + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/ListTrim.php b/vendor/predis/predis/lib/Predis/Command/ListTrim.php new file mode 100755 index 0000000..80d73e5 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/ListTrim.php @@ -0,0 +1,27 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @link http://redis.io/commands/ltrim + * @author Daniele Alessandri + */ +class ListTrim extends PrefixableCommand +{ + /** + * {@inheritdoc} + */ + public function getId() + { + return 'LTRIM'; + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/PrefixHelpers.php b/vendor/predis/predis/lib/Predis/Command/PrefixHelpers.php new file mode 100755 index 0000000..83e2e9a --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/PrefixHelpers.php @@ -0,0 +1,108 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * Class that defines a few helpers method for prefixing keys. + * + * @author Daniele Alessandri + */ +class PrefixHelpers +{ + /** + * Applies the specified prefix only the first argument. + * + * @param CommandInterface $command Command instance. + * @param string $prefix Prefix string. + */ + public static function first(CommandInterface $command, $prefix) + { + if ($arguments = $command->getArguments()) { + $arguments[0] = "$prefix{$arguments[0]}"; + $command->setRawArguments($arguments); + } + } + + /** + * Applies the specified prefix to all the arguments. + * + * @param CommandInterface $command Command instance. + * @param string $prefix Prefix string. + */ + public static function all(CommandInterface $command, $prefix) + { + if ($arguments = $command->getArguments()) { + foreach ($arguments as &$key) { + $key = "$prefix$key"; + } + + $command->setRawArguments($arguments); + } + } + + /** + * Applies the specified prefix only to even arguments in the list. + * + * @param CommandInterface $command Command instance. + * @param string $prefix Prefix string. + */ + public static function interleaved(CommandInterface $command, $prefix) + { + if ($arguments = $command->getArguments()) { + $length = count($arguments); + + for ($i = 0; $i < $length; $i += 2) { + $arguments[$i] = "$prefix{$arguments[$i]}"; + } + + $command->setRawArguments($arguments); + } + } + + /** + * Applies the specified prefix to all the arguments but the first one. + * + * @param CommandInterface $command Command instance. + * @param string $prefix Prefix string. + */ + public static function skipFirst(CommandInterface $command, $prefix) + { + if ($arguments = $command->getArguments()) { + $length = count($arguments); + + for ($i = 1; $i < $length; $i++) { + $arguments[$i] = "$prefix{$arguments[$i]}"; + } + + $command->setRawArguments($arguments); + } + } + + /** + * Applies the specified prefix to all the arguments but the last one. + * + * @param CommandInterface $command Command instance. + * @param string $prefix Prefix string. + */ + public static function skipLast(CommandInterface $command, $prefix) + { + if ($arguments = $command->getArguments()) { + $length = count($arguments); + + for ($i = 0; $i < $length - 1; $i++) { + $arguments[$i] = "$prefix{$arguments[$i]}"; + } + + $command->setRawArguments($arguments); + } + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/PrefixableCommand.php b/vendor/predis/predis/lib/Predis/Command/PrefixableCommand.php new file mode 100755 index 0000000..7112e87 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/PrefixableCommand.php @@ -0,0 +1,31 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * Base class for Redis commands with prefixable keys. + * + * @author Daniele Alessandri + */ +abstract class PrefixableCommand extends AbstractCommand implements PrefixableCommandInterface +{ + /** + * {@inheritdoc} + */ + public function prefixKeys($prefix) + { + if ($arguments = $this->getArguments()) { + $arguments[0] = "$prefix{$arguments[0]}"; + $this->setRawArguments($arguments); + } + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/PrefixableCommandInterface.php b/vendor/predis/predis/lib/Predis/Command/PrefixableCommandInterface.php new file mode 100755 index 0000000..acb99a2 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/PrefixableCommandInterface.php @@ -0,0 +1,27 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * Defines a command whose keys can be prefixed. + * + * @author Daniele Alessandri + */ +interface PrefixableCommandInterface +{ + /** + * Prefixes all the keys found in the arguments of the command. + * + * @param string $prefix String used to prefix the keys. + */ + public function prefixKeys($prefix); +} diff --git a/vendor/predis/predis/lib/Predis/Command/Processor/CommandProcessingInterface.php b/vendor/predis/predis/lib/Predis/Command/Processor/CommandProcessingInterface.php new file mode 100755 index 0000000..376d465 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/Processor/CommandProcessingInterface.php @@ -0,0 +1,34 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command\Processor; + +/** + * Defines an object that can process commands using command processors. + * + * @author Daniele Alessandri + */ +interface CommandProcessingInterface +{ + /** + * Associates a command processor. + * + * @param CommandProcessorInterface $processor The command processor. + */ + public function setProcessor(CommandProcessorInterface $processor); + + /** + * Returns the associated command processor. + * + * @return CommandProcessorInterface + */ + public function getProcessor(); +} diff --git a/vendor/predis/predis/lib/Predis/Command/Processor/CommandProcessorChainInterface.php b/vendor/predis/predis/lib/Predis/Command/Processor/CommandProcessorChainInterface.php new file mode 100755 index 0000000..2985ac9 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/Processor/CommandProcessorChainInterface.php @@ -0,0 +1,42 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command\Processor; + +/** + * A command processor chain processes a command using multiple chained command + * processor before it is sent to Redis. + * + * @author Daniele Alessandri + */ +interface CommandProcessorChainInterface extends CommandProcessorInterface, \IteratorAggregate, \Countable +{ + /** + * Adds a command processor. + * + * @param CommandProcessorInterface $processor A command processor. + */ + public function add(CommandProcessorInterface $processor); + + /** + * Removes a command processor from the chain. + * + * @param CommandProcessorInterface $processor A command processor. + */ + public function remove(CommandProcessorInterface $processor); + + /** + * Returns an ordered list of the command processors in the chain. + * + * @return array + */ + public function getProcessors(); +} diff --git a/vendor/predis/predis/lib/Predis/Command/Processor/CommandProcessorInterface.php b/vendor/predis/predis/lib/Predis/Command/Processor/CommandProcessorInterface.php new file mode 100755 index 0000000..e23eade --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/Processor/CommandProcessorInterface.php @@ -0,0 +1,29 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command\Processor; + +use Predis\Command\CommandInterface; + +/** + * A command processor processes commands before they are sent to Redis. + * + * @author Daniele Alessandri + */ +interface CommandProcessorInterface +{ + /** + * Processes a Redis command. + * + * @param CommandInterface $command Redis command. + */ + public function process(CommandInterface $command); +} diff --git a/vendor/predis/predis/lib/Predis/Command/Processor/KeyPrefixProcessor.php b/vendor/predis/predis/lib/Predis/Command/Processor/KeyPrefixProcessor.php new file mode 100755 index 0000000..ed0d17f --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/Processor/KeyPrefixProcessor.php @@ -0,0 +1,72 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command\Processor; + +use Predis\Command\CommandInterface; +use Predis\Command\PrefixableCommandInterface; + +/** + * Command processor that is used to prefix the keys contained in the arguments + * of a Redis command. + * + * @author Daniele Alessandri + */ +class KeyPrefixProcessor implements CommandProcessorInterface +{ + private $prefix; + + /** + * @param string $prefix Prefix for the keys. + */ + public function __construct($prefix) + { + $this->setPrefix($prefix); + } + + /** + * Sets a prefix that is applied to all the keys. + * + * @param string $prefix Prefix for the keys. + */ + public function setPrefix($prefix) + { + $this->prefix = $prefix; + } + + /** + * Gets the current prefix. + * + * @return string + */ + public function getPrefix() + { + return $this->prefix; + } + + /** + * {@inheritdoc} + */ + public function process(CommandInterface $command) + { + if ($command instanceof PrefixableCommandInterface && $command->getArguments()) { + $command->prefixKeys($this->prefix); + } + } + + /** + * {@inheritdoc} + */ + public function __toString() + { + return $this->getPrefix(); + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/Processor/ProcessorChain.php b/vendor/predis/predis/lib/Predis/Command/Processor/ProcessorChain.php new file mode 100755 index 0000000..fb4b109 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/Processor/ProcessorChain.php @@ -0,0 +1,130 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command\Processor; + +use Predis\Command\CommandInterface; + +/** + * Default implementation of a command processors chain. + * + * @author Daniele Alessandri + */ +class ProcessorChain implements CommandProcessorChainInterface, \ArrayAccess +{ + private $processors = array(); + + /** + * @param array $processors List of instances of CommandProcessorInterface. + */ + public function __construct($processors = array()) + { + foreach ($processors as $processor) { + $this->add($processor); + } + } + + /** + * {@inheritdoc} + */ + public function add(CommandProcessorInterface $processor) + { + $this->processors[] = $processor; + } + + /** + * {@inheritdoc} + */ + public function remove(CommandProcessorInterface $processor) + { + if (false !== $index = array_search($processor, $this->processors, true)) { + unset($this[$index]); + } + } + + /** + * {@inheritdoc} + */ + public function process(CommandInterface $command) + { + for ($i = 0; $i < $count = count($this->processors); $i++) { + $this->processors[$i]->process($command); + } + } + + /** + * {@inheritdoc} + */ + public function getProcessors() + { + return $this->processors; + } + + /** + * Returns an iterator over the list of command processor in the chain. + * + * @return \ArrayIterator + */ + public function getIterator() + { + return new \ArrayIterator($this->processors); + } + + /** + * Returns the number of command processors in the chain. + * + * @return int + */ + public function count() + { + return count($this->processors); + } + + /** + * {@inheritdoc} + */ + public function offsetExists($index) + { + return isset($this->processors[$index]); + } + + /** + * {@inheritdoc} + */ + public function offsetGet($index) + { + return $this->processors[$index]; + } + + /** + * {@inheritdoc} + */ + public function offsetSet($index, $processor) + { + if (!$processor instanceof CommandProcessorInterface) { + throw new \InvalidArgumentException( + 'A processor chain can hold only instances of classes implementing '. + 'the Predis\Command\Processor\CommandProcessorInterface interface' + ); + } + + $this->processors[$index] = $processor; + } + + /** + * {@inheritdoc} + */ + public function offsetUnset($index) + { + unset($this->processors[$index]); + $this->processors = array_values($this->processors); + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/PubSubPublish.php b/vendor/predis/predis/lib/Predis/Command/PubSubPublish.php new file mode 100755 index 0000000..b2ecce5 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/PubSubPublish.php @@ -0,0 +1,27 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @link http://redis.io/commands/publish + * @author Daniele Alessandri + */ +class PubSubPublish extends PrefixableCommand +{ + /** + * {@inheritdoc} + */ + public function getId() + { + return 'PUBLISH'; + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/PubSubSubscribe.php b/vendor/predis/predis/lib/Predis/Command/PubSubSubscribe.php new file mode 100755 index 0000000..eb8be65 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/PubSubSubscribe.php @@ -0,0 +1,43 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @link http://redis.io/commands/subscribe + * @author Daniele Alessandri + */ +class PubSubSubscribe extends AbstractCommand implements PrefixableCommandInterface +{ + /** + * {@inheritdoc} + */ + public function getId() + { + return 'SUBSCRIBE'; + } + + /** + * {@inheritdoc} + */ + protected function filterArguments(Array $arguments) + { + return self::normalizeArguments($arguments); + } + + /** + * {@inheritdoc} + */ + public function prefixKeys($prefix) + { + PrefixHelpers::all($this, $prefix); + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/PubSubSubscribeByPattern.php b/vendor/predis/predis/lib/Predis/Command/PubSubSubscribeByPattern.php new file mode 100755 index 0000000..7629e6d --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/PubSubSubscribeByPattern.php @@ -0,0 +1,27 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @link http://redis.io/commands/psubscribe + * @author Daniele Alessandri + */ +class PubSubSubscribeByPattern extends PubSubSubscribe +{ + /** + * {@inheritdoc} + */ + public function getId() + { + return 'PSUBSCRIBE'; + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/PubSubUnsubscribe.php b/vendor/predis/predis/lib/Predis/Command/PubSubUnsubscribe.php new file mode 100755 index 0000000..ba70fe4 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/PubSubUnsubscribe.php @@ -0,0 +1,43 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @link http://redis.io/commands/unsubscribe + * @author Daniele Alessandri + */ +class PubSubUnsubscribe extends AbstractCommand implements PrefixableCommandInterface +{ + /** + * {@inheritdoc} + */ + public function getId() + { + return 'UNSUBSCRIBE'; + } + + /** + * {@inheritdoc} + */ + protected function filterArguments(Array $arguments) + { + return self::normalizeArguments($arguments); + } + + /** + * {@inheritdoc} + */ + public function prefixKeys($prefix) + { + PrefixHelpers::all($this, $prefix); + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/PubSubUnsubscribeByPattern.php b/vendor/predis/predis/lib/Predis/Command/PubSubUnsubscribeByPattern.php new file mode 100755 index 0000000..f846e65 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/PubSubUnsubscribeByPattern.php @@ -0,0 +1,27 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @link http://redis.io/commands/punsubscribe + * @author Daniele Alessandri + */ +class PubSubUnsubscribeByPattern extends PubSubUnsubscribe +{ + /** + * {@inheritdoc} + */ + public function getId() + { + return 'PUNSUBSCRIBE'; + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/RawCommand.php b/vendor/predis/predis/lib/Predis/Command/RawCommand.php new file mode 100755 index 0000000..6afa736 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/RawCommand.php @@ -0,0 +1,157 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +use InvalidArgumentException; + +/** + * Class for generic "anonymous" Redis commands. + * + * This command class does not filter input arguments or parse responses, but + * can be used to leverage the standard Predis API to execute any command simply + * by providing the needed arguments following the command signature as defined + * by Redis in its documentation. + * + * @author Daniele Alessandri + */ +class RawCommand implements CommandInterface +{ + private $hash; + private $commandID; + private $arguments; + + public function __construct(array $arguments) + { + if (!$arguments) { + throw new InvalidArgumentException("Arguments array is missing the command ID"); + } + + $this->commandID = strtoupper(array_shift($arguments)); + $this->arguments = $arguments; + } + + /** + * Creates a new raw command using a variadic method. + * + * @param string $commandID Redis command ID. + * @param string ... Arguments list for the command. + * @return CommandInterface + */ + public static function create($commandID /* [ $arg, ... */) + { + $arguments = func_get_args(); + $command = new self($arguments); + + return $command; + } + + /** + * {@inheritdoc} + */ + public function getId() + { + return $this->commandID; + } + + /** + * {@inheritdoc} + */ + public function setArguments(array $arguments) + { + $this->arguments = $arguments; + unset($this->hash); + } + + /** + * {@inheritdoc} + */ + public function setRawArguments(array $arguments) + { + $this->setArguments($arguments); + } + + /** + * {@inheritdoc} + */ + public function getArguments() + { + return $this->arguments; + } + + /** + * {@inheritdoc} + */ + public function getArgument($index) + { + if (isset($this->arguments[$index])) { + return $this->arguments[$index]; + } + } + + /** + * {@inheritdoc} + */ + public function setHash($hash) + { + $this->hash = $hash; + } + + /** + * {@inheritdoc} + */ + public function getHash() + { + if (isset($this->hash)) { + return $this->hash; + } + } + + /** + * {@inheritdoc} + */ + public function parseResponse($data) + { + return $data; + } + + /** + * Helper function used to reduce a list of arguments to a string. + * + * @param string $accumulator Temporary string. + * @param string $argument Current argument. + * @return string + */ + protected function toStringArgumentReducer($accumulator, $argument) + { + if (strlen($argument) > 32) { + $argument = substr($argument, 0, 32) . '[...]'; + } + + $accumulator .= " $argument"; + + return $accumulator; + } + + /** + * Returns a partial string representation of the command with its arguments. + * + * @return string + */ + public function __toString() + { + return array_reduce( + $this->getArguments(), + array($this, 'toStringArgumentReducer'), + $this->getId() + ); + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/ScriptedCommand.php b/vendor/predis/predis/lib/Predis/Command/ScriptedCommand.php new file mode 100755 index 0000000..67855c0 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/ScriptedCommand.php @@ -0,0 +1,76 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * Base class used to implement an higher level abstraction for "virtual" + * commands based on EVAL. + * + * @link http://redis.io/commands/eval + * @author Daniele Alessandri + */ +abstract class ScriptedCommand extends ServerEvalSHA +{ + /** + * Gets the body of a Lua script. + * + * @return string + */ + abstract public function getScript(); + + /** + * Specifies the number of arguments that should be considered as keys. + * + * The default behaviour for the base class is to return 0 to indicate that + * all the elements of the arguments array should be considered as keys, but + * subclasses can enforce a static number of keys. + * + * @return int + */ + protected function getKeysCount() + { + return 0; + } + + /** + * Returns the elements from the arguments that are identified as keys. + * + * @return array + */ + public function getKeys() + { + return array_slice($this->getArguments(), 2, $this->getKeysCount()); + } + + /** + * {@inheritdoc} + */ + protected function filterArguments(Array $arguments) + { + if (($numkeys = $this->getKeysCount()) && $numkeys < 0) { + $numkeys = count($arguments) + $numkeys; + } + + return array_merge(array(sha1($this->getScript()), (int) $numkeys), $arguments); + } + + /** + * @return array + */ + public function getEvalArguments() + { + $arguments = $this->getArguments(); + $arguments[0] = $this->getScript(); + + return $arguments; + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/ServerBackgroundRewriteAOF.php b/vendor/predis/predis/lib/Predis/Command/ServerBackgroundRewriteAOF.php new file mode 100755 index 0000000..c4b4007 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/ServerBackgroundRewriteAOF.php @@ -0,0 +1,35 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @link http://redis.io/commands/bgrewriteaof + * @author Daniele Alessandri + */ +class ServerBackgroundRewriteAOF extends AbstractCommand +{ + /** + * {@inheritdoc} + */ + public function getId() + { + return 'BGREWRITEAOF'; + } + + /** + * {@inheritdoc} + */ + public function parseResponse($data) + { + return $data == 'Background append only file rewriting started'; + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/ServerBackgroundSave.php b/vendor/predis/predis/lib/Predis/Command/ServerBackgroundSave.php new file mode 100755 index 0000000..5993201 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/ServerBackgroundSave.php @@ -0,0 +1,35 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @link http://redis.io/commands/bgsave + * @author Daniele Alessandri + */ +class ServerBackgroundSave extends AbstractCommand +{ + /** + * {@inheritdoc} + */ + public function getId() + { + return 'BGSAVE'; + } + + /** + * {@inheritdoc} + */ + public function parseResponse($data) + { + return $data === 'Background saving started' ? true : $data; + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/ServerClient.php b/vendor/predis/predis/lib/Predis/Command/ServerClient.php new file mode 100755 index 0000000..ca14579 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/ServerClient.php @@ -0,0 +1,73 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @link http://redis.io/commands/client-list + * @link http://redis.io/commands/client-kill + * @link http://redis.io/commands/client-getname + * @link http://redis.io/commands/client-setname + * @author Daniele Alessandri + */ +class ServerClient extends AbstractCommand +{ + /** + * {@inheritdoc} + */ + public function getId() + { + return 'CLIENT'; + } + + /** + * {@inheritdoc} + */ + public function parseResponse($data) + { + $args = array_change_key_case($this->getArguments(), CASE_UPPER); + + switch (strtoupper($args[0])) { + case 'LIST': + return $this->parseClientList($data); + case 'KILL': + case 'GETNAME': + case 'SETNAME': + default: + return $data; + } + } + + /** + * Parses the reply buffer and returns the list of clients returned by + * the CLIENT LIST command. + * + * @param string $data Reply buffer + * @return array + */ + protected function parseClientList($data) + { + $clients = array(); + + foreach (explode("\n", $data, -1) as $clientData) { + $client = array(); + + foreach (explode(' ', $clientData) as $kv) { + @list($k, $v) = explode('=', $kv); + $client[$k] = $v; + } + + $clients[] = $client; + } + + return $clients; + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/ServerConfig.php b/vendor/predis/predis/lib/Predis/Command/ServerConfig.php new file mode 100755 index 0000000..f63215c --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/ServerConfig.php @@ -0,0 +1,48 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @link http://redis.io/commands/config-set + * @link http://redis.io/commands/config-get + * @link http://redis.io/commands/config-resetstat + * @link http://redis.io/commands/config-rewrite + * @author Daniele Alessandri + */ +class ServerConfig extends AbstractCommand +{ + /** + * {@inheritdoc} + */ + public function getId() + { + return 'CONFIG'; + } + + /** + * {@inheritdoc} + */ + public function parseResponse($data) + { + if (is_array($data)) { + $result = array(); + + for ($i = 0; $i < count($data); $i++) { + $result[$data[$i]] = $data[++$i]; + } + + return $result; + } + + return $data; + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/ServerDatabaseSize.php b/vendor/predis/predis/lib/Predis/Command/ServerDatabaseSize.php new file mode 100755 index 0000000..51dcac6 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/ServerDatabaseSize.php @@ -0,0 +1,27 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @link http://redis.io/commands/dbsize + * @author Daniele Alessandri + */ +class ServerDatabaseSize extends AbstractCommand +{ + /** + * {@inheritdoc} + */ + public function getId() + { + return 'DBSIZE'; + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/ServerEval.php b/vendor/predis/predis/lib/Predis/Command/ServerEval.php new file mode 100755 index 0000000..0c1f182 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/ServerEval.php @@ -0,0 +1,51 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @link http://redis.io/commands/eval + * @author Daniele Alessandri + */ +class ServerEval extends AbstractCommand implements PrefixableCommandInterface +{ + /** + * {@inheritdoc} + */ + public function getId() + { + return 'EVAL'; + } + + /** + * {@inheritdoc} + */ + public function prefixKeys($prefix) + { + if ($arguments = $this->getArguments()) { + for ($i = 2; $i < $arguments[1] + 2; $i++) { + $arguments[$i] = "$prefix{$arguments[$i]}"; + } + + $this->setRawArguments($arguments); + } + } + + /** + * Calculates the SHA1 hash of the body of the script. + * + * @return string SHA1 hash. + */ + public function getScriptHash() + { + return sha1($this->getArgument(0)); + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/ServerEvalSHA.php b/vendor/predis/predis/lib/Predis/Command/ServerEvalSHA.php new file mode 100755 index 0000000..a670390 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/ServerEvalSHA.php @@ -0,0 +1,37 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @link http://redis.io/commands/evalsha + * @author Daniele Alessandri + */ +class ServerEvalSHA extends ServerEval +{ + /** + * {@inheritdoc} + */ + public function getId() + { + return 'EVALSHA'; + } + + /** + * Returns the SHA1 hash of the body of the script. + * + * @return string SHA1 hash. + */ + public function getScriptHash() + { + return $this->getArgument(0); + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/ServerFlushAll.php b/vendor/predis/predis/lib/Predis/Command/ServerFlushAll.php new file mode 100755 index 0000000..a50218c --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/ServerFlushAll.php @@ -0,0 +1,27 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @link http://redis.io/commands/flushall + * @author Daniele Alessandri + */ +class ServerFlushAll extends AbstractCommand +{ + /** + * {@inheritdoc} + */ + public function getId() + { + return 'FLUSHALL'; + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/ServerFlushDatabase.php b/vendor/predis/predis/lib/Predis/Command/ServerFlushDatabase.php new file mode 100755 index 0000000..8b6b6a2 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/ServerFlushDatabase.php @@ -0,0 +1,27 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @link http://redis.io/commands/flushdb + * @author Daniele Alessandri + */ +class ServerFlushDatabase extends AbstractCommand +{ + /** + * {@inheritdoc} + */ + public function getId() + { + return 'FLUSHDB'; + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/ServerInfo.php b/vendor/predis/predis/lib/Predis/Command/ServerInfo.php new file mode 100755 index 0000000..899b16b --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/ServerInfo.php @@ -0,0 +1,100 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @link http://redis.io/commands/info + * @author Daniele Alessandri + */ +class ServerInfo extends AbstractCommand +{ + /** + * {@inheritdoc} + */ + public function getId() + { + return 'INFO'; + } + + /** + * {@inheritdoc} + */ + public function parseResponse($data) + { + $info = array(); + $infoLines = preg_split('/\r?\n/', $data); + + foreach ($infoLines as $row) { + @list($k, $v) = explode(':', $row); + + if ($row === '' || !isset($v)) { + continue; + } + + if (!preg_match('/^db\d+$/', $k)) { + if ($k === 'allocation_stats') { + $info[$k] = $this->parseAllocationStats($v); + continue; + } + + $info[$k] = $v; + } else { + $info[$k] = $this->parseDatabaseStats($v); + } + } + + return $info; + } + + /** + * Parses the reply buffer and extracts the statistics of each logical DB. + * + * @param string $str Reply buffer. + * @return array + */ + protected function parseDatabaseStats($str) + { + $db = array(); + + foreach (explode(',', $str) as $dbvar) { + list($dbvk, $dbvv) = explode('=', $dbvar); + $db[trim($dbvk)] = $dbvv; + } + + return $db; + } + + /** + * Parses the reply buffer and extracts the allocation statistics. + * + * @param string $str Reply buffer. + * @return array + */ + protected function parseAllocationStats($str) + { + $stats = array(); + + foreach (explode(',', $str) as $kv) { + @list($size, $objects, $extra) = explode('=', $kv); + + // hack to prevent incorrect values when parsing the >=256 key + if (isset($extra)) { + $size = ">=$objects"; + $objects = $extra; + } + + $stats[$size] = $objects; + } + + return $stats; + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/ServerInfoV26x.php b/vendor/predis/predis/lib/Predis/Command/ServerInfoV26x.php new file mode 100755 index 0000000..457fe30 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/ServerInfoV26x.php @@ -0,0 +1,60 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @link http://redis.io/commands/info + * @author Daniele Alessandri + */ +class ServerInfoV26x extends ServerInfo +{ + /** + * {@inheritdoc} + */ + public function parseResponse($data) + { + $info = array(); + $current = null; + $infoLines = preg_split('/\r?\n/', $data); + + if (isset($infoLines[0]) && $infoLines[0][0] !== '#') { + return parent::parseResponse($data); + } + + foreach ($infoLines as $row) { + if ($row === '') { + continue; + } + + if (preg_match('/^# (\w+)$/', $row, $matches)) { + $info[$matches[1]] = array(); + $current = &$info[$matches[1]]; + continue; + } + + list($k, $v) = explode(':', $row); + + if (!preg_match('/^db\d+$/', $k)) { + if ($k === 'allocation_stats') { + $current[$k] = $this->parseAllocationStats($v); + continue; + } + + $current[$k] = $v; + } else { + $current[$k] = $this->parseDatabaseStats($v); + } + } + + return $info; + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/ServerLastSave.php b/vendor/predis/predis/lib/Predis/Command/ServerLastSave.php new file mode 100755 index 0000000..33a1e93 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/ServerLastSave.php @@ -0,0 +1,27 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @link http://redis.io/commands/lastsave + * @author Daniele Alessandri + */ +class ServerLastSave extends AbstractCommand +{ + /** + * {@inheritdoc} + */ + public function getId() + { + return 'LASTSAVE'; + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/ServerMonitor.php b/vendor/predis/predis/lib/Predis/Command/ServerMonitor.php new file mode 100755 index 0000000..7f4a83f --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/ServerMonitor.php @@ -0,0 +1,27 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @link http://redis.io/commands/monitor + * @author Daniele Alessandri + */ +class ServerMonitor extends AbstractCommand +{ + /** + * {@inheritdoc} + */ + public function getId() + { + return 'MONITOR'; + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/ServerObject.php b/vendor/predis/predis/lib/Predis/Command/ServerObject.php new file mode 100755 index 0000000..989fbd7 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/ServerObject.php @@ -0,0 +1,27 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @link http://redis.io/commands/object + * @author Daniele Alessandri + */ +class ServerObject extends AbstractCommand +{ + /** + * {@inheritdoc} + */ + public function getId() + { + return 'OBJECT'; + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/ServerSave.php b/vendor/predis/predis/lib/Predis/Command/ServerSave.php new file mode 100755 index 0000000..6dd3c79 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/ServerSave.php @@ -0,0 +1,27 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @link http://redis.io/commands/save + * @author Daniele Alessandri + */ +class ServerSave extends AbstractCommand +{ + /** + * {@inheritdoc} + */ + public function getId() + { + return 'SAVE'; + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/ServerScript.php b/vendor/predis/predis/lib/Predis/Command/ServerScript.php new file mode 100755 index 0000000..5b66866 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/ServerScript.php @@ -0,0 +1,27 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @link http://redis.io/commands/script + * @author Daniele Alessandri + */ +class ServerScript extends AbstractCommand +{ + /** + * {@inheritdoc} + */ + public function getId() + { + return 'SCRIPT'; + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/ServerShutdown.php b/vendor/predis/predis/lib/Predis/Command/ServerShutdown.php new file mode 100755 index 0000000..b0278b0 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/ServerShutdown.php @@ -0,0 +1,27 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @link http://redis.io/commands/shutdown + * @author Daniele Alessandri + */ +class ServerShutdown extends AbstractCommand +{ + /** + * {@inheritdoc} + */ + public function getId() + { + return 'SHUTDOWN'; + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/ServerSlaveOf.php b/vendor/predis/predis/lib/Predis/Command/ServerSlaveOf.php new file mode 100755 index 0000000..94f9f69 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/ServerSlaveOf.php @@ -0,0 +1,39 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @link http://redis.io/commands/slaveof + * @author Daniele Alessandri + */ +class ServerSlaveOf extends AbstractCommand +{ + /** + * {@inheritdoc} + */ + public function getId() + { + return 'SLAVEOF'; + } + + /** + * {@inheritdoc} + */ + protected function filterArguments(Array $arguments) + { + if (count($arguments) === 0 || $arguments[0] === 'NO ONE') { + return array('NO', 'ONE'); + } + + return $arguments; + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/ServerSlowlog.php b/vendor/predis/predis/lib/Predis/Command/ServerSlowlog.php new file mode 100755 index 0000000..ad4155f --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/ServerSlowlog.php @@ -0,0 +1,50 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @link http://redis.io/commands/slowlog + * @author Daniele Alessandri + */ +class ServerSlowlog extends AbstractCommand +{ + /** + * {@inheritdoc} + */ + public function getId() + { + return 'SLOWLOG'; + } + + /** + * {@inheritdoc} + */ + public function parseResponse($data) + { + if (is_array($data)) { + $log = array(); + + foreach ($data as $index => $entry) { + $log[$index] = array( + 'id' => $entry[0], + 'timestamp' => $entry[1], + 'duration' => $entry[2], + 'command' => $entry[3], + ); + } + + return $log; + } + + return $data; + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/ServerTime.php b/vendor/predis/predis/lib/Predis/Command/ServerTime.php new file mode 100755 index 0000000..1797637 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/ServerTime.php @@ -0,0 +1,27 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @link http://redis.io/commands/time + * @author Daniele Alessandri + */ +class ServerTime extends AbstractCommand +{ + /** + * {@inheritdoc} + */ + public function getId() + { + return 'TIME'; + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/SetAdd.php b/vendor/predis/predis/lib/Predis/Command/SetAdd.php new file mode 100755 index 0000000..f03e02b --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/SetAdd.php @@ -0,0 +1,35 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @link http://redis.io/commands/sadd + * @author Daniele Alessandri + */ +class SetAdd extends PrefixableCommand +{ + /** + * {@inheritdoc} + */ + public function getId() + { + return 'SADD'; + } + + /** + * {@inheritdoc} + */ + protected function filterArguments(Array $arguments) + { + return self::normalizeVariadic($arguments); + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/SetCardinality.php b/vendor/predis/predis/lib/Predis/Command/SetCardinality.php new file mode 100755 index 0000000..8e6e48e --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/SetCardinality.php @@ -0,0 +1,27 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @link http://redis.io/commands/scard + * @author Daniele Alessandri + */ +class SetCardinality extends PrefixableCommand +{ + /** + * {@inheritdoc} + */ + public function getId() + { + return 'SCARD'; + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/SetDifference.php b/vendor/predis/predis/lib/Predis/Command/SetDifference.php new file mode 100755 index 0000000..14d3f21 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/SetDifference.php @@ -0,0 +1,27 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @link http://redis.io/commands/sdiff + * @author Daniele Alessandri + */ +class SetDifference extends SetIntersection +{ + /** + * {@inheritdoc} + */ + public function getId() + { + return 'SDIFF'; + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/SetDifferenceStore.php b/vendor/predis/predis/lib/Predis/Command/SetDifferenceStore.php new file mode 100755 index 0000000..1fae8b7 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/SetDifferenceStore.php @@ -0,0 +1,27 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @link http://redis.io/commands/sdiffstore + * @author Daniele Alessandri + */ +class SetDifferenceStore extends SetIntersectionStore +{ + /** + * {@inheritdoc} + */ + public function getId() + { + return 'SDIFFSTORE'; + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/SetIntersection.php b/vendor/predis/predis/lib/Predis/Command/SetIntersection.php new file mode 100755 index 0000000..c6590d2 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/SetIntersection.php @@ -0,0 +1,43 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @link http://redis.io/commands/sinter + * @author Daniele Alessandri + */ +class SetIntersection extends AbstractCommand implements PrefixableCommandInterface +{ + /** + * {@inheritdoc} + */ + public function getId() + { + return 'SINTER'; + } + + /** + * {@inheritdoc} + */ + protected function filterArguments(Array $arguments) + { + return self::normalizeArguments($arguments); + } + + /** + * {@inheritdoc} + */ + public function prefixKeys($prefix) + { + PrefixHelpers::all($this, $prefix); + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/SetIntersectionStore.php b/vendor/predis/predis/lib/Predis/Command/SetIntersectionStore.php new file mode 100755 index 0000000..4e764e0 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/SetIntersectionStore.php @@ -0,0 +1,47 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @link http://redis.io/commands/sinterstore + * @author Daniele Alessandri + */ +class SetIntersectionStore extends AbstractCommand implements PrefixableCommandInterface +{ + /** + * {@inheritdoc} + */ + public function getId() + { + return 'SINTERSTORE'; + } + + /** + * {@inheritdoc} + */ + protected function filterArguments(Array $arguments) + { + if (count($arguments) === 2 && is_array($arguments[1])) { + return array_merge(array($arguments[0]), $arguments[1]); + } + + return $arguments; + } + + /** + * {@inheritdoc} + */ + public function prefixKeys($prefix) + { + PrefixHelpers::all($this, $prefix); + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/SetIsMember.php b/vendor/predis/predis/lib/Predis/Command/SetIsMember.php new file mode 100755 index 0000000..0773520 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/SetIsMember.php @@ -0,0 +1,35 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @link http://redis.io/commands/sismember + * @author Daniele Alessandri + */ +class SetIsMember extends PrefixableCommand +{ + /** + * {@inheritdoc} + */ + public function getId() + { + return 'SISMEMBER'; + } + + /** + * {@inheritdoc} + */ + public function parseResponse($data) + { + return (bool) $data; + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/SetMembers.php b/vendor/predis/predis/lib/Predis/Command/SetMembers.php new file mode 100755 index 0000000..3ebef0a --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/SetMembers.php @@ -0,0 +1,27 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @link http://redis.io/commands/smembers + * @author Daniele Alessandri + */ +class SetMembers extends PrefixableCommand +{ + /** + * {@inheritdoc} + */ + public function getId() + { + return 'SMEMBERS'; + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/SetMove.php b/vendor/predis/predis/lib/Predis/Command/SetMove.php new file mode 100755 index 0000000..01678ec --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/SetMove.php @@ -0,0 +1,43 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @link http://redis.io/commands/smove + * @author Daniele Alessandri + */ +class SetMove extends AbstractCommand implements PrefixableCommandInterface +{ + /** + * {@inheritdoc} + */ + public function getId() + { + return 'SMOVE'; + } + + /** + * {@inheritdoc} + */ + public function prefixKeys($prefix) + { + PrefixHelpers::skipLast($this, $prefix); + } + + /** + * {@inheritdoc} + */ + public function parseResponse($data) + { + return (bool) $data; + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/SetPop.php b/vendor/predis/predis/lib/Predis/Command/SetPop.php new file mode 100755 index 0000000..ebfec0c --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/SetPop.php @@ -0,0 +1,27 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @link http://redis.io/commands/spop + * @author Daniele Alessandri + */ +class SetPop extends PrefixableCommand +{ + /** + * {@inheritdoc} + */ + public function getId() + { + return 'SPOP'; + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/SetRandomMember.php b/vendor/predis/predis/lib/Predis/Command/SetRandomMember.php new file mode 100755 index 0000000..a6b6062 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/SetRandomMember.php @@ -0,0 +1,27 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @link http://redis.io/commands/srandmember + * @author Daniele Alessandri + */ +class SetRandomMember extends PrefixableCommand +{ + /** + * {@inheritdoc} + */ + public function getId() + { + return 'SRANDMEMBER'; + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/SetRemove.php b/vendor/predis/predis/lib/Predis/Command/SetRemove.php new file mode 100755 index 0000000..f7cb577 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/SetRemove.php @@ -0,0 +1,35 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @link http://redis.io/commands/srem + * @author Daniele Alessandri + */ +class SetRemove extends PrefixableCommand +{ + /** + * {@inheritdoc} + */ + public function getId() + { + return 'SREM'; + } + + /** + * {@inheritdoc} + */ + protected function filterArguments(Array $arguments) + { + return self::normalizeVariadic($arguments); + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/SetScan.php b/vendor/predis/predis/lib/Predis/Command/SetScan.php new file mode 100755 index 0000000..27b6de2 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/SetScan.php @@ -0,0 +1,76 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @link http://redis.io/commands/sscan + * @author Daniele Alessandri + */ +class SetScan extends PrefixableCommand +{ + /** + * {@inheritdoc} + */ + public function getId() + { + return 'SSCAN'; + } + + /** + * {@inheritdoc} + */ + protected function filterArguments(Array $arguments) + { + if (count($arguments) === 3 && is_array($arguments[2])) { + $options = $this->prepareOptions(array_pop($arguments)); + $arguments = array_merge($arguments, $options); + } + + return $arguments; + } + + /** + * Returns a list of options and modifiers compatible with Redis. + * + * @param array $options List of options. + * @return array + */ + protected function prepareOptions($options) + { + $options = array_change_key_case($options, CASE_UPPER); + $normalized = array(); + + if (!empty($options['MATCH'])) { + $normalized[] = 'MATCH'; + $normalized[] = $options['MATCH']; + } + + if (!empty($options['COUNT'])) { + $normalized[] = 'COUNT'; + $normalized[] = $options['COUNT']; + } + + return $normalized; + } + + /** + * {@inheritdoc} + */ + public function parseResponse($data) + { + if (is_array($data)) { + $data[0] = (int) $data[0]; + } + + return $data; + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/SetUnion.php b/vendor/predis/predis/lib/Predis/Command/SetUnion.php new file mode 100755 index 0000000..c9f322b --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/SetUnion.php @@ -0,0 +1,27 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @link http://redis.io/commands/sunion + * @author Daniele Alessandri + */ +class SetUnion extends SetIntersection +{ + /** + * {@inheritdoc} + */ + public function getId() + { + return 'SUNION'; + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/SetUnionStore.php b/vendor/predis/predis/lib/Predis/Command/SetUnionStore.php new file mode 100755 index 0000000..daf66c3 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/SetUnionStore.php @@ -0,0 +1,27 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @link http://redis.io/commands/sunionstore + * @author Daniele Alessandri + */ +class SetUnionStore extends SetIntersectionStore +{ + /** + * {@inheritdoc} + */ + public function getId() + { + return 'SUNIONSTORE'; + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/StringAppend.php b/vendor/predis/predis/lib/Predis/Command/StringAppend.php new file mode 100755 index 0000000..8d14614 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/StringAppend.php @@ -0,0 +1,27 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @link http://redis.io/commands/append + * @author Daniele Alessandri + */ +class StringAppend extends PrefixableCommand +{ + /** + * {@inheritdoc} + */ + public function getId() + { + return 'APPEND'; + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/StringBitCount.php b/vendor/predis/predis/lib/Predis/Command/StringBitCount.php new file mode 100755 index 0000000..19d534b --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/StringBitCount.php @@ -0,0 +1,27 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @link http://redis.io/commands/bitcount + * @author Daniele Alessandri + */ +class StringBitCount extends PrefixableCommand +{ + /** + * {@inheritdoc} + */ + public function getId() + { + return 'BITCOUNT'; + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/StringBitOp.php b/vendor/predis/predis/lib/Predis/Command/StringBitOp.php new file mode 100755 index 0000000..0236bb1 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/StringBitOp.php @@ -0,0 +1,49 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @link http://redis.io/commands/bitop + * @author Daniele Alessandri + */ +class StringBitOp extends AbstractCommand implements PrefixableCommandInterface +{ + /** + * {@inheritdoc} + */ + public function getId() + { + return 'BITOP'; + } + + /** + * {@inheritdoc} + */ + protected function filterArguments(Array $arguments) + { + if (count($arguments) === 3 && is_array($arguments[2])) { + list($operation, $destination, ) = $arguments; + $arguments = $arguments[2]; + array_unshift($arguments, $operation, $destination); + } + + return $arguments; + } + + /** + * {@inheritdoc} + */ + public function prefixKeys($prefix) + { + PrefixHelpers::skipFirst($this, $prefix); + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/StringDecrement.php b/vendor/predis/predis/lib/Predis/Command/StringDecrement.php new file mode 100755 index 0000000..0e45cd0 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/StringDecrement.php @@ -0,0 +1,27 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @link http://redis.io/commands/decr + * @author Daniele Alessandri + */ +class StringDecrement extends PrefixableCommand +{ + /** + * {@inheritdoc} + */ + public function getId() + { + return 'DECR'; + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/StringDecrementBy.php b/vendor/predis/predis/lib/Predis/Command/StringDecrementBy.php new file mode 100755 index 0000000..e716e0e --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/StringDecrementBy.php @@ -0,0 +1,27 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @link http://redis.io/commands/decrby + * @author Daniele Alessandri + */ +class StringDecrementBy extends PrefixableCommand +{ + /** + * {@inheritdoc} + */ + public function getId() + { + return 'DECRBY'; + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/StringGet.php b/vendor/predis/predis/lib/Predis/Command/StringGet.php new file mode 100755 index 0000000..851c710 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/StringGet.php @@ -0,0 +1,27 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @link http://redis.io/commands/get + * @author Daniele Alessandri + */ +class StringGet extends PrefixableCommand +{ + /** + * {@inheritdoc} + */ + public function getId() + { + return 'GET'; + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/StringGetBit.php b/vendor/predis/predis/lib/Predis/Command/StringGetBit.php new file mode 100755 index 0000000..954c39f --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/StringGetBit.php @@ -0,0 +1,27 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @link http://redis.io/commands/getbit + * @author Daniele Alessandri + */ +class StringGetBit extends PrefixableCommand +{ + /** + * {@inheritdoc} + */ + public function getId() + { + return 'GETBIT'; + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/StringGetMultiple.php b/vendor/predis/predis/lib/Predis/Command/StringGetMultiple.php new file mode 100755 index 0000000..71d9187 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/StringGetMultiple.php @@ -0,0 +1,43 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @link http://redis.io/commands/mget + * @author Daniele Alessandri + */ +class StringGetMultiple extends AbstractCommand implements PrefixableCommandInterface +{ + /** + * {@inheritdoc} + */ + public function getId() + { + return 'MGET'; + } + + /** + * {@inheritdoc} + */ + protected function filterArguments(Array $arguments) + { + return self::normalizeArguments($arguments); + } + + /** + * {@inheritdoc} + */ + public function prefixKeys($prefix) + { + PrefixHelpers::all($this, $prefix); + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/StringGetRange.php b/vendor/predis/predis/lib/Predis/Command/StringGetRange.php new file mode 100755 index 0000000..aed4853 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/StringGetRange.php @@ -0,0 +1,27 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @link http://redis.io/commands/getrange + * @author Daniele Alessandri + */ +class StringGetRange extends PrefixableCommand +{ + /** + * {@inheritdoc} + */ + public function getId() + { + return 'GETRANGE'; + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/StringGetSet.php b/vendor/predis/predis/lib/Predis/Command/StringGetSet.php new file mode 100755 index 0000000..d4b8e23 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/StringGetSet.php @@ -0,0 +1,27 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @link http://redis.io/commands/getset + * @author Daniele Alessandri + */ +class StringGetSet extends PrefixableCommand +{ + /** + * {@inheritdoc} + */ + public function getId() + { + return 'GETSET'; + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/StringIncrement.php b/vendor/predis/predis/lib/Predis/Command/StringIncrement.php new file mode 100755 index 0000000..4848afc --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/StringIncrement.php @@ -0,0 +1,27 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @link http://redis.io/commands/incr + * @author Daniele Alessandri + */ +class StringIncrement extends PrefixableCommand +{ + /** + * {@inheritdoc} + */ + public function getId() + { + return 'INCR'; + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/StringIncrementBy.php b/vendor/predis/predis/lib/Predis/Command/StringIncrementBy.php new file mode 100755 index 0000000..7fa3188 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/StringIncrementBy.php @@ -0,0 +1,27 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @link http://redis.io/commands/incrby + * @author Daniele Alessandri + */ +class StringIncrementBy extends PrefixableCommand +{ + /** + * {@inheritdoc} + */ + public function getId() + { + return 'INCRBY'; + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/StringIncrementByFloat.php b/vendor/predis/predis/lib/Predis/Command/StringIncrementByFloat.php new file mode 100755 index 0000000..7e14dff --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/StringIncrementByFloat.php @@ -0,0 +1,27 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @link http://redis.io/commands/incrbyfloat + * @author Daniele Alessandri + */ +class StringIncrementByFloat extends PrefixableCommand +{ + /** + * {@inheritdoc} + */ + public function getId() + { + return 'INCRBYFLOAT'; + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/StringPreciseSetExpire.php b/vendor/predis/predis/lib/Predis/Command/StringPreciseSetExpire.php new file mode 100755 index 0000000..da2cbad --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/StringPreciseSetExpire.php @@ -0,0 +1,27 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @link http://redis.io/commands/psetex + * @author Daniele Alessandri + */ +class StringPreciseSetExpire extends StringSetExpire +{ + /** + * {@inheritdoc} + */ + public function getId() + { + return 'PSETEX'; + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/StringSet.php b/vendor/predis/predis/lib/Predis/Command/StringSet.php new file mode 100755 index 0000000..eb3739b --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/StringSet.php @@ -0,0 +1,27 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @link http://redis.io/commands/set + * @author Daniele Alessandri + */ +class StringSet extends PrefixableCommand +{ + /** + * {@inheritdoc} + */ + public function getId() + { + return 'SET'; + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/StringSetBit.php b/vendor/predis/predis/lib/Predis/Command/StringSetBit.php new file mode 100755 index 0000000..a92b418 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/StringSetBit.php @@ -0,0 +1,27 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @link http://redis.io/commands/setbit + * @author Daniele Alessandri + */ +class StringSetBit extends PrefixableCommand +{ + /** + * {@inheritdoc} + */ + public function getId() + { + return 'SETBIT'; + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/StringSetExpire.php b/vendor/predis/predis/lib/Predis/Command/StringSetExpire.php new file mode 100755 index 0000000..c235e2b --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/StringSetExpire.php @@ -0,0 +1,27 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @link http://redis.io/commands/setex + * @author Daniele Alessandri + */ +class StringSetExpire extends PrefixableCommand +{ + /** + * {@inheritdoc} + */ + public function getId() + { + return 'SETEX'; + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/StringSetMultiple.php b/vendor/predis/predis/lib/Predis/Command/StringSetMultiple.php new file mode 100755 index 0000000..cda5157 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/StringSetMultiple.php @@ -0,0 +1,55 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @link http://redis.io/commands/mset + * @author Daniele Alessandri + */ +class StringSetMultiple extends AbstractCommand implements PrefixableCommandInterface +{ + /** + * {@inheritdoc} + */ + public function getId() + { + return 'MSET'; + } + + /** + * {@inheritdoc} + */ + protected function filterArguments(Array $arguments) + { + if (count($arguments) === 1 && is_array($arguments[0])) { + $flattenedKVs = array(); + $args = $arguments[0]; + + foreach ($args as $k => $v) { + $flattenedKVs[] = $k; + $flattenedKVs[] = $v; + } + + return $flattenedKVs; + } + + return $arguments; + } + + /** + * {@inheritdoc} + */ + public function prefixKeys($prefix) + { + PrefixHelpers::interleaved($this, $prefix); + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/StringSetMultiplePreserve.php b/vendor/predis/predis/lib/Predis/Command/StringSetMultiplePreserve.php new file mode 100755 index 0000000..961422d --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/StringSetMultiplePreserve.php @@ -0,0 +1,35 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @link http://redis.io/commands/msetnx + * @author Daniele Alessandri + */ +class StringSetMultiplePreserve extends StringSetMultiple +{ + /** + * {@inheritdoc} + */ + public function getId() + { + return 'MSETNX'; + } + + /** + * {@inheritdoc} + */ + public function parseResponse($data) + { + return (bool) $data; + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/StringSetPreserve.php b/vendor/predis/predis/lib/Predis/Command/StringSetPreserve.php new file mode 100755 index 0000000..d6e4a81 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/StringSetPreserve.php @@ -0,0 +1,35 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @link http://redis.io/commands/setnx + * @author Daniele Alessandri + */ +class StringSetPreserve extends PrefixableCommand +{ + /** + * {@inheritdoc} + */ + public function getId() + { + return 'SETNX'; + } + + /** + * {@inheritdoc} + */ + public function parseResponse($data) + { + return (bool) $data; + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/StringSetRange.php b/vendor/predis/predis/lib/Predis/Command/StringSetRange.php new file mode 100755 index 0000000..da30f32 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/StringSetRange.php @@ -0,0 +1,27 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @link http://redis.io/commands/setrange + * @author Daniele Alessandri + */ +class StringSetRange extends PrefixableCommand +{ + /** + * {@inheritdoc} + */ + public function getId() + { + return 'SETRANGE'; + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/StringStrlen.php b/vendor/predis/predis/lib/Predis/Command/StringStrlen.php new file mode 100755 index 0000000..1b839ad --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/StringStrlen.php @@ -0,0 +1,27 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @link http://redis.io/commands/strlen + * @author Daniele Alessandri + */ +class StringStrlen extends PrefixableCommand +{ + /** + * {@inheritdoc} + */ + public function getId() + { + return 'STRLEN'; + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/StringSubstr.php b/vendor/predis/predis/lib/Predis/Command/StringSubstr.php new file mode 100755 index 0000000..671fc16 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/StringSubstr.php @@ -0,0 +1,27 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @link http://redis.io/commands/substr + * @author Daniele Alessandri + */ +class StringSubstr extends PrefixableCommand +{ + /** + * {@inheritdoc} + */ + public function getId() + { + return 'SUBSTR'; + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/TransactionDiscard.php b/vendor/predis/predis/lib/Predis/Command/TransactionDiscard.php new file mode 100755 index 0000000..67010b0 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/TransactionDiscard.php @@ -0,0 +1,27 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @link http://redis.io/commands/discard + * @author Daniele Alessandri + */ +class TransactionDiscard extends AbstractCommand +{ + /** + * {@inheritdoc} + */ + public function getId() + { + return 'DISCARD'; + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/TransactionExec.php b/vendor/predis/predis/lib/Predis/Command/TransactionExec.php new file mode 100755 index 0000000..5141454 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/TransactionExec.php @@ -0,0 +1,27 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @link http://redis.io/commands/exec + * @author Daniele Alessandri + */ +class TransactionExec extends AbstractCommand +{ + /** + * {@inheritdoc} + */ + public function getId() + { + return 'EXEC'; + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/TransactionMulti.php b/vendor/predis/predis/lib/Predis/Command/TransactionMulti.php new file mode 100755 index 0000000..8f4ccf1 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/TransactionMulti.php @@ -0,0 +1,27 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @link http://redis.io/commands/multi + * @author Daniele Alessandri + */ +class TransactionMulti extends AbstractCommand +{ + /** + * {@inheritdoc} + */ + public function getId() + { + return 'MULTI'; + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/TransactionUnwatch.php b/vendor/predis/predis/lib/Predis/Command/TransactionUnwatch.php new file mode 100755 index 0000000..697e09f --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/TransactionUnwatch.php @@ -0,0 +1,35 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @link http://redis.io/commands/unwatch + * @author Daniele Alessandri + */ +class TransactionUnwatch extends AbstractCommand +{ + /** + * {@inheritdoc} + */ + public function getId() + { + return 'UNWATCH'; + } + + /** + * {@inheritdoc} + */ + public function parseResponse($data) + { + return (bool) $data; + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/TransactionWatch.php b/vendor/predis/predis/lib/Predis/Command/TransactionWatch.php new file mode 100755 index 0000000..a1dd9a2 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/TransactionWatch.php @@ -0,0 +1,55 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @link http://redis.io/commands/watch + * @author Daniele Alessandri + */ +class TransactionWatch extends AbstractCommand implements PrefixableCommandInterface +{ + /** + * {@inheritdoc} + */ + public function getId() + { + return 'WATCH'; + } + + /** + * {@inheritdoc} + */ + protected function filterArguments(Array $arguments) + { + if (isset($arguments[0]) && is_array($arguments[0])) { + return $arguments[0]; + } + + return $arguments; + } + + /** + * {@inheritdoc} + */ + public function prefixKeys($prefix) + { + PrefixHelpers::all($this, $prefix); + } + + /** + * {@inheritdoc} + */ + public function parseResponse($data) + { + return (bool) $data; + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/ZSetAdd.php b/vendor/predis/predis/lib/Predis/Command/ZSetAdd.php new file mode 100755 index 0000000..2dd86da --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/ZSetAdd.php @@ -0,0 +1,46 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @link http://redis.io/commands/zadd + * @author Daniele Alessandri + */ +class ZSetAdd extends PrefixableCommand +{ + /** + * {@inheritdoc} + */ + public function getId() + { + return 'ZADD'; + } + + /** + * {@inheritdoc} + */ + protected function filterArguments(Array $arguments) + { + if (count($arguments) === 2 && is_array($arguments[1])) { + $flattened = array($arguments[0]); + + foreach ($arguments[1] as $member => $score) { + $flattened[] = $score; + $flattened[] = $member; + } + + return $flattened; + } + + return $arguments; + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/ZSetCardinality.php b/vendor/predis/predis/lib/Predis/Command/ZSetCardinality.php new file mode 100755 index 0000000..4e4432e --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/ZSetCardinality.php @@ -0,0 +1,27 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @link http://redis.io/commands/zcard + * @author Daniele Alessandri + */ +class ZSetCardinality extends PrefixableCommand +{ + /** + * {@inheritdoc} + */ + public function getId() + { + return 'ZCARD'; + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/ZSetCount.php b/vendor/predis/predis/lib/Predis/Command/ZSetCount.php new file mode 100755 index 0000000..2d8aa9c --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/ZSetCount.php @@ -0,0 +1,27 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @link http://redis.io/commands/zcount + * @author Daniele Alessandri + */ +class ZSetCount extends PrefixableCommand +{ + /** + * {@inheritdoc} + */ + public function getId() + { + return 'ZCOUNT'; + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/ZSetIncrementBy.php b/vendor/predis/predis/lib/Predis/Command/ZSetIncrementBy.php new file mode 100755 index 0000000..a32bfab --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/ZSetIncrementBy.php @@ -0,0 +1,27 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @link http://redis.io/commands/zincrby + * @author Daniele Alessandri + */ +class ZSetIncrementBy extends PrefixableCommand +{ + /** + * {@inheritdoc} + */ + public function getId() + { + return 'ZINCRBY'; + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/ZSetIntersectionStore.php b/vendor/predis/predis/lib/Predis/Command/ZSetIntersectionStore.php new file mode 100755 index 0000000..9f6b109 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/ZSetIntersectionStore.php @@ -0,0 +1,27 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @link http://redis.io/commands/zinterstore + * @author Daniele Alessandri + */ +class ZSetIntersectionStore extends ZSetUnionStore +{ + /** + * {@inheritdoc} + */ + public function getId() + { + return 'ZINTERSTORE'; + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/ZSetRange.php b/vendor/predis/predis/lib/Predis/Command/ZSetRange.php new file mode 100755 index 0000000..a719fda --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/ZSetRange.php @@ -0,0 +1,103 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @link http://redis.io/commands/zrange + * @author Daniele Alessandri + */ +class ZSetRange extends PrefixableCommand +{ + /** + * {@inheritdoc} + */ + public function getId() + { + return 'ZRANGE'; + } + + /** + * {@inheritdoc} + */ + protected function filterArguments(Array $arguments) + { + if (count($arguments) === 4) { + $lastType = gettype($arguments[3]); + + if ($lastType === 'string' && strtoupper($arguments[3]) === 'WITHSCORES') { + // Used for compatibility with older versions + $arguments[3] = array('WITHSCORES' => true); + $lastType = 'array'; + } + + if ($lastType === 'array') { + $options = $this->prepareOptions(array_pop($arguments)); + + return array_merge($arguments, $options); + } + } + + return $arguments; + } + + /** + * Returns a list of options and modifiers compatible with Redis. + * + * @param array $options List of options. + * @return array + */ + protected function prepareOptions($options) + { + $opts = array_change_key_case($options, CASE_UPPER); + $finalizedOpts = array(); + + if (!empty($opts['WITHSCORES'])) { + $finalizedOpts[] = 'WITHSCORES'; + } + + return $finalizedOpts; + } + + /** + * Checks for the presence of the WITHSCORES modifier. + * + * @return bool + */ + protected function withScores() + { + $arguments = $this->getArguments(); + + if (count($arguments) < 4) { + return false; + } + + return strtoupper($arguments[3]) === 'WITHSCORES'; + } + + /** + * {@inheritdoc} + */ + public function parseResponse($data) + { + if ($this->withScores()) { + $result = array(); + + for ($i = 0; $i < count($data); $i++) { + $result[] = array($data[$i], $data[++$i]); + } + + return $result; + } + + return $data; + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/ZSetRangeByScore.php b/vendor/predis/predis/lib/Predis/Command/ZSetRangeByScore.php new file mode 100755 index 0000000..cfe73aa --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/ZSetRangeByScore.php @@ -0,0 +1,67 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @link http://redis.io/commands/zrangebyscore + * @author Daniele Alessandri + */ +class ZSetRangeByScore extends ZSetRange +{ + /** + * {@inheritdoc} + */ + public function getId() + { + return 'ZRANGEBYSCORE'; + } + + /** + * {@inheritdoc} + */ + protected function prepareOptions($options) + { + $opts = array_change_key_case($options, CASE_UPPER); + $finalizedOpts = array(); + + if (isset($opts['LIMIT']) && is_array($opts['LIMIT'])) { + $limit = array_change_key_case($opts['LIMIT'], CASE_UPPER); + + $finalizedOpts[] = 'LIMIT'; + $finalizedOpts[] = isset($limit['OFFSET']) ? $limit['OFFSET'] : $limit[0]; + $finalizedOpts[] = isset($limit['COUNT']) ? $limit['COUNT'] : $limit[1]; + } + + return array_merge($finalizedOpts, parent::prepareOptions($options)); + } + + /** + * {@inheritdoc} + */ + protected function withScores() + { + $arguments = $this->getArguments(); + + for ($i = 3; $i < count($arguments); $i++) { + switch (strtoupper($arguments[$i])) { + case 'WITHSCORES': + return true; + + case 'LIMIT': + $i += 2; + break; + } + } + + return false; + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/ZSetRank.php b/vendor/predis/predis/lib/Predis/Command/ZSetRank.php new file mode 100755 index 0000000..41c2ae2 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/ZSetRank.php @@ -0,0 +1,27 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @link http://redis.io/commands/zrank + * @author Daniele Alessandri + */ +class ZSetRank extends PrefixableCommand +{ + /** + * {@inheritdoc} + */ + public function getId() + { + return 'ZRANK'; + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/ZSetRemove.php b/vendor/predis/predis/lib/Predis/Command/ZSetRemove.php new file mode 100755 index 0000000..ae7208d --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/ZSetRemove.php @@ -0,0 +1,35 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @link http://redis.io/commands/zrem + * @author Daniele Alessandri + */ +class ZSetRemove extends PrefixableCommand +{ + /** + * {@inheritdoc} + */ + public function getId() + { + return 'ZREM'; + } + + /** + * {@inheritdoc} + */ + protected function filterArguments(Array $arguments) + { + return self::normalizeVariadic($arguments); + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/ZSetRemoveRangeByRank.php b/vendor/predis/predis/lib/Predis/Command/ZSetRemoveRangeByRank.php new file mode 100755 index 0000000..45b9028 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/ZSetRemoveRangeByRank.php @@ -0,0 +1,27 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @link http://redis.io/commands/zremrangebyrank + * @author Daniele Alessandri + */ +class ZSetRemoveRangeByRank extends PrefixableCommand +{ + /** + * {@inheritdoc} + */ + public function getId() + { + return 'ZREMRANGEBYRANK'; + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/ZSetRemoveRangeByScore.php b/vendor/predis/predis/lib/Predis/Command/ZSetRemoveRangeByScore.php new file mode 100755 index 0000000..a2b3ad8 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/ZSetRemoveRangeByScore.php @@ -0,0 +1,27 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @link http://redis.io/commands/zremrangebyscore + * @author Daniele Alessandri + */ +class ZSetRemoveRangeByScore extends PrefixableCommand +{ + /** + * {@inheritdoc} + */ + public function getId() + { + return 'ZREMRANGEBYSCORE'; + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/ZSetReverseRange.php b/vendor/predis/predis/lib/Predis/Command/ZSetReverseRange.php new file mode 100755 index 0000000..e7344e0 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/ZSetReverseRange.php @@ -0,0 +1,27 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @link http://redis.io/commands/zrevrange + * @author Daniele Alessandri + */ +class ZSetReverseRange extends ZSetRange +{ + /** + * {@inheritdoc} + */ + public function getId() + { + return 'ZREVRANGE'; + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/ZSetReverseRangeByScore.php b/vendor/predis/predis/lib/Predis/Command/ZSetReverseRangeByScore.php new file mode 100755 index 0000000..cded7c1 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/ZSetReverseRangeByScore.php @@ -0,0 +1,27 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @link http://redis.io/commands/zrevrangebyscore + * @author Daniele Alessandri + */ +class ZSetReverseRangeByScore extends ZSetRangeByScore +{ + /** + * {@inheritdoc} + */ + public function getId() + { + return 'ZREVRANGEBYSCORE'; + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/ZSetReverseRank.php b/vendor/predis/predis/lib/Predis/Command/ZSetReverseRank.php new file mode 100755 index 0000000..feb1048 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/ZSetReverseRank.php @@ -0,0 +1,27 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @link http://redis.io/commands/zrevrank + * @author Daniele Alessandri + */ +class ZSetReverseRank extends PrefixableCommand +{ + /** + * {@inheritdoc} + */ + public function getId() + { + return 'ZREVRANK'; + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/ZSetScan.php b/vendor/predis/predis/lib/Predis/Command/ZSetScan.php new file mode 100755 index 0000000..41d22e5 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/ZSetScan.php @@ -0,0 +1,85 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @link http://redis.io/commands/zscan + * @author Daniele Alessandri + */ +class ZSetScan extends PrefixableCommand +{ + /** + * {@inheritdoc} + */ + public function getId() + { + return 'ZSCAN'; + } + + /** + * {@inheritdoc} + */ + protected function filterArguments(Array $arguments) + { + if (count($arguments) === 3 && is_array($arguments[2])) { + $options = $this->prepareOptions(array_pop($arguments)); + $arguments = array_merge($arguments, $options); + } + + return $arguments; + } + + /** + * Returns a list of options and modifiers compatible with Redis. + * + * @param array $options List of options. + * @return array + */ + protected function prepareOptions($options) + { + $options = array_change_key_case($options, CASE_UPPER); + $normalized = array(); + + if (!empty($options['MATCH'])) { + $normalized[] = 'MATCH'; + $normalized[] = $options['MATCH']; + } + + if (!empty($options['COUNT'])) { + $normalized[] = 'COUNT'; + $normalized[] = $options['COUNT']; + } + + return $normalized; + } + + /** + * {@inheritdoc} + */ + public function parseResponse($data) + { + if (is_array($data)) { + $data[0] = (int) $data[0]; + + $members = $data[1]; + $result = array(); + + for ($i = 0; $i < count($members); $i++) { + $result[] = array($members[$i], (float) $members[++$i]); + } + + $data[1] = $result; + } + + return $data; + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/ZSetScore.php b/vendor/predis/predis/lib/Predis/Command/ZSetScore.php new file mode 100755 index 0000000..8455e4e --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/ZSetScore.php @@ -0,0 +1,27 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @link http://redis.io/commands/zscore + * @author Daniele Alessandri + */ +class ZSetScore extends PrefixableCommand +{ + /** + * {@inheritdoc} + */ + public function getId() + { + return 'ZSCORE'; + } +} diff --git a/vendor/predis/predis/lib/Predis/Command/ZSetUnionStore.php b/vendor/predis/predis/lib/Predis/Command/ZSetUnionStore.php new file mode 100755 index 0000000..725d2b0 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Command/ZSetUnionStore.php @@ -0,0 +1,93 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @link http://redis.io/commands/zunionstore + * @author Daniele Alessandri + */ +class ZSetUnionStore extends PrefixableCommand +{ + /** + * {@inheritdoc} + */ + public function getId() + { + return 'ZUNIONSTORE'; + } + + /** + * {@inheritdoc} + */ + protected function filterArguments(Array $arguments) + { + $options = array(); + $argc = count($arguments); + + if ($argc > 2 && is_array($arguments[$argc - 1])) { + $options = $this->prepareOptions(array_pop($arguments)); + } + + if (is_array($arguments[1])) { + $arguments = array_merge( + array($arguments[0], count($arguments[1])), + $arguments[1] + ); + } + + return array_merge($arguments, $options); + } + + /** + * Returns a list of options and modifiers compatible with Redis. + * + * @param array $options List of options. + * @return array + */ + private function prepareOptions($options) + { + $opts = array_change_key_case($options, CASE_UPPER); + $finalizedOpts = array(); + + if (isset($opts['WEIGHTS']) && is_array($opts['WEIGHTS'])) { + $finalizedOpts[] = 'WEIGHTS'; + + foreach ($opts['WEIGHTS'] as $weight) { + $finalizedOpts[] = $weight; + } + } + + if (isset($opts['AGGREGATE'])) { + $finalizedOpts[] = 'AGGREGATE'; + $finalizedOpts[] = $opts['AGGREGATE']; + } + + return $finalizedOpts; + } + + /** + * {@inheritdoc} + */ + public function prefixKeys($prefix) + { + if ($arguments = $this->getArguments()) { + $arguments[0] = "$prefix{$arguments[0]}"; + $length = ((int) $arguments[1]) + 2; + + for ($i = 2; $i < $length; $i++) { + $arguments[$i] = "$prefix{$arguments[$i]}"; + } + + $this->setRawArguments($arguments); + } + } +} diff --git a/vendor/predis/predis/lib/Predis/CommunicationException.php b/vendor/predis/predis/lib/Predis/CommunicationException.php new file mode 100755 index 0000000..a44b27d --- /dev/null +++ b/vendor/predis/predis/lib/Predis/CommunicationException.php @@ -0,0 +1,76 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis; + +use Predis\Connection\SingleConnectionInterface; + +/** + * Base exception class for network-related errors. + * + * @author Daniele Alessandri + */ +abstract class CommunicationException extends PredisException +{ + private $connection; + + /** + * @param SingleConnectionInterface $connection Connection that generated the exception. + * @param string $message Error message. + * @param int $code Error code. + * @param \Exception $innerException Inner exception for wrapping the original error. + */ + public function __construct( + SingleConnectionInterface $connection, $message = null, $code = null, \Exception $innerException = null + ) { + parent::__construct($message, $code, $innerException); + $this->connection = $connection; + } + + /** + * Gets the connection that generated the exception. + * + * @return SingleConnectionInterface + */ + public function getConnection() + { + return $this->connection; + } + + /** + * Indicates if the receiver should reset the underlying connection. + * + * @return bool + */ + public function shouldResetConnection() + { + return true; + } + + /** + * Offers a generic and reusable method to handle exceptions generated by + * a connection object. + * + * @param CommunicationException $exception Exception. + */ + public static function handle(CommunicationException $exception) + { + if ($exception->shouldResetConnection()) { + $connection = $exception->getConnection(); + + if ($connection->isConnected()) { + $connection->disconnect(); + } + } + + throw $exception; + } +} diff --git a/vendor/predis/predis/lib/Predis/Connection/AbstractConnection.php b/vendor/predis/predis/lib/Predis/Connection/AbstractConnection.php new file mode 100755 index 0000000..8ebf050 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Connection/AbstractConnection.php @@ -0,0 +1,227 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Connection; + +use Predis\ClientException; +use Predis\CommunicationException; +use Predis\NotSupportedException; +use Predis\Command\CommandInterface; +use Predis\Protocol\ProtocolException; + +/** + * Base class with the common logic used by connection classes to communicate with Redis. + * + * @author Daniele Alessandri + */ +abstract class AbstractConnection implements SingleConnectionInterface +{ + private $resource; + private $cachedId; + + protected $parameters; + protected $initCmds = array(); + + /** + * @param ConnectionParametersInterface $parameters Parameters used to initialize the connection. + */ + public function __construct(ConnectionParametersInterface $parameters) + { + $this->parameters = $this->checkParameters($parameters); + } + + /** + * Disconnects from the server and destroys the underlying resource when + * PHP's garbage collector kicks in. + */ + public function __destruct() + { + $this->disconnect(); + } + + /** + * Checks some of the parameters used to initialize the connection. + * + * @param ConnectionParametersInterface $parameters Initialization parameters for the connection. + * @return ConnectionParametersInterface + */ + protected function checkParameters(ConnectionParametersInterface $parameters) + { + switch ($parameters->scheme) { + case 'unix': + if (!isset($parameters->path)) { + throw new \InvalidArgumentException('Missing UNIX domain socket path'); + } + + case 'tcp': + return $parameters; + + default: + throw new \InvalidArgumentException("Invalid scheme: {$parameters->scheme}"); + } + } + + /** + * Creates the underlying resource used to communicate with Redis. + * + * @return mixed + */ + abstract protected function createResource(); + + /** + * {@inheritdoc} + */ + public function isConnected() + { + return isset($this->resource); + } + + /** + * {@inheritdoc} + */ + public function connect() + { + if ($this->isConnected()) { + throw new ClientException('Connection already estabilished'); + } + + $this->resource = $this->createResource(); + } + + /** + * {@inheritdoc} + */ + public function disconnect() + { + unset($this->resource); + } + + /** + * {@inheritdoc} + */ + public function pushInitCommand(CommandInterface $command) + { + $this->initCmds[] = $command; + } + + /** + * {@inheritdoc} + */ + public function executeCommand(CommandInterface $command) + { + $this->writeCommand($command); + + return $this->readResponse($command); + } + + /** + * {@inheritdoc} + */ + public function readResponse(CommandInterface $command) + { + return $this->read(); + } + + /** + * Helper method to handle connection errors. + * + * @param string $message Error message. + * @param int $code Error code. + */ + protected function onConnectionError($message, $code = null) + { + CommunicationException::handle(new ConnectionException($this, "$message [{$this->parameters->scheme}://{$this->getIdentifier()}]", $code)); + } + + /** + * Helper method to handle protocol errors. + * + * @param string $message Error message. + */ + protected function onProtocolError($message) + { + CommunicationException::handle(new ProtocolException($this, "$message [{$this->parameters->scheme}://{$this->getIdentifier()}]")); + } + + /** + * Helper method to handle not supported connection parameters. + * + * @param string $option Name of the option. + * @param mixed $parameters Parameters used to initialize the connection. + */ + protected function onInvalidOption($option, $parameters = null) + { + $class = get_called_class(); + $message = "Invalid option for connection $class: $option"; + + if (isset($parameters)) { + $message .= sprintf(' [%s => %s]', $option, $parameters->{$option}); + } + + throw new NotSupportedException($message); + } + + /** + * {@inheritdoc} + */ + public function getResource() + { + if (isset($this->resource)) { + return $this->resource; + } + + $this->connect(); + + return $this->resource; + } + + /** + * {@inheritdoc} + */ + public function getParameters() + { + return $this->parameters; + } + + /** + * Gets an identifier for the connection. + * + * @return string + */ + protected function getIdentifier() + { + if ($this->parameters->scheme === 'unix') { + return $this->parameters->path; + } + + return "{$this->parameters->host}:{$this->parameters->port}"; + } + + /** + * {@inheritdoc} + */ + public function __toString() + { + if (!isset($this->cachedId)) { + $this->cachedId = $this->getIdentifier(); + } + + return $this->cachedId; + } + + /** + * {@inheritdoc} + */ + public function __sleep() + { + return array('parameters', 'initCmds'); + } +} diff --git a/vendor/predis/predis/lib/Predis/Connection/AggregatedConnectionInterface.php b/vendor/predis/predis/lib/Predis/Connection/AggregatedConnectionInterface.php new file mode 100755 index 0000000..0b2c156 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Connection/AggregatedConnectionInterface.php @@ -0,0 +1,55 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Connection; + +use Predis\Command\CommandInterface; + +/** + * Defines a virtual connection composed by multiple connection objects. + * + * @author Daniele Alessandri + */ +interface AggregatedConnectionInterface extends ConnectionInterface +{ + /** + * Adds a connection instance to the aggregated connection. + * + * @param SingleConnectionInterface $connection Instance of a connection. + */ + public function add(SingleConnectionInterface $connection); + + /** + * Removes the specified connection instance from the aggregated + * connection. + * + * @param SingleConnectionInterface $connection Instance of a connection. + * @return bool Returns true if the connection was in the pool. + */ + public function remove(SingleConnectionInterface $connection); + + /** + * Gets the actual connection instance in charge of the specified command. + * + * @param CommandInterface $command Instance of a Redis command. + * @return SingleConnectionInterface + */ + public function getConnection(CommandInterface $command); + + /** + * Retrieves a connection instance from the aggregated connection + * using an alias. + * + * @param string $connectionId Alias of a connection + * @return SingleConnectionInterface + */ + public function getConnectionById($connectionId); +} diff --git a/vendor/predis/predis/lib/Predis/Connection/ClusterConnectionInterface.php b/vendor/predis/predis/lib/Predis/Connection/ClusterConnectionInterface.php new file mode 100755 index 0000000..956ef2c --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Connection/ClusterConnectionInterface.php @@ -0,0 +1,22 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Connection; + +/** + * Defines a cluster of Redis servers formed by aggregating multiple + * connection objects. + * + * @author Daniele Alessandri + */ +interface ClusterConnectionInterface extends AggregatedConnectionInterface +{ +} diff --git a/vendor/predis/predis/lib/Predis/Connection/ComposableConnectionInterface.php b/vendor/predis/predis/lib/Predis/Connection/ComposableConnectionInterface.php new file mode 100755 index 0000000..8b63536 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Connection/ComposableConnectionInterface.php @@ -0,0 +1,57 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Connection; + +use Predis\Protocol\ProtocolInterface; + +/** + * Defines a connection object used to communicate with a single Redis server + * that leverages an external protocol processor to handle pluggable protocol + * handlers. + * + * @author Daniele Alessandri + */ +interface ComposableConnectionInterface extends SingleConnectionInterface +{ + /** + * Sets the protocol processor used by the connection. + * + * @param ProtocolInterface $protocol Protocol processor. + */ + public function setProtocol(ProtocolInterface $protocol); + + /** + * Gets the protocol processor used by the connection. + */ + public function getProtocol(); + + /** + * Writes a buffer that contains a serialized Redis command. + * + * @param string $buffer Serialized Redis command. + */ + public function writeBytes($buffer); + + /** + * Reads a specified number of bytes from the connection. + * + * @param string + */ + public function readBytes($length); + + /** + * Reads a line from the connection. + * + * @param string + */ + public function readLine(); +} diff --git a/vendor/predis/predis/lib/Predis/Connection/ComposableStreamConnection.php b/vendor/predis/predis/lib/Predis/Connection/ComposableStreamConnection.php new file mode 100755 index 0000000..0c86302 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Connection/ComposableStreamConnection.php @@ -0,0 +1,135 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Connection; + +use Predis\Command\CommandInterface; +use Predis\Protocol\ProtocolInterface; +use Predis\Protocol\Text\TextProtocol; + +/** + * Connection abstraction to Redis servers based on PHP's stream that uses an + * external protocol processor defining the protocol used for the communication. + * + * @author Daniele Alessandri + */ +class ComposableStreamConnection extends StreamConnection implements ComposableConnectionInterface +{ + private $protocol; + + /** + * @param ConnectionParametersInterface $parameters Parameters used to initialize the connection. + * @param ProtocolInterface $protocol A protocol processor. + */ + public function __construct(ConnectionParametersInterface $parameters, ProtocolInterface $protocol = null) + { + $this->parameters = $this->checkParameters($parameters); + $this->protocol = $protocol ?: new TextProtocol(); + } + + /** + * {@inheritdoc} + */ + public function setProtocol(ProtocolInterface $protocol) + { + if ($protocol === null) { + throw new \InvalidArgumentException("The protocol instance cannot be a null value"); + } + + $this->protocol = $protocol; + } + + /** + * {@inheritdoc} + */ + public function getProtocol() + { + return $this->protocol; + } + + /** + * {@inheritdoc} + */ + public function writeBytes($buffer) + { + parent::writeBytes($buffer); + } + + /** + * {@inheritdoc} + */ + public function readBytes($length) + { + if ($length <= 0) { + throw new \InvalidArgumentException('Length parameter must be greater than 0'); + } + + $value = ''; + $socket = $this->getResource(); + + do { + $chunk = fread($socket, $length); + + if ($chunk === false || $chunk === '') { + $this->onConnectionError('Error while reading bytes from the server'); + } + + $value .= $chunk; + } while (($length -= strlen($chunk)) > 0); + + return $value; + } + + /** + * {@inheritdoc} + */ + public function readLine() + { + $value = ''; + $socket = $this->getResource(); + + do { + $chunk = fgets($socket); + + if ($chunk === false || $chunk === '') { + $this->onConnectionError('Error while reading line from the server'); + } + + $value .= $chunk; + } while (substr($value, -2) !== "\r\n"); + + return substr($value, 0, -2); + } + + /** + * {@inheritdoc} + */ + public function writeCommand(CommandInterface $command) + { + $this->protocol->write($this, $command); + } + + /** + * {@inheritdoc} + */ + public function read() + { + return $this->protocol->read($this); + } + + /** + * {@inheritdoc} + */ + public function __sleep() + { + return array_diff(array_merge(parent::__sleep(), array('protocol')), array('mbiterable')); + } +} diff --git a/vendor/predis/predis/lib/Predis/Connection/ConnectionException.php b/vendor/predis/predis/lib/Predis/Connection/ConnectionException.php new file mode 100755 index 0000000..ef2e9d7 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Connection/ConnectionException.php @@ -0,0 +1,23 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Connection; + +use Predis\CommunicationException; + +/** + * Exception class that identifies connection-related errors. + * + * @author Daniele Alessandri + */ +class ConnectionException extends CommunicationException +{ +} diff --git a/vendor/predis/predis/lib/Predis/Connection/ConnectionFactory.php b/vendor/predis/predis/lib/Predis/Connection/ConnectionFactory.php new file mode 100755 index 0000000..1023adb --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Connection/ConnectionFactory.php @@ -0,0 +1,180 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Connection; + +use Predis\Profile\ServerProfileInterface; + +/** + * Provides a default factory for Redis connections that maps URI schemes + * to connection classes implementing Predis\Connection\SingleConnectionInterface. + * + * @author Daniele Alessandri + */ +class ConnectionFactory implements ConnectionFactoryInterface +{ + protected $schemes; + protected $profile; + + /** + * Initializes a new instance of the default connection factory class used by Predis. + * + * @param ServerProfileInterface $profile Server profile used to initialize new connections. + */ + public function __construct(ServerProfileInterface $profile = null) + { + $this->schemes = $this->getDefaultSchemes(); + $this->profile = $profile; + } + + /** + * Returns a named array that maps URI schemes to connection classes. + * + * @return array Map of URI schemes and connection classes. + */ + protected function getDefaultSchemes() + { + return array( + 'tcp' => 'Predis\Connection\StreamConnection', + 'unix' => 'Predis\Connection\StreamConnection', + 'http' => 'Predis\Connection\WebdisConnection', + ); + } + + /** + * Checks if the provided argument represents a valid connection class + * implementing Predis\Connection\SingleConnectionInterface. Optionally, + * callable objects are used for lazy initialization of connection objects. + * + * @param mixed $initializer FQN of a connection class or a callable for lazy initialization. + * @return mixed + */ + protected function checkInitializer($initializer) + { + if (is_callable($initializer)) { + return $initializer; + } + + $initializerReflection = new \ReflectionClass($initializer); + + if (!$initializerReflection->isSubclassOf('Predis\Connection\SingleConnectionInterface')) { + throw new \InvalidArgumentException( + 'A connection initializer must be a valid connection class or a callable object' + ); + } + + return $initializer; + } + + /** + * {@inheritdoc} + */ + public function define($scheme, $initializer) + { + $this->schemes[$scheme] = $this->checkInitializer($initializer); + } + + /** + * {@inheritdoc} + */ + public function undefine($scheme) + { + unset($this->schemes[$scheme]); + } + + /** + * {@inheritdoc} + */ + public function create($parameters) + { + if (!$parameters instanceof ConnectionParametersInterface) { + $parameters = new ConnectionParameters($parameters ?: array()); + } + + $scheme = $parameters->scheme; + + if (!isset($this->schemes[$scheme])) { + throw new \InvalidArgumentException("Unknown connection scheme: $scheme"); + } + + $initializer = $this->schemes[$scheme]; + + if (is_callable($initializer)) { + $connection = call_user_func($initializer, $parameters, $this); + } else { + $connection = new $initializer($parameters); + $this->prepareConnection($connection); + } + + if (!$connection instanceof SingleConnectionInterface) { + throw new \InvalidArgumentException( + 'Objects returned by connection initializers must implement ' . + 'Predis\Connection\SingleConnectionInterface' + ); + } + + return $connection; + } + + /** + * {@inheritdoc} + */ + public function createAggregated(AggregatedConnectionInterface $connection, Array $parameters) + { + foreach ($parameters as $node) { + $connection->add($node instanceof SingleConnectionInterface ? $node : $this->create($node)); + } + + return $connection; + } + + /** + * Prepares a connection object after its initialization. + * + * @param SingleConnectionInterface $connection Instance of a connection object. + */ + protected function prepareConnection(SingleConnectionInterface $connection) + { + if (isset($this->profile)) { + $parameters = $connection->getParameters(); + + if (isset($parameters->password)) { + $command = $this->profile->createCommand('auth', array($parameters->password)); + $connection->pushInitCommand($command); + } + + if (isset($parameters->database)) { + $command = $this->profile->createCommand('select', array($parameters->database)); + $connection->pushInitCommand($command); + } + } + } + + /** + * Sets the server profile used to create initialization commands for connections. + * + * @param ServerProfileInterface $profile Server profile instance. + */ + public function setProfile(ServerProfileInterface $profile) + { + $this->profile = $profile; + } + + /** + * Returns the server profile used to create initialization commands for connections. + * + * @return ServerProfileInterface + */ + public function getProfile() + { + return $this->profile; + } +} diff --git a/vendor/predis/predis/lib/Predis/Connection/ConnectionFactoryInterface.php b/vendor/predis/predis/lib/Predis/Connection/ConnectionFactoryInterface.php new file mode 100755 index 0000000..8bade2b --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Connection/ConnectionFactoryInterface.php @@ -0,0 +1,53 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Connection; + +/** + * Interface that must be implemented by classes that provide their own mechanism + * to create and initialize new instances of Predis\Connection\SingleConnectionInterface. + * + * @author Daniele Alessandri + */ +interface ConnectionFactoryInterface +{ + /** + * Defines or overrides the connection class identified by a scheme prefix. + * + * @param string $scheme URI scheme identifying the connection class. + * @param mixed $initializer FQN of a connection class or a callable object for lazy initialization. + */ + public function define($scheme, $initializer); + + /** + * Undefines the connection identified by a scheme prefix. + * + * @param string $scheme Parameters for the connection. + */ + public function undefine($scheme); + + /** + * Creates a new connection object. + * + * @param mixed $parameters Parameters for the connection. + * @return SingleConnectionInterface + */ + public function create($parameters); + + /** + * Prepares an aggregation of connection objects. + * + * @param AggregatedConnectionInterface $cluster Instance of an aggregated connection class. + * @param array $parameters List of parameters for each connection object. + * @return AggregatedConnectionInterface + */ + public function createAggregated(AggregatedConnectionInterface $cluster, Array $parameters); +} diff --git a/vendor/predis/predis/lib/Predis/Connection/ConnectionInterface.php b/vendor/predis/predis/lib/Predis/Connection/ConnectionInterface.php new file mode 100755 index 0000000..1f51b0a --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Connection/ConnectionInterface.php @@ -0,0 +1,63 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Connection; + +use Predis\Command\CommandInterface; + +/** + * Defines a connection object used to communicate with one or multiple + * Redis servers. + * + * @author Daniele Alessandri + */ +interface ConnectionInterface +{ + /** + * Opens the connection. + */ + public function connect(); + + /** + * Closes the connection. + */ + public function disconnect(); + + /** + * Returns if the connection is open. + * + * @return bool + */ + public function isConnected(); + + /** + * Write a Redis command on the connection. + * + * @param CommandInterface $command Instance of a Redis command. + */ + public function writeCommand(CommandInterface $command); + + /** + * Reads the reply for a Redis command from the connection. + * + * @param CommandInterface $command Instance of a Redis command. + * @return mixed + */ + public function readResponse(CommandInterface $command); + + /** + * Writes a Redis command to the connection and reads back the reply. + * + * @param CommandInterface $command Instance of a Redis command. + * @return mixed + */ + public function executeCommand(CommandInterface $command); +} diff --git a/vendor/predis/predis/lib/Predis/Connection/ConnectionParameters.php b/vendor/predis/predis/lib/Predis/Connection/ConnectionParameters.php new file mode 100755 index 0000000..b91d3af --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Connection/ConnectionParameters.php @@ -0,0 +1,183 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Connection; + +use Predis\ClientException; + +/** + * Handles parsing and validation of connection parameters. + * + * @author Daniele Alessandri + */ +class ConnectionParameters implements ConnectionParametersInterface +{ + private $parameters; + + private static $defaults = array( + 'scheme' => 'tcp', + 'host' => '127.0.0.1', + 'port' => 6379, + 'timeout' => 5.0, + ); + + /** + * @param string|array $parameters Connection parameters in the form of an URI string or a named array. + */ + public function __construct($parameters = array()) + { + if (!is_array($parameters)) { + $parameters = self::parseURI($parameters); + } + + $this->parameters = $this->filter($parameters) + $this->getDefaults(); + } + + /** + * Returns some default parameters with their values. + * + * @return array + */ + protected function getDefaults() + { + return self::$defaults; + } + + /** + * Returns cast functions for user-supplied parameter values. + * + * @return array + */ + protected function getValueCasters() + { + return array( + 'port' => 'self::castInteger', + 'async_connect' => 'self::castBoolean', + 'persistent' => 'self::castBoolean', + 'timeout' => 'self::castFloat', + 'read_write_timeout' => 'self::castFloat', + 'iterable_multibulk' => 'self::castBoolean', + ); + } + + /** + * Validates value as boolean. + * + * @param mixed $value Input value. + * @return bool + */ + private static function castBoolean($value) + { + return (bool) $value; + } + + /** + * Validates value as float. + * + * @param mixed $value Input value. + * @return float + */ + private static function castFloat($value) + { + return (float) $value; + } + + /** + * Validates value as integer. + * + * @param mixed $value Input value. + * @return int + */ + private static function castInteger($value) + { + return (int) $value; + } + + /** + * Parses an URI string and returns an array of connection parameters. + * + * @param string $uri Connection string. + * @return array + */ + public static function parseURI($uri) + { + if (stripos($uri, 'unix') === 0) { + // Hack to support URIs for UNIX sockets with minimal effort. + $uri = str_ireplace('unix:///', 'unix://localhost/', $uri); + } + + if (!($parsed = @parse_url($uri)) || !isset($parsed['host'])) { + throw new ClientException("Invalid URI: $uri"); + } + + if (isset($parsed['query'])) { + parse_str($parsed['query'], $queryarray); + unset($parsed['query']); + + $parsed = array_merge($parsed, $queryarray); + } + + return $parsed; + } + + /** + * Validates and converts each value of the connection parameters array. + * + * @param array $parameters Connection parameters. + * @return array + */ + private function filter(Array $parameters) + { + if ($parameters) { + $casters = array_intersect_key($this->getValueCasters(), $parameters); + + foreach ($casters as $parameter => $caster) { + $parameters[$parameter] = call_user_func($caster, $parameters[$parameter]); + } + } + + return $parameters; + } + + /** + * {@inheritdoc} + */ + public function __get($parameter) + { + if (isset($this->{$parameter})) { + return $this->parameters[$parameter]; + } + } + + /** + * {@inheritdoc} + */ + public function __isset($parameter) + { + return isset($this->parameters[$parameter]); + } + + /** + * {@inheritdoc} + */ + public function toArray() + { + return $this->parameters; + } + + /** + * {@inheritdoc} + */ + public function __sleep() + { + return array('parameters'); + } +} diff --git a/vendor/predis/predis/lib/Predis/Connection/ConnectionParametersInterface.php b/vendor/predis/predis/lib/Predis/Connection/ConnectionParametersInterface.php new file mode 100755 index 0000000..3728217 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Connection/ConnectionParametersInterface.php @@ -0,0 +1,44 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Connection; + +/** + * Interface that must be implemented by classes that provide their own mechanism + * to parse and handle connection parameters. + * + * @author Daniele Alessandri + */ +interface ConnectionParametersInterface +{ + /** + * Checks if the specified parameters is set. + * + * @param string $parameter Name of the parameter. + * @return bool + */ + public function __isset($parameter); + + /** + * Returns the value of the specified parameter. + * + * @param string $parameter Name of the parameter. + * @return mixed + */ + public function __get($parameter); + + /** + * Returns an array representation of the connection parameters. + * + * @return array + */ + public function toArray(); +} diff --git a/vendor/predis/predis/lib/Predis/Connection/MasterSlaveReplication.php b/vendor/predis/predis/lib/Predis/Connection/MasterSlaveReplication.php new file mode 100755 index 0000000..91c8de4 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Connection/MasterSlaveReplication.php @@ -0,0 +1,261 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Connection; + +use Predis\Command\CommandInterface; +use Predis\Replication\ReplicationStrategy; + +/** + * Aggregated connection class used by to handle replication with a + * group of servers in a master/slave configuration. + * + * @author Daniele Alessandri + */ +class MasterSlaveReplication implements ReplicationConnectionInterface +{ + protected $strategy; + protected $master; + protected $slaves; + protected $current; + + /** + * + */ + public function __construct(ReplicationStrategy $strategy = null) + { + $this->slaves = array(); + $this->strategy = $strategy ?: new ReplicationStrategy(); + } + + /** + * Checks if one master and at least one slave have been defined. + */ + protected function check() + { + if (!isset($this->master) || !$this->slaves) { + throw new \RuntimeException('Replication needs a master and at least one slave.'); + } + } + + /** + * Resets the connection state. + */ + protected function reset() + { + $this->current = null; + } + + /** + * {@inheritdoc} + */ + public function add(SingleConnectionInterface $connection) + { + $alias = $connection->getParameters()->alias; + + if ($alias === 'master') { + $this->master = $connection; + } else { + $this->slaves[$alias ?: count($this->slaves)] = $connection; + } + + $this->reset(); + } + + /** + * {@inheritdoc} + */ + public function remove(SingleConnectionInterface $connection) + { + if ($connection->getParameters()->alias === 'master') { + $this->master = null; + $this->reset(); + + return true; + } else { + if (($id = array_search($connection, $this->slaves, true)) !== false) { + unset($this->slaves[$id]); + $this->reset(); + + return true; + } + } + + return false; + } + + /** + * {@inheritdoc} + */ + public function getConnection(CommandInterface $command) + { + if ($this->current === null) { + $this->check(); + $this->current = $this->strategy->isReadOperation($command) ? $this->pickSlave() : $this->master; + + return $this->current; + } + + if ($this->current === $this->master) { + return $this->current; + } + + if (!$this->strategy->isReadOperation($command)) { + $this->current = $this->master; + } + + return $this->current; + } + + /** + * {@inheritdoc} + */ + public function getConnectionById($connectionId) + { + if ($connectionId === 'master') { + return $this->master; + } + + if (isset($this->slaves[$connectionId])) { + return $this->slaves[$connectionId]; + } + + return null; + } + + /** + * {@inheritdoc} + */ + public function switchTo($connection) + { + $this->check(); + + if (!$connection instanceof SingleConnectionInterface) { + $connection = $this->getConnectionById($connection); + } + if ($connection !== $this->master && !in_array($connection, $this->slaves, true)) { + throw new \InvalidArgumentException('The specified connection is not valid.'); + } + + $this->current = $connection; + } + + /** + * {@inheritdoc} + */ + public function getCurrent() + { + return $this->current; + } + + /** + * {@inheritdoc} + */ + public function getMaster() + { + return $this->master; + } + + /** + * {@inheritdoc} + */ + public function getSlaves() + { + return array_values($this->slaves); + } + + /** + * Returns the underlying replication strategy. + * + * @return ReplicationStrategy + */ + public function getReplicationStrategy() + { + return $this->strategy; + } + + /** + * Returns a random slave. + * + * @return SingleConnectionInterface + */ + protected function pickSlave() + { + return $this->slaves[array_rand($this->slaves)]; + } + + /** + * {@inheritdoc} + */ + public function isConnected() + { + return $this->current ? $this->current->isConnected() : false; + } + + /** + * {@inheritdoc} + */ + public function connect() + { + if ($this->current === null) { + $this->check(); + $this->current = $this->pickSlave(); + } + + $this->current->connect(); + } + + /** + * {@inheritdoc} + */ + public function disconnect() + { + if ($this->master) { + $this->master->disconnect(); + } + + foreach ($this->slaves as $connection) { + $connection->disconnect(); + } + } + + /** + * {@inheritdoc} + */ + public function writeCommand(CommandInterface $command) + { + $this->getConnection($command)->writeCommand($command); + } + + /** + * {@inheritdoc} + */ + public function readResponse(CommandInterface $command) + { + return $this->getConnection($command)->readResponse($command); + } + + /** + * {@inheritdoc} + */ + public function executeCommand(CommandInterface $command) + { + return $this->getConnection($command)->executeCommand($command); + } + + /** + * {@inheritdoc} + */ + public function __sleep() + { + return array('master', 'slaves', 'strategy'); + } +} diff --git a/vendor/predis/predis/lib/Predis/Connection/PhpiredisConnection.php b/vendor/predis/predis/lib/Predis/Connection/PhpiredisConnection.php new file mode 100755 index 0000000..c376548 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Connection/PhpiredisConnection.php @@ -0,0 +1,393 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Connection; + +use Predis\NotSupportedException; +use Predis\ResponseError; +use Predis\ResponseQueued; +use Predis\Command\CommandInterface; + +/** + * This class provides the implementation of a Predis connection that uses the + * PHP socket extension for network communication and wraps the phpiredis C + * extension (PHP bindings for hiredis) to parse the Redis protocol. Everything + * is highly experimental (even the very same phpiredis since it is quite new), + * so use it at your own risk. + * + * This class is mainly intended to provide an optional low-overhead alternative + * for processing replies from Redis compared to the standard pure-PHP classes. + * Differences in speed when dealing with short inline replies are practically + * nonexistent, the actual speed boost is for long multibulk replies when this + * protocol processor can parse and return replies very fast. + * + * For instructions on how to build and install the phpiredis extension, please + * consult the repository of the project. + * + * The connection parameters supported by this class are: + * + * - scheme: it can be either 'tcp' or 'unix'. + * - host: hostname or IP address of the server. + * - port: TCP port of the server. + * - path: path of a UNIX domain socket when scheme is 'unix'. + * - timeout: timeout to perform the connection. + * - read_write_timeout: timeout of read / write operations. + * + * @link http://github.com/nrk/phpiredis + * @author Daniele Alessandri + */ +class PhpiredisConnection extends AbstractConnection +{ + const ERR_MSG_EXTENSION = 'The %s extension must be loaded in order to be able to use this connection class'; + + private $reader; + + /** + * {@inheritdoc} + */ + public function __construct(ConnectionParametersInterface $parameters) + { + $this->checkExtensions(); + $this->initializeReader(); + + parent::__construct($parameters); + } + + /** + * Disconnects from the server and destroys the underlying resource and the + * protocol reader resource when PHP's garbage collector kicks in. + */ + public function __destruct() + { + phpiredis_reader_destroy($this->reader); + + parent::__destruct(); + } + + /** + * Checks if the socket and phpiredis extensions are loaded in PHP. + */ + private function checkExtensions() + { + if (!function_exists('socket_create')) { + throw new NotSupportedException(sprintf(self::ERR_MSG_EXTENSION, 'socket')); + } + if (!function_exists('phpiredis_reader_create')) { + throw new NotSupportedException(sprintf(self::ERR_MSG_EXTENSION, 'phpiredis')); + } + } + + /** + * {@inheritdoc} + */ + protected function checkParameters(ConnectionParametersInterface $parameters) + { + if (isset($parameters->iterable_multibulk)) { + $this->onInvalidOption('iterable_multibulk', $parameters); + } + if (isset($parameters->persistent)) { + $this->onInvalidOption('persistent', $parameters); + } + + return parent::checkParameters($parameters); + } + + /** + * Initializes the protocol reader resource. + */ + private function initializeReader() + { + $reader = phpiredis_reader_create(); + + phpiredis_reader_set_status_handler($reader, $this->getStatusHandler()); + phpiredis_reader_set_error_handler($reader, $this->getErrorHandler()); + + $this->reader = $reader; + } + + /** + * Gets the handler used by the protocol reader to handle status replies. + * + * @return \Closure + */ + private function getStatusHandler() + { + return function ($payload) { + switch ($payload) { + case 'OK': + return true; + + case 'QUEUED': + return new ResponseQueued(); + + default: + return $payload; + } + }; + } + + /** + * Gets the handler used by the protocol reader to handle Redis errors. + * + * @return \Closure + */ + private function getErrorHandler() + { + return function ($errorMessage) { + return new ResponseError($errorMessage); + }; + } + + /** + * Helper method used to throw exceptions on socket errors. + */ + private function emitSocketError() + { + $errno = socket_last_error(); + $errstr = socket_strerror($errno); + + $this->disconnect(); + + $this->onConnectionError(trim($errstr), $errno); + } + + /** + * {@inheritdoc} + */ + protected function createResource() + { + $parameters = $this->parameters; + + $isUnix = $this->parameters->scheme === 'unix'; + $domain = $isUnix ? AF_UNIX : AF_INET; + $protocol = $isUnix ? 0 : SOL_TCP; + + $socket = @call_user_func('socket_create', $domain, SOCK_STREAM, $protocol); + if (!is_resource($socket)) { + $this->emitSocketError(); + } + + $this->setSocketOptions($socket, $parameters); + + return $socket; + } + + /** + * Sets options on the socket resource from the connection parameters. + * + * @param resource $socket Socket resource. + * @param ConnectionParametersInterface $parameters Parameters used to initialize the connection. + */ + private function setSocketOptions($socket, ConnectionParametersInterface $parameters) + { + if ($parameters->scheme !== 'tcp') { + return; + } + + if (!socket_set_option($socket, SOL_TCP, TCP_NODELAY, 1)) { + $this->emitSocketError(); + } + + if (!socket_set_option($socket, SOL_SOCKET, SO_REUSEADDR, 1)) { + $this->emitSocketError(); + } + + if (isset($parameters->read_write_timeout)) { + $rwtimeout = $parameters->read_write_timeout; + $timeoutSec = floor($rwtimeout); + $timeoutUsec = ($rwtimeout - $timeoutSec) * 1000000; + + $timeout = array( + 'sec' => $timeoutSec, + 'usec' => $timeoutUsec, + ); + + if (!socket_set_option($socket, SOL_SOCKET, SO_SNDTIMEO, $timeout)) { + $this->emitSocketError(); + } + + if (!socket_set_option($socket, SOL_SOCKET, SO_RCVTIMEO, $timeout)) { + $this->emitSocketError(); + } + } + } + + /** + * Gets the address from the connection parameters. + * + * @param ConnectionParametersInterface $parameters Parameters used to initialize the connection. + * @return string + */ + protected static function getAddress(ConnectionParametersInterface $parameters) + { + if ($parameters->scheme === 'unix') { + return $parameters->path; + } + + $host = $parameters->host; + + if (ip2long($host) === false) { + if (false === $addresses = gethostbynamel($host)) { + return false; + } + + return $addresses[array_rand($addresses)]; + } + + return $host; + } + + /** + * Opens the actual connection to the server with a timeout. + * + * @param ConnectionParametersInterface $parameters Parameters used to initialize the connection. + * @return string + */ + private function connectWithTimeout(ConnectionParametersInterface $parameters) + { + if (false === $host = self::getAddress($parameters)) { + $this->onConnectionError("Cannot resolve the address of '$parameters->host'."); + } + + $socket = $this->getResource(); + + socket_set_nonblock($socket); + + if (@socket_connect($socket, $host, $parameters->port) === false) { + $error = socket_last_error(); + if ($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY) { + $this->emitSocketError(); + } + } + + socket_set_block($socket); + + $null = null; + $selectable = array($socket); + + $timeout = $parameters->timeout; + $timeoutSecs = floor($timeout); + $timeoutUSecs = ($timeout - $timeoutSecs) * 1000000; + + $selected = socket_select($selectable, $selectable, $null, $timeoutSecs, $timeoutUSecs); + + if ($selected === 2) { + $this->onConnectionError('Connection refused', SOCKET_ECONNREFUSED); + } + if ($selected === 0) { + $this->onConnectionError('Connection timed out', SOCKET_ETIMEDOUT); + } + if ($selected === false) { + $this->emitSocketError(); + } + } + + /** + * {@inheritdoc} + */ + public function connect() + { + parent::connect(); + + $this->connectWithTimeout($this->parameters); + + if ($this->initCmds) { + $this->sendInitializationCommands(); + } + } + + /** + * {@inheritdoc} + */ + public function disconnect() + { + if ($this->isConnected()) { + socket_close($this->getResource()); + parent::disconnect(); + } + } + + /** + * Sends the initialization commands to Redis when the connection is opened. + */ + private function sendInitializationCommands() + { + foreach ($this->initCmds as $command) { + $this->writeCommand($command); + } + foreach ($this->initCmds as $command) { + $this->readResponse($command); + } + } + + /** + * {@inheritdoc} + */ + protected function write($buffer) + { + $socket = $this->getResource(); + + while (($length = strlen($buffer)) > 0) { + $written = socket_write($socket, $buffer, $length); + + if ($length === $written) { + return; + } + if ($written === false) { + $this->onConnectionError('Error while writing bytes to the server'); + } + + $buffer = substr($buffer, $written); + } + } + + /** + * {@inheritdoc} + */ + public function read() + { + $socket = $this->getResource(); + $reader = $this->reader; + + while (($state = phpiredis_reader_get_state($reader)) === PHPIREDIS_READER_STATE_INCOMPLETE) { + if (@socket_recv($socket, $buffer, 4096, 0) === false || $buffer === '') { + $this->emitSocketError(); + } + + phpiredis_reader_feed($reader, $buffer); + } + + if ($state === PHPIREDIS_READER_STATE_COMPLETE) { + return phpiredis_reader_get_reply($reader); + } else { + $this->onProtocolError(phpiredis_reader_get_error($reader)); + } + } + + /** + * {@inheritdoc} + */ + public function writeCommand(CommandInterface $command) + { + $cmdargs = $command->getArguments(); + array_unshift($cmdargs, $command->getId()); + $this->write(phpiredis_format_command($cmdargs)); + } + + /** + * {@inheritdoc} + */ + public function __wakeup() + { + $this->checkExtensions(); + $this->initializeReader(); + } +} diff --git a/vendor/predis/predis/lib/Predis/Connection/PhpiredisStreamConnection.php b/vendor/predis/predis/lib/Predis/Connection/PhpiredisStreamConnection.php new file mode 100755 index 0000000..286e522 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Connection/PhpiredisStreamConnection.php @@ -0,0 +1,196 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Connection; + +use Predis\NotSupportedException; +use Predis\ResponseError; +use Predis\ResponseQueued; +use Predis\Command\CommandInterface; + +/** + * This class provides the implementation of a Predis connection that uses PHP's + * streams for network communication and wraps the phpiredis C extension (PHP + * bindings for hiredis) to parse and serialize the Redis protocol. Everything + * is highly experimental (even the very same phpiredis since it is quite new), + * so use it at your own risk. + * + * This class is mainly intended to provide an optional low-overhead alternative + * for processing replies from Redis compared to the standard pure-PHP classes. + * Differences in speed when dealing with short inline replies are practically + * nonexistent, the actual speed boost is for long multibulk replies when this + * protocol processor can parse and return replies very fast. + * + * For instructions on how to build and install the phpiredis extension, please + * consult the repository of the project. + * + * The connection parameters supported by this class are: + * + * - scheme: it can be either 'tcp' or 'unix'. + * - host: hostname or IP address of the server. + * - port: TCP port of the server. + * - path: path of a UNIX domain socket when scheme is 'unix'. + * - timeout: timeout to perform the connection. + * - read_write_timeout: timeout of read / write operations. + * - async_connect: performs the connection asynchronously. + * - tcp_nodelay: enables or disables Nagle's algorithm for coalescing. + * - persistent: the connection is left intact after a GC collection. + * + * @link https://github.com/nrk/phpiredis + * @author Daniele Alessandri + */ +class PhpiredisStreamConnection extends StreamConnection +{ + private $reader; + + /** + * {@inheritdoc} + */ + public function __construct(ConnectionParametersInterface $parameters) + { + $this->checkExtensions(); + $this->initializeReader(); + + parent::__construct($parameters); + } + + /** + * {@inheritdoc} + */ + public function __destruct() + { + phpiredis_reader_destroy($this->reader); + + parent::__destruct(); + } + + /** + * Checks if the phpiredis extension is loaded in PHP. + */ + protected function checkExtensions() + { + if (!function_exists('phpiredis_reader_create')) { + throw new NotSupportedException( + 'The phpiredis extension must be loaded in order to be able to use this connection class' + ); + } + } + + /** + * {@inheritdoc} + */ + protected function checkParameters(ConnectionParametersInterface $parameters) + { + if (isset($parameters->iterable_multibulk)) { + $this->onInvalidOption('iterable_multibulk', $parameters); + } + + return parent::checkParameters($parameters); + } + + /** + * Initializes the protocol reader resource. + */ + protected function initializeReader() + { + $reader = phpiredis_reader_create(); + + phpiredis_reader_set_status_handler($reader, $this->getStatusHandler()); + phpiredis_reader_set_error_handler($reader, $this->getErrorHandler()); + + $this->reader = $reader; + } + + /** + * Gets the handler used by the protocol reader to handle status replies. + * + * @return \Closure + */ + protected function getStatusHandler() + { + return function ($payload) { + switch ($payload) { + case 'OK': + return true; + + case 'QUEUED': + return new ResponseQueued(); + + default: + return $payload; + } + }; + } + + /** + * Gets the handler used by the protocol reader to handle Redis errors. + * + * @return \Closure + */ + protected function getErrorHandler() + { + return function ($errorMessage) { + return new ResponseError($errorMessage); + }; + } + + /** + * {@inheritdoc} + */ + public function read() + { + $socket = $this->getResource(); + $reader = $this->reader; + + while (PHPIREDIS_READER_STATE_INCOMPLETE === $state = phpiredis_reader_get_state($reader)) { + $buffer = fread($socket, 4096); + + if ($buffer === false || $buffer === '') { + $this->onConnectionError('Error while reading bytes from the server'); + } + + phpiredis_reader_feed($reader, $buffer); + } + + if ($state === PHPIREDIS_READER_STATE_COMPLETE) { + return phpiredis_reader_get_reply($reader); + } else { + $this->onProtocolError(phpiredis_reader_get_error($reader)); + } + } + + /** + * {@inheritdoc} + */ + public function writeCommand(CommandInterface $command) + { + $cmdargs = $command->getArguments(); + array_unshift($cmdargs, $command->getId()); + $this->writeBytes(phpiredis_format_command($cmdargs)); + } + + /** + * {@inheritdoc} + */ + public function __sleep() + { + return array_diff(parent::__sleep(), array('mbiterable')); + } + + /** + * {@inheritdoc} + */ + public function __wakeup() + { + $this->checkExtensions(); + $this->initializeReader(); + } +} diff --git a/vendor/predis/predis/lib/Predis/Connection/PredisCluster.php b/vendor/predis/predis/lib/Predis/Connection/PredisCluster.php new file mode 100755 index 0000000..eb756f2 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Connection/PredisCluster.php @@ -0,0 +1,232 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Connection; + +use Predis\Cluster\CommandHashStrategyInterface; +use Predis\NotSupportedException; +use Predis\Cluster\PredisClusterHashStrategy; +use Predis\Cluster\Distribution\DistributionStrategyInterface; +use Predis\Cluster\Distribution\HashRing; +use Predis\Command\CommandInterface; + +/** + * Abstraction for a cluster of aggregated connections to various Redis servers + * implementing client-side sharding based on pluggable distribution strategies. + * + * @author Daniele Alessandri + * @todo Add the ability to remove connections from pool. + */ +class PredisCluster implements ClusterConnectionInterface, \IteratorAggregate, \Countable +{ + private $pool; + private $strategy; + private $distributor; + + /** + * @param DistributionStrategyInterface $distributor Distribution strategy used by the cluster. + */ + public function __construct(DistributionStrategyInterface $distributor = null) + { + $distributor = $distributor ?: new HashRing(); + + $this->pool = array(); + $this->strategy = new PredisClusterHashStrategy($distributor->getHashGenerator()); + $this->distributor = $distributor; + } + + /** + * {@inheritdoc} + */ + public function isConnected() + { + foreach ($this->pool as $connection) { + if ($connection->isConnected()) { + return true; + } + } + + return false; + } + + /** + * {@inheritdoc} + */ + public function connect() + { + foreach ($this->pool as $connection) { + $connection->connect(); + } + } + + /** + * {@inheritdoc} + */ + public function disconnect() + { + foreach ($this->pool as $connection) { + $connection->disconnect(); + } + } + + /** + * {@inheritdoc} + */ + public function add(SingleConnectionInterface $connection) + { + $parameters = $connection->getParameters(); + + if (isset($parameters->alias)) { + $this->pool[$parameters->alias] = $connection; + } else { + $this->pool[] = $connection; + } + + $weight = isset($parameters->weight) ? $parameters->weight : null; + $this->distributor->add($connection, $weight); + } + + /** + * {@inheritdoc} + */ + public function remove(SingleConnectionInterface $connection) + { + if (($id = array_search($connection, $this->pool, true)) !== false) { + unset($this->pool[$id]); + $this->distributor->remove($connection); + + return true; + } + + return false; + } + + /** + * Removes a connection instance using its alias or index. + * + * @param string $connectionId Alias or index of a connection. + * @return bool Returns true if the connection was in the pool. + */ + public function removeById($connectionId) + { + if ($connection = $this->getConnectionById($connectionId)) { + return $this->remove($connection); + } + + return false; + } + + /** + * {@inheritdoc} + */ + public function getConnection(CommandInterface $command) + { + $hash = $this->strategy->getHash($command); + + if (!isset($hash)) { + throw new NotSupportedException("Cannot use {$command->getId()} with a cluster of connections"); + } + + $node = $this->distributor->get($hash); + + return $node; + } + + /** + * {@inheritdoc} + */ + public function getConnectionById($connectionId) + { + return isset($this->pool[$connectionId]) ? $this->pool[$connectionId] : null; + } + + /** + * Retrieves a connection instance from the cluster using a key. + * + * @param string $key Key of a Redis value. + * @return SingleConnectionInterface + */ + public function getConnectionByKey($key) + { + $hash = $this->strategy->getKeyHash($key); + $node = $this->distributor->get($hash); + + return $node; + } + + /** + * Returns the underlying command hash strategy used to hash + * commands by their keys. + * + * @return CommandHashStrategyInterface + */ + public function getCommandHashStrategy() + { + return $this->strategy; + } + + /** + * {@inheritdoc} + */ + public function count() + { + return count($this->pool); + } + + /** + * {@inheritdoc} + */ + public function getIterator() + { + return new \ArrayIterator($this->pool); + } + + /** + * {@inheritdoc} + */ + public function writeCommand(CommandInterface $command) + { + $this->getConnection($command)->writeCommand($command); + } + + /** + * {@inheritdoc} + */ + public function readResponse(CommandInterface $command) + { + return $this->getConnection($command)->readResponse($command); + } + + /** + * {@inheritdoc} + */ + public function executeCommand(CommandInterface $command) + { + return $this->getConnection($command)->executeCommand($command); + } + + /** + * Executes the specified Redis command on all the nodes of a cluster. + * + * @param CommandInterface $command A Redis command. + * @return array + */ + public function executeCommandOnNodes(CommandInterface $command) + { + $replies = array(); + + foreach ($this->pool as $connection) { + $replies[] = $connection->executeCommand($command); + } + + return $replies; + } +} diff --git a/vendor/predis/predis/lib/Predis/Connection/RedisCluster.php b/vendor/predis/predis/lib/Predis/Connection/RedisCluster.php new file mode 100755 index 0000000..b7e3249 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Connection/RedisCluster.php @@ -0,0 +1,526 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Connection; + +use ArrayIterator; +use Countable; +use IteratorAggregate; +use OutOfBoundsException; +use Predis\NotSupportedException; +use Predis\ResponseErrorInterface; +use Predis\Cluster\CommandHashStrategyInterface; +use Predis\Cluster\RedisClusterHashStrategy; +use Predis\Command\CommandInterface; +use Predis\Command\RawCommand; + +/** + * Abstraction for a Redis-backed cluster of nodes (Redis >= 3.0.0). + * + * This connection backend offers smart support for redis-cluster by handling + * automatic slots map (re)generation upon -MOVE or -ASK responses returned by + * Redis when redirecting a client to a different node. + * + * The cluster can be pre-initialized using only a subset of the actual nodes in + * the cluster, Predis will do the rest by adjusting the slots map and creating + * the missing underlying connection instances on the fly. + * + * It is possible to pre-associate connections to a slots range with the "slots" + * parameter in the form "$first-$last". This can greatly reduce runtime node + * guessing and redirections. + * + * It is also possible to ask for the full and updated slots map directly to one + * of the nodes and optionally enable such a behaviour upon -MOVED redirections. + * Asking for the cluster configuration to Redis is actually done by issuing a + * CLUSTER NODES command to a random node in the pool. + * + * @author Daniele Alessandri + */ +class RedisCluster implements ClusterConnectionInterface, IteratorAggregate, Countable +{ + private $askClusterNodes = false; + private $defaultParameters = array(); + private $pool = array(); + private $slots = array(); + private $slotsMap; + private $strategy; + private $connections; + + /** + * @param ConnectionFactoryInterface $connections Connection factory object. + */ + public function __construct(ConnectionFactoryInterface $connections = null) + { + $this->strategy = new RedisClusterHashStrategy(); + $this->connections = $connections ?: new ConnectionFactory(); + } + + /** + * {@inheritdoc} + */ + public function isConnected() + { + foreach ($this->pool as $connection) { + if ($connection->isConnected()) { + return true; + } + } + + return false; + } + + /** + * {@inheritdoc} + */ + public function connect() + { + if ($connection = $this->getRandomConnection()) { + $connection->connect(); + } + } + + /** + * {@inheritdoc} + */ + public function disconnect() + { + foreach ($this->pool as $connection) { + $connection->disconnect(); + } + } + + /** + * {@inheritdoc} + */ + public function add(SingleConnectionInterface $connection) + { + $this->pool[(string) $connection] = $connection; + unset($this->slotsMap); + } + + /** + * {@inheritdoc} + */ + public function remove(SingleConnectionInterface $connection) + { + if (false !== $id = array_search($connection, $this->pool, true)) { + unset( + $this->pool[$id], + $this->slotsMap + ); + + return true; + } + + return false; + } + + /** + * Removes a connection instance by using its identifier. + * + * @param string $connectionID Connection identifier. + * @return bool True if the connection was in the pool. + */ + public function removeById($connectionID) + { + if (isset($this->pool[$connectionID])) { + unset( + $this->pool[$connectionID], + $this->slotsMap + ); + + return true; + } + + return false; + } + + /** + * Generates the current slots map by guessing the cluster configuration out + * of the connection parameters of the connections in the pool. + * + * Generation is based on the same algorithm used by Redis to generate the + * cluster, so it is most effective when all of the connections supplied on + * initialization have the "slots" parameter properly set accordingly to the + * current cluster configuration. + */ + public function buildSlotsMap() + { + $this->slotsMap = array(); + + foreach ($this->pool as $connectionID => $connection) { + $parameters = $connection->getParameters(); + + if (!isset($parameters->slots)) { + continue; + } + + $slots = explode('-', $parameters->slots, 2); + $this->setSlots($slots[0], $slots[1], $connectionID); + } + } + + /** + * Generates the current slots map by fetching the cluster configuration to + * one of the nodes by leveraging the CLUSTER NODES command. + */ + public function askClusterNodes() + { + if (!$connection = $this->getRandomConnection()) { + return array(); + } + + $cmdCluster = RawCommand::create('CLUSTER', 'NODES'); + $response = $connection->executeCommand($cmdCluster); + + $nodes = explode("\n", $response, -1); + $count = count($nodes); + + for ($i = 0; $i < $count; $i++) { + $node = explode(' ', $nodes[$i], 9); + $slots = explode('-', $node[8], 2); + + if ($node[1] === ':0') { + $this->setSlots($slots[0], $slots[1], (string) $connection); + } else { + $this->setSlots($slots[0], $slots[1], $node[1]); + } + } + } + + /** + * Returns the current slots map for the cluster. + * + * @return array + */ + public function getSlotsMap() + { + if (!isset($this->slotsMap)) { + $this->slotsMap = array(); + } + + return $this->slotsMap; + } + + /** + * Pre-associates a connection to a slots range to avoid runtime guessing. + * + * @param int $first Initial slot of the range. + * @param int $last Last slot of the range. + * @param SingleConnectionInterface|string $connection ID or connection instance. + */ + public function setSlots($first, $last, $connection) + { + if ($first < 0x0000 || $first > 0x3FFF || + $last < 0x0000 || $last > 0x3FFF || + $last < $first + ) { + throw new OutOfBoundsException( + "Invalid slot range for $connection: [$first-$last]" + ); + } + + $slots = array_fill($first, $last - $first + 1, (string) $connection); + $this->slotsMap = $this->getSlotsMap() + $slots; + } + + /** + * Guesses the correct node associated to a given slot using a precalculated + * slots map, falling back to the same logic used by Redis to initialize a + * cluster (best-effort). + * + * @param int $slot Slot index. + * @return string Connection ID. + */ + protected function guessNode($slot) + { + if (!isset($this->slotsMap)) { + $this->buildSlotsMap(); + } + + if (isset($this->slotsMap[$slot])) { + return $this->slotsMap[$slot]; + } + + $count = count($this->pool); + $index = min((int) ($slot / (int) (16384 / $count)), $count - 1); + $nodes = array_keys($this->pool); + + return $nodes[$index]; + } + + /** + * Creates a new connection instance from the given connection ID. + * + * @param string $connectionID Identifier for the connection. + * @return SingleConnectionInterface + */ + protected function createConnection($connectionID) + { + $host = explode(':', $connectionID, 2); + + $parameters = array_merge($this->defaultParameters, array( + 'host' => $host[0], + 'port' => $host[1], + )); + + $connection = $this->connections->create($parameters); + + return $connection; + } + + /** + * {@inheritdoc} + */ + public function getConnection(CommandInterface $command) + { + $hash = $this->strategy->getHash($command); + + if (!isset($hash)) { + throw new NotSupportedException( + "Cannot use {$command->getId()} with redis-cluster" + ); + } + + $slot = $hash & 0x3FFF; + + if (isset($this->slots[$slot])) { + return $this->slots[$slot]; + } else { + return $this->getConnectionBySlot($slot); + } + } + + /** + * Returns the connection currently associated to a given slot. + * + * @param int $slot Slot index. + * @return SingleConnectionInterface + */ + public function getConnectionBySlot($slot) + { + if ($slot < 0x0000 || $slot > 0x3FFF) { + throw new OutOfBoundsException("Invalid slot [$slot]"); + } + + if (isset($this->slots[$slot])) { + return $this->slots[$slot]; + } + + $connectionID = $this->guessNode($slot); + + if (!$connection = $this->getConnectionById($connectionID)) { + $connection = $this->createConnection($connectionID); + $this->pool[$connectionID] = $connection; + } + + return $this->slots[$slot] = $connection; + } + + /** + * {@inheritdoc} + */ + public function getConnectionById($connectionID) + { + if (isset($this->pool[$connectionID])) { + return $this->pool[$connectionID]; + } + } + + /** + * Returns a random connection from the pool. + * + * @return SingleConnectionInterface + */ + protected function getRandomConnection() + { + if ($this->pool) { + return $this->pool[array_rand($this->pool)]; + } + } + + /** + * Permanently associates the connection instance to a new slot. + * The connection is added to the connections pool if not yet included. + * + * @param SingleConnectionInterface $connection Connection instance. + * @param int $slot Target slot index. + */ + protected function move(SingleConnectionInterface $connection, $slot) + { + $this->pool[(string) $connection] = $connection; + $this->slots[(int) $slot] = $connection; + } + + /** + * Handles -ERR responses returned by Redis. + * + * @param CommandInterface $command Command that generated the -ERR response. + * @param ResponseErrorInterface $error Redis error response object. + * @return mixed + */ + protected function onErrorResponse(CommandInterface $command, ResponseErrorInterface $error) + { + $details = explode(' ', $error->getMessage(), 2); + + switch ($details[0]) { + case 'MOVED': + return $this->onMovedResponse($command, $details[1]); + + case 'ASK': + return $this->onAskResponse($command, $details[1]); + + default: + return $error; + } + } + + /** + * Handles -MOVED responses by executing again the command against the node + * indicated by the Redis response. + * + * @param CommandInterface $command Command that generated the -MOVED response. + * @param string $details Parameters of the -MOVED response. + * @return mixed + */ + protected function onMovedResponse(CommandInterface $command, $details) + { + list($slot, $connectionID) = explode(' ', $details, 2); + + if (!$connection = $this->getConnectionById($connectionID)) { + $connection = $this->createConnection($connectionID); + } + + if ($this->askClusterNodes) { + $this->askClusterNodes(); + } + + $this->move($connection, $slot); + $response = $this->executeCommand($command); + + return $response; + } + + /** + * Handles -ASK responses by executing again the command against the node + * indicated by the Redis response. + * + * @param CommandInterface $command Command that generated the -ASK response. + * @param string $details Parameters of the -ASK response. + * @return mixed + */ + protected function onAskResponse(CommandInterface $command, $details) + { + list($slot, $connectionID) = explode(' ', $details, 2); + + if (!$connection = $this->getConnectionById($connectionID)) { + $connection = $this->createConnection($connectionID); + } + + $connection->executeCommand(RawCommand::create('ASKING')); + $response = $connection->executeCommand($command); + + return $response; + } + + /** + * {@inheritdoc} + */ + public function writeCommand(CommandInterface $command) + { + $this->getConnection($command)->writeCommand($command); + } + + /** + * {@inheritdoc} + */ + public function readResponse(CommandInterface $command) + { + return $this->getConnection($command)->readResponse($command); + } + + /** + * {@inheritdoc} + */ + public function executeCommand(CommandInterface $command) + { + $connection = $this->getConnection($command); + $response = $connection->executeCommand($command); + + if ($response instanceof ResponseErrorInterface) { + return $this->onErrorResponse($command, $response); + } + + return $response; + } + + /** + * {@inheritdoc} + */ + public function count() + { + return count($this->pool); + } + + /** + * {@inheritdoc} + */ + public function getIterator() + { + return new ArrayIterator(array_values($this->pool)); + } + + /** + * Returns the underlying hash strategy used to hash commands by their keys. + * + * @return CommandHashStrategyInterface + */ + public function getCommandHashStrategy() + { + return $this->strategy; + } + + /** + * Enables automatic fetching of the current slots map from one of the nodes + * using the CLUSTER NODES command. This option is disabled by default but + * asking the current slots map to Redis upon -MOVE responses may reduce + * overhead by eliminating the trial-and-error nature of the node guessing + * procedure, mostly when targeting many keys that would end up in a lot of + * redirections. + * + * The slots map can still be manually fetched using the askClusterNodes() + * method whether or not this option is enabled. + * + * @param bool $value Enable or disable the use of CLUSTER NODES. + */ + public function enableClusterNodes($value) + { + $this->askClusterNodes = (bool) $value; + } + + /** + * Sets a default array of connection parameters to be applied when creating + * new connection instances on the fly when they are not part of the initial + * pool supplied upon cluster initialization. + * + * These parameters are not applied to connections added to the pool using + * the add() method. + * + * @param array $parameters Array of connection parameters. + */ + public function setDefaultParameters(array $parameters) + { + $this->defaultParameters = array_merge( + $this->defaultParameters, + $parameters ?: array() + ); + } +} diff --git a/vendor/predis/predis/lib/Predis/Connection/ReplicationConnectionInterface.php b/vendor/predis/predis/lib/Predis/Connection/ReplicationConnectionInterface.php new file mode 100755 index 0000000..7142dfa --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Connection/ReplicationConnectionInterface.php @@ -0,0 +1,48 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Connection; + +/** + * Defines a group of Redis servers in a master/slave replication configuration. + * + * @author Daniele Alessandri + */ +interface ReplicationConnectionInterface extends AggregatedConnectionInterface +{ + /** + * Switches the internal connection object being used. + * + * @param string $connection Alias of a connection + */ + public function switchTo($connection); + + /** + * Retrieves the connection object currently being used. + * + * @return SingleConnectionInterface + */ + public function getCurrent(); + + /** + * Retrieves the connection object to the master Redis server. + * + * @return SingleConnectionInterface + */ + public function getMaster(); + + /** + * Retrieves a list of connection objects to slaves Redis servers. + * + * @return SingleConnectionInterface + */ + public function getSlaves(); +} diff --git a/vendor/predis/predis/lib/Predis/Connection/SingleConnectionInterface.php b/vendor/predis/predis/lib/Predis/Connection/SingleConnectionInterface.php new file mode 100755 index 0000000..9b080c2 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Connection/SingleConnectionInterface.php @@ -0,0 +1,58 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Connection; + +use Predis\Command\CommandInterface; + +/** + * Defines a connection object used to communicate with a single Redis server. + * + * @author Daniele Alessandri + */ +interface SingleConnectionInterface extends ConnectionInterface +{ + /** + * Returns a string representation of the connection. + * + * @return string + */ + public function __toString(); + + /** + * Returns the underlying resource used to communicate with a Redis server. + * + * @return mixed + */ + public function getResource(); + + /** + * Gets the parameters used to initialize the connection object. + * + * @return ConnectionParametersInterface + */ + public function getParameters(); + + /** + * Pushes the instance of a Redis command to the queue of commands executed + * when the actual connection to a server is estabilished. + * + * @param CommandInterface $command Instance of a Redis command. + */ + public function pushInitCommand(CommandInterface $command); + + /** + * Reads a reply from the server. + * + * @return mixed + */ + public function read(); +} diff --git a/vendor/predis/predis/lib/Predis/Connection/StreamConnection.php b/vendor/predis/predis/lib/Predis/Connection/StreamConnection.php new file mode 100755 index 0000000..a42788b --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Connection/StreamConnection.php @@ -0,0 +1,307 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Connection; + +use Predis\ResponseError; +use Predis\ResponseQueued; +use Predis\Command\CommandInterface; +use Predis\Iterator\MultiBulkResponseSimple; + +/** + * Standard connection to Redis servers implemented on top of PHP's streams. + * The connection parameters supported by this class are: + * + * - scheme: it can be either 'tcp' or 'unix'. + * - host: hostname or IP address of the server. + * - port: TCP port of the server. + * - path: path of a UNIX domain socket when scheme is 'unix'. + * - timeout: timeout to perform the connection. + * - read_write_timeout: timeout of read / write operations. + * - async_connect: performs the connection asynchronously. + * - tcp_nodelay: enables or disables Nagle's algorithm for coalescing. + * - persistent: the connection is left intact after a GC collection. + * - iterable_multibulk: multibulk replies treated as iterable objects. + * + * @author Daniele Alessandri + */ +class StreamConnection extends AbstractConnection +{ + private $mbiterable; + + /** + * {@inheritdoc} + */ + public function __construct(ConnectionParametersInterface $parameters) + { + $this->mbiterable = (bool) $parameters->iterable_multibulk; + + parent::__construct($parameters); + } + + /** + * Disconnects from the server and destroys the underlying resource when + * PHP's garbage collector kicks in only if the connection has not been + * marked as persistent. + */ + public function __destruct() + { + if (isset($this->parameters) && !$this->parameters->persistent) { + $this->disconnect(); + } + } + + /** + * {@inheritdoc} + */ + protected function createResource() + { + $parameters = $this->parameters; + $initializer = "{$parameters->scheme}StreamInitializer"; + + return $this->$initializer($parameters); + } + + /** + * Initializes a TCP stream resource. + * + * @param ConnectionParametersInterface $parameters Parameters used to initialize the connection. + * @return resource + */ + private function tcpStreamInitializer(ConnectionParametersInterface $parameters) + { + $uri = "tcp://{$parameters->host}:{$parameters->port}"; + $flags = STREAM_CLIENT_CONNECT; + + if (isset($parameters->async_connect) && $parameters->async_connect) { + $flags |= STREAM_CLIENT_ASYNC_CONNECT; + } + + if (isset($parameters->persistent) && $parameters->persistent) { + $flags |= STREAM_CLIENT_PERSISTENT; + $uri .= strpos($path = $parameters->path, '/') === 0 ? $path : "/$path"; + } + + $resource = @stream_socket_client($uri, $errno, $errstr, $parameters->timeout, $flags); + + if (!$resource) { + $this->onConnectionError(trim($errstr), $errno); + } + + if (isset($parameters->read_write_timeout)) { + $rwtimeout = $parameters->read_write_timeout; + $rwtimeout = $rwtimeout > 0 ? $rwtimeout : -1; + $timeoutSeconds = floor($rwtimeout); + $timeoutUSeconds = ($rwtimeout - $timeoutSeconds) * 1000000; + stream_set_timeout($resource, $timeoutSeconds, $timeoutUSeconds); + } + + if (isset($parameters->tcp_nodelay) && version_compare(PHP_VERSION, '5.4.0') >= 0) { + $socket = socket_import_stream($resource); + socket_set_option($socket, SOL_TCP, TCP_NODELAY, (int) $parameters->tcp_nodelay); + } + + return $resource; + } + + /** + * Initializes a UNIX stream resource. + * + * @param ConnectionParametersInterface $parameters Parameters used to initialize the connection. + * @return resource + */ + private function unixStreamInitializer(ConnectionParametersInterface $parameters) + { + $uri = "unix://{$parameters->path}"; + $flags = STREAM_CLIENT_CONNECT; + + if ($parameters->persistent) { + $flags |= STREAM_CLIENT_PERSISTENT; + } + + $resource = @stream_socket_client($uri, $errno, $errstr, $parameters->timeout, $flags); + + if (!$resource) { + $this->onConnectionError(trim($errstr), $errno); + } + + return $resource; + } + + /** + * {@inheritdoc} + */ + public function connect() + { + parent::connect(); + + if ($this->initCmds) { + $this->sendInitializationCommands(); + } + } + + /** + * {@inheritdoc} + */ + public function disconnect() + { + if ($this->isConnected()) { + fclose($this->getResource()); + parent::disconnect(); + } + } + + /** + * Sends the initialization commands to Redis when the connection is opened. + */ + private function sendInitializationCommands() + { + foreach ($this->initCmds as $command) { + $this->writeCommand($command); + } + foreach ($this->initCmds as $command) { + $this->readResponse($command); + } + } + + /** + * Performs a write operation on the stream of the buffer containing a + * command serialized with the Redis wire protocol. + * + * @param string $buffer Redis wire protocol representation of a command. + */ + protected function writeBytes($buffer) + { + $socket = $this->getResource(); + + while (($length = strlen($buffer)) > 0) { + $written = fwrite($socket, $buffer); + + if ($length === $written) { + return; + } + if ($written === false || $written === 0) { + $this->onConnectionError('Error while writing bytes to the server'); + } + + $buffer = substr($buffer, $written); + } + } + + /** + * {@inheritdoc} + */ + public function read() + { + $socket = $this->getResource(); + $chunk = fgets($socket); + + if ($chunk === false || $chunk === '') { + $this->onConnectionError('Error while reading line from the server'); + } + + $prefix = $chunk[0]; + $payload = substr($chunk, 1, -2); + + switch ($prefix) { + case '+': + switch ($payload) { + case 'OK': + return true; + + case 'QUEUED': + return new ResponseQueued(); + + default: + return $payload; + } + + case '$': + $size = (int) $payload; + if ($size === -1) { + return null; + } + + $bulkData = ''; + $bytesLeft = ($size += 2); + + do { + $chunk = fread($socket, min($bytesLeft, 4096)); + + if ($chunk === false || $chunk === '') { + $this->onConnectionError('Error while reading bytes from the server'); + } + + $bulkData .= $chunk; + $bytesLeft = $size - strlen($bulkData); + } while ($bytesLeft > 0); + + return substr($bulkData, 0, -2); + + case '*': + $count = (int) $payload; + + if ($count === -1) { + return null; + } + if ($this->mbiterable) { + return new MultiBulkResponseSimple($this, $count); + } + + $multibulk = array(); + + for ($i = 0; $i < $count; $i++) { + $multibulk[$i] = $this->read(); + } + + return $multibulk; + + case ':': + return (int) $payload; + + case '-': + return new ResponseError($payload); + + default: + $this->onProtocolError("Unknown prefix: '$prefix'"); + } + } + + /** + * {@inheritdoc} + */ + public function writeCommand(CommandInterface $command) + { + $commandId = $command->getId(); + $arguments = $command->getArguments(); + + $cmdlen = strlen($commandId); + $reqlen = count($arguments) + 1; + + $buffer = "*{$reqlen}\r\n\${$cmdlen}\r\n{$commandId}\r\n"; + + for ($i = 0, $reqlen--; $i < $reqlen; $i++) { + $argument = $arguments[$i]; + $arglen = strlen($argument); + $buffer .= "\${$arglen}\r\n{$argument}\r\n"; + } + + $this->writeBytes($buffer); + } + + /** + * {@inheritdoc} + */ + public function __sleep() + { + return array_merge(parent::__sleep(), array('mbiterable')); + } +} diff --git a/vendor/predis/predis/lib/Predis/Connection/WebdisConnection.php b/vendor/predis/predis/lib/Predis/Connection/WebdisConnection.php new file mode 100755 index 0000000..b897268 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Connection/WebdisConnection.php @@ -0,0 +1,335 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Connection; + +use Predis\NotSupportedException; +use Predis\ResponseError; +use Predis\Command\CommandInterface; +use Predis\Connection\ConnectionException; +use Predis\Protocol\ProtocolException; + +/** + * This class implements a Predis connection that actually talks with Webdis + * instead of connecting directly to Redis. It relies on the cURL extension to + * communicate with the web server and the phpiredis extension to parse the + * protocol of the replies returned in the http response bodies. + * + * Some features are not yet available or they simply cannot be implemented: + * - Pipelining commands. + * - Publish / Subscribe. + * - MULTI / EXEC transactions (not yet supported by Webdis). + * + * The connection parameters supported by this class are: + * + * - scheme: must be 'http'. + * - host: hostname or IP address of the server. + * - port: TCP port of the server. + * - timeout: timeout to perform the connection. + * - user: username for authentication. + * - pass: password for authentication. + * + * @link http://webd.is + * @link http://github.com/nicolasff/webdis + * @link http://github.com/seppo0010/phpiredis + * @author Daniele Alessandri + */ +class WebdisConnection implements SingleConnectionInterface +{ + const ERR_MSG_EXTENSION = 'The %s extension must be loaded in order to be able to use this connection class'; + + private $parameters; + private $resource; + private $reader; + + /** + * @param ConnectionParametersInterface $parameters Parameters used to initialize the connection. + */ + public function __construct(ConnectionParametersInterface $parameters) + { + $this->checkExtensions(); + + if ($parameters->scheme !== 'http') { + throw new \InvalidArgumentException("Invalid scheme: {$parameters->scheme}"); + } + + $this->parameters = $parameters; + $this->resource = $this->initializeCurl($parameters); + $this->reader = $this->initializeReader($parameters); + } + + /** + * Frees the underlying cURL and protocol reader resources when PHP's + * garbage collector kicks in. + */ + public function __destruct() + { + curl_close($this->resource); + phpiredis_reader_destroy($this->reader); + } + + /** + * Helper method used to throw on unsupported methods. + */ + private function throwNotSupportedException($function) + { + $class = __CLASS__; + throw new NotSupportedException("The method $class::$function() is not supported"); + } + + /** + * Checks if the cURL and phpiredis extensions are loaded in PHP. + */ + private function checkExtensions() + { + if (!function_exists('curl_init')) { + throw new NotSupportedException(sprintf(self::ERR_MSG_EXTENSION, 'curl')); + } + + if (!function_exists('phpiredis_reader_create')) { + throw new NotSupportedException(sprintf(self::ERR_MSG_EXTENSION, 'phpiredis')); + } + } + + /** + * Initializes cURL. + * + * @param ConnectionParametersInterface $parameters Parameters used to initialize the connection. + * @return resource + */ + private function initializeCurl(ConnectionParametersInterface $parameters) + { + $options = array( + CURLOPT_FAILONERROR => true, + CURLOPT_CONNECTTIMEOUT_MS => $parameters->timeout * 1000, + CURLOPT_URL => "{$parameters->scheme}://{$parameters->host}:{$parameters->port}", + CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, + CURLOPT_POST => true, + CURLOPT_WRITEFUNCTION => array($this, 'feedReader'), + ); + + if (isset($parameters->user, $parameters->pass)) { + $options[CURLOPT_USERPWD] = "{$parameters->user}:{$parameters->pass}"; + } + + curl_setopt_array($resource = curl_init(), $options); + + return $resource; + } + + /** + * Initializes phpiredis' protocol reader. + * + * @param ConnectionParametersInterface $parameters Parameters used to initialize the connection. + * @return resource + */ + private function initializeReader(ConnectionParametersInterface $parameters) + { + $reader = phpiredis_reader_create(); + + phpiredis_reader_set_status_handler($reader, $this->getStatusHandler()); + phpiredis_reader_set_error_handler($reader, $this->getErrorHandler()); + + return $reader; + } + + /** + * Gets the handler used by the protocol reader to handle status replies. + * + * @return \Closure + */ + protected function getStatusHandler() + { + return function ($payload) { + return $payload === 'OK' ? true : $payload; + }; + } + + /** + * Gets the handler used by the protocol reader to handle Redis errors. + * + * @return \Closure + */ + protected function getErrorHandler() + { + return function ($errorMessage) { + return new ResponseError($errorMessage); + }; + } + + /** + * Feeds phpredis' reader resource with the data read from the network. + * + * @param resource $resource Reader resource. + * @param string $buffer Buffer with the reply read from the network. + * @return int + */ + protected function feedReader($resource, $buffer) + { + phpiredis_reader_feed($this->reader, $buffer); + + return strlen($buffer); + } + + /** + * {@inheritdoc} + */ + public function connect() + { + // NOOP + } + + /** + * {@inheritdoc} + */ + public function disconnect() + { + // NOOP + } + + /** + * {@inheritdoc} + */ + public function isConnected() + { + return true; + } + + /** + * Checks if the specified command is supported by this connection class. + * + * @param CommandInterface $command The instance of a Redis command. + * @return string + */ + protected function getCommandId(CommandInterface $command) + { + switch (($commandId = $command->getId())) { + case 'AUTH': + case 'SELECT': + case 'MULTI': + case 'EXEC': + case 'WATCH': + case 'UNWATCH': + case 'DISCARD': + case 'MONITOR': + throw new NotSupportedException("Disabled command: {$command->getId()}"); + + default: + return $commandId; + } + } + + /** + * {@inheritdoc} + */ + public function writeCommand(CommandInterface $command) + { + $this->throwNotSupportedException(__FUNCTION__); + } + + /** + * {@inheritdoc} + */ + public function readResponse(CommandInterface $command) + { + $this->throwNotSupportedException(__FUNCTION__); + } + + /** + * {@inheritdoc} + */ + public function executeCommand(CommandInterface $command) + { + $resource = $this->resource; + $commandId = $this->getCommandId($command); + + if ($arguments = $command->getArguments()) { + $arguments = implode('/', array_map('urlencode', $arguments)); + $serializedCommand = "$commandId/$arguments.raw"; + } else { + $serializedCommand = "$commandId.raw"; + } + + curl_setopt($resource, CURLOPT_POSTFIELDS, $serializedCommand); + + if (curl_exec($resource) === false) { + $error = curl_error($resource); + $errno = curl_errno($resource); + throw new ConnectionException($this, trim($error), $errno); + } + + if (phpiredis_reader_get_state($this->reader) !== PHPIREDIS_READER_STATE_COMPLETE) { + throw new ProtocolException($this, phpiredis_reader_get_error($this->reader)); + } + + return phpiredis_reader_get_reply($this->reader); + } + + /** + * {@inheritdoc} + */ + public function getResource() + { + return $this->resource; + } + + /** + * {@inheritdoc} + */ + public function getParameters() + { + return $this->parameters; + } + + /** + * {@inheritdoc} + */ + public function pushInitCommand(CommandInterface $command) + { + $this->throwNotSupportedException(__FUNCTION__); + } + + /** + * {@inheritdoc} + */ + public function read() + { + $this->throwNotSupportedException(__FUNCTION__); + } + + /** + * {@inheritdoc} + */ + public function __toString() + { + return "{$this->parameters->host}:{$this->parameters->port}"; + } + + /** + * {@inheritdoc} + */ + public function __sleep() + { + return array('parameters'); + } + + /** + * {@inheritdoc} + */ + public function __wakeup() + { + $this->checkExtensions(); + $parameters = $this->getParameters(); + + $this->resource = $this->initializeCurl($parameters); + $this->reader = $this->initializeReader($parameters); + } +} diff --git a/vendor/predis/predis/lib/Predis/ExecutableContextInterface.php b/vendor/predis/predis/lib/Predis/ExecutableContextInterface.php new file mode 100755 index 0000000..1cb1e83 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/ExecutableContextInterface.php @@ -0,0 +1,29 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis; + +/** + * Defines the interface of a basic client object or abstraction that + * can send commands to Redis. + * + * @author Daniele Alessandri + */ +interface ExecutableContextInterface +{ + /** + * Starts the execution of the context. + * + * @param mixed $callable Optional callback for execution. + * @return array + */ + public function execute($callable = null); +} diff --git a/vendor/predis/predis/lib/Predis/Helpers.php b/vendor/predis/predis/lib/Predis/Helpers.php new file mode 100755 index 0000000..064f72d --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Helpers.php @@ -0,0 +1,73 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis; + +/** + * Defines a few helper methods. + * + * @author Daniele Alessandri + * @deprecated Deprecated since v0.8.3. + */ +class Helpers +{ + /** + * Offers a generic and reusable method to handle exceptions generated by + * a connection object. + * + * @deprecated Deprecated since v0.8.3 - moved in Predis\CommunicationException::handle() + * @param CommunicationException $exception Exception. + */ + public static function onCommunicationException(CommunicationException $exception) + { + if ($exception->shouldResetConnection()) { + $connection = $exception->getConnection(); + + if ($connection->isConnected()) { + $connection->disconnect(); + } + } + + throw $exception; + } + + /** + * Normalizes the arguments array passed to a Redis command. + * + * @deprecated Deprecated since v0.8.3 - moved in Predis\Command\AbstractCommand::normalizeArguments() + * @param array $arguments Arguments for a command. + * @return array + */ + public static function filterArrayArguments(Array $arguments) + { + if (count($arguments) === 1 && is_array($arguments[0])) { + return $arguments[0]; + } + + return $arguments; + } + + /** + * Normalizes the arguments array passed to a variadic Redis command. + * + * @deprecated Deprecated since v0.8.3 - moved in Predis\Command\AbstractCommand::normalizeVariadic() + * @param array $arguments Arguments for a command. + * @return array + */ + public static function filterVariadicValues(Array $arguments) + { + if (count($arguments) === 2 && is_array($arguments[1])) { + return array_merge(array($arguments[0]), $arguments[1]); + } + + return $arguments; + } +} diff --git a/vendor/predis/predis/lib/Predis/Iterator/MultiBulkResponse.php b/vendor/predis/predis/lib/Predis/Iterator/MultiBulkResponse.php new file mode 100755 index 0000000..317a006 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Iterator/MultiBulkResponse.php @@ -0,0 +1,100 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Iterator; + +use Predis\ResponseObjectInterface; + +/** + * Iterator that abstracts the access to multibulk replies and allows + * them to be consumed by user's code in a streaming fashion. + * + * @author Daniele Alessandri + */ +abstract class MultiBulkResponse implements \Iterator, \Countable, ResponseObjectInterface +{ + protected $position; + protected $current; + protected $replySize; + + /** + * {@inheritdoc} + */ + public function rewind() + { + // NOOP + } + + /** + * {@inheritdoc} + */ + public function current() + { + return $this->current; + } + + /** + * {@inheritdoc} + */ + public function key() + { + return $this->position; + } + + /** + * {@inheritdoc} + */ + public function next() + { + if (++$this->position < $this->replySize) { + $this->current = $this->getValue(); + } + + return $this->position; + } + + /** + * {@inheritdoc} + */ + public function valid() + { + return $this->position < $this->replySize; + } + + /** + * Returns the number of items of the whole multibulk reply. + * + * This method should be used to get the size of the current multibulk + * reply without using iterator_count, which actually consumes the + * iterator to calculate the size (rewinding is not supported). + * + * @return int + */ + public function count() + { + return $this->replySize; + } + + /** + * Returns the current position of the iterator. + * + * @return int + */ + public function getPosition() + { + return $this->position; + } + + /** + * {@inheritdoc} + */ + abstract protected function getValue(); +} diff --git a/vendor/predis/predis/lib/Predis/Iterator/MultiBulkResponseSimple.php b/vendor/predis/predis/lib/Predis/Iterator/MultiBulkResponseSimple.php new file mode 100755 index 0000000..f3e7440 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Iterator/MultiBulkResponseSimple.php @@ -0,0 +1,89 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Iterator; + +use Predis\Connection\SingleConnectionInterface; + +/** + * Streams a multibulk reply. + * + * @author Daniele Alessandri + */ +class MultiBulkResponseSimple extends MultiBulkResponse +{ + private $connection; + + /** + * @param SingleConnectionInterface $connection Connection to Redis. + * @param int $size Number of elements of the multibulk reply. + */ + public function __construct(SingleConnectionInterface $connection, $size) + { + $this->connection = $connection; + $this->position = 0; + $this->current = $size > 0 ? $this->getValue() : null; + $this->replySize = $size; + } + + /** + * Handles the synchronization of the client with the Redis protocol + * then PHP's garbage collector kicks in (e.g. then the iterator goes + * out of the scope of a foreach). + */ + public function __destruct() + { + $this->sync(true); + } + + /** + * Synchronizes the client with the queued elements that have not been + * read from the connection by consuming the rest of the multibulk reply, + * or simply by dropping the connection. + * + * @param bool $drop True to synchronize the client by dropping the connection. + * False to synchronize the client by consuming the multibulk reply. + */ + public function sync($drop = false) + { + if ($drop == true) { + if ($this->valid()) { + $this->position = $this->replySize; + $this->connection->disconnect(); + } + } else { + while ($this->valid()) { + $this->next(); + } + } + } + + /** + * Reads the next item of the multibulk reply from the server. + * + * @return mixed + */ + protected function getValue() + { + return $this->connection->read(); + } + + /** + * Returns an iterator that reads the multi-bulk response as + * list of tuples. + * + * @return MultiBulkResponseTuple + */ + public function asTuple() + { + return new MultiBulkResponseTuple($this); + } +} diff --git a/vendor/predis/predis/lib/Predis/Iterator/MultiBulkResponseTuple.php b/vendor/predis/predis/lib/Predis/Iterator/MultiBulkResponseTuple.php new file mode 100755 index 0000000..39d7828 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Iterator/MultiBulkResponseTuple.php @@ -0,0 +1,83 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Iterator; + +/** + * Abstracts the access to a streamable list of tuples represented + * as a multibulk reply that alternates keys and values. + * + * @author Daniele Alessandri + */ +class MultiBulkResponseTuple extends MultiBulkResponse implements \OuterIterator +{ + private $iterator; + + /** + * @param MultiBulkResponseSimple $iterator Multibulk reply iterator. + */ + public function __construct(MultiBulkResponseSimple $iterator) + { + $this->checkPreconditions($iterator); + + $virtualSize = count($iterator) / 2; + $this->iterator = $iterator; + $this->position = $iterator->getPosition(); + $this->current = $virtualSize > 0 ? $this->getValue() : null; + $this->replySize = $virtualSize; + } + + /** + * Checks for valid preconditions. + * + * @param MultiBulkResponseSimple $iterator Multibulk reply iterator. + */ + protected function checkPreconditions(MultiBulkResponseSimple $iterator) + { + if ($iterator->getPosition() !== 0) { + throw new \RuntimeException('Cannot initialize a tuple iterator with an already initiated iterator'); + } + + if (($size = count($iterator)) % 2 !== 0) { + throw new \UnexpectedValueException("Invalid reply size for a tuple iterator [$size]"); + } + } + + /** + * {@inheritdoc} + */ + public function getInnerIterator() + { + return $this->iterator; + } + + /** + * {@inheritdoc} + */ + public function __destruct() + { + $this->iterator->sync(true); + } + + /** + * {@inheritdoc} + */ + protected function getValue() + { + $k = $this->iterator->current(); + $this->iterator->next(); + + $v = $this->iterator->current(); + $this->iterator->next(); + + return array($k, $v); + } +} diff --git a/vendor/predis/predis/lib/Predis/Monitor/MonitorContext.php b/vendor/predis/predis/lib/Predis/Monitor/MonitorContext.php new file mode 100755 index 0000000..73c1bca --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Monitor/MonitorContext.php @@ -0,0 +1,165 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Monitor; + +use Predis\ClientInterface; +use Predis\NotSupportedException; +use Predis\Connection\AggregatedConnectionInterface; + +/** + * Client-side abstraction of a Redis MONITOR context. + * + * @author Daniele Alessandri + */ +class MonitorContext implements \Iterator +{ + private $client; + private $isValid; + private $position; + + /** + * @param ClientInterface $client Client instance used by the context. + */ + public function __construct(ClientInterface $client) + { + $this->checkCapabilities($client); + $this->client = $client; + $this->openContext(); + } + + /** + * Automatically closes the context when PHP's garbage collector kicks in. + */ + public function __destruct() + { + $this->closeContext(); + } + + /** + * Checks if the passed client instance satisfies the required conditions + * needed to initialize a monitor context. + * + * @param ClientInterface $client Client instance used by the context. + */ + private function checkCapabilities(ClientInterface $client) + { + if ($client->getConnection() instanceof AggregatedConnectionInterface) { + throw new NotSupportedException('Cannot initialize a monitor context when using aggregated connections'); + } + if ($client->getProfile()->supportsCommand('monitor') === false) { + throw new NotSupportedException('The current profile does not support the MONITOR command'); + } + } + + /** + * Initializes the context and sends the MONITOR command to the server. + */ + protected function openContext() + { + $this->isValid = true; + $monitor = $this->client->createCommand('monitor'); + $this->client->executeCommand($monitor); + } + + /** + * Closes the context. Internally this is done by disconnecting from server + * since there is no way to terminate the stream initialized by MONITOR. + */ + public function closeContext() + { + $this->client->disconnect(); + $this->isValid = false; + } + + /** + * {@inheritdoc} + */ + public function rewind() + { + // NOOP + } + + /** + * Returns the last message payload retrieved from the server. + * + * @return Object + */ + public function current() + { + return $this->getValue(); + } + + /** + * {@inheritdoc} + */ + public function key() + { + return $this->position; + } + + /** + * {@inheritdoc} + */ + public function next() + { + $this->position++; + } + + /** + * Checks if the the context is still in a valid state to continue. + * + * @return bool + */ + public function valid() + { + return $this->isValid; + } + + /** + * Waits for a new message from the server generated by MONITOR and + * returns it when available. + * + * @return Object + */ + private function getValue() + { + $database = 0; + $client = null; + $event = $this->client->getConnection()->read(); + + $callback = function ($matches) use (&$database, &$client) { + if (2 === $count = count($matches)) { + // Redis <= 2.4 + $database = (int) $matches[1]; + } + + if (4 === $count) { + // Redis >= 2.6 + $database = (int) $matches[2]; + $client = $matches[3]; + } + + return ' '; + }; + + $event = preg_replace_callback('/ \(db (\d+)\) | \[(\d+) (.*?)\] /', $callback, $event, 1); + @list($timestamp, $command, $arguments) = explode(' ', $event, 3); + + return (object) array( + 'timestamp' => (float) $timestamp, + 'database' => $database, + 'client' => $client, + 'command' => substr($command, 1, -1), + 'arguments' => $arguments, + ); + } +} diff --git a/vendor/predis/predis/lib/Predis/NotSupportedException.php b/vendor/predis/predis/lib/Predis/NotSupportedException.php new file mode 100755 index 0000000..631b820 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/NotSupportedException.php @@ -0,0 +1,22 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis; + +/** + * Exception class generated when trying to use features not + * supported by certain classes or abstractions. + * + * @author Daniele Alessandri + */ +class NotSupportedException extends PredisException +{ +} diff --git a/vendor/predis/predis/lib/Predis/Option/AbstractOption.php b/vendor/predis/predis/lib/Predis/Option/AbstractOption.php new file mode 100755 index 0000000..92506cd --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Option/AbstractOption.php @@ -0,0 +1,48 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Option; + +/** + * Implements a client option. + * + * @author Daniele Alessandri + */ +abstract class AbstractOption implements OptionInterface +{ + /** + * {@inheritdoc} + */ + public function filter(ClientOptionsInterface $options, $value) + { + return $value; + } + + /** + * {@inheritdoc} + */ + public function getDefault(ClientOptionsInterface $options) + { + return null; + } + + /** + * {@inheritdoc} + */ + public function __invoke(ClientOptionsInterface $options, $value) + { + if (isset($value)) { + return $this->filter($options, $value); + } + + return $this->getDefault($options); + } +} diff --git a/vendor/predis/predis/lib/Predis/Option/ClientCluster.php b/vendor/predis/predis/lib/Predis/Option/ClientCluster.php new file mode 100755 index 0000000..fca9796 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Option/ClientCluster.php @@ -0,0 +1,96 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Option; + +use Predis\Connection\ClusterConnectionInterface; +use Predis\Connection\PredisCluster; +use Predis\Connection\RedisCluster; + +/** + * Option class that returns a connection cluster to be used by a client. + * + * @author Daniele Alessandri + */ +class ClientCluster extends AbstractOption +{ + /** + * Checks if the specified value is a valid instance of ClusterConnectionInterface. + * + * @param ClusterConnectionInterface $cluster Instance of a connection cluster. + * @return ClusterConnectionInterface + */ + protected function checkInstance($cluster) + { + if (!$cluster instanceof ClusterConnectionInterface) { + throw new \InvalidArgumentException('Instance of Predis\Connection\ClusterConnectionInterface expected'); + } + + return $cluster; + } + + /** + * {@inheritdoc} + */ + public function filter(ClientOptionsInterface $options, $value) + { + if (is_callable($value)) { + return $this->checkInstance(call_user_func($value, $options, $this)); + } + + $initializer = $this->getInitializer($options, $value); + + return $this->checkInstance($initializer()); + } + + /** + * Returns an initializer for the specified FQN or type. + * + * @param string $fqnOrType Type of cluster or FQN of a class implementing ClusterConnectionInterface. + * @param ClientOptionsInterface $options Instance of the client options. + * @return \Closure + */ + protected function getInitializer(ClientOptionsInterface $options, $fqnOrType) + { + switch ($fqnOrType) { + case 'predis': + return function () { + return new PredisCluster(); + }; + + case 'redis': + return function () use ($options) { + $connectionFactory = $options->connections; + $cluster = new RedisCluster($connectionFactory); + + return $cluster; + }; + + default: + // TODO: we should not even allow non-string values here. + if (is_string($fqnOrType) && !class_exists($fqnOrType)) { + throw new \InvalidArgumentException("Class $fqnOrType does not exist"); + } + + return function () use ($fqnOrType) { + return new $fqnOrType(); + }; + } + } + + /** + * {@inheritdoc} + */ + public function getDefault(ClientOptionsInterface $options) + { + return new PredisCluster(); + } +} diff --git a/vendor/predis/predis/lib/Predis/Option/ClientConnectionFactory.php b/vendor/predis/predis/lib/Predis/Option/ClientConnectionFactory.php new file mode 100755 index 0000000..e671e52 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Option/ClientConnectionFactory.php @@ -0,0 +1,73 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Option; + +use Predis\Connection\ConnectionFactory; +use Predis\Connection\ConnectionFactoryInterface; + +/** + * Option class that returns a connection factory to be used by a client. + * + * @author Daniele Alessandri + */ +class ClientConnectionFactory extends AbstractOption +{ + /** + * {@inheritdoc} + */ + public function filter(ClientOptionsInterface $options, $value) + { + if ($value instanceof ConnectionFactoryInterface) { + return $value; + } + + if (is_array($value)) { + $factory = $this->getDefault($options); + + foreach ($value as $scheme => $initializer) { + $factory->define($scheme, $initializer); + } + + return $factory; + } + + if (is_callable($value)) { + $factory = call_user_func($value, $options, $this); + + if (!$factory instanceof ConnectionFactoryInterface) { + throw new \InvalidArgumentException('Instance of Predis\Connection\ConnectionFactoryInterface expected'); + } + + return $factory; + } + + if (@class_exists($value)) { + $factory = new $value(); + + if (!$factory instanceof ConnectionFactoryInterface) { + throw new \InvalidArgumentException("Class $value must be an instance of Predis\Connection\ConnectionFactoryInterface"); + } + + return $factory; + } + + throw new \InvalidArgumentException('Invalid value for the connections option'); + } + + /** + * {@inheritdoc} + */ + public function getDefault(ClientOptionsInterface $options) + { + return new ConnectionFactory($options->profile); + } +} diff --git a/vendor/predis/predis/lib/Predis/Option/ClientExceptions.php b/vendor/predis/predis/lib/Predis/Option/ClientExceptions.php new file mode 100755 index 0000000..ad422da --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Option/ClientExceptions.php @@ -0,0 +1,36 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Option; + +/** + * Option class used to specify if the client should throw server exceptions. + * + * @author Daniele Alessandri + */ +class ClientExceptions extends AbstractOption +{ + /** + * {@inheritdoc} + */ + public function filter(ClientOptionsInterface $options, $value) + { + return (bool) $value; + } + + /** + * {@inheritdoc} + */ + public function getDefault(ClientOptionsInterface $options) + { + return true; + } +} diff --git a/vendor/predis/predis/lib/Predis/Option/ClientOptions.php b/vendor/predis/predis/lib/Predis/Option/ClientOptions.php new file mode 100755 index 0000000..e579041 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Option/ClientOptions.php @@ -0,0 +1,125 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Option; + +/** + * Class that manages client options with filtering and conversion. + * + * @author Daniele Alessandri + */ +class ClientOptions implements ClientOptionsInterface +{ + private $handlers; + private $defined; + private $options = array(); + + /** + * @param array $options Array of client options. + */ + public function __construct(Array $options = array()) + { + $this->handlers = $this->initialize($options); + $this->defined = array_fill_keys(array_keys($options), true); + } + + /** + * Ensures that the default options are initialized. + * + * @return array + */ + protected function getDefaultOptions() + { + return array( + 'profile' => new ClientProfile(), + 'connections' => new ClientConnectionFactory(), + 'cluster' => new ClientCluster(), + 'replication' => new ClientReplication(), + 'prefix' => new ClientPrefix(), + 'exceptions' => new ClientExceptions(), + ); + } + + /** + * Initializes client options handlers. + * + * @param array $options List of client options values. + * @return array + */ + protected function initialize(Array $options) + { + $handlers = $this->getDefaultOptions(); + + foreach ($options as $option => $value) { + if (isset($handlers[$option])) { + $handler = $handlers[$option]; + $handlers[$option] = function ($options) use ($handler, $value) { + return $handler->filter($options, $value); + }; + } else { + $this->options[$option] = $value; + } + } + + return $handlers; + } + + /** + * Checks if the specified option is set. + * + * @param string $option Name of the option. + * @return bool + */ + public function __isset($option) + { + return isset($this->defined[$option]); + } + + /** + * Returns the value of the specified option. + * + * @param string $option Name of the option. + * @return mixed + */ + public function __get($option) + { + if (isset($this->options[$option])) { + return $this->options[$option]; + } + + if (isset($this->handlers[$option])) { + $handler = $this->handlers[$option]; + $value = $handler instanceof OptionInterface ? $handler->getDefault($this) : $handler($this); + $this->options[$option] = $value; + + return $value; + } + } + + /** + * Returns the default value for the specified option. + * + * @param string|OptionInterface $option Name or instance of the option. + * @return mixed + */ + public function getDefault($option) + { + if ($option instanceof OptionInterface) { + return $option->getDefault($this); + } + + $options = $this->getDefaultOptions(); + + if (isset($options[$option])) { + return $options[$option]->getDefault($this); + } + } +} diff --git a/vendor/predis/predis/lib/Predis/Option/ClientOptionsInterface.php b/vendor/predis/predis/lib/Predis/Option/ClientOptionsInterface.php new file mode 100755 index 0000000..543e18a --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Option/ClientOptionsInterface.php @@ -0,0 +1,21 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Option; + +/** + * Marker interface defining a client options bag. + * + * @author Daniele Alessandri + */ +interface ClientOptionsInterface +{ +} diff --git a/vendor/predis/predis/lib/Predis/Option/ClientPrefix.php b/vendor/predis/predis/lib/Predis/Option/ClientPrefix.php new file mode 100755 index 0000000..01a166a --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Option/ClientPrefix.php @@ -0,0 +1,30 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Option; + +use Predis\Command\Processor\KeyPrefixProcessor; + +/** + * Option class that handles the prefixing of keys in commands. + * + * @author Daniele Alessandri + */ +class ClientPrefix extends AbstractOption +{ + /** + * {@inheritdoc} + */ + public function filter(ClientOptionsInterface $options, $value) + { + return new KeyPrefixProcessor($value); + } +} diff --git a/vendor/predis/predis/lib/Predis/Option/ClientProfile.php b/vendor/predis/predis/lib/Predis/Option/ClientProfile.php new file mode 100755 index 0000000..660066d --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Option/ClientProfile.php @@ -0,0 +1,61 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Option; + +use Predis\Profile\ServerProfile; +use Predis\Profile\ServerProfileInterface; + +/** + * Option class that handles server profiles to be used by a client. + * + * @author Daniele Alessandri + */ +class ClientProfile extends AbstractOption +{ + /** + * {@inheritdoc} + */ + public function filter(ClientOptionsInterface $options, $value) + { + if (is_string($value)) { + $value = ServerProfile::get($value); + + if (isset($options->prefix)) { + $value->setProcessor($options->prefix); + } + } + + if (is_callable($value)) { + $value = call_user_func($value, $options, $this); + } + + if (!$value instanceof ServerProfileInterface) { + throw new \InvalidArgumentException('Invalid value for the profile option'); + } + + return $value; + } + + /** + * {@inheritdoc} + */ + public function getDefault(ClientOptionsInterface $options) + { + $profile = ServerProfile::getDefault(); + + if (isset($options->prefix)) { + $profile->setProcessor($options->prefix); + } + + return $profile; + } +} diff --git a/vendor/predis/predis/lib/Predis/Option/ClientReplication.php b/vendor/predis/predis/lib/Predis/Option/ClientReplication.php new file mode 100755 index 0000000..ad70308 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Option/ClientReplication.php @@ -0,0 +1,78 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Option; + +use Predis\Connection\MasterSlaveReplication; +use Predis\Connection\ReplicationConnectionInterface; + +/** + * Option class that returns a replication connection be used by a client. + * + * @author Daniele Alessandri + */ +class ClientReplication extends AbstractOption +{ + /** + * Checks if the specified value is a valid instance of ReplicationConnectionInterface. + * + * @param ReplicationConnectionInterface $connection Instance of a replication connection. + * @return ReplicationConnectionInterface + */ + protected function checkInstance($connection) + { + if (!$connection instanceof ReplicationConnectionInterface) { + throw new \InvalidArgumentException('Instance of Predis\Connection\ReplicationConnectionInterface expected'); + } + + return $connection; + } + + /** + * {@inheritdoc} + */ + public function filter(ClientOptionsInterface $options, $value) + { + if (is_callable($value)) { + $connection = call_user_func($value, $options, $this); + + if (!$connection instanceof ReplicationConnectionInterface) { + throw new \InvalidArgumentException('Instance of Predis\Connection\ReplicationConnectionInterface expected'); + } + + return $connection; + } + + if (is_string($value)) { + if (!class_exists($value)) { + throw new \InvalidArgumentException("Class $value does not exist"); + } + + if (!($connection = new $value()) instanceof ReplicationConnectionInterface) { + throw new \InvalidArgumentException('Instance of Predis\Connection\ReplicationConnectionInterface expected'); + } + + return $connection; + } + + if ($value == true) { + return $this->getDefault($options); + } + } + + /** + * {@inheritdoc} + */ + public function getDefault(ClientOptionsInterface $options) + { + return new MasterSlaveReplication(); + } +} diff --git a/vendor/predis/predis/lib/Predis/Option/CustomOption.php b/vendor/predis/predis/lib/Predis/Option/CustomOption.php new file mode 100755 index 0000000..848c8b9 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Option/CustomOption.php @@ -0,0 +1,89 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Option; + +/** + * Implements a generic class used to dynamically define a client option. + * + * @author Daniele Alessandri + */ +class CustomOption implements OptionInterface +{ + private $filter; + private $default; + + /** + * @param array $options List of options + */ + public function __construct(Array $options = array()) + { + $this->filter = $this->ensureCallable($options, 'filter'); + $this->default = $this->ensureCallable($options, 'default'); + } + + /** + * Checks if the specified value in the options array is a callable object. + * + * @param array $options Array of options + * @param string $key Target option. + */ + private function ensureCallable($options, $key) + { + if (!isset($options[$key])) { + return; + } + + if (is_callable($callable = $options[$key])) { + return $callable; + } + + throw new \InvalidArgumentException("The parameter $key must be callable"); + } + + /** + * {@inheritdoc} + */ + public function filter(ClientOptionsInterface $options, $value) + { + if (isset($value)) { + if ($this->filter === null) { + return $value; + } + + return call_user_func($this->filter, $options, $value); + } + } + + /** + * {@inheritdoc} + */ + public function getDefault(ClientOptionsInterface $options) + { + if (!isset($this->default)) { + return; + } + + return call_user_func($this->default, $options); + } + + /** + * {@inheritdoc} + */ + public function __invoke(ClientOptionsInterface $options, $value) + { + if (isset($value)) { + return $this->filter($options, $value); + } + + return $this->getDefault($options); + } +} diff --git a/vendor/predis/predis/lib/Predis/Option/OptionInterface.php b/vendor/predis/predis/lib/Predis/Option/OptionInterface.php new file mode 100755 index 0000000..29e8165 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Option/OptionInterface.php @@ -0,0 +1,47 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Option; + +/** + * Interface that defines a client option. + * + * @author Daniele Alessandri + */ +interface OptionInterface +{ + /** + * Filters (and optionally converts) the passed value. + * + * @param ClientOptionsInterface $options Options container. + * @param mixed $value Input value. + * @return mixed + */ + public function filter(ClientOptionsInterface $options, $value); + + /** + * Returns a default value for the option. + * + * @param ClientOptionsInterface $options Options container. + * @return mixed + */ + public function getDefault(ClientOptionsInterface $options); + + /** + * Filters a value and, if no value is specified, returns the default one + * defined by the option. + * + * @param ClientOptionsInterface $options Options container. + * @param mixed $value Input value. + * @return mixed + */ + public function __invoke(ClientOptionsInterface $options, $value); +} diff --git a/vendor/predis/predis/lib/Predis/Pipeline/FireAndForgetExecutor.php b/vendor/predis/predis/lib/Predis/Pipeline/FireAndForgetExecutor.php new file mode 100755 index 0000000..3e04799 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Pipeline/FireAndForgetExecutor.php @@ -0,0 +1,55 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Pipeline; + +use SplQueue; +use Predis\Connection\ConnectionInterface; +use Predis\Connection\ReplicationConnectionInterface; + +/** + * Implements a pipeline executor strategy that writes a list of commands to + * the connection object but does not read back their replies. + * + * @author Daniele Alessandri + */ +class FireAndForgetExecutor implements PipelineExecutorInterface +{ + /** + * Allows the pipeline executor to perform operations on the + * connection before starting to execute the commands stored + * in the pipeline. + * + * @param ConnectionInterface $connection Connection instance. + */ + protected function checkConnection(ConnectionInterface $connection) + { + if ($connection instanceof ReplicationConnectionInterface) { + $connection->switchTo('master'); + } + } + + /** + * {@inheritdoc} + */ + public function execute(ConnectionInterface $connection, SplQueue $commands) + { + $this->checkConnection($connection); + + while (!$commands->isEmpty()) { + $connection->writeCommand($commands->dequeue()); + } + + $connection->disconnect(); + + return array(); + } +} diff --git a/vendor/predis/predis/lib/Predis/Pipeline/MultiExecExecutor.php b/vendor/predis/predis/lib/Predis/Pipeline/MultiExecExecutor.php new file mode 100755 index 0000000..5f6c09e --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Pipeline/MultiExecExecutor.php @@ -0,0 +1,168 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Pipeline; + +use Iterator; +use SplQueue; +use Predis\ClientException; +use Predis\ResponseErrorInterface; +use Predis\ResponseObjectInterface; +use Predis\ServerException; +use Predis\Connection\ConnectionInterface; +use Predis\Connection\SingleConnectionInterface; +use Predis\Profile\ServerProfile; +use Predis\Profile\ServerProfileInterface; + +/** + * Implements a pipeline executor that wraps the whole pipeline + * in a MULTI / EXEC context to make sure that it is executed + * correctly. + * + * @author Daniele Alessandri + */ +class MultiExecExecutor implements PipelineExecutorInterface +{ + protected $profile; + + /** + * + */ + public function __construct(ServerProfileInterface $profile = null) + { + $this->setProfile($profile ?: ServerProfile::getDefault()); + } + + /** + * Allows the pipeline executor to perform operations on the + * connection before starting to execute the commands stored + * in the pipeline. + * + * @param ConnectionInterface $connection Connection instance. + */ + protected function checkConnection(ConnectionInterface $connection) + { + if (!$connection instanceof SingleConnectionInterface) { + $class = __CLASS__; + throw new ClientException("$class can be used only with single connections"); + } + } + + /** + * {@inheritdoc} + */ + public function execute(ConnectionInterface $connection, SplQueue $commands) + { + $this->checkConnection($connection); + + $cmd = $this->profile->createCommand('multi'); + $connection->executeCommand($cmd); + + foreach ($commands as $command) { + $connection->writeCommand($command); + } + + foreach ($commands as $command) { + $response = $connection->readResponse($command); + + if ($response instanceof ResponseErrorInterface) { + $cmd = $this->profile->createCommand('discard'); + $connection->executeCommand($cmd); + + throw new ServerException($response->getMessage()); + } + } + + $cmd = $this->profile->createCommand('exec'); + $responses = $connection->executeCommand($cmd); + + if (!isset($responses)) { + throw new ClientException('The underlying transaction has been aborted by the server'); + } + + if (count($responses) !== count($commands)) { + throw new ClientException("Invalid number of replies [expected: ".count($commands)." - actual: ".count($responses)."]"); + } + + $consumer = $responses instanceof Iterator ? 'consumeIteratorResponse' : 'consumeArrayResponse'; + + return $this->$consumer($commands, $responses); + } + + /** + * Consumes an iterator response returned by EXEC. + * + * @param SplQueue $commands Pipelined commands + * @param Iterator $responses Responses returned by EXEC. + * @return array + */ + protected function consumeIteratorResponse(SplQueue $commands, Iterator $responses) + { + $values = array(); + + foreach ($responses as $response) { + $command = $commands->dequeue(); + + if ($response instanceof ResponseObjectInterface) { + if ($response instanceof Iterator) { + $response = iterator_to_array($response); + $values[] = $command->parseResponse($response); + } else { + $values[] = $response; + } + } else { + $values[] = $command->parseResponse($response); + } + } + + return $values; + } + + /** + * Consumes an array response returned by EXEC. + * + * @param SplQueue $commands Pipelined commands + * @param Array $responses Responses returned by EXEC. + * @return array + */ + protected function consumeArrayResponse(SplQueue $commands, Array &$responses) + { + $size = count($commands); + $values = array(); + + for ($i = 0; $i < $size; $i++) { + $command = $commands->dequeue(); + $response = $responses[$i]; + + if ($response instanceof ResponseObjectInterface) { + $values[$i] = $response; + } else { + $values[$i] = $command->parseResponse($response); + } + + unset($responses[$i]); + } + + return $values; + } + + /** + * @param ServerProfileInterface $profile Server profile. + */ + public function setProfile(ServerProfileInterface $profile) + { + if (!$profile->supportsCommands(array('multi', 'exec', 'discard'))) { + throw new ClientException('The specified server profile must support MULTI, EXEC and DISCARD.'); + } + + $this->profile = $profile; + } +} diff --git a/vendor/predis/predis/lib/Predis/Pipeline/PipelineContext.php b/vendor/predis/predis/lib/Predis/Pipeline/PipelineContext.php new file mode 100755 index 0000000..ce14a0c --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Pipeline/PipelineContext.php @@ -0,0 +1,189 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Pipeline; + +use SplQueue; +use Predis\BasicClientInterface; +use Predis\ClientException; +use Predis\ClientInterface; +use Predis\ExecutableContextInterface; +use Predis\Command\CommandInterface; + +/** + * Abstraction of a pipeline context where write and read operations + * of commands and their replies over the network are pipelined. + * + * @author Daniele Alessandri + */ +class PipelineContext implements BasicClientInterface, ExecutableContextInterface +{ + private $client; + private $executor; + private $pipeline; + + private $replies = array(); + private $running = false; + + /** + * @param ClientInterface $client Client instance used by the context. + * @param PipelineExecutorInterface $executor Pipeline executor instace. + */ + public function __construct(ClientInterface $client, PipelineExecutorInterface $executor = null) + { + $this->client = $client; + $this->executor = $executor ?: $this->createExecutor($client); + $this->pipeline = new SplQueue(); + } + + /** + * Returns a pipeline executor depending on the kind of the underlying + * connection and the passed options. + * + * @param ClientInterface $client Client instance used by the context. + * @return PipelineExecutorInterface + */ + protected function createExecutor(ClientInterface $client) + { + $options = $client->getOptions(); + + if (isset($options->exceptions)) { + return new StandardExecutor($options->exceptions); + } + + return new StandardExecutor(); + } + + /** + * Queues a command into the pipeline buffer. + * + * @param string $method Command ID. + * @param array $arguments Arguments for the command. + * @return $this + */ + public function __call($method, $arguments) + { + $command = $this->client->createCommand($method, $arguments); + $this->recordCommand($command); + + return $this; + } + + /** + * Queues a command instance into the pipeline buffer. + * + * @param CommandInterface $command Command to queue in the buffer. + */ + protected function recordCommand(CommandInterface $command) + { + $this->pipeline->enqueue($command); + } + + /** + * Queues a command instance into the pipeline buffer. + * + * @param CommandInterface $command Command to queue in the buffer. + * @return $this + */ + public function executeCommand(CommandInterface $command) + { + $this->recordCommand($command); + + return $this; + } + + /** + * Flushes the buffer that holds the queued commands. + * + * @param bool $send Specifies if the commands in the buffer should be sent to Redis. + * @return PipelineContext + */ + public function flushPipeline($send = true) + { + if ($send && !$this->pipeline->isEmpty()) { + $connection = $this->client->getConnection(); + $replies = $this->executor->execute($connection, $this->pipeline); + $this->replies = array_merge($this->replies, $replies); + } else { + $this->pipeline = new SplQueue(); + } + + return $this; + } + + /** + * Marks the running status of the pipeline. + * + * @param bool $bool True if the pipeline is running. + * False if the pipeline is not running. + */ + private function setRunning($bool) + { + if ($bool === true && $this->running === true) { + throw new ClientException("This pipeline is already opened"); + } + + $this->running = $bool; + } + + /** + * Handles the actual execution of the whole pipeline. + * + * @param mixed $callable Optional callback for execution. + * @return array + */ + public function execute($callable = null) + { + if ($callable && !is_callable($callable)) { + throw new \InvalidArgumentException('Argument passed must be a callable object'); + } + + $this->setRunning(true); + $pipelineBlockException = null; + + try { + if ($callable !== null) { + call_user_func($callable, $this); + } + $this->flushPipeline(); + } catch (\Exception $exception) { + $pipelineBlockException = $exception; + } + + $this->setRunning(false); + + if ($pipelineBlockException !== null) { + throw $pipelineBlockException; + } + + return $this->replies; + } + + /** + * Returns the underlying client instance used by the pipeline object. + * + * @return ClientInterface + */ + public function getClient() + { + return $this->client; + } + + /** + * Returns the underlying pipeline executor used by the pipeline object. + * + * @return PipelineExecutorInterface + */ + public function getExecutor() + { + return $this->executor; + } +} diff --git a/vendor/predis/predis/lib/Predis/Pipeline/PipelineExecutorInterface.php b/vendor/predis/predis/lib/Predis/Pipeline/PipelineExecutorInterface.php new file mode 100755 index 0000000..74b7d41 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Pipeline/PipelineExecutorInterface.php @@ -0,0 +1,33 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Pipeline; + +use SplQueue; +use Predis\Connection\ConnectionInterface; + +/** + * Defines a strategy to write a list of commands to the network + * and read back their replies. + * + * @author Daniele Alessandri + */ +interface PipelineExecutorInterface +{ + /** + * Writes a list of commands to the network and reads back their replies. + * + * @param ConnectionInterface $connection Connection to Redis. + * @param SplQueue $commands Commands queued for execution. + * @return array + */ + public function execute(ConnectionInterface $connection, SplQueue $commands); +} diff --git a/vendor/predis/predis/lib/Predis/Pipeline/SafeClusterExecutor.php b/vendor/predis/predis/lib/Predis/Pipeline/SafeClusterExecutor.php new file mode 100755 index 0000000..b362230 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Pipeline/SafeClusterExecutor.php @@ -0,0 +1,72 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Pipeline; + +use SplQueue; +use Predis\CommunicationException; +use Predis\Connection\ConnectionInterface; + +/** + * Implements a pipeline executor strategy for connection clusters that does + * not fail when an error is encountered, but adds the returned error in the + * replies array. + * + * @author Daniele Alessandri + */ +class SafeClusterExecutor implements PipelineExecutorInterface +{ + /** + * {@inheritdoc} + */ + public function execute(ConnectionInterface $connection, SplQueue $commands) + { + $size = count($commands); + $values = array(); + $connectionExceptions = array(); + + foreach ($commands as $command) { + $cmdConnection = $connection->getConnection($command); + + if (isset($connectionExceptions[spl_object_hash($cmdConnection)])) { + continue; + } + + try { + $cmdConnection->writeCommand($command); + } catch (CommunicationException $exception) { + $connectionExceptions[spl_object_hash($cmdConnection)] = $exception; + } + } + + for ($i = 0; $i < $size; $i++) { + $command = $commands->dequeue(); + + $cmdConnection = $connection->getConnection($command); + $connectionObjectHash = spl_object_hash($cmdConnection); + + if (isset($connectionExceptions[$connectionObjectHash])) { + $values[$i] = $connectionExceptions[$connectionObjectHash]; + continue; + } + + try { + $response = $cmdConnection->readResponse($command); + $values[$i] = $response instanceof \Iterator ? iterator_to_array($response) : $response; + } catch (CommunicationException $exception) { + $values[$i] = $exception; + $connectionExceptions[$connectionObjectHash] = $exception; + } + } + + return $values; + } +} diff --git a/vendor/predis/predis/lib/Predis/Pipeline/SafeExecutor.php b/vendor/predis/predis/lib/Predis/Pipeline/SafeExecutor.php new file mode 100755 index 0000000..2d693c0 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Pipeline/SafeExecutor.php @@ -0,0 +1,57 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Pipeline; + +use SplQueue; +use Predis\CommunicationException; +use Predis\Connection\ConnectionInterface; + +/** + * Implements a pipeline executor strategy that does not fail when an error is + * encountered, but adds the returned error in the replies array. + * + * @author Daniele Alessandri + */ +class SafeExecutor implements PipelineExecutorInterface +{ + /** + * {@inheritdoc} + */ + public function execute(ConnectionInterface $connection, SplQueue $commands) + { + $size = count($commands); + $values = array(); + + foreach ($commands as $command) { + try { + $connection->writeCommand($command); + } catch (CommunicationException $exception) { + return array_fill(0, $size, $exception); + } + } + + for ($i = 0; $i < $size; $i++) { + $command = $commands->dequeue(); + + try { + $response = $connection->readResponse($command); + $values[$i] = $response instanceof \Iterator ? iterator_to_array($response) : $response; + } catch (CommunicationException $exception) { + $toAdd = count($commands) - count($values); + $values = array_merge($values, array_fill(0, $toAdd, $exception)); + break; + } + } + + return $values; + } +} diff --git a/vendor/predis/predis/lib/Predis/Pipeline/StandardExecutor.php b/vendor/predis/predis/lib/Predis/Pipeline/StandardExecutor.php new file mode 100755 index 0000000..dd1e043 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Pipeline/StandardExecutor.php @@ -0,0 +1,123 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Pipeline; + +use Iterator; +use SplQueue; +use Predis\ResponseErrorInterface; +use Predis\ResponseObjectInterface; +use Predis\ServerException; +use Predis\Command\CommandInterface; +use Predis\Connection\ConnectionInterface; +use Predis\Connection\ReplicationConnectionInterface; + +/** + * Implements the standard pipeline executor strategy used + * to write a list of commands and read their replies over + * a connection to Redis. + * + * @author Daniele Alessandri + */ +class StandardExecutor implements PipelineExecutorInterface +{ + protected $exceptions; + + /** + * @param bool $exceptions Specifies if the executor should throw exceptions on server errors. + */ + public function __construct($exceptions = true) + { + $this->exceptions = (bool) $exceptions; + } + + /** + * Allows the pipeline executor to perform operations on the + * connection before starting to execute the commands stored + * in the pipeline. + * + * @param ConnectionInterface $connection Connection instance. + */ + protected function checkConnection(ConnectionInterface $connection) + { + if ($connection instanceof ReplicationConnectionInterface) { + $connection->switchTo('master'); + } + } + + /** + * Handles a response object. + * + * @param ConnectionInterface $connection + * @param CommandInterface $command + * @param ResponseObjectInterface $response + * @return mixed + */ + protected function onResponseObject(ConnectionInterface $connection, CommandInterface $command, ResponseObjectInterface $response) + { + if ($response instanceof ResponseErrorInterface) { + return $this->onResponseError($connection, $response); + } + + if ($response instanceof Iterator) { + return $command->parseResponse(iterator_to_array($response)); + } + + return $response; + } + + /** + * Handles -ERR responses returned by Redis. + * + * @param ConnectionInterface $connection The connection that returned the error. + * @param ResponseErrorInterface $response The error response instance. + * @return ResponseErrorInterface + */ + protected function onResponseError(ConnectionInterface $connection, ResponseErrorInterface $response) + { + if (!$this->exceptions) { + return $response; + } + + // Force disconnection to prevent protocol desynchronization. + $connection->disconnect(); + $message = $response->getMessage(); + + throw new ServerException($message); + } + + /** + * {@inheritdoc} + */ + public function execute(ConnectionInterface $connection, SplQueue $commands) + { + $this->checkConnection($connection); + + foreach ($commands as $command) { + $connection->writeCommand($command); + } + + $values = array(); + + while (!$commands->isEmpty()) { + $command = $commands->dequeue(); + $response = $connection->readResponse($command); + + if ($response instanceof ResponseObjectInterface) { + $values[] = $this->onResponseObject($connection, $command, $response); + } else { + $values[] = $command->parseResponse($response); + } + } + + return $values; + } +} diff --git a/vendor/predis/predis/lib/Predis/PredisException.php b/vendor/predis/predis/lib/Predis/PredisException.php new file mode 100755 index 0000000..122bde1 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/PredisException.php @@ -0,0 +1,21 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis; + +/** + * Base exception class for Predis-related errors. + * + * @author Daniele Alessandri + */ +abstract class PredisException extends \Exception +{ +} diff --git a/vendor/predis/predis/lib/Predis/Profile/ServerProfile.php b/vendor/predis/predis/lib/Predis/Profile/ServerProfile.php new file mode 100755 index 0000000..75462fa --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Profile/ServerProfile.php @@ -0,0 +1,228 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Profile; + +use Predis\ClientException; +use Predis\Command\Processor\CommandProcessingInterface; +use Predis\Command\Processor\CommandProcessorInterface; + +/** + * Base class that implements common functionalities of server profiles. + * + * @author Daniele Alessandri + */ +abstract class ServerProfile implements ServerProfileInterface, CommandProcessingInterface +{ + private static $profiles; + + private $commands; + private $processor; + + /** + * + */ + public function __construct() + { + $this->commands = $this->getSupportedCommands(); + } + + /** + * Returns a map of all the commands supported by the profile and their + * actual PHP classes. + * + * @return array + */ + abstract protected function getSupportedCommands(); + + /** + * Returns the default server profile. + * + * @return ServerProfileInterface + */ + public static function getDefault() + { + return self::get('default'); + } + + /** + * Returns the development server profile. + * + * @return ServerProfileInterface + */ + public static function getDevelopment() + { + return self::get('dev'); + } + + /** + * Returns a map of all the server profiles supported by default and their + * actual PHP classes. + * + * @return array + */ + private static function getDefaultProfiles() + { + return array( + '1.2' => 'Predis\Profile\ServerVersion12', + '2.0' => 'Predis\Profile\ServerVersion20', + '2.2' => 'Predis\Profile\ServerVersion22', + '2.4' => 'Predis\Profile\ServerVersion24', + '2.6' => 'Predis\Profile\ServerVersion26', + '2.8' => 'Predis\Profile\ServerVersion28', + 'default' => 'Predis\Profile\ServerVersion26', + 'dev' => 'Predis\Profile\ServerVersionNext', + ); + } + + /** + * Registers a new server profile. + * + * @param string $alias Profile version or alias. + * @param string $profileClass FQN of a class implementing Predis\Profile\ServerProfileInterface. + */ + public static function define($alias, $profileClass) + { + if (!isset(self::$profiles)) { + self::$profiles = self::getDefaultProfiles(); + } + + $profileReflection = new \ReflectionClass($profileClass); + + if (!$profileReflection->isSubclassOf('Predis\Profile\ServerProfileInterface')) { + throw new \InvalidArgumentException("Cannot register '$profileClass' as it is not a valid profile class"); + } + + self::$profiles[$alias] = $profileClass; + } + + /** + * Returns the specified server profile. + * + * @param string $version Profile version or alias. + * @return ServerProfileInterface + */ + public static function get($version) + { + if (!isset(self::$profiles)) { + self::$profiles = self::getDefaultProfiles(); + } + + if (!isset(self::$profiles[$version])) { + throw new ClientException("Unknown server profile: $version"); + } + + $profile = self::$profiles[$version]; + + return new $profile(); + } + + /** + * {@inheritdoc} + */ + public function supportsCommands(Array $commands) + { + foreach ($commands as $command) { + if (!$this->supportsCommand($command)) { + return false; + } + } + + return true; + } + + /** + * {@inheritdoc} + */ + public function supportsCommand($command) + { + return isset($this->commands[strtolower($command)]); + } + + /** + * Returns the FQN of the class that represent the specified command ID + * registered in the current server profile. + * + * @param string $command Command ID. + * @return string + */ + public function getCommandClass($command) + { + if (isset($this->commands[$command = strtolower($command)])) { + return $this->commands[$command]; + } + } + + /** + * {@inheritdoc} + */ + public function createCommand($method, $arguments = array()) + { + $method = strtolower($method); + + if (!isset($this->commands[$method])) { + throw new ClientException("'$method' is not a registered Redis command"); + } + + $commandClass = $this->commands[$method]; + $command = new $commandClass(); + $command->setArguments($arguments); + + if (isset($this->processor)) { + $this->processor->process($command); + } + + return $command; + } + + /** + * Defines a new commands in the server profile. + * + * @param string $alias Command ID. + * @param string $command FQN of a class implementing Predis\Command\CommandInterface. + */ + public function defineCommand($alias, $command) + { + $commandReflection = new \ReflectionClass($command); + + if (!$commandReflection->isSubclassOf('Predis\Command\CommandInterface')) { + throw new \InvalidArgumentException("Cannot register '$command' as it is not a valid Redis command"); + } + + $this->commands[strtolower($alias)] = $command; + } + + /** + * {@inheritdoc} + */ + public function setProcessor(CommandProcessorInterface $processor = null) + { + $this->processor = $processor; + } + + /** + * {@inheritdoc} + */ + public function getProcessor() + { + return $this->processor; + } + + /** + * Returns the version of server profile as its string representation. + * + * @return string + */ + public function __toString() + { + return $this->getVersion(); + } +} diff --git a/vendor/predis/predis/lib/Predis/Profile/ServerProfileInterface.php b/vendor/predis/predis/lib/Predis/Profile/ServerProfileInterface.php new file mode 100755 index 0000000..ea9a8a0 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Profile/ServerProfileInterface.php @@ -0,0 +1,56 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Profile; + +use Predis\Command\CommandInterface; + +/** + * A server profile defines features and commands supported by certain + * versions of Redis. Instances of Predis\Client should use a server + * profile matching the version of Redis in use. + * + * @author Daniele Alessandri + */ +interface ServerProfileInterface +{ + /** + * Gets a profile version corresponding to a Redis version. + * + * @return string + */ + public function getVersion(); + + /** + * Checks if the profile supports the specified command. + * + * @param string $command Command ID. + * @return bool + */ + public function supportsCommand($command); + + /** + * Checks if the profile supports the specified list of commands. + * + * @param array $commands List of command IDs. + * @return string + */ + public function supportsCommands(Array $commands); + + /** + * Creates a new command instance. + * + * @param string $method Command ID. + * @param array $arguments Arguments for the command. + * @return CommandInterface + */ + public function createCommand($method, $arguments = array()); +} diff --git a/vendor/predis/predis/lib/Predis/Profile/ServerVersion12.php b/vendor/predis/predis/lib/Predis/Profile/ServerVersion12.php new file mode 100755 index 0000000..4e339a7 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Profile/ServerVersion12.php @@ -0,0 +1,125 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Profile; + +/** + * Server profile for Redis v1.2.x. + * + * @author Daniele Alessandri + */ +class ServerVersion12 extends ServerProfile +{ + /** + * {@inheritdoc} + */ + public function getVersion() + { + return '1.2'; + } + + /** + * {@inheritdoc} + */ + public function getSupportedCommands() + { + return array( + /* ---------------- Redis 1.2 ---------------- */ + + /* commands operating on the key space */ + 'exists' => 'Predis\Command\KeyExists', + 'del' => 'Predis\Command\KeyDelete', + 'type' => 'Predis\Command\KeyType', + 'keys' => 'Predis\Command\KeyKeysV12x', + 'randomkey' => 'Predis\Command\KeyRandom', + 'rename' => 'Predis\Command\KeyRename', + 'renamenx' => 'Predis\Command\KeyRenamePreserve', + 'expire' => 'Predis\Command\KeyExpire', + 'expireat' => 'Predis\Command\KeyExpireAt', + 'ttl' => 'Predis\Command\KeyTimeToLive', + 'move' => 'Predis\Command\KeyMove', + 'sort' => 'Predis\Command\KeySort', + + /* commands operating on string values */ + 'set' => 'Predis\Command\StringSet', + 'setnx' => 'Predis\Command\StringSetPreserve', + 'mset' => 'Predis\Command\StringSetMultiple', + 'msetnx' => 'Predis\Command\StringSetMultiplePreserve', + 'get' => 'Predis\Command\StringGet', + 'mget' => 'Predis\Command\StringGetMultiple', + 'getset' => 'Predis\Command\StringGetSet', + 'incr' => 'Predis\Command\StringIncrement', + 'incrby' => 'Predis\Command\StringIncrementBy', + 'decr' => 'Predis\Command\StringDecrement', + 'decrby' => 'Predis\Command\StringDecrementBy', + + /* commands operating on lists */ + 'rpush' => 'Predis\Command\ListPushTail', + 'lpush' => 'Predis\Command\ListPushHead', + 'llen' => 'Predis\Command\ListLength', + 'lrange' => 'Predis\Command\ListRange', + 'ltrim' => 'Predis\Command\ListTrim', + 'lindex' => 'Predis\Command\ListIndex', + 'lset' => 'Predis\Command\ListSet', + 'lrem' => 'Predis\Command\ListRemove', + 'lpop' => 'Predis\Command\ListPopFirst', + 'rpop' => 'Predis\Command\ListPopLast', + 'rpoplpush' => 'Predis\Command\ListPopLastPushHead', + + /* commands operating on sets */ + 'sadd' => 'Predis\Command\SetAdd', + 'srem' => 'Predis\Command\SetRemove', + 'spop' => 'Predis\Command\SetPop', + 'smove' => 'Predis\Command\SetMove', + 'scard' => 'Predis\Command\SetCardinality', + 'sismember' => 'Predis\Command\SetIsMember', + 'sinter' => 'Predis\Command\SetIntersection', + 'sinterstore' => 'Predis\Command\SetIntersectionStore', + 'sunion' => 'Predis\Command\SetUnion', + 'sunionstore' => 'Predis\Command\SetUnionStore', + 'sdiff' => 'Predis\Command\SetDifference', + 'sdiffstore' => 'Predis\Command\SetDifferenceStore', + 'smembers' => 'Predis\Command\SetMembers', + 'srandmember' => 'Predis\Command\SetRandomMember', + + /* commands operating on sorted sets */ + 'zadd' => 'Predis\Command\ZSetAdd', + 'zincrby' => 'Predis\Command\ZSetIncrementBy', + 'zrem' => 'Predis\Command\ZSetRemove', + 'zrange' => 'Predis\Command\ZSetRange', + 'zrevrange' => 'Predis\Command\ZSetReverseRange', + 'zrangebyscore' => 'Predis\Command\ZSetRangeByScore', + 'zcard' => 'Predis\Command\ZSetCardinality', + 'zscore' => 'Predis\Command\ZSetScore', + 'zremrangebyscore' => 'Predis\Command\ZSetRemoveRangeByScore', + + /* connection related commands */ + 'ping' => 'Predis\Command\ConnectionPing', + 'auth' => 'Predis\Command\ConnectionAuth', + 'select' => 'Predis\Command\ConnectionSelect', + 'echo' => 'Predis\Command\ConnectionEcho', + 'quit' => 'Predis\Command\ConnectionQuit', + + /* remote server control commands */ + 'info' => 'Predis\Command\ServerInfo', + 'slaveof' => 'Predis\Command\ServerSlaveOf', + 'monitor' => 'Predis\Command\ServerMonitor', + 'dbsize' => 'Predis\Command\ServerDatabaseSize', + 'flushdb' => 'Predis\Command\ServerFlushDatabase', + 'flushall' => 'Predis\Command\ServerFlushAll', + 'save' => 'Predis\Command\ServerSave', + 'bgsave' => 'Predis\Command\ServerBackgroundSave', + 'lastsave' => 'Predis\Command\ServerLastSave', + 'shutdown' => 'Predis\Command\ServerShutdown', + 'bgrewriteaof' => 'Predis\Command\ServerBackgroundRewriteAOF', + ); + } +} diff --git a/vendor/predis/predis/lib/Predis/Profile/ServerVersion20.php b/vendor/predis/predis/lib/Predis/Profile/ServerVersion20.php new file mode 100755 index 0000000..4fae3f9 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Profile/ServerVersion20.php @@ -0,0 +1,173 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Profile; + +/** + * Server profile for Redis v2.0.x. + * + * @author Daniele Alessandri + */ +class ServerVersion20 extends ServerProfile +{ + /** + * {@inheritdoc} + */ + public function getVersion() + { + return '2.0'; + } + + /** + * {@inheritdoc} + */ + public function getSupportedCommands() + { + return array( + /* ---------------- Redis 1.2 ---------------- */ + + /* commands operating on the key space */ + 'exists' => 'Predis\Command\KeyExists', + 'del' => 'Predis\Command\KeyDelete', + 'type' => 'Predis\Command\KeyType', + 'keys' => 'Predis\Command\KeyKeys', + 'randomkey' => 'Predis\Command\KeyRandom', + 'rename' => 'Predis\Command\KeyRename', + 'renamenx' => 'Predis\Command\KeyRenamePreserve', + 'expire' => 'Predis\Command\KeyExpire', + 'expireat' => 'Predis\Command\KeyExpireAt', + 'ttl' => 'Predis\Command\KeyTimeToLive', + 'move' => 'Predis\Command\KeyMove', + 'sort' => 'Predis\Command\KeySort', + + /* commands operating on string values */ + 'set' => 'Predis\Command\StringSet', + 'setnx' => 'Predis\Command\StringSetPreserve', + 'mset' => 'Predis\Command\StringSetMultiple', + 'msetnx' => 'Predis\Command\StringSetMultiplePreserve', + 'get' => 'Predis\Command\StringGet', + 'mget' => 'Predis\Command\StringGetMultiple', + 'getset' => 'Predis\Command\StringGetSet', + 'incr' => 'Predis\Command\StringIncrement', + 'incrby' => 'Predis\Command\StringIncrementBy', + 'decr' => 'Predis\Command\StringDecrement', + 'decrby' => 'Predis\Command\StringDecrementBy', + + /* commands operating on lists */ + 'rpush' => 'Predis\Command\ListPushTail', + 'lpush' => 'Predis\Command\ListPushHead', + 'llen' => 'Predis\Command\ListLength', + 'lrange' => 'Predis\Command\ListRange', + 'ltrim' => 'Predis\Command\ListTrim', + 'lindex' => 'Predis\Command\ListIndex', + 'lset' => 'Predis\Command\ListSet', + 'lrem' => 'Predis\Command\ListRemove', + 'lpop' => 'Predis\Command\ListPopFirst', + 'rpop' => 'Predis\Command\ListPopLast', + 'rpoplpush' => 'Predis\Command\ListPopLastPushHead', + + /* commands operating on sets */ + 'sadd' => 'Predis\Command\SetAdd', + 'srem' => 'Predis\Command\SetRemove', + 'spop' => 'Predis\Command\SetPop', + 'smove' => 'Predis\Command\SetMove', + 'scard' => 'Predis\Command\SetCardinality', + 'sismember' => 'Predis\Command\SetIsMember', + 'sinter' => 'Predis\Command\SetIntersection', + 'sinterstore' => 'Predis\Command\SetIntersectionStore', + 'sunion' => 'Predis\Command\SetUnion', + 'sunionstore' => 'Predis\Command\SetUnionStore', + 'sdiff' => 'Predis\Command\SetDifference', + 'sdiffstore' => 'Predis\Command\SetDifferenceStore', + 'smembers' => 'Predis\Command\SetMembers', + 'srandmember' => 'Predis\Command\SetRandomMember', + + /* commands operating on sorted sets */ + 'zadd' => 'Predis\Command\ZSetAdd', + 'zincrby' => 'Predis\Command\ZSetIncrementBy', + 'zrem' => 'Predis\Command\ZSetRemove', + 'zrange' => 'Predis\Command\ZSetRange', + 'zrevrange' => 'Predis\Command\ZSetReverseRange', + 'zrangebyscore' => 'Predis\Command\ZSetRangeByScore', + 'zcard' => 'Predis\Command\ZSetCardinality', + 'zscore' => 'Predis\Command\ZSetScore', + 'zremrangebyscore' => 'Predis\Command\ZSetRemoveRangeByScore', + + /* connection related commands */ + 'ping' => 'Predis\Command\ConnectionPing', + 'auth' => 'Predis\Command\ConnectionAuth', + 'select' => 'Predis\Command\ConnectionSelect', + 'echo' => 'Predis\Command\ConnectionEcho', + 'quit' => 'Predis\Command\ConnectionQuit', + + /* remote server control commands */ + 'info' => 'Predis\Command\ServerInfo', + 'slaveof' => 'Predis\Command\ServerSlaveOf', + 'monitor' => 'Predis\Command\ServerMonitor', + 'dbsize' => 'Predis\Command\ServerDatabaseSize', + 'flushdb' => 'Predis\Command\ServerFlushDatabase', + 'flushall' => 'Predis\Command\ServerFlushAll', + 'save' => 'Predis\Command\ServerSave', + 'bgsave' => 'Predis\Command\ServerBackgroundSave', + 'lastsave' => 'Predis\Command\ServerLastSave', + 'shutdown' => 'Predis\Command\ServerShutdown', + 'bgrewriteaof' => 'Predis\Command\ServerBackgroundRewriteAOF', + + /* ---------------- Redis 2.0 ---------------- */ + + /* commands operating on string values */ + 'setex' => 'Predis\Command\StringSetExpire', + 'append' => 'Predis\Command\StringAppend', + 'substr' => 'Predis\Command\StringSubstr', + + /* commands operating on lists */ + 'blpop' => 'Predis\Command\ListPopFirstBlocking', + 'brpop' => 'Predis\Command\ListPopLastBlocking', + + /* commands operating on sorted sets */ + 'zunionstore' => 'Predis\Command\ZSetUnionStore', + 'zinterstore' => 'Predis\Command\ZSetIntersectionStore', + 'zcount' => 'Predis\Command\ZSetCount', + 'zrank' => 'Predis\Command\ZSetRank', + 'zrevrank' => 'Predis\Command\ZSetReverseRank', + 'zremrangebyrank' => 'Predis\Command\ZSetRemoveRangeByRank', + + /* commands operating on hashes */ + 'hset' => 'Predis\Command\HashSet', + 'hsetnx' => 'Predis\Command\HashSetPreserve', + 'hmset' => 'Predis\Command\HashSetMultiple', + 'hincrby' => 'Predis\Command\HashIncrementBy', + 'hget' => 'Predis\Command\HashGet', + 'hmget' => 'Predis\Command\HashGetMultiple', + 'hdel' => 'Predis\Command\HashDelete', + 'hexists' => 'Predis\Command\HashExists', + 'hlen' => 'Predis\Command\HashLength', + 'hkeys' => 'Predis\Command\HashKeys', + 'hvals' => 'Predis\Command\HashValues', + 'hgetall' => 'Predis\Command\HashGetAll', + + /* transactions */ + 'multi' => 'Predis\Command\TransactionMulti', + 'exec' => 'Predis\Command\TransactionExec', + 'discard' => 'Predis\Command\TransactionDiscard', + + /* publish - subscribe */ + 'subscribe' => 'Predis\Command\PubSubSubscribe', + 'unsubscribe' => 'Predis\Command\PubSubUnsubscribe', + 'psubscribe' => 'Predis\Command\PubSubSubscribeByPattern', + 'punsubscribe' => 'Predis\Command\PubSubUnsubscribeByPattern', + 'publish' => 'Predis\Command\PubSubPublish', + + /* remote server control commands */ + 'config' => 'Predis\Command\ServerConfig', + ); + } +} diff --git a/vendor/predis/predis/lib/Predis/Profile/ServerVersion22.php b/vendor/predis/predis/lib/Predis/Profile/ServerVersion22.php new file mode 100755 index 0000000..2fe4fca --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Profile/ServerVersion22.php @@ -0,0 +1,202 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Profile; + +/** + * Server profile for Redis v2.2.x. + * + * @author Daniele Alessandri + */ +class ServerVersion22 extends ServerProfile +{ + /** + * {@inheritdoc} + */ + public function getVersion() + { + return '2.2'; + } + + /** + * {@inheritdoc} + */ + public function getSupportedCommands() + { + return array( + /* ---------------- Redis 1.2 ---------------- */ + + /* commands operating on the key space */ + 'exists' => 'Predis\Command\KeyExists', + 'del' => 'Predis\Command\KeyDelete', + 'type' => 'Predis\Command\KeyType', + 'keys' => 'Predis\Command\KeyKeys', + 'randomkey' => 'Predis\Command\KeyRandom', + 'rename' => 'Predis\Command\KeyRename', + 'renamenx' => 'Predis\Command\KeyRenamePreserve', + 'expire' => 'Predis\Command\KeyExpire', + 'expireat' => 'Predis\Command\KeyExpireAt', + 'ttl' => 'Predis\Command\KeyTimeToLive', + 'move' => 'Predis\Command\KeyMove', + 'sort' => 'Predis\Command\KeySort', + + /* commands operating on string values */ + 'set' => 'Predis\Command\StringSet', + 'setnx' => 'Predis\Command\StringSetPreserve', + 'mset' => 'Predis\Command\StringSetMultiple', + 'msetnx' => 'Predis\Command\StringSetMultiplePreserve', + 'get' => 'Predis\Command\StringGet', + 'mget' => 'Predis\Command\StringGetMultiple', + 'getset' => 'Predis\Command\StringGetSet', + 'incr' => 'Predis\Command\StringIncrement', + 'incrby' => 'Predis\Command\StringIncrementBy', + 'decr' => 'Predis\Command\StringDecrement', + 'decrby' => 'Predis\Command\StringDecrementBy', + + /* commands operating on lists */ + 'rpush' => 'Predis\Command\ListPushTail', + 'lpush' => 'Predis\Command\ListPushHead', + 'llen' => 'Predis\Command\ListLength', + 'lrange' => 'Predis\Command\ListRange', + 'ltrim' => 'Predis\Command\ListTrim', + 'lindex' => 'Predis\Command\ListIndex', + 'lset' => 'Predis\Command\ListSet', + 'lrem' => 'Predis\Command\ListRemove', + 'lpop' => 'Predis\Command\ListPopFirst', + 'rpop' => 'Predis\Command\ListPopLast', + 'rpoplpush' => 'Predis\Command\ListPopLastPushHead', + + /* commands operating on sets */ + 'sadd' => 'Predis\Command\SetAdd', + 'srem' => 'Predis\Command\SetRemove', + 'spop' => 'Predis\Command\SetPop', + 'smove' => 'Predis\Command\SetMove', + 'scard' => 'Predis\Command\SetCardinality', + 'sismember' => 'Predis\Command\SetIsMember', + 'sinter' => 'Predis\Command\SetIntersection', + 'sinterstore' => 'Predis\Command\SetIntersectionStore', + 'sunion' => 'Predis\Command\SetUnion', + 'sunionstore' => 'Predis\Command\SetUnionStore', + 'sdiff' => 'Predis\Command\SetDifference', + 'sdiffstore' => 'Predis\Command\SetDifferenceStore', + 'smembers' => 'Predis\Command\SetMembers', + 'srandmember' => 'Predis\Command\SetRandomMember', + + /* commands operating on sorted sets */ + 'zadd' => 'Predis\Command\ZSetAdd', + 'zincrby' => 'Predis\Command\ZSetIncrementBy', + 'zrem' => 'Predis\Command\ZSetRemove', + 'zrange' => 'Predis\Command\ZSetRange', + 'zrevrange' => 'Predis\Command\ZSetReverseRange', + 'zrangebyscore' => 'Predis\Command\ZSetRangeByScore', + 'zcard' => 'Predis\Command\ZSetCardinality', + 'zscore' => 'Predis\Command\ZSetScore', + 'zremrangebyscore' => 'Predis\Command\ZSetRemoveRangeByScore', + + /* connection related commands */ + 'ping' => 'Predis\Command\ConnectionPing', + 'auth' => 'Predis\Command\ConnectionAuth', + 'select' => 'Predis\Command\ConnectionSelect', + 'echo' => 'Predis\Command\ConnectionEcho', + 'quit' => 'Predis\Command\ConnectionQuit', + + /* remote server control commands */ + 'info' => 'Predis\Command\ServerInfo', + 'slaveof' => 'Predis\Command\ServerSlaveOf', + 'monitor' => 'Predis\Command\ServerMonitor', + 'dbsize' => 'Predis\Command\ServerDatabaseSize', + 'flushdb' => 'Predis\Command\ServerFlushDatabase', + 'flushall' => 'Predis\Command\ServerFlushAll', + 'save' => 'Predis\Command\ServerSave', + 'bgsave' => 'Predis\Command\ServerBackgroundSave', + 'lastsave' => 'Predis\Command\ServerLastSave', + 'shutdown' => 'Predis\Command\ServerShutdown', + 'bgrewriteaof' => 'Predis\Command\ServerBackgroundRewriteAOF', + + /* ---------------- Redis 2.0 ---------------- */ + + /* commands operating on string values */ + 'setex' => 'Predis\Command\StringSetExpire', + 'append' => 'Predis\Command\StringAppend', + 'substr' => 'Predis\Command\StringSubstr', + + /* commands operating on lists */ + 'blpop' => 'Predis\Command\ListPopFirstBlocking', + 'brpop' => 'Predis\Command\ListPopLastBlocking', + + /* commands operating on sorted sets */ + 'zunionstore' => 'Predis\Command\ZSetUnionStore', + 'zinterstore' => 'Predis\Command\ZSetIntersectionStore', + 'zcount' => 'Predis\Command\ZSetCount', + 'zrank' => 'Predis\Command\ZSetRank', + 'zrevrank' => 'Predis\Command\ZSetReverseRank', + 'zremrangebyrank' => 'Predis\Command\ZSetRemoveRangeByRank', + + /* commands operating on hashes */ + 'hset' => 'Predis\Command\HashSet', + 'hsetnx' => 'Predis\Command\HashSetPreserve', + 'hmset' => 'Predis\Command\HashSetMultiple', + 'hincrby' => 'Predis\Command\HashIncrementBy', + 'hget' => 'Predis\Command\HashGet', + 'hmget' => 'Predis\Command\HashGetMultiple', + 'hdel' => 'Predis\Command\HashDelete', + 'hexists' => 'Predis\Command\HashExists', + 'hlen' => 'Predis\Command\HashLength', + 'hkeys' => 'Predis\Command\HashKeys', + 'hvals' => 'Predis\Command\HashValues', + 'hgetall' => 'Predis\Command\HashGetAll', + + /* transactions */ + 'multi' => 'Predis\Command\TransactionMulti', + 'exec' => 'Predis\Command\TransactionExec', + 'discard' => 'Predis\Command\TransactionDiscard', + + /* publish - subscribe */ + 'subscribe' => 'Predis\Command\PubSubSubscribe', + 'unsubscribe' => 'Predis\Command\PubSubUnsubscribe', + 'psubscribe' => 'Predis\Command\PubSubSubscribeByPattern', + 'punsubscribe' => 'Predis\Command\PubSubUnsubscribeByPattern', + 'publish' => 'Predis\Command\PubSubPublish', + + /* remote server control commands */ + 'config' => 'Predis\Command\ServerConfig', + + /* ---------------- Redis 2.2 ---------------- */ + + /* commands operating on the key space */ + 'persist' => 'Predis\Command\KeyPersist', + + /* commands operating on string values */ + 'strlen' => 'Predis\Command\StringStrlen', + 'setrange' => 'Predis\Command\StringSetRange', + 'getrange' => 'Predis\Command\StringGetRange', + 'setbit' => 'Predis\Command\StringSetBit', + 'getbit' => 'Predis\Command\StringGetBit', + + /* commands operating on lists */ + 'rpushx' => 'Predis\Command\ListPushTailX', + 'lpushx' => 'Predis\Command\ListPushHeadX', + 'linsert' => 'Predis\Command\ListInsert', + 'brpoplpush' => 'Predis\Command\ListPopLastPushHeadBlocking', + + /* commands operating on sorted sets */ + 'zrevrangebyscore' => 'Predis\Command\ZSetReverseRangeByScore', + + /* transactions */ + 'watch' => 'Predis\Command\TransactionWatch', + 'unwatch' => 'Predis\Command\TransactionUnwatch', + + /* remote server control commands */ + 'object' => 'Predis\Command\ServerObject', + 'slowlog' => 'Predis\Command\ServerSlowlog', + ); + } +} diff --git a/vendor/predis/predis/lib/Predis/Profile/ServerVersion24.php b/vendor/predis/predis/lib/Predis/Profile/ServerVersion24.php new file mode 100755 index 0000000..455d5b6 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Profile/ServerVersion24.php @@ -0,0 +1,207 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Profile; + +/** + * Server profile for Redis v2.4.x. + * + * @author Daniele Alessandri + */ +class ServerVersion24 extends ServerProfile +{ + /** + * {@inheritdoc} + */ + public function getVersion() + { + return '2.4'; + } + + /** + * {@inheritdoc} + */ + public function getSupportedCommands() + { + return array( + /* ---------------- Redis 1.2 ---------------- */ + + /* commands operating on the key space */ + 'exists' => 'Predis\Command\KeyExists', + 'del' => 'Predis\Command\KeyDelete', + 'type' => 'Predis\Command\KeyType', + 'keys' => 'Predis\Command\KeyKeys', + 'randomkey' => 'Predis\Command\KeyRandom', + 'rename' => 'Predis\Command\KeyRename', + 'renamenx' => 'Predis\Command\KeyRenamePreserve', + 'expire' => 'Predis\Command\KeyExpire', + 'expireat' => 'Predis\Command\KeyExpireAt', + 'ttl' => 'Predis\Command\KeyTimeToLive', + 'move' => 'Predis\Command\KeyMove', + 'sort' => 'Predis\Command\KeySort', + + /* commands operating on string values */ + 'set' => 'Predis\Command\StringSet', + 'setnx' => 'Predis\Command\StringSetPreserve', + 'mset' => 'Predis\Command\StringSetMultiple', + 'msetnx' => 'Predis\Command\StringSetMultiplePreserve', + 'get' => 'Predis\Command\StringGet', + 'mget' => 'Predis\Command\StringGetMultiple', + 'getset' => 'Predis\Command\StringGetSet', + 'incr' => 'Predis\Command\StringIncrement', + 'incrby' => 'Predis\Command\StringIncrementBy', + 'decr' => 'Predis\Command\StringDecrement', + 'decrby' => 'Predis\Command\StringDecrementBy', + + /* commands operating on lists */ + 'rpush' => 'Predis\Command\ListPushTail', + 'lpush' => 'Predis\Command\ListPushHead', + 'llen' => 'Predis\Command\ListLength', + 'lrange' => 'Predis\Command\ListRange', + 'ltrim' => 'Predis\Command\ListTrim', + 'lindex' => 'Predis\Command\ListIndex', + 'lset' => 'Predis\Command\ListSet', + 'lrem' => 'Predis\Command\ListRemove', + 'lpop' => 'Predis\Command\ListPopFirst', + 'rpop' => 'Predis\Command\ListPopLast', + 'rpoplpush' => 'Predis\Command\ListPopLastPushHead', + + /* commands operating on sets */ + 'sadd' => 'Predis\Command\SetAdd', + 'srem' => 'Predis\Command\SetRemove', + 'spop' => 'Predis\Command\SetPop', + 'smove' => 'Predis\Command\SetMove', + 'scard' => 'Predis\Command\SetCardinality', + 'sismember' => 'Predis\Command\SetIsMember', + 'sinter' => 'Predis\Command\SetIntersection', + 'sinterstore' => 'Predis\Command\SetIntersectionStore', + 'sunion' => 'Predis\Command\SetUnion', + 'sunionstore' => 'Predis\Command\SetUnionStore', + 'sdiff' => 'Predis\Command\SetDifference', + 'sdiffstore' => 'Predis\Command\SetDifferenceStore', + 'smembers' => 'Predis\Command\SetMembers', + 'srandmember' => 'Predis\Command\SetRandomMember', + + /* commands operating on sorted sets */ + 'zadd' => 'Predis\Command\ZSetAdd', + 'zincrby' => 'Predis\Command\ZSetIncrementBy', + 'zrem' => 'Predis\Command\ZSetRemove', + 'zrange' => 'Predis\Command\ZSetRange', + 'zrevrange' => 'Predis\Command\ZSetReverseRange', + 'zrangebyscore' => 'Predis\Command\ZSetRangeByScore', + 'zcard' => 'Predis\Command\ZSetCardinality', + 'zscore' => 'Predis\Command\ZSetScore', + 'zremrangebyscore' => 'Predis\Command\ZSetRemoveRangeByScore', + + /* connection related commands */ + 'ping' => 'Predis\Command\ConnectionPing', + 'auth' => 'Predis\Command\ConnectionAuth', + 'select' => 'Predis\Command\ConnectionSelect', + 'echo' => 'Predis\Command\ConnectionEcho', + 'quit' => 'Predis\Command\ConnectionQuit', + + /* remote server control commands */ + 'info' => 'Predis\Command\ServerInfo', + 'slaveof' => 'Predis\Command\ServerSlaveOf', + 'monitor' => 'Predis\Command\ServerMonitor', + 'dbsize' => 'Predis\Command\ServerDatabaseSize', + 'flushdb' => 'Predis\Command\ServerFlushDatabase', + 'flushall' => 'Predis\Command\ServerFlushAll', + 'save' => 'Predis\Command\ServerSave', + 'bgsave' => 'Predis\Command\ServerBackgroundSave', + 'lastsave' => 'Predis\Command\ServerLastSave', + 'shutdown' => 'Predis\Command\ServerShutdown', + 'bgrewriteaof' => 'Predis\Command\ServerBackgroundRewriteAOF', + + /* ---------------- Redis 2.0 ---------------- */ + + /* commands operating on string values */ + 'setex' => 'Predis\Command\StringSetExpire', + 'append' => 'Predis\Command\StringAppend', + 'substr' => 'Predis\Command\StringSubstr', + + /* commands operating on lists */ + 'blpop' => 'Predis\Command\ListPopFirstBlocking', + 'brpop' => 'Predis\Command\ListPopLastBlocking', + + /* commands operating on sorted sets */ + 'zunionstore' => 'Predis\Command\ZSetUnionStore', + 'zinterstore' => 'Predis\Command\ZSetIntersectionStore', + 'zcount' => 'Predis\Command\ZSetCount', + 'zrank' => 'Predis\Command\ZSetRank', + 'zrevrank' => 'Predis\Command\ZSetReverseRank', + 'zremrangebyrank' => 'Predis\Command\ZSetRemoveRangeByRank', + + /* commands operating on hashes */ + 'hset' => 'Predis\Command\HashSet', + 'hsetnx' => 'Predis\Command\HashSetPreserve', + 'hmset' => 'Predis\Command\HashSetMultiple', + 'hincrby' => 'Predis\Command\HashIncrementBy', + 'hget' => 'Predis\Command\HashGet', + 'hmget' => 'Predis\Command\HashGetMultiple', + 'hdel' => 'Predis\Command\HashDelete', + 'hexists' => 'Predis\Command\HashExists', + 'hlen' => 'Predis\Command\HashLength', + 'hkeys' => 'Predis\Command\HashKeys', + 'hvals' => 'Predis\Command\HashValues', + 'hgetall' => 'Predis\Command\HashGetAll', + + /* transactions */ + 'multi' => 'Predis\Command\TransactionMulti', + 'exec' => 'Predis\Command\TransactionExec', + 'discard' => 'Predis\Command\TransactionDiscard', + + /* publish - subscribe */ + 'subscribe' => 'Predis\Command\PubSubSubscribe', + 'unsubscribe' => 'Predis\Command\PubSubUnsubscribe', + 'psubscribe' => 'Predis\Command\PubSubSubscribeByPattern', + 'punsubscribe' => 'Predis\Command\PubSubUnsubscribeByPattern', + 'publish' => 'Predis\Command\PubSubPublish', + + /* remote server control commands */ + 'config' => 'Predis\Command\ServerConfig', + + /* ---------------- Redis 2.2 ---------------- */ + + /* commands operating on the key space */ + 'persist' => 'Predis\Command\KeyPersist', + + /* commands operating on string values */ + 'strlen' => 'Predis\Command\StringStrlen', + 'setrange' => 'Predis\Command\StringSetRange', + 'getrange' => 'Predis\Command\StringGetRange', + 'setbit' => 'Predis\Command\StringSetBit', + 'getbit' => 'Predis\Command\StringGetBit', + + /* commands operating on lists */ + 'rpushx' => 'Predis\Command\ListPushTailX', + 'lpushx' => 'Predis\Command\ListPushHeadX', + 'linsert' => 'Predis\Command\ListInsert', + 'brpoplpush' => 'Predis\Command\ListPopLastPushHeadBlocking', + + /* commands operating on sorted sets */ + 'zrevrangebyscore' => 'Predis\Command\ZSetReverseRangeByScore', + + /* transactions */ + 'watch' => 'Predis\Command\TransactionWatch', + 'unwatch' => 'Predis\Command\TransactionUnwatch', + + /* remote server control commands */ + 'object' => 'Predis\Command\ServerObject', + 'slowlog' => 'Predis\Command\ServerSlowlog', + + /* ---------------- Redis 2.4 ---------------- */ + + /* remote server control commands */ + 'client' => 'Predis\Command\ServerClient', + ); + } +} diff --git a/vendor/predis/predis/lib/Predis/Profile/ServerVersion26.php b/vendor/predis/predis/lib/Predis/Profile/ServerVersion26.php new file mode 100755 index 0000000..875f409 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Profile/ServerVersion26.php @@ -0,0 +1,233 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Profile; + +/** + * Server profile for Redis v2.6.x. + * + * @author Daniele Alessandri + */ +class ServerVersion26 extends ServerProfile +{ + /** + * {@inheritdoc} + */ + public function getVersion() + { + return '2.6'; + } + + /** + * {@inheritdoc} + */ + public function getSupportedCommands() + { + return array( + /* ---------------- Redis 1.2 ---------------- */ + + /* commands operating on the key space */ + 'exists' => 'Predis\Command\KeyExists', + 'del' => 'Predis\Command\KeyDelete', + 'type' => 'Predis\Command\KeyType', + 'keys' => 'Predis\Command\KeyKeys', + 'randomkey' => 'Predis\Command\KeyRandom', + 'rename' => 'Predis\Command\KeyRename', + 'renamenx' => 'Predis\Command\KeyRenamePreserve', + 'expire' => 'Predis\Command\KeyExpire', + 'expireat' => 'Predis\Command\KeyExpireAt', + 'ttl' => 'Predis\Command\KeyTimeToLive', + 'move' => 'Predis\Command\KeyMove', + 'sort' => 'Predis\Command\KeySort', + 'dump' => 'Predis\Command\KeyDump', + 'restore' => 'Predis\Command\KeyRestore', + + /* commands operating on string values */ + 'set' => 'Predis\Command\StringSet', + 'setnx' => 'Predis\Command\StringSetPreserve', + 'mset' => 'Predis\Command\StringSetMultiple', + 'msetnx' => 'Predis\Command\StringSetMultiplePreserve', + 'get' => 'Predis\Command\StringGet', + 'mget' => 'Predis\Command\StringGetMultiple', + 'getset' => 'Predis\Command\StringGetSet', + 'incr' => 'Predis\Command\StringIncrement', + 'incrby' => 'Predis\Command\StringIncrementBy', + 'decr' => 'Predis\Command\StringDecrement', + 'decrby' => 'Predis\Command\StringDecrementBy', + + /* commands operating on lists */ + 'rpush' => 'Predis\Command\ListPushTail', + 'lpush' => 'Predis\Command\ListPushHead', + 'llen' => 'Predis\Command\ListLength', + 'lrange' => 'Predis\Command\ListRange', + 'ltrim' => 'Predis\Command\ListTrim', + 'lindex' => 'Predis\Command\ListIndex', + 'lset' => 'Predis\Command\ListSet', + 'lrem' => 'Predis\Command\ListRemove', + 'lpop' => 'Predis\Command\ListPopFirst', + 'rpop' => 'Predis\Command\ListPopLast', + 'rpoplpush' => 'Predis\Command\ListPopLastPushHead', + + /* commands operating on sets */ + 'sadd' => 'Predis\Command\SetAdd', + 'srem' => 'Predis\Command\SetRemove', + 'spop' => 'Predis\Command\SetPop', + 'smove' => 'Predis\Command\SetMove', + 'scard' => 'Predis\Command\SetCardinality', + 'sismember' => 'Predis\Command\SetIsMember', + 'sinter' => 'Predis\Command\SetIntersection', + 'sinterstore' => 'Predis\Command\SetIntersectionStore', + 'sunion' => 'Predis\Command\SetUnion', + 'sunionstore' => 'Predis\Command\SetUnionStore', + 'sdiff' => 'Predis\Command\SetDifference', + 'sdiffstore' => 'Predis\Command\SetDifferenceStore', + 'smembers' => 'Predis\Command\SetMembers', + 'srandmember' => 'Predis\Command\SetRandomMember', + + /* commands operating on sorted sets */ + 'zadd' => 'Predis\Command\ZSetAdd', + 'zincrby' => 'Predis\Command\ZSetIncrementBy', + 'zrem' => 'Predis\Command\ZSetRemove', + 'zrange' => 'Predis\Command\ZSetRange', + 'zrevrange' => 'Predis\Command\ZSetReverseRange', + 'zrangebyscore' => 'Predis\Command\ZSetRangeByScore', + 'zcard' => 'Predis\Command\ZSetCardinality', + 'zscore' => 'Predis\Command\ZSetScore', + 'zremrangebyscore' => 'Predis\Command\ZSetRemoveRangeByScore', + + /* connection related commands */ + 'ping' => 'Predis\Command\ConnectionPing', + 'auth' => 'Predis\Command\ConnectionAuth', + 'select' => 'Predis\Command\ConnectionSelect', + 'echo' => 'Predis\Command\ConnectionEcho', + 'quit' => 'Predis\Command\ConnectionQuit', + + /* remote server control commands */ + 'info' => 'Predis\Command\ServerInfoV26x', + 'slaveof' => 'Predis\Command\ServerSlaveOf', + 'monitor' => 'Predis\Command\ServerMonitor', + 'dbsize' => 'Predis\Command\ServerDatabaseSize', + 'flushdb' => 'Predis\Command\ServerFlushDatabase', + 'flushall' => 'Predis\Command\ServerFlushAll', + 'save' => 'Predis\Command\ServerSave', + 'bgsave' => 'Predis\Command\ServerBackgroundSave', + 'lastsave' => 'Predis\Command\ServerLastSave', + 'shutdown' => 'Predis\Command\ServerShutdown', + 'bgrewriteaof' => 'Predis\Command\ServerBackgroundRewriteAOF', + + /* ---------------- Redis 2.0 ---------------- */ + + /* commands operating on string values */ + 'setex' => 'Predis\Command\StringSetExpire', + 'append' => 'Predis\Command\StringAppend', + 'substr' => 'Predis\Command\StringSubstr', + + /* commands operating on lists */ + 'blpop' => 'Predis\Command\ListPopFirstBlocking', + 'brpop' => 'Predis\Command\ListPopLastBlocking', + + /* commands operating on sorted sets */ + 'zunionstore' => 'Predis\Command\ZSetUnionStore', + 'zinterstore' => 'Predis\Command\ZSetIntersectionStore', + 'zcount' => 'Predis\Command\ZSetCount', + 'zrank' => 'Predis\Command\ZSetRank', + 'zrevrank' => 'Predis\Command\ZSetReverseRank', + 'zremrangebyrank' => 'Predis\Command\ZSetRemoveRangeByRank', + + /* commands operating on hashes */ + 'hset' => 'Predis\Command\HashSet', + 'hsetnx' => 'Predis\Command\HashSetPreserve', + 'hmset' => 'Predis\Command\HashSetMultiple', + 'hincrby' => 'Predis\Command\HashIncrementBy', + 'hget' => 'Predis\Command\HashGet', + 'hmget' => 'Predis\Command\HashGetMultiple', + 'hdel' => 'Predis\Command\HashDelete', + 'hexists' => 'Predis\Command\HashExists', + 'hlen' => 'Predis\Command\HashLength', + 'hkeys' => 'Predis\Command\HashKeys', + 'hvals' => 'Predis\Command\HashValues', + 'hgetall' => 'Predis\Command\HashGetAll', + + /* transactions */ + 'multi' => 'Predis\Command\TransactionMulti', + 'exec' => 'Predis\Command\TransactionExec', + 'discard' => 'Predis\Command\TransactionDiscard', + + /* publish - subscribe */ + 'subscribe' => 'Predis\Command\PubSubSubscribe', + 'unsubscribe' => 'Predis\Command\PubSubUnsubscribe', + 'psubscribe' => 'Predis\Command\PubSubSubscribeByPattern', + 'punsubscribe' => 'Predis\Command\PubSubUnsubscribeByPattern', + 'publish' => 'Predis\Command\PubSubPublish', + + /* remote server control commands */ + 'config' => 'Predis\Command\ServerConfig', + + /* ---------------- Redis 2.2 ---------------- */ + + /* commands operating on the key space */ + 'persist' => 'Predis\Command\KeyPersist', + + /* commands operating on string values */ + 'strlen' => 'Predis\Command\StringStrlen', + 'setrange' => 'Predis\Command\StringSetRange', + 'getrange' => 'Predis\Command\StringGetRange', + 'setbit' => 'Predis\Command\StringSetBit', + 'getbit' => 'Predis\Command\StringGetBit', + + /* commands operating on lists */ + 'rpushx' => 'Predis\Command\ListPushTailX', + 'lpushx' => 'Predis\Command\ListPushHeadX', + 'linsert' => 'Predis\Command\ListInsert', + 'brpoplpush' => 'Predis\Command\ListPopLastPushHeadBlocking', + + /* commands operating on sorted sets */ + 'zrevrangebyscore' => 'Predis\Command\ZSetReverseRangeByScore', + + /* transactions */ + 'watch' => 'Predis\Command\TransactionWatch', + 'unwatch' => 'Predis\Command\TransactionUnwatch', + + /* remote server control commands */ + 'object' => 'Predis\Command\ServerObject', + 'slowlog' => 'Predis\Command\ServerSlowlog', + + /* ---------------- Redis 2.4 ---------------- */ + + /* remote server control commands */ + 'client' => 'Predis\Command\ServerClient', + + /* ---------------- Redis 2.6 ---------------- */ + + /* commands operating on the key space */ + 'pttl' => 'Predis\Command\KeyPreciseTimeToLive', + 'pexpire' => 'Predis\Command\KeyPreciseExpire', + 'pexpireat' => 'Predis\Command\KeyPreciseExpireAt', + + /* commands operating on string values */ + 'psetex' => 'Predis\Command\StringPreciseSetExpire', + 'incrbyfloat' => 'Predis\Command\StringIncrementByFloat', + 'bitop' => 'Predis\Command\StringBitOp', + 'bitcount' => 'Predis\Command\StringBitCount', + + /* commands operating on hashes */ + 'hincrbyfloat' => 'Predis\Command\HashIncrementByFloat', + + /* scripting */ + 'eval' => 'Predis\Command\ServerEval', + 'evalsha' => 'Predis\Command\ServerEvalSHA', + 'script' => 'Predis\Command\ServerScript', + + /* remote server control commands */ + 'time' => 'Predis\Command\ServerTime', + ); + } +} diff --git a/vendor/predis/predis/lib/Predis/Profile/ServerVersion28.php b/vendor/predis/predis/lib/Predis/Profile/ServerVersion28.php new file mode 100755 index 0000000..df4598b --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Profile/ServerVersion28.php @@ -0,0 +1,247 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Profile; + +/** + * Server profile for Redis v2.8.x. + * + * @author Daniele Alessandri + */ +class ServerVersion28 extends ServerProfile +{ + /** + * {@inheritdoc} + */ + public function getVersion() + { + return '2.8'; + } + + /** + * {@inheritdoc} + */ + public function getSupportedCommands() + { + return array( + /* ---------------- Redis 1.2 ---------------- */ + + /* commands operating on the key space */ + 'exists' => 'Predis\Command\KeyExists', + 'del' => 'Predis\Command\KeyDelete', + 'type' => 'Predis\Command\KeyType', + 'keys' => 'Predis\Command\KeyKeys', + 'randomkey' => 'Predis\Command\KeyRandom', + 'rename' => 'Predis\Command\KeyRename', + 'renamenx' => 'Predis\Command\KeyRenamePreserve', + 'expire' => 'Predis\Command\KeyExpire', + 'expireat' => 'Predis\Command\KeyExpireAt', + 'ttl' => 'Predis\Command\KeyTimeToLive', + 'move' => 'Predis\Command\KeyMove', + 'sort' => 'Predis\Command\KeySort', + 'dump' => 'Predis\Command\KeyDump', + 'restore' => 'Predis\Command\KeyRestore', + + /* commands operating on string values */ + 'set' => 'Predis\Command\StringSet', + 'setnx' => 'Predis\Command\StringSetPreserve', + 'mset' => 'Predis\Command\StringSetMultiple', + 'msetnx' => 'Predis\Command\StringSetMultiplePreserve', + 'get' => 'Predis\Command\StringGet', + 'mget' => 'Predis\Command\StringGetMultiple', + 'getset' => 'Predis\Command\StringGetSet', + 'incr' => 'Predis\Command\StringIncrement', + 'incrby' => 'Predis\Command\StringIncrementBy', + 'decr' => 'Predis\Command\StringDecrement', + 'decrby' => 'Predis\Command\StringDecrementBy', + + /* commands operating on lists */ + 'rpush' => 'Predis\Command\ListPushTail', + 'lpush' => 'Predis\Command\ListPushHead', + 'llen' => 'Predis\Command\ListLength', + 'lrange' => 'Predis\Command\ListRange', + 'ltrim' => 'Predis\Command\ListTrim', + 'lindex' => 'Predis\Command\ListIndex', + 'lset' => 'Predis\Command\ListSet', + 'lrem' => 'Predis\Command\ListRemove', + 'lpop' => 'Predis\Command\ListPopFirst', + 'rpop' => 'Predis\Command\ListPopLast', + 'rpoplpush' => 'Predis\Command\ListPopLastPushHead', + + /* commands operating on sets */ + 'sadd' => 'Predis\Command\SetAdd', + 'srem' => 'Predis\Command\SetRemove', + 'spop' => 'Predis\Command\SetPop', + 'smove' => 'Predis\Command\SetMove', + 'scard' => 'Predis\Command\SetCardinality', + 'sismember' => 'Predis\Command\SetIsMember', + 'sinter' => 'Predis\Command\SetIntersection', + 'sinterstore' => 'Predis\Command\SetIntersectionStore', + 'sunion' => 'Predis\Command\SetUnion', + 'sunionstore' => 'Predis\Command\SetUnionStore', + 'sdiff' => 'Predis\Command\SetDifference', + 'sdiffstore' => 'Predis\Command\SetDifferenceStore', + 'smembers' => 'Predis\Command\SetMembers', + 'srandmember' => 'Predis\Command\SetRandomMember', + + /* commands operating on sorted sets */ + 'zadd' => 'Predis\Command\ZSetAdd', + 'zincrby' => 'Predis\Command\ZSetIncrementBy', + 'zrem' => 'Predis\Command\ZSetRemove', + 'zrange' => 'Predis\Command\ZSetRange', + 'zrevrange' => 'Predis\Command\ZSetReverseRange', + 'zrangebyscore' => 'Predis\Command\ZSetRangeByScore', + 'zcard' => 'Predis\Command\ZSetCardinality', + 'zscore' => 'Predis\Command\ZSetScore', + 'zremrangebyscore' => 'Predis\Command\ZSetRemoveRangeByScore', + + /* connection related commands */ + 'ping' => 'Predis\Command\ConnectionPing', + 'auth' => 'Predis\Command\ConnectionAuth', + 'select' => 'Predis\Command\ConnectionSelect', + 'echo' => 'Predis\Command\ConnectionEcho', + 'quit' => 'Predis\Command\ConnectionQuit', + + /* remote server control commands */ + 'info' => 'Predis\Command\ServerInfoV26x', + 'slaveof' => 'Predis\Command\ServerSlaveOf', + 'monitor' => 'Predis\Command\ServerMonitor', + 'dbsize' => 'Predis\Command\ServerDatabaseSize', + 'flushdb' => 'Predis\Command\ServerFlushDatabase', + 'flushall' => 'Predis\Command\ServerFlushAll', + 'save' => 'Predis\Command\ServerSave', + 'bgsave' => 'Predis\Command\ServerBackgroundSave', + 'lastsave' => 'Predis\Command\ServerLastSave', + 'shutdown' => 'Predis\Command\ServerShutdown', + 'bgrewriteaof' => 'Predis\Command\ServerBackgroundRewriteAOF', + + /* ---------------- Redis 2.0 ---------------- */ + + /* commands operating on string values */ + 'setex' => 'Predis\Command\StringSetExpire', + 'append' => 'Predis\Command\StringAppend', + 'substr' => 'Predis\Command\StringSubstr', + + /* commands operating on lists */ + 'blpop' => 'Predis\Command\ListPopFirstBlocking', + 'brpop' => 'Predis\Command\ListPopLastBlocking', + + /* commands operating on sorted sets */ + 'zunionstore' => 'Predis\Command\ZSetUnionStore', + 'zinterstore' => 'Predis\Command\ZSetIntersectionStore', + 'zcount' => 'Predis\Command\ZSetCount', + 'zrank' => 'Predis\Command\ZSetRank', + 'zrevrank' => 'Predis\Command\ZSetReverseRank', + 'zremrangebyrank' => 'Predis\Command\ZSetRemoveRangeByRank', + + /* commands operating on hashes */ + 'hset' => 'Predis\Command\HashSet', + 'hsetnx' => 'Predis\Command\HashSetPreserve', + 'hmset' => 'Predis\Command\HashSetMultiple', + 'hincrby' => 'Predis\Command\HashIncrementBy', + 'hget' => 'Predis\Command\HashGet', + 'hmget' => 'Predis\Command\HashGetMultiple', + 'hdel' => 'Predis\Command\HashDelete', + 'hexists' => 'Predis\Command\HashExists', + 'hlen' => 'Predis\Command\HashLength', + 'hkeys' => 'Predis\Command\HashKeys', + 'hvals' => 'Predis\Command\HashValues', + 'hgetall' => 'Predis\Command\HashGetAll', + + /* transactions */ + 'multi' => 'Predis\Command\TransactionMulti', + 'exec' => 'Predis\Command\TransactionExec', + 'discard' => 'Predis\Command\TransactionDiscard', + + /* publish - subscribe */ + 'subscribe' => 'Predis\Command\PubSubSubscribe', + 'unsubscribe' => 'Predis\Command\PubSubUnsubscribe', + 'psubscribe' => 'Predis\Command\PubSubSubscribeByPattern', + 'punsubscribe' => 'Predis\Command\PubSubUnsubscribeByPattern', + 'publish' => 'Predis\Command\PubSubPublish', + + /* remote server control commands */ + 'config' => 'Predis\Command\ServerConfig', + + /* ---------------- Redis 2.2 ---------------- */ + + /* commands operating on the key space */ + 'persist' => 'Predis\Command\KeyPersist', + + /* commands operating on string values */ + 'strlen' => 'Predis\Command\StringStrlen', + 'setrange' => 'Predis\Command\StringSetRange', + 'getrange' => 'Predis\Command\StringGetRange', + 'setbit' => 'Predis\Command\StringSetBit', + 'getbit' => 'Predis\Command\StringGetBit', + + /* commands operating on lists */ + 'rpushx' => 'Predis\Command\ListPushTailX', + 'lpushx' => 'Predis\Command\ListPushHeadX', + 'linsert' => 'Predis\Command\ListInsert', + 'brpoplpush' => 'Predis\Command\ListPopLastPushHeadBlocking', + + /* commands operating on sorted sets */ + 'zrevrangebyscore' => 'Predis\Command\ZSetReverseRangeByScore', + + /* transactions */ + 'watch' => 'Predis\Command\TransactionWatch', + 'unwatch' => 'Predis\Command\TransactionUnwatch', + + /* remote server control commands */ + 'object' => 'Predis\Command\ServerObject', + 'slowlog' => 'Predis\Command\ServerSlowlog', + + /* ---------------- Redis 2.4 ---------------- */ + + /* remote server control commands */ + 'client' => 'Predis\Command\ServerClient', + + /* ---------------- Redis 2.6 ---------------- */ + + /* commands operating on the key space */ + 'pttl' => 'Predis\Command\KeyPreciseTimeToLive', + 'pexpire' => 'Predis\Command\KeyPreciseExpire', + 'pexpireat' => 'Predis\Command\KeyPreciseExpireAt', + + /* commands operating on string values */ + 'psetex' => 'Predis\Command\StringPreciseSetExpire', + 'incrbyfloat' => 'Predis\Command\StringIncrementByFloat', + 'bitop' => 'Predis\Command\StringBitOp', + 'bitcount' => 'Predis\Command\StringBitCount', + + /* commands operating on hashes */ + 'hincrbyfloat' => 'Predis\Command\HashIncrementByFloat', + + /* scripting */ + 'eval' => 'Predis\Command\ServerEval', + 'evalsha' => 'Predis\Command\ServerEvalSHA', + 'script' => 'Predis\Command\ServerScript', + + /* remote server control commands */ + 'time' => 'Predis\Command\ServerTime', + + /* ---------------- Redis 2.8 ---------------- */ + + /* commands operating on the key space */ + 'scan' => 'Predis\Command\KeyScan', + + /* commands operating on sets */ + 'sscan' => 'Predis\Command\SetScan', + + /* commands operating on sorted sets */ + 'zscan' => 'Predis\Command\ZSetScan', + + /* commands operating on hashes */ + 'hscan' => 'Predis\Command\HashScan', + ); + } +} diff --git a/vendor/predis/predis/lib/Predis/Profile/ServerVersionNext.php b/vendor/predis/predis/lib/Predis/Profile/ServerVersionNext.php new file mode 100755 index 0000000..e98c354 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Profile/ServerVersionNext.php @@ -0,0 +1,36 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Profile; + +/** + * Server profile for the current unstable version of Redis. + * + * @author Daniele Alessandri + */ +class ServerVersionNext extends ServerVersion28 +{ + /** + * {@inheritdoc} + */ + public function getVersion() + { + return '3.0'; + } + + /** + * {@inheritdoc} + */ + public function getSupportedCommands() + { + return array_merge(parent::getSupportedCommands(), array()); + } +} diff --git a/vendor/predis/predis/lib/Predis/Protocol/CommandSerializerInterface.php b/vendor/predis/predis/lib/Predis/Protocol/CommandSerializerInterface.php new file mode 100755 index 0000000..f57f1ad --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Protocol/CommandSerializerInterface.php @@ -0,0 +1,30 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Protocol; + +use Predis\Command\CommandInterface; + +/** + * Interface that defines a custom serializer for Redis commands. + * + * @author Daniele Alessandri + */ +interface CommandSerializerInterface +{ + /** + * Serializes a Redis command. + * + * @param CommandInterface $command Redis command. + * @return string + */ + public function serialize(CommandInterface $command); +} diff --git a/vendor/predis/predis/lib/Predis/Protocol/ComposableProtocolInterface.php b/vendor/predis/predis/lib/Predis/Protocol/ComposableProtocolInterface.php new file mode 100755 index 0000000..56990a0 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Protocol/ComposableProtocolInterface.php @@ -0,0 +1,50 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Protocol; + +/** + * Interface that defines a customizable protocol processor that serializes + * Redis commands and parses replies returned by the server to PHP objects + * using a pluggable set of classes defining the underlying wire protocol. + * + * @author Daniele Alessandri + */ +interface ComposableProtocolInterface extends ProtocolInterface +{ + /** + * Sets the command serializer to be used by the protocol processor. + * + * @param CommandSerializerInterface $serializer Command serializer. + */ + public function setSerializer(CommandSerializerInterface $serializer); + + /** + * Returns the command serializer used by the protocol processor. + * + * @return CommandSerializerInterface + */ + public function getSerializer(); + + /** + * Sets the response reader to be used by the protocol processor. + * + * @param ResponseReaderInterface $reader Response reader. + */ + public function setReader(ResponseReaderInterface $reader); + + /** + * Returns the response reader used by the protocol processor. + * + * @return ResponseReaderInterface + */ + public function getReader(); +} diff --git a/vendor/predis/predis/lib/Predis/Protocol/ProtocolException.php b/vendor/predis/predis/lib/Predis/Protocol/ProtocolException.php new file mode 100755 index 0000000..6539021 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Protocol/ProtocolException.php @@ -0,0 +1,24 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Protocol; + +use Predis\CommunicationException; + +/** + * Exception class that identifies errors encountered while + * handling the Redis wire protocol. + * + * @author Daniele Alessandri + */ +class ProtocolException extends CommunicationException +{ +} diff --git a/vendor/predis/predis/lib/Predis/Protocol/ProtocolInterface.php b/vendor/predis/predis/lib/Predis/Protocol/ProtocolInterface.php new file mode 100755 index 0000000..cebe0e5 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Protocol/ProtocolInterface.php @@ -0,0 +1,40 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Protocol; + +use Predis\Command\CommandInterface; +use Predis\Connection\ComposableConnectionInterface; + +/** + * Interface that defines a protocol processor that serializes Redis commands + * and parses replies returned by the server to PHP objects. + * + * @author Daniele Alessandri + */ +interface ProtocolInterface extends ResponseReaderInterface +{ + /** + * Writes a Redis command on the specified connection. + * + * @param ComposableConnectionInterface $connection Connection to Redis. + * @param CommandInterface $command Redis command. + */ + public function write(ComposableConnectionInterface $connection, CommandInterface $command); + + /** + * Sets the options for the protocol processor. + * + * @param string $option Name of the option. + * @param mixed $value Value of the option. + */ + public function setOption($option, $value); +} diff --git a/vendor/predis/predis/lib/Predis/Protocol/ResponseHandlerInterface.php b/vendor/predis/predis/lib/Predis/Protocol/ResponseHandlerInterface.php new file mode 100755 index 0000000..7900fe6 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Protocol/ResponseHandlerInterface.php @@ -0,0 +1,32 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Protocol; + +use Predis\Connection\ComposableConnectionInterface; + +/** + * Interface that defines an handler able to parse a reply. + * + * @author Daniele Alessandri + */ +interface ResponseHandlerInterface +{ + /** + * Parses a type of reply returned by Redis and reads more data from the + * connection if needed. + * + * @param ComposableConnectionInterface $connection Connection to Redis. + * @param string $payload Initial payload of the reply. + * @return mixed + */ + public function handle(ComposableConnectionInterface $connection, $payload); +} diff --git a/vendor/predis/predis/lib/Predis/Protocol/ResponseReaderInterface.php b/vendor/predis/predis/lib/Predis/Protocol/ResponseReaderInterface.php new file mode 100755 index 0000000..a89cb75 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Protocol/ResponseReaderInterface.php @@ -0,0 +1,31 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Protocol; + +use Predis\Connection\ComposableConnectionInterface; + +/** + * Interface that defines a response reader able to parse replies returned by + * Redis and deserialize them to PHP objects. + * + * @author Daniele Alessandri + */ +interface ResponseReaderInterface +{ + /** + * Reads replies from a connection to Redis and deserializes them. + * + * @param ComposableConnectionInterface $connection Connection to Redis. + * @return mixed + */ + public function read(ComposableConnectionInterface $connection); +} diff --git a/vendor/predis/predis/lib/Predis/Protocol/Text/ComposableTextProtocol.php b/vendor/predis/predis/lib/Predis/Protocol/Text/ComposableTextProtocol.php new file mode 100755 index 0000000..1429990 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Protocol/Text/ComposableTextProtocol.php @@ -0,0 +1,129 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Protocol\Text; + +use Predis\Command\CommandInterface; +use Predis\Connection\ComposableConnectionInterface; +use Predis\Protocol\ResponseReaderInterface; +use Predis\Protocol\CommandSerializerInterface; +use Predis\Protocol\ComposableProtocolInterface; + +/** + * Implements a customizable protocol processor that uses the standard Redis + * wire protocol to serialize Redis commands and parse replies returned by + * the server using a pluggable set of classes. + * + * @link http://redis.io/topics/protocol + * @author Daniele Alessandri + */ +class ComposableTextProtocol implements ComposableProtocolInterface +{ + private $serializer; + private $reader; + + /** + * @param array $options Set of options used to initialize the protocol processor. + */ + public function __construct(Array $options = array()) + { + $this->setSerializer(new TextCommandSerializer()); + $this->setReader(new TextResponseReader()); + + if (count($options) > 0) { + $this->initializeOptions($options); + } + } + + /** + * Initializes the protocol processor using a set of options. + * + * @param array $options Set of options. + */ + private function initializeOptions(Array $options) + { + foreach ($options as $k => $v) { + $this->setOption($k, $v); + } + } + + /** + * {@inheritdoc} + */ + public function setOption($option, $value) + { + switch ($option) { + case 'iterable_multibulk': + $handler = $value ? new ResponseMultiBulkStreamHandler() : new ResponseMultiBulkHandler(); + $this->reader->setHandler(TextProtocol::PREFIX_MULTI_BULK, $handler); + break; + + default: + throw new \InvalidArgumentException("The option $option is not supported by the current protocol"); + } + } + + /** + * {@inheritdoc} + */ + public function serialize(CommandInterface $command) + { + return $this->serializer->serialize($command); + } + + /** + * {@inheritdoc} + */ + public function write(ComposableConnectionInterface $connection, CommandInterface $command) + { + $connection->writeBytes($this->serializer->serialize($command)); + } + + /** + * {@inheritdoc} + */ + public function read(ComposableConnectionInterface $connection) + { + return $this->reader->read($connection); + } + + /** + * {@inheritdoc} + */ + public function setSerializer(CommandSerializerInterface $serializer) + { + $this->serializer = $serializer; + } + + /** + * {@inheritdoc} + */ + public function getSerializer() + { + return $this->serializer; + } + + /** + * {@inheritdoc} + */ + public function setReader(ResponseReaderInterface $reader) + { + $this->reader = $reader; + } + + /** + * {@inheritdoc} + */ + public function getReader() + { + return $this->reader; + } +} diff --git a/vendor/predis/predis/lib/Predis/Protocol/Text/ResponseBulkHandler.php b/vendor/predis/predis/lib/Predis/Protocol/Text/ResponseBulkHandler.php new file mode 100755 index 0000000..29792cc --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Protocol/Text/ResponseBulkHandler.php @@ -0,0 +1,53 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Protocol\Text; + +use Predis\CommunicationException; +use Predis\Connection\ComposableConnectionInterface; +use Predis\Protocol\ProtocolException; +use Predis\Protocol\ResponseHandlerInterface; + +/** + * Implements a response handler for bulk replies using the standard wire + * protocol defined by Redis. + * + * @link http://redis.io/topics/protocol + * @author Daniele Alessandri + */ +class ResponseBulkHandler implements ResponseHandlerInterface +{ + /** + * Handles a bulk reply returned by Redis. + * + * @param ComposableConnectionInterface $connection Connection to Redis. + * @param string $lengthString Bytes size of the bulk reply. + * @return string + */ + public function handle(ComposableConnectionInterface $connection, $lengthString) + { + $length = (int) $lengthString; + + if ("$length" !== $lengthString) { + CommunicationException::handle(new ProtocolException( + $connection, "Cannot parse '$lengthString' as bulk length" + )); + } + + if ($length >= 0) { + return substr($connection->readBytes($length + 2), 0, -2); + } + + if ($length == -1) { + return null; + } + } +} diff --git a/vendor/predis/predis/lib/Predis/Protocol/Text/ResponseErrorHandler.php b/vendor/predis/predis/lib/Predis/Protocol/Text/ResponseErrorHandler.php new file mode 100755 index 0000000..a1e27d3 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Protocol/Text/ResponseErrorHandler.php @@ -0,0 +1,37 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Protocol\Text; + +use Predis\ResponseError; +use Predis\Connection\ComposableConnectionInterface; +use Predis\Protocol\ResponseHandlerInterface; + +/** + * Implements a response handler for error replies using the standard wire + * protocol defined by Redis. + * + * This handler returns a reply object to notify the user that an error has + * occurred on the server. + * + * @link http://redis.io/topics/protocol + * @author Daniele Alessandri + */ +class ResponseErrorHandler implements ResponseHandlerInterface +{ + /** + * {@inheritdoc} + */ + public function handle(ComposableConnectionInterface $connection, $errorMessage) + { + return new ResponseError($errorMessage); + } +} diff --git a/vendor/predis/predis/lib/Predis/Protocol/Text/ResponseIntegerHandler.php b/vendor/predis/predis/lib/Predis/Protocol/Text/ResponseIntegerHandler.php new file mode 100755 index 0000000..866a25f --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Protocol/Text/ResponseIntegerHandler.php @@ -0,0 +1,49 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Protocol\Text; + +use Predis\CommunicationException; +use Predis\Connection\ComposableConnectionInterface; +use Predis\Protocol\ProtocolException; +use Predis\Protocol\ResponseHandlerInterface; + +/** + * Implements a response handler for integer replies using the standard wire + * protocol defined by Redis. + * + * @link http://redis.io/topics/protocol + * @author Daniele Alessandri + */ +class ResponseIntegerHandler implements ResponseHandlerInterface +{ + /** + * Handles an integer reply returned by Redis. + * + * @param ComposableConnectionInterface $connection Connection to Redis. + * @param string $number String representation of an integer. + * @return int + */ + public function handle(ComposableConnectionInterface $connection, $number) + { + if (is_numeric($number)) { + return (int) $number; + } + + if ($number !== 'nil') { + CommunicationException::handle(new ProtocolException( + $connection, "Cannot parse '$number' as numeric response" + )); + } + + return null; + } +} diff --git a/vendor/predis/predis/lib/Predis/Protocol/Text/ResponseMultiBulkHandler.php b/vendor/predis/predis/lib/Predis/Protocol/Text/ResponseMultiBulkHandler.php new file mode 100755 index 0000000..06bffad --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Protocol/Text/ResponseMultiBulkHandler.php @@ -0,0 +1,72 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Protocol\Text; + +use Predis\CommunicationException; +use Predis\Connection\ComposableConnectionInterface; +use Predis\Protocol\ProtocolException; +use Predis\Protocol\ResponseHandlerInterface; + +/** + * Implements a response handler for multi-bulk replies using the standard + * wire protocol defined by Redis. + * + * @link http://redis.io/topics/protocol + * @author Daniele Alessandri + */ +class ResponseMultiBulkHandler implements ResponseHandlerInterface +{ + /** + * Handles a multi-bulk reply returned by Redis. + * + * @param ComposableConnectionInterface $connection Connection to Redis. + * @param string $lengthString Number of items in the multi-bulk reply. + * @return array + */ + public function handle(ComposableConnectionInterface $connection, $lengthString) + { + $length = (int) $lengthString; + + if ("$length" !== $lengthString) { + CommunicationException::handle(new ProtocolException( + $connection, "Cannot parse '$lengthString' as multi-bulk length" + )); + } + + if ($length === -1) { + return null; + } + + $list = array(); + + if ($length > 0) { + $handlersCache = array(); + $reader = $connection->getProtocol()->getReader(); + + for ($i = 0; $i < $length; $i++) { + $header = $connection->readLine(); + $prefix = $header[0]; + + if (isset($handlersCache[$prefix])) { + $handler = $handlersCache[$prefix]; + } else { + $handler = $reader->getHandler($prefix); + $handlersCache[$prefix] = $handler; + } + + $list[$i] = $handler->handle($connection, substr($header, 1)); + } + } + + return $list; + } +} diff --git a/vendor/predis/predis/lib/Predis/Protocol/Text/ResponseMultiBulkStreamHandler.php b/vendor/predis/predis/lib/Predis/Protocol/Text/ResponseMultiBulkStreamHandler.php new file mode 100755 index 0000000..bed3eda --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Protocol/Text/ResponseMultiBulkStreamHandler.php @@ -0,0 +1,48 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Protocol\Text; + +use Predis\CommunicationException; +use Predis\Connection\ComposableConnectionInterface; +use Predis\Iterator\MultiBulkResponseSimple; +use Predis\Protocol\ProtocolException; +use Predis\Protocol\ResponseHandlerInterface; + +/** + * Implements a response handler for iterable multi-bulk replies using the + * standard wire protocol defined by Redis. + * + * @link http://redis.io/topics/protocol + * @author Daniele Alessandri + */ +class ResponseMultiBulkStreamHandler implements ResponseHandlerInterface +{ + /** + * Handles a multi-bulk reply returned by Redis in a streamable fashion. + * + * @param ComposableConnectionInterface $connection Connection to Redis. + * @param string $lengthString Number of items in the multi-bulk reply. + * @return MultiBulkResponseSimple + */ + public function handle(ComposableConnectionInterface $connection, $lengthString) + { + $length = (int) $lengthString; + + if ("$length" != $lengthString) { + CommunicationException::handle(new ProtocolException( + $connection, "Cannot parse '$lengthString' as multi-bulk length" + )); + } + + return new MultiBulkResponseSimple($connection, $length); + } +} diff --git a/vendor/predis/predis/lib/Predis/Protocol/Text/ResponseStatusHandler.php b/vendor/predis/predis/lib/Predis/Protocol/Text/ResponseStatusHandler.php new file mode 100755 index 0000000..978996a --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Protocol/Text/ResponseStatusHandler.php @@ -0,0 +1,43 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Protocol\Text; + +use Predis\ResponseQueued; +use Predis\Connection\ComposableConnectionInterface; +use Predis\Protocol\ResponseHandlerInterface; + +/** + * Implements a response handler for status replies using the standard wire + * protocol defined by Redis. + * + * @link http://redis.io/topics/protocol + * @author Daniele Alessandri + */ +class ResponseStatusHandler implements ResponseHandlerInterface +{ + /** + * {@inheritdoc} + */ + public function handle(ComposableConnectionInterface $connection, $status) + { + switch ($status) { + case 'OK': + return true; + + case 'QUEUED': + return new ResponseQueued(); + + default: + return $status; + } + } +} diff --git a/vendor/predis/predis/lib/Predis/Protocol/Text/TextCommandSerializer.php b/vendor/predis/predis/lib/Predis/Protocol/Text/TextCommandSerializer.php new file mode 100755 index 0000000..faa27c0 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Protocol/Text/TextCommandSerializer.php @@ -0,0 +1,47 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Protocol\Text; + +use Predis\Command\CommandInterface; +use Predis\Protocol\CommandSerializerInterface; + +/** + * Implements a pluggable command serializer using the standard wire protocol + * defined by Redis. + * + * @link http://redis.io/topics/protocol + * @author Daniele Alessandri + */ +class TextCommandSerializer implements CommandSerializerInterface +{ + /** + * {@inheritdoc} + */ + public function serialize(CommandInterface $command) + { + $commandId = $command->getId(); + $arguments = $command->getArguments(); + + $cmdlen = strlen($commandId); + $reqlen = count($arguments) + 1; + + $buffer = "*{$reqlen}\r\n\${$cmdlen}\r\n{$commandId}\r\n"; + + for ($i = 0, $reqlen--; $i < $reqlen; $i++) { + $argument = $arguments[$i]; + $arglen = strlen($argument); + $buffer .= "\${$arglen}\r\n{$argument}\r\n"; + } + + return $buffer; + } +} diff --git a/vendor/predis/predis/lib/Predis/Protocol/Text/TextProtocol.php b/vendor/predis/predis/lib/Predis/Protocol/Text/TextProtocol.php new file mode 100755 index 0000000..eef0704 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Protocol/Text/TextProtocol.php @@ -0,0 +1,137 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Protocol\Text; + +use Predis\CommunicationException; +use Predis\ResponseError; +use Predis\ResponseQueued; +use Predis\Command\CommandInterface; +use Predis\Connection\ComposableConnectionInterface; +use Predis\Iterator\MultiBulkResponseSimple; +use Predis\Protocol\ProtocolException; +use Predis\Protocol\ProtocolInterface; + +/** + * Implements a protocol processor for the standard wire protocol defined by Redis. + * + * @link http://redis.io/topics/protocol + * @author Daniele Alessandri + */ +class TextProtocol implements ProtocolInterface +{ + const NEWLINE = "\r\n"; + const OK = 'OK'; + const ERROR = 'ERR'; + const QUEUED = 'QUEUED'; + const NULL = 'nil'; + + const PREFIX_STATUS = '+'; + const PREFIX_ERROR = '-'; + const PREFIX_INTEGER = ':'; + const PREFIX_BULK = '$'; + const PREFIX_MULTI_BULK = '*'; + + const BUFFER_SIZE = 4096; + + private $mbiterable; + private $serializer; + + /** + * + */ + public function __construct() + { + $this->mbiterable = false; + $this->serializer = new TextCommandSerializer(); + } + + /** + * {@inheritdoc} + */ + public function write(ComposableConnectionInterface $connection, CommandInterface $command) + { + $connection->writeBytes($this->serializer->serialize($command)); + } + + /** + * {@inheritdoc} + */ + public function read(ComposableConnectionInterface $connection) + { + $chunk = $connection->readLine(); + $prefix = $chunk[0]; + $payload = substr($chunk, 1); + + switch ($prefix) { + case '+': + switch ($payload) { + case 'OK': + return true; + + case 'QUEUED': + return new ResponseQueued(); + + default: + return $payload; + } + + case '$': + $size = (int) $payload; + if ($size === -1) { + return null; + } + + return substr($connection->readBytes($size + 2), 0, -2); + + case '*': + $count = (int) $payload; + + if ($count === -1) { + return null; + } + if ($this->mbiterable) { + return new MultiBulkResponseSimple($connection, $count); + } + + $multibulk = array(); + + for ($i = 0; $i < $count; $i++) { + $multibulk[$i] = $this->read($connection); + } + + return $multibulk; + + case ':': + return (int) $payload; + + case '-': + return new ResponseError($payload); + + default: + CommunicationException::handle(new ProtocolException( + $connection, "Unknown prefix: '$prefix'" + )); + } + } + + /** + * {@inheritdoc} + */ + public function setOption($option, $value) + { + switch ($option) { + case 'iterable_multibulk': + $this->mbiterable = (bool) $value; + break; + } + } +} diff --git a/vendor/predis/predis/lib/Predis/Protocol/Text/TextResponseReader.php b/vendor/predis/predis/lib/Predis/Protocol/Text/TextResponseReader.php new file mode 100755 index 0000000..ab02f3a --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Protocol/Text/TextResponseReader.php @@ -0,0 +1,113 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Protocol\Text; + +use Predis\CommunicationException; +use Predis\Connection\ComposableConnectionInterface; +use Predis\Protocol\ProtocolException; +use Predis\Protocol\ResponseHandlerInterface; +use Predis\Protocol\ResponseReaderInterface; + +/** + * Implements a pluggable response reader using the standard wire protocol + * defined by Redis. + * + * @link http://redis.io/topics/protocol + * @author Daniele Alessandri + */ +class TextResponseReader implements ResponseReaderInterface +{ + private $handlers; + + /** + * + */ + public function __construct() + { + $this->handlers = $this->getDefaultHandlers(); + } + + /** + * Returns the default set of response handlers for all the type of replies + * that can be returned by Redis. + */ + private function getDefaultHandlers() + { + return array( + TextProtocol::PREFIX_STATUS => new ResponseStatusHandler(), + TextProtocol::PREFIX_ERROR => new ResponseErrorHandler(), + TextProtocol::PREFIX_INTEGER => new ResponseIntegerHandler(), + TextProtocol::PREFIX_BULK => new ResponseBulkHandler(), + TextProtocol::PREFIX_MULTI_BULK => new ResponseMultiBulkHandler(), + ); + } + + /** + * Sets a response handler for a certain prefix that identifies a type of + * reply that can be returned by Redis. + * + * @param string $prefix Identifier for a type of reply. + * @param ResponseHandlerInterface $handler Response handler for the reply. + */ + public function setHandler($prefix, ResponseHandlerInterface $handler) + { + $this->handlers[$prefix] = $handler; + } + + /** + * Returns the response handler associated to a certain type of reply that + * can be returned by Redis. + * + * @param string $prefix Identifier for a type of reply. + * @return ResponseHandlerInterface + */ + public function getHandler($prefix) + { + if (isset($this->handlers[$prefix])) { + return $this->handlers[$prefix]; + } + } + + /** + * {@inheritdoc} + */ + public function read(ComposableConnectionInterface $connection) + { + $header = $connection->readLine(); + + if ($header === '') { + $this->protocolError($connection, 'Unexpected empty header'); + } + + $prefix = $header[0]; + + if (!isset($this->handlers[$prefix])) { + $this->protocolError($connection, "Unknown prefix: '$prefix'"); + } + + $handler = $this->handlers[$prefix]; + + return $handler->handle($connection, substr($header, 1)); + } + + /** + * Helper method used to handle a protocol error generated while reading a + * reply from a connection to Redis. + * + * @param ComposableConnectionInterface $connection Connection to Redis that generated the error. + * @param string $message Error message. + */ + private function protocolError(ComposableConnectionInterface $connection, $message) + { + CommunicationException::handle(new ProtocolException($connection, $message)); + } +} diff --git a/vendor/predis/predis/lib/Predis/PubSub/AbstractPubSubContext.php b/vendor/predis/predis/lib/Predis/PubSub/AbstractPubSubContext.php new file mode 100755 index 0000000..d1e83de --- /dev/null +++ b/vendor/predis/predis/lib/Predis/PubSub/AbstractPubSubContext.php @@ -0,0 +1,206 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\PubSub; + +/** + * Client-side abstraction of a Publish / Subscribe context. + * + * @author Daniele Alessandri + */ +abstract class AbstractPubSubContext implements \Iterator +{ + const SUBSCRIBE = 'subscribe'; + const UNSUBSCRIBE = 'unsubscribe'; + const PSUBSCRIBE = 'psubscribe'; + const PUNSUBSCRIBE = 'punsubscribe'; + const MESSAGE = 'message'; + const PMESSAGE = 'pmessage'; + + const STATUS_VALID = 1; // 0b0001 + const STATUS_SUBSCRIBED = 2; // 0b0010 + const STATUS_PSUBSCRIBED = 4; // 0b0100 + + private $position = null; + private $statusFlags = self::STATUS_VALID; + + /** + * Automatically closes the context when PHP's garbage collector kicks in. + */ + public function __destruct() + { + $this->closeContext(true); + } + + /** + * Checks if the specified flag is valid in the state of the context. + * + * @param int $value Flag. + * @return bool + */ + protected function isFlagSet($value) + { + return ($this->statusFlags & $value) === $value; + } + + /** + * Subscribes to the specified channels. + * + * @param mixed $channel,... One or more channel names. + */ + public function subscribe($channel /*, ... */) + { + $this->writeCommand(self::SUBSCRIBE, func_get_args()); + $this->statusFlags |= self::STATUS_SUBSCRIBED; + } + + /** + * Unsubscribes from the specified channels. + * + * @param string ... One or more channel names. + */ + public function unsubscribe(/* ... */) + { + $this->writeCommand(self::UNSUBSCRIBE, func_get_args()); + } + + /** + * Subscribes to the specified channels using a pattern. + * + * @param mixed $pattern,... One or more channel name patterns. + */ + public function psubscribe($pattern /* ... */) + { + $this->writeCommand(self::PSUBSCRIBE, func_get_args()); + $this->statusFlags |= self::STATUS_PSUBSCRIBED; + } + + /** + * Unsubscribes from the specified channels using a pattern. + * + * @param string ... One or more channel name patterns. + */ + public function punsubscribe(/* ... */) + { + $this->writeCommand(self::PUNSUBSCRIBE, func_get_args()); + } + + /** + * Closes the context by unsubscribing from all the subscribed channels. + * Optionally, the context can be forcefully closed by dropping the + * underlying connection. + * + * @param bool $force Forcefully close the context by closing the connection. + * @return bool Returns false if there are no pending messages. + */ + public function closeContext($force = false) + { + if (!$this->valid()) { + return false; + } + + if ($force) { + $this->invalidate(); + $this->disconnect(); + } else { + if ($this->isFlagSet(self::STATUS_SUBSCRIBED)) { + $this->unsubscribe(); + } + if ($this->isFlagSet(self::STATUS_PSUBSCRIBED)) { + $this->punsubscribe(); + } + } + + return !$force; + } + + /** + * Closes the underlying connection on forced disconnection. + */ + abstract protected function disconnect(); + + /** + * Writes a Redis command on the underlying connection. + * + * @param string $method ID of the command. + * @param array $arguments List of arguments. + */ + abstract protected function writeCommand($method, $arguments); + + /** + * {@inheritdoc} + */ + public function rewind() + { + // NOOP + } + + /** + * Returns the last message payload retrieved from the server and generated + * by one of the active subscriptions. + * + * @return array + */ + public function current() + { + return $this->getValue(); + } + + /** + * {@inheritdoc} + */ + public function key() + { + return $this->position; + } + + /** + * {@inheritdoc} + */ + public function next() + { + if ($this->valid()) { + $this->position++; + } + + return $this->position; + } + + /** + * Checks if the the context is still in a valid state to continue. + * + * @return bool + */ + public function valid() + { + $isValid = $this->isFlagSet(self::STATUS_VALID); + $subscriptionFlags = self::STATUS_SUBSCRIBED | self::STATUS_PSUBSCRIBED; + $hasSubscriptions = ($this->statusFlags & $subscriptionFlags) > 0; + + return $isValid && $hasSubscriptions; + } + + /** + * Resets the state of the context. + */ + protected function invalidate() + { + $this->statusFlags = 0; // 0b0000; + } + + /** + * Waits for a new message from the server generated by one of the active + * subscriptions and returns it when available. + * + * @return array + */ + abstract protected function getValue(); +} diff --git a/vendor/predis/predis/lib/Predis/PubSub/DispatcherLoop.php b/vendor/predis/predis/lib/Predis/PubSub/DispatcherLoop.php new file mode 100755 index 0000000..c35b707 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/PubSub/DispatcherLoop.php @@ -0,0 +1,170 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\PubSub; + +use Predis\ClientInterface; + +/** + * Method-dispatcher loop built around the client-side abstraction of a Redis + * Publish / Subscribe context. + * + * @author Daniele Alessandri + */ +class DispatcherLoop +{ + private $pubSubContext; + + protected $callbacks; + protected $defaultCallback; + protected $subscriptionCallback; + + /** + * @param ClientInterface $client Client instance used by the context. + */ + public function __construct(ClientInterface $client) + { + $this->callbacks = array(); + $this->pubSubContext = $client->pubSubLoop(); + } + + /** + * Checks if the passed argument is a valid callback. + * + * @param mixed $callable A callback. + */ + protected function validateCallback($callable) + { + if (!is_callable($callable)) { + throw new \InvalidArgumentException("A valid callable object must be provided"); + } + } + + /** + * Returns the underlying Publish / Subscribe context. + * + * @return PubSubContext + */ + public function getPubSubContext() + { + return $this->pubSubContext; + } + + /** + * Sets a callback that gets invoked upon new subscriptions. + * + * @param mixed $callable A callback. + */ + public function subscriptionCallback($callable = null) + { + if (isset($callable)) { + $this->validateCallback($callable); + } + + $this->subscriptionCallback = $callable; + } + + /** + * Sets a callback that gets invoked when a message is received on a + * channel that does not have an associated callback. + * + * @param mixed $callable A callback. + */ + public function defaultCallback($callable = null) + { + if (isset($callable)) { + $this->validateCallback($callable); + } + + $this->subscriptionCallback = $callable; + } + + /** + * Binds a callback to a channel. + * + * @param string $channel Channel name. + * @param Callable $callback A callback. + */ + public function attachCallback($channel, $callback) + { + $callbackName = $this->getPrefixKeys() . $channel; + + $this->validateCallback($callback); + $this->callbacks[$callbackName] = $callback; + $this->pubSubContext->subscribe($channel); + } + + /** + * Stops listening to a channel and removes the associated callback. + * + * @param string $channel Redis channel. + */ + public function detachCallback($channel) + { + $callbackName = $this->getPrefixKeys() . $channel; + + if (isset($this->callbacks[$callbackName])) { + unset($this->callbacks[$callbackName]); + $this->pubSubContext->unsubscribe($channel); + } + } + + /** + * Starts the dispatcher loop. + */ + public function run() + { + foreach ($this->pubSubContext as $message) { + $kind = $message->kind; + + if ($kind !== PubSubContext::MESSAGE && $kind !== PubSubContext::PMESSAGE) { + if (isset($this->subscriptionCallback)) { + $callback = $this->subscriptionCallback; + call_user_func($callback, $message); + } + + continue; + } + + if (isset($this->callbacks[$message->channel])) { + $callback = $this->callbacks[$message->channel]; + call_user_func($callback, $message->payload); + } elseif (isset($this->defaultCallback)) { + $callback = $this->defaultCallback; + call_user_func($callback, $message); + } + } + } + + /** + * Terminates the dispatcher loop. + */ + public function stop() + { + $this->pubSubContext->closeContext(); + } + + /** + * Return the prefix of the keys + * + * @return string + */ + protected function getPrefixKeys() + { + $options = $this->pubSubContext->getClient()->getOptions(); + + if (isset($options->prefix)) { + return $options->prefix->getPrefix(); + } + + return ''; + } +} diff --git a/vendor/predis/predis/lib/Predis/PubSub/PubSubContext.php b/vendor/predis/predis/lib/Predis/PubSub/PubSubContext.php new file mode 100755 index 0000000..c01f3c0 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/PubSub/PubSubContext.php @@ -0,0 +1,141 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\PubSub; + +use Predis\ClientException; +use Predis\ClientInterface; +use Predis\Command\AbstractCommand as Command; +use Predis\NotSupportedException; +use Predis\Connection\AggregatedConnectionInterface; + +/** + * Client-side abstraction of a Publish / Subscribe context. + * + * @author Daniele Alessandri + */ +class PubSubContext extends AbstractPubSubContext +{ + private $client; + private $options; + + /** + * @param ClientInterface $client Client instance used by the context. + * @param array $options Options for the context initialization. + */ + public function __construct(ClientInterface $client, Array $options = null) + { + $this->checkCapabilities($client); + $this->options = $options ?: array(); + $this->client = $client; + + $this->genericSubscribeInit('subscribe'); + $this->genericSubscribeInit('psubscribe'); + } + + /** + * Returns the underlying client instance used by the pub/sub iterator. + * + * @return ClientInterface + */ + public function getClient() + { + return $this->client; + } + + /** + * Checks if the passed client instance satisfies the required conditions + * needed to initialize a Publish / Subscribe context. + * + * @param ClientInterface $client Client instance used by the context. + */ + private function checkCapabilities(ClientInterface $client) + { + if ($client->getConnection() instanceof AggregatedConnectionInterface) { + throw new NotSupportedException('Cannot initialize a PUB/SUB context when using aggregated connections'); + } + + $commands = array('publish', 'subscribe', 'unsubscribe', 'psubscribe', 'punsubscribe'); + + if ($client->getProfile()->supportsCommands($commands) === false) { + throw new NotSupportedException('The current profile does not support PUB/SUB related commands'); + } + } + + /** + * This method shares the logic to handle both SUBSCRIBE and PSUBSCRIBE. + * + * @param string $subscribeAction Type of subscription. + */ + private function genericSubscribeInit($subscribeAction) + { + if (isset($this->options[$subscribeAction])) { + $this->$subscribeAction($this->options[$subscribeAction]); + } + } + + /** + * {@inheritdoc} + */ + protected function writeCommand($method, $arguments) + { + $arguments = Command::normalizeArguments($arguments); + $command = $this->client->createCommand($method, $arguments); + $this->client->getConnection()->writeCommand($command); + } + + /** + * {@inheritdoc} + */ + protected function disconnect() + { + $this->client->disconnect(); + } + + /** + * {@inheritdoc} + */ + protected function getValue() + { + $response = $this->client->getConnection()->read(); + + switch ($response[0]) { + case self::SUBSCRIBE: + case self::UNSUBSCRIBE: + case self::PSUBSCRIBE: + case self::PUNSUBSCRIBE: + if ($response[2] === 0) { + $this->invalidate(); + } + // The missing break here is intentional as we must process + // subscriptions and unsubscriptions as standard messages. + + case self::MESSAGE: + return (object) array( + 'kind' => $response[0], + 'channel' => $response[1], + 'payload' => $response[2], + ); + + case self::PMESSAGE: + return (object) array( + 'kind' => $response[0], + 'pattern' => $response[1], + 'channel' => $response[2], + 'payload' => $response[3], + ); + + default: + $message = "Received an unknown message type {$response[0]} inside of a pubsub context"; + throw new ClientException($message); + } + } +} diff --git a/vendor/predis/predis/lib/Predis/Replication/ReplicationStrategy.php b/vendor/predis/predis/lib/Predis/Replication/ReplicationStrategy.php new file mode 100755 index 0000000..2c4c9ab --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Replication/ReplicationStrategy.php @@ -0,0 +1,223 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Replication; + +use Predis\NotSupportedException; +use Predis\Command\CommandInterface; + +/** + * Defines a strategy for master/reply replication. + * + * @author Daniele Alessandri + */ +class ReplicationStrategy +{ + protected $disallowed; + protected $readonly; + protected $readonlySHA1; + + /** + * + */ + public function __construct() + { + $this->disallowed = $this->getDisallowedOperations(); + $this->readonly = $this->getReadOnlyOperations(); + $this->readonlySHA1 = array(); + } + + /** + * Returns if the specified command performs a read-only operation + * against a key stored on Redis. + * + * @param CommandInterface $command Instance of Redis command. + * @return bool + */ + public function isReadOperation(CommandInterface $command) + { + if (isset($this->disallowed[$id = $command->getId()])) { + throw new NotSupportedException("The command $id is not allowed in replication mode"); + } + + if (isset($this->readonly[$id])) { + if (true === $readonly = $this->readonly[$id]) { + return true; + } + + return call_user_func($readonly, $command); + } + + if (($eval = $id === 'EVAL') || $id === 'EVALSHA') { + $sha1 = $eval ? sha1($command->getArgument(0)) : $command->getArgument(0); + + if (isset($this->readonlySHA1[$sha1])) { + if (true === $readonly = $this->readonlySHA1[$sha1]) { + return true; + } + + return call_user_func($readonly, $command); + } + } + + return false; + } + + /** + * Returns if the specified command is disallowed in a master/slave + * replication context. + * + * @param CommandInterface $command Instance of Redis command. + * @return bool + */ + public function isDisallowedOperation(CommandInterface $command) + { + return isset($this->disallowed[$command->getId()]); + } + + /** + * Checks if a SORT command is a readable operation by parsing the arguments + * array of the specified commad instance. + * + * @param CommandInterface $command Instance of Redis command. + * @return bool + */ + protected function isSortReadOnly(CommandInterface $command) + { + $arguments = $command->getArguments(); + + return ($c = count($arguments)) === 1 ? true : $arguments[$c - 2] !== 'STORE'; + } + + /** + * Marks a command as a read-only operation. When the behaviour of a + * command can be decided only at runtime depending on its arguments, + * a callable object can be provided to dynamically check if the passed + * instance of a command performs write operations or not. + * + * @param string $commandID ID of the command. + * @param mixed $readonly A boolean or a callable object. + */ + public function setCommandReadOnly($commandID, $readonly = true) + { + $commandID = strtoupper($commandID); + + if ($readonly) { + $this->readonly[$commandID] = $readonly; + } else { + unset($this->readonly[$commandID]); + } + } + + /** + * Marks a Lua script for EVAL and EVALSHA as a read-only operation. When + * the behaviour of a script can be decided only at runtime depending on + * its arguments, a callable object can be provided to dynamically check + * if the passed instance of EVAL or EVALSHA performs write operations or + * not. + * + * @param string $script Body of the Lua script. + * @param mixed $readonly A boolean or a callable object. + */ + public function setScriptReadOnly($script, $readonly = true) + { + $sha1 = sha1($script); + + if ($readonly) { + $this->readonlySHA1[$sha1] = $readonly; + } else { + unset($this->readonlySHA1[$sha1]); + } + } + + /** + * Returns the default list of disallowed commands. + * + * @return array + */ + protected function getDisallowedOperations() + { + return array( + 'SHUTDOWN' => true, + 'INFO' => true, + 'DBSIZE' => true, + 'LASTSAVE' => true, + 'CONFIG' => true, + 'MONITOR' => true, + 'SLAVEOF' => true, + 'SAVE' => true, + 'BGSAVE' => true, + 'BGREWRITEAOF' => true, + 'SLOWLOG' => true, + ); + } + + /** + * Returns the default list of commands performing read-only operations. + * + * @return array + */ + protected function getReadOnlyOperations() + { + return array( + 'EXISTS' => true, + 'TYPE' => true, + 'KEYS' => true, + 'SCAN' => true, + 'RANDOMKEY' => true, + 'TTL' => true, + 'GET' => true, + 'MGET' => true, + 'SUBSTR' => true, + 'STRLEN' => true, + 'GETRANGE' => true, + 'GETBIT' => true, + 'LLEN' => true, + 'LRANGE' => true, + 'LINDEX' => true, + 'SCARD' => true, + 'SISMEMBER' => true, + 'SINTER' => true, + 'SUNION' => true, + 'SDIFF' => true, + 'SMEMBERS' => true, + 'SSCAN' => true, + 'SRANDMEMBER' => true, + 'ZRANGE' => true, + 'ZREVRANGE' => true, + 'ZRANGEBYSCORE' => true, + 'ZREVRANGEBYSCORE' => true, + 'ZCARD' => true, + 'ZSCORE' => true, + 'ZCOUNT' => true, + 'ZRANK' => true, + 'ZREVRANK' => true, + 'ZSCAN' => true, + 'HGET' => true, + 'HMGET' => true, + 'HEXISTS' => true, + 'HLEN' => true, + 'HKEYS' => true, + 'HVALS' => true, + 'HGETALL' => true, + 'HSCAN' => true, + 'PING' => true, + 'AUTH' => true, + 'SELECT' => true, + 'ECHO' => true, + 'QUIT' => true, + 'OBJECT' => true, + 'BITCOUNT' => true, + 'TIME' => true, + 'SORT' => array($this, 'isSortReadOnly'), + ); + } +} diff --git a/vendor/predis/predis/lib/Predis/ResponseError.php b/vendor/predis/predis/lib/Predis/ResponseError.php new file mode 100755 index 0000000..0ab9a8a --- /dev/null +++ b/vendor/predis/predis/lib/Predis/ResponseError.php @@ -0,0 +1,59 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis; + +/** + * Represents an error returned by Redis (-ERR replies) during the execution + * of a command on the server. + * + * @author Daniele Alessandri + */ +class ResponseError implements ResponseErrorInterface +{ + private $message; + + /** + * @param string $message Error message returned by Redis + */ + public function __construct($message) + { + $this->message = $message; + } + + /** + * {@inheritdoc} + */ + public function getMessage() + { + return $this->message; + } + + /** + * {@inheritdoc} + */ + public function getErrorType() + { + list($errorType, ) = explode(' ', $this->getMessage(), 2); + + return $errorType; + } + + /** + * Converts the object to its string representation. + * + * @return string + */ + public function __toString() + { + return $this->getMessage(); + } +} diff --git a/vendor/predis/predis/lib/Predis/ResponseErrorInterface.php b/vendor/predis/predis/lib/Predis/ResponseErrorInterface.php new file mode 100755 index 0000000..8c1a005 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/ResponseErrorInterface.php @@ -0,0 +1,35 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis; + +/** + * Represents an error returned by Redis (replies identified by "-" in the + * Redis response protocol) during the execution of an operation on the server. + * + * @author Daniele Alessandri + */ +interface ResponseErrorInterface extends ResponseObjectInterface +{ + /** + * Returns the error message + * + * @return string + */ + public function getMessage(); + + /** + * Returns the error type (e.g. ERR, ASK, MOVED) + * + * @return string + */ + public function getErrorType(); +} diff --git a/vendor/predis/predis/lib/Predis/ResponseObjectInterface.php b/vendor/predis/predis/lib/Predis/ResponseObjectInterface.php new file mode 100755 index 0000000..ba81783 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/ResponseObjectInterface.php @@ -0,0 +1,21 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis; + +/** + * Represents a complex reply object from Redis. + * + * @author Daniele Alessandri + */ +interface ResponseObjectInterface +{ +} diff --git a/vendor/predis/predis/lib/Predis/ResponseQueued.php b/vendor/predis/predis/lib/Predis/ResponseQueued.php new file mode 100755 index 0000000..a843269 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/ResponseQueued.php @@ -0,0 +1,53 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis; + +/** + * Represents a +QUEUED response returned by Redis as a reply to each command + * executed inside a MULTI/ EXEC transaction. + * + * @author Daniele Alessandri + */ +class ResponseQueued implements ResponseObjectInterface +{ + /** + * Converts the object to its string representation. + * + * @return string + */ + public function __toString() + { + return 'QUEUED'; + } + + /** + * Returns the value of the specified property. + * + * @param string $property Name of the property. + * @return mixed + */ + public function __get($property) + { + return $property === 'queued'; + } + + /** + * Checks if the specified property is set. + * + * @param string $property Name of the property. + * @return bool + */ + public function __isset($property) + { + return $property === 'queued'; + } +} diff --git a/vendor/predis/predis/lib/Predis/ServerException.php b/vendor/predis/predis/lib/Predis/ServerException.php new file mode 100755 index 0000000..0a60c7e --- /dev/null +++ b/vendor/predis/predis/lib/Predis/ServerException.php @@ -0,0 +1,42 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis; + +/** + * Exception class that identifies server-side Redis errors. + * + * @author Daniele Alessandri + */ +class ServerException extends PredisException implements ResponseErrorInterface +{ + /** + * Gets the type of the error returned by Redis. + * + * @return string + */ + public function getErrorType() + { + list($errorType, ) = explode(' ', $this->getMessage(), 2); + + return $errorType; + } + + /** + * Converts the exception to an instance of ResponseError. + * + * @return ResponseError + */ + public function toResponseError() + { + return new ResponseError($this->getMessage()); + } +} diff --git a/vendor/predis/predis/lib/Predis/Session/SessionHandler.php b/vendor/predis/predis/lib/Predis/Session/SessionHandler.php new file mode 100755 index 0000000..dc4e4be --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Session/SessionHandler.php @@ -0,0 +1,138 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Session; + +use SessionHandlerInterface; +use Predis\ClientInterface; + +/** + * Session handler class that relies on Predis\Client to store PHP's sessions + * data into one or multiple Redis servers. + * + * This class is mostly intended for PHP 5.4 but it can be used under PHP 5.3 provided + * that a polyfill for `SessionHandlerInterface` is defined by either you or an external + * package such as `symfony/http-foundation`. + * + * @author Daniele Alessandri + */ +class SessionHandler implements SessionHandlerInterface +{ + protected $client; + protected $ttl; + + /** + * @param ClientInterface $client Fully initialized client instance. + * @param array $options Session handler options. + */ + public function __construct(ClientInterface $client, Array $options = array()) + { + $this->client = $client; + $this->ttl = (int) (isset($options['gc_maxlifetime']) ? $options['gc_maxlifetime'] : ini_get('session.gc_maxlifetime')); + } + + /** + * Registers the handler instance as the current session handler. + */ + public function register() + { + if (version_compare(PHP_VERSION, '5.4.0') >= 0) { + session_set_save_handler($this, true); + } else { + session_set_save_handler( + array($this, 'open'), + array($this, 'close'), + array($this, 'read'), + array($this, 'write'), + array($this, 'destroy'), + array($this, 'gc') + ); + } + } + + /** + * {@inheritdoc} + */ + public function open($save_path, $session_id) + { + // NOOP + return true; + } + + /** + * {@inheritdoc} + */ + public function close() + { + // NOOP + return true; + } + + /** + * {@inheritdoc} + */ + public function gc($maxlifetime) + { + // NOOP + return true; + } + + /** + * {@inheritdoc} + */ + public function read($session_id) + { + if ($data = $this->client->get($session_id)) { + return $data; + } + + return ''; + } + /** + * {@inheritdoc} + */ + public function write($session_id, $session_data) + { + $this->client->setex($session_id, $this->ttl, $session_data); + + return true; + } + + /** + * {@inheritdoc} + */ + public function destroy($session_id) + { + $this->client->del($session_id); + + return true; + } + + /** + * Returns the underlying client instance. + * + * @return ClientInterface + */ + public function getClient() + { + return $this->client; + } + + /** + * Returns the session max lifetime value. + * + * @return int + */ + public function getMaxLifeTime() + { + return $this->ttl; + } +} diff --git a/vendor/predis/predis/lib/Predis/Transaction/AbortedMultiExecException.php b/vendor/predis/predis/lib/Predis/Transaction/AbortedMultiExecException.php new file mode 100755 index 0000000..81eed8b --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Transaction/AbortedMultiExecException.php @@ -0,0 +1,45 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Transaction; + +use Predis\PredisException; + +/** + * Exception class that identifies MULTI / EXEC transactions aborted by Redis. + * + * @author Daniele Alessandri + */ +class AbortedMultiExecException extends PredisException +{ + private $transaction; + + /** + * @param MultiExecContext $transaction Transaction that generated the exception. + * @param string $message Error message. + * @param int $code Error code. + */ + public function __construct(MultiExecContext $transaction, $message, $code = null) + { + parent::__construct($message, $code); + $this->transaction = $transaction; + } + + /** + * Returns the transaction that generated the exception. + * + * @return MultiExecContext + */ + public function getTransaction() + { + return $this->transaction; + } +} diff --git a/vendor/predis/predis/lib/Predis/Transaction/MultiExecContext.php b/vendor/predis/predis/lib/Predis/Transaction/MultiExecContext.php new file mode 100755 index 0000000..52fcaa7 --- /dev/null +++ b/vendor/predis/predis/lib/Predis/Transaction/MultiExecContext.php @@ -0,0 +1,449 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Transaction; + +use SplQueue; +use Predis\BasicClientInterface; +use Predis\ClientException; +use Predis\ClientInterface; +use Predis\CommunicationException; +use Predis\ExecutableContextInterface; +use Predis\NotSupportedException; +use Predis\ResponseErrorInterface; +use Predis\ResponseQueued; +use Predis\ServerException; +use Predis\Command\CommandInterface; +use Predis\Connection\AggregatedConnectionInterface; +use Predis\Protocol\ProtocolException; + +/** + * Client-side abstraction of a Redis transaction based on MULTI / EXEC. + * + * @author Daniele Alessandri + */ +class MultiExecContext implements BasicClientInterface, ExecutableContextInterface +{ + const STATE_RESET = 0; // 0b00000 + const STATE_INITIALIZED = 1; // 0b00001 + const STATE_INSIDEBLOCK = 2; // 0b00010 + const STATE_DISCARDED = 4; // 0b00100 + const STATE_CAS = 8; // 0b01000 + const STATE_WATCH = 16; // 0b10000 + + private $state; + private $canWatch; + + protected $client; + protected $options; + protected $commands; + + /** + * @param ClientInterface $client Client instance used by the context. + * @param array $options Options for the context initialization. + */ + public function __construct(ClientInterface $client, Array $options = null) + { + $this->checkCapabilities($client); + $this->options = $options ?: array(); + $this->client = $client; + $this->reset(); + } + + /** + * Sets the internal state flags. + * + * @param int $flags Set of flags + */ + protected function setState($flags) + { + $this->state = $flags; + } + + /** + * Gets the internal state flags. + * + * @return int + */ + protected function getState() + { + return $this->state; + } + + /** + * Sets one or more flags. + * + * @param int $flags Set of flags + */ + protected function flagState($flags) + { + $this->state |= $flags; + } + + /** + * Resets one or more flags. + * + * @param int $flags Set of flags + */ + protected function unflagState($flags) + { + $this->state &= ~$flags; + } + + /** + * Checks is a flag is set. + * + * @param int $flags Flag + * @return bool + */ + protected function checkState($flags) + { + return ($this->state & $flags) === $flags; + } + + /** + * Checks if the passed client instance satisfies the required conditions + * needed to initialize a transaction context. + * + * @param ClientInterface $client Client instance used by the context. + */ + private function checkCapabilities(ClientInterface $client) + { + if ($client->getConnection() instanceof AggregatedConnectionInterface) { + throw new NotSupportedException('Cannot initialize a MULTI/EXEC context when using aggregated connections'); + } + + $profile = $client->getProfile(); + + if ($profile->supportsCommands(array('multi', 'exec', 'discard')) === false) { + throw new NotSupportedException('The current profile does not support MULTI, EXEC and DISCARD'); + } + + $this->canWatch = $profile->supportsCommands(array('watch', 'unwatch')); + } + + /** + * Checks if WATCH and UNWATCH are supported by the server profile. + */ + private function isWatchSupported() + { + if ($this->canWatch === false) { + throw new NotSupportedException('The current profile does not support WATCH and UNWATCH'); + } + } + + /** + * Resets the state of a transaction. + */ + protected function reset() + { + $this->setState(self::STATE_RESET); + $this->commands = new SplQueue(); + } + + /** + * Initializes a new transaction. + */ + protected function initialize() + { + if ($this->checkState(self::STATE_INITIALIZED)) { + return; + } + + $options = $this->options; + + if (isset($options['cas']) && $options['cas']) { + $this->flagState(self::STATE_CAS); + } + if (isset($options['watch'])) { + $this->watch($options['watch']); + } + + $cas = $this->checkState(self::STATE_CAS); + $discarded = $this->checkState(self::STATE_DISCARDED); + + if (!$cas || ($cas && $discarded)) { + $this->client->multi(); + + if ($discarded) { + $this->unflagState(self::STATE_CAS); + } + } + + $this->unflagState(self::STATE_DISCARDED); + $this->flagState(self::STATE_INITIALIZED); + } + + /** + * Dynamically invokes a Redis command with the specified arguments. + * + * @param string $method Command ID. + * @param array $arguments Arguments for the command. + * @return mixed + */ + public function __call($method, $arguments) + { + $command = $this->client->createCommand($method, $arguments); + $response = $this->executeCommand($command); + + return $response; + } + + /** + * Executes the specified Redis command. + * + * @param CommandInterface $command Command instance. + * @return $this|mixed + */ + public function executeCommand(CommandInterface $command) + { + $this->initialize(); + $response = $this->client->executeCommand($command); + + if ($this->checkState(self::STATE_CAS)) { + return $response; + } + + if (!$response instanceof ResponseQueued) { + $this->onProtocolError('The server did not respond with a QUEUED status reply'); + } + + $this->commands->enqueue($command); + + return $this; + } + + /** + * Executes WATCH on one or more keys. + * + * @param string|array $keys One or more keys. + * @return mixed + */ + public function watch($keys) + { + $this->isWatchSupported(); + + if ($this->checkState(self::STATE_INITIALIZED) && !$this->checkState(self::STATE_CAS)) { + throw new ClientException('WATCH after MULTI is not allowed'); + } + + $reply = $this->client->watch($keys); + $this->flagState(self::STATE_WATCH); + + return $reply; + } + + /** + * Finalizes the transaction on the server by executing MULTI on the server. + * + * @return MultiExecContext + */ + public function multi() + { + if ($this->checkState(self::STATE_INITIALIZED | self::STATE_CAS)) { + $this->unflagState(self::STATE_CAS); + $this->client->multi(); + } else { + $this->initialize(); + } + + return $this; + } + + /** + * Executes UNWATCH. + * + * @return MultiExecContext + */ + public function unwatch() + { + $this->isWatchSupported(); + $this->unflagState(self::STATE_WATCH); + $this->__call('unwatch', array()); + + return $this; + } + + /** + * Resets a transaction by UNWATCHing the keys that are being WATCHed and + * DISCARDing the pending commands that have been already sent to the server. + * + * @return MultiExecContext + */ + public function discard() + { + if ($this->checkState(self::STATE_INITIALIZED)) { + $command = $this->checkState(self::STATE_CAS) ? 'unwatch' : 'discard'; + $this->client->$command(); + $this->reset(); + $this->flagState(self::STATE_DISCARDED); + } + + return $this; + } + + /** + * Executes the whole transaction. + * + * @return mixed + */ + public function exec() + { + return $this->execute(); + } + + /** + * Checks the state of the transaction before execution. + * + * @param mixed $callable Callback for execution. + */ + private function checkBeforeExecution($callable) + { + if ($this->checkState(self::STATE_INSIDEBLOCK)) { + throw new ClientException("Cannot invoke 'execute' or 'exec' inside an active client transaction block"); + } + + if ($callable) { + if (!is_callable($callable)) { + throw new \InvalidArgumentException('Argument passed must be a callable object'); + } + + if (!$this->commands->isEmpty()) { + $this->discard(); + throw new ClientException('Cannot execute a transaction block after using fluent interface'); + } + } + + if (isset($this->options['retry']) && !isset($callable)) { + $this->discard(); + throw new \InvalidArgumentException('Automatic retries can be used only when a transaction block is provided'); + } + } + + /** + * Handles the actual execution of the whole transaction. + * + * @param mixed $callable Optional callback for execution. + * @return array + */ + public function execute($callable = null) + { + $this->checkBeforeExecution($callable); + + $reply = null; + $values = array(); + $attempts = isset($this->options['retry']) ? (int) $this->options['retry'] : 0; + + do { + if ($callable !== null) { + $this->executeTransactionBlock($callable); + } + + if ($this->commands->isEmpty()) { + if ($this->checkState(self::STATE_WATCH)) { + $this->discard(); + } + + return null; + } + + $reply = $this->client->exec(); + + if ($reply === null) { + if ($attempts === 0) { + $message = 'The current transaction has been aborted by the server'; + throw new AbortedMultiExecException($this, $message); + } + + $this->reset(); + + if (isset($this->options['on_retry']) && is_callable($this->options['on_retry'])) { + call_user_func($this->options['on_retry'], $this, $attempts); + } + + continue; + } + + break; + } while ($attempts-- > 0); + + $exec = $reply instanceof \Iterator ? iterator_to_array($reply) : $reply; + $commands = $this->commands; + + $size = count($exec); + if ($size !== count($commands)) { + $this->onProtocolError("EXEC returned an unexpected number of replies"); + } + + $clientOpts = $this->client->getOptions(); + $useExceptions = isset($clientOpts->exceptions) ? $clientOpts->exceptions : true; + + for ($i = 0; $i < $size; $i++) { + $commandReply = $exec[$i]; + + if ($commandReply instanceof ResponseErrorInterface && $useExceptions) { + $message = $commandReply->getMessage(); + throw new ServerException($message); + } + + if ($commandReply instanceof \Iterator) { + $commandReply = iterator_to_array($commandReply); + } + + $values[$i] = $commands->dequeue()->parseResponse($commandReply); + } + + return $values; + } + + /** + * Passes the current transaction context to a callable block for execution. + * + * @param mixed $callable Callback. + */ + protected function executeTransactionBlock($callable) + { + $blockException = null; + $this->flagState(self::STATE_INSIDEBLOCK); + + try { + call_user_func($callable, $this); + } catch (CommunicationException $exception) { + $blockException = $exception; + } catch (ServerException $exception) { + $blockException = $exception; + } catch (\Exception $exception) { + $blockException = $exception; + $this->discard(); + } + + $this->unflagState(self::STATE_INSIDEBLOCK); + + if ($blockException !== null) { + throw $blockException; + } + } + + /** + * Helper method that handles protocol errors encountered inside a transaction. + * + * @param string $message Error message. + */ + private function onProtocolError($message) + { + // Since a MULTI/EXEC block cannot be initialized when using aggregated + // connections, we can safely assume that Predis\Client::getConnection() + // will always return an instance of Predis\Connection\SingleConnectionInterface. + CommunicationException::handle(new ProtocolException( + $this->client->getConnection(), $message + )); + } +} diff --git a/vendor/predis/predis/package.ini b/vendor/predis/predis/package.ini new file mode 100755 index 0000000..06f3e97 --- /dev/null +++ b/vendor/predis/predis/package.ini @@ -0,0 +1,37 @@ +; This file is meant to be used with Onion http://c9s.github.com/Onion/ +; For instructions on how to build a PEAR package of Predis please follow +; the instructions at this URL: +; +; https://github.com/c9s/Onion#a-quick-tutorial-for-building-pear-package +; + +[package] +name = "Predis" +desc = "Flexible and feature-complete PHP client library for Redis" +homepage = "http://github.com/nrk/predis" +license = "MIT" +version = "0.8.5" +stability = "stable" +channel = "pear.nrk.io" + +author = "Daniele Alessandri \"nrk\" " + +[require] +php = ">= 5.3.2" +pearinstaller = "1.4.1" + +[roles] +*.xml.dist = test +*.md = doc +LICENSE = doc +lib = php + +[optional phpiredis] +hint = "Add support for faster protocol handling with phpiredis" +extensions[] = socket +extensions[] = phpiredis + +[optional webdis] +hint = "Add support for Webdis" +extensions[] = curl +extensions[] = phpiredis diff --git a/vendor/predis/predis/phpunit.xml.dist b/vendor/predis/predis/phpunit.xml.dist new file mode 100755 index 0000000..1a6a012 --- /dev/null +++ b/vendor/predis/predis/phpunit.xml.dist @@ -0,0 +1,39 @@ + + + + + + tests/Predis/ + + + + + + ext-phpiredis + ext-curl + realm-webdis + + + + + + + + + + lib/Predis/ + + + + + + + + + + + + + + + diff --git a/vendor/predis/predis/phpunit.xml.travisci b/vendor/predis/predis/phpunit.xml.travisci new file mode 100755 index 0000000..a74297e --- /dev/null +++ b/vendor/predis/predis/phpunit.xml.travisci @@ -0,0 +1,43 @@ + + + + + + tests/Predis/ + + + + + + ext-phpiredis + ext-curl + realm-webdis + + + + + + + + + + lib/Predis/ + + + + + + + + + + + + + + + + + + + diff --git a/vendor/predis/predis/tests/PHPUnit/ArrayHasSameValuesConstraint.php b/vendor/predis/predis/tests/PHPUnit/ArrayHasSameValuesConstraint.php new file mode 100755 index 0000000..13035bb --- /dev/null +++ b/vendor/predis/predis/tests/PHPUnit/ArrayHasSameValuesConstraint.php @@ -0,0 +1,58 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +/** + * Constraint that accepts arrays with the same elements but different order. + */ +class ArrayHasSameValuesConstraint extends PHPUnit_Framework_Constraint +{ + protected $array; + + /** + * @param array $array + */ + public function __construct($array) + { + $this->array = $array; + } + + /** + * {@inheritdoc} + */ + public function matches($other) + { + if (count($this->array) !== count($other)) { + return false; + } + + if (array_diff($this->array, $other)) { + return false; + } + + return true; + } + + /** + * {@inheritdoc} + */ + public function toString() + { + return 'two arrays contain the same elements.'; + } + + /** + * {@inheritdoc} + */ + protected function failureDescription($other) + { + return $this->toString(); + } +} diff --git a/vendor/predis/predis/tests/PHPUnit/PredisCommandTestCase.php b/vendor/predis/predis/tests/PHPUnit/PredisCommandTestCase.php new file mode 100755 index 0000000..8dc08cc --- /dev/null +++ b/vendor/predis/predis/tests/PHPUnit/PredisCommandTestCase.php @@ -0,0 +1,127 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +use PredisTestCase; +use Predis\Client; + +/** + * + */ +abstract class PredisCommandTestCase extends PredisTestCase +{ + /** + * Returns the expected command. + * + * @return CommandInterface|string Instance or FQN of the expected command. + */ + abstract protected function getExpectedCommand(); + + /** + * Returns the expected command ID. + * + * @return string + */ + abstract protected function getExpectedId(); + + /** + * Returns a new command instance. + * + * @return CommandInterface + */ + public function getCommand() + { + $command = $this->getExpectedCommand(); + + return $command instanceof CommandInterface ? $command : new $command(); + } + + /** + * Returns a new client instance. + * + * @param bool $flushdb Flush selected database before returning the client. + * @return Client + */ + public function getClient($flushdb = true) + { + $profile = $this->getProfile(); + + if (!$profile->supportsCommand($id = $this->getExpectedId())) { + $this->markTestSkipped( + "The profile {$profile->getVersion()} does not support command {$id}" + ); + } + + $client = $this->createClient(null, null, $flushdb); + + return $client; + } + + /** + * Returns wether the command is prefixable or not. + * + * @return bool + */ + protected function isPrefixable() + { + return $this->getCommand() instanceof PrefixableCommandInterface; + } + + /** + * Returns a new command instance with the specified arguments. + * + * @param ... List of arguments for the command. + * @return CommandInterface + */ + protected function getCommandWithArguments(/* arguments */) + { + return $this->getCommandWithArgumentsArray(func_get_args()); + } + + /** + * Returns a new command instance with the specified arguments. + * + * @param array $arguments Arguments for the command. + * @return CommandInterface + */ + protected function getCommandWithArgumentsArray(Array $arguments) + { + $command = $this->getCommand(); + $command->setArguments($arguments); + + return $command; + } + + /** + * @group disconnected + */ + public function testCommandId() + { + $command = $this->getCommand(); + + $this->assertInstanceOf('Predis\Command\CommandInterface', $command); + $this->assertEquals($this->getExpectedId(), $command->getId()); + } + + /** + * @group disconnected + */ + public function testRawArguments() + { + $expected = array('1st', '2nd', '3rd', '4th'); + + $command = $this->getCommand(); + $command->setRawArguments($expected); + + $this->assertSame($expected, $command->getArguments()); + } +} diff --git a/vendor/predis/predis/tests/PHPUnit/PredisConnectionTestCase.php b/vendor/predis/predis/tests/PHPUnit/PredisConnectionTestCase.php new file mode 100755 index 0000000..0ac6545 --- /dev/null +++ b/vendor/predis/predis/tests/PHPUnit/PredisConnectionTestCase.php @@ -0,0 +1,333 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Connection; + +use PredisTestCase; +use Predis\Profile\ServerProfile; + +/** + * @group realm-connection + */ +abstract class PredisConnectionTestCase extends PredisTestCase +{ + /** + * @group disconnected + * @group slow + * @expectedException Predis\Connection\ConnectionException + */ + public function testThrowExceptionWhenUnableToConnect() + { + $parameters = array('host' => '169.254.10.10', 'timeout' => 0.5); + $connection = $this->getConnection($profile, false, $parameters); + $connection->executeCommand($this->getProfile()->createCommand('ping')); + } + + // ******************************************************************** // + // ---- INTEGRATION TESTS --------------------------------------------- // + // ******************************************************************** // + + /** + * @group connected + */ + public function testConnectForcesConnection() + { + $connection = $this->getConnection(); + + $this->assertFalse($connection->isConnected()); + $connection->connect(); + $this->assertTrue($connection->isConnected()); + } + + /** + * @group connected + * @expectedException Predis\ClientException + * @expectedExceptionMessage Connection already estabilished + */ + public function testThrowsExceptionOnConnectWhenAlreadyConnected() + { + $connection = $this->getConnection(); + + $connection->connect(); + $connection->connect(); + } + + /** + * @group connected + */ + public function testDisconnectForcesDisconnection() + { + $connection = $this->getConnection(); + + $connection->connect(); + $this->assertTrue($connection->isConnected()); + + $connection->disconnect(); + $this->assertFalse($connection->isConnected()); + } + + /** + * @group disconnected + */ + public function testDoesNotThrowExceptionOnDisconnectWhenAlreadyDisconnected() + { + $connection = $this->getConnection(); + + $this->assertFalse($connection->isConnected()); + $connection->disconnect(); + $this->assertFalse($connection->isConnected()); + } + + /** + * @group connected + */ + public function testGetResourceForcesConnection() + { + $connection = $this->getConnection(); + + $this->assertFalse($connection->isConnected()); + $this->assertInternalType('resource', $connection->getResource()); + $this->assertTrue($connection->isConnected()); + } + + /** + * @group connected + */ + public function testSendingCommandForcesConnection() + { + $connection = $this->getConnection($profile); + $cmdPing = $profile->createCommand('ping'); + + $this->assertSame('PONG', $connection->executeCommand($cmdPing)); + $this->assertTrue($connection->isConnected()); + } + + /** + * @group connected + */ + public function testExecutesCommandOnServer() + { + $connection = $this->getConnection($profile); + + $cmdPing = $this->getMock($profile->getCommandClass('ping'), array('parseResponse')); + $cmdPing->expects($this->never()) + ->method('parseResponse'); + + $this->assertSame('PONG', $connection->executeCommand($cmdPing)); + } + + /** + * @group connected + */ + public function testWritesCommandToServer() + { + $connection = $this->getConnection($profile); + + $cmdPing = $this->getMock($profile->getCommandClass('ping'), array('parseResponse')); + $cmdPing->expects($this->never()) + ->method('parseResponse'); + + $connection->writeCommand($cmdPing); + $connection->disconnect(); + } + + /** + * @group connected + */ + public function testReadsCommandFromServer() + { + $connection = $this->getConnection($profile); + + $cmdPing = $this->getMock($profile->getCommandClass('ping'), array('parseResponse')); + $cmdPing->expects($this->never()) + ->method('parseResponse'); + + $connection->writeCommand($cmdPing); + $this->assertSame('PONG', $connection->readResponse($cmdPing)); + } + + /** + * @group connected + */ + public function testIsAbleToWriteMultipleCommandsAndReadThemBackForPipelining() + { + $connection = $this->getConnection($profile); + + $cmdPing = $this->getMock($profile->getCommandClass('ping'), array('parseResponse')); + $cmdPing->expects($this->never()) + ->method('parseResponse'); + + $cmdEcho = $this->getMock($profile->getCommandClass('echo'), array('parseResponse')); + $cmdEcho->setArguments(array('ECHOED')); + $cmdEcho->expects($this->never()) + ->method('parseResponse'); + + $connection = $this->getConnection(); + + $connection->writeCommand($cmdPing); + $connection->writeCommand($cmdEcho); + + $this->assertSame('PONG', $connection->readResponse($cmdPing)); + $this->assertSame('ECHOED', $connection->readResponse($cmdEcho)); + } + + /** + * @group connected + */ + public function testSendsInitializationCommandsOnConnection() + { + $connection = $this->getConnection($profile, true); + + $cmdPing = $this->getMock($profile->getCommandClass('ping'), array('getArguments')); + $cmdPing->expects($this->once()) + ->method('getArguments') + ->will($this->returnValue(array())); + + $cmdEcho = $this->getMock($profile->getCommandClass('echo'), array('getArguments')); + $cmdEcho->expects($this->once()) + ->method('getArguments') + ->will($this->returnValue(array('ECHOED'))); + + $connection->pushInitCommand($cmdPing); + $connection->pushInitCommand($cmdEcho); + + $connection->connect(); + } + + /** + * @group connected + */ + public function testReadsStatusReplies() + { + $connection = $this->getConnection($profile, true); + + $connection->writeCommand($profile->createCommand('set', array('foo', 'bar'))); + $this->assertTrue($connection->read()); + + $connection->writeCommand($profile->createCommand('ping')); + $this->assertSame('PONG', $connection->read()); + + $connection->writeCommand($profile->createCommand('multi')); + $connection->writeCommand($profile->createCommand('ping')); + $this->assertTrue($connection->read()); + $this->assertInstanceOf('Predis\ResponseQueued', $connection->read()); + } + + /** + * @group connected + */ + public function testReadsBulkReplies() + { + $connection = $this->getConnection($profile, true); + + $connection->executeCommand($profile->createCommand('set', array('foo', 'bar'))); + + $connection->writeCommand($profile->createCommand('get', array('foo'))); + $this->assertSame('bar', $connection->read()); + + $connection->writeCommand($profile->createCommand('get', array('hoge'))); + $this->assertNull($connection->read()); + } + + /** + * @group connected + */ + public function testReadsIntegerReplies() + { + $connection = $this->getConnection($profile, true); + + $connection->executeCommand($profile->createCommand('rpush', array('metavars', 'foo', 'hoge', 'lol'))); + $connection->writeCommand($profile->createCommand('llen', array('metavars'))); + + $this->assertSame(3, $connection->read()); + } + + /** + * @group connected + */ + public function testReadsErrorRepliesAsResponseErrorObjects() + { + $connection = $this->getConnection($profile, true); + + $connection->executeCommand($profile->createCommand('set', array('foo', 'bar'))); + $connection->writeCommand($profile->createCommand('rpush', array('foo', 'baz'))); + + $this->assertInstanceOf('Predis\ResponseError', $error = $connection->read()); + $this->assertRegExp('/[ERR|WRONGTYPE] Operation against a key holding the wrong kind of value/', $error->getMessage()); + } + + /** + * @group connected + */ + public function testReadsMultibulkRepliesAsArrays() + { + $connection = $this->getConnection($profile, true); + + $connection->executeCommand($profile->createCommand('rpush', array('metavars', 'foo', 'hoge', 'lol'))); + $connection->writeCommand($profile->createCommand('lrange', array('metavars', 0, -1))); + + $this->assertSame(array('foo', 'hoge', 'lol'), $connection->read()); + } + + /** + * @group connected + * @group slow + * @expectedException Predis\Connection\ConnectionException + */ + public function testThrowsExceptionOnConnectionTimeout() + { + $connection = $this->getConnection($_, false, array('host' => '169.254.10.10', 'timeout' => 0.5)); + + $connection->connect(); + } + + /** + * @group connected + * @group slow + * @expectedException Predis\Connection\ConnectionException + */ + public function testThrowsExceptionOnReadWriteTimeout() + { + $connection = $this->getConnection($profile, true, array('read_write_timeout' => 0.5)); + + $connection->executeCommand($profile->createCommand('brpop', array('foo', 3))); + } + + // ******************************************************************** // + // ---- HELPER METHODS ------------------------------------------------ // + // ******************************************************************** // + + /** + * Returns a named array with the default connection parameters and their values. + * + * @return Array Default connection parameters. + */ + protected function getDefaultParametersArray() + { + return array( + 'scheme' => 'tcp', + 'host' => REDIS_SERVER_HOST, + 'port' => REDIS_SERVER_PORT, + 'database' => REDIS_SERVER_DBNUM, + 'read_write_timeout' => 2, + ); + } + + /** + * Returns a new instance of a connection instance. + * + * @param ServerProfile $profile Reference to the server profile instance. + * @param bool $initialize Push default initialization commands (SELECT and FLUSHDB). + * @param array $parameters Additional connection parameters. + * @return StreamConnection + */ + abstract protected function getConnection(&$profile = null, $initialize = false, Array $parameters = array()); +} diff --git a/vendor/predis/predis/tests/PHPUnit/PredisDistributorTestCase.php b/vendor/predis/predis/tests/PHPUnit/PredisDistributorTestCase.php new file mode 100755 index 0000000..29e06aa --- /dev/null +++ b/vendor/predis/predis/tests/PHPUnit/PredisDistributorTestCase.php @@ -0,0 +1,67 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Cluster\Distribution; + +use PredisTestCase; + +/** + * + */ +abstract class PredisDistributorTestCase extends PredisTestCase +{ + /** + * Returns a new instance of the tested distributor. + * + * @return Predis\Cluster\Distribution\DistributionStrategyInterface + */ + abstract protected function getDistributorInstance(); + + /** + * Returns a list of nodes from the hashring. + * + * @param DistributionStrategyInterface $ring Hashring instance. + * @param int $iterations Number of nodes to fetch. + * @return array Nodes from the hashring. + */ + protected function getNodes(DistributionStrategyInterface $ring, $iterations = 10) + { + $nodes = array(); + + for ($i = 0; $i < $iterations; $i++) { + $key = $ring->hash($i * $i); + $nodes[] = $ring->get($key); + } + + return $nodes; + } + + /** + * @group disconnected + */ + public function testEmptyRingThrowsException() + { + $this->setExpectedException('Predis\Cluster\Distribution\EmptyRingException'); + + $ring = $this->getDistributorInstance(); + $ring->get('nodekey'); + } + + /** + * @group disconnected + */ + public function testRemoveOnEmptyRingDoesNotThrowException() + { + $ring = $this->getDistributorInstance(); + + $this->assertNull($ring->remove('node')); + } +} diff --git a/vendor/predis/predis/tests/PHPUnit/PredisProfileTestCase.php b/vendor/predis/predis/tests/PHPUnit/PredisProfileTestCase.php new file mode 100755 index 0000000..b5d46f6 --- /dev/null +++ b/vendor/predis/predis/tests/PHPUnit/PredisProfileTestCase.php @@ -0,0 +1,81 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Profile; + +use PredisTestCase; + +/** + * + */ +abstract class PredisProfileTestCase extends PredisTestCase +{ + /** + * Returns a new instance of the tested profile. + * + * @param string $version Version of Redis. + * @return ServerProfileInterface + */ + protected function getProfile($version = null) + { + $this->markTestIncomplete("Server profile must be defined in ".get_class($this)); + } + + /** + * Returns the expected version string for the tested profile. + * + * @return string Version string. + */ + abstract protected function getExpectedVersion(); + + /** + * Returns the expected list of commands supported by the tested profile. + * + * @return array List of supported commands. + */ + abstract protected function getExpectedCommands(); + + /** + * Returns the list of commands supported by the current + * server profile. + * + * @param ServerProfileInterface $profile Server profile instance. + * @return array + */ + protected function getCommands(ServerProfileInterface $profile) + { + $commands = $profile->getSupportedCommands(); + + return array_keys($commands); + } + + /** + * @group disconnected + */ + public function testGetVersion() + { + $profile = $this->getProfile(); + + $this->assertEquals($this->getExpectedVersion(), $profile->getVersion()); + } + + /** + * @group disconnected + */ + public function testSupportedCommands() + { + $profile = $this->getProfile(); + $expected = $this->getExpectedCommands(); + $commands = $this->getCommands($profile); + + $this->assertSame($expected, $commands); + } +} diff --git a/vendor/predis/predis/tests/PHPUnit/PredisTestCase.php b/vendor/predis/predis/tests/PHPUnit/PredisTestCase.php new file mode 100755 index 0000000..9b24928 --- /dev/null +++ b/vendor/predis/predis/tests/PHPUnit/PredisTestCase.php @@ -0,0 +1,240 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +use Predis\Client; +use Predis\Command\CommandInterface; +use Predis\Connection\ConnectionParameters; +use Predis\Profile\ServerProfile; +use Predis\Profile\ServerProfileInterface; + +/** + * Base test case class for the Predis test suite. + */ +abstract class PredisTestCase extends PHPUnit_Framework_TestCase +{ + /** + * Verifies that a Redis command is a valid Predis\Command\CommandInterface + * instance with the specified ID and command arguments. + * + * @param string|CommandInterface $command Expected command or command ID. + * @param array $arguments Expected command arguments. + * @return RedisCommandConstraint + */ + public function isRedisCommand($command = null, array $arguments = null) + { + return new RedisCommandConstraint($command, $arguments); + } + + /** + * Verifies that a Redis command is a valid Predis\Command\CommandInterface + * instance with the specified ID and command arguments. The comparison does + * not check for identity when passing a Predis\Command\CommandInterface + * instance for $expected. + * + * @param array|string|CommandInterface $expected Expected command. + * @param mixed $actual Actual command. + * @param string $message Optional assertion message. + */ + public function assertRedisCommand($expected, $actual, $message = '') + { + if (is_array($expected)) { + @list($command, $arguments) = $expected; + } else { + $command = $expected; + $arguments = null; + } + + $this->assertThat($actual, new RedisCommandConstraint($command, $arguments), $message); + } + + /** + * Asserts that two arrays have the same values, even if with different order. + * + * @param array $expected Expected array. + * @param array $actual Actual array. + * @param string $message Optional assertion message. + */ + public function assertSameValues(array $expected, array $actual, $message = '') + { + $this->assertThat($actual, new ArrayHasSameValuesConstraint($expected), $message); + } + + /** + * Returns a named array with the default connection parameters and their values. + * + * @return array Default connection parameters. + */ + protected function getDefaultParametersArray() + { + return array( + 'scheme' => 'tcp', + 'host' => REDIS_SERVER_HOST, + 'port' => REDIS_SERVER_PORT, + 'database' => REDIS_SERVER_DBNUM, + ); + } + + /** + * Returns a named array with the default client options and their values. + * + * @return array Default connection parameters. + */ + protected function getDefaultOptionsArray() + { + return array( + 'profile' => REDIS_SERVER_VERSION, + ); + } + + /** + * Returns a named array with the default connection parameters merged with + * the specified additional parameters. + * + * @param array $additional Additional connection parameters. + * @return array Connection parameters. + */ + protected function getParametersArray(array $additional) + { + return array_merge($this->getDefaultParametersArray(), $additional); + } + + /** + * Returns a new instance of connection parameters. + * + * @param array $additional Additional connection parameters. + * @return Connection\ConnectionParameters Default connection parameters. + */ + protected function getParameters($additional = array()) + { + $parameters = array_merge($this->getDefaultParametersArray(), $additional); + $parameters = new ConnectionParameters($parameters); + + return $parameters; + } + + /** + * Returns a new instance of server profile. + * + * @param string $version Redis profile. + * @return ServerProfileInterface + */ + protected function getProfile($version = null) + { + return ServerProfile::get($version ?: REDIS_SERVER_VERSION); + } + + /** + * Returns a new client instance. + * + * @param array $parameters Additional connection parameters. + * @param array $options Additional client options. + * @param bool $flushdb Flush selected database before returning the client. + * @return Client + */ + protected function createClient(array $parameters = null, array $options = null, $flushdb = true) + { + $parameters = array_merge( + $this->getDefaultParametersArray(), + $parameters ?: array() + ); + + $options = array_merge( + array( + 'profile' => $this->getProfile(), + ), + $options ?: array() + ); + + $client = new Client($parameters, $options); + $client->connect(); + + if ($flushdb) { + $client->flushdb(); + } + + return $client; + } + + /** + * @param string $expectedVersion Expected redis version. + * @param string $operator Comparison operator. + * @param callable $callback Callback for matching version. + * @throws PHPUnit_Framework_SkippedTestError When expected redis version is not met. + */ + protected function executeOnRedisVersion($expectedVersion, $operator, $callback) + { + $client = $this->createClient(null, null, true); + $info = array_change_key_case($client->info()); + + if (isset($info['server']['redis_version'])) { + // Redis >= 2.6 + $version = $info['server']['redis_version']; + } elseif (isset($info['redis_version'])) { + // Redis < 2.6 + $version = $info['redis_version']; + } else { + throw new RuntimeException('Unable to retrieve server info'); + } + + $comparation = version_compare($version, $expectedVersion); + + if ($match = eval("return $comparation $operator 0;")) { + call_user_func($callback, $this, $version); + } + + return $match; + } + + /** + * @param string $expectedVersion Expected redis version. + * @param string $operator Comparison operator. + * @param callable $callback Callback for matching version. + * @throws PHPUnit_Framework_SkippedTestError When expected redis version is not met. + */ + protected function executeOnProfileVersion($expectedVersion, $operator, $callback) + { + $profile = $this->getProfile(); + $comparation = version_compare($version = $profile->getVersion(), $expectedVersion); + + if ($match = eval("return $comparation $operator 0;")) { + call_user_func($callback, $this, $version); + } + + return $match; + } + + /** + * @param string $expectedVersion Expected redis version. + * @param string $message Optional message. + * @param bool $remote Based on local profile or remote redis version. + * @throws RuntimeException when unable to retrieve server info or redis version + * @throws \PHPUnit_Framework_SkippedTestError when expected redis version is not met + */ + public function markTestSkippedOnRedisVersionBelow($expectedVersion, $message = '', $remote = true) + { + $callback = function ($test, $version) use ($message, $expectedVersion) { + $test->markTestSkipped($message ?: "Test requires Redis $expectedVersion, current is $version."); + }; + + $method = $remote ? 'executeOnRedisVersion' : 'executeOnProfileVersion'; + $this->$method($expectedVersion, '<', $callback); + } + + /** + * Sleep the test case with microseconds resolution. + * + * @param float $seconds Seconds to sleep. + */ + protected function sleep($seconds) + { + usleep($seconds * 1000000); + } +} diff --git a/vendor/predis/predis/tests/PHPUnit/RedisCommandConstraint.php b/vendor/predis/predis/tests/PHPUnit/RedisCommandConstraint.php new file mode 100755 index 0000000..7bf6bc7 --- /dev/null +++ b/vendor/predis/predis/tests/PHPUnit/RedisCommandConstraint.php @@ -0,0 +1,98 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +use Predis\Command\CommandInterface; + +/** + * Constraint that verifies a redis command. + */ +class RedisCommandConstraint extends PHPUnit_Framework_Constraint +{ + protected $commandID; + protected $arguments; + + /** + * @param string|CommandInterface $command Expected command ID or instance. + * @param array $arguments Expected command arguments. + */ + public function __construct($command = null, array $arguments = null) + { + if ($command instanceof CommandInterface) { + $this->commandID = strtoupper($command->getId()); + $this->arguments = $arguments ?: $command->getArguments(); + } else { + $this->commandID = strtoupper($command); + $this->arguments = $arguments; + } + } + + /** + * {@inheritdoc} + */ + public function matches($other) + { + if (!$other instanceof CommandInterface) { + return false; + } + + if ($this->commandID && strtoupper($other->getId()) !== $this->commandID) { + return false; + } + + if ($this->arguments !== null) { + $otherArguments = $other->getArguments(); + + if (count($this->arguments) !== count($otherArguments)) { + return false; + } + + for ($i = 0; $i < count($this->arguments); $i++) { + if (((string) $this->arguments[$i]) !== ((string) $otherArguments[$i])) { + return false; + } + } + } + + return true; + } + + /** + * {@inheritdoc} + * + * @todo Improve output using diff when expected and actual arguments of a + * command do not match. + */ + public function toString() + { + $string = 'is a Redis command'; + + if ($this->commandID) { + $string .= " with ID '{$this->commandID}'"; + } + + if ($this->arguments) { + $string .= " and the following arguments:\n\n"; + $string .= PHPUnit_Util_Type::export($this->arguments); + } + + return $string; + } + + /** + * {@inheritdoc} + */ + protected function failureDescription($other) + { + $string = is_object($other) ? get_class($other) : $other; + + return "$string {$this->toString()}"; + } +} diff --git a/vendor/predis/predis/tests/Predis/ClientExceptionTest.php b/vendor/predis/predis/tests/Predis/ClientExceptionTest.php new file mode 100755 index 0000000..7347149 --- /dev/null +++ b/vendor/predis/predis/tests/Predis/ClientExceptionTest.php @@ -0,0 +1,43 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis; + +use PredisTestCase; + +/** + * + */ +class ClientExceptionTest extends PredisTestCase +{ + /** + * @group disconnected + */ + public function testExceptionMessage() + { + $message = 'This is a client exception.'; + + $this->setExpectedException('Predis\ClientException', $message); + + throw new ClientException($message); + } + + /** + * @group disconnected + */ + public function testExceptionClass() + { + $exception = new ClientException(); + + $this->assertInstanceOf('Predis\ClientException', $exception); + $this->assertInstanceOf('Predis\PredisException', $exception); + } +} diff --git a/vendor/predis/predis/tests/Predis/ClientTest.php b/vendor/predis/predis/tests/Predis/ClientTest.php new file mode 100755 index 0000000..314e47c --- /dev/null +++ b/vendor/predis/predis/tests/Predis/ClientTest.php @@ -0,0 +1,777 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis; + +use PredisTestCase; +use Predis\Connection\ConnectionFactory; +use Predis\Connection\MasterSlaveReplication; +use Predis\Connection\PredisCluster; +use Predis\Profile\ServerProfile; + +/** + * + */ +class ClientTest extends PredisTestCase +{ + /** + * @group disconnected + */ + public function testConstructorWithoutArguments() + { + $client = new Client(); + + $connection = $client->getConnection(); + $this->assertInstanceOf('Predis\Connection\SingleConnectionInterface', $connection); + + $parameters = $connection->getParameters(); + $this->assertSame($parameters->host, '127.0.0.1'); + $this->assertSame($parameters->port, 6379); + + $options = $client->getOptions(); + $this->assertSame($options->profile->getVersion(), ServerProfile::getDefault()->getVersion()); + + $this->assertFalse($client->isConnected()); + } + + /** + * @group disconnected + */ + public function testConstructorWithNullArgument() + { + $client = new Client(null); + + $connection = $client->getConnection(); + $this->assertInstanceOf('Predis\Connection\SingleConnectionInterface', $connection); + + $parameters = $connection->getParameters(); + $this->assertSame($parameters->host, '127.0.0.1'); + $this->assertSame($parameters->port, 6379); + + $options = $client->getOptions(); + $this->assertSame($options->profile->getVersion(), ServerProfile::getDefault()->getVersion()); + + $this->assertFalse($client->isConnected()); + } + + /** + * @group disconnected + */ + public function testConstructorWithNullAndNullArguments() + { + $client = new Client(null, null); + + $connection = $client->getConnection(); + $this->assertInstanceOf('Predis\Connection\SingleConnectionInterface', $connection); + + $parameters = $connection->getParameters(); + $this->assertSame($parameters->host, '127.0.0.1'); + $this->assertSame($parameters->port, 6379); + + $options = $client->getOptions(); + $this->assertSame($options->profile->getVersion(), ServerProfile::getDefault()->getVersion()); + + $this->assertFalse($client->isConnected()); + } + + /** + * @group disconnected + */ + public function testConstructorWithArrayArgument() + { + $client = new Client($arg1 = array('host' => 'localhost', 'port' => 7000)); + + $parameters = $client->getConnection()->getParameters(); + $this->assertSame($parameters->host, $arg1['host']); + $this->assertSame($parameters->port, $arg1['port']); + } + + /** + * @group disconnected + */ + public function testConstructorWithArrayOfArrayArgument() + { + $arg1 = array( + array('host' => 'localhost', 'port' => 7000), + array('host' => 'localhost', 'port' => 7001), + ); + + $client = new Client($arg1); + + $this->assertInstanceOf('Predis\Connection\ClusterConnectionInterface', $client->getConnection()); + } + + /** + * @group disconnected + */ + public function testConstructorWithStringArgument() + { + $client = new Client('tcp://localhost:7000'); + + $parameters = $client->getConnection()->getParameters(); + $this->assertSame($parameters->host, 'localhost'); + $this->assertSame($parameters->port, 7000); + } + + /** + * @group disconnected + */ + public function testConstructorWithArrayOfStringArgument() + { + $client = new Client($arg1 = array('tcp://localhost:7000', 'tcp://localhost:7001')); + + $this->assertInstanceOf('Predis\Connection\ClusterConnectionInterface', $client->getConnection()); + } + + /** + * @group disconnected + */ + public function testConstructorWithArrayOfConnectionsArgument() + { + $connection1 = $this->getMock('Predis\Connection\SingleConnectionInterface'); + $connection2 = $this->getMock('Predis\Connection\SingleConnectionInterface'); + + $client = new Client(array($connection1, $connection2)); + + $this->assertInstanceOf('Predis\Connection\ClusterConnectionInterface', $cluster = $client->getConnection()); + $this->assertSame($connection1, $cluster->getConnectionById(0)); + $this->assertSame($connection2, $cluster->getConnectionById(1)); + } + + /** + * @group disconnected + */ + public function testConstructorWithConnectionArgument() + { + $factory = new ConnectionFactory(); + $connection = $factory->create('tcp://localhost:7000'); + + $client = new Client($connection); + + $this->assertInstanceOf('Predis\Connection\SingleConnectionInterface', $client->getConnection()); + $this->assertSame($connection, $client->getConnection()); + + $parameters = $client->getConnection()->getParameters(); + $this->assertSame($parameters->host, 'localhost'); + $this->assertSame($parameters->port, 7000); + } + + /** + * @group disconnected + */ + public function testConstructorWithClusterArgument() + { + $cluster = new PredisCluster(); + + $factory = new ConnectionFactory(); + $factory->createAggregated($cluster, array('tcp://localhost:7000', 'tcp://localhost:7001')); + + $client = new Client($cluster); + + $this->assertInstanceOf('Predis\Connection\ClusterConnectionInterface', $client->getConnection()); + $this->assertSame($cluster, $client->getConnection()); + } + + /** + * @group disconnected + */ + public function testConstructorWithReplicationArgument() + { + $replication = new MasterSlaveReplication(); + + $factory = new ConnectionFactory(); + $factory->createAggregated($replication, array('tcp://host1?alias=master', 'tcp://host2?alias=slave')); + + $client = new Client($replication); + + $this->assertInstanceOf('Predis\Connection\ReplicationConnectionInterface', $client->getConnection()); + $this->assertSame($replication, $client->getConnection()); + } + + /** + * @group disconnected + */ + public function testConstructorWithCallableArgument() + { + $connection = $this->getMock('Predis\Connection\ConnectionInterface'); + + $callable = $this->getMock('stdClass', array('__invoke')); + $callable->expects($this->once()) + ->method('__invoke') + ->with($this->isInstanceOf('Predis\Option\ClientOptions')) + ->will($this->returnValue($connection)); + + $client = new Client($callable); + + $this->assertSame($connection, $client->getConnection()); + } + + /** + * @group disconnected + * @expectedException InvalidArgumentException + * @expectedExceptionMessage Callable parameters must return instances of Predis\Connection\ConnectionInterface + */ + public function testConstructorWithCallableArgumentButInvalidReturnType() + { + $wrongType = $this->getMock('stdClass'); + + $callable = $this->getMock('stdClass', array('__invoke')); + $callable->expects($this->once()) + ->method('__invoke') + ->with($this->isInstanceOf('Predis\Option\ClientOptions')) + ->will($this->returnValue($wrongType)); + + $client = new Client($callable); + } + + /** + * @group disconnected + */ + public function testConstructorWithNullAndArrayArgument() + { + $factory = $this->getMock('Predis\Connection\ConnectionFactoryInterface'); + + $arg2 = array('profile' => '2.0', 'prefix' => 'prefix:', 'connections' => $factory); + $client = new Client(null, $arg2); + + $profile = $client->getProfile(); + $this->assertSame($profile->getVersion(), ServerProfile::get('2.0')->getVersion()); + $this->assertInstanceOf('Predis\Command\Processor\KeyPrefixProcessor', $profile->getProcessor()); + $this->assertSame('prefix:', $profile->getProcessor()->getPrefix()); + + $this->assertSame($factory, $client->getConnectionFactory()); + } + + /** + * @group disconnected + */ + public function testConstructorWithArrayAndOptionReplicationArgument() + { + $arg1 = array('tcp://host1?alias=master', 'tcp://host2?alias=slave'); + $arg2 = array('replication' => true); + $client = new Client($arg1, $arg2); + + $this->assertInstanceOf('Predis\Connection\ReplicationConnectionInterface', $connection = $client->getConnection()); + $this->assertSame('host1', $connection->getConnectionById('master')->getParameters()->host); + $this->assertSame('host2', $connection->getConnectionById('slave')->getParameters()->host); + } + + /** + * @group disconnected + */ + public function testConnectAndDisconnect() + { + $connection = $this->getMock('Predis\Connection\ConnectionInterface'); + $connection->expects($this->once())->method('connect'); + $connection->expects($this->once())->method('disconnect'); + + $client = new Client($connection); + $client->connect(); + $client->disconnect(); + } + + /** + * @group disconnected + */ + public function testIsConnectedChecksConnectionState() + { + $connection = $this->getMock('Predis\Connection\ConnectionInterface'); + $connection->expects($this->once())->method('isConnected'); + + $client = new Client($connection); + $client->isConnected(); + } + + /** + * @group disconnected + */ + public function testQuitIsAliasForDisconnect() + { + $connection = $this->getMock('Predis\Connection\ConnectionInterface'); + $connection->expects($this->once())->method('disconnect'); + + $client = new Client($connection); + $client->quit(); + } + + /** + * @group disconnected + */ + public function testCreatesNewCommandUsingSpecifiedProfile() + { + $ping = ServerProfile::getDefault()->createCommand('ping', array()); + + $profile = $this->getMock('Predis\Profile\ServerProfileInterface'); + $profile->expects($this->once()) + ->method('createCommand') + ->with('ping', array()) + ->will($this->returnValue($ping)); + + $client = new Client(null, array('profile' => $profile)); + $this->assertSame($ping, $client->createCommand('ping', array())); + } + + /** + * @group disconnected + */ + public function testExecuteCommandReturnsParsedReplies() + { + $profile = ServerProfile::getDefault(); + + $ping = $profile->createCommand('ping', array()); + $hgetall = $profile->createCommand('hgetall', array('metavars', 'foo', 'hoge')); + + $connection= $this->getMock('Predis\Connection\ConnectionInterface'); + $connection->expects($this->at(0)) + ->method('executeCommand') + ->with($ping) + ->will($this->returnValue('PONG')); + $connection->expects($this->at(1)) + ->method('executeCommand') + ->with($hgetall) + ->will($this->returnValue(array('foo', 'bar', 'hoge', 'piyo'))); + + $client = new Client($connection); + + $this->assertTrue($client->executeCommand($ping)); + $this->assertSame(array('foo' => 'bar', 'hoge' => 'piyo'), $client->executeCommand($hgetall)); + } + + /** + * @group disconnected + * @expectedException Predis\ServerException + * @expectedExceptionMessage Operation against a key holding the wrong kind of value + */ + public function testExecuteCommandThrowsExceptionOnRedisError() + { + $ping = ServerProfile::getDefault()->createCommand('ping', array()); + $expectedResponse = new ResponseError('ERR Operation against a key holding the wrong kind of value'); + + $connection= $this->getMock('Predis\Connection\ConnectionInterface'); + $connection->expects($this->once()) + ->method('executeCommand') + ->will($this->returnValue($expectedResponse)); + + $client = new Client($connection); + $client->executeCommand($ping); + } + + /** + * @group disconnected + */ + public function testExecuteCommandReturnsErrorResponseOnRedisError() + { + $ping = ServerProfile::getDefault()->createCommand('ping', array()); + $expectedResponse = new ResponseError('ERR Operation against a key holding the wrong kind of value'); + + $connection= $this->getMock('Predis\Connection\ConnectionInterface'); + $connection->expects($this->once()) + ->method('executeCommand') + ->will($this->returnValue($expectedResponse)); + + $client = new Client($connection, array('exceptions' => false)); + $response = $client->executeCommand($ping); + + $this->assertSame($response, $expectedResponse); + } + + /** + * @group disconnected + */ + public function testCallingRedisCommandExecutesInstanceOfCommand() + { + $ping = ServerProfile::getDefault()->createCommand('ping', array()); + + $connection = $this->getMock('Predis\Connection\ConnectionInterface'); + $connection->expects($this->once()) + ->method('executeCommand') + ->with($this->isInstanceOf('Predis\Command\ConnectionPing')) + ->will($this->returnValue('PONG')); + + $profile = $this->getMock('Predis\Profile\ServerProfileInterface'); + $profile->expects($this->once()) + ->method('createCommand') + ->with('ping', array()) + ->will($this->returnValue($ping)); + + $options = array('profile' => $profile); + $client = $this->getMock('Predis\Client', null, array($connection, $options)); + + $this->assertTrue($client->ping()); + } + + /** + * @group disconnected + * @expectedException Predis\ServerException + * @expectedExceptionMessage Operation against a key holding the wrong kind of value + */ + public function testCallingRedisCommandThrowsExceptionOnServerError() + { + $expectedResponse = new ResponseError('ERR Operation against a key holding the wrong kind of value'); + + $connection = $this->getMock('Predis\Connection\ConnectionInterface'); + $connection->expects($this->once()) + ->method('executeCommand') + ->with($this->isInstanceOf('Predis\Command\ConnectionPing')) + ->will($this->returnValue($expectedResponse)); + + $client = new Client($connection); + $client->ping(); + } + + /** + * @group disconnected + */ + public function testCallingRedisCommandReturnsErrorResponseOnRedisError() + { + $expectedResponse = new ResponseError('ERR Operation against a key holding the wrong kind of value'); + + $connection = $this->getMock('Predis\Connection\ConnectionInterface'); + $connection->expects($this->once()) + ->method('executeCommand') + ->with($this->isInstanceOf('Predis\Command\ConnectionPing')) + ->will($this->returnValue($expectedResponse)); + + $client = new Client($connection, array('exceptions' => false)); + $response = $client->ping(); + + $this->assertSame($response, $expectedResponse); + } + + /** + * @group disconnected + * @expectedException Predis\ClientException + * @expectedExceptionMessage 'invalidcommand' is not a registered Redis command + */ + public function testThrowsExceptionOnNonRegisteredRedisCommand() + { + $client = new Client(); + $client->invalidCommand(); + } + + /** + * @group disconnected + */ + public function testGetConnectionFromAggregatedConnectionWithAlias() + { + $client = new Client(array('tcp://host1?alias=node01', 'tcp://host2?alias=node02')); + + $this->assertInstanceOf('Predis\Connection\ClusterConnectionInterface', $cluster = $client->getConnection()); + $this->assertInstanceOf('Predis\Connection\SingleConnectionInterface', $node01 = $client->getConnectionById('node01')); + $this->assertInstanceOf('Predis\Connection\SingleConnectionInterface', $node02 = $client->getConnectionById('node02')); + + $this->assertSame('host1', $node01->getParameters()->host); + $this->assertSame('host2', $node02->getParameters()->host); + } + + /** + * @group disconnected + * @expectedException Predis\NotSupportedException + * @expectedExceptionMessage Retrieving connections by ID is supported only when using aggregated connections + */ + public function testGetConnectionByIdWorksOnlyWithAggregatedConnections() + { + $client = new Client(); + + $client->getConnectionById('node01'); + } + + /** + * @group disconnected + */ + public function testCreateClientWithConnectionFromAggregatedConnection() + { + $client = new Client(array('tcp://host1?alias=node01', 'tcp://host2?alias=node02'), array('prefix' => 'pfx:')); + + $this->assertInstanceOf('Predis\Connection\ClusterConnectionInterface', $cluster = $client->getConnection()); + $this->assertInstanceOf('Predis\Connection\SingleConnectionInterface', $node01 = $client->getConnectionById('node01')); + $this->assertInstanceOf('Predis\Connection\SingleConnectionInterface', $node02 = $client->getConnectionById('node02')); + + $clientNode02 = $client->getClientFor('node02'); + + $this->assertInstanceOf('Predis\Client', $clientNode02); + $this->assertSame($node02, $clientNode02->getConnection()); + $this->assertSame($client->getOptions(), $clientNode02->getOptions()); + } + + /** + * @group disconnected + */ + public function testGetClientForReturnsInstanceOfSubclass() + { + $nodes = array('tcp://host1?alias=node01', 'tcp://host2?alias=node02'); + $client = $this->getMock('Predis\Client', array('dummy'), array($nodes), 'SubclassedClient'); + + $this->assertInstanceOf('SubclassedClient', $client->getClientFor('node02')); + } + + /** + * @group disconnected + */ + public function testPipelineWithoutArgumentsReturnsPipelineContext() + { + $client = new Client(); + + $this->assertInstanceOf('Predis\Pipeline\PipelineContext', $client->pipeline()); + } + + /** + * @group disconnected + */ + public function testPipelineWithArrayReturnsPipelineContextWithOptions() + { + $client = new Client(); + $executor = $this->getMock('Predis\Pipeline\PipelineExecutorInterface'); + + $options = array('executor' => $executor); + $this->assertInstanceOf('Predis\Pipeline\PipelineContext', $pipeline = $client->pipeline($options)); + $this->assertSame($executor, $pipeline->getExecutor()); + + $options = array('executor' => function ($client, $options) use ($executor) { return $executor; }); + $this->assertInstanceOf('Predis\Pipeline\PipelineContext', $pipeline = $client->pipeline($options)); + $this->assertSame($executor, $pipeline->getExecutor()); + } + + /** + * @group disconnected + */ + public function testPipelineWithCallableExecutesPipeline() + { + $callable = $this->getMock('stdClass', array('__invoke')); + $callable->expects($this->once()) + ->method('__invoke') + ->with($this->isInstanceOf('Predis\Pipeline\PipelineContext')); + + $client = new Client(); + $client->pipeline($callable); + } + + /** + * @group disconnected + */ + public function testPipelineWithArrayAndCallableExecutesPipelineWithOptions() + { + $executor = $this->getMock('Predis\Pipeline\PipelineExecutorInterface'); + $options = array('executor' => $executor); + + $test = $this; + $mockCallback = function ($pipeline) use ($executor, $test) { + $reflection = new \ReflectionProperty($pipeline, 'executor'); + $reflection->setAccessible(true); + + $test->assertSame($executor, $reflection->getValue($pipeline)); + }; + + $callable = $this->getMock('stdClass', array('__invoke')); + $callable->expects($this->once()) + ->method('__invoke') + ->with($this->isInstanceOf('Predis\Pipeline\PipelineContext')) + ->will($this->returnCallback($mockCallback)); + + $client = new Client(); + $client->pipeline($options, $callable); + } + + /** + * @group disconnected + */ + public function testPubSubLoopWithoutArgumentsReturnsPubSubContext() + { + $client = new Client(); + + $this->assertInstanceOf('Predis\PubSub\PubSubContext', $client->pubSubLoop()); + } + + /** + * @group disconnected + */ + public function testPubSubLoopWithArrayReturnsPubSubContextWithOptions() + { + $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); + $options = array('subscribe' => 'channel'); + + $client = new Client($connection); + + $this->assertInstanceOf('Predis\PubSub\PubSubContext', $pubsub = $client->pubSubLoop($options)); + + $reflection = new \ReflectionProperty($pubsub, 'options'); + $reflection->setAccessible(true); + + $this->assertSame($options, $reflection->getValue($pubsub)); + } + + /** + * @group disconnected + */ + public function testPubSubLoopWithArrayAndCallableExecutesPubSub() + { + // NOTE: we use a subscribe count of 0 in the fake message to trick + // the context and to make it think that it can be closed + // since there are no more subscriptions active. + + $message = array('subscribe', 'channel', 0); + $options = array('subscribe' => 'channel'); + + $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); + $connection->expects($this->once()) + ->method('read') + ->will($this->returnValue($message)); + + $callable = $this->getMock('stdClass', array('__invoke')); + $callable->expects($this->once()) + ->method('__invoke'); + + $client = new Client($connection); + $client->pubSubLoop($options, $callable); + } + + /** + * @group disconnected + */ + public function testPubSubIsAliasForPubSubLoop() + { + $client = new Client(); + + $this->assertInstanceOf('Predis\PubSub\PubSubContext', $client->pubSub()); + } + + /** + * @group disconnected + */ + public function testMultiExecWithoutArgumentsReturnsMultiExecContext() + { + $client = new Client(); + + $this->assertInstanceOf('Predis\Transaction\MultiExecContext', $client->multiExec()); + } + + /** + * @group disconnected + */ + public function testMethodTransactionIsAliasForMethodMultiExec() + { + $client = new Client(); + + $this->assertInstanceOf('Predis\Transaction\MultiExecContext', $client->transaction()); + } + + /** + * @group disconnected + */ + public function testMultiExecWithArrayReturnsMultiExecContextWithOptions() + { + $options = array('cas' => true, 'retry' => 3); + + $client = new Client(); + + $this->assertInstanceOf('Predis\Transaction\MultiExecContext', $tx = $client->multiExec($options)); + + $reflection = new \ReflectionProperty($tx, 'options'); + $reflection->setAccessible(true); + + $this->assertSame($options, $reflection->getValue($tx)); + } + + /** + * @group disconnected + */ + public function testMultiExecWithArrayAndCallableExecutesMultiExec() + { + // NOTE: we use CAS since testing the actual MULTI/EXEC context + // here is not the point. + $options = array('cas' => true, 'retry' => 3); + + $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); + $connection->expects($this->once()) + ->method('executeCommand') + ->will($this->returnValue(new ResponseQueued())); + + $txCallback = function ($tx) { + $tx->ping(); + }; + + $callable = $this->getMock('stdClass', array('__invoke')); + $callable->expects($this->once()) + ->method('__invoke') + ->will($this->returnCallback($txCallback)); + + $client = new Client($connection); + $client->multiExec($options, $callable); + } + + /** + * @group disconnected + */ + public function testMonitorReturnsMonitorContext() + { + $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); + $client = new Client($connection); + + $this->assertInstanceOf('Predis\Monitor\MonitorContext', $monitor = $client->monitor()); + } + + /** + * @group disconnected + */ + public function testClientResendScriptedCommandUsingEvalOnNoScriptErrors() + { + $command = $this->getMockForAbstractClass('Predis\Command\ScriptedCommand', array(), '', true, true, true, array('parseResponse')); + $command->expects($this->once()) + ->method('getScript') + ->will($this->returnValue('return redis.call(\'exists\', KEYS[1])')); + $command->expects($this->once()) + ->method('parseResponse') + ->with('OK') + ->will($this->returnValue(true)); + + $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); + $connection->expects($this->at(0)) + ->method('executeCommand') + ->with($command) + ->will($this->returnValue(new ResponseError('NOSCRIPT'))); + $connection->expects($this->at(1)) + ->method('executeCommand') + ->with($this->isInstanceOf('Predis\Command\ServerEval')) + ->will($this->returnValue('OK')); + + $client = new Client($connection); + + $this->assertTrue($client->executeCommand($command)); + } + + // ******************************************************************** // + // ---- HELPER METHODS ------------------------------------------------ // + // ******************************************************************** // + + /** + * Returns an URI string representation of the specified connection parameters. + * + * @param Array $parameters Array of connection parameters. + * @return String URI string. + */ + protected function getParametersString(Array $parameters) + { + $defaults = $this->getDefaultParametersArray(); + + $scheme = isset($parameters['scheme']) ? $parameters['scheme'] : $defaults['scheme']; + $host = isset($parameters['host']) ? $parameters['host'] : $defaults['host']; + $port = isset($parameters['port']) ? $parameters['port'] : $defaults['port']; + + unset($parameters['scheme'], $parameters['host'], $parameters['port']); + $uriString = "$scheme://$host:$port/?"; + + foreach ($parameters as $k => $v) { + $uriString .= "$k=$v&"; + } + + return $uriString; + } +} diff --git a/vendor/predis/predis/tests/Predis/Cluster/Distribution/EmptyRingExceptionTest.php b/vendor/predis/predis/tests/Predis/Cluster/Distribution/EmptyRingExceptionTest.php new file mode 100755 index 0000000..379e78e --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Cluster/Distribution/EmptyRingExceptionTest.php @@ -0,0 +1,31 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Cluster\Distribution; + +use PredisTestCase; + +/** + * @todo Not really useful right now. + */ +class EmptyRingExceptionTest extends PredisTestCase +{ + /** + * @group disconnected + */ + public function testExceptionMessage() + { + $message = 'Empty Ring'; + $this->setExpectedException('Predis\Cluster\Distribution\EmptyRingException', $message); + + throw new EmptyRingException($message); + } +} diff --git a/vendor/predis/predis/tests/Predis/Cluster/Distribution/HashRingTest.php b/vendor/predis/predis/tests/Predis/Cluster/Distribution/HashRingTest.php new file mode 100755 index 0000000..efa09f3 --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Cluster/Distribution/HashRingTest.php @@ -0,0 +1,153 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Cluster\Distribution; + +/** + * @todo To be improved. + */ +class HashRingTest extends PredisDistributorTestCase +{ + /** + * {@inheritdoc} + */ + public function getDistributorInstance() + { + return new HashRing(); + } + + /** + * @group disconnected + */ + public function testHash() + { + $ring = $this->getDistributorInstance(); + + $this->assertEquals(crc32('foobar'), $ring->hash('foobar')); + } + + /** + * @group disconnected + */ + public function testSingleNodeInRing() + { + $node = '127.0.0.1:7000'; + + $ring = $this->getDistributorInstance(); + $ring->add($node); + + $expected = array_fill(0, 20, $node); + $actual = $this->getNodes($ring, 20); + + $this->assertSame($expected, $actual); + } + + /** + * @group disconnected + */ + public function testMultipleNodesInRing() + { + $nodes = array( + '127.0.0.1:7000', + '127.0.0.1:7001', + '127.0.0.1:7002', + ); + + $ring = $this->getDistributorInstance(); + foreach ($nodes as $node) { + $ring->add($node); + } + + $expected = array( + '127.0.0.1:7001', + '127.0.0.1:7001', + '127.0.0.1:7001', + '127.0.0.1:7002', + '127.0.0.1:7002', + '127.0.0.1:7001', + '127.0.0.1:7001', + '127.0.0.1:7000', + '127.0.0.1:7001', + '127.0.0.1:7002', + '127.0.0.1:7002', + '127.0.0.1:7002', + '127.0.0.1:7002', + '127.0.0.1:7000', + '127.0.0.1:7002', + '127.0.0.1:7002', + '127.0.0.1:7002', + '127.0.0.1:7000', + '127.0.0.1:7001', + '127.0.0.1:7002', + ); + + $actual = $this->getNodes($ring, 20); + + $this->assertSame($expected, $actual); + } + + /** + * @group disconnected + */ + public function testSubsequendAddAndRemoveFromRing() + { + $ring = $this->getDistributorInstance(); + + $expected1 = array_fill(0, 10, '127.0.0.1:7000'); + $expected3 = array_fill(0, 10, '127.0.0.1:7001'); + $expected2 = array( + '127.0.0.1:7001', + '127.0.0.1:7001', + '127.0.0.1:7001', + '127.0.0.1:7001', + '127.0.0.1:7001', + '127.0.0.1:7001', + '127.0.0.1:7001', + '127.0.0.1:7000', + '127.0.0.1:7001', + '127.0.0.1:7000', + ); + + $ring->add('127.0.0.1:7000'); + $actual1 = $this->getNodes($ring, 10); + + $ring->add('127.0.0.1:7001'); + $actual2 = $this->getNodes($ring, 10); + + $ring->remove('127.0.0.1:7000'); + $actual3 = $this->getNodes($ring, 10); + + $this->assertSame($expected1, $actual1); + $this->assertSame($expected2, $actual2); + $this->assertSame($expected3, $actual3); + } + + /** + * @todo This tests should be moved in Predis\Cluster\Distribution\DistributionStrategyTestCase + * @group disconnected + */ + public function testCallbackToGetNodeHash() + { + $node = '127.0.0.1:7000'; + $replicas = HashRing::DEFAULT_REPLICAS; + $callable = $this->getMock('stdClass', array('__invoke')); + + $callable->expects($this->once()) + ->method('__invoke') + ->with($node) + ->will($this->returnValue($node)); + + $ring = new HashRing($replicas, $callable); + $ring->add($node); + + $this->getNodes($ring); + } +} diff --git a/vendor/predis/predis/tests/Predis/Cluster/Distribution/KetamaPureRingTest.php b/vendor/predis/predis/tests/Predis/Cluster/Distribution/KetamaPureRingTest.php new file mode 100755 index 0000000..b3b1415 --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Cluster/Distribution/KetamaPureRingTest.php @@ -0,0 +1,153 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Cluster\Distribution; + +/** + * @todo To be improved. + */ +class KetamaPureRingTest extends PredisDistributorTestCase +{ + /** + * {@inheritdoc} + */ + public function getDistributorInstance() + { + return new KetamaPureRing(); + } + + /** + * @group disconnected + */ + public function testHash() + { + $ring = $this->getDistributorInstance(); + list(, $hash) = unpack('V', md5('foobar', true)); + + $this->assertEquals($hash, $ring->hash('foobar')); + } + + /** + * @group disconnected + */ + public function testSingleNodeInRing() + { + $node = '127.0.0.1:7000'; + + $ring = $this->getDistributorInstance(); + $ring->add($node); + + $expected = array_fill(0, 20, $node); + $actual = $this->getNodes($ring, 20); + + $this->assertSame($expected, $actual); + } + + /** + * @group disconnected + */ + public function testMultipleNodesInRing() + { + $nodes = array( + '127.0.0.1:7000', + '127.0.0.1:7001', + '127.0.0.1:7002', + ); + + $ring = $this->getDistributorInstance(); + foreach ($nodes as $node) { + $ring->add($node); + } + + $expected = array( + '127.0.0.1:7000', + '127.0.0.1:7001', + '127.0.0.1:7000', + '127.0.0.1:7002', + '127.0.0.1:7000', + '127.0.0.1:7001', + '127.0.0.1:7000', + '127.0.0.1:7001', + '127.0.0.1:7000', + '127.0.0.1:7002', + '127.0.0.1:7000', + '127.0.0.1:7000', + '127.0.0.1:7001', + '127.0.0.1:7000', + '127.0.0.1:7001', + '127.0.0.1:7002', + '127.0.0.1:7000', + '127.0.0.1:7002', + '127.0.0.1:7001', + '127.0.0.1:7002', + ); + + $actual = $this->getNodes($ring, 20); + + $this->assertSame($expected, $actual); + } + + /** + * @group disconnected + */ + public function testSubsequendAddAndRemoveFromRing() + { + $ring = $this->getDistributorInstance(); + + $expected1 = array_fill(0, 10, '127.0.0.1:7000'); + $expected3 = array_fill(0, 10, '127.0.0.1:7001'); + $expected2 = array( + '127.0.0.1:7000', + '127.0.0.1:7001', + '127.0.0.1:7000', + '127.0.0.1:7001', + '127.0.0.1:7000', + '127.0.0.1:7001', + '127.0.0.1:7000', + '127.0.0.1:7001', + '127.0.0.1:7000', + '127.0.0.1:7001', + ); + + $ring->add('127.0.0.1:7000'); + $actual1 = $this->getNodes($ring, 10); + + $ring->add('127.0.0.1:7001'); + $actual2 = $this->getNodes($ring, 10); + + $ring->remove('127.0.0.1:7000'); + $actual3 = $this->getNodes($ring, 10); + + $this->assertSame($expected1, $actual1); + $this->assertSame($expected2, $actual2); + $this->assertSame($expected3, $actual3); + } + + /** + * @todo This tests should be moved in Predis\Cluster\Distribution\DistributionStrategyTestCase + * @group disconnected + */ + public function testCallbackToGetNodeHash() + { + $node = '127.0.0.1:7000'; + $callable = $this->getMock('stdClass', array('__invoke')); + + $callable->expects($this->once()) + ->method('__invoke') + ->with($node) + ->will($this->returnValue($node)); + + $ring = new KetamaPureRing($callable); + $ring->add($node); + + $this->getNodes($ring); + } +} diff --git a/vendor/predis/predis/tests/Predis/Cluster/PredisClusterHashStrategyTest.php b/vendor/predis/predis/tests/Predis/Cluster/PredisClusterHashStrategyTest.php new file mode 100755 index 0000000..b9bdb9c --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Cluster/PredisClusterHashStrategyTest.php @@ -0,0 +1,374 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Cluster; + +use PredisTestCase; +use Predis\Cluster\Distribution\HashRing; +use Predis\Profile\ServerProfile; + +/** + * + */ +class PredisClusterHashStrategyTest extends PredisTestCase +{ + /** + * @group disconnected + */ + public function testSupportsKeyTags() + { + // NOTE: 32 and 64 bits PHP runtimes can produce different hash values. + $expected = PHP_INT_SIZE == 4 ? -1938594527 : 2356372769; + + $strategy = $this->getHashStrategy(); + + $this->assertSame($expected, $strategy->getKeyHash('{foo}')); + $this->assertSame($expected, $strategy->getKeyHash('{foo}:bar')); + $this->assertSame($expected, $strategy->getKeyHash('{foo}:baz')); + $this->assertSame($expected, $strategy->getKeyHash('bar:{foo}:bar')); + + $this->assertSame(0, $strategy->getKeyHash('')); + $this->assertSame(0, $strategy->getKeyHash('{}')); + } + + /** + * @group disconnected + */ + public function testSupportedCommands() + { + $strategy = $this->getHashStrategy(); + + $this->assertSame($this->getExpectedCommands(), $strategy->getSupportedCommands()); + } + + /** + * @group disconnected + */ + public function testReturnsNullOnUnsupportedCommand() + { + $strategy = $this->getHashStrategy(); + $command = ServerProfile::getDevelopment()->createCommand('ping'); + + $this->assertNull($strategy->getHash($command)); + } + + /** + * @group disconnected + */ + public function testFirstKeyCommands() + { + $strategy = $this->getHashStrategy(); + $profile = ServerProfile::getDevelopment(); + $arguments = array('key'); + + foreach ($this->getExpectedCommands('keys-first') as $commandID) { + $command = $profile->createCommand($commandID, $arguments); + $this->assertNotNull($strategy->getHash($command), $commandID); + } + } + + /** + * @group disconnected + */ + public function testAllKeysCommands() + { + $strategy = $this->getHashStrategy(); + $profile = ServerProfile::getDevelopment(); + $arguments = array('{key}:1', '{key}:2', '{key}:3', '{key}:4'); + + foreach ($this->getExpectedCommands('keys-all') as $commandID) { + $command = $profile->createCommand($commandID, $arguments); + $this->assertNotNull($strategy->getHash($command), $commandID); + } + } + + /** + * @group disconnected + */ + public function testInterleavedKeysCommands() + { + $strategy = $this->getHashStrategy(); + $profile = ServerProfile::getDevelopment(); + $arguments = array('{key}:1', 'value1', '{key}:2', 'value2'); + + foreach ($this->getExpectedCommands('keys-interleaved') as $commandID) { + $command = $profile->createCommand($commandID, $arguments); + $this->assertNotNull($strategy->getHash($command), $commandID); + } + } + + /** + * @group disconnected + */ + public function testKeysForBlockingListCommands() + { + $strategy = $this->getHashStrategy(); + $profile = ServerProfile::getDevelopment(); + $arguments = array('{key}:1', '{key}:2', 10); + + foreach ($this->getExpectedCommands('keys-blockinglist') as $commandID) { + $command = $profile->createCommand($commandID, $arguments); + $this->assertNotNull($strategy->getHash($command), $commandID); + } + } + + /** + * @group disconnected + */ + public function testKeysForZsetAggregationCommands() + { + $strategy = $this->getHashStrategy(); + $profile = ServerProfile::getDevelopment(); + $arguments = array('{key}:destination', 2, '{key}:1', '{key}:1', array('aggregate' => 'SUM')); + + foreach ($this->getExpectedCommands('keys-zaggregated') as $commandID) { + $command = $profile->createCommand($commandID, $arguments); + $this->assertNotNull($strategy->getHash($command), $commandID); + } + } + + /** + * @group disconnected + */ + public function testKeysForBitOpCommand() + { + $strategy = $this->getHashStrategy(); + $profile = ServerProfile::getDevelopment(); + $arguments = array('AND', '{key}:destination', '{key}:src:1', '{key}:src:2'); + + foreach ($this->getExpectedCommands('keys-bitop') as $commandID) { + $command = $profile->createCommand($commandID, $arguments); + $this->assertNotNull($strategy->getHash($command), $commandID); + } + } + + /** + * @group disconnected + */ + public function testKeysForScriptCommand() + { + $strategy = $this->getHashStrategy(); + $profile = ServerProfile::getDevelopment(); + $arguments = array('%SCRIPT%', 2, '{key}:1', '{key}:2', 'value1', 'value2'); + + foreach ($this->getExpectedCommands('keys-script') as $commandID) { + $command = $profile->createCommand($commandID, $arguments); + $this->assertNotNull($strategy->getHash($command), $commandID); + } + } + + /** + * @group disconnected + */ + public function testKeysForScriptedCommand() + { + $strategy = $this->getHashStrategy(); + $arguments = array('{key}:1', '{key}:2', 'value1', 'value2'); + + $command = $this->getMock('Predis\Command\ScriptedCommand', array('getScript', 'getKeysCount')); + $command->expects($this->once()) + ->method('getScript') + ->will($this->returnValue('return true')); + $command->expects($this->exactly(2)) + ->method('getKeysCount') + ->will($this->returnValue(2)); + $command->setArguments($arguments); + + $this->assertNotNull($strategy->getHash($command), "Scripted Command [{$command->getId()}]"); + } + + /** + * @group disconnected + */ + public function testUnsettingCommandHandler() + { + $strategy = $this->getHashStrategy(); + $profile = ServerProfile::getDevelopment(); + + $strategy->setCommandHandler('set'); + $strategy->setCommandHandler('get', null); + + $command = $profile->createCommand('set', array('key', 'value')); + $this->assertNull($strategy->getHash($command)); + + $command = $profile->createCommand('get', array('key')); + $this->assertNull($strategy->getHash($command)); + } + + /** + * @group disconnected + */ + public function testSettingCustomCommandHandler() + { + $strategy = $this->getHashStrategy(); + $profile = ServerProfile::getDevelopment(); + + $callable = $this->getMock('stdClass', array('__invoke')); + $callable->expects($this->once()) + ->method('__invoke') + ->with($this->isInstanceOf('Predis\Command\CommandInterface')) + ->will($this->returnValue('key')); + + $strategy->setCommandHandler('get', $callable); + + $command = $profile->createCommand('get', array('key')); + $this->assertNotNull($strategy->getHash($command)); + } + + // ******************************************************************** // + // ---- HELPER METHODS ------------------------------------------------ // + // ******************************************************************** // + + /** + * Creates the default hash strategy object. + * + * @return CommandHashStrategyInterface + */ + protected function getHashStrategy() + { + $distributor = new HashRing(); + $hashGenerator = $distributor->getHashGenerator(); + $strategy = new PredisClusterHashStrategy($hashGenerator); + + return $strategy; + } + + /** + * Returns the list of expected supported commands. + * + * @param string $type Optional type of command (based on its keys) + * @return array + */ + protected function getExpectedCommands($type = null) + { + $commands = array( + /* commands operating on the key space */ + 'EXISTS' => 'keys-first', + 'DEL' => 'keys-all', + 'TYPE' => 'keys-first', + 'EXPIRE' => 'keys-first', + 'EXPIREAT' => 'keys-first', + 'PERSIST' => 'keys-first', + 'PEXPIRE' => 'keys-first', + 'PEXPIREAT' => 'keys-first', + 'TTL' => 'keys-first', + 'PTTL' => 'keys-first', + 'SORT' => 'keys-first', // TODO + 'DUMP' => 'keys-first', + 'RESTORE' => 'keys-first', + + /* commands operating on string values */ + 'APPEND' => 'keys-first', + 'DECR' => 'keys-first', + 'DECRBY' => 'keys-first', + 'GET' => 'keys-first', + 'GETBIT' => 'keys-first', + 'MGET' => 'keys-all', + 'SET' => 'keys-first', + 'GETRANGE' => 'keys-first', + 'GETSET' => 'keys-first', + 'INCR' => 'keys-first', + 'INCRBY' => 'keys-first', + 'SETBIT' => 'keys-first', + 'SETEX' => 'keys-first', + 'MSET' => 'keys-interleaved', + 'MSETNX' => 'keys-interleaved', + 'SETNX' => 'keys-first', + 'SETRANGE' => 'keys-first', + 'STRLEN' => 'keys-first', + 'SUBSTR' => 'keys-first', + 'BITOP' => 'keys-bitop', + 'BITCOUNT' => 'keys-first', + + /* commands operating on lists */ + 'LINSERT' => 'keys-first', + 'LINDEX' => 'keys-first', + 'LLEN' => 'keys-first', + 'LPOP' => 'keys-first', + 'RPOP' => 'keys-first', + 'RPOPLPUSH' => 'keys-all', + 'BLPOP' => 'keys-blockinglist', + 'BRPOP' => 'keys-blockinglist', + 'BRPOPLPUSH' => 'keys-blockinglist', + 'LPUSH' => 'keys-first', + 'LPUSHX' => 'keys-first', + 'RPUSH' => 'keys-first', + 'RPUSHX' => 'keys-first', + 'LRANGE' => 'keys-first', + 'LREM' => 'keys-first', + 'LSET' => 'keys-first', + 'LTRIM' => 'keys-first', + + /* commands operating on sets */ + 'SADD' => 'keys-first', + 'SCARD' => 'keys-first', + 'SDIFF' => 'keys-all', + 'SDIFFSTORE' => 'keys-all', + 'SINTER' => 'keys-all', + 'SINTERSTORE' => 'keys-all', + 'SUNION' => 'keys-all', + 'SUNIONSTORE' => 'keys-all', + 'SISMEMBER' => 'keys-first', + 'SMEMBERS' => 'keys-first', + 'SSCAN' => 'keys-first', + 'SPOP' => 'keys-first', + 'SRANDMEMBER' => 'keys-first', + 'SREM' => 'keys-first', + + /* commands operating on sorted sets */ + 'ZADD' => 'keys-first', + 'ZCARD' => 'keys-first', + 'ZCOUNT' => 'keys-first', + 'ZINCRBY' => 'keys-first', + 'ZINTERSTORE' => 'keys-zaggregated', + 'ZRANGE' => 'keys-first', + 'ZRANGEBYSCORE' => 'keys-first', + 'ZRANK' => 'keys-first', + 'ZREM' => 'keys-first', + 'ZREMRANGEBYRANK' => 'keys-first', + 'ZREMRANGEBYSCORE' => 'keys-first', + 'ZREVRANGE' => 'keys-first', + 'ZREVRANGEBYSCORE' => 'keys-first', + 'ZREVRANK' => 'keys-first', + 'ZSCORE' => 'keys-first', + 'ZUNIONSTORE' => 'keys-zaggregated', + 'ZSCAN' => 'keys-first', + + /* commands operating on hashes */ + 'HDEL' => 'keys-first', + 'HEXISTS' => 'keys-first', + 'HGET' => 'keys-first', + 'HGETALL' => 'keys-first', + 'HMGET' => 'keys-first', + 'HMSET' => 'keys-first', + 'HINCRBY' => 'keys-first', + 'HINCRBYFLOAT' => 'keys-first', + 'HKEYS' => 'keys-first', + 'HLEN' => 'keys-first', + 'HSET' => 'keys-first', + 'HSETNX' => 'keys-first', + 'HVALS' => 'keys-first', + 'HSCAN' => 'keys-first', + + /* scripting */ + 'EVAL' => 'keys-script', + 'EVALSHA' => 'keys-script', + ); + + if (isset($type)) { + $commands = array_filter($commands, function ($expectedType) use ($type) { + return $expectedType === $type; + }); + } + + return array_keys($commands); + } +} diff --git a/vendor/predis/predis/tests/Predis/Cluster/RedisClusterHashStrategyTest.php b/vendor/predis/predis/tests/Predis/Cluster/RedisClusterHashStrategyTest.php new file mode 100755 index 0000000..3bc3493 --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Cluster/RedisClusterHashStrategyTest.php @@ -0,0 +1,367 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Cluster; + +use PredisTestCase; +use Predis\Profile\ServerProfile; + +/** + * + */ +class RedisClusterHashStrategyTest extends PredisTestCase +{ + /** + * @group disconnected + */ + public function testDoesNotSupportKeyTags() + { + $strategy = $this->getHashStrategy(); + + $this->assertSame(35910, $strategy->getKeyHash('{foo}')); + $this->assertSame(60032, $strategy->getKeyHash('{foo}:bar')); + $this->assertSame(27528, $strategy->getKeyHash('{foo}:baz')); + $this->assertSame(34064, $strategy->getKeyHash('bar:{foo}:bar')); + } + + /** + * @group disconnected + */ + public function testSupportedCommands() + { + $strategy = $this->getHashStrategy(); + + $this->assertSame($this->getExpectedCommands(), $strategy->getSupportedCommands()); + } + + /** + * @group disconnected + */ + public function testReturnsNullOnUnsupportedCommand() + { + $strategy = $this->getHashStrategy(); + $command = ServerProfile::getDevelopment()->createCommand('ping'); + + $this->assertNull($strategy->getHash($command)); + } + + /** + * @group disconnected + */ + public function testFirstKeyCommands() + { + $strategy = $this->getHashStrategy(); + $profile = ServerProfile::getDevelopment(); + $arguments = array('key'); + + foreach ($this->getExpectedCommands('keys-first') as $commandID) { + $command = $profile->createCommand($commandID, $arguments); + $this->assertNotNull($strategy->getHash($command), $commandID); + } + } + + /** + * @group disconnected + */ + public function testAllKeysCommandsWithOneKey() + { + $strategy = $this->getHashStrategy(); + $profile = ServerProfile::getDevelopment(); + $arguments = array('key'); + + foreach ($this->getExpectedCommands('keys-all') as $commandID) { + $command = $profile->createCommand($commandID, $arguments); + $this->assertNotNull($strategy->getHash($command), $commandID); + } + } + + /** + * @group disconnected + */ + public function testAllKeysCommandsWithMoreKeys() + { + $strategy = $this->getHashStrategy(); + $profile = ServerProfile::getDevelopment(); + $arguments = array('key1', 'key2'); + + foreach ($this->getExpectedCommands('keys-all') as $commandID) { + $command = $profile->createCommand($commandID, $arguments); + $this->assertNull($strategy->getHash($command), $commandID); + } + } + + /** + * @group disconnected + */ + public function testInterleavedKeysCommandsWithOneKey() + { + $strategy = $this->getHashStrategy(); + $profile = ServerProfile::getDevelopment(); + $arguments = array('key:1', 'value1'); + + foreach ($this->getExpectedCommands('keys-interleaved') as $commandID) { + $command = $profile->createCommand($commandID, $arguments); + $this->assertNotNull($strategy->getHash($command), $commandID); + } + } + + /** + * @group disconnected + */ + public function testInterleavedKeysCommandsWithMoreKeys() + { + $strategy = $this->getHashStrategy(); + $profile = ServerProfile::getDevelopment(); + $arguments = array('key:1', 'value1', 'key:2', 'value2'); + + foreach ($this->getExpectedCommands('keys-interleaved') as $commandID) { + $command = $profile->createCommand($commandID, $arguments); + $this->assertNull($strategy->getHash($command), $commandID); + } + } + + /** + * @group disconnected + */ + public function testKeysForBlockingListCommandsWithOneKey() + { + $strategy = $this->getHashStrategy(); + $profile = ServerProfile::getDevelopment(); + $arguments = array('key:1', 10); + + foreach ($this->getExpectedCommands('keys-blockinglist') as $commandID) { + $command = $profile->createCommand($commandID, $arguments); + $this->assertNotNull($strategy->getHash($command), $commandID); + } + } + + /** + * @group disconnected + */ + public function testKeysForBlockingListCommandsWithMoreKeys() + { + $strategy = $this->getHashStrategy(); + $profile = ServerProfile::getDevelopment(); + $arguments = array('key:1', 'key:2', 10); + + foreach ($this->getExpectedCommands('keys-blockinglist') as $commandID) { + $command = $profile->createCommand($commandID, $arguments); + $this->assertNull($strategy->getHash($command), $commandID); + } + } + + /** + * @group disconnected + */ + public function testKeysForScriptCommand() + { + $strategy = $this->getHashStrategy(); + $profile = ServerProfile::getDevelopment(); + $arguments = array('%SCRIPT%', 1, 'key:1', 'value1'); + + foreach ($this->getExpectedCommands('keys-script') as $commandID) { + $command = $profile->createCommand($commandID, $arguments); + $this->assertNotNull($strategy->getHash($command), $commandID); + } + } + + /** + * @group disconnected + */ + public function testKeysForScriptedCommand() + { + $strategy = $this->getHashStrategy(); + $arguments = array('key:1', 'value1'); + + $command = $this->getMock('Predis\Command\ScriptedCommand', array('getScript', 'getKeysCount')); + $command->expects($this->once()) + ->method('getScript') + ->will($this->returnValue('return true')); + $command->expects($this->exactly(2)) + ->method('getKeysCount') + ->will($this->returnValue(1)); + $command->setArguments($arguments); + + $this->assertNotNull($strategy->getHash($command), "Scripted Command [{$command->getId()}]"); + } + + /** + * @group disconnected + */ + public function testUnsettingCommandHandler() + { + $strategy = $this->getHashStrategy(); + $profile = ServerProfile::getDevelopment(); + + $strategy->setCommandHandler('set'); + $strategy->setCommandHandler('get', null); + + $command = $profile->createCommand('set', array('key', 'value')); + $this->assertNull($strategy->getHash($command)); + + $command = $profile->createCommand('get', array('key')); + $this->assertNull($strategy->getHash($command)); + } + + /** + * @group disconnected + */ + public function testSettingCustomCommandHandler() + { + $strategy = $this->getHashStrategy(); + $profile = ServerProfile::getDevelopment(); + + $callable = $this->getMock('stdClass', array('__invoke')); + $callable->expects($this->once()) + ->method('__invoke') + ->with($this->isInstanceOf('Predis\Command\CommandInterface')) + ->will($this->returnValue('key')); + + $strategy->setCommandHandler('get', $callable); + + $command = $profile->createCommand('get', array('key')); + $this->assertNotNull($strategy->getHash($command)); + } + + // ******************************************************************** // + // ---- HELPER METHODS ------------------------------------------------ // + // ******************************************************************** // + + /** + * Creates the default hash strategy object. + * + * @return CommandHashStrategyInterface + */ + protected function getHashStrategy() + { + $strategy = new RedisClusterHashStrategy(); + + return $strategy; + } + + /** + * Returns the list of expected supported commands. + * + * @param string $type Optional type of command (based on its keys) + * @return array + */ + protected function getExpectedCommands($type = null) + { + $commands = array( + /* commands operating on the key space */ + 'EXISTS' => 'keys-first', + 'DEL' => 'keys-all', + 'TYPE' => 'keys-first', + 'EXPIRE' => 'keys-first', + 'EXPIREAT' => 'keys-first', + 'PERSIST' => 'keys-first', + 'PEXPIRE' => 'keys-first', + 'PEXPIREAT' => 'keys-first', + 'TTL' => 'keys-first', + 'PTTL' => 'keys-first', + 'SORT' => 'keys-first', // TODO + + /* commands operating on string values */ + 'APPEND' => 'keys-first', + 'DECR' => 'keys-first', + 'DECRBY' => 'keys-first', + 'GET' => 'keys-first', + 'GETBIT' => 'keys-first', + 'MGET' => 'keys-all', + 'SET' => 'keys-first', + 'GETRANGE' => 'keys-first', + 'GETSET' => 'keys-first', + 'INCR' => 'keys-first', + 'INCRBY' => 'keys-first', + 'SETBIT' => 'keys-first', + 'SETEX' => 'keys-first', + 'MSET' => 'keys-interleaved', + 'MSETNX' => 'keys-interleaved', + 'SETNX' => 'keys-first', + 'SETRANGE' => 'keys-first', + 'STRLEN' => 'keys-first', + 'SUBSTR' => 'keys-first', + 'BITCOUNT' => 'keys-first', + + /* commands operating on lists */ + 'LINSERT' => 'keys-first', + 'LINDEX' => 'keys-first', + 'LLEN' => 'keys-first', + 'LPOP' => 'keys-first', + 'RPOP' => 'keys-first', + 'BLPOP' => 'keys-blockinglist', + 'BRPOP' => 'keys-blockinglist', + 'LPUSH' => 'keys-first', + 'LPUSHX' => 'keys-first', + 'RPUSH' => 'keys-first', + 'RPUSHX' => 'keys-first', + 'LRANGE' => 'keys-first', + 'LREM' => 'keys-first', + 'LSET' => 'keys-first', + 'LTRIM' => 'keys-first', + + /* commands operating on sets */ + 'SADD' => 'keys-first', + 'SCARD' => 'keys-first', + 'SISMEMBER' => 'keys-first', + 'SMEMBERS' => 'keys-first', + 'SSCAN' => 'keys-first', + 'SPOP' => 'keys-first', + 'SRANDMEMBER' => 'keys-first', + 'SREM' => 'keys-first', + + /* commands operating on sorted sets */ + 'ZADD' => 'keys-first', + 'ZCARD' => 'keys-first', + 'ZCOUNT' => 'keys-first', + 'ZINCRBY' => 'keys-first', + 'ZRANGE' => 'keys-first', + 'ZRANGEBYSCORE' => 'keys-first', + 'ZRANK' => 'keys-first', + 'ZREM' => 'keys-first', + 'ZREMRANGEBYRANK' => 'keys-first', + 'ZREMRANGEBYSCORE' => 'keys-first', + 'ZREVRANGE' => 'keys-first', + 'ZREVRANGEBYSCORE' => 'keys-first', + 'ZREVRANK' => 'keys-first', + 'ZSCORE' => 'keys-first', + 'ZSCAN' => 'keys-first', + + /* commands operating on hashes */ + 'HDEL' => 'keys-first', + 'HEXISTS' => 'keys-first', + 'HGET' => 'keys-first', + 'HGETALL' => 'keys-first', + 'HMGET' => 'keys-first', + 'HMSET' => 'keys-first', + 'HINCRBY' => 'keys-first', + 'HINCRBYFLOAT' => 'keys-first', + 'HKEYS' => 'keys-first', + 'HLEN' => 'keys-first', + 'HSET' => 'keys-first', + 'HSETNX' => 'keys-first', + 'HVALS' => 'keys-first', + 'HSCAN' => 'keys-first', + + /* scripting */ + 'EVAL' => 'keys-script', + 'EVALSHA' => 'keys-script', + ); + + if (isset($type)) { + $commands = array_filter($commands, function ($expectedType) use ($type) { + return $expectedType === $type; + }); + } + + return array_keys($commands); + } +} diff --git a/vendor/predis/predis/tests/Predis/Collection/Iterator/HashKeyTest.php b/vendor/predis/predis/tests/Predis/Collection/Iterator/HashKeyTest.php new file mode 100755 index 0000000..4c22a83 --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Collection/Iterator/HashKeyTest.php @@ -0,0 +1,480 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Collection\Iterator; + +use PredisTestCase; +use Predis\Client; +use Predis\Profile\ServerProfile; + +/** + * @group realm-iterators + */ +class HashKeyTest extends PredisTestCase +{ + /** + * @group disconnected + * @expectedException Predis\NotSupportedException + * @expectedExceptionMessage The specified server profile does not support the `HSCAN` command. + */ + public function testThrowsExceptionOnInvalidServerProfile() + { + $client = $this->getMock('Predis\ClientInterface'); + + $client->expects($this->any()) + ->method('getProfile') + ->will($this->returnValue(ServerProfile::get('2.0'))); + + $iterator = new HashKey($client, 'key:hash'); + } + + /** + * @group disconnected + */ + public function testIterationWithNoResults() + { + $client = $this->getMock('Predis\Client', array('getProfile', 'hscan')); + + $client->expects($this->any()) + ->method('getProfile') + ->will($this->returnValue(ServerProfile::get('2.8'))); + $client->expects($this->once()) + ->method('hscan') + ->with('key:hash', 0, array()) + ->will($this->returnValue(array(0, array()))); + + $iterator = new HashKey($client, 'key:hash'); + + $iterator->rewind(); + $this->assertFalse($iterator->valid()); + } + + /** + * @group disconnected + */ + public function testIterationOnSingleFetch() + { + $client = $this->getMock('Predis\Client', array('getProfile', 'hscan')); + + $client->expects($this->any()) + ->method('getProfile') + ->will($this->returnValue(ServerProfile::get('2.8'))); + $client->expects($this->once()) + ->method('hscan') + ->with('key:hash', 0, array()) + ->will($this->returnValue(array(0, array( + 'field:1st' => 'value:1st', 'field:2nd' => 'value:2nd', 'field:3rd' => 'value:3rd', + )))); + + $iterator = new HashKey($client, 'key:hash'); + + $iterator->rewind(); + $this->assertTrue($iterator->valid()); + $this->assertSame('value:1st', $iterator->current()); + $this->assertSame('field:1st', $iterator->key()); + + $iterator->next(); + $this->assertTrue($iterator->valid()); + $this->assertSame('value:2nd', $iterator->current()); + $this->assertSame('field:2nd', $iterator->key()); + + $iterator->next(); + $this->assertTrue($iterator->valid()); + $this->assertSame('value:3rd', $iterator->current()); + $this->assertSame('field:3rd', $iterator->key()); + + $iterator->next(); + $this->assertFalse($iterator->valid()); + } + + /** + * @group disconnected + */ + public function testIterationOnMultipleFetches() + { + $client = $this->getMock('Predis\Client', array('getProfile', 'hscan')); + + $client->expects($this->any()) + ->method('getProfile') + ->will($this->returnValue(ServerProfile::get('2.8'))); + $client->expects($this->at(1)) + ->method('hscan') + ->with('key:hash', 0, array()) + ->will($this->returnValue(array(2, array( + 'field:1st' => 'value:1st', 'field:2nd' => 'value:2nd', + )))); + $client->expects($this->at(2)) + ->method('hscan') + ->with('key:hash', 2, array()) + ->will($this->returnValue(array(0, array( + 'field:3rd' => 'value:3rd', + )))); + + $iterator = new HashKey($client, 'key:hash'); + + $iterator->rewind(); + $this->assertTrue($iterator->valid()); + $this->assertSame('value:1st', $iterator->current()); + $this->assertSame('field:1st', $iterator->key()); + + $iterator->next(); + $this->assertTrue($iterator->valid()); + $this->assertSame('value:2nd', $iterator->current()); + $this->assertSame('field:2nd', $iterator->key()); + + $iterator->next(); + $this->assertTrue($iterator->valid()); + $this->assertSame('value:3rd', $iterator->current()); + $this->assertSame('field:3rd', $iterator->key()); + + $iterator->next(); + $this->assertFalse($iterator->valid()); + } + + /** + * @group disconnected + */ + public function testIterationOnMultipleFetchesAndHoleInFirstFetch() + { + $client = $this->getMock('Predis\Client', array('getProfile', 'hscan')); + + $client->expects($this->any()) + ->method('getProfile') + ->will($this->returnValue(ServerProfile::get('2.8'))); + $client->expects($this->at(1)) + ->method('hscan') + ->with('key:hash', 0, array()) + ->will($this->returnValue(array(4, array()))); + $client->expects($this->at(2)) + ->method('hscan') + ->with('key:hash', 4, array()) + ->will($this->returnValue(array(0, array( + 'field:1st' => 'value:1st', 'field:2nd' => 'value:2nd', + )))); + + $iterator = new HashKey($client, 'key:hash'); + + $iterator->rewind(); + $this->assertTrue($iterator->valid()); + $this->assertSame('value:1st', $iterator->current()); + $this->assertSame('field:1st', $iterator->key()); + + $iterator->next(); + $this->assertTrue($iterator->valid()); + $this->assertSame('value:2nd', $iterator->current()); + $this->assertSame('field:2nd', $iterator->key()); + + $iterator->next(); + $this->assertFalse($iterator->valid()); + } + + /** + * @group disconnected + */ + public function testIterationOnMultipleFetchesAndHoleInMidFetch() + { + $client = $this->getMock('Predis\Client', array('getProfile', 'hscan')); + + $client->expects($this->any()) + ->method('getProfile') + ->will($this->returnValue(ServerProfile::get('2.8'))); + $client->expects($this->at(1)) + ->method('hscan') + ->with('key:hash', 0, array()) + ->will($this->returnValue(array(2, array( + 'field:1st' => 'value:1st', 'field:2nd' => 'value:2nd', + )))); + $client->expects($this->at(2)) + ->method('hscan') + ->with('key:hash', 2, array()) + ->will($this->returnValue(array(5, array()))); + $client->expects($this->at(3)) + ->method('hscan') + ->with('key:hash', 5, array()) + ->will($this->returnValue(array(0, array( + 'field:3rd' => 'value:3rd', + )))); + + $iterator = new HashKey($client, 'key:hash'); + + $iterator->rewind(); + $this->assertTrue($iterator->valid()); + $this->assertSame('value:1st', $iterator->current()); + $this->assertSame('field:1st', $iterator->key()); + + $iterator->next(); + $this->assertTrue($iterator->valid()); + $this->assertSame('value:2nd', $iterator->current()); + $this->assertSame('field:2nd', $iterator->key()); + + $iterator->next(); + $this->assertTrue($iterator->valid()); + $this->assertSame('value:3rd', $iterator->current()); + $this->assertSame('field:3rd', $iterator->key()); + + $iterator->next(); + $this->assertFalse($iterator->valid()); + } + + /** + * @group disconnected + */ + public function testIterationWithOptionMatch() + { + $client = $this->getMock('Predis\Client', array('getProfile', 'hscan')); + + $client->expects($this->any()) + ->method('getProfile') + ->will($this->returnValue(ServerProfile::get('2.8'))); + $client->expects($this->at(1)) + ->method('hscan') + ->with('key:hash', 0, array('MATCH' => 'field:*')) + ->will($this->returnValue(array(2, array( + 'field:1st' => 'value:1st', 'field:2nd' => 'value:2nd', + )))); + + $iterator = new HashKey($client, 'key:hash', 'field:*'); + + $iterator->rewind(); + $this->assertTrue($iterator->valid()); + $this->assertSame('value:1st', $iterator->current()); + $this->assertSame('field:1st', $iterator->key()); + + $iterator->next(); + $this->assertTrue($iterator->valid()); + $this->assertSame('value:2nd', $iterator->current()); + $this->assertSame('field:2nd', $iterator->key()); + + $iterator->next(); + $this->assertFalse($iterator->valid()); + } + + /** + * @group disconnected + */ + public function testIterationWithOptionMatchOnMultipleFetches() + { + $client = $this->getMock('Predis\Client', array('getProfile', 'hscan')); + + $client->expects($this->any()) + ->method('getProfile') + ->will($this->returnValue(ServerProfile::get('2.8'))); + $client->expects($this->at(1)) + ->method('hscan') + ->with('key:hash', 0, array('MATCH' => 'field:*')) + ->will($this->returnValue(array(1, array( + 'field:1st' => 'value:1st', + )))); + $client->expects($this->at(2)) + ->method('hscan') + ->with('key:hash', 1, array('MATCH' => 'field:*')) + ->will($this->returnValue(array(0, array( + 'field:2nd' => 'value:2nd', + )))); + + $iterator = new HashKey($client, 'key:hash', 'field:*'); + + $iterator->rewind(); + $this->assertTrue($iterator->valid()); + $this->assertSame('value:1st', $iterator->current()); + $this->assertSame('field:1st', $iterator->key()); + + $iterator->next(); + $this->assertTrue($iterator->valid()); + $this->assertSame('value:2nd', $iterator->current()); + $this->assertSame('field:2nd', $iterator->key()); + + $iterator->next(); + $this->assertFalse($iterator->valid()); + } + + /** + * @group disconnected + */ + public function testIterationWithOptionCount() + { + $client = $this->getMock('Predis\Client', array('getProfile', 'hscan')); + + $client->expects($this->any()) + ->method('getProfile') + ->will($this->returnValue(ServerProfile::get('2.8'))); + $client->expects($this->at(1)) + ->method('hscan') + ->with('key:hash', 0, array('COUNT' => 2)) + ->will($this->returnValue(array(0, array( + 'field:1st' => 'value:1st', 'field:2nd' => 'value:2nd', + )))); + + $iterator = new HashKey($client, 'key:hash', null, 2); + + $iterator->rewind(); + $this->assertTrue($iterator->valid()); + $this->assertSame('value:1st', $iterator->current()); + $this->assertSame('field:1st', $iterator->key()); + + $iterator->next(); + $this->assertTrue($iterator->valid()); + $this->assertSame('value:2nd', $iterator->current()); + $this->assertSame('field:2nd', $iterator->key()); + + $iterator->next(); + $this->assertFalse($iterator->valid()); + } + + /** + * @group disconnected + */ + public function testIterationWithOptionCountOnMultipleFetches() + { + $client = $this->getMock('Predis\Client', array('getProfile', 'hscan')); + + $client->expects($this->any()) + ->method('getProfile') + ->will($this->returnValue(ServerProfile::get('2.8'))); + $client->expects($this->at(1)) + ->method('hscan') + ->with('key:hash', 0, array('COUNT' => 1)) + ->will($this->returnValue(array(1, array( + 'field:1st' => 'value:1st', + )))); + $client->expects($this->at(2)) + ->method('hscan') + ->with('key:hash', 1, array('COUNT' => 1)) + ->will($this->returnValue(array(0, array( + 'field:2nd' => 'value:2nd', + )))); + + $iterator = new HashKey($client, 'key:hash', null, 1); + + $iterator->rewind(); + $this->assertTrue($iterator->valid()); + $this->assertSame('value:1st', $iterator->current()); + $this->assertSame('field:1st', $iterator->key()); + + $iterator->next(); + $this->assertTrue($iterator->valid()); + $this->assertSame('value:2nd', $iterator->current()); + $this->assertSame('field:2nd', $iterator->key()); + + $iterator->next(); + $this->assertFalse($iterator->valid()); + } + + /** + * @group disconnected + */ + public function testIterationWithOptionsMatchAndCount() + { + $client = $this->getMock('Predis\Client', array('getProfile', 'hscan')); + + $client->expects($this->any()) + ->method('getProfile') + ->will($this->returnValue(ServerProfile::get('2.8'))); + $client->expects($this->at(1)) + ->method('hscan') + ->with('key:hash', 0, array('MATCH' => 'field:*', 'COUNT' => 2)) + ->will($this->returnValue(array(0, array( + 'field:1st' => 'value:1st', 'field:2nd' => 'value:2nd', + )))); + + $iterator = new HashKey($client, 'key:hash', 'field:*', 2); + + $iterator->rewind(); + $this->assertTrue($iterator->valid()); + $this->assertSame('value:1st', $iterator->current()); + $this->assertSame('field:1st', $iterator->key()); + + $iterator->next(); + $this->assertTrue($iterator->valid()); + $this->assertSame('value:2nd', $iterator->current()); + $this->assertSame('field:2nd', $iterator->key()); + + $iterator->next(); + $this->assertFalse($iterator->valid()); + } + + /** + * @group disconnected + */ + public function testIterationWithOptionsMatchAndCountOnMultipleFetches() + { + $client = $this->getMock('Predis\Client', array('getProfile', 'hscan')); + + $client->expects($this->any()) + ->method('getProfile') + ->will($this->returnValue(ServerProfile::get('2.8'))); + $client->expects($this->at(1)) + ->method('hscan') + ->with('key:hash', 0, array('MATCH' => 'field:*', 'COUNT' => 1)) + ->will($this->returnValue(array(1, array( + 'field:1st' => 'value:1st', + )))); + $client->expects($this->at(2)) + ->method('hscan') + ->with('key:hash', 1, array('MATCH' => 'field:*', 'COUNT' => 1)) + ->will($this->returnValue(array(0, array( + 'field:2nd' => 'value:2nd', + )))); + + $iterator = new HashKey($client, 'key:hash', 'field:*', 1); + + $iterator->rewind(); + $this->assertTrue($iterator->valid()); + $this->assertSame('value:1st', $iterator->current()); + $this->assertSame('field:1st', $iterator->key()); + + $iterator->next(); + $this->assertTrue($iterator->valid()); + $this->assertSame('value:2nd', $iterator->current()); + $this->assertSame('field:2nd', $iterator->key()); + + $iterator->next(); + $this->assertFalse($iterator->valid()); + } + + /** + * @group disconnected + */ + public function testIterationRewindable() + { + $client = $this->getMock('Predis\Client', array('getProfile', 'hscan')); + + $client->expects($this->any()) + ->method('getProfile') + ->will($this->returnValue(ServerProfile::get('2.8'))); + $client->expects($this->exactly(2)) + ->method('hscan') + ->with('key:hash', 0, array()) + ->will($this->returnValue(array(0, array( + 'field:1st' => 'value:1st', 'field:2nd' => 'value:2nd', + )))); + + $iterator = new HashKey($client, 'key:hash'); + + $iterator->rewind(); + $this->assertTrue($iterator->valid()); + $this->assertSame('value:1st', $iterator->current()); + $this->assertSame('field:1st', $iterator->key()); + + $iterator->rewind(); + $this->assertTrue($iterator->valid()); + $this->assertSame('value:1st', $iterator->current()); + $this->assertSame('field:1st', $iterator->key()); + + $iterator->next(); + $this->assertTrue($iterator->valid()); + $this->assertSame('value:2nd', $iterator->current()); + $this->assertSame('field:2nd', $iterator->key()); + + $iterator->next(); + $this->assertFalse($iterator->valid()); + } +} diff --git a/vendor/predis/predis/tests/Predis/Collection/Iterator/KeyspaceTest.php b/vendor/predis/predis/tests/Predis/Collection/Iterator/KeyspaceTest.php new file mode 100755 index 0000000..70b4a79 --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Collection/Iterator/KeyspaceTest.php @@ -0,0 +1,448 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Collection\Iterator; + +use PredisTestCase; +use Predis\Client; +use Predis\Profile\ServerProfile; + +/** + * @group realm-iterators + */ +class KeyspaceTest extends PredisTestCase +{ + /** + * @group disconnected + * @expectedException Predis\NotSupportedException + * @expectedExceptionMessage The specified server profile does not support the `SCAN` command. + */ + public function testThrowsExceptionOnInvalidServerProfile() + { + $client = $this->getMock('Predis\ClientInterface'); + + $client->expects($this->any()) + ->method('getProfile') + ->will($this->returnValue(ServerProfile::get('2.0'))); + + $iterator = new Keyspace($client); + } + + /** + * @group disconnected + */ + public function testIterationWithNoResults() + { + $client = $this->getMock('Predis\Client', array('getProfile', 'scan')); + + $client->expects($this->any()) + ->method('getProfile') + ->will($this->returnValue(ServerProfile::get('2.8'))); + $client->expects($this->once()) + ->method('scan') + ->with(0, array()) + ->will($this->returnValue(array(0, array()))); + + $iterator = new Keyspace($client); + + $iterator->rewind(); + $this->assertFalse($iterator->valid()); + } + + /** + * @group disconnected + */ + public function testIterationOnSingleFetch() + { + $client = $this->getMock('Predis\Client', array('getProfile', 'scan')); + + $client->expects($this->any()) + ->method('getProfile') + ->will($this->returnValue(ServerProfile::get('2.8'))); + $client->expects($this->once()) + ->method('scan') + ->with(0, array()) + ->will($this->returnValue(array(0, array('key:1st', 'key:2nd', 'key:3rd')))); + + $iterator = new Keyspace($client); + + $iterator->rewind(); + $this->assertTrue($iterator->valid()); + $this->assertSame('key:1st', $iterator->current()); + $this->assertSame(0, $iterator->key()); + + $iterator->next(); + $this->assertTrue($iterator->valid()); + $this->assertSame('key:2nd', $iterator->current()); + $this->assertSame(1, $iterator->key()); + + $iterator->next(); + $this->assertTrue($iterator->valid()); + $this->assertSame('key:3rd', $iterator->current()); + $this->assertSame(2, $iterator->key()); + + $iterator->next(); + $this->assertFalse($iterator->valid()); + } + + /** + * @group disconnected + */ + public function testIterationOnMultipleFetches() + { + $client = $this->getMock('Predis\Client', array('getProfile', 'scan')); + + $client->expects($this->any()) + ->method('getProfile') + ->will($this->returnValue(ServerProfile::get('2.8'))); + $client->expects($this->at(1)) + ->method('scan') + ->with(0, array()) + ->will($this->returnValue(array(2, array('key:1st', 'key:2nd')))); + $client->expects($this->at(2)) + ->method('scan') + ->with(2, array()) + ->will($this->returnValue(array(0, array('key:3rd')))); + + $iterator = new Keyspace($client); + + $iterator->rewind(); + $this->assertTrue($iterator->valid()); + $this->assertSame('key:1st', $iterator->current()); + $this->assertSame(0, $iterator->key()); + + $iterator->next(); + $this->assertTrue($iterator->valid()); + $this->assertSame('key:2nd', $iterator->current()); + $this->assertSame(1, $iterator->key()); + + $iterator->next(); + $this->assertTrue($iterator->valid()); + $this->assertSame('key:3rd', $iterator->current()); + $this->assertSame(2, $iterator->key()); + + $iterator->next(); + $this->assertFalse($iterator->valid()); + } + + /** + * @group disconnected + */ + public function testIterationOnMultipleFetchesAndHoleInFirstFetch() + { + $client = $this->getMock('Predis\Client', array('getProfile', 'scan')); + + $client->expects($this->any()) + ->method('getProfile') + ->will($this->returnValue(ServerProfile::get('2.8'))); + $client->expects($this->at(1)) + ->method('scan') + ->with(0, array()) + ->will($this->returnValue(array(4, array()))); + $client->expects($this->at(2)) + ->method('scan') + ->with(4, array()) + ->will($this->returnValue(array(0, array('key:1st', 'key:2nd')))); + + $iterator = new Keyspace($client); + + $iterator->rewind(); + $this->assertTrue($iterator->valid()); + $this->assertSame('key:1st', $iterator->current()); + $this->assertSame(0, $iterator->key()); + + $iterator->next(); + $this->assertTrue($iterator->valid()); + $this->assertSame('key:2nd', $iterator->current()); + $this->assertSame(1, $iterator->key()); + + $iterator->next(); + $this->assertFalse($iterator->valid()); + } + + /** + * @group disconnected + */ + public function testIterationOnMultipleFetchesAndHoleInMidFetch() + { + $client = $this->getMock('Predis\Client', array('getProfile', 'scan')); + + $client->expects($this->any()) + ->method('getProfile') + ->will($this->returnValue(ServerProfile::get('2.8'))); + $client->expects($this->at(1)) + ->method('scan') + ->with(0, array()) + ->will($this->returnValue(array(2, array('key:1st', 'key:2nd')))); + $client->expects($this->at(2)) + ->method('scan') + ->with(2, array()) + ->will($this->returnValue(array(5, array()))); + $client->expects($this->at(3)) + ->method('scan') + ->with(5, array()) + ->will($this->returnValue(array(0, array('key:3rd')))); + + $iterator = new Keyspace($client); + + $iterator->rewind(); + $this->assertTrue($iterator->valid()); + $this->assertSame('key:1st', $iterator->current()); + $this->assertSame(0, $iterator->key()); + + $iterator->next(); + $this->assertTrue($iterator->valid()); + $this->assertSame('key:2nd', $iterator->current()); + $this->assertSame(1, $iterator->key()); + + $iterator->next(); + $this->assertTrue($iterator->valid()); + $this->assertSame('key:3rd', $iterator->current()); + $this->assertSame(2, $iterator->key()); + + $iterator->next(); + $this->assertFalse($iterator->valid()); + } + + /** + * @group disconnected + */ + public function testIterationWithOptionMatch() + { + $client = $this->getMock('Predis\Client', array('getProfile', 'scan')); + + $client->expects($this->any()) + ->method('getProfile') + ->will($this->returnValue(ServerProfile::get('2.8'))); + $client->expects($this->at(1)) + ->method('scan') + ->with(0, array('MATCH' => 'key:*')) + ->will($this->returnValue(array(0, array('key:1st', 'key:2nd')))); + + $iterator = new Keyspace($client, 'key:*'); + + $iterator->rewind(); + $this->assertTrue($iterator->valid()); + $this->assertSame('key:1st', $iterator->current()); + $this->assertSame(0, $iterator->key()); + + $iterator->next(); + $this->assertTrue($iterator->valid()); + $this->assertSame('key:2nd', $iterator->current()); + $this->assertSame(1, $iterator->key()); + + $iterator->next(); + $this->assertFalse($iterator->valid()); + } + + /** + * @group disconnected + */ + public function testIterationWithOptionMatchOnMultipleFetches() + { + $client = $this->getMock('Predis\Client', array('getProfile', 'scan')); + + $client->expects($this->any()) + ->method('getProfile') + ->will($this->returnValue(ServerProfile::get('2.8'))); + $client->expects($this->at(1)) + ->method('scan') + ->with(0, array('MATCH' => 'key:*')) + ->will($this->returnValue(array(1, array('key:1st')))); + $client->expects($this->at(2)) + ->method('scan') + ->with(1, array('MATCH' => 'key:*')) + ->will($this->returnValue(array(0, array('key:2nd')))); + + $iterator = new Keyspace($client, 'key:*'); + + $iterator->rewind(); + $this->assertTrue($iterator->valid()); + $this->assertSame('key:1st', $iterator->current()); + $this->assertSame(0, $iterator->key()); + + $iterator->next(); + $this->assertTrue($iterator->valid()); + $this->assertSame('key:2nd', $iterator->current()); + $this->assertSame(1, $iterator->key()); + + $iterator->next(); + $this->assertFalse($iterator->valid()); + } + + /** + * @group disconnected + */ + public function testIterationWithOptionCount() + { + $client = $this->getMock('Predis\Client', array('getProfile', 'scan')); + + $client->expects($this->any()) + ->method('getProfile') + ->will($this->returnValue(ServerProfile::get('2.8'))); + $client->expects($this->at(1)) + ->method('scan') + ->with(0, array('COUNT' => 2)) + ->will($this->returnValue(array(0, array('key:1st', 'key:2nd')))); + + $iterator = new Keyspace($client, null, 2); + + $iterator->rewind(); + $this->assertTrue($iterator->valid()); + $this->assertSame('key:1st', $iterator->current()); + $this->assertSame(0, $iterator->key()); + + $iterator->next(); + $this->assertTrue($iterator->valid()); + $this->assertSame('key:2nd', $iterator->current()); + $this->assertSame(1, $iterator->key()); + + $iterator->next(); + $this->assertFalse($iterator->valid()); + } + + /** + * @group disconnected + */ + public function testIterationWithOptionCountOnMultipleFetches() + { + $client = $this->getMock('Predis\Client', array('getProfile', 'scan')); + + $client->expects($this->any()) + ->method('getProfile') + ->will($this->returnValue(ServerProfile::get('2.8'))); + $client->expects($this->at(1)) + ->method('scan') + ->with(0, array('COUNT' => 1)) + ->will($this->returnValue(array(1, array('key:1st')))); + $client->expects($this->at(2)) + ->method('scan') + ->with(1, array('COUNT' => 1)) + ->will($this->returnValue(array(0, array('key:2nd')))); + + $iterator = new Keyspace($client, null, 1); + + $iterator->rewind(); + $this->assertTrue($iterator->valid()); + $this->assertSame('key:1st', $iterator->current()); + $this->assertSame(0, $iterator->key()); + + $iterator->next(); + $this->assertTrue($iterator->valid()); + $this->assertSame('key:2nd', $iterator->current()); + $this->assertSame(1, $iterator->key()); + + $iterator->next(); + $this->assertFalse($iterator->valid()); + } + + /** + * @group disconnected + */ + public function testIterationWithOptionsMatchAndCount() + { + $client = $this->getMock('Predis\Client', array('getProfile', 'scan')); + + $client->expects($this->any()) + ->method('getProfile') + ->will($this->returnValue(ServerProfile::get('2.8'))); + $client->expects($this->at(1)) + ->method('scan') + ->with(0, array('MATCH' => 'key:*', 'COUNT' => 2)) + ->will($this->returnValue(array(0, array('key:1st', 'key:2nd')))); + + $iterator = new Keyspace($client, 'key:*', 2); + + $iterator->rewind(); + $this->assertTrue($iterator->valid()); + $this->assertSame('key:1st', $iterator->current()); + $this->assertSame(0, $iterator->key()); + + $iterator->next(); + $this->assertTrue($iterator->valid()); + $this->assertSame('key:2nd', $iterator->current()); + $this->assertSame(1, $iterator->key()); + + $iterator->next(); + $this->assertFalse($iterator->valid()); + } + + /** + * @group disconnected + */ + public function testIterationWithOptionsMatchAndCountOnMultipleFetches() + { + $client = $this->getMock('Predis\Client', array('getProfile', 'scan')); + + $client->expects($this->any()) + ->method('getProfile') + ->will($this->returnValue(ServerProfile::get('2.8'))); + $client->expects($this->at(1)) + ->method('scan') + ->with(0, array('MATCH' => 'key:*', 'COUNT' => 1)) + ->will($this->returnValue(array(1, array('key:1st')))); + $client->expects($this->at(2)) + ->method('scan') + ->with(1, array('MATCH' => 'key:*', 'COUNT' => 1)) + ->will($this->returnValue(array(0, array('key:2nd')))); + + $iterator = new Keyspace($client, 'key:*', 1); + + $iterator->rewind(); + $this->assertTrue($iterator->valid()); + $this->assertSame('key:1st', $iterator->current()); + $this->assertSame(0, $iterator->key()); + + $iterator->next(); + $this->assertTrue($iterator->valid()); + $this->assertSame('key:2nd', $iterator->current()); + $this->assertSame(1, $iterator->key()); + + $iterator->next(); + $this->assertFalse($iterator->valid()); + } + + /** + * @group disconnected + */ + public function testIterationRewindable() + { + $client = $this->getMock('Predis\Client', array('getProfile', 'scan')); + + $client->expects($this->any()) + ->method('getProfile') + ->will($this->returnValue(ServerProfile::get('2.8'))); + $client->expects($this->exactly(2)) + ->method('scan') + ->with(0, array()) + ->will($this->returnValue(array(0, array('key:1st', 'key:2nd')))); + + $iterator = new Keyspace($client); + + $iterator->rewind(); + $this->assertTrue($iterator->valid()); + $this->assertSame('key:1st', $iterator->current()); + $this->assertSame(0, $iterator->key()); + + $iterator->rewind(); + $this->assertTrue($iterator->valid()); + $this->assertSame('key:1st', $iterator->current()); + $this->assertSame(0, $iterator->key()); + + $iterator->next(); + $this->assertTrue($iterator->valid()); + $this->assertSame(1, $iterator->key()); + $this->assertSame('key:2nd', $iterator->current()); + + $iterator->next(); + $this->assertFalse($iterator->valid()); + } +} diff --git a/vendor/predis/predis/tests/Predis/Collection/Iterator/ListKeyTest.php b/vendor/predis/predis/tests/Predis/Collection/Iterator/ListKeyTest.php new file mode 100755 index 0000000..a0470d3 --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Collection/Iterator/ListKeyTest.php @@ -0,0 +1,248 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Collection\Iterator; + +use PredisTestCase; +use Predis\Client; +use Predis\Profile\ServerProfile; + +/** + * @group realm-iterators + */ +class ListKeyTest extends PredisTestCase +{ + /** + * @group disconnected + */ + public function testIterationWithNoResults() + { + $client = $this->getMock('Predis\Client', array('getProfile', 'lrange')); + + $client->expects($this->any()) + ->method('getProfile') + ->will($this->returnValue(ServerProfile::getDefault())); + $client->expects($this->once()) + ->method('lrange') + ->with('key:list', 0, 9) + ->will($this->returnValue(array())); + + $iterator = new ListKey($client, 'key:list'); + + $iterator->rewind(); + $this->assertFalse($iterator->valid()); + } + + /** + * @group disconnected + */ + public function testIterationOnSingleFetch() + { + $client = $this->getMock('Predis\Client', array('getProfile', 'lrange')); + + $client->expects($this->any()) + ->method('getProfile') + ->will($this->returnValue(ServerProfile::getDefault())); + $client->expects($this->once()) + ->method('lrange') + ->with('key:list', 0, 9) + ->will($this->returnValue(array('item:1', 'item:2', 'item:3'))); + + $iterator = new ListKey($client, 'key:list'); + + $iterator->rewind(); + $this->assertTrue($iterator->valid()); + $this->assertSame('item:1', $iterator->current()); + $this->assertSame(0, $iterator->key()); + + $iterator->next(); + $this->assertTrue($iterator->valid()); + $this->assertSame('item:2', $iterator->current()); + $this->assertSame(1, $iterator->key()); + + $iterator->next(); + $this->assertTrue($iterator->valid()); + $this->assertSame('item:3', $iterator->current()); + $this->assertSame(2, $iterator->key()); + + $iterator->next(); + $this->assertFalse($iterator->valid()); + } + + /** + * @group disconnected + */ + public function testIterationOnMultipleFetches() + { + $client = $this->getMock('Predis\Client', array('getProfile', 'lrange')); + + $client->expects($this->any()) + ->method('getProfile') + ->will($this->returnValue(ServerProfile::getDefault())); + $client->expects($this->at(1)) + ->method('lrange') + ->with('key:list', 0, 9) + ->will($this->returnValue(array( + 'item:1', 'item:2', 'item:3', 'item:4', 'item:5', 'item:6', 'item:7', 'item:8', 'item:9', 'item:10' + ))); + $client->expects($this->at(2)) + ->method('lrange') + ->with('key:list', 10, 19) + ->will($this->returnValue(array('item:11', 'item:12'))); + + $iterator = new ListKey($client, 'key:list'); + + for ($i = 1, $iterator->rewind(); $i <= 12; $i++, $iterator->next()) { + $this->assertTrue($iterator->valid()); + $this->assertSame("item:$i", $iterator->current()); + $this->assertSame($i - 1, $iterator->key()); + } + + $this->assertFalse($iterator->valid()); + } + + /** + * @group disconnected + * @expectedException InvalidArgumentException + * @expectedExceptionMessage The $count argument must be a positive integer. + */ + public function testThrowsExceptionOnConstructorWithNonIntegerCountParameter() + { + $client = $this->getMock('Predis\ClientInterface'); + $client->expects($this->any()) + ->method('getProfile') + ->will($this->returnValue(ServerProfile::getDefault())); + + $iterator = new ListKey($client, 'key:list', 'wrong'); + } + + /** + * @group disconnected + * @expectedException InvalidArgumentException + * @expectedExceptionMessage The $count argument must be a positive integer. + */ + public function testThrowsExceptionOnConstructorWithNegativeCountParameter() + { + $client = $this->getMock('Predis\ClientInterface'); + $client->expects($this->any()) + ->method('getProfile') + ->will($this->returnValue(ServerProfile::getDefault())); + + $iterator = new ListKey($client, 'key:list', 'wrong'); + } + + /** + * @group disconnected + */ + public function testIterationWithCountParameter() + { + $client = $this->getMock('Predis\Client', array('getProfile', 'lrange')); + + $client->expects($this->any()) + ->method('getProfile') + ->will($this->returnValue(ServerProfile::getDefault())); + $client->expects($this->at(1)) + ->method('lrange') + ->with('key:list', 0, 4) + ->will($this->returnValue(array('item:1', 'item:2'))); + + $iterator = new ListKey($client, 'key:list', 5); + + $iterator->rewind(); + $this->assertTrue($iterator->valid()); + $this->assertSame('item:1', $iterator->current()); + $this->assertSame(0, $iterator->key()); + + $iterator->next(); + $this->assertTrue($iterator->valid()); + $this->assertSame('item:2', $iterator->current()); + $this->assertSame(1, $iterator->key()); + + $iterator->next(); + $this->assertFalse($iterator->valid()); + } + + /** + * @group disconnected + */ + public function testIterationWithCountParameterOnMultipleFetches() + { + $client = $this->getMock('Predis\Client', array('getProfile', 'lrange')); + + $client->expects($this->any()) + ->method('getProfile') + ->will($this->returnValue(ServerProfile::getDefault())); + $client->expects($this->at(1)) + ->method('lrange') + ->with('key:list', 0, 1) + ->will($this->returnValue(array('item:1', 'item:2'))); + $client->expects($this->at(2)) + ->method('lrange') + ->with('key:list', 2, 3) + ->will($this->returnValue(array('item:3'))); + + $iterator = new ListKey($client, 'key:list', 2); + + $iterator->rewind(); + $this->assertTrue($iterator->valid()); + $this->assertSame('item:1', $iterator->current()); + $this->assertSame(0, $iterator->key()); + + $iterator->next(); + $this->assertTrue($iterator->valid()); + $this->assertSame('item:2', $iterator->current()); + $this->assertSame(1, $iterator->key()); + + $iterator->next(); + $this->assertTrue($iterator->valid()); + $this->assertSame('item:3', $iterator->current()); + $this->assertSame(2, $iterator->key()); + + $iterator->next(); + $this->assertFalse($iterator->valid()); + } + + /** + * @group disconnected + */ + public function testIterationRewindable() + { + $client = $this->getMock('Predis\Client', array('getProfile', 'lrange')); + + $client->expects($this->any()) + ->method('getProfile') + ->will($this->returnValue(ServerProfile::getDefault())); + $client->expects($this->exactly(2)) + ->method('lrange') + ->with('key:list', 0, 9) + ->will($this->returnValue(array('item:1', 'item:2'))); + + $iterator = new ListKey($client, 'key:list'); + + $iterator->rewind(); + $this->assertTrue($iterator->valid()); + $this->assertSame('item:1', $iterator->current()); + $this->assertSame(0, $iterator->key()); + + $iterator->rewind(); + $this->assertTrue($iterator->valid()); + $this->assertSame('item:1', $iterator->current()); + $this->assertSame(0, $iterator->key()); + + $iterator->next(); + $this->assertTrue($iterator->valid()); + $this->assertSame(1, $iterator->key()); + $this->assertSame('item:2', $iterator->current()); + + $iterator->next(); + $this->assertFalse($iterator->valid()); + } +} diff --git a/vendor/predis/predis/tests/Predis/Collection/Iterator/SetKeyTest.php b/vendor/predis/predis/tests/Predis/Collection/Iterator/SetKeyTest.php new file mode 100755 index 0000000..e8f8981 --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Collection/Iterator/SetKeyTest.php @@ -0,0 +1,448 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Collection\Iterator; + +use PredisTestCase; +use Predis\Client; +use Predis\Profile\ServerProfile; + +/** + * @group realm-iterators + */ +class SetKeyTest extends PredisTestCase +{ + /** + * @group disconnected + * @expectedException Predis\NotSupportedException + * @expectedExceptionMessage The specified server profile does not support the `SSCAN` command. + */ + public function testThrowsExceptionOnInvalidServerProfile() + { + $client = $this->getMock('Predis\ClientInterface'); + + $client->expects($this->any()) + ->method('getProfile') + ->will($this->returnValue(ServerProfile::get('2.0'))); + + $iterator = new SetKey($client, 'key:set'); + } + + /** + * @group disconnected + */ + public function testIterationWithNoResults() + { + $client = $this->getMock('Predis\Client', array('getProfile', 'sscan')); + + $client->expects($this->any()) + ->method('getProfile') + ->will($this->returnValue(ServerProfile::get('2.8'))); + $client->expects($this->once()) + ->method('sscan') + ->with('key:set', 0, array()) + ->will($this->returnValue(array(0, array()))); + + $iterator = new SetKey($client, 'key:set'); + + $iterator->rewind(); + $this->assertFalse($iterator->valid()); + } + + /** + * @group disconnected + */ + public function testIterationOnSingleFetch() + { + $client = $this->getMock('Predis\Client', array('getProfile', 'sscan')); + + $client->expects($this->any()) + ->method('getProfile') + ->will($this->returnValue(ServerProfile::get('2.8'))); + $client->expects($this->once()) + ->method('sscan') + ->with('key:set', 0, array()) + ->will($this->returnValue(array(0, array('member:1st', 'member:2nd', 'member:3rd')))); + + $iterator = new SetKey($client, 'key:set'); + + $iterator->rewind(); + $this->assertTrue($iterator->valid()); + $this->assertSame('member:1st', $iterator->current()); + $this->assertSame(0, $iterator->key()); + + $iterator->next(); + $this->assertTrue($iterator->valid()); + $this->assertSame('member:2nd', $iterator->current()); + $this->assertSame(1, $iterator->key()); + + $iterator->next(); + $this->assertTrue($iterator->valid()); + $this->assertSame('member:3rd', $iterator->current()); + $this->assertSame(2, $iterator->key()); + + $iterator->next(); + $this->assertFalse($iterator->valid()); + } + + /** + * @group disconnected + */ + public function testIterationOnMultipleFetches() + { + $client = $this->getMock('Predis\Client', array('getProfile', 'sscan')); + + $client->expects($this->any()) + ->method('getProfile') + ->will($this->returnValue(ServerProfile::get('2.8'))); + $client->expects($this->at(1)) + ->method('sscan') + ->with('key:set', 0, array()) + ->will($this->returnValue(array(2, array('member:1st', 'member:2nd')))); + $client->expects($this->at(2)) + ->method('sscan') + ->with('key:set', 2, array()) + ->will($this->returnValue(array(0, array('member:3rd')))); + + $iterator = new SetKey($client, 'key:set'); + + $iterator->rewind(); + $this->assertTrue($iterator->valid()); + $this->assertSame('member:1st', $iterator->current()); + $this->assertSame(0, $iterator->key()); + + $iterator->next(); + $this->assertTrue($iterator->valid()); + $this->assertSame('member:2nd', $iterator->current()); + $this->assertSame(1, $iterator->key()); + + $iterator->next(); + $this->assertTrue($iterator->valid()); + $this->assertSame('member:3rd', $iterator->current()); + $this->assertSame(2, $iterator->key()); + + $iterator->next(); + $this->assertFalse($iterator->valid()); + } + + /** + * @group disconnected + */ + public function testIterationOnMultipleFetchesAndHoleInFirstFetch() + { + $client = $this->getMock('Predis\Client', array('getProfile', 'sscan')); + + $client->expects($this->any()) + ->method('getProfile') + ->will($this->returnValue(ServerProfile::get('2.8'))); + $client->expects($this->at(1)) + ->method('sscan') + ->with('key:set', 0, array()) + ->will($this->returnValue(array(4, array()))); + $client->expects($this->at(2)) + ->method('sscan') + ->with('key:set', 4, array()) + ->will($this->returnValue(array(0, array('member:1st', 'member:2nd')))); + + $iterator = new SetKey($client, 'key:set'); + + $iterator->rewind(); + $this->assertTrue($iterator->valid()); + $this->assertSame('member:1st', $iterator->current()); + $this->assertSame(0, $iterator->key()); + + $iterator->next(); + $this->assertTrue($iterator->valid()); + $this->assertSame('member:2nd', $iterator->current()); + $this->assertSame(1, $iterator->key()); + + $iterator->next(); + $this->assertFalse($iterator->valid()); + } + + /** + * @group disconnected + */ + public function testIterationOnMultipleFetchesAndHoleInMidFetch() + { + $client = $this->getMock('Predis\Client', array('getProfile', 'sscan')); + + $client->expects($this->any()) + ->method('getProfile') + ->will($this->returnValue(ServerProfile::get('2.8'))); + $client->expects($this->at(1)) + ->method('sscan') + ->with('key:set', 0, array()) + ->will($this->returnValue(array(2, array('member:1st', 'member:2nd')))); + $client->expects($this->at(2)) + ->method('sscan') + ->with('key:set', 2, array()) + ->will($this->returnValue(array(5, array()))); + $client->expects($this->at(3)) + ->method('sscan') + ->with('key:set', 5, array()) + ->will($this->returnValue(array(0, array('member:3rd')))); + + $iterator = new SetKey($client, 'key:set'); + + $iterator->rewind(); + $this->assertTrue($iterator->valid()); + $this->assertSame('member:1st', $iterator->current()); + $this->assertSame(0, $iterator->key()); + + $iterator->next(); + $this->assertTrue($iterator->valid()); + $this->assertSame('member:2nd', $iterator->current()); + $this->assertSame(1, $iterator->key()); + + $iterator->next(); + $this->assertTrue($iterator->valid()); + $this->assertSame('member:3rd', $iterator->current()); + $this->assertSame(2, $iterator->key()); + + $iterator->next(); + $this->assertFalse($iterator->valid()); + } + + /** + * @group disconnected + */ + public function testIterationWithOptionMatch() + { + $client = $this->getMock('Predis\Client', array('getProfile', 'sscan')); + + $client->expects($this->any()) + ->method('getProfile') + ->will($this->returnValue(ServerProfile::get('2.8'))); + $client->expects($this->at(1)) + ->method('sscan') + ->with('key:set', 0, array('MATCH' => 'member:*')) + ->will($this->returnValue(array(0, array('member:1st', 'member:2nd')))); + + $iterator = new SetKey($client, 'key:set', 'member:*'); + + $iterator->rewind(); + $this->assertTrue($iterator->valid()); + $this->assertSame('member:1st', $iterator->current()); + $this->assertSame(0, $iterator->key()); + + $iterator->next(); + $this->assertTrue($iterator->valid()); + $this->assertSame('member:2nd', $iterator->current()); + $this->assertSame(1, $iterator->key()); + + $iterator->next(); + $this->assertFalse($iterator->valid()); + } + + /** + * @group disconnected + */ + public function testIterationWithOptionMatchOnMultipleFetches() + { + $client = $this->getMock('Predis\Client', array('getProfile', 'sscan')); + + $client->expects($this->any()) + ->method('getProfile') + ->will($this->returnValue(ServerProfile::get('2.8'))); + $client->expects($this->at(1)) + ->method('sscan') + ->with('key:set', 0, array('MATCH' => 'member:*')) + ->will($this->returnValue(array(1, array('member:1st')))); + $client->expects($this->at(2)) + ->method('sscan') + ->with('key:set', 1, array('MATCH' => 'member:*')) + ->will($this->returnValue(array(0, array('member:2nd')))); + + $iterator = new SetKey($client, 'key:set', 'member:*'); + + $iterator->rewind(); + $this->assertTrue($iterator->valid()); + $this->assertSame('member:1st', $iterator->current()); + $this->assertSame(0, $iterator->key()); + + $iterator->next(); + $this->assertTrue($iterator->valid()); + $this->assertSame('member:2nd', $iterator->current()); + $this->assertSame(1, $iterator->key()); + + $iterator->next(); + $this->assertFalse($iterator->valid()); + } + + /** + * @group disconnected + */ + public function testIterationWithOptionCount() + { + $client = $this->getMock('Predis\Client', array('getProfile', 'sscan')); + + $client->expects($this->any()) + ->method('getProfile') + ->will($this->returnValue(ServerProfile::get('2.8'))); + $client->expects($this->at(1)) + ->method('sscan') + ->with('key:set', 0, array('COUNT' => 2)) + ->will($this->returnValue(array(0, array('member:1st', 'member:2nd')))); + + $iterator = new SetKey($client, 'key:set', null, 2); + + $iterator->rewind(); + $this->assertTrue($iterator->valid()); + $this->assertSame('member:1st', $iterator->current()); + $this->assertSame(0, $iterator->key()); + + $iterator->next(); + $this->assertTrue($iterator->valid()); + $this->assertSame('member:2nd', $iterator->current()); + $this->assertSame(1, $iterator->key()); + + $iterator->next(); + $this->assertFalse($iterator->valid()); + } + + /** + * @group disconnected + */ + public function testIterationWithOptionCountOnMultipleFetches() + { + $client = $this->getMock('Predis\Client', array('getProfile', 'sscan')); + + $client->expects($this->any()) + ->method('getProfile') + ->will($this->returnValue(ServerProfile::get('2.8'))); + $client->expects($this->at(1)) + ->method('sscan') + ->with('key:set', 0, array('COUNT' => 1)) + ->will($this->returnValue(array(1, array('member:1st')))); + $client->expects($this->at(2)) + ->method('sscan') + ->with('key:set', 1, array('COUNT' => 1)) + ->will($this->returnValue(array(0, array('member:2nd')))); + + $iterator = new SetKey($client, 'key:set', null, 1); + + $iterator->rewind(); + $this->assertTrue($iterator->valid()); + $this->assertSame('member:1st', $iterator->current()); + $this->assertSame(0, $iterator->key()); + + $iterator->next(); + $this->assertTrue($iterator->valid()); + $this->assertSame('member:2nd', $iterator->current()); + $this->assertSame(1, $iterator->key()); + + $iterator->next(); + $this->assertFalse($iterator->valid()); + } + + /** + * @group disconnected + */ + public function testIterationWithOptionsMatchAndCount() + { + $client = $this->getMock('Predis\Client', array('getProfile', 'sscan')); + + $client->expects($this->any()) + ->method('getProfile') + ->will($this->returnValue(ServerProfile::get('2.8'))); + $client->expects($this->at(1)) + ->method('sscan') + ->with('key:set', 0, array('MATCH' => 'member:*', 'COUNT' => 2)) + ->will($this->returnValue(array(0, array('member:1st', 'member:2nd')))); + + $iterator = new SetKey($client, 'key:set', 'member:*', 2); + + $iterator->rewind(); + $this->assertTrue($iterator->valid()); + $this->assertSame('member:1st', $iterator->current()); + $this->assertSame(0, $iterator->key()); + + $iterator->next(); + $this->assertTrue($iterator->valid()); + $this->assertSame('member:2nd', $iterator->current()); + $this->assertSame(1, $iterator->key()); + + $iterator->next(); + $this->assertFalse($iterator->valid()); + } + + /** + * @group disconnected + */ + public function testIterationWithOptionsMatchAndCountOnMultipleFetches() + { + $client = $this->getMock('Predis\Client', array('getProfile', 'sscan')); + + $client->expects($this->any()) + ->method('getProfile') + ->will($this->returnValue(ServerProfile::get('2.8'))); + $client->expects($this->at(1)) + ->method('sscan') + ->with('key:set', 0, array('MATCH' => 'member:*', 'COUNT' => 1)) + ->will($this->returnValue(array(1, array('member:1st')))); + $client->expects($this->at(2)) + ->method('sscan') + ->with('key:set', 1, array('MATCH' => 'member:*', 'COUNT' => 1)) + ->will($this->returnValue(array(0, array('member:2nd')))); + + $iterator = new SetKey($client, 'key:set', 'member:*', 1); + + $iterator->rewind(); + $this->assertTrue($iterator->valid()); + $this->assertSame('member:1st', $iterator->current()); + $this->assertSame(0, $iterator->key()); + + $iterator->next(); + $this->assertTrue($iterator->valid()); + $this->assertSame('member:2nd', $iterator->current()); + $this->assertSame(1, $iterator->key()); + + $iterator->next(); + $this->assertFalse($iterator->valid()); + } + + /** + * @group disconnected + */ + public function testIterationRewindable() + { + $client = $this->getMock('Predis\Client', array('getProfile', 'sscan')); + + $client->expects($this->any()) + ->method('getProfile') + ->will($this->returnValue(ServerProfile::get('2.8'))); + $client->expects($this->exactly(2)) + ->method('sscan') + ->with('key:set', 0, array()) + ->will($this->returnValue(array(0, array('member:1st', 'member:2nd')))); + + $iterator = new SetKey($client, 'key:set'); + + $iterator->rewind(); + $this->assertTrue($iterator->valid()); + $this->assertSame('member:1st', $iterator->current()); + $this->assertSame(0, $iterator->key()); + + $iterator->rewind(); + $this->assertTrue($iterator->valid()); + $this->assertSame('member:1st', $iterator->current()); + $this->assertSame(0, $iterator->key()); + + $iterator->next(); + $this->assertTrue($iterator->valid()); + $this->assertSame('member:2nd', $iterator->current()); + $this->assertSame(1, $iterator->key()); + + $iterator->next(); + $this->assertFalse($iterator->valid()); + } +} diff --git a/vendor/predis/predis/tests/Predis/Collection/Iterator/SortedSetKeyTest.php b/vendor/predis/predis/tests/Predis/Collection/Iterator/SortedSetKeyTest.php new file mode 100755 index 0000000..955a699 --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Collection/Iterator/SortedSetKeyTest.php @@ -0,0 +1,480 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Collection\Iterator; + +use PredisTestCase; +use Predis\Client; +use Predis\Profile\ServerProfile; + +/** + * @group realm-iterators + */ +class SortedSetTest extends PredisTestCase +{ + /** + * @group disconnected + * @expectedException Predis\NotSupportedException + * @expectedExceptionMessage The specified server profile does not support the `ZSCAN` command. + */ + public function testThrowsExceptionOnInvalidServerProfile() + { + $client = $this->getMock('Predis\ClientInterface'); + + $client->expects($this->any()) + ->method('getProfile') + ->will($this->returnValue(ServerProfile::get('2.0'))); + + $iterator = new SortedSetKey($client, 'key:zset'); + } + + /** + * @group disconnected + */ + public function testIterationWithNoResults() + { + $client = $this->getMock('Predis\Client', array('getProfile', 'zscan')); + + $client->expects($this->any()) + ->method('getProfile') + ->will($this->returnValue(ServerProfile::get('2.8'))); + $client->expects($this->once()) + ->method('zscan') + ->with('key:zset', 0, array()) + ->will($this->returnValue(array(0, array()))); + + $iterator = new SortedSetKey($client, 'key:zset'); + + $iterator->rewind(); + $this->assertFalse($iterator->valid()); + } + + /** + * @group disconnected + */ + public function testIterationOnSingleFetch() + { + $client = $this->getMock('Predis\Client', array('getProfile', 'zscan')); + + $client->expects($this->any()) + ->method('getProfile') + ->will($this->returnValue(ServerProfile::get('2.8'))); + $client->expects($this->once()) + ->method('zscan') + ->with('key:zset', 0, array()) + ->will($this->returnValue(array(0, array( + array('member:1st', 1.0), array('member:2nd', 2.0), array('member:3rd', 3.0), + )))); + + $iterator = new SortedSetKey($client, 'key:zset'); + + $iterator->rewind(); + $this->assertTrue($iterator->valid()); + $this->assertSame(1.0, $iterator->current()); + $this->assertSame('member:1st', $iterator->key()); + + $iterator->next(); + $this->assertTrue($iterator->valid()); + $this->assertSame(2.0, $iterator->current()); + $this->assertSame('member:2nd', $iterator->key()); + + $iterator->next(); + $this->assertTrue($iterator->valid()); + $this->assertSame(3.0, $iterator->current()); + $this->assertSame('member:3rd', $iterator->key()); + + $iterator->next(); + $this->assertFalse($iterator->valid()); + } + + /** + * @group disconnected + */ + public function testIterationOnMultipleFetches() + { + $client = $this->getMock('Predis\Client', array('getProfile', 'zscan')); + + $client->expects($this->any()) + ->method('getProfile') + ->will($this->returnValue(ServerProfile::get('2.8'))); + $client->expects($this->at(1)) + ->method('zscan') + ->with('key:zset', 0, array()) + ->will($this->returnValue(array(2, array( + array('member:1st', 1.0), array('member:2nd', 2.0), + )))); + $client->expects($this->at(2)) + ->method('zscan') + ->with('key:zset', 2, array()) + ->will($this->returnValue(array(0, array( + array('member:3rd', 3.0), + )))); + + $iterator = new SortedSetKey($client, 'key:zset'); + + $iterator->rewind(); + $this->assertTrue($iterator->valid()); + $this->assertSame(1.0, $iterator->current()); + $this->assertSame('member:1st', $iterator->key()); + + $iterator->next(); + $this->assertTrue($iterator->valid()); + $this->assertSame(2.0, $iterator->current()); + $this->assertSame('member:2nd', $iterator->key()); + + $iterator->next(); + $this->assertTrue($iterator->valid()); + $this->assertSame(3.0, $iterator->current()); + $this->assertSame('member:3rd', $iterator->key()); + + $iterator->next(); + $this->assertFalse($iterator->valid()); + } + + /** + * @group disconnected + */ + public function testIterationOnMultipleFetchesAndHoleInFirstFetch() + { + $client = $this->getMock('Predis\Client', array('getProfile', 'zscan')); + + $client->expects($this->any()) + ->method('getProfile') + ->will($this->returnValue(ServerProfile::get('2.8'))); + $client->expects($this->at(1)) + ->method('zscan') + ->with('key:zset', 0, array()) + ->will($this->returnValue(array(4, array()))); + $client->expects($this->at(2)) + ->method('zscan') + ->with('key:zset', 4, array()) + ->will($this->returnValue(array(0, array( + array('member:1st', 1.0), array('member:2nd', 2.0), + )))); + + $iterator = new SortedSetKey($client, 'key:zset'); + + $iterator->rewind(); + $this->assertTrue($iterator->valid()); + $this->assertSame(1.0, $iterator->current()); + $this->assertSame('member:1st', $iterator->key()); + + $iterator->next(); + $this->assertTrue($iterator->valid()); + $this->assertSame(2.0, $iterator->current()); + $this->assertSame('member:2nd', $iterator->key()); + + $iterator->next(); + $this->assertFalse($iterator->valid()); + } + + /** + * @group disconnected + */ + public function testIterationOnMultipleFetchesAndHoleInMidFetch() + { + $client = $this->getMock('Predis\Client', array('getProfile', 'zscan')); + + $client->expects($this->any()) + ->method('getProfile') + ->will($this->returnValue(ServerProfile::get('2.8'))); + $client->expects($this->at(1)) + ->method('zscan') + ->with('key:zset', 0, array()) + ->will($this->returnValue(array(2, array( + array('member:1st', 1.0), array('member:2nd', 2.0), + )))); + $client->expects($this->at(2)) + ->method('zscan') + ->with('key:zset', 2, array()) + ->will($this->returnValue(array(5, array()))); + $client->expects($this->at(3)) + ->method('zscan') + ->with('key:zset', 5, array()) + ->will($this->returnValue(array(0, array( + array('member:3rd', 3.0) + )))); + + $iterator = new SortedSetKey($client, 'key:zset'); + + $iterator->rewind(); + $this->assertTrue($iterator->valid()); + $this->assertSame(1.0, $iterator->current()); + $this->assertSame('member:1st', $iterator->key()); + + $iterator->next(); + $this->assertTrue($iterator->valid()); + $this->assertSame(2.0, $iterator->current()); + $this->assertSame('member:2nd', $iterator->key()); + + $iterator->next(); + $this->assertTrue($iterator->valid()); + $this->assertSame(3.0, $iterator->current()); + $this->assertSame('member:3rd', $iterator->key()); + + $iterator->next(); + $this->assertFalse($iterator->valid()); + } + + /** + * @group disconnected + */ + public function testIterationWithOptionMatch() + { + $client = $this->getMock('Predis\Client', array('getProfile', 'zscan')); + + $client->expects($this->any()) + ->method('getProfile') + ->will($this->returnValue(ServerProfile::get('2.8'))); + $client->expects($this->at(1)) + ->method('zscan') + ->with('key:zset', 0, array('MATCH' => 'member:*')) + ->will($this->returnValue(array(2, array( + array('member:1st', 1.0), array('member:2nd', 2.0), + )))); + + $iterator = new SortedSetKey($client, 'key:zset', 'member:*'); + + $iterator->rewind(); + $this->assertTrue($iterator->valid()); + $this->assertSame(1.0, $iterator->current()); + $this->assertSame('member:1st', $iterator->key()); + + $iterator->next(); + $this->assertTrue($iterator->valid()); + $this->assertSame(2.0, $iterator->current()); + $this->assertSame('member:2nd', $iterator->key()); + + $iterator->next(); + $this->assertFalse($iterator->valid()); + } + + /** + * @group disconnected + */ + public function testIterationWithOptionMatchOnMultipleFetches() + { + $client = $this->getMock('Predis\Client', array('getProfile', 'zscan')); + + $client->expects($this->any()) + ->method('getProfile') + ->will($this->returnValue(ServerProfile::get('2.8'))); + $client->expects($this->at(1)) + ->method('zscan') + ->with('key:zset', 0, array('MATCH' => 'member:*')) + ->will($this->returnValue(array(1, array( + array('member:1st', 1.0), + )))); + $client->expects($this->at(2)) + ->method('zscan') + ->with('key:zset', 1, array('MATCH' => 'member:*')) + ->will($this->returnValue(array(0, array( + array('member:2nd', 2.0), + )))); + + $iterator = new SortedSetKey($client, 'key:zset', 'member:*'); + + $iterator->rewind(); + $this->assertTrue($iterator->valid()); + $this->assertSame(1.0, $iterator->current()); + $this->assertSame('member:1st', $iterator->key()); + + $iterator->next(); + $this->assertTrue($iterator->valid()); + $this->assertSame(2.0, $iterator->current()); + $this->assertSame('member:2nd', $iterator->key()); + + $iterator->next(); + $this->assertFalse($iterator->valid()); + } + + /** + * @group disconnected + */ + public function testIterationWithOptionCount() + { + $client = $this->getMock('Predis\Client', array('getProfile', 'zscan')); + + $client->expects($this->any()) + ->method('getProfile') + ->will($this->returnValue(ServerProfile::get('2.8'))); + $client->expects($this->at(1)) + ->method('zscan') + ->with('key:zset', 0, array('COUNT' => 2)) + ->will($this->returnValue(array(0, array( + array('member:1st', 1.0), array('member:2nd', 2.0), + )))); + + $iterator = new SortedSetKey($client, 'key:zset', null, 2); + + $iterator->rewind(); + $this->assertTrue($iterator->valid()); + $this->assertSame(1.0, $iterator->current()); + $this->assertSame('member:1st', $iterator->key()); + + $iterator->next(); + $this->assertTrue($iterator->valid()); + $this->assertSame(2.0, $iterator->current()); + $this->assertSame('member:2nd', $iterator->key()); + + $iterator->next(); + $this->assertFalse($iterator->valid()); + } + + /** + * @group disconnected + */ + public function testIterationWithOptionCountOnMultipleFetches() + { + $client = $this->getMock('Predis\Client', array('getProfile', 'zscan')); + + $client->expects($this->any()) + ->method('getProfile') + ->will($this->returnValue(ServerProfile::get('2.8'))); + $client->expects($this->at(1)) + ->method('zscan') + ->with('key:zset', 0, array('COUNT' => 1)) + ->will($this->returnValue(array(1, array( + array('member:1st', 1.0), + )))); + $client->expects($this->at(2)) + ->method('zscan') + ->with('key:zset', 1, array('COUNT' => 1)) + ->will($this->returnValue(array(0, array( + array('member:2nd', 2.0), + )))); + + $iterator = new SortedSetKey($client, 'key:zset', null, 1); + + $iterator->rewind(); + $this->assertTrue($iterator->valid()); + $this->assertSame(1.0, $iterator->current()); + $this->assertSame('member:1st', $iterator->key()); + + $iterator->next(); + $this->assertTrue($iterator->valid()); + $this->assertSame(2.0, $iterator->current()); + $this->assertSame('member:2nd', $iterator->key()); + + $iterator->next(); + $this->assertFalse($iterator->valid()); + } + + /** + * @group disconnected + */ + public function testIterationWithOptionsMatchAndCount() + { + $client = $this->getMock('Predis\Client', array('getProfile', 'zscan')); + + $client->expects($this->any()) + ->method('getProfile') + ->will($this->returnValue(ServerProfile::get('2.8'))); + $client->expects($this->at(1)) + ->method('zscan') + ->with('key:zset', 0, array('MATCH' => 'member:*', 'COUNT' => 2)) + ->will($this->returnValue(array(0, array( + array('member:1st', 1.0), array('member:2nd', 2.0), + )))); + + $iterator = new SortedSetKey($client, 'key:zset', 'member:*', 2); + + $iterator->rewind(); + $this->assertTrue($iterator->valid()); + $this->assertSame(1.0, $iterator->current()); + $this->assertSame('member:1st', $iterator->key()); + + $iterator->next(); + $this->assertTrue($iterator->valid()); + $this->assertSame(2.0, $iterator->current()); + $this->assertSame('member:2nd', $iterator->key()); + + $iterator->next(); + $this->assertFalse($iterator->valid()); + } + + /** + * @group disconnected + */ + public function testIterationWithOptionsMatchAndCountOnMultipleFetches() + { + $client = $this->getMock('Predis\Client', array('getProfile', 'zscan')); + + $client->expects($this->any()) + ->method('getProfile') + ->will($this->returnValue(ServerProfile::get('2.8'))); + $client->expects($this->at(1)) + ->method('zscan') + ->with('key:zset', 0, array('MATCH' => 'member:*', 'COUNT' => 1)) + ->will($this->returnValue(array(1, array( + array('member:1st', 1.0), + )))); + $client->expects($this->at(2)) + ->method('zscan') + ->with('key:zset', 1, array('MATCH' => 'member:*', 'COUNT' => 1)) + ->will($this->returnValue(array(0, array( + array('member:2nd', 2.0), + )))); + + $iterator = new SortedSetKey($client, 'key:zset', 'member:*', 1); + + $iterator->rewind(); + $this->assertTrue($iterator->valid()); + $this->assertSame(1.0, $iterator->current()); + $this->assertSame('member:1st', $iterator->key()); + + $iterator->next(); + $this->assertTrue($iterator->valid()); + $this->assertSame(2.0, $iterator->current()); + $this->assertSame('member:2nd', $iterator->key()); + + $iterator->next(); + $this->assertFalse($iterator->valid()); + } + + /** + * @group disconnected + */ + public function testIterationRewindable() + { + $client = $this->getMock('Predis\Client', array('getProfile', 'zscan')); + + $client->expects($this->any()) + ->method('getProfile') + ->will($this->returnValue(ServerProfile::get('2.8'))); + $client->expects($this->exactly(2)) + ->method('zscan') + ->with('key:zset', 0, array()) + ->will($this->returnValue(array(0, array( + array('member:1st', 1.0), array('member:2nd', 2.0), + )))); + + $iterator = new SortedSetKey($client, 'key:zset'); + + $iterator->rewind(); + $this->assertTrue($iterator->valid()); + $this->assertSame(1.0, $iterator->current()); + $this->assertSame('member:1st', $iterator->key()); + + $iterator->rewind(); + $this->assertTrue($iterator->valid()); + $this->assertSame(1.0, $iterator->current()); + $this->assertSame('member:1st', $iterator->key()); + + $iterator->next(); + $this->assertTrue($iterator->valid()); + $this->assertSame(2.0, $iterator->current()); + $this->assertSame('member:2nd', $iterator->key()); + + $iterator->next(); + $this->assertFalse($iterator->valid()); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/CommandTest.php b/vendor/predis/predis/tests/Predis/Command/CommandTest.php new file mode 100755 index 0000000..627aada --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/CommandTest.php @@ -0,0 +1,180 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +use PredisTestCase; + +/** + * + */ +class CommandTest extends PredisTestCase +{ + /** + * @group disconnected + */ + public function testImplementsCorrectInterface() + { + $command = $this->getMockForAbstractClass('Predis\Command\AbstractCommand'); + + $this->assertInstanceOf('Predis\Command\CommandInterface', $command); + } + + /** + * @group disconnected + */ + public function testGetEmptyArguments() + { + $command = $this->getMockForAbstractClass('Predis\Command\AbstractCommand'); + + $this->assertEmpty($command->getArguments()); + } + + /** + * @group disconnected + */ + public function testSetRawArguments() + { + $arguments = array('1st', '2nd', '3rd'); + + $command = $this->getMockForAbstractClass('Predis\Command\AbstractCommand'); + $command->setRawArguments($arguments); + + $this->assertEquals($arguments, $command->getArguments()); + } + + /** + * @group disconnected + * + * @todo Since AbstractCommand::filterArguments is protected we cannot set an expectation + * for it when AbstractCommand::setArguments() is invoked. I wonder how we can do that. + */ + public function testSetArguments() + { + $arguments = array('1st', '2nd', '3rd'); + + $command = $this->getMockForAbstractClass('Predis\Command\AbstractCommand'); + $command->setArguments($arguments); + + $this->assertEquals($arguments, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testGetArgumentAtIndex() + { + $arguments = array('1st', '2nd', '3rd'); + + $command = $this->getMockForAbstractClass('Predis\Command\AbstractCommand'); + $command->setArguments($arguments); + + $this->assertEquals($arguments[0], $command->getArgument(0)); + $this->assertEquals($arguments[2], $command->getArgument(2)); + $this->assertNull($command->getArgument(10)); + } + + /** + * @group disconnected + */ + public function testParseResponse() + { + $response = 'response-buffer'; + $command = $this->getMockForAbstractClass('Predis\Command\AbstractCommand'); + + $this->assertEquals($response, $command->parseResponse($response)); + } + + /** + * @group disconnected + */ + public function testSetAndGetHash() + { + $hash = "key-hash"; + + $command = $this->getMockForAbstractClass('Predis\Command\AbstractCommand'); + $command->setRawArguments(array('key')); + + $this->assertNull($command->getHash()); + + $command->setHash($hash); + $this->assertSame($hash, $command->getHash()); + + $command->setArguments(array('key')); + $this->assertNull($command->getHash()); + + $command->setHash($hash); + $command->setRawArguments(array('key')); + $this->assertNull($command->getHash()); + } + /** + * @group disconnected + */ + public function testToString() + { + $expected = 'SET key value'; + $arguments = array('key', 'value'); + + $command = $this->getMockForAbstractClass('Predis\Command\AbstractCommand'); + $command->expects($this->once())->method('getId')->will($this->returnValue('SET')); + + $command->setRawArguments($arguments); + + $this->assertEquals($expected, (string) $command); + } + + /** + * @group disconnected + */ + public function testToStringWithLongArguments() + { + $expected = 'SET key abcdefghijklmnopqrstuvwxyz012345[...]'; + $arguments = array('key', 'abcdefghijklmnopqrstuvwxyz0123456789'); + + $command = $this->getMockForAbstractClass('Predis\Command\AbstractCommand'); + $command->expects($this->once())->method('getId')->will($this->returnValue('SET')); + + $command->setRawArguments($arguments); + + $this->assertEquals($expected, (string) $command); + } + + /** + * @group disconnected + */ + public function testNormalizeArguments() + { + $arguments = array('arg1', 'arg2', 'arg3', 'arg4'); + + $this->assertSame($arguments, AbstractCommand::normalizeArguments($arguments)); + $this->assertSame($arguments, AbstractCommand::normalizeArguments(array($arguments))); + + $arguments = array(array(), array()); + $this->assertSame($arguments, AbstractCommand::normalizeArguments($arguments)); + + $arguments = array(new \stdClass()); + $this->assertSame($arguments, AbstractCommand::normalizeArguments($arguments)); + } + + /** + * @group disconnected + */ + public function testNormalizeVariadic() + { + $arguments = array('key', 'value1', 'value2', 'value3'); + + $this->assertSame($arguments, AbstractCommand::normalizeVariadic($arguments)); + $this->assertSame($arguments, AbstractCommand::normalizeVariadic(array('key', array('value1', 'value2', 'value3')))); + + $arguments = array(new \stdClass()); + $this->assertSame($arguments, AbstractCommand::normalizeVariadic($arguments)); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/ConnectionAuthTest.php b/vendor/predis/predis/tests/Predis/Command/ConnectionAuthTest.php new file mode 100755 index 0000000..6248a32 --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/ConnectionAuthTest.php @@ -0,0 +1,62 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @group commands + * @group realm-connection + */ +class ConnectionAuthTest extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return 'Predis\Command\ConnectionAuth'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return 'AUTH'; + } + + /** + * @group disconnected + */ + public function testFilterArguments() + { + $arguments = array('password'); + $expected = array('password'); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse() + { + $raw = null; + $expected = null; + + $command = $this->getCommand(); + + $this->assertSame($expected, $command->parseResponse($raw)); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/ConnectionEchoTest.php b/vendor/predis/predis/tests/Predis/Command/ConnectionEchoTest.php new file mode 100755 index 0000000..3d506c7 --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/ConnectionEchoTest.php @@ -0,0 +1,74 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @group commands + * @group realm-connection + */ +class ConnectionEchoTest extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return 'Predis\Command\ConnectionEcho'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return 'ECHO'; + } + + /** + * @group disconnected + */ + public function testFilterArguments() + { + $arguments = array('message'); + $expected = array('message'); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse() + { + $raw = 'message'; + $expected = 'message'; + + $command = $this->getCommand(); + + $this->assertSame($expected, $command->parseResponse($raw)); + } + + /** + * @group connected + */ + public function testAlwaysReturnsThePassedMessage() + { + $redis = $this->getClient(); + + $message = 'Can you hear me?'; + + $this->assertSame($message, $redis->echo($message)); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/ConnectionPingTest.php b/vendor/predis/predis/tests/Predis/Command/ConnectionPingTest.php new file mode 100755 index 0000000..725337d --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/ConnectionPingTest.php @@ -0,0 +1,69 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @group commands + * @group realm-connection + */ +class ConnectionPingTest extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return 'Predis\Command\ConnectionPing'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return 'PING'; + } + + /** + * @group disconnected + */ + public function testFilterArguments() + { + $arguments = array(); + $expected = array(); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse() + { + $command = $this->getCommand(); + + $this->assertTrue($command->parseResponse('PONG')); + } + + /** + * @group connected + */ + public function testAlwaysReturnsTrue() + { + $redis = $this->getClient(); + + $this->assertTrue($redis->ping()); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/ConnectionQuitTest.php b/vendor/predis/predis/tests/Predis/Command/ConnectionQuitTest.php new file mode 100755 index 0000000..1be47a5 --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/ConnectionQuitTest.php @@ -0,0 +1,70 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @group commands + * @group realm-connection + */ +class ConnectionQuitTest extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return 'Predis\Command\ConnectionQuit'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return 'QUIT'; + } + + /** + * @group disconnected + */ + public function testFilterArguments() + { + $arguments = array(); + $expected = array(); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse() + { + $command = $this->getCommand(); + + $this->assertTrue($command->parseResponse(true)); + } + + /** + * @group connected + */ + public function testReturnsTrueWhenClosingConnection() + { + $redis = $this->getClient(); + $command = $this->getCommand(); + + $this->assertTrue($redis->executeCommand($command)); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/ConnectionSelectTest.php b/vendor/predis/predis/tests/Predis/Command/ConnectionSelectTest.php new file mode 100755 index 0000000..6e253fa --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/ConnectionSelectTest.php @@ -0,0 +1,84 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @group commands + * @group realm-connection + */ +class ConnectionSelectTest extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return 'Predis\Command\ConnectionSelect'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return 'SELECT'; + } + + /** + * @group disconnected + */ + public function testFilterArguments() + { + $arguments = array(10); + $expected = array(10); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse() + { + $command = $this->getCommand(); + + $this->assertTrue($command->parseResponse(true)); + } + + /** + * @group connected + */ + public function testCanSelectDifferentDatabase() + { + $redis = $this->getClient(); + + $redis->set('foo', 'bar'); + + $this->assertTrue($redis->select(REDIS_SERVER_DBNUM - 1)); + $this->assertFalse($redis->exists('foo')); + } + + /** + * @group connected + * @expectedException Predis\ServerException + * @expectedExceptionMessage ERR invalid DB index + */ + public function testThrowsExceptionOnUnexpectedDatabase() + { + $redis = $this->getClient(); + + $redis->select(100000000); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/HashDeleteTest.php b/vendor/predis/predis/tests/Predis/Command/HashDeleteTest.php new file mode 100755 index 0000000..e904f0a --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/HashDeleteTest.php @@ -0,0 +1,123 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @group commands + * @group realm-hash + */ +class HashDeleteTest extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return 'Predis\Command\HashDelete'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return 'HDEL'; + } + + /** + * @group disconnected + */ + public function testFilterArguments() + { + $arguments = array('key', 'field1', 'field2', 'field3'); + $expected = array('key', 'field1', 'field2', 'field3'); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testFilterArgumentsFieldsAsSingleArray() + { + $arguments = array('key', array('field1', 'field2', 'field3')); + $expected = array('key', 'field1', 'field2', 'field3'); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse() + { + $this->assertSame(1, $this->getCommand()->parseResponse(1)); + } + + /** + * @group disconnected + */ + public function testPrefixKeys() + { + $arguments = array('key', 'field1', 'field2', 'field3'); + $expected = array('prefix:key', 'field1', 'field2', 'field3'); + + $command = $this->getCommandWithArgumentsArray($arguments); + $command->prefixKeys('prefix:'); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testPrefixKeysIgnoredOnEmptyArguments() + { + $command = $this->getCommand(); + $command->prefixKeys('prefix:'); + + $this->assertSame(array(), $command->getArguments()); + } + + /** + * @group connected + */ + public function testDeletesSpecifiedFieldsFromHash() + { + $redis = $this->getClient(); + + $redis->hmset('metavars', 'foo', 'bar', 'hoge', 'piyo', 'lol', 'wut'); + + $this->assertSame(2, $redis->hdel('metavars', 'foo', 'hoge')); + $this->assertSame(0, $redis->hdel('metavars', 'foofoo')); + $this->assertSame(0, $redis->hdel('unknown', 'foo')); + } + + /** + * @group connected + * @expectedException Predis\ServerException + * @expectedExceptionMessage Operation against a key holding the wrong kind of value + */ + public function testThrowsExceptionOnWrongType() + { + $redis = $this->getClient(); + + $redis->set('foo', 'bar'); + $redis->hdel('foo', 'bar'); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/HashExistsTest.php b/vendor/predis/predis/tests/Predis/Command/HashExistsTest.php new file mode 100755 index 0000000..a7975a6 --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/HashExistsTest.php @@ -0,0 +1,112 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @group commands + * @group realm-hash + */ +class HashExistsTest extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return 'Predis\Command\HashExists'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return 'HEXISTS'; + } + + /** + * @group disconnected + */ + public function testFilterArguments() + { + $arguments = array('key', 'field'); + $expected = array('key', 'field'); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse() + { + $command = $this->getCommand(); + + $this->assertFalse($command->parseResponse(0)); + $this->assertTrue($command->parseResponse(1)); + } + + /** + * @group disconnected + */ + public function testPrefixKeys() + { + $arguments = array('key', 'field'); + $expected = array('prefix:key', 'field'); + + $command = $this->getCommandWithArgumentsArray($arguments); + $command->prefixKeys('prefix:'); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testPrefixKeysIgnoredOnEmptyArguments() + { + $command = $this->getCommand(); + $command->prefixKeys('prefix:'); + + $this->assertSame(array(), $command->getArguments()); + } + + /** + * @group connected + */ + public function testReturnsExistenceOfSpecifiedField() + { + $redis = $this->getClient(); + + $redis->hmset('metavars', 'foo', 'bar', 'hoge', 'piyo'); + + $this->assertTrue($redis->hexists('metavars', 'foo')); + $this->assertFalse($redis->hexists('metavars', 'lol')); + $this->assertFalse($redis->hexists('unknown', 'foo')); + } + + /** + * @group connected + * @expectedException Predis\ServerException + * @expectedExceptionMessage Operation against a key holding the wrong kind of value + */ + public function testThrowsExceptionOnWrongType() + { + $redis = $this->getClient(); + + $redis->set('foo', 'bar'); + $redis->hexists('foo', 'bar'); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/HashGetAllTest.php b/vendor/predis/predis/tests/Predis/Command/HashGetAllTest.php new file mode 100755 index 0000000..b24b52b --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/HashGetAllTest.php @@ -0,0 +1,113 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @group commands + * @group realm-hash + */ +class HashGetAllTest extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return 'Predis\Command\HashGetAll'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return 'HGETALL'; + } + + /** + * @group disconnected + */ + public function testFilterArguments() + { + $arguments = array('key'); + $expected = array('key'); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse() + { + $raw = array('foo', 'bar', 'hoge', 'piyo', 'lol', 'wut'); + $expected = array('foo' => 'bar', 'hoge' => 'piyo', 'lol' => 'wut'); + + $command = $this->getCommand(); + + $this->assertSame($expected, $command->parseResponse($raw)); + } + + /** + * @group disconnected + */ + public function testPrefixKeys() + { + $arguments = array('key'); + $expected = array('prefix:key'); + + $command = $this->getCommandWithArgumentsArray($arguments); + $command->prefixKeys('prefix:'); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testPrefixKeysIgnoredOnEmptyArguments() + { + $command = $this->getCommand(); + $command->prefixKeys('prefix:'); + + $this->assertSame(array(), $command->getArguments()); + } + + /** + * @group connected + */ + public function testReturnsAllTheFieldsAndTheirValues() + { + $redis = $this->getClient(); + + $redis->hmset('metavars', 'foo', 'bar', 'hoge', 'piyo', 'lol', 'wut'); + + $this->assertSame(array('foo' => 'bar', 'hoge' => 'piyo', 'lol' => 'wut'), $redis->hgetall('metavars')); + $this->assertSame(array(), $redis->hgetall('unknown')); + } + + /** + * @group connected + * @expectedException Predis\ServerException + * @expectedExceptionMessage Operation against a key holding the wrong kind of value + */ + public function testThrowsExceptionOnWrongType() + { + $redis = $this->getClient(); + + $redis->set('foo', 'bar'); + $redis->hgetall('foo'); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/HashGetMultipleTest.php b/vendor/predis/predis/tests/Predis/Command/HashGetMultipleTest.php new file mode 100755 index 0000000..d013bdc --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/HashGetMultipleTest.php @@ -0,0 +1,129 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @group commands + * @group realm-hash + */ +class HashGetMultipleTest extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return 'Predis\Command\HashGetMultiple'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return 'HMGET'; + } + + /** + * @group disconnected + */ + public function testFilterArguments() + { + $arguments = array('key', 'field1', 'field2', 'field3'); + $expected = array('key', 'field1', 'field2', 'field3'); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testFilterArgumentsFieldsAsSingleArray() + { + $arguments = array('key', array('field1', 'field2', 'field3')); + $expected = array('key', 'field1', 'field2', 'field3'); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse() + { + $raw = array('bar', 'piyo', 'wut'); + $expected = array('bar', 'piyo', 'wut'); + + $command = $this->getCommand(); + + $this->assertSame($expected, $command->parseResponse($raw)); + } + + /** + * @group disconnected + */ + public function testPrefixKeys() + { + $arguments = array('key', 'field1', 'field2', 'field3'); + $expected = array('prefix:key', 'field1', 'field2', 'field3'); + + $command = $this->getCommandWithArgumentsArray($arguments); + $command->prefixKeys('prefix:'); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testPrefixKeysIgnoredOnEmptyArguments() + { + $command = $this->getCommand(); + $command->prefixKeys('prefix:'); + + $this->assertSame(array(), $command->getArguments()); + } + + /** + * @group connected + */ + public function testReturnsValuesOfSpecifiedFields() + { + $redis = $this->getClient(); + + $redis->hmset('metavars', 'foo', 'bar', 'hoge', 'piyo', 'lol', 'wut'); + + $this->assertSame(array('bar', 'piyo', null), $redis->hmget('metavars', 'foo', 'hoge', 'unknown')); + $this->assertSame(array('bar', 'bar'), $redis->hmget('metavars', 'foo', 'foo')); + $this->assertSame(array(null, null), $redis->hmget('metavars', 'unknown', 'unknown')); + $this->assertSame(array(null, null), $redis->hmget('unknown', 'foo', 'hoge')); + } + + /** + * @group connected + * @expectedException Predis\ServerException + * @expectedExceptionMessage Operation against a key holding the wrong kind of value + */ + public function testThrowsExceptionOnWrongType() + { + $redis = $this->getClient(); + + $redis->set('foo', 'bar'); + $redis->hmget('foo', 'bar'); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/HashGetTest.php b/vendor/predis/predis/tests/Predis/Command/HashGetTest.php new file mode 100755 index 0000000..2368447 --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/HashGetTest.php @@ -0,0 +1,109 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @group commands + * @group realm-hash + */ +class HashGetTest extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return 'Predis\Command\HashGet'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return 'HGET'; + } + + /** + * @group disconnected + */ + public function testFilterArguments() + { + $arguments = array('key', 'field'); + $expected = array('key', 'field'); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse() + { + $this->assertSame('value', $this->getCommand()->parseResponse('value')); + } + + /** + * @group disconnected + */ + public function testPrefixKeys() + { + $arguments = array('key', 'field'); + $expected = array('prefix:key', 'field'); + + $command = $this->getCommandWithArgumentsArray($arguments); + $command->prefixKeys('prefix:'); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testPrefixKeysIgnoredOnEmptyArguments() + { + $command = $this->getCommand(); + $command->prefixKeys('prefix:'); + + $this->assertSame(array(), $command->getArguments()); + } + + /** + * @group connected + */ + public function testReturnsValueOfSpecifiedField() + { + $redis = $this->getClient(); + + $redis->hmset('metavars', 'foo', 'bar', 'hoge', 'piyo'); + + $this->assertSame('bar', $redis->hget('metavars', 'foo')); + $this->assertNull($redis->hget('metavars', 'lol')); + $this->assertNull($redis->hget('unknown', 'foo')); + } + + /** + * @group connected + * @expectedException Predis\ServerException + * @expectedExceptionMessage Operation against a key holding the wrong kind of value + */ + public function testThrowsExceptionOnWrongType() + { + $redis = $this->getClient(); + + $redis->set('foo', 'bar'); + $redis->hget('foo', 'bar'); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/HashIncrementByFloatTest.php b/vendor/predis/predis/tests/Predis/Command/HashIncrementByFloatTest.php new file mode 100755 index 0000000..8e78c97 --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/HashIncrementByFloatTest.php @@ -0,0 +1,134 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @group commands + * @group realm-hash + */ +class HashIncrementByFloatTest extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return 'Predis\Command\HashIncrementByFloat'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return 'HINCRBYFLOAT'; + } + + /** + * @group disconnected + */ + public function testFilterArguments() + { + $arguments = array('key', 'field', 10.5); + $expected = array('key', 'field', 10.5); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse() + { + $this->assertSame(10.5, $this->getCommand()->parseResponse(10.5)); + } + + /** + * @group disconnected + */ + public function testPrefixKeys() + { + $arguments = array('key', 'field', 10.5); + $expected = array('prefix:key', 'field', 10.5); + + $command = $this->getCommandWithArgumentsArray($arguments); + $command->prefixKeys('prefix:'); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testPrefixKeysIgnoredOnEmptyArguments() + { + $command = $this->getCommand(); + $command->prefixKeys('prefix:'); + + $this->assertSame(array(), $command->getArguments()); + } + + /** + * @group connected + */ + public function testIncrementsValueOfFieldByFloat() + { + $redis = $this->getClient(); + + $this->assertSame('10.5', $redis->hincrbyfloat('metavars', 'foo', 10.5)); + $this->assertSame('10.001', $redis->hincrbyfloat('metavars', 'hoge', 10.001)); + $this->assertSame('11', $redis->hincrbyfloat('metavars', 'hoge', 0.999)); + $this->assertSame(array('foo' => '10.5', 'hoge' => '11'), $redis->hgetall('metavars')); + } + + /** + * @group connected + */ + public function testDecrementsValueOfFieldByFloat() + { + $redis = $this->getClient(); + + $this->assertSame('-10.5', $redis->hincrbyfloat('metavars', 'foo', -10.5)); + $this->assertSame('-10.001', $redis->hincrbyfloat('metavars', 'hoge', -10.001)); + $this->assertSame('-11', $redis->hincrbyfloat('metavars', 'hoge', -0.999)); + $this->assertSame(array('foo' => '-10.5', 'hoge' => '-11'), $redis->hgetall('metavars')); + } + + /** + * @group connected + * @expectedException Predis\ServerException + * @expectedExceptionMessage ERR hash value is not a valid float + */ + public function testThrowsExceptionOnStringField() + { + $redis = $this->getClient(); + + $redis->hset('metavars', 'foo', 'bar'); + $redis->hincrbyfloat('metavars', 'foo', 10.0); + } + + /** + * @group connected + * @expectedException Predis\ServerException + * @expectedExceptionMessage Operation against a key holding the wrong kind of value + */ + public function testThrowsExceptionOnWrongType() + { + $redis = $this->getClient(); + + $redis->set('foo', 'bar'); + $redis->hincrbyfloat('foo', 'bar', 10.5); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/HashIncrementByTest.php b/vendor/predis/predis/tests/Predis/Command/HashIncrementByTest.php new file mode 100755 index 0000000..79d63be --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/HashIncrementByTest.php @@ -0,0 +1,134 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @group commands + * @group realm-hash + */ +class HashIncrementByTest extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return 'Predis\Command\HashIncrementBy'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return 'HINCRBY'; + } + + /** + * @group disconnected + */ + public function testFilterArguments() + { + $arguments = array('key', 'field', 10); + $expected = array('key', 'field', 10); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse() + { + $this->assertSame(10, $this->getCommand()->parseResponse(10)); + } + + /** + * @group disconnected + */ + public function testPrefixKeys() + { + $arguments = array('key', 'field', 10); + $expected = array('prefix:key', 'field', 10); + + $command = $this->getCommandWithArgumentsArray($arguments); + $command->prefixKeys('prefix:'); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testPrefixKeysIgnoredOnEmptyArguments() + { + $command = $this->getCommand(); + $command->prefixKeys('prefix:'); + + $this->assertSame(array(), $command->getArguments()); + } + + /** + * @group connected + */ + public function testIncrementsValueOfFieldByInteger() + { + $redis = $this->getClient(); + + $this->assertSame(10, $redis->hincrby('metavars', 'foo', 10)); + $this->assertSame(5, $redis->hincrby('metavars', 'hoge', 5)); + $this->assertSame(15, $redis->hincrby('metavars', 'hoge', 10)); + $this->assertSame(array('foo' => '10', 'hoge' => '15'), $redis->hgetall('metavars')); + } + + /** + * @group connected + */ + public function testDecrementsValueOfFieldByInteger() + { + $redis = $this->getClient(); + + $this->assertSame(-10, $redis->hincrby('metavars', 'foo', -10)); + $this->assertSame(-5, $redis->hincrby('metavars', 'hoge', -5)); + $this->assertSame(-15, $redis->hincrby('metavars', 'hoge', -10)); + $this->assertSame(array('foo' => '-10', 'hoge' => '-15'), $redis->hgetall('metavars')); + } + + /** + * @group connected + * @expectedException Predis\ServerException + * @expectedExceptionMessage ERR hash value is not an integer + */ + public function testThrowsExceptionOnStringField() + { + $redis = $this->getClient(); + + $redis->hset('metavars', 'foo', 'bar'); + $redis->hincrby('metavars', 'foo', 10); + } + + /** + * @group connected + * @expectedException Predis\ServerException + * @expectedExceptionMessage Operation against a key holding the wrong kind of value + */ + public function testThrowsExceptionOnWrongType() + { + $redis = $this->getClient(); + + $redis->set('foo', 'bar'); + $redis->hincrby('foo', 'bar', 10); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/HashKeysTest.php b/vendor/predis/predis/tests/Predis/Command/HashKeysTest.php new file mode 100755 index 0000000..36e6d94 --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/HashKeysTest.php @@ -0,0 +1,113 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @group commands + * @group realm-hash + */ +class HashKeysTest extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return 'Predis\Command\HashKeys'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return 'HKEYS'; + } + + /** + * @group disconnected + */ + public function testFilterArguments() + { + $arguments = array('key'); + $expected = array('key'); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse() + { + $raw = array('foo', 'hoge', 'lol'); + $expected = array('foo', 'hoge', 'lol'); + + $command = $this->getCommand(); + + $this->assertSame($expected, $command->parseResponse($raw)); + } + + /** + * @group disconnected + */ + public function testPrefixKeys() + { + $arguments = array('key'); + $expected = array('prefix:key'); + + $command = $this->getCommandWithArgumentsArray($arguments); + $command->prefixKeys('prefix:'); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testPrefixKeysIgnoredOnEmptyArguments() + { + $command = $this->getCommand(); + $command->prefixKeys('prefix:'); + + $this->assertSame(array(), $command->getArguments()); + } + + /** + * @group connected + */ + public function testReturnsKeysOfHash() + { + $redis = $this->getClient(); + + $redis->hmset('metavars', 'foo', 'bar', 'hoge', 'piyo', 'lol', 'wut'); + + $this->assertSame(array('foo', 'hoge', 'lol'), $redis->hkeys('metavars')); + $this->assertSame(array(), $redis->hkeys('unknown')); + } + + /** + * @group connected + * @expectedException Predis\ServerException + * @expectedExceptionMessage Operation against a key holding the wrong kind of value + */ + public function testThrowsExceptionOnWrongType() + { + $redis = $this->getClient(); + + $redis->set('foo', 'bar'); + $redis->hkeys('foo'); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/HashLengthTest.php b/vendor/predis/predis/tests/Predis/Command/HashLengthTest.php new file mode 100755 index 0000000..1599cd9 --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/HashLengthTest.php @@ -0,0 +1,108 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @group commands + * @group realm-hash + */ +class HashLengthTest extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return 'Predis\Command\HashLength'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return 'HLEN'; + } + + /** + * @group disconnected + */ + public function testFilterArguments() + { + $arguments = array('key'); + $expected = array('key'); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse() + { + $this->assertSame(1, $this->getCommand()->parseResponse(1)); + } + + /** + * @group disconnected + */ + public function testPrefixKeys() + { + $arguments = array('key'); + $expected = array('prefix:key'); + + $command = $this->getCommandWithArgumentsArray($arguments); + $command->prefixKeys('prefix:'); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testPrefixKeysIgnoredOnEmptyArguments() + { + $command = $this->getCommand(); + $command->prefixKeys('prefix:'); + + $this->assertSame(array(), $command->getArguments()); + } + + /** + * @group connected + */ + public function testReturnsLengthOfHash() + { + $redis = $this->getClient(); + + $redis->hmset('metavars', 'foo', 'bar', 'hoge', 'piyo', 'lol', 'wut'); + + $this->assertSame(3, $redis->hlen('metavars')); + $this->assertSame(0, $redis->hlen('unknown')); + } + + /** + * @group connected + * @expectedException Predis\ServerException + * @expectedExceptionMessage Operation against a key holding the wrong kind of value + */ + public function testThrowsExceptionOnWrongType() + { + $redis = $this->getClient(); + + $redis->set('foo', 'bar'); + $redis->hlen('foo'); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/HashScanTest.php b/vendor/predis/predis/tests/Predis/Command/HashScanTest.php new file mode 100755 index 0000000..2288603 --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/HashScanTest.php @@ -0,0 +1,161 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @group commands + * @group realm-hash + */ +class HashScanTest extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return 'Predis\Command\HashScan'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return 'HSCAN'; + } + + /** + * @group disconnected + */ + public function testFilterArguments() + { + $arguments = array('key', 0, 'MATCH', 'field:*', 'COUNT', 10); + $expected = array('key', 0, 'MATCH', 'field:*', 'COUNT', 10); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testFilterArgumentsBasicUsage() + { + $arguments = array('key', 0); + $expected = array('key', 0); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testFilterArgumentsWithOptionsArray() + { + $arguments = array('key', 0, array('match' => 'field:*', 'count' => 10)); + $expected = array('key', 0, 'MATCH', 'field:*', 'COUNT', 10); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse() + { + $raw = array('3', array('field:1', '1', 'field:2', '2', 'field:3', '3')); + $expected = array(3, array('field:1' => '1', 'field:2' => '2', 'field:3' => '3')); + + $command = $this->getCommand(); + + $this->assertSame($expected, $command->parseResponse($raw)); + } + + /** + * @group disconnected + */ + public function testPrefixKeys() + { + $arguments = array('key', '0', 'MATCH', 'field:*', 'COUNT', 10); + $expected = array('prefix:key', '0', 'MATCH', 'field:*', 'COUNT', 10); + + $command = $this->getCommandWithArgumentsArray($arguments); + $command->prefixKeys('prefix:'); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testPrefixKeysIgnoredOnEmptyArguments() + { + $command = $this->getCommand(); + $command->prefixKeys('prefix:'); + + $this->assertSame(array(), $command->getArguments()); + } + + /** + * @group connected + */ + public function testScanWithoutMatch() + { + $expectedFields = array('field:one', 'field:two', 'field:three', 'field:four'); + $expectedValues = array('one', 'two', 'three', 'four'); + + $redis = $this->getClient(); + $redis->hmset('key', array_combine($expectedFields, $expectedValues)); + + $response = $redis->hscan('key', 0); + + $this->assertSame(0, $response[0]); + $this->assertSame($expectedFields, array_keys($response[1])); + $this->assertSame($expectedValues, array_values($response[1])); + } + + /** + * @group connected + */ + public function testScanWithMatchingMembers() + { + $redis = $this->getClient(); + $redis->hmset('key', array('field:one' => 'one', 'field:two' => 'two', 'field:three' => 'three', 'field:four' => 'four')); + + $response = $redis->hscan('key', 0, 'MATCH', 'field:t*'); + + $this->assertSame(array('field:two', 'field:three'), array_keys($response[1])); + $this->assertSame(array('two', 'three'), array_values($response[1])); + } + + /** + * @group connected + */ + public function testScanWithNoMatchingMembers() + { + $redis = $this->getClient(); + $redis->hmset('key', array('field:one' => 'one', 'field:two' => 'two', 'field:three' => 'three', 'field:four' => 'four')); + + $response = $redis->hscan('key', 0, 'MATCH', 'nofield:*'); + + $this->assertSame(0, $response[0]); + $this->assertEmpty($response[1]); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/HashSetMultipleTest.php b/vendor/predis/predis/tests/Predis/Command/HashSetMultipleTest.php new file mode 100755 index 0000000..9a7379b --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/HashSetMultipleTest.php @@ -0,0 +1,135 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @group commands + * @group realm-hash + */ +class HashSetMultipleTest extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return 'Predis\Command\HashSetMultiple'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return 'HMSET'; + } + + /** + * @group disconnected + */ + public function testFilterArguments() + { + $arguments = array('key', 'field1', 'value1', 'field2', 'value2'); + $expected = array('key', 'field1', 'value1', 'field2', 'value2'); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testFilterArgumentsFieldsValuesAsSingleArray() + { + $arguments = array('key', array('field1' => 'value1', 'field2' => 'value2')); + $expected = array('key', 'field1', 'value1', 'field2', 'value2'); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse() + { + $this->assertTrue($this->getCommand()->parseResponse(true)); + } + + /** + * @group disconnected + */ + public function testPrefixKeys() + { + $arguments = array('key', 'field1', 'value1', 'field2', 'value2'); + $expected = array('prefix:key', 'field1', 'value1', 'field2', 'value2'); + + $command = $this->getCommandWithArgumentsArray($arguments); + $command->prefixKeys('prefix:'); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testPrefixKeysIgnoredOnEmptyArguments() + { + $command = $this->getCommand(); + $command->prefixKeys('prefix:'); + + $this->assertSame(array(), $command->getArguments()); + } + + /** + * @group connected + */ + public function testSetsSpecifiedFieldsOfHash() + { + $redis = $this->getClient(); + + $this->assertTrue($redis->hmset('metavars', 'foo', 'bar', 'hoge', 'piyo')); + $this->assertSame(array('foo' => 'bar', 'hoge' => 'piyo'), $redis->hgetall('metavars')); + + $this->assertTrue($redis->hmset('metavars', 'foo', 'barbar', 'lol', 'wut')); + $this->assertSame(array('foo' => 'barbar', 'hoge' => 'piyo', 'lol' => 'wut'), $redis->hgetall('metavars')); + } + + /** + * @group connected + */ + public function testSetsTheSpecifiedFie() + { + $redis = $this->getClient(); + + $redis->hmset('metavars', 'foo', 'bar', 'hoge', 'piyo', 'lol', 'wut'); + + $this->assertSame(array('foo' => 'bar', 'hoge' => 'piyo', 'lol' => 'wut'), $redis->hgetall('metavars')); + } + + /** + * @group connected + * @expectedException Predis\ServerException + * @expectedExceptionMessage Operation against a key holding the wrong kind of value + */ + public function testThrowsExceptionOnWrongType() + { + $redis = $this->getClient(); + + $redis->set('metavars', 'bar'); + $redis->hmset('metavars', 'foo', 'bar'); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/HashSetPreserveTest.php b/vendor/predis/predis/tests/Predis/Command/HashSetPreserveTest.php new file mode 100755 index 0000000..c8367bc --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/HashSetPreserveTest.php @@ -0,0 +1,112 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @group commands + * @group realm-hash + */ +class HashSetPreserveTest extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return 'Predis\Command\HashSetPreserve'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return 'HSETNX'; + } + + /** + * @group disconnected + */ + public function testFilterArguments() + { + $arguments = array('key', 'field', 'value'); + $expected = array('key', 'field', 'value'); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse() + { + $command = $this->getCommand(); + + $this->assertTrue($command->parseResponse(1)); + $this->assertFalse($command->parseResponse(0)); + } + + /** + * @group disconnected + */ + public function testPrefixKeys() + { + $arguments = array('key', 'field', 'value'); + $expected = array('prefix:key', 'field', 'value'); + + $command = $this->getCommandWithArgumentsArray($arguments); + $command->prefixKeys('prefix:'); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testPrefixKeysIgnoredOnEmptyArguments() + { + $command = $this->getCommand(); + $command->prefixKeys('prefix:'); + + $this->assertSame(array(), $command->getArguments()); + } + + /** + * @group connected + */ + public function testSetsNewFieldsAndPreserversExistingOnes() + { + $redis = $this->getClient(); + + $this->assertTrue($redis->hsetnx('metavars', 'foo', 'bar')); + $this->assertTrue($redis->hsetnx('metavars', 'hoge', 'piyo')); + $this->assertFalse($redis->hsetnx('metavars', 'foo', 'barbar')); + + $this->assertSame(array('bar', 'piyo'), $redis->hmget('metavars', 'foo', 'hoge')); + } + + /** + * @group connected + * @expectedException Predis\ServerException + * @expectedExceptionMessage Operation against a key holding the wrong kind of value + */ + public function testThrowsExceptionOnWrongType() + { + $redis = $this->getClient(); + + $redis->set('metavars', 'foo'); + $redis->hsetnx('metavars', 'foo', 'bar'); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/HashSetTest.php b/vendor/predis/predis/tests/Predis/Command/HashSetTest.php new file mode 100755 index 0000000..e517786 --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/HashSetTest.php @@ -0,0 +1,111 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @group commands + * @group realm-hash + */ +class HashSetTest extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return 'Predis\Command\HashSet'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return 'HSET'; + } + + /** + * @group disconnected + */ + public function testFilterArguments() + { + $arguments = array('key', 'field', 'value'); + $expected = array('key', 'field', 'value'); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse() + { + $command = $this->getCommand(); + + $this->assertTrue($command->parseResponse(1)); + $this->assertFalse($command->parseResponse(0)); + } + + /** + * @group disconnected + */ + public function testPrefixKeys() + { + $arguments = array('key', 'field', 'value'); + $expected = array('prefix:key', 'field', 'value'); + + $command = $this->getCommandWithArgumentsArray($arguments); + $command->prefixKeys('prefix:'); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testPrefixKeysIgnoredOnEmptyArguments() + { + $command = $this->getCommand(); + $command->prefixKeys('prefix:'); + + $this->assertSame(array(), $command->getArguments()); + } + + /** + * @group connected + */ + public function testSetsValueOfSpecifiedField() + { + $redis = $this->getClient(); + + $this->assertTrue($redis->hset('metavars', 'foo', 'bar')); + $this->assertTrue($redis->hset('metavars', 'hoge', 'piyo')); + + $this->assertSame(array('bar', 'piyo'), $redis->hmget('metavars', 'foo', 'hoge')); + } + + /** + * @group connected + * @expectedException Predis\ServerException + * @expectedExceptionMessage Operation against a key holding the wrong kind of value + */ + public function testThrowsExceptionOnWrongType() + { + $redis = $this->getClient(); + + $redis->set('metavars', 'foo'); + $redis->hset('metavars', 'foo', 'bar'); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/HashValuesTest.php b/vendor/predis/predis/tests/Predis/Command/HashValuesTest.php new file mode 100755 index 0000000..7bae8ca --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/HashValuesTest.php @@ -0,0 +1,113 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @group commands + * @group realm-hash + */ +class HashValuesTest extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return 'Predis\Command\HashValues'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return 'HVALS'; + } + + /** + * @group disconnected + */ + public function testFilterArguments() + { + $arguments = array('key'); + $expected = array('key'); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse() + { + $raw = array('foo', 'hoge', 'lol'); + $expected = array('foo', 'hoge', 'lol'); + + $command = $this->getCommand(); + + $this->assertSame($expected, $command->parseResponse($raw)); + } + + /** + * @group disconnected + */ + public function testPrefixKeys() + { + $arguments = array('key'); + $expected = array('prefix:key'); + + $command = $this->getCommandWithArgumentsArray($arguments); + $command->prefixKeys('prefix:'); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testPrefixKeysIgnoredOnEmptyArguments() + { + $command = $this->getCommand(); + $command->prefixKeys('prefix:'); + + $this->assertSame(array(), $command->getArguments()); + } + + /** + * @group connected + */ + public function testReturnsValuesOfHash() + { + $redis = $this->getClient(); + + $redis->hmset('metavars', 'foo', 'bar', 'hoge', 'piyo', 'lol', 'wut'); + + $this->assertSame(array('bar', 'piyo', 'wut'), $redis->hvals('metavars')); + $this->assertSame(array(), $redis->hvals('unknown')); + } + + /** + * @group connected + * @expectedException Predis\ServerException + * @expectedExceptionMessage Operation against a key holding the wrong kind of value + */ + public function testThrowsExceptionOnWrongType() + { + $redis = $this->getClient(); + + $redis->set('foo', 'bar'); + $redis->hvals('foo'); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/KeyDeleteTest.php b/vendor/predis/predis/tests/Predis/Command/KeyDeleteTest.php new file mode 100755 index 0000000..2e9bd92 --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/KeyDeleteTest.php @@ -0,0 +1,117 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @group commands + * @group realm-key + */ +class KeyDeleteTest extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return 'Predis\Command\KeyDelete'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return 'DEL'; + } + + /** + * @group disconnected + */ + public function testFilterArguments() + { + $arguments = array('key1', 'key2', 'key3'); + $expected = array('key1', 'key2', 'key3'); + + $command = $this->getCommand(); + $command->setArguments($arguments); + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testFilterArgumentsAsSingleArray() + { + $arguments = array(array('key1', 'key2', 'key3')); + $expected = array('key1', 'key2', 'key3'); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse() + { + $command = $this->getCommand(); + + $this->assertSame(10, $command->parseResponse(10)); + } + + /** + * @group disconnected + */ + public function testPrefixKeys() + { + $arguments = array('key1', 'key2', 'key3'); + $expected = array('prefix:key1', 'prefix:key2', 'prefix:key3'); + + $command = $this->getCommandWithArgumentsArray($arguments); + $command->prefixKeys('prefix:'); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testPrefixKeysIgnoredOnEmptyArguments() + { + $command = $this->getCommand(); + $command->prefixKeys('prefix:'); + + $this->assertSame(array(), $command->getArguments()); + } + + /** + * @group connected + */ + public function testReturnsNumberOfDeletedKeys() + { + $redis = $this->getClient(); + + $this->assertSame(0, $redis->del('foo')); + + $redis->set('foo', 'bar'); + $this->assertSame(1, $redis->del('foo')); + + $redis->set('foo', 'bar'); + $this->assertSame(1, $redis->del('foo', 'hoge')); + + $redis->set('foo', 'bar'); + $redis->set('hoge', 'piyo'); + $this->assertSame(2, $redis->del('foo', 'hoge')); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/KeyDumpTest.php b/vendor/predis/predis/tests/Predis/Command/KeyDumpTest.php new file mode 100755 index 0000000..c9adcf2 --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/KeyDumpTest.php @@ -0,0 +1,87 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @group commands + * @group realm-key + */ +class KeyDumpTest extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return 'Predis\Command\KeyDump'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return 'DUMP'; + } + + /** + * @group disconnected + */ + public function testFilterArguments() + { + $arguments = array('key'); + $expected = array('key'); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse() + { + $raw = "\x00\xC0\n\x06\x00\xF8r?\xC5\xFB\xFB_("; + $expected = "\x00\xC0\n\x06\x00\xF8r?\xC5\xFB\xFB_("; + + $command = $this->getCommand(); + + $this->assertSame($expected, $command->parseResponse($raw)); + } + + /** + * @group disconnected + */ + public function testPrefixKeys() + { + $arguments = array('key'); + $expected = array('prefix:key'); + + $command = $this->getCommandWithArgumentsArray($arguments); + $command->prefixKeys('prefix:'); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testPrefixKeysIgnoredOnEmptyArguments() + { + $command = $this->getCommand(); + $command->prefixKeys('prefix:'); + + $this->assertSame(array(), $command->getArguments()); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/KeyExistsTest.php b/vendor/predis/predis/tests/Predis/Command/KeyExistsTest.php new file mode 100755 index 0000000..eedf054 --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/KeyExistsTest.php @@ -0,0 +1,106 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @group commands + * @group realm-key + */ +class KeyExistsTest extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return 'Predis\Command\KeyExists'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return 'EXISTS'; + } + + /** + * @group disconnected + */ + public function testFilterArguments() + { + $arguments = array('key'); + $expected = array('key'); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse() + { + $command = $this->getCommand(); + + $this->assertTrue($command->parseResponse(1)); + $this->assertFalse($command->parseResponse(0)); + } + + /** + * @group disconnected + */ + public function testPrefixKeys() + { + $arguments = array('key'); + $expected = array('prefix:key'); + + $command = $this->getCommandWithArgumentsArray($arguments); + $command->prefixKeys('prefix:'); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testPrefixKeysIgnoredOnEmptyArguments() + { + $command = $this->getCommand(); + $command->prefixKeys('prefix:'); + + $this->assertSame(array(), $command->getArguments()); + } + + /** + * @group connected + */ + public function testReturnsTrueIfKeyExists() + { + $redis = $this->getClient(); + + $redis->set('foo', 'bar'); + $this->assertTrue($redis->exists('foo')); + } + + /** + * @group connected + */ + public function testReturnsFalseIfKeyDoesNotExist() + { + $redis = $this->getClient(); + + $this->assertFalse($redis->exists('foo')); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/KeyExpireAtTest.php b/vendor/predis/predis/tests/Predis/Command/KeyExpireAtTest.php new file mode 100755 index 0000000..9208b0e --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/KeyExpireAtTest.php @@ -0,0 +1,129 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @group commands + * @group realm-key + */ +class KeyExpireAtTest extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return 'Predis\Command\KeyExpireAt'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return 'EXPIREAT'; + } + + /** + * @group disconnected + */ + public function testFilterArguments() + { + $arguments = array('key', 'ttl'); + $expected = array('key', 'ttl'); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse() + { + $command = $this->getCommand(); + + $this->assertTrue($command->parseResponse(1)); + $this->assertFalse($command->parseResponse(0)); + } + + /** + * @group disconnected + */ + public function testPrefixKeys() + { + $arguments = array('key', 'value'); + $expected = array('prefix:key', 'value'); + + $command = $this->getCommandWithArgumentsArray($arguments); + $command->prefixKeys('prefix:'); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testPrefixKeysIgnoredOnEmptyArguments() + { + $command = $this->getCommand(); + $command->prefixKeys('prefix:'); + + $this->assertSame(array(), $command->getArguments()); + } + + /** + * @group connected + */ + public function testReturnsFalseOnNonExistingKeys() + { + $redis = $this->getClient(); + + $this->assertFalse($redis->expireat('foo', 2)); + } + + /** + * @medium + * @group connected + * @group slow + */ + public function testCanExpireKeys() + { + $redis = $this->getClient(); + + $now = time(); + $redis->set('foo', 'bar'); + + $this->assertTrue($redis->expireat('foo', $now + 1)); + $this->assertLessThanOrEqual(1, $redis->ttl('foo')); + + $this->sleep(2); + + $this->assertFalse($redis->exists('foo')); + } + + /** + * @group connected + */ + public function testDeletesKeysOnPastUnixTime() + { + $redis = $this->getClient(); + + $now = time(); + $redis->set('foo', 'bar'); + + $this->assertTrue($redis->expireat('foo', $now - 100)); + $this->assertFalse($redis->exists('foo')); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/KeyExpireTest.php b/vendor/predis/predis/tests/Predis/Command/KeyExpireTest.php new file mode 100755 index 0000000..71e9fdd --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/KeyExpireTest.php @@ -0,0 +1,143 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @group commands + * @group realm-key + */ +class KeyExpireTest extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return 'Predis\Command\KeyExpire'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return 'EXPIRE'; + } + + /** + * @group disconnected + */ + public function testFilterArguments() + { + $arguments = array('key', 'ttl'); + $expected = array('key', 'ttl'); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse() + { + $command = $this->getCommand(); + + $this->assertTrue($command->parseResponse(1)); + $this->assertFalse($command->parseResponse(0)); + } + + /** + * @group disconnected + */ + public function testPrefixKeys() + { + $arguments = array('key', 'value'); + $expected = array('prefix:key', 'value'); + + $command = $this->getCommandWithArgumentsArray($arguments); + $command->prefixKeys('prefix:'); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testPrefixKeysIgnoredOnEmptyArguments() + { + $command = $this->getCommand(); + $command->prefixKeys('prefix:'); + + $this->assertSame(array(), $command->getArguments()); + } + + /** + * @group connected + */ + public function testReturnsFalseOnNonExistingKeys() + { + $redis = $this->getClient(); + + $this->assertFalse($redis->expire('foo', 2)); + } + + /** + * @medium + * @group connected + * @group slow + */ + public function testCanExpireKeys() + { + $redis = $this->getClient(); + + $redis->set('foo', 'bar'); + + $this->assertTrue($redis->expire('foo', 1)); + $this->assertSame(1, $redis->ttl('foo')); + + $this->sleep(2.0); + + $this->assertFalse($redis->exists('foo')); + } + + /** + * @medium + * @group connected + * @group slow + */ + public function testConsistencyWithTTL() + { + $redis = $this->getClient(); + + $redis->set('foo', 'bar'); + + $this->assertTrue($redis->expire('foo', 10)); + $this->sleep(1.5); + $this->assertLessThan(10, $redis->ttl('foo')); + } + + /** + * @group connected + */ + public function testDeletesKeysOnNegativeTTL() + { + $redis = $this->getClient(); + + $redis->set('foo', 'bar'); + + $this->assertTrue($redis->expire('foo', -10)); + $this->assertFalse($redis->exists('foo')); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/KeyKeysTest.php b/vendor/predis/predis/tests/Predis/Command/KeyKeysTest.php new file mode 100755 index 0000000..ec37d99 --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/KeyKeysTest.php @@ -0,0 +1,103 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @group commands + * @group realm-key + */ +class KeyKeysTest extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return 'Predis\Command\KeyKeys'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return 'KEYS'; + } + + /** + * @group disconnected + */ + public function testFilterArguments() + { + $arguments = array('pattern:*'); + $expected = array('pattern:*'); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse() + { + $raw = array('key1', 'key2', 'key3'); + $parsed = array('key1', 'key2', 'key3'); + + $this->assertSame($parsed, $this->getCommand()->parseResponse($raw)); + } + + /** + * @group disconnected + */ + public function testPrefixKeys() + { + $arguments = array('pattern'); + $expected = array('prefix:pattern'); + + $command = $this->getCommandWithArgumentsArray($arguments); + $command->prefixKeys('prefix:'); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testPrefixKeysIgnoredOnEmptyArguments() + { + $command = $this->getCommand(); + $command->prefixKeys('prefix:'); + + $this->assertSame(array(), $command->getArguments()); + } + + /** + * @group connected + */ + public function testReturnsArrayOfMatchingKeys() + { + $keys = array('aaa' => 1, 'aba' => 2, 'aca' => 3); + $keysNS = array('metavar:foo' => 'bar', 'metavar:hoge' => 'piyo'); + $keysAll = array_merge($keys, $keysNS); + + $redis = $this->getClient(); + $redis->mset($keysAll); + + $this->assertSame(array(), $redis->keys('nomatch:*')); + $this->assertSameValues(array_keys($keysNS), $redis->keys('metavar:*')); + $this->assertSameValues(array_keys($keysAll), $redis->keys('*')); + $this->assertSameValues(array_keys($keys), $redis->keys('a?a')); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/KeyKeysV12xTest.php b/vendor/predis/predis/tests/Predis/Command/KeyKeysV12xTest.php new file mode 100755 index 0000000..9313adf --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/KeyKeysV12xTest.php @@ -0,0 +1,89 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * We only perform disconnected tests for this commands because + * it is too old (Redis v1.2) and expects a different response + * format. + * + * @group commands + * @group realm-key + */ +class KeyKeysV12xTest extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return 'Predis\Command\KeyKeysV12x'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return 'KEYS'; + } + + /** + * @group disconnected + */ + public function testFilterArguments() + { + $arguments = array('pattern:*'); + $expected = array('pattern:*'); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse() + { + $raw = 'key1 key2 key3'; + $parsed = array('key1', 'key2', 'key3'); + + $this->assertSame($parsed, $this->getCommand()->parseResponse($raw)); + } + + /** + * @group disconnected + */ + public function testPrefixKeys() + { + $arguments = array('pattern'); + $expected = array('prefix:pattern'); + + $command = $this->getCommandWithArgumentsArray($arguments); + $command->prefixKeys('prefix:'); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testPrefixKeysIgnoredOnEmptyArguments() + { + $command = $this->getCommand(); + $command->prefixKeys('prefix:'); + + $this->assertSame(array(), $command->getArguments()); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/KeyMoveTest.php b/vendor/predis/predis/tests/Predis/Command/KeyMoveTest.php new file mode 100755 index 0000000..8aa8ad4 --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/KeyMoveTest.php @@ -0,0 +1,119 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @group commands + * @group realm-key + */ +class KeyMoveTest extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return 'Predis\Command\KeyMove'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return 'MOVE'; + } + + /** + * @group disconnected + */ + public function testFilterArguments() + { + $arguments = array('key', 10); + $expected = array('key', 10); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse() + { + $command = $this->getCommand(); + + $this->assertTrue($command->parseResponse(1)); + $this->assertFalse($command->parseResponse(0)); + } + + /** + * @group disconnected + */ + public function testPrefixKeys() + { + $arguments = array('key', 'db'); + $expected = array('prefix:key', 'db'); + + $command = $this->getCommandWithArgumentsArray($arguments); + $command->prefixKeys('prefix:'); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testPrefixKeysIgnoredOnEmptyArguments() + { + $command = $this->getCommand(); + $command->prefixKeys('prefix:'); + + $this->assertSame(array(), $command->getArguments()); + } + + /** + * @group connected + * @todo This test fails if REDIS_SERVER_DBNUM is 0. + */ + public function testMovesKeysToDifferentDatabases() + { + $db = REDIS_SERVER_DBNUM - 1; + $redis = $this->getClient(); + + $redis->set('foo', 'bar'); + + $this->assertTrue($redis->move('foo', $db)); + $this->assertFalse($redis->exists('foo')); + + $redis->select($db); + $this->assertTrue($redis->exists('foo')); + + $redis->del('foo'); + } + + /** + * @group connected + * @expectedException Predis\ServerException + * @expectedExceptionMessage ERR index out of range + */ + public function testThrowsExceptionOnInvalidDatabases() + { + $redis = $this->getClient(); + + $redis->set('foo', 'bar'); + + $redis->move('foo', 100000000); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/KeyPersistTest.php b/vendor/predis/predis/tests/Predis/Command/KeyPersistTest.php new file mode 100755 index 0000000..495c953 --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/KeyPersistTest.php @@ -0,0 +1,121 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @group commands + * @group realm-key + */ +class KeyPersistTest extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return 'Predis\Command\KeyPersist'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return 'PERSIST'; + } + + /** + * @group disconnected + */ + public function testFilterArguments() + { + $arguments = array('key'); + $expected = array('key'); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse() + { + $command = $this->getCommand(); + + $this->assertTrue($command->parseResponse(1)); + $this->assertFalse($command->parseResponse(0)); + } + + /** + * @group disconnected + */ + public function testPrefixKeys() + { + $arguments = array('key'); + $expected = array('prefix:key'); + + $command = $this->getCommandWithArgumentsArray($arguments); + $command->prefixKeys('prefix:'); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testPrefixKeysIgnoredOnEmptyArguments() + { + $command = $this->getCommand(); + $command->prefixKeys('prefix:'); + + $this->assertSame(array(), $command->getArguments()); + } + + /** + * @group connected + */ + public function testRemovesExpireFromKey() + { + $redis = $this->getClient(); + + $redis->set('foo', 'bar'); + $redis->expire('foo', 10); + + $this->assertTrue($redis->persist('foo')); + $this->assertSame(-1, $redis->ttl('foo')); + } + + /** + * @group connected + */ + public function testReturnsFalseOnNonExpiringKeys() + { + $redis = $this->getClient(); + + $redis->set('foo', 'bar'); + + $this->assertFalse($redis->persist('foo')); + } + + /** + * @group connected + */ + public function testReturnsFalseOnNonExistentKeys() + { + $redis = $this->getClient(); + + $this->assertFalse($redis->persist('foo')); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/KeyPreciseExpireAtTest.php b/vendor/predis/predis/tests/Predis/Command/KeyPreciseExpireAtTest.php new file mode 100755 index 0000000..ed0c300 --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/KeyPreciseExpireAtTest.php @@ -0,0 +1,119 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @group commands + * @group realm-key + */ +class KeyPreciseExpireAtTest extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return 'Predis\Command\KeyPreciseExpireAt'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return 'PEXPIREAT'; + } + + /** + * @group disconnected + */ + public function testFilterArguments() + { + $arguments = array('key', 100); + $expected = array('key', 100); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse() + { + $command = $this->getCommand(); + + $this->assertTrue($command->parseResponse(1)); + $this->assertFalse($command->parseResponse(0)); + } + + /** + * @group disconnected + */ + public function testPrefixKeys() + { + $arguments = array('key', 'value'); + $expected = array('prefix:key', 'value'); + + $command = $this->getCommandWithArgumentsArray($arguments); + $command->prefixKeys('prefix:'); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testPrefixKeysIgnoredOnEmptyArguments() + { + $command = $this->getCommand(); + $command->prefixKeys('prefix:'); + + $this->assertSame(array(), $command->getArguments()); + } + + /** + * @medium + * @group connected + * @group slow + */ + public function testCanExpireKeys() + { + $ttl = 1.5; + $redis = $this->getClient(); + + $redis->set('foo', 'bar'); + + $this->assertTrue($redis->pexpireat('foo', time() + $ttl * 1000)); + $this->assertLessThan($ttl * 1000, $redis->pttl('foo')); + + $this->sleep($ttl + 0.5); + + $this->assertFalse($redis->exists('foo')); + } + + /** + * @group connected + */ + public function testDeletesKeysOnPastUnixTime() + { + $redis = $this->getClient(); + + $now = time(); + $redis->set('foo', 'bar'); + + $this->assertTrue($redis->expireat('foo', time() - 100000)); + $this->assertFalse($redis->exists('foo')); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/KeyPreciseExpireTest.php b/vendor/predis/predis/tests/Predis/Command/KeyPreciseExpireTest.php new file mode 100755 index 0000000..7fd12ab --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/KeyPreciseExpireTest.php @@ -0,0 +1,144 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @group commands + * @group realm-key + */ +class KeyPreciseExpireTest extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return 'Predis\Command\KeyPreciseExpire'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return 'PEXPIRE'; + } + + /** + * @group disconnected + */ + public function testFilterArguments() + { + $arguments = array('key', 100); + $expected = array('key', 100); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse() + { + $command = $this->getCommand(); + + $this->assertTrue($command->parseResponse(1)); + $this->assertFalse($command->parseResponse(0)); + } + + /** + * @group disconnected + */ + public function testPrefixKeys() + { + $arguments = array('key', 'value'); + $expected = array('prefix:key', 'value'); + + $command = $this->getCommandWithArgumentsArray($arguments); + $command->prefixKeys('prefix:'); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testPrefixKeysIgnoredOnEmptyArguments() + { + $command = $this->getCommand(); + $command->prefixKeys('prefix:'); + + $this->assertSame(array(), $command->getArguments()); + } + + /** + * @group connected + */ + public function testReturnsFalseOnNonExistingKeys() + { + $redis = $this->getClient(); + + $this->assertFalse($redis->pexpire('foo', 20000)); + } + + /** + * @medium + * @group connected + * @group slow + */ + public function testCanExpireKeys() + { + $ttl = 1 * 1000; + $redis = $this->getClient(); + + $redis->set('foo', 'bar'); + + $this->assertTrue($redis->pexpire('foo', $ttl)); + + $this->sleep(1.2); + $this->assertFalse($redis->exists('foo')); + } + + /** + * @group connected + * @group slow + */ + public function testConsistencyWithTTL() + { + $ttl = 1 * 1000; + $redis = $this->getClient(); + + $redis->set('foo', 'bar'); + + $this->assertTrue($redis->pexpire('foo', $ttl)); + + $this->sleep(0.5); + $this->assertLessThanOrEqual($ttl, $redis->pttl('foo')); + $this->assertGreaterThan($ttl - 800, $redis->pttl('foo')); + } + + /** + * @group connected + */ + public function testDeletesKeysOnNegativeTTL() + { + $redis = $this->getClient(); + + $redis->set('foo', 'bar'); + + $this->assertTrue($redis->pexpire('foo', -10000)); + $this->assertFalse($redis->exists('foo')); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/KeyPreciseTimeToLiveTest.php b/vendor/predis/predis/tests/Predis/Command/KeyPreciseTimeToLiveTest.php new file mode 100755 index 0000000..1cc3945 --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/KeyPreciseTimeToLiveTest.php @@ -0,0 +1,120 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @group commands + * @group realm-key + */ +class KeyPreciseTimeToLiveTest extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return 'Predis\Command\KeyPreciseTimeToLive'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return 'PTTL'; + } + + /** + * @group disconnected + */ + public function testFilterArguments() + { + $arguments = array('key', 10); + $expected = array('key', 10); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse() + { + $command = $this->getCommand(); + + $this->assertSame(100, $command->parseResponse(100)); + } + + /** + * @group disconnected + */ + public function testPrefixKeys() + { + $arguments = array('key', 10); + $expected = array('prefix:key', 10); + + $command = $this->getCommandWithArgumentsArray($arguments); + $command->prefixKeys('prefix:'); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testPrefixKeysIgnoredOnEmptyArguments() + { + $command = $this->getCommand(); + $command->prefixKeys('prefix:'); + + $this->assertSame(array(), $command->getArguments()); + } + + /** + * @group connected + */ + public function testReturnsTTL() + { + $redis = $this->getClient(); + + $redis->set('foo', 'bar'); + $redis->expire('foo', 10); + + $this->assertLessThanOrEqual(10000, $redis->pttl('foo')); + } + + /** + * @group connected + */ + public function testReturnsLessThanZeroOnNonExpiringKeys() + { + $redis = $this->getClient(); + + $redis->set('foo', 'bar'); + $this->assertSame(-1, $redis->pttl('foo')); + } + + /** + * @group connected + * @todo PTTL changed in Redis >= 2.8 to return -2 on non existing keys, we + * should handle this case with a better solution than the current one. + */ + public function testReturnsLessThanZeroOnNonExistingKeys() + { + $redis = $this->getClient(); + + $this->assertLessThanOrEqual(-1, $redis->pttl('foo')); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/KeyRandomTest.php b/vendor/predis/predis/tests/Predis/Command/KeyRandomTest.php new file mode 100755 index 0000000..5a2dd88 --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/KeyRandomTest.php @@ -0,0 +1,85 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @group commands + * @group realm-key + */ +class KeyRandomTest extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return 'Predis\Command\KeyRandom'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return 'RANDOMKEY'; + } + + /** + * @group disconnected + */ + public function testFilterArguments() + { + $arguments = array(); + $expected = array(); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse() + { + $raw = 'key'; + $expected = 'key'; + + $command = $this->getCommand(); + + $this->assertSame($expected, $command->parseResponse($raw)); + } + + /** + * @group connected + */ + public function testReturnsFalseOnNonExpiringKeys() + { + $keys = array('key:1' => 1, 'key:2' => 2, 'key:3' => 3); + + $redis = $this->getClient(); + $redis->mset($keys); + + $this->assertContains($redis->randomkey(), array_keys($keys)); + } + + /** + * @group connected + */ + public function testReturnsNullOnEmptyDatabase() + { + $redis = $this->getClient(); + + $this->assertNull($redis->randomkey()); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/KeyRenamePreserveTest.php b/vendor/predis/predis/tests/Predis/Command/KeyRenamePreserveTest.php new file mode 100755 index 0000000..9a549c8 --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/KeyRenamePreserveTest.php @@ -0,0 +1,109 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @group commands + * @group realm-key + */ +class KeyRenamePreserveTest extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return 'Predis\Command\KeyRenamePreserve'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return 'RENAMENX'; + } + + /** + * @group disconnected + */ + public function testFilterArguments() + { + $arguments = array('key', 'newkey'); + $expected = array('key', 'newkey'); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse() + { + $this->assertTrue($this->getCommand()->parseResponse(1)); + $this->assertFalse($this->getCommand()->parseResponse(0)); + } + + /** + * @group disconnected + */ + public function testPrefixKeys() + { + $arguments = array('key', 'newkey'); + $expected = array('prefix:key', 'prefix:newkey'); + + $command = $this->getCommandWithArgumentsArray($arguments); + $command->prefixKeys('prefix:'); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testPrefixKeysIgnoredOnEmptyArguments() + { + $command = $this->getCommand(); + $command->prefixKeys('prefix:'); + + $this->assertSame(array(), $command->getArguments()); + } + + /** + * @group connected + */ + public function testRenamesKeys() + { + $redis = $this->getClient(); + + $redis->set('foo', 'bar'); + + $this->assertTrue($redis->renamenx('foo', 'foofoo')); + $this->assertFalse($redis->exists('foo')); + $this->assertTrue($redis->exists('foofoo')); + } + + /** + * @group connected + * @expectedException Predis\ServerException + * @expectedExceptionMessage ERR no such key + */ + public function testReturnsFalseOnNonExistingKeys() + { + $redis = $this->getClient(); + + $this->assertFalse($redis->renamenx('foo', 'foobar')); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/KeyRenameTest.php b/vendor/predis/predis/tests/Predis/Command/KeyRenameTest.php new file mode 100755 index 0000000..5d8e59a --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/KeyRenameTest.php @@ -0,0 +1,108 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @group commands + * @group realm-key + */ +class KeyRenameTest extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return 'Predis\Command\KeyRename'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return 'RENAME'; + } + + /** + * @group disconnected + */ + public function testFilterArguments() + { + $arguments = array('key', 'newkey'); + $expected = array('key', 'newkey'); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse() + { + $this->assertTrue($this->getCommand()->parseResponse(true)); + } + + /** + * @group disconnected + */ + public function testPrefixKeys() + { + $arguments = array('key', 'newkey'); + $expected = array('prefix:key', 'prefix:newkey'); + + $command = $this->getCommandWithArgumentsArray($arguments); + $command->prefixKeys('prefix:'); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testPrefixKeysIgnoredOnEmptyArguments() + { + $command = $this->getCommand(); + $command->prefixKeys('prefix:'); + + $this->assertSame(array(), $command->getArguments()); + } + + /** + * @group connected + */ + public function testRenamesKeys() + { + $redis = $this->getClient(); + + $redis->set('foo', 'bar'); + + $this->assertTrue($redis->rename('foo', 'foofoo')); + $this->assertFalse($redis->exists('foo')); + $this->assertTrue($redis->exists('foofoo')); + } + + /** + * @group connected + * @expectedException Predis\ServerException + * @expectedExceptionMessage ERR no such key + */ + public function testThrowsExceptionOnNonExistingKeys() + { + $redis = $this->getClient(); + + $redis->rename('foo', 'foobar'); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/KeyRestoreTest.php b/vendor/predis/predis/tests/Predis/Command/KeyRestoreTest.php new file mode 100755 index 0000000..95b2d3d --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/KeyRestoreTest.php @@ -0,0 +1,82 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @group commands + * @group realm-key + */ +class KeyRestoreTest extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return 'Predis\Command\KeyRestore'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return 'RESTORE'; + } + + /** + * @group disconnected + */ + public function testFilterArguments() + { + $arguments = array('key', 0, "\x00\xC0\n\x06\x00\xF8r?\xC5\xFB\xFB_("); + $expected = array('key', 0, "\x00\xC0\n\x06\x00\xF8r?\xC5\xFB\xFB_("); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse() + { + $this->assertTrue($this->getCommand()->parseResponse(true)); + } + + /** + * @group disconnected + */ + public function testPrefixKeys() + { + $arguments = array('key', 0, "\x00\xC0\n\x06\x00\xF8r?\xC5\xFB\xFB_("); + $expected = array('prefix:key', 0, "\x00\xC0\n\x06\x00\xF8r?\xC5\xFB\xFB_("); + + $command = $this->getCommandWithArgumentsArray($arguments); + $command->prefixKeys('prefix:'); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testPrefixKeysIgnoredOnEmptyArguments() + { + $command = $this->getCommand(); + $command->prefixKeys('prefix:'); + + $this->assertSame(array(), $command->getArguments()); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/KeyScanTest.php b/vendor/predis/predis/tests/Predis/Command/KeyScanTest.php new file mode 100755 index 0000000..62d36d7 --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/KeyScanTest.php @@ -0,0 +1,136 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @group commands + * @group realm-key + */ +class KeyScanTest extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return 'Predis\Command\KeyScan'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return 'SCAN'; + } + + /** + * @group disconnected + */ + public function testFilterArguments() + { + $arguments = array(0, 'MATCH', 'key:*', 'COUNT', 5); + $expected = array(0, 'MATCH', 'key:*', 'COUNT', 5); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testFilterArgumentsBasicUsage() + { + $arguments = array(0); + $expected = array(0); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testFilterArgumentsWithOptionsArray() + { + $arguments = array(0, array('match' => 'key:*', 'count' => 5)); + $expected = array(0, 'MATCH', 'key:*', 'COUNT', 5); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse() + { + $raw = array('3', array('key:1', 'key:2', 'key:3')); + $expected = array(3, array('key:1', 'key:2', 'key:3')); + + $command = $this->getCommand(); + + $this->assertSame($expected, $command->parseResponse($raw)); + } + + /** + * @group connected + */ + public function testScanWithoutMatch() + { + $kvs = array('key:one' => 'one', 'key:two' => 'two', 'key:three' => 'three', 'key:four' => 'four'); + + $redis = $this->getClient(); + $redis->mset($kvs); + + $response = $redis->scan(0); + + $this->assertSameValues(array_keys($kvs), $response[1]); + } + + /** + * @group connected + */ + public function testScanWithMatchingKeys() + { + $kvs = array('key:one' => 'one', 'key:two' => 'two', 'key:three' => 'three', 'key:four' => 'four'); + + $redis = $this->getClient(); + $redis->mset($kvs); + + $response = $redis->scan(0, 'MATCH', 'key:t*'); + + $this->assertSameValues(array('key:two', 'key:three'), $response[1]); + } + + /** + * @group connected + */ + public function testScanWithNoMatchingKeys() + { + $kvs = array('key:one' => 'one', 'key:two' => 'two', 'key:three' => 'three', 'key:four' => 'four'); + + $redis = $this->getClient(); + $redis->mset($kvs); + + $response = $redis->scan(0, 'MATCH', 'nokey:*'); + + $this->assertSame(0, $response[0]); + $this->assertEmpty($response[1]); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/KeySortTest.php b/vendor/predis/predis/tests/Predis/Command/KeySortTest.php new file mode 100755 index 0000000..d1862d5 --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/KeySortTest.php @@ -0,0 +1,279 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @group commands + * @group realm-key + */ +class KeySortTest extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return 'Predis\Command\KeySort'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return 'SORT'; + } + + /** + * Utility method to to an LPUSH of some unordered values on a key. + * + * @param Predis\Client $redis Redis client instance. + * @param string $key Target key + * @return array + */ + protected function lpushUnorderedList(Predis\Client $redis, $key) + { + $list = array(2, 100, 3, 1, 30, 10); + $redis->lpush($key, $list); + + return $list; + } + + /** + * @group disconnected + */ + public function testFilterArguments() + { + $modifiers = array( + 'by' => 'by_key_*', + 'limit' => array(1, 4), + 'get' => array('object_*', '#'), + 'sort' => 'asc', + 'alpha' => true, + 'store' => 'destination_key', + ); + $arguments = array('key', $modifiers); + + $expected = array( + 'key', 'BY', 'by_key_*', 'GET', 'object_*', 'GET', '#', + 'LIMIT', 1, 4, 'ASC', 'ALPHA', 'STORE', 'destination_key' + ); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertEquals($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testGetModifierCanBeString() + { + $arguments = array('key', array('get' => '#')); + $expected = array('key', 'GET', '#'); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse() + { + $raw = array('value1', 'value2', 'value3'); + $expected = array('value1', 'value2', 'value3'); + + $command = $this->getCommand(); + + $this->assertSame($expected, $command->parseResponse($raw)); + } + + /** + * @group disconnected + */ + public function testPrefixKeys() + { + $modifiers = array( + 'by' => 'by_key_*', + 'limit' => array(1, 4), + 'get' => array('object_*', '#'), + 'sort' => 'asc', + 'alpha' => true, + 'store' => 'destination_key', + ); + $arguments = array('key', $modifiers); + + $expected = array( + 'prefix:key', 'BY', 'prefix:by_key_*', 'GET', 'prefix:object_*', 'GET', '#', + 'LIMIT', 1, 4, 'ASC', 'ALPHA', 'STORE', 'prefix:destination_key' + ); + + $command = $this->getCommandWithArgumentsArray($arguments); + $command->prefixKeys('prefix:'); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testPrefixKeysIgnoredOnEmptyArguments() + { + $command = $this->getCommand(); + $command->prefixKeys('prefix:'); + + $this->assertSame(array(), $command->getArguments()); + } + + /** + * @group connected + */ + public function testBasicSort() + { + $redis = $this->getClient(); + $redis->lpush('list:unordered', $unordered = array(2, 100, 3, 1, 30, 10)); + + $this->assertEquals(array(1, 2, 3, 10, 30, 100), $redis->sort('list:unordered')); + } + + /** + * @group connected + */ + public function testSortWithAscOrDescModifier() + { + $redis = $this->getClient(); + $redis->lpush('list:unordered', $unordered = array(2, 100, 3, 1, 30, 10)); + + $this->assertEquals( + array(100, 30, 10, 3, 2, 1), + $redis->sort('list:unordered', array( + 'sort' => 'desc', + )) + ); + + $this->assertEquals( + array(1, 2, 3, 10, 30, 100), + $redis->sort('list:unordered', array( + 'sort' => 'asc', + )) + ); + } + + /** + * @group connected + */ + public function testSortWithLimitModifier() + { + $redis = $this->getClient(); + $redis->lpush('list:unordered', $unordered = array(2, 100, 3, 1, 30, 10)); + + $this->assertEquals( + array(1, 2, 3), + $redis->sort('list:unordered', array( + 'limit' => array(0, 3), + )) + ); + + $this->assertEquals( + array(10, 30), + $redis->sort('list:unordered', array( + 'limit' => array(3, 2) + )) + ); + } + + /** + * @group connected + */ + public function testSortWithAlphaModifier() + { + $redis = $this->getClient(); + $redis->lpush('list:unordered', $unordered = array(2, 100, 3, 1, 30, 10)); + + $this->assertEquals( + array(1, 10, 100, 2, 3, 30), + $redis->sort('list:unordered', array( + 'alpha' => true + )) + ); + } + + /** + * @group connected + */ + public function testSortWithStoreModifier() + { + $redis = $this->getClient(); + $redis->lpush('list:unordered', $unordered = array(2, 100, 3, 1, 30, 10)); + + $this->assertEquals( + count($unordered), + $redis->sort('list:unordered', array( + 'store' => 'list:ordered' + )) + ); + + $this->assertEquals(array(1, 2, 3, 10, 30, 100), $redis->lrange('list:ordered', 0, -1)); + } + + /** + * @group connected + */ + public function testSortWithCombinedModifiers() + { + $redis = $this->getClient(); + $redis->lpush('list:unordered', $unordered = array(2, 100, 3, 1, 30, 10)); + + $this->assertEquals( + array(30, 10, 3, 2), + $redis->sort('list:unordered', array( + 'alpha' => false, + 'sort' => 'desc', + 'limit' => array(1, 4) + )) + ); + } + + /** + * @group connected + */ + public function testSortWithGetModifiers() + { + $redis = $this->getClient(); + $redis->lpush('list:unordered', $unordered = array(2, 100, 3, 1, 30, 10)); + + $redis->rpush('list:uids', $uids = array(1003, 1001, 1002, 1000)); + $redis->mset($sortget = array( + 'uid:1000' => 'foo', 'uid:1001' => 'bar', + 'uid:1002' => 'hoge', 'uid:1003' => 'piyo', + )); + + $this->assertEquals(array_values($sortget), $redis->sort('list:uids', array('get' => 'uid:*'))); + } + + /** + * @group connected + * @expectedException Predis\ServerException + * @expectedExceptionMessage Operation against a key holding the wrong kind of value + */ + public function testThrowsExceptionOnWrongType() + { + $redis = $this->getClient(); + + $redis->set('foo', 'bar'); + $redis->sort('foo'); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/KeyTimeToLiveTest.php b/vendor/predis/predis/tests/Predis/Command/KeyTimeToLiveTest.php new file mode 100755 index 0000000..98aca39 --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/KeyTimeToLiveTest.php @@ -0,0 +1,122 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @group commands + * @group realm-key + */ +class KeyTimeToLiveTest extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return 'Predis\Command\KeyTimeToLive'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return 'TTL'; + } + + /** + * @group disconnected + */ + public function testFilterArguments() + { + $arguments = array('key', 10); + $expected = array('key', 10); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse() + { + $command = $this->getCommand(); + + $this->assertSame(100, $command->parseResponse(100)); + } + + /** + * @group disconnected + */ + public function testPrefixKeys() + { + $arguments = array('key', 10); + $expected = array('prefix:key', 10); + + $command = $this->getCommandWithArgumentsArray($arguments); + $command->prefixKeys('prefix:'); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testPrefixKeysIgnoredOnEmptyArguments() + { + $command = $this->getCommand(); + $command->prefixKeys('prefix:'); + + $this->assertSame(array(), $command->getArguments()); + } + + /** + * @group connected + */ + public function testReturnsTTL() + { + $redis = $this->getClient(); + + $redis->set('foo', 'bar'); + $redis->expire('foo', 10); + + $this->assertSame(10, $redis->ttl('foo')); + } + + /** + * @group connected + */ + public function testReturnsLessThanZeroOnNonExpiringKeys() + { + $redis = $this->getClient(); + + $redis->set('foo', 'bar'); + $this->assertSame(-1, $redis->ttl('foo')); + } + + /** + * @group connected + */ + public function testReturnsLessThanZeroOnNonExistingKeys() + { + $this->executeOnRedisVersion('2.8.0', '<', function ($test) { + $test->assertSame(-1, $test->getClient()->ttl('foo')); + }); + + $this->executeOnRedisVersion('2.8.0', '>=', function ($test) { + $test->assertSame(-2, $test->getClient()->ttl('foo')); + }); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/KeyTypeTest.php b/vendor/predis/predis/tests/Predis/Command/KeyTypeTest.php new file mode 100755 index 0000000..870dbfe --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/KeyTypeTest.php @@ -0,0 +1,107 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @group commands + * @group realm-key + */ +class KeyTypeTest extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return 'Predis\Command\KeyType'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return 'TYPE'; + } + + /** + * @group disconnected + */ + public function testFilterArguments() + { + $arguments = array('key'); + $expected = array('key'); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse() + { + $this->assertSame('type', $this->getCommand()->parseResponse('type')); + } + + /** + * @group disconnected + */ + public function testPrefixKeys() + { + $arguments = array('key'); + $expected = array('prefix:key'); + + $command = $this->getCommandWithArgumentsArray($arguments); + $command->prefixKeys('prefix:'); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testPrefixKeysIgnoredOnEmptyArguments() + { + $command = $this->getCommand(); + $command->prefixKeys('prefix:'); + + $this->assertSame(array(), $command->getArguments()); + } + + /** + * @group connected + */ + public function testReturnsTypeOfKey() + { + $redis = $this->getClient(); + + $this->assertSame('none', $redis->type('type:keydoesnotexist')); + + $redis->set('type:string', 'foobar'); + $this->assertSame('string', $redis->type('type:string')); + + $redis->lpush('type:list', 'foobar'); + $this->assertSame('list', $redis->type('type:list')); + + $redis->sadd('type:set', 'foobar'); + $this->assertSame('set', $redis->type('type:set')); + + $redis->zadd('type:zset', 0, 'foobar'); + $this->assertSame('zset', $redis->type('type:zset')); + + $redis->hset('type:hash', 'foo', 'bar'); + $this->assertSame('hash', $redis->type('type:hash')); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/ListIndexTest.php b/vendor/predis/predis/tests/Predis/Command/ListIndexTest.php new file mode 100755 index 0000000..623c02d --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/ListIndexTest.php @@ -0,0 +1,124 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @group commands + * @group realm-list + */ +class ListIndexTest extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return 'Predis\Command\ListIndex'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return 'LINDEX'; + } + + /** + * @group disconnected + */ + public function testFilterArguments() + { + $arguments = array('key', 1); + $expected = array('key', 1); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse() + { + $this->assertSame(0, $this->getCommand()->parseResponse(0)); + } + + /** + * @group disconnected + */ + public function testPrefixKeys() + { + $arguments = array('key', 1); + $expected = array('prefix:key', 1); + + $command = $this->getCommandWithArgumentsArray($arguments); + $command->prefixKeys('prefix:'); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testPrefixKeysIgnoredOnEmptyArguments() + { + $command = $this->getCommand(); + $command->prefixKeys('prefix:'); + + $this->assertSame(array(), $command->getArguments()); + } + + /** + * @group connected + */ + public function testReturnsElementAtIndex() + { + $redis = $this->getClient(); + + $redis->rpush('letters', 'a', 'b', 'c', 'd', 'e'); + + $this->assertSame('a', $redis->lindex('letters', 0)); + $this->assertSame('c', $redis->lindex('letters', 2)); + $this->assertNull($redis->lindex('letters', 100)); + } + + /** + * @group connected + */ + public function testReturnsElementAtNegativeIndex() + { + $redis = $this->getClient(); + + $redis->rpush('letters', 'a', 'b', 'c', 'd', 'e'); + + $this->assertSame('a', $redis->lindex('letters', -0)); + $this->assertSame('c', $redis->lindex('letters', -3)); + $this->assertSame('e', $redis->lindex('letters', -1)); + $this->assertNull($redis->lindex('letters', -100)); + } + + /** + * @group connected + * @expectedException Predis\ServerException + * @expectedExceptionMessage Operation against a key holding the wrong kind of value + */ + public function testThrowsExceptionOnWrongType() + { + $redis = $this->getClient(); + + $redis->set('foo', 'bar'); + $redis->lindex('foo', 0); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/ListInsertTest.php b/vendor/predis/predis/tests/Predis/Command/ListInsertTest.php new file mode 100755 index 0000000..20dcd0e --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/ListInsertTest.php @@ -0,0 +1,132 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @group commands + * @group realm-list + */ +class ListInsertTest extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return 'Predis\Command\ListInsert'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return 'LINSERT'; + } + + /** + * @group disconnected + */ + public function testFilterArguments() + { + $arguments = array('key', 'before', 'value1', 'value2'); + $expected = array('key', 'before', 'value1', 'value2'); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse() + { + $this->assertSame(1, $this->getCommand()->parseResponse(1)); + } + + /** + * @group disconnected + */ + public function testPrefixKeys() + { + $arguments = array('key', 'before', 'value1', 'value2'); + $expected = array('prefix:key', 'before', 'value1', 'value2'); + + $command = $this->getCommandWithArgumentsArray($arguments); + $command->prefixKeys('prefix:'); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testPrefixKeysIgnoredOnEmptyArguments() + { + $command = $this->getCommand(); + $command->prefixKeys('prefix:'); + + $this->assertSame(array(), $command->getArguments()); + } + + /** + * @group connected + */ + public function testReturnsLengthOfListAfterInser() + { + $redis = $this->getClient(); + + $redis->rpush('letters', 'a', 'c', 'e'); + + $this->assertSame(4, $redis->linsert('letters', 'before', 'c', 'b')); + $this->assertSame(5, $redis->linsert('letters', 'after', 'c', 'd')); + $this->assertSame(array('a', 'b', 'c', 'd', 'e'), $redis->lrange('letters', 0, -1)); + } + + /** + * @group connected + */ + public function testReturnsNegativeLengthOnFailedInsert() + { + $redis = $this->getClient(); + + $redis->rpush('letters', 'a', 'c', 'e'); + + $this->assertSame(-1, $redis->linsert('letters', 'before', 'n', 'm')); + $this->assertSame(-1, $redis->linsert('letters', 'after', 'o', 'p')); + } + + /** + * @group connected + */ + public function testReturnsZeroLengthOnNonExistingList() + { + $redis = $this->getClient(); + + $this->assertSame(0, $redis->linsert('letters', 'after', 'a', 'b')); + } + + /** + * @group connected + * @expectedException Predis\ServerException + * @expectedExceptionMessage Operation against a key holding the wrong kind of value + */ + public function testThrowsExceptionOnWrongType() + { + $redis = $this->getClient(); + + $redis->set('foo', 'bar'); + $redis->linsert('foo', 'BEFORE', 'bar', 'baz'); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/ListLengthTest.php b/vendor/predis/predis/tests/Predis/Command/ListLengthTest.php new file mode 100755 index 0000000..7fac2c0 --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/ListLengthTest.php @@ -0,0 +1,119 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @group commands + * @group realm-list + */ +class ListLengthTest extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return 'Predis\Command\ListLength'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return 'LLEN'; + } + + /** + * @group disconnected + */ + public function testFilterArguments() + { + $arguments = array('key'); + $expected = array('key'); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse() + { + $this->assertSame(1, $this->getCommand()->parseResponse(1)); + } + + /** + * @group disconnected + */ + public function testPrefixKeys() + { + $arguments = array('key'); + $expected = array('prefix:key'); + + $command = $this->getCommandWithArgumentsArray($arguments); + $command->prefixKeys('prefix:'); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testPrefixKeysIgnoredOnEmptyArguments() + { + $command = $this->getCommand(); + $command->prefixKeys('prefix:'); + + $this->assertSame(array(), $command->getArguments()); + } + + /** + * @group connected + */ + public function testReturnsLengthOfList() + { + $redis = $this->getClient(); + + $redis->rpush('letters', 'a', 'b', 'c'); + $this->assertSame(3, $redis->llen('letters')); + + $redis->rpush('letters', 'd', 'e', 'f'); + $this->assertSame(6, $redis->llen('letters')); + } + + /** + * @group connected + */ + public function testReturnsZeroLengthOnNonExistingList() + { + $redis = $this->getClient(); + + $this->assertSame(0, $redis->llen('letters')); + } + + /** + * @group connected + * @expectedException Predis\ServerException + * @expectedExceptionMessage Operation against a key holding the wrong kind of value + */ + public function testThrowsExceptionOnWrongType() + { + $redis = $this->getClient(); + + $redis->set('foo', 'bar'); + $redis->llen('foo'); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/ListPopFirstBlockingTest.php b/vendor/predis/predis/tests/Predis/Command/ListPopFirstBlockingTest.php new file mode 100755 index 0000000..140b3b0 --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/ListPopFirstBlockingTest.php @@ -0,0 +1,103 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @group commands + * @group realm-list + * @todo Testing blocking pop operations against Redis using PHP is + * tricky, so we will skip these kind of tests for now. + */ +class ListPopFirstBlockingTest extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return 'Predis\Command\ListPopFirstBlocking'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return 'BLPOP'; + } + + /** + * @group disconnected + */ + public function testFilterArguments() + { + $arguments = array('key1', 'key2', 'key3', 10); + $expected = array('key1', 'key2', 'key3', 10); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testFilterArgumentsKeysAsSingleArray() + { + $arguments = array(array('key1', 'key2', 'key3'), 10); + $expected = array('key1', 'key2', 'key3', 10); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse() + { + $raw = array('key', 'value'); + $expected = array('key', 'value'); + + $command = $this->getCommand(); + + $this->assertSame($expected, $command->parseResponse($raw)); + } + + /** + * @group disconnected + */ + public function testPrefixKeys() + { + $arguments = array('key1', 'key2', 'key3', 10); + $expected = array('prefix:key1', 'prefix:key2', 'prefix:key3', 10); + + $command = $this->getCommandWithArgumentsArray($arguments); + $command->prefixKeys('prefix:'); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testPrefixKeysIgnoredOnEmptyArguments() + { + $command = $this->getCommand(); + $command->prefixKeys('prefix:'); + + $this->assertSame(array(), $command->getArguments()); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/ListPopFirstTest.php b/vendor/predis/predis/tests/Predis/Command/ListPopFirstTest.php new file mode 100755 index 0000000..b95d1c5 --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/ListPopFirstTest.php @@ -0,0 +1,119 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @group commands + * @group realm-list + */ +class ListPopFirstTest extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return 'Predis\Command\ListPopFirst'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return 'LPOP'; + } + + /** + * @group disconnected + */ + public function testFilterArguments() + { + $arguments = array('key'); + $expected = array('key'); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse() + { + $this->assertSame('element', $this->getCommand()->parseResponse('element')); + } + + /** + * @group disconnected + */ + public function testPrefixKeys() + { + $arguments = array('key'); + $expected = array('prefix:key'); + + $command = $this->getCommandWithArgumentsArray($arguments); + $command->prefixKeys('prefix:'); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testPrefixKeysIgnoredOnEmptyArguments() + { + $command = $this->getCommand(); + $command->prefixKeys('prefix:'); + + $this->assertSame(array(), $command->getArguments()); + } + + /** + * @group connected + */ + public function testPopsTheFirstElementFromList() + { + $redis = $this->getClient(); + + $redis->rpush('letters', 'a', 'b', 'c', 'd'); + + $this->assertSame('a', $redis->lpop('letters')); + $this->assertSame('b', $redis->lpop('letters')); + $this->assertSame(array('c', 'd'), $redis->lrange('letters', 0, -1)); + } + + /** + * @group connected + */ + public function testReturnsNullOnEmptyList() + { + $redis = $this->getClient(); + + $this->assertNull($redis->lpop('letters')); + } + + /** + * @group connected + * @expectedException Predis\ServerException + * @expectedExceptionMessage Operation against a key holding the wrong kind of value + */ + public function testThrowsExceptionOnWrongType() + { + $redis = $this->getClient(); + + $redis->set('foo', 'bar'); + $redis->lpop('foo'); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/ListPopLastBlockingTest.php b/vendor/predis/predis/tests/Predis/Command/ListPopLastBlockingTest.php new file mode 100755 index 0000000..4b9fce1 --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/ListPopLastBlockingTest.php @@ -0,0 +1,103 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @group commands + * @group realm-list + * @todo Testing blocking pop operations against Redis using PHP is + * tricky, so we will skip these kind of tests for now. + */ +class ListPopLastBlockingTest extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return 'Predis\Command\ListPopLastBlocking'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return 'BRPOP'; + } + + /** + * @group disconnected + */ + public function testFilterArguments() + { + $arguments = array('key1', 'key2', 'key3', 10); + $expected = array('key1', 'key2', 'key3', 10); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testFilterArgumentsKeysAsSingleArray() + { + $arguments = array(array('key1', 'key2', 'key3'), 10); + $expected = array('key1', 'key2', 'key3', 10); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse() + { + $raw = array('key', 'value'); + $expected = array('key', 'value'); + + $command = $this->getCommand(); + + $this->assertSame($expected, $command->parseResponse($raw)); + } + + /** + * @group disconnected + */ + public function testPrefixKeys() + { + $arguments = array('key1', 'key2', 'key3', 10); + $expected = array('prefix:key1', 'prefix:key2', 'prefix:key3', 10); + + $command = $this->getCommandWithArgumentsArray($arguments); + $command->prefixKeys('prefix:'); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testPrefixKeysIgnoredOnEmptyArguments() + { + $command = $this->getCommand(); + $command->prefixKeys('prefix:'); + + $this->assertSame(array(), $command->getArguments()); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/ListPopLastPushHeadBlockingTest.php b/vendor/predis/predis/tests/Predis/Command/ListPopLastPushHeadBlockingTest.php new file mode 100755 index 0000000..2835a52 --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/ListPopLastPushHeadBlockingTest.php @@ -0,0 +1,84 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @group commands + * @group realm-list + * @todo Testing blocking pop operations against Redis using PHP is + * tricky, so we will skip these kind of tests for now. + */ +class ListPopLastPushHeadBlockingTest extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return 'Predis\Command\ListPopLastPushHeadBlocking'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return 'BRPOPLPUSH'; + } + + /** + * @group disconnected + */ + public function testFilterArguments() + { + $arguments = array('key:source', 'key:destination', 10); + $expected = array('key:source', 'key:destination', 10); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse() + { + $this->assertSame('element', $this->getCommand()->parseResponse('element')); + } + + /** + * @group disconnected + */ + public function testPrefixKeys() + { + $arguments = array('key:source', 'key:destination', 10); + $expected = array('prefix:key:source', 'prefix:key:destination', 10); + + $command = $this->getCommandWithArgumentsArray($arguments); + $command->prefixKeys('prefix:'); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testPrefixKeysIgnoredOnEmptyArguments() + { + $command = $this->getCommand(); + $command->prefixKeys('prefix:'); + + $this->assertSame(array(), $command->getArguments()); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/ListPopLastPushHeadTest.php b/vendor/predis/predis/tests/Predis/Command/ListPopLastPushHeadTest.php new file mode 100755 index 0000000..f6a350c --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/ListPopLastPushHeadTest.php @@ -0,0 +1,153 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @group commands + * @group realm-list + */ +class ListPopLastPushHeadTest extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return 'Predis\Command\ListPopLastPushHead'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return 'RPOPLPUSH'; + } + + /** + * @group disconnected + */ + public function testFilterArguments() + { + $arguments = array('key:source', 'key:destination'); + $expected = array('key:source', 'key:destination'); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse() + { + $this->assertSame('element', $this->getCommand()->parseResponse('element')); + } + + /** + * @group disconnected + */ + public function testPrefixKeys() + { + $arguments = array('key:source', 'key:destination'); + $expected = array('prefix:key:source', 'prefix:key:destination'); + + $command = $this->getCommandWithArgumentsArray($arguments); + $command->prefixKeys('prefix:'); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testPrefixKeysIgnoredOnEmptyArguments() + { + $command = $this->getCommand(); + $command->prefixKeys('prefix:'); + + $this->assertSame(array(), $command->getArguments()); + } + + /** + * @group connected + */ + public function testReturnsElementPoppedFromSourceAndPushesToDestination() + { + $redis = $this->getClient(); + + $redis->rpush('letters:source', 'a', 'b', 'c'); + + $this->assertSame('c', $redis->rpoplpush('letters:source', 'letters:destination')); + $this->assertSame('b', $redis->rpoplpush('letters:source', 'letters:destination')); + $this->assertSame('a', $redis->rpoplpush('letters:source', 'letters:destination')); + + $this->assertSame(array(), $redis->lrange('letters:source', 0, -1)); + $this->assertSame(array('a', 'b', 'c'), $redis->lrange('letters:destination', 0, -1)); + } + + /** + * @group connected + */ + public function testReturnsElementPoppedFromSourceAndPushesToSelf() + { + $redis = $this->getClient(); + + $redis->rpush('letters:source', 'a', 'b', 'c'); + + $this->assertSame('c', $redis->rpoplpush('letters:source', 'letters:source')); + $this->assertSame('b', $redis->rpoplpush('letters:source', 'letters:source')); + $this->assertSame('a', $redis->rpoplpush('letters:source', 'letters:source')); + + $this->assertSame(array('a', 'b', 'c'), $redis->lrange('letters:source', 0, -1)); + } + + /** + * @group connected + */ + public function testReturnsNullOnEmptySource() + { + $redis = $this->getClient(); + + $this->assertNull($redis->rpoplpush('key:source', 'key:destination')); + } + + /** + * @group connected + * @expectedException Predis\ServerException + * @expectedExceptionMessage Operation against a key holding the wrong kind of value + */ + public function testThrowsExceptionOnWrongTypeOfSourceKey() + { + $redis = $this->getClient(); + + $redis->set('key:source', 'foo'); + $redis->rpoplpush('key:source', 'key:destination'); + } + + /** + * @group connected + * @expectedException Predis\ServerException + * @expectedExceptionMessage Operation against a key holding the wrong kind of value + */ + public function testThrowsExceptionOnWrongTypeOfDestinationKey() + { + $redis = $this->getClient(); + + $redis->rpush('key:source', 'foo'); + $redis->set('key:destination', 'bar'); + + $redis->rpoplpush('key:source', 'key:destination'); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/ListPopLastTest.php b/vendor/predis/predis/tests/Predis/Command/ListPopLastTest.php new file mode 100755 index 0000000..fd25bd1 --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/ListPopLastTest.php @@ -0,0 +1,119 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @group commands + * @group realm-list + */ +class ListPopLastTest extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return 'Predis\Command\ListPopLast'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return 'RPOP'; + } + + /** + * @group disconnected + */ + public function testFilterArguments() + { + $arguments = array('key'); + $expected = array('key'); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse() + { + $this->assertSame('element', $this->getCommand()->parseResponse('element')); + } + + /** + * @group disconnected + */ + public function testPrefixKeys() + { + $arguments = array('key'); + $expected = array('prefix:key'); + + $command = $this->getCommandWithArgumentsArray($arguments); + $command->prefixKeys('prefix:'); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testPrefixKeysIgnoredOnEmptyArguments() + { + $command = $this->getCommand(); + $command->prefixKeys('prefix:'); + + $this->assertSame(array(), $command->getArguments()); + } + + /** + * @group connected + */ + public function testPopsTheLastElementFromList() + { + $redis = $this->getClient(); + + $redis->rpush('letters', 'a', 'b', 'c', 'd'); + + $this->assertSame('d', $redis->rpop('letters')); + $this->assertSame('c', $redis->rpop('letters')); + $this->assertSame(array('a', 'b'), $redis->lrange('letters', 0, -1)); + } + + /** + * @group connected + */ + public function testReturnsNullOnEmptyList() + { + $redis = $this->getClient(); + + $this->assertNull($redis->rpop('letters')); + } + + /** + * @group connected + * @expectedException Predis\ServerException + * @expectedExceptionMessage Operation against a key holding the wrong kind of value + */ + public function testThrowsExceptionOnWrongType() + { + $redis = $this->getClient(); + + $redis->set('foo', 'bar'); + $redis->rpop('foo'); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/ListPushHeadTest.php b/vendor/predis/predis/tests/Predis/Command/ListPushHeadTest.php new file mode 100755 index 0000000..acb2c29 --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/ListPushHeadTest.php @@ -0,0 +1,122 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @group commands + * @group realm-list + */ +class ListPushHeadTest extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return 'Predis\Command\ListPushHead'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return 'LPUSH'; + } + + /** + * @group disconnected + */ + public function testFilterArguments() + { + $arguments = array('key', 'value1', 'value2', 'value3'); + $expected = array('key', 'value1', 'value2', 'value3'); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testFilterArgumentsValuesAsSingleArray() + { + $arguments = array('key', array('value1', 'value2', 'value3')); + $expected = array('key', 'value1', 'value2', 'value3'); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse() + { + $this->assertSame(1, $this->getCommand()->parseResponse(1)); + } + + /** + * @group disconnected + */ + public function testPrefixKeys() + { + $arguments = array('key', 'value1', 'value2', 'value3'); + $expected = array('prefix:key', 'value1', 'value2', 'value3'); + + $command = $this->getCommandWithArgumentsArray($arguments); + $command->prefixKeys('prefix:'); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testPrefixKeysIgnoredOnEmptyArguments() + { + $command = $this->getCommand(); + $command->prefixKeys('prefix:'); + + $this->assertSame(array(), $command->getArguments()); + } + + /** + * @group connected + */ + public function testPushesElementsToHeadOfList() + { + $redis = $this->getClient(); + + // NOTE: List push operations return the list length since Redis commit 520b5a3 + $this->assertSame(1, $redis->lpush('metavars', 'foo')); + $this->assertSame(2, $redis->lpush('metavars', 'hoge')); + $this->assertSame(array('hoge', 'foo'), $redis->lrange('metavars', 0, -1)); + } + + /** + * @group connected + * @expectedException Predis\ServerException + * @expectedExceptionMessage Operation against a key holding the wrong kind of value + */ + public function testThrowsExceptionOnWrongType() + { + $redis = $this->getClient(); + + $redis->set('metavars', 'foo'); + $redis->lpush('metavars', 'hoge'); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/ListPushHeadXTest.php b/vendor/predis/predis/tests/Predis/Command/ListPushHeadXTest.php new file mode 100755 index 0000000..c37698c --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/ListPushHeadXTest.php @@ -0,0 +1,120 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @group commands + * @group realm-list + */ +class ListPushHeadXTest extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return 'Predis\Command\ListPushHeadX'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return 'LPUSHX'; + } + + /** + * @group disconnected + */ + public function testFilterArguments() + { + $arguments = array('key', 'value'); + $expected = array('key', 'value'); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse() + { + $this->assertSame(1, $this->getCommand()->parseResponse(1)); + } + + /** + * @group disconnected + */ + public function testPrefixKeys() + { + $arguments = array('key', 'value'); + $expected = array('prefix:key', 'value'); + + $command = $this->getCommandWithArgumentsArray($arguments); + $command->prefixKeys('prefix:'); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testPrefixKeysIgnoredOnEmptyArguments() + { + $command = $this->getCommand(); + $command->prefixKeys('prefix:'); + + $this->assertSame(array(), $command->getArguments()); + } + + /** + * @group connected + */ + public function testPushesElementsToHeadOfExistingList() + { + $redis = $this->getClient(); + + $redis->lpush('metavars', 'foo'); + + $this->assertSame(2, $redis->lpushx('metavars', 'hoge')); + $this->assertSame(array('hoge', 'foo'), $redis->lrange('metavars', 0, -1)); + } + + /** + * @group connected + */ + public function testDoesNotPushElementOnNonExistingKey() + { + $redis = $this->getClient(); + + $this->assertSame(0, $redis->lpushx('metavars', 'foo')); + $this->assertSame(0, $redis->lpushx('metavars', 'hoge')); + $this->assertFalse($redis->exists('metavars')); + } + + /** + * @group connected + * @expectedException Predis\ServerException + * @expectedExceptionMessage Operation against a key holding the wrong kind of value + */ + public function testThrowsExceptionOnWrongType() + { + $redis = $this->getClient(); + + $redis->set('metavars', 'foo'); + $redis->lpushx('metavars', 'hoge'); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/ListPushTailTest.php b/vendor/predis/predis/tests/Predis/Command/ListPushTailTest.php new file mode 100755 index 0000000..70731f1 --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/ListPushTailTest.php @@ -0,0 +1,122 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @group commands + * @group realm-list + */ +class ListPushTailTest extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return 'Predis\Command\ListPushTail'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return 'RPUSH'; + } + + /** + * @group disconnected + */ + public function testFilterArguments() + { + $arguments = array('key', 'value1', 'value2', 'value3'); + $expected = array('key', 'value1', 'value2', 'value3'); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testFilterArgumentsValuesAsSingleArray() + { + $arguments = array('key', array('value1', 'value2', 'value3')); + $expected = array('key', 'value1', 'value2', 'value3'); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse() + { + $this->assertSame(1, $this->getCommand()->parseResponse(1)); + } + + /** + * @group disconnected + */ + public function testPrefixKeys() + { + $arguments = array('key', 'value1', 'value2', 'value3'); + $expected = array('prefix:key', 'value1', 'value2', 'value3'); + + $command = $this->getCommandWithArgumentsArray($arguments); + $command->prefixKeys('prefix:'); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testPrefixKeysIgnoredOnEmptyArguments() + { + $command = $this->getCommand(); + $command->prefixKeys('prefix:'); + + $this->assertSame(array(), $command->getArguments()); + } + + /** + * @group connected + */ + public function testPushesElementsToHeadOfList() + { + $redis = $this->getClient(); + + // NOTE: List push operations return the list length since Redis commit 520b5a3 + $this->assertSame(1, $redis->rpush('metavars', 'foo')); + $this->assertSame(2, $redis->rpush('metavars', 'hoge')); + $this->assertSame(array('foo', 'hoge'), $redis->lrange('metavars', 0, -1)); + } + + /** + * @group connected + * @expectedException Predis\ServerException + * @expectedExceptionMessage Operation against a key holding the wrong kind of value + */ + public function testThrowsExceptionOnWrongType() + { + $redis = $this->getClient(); + + $redis->set('metavars', 'foo'); + $redis->rpush('metavars', 'hoge'); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/ListPushTailXTest.php b/vendor/predis/predis/tests/Predis/Command/ListPushTailXTest.php new file mode 100755 index 0000000..30b968c --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/ListPushTailXTest.php @@ -0,0 +1,120 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @group commands + * @group realm-list + */ +class ListPushTailXTest extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return 'Predis\Command\ListPushTailX'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return 'RPUSHX'; + } + + /** + * @group disconnected + */ + public function testFilterArguments() + { + $arguments = array('key', 'value'); + $expected = array('key', 'value'); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse() + { + $this->assertSame(1, $this->getCommand()->parseResponse(1)); + } + + /** + * @group disconnected + */ + public function testPrefixKeys() + { + $arguments = array('key', 'value'); + $expected = array('prefix:key', 'value'); + + $command = $this->getCommandWithArgumentsArray($arguments); + $command->prefixKeys('prefix:'); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testPrefixKeysIgnoredOnEmptyArguments() + { + $command = $this->getCommand(); + $command->prefixKeys('prefix:'); + + $this->assertSame(array(), $command->getArguments()); + } + + /** + * @group connected + */ + public function testPushesElementsToHeadOfExistingList() + { + $redis = $this->getClient(); + + $redis->rpush('metavars', 'foo'); + + $this->assertSame(2, $redis->rpushx('metavars', 'hoge')); + $this->assertSame(array('foo', 'hoge'), $redis->lrange('metavars', 0, -1)); + } + + /** + * @group connected + */ + public function testDoesNotPushElementOnNonExistingKey() + { + $redis = $this->getClient(); + + $this->assertSame(0, $redis->rpushx('metavars', 'foo')); + $this->assertSame(0, $redis->rpushx('metavars', 'hoge')); + $this->assertFalse($redis->exists('metavars')); + } + + /** + * @group connected + * @expectedException Predis\ServerException + * @expectedExceptionMessage Operation against a key holding the wrong kind of value + */ + public function testThrowsExceptionOnWrongType() + { + $redis = $this->getClient(); + + $redis->set('metavars', 'foo'); + $redis->rpushx('metavars', 'hoge'); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/ListRangeTest.php b/vendor/predis/predis/tests/Predis/Command/ListRangeTest.php new file mode 100755 index 0000000..f70b0b8 --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/ListRangeTest.php @@ -0,0 +1,163 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @group commands + * @group realm-list + */ +class ListRangeTest extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return 'Predis\Command\ListRange'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return 'LRANGE'; + } + + /** + * @group disconnected + */ + public function testFilterArguments() + { + $arguments = array('key', 0, -1); + $expected = array('key', 0, -1); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse() + { + $raw = array('value1', 'value2', 'value3'); + $expected = array('value1', 'value2', 'value3'); + + $command = $this->getCommand(); + + $this->assertSame($expected, $command->parseResponse($raw)); + } + + /** + * @group disconnected + */ + public function testPrefixKeys() + { + $arguments = array('key', 0, -1); + $expected = array('prefix:key', 0, -1); + + $command = $this->getCommandWithArgumentsArray($arguments); + $command->prefixKeys('prefix:'); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testPrefixKeysIgnoredOnEmptyArguments() + { + $command = $this->getCommand(); + $command->prefixKeys('prefix:'); + + $this->assertSame(array(), $command->getArguments()); + } + + /** + * @group connected + */ + public function testReturnsListSliceWithPositiveStartAndStop() + { + $redis = $this->getClient(); + + $redis->rpush('letters', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'l'); + + $this->assertSame(array('a', 'b', 'c', 'd'), $redis->lrange('letters', 0, 3)); + $this->assertSame(array('e', 'f', 'g', 'h'), $redis->lrange('letters', 4, 7)); + $this->assertSame(array('a', 'b'), $redis->lrange('letters', 0, 1)); + $this->assertSame(array('a'), $redis->lrange('letters', 0, 0)); + } + + /** + * @group connected + */ + public function testReturnsListSliceWithPositiveStartAndNegativeStop() + { + $redis = $this->getClient(); + + $redis->rpush('letters', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'l'); + + $this->assertSame(array('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'l'), $redis->lrange('letters', 0, -1)); + $this->assertSame(array('f'), $redis->lrange('letters', 5, -5)); + $this->assertSame(array(), $redis->lrange('letters', 7, -5)); + } + + /** + * @group connected + */ + public function testReturnsListSliceWithNegativeStartAndStop() + { + $redis = $this->getClient(); + + $redis->rpush('letters', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'l'); + + $this->assertSame(array('f'), $redis->lrange('letters', -5, -5)); + } + + /** + * @group connected + */ + public function testHandlesStartAndStopOverflow() + { + $redis = $this->getClient(); + + $redis->rpush('letters', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'l'); + + $this->assertSame(array('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'l'), $redis->lrange('letters', -100, 100)); + } + + /** + * @group connected + */ + public function testReturnsEmptyArrayOnNonExistingList() + { + $redis = $this->getClient(); + + $this->assertSame(array(), $redis->lrange('letters', 0, -1)); + } + + /** + * @group connected + * @expectedException Predis\ServerException + * @expectedExceptionMessage Operation against a key holding the wrong kind of value + */ + public function testThrowsExceptionOnWrongType() + { + $redis = $this->getClient(); + + $redis->set('metavars', 'foo'); + $redis->lrange('metavars', 0, -1); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/ListRemoveTest.php b/vendor/predis/predis/tests/Predis/Command/ListRemoveTest.php new file mode 100755 index 0000000..6711e00 --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/ListRemoveTest.php @@ -0,0 +1,147 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @group commands + * @group realm-list + */ +class ListRemoveTest extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return 'Predis\Command\ListRemove'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return 'LREM'; + } + + /** + * @group disconnected + */ + public function testFilterArguments() + { + $arguments = array('key', 1, 'value'); + $expected = array('key', 1, 'value'); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse() + { + $this->assertSame(1, $this->getCommand()->parseResponse(1)); + } + + /** + * @group disconnected + */ + public function testPrefixKeys() + { + $arguments = array('key', 1, 'value'); + $expected = array('prefix:key', 1, 'value'); + + $command = $this->getCommandWithArgumentsArray($arguments); + $command->prefixKeys('prefix:'); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testPrefixKeysIgnoredOnEmptyArguments() + { + $command = $this->getCommand(); + $command->prefixKeys('prefix:'); + + $this->assertSame(array(), $command->getArguments()); + } + + /** + * @group connected + */ + public function testRemovesMatchingElementsFromHeadToTail() + { + $redis = $this->getClient(); + + $redis->rpush('letters', 'a', '_', 'b', '_', 'c', '_', 'd', '_'); + + $this->assertSame(2, $redis->lrem('letters', 2, '_')); + $this->assertSame(array('a', 'b', 'c', '_', 'd', '_'), $redis->lrange('letters', 0, -1)); + } + + /** + * @group connected + */ + public function testRemovesMatchingElementsFromTailToHead() + { + $redis = $this->getClient(); + + $redis->rpush('letters', 'a', '_', 'b', '_', 'c', '_', 'd', '_'); + + $this->assertSame(2, $redis->lrem('letters', -2, '_')); + $this->assertSame(array('a', '_', 'b', '_', 'c', 'd'), $redis->lrange('letters', 0, -1)); + } + + /** + * @group connected + */ + public function testRemovesAllMatchingElements() + { + $redis = $this->getClient(); + + $redis->rpush('letters', 'a', '_', 'b', '_', 'c', '_', 'd', '_'); + + $this->assertSame(4, $redis->lrem('letters', 0, '_')); + $this->assertSame(array('a', 'b', 'c', 'd'), $redis->lrange('letters', 0, -1)); + } + + /** + * @group connected + */ + public function testReturnsZeroOnNonMatchingElementsOrEmptyList() + { + $redis = $this->getClient(); + + $redis->rpush('letters', 'a', 'b', 'c', 'd'); + + $this->assertSame(0, $redis->lrem('letters', 0, 'z')); + $this->assertSame(0, $redis->lrem('digits', 0, 100)); + } + + /** + * @group connected + * @expectedException Predis\ServerException + * @expectedExceptionMessage Operation against a key holding the wrong kind of value + */ + public function testThrowsExceptionOnWrongType() + { + $redis = $this->getClient(); + + $redis->set('metavars', 'foo'); + $redis->lrem('metavars', 0, 0); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/ListSetTest.php b/vendor/predis/predis/tests/Predis/Command/ListSetTest.php new file mode 100755 index 0000000..8647b46 --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/ListSetTest.php @@ -0,0 +1,121 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @group commands + * @group realm-list + */ +class ListSetTest extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return 'Predis\Command\ListSet'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return 'LSET'; + } + + /** + * @group disconnected + */ + public function testFilterArguments() + { + $arguments = array('key', 0, 'value'); + $expected = array('key', 0, 'value'); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse() + { + $this->assertTrue($this->getCommand()->parseResponse(true)); + } + + /** + * @group disconnected + */ + public function testPrefixKeys() + { + $arguments = array('key', 0, 'value'); + $expected = array('prefix:key', 0, 'value'); + + $command = $this->getCommandWithArgumentsArray($arguments); + $command->prefixKeys('prefix:'); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testPrefixKeysIgnoredOnEmptyArguments() + { + $command = $this->getCommand(); + $command->prefixKeys('prefix:'); + + $this->assertSame(array(), $command->getArguments()); + } + + /** + * @group connected + */ + public function testSetsElementAtSpecifiedIndex() + { + $redis = $this->getClient(); + + $redis->rpush('letters', 'a', 'b', 'c'); + + $this->assertTrue($redis->lset('letters', 1, 'B')); + $this->assertSame(array('a', 'B', 'c'), $redis->lrange('letters', 0, -1)); + } + + /** + * @group connected + * @expectedException Predis\ServerException + * @expectedExceptionMessage ERR index out of range + */ + public function testThrowsExceptionOnIndexOutOfRange() + { + $redis = $this->getClient(); + + $redis->rpush('letters', 'a', 'b', 'c'); + $redis->lset('letters', 21, 'z'); + } + + /** + * @group connected + * @expectedException Predis\ServerException + * @expectedExceptionMessage Operation against a key holding the wrong kind of value + */ + public function testThrowsExceptionOnWrongType() + { + $redis = $this->getClient(); + + $redis->set('metavars', 'foo'); + $redis->lset('metavars', 0, 'hoge'); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/ListTrimTest.php b/vendor/predis/predis/tests/Predis/Command/ListTrimTest.php new file mode 100755 index 0000000..1e1c399 --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/ListTrimTest.php @@ -0,0 +1,153 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @group commands + * @group realm-list + */ +class ListTrimTest extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return 'Predis\Command\ListTrim'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return 'LTRIM'; + } + + /** + * @group disconnected + */ + public function testFilterArguments() + { + $arguments = array('key', 0, 1); + $expected = array('key', 0, 1); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse() + { + $this->assertTrue($this->getCommand()->parseResponse(true)); + } + + /** + * @group disconnected + */ + public function testPrefixKeys() + { + $arguments = array('key', 0, 1); + $expected = array('prefix:key', 0, 1); + + $command = $this->getCommandWithArgumentsArray($arguments); + $command->prefixKeys('prefix:'); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testPrefixKeysIgnoredOnEmptyArguments() + { + $command = $this->getCommand(); + $command->prefixKeys('prefix:'); + + $this->assertSame(array(), $command->getArguments()); + } + + /** + * @group connected + */ + public function testTrimsListWithPositiveStartAndStop() + { + $redis = $this->getClient(); + + $redis->rpush('letters', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'l'); + + $this->assertTrue($redis->ltrim('letters', 0, 2)); + $this->assertSame(array('a', 'b', 'c'), $redis->lrange('letters', 0, -1)); + + $redis->flushdb(); + $redis->rpush('letters', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'l'); + + $this->assertTrue($redis->ltrim('letters', 5, 9)); + $this->assertSame(array('f', 'g', 'h', 'i', 'l'), $redis->lrange('letters', 0, -1)); + } + + /** + * @group connected + */ + public function testTrimsListWithPositiveStartAndNegativeStop() + { + $redis = $this->getClient(); + + $redis->rpush('letters', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'l'); + + $this->assertTrue($redis->ltrim('letters', 0, -6)); + $this->assertSame(array('a', 'b', 'c', 'd', 'e'), $redis->lrange('letters', 0, -1)); + } + + /** + * @group connected + */ + public function testTrimsListWithNegativeStartAndStop() + { + $redis = $this->getClient(); + + $redis->rpush('letters', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'l'); + + $this->assertTrue($redis->ltrim('letters', -5, -5)); + $this->assertSame(array('f'), $redis->lrange('letters', 0, -1)); + } + + /** + * @group connected + */ + public function testHandlesStartAndStopOverflow() + { + $redis = $this->getClient(); + + $redis->rpush('letters', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'l'); + + $this->assertTrue($redis->ltrim('letters', -100, 100)); + $this->assertSame(array('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'l'), $redis->lrange('letters', -100, 100)); + } + + /** + * @group connected + * @expectedException Predis\ServerException + * @expectedExceptionMessage Operation against a key holding the wrong kind of value + */ + public function testThrowsExceptionOnWrongType() + { + $redis = $this->getClient(); + + $redis->set('metavars', 'foo'); + $redis->ltrim('metavars', 0, 1); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/PrefixHelpersTest.php b/vendor/predis/predis/tests/Predis/Command/PrefixHelpersTest.php new file mode 100755 index 0000000..ae5a8d3 --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/PrefixHelpersTest.php @@ -0,0 +1,84 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +use PredisTestCase; + +/** + * + */ +class PrefixHelpersTest extends PredisTestCase +{ + /** + * @group disconnected + */ + public function testPrefixFirst() + { + $arguments = array('1st', '2nd', '3rd', '4th'); + $expected = array('prefix:1st', '2nd', '3rd', '4th'); + + $command = $this->getMockForAbstractClass('Predis\Command\AbstractCommand'); + $command->setRawArguments($arguments); + + PrefixHelpers::first($command, 'prefix:'); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testPrefixAll() + { + $arguments = array('1st', '2nd', '3rd', '4th'); + $expected = array('prefix:1st', 'prefix:2nd', 'prefix:3rd', 'prefix:4th'); + + $command = $this->getMockForAbstractClass('Predis\Command\AbstractCommand'); + $command->setRawArguments($arguments); + + PrefixHelpers::all($command, 'prefix:'); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testPrefixInterleaved() + { + $arguments = array('1st', '2nd', '3rd', '4th'); + $expected = array('prefix:1st', '2nd', 'prefix:3rd', '4th'); + + $command = $this->getMockForAbstractClass('Predis\Command\AbstractCommand'); + $command->setRawArguments($arguments); + + PrefixHelpers::interleaved($command, 'prefix:'); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testPrefixSkipLast() + { + $arguments = array('1st', '2nd', '3rd', '4th'); + $expected = array('prefix:1st', 'prefix:2nd', 'prefix:3rd', '4th'); + + $command = $this->getMockForAbstractClass('Predis\Command\AbstractCommand'); + $command->setRawArguments($arguments); + + PrefixHelpers::skipLast($command, 'prefix:'); + + $this->assertSame($expected, $command->getArguments()); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/PrefixableCommandTest.php b/vendor/predis/predis/tests/Predis/Command/PrefixableCommandTest.php new file mode 100755 index 0000000..0da6662 --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/PrefixableCommandTest.php @@ -0,0 +1,54 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +use PredisTestCase; + +/** + * + */ +class PrefixableCommandTest extends PredisTestCase +{ + /** + * @group disconnected + */ + public function testImplementsCorrectInterface() + { + $command = $this->getMockForAbstractClass('Predis\Command\PrefixableCommand'); + + $this->assertInstanceOf('Predis\Command\PrefixableCommandInterface', $command); + $this->assertInstanceOf('Predis\Command\CommandInterface', $command); + } + + /** + * @group disconnected + */ + public function testAddPrefixToFirstArgument() + { + $command = $this->getMockForAbstractClass('Predis\Command\PrefixableCommand'); + $command->setRawArguments(array('key', 'value')); + $command->prefixKeys('prefix:'); + + $this->assertSame(array('prefix:key', 'value'), $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testDoesNotBreakOnEmptyArguments() + { + $command = $this->getMockForAbstractClass('Predis\Command\PrefixableCommand'); + $command->prefixKeys('prefix:'); + + $this->assertEmpty($command->getArguments()); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/Processor/KeyPrefixProcessorTest.php b/vendor/predis/predis/tests/Predis/Command/Processor/KeyPrefixProcessorTest.php new file mode 100755 index 0000000..10c3fd9 --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/Processor/KeyPrefixProcessorTest.php @@ -0,0 +1,111 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command\Processor; + +use PredisTestCase; + +/** + * + */ +class KeyPrefixProcessorTest extends PredisTestCase +{ + /** + * @group disconnected + */ + public function testConstructorWithPrefix() + { + $prefix = 'prefix:'; + $processor = new KeyPrefixProcessor($prefix); + + $this->assertInstanceOf('Predis\Command\Processor\CommandProcessorInterface', $processor); + $this->assertEquals($prefix, $processor->getPrefix()); + } + + /** + * @group disconnected + */ + public function testChangePrefix() + { + $prefix1 = 'prefix:'; + $prefix2 = 'prefix:new:'; + + $processor = new KeyPrefixProcessor($prefix1); + $this->assertEquals($prefix1, $processor->getPrefix()); + + $processor->setPrefix($prefix2); + $this->assertEquals($prefix2, $processor->getPrefix()); + } + + /** + * @group disconnected + */ + public function testProcessPrefixableCommands() + { + $prefix = 'prefix:'; + + $command = $this->getMock('Predis\Command\PrefixableCommand'); + $command->expects($this->once()) + ->method('prefixKeys') + ->with($prefix); + $command->expects($this->once()) + ->method('getArguments') + ->will($this->returnValue('key')); + + $processor = new KeyPrefixProcessor($prefix); + + $processor->process($command); + } + + /** + * @group disconnected + */ + public function testSkipPrefixableCommandsWithNoArguments() + { + $prefix = 'prefix:'; + + $command = $this->getMock('Predis\Command\PrefixableCommand'); + $command->expects($this->never()) + ->method('prefixKeys'); + + $processor = new KeyPrefixProcessor($prefix); + + $processor->process($command); + } + + /** + * @group disconnected + */ + public function testSkipNotPrefixableCommands() + { + $prefix = 'prefix:'; + $unprefixed = 'key'; + $expected = "$prefix$unprefixed"; + + $command = $this->getMock('Predis\Command\CommandInterface'); + $command->expects($this->never())->method('prefixKeys'); + + $processor = new KeyPrefixProcessor($prefix); + + $processor->process($command); + } + + /** + * @group disconnected + */ + public function testInstanceCanBeCastedToString() + { + $prefix = 'prefix:'; + $processor = new KeyPrefixProcessor($prefix); + + $this->assertEquals($prefix, (string) $processor); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/Processor/ProcessorChainTest.php b/vendor/predis/predis/tests/Predis/Command/Processor/ProcessorChainTest.php new file mode 100755 index 0000000..55264f5 --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/Processor/ProcessorChainTest.php @@ -0,0 +1,170 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command\Processor; + +use PredisTestCase; + +/** + * + */ +class ProcessorChainTest extends PredisTestCase +{ + /** + * @group disconnected + */ + public function testConstructor() + { + $chain = new ProcessorChain(); + + $this->assertInstanceOf('Predis\Command\Processor\CommandProcessorInterface', $chain); + $this->assertInstanceOf('Predis\Command\Processor\CommandProcessorChainInterface', $chain); + $this->assertEmpty($chain->getProcessors()); + } + + /** + * @group disconnected + */ + public function testConstructorWithProcessorsArray() + { + $processors = array( + $this->getMock('Predis\Command\Processor\CommandProcessorInterface'), + $this->getMock('Predis\Command\Processor\CommandProcessorInterface'), + ); + + $chain = new ProcessorChain($processors); + + $this->assertSame($processors, $chain->getProcessors()); + } + + /** + * @group disconnected + */ + public function testCountProcessors() + { + $processors = array( + $this->getMock('Predis\Command\Processor\CommandProcessorInterface'), + $this->getMock('Predis\Command\Processor\CommandProcessorInterface'), + ); + + $chain = new ProcessorChain($processors); + + $this->assertEquals(2, $chain->count()); + } + + /** + * @group disconnected + */ + public function testAddProcessors() + { + $processors = array( + $this->getMock('Predis\Command\Processor\CommandProcessorInterface'), + $this->getMock('Predis\Command\Processor\CommandProcessorInterface'), + ); + + $chain = new ProcessorChain(); + $chain->add($processors[0]); + $chain->add($processors[1]); + + $this->assertSame($processors, $chain->getProcessors()); + } + + /** + * @group disconnected + */ + public function testAddMoreProcessors() + { + $processors1 = array( + $this->getMock('Predis\Command\Processor\CommandProcessorInterface'), + $this->getMock('Predis\Command\Processor\CommandProcessorInterface'), + ); + + $processors2 = array( + $this->getMock('Predis\Command\Processor\CommandProcessorInterface'), + $this->getMock('Predis\Command\Processor\CommandProcessorInterface'), + ); + + $chain = new ProcessorChain($processors1); + $chain->add($processors2[0]); + $chain->add($processors2[1]); + + $this->assertSame(array_merge($processors1, $processors2), $chain->getProcessors()); + } + + /** + * @group disconnected + */ + public function testRemoveProcessors() + { + $processors = array( + $this->getMock('Predis\Command\Processor\CommandProcessorInterface'), + $this->getMock('Predis\Command\Processor\CommandProcessorInterface'), + ); + + $chain = new ProcessorChain($processors); + + $chain->remove($processors[0]); + $this->assertSame(array($processors[1]), $chain->getProcessors()); + + $chain->remove($processors[1]); + $this->assertEmpty($chain->getProcessors()); + } + + /** + * @group disconnected + */ + public function testRemoveProcessorNotInChain() + { + $processor = $this->getMock('Predis\Command\Processor\CommandProcessorInterface'); + $processors = array( + $this->getMock('Predis\Command\Processor\CommandProcessorInterface'), + $this->getMock('Predis\Command\Processor\CommandProcessorInterface'), + ); + + $chain = new ProcessorChain($processors); + $chain->remove($processor); + + $this->assertSame($processors, $chain->getProcessors()); + } + + /** + * @group disconnected + */ + public function testRemoveProcessorFromEmptyChain() + { + $processor = $this->getMock('Predis\Command\Processor\CommandProcessorInterface'); + + $chain = new ProcessorChain(); + $this->assertEmpty($chain->getProcessors()); + + $chain->remove($processor); + $this->assertEmpty($chain->getProcessors()); + } + + /** + * @group disconnected + */ + public function testProcessChain() + { + $command = $this->getMock('Predis\Command\CommandInterface'); + + $processor1 = $this->getMock('Predis\Command\Processor\CommandProcessorInterface'); + $processor1->expects($this->once())->method('process')->with($command); + + $processor2 = $this->getMock('Predis\Command\Processor\CommandProcessorInterface'); + $processor2->expects($this->once())->method('process')->with($command); + + $processors = array($processor1, $processor2); + + $chain = new ProcessorChain($processors); + $chain->process($command); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/PubSubPublishTest.php b/vendor/predis/predis/tests/Predis/Command/PubSubPublishTest.php new file mode 100755 index 0000000..3196f18 --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/PubSubPublishTest.php @@ -0,0 +1,96 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @group commands + * @group realm-pubsub + */ +class PubSubPublishTest extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return 'Predis\Command\PubSubPublish'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return 'PUBLISH'; + } + + /** + * @group disconnected + */ + public function testFilterArguments() + { + $arguments = array('channel', 'message'); + $expected = array('channel', 'message'); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse() + { + $this->assertSame(1, $this->getCommand()->parseResponse(1)); + } + + /** + * @group disconnected + */ + public function testPrefixKeys() + { + $arguments = array('channel', 'message'); + $expected = array('prefix:channel', 'message'); + + $command = $this->getCommandWithArgumentsArray($arguments); + $command->prefixKeys('prefix:'); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testPrefixKeysIgnoredOnEmptyArguments() + { + $command = $this->getCommand(); + $command->prefixKeys('prefix:'); + + $this->assertSame(array(), $command->getArguments()); + } + + /** + * @group connected + */ + public function testPublishesMessagesToChannel() + { + $redis1 = $this->getClient(); + $redis2 = $this->getClient(); + + $redis1->subscribe('channel:foo'); + + $this->assertSame(1, $redis2->publish('channel:foo', 'bar')); + $this->assertSame(0, $redis2->publish('channel:hoge', 'piyo')); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/PubSubSubscribeByPatternTest.php b/vendor/predis/predis/tests/Predis/Command/PubSubSubscribeByPatternTest.php new file mode 100755 index 0000000..f384206 --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/PubSubSubscribeByPatternTest.php @@ -0,0 +1,182 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @group commands + * @group realm-pubsub + */ +class PubSubSubscribeByPatternTest extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return 'Predis\Command\PubSubSubscribeByPattern'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return 'PSUBSCRIBE'; + } + + /** + * @group disconnected + */ + public function testFilterArguments() + { + $arguments = array('channel:foo:*', 'channel:hoge:*'); + $expected = array('channel:foo:*', 'channel:hoge:*'); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testFilterArgumentsAsSingleArray() + { + $arguments = array(array('channel:foo:*', 'channel:hoge:*')); + $expected = array('channel:foo:*', 'channel:hoge:*'); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse() + { + $raw = array('psubscribe', 'channel:*', 1); + $expected = array('psubscribe', 'channel:*', 1); + + $command = $this->getCommand(); + + $this->assertSame($expected, $command->parseResponse($raw)); + } + + /** + * @group disconnected + */ + public function testPrefixKeys() + { + $arguments = array('channel:foo:*', 'channel:hoge:*'); + $expected = array('prefix:channel:foo:*', 'prefix:channel:hoge:*'); + + $command = $this->getCommandWithArgumentsArray($arguments); + $command->prefixKeys('prefix:'); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testPrefixKeysIgnoredOnEmptyArguments() + { + $command = $this->getCommand(); + $command->prefixKeys('prefix:'); + + $this->assertSame(array(), $command->getArguments()); + } + + /** + * @group connected + */ + public function testReturnsTheFirstPsubscribedChannelDetails() + { + $redis = $this->getClient(); + + $this->assertSame(array('psubscribe', 'channel:*', 1), $redis->psubscribe('channel:*')); + } + + /** + * @group connected + */ + public function testCanSendPsubscribeAfterPsubscribe() + { + $redis = $this->getClient(); + + $this->assertSame(array('psubscribe', 'channel:foo:*', 1), $redis->psubscribe('channel:foo:*')); + $this->assertSame(array('psubscribe', 'channel:hoge:*', 2), $redis->psubscribe('channel:hoge:*')); + } + + /** + * @group connected + */ + public function testCanSendSubscribeAfterPsubscribe() + { + $redis = $this->getClient(); + + $this->assertSame(array('psubscribe', 'channel:foo:*', 1), $redis->psubscribe('channel:foo:*')); + $this->assertSame(array('subscribe', 'channel:foo:bar', 2), $redis->subscribe('channel:foo:bar')); + } + + /** + * @group connected + */ + public function testCanSendUnsubscribeAfterPsubscribe() + { + $redis = $this->getClient(); + + $this->assertSame(array('psubscribe', 'channel:foo:*', 1), $redis->psubscribe('channel:foo:*')); + $this->assertSame(array('psubscribe', 'channel:hoge:*', 2), $redis->psubscribe('channel:hoge:*')); + $this->assertSame(array('unsubscribe', 'channel:foo:bar', 2), $redis->unsubscribe('channel:foo:bar')); + } + + /** + * @group connected + */ + public function testCanSendPunsubscribeAfterPsubscribe() + { + $redis = $this->getClient(); + + $this->assertSame(array('psubscribe', 'channel:foo:*', 1), $redis->psubscribe('channel:foo:*')); + $this->assertSame(array('psubscribe', 'channel:hoge:*', 2), $redis->psubscribe('channel:hoge:*')); + $this->assertSame(array('punsubscribe', 'channel:*:*', 2), $redis->punsubscribe('channel:*:*')); + } + + /** + * @group connected + */ + public function testCanSendQuitAfterPsubscribe() + { + $redis = $this->getClient(); + $quit = $this->getProfile()->createCommand('quit'); + + $this->assertSame(array('subscribe', 'channel1', 1), $redis->subscribe('channel1')); + $this->assertTrue($redis->executeCommand($quit)); + } + + /** + * @group connected + * @expectedException Predis\ServerException + * @expectedExceptionMessage ERR only (P)SUBSCRIBE / (P)UNSUBSCRIBE / QUIT allowed in this context + */ + public function testCannotSendOtherCommandsAfterPsubscribe() + { + $redis = $this->getClient(); + + $redis->psubscribe('channel:*'); + $redis->set('foo', 'bar'); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/PubSubSubscribeTest.php b/vendor/predis/predis/tests/Predis/Command/PubSubSubscribeTest.php new file mode 100755 index 0000000..47f02fd --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/PubSubSubscribeTest.php @@ -0,0 +1,182 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @group commands + * @group realm-pubsub + */ +class PubSubSubscribeTest extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return 'Predis\Command\PubSubSubscribe'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return 'SUBSCRIBE'; + } + + /** + * @group disconnected + */ + public function testFilterArguments() + { + $arguments = array('channel:foo', 'channel:bar'); + $expected = array('channel:foo', 'channel:bar'); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testFilterArgumentsAsSingleArray() + { + $arguments = array(array('channel:foo', 'channel:bar')); + $expected = array('channel:foo', 'channel:bar'); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse() + { + $raw = array('subscribe', 'channel', 1); + $expected = array('subscribe', 'channel', 1); + + $command = $this->getCommand(); + + $this->assertSame($expected, $command->parseResponse($raw)); + } + + /** + * @group disconnected + */ + public function testPrefixKeys() + { + $arguments = array(array('channel:foo', 'channel:bar')); + $expected = array('prefix:channel:foo', 'prefix:channel:bar'); + + $command = $this->getCommandWithArgumentsArray($arguments); + $command->prefixKeys('prefix:'); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testPrefixKeysIgnoredOnEmptyArguments() + { + $command = $this->getCommand(); + $command->prefixKeys('prefix:'); + + $this->assertSame(array(), $command->getArguments()); + } + + /** + * @group connected + */ + public function testReturnsTheFirstSubscribedChannelDetails() + { + $redis = $this->getClient(); + + $this->assertSame(array('subscribe', 'channel', 1), $redis->subscribe('channel')); + } + + /** + * @group connected + */ + public function testCanSendSubscribeAfterSubscribe() + { + $redis = $this->getClient(); + + $this->assertSame(array('subscribe', 'channel:foo', 1), $redis->subscribe('channel:foo')); + $this->assertSame(array('subscribe', 'channel:bar', 2), $redis->subscribe('channel:bar')); + } + + /** + * @group connected + */ + public function testCanSendPsubscribeAfterSubscribe() + { + $redis = $this->getClient(); + + $this->assertSame(array('subscribe', 'channel:foo', 1), $redis->subscribe('channel:foo')); + $this->assertSame(array('psubscribe', 'channel:*', 2), $redis->psubscribe('channel:*')); + } + + /** + * @group connected + */ + public function testCanSendUnsubscribeAfterSubscribe() + { + $redis = $this->getClient(); + + $this->assertSame(array('subscribe', 'channel:foo', 1), $redis->subscribe('channel:foo')); + $this->assertSame(array('subscribe', 'channel:bar', 2), $redis->subscribe('channel:bar')); + $this->assertSame(array('unsubscribe', 'channel:foo', 1), $redis->unsubscribe('channel:foo')); + } + + /** + * @group connected + */ + public function testCanSendPunsubscribeAfterSubscribe() + { + $redis = $this->getClient(); + + $this->assertSame(array('subscribe', 'channel:foo', 1), $redis->subscribe('channel:foo')); + $this->assertSame(array('subscribe', 'channel:bar', 2), $redis->subscribe('channel:bar')); + $this->assertSame(array('punsubscribe', 'channel:*', 2), $redis->punsubscribe('channel:*')); + } + + /** + * @group connected + */ + public function testCanSendQuitAfterSubscribe() + { + $redis = $this->getClient(); + $quit = $this->getProfile()->createCommand('quit'); + + $this->assertSame(array('subscribe', 'channel:foo', 1), $redis->subscribe('channel:foo')); + $this->assertTrue($redis->executeCommand($quit)); + } + + /** + * @group connected + * @expectedException Predis\ServerException + * @expectedExceptionMessage ERR only (P)SUBSCRIBE / (P)UNSUBSCRIBE / QUIT allowed in this context + */ + public function testCannotSendOtherCommandsAfterSubscribe() + { + $redis = $this->getClient(); + + $redis->subscribe('channel:foo'); + $redis->set('foo', 'bar'); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/PubSubUnsubscribeByPatternTest.php b/vendor/predis/predis/tests/Predis/Command/PubSubUnsubscribeByPatternTest.php new file mode 100755 index 0000000..bbb1923 --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/PubSubUnsubscribeByPatternTest.php @@ -0,0 +1,150 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @group commands + * @group realm-pubsub + */ +class PubSubUnsubscribeByPatternTest extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return 'Predis\Command\PubSubUnsubscribeByPattern'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return 'PUNSUBSCRIBE'; + } + + /** + * @group disconnected + */ + public function testFilterArguments() + { + $arguments = array('channel:foo:*', 'channel:bar:*'); + $expected = array('channel:foo:*', 'channel:bar:*'); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testFilterArgumentsAsSingleArray() + { + $arguments = array(array('channel:foo:*', 'channel:bar:*')); + $expected = array('channel:foo:*', 'channel:bar:*'); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse() + { + $raw = array('punsubscribe', 'channel:*', 1); + $expected = array('punsubscribe', 'channel:*', 1); + + $command = $this->getCommand(); + + $this->assertSame($expected, $command->parseResponse($raw)); + } + + /** + * @group disconnected + */ + public function testPrefixKeys() + { + $arguments = array(array('channel:foo:*', 'channel:bar:*')); + $expected = array('prefix:channel:foo:*', 'prefix:channel:bar:*'); + + $command = $this->getCommandWithArgumentsArray($arguments); + $command->prefixKeys('prefix:'); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testPrefixKeysIgnoredOnEmptyArguments() + { + $command = $this->getCommand(); + $command->prefixKeys('prefix:'); + + $this->assertSame(array(), $command->getArguments()); + } + + /** + * @group connected + */ + public function testDoesNotSwitchToSubscribeMode() + { + $redis = $this->getClient(); + + $this->assertSame(array('punsubscribe', 'channel:*', 0), $redis->punsubscribe('channel:*')); + $this->assertSame('echoed', $redis->echo('echoed')); + } + + /** + * @group connected + */ + public function testUnsubscribesFromNotSubscribedChannels() + { + $redis = $this->getClient(); + + $this->assertSame(array('punsubscribe', 'channel:*', 0), $redis->punsubscribe('channel:*')); + } + + /** + * @group connected + */ + public function testUnsubscribesFromSubscribedChannels() + { + $redis = $this->getClient(); + + $this->assertSame(array('subscribe', 'channel:foo', 1), $redis->subscribe('channel:foo')); + $this->assertSame(array('subscribe', 'channel:bar', 2), $redis->subscribe('channel:bar')); + $this->assertSame(array('punsubscribe', 'channel:*', 2), $redis->punsubscribe('channel:*')); + } + + /** + * @group connected + * @todo Disabled for now, must investigate why this test hangs on PUNSUBSCRIBE. + */ + public function __testUnsubscribesFromAllSubscribedChannels() + { + $redis = $this->getClient(); + + $this->assertSame(array('subscribe', 'channel:foo', 1), $redis->subscribe('channel:foo')); + $this->assertSame(array('subscribe', 'channel:bar', 2), $redis->subscribe('channel:bar')); + + $this->assertSame(array('punsubscribe', 'channel:foo', 1), $redis->punsubscribe()); + $this->assertSame(array('punsubscribe', 'channel:bar', 0), $redis->getConnection()->read()); + $this->assertSame('echoed', $redis->echo('echoed')); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/PubSubUnsubscribeTest.php b/vendor/predis/predis/tests/Predis/Command/PubSubUnsubscribeTest.php new file mode 100755 index 0000000..c93927d --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/PubSubUnsubscribeTest.php @@ -0,0 +1,150 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @group commands + * @group realm-pubsub + */ +class PubSubUnsubscribeTest extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return 'Predis\Command\PubSubUnsubscribe'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return 'UNSUBSCRIBE'; + } + + /** + * @group disconnected + */ + public function testFilterArguments() + { + $arguments = array('channel1', 'channel2', 'channel3'); + $expected = array('channel1', 'channel2', 'channel3'); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testFilterArgumentsAsSingleArray() + { + $arguments = array(array('channel1', 'channel2', 'channel3')); + $expected = array('channel1', 'channel2', 'channel3'); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse() + { + $raw = array('unsubscribe', 'channel', 1); + $expected = array('unsubscribe', 'channel', 1); + + $command = $this->getCommand(); + + $this->assertSame($expected, $command->parseResponse($raw)); + } + + /** + * @group disconnected + */ + public function testPrefixKeys() + { + $arguments = array(array('channel1', 'channel2', 'channel3')); + $expected = array('prefix:channel1', 'prefix:channel2', 'prefix:channel3'); + + $command = $this->getCommandWithArgumentsArray($arguments); + $command->prefixKeys('prefix:'); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testPrefixKeysIgnoredOnEmptyArguments() + { + $command = $this->getCommand(); + $command->prefixKeys('prefix:'); + + $this->assertSame(array(), $command->getArguments()); + } + + /** + * @group connected + */ + public function testDoesNotSwitchToSubscribeMode() + { + $redis = $this->getClient(); + + $this->assertSame(array('unsubscribe', 'channel', 0), $redis->unsubscribe('channel')); + $this->assertSame('echoed', $redis->echo('echoed')); + } + + /** + * @group connected + */ + public function testUnsubscribesFromNotSubscribedChannels() + { + $redis = $this->getClient(); + + $this->assertSame(array('unsubscribe', 'channel', 0), $redis->unsubscribe('channel')); + } + + /** + * @group connected + */ + public function testUnsubscribesFromSubscribedChannels() + { + $redis = $this->getClient(); + + $this->assertSame(array('subscribe', 'channel', 1), $redis->subscribe('channel')); + $this->assertSame(array('unsubscribe', 'channel', 0), $redis->unsubscribe('channel')); + } + + /** + * @group connected + */ + public function testUnsubscribesFromAllSubscribedChannels() + { + $redis = $this->getClient(); + + $this->assertSame(array('subscribe', 'channel:foo', 1), $redis->subscribe('channel:foo')); + $this->assertSame(array('subscribe', 'channel:bar', 2), $redis->subscribe('channel:bar')); + + list($_, $unsubscribed1, $_) = $redis->unsubscribe(); + list($_, $unsubscribed2, $_) = $redis->getConnection()->read(); + $this->assertSameValues(array('channel:foo', 'channel:bar'), array($unsubscribed1, $unsubscribed2)); + + $this->assertSame('echoed', $redis->echo('echoed')); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/RawCommandTest.php b/vendor/predis/predis/tests/Predis/Command/RawCommandTest.php new file mode 100755 index 0000000..9a758dc --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/RawCommandTest.php @@ -0,0 +1,151 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +use PredisTestCase; + +/** + * + */ +class RawCommandTest extends PredisTestCase +{ + /** + * @group disconnected + */ + public function testConstructorWithCommandID() + { + $commandID = 'PING'; + $command = new RawCommand(array($commandID)); + + $this->assertSame($commandID, $command->getId()); + $this->assertEmpty($command->getArguments()); + } + + /** + * @group disconnected + */ + public function testConstructorWithCommandIDAndArguments() + { + $commandID = 'SET'; + $commandArgs = array('foo', 'bar'); + + $command = new RawCommand(array_merge((array) $commandID, $commandArgs)); + + $this->assertSame($commandID, $command->getId()); + $this->assertSame($commandArgs, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testStaticCreate() + { + $command = RawCommand::create('SET'); + $this->assertSame('SET', $command->getId()); + $this->assertEmpty($command->getArguments()); + + $command = RawCommand::create('SET', 'foo', 'bar'); + $this->assertSame('SET', $command->getId()); + $this->assertSame(array('foo', 'bar'), $command->getArguments()); + } + + /** + * @group disconnected + * @expectedException InvalidArgumentException + * @expectedExceptionMessage Arguments array is missing the command ID + */ + public function testExceptionOnMissingCommandID() + { + $command = new RawCommand(array()); + } + + /** + * @group disconnected + * @expectedException PHPUnit_Framework_Error_Warning + * @expectedExceptionMessage Missing argument 1 for Predis\Command\RawCommand::create() + */ + public function testPHPWarningOnMissingCommandIDWithStaticCreate() + { + RawCommand::create(); + } + + /** + * @group disconnected + */ + public function testSetArguments() + { + $commandID = 'SET'; + $command = new RawCommand(array($commandID)); + + $command->setArguments($commandArgs = array('foo', 'bar')); + $this->assertSame($commandArgs, $command->getArguments()); + + $command->setArguments($commandArgs = array('hoge', 'piyo')); + $this->assertSame($commandArgs, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testSetRawArguments() + { + $commandID = 'SET'; + $command = new RawCommand(array($commandID)); + + $command->setRawArguments($commandArgs = array('foo', 'bar')); + $this->assertSame($commandArgs, $command->getArguments()); + + $command->setRawArguments($commandArgs = array('hoge', 'piyo')); + $this->assertSame($commandArgs, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testSetAndGetHash() + { + $hash = "key-hash"; + $arguments = array('SET', 'key', 'value'); + $command = new RawCommand($arguments); + + $this->assertNull($command->getHash()); + + $command->setHash($hash); + $this->assertSame($hash, $command->getHash()); + + $command->setArguments(array('hoge', 'piyo')); + $this->assertNull($command->getHash()); + } + + /** + * @group disconnected + */ + public function testNormalizesCommandIdentifiersToUppercase() + { + $command = new RawCommand(array('set', 'key', 'value')); + + $this->assertSame('SET', $command->getId()); + } + + /** + * @group disconnected + */ + public function testToString() + { + $arguments = array('SET', 'key', 'value'); + $expected = implode(' ', $arguments); + + $command = new RawCommand($arguments); + + $this->assertEquals($expected, (string) $command); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/ScriptedCommandTest.php b/vendor/predis/predis/tests/Predis/Command/ScriptedCommandTest.php new file mode 100755 index 0000000..b370928 --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/ScriptedCommandTest.php @@ -0,0 +1,200 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +use PredisTestCase; + +/** + * @group realm-scripting + */ +class ScriptedCommandTest extends PredisTestCase +{ + const LUA_SCRIPT = 'return { KEYS[1], KEYS[2], ARGV[1], ARGV[2] }'; + const LUA_SCRIPT_SHA1 = '6e07f61f502e36d123fe28523076af588f5c315e'; + + /** + * @group disconnected + */ + public function testGetArguments() + { + $arguments = array('key1', 'key2', 'value1', 'value2'); + + $command = $this->getMock('Predis\Command\ScriptedCommand', array('getScript', 'getKeysCount')); + $command->expects($this->once()) + ->method('getScript') + ->will($this->returnValue(self::LUA_SCRIPT)); + $command->expects($this->once()) + ->method('getKeysCount') + ->will($this->returnValue(2)); + $command->setArguments($arguments); + + $this->assertSame(array_merge(array(self::LUA_SCRIPT_SHA1, 2), $arguments), $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testGetArgumentsWithNegativeKeysCount() + { + $arguments = array('key1', 'key2', 'value1', 'value2'); + + $command = $this->getMock('Predis\Command\ScriptedCommand', array('getScript', 'getKeysCount')); + $command->expects($this->once()) + ->method('getScript') + ->will($this->returnValue(self::LUA_SCRIPT)); + $command->expects($this->once()) + ->method('getKeysCount') + ->will($this->returnValue(-2)); + $command->setArguments($arguments); + + $this->assertSame(array_merge(array(self::LUA_SCRIPT_SHA1, 2), $arguments), $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testGetArgumentsWithZeroKeysCount() + { + $arguments = array('value1', 'value2', 'value3'); + + $command = $this->getMock('Predis\Command\ScriptedCommand', array('getScript', 'getKeysCount')); + $command->expects($this->once()) + ->method('getScript') + ->will($this->returnValue(self::LUA_SCRIPT)); + $command->expects($this->once()) + ->method('getKeysCount') + ->will($this->returnValue(0)); + $command->setArguments($arguments); + + $this->assertSame(array_merge(array(self::LUA_SCRIPT_SHA1, 0), $arguments), $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testGetKeys() + { + $arguments = array('key1', 'key2', 'value1', 'value2'); + + $command = $this->getMock('Predis\Command\ScriptedCommand', array('getScript', 'getKeysCount')); + $command->expects($this->once()) + ->method('getScript') + ->will($this->returnValue(self::LUA_SCRIPT)); + $command->expects($this->exactly(2)) + ->method('getKeysCount') + ->will($this->returnValue(2)); + $command->setArguments($arguments); + + $this->assertSame(array('key1', 'key2'), $command->getKeys()); + } + + /** + * @group disconnected + */ + public function testGetKeysWithZeroKeysCount() + { + $arguments = array('value1', 'value2', 'value3'); + + $command = $this->getMock('Predis\Command\ScriptedCommand', array('getScript', 'getKeysCount')); + $command->expects($this->once()) + ->method('getScript') + ->will($this->returnValue(self::LUA_SCRIPT)); + $command->expects($this->exactly(2)) + ->method('getKeysCount') + ->will($this->returnValue(0)); + $command->setArguments($arguments); + + $this->assertSame(array(), $command->getKeys()); + } + + /** + * @group disconnected + */ + public function testGetKeysWithNegativeKeysCount() + { + $arguments = array('key1', 'key2', 'value1', 'value2'); + + $command = $this->getMock('Predis\Command\ScriptedCommand', array('getScript', 'getKeysCount')); + $command->expects($this->once()) + ->method('getScript') + ->will($this->returnValue(self::LUA_SCRIPT)); + $command->expects($this->exactly(2)) + ->method('getKeysCount') + ->will($this->returnValue(-2)); + $command->setArguments($arguments); + + $this->assertSame(array('key1', 'key2'), $command->getKeys()); + } + + /** + * @group disconnected + */ + public function testPrefixKeys() + { + $arguments = array('foo', 'hoge', 'bar', 'piyo'); + $expected = array('prefix:foo', 'prefix:hoge'); + + $command = $this->getMock('Predis\Command\ScriptedCommand', array('getScript', 'getKeysCount')); + $command->expects($this->once()) + ->method('getScript') + ->will($this->returnValue(self::LUA_SCRIPT)); + $command->expects($this->exactly(2)) + ->method('getKeysCount') + ->will($this->returnValue(2)); + $command->setArguments($arguments); + + $command->prefixKeys('prefix:'); + + $this->assertSame($expected, $command->getKeys()); + } + + /** + * @group disconnected + */ + public function testPrefixKeysWithNegativeKeysCount() + { + $arguments = array('foo', 'hoge', 'bar', 'piyo'); + $expected = array('prefix:foo', 'prefix:hoge'); + + $command = $this->getMock('Predis\Command\ScriptedCommand', array('getScript', 'getKeysCount')); + $command->expects($this->once()) + ->method('getScript') + ->will($this->returnValue(self::LUA_SCRIPT)); + $command->expects($this->exactly(2)) + ->method('getKeysCount') + ->will($this->returnValue(-2)); + $command->setArguments($arguments); + + $command->prefixKeys('prefix:'); + + $this->assertSame($expected, $command->getKeys()); + } + + /** + * @group disconnected + */ + public function testGetScriptHash() + { + $arguments = array('key1', 'key2', 'value1', 'value2'); + + $command = $this->getMock('Predis\Command\ScriptedCommand', array('getScript', 'getKeysCount')); + $command->expects($this->once()) + ->method('getScript') + ->will($this->returnValue(self::LUA_SCRIPT)); + $command->expects($this->once()) + ->method('getKeysCount') + ->will($this->returnValue(2)); + $command->setArguments($arguments); + + $this->assertSame(self::LUA_SCRIPT_SHA1, $command->getScriptHash()); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/ServerBackgroundRewriteAOFTest.php b/vendor/predis/predis/tests/Predis/Command/ServerBackgroundRewriteAOFTest.php new file mode 100755 index 0000000..9706f11 --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/ServerBackgroundRewriteAOFTest.php @@ -0,0 +1,54 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @group commands + * @group realm-server + */ +class ServerBackgroundRewriteAOFTest extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return 'Predis\Command\ServerBackgroundRewriteAOF'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return 'BGREWRITEAOF'; + } + + /** + * @group disconnected + */ + public function testFilterArguments() + { + $command = $this->getCommand(); + $command->setArguments(array()); + + $this->assertSame(array(), $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse() + { + $this->assertTrue($this->getCommand()->parseResponse(true)); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/ServerBackgroundSaveTest.php b/vendor/predis/predis/tests/Predis/Command/ServerBackgroundSaveTest.php new file mode 100755 index 0000000..54d3b2f --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/ServerBackgroundSaveTest.php @@ -0,0 +1,54 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @group commands + * @group realm-server + */ +class ServerBackgroundSaveTest extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return 'Predis\Command\ServerBackgroundSave'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return 'BGSAVE'; + } + + /** + * @group disconnected + */ + public function testFilterArguments() + { + $command = $this->getCommand(); + $command->setArguments(array()); + + $this->assertSame(array(), $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse() + { + $this->assertTrue($this->getCommand()->parseResponse(true)); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/ServerClientTest.php b/vendor/predis/predis/tests/Predis/Command/ServerClientTest.php new file mode 100755 index 0000000..db053de --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/ServerClientTest.php @@ -0,0 +1,221 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @group commands + * @group realm-server + */ +class ServerClientTest extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return 'Predis\Command\ServerClient'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return 'CLIENT'; + } + + /** + * @group disconnected + */ + public function testFilterArgumentsOfClientKill() + { + $arguments = array('kill', '127.0.0.1:45393'); + $expected = array('kill', '127.0.0.1:45393'); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testFilterArgumentsOfClientList() + { + $arguments = array('list'); + $expected = array('list'); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testFilterArgumentsOfClientGetname() + { + $arguments = $expected = array('getname'); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testFilterArgumentsOfClientSetname() + { + $arguments = $expected = array('setname', 'connection-a'); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponseOfClientKill() + { + $command = $this->getCommand(); + $command->setArguments(array('kill')); + + $this->assertSame(true, $command->parseResponse(true)); + } + + /** + * @group disconnected + */ + public function testParseResponseOfClientList() + { + $command = $this->getCommand(); + $command->setArguments(array('list')); + + $raw =<<'127.0.0.1:45393','fd'=>'6','idle'=>'0','flags'=>'N','db'=>'0','sub'=>'0','psub'=>'0'), + array('addr'=>'127.0.0.1:45394','fd'=>'7','idle'=>'0','flags'=>'N','db'=>'0','sub'=>'0','psub'=>'0'), + array('addr'=>'127.0.0.1:45395','fd'=>'8','idle'=>'0','flags'=>'N','db'=>'0','sub'=>'0','psub'=>'0'), + ); + + $this->assertSame($parsed, $command->parseResponse($raw)); + } + + /** + * @group connected + */ + public function testReturnsListOfConnectedClients() + { + $redis = $this->getClient(); + + $this->assertInternalType('array', $clients = $redis->client('LIST')); + $this->assertGreaterThanOrEqual(1, count($clients)); + $this->assertInternalType('array', $clients[0]); + $this->assertArrayHasKey('addr', $clients[0]); + $this->assertArrayHasKey('fd', $clients[0]); + $this->assertArrayHasKey('idle', $clients[0]); + $this->assertArrayHasKey('flags', $clients[0]); + $this->assertArrayHasKey('db', $clients[0]); + $this->assertArrayHasKey('sub', $clients[0]); + $this->assertArrayHasKey('psub', $clients[0]); + } + + /** + * @group connected + */ + public function testGetsNameOfConnection() + { + $this->markTestSkippedOnRedisVersionBelow('2.6.9'); + + $redis = $this->getClient(); + $clientName = $redis->client('GETNAME'); + $this->assertNull($clientName); + + $expectedConnectionName = 'foo-bar'; + $this->assertTrue($redis->client('SETNAME', $expectedConnectionName)); + $this->assertEquals($expectedConnectionName, $redis->client('GETNAME')); + } + + /** + * @group connected + */ + public function testSetsNameOfConnection() + { + $this->markTestSkippedOnRedisVersionBelow('2.6.9'); + + $redis = $this->getClient(); + + $expectedConnectionName = 'foo-baz'; + $this->assertTrue($redis->client('SETNAME', $expectedConnectionName)); + $this->assertEquals($expectedConnectionName, $redis->client('GETNAME')); + } + + /** + * @return array + */ + public function invalidConnectionNameProvider() + { + return array( + array('foo space'), + array('foo \n'), + array('foo $'), + ); + } + + /** + * @group connected + * @expectedException Predis\ServerException + * @dataProvider invalidConnectionNameProvider + */ + public function testInvalidSetNameOfConnection($invalidConnectionName) + { + $this->markTestSkippedOnRedisVersionBelow('2.6.9'); + + $redis = $this->getClient(); + $redis->client('SETNAME', $invalidConnectionName); + } + + /** + * @group connected + * @expectedException Predis\ServerException + */ + public function testThrowsExceptioOnWrongModifier() + { + $redis = $this->getClient(); + + $this->assertTrue($redis->client('FOO')); + } + + /** + * @group connected + * @expectedException Predis\ServerException + * @expectedExceptionMessage ERR No such client + */ + public function testThrowsExceptionWhenKillingUnknownClient() + { + $redis = $this->getClient(); + + $this->assertTrue($redis->client('KILL', '127.0.0.1:65535')); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/ServerConfigTest.php b/vendor/predis/predis/tests/Predis/Command/ServerConfigTest.php new file mode 100755 index 0000000..e27e092 --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/ServerConfigTest.php @@ -0,0 +1,171 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @group commands + * @group realm-server + */ +class ServerConfigTest extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return 'Predis\Command\ServerConfig'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return 'CONFIG'; + } + + /** + * @group disconnected + */ + public function testFilterArguments() + { + $arguments = array('GET', 'slowlog'); + $expected = array('GET', 'slowlog'); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponseOfConfigGet() + { + $raw = array('slowlog-log-slower-than','10000','slowlog-max-len','64','loglevel','verbose'); + $expected = array( + 'slowlog-log-slower-than' => '10000', + 'slowlog-max-len' => '64', + 'loglevel' => 'verbose', + ); + + $command = $this->getCommand(); + + $this->assertSame($expected, $command->parseResponse($raw)); + } + + /** + * @group disconnected + */ + public function testParseResponseOfConfigSet() + { + $command = $this->getCommand(); + + $this->assertTrue($command->parseResponse(true)); + } + + /** + * @group disconnected + */ + public function testParseResponseOfConfigResetstat() + { + $command = $this->getCommand(); + + $this->assertTrue($command->parseResponse(true)); + } + + /** + * @group connected + */ + public function testReturnsListOfConfigurationValues() + { + $redis = $this->getClient(); + + $this->assertInternalType('array', $configs = $redis->config('GET', '*')); + $this->assertGreaterThan(1, count($configs)); + $this->assertArrayHasKey('loglevel', $configs); + $this->assertArrayHasKey('appendonly', $configs); + $this->assertArrayHasKey('dbfilename', $configs); + } + + /** + * @group connected + */ + public function testReturnsListOfOneConfigurationEntry() + { + $redis = $this->getClient(); + + $this->assertInternalType('array', $configs = $redis->config('GET', 'dbfilename')); + $this->assertEquals(1, count($configs)); + $this->assertArrayHasKey('dbfilename', $configs); + } + + /** + * @group connected + */ + public function testReturnsEmptyListOnUnknownConfigurationEntry() + { + $redis = $this->getClient(); + + $this->assertSame(array(), $redis->config('GET', 'foobar')); + } + + /** + * @group connected + */ + public function testReturnsTrueOnSuccessfulConfiguration() + { + $redis = $this->getClient(); + + $previous = $redis->config('GET', 'loglevel'); + + $this->assertTrue($redis->config('SET', 'loglevel', 'notice')); + $this->assertSame(array('loglevel' => 'notice'), $redis->config('GET', 'loglevel')); + + // We set the loglevel configuration to the previous value. + $redis->config('SET', 'loglevel', $previous['loglevel']); + } + + /** + * @group connected + * @expectedException Predis\ServerException + * @expectedExceptionMessage ERR Unsupported CONFIG parameter: foo + */ + public function testThrowsExceptionWhenSettingUnknownConfiguration() + { + $redis = $this->getClient(); + + $this->assertFalse($redis->config('SET', 'foo', 'bar')); + } + + /** + * @group connected + */ + public function testReturnsTrueOnResetstat() + { + $redis = $this->getClient(); + + $this->assertTrue($redis->config('RESETSTAT')); + } + + /** + * @group connected + * @expectedException Predis\ServerException + */ + public function testThrowsExceptionOnUnknownSubcommand() + { + $redis = $this->getClient(); + + $this->assertFalse($redis->config('FOO')); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/ServerDatabaseSizeTest.php b/vendor/predis/predis/tests/Predis/Command/ServerDatabaseSizeTest.php new file mode 100755 index 0000000..b984e37 --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/ServerDatabaseSizeTest.php @@ -0,0 +1,65 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @group commands + * @group realm-server + */ +class ServerDatabaseSizeTest extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return 'Predis\Command\ServerDatabaseSize'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return 'DBSIZE'; + } + + /** + * @group disconnected + */ + public function testFilterArguments() + { + $command = $this->getCommand(); + $command->setArguments(array()); + + $this->assertSame(array(), $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse() + { + $this->assertSame(100, $this->getCommand()->parseResponse(100)); + } + + /** + * @group connected + */ + public function testReturnsCurrentSizeOfDatabase() + { + $redis = $this->getClient(); + + $redis->set('foo', 'bar'); + $this->assertGreaterThan(0, $redis->dbsize()); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/ServerEvalSHATest.php b/vendor/predis/predis/tests/Predis/Command/ServerEvalSHATest.php new file mode 100755 index 0000000..3f52317 --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/ServerEvalSHATest.php @@ -0,0 +1,136 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @group commands + * @group realm-scripting + */ +class ServerEvalSHATest extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return 'Predis\Command\ServerEvalSHA'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return 'EVALSHA'; + } + + /** + * @group disconnected + */ + public function testFilterArguments() + { + $arguments = array('9d0c0826bde023cc39eebaaf832c32a890f3b088', 1, 'foo', 'bar'); + $expected = array('9d0c0826bde023cc39eebaaf832c32a890f3b088', 1, 'foo', 'bar'); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse() + { + $command = $this->getCommand(); + + $this->assertSame('bar', $this->getCommand()->parseResponse('bar')); + } + + /** + * @group disconnected + */ + public function testPrefixKeys() + { + $sha1 = 'a42059b356c875f0717db19a51f6aaca9ae659ea'; + + $arguments = array($sha1, 2, 'foo', 'hoge', 'bar', 'piyo'); + $expected = array($sha1, 2, 'prefix:foo', 'prefix:hoge', 'bar', 'piyo'); + + $command = $this->getCommandWithArgumentsArray($arguments); + $command->prefixKeys('prefix:'); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testPrefixKeysIgnoredOnEmptyArguments() + { + $command = $this->getCommand(); + $command->prefixKeys('prefix:'); + + $this->assertSame(array(), $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testGetScriptHash() + { + $command = $this->getCommandWithArgumentsArray(array($sha1 = sha1('return true')), 0); + $this->assertSame($sha1, $command->getScriptHash()); + } + + /** + * @group connected + */ + public function testExecutesSpecifiedLuaScript() + { + $redis = $this->getClient(); + + $lua = 'return {KEYS[1],KEYS[2],ARGV[1],ARGV[2]}'; + $sha1 = sha1($lua); + $result = array('foo', 'hoge', 'bar', 'piyo'); + + $this->assertSame($result, $redis->eval($lua, 2, 'foo', 'hoge', 'bar', 'piyo')); + $this->assertSame($result, $redis->evalsha($sha1, 2, 'foo', 'hoge', 'bar', 'piyo')); + } + + /** + * @group connected + * @expectedException Predis\ServerException + */ + public function testThrowsExceptionOnWrongNumberOfKeys() + { + $redis = $this->getClient(); + + $lua = 'return {KEYS[1],KEYS[2],ARGV[1],ARGV[2]}'; + $sha1 = sha1($lua); + + $redis->eval($lua, 2, 'foo', 'hoge', 'bar', 'piyo'); + $redis->evalsha($sha1, 3, 'foo', 'hoge'); + } + + /** + * @group connected + * @expectedException Predis\ServerException + */ + public function testThrowsExceptionOnInvalidScript() + { + $redis = $this->getClient(); + + $redis->evalsha('ffffffffffffffffffffffffffffffffffffffff', 0); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/ServerEvalTest.php b/vendor/predis/predis/tests/Predis/Command/ServerEvalTest.php new file mode 100755 index 0000000..02a1b03 --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/ServerEvalTest.php @@ -0,0 +1,131 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @group commands + * @group realm-scripting + */ +class ServerEvalTest extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return 'Predis\Command\ServerEval'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return 'EVAL'; + } + + /** + * @group disconnected + */ + public function testFilterArguments() + { + $arguments = array('return redis.call("SET", KEYS[1], ARGV[1])', 1, 'foo', 'bar'); + $expected = array('return redis.call("SET", KEYS[1], ARGV[1])', 1, 'foo', 'bar'); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse() + { + $command = $this->getCommand(); + + $this->assertSame('bar', $this->getCommand()->parseResponse('bar')); + } + + /** + * @group disconnected + */ + public function testPrefixKeys() + { + $lua = 'return {KEYS[1],KEYS[2],ARGV[1],ARGV[2]}'; + + $arguments = array($lua, 2, 'foo', 'hoge', 'bar', 'piyo'); + $expected = array($lua, 2, 'prefix:foo', 'prefix:hoge', 'bar', 'piyo'); + + $command = $this->getCommandWithArgumentsArray($arguments); + $command->prefixKeys('prefix:'); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testPrefixKeysIgnoredOnEmptyArguments() + { + $command = $this->getCommand(); + $command->prefixKeys('prefix:'); + + $this->assertSame(array(), $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testGetScriptHash() + { + $command = $this->getCommandWithArgumentsArray(array($lua = 'return true', 0)); + $this->assertSame(sha1($lua), $command->getScriptHash()); + } + + /** + * @group connected + */ + public function testExecutesSpecifiedLuaScript() + { + $redis = $this->getClient(); + + $lua = 'return {KEYS[1],KEYS[2],ARGV[1],ARGV[2]}'; + $result = array('foo', 'hoge', 'bar', 'piyo'); + + $this->assertSame($result, $redis->eval($lua, 2, 'foo', 'hoge', 'bar', 'piyo')); + } + + /** + * @group connected + * @expectedException Predis\ServerException + */ + public function testThrowsExceptionOnWrongNumberOfKeys() + { + $redis = $this->getClient(); + $lua = 'return {KEYS[1],KEYS[2],ARGV[1],ARGV[2]}'; + + $redis->eval($lua, 3, 'foo', 'hoge'); + } + + /** + * @group connected + * @expectedException Predis\ServerException + */ + public function testThrowsExceptionOnInvalidScript() + { + $redis = $this->getClient(); + + $redis->eval('invalid', 0); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/ServerFlushAllTest.php b/vendor/predis/predis/tests/Predis/Command/ServerFlushAllTest.php new file mode 100755 index 0000000..6122e5d --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/ServerFlushAllTest.php @@ -0,0 +1,54 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @group commands + * @group realm-server + */ +class ServerFlushAllTest extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return 'Predis\Command\ServerFlushAll'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return 'FLUSHALL'; + } + + /** + * @group disconnected + */ + public function testFilterArguments() + { + $command = $this->getCommand(); + $command->setArguments(array()); + + $this->assertSame(array(), $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse() + { + $this->assertTrue($this->getCommand()->parseResponse(true)); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/ServerFlushDatabaseTest.php b/vendor/predis/predis/tests/Predis/Command/ServerFlushDatabaseTest.php new file mode 100755 index 0000000..cb206f8 --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/ServerFlushDatabaseTest.php @@ -0,0 +1,67 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @group commands + * @group realm-server + */ +class ServerFlushDatabaseTest extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return 'Predis\Command\ServerFlushDatabase'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return 'FLUSHDB'; + } + + /** + * @group disconnected + */ + public function testFilterArguments() + { + $command = $this->getCommand(); + $command->setArguments(array()); + + $this->assertSame(array(), $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse() + { + $this->assertTrue($this->getCommand()->parseResponse(true)); + } + + /** + * @group connected + */ + public function testFlushesTheEntireLogicalDatabase() + { + $redis = $this->getClient(); + + $redis->set('foo', 'bar'); + + $this->assertTrue($redis->flushdb()); + $this->assertFalse($redis->exists('foo')); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/ServerInfoTest.php b/vendor/predis/predis/tests/Predis/Command/ServerInfoTest.php new file mode 100755 index 0000000..20c36e8 --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/ServerInfoTest.php @@ -0,0 +1,287 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @group commands + * @group realm-server + */ +class ServerInfoTest extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return 'Predis\Command\ServerInfo'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return 'INFO'; + } + + /** + * @group disconnected + */ + public function testFilterArguments() + { + $command = $this->getCommand(); + $command->setArguments(array()); + + $this->assertSame(array(), $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse() + { + $raw =<< '2.4.4', + 'redis_git_sha1' => 'bc62bc5e', + 'redis_git_dirty' => '0', + 'arch_bits' => '32', + 'multiplexing_api' => 'epoll', + 'process_id' => '15640', + 'uptime_in_seconds' => '792', + 'uptime_in_days' => '0', + 'lru_clock' => '197890', + 'used_cpu_sys' => '0.08', + 'used_cpu_user' => '0.10', + 'used_cpu_sys_children' => '0.00', + 'used_cpu_user_children' => '0.00', + 'connected_clients' => '1', + 'connected_slaves' => '0', + 'client_longest_output_list' => '0', + 'client_biggest_input_buf' => '0', + 'blocked_clients' => '0', + 'used_memory' => '556156', + 'used_memory_human' => '543.12K', + 'used_memory_rss' => '1396736', + 'used_memory_peak' => '547688', + 'used_memory_peak_human' => '534.85K', + 'mem_fragmentation_ratio' => '2.51', + 'mem_allocator' => 'jemalloc-2.2.1', + 'loading' => '0', + 'aof_enabled' => '0', + 'changes_since_last_save' => '0', + 'bgsave_in_progress' => '0', + 'last_save_time' => '1323183872', + 'bgrewriteaof_in_progress' => '0', + 'total_connections_received' => '2', + 'total_commands_processed' => '1', + 'expired_keys' => '0', + 'evicted_keys' => '0', + 'keyspace_hits' => '0', + 'keyspace_misses' => '0', + 'pubsub_channels' => '0', + 'pubsub_patterns' => '0', + 'latest_fork_usec' => '0', + 'vm_enabled' => '0', + 'role' => 'master', + 'db0' => array('keys' => '2', 'expires' => '0'), + 'db5' => array('keys' => '1', 'expires' => '0'), + ); + + $this->assertSame($expected, $this->getCommand()->parseResponse($raw)); + } + + /** + * @group disconnected + */ + public function testCanParseResponsesFromRedis30() + { + $raw =<< '2.9.0', + 'redis_git_sha1' => '237194b7', + 'redis_git_dirty' => '0', + 'arch_bits' => '32', + 'multiplexing_api' => 'epoll', + 'process_id' => '16620', + 'tcp_port' => '6379', + 'uptime_in_seconds' => '444', + 'uptime_in_days' => '0', + 'lru_clock' => '198040', + 'connected_clients' => '1', + 'client_longest_output_list' => '0', + 'client_biggest_input_buf' => '0', + 'blocked_clients' => '0', + 'used_memory' => '628076', + 'used_memory_human' => '613.36K', + 'used_memory_rss' => '1568768', + 'used_memory_peak' => '570056', + 'used_memory_peak_human' => '556.70K', + 'used_memory_lua' => '14336', + 'mem_fragmentation_ratio' => '2.50', + 'mem_allocator' => 'jemalloc-2.2.1', + 'loading' => '0', + 'aof_enabled' => '0', + 'changes_since_last_save' => '0', + 'bgsave_in_progress' => '0', + 'last_save_time' => '1323185719', + 'bgrewriteaof_in_progress' => '0', + 'total_connections_received' => '4', + 'total_commands_processed' => '3', + 'rejected_connections' => '0', + 'expired_keys' => '0', + 'evicted_keys' => '0', + 'keyspace_hits' => '0', + 'keyspace_misses' => '0', + 'pubsub_channels' => '0', + 'pubsub_patterns' => '0', + 'latest_fork_usec' => '0', + 'role' => 'master', + 'connected_slaves' => '0', + 'used_cpu_sys' => '0.06', + 'used_cpu_user' => '0.06', + 'used_cpu_sys_children' => '0.00', + 'used_cpu_user_children' => '0.00', + 'cluster_enabled' => '0', + 'db0' => array('keys' => '2', 'expires' => '0'), + 'db5' => array('keys' => '1','expires' => '0'), + ); + + $this->assertSame($expected, $this->getCommand()->parseResponse($raw)); + } + + /** + * @group connected + */ + public function testReturnsAnArrayOfInfo() + { + $redis = $this->getClient(); + $command = $this->getCommand(); + + $this->assertInternalType('array', $info = $redis->executeCommand($command)); + $this->assertArrayHasKey('redis_version', $info); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/ServerInfoV26xTest.php b/vendor/predis/predis/tests/Predis/Command/ServerInfoV26xTest.php new file mode 100755 index 0000000..a9a89b6 --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/ServerInfoV26xTest.php @@ -0,0 +1,305 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @group commands + * @group realm-server + */ +class ServerInfoV26xTest extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return 'Predis\Command\ServerInfoV26x'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return 'INFO'; + } + + /** + * @group disconnected + */ + public function testFilterArguments() + { + $command = $this->getCommand(); + $command->setArguments(array()); + + $this->assertSame(array(), $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse() + { + $raw =<< array( + 'redis_version' => '2.9.0', + 'redis_git_sha1' => '237194b7', + 'redis_git_dirty' => '0', + 'arch_bits' => '32', + 'multiplexing_api' => 'epoll', + 'process_id' => '16620', + 'tcp_port' => '6379', + 'uptime_in_seconds' => '444', + 'uptime_in_days' => '0', + 'lru_clock' => '198040', + ), + 'Clients' => array( + 'connected_clients' => '1', + 'client_longest_output_list' => '0', + 'client_biggest_input_buf' => '0', + 'blocked_clients' => '0', + ), + 'Memory' => array( + 'used_memory' => '628076', + 'used_memory_human' => '613.36K', + 'used_memory_rss' => '1568768', + 'used_memory_peak' => '570056', + 'used_memory_peak_human' => '556.70K', + 'used_memory_lua' => '14336', + 'mem_fragmentation_ratio' => '2.50', + 'mem_allocator' => 'jemalloc-2.2.1', + ), + 'Persistence' => array( + 'loading' => '0', + 'aof_enabled' => '0', + 'changes_since_last_save' => '0', + 'bgsave_in_progress' => '0', + 'last_save_time' => '1323185719', + 'bgrewriteaof_in_progress' => '0', + ), + 'Stats' => array( + 'total_connections_received' => '4', + 'total_commands_processed' => '3', + 'rejected_connections' => '0', + 'expired_keys' => '0', + 'evicted_keys' => '0', + 'keyspace_hits' => '0', + 'keyspace_misses' => '0', + 'pubsub_channels' => '0', + 'pubsub_patterns' => '0', + 'latest_fork_usec' => '0', + ), + 'Replication' => array( + 'role' => 'master', + 'connected_slaves' => '0', + ), + 'CPU' => array( + 'used_cpu_sys' => '0.06', + 'used_cpu_user' => '0.06', + 'used_cpu_sys_children' => '0.00', + 'used_cpu_user_children' => '0.00', + ), + 'Cluster' => array( + 'cluster_enabled' => '0', + ), + 'Keyspace' => array( + 'db0' => array('keys' => '2', 'expires' => '0'), + 'db5' => array('keys' => '1', 'expires' => '0') + ), + ); + + $this->assertSame($expected, $this->getCommand()->parseResponse($raw)); + } + + /** + * @group disconnected + */ + public function testCanParseResponsesFromOlderRedisVersions() + { + $raw =<< '2.4.4', + 'redis_git_sha1' => 'bc62bc5e', + 'redis_git_dirty' => '0', + 'arch_bits' => '32', + 'multiplexing_api' => 'epoll', + 'process_id' => '15640', + 'uptime_in_seconds' => '792', + 'uptime_in_days' => '0', + 'lru_clock' => '197890', + 'used_cpu_sys' => '0.08', + 'used_cpu_user' => '0.10', + 'used_cpu_sys_children' => '0.00', + 'used_cpu_user_children' => '0.00', + 'connected_clients' => '1', + 'connected_slaves' => '0', + 'client_longest_output_list' => '0', + 'client_biggest_input_buf' => '0', + 'blocked_clients' => '0', + 'used_memory' => '556156', + 'used_memory_human' => '543.12K', + 'used_memory_rss' => '1396736', + 'used_memory_peak' => '547688', + 'used_memory_peak_human' => '534.85K', + 'mem_fragmentation_ratio' => '2.51', + 'mem_allocator' => 'jemalloc-2.2.1', + 'loading' => '0', + 'aof_enabled' => '0', + 'changes_since_last_save' => '0', + 'bgsave_in_progress' => '0', + 'last_save_time' => '1323183872', + 'bgrewriteaof_in_progress' => '0', + 'total_connections_received' => '2', + 'total_commands_processed' => '1', + 'expired_keys' => '0', + 'evicted_keys' => '0', + 'keyspace_hits' => '0', + 'keyspace_misses' => '0', + 'pubsub_channels' => '0', + 'pubsub_patterns' => '0', + 'latest_fork_usec' => '0', + 'vm_enabled' => '0', + 'role' => 'master', + 'db0' => array('keys' => '2', 'expires' => '0'), + 'db5' => array('keys' => '1', 'expires' => '0'), + ); + + $this->assertSame($expected, $this->getCommand()->parseResponse($raw)); + } + + /** + * @group connected + */ + public function testReturnsAnArrayOfInfo() + { + $redis = $this->getClient(); + $command = $this->getCommand(); + + $this->assertInternalType('array', $info = $redis->executeCommand($command)); + $this->assertArrayHasKey('redis_version', isset($info['Server']) ? $info['Server'] : $info); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/ServerLastSaveTest.php b/vendor/predis/predis/tests/Predis/Command/ServerLastSaveTest.php new file mode 100755 index 0000000..f051127 --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/ServerLastSaveTest.php @@ -0,0 +1,64 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @group commands + * @group realm-server + */ +class ServerLastSaveTest extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return 'Predis\Command\ServerLastSave'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return 'LASTSAVE'; + } + + /** + * @group disconnected + */ + public function testFilterArguments() + { + $command = $this->getCommand(); + $command->setArguments(array()); + + $this->assertSame(array(), $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse() + { + $this->assertSame(100, $this->getCommand()->parseResponse(100)); + } + + /** + * @group connected + */ + public function testReturnsIntegerValue() + { + $redis = $this->getClient(); + + $this->assertInternalType('integer', $redis->lastsave()); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/ServerMonitorTest.php b/vendor/predis/predis/tests/Predis/Command/ServerMonitorTest.php new file mode 100755 index 0000000..01bd6aa --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/ServerMonitorTest.php @@ -0,0 +1,72 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @group commands + * @group realm-server + * @group realm-monitor + */ +class ServerMonitorTest extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return 'Predis\Command\ServerMonitor'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return 'MONITOR'; + } + + /** + * @group disconnected + */ + public function testFilterArguments() + { + $command = $this->getCommand(); + $command->setArguments(array()); + + $this->assertSame(array(), $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse() + { + $this->assertTrue($this->getCommand()->parseResponse(true)); + } + + /** + * @group connected + */ + public function testReturnsTrueAndReadsEventsFromTheConnection() + { + $connection = $this->getClient()->getConnection(); + $command = $this->getCommand(); + + $this->assertTrue($connection->executeCommand($command)); + + // NOTE: Starting with 2.6 Redis does not return the "MONITOR" message after + // +OK to the client that issued the MONITOR command. + if (version_compare($this->getProfile()->getVersion(), '2.4', '<=')) { + $this->assertRegExp('/\d+.\d+(\s?\(db \d+\))? "MONITOR"/', $connection->read()); + } + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/ServerObjectTest.php b/vendor/predis/predis/tests/Predis/Command/ServerObjectTest.php new file mode 100755 index 0000000..1e4572b --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/ServerObjectTest.php @@ -0,0 +1,113 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @group commands + * @group realm-server + */ +class ServerObjectTest extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return 'Predis\Command\ServerObject'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return 'OBJECT'; + } + + /** + * @group disconnected + */ + public function testFilterArguments() + { + $arguments = array('REFCOUNT', 'key'); + $expected = array('REFCOUNT', 'key'); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse() + { + $this->assertSame('ziplist', $this->getCommand()->parseResponse('ziplist')); + } + + /** + * @group connected + */ + public function testObjectRefcount() + { + $redis = $this->getClient(); + + $redis->set('foo', 'bar'); + $this->assertInternalType('integer', $redis->object('REFCOUNT', 'foo')); + } + + /** + * @group connected + */ + public function testObjectIdletime() + { + $redis = $this->getClient(); + + $redis->set('foo', 'bar'); + $this->assertInternalType('integer', $redis->object('IDLETIME', 'foo')); + } + + /** + * @group connected + */ + public function testObjectEncoding() + { + $redis = $this->getClient(); + + $redis->lpush('list:metavars', 'foo', 'bar'); + $this->assertSame('ziplist', $redis->object('ENCODING', 'list:metavars')); + } + + /** + * @group connected + */ + public function testReturnsNullOnNonExistingKey() + { + $redis = $this->getClient(); + + $this->assertNull($redis->object('REFCOUNT', 'foo')); + $this->assertNull($redis->object('IDLETIME', 'foo')); + $this->assertNull($redis->object('ENCODING', 'foo')); + } + + /** + * @group connected + * @expectedException Predis\ServerException + */ + public function testThrowsExceptionOnInvalidSubcommand() + { + $redis = $this->getClient(); + + $redis->object('INVALID', 'foo'); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/ServerSaveTest.php b/vendor/predis/predis/tests/Predis/Command/ServerSaveTest.php new file mode 100755 index 0000000..fecf1db --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/ServerSaveTest.php @@ -0,0 +1,54 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @group commands + * @group realm-server + */ +class ServerSaveTest extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return 'Predis\Command\ServerSave'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return 'SAVE'; + } + + /** + * @group disconnected + */ + public function testFilterArguments() + { + $command = $this->getCommand(); + $command->setArguments(array()); + + $this->assertSame(array(), $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse() + { + $this->assertTrue($this->getCommand()->parseResponse(true)); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/ServerScriptTest.php b/vendor/predis/predis/tests/Predis/Command/ServerScriptTest.php new file mode 100755 index 0000000..f03ab78 --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/ServerScriptTest.php @@ -0,0 +1,108 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @group commands + * @group realm-scripting + */ +class ServerScriptTest extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return 'Predis\Command\ServerScript'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return 'SCRIPT'; + } + + /** + * @group disconnected + */ + public function testFilterArguments() + { + $arguments = array('EXISTS', '9d0c0826bde023cc39eebaaf832c32a890f3b088', 'ffffffffffffffffffffffffffffffffffffffff'); + $expected = array('EXISTS', '9d0c0826bde023cc39eebaaf832c32a890f3b088', 'ffffffffffffffffffffffffffffffffffffffff'); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse() + { + $this->assertTrue($this->getCommand()->parseResponse(true)); + } + + /** + * @group connected + * @todo We should probably convert integers to booleans. + */ + public function testExistsReturnAnArrayOfValues() + { + $redis = $this->getClient(); + + $redis->eval($lua = 'return true', 0); + $sha1 = sha1($lua); + + $this->assertSame(array(1, 0), $redis->script('EXISTS', $sha1, 'ffffffffffffffffffffffffffffffffffffffff')); + } + + /** + * @group connected + */ + public function testLoadReturnsHashOfScripts() + { + $redis = $this->getClient(); + + $lua = 'return true'; + $sha1 = sha1($lua); + + $this->assertSame($sha1, $redis->script('LOAD', $lua)); + } + + /** + * @group connected + */ + public function testFlushesExistingScripts() + { + $redis = $this->getClient(); + + $sha1 = $redis->script('LOAD', 'return true'); + + $this->assertTrue($redis->script('FLUSH')); + $this->assertSame(array(0), $redis->script('EXISTS', $sha1)); + } + + /** + * @group connected + * @expectedException Predis\ServerException + */ + public function testThrowsExceptionOnInvalidSubcommand() + { + $redis = $this->getClient(); + + $redis->script('INVALID'); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/ServerShutdownTest.php b/vendor/predis/predis/tests/Predis/Command/ServerShutdownTest.php new file mode 100755 index 0000000..ced931e --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/ServerShutdownTest.php @@ -0,0 +1,46 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @group commands + * @group realm-server + */ +class ServerShutdownTest extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return 'Predis\Command\ServerShutdown'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return 'SHUTDOWN'; + } + + /** + * @group disconnected + */ + public function testFilterArguments() + { + $command = $this->getCommand(); + $command->setArguments(array()); + + $this->assertSame(array(), $command->getArguments()); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/ServerSlaveOfTest.php b/vendor/predis/predis/tests/Predis/Command/ServerSlaveOfTest.php new file mode 100755 index 0000000..f6932ff --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/ServerSlaveOfTest.php @@ -0,0 +1,85 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @group commands + * @group realm-server + */ +class ServerSlaveOfTest extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return 'Predis\Command\ServerSlaveOf'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return 'SLAVEOF'; + } + + /** + * @group disconnected + */ + public function testFilterArgumentsHostPortArray() + { + $arguments = array('127.0.0.1', '80'); + $expected = array('127.0.0.1', '80'); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testFilterArgumentsNoOneArray() + { + $arguments = array('NO', 'ONE'); + $expected = array('NO', 'ONE'); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testFilterArgumentsNoOneString() + { + $arguments = array('NO ONE'); + $expected = array('NO', 'ONE'); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse() + { + $this->assertTrue($this->getCommand()->parseResponse(true)); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/ServerSlowlogTest.php b/vendor/predis/predis/tests/Predis/Command/ServerSlowlogTest.php new file mode 100755 index 0000000..1590a2e --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/ServerSlowlogTest.php @@ -0,0 +1,118 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * In order to support the output of SLOWLOG, the backend connection + * must be able to parse nested multibulk replies deeper than 2 levels. + * + * @group commands + * @group realm-server + */ +class ServerSlowlogTest extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return 'Predis\Command\ServerSlowlog'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return 'SLOWLOG'; + } + + /** + * @group disconnected + */ + public function testFilterArguments() + { + $arguments = array('GET', '2'); + $expected = array('GET', '2'); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse() + { + $raw = array(array(0, 1323163469, 12451, array('SORT', 'list:unordered'))); + $expected = array( + array( + 'id' => 0, + 'timestamp' => 1323163469, + 'duration' => 12451, + 'command' => array('SORT', 'list:unordered'), + ), + ); + + $command = $this->getCommand(); + + $this->assertSame($expected, $command->parseResponse($raw)); + } + + /** + * @group connected + */ + public function testReturnsAnArrayOfLoggedCommands() + { + $redis = $this->getClient(); + + $config = $redis->config('get', 'slowlog-log-slower-than'); + $threshold = array_pop($config); + + $redis->config('set', 'slowlog-log-slower-than', 0); + $redis->set('foo', 'bar'); + + $this->assertInternalType('array', $slowlog = $redis->slowlog('GET')); + $this->assertGreaterThan(0, count($slowlog)); + + $this->assertInternalType('array', $slowlog[0]); + $this->assertGreaterThan(0, $slowlog[0]['id']); + $this->assertGreaterThan(0, $slowlog[0]['timestamp']); + $this->assertGreaterThan(0, $slowlog[0]['duration']); + $this->assertInternalType('array', $slowlog[0]['command']); + + $redis->config('set', 'slowlog-log-slower-than', $threshold); + } + + /** + * @group connected + */ + public function testCanResetTheLog() + { + $redis = $this->getClient(); + + $this->assertTrue($redis->slowlog('RESET')); + } + + /** + * @group connected + * @expectedException Predis\ServerException + */ + public function testThrowsExceptionOnInvalidSubcommand() + { + $redis = $this->getClient(); + + $redis->slowlog('INVALID'); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/ServerTimeTest.php b/vendor/predis/predis/tests/Predis/Command/ServerTimeTest.php new file mode 100755 index 0000000..41c583c --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/ServerTimeTest.php @@ -0,0 +1,72 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @group commands + * @group realm-server + */ +class ServerTimeTest extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return 'Predis\Command\ServerTime'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return 'TIME'; + } + + /** + * @group disconnected + */ + public function testFilterArguments() + { + $arguments = array(); + $expected = array(); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse() + { + $expected = array(1331114908, 453990); + $command = $this->getCommand(); + + $this->assertSame($expected, $command->parseResponse($expected)); + } + + /** + * @group connected + */ + public function testReturnsServerTime() + { + $redis = $this->getClient(); + + $this->assertInternalType('array', $time = $redis->time()); + $this->assertInternalType('string', $time[0]); + $this->assertInternalType('string', $time[1]); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/SetAddTest.php b/vendor/predis/predis/tests/Predis/Command/SetAddTest.php new file mode 100755 index 0000000..012eb29 --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/SetAddTest.php @@ -0,0 +1,121 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @group commands + * @group realm-set + */ +class SetAddTest extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return 'Predis\Command\SetAdd'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return 'SADD'; + } + + /** + * @group disconnected + */ + public function testFilterArguments() + { + $arguments = array('key', 'member1', 'member2', 'member3'); + $expected = array('key', 'member1', 'member2', 'member3'); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testFilterArgumentsValuesAsSingleArray() + { + $arguments = array('key', array('member1', 'member2', 'member3')); + $expected = array('key', 'member1', 'member2', 'member3'); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse() + { + $this->assertSame(1, $this->getCommand()->parseResponse(1)); + } + + /** + * @group disconnected + */ + public function testPrefixKeys() + { + $arguments = array('key', 'member1', 'member2', 'member3'); + $expected = array('prefix:key', 'member1', 'member2', 'member3'); + + $command = $this->getCommandWithArgumentsArray($arguments); + $command->prefixKeys('prefix:'); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testPrefixKeysIgnoredOnEmptyArguments() + { + $command = $this->getCommand(); + $command->prefixKeys('prefix:'); + + $this->assertSame(array(), $command->getArguments()); + } + + /** + * @group connected + */ + public function testAddsMembersToSet() + { + $redis = $this->getClient(); + + $this->assertSame(1, $redis->sadd('letters', 'a')); + $this->assertSame(2, $redis->sadd('letters', 'b', 'c')); + $this->assertSame(0, $redis->sadd('letters', 'b')); + } + + /** + * @group connected + * @expectedException Predis\ServerException + * @expectedExceptionMessage Operation against a key holding the wrong kind of value + */ + public function testThrowsExceptionOnWrongType() + { + $redis = $this->getClient(); + + $redis->set('metavars', 'foo'); + $redis->sadd('metavars', 'hoge'); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/SetCardinalityTest.php b/vendor/predis/predis/tests/Predis/Command/SetCardinalityTest.php new file mode 100755 index 0000000..4bc34ab --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/SetCardinalityTest.php @@ -0,0 +1,117 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @group commands + * @group realm-set + */ +class SetCardinalityTest extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return 'Predis\Command\SetCardinality'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return 'SCARD'; + } + + /** + * @group disconnected + */ + public function testFilterArguments() + { + $arguments = array('key'); + $expected = array('key'); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse() + { + $this->assertSame(1, $this->getCommand()->parseResponse(1)); + } + + /** + * @group disconnected + */ + public function testPrefixKeys() + { + $arguments = array('key'); + $expected = array('prefix:key'); + + $command = $this->getCommandWithArgumentsArray($arguments); + $command->prefixKeys('prefix:'); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testPrefixKeysIgnoredOnEmptyArguments() + { + $command = $this->getCommand(); + $command->prefixKeys('prefix:'); + + $this->assertSame(array(), $command->getArguments()); + } + + /** + * @group connected + */ + public function testReturnsNumberOfMembers() + { + $redis = $this->getClient(); + + $redis->sadd('letters', 'a', 'b', 'c', 'd'); + + $this->assertSame(4, $redis->scard('letters')); + } + + /** + * @group connected + */ + public function testReturnsZeroOnEmptySet() + { + $redis = $this->getClient(); + + $this->assertSame(0, $redis->scard('letters')); + } + + /** + * @group connected + * @expectedException Predis\ServerException + * @expectedExceptionMessage Operation against a key holding the wrong kind of value + */ + public function testThrowsExceptionOnWrongType() + { + $redis = $this->getClient(); + + $redis->set('metavars', 'foo'); + $redis->scard('metavars'); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/SetDifferenceStoreTest.php b/vendor/predis/predis/tests/Predis/Command/SetDifferenceStoreTest.php new file mode 100755 index 0000000..440d924 --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/SetDifferenceStoreTest.php @@ -0,0 +1,140 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @group commands + * @group realm-set + */ +class SetDifferenceStoreTest extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return 'Predis\Command\SetDifferenceStore'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return 'SDIFFSTORE'; + } + + /** + * @group disconnected + */ + public function testFilterArguments() + { + $arguments = array('key:destination', 'key:source1', 'key:source:2'); + $expected = array('key:destination', 'key:source1', 'key:source:2'); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testFilterArgumentsSourceKeysAsSingleArray() + { + $arguments = array('key:destination', array('key:source1', 'key:source:2')); + $expected = array('key:destination', 'key:source1', 'key:source:2'); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse() + { + $this->assertSame(1, $this->getCommand()->parseResponse(1)); + } + + /** + * @group disconnected + */ + public function testPrefixKeys() + { + $arguments = array('key:destination', 'key:source1', 'key:source:2'); + $expected = array('prefix:key:destination', 'prefix:key:source1', 'prefix:key:source:2'); + + $command = $this->getCommandWithArgumentsArray($arguments); + $command->prefixKeys('prefix:'); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testPrefixKeysIgnoredOnEmptyArguments() + { + $command = $this->getCommand(); + $command->prefixKeys('prefix:'); + + $this->assertSame(array(), $command->getArguments()); + } + + /** + * @group connected + */ + public function testStoresMembersOfSetOnSingleSet() + { + $redis = $this->getClient(); + + $redis->sadd('letters:1st', 'a', 'b', 'c', 'd', 'e', 'f', 'g'); + + $this->assertSame(7, $redis->sdiffstore('letters:destination', 'letters:1st')); + $this->assertSameValues(array( 'a', 'b', 'c', 'd', 'e', 'f', 'g'), $redis->smembers('letters:destination')); + } + + /** + * @group connected + */ + public function testStoresDifferenceOfMultipleSets() + { + $redis = $this->getClient(); + + $redis->sadd('letters:1st', 'a', 'b', 'c', 'd', 'e', 'f', 'g'); + $redis->sadd('letters:2nd', 'a', 'c', 'f', 'g'); + $redis->sadd('letters:3rd', 'a', 'b', 'e', 'f'); + + $this->assertSame(3, $redis->sdiffstore('letters:destination', 'letters:1st', 'letters:2nd')); + $this->assertSameValues(array('b', 'd', 'e'), $redis->smembers('letters:destination')); + + $this->assertSame(1, $redis->sdiffstore('letters:destination', 'letters:1st', 'letters:2nd', 'letters:3rd')); + $this->assertSameValues(array('d'), $redis->smembers('letters:destination')); + } + + /** + * @group connected + * @expectedException Predis\ServerException + * @expectedExceptionMessage Operation against a key holding the wrong kind of value + */ + public function testThrowsExceptionOnWrongTypeOfSourceKey() + { + $redis = $this->getClient(); + + $redis->set('set:source', 'foo'); + $redis->sdiffstore('set:destination', 'set:source'); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/SetDifferenceTest.php b/vendor/predis/predis/tests/Predis/Command/SetDifferenceTest.php new file mode 100755 index 0000000..0fd326e --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/SetDifferenceTest.php @@ -0,0 +1,142 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @group commands + * @group realm-set + */ +class SetDifferenceTest extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return 'Predis\Command\SetDifference'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return 'SDIFF'; + } + + /** + * @group disconnected + */ + public function testFilterArguments() + { + $arguments = array('key1', 'key2', 'key3'); + $expected = array('key1', 'key2', 'key3'); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testFilterArgumentsAsSingleArray() + { + $arguments = array(array('key1', 'key2', 'key3')); + $expected = array('key1', 'key2', 'key3'); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse() + { + $raw = array('member1', 'member2', 'member3'); + $expected = array('member1', 'member2', 'member3'); + + $command = $this->getCommand(); + + $this->assertSame($expected, $command->parseResponse($raw)); + } + + /** + * @group disconnected + */ + public function testPrefixKeys() + { + $arguments = array('key1', 'key2', 'key3'); + $expected = array('prefix:key1', 'prefix:key2', 'prefix:key3'); + + $command = $this->getCommandWithArgumentsArray($arguments); + $command->prefixKeys('prefix:'); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testPrefixKeysIgnoredOnEmptyArguments() + { + $command = $this->getCommand(); + $command->prefixKeys('prefix:'); + + $this->assertSame(array(), $command->getArguments()); + } + + /** + * @group connected + */ + public function testReturnsMembersOnSingleKeyOrNonExistingSetForDifference() + { + $redis = $this->getClient(); + + $redis->sadd('letters:1st', 'a', 'b', 'c', 'd', 'e', 'f', 'g'); + + $this->assertSameValues(array( 'a', 'b', 'c', 'd', 'e', 'f', 'g'), $redis->sdiff('letters:1st')); + $this->assertSameValues(array( 'a', 'b', 'c', 'd', 'e', 'f', 'g'), $redis->sdiff('letters:1st', 'letters:2nd')); + } + + /** + * @group connected + */ + public function testReturnsMembersFromDifferenceAmongSets() + { + $redis = $this->getClient(); + + $redis->sadd('letters:1st', 'a', 'b', 'c', 'd', 'e', 'f', 'g'); + $redis->sadd('letters:2nd', 'a', 'c', 'f', 'g'); + $redis->sadd('letters:3rd', 'a', 'b', 'e', 'f'); + + $this->assertSameValues(array('b', 'd', 'e'), $redis->sdiff('letters:1st', 'letters:2nd')); + $this->assertSameValues(array('d'), $redis->sdiff('letters:1st', 'letters:2nd', 'letters:3rd')); + } + + /** + * @group connected + * @expectedException Predis\ServerException + * @expectedExceptionMessage Operation against a key holding the wrong kind of value + */ + public function testThrowsExceptionOnWrongType() + { + $redis = $this->getClient(); + + $redis->set('set:foo', 'a'); + $redis->sdiff('set:foo'); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/SetIntersectionStoreTest.php b/vendor/predis/predis/tests/Predis/Command/SetIntersectionStoreTest.php new file mode 100755 index 0000000..30e27ed --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/SetIntersectionStoreTest.php @@ -0,0 +1,153 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @group commands + * @group realm-set + */ +class SetIntersectionStoreTest extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return 'Predis\Command\SetIntersectionStore'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return 'SINTERSTORE'; + } + + /** + * @group disconnected + */ + public function testFilterArguments() + { + $arguments = array('key:destination', 'key:source1', 'key:source:2'); + $expected = array('key:destination', 'key:source1', 'key:source:2'); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testFilterArgumentsSourceKeysAsSingleArray() + { + $arguments = array('key:destination', array('key:source1', 'key:source:2')); + $expected = array('key:destination', 'key:source1', 'key:source:2'); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse() + { + $this->assertSame(1, $this->getCommand()->parseResponse(1)); + } + + /** + * @group disconnected + */ + public function testPrefixKeys() + { + $arguments = array('key:destination', 'key:source1', 'key:source:2'); + $expected = array('prefix:key:destination', 'prefix:key:source1', 'prefix:key:source:2'); + + $command = $this->getCommandWithArgumentsArray($arguments); + $command->prefixKeys('prefix:'); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testPrefixKeysIgnoredOnEmptyArguments() + { + $command = $this->getCommand(); + $command->prefixKeys('prefix:'); + + $this->assertSame(array(), $command->getArguments()); + } + + /** + * @group connected + */ + public function testStoresMembersOfSetOnSingleKey() + { + $redis = $this->getClient(); + + $redis->sadd('letters:1st', 'a', 'b', 'c', 'd', 'e', 'f', 'g'); + + $this->assertSame(7, $redis->sinterstore('letters:destination', 'letters:1st')); + $this->assertSameValues(array( 'a', 'b', 'c', 'd', 'e', 'f', 'g'), $redis->smembers('letters:destination')); + } + + /** + * @group connected + */ + public function testDoesNotStoreOnNonExistingSetForIntersection() + { + $redis = $this->getClient(); + + $redis->sadd('letters:1st', 'a', 'b', 'c', 'd', 'e', 'f', 'g'); + + $this->assertSame(0, $redis->sinterstore('letters:destination', 'letters:1st', 'letters:2nd')); + $this->assertFalse($redis->exists('letters:destination')); + } + + /** + * @group connected + */ + public function testStoresIntersectionOfMultipleSets() + { + $redis = $this->getClient(); + + $redis->sadd('letters:1st', 'a', 'b', 'c', 'd', 'e', 'f', 'g'); + $redis->sadd('letters:2nd', 'a', 'c', 'f', 'g'); + $redis->sadd('letters:3rd', 'a', 'b', 'e', 'f'); + + $this->assertSame(4, $redis->sinterstore('letters:destination', 'letters:1st', 'letters:2nd')); + $this->assertSameValues(array('a', 'c', 'f', 'g'), $redis->smembers('letters:destination')); + + $this->assertSame(2, $redis->sinterstore('letters:destination', 'letters:1st', 'letters:2nd', 'letters:3rd')); + $this->assertSameValues(array('a', 'f'), $redis->smembers('letters:destination')); + } + + /** + * @group connected + * @expectedException Predis\ServerException + * @expectedExceptionMessage Operation against a key holding the wrong kind of value + */ + public function testThrowsExceptionOnWrongTypeOfSourceKey() + { + $redis = $this->getClient(); + + $redis->set('set:source', 'foo'); + $redis->sinterstore('set:destination', 'set:source'); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/SetIntersectionTest.php b/vendor/predis/predis/tests/Predis/Command/SetIntersectionTest.php new file mode 100755 index 0000000..b15fcdb --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/SetIntersectionTest.php @@ -0,0 +1,153 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @group commands + * @group realm-set + */ +class SetIntersectionTest extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return 'Predis\Command\SetIntersection'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return 'SINTER'; + } + + /** + * @group disconnected + */ + public function testFilterArguments() + { + $arguments = array('key1', 'key2', 'key3'); + $expected = array('key1', 'key2', 'key3'); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testFilterArgumentsAsSingleArray() + { + $arguments = array(array('key1', 'key2', 'key3')); + $expected = array('key1', 'key2', 'key3'); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse() + { + $raw = array('member1', 'member2', 'member3'); + $expected = array('member1', 'member2', 'member3'); + + $command = $this->getCommand(); + + $this->assertSame($expected, $command->parseResponse($raw)); + } + + /** + * @group disconnected + */ + public function testPrefixKeys() + { + $arguments = array('key1', 'key2', 'key3'); + $expected = array('prefix:key1', 'prefix:key2', 'prefix:key3'); + + $command = $this->getCommandWithArgumentsArray($arguments); + $command->prefixKeys('prefix:'); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testPrefixKeysIgnoredOnEmptyArguments() + { + $command = $this->getCommand(); + $command->prefixKeys('prefix:'); + + $this->assertSame(array(), $command->getArguments()); + } + + /** + * @group connected + */ + public function testReturnsMembersOfSetOnSingleKey() + { + $redis = $this->getClient(); + + $redis->sadd('letters:1st', 'a', 'b', 'c', 'd', 'e', 'f', 'g'); + + $this->assertSameValues(array('a', 'b', 'c', 'd', 'e', 'f', 'g'), $redis->sinter('letters:1st')); + } + + /** + * @group connected + */ + public function testReturnsEmptyArrayOnNonExistingSetForIntersection() + { + $redis = $this->getClient(); + + $redis->sadd('letters:1st', 'a', 'b', 'c', 'd', 'e', 'f', 'g'); + + $this->assertSameValues(array(), $redis->sinter('letters:1st', 'letters:2nd')); + } + + /** + * @group connected + */ + public function testReturnsMembersFromIntersectionAmongSets() + { + $redis = $this->getClient(); + + $redis->sadd('letters:1st', 'a', 'b', 'c', 'd', 'e', 'f', 'g'); + $redis->sadd('letters:2nd', 'a', 'c', 'f', 'g'); + $redis->sadd('letters:3rd', 'a', 'b', 'e', 'f'); + + $this->assertSameValues(array('a', 'c', 'f', 'g'), $redis->sinter('letters:1st', 'letters:2nd')); + $this->assertSameValues(array('a', 'f'), $redis->sinter('letters:1st', 'letters:2nd', 'letters:3rd')); + } + + /** + * @group connected + * @expectedException Predis\ServerException + * @expectedExceptionMessage Operation against a key holding the wrong kind of value + */ + public function testThrowsExceptionOnWrongType() + { + $redis = $this->getClient(); + + $redis->set('set:foo', 'a'); + $redis->sinter('set:foo'); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/SetIsMemberTest.php b/vendor/predis/predis/tests/Predis/Command/SetIsMemberTest.php new file mode 100755 index 0000000..c85e8c1 --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/SetIsMemberTest.php @@ -0,0 +1,121 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @group commands + * @group realm-set + */ +class SetIsMemberTest extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return 'Predis\Command\SetIsMember'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return 'SISMEMBER'; + } + + /** + * @group disconnected + */ + public function testFilterArguments() + { + $arguments = array('key', 'member'); + $expected = array('key', 'member'); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse() + { + $command = $this->getCommand(); + + $this->assertTrue($command->parseResponse(1)); + $this->assertFalse($command->parseResponse(0)); + } + + /** + * @group disconnected + */ + public function testPrefixKeys() + { + $arguments = array('key', 'member'); + $expected = array('prefix:key', 'member'); + + $command = $this->getCommandWithArgumentsArray($arguments); + $command->prefixKeys('prefix:'); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testPrefixKeysIgnoredOnEmptyArguments() + { + $command = $this->getCommand(); + $command->prefixKeys('prefix:'); + + $this->assertSame(array(), $command->getArguments()); + } + + /** + * @group connected + */ + public function testReturnsMemberExistenceInSet() + { + $redis = $this->getClient(); + + $redis->sadd('letters', 'a', 'b', 'c'); + + $this->assertTrue($redis->sismember('letters', 'a')); + $this->assertFalse($redis->sismember('letters', 'z')); + } + + /** + * @group connected + */ + public function testReturnsFalseOnNonExistingSet() + { + $redis = $this->getClient(); + + $this->assertFalse($redis->sismember('letters', 'a')); + } + + /** + * @group connected + * @expectedException Predis\ServerException + * @expectedExceptionMessage Operation against a key holding the wrong kind of value + */ + public function testThrowsExceptionOnWrongType() + { + $redis = $this->getClient(); + + $redis->set('foo', 'bar'); + $redis->sismember('foo', 'bar'); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/SetMembersTest.php b/vendor/predis/predis/tests/Predis/Command/SetMembersTest.php new file mode 100755 index 0000000..b96a9bf --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/SetMembersTest.php @@ -0,0 +1,113 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @group commands + * @group realm-set + */ +class SetMembersTest extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return 'Predis\Command\SetMembers'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return 'SMEMBERS'; + } + + /** + * @group disconnected + */ + public function testFilterArguments() + { + $arguments = array('key'); + $expected = array('key'); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse() + { + $raw = array('member1', 'member2', 'member3'); + $expected = array('member1', 'member2', 'member3'); + + $command = $this->getCommand(); + + $this->assertSame($expected, $command->parseResponse($raw)); + } + + /** + * @group disconnected + */ + public function testPrefixKeys() + { + $arguments = array('key'); + $expected = array('prefix:key'); + + $command = $this->getCommandWithArgumentsArray($arguments); + $command->prefixKeys('prefix:'); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testPrefixKeysIgnoredOnEmptyArguments() + { + $command = $this->getCommand(); + $command->prefixKeys('prefix:'); + + $this->assertSame(array(), $command->getArguments()); + } + + /** + * @group connected + */ + public function testReturnsFalseOnNonExistingSet() + { + $redis = $this->getClient(); + + $redis->sadd('letters', 'a', 'b', 'c', 'd', 'e'); + + $this->assertSameValues(array('a', 'b', 'c', 'd', 'e'), $redis->smembers('letters')); + $this->assertSame(array(), $redis->smembers('digits')); + } + + /** + * @group connected + * @expectedException Predis\ServerException + * @expectedExceptionMessage Operation against a key holding the wrong kind of value + */ + public function testThrowsExceptionOnWrongType() + { + $redis = $this->getClient(); + + $redis->set('foo', 'bar'); + $redis->smembers('foo'); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/SetMoveTest.php b/vendor/predis/predis/tests/Predis/Command/SetMoveTest.php new file mode 100755 index 0000000..9ed4c2a --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/SetMoveTest.php @@ -0,0 +1,129 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @group commands + * @group realm-set + */ +class SetMoveTest extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return 'Predis\Command\SetMove'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return 'SMOVE'; + } + + /** + * @group disconnected + */ + public function testFilterArguments() + { + $arguments = array('key:source', 'key:destination', 'member'); + $expected = array('key:source', 'key:destination', 'member'); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse() + { + $command = $this->getCommand(); + + $this->assertTrue($command->parseResponse(1)); + $this->assertFalse($command->parseResponse(0)); + } + + /** + * @group disconnected + */ + public function testPrefixKeys() + { + $arguments = array('key:source', 'key:destination', 'member'); + $expected = array('prefix:key:source', 'prefix:key:destination', 'member'); + + $command = $this->getCommandWithArgumentsArray($arguments); + $command->prefixKeys('prefix:'); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testPrefixKeysIgnoredOnEmptyArguments() + { + $command = $this->getCommand(); + $command->prefixKeys('prefix:'); + + $this->assertSame(array(), $command->getArguments()); + } + + /** + * @group connected + */ + public function testReturnsMemberExistenceInSet() + { + $redis = $this->getClient(); + + $redis->sadd('letters:source', 'a', 'b', 'c'); + + $this->assertTrue($redis->smove('letters:source', 'letters:destination', 'b')); + $this->assertFalse($redis->smove('letters:source', 'letters:destination', 'z')); + + $this->assertSameValues(array('a', 'c'), $redis->smembers('letters:source')); + $this->assertSameValues(array('b'), $redis->smembers('letters:destination')); + } + + /** + * @group connected + * @expectedException Predis\ServerException + * @expectedExceptionMessage Operation against a key holding the wrong kind of value + */ + public function testThrowsExceptionOnWrongTypeOfSourceKey() + { + $redis = $this->getClient(); + + $redis->set('set:source', 'foo'); + $redis->sadd('set:destination', 'bar'); + $redis->smove('set:destination', 'set:source', 'foo'); + } + + /** + * @group connected + * @expectedException Predis\ServerException + * @expectedExceptionMessage Operation against a key holding the wrong kind of value + */ + public function testThrowsExceptionOnWrongTypeOfDestinationKey() + { + $redis = $this->getClient(); + + $redis->sadd('set:source', 'foo'); + $redis->set('set:destination', 'bar'); + $redis->smove('set:destination', 'set:source', 'foo'); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/SetPopTest.php b/vendor/predis/predis/tests/Predis/Command/SetPopTest.php new file mode 100755 index 0000000..f577cb6 --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/SetPopTest.php @@ -0,0 +1,110 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @group commands + * @group realm-set + */ +class SetPopTest extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return 'Predis\Command\SetPop'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return 'SPOP'; + } + + /** + * @group disconnected + */ + public function testFilterArguments() + { + $arguments = array('key'); + $expected = array('key'); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse() + { + $this->assertSame('member', $this->getCommand()->parseResponse('member')); + } + + /** + * @group disconnected + */ + public function testPrefixKeys() + { + $arguments = array('key'); + $expected = array('prefix:key'); + + $command = $this->getCommandWithArgumentsArray($arguments); + $command->prefixKeys('prefix:'); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testPrefixKeysIgnoredOnEmptyArguments() + { + $command = $this->getCommand(); + $command->prefixKeys('prefix:'); + + $this->assertSame(array(), $command->getArguments()); + } + + /** + * @group connected + */ + public function testPopsRandomMemberFromSet() + { + $redis = $this->getClient(); + + $redis->sadd('letters', 'a', 'b'); + + $this->assertContains($redis->spop('letters'), array('a', 'b')); + $this->assertContains($redis->spop('letters'), array('a', 'b')); + + $this->assertNull($redis->spop('letters')); + } + + /** + * @group connected + * @expectedException Predis\ServerException + * @expectedExceptionMessage Operation against a key holding the wrong kind of value + */ + public function testThrowsExceptionOnWrongType() + { + $redis = $this->getClient(); + + $redis->set('foo', 'bar'); + $redis->spop('foo'); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/SetRandomMemberTest.php b/vendor/predis/predis/tests/Predis/Command/SetRandomMemberTest.php new file mode 100755 index 0000000..7213730 --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/SetRandomMemberTest.php @@ -0,0 +1,118 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @group commands + * @group realm-set + */ +class SetRandomMemberTest extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return 'Predis\Command\SetRandomMember'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return 'SRANDMEMBER'; + } + + /** + * @group disconnected + */ + public function testFilterArguments() + { + $arguments = array('key', 1); + $expected = array('key', 1); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse() + { + $this->assertSame('member', $this->getCommand()->parseResponse('member')); + } + + /** + * @group disconnected + */ + public function testPrefixKeys() + { + $arguments = array('key'); + $expected = array('prefix:key'); + + $command = $this->getCommandWithArgumentsArray($arguments); + $command->prefixKeys('prefix:'); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testPrefixKeysIgnoredOnEmptyArguments() + { + $command = $this->getCommand(); + $command->prefixKeys('prefix:'); + + $this->assertSame(array(), $command->getArguments()); + } + + /** + * @group connected + */ + public function testReturnsRandomMemberFromSet() + { + $redis = $this->getClient(); + + $redis->sadd('letters', 'a', 'b'); + + $this->assertContains($redis->srandmember('letters'), array('a', 'b')); + $this->assertContains($redis->srandmember('letters'), array('a', 'b')); + + $this->assertSame(2, $redis->scard('letters')); + } + + /** + * @group connected + */ + public function testReturnsNullOnNonExistingSet() + { + $this->assertNull($this->getClient()->srandmember('letters')); + } + + /** + * @group connected + * @expectedException Predis\ServerException + * @expectedExceptionMessage Operation against a key holding the wrong kind of value + */ + public function testThrowsExceptionOnWrongType() + { + $redis = $this->getClient(); + + $redis->set('foo', 'bar'); + $redis->srandmember('foo'); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/SetRemoveTest.php b/vendor/predis/predis/tests/Predis/Command/SetRemoveTest.php new file mode 100755 index 0000000..5348d72 --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/SetRemoveTest.php @@ -0,0 +1,125 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @group commands + * @group realm-set + */ +class SetRemoveTest extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return 'Predis\Command\SetRemove'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return 'SREM'; + } + + /** + * @group disconnected + */ + public function testFilterArguments() + { + $arguments = array('key', 'member1', 'member2', 'member3'); + $expected = array('key', 'member1', 'member2', 'member3'); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testFilterArgumentsMembersAsSingleArray() + { + $arguments = array('key', array('member1', 'member2', 'member3')); + $expected = array('key', 'member1', 'member2', 'member3'); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse() + { + $this->assertSame(1, $this->getCommand()->parseResponse(1)); + } + + /** + * @group disconnected + */ + public function testPrefixKeys() + { + $arguments = array('key', 'member1', 'member2', 'member3'); + $expected = array('prefix:key', 'member1', 'member2', 'member3'); + + $command = $this->getCommandWithArgumentsArray($arguments); + $command->prefixKeys('prefix:'); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testPrefixKeysIgnoredOnEmptyArguments() + { + $command = $this->getCommand(); + $command->prefixKeys('prefix:'); + + $this->assertSame(array(), $command->getArguments()); + } + + /** + * @group connected + */ + public function testRemovesMembersFromSet() + { + $redis = $this->getClient(); + + $redis->sadd('letters', 'a', 'b', 'c', 'd'); + + $this->assertSame(1, $redis->srem('letters', 'b')); + $this->assertSame(1, $redis->srem('letters', 'd', 'z')); + $this->assertSameValues(array('a', 'c'), $redis->smembers('letters')); + + $this->assertSame(0, $redis->srem('digits', 1)); + } + + /** + * @group connected + * @expectedException Predis\ServerException + * @expectedExceptionMessage Operation against a key holding the wrong kind of value + */ + public function testThrowsExceptionOnWrongType() + { + $redis = $this->getClient(); + + $redis->set('foo', 'bar'); + $redis->srem('foo', 'bar'); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/SetScanTest.php b/vendor/predis/predis/tests/Predis/Command/SetScanTest.php new file mode 100755 index 0000000..64a4fa4 --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/SetScanTest.php @@ -0,0 +1,156 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @group commands + * @group realm-set + */ +class SetScanTest extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return 'Predis\Command\SetScan'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return 'SSCAN'; + } + + /** + * @group disconnected + */ + public function testFilterArguments() + { + $arguments = array('key', 0, 'MATCH', 'member:*', 'COUNT', 10); + $expected = array('key', 0, 'MATCH', 'member:*', 'COUNT', 10); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testFilterArgumentsBasicUsage() + { + $arguments = array('key', 0); + $expected = array('key', 0); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testFilterArgumentsWithOptionsArray() + { + $arguments = array('key', 0, array('match' => 'member:*', 'count' => 10)); + $expected = array('key', 0, 'MATCH', 'member:*', 'COUNT', 10); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse() + { + $raw = array('3', array('member:1', 'member:2', 'member:3')); + $expected = array(3, array('member:1', 'member:2', 'member:3')); + + $command = $this->getCommand(); + + $this->assertSame($expected, $command->parseResponse($raw)); + } + + /** + * @group disconnected + */ + public function testPrefixKeys() + { + $arguments = array('key', '0', 'MATCH', 'member:*', 'COUNT', 10); + $expected = array('prefix:key', '0', 'MATCH', 'member:*', 'COUNT', 10); + + $command = $this->getCommandWithArgumentsArray($arguments); + $command->prefixKeys('prefix:'); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testPrefixKeysIgnoredOnEmptyArguments() + { + $command = $this->getCommand(); + $command->prefixKeys('prefix:'); + + $this->assertSame(array(), $command->getArguments()); + } + + /** + * @group connected + */ + public function testScanWithoutMatch() + { + $redis = $this->getClient(); + $redis->sadd('key', $members = array('member:one', 'member:two', 'member:three', 'member:four')); + + $response = $redis->sscan('key', 0); + + $this->assertSame(0, $response[0]); + $this->assertSameValues($members, $response[1]); + } + + /** + * @group connected + */ + public function testScanWithMatchingMembers() + { + $redis = $this->getClient(); + $redis->sadd('key', $members = array('member:one', 'member:two', 'member:three', 'member:four')); + + $response = $redis->sscan('key', 0, 'MATCH', 'member:t*'); + + $this->assertSameValues(array('member:two', 'member:three'), $response[1]); + } + + /** + * @group connected + */ + public function testScanWithNoMatchingMembers() + { + $redis = $this->getClient(); + $redis->sadd('key', $members = array('member:one', 'member:two', 'member:three', 'member:four')); + + $response = $redis->sscan('key', 0, 'MATCH', 'nomember:*'); + + $this->assertSame(0, $response[0]); + $this->assertEmpty($response[1]); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/SetUnionStoreTest.php b/vendor/predis/predis/tests/Predis/Command/SetUnionStoreTest.php new file mode 100755 index 0000000..0f4083c --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/SetUnionStoreTest.php @@ -0,0 +1,140 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @group commands + * @group realm-set + */ +class SetUnionStoreTest extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return 'Predis\Command\SetUnionStore'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return 'SUNIONSTORE'; + } + + /** + * @group disconnected + */ + public function testFilterArguments() + { + $arguments = array('key:destination', 'key:source1', 'key:source:2'); + $expected = array('key:destination', 'key:source1', 'key:source:2'); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testFilterArgumentsSourceKeysAsSingleArray() + { + $arguments = array('key:destination', array('key:source1', 'key:source:2')); + $expected = array('key:destination', 'key:source1', 'key:source:2'); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse() + { + $this->assertSame(1, $this->getCommand()->parseResponse(1)); + } + + /** + * @group disconnected + */ + public function testPrefixKeys() + { + $arguments = array('key:destination', 'key:source1', 'key:source:2'); + $expected = array('prefix:key:destination', 'prefix:key:source1', 'prefix:key:source:2'); + + $command = $this->getCommandWithArgumentsArray($arguments); + $command->prefixKeys('prefix:'); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testPrefixKeysIgnoredOnEmptyArguments() + { + $command = $this->getCommand(); + $command->prefixKeys('prefix:'); + + $this->assertSame(array(), $command->getArguments()); + } + + /** + * @group connected + */ + public function testStoresMembersOfSetOnSingleSet() + { + $redis = $this->getClient(); + + $redis->sadd('letters:1st', 'a', 'b', 'c', 'd', 'e', 'f', 'g'); + + $this->assertSame(7, $redis->sunionstore('letters:destination', 'letters:1st')); + $this->assertSameValues(array( 'a', 'b', 'c', 'd', 'e', 'f', 'g'), $redis->smembers('letters:destination')); + } + + /** + * @group connected + */ + public function testStoresUnionOfMultipleSets() + { + $redis = $this->getClient(); + + $redis->sadd('letters:1st', 'b', 'd', 'f'); + $redis->sadd('letters:2nd', 'a', 'c', 'g'); + $redis->sadd('letters:3rd', 'a', 'e', 'f'); + + $this->assertSame(5, $redis->sunionstore('letters:destination', 'letters:2nd', 'letters:3rd')); + $this->assertSameValues(array('a', 'c', 'e', 'f', 'g'), $redis->smembers('letters:destination')); + + $this->assertSame(7, $redis->sunionstore('letters:destination', 'letters:1st', 'letters:2nd', 'letters:3rd')); + $this->assertSameValues(array( 'a', 'b', 'c', 'd', 'e', 'f', 'g'), $redis->smembers('letters:destination')); + } + + /** + * @group connected + * @expectedException Predis\ServerException + * @expectedExceptionMessage Operation against a key holding the wrong kind of value + */ + public function testThrowsExceptionOnWrongTypeOfSourceKey() + { + $redis = $this->getClient(); + + $redis->set('set:source', 'foo'); + $redis->sunionstore('set:destination', 'set:source'); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/SetUnionTest.php b/vendor/predis/predis/tests/Predis/Command/SetUnionTest.php new file mode 100755 index 0000000..6f88912 --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/SetUnionTest.php @@ -0,0 +1,142 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @group commands + * @group realm-set + */ +class SetUnionTest extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return 'Predis\Command\SetUnion'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return 'SUNION'; + } + + /** + * @group disconnected + */ + public function testFilterArguments() + { + $arguments = array('key1', 'key2', 'key3'); + $expected = array('key1', 'key2', 'key3'); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testFilterArgumentsAsSingleArray() + { + $arguments = array(array('key1', 'key2', 'key3')); + $expected = array('key1', 'key2', 'key3'); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse() + { + $raw = array('member1', 'member2', 'member3'); + $expected = array('member1', 'member2', 'member3'); + + $command = $this->getCommand(); + + $this->assertSame($expected, $command->parseResponse($raw)); + } + + /** + * @group disconnected + */ + public function testPrefixKeys() + { + $arguments = array('key1', 'key2', 'key3'); + $expected = array('prefix:key1', 'prefix:key2', 'prefix:key3'); + + $command = $this->getCommandWithArgumentsArray($arguments); + $command->prefixKeys('prefix:'); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testPrefixKeysIgnoredOnEmptyArguments() + { + $command = $this->getCommand(); + $command->prefixKeys('prefix:'); + + $this->assertSame(array(), $command->getArguments()); + } + + /** + * @group connected + */ + public function testReturnsMembersOnSingleKeyOrNonExistingSetForUnion() + { + $redis = $this->getClient(); + + $redis->sadd('letters:1st', 'a', 'b', 'c', 'd', 'e', 'f', 'g'); + + $this->assertSameValues(array( 'a', 'b', 'c', 'd', 'e', 'f', 'g'), $redis->sunion('letters:1st')); + $this->assertSameValues(array( 'a', 'b', 'c', 'd', 'e', 'f', 'g'), $redis->sunion('letters:1st', 'letters:2nd')); + } + + /** + * @group connected + */ + public function testReturnsMembersFromDifferenceAmongSets() + { + $redis = $this->getClient(); + + $redis->sadd('letters:1st', 'b', 'd', 'f'); + $redis->sadd('letters:2nd', 'a', 'c', 'g'); + $redis->sadd('letters:3rd', 'a', 'e', 'f'); + + $this->assertSameValues(array('a', 'c', 'e', 'f', 'g'), $redis->sunion('letters:2nd', 'letters:3rd')); + $this->assertSameValues(array( 'a', 'b', 'c', 'd', 'e', 'f', 'g'), $redis->sunion('letters:1st', 'letters:2nd', 'letters:3rd')); + } + + /** + * @group connected + * @expectedException Predis\ServerException + * @expectedExceptionMessage Operation against a key holding the wrong kind of value + */ + public function testThrowsExceptionOnWrongType() + { + $redis = $this->getClient(); + + $redis->set('set:foo', 'a'); + $redis->sunion('set:foo'); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/StringAppendTest.php b/vendor/predis/predis/tests/Predis/Command/StringAppendTest.php new file mode 100755 index 0000000..8ed6822 --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/StringAppendTest.php @@ -0,0 +1,120 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @group commands + * @group realm-string + */ +class StringAppendTest extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return 'Predis\Command\StringAppend'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return 'APPEND'; + } + + /** + * @group disconnected + */ + public function testFilterArguments() + { + $arguments = array('key', 'value'); + $expected = array('key', 'value'); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse() + { + $this->assertSame(10, $this->getCommand()->parseResponse(10)); + } + + /** + * @group disconnected + */ + public function testPrefixKeys() + { + $arguments = array('key', 'value'); + $expected = array('prefix:key', 'value'); + + $command = $this->getCommandWithArgumentsArray($arguments); + $command->prefixKeys('prefix:'); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testPrefixKeysIgnoredOnEmptyArguments() + { + $command = $this->getCommand(); + $command->prefixKeys('prefix:'); + + $this->assertSame(array(), $command->getArguments()); + } + + /** + * @group connected + */ + public function testCreatesNewKeyOnNonExistingKey() + { + $redis = $this->getClient(); + + $this->assertSame(3, $redis->append('foo', 'bar')); + $this->assertSame('bar', $redis->get('foo')); + } + + /** + * @group connected + */ + public function testReturnsTheLenghtOfTheStringAfterAppend() + { + $redis = $this->getClient(); + + $redis->set('foo', 'bar'); + + $this->assertSame(5, $redis->append('foo', '__')); + $this->assertSame(8, $redis->append('foo', 'bar')); + $this->assertSame('bar__bar', $redis->get('foo')); + } + + /** + * @group connected + * @expectedException Predis\ServerException + * @expectedExceptionMessage Operation against a key holding the wrong kind of value + */ + public function testThrowsExceptionOnWrongType() + { + $redis = $this->getClient(); + + $redis->lpush('metavars', 'foo'); + $redis->append('metavars', 'bar'); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/StringBitCountTest.php b/vendor/predis/predis/tests/Predis/Command/StringBitCountTest.php new file mode 100755 index 0000000..f765d20 --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/StringBitCountTest.php @@ -0,0 +1,117 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @group commands + * @group realm-string + */ +class StringBitCountTest extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return 'Predis\Command\StringBitCount'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return 'BITCOUNT'; + } + + /** + * @group disconnected + */ + public function testFilterArguments() + { + $arguments = array('key', 0, 10); + $expected = array('key', 0, 10); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse() + { + $raw = 10; + $expected = 10; + + $command = $this->getCommand(); + + $this->assertSame($expected, $command->parseResponse($raw)); + } + + /** + * @group disconnected + */ + public function testPrefixKeys() + { + $arguments = array('key', 0, 10); + $expected = array('prefix:key', 0, 10); + + $command = $this->getCommandWithArgumentsArray($arguments); + $command->prefixKeys('prefix:'); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testPrefixKeysIgnoredOnEmptyArguments() + { + $command = $this->getCommand(); + $command->prefixKeys('prefix:'); + + $this->assertSame(array(), $command->getArguments()); + } + + /** + * @group connected + */ + public function testReturnsNumberOfBitsSet() + { + $redis = $this->getClient(); + + $redis->setbit('key', 1, 1); + $redis->setbit('key', 10, 1); + $redis->setbit('key', 16, 1); + $redis->setbit('key', 22, 1); + $redis->setbit('key', 32, 1); + + $this->assertSame(5, $redis->bitcount('key'), 'Count bits set (without range)'); + $this->assertSame(3, $redis->bitcount('key', 2, 4), 'Count bits set (with range)'); + } + + /** + * @group connected + * @expectedException Predis\ServerException + * @expectedExceptionMessage Operation against a key holding the wrong kind of value + */ + public function testThrowsExceptionOnWrongType() + { + $redis = $this->getClient(); + + $redis->lpush('key', 'list'); + $redis->bitcount('key'); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/StringBitOpTest.php b/vendor/predis/predis/tests/Predis/Command/StringBitOpTest.php new file mode 100755 index 0000000..8caf2ac --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/StringBitOpTest.php @@ -0,0 +1,202 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @group commands + * @group realm-string + */ +class StringBitOpTest extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return 'Predis\Command\StringBitOp'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return 'BITOP'; + } + + /** + * @group disconnected + */ + public function testFilterArguments() + { + $arguments = array('AND', 'key:dst', 'key:01', 'key:02'); + $expected = array('AND', 'key:dst', 'key:01', 'key:02'); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testFilterArgumentsKeysAsSingleArray() + { + $arguments = array('AND', 'key:dst', array('key:01', 'key:02')); + $expected = array('AND', 'key:dst', 'key:01', 'key:02'); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse() + { + $raw = 10; + $expected = 10; + + $command = $this->getCommand(); + + $this->assertSame($expected, $command->parseResponse($raw)); + } + + /** + * @group disconnected + */ + public function testPrefixKeys() + { + $arguments = array('AND', 'key:dst', 'key:01', 'key:02'); + $expected = array('AND', 'prefix:key:dst', 'prefix:key:01', 'prefix:key:02'); + + $command = $this->getCommandWithArgumentsArray($arguments); + $command->prefixKeys('prefix:'); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testPrefixKeysIgnoredOnEmptyArguments() + { + $command = $this->getCommand(); + $command->prefixKeys('prefix:'); + + $this->assertSame(array(), $command->getArguments()); + } + + /** + * @group connected + */ + public function testCanPerformBitwiseAND() + { + $redis = $this->getClient(); + + $redis->set('key:src:1', "h\x80"); + $redis->set('key:src:2', "R"); + + $this->assertSame(2, $redis->bitop('AND', 'key:dst', 'key:src:1', 'key:src:2')); + $this->assertSame("@\x00", $redis->get('key:dst')); + } + + /** + * @group connected + */ + public function testCanPerformBitwiseOR() + { + $redis = $this->getClient(); + + $redis->set('key:src:1', "h\x80"); + $redis->set('key:src:2', "R"); + + $this->assertSame(2, $redis->bitop('OR', 'key:dst', 'key:src:1', 'key:src:2')); + $this->assertSame("z\x80", $redis->get('key:dst')); + } + + /** + * @group connected + */ + public function testCanPerformBitwiseXOR() + { + $redis = $this->getClient(); + + $redis->set('key:src:1', "h\x80"); + $redis->set('key:src:2', "R"); + + $this->assertSame(2, $redis->bitop('XOR', 'key:dst', 'key:src:1', 'key:src:2')); + $this->assertSame(":\x80", $redis->get('key:dst')); + } + + /** + * @group connected + */ + public function testCanPerformBitwiseNOT() + { + $redis = $this->getClient(); + + $redis->set('key:src:1', "h\x80"); + + $this->assertSame(2, $redis->bitop('NOT', 'key:dst', 'key:src:1')); + $this->assertSame("\x97\x7f", $redis->get('key:dst')); + } + + /** + * @group connected + * @expectedException Predis\ServerException + * @expectedExceptionMessage ERR BITOP NOT must be called with a single source key. + */ + public function testBitwiseNOTAcceptsOnlyOneSourceKey() + { + $this->getClient()->bitop('NOT', 'key:dst', 'key:src:1', 'key:src:2'); + } + + /** + * @group connected + * @expectedException Predis\ServerException + * @expectedExceptionMessage ERR syntax error + */ + public function testThrowsExceptionOnInvalidOperation() + { + $this->getClient()->bitop('NOOP', 'key:dst', 'key:src:1', 'key:src:2'); + } + + /** + * @group connected + * @expectedException Predis\ServerException + * @expectedExceptionMessage Operation against a key holding the wrong kind of value + */ + public function testThrowsExceptionOnInvalidSourceKey() + { + $redis = $this->getClient(); + + $redis->lpush('key:src:1', 'list'); + $redis->bitop('AND', 'key:dst', 'key:src:1', 'key:src:2'); + } + + /** + * @group connected + */ + public function testDoesNotThrowExceptionOnInvalidDestinationKey() + { + $redis = $this->getClient(); + + $redis->lpush('key:dst', 'list'); + $redis->bitop('AND', 'key:dst', 'key:src:1', 'key:src:2'); + + $this->assertSame('none', $redis->type('key:dst')); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/StringDecrementByTest.php b/vendor/predis/predis/tests/Predis/Command/StringDecrementByTest.php new file mode 100755 index 0000000..6529ef5 --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/StringDecrementByTest.php @@ -0,0 +1,145 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @group commands + * @group realm-string + */ +class StringDecrementByTest extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return 'Predis\Command\StringDecrementBy'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return 'DECRBY'; + } + + /** + * @group disconnected + */ + public function testFilterArguments() + { + $arguments = array('key', 5); + $expected = array('key', 5); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse() + { + $this->assertSame(5, $this->getCommand()->parseResponse(5)); + } + + /** + * @group disconnected + */ + public function testPrefixKeys() + { + $arguments = array('key', 5); + $expected = array('prefix:key', 5); + + $command = $this->getCommandWithArgumentsArray($arguments); + $command->prefixKeys('prefix:'); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testPrefixKeysIgnoredOnEmptyArguments() + { + $command = $this->getCommand(); + $command->prefixKeys('prefix:'); + + $this->assertSame(array(), $command->getArguments()); + } + + /** + * @group connected + */ + public function testCreatesNewKeyOnNonExistingKey() + { + $redis = $this->getClient(); + + $this->assertSame(-10, $redis->decrby('foo', 10)); + $this->assertEquals(-10, $redis->get('foo')); + } + + /** + * @group connected + */ + public function testReturnsTheValueOfTheKeyAfterDecrement() + { + $redis = $this->getClient(); + + $redis->set('foo', 10); + + $this->assertSame(6, $redis->decrby('foo', 4)); + $this->assertSame(0, $redis->decrby('foo', 6)); + $this->assertSame(-25, $redis->decrby('foo', 25)); + } + + /** + * @group connected + * @expectedException Predis\ServerException + * @expectedExceptionMessage ERR value is not an integer or out of range + */ + public function testThrowsExceptionOnDecrementValueNotInteger() + { + $redis = $this->getClient(); + + $redis->decrby('foo', 'bar'); + } + + /** + * @group connected + * @expectedException Predis\ServerException + * @expectedExceptionMessage ERR value is not an integer or out of range + */ + public function testThrowsExceptionOnKeyValueNotInteger() + { + $redis = $this->getClient(); + + $redis->set('foo', 'bar'); + $redis->decrby('foo', 5); + } + + /** + * @group connected + * @expectedException Predis\ServerException + * @expectedExceptionMessage Operation against a key holding the wrong kind of value + */ + public function testThrowsExceptionOnWrongType() + { + $redis = $this->getClient(); + + $redis->lpush('metavars', 'foo'); + $redis->decrby('metavars', 10); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/StringDecrementTest.php b/vendor/predis/predis/tests/Predis/Command/StringDecrementTest.php new file mode 100755 index 0000000..bc4b14a --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/StringDecrementTest.php @@ -0,0 +1,132 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @group commands + * @group realm-string + */ +class StringDecrementTest extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return 'Predis\Command\StringDecrement'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return 'DECR'; + } + + /** + * @group disconnected + */ + public function testFilterArguments() + { + $arguments = array('key'); + $expected = array('key'); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse() + { + $this->assertSame(5, $this->getCommand()->parseResponse(5)); + } + + /** + * @group disconnected + */ + public function testPrefixKeys() + { + $arguments = array('key'); + $expected = array('prefix:key'); + + $command = $this->getCommandWithArgumentsArray($arguments); + $command->prefixKeys('prefix:'); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testPrefixKeysIgnoredOnEmptyArguments() + { + $command = $this->getCommand(); + $command->prefixKeys('prefix:'); + + $this->assertSame(array(), $command->getArguments()); + } + + /** + * @group connected + */ + public function testCreatesNewKeyOnNonExistingKey() + { + $redis = $this->getClient(); + + $this->assertSame(-1, $redis->decr('foo')); + $this->assertEquals(-1, $redis->get('foo')); + } + + /** + * @group connected + */ + public function testReturnsTheValueOfTheKeyAfterDecrement() + { + $redis = $this->getClient(); + + $redis->set('foo', 1); + + $this->assertSame(0, $redis->decr('foo')); + $this->assertSame(-1, $redis->decr('foo')); + } + + /** + * @group connected + * @expectedException Predis\ServerException + * @expectedExceptionMessage ERR value is not an integer or out of range + */ + public function testThrowsExceptionOnKeyValueNotInteger() + { + $redis = $this->getClient(); + + $redis->set('foo', 'bar'); + $redis->decr('foo'); + } + + /** + * @group connected + * @expectedException Predis\ServerException + * @expectedExceptionMessage Operation against a key holding the wrong kind of value + */ + public function testThrowsExceptionOnWrongType() + { + $redis = $this->getClient(); + + $redis->lpush('metavars', 'foo'); + $redis->decr('metavars'); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/StringGetBitTest.php b/vendor/predis/predis/tests/Predis/Command/StringGetBitTest.php new file mode 100755 index 0000000..3afb735 --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/StringGetBitTest.php @@ -0,0 +1,138 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @group commands + * @group realm-string + */ +class StringGetBitTest extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return 'Predis\Command\StringGetBit'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return 'GETBIT'; + } + + /** + * @group disconnected + */ + public function testFilterArguments() + { + $arguments = array('key', 100); + $expected = array('key', 100); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse() + { + $command = $this->getCommand(); + $this->assertSame(0, $command->parseResponse(0)); + $this->assertSame(1, $command->parseResponse(1)); + } + + /** + * @group disconnected + */ + public function testPrefixKeys() + { + $arguments = array('key', 100); + $expected = array('prefix:key', 100); + + $command = $this->getCommandWithArgumentsArray($arguments); + $command->prefixKeys('prefix:'); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testPrefixKeysIgnoredOnEmptyArguments() + { + $command = $this->getCommand(); + $command->prefixKeys('prefix:'); + + $this->assertSame(array(), $command->getArguments()); + } + + /** + * @group connected + */ + public function testCanGetBitsFromString() + { + $redis = $this->getClient(); + + $redis->set('key:binary', "\x80\x00\00\x01"); + + $this->assertSame(1, $redis->getbit('key:binary', 0)); + $this->assertSame(0, $redis->getbit('key:binary', 15)); + $this->assertSame(1, $redis->getbit('key:binary', 31)); + $this->assertSame(0, $redis->getbit('key:binary', 63)); + } + + /** + * @group connected + * @expectedException Predis\ServerException + * @expectedExceptionMessage ERR bit offset is not an integer or out of range + */ + public function testThrowsExceptionOnNegativeOffset() + { + $redis = $this->getClient(); + + $redis->set('key:binary', "\x80\x00\00\x01"); + $redis->getbit('key:binary', -1); + } + + /** + * @group connected + * @expectedException Predis\ServerException + * @expectedExceptionMessage ERR bit offset is not an integer or out of range + */ + public function testThrowsExceptionOnInvalidOffset() + { + $redis = $this->getClient(); + + $redis->set('key:binary', "\x80\x00\00\x01"); + $redis->getbit('key:binary', 'invalid'); + } + + /** + * @group connected + * @expectedException Predis\ServerException + * @expectedExceptionMessage Operation against a key holding the wrong kind of value + */ + public function testThrowsExceptionOnWrongType() + { + $redis = $this->getClient(); + + $redis->lpush('metavars', 'foo'); + $redis->getbit('metavars', '1'); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/StringGetMultipleTest.php b/vendor/predis/predis/tests/Predis/Command/StringGetMultipleTest.php new file mode 100755 index 0000000..ad009aa --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/StringGetMultipleTest.php @@ -0,0 +1,135 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @group commands + * @group realm-string + */ +class StringGetMultipleTest extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return 'Predis\Command\StringGetMultiple'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return 'MGET'; + } + + /** + * @group disconnected + */ + public function testFilterArguments() + { + $arguments = array('key1', 'key2', 'key3'); + $expected = array('key1', 'key2', 'key3'); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testFilterArgumentsAsSingleArray() + { + $arguments = array(array('key1', 'key2', 'key3')); + $expected = array('key1', 'key2', 'key3'); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse() + { + $raw = array('value1', 'value2', 'value3'); + $expected = array('value1', 'value2', 'value3'); + + $command = $this->getCommand(); + + $this->assertSame($expected, $command->parseResponse($raw)); + } + + /** + * @group disconnected + */ + public function testPrefixKeys() + { + $arguments = array('key1', 'key2', 'key3'); + $expected = array('prefix:key1', 'prefix:key2', 'prefix:key3'); + + $command = $this->getCommandWithArgumentsArray($arguments); + $command->prefixKeys('prefix:'); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testPrefixKeysIgnoredOnEmptyArguments() + { + $command = $this->getCommand(); + $command->prefixKeys('prefix:'); + + $this->assertSame(array(), $command->getArguments()); + } + + /** + * @group connected + */ + public function testReturnsArrayOfValues() + { + $redis = $this->getClient(); + + $redis->set('foo', 'bar'); + $redis->set('hoge', 'piyo'); + + $this->assertSame(array('bar', 'piyo'), $redis->mget('foo', 'hoge')); + } + + /** + * @group connected + */ + public function testReturnsArrayWithNullValuesOnNonExistingKeys() + { + $redis = $this->getClient(); + + $this->assertSame(array(null, null), $redis->mget('foo', 'hoge')); + } + + /** + * @group connected + */ + public function testDoesNotThrowExceptionOnWrongType() + { + $redis = $this->getClient(); + + $redis->lpush('metavars', 'foo'); + $this->assertSame(array(null), $redis->mget('metavars')); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/StringGetRangeTest.php b/vendor/predis/predis/tests/Predis/Command/StringGetRangeTest.php new file mode 100755 index 0000000..d7de14b --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/StringGetRangeTest.php @@ -0,0 +1,123 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @group commands + * @group realm-string + */ +class StringGetRangeTest extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return 'Predis\Command\StringGetRange'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return 'GETRANGE'; + } + + /** + * @group disconnected + */ + public function testFilterArguments() + { + $arguments = array('key', 5, 10); + $expected = array('key', 5, 10); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse() + { + $this->assertSame('substring',$this->getCommand()->parseResponse('substring')); + } + + /** + * @group disconnected + */ + public function testPrefixKeys() + { + $arguments = array('key', 5, 10); + $expected = array('prefix:key', 5, 10); + + $command = $this->getCommandWithArgumentsArray($arguments); + $command->prefixKeys('prefix:'); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testPrefixKeysIgnoredOnEmptyArguments() + { + $command = $this->getCommand(); + $command->prefixKeys('prefix:'); + + $this->assertSame(array(), $command->getArguments()); + } + + /** + * @group connected + */ + public function testReturnsSubstring() + { + $redis = $this->getClient(); + + $redis->set('string', 'this is a string'); + + $this->assertSame('this', $redis->getrange('string', 0, 3)); + $this->assertSame('ing', $redis->getrange('string', -3, -1)); + $this->assertSame('this is a string', $redis->getrange('string', 0, -1)); + $this->assertSame('string', $redis->getrange('string', 10, 100)); + + $this->assertSame('t', $redis->getrange('string', 0, 0)); + $this->assertSame('', $redis->getrange('string', -1, 0)); + } + + /** + * @group connected + */ + public function testReturnsEmptyStringOnNonExistingKey() + { + $redis = $this->getClient(); + + $this->assertSame('', $redis->getrange('string', 0, 3)); + } + + /** + * @group connected + * @expectedException Predis\ServerException + * @expectedExceptionMessage Operation against a key holding the wrong kind of value + */ + public function testThrowsExceptionOnWrongType() + { + $redis = $this->getClient(); + + $redis->lpush('metavars', 'foo'); + $redis->getrange('metavars', 0, 5); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/StringGetSetTest.php b/vendor/predis/predis/tests/Predis/Command/StringGetSetTest.php new file mode 100755 index 0000000..b31a7a4 --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/StringGetSetTest.php @@ -0,0 +1,109 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @group commands + * @group realm-string + */ +class StringGetSetTest extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return 'Predis\Command\StringGetSet'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return 'GETSET'; + } + + /** + * @group disconnected + */ + public function testFilterArguments() + { + $arguments = array('key', 'value'); + $expected = array('key', 'value'); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse() + { + $this->assertSame('value', $this->getCommand()->parseResponse('value')); + } + + /** + * @group disconnected + */ + public function testPrefixKeys() + { + $arguments = array('key', 'value'); + $expected = array('prefix:key', 'value'); + + $command = $this->getCommandWithArgumentsArray($arguments); + $command->prefixKeys('prefix:'); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testPrefixKeysIgnoredOnEmptyArguments() + { + $command = $this->getCommand(); + $command->prefixKeys('prefix:'); + + $this->assertSame(array(), $command->getArguments()); + } + + /** + * @group connected + */ + public function testReturnsPreviousValueOfKey() + { + $redis = $this->getClient(); + + $this->assertNull($redis->getset('foo', 'bar')); + $this->assertSame('bar', $redis->getset('foo', 'barbar')); + + $redis->set('hoge', 'piyo'); + $this->assertSame('piyo', $redis->getset('hoge', 'piyopiyo')); + } + + /** + * @group connected + * @expectedException Predis\ServerException + * @expectedExceptionMessage Operation against a key holding the wrong kind of value + */ + public function testThrowsExceptionOnWrongType() + { + $redis = $this->getClient(); + + $redis->lpush('metavars', 'foo'); + $redis->getset('metavars', 'foo'); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/StringGetTest.php b/vendor/predis/predis/tests/Predis/Command/StringGetTest.php new file mode 100755 index 0000000..75cb981 --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/StringGetTest.php @@ -0,0 +1,130 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @group commands + * @group realm-string + */ +class StringGetTest extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return 'Predis\Command\StringGet'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return 'GET'; + } + + /** + * @group disconnected + */ + public function testFilterArguments() + { + $arguments = array('foo'); + $expected = array('foo'); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse() + { + $this->assertSame('bar', $this->getCommand()->parseResponse('bar')); + } + + /** + * @group disconnected + */ + public function testPrefixKeys() + { + $arguments = array('key'); + $expected = array('prefix:key'); + + $command = $this->getCommandWithArgumentsArray($arguments); + $command->prefixKeys('prefix:'); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testPrefixKeysIgnoredOnEmptyArguments() + { + $command = $this->getCommand(); + $command->prefixKeys('prefix:'); + + $this->assertSame(array(), $command->getArguments()); + } + + /** + * @group connected + */ + public function testReturnsStringValue() + { + $redis = $this->getClient(); + + $this->assertTrue($redis->set('foo', 'bar')); + $this->assertEquals('bar', $redis->get('foo')); + } + + /** + * @group connected + */ + public function testReturnsEmptyStringOnEmptyStrings() + { + $redis = $this->getClient(); + + $redis->set('foo', ''); + + $this->assertTrue($redis->exists('foo')); + $this->assertSame('', $redis->get('foo')); + } + + /** + * @group connected + */ + public function testReturnsNullOnNonExistingKeys() + { + $redis = $this->getClient(); + + $this->assertFalse($redis->exists('foo')); + $this->assertNull($redis->get('foo')); + } + + /** + * @group connected + * @expectedException Predis\ServerException + * @expectedExceptionMessage Operation against a key holding the wrong kind of value + */ + public function testThrowsExceptionOnWrongType() + { + $redis = $this->getClient(); + + $redis->rpush('metavars', 'foo'); + $redis->get('metavars'); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/StringIncrementByFloatTest.php b/vendor/predis/predis/tests/Predis/Command/StringIncrementByFloatTest.php new file mode 100755 index 0000000..47d884d --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/StringIncrementByFloatTest.php @@ -0,0 +1,145 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @group commands + * @group realm-string + */ +class StringIncrementByFloatTest extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return 'Predis\Command\StringIncrementByFloat'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return 'INCRBYFLOAT'; + } + + /** + * @group disconnected + */ + public function testFilterArguments() + { + $arguments = array('key', 5.0); + $expected = array('key', 5.0); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse() + { + $this->assertSame(5.0, $this->getCommand()->parseResponse(5.0)); + } + + /** + * @group disconnected + */ + public function testPrefixKeys() + { + $arguments = array('key', 5.0); + $expected = array('prefix:key', 5.0); + + $command = $this->getCommandWithArgumentsArray($arguments); + $command->prefixKeys('prefix:'); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testPrefixKeysIgnoredOnEmptyArguments() + { + $command = $this->getCommand(); + $command->prefixKeys('prefix:'); + + $this->assertSame(array(), $command->getArguments()); + } + + /** + * @group connected + */ + public function testCreatesNewKeyOnNonExistingKey() + { + $redis = $this->getClient(); + + $this->assertEquals(10.5, $redis->incrbyfloat('foo', 10.5)); + $this->assertEquals(10.5, $redis->get('foo')); + } + + /** + * @group connected + */ + public function testReturnsTheValueOfTheKeyAfterIncrement() + { + $redis = $this->getClient(); + + $redis->set('foo', 2); + + $this->assertEquals(22.123, $redis->incrbyfloat('foo', 20.123)); + $this->assertEquals(10, $redis->incrbyfloat('foo', -12.123)); + $this->assertEquals(-100.01, $redis->incrbyfloat('foo', -110.01)); + } + + /** + * @group connected + * @expectedException Predis\ServerException + * @expectedExceptionMessage ERR value is not a valid float + */ + public function testThrowsExceptionOnDecrementValueNotFloat() + { + $redis = $this->getClient(); + + $redis->incrbyfloat('foo', 'bar'); + } + + /** + * @group connected + * @expectedException Predis\ServerException + * @expectedExceptionMessage ERR value is not a valid float + */ + public function testThrowsExceptionOnKeyValueNotFloat() + { + $redis = $this->getClient(); + + $redis->set('foo', 'bar'); + $redis->incrbyfloat('foo', 10.0); + } + + /** + * @group connected + * @expectedException Predis\ServerException + * @expectedExceptionMessage Operation against a key holding the wrong kind of value + */ + public function testThrowsExceptionOnWrongType() + { + $redis = $this->getClient(); + + $redis->lpush('metavars', 'foo'); + $redis->incrbyfloat('metavars', 10.0); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/StringIncrementByTest.php b/vendor/predis/predis/tests/Predis/Command/StringIncrementByTest.php new file mode 100755 index 0000000..ef55f5a --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/StringIncrementByTest.php @@ -0,0 +1,145 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @group commands + * @group realm-string + */ +class StringIncrementByTest extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return 'Predis\Command\StringIncrementBy'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return 'INCRBY'; + } + + /** + * @group disconnected + */ + public function testFilterArguments() + { + $arguments = array('key', 5); + $expected = array('key', 5); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse() + { + $this->assertSame(5, $this->getCommand()->parseResponse(5)); + } + + /** + * @group disconnected + */ + public function testPrefixKeys() + { + $arguments = array('key', 5); + $expected = array('prefix:key', 5); + + $command = $this->getCommandWithArgumentsArray($arguments); + $command->prefixKeys('prefix:'); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testPrefixKeysIgnoredOnEmptyArguments() + { + $command = $this->getCommand(); + $command->prefixKeys('prefix:'); + + $this->assertSame(array(), $command->getArguments()); + } + + /** + * @group connected + */ + public function testCreatesNewKeyOnNonExistingKey() + { + $redis = $this->getClient(); + + $this->assertSame(10, $redis->incrby('foo', 10)); + $this->assertEquals(10, $redis->get('foo')); + } + + /** + * @group connected + */ + public function testReturnsTheValueOfTheKeyAfterIncrement() + { + $redis = $this->getClient(); + + $redis->set('foo', 2); + + $this->assertSame(22, $redis->incrby('foo', 20)); + $this->assertSame(10, $redis->incrby('foo', -12)); + $this->assertSame(-100, $redis->incrby('foo', -110)); + } + + /** + * @group connected + * @expectedException Predis\ServerException + * @expectedExceptionMessage ERR value is not an integer or out of range + */ + public function testThrowsExceptionOnDecrementValueNotInteger() + { + $redis = $this->getClient(); + + $redis->incrby('foo', 'bar'); + } + + /** + * @group connected + * @expectedException Predis\ServerException + * @expectedExceptionMessage ERR value is not an integer or out of range + */ + public function testThrowsExceptionOnKeyValueNotInteger() + { + $redis = $this->getClient(); + + $redis->set('foo', 'bar'); + $redis->incrby('foo', 10); + } + + /** + * @group connected + * @expectedException Predis\ServerException + * @expectedExceptionMessage Operation against a key holding the wrong kind of value + */ + public function testThrowsExceptionOnWrongType() + { + $redis = $this->getClient(); + + $redis->lpush('metavars', 'foo'); + $redis->incrby('metavars', 10); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/StringIncrementTest.php b/vendor/predis/predis/tests/Predis/Command/StringIncrementTest.php new file mode 100755 index 0000000..b6017c3 --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/StringIncrementTest.php @@ -0,0 +1,119 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @group commands + * @group realm-string + */ +class StringIncrementTest extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return 'Predis\Command\StringIncrement'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return 'INCR'; + } + + /** + * @group disconnected + */ + public function testFilterArguments() + { + $arguments = array('key'); + $expected = array('key'); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse() + { + $this->assertSame(5, $this->getCommand()->parseResponse(5)); + } + + /** + * @group disconnected + */ + public function testPrefixKeys() + { + $arguments = array('key'); + $expected = array('prefix:key'); + + $command = $this->getCommandWithArgumentsArray($arguments); + $command->prefixKeys('prefix:'); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testPrefixKeysIgnoredOnEmptyArguments() + { + $command = $this->getCommand(); + $command->prefixKeys('prefix:'); + + $this->assertSame(array(), $command->getArguments()); + } + + /** + * @group connected + */ + public function testCreatesNewKeyOnNonExistingKey() + { + $redis = $this->getClient(); + + $this->assertSame(1, $redis->incr('foo')); + $this->assertEquals(1, $redis->get('foo')); + } + + /** + * @group connected + */ + public function testReturnsTheValueOfTheKeyAfterIncrement() + { + $redis = $this->getClient(); + + $redis->set('foo', 2); + + $this->assertSame(3, $redis->incr('foo')); + $this->assertSame(4, $redis->incr('foo')); + } + + /** + * @group connected + * @expectedException Predis\ServerException + * @expectedExceptionMessage Operation against a key holding the wrong kind of value + */ + public function testThrowsExceptionOnWrongType() + { + $redis = $this->getClient(); + + $redis->lpush('metavars', 'foo'); + $redis->incr('metavars'); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/StringPreciseSetExpireTest.php b/vendor/predis/predis/tests/Predis/Command/StringPreciseSetExpireTest.php new file mode 100755 index 0000000..ca2f18c --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/StringPreciseSetExpireTest.php @@ -0,0 +1,139 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @group commands + * @group realm-string + */ +class StringPreciseSetExpireTest extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return 'Predis\Command\StringPreciseSetExpire'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return 'PSETEX'; + } + + /** + * @group disconnected + */ + public function testFilterArguments() + { + $arguments = array('key', 10, 'hello'); + $expected = array('key', 10, 'hello'); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse() + { + $this->assertTrue($this->getCommand()->parseResponse(true)); + } + + /** + * @group disconnected + */ + public function testPrefixKeys() + { + $arguments = array('key', 10, 'hello'); + $expected = array('prefix:key', 10, 'hello'); + + $command = $this->getCommandWithArgumentsArray($arguments); + $command->prefixKeys('prefix:'); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testPrefixKeysIgnoredOnEmptyArguments() + { + $command = $this->getCommand(); + $command->prefixKeys('prefix:'); + + $this->assertSame(array(), $command->getArguments()); + } + + /** + * @group connected + */ + public function testCreatesNewKeyAndSetsTTL() + { + $redis = $this->getClient(); + + $this->assertTrue($redis->psetex('foo', 10000, 'bar')); + $this->assertTrue($redis->exists('foo')); + $this->assertEquals(10, $redis->ttl('foo')); + } + + /** + * @group connected + * @group slow + */ + public function testKeyExpiresAfterTTL() + { + $redis = $this->getClient(); + + $redis->psetex('foo', 50, 'bar'); + $this->sleep(0.5); + $this->assertFalse($redis->exists('foo'));; + } + + /** + * @group connected + * @expectedException Predis\ServerException + * @expectedExceptionMessage ERR value is not an integer or out of range + */ + public function testThrowsExceptionOnNonIntegerTTL() + { + $this->getClient()->psetex('foo', 2.5, 'bar'); + } + + /** + * @group connected + * @expectedException Predis\ServerException + * @expectedExceptionMessage ERR invalid expire time in SETEX + * @todo Should not Redis return PSETEX instead of SETEX here? + */ + public function testThrowsExceptionOnZeroTTL() + { + $this->getClient()->psetex('foo', 0, 'bar'); + } + + /** + * @group connected + * @expectedException Predis\ServerException + * @expectedExceptionMessage ERR invalid expire time in SETEX + * @todo Should not Redis return PSETEX instead of SETEX here? + */ + public function testThrowsExceptionOnNegativeTTL() + { + $this->getClient()->psetex('foo', -10000, 'bar'); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/StringSetBitTest.php b/vendor/predis/predis/tests/Predis/Command/StringSetBitTest.php new file mode 100755 index 0000000..8dda640 --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/StringSetBitTest.php @@ -0,0 +1,154 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @group commands + * @group realm-string + */ +class StringSetBitTest extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return 'Predis\Command\StringSetBit'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return 'SETBIT'; + } + + /** + * @group disconnected + */ + public function testFilterArguments() + { + $arguments = array('key', 7, 1); + $expected = array('key', 7, 1); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse() + { + $command = $this->getCommand(); + $this->assertSame(0, $command->parseResponse(0)); + $this->assertSame(1, $command->parseResponse(1)); + } + + /** + * @group disconnected + */ + public function testPrefixKeys() + { + $arguments = array('key', 7, 1); + $expected = array('prefix:key', 7, 1); + + $command = $this->getCommandWithArgumentsArray($arguments); + $command->prefixKeys('prefix:'); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testPrefixKeysIgnoredOnEmptyArguments() + { + $command = $this->getCommand(); + $command->prefixKeys('prefix:'); + + $this->assertSame(array(), $command->getArguments()); + } + + /** + * @group connected + */ + public function testCanSetBitsOfStrings() + { + $redis = $this->getClient(); + + $redis->set('key:binary', "\x80\x00\00\x01"); + + $this->assertEquals(1, $redis->setbit('key:binary', 0, 0)); + $this->assertEquals(0, $redis->setbit('key:binary', 0, 0)); + $this->assertEquals("\x00\x00\00\x01", $redis->get('key:binary')); + } + + /** + * @group connected + */ + public function testCreatesNewKeyOnNonExistingKey() + { + $redis = $this->getClient(); + + $this->assertSame(0, $redis->setbit('key:binary', 31, 1)); + $this->assertSame(0, $redis->setbit('key:binary', 0, 1)); + $this->assertSame(4, $redis->strlen('key:binary')); + $this->assertSame("\x80\x00\00\x01", $redis->get('key:binary')); + } + + /** + * @group connected + * @expectedException Predis\ServerException + * @expectedExceptionMessage ERR bit is not an integer or out of range + */ + public function testThrowsExceptionOnInvalidBitValue() + { + $redis = $this->getClient()->setbit('key:binary', 10, 255); + } + + /** + * @group connected + * @expectedException Predis\ServerException + * @expectedExceptionMessage ERR bit offset is not an integer or out of range + */ + public function testThrowsExceptionOnNegativeOffset() + { + $redis = $this->getClient()->setbit('key:binary', -1, 1); + } + + /** + * @group connected + * @expectedException Predis\ServerException + * @expectedExceptionMessage ERR bit offset is not an integer or out of range + */ + public function testThrowsExceptionOnInvalidOffset() + { + $redis = $this->getClient()->setbit('key:binary', 'invalid', 1); + } + + /** + * @group connected + * @expectedException Predis\ServerException + * @expectedExceptionMessage Operation against a key holding the wrong kind of value + */ + public function testThrowsExceptionOnWrongType() + { + $redis = $this->getClient(); + + $redis->lpush('metavars', 'foo'); + $redis->setbit('metavars', 0, 1); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/StringSetExpireTest.php b/vendor/predis/predis/tests/Predis/Command/StringSetExpireTest.php new file mode 100755 index 0000000..769469b --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/StringSetExpireTest.php @@ -0,0 +1,138 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @group commands + * @group realm-string + */ +class StringSetExpireTest extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return 'Predis\Command\StringSetExpire'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return 'SETEX'; + } + + /** + * @group disconnected + */ + public function testFilterArguments() + { + $arguments = array('key', 10, 'hello'); + $expected = array('key', 10, 'hello'); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse() + { + $this->assertTrue($this->getCommand()->parseResponse(true)); + } + + /** + * @group disconnected + */ + public function testPrefixKeys() + { + $arguments = array('key', 10, 'hello'); + $expected = array('prefix:key', 10, 'hello'); + + $command = $this->getCommandWithArgumentsArray($arguments); + $command->prefixKeys('prefix:'); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testPrefixKeysIgnoredOnEmptyArguments() + { + $command = $this->getCommand(); + $command->prefixKeys('prefix:'); + + $this->assertSame(array(), $command->getArguments()); + } + + /** + * @group connected + */ + public function testCreatesNewKeyAndSetsTTL() + { + $redis = $this->getClient(); + + $this->assertTrue($redis->setex('foo', 10, 'bar')); + $this->assertTrue($redis->exists('foo')); + $this->assertEquals(10, $redis->ttl('foo')); + } + + /** + * @medium + * @group connected + * @group slow + */ + public function testKeyExpiresAfterTTL() + { + $redis = $this->getClient(); + + $redis->setex('foo', 1, 'bar'); + $this->sleep(2.0); + $this->assertFalse($redis->exists('foo'));; + } + + /** + * @group connected + * @expectedException Predis\ServerException + * @expectedExceptionMessage ERR value is not an integer or out of range + */ + public function testThrowsExceptionOnNonIntegerTTL() + { + $this->getClient()->setex('foo', 2.5, 'bar'); + } + + /** + * @group connected + * @expectedException Predis\ServerException + * @expectedExceptionMessage ERR invalid expire time in SETEX + */ + public function testThrowsExceptionOnZeroTTL() + { + $this->getClient()->setex('foo', 0, 'bar'); + } + + /** + * @group connected + * @expectedException Predis\ServerException + * @expectedExceptionMessage ERR invalid expire time in SETEX + */ + public function testThrowsExceptionOnNegativeTTL() + { + $this->getClient()->setex('foo', -10, 'bar'); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/StringSetMultiplePreserveTest.php b/vendor/predis/predis/tests/Predis/Command/StringSetMultiplePreserveTest.php new file mode 100755 index 0000000..dcb1780 --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/StringSetMultiplePreserveTest.php @@ -0,0 +1,122 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @group commands + * @group realm-string + */ +class StringSetMultiplePreserveTest extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return 'Predis\Command\StringSetMultiplePreserve'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return 'MSETNX'; + } + + /** + * @group disconnected + */ + public function testFilterArguments() + { + $arguments = array('foo', 'bar', 'hoge', 'piyo'); + $expected = array('foo', 'bar', 'hoge', 'piyo'); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testFilterArgumentsAsSingleNamedArray() + { + $arguments = array(array('foo' => 'bar', 'hoge' => 'piyo')); + $expected = array('foo', 'bar', 'hoge', 'piyo'); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse() + { + $this->assertSame(true, $this->getCommand()->parseResponse(true)); + } + + /** + * @group disconnected + */ + public function testPrefixKeys() + { + $arguments = array('foo', 'bar', 'hoge', 'piyo'); + $expected = array('prefix:foo', 'bar', 'prefix:hoge', 'piyo'); + + $command = $this->getCommandWithArgumentsArray($arguments); + $command->prefixKeys('prefix:'); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testPrefixKeysIgnoredOnEmptyArguments() + { + $command = $this->getCommand(); + $command->prefixKeys('prefix:'); + + $this->assertSame(array(), $command->getArguments()); + } + + /** + * @group connected + */ + public function testCreatesMultipleKeys() + { + $redis = $this->getClient(); + + $this->assertTrue($redis->msetnx('foo', 'bar', 'hoge', 'piyo')); + $this->assertSame('bar', $redis->get('foo')); + $this->assertSame('piyo', $redis->get('hoge')); + } + + /** + * @group connected + */ + public function testCreatesMultipleKeysAndPreservesExistingOnes() + { + $redis = $this->getClient(); + + $redis->set('foo', 'bar'); + + $this->assertFalse($redis->msetnx('foo', 'barbar', 'hoge', 'piyo')); + $this->assertSame('bar', $redis->get('foo')); + $this->assertFalse($redis->exists('hoge')); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/StringSetMultipleTest.php b/vendor/predis/predis/tests/Predis/Command/StringSetMultipleTest.php new file mode 100755 index 0000000..c1a7f0e --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/StringSetMultipleTest.php @@ -0,0 +1,108 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @group commands + * @group realm-string + */ +class StringSetMultipleTest extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return 'Predis\Command\StringSetMultiple'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return 'MSET'; + } + + /** + * @group disconnected + */ + public function testFilterArguments() + { + $arguments = array('foo', 'bar', 'hoge', 'piyo'); + $expected = array('foo', 'bar', 'hoge', 'piyo'); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testFilterArgumentsAsSingleNamedArray() + { + $arguments = array(array('foo' => 'bar', 'hoge' => 'piyo')); + $expected = array('foo', 'bar', 'hoge', 'piyo'); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse() + { + $this->assertSame(true, $this->getCommand()->parseResponse(true)); + } + + /** + * @group disconnected + */ + public function testPrefixKeys() + { + $arguments = array('foo', 'bar', 'hoge', 'piyo'); + $expected = array('prefix:foo', 'bar', 'prefix:hoge', 'piyo'); + + $command = $this->getCommandWithArgumentsArray($arguments); + $command->prefixKeys('prefix:'); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testPrefixKeysIgnoredOnEmptyArguments() + { + $command = $this->getCommand(); + $command->prefixKeys('prefix:'); + + $this->assertSame(array(), $command->getArguments()); + } + + /** + * @group connected + */ + public function testCreatesMultipleKeys() + { + $redis = $this->getClient(); + + $this->assertTrue($redis->mset('foo', 'bar', 'hoge', 'piyo')); + $this->assertSame('bar', $redis->get('foo')); + $this->assertSame('piyo', $redis->get('hoge')); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/StringSetPreserveTest.php b/vendor/predis/predis/tests/Predis/Command/StringSetPreserveTest.php new file mode 100755 index 0000000..a77c514 --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/StringSetPreserveTest.php @@ -0,0 +1,94 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @group commands + * @group realm-string + */ +class StringSetPreserveTest extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return 'Predis\Command\StringSetPreserve'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return 'SETNX'; + } + + /** + * @group disconnected + */ + public function testFilterArguments() + { + $arguments = array('foo', 'bar'); + $expected = array('foo', 'bar'); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse() + { + $this->assertTrue($this->getCommand()->parseResponse(1)); + } + + /** + * @group disconnected + */ + public function testPrefixKeys() + { + $arguments = array('key', 'value'); + $expected = array('prefix:key', 'value'); + + $command = $this->getCommandWithArgumentsArray($arguments); + $command->prefixKeys('prefix:'); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testPrefixKeysIgnoredOnEmptyArguments() + { + $command = $this->getCommand(); + $command->prefixKeys('prefix:'); + + $this->assertSame(array(), $command->getArguments()); + } + + /** + * @group connected + */ + public function testSetStringValue() + { + $redis = $this->getClient(); + + $this->assertTrue($redis->setnx('foo', 'bar')); + $this->assertFalse($redis->setnx('foo', 'barbar')); + $this->assertEquals('bar', $redis->get('foo')); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/StringSetRangeTest.php b/vendor/predis/predis/tests/Predis/Command/StringSetRangeTest.php new file mode 100755 index 0000000..eafb663 --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/StringSetRangeTest.php @@ -0,0 +1,148 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @group commands + * @group realm-string + */ +class StringSetRangeTest extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return 'Predis\Command\StringSetRange'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return 'SETRANGE'; + } + + /** + * @group disconnected + */ + public function testFilterArguments() + { + $arguments = array('key', 5, 'range'); + $expected = array('key', 5, 'range'); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse() + { + $this->assertSame(10, $this->getCommand()->parseResponse(10)); + } + + /** + * @group disconnected + */ + public function testPrefixKeys() + { + $arguments = array('key', 5, 'range'); + $expected = array('prefix:key', 5, 'range'); + + $command = $this->getCommandWithArgumentsArray($arguments); + $command->prefixKeys('prefix:'); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testPrefixKeysIgnoredOnEmptyArguments() + { + $command = $this->getCommand(); + $command->prefixKeys('prefix:'); + + $this->assertSame(array(), $command->getArguments()); + } + + /** + * @group connected + */ + public function testCreatesNewKeyOnNonExistingKey() + { + $redis = $this->getClient(); + + $this->assertSame(3, $redis->setrange('foo', 0, 'bar')); + $this->assertSame('bar', $redis->get('foo')); + + $this->assertSame(8, $redis->setrange('hoge', 4, 'piyo')); + $this->assertSame("\x00\x00\x00\x00piyo", $redis->get('hoge')); + } + + /** + * @group connected + */ + public function testOverwritesOrAppendBytesInKeys() + { + $redis = $this->getClient(); + + $redis->set('foo', 'barbar'); + + $this->assertSame(6, $redis->setrange('foo', 3, 'baz')); + $this->assertSame('barbaz', $redis->get('foo')); + + $this->assertEquals(16, $redis->setrange('foo', 10, 'foofoo')); + $this->assertEquals("barbaz\x00\x00\x00\x00foofoo", $redis->get('foo')); + } + + /** + * @group connected + */ + public function testHandlesBinaryData() + { + $redis = $this->getClient(); + + $this->assertSame(4, $redis->setrange('key:binary', 0, pack('i', -2147483648))); + + list($unpacked) = array_values(unpack('i', $redis->get('key:binary'))); + $this->assertEquals(-2147483648, $unpacked); + } + + /** + * @group connected + * @expectedException Predis\ServerException + * @expectedExceptionMessage ERR offset is out of range + */ + public function testThrowsExceptionOnInvalidOffset() + { + $this->getClient()->setrange('var', -1, 'bogus'); + } + + /** + * @group connected + * @expectedException Predis\ServerException + * @expectedExceptionMessage Operation against a key holding the wrong kind of value + */ + public function testThrowsExceptionOnWrongType() + { + $redis = $this->getClient(); + + $redis->lpush('metavars', 'foo'); + $redis->setrange('metavars', 3, 'bar'); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/StringSetTest.php b/vendor/predis/predis/tests/Predis/Command/StringSetTest.php new file mode 100755 index 0000000..61ca580 --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/StringSetTest.php @@ -0,0 +1,94 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @group commands + * @group realm-string + */ +class StringSetTest extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return 'Predis\Command\StringSet'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return 'SET'; + } + + /** + * @group disconnected + */ + public function testFilterArguments() + { + $arguments = array('foo', 'bar'); + $expected = array('foo', 'bar'); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse() + { + $this->assertTrue($this->getCommand()->parseResponse(true)); + } + + /** + * @group disconnected + */ + public function testPrefixKeys() + { + $arguments = array('key', 'value'); + $expected = array('prefix:key', 'value'); + + $command = $this->getCommandWithArgumentsArray($arguments); + $command->prefixKeys('prefix:'); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testPrefixKeysIgnoredOnEmptyArguments() + { + $command = $this->getCommand(); + $command->prefixKeys('prefix:'); + + $this->assertSame(array(), $command->getArguments()); + } + + /** + * @group connected + */ + public function testSetStringValue() + { + $redis = $this->getClient(); + + $this->assertTrue($redis->set('foo', 'bar')); + $this->assertTrue($redis->exists('foo')); + $this->assertEquals('bar', $redis->get('foo')); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/StringStrlenTest.php b/vendor/predis/predis/tests/Predis/Command/StringStrlenTest.php new file mode 100755 index 0000000..c5c06c5 --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/StringStrlenTest.php @@ -0,0 +1,119 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @group commands + * @group realm-string + */ +class StringStrlenTest extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return 'Predis\Command\StringStrlen'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return 'STRLEN'; + } + + /** + * @group disconnected + */ + public function testFilterArguments() + { + $arguments = array('key'); + $expected = array('key'); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse() + { + $this->assertSame(4, $this->getCommand()->parseResponse(4)); + } + + /** + * @group disconnected + */ + public function testPrefixKeys() + { + $arguments = array('key'); + $expected = array('prefix:key'); + + $command = $this->getCommandWithArgumentsArray($arguments); + $command->prefixKeys('prefix:'); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testPrefixKeysIgnoredOnEmptyArguments() + { + $command = $this->getCommand(); + $command->prefixKeys('prefix:'); + + $this->assertSame(array(), $command->getArguments()); + } + + /** + * @group connected + */ + public function testReturnsTheLengthOfString() + { + $redis = $this->getClient(); + + $redis->set('foo', 'bar'); + $this->assertSame(3, $redis->strlen('foo')); + + $redis->append('foo', 'bar'); + $this->assertSame(6, $redis->strlen('foo')); + } + + /** + * @group connected + */ + public function testReturnsZeroOnNonExistingKeys() + { + $redis = $this->getClient(); + + $this->assertSame(0, $redis->strlen('foo')); + } + + /** + * @group connected + * @expectedException Predis\ServerException + * @expectedExceptionMessage Operation against a key holding the wrong kind of value + */ + public function testThrowsExceptionOnWrongType() + { + $redis = $this->getClient(); + + $redis->lpush('metavars', 'foo'); + $redis->strlen('metavars'); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/StringSubstrTest.php b/vendor/predis/predis/tests/Predis/Command/StringSubstrTest.php new file mode 100755 index 0000000..42acf8c --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/StringSubstrTest.php @@ -0,0 +1,86 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * SUBSTR is actually the old name of GETRANGE in version of Redis <= 2.0. + * This command should be considered obsolete and we will perform any kind + * of tests against a Redis server for this one. + * + * @group commands + * @group realm-string + */ +class StringSubstrTest extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return 'Predis\Command\StringSubstr'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return 'SUBSTR'; + } + + /** + * @group disconnected + */ + public function testFilterArguments() + { + $arguments = array('key', 5, 10); + $expected = array('key', 5, 10); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse() + { + $this->assertSame('substring',$this->getCommand()->parseResponse('substring')); + } + + /** + * @group disconnected + */ + public function testPrefixKeys() + { + $arguments = array('key', 5, 10); + $expected = array('prefix:key', 5, 10); + + $command = $this->getCommandWithArgumentsArray($arguments); + $command->prefixKeys('prefix:'); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testPrefixKeysIgnoredOnEmptyArguments() + { + $command = $this->getCommand(); + $command->prefixKeys('prefix:'); + + $this->assertSame(array(), $command->getArguments()); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/TransactionDiscardTest.php b/vendor/predis/predis/tests/Predis/Command/TransactionDiscardTest.php new file mode 100755 index 0000000..1b450c2 --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/TransactionDiscardTest.php @@ -0,0 +1,80 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @group commands + * @group realm-transaction + */ +class TransactionDiscardTest extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return 'Predis\Command\TransactionDiscard'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return 'DISCARD'; + } + + /** + * @group disconnected + */ + public function testFilterArguments() + { + $command = $this->getCommand(); + $command->setArguments(array()); + + $this->assertSame(array(), $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse() + { + $this->assertTrue($this->getCommand()->parseResponse(true)); + } + + /** + * @group connected + */ + public function testAbortsTransactionAndRestoresNormalFlow() + { + $redis = $this->getClient(); + + $redis->multi(); + + $this->assertInstanceOf('Predis\ResponseQueued', $redis->set('foo', 'bar')); + $this->assertTrue($redis->discard()); + $this->assertFalse($redis->exists('foo')); + } + + /** + * @group connected + * @expectedException Predis\ServerException + * @expectedExceptionMessage ERR DISCARD without MULTI + */ + public function testThrowsExceptionWhenCallingOutsideTransaction() + { + $redis = $this->getClient(); + + $redis->discard(); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/TransactionExecTest.php b/vendor/predis/predis/tests/Predis/Command/TransactionExecTest.php new file mode 100755 index 0000000..634bca5 --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/TransactionExecTest.php @@ -0,0 +1,112 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @group commands + * @group realm-transaction + */ +class TransactionExecTest extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return 'Predis\Command\TransactionExec'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return 'EXEC'; + } + + /** + * @group disconnected + */ + public function testFilterArguments() + { + $command = $this->getCommand(); + $command->setArguments(array()); + + $this->assertSame(array(), $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse() + { + $raw = array('tx1', 'tx2'); + $expected = array('tx1', 'tx2'); + + $command = $this->getCommand(); + + $this->assertSame($expected, $command->parseResponse($raw)); + } + + /** + * @group connected + */ + public function testExecutesTransactionAndReturnsArrayOfReplies() + { + $redis = $this->getClient(); + + $redis->multi(); + $redis->echo('tx1'); + $redis->echo('tx2'); + + $this->assertSame(array('tx1', 'tx2'), $redis->exec()); + } + + /** + * @group connected + */ + public function testReturnsEmptyArrayOnEmptyTransactions() + { + $redis = $this->getClient(); + + $redis->multi(); + + $this->assertSame(array(), $redis->exec()); + } + + /** + * @group connected + */ + public function testRepliesOfTransactionsAreNotParsed() + { + $redis = $this->getClient(); + + $redis->multi(); + $redis->ping(); + $redis->set('foo', 'bar'); + $redis->exists('foo'); + + $this->assertSame(array('PONG', true, 1), $redis->exec()); + } + + /** + * @group connected + * @expectedException Predis\ServerException + * @expectedExceptionMessage ERR EXEC without MULTI + */ + public function testThrowsExceptionWhenCallingOutsideTransaction() + { + $redis = $this->getClient(); + + $redis->exec(); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/TransactionMultiTest.php b/vendor/predis/predis/tests/Predis/Command/TransactionMultiTest.php new file mode 100755 index 0000000..d7bde81 --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/TransactionMultiTest.php @@ -0,0 +1,91 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @group commands + * @group realm-transaction + */ +class TransactionMultiTest extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return 'Predis\Command\TransactionMulti'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return 'MULTI'; + } + + /** + * @group disconnected + */ + public function testFilterArguments() + { + $command = $this->getCommand(); + $command->setArguments(array()); + + $this->assertSame(array(), $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse() + { + $this->assertTrue($this->getCommand()->parseResponse(true)); + } + + /** + * @group connected + */ + public function testInitializesNewTransaction() + { + $redis = $this->getClient(); + + $this->assertTrue($redis->multi()); + $this->assertSame('QUEUED', (string) $redis->echo('tx1')); + $this->assertSame('QUEUED', (string) $redis->echo('tx2')); + } + + /** + * @group connected + */ + public function testActuallyReturnsReplyObjectAbstraction() + { + $redis = $this->getClient(); + + $this->assertTrue($redis->multi()); + $this->assertInstanceOf('Predis\ResponseObjectInterface', $redis->echo('tx1')); + $this->assertInstanceOf('Predis\ResponseQueued', $redis->echo('tx2')); + } + + /** + * @group connected + * @expectedException Predis\ServerException + * @expectedExceptionMessage ERR MULTI calls can not be nested + */ + public function testThrowsExceptionWhenCallingMultiInsideTransaction() + { + $redis = $this->getClient(); + + $redis->multi(); + $redis->multi(); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/TransactionUnwatchTest.php b/vendor/predis/predis/tests/Predis/Command/TransactionUnwatchTest.php new file mode 100755 index 0000000..e437587 --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/TransactionUnwatchTest.php @@ -0,0 +1,84 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @group commands + * @group realm-transaction + */ +class TransactionUnwatchTest extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return 'Predis\Command\TransactionUnwatch'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return 'UNWATCH'; + } + + /** + * @group disconnected + */ + public function testFilterArguments() + { + $command = $this->getCommand(); + $command->setArguments(array()); + + $this->assertSame(array(), $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse() + { + $this->assertTrue($this->getCommand()->parseResponse(true)); + } + + /** + * @group connected + */ + public function testUnwatchWatchedKeys() + { + $redis1 = $this->getClient(); + $redis2 = $this->getClient(); + + $redis1->set('foo', 'bar'); + $redis1->watch('foo'); + $this->assertTrue($redis1->unwatch()); + $redis1->multi(); + $redis1->get('foo'); + + $redis2->set('foo', 'hijacked'); + + $this->assertSame(array('hijacked'), $redis1->exec()); + } + + /** + * @group connected + */ + public function testCanBeCalledInsideTransaction() + { + $redis = $this->getClient(); + + $redis->multi(); + $this->assertInstanceOf('Predis\ResponseQueued', $redis->unwatch()); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/TransactionWatchTest.php b/vendor/predis/predis/tests/Predis/Command/TransactionWatchTest.php new file mode 100755 index 0000000..494afbe --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/TransactionWatchTest.php @@ -0,0 +1,143 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @group commands + * @group realm-transaction + */ +class TransactionWatchTest extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return 'Predis\Command\TransactionWatch'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return 'WATCH'; + } + + /** + * @group disconnected + */ + public function testFilterArguments() + { + $arguments = array('key1', 'key2', 'key3'); + $expected = array('key1', 'key2', 'key3'); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testFilterArgumentsAsSingleArray() + { + $arguments = array(array('key1', 'key2', 'key3')); + $expected = array('key1', 'key2', 'key3'); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse() + { + $this->assertTrue($this->getCommand()->parseResponse(true)); + } + + /** + * @group disconnected + */ + public function testPrefixKeys() + { + $arguments = array('key1', 'key2', 'key3'); + $expected = array('prefix:key1', 'prefix:key2', 'prefix:key3'); + + $command = $this->getCommandWithArgumentsArray($arguments); + $command->prefixKeys('prefix:'); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testPrefixKeysIgnoredOnEmptyArguments() + { + $command = $this->getCommand(); + $command->prefixKeys('prefix:'); + + $this->assertSame(array(), $command->getArguments()); + } + + /** + * @group connected + */ + public function testAbortsTransactionOnExternalWriteOperations() + { + $redis1 = $this->getClient(); + $redis2 = $this->getClient(); + + $redis1->mset('foo', 'bar', 'hoge', 'piyo'); + + $this->assertTrue($redis1->watch('foo', 'hoge')); + $this->assertTrue($redis1->multi()); + $this->assertInstanceOf('Predis\ResponseQueued', $redis1->get('foo')); + $this->assertTrue($redis2->set('foo', 'hijacked')); + $this->assertNull($redis1->exec()); + $this->assertSame('hijacked', $redis1->get('foo')); + } + + /** + * @group connected + */ + public function testCanWatchNotYetExistingKeys() + { + $redis1 = $this->getClient(); + $redis2 = $this->getClient(); + + $this->assertTrue($redis1->watch('foo')); + $this->assertTrue($redis1->multi()); + $this->assertInstanceOf('Predis\ResponseQueued', $redis1->set('foo', 'bar')); + $this->assertTrue($redis2->set('foo', 'hijacked')); + $this->assertNull($redis1->exec()); + $this->assertSame('hijacked', $redis1->get('foo')); + } + + /** + * @group connected + * @expectedException Predis\ServerException + * @expectedExceptionMessage ERR WATCH inside MULTI is not allowed + */ + public function testThrowsExceptionWhenCallingInsideTransaction() + { + $redis = $this->getClient(); + + $redis->multi(); + $redis->watch('foo'); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/ZSetAddTest.php b/vendor/predis/predis/tests/Predis/Command/ZSetAddTest.php new file mode 100755 index 0000000..0a4280e --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/ZSetAddTest.php @@ -0,0 +1,134 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @group commands + * @group realm-zset + */ +class ZSetAddTest extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return 'Predis\Command\ZSetAdd'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return 'ZADD'; + } + + /** + * @group disconnected + */ + public function testFilterArguments() + { + $arguments = array('key', 1, 'member1', 2, 'member2'); + $expected = array('key', 1, 'member1', 2, 'member2'); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testFilterArgumentsMembersScoresAsSingleArray() + { + $arguments = array('key', array('member1' => 1, 'member2' => 2)); + $expected = array('key', 1, 'member1', 2, 'member2'); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse() + { + $this->assertSame(1, $this->getCommand()->parseResponse(1)); + } + + /** + * @group disconnected + */ + public function testPrefixKeys() + { + $arguments = array('key', 'score1', 'member1', 'score2', 'member2'); + $expected = array('prefix:key', 'score1', 'member1', 'score2', 'member2'); + + $command = $this->getCommandWithArgumentsArray($arguments); + $command->prefixKeys('prefix:'); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testPrefixKeysIgnoredOnEmptyArguments() + { + $command = $this->getCommand(); + $command->prefixKeys('prefix:'); + + $this->assertSame(array(), $command->getArguments()); + } + + /** + * @group connected + */ + public function testAddsOrUpdatesMembersOrderingByScore() + { + $redis = $this->getClient(); + + $this->assertSame(5, $redis->zadd('letters', 1, 'a', 2, 'b', 3, 'c', 4, 'd', 5, 'e')); + $this->assertSame(array('a', 'b', 'c', 'd', 'e'), $redis->zrange('letters', 0, -1)); + + $this->assertSame(1, $redis->zadd('letters', 1, 'e', 8, 'c', 6, 'f')); + $this->assertSame(array('a', 'e', 'b', 'd', 'f', 'c'), $redis->zrange('letters', 0, -1)); + } + + /** + * @group connected + */ + public function testAcceptsFloatValuesAsScore() + { + $redis = $this->getClient(); + + $redis->zadd('letters', 0.2, 'b', 0.3, 'a', 0.1, 'c'); + $this->assertSame(array('c', 'b', 'a'), $redis->zrange('letters', 0, -1)); + } + + /** + * @group connected + * @expectedException Predis\ServerException + * @expectedExceptionMessage Operation against a key holding the wrong kind of value + */ + public function testThrowsExceptionOnWrongType() + { + $redis = $this->getClient(); + + $redis->set('foo', 'bar'); + $redis->zadd('foo', 10, 'bar'); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/ZSetCardinalityTest.php b/vendor/predis/predis/tests/Predis/Command/ZSetCardinalityTest.php new file mode 100755 index 0000000..2be63fa --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/ZSetCardinalityTest.php @@ -0,0 +1,108 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @group commands + * @group realm-zset + */ +class ZSetCardinalityTest extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return 'Predis\Command\ZSetCardinality'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return 'ZCARD'; + } + + /** + * @group disconnected + */ + public function testFilterArguments() + { + $arguments = array('key'); + $expected = array('key'); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse() + { + $this->assertSame(1, $this->getCommand()->parseResponse(1)); + } + + /** + * @group disconnected + */ + public function testPrefixKeys() + { + $arguments = array('key'); + $expected = array('prefix:key'); + + $command = $this->getCommandWithArgumentsArray($arguments); + $command->prefixKeys('prefix:'); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testPrefixKeysIgnoredOnEmptyArguments() + { + $command = $this->getCommand(); + $command->prefixKeys('prefix:'); + + $this->assertSame(array(), $command->getArguments()); + } + + /** + * @group connected + */ + public function testReturnsSizeOfSortedSet() + { + $redis = $this->getClient(); + + $redis->zadd('letters', 1, 'a', 2, 'b', 3, 'c'); + $this->assertSame(3, $redis->zcard('letters')); + + $this->assertSame(0, $redis->zcard('unknown')); + } + + /** + * @group connected + * @expectedException Predis\ServerException + * @expectedExceptionMessage Operation against a key holding the wrong kind of value + */ + public function testThrowsExceptionOnWrongType() + { + $redis = $this->getClient(); + + $redis->set('foo', 'bar'); + $redis->zcard('foo'); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/ZSetCountTest.php b/vendor/predis/predis/tests/Predis/Command/ZSetCountTest.php new file mode 100755 index 0000000..03cc696 --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/ZSetCountTest.php @@ -0,0 +1,141 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @group commands + * @group realm-zset + */ +class ZSetCountTest extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return 'Predis\Command\ZSetCount'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return 'ZCOUNT'; + } + + /** + * @group disconnected + */ + public function testFilterArguments() + { + $arguments = array('key', 0, 10); + $expected = array('key', 0, 10); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse() + { + $this->assertSame(1, $this->getCommand()->parseResponse(1)); + } + + /** + * @group disconnected + */ + public function testPrefixKeys() + { + $arguments = array('key', 0, 10); + $expected = array('prefix:key', 0, 10); + + $command = $this->getCommandWithArgumentsArray($arguments); + $command->prefixKeys('prefix:'); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testPrefixKeysIgnoredOnEmptyArguments() + { + $command = $this->getCommand(); + $command->prefixKeys('prefix:'); + + $this->assertSame(array(), $command->getArguments()); + } + + /** + * @group connected + */ + public function testReturnsNumberOfElementsInGivenScoreRange() + { + $redis = $this->getClient(); + + $redis->zadd('letters', 10, 'a', 20, 'b', 30, 'c', 40, 'd', 50, 'e'); + + $this->assertSame(5, $redis->zcount('letters', 0, 100)); + $this->assertSame(5, $redis->zcount('letters', -100, 100)); + $this->assertSame(2, $redis->zcount('letters', 25, 45)); + $this->assertSame(1, $redis->zcount('letters', 20, 20)); + $this->assertSame(0, $redis->zcount('letters', 0, 0)); + + $this->assertSame(0, $redis->zcount('unknown', 0, 100)); + } + + /** + * @group connected + */ + public function testInfinityScoreIntervals() + { + $redis = $this->getClient(); + + $redis->zadd('letters', 10, 'a', 20, 'b', 30, 'c', 40, 'd', 50, 'e'); + + $this->assertSame(3, $redis->zcount('letters', '-inf', 30)); + $this->assertSame(3, $redis->zcount('letters', 30, '+inf')); + $this->assertSame(5, $redis->zcount('letters', '-inf', '+inf')); + } + + /** + * @group connected + */ + public function testExclusiveScoreIntervals() + { + $redis = $this->getClient(); + + $redis->zadd('letters', 10, 'a', 20, 'b', 30, 'c', 40, 'd', 50, 'e'); + + $this->assertSame(2, $redis->zcount('letters', 10, '(30')); + $this->assertSame(2, $redis->zcount('letters', '(10', 30)); + $this->assertSame(1, $redis->zcount('letters', '(10', '(30')); + } + + /** + * @group connected + * @expectedException Predis\ServerException + * @expectedExceptionMessage Operation against a key holding the wrong kind of value + */ + public function testThrowsExceptionOnWrongType() + { + $redis = $this->getClient(); + + $redis->set('foo', 'bar'); + $redis->zcount('foo', 0, 10); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/ZSetIncrementByTest.php b/vendor/predis/predis/tests/Predis/Command/ZSetIncrementByTest.php new file mode 100755 index 0000000..ab65a91 --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/ZSetIncrementByTest.php @@ -0,0 +1,108 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @group commands + * @group realm-zset + */ +class ZSetIncrementByTest extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return 'Predis\Command\ZSetIncrementBy'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return 'ZINCRBY'; + } + + /** + * @group disconnected + */ + public function testFilterArguments() + { + $arguments = array('key', 1.0, 'member'); + $expected = array('key', 1.0, 'member'); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse() + { + $this->assertSame('1', $this->getCommand()->parseResponse('1')); + } + + /** + * @group disconnected + */ + public function testPrefixKeys() + { + $arguments = array('key', 1.0, 'member'); + $expected = array('prefix:key', 1.0, 'member'); + + $command = $this->getCommandWithArgumentsArray($arguments); + $command->prefixKeys('prefix:'); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testPrefixKeysIgnoredOnEmptyArguments() + { + $command = $this->getCommand(); + $command->prefixKeys('prefix:'); + + $this->assertSame(array(), $command->getArguments()); + } + + /** + * @group connected + */ + public function testIncrementsScoreOfMemberByFloat() + { + $redis = $this->getClient(); + + $this->assertSame('1', $redis->zincrby('letters', 1, 'member')); + $this->assertSame('0', $redis->zincrby('letters', -1, 'member')); + $this->assertSame('0.5', $redis->zincrby('letters', 0.5, 'member')); + $this->assertSame('-10', $redis->zincrby('letters', -10.5, 'member')); + } + + /** + * @group connected + * @expectedException Predis\ServerException + * @expectedExceptionMessage Operation against a key holding the wrong kind of value + */ + public function testThrowsExceptionOnWrongType() + { + $redis = $this->getClient(); + + $redis->set('foo', 'bar'); + $redis->zincrby('foo', 1, 'bar'); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/ZSetIntersectionStoreTest.php b/vendor/predis/predis/tests/Predis/Command/ZSetIntersectionStoreTest.php new file mode 100755 index 0000000..c2c8e1c --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/ZSetIntersectionStoreTest.php @@ -0,0 +1,201 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @group commands + * @group realm-zset + */ +class ZSetIntersectionStoreTest extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return 'Predis\Command\ZSetIntersectionStore'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return 'ZINTERSTORE'; + } + + /** + * @group disconnected + */ + public function testFilterArguments() + { + $modifiers = array( + 'aggregate' => 'sum', + 'weights' => array(10, 100), + ); + $arguments = array('zset:destination', 2, 'zset1', 'zset2', $modifiers); + + $expected = array( + 'zset:destination', 2, 'zset1', 'zset2', 'WEIGHTS', 10, 100, 'AGGREGATE', 'sum' + ); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testFilterArgumentsSourceKeysAsSingleArray() + { + $modifiers = array( + 'aggregate' => 'sum', + 'weights' => array(10, 100), + ); + $arguments = array('zset:destination', array('zset1', 'zset2'), $modifiers); + + $expected = array( + 'zset:destination', 2, 'zset1', 'zset2', 'WEIGHTS', 10, 100, 'AGGREGATE', 'sum' + ); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse() + { + $this->assertSame(1, $this->getCommand()->parseResponse(1)); + } + + /** + * @group disconnected + */ + public function testPrefixKeys() + { + $modifiers = array( + 'aggregate' => 'sum', + 'weights' => array(10, 100), + ); + $arguments = array('zset:destination', 2, 'zset1', 'zset2', $modifiers); + + $expected = array( + 'prefix:zset:destination', 2, 'prefix:zset1', 'prefix:zset2', 'WEIGHTS', 10, 100, 'AGGREGATE', 'sum' + ); + + $command = $this->getCommandWithArgumentsArray($arguments); + $command->prefixKeys('prefix:'); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testPrefixKeysIgnoredOnEmptyArguments() + { + $command = $this->getCommand(); + $command->prefixKeys('prefix:'); + + $this->assertSame(array(), $command->getArguments()); + } + + /** + * @group connected + */ + public function testStoresIntersectionInNewSortedSet() + { + $redis = $this->getClient(); + + $redis->zadd('letters:1st', 1, 'a', 2, 'b', 3, 'c'); + $redis->zadd('letters:2nd', 1, 'b', 2, 'c', 3, 'd'); + + $this->assertSame(2, $redis->zinterstore('letters:out', 2, 'letters:1st', 'letters:2nd')); + $this->assertSame(array(array('b', '3'), array('c', '5')), $redis->zrange('letters:out', 0, -1, 'withscores')); + + $this->assertSame(0, $redis->zinterstore('letters:out', 2, 'letters:1st', 'letters:void')); + $this->assertSame(0, $redis->zinterstore('letters:out', 2, 'letters:void', 'letters:2nd')); + $this->assertSame(0, $redis->zinterstore('letters:out', 2, 'letters:void', 'letters:void')); + } + + /** + * @group connected + */ + public function testStoresIntersectionWithAggregateModifier() + { + $redis = $this->getClient(); + + $redis->zadd('letters:1st', 1, 'a', 2, 'b', 3, 'c'); + $redis->zadd('letters:2nd', 1, 'b', 2, 'c', 3, 'd'); + + $options = array('aggregate' => 'min'); + $this->assertSame(2, $redis->zinterstore('letters:min', 2, 'letters:1st', 'letters:2nd', $options)); + $this->assertSame(array(array('b', '1'), array('c', '2')), $redis->zrange('letters:min', 0, -1, 'withscores')); + + $options = array('aggregate' => 'max'); + $this->assertSame(2, $redis->zinterstore('letters:max', 2, 'letters:1st', 'letters:2nd', $options)); + $this->assertSame(array(array('b', '2'), array('c', '3')), $redis->zrange('letters:max', 0, -1, 'withscores')); + + $options = array('aggregate' => 'sum'); + $this->assertSame(2, $redis->zinterstore('letters:sum', 2, 'letters:1st', 'letters:2nd', $options)); + $this->assertSame(array(array('b', '3'), array('c', '5')), $redis->zrange('letters:sum', 0, -1, 'withscores')); + } + + /** + * @group connected + */ + public function testStoresIntersectionWithWeightsModifier() + { + $redis = $this->getClient(); + + $redis->zadd('letters:1st', 1, 'a', 2, 'b', 3, 'c'); + $redis->zadd('letters:2nd', 1, 'b', 2, 'c', 3, 'd'); + + $options = array('weights' => array(2, 3)); + $this->assertSame(2, $redis->zinterstore('letters:out', 2, 'letters:1st', 'letters:2nd', $options)); + $this->assertSame(array(array('b', '7'), array('c', '12')), $redis->zrange('letters:out', 0, -1, 'withscores')); + } + + /** + * @group connected + */ + public function testStoresIntersectionWithCombinedModifiers() + { + $redis = $this->getClient(); + + $redis->zadd('letters:1st', 1, 'a', 2, 'b', 3, 'c'); + $redis->zadd('letters:2nd', 1, 'b', 2, 'c', 3, 'd'); + + $options = array('aggregate' => 'max', 'weights' => array(10, 15)); + $this->assertSame(2, $redis->zinterstore('letters:out', 2, 'letters:1st', 'letters:2nd', $options)); + $this->assertSame(array(array('b', '20'), array('c', '30')), $redis->zrange('letters:out', 0, -1, 'withscores')); + } + + /** + * @group connected + * @expectedException Predis\ServerException + * @expectedExceptionMessage Operation against a key holding the wrong kind of value + */ + public function testThrowsExceptionOnWrongType() + { + $redis = $this->getClient(); + + $redis->set('foo', 'bar'); + $redis->zinterstore('zset:destination', 1, 'foo'); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/ZSetRangeByScoreTest.php b/vendor/predis/predis/tests/Predis/Command/ZSetRangeByScoreTest.php new file mode 100755 index 0000000..6b37a12 --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/ZSetRangeByScoreTest.php @@ -0,0 +1,257 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @group commands + * @group realm-zset + */ +class ZSetRangeByScoreTest extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return 'Predis\Command\ZSetRangeByScore'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return 'ZRANGEBYSCORE'; + } + + /** + * @group disconnected + */ + public function testFilterArguments() + { + $modifiers = array( + 'withscores' => true, + 'limit' => array(0, 100), + ); + + $arguments = array('zset', 0, 100, $modifiers); + $expected = array('zset', 0, 100, 'LIMIT', 0, 100, 'WITHSCORES'); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testFilterArgumentsWithStringWithscores() + { + $arguments = array('zset', 0, 100, 'withscores'); + $expected = array('zset', 0, 100, 'WITHSCORES'); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testFilterArgumentsWithNamedLimit() + { + $arguments = array('zset', 0, 100, array('limit' => array('offset' => 1, 'count' => 2))); + $expected = array('zset', 0, 100, 'LIMIT', 1, 2); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse() + { + $raw = array('element1', 'element2', 'element3'); + $expected = array('element1', 'element2', 'element3'); + + $command = $this->getCommand(); + + $this->assertSame($expected, $command->parseResponse($raw)); + } + + /** + * @group disconnected + */ + public function testParseResponseWithScores() + { + $raw = array('element1', '1', 'element2', '2', 'element3', '3'); + $expected = array(array('element1', '1'), array('element2', '2'), array('element3', '3')); + + $command = $this->getCommandWithArgumentsArray(array('zset', 0, 1, 'withscores')); + + $this->assertSame($expected, $command->parseResponse($raw)); + } + + /** + * @group disconnected + */ + public function testPrefixKeys() + { + $modifiers = array( + 'withscores' => true, + 'limit' => array(0, 100), + ); + + $arguments = array('zset', 0, 100, $modifiers); + $expected = array('prefix:zset', 0, 100, 'LIMIT', 0, 100, 'WITHSCORES'); + + $command = $this->getCommandWithArgumentsArray($arguments); + $command->prefixKeys('prefix:'); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testPrefixKeysIgnoredOnEmptyArguments() + { + $command = $this->getCommand(); + $command->prefixKeys('prefix:'); + + $this->assertSame(array(), $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testAddsWithscoresModifiersOnlyWhenOptionIsTrue() + { + $command = $this->getCommandWithArguments('zset', 0, 100, array('withscores' => true)); + $this->assertSame(array('zset', 0, 100, 'WITHSCORES'), $command->getArguments()); + + $command = $this->getCommandWithArguments('zset', 0, 100, array('withscores' => 1)); + $this->assertSame(array('zset', 0, 100, 'WITHSCORES'), $command->getArguments()); + + $command = $this->getCommandWithArguments('zset', 0, 100, array('withscores' => false)); + $this->assertSame(array('zset', 0, 100), $command->getArguments()); + + $command = $this->getCommandWithArguments('zset', 0, 100, array('withscores' => 0)); + $this->assertSame(array('zset', 0, 100), $command->getArguments()); + } + + /** + * @group connected + */ + public function testReturnsElementsInScoreRange() + { + $redis = $this->getClient(); + + $redis->zadd('letters', -10, 'a', 0, 'b', 10, 'c', 20, 'd', 20, 'e', 30, 'f'); + + $this->assertSame(array('a'), $redis->zrangebyscore('letters', -10, -10)); + $this->assertSame(array('c', 'd', 'e', 'f'), $redis->zrangebyscore('letters', 10, 30)); + $this->assertSame(array('d', 'e'), $redis->zrangebyscore('letters', 20, 20)); + $this->assertSame(array(), $redis->zrangebyscore('letters', 30, 0)); + + $this->assertSame(array(), $redis->zrangebyscore('unknown', 0, 30)); + } + + /** + * @group connected + */ + public function testInfinityScoreIntervals() + { + $redis = $this->getClient(); + + $redis->zadd('letters', -10, 'a', 0, 'b', 10, 'c', 20, 'd', 20, 'e', 30, 'f'); + + $this->assertSame(array('a', 'b', 'c'), $redis->zrangebyscore('letters', '-inf', 15)); + $this->assertSame(array('d', 'e', 'f'), $redis->zrangebyscore('letters', 15, '+inf')); + $this->assertSame(array('a', 'b', 'c', 'd', 'e', 'f'), $redis->zrangebyscore('letters', '-inf', '+inf')); + } + + /** + * @group connected + */ + public function testExclusiveScoreIntervals() + { + $redis = $this->getClient(); + + $redis->zadd('letters', -10, 'a', 0, 'b', 10, 'c', 20, 'd', 20, 'e', 30, 'f'); + + $this->assertSame(array('c', 'd', 'e'), $redis->zrangebyscore('letters', 10, '(30')); + $this->assertSame(array('d', 'e', 'f'), $redis->zrangebyscore('letters', '(10', 30)); + $this->assertSame(array('d', 'e'), $redis->zrangebyscore('letters', '(10', '(30')); + } + + /** + * @group connected + */ + public function testRangeWithWithscoresModifier() + { + $redis = $this->getClient(); + + $redis->zadd('letters', -10, 'a', 0, 'b', 10, 'c', 20, 'd', 20, 'e', 30, 'f'); + $expected = array(array('c', '10'), array('d', '20'), array('e', '20')); + + $this->assertSame($expected, $redis->zrangebyscore('letters', 10, 20, 'withscores')); + $this->assertSame($expected, $redis->zrangebyscore('letters', 10, 20, array('withscores' => true))); + } + + /** + * @group connected + */ + public function testRangeWithLimitModifier() + { + $redis = $this->getClient(); + + $redis->zadd('letters', -10, 'a', 0, 'b', 10, 'c', 20, 'd', 20, 'e', 30, 'f'); + $expected = array('d', 'e'); + + $this->assertSame($expected, $redis->zrangebyscore('letters', 10, 20, array('limit' => array(1, 2)))); + $this->assertSame($expected, $redis->zrangebyscore('letters', 10, 20, array('limit' => array('offset' => 1, 'count' => 2)))); + } + + /** + * @group connected + */ + public function testRangeWithCombinedModifiers() + { + $redis = $this->getClient(); + + $redis->zadd('letters', -10, 'a', 0, 'b', 10, 'c', 20, 'd', 20, 'e', 30, 'f'); + + $options = array('limit' => array(1, 2), 'withscores' => true); + $expected = array(array('d', '20'), array('e', '20')); + + $this->assertSame($expected, $redis->zrangebyscore('letters', 10, 20, $options)); + } + + /** + * @group connected + * @expectedException Predis\ServerException + * @expectedExceptionMessage Operation against a key holding the wrong kind of value + */ + public function testThrowsExceptionOnWrongType() + { + $redis = $this->getClient(); + + $redis->set('foo', 'bar'); + $redis->zrangebyscore('foo', 0, 10); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/ZSetRangeTest.php b/vendor/predis/predis/tests/Predis/Command/ZSetRangeTest.php new file mode 100755 index 0000000..1ea7a97 --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/ZSetRangeTest.php @@ -0,0 +1,180 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @group commands + * @group realm-zset + */ +class ZSetRangeTest extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return 'Predis\Command\ZSetRange'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return 'ZRANGE'; + } + + /** + * @group disconnected + */ + public function testFilterArguments() + { + $arguments = array('zset', 0, 100, array('withscores' => true)); + $expected = array('zset', 0, 100, 'WITHSCORES'); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testFilterArgumentsWithStringWithscores() + { + $arguments = array('zset', 0, 100, 'withscores'); + $expected = array('zset', 0, 100, 'WITHSCORES'); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse() + { + $raw = array('element1', 'element2', 'element3'); + $expected = array('element1', 'element2', 'element3'); + + $command = $this->getCommand(); + + $this->assertSame($expected, $command->parseResponse($raw)); + } + + /** + * @group disconnected + */ + public function testParseResponseWithScores() + { + $raw = array('element1', '1', 'element2', '2', 'element3', '3'); + $expected = array(array('element1', '1'), array('element2', '2'), array('element3', '3')); + + $command = $this->getCommandWithArgumentsArray(array('zset', 0, 1, 'withscores')); + + $this->assertSame($expected, $command->parseResponse($raw)); + } + + /** + * @group disconnected + */ + public function testPrefixKeys() + { + $arguments = array('zset', 0, 100, array('withscores' => true)); + $expected = array('prefix:zset', 0, 100, 'WITHSCORES'); + + $command = $this->getCommandWithArgumentsArray($arguments); + $command->prefixKeys('prefix:'); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testPrefixKeysIgnoredOnEmptyArguments() + { + $command = $this->getCommand(); + $command->prefixKeys('prefix:'); + + $this->assertSame(array(), $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testAddsWithscoresModifiersOnlyWhenOptionIsTrue() + { + $command = $this->getCommandWithArguments('zset', 0, 100, array('withscores' => true)); + $this->assertSame(array('zset', 0, 100, 'WITHSCORES'), $command->getArguments()); + + $command = $this->getCommandWithArguments('zset', 0, 100, array('withscores' => 1)); + $this->assertSame(array('zset', 0, 100, 'WITHSCORES'), $command->getArguments()); + + $command = $this->getCommandWithArguments('zset', 0, 100, array('withscores' => false)); + $this->assertSame(array('zset', 0, 100), $command->getArguments()); + + $command = $this->getCommandWithArguments('zset', 0, 100, array('withscores' => 0)); + $this->assertSame(array('zset', 0, 100), $command->getArguments()); + } + + /** + * @group connected + */ + public function testReturnsElementsInRange() + { + $redis = $this->getClient(); + + $redis->zadd('letters', -10, 'a', 0, 'b', 10, 'c', 20, 'd', 20, 'e', 30, 'f'); + + $this->assertSame(array(), $redis->zrange('letters', 1, 0)); + $this->assertSame(array('a'), $redis->zrange('letters', 0, 0)); + $this->assertSame(array('a', 'b', 'c', 'd'), $redis->zrange('letters', 0, 3)); + + $this->assertSame(array('a', 'b', 'c', 'd', 'e', 'f'), $redis->zrange('letters', 0, -1)); + $this->assertSame(array('a', 'b', 'c'), $redis->zrange('letters', 0, -4)); + $this->assertSame(array('c'), $redis->zrange('letters', 2, -4)); + $this->assertSame(array('a', 'b', 'c', 'd', 'e', 'f'), $redis->zrange('letters', -100, 100)); + + $this->assertSame(array(), $redis->zrange('unknown', 0, 30)); + } + + /** + * @group connected + */ + public function testRangeWithWithscoresModifier() + { + $redis = $this->getClient(); + + $redis->zadd('letters', -10, 'a', 0, 'b', 10, 'c', 20, 'd', 20, 'e', 30, 'f'); + $expected = array(array('c', '10'), array('d', '20'), array('e', '20')); + + $this->assertSame($expected, $redis->zrange('letters', 2, 4, 'withscores')); + $this->assertSame($expected, $redis->zrange('letters', 2, 4, array('withscores' => true))); + } + + /** + * @group connected + * @expectedException Predis\ServerException + * @expectedExceptionMessage Operation against a key holding the wrong kind of value + */ + public function testThrowsExceptionOnWrongType() + { + $redis = $this->getClient(); + + $redis->set('foo', 'bar'); + $redis->zrange('foo', 0, 10); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/ZSetRankTest.php b/vendor/predis/predis/tests/Predis/Command/ZSetRankTest.php new file mode 100755 index 0000000..87c4932 --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/ZSetRankTest.php @@ -0,0 +1,111 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @group commands + * @group realm-zset + */ +class ZSetRankTest extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return 'Predis\Command\ZSetRank'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return 'ZRANK'; + } + + /** + * @group disconnected + */ + public function testFilterArguments() + { + $arguments = array('key', 'member'); + $expected = array('key', 'member'); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse() + { + $this->assertSame(1, $this->getCommand()->parseResponse(1)); + } + + /** + * @group disconnected + */ + public function testPrefixKeys() + { + $arguments = array('key', 'member'); + $expected = array('prefix:key', 'member'); + + $command = $this->getCommandWithArgumentsArray($arguments); + $command->prefixKeys('prefix:'); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testPrefixKeysIgnoredOnEmptyArguments() + { + $command = $this->getCommand(); + $command->prefixKeys('prefix:'); + + $this->assertSame(array(), $command->getArguments()); + } + + /** + * @group connected + */ + public function testReturnsRank() + { + $redis = $this->getClient(); + + $redis->zadd('letters', -10, 'a', 0, 'b', 10, 'c', 20, 'd', 20, 'e', 30, 'f'); + + $this->assertSame(0, $redis->zrank('letters', 'a')); + $this->assertSame(1, $redis->zrank('letters', 'b')); + $this->assertSame(4, $redis->zrank('letters', 'e')); + + $this->assertNull($redis->zrank('unknown', 'a')); + } + + /** + * @group connected + * @expectedException Predis\ServerException + * @expectedExceptionMessage Operation against a key holding the wrong kind of value + */ + public function testThrowsExceptionOnWrongType() + { + $redis = $this->getClient(); + + $redis->set('foo', 'bar'); + $redis->zrank('foo', 'bar'); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/ZSetRemoveRangeByRankTest.php b/vendor/predis/predis/tests/Predis/Command/ZSetRemoveRangeByRankTest.php new file mode 100755 index 0000000..9bdcc59 --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/ZSetRemoveRangeByRankTest.php @@ -0,0 +1,123 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @group commands + * @group realm-zset + */ +class ZSetRemoveRangeByRankTest extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return 'Predis\Command\ZSetRemoveRangeByRank'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return 'ZREMRANGEBYRANK'; + } + + /** + * @group disconnected + */ + public function testFilterArguments() + { + $arguments = array('key', 0, 10); + $expected = array('key', 0, 10); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse() + { + $this->assertSame(1, $this->getCommand()->parseResponse(1)); + } + + /** + * @group disconnected + */ + public function testPrefixKeys() + { + $arguments = array('key', 0, 10); + $expected = array('prefix:key', 0, 10); + + $command = $this->getCommandWithArgumentsArray($arguments); + $command->prefixKeys('prefix:'); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testPrefixKeysIgnoredOnEmptyArguments() + { + $command = $this->getCommand(); + $command->prefixKeys('prefix:'); + + $this->assertSame(array(), $command->getArguments()); + } + + /** + * @group connected + */ + public function testRemovesRangeByRank() + { + $redis = $this->getClient(); + + $redis->zadd('letters', -10, 'a', 0, 'b', 10, 'c', 20, 'd', 20, 'e', 30, 'f'); + + $this->assertSame(3, $redis->zremrangebyrank('letters', 2, 4)); + $this->assertSame(array('a', 'b', 'f'), $redis->zrange('letters', 0, -1)); + + $this->assertSame(0, $redis->zremrangebyrank('unknown', 0, 30)); + } + + /** + * @group connected + */ + public function testRemovesRangeByRankWithNegativeIndex() + { + $redis = $this->getClient(); + + $redis->zadd('letters', -10, 'a', 0, 'b', 10, 'c', 20, 'd', 20, 'e', 30, 'f'); + + $this->assertSame(3, $redis->zremrangebyrank('letters', -5, 3)); + $this->assertSame(array('a', 'e', 'f'), $redis->zrange('letters', 0, -1)); + } + + /** + * @group connected + * @expectedException Predis\ServerException + * @expectedExceptionMessage Operation against a key holding the wrong kind of value + */ + public function testThrowsExceptionOnWrongType() + { + $redis = $this->getClient(); + + $redis->set('foo', 'bar'); + $redis->zremrangebyrank('foo', 0, 10); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/ZSetRemoveRangeByScoreTest.php b/vendor/predis/predis/tests/Predis/Command/ZSetRemoveRangeByScoreTest.php new file mode 100755 index 0000000..193d72b --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/ZSetRemoveRangeByScoreTest.php @@ -0,0 +1,123 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @group commands + * @group realm-zset + */ +class ZSetRemoveRangeByScoreTest extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return 'Predis\Command\ZSetRemoveRangeByScore'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return 'ZREMRANGEBYSCORE'; + } + + /** + * @group disconnected + */ + public function testFilterArguments() + { + $arguments = array('key', 0, 10); + $expected = array('key', 0, 10); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse() + { + $this->assertSame(1, $this->getCommand()->parseResponse(1)); + } + + /** + * @group disconnected + */ + public function testPrefixKeys() + { + $arguments = array('key', 0, 10); + $expected = array('prefix:key', 0, 10); + + $command = $this->getCommandWithArgumentsArray($arguments); + $command->prefixKeys('prefix:'); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testPrefixKeysIgnoredOnEmptyArguments() + { + $command = $this->getCommand(); + $command->prefixKeys('prefix:'); + + $this->assertSame(array(), $command->getArguments()); + } + + /** + * @group connected + */ + public function testRemovesRangeByScore() + { + $redis = $this->getClient(); + + $redis->zadd('letters', -10, 'a', 0, 'b', 10, 'c', 20, 'd', 20, 'e', 30, 'f'); + + $this->assertSame(3, $redis->zremrangebyscore('letters', 5, 20)); + $this->assertSame(array('a', 'b', 'f'), $redis->zrange('letters', 0, -1)); + + $this->assertSame(0, $redis->zremrangebyscore('unknown', 0, 30)); + } + + /** + * @group connected + */ + public function testRemovesRangeByExclusiveScore() + { + $redis = $this->getClient(); + + $redis->zadd('letters', -10, 'a', 0, 'b', 10, 'c', 20, 'd', 20, 'e', 30, 'f'); + + $this->assertSame(2, $redis->zremrangebyscore('letters', '(10', '(30')); + $this->assertSame(array('a', 'b', 'c', 'f'), $redis->zrange('letters', 0, -1)); + } + + /** + * @group connected + * @expectedException Predis\ServerException + * @expectedExceptionMessage Operation against a key holding the wrong kind of value + */ + public function testThrowsExceptionOnWrongType() + { + $redis = $this->getClient(); + + $redis->set('foo', 'bar'); + $redis->zremrangebyscore('foo', 0, 10); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/ZSetRemoveTest.php b/vendor/predis/predis/tests/Predis/Command/ZSetRemoveTest.php new file mode 100755 index 0000000..f419ddb --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/ZSetRemoveTest.php @@ -0,0 +1,110 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @group commands + * @group realm-zset + */ +class ZSetRemoveTest extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return 'Predis\Command\ZSetRemove'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return 'ZREM'; + } + + /** + * @group disconnected + */ + public function testFilterArguments() + { + $arguments = array('zset', 'member1', 'member2', 'member3'); + $expected = array('zset', 'member1', 'member2', 'member3'); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse() + { + $this->assertSame(1, $this->getCommand()->parseResponse(1)); + } + + /** + * @group disconnected + */ + public function testPrefixKeys() + { + $arguments = array('zset', 'member1', 'member2', 'member3'); + $expected = array('prefix:zset', 'member1', 'member2', 'member3'); + + $command = $this->getCommandWithArgumentsArray($arguments); + $command->prefixKeys('prefix:'); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testPrefixKeysIgnoredOnEmptyArguments() + { + $command = $this->getCommand(); + $command->prefixKeys('prefix:'); + + $this->assertSame(array(), $command->getArguments()); + } + + /** + * @group connected + */ + public function testRemovesSpecifiedMembers() + { + $redis = $this->getClient(); + + $redis->zadd('letters', -10, 'a', 0, 'b', 10, 'c', 20, 'd', 20, 'e', 30, 'f'); + + $this->assertSame(3, $redis->zrem('letters', 'b', 'd', 'f', 'z')); + $this->assertSame(array('a', 'c', 'e'), $redis->zrange('letters', 0, -1)); + + $this->assertSame(0, $redis->zrem('unknown', 'a')); + } + + /** + * @group connected + * @expectedException Predis\ServerException + * @expectedExceptionMessage Operation against a key holding the wrong kind of value + */ + public function testThrowsExceptionOnWrongType() + { + $redis = $this->getClient(); + + $redis->set('foo', 'bar'); + $redis->zrem('foo', 'bar'); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/ZSetReverseRangeByScoreTest.php b/vendor/predis/predis/tests/Predis/Command/ZSetReverseRangeByScoreTest.php new file mode 100755 index 0000000..1186ed3 --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/ZSetReverseRangeByScoreTest.php @@ -0,0 +1,257 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @group commands + * @group realm-zset + */ +class ZSetReverseRangeByScoreTest extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return 'Predis\Command\ZSetReverseRangeByScore'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return 'ZREVRANGEBYSCORE'; + } + + /** + * @group disconnected + */ + public function testFilterArguments() + { + $modifiers = array( + 'withscores' => true, + 'limit' => array(0, 100), + ); + + $arguments = array('zset', 0, 100, $modifiers); + $expected = array('zset', 0, 100, 'LIMIT', 0, 100, 'WITHSCORES'); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testFilterArgumentsWithStringWithscores() + { + $arguments = array('zset', 0, 100, 'withscores'); + $expected = array('zset', 0, 100, 'WITHSCORES'); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testFilterArgumentsWithNamedLimit() + { + $arguments = array('zset', 0, 100, array('limit' => array('offset' => 1, 'count' => 2))); + $expected = array('zset', 0, 100, 'LIMIT', 1, 2); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse() + { + $raw = array('element1', 'element2', 'element3'); + $expected = array('element1', 'element2', 'element3'); + + $command = $this->getCommand(); + + $this->assertSame($expected, $command->parseResponse($raw)); + } + + /** + * @group disconnected + */ + public function testParseResponseWithScores() + { + $raw = array('element1', '1', 'element2', '2', 'element3', '3'); + $expected = array(array('element1', '1'), array('element2', '2'), array('element3', '3')); + + $command = $this->getCommandWithArgumentsArray(array('zset', 0, 1, 'withscores')); + + $this->assertSame($expected, $command->parseResponse($raw)); + } + + /** + * @group disconnected + */ + public function testPrefixKeys() + { + $modifiers = array( + 'withscores' => true, + 'limit' => array(0, 100), + ); + + $arguments = array('zset', 0, 100, $modifiers); + $expected = array('prefix:zset', 0, 100, 'LIMIT', 0, 100, 'WITHSCORES'); + + $command = $this->getCommandWithArgumentsArray($arguments); + $command->prefixKeys('prefix:'); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testPrefixKeysIgnoredOnEmptyArguments() + { + $command = $this->getCommand(); + $command->prefixKeys('prefix:'); + + $this->assertSame(array(), $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testAddsWithscoresModifiersOnlyWhenOptionIsTrue() + { + $command = $this->getCommandWithArguments('zset', 0, 100, array('withscores' => true)); + $this->assertSame(array('zset', 0, 100, 'WITHSCORES'), $command->getArguments()); + + $command = $this->getCommandWithArguments('zset', 0, 100, array('withscores' => 1)); + $this->assertSame(array('zset', 0, 100, 'WITHSCORES'), $command->getArguments()); + + $command = $this->getCommandWithArguments('zset', 0, 100, array('withscores' => false)); + $this->assertSame(array('zset', 0, 100), $command->getArguments()); + + $command = $this->getCommandWithArguments('zset', 0, 100, array('withscores' => 0)); + $this->assertSame(array('zset', 0, 100), $command->getArguments()); + } + + /** + * @group connected + */ + public function testReturnsElementsInScoreRange() + { + $redis = $this->getClient(); + + $redis->zadd('letters', -10, 'a', 0, 'b', 10, 'c', 20, 'd', 20, 'e', 30, 'f'); + + $this->assertSame(array('a'), $redis->zrevrangebyscore('letters', -10, -10)); + $this->assertSame(array(), $redis->zrevrangebyscore('letters', 10, 30)); + $this->assertSame(array('e', 'd'), $redis->zrevrangebyscore('letters', 20, 20)); + $this->assertSame(array('f', 'e', 'd', 'c', 'b'), $redis->zrevrangebyscore('letters', 30, 0)); + + $this->assertSame(array(), $redis->zrevrangebyscore('unknown', 0, 30)); + } + + /** + * @group connected + */ + public function testInfinityScoreIntervals() + { + $redis = $this->getClient(); + + $redis->zadd('letters', -10, 'a', 0, 'b', 10, 'c', 20, 'd', 20, 'e', 30, 'f'); + + $this->assertSame(array('f', 'e', 'd'), $redis->zrevrangebyscore('letters', '+inf', 15)); + $this->assertSame(array('c', 'b', 'a'), $redis->zrevrangebyscore('letters', 15, '-inf')); + $this->assertSame(array('f', 'e', 'd', 'c', 'b', 'a'), $redis->zrevrangebyscore('letters', '+inf', '-inf')); + } + + /** + * @group connected + */ + public function testExclusiveScoreIntervals() + { + $redis = $this->getClient(); + + $redis->zadd('letters', -10, 'a', 0, 'b', 10, 'c', 20, 'd', 20, 'e', 30, 'f'); + + $this->assertSame(array('e', 'd', 'c'), $redis->zrevrangebyscore('letters', '(30', 10)); + $this->assertSame(array('f', 'e', 'd'), $redis->zrevrangebyscore('letters', 30, '(10')); + $this->assertSame(array('e', 'd'), $redis->zrevrangebyscore('letters', '(30', '(10')); + } + + /** + * @group connected + */ + public function testRangeWithWithscoresModifier() + { + $redis = $this->getClient(); + + $redis->zadd('letters', -10, 'a', 0, 'b', 10, 'c', 20, 'd', 20, 'e', 30, 'f'); + $expected = array(array('e', '20'), array('d', '20'), array('c', '10')); + + $this->assertSame($expected, $redis->zrevrangebyscore('letters', 20, 10, 'withscores')); + $this->assertSame($expected, $redis->zrevrangebyscore('letters', 20, 10, array('withscores' => true))); + } + + /** + * @group connected + */ + public function testRangeWithLimitModifier() + { + $redis = $this->getClient(); + + $redis->zadd('letters', -10, 'a', 0, 'b', 10, 'c', 20, 'd', 20, 'e', 30, 'f'); + $expected = array('d', 'c'); + + $this->assertSame($expected, $redis->zrevrangebyscore('letters', 20, 10, array('limit' => array(1, 2)))); + $this->assertSame($expected, $redis->zrevrangebyscore('letters', 20, 10, array('limit' => array('offset' => 1, 'count' => 2)))); + } + + /** + * @group connected + */ + public function testRangeWithCombinedModifiers() + { + $redis = $this->getClient(); + + $redis->zadd('letters', -10, 'a', 0, 'b', 10, 'c', 20, 'd', 20, 'e', 30, 'f'); + + $options = array('limit' => array(1, 2), 'withscores' => true); + $expected = array(array('d', '20'), array('c', '10')); + + $this->assertSame($expected, $redis->zrevrangebyscore('letters', 20, 10, $options)); + } + + /** + * @group connected + * @expectedException Predis\ServerException + * @expectedExceptionMessage Operation against a key holding the wrong kind of value + */ + public function testThrowsExceptionOnWrongType() + { + $redis = $this->getClient(); + + $redis->set('foo', 'bar'); + $redis->zrevrangebyscore('foo', 0, 10); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/ZSetReverseRangeTest.php b/vendor/predis/predis/tests/Predis/Command/ZSetReverseRangeTest.php new file mode 100755 index 0000000..e83462b --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/ZSetReverseRangeTest.php @@ -0,0 +1,180 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @group commands + * @group realm-zset + */ +class ZSetReverseRangeTest extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return 'Predis\Command\ZSetReverseRange'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return 'ZREVRANGE'; + } + + /** + * @group disconnected + */ + public function testFilterArguments() + { + $arguments = array('zset', 0, 100, array('withscores' => true)); + $expected = array('zset', 0, 100, 'WITHSCORES'); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testFilterArgumentsWithStringWithscores() + { + $arguments = array('zset', 0, 100, 'withscores'); + $expected = array('zset', 0, 100, 'WITHSCORES'); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse() + { + $raw = array('element1', 'element2', 'element3'); + $expected = array('element1', 'element2', 'element3'); + + $command = $this->getCommand(); + + $this->assertSame($expected, $command->parseResponse($raw)); + } + + /** + * @group disconnected + */ + public function testParseResponseWithScores() + { + $raw = array('element1', '1', 'element2', '2', 'element3', '3'); + $expected = array(array('element1', '1'), array('element2', '2'), array('element3', '3')); + + $command = $this->getCommandWithArgumentsArray(array('zset', 0, 1, 'withscores')); + + $this->assertSame($expected, $command->parseResponse($raw)); + } + + /** + * @group disconnected + */ + public function testPrefixKeys() + { + $arguments = array('zset', 0, 100, array('withscores' => true)); + $expected = array('prefix:zset', 0, 100, 'WITHSCORES'); + + $command = $this->getCommandWithArgumentsArray($arguments); + $command->prefixKeys('prefix:'); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testPrefixKeysIgnoredOnEmptyArguments() + { + $command = $this->getCommand(); + $command->prefixKeys('prefix:'); + + $this->assertSame(array(), $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testAddsWithscoresModifiersOnlyWhenOptionIsTrue() + { + $command = $this->getCommandWithArguments('zset', 0, 100, array('withscores' => true)); + $this->assertSame(array('zset', 0, 100, 'WITHSCORES'), $command->getArguments()); + + $command = $this->getCommandWithArguments('zset', 0, 100, array('withscores' => 1)); + $this->assertSame(array('zset', 0, 100, 'WITHSCORES'), $command->getArguments()); + + $command = $this->getCommandWithArguments('zset', 0, 100, array('withscores' => false)); + $this->assertSame(array('zset', 0, 100), $command->getArguments()); + + $command = $this->getCommandWithArguments('zset', 0, 100, array('withscores' => 0)); + $this->assertSame(array('zset', 0, 100), $command->getArguments()); + } + + /** + * @group connected + */ + public function testReturnsElementsInRange() + { + $redis = $this->getClient(); + + $redis->zadd('letters', -10, 'a', 0, 'b', 10, 'c', 20, 'd', 20, 'e', 30, 'f'); + + $this->assertSame(array(), $redis->zrevrange('letters', 1, 0)); + $this->assertSame(array('f'), $redis->zrevrange('letters', 0, 0)); + $this->assertSame(array('f', 'e', 'd', 'c'), $redis->zrevrange('letters', 0, 3)); + + $this->assertSame(array('f', 'e', 'd', 'c', 'b', 'a'), $redis->zrevrange('letters', 0, -1)); + $this->assertSame(array('f', 'e', 'd'), $redis->zrevrange('letters', 0, -4)); + $this->assertSame(array('d'), $redis->zrevrange('letters', 2, -4)); + $this->assertSame(array('f', 'e', 'd', 'c', 'b', 'a'), $redis->zrevrange('letters', -100, 100)); + + $this->assertSame(array(), $redis->zrevrange('unknown', 0, 30)); + } + + /** + * @group connected + */ + public function testRangeWithWithscoresModifier() + { + $redis = $this->getClient(); + + $redis->zadd('letters', -10, 'a', 0, 'b', 10, 'c', 20, 'd', 20, 'e', 30, 'f'); + $expected = array(array('d', '20'), array('c', '10'), array('b', '0')); + + $this->assertSame($expected, $redis->zrevrange('letters', 2, 4, 'withscores')); + $this->assertSame($expected, $redis->zrevrange('letters', 2, 4, array('withscores' => true))); + } + + /** + * @group connected + * @expectedException Predis\ServerException + * @expectedExceptionMessage Operation against a key holding the wrong kind of value + */ + public function testThrowsExceptionOnWrongType() + { + $redis = $this->getClient(); + + $redis->set('foo', 'bar'); + $redis->zrevrange('foo', 0, 10); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/ZSetReverseRankTest.php b/vendor/predis/predis/tests/Predis/Command/ZSetReverseRankTest.php new file mode 100755 index 0000000..d61cee5 --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/ZSetReverseRankTest.php @@ -0,0 +1,111 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @group commands + * @group realm-zset + */ +class ZSetReverseRankTest extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return 'Predis\Command\ZSetReverseRank'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return 'ZREVRANK'; + } + + /** + * @group disconnected + */ + public function testFilterArguments() + { + $arguments = array('key', 'member'); + $expected = array('key', 'member'); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse() + { + $this->assertSame(1, $this->getCommand()->parseResponse(1)); + } + + /** + * @group disconnected + */ + public function testPrefixKeys() + { + $arguments = array('key', 'member'); + $expected = array('prefix:key', 'member'); + + $command = $this->getCommandWithArgumentsArray($arguments); + $command->prefixKeys('prefix:'); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testPrefixKeysIgnoredOnEmptyArguments() + { + $command = $this->getCommand(); + $command->prefixKeys('prefix:'); + + $this->assertSame(array(), $command->getArguments()); + } + + /** + * @group connected + */ + public function testReturnsRank() + { + $redis = $this->getClient(); + + $redis->zadd('letters', -10, 'a', 0, 'b', 10, 'c', 20, 'd', 20, 'e', 30, 'f'); + + $this->assertSame(5, $redis->zrevrank('letters', 'a')); + $this->assertSame(4, $redis->zrevrank('letters', 'b')); + $this->assertSame(1, $redis->zrevrank('letters', 'e')); + + $this->assertNull($redis->zrevrank('unknown', 'a')); + } + + /** + * @group connected + * @expectedException Predis\ServerException + * @expectedExceptionMessage Operation against a key holding the wrong kind of value + */ + public function testThrowsExceptionOnWrongType() + { + $redis = $this->getClient(); + + $redis->set('foo', 'bar'); + $redis->zrevrank('foo', 'bar'); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/ZSetScanTest.php b/vendor/predis/predis/tests/Predis/Command/ZSetScanTest.php new file mode 100755 index 0000000..20e31dd --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/ZSetScanTest.php @@ -0,0 +1,161 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @group commands + * @group realm-zset + */ +class ZSetScanTest extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return 'Predis\Command\ZSetScan'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return 'ZSCAN'; + } + + /** + * @group disconnected + */ + public function testFilterArguments() + { + $arguments = array('key', 0, 'MATCH', 'member:*', 'COUNT', 10); + $expected = array('key', 0, 'MATCH', 'member:*', 'COUNT', 10); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testFilterArgumentsBasicUsage() + { + $arguments = array('key', 0); + $expected = array('key', 0); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testFilterArgumentsWithOptionsArray() + { + $arguments = array('key', 0, array('match' => 'member:*', 'count' => 10)); + $expected = array('key', 0, 'MATCH', 'member:*', 'COUNT', 10); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse() + { + $raw = array('3', array('member:1', '1', 'member:2', '2', 'member:3', '3')); + $expected = array(3, array(array('member:1' , 1.0), array('member:2', 2.0), array('member:3' , 3.0))); + + $command = $this->getCommand(); + + $this->assertSame($expected, $command->parseResponse($raw)); + } + + /** + * @group disconnected + */ + public function testPrefixKeys() + { + $arguments = array('key', '0', 'MATCH', 'member:*', 'COUNT', 10); + $expected = array('prefix:key', '0', 'MATCH', 'member:*', 'COUNT', 10); + + $command = $this->getCommandWithArgumentsArray($arguments); + $command->prefixKeys('prefix:'); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testPrefixKeysIgnoredOnEmptyArguments() + { + $command = $this->getCommand(); + $command->prefixKeys('prefix:'); + + $this->assertSame(array(), $command->getArguments()); + } + + /** + * @group connected + */ + public function testScanWithoutMatch() + { + $expectedMembers = array('member:one', 'member:two', 'member:three', 'member:four'); + $expectedScores = array(1.0, 2.0, 3.0, 4.0); + + $redis = $this->getClient(); + $redis->zadd('key', array_combine($expectedMembers, $expectedScores)); + + $response = $redis->zscan('key', 0); + + $this->assertSame(0, $response[0]); + $this->assertSame($expectedMembers, array_map(function ($e) { return $e[0]; }, $response[1])); + $this->assertSame($expectedScores, array_map(function ($e) { return $e[1]; }, $response[1])); + } + + /** + * @group connected + */ + public function testScanWithMatchingMembers() + { + $redis = $this->getClient(); + $redis->zadd('key', array('member:one' => 1.0, 'member:two' => 2.0, 'member:three' => 3.0, 'member:four' => 4.0)); + + $response = $redis->zscan('key', 0, 'MATCH', 'member:t*'); + + $this->assertSame(array('member:two', 'member:three'), array_map(function ($e) { return $e[0]; }, $response[1])); + $this->assertSame(array(2.0, 3.0), array_map(function ($e) { return $e[1]; }, $response[1])); + } + + /** + * @group connected + */ + public function testScanWithNoMatchingMembers() + { + $redis = $this->getClient(); + $redis->zadd('key', $members = array('member:one' => 1.0, 'member:two' => 2.0, 'member:three' => 3.0, 'member:four' => 4.0)); + + $response = $redis->zscan('key', 0, 'MATCH', 'nomember:*'); + + $this->assertSame(0, $response[0]); + $this->assertEmpty($response[1]); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/ZSetScoreTest.php b/vendor/predis/predis/tests/Predis/Command/ZSetScoreTest.php new file mode 100755 index 0000000..b65f9f3 --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/ZSetScoreTest.php @@ -0,0 +1,111 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @group commands + * @group realm-zset + */ +class ZSetScoreTest extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return 'Predis\Command\ZSetScore'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return 'ZSCORE'; + } + + /** + * @group disconnected + */ + public function testFilterArguments() + { + $arguments = array('key', 'member'); + $expected = array('key', 'member'); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse() + { + $this->assertSame(1, $this->getCommand()->parseResponse(1)); + } + + /** + * @group disconnected + */ + public function testPrefixKeys() + { + $arguments = array('key', 'member'); + $expected = array('prefix:key', 'member'); + + $command = $this->getCommandWithArgumentsArray($arguments); + $command->prefixKeys('prefix:'); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testPrefixKeysIgnoredOnEmptyArguments() + { + $command = $this->getCommand(); + $command->prefixKeys('prefix:'); + + $this->assertSame(array(), $command->getArguments()); + } + + /** + * @group connected + */ + public function testReturnsRank() + { + $redis = $this->getClient(); + + $redis->zadd('letters', -10, 'a', 0, 'b', 10, 'c', 20, 'd', 20, 'e', 30, 'f'); + + $this->assertSame('-10', $redis->zscore('letters', 'a')); + $this->assertSame('0', $redis->zscore('letters', 'b')); + $this->assertSame('20', $redis->zscore('letters', 'e')); + + $this->assertNull($redis->zscore('unknown', 'a')); + } + + /** + * @group connected + * @expectedException Predis\ServerException + * @expectedExceptionMessage Operation against a key holding the wrong kind of value + */ + public function testThrowsExceptionOnWrongType() + { + $redis = $this->getClient(); + + $redis->set('foo', 'bar'); + $redis->zscore('foo', 'bar'); + } +} diff --git a/vendor/predis/predis/tests/Predis/Command/ZSetUnionStoreTest.php b/vendor/predis/predis/tests/Predis/Command/ZSetUnionStoreTest.php new file mode 100755 index 0000000..eb42786 --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Command/ZSetUnionStoreTest.php @@ -0,0 +1,219 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Command; + +/** + * @group commands + * @group realm-zset + */ +class ZSetUnionStoreTest extends PredisCommandTestCase +{ + /** + * {@inheritdoc} + */ + protected function getExpectedCommand() + { + return 'Predis\Command\ZSetUnionStore'; + } + + /** + * {@inheritdoc} + */ + protected function getExpectedId() + { + return 'ZUNIONSTORE'; + } + + /** + * @group disconnected + */ + public function testFilterArguments() + { + $modifiers = array( + 'aggregate' => 'sum', + 'weights' => array(10, 100), + ); + $arguments = array('zset:destination', 2, 'zset1', 'zset2', $modifiers); + + $expected = array( + 'zset:destination', 2, 'zset1', 'zset2', 'WEIGHTS', 10, 100, 'AGGREGATE', 'sum' + ); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testFilterArgumentsSourceKeysAsSingleArray() + { + $modifiers = array( + 'aggregate' => 'sum', + 'weights' => array(10, 100), + ); + $arguments = array('zset:destination', array('zset1', 'zset2'), $modifiers); + + $expected = array( + 'zset:destination', 2, 'zset1', 'zset2', 'WEIGHTS', 10, 100, 'AGGREGATE', 'sum' + ); + + $command = $this->getCommand(); + $command->setArguments($arguments); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testParseResponse() + { + $this->assertSame(1, $this->getCommand()->parseResponse(1)); + } + + /** + * @group disconnected + */ + public function testPrefixKeys() + { + $modifiers = array( + 'aggregate' => 'sum', + 'weights' => array(10, 100), + ); + $arguments = array('zset:destination', 2, 'zset1', 'zset2', $modifiers); + + $expected = array( + 'prefix:zset:destination', 2, 'prefix:zset1', 'prefix:zset2', 'WEIGHTS', 10, 100, 'AGGREGATE', 'sum' + ); + + $command = $this->getCommandWithArgumentsArray($arguments); + $command->prefixKeys('prefix:'); + + $this->assertSame($expected, $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testPrefixKeysIgnoredOnEmptyArguments() + { + $command = $this->getCommand(); + $command->prefixKeys('prefix:'); + + $this->assertSame(array(), $command->getArguments()); + } + + /** + * @group connected + */ + public function testStoresUnionInNewSortedSet() + { + $redis = $this->getClient(); + + $redis->zadd('letters:1st', 1, 'a', 2, 'b', 3, 'c'); + $redis->zadd('letters:2nd', 1, 'b', 2, 'c', 3, 'd'); + + $this->assertSame(4, $redis->zunionstore('letters:out', 2, 'letters:1st', 'letters:2nd')); + $this->assertSame( + array(array('a', '1'), array('b', '3'), array('d', '3'), array('c', '5')), + $redis->zrange('letters:out', 0, -1, 'withscores') + ); + + $this->assertSame(3, $redis->zunionstore('letters:out', 2, 'letters:1st', 'letters:void')); + $this->assertSame(3, $redis->zunionstore('letters:out', 2, 'letters:void', 'letters:2nd')); + $this->assertSame(0, $redis->zunionstore('letters:out', 2, 'letters:void', 'letters:void')); + } + + /** + * @group connected + */ + public function testStoresUnionWithAggregateModifier() + { + $redis = $this->getClient(); + + $redis->zadd('letters:1st', 1, 'a', 2, 'b', 3, 'c'); + $redis->zadd('letters:2nd', 1, 'b', 2, 'c', 3, 'd'); + + $options = array('aggregate' => 'min'); + $this->assertSame(4, $redis->zunionstore('letters:min', 2, 'letters:1st', 'letters:2nd', $options)); + $this->assertSame( + array(array('a', '1'), array('b', '1'), array('c', '2'), array('d', '3')), + $redis->zrange('letters:min', 0, -1, 'withscores') + ); + + $options = array('aggregate' => 'max'); + $this->assertSame(4, $redis->zunionstore('letters:max', 2, 'letters:1st', 'letters:2nd', $options)); + $this->assertSame( + array(array('a', '1'), array('b', '2'), array('c', '3'), array('d', '3')), + $redis->zrange('letters:max', 0, -1, 'withscores') + ); + + $options = array('aggregate' => 'sum'); + $this->assertSame(4, $redis->zunionstore('letters:sum', 2, 'letters:1st', 'letters:2nd', $options)); + $this->assertSame( + array(array('a', '1'), array('b', '3'), array('d', '3'), array('c', '5')), + $redis->zrange('letters:sum', 0, -1, 'withscores') + ); + } + + /** + * @group connected + */ + public function testStoresUnionWithWeightsModifier() + { + $redis = $this->getClient(); + + $redis->zadd('letters:1st', 1, 'a', 2, 'b', 3, 'c'); + $redis->zadd('letters:2nd', 1, 'b', 2, 'c', 3, 'd'); + + $options = array('weights' => array(2, 3)); + $this->assertSame(4, $redis->zunionstore('letters:out', 2, 'letters:1st', 'letters:2nd', $options)); + $this->assertSame( + array(array('a', '2'), array('b', '7'), array('d', '9'), array('c', '12')), + $redis->zrange('letters:out', 0, -1, 'withscores') + ); + } + + /** + * @group connected + */ + public function testStoresUnionWithCombinedModifiers() + { + $redis = $this->getClient(); + + $redis->zadd('letters:1st', 1, 'a', 2, 'b', 3, 'c'); + $redis->zadd('letters:2nd', 1, 'b', 2, 'c', 3, 'd'); + + $options = array('aggregate' => 'max', 'weights' => array(10, 15)); + $this->assertSame(4, $redis->zunionstore('letters:out', 2, 'letters:1st', 'letters:2nd', $options)); + $this->assertSame( + array(array('a', '10'), array('b', '20'), array('c', '30'), array('d', '45')), + $redis->zrange('letters:out', 0, -1, 'withscores') + ); + } + + /** + * @group connected + * @expectedException Predis\ServerException + * @expectedExceptionMessage Operation against a key holding the wrong kind of value + */ + public function testThrowsExceptionOnWrongType() + { + $redis = $this->getClient(); + + $redis->set('foo', 'bar'); + $redis->zunionstore('zset:destination', 1, 'foo'); + } +} diff --git a/vendor/predis/predis/tests/Predis/CommunicationExceptionTest.php b/vendor/predis/predis/tests/Predis/CommunicationExceptionTest.php new file mode 100755 index 0000000..4199334 --- /dev/null +++ b/vendor/predis/predis/tests/Predis/CommunicationExceptionTest.php @@ -0,0 +1,113 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis; + +use PredisTestCase; +use Predis\Connection\SingleConnectionInterface; + +/** + * + */ +class CommunicationExceptionTest extends PredisTestCase +{ + /** + * @group disconnected + */ + public function testExceptionMessage() + { + $message = 'Connection error message.'; + $connection = $this->getMockedConnectionBase(); + $exception = $this->getException($connection, $message); + + $this->setExpectedException('Predis\CommunicationException', $message); + + throw $exception; + } + + /** + * @group disconnected + */ + public function testExceptionConnection() + { + $connection = $this->getMockedConnectionBase(); + $exception = $this->getException($connection, 'ERROR MESSAGE'); + + $this->assertSame($connection, $exception->getConnection()); + } + + /** + * @group disconnected + */ + public function testShouldResetConnection() + { + $connection = $this->getMockedConnectionBase(); + $exception = $this->getException($connection, 'ERROR MESSAGE'); + + $this->assertTrue($exception->shouldResetConnection()); + } + + /** + * @group disconnected + * @expectedException Predis\CommunicationException + * @expectedExceptionMessage Communication error + */ + public function testCommunicationExceptionHandling() + { + $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); + $connection->expects($this->once())->method('isConnected')->will($this->returnValue(true)); + $connection->expects($this->once())->method('disconnect'); + + $exception = $this->getException($connection, 'Communication error'); + + CommunicationException::handle($exception); + } + + // ******************************************************************** // + // ---- HELPER METHODS ------------------------------------------------ // + // ******************************************************************** // + + /** + * Returns a mocked connection instance. + * + * @param mixed $parameters Connection parameters. + * @return SingleConnectionInterface + */ + protected function getMockedConnectionBase($parameters = null) + { + $builder = $this->getMockBuilder('Predis\Connection\AbstractConnection'); + + if ($parameters === null) { + $builder->disableOriginalConstructor(); + } elseif (!$parameters instanceof ConnectionParametersInterface) { + $parameters = new ConnectionParameters($parameters); + } + + return $builder->getMockForAbstractClass(array($parameters)); + } + + /** + * Returns a connection exception instance. + * + * @param Connection\SingleConnectionInterface $connection Connection instance. + * @param string $message Exception message. + * @param int $code Exception code. + * @param \Exception $inner Inner exception. + * @return \Exception + */ + protected function getException(SingleConnectionInterface $connection, $message, $code = 0, \Exception $inner = null) + { + $arguments = array($connection, $message, $code, $inner); + $mock = $this->getMockForAbstractClass('Predis\CommunicationException', $arguments); + + return $mock; + } +} diff --git a/vendor/predis/predis/tests/Predis/Connection/ComposableStreamConnectionTest.php b/vendor/predis/predis/tests/Predis/Connection/ComposableStreamConnectionTest.php new file mode 100755 index 0000000..5942801 --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Connection/ComposableStreamConnectionTest.php @@ -0,0 +1,120 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Connection; + +/** + * + */ +class ComposableStreamConnectionTest extends PredisConnectionTestCase +{ + /** + * @group disconnected + */ + public function testConstructorDoesNotOpenConnection() + { + $connection = new ComposableStreamConnection($this->getParameters()); + + $this->assertFalse($connection->isConnected()); + } + + /** + * @group disconnected + */ + public function testExposesParameters() + { + $parameters = $this->getParameters(); + $connection = new ComposableStreamConnection($parameters); + + $this->assertSame($parameters, $connection->getParameters()); + } + + /** + * @group disconnected + * @expectedException InvalidArgumentException + * @expectedExceptionMessage Invalid scheme: udp + */ + public function testThrowsExceptionOnInvalidScheme() + { + $parameters = $this->getParameters(array('scheme' => 'udp')); + $connection = new ComposableStreamConnection($parameters); + } + + /** + * @group disconnected + */ + public function testCanBeSerialized() + { + $parameters = $this->getParameters(array('alias' => 'redis', 'read_write_timeout' => 10)); + $connection = new ComposableStreamConnection($parameters); + + $unserialized = unserialize(serialize($connection)); + + $this->assertEquals($connection, $unserialized); + } + + // ******************************************************************** // + // ---- INTEGRATION TESTS --------------------------------------------- // + // ******************************************************************** // + + /** + * @group connected + */ + public function testReadsMultibulkRepliesAsIterators() + { + $connection = $this->getConnection($profile, true); + $connection->getProtocol()->setOption('iterable_multibulk', true); + + $connection->executeCommand($profile->createCommand('rpush', array('metavars', 'foo', 'hoge', 'lol'))); + $connection->writeCommand($profile->createCommand('lrange', array('metavars', 0, -1))); + + $this->assertInstanceOf('Predis\Iterator\MultiBulkResponse', $iterator = $connection->read()); + $this->assertSame(array('foo', 'hoge', 'lol'), iterator_to_array($iterator)); + } + + /** + * @group connected + * @expectedException Predis\Protocol\ProtocolException + * @expectedExceptionMessage Unknown prefix: 'P' + */ + public function testThrowsExceptionOnProtocolDesynchronizationErrors() + { + $connection = $this->getConnection($profile); + $stream = $connection->getResource(); + + $connection->writeCommand($profile->createCommand('ping')); + fread($stream, 1); + + $connection->read(); + } + + // ******************************************************************** // + // ---- HELPER METHODS ------------------------------------------------ // + // ******************************************************************** // + + /** + * {@inheritdoc} + */ + protected function getConnection(&$profile = null, $initialize = false, Array $parameters = array()) + { + $parameters = $this->getParameters($parameters); + $profile = $this->getProfile(); + + $connection = new ComposableStreamConnection($parameters); + + if ($initialize) { + $connection->pushInitCommand($profile->createCommand('select', array($parameters->database))); + $connection->pushInitCommand($profile->createCommand('flushdb')); + } + + return $connection; + } +} diff --git a/vendor/predis/predis/tests/Predis/Connection/ConnectionExceptionTest.php b/vendor/predis/predis/tests/Predis/Connection/ConnectionExceptionTest.php new file mode 100755 index 0000000..71cb4b6 --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Connection/ConnectionExceptionTest.php @@ -0,0 +1,31 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Connection; + +require_once __DIR__.'/../CommunicationExceptionTest.php'; + +use Predis\CommunicationExceptionTest; +use Predis\Connection\SingleConnectionInterface; + +/** + * + */ +class ConnectionExceptionTest extends CommunicationExceptionTest +{ + /** + * {@inheritdoc} + */ + protected function getException(SingleConnectionInterface $connection, $message, $code = 0, \Exception $inner = null) + { + return new ConnectionException($connection, $message, $code, $inner); + } +} diff --git a/vendor/predis/predis/tests/Predis/Connection/ConnectionFactoryTest.php b/vendor/predis/predis/tests/Predis/Connection/ConnectionFactoryTest.php new file mode 100755 index 0000000..809106f --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Connection/ConnectionFactoryTest.php @@ -0,0 +1,383 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Connection; + +use PredisTestCase; +/** + * + */ +class ConnectionFactoryTest extends PredisTestCase +{ + /** + * @group disconnected + */ + public function testImplementsCorrectInterface() + { + $factory = new ConnectionFactory(); + + $this->assertInstanceOf('Predis\Connection\ConnectionFactoryInterface', $factory); + } + + /** + * @group disconnected + */ + public function testCreateConnection() + { + $factory = new ConnectionFactory(); + + $tcp = new ConnectionParameters(array( + 'scheme' => 'tcp', + 'host' => 'locahost', + )); + + $connection = $factory->create($tcp); + $parameters = $connection->getParameters(); + $this->assertInstanceOf('Predis\Connection\StreamConnection', $connection); + $this->assertEquals($tcp->scheme, $parameters->scheme); + $this->assertEquals($tcp->host, $parameters->host); + $this->assertEquals($tcp->database, $parameters->database); + + $unix = new ConnectionParameters(array( + 'scheme' => 'unix', + 'path' => '/tmp/redis.sock', + )); + + $connection = $factory->create($tcp); + $parameters = $connection->getParameters(); + $this->assertInstanceOf('Predis\Connection\StreamConnection', $connection); + $this->assertEquals($tcp->scheme, $parameters->scheme); + $this->assertEquals($tcp->database, $parameters->database); + } + + /** + * @group disconnected + */ + public function testCreateConnectionWithNullParameters() + { + $factory = new ConnectionFactory(); + $connection = $factory->create(null); + $parameters = $connection->getParameters(); + + $this->assertInstanceOf('Predis\Connection\SingleConnectionInterface', $connection); + $this->assertEquals('tcp', $parameters->scheme); + + $this->assertFalse(isset($parameters->custom)); + $this->assertNull($parameters->custom); + } + + /** + * @group disconnected + */ + public function testCreateConnectionWithArrayParameters() + { + $factory = new ConnectionFactory(); + $connection = $factory->create(array('scheme' => 'tcp', 'custom' => 'foobar')); + $parameters = $connection->getParameters(); + + $this->assertInstanceOf('Predis\Connection\SingleConnectionInterface', $connection); + $this->assertEquals('tcp', $parameters->scheme); + + $this->assertTrue(isset($parameters->custom)); + $this->assertSame('foobar', $parameters->custom); + } + + /** + * @group disconnected + */ + public function testCreateConnectionWithStringURI() + { + $factory = new ConnectionFactory(); + $connection = $factory->create('tcp://127.0.0.1?custom=foobar'); + $parameters = $connection->getParameters(); + + $this->assertInstanceOf('Predis\Connection\SingleConnectionInterface', $connection); + $this->assertEquals('tcp', $parameters->scheme); + + $this->assertTrue(isset($parameters->custom)); + $this->assertSame('foobar', $parameters->custom); + } + + /** + * @group disconnected + */ + public function testCreateConnectionWithoutInitializationCommands() + { + $profile = $this->getMock('Predis\Profile\ServerProfileInterface'); + $profile->expects($this->never())->method('create'); + + $factory = new ConnectionFactory($profile); + $parameters = new ConnectionParameters(); + $connection = $factory->create($parameters); + + $this->assertInstanceOf('Predis\Connection\SingleConnectionInterface', $connection); + } + + /** + * @group disconnected + */ + public function testCreateConnectionWithInitializationCommands() + { + $test = $this; + $database = 15; + $password = 'foobar'; + $commands = array(); + + $createCommand = function ($id, $arguments) use ($test, &$commands) { + $commands[$id] = $arguments; + $command = $test->getMock('Predis\Command\CommandInterface'); + + return $command; + }; + + $profile = $this->getMock('Predis\Profile\ServerProfileInterface'); + $profile->expects($this->exactly(2)) + ->method('createCommand') + ->with($this->isType('string'), $this->isType('array')) + ->will($this->returnCallback($createCommand)); + + $factory = new ConnectionFactory($profile); + $parameters = new ConnectionParameters(array('database' => $database, 'password' => $password)); + $connection = $factory->create($parameters); + + $this->assertInstanceOf('Predis\Connection\SingleConnectionInterface', $connection); + $this->assertEquals(2, count($commands)); // TODO: assertCount()? + $this->assertEquals(array($database), $commands['select']); + $this->assertEquals(array($password), $commands['auth']); + } + + /** + * @group disconnected + * @todo This test smells but there's no other way around it right now. + */ + public function testCreateConnectionWithDatabaseAndPasswordButNoProfile() + { + $parameters = new ConnectionParameters(array('database' => 0, 'password' => 'foobar')); + + $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); + $connection->expects($this->never()) + ->method('getParameters') + ->will($this->returnValue($parameters)); + $connection->expects($this->never()) + ->method('pushInitCommand'); + + $factory = new ConnectionFactory(); + + $reflection = new \ReflectionObject($factory); + $prepareConnection = $reflection->getMethod('prepareConnection'); + $prepareConnection->setAccessible(true); + $prepareConnection->invoke($factory, $connection); + } + + /** + * @group disconnected + */ + public function testCreateUndefinedConnection() + { + $scheme = 'unknown'; + $this->setExpectedException('InvalidArgumentException', "Unknown connection scheme: $scheme"); + + $factory = new ConnectionFactory(); + $factory->create(new ConnectionParameters(array('scheme' => $scheme))); + } + + /** + * @group disconnected + */ + public function testDefineConnectionWithFQN() + { + list(, $connectionClass) = $this->getMockConnectionClass(); + + $parameters = new ConnectionParameters(array('scheme' => 'foobar')); + $factory = new ConnectionFactory(); + + $factory->define($parameters->scheme, $connectionClass); + $connection = $factory->create($parameters); + + $this->assertInstanceOf($connectionClass, $connection); + } + + /** + * @group disconnected + */ + public function testDefineConnectionWithCallable() + { + list(, $connectionClass) = $this->getMockConnectionClass(); + + $parameters = new ConnectionParameters(array('scheme' => 'foobar')); + + $initializer = function ($parameters) use ($connectionClass) { + return new $connectionClass($parameters); + }; + + $initializerMock = $this->getMock('stdClass', array('__invoke')); + $initializerMock->expects($this->exactly(2)) + ->method('__invoke') + ->with($parameters) + ->will($this->returnCallback($initializer)); + + $factory = new ConnectionFactory(); + $factory->define($parameters->scheme, $initializerMock); + $connection1 = $factory->create($parameters); + $connection2 = $factory->create($parameters); + + $this->assertInstanceOf($connectionClass, $connection1); + $this->assertInstanceOf($connectionClass, $connection2); + $this->assertNotSame($connection1, $connection2); + } + + /** + * @group disconnected + */ + public function testDefineConnectionWithInvalidArgument() + { + $this->setExpectedException('InvalidArgumentException'); + + $factory = new ConnectionFactory(); + $factory->define('foobar', new \stdClass()); + } + + /** + * @group disconnected + */ + public function testUndefineDefinedConnection() + { + $this->setExpectedException('InvalidArgumentException', 'Unknown connection scheme: tcp'); + + $factory = new ConnectionFactory(); + $factory->undefine('tcp'); + $factory->create('tcp://127.0.0.1'); + } + + /** + * @group disconnected + */ + public function testUndefineUndefinedConnection() + { + $factory = new ConnectionFactory(); + $factory->undefine('unknown'); + $connection = $factory->create('tcp://127.0.0.1'); + + $this->assertInstanceOf('Predis\Connection\SingleConnectionInterface', $connection); + } + + /** + * @group disconnected + */ + public function testDefineAndUndefineConnection() + { + list(, $connectionClass) = $this->getMockConnectionClass(); + + $factory = new ConnectionFactory(); + + $factory->define('redis', $connectionClass); + $this->assertInstanceOf($connectionClass, $factory->create('redis://127.0.0.1')); + + $factory->undefine('redis'); + $this->setExpectedException('InvalidArgumentException', 'Unknown connection scheme: redis'); + $factory->create('redis://127.0.0.1'); + } + + /** + * @group disconnected + */ + public function testAggregatedConnectionSkipCreationOnConnectionInstance() + { + list(, $connectionClass) = $this->getMockConnectionClass(); + + $cluster = $this->getMock('Predis\Connection\ClusterConnectionInterface'); + $cluster->expects($this->exactly(2)) + ->method('add') + ->with($this->isInstanceOf('Predis\Connection\SingleConnectionInterface')); + + $factory = $this->getMock('Predis\Connection\ConnectionFactory', array('create')); + $factory->expects($this->never()) + ->method('create'); + + $factory->createAggregated($cluster, array(new $connectionClass(), new $connectionClass())); + } + + /** + * @group disconnected + */ + public function testAggregatedConnectionWithMixedParameters() + { + list(, $connectionClass) = $this->getMockConnectionClass(); + + $cluster = $this->getMock('Predis\Connection\ClusterConnectionInterface'); + $cluster->expects($this->exactly(4)) + ->method('add') + ->with($this->isInstanceOf('Predis\Connection\SingleConnectionInterface')); + + $factory = $this->getMock('Predis\Connection\ConnectionFactory', array('create')); + $factory->expects($this->exactly(3)) + ->method('create') + ->will($this->returnCallback(function ($_) use ($connectionClass) { + return new $connectionClass; + })); + + $factory->createAggregated($cluster, array(null, 'tcp://127.0.0.1', array('scheme' => 'tcp'), new $connectionClass())); + } + + /** + * @group disconnected + */ + public function testAggregatedConnectionWithEmptyListOfParameters() + { + $cluster = $this->getMock('Predis\Connection\ClusterConnectionInterface'); + $cluster->expects($this->never())->method('add'); + + $factory = $this->getMock('Predis\Connection\ConnectionFactory', array('create')); + $factory->expects($this->never())->method('create'); + + $factory->createAggregated($cluster, array()); + } + + /** + * @group disconnected + * @todo We might want to add a test for SingleConnectionInterface::pushInitCommand(). + */ + public function testAggregatedConnectionWithServerProfileArgument() + { + list(, $connectionClass) = $this->getMockConnectionClass(); + + $cluster = $this->getMock('Predis\Connection\ClusterConnectionInterface'); + $profile = $this->getMock('Predis\Profile\ServerProfileInterface'); + + $factory = $this->getMock('Predis\Connection\ConnectionFactory', array('create'), array($profile)); + $factory->expects($this->exactly(2)) + ->method('create') + ->with($this->anything()) + ->will($this->returnCallback(function ($_) use ($connectionClass) { + return new $connectionClass(); + })); + + $nodes = array('tcp://127.0.0.1:7001?password=foo', 'tcp://127.0.0.1:7002?password=bar'); + $factory->createAggregated($cluster, $nodes); + } + + + // ******************************************************************** // + // ---- HELPER METHODS ------------------------------------------------ // + // ******************************************************************** // + + /** + * Returns a mocked Predis\Connection\SingleConnectionInterface. + * + * @return Array Mock instance and class name + */ + protected function getMockConnectionClass() + { + $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); + + return array($connection, get_class($connection)); + } +} diff --git a/vendor/predis/predis/tests/Predis/Connection/ConnectionParametersTest.php b/vendor/predis/predis/tests/Predis/Connection/ConnectionParametersTest.php new file mode 100755 index 0000000..d31b32a --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Connection/ConnectionParametersTest.php @@ -0,0 +1,265 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Connection; + +use PredisTestCase; +/** + * @todo ConnectionParameters::define(); + * @todo ConnectionParameters::undefine(); + */ +class ParametersTest extends PredisTestCase +{ + /** + * @group disconnected + */ + public function testDefaultValues() + { + $defaults = $this->getDefaultParametersArray(); + $parameters = new ConnectionParameters(); + + $this->assertEquals($defaults['scheme'], $parameters->scheme); + $this->assertEquals($defaults['host'], $parameters->host); + $this->assertEquals($defaults['port'], $parameters->port); + $this->assertEquals($defaults['timeout'], $parameters->timeout); + } + + /** + * @group disconnected + */ + public function testIsSet() + { + $parameters = new ConnectionParameters(); + + $this->assertTrue(isset($parameters->scheme)); + $this->assertFalse(isset($parameters->unknown)); + } + + /** + * @group disconnected + */ + public function testUserDefinedParameters() + { + $parameters = new ConnectionParameters(array('port' => 7000, 'custom' => 'foobar')); + + $this->assertTrue(isset($parameters->scheme)); + $this->assertSame('tcp', $parameters->scheme); + + $this->assertTrue(isset($parameters->port)); + $this->assertSame(7000, $parameters->port); + + $this->assertTrue(isset($parameters->custom)); + $this->assertSame('foobar', $parameters->custom); + + $this->assertFalse(isset($parameters->unknown)); + $this->assertNull($parameters->unknown); + } + + /** + * @group disconnected + */ + public function testConstructWithUriString() + { + $defaults = $this->getDefaultParametersArray(); + + $overrides = array( + 'port' => 7000, + 'database' => 5, + 'iterable_multibulk' => false, + 'custom' => 'foobar', + ); + + $parameters = new ConnectionParameters($this->getParametersString($overrides)); + + $this->assertEquals($defaults['scheme'], $parameters->scheme); + $this->assertEquals($defaults['host'], $parameters->host); + $this->assertEquals($overrides['port'], $parameters->port); + + $this->assertEquals($overrides['database'], $parameters->database); + $this->assertEquals($overrides['iterable_multibulk'], $parameters->iterable_multibulk); + + $this->assertTrue(isset($parameters->custom)); + $this->assertEquals($overrides['custom'], $parameters->custom); + + $this->assertFalse(isset($parameters->unknown)); + $this->assertNull($parameters->unknown); + } + + /** + * @group disconnected + */ + public function testToArray() + { + $additional = array('port' => 7000, 'custom' => 'foobar'); + $parameters = new ConnectionParameters($additional); + + $this->assertEquals($this->getParametersArray($additional), $parameters->toArray()); + } + + /** + * @group disconnected + */ + public function testSerialization() + { + $parameters = new ConnectionParameters(array('port' => 7000, 'custom' => 'foobar')); + $unserialized = unserialize(serialize($parameters)); + + $this->assertEquals($parameters->scheme, $unserialized->scheme); + $this->assertEquals($parameters->port, $unserialized->port); + + $this->assertTrue(isset($unserialized->custom)); + $this->assertEquals($parameters->custom, $unserialized->custom); + + $this->assertFalse(isset($unserialized->unknown)); + $this->assertNull($unserialized->unknown); + } + + /** + * @group disconnected + */ + public function testParsingURI() + { + $uri = 'tcp://10.10.10.10:6400?timeout=0.5&persistent=1'; + + $expected = array( + 'scheme' => 'tcp', + 'host' => '10.10.10.10', + 'port' => 6400, + 'timeout' => '0.5', + 'persistent' => '1', + ); + + $this->assertSame($expected, ConnectionParameters::parseURI($uri)); + } + + /** + * @group disconnected + */ + public function testParsingUnixDomainURI() + { + $uri = 'unix:///tmp/redis.sock?timeout=0.5&persistent=1'; + + $expected = array( + 'scheme' => 'unix', + 'host' => 'localhost', + 'path' => '/tmp/redis.sock', + 'timeout' => '0.5', + 'persistent' => '1', + ); + + $this->assertSame($expected, ConnectionParameters::parseURI($uri)); + } + + /** + * @group disconnected + */ + public function testParsingURIWithIncompletePairInQueryString() + { + $uri = 'tcp://10.10.10.10?persistent=1&foo=&bar'; + + $expected = array( + 'scheme' => 'tcp', + 'host' => '10.10.10.10', + 'persistent' => '1', + 'foo' => '', + 'bar' => '', + ); + + $this->assertSame($expected, ConnectionParameters::parseURI($uri)); + } + + /** + * @group disconnected + */ + public function testParsingURIWithMoreThanOneEqualSignInQueryStringPairValue() + { + $uri = 'tcp://10.10.10.10?foobar=a=b=c&persistent=1'; + + $expected = array( + 'scheme' => 'tcp', + 'host' => '10.10.10.10', + 'foobar' => 'a=b=c', + 'persistent' => '1', + ); + + $this->assertSame($expected, ConnectionParameters::parseURI($uri)); + } + + /** + * @group disconnected + */ + public function testParsingURIWhenQueryStringHasBracketsInFieldnames() + { + $uri = 'tcp://10.10.10.10?persistent=1&metavars[]=foo&metavars[]=hoge'; + + $expected = array( + 'scheme' => 'tcp', + 'host' => '10.10.10.10', + 'persistent' => '1', + 'metavars' => array('foo', 'hoge'), + ); + + $this->assertSame($expected, ConnectionParameters::parseURI($uri)); + } + + /** + * @group disconnected + * @expectedException Predis\ClientException + * @expectedExceptionMessage Invalid URI: tcp://invalid:uri + */ + public function testParsingURIThrowOnInvalidURI() + { + ConnectionParameters::parseURI('tcp://invalid:uri'); + } + + // ******************************************************************** // + // ---- HELPER METHODS ------------------------------------------------ // + // ******************************************************************** // + + /** + * Returns a named array with the default connection parameters and their values. + * + * @return Array Default connection parameters. + */ + protected function getDefaultParametersArray() + { + return array( + 'scheme' => 'tcp', + 'host' => '127.0.0.1', + 'port' => 6379, + 'timeout' => 5.0, + ); + } + + /** + * Returns an URI string representation of the specified connection parameters. + * + * @param Array $parameters Array of connection parameters. + * @return String URI string. + */ + protected function getParametersString(Array $parameters) + { + $defaults = $this->getDefaultParametersArray(); + + $scheme = isset($parameters['scheme']) ? $parameters['scheme'] : $defaults['scheme']; + $host = isset($parameters['host']) ? $parameters['host'] : $defaults['host']; + $port = isset($parameters['port']) ? $parameters['port'] : $defaults['port']; + + unset($parameters['scheme'], $parameters['host'], $parameters['port']); + $uriString = "$scheme://$host:$port/?"; + + foreach ($parameters as $k => $v) { + $uriString .= "$k=$v&"; + } + + return $uriString; + } +} diff --git a/vendor/predis/predis/tests/Predis/Connection/MasterSlaveReplicationTest.php b/vendor/predis/predis/tests/Predis/Connection/MasterSlaveReplicationTest.php new file mode 100755 index 0000000..9d364c9 --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Connection/MasterSlaveReplicationTest.php @@ -0,0 +1,593 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Connection; + +use PredisTestCase; +use Predis\Profile\ServerProfile; +use Predis\Replication\ReplicationStrategy; + +/** + * + */ +class MasterSlaveReplicationTest extends PredisTestCase +{ + /** + * @group disconnected + */ + public function testAddingConnectionsToReplication() + { + $master = $this->getMockConnection('tcp://host1?alias=master'); + $slave1 = $this->getMockConnection('tcp://host2?alias=slave1'); + $slave2 = $this->getMockConnection('tcp://host3?alias=slave2'); + + $replication = new MasterSlaveReplication(); + $replication->add($master); + $replication->add($slave1); + $replication->add($slave2); + + $this->assertSame($master, $replication->getConnectionById('master')); + $this->assertSame($slave1, $replication->getConnectionById('slave1')); + $this->assertSame($slave2, $replication->getConnectionById('slave2')); + + $this->assertSame($master, $replication->getMaster()); + $this->assertSame(array($slave1, $slave2), $replication->getSlaves()); + } + + /** + * @group disconnected + */ + public function testRemovingConnectionsFromReplication() + { + $master = $this->getMockConnection('tcp://host1?alias=master'); + $slave1 = $this->getMockConnection('tcp://host2?alias=slave1'); + $slave2 = $this->getMockConnection('tcp://host3?alias=slave2'); + + $replication = new MasterSlaveReplication(); + $replication->add($master); + $replication->add($slave1); + + $this->assertTrue($replication->remove($slave1)); + $this->assertFalse($replication->remove($slave2)); + + $this->assertSame($master, $replication->getMaster()); + $this->assertSame(array(), $replication->getSlaves()); + } + + /** + * @group disconnected + * @expectedException RuntimeException + * @expectedExceptionMessage Replication needs a master and at least one slave + */ + public function testThrowsExceptionOnEmptyReplication() + { + $replication = new MasterSlaveReplication(); + $replication->connect(); + } + + /** + * @group disconnected + * @expectedException RuntimeException + * @expectedExceptionMessage Replication needs a master and at least one slave + */ + public function testThrowsExceptionOnMissingMaster() + { + $replication = new MasterSlaveReplication(); + $replication->add($this->getMockConnection('tcp://host2?alias=slave1')); + + $replication->connect(); + } + + /** + * @group disconnected + * @expectedException RuntimeException + * @expectedExceptionMessage Replication needs a master and at least one slave + */ + public function testThrowsExceptionOnMissingSlave() + { + $replication = new MasterSlaveReplication(); + $replication->add($this->getMockConnection('tcp://host1?alias=master')); + + $replication->connect(); + } + + /** + * @group disconnected + */ + public function testConnectForcesConnectionToOneOfSlaves() + { + $master = $this->getMockConnection('tcp://host1?alias=master'); + $master->expects($this->never())->method('connect'); + + $slave = $this->getMockConnection('tcp://host2?alias=slave1'); + $slave->expects($this->once())->method('connect'); + + $replication = new MasterSlaveReplication(); + $replication->add($master); + $replication->add($slave); + + $replication->connect(); + } + + /** + * @group disconnected + */ + public function testIsConnectedReturnsTrueIfAtLeastOneConnectionIsOpen() + { + $master = $this->getMockConnection('tcp://host1?alias=master'); + $master->expects($this->never())->method('isConnected')->will($this->returnValue(false)); + + $slave = $this->getMockConnection('tcp://host2?alias=slave1'); + $slave->expects($this->once())->method('isConnected')->will($this->returnValue(true)); + + $replication = new MasterSlaveReplication(); + $replication->add($master); + $replication->add($slave); + $replication->connect(); + + $this->assertTrue($replication->isConnected()); + } + + /** + * @group disconnected + */ + public function testIsConnectedReturnsFalseIfAllConnectionsAreClosed() + { + $master = $this->getMockConnection('tcp://host1?alias=master'); + $master->expects($this->any())->method('isConnected')->will($this->returnValue(false)); + + $slave = $this->getMockConnection('tcp://host2?alias=slave1'); + $slave->expects($this->any())->method('isConnected')->will($this->returnValue(false)); + + $replication = new MasterSlaveReplication(); + $replication->add($master); + $replication->add($slave); + + $this->assertFalse($replication->isConnected()); + + $replication->connect(); + $replication->disconnect(); + + $this->assertFalse($replication->isConnected()); + } + + /** + * @group disconnected + */ + public function testDisconnectForcesCurrentConnectionToDisconnect() + { + $master = $this->getMockConnection('tcp://host1?alias=master'); + $master->expects($this->once())->method('disconnect'); + + $slave = $this->getMockConnection('tcp://host2?alias=slave1'); + $slave->expects($this->once())->method('disconnect'); + + $replication = new MasterSlaveReplication(); + $replication->add($master); + $replication->add($slave); + + $replication->disconnect(); + } + + /** + * @group disconnected + */ + public function testCanSwitchConnectionByAlias() + { + $master = $this->getMockConnection('tcp://host1?alias=master'); + $slave1 = $this->getMockConnection('tcp://host2?alias=slave1'); + + $replication = new MasterSlaveReplication(); + $replication->add($master); + $replication->add($slave1); + + $this->assertNull($replication->getCurrent()); + + $replication->switchTo('master'); + $this->assertSame($master, $replication->getCurrent()); + $replication->switchTo('slave1'); + $this->assertSame($slave1, $replication->getCurrent()); + } + + /** + * @group disconnected + * @expectedException InvalidArgumentException + * @expectedExceptionMessage The specified connection is not valid + */ + public function testThrowsErrorWhenSwitchingToUnknownConnection() + { + $replication = new MasterSlaveReplication(); + $replication->add($this->getMockConnection('tcp://host1?alias=master')); + $replication->add($this->getMockConnection('tcp://host2?alias=slave1')); + + $replication->switchTo('unknown'); + } + + /** + * @group disconnected + */ + public function testUsesSlavesOnReadOnlyCommands() + { + $profile = ServerProfile::getDefault(); + + $master = $this->getMockConnection('tcp://host1?alias=master'); + $slave1 = $this->getMockConnection('tcp://host2?alias=slave1'); + + $replication = new MasterSlaveReplication(); + $replication->add($master); + $replication->add($slave1); + + $cmd = $profile->createCommand('exists', array('foo')); + $this->assertSame($slave1, $replication->getConnection($cmd)); + + $cmd = $profile->createCommand('get', array('foo')); + $this->assertSame($slave1, $replication->getConnection($cmd)); + } + + /** + * @group disconnected + */ + public function testUsesMasterOnWriteCommands() + { + $profile = ServerProfile::getDefault(); + + $master = $this->getMockConnection('tcp://host1?alias=master'); + $slave1 = $this->getMockConnection('tcp://host2?alias=slave1'); + + $replication = new MasterSlaveReplication(); + $replication->add($master); + $replication->add($slave1); + + $cmd = $profile->createCommand('set', array('foo', 'bar')); + $this->assertSame($master, $replication->getConnection($cmd)); + + $cmd = $profile->createCommand('get', array('foo')); + $this->assertSame($master, $replication->getConnection($cmd)); + } + + /** + * @group disconnected + */ + public function testSwitchesFromSlaveToMasterOnWriteCommands() + { + $profile = ServerProfile::getDefault(); + + $master = $this->getMockConnection('tcp://host1?alias=master'); + $slave1 = $this->getMockConnection('tcp://host2?alias=slave1'); + + $replication = new MasterSlaveReplication(); + $replication->add($master); + $replication->add($slave1); + + $cmd = $profile->createCommand('exists', array('foo')); + $this->assertSame($slave1, $replication->getConnection($cmd)); + + $cmd = $profile->createCommand('set', array('foo', 'bar')); + $this->assertSame($master, $replication->getConnection($cmd)); + + $cmd = $profile->createCommand('exists', array('foo')); + $this->assertSame($master, $replication->getConnection($cmd)); + } + + /** + * @group disconnected + */ + public function testWritesCommandToCorrectConnection() + { + $profile = ServerProfile::getDefault(); + $cmdExists = $profile->createCommand('exists', array('foo')); + $cmdSet = $profile->getDefault()->createCommand('set', array('foo', 'bar')); + + $master = $this->getMockConnection('tcp://host1?alias=master'); + $master->expects($this->once())->method('writeCommand')->with($cmdSet); + + $slave1 = $this->getMockConnection('tcp://host2?alias=slave1'); + $slave1->expects($this->once())->method('writeCommand')->with($cmdExists); + + $replication = new MasterSlaveReplication(); + $replication->add($master); + $replication->add($slave1); + + $replication->writeCommand($cmdExists); + $replication->writeCommand($cmdSet); + } + + /** + * @group disconnected + */ + public function testReadsCommandFromCorrectConnection() + { + $profile = ServerProfile::getDefault(); + $cmdExists = $profile->createCommand('exists', array('foo')); + $cmdSet = $profile->getDefault()->createCommand('set', array('foo', 'bar')); + + $master = $this->getMockConnection('tcp://host1?alias=master'); + $master->expects($this->once())->method('readResponse')->with($cmdSet); + + $slave1 = $this->getMockConnection('tcp://host2?alias=slave1'); + $slave1->expects($this->once())->method('readResponse')->with($cmdExists); + + $replication = new MasterSlaveReplication(); + $replication->add($master); + $replication->add($slave1); + + $replication->readResponse($cmdExists); + $replication->readResponse($cmdSet); + } + + /** + * @group disconnected + */ + public function testExecutesCommandOnCorrectConnection() + { + $profile = ServerProfile::getDefault(); + $cmdExists = $profile->createCommand('exists', array('foo')); + $cmdSet = $profile->getDefault()->createCommand('set', array('foo', 'bar')); + + $master = $this->getMockConnection('tcp://host1?alias=master'); + $master->expects($this->once())->method('executeCommand')->with($cmdSet); + + $slave1 = $this->getMockConnection('tcp://host2?alias=slave1'); + $slave1->expects($this->once())->method('executeCommand')->with($cmdExists); + + $replication = new MasterSlaveReplication(); + $replication->add($master); + $replication->add($slave1); + + $replication->executeCommand($cmdExists); + $replication->executeCommand($cmdSet); + } + + /** + * @group disconnected + */ + public function testWatchTriggersSwitchToMasterConnection() + { + $profile = ServerProfile::getDefault(); + $cmdWatch = $profile->createCommand('watch', array('foo')); + + $master = $this->getMockConnection('tcp://host1?alias=master'); + $master->expects($this->once())->method('executeCommand')->with($cmdWatch); + + $slave1 = $this->getMockConnection('tcp://host2?alias=slave1'); + $slave1->expects($this->never())->method('executeCommand'); + + $replication = new MasterSlaveReplication(); + $replication->add($master); + $replication->add($slave1); + + $replication->executeCommand($cmdWatch); + } + + /** + * @group disconnected + */ + public function testMultiTriggersSwitchToMasterConnection() + { + $profile = ServerProfile::getDefault(); + $cmdMulti = $profile->createCommand('multi'); + + $master = $this->getMockConnection('tcp://host1?alias=master'); + $master->expects($this->once())->method('executeCommand')->with($cmdMulti); + + $slave1 = $this->getMockConnection('tcp://host2?alias=slave1'); + $slave1->expects($this->never())->method('executeCommand'); + + $replication = new MasterSlaveReplication(); + $replication->add($master); + $replication->add($slave1); + + $replication->executeCommand($cmdMulti); + } + + /** + * @group disconnected + */ + public function testEvalTriggersSwitchToMasterConnection() + { + $profile = ServerProfile::get('dev'); + $cmdEval = $profile->createCommand('eval', array("return redis.call('info')")); + + $master = $this->getMockConnection('tcp://host1?alias=master'); + $master->expects($this->once())->method('executeCommand')->with($cmdEval); + + $slave1 = $this->getMockConnection('tcp://host2?alias=slave1'); + $slave1->expects($this->never())->method('executeCommand'); + + $replication = new MasterSlaveReplication(); + $replication->add($master); + $replication->add($slave1); + + $replication->executeCommand($cmdEval); + } + + /** + * @group disconnected + */ + public function testSortTriggersSwitchToMasterConnectionOnStoreModifier() + { + $profile = ServerProfile::get('dev'); + $cmdSortNormal = $profile->createCommand('sort', array('key')); + $cmdSortStore = $profile->createCommand('sort', array('key', array('store' => 'key:store'))); + + $master = $this->getMockConnection('tcp://host1?alias=master'); + $master->expects($this->once())->method('executeCommand')->with($cmdSortStore); + + $slave1 = $this->getMockConnection('tcp://host2?alias=slave1'); + $slave1->expects($this->once())->method('executeCommand')->with($cmdSortNormal); + + $replication = new MasterSlaveReplication(); + $replication->add($master); + $replication->add($slave1); + + $replication->executeCommand($cmdSortNormal); + $replication->executeCommand($cmdSortStore); + } + + /** + * @group disconnected + * @expectedException Predis\NotSupportedException + * @expectedExceptionMessage The command INFO is not allowed in replication mode + */ + public function testThrowsExceptionOnNonSupportedCommand() + { + $cmd = ServerProfile::getDefault()->createCommand('info'); + + $replication = new MasterSlaveReplication(); + $replication->add($this->getMockConnection('tcp://host1?alias=master')); + $replication->add($this->getMockConnection('tcp://host2?alias=slave1')); + + $replication->getConnection($cmd); + } + + /** + * @group disconnected + */ + public function testCanOverrideReadOnlyFlagForCommands() + { + $profile = ServerProfile::getDefault(); + $cmdSet = $profile->createCommand('set', array('foo', 'bar')); + $cmdGet = $profile->createCommand('get', array('foo')); + + $master = $this->getMockConnection('tcp://host1?alias=master'); + $master->expects($this->once())->method('executeCommand')->with($cmdGet); + + $slave1 = $this->getMockConnection('tcp://host2?alias=slave1'); + $slave1->expects($this->once())->method('executeCommand')->with($cmdSet); + + $replication = new MasterSlaveReplication(); + $replication->add($master); + $replication->add($slave1); + + $replication->getReplicationStrategy()->setCommandReadOnly($cmdSet->getId(), true); + $replication->getReplicationStrategy()->setCommandReadOnly($cmdGet->getId(), false); + + $replication->executeCommand($cmdSet); + $replication->executeCommand($cmdGet); + } + + /** + * @group disconnected + */ + public function testAcceptsCallableToOverrideReadOnlyFlagForCommands() + { + $profile = ServerProfile::getDefault(); + $cmdExistsFoo = $profile->createCommand('exists', array('foo')); + $cmdExistsBar = $profile->createCommand('exists', array('bar')); + + $master = $this->getMockConnection('tcp://host1?alias=master'); + $master->expects($this->once())->method('executeCommand')->with($cmdExistsBar); + + $slave1 = $this->getMockConnection('tcp://host2?alias=slave1'); + $slave1->expects($this->once())->method('executeCommand')->with($cmdExistsFoo); + + $replication = new MasterSlaveReplication(); + $replication->add($master); + $replication->add($slave1); + + $replication->getReplicationStrategy()->setCommandReadOnly('exists', function ($cmd) { + list($arg1) = $cmd->getArguments(); + + return $arg1 === 'foo'; + }); + + $replication->executeCommand($cmdExistsFoo); + $replication->executeCommand($cmdExistsBar); + } + + /** + * @group disconnected + */ + public function testCanSetReadOnlyFlagForEvalScripts() + { + $profile = ServerProfile::get('dev'); + + $cmdEval = $profile->createCommand('eval', array($script = "return redis.call('info');")); + $cmdEvalSha = $profile->createCommand('evalsha', array($scriptSHA1 = sha1($script))); + + $master = $this->getMockConnection('tcp://host1?alias=master'); + $master->expects($this->never())->method('executeCommand'); + + $slave1 = $this->getMockConnection('tcp://host2?alias=slave1'); + $slave1->expects($this->exactly(2)) + ->method('executeCommand') + ->with($this->logicalOr($cmdEval, $cmdEvalSha)); + + $replication = new MasterSlaveReplication(); + $replication->add($master); + $replication->add($slave1); + + $replication->getReplicationStrategy()->setScriptReadOnly($script); + + $replication->executeCommand($cmdEval); + $replication->executeCommand($cmdEvalSha); + } + + /** + * @group disconnected + */ + public function testExposesReplicationStrategy() + { + $replication = new MasterSlaveReplication(); + $this->assertInstanceOf('Predis\Replication\ReplicationStrategy', $replication->getReplicationStrategy()); + + $strategy = new ReplicationStrategy(); + $replication = new MasterSlaveReplication($strategy); + $this->assertSame($strategy, $replication->getReplicationStrategy()); + } + + /** + * @group disconnected + */ + public function testCanBeSerialized() + { + $master = $this->getMockConnection('tcp://host1?alias=master'); + $slave1 = $this->getMockConnection('tcp://host2?alias=slave1'); + + $replication = new MasterSlaveReplication(); + $replication->add($master); + $replication->add($slave1); + + $unserialized = unserialize(serialize($replication)); + + $this->assertEquals($master, $unserialized->getConnectionById('master')); + $this->assertEquals($slave1, $unserialized->getConnectionById('slave1')); + } + + // ******************************************************************** // + // ---- HELPER METHODS ------------------------------------------------ // + // ******************************************************************** // + + /** + * Returns a base mocked connection from Predis\Connection\SingleConnectionInterface. + * + * @param mixed $parameters Optional parameters. + * @return mixed + */ + protected function getMockConnection($parameters = null) + { + $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); + + if ($parameters) { + $parameters = new ConnectionParameters($parameters); + $hash = "{$parameters->host}:{$parameters->port}"; + + $connection->expects($this->any()) + ->method('getParameters') + ->will($this->returnValue($parameters)); + $connection->expects($this->any()) + ->method('__toString') + ->will($this->returnValue($hash)); + } + + return $connection; + } +} diff --git a/vendor/predis/predis/tests/Predis/Connection/PhpiredisConnectionTest.php b/vendor/predis/predis/tests/Predis/Connection/PhpiredisConnectionTest.php new file mode 100755 index 0000000..0044814 --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Connection/PhpiredisConnectionTest.php @@ -0,0 +1,138 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Connection; + +/** + * @group ext-phpiredis + */ +class PhpiredisConnectionTest extends PredisConnectionTestCase +{ + /** + * @group disconnected + */ + public function testConstructorDoesNotOpenConnection() + { + $connection = new PhpiredisConnection($this->getParameters()); + + $this->assertFalse($connection->isConnected()); + } + + /** + * @group disconnected + */ + public function testExposesParameters() + { + $parameters = $this->getParameters(); + $connection = new PhpiredisConnection($parameters); + + $this->assertSame($parameters, $connection->getParameters()); + } + + /** + * @group disconnected + * @expectedException InvalidArgumentException + * @expectedExceptionMessage Invalid scheme: udp + */ + public function testThrowsExceptionOnInvalidScheme() + { + $parameters = $this->getParameters(array('scheme' => 'udp')); + $connection = new PhpiredisConnection($parameters); + } + + /** + * @group disconnected + */ + public function testCanBeSerialized() + { + $parameters = $this->getParameters(array('alias' => 'redis', 'read_write_timeout' => 10)); + $connection = new PhpiredisConnection($parameters); + + $unserialized = unserialize(serialize($connection)); + + $this->assertInstanceOf('Predis\Connection\PhpiredisConnection', $unserialized); + $this->assertEquals($parameters, $unserialized->getParameters()); + } + + // ******************************************************************** // + // ---- INTEGRATION TESTS --------------------------------------------- // + // ******************************************************************** // + + /** + * @group connected + */ + public function testExecutesCommandsOnServer() + { + $connection = $this->getConnection($profile, true); + + $cmdPing = $profile->createCommand('ping'); + $cmdEcho = $profile->createCommand('echo', array('echoed')); + $cmdGet = $profile->createCommand('get', array('foobar')); + $cmdRpush = $profile->createCommand('rpush', array('metavars', 'foo', 'hoge', 'lol')); + $cmdLrange = $profile->createCommand('lrange', array('metavars', 0, -1)); + + $this->assertSame('PONG', $connection->executeCommand($cmdPing)); + $this->assertSame('echoed', $connection->executeCommand($cmdEcho)); + $this->assertNull($connection->executeCommand($cmdGet)); + $this->assertSame(3, $connection->executeCommand($cmdRpush)); + $this->assertSame(array('foo', 'hoge', 'lol'), $connection->executeCommand($cmdLrange)); + } + + /** + * @group connected + * @expectedException Predis\Connection\ConnectionException + * @expectedExceptionMessage Cannot resolve the address of 'bogus.tld'. + */ + public function testThrowsExceptionOnUnresolvableHostname() + { + $parameters = $this->getParameters(array('host' => 'bogus.tld')); + $connection = new PhpiredisConnection($parameters); + $connection->connect(); + } + + /** + * @group connected + * @expectedException Predis\Protocol\ProtocolException + * @expectedExceptionMessage Protocol error, got "P" as reply type byte + */ + public function testThrowsExceptionOnProtocolDesynchronizationErrors() + { + $connection = $this->getConnection($profile); + $socket = $connection->getResource(); + + $connection->writeCommand($profile->createCommand('ping')); + socket_read($socket, 1); + + $connection->read(); + } + + // ******************************************************************** // + // ---- HELPER METHODS ------------------------------------------------ // + // ******************************************************************** // + + /** + * {@inheritdoc} + */ + protected function getConnection(&$profile = null, $initialize = false, Array $parameters = array()) + { + $parameters = $this->getParameters($parameters); + $profile = $this->getProfile(); + + $connection = new PhpiredisConnection($parameters); + + if ($initialize) { + $connection->pushInitCommand($profile->createCommand('select', array($parameters->database))); + $connection->pushInitCommand($profile->createCommand('flushdb')); + } + + return $connection; + } +} diff --git a/vendor/predis/predis/tests/Predis/Connection/PhpiredisStreamConnectionTest.php b/vendor/predis/predis/tests/Predis/Connection/PhpiredisStreamConnectionTest.php new file mode 100755 index 0000000..7126f2a --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Connection/PhpiredisStreamConnectionTest.php @@ -0,0 +1,145 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Connection; + +/** + * @group ext-phpiredis + */ +class PhpiredisStreamConnectionTest extends PredisConnectionTestCase +{ + /** + * @group disconnected + */ + public function testConstructorDoesNotOpenConnection() + { + $connection = new PhpiredisStreamConnection($this->getParameters()); + + $this->assertFalse($connection->isConnected()); + } + + /** + * @group disconnected + */ + public function testExposesParameters() + { + $parameters = $this->getParameters(); + $connection = new PhpiredisStreamConnection($parameters); + + $this->assertSame($parameters, $connection->getParameters()); + } + + /** + * @group disconnected + * @expectedException InvalidArgumentException + * @expectedExceptionMessage Invalid scheme: udp + */ + public function testThrowsExceptionOnInvalidScheme() + { + $parameters = $this->getParameters(array('scheme' => 'udp')); + $connection = new PhpiredisStreamConnection($parameters); + } + + /** + * @group disconnected + */ + public function testCanBeSerialized() + { + $parameters = $this->getParameters(array('alias' => 'redis', 'read_write_timeout' => 10)); + $connection = new PhpiredisStreamConnection($parameters); + + $unserialized = unserialize(serialize($connection)); + + $this->assertInstanceOf('Predis\Connection\PhpiredisStreamConnection', $unserialized); + $this->assertEquals($parameters, $unserialized->getParameters()); + } + + // ******************************************************************** // + // ---- INTEGRATION TESTS --------------------------------------------- // + // ******************************************************************** // + + /** + * @group connected + */ + public function testAcceptsTcpNodelayParameter() + { + if (!version_compare(PHP_VERSION, '5.4.0', '>=')) { + $this->markTestSkipped('Setting TCP_NODELAY on PHP socket streams works on PHP >= 5.4.0'); + } + + $connection = new PhpiredisStreamConnection($this->getParameters(array('tcp_nodelay' => false))); + $connection->connect(); + $this->assertTrue($connection->isConnected()); + + $connection = new PhpiredisStreamConnection($this->getParameters(array('tcp_nodelay' => true))); + $connection->connect(); + $this->assertTrue($connection->isConnected()); + } + + /** + * @group connected + */ + public function testExecutesCommandsOnServer() + { + $connection = $this->getConnection($profile, true); + + $cmdPing = $profile->createCommand('ping'); + $cmdEcho = $profile->createCommand('echo', array('echoed')); + $cmdGet = $profile->createCommand('get', array('foobar')); + $cmdRpush = $profile->createCommand('rpush', array('metavars', 'foo', 'hoge', 'lol')); + $cmdLrange = $profile->createCommand('lrange', array('metavars', 0, -1)); + + $this->assertSame('PONG', $connection->executeCommand($cmdPing)); + $this->assertSame('echoed', $connection->executeCommand($cmdEcho)); + $this->assertNull($connection->executeCommand($cmdGet)); + $this->assertSame(3, $connection->executeCommand($cmdRpush)); + $this->assertSame(array('foo', 'hoge', 'lol'), $connection->executeCommand($cmdLrange)); + } + + /** + * @medium + * @group connected + * @expectedException Predis\Protocol\ProtocolException + * @expectedExceptionMessage Protocol error, got "P" as reply type byte + */ + public function testThrowsExceptionOnProtocolDesynchronizationErrors() + { + $connection = $this->getConnection($profile); + $socket = $connection->getResource(); + + $connection->writeCommand($profile->createCommand('ping')); + fread($socket, 1); + + $connection->read(); + } + + // ******************************************************************** // + // ---- HELPER METHODS ------------------------------------------------ // + // ******************************************************************** // + + /** + * {@inheritdoc} + */ + protected function getConnection(&$profile = null, $initialize = false, Array $parameters = array()) + { + $parameters = $this->getParameters($parameters); + $profile = $this->getProfile(); + + $connection = new PhpiredisStreamConnection($parameters); + + if ($initialize) { + $connection->pushInitCommand($profile->createCommand('select', array($parameters->database))); + $connection->pushInitCommand($profile->createCommand('flushdb')); + } + + return $connection; + } +} diff --git a/vendor/predis/predis/tests/Predis/Connection/PredisClusterTest.php b/vendor/predis/predis/tests/Predis/Connection/PredisClusterTest.php new file mode 100755 index 0000000..76a7e42 --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Connection/PredisClusterTest.php @@ -0,0 +1,404 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Connection; + +use PredisTestCase; +use Predis\Profile\ServerProfile; + +/** + * + */ +class PredisClusterTest extends PredisTestCase +{ + /** + * @group disconnected + */ + public function testExposesCommandHashStrategy() + { + $cluster = new PredisCluster(); + $this->assertInstanceOf('Predis\Cluster\PredisClusterHashStrategy', $cluster->getCommandHashStrategy()); + } + + /** + * @group disconnected + */ + public function testAddingConnectionsToCluster() + { + $connection1 = $this->getMockConnection(); + $connection2 = $this->getMockConnection(); + + $cluster = new PredisCluster(); + $cluster->add($connection1); + $cluster->add($connection2); + + $this->assertSame(2, count($cluster)); + $this->assertSame($connection1, $cluster->getConnectionById(0)); + $this->assertSame($connection2, $cluster->getConnectionById(1)); + } + + /** + * @group disconnected + */ + public function testAddingConnectionsToClusterUsesConnectionAlias() + { + $connection1 = $this->getMockConnection('tcp://host1:7001?alias=node1'); + $connection2 = $this->getMockConnection('tcp://host1:7002?alias=node2'); + + $cluster = new PredisCluster(); + $cluster->add($connection1); + $cluster->add($connection2); + + $this->assertSame(2, count($cluster)); + $this->assertSame($connection1, $cluster->getConnectionById('node1')); + $this->assertSame($connection2, $cluster->getConnectionById('node2')); + } + + /** + * @group disconnected + */ + public function testRemovingConnectionsFromCluster() + { + $connection1 = $this->getMockConnection(); + $connection2 = $this->getMockConnection(); + $connection3 = $this->getMockConnection(); + + $cluster = new PredisCluster(); + $cluster->add($connection1); + $cluster->add($connection2); + + $this->assertTrue($cluster->remove($connection1)); + $this->assertFalse($cluster->remove($connection3)); + $this->assertSame(1, count($cluster)); + } + + /** + * @group disconnected + */ + public function testRemovingConnectionsFromClusterByAlias() + { + $connection1 = $this->getMockConnection(); + $connection2 = $this->getMockConnection('tcp://host1:7001?alias=node2'); + $connection3 = $this->getMockConnection('tcp://host1:7002?alias=node3'); + $connection4 = $this->getMockConnection('tcp://host1:7003?alias=node4'); + + $cluster = new PredisCluster(); + $cluster->add($connection1); + $cluster->add($connection2); + $cluster->add($connection3); + + $this->assertTrue($cluster->removeById(0)); + $this->assertTrue($cluster->removeById('node2')); + $this->assertFalse($cluster->removeById('node4')); + $this->assertSame(1, count($cluster)); + } + + /** + * @group disconnected + */ + public function testConnectForcesAllConnectionsToConnect() + { + $connection1 = $this->getMockConnection(); + $connection1->expects($this->once())->method('connect'); + + $connection2 = $this->getMockConnection(); + $connection2->expects($this->once())->method('connect'); + + $cluster = new PredisCluster(); + $cluster->add($connection1); + $cluster->add($connection2); + + $cluster->connect(); + } + + /** + * @group disconnected + */ + public function testDisconnectForcesAllConnectionsToDisconnect() + { + $connection1 = $this->getMockConnection(); + $connection1->expects($this->once())->method('disconnect'); + + $connection2 = $this->getMockConnection(); + $connection2->expects($this->once())->method('disconnect'); + + $cluster = new PredisCluster(); + $cluster->add($connection1); + $cluster->add($connection2); + + $cluster->disconnect(); + } + + /** + * @group disconnected + */ + public function testIsConnectedReturnsTrueIfAtLeastOneConnectionIsOpen() + { + $connection1 = $this->getMockConnection(); + $connection1->expects($this->once()) + ->method('isConnected') + ->will($this->returnValue(false)); + + $connection2 = $this->getMockConnection(); + $connection2->expects($this->once()) + ->method('isConnected') + ->will($this->returnValue(true)); + + $cluster = new PredisCluster(); + $cluster->add($connection1); + $cluster->add($connection2); + + $this->assertTrue($cluster->isConnected()); + } + + /** + * @group disconnected + */ + public function testIsConnectedReturnsFalseIfAllConnectionsAreClosed() + { + $connection1 = $this->getMockConnection(); + $connection1->expects($this->once()) + ->method('isConnected') + ->will($this->returnValue(false)); + + $connection2 = $this->getMockConnection(); + $connection2->expects($this->once()) + ->method('isConnected') + ->will($this->returnValue(false)); + + $cluster = new PredisCluster(); + $cluster->add($connection1); + $cluster->add($connection2); + + $this->assertFalse($cluster->isConnected()); + } + + /** + * @group disconnected + */ + public function testCanReturnAnIteratorForConnections() + { + $connection1 = $this->getMockConnection(); + $connection2 = $this->getMockConnection(); + + $cluster = new PredisCluster(); + $cluster->add($connection1); + $cluster->add($connection2); + + $this->assertInstanceOf('Iterator', $iterator = $cluster->getIterator()); + $connections = iterator_to_array($iterator); + + $this->assertSame($connection1, $connections[0]); + $this->assertSame($connection2, $connections[1]); + } + + /** + * @group disconnected + */ + public function testReturnsCorrectConnectionUsingKey() + { + $connection1 = $this->getMockConnection('tcp://host1:7001'); + $connection2 = $this->getMockConnection('tcp://host1:7002'); + + $cluster = new PredisCluster(); + $cluster->add($connection1); + $cluster->add($connection2); + + $this->assertSame($connection1, $cluster->getConnectionByKey('node01:5431')); + $this->assertSame($connection2, $cluster->getConnectionByKey('node02:3212')); + $this->assertSame($connection1, $cluster->getConnectionByKey('prefix:{node01:5431}')); + $this->assertSame($connection2, $cluster->getConnectionByKey('prefix:{node02:3212}')); + } + + /** + * @group disconnected + */ + public function testReturnsCorrectConnectionUsingCommandInstance() + { + $profile = ServerProfile::getDefault(); + + $connection1 = $this->getMockConnection('tcp://host1:7001'); + $connection2 = $this->getMockConnection('tcp://host1:7002'); + + $cluster = new PredisCluster(); + $cluster->add($connection1); + $cluster->add($connection2); + + $set = $profile->createCommand('set', array('node01:5431', 'foobar')); + $get = $profile->createCommand('get', array('node01:5431')); + $this->assertSame($connection1, $cluster->getConnection($set)); + $this->assertSame($connection1, $cluster->getConnection($get)); + + $set = $profile->createCommand('set', array('prefix:{node01:5431}', 'foobar')); + $get = $profile->createCommand('get', array('prefix:{node01:5431}')); + $this->assertSame($connection1, $cluster->getConnection($set)); + $this->assertSame($connection1, $cluster->getConnection($get)); + + $set = $profile->createCommand('set', array('node02:3212', 'foobar')); + $get = $profile->createCommand('get', array('node02:3212')); + $this->assertSame($connection2, $cluster->getConnection($set)); + $this->assertSame($connection2, $cluster->getConnection($get)); + + $set = $profile->createCommand('set', array('prefix:{node02:3212}', 'foobar')); + $get = $profile->createCommand('get', array('prefix:{node02:3212}')); + $this->assertSame($connection2, $cluster->getConnection($set)); + $this->assertSame($connection2, $cluster->getConnection($get)); + } + + /** + * @group disconnected + * @expectedException Predis\NotSupportedException + * @expectedExceptionMessage Cannot use PING with a cluster of connections + */ + public function testThrowsExceptionOnNonShardableCommand() + { + $ping = ServerProfile::getDefault()->createCommand('ping'); + + $cluster = new PredisCluster(); + $cluster->add($this->getMockConnection()); + + $cluster->getConnection($ping); + } + + /** + * @group disconnected + */ + public function testWritesCommandToCorrectConnection() + { + $command = ServerProfile::getDefault()->createCommand('get', array('node01:5431')); + + $connection1 = $this->getMockConnection('tcp://host1:7001'); + $connection1->expects($this->once())->method('writeCommand')->with($command); + + $connection2 = $this->getMockConnection('tcp://host1:7002'); + $connection2->expects($this->never())->method('writeCommand'); + + $cluster = new PredisCluster(); + $cluster->add($connection1); + $cluster->add($connection2); + + $cluster->writeCommand($command); + } + + /** + * @group disconnected + */ + public function testReadsCommandFromCorrectConnection() + { + $command = ServerProfile::getDefault()->createCommand('get', array('node02:3212')); + + $connection1 = $this->getMockConnection('tcp://host1:7001'); + $connection1->expects($this->never())->method('readResponse'); + + $connection2 = $this->getMockConnection('tcp://host1:7002'); + $connection2->expects($this->once())->method('readResponse')->with($command); + + $cluster = new PredisCluster(); + $cluster->add($connection1); + $cluster->add($connection2); + + $cluster->readResponse($command); + } + + /** + * @group disconnected + */ + public function testExecutesCommandOnCorrectConnection() + { + $command = ServerProfile::getDefault()->createCommand('get', array('node01:5431')); + + $connection1 = $this->getMockConnection('tcp://host1:7001'); + $connection1->expects($this->once())->method('executeCommand')->with($command); + + $connection2 = $this->getMockConnection('tcp://host1:7002'); + $connection2->expects($this->never())->method('executeCommand'); + + $cluster = new PredisCluster(); + $cluster->add($connection1); + $cluster->add($connection2); + + $cluster->executeCommand($command); + } + + /** + * @group disconnected + */ + public function testExecuteCommandOnEachNode() + { + $ping = ServerProfile::getDefault()->createCommand('ping', array()); + + $connection1 = $this->getMock('Predis\Connection\SingleConnectionInterface'); + $connection1->expects($this->once()) + ->method('executeCommand') + ->with($ping) + ->will($this->returnValue(true)); + + $connection2 = $this->getMock('Predis\Connection\SingleConnectionInterface'); + $connection2->expects($this->once()) + ->method('executeCommand') + ->with($ping) + ->will($this->returnValue(false)); + + $cluster = new PredisCluster(); + $cluster->add($connection1); + $cluster->add($connection2); + + $this->assertSame(array(true, false), $cluster->executeCommandOnNodes($ping)); + } + + /** + * @group disconnected + */ + public function testCanBeSerialized() + { + $connection1 = $this->getMockConnection('tcp://host1?alias=first'); + $connection2 = $this->getMockConnection('tcp://host2?alias=second'); + + $cluster = new PredisCluster(); + $cluster->add($connection1); + $cluster->add($connection2); + + // We use the following line to initialize the underlying hashring. + $cluster->getConnectionByKey('foo'); + $unserialized = unserialize(serialize($cluster)); + + $this->assertEquals($cluster, $unserialized); + } + + // ******************************************************************** // + // ---- HELPER METHODS ------------------------------------------------ // + // ******************************************************************** // + + /** + * Returns a base mocked connection from Predis\Connection\SingleConnectionInterface. + * + * @param mixed $parameters Optional parameters. + * @return mixed + */ + protected function getMockConnection($parameters = null) + { + $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); + + if ($parameters) { + $parameters = new ConnectionParameters($parameters); + $hash = "{$parameters->host}:{$parameters->port}"; + + $connection->expects($this->any()) + ->method('getParameters') + ->will($this->returnValue($parameters)); + $connection->expects($this->any()) + ->method('__toString') + ->will($this->returnValue($hash)); + } + + return $connection; + } +} diff --git a/vendor/predis/predis/tests/Predis/Connection/RedisClusterTest.php b/vendor/predis/predis/tests/Predis/Connection/RedisClusterTest.php new file mode 100755 index 0000000..77dee67 --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Connection/RedisClusterTest.php @@ -0,0 +1,667 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Connection; + +use PredisTestCase; +use Predis\ResponseError; +use Predis\Profile\ServerProfile; + +/** + * + */ +class RedisClusterTest extends PredisTestCase +{ + /** + * @group disconnected + */ + public function testExposesCommandHashStrategy() + { + $cluster = new RedisCluster(); + $this->assertInstanceOf('Predis\Cluster\RedisClusterHashStrategy', $cluster->getCommandHashStrategy()); + } + + /** + * @group disconnected + */ + public function testAddingConnectionsToCluster() + { + $connection1 = $this->getMockConnection('tcp://127.0.0.1:6379'); + $connection2 = $this->getMockConnection('tcp://127.0.0.1:6380'); + + $cluster = new RedisCluster(); + $cluster->add($connection1); + $cluster->add($connection2); + + $this->assertSame(2, count($cluster)); + $this->assertSame($connection1, $cluster->getConnectionById('127.0.0.1:6379')); + $this->assertSame($connection2, $cluster->getConnectionById('127.0.0.1:6380')); + } + + /** + * @group disconnected + */ + public function testRemovingConnectionsFromCluster() + { + $connection1 = $this->getMockConnection('tcp://127.0.0.1:6379'); + $connection2 = $this->getMockConnection('tcp://127.0.0.1:6380'); + $connection3 = $this->getMockConnection('tcp://127.0.0.1:6371'); + + $cluster = new RedisCluster(); + $cluster->add($connection1); + $cluster->add($connection2); + + $this->assertTrue($cluster->remove($connection1)); + $this->assertFalse($cluster->remove($connection3)); + $this->assertSame(1, count($cluster)); + } + + /** + * @group disconnected + */ + public function testRemovingConnectionsFromClusterByAlias() + { + $connection1 = $this->getMockConnection('tcp://127.0.0.1:6379'); + $connection2 = $this->getMockConnection('tcp://127.0.0.1:6380'); + + $cluster = new RedisCluster(); + $cluster->add($connection1); + $cluster->add($connection2); + + $this->assertTrue($cluster->removeById('127.0.0.1:6380')); + $this->assertFalse($cluster->removeById('127.0.0.1:6390')); + $this->assertSame(1, count($cluster)); + } + + /** + * @group disconnected + */ + public function testCountReturnsNumberOfConnectionsInPool() + { + $connection1 = $this->getMockConnection('tcp://127.0.0.1:6379'); + $connection2 = $this->getMockConnection('tcp://127.0.0.1:6380'); + $connection3 = $this->getMockConnection('tcp://127.0.0.1:6381'); + + $cluster = new RedisCluster(); + $cluster->add($connection1); + $cluster->add($connection2); + $cluster->add($connection3); + + $this->assertSame(3, count($cluster)); + + $cluster->remove($connection3); + + $this->assertSame(2, count($cluster)); + } + + /** + * @group disconnected + */ + public function testConnectPicksRandomConnection() + { + $connect1 = false; + $connect2 = false; + + $connection1 = $this->getMockConnection('tcp://127.0.0.1:6379'); + $connection1->expects($this->any()) + ->method('connect') + ->will($this->returnCallback(function () use (&$connect1) { + $connect1 = true; + })); + $connection1->expects($this->any()) + ->method('isConnected') + ->will($this->returnCallback(function () use (&$connect1) { + return $connect1; + })); + + $connection2 = $this->getMockConnection('tcp://127.0.0.1:6380'); + $connection2->expects($this->any()) + ->method('connect') + ->will($this->returnCallback(function () use (&$connect2) { + $connect2 = true; + })); + $connection2->expects($this->any()) + ->method('isConnected') + ->will($this->returnCallback(function () use (&$connect2) { + return $connect2; + })); + + $cluster = new RedisCluster(); + $cluster->add($connection1); + $cluster->add($connection2); + + $cluster->connect(); + + $this->assertTrue($cluster->isConnected()); + + if ($connect1) { + $this->assertTrue($connect1); + $this->assertFalse($connect2); + } else { + $this->assertFalse($connect1); + $this->assertTrue($connect2); + } + } + + /** + * @group disconnected + */ + public function testDisconnectForcesAllConnectionsToDisconnect() + { + $connection1 = $this->getMockConnection('tcp://127.0.0.1:6379'); + $connection1->expects($this->once())->method('disconnect'); + + $connection2 = $this->getMockConnection('tcp://127.0.0.1:6380'); + $connection2->expects($this->once())->method('disconnect'); + + $cluster = new RedisCluster(); + $cluster->add($connection1); + $cluster->add($connection2); + + $cluster->disconnect(); + } + + /** + * @group disconnected + */ + public function testIsConnectedReturnsTrueIfAtLeastOneConnectionIsOpen() + { + $connection1 = $this->getMockConnection('tcp://127.0.0.1:6379'); + $connection1->expects($this->once()) + ->method('isConnected') + ->will($this->returnValue(false)); + + $connection2 = $this->getMockConnection('tcp://127.0.0.1:6380'); + $connection2->expects($this->once()) + ->method('isConnected') + ->will($this->returnValue(true)); + + $cluster = new RedisCluster(); + $cluster->add($connection1); + $cluster->add($connection2); + + $this->assertTrue($cluster->isConnected()); + } + + /** + * @group disconnected + */ + public function testIsConnectedReturnsFalseIfAllConnectionsAreClosed() + { + $connection1 = $this->getMockConnection('tcp://127.0.0.1:6379'); + $connection1->expects($this->once()) + ->method('isConnected') + ->will($this->returnValue(false)); + + $connection2 = $this->getMockConnection('tcp://127.0.0.1:6380'); + $connection2->expects($this->once()) + ->method('isConnected') + ->will($this->returnValue(false)); + + $cluster = new RedisCluster(); + $cluster->add($connection1); + $cluster->add($connection2); + + $this->assertFalse($cluster->isConnected()); + } + + /** + * @group disconnected + */ + public function testCanReturnAnIteratorForConnections() + { + $connection1 = $this->getMockConnection('tcp://127.0.0.1:6379'); + $connection2 = $this->getMockConnection('tcp://127.0.0.1:6380'); + + $cluster = new RedisCluster(); + $cluster->add($connection1); + $cluster->add($connection2); + + $this->assertInstanceOf('Iterator', $iterator = $cluster->getIterator()); + $connections = iterator_to_array($iterator); + + $this->assertSame($connection1, $connections[0]); + $this->assertSame($connection2, $connections[1]); + } + + /** + * @group disconnected + */ + public function testCanAssignConnectionsToCustomSlots() + { + $connection1 = $this->getMockConnection('tcp://127.0.0.1:6379'); + $connection2 = $this->getMockConnection('tcp://127.0.0.1:6380'); + $connection3 = $this->getMockConnection('tcp://127.0.0.1:6381'); + + $cluster = new RedisCluster(); + $cluster->add($connection1); + $cluster->add($connection2); + $cluster->add($connection3); + + $cluster->setSlots(0, 1364, '127.0.0.1:6379'); + $cluster->setSlots(1365, 2729, '127.0.0.1:6380'); + $cluster->setSlots(2730, 4095, '127.0.0.1:6381'); + + $expectedMap = array_merge( + array_fill(0, 1365, '127.0.0.1:6379'), + array_fill(1364, 1365, '127.0.0.1:6380'), + array_fill(2729, 1366, '127.0.0.1:6381') + ); + + $this->assertSame($expectedMap, $cluster->getSlotsMap()); + } + + /** + * @group disconnected + */ + public function testAddingConnectionResetsSlotsMap() + { + $connection1 = $this->getMockConnection('tcp://127.0.0.1:6379'); + $connection2 = $this->getMockConnection('tcp://127.0.0.1:6380'); + + $cluster = new RedisCluster(); + $cluster->add($connection1); + + $cluster->setSlots(0, 4095, '127.0.0.1:6379'); + $this->assertSame(array_fill(0, 4096, '127.0.0.1:6379'), $cluster->getSlotsMap()); + + $cluster->add($connection2); + + $this->assertEmpty($cluster->getSlotsMap()); + } + + /** + * @group disconnected + */ + public function testRemovingConnectionResetsSlotsMap() + { + $connection1 = $this->getMockConnection('tcp://127.0.0.1:6379'); + $connection2 = $this->getMockConnection('tcp://127.0.0.1:6380'); + + $cluster = new RedisCluster(); + $cluster->add($connection1); + $cluster->add($connection2); + + $cluster->setSlots(0, 2047, '127.0.0.1:6379'); + $cluster->setSlots(2048, 4095, '127.0.0.1:6380'); + + $expectedMap = array_merge( + array_fill(0, 2048, '127.0.0.1:6379'), + array_fill(2048, 2048, '127.0.0.1:6380') + ); + + $this->assertSame($expectedMap, $cluster->getSlotsMap()); + + $cluster->remove($connection1); + $this->assertEmpty($cluster->getSlotsMap()); + } + + /** + * @group disconnected + */ + public function testCanAssignConnectionsToCustomSlotsFromParameters() + { + $connection1 = $this->getMockConnection('tcp://127.0.0.1:6379?slots=0-5460'); + $connection2 = $this->getMockConnection('tcp://127.0.0.1:6380?slots=5461-10921'); + $connection3 = $this->getMockConnection('tcp://127.0.0.1:6381?slots=10922-16383'); + + $cluster = new RedisCluster(); + $cluster->add($connection1); + $cluster->add($connection2); + $cluster->add($connection3); + + $expectedMap = array_merge( + array_fill(0, 5461, '127.0.0.1:6379'), + array_fill(5460, 5461, '127.0.0.1:6380'), + array_fill(10921, 5462, '127.0.0.1:6381') + ); + + $cluster->buildSlotsMap(); + + $this->assertSame($expectedMap, $cluster->getSlotsMap()); + } + + /** + * @group disconnected + */ + public function testReturnsCorrectConnectionUsingSlotID() + { + $connection1 = $this->getMockConnection('tcp://127.0.0.1:6379'); + $connection2 = $this->getMockConnection('tcp://127.0.0.1:6380'); + $connection3 = $this->getMockConnection('tcp://127.0.0.1:6381'); + + $cluster = new RedisCluster(); + $cluster->add($connection1); + $cluster->add($connection2); + $cluster->add($connection3); + + $this->assertSame($connection1, $cluster->getConnectionBySlot(0)); + $this->assertSame($connection2, $cluster->getConnectionBySlot(5461)); + $this->assertSame($connection3, $cluster->getConnectionBySlot(10922)); + + $cluster->setSlots(5461, 7096, '127.0.0.1:6380'); + $this->assertSame($connection2, $cluster->getConnectionBySlot(5461)); + } + + /** + * @group disconnected + */ + public function testReturnsCorrectConnectionUsingCommandInstance() + { + $profile = ServerProfile::getDefault(); + + $connection1 = $this->getMockConnection('tcp://127.0.0.1:6379'); + $connection2 = $this->getMockConnection('tcp://127.0.0.1:6380'); + $connection3 = $this->getMockConnection('tcp://127.0.0.1:6381'); + + $cluster = new RedisCluster(); + $cluster->add($connection1); + $cluster->add($connection2); + $cluster->add($connection3); + + $set = $profile->createCommand('set', array('node:1001', 'foobar')); + $get = $profile->createCommand('get', array('node:1001')); + $this->assertSame($connection1, $cluster->getConnection($set)); + $this->assertSame($connection1, $cluster->getConnection($get)); + + $set = $profile->createCommand('set', array('node:1048', 'foobar')); + $get = $profile->createCommand('get', array('node:1048')); + $this->assertSame($connection2, $cluster->getConnection($set)); + $this->assertSame($connection2, $cluster->getConnection($get)); + + $set = $profile->createCommand('set', array('node:1082', 'foobar')); + $get = $profile->createCommand('get', array('node:1082')); + $this->assertSame($connection3, $cluster->getConnection($set)); + $this->assertSame($connection3, $cluster->getConnection($get)); + } + + /** + * @group disconnected + */ + public function testWritesCommandToCorrectConnection() + { + $command = ServerProfile::getDefault()->createCommand('get', array('node:1001')); + + $connection1 = $this->getMockConnection('tcp://127.0.0.1:6379'); + $connection1->expects($this->once())->method('writeCommand')->with($command); + + $connection2 = $this->getMockConnection('tcp://127.0.0.1:6380'); + $connection2->expects($this->never())->method('writeCommand'); + + $cluster = new RedisCluster(); + $cluster->add($connection1); + $cluster->add($connection2); + + $cluster->writeCommand($command); + } + + /** + * @group disconnected + */ + public function testReadsCommandFromCorrectConnection() + { + $command = ServerProfile::getDefault()->createCommand('get', array('node:1050')); + + $connection1 = $this->getMockConnection('tcp://127.0.0.1:6379'); + $connection1->expects($this->never())->method('readResponse'); + + $connection2 = $this->getMockConnection('tcp://127.0.0.1:6380'); + $connection2->expects($this->once())->method('readResponse')->with($command); + + $cluster = new RedisCluster(); + $cluster->add($connection1); + $cluster->add($connection2); + + $cluster->readResponse($command); + } + + /** + * @group disconnected + */ + public function testDoesNotSupportKeyTags() + { + $profile = ServerProfile::getDefault(); + + $connection1 = $this->getMockConnection('tcp://127.0.0.1:6379'); + $connection2 = $this->getMockConnection('tcp://127.0.0.1:6380'); + + $cluster = new RedisCluster(); + $cluster->add($connection1); + $cluster->add($connection2); + + $set = $profile->createCommand('set', array('{node:1001}:foo', 'foobar')); + $get = $profile->createCommand('get', array('{node:1001}:foo')); + $this->assertSame($connection1, $cluster->getConnection($set)); + $this->assertSame($connection1, $cluster->getConnection($get)); + + $set = $profile->createCommand('set', array('{node:1001}:bar', 'foobar')); + $get = $profile->createCommand('get', array('{node:1001}:bar')); + $this->assertSame($connection2, $cluster->getConnection($set)); + $this->assertSame($connection2, $cluster->getConnection($get)); + } + + /** + * @group disconnected + */ + public function testAskResponseWithConnectionInPool() + { + $askResponse = new ResponseError('ASK 1970 127.0.0.1:6380'); + + $command = ServerProfile::getDefault()->createCommand('get', array('node:1001')); + + $connection1 = $this->getMockConnection('tcp://127.0.0.1:6379'); + $connection1->expects($this->exactly(2)) + ->method('executeCommand') + ->with($command) + ->will($this->onConsecutiveCalls($askResponse, 'foobar')); + + $connection2 = $this->getMockConnection('tcp://127.0.0.1:6380'); + $connection2->expects($this->at(2)) + ->method('executeCommand') + ->with($this->isRedisCommand('ASKING')); + $connection2->expects($this->at(3)) + ->method('executeCommand') + ->with($command) + ->will($this->returnValue('foobar')); + + $factory = $this->getMock('Predis\Connection\ConnectionFactory'); + $factory->expects($this->never())->method('create'); + + $cluster = new RedisCluster($factory); + $cluster->add($connection1); + $cluster->add($connection2); + + $this->assertSame('foobar', $cluster->executeCommand($command)); + $this->assertSame('foobar', $cluster->executeCommand($command)); + $this->assertSame(2, count($cluster)); + } + + /** + * @group disconnected + */ + public function testAskResponseWithConnectionNotInPool() + { + $askResponse = new ResponseError('ASK 1970 127.0.0.1:6381'); + + $command = ServerProfile::getDefault()->createCommand('get', array('node:1001')); + + $connection1 = $this->getMockConnection('tcp://127.0.0.1:6379'); + $connection1->expects($this->exactly(2)) + ->method('executeCommand') + ->with($command) + ->will($this->onConsecutiveCalls($askResponse, 'foobar')); + + $connection2 = $this->getMockConnection('tcp://127.0.0.1:6380'); + $connection2->expects($this->never()) + ->method('executeCommand'); + + $connection3 = $this->getMockConnection('tcp://127.0.0.1:6381'); + $connection3->expects($this->at(0)) + ->method('executeCommand') + ->with($this->isRedisCommand('ASKING')); + $connection3->expects($this->at(1)) + ->method('executeCommand') + ->with($command) + ->will($this->returnValue('foobar')); + + $factory = $this->getMock('Predis\Connection\ConnectionFactory'); + $factory->expects($this->once()) + ->method('create') + ->with(array('host' => '127.0.0.1', 'port' => '6381')) + ->will($this->returnValue($connection3)); + + $cluster = new RedisCluster($factory); + $cluster->add($connection1); + $cluster->add($connection2); + + $this->assertSame('foobar', $cluster->executeCommand($command)); + $this->assertSame('foobar', $cluster->executeCommand($command)); + $this->assertSame(2, count($cluster)); + } + + /** + * @group disconnected + */ + public function testMovedResponseWithConnectionInPool() + { + $movedResponse = new ResponseError('MOVED 1970 127.0.0.1:6380'); + + $command = ServerProfile::getDefault()->createCommand('get', array('node:1001')); + + $connection1 = $this->getMockConnection('tcp://127.0.0.1:6379'); + $connection1->expects($this->exactly(1)) + ->method('executeCommand') + ->with($command) + ->will($this->returnValue($movedResponse)); + + $connection2 = $this->getMockConnection('tcp://127.0.0.1:6380'); + $connection2->expects($this->exactly(2)) + ->method('executeCommand') + ->with($command) + ->will($this->onConsecutiveCalls('foobar', 'foobar')); + + $factory = $this->getMock('Predis\Connection\ConnectionFactory'); + $factory->expects($this->never())->method('create'); + + $cluster = new RedisCluster($factory); + $cluster->add($connection1); + $cluster->add($connection2); + + $this->assertSame('foobar', $cluster->executeCommand($command)); + $this->assertSame('foobar', $cluster->executeCommand($command)); + $this->assertSame(2, count($cluster)); + } + + /** + * @group disconnected + */ + public function testMovedResponseWithConnectionNotInPool() + { + $movedResponse = new ResponseError('MOVED 1970 127.0.0.1:6381'); + + $command = ServerProfile::getDefault()->createCommand('get', array('node:1001')); + + $connection1 = $this->getMockConnection('tcp://127.0.0.1:6379'); + $connection1->expects($this->once()) + ->method('executeCommand') + ->with($command) + ->will($this->returnValue($movedResponse)); + + $connection2 = $this->getMockConnection('tcp://127.0.0.1:6380'); + $connection2->expects($this->never()) + ->method('executeCommand'); + + $connection3 = $this->getMockConnection('tcp://127.0.0.1:6381'); + $connection3->expects($this->exactly(2)) + ->method('executeCommand') + ->with($command) + ->will($this->onConsecutiveCalls('foobar', 'foobar')); + + $factory = $this->getMock('Predis\Connection\ConnectionFactory'); + $factory->expects($this->once()) + ->method('create') + ->with(array('host' => '127.0.0.1', 'port' => '6381')) + ->will($this->returnValue($connection3)); + + $cluster = new RedisCluster($factory); + $cluster->add($connection1); + $cluster->add($connection2); + + $this->assertSame('foobar', $cluster->executeCommand($command)); + $this->assertSame('foobar', $cluster->executeCommand($command)); + $this->assertSame(3, count($cluster)); + } + + /** + * @group disconnected + * @expectedException Predis\NotSupportedException + * @expectedExceptionMessage Cannot use PING with redis-cluster + */ + public function testThrowsExceptionOnNonSupportedCommand() + { + $ping = ServerProfile::getDefault()->createCommand('ping'); + + $cluster = new RedisCluster(); + $cluster->add($this->getMockConnection('tcp://127.0.0.1:6379')); + + $cluster->getConnection($ping); + } + + /** + * @group disconnected + */ + public function testCanBeSerialized() + { + $connection1 = $this->getMockConnection('tcp://127.0.0.1:6379?slots=0-1364'); + $connection2 = $this->getMockConnection('tcp://127.0.0.1:6380?slots=1365-2729'); + $connection3 = $this->getMockConnection('tcp://127.0.0.1:6381?slots=2730-4095'); + + $cluster = new RedisCluster(); + $cluster->add($connection1); + $cluster->add($connection2); + $cluster->add($connection3); + + $cluster->buildSlotsMap(); + + $unserialized = unserialize(serialize($cluster)); + + $this->assertEquals($cluster, $unserialized); + } + + // ******************************************************************** // + // ---- HELPER METHODS ------------------------------------------------ // + // ******************************************************************** // + + /** + * Returns a base mocked connection from Predis\Connection\SingleConnectionInterface. + * + * @param mixed $parameters Optional parameters. + * @return mixed + */ + protected function getMockConnection($parameters = null) + { + $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); + + if ($parameters) { + $parameters = new ConnectionParameters($parameters); + $hash = "{$parameters->host}:{$parameters->port}"; + + $connection->expects($this->any()) + ->method('getParameters') + ->will($this->returnValue($parameters)); + $connection->expects($this->any()) + ->method('__toString') + ->will($this->returnValue($hash)); + } + + return $connection; + } +} diff --git a/vendor/predis/predis/tests/Predis/Connection/StreamConnectionTest.php b/vendor/predis/predis/tests/Predis/Connection/StreamConnectionTest.php new file mode 100755 index 0000000..f4ff2f6 --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Connection/StreamConnectionTest.php @@ -0,0 +1,137 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Connection; + +/** + * + */ +class StreamConnectionTest extends PredisConnectionTestCase +{ + /** + * @group disconnected + */ + public function testConstructorDoesNotOpenConnection() + { + $connection = new StreamConnection($this->getParameters()); + + $this->assertFalse($connection->isConnected()); + } + + /** + * @group disconnected + */ + public function testExposesParameters() + { + $parameters = $this->getParameters(); + $connection = new StreamConnection($parameters); + + $this->assertSame($parameters, $connection->getParameters()); + } + + /** + * @group disconnected + * @expectedException InvalidArgumentException + * @expectedExceptionMessage Invalid scheme: udp + */ + public function testThrowsExceptionOnInvalidScheme() + { + $parameters = $this->getParameters(array('scheme' => 'udp')); + $connection = new StreamConnection($parameters); + } + + /** + * @group disconnected + */ + public function testCanBeSerialized() + { + $parameters = $this->getParameters(array('alias' => 'redis', 'read_write_timeout' => 10)); + $connection = new StreamConnection($parameters); + + $unserialized = unserialize(serialize($connection)); + + $this->assertEquals($connection, $unserialized); + } + + // ******************************************************************** // + // ---- INTEGRATION TESTS --------------------------------------------- // + // ******************************************************************** // + + /** + * @group connected + */ + public function testAcceptsTcpNodelayParameter() + { + if (!version_compare(PHP_VERSION, '5.4.0', '>=')) { + $this->markTestSkipped('Setting TCP_NODELAY on PHP socket streams works on PHP >= 5.4.0'); + } + + $connection = new StreamConnection($this->getParameters(array('tcp_nodelay' => false))); + $connection->connect(); + $this->assertTrue($connection->isConnected()); + + $connection = new StreamConnection($this->getParameters(array('tcp_nodelay' => true))); + $connection->connect(); + $this->assertTrue($connection->isConnected()); + } + + /** + * @group connected + */ + public function testReadsMultibulkRepliesAsIterators() + { + $connection = $this->getConnection($profile, true, array('iterable_multibulk' => true)); + + $connection->executeCommand($profile->createCommand('rpush', array('metavars', 'foo', 'hoge', 'lol'))); + $connection->writeCommand($profile->createCommand('lrange', array('metavars', 0, -1))); + + $this->assertInstanceOf('Predis\Iterator\MultiBulkResponse', $iterator = $connection->read()); + $this->assertSame(array('foo', 'hoge', 'lol'), iterator_to_array($iterator)); + } + + /** + * @group connected + * @expectedException Predis\Protocol\ProtocolException + * @expectedExceptionMessage Unknown prefix: 'P' + */ + public function testThrowsExceptionOnProtocolDesynchronizationErrors() + { + $connection = $this->getConnection($profile); + $stream = $connection->getResource(); + + $connection->writeCommand($profile->createCommand('ping')); + fread($stream, 1); + + $connection->read(); + } + + // ******************************************************************** // + // ---- HELPER METHODS ------------------------------------------------ // + // ******************************************************************** // + + /** + * {@inheritdoc} + */ + protected function getConnection(&$profile = null, $initialize = false, Array $parameters = array()) + { + $parameters = $this->getParameters($parameters); + $profile = $this->getProfile(); + + $connection = new StreamConnection($parameters); + + if ($initialize) { + $connection->pushInitCommand($profile->createCommand('select', array($parameters->database))); + $connection->pushInitCommand($profile->createCommand('flushdb')); + } + + return $connection; + } +} diff --git a/vendor/predis/predis/tests/Predis/Connection/WebdisConnectionTest.php b/vendor/predis/predis/tests/Predis/Connection/WebdisConnectionTest.php new file mode 100755 index 0000000..6eaea14 --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Connection/WebdisConnectionTest.php @@ -0,0 +1,186 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Connection; + +use PredisTestCase; + +/** + * @group ext-curl + * @group ext-phpiredis + * @group realm-connection + * @group realm-webdis + */ +class WebdisConnectionTest extends PredisTestCase +{ + /** + * @group disconnected + */ + public function testIsConnectedAlwaysReturnsTrue() + { + $connection = new WebdisConnection($this->getParameters()); + + $this->assertTrue($connection->isConnected()); + } + + /** + * @group disconnected + * @expectedException Predis\NotSupportedException + * @expectedExceptionMessage The method Predis\Connection\WebdisConnection::writeCommand() is not supported + */ + public function testWritingCommandsIsNotSupported() + { + $connection = new WebdisConnection($this->getParameters()); + $connection->writeCommand($this->getProfile()->createCommand('ping')); + } + + /** + * @group disconnected + * @expectedException Predis\NotSupportedException + * @expectedExceptionMessage The method Predis\Connection\WebdisConnection::readResponse() is not supported + */ + public function testReadingResponsesIsNotSupported() + { + $connection = new WebdisConnection($this->getParameters()); + $connection->readResponse($this->getProfile()->createCommand('ping')); + } + + /** + * @group disconnected + * @expectedException Predis\NotSupportedException + * @expectedExceptionMessage The method Predis\Connection\WebdisConnection::read() is not supported + */ + public function testReadingFromConnectionIsNotSupported() + { + $connection = new WebdisConnection($this->getParameters()); + $connection->read(); + } + + /** + * @group disconnected + * @expectedException Predis\NotSupportedException + * @expectedExceptionMessage The method Predis\Connection\WebdisConnection::pushInitCommand() is not supported + */ + public function testPushingInitCommandsIsNotSupported() + { + $connection = new WebdisConnection($this->getParameters()); + $connection->pushInitCommand($this->getProfile()->createCommand('ping')); + } + + /** + * @group disconnected + * @expectedException Predis\NotSupportedException + * @expectedExceptionMessage Disabled command: SELECT + */ + public function testRejectCommandSelect() + { + $connection = new WebdisConnection($this->getParameters()); + $connection->executeCommand($this->getProfile()->createCommand('select', array(0))); + } + + /** + * @group disconnected + * @expectedException Predis\NotSupportedException + * @expectedExceptionMessage Disabled command: AUTH + */ + public function testRejectCommandAuth() + { + $connection = new WebdisConnection($this->getParameters()); + $connection->executeCommand($this->getProfile()->createCommand('auth', array('foobar'))); + } + + /** + * @group disconnected + */ + public function testCanBeSerialized() + { + $parameters = $this->getParameters(array('alias' => 'webdis')); + $connection = new WebdisConnection($parameters); + + $unserialized = unserialize(serialize($connection)); + + $this->assertInstanceOf('Predis\Connection\WebdisConnection', $unserialized); + $this->assertEquals($parameters, $unserialized->getParameters()); + } + + // ******************************************************************** // + // ---- INTEGRATION TESTS --------------------------------------------- // + // ******************************************************************** // + + /** + * @group connected + */ + public function testExecutesCommandsOnServer() + { + $connection = $this->getConnection($profile); + + $cmdPing = $profile->createCommand('ping'); + $cmdEcho = $profile->createCommand('echo', array('echoed')); + $cmdGet = $profile->createCommand('get', array('foobar')); + $cmdRpush = $profile->createCommand('rpush', array('metavars', 'foo', 'hoge', 'lol')); + $cmdLrange = $profile->createCommand('lrange', array('metavars', 0, -1)); + + $this->assertSame('PONG', $connection->executeCommand($cmdPing)); + $this->assertSame('echoed', $connection->executeCommand($cmdEcho)); + $this->assertNull($connection->executeCommand($cmdGet)); + $this->assertSame(3, $connection->executeCommand($cmdRpush)); + $this->assertSame(array('foo', 'hoge', 'lol'), $connection->executeCommand($cmdLrange)); + } + + /** + * @medium + * @group disconnected + * @group slow + * @expectedException Predis\Connection\ConnectionException + */ + public function testThrowExceptionWhenUnableToConnect() + { + $parameters = $this->getParameters(array('host' => '169.254.10.10')); + $connection = new WebdisConnection($parameters); + $connection->executeCommand($this->getProfile()->createCommand('ping')); + } + + // ******************************************************************** // + // ---- HELPER METHODS ------------------------------------------------ // + // ******************************************************************** // + + /** + * Returns a named array with the default connection parameters and their values. + * + * @return Array Default connection parameters. + */ + protected function getDefaultParametersArray() + { + return array( + 'scheme' => 'http', + 'host' => WEBDIS_SERVER_HOST, + 'port' => WEBDIS_SERVER_PORT, + ); + } + + /** + * Returns a new instance of a connection instance. + * + * @param mixed $profile Redis profile. + * @param array $parameters Additional connection parameters. + * @return WebdisConnection + */ + protected function getConnection(&$profile = null, Array $parameters = array()) + { + $parameters = $this->getParameters($parameters); + $profile = $this->getProfile(); + + $connection = new WebdisConnection($parameters); + $connection->executeCommand($profile->createCommand('flushdb')); + + return $connection; + } +} diff --git a/vendor/predis/predis/tests/Predis/HelpersTest.php b/vendor/predis/predis/tests/Predis/HelpersTest.php new file mode 100755 index 0000000..ac69b7b --- /dev/null +++ b/vendor/predis/predis/tests/Predis/HelpersTest.php @@ -0,0 +1,70 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis; + +use PredisTestCase; + +/** + * + */ +class HelpersTest extends PredisTestCase +{ + /** + * @group disconnected + */ + public function testOnCommunicationException() + { + $this->setExpectedException('Predis\CommunicationException'); + + $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); + $connection->expects($this->once())->method('isConnected')->will($this->returnValue(true)); + $connection->expects($this->once())->method('disconnect'); + + $exception = $this->getMockForAbstractClass('Predis\CommunicationException', array($connection)); + + Helpers::onCommunicationException($exception); + } + + /** + * @group disconnected + */ + public function testFilterArrayArguments() + { + $arguments = array('arg1', 'arg2', 'arg3', 'arg4'); + + $this->assertSame($arguments, Helpers::filterArrayArguments($arguments)); + $this->assertSame($arguments, Helpers::filterArrayArguments(array($arguments))); + + $arguments = array(array(), array()); + $this->assertSame($arguments, Helpers::filterArrayArguments($arguments)); + + $arguments = array(new \stdClass()); + $this->assertSame($arguments, Helpers::filterArrayArguments($arguments)); + } + + /** + * @group disconnected + */ + public function testFilterVariadicValues() + { + $arguments = array('key', 'value1', 'value2', 'value3'); + + $this->assertSame($arguments, Helpers::filterVariadicValues($arguments)); + $this->assertSame($arguments, Helpers::filterVariadicValues(array('key', array('value1', 'value2', 'value3')))); + + $arguments = array(array(), array()); + $this->assertSame($arguments, Helpers::filterArrayArguments($arguments)); + + $arguments = array(new \stdClass()); + $this->assertSame($arguments, Helpers::filterArrayArguments($arguments)); + } +} diff --git a/vendor/predis/predis/tests/Predis/Iterator/MultiBulkResponseSimpleTest.php b/vendor/predis/predis/tests/Predis/Iterator/MultiBulkResponseSimpleTest.php new file mode 100755 index 0000000..5ab5faf --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Iterator/MultiBulkResponseSimpleTest.php @@ -0,0 +1,128 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Iterator; + +use PredisTestCase; +use Predis\Client; + +/** + * @group realm-iterators + */ +class MultiBulkResponseSimpleTest extends PredisTestCase +{ + /** + * @group connected + */ + public function testIterableMultibulk() + { + $client = $this->getClient(); + $client->rpush('metavars', 'foo', 'hoge', 'lol'); + + $this->assertInstanceOf('Iterator', $iterator = $client->lrange('metavars', 0, -1)); + $this->assertInstanceOf('Predis\Iterator\MultiBulkResponseSimple', $iterator); + $this->assertTrue($iterator->valid()); + $this->assertSame(3, $iterator->count()); + + $this->assertSame('foo', $iterator->current()); + $this->assertSame(1, $iterator->next()); + $this->assertTrue($iterator->valid()); + + $this->assertSame('hoge', $iterator->current()); + $this->assertSame(2, $iterator->next()); + $this->assertTrue($iterator->valid()); + + $this->assertSame('lol', $iterator->current()); + $this->assertSame(3, $iterator->next()); + $this->assertFalse($iterator->valid()); + + $this->assertTrue($client->ping()); + } + + /** + * @group connected + */ + public function testIterableMultibulkCanBeWrappedAsTupleIterator() + { + $client = $this->getClient(); + $client->mset('foo', 'bar', 'hoge', 'piyo'); + + $this->assertInstanceOf('Predis\Iterator\MultiBulkResponseSimple', $iterator = $client->mget('foo', 'bar')); + $this->assertInstanceOf('Predis\Iterator\MultiBulkResponseTuple', $iterator->asTuple()); + } + + /** + * @group connected + */ + public function testSyncWithFalseConsumesReplyFromUnderlyingConnection() + { + $client = $this->getClient(); + $client->rpush('metavars', 'foo', 'hoge', 'lol'); + + $iterator = $client->lrange('metavars', 0, -1); + $iterator->sync(false); + + $this->assertTrue($client->isConnected()); + $this->assertTrue($client->ping()); + } + + /** + * @group connected + */ + public function testSyncWithTrueDropsUnderlyingConnection() + { + $client = $this->getClient(); + $client->rpush('metavars', 'foo', 'hoge', 'lol'); + + $iterator = $client->lrange('metavars', 0, -1); + $iterator->sync(true); + + $this->assertFalse($client->isConnected()); + $this->assertTrue($client->ping()); + } + + /** + * @group connected + */ + public function testGarbageCollectorDropsUnderlyingConnection() + { + $client = $this->getClient(); + $client->rpush('metavars', 'foo', 'hoge', 'lol'); + + $iterator = $client->lrange('metavars', 0, -1); + + unset($iterator); + + $this->assertFalse($client->isConnected()); + $this->assertTrue($client->ping()); + } + + // ******************************************************************** // + // ---- HELPER METHODS ------------------------------------------------ // + // ******************************************************************** // + + /** + * Returns a new client instance. + * + * @return Client + */ + protected function getClient() + { + $parameters = $this->getParametersArray(array( + 'iterable_multibulk' => true, + 'read_write_timeout' => 2, + )); + + $client = $this->createClient($parameters); + + return $client; + } +} diff --git a/vendor/predis/predis/tests/Predis/Iterator/MultiBulkResponseTupleTest.php b/vendor/predis/predis/tests/Predis/Iterator/MultiBulkResponseTupleTest.php new file mode 100755 index 0000000..5ac5845 --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Iterator/MultiBulkResponseTupleTest.php @@ -0,0 +1,114 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Iterator; + +use PredisTestCase; +use Predis\Client; + +/** + * @group realm-iterators + */ +class MultiBulkResponseTupleTest extends PredisTestCase +{ + /** + * @group disconnected + * @expectedException RuntimeException + * @expectedExceptionMessage Cannot initialize a tuple iterator with an already initiated iterator + */ + public function testInitiatedMultiBulkIteratorsAreNotValid() + { + $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); + $iterator = new MultiBulkResponseSimple($connection, 2); + $iterator->next(); + + new MultiBulkResponseTuple($iterator); + } + + /** + * @group disconnected + * @expectedException UnexpectedValueException + * @expectedExceptionMessage Invalid reply size for a tuple iterator [3] + */ + public function testMultiBulkWithOddSizesAreInvalid() + { + $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); + $iterator = new MultiBulkResponseSimple($connection, 3); + + new MultiBulkResponseTuple($iterator); + } + + /** + * @group connected + */ + public function testIterableMultibulk() + { + $client = $this->getClient(); + $client->zadd('metavars', 1, 'foo', 2, 'hoge', 3, 'lol'); + + $this->assertInstanceOf('OuterIterator', $iterator = $client->zrange('metavars', 0, -1, 'withscores')->asTuple()); + $this->assertInstanceOf('Predis\Iterator\MultiBulkResponseTuple', $iterator); + $this->assertInstanceOf('Predis\Iterator\MultiBulkResponseSimple', $iterator->getInnerIterator()); + $this->assertTrue($iterator->valid()); + $this->assertSame(3, $iterator->count()); + + $this->assertSame(array('foo', '1'), $iterator->current()); + $this->assertSame(1, $iterator->next()); + $this->assertTrue($iterator->valid()); + + $this->assertSame(array('hoge', '2'), $iterator->current()); + $this->assertSame(2, $iterator->next()); + $this->assertTrue($iterator->valid()); + + $this->assertSame(array('lol', '3'), $iterator->current()); + $this->assertSame(3, $iterator->next()); + $this->assertFalse($iterator->valid()); + + $this->assertTrue($client->ping()); + } + + /** + * @group connected + */ + public function testGarbageCollectorDropsUnderlyingConnection() + { + $client = $this->getClient(); + $client->zadd('metavars', 1, 'foo', 2, 'hoge', 3, 'lol'); + + $iterator = $client->zrange('metavars', 0, -1, 'withscores')->asTuple(); + + unset($iterator); + + $this->assertFalse($client->isConnected()); + $this->assertTrue($client->ping()); + } + + // ******************************************************************** // + // ---- HELPER METHODS ------------------------------------------------ // + // ******************************************************************** // + + /** + * Returns a new client instance. + * + * @return Client + */ + protected function getClient() + { + $parameters = $this->getParametersArray(array( + 'iterable_multibulk' => true, + 'read_write_timeout' => 2, + )); + + $client = $this->createClient($parameters); + + return $client; + } +} diff --git a/vendor/predis/predis/tests/Predis/Monitor/MonitorContextTest.php b/vendor/predis/predis/tests/Predis/Monitor/MonitorContextTest.php new file mode 100755 index 0000000..7be5a6a --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Monitor/MonitorContextTest.php @@ -0,0 +1,196 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Monitor; + +use PredisTestCase; +use Predis\Client; +use Predis\Profile\ServerProfile; + +/** + * @group realm-monitor + */ +class MonitorContextTest extends PredisTestCase +{ + /** + * @group disconnected + * @expectedException Predis\NotSupportedException + * @expectedExceptionMessage The current profile does not support the MONITOR command + */ + public function testMonitorContextRequireMonitorCommand() + { + $profile = $this->getMock('Predis\Profile\ServerProfileInterface'); + $profile->expects($this->once()) + ->method('supportsCommand') + ->with('monitor') + ->will($this->returnValue(false)); + + $client = new Client(null, array('profile' => $profile)); + $monitor = new MonitorContext($client); + } + + /** + * @group disconnected + * @expectedException Predis\NotSupportedException + * @expectedExceptionMessage Cannot initialize a monitor context when using aggregated connections + */ + public function testMonitorContextDoesNotWorkOnClusters() + { + $cluster = $this->getMock('Predis\Connection\ClusterConnectionInterface'); + + $client = new Client($cluster); + $monitor = new MonitorContext($client); + } + + /** + * @group disconnected + */ + public function testConstructorOpensContext() + { + $cmdMonitor = ServerProfile::getDefault()->createCommand('monitor'); + + $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); + + $client = $this->getMock('Predis\Client', array('createCommand', 'executeCommand'), array($connection)); + $client->expects($this->once()) + ->method('createCommand') + ->with('monitor', array()) + ->will($this->returnValue($cmdMonitor)); + $client->expects($this->once()) + ->method('executeCommand') + ->with($cmdMonitor); + + $monitor = new MonitorContext($client); + } + + /** + * @group disconnected + * @todo We should investigate why disconnect is invoked 2 times in this test, + * but the reason is probably that the GC invokes __destruct() on monitor + * thus calling $client->disconnect() a second time at the end of the test. + */ + public function testClosingContextClosesConnection() + { + $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); + + $client = $this->getMock('Predis\Client', array('disconnect'), array($connection)); + $client->expects($this->exactly(2))->method('disconnect'); + + $monitor = new MonitorContext($client); + $monitor->closeContext(); + } + + /** + * @group disconnected + */ + public function testGarbageCollectorRunClosesContext() + { + $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); + + $client = $this->getMock('Predis\Client', array('disconnect'), array($connection)); + $client->expects($this->once())->method('disconnect'); + + $monitor = new MonitorContext($client); + unset($monitor); + } + + /** + * @group disconnected + */ + public function testReadsMessageFromConnectionToRedis24() + { + $message = '1323367530.939137 (db 15) "MONITOR"'; + + $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); + $connection->expects($this->once()) + ->method('read') + ->will($this->returnValue($message)); + + $client = new Client($connection); + $monitor = new MonitorContext($client); + + $payload = $monitor->current(); + $this->assertSame(1323367530, (int) $payload->timestamp); + $this->assertSame(15, $payload->database); + $this->assertNull($payload->client); + $this->assertSame('MONITOR', $payload->command); + $this->assertNull($payload->arguments); + } + + /** + * @group disconnected + */ + public function testReadsMessageFromConnectionToRedis26() + { + $message = '1323367530.939137 [15 127.0.0.1:37265] "MONITOR"'; + + $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); + $connection->expects($this->once()) + ->method('read') + ->will($this->returnValue($message)); + + $client = new Client($connection); + $monitor = new MonitorContext($client); + + $payload = $monitor->current(); + $this->assertSame(1323367530, (int) $payload->timestamp); + $this->assertSame(15, $payload->database); + $this->assertSame('127.0.0.1:37265', $payload->client); + $this->assertSame('MONITOR', $payload->command); + $this->assertNull($payload->arguments); + } + + // ******************************************************************** // + // ---- INTEGRATION TESTS --------------------------------------------- // + // ******************************************************************** // + + /** + * @group connected + */ + public function testMonitorAgainstRedisServer() + { + $parameters = array( + 'host' => REDIS_SERVER_HOST, + 'port' => REDIS_SERVER_PORT, + 'database' => REDIS_SERVER_DBNUM, + // Prevents suite from handing on broken test + 'read_write_timeout' => 2, + ); + + $options = array('profile' => REDIS_SERVER_VERSION); + $echoed = array(); + + $producer = new Client($parameters, $options); + $producer->connect(); + + $consumer = new Client($parameters, $options); + $consumer->connect(); + + $monitor = new MonitorContext($consumer); + + $producer->echo('message1'); + $producer->echo('message2'); + $producer->echo('QUIT'); + + foreach ($monitor as $message) { + if ($message->command == 'ECHO') { + $echoed[] = $arguments = trim($message->arguments, '"'); + if ($arguments == 'QUIT') { + $monitor->closeContext(); + } + } + } + + $this->assertSame(array('message1', 'message2', 'QUIT'), $echoed); + $this->assertFalse($monitor->valid()); + $this->assertTrue($consumer->ping()); + } +} diff --git a/vendor/predis/predis/tests/Predis/Option/AbstractOptionTest.php b/vendor/predis/predis/tests/Predis/Option/AbstractOptionTest.php new file mode 100755 index 0000000..17f6acf --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Option/AbstractOptionTest.php @@ -0,0 +1,79 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Option; + +use PredisTestCase; + +/** + * + */ +class AbstractOptionTest extends PredisTestCase +{ + /** + * @group disconnected + */ + public function testValidationReturnsTheSameObject() + { + $value = new \stdClass(); + $options = $this->getMock('Predis\Option\ClientOptionsInterface'); + $option = $this->getMockForAbstractClass('Predis\Option\AbstractOption'); + + $this->assertSame($value, $option->filter($options, $value)); + } + + /** + * @group disconnected + */ + public function testDefaultReturnsNull() + { + $options = $this->getMock('Predis\Option\ClientOptionsInterface'); + $option = $this->getMockForAbstractClass('Predis\Option\AbstractOption'); + + $this->assertNull($option->getDefault($options)); + } + + /** + * @group disconnected + */ + public function testInvokePerformsValidationWhenValueIsSet() + { + $value = new \stdClass(); + $options = $this->getMock('Predis\Option\ClientOptionsInterface'); + + $option = $this->getMock('Predis\Option\AbstractOption', array('filter', 'getDefault')); + $option->expects($this->once()) + ->method('filter') + ->with($options, $value) + ->will($this->returnValue($value)); + $option->expects($this->never())->method('getDefault'); + + $this->assertSame($value, $option($options, $value)); + } + + /** + * @group disconnected + */ + public function testInvokeReturnsDefaultWhenValueIsNotSet() + { + $expected = new \stdClass(); + $options = $this->getMock('Predis\Option\ClientOptionsInterface'); + + $option = $this->getMock('Predis\Option\AbstractOption', array('filter', 'getDefault')); + $option->expects($this->never())->method('filter'); + $option->expects($this->once()) + ->method('getDefault') + ->with($options) + ->will($this->returnValue($expected)); + + $this->assertSame($expected, $option($options, null)); + } +} diff --git a/vendor/predis/predis/tests/Predis/Option/ClientClusterTest.php b/vendor/predis/predis/tests/Predis/Option/ClientClusterTest.php new file mode 100755 index 0000000..ec8e636 --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Option/ClientClusterTest.php @@ -0,0 +1,127 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Option; + +use PredisTestCase; + +/** + * + */ +class ClientClusterTest extends PredisTestCase +{ + /** + * @group disconnected + */ + public function testValidationAcceptsFQNStringAsInitializer() + { + $clusterClass = get_class($this->getMock('Predis\Connection\ClusterConnectionInterface')); + + $options = $this->getMock('Predis\Option\ClientOptionsInterface'); + $option = new ClientCluster(); + + $cluster = $option->filter($options, $clusterClass); + + $this->assertInstanceOf('Predis\Connection\ClusterConnectionInterface', $cluster); + } + + /** + * @group disconnected + */ + public function testValidationRecognizesCertainPredefinedShortNames() + { + $options = $this->getMock('Predis\Option\ClientOptionsInterface'); + $option = new ClientCluster(); + + $cluster = $option->filter($options, 'predis'); + + $this->assertInstanceOf('Predis\Connection\ClusterConnectionInterface', $cluster); + } + + /** + * @group disconnected + */ + public function testValidationAcceptsCallableObjectAsInitializers() + { + $value = $this->getMock('Predis\Connection\ClusterConnectionInterface'); + + $options = $this->getMock('Predis\Option\ClientOptionsInterface'); + $option = new ClientCluster(); + + $initializer = $this->getMock('stdClass', array('__invoke')); + $initializer->expects($this->once()) + ->method('__invoke') + ->with($this->isInstanceOf('Predis\Option\ClientOptionsInterface'), $option) + ->will($this->returnValue($value)); + + $cluster = $option->filter($options, $initializer, $option); + + $this->assertInstanceOf('Predis\Connection\ClusterConnectionInterface', $cluster); + $this->assertSame($value, $cluster); + } + + /** + * @group disconnected + */ + public function testValidationThrowsExceptionOnInvalidClassTypes() + { + $this->setExpectedException('InvalidArgumentException'); + + $connectionClass = get_class($this->getMock('Predis\Connection\SingleConnectionInterface')); + $options = $this->getMock('Predis\Option\ClientOptionsInterface'); + $option = new ClientCluster(); + + $option->filter($options, $connectionClass); + } + + /** + * @group disconnected + */ + public function testValidationThrowsExceptionOnInvalidShortName() + { + $this->setExpectedException('InvalidArgumentException'); + + $options = $this->getMock('Predis\Option\ClientOptionsInterface'); + $option = new ClientCluster(); + + $option->filter($options, 'unknown'); + } + + /** + * @group disconnected + */ + public function testValidationThrowsExceptionOnInvalidObjectReturnedByCallback() + { + $this->setExpectedException('InvalidArgumentException'); + + $value = function ($options) { + return new \stdClass(); + }; + + $options = $this->getMock('Predis\Option\ClientOptionsInterface'); + $option = new ClientCluster(); + + $option->filter($options, $value); + } + + /** + * @group disconnected + */ + public function testValidationThrowsExceptionOnInvalidArguments() + { + $this->setExpectedException('InvalidArgumentException'); + + $options = $this->getMock('Predis\Option\ClientOptionsInterface'); + $option = new ClientCluster(); + + $option->filter($options, new \stdClass()); + } +} diff --git a/vendor/predis/predis/tests/Predis/Option/ClientConnectionFactoryTest.php b/vendor/predis/predis/tests/Predis/Option/ClientConnectionFactoryTest.php new file mode 100755 index 0000000..c47b2c9 --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Option/ClientConnectionFactoryTest.php @@ -0,0 +1,137 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Option; + +use PredisTestCase; +use Predis\Connection\ConnectionFactory; + +/** + * + */ +class ClientConnectionFactoryTest extends PredisTestCase +{ + /** + * @group disconnected + */ + public function testValidationReturnsDefaultFactoryWithSchemeDefinitionsArray() + { + $connectionClass = get_class($this->getMock('Predis\Connection\SingleConnectionInterface')); + $value = array('tcp' => $connectionClass, 'redis' => $connectionClass); + + $options = $this->getMock('Predis\Option\ClientOptionsInterface'); + + $default = $this->getMock('Predis\Connection\ConnectionFactoryInterface'); + $default->expects($this->exactly(2)) + ->method('define') + ->with($this->matchesRegularExpression('/^tcp|redis$/'), $connectionClass); + + $option = $this->getMock('Predis\Option\ClientConnectionFactory', array('getDefault')); + $option->expects($this->once()) + ->method('getDefault') + ->with($options) + ->will($this->returnValue($default)); + + $factory = $option->filter($options, $value); + + $this->assertInstanceOf('Predis\Connection\ConnectionFactoryInterface', $factory); + $this->assertSame($default, $factory); + } + + /** + * @group disconnected + */ + public function testValidationAcceptsFactoryInstancesAsValue() + { + $value = $this->getMock('Predis\Connection\ConnectionFactoryInterface'); + $options = $this->getMock('Predis\Option\ClientOptionsInterface'); + + $option = $this->getMock('Predis\Option\ClientConnectionFactory', array('getDefault')); + $option->expects($this->never())->method('getDefault'); + + $this->assertSame($value, $option->filter($options, $value)); + } + + /** + * @group disconnected + */ + public function testValidationAcceptsCallableObjectAsInitializers() + { + $value = $this->getMock('Predis\Connection\ConnectionFactoryInterface'); + $options = $this->getMock('Predis\Option\ClientOptionsInterface'); + $option = new ClientConnectionFactory(); + + $initializer = $this->getMock('stdClass', array('__invoke')); + $initializer->expects($this->once()) + ->method('__invoke') + ->with($this->isInstanceOf('Predis\Option\ClientOptionsInterface'), $option) + ->will($this->returnValue($value)); + + $cluster = $option->filter($options, $initializer, $option); + + $this->assertInstanceOf('Predis\Connection\ConnectionFactoryInterface', $cluster); + $this->assertSame($value, $cluster); + } + + /** + * @group disconnected + */ + public function testValidationAcceptsStringAsValue() + { + $factory = 'Predis\Connection\ConnectionFactory'; + $options = $this->getMock('Predis\Option\ClientOptionsInterface'); + + $option = $this->getMock('Predis\Option\ClientConnectionFactory', array('getDefault')); + $option->expects($this->never())->method('getDefault'); + + $this->assertInstanceOf($factory, $option->filter($options, $factory)); + } + + /** + * @group disconnected + */ + public function testValidationThrowsExceptionOnWrongInvalidArguments() + { + $this->setExpectedException('InvalidArgumentException'); + + $options = $this->getMock('Predis\Option\ClientOptionsInterface'); + $option = new ClientConnectionFactory(); + + $option->filter($options, new \stdClass()); + } + + /** + * @group disconnected + */ + public function testInvokeReturnsSpecifiedFactoryOrDefault() + { + $value = $this->getMock('Predis\Connection\ConnectionFactoryInterface'); + $options = $this->getMock('Predis\Option\ClientOptionsInterface'); + + $option = $this->getMock('Predis\Option\ClientConnectionFactory', array('filter', 'getDefault')); + $option->expects($this->once()) + ->method('filter') + ->with($options, $value) + ->will($this->returnValue($value)); + $option->expects($this->never())->method('getDefault'); + + $this->assertInstanceOf('Predis\Connection\ConnectionFactoryInterface', $option($options, $value)); + + $option = $this->getMock('Predis\Option\ClientConnectionFactory', array('filter', 'getDefault')); + $option->expects($this->never())->method('filter'); + $option->expects($this->once()) + ->method('getDefault') + ->with($options) + ->will($this->returnValue($value)); + + $this->assertInstanceOf('Predis\Connection\ConnectionFactoryInterface', $option($options, null)); + } +} diff --git a/vendor/predis/predis/tests/Predis/Option/ClientExceptionsTest.php b/vendor/predis/predis/tests/Predis/Option/ClientExceptionsTest.php new file mode 100755 index 0000000..ec414bd --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Option/ClientExceptionsTest.php @@ -0,0 +1,31 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Option; + +use PredisTestCase; + +/** + * + */ +class ClientExceptionsTest extends PredisTestCase +{ + /** + * @group disconnected + */ + public function testDefaultReturnsTrue() + { + $options = $this->getMock('Predis\Option\ClientOptionsInterface'); + $option = new ClientExceptions(); + + $this->assertTrue($option->getDefault($options)); + } +} diff --git a/vendor/predis/predis/tests/Predis/Option/ClientOptionsTest.php b/vendor/predis/predis/tests/Predis/Option/ClientOptionsTest.php new file mode 100755 index 0000000..f74c103 --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Option/ClientOptionsTest.php @@ -0,0 +1,128 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Option; + +use PredisTestCase; + +/** + * @todo We should test the inner work performed by this class + * using mock objects, but it is quite hard to to that. + */ +class ClientOptionsTest extends PredisTestCase +{ + /** + * @group disconnected + */ + public function testConstructorWithoutArguments() + { + $options = new ClientOptions(); + + $this->assertInstanceOf('Predis\Connection\ConnectionFactoryInterface', $options->connections); + $this->assertInstanceOf('Predis\Profile\ServerProfileInterface', $options->profile); + $this->assertInstanceOf('Predis\Connection\ClusterConnectionInterface', $options->cluster); + $this->assertNull($options->prefix); + } + + /** + * @group disconnected + */ + public function testConstructorWithArrayArgument() + { + $options = new ClientOptions(array( + 'cluster' => 'Predis\Connection\PredisCluster', + 'connections' => 'Predis\Connection\ConnectionFactory', + 'prefix' => 'prefix:', + 'profile' => '2.0', + 'exceptions' => false, + )); + + $this->assertInstanceOf('Predis\Connection\ConnectionFactoryInterface', $options->connections); + $this->assertInstanceOf('Predis\Profile\ServerProfileInterface', $options->profile); + $this->assertInstanceOf('Predis\Connection\ClusterConnectionInterface', $options->cluster); + $this->assertInstanceOf('Predis\Command\Processor\CommandProcessorInterface', $options->prefix); + $this->assertInternalType('bool', $options->exceptions); + } + + /** + * @group disconnected + */ + public function testHandlesCustomOptionsWithoutHandlers() + { + $options = new ClientOptions(array( + 'custom' => 'foobar', + )); + + $this->assertSame('foobar', $options->custom); + } + + /** + * @group disconnected + */ + public function testIsSetReturnsIfOptionHasBeenSetByUser() + { + $options = new ClientOptions(array( + 'prefix' => 'prefix:', + 'custom' => 'foobar', + )); + + $this->assertTrue(isset($options->prefix)); + $this->assertTrue(isset($options->custom)); + $this->assertFalse(isset($options->profile)); + } + + /** + * @group disconnected + */ + public function testGetDefaultUsingOptionName() + { + $options = new ClientOptions(); + + $this->assertInstanceOf('Predis\Connection\PredisCluster', $options->getDefault('cluster')); + } + + /** + * @group disconnected + */ + public function testGetDefaultUsingUnhandledOptionName() + { + $options = new ClientOptions(); + $option = new ClientCluster(); + + $this->assertNull($options->getDefault('foo')); + } + + /** + * @group disconnected + */ + public function testGetDefaultUsingOptionInstance() + { + $options = new ClientOptions(); + $option = new ClientCluster(); + + $this->assertInstanceOf('Predis\Connection\PredisCluster', $options->getDefault($option)); + } + + /** + * @group disconnected + */ + public function testGetDefaultUsingUnhandledOptionInstance() + { + $options = new ClientOptions(); + $option = new CustomOption(array( + 'default' => function ($options) { + return 'foo'; + }, + )); + + $this->assertSame('foo', $options->getDefault($option)); + } +} diff --git a/vendor/predis/predis/tests/Predis/Option/ClientPrefixTest.php b/vendor/predis/predis/tests/Predis/Option/ClientPrefixTest.php new file mode 100755 index 0000000..08763f6 --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Option/ClientPrefixTest.php @@ -0,0 +1,59 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Option; + +use PredisTestCase; + +/** + * + */ +class ClientPrefixTest extends PredisTestCase +{ + /** + * @group disconnected + */ + public function testValidationReturnsCommandProcessor() + { + $value = 'prefix:'; + $options = $this->getMock('Predis\Option\ClientOptionsInterface'); + $option = new ClientPrefix(); + + $return = $option->filter($options, $value); + + $this->assertInstanceOf('Predis\Command\Processor\CommandProcessorInterface', $return); + $this->assertInstanceOf('Predis\Command\Processor\KeyPrefixProcessor', $return); + $this->assertEquals($value, $return->getPrefix()); + } + + /** + * @group disconnected + */ + public function testDefaultReturnsNull() + { + $options = $this->getMock('Predis\Option\ClientOptionsInterface'); + $option = new ClientPrefix(); + + $this->assertNull($option->getDefault($options)); + } + + /** + * @group disconnected + */ + public function testInvokeReturnsCommandProcessorOrNull() + { + $options = $this->getMock('Predis\Option\ClientOptionsInterface'); + $option = new ClientPrefix(); + + $this->assertInstanceOf('Predis\Command\Processor\CommandProcessorInterface', $option($options, 'prefix:')); + $this->assertNull($option($options, null)); + } +} diff --git a/vendor/predis/predis/tests/Predis/Option/ClientProfileTest.php b/vendor/predis/predis/tests/Predis/Option/ClientProfileTest.php new file mode 100755 index 0000000..5136234 --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Option/ClientProfileTest.php @@ -0,0 +1,210 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Option; + +use PredisTestCase; +use Predis\Command\Processor\KeyPrefixProcessor; +use Predis\Profile\ServerProfile; + +/** + * + */ +class ClientProfileTest extends PredisTestCase +{ + /** + * @group disconnected + */ + public function testValidationReturnsServerProfileWithStringValue() + { + $options = $this->getMock('Predis\Option\ClientOptionsInterface'); + $option = new ClientProfile(); + + $profile = $option->filter($options, '2.0'); + + $this->assertInstanceOf('Predis\Profile\ServerProfileInterface', $profile); + $this->assertEquals('2.0', $profile->getVersion()); + $this->assertNull($profile->getProcessor()); + } + + /** + * @group disconnected + */ + public function testValidationAcceptsProfileInstancesAsValue() + { + $value = ServerProfile::get('2.0'); + $options = $this->getMock('Predis\Option\ClientOptionsInterface'); + $option = new ClientProfile(); + + $profile = $option->filter($options, $value); + + $this->assertInstanceOf('Predis\Profile\ServerProfileInterface', $profile); + $this->assertEquals('2.0', $profile->getVersion()); + $this->assertNull($profile->getProcessor()); + } + + /** + * @group disconnected + */ + public function testValidationAcceptsCallableObjectAsInitializers() + { + $value = $this->getMock('Predis\Profile\ServerProfileInterface'); + + $options = $this->getMock('Predis\Option\ClientOptionsInterface'); + $option = new ClientProfile(); + + $initializer = $this->getMock('stdClass', array('__invoke')); + $initializer->expects($this->once()) + ->method('__invoke') + ->with($this->isInstanceOf('Predis\Option\ClientOptionsInterface'), $option) + ->will($this->returnValue($value)); + + $profile = $option->filter($options, $initializer, $option); + + $this->assertInstanceOf('Predis\Profile\ServerProfileInterface', $profile); + $this->assertSame($value, $profile); + } + + /** + * @group disconnected + */ + public function testValidationThrowsExceptionOnWrongInvalidArguments() + { + $this->setExpectedException('InvalidArgumentException'); + + $options = $this->getMock('Predis\Option\ClientOptionsInterface'); + $option = new ClientProfile(); + + $option->filter($options, new \stdClass()); + } + + /** + * @group disconnected + */ + public function testDefaultReturnsDefaultServerProfile() + { + $options = $this->getMock('Predis\Option\ClientOptionsInterface'); + $option = new ClientProfile(); + + $profile = $option->getDefault($options); + + $this->assertInstanceOf('Predis\Profile\ServerProfileInterface', $profile); + $this->assertInstanceOf(get_class(ServerProfile::getDefault()), $profile); + $this->assertNull($profile->getProcessor()); + } + + /** + * @group disconnected + */ + public function testInvokeReturnsSpecifiedServerProfileOrDefault() + { + $options = $this->getMock('Predis\Option\ClientOptionsInterface'); + $option = new ClientProfile(); + + $profile = $option($options, '2.0'); + + $this->assertInstanceOf('Predis\Profile\ServerProfileInterface', $profile); + $this->assertEquals('2.0', $profile->getVersion()); + $this->assertNull($profile->getProcessor()); + + $profile = $option($options, null); + + $this->assertInstanceOf('Predis\Profile\ServerProfileInterface', $profile); + $this->assertInstanceOf(get_class(ServerProfile::getDefault()), $profile); + $this->assertNull($profile->getProcessor()); + } + + /** + * @group disconnected + * @todo Can't we when trap __isset when mocking an interface? Doesn't seem to work here. + */ + public function testFilterSetsPrefixProcessorFromClientOptions() + { + $options = $this->getMock('Predis\Option\ClientOptions', array('__isset', '__get')); + $options->expects($this->once()) + ->method('__isset') + ->with('prefix') + ->will($this->returnValue(true)); + $options->expects($this->once()) + ->method('__get') + ->with('prefix') + ->will($this->returnValue(new KeyPrefixProcessor('prefix:'))); + + $option = new ClientProfile(); + + $profile = $option->filter($options, '2.0'); + + $this->assertInstanceOf('Predis\Profile\ServerProfileInterface', $profile); + $this->assertEquals('2.0', $profile->getVersion()); + $this->assertInstanceOf('Predis\Command\Processor\KeyPrefixProcessor', $profile->getProcessor()); + $this->assertEquals('prefix:', $profile->getProcessor()->getPrefix()); + } + + /** + * @group disconnected + * @todo Can't we when trap __isset when mocking an interface? Doesn't seem to work here. + */ + public function testDefaultSetsPrefixProcessorFromClientOptions() + { + $options = $this->getMock('Predis\Option\ClientOptions', array('__isset', '__get')); + $options->expects($this->once()) + ->method('__isset') + ->with('prefix') + ->will($this->returnValue(true)); + $options->expects($this->once()) + ->method('__get') + ->with('prefix') + ->will($this->returnValue(new KeyPrefixProcessor('prefix:'))); + + $option = new ClientProfile(); + + $profile = $option->getDefault($options); + + $this->assertInstanceOf('Predis\Profile\ServerProfileInterface', $profile); + $this->assertInstanceOf(get_class(ServerProfile::getDefault()), $profile); + $this->assertInstanceOf('Predis\Command\Processor\KeyPrefixProcessor', $profile->getProcessor()); + $this->assertEquals('prefix:', $profile->getProcessor()->getPrefix()); + } + + /** + * @group disconnected + */ + public function testValidationDoesNotSetPrefixProcessorWhenValueIsProfileInstance() + { + $options = $this->getMock('Predis\Option\ClientOptions', array('__isset', '__get')); + $options->expects($this->never())->method('__isset'); + $options->expects($this->never())->method('__get'); + + $option = new ClientProfile(); + + $profile = $option->filter($options, ServerProfile::getDefault()); + + $this->assertInstanceOf('Predis\Profile\ServerProfileInterface', $profile); + $this->assertNull($profile->getProcessor()); + } + + /** + * @group disconnected + * @expectedException InvalidArgumentException + * @expectedExceptionMessage Invalid value for the profile option + */ + public function testValidationThrowsExceptionOnInvalidObjectReturnedByCallback() + { + $value = function ($options) { + return new \stdClass(); + }; + + $options = $this->getMock('Predis\Option\ClientOptionsInterface'); + $option = new ClientProfile(); + + $option->filter($options, $value); + } +} diff --git a/vendor/predis/predis/tests/Predis/Option/ClientReplicationTest.php b/vendor/predis/predis/tests/Predis/Option/ClientReplicationTest.php new file mode 100755 index 0000000..ba93abd --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Option/ClientReplicationTest.php @@ -0,0 +1,101 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Option; + +use PredisTestCase; + +/** + * + */ +class ClientReplicationTest extends PredisTestCase +{ + /** + * @group disconnected + */ + public function testValidationAcceptsFQNStringAsInitializer() + { + $replicationClass = get_class($this->getMock('Predis\Connection\ReplicationConnectionInterface')); + + $options = $this->getMock('Predis\Option\ClientOptionsInterface'); + $option = new ClientReplication(); + + $replication = $option->filter($options, $replicationClass); + + $this->assertInstanceOf('Predis\Connection\ReplicationConnectionInterface', $replication); + } + + /** + * @group disconnected + */ + public function testValidationAcceptsBooleanValue() + { + $options = $this->getMock('Predis\Option\ClientOptionsInterface'); + $option = new ClientReplication(); + + $replication = $option->filter($options, true); + $this->assertInstanceOf('Predis\Connection\ReplicationConnectionInterface', $replication); + + $replication = $option->filter($options, false); + $this->assertNull($replication); + } + + /** + * @group disconnected + */ + public function testValidationAcceptsCallableObjectAsInitializers() + { + $value = $this->getMock('Predis\Connection\ReplicationConnectionInterface'); + + $options = $this->getMock('Predis\Option\ClientOptionsInterface'); + $option = new ClientReplication(); + + $initializer = $this->getMock('stdClass', array('__invoke')); + $initializer->expects($this->once()) + ->method('__invoke') + ->with($this->isInstanceOf('Predis\Option\ClientOptionsInterface'), $option) + ->will($this->returnValue($value)); + + $replication = $option->filter($options, $initializer, $option); + + $this->assertInstanceOf('Predis\Connection\ReplicationConnectionInterface', $replication); + $this->assertSame($value, $replication); + } + + /** + * @group disconnected + * @expectedException InvalidArgumentException + */ + public function testValidationThrowsExceptionOnInvalidObjectReturnedByCallback() + { + $value = function ($options) { + return new \stdClass(); + }; + + $options = $this->getMock('Predis\Option\ClientOptionsInterface'); + $option = new ClientReplication(); + + $option->filter($options, $value); + } + + /** + * @group disconnected + * @expectedException InvalidArgumentException + */ + public function testValidationThrowsExceptionOnInvalidClassTypes() + { + $connectionClass = get_class($this->getMock('Predis\Connection\SingleConnectionInterface')); + $options = $this->getMock('Predis\Option\ClientOptionsInterface'); + $option = new ClientReplication(); + + $option->filter($options, $connectionClass); + } +} diff --git a/vendor/predis/predis/tests/Predis/Option/CustomOptionTest.php b/vendor/predis/predis/tests/Predis/Option/CustomOptionTest.php new file mode 100755 index 0000000..13f70e3 --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Option/CustomOptionTest.php @@ -0,0 +1,114 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Option; + +use PredisTestCase; + +/** + * + */ +class CustomOptionTest extends PredisTestCase +{ + /** + * @group disconnected + * @expectedException InvalidArgumentException + */ + public function testConstructorAcceptsOnlyCallablesForFilter() + { + $option = new CustomOption(array('filter' => new \stdClass())); + } + + /** + * @group disconnected + * @expectedException InvalidArgumentException + */ + public function testConstructorAcceptsOnlyCallablesForDefault() + { + $option = new CustomOption(array('default' => new \stdClass())); + } + + /** + * @group disconnected + */ + public function testConstructorIgnoresUnrecognizedParameters() + { + $option = new CustomOption(array('unknown' => new \stdClass())); + + $this->assertNotNull($option); + } + + /** + * @group disconnected + */ + public function testFilterWithoutCallbackReturnsValue() + { + $options = $this->getMock('Predis\Option\ClientOptionsInterface'); + $option = new CustomOption(); + + $this->assertEquals('test', $option->filter($options, 'test')); + } + + /** + * @group disconnected + */ + public function testDefaultWithoutCallbackReturnsNull() + { + $options = $this->getMock('Predis\Option\ClientOptionsInterface'); + $option = new CustomOption(); + + $this->assertNull($option->getDefault($options)); + } + + /** + * @group disconnected + */ + public function testInvokeCallsFilterCallback() + { + $value = 'test'; + + $options = $this->getMock('Predis\Option\ClientOptionsInterface'); + + $filter = $this->getMock('stdClass', array('__invoke')); + $filter->expects($this->once()) + ->method('__invoke') + ->with($this->isInstanceOf('Predis\Option\ClientOptionsInterface'), $value) + ->will($this->returnValue(true)); + + $default = $this->getMock('stdClass', array('__invoke')); + $default->expects($this->never())->method('__invoke'); + + $option = new CustomOption(array('filter' => $filter, 'default' => $default)); + + $this->assertTrue($option($options, $value)); + } + + /** + * @group disconnected + */ + public function testInvokeCallsDefaultCallback() + { + $options = $this->getMock('Predis\Option\ClientOptionsInterface'); + + $filter = $this->getMock('stdClass', array('__invoke')); + $filter->expects($this->never())->method('__invoke'); + + $default = $this->getMock('stdClass', array('__invoke')); + $default->expects($this->once()) + ->method('__invoke') + ->with($this->isInstanceOf('Predis\Option\ClientOptionsInterface')) + ->will($this->returnValue(true)); + + $option = new CustomOption(array('filter' => $filter, 'default' => $default)); + + $this->assertTrue($option($options, null)); + } +} diff --git a/vendor/predis/predis/tests/Predis/Pipeline/FireAndForgetExecutorTest.php b/vendor/predis/predis/tests/Predis/Pipeline/FireAndForgetExecutorTest.php new file mode 100755 index 0000000..709499a --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Pipeline/FireAndForgetExecutorTest.php @@ -0,0 +1,86 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Pipeline; + +use SplQueue; +use PredisTestCase; +use Predis\Profile\ServerProfile; + +/** + * + */ +class FireAndForgetExecutorTest extends PredisTestCase +{ + /** + * @group disconnected + */ + public function testExecutorWithSingleConnection() + { + $executor = new FireAndForgetExecutor(); + $pipeline = $this->getCommandsQueue(); + + $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); + $connection->expects($this->exactly(3)) + ->method('writeCommand'); + $connection->expects($this->never()) + ->method('readResponse'); + + $replies = $executor->execute($connection, $pipeline); + + $this->assertTrue($pipeline->isEmpty()); + $this->assertEmpty($replies); + } + + /** + * @group disconnected + */ + public function testExecutorWithReplicationConnection() + { + $executor = new FireAndForgetExecutor(); + $pipeline = $this->getCommandsQueue(); + + $connection = $this->getMock('Predis\Connection\ReplicationConnectionInterface'); + $connection->expects($this->once()) + ->method('switchTo') + ->with('master'); + $connection->expects($this->exactly(3)) + ->method('writeCommand'); + $connection->expects($this->never()) + ->method('readResponse'); + + $replies = $executor->execute($connection, $pipeline); + + $this->assertTrue($pipeline->isEmpty()); + $this->assertEmpty($replies); + } + + // ******************************************************************** // + // ---- HELPER METHODS ------------------------------------------------ // + // ******************************************************************** // + + /** + * Returns a list of queued command instances. + * + * @return SplQueue + */ + protected function getCommandsQueue() + { + $profile = ServerProfile::getDevelopment(); + + $pipeline = new SplQueue(); + $pipeline->enqueue($profile->createCommand('ping')); + $pipeline->enqueue($profile->createCommand('ping')); + $pipeline->enqueue($profile->createCommand('ping')); + + return $pipeline; + } +} diff --git a/vendor/predis/predis/tests/Predis/Pipeline/MultiExecExecutorTest.php b/vendor/predis/predis/tests/Predis/Pipeline/MultiExecExecutorTest.php new file mode 100755 index 0000000..02baddb --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Pipeline/MultiExecExecutorTest.php @@ -0,0 +1,187 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Pipeline; + +use ArrayIterator; +use SplQueue; +use PredisTestCase; +use Predis\ResponseError; +use Predis\ResponseObjectInterface; +use Predis\ResponseQueued; +use Predis\Profile\ServerProfile; + +/** + * + */ +class ResponseIteratorStub extends ArrayIterator implements ResponseObjectInterface +{ +} + +/** + * + */ +class MultiExecExecutorTest extends PredisTestCase +{ + /** + * @group disconnected + */ + public function testExecutorWithSingleConnection() + { + $executor = new MultiExecExecutor(); + $pipeline = $this->getCommandsQueue(); + $queued = new ResponseQueued(); + + $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); + $connection->expects($this->exactly(2)) + ->method('executeCommand') + ->will($this->onConsecutiveCalls(true, array('PONG', 'PONG', 'PONG'))); + $connection->expects($this->exactly(3)) + ->method('writeCommand'); + $connection->expects($this->at(3)) + ->method('readResponse') + ->will($this->onConsecutiveCalls($queued, $queued, $queued)); + + $replies = $executor->execute($connection, $pipeline); + + $this->assertTrue($pipeline->isEmpty()); + $this->assertSame(array(true, true, true), $replies); + } + + /** + * @group disconnected + */ + public function testExecutorWithSingleConnectionReturningIterator() + { + $executor = new MultiExecExecutor(); + $pipeline = $this->getCommandsQueue(); + $queued = new ResponseQueued(); + $execResponse = new ResponseIteratorStub(array('PONG', 'PONG', 'PONG')); + + $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); + $connection->expects($this->exactly(2)) + ->method('executeCommand') + ->will($this->onConsecutiveCalls(true, $execResponse)); + $connection->expects($this->exactly(3)) + ->method('writeCommand'); + $connection->expects($this->at(3)) + ->method('readResponse') + ->will($this->onConsecutiveCalls($queued, $queued, $queued)); + + $replies = $executor->execute($connection, $pipeline); + + $this->assertTrue($pipeline->isEmpty()); + $this->assertSame(array(true, true, true), $replies); + } + + /** + * @group disconnected + * @expectedException Predis\ClientException + * @expectedExceptionMessage The underlying transaction has been aborted by the server + */ + public function testExecutorWithAbortedTransaction() + { + $executor = new MultiExecExecutor(); + $pipeline = $this->getCommandsQueue(); + + $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); + $connection->expects($this->exactly(2)) + ->method('executeCommand') + ->will($this->onConsecutiveCalls(true, null)); + + $executor->execute($connection, $pipeline); + } + + /** + * @group disconnected + * @expectedException Predis\ServerException + * @expectedExceptionMessage ERR Test error + */ + public function testExecutorWithErrorInTransaction() + { + $executor = new MultiExecExecutor(); + $pipeline = $this->getCommandsQueue(); + $queued = new ResponseQueued(); + $error = new ResponseError('ERR Test error'); + + $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); + $connection->expects($this->at(0)) + ->method('executeCommand') + ->will($this->returnValue(true)); + $connection->expects($this->exactly(3)) + ->method('readResponse') + ->will($this->onConsecutiveCalls($queued, $queued, $error)); + $connection->expects($this->at(7)) + ->method('executeCommand') + ->with($this->isInstanceOf('Predis\Command\TransactionDiscard')); + + $executor->execute($connection, $pipeline); + } + + /** + * @group disconnected + */ + public function testExecutorWithErrorInCommandResponse() + { + $executor = new MultiExecExecutor(); + $pipeline = $this->getCommandsQueue(); + $queued = new ResponseQueued(); + $error = new ResponseError('ERR Test error'); + + $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); + $connection->expects($this->exactly(3)) + ->method('readResponse') + ->will($this->onConsecutiveCalls($queued, $queued, $queued)); + $connection->expects($this->at(7)) + ->method('executeCommand') + ->will($this->returnValue(array('PONG', 'PONG', $error))); + + $replies = $executor->execute($connection, $pipeline); + + $this->assertSame(array(true, true, $error), $replies); + } + + /** + * @group disconnected + * @expectedException Predis\ClientException + * @expectedExceptionMessage Predis\Pipeline\MultiExecExecutor can be used only with single connections + */ + public function testExecutorWithAggregatedConnection() + { + $executor = new MultiExecExecutor(); + $pipeline = $this->getCommandsQueue(); + + $connection = $this->getMock('Predis\Connection\ReplicationConnectionInterface'); + + $replies = $executor->execute($connection, $pipeline); + } + + // ******************************************************************** // + // ---- HELPER METHODS ------------------------------------------------ // + // ******************************************************************** // + + /** + * Returns a list of queued command instances. + * + * @return SplQueue + */ + protected function getCommandsQueue() + { + $profile = ServerProfile::getDevelopment(); + + $pipeline = new SplQueue(); + $pipeline->enqueue($profile->createCommand('ping')); + $pipeline->enqueue($profile->createCommand('ping')); + $pipeline->enqueue($profile->createCommand('ping')); + + return $pipeline; + } +} diff --git a/vendor/predis/predis/tests/Predis/Pipeline/PipelineContextTest.php b/vendor/predis/predis/tests/Predis/Pipeline/PipelineContextTest.php new file mode 100755 index 0000000..4354e12 --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Pipeline/PipelineContextTest.php @@ -0,0 +1,438 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Pipeline; + +use PredisTestCase; +use Predis\Client; +use Predis\ClientException; +use Predis\Profile\ServerProfile; + +/** + * + */ +class PipelineContextTest extends PredisTestCase +{ + /** + * @group disconnected + */ + public function testConstructorWithoutOptions() + { + $client = new Client(); + $pipeline = new PipelineContext($client); + + $this->assertSame($client, $pipeline->getClient()); + $this->assertInstanceOf('Predis\Pipeline\StandardExecutor', $pipeline->getExecutor()); + } + + /** + * @group disconnected + */ + public function testConstructorWithExecutorArgument() + { + $client = new Client(); + $executor = $this->getMock('Predis\Pipeline\PipelineExecutorInterface'); + + $pipeline = new PipelineContext($client, $executor); + $this->assertSame($executor, $pipeline->getExecutor()); + } + + /** + * @group disconnected + */ + public function testCallDoesNotSendCommandsWithoutExecute() + { + $executor = $this->getMock('Predis\Pipeline\PipelineExecutorInterface'); + $executor->expects($this->never())->method('executor'); + + $pipeline = new PipelineContext(new Client(), $executor); + + $pipeline->echo('one'); + $pipeline->echo('two'); + $pipeline->echo('three'); + } + + /** + * @group disconnected + */ + public function testCallReturnsPipelineForFluentInterface() + { + $executor = $this->getMock('Predis\Pipeline\PipelineExecutorInterface'); + $executor->expects($this->never())->method('executor'); + + $pipeline = new PipelineContext(new Client(), $executor); + + $this->assertSame($pipeline, $pipeline->echo('one')); + $this->assertSame($pipeline, $pipeline->echo('one')->echo('two')->echo('three')); + } + + /** + * @group disconnected + */ + public function testExecuteReturnsPipelineForFluentInterface() + { + $profile = ServerProfile::getDefault(); + $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); + + $pipeline = new PipelineContext(new Client($connection)); + $command = $profile->createCommand('echo', array('one')); + + $this->assertSame($pipeline, $pipeline->executeCommand($command)); + } + + /** + * @group disconnected + */ + public function testExecuteCommandDoesNotSendCommandsWithoutExecute() + { + $profile = ServerProfile::getDefault(); + + $executor = $this->getMock('Predis\Pipeline\PipelineExecutorInterface'); + $executor->expects($this->never())->method('executor'); + + $pipeline = new PipelineContext(new Client(), $executor); + + $pipeline->executeCommand($profile->createCommand('echo', array('one'))); + $pipeline->executeCommand($profile->createCommand('echo', array('two'))); + $pipeline->executeCommand($profile->createCommand('echo', array('three'))); + } + + /** + * @group disconnected + */ + public function testExecuteWithEmptyBuffer() + { + $executor = $this->getMock('Predis\Pipeline\PipelineExecutorInterface'); + $executor->expects($this->never())->method('executor'); + + $pipeline = new PipelineContext(new Client(), $executor); + + $this->assertSame(array(), $pipeline->execute()); + } + + /** + * @group disconnected + */ + public function testExecuteWithFilledBuffer() + { + $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); + $connection->expects($this->exactly(3)) + ->method('writeCommand'); + $connection->expects($this->exactly(3)) + ->method('readResponse') + ->will($this->returnCallback($this->getReadCallback())); + + $pipeline = new PipelineContext(new Client($connection)); + + $pipeline->echo('one'); + $pipeline->echo('two'); + $pipeline->echo('three'); + + $pipeline->flushPipeline(); + + $this->assertSame(array('one', 'two', 'three'), $pipeline->execute()); + } + + /** + * @group disconnected + */ + public function testFlushWithFalseArgumentDiscardsBuffer() + { + $executor = $this->getMock('Predis\Pipeline\PipelineExecutorInterface'); + $executor->expects($this->never())->method('executor'); + + $pipeline = new PipelineContext(new Client(), $executor); + + $pipeline->echo('one'); + $pipeline->echo('two'); + $pipeline->echo('three'); + + $pipeline->flushPipeline(false); + + $this->assertSame(array(), $pipeline->execute()); + } + + /** + * @group disconnected + */ + public function testFlushHandlesPartialBuffers() + { + $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); + $connection->expects($this->exactly(4)) + ->method('writeCommand'); + $connection->expects($this->exactly(4)) + ->method('readResponse') + ->will($this->returnCallback($this->getReadCallback())); + + $pipeline = new PipelineContext(new Client($connection)); + + $pipeline->echo('one'); + $pipeline->echo('two'); + $pipeline->flushPipeline(); + $pipeline->echo('three'); + $pipeline->echo('four'); + + $this->assertSame(array('one', 'two', 'three', 'four'), $pipeline->execute()); + } + + /** + * @group disconnected + */ + public function testExecuteAcceptsCallableArgument() + { + $test = $this; + $pipeline = new PipelineContext(new Client()); + + $callable = function ($pipe) use ($test, $pipeline) { + $test->assertSame($pipeline, $pipe); + $pipe->flushPipeline(false); + }; + + $pipeline->execute($callable); + } + + /** + * @group disconnected + * @expectedException InvalidArgumentException + */ + public function testExecuteDoesNotAcceptNonCallableArgument() + { + $noncallable = new \stdClass(); + + $pipeline = new PipelineContext(new Client()); + $pipeline->execute($noncallable); + } + + /** + * @group disconnected + * @expectedException Predis\ClientException + */ + public function testExecuteInsideCallableArgumentThrowsException() + { + $pipeline = new PipelineContext(new Client()); + + $pipeline->execute(function ($pipe) { + $pipe->execute(); + }); + } + + /** + * @group disconnected + */ + public function testExecuteWithCallableArgumentRunsPipelineInCallable() + { + $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); + $connection->expects($this->exactly(4)) + ->method('writeCommand'); + $connection->expects($this->exactly(4)) + ->method('readResponse') + ->will($this->returnCallback($this->getReadCallback())); + + $pipeline = new PipelineContext(new Client($connection)); + + $replies = $pipeline->execute(function ($pipe) { + $pipe->echo('one'); + $pipe->echo('two'); + $pipe->echo('three'); + $pipe->echo('four'); + }); + + $this->assertSame(array('one', 'two', 'three', 'four'), $replies); + } + + /** + * @group disconnected + */ + public function testExecuteWithCallableArgumentHandlesExceptions() + { + $exception = null; + + $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); + $connection->expects($this->never())->method('writeCommand'); + $connection->expects($this->never())->method('readResponse'); + + $pipeline = new PipelineContext(new Client($connection)); + + $exception = null; + $replies = null; + + try { + $replies = $pipeline->execute(function ($pipe) { + $pipe->echo('one'); + throw new ClientException('TEST'); + $pipe->echo('two'); + }); + } catch (\Exception $exception) { + // NOOP + } + + $this->assertInstanceOf('Predis\ClientException', $exception); + $this->assertSame('TEST', $exception->getMessage()); + $this->assertNull($replies); + } + + // ******************************************************************** // + // ---- INTEGRATION TESTS --------------------------------------------- // + // ******************************************************************** // + + /** + * @group connected + */ + public function testIntegrationWithFluentInterface() + { + $pipeline = $this->getClient()->pipeline(); + + $results = $pipeline->echo('one') + ->echo('two') + ->echo('three') + ->execute(); + + $this->assertSame(array('one', 'two', 'three'), $results); + } + + /** + * @group connected + */ + public function testIntegrationWithCallableBlock() + { + $client = $this->getClient(); + + $results = $client->pipeline(function ($pipe) { + $pipe->set('foo', 'bar'); + $pipe->get('foo'); + }); + + $this->assertSame(array(true, 'bar'), $results); + $this->assertTrue($client->exists('foo')); + } + + /** + * @group connected + */ + public function testOutOfBandMessagesInsidePipeline() + { + $oob = null; + $client = $this->getClient(); + + $results = $client->pipeline(function ($pipe) use (&$oob) { + $pipe->set('foo', 'bar'); + $oob = $pipe->getClient()->echo('oob message'); + $pipe->get('foo'); + }); + + $this->assertSame(array(true, 'bar'), $results); + $this->assertSame('oob message', $oob); + $this->assertTrue($client->exists('foo')); + } + + /** + * @group connected + */ + public function testIntegrationWithClientExceptionInCallableBlock() + { + $exception = null; + + $client = $this->getClient(); + + try { + $client->pipeline(function ($pipe) { + $pipe->set('foo', 'bar'); + throw new ClientException('TEST'); + }); + } catch (\Exception $exception) { + // NOOP + } + + $this->assertInstanceOf('Predis\ClientException', $exception); + $this->assertSame('TEST', $exception->getMessage()); + $this->assertFalse($client->exists('foo')); + } + + /** + * @group connected + */ + public function testIntegrationWithServerExceptionInCallableBlock() + { + $exception = null; + + $client = $this->getClient(); + + try { + $client->pipeline(function ($pipe) { + $pipe->set('foo', 'bar'); + // LPUSH on a string key fails, but won't stop + // the pipeline to send the commands. + $pipe->lpush('foo', 'bar'); + $pipe->set('hoge', 'piyo'); + }); + } catch (\Exception $exception) { + // NOOP + } + + $this->assertInstanceOf('Predis\ServerException', $exception); + $this->assertTrue($client->exists('foo')); + $this->assertTrue($client->exists('hoge')); + } + + /** + * @group connected + */ + public function testIntegrationWithServerErrorInCallableBlock() + { + $client = $this->getClient(array(), array('exceptions' => false)); + + $results = $client->pipeline(function ($pipe) { + $pipe->set('foo', 'bar'); + $pipe->lpush('foo', 'bar'); // LPUSH on a string key fails. + $pipe->get('foo'); + }); + + $this->assertTrue($results[0]); + $this->assertInstanceOf('Predis\ResponseError', $results[1]); + $this->assertSame('bar', $results[2]); + } + + // ******************************************************************** // + // ---- HELPER METHODS ------------------------------------------------ // + // ******************************************************************** // + + /** + * Returns a client instance connected to the specified Redis + * server instance to perform integration tests. + * + * @param array $parameters Additional connection parameters. + * @param array $options Additional client options. + * @return Client + */ + protected function getClient(array $parameters = array(), array $options = array()) + { + return $this->createClient($parameters, $options); + } + + /** + * Helper method that returns a callback used to emulate a reply + * to an ECHO command. + * + * @return \Closure + */ + protected function getReadCallback() + { + return function ($command) { + if (($id = $command->getId()) !== 'ECHO') { + throw new \InvalidArgumentException("Expected ECHO, got {$id}"); + } + + list($echoed) = $command->getArguments(); + + return $echoed; + }; + } +} diff --git a/vendor/predis/predis/tests/Predis/Pipeline/StandardExecutorTest.php b/vendor/predis/predis/tests/Predis/Pipeline/StandardExecutorTest.php new file mode 100755 index 0000000..e7a2ea5 --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Pipeline/StandardExecutorTest.php @@ -0,0 +1,159 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Pipeline; + +use SplQueue; +use PredisTestCase; +use Predis\ResponseError; +use Predis\ResponseObjectInterface; +use Predis\Profile\ServerProfile; + +/** + * + */ +class StandardExecutorTest extends PredisTestCase +{ + /** + * @group disconnected + */ + public function testExecutorWithSingleConnection() + { + $executor = new StandardExecutor(); + $pipeline = $this->getCommandsQueue(); + + $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); + $connection->expects($this->exactly(3)) + ->method('writeCommand'); + $connection->expects($this->exactly(3)) + ->method('readResponse') + ->will($this->returnValue('PONG')); + + $replies = $executor->execute($connection, $pipeline); + + $this->assertTrue($pipeline->isEmpty()); + $this->assertSame(array(true, true, true), $replies); + } + + /** + * @group disconnected + */ + public function testExecutorWithReplicationConnection() + { + $executor = new StandardExecutor(); + $pipeline = $this->getCommandsQueue(); + + $connection = $this->getMock('Predis\Connection\ReplicationConnectionInterface'); + $connection->expects($this->once()) + ->method('switchTo') + ->with('master'); + $connection->expects($this->exactly(3)) + ->method('writeCommand'); + $connection->expects($this->exactly(3)) + ->method('readResponse') + ->will($this->returnValue('PONG')); + + $replies = $executor->execute($connection, $pipeline); + + $this->assertTrue($pipeline->isEmpty()); + $this->assertSame(array(true, true, true), $replies); + } + + /** + * @group disconnected + */ + public function testExecutorDoesNotParseResponseObjects() + { + $executor = new StandardExecutor(); + $response = $this->getMock('Predis\ResponseObjectInterface'); + + $this->simpleResponseObjectTest($executor, $response); + } + + /** + * @group disconnected + */ + public function testExecutorCanReturnRedisErrors() + { + $executor = new StandardExecutor(false); + $response = $this->getMock('Predis\ResponseErrorInterface'); + + $this->simpleResponseObjectTest($executor, $response); + } + + /** + * @group disconnected + * @expectedException Predis\ServerException + * @expectedExceptionMessage ERR Test error + */ + public function testExecutorCanThrowExceptions() + { + $executor = new StandardExecutor(true); + $pipeline = $this->getCommandsQueue(); + $error = new ResponseError('ERR Test error'); + + $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); + $connection->expects($this->once()) + ->method('readResponse') + ->will($this->returnValue($error)); + + $executor->execute($connection, $pipeline); + } + + // ******************************************************************** // + // ---- HELPER METHODS ------------------------------------------------ // + // ******************************************************************** // + + /** + * Executes a test for the Predis\ResponseObjectInterface type. + * + * @param PipelineExecutorInterface $executor + * @param ResponseObjectInterface $response + */ + protected function simpleResponseObjectTest(PipelineExecutorInterface $executor, ResponseObjectInterface $response) + { + $pipeline = new SplQueue(); + + $command = $this->getMock('Predis\Command\CommandInterface'); + $command->expects($this->never()) + ->method('parseResponse'); + + $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); + $connection->expects($this->once()) + ->method('writeCommand'); + $connection->expects($this->once()) + ->method('readResponse') + ->will($this->returnValue($response)); + + $pipeline->enqueue($command); + $replies = $executor->execute($connection, $pipeline); + + $this->assertTrue($pipeline->isEmpty()); + $this->assertSame(array($response), $replies); + } + + /** + * Returns a list of queued command instances. + * + * @return SplQueue + */ + protected function getCommandsQueue() + { + $profile = ServerProfile::getDevelopment(); + + $pipeline = new SplQueue(); + $pipeline->enqueue($profile->createCommand('ping')); + $pipeline->enqueue($profile->createCommand('ping')); + $pipeline->enqueue($profile->createCommand('ping')); + + return $pipeline; + } +} diff --git a/vendor/predis/predis/tests/Predis/PredisExceptionTest.php b/vendor/predis/predis/tests/Predis/PredisExceptionTest.php new file mode 100755 index 0000000..07b6381 --- /dev/null +++ b/vendor/predis/predis/tests/Predis/PredisExceptionTest.php @@ -0,0 +1,33 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis; + +use PredisTestCase; + +/** + * + */ +class PredisExceptionTest extends PredisTestCase +{ + /** + * @group disconnected + */ + public function testExceptionMessage() + { + $message = 'Predis exception message'; + $exception = $this->getMockForAbstractClass('Predis\PredisException', array($message)); + + $this->setExpectedException('Predis\PredisException', $message); + + throw $exception; + } +} diff --git a/vendor/predis/predis/tests/Predis/Profile/ServerProfileTest.php b/vendor/predis/predis/tests/Predis/Profile/ServerProfileTest.php new file mode 100755 index 0000000..6173973 --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Profile/ServerProfileTest.php @@ -0,0 +1,293 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Profile; + +use PredisTestCase; +use Predis\Command\Processor\ProcessorChain; + +/** + * + */ +class ServerProfileTest extends PredisTestCase +{ + const DEFAULT_PROFILE_VERSION = '2.6'; + const DEVELOPMENT_PROFILE_VERSION = '3.0'; + + /** + * @group disconnected + */ + public function testGetVersion() + { + $profile = ServerProfile::get('2.0'); + + $this->assertInstanceOf('Predis\Profile\ServerProfileInterface', $profile); + $this->assertEquals('2.0', $profile->getVersion()); + } + + /** + * @group disconnected + */ + public function testGetDefault() + { + $profile1 = ServerProfile::get(self::DEFAULT_PROFILE_VERSION); + $profile2 = ServerProfile::get('default'); + $profile3 = ServerProfile::getDefault(); + + $this->assertInstanceOf('Predis\Profile\ServerProfileInterface', $profile1); + $this->assertInstanceOf('Predis\Profile\ServerProfileInterface', $profile2); + $this->assertInstanceOf('Predis\Profile\ServerProfileInterface', $profile3); + $this->assertEquals($profile1->getVersion(), $profile2->getVersion()); + $this->assertEquals($profile2->getVersion(), $profile3->getVersion()); + } + + /** + * @group disconnected + */ + public function testGetDevelopment() + { + $profile1 = ServerProfile::get('dev'); + $profile2 = ServerProfile::getDevelopment(); + + $this->assertInstanceOf('Predis\Profile\ServerProfileInterface', $profile1); + $this->assertInstanceOf('Predis\Profile\ServerProfileInterface', $profile2); + $this->assertEquals(self::DEVELOPMENT_PROFILE_VERSION, $profile2->getVersion()); + } + + /** + * @group disconnected + * @expectedException Predis\ClientException + * @expectedExceptionMessage Unknown server profile: 1.0 + */ + public function testGetUndefinedProfile() + { + ServerProfile::get('1.0'); + } + + /** + * @group disconnected + */ + public function testDefineProfile() + { + $profileClass = get_class($this->getMock('Predis\Profile\ServerProfileInterface')); + + ServerProfile::define('mock', $profileClass); + + $this->assertInstanceOf($profileClass, ServerProfile::get('mock')); + } + + /** + * @group disconnected + * @expectedException InvalidArgumentException + * @expectedExceptionMessage Cannot register 'stdClass' as it is not a valid profile class + */ + public function testDefineInvalidProfile() + { + ServerProfile::define('bogus', 'stdClass'); + } + + /** + * @group disconnected + */ + public function testToString() + { + $this->assertEquals('2.0', (string) ServerProfile::get('2.0')); + } + + /** + * @group disconnected + */ + public function testSupportCommand() + { + $profile = ServerProfile::getDefault(); + + $this->assertTrue($profile->supportsCommand('info')); + $this->assertTrue($profile->supportsCommand('INFO')); + + $this->assertFalse($profile->supportsCommand('unknown')); + $this->assertFalse($profile->supportsCommand('UNKNOWN')); + } + + /** + * @group disconnected + */ + public function testSupportCommands() + { + $profile = ServerProfile::getDefault(); + + $this->assertTrue($profile->supportsCommands(array('get', 'set'))); + $this->assertTrue($profile->supportsCommands(array('GET', 'SET'))); + + $this->assertFalse($profile->supportsCommands(array('get', 'unknown'))); + + $this->assertFalse($profile->supportsCommands(array('unknown1', 'unknown2'))); + } + + /** + * @group disconnected + */ + public function testGetCommandClass() + { + $profile = ServerProfile::getDefault(); + + $this->assertSame('Predis\Command\ConnectionPing', $profile->getCommandClass('ping')); + $this->assertSame('Predis\Command\ConnectionPing', $profile->getCommandClass('PING')); + + $this->assertNull($profile->getCommandClass('unknown')); + $this->assertNull($profile->getCommandClass('UNKNOWN')); + } + + /** + * @group disconnected + */ + public function testDefineCommand() + { + $profile = ServerProfile::getDefault(); + $command = $this->getMock('Predis\Command\CommandInterface'); + + $profile->defineCommand('mock', get_class($command)); + + $this->assertTrue($profile->supportsCommand('mock')); + $this->assertTrue($profile->supportsCommand('MOCK')); + + $this->assertSame(get_class($command), $profile->getCommandClass('mock')); + } + + /** + * @group disconnected + * @expectedException InvalidArgumentException + * @expectedExceptionMessage Cannot register 'stdClass' as it is not a valid Redis command + */ + public function testDefineInvalidCommand() + { + $profile = ServerProfile::getDefault(); + + $profile->defineCommand('mock', 'stdClass'); + } + + /** + * @group disconnected + */ + public function testCreateCommandWithoutArguments() + { + $profile = ServerProfile::getDefault(); + + $command = $profile->createCommand('info'); + $this->assertInstanceOf('Predis\Command\CommandInterface', $command); + $this->assertEquals('INFO', $command->getId()); + $this->assertEquals(array(), $command->getArguments()); + } + + /** + * @group disconnected + */ + public function testCreateCommandWithArguments() + { + $profile = ServerProfile::getDefault(); + $arguments = array('foo', 'bar'); + + $command = $profile->createCommand('set', $arguments); + $this->assertInstanceOf('Predis\Command\CommandInterface', $command); + $this->assertEquals('SET', $command->getId()); + $this->assertEquals($arguments, $command->getArguments()); + } + + /** + * @group disconnected + * @expectedException Predis\ClientException + * @expectedExceptionMessage 'unknown' is not a registered Redis command + */ + public function testCreateUndefinedCommand() + { + $profile = ServerProfile::getDefault(); + $profile->createCommand('unknown'); + } + + /** + * @group disconnected + */ + public function testGetDefaultProcessor() + { + $profile = ServerProfile::getDefault(); + + $this->assertNull($profile->getProcessor()); + } + + /** + * @group disconnected + */ + public function testSetProcessor() + { + $processor = $this->getMock('Predis\Command\Processor\CommandProcessorInterface'); + + $profile = ServerProfile::getDefault(); + $profile->setProcessor($processor); + + $this->assertSame($processor, $profile->getProcessor()); + } + + /** + * @group disconnected + */ + public function testSetAndUnsetProcessor() + { + $processor = $this->getMock('Predis\Command\Processor\CommandProcessorInterface'); + $profile = ServerProfile::getDefault(); + + $profile->setProcessor($processor); + $this->assertSame($processor, $profile->getProcessor()); + + $profile->setProcessor(null); + $this->assertNull($profile->getProcessor()); + } + + /** + * @group disconnected + * @todo Could it be that objects passed to the return callback of a mocked + * method are cloned instead of being passed by reference? + */ + public function testSingleProcessor() + { + $argsRef = null; + + $processor = $this->getMock('Predis\Command\Processor\CommandProcessorInterface'); + $processor->expects($this->once()) + ->method('process') + ->with($this->isInstanceOf('Predis\Command\CommandInterface')) + ->will($this->returnCallback(function ($cmd) use (&$argsRef) { + $cmd->setRawArguments($argsRef = array_map('strtoupper', $cmd->getArguments())); + })); + + $profile = ServerProfile::getDefault(); + $profile->setProcessor($processor); + $command = $profile->createCommand('set', array('foo', 'bar')); + + $this->assertSame(array('FOO', 'BAR'), $argsRef); + } + + /** + * @group disconnected + */ + public function testChainOfProcessors() + { + $processor = $this->getMock('Predis\Command\Processor\CommandProcessorInterface'); + $processor->expects($this->exactly(2)) + ->method('process'); + + $chain = new ProcessorChain(); + $chain->add($processor); + $chain->add($processor); + + $profile = ServerProfile::getDefault(); + $profile->setProcessor($chain); + $profile->createCommand('info'); + } +} diff --git a/vendor/predis/predis/tests/Predis/Profile/ServerVersion12Test.php b/vendor/predis/predis/tests/Predis/Profile/ServerVersion12Test.php new file mode 100755 index 0000000..1723dce --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Profile/ServerVersion12Test.php @@ -0,0 +1,116 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Profile; + +/** + * + */ +class ServerVersion12Test extends PredisProfileTestCase +{ + /** + * {@inheritdoc} + */ + public function getProfile($version = null) + { + return new ServerVersion12(); + } + + /** + * {@inheritdoc} + */ + public function getExpectedVersion() + { + return '1.2'; + } + + /** + * {@inheritdoc} + */ + public function getExpectedCommands() + { + return array( + 0 => 'exists', + 1 => 'del', + 2 => 'type', + 3 => 'keys', + 4 => 'randomkey', + 5 => 'rename', + 6 => 'renamenx', + 7 => 'expire', + 8 => 'expireat', + 9 => 'ttl', + 10 => 'move', + 11 => 'sort', + 12 => 'set', + 13 => 'setnx', + 14 => 'mset', + 15 => 'msetnx', + 16 => 'get', + 17 => 'mget', + 18 => 'getset', + 19 => 'incr', + 20 => 'incrby', + 21 => 'decr', + 22 => 'decrby', + 23 => 'rpush', + 24 => 'lpush', + 25 => 'llen', + 26 => 'lrange', + 27 => 'ltrim', + 28 => 'lindex', + 29 => 'lset', + 30 => 'lrem', + 31 => 'lpop', + 32 => 'rpop', + 33 => 'rpoplpush', + 34 => 'sadd', + 35 => 'srem', + 36 => 'spop', + 37 => 'smove', + 38 => 'scard', + 39 => 'sismember', + 40 => 'sinter', + 41 => 'sinterstore', + 42 => 'sunion', + 43 => 'sunionstore', + 44 => 'sdiff', + 45 => 'sdiffstore', + 46 => 'smembers', + 47 => 'srandmember', + 48 => 'zadd', + 49 => 'zincrby', + 50 => 'zrem', + 51 => 'zrange', + 52 => 'zrevrange', + 53 => 'zrangebyscore', + 54 => 'zcard', + 55 => 'zscore', + 56 => 'zremrangebyscore', + 57 => 'ping', + 58 => 'auth', + 59 => 'select', + 60 => 'echo', + 61 => 'quit', + 62 => 'info', + 63 => 'slaveof', + 64 => 'monitor', + 65 => 'dbsize', + 66 => 'flushdb', + 67 => 'flushall', + 68 => 'save', + 69 => 'bgsave', + 70 => 'lastsave', + 71 => 'shutdown', + 72 => 'bgrewriteaof', + ); + } +} diff --git a/vendor/predis/predis/tests/Predis/Profile/ServerVersion20Test.php b/vendor/predis/predis/tests/Predis/Profile/ServerVersion20Test.php new file mode 100755 index 0000000..f1f1aba --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Profile/ServerVersion20Test.php @@ -0,0 +1,148 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Profile; + +/** + * + */ +class ServerVersion20Test extends PredisProfileTestCase +{ + /** + * {@inheritdoc} + */ + public function getProfile($version = null) + { + return new ServerVersion20(); + } + + /** + * {@inheritdoc} + */ + public function getExpectedVersion() + { + return '2.0'; + } + + /** + * {@inheritdoc} + */ + public function getExpectedCommands() + { + return array( + 0 => 'exists', + 1 => 'del', + 2 => 'type', + 3 => 'keys', + 4 => 'randomkey', + 5 => 'rename', + 6 => 'renamenx', + 7 => 'expire', + 8 => 'expireat', + 9 => 'ttl', + 10 => 'move', + 11 => 'sort', + 12 => 'set', + 13 => 'setnx', + 14 => 'mset', + 15 => 'msetnx', + 16 => 'get', + 17 => 'mget', + 18 => 'getset', + 19 => 'incr', + 20 => 'incrby', + 21 => 'decr', + 22 => 'decrby', + 23 => 'rpush', + 24 => 'lpush', + 25 => 'llen', + 26 => 'lrange', + 27 => 'ltrim', + 28 => 'lindex', + 29 => 'lset', + 30 => 'lrem', + 31 => 'lpop', + 32 => 'rpop', + 33 => 'rpoplpush', + 34 => 'sadd', + 35 => 'srem', + 36 => 'spop', + 37 => 'smove', + 38 => 'scard', + 39 => 'sismember', + 40 => 'sinter', + 41 => 'sinterstore', + 42 => 'sunion', + 43 => 'sunionstore', + 44 => 'sdiff', + 45 => 'sdiffstore', + 46 => 'smembers', + 47 => 'srandmember', + 48 => 'zadd', + 49 => 'zincrby', + 50 => 'zrem', + 51 => 'zrange', + 52 => 'zrevrange', + 53 => 'zrangebyscore', + 54 => 'zcard', + 55 => 'zscore', + 56 => 'zremrangebyscore', + 57 => 'ping', + 58 => 'auth', + 59 => 'select', + 60 => 'echo', + 61 => 'quit', + 62 => 'info', + 63 => 'slaveof', + 64 => 'monitor', + 65 => 'dbsize', + 66 => 'flushdb', + 67 => 'flushall', + 68 => 'save', + 69 => 'bgsave', + 70 => 'lastsave', + 71 => 'shutdown', + 72 => 'bgrewriteaof', + 73 => 'setex', + 74 => 'append', + 75 => 'substr', + 76 => 'blpop', + 77 => 'brpop', + 78 => 'zunionstore', + 79 => 'zinterstore', + 80 => 'zcount', + 81 => 'zrank', + 82 => 'zrevrank', + 83 => 'zremrangebyrank', + 84 => 'hset', + 85 => 'hsetnx', + 86 => 'hmset', + 87 => 'hincrby', + 88 => 'hget', + 89 => 'hmget', + 90 => 'hdel', + 91 => 'hexists', + 92 => 'hlen', + 93 => 'hkeys', + 94 => 'hvals', + 95 => 'hgetall', + 96 => 'multi', + 97 => 'exec', + 98 => 'discard', + 99 => 'subscribe', + 100 => 'unsubscribe', + 101 => 'psubscribe', + 102 => 'punsubscribe', + 103 => 'publish', + 104 => 'config', + ); + } +} diff --git a/vendor/predis/predis/tests/Predis/Profile/ServerVersion22Test.php b/vendor/predis/predis/tests/Predis/Profile/ServerVersion22Test.php new file mode 100755 index 0000000..a62efa0 --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Profile/ServerVersion22Test.php @@ -0,0 +1,163 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Profile; + +/** + * + */ +class ServerVersion22Test extends PredisProfileTestCase +{ + /** + * {@inheritdoc} + */ + public function getProfile($version = null) + { + return new ServerVersion22(); + } + + /** + * {@inheritdoc} + */ + public function getExpectedVersion() + { + return '2.2'; + } + + /** + * {@inheritdoc} + */ + public function getExpectedCommands() + { + return array( + 0 => 'exists', + 1 => 'del', + 2 => 'type', + 3 => 'keys', + 4 => 'randomkey', + 5 => 'rename', + 6 => 'renamenx', + 7 => 'expire', + 8 => 'expireat', + 9 => 'ttl', + 10 => 'move', + 11 => 'sort', + 12 => 'set', + 13 => 'setnx', + 14 => 'mset', + 15 => 'msetnx', + 16 => 'get', + 17 => 'mget', + 18 => 'getset', + 19 => 'incr', + 20 => 'incrby', + 21 => 'decr', + 22 => 'decrby', + 23 => 'rpush', + 24 => 'lpush', + 25 => 'llen', + 26 => 'lrange', + 27 => 'ltrim', + 28 => 'lindex', + 29 => 'lset', + 30 => 'lrem', + 31 => 'lpop', + 32 => 'rpop', + 33 => 'rpoplpush', + 34 => 'sadd', + 35 => 'srem', + 36 => 'spop', + 37 => 'smove', + 38 => 'scard', + 39 => 'sismember', + 40 => 'sinter', + 41 => 'sinterstore', + 42 => 'sunion', + 43 => 'sunionstore', + 44 => 'sdiff', + 45 => 'sdiffstore', + 46 => 'smembers', + 47 => 'srandmember', + 48 => 'zadd', + 49 => 'zincrby', + 50 => 'zrem', + 51 => 'zrange', + 52 => 'zrevrange', + 53 => 'zrangebyscore', + 54 => 'zcard', + 55 => 'zscore', + 56 => 'zremrangebyscore', + 57 => 'ping', + 58 => 'auth', + 59 => 'select', + 60 => 'echo', + 61 => 'quit', + 62 => 'info', + 63 => 'slaveof', + 64 => 'monitor', + 65 => 'dbsize', + 66 => 'flushdb', + 67 => 'flushall', + 68 => 'save', + 69 => 'bgsave', + 70 => 'lastsave', + 71 => 'shutdown', + 72 => 'bgrewriteaof', + 73 => 'setex', + 74 => 'append', + 75 => 'substr', + 76 => 'blpop', + 77 => 'brpop', + 78 => 'zunionstore', + 79 => 'zinterstore', + 80 => 'zcount', + 81 => 'zrank', + 82 => 'zrevrank', + 83 => 'zremrangebyrank', + 84 => 'hset', + 85 => 'hsetnx', + 86 => 'hmset', + 87 => 'hincrby', + 88 => 'hget', + 89 => 'hmget', + 90 => 'hdel', + 91 => 'hexists', + 92 => 'hlen', + 93 => 'hkeys', + 94 => 'hvals', + 95 => 'hgetall', + 96 => 'multi', + 97 => 'exec', + 98 => 'discard', + 99 => 'subscribe', + 100 => 'unsubscribe', + 101 => 'psubscribe', + 102 => 'punsubscribe', + 103 => 'publish', + 104 => 'config', + 105 => 'persist', + 106 => 'strlen', + 107 => 'setrange', + 108 => 'getrange', + 109 => 'setbit', + 110 => 'getbit', + 111 => 'rpushx', + 112 => 'lpushx', + 113 => 'linsert', + 114 => 'brpoplpush', + 115 => 'zrevrangebyscore', + 116 => 'watch', + 117 => 'unwatch', + 118 => 'object', + 119 => 'slowlog', + ); + } +} diff --git a/vendor/predis/predis/tests/Predis/Profile/ServerVersion24Test.php b/vendor/predis/predis/tests/Predis/Profile/ServerVersion24Test.php new file mode 100755 index 0000000..899d319 --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Profile/ServerVersion24Test.php @@ -0,0 +1,164 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Profile; + +/** + * + */ +class ServerVersion24Test extends PredisProfileTestCase +{ + /** + * {@inheritdoc} + */ + public function getProfile($version = null) + { + return new ServerVersion24(); + } + + /** + * {@inheritdoc} + */ + public function getExpectedVersion() + { + return '2.4'; + } + + /** + * {@inheritdoc} + */ + public function getExpectedCommands() + { + return array( + 0 => 'exists', + 1 => 'del', + 2 => 'type', + 3 => 'keys', + 4 => 'randomkey', + 5 => 'rename', + 6 => 'renamenx', + 7 => 'expire', + 8 => 'expireat', + 9 => 'ttl', + 10 => 'move', + 11 => 'sort', + 12 => 'set', + 13 => 'setnx', + 14 => 'mset', + 15 => 'msetnx', + 16 => 'get', + 17 => 'mget', + 18 => 'getset', + 19 => 'incr', + 20 => 'incrby', + 21 => 'decr', + 22 => 'decrby', + 23 => 'rpush', + 24 => 'lpush', + 25 => 'llen', + 26 => 'lrange', + 27 => 'ltrim', + 28 => 'lindex', + 29 => 'lset', + 30 => 'lrem', + 31 => 'lpop', + 32 => 'rpop', + 33 => 'rpoplpush', + 34 => 'sadd', + 35 => 'srem', + 36 => 'spop', + 37 => 'smove', + 38 => 'scard', + 39 => 'sismember', + 40 => 'sinter', + 41 => 'sinterstore', + 42 => 'sunion', + 43 => 'sunionstore', + 44 => 'sdiff', + 45 => 'sdiffstore', + 46 => 'smembers', + 47 => 'srandmember', + 48 => 'zadd', + 49 => 'zincrby', + 50 => 'zrem', + 51 => 'zrange', + 52 => 'zrevrange', + 53 => 'zrangebyscore', + 54 => 'zcard', + 55 => 'zscore', + 56 => 'zremrangebyscore', + 57 => 'ping', + 58 => 'auth', + 59 => 'select', + 60 => 'echo', + 61 => 'quit', + 62 => 'info', + 63 => 'slaveof', + 64 => 'monitor', + 65 => 'dbsize', + 66 => 'flushdb', + 67 => 'flushall', + 68 => 'save', + 69 => 'bgsave', + 70 => 'lastsave', + 71 => 'shutdown', + 72 => 'bgrewriteaof', + 73 => 'setex', + 74 => 'append', + 75 => 'substr', + 76 => 'blpop', + 77 => 'brpop', + 78 => 'zunionstore', + 79 => 'zinterstore', + 80 => 'zcount', + 81 => 'zrank', + 82 => 'zrevrank', + 83 => 'zremrangebyrank', + 84 => 'hset', + 85 => 'hsetnx', + 86 => 'hmset', + 87 => 'hincrby', + 88 => 'hget', + 89 => 'hmget', + 90 => 'hdel', + 91 => 'hexists', + 92 => 'hlen', + 93 => 'hkeys', + 94 => 'hvals', + 95 => 'hgetall', + 96 => 'multi', + 97 => 'exec', + 98 => 'discard', + 99 => 'subscribe', + 100 => 'unsubscribe', + 101 => 'psubscribe', + 102 => 'punsubscribe', + 103 => 'publish', + 104 => 'config', + 105 => 'persist', + 106 => 'strlen', + 107 => 'setrange', + 108 => 'getrange', + 109 => 'setbit', + 110 => 'getbit', + 111 => 'rpushx', + 112 => 'lpushx', + 113 => 'linsert', + 114 => 'brpoplpush', + 115 => 'zrevrangebyscore', + 116 => 'watch', + 117 => 'unwatch', + 118 => 'object', + 119 => 'slowlog', + 120 => 'client', + ); + } +} diff --git a/vendor/predis/predis/tests/Predis/Profile/ServerVersion26Test.php b/vendor/predis/predis/tests/Predis/Profile/ServerVersion26Test.php new file mode 100755 index 0000000..bc01e5c --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Profile/ServerVersion26Test.php @@ -0,0 +1,178 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Profile; + +/** + * + */ +class ServerVersion26Test extends PredisProfileTestCase +{ + /** + * {@inheritdoc} + */ + public function getProfile($version = null) + { + return new ServerVersion26(); + } + + /** + * {@inheritdoc} + */ + public function getExpectedVersion() + { + return '2.6'; + } + + /** + * {@inheritdoc} + */ + public function getExpectedCommands() + { + return array( + 0 => 'exists', + 1 => 'del', + 2 => 'type', + 3 => 'keys', + 4 => 'randomkey', + 5 => 'rename', + 6 => 'renamenx', + 7 => 'expire', + 8 => 'expireat', + 9 => 'ttl', + 10 => 'move', + 11 => 'sort', + 12 => 'dump', + 13 => 'restore', + 14 => 'set', + 15 => 'setnx', + 16 => 'mset', + 17 => 'msetnx', + 18 => 'get', + 19 => 'mget', + 20 => 'getset', + 21 => 'incr', + 22 => 'incrby', + 23 => 'decr', + 24 => 'decrby', + 25 => 'rpush', + 26 => 'lpush', + 27 => 'llen', + 28 => 'lrange', + 29 => 'ltrim', + 30 => 'lindex', + 31 => 'lset', + 32 => 'lrem', + 33 => 'lpop', + 34 => 'rpop', + 35 => 'rpoplpush', + 36 => 'sadd', + 37 => 'srem', + 38 => 'spop', + 39 => 'smove', + 40 => 'scard', + 41 => 'sismember', + 42 => 'sinter', + 43 => 'sinterstore', + 44 => 'sunion', + 45 => 'sunionstore', + 46 => 'sdiff', + 47 => 'sdiffstore', + 48 => 'smembers', + 49 => 'srandmember', + 50 => 'zadd', + 51 => 'zincrby', + 52 => 'zrem', + 53 => 'zrange', + 54 => 'zrevrange', + 55 => 'zrangebyscore', + 56 => 'zcard', + 57 => 'zscore', + 58 => 'zremrangebyscore', + 59 => 'ping', + 60 => 'auth', + 61 => 'select', + 62 => 'echo', + 63 => 'quit', + 64 => 'info', + 65 => 'slaveof', + 66 => 'monitor', + 67 => 'dbsize', + 68 => 'flushdb', + 69 => 'flushall', + 70 => 'save', + 71 => 'bgsave', + 72 => 'lastsave', + 73 => 'shutdown', + 74 => 'bgrewriteaof', + 75 => 'setex', + 76 => 'append', + 77 => 'substr', + 78 => 'blpop', + 79 => 'brpop', + 80 => 'zunionstore', + 81 => 'zinterstore', + 82 => 'zcount', + 83 => 'zrank', + 84 => 'zrevrank', + 85 => 'zremrangebyrank', + 86 => 'hset', + 87 => 'hsetnx', + 88 => 'hmset', + 89 => 'hincrby', + 90 => 'hget', + 91 => 'hmget', + 92 => 'hdel', + 93 => 'hexists', + 94 => 'hlen', + 95 => 'hkeys', + 96 => 'hvals', + 97 => 'hgetall', + 98 => 'multi', + 99 => 'exec', + 100 => 'discard', + 101 => 'subscribe', + 102 => 'unsubscribe', + 103 => 'psubscribe', + 104 => 'punsubscribe', + 105 => 'publish', + 106 => 'config', + 107 => 'persist', + 108 => 'strlen', + 109 => 'setrange', + 110 => 'getrange', + 111 => 'setbit', + 112 => 'getbit', + 113 => 'rpushx', + 114 => 'lpushx', + 115 => 'linsert', + 116 => 'brpoplpush', + 117 => 'zrevrangebyscore', + 118 => 'watch', + 119 => 'unwatch', + 120 => 'object', + 121 => 'slowlog', + 122 => 'client', + 123 => 'pttl', + 124 => 'pexpire', + 125 => 'pexpireat', + 126 => 'psetex', + 127 => 'incrbyfloat', + 128 => 'bitop', + 129 => 'bitcount', + 130 => 'hincrbyfloat', + 131 => 'eval', + 132 => 'evalsha', + 133 => 'script', + 134 => 'time', + ); + } +} diff --git a/vendor/predis/predis/tests/Predis/Profile/ServerVersion28Test.php b/vendor/predis/predis/tests/Predis/Profile/ServerVersion28Test.php new file mode 100755 index 0000000..b9cf281 --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Profile/ServerVersion28Test.php @@ -0,0 +1,182 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Profile; + +/** + * + */ +class ServerVersion28Test extends PredisProfileTestCase +{ + /** + * {@inheritdoc} + */ + public function getProfile($version = null) + { + return new ServerVersion28(); + } + + /** + * {@inheritdoc} + */ + public function getExpectedVersion() + { + return '2.8'; + } + + /** + * {@inheritdoc} + */ + public function getExpectedCommands() + { + return array( + 0 => 'exists', + 1 => 'del', + 2 => 'type', + 3 => 'keys', + 4 => 'randomkey', + 5 => 'rename', + 6 => 'renamenx', + 7 => 'expire', + 8 => 'expireat', + 9 => 'ttl', + 10 => 'move', + 11 => 'sort', + 12 => 'dump', + 13 => 'restore', + 14 => 'set', + 15 => 'setnx', + 16 => 'mset', + 17 => 'msetnx', + 18 => 'get', + 19 => 'mget', + 20 => 'getset', + 21 => 'incr', + 22 => 'incrby', + 23 => 'decr', + 24 => 'decrby', + 25 => 'rpush', + 26 => 'lpush', + 27 => 'llen', + 28 => 'lrange', + 29 => 'ltrim', + 30 => 'lindex', + 31 => 'lset', + 32 => 'lrem', + 33 => 'lpop', + 34 => 'rpop', + 35 => 'rpoplpush', + 36 => 'sadd', + 37 => 'srem', + 38 => 'spop', + 39 => 'smove', + 40 => 'scard', + 41 => 'sismember', + 42 => 'sinter', + 43 => 'sinterstore', + 44 => 'sunion', + 45 => 'sunionstore', + 46 => 'sdiff', + 47 => 'sdiffstore', + 48 => 'smembers', + 49 => 'srandmember', + 50 => 'zadd', + 51 => 'zincrby', + 52 => 'zrem', + 53 => 'zrange', + 54 => 'zrevrange', + 55 => 'zrangebyscore', + 56 => 'zcard', + 57 => 'zscore', + 58 => 'zremrangebyscore', + 59 => 'ping', + 60 => 'auth', + 61 => 'select', + 62 => 'echo', + 63 => 'quit', + 64 => 'info', + 65 => 'slaveof', + 66 => 'monitor', + 67 => 'dbsize', + 68 => 'flushdb', + 69 => 'flushall', + 70 => 'save', + 71 => 'bgsave', + 72 => 'lastsave', + 73 => 'shutdown', + 74 => 'bgrewriteaof', + 75 => 'setex', + 76 => 'append', + 77 => 'substr', + 78 => 'blpop', + 79 => 'brpop', + 80 => 'zunionstore', + 81 => 'zinterstore', + 82 => 'zcount', + 83 => 'zrank', + 84 => 'zrevrank', + 85 => 'zremrangebyrank', + 86 => 'hset', + 87 => 'hsetnx', + 88 => 'hmset', + 89 => 'hincrby', + 90 => 'hget', + 91 => 'hmget', + 92 => 'hdel', + 93 => 'hexists', + 94 => 'hlen', + 95 => 'hkeys', + 96 => 'hvals', + 97 => 'hgetall', + 98 => 'multi', + 99 => 'exec', + 100 => 'discard', + 101 => 'subscribe', + 102 => 'unsubscribe', + 103 => 'psubscribe', + 104 => 'punsubscribe', + 105 => 'publish', + 106 => 'config', + 107 => 'persist', + 108 => 'strlen', + 109 => 'setrange', + 110 => 'getrange', + 111 => 'setbit', + 112 => 'getbit', + 113 => 'rpushx', + 114 => 'lpushx', + 115 => 'linsert', + 116 => 'brpoplpush', + 117 => 'zrevrangebyscore', + 118 => 'watch', + 119 => 'unwatch', + 120 => 'object', + 121 => 'slowlog', + 122 => 'client', + 123 => 'pttl', + 124 => 'pexpire', + 125 => 'pexpireat', + 126 => 'psetex', + 127 => 'incrbyfloat', + 128 => 'bitop', + 129 => 'bitcount', + 130 => 'hincrbyfloat', + 131 => 'eval', + 132 => 'evalsha', + 133 => 'script', + 134 => 'time', + 135 => 'scan', + 136 => 'sscan', + 137 => 'zscan', + 138 => 'hscan', + ); + } +} diff --git a/vendor/predis/predis/tests/Predis/Profile/ServerVersionNextTest.php b/vendor/predis/predis/tests/Predis/Profile/ServerVersionNextTest.php new file mode 100755 index 0000000..9a5a1f0 --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Profile/ServerVersionNextTest.php @@ -0,0 +1,182 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Profile; + +/** + * + */ +class ServerVersionNextTest extends PredisProfileTestCase +{ + /** + * {@inheritdoc} + */ + public function getProfile($version = null) + { + return new ServerVersionNext(); + } + + /** + * {@inheritdoc} + */ + public function getExpectedVersion() + { + return '3.0'; + } + + /** + * {@inheritdoc} + */ + public function getExpectedCommands() + { + return array( + 0 => 'exists', + 1 => 'del', + 2 => 'type', + 3 => 'keys', + 4 => 'randomkey', + 5 => 'rename', + 6 => 'renamenx', + 7 => 'expire', + 8 => 'expireat', + 9 => 'ttl', + 10 => 'move', + 11 => 'sort', + 12 => 'dump', + 13 => 'restore', + 14 => 'set', + 15 => 'setnx', + 16 => 'mset', + 17 => 'msetnx', + 18 => 'get', + 19 => 'mget', + 20 => 'getset', + 21 => 'incr', + 22 => 'incrby', + 23 => 'decr', + 24 => 'decrby', + 25 => 'rpush', + 26 => 'lpush', + 27 => 'llen', + 28 => 'lrange', + 29 => 'ltrim', + 30 => 'lindex', + 31 => 'lset', + 32 => 'lrem', + 33 => 'lpop', + 34 => 'rpop', + 35 => 'rpoplpush', + 36 => 'sadd', + 37 => 'srem', + 38 => 'spop', + 39 => 'smove', + 40 => 'scard', + 41 => 'sismember', + 42 => 'sinter', + 43 => 'sinterstore', + 44 => 'sunion', + 45 => 'sunionstore', + 46 => 'sdiff', + 47 => 'sdiffstore', + 48 => 'smembers', + 49 => 'srandmember', + 50 => 'zadd', + 51 => 'zincrby', + 52 => 'zrem', + 53 => 'zrange', + 54 => 'zrevrange', + 55 => 'zrangebyscore', + 56 => 'zcard', + 57 => 'zscore', + 58 => 'zremrangebyscore', + 59 => 'ping', + 60 => 'auth', + 61 => 'select', + 62 => 'echo', + 63 => 'quit', + 64 => 'info', + 65 => 'slaveof', + 66 => 'monitor', + 67 => 'dbsize', + 68 => 'flushdb', + 69 => 'flushall', + 70 => 'save', + 71 => 'bgsave', + 72 => 'lastsave', + 73 => 'shutdown', + 74 => 'bgrewriteaof', + 75 => 'setex', + 76 => 'append', + 77 => 'substr', + 78 => 'blpop', + 79 => 'brpop', + 80 => 'zunionstore', + 81 => 'zinterstore', + 82 => 'zcount', + 83 => 'zrank', + 84 => 'zrevrank', + 85 => 'zremrangebyrank', + 86 => 'hset', + 87 => 'hsetnx', + 88 => 'hmset', + 89 => 'hincrby', + 90 => 'hget', + 91 => 'hmget', + 92 => 'hdel', + 93 => 'hexists', + 94 => 'hlen', + 95 => 'hkeys', + 96 => 'hvals', + 97 => 'hgetall', + 98 => 'multi', + 99 => 'exec', + 100 => 'discard', + 101 => 'subscribe', + 102 => 'unsubscribe', + 103 => 'psubscribe', + 104 => 'punsubscribe', + 105 => 'publish', + 106 => 'config', + 107 => 'persist', + 108 => 'strlen', + 109 => 'setrange', + 110 => 'getrange', + 111 => 'setbit', + 112 => 'getbit', + 113 => 'rpushx', + 114 => 'lpushx', + 115 => 'linsert', + 116 => 'brpoplpush', + 117 => 'zrevrangebyscore', + 118 => 'watch', + 119 => 'unwatch', + 120 => 'object', + 121 => 'slowlog', + 122 => 'client', + 123 => 'pttl', + 124 => 'pexpire', + 125 => 'pexpireat', + 126 => 'psetex', + 127 => 'incrbyfloat', + 128 => 'bitop', + 129 => 'bitcount', + 130 => 'hincrbyfloat', + 131 => 'eval', + 132 => 'evalsha', + 133 => 'script', + 134 => 'time', + 135 => 'scan', + 136 => 'sscan', + 137 => 'zscan', + 138 => 'hscan', + ); + } +} diff --git a/vendor/predis/predis/tests/Predis/Protocol/ProtocolExceptionTest.php b/vendor/predis/predis/tests/Predis/Protocol/ProtocolExceptionTest.php new file mode 100755 index 0000000..a8b2ac7 --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Protocol/ProtocolExceptionTest.php @@ -0,0 +1,31 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Protocol; + +require_once __DIR__.'/../CommunicationExceptionTest.php'; + +use Predis\CommunicationExceptionTest; +use Predis\Connection\SingleConnectionInterface; + +/** + * + */ +class ProtocolExceptionTest extends CommunicationExceptionTest +{ + /** + * {@inheritdoc} + */ + protected function getException(SingleConnectionInterface $connection, $message, $code = 0, \Exception $inner = null) + { + return new ProtocolException($connection, $message, $code, $inner); + } +} diff --git a/vendor/predis/predis/tests/Predis/Protocol/Text/ComposableTextProtocolTest.php b/vendor/predis/predis/tests/Predis/Protocol/Text/ComposableTextProtocolTest.php new file mode 100755 index 0000000..b9bbc66 --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Protocol/Text/ComposableTextProtocolTest.php @@ -0,0 +1,119 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Protocol\Text; + +use PredisTestCase; + +/** + * + */ +class ComposableTextProtocolTest extends PredisTestCase +{ + /** + * @group disconnected + */ + public function testCustomSerializer() + { + $serializer = $this->getMock('Predis\Protocol\CommandSerializerInterface'); + + $protocol = new ComposableTextProtocol(); + $protocol->setSerializer($serializer); + + $this->assertSame($serializer, $protocol->getSerializer()); + } + + /** + * @group disconnected + */ + public function testCustomReader() + { + $reader = $this->getMock('Predis\Protocol\ResponseReaderInterface'); + + $protocol = new ComposableTextProtocol(); + $protocol->setReader($reader); + + $this->assertSame($reader, $protocol->getReader()); + } + + /** + * @group disconnected + */ + public function testConnectionWrite() + { + $serialized = "*1\r\n$4\r\nPING\r\n"; + + $command = $this->getMock('Predis\Command\CommandInterface'); + $connection = $this->getMock('Predis\Connection\ComposableConnectionInterface'); + $serializer = $this->getMock('Predis\Protocol\CommandSerializerInterface'); + + $protocol = new ComposableTextProtocol(); + $protocol->setSerializer($serializer); + + $connection->expects($this->once()) + ->method('writeBytes') + ->with($this->equalTo($serialized)); + + $serializer->expects($this->once()) + ->method('serialize') + ->with($command) + ->will($this->returnValue($serialized)); + + $protocol->write($connection, $command); + } + + /** + * @group disconnected + */ + public function testConnectionRead() + { + $serialized = "*1\r\n$4\r\nPING\r\n"; + + $connection = $this->getMock('Predis\Connection\ComposableConnectionInterface'); + $reader = $this->getMock('Predis\Protocol\ResponseReaderInterface'); + + $protocol = new ComposableTextProtocol(); + $protocol->setReader($reader); + + $reader->expects($this->once()) + ->method('read') + ->with($connection) + ->will($this->returnValue('bulk')); + + $this->assertSame('bulk', $protocol->read($connection)); + } + + /** + * @group disconnected + */ + public function testSetMultibulkOption() + { + $protocol = new ComposableTextProtocol(); + $reader = $protocol->getReader(); + + $protocol->setOption('iterable_multibulk', true); + $this->assertInstanceOf('Predis\Protocol\Text\ResponseMultiBulkStreamHandler', $reader->getHandler('*')); + + $protocol->setOption('iterable_multibulk', false); + $this->assertInstanceOf('Predis\Protocol\Text\ResponseMultiBulkHandler', $reader->getHandler('*')); + } + + /** + * @group disconnected + * @expectedException InvalidArgumentException + * @expectedExceptionMessage The option unknown_option is not supported by the current protocol + */ + public function testSetInvalidOption() + { + $protocol = new ComposableTextProtocol(); + $protocol->setOption('unknown_option', true); + } +} diff --git a/vendor/predis/predis/tests/Predis/Protocol/Text/ResponseBulkHandlerTest.php b/vendor/predis/predis/tests/Predis/Protocol/Text/ResponseBulkHandlerTest.php new file mode 100755 index 0000000..930076d --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Protocol/Text/ResponseBulkHandlerTest.php @@ -0,0 +1,91 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Protocol\Text; + +use PredisTestCase; + +/** + * + */ +class ResponseBulkHandlerTest extends PredisTestCase +{ + /** + * @group disconnected + */ + public function testZeroLengthBulk() + { + $handler = new ResponseBulkHandler(); + + $connection = $this->getMock('Predis\Connection\ComposableConnectionInterface'); + + $connection->expects($this->never())->method('readLine'); + $connection->expects($this->once()) + ->method('readBytes') + ->with($this->equalTo(2)) + ->will($this->returnValue("\r\n")); + + $this->assertSame('', $handler->handle($connection, '0')); + } + + /** + * @group disconnected + */ + public function testBulk() + { + $bulk = "This is a bulk string."; + $bulkLengh = strlen($bulk); + + $handler = new ResponseBulkHandler(); + + $connection = $this->getMock('Predis\Connection\ComposableConnectionInterface'); + + $connection->expects($this->never())->method('readLine'); + $connection->expects($this->once()) + ->method('readBytes') + ->with($this->equalTo($bulkLengh + 2)) + ->will($this->returnValue("$bulk\r\n")); + + $this->assertSame($bulk, $handler->handle($connection, (string) $bulkLengh)); + } + + /** + * @group disconnected + */ + public function testNull() + { + $handler = new ResponseBulkHandler(); + + $connection = $this->getMock('Predis\Connection\ComposableConnectionInterface'); + + $connection->expects($this->never())->method('readLine'); + $connection->expects($this->never())->method('readBytes'); + + $this->assertNull($handler->handle($connection, '-1')); + } + + /** + * @group disconnected + * @expectedException Predis\Protocol\ProtocolException + * @expectedExceptionMessage Cannot parse 'invalid' as bulk length + */ + public function testInvalidLength() + { + $handler = new ResponseBulkHandler(); + + $connection = $this->getMock('Predis\Connection\ComposableConnectionInterface'); + + $connection->expects($this->never())->method('readLine'); + $connection->expects($this->never())->method('readBytes'); + + $handler->handle($connection, 'invalid'); + } +} diff --git a/vendor/predis/predis/tests/Predis/Protocol/Text/ResponseErrorHandlerTest.php b/vendor/predis/predis/tests/Predis/Protocol/Text/ResponseErrorHandlerTest.php new file mode 100755 index 0000000..e6b0ef0 --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Protocol/Text/ResponseErrorHandlerTest.php @@ -0,0 +1,39 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Protocol\Text; + +use PredisTestCase; + +/** + * + */ +class ResponseErrorHandlerTest extends PredisTestCase +{ + /** + * @group disconnected + */ + public function testOk() + { + $handler = new ResponseErrorHandler(); + + $connection = $this->getMock('Predis\Connection\ComposableConnectionInterface'); + + $connection->expects($this->never())->method('readLine'); + $connection->expects($this->never())->method('readBytes'); + + $message = "ERR Operation against a key holding the wrong kind of value"; + $response = $handler->handle($connection, $message); + + $this->assertInstanceOf('Predis\ResponseError', $response); + $this->assertSame($message, $response->getMessage()); + } +} diff --git a/vendor/predis/predis/tests/Predis/Protocol/Text/ResponseIntegerHandlerTest.php b/vendor/predis/predis/tests/Predis/Protocol/Text/ResponseIntegerHandlerTest.php new file mode 100755 index 0000000..e30f011 --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Protocol/Text/ResponseIntegerHandlerTest.php @@ -0,0 +1,70 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Protocol\Text; + +use PredisTestCase; + +/** + * + */ +class ResponseIntegerHandlerTest extends PredisTestCase +{ + /** + * @group disconnected + */ + public function testInteger() + { + $handler = new ResponseIntegerHandler(); + + $connection = $this->getMock('Predis\Connection\ComposableConnectionInterface'); + + $connection->expects($this->never())->method('readLine'); + $connection->expects($this->never())->method('readBytes'); + + $this->assertSame(0, $handler->handle($connection, '0')); + $this->assertSame(1, $handler->handle($connection, '1')); + $this->assertSame(10, $handler->handle($connection, '10')); + $this->assertSame(-10, $handler->handle($connection, '-10')); + } + + /** + * @group disconnected + */ + public function testNull() + { + $handler = new ResponseIntegerHandler(); + + $connection = $this->getMock('Predis\Connection\ComposableConnectionInterface'); + + $connection->expects($this->never())->method('readLine'); + $connection->expects($this->never())->method('readBytes'); + + $this->assertNull($handler->handle($connection, 'nil')); + } + + /** + * @group disconnected + * @expectedException Predis\Protocol\ProtocolException + * @expectedExceptionMessage Cannot parse 'invalid' as numeric response + */ + public function testInvalid() + { + $handler = new ResponseIntegerHandler(); + + $connection = $this->getMock('Predis\Connection\ComposableConnectionInterface'); + + $connection->expects($this->never())->method('readLine'); + $connection->expects($this->never())->method('readBytes'); + + $handler->handle($connection, 'invalid'); + } +} diff --git a/vendor/predis/predis/tests/Predis/Protocol/Text/ResponseMultiBulkHandlerTest.php b/vendor/predis/predis/tests/Predis/Protocol/Text/ResponseMultiBulkHandlerTest.php new file mode 100755 index 0000000..d1964a8 --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Protocol/Text/ResponseMultiBulkHandlerTest.php @@ -0,0 +1,84 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Protocol\Text; + +use PredisTestCase; + +/** + * + */ +class ResponseMultiBulkHandlerTest extends PredisTestCase +{ + /** + * @group disconnected + */ + public function testMultiBulk() + { + $handler = new ResponseMultiBulkHandler(); + + $connection = $this->getMock('Predis\Connection\ComposableConnectionInterface'); + + $connection->expects($this->once()) + ->method('getProtocol') + ->will($this->returnValue(new ComposableTextProtocol())); + + $connection->expects($this->at(1)) + ->method('readLine') + ->will($this->returnValue("$3")); + + $connection->expects($this->at(2)) + ->method('readBytes') + ->will($this->returnValue("foo\r\n")); + + $connection->expects($this->at(3)) + ->method('readLine') + ->will($this->returnValue("$3")); + + $connection->expects($this->at(4)) + ->method('readBytes') + ->will($this->returnValue("bar\r\n")); + + $this->assertSame(array('foo', 'bar'), $handler->handle($connection, '2')); + } + + /** + * @group disconnected + */ + public function testNull() + { + $handler = new ResponseMultiBulkHandler(); + + $connection = $this->getMock('Predis\Connection\ComposableConnectionInterface'); + + $connection->expects($this->never())->method('readLine'); + $connection->expects($this->never())->method('readBytes'); + + $this->assertNull($handler->handle($connection, '-1')); + } + + /** + * @group disconnected + * @expectedException Predis\Protocol\ProtocolException + * @expectedExceptionMessage Cannot parse 'invalid' as multi-bulk length + */ + public function testInvalid() + { + $handler = new ResponseMultiBulkHandler(); + + $connection = $this->getMock('Predis\Connection\ComposableConnectionInterface'); + + $connection->expects($this->never())->method('readLine'); + $connection->expects($this->never())->method('readBytes'); + + $handler->handle($connection, 'invalid'); + } +} diff --git a/vendor/predis/predis/tests/Predis/Protocol/Text/ResponseMultiBulkStreamHandlerTest.php b/vendor/predis/predis/tests/Predis/Protocol/Text/ResponseMultiBulkStreamHandlerTest.php new file mode 100755 index 0000000..cd64704 --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Protocol/Text/ResponseMultiBulkStreamHandlerTest.php @@ -0,0 +1,52 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Protocol\Text; + +use PredisTestCase; + +/** + * + */ +class ResponseMultiBulkStreamHandlerTest extends PredisTestCase +{ + /** + * @group disconnected + */ + public function testOk() + { + $handler = new ResponseMultiBulkStreamHandler(); + + $connection = $this->getMock('Predis\Connection\ComposableConnectionInterface'); + + $connection->expects($this->never())->method('readLine'); + $connection->expects($this->never())->method('readBytes'); + + $this->assertInstanceOf('Predis\Iterator\MultiBulkResponseSimple', $handler->handle($connection, '1')); + } + + /** + * @group disconnected + * @expectedException Predis\Protocol\ProtocolException + * @expectedExceptionMessage Cannot parse 'invalid' as multi-bulk length + */ + public function testInvalid() + { + $handler = new ResponseMultiBulkStreamHandler(); + + $connection = $this->getMock('Predis\Connection\ComposableConnectionInterface'); + + $connection->expects($this->never())->method('readLine'); + $connection->expects($this->never())->method('readBytes'); + + $handler->handle($connection, 'invalid'); + } +} diff --git a/vendor/predis/predis/tests/Predis/Protocol/Text/ResponseStatusHandlerTest.php b/vendor/predis/predis/tests/Predis/Protocol/Text/ResponseStatusHandlerTest.php new file mode 100755 index 0000000..fabe14a --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Protocol/Text/ResponseStatusHandlerTest.php @@ -0,0 +1,66 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Protocol\Text; + +use PredisTestCase; +use Predis\ResponseQueued; + +/** + * + */ +class ResponseStatusHandlerTest extends PredisTestCase +{ + /** + * @group disconnected + */ + public function testOk() + { + $handler = new ResponseStatusHandler(); + + $connection = $this->getMock('Predis\Connection\ComposableConnectionInterface'); + + $connection->expects($this->never())->method('readLine'); + $connection->expects($this->never())->method('readBytes'); + + $this->assertTrue($handler->handle($connection, 'OK')); + } + + /** + * @group disconnected + */ + public function testQueued() + { + $handler = new ResponseStatusHandler(); + + $connection = $this->getMock('Predis\Connection\ComposableConnectionInterface'); + + $connection->expects($this->never())->method('readLine'); + $connection->expects($this->never())->method('readBytes'); + + $this->assertInstanceOf('Predis\ResponseQueued', $handler->handle($connection, 'QUEUED')); + } + + /** + * @group disconnected + */ + public function testPlainString() + { + $handler = new ResponseStatusHandler(); + + $connection = $this->getMock('Predis\Connection\ComposableConnectionInterface'); + + $connection->expects($this->never())->method('readLine'); + $connection->expects($this->never())->method('readBytes'); + + $this->assertSame('Background saving started', $handler->handle($connection, 'Background saving started')); + } +} diff --git a/vendor/predis/predis/tests/Predis/Protocol/Text/TextCommandSerializerTest.php b/vendor/predis/predis/tests/Predis/Protocol/Text/TextCommandSerializerTest.php new file mode 100755 index 0000000..5cba9ce --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Protocol/Text/TextCommandSerializerTest.php @@ -0,0 +1,64 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Protocol\Text; + +use PredisTestCase; + +/** + * + */ +class TextCommandSerializerTest extends PredisTestCase +{ + /** + * @group disconnected + */ + public function testSerializerIdWithNoArguments() + { + $serializer = new TextCommandSerializer(); + + $command = $this->getMock('Predis\Command\CommandInterface'); + + $command->expects($this->once()) + ->method('getId') + ->will($this->returnValue('PING')); + + $command->expects($this->once()) + ->method('getArguments') + ->will($this->returnValue(array())); + + $result = $serializer->serialize($command); + + $this->assertSame("*1\r\n$4\r\nPING\r\n", $result); + } + + /** + * @group disconnected + */ + public function testSerializerIdWithArguments() + { + $serializer = new TextCommandSerializer(); + + $command = $this->getMock('Predis\Command\CommandInterface'); + + $command->expects($this->once()) + ->method('getId') + ->will($this->returnValue('SET')); + + $command->expects($this->once()) + ->method('getArguments') + ->will($this->returnValue(array('key', 'value'))); + + $result = $serializer->serialize($command); + + $this->assertSame("*3\r\n$3\r\nSET\r\n$3\r\nkey\r\n$5\r\nvalue\r\n", $result); + } +} diff --git a/vendor/predis/predis/tests/Predis/Protocol/Text/TextProtocolTest.php b/vendor/predis/predis/tests/Predis/Protocol/Text/TextProtocolTest.php new file mode 100755 index 0000000..b1d643c --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Protocol/Text/TextProtocolTest.php @@ -0,0 +1,119 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Protocol\Text; + +use PredisTestCase; + +/** + * + */ +class TextProtocolTest extends PredisTestCase +{ + /** + * @group disconnected + */ + public function testConnectionWrite() + { + $serialized = "*1\r\n$4\r\nPING\r\n"; + $protocol = new TextProtocol(); + + $command = $this->getMock('Predis\Command\CommandInterface'); + + $command->expects($this->once()) + ->method('getId') + ->will($this->returnValue('PING')); + + $command->expects($this->once()) + ->method('getArguments') + ->will($this->returnValue(array())); + + $connection = $this->getMock('Predis\Connection\ComposableConnectionInterface'); + + $connection->expects($this->once()) + ->method('writeBytes') + ->with($this->equalTo($serialized)); + + $protocol->write($connection, $command); + } + + /** + * @todo Improve test coverage + * @group disconnected + */ + public function testConnectionRead() + { + $protocol = new TextProtocol(); + + $connection = $this->getMock('Predis\Connection\ComposableConnectionInterface'); + + $connection->expects($this->at(0)) + ->method('readLine') + ->will($this->returnValue("+OK")); + + $connection->expects($this->at(1)) + ->method('readLine') + ->will($this->returnValue("-ERR error message")); + + $connection->expects($this->at(2)) + ->method('readLine') + ->will($this->returnValue(":2")); + + $connection->expects($this->at(3)) + ->method('readLine') + ->will($this->returnValue("$-1")); + + $connection->expects($this->at(4)) + ->method('readLine') + ->will($this->returnValue("*-1")); + + $this->assertTrue($protocol->read($connection)); + $this->assertEquals("ERR error message", $protocol->read($connection)); + $this->assertSame(2, $protocol->read($connection)); + $this->assertNull($protocol->read($connection)); + $this->assertNull($protocol->read($connection)); + } + + /** + * @group disconnected + */ + public function testIterableMultibulkSupport() + { + $protocol = new TextProtocol(); + $protocol->setOption('iterable_multibulk', true); + + $connection = $this->getMock('Predis\Connection\ComposableConnectionInterface'); + + $connection->expects($this->once(4)) + ->method('readLine') + ->will($this->returnValue("*1")); + + $this->assertInstanceOf('Predis\Iterator\MultiBulkResponseSimple', $protocol->read($connection)); + } + + /** + * @group disconnected + * @expectedException Predis\Protocol\ProtocolException + * @expectedExceptionMessage Unknown prefix: '!' + */ + public function testUnknownResponsePrefix() + { + $protocol = new TextProtocol(); + + $connection = $this->getMock('Predis\Connection\ComposableConnectionInterface'); + + $connection->expects($this->once()) + ->method('readLine') + ->will($this->returnValue('!')); + + $protocol->read($connection); + } +} diff --git a/vendor/predis/predis/tests/Predis/Protocol/Text/TextResponseReaderTest.php b/vendor/predis/predis/tests/Predis/Protocol/Text/TextResponseReaderTest.php new file mode 100755 index 0000000..a47fd35 --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Protocol/Text/TextResponseReaderTest.php @@ -0,0 +1,123 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Protocol\Text; + +use PredisTestCase; + +/** + * + */ +class TextResponseReaderTest extends PredisTestCase +{ + /** + * @group disconnected + */ + public function testDefaultHandlers() + { + $reader = new TextResponseReader(); + + $this->assertInstanceOf('Predis\Protocol\Text\ResponseStatusHandler', $reader->getHandler('+')); + $this->assertInstanceOf('Predis\Protocol\Text\ResponseErrorHandler', $reader->getHandler('-')); + $this->assertInstanceOf('Predis\Protocol\Text\ResponseIntegerHandler', $reader->getHandler(':')); + $this->assertInstanceOf('Predis\Protocol\Text\ResponseBulkHandler', $reader->getHandler('$')); + $this->assertInstanceOf('Predis\Protocol\Text\ResponseMultiBulkHandler', $reader->getHandler('*')); + + $this->assertNull($reader->getHandler('!')); + } + + /** + * @group disconnected + */ + public function testReplaceHandler() + { + $handler = $this->getMock('Predis\Protocol\ResponseHandlerInterface'); + + $reader = new TextResponseReader(); + $reader->setHandler('+', $handler); + + $this->assertSame($handler, $reader->getHandler('+')); + } + + /** + * @group disconnected + */ + public function testReadResponse() + { + $reader = new TextResponseReader(); + + $protocol = new ComposableTextProtocol(); + $protocol->setReader($reader); + + $connection = $this->getMock('Predis\Connection\ComposableConnectionInterface'); + + $connection->expects($this->at(0)) + ->method('readLine') + ->will($this->returnValue("+OK")); + + $connection->expects($this->at(1)) + ->method('readLine') + ->will($this->returnValue("-ERR error message")); + + $connection->expects($this->at(2)) + ->method('readLine') + ->will($this->returnValue(":2")); + + $connection->expects($this->at(3)) + ->method('readLine') + ->will($this->returnValue("$-1")); + + $connection->expects($this->at(4)) + ->method('readLine') + ->will($this->returnValue("*-1")); + + $this->assertTrue($reader->read($connection)); + $this->assertEquals("ERR error message", $reader->read($connection)); + $this->assertSame(2, $reader->read($connection)); + $this->assertNull($reader->read($connection)); + $this->assertNull($reader->read($connection)); + } + + /** + * @group disconnected + * @expectedException Predis\Protocol\ProtocolException + * @expectedExceptionMessage Unexpected empty header + */ + public function testEmptyResponseHeader() + { + $reader = new TextResponseReader(); + + $connection = $this->getMock('Predis\Connection\ComposableConnectionInterface'); + + $connection->expects($this->once()) + ->method('readLine') + ->will($this->returnValue('')); + + $reader->read($connection); + } + /** + * @group disconnected + * @expectedException Predis\Protocol\ProtocolException + * @expectedExceptionMessage Unknown prefix: '!' + */ + public function testUnknownResponsePrefix() + { + $reader = new TextResponseReader(); + + $connection = $this->getMock('Predis\Connection\ComposableConnectionInterface'); + + $connection->expects($this->once()) + ->method('readLine') + ->will($this->returnValue('!')); + + $reader->read($connection); + } +} diff --git a/vendor/predis/predis/tests/Predis/PubSub/DispatcherLoopTest.php b/vendor/predis/predis/tests/Predis/PubSub/DispatcherLoopTest.php new file mode 100755 index 0000000..e92c894 --- /dev/null +++ b/vendor/predis/predis/tests/Predis/PubSub/DispatcherLoopTest.php @@ -0,0 +1,125 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\PubSub; + +use PredisTestCase; +use Predis\Client; + +/** + * @group realm-pubsub + */ +class DispatcherLoopTest extends PredisTestCase +{ + // ******************************************************************** // + // ---- INTEGRATION TESTS --------------------------------------------- // + // ******************************************************************** // + + /** + * @group connected + */ + public function testDispatcherLoopAgainstRedisServer() + { + $parameters = array( + 'host' => REDIS_SERVER_HOST, + 'port' => REDIS_SERVER_PORT, + 'database' => REDIS_SERVER_DBNUM, + // Prevents suite from handing on broken test + 'read_write_timeout' => 2, + ); + + $options = array('profile' => REDIS_SERVER_VERSION); + + $producer = new Client($parameters, $options); + $producer->connect(); + + $consumer = new Client($parameters, $options); + $consumer->connect(); + + $dispatcher = new DispatcherLoop($consumer); + + $function01 = $this->getMock('stdClass', array('__invoke')); + $function01->expects($this->exactly(2)) + ->method('__invoke') + ->with($this->logicalOr( + $this->equalTo('01:argument'), + $this->equalTo('01:quit') + )) + ->will($this->returnCallback(function ($arg) use ($dispatcher) { + if ($arg === '01:quit') { + $dispatcher->stop(); + } + })); + + $function02 = $this->getMock('stdClass', array('__invoke')); + $function02->expects($this->once()) + ->method('__invoke') + ->with('02:argument'); + + $function03 = $this->getMock('stdClass', array('__invoke')); + $function03->expects($this->never()) + ->method('__invoke'); + + $dispatcher->attachCallback('function:01', $function01); + $dispatcher->attachCallback('function:02', $function02); + $dispatcher->attachCallback('function:03', $function03); + + $producer->publish('function:01', '01:argument'); + $producer->publish('function:02', '02:argument'); + $producer->publish('function:01', '01:quit'); + + $dispatcher->run(); + + $this->assertTrue($consumer->ping()); + } + + /** + * @group connected + */ + public function testDispatcherLoopAgainstRedisServerWithPrefix() + { + $parameters = array( + 'host' => REDIS_SERVER_HOST, + 'port' => REDIS_SERVER_PORT, + 'database' => REDIS_SERVER_DBNUM, + // Prevents suite from handing on broken test + 'read_write_timeout' => 2, + ); + + $options = array('profile' => REDIS_SERVER_VERSION); + + $producerNonPfx = new Client($parameters, $options); + $producerNonPfx->connect(); + + $producerPfx = new Client($parameters, $options + array('prefix' => 'foobar')); + $producerPfx->connect(); + + $consumer = new Client($parameters, $options + array('prefix' => 'foobar')); + $dispatcher = new DispatcherLoop($consumer); + + $callback = $this->getMock('stdClass', array('__invoke')); + $callback->expects($this->exactly(1)) + ->method('__invoke') + ->with($this->equalTo('arg:prefixed')) + ->will($this->returnCallback(function ($arg) use ($dispatcher) { + $dispatcher->stop(); + })); + + $dispatcher->attachCallback('callback', $callback); + + $producerNonPfx->publish('callback', 'arg:non-prefixed'); + $producerPfx->publish('callback', 'arg:prefixed'); + + $dispatcher->run(); + + $this->assertTrue($consumer->ping()); + } +} diff --git a/vendor/predis/predis/tests/Predis/PubSub/PubSubContextTest.php b/vendor/predis/predis/tests/Predis/PubSub/PubSubContextTest.php new file mode 100755 index 0000000..1cbe8af --- /dev/null +++ b/vendor/predis/predis/tests/Predis/PubSub/PubSubContextTest.php @@ -0,0 +1,307 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\PubSub; + +use PredisTestCase; +use Predis\Client; +use Predis\Profile\ServerProfile; + +/** + * @group realm-pubsub + */ +class PubSubContextTest extends PredisTestCase +{ + /** + * @group disconnected + * @expectedException Predis\NotSupportedException + * @expectedExceptionMessage The current profile does not support PUB/SUB related commands + */ + public function testPubSubContextRequirePubSubRelatedCommand() + { + $profile = $this->getMock('Predis\Profile\ServerProfileInterface'); + $profile->expects($this->any()) + ->method('supportsCommands') + ->will($this->returnValue(false)); + + $client = new Client(null, array('profile' => $profile)); + $pubsub = new PubSubContext($client); + } + + /** + * @group disconnected + * @expectedException Predis\NotSupportedException + * @expectedExceptionMessage Cannot initialize a PUB/SUB context when using aggregated connections + */ + public function testPubSubContextDoesNotWorkOnClusters() + { + $cluster = $this->getMock('Predis\Connection\ClusterConnectionInterface'); + + $client = new Client($cluster); + $pubsub = new PubSubContext($client); + } + + /** + * @group disconnected + */ + public function testConstructorWithoutSubscriptionsDoesNotOpenContext() + { + $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); + + $client = $this->getMock('Predis\Client', array('executeCommand'), array($connection)); + $client->expects($this->never())->method('executeCommand'); + + $pubsub = new PubSubContext($client); + } + + /** + * @group disconnected + */ + public function testConstructorWithSubscriptionsOpensContext() + { + $profile = ServerProfile::get(REDIS_SERVER_VERSION); + + $cmdSubscribe = $profile->createCommand('subscribe', array('channel:foo')); + $cmdPsubscribe = $profile->createCommand('psubscribe', array('channels:*')); + + $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); + $connection->expects($this->exactly(2))->method('writeCommand'); + + $client = $this->getMock('Predis\Client', array('createCommand', 'writeCommand'), array($connection)); + $client->expects($this->exactly(2)) + ->method('createCommand') + ->with($this->logicalOr($this->equalTo('subscribe'), $this->equalTo('psubscribe'))) + ->will($this->returnCallback(function ($id, $args) use ($profile) { + return $profile->createCommand($id, $args); + })); + + $options = array('subscribe' => 'channel:foo', 'psubscribe' => 'channels:*'); + $pubsub = new PubSubContext($client, $options); + } + + /** + * @group disconnected + */ + public function testClosingContextWithTrueClosesConnection() + { + $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); + + $client = $this->getMock('Predis\Client', array('disconnect'), array($connection)); + $client->expects($this->exactly(1))->method('disconnect'); + + $pubsub = new PubSubContext($client, array('subscribe' => 'channel:foo')); + + $connection->expects($this->never())->method('writeCommand'); + + $pubsub->closeContext(true); + } + + /** + * @group disconnected + */ + public function testClosingContextWithFalseSendsUnsubscriptions() + { + $profile = ServerProfile::get(REDIS_SERVER_VERSION); + $classUnsubscribe = $profile->getCommandClass('unsubscribe'); + $classPunsubscribe = $profile->getCommandClass('punsubscribe'); + + $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); + + $client = $this->getMock('Predis\Client', array('disconnect'), array($connection)); + + $options = array('subscribe' => 'channel:foo', 'psubscribe' => 'channels:*'); + $pubsub = new PubSubContext($client, $options); + + $connection->expects($this->exactly(2)) + ->method('writeCommand') + ->with($this->logicalOr( + $this->isInstanceOf($classUnsubscribe), + $this->isInstanceOf($classPunsubscribe) + )); + + $pubsub->closeContext(false); + } + + /** + * @group disconnected + */ + public function testIsNotValidWhenNotSubscribed() + { + $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); + $client = $this->getMock('Predis\Client', array('disconnect'), array($connection)); + + $pubsub = new PubSubContext($client); + + $this->assertFalse($pubsub->valid()); + $this->assertNull($pubsub->next()); + } + + /** + * @group disconnected + */ + public function testReadsMessageFromConnection() + { + $rawmessage = array('message', 'channel:foo', 'message from channel'); + + $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); + $connection->expects($this->once())->method('read')->will($this->returnValue($rawmessage)); + + $client = new Client($connection); + $pubsub = new PubSubContext($client, array('subscribe' => 'channel:foo')); + + $message = $pubsub->current(); + $this->assertSame('message', $message->kind); + $this->assertSame('channel:foo', $message->channel); + $this->assertSame('message from channel', $message->payload); + } + + /** + * @group disconnected + */ + public function testReadsPmessageFromConnection() + { + $rawmessage = array('pmessage', 'channel:*', 'channel:foo', 'message from channel'); + + $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); + $connection->expects($this->once())->method('read')->will($this->returnValue($rawmessage)); + + $client = new Client($connection); + $pubsub = new PubSubContext($client, array('psubscribe' => 'channel:*')); + + $message = $pubsub->current(); + $this->assertSame('pmessage', $message->kind); + $this->assertSame('channel:*', $message->pattern); + $this->assertSame('channel:foo', $message->channel); + $this->assertSame('message from channel', $message->payload); + } + + /** + * @group disconnected + */ + public function testReadsSubscriptionMessageFromConnection() + { + $rawmessage = array('subscribe', 'channel:foo', 1); + + $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); + $connection->expects($this->once())->method('read')->will($this->returnValue($rawmessage)); + + $client = new Client($connection); + $pubsub = new PubSubContext($client, array('subscribe' => 'channel:foo')); + + $message = $pubsub->current(); + $this->assertSame('subscribe', $message->kind); + $this->assertSame('channel:foo', $message->channel); + $this->assertSame(1, $message->payload); + } + + /** + * @group disconnected + */ + public function testReadsUnsubscriptionMessageFromConnection() + { + $rawmessage = array('unsubscribe', 'channel:foo', 1); + + $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); + $connection->expects($this->once())->method('read')->will($this->returnValue($rawmessage)); + + $client = new Client($connection); + $pubsub = new PubSubContext($client, array('subscribe' => 'channel:foo')); + + $message = $pubsub->current(); + $this->assertSame('unsubscribe', $message->kind); + $this->assertSame('channel:foo', $message->channel); + $this->assertSame(1, $message->payload); + } + + /** + * @group disconnected + */ + public function testUnsubscriptionMessageWithZeroChannelCountInvalidatesContext() + { + $rawmessage = array('unsubscribe', 'channel:foo', 0); + + $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); + $connection->expects($this->once())->method('read')->will($this->returnValue($rawmessage)); + + $client = new Client($connection); + $pubsub = new PubSubContext($client, array('subscribe' => 'channel:foo')); + + $this->assertTrue($pubsub->valid()); + + $message = $pubsub->current(); + $this->assertSame('unsubscribe', $message->kind); + $this->assertSame('channel:foo', $message->channel); + $this->assertSame(0, $message->payload); + + $this->assertFalse($pubsub->valid()); + } + + /** + * @group disconnected + */ + public function testGetUnderlyingClientInstance() + { + $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); + + $client = new Client($connection); + $pubsub = new PubSubContext($client); + + $this->assertSame($client, $pubsub->getClient()); + } + + // ******************************************************************** // + // ---- INTEGRATION TESTS --------------------------------------------- // + // ******************************************************************** // + + /** + * @group connected + */ + public function testPubSubAgainstRedisServer() + { + $parameters = array( + 'host' => REDIS_SERVER_HOST, + 'port' => REDIS_SERVER_PORT, + 'database' => REDIS_SERVER_DBNUM, + // Prevents suite from handing on broken test + 'read_write_timeout' => 2, + ); + + $options = array('profile' => REDIS_SERVER_VERSION); + $messages = array(); + + $producer = new Client($parameters, $options); + $producer->connect(); + + $consumer = new Client($parameters, $options); + $consumer->connect(); + + $pubsub = new PubSubContext($consumer); + $pubsub->subscribe('channel:foo'); + + $producer->publish('channel:foo', 'message1'); + $producer->publish('channel:foo', 'message2'); + $producer->publish('channel:foo', 'QUIT'); + + foreach ($pubsub as $message) { + if ($message->kind !== 'message') { + continue; + } + $messages[] = ($payload = $message->payload); + if ($payload === 'QUIT') { + $pubsub->closeContext(); + } + } + + $this->assertSame(array('message1', 'message2', 'QUIT'), $messages); + $this->assertFalse($pubsub->valid()); + $this->assertTrue($consumer->ping()); + } +} diff --git a/vendor/predis/predis/tests/Predis/Replication/ReplicationStrategyTest.php b/vendor/predis/predis/tests/Predis/Replication/ReplicationStrategyTest.php new file mode 100755 index 0000000..474e95e --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Replication/ReplicationStrategyTest.php @@ -0,0 +1,373 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Replication; + +use PredisTestCase; +use Predis\Profile\ServerProfile; + +/** + * + */ +class ReplicationStrategyTest extends PredisTestCase +{ + /** + * @group disconnected + */ + public function testReadCommands() + { + $profile = ServerProfile::getDevelopment(); + $strategy = new ReplicationStrategy(); + + foreach ($this->getExpectedCommands('read') as $commandId) { + $command = $profile->createCommand($commandId); + $this->assertTrue($strategy->isReadOperation($command)); + } + } + + /** + * @group disconnected + */ + public function testWriteCommands() + { + $profile = ServerProfile::getDevelopment(); + $strategy = new ReplicationStrategy(); + + foreach ($this->getExpectedCommands('write') as $commandId) { + $command = $profile->createCommand($commandId); + $this->assertFalse($strategy->isReadOperation($command), $commandId); + } + } + + /** + * @group disconnected + */ + public function testDisallowedCommands() + { + $profile = ServerProfile::getDevelopment(); + $strategy = new ReplicationStrategy(); + + foreach ($this->getExpectedCommands('disallowed') as $commandId) { + $command = $profile->createCommand($commandId); + $this->assertTrue($strategy->isDisallowedOperation($command), $commandId); + } + } + + /** + * @group disconnected + */ + public function testSortCommand() + { + $profile = ServerProfile::getDevelopment(); + $strategy = new ReplicationStrategy(); + + $cmdReadSort = $profile->createCommand('SORT', array('key:list')); + $this->assertTrue($strategy->isReadOperation($cmdReadSort), 'SORT [read-only]'); + + $cmdWriteSort = $profile->createCommand('SORT', array('key:list', array('store' => 'key:stored'))); + $this->assertFalse($strategy->isReadOperation($cmdWriteSort), 'SORT [write with STORE]'); + } + + /** + * @group disconnected + * @expectedException Predis\NotSupportedException + * @expectedExceptionMessage The command INFO is not allowed in replication mode + */ + public function testUsingDisallowedCommandThrowsException() + { + $profile = ServerProfile::getDevelopment(); + $strategy = new ReplicationStrategy(); + + $command = $profile->createCommand('INFO'); + $strategy->isReadOperation($command); + } + + /** + * @group disconnected + */ + public function testDefaultIsWriteOperation() + { + $strategy = new ReplicationStrategy(); + + $command = $this->getMock('Predis\Command\CommandInterface'); + $command->expects($this->any()) + ->method('getId') + ->will($this->returnValue('CMDTEST')); + + $this->assertFalse($strategy->isReadOperation($command)); + } + + /** + * @group disconnected + */ + public function testCanSetCommandAsReadOperation() + { + $strategy = new ReplicationStrategy(); + + $command = $this->getMock('Predis\Command\CommandInterface'); + $command->expects($this->any()) + ->method('getId') + ->will($this->returnValue('CMDTEST')); + + $strategy->setCommandReadOnly('CMDTEST', true); + $this->assertTrue($strategy->isReadOperation($command)); + } + + /** + * @group disconnected + */ + public function testCanSetCommandAsWriteOperation() + { + $strategy = new ReplicationStrategy(); + + $command = $this->getMock('Predis\Command\CommandInterface'); + $command->expects($this->any()) + ->method('getId') + ->will($this->returnValue('CMDTEST')); + + $strategy->setCommandReadOnly('CMDTEST', false); + $this->assertFalse($strategy->isReadOperation($command)); + + $strategy->setCommandReadOnly('GET', false); + $this->assertFalse($strategy->isReadOperation($command)); + } + + /** + * @group disconnected + */ + public function testCanUseCallableToCheckCommand() + { + $strategy = new ReplicationStrategy(); + $profile = ServerProfile::getDevelopment(); + + $strategy->setCommandReadOnly('SET', function ($command) { + return $command->getArgument(1) === true; + }); + + $command = $profile->createCommand('SET', array('trigger', false)); + $this->assertFalse($strategy->isReadOperation($command)); + + $command = $profile->createCommand('SET', array('trigger', true)); + $this->assertTrue($strategy->isReadOperation($command)); + } + + /** + * @group disconnected + */ + public function testSetLuaScriptAsReadOperation() + { + $strategy = new ReplicationStrategy(); + $profile = ServerProfile::getDevelopment(); + + $writeScript = 'redis.call("set", "foo", "bar")'; + $readScript = 'return true'; + + $strategy->setScriptReadOnly($readScript, true); + + $cmdEval = $profile->createCommand('EVAL', array($writeScript)); + $cmdEvalSHA = $profile->createCommand('EVALSHA', array(sha1($writeScript))); + $this->assertFalse($strategy->isReadOperation($cmdEval)); + $this->assertFalse($strategy->isReadOperation($cmdEvalSHA)); + + $cmdEval = $profile->createCommand('EVAL', array($readScript)); + $cmdEvalSHA = $profile->createCommand('EVALSHA', array(sha1($readScript))); + $this->assertTrue($strategy->isReadOperation($cmdEval)); + $this->assertTrue($strategy->isReadOperation($cmdEvalSHA)); + } + + /** + * @group disconnected + */ + public function testSetLuaScriptAsReadOperationWorksWithScriptedCommand() + { + $strategy = new ReplicationStrategy(); + + $command = $this->getMock('Predis\Command\ScriptedCommand', array('getScript')); + $command->expects($this->any()) + ->method('getScript') + ->will($this->returnValue($script = 'return true')); + + $strategy->setScriptReadOnly($script, function ($command) { + return $command->getArgument(2) === true; + }); + + $command->setArguments(array(false)); + $this->assertFalse($strategy->isReadOperation($command)); + + $command->setArguments(array(true)); + $this->assertTrue($strategy->isReadOperation($command)); + } + + /** + * @group disconnected + */ + public function testSetLuaScriptAsReadOperationWorksWithScriptedCommandAndCallableCheck() + { + $strategy = new ReplicationStrategy(); + + $command = $this->getMock('Predis\Command\ScriptedCommand', array('getScript')); + $command->expects($this->any()) + ->method('getScript') + ->will($this->returnValue($script = 'return true')); + + $command->setArguments(array('trigger', false)); + + $strategy->setScriptReadOnly($script, true); + + $this->assertTrue($strategy->isReadOperation($command)); + } + + // ******************************************************************** // + // ---- HELPER METHODS ------------------------------------------------ // + // ******************************************************************** // + + /** + * Returns the list of expected supported commands. + * + * @param string $type Optional type of command (based on its keys) + * @return array + */ + protected function getExpectedCommands($type = null) + { + $commands = array( + /* commands operating on the connection */ + 'AUTH' => 'read', + 'SELECT' => 'read', + 'ECHO' => 'read', + 'QUIT' => 'read', + 'OBJECT' => 'read', + 'BITCOUNT' => 'read', + 'TIME' => 'read', + 'SHUTDOWN' => 'disallowed', + 'INFO' => 'disallowed', + 'DBSIZE' => 'disallowed', + 'LASTSAVE' => 'disallowed', + 'CONFIG' => 'disallowed', + 'MONITOR' => 'disallowed', + 'SLAVEOF' => 'disallowed', + 'SAVE' => 'disallowed', + 'BGSAVE' => 'disallowed', + 'BGREWRITEAOF' => 'disallowed', + 'SLOWLOG' => 'disallowed', + + /* commands operating on the key space */ + 'EXISTS' => 'read', + 'DEL' => 'write', + 'TYPE' => 'read', + 'EXPIRE' => 'write', + 'EXPIREAT' => 'write', + 'PERSIST' => 'write', + 'PEXPIRE' => 'write', + 'PEXPIREAT' => 'write', + 'TTL' => 'read', + 'PTTL' => 'write', + 'SORT' => 'variable', + 'KEYS' => 'read', + 'SCAN' => 'read', + 'RANDOMKEY' => 'read', + + /* commands operating on string values */ + 'APPEND' => 'write', + 'DECR' => 'write', + 'DECRBY' => 'write', + 'GET' => 'read', + 'GETBIT' => 'read', + 'MGET' => 'read', + 'SET' => 'write', + 'GETRANGE' => 'read', + 'GETSET' => 'write', + 'INCR' => 'write', + 'INCRBY' => 'write', + 'SETBIT' => 'write', + 'SETEX' => 'write', + 'MSET' => 'write', + 'MSETNX' => 'write', + 'SETNX' => 'write', + 'SETRANGE' => 'write', + 'STRLEN' => 'read', + 'SUBSTR' => 'read', + + /* commands operating on lists */ + 'LINSERT' => 'write', + 'LINDEX' => 'read', + 'LLEN' => 'read', + 'LPOP' => 'write', + 'RPOP' => 'write', + 'BLPOP' => 'write', + 'BRPOP' => 'write', + 'LPUSH' => 'write', + 'LPUSHX' => 'write', + 'RPUSH' => 'write', + 'RPUSHX' => 'write', + 'LRANGE' => 'read', + 'LREM' => 'write', + 'LSET' => 'write', + 'LTRIM' => 'write', + + /* commands operating on sets */ + 'SADD' => 'write', + 'SCARD' => 'read', + 'SISMEMBER' => 'read', + 'SMEMBERS' => 'read', + 'SSCAN' => 'read', + 'SRANDMEMBER' => 'read', + 'SPOP' => 'write', + 'SREM' => 'write', + 'SINTER' => 'read', + 'SUNION' => 'read', + 'SDIFF' => 'read', + + /* commands operating on sorted sets */ + 'ZADD' => 'write', + 'ZCARD' => 'read', + 'ZCOUNT' => 'read', + 'ZINCRBY' => 'write', + 'ZRANGE' => 'read', + 'ZRANGEBYSCORE' => 'read', + 'ZRANK' => 'read', + 'ZREM' => 'write', + 'ZREMRANGEBYRANK' => 'write', + 'ZREMRANGEBYSCORE' => 'write', + 'ZREVRANGE' => 'read', + 'ZREVRANGEBYSCORE' => 'read', + 'ZREVRANK' => 'read', + 'ZSCORE' => 'read', + 'ZSCAN' => 'read', + + /* commands operating on hashes */ + 'HDEL' => 'write', + 'HEXISTS' => 'read', + 'HGET' => 'read', + 'HGETALL' => 'read', + 'HMGET' => 'read', + 'HINCRBY' => 'write', + 'HINCRBYFLOAT' => 'write', + 'HKEYS' => 'read', + 'HLEN' => 'read', + 'HSET' => 'write', + 'HSETNX' => 'write', + 'HVALS' => 'read', + 'HSCAN' => 'read', + + /* scripting */ + 'EVAL' => 'write', + 'EVALSHA' => 'write', + ); + + if (isset($type)) { + $commands = array_filter($commands, function ($expectedType) use ($type) { + return $expectedType === $type; + }); + } + + return array_keys($commands); + } +} diff --git a/vendor/predis/predis/tests/Predis/ResponseErrorTest.php b/vendor/predis/predis/tests/Predis/ResponseErrorTest.php new file mode 100755 index 0000000..b3a1f67 --- /dev/null +++ b/vendor/predis/predis/tests/Predis/ResponseErrorTest.php @@ -0,0 +1,63 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis; + +use PredisTestCase; + +/** + * + */ +class ResponseErrorTest extends PredisTestCase +{ + const ERR_WRONG_KEY_TYPE = 'ERR Operation against a key holding the wrong kind of value'; + + /** + * @group disconnected + */ + public function testResponseErrorClass() + { + $error = new ResponseError(self::ERR_WRONG_KEY_TYPE); + + $this->assertInstanceOf('Predis\ResponseErrorInterface', $error); + $this->assertInstanceOf('Predis\ResponseObjectInterface', $error); + } + + /** + * @group disconnected + */ + public function testErrorMessage() + { + $error = new ResponseError(self::ERR_WRONG_KEY_TYPE); + + $this->assertEquals(self::ERR_WRONG_KEY_TYPE, $error->getMessage()); + } + + /** + * @group disconnected + */ + public function testErrorType() + { + $exception = new ResponseError(self::ERR_WRONG_KEY_TYPE); + + $this->assertEquals('ERR', $exception->getErrorType()); + } + + /** + * @group disconnected + */ + public function testToString() + { + $error = new ResponseError(self::ERR_WRONG_KEY_TYPE); + + $this->assertEquals(self::ERR_WRONG_KEY_TYPE, (string) $error); + } +} diff --git a/vendor/predis/predis/tests/Predis/ResponseQueuedTest.php b/vendor/predis/predis/tests/Predis/ResponseQueuedTest.php new file mode 100755 index 0000000..4b2b4c7 --- /dev/null +++ b/vendor/predis/predis/tests/Predis/ResponseQueuedTest.php @@ -0,0 +1,51 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis; + +use PredisTestCase; + +/** + * + */ +class ResponseQueuedTest extends PredisTestCase +{ + /** + * @group disconnected + */ + public function testResponseQueuedClass() + { + $queued = new ResponseQueued(); + + $this->assertInstanceOf('Predis\ResponseObjectInterface', $queued); + } + + /** + * @group disconnected + */ + public function testToString() + { + $queued = new ResponseQueued(); + + $this->assertEquals('QUEUED', (string) $queued); + } + + /** + * @group disconnected + */ + public function testQueuedProperty() + { + $queued = new ResponseQueued(); + + $this->assertTrue(isset($queued->queued)); + $this->assertTrue($queued->queued); + } +} diff --git a/vendor/predis/predis/tests/Predis/ServerExceptionTest.php b/vendor/predis/predis/tests/Predis/ServerExceptionTest.php new file mode 100755 index 0000000..d9aa7a1 --- /dev/null +++ b/vendor/predis/predis/tests/Predis/ServerExceptionTest.php @@ -0,0 +1,69 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis; + +use PredisTestCase; + +/** + * + */ +class ServerExceptionTest extends PredisTestCase +{ + const ERR_WRONG_KEY_TYPE = 'ERR Operation against a key holding the wrong kind of value'; + + /** + * @group disconnected + */ + public function testExceptionMessage() + { + $this->setExpectedException('Predis\ServerException', self::ERR_WRONG_KEY_TYPE); + + throw new ServerException(self::ERR_WRONG_KEY_TYPE); + } + + /** + * @group disconnected + */ + public function testExceptionClass() + { + $exception = new ServerException(self::ERR_WRONG_KEY_TYPE); + + $this->assertInstanceOf('Predis\ServerException', $exception); + $this->assertInstanceOf('Predis\ResponseErrorInterface', $exception); + $this->assertInstanceOf('Predis\ResponseObjectInterface', $exception); + $this->assertInstanceOf('Predis\PredisException', $exception); + } + + /** + * @group disconnected + */ + public function testErrorType() + { + $exception = new ServerException(self::ERR_WRONG_KEY_TYPE); + + $this->assertEquals('ERR', $exception->getErrorType()); + } + + /** + * @group disconnected + */ + public function testToResponseError() + { + $exception = new ServerException(self::ERR_WRONG_KEY_TYPE); + $error = $exception->toResponseError(); + + $this->assertInstanceOf('Predis\ResponseError', $error); + + $this->assertEquals($exception->getMessage(), $error->getMessage()); + $this->assertEquals($exception->getErrorType(), $error->getErrorType()); + } +} diff --git a/vendor/predis/predis/tests/Predis/Transaction/AbortedMultiExecExceptionTest.php b/vendor/predis/predis/tests/Predis/Transaction/AbortedMultiExecExceptionTest.php new file mode 100755 index 0000000..fc10e92 --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Transaction/AbortedMultiExecExceptionTest.php @@ -0,0 +1,35 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Transaction; + +use PredisTestCase; +use Predis\Client; + +/** + * + */ +class AbortedMultiExecExceptionTest extends PredisTestCase +{ + /** + * @group disconnected + */ + public function testExceptionClass() + { + $client = new Client(); + $transaction = new MultiExecContext($client); + $exception = new AbortedMultiExecException($transaction, 'ABORTED'); + + $this->assertInstanceOf('Predis\PredisException', $exception); + $this->assertSame('ABORTED', $exception->getMessage()); + $this->assertSame($transaction, $exception->getTransaction()); + } +} diff --git a/vendor/predis/predis/tests/Predis/Transaction/MultiExecContextTest.php b/vendor/predis/predis/tests/Predis/Transaction/MultiExecContextTest.php new file mode 100755 index 0000000..6ae5553 --- /dev/null +++ b/vendor/predis/predis/tests/Predis/Transaction/MultiExecContextTest.php @@ -0,0 +1,778 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Predis\Transaction; + +use PredisTestCase; +use Predis\Client; +use Predis\ResponseQueued; +use Predis\ServerException; +use Predis\Command\CommandInterface; + +/** + * @group realm-transaction + */ +class MultiExecContextTest extends PredisTestCase +{ + /** + * @group disconnected + * @expectedException Predis\NotSupportedException + * @expectedExceptionMessage The current profile does not support MULTI, EXEC and DISCARD + */ + public function testThrowsExceptionOnUnsupportedMultiExecInProfile() + { + $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); + $client = new Client($connection, array('profile' => '1.2')); + $tx = new MultiExecContext($client); + } + + /** + * @group disconnected + * @expectedException Predis\NotSupportedException + * @expectedExceptionMessage The current profile does not support WATCH and UNWATCH + */ + public function testThrowsExceptionOnUnsupportedWatchUnwatchInProfile() + { + $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); + $client = new Client($connection, array('profile' => '2.0')); + $tx = new MultiExecContext($client, array('options' => 'cas')); + + $tx->watch('foo'); + } + + /** + * @group disconnected + */ + public function testExecutionWithFluentInterface() + { + $commands = array(); + $expected = array('one', 'two', 'three'); + + $callback = $this->getExecuteCallback($expected, $commands); + $tx = $this->getMockedTransaction($callback); + + $this->assertSame($expected, $tx->echo('one')->echo('two')->echo('three')->execute()); + $this->assertSame(array('MULTI', 'ECHO', 'ECHO', 'ECHO', 'EXEC'), self::commandsToIDs($commands)); + } + + /** + * @group disconnected + */ + public function testExecutionWithCallable() + { + $commands = array(); + $expected = array('one', 'two', 'three'); + + $callback = $this->getExecuteCallback($expected, $commands); + $tx = $this->getMockedTransaction($callback); + + $replies = $tx->execute(function ($tx) { + $tx->echo('one'); + $tx->echo('two'); + $tx->echo('three'); + }); + + $this->assertSame($expected, $replies); + $this->assertSame(array('MULTI', 'ECHO', 'ECHO', 'ECHO', 'EXEC'), self::commandsToIDs($commands)); + } + + /** + * @group disconnected + */ + public function testCannotMixExecutionWithFluentInterfaceAndCallable() + { + $exception = null; + + $commands = array(); + + $callback = $this->getExecuteCallback(null, $commands); + $tx = $this->getMockedTransaction($callback); + + $exception = null; + + try { + $tx->echo('foo')->execute(function ($tx) { + $tx->echo('bar'); + }); + } catch (\Exception $exception) { + // NOOP + } + + $this->assertInstanceOf('Predis\ClientException', $exception); + $this->assertSame(array('MULTI', 'ECHO', 'DISCARD'), self::commandsToIDs($commands)); + } + + /** + * @group disconnected + */ + public function testEmptyTransactionDoesNotSendMultiExecCommands() + { + $commands = array(); + + $callback = $this->getExecuteCallback(null, $commands); + $tx = $this->getMockedTransaction($callback); + + $replies = $tx->execute(function ($tx) { + // NOOP + }); + + $this->assertNull($replies); + $this->assertSame(array(), self::commandsToIDs($commands)); + } + + /** + * @group disconnected + * @expectedException Predis\ClientException + * @expectedExceptionMessage Cannot invoke 'execute' or 'exec' inside an active client transaction block + */ + public function testThrowsExceptionOnExecInsideTransactionBlock() + { + $commands = array(); + + $callback = $this->getExecuteCallback(null, $commands); + $tx = $this->getMockedTransaction($callback); + + $replies = $tx->execute(function ($tx) { + $tx->exec(); + }); + + $this->assertNull($replies); + $this->assertSame(array(), self::commandsToIDs($commands)); + } + + /** + * @group disconnected + */ + public function testEmptyTransactionIgnoresDiscard() + { + $commands = array(); + + $callback = $this->getExecuteCallback(null, $commands); + $tx = $this->getMockedTransaction($callback); + + $replies = $tx->execute(function ($tx) { + $tx->discard(); + }); + + $this->assertNull($replies); + $this->assertSame(array(), self::commandsToIDs($commands)); + } + + /** + * @group disconnected + */ + public function testTransactionWithCommandsSendsDiscard() + { + $commands = array(); + + $callback = $this->getExecuteCallback(null, $commands); + $tx = $this->getMockedTransaction($callback); + + $replies = $tx->execute(function ($tx) { + $tx->set('foo', 'bar'); + $tx->get('foo'); + $tx->discard(); + }); + + $this->assertNull($replies); + $this->assertSame(array('MULTI', 'SET', 'GET', 'DISCARD'), self::commandsToIDs($commands)); + } + + /** + * @group disconnected + */ + public function testSendMultiOnCommandsFollowingDiscard() + { + $commands = array(); + $expected = array('after DISCARD'); + + $callback = $this->getExecuteCallback($expected, $commands); + $tx = $this->getMockedTransaction($callback); + + $replies = $tx->execute(function ($tx) { + $tx->echo('before DISCARD'); + $tx->discard(); + $tx->echo('after DISCARD'); + }); + + $this->assertSame($replies, $expected); + $this->assertSame(array('MULTI', 'ECHO', 'DISCARD', 'MULTI', 'ECHO', 'EXEC'), self::commandsToIDs($commands)); + } + /** + * @group disconnected + * @expectedException Predis\ClientException + */ + public function testThrowsExceptionOnWatchInsideMulti() + { + $callback = $this->getExecuteCallback(); + $tx = $this->getMockedTransaction($callback); + + $tx->echo('foobar')->watch('foo')->execute(); + } + + /** + * @group disconnected + */ + public function testUnwatchInsideMulti() + { + $commands = array(); + $expected = array('foobar', true); + + $callback = $this->getExecuteCallback($expected, $commands); + $tx = $this->getMockedTransaction($callback); + + $replies = $tx->echo('foobar')->unwatch('foo')->execute(); + + $this->assertSame($replies, $expected); + $this->assertSame(array('MULTI', 'ECHO', 'UNWATCH', 'EXEC'), self::commandsToIDs($commands)); + } + + /** + * @group disconnected + */ + public function testAutomaticWatchInOptions() + { + $txCommands = $casCommands = array(); + $expected = array('bar', 'piyo'); + $options = array('watch' => array('foo', 'hoge')); + + $callback = $this->getExecuteCallback($expected, $txCommands, $casCommands); + $tx = $this->getMockedTransaction($callback, $options); + + $replies = $tx->execute(function ($tx) { + $tx->get('foo'); + $tx->get('hoge'); + }); + + $this->assertSame($replies, $expected); + $this->assertSame(array('WATCH'), self::commandsToIDs($casCommands)); + $this->assertSame(array('foo', 'hoge'), $casCommands[0]->getArguments()); + $this->assertSame(array('MULTI', 'GET', 'GET', 'EXEC'), self::commandsToIDs($txCommands)); + } + /** + * @group disconnected + */ + public function testCheckAndSetWithFluentInterface() + { + $txCommands = $casCommands = array(); + $expected = array('bar', 'piyo'); + $options = array('cas' => true, 'watch' => array('foo', 'hoge')); + + $callback = $this->getExecuteCallback($expected, $txCommands, $casCommands); + $tx = $this->getMockedTransaction($callback, $options); + + $tx->watch('foobar'); + $this->assertSame('DUMMY_REPLY', $tx->get('foo')); + $this->assertSame('DUMMY_REPLY', $tx->get('hoge')); + + $replies = $tx->multi() + ->get('foo') + ->get('hoge') + ->execute(); + + $this->assertSame($replies, $expected); + $this->assertSame(array('WATCH', 'WATCH', 'GET', 'GET'), self::commandsToIDs($casCommands)); + $this->assertSame(array('MULTI', 'GET', 'GET', 'EXEC'), self::commandsToIDs($txCommands)); + } + + /** + * @group disconnected + */ + public function testCheckAndSetWithBlock() + { + $txCommands = $casCommands = array(); + $expected = array('bar', 'piyo'); + $options = array('cas' => true, 'watch' => array('foo', 'hoge')); + + $callback = $this->getExecuteCallback($expected, $txCommands, $casCommands); + $tx = $this->getMockedTransaction($callback, $options); + + $test = $this; + $replies = $tx->execute(function ($tx) use ($test) { + $tx->watch('foobar'); + + $reply1 = $tx->get('foo'); + $reply2 = $tx->get('hoge'); + + $test->assertSame('DUMMY_REPLY', $reply1); + $test->assertSame('DUMMY_REPLY', $reply2); + + $tx->multi(); + + $tx->get('foo'); + $tx->get('hoge'); + }); + + $this->assertSame($replies, $expected); + $this->assertSame(array('WATCH', 'WATCH', 'GET', 'GET'), self::commandsToIDs($casCommands)); + $this->assertSame(array('MULTI', 'GET', 'GET', 'EXEC'), self::commandsToIDs($txCommands)); + } + + /** + * @group disconnected + */ + public function testCheckAndSetWithEmptyBlock() + { + $txCommands = $casCommands = array(); + $options = array('cas' => true); + + $callback = $this->getExecuteCallback(array(), $txCommands, $casCommands); + $tx = $this->getMockedTransaction($callback, $options); + + $tx->execute(function ($tx) { + $tx->multi(); + }); + + $this->assertSame(array(), self::commandsToIDs($casCommands)); + $this->assertSame(array(), self::commandsToIDs($txCommands)); + } + + /** + * @group disconnected + */ + public function testCheckAndSetWithoutExec() + { + $txCommands = $casCommands = array(); + $options = array('cas' => true); + + $callback = $this->getExecuteCallback(array(), $txCommands, $casCommands); + $tx = $this->getMockedTransaction($callback, $options); + + $tx->execute(function ($tx) { + $bar = $tx->get('foo'); + $tx->set('hoge', 'piyo'); + }); + + $this->assertSame(array('GET', 'SET'), self::commandsToIDs($casCommands)); + $this->assertSame(array(), self::commandsToIDs($txCommands)); + } + + /** + * @group disconnected + * @expectedException InvalidArgumentException + * @expectedExceptionMessage Automatic retries can be used only when a transaction block is provided + */ + public function testThrowsExceptionOnAutomaticRetriesWithFluentInterface() + { + $options = array('retry' => 1); + + $callback = $this->getExecuteCallback(); + $tx = $this->getMockedTransaction($callback, $options); + + $tx->echo('message')->execute(); + } + + /** + * @group disconnected + */ + public function testAutomaticRetryOnServerSideTransactionAbort() + { + $casCommands = $txCommands = array(); + $expected = array('bar'); + $options = array('watch' => array('foo', 'bar'), 'retry' => ($attempts = 2) + 1); + + $sentinel = $this->getMock('stdClass', array('signal')); + $sentinel->expects($this->exactly($attempts))->method('signal'); + + $callback = $this->getExecuteCallback($expected, $txCommands, $casCommands); + $tx = $this->getMockedTransaction($callback, $options); + + $replies = $tx->execute(function ($tx) use ($sentinel, &$attempts) { + $tx->get('foo'); + + if ($attempts > 0) { + $attempts -= 1; + $sentinel->signal(); + + $tx->echo('!!ABORT!!'); + } + }); + + $this->assertSame($replies, $expected); + $this->assertSame(array('WATCH'), self::commandsToIDs($casCommands)); + $this->assertSame(array('foo', 'bar'), $casCommands[0]->getArguments()); + $this->assertSame(array('MULTI', 'GET', 'EXEC'), self::commandsToIDs($txCommands)); + } + + /** + * @group disconnected + * @expectedException Predis\Transaction\AbortedMultiExecException + */ + public function testThrowsExceptionOnServerSideTransactionAbort() + { + $callback = $this->getExecuteCallback(); + $tx = $this->getMockedTransaction($callback); + + $replies = $tx->execute(function ($tx) { + $tx->echo('!!ABORT!!'); + }); + } + + /** + * @group disconnected + */ + public function testHandlesStandardExceptionsInBlock() + { + $exception = null; + + $commands = array(); + $expected = array('foobar', true); + + $callback = $this->getExecuteCallback($expected, $commands); + $tx = $this->getMockedTransaction($callback); + + $replies = null; + + try { + $replies = $tx->execute(function ($tx) { + $tx->set('foo', 'bar'); + $tx->get('foo'); + + throw new \RuntimeException('TEST'); + }); + } catch (\Exception $exception) { + // NOOP + } + + $this->assertNull($replies, $expected); + $this->assertSame(array('MULTI', 'SET', 'GET', 'DISCARD'), self::commandsToIDs($commands)); + } + + /** + * @group disconnected + */ + public function testHandlesServerExceptionsInBlock() + { + $commands = array(); + $expected = array('foobar', true); + + $callback = $this->getExecuteCallback($expected, $commands); + $tx = $this->getMockedTransaction($callback); + + $replies = null; + + try { + $replies = $tx->execute(function ($tx) { + $tx->set('foo', 'bar'); + $tx->echo('ERR Invalid operation'); + $tx->get('foo'); + }); + } catch (ServerException $exception) { + $tx->discard(); + } + + $this->assertNull($replies); + $this->assertSame(array('MULTI', 'SET', 'ECHO', 'DISCARD'), self::commandsToIDs($commands)); + } + + // ******************************************************************** // + // ---- INTEGRATION TESTS --------------------------------------------- // + // ******************************************************************** // + + /** + * @group connected + */ + public function testIntegrationHandlesStandardExceptionsInBlock() + { + $exception = null; + + $client = $this->getClient(); + + try { + $client->multiExec(function ($tx) { + $tx->set('foo', 'bar'); + throw new \RuntimeException("TEST"); + }); + } catch (\Exception $exception) { + // NOOP + } + + $this->assertInstanceOf('RuntimeException', $exception); + $this->assertFalse($client->exists('foo')); + } + + /** + * @group connected + */ + public function testIntegrationThrowsExceptionOnRedisErrorInBlock() + { + $exception = null; + + $client = $this->getClient(); + $value = (string) rand(); + + try { + $client->multiExec(function ($tx) use ($value) { + $tx->set('foo', 'bar'); + $tx->lpush('foo', 'bar'); + $tx->set('foo', $value); + }); + } catch (ServerException $exception) { + // NOOP + } + + $this->assertInstanceOf('Predis\ResponseErrorInterface', $exception); + $this->assertSame($value, $client->get('foo')); + } + + /** + * @group connected + */ + public function testIntegrationReturnsErrorObjectOnRedisErrorInBlock() + { + $client = $this->getClient(array(), array('exceptions' => false)); + + $replies = $client->multiExec(function ($tx) { + $tx->set('foo', 'bar'); + $tx->lpush('foo', 'bar'); + $tx->echo('foobar'); + }); + + $this->assertTrue($replies[0]); + $this->assertInstanceOf('Predis\ResponseErrorInterface', $replies[1]); + $this->assertSame('foobar', $replies[2]); + } + + /** + * @group connected + */ + public function testIntegrationSendMultiOnCommandsAfterDiscard() + { + $client = $this->getClient(); + + $replies = $client->multiExec(function ($tx) { + $tx->set('foo', 'bar'); + $tx->discard(); + $tx->set('hoge', 'piyo'); + }); + + $this->assertSame(1, count($replies)); + $this->assertFalse($client->exists('foo')); + $this->assertTrue($client->exists('hoge')); + } + + /** + * @group connected + */ + public function testIntegrationWritesOnWatchedKeysAbortTransaction() + { + $exception = null; + + $client1 = $this->getClient(); + $client2 = $this->getClient(); + + try { + $client1->multiExec(array('watch' => 'sentinel'), function ($tx) use ($client2) { + $tx->set('sentinel', 'client1'); + $tx->get('sentinel'); + $client2->set('sentinel', 'client2'); + }); + } catch (AbortedMultiExecException $exception) { + // NOOP + } + + $this->assertInstanceOf('Predis\Transaction\AbortedMultiExecException', $exception); + $this->assertSame('client2', $client1->get('sentinel')); + } + + /** + * @group connected + */ + public function testIntegrationCheckAndSetWithDiscardAndRetry() + { + $client = $this->getClient(); + + $client->set('foo', 'bar'); + $options = array('watch' => 'foo', 'cas' => true); + + $replies = $client->multiExec($options, function ($tx) { + $tx->watch('foobar'); + $foo = $tx->get('foo'); + + $tx->multi(); + $tx->set('foobar', $foo); + $tx->discard(); + $tx->mget('foo', 'foobar'); + }); + + $this->assertInternalType('array', $replies); + $this->assertSame(array(array('bar', null)), $replies); + + $hijack = true; + $client2 = $this->getClient(); + $client->set('foo', 'bar'); + + $options = array('watch' => 'foo', 'cas' => true, 'retry' => 1); + $replies = $client->multiExec($options, function ($tx) use ($client2, &$hijack) { + $foo = $tx->get('foo'); + $tx->multi(); + + $tx->set('foobar', $foo); + $tx->discard(); + + if ($hijack) { + $hijack = false; + $client2->set('foo', 'hijacked!'); + } + + $tx->mget('foo', 'foobar'); + }); + + $this->assertInternalType('array', $replies); + $this->assertSame(array(array('hijacked!', null)), $replies); + } + + // ******************************************************************** // + // ---- HELPER METHODS ------------------------------------------------ // + // ******************************************************************** // + + /** + * Returns a mocked instance of Predis\Connection\SingleConnectionInterface + * usingthe specified callback to return values from executeCommand(). + * + * @param \Closure $executeCallback + * @return \Predis\Connection\SingleConnectionInterface + */ + protected function getMockedConnection($executeCallback) + { + $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); + $connection->expects($this->any()) + ->method('executeCommand') + ->will($this->returnCallback($executeCallback)); + + return $connection; + } + + /** + * Returns a mocked instance of Predis\Transaction\MultiExecContext using + * the specified callback to return values from the executeCommand method + * of the underlying connection. + * + * @param \Closure $executeCallback + * @param array $options + * @return MultiExecContext + */ + protected function getMockedTransaction($executeCallback, $options = array()) + { + $connection = $this->getMockedConnection($executeCallback); + $client = new Client($connection); + $transaction = new MultiExecContext($client, $options); + + return $transaction; + } + + /** + * Returns a callback that emulates a server-side MULTI/EXEC transaction context. + * + * @param array $expected Expected responses. + * @param array $commands Reference to an array storing the whole flow of commands. + * @param array $cas Check and set operations performed by the transaction. + * @return \Closure + */ + protected function getExecuteCallback($expected = array(), &$commands = array(), &$cas = array()) + { + $multi = $watch = $abort = false; + + return function (CommandInterface $command) use (&$expected, &$commands, &$cas, &$multi, &$watch, &$abort) { + $cmd = $command->getId(); + + if ($multi || $cmd === 'MULTI') { + $commands[] = $command; + } else { + $cas[] = $command; + } + + switch ($cmd) { + case 'WATCH': + if ($multi) { + throw new ServerException("ERR $cmd inside MULTI is not allowed"); + } + + return $watch = true; + + case 'MULTI': + if ($multi) { + throw new ServerException("ERR MULTI calls can not be nested"); + } + + return $multi = true; + + case 'EXEC': + if (!$multi) { + throw new ServerException("ERR $cmd without MULTI"); + } + + $watch = $multi = false; + + if ($abort) { + $commands = $cas = array(); + $abort = false; + + return null; + } + + return $expected; + + case 'DISCARD': + if (!$multi) { + throw new ServerException("ERR $cmd without MULTI"); + } + + $watch = $multi = false; + + return true; + + case 'ECHO': + @list($trigger) = $command->getArguments(); + if (strpos($trigger, 'ERR ') === 0) { + throw new ServerException($trigger); + } + + if ($trigger === '!!ABORT!!' && $multi) { + $abort = true; + } + + return new ResponseQueued(); + + case 'UNWATCH': + $watch = false; + + default: + return $multi ? new ResponseQueued() : 'DUMMY_REPLY'; + } + }; + } + + /** + * Converts an array of instances of Predis\Command\CommandInterface and + * returns an array containing their IDs. + * + * @param array $commands List of commands instances. + * @return array + */ + protected static function commandsToIDs($commands) + { + return array_map(function ($cmd) { return $cmd->getId(); }, $commands); + } + + /** + * Returns a client instance connected to the specified Redis + * server instance to perform integration tests. + * + * @param array Additional connection parameters. + * @param array Additional client options. + * @return Client client instance. + */ + protected function getClient(array $parameters = array(), array $options = array()) + { + return $this->createClient($parameters, $options); + } +} diff --git a/vendor/predis/predis/tests/README.md b/vendor/predis/predis/tests/README.md new file mode 100755 index 0000000..0202907 --- /dev/null +++ b/vendor/predis/predis/tests/README.md @@ -0,0 +1,83 @@ +# About testing Predis # + +__ATTENTION__: Do not ever ever run this test suite against instances of Redis running in production +environments or containing data you are interested in! If you still want to test this library on a +production server without hitting the database, please read ahead about how to disable integration +tests. + +Predis ships a comprehensive test suite that uses __PHPUnit__ to cover every aspect of the library. +The suite is organized into several unit groups with the PHPUnit `@group` annotation which makes it +possible to run only selected groups of tests. The main groups are: + + - __disconnected__: generic tests verifying the correct behaviour of the library without requiring + an active connection to Redis. + - __connected__: integration tests that require an active connection to Redis + - __commands__: tests for the implementation of Redis commands. + - __slow__: tests that might slow down the execution of the test suite (either __connected__ or + __disconnected__). + +A list of all the available groups in the suite can be obtained by running: + +```bash +$ phpunit --list-groups +``` + +Groups of tests can be disabled or enabled via the XML configuration file or the standard command +line test runner. Please note that due to a bug in PHPUnit, older versions ignore the `--group` +option when the group is excluded in the XML configuration file. More details about this issue are +available on [PHPUnit's bug tracker](http://github.com/sebastianbergmann/phpunit/issues/320). + +Certain groups of tests requiring native extensions, such as `ext-curl` or `ext-phpiredis`, are +disabled by default in the configuration file. To enable these groups of tests you should remove +them from the exclusion list in `phpunit.xml`. + +### Combining groups for inclusion or exclusion with the command-line runner ### + +```bash +$ phpunit --group disconnected --exclude-group commands,slow +``` + +### Integration tests ### + +The suite performs integration tests against a running instance of Redis (>= 2.4.0) to verify the +correct behavior of the implementation of each command and certain abstractions implemented in the +library that depend on them. These tests are identified by the __connected__ group. + +Integration tests for commands that are not defined in the specified server profile (see the value +of the `REDIS_SERVER_VERSION` constant in `phpunit.xml`) are marked as __skipped__ automatically. + +By default, the test suite is configured to execute integration tests using the server profile for +Redis v2.6. You can run the suite against a Redis instance built from the `unstable` branch with the +development profile by changing the `REDIS_SERVER_VERSION` to `dev` in the `phpunit.xml` file, or to +`2.8` for the current stable version. + +If you do not have a Redis instance up and running or available for testing, you can completely +disable integration tests by excluding the __connected__ group: + +```bash +$ phpunit --exclude-group connected +``` + +### Slow tests ### + +Certain tests can slow down the execution of the suite. These tests can be disabled by excluding the +__slow__ group: + +```bash +$ phpunit --exclude-group slow +``` + +### Testing Redis commands ### + +We also provide an helper script in the `bin` directory that can be used to automatically generate a +file with the scheleton of a test case to test a Redis command by specifying the name of the class +in the `Predis\Command` namespace (only classes in this namespace are considered valid). For example + to generate a test case for `SET` (represented by the `Predis\Command\StringSet` class): + +```bash +$ ./bin/create-command-test --class=StringSet +``` + +Each command has its own realm (e.g. commands operating on strings, lists, sets and such) which is +automatically inferred from the name of the specified class. The realm can be also provided manually +leveraging the `--realm` option. diff --git a/vendor/predis/predis/tests/bootstrap.php b/vendor/predis/predis/tests/bootstrap.php new file mode 100755 index 0000000..e55c906 --- /dev/null +++ b/vendor/predis/predis/tests/bootstrap.php @@ -0,0 +1,26 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +if (file_exists(__DIR__.'/../autoload.php')) { + require __DIR__.'/../autoload.php'; +} else if (@include('Predis/Autoloader.php')) { + Predis\Autoloader::register(); +} else { + die('ERROR: Unable to find a suitable mean to register Predis\Autoloader.'); +} + +require __DIR__.'/PHPUnit/ArrayHasSameValuesConstraint.php'; +require __DIR__.'/PHPUnit/RedisCommandConstraint.php'; +require __DIR__.'/PHPUnit/PredisTestCase.php'; +require __DIR__.'/PHPUnit/PredisCommandTestCase.php'; +require __DIR__.'/PHPUnit/PredisConnectionTestCase.php'; +require __DIR__.'/PHPUnit/PredisProfileTestCase.php'; +require __DIR__.'/PHPUnit/PredisDistributorTestCase.php'; diff --git a/vendor/psr/log/.gitignore b/vendor/psr/log/.gitignore new file mode 100755 index 0000000..22d0d82 --- /dev/null +++ b/vendor/psr/log/.gitignore @@ -0,0 +1 @@ +vendor diff --git a/vendor/psr/log/LICENSE b/vendor/psr/log/LICENSE new file mode 100755 index 0000000..474c952 --- /dev/null +++ b/vendor/psr/log/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2012 PHP Framework Interoperability Group + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/vendor/psr/log/Psr/Log/AbstractLogger.php b/vendor/psr/log/Psr/Log/AbstractLogger.php new file mode 100755 index 0000000..00f9034 --- /dev/null +++ b/vendor/psr/log/Psr/Log/AbstractLogger.php @@ -0,0 +1,120 @@ +log(LogLevel::EMERGENCY, $message, $context); + } + + /** + * Action must be taken immediately. + * + * Example: Entire website down, database unavailable, etc. This should + * trigger the SMS alerts and wake you up. + * + * @param string $message + * @param array $context + * @return null + */ + public function alert($message, array $context = array()) + { + $this->log(LogLevel::ALERT, $message, $context); + } + + /** + * Critical conditions. + * + * Example: Application component unavailable, unexpected exception. + * + * @param string $message + * @param array $context + * @return null + */ + public function critical($message, array $context = array()) + { + $this->log(LogLevel::CRITICAL, $message, $context); + } + + /** + * Runtime errors that do not require immediate action but should typically + * be logged and monitored. + * + * @param string $message + * @param array $context + * @return null + */ + public function error($message, array $context = array()) + { + $this->log(LogLevel::ERROR, $message, $context); + } + + /** + * Exceptional occurrences that are not errors. + * + * Example: Use of deprecated APIs, poor use of an API, undesirable things + * that are not necessarily wrong. + * + * @param string $message + * @param array $context + * @return null + */ + public function warning($message, array $context = array()) + { + $this->log(LogLevel::WARNING, $message, $context); + } + + /** + * Normal but significant events. + * + * @param string $message + * @param array $context + * @return null + */ + public function notice($message, array $context = array()) + { + $this->log(LogLevel::NOTICE, $message, $context); + } + + /** + * Interesting events. + * + * Example: User logs in, SQL logs. + * + * @param string $message + * @param array $context + * @return null + */ + public function info($message, array $context = array()) + { + $this->log(LogLevel::INFO, $message, $context); + } + + /** + * Detailed debug information. + * + * @param string $message + * @param array $context + * @return null + */ + public function debug($message, array $context = array()) + { + $this->log(LogLevel::DEBUG, $message, $context); + } +} diff --git a/vendor/psr/log/Psr/Log/InvalidArgumentException.php b/vendor/psr/log/Psr/Log/InvalidArgumentException.php new file mode 100755 index 0000000..67f852d --- /dev/null +++ b/vendor/psr/log/Psr/Log/InvalidArgumentException.php @@ -0,0 +1,7 @@ +logger = $logger; + } +} diff --git a/vendor/psr/log/Psr/Log/LoggerInterface.php b/vendor/psr/log/Psr/Log/LoggerInterface.php new file mode 100755 index 0000000..476bb96 --- /dev/null +++ b/vendor/psr/log/Psr/Log/LoggerInterface.php @@ -0,0 +1,114 @@ +log(LogLevel::EMERGENCY, $message, $context); + } + + /** + * Action must be taken immediately. + * + * Example: Entire website down, database unavailable, etc. This should + * trigger the SMS alerts and wake you up. + * + * @param string $message + * @param array $context + * @return null + */ + public function alert($message, array $context = array()) + { + $this->log(LogLevel::ALERT, $message, $context); + } + + /** + * Critical conditions. + * + * Example: Application component unavailable, unexpected exception. + * + * @param string $message + * @param array $context + * @return null + */ + public function critical($message, array $context = array()) + { + $this->log(LogLevel::CRITICAL, $message, $context); + } + + /** + * Runtime errors that do not require immediate action but should typically + * be logged and monitored. + * + * @param string $message + * @param array $context + * @return null + */ + public function error($message, array $context = array()) + { + $this->log(LogLevel::ERROR, $message, $context); + } + + /** + * Exceptional occurrences that are not errors. + * + * Example: Use of deprecated APIs, poor use of an API, undesirable things + * that are not necessarily wrong. + * + * @param string $message + * @param array $context + * @return null + */ + public function warning($message, array $context = array()) + { + $this->log(LogLevel::WARNING, $message, $context); + } + + /** + * Normal but significant events. + * + * @param string $message + * @param array $context + * @return null + */ + public function notice($message, array $context = array()) + { + $this->log(LogLevel::NOTICE, $message, $context); + } + + /** + * Interesting events. + * + * Example: User logs in, SQL logs. + * + * @param string $message + * @param array $context + * @return null + */ + public function info($message, array $context = array()) + { + $this->log(LogLevel::INFO, $message, $context); + } + + /** + * Detailed debug information. + * + * @param string $message + * @param array $context + * @return null + */ + public function debug($message, array $context = array()) + { + $this->log(LogLevel::DEBUG, $message, $context); + } + + /** + * Logs with an arbitrary level. + * + * @param mixed $level + * @param string $message + * @param array $context + * @return null + */ + abstract public function log($level, $message, array $context = array()); +} diff --git a/vendor/psr/log/Psr/Log/NullLogger.php b/vendor/psr/log/Psr/Log/NullLogger.php new file mode 100755 index 0000000..553a3c5 --- /dev/null +++ b/vendor/psr/log/Psr/Log/NullLogger.php @@ -0,0 +1,27 @@ +logger) { }` + * blocks. + */ +class NullLogger extends AbstractLogger +{ + /** + * Logs with an arbitrary level. + * + * @param mixed $level + * @param string $message + * @param array $context + * @return null + */ + public function log($level, $message, array $context = array()) + { + // noop + } +} diff --git a/vendor/psr/log/Psr/Log/Test/LoggerInterfaceTest.php b/vendor/psr/log/Psr/Log/Test/LoggerInterfaceTest.php new file mode 100755 index 0000000..a932815 --- /dev/null +++ b/vendor/psr/log/Psr/Log/Test/LoggerInterfaceTest.php @@ -0,0 +1,116 @@ + " + * + * Example ->error('Foo') would yield "error Foo" + * + * @return string[] + */ + abstract function getLogs(); + + public function testImplements() + { + $this->assertInstanceOf('Psr\Log\LoggerInterface', $this->getLogger()); + } + + /** + * @dataProvider provideLevelsAndMessages + */ + public function testLogsAtAllLevels($level, $message) + { + $logger = $this->getLogger(); + $logger->{$level}($message, array('user' => 'Bob')); + $logger->log($level, $message, array('user' => 'Bob')); + + $expected = array( + $level.' message of level '.$level.' with context: Bob', + $level.' message of level '.$level.' with context: Bob', + ); + $this->assertEquals($expected, $this->getLogs()); + } + + public function provideLevelsAndMessages() + { + return array( + LogLevel::EMERGENCY => array(LogLevel::EMERGENCY, 'message of level emergency with context: {user}'), + LogLevel::ALERT => array(LogLevel::ALERT, 'message of level alert with context: {user}'), + LogLevel::CRITICAL => array(LogLevel::CRITICAL, 'message of level critical with context: {user}'), + LogLevel::ERROR => array(LogLevel::ERROR, 'message of level error with context: {user}'), + LogLevel::WARNING => array(LogLevel::WARNING, 'message of level warning with context: {user}'), + LogLevel::NOTICE => array(LogLevel::NOTICE, 'message of level notice with context: {user}'), + LogLevel::INFO => array(LogLevel::INFO, 'message of level info with context: {user}'), + LogLevel::DEBUG => array(LogLevel::DEBUG, 'message of level debug with context: {user}'), + ); + } + + /** + * @expectedException Psr\Log\InvalidArgumentException + */ + public function testThrowsOnInvalidLevel() + { + $logger = $this->getLogger(); + $logger->log('invalid level', 'Foo'); + } + + public function testContextReplacement() + { + $logger = $this->getLogger(); + $logger->info('{Message {nothing} {user} {foo.bar} a}', array('user' => 'Bob', 'foo.bar' => 'Bar')); + + $expected = array('info {Message {nothing} Bob Bar a}'); + $this->assertEquals($expected, $this->getLogs()); + } + + public function testObjectCastToString() + { + $dummy = $this->getMock('Psr\Log\Test\DummyTest', array('__toString')); + $dummy->expects($this->once()) + ->method('__toString') + ->will($this->returnValue('DUMMY')); + + $this->getLogger()->warning($dummy); + } + + public function testContextCanContainAnything() + { + $context = array( + 'bool' => true, + 'null' => null, + 'string' => 'Foo', + 'int' => 0, + 'float' => 0.5, + 'nested' => array('with object' => new DummyTest), + 'object' => new \DateTime, + 'resource' => fopen('php://memory', 'r'), + ); + + $this->getLogger()->warning('Crazy context data', $context); + } + + public function testContextExceptionKeyCanBeExceptionOrOtherValues() + { + $this->getLogger()->warning('Random message', array('exception' => 'oops')); + $this->getLogger()->critical('Uncaught Exception!', array('exception' => new \LogicException('Fail'))); + } +} + +class DummyTest +{ +} \ No newline at end of file diff --git a/vendor/psr/log/README.md b/vendor/psr/log/README.md new file mode 100755 index 0000000..574bc1c --- /dev/null +++ b/vendor/psr/log/README.md @@ -0,0 +1,45 @@ +PSR Log +======= + +This repository holds all interfaces/classes/traits related to +[PSR-3](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-3-logger-interface.md). + +Note that this is not a logger of its own. It is merely an interface that +describes a logger. See the specification for more details. + +Usage +----- + +If you need a logger, you can use the interface like this: + +```php +logger = $logger; + } + + public function doSomething() + { + if ($this->logger) { + $this->logger->info('Doing work'); + } + + // do something useful + } +} +``` + +You can then pick one of the implementations of the interface to get a logger. + +If you want to implement the interface, you can require this package and +implement `Psr\Log\LoggerInterface` in your code. Please read the +[specification text](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-3-logger-interface.md) +for details. diff --git a/vendor/psr/log/composer.json b/vendor/psr/log/composer.json new file mode 100755 index 0000000..6bdcc21 --- /dev/null +++ b/vendor/psr/log/composer.json @@ -0,0 +1,17 @@ +{ + "name": "psr/log", + "description": "Common interface for logging libraries", + "keywords": ["psr", "psr-3", "log"], + "license": "MIT", + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "autoload": { + "psr-0": { + "Psr\\Log\\": "" + } + } +} diff --git a/vendor/stack/builder/.gitignore b/vendor/stack/builder/.gitignore new file mode 100755 index 0000000..22d0d82 --- /dev/null +++ b/vendor/stack/builder/.gitignore @@ -0,0 +1 @@ +vendor diff --git a/vendor/stack/builder/.travis.yml b/vendor/stack/builder/.travis.yml new file mode 100755 index 0000000..1d50df4 --- /dev/null +++ b/vendor/stack/builder/.travis.yml @@ -0,0 +1,19 @@ +language: php + +php: + - 5.3.3 + - 5.3 + - 5.4 + - 5.5 + - hhvm + +before_script: + - composer self-update + - composer install --no-interaction --prefer-source + +script: phpunit --coverage-text + +matrix: + allow_failures: + - php: hhvm + fast_finish: true diff --git a/vendor/stack/builder/CHANGELOG.md b/vendor/stack/builder/CHANGELOG.md new file mode 100755 index 0000000..f6f35d6 --- /dev/null +++ b/vendor/stack/builder/CHANGELOG.md @@ -0,0 +1,14 @@ +CHANGELOG +========= + +* 1.0.2 (2014-xx-xx) + + * Validate missing arguments (@bajbnet). + +* 1.0.1 (2013-10-25) + + * Lower PHP requirement to 5.3. + +* 1.0.0 (2013-08-02) + + * Initial release. diff --git a/vendor/stack/builder/LICENSE b/vendor/stack/builder/LICENSE new file mode 100755 index 0000000..ceac72c --- /dev/null +++ b/vendor/stack/builder/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2013 Igor Wiedler + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is furnished +to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/vendor/stack/builder/README.md b/vendor/stack/builder/README.md new file mode 100755 index 0000000..812406c --- /dev/null +++ b/vendor/stack/builder/README.md @@ -0,0 +1,62 @@ +# Stack/Builder + +Builder for stack middlewares based on HttpKernelInterface. + +Stack/Builder is a small library that helps you construct a nested +HttpKernelInterface decorator tree. It models it as a stack of middlewares. + +## Example + +If you want to decorate a [silex](https://github.com/fabpot/Silex) app with +session and cache middlewares, you'll have to do something like this: + + use Symfony\Component\HttpKernel\HttpCache\Store; + + $app = new Silex\Application(); + + $app->get('/', function () { + return 'Hello World!'; + }); + + $app = new Stack\Session( + new Symfony\Component\HttpKernel\HttpCache\HttpCache( + $app, + new Store(__DIR__.'/cache') + ) + ); + +This can get quite annoying indeed. Stack/Builder simplifies that: + + $stack = (new Stack\Builder()) + ->push('Stack\Session') + ->push('Symfony\Component\HttpKernel\HttpCache\HttpCache', new Store(__DIR__.'/cache')); + + $app = $stack->resolve($app); + +As you can see, by arranging the layers as a stack, they become a lot easier +to work with. + +In the front controller, you need to serve the request: + + use Symfony\Component\HttpFoundation\Request; + + $request = Request::createFromGlobals(); + $response = $app->handle($request)->send(); + $app->terminate($request, $response); + +Stack/Builder also supports pushing a `callable` on to the stack, for situations +where instantiating middlewares might be more complicated. The `callable` should +accept a `HttpKernelInterface` as the first argument and should also return a +`HttpKernelInterface`. The example above could be rewritten as: + + $stack = (new Stack\Builder()) + ->push('Stack\Session') + ->push(function ($app) { + $cache = new HttpCache($app, new Store(__DIR__.'/cache')); + return $cache; + }); + +## Inspiration + +* [Rack::Builder](http://rack.rubyforge.org/doc/Rack/Builder.html) +* [HttpKernel middlewares](https://igor.io/2013/02/02/http-kernel-middlewares.html) diff --git a/vendor/stack/builder/composer.json b/vendor/stack/builder/composer.json new file mode 100755 index 0000000..e9f164c --- /dev/null +++ b/vendor/stack/builder/composer.json @@ -0,0 +1,26 @@ +{ + "name": "stack/builder", + "description": "Builder for stack middlewares based on HttpKernelInterface.", + "keywords": ["stack"], + "license": "MIT", + "authors": [ + { + "name": "Igor Wiedler", + "email": "igor@wiedler.ch" + } + ], + "require": { + "php": ">=5.3.0", + "symfony/http-foundation": "~2.1", + "symfony/http-kernel": "~2.1" + }, + "require-dev": { + "silex/silex": "~1.0" + }, + "autoload": { + "psr-0": { "Stack": "src" } + }, + "extra": { + "branch-alias": { "dev-master": "1.0-dev" } + } +} diff --git a/vendor/stack/builder/composer.lock b/vendor/stack/builder/composer.lock new file mode 100755 index 0000000..26c6a99 --- /dev/null +++ b/vendor/stack/builder/composer.lock @@ -0,0 +1,488 @@ +{ + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file" + ], + "hash": "78698481679eca710495d5aca028baaa", + "packages": [ + { + "name": "psr/log", + "version": "1.0.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/log.git", + "reference": "fe0936ee26643249e916849d48e3a51d5f5e278b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/log/zipball/fe0936ee26643249e916849d48e3a51d5f5e278b", + "reference": "fe0936ee26643249e916849d48e3a51d5f5e278b", + "shasum": "" + }, + "type": "library", + "autoload": { + "psr-0": { + "Psr\\Log\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common interface for logging libraries", + "keywords": [ + "log", + "psr", + "psr-3" + ], + "time": "2012-12-21 11:40:51" + }, + { + "name": "symfony/debug", + "version": "v2.4.1", + "target-dir": "Symfony/Component/Debug", + "source": { + "type": "git", + "url": "https://github.com/symfony/Debug.git", + "reference": "74110be5ec681a83fc5bd66dd5fd29fe85fe9c1f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/Debug/zipball/74110be5ec681a83fc5bd66dd5fd29fe85fe9c1f", + "reference": "74110be5ec681a83fc5bd66dd5fd29fe85fe9c1f", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "symfony/http-foundation": "~2.1", + "symfony/http-kernel": "~2.1" + }, + "suggest": { + "symfony/http-foundation": "", + "symfony/http-kernel": "" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.4-dev" + } + }, + "autoload": { + "psr-0": { + "Symfony\\Component\\Debug\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + } + ], + "description": "Symfony Debug Component", + "homepage": "http://symfony.com", + "time": "2014-01-01 09:02:49" + }, + { + "name": "symfony/event-dispatcher", + "version": "v2.4.1", + "target-dir": "Symfony/Component/EventDispatcher", + "source": { + "type": "git", + "url": "https://github.com/symfony/EventDispatcher.git", + "reference": "e3ba42f6a70554ed05749e61b829550f6ac33601" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/EventDispatcher/zipball/e3ba42f6a70554ed05749e61b829550f6ac33601", + "reference": "e3ba42f6a70554ed05749e61b829550f6ac33601", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "symfony/dependency-injection": "~2.0" + }, + "suggest": { + "symfony/dependency-injection": "", + "symfony/http-kernel": "" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.4-dev" + } + }, + "autoload": { + "psr-0": { + "Symfony\\Component\\EventDispatcher\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + } + ], + "description": "Symfony EventDispatcher Component", + "homepage": "http://symfony.com", + "time": "2013-12-28 08:12:03" + }, + { + "name": "symfony/http-foundation", + "version": "v2.4.1", + "target-dir": "Symfony/Component/HttpFoundation", + "source": { + "type": "git", + "url": "https://github.com/symfony/HttpFoundation.git", + "reference": "6c6b8a7bcd7e2cc920cd6acace563fdbf121d844" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/HttpFoundation/zipball/6c6b8a7bcd7e2cc920cd6acace563fdbf121d844", + "reference": "6c6b8a7bcd7e2cc920cd6acace563fdbf121d844", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.4-dev" + } + }, + "autoload": { + "psr-0": { + "Symfony\\Component\\HttpFoundation\\": "" + }, + "classmap": [ + "Symfony/Component/HttpFoundation/Resources/stubs" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + } + ], + "description": "Symfony HttpFoundation Component", + "homepage": "http://symfony.com", + "time": "2014-01-05 02:10:50" + }, + { + "name": "symfony/http-kernel", + "version": "v2.4.1", + "target-dir": "Symfony/Component/HttpKernel", + "source": { + "type": "git", + "url": "https://github.com/symfony/HttpKernel.git", + "reference": "0605eedeb52c4d3a3144128d8336395a57be60d4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/HttpKernel/zipball/0605eedeb52c4d3a3144128d8336395a57be60d4", + "reference": "0605eedeb52c4d3a3144128d8336395a57be60d4", + "shasum": "" + }, + "require": { + "php": ">=5.3.3", + "psr/log": "~1.0", + "symfony/debug": "~2.3", + "symfony/event-dispatcher": "~2.1", + "symfony/http-foundation": "~2.4" + }, + "require-dev": { + "symfony/browser-kit": "~2.2", + "symfony/class-loader": "~2.1", + "symfony/config": "~2.0", + "symfony/console": "~2.2", + "symfony/dependency-injection": "~2.0", + "symfony/finder": "~2.0", + "symfony/process": "~2.0", + "symfony/routing": "~2.2", + "symfony/stopwatch": "~2.2", + "symfony/templating": "~2.2" + }, + "suggest": { + "symfony/browser-kit": "", + "symfony/class-loader": "", + "symfony/config": "", + "symfony/console": "", + "symfony/dependency-injection": "", + "symfony/finder": "" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.4-dev" + } + }, + "autoload": { + "psr-0": { + "Symfony\\Component\\HttpKernel\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + } + ], + "description": "Symfony HttpKernel Component", + "homepage": "http://symfony.com", + "time": "2014-01-05 02:12:11" + } + ], + "packages-dev": [ + { + "name": "pimple/pimple", + "version": "v1.1.0", + "source": { + "type": "git", + "url": "https://github.com/fabpot/Pimple.git", + "reference": "471c7d7c52ad6594e17b8ec33efdd1be592b5d83" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/fabpot/Pimple/zipball/471c7d7c52ad6594e17b8ec33efdd1be592b5d83", + "reference": "471c7d7c52ad6594e17b8ec33efdd1be592b5d83", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.1.x-dev" + } + }, + "autoload": { + "psr-0": { + "Pimple": "lib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + } + ], + "description": "Pimple is a simple Dependency Injection Container for PHP 5.3", + "homepage": "http://pimple.sensiolabs.org", + "keywords": [ + "container", + "dependency injection" + ], + "time": "2013-09-19 04:53:08" + }, + { + "name": "silex/silex", + "version": "v1.1.2", + "source": { + "type": "git", + "url": "https://github.com/silexphp/Silex.git", + "reference": "47cc7d6545450ef8a91f50c04e8c7b3b04fceae9" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/silexphp/Silex/zipball/47cc7d6545450ef8a91f50c04e8c7b3b04fceae9", + "reference": "47cc7d6545450ef8a91f50c04e8c7b3b04fceae9", + "shasum": "" + }, + "require": { + "php": ">=5.3.3", + "pimple/pimple": "~1.0", + "symfony/event-dispatcher": ">=2.3,<2.5-dev", + "symfony/http-foundation": ">=2.3,<2.5-dev", + "symfony/http-kernel": ">=2.3,<2.5-dev", + "symfony/routing": ">=2.3,<2.5-dev" + }, + "require-dev": { + "doctrine/dbal": ">=2.2.0,<2.4.0-dev", + "monolog/monolog": "~1.4,>=1.4.1", + "phpunit/phpunit": "~3.7", + "swiftmailer/swiftmailer": "5.*", + "symfony/browser-kit": ">=2.3,<2.5-dev", + "symfony/config": ">=2.3,<2.5-dev", + "symfony/css-selector": ">=2.3,<2.5-dev", + "symfony/debug": ">=2.3,<2.5-dev", + "symfony/dom-crawler": ">=2.3,<2.5-dev", + "symfony/finder": ">=2.3,<2.5-dev", + "symfony/form": ">=2.3,<2.5-dev", + "symfony/locale": ">=2.3,<2.5-dev", + "symfony/monolog-bridge": ">=2.3,<2.5-dev", + "symfony/options-resolver": ">=2.3,<2.5-dev", + "symfony/process": ">=2.3,<2.5-dev", + "symfony/security": ">=2.3,<2.5-dev", + "symfony/serializer": ">=2.3,<2.5-dev", + "symfony/translation": ">=2.3,<2.5-dev", + "symfony/twig-bridge": ">=2.3,<2.5-dev", + "symfony/validator": ">=2.3,<2.5-dev", + "twig/twig": ">=1.8.0,<2.0-dev" + }, + "suggest": { + "symfony/browser-kit": ">=2.3,<2.5-dev", + "symfony/css-selector": ">=2.3,<2.5-dev", + "symfony/dom-crawler": ">=2.3,<2.5-dev", + "symfony/form": ">=2.3,<2.5-dev" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.1.x-dev" + } + }, + "autoload": { + "psr-0": { + "Silex": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Igor Wiedler", + "email": "igor@wiedler.ch", + "homepage": "http://wiedler.ch/igor/" + } + ], + "description": "The PHP micro-framework based on the Symfony2 Components", + "homepage": "http://silex.sensiolabs.org", + "keywords": [ + "microframework" + ], + "time": "2013-10-30 08:53:26" + }, + { + "name": "symfony/routing", + "version": "v2.4.1", + "target-dir": "Symfony/Component/Routing", + "source": { + "type": "git", + "url": "https://github.com/symfony/Routing.git", + "reference": "4abfb500aab8be458c9e3a227ea56b190584f78a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/Routing/zipball/4abfb500aab8be458c9e3a227ea56b190584f78a", + "reference": "4abfb500aab8be458c9e3a227ea56b190584f78a", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "doctrine/annotations": "~1.0", + "psr/log": "~1.0", + "symfony/config": "~2.2", + "symfony/expression-language": "~2.4", + "symfony/yaml": "~2.0" + }, + "suggest": { + "doctrine/annotations": "For using the annotation loader", + "symfony/config": "For using the all-in-one router or any loader", + "symfony/expression-language": "For using expression matching", + "symfony/yaml": "For using the YAML loader" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.4-dev" + } + }, + "autoload": { + "psr-0": { + "Symfony\\Component\\Routing\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + } + ], + "description": "Symfony Routing Component", + "homepage": "http://symfony.com", + "keywords": [ + "router", + "routing", + "uri", + "url" + ], + "time": "2014-01-05 02:10:50" + } + ], + "aliases": [ + + ], + "minimum-stability": "stable", + "stability-flags": [ + + ], + "platform": { + "php": ">=5.3.0" + }, + "platform-dev": [ + + ] +} diff --git a/vendor/stack/builder/phpunit.xml.dist b/vendor/stack/builder/phpunit.xml.dist new file mode 100755 index 0000000..a2437ec --- /dev/null +++ b/vendor/stack/builder/phpunit.xml.dist @@ -0,0 +1,30 @@ + + + + + + ./tests/unit/ + + + + + + ./tests/integration/ + + + + + + ./tests/functional/ + + + + + + ./src/ + + + diff --git a/vendor/stack/builder/src/Stack/Builder.php b/vendor/stack/builder/src/Stack/Builder.php new file mode 100755 index 0000000..c7ee05a --- /dev/null +++ b/vendor/stack/builder/src/Stack/Builder.php @@ -0,0 +1,63 @@ +specs = new \SplStack(); + } + + public function unshift(/*$kernelClass, $args...*/) + { + if (func_num_args() === 0) { + throw new \InvalidArgumentException("Missing argument(s) when calling unshift"); + } + + $spec = func_get_args(); + $this->specs->unshift($spec); + + return $this; + } + + public function push(/*$kernelClass, $args...*/) + { + if (func_num_args() === 0) { + throw new \InvalidArgumentException("Missing argument(s) when calling push"); + } + + $spec = func_get_args(); + $this->specs->push($spec); + + return $this; + } + + public function resolve(HttpKernelInterface $app) + { + $middlewares = array($app); + + foreach ($this->specs as $spec) { + $args = $spec; + $firstArg = array_shift($args); + + if (is_callable($firstArg)) { + $app = $firstArg($app); + } else { + $kernelClass = $firstArg; + array_unshift($args, $app); + + $reflection = new \ReflectionClass($kernelClass); + $app = $reflection->newInstanceArgs($args); + } + + array_unshift($middlewares, $app); + } + + return new StackedHttpKernel($app, $middlewares); + } +} diff --git a/vendor/stack/builder/src/Stack/StackedHttpKernel.php b/vendor/stack/builder/src/Stack/StackedHttpKernel.php new file mode 100755 index 0000000..2b96dd9 --- /dev/null +++ b/vendor/stack/builder/src/Stack/StackedHttpKernel.php @@ -0,0 +1,34 @@ +app = $app; + $this->middlewares = $middlewares; + } + + public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true) + { + return $this->app->handle($request, $type, $catch); + } + + public function terminate(Request $request, Response $response) + { + foreach ($this->middlewares as $kernel) { + if ($kernel instanceof TerminableInterface) { + $kernel->terminate($request, $response); + } + } + } +} diff --git a/vendor/stack/builder/tests/functional/SilexApplicationTest.php b/vendor/stack/builder/tests/functional/SilexApplicationTest.php new file mode 100755 index 0000000..5636336 --- /dev/null +++ b/vendor/stack/builder/tests/functional/SilexApplicationTest.php @@ -0,0 +1,60 @@ +get('/foo', function () { + return 'bar'; + }); + + $finished = false; + + $app->finish(function () use (&$finished) { + $finished = true; + }); + + $stack = new Builder(); + $stack + ->push('functional\Append', '.A') + ->push('functional\Append', '.B'); + + $app = $stack->resolve($app); + + $request = Request::create('/foo'); + $response = $app->handle($request); + $app->terminate($request, $response); + + $this->assertSame('bar.B.A', $response->getContent()); + $this->assertTrue($finished); + } +} + +class Append implements HttpKernelInterface +{ + private $app; + private $appendix; + + public function __construct(HttpKernelInterface $app, $appendix) + { + $this->app = $app; + $this->appendix = $appendix; + } + + public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true) + { + $response = clone $this->app->handle($request, $type, $catch); + $response->setContent($response->getContent().$this->appendix); + + return $response; + } +} diff --git a/vendor/stack/builder/tests/unit/Stack/BuilderTest.php b/vendor/stack/builder/tests/unit/Stack/BuilderTest.php new file mode 100755 index 0000000..4092d01 --- /dev/null +++ b/vendor/stack/builder/tests/unit/Stack/BuilderTest.php @@ -0,0 +1,215 @@ +getHttpKernelMock(new Response('ok')); + + $stack = new Builder(); + $resolved = $stack->resolve($app); + + $request = Request::create('/'); + $response = $resolved->handle($request); + + $this->assertInstanceOf('Stack\StackedHttpKernel', $resolved); + $this->assertSame('ok', $response->getContent()); + } + + /** @test */ + public function resolvedKernelShouldDelegateTerminateCalls() + { + $app = $this->getTerminableMock(); + + $stack = new Builder(); + $resolved = $stack->resolve($app); + + $request = Request::create('/'); + $response = new Response('ok'); + + $resolved->handle($request); + $resolved->terminate($request, $response); + } + + /** @test */ + public function pushShouldReturnSelf() + { + $stack = new Builder(); + $this->assertSame($stack, $stack->push('Stack\AppendA')); + } + + /** @test */ + public function pushShouldThrowOnInvalidInput() + { + $this->setExpectedException('InvalidArgumentException', 'Missing argument(s) when calling push'); + $stack = new Builder(); + $stack->push(); + } + + /** @test */ + public function unshiftShouldReturnSelf() + { + $stack = new Builder(); + $this->assertSame($stack, $stack->unshift('Stack\AppendA')); + } + + /** @test */ + public function unshiftShouldThrowOnInvalidInput() + { + $this->setExpectedException('InvalidArgumentException', 'Missing argument(s) when calling unshift'); + $stack = new Builder(); + $stack->unshift(); + } + + /** @test */ + public function appendMiddlewareShouldAppendToBody() + { + $app = $this->getHttpKernelMock(new Response('ok')); + + $stack = new Builder(); + $stack->push('Stack\AppendA'); + $resolved = $stack->resolve($app); + + $request = Request::create('/'); + $response = $resolved->handle($request); + + $this->assertSame('ok.A', $response->getContent()); + } + + /** @test */ + public function unshiftMiddlewareShouldPutMiddlewareBeforePushed() + { + $app = $this->getHttpKernelMock(new Response('ok')); + + $stack = new Builder(); + $stack->push('Stack\Append', '2.'); + $stack->unshift('Stack\Append', '1.'); + $resolved = $stack->resolve($app); + + $request = Request::create('/'); + $response = $resolved->handle($request); + + $this->assertSame('ok2.1.', $response->getContent()); + } + + /** @test */ + public function stackedMiddlewaresShouldWrapInReverseOrder() + { + $app = $this->getHttpKernelMock(new Response('ok')); + + $stack = new Builder(); + $stack->push('Stack\AppendA'); + $stack->push('Stack\AppendB'); + $resolved = $stack->resolve($app); + + $request = Request::create('/'); + $response = $resolved->handle($request); + + $this->assertSame('ok.B.A', $response->getContent()); + } + + /** @test */ + public function resolveShouldPassPushArgumentsToMiddlewareConstructor() + { + $app = $this->getHttpKernelMock(new Response('ok')); + + $stack = new Builder(); + $stack->push('Stack\Append', '.foo'); + $stack->push('Stack\Append', '.bar'); + $resolved = $stack->resolve($app); + + $request = Request::create('/'); + $response = $resolved->handle($request); + + $this->assertSame('ok.bar.foo', $response->getContent()); + } + + /** @test */ + public function resolveShouldCallSpecFactories() + { + $app = $this->getHttpKernelMock(new Response('ok')); + + $stack = new Builder(); + $stack->push(function ($app) { return new Append($app, '.foo'); }); + $stack->push(function ($app) { return new Append($app, '.bar'); }); + $resolved = $stack->resolve($app); + + $request = Request::create('/'); + $response = $resolved->handle($request); + + $this->assertSame('ok.bar.foo', $response->getContent()); + } + + private function getHttpKernelMock(Response $response) + { + $app = $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface'); + $app->expects($this->any()) + ->method('handle') + ->with($this->isInstanceOf('Symfony\Component\HttpFoundation\Request')) + ->will($this->returnValue($response)); + + return $app; + } + + private function getTerminableMock() + { + $app = $this->getMock('Stack\TerminableHttpKernel'); + $app->expects($this->once()) + ->method('terminate') + ->with( + $this->isInstanceOf('Symfony\Component\HttpFoundation\Request'), + $this->isInstanceOf('Symfony\Component\HttpFoundation\Response') + ); + + return $app; + } +} + +abstract class TerminableHttpKernel implements HttpKernelInterface, TerminableInterface +{ +} + +class Append implements HttpKernelInterface +{ + private $app; + private $appendix; + + public function __construct(HttpKernelInterface $app, $appendix) + { + $this->app = $app; + $this->appendix = $appendix; + } + + public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true) + { + $response = clone $this->app->handle($request, $type, $catch); + $response->setContent($response->getContent().$this->appendix); + + return $response; + } +} + +class AppendA extends Append +{ + public function __construct(HttpKernelInterface $app) + { + parent::__construct($app, '.A'); + } +} + +class AppendB extends Append +{ + public function __construct(HttpKernelInterface $app) + { + parent::__construct($app, '.B'); + } +} diff --git a/vendor/stack/builder/tests/unit/Stack/StackedHttpKernelTest.php b/vendor/stack/builder/tests/unit/Stack/StackedHttpKernelTest.php new file mode 100755 index 0000000..e2ced54 --- /dev/null +++ b/vendor/stack/builder/tests/unit/Stack/StackedHttpKernelTest.php @@ -0,0 +1,80 @@ +getHttpKernelMock(new Response('ok')); + $kernel = new StackedHttpKernel($app, array($app)); + + $request = Request::create('/'); + $response = $kernel->handle($request); + + $this->assertSame('ok', $response->getContent()); + } + + /** @test */ + public function handleShouldStillDelegateToAppWithMiddlewares() + { + $app = $this->getHttpKernelMock(new Response('ok')); + $foo = $this->getHttpKernelMock(new Response('foo')); + $bar = $this->getHttpKernelMock(new Response('bar')); + $kernel = new StackedHttpKernel($app, array($app, $foo, $bar)); + + $request = Request::create('/'); + $response = $kernel->handle($request); + + $this->assertSame('ok', $response->getContent()); + } + + /** @test */ + public function terminateShouldDelegateToMiddlewares() + { + $app = $this->getTerminableMock(new Response('ok')); + $foo = $this->getTerminableMock(); + $bar = $this->getTerminableMock(); + $kernel = new StackedHttpKernel($app, array($app, $foo, $bar)); + + $request = Request::create('/'); + $response = $kernel->handle($request); + $kernel->terminate($request, $response); + } + + private function getHttpKernelMock(Response $response) + { + $app = $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface'); + $app->expects($this->any()) + ->method('handle') + ->with($this->isInstanceOf('Symfony\Component\HttpFoundation\Request')) + ->will($this->returnValue($response)); + + return $app; + } + + private function getTerminableMock(Response $response = null) + { + $app = $this->getMock('Stack\TerminableHttpKernel'); + if ($response) { + $app->expects($this->any()) + ->method('handle') + ->with($this->isInstanceOf('Symfony\Component\HttpFoundation\Request')) + ->will($this->returnValue($response)); + } + $app->expects($this->once()) + ->method('terminate') + ->with( + $this->isInstanceOf('Symfony\Component\HttpFoundation\Request'), + $this->isInstanceOf('Symfony\Component\HttpFoundation\Response') + ); + + return $app; + } +} diff --git a/vendor/swiftmailer/swiftmailer/.gitattributes b/vendor/swiftmailer/swiftmailer/.gitattributes new file mode 100755 index 0000000..5568ef0 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/.gitattributes @@ -0,0 +1,6 @@ +*.crt -crlf +*.key -crlf +*.srl -crlf +*.pub -crlf +*.priv -crlf +*.txt -crlf diff --git a/vendor/swiftmailer/swiftmailer/.gitignore b/vendor/swiftmailer/swiftmailer/.gitignore new file mode 100755 index 0000000..9a23ffe --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/.gitignore @@ -0,0 +1,4 @@ +/tests/acceptance.conf.php +/tests/smoke.conf.php +/build/* +/vendor/ diff --git a/vendor/swiftmailer/swiftmailer/.travis.yml b/vendor/swiftmailer/swiftmailer/.travis.yml new file mode 100755 index 0000000..cadee01 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/.travis.yml @@ -0,0 +1,25 @@ +language: php + +php: + - 5.3 + - 5.4 + - 5.5 + - 5.6 + - hhvm-nightly + +before_script: + - cp tests/acceptance.conf.php.default tests/acceptance.conf.php + - cp tests/smoke.conf.php.default tests/smoke.conf.php + - composer self-update + - composer update --no-interaction --prefer-source + - gem install mailcatcher + - mailcatcher --smtp-port 4456 + +script: + - phpunit --verbose + +matrix: + allow_failures: + - php: 5.6 + - php: hhvm-nightly + fast_finish: true diff --git a/vendor/swiftmailer/swiftmailer/CHANGES b/vendor/swiftmailer/swiftmailer/CHANGES new file mode 100755 index 0000000..ddbee68 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/CHANGES @@ -0,0 +1,158 @@ +Changelog +========= + +5.2.0 (2014-05-08) +------------------ + + * fixed Swift_ByteStream_FileByteStream::read() to match to the specification + * fixed from-charset and to-charset arguments in mbstring_convert_encoding() usages + * fixed infinite loop in StreamBuffer + * fixed NullTransport to return the number of ignored emails instead of 0 + * Use phpunit and mockery for unit testing (realityking) + +5.1.0 (2014-03-18) +------------------ + + * fixed data writing to stream when sending large messages + * added support for libopendkim (https://github.com/xdecock/php-opendkim) + * merged SignedMessage and Message + * added Gmail XOAuth2 authentication + * updated the list of known mime types + * added NTLM authentication + +5.0.3 (2013-12-03) +------------------ + + * fixed double-dot bug + * fixed DKIM signer + +5.0.2 (2013-08-30) +------------------ + + * handled correct exception type while reading IoBuffer output + +5.0.1 (2013-06-17) +------------------ + + * changed the spool to only start the transport when a mail has to be sent + * fixed compatibility with PHP 5.2 + * fixed LICENSE file + +5.0.0 (2013-04-30) +------------------ + + * changed the license from LGPL to MIT + +4.3.1 (2013-04-11) +------------------ + + * removed usage of the native QP encoder when the charset is not UTF-8 + * fixed usage of uniqid to avoid collisions + * made a performance improvement when tokenizing large headers + * fixed usage of the PHP native QP encoder on PHP 5.4.7+ + +4.3.0 (2013-01-08) +------------------ + + * made the temporary directory configurable via the TMPDIR env variable + * added S/MIME signer and encryption support + +4.2.2 (2012-10-25) +------------------ + + * added the possibility to throttle messages per second in ThrottlerPlugin (mostly for Amazon SES) + * switched mime.qpcontentencoder to automatically use the PHP native encoder on PHP 5.4.7+ + * allowed specifying a whitelist with regular expressions in RedirectingPlugin + +4.2.1 (2012-07-13) +------------------ + + * changed the coding standards to PSR-1/2 + * fixed issue with autoloading + * added NativeQpContentEncoder to enhance performance (for PHP 5.3+) + +4.2.0 (2012-06-29) +------------------ + + * added documentation about how to use the Japanese support introduced in 4.1.8 + * added a way to override the default configuration in a lazy way + * changed the PEAR init script to lazy-load the initialization + * fixed a bug when calling Swift_Preferences before anything else (regression introduced in 4.1.8) + +4.1.8 (2012-06-17) +------------------ + + * added Japanese iso-2022-jp support + * changed the init script to lazy-load the initialization + * fixed docblocks (@id) which caused some problems with libraries parsing the dobclocks + * fixed Swift_Mime_Headers_IdentificationHeader::setId() when passed an array of ids + * fixed encoding of email addresses in headers + * added replacements setter to the Decorator plugin + +4.1.7 (2012-04-26) +------------------ + + * fixed QpEncoder safeMapShareId property + +4.1.6 (2012-03-23) +------------------ + + * reduced the size of serialized Messages + +4.1.5 (2012-01-04) +------------------ + + * enforced Swift_Spool::queueMessage() to return a Boolean + * made an optimization to the memory spool: start the transport only when required + * prevented stream_socket_client() from generating an error and throw a Swift_TransportException instead + * fixed a PHP warning when calling to mail() when safe_mode is off + * many doc tweaks + +4.1.4 (2011-12-16) +------------------ + + * added a memory spool (Swift_MemorySpool) + * fixed too many opened files when sending emails with attachments + +4.1.3 (2011-10-27) +------------------ + + * added STARTTLS support + * added missing @return tags on fluent methods + * added a MessageLogger plugin that logs all sent messages + * added composer.json + +4.1.2 (2011-09-13) +------------------ + + * fixed wrong detection of magic_quotes_runtime + * fixed fatal errors when no To or Subject header has been set + * fixed charset on parameter header continuations + * added documentation about how to install Swiftmailer from the PEAR channel + * fixed various typos and markup problem in the documentation + * fixed warning when cache directory does not exist + * fixed "slashes are escaped" bug + * changed require_once() to require() in autoload + +4.1.1 (2011-07-04) +------------------ + + * added missing file in PEAR package + +4.1.0 (2011-06-30) +------------------ + + * documentation has been converted to ReST + +4.1.0 RC1 (2011-06-17) +---------------------- + +New features: + + * changed the Decorator Plugin to allow replacements in all headers + * added Swift_Mime_Grammar and Swift_Validate to validate an email address + * modified the autoloader to lazy-initialize Swiftmailer + * removed Swift_Mailer::batchSend() + * added NullTransport + * added new plugins: RedirectingPlugin and ImpersonatePlugin + * added a way to send messages asynchronously (Spool) diff --git a/vendor/swiftmailer/swiftmailer/LICENSE b/vendor/swiftmailer/swiftmailer/LICENSE new file mode 100755 index 0000000..674bb2a --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2013 Fabien Potencier + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is furnished +to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/vendor/swiftmailer/swiftmailer/README b/vendor/swiftmailer/swiftmailer/README new file mode 100755 index 0000000..eb5f8bc --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/README @@ -0,0 +1,16 @@ +Swift Mailer +------------ + +Swift Mailer is a component based mailing solution for PHP 5. +It is released under the MIT license. + +Homepage: http://swiftmailer.org +Documentation: http://swiftmailer.org/docs +Mailing List: http://groups.google.com/group/swiftmailer +Bugs: https://github.com/swiftmailer/swiftmailer/issues +Repository: https://github.com/swiftmailer/swiftmailer + +Swift Mailer is highly object-oriented by design and lends itself +to use in complex web application with a great deal of flexibility. + +For full details on usage, see the documentation. diff --git a/vendor/swiftmailer/swiftmailer/README.git b/vendor/swiftmailer/swiftmailer/README.git new file mode 100755 index 0000000..ad9cc2e --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/README.git @@ -0,0 +1,67 @@ +This README applies to anyone who checks out the source from git. + +If you're reading this page on github.com, and you don't have git +installed or know about git, you can download this repository by +using the "download" button on github.com, right above the file +list. + +PREAMBLE: +--------- + +The git repository is structured in the expected way where "master" is the +main branch you should use if you want to have bleeding-edge updates. Any +other branch should be ignored since it will likely contain unstable +and/or experimental developments. + +Generally speaking you should feel safe using the "master" branch in +production code. Anything likely to break will be committed to another +branch. Only bugfixes and clean non-breaking feature additions will be +performed in master. + +All releases (post version 4.0.0) are tagged using the version number of +that release. Earlier versions exist in a subversion repository at the +old sourceforge project page. + + +WHAT IS SWIFT MAILER? +--------------------- + +Swift Mailer is a component based mailing solution for PHP 5. +It is released under the MIT license. + +Homepage: http://swiftmailer.org/ +Documentation: http://swiftmailer.org/docs +Mailing List: http://groups.google.com/group/swiftmailer +Bugs: https://github.com/swiftmailer/swiftmailer/issues +Repository: https://github.com/swiftmailer/swiftmailer + +Swift Mailer is highly object-oriented by design and lends itself +to use in complex web application with a great deal of flexibility. + +For full details on usage, see the documentation. + + +WHY SO MUCH CLUTTER? +-------------------- +As you can probably see, there are a lot more files in here than you find in +the pre-packaged versions. That's because I store notes (UML, RFCs etc) in +the repository. + +The main library files live in /lib and the tests live in /tests. You can run +the tests by pointing your web browser at /test-suite, or by running the +command "php test-suite/run.php". Some tests will be "skipped" if +tests/smoke.conf.php and tests/acceptance.conf.php are not edited. This is +harmless and normal. + +If you want to create a bundled-up package from subversion you can do so if +you have Ant (http://ant.apache.org/) installed. Simply run "ant package" +from this directory and the tar.gz file will be created in the /build +directory. + +Running the command "ant" with no arguments will bundle up the package without +compressing it into a tar.gz file. + +Tests can also be run using "ant test" provided php is on your PATH +environment variable. + +EoM diff --git a/vendor/swiftmailer/swiftmailer/VERSION b/vendor/swiftmailer/swiftmailer/VERSION new file mode 100755 index 0000000..137c6ad --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/VERSION @@ -0,0 +1 @@ +Swift-5.2.0 diff --git a/vendor/swiftmailer/swiftmailer/build.xml b/vendor/swiftmailer/swiftmailer/build.xml new file mode 100755 index 0000000..2260269 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/build.xml @@ -0,0 +1,93 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/vendor/swiftmailer/swiftmailer/composer.json b/vendor/swiftmailer/swiftmailer/composer.json new file mode 100755 index 0000000..b76b7a8 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/composer.json @@ -0,0 +1,31 @@ +{ + "name": "swiftmailer/swiftmailer", + "type": "library", + "description": "Swiftmailer, free feature-rich PHP mailer", + "keywords": ["mail","mailer"], + "homepage": "http://swiftmailer.org", + "license": "MIT", + "authors": [ + { + "name": "Chris Corbyn" + }, + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + } + ], + "require": { + "php": ">=5.2.4" + }, + "require-dev": { + "mockery/mockery": "~0.9.1" + }, + "autoload": { + "files": ["lib/swift_required.php"] + }, + "extra": { + "branch-alias": { + "dev-master": "5.2-dev" + } + } +} diff --git a/vendor/swiftmailer/swiftmailer/create_pear_package.php b/vendor/swiftmailer/swiftmailer/create_pear_package.php new file mode 100755 index 0000000..521d650 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/create_pear_package.php @@ -0,0 +1,42 @@ + date('Y-m-d'), + 'time' => date('H:m:00'), + 'version' => $argv[1], + 'api_version' => $argv[1], + 'stability' => $argv[2], + 'api_stability' => $argv[2], +); + +$context['files'] = ''; +$path = realpath(dirname(__FILE__).'/lib/classes/Swift'); +foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path), RecursiveIteratorIterator::LEAVES_ONLY) as $file) +{ + if (preg_match('/\.php$/', $file)) + { + $name = str_replace($path.'/', '', $file); + $context['files'] .= ' '."\n"; + } +} + +$template = file_get_contents(dirname(__FILE__).'/package.xml.tpl'); +$content = preg_replace_callback('/\{\{\s*([a-zA-Z0-9_]+)\s*\}\}/', 'replace_parameters', $template); +file_put_contents(dirname(__FILE__).'/package.xml', $content); + +function replace_parameters($matches) +{ + global $context; + + return isset($context[$matches[1]]) ? $context[$matches[1]] : null; +} diff --git a/vendor/swiftmailer/swiftmailer/doc/headers.rst b/vendor/swiftmailer/swiftmailer/doc/headers.rst new file mode 100755 index 0000000..6aec23f --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/doc/headers.rst @@ -0,0 +1,742 @@ +Message Headers +=============== + +Sometimes you'll want to add your own headers to a message or modify/remove +headers that are already present. You work with the message's HeaderSet to do +this. + +Header Basics +------------- + +All MIME entities in Swift Mailer -- including the message itself -- +store their headers in a single object called a HeaderSet. This HeaderSet is +retrieved with the ``getHeaders()`` method. + +As mentioned in the previous chapter, everything that forms a part of a message +in Swift Mailer is a MIME entity that is represented by an instance of +``Swift_Mime_MimeEntity``. This includes -- most notably -- the message object +itself, attachments, MIME parts and embedded images. Each of these MIME entities +consists of a body and a set of headers that describe the body. + +For all of the "standard" headers in these MIME entities, such as the +``Content-Type``, there are named methods for working with them, such as +``setContentType()`` and ``getContentType()``. This is because headers are a +moderately complex area of the library. Each header has a slightly different +required structure that it must meet in order to comply with the standards that +govern email (and that are checked by spam blockers etc). + +You fetch the HeaderSet from a MIME entity like so: + +.. code-block:: php + + $message = Swift_Message::newInstance(); + + // Fetch the HeaderSet from a Message object + $headers = $message->getHeaders(); + + $attachment = Swift_Attachment::fromPath('document.pdf'); + + // Fetch the HeaderSet from an attachment object + $headers = $attachment->getHeaders(); + +The job of the HeaderSet is to contain and manage instances of Header objects. +Depending upon the MIME entity the HeaderSet came from, the contents of the +HeaderSet will be different, since an attachment for example has a different +set of headers to those in a message. + +You can find out what the HeaderSet contains with a quick loop, dumping out +the names of the headers: + +.. code-block:: php + + foreach ($headers->getAll() as $header) { + printf("%s
    \n", $header->getFieldName()); + } + + /* + Content-Transfer-Encoding + Content-Type + MIME-Version + Date + Message-ID + From + Subject + To + */ + +You can also dump out the rendered HeaderSet by calling its ``toString()`` +method: + +.. code-block:: php + + echo $headers->toString(); + + /* + Message-ID: <1234869991.499a9ee7f1d5e@swift.generated> + Date: Tue, 17 Feb 2009 22:26:31 +1100 + Subject: Awesome subject! + From: sender@example.org + To: recipient@example.org + MIME-Version: 1.0 + Content-Type: text/plain; charset=utf-8 + Content-Transfer-Encoding: quoted-printable + */ + +Where the complexity comes in is when you want to modify an existing header. +This complexity comes from the fact that each header can be of a slightly +different type (such as a Date header, or a header that contains email +addresses, or a header that has key-value parameters on it!). Each header in the +HeaderSet is an instance of ``Swift_Mime_Header``. They all have common +functionality, but knowing exactly what type of header you're working with will +allow you a little more control. + +You can determine the type of header by comparing the return value of its +``getFieldType()`` method with the constants ``TYPE_TEXT``, +``TYPE_PARAMETERIZED``, ``TYPE_DATE``, ``TYPE_MAILBOX``, ``TYPE_ID`` and +``TYPE_PATH`` which are defined in ``Swift_Mime_Header``. + + +.. code-block:: php + + foreach ($headers->getAll() as $header) { + switch ($header->getFieldType()) { + case Swift_Mime_Header::TYPE_TEXT: $type = 'text'; + break; + case Swift_Mime_Header::TYPE_PARAMETERIZED: $type = 'parameterized'; + break; + case Swift_Mime_Header::TYPE_MAILBOX: $type = 'mailbox'; + break; + case Swift_Mime_Header::TYPE_DATE: $type = 'date'; + break; + case Swift_Mime_Header::TYPE_ID: $type = 'ID'; + break; + case Swift_Mime_Header::TYPE_PATH: $type = 'path'; + break; + } + printf("%s: is a %s header
    \n", $header->getFieldName(), $type); + } + + /* + Content-Transfer-Encoding: is a text header + Content-Type: is a parameterized header + MIME-Version: is a text header + Date: is a date header + Message-ID: is a ID header + From: is a mailbox header + Subject: is a text header + To: is a mailbox header + */ + +Headers can be removed from the set, modified within the set, or added to the +set. + +The following sections show you how to work with the HeaderSet and explain the +details of each implementation of ``Swift_Mime_Header`` that may +exist within the HeaderSet. + +Header Types +------------ + +Because all headers are modeled on different data (dates, addresses, text!) +there are different types of Header in Swift Mailer. Swift Mailer attempts to +categorize all possible MIME headers into more general groups, defined by a +small number of classes. + +Text Headers +~~~~~~~~~~~~ + +Text headers are the simplest type of Header. They contain textual information +with no special information included within it -- for example the Subject +header in a message. + +There's nothing particularly interesting about a text header, though it is +probably the one you'd opt to use if you need to add a custom header to a +message. It represents text just like you'd think it does. If the text +contains characters that are not permitted in a message header (such as new +lines, or non-ascii characters) then the header takes care of encoding the +text so that it can be used. + +No header -- including text headers -- in Swift Mailer is vulnerable to +header-injection attacks. Swift Mailer breaks any attempt at header injection by +encoding the dangerous data into a non-dangerous form. + +It's easy to add a new text header to a HeaderSet. You do this by calling the +HeaderSet's ``addTextHeader()`` method. + +.. code-block:: php + + $message = Swift_Message::newInstance(); + + $headers = $message->getHeaders(); + + $headers->addTextHeader('Your-Header-Name', 'the header value'); + +Changing the value of an existing text header is done by calling it's +``setValue()`` method. + +.. code-block:: php + + $subject = $message->getHeaders()->get('Subject'); + + $subject->setValue('new subject'); + +When output via ``toString()``, a text header produces something like the +following: + +.. code-block:: php + + $subject = $message->getHeaders()->get('Subject'); + + $subject->setValue('amazing subject line'); + + echo $subject->toString(); + + /* + + Subject: amazing subject line + + */ + +If the header contains any characters that are outside of the US-ASCII range +however, they will be encoded. This is nothing to be concerned about since +mail clients will decode them back. + +.. code-block:: php + + $subject = $message->getHeaders()->get('Subject'); + + $subject->setValue('contains – dash'); + + echo $subject->toString(); + + /* + + Subject: contains =?utf-8?Q?=E2=80=93?= dash + + */ + +Parameterized Headers +~~~~~~~~~~~~~~~~~~~~~ + +Parameterized headers are text headers that contain key-value parameters +following the textual content. The Content-Type header of a message is a +parameterized header since it contains charset information after the content +type. + +The parameterized header type is a special type of text header. It extends the +text header by allowing additional information to follow it. All of the methods +from text headers are available in addition to the methods described here. + +Adding a parameterized header to a HeaderSet is done by using the +``addParameterizedHeader()`` method which takes a text value like +``addTextHeader()`` but it also accepts an associative array of +key-value parameters. + +.. code-block:: php + + $message = Swift_Message::newInstance(); + + $headers = $message->getHeaders(); + + $headers->addParameterizedHeader( + 'Header-Name', 'header value', + array('foo' => 'bar') + ); + +To change the text value of the header, call it's ``setValue()`` method just as +you do with text headers. + +To change the parameters in the header, call the header's ``setParameters()`` +method or the ``setParameter()`` method (note the pluralization). + +.. code-block:: php + + $type = $message->getHeaders()->get('Content-Type'); + + // setParameters() takes an associative array + $type->setParameters(array( + 'name' => 'file.txt', + 'charset' => 'iso-8859-1' + )); + + // setParameter() takes two args for $key and $value + $type->setParameter('charset', 'iso-8859-1'); + +When output via ``toString()``, a parameterized header produces something like +the following: + +.. code-block:: php + + $type = $message->getHeaders()->get('Content-Type'); + + $type->setValue('text/html'); + $type->setParameter('charset', 'utf-8'); + + echo $type->toString(); + + /* + + Content-Type: text/html; charset=utf-8 + + */ + +If the header contains any characters that are outside of the US-ASCII range +however, they will be encoded, just like they are for text headers. This is +nothing to be concerned about since mail clients will decode them back. +Likewise, if the parameters contain any non-ascii characters they will be +encoded so that they can be transmitted safely. + +.. code-block:: php + + $attachment = Swift_Attachment::newInstance(); + + $disp = $attachment->getHeaders()->get('Content-Disposition'); + + $disp->setValue('attachment'); + $disp->setParameter('filename', 'report–may.pdf'); + + echo $disp->toString(); + + /* + + Content-Disposition: attachment; filename*=utf-8''report%E2%80%93may.pdf + + */ + +Date Headers +~~~~~~~~~~~~ + +Date headers contains an RFC 2822 formatted date (i.e. what PHP's ``date('r')`` +returns). They are used anywhere a date or time is needed to be presented as a +message header. + +The data on which a date header is modeled is simply a UNIX timestamp such as +that returned by ``time()`` or ``strtotime()``. The timestamp is used to create +a correctly structured RFC 2822 formatted date such as +``Tue, 17 Feb 2009 22:26:31 +1100``. + +The obvious place this header type is used is in the ``Date:`` header of the +message itself. + +It's easy to add a new date header to a HeaderSet. You do this by calling +the HeaderSet's ``addDateHeader()`` method. + +.. code-block:: php + + $message = Swift_Message::newInstance(); + + $headers = $message->getHeaders(); + + $headers->addDateHeader('Your-Header-Name', strtotime('3 days ago')); + +Changing the value of an existing date header is done by calling it's +``setTimestamp()`` method. + +.. code-block:: php + + $date = $message->getHeaders()->get('Date'); + + $date->setTimestamp(time()); + +When output via ``toString()``, a date header produces something like the +following: + +.. code-block:: php + + $date = $message->getHeaders()->get('Date'); + + echo $date->toString(); + + /* + + Date: Wed, 18 Feb 2009 13:35:02 +1100 + + */ + +Mailbox (e-mail address) Headers +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Mailbox headers contain one or more email addresses, possibly with +personalized names attached to them. The data on which they are modeled is +represented by an associative array of email addresses and names. + +Mailbox headers are probably the most complex header type to understand in +Swift Mailer because they accept their input as an array which can take various +forms, as described in the previous chapter. + +All of the headers that contain e-mail addresses in a message -- with the +exception of ``Return-Path:`` which has a stricter syntax -- use this header +type. That is, ``To:``, ``From:`` etc. + +You add a new mailbox header to a HeaderSet by calling the HeaderSet's +``addMailboxHeader()`` method. + +.. code-block:: php + + $message = Swift_Message::newInstance(); + + $headers = $message->getHeaders(); + + $headers->addMailboxHeader('Your-Header-Name', array( + 'person1@example.org' => 'Person Name One', + 'person2@example.org', + 'person3@example.org', + 'person4@example.org' => 'Another named person' + )); + +Changing the value of an existing mailbox header is done by calling it's +``setNameAddresses()`` method. + +.. code-block:: php + + $to = $message->getHeaders()->get('To'); + + $to->setNameAddresses(array( + 'joe@example.org' => 'Joe Bloggs', + 'john@example.org' => 'John Doe', + 'no-name@example.org' + )); + +If you don't wish to concern yourself with the complicated accepted input +formats accepted by ``setNameAddresses()`` as described in the previous chapter +and you only want to set one or more addresses (not names) then you can just +use the ``setAddresses()`` method instead. + +.. code-block:: php + + $to = $message->getHeaders()->get('To'); + + $to->setAddresses(array( + 'joe@example.org', + 'john@example.org', + 'no-name@example.org' + )); + +.. note:: + + Both methods will accept the above input format in practice. + +If all you want to do is set a single address in the header, you can use a +string as the input parameter to ``setAddresses()`` and/or +``setNameAddresses()``. + +.. code-block:: php + + $to = $message->getHeaders()->get('To'); + + $to->setAddresses('joe-bloggs@example.org'); + +When output via ``toString()``, a mailbox header produces something like the +following: + +.. code-block:: php + + $to = $message->getHeaders()->get('To'); + + $to->setNameAddresses(array( + 'person1@example.org' => 'Name of Person', + 'person2@example.org', + 'person3@example.org' => 'Another Person' + )); + + echo $to->toString(); + + /* + + To: Name of Person , person2@example.org, Another Person + + + */ + +ID Headers +~~~~~~~~~~ + +ID headers contain identifiers for the entity (or the message). The most +notable ID header is the Message-ID header on the message itself. + +An ID that exists inside an ID header looks more-or-less less like an email +address. For example, ``<1234955437.499becad62ec2@example.org>``. +The part to the left of the @ sign is usually unique, based on the current time +and some random factor. The part on the right is usually a domain name. + +Any ID passed to the header's ``setId()`` method absolutely MUST conform to +this structure, otherwise you'll get an Exception thrown at you by Swift Mailer +(a ``Swift_RfcComplianceException``). This is to ensure that the generated +email complies with relevant RFC documents and therefore is less likely to be +blocked as spam. + +It's easy to add a new ID header to a HeaderSet. You do this by calling +the HeaderSet's ``addIdHeader()`` method. + +.. code-block:: php + + $message = Swift_Message::newInstance(); + + $headers = $message->getHeaders(); + + $headers->addIdHeader('Your-Header-Name', '123456.unqiue@example.org'); + +Changing the value of an existing date header is done by calling its +``setId()`` method. + +.. code-block:: php + + $msgId = $message->getHeaders()->get('Message-ID'); + + $msgId->setId(time() . '.' . uniqid('thing') . '@example.org'); + +When output via ``toString()``, an ID header produces something like the +following: + +.. code-block:: php + + $msgId = $message->getHeaders()->get('Message-ID'); + + echo $msgId->toString(); + + /* + + Message-ID: <1234955437.499becad62ec2@example.org> + + */ + +Path Headers +~~~~~~~~~~~~ + +Path headers are like very-restricted mailbox headers. They contain a single +email address with no associated name. The Return-Path header of a message is +a path header. + +You add a new path header to a HeaderSet by calling the HeaderSet's +``addPathHeader()`` method. + +.. code-block:: php + + $message = Swift_Message::newInstance(); + + $headers = $message->getHeaders(); + + $headers->addPathHeader('Your-Header-Name', 'person@example.org'); + + +Changing the value of an existing path header is done by calling its +``setAddress()`` method. + +.. code-block:: php + + $return = $message->getHeaders()->get('Return-Path'); + + $return->setAddress('my-address@example.org'); + +When output via ``toString()``, a path header produces something like the +following: + +.. code-block:: php + + $return = $message->getHeaders()->get('Return-Path'); + + $return->setAddress('person@example.org'); + + echo $return->toString(); + + /* + + Return-Path: + + */ + +Header Operations +----------------- + +Working with the headers in a message involves knowing how to use the methods +on the HeaderSet and on the individual Headers within the HeaderSet. + +Adding new Headers +~~~~~~~~~~~~~~~~~~ + +New headers can be added to the HeaderSet by using one of the provided +``add..Header()`` methods. + +To add a header to a MIME entity (such as the message): + +Get the HeaderSet from the entity by via its ``getHeaders()`` method. + +* Add the header to the HeaderSet by calling one of the ``add..Header()`` + methods. + +The added header will appear in the message when it is sent. + +.. code-block:: php + + // Adding a custom header to a message + $message = Swift_Message::newInstance(); + $headers = $message->getHeaders(); + $headers->addTextHeader('X-Mine', 'something here'); + + // Adding a custom header to an attachment + $attachment = Swift_Attachment::fromPath('/path/to/doc.pdf'); + $attachment->getHeaders()->addDateHeader('X-Created-Time', time()); + +Retrieving Headers +~~~~~~~~~~~~~~~~~~ + +Headers are retrieved through the HeaderSet's ``get()`` and ``getAll()`` +methods. + +To get a header, or several headers from a MIME entity: + +* Get the HeaderSet from the entity by via its ``getHeaders()`` method. + +* Get the header(s) from the HeaderSet by calling either ``get()`` or + ``getAll()``. + +When using ``get()`` a single header is returned that matches the name (case +insensitive) that is passed to it. When using ``getAll()`` with a header name, +an array of headers with that name are returned. Calling ``getAll()`` with no +arguments returns an array of all headers present in the entity. + +.. note:: + + It's valid for some headers to appear more than once in a message (e.g. + the Received header). For this reason ``getAll()`` exists to fetch all + headers with a specified name. In addition, ``get()`` accepts an optional + numerical index, starting from zero to specify which header you want more + specifically. + +.. note:: + + If you want to modify the contents of the header and you don't know for + sure what type of header it is then you may need to check the type by + calling its ``getFieldType()`` method. + + .. code-block:: php + + $headers = $message->getHeaders(); + + // Get the To: header + $toHeader = $headers->get('To'); + + // Get all headers named "X-Foo" + $fooHeaders = $headers->getAll('X-Foo'); + + // Get the second header named "X-Foo" + $foo = $headers->get('X-Foo', 1); + + // Get all headers that are present + $all = $headers->getAll(); + +Check if a Header Exists +~~~~~~~~~~~~~~~~~~~~~~~~ + +You can check if a named header is present in a HeaderSet by calling its +``has()`` method. + +To check if a header exists: + +* Get the HeaderSet from the entity by via its ``getHeaders()`` method. + +* Call the HeaderSet's ``has()`` method specifying the header you're looking + for. + +If the header exists, ``true`` will be returned or ``false`` if not. + +.. note:: + + It's valid for some headers to appear more than once in a message (e.g. + the Received header). For this reason ``has()`` accepts an optional + numerical index, starting from zero to specify which header you want to + check more specifically. + + .. code-block:: php + + $headers = $message->getHeaders(); + + // Check if the To: header exists + if ($headers->has('To')) { + echo 'To: exists'; + } + + // Check if an X-Foo header exists twice (i.e. check for the 2nd one) + if ($headers->has('X-Foo', 1)) { + echo 'Second X-Foo header exists'; + } + +Removing Headers +~~~~~~~~~~~~~~~~ + +Removing a Header from the HeaderSet is done by calling the HeaderSet's +``remove()`` or ``removeAll()`` methods. + +To remove an existing header: + +* Get the HeaderSet from the entity by via its ``getHeaders()`` method. + +* Call the HeaderSet's ``remove()`` or ``removeAll()`` methods specifying the + header you want to remove. + +When calling ``remove()`` a single header will be removed. When calling +``removeAll()`` all headers with the given name will be removed. If no headers +exist with the given name, no errors will occur. + +.. note:: + + It's valid for some headers to appear more than once in a message (e.g. + the Received header). For this reason ``remove()`` accepts an optional + numerical index, starting from zero to specify which header you want to + check more specifically. For the same reason, ``removeAll()`` exists to + remove all headers that have the given name. + + .. code-block:: php + + $headers = $message->getHeaders(); + + // Remove the Subject: header + $headers->remove('Subject'); + + // Remove all X-Foo headers + $headers->removeAll('X-Foo'); + + // Remove only the second X-Foo header + $headers->remove('X-Foo', 1); + +Modifying a Header's Content +~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +To change a Header's content you should know what type of header it is and then +call it's appropriate setter method. All headers also have a +``setFieldBodyModel()`` method that accepts a mixed parameter and delegates to +the correct setter. + +To modify an existing header: + +* Get the HeaderSet from the entity by via its ``getHeaders()`` method. + +* Get the Header by using the HeaderSet's ``get()``. + +* Call the Header's appropriate setter method or call the header's + ``setFieldBodyModel()`` method. + +The header will be updated inside the HeaderSet and the changes will be seen +when the message is sent. + +.. code-block:: php + + $headers = $message->getHeaders(); + + // Change the Subject: header + $subj = $headers->get('Subject'); + $subj->setValue('new subject here'); + + // Change the To: header + $to = $headers->get('To'); + $to->setNameAddresses(array( + 'person@example.org' => 'Person', + 'thing@example.org' + )); + + // Using the setFieldBodyModel() just delegates to the correct method + // So here to calls setNameAddresses() + $to->setFieldBodyModel(array( + 'person@example.org' => 'Person', + 'thing@example.org' + )); diff --git a/vendor/swiftmailer/swiftmailer/doc/help-resources.rst b/vendor/swiftmailer/swiftmailer/doc/help-resources.rst new file mode 100755 index 0000000..4208935 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/doc/help-resources.rst @@ -0,0 +1,44 @@ +Getting Help +============ + +There are a number of ways you can get help when using Swift Mailer, depending +upon the nature of your problem. For bug reports and feature requests create a +new ticket in GitHub. For general advice ask on the Google Group +(swiftmailer). + +Submitting Bugs & Feature Requests +---------------------------------- + +Bugs and feature requests should be posted on GitHub. + +If you post a bug or request a feature in the forum, or on the Google Group +you will most likely be asked to create a ticket in `GitHub`_ since it is +simply not feasible to manage such requests from a number of a different +sources. + +When you go to GitHub you will be asked to create a username and password +before you can create a ticket. This is free and takes very little time. + +When you create your ticket, do not assign it to any milestones. A developer +will assess your ticket and re-assign it as needed. + +If your ticket is reporting a bug present in the current version, which was +not present in the previous version please include the tag "regression" in +your ticket. + +GitHub will update you when work is performed on your ticket. + +Ask on the Google Group +----------------------- + +You can seek advice at Google Groups, within the "swiftmailer" `group`_. + +You can post messages to this group if you want help, or there's something you +wish to discuss with the developers and with other users. + +This is probably the fastest way to get help since it is primarily email-based +for most users, though bug reports should not be posted here since they may +not be resolved. + +.. _`GitHub`: https://github.com/swiftmailer/swiftmailer/issues +.. _`group`: http://groups.google.com/group/swiftmailer diff --git a/vendor/swiftmailer/swiftmailer/doc/including-the-files.rst b/vendor/swiftmailer/swiftmailer/doc/including-the-files.rst new file mode 100755 index 0000000..978dca2 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/doc/including-the-files.rst @@ -0,0 +1,46 @@ +Including Swift Mailer (Autoloading) +==================================== + +If you are using Composer, Swift Mailer will be automatically autoloaded. + +If not, you can use the built-in autoloader by requiring the +``swift_required.php`` file:: + + require_once '/path/to/swift-mailer/lib/swift_required.php'; + + /* rest of code goes here */ + +If you want to override the default Swift Mailer configuration, call the +``init()`` method on the ``Swift`` class and pass it a valid PHP callable (a +PHP function name, a PHP 5.3 anonymous function, ...):: + + require_once '/path/to/swift-mailer/lib/swift_required.php'; + + function swiftmailer_configurator() { + // configure Swift Mailer + + Swift_DependencyContainer::getInstance()->... + Swift_Preferences::getInstance()->... + } + + Swift::init('swiftmailer_configurator'); + + /* rest of code goes here */ + +The advantage of using the ``init()`` method is that your code will be +executed only if you use Swift Mailer in your script. + +.. note:: + + While Swift Mailer's autoloader is designed to play nicely with other + autoloaders, sometimes you may have a need to avoid using Swift Mailer's + autoloader and use your own instead. Include the ``swift_init.php`` + instead of the ``swift_required.php`` if you need to do this. The very + minimum include is the ``swift_init.php`` file since Swift Mailer will not + work without the dependency injection this file sets up: + + .. code-block:: php + + require_once '/path/to/swift-mailer/lib/swift_init.php'; + + /* rest of code goes here */ diff --git a/vendor/swiftmailer/swiftmailer/doc/index.rst b/vendor/swiftmailer/swiftmailer/doc/index.rst new file mode 100755 index 0000000..a1a0a92 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/doc/index.rst @@ -0,0 +1,16 @@ +Swiftmailer +=========== + +.. toctree:: + :maxdepth: 2 + + introduction + overview + installing + help-resources + including-the-files + messages + headers + sending + plugins + japanese diff --git a/vendor/swiftmailer/swiftmailer/doc/installing.rst b/vendor/swiftmailer/swiftmailer/doc/installing.rst new file mode 100755 index 0000000..24aeaec --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/doc/installing.rst @@ -0,0 +1,215 @@ +Installing the Library +====================== + +Installing Swift Mailer is trivial. Usually it's just a case of uploading the +extracted source files to your web server. + +Installing with Composer +------------------------ + +If you use Composer to manage your project dependencies, you can install +Swiftmailer like this: + +.. code-block:: bash + + $ php composer.phar require swiftmailer/swiftmailer @stable + +Installing from a Package +------------------------- + +Most users will download a package from the Swift Mailer website and install +Swift Mailer using this. + +If you downloaded Swift Mailer as a ``.tar.gz`` or +``.zip`` file installation is as simple as extracting the archive +and uploading it to your web server. + +Extracting the Library +~~~~~~~~~~~~~~~~~~~~~~ + +You extract the archive by using your favorite unarchiving tool such as +``tar`` or 7-Zip. + +You will need to have access to a program that can open uncompress the +archive. On Windows computers, 7-Zip will work. On Mac and Linux systems you +can use ``tar`` on the command line. + +To extract your downloaded package: + +* Use the "extract" facility of your archiving software. + +The source code will be placed into a directory with the same name as the +archive (e.g. Swift-4.0.0-b1). + +The following example shows the process on Mac OS X and Linux systems using +the ``tar`` command. + +.. code-block:: bash + + $ ls + Swift-4.0.0-dev.tar.gz + $ tar xvzf Swift-4.0.0-dev.tar.gz + Swift-4.0.0-dev/ + Swift-4.0.0-dev/lib/ + Swift-4.0.0-dev/lib/classes/ + Swift-4.0.0-dev/lib/classes/Swift/ + Swift-4.0.0-dev/lib/classes/Swift/ByteStream/ + Swift-4.0.0-dev/lib/classes/Swift/CharacterReader/ + Swift-4.0.0-dev/lib/classes/Swift/CharacterReaderFactory/ + Swift-4.0.0-dev/lib/classes/Swift/CharacterStream/ + Swift-4.0.0-dev/lib/classes/Swift/Encoder/ + + ... etc etc ... + + Swift-4.0.0-dev/tests/unit/Swift/Transport/LoadBalancedTransportTest.php + Swift-4.0.0-dev/tests/unit/Swift/Transport/SendmailTransportTest.php + Swift-4.0.0-dev/tests/unit/Swift/Transport/StreamBufferTest.php + $ cd Swift-4.0.0-dev + $ ls + CHANGES LICENSE ... + $ + +Installing from Git +------------------- + +It's possible to download and install Swift Mailer directly from github.com if +you want to keep up-to-date with ease. + +Swift Mailer's source code is kept in a git repository at github.com so you +can get the source directly from the repository. + +.. note:: + + You do not need to have git installed to use Swift Mailer from GitHub. If + you don't have git installed, go to `GitHub`_ and click the "Download" + button. + +Cloning the Repository +~~~~~~~~~~~~~~~~~~~~~~ + +The repository can be cloned from git://github.com/swiftmailer/swiftmailer.git +using the ``git clone`` command. + +You will need to have ``git`` installed before you can use the +``git clone`` command. + +To clone the repository: + +* Open your favorite terminal environment (command line). + +* Move to the directory you want to clone to. + +* Run the command ``git clone git://github.com/swiftmailer/swiftmailer.git + swiftmailer``. + +The source code will be downloaded into a directory called "swiftmailer". + +The example shows the process on a UNIX-like system such as Linux, BSD or Mac +OS X. + +.. code-block:: bash + + $ cd source_code/ + $ git clone git://github.com/swiftmailer/swiftmailer.git swiftmailer + Initialized empty Git repository in /Users/chris/source_code/swiftmailer/.git/ + remote: Counting objects: 6815, done. + remote: Compressing objects: 100% (2761/2761), done. + remote: Total 6815 (delta 3641), reused 6326 (delta 3286) + Receiving objects: 100% (6815/6815), 4.35 MiB | 162 KiB/s, done. + Resolving deltas: 100% (3641/3641), done. + Checking out files: 100% (1847/1847), done. + $ cd swiftmailer/ + $ ls + CHANGES LICENSE ... + $ + +Installing from PEAR +-------------------- + +.. note:: + + Using PEAR for installing Swiftmailer is deprecated and Swiftmailer 5.1.0 + was the last version published on the PEAR channel; use Composer instead. + +If you want to install Swift Mailer globally on your machine, the easiest +installation method is using the PEAR channel. + +To install the Swift Mailer PEAR package: + +* Run the command ``pear channel-discover pear.swiftmailer.org``. + +* Then, run the command ``pear install swift/swift``. + +Uploading to your Host +---------------------- + +You only need to upload the "lib/" directory to your web host for production +use. All other files and directories are support files not needed in +production. + +You will need FTP, ``rsync`` or similar software installed in order to upload +the "lib/" directory to your web host. + +To upload Swift Mailer: + +* Open your FTP program, or a command line if you prefer rsync/scp. + +* Upload the "lib/" directory to your hosting account. + +The files needed to use Swift Mailer should now be accessible to PHP on your +host. + +The following example shows show you can upload the files using +``rsync`` on Linux or OS X. + +.. note:: + + You do not need to place the files inside your web root. They only need to + be in a place where your PHP scripts can "include" them. + + .. code-block:: bash + + $ rsync -rvz lib d11wtq@swiftmailer.org:swiftmailer + building file list ... done + created directory swiftmailer + lib/ + lib/mime_types.php + lib/preferences.php + lib/swift_required.php + lib/classes/ + lib/classes/Swift/ + lib/classes/Swift/Attachment.php + lib/classes/Swift/CharacterReader.php + ... etc etc ... + lib/dependency_maps/ + lib/dependency_maps/cache_deps.php + lib/dependency_maps/mime_deps.php + lib/dependency_maps/transport_deps.php + + sent 151692 bytes received 2974 bytes 5836.45 bytes/sec + total size is 401405 speedup is 2.60 + $ + +.. _`GitHub`: http://github.com/swiftmailer/swiftmailer + +Troubleshooting +--------------- + +Swift Mailer does not work when used with function overloading as implemented +by ``mbstring`` (``mbstring.func_overload`` set to ``2``). A workaround is to +temporarily change the internal encoding to ``ASCII`` when sending an email: + +.. code-block:: php + + if (function_exists('mb_internal_encoding') && ((int) ini_get('mbstring.func_overload')) & 2) + { + $mbEncoding = mb_internal_encoding(); + mb_internal_encoding('ASCII'); + } + + // Create your message and send it with Swift Mailer + + if (isset($mbEncoding)) + { + mb_internal_encoding($mbEncoding); + } diff --git a/vendor/swiftmailer/swiftmailer/doc/introduction.rst b/vendor/swiftmailer/swiftmailer/doc/introduction.rst new file mode 100755 index 0000000..a85336b --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/doc/introduction.rst @@ -0,0 +1,135 @@ +Introduction +============ + +Swift Mailer is a component-based library for sending e-mails from PHP +applications. + +Organization of this Book +------------------------- + +This book has been written so that those who need information quickly are able +to find what they need, and those who wish to learn more advanced topics can +read deeper into each chapter. + +The book begins with an overview of Swift Mailer, discussing what's included +in the package and preparing you for the remainder of the book. + +It is possible to read this user guide just like any other book (from +beginning to end). Each chapter begins with a discussion of the contents it +contains, followed by a short code sample designed to give you a head start. +As you get further into a chapter you will learn more about Swift Mailer's +capabilities, but often you will be able to head directly to the topic you +wish to learn about. + +Throughout this book you will be presented with code samples, which most +people should find ample to implement Swift Mailer appropriately in their own +projects. We will also use diagrams where appropriate, and where we believe +readers may find it helpful we will discuss some related theory, including +reference to certain documents you are able to find online. + +Code Samples +------------ + +Code samples presented in this book will be displayed on a different colored +background in a monospaced font. Samples are not to be taken as copy & paste +code snippets. + +Code examples are used through the book to clarify what is written in text. +They will sometimes be usable as-is, but they should always be taken as +outline/pseudo code only. + +A code sample will look like this:: + + class AClass + { + ... + } + + // A Comment + $obj = new AClass($arg1, $arg2, ... ); + + /* A note about another way of doing something + $obj = AClass::newInstance($arg1, $arg2, ... ); + + */ + +The presence of 3 dots ``...`` in a code sample indicates that we have left +out a chunk of the code for brevity, they are not actually part of the code. + +We will often place multi-line comments ``/* ... */`` in the code so that we +can show alternative ways of achieving the same result. + +You should read the code examples given and try to understand them. They are +kept concise so that you are not overwhelmed with information. + +History of Swift Mailer +----------------------- + +Swift Mailer began back in 2005 as a one-class project for sending mail over +SMTP. It has since grown into the flexible component-based library that is in +development today. + +Chris Corbyn first posted Swift Mailer on a web forum asking for comments from +other developers. It was never intended as a fully supported open source +project, but members of the forum began to adopt it and make use of it. + +Very quickly feature requests were coming for the ability to add attachments +and use SMTP authentication, along with a number of other "obvious" missing +features. Considering the only alternative was PHPMailer it seemed like a good +time to bring some fresh tools to the table. Chris began working towards a +more component based, PHP5-like approach unlike the existing single-class, +legacy PHP4 approach taken by PHPMailer. + +Members of the forum offered a lot of advice and critique on the code as he +worked through this project and released versions 2 and 3 of the library in +2005 and 2006, which by then had been broken down into smaller classes +offering more flexibility and supporting plugins. To this day the Swift Mailer +team still receive a lot of feature requests from users both on the forum and +in by email. + +Until 2008 Chris was the sole developer of Swift Mailer, but entering 2009 he +gained the support of two experienced developers well-known to him: Paul +Annesley and Christopher Thompson. This has been an extremely welcome change. + +As of September 2009, Chris handed over the maintenance of Swift Mailer to +Fabien Potencier. + +Now 2009 and in its fourth major version Swift Mailer is more object-oriented +and flexible than ever, both from a usability standpoint and from a +development standpoint. + +By no means is Swift Mailer ready to call "finished". There are still many +features that can be added to the library along with the constant refactoring +that happens behind the scenes. + +It's a Library! +--------------- + +Swift Mailer is not an application - it's a library. + +To most experienced developers this is probably an obvious point to make, but +it's certainly worth mentioning. Many people often contact us having gotten +the completely wrong end of the stick in terms of what Swift Mailer is +actually for. + +It's not an application. It does not have a graphical user interface. It +cannot be opened in your web browser directly. + +It's a library (or a framework if you like). It provides a whole lot of +classes that do some very complicated things, so that you don't have to. You +"use" Swift Mailer within an application so that your application can have the +ability to send emails. + +The component-based structure of the library means that you are free to +implement it in a number of different ways and that you can pick and choose +what you want to use. + +An application on the other hand (such as a blog or a forum) is already "put +together" in a particular way, (usually) provides a graphical user interface +and most likely doesn't offer a great deal of integration with your own +application. + +Embrace the structure of the library and use the components it offers to your +advantage. Learning what the components do, rather than blindly copying and +pasting existing code will put you in a great position to build a powerful +application! diff --git a/vendor/swiftmailer/swiftmailer/doc/japanese.rst b/vendor/swiftmailer/swiftmailer/doc/japanese.rst new file mode 100755 index 0000000..34afa7b --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/doc/japanese.rst @@ -0,0 +1,22 @@ +Using Swift Mailer for Japanese Emails +====================================== + +To send emails in Japanese, you need to tweak the default configuration. + +After requiring the Swift Mailer autoloader (by including the +``swift_required.php`` file), call the ``Swift::init()`` method with the +following code:: + + require_once '/path/to/swift-mailer/lib/swift_required.php'; + + Swift::init(function () { + Swift_DependencyContainer::getInstance() + ->register('mime.qpheaderencoder') + ->asAliasOf('mime.base64headerencoder'); + + Swift_Preferences::getInstance()->setCharset('iso-2022-jp'); + }); + + /* rest of code goes here */ + +That's all! diff --git a/vendor/swiftmailer/swiftmailer/doc/messages.rst b/vendor/swiftmailer/swiftmailer/doc/messages.rst new file mode 100755 index 0000000..7a19253 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/doc/messages.rst @@ -0,0 +1,1057 @@ +Creating Messages +================= + +Creating messages in Swift Mailer is done by making use of the various MIME +entities provided with the library. Complex messages can be quickly created +with very little effort. + +Quick Reference for Creating a Message +--------------------------------------- + +You can think of creating a Message as being similar to the steps you perform +when you click the Compose button in your mail client. You give it a subject, +specify some recipients, add any attachments and write your message. + +To create a Message: + +* Call the ``newInstance()`` method of ``Swift_Message``. + +* Set your sender address (``From:``) with ``setFrom()`` or ``setSender()``. + +* Set a subject line with ``setSubject()``. + +* Set recipients with ``setTo()``, ``setCc()`` and/or ``setBcc()``. + +* Set a body with ``setBody()``. + +* Add attachments with ``attach()``. + +.. code-block:: php + + require_once 'lib/swift_required.php'; + + // Create the message + $message = Swift_Message::newInstance() + + // Give the message a subject + ->setSubject('Your subject') + + // Set the From address with an associative array + ->setFrom(array('john@doe.com' => 'John Doe')) + + // Set the To addresses with an associative array + ->setTo(array('receiver@domain.org', 'other@domain.org' => 'A name')) + + // Give it a body + ->setBody('Here is the message itself') + + // And optionally an alternative body + ->addPart('Here is the message itself', 'text/html') + + // Optionally add any attachments + ->attach(Swift_Attachment::fromPath('my-document.pdf')) + ; + +Message Basics +-------------- + +A message is a container for anything you want to send to somebody else. There +are several basic aspects of a message that you should know. + +An e-mail message is made up of several relatively simple entities that are +combined in different ways to achieve different results. All of these entities +have the same fundamental outline but serve a different purpose. The Message +itself can be defined as a MIME entity, an Attachment is a MIME entity, all +MIME parts are MIME entities -- and so on! + +The basic units of each MIME entity -- be it the Message itself, or an +Attachment -- are its Headers and its body: + +.. code-block:: text + + Header-Name: A header value + Other-Header: Another value + + The body content itself + +The Headers of a MIME entity, and its body must conform to some strict +standards defined by various RFC documents. Swift Mailer ensures that these +specifications are followed by using various types of object, including +Encoders and different Header types to generate the entity. + +The Structure of a Message +~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Of all of the MIME entities, a message -- ``Swift_Message`` +is the largest and most complex. It has many properties that can be updated +and it can contain other MIME entities -- attachments for example -- +nested inside it. + +A Message has a lot of different Headers which are there to present +information about the message to the recipients' mail client. Most of these +headers will be familiar to the majority of users, but we'll list the basic +ones. Although it's possible to work directly with the Headers of a Message +(or other MIME entity), the standard Headers have accessor methods provided to +abstract away the complex details for you. For example, although the Date on a +message is written with a strict format, you only need to pass a UNIX +timestamp to ``setDate()``. + ++-------------------------------+------------------------------------------------------------------------------------------------------------------------------------+---------------------------------------------+ +| Header | Description | Accessors | ++===============================+====================================================================================================================================+=============================================+ +| ``Message-ID`` | Identifies this message with a unique ID, usually containing the domain name and time generated | ``getId()`` / ``setId()`` | ++-------------------------------+------------------------------------------------------------------------------------------------------------------------------------+---------------------------------------------+ +| ``Return-Path`` | Specifies where bounces should go (Swift Mailer reads this for other uses) | ``getReturnPath()`` / ``setReturnPath()`` | ++-------------------------------+------------------------------------------------------------------------------------------------------------------------------------+---------------------------------------------+ +| ``From`` | Specifies the address of the person who the message is from. This can be multiple addresses if multiple people wrote the message. | ``getFrom()`` / ``setFrom()`` | ++-------------------------------+------------------------------------------------------------------------------------------------------------------------------------+---------------------------------------------+ +| ``Sender`` | Specifies the address of the person who physically sent the message (higher precedence than ``From:``) | ``getSender()`` / ``setSender()`` | ++-------------------------------+------------------------------------------------------------------------------------------------------------------------------------+---------------------------------------------+ +| ``To`` | Specifies the addresses of the intended recipients | ``getTo()`` / ``setTo()`` | ++-------------------------------+------------------------------------------------------------------------------------------------------------------------------------+---------------------------------------------+ +| ``Cc`` | Specifies the addresses of recipients who will be copied in on the message | ``getCc()`` / ``setCc()`` | ++-------------------------------+------------------------------------------------------------------------------------------------------------------------------------+---------------------------------------------+ +| ``Bcc`` | Specifies the addresses of recipients who the message will be blind-copied to. Other recipients will not be aware of these copies. | ``getBcc()`` / ``setBcc()`` | ++-------------------------------+------------------------------------------------------------------------------------------------------------------------------------+---------------------------------------------+ +| ``Reply-To`` | Specifies the address where replies are sent to | ``getReplyTo()`` / ``setReplyTo()`` | ++-------------------------------+------------------------------------------------------------------------------------------------------------------------------------+---------------------------------------------+ +| ``Subject`` | Specifies the subject line that is displayed in the recipients' mail client | ``getSubject()`` / ``setSubject()`` | ++-------------------------------+------------------------------------------------------------------------------------------------------------------------------------+---------------------------------------------+ +| ``Date`` | Specifies the date at which the message was sent | ``getDate()`` / ``setDate()`` | ++-------------------------------+------------------------------------------------------------------------------------------------------------------------------------+---------------------------------------------+ +| ``Content-Type`` | Specifies the format of the message (usually text/plain or text/html) | ``getContentType()`` / ``setContentType()`` | ++-------------------------------+------------------------------------------------------------------------------------------------------------------------------------+---------------------------------------------+ +| ``Content-Transfer-Encoding`` | Specifies the encoding scheme in the message | ``getEncoder()`` / ``setEncoder()`` | ++-------------------------------+------------------------------------------------------------------------------------------------------------------------------------+---------------------------------------------+ + +Working with a Message Object +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Although there are a lot of available methods on a message object, you only +need to make use of a small subset of them. Usually you'll use +``setSubject()``, ``setTo()`` and +``setFrom()`` before setting the body of your message with +``setBody()``. + +Calling methods is simple. You just call them like functions, but using the +object operator "``->``" to do so. If you've created +a message object and called it ``$message`` then you'd set a +subject on it like so: + +.. code-block:: php + + require_once 'lib/swift_required.php'; + + $message = Swift_Message::newInstance(); + $message->setSubject('My subject'); + +All MIME entities (including a message) have a ``toString()`` +method that you can call if you want to take a look at what is going to be +sent. For example, if you ``echo +$message->toString();`` you would see something like this: + +.. code-block:: bash + + Message-ID: <1230173678.4952f5eeb1432@swift.generated> + Date: Thu, 25 Dec 2008 13:54:38 +1100 + Subject: Example subject + From: Chris Corbyn + To: Receiver Name + MIME-Version: 1.0 + Content-Type: text/plain; charset=utf-8 + Content-Transfer-Encoding: quoted-printable + + Here is the message + +We'll take a closer look at the methods you use to create your message in the +following sections. + +Adding Content to Your Message +------------------------------ + +Rich content can be added to messages in Swift Mailer with relative ease by +calling methods such as ``setSubject()``, ``setBody()``, ``addPart()`` and +``attach()``. + +Setting the Subject Line +~~~~~~~~~~~~~~~~~~~~~~~~ + +The subject line, displayed in the recipients' mail client can be set with the +``setSubject()`` method, or as a parameter to ``Swift_Message::newInstance()``. + +To set the subject of your Message: + +* Call the ``setSubject()`` method of the Message, or specify it at the time + you create the message. + + .. code-block:: php + + // Pass it as a parameter when you create the message + $message = Swift_Message::newInstance('My amazing subject'); + + // Or set it after like this + $message->setSubject('My amazing subject'); + +Setting the Body Content +~~~~~~~~~~~~~~~~~~~~~~~~ + +The body of the message -- seen when the user opens the message -- +is specified by calling the ``setBody()`` method. If an alternative body is to +be included ``addPart()`` can be used. + +The body of a message is the main part that is read by the user. Often people +want to send a message in HTML format (``text/html``), other +times people want to send in plain text (``text/plain``), or +sometimes people want to send both versions and allow the recipient to choose +how they view the message. + +As a rule of thumb, if you're going to send a HTML email, always include a +plain-text equivalent of the same content so that users who prefer to read +plain text can do so. + +To set the body of your Message: + +* Call the ``setBody()`` method of the Message, or specify it at the time you + create the message. + +* Add any alternative bodies with ``addPart()``. + +If the recipient's mail client offers preferences for displaying text vs. HTML +then the mail client will present that part to the user where available. In +other cases the mail client will display the "best" part it can - usually HTML +if you've included HTML. + +.. code-block:: php + + // Pass it as a parameter when you create the message + $message = Swift_Message::newInstance('Subject here', 'My amazing body'); + + // Or set it after like this + $message->setBody('My amazing body', 'text/html'); + + // Add alternative parts with addPart() + $message->addPart('My amazing body in plain text', 'text/plain'); + +Attaching Files +--------------- + +Attachments are downloadable parts of a message and can be added by calling +the ``attach()`` method on the message. You can add attachments that exist on +disk, or you can create attachments on-the-fly. + +Attachments are actually an interesting area of Swift Mailer and something +that could put a lot of power at your fingertips if you grasp the concept +behind the way a message is held together. + +Although we refer to files sent over e-mails as "attachments" -- because +they're attached to the message -- lots of other parts of the message are +actually "attached" even if we don't refer to these parts as attachments. + +File attachments are created by the ``Swift_Attachment`` class +and then attached to the message via the ``attach()`` method on +it. For all of the "every day" MIME types such as all image formats, word +documents, PDFs and spreadsheets you don't need to explicitly set the +content-type of the attachment, though it would do no harm to do so. For less +common formats you should set the content-type -- which we'll cover in a +moment. + +Attaching Existing Files +~~~~~~~~~~~~~~~~~~~~~~~~ + +Files that already exist, either on disk or at a URL can be attached to a +message with just one line of code, using ``Swift_Attachment::fromPath()``. + +You can attach files that exist locally, or if your PHP installation has +``allow_url_fopen`` turned on you can attach files from other +websites. + +To attach an existing file: + +* Create an attachment with ``Swift_Attachment::fromPath()``. + +* Add the attachment to the message with ``attach()``. + +The attachment will be presented to the recipient as a downloadable file with +the same filename as the one you attached. + +.. code-block:: php + + // Create the attachment + // * Note that you can technically leave the content-type parameter out + $attachment = Swift_Attachment::fromPath('/path/to/image.jpg', 'image/jpeg'); + + // Attach it to the message + $message->attach($attachment); + + + // The two statements above could be written in one line instead + $message->attach(Swift_Attachment::fromPath('/path/to/image.jpg')); + + + // You can attach files from a URL if allow_url_fopen is on in php.ini + $message->attach(Swift_Attachment::fromPath('http://site.tld/logo.png')); + +Setting the Filename +~~~~~~~~~~~~~~~~~~~~ + +Usually you don't need to explicitly set the filename of an attachment because +the name of the attached file will be used by default, but if you want to set +the filename you use the ``setFilename()`` method of the Attachment. + +To change the filename of an attachment: + +* Call its ``setFilename()`` method. + +The attachment will be attached in the normal way, but meta-data sent inside +the email will rename the file to something else. + +.. code-block:: php + + // Create the attachment and call its setFilename() method + $attachment = Swift_Attachment::fromPath('/path/to/image.jpg') + ->setFilename('cool.jpg'); + + + // Because there's a fluid interface, you can do this in one statement + $message->attach( + Swift_Attachment::fromPath('/path/to/image.jpg')->setFilename('cool.jpg') + ); + +Attaching Dynamic Content +~~~~~~~~~~~~~~~~~~~~~~~~~ + +Files that are generated at runtime, such as PDF documents or images created +via GD can be attached directly to a message without writing them out to disk. +Use the standard ``Swift_Attachment::newInstance()`` method. + +To attach dynamically created content: + +* Create your content as you normally would. + +* Create an attachment with ``Swift_Attachment::newInstance()``, specifying + the source data of your content along with a name and the content-type. + +* Add the attachment to the message with ``attach()``. + +The attachment will be presented to the recipient as a downloadable file +with the filename and content-type you specify. + +.. note:: + + If you would usually write the file to disk anyway you should just attach + it with ``Swift_Attachment::fromPath()`` since this will use less memory: + + .. code-block:: php + + // Create your file contents in the normal way, but don't write them to disk + $data = create_my_pdf_data(); + + // Create the attachment with your data + $attachment = Swift_Attachment::newInstance($data, 'my-file.pdf', 'application/pdf'); + + // Attach it to the message + $message->attach($attachment); + + + // You can alternatively use method chaining to build the attachment + $attachment = Swift_Attachment::newInstance() + ->setFilename('my-file.pdf') + ->setContentType('application/pdf') + ->setBody($data) + ; + +Changing the Disposition +~~~~~~~~~~~~~~~~~~~~~~~~ + +Attachments just appear as files that can be saved to the Desktop if desired. +You can make attachment appear inline where possible by using the +``setDisposition()`` method of an attachment. + +To make an attachment appear inline: + +* Call its ``setDisposition()`` method. + +The attachment will be displayed within the email viewing window if the mail +client knows how to display it. + +.. note:: + + If you try to create an inline attachment for a non-displayable file type + such as a ZIP file, the mail client should just present the attachment as + normal: + + .. code-block:: php + + // Create the attachment and call its setDisposition() method + $attachment = Swift_Attachment::fromPath('/path/to/image.jpg') + ->setDisposition('inline'); + + + // Because there's a fluid interface, you can do this in one statement + $message->attach( + Swift_Attachment::fromPath('/path/to/image.jpg')->setDisposition('inline') + ); + +Embedding Inline Media Files +~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Often people want to include an image or other content inline with a HTML +message. It's easy to do this with HTML linking to remote resources, but this +approach is usually blocked by mail clients. Swift Mailer allows you to embed +your media directly into the message. + +Mail clients usually block downloads from remote resources because this +technique was often abused as a mean of tracking who opened an email. If +you're sending a HTML email and you want to include an image in the message +another approach you can take is to embed the image directly. + +Swift Mailer makes embedding files into messages extremely streamlined. You +embed a file by calling the ``embed()`` method of the message, +which returns a value you can use in a ``src`` or +``href`` attribute in your HTML. + +Just like with attachments, it's possible to embed dynamically generated +content without having an existing file available. + +The embedded files are sent in the email as a special type of attachment that +has a unique ID used to reference them within your HTML attributes. On mail +clients that do not support embedded files they may appear as attachments. + +Although this is commonly done for images, in theory it will work for any +displayable (or playable) media type. Support for other media types (such as +video) is dependent on the mail client however. + +Embedding Existing Files +........................ + +Files that already exist, either on disk or at a URL can be embedded in a +message with just one line of code, using ``Swift_EmbeddedFile::fromPath()``. + +You can embed files that exist locally, or if your PHP installation has +``allow_url_fopen`` turned on you can embed files from other websites. + +To embed an existing file: + +* Create a message object with ``Swift_Message::newInstance()``. + +* Set the body as HTML, and embed a file at the correct point in the message with ``embed()``. + +The file will be displayed with the message inline with the HTML wherever its ID +is used as a ``src`` attribute. + +.. note:: + + ``Swift_Image`` and ``Swift_EmbeddedFile`` are just aliases of one + another. ``Swift_Image`` exists for semantic purposes. + +.. note:: + + You can embed files in two stages if you prefer. Just capture the return + value of ``embed()`` in a variable and use that as the ``src`` attribute. + + .. code-block:: php + + // Create the message + $message = Swift_Message::newInstance('My subject'); + + // Set the body + $message->setBody( + '' . + ' ' . + ' ' . + ' Here is an image Image' . + ' Rest of message' . + ' ' . + '', + 'text/html' // Mark the content-type as HTML + ); + + // You can embed files from a URL if allow_url_fopen is on in php.ini + $message->setBody( + '' . + ' ' . + ' ' . + ' Here is an image Image' . + ' Rest of message' . + ' ' . + '', + 'text/html' + ); + + + // If placing the embed() code inline becomes cumbersome + // it's easy to do this in two steps + $cid = $message->embed(Swift_Image::fromPath('image.png')); + + $message->setBody( + '' . + ' ' . + ' ' . + ' Here is an image Image' . + ' Rest of message' . + ' ' . + '', + 'text/html' // Mark the content-type as HTML + ); + +Embedding Dynamic Content +......................... + +Images that are generated at runtime, such as images created via GD can be +embedded directly to a message without writing them out to disk. Use the +standard ``Swift_Image::newInstance()`` method. + +To embed dynamically created content: + +* Create a message object with ``Swift_Message::newInstance()``. + +* Set the body as HTML, and embed a file at the correct point in the message + with ``embed()``. You will need to specify a filename and a content-type. + +The file will be displayed with the message inline with the HTML wherever its ID +is used as a ``src`` attribute. + +.. note:: + + ``Swift_Image`` and ``Swift_EmbeddedFile`` are just aliases of one + another. ``Swift_Image`` exists for semantic purposes. + +.. note:: + + You can embed files in two stages if you prefer. Just capture the return + value of ``embed()`` in a variable and use that as the ``src`` attribute. + + .. code-block:: php + + // Create your file contents in the normal way, but don't write them to disk + $img_data = create_my_image_data(); + + // Create the message + $message = Swift_Message::newInstance('My subject'); + + // Set the body + $message->setBody( + '' . + ' ' . + ' ' . + ' Here is an image Image' . + ' Rest of message' . + ' ' . + '', + 'text/html' // Mark the content-type as HTML + ); + + + // If placing the embed() code inline becomes cumbersome + // it's easy to do this in two steps + $cid = $message->embed(Swift_Image::newInstance($img_data, 'image.jpg', 'image/jpeg')); + + $message->setBody( + '' . + ' ' . + ' ' . + ' Here is an image Image' . + ' Rest of message' . + ' ' . + '', + 'text/html' // Mark the content-type as HTML + ); + +Adding Recipients to Your Message +--------------------------------- + +Recipients are specified within the message itself via ``setTo()``, ``setCc()`` +and ``setBcc()``. Swift Mailer reads these recipients from the message when it +gets sent so that it knows where to send the message to. + +Message recipients are one of three types: + +* ``To:`` recipients -- the primary recipients (required) + +* ``Cc:`` recipients -- receive a copy of the message (optional) + +* ``Bcc:`` recipients -- hidden from other recipients (optional) + +Each type can contain one, or several addresses. It's possible to list only +the addresses of the recipients, or you can personalize the address by +providing the real name of the recipient. + +Make sure to add only valid email addresses as recipients. If you try to add an +invalid email address with ``setTo()``, ``setCc()`` or ``setBcc()``, Swift +Mailer will throw a ``Swift_RfcComplianceException``. + +If you add recipients automatically based on a data source that may contain +invalid email addresses, you can prevent possible exceptions by validating the +addresses using ``Swift_Validate::email($email)`` and only adding addresses +that validate. Another way would be to wrap your ``setTo()``, ``setCc()`` and +``setBcc()`` calls in a try-catch block and handle the +``Swift_RfcComplianceException`` in the catch block. + +.. sidebar:: Syntax for Addresses + + If you only wish to refer to a single email address (for example your + ``From:`` address) then you can just use a string. + + .. code-block:: php + + $message->setFrom('some@address.tld'); + + If you want to include a name then you must use an associative array. + + .. code-block:: php + + $message->setFrom(array('some@address.tld' => 'The Name')); + + If you want to include multiple addresses then you must use an array. + + .. code-block:: php + + $message->setTo(array('some@address.tld', 'other@address.tld')); + + You can mix personalized (addresses with a name) and non-personalized + addresses in the same list by mixing the use of associative and + non-associative array syntax. + + .. code-block:: php + + $message->setTo(array( + 'recipient-with-name@example.org' => 'Recipient Name One', + 'no-name@example.org', // Note that this is not a key-value pair + 'named-recipient@example.org' => 'Recipient Name Two' + )); + +Setting ``To:`` Recipients +~~~~~~~~~~~~~~~~~~~~~~~~~~ + +``To:`` recipients are required in a message and are set with the +``setTo()`` or ``addTo()`` methods of the message. + +To set ``To:`` recipients, create the message object using either +``new Swift_Message( ... )`` or ``Swift_Message::newInstance( ... )``, +then call the ``setTo()`` method with a complete array of addresses, or use the +``addTo()`` method to iteratively add recipients. + +The ``setTo()`` method accepts input in various formats as described earlier in +this chapter. The ``addTo()`` method takes either one or two parameters. The +first being the email address and the second optional parameter being the name +of the recipient. + +``To:`` recipients are visible in the message headers and will be +seen by the other recipients. + +.. note:: + + Multiple calls to ``setTo()`` will not add new recipients -- each + call overrides the previous calls. If you want to iteratively add + recipients, use the ``addTo()`` method. + + .. code-block:: php + + // Using setTo() to set all recipients in one go + $message->setTo(array( + 'person1@example.org', + 'person2@otherdomain.org' => 'Person 2 Name', + 'person3@example.org', + 'person4@example.org', + 'person5@example.org' => 'Person 5 Name' + )); + + // Using addTo() to add recipients iteratively + $message->addTo('person1@example.org'); + $message->addTo('person2@example.org', 'Person 2 Name'); + +Setting ``Cc:`` Recipients +~~~~~~~~~~~~~~~~~~~~~~~~~~ + +``Cc:`` recipients are set with the ``setCc()`` or ``addCc()`` methods of the +message. + +To set ``Cc:`` recipients, create the message object using either +``new Swift_Message( ... )`` or ``Swift_Message::newInstance( ... )``, then call +the ``setCc()`` method with a complete array of addresses, or use the +``addCc()`` method to iteratively add recipients. + +The ``setCc()`` method accepts input in various formats as described earlier in +this chapter. The ``addCc()`` method takes either one or two parameters. The +first being the email address and the second optional parameter being the name +of the recipient. + +``Cc:`` recipients are visible in the message headers and will be +seen by the other recipients. + +.. note:: + + Multiple calls to ``setCc()`` will not add new recipients -- each + call overrides the previous calls. If you want to iteratively add Cc: + recipients, use the ``addCc()`` method. + + .. code-block:: php + + // Using setCc() to set all recipients in one go + $message->setCc(array( + 'person1@example.org', + 'person2@otherdomain.org' => 'Person 2 Name', + 'person3@example.org', + 'person4@example.org', + 'person5@example.org' => 'Person 5 Name' + )); + + // Using addCc() to add recipients iteratively + $message->addCc('person1@example.org'); + $message->addCc('person2@example.org', 'Person 2 Name'); + +Setting ``Bcc:`` Recipients +~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +``Bcc:`` recipients receive a copy of the message without anybody else knowing +it, and are set with the ``setBcc()`` or ``addBcc()`` methods of the message. + +To set ``Bcc:`` recipients, create the message object using either ``new +Swift_Message( ... )`` or ``Swift_Message::newInstance( ... )``, then call the +``setBcc()`` method with a complete array of addresses, or use +the ``addBcc()`` method to iteratively add recipients. + +The ``setBcc()`` method accepts input in various formats as described earlier in +this chapter. The ``addBcc()`` method takes either one or two parameters. The +first being the email address and the second optional parameter being the name +of the recipient. + +Only the individual ``Bcc:`` recipient will see their address in the message +headers. Other recipients (including other ``Bcc:`` recipients) will not see the +address. + +.. note:: + + Multiple calls to ``setBcc()`` will not add new recipients -- each + call overrides the previous calls. If you want to iteratively add Bcc: + recipients, use the ``addBcc()`` method. + + .. code-block:: php + + // Using setBcc() to set all recipients in one go + $message->setBcc(array( + 'person1@example.org', + 'person2@otherdomain.org' => 'Person 2 Name', + 'person3@example.org', + 'person4@example.org', + 'person5@example.org' => 'Person 5 Name' + )); + + // Using addBcc() to add recipients iteratively + $message->addBcc('person1@example.org'); + $message->addBcc('person2@example.org', 'Person 2 Name'); + +Specifying Sender Details +------------------------- + +An email must include information about who sent it. Usually this is managed +by the ``From:`` address, however there are other options. + +The sender information is contained in three possible places: + +* ``From:`` -- the address(es) of who wrote the message (required) + +* ``Sender:`` -- the address of the single person who sent the message + (optional) + +* ``Return-Path:`` -- the address where bounces should go to (optional) + +You must always include a ``From:`` address by using ``setFrom()`` on the +message. Swift Mailer will use this as the default ``Return-Path:`` unless +otherwise specified. + +The ``Sender:`` address exists because the person who actually sent the email +may not be the person who wrote the email. It has a higher precedence than the +``From:`` address and will be used as the ``Return-Path:`` unless otherwise +specified. + +Setting the ``From:`` Address +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +A ``From:`` address is required and is set with the ``setFrom()`` method of the +message. ``From:`` addresses specify who actually wrote the email, and usually who sent it. + +What most people probably don't realise is that you can have more than one +``From:`` address if more than one person wrote the email -- for example if an +email was put together by a committee. + +To set the ``From:`` address(es): + +* Call the ``setFrom()`` method on the Message. + +The ``From:`` address(es) are visible in the message headers and +will be seen by the recipients. + +.. note:: + + If you set multiple ``From:`` addresses then you absolutely must set a + ``Sender:`` address to indicate who physically sent the message. + + .. code-block:: php + + // Set a single From: address + $message->setFrom('your@address.tld'); + + // Set a From: address including a name + $message->setFrom(array('your@address.tld' => 'Your Name')); + + // Set multiple From: addresses if multiple people wrote the email + $message->setFrom(array( + 'person1@example.org' => 'Sender One', + 'person2@example.org' => 'Sender Two' + )); + +Setting the ``Sender:`` Address +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +A ``Sender:`` address specifies who sent the message and is set with the +``setSender()`` method of the message. + +To set the ``Sender:`` address: + +* Call the ``setSender()`` method on the Message. + +The ``Sender:`` address is visible in the message headers and will be seen by +the recipients. + +This address will be used as the ``Return-Path:`` unless otherwise specified. + +.. note:: + + If you set multiple ``From:`` addresses then you absolutely must set a + ``Sender:`` address to indicate who physically sent the message. + +You must not set more than one sender address on a message because it's not +possible for more than one person to send a single message. + +.. code-block:: php + + $message->setSender('your@address.tld'); + +Setting the ``Return-Path:`` (Bounce) Address +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The ``Return-Path:`` address specifies where bounce notifications should +be sent and is set with the ``setReturnPath()`` method of the message. + +You can only have one ``Return-Path:`` and it must not include +a personal name. + +To set the ``Return-Path:`` address: + +* Call the ``setReturnPath()`` method on the Message. + +Bounce notifications will be sent to this address. + +.. code-block:: php + + $message->setReturnPath('bounces@address.tld'); + + +Signed/Encrypted Message +------------------------ + +To increase the integrity/security of a message it is possible to sign and/or +encrypt an message using one or multiple signers. + +S/MIME +~~~~~~ + +S/MIME can sign and/or encrypt a message using the OpenSSL extension. + +When signing a message, the signer creates a signature of the entire content of the message (including attachments). + +The certificate and private key must be PEM encoded, and can be either created using for example OpenSSL or +obtained at an official Certificate Authority (CA). + +**The recipient must have the CA certificate in the list of trusted issuers in order to verify the signature.** + +**Make sure the certificate supports emailProtection.** + +When using OpenSSL this can done by the including the *-addtrust emailProtection* parameter when creating the certificate. + +.. code-block:: php + + $message = Swift_Message::newInstance(); + + $smimeSigner = Swift_Signers_SMimeSigner::newInstance(); + $smimeSigner->setSignCertificate('/path/to/certificate.pem', '/path/to/private-key.pem'); + $message->attachSigner($smimeSigner); + +When the private key is secured using a passphrase use the following instead. + +.. code-block:: php + + $message = Swift_Message::newInstance(); + + $smimeSigner = Swift_Signers_SMimeSigner::newInstance(); + $smimeSigner->setSignCertificate('/path/to/certificate.pem', array('/path/to/private-key.pem', 'passphrase')); + $message->attachSigner($smimeSigner); + +By default the signature is added as attachment, +making the message still readable for mailing agents not supporting signed messages. + +Storing the message as binary is also possible but not recommended. + +.. code-block:: php + + $smimeSigner->setSignCertificate('/path/to/certificate.pem', '/path/to/private-key.pem', PKCS7_BINARY); + +When encrypting the message (also known as enveloping), the entire message (including attachments) +is encrypted using a certificate, and the recipient can then decrypt the message using corresponding private key. + +Encrypting ensures nobody can read the contents of the message without the private key. + +Normally the recipient provides a certificate for encrypting and keeping the decryption key private. + +Using both signing and encrypting is also possible. + +.. code-block:: php + + $message = Swift_Message::newInstance(); + + $smimeSigner = Swift_Signers_SMimeSigner::newInstance(); + $smimeSigner->setSignCertificate('/path/to/sign-certificate.pem', '/path/to/private-key.pem'); + $smimeSigner->setEncryptCertificate('/path/to/encrypt-certificate.pem'); + $message->attachSigner($smimeSigner); + +The used encryption cipher can be set as the second parameter of setEncryptCertificate() + +See http://php.net/manual/openssl.ciphers for a list of supported ciphers. + +By default the message is first signed and then encrypted, this can be changed by adding. + +.. code-block:: php + + $smimeSigner->setSignThenEncrypt(false); + +**Changing this is not recommended as most mail agents don't support this none-standard way.** + +Only when having trouble with sign then encrypt method, this should be changed. + +Requesting a Read Receipt +------------------------- + +It is possible to request a read-receipt to be sent to an address when the +email is opened. To request a read receipt set the address with +``setReadReceiptTo()``. + +To request a read receipt: + +* Set the address you want the receipt to be sent to with the + ``setReadReceiptTo()`` method on the Message. + +When the email is opened, if the mail client supports it a notification will be sent to this address. + +.. note:: + + Read receipts won't work for the majority of recipients since many mail + clients auto-disable them. Those clients that will send a read receipt + will make the user aware that one has been requested. + + .. code-block:: php + + $message->setReadReceiptTo('your@address.tld'); + +Setting the Character Set +------------------------- + +The character set of the message (and it's MIME parts) is set with the +``setCharset()`` method. You can also change the global default of UTF-8 by +working with the ``Swift_Preferences`` class. + +Swift Mailer will default to the UTF-8 character set unless otherwise +overridden. UTF-8 will work in most instances since it includes all of the +standard US keyboard characters in addition to most international characters. + +It is absolutely vital however that you know what character set your message +(or it's MIME parts) are written in otherwise your message may be received +completely garbled. + +There are two places in Swift Mailer where you can change the character set: + +* In the ``Swift_Preferences`` class + +* On each individual message and/or MIME part + +To set the character set of your Message: + +* Change the global UTF-8 setting by calling + ``Swift_Preferences::setCharset()``; or + +* Call the ``setCharset()`` method on the message or the MIME part. + + .. code-block:: php + + // Approach 1: Change the global setting (suggested) + Swift_Preferences::getInstance()->setCharset('iso-8859-2'); + + // Approach 2: Call the setCharset() method of the message + $message = Swift_Message::newInstance() + ->setCharset('iso-8859-2'); + + // Approach 3: Specify the charset when setting the body + $message->setBody('My body', 'text/html', 'iso-8859-2'); + + // Approach 4: Specify the charset for each part added + $message->addPart('My part', 'text/plain', 'iso-8859-2'); + +Setting the Line Length +----------------------- + +The length of lines in a message can be changed by using the ``setMaxLineLength()`` method on the message. It should be kept to less than +1000 characters. + +Swift Mailer defaults to using 78 characters per line in a message. This is +done for historical reasons and so that the message can be easily viewed in +plain-text terminals. + +To change the maximum length of lines in your Message: + +* Call the ``setMaxLineLength()`` method on the Message. + +Lines that are longer than the line length specified will be wrapped between +words. + +.. note:: + + You should never set a maximum length longer than 1000 characters + according to RFC 2822. Doing so could have unspecified side-effects such + as truncating parts of your message when it is transported between SMTP + servers. + + .. code-block:: php + + $message->setMaxLineLength(1000); + +Setting the Message Priority +---------------------------- + +You can change the priority of the message with ``setPriority()``. Setting the +priority will not change the way your email is sent -- it is purely an +indicative setting for the recipient. + +The priority of a message is an indication to the recipient what significance +it has. Swift Mailer allows you to set the priority by calling the ``setPriority`` method. This method takes an integer value between 1 and 5: + +* Highest +* High +* Normal +* Low +* Lowest + +To set the message priority: + +* Set the priority as an integer between 1 and 5 with the ``setPriority()`` + method on the Message. + +.. code-block:: php + + // Indicate "High" priority + $message->setPriority(2); diff --git a/vendor/swiftmailer/swiftmailer/doc/overview.rst b/vendor/swiftmailer/swiftmailer/doc/overview.rst new file mode 100755 index 0000000..c912617 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/doc/overview.rst @@ -0,0 +1,161 @@ +Library Overview +================ + +Most features (and more) of your every day mail client software are provided +by Swift Mailer, using object-oriented PHP code as the interface. + +In this chapter we will take a short tour of the various components, which put +together form the Swift Mailer library as a whole. You will learn key +terminology used throughout the rest of this book and you will gain a little +understanding of the classes you will work with as you integrate Swift Mailer +into your application. + +This chapter is intended to prepare you for the information contained in the +subsequent chapters of this book. You may choose to skip this chapter if you +are fairly technically minded, though it is likely to save you some time in +the long run if you at least read between the lines here. + +System Requirements +------------------- + +The basic requirements to operate Swift Mailer are extremely minimal and +easily achieved. Historically, Swift Mailer has supported both PHP 4 and PHP 5 +by following a parallel development workflow. Now in it's fourth major +version, and Swift Mailer operates on servers running PHP 5.2 or higher. + +The library aims to work with as many PHP 5 projects as possible: + +* PHP 5.2 or higher, with the SPL extension (standard) + +* Limited network access to connect to remote SMTP servers + +* 8 MB or more memory limit (Swift Mailer uses around 2 MB) + +Component Breakdown +------------------- + +Swift Mailer is made up of many classes. Each of these classes can be grouped +into a general "component" group which describes the task it is designed to +perform. + +We'll take a brief look at the components which form Swift Mailer in this +section of the book. + +The Mailer +~~~~~~~~~~ + +The mailer class, ``Swift_Mailer`` is the central class in the library where +all of the other components meet one another. ``Swift_Mailer`` acts as a sort +of message dispatcher, communicating with the underlying Transport to deliver +your Message to all intended recipients. + +If you were to dig around in the source code for Swift Mailer you'd notice +that ``Swift_Mailer`` itself is pretty bare. It delegates to other objects for +most tasks and in theory, if you knew the internals of Swift Mailer well you +could by-pass this class entirely. We wouldn't advise doing such a thing +however -- there are reasons this class exists: + +* for consistency, regardless of the Transport used + +* to provide abstraction from the internals in the event internal API changes + are made + +* to provide convenience wrappers around aspects of the internal API + +An instance of ``Swift_Mailer`` is created by the developer before sending any +Messages. + +Transports +~~~~~~~~~~ + +Transports are the classes in Swift Mailer that are responsible for +communicating with a service in order to deliver a Message. There are several +types of Transport in Swift Mailer, all of which implement the Swift_Transport +interface and offer underlying start(), stop() and send() methods. + +Typically you will not need to know how a Transport works under-the-surface, +you will only need to know how to create an instance of one, and which one to +use for your environment. + ++---------------------------------+---------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------+ +| Class | Features | Pros/cons | ++=================================+=============================================================================================+===============================================================================================================================================+ +| ``Swift_SmtpTransport`` | Sends messages over SMTP; Supports Authentication; Supports Encryption | Very portable; Pleasingly predictable results; Provides good feedback | ++---------------------------------+---------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------+ +| ``Swift_SendmailTransport`` | Communicates with a locally installed ``sendmail`` executable (Linux/UNIX) | Quick time-to-run; Provides less-accurate feedback than SMTP; Requires ``sendmail`` installation | ++---------------------------------+---------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------+ +| ``Swift_MailTransport`` | Uses PHP's built-in ``mail()`` function | Very portable; Potentially unpredictable results; Provides extremely weak feedback | ++---------------------------------+---------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------+ +| ``Swift_LoadBalancedTransport`` | Cycles through a collection of the other Transports to manage load-reduction | Provides graceful fallback if one Transport fails (e.g. an SMTP server is down); Keeps the load on remote services down by spreading the work | ++---------------------------------+---------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------+ +| ``Swift_FailoverTransport`` | Works in conjunction with a collection of the other Transports to provide high-availability | Provides graceful fallback if one Transport fails (e.g. an SMTP server is down) | ++---------------------------------+---------------------------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------+ + +MIME Entities +~~~~~~~~~~~~~ + +Everything that forms part of a Message is called a MIME Entity. All MIME +entities in Swift Mailer share a common set of features. There are various +types of MIME entity that serve different purposes such as Attachments and +MIME parts. + +An e-mail message is made up of several relatively simple entities that are +combined in different ways to achieve different results. All of these entities +have the same fundamental outline but serve a different purpose. The Message +itself can be defined as a MIME entity, an Attachment is a MIME entity, all +MIME parts are MIME entities -- and so on! + +The basic units of each MIME entity -- be it the Message itself, or an +Attachment -- are its Headers and its body: + +.. code-block:: text + + Other-Header: Another value + + The body content itself + +The Headers of a MIME entity, and its body must conform to some strict +standards defined by various RFC documents. Swift Mailer ensures that these +specifications are followed by using various types of object, including +Encoders and different Header types to generate the entity. + +Each MIME component implements the base ``Swift_Mime_MimeEntity`` interface, +which offers methods for retrieving Headers, adding new Headers, changing the +Encoder, updating the body and so on! + +All MIME entities have one Header in common -- the Content-Type Header, +updated with the entity's ``setContentType()`` method. + +Encoders +~~~~~~~~ + +Encoders are used to transform the content of Messages generated in Swift +Mailer into a format that is safe to send across the internet and that +conforms to RFC specifications. + +Generally speaking you will not need to interact with the Encoders in Swift +Mailer -- the correct settings will be handled by the library itself. +However they are probably worth a brief mention in the event that you do want +to play with them. + +Both the Headers and the body of all MIME entities (including the Message +itself) use Encoders to ensure the data they contain can be sent over the +internet without becoming corrupted or misinterpreted. + +There are two types of Encoder: Base64 and Quoted-Printable. + +Plugins +~~~~~~~ + +Plugins exist to extend, or modify the behaviour of Swift Mailer. They respond +to Events that are fired within the Transports during sending. + +There are a number of Plugins provided as part of the base Swift Mailer +package and they all follow a common interface to respond to Events fired +within the library. Interfaces are provided to "listen" to each type of Event +fired and to act as desired when a listened-to Event occurs. + +Although several plugins are provided with Swift Mailer out-of-the-box, the +Events system has been specifically designed to make it easy for experienced +object-oriented developers to write their own plugins in order to achieve +goals that may not be possible with the base library. diff --git a/vendor/swiftmailer/swiftmailer/doc/plugins.rst b/vendor/swiftmailer/swiftmailer/doc/plugins.rst new file mode 100755 index 0000000..16ae335 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/doc/plugins.rst @@ -0,0 +1,385 @@ +Plugins +======= + +Plugins are provided with Swift Mailer and can be used to extend the behavior +of the library in situations where using simple class inheritance would be more complex. + +AntiFlood Plugin +---------------- + +Many SMTP servers have limits on the number of messages that may be sent +during any single SMTP connection. The AntiFlood plugin provides a way to stay +within this limit while still managing a large number of emails. + +A typical limit for a single connection is 100 emails. If the server you +connect to imposes such a limit, it expects you to disconnect after that +number of emails has been sent. You could manage this manually within a loop, +but the AntiFlood plugin provides the necessary wrapper code so that you don't +need to worry about this logic. + +Regardless of limits imposed by the server, it's usually a good idea to be +conservative with the resources of the SMTP server. Sending will become +sluggish if the server is being over-used so using the AntiFlood plugin will +not be a bad idea even if no limits exist. + +The AntiFlood plugin's logic is basically to disconnect and the immediately +re-connect with the SMTP server every X number of emails sent, where X is a +number you specify to the plugin. + +You can also specify a time period in seconds that Swift Mailer should pause +for between the disconnect/re-connect process. It's a good idea to pause for a +short time (say 30 seconds every 100 emails) simply to give the SMTP server a +chance to process its queue and recover some resources. + +Using the AntiFlood Plugin +~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The AntiFlood Plugin -- like all plugins -- is added with the Mailer class's +``registerPlugin()`` method. It takes two constructor parameters: the number of +emails to pause after, and optionally the number of seconds to pause for. + +To use the AntiFlood plugin: + +* Create an instance of the Mailer using any Transport you choose. + +* Create an instance of the ``Swift_Plugins_AntiFloodPlugin`` class, passing + in one or two constructor parameters. + +* Register the plugin using the Mailer's ``registerPlugin()`` method. + +* Continue using Swift Mailer to send messages as normal. + +When Swift Mailer sends messages it will count the number of messages that +have been sent since the last re-connect. Once the number hits your specified +threshold it will disconnect and re-connect, optionally pausing for a +specified amount of time. + +.. code-block:: php + + require_once 'lib/swift_required.php'; + + // Create the Mailer using any Transport + $mailer = Swift_Mailer::newInstance( + Swift_SmtpTransport::newInstance('smtp.example.org', 25) + ); + + // Use AntiFlood to re-connect after 100 emails + $mailer->registerPlugin(new Swift_Plugins_AntiFloodPlugin(100)); + + // And specify a time in seconds to pause for (30 secs) + $mailer->registerPlugin(new Swift_Plugins_AntiFloodPlugin(100, 30)); + + // Continue sending as normal + for ($lotsOfRecipients as $recipient) { + ... + + $mailer->send( ... ); + } + +Throttler Plugin +---------------- + +If your SMTP server has restrictions in place to limit the rate at which you +send emails, then your code will need to be aware of this rate-limiting. The +Throttler plugin makes Swift Mailer run at a rate-limited speed. + +Many shared hosts don't open their SMTP servers as a free-for-all. Usually +they have policies in place (probably to discourage spammers) that only allow +you to send a fixed number of emails per-hour/day. + +The Throttler plugin supports two modes of rate-limiting and with each, you +will need to do that math to figure out the values you want. The plugin can +limit based on the number of emails per minute, or the number of +bytes-transferred per-minute. + +Using the Throttler Plugin +~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The Throttler Plugin -- like all plugins -- is added with the Mailer class' +``registerPlugin()`` method. It has two required constructor parameters that +tell it how to do its rate-limiting. + +To use the Throttler plugin: + +* Create an instance of the Mailer using any Transport you choose. + +* Create an instance of the ``Swift_Plugins_ThrottlerPlugin`` class, passing + the number of emails, or bytes you wish to limit by, along with the mode + you're using. + +* Register the plugin using the Mailer's ``registerPlugin()`` method. + +* Continue using Swift Mailer to send messages as normal. + +When Swift Mailer sends messages it will keep track of the rate at which sending +messages is occurring. If it realises that sending is happening too fast, it +will cause your program to ``sleep()`` for enough time to average out the rate. + +.. code-block:: php + + require_once 'lib/swift_required.php'; + + // Create the Mailer using any Transport + $mailer = Swift_Mailer::newInstance( + Swift_SmtpTransport::newInstance('smtp.example.org', 25) + ); + + // Rate limit to 100 emails per-minute + $mailer->registerPlugin(new Swift_Plugins_ThrottlerPlugin( + 100, Swift_Plugins_ThrottlerPlugin::MESSAGES_PER_MINUTE + )); + + // Rate limit to 10MB per-minute + $mailer->registerPlugin(new Swift_Plugins_ThrottlerPlugin( + 1024 * 1024 * 10, Swift_Plugins_ThrottlerPlugin::BYTES_PER_MINUTE + )); + + // Continue sending as normal + for ($lotsOfRecipients as $recipient) { + ... + + $mailer->send( ... ); + } + +Logger Plugin +------------- + +The Logger plugins helps with debugging during the process of sending. It can +help to identify why an SMTP server is rejecting addresses, or any other +hard-to-find problems that may arise. + +The Logger plugin comes in two parts. There's the plugin itself, along with +one of a number of possible Loggers that you may choose to use. For example, +the logger may output messages directly in realtime, or it may capture +messages in an array. + +One other notable feature is the way in which the Logger plugin changes +Exception messages. If Exceptions are being thrown but the error message does +not provide conclusive information as to the source of the problem (such as an +ambiguous SMTP error) the Logger plugin includes the entire SMTP transcript in +the error message so that debugging becomes a simpler task. + +There are a few available Loggers included with Swift Mailer, but writing your +own implementation is incredibly simple and is achieved by creating a short +class that implements the ``Swift_Plugins_Logger`` interface. + +* ``Swift_Plugins_Loggers_ArrayLogger``: Keeps a collection of log messages + inside an array. The array content can be cleared or dumped out to the + screen. + +* ``Swift_Plugins_Loggers_EchoLogger``: Prints output to the screen in + realtime. Handy for very rudimentary debug output. + +Using the Logger Plugin +~~~~~~~~~~~~~~~~~~~~~~~ + +The Logger Plugin -- like all plugins -- is added with the Mailer class' +``registerPlugin()`` method. It accepts an instance of ``Swift_Plugins_Logger`` +in its constructor. + +To use the Logger plugin: + +* Create an instance of the Mailer using any Transport you choose. + +* Create an instance of the a Logger implementation of + ``Swift_Plugins_Logger``. + +* Create an instance of the ``Swift_Plugins_LoggerPlugin`` class, passing the + created Logger instance to its constructor. + +* Register the plugin using the Mailer's ``registerPlugin()`` method. + +* Continue using Swift Mailer to send messages as normal. + +* Dump the contents of the log with the logger's ``dump()`` method. + +When Swift Mailer sends messages it will keep a log of all the interactions +with the underlying Transport being used. Depending upon the Logger that has +been used the behaviour will differ, but all implementations offer a way to +get the contents of the log. + +.. code-block:: php + + require_once 'lib/swift_required.php'; + + // Create the Mailer using any Transport + $mailer = Swift_Mailer::newInstance( + Swift_SmtpTransport::newInstance('smtp.example.org', 25) + ); + + // To use the ArrayLogger + $logger = new Swift_Plugins_Loggers_ArrayLogger(); + $mailer->registerPlugin(new Swift_Plugins_LoggerPlugin($logger)); + + // Or to use the Echo Logger + $logger = new Swift_Plugins_Loggers_EchoLogger(); + $mailer->registerPlugin(new Swift_Plugins_LoggerPlugin($logger)); + + // Continue sending as normal + for ($lotsOfRecipients as $recipient) { + ... + + $mailer->send( ... ); + } + + // Dump the log contents + // NOTE: The EchoLogger dumps in realtime so dump() does nothing for it + echo $logger->dump(); + +Decorator Plugin +---------------- + +Often there's a need to send the same message to multiple recipients, but with +tiny variations such as the recipient's name being used inside the message +body. The Decorator plugin aims to provide a solution for allowing these small +differences. + +The decorator plugin works by intercepting the sending process of Swift +Mailer, reading the email address in the To: field and then looking up a set +of replacements for a template. + +While the use of this plugin is simple, it is probably the most commonly +misunderstood plugin due to the way in which it works. The typical mistake +users make is to try registering the plugin multiple times (once for each +recipient) -- inside a loop for example. This is incorrect. + +The Decorator plugin should be registered just once, but containing the list +of all recipients prior to sending. It will use this list of recipients to +find the required replacements during sending. + +Using the Decorator Plugin +~~~~~~~~~~~~~~~~~~~~~~~~~~ + +To use the Decorator plugin, simply create an associative array of replacements +based on email addresses and then use the mailer's ``registerPlugin()`` method +to add the plugin. + +First create an associative array of replacements based on the email addresses +you'll be sending the message to. + +.. note:: + + The replacements array becomes a 2-dimensional array whose keys are the + email addresses and whose values are an associative array of replacements + for that email address. The curly braces used in this example can be any + type of syntax you choose, provided they match the placeholders in your + email template. + + .. code-block:: php + + $replacements = array(); + foreach ($users as $user) { + $replacements[$user['email']] = array( + '{username}'=>$user['username'], + '{password}'=>$user['password'] + ); + } + +Now create an instance of the Decorator plugin using this array of replacements +and then register it with the Mailer. Do this only once! + +.. code-block:: php + + $decorator = new Swift_Plugins_DecoratorPlugin($replacements); + + $mailer->registerPlugin($decorator); + +When you create your message, replace elements in the body (and/or the subject +line) with your placeholders. + +.. code-block:: php + + $message = Swift_Message::newInstance() + ->setSubject('Important notice for {username}') + ->setBody( + "Hello {username}, we have reset your password to {password}\n" . + "Please log in and change it at your earliest convenience." + ) + ; + + foreach ($users as $user) { + $message->addTo($user['email']); + } + +When you send this message to each of your recipients listed in your +``$replacements`` array they will receive a message customized for just +themselves. For example, the message used above when received may appear like +this to one user: + +.. code-block:: text + + Subject: Important notice for smilingsunshine2009 + + Hello smilingsunshine2009, we have reset your password to rainyDays + Please log in and change it at your earliest convenience. + +While another use may receive the message as: + +.. code-block:: text + + Subject: Important notice for billy-bo-bob + + Hello billy-bo-bob, we have reset your password to dancingOctopus + Please log in and change it at your earliest convenience. + +While the decorator plugin provides a means to solve this problem, there are +various ways you could tackle this problem without the need for a plugin. +We're trying to come up with a better way ourselves and while we have several +(obvious) ideas we don't quite have the perfect solution to go ahead and +implement it. Watch this space. + +Providing Your Own Replacements Lookup for the Decorator +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Filling an array with replacements may not be the best solution for providing +replacement information to the decorator. If you have a more elegant algorithm +that performs replacement lookups on-the-fly you may provide your own +implementation. + +Providing your own replacements lookup implementation for the Decorator is +simply a matter of passing an instance of ``Swift_Plugins_Decorator_Replacements`` to the decorator plugin's constructor, +rather than passing in an array. + +The Replacements interface is very simple to implement since it has just one +method: ``getReplacementsFor($address)``. + +Imagine you want to look up replacements from a database on-the-fly, you might +provide an implementation that does this. You need to create a small class. + +.. code-block:: php + + class DbReplacements implements Swift_Plugins_Decorator_Replacements { + public function getReplacementsFor($address) { + $sql = sprintf( + "SELECT * FROM user WHERE email = '%s'", + mysql_real_escape_string($address) + ); + + $result = mysql_query($sql); + + if ($row = mysql_fetch_assoc($result)) { + return array( + '{username}'=>$row['username'], + '{password}'=>$row['password'] + ); + } + } + } + +Now all you need to do is pass an instance of your class into the Decorator +plugin's constructor instead of passing an array. + +.. code-block:: php + + $decorator = new Swift_Plugins_DecoratorPlugin(new DbReplacements()); + + $mailer->registerPlugin($decorator); + +For each message sent, the plugin will call your class' ``getReplacementsFor()`` +method to find the array of replacements it needs. + +.. note:: + + If your lookup algorithm is case sensitive, you should transform the + ``$address`` argument as appropriate -- for example by passing it + through ``strtolower()``. diff --git a/vendor/swiftmailer/swiftmailer/doc/sending.rst b/vendor/swiftmailer/swiftmailer/doc/sending.rst new file mode 100755 index 0000000..3e9c3a8 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/doc/sending.rst @@ -0,0 +1,607 @@ +Sending Messages +================ + +Quick Reference for Sending a Message +------------------------------------- + +Sending a message is very straightforward. You create a Transport, use it to +create the Mailer, then you use the Mailer to send the message. + +To send a Message: + +* Create a Transport from one of the provided Transports -- + ``Swift_SmtpTransport``, ``Swift_SendmailTransport``, ``Swift_MailTransport`` + or one of the aggregate Transports. + +* Create an instance of the ``Swift_Mailer`` class, using the Transport as + it's constructor parameter. + +* Create a Message. + +* Send the message via the ``send()`` method on the Mailer object. + +.. caution:: + + The ``Swift_SmtpTransport`` and ``Swift_SendmailTransport`` transports use + ``proc_*`` PHP functions, which might not be available on your PHP + installation. You can easily check if that's the case by running the + following PHP script: ``setUsername('your username') + ->setPassword('your password') + ; + + /* + You could alternatively use a different transport such as Sendmail or Mail: + + // Sendmail + $transport = Swift_SendmailTransport::newInstance('/usr/sbin/sendmail -bs'); + + // Mail + $transport = Swift_MailTransport::newInstance(); + */ + + // Create the Mailer using your created Transport + $mailer = Swift_Mailer::newInstance($transport); + + // Create a message + $message = Swift_Message::newInstance('Wonderful Subject') + ->setFrom(array('john@doe.com' => 'John Doe')) + ->setTo(array('receiver@domain.org', 'other@domain.org' => 'A name')) + ->setBody('Here is the message itself') + ; + + // Send the message + $result = $mailer->send($message); + +Transport Types +~~~~~~~~~~~~~~~ + +A Transport is the component which actually does the sending. You need to +provide a Transport object to the Mailer class and there are several possible +options. + +Typically you will not need to know how a Transport works under-the-surface, +you will only need to know how to create an instance of one, and which one to +use for your environment. + +The SMTP Transport +.................. + +The SMTP Transport sends messages over the (standardized) Simple Message +Transfer Protocol. It can deal with encryption and authentication. + +The SMTP Transport, ``Swift_SmtpTransport`` is without doubt the most commonly +used Transport because it will work on 99% of web servers (I just made that +number up, but you get the idea). All the server needs is the ability to +connect to a remote (or even local) SMTP server on the correct port number +(usually 25). + +SMTP servers often require users to authenticate with a username and password +before any mail can be sent to other domains. This is easily achieved using +Swift Mailer with the SMTP Transport. + +SMTP is a protocol -- in other words it's a "way" of communicating a job +to be done (i.e. sending a message). The SMTP protocol is the fundamental +basis on which messages are delivered all over the internet 7 days a week, 365 +days a year. For this reason it's the most "direct" method of sending messages +you can use and it's the one that will give you the most power and feedback +(such as delivery failures) when using Swift Mailer. + +Because SMTP is generally run as a remote service (i.e. you connect to it over +the network/internet) it's extremely portable from server-to-server. You can +easily store the SMTP server address and port number in a configuration file +within your application and adjust the settings accordingly if the code is +moved or if the SMTP server is changed. + +Some SMTP servers -- Google for example -- use encryption for security reasons. +Swift Mailer supports using both SSL and TLS encryption settings. + +Using the SMTP Transport +^^^^^^^^^^^^^^^^^^^^^^^^ + +The SMTP Transport is easy to use. Most configuration options can be set with +the constructor. + +To use the SMTP Transport you need to know which SMTP server your code needs +to connect to. Ask your web host if you're not sure. Lots of people ask me who +to connect to -- I really can't answer that since it's a setting that's +extremely specific to your hosting environment. + +To use the SMTP Transport: + +* Call ``Swift_SmtpTransport::newInstance()`` with the SMTP server name and + optionally with a port number (defaults to 25). + +* Use the returned object to create the Mailer. + +A connection to the SMTP server will be established upon the first call to +``send()``. + +.. code-block:: php + + require_once 'lib/swift_required.php'; + + // Create the Transport + $transport = Swift_SmtpTransport::newInstance('smtp.example.org', 25); + + // Create the Mailer using your created Transport + $mailer = Swift_Mailer::newInstance($transport); + + /* + It's also possible to use multiple method calls + + $transport = Swift_SmtpTransport::newInstance() + ->setHost('smtp.example.org') + ->setPort(25) + ; + */ + +Encrypted SMTP +^^^^^^^^^^^^^^ + +You can use SSL or TLS encryption with the SMTP Transport by specifying it as +a parameter or with a method call. + +To use encryption with the SMTP Transport: + +* Pass the encryption setting as a third parameter to + ``Swift_SmtpTransport::newInstance()``; or + +* Call the ``setEncryption()`` method on the Transport. + +A connection to the SMTP server will be established upon the first call to +``send()``. The connection will be initiated with the correct encryption +settings. + +.. note:: + + For SSL or TLS encryption to work your PHP installation must have + appropriate OpenSSL transports wrappers. You can check if "tls" and/or + "ssl" are present in your PHP installation by using the PHP function + ``stream_get_transports()`` + + .. code-block:: php + + require_once 'lib/swift_required.php'; + + // Create the Transport + $transport = Swift_SmtpTransport::newInstance('smtp.example.org', 587, 'ssl'); + + // Create the Mailer using your created Transport + $mailer = Swift_Mailer::newInstance($transport); + + /* + It's also possible to use multiple method calls + + $transport = Swift_SmtpTransport::newInstance() + ->setHost('smtp.example.org') + ->setPort(587) + ->setEncryption('ssl') + ; + */ + +SMTP with a Username and Password +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Some servers require authentication. You can provide a username and password +with ``setUsername()`` and ``setPassword()`` methods. + +To use a username and password with the SMTP Transport: + +* Create the Transport with ``Swift_SmtpTransport::newInstance()``. + +* Call the ``setUsername()`` and ``setPassword()`` methods on the Transport. + +Your username and password will be used to authenticate upon first connect +when ``send()`` are first used on the Mailer. + +If authentication fails, an Exception of type ``Swift_TransportException`` will +be thrown. + +.. note:: + + If you need to know early whether or not authentication has failed and an + Exception is going to be thrown, call the ``start()`` method on the + created Transport. + + .. code-block:: php + + require_once 'lib/swift_required.php'; + + // Create the Transport the call setUsername() and setPassword() + $transport = Swift_SmtpTransport::newInstance('smtp.example.org', 25) + ->setUsername('username') + ->setPassword('password') + ; + + // Create the Mailer using your created Transport + $mailer = Swift_Mailer::newInstance($transport); + +The Sendmail Transport +...................... + +The Sendmail Transport sends messages by communicating with a locally +installed MTA -- such as ``sendmail``. + +The Sendmail Transport, ``Swift_SendmailTransport`` does not directly connect to +any remote services. It is designed for Linux servers that have ``sendmail`` +installed. The Transport starts a local ``sendmail`` process and sends messages +to it. Usually the ``sendmail`` process will respond quickly as it spools your +messages to disk before sending them. + +The Transport is named the Sendmail Transport for historical reasons +(``sendmail`` was the "standard" UNIX tool for sending e-mail for years). It +will send messages using other transfer agents such as Exim or Postfix despite +its name, provided they have the relevant sendmail wrappers so that they can be +started with the correct command-line flags. + +It's a common misconception that because the Sendmail Transport returns a +result very quickly it must therefore deliver messages to recipients quickly +-- this is not true. It's not slow by any means, but it's certainly not +faster than SMTP when it comes to getting messages to the intended recipients. +This is because sendmail itself sends the messages over SMTP once they have +been quickly spooled to disk. + +The Sendmail Transport has the potential to be just as smart of the SMTP +Transport when it comes to notifying Swift Mailer about which recipients were +rejected, but in reality the majority of locally installed ``sendmail`` +instances are not configured well enough to provide any useful feedback. As such +Swift Mailer may report successful deliveries where they did in fact fail before +they even left your server. + +You can run the Sendmail Transport in two different modes specified by command +line flags: + +* "``-bs``" runs in SMTP mode so theoretically it will act like the SMTP + Transport + +* "``-t``" runs in piped mode with no feedback, but theoretically faster, + though not advised + +You can think of the Sendmail Transport as a sort of asynchronous SMTP Transport +-- though if you have problems with delivery failures you should try using the +SMTP Transport instead. Swift Mailer isn't doing the work here, it's simply +passing the work to somebody else (i.e. ``sendmail``). + +Using the Sendmail Transport +^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +To use the Sendmail Transport you simply need to call +``Swift_SendmailTransport::newInstance()`` with the command as a parameter. + +To use the Sendmail Transport you need to know where ``sendmail`` or another MTA +exists on the server. Swift Mailer uses a default value of +``/usr/sbin/sendmail``, which should work on most systems. + +You specify the entire command as a parameter (i.e. including the command line +flags). Swift Mailer supports operational modes of "``-bs``" (default) and +"``-t``". + +.. note:: + + If you run sendmail in "``-t``" mode you will get no feedback as to whether + or not sending has succeeded. Use "``-bs``" unless you have a reason not to. + +To use the Sendmail Transport: + +* Call ``Swift_SendmailTransport::newInstance()`` with the command, including + the correct command line flags. The default is to use ``/usr/sbin/sendmail + -bs`` if this is not specified. + +* Use the returned object to create the Mailer. + +A sendmail process will be started upon the first call to ``send()``. If the +process cannot be started successfully an Exception of type +``Swift_TransportException`` will be thrown. + +.. code-block:: php + + require_once 'lib/swift_required.php'; + + // Create the Transport + $transport = Swift_SendmailTransport::newInstance('/usr/sbin/exim -bs'); + + // Create the Mailer using your created Transport + $mailer = Swift_Mailer::newInstance($transport); + +The Mail Transport +.................. + +The Mail Transport sends messages by delegating to PHP's internal +``mail()`` function. + +In my experience -- and others' -- the ``mail()`` function is not particularly +predictable, or helpful. + +Quite notably, the ``mail()`` function behaves entirely differently between +Linux and Windows servers. On linux it uses ``sendmail``, but on Windows it uses +SMTP. + +In order for the ``mail()`` function to even work at all ``php.ini`` needs to be +configured correctly, specifying the location of sendmail or of an SMTP server. + +The problem with ``mail()`` is that it "tries" to simplify things to the point +that it actually makes things more complex due to poor interface design. The +developers of Swift Mailer have gone to a lot of effort to make the Mail +Transport work with a reasonable degree of consistency. + +Serious drawbacks when using this Transport are: + +* Unpredictable message headers + +* Lack of feedback regarding delivery failures + +* Lack of support for several plugins that require real-time delivery feedback + +It's a last resort, and we say that with a passion! + +Using the Mail Transport +^^^^^^^^^^^^^^^^^^^^^^^^ + +To use the Mail Transport you simply need to call +``Swift_MailTransport::newInstance()``. It's unlikely you'll need to configure +the Transport. + +To use the Mail Transport: + +* Call ``Swift_MailTransport::newInstance()``. + +* Use the returned object to create the Mailer. + +Messages will be sent using the ``mail()`` function. + +.. note:: + + The ``mail()`` function can take a ``$additional_parameters`` parameter. + Swift Mailer sets this to "``-f%s``" by default, where the "%s" is + substituted with the address of the sender (via a ``sprintf()``) at send + time. You may override this default by passing an argument to + ``newInstance()``. + + .. code-block:: php + + require_once 'lib/swift_required.php'; + + // Create the Transport + $transport = Swift_MailTransport::newInstance(); + + // Create the Mailer using your created Transport + $mailer = Swift_Mailer::newInstance($transport); + +Available Methods for Sending Messages +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The Mailer class offers two methods for sending Messages -- ``send()``. +Each behaves in a slightly different way. + +When a message is sent in Swift Mailer, the Mailer class communicates with +whichever Transport class you have chosen to use. + +Each recipient in the message should either be accepted or rejected by the +Transport. For example, if the domain name on the email address is not +reachable the SMTP Transport may reject the address because it cannot process +it. Whichever method you use -- ``send()`` -- Swift Mailer will return +an integer indicating the number of accepted recipients. + +.. note:: + + It's possible to find out which recipients were rejected -- we'll cover that + later in this chapter. + +Using the ``send()`` Method +........................... + +The ``send()`` method of the ``Swift_Mailer`` class sends a message using +exactly the same logic as your Desktop mail client would use. Just pass it a +Message and get a result. + +To send a Message with ``send()``: + +* Create a Transport from one of the provided Transports -- + ``Swift_SmtpTransport``, ``Swift_SendmailTransport``, + ``Swift_MailTransport`` or one of the aggregate Transports. + +* Create an instance of the ``Swift_Mailer`` class, using the Transport as + it's constructor parameter. + +* Create a Message. + +* Send the message via the ``send()`` method on the Mailer object. + +The message will be sent just like it would be sent if you used your mail +client. An integer is returned which includes the number of successful +recipients. If none of the recipients could be sent to then zero will be +returned, which equates to a boolean ``false``. If you set two +``To:`` recipients and three ``Bcc:`` recipients in the message and all of the +recipients are delivered to successfully then the value 5 will be returned. + +.. code-block:: php + + require_once 'lib/swift_required.php'; + + // Create the Transport + $transport = Swift_SmtpTransport::newInstance('localhost', 25); + + // Create the Mailer using your created Transport + $mailer = Swift_Mailer::newInstance($transport); + + // Create a message + $message = Swift_Message::newInstance('Wonderful Subject') + ->setFrom(array('john@doe.com' => 'John Doe')) + ->setTo(array('receiver@domain.org', 'other@domain.org' => 'A name')) + ->setBody('Here is the message itself') + ; + + // Send the message + $numSent = $mailer->send($message); + + printf("Sent %d messages\n", $numSent); + + /* Note that often that only the boolean equivalent of the + return value is of concern (zero indicates FALSE) + + if ($mailer->send($message)) + { + echo "Sent\n"; + } + else + { + echo "Failed\n"; + } + + */ + +Sending Emails in Batch +....................... + +If you want to send a separate message to each recipient so that only their +own address shows up in the ``To:`` field, follow the following recipe: + +* Create a Transport from one of the provided Transports -- + ``Swift_SmtpTransport``, ``Swift_SendmailTransport``, + ``Swift_MailTransport`` or one of the aggregate Transports. + +* Create an instance of the ``Swift_Mailer`` class, using the Transport as + it's constructor parameter. + +* Create a Message. + +* Iterate over the recipients and send message via the ``send()`` method on + the Mailer object. + +Each recipient of the messages receives a different copy with only their own +email address on the ``To:`` field. + +Make sure to add only valid email addresses as recipients. If you try to add an +invalid email address with ``setTo()``, ``setCc()`` or ``setBcc()``, Swift +Mailer will throw a ``Swift_RfcComplianceException``. + +If you add recipients automatically based on a data source that may contain +invalid email addresses, you can prevent possible exceptions by validating the +addresses using ``Swift_Validate::email($email)`` and only adding addresses +that validate. Another way would be to wrap your ``setTo()``, ``setCc()`` and +``setBcc()`` calls in a try-catch block and handle the +``Swift_RfcComplianceException`` in the catch block. + +Handling invalid addresses properly is especially important when sending emails +in large batches since a single invalid address might cause an unhandled +exception and stop the execution or your script early. + +.. note:: + + In the following example, two emails are sent. One to each of + ``receiver@domain.org`` and ``other@domain.org``. These recipients will + not be aware of each other. + + .. code-block:: php + + require_once 'lib/swift_required.php'; + + // Create the Transport + $transport = Swift_SmtpTransport::newInstance('localhost', 25); + + // Create the Mailer using your created Transport + $mailer = Swift_Mailer::newInstance($transport); + + // Create a message + $message = Swift_Message::newInstance('Wonderful Subject') + ->setFrom(array('john@doe.com' => 'John Doe')) + ->setBody('Here is the message itself') + ; + + // Send the message + $failedRecipients = array(); + $numSent = 0; + $to = array('receiver@domain.org', 'other@domain.org' => 'A name'); + + foreach ($to as $address => $name) + { + if (is_int($address)) { + $message->setTo($name); + } else { + $message->setTo(array($address => $name)); + } + + $numSent += $mailer->send($message, $failedRecipients); + } + + printf("Sent %d messages\n", $numSent); + +Finding out Rejected Addresses +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +It's possible to get a list of addresses that were rejected by the Transport +by using a by-reference parameter to ``send()``. + +As Swift Mailer attempts to send the message to each address given to it, if a +recipient is rejected it will be added to the array. You can pass an existing +array, otherwise one will be created by-reference. + +Collecting the list of recipients that were rejected can be useful in +circumstances where you need to "prune" a mailing list for example when some +addresses cannot be delivered to. + +Getting Failures By-reference +............................. + +Collecting delivery failures by-reference with the ``send()`` method is as +simple as passing a variable name to the method call. + +To get failed recipients by-reference: + +* Pass a by-reference variable name to the ``send()`` method of the Mailer + class. + +If the Transport rejects any of the recipients, the culprit addresses will be +added to the array provided by-reference. + +.. note:: + + If the variable name does not yet exist, it will be initialized as an + empty array and then failures will be added to that array. If the variable + already exists it will be type-cast to an array and failures will be added + to it. + + .. code-block:: php + + $mailer = Swift_Mailer::newInstance( ... ); + + $message = Swift_Message::newInstance( ... ) + ->setFrom( ... ) + ->setTo(array( + 'receiver@bad-domain.org' => 'Receiver Name', + 'other@domain.org' => 'A name', + 'other-receiver@bad-domain.org' => 'Other Name' + )) + ->setBody( ... ) + ; + + // Pass a variable name to the send() method + if (!$mailer->send($message, $failures)) + { + echo "Failures:"; + print_r($failures); + } + + /* + Failures: + Array ( + 0 => receiver@bad-domain.org, + 1 => other-receiver@bad-domain.org + ) + */ diff --git a/vendor/swiftmailer/swiftmailer/doc/uml/Encoders.graffle b/vendor/swiftmailer/swiftmailer/doc/uml/Encoders.graffle new file mode 100755 index 0000000..f895752 Binary files /dev/null and b/vendor/swiftmailer/swiftmailer/doc/uml/Encoders.graffle differ diff --git a/vendor/swiftmailer/swiftmailer/doc/uml/Mime.graffle b/vendor/swiftmailer/swiftmailer/doc/uml/Mime.graffle new file mode 100755 index 0000000..e1e33cb Binary files /dev/null and b/vendor/swiftmailer/swiftmailer/doc/uml/Mime.graffle differ diff --git a/vendor/swiftmailer/swiftmailer/doc/uml/Transports.graffle b/vendor/swiftmailer/swiftmailer/doc/uml/Transports.graffle new file mode 100755 index 0000000..5670e2b Binary files /dev/null and b/vendor/swiftmailer/swiftmailer/doc/uml/Transports.graffle differ diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift.php new file mode 100755 index 0000000..1d1f821 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift.php @@ -0,0 +1,81 @@ +createDependenciesFor('mime.attachment') + ); + + $this->setBody($data); + $this->setFilename($filename); + if ($contentType) { + $this->setContentType($contentType); + } + } + + /** + * Create a new Attachment. + * + * @param string|Swift_OutputByteStream $data + * @param string $filename + * @param string $contentType + * + * @return Swift_Mime_Attachment + */ + public static function newInstance($data = null, $filename = null, $contentType = null) + { + return new self($data, $filename, $contentType); + } + + /** + * Create a new Attachment from a filesystem path. + * + * @param string $path + * @param string $contentType optional + * + * @return Swift_Mime_Attachment + */ + public static function fromPath($path, $contentType = null) + { + return self::newInstance()->setFile( + new Swift_ByteStream_FileByteStream($path), + $contentType + ); + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/ByteStream/AbstractFilterableInputStream.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/ByteStream/AbstractFilterableInputStream.php new file mode 100755 index 0000000..e12c0dd --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/ByteStream/AbstractFilterableInputStream.php @@ -0,0 +1,183 @@ +_filters[$key] = $filter; + } + + /** + * Remove an already present StreamFilter based on its $key. + * + * @param string $key + */ + public function removeFilter($key) + { + unset($this->_filters[$key]); + } + + /** + * Writes $bytes to the end of the stream. + * + * @param string $bytes + * + * @return int + * + * @throws Swift_IoException + */ + public function write($bytes) + { + $this->_writeBuffer .= $bytes; + foreach ($this->_filters as $filter) { + if ($filter->shouldBuffer($this->_writeBuffer)) { + return; + } + } + $this->_doWrite($this->_writeBuffer); + + return ++$this->_sequence; + } + + /** + * For any bytes that are currently buffered inside the stream, force them + * off the buffer. + * + * @throws Swift_IoException + */ + public function commit() + { + $this->_doWrite($this->_writeBuffer); + } + + /** + * Attach $is to this stream. + * + * The stream acts as an observer, receiving all data that is written. + * All {@link write()} and {@link flushBuffers()} operations will be mirrored. + * + * @param Swift_InputByteStream $is + */ + public function bind(Swift_InputByteStream $is) + { + $this->_mirrors[] = $is; + } + + /** + * Remove an already bound stream. + * + * If $is is not bound, no errors will be raised. + * If the stream currently has any buffered data it will be written to $is + * before unbinding occurs. + * + * @param Swift_InputByteStream $is + */ + public function unbind(Swift_InputByteStream $is) + { + foreach ($this->_mirrors as $k => $stream) { + if ($is === $stream) { + if ($this->_writeBuffer !== '') { + $stream->write($this->_writeBuffer); + } + unset($this->_mirrors[$k]); + } + } + } + + /** + * Flush the contents of the stream (empty it) and set the internal pointer + * to the beginning. + * + * @throws Swift_IoException + */ + public function flushBuffers() + { + if ($this->_writeBuffer !== '') { + $this->_doWrite($this->_writeBuffer); + } + $this->_flush(); + + foreach ($this->_mirrors as $stream) { + $stream->flushBuffers(); + } + } + + // -- Private methods + + /** Run $bytes through all filters */ + private function _filter($bytes) + { + foreach ($this->_filters as $filter) { + $bytes = $filter->filter($bytes); + } + + return $bytes; + } + + /** Just write the bytes to the stream */ + private function _doWrite($bytes) + { + $this->_commit($this->_filter($bytes)); + + foreach ($this->_mirrors as $stream) { + $stream->write($bytes); + } + + $this->_writeBuffer = ''; + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/ByteStream/ArrayByteStream.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/ByteStream/ArrayByteStream.php new file mode 100755 index 0000000..aa29597 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/ByteStream/ArrayByteStream.php @@ -0,0 +1,186 @@ +_array = $stack; + $this->_arraySize = count($stack); + } elseif (is_string($stack)) { + $this->write($stack); + } else { + $this->_array = array(); + } + } + + /** + * Reads $length bytes from the stream into a string and moves the pointer + * through the stream by $length. + * + * If less bytes exist than are requested the + * remaining bytes are given instead. If no bytes are remaining at all, boolean + * false is returned. + * + * @param int $length + * + * @return string + */ + public function read($length) + { + if ($this->_offset == $this->_arraySize) { + return false; + } + + // Don't use array slice + $end = $length + $this->_offset; + $end = $this->_arraySize<$end + ?$this->_arraySize + :$end; + $ret = ''; + for (; $this->_offset < $end; ++$this->_offset) { + $ret .= $this->_array[$this->_offset]; + } + + return $ret; + } + + /** + * Writes $bytes to the end of the stream. + * + * @param string $bytes + */ + public function write($bytes) + { + $to_add = str_split($bytes); + foreach ($to_add as $value) { + $this->_array[] = $value; + } + $this->_arraySize = count($this->_array); + + foreach ($this->_mirrors as $stream) { + $stream->write($bytes); + } + } + + /** + * Not used. + */ + public function commit() + { + } + + /** + * Attach $is to this stream. + * + * The stream acts as an observer, receiving all data that is written. + * All {@link write()} and {@link flushBuffers()} operations will be mirrored. + * + * @param Swift_InputByteStream $is + */ + public function bind(Swift_InputByteStream $is) + { + $this->_mirrors[] = $is; + } + + /** + * Remove an already bound stream. + * + * If $is is not bound, no errors will be raised. + * If the stream currently has any buffered data it will be written to $is + * before unbinding occurs. + * + * @param Swift_InputByteStream $is + */ + public function unbind(Swift_InputByteStream $is) + { + foreach ($this->_mirrors as $k => $stream) { + if ($is === $stream) { + unset($this->_mirrors[$k]); + } + } + } + + /** + * Move the internal read pointer to $byteOffset in the stream. + * + * @param int $byteOffset + * + * @return bool + */ + public function setReadPointer($byteOffset) + { + if ($byteOffset > $this->_arraySize) { + $byteOffset = $this->_arraySize; + } elseif ($byteOffset < 0) { + $byteOffset = 0; + } + + $this->_offset = $byteOffset; + } + + /** + * Flush the contents of the stream (empty it) and set the internal pointer + * to the beginning. + */ + public function flushBuffers() + { + $this->_offset = 0; + $this->_array = array(); + $this->_arraySize = 0; + + foreach ($this->_mirrors as $stream) { + $stream->flushBuffers(); + } + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/ByteStream/FileByteStream.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/ByteStream/FileByteStream.php new file mode 100755 index 0000000..6f1d87e --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/ByteStream/FileByteStream.php @@ -0,0 +1,233 @@ +_path = $path; + $this->_mode = $writable ? 'w+b' : 'rb'; + + if (function_exists('get_magic_quotes_runtime') && @get_magic_quotes_runtime() == 1) { + $this->_quotes = true; + } + } + + /** + * Get the complete path to the file. + * + * @return string + */ + public function getPath() + { + return $this->_path; + } + + /** + * Reads $length bytes from the stream into a string and moves the pointer + * through the stream by $length. + * + * If less bytes exist than are requested the + * remaining bytes are given instead. If no bytes are remaining at all, boolean + * false is returned. + * + * @param int $length + * + * @return string|bool + * + * @throws Swift_IoException + */ + public function read($length) + { + $fp = $this->_getReadHandle(); + if (!feof($fp)) { + if ($this->_quotes) { + ini_set('magic_quotes_runtime', 0); + } + $bytes = fread($fp, $length); + if ($this->_quotes) { + ini_set('magic_quotes_runtime', 1); + } + $this->_offset = ftell($fp); + + // If we read one byte after reaching the end of the file + // feof() will return false and an empty string is returned + if ($bytes === '' && feof($fp)) { + $this->_resetReadHandle(); + + return false; + } + + return $bytes; + } + + $this->_resetReadHandle(); + + return false; + } + + /** + * Move the internal read pointer to $byteOffset in the stream. + * + * @param int $byteOffset + * + * @return bool + */ + public function setReadPointer($byteOffset) + { + if (isset($this->_reader)) { + $this->_seekReadStreamToPosition($byteOffset); + } + $this->_offset = $byteOffset; + } + + // -- Private methods + + /** Just write the bytes to the file */ + protected function _commit($bytes) + { + fwrite($this->_getWriteHandle(), $bytes); + $this->_resetReadHandle(); + } + + /** Not used */ + protected function _flush() + { + } + + /** Get the resource for reading */ + private function _getReadHandle() + { + if (!isset($this->_reader)) { + if (!$this->_reader = fopen($this->_path, 'rb')) { + throw new Swift_IoException( + 'Unable to open file for reading [' . $this->_path . ']' + ); + } + if ($this->_offset <> 0) { + $this->_getReadStreamSeekableStatus(); + $this->_seekReadStreamToPosition($this->_offset); + } + } + + return $this->_reader; + } + + /** Get the resource for writing */ + private function _getWriteHandle() + { + if (!isset($this->_writer)) { + if (!$this->_writer = fopen($this->_path, $this->_mode)) { + throw new Swift_IoException( + 'Unable to open file for writing [' . $this->_path . ']' + ); + } + } + + return $this->_writer; + } + + /** Force a reload of the resource for reading */ + private function _resetReadHandle() + { + if (isset($this->_reader)) { + fclose($this->_reader); + $this->_reader = null; + } + } + + /** Check if ReadOnly Stream is seekable */ + private function _getReadStreamSeekableStatus() + { + $metas = stream_get_meta_data($this->_reader); + $this->_seekable = $metas['seekable']; + } + + /** Streams in a readOnly stream ensuring copy if needed */ + private function _seekReadStreamToPosition($offset) + { + if ($this->_seekable===null) { + $this->_getReadStreamSeekableStatus(); + } + if ($this->_seekable === false) { + $currentPos = ftell($this->_reader); + if ($currentPos<$offset) { + $toDiscard = $offset-$currentPos; + fread($this->_reader, $toDiscard); + + return; + } + $this->_copyReadStream(); + } + fseek($this->_reader, $offset, SEEK_SET); + } + + /** Copy a readOnly Stream to ensure seekability */ + private function _copyReadStream() + { + if ($tmpFile = fopen('php://temp/maxmemory:4096', 'w+b')) { + /* We have opened a php:// Stream Should work without problem */ + } elseif (function_exists('sys_get_temp_dir') && is_writable(sys_get_temp_dir()) && ($tmpFile = tmpfile())) { + /* We have opened a tmpfile */ + } else { + throw new Swift_IoException('Unable to copy the file to make it seekable, sys_temp_dir is not writable, php://memory not available'); + } + $currentPos = ftell($this->_reader); + fclose($this->_reader); + $source = fopen($this->_path, 'rb'); + if (!$source) { + throw new Swift_IoException('Unable to open file for copying [' . $this->_path . ']'); + } + fseek($tmpFile, 0, SEEK_SET); + while (!feof($source)) { + fwrite($tmpFile, fread($source, 4096)); + } + fseek($tmpFile, $currentPos, SEEK_SET); + fclose($source); + $this->_reader = $tmpFile; + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/ByteStream/TemporaryFileByteStream.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/ByteStream/TemporaryFileByteStream.php new file mode 100755 index 0000000..f35f885 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/ByteStream/TemporaryFileByteStream.php @@ -0,0 +1,44 @@ +getPath())) === false) { + throw new Swift_IoException('Failed to get temporary file content.'); + } + + return $content; + } + + public function __destruct() + { + if (file_exists($this->getPath())) { + @unlink($this->getPath()); + } + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/CharacterReader.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/CharacterReader.php new file mode 100755 index 0000000..91a9c96 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/CharacterReader.php @@ -0,0 +1,69 @@ + + */ +interface Swift_CharacterReader +{ + const MAP_TYPE_INVALID = 0x01; + const MAP_TYPE_FIXED_LEN = 0x02; + const MAP_TYPE_POSITIONS = 0x03; + + /** + * Returns the complete character map + * + * @param string $string + * @param int $startOffset + * @param array $currentMap + * @param mixed $ignoredChars + * + * @return int + */ + public function getCharPositions($string, $startOffset, &$currentMap, &$ignoredChars); + + /** + * Returns the mapType, see constants. + * + * @return int + */ + public function getMapType(); + + /** + * Returns an integer which specifies how many more bytes to read. + * + * A positive integer indicates the number of more bytes to fetch before invoking + * this method again. + * + * A value of zero means this is already a valid character. + * A value of -1 means this cannot possibly be a valid character. + * + * @param integer[] $bytes + * @param int $size + * + * @return int + */ + public function validateByteSequence($bytes, $size); + + /** + * Returns the number of bytes which should be read to start each character. + * + * For fixed width character sets this should be the number of octets-per-character. + * For multibyte character sets this will probably be 1. + * + * @return int + */ + public function getInitialByteSize(); +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/CharacterReader/GenericFixedWidthReader.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/CharacterReader/GenericFixedWidthReader.php new file mode 100755 index 0000000..6547612 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/CharacterReader/GenericFixedWidthReader.php @@ -0,0 +1,99 @@ + + */ +class Swift_CharacterReader_GenericFixedWidthReader implements Swift_CharacterReader +{ + /** + * The number of bytes in a single character. + * + * @var int + */ + private $_width; + + /** + * Creates a new GenericFixedWidthReader using $width bytes per character. + * + * @param int $width + */ + public function __construct($width) + { + $this->_width = $width; + } + + /** + * Returns the complete character map. + * + * @param string $string + * @param int $startOffset + * @param array $currentMap + * @param mixed $ignoredChars + * + * @return int + */ + public function getCharPositions($string, $startOffset, &$currentMap, &$ignoredChars) + { + $strlen = strlen($string); + // % and / are CPU intensive, so, maybe find a better way + $ignored = $strlen % $this->_width; + $ignoredChars = substr($string, - $ignored); + $currentMap = $this->_width; + + return ($strlen - $ignored) / $this->_width; + } + + /** + * Returns the mapType. + * + * @return int + */ + public function getMapType() + { + return self::MAP_TYPE_FIXED_LEN; + } + + /** + * Returns an integer which specifies how many more bytes to read. + * + * A positive integer indicates the number of more bytes to fetch before invoking + * this method again. + * + * A value of zero means this is already a valid character. + * A value of -1 means this cannot possibly be a valid character. + * + * @param string $bytes + * @param int $size + * + * @return int + */ + public function validateByteSequence($bytes, $size) + { + $needed = $this->_width - $size; + + return ($needed > -1) ? $needed : -1; + } + + /** + * Returns the number of bytes which should be read to start each character. + * + * @return int + */ + public function getInitialByteSize() + { + return $this->_width; + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/CharacterReader/UsAsciiReader.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/CharacterReader/UsAsciiReader.php new file mode 100755 index 0000000..8d03f31 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/CharacterReader/UsAsciiReader.php @@ -0,0 +1,85 @@ +"\x07F") { // Invalid char + $currentMap[$i+$startOffset]=$string[$i]; + } + } + + return $strlen; + } + + /** + * Returns mapType + * + * @return int mapType + */ + public function getMapType() + { + return self::MAP_TYPE_INVALID; + } + + /** + * Returns an integer which specifies how many more bytes to read. + * + * A positive integer indicates the number of more bytes to fetch before invoking + * this method again. + * A value of zero means this is already a valid character. + * A value of -1 means this cannot possibly be a valid character. + * + * @param string $bytes + * @param int $size + * + * @return int + */ + public function validateByteSequence($bytes, $size) + { + $byte = reset($bytes); + if (1 == count($bytes) && $byte >= 0x00 && $byte <= 0x7F) { + return 0; + } else { + return -1; + } + } + + /** + * Returns the number of bytes which should be read to start each character. + * + * @return int + */ + public function getInitialByteSize() + { + return 1; + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/CharacterReader/Utf8Reader.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/CharacterReader/Utf8Reader.php new file mode 100755 index 0000000..900bad5 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/CharacterReader/Utf8Reader.php @@ -0,0 +1,181 @@ + + */ +class Swift_CharacterReader_Utf8Reader implements Swift_CharacterReader +{ + /** Pre-computed for optimization */ + private static $length_map=array( + // N=0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F, + 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, // 0x0N + 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, // 0x1N + 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, // 0x2N + 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, // 0x3N + 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, // 0x4N + 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, // 0x5N + 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, // 0x6N + 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, // 0x7N + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, // 0x8N + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, // 0x9N + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, // 0xAN + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, // 0xBN + 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, // 0xCN + 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, // 0xDN + 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3, // 0xEN + 4,4,4,4,4,4,4,4,5,5,5,5,6,6,0,0 // 0xFN + ); + + private static $s_length_map=array( + "\x00"=>1, "\x01"=>1, "\x02"=>1, "\x03"=>1, "\x04"=>1, "\x05"=>1, "\x06"=>1, "\x07"=>1, + "\x08"=>1, "\x09"=>1, "\x0a"=>1, "\x0b"=>1, "\x0c"=>1, "\x0d"=>1, "\x0e"=>1, "\x0f"=>1, + "\x10"=>1, "\x11"=>1, "\x12"=>1, "\x13"=>1, "\x14"=>1, "\x15"=>1, "\x16"=>1, "\x17"=>1, + "\x18"=>1, "\x19"=>1, "\x1a"=>1, "\x1b"=>1, "\x1c"=>1, "\x1d"=>1, "\x1e"=>1, "\x1f"=>1, + "\x20"=>1, "\x21"=>1, "\x22"=>1, "\x23"=>1, "\x24"=>1, "\x25"=>1, "\x26"=>1, "\x27"=>1, + "\x28"=>1, "\x29"=>1, "\x2a"=>1, "\x2b"=>1, "\x2c"=>1, "\x2d"=>1, "\x2e"=>1, "\x2f"=>1, + "\x30"=>1, "\x31"=>1, "\x32"=>1, "\x33"=>1, "\x34"=>1, "\x35"=>1, "\x36"=>1, "\x37"=>1, + "\x38"=>1, "\x39"=>1, "\x3a"=>1, "\x3b"=>1, "\x3c"=>1, "\x3d"=>1, "\x3e"=>1, "\x3f"=>1, + "\x40"=>1, "\x41"=>1, "\x42"=>1, "\x43"=>1, "\x44"=>1, "\x45"=>1, "\x46"=>1, "\x47"=>1, + "\x48"=>1, "\x49"=>1, "\x4a"=>1, "\x4b"=>1, "\x4c"=>1, "\x4d"=>1, "\x4e"=>1, "\x4f"=>1, + "\x50"=>1, "\x51"=>1, "\x52"=>1, "\x53"=>1, "\x54"=>1, "\x55"=>1, "\x56"=>1, "\x57"=>1, + "\x58"=>1, "\x59"=>1, "\x5a"=>1, "\x5b"=>1, "\x5c"=>1, "\x5d"=>1, "\x5e"=>1, "\x5f"=>1, + "\x60"=>1, "\x61"=>1, "\x62"=>1, "\x63"=>1, "\x64"=>1, "\x65"=>1, "\x66"=>1, "\x67"=>1, + "\x68"=>1, "\x69"=>1, "\x6a"=>1, "\x6b"=>1, "\x6c"=>1, "\x6d"=>1, "\x6e"=>1, "\x6f"=>1, + "\x70"=>1, "\x71"=>1, "\x72"=>1, "\x73"=>1, "\x74"=>1, "\x75"=>1, "\x76"=>1, "\x77"=>1, + "\x78"=>1, "\x79"=>1, "\x7a"=>1, "\x7b"=>1, "\x7c"=>1, "\x7d"=>1, "\x7e"=>1, "\x7f"=>1, + "\x80"=>0, "\x81"=>0, "\x82"=>0, "\x83"=>0, "\x84"=>0, "\x85"=>0, "\x86"=>0, "\x87"=>0, + "\x88"=>0, "\x89"=>0, "\x8a"=>0, "\x8b"=>0, "\x8c"=>0, "\x8d"=>0, "\x8e"=>0, "\x8f"=>0, + "\x90"=>0, "\x91"=>0, "\x92"=>0, "\x93"=>0, "\x94"=>0, "\x95"=>0, "\x96"=>0, "\x97"=>0, + "\x98"=>0, "\x99"=>0, "\x9a"=>0, "\x9b"=>0, "\x9c"=>0, "\x9d"=>0, "\x9e"=>0, "\x9f"=>0, + "\xa0"=>0, "\xa1"=>0, "\xa2"=>0, "\xa3"=>0, "\xa4"=>0, "\xa5"=>0, "\xa6"=>0, "\xa7"=>0, + "\xa8"=>0, "\xa9"=>0, "\xaa"=>0, "\xab"=>0, "\xac"=>0, "\xad"=>0, "\xae"=>0, "\xaf"=>0, + "\xb0"=>0, "\xb1"=>0, "\xb2"=>0, "\xb3"=>0, "\xb4"=>0, "\xb5"=>0, "\xb6"=>0, "\xb7"=>0, + "\xb8"=>0, "\xb9"=>0, "\xba"=>0, "\xbb"=>0, "\xbc"=>0, "\xbd"=>0, "\xbe"=>0, "\xbf"=>0, + "\xc0"=>2, "\xc1"=>2, "\xc2"=>2, "\xc3"=>2, "\xc4"=>2, "\xc5"=>2, "\xc6"=>2, "\xc7"=>2, + "\xc8"=>2, "\xc9"=>2, "\xca"=>2, "\xcb"=>2, "\xcc"=>2, "\xcd"=>2, "\xce"=>2, "\xcf"=>2, + "\xd0"=>2, "\xd1"=>2, "\xd2"=>2, "\xd3"=>2, "\xd4"=>2, "\xd5"=>2, "\xd6"=>2, "\xd7"=>2, + "\xd8"=>2, "\xd9"=>2, "\xda"=>2, "\xdb"=>2, "\xdc"=>2, "\xdd"=>2, "\xde"=>2, "\xdf"=>2, + "\xe0"=>3, "\xe1"=>3, "\xe2"=>3, "\xe3"=>3, "\xe4"=>3, "\xe5"=>3, "\xe6"=>3, "\xe7"=>3, + "\xe8"=>3, "\xe9"=>3, "\xea"=>3, "\xeb"=>3, "\xec"=>3, "\xed"=>3, "\xee"=>3, "\xef"=>3, + "\xf0"=>4, "\xf1"=>4, "\xf2"=>4, "\xf3"=>4, "\xf4"=>4, "\xf5"=>4, "\xf6"=>4, "\xf7"=>4, + "\xf8"=>5, "\xf9"=>5, "\xfa"=>5, "\xfb"=>5, "\xfc"=>6, "\xfd"=>6, "\xfe"=>0, "\xff"=>0, + ); + + /** + * Returns the complete character map. + * + * @param string $string + * @param int $startOffset + * @param array $currentMap + * @param mixed $ignoredChars + * + * @return int + */ + public function getCharPositions($string, $startOffset, &$currentMap, &$ignoredChars) + { + if (!isset($currentMap['i']) || ! isset($currentMap['p'])) { + $currentMap['p'] = $currentMap['i'] = array(); + } + + $strlen=strlen($string); + $charPos=count($currentMap['p']); + $foundChars=0; + $invalid=false; + for ($i = 0; $i < $strlen; ++$i) { + $char = $string[$i]; + $size = self::$s_length_map[$char]; + if ($size == 0) { + /* char is invalid, we must wait for a resync */ + $invalid = true; + continue; + } else { + if ($invalid == true) { + /* We mark the chars as invalid and start a new char */ + $currentMap['p'][$charPos + $foundChars] = $startOffset + $i; + $currentMap['i'][$charPos + $foundChars] = true; + ++$foundChars; + $invalid = false; + } + if (($i + $size) > $strlen) { + $ignoredChars = substr($string, $i); + break; + } + for ($j = 1; $j < $size; ++$j) { + $char = $string[$i + $j]; + if ($char > "\x7F" && $char < "\xC0") { + // Valid - continue parsing + } else { + /* char is invalid, we must wait for a resync */ + $invalid = true; + continue 2; + } + } + /* Ok we got a complete char here */ + $currentMap['p'][$charPos + $foundChars] = $startOffset + $i + $size; + $i += $j - 1; + ++$foundChars; + } + } + + return $foundChars; + } + + /** + * Returns mapType. + * + * @return int mapType + */ + public function getMapType() + { + return self::MAP_TYPE_POSITIONS; + } + + /** + * Returns an integer which specifies how many more bytes to read. + * + * A positive integer indicates the number of more bytes to fetch before invoking + * this method again. + * A value of zero means this is already a valid character. + * A value of -1 means this cannot possibly be a valid character. + * + * @param string $bytes + * @param int $size + * + * @return int + */ + public function validateByteSequence($bytes, $size) + { + if ($size<1) { + return -1; + } + $needed = self::$length_map[$bytes[0]] - $size; + + return ($needed > -1) + ? $needed + : -1 + ; + } + + /** + * Returns the number of bytes which should be read to start each character. + * + * @return int + */ + public function getInitialByteSize() + { + return 1; + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/CharacterReaderFactory.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/CharacterReaderFactory.php new file mode 100755 index 0000000..d653b81 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/CharacterReaderFactory.php @@ -0,0 +1,28 @@ +init(); + } + + public function __wakeup() + { + $this->init(); + } + + public function init() + { + if (count(self::$_map) > 0) { + return; + } + + $prefix = 'Swift_CharacterReader_'; + + $singleByte = array( + 'class' => $prefix . 'GenericFixedWidthReader', + 'constructor' => array(1) + ); + + $doubleByte = array( + 'class' => $prefix . 'GenericFixedWidthReader', + 'constructor' => array(2) + ); + + $fourBytes = array( + 'class' => $prefix . 'GenericFixedWidthReader', + 'constructor' => array(4) + ); + + // Utf-8 + self::$_map['utf-?8'] = array( + 'class' => $prefix . 'Utf8Reader', + 'constructor' => array() + ); + + //7-8 bit charsets + self::$_map['(us-)?ascii'] = $singleByte; + self::$_map['(iso|iec)-?8859-?[0-9]+'] = $singleByte; + self::$_map['windows-?125[0-9]'] = $singleByte; + self::$_map['cp-?[0-9]+'] = $singleByte; + self::$_map['ansi'] = $singleByte; + self::$_map['macintosh'] = $singleByte; + self::$_map['koi-?7'] = $singleByte; + self::$_map['koi-?8-?.+'] = $singleByte; + self::$_map['mik'] = $singleByte; + self::$_map['(cork|t1)'] = $singleByte; + self::$_map['v?iscii'] = $singleByte; + + //16 bits + self::$_map['(ucs-?2|utf-?16)'] = $doubleByte; + + //32 bits + self::$_map['(ucs-?4|utf-?32)'] = $fourBytes; + + // Fallback + self::$_map['.*'] = $singleByte; + } + + /** + * Returns a CharacterReader suitable for the charset applied. + * + * @param string $charset + * + * @return Swift_CharacterReader + */ + public function getReaderFor($charset) + { + $charset = trim(strtolower($charset)); + foreach (self::$_map as $pattern => $spec) { + $re = '/^' . $pattern . '$/D'; + if (preg_match($re, $charset)) { + if (!array_key_exists($pattern, self::$_loaded)) { + $reflector = new ReflectionClass($spec['class']); + if ($reflector->getConstructor()) { + $reader = $reflector->newInstanceArgs($spec['constructor']); + } else { + $reader = $reflector->newInstance(); + } + self::$_loaded[$pattern] = $reader; + } + + return self::$_loaded[$pattern]; + } + } + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/CharacterStream.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/CharacterStream.php new file mode 100755 index 0000000..a0f0721 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/CharacterStream.php @@ -0,0 +1,91 @@ +setCharacterReaderFactory($factory); + $this->setCharacterSet($charset); + } + + /** + * Set the character set used in this CharacterStream. + * + * @param string $charset + */ + public function setCharacterSet($charset) + { + $this->_charset = $charset; + $this->_charReader = null; + } + + /** + * Set the CharacterReaderFactory for multi charset support. + * + * @param Swift_CharacterReaderFactory $factory + */ + public function setCharacterReaderFactory(Swift_CharacterReaderFactory $factory) + { + $this->_charReaderFactory = $factory; + } + + /** + * Overwrite this character stream using the byte sequence in the byte stream. + * + * @param Swift_OutputByteStream $os output stream to read from + */ + public function importByteStream(Swift_OutputByteStream $os) + { + if (!isset($this->_charReader)) { + $this->_charReader = $this->_charReaderFactory + ->getReaderFor($this->_charset); + } + + $startLength = $this->_charReader->getInitialByteSize(); + while (false !== $bytes = $os->read($startLength)) { + $c = array(); + for ($i = 0, $len = strlen($bytes); $i < $len; ++$i) { + $c[] = self::$_byteMap[$bytes[$i]]; + } + $size = count($c); + $need = $this->_charReader + ->validateByteSequence($c, $size); + if ($need > 0 && + false !== $bytes = $os->read($need)) + { + for ($i = 0, $len = strlen($bytes); $i < $len; ++$i) { + $c[] = self::$_byteMap[$bytes[$i]]; + } + } + $this->_array[] = $c; + ++$this->_array_size; + } + } + + /** + * Import a string a bytes into this CharacterStream, overwriting any existing + * data in the stream. + * + * @param string $string + */ + public function importString($string) + { + $this->flushContents(); + $this->write($string); + } + + /** + * Read $length characters from the stream and move the internal pointer + * $length further into the stream. + * + * @param int $length + * + * @return string + */ + public function read($length) + { + if ($this->_offset == $this->_array_size) { + return false; + } + + // Don't use array slice + $arrays = array(); + $end = $length + $this->_offset; + for ($i = $this->_offset; $i < $end; ++$i) { + if (!isset($this->_array[$i])) { + break; + } + $arrays[] = $this->_array[$i]; + } + $this->_offset += $i - $this->_offset; // Limit function calls + $chars = false; + foreach ($arrays as $array) { + $chars .= implode('', array_map('chr', $array)); + } + + return $chars; + } + + /** + * Read $length characters from the stream and return a 1-dimensional array + * containing there octet values. + * + * @param int $length + * + * @return integer[] + */ + public function readBytes($length) + { + if ($this->_offset == $this->_array_size) { + return false; + } + $arrays = array(); + $end = $length + $this->_offset; + for ($i = $this->_offset; $i < $end; ++$i) { + if (!isset($this->_array[$i])) { + break; + } + $arrays[] = $this->_array[$i]; + } + $this->_offset += ($i - $this->_offset); // Limit function calls + + return call_user_func_array('array_merge', $arrays); + } + + /** + * Write $chars to the end of the stream. + * + * @param string $chars + */ + public function write($chars) + { + if (!isset($this->_charReader)) { + $this->_charReader = $this->_charReaderFactory->getReaderFor( + $this->_charset); + } + + $startLength = $this->_charReader->getInitialByteSize(); + + $fp = fopen('php://memory', 'w+b'); + fwrite($fp, $chars); + unset($chars); + fseek($fp, 0, SEEK_SET); + + $buffer = array(0); + $buf_pos = 1; + $buf_len = 1; + $has_datas = true; + do { + $bytes = array(); + // Buffer Filing + if ($buf_len - $buf_pos < $startLength) { + $buf = array_splice($buffer, $buf_pos); + $new = $this->_reloadBuffer($fp, 100); + if ($new) { + $buffer = array_merge($buf, $new); + $buf_len = count($buffer); + $buf_pos = 0; + } else { + $has_datas = false; + } + } + if ($buf_len - $buf_pos > 0) { + $size = 0; + for ($i = 0; $i < $startLength && isset($buffer[$buf_pos]); ++$i) { + ++$size; + $bytes[] = $buffer[$buf_pos++]; + } + $need = $this->_charReader->validateByteSequence( + $bytes, $size); + if ($need > 0) { + if ($buf_len - $buf_pos < $need) { + $new = $this->_reloadBuffer($fp, $need); + + if ($new) { + $buffer = array_merge($buffer, $new); + $buf_len = count($buffer); + } + } + for ($i = 0; $i < $need && isset($buffer[$buf_pos]); ++$i) { + $bytes[] = $buffer[$buf_pos++]; + } + } + $this->_array[] = $bytes; + ++$this->_array_size; + } + } while ($has_datas); + + fclose($fp); + } + + /** + * Move the internal pointer to $charOffset in the stream. + * + * @param int $charOffset + */ + public function setPointer($charOffset) + { + if ($charOffset > $this->_array_size) { + $charOffset = $this->_array_size; + } elseif ($charOffset < 0) { + $charOffset = 0; + } + $this->_offset = $charOffset; + } + + /** + * Empty the stream and reset the internal pointer. + */ + public function flushContents() + { + $this->_offset = 0; + $this->_array = array(); + $this->_array_size = 0; + } + + private function _reloadBuffer($fp, $len) + { + if (!feof($fp) && ($bytes = fread($fp, $len)) !== false) { + $buf = array(); + for ($i = 0, $len = strlen($bytes); $i < $len; ++$i) { + $buf[] = self::$_byteMap[$bytes[$i]]; + } + + return $buf; + } + + return false; + } + + private static function _initializeMaps() + { + if (!isset(self::$_charMap)) { + self::$_charMap = array(); + for ($byte = 0; $byte < 256; ++$byte) { + self::$_charMap[$byte] = chr($byte); + } + self::$_byteMap = array_flip(self::$_charMap); + } + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/CharacterStream/NgCharacterStream.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/CharacterStream/NgCharacterStream.php new file mode 100755 index 0000000..d43c4e0 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/CharacterStream/NgCharacterStream.php @@ -0,0 +1,277 @@ + + */ + +class Swift_CharacterStream_NgCharacterStream implements Swift_CharacterStream +{ + /** + * The char reader (lazy-loaded) for the current charset. + * + * @var Swift_CharacterReader + */ + private $_charReader; + + /** + * A factory for creating CharacterReader instances. + * + * @var Swift_CharacterReaderFactory + */ + private $_charReaderFactory; + + /** + * The character set this stream is using. + * + * @var string + */ + private $_charset; + + /** + * The data's stored as-is. + * + * @var string + */ + private $_datas = ''; + + /** + * Number of bytes in the stream + * + * @var int + */ + private $_datasSize = 0; + + /** + * Map. + * + * @var mixed + */ + private $_map; + + /** + * Map Type. + * + * @var int + */ + private $_mapType = 0; + + /** + * Number of characters in the stream. + * + * @var int + */ + private $_charCount = 0; + + /** + * Position in the stream. + * + * @var int + */ + private $_currentPos = 0; + + /** + * Constructor. + * + * @param Swift_CharacterReaderFactory $factory + * @param string $charset + */ + public function __construct(Swift_CharacterReaderFactory $factory, $charset) + { + $this->setCharacterReaderFactory($factory); + $this->setCharacterSet($charset); + } + + /* -- Changing parameters of the stream -- */ + + /** + * Set the character set used in this CharacterStream. + * + * @param string $charset + */ + public function setCharacterSet($charset) + { + $this->_charset = $charset; + $this->_charReader = null; + $this->_mapType = 0; + } + + /** + * Set the CharacterReaderFactory for multi charset support. + * + * @param Swift_CharacterReaderFactory $factory + */ + public function setCharacterReaderFactory(Swift_CharacterReaderFactory $factory) + { + $this->_charReaderFactory = $factory; + } + + /** + * @see Swift_CharacterStream::flushContents() + */ + public function flushContents() + { + $this->_datas = null; + $this->_map = null; + $this->_charCount = 0; + $this->_currentPos = 0; + $this->_datasSize = 0; + } + + /** + * @see Swift_CharacterStream::importByteStream() + * + * @param Swift_OutputByteStream $os + */ + public function importByteStream(Swift_OutputByteStream $os) + { + $this->flushContents(); + $blocks=512; + $os->setReadPointer(0); + while(false!==($read = $os->read($blocks))) + $this->write($read); + } + + /** + * @see Swift_CharacterStream::importString() + * + * @param string $string + */ + public function importString($string) + { + $this->flushContents(); + $this->write($string); + } + + /** + * @see Swift_CharacterStream::read() + * + * @param int $length + * + * @return string + */ + public function read($length) + { + if ($this->_currentPos>=$this->_charCount) { + return false; + } + $ret=false; + $length = ($this->_currentPos+$length > $this->_charCount) + ? $this->_charCount - $this->_currentPos + : $length; + switch ($this->_mapType) { + case Swift_CharacterReader::MAP_TYPE_FIXED_LEN: + $len = $length*$this->_map; + $ret = substr($this->_datas, + $this->_currentPos * $this->_map, + $len); + $this->_currentPos += $length; + break; + + case Swift_CharacterReader::MAP_TYPE_INVALID: + $end = $this->_currentPos + $length; + $end = $end > $this->_charCount + ?$this->_charCount + :$end; + $ret = ''; + for (; $this->_currentPos < $length; ++$this->_currentPos) { + if (isset ($this->_map[$this->_currentPos])) { + $ret .= '?'; + } else { + $ret .= $this->_datas[$this->_currentPos]; + } + } + break; + + case Swift_CharacterReader::MAP_TYPE_POSITIONS: + $end = $this->_currentPos + $length; + $end = $end > $this->_charCount + ?$this->_charCount + :$end; + $ret = ''; + $start = 0; + if ($this->_currentPos>0) { + $start = $this->_map['p'][$this->_currentPos-1]; + } + $to = $start; + for (; $this->_currentPos < $end; ++$this->_currentPos) { + if (isset($this->_map['i'][$this->_currentPos])) { + $ret .= substr($this->_datas, $start, $to - $start).'?'; + $start = $this->_map['p'][$this->_currentPos]; + } else { + $to = $this->_map['p'][$this->_currentPos]; + } + } + $ret .= substr($this->_datas, $start, $to - $start); + break; + } + + return $ret; + } + + /** + * @see Swift_CharacterStream::readBytes() + * + * @param int $length + * + * @return integer[] + */ + public function readBytes($length) + { + $read=$this->read($length); + if ($read!==false) { + $ret = array_map('ord', str_split($read, 1)); + + return $ret; + } + + return false; + } + + /** + * @see Swift_CharacterStream::setPointer() + * + * @param int $charOffset + */ + public function setPointer($charOffset) + { + if ($this->_charCount<$charOffset) { + $charOffset=$this->_charCount; + } + $this->_currentPos = $charOffset; + } + + /** + * @see Swift_CharacterStream::write() + * + * @param string $chars + */ + public function write($chars) + { + if (!isset($this->_charReader)) { + $this->_charReader = $this->_charReaderFactory->getReaderFor( + $this->_charset); + $this->_map = array(); + $this->_mapType = $this->_charReader->getMapType(); + } + $ignored=''; + $this->_datas .= $chars; + $this->_charCount += $this->_charReader->getCharPositions(substr($this->_datas, $this->_datasSize), $this->_datasSize, $this->_map, $ignored); + if ($ignored!==false) { + $this->_datasSize=strlen($this->_datas)-strlen($ignored); + } else { + $this->_datasSize=strlen($this->_datas); + } + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/ConfigurableSpool.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/ConfigurableSpool.php new file mode 100755 index 0000000..11179f8 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/ConfigurableSpool.php @@ -0,0 +1,64 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +/** + * Base class for Spools (implements time and message limits). + * + * @package Swift + * @author Fabien Potencier + */ +abstract class Swift_ConfigurableSpool implements Swift_Spool +{ + /** The maximum number of messages to send per flush */ + private $_message_limit; + + /** The time limit per flush */ + private $_time_limit; + + /** + * Sets the maximum number of messages to send per flush. + * + * @param int $limit + */ + public function setMessageLimit($limit) + { + $this->_message_limit = (int) $limit; + } + + /** + * Gets the maximum number of messages to send per flush. + * + * @return int The limit + */ + public function getMessageLimit() + { + return $this->_message_limit; + } + + /** + * Sets the time limit (in seconds) per flush. + * + * @param int $limit The limit + */ + public function setTimeLimit($limit) + { + $this->_time_limit = (int) $limit; + } + + /** + * Gets the time limit (in seconds) per flush. + * + * @return int The limit + */ + public function getTimeLimit() + { + return $this->_time_limit; + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/DependencyContainer.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/DependencyContainer.php new file mode 100755 index 0000000..2f9a774 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/DependencyContainer.php @@ -0,0 +1,373 @@ +_store); + } + + /** + * Test if an item is registered in this container with the given name. + * + * @see register() + * + * @param string $itemName + * + * @return bool + */ + public function has($itemName) + { + return array_key_exists($itemName, $this->_store) + && isset($this->_store[$itemName]['lookupType']); + } + + /** + * Lookup the item with the given $itemName. + * + * @see register() + * + * @param string $itemName + * + * @return mixed + * + * @throws Swift_DependencyException If the dependency is not found + */ + public function lookup($itemName) + { + if (!$this->has($itemName)) { + throw new Swift_DependencyException( + 'Cannot lookup dependency "' . $itemName . '" since it is not registered.' + ); + } + + switch ($this->_store[$itemName]['lookupType']) { + case self::TYPE_ALIAS: + return $this->_createAlias($itemName); + case self::TYPE_VALUE: + return $this->_getValue($itemName); + case self::TYPE_INSTANCE: + return $this->_createNewInstance($itemName); + case self::TYPE_SHARED: + return $this->_createSharedInstance($itemName); + } + } + + /** + * Create an array of arguments passed to the constructor of $itemName. + * + * @param string $itemName + * + * @return array + */ + public function createDependenciesFor($itemName) + { + $args = array(); + if (isset($this->_store[$itemName]['args'])) { + $args = $this->_resolveArgs($this->_store[$itemName]['args']); + } + + return $args; + } + + /** + * Register a new dependency with $itemName. + * + * This method returns the current DependencyContainer instance because it + * requires the use of the fluid interface to set the specific details for the + * dependency. + * @see asNewInstanceOf(), asSharedInstanceOf(), asValue() + * + * @param string $itemName + * + * @return Swift_DependencyContainer + */ + public function register($itemName) + { + $this->_store[$itemName] = array(); + $this->_endPoint =& $this->_store[$itemName]; + + return $this; + } + + /** + * Specify the previously registered item as a literal value. + * + * {@link register()} must be called before this will work. + * + * @param mixed $value + * + * @return Swift_DependencyContainer + */ + public function asValue($value) + { + $endPoint =& $this->_getEndPoint(); + $endPoint['lookupType'] = self::TYPE_VALUE; + $endPoint['value'] = $value; + + return $this; + } + + /** + * Specify the previously registered item as an alias of another item. + * + * @param string $lookup + * + * @return Swift_DependencyContainer + */ + public function asAliasOf($lookup) + { + $endPoint =& $this->_getEndPoint(); + $endPoint['lookupType'] = self::TYPE_ALIAS; + $endPoint['ref'] = $lookup; + + return $this; + } + + /** + * Specify the previously registered item as a new instance of $className. + * + * {@link register()} must be called before this will work. + * Any arguments can be set with {@link withDependencies()}, + * {@link addConstructorValue()} or {@link addConstructorLookup()}. + * + * @see withDependencies(), addConstructorValue(), addConstructorLookup() + * + * @param string $className + * + * @return Swift_DependencyContainer + */ + public function asNewInstanceOf($className) + { + $endPoint =& $this->_getEndPoint(); + $endPoint['lookupType'] = self::TYPE_INSTANCE; + $endPoint['className'] = $className; + + return $this; + } + + /** + * Specify the previously registered item as a shared instance of $className. + * + * {@link register()} must be called before this will work. + * + * @param string $className + * + * @return Swift_DependencyContainer + */ + public function asSharedInstanceOf($className) + { + $endPoint =& $this->_getEndPoint(); + $endPoint['lookupType'] = self::TYPE_SHARED; + $endPoint['className'] = $className; + + return $this; + } + + /** + * Specify a list of injected dependencies for the previously registered item. + * + * This method takes an array of lookup names. + * + * @see addConstructorValue(), addConstructorLookup() + * + * @param array $lookups + * + * @return Swift_DependencyContainer + */ + public function withDependencies(array $lookups) + { + $endPoint =& $this->_getEndPoint(); + $endPoint['args'] = array(); + foreach ($lookups as $lookup) { + $this->addConstructorLookup($lookup); + } + + return $this; + } + + /** + * Specify a literal (non looked up) value for the constructor of the + * previously registered item. + * + * @see withDependencies(), addConstructorLookup() + * + * @param mixed $value + * + * @return Swift_DependencyContainer + */ + public function addConstructorValue($value) + { + $endPoint =& $this->_getEndPoint(); + if (!isset($endPoint['args'])) { + $endPoint['args'] = array(); + } + $endPoint['args'][] = array('type' => 'value', 'item' => $value); + + return $this; + } + + /** + * Specify a dependency lookup for the constructor of the previously + * registered item. + * + * @see withDependencies(), addConstructorValue() + * + * @param string $lookup + * + * @return Swift_DependencyContainer + */ + public function addConstructorLookup($lookup) + { + $endPoint =& $this->_getEndPoint(); + if (!isset($this->_endPoint['args'])) { + $endPoint['args'] = array(); + } + $endPoint['args'][] = array('type' => 'lookup', 'item' => $lookup); + + return $this; + } + + // -- Private methods + + /** Get the literal value with $itemName */ + private function _getValue($itemName) + { + return $this->_store[$itemName]['value']; + } + + /** Resolve an alias to another item */ + private function _createAlias($itemName) + { + return $this->lookup($this->_store[$itemName]['ref']); + } + + /** Create a fresh instance of $itemName */ + private function _createNewInstance($itemName) + { + $reflector = new ReflectionClass($this->_store[$itemName]['className']); + if ($reflector->getConstructor()) { + return $reflector->newInstanceArgs( + $this->createDependenciesFor($itemName) + ); + } else { + return $reflector->newInstance(); + } + } + + /** Create and register a shared instance of $itemName */ + private function _createSharedInstance($itemName) + { + if (!isset($this->_store[$itemName]['instance'])) { + $this->_store[$itemName]['instance'] = $this->_createNewInstance($itemName); + } + + return $this->_store[$itemName]['instance']; + } + + /** Get the current endpoint in the store */ + private function &_getEndPoint() + { + if (!isset($this->_endPoint)) { + throw new BadMethodCallException( + 'Component must first be registered by calling register()' + ); + } + + return $this->_endPoint; + } + + /** Get an argument list with dependencies resolved */ + private function _resolveArgs(array $args) + { + $resolved = array(); + foreach ($args as $argDefinition) { + switch ($argDefinition['type']) { + case 'lookup': + $resolved[] = $this->_lookupRecursive($argDefinition['item']); + break; + case 'value': + $resolved[] = $argDefinition['item']; + break; + } + } + + return $resolved; + } + + /** Resolve a single dependency with an collections */ + private function _lookupRecursive($item) + { + if (is_array($item)) { + $collection = array(); + foreach ($item as $k => $v) { + $collection[$k] = $this->_lookupRecursive($v); + } + + return $collection; + } else { + return $this->lookup($item); + } + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/DependencyException.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/DependencyException.php new file mode 100755 index 0000000..b3f0170 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/DependencyException.php @@ -0,0 +1,28 @@ +createDependenciesFor('mime.embeddedfile') + ); + + $this->setBody($data); + $this->setFilename($filename); + if ($contentType) { + $this->setContentType($contentType); + } + } + + /** + * Create a new EmbeddedFile. + * + * @param string|Swift_OutputByteStream $data + * @param string $filename + * @param string $contentType + * + * @return Swift_Mime_EmbeddedFile + */ + public static function newInstance($data = null, $filename = null, $contentType = null) + { + return new self($data, $filename, $contentType); + } + + /** + * Create a new EmbeddedFile from a filesystem path. + * + * @param string $path + * + * @return Swift_Mime_EmbeddedFile + */ + public static function fromPath($path) + { + return self::newInstance()->setFile( + new Swift_ByteStream_FileByteStream($path) + ); + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Encoder.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Encoder.php new file mode 100755 index 0000000..2ad62e6 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Encoder.php @@ -0,0 +1,29 @@ += $maxLineLength || 76 < $maxLineLength) { + $maxLineLength = 76; + } + + $encodedString = base64_encode($string); + $firstLine = ''; + + if (0 != $firstLineOffset) { + $firstLine = substr( + $encodedString, 0, $maxLineLength - $firstLineOffset + ) . "\r\n"; + $encodedString = substr( + $encodedString, $maxLineLength - $firstLineOffset + ); + } + + return $firstLine . trim(chunk_split($encodedString, $maxLineLength, "\r\n")); + } + + /** + * Does nothing. + */ + public function charsetChanged($charset) + { + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Encoder/QpEncoder.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Encoder/QpEncoder.php new file mode 100755 index 0000000..3c362ed --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Encoder/QpEncoder.php @@ -0,0 +1,286 @@ + '=00', 1 => '=01', 2 => '=02', 3 => '=03', 4 => '=04', + 5 => '=05', 6 => '=06', 7 => '=07', 8 => '=08', 9 => '=09', + 10 => '=0A', 11 => '=0B', 12 => '=0C', 13 => '=0D', 14 => '=0E', + 15 => '=0F', 16 => '=10', 17 => '=11', 18 => '=12', 19 => '=13', + 20 => '=14', 21 => '=15', 22 => '=16', 23 => '=17', 24 => '=18', + 25 => '=19', 26 => '=1A', 27 => '=1B', 28 => '=1C', 29 => '=1D', + 30 => '=1E', 31 => '=1F', 32 => '=20', 33 => '=21', 34 => '=22', + 35 => '=23', 36 => '=24', 37 => '=25', 38 => '=26', 39 => '=27', + 40 => '=28', 41 => '=29', 42 => '=2A', 43 => '=2B', 44 => '=2C', + 45 => '=2D', 46 => '=2E', 47 => '=2F', 48 => '=30', 49 => '=31', + 50 => '=32', 51 => '=33', 52 => '=34', 53 => '=35', 54 => '=36', + 55 => '=37', 56 => '=38', 57 => '=39', 58 => '=3A', 59 => '=3B', + 60 => '=3C', 61 => '=3D', 62 => '=3E', 63 => '=3F', 64 => '=40', + 65 => '=41', 66 => '=42', 67 => '=43', 68 => '=44', 69 => '=45', + 70 => '=46', 71 => '=47', 72 => '=48', 73 => '=49', 74 => '=4A', + 75 => '=4B', 76 => '=4C', 77 => '=4D', 78 => '=4E', 79 => '=4F', + 80 => '=50', 81 => '=51', 82 => '=52', 83 => '=53', 84 => '=54', + 85 => '=55', 86 => '=56', 87 => '=57', 88 => '=58', 89 => '=59', + 90 => '=5A', 91 => '=5B', 92 => '=5C', 93 => '=5D', 94 => '=5E', + 95 => '=5F', 96 => '=60', 97 => '=61', 98 => '=62', 99 => '=63', + 100 => '=64', 101 => '=65', 102 => '=66', 103 => '=67', 104 => '=68', + 105 => '=69', 106 => '=6A', 107 => '=6B', 108 => '=6C', 109 => '=6D', + 110 => '=6E', 111 => '=6F', 112 => '=70', 113 => '=71', 114 => '=72', + 115 => '=73', 116 => '=74', 117 => '=75', 118 => '=76', 119 => '=77', + 120 => '=78', 121 => '=79', 122 => '=7A', 123 => '=7B', 124 => '=7C', + 125 => '=7D', 126 => '=7E', 127 => '=7F', 128 => '=80', 129 => '=81', + 130 => '=82', 131 => '=83', 132 => '=84', 133 => '=85', 134 => '=86', + 135 => '=87', 136 => '=88', 137 => '=89', 138 => '=8A', 139 => '=8B', + 140 => '=8C', 141 => '=8D', 142 => '=8E', 143 => '=8F', 144 => '=90', + 145 => '=91', 146 => '=92', 147 => '=93', 148 => '=94', 149 => '=95', + 150 => '=96', 151 => '=97', 152 => '=98', 153 => '=99', 154 => '=9A', + 155 => '=9B', 156 => '=9C', 157 => '=9D', 158 => '=9E', 159 => '=9F', + 160 => '=A0', 161 => '=A1', 162 => '=A2', 163 => '=A3', 164 => '=A4', + 165 => '=A5', 166 => '=A6', 167 => '=A7', 168 => '=A8', 169 => '=A9', + 170 => '=AA', 171 => '=AB', 172 => '=AC', 173 => '=AD', 174 => '=AE', + 175 => '=AF', 176 => '=B0', 177 => '=B1', 178 => '=B2', 179 => '=B3', + 180 => '=B4', 181 => '=B5', 182 => '=B6', 183 => '=B7', 184 => '=B8', + 185 => '=B9', 186 => '=BA', 187 => '=BB', 188 => '=BC', 189 => '=BD', + 190 => '=BE', 191 => '=BF', 192 => '=C0', 193 => '=C1', 194 => '=C2', + 195 => '=C3', 196 => '=C4', 197 => '=C5', 198 => '=C6', 199 => '=C7', + 200 => '=C8', 201 => '=C9', 202 => '=CA', 203 => '=CB', 204 => '=CC', + 205 => '=CD', 206 => '=CE', 207 => '=CF', 208 => '=D0', 209 => '=D1', + 210 => '=D2', 211 => '=D3', 212 => '=D4', 213 => '=D5', 214 => '=D6', + 215 => '=D7', 216 => '=D8', 217 => '=D9', 218 => '=DA', 219 => '=DB', + 220 => '=DC', 221 => '=DD', 222 => '=DE', 223 => '=DF', 224 => '=E0', + 225 => '=E1', 226 => '=E2', 227 => '=E3', 228 => '=E4', 229 => '=E5', + 230 => '=E6', 231 => '=E7', 232 => '=E8', 233 => '=E9', 234 => '=EA', + 235 => '=EB', 236 => '=EC', 237 => '=ED', 238 => '=EE', 239 => '=EF', + 240 => '=F0', 241 => '=F1', 242 => '=F2', 243 => '=F3', 244 => '=F4', + 245 => '=F5', 246 => '=F6', 247 => '=F7', 248 => '=F8', 249 => '=F9', + 250 => '=FA', 251 => '=FB', 252 => '=FC', 253 => '=FD', 254 => '=FE', + 255 => '=FF' + ); + + protected static $_safeMapShare = array(); + + /** + * A map of non-encoded ascii characters. + * + * @var string[] + */ + protected $_safeMap = array(); + + /** + * Creates a new QpEncoder for the given CharacterStream. + * + * @param Swift_CharacterStream $charStream to use for reading characters + * @param Swift_StreamFilter $filter if input should be canonicalized + */ + public function __construct(Swift_CharacterStream $charStream, Swift_StreamFilter $filter = null) + { + $this->_charStream = $charStream; + if (!isset(self::$_safeMapShare[$this->getSafeMapShareId()])) { + $this->initSafeMap(); + self::$_safeMapShare[$this->getSafeMapShareId()] = $this->_safeMap; + } else { + $this->_safeMap = self::$_safeMapShare[$this->getSafeMapShareId()]; + } + $this->_filter = $filter; + } + + public function __sleep() + { + return array('_charStream', '_filter'); + } + + public function __wakeup() + { + if (!isset(self::$_safeMapShare[$this->getSafeMapShareId()])) { + $this->initSafeMap(); + self::$_safeMapShare[$this->getSafeMapShareId()] = $this->_safeMap; + } else { + $this->_safeMap = self::$_safeMapShare[$this->getSafeMapShareId()]; + } + } + + protected function getSafeMapShareId() + { + return get_class($this); + } + + protected function initSafeMap() + { + foreach (array_merge( + array(0x09, 0x20), range(0x21, 0x3C), range(0x3E, 0x7E)) as $byte) + { + $this->_safeMap[$byte] = chr($byte); + } + } + + /** + * Takes an unencoded string and produces a QP encoded string from it. + * + * QP encoded strings have a maximum line length of 76 characters. + * If the first line needs to be shorter, indicate the difference with + * $firstLineOffset. + * + * @param string $string to encode + * @param int $firstLineOffset, optional + * @param int $maxLineLength, optional 0 indicates the default of 76 chars + * + * @return string + */ + public function encodeString($string, $firstLineOffset = 0, $maxLineLength = 0) + { + if ($maxLineLength > 76 || $maxLineLength <= 0) { + $maxLineLength = 76; + } + + $thisLineLength = $maxLineLength - $firstLineOffset; + + $lines = array(); + $lNo = 0; + $lines[$lNo] = ''; + $currentLine =& $lines[$lNo++]; + $size=$lineLen=0; + + $this->_charStream->flushContents(); + $this->_charStream->importString($string); + + // Fetching more than 4 chars at one is slower, as is fetching fewer bytes + // Conveniently 4 chars is the UTF-8 safe number since UTF-8 has up to 6 + // bytes per char and (6 * 4 * 3 = 72 chars per line) * =NN is 3 bytes + while (false !== $bytes = $this->_nextSequence()) { + // If we're filtering the input + if (isset($this->_filter)) { + // If we can't filter because we need more bytes + while ($this->_filter->shouldBuffer($bytes)) { + // Then collect bytes into the buffer + if (false === $moreBytes = $this->_nextSequence(1)) { + break; + } + + foreach ($moreBytes as $b) { + $bytes[] = $b; + } + } + // And filter them + $bytes = $this->_filter->filter($bytes); + } + + $enc = $this->_encodeByteSequence($bytes, $size); + if ($currentLine && $lineLen+$size >= $thisLineLength) { + $lines[$lNo] = ''; + $currentLine =& $lines[$lNo++]; + $thisLineLength = $maxLineLength; + $lineLen=0; + } + $lineLen+=$size; + $currentLine .= $enc; + } + + return $this->_standardize(implode("=\r\n", $lines)); + } + + /** + * Updates the charset used. + * + * @param string $charset + */ + public function charsetChanged($charset) + { + $this->_charStream->setCharacterSet($charset); + } + + // -- Protected methods + + /** + * Encode the given byte array into a verbatim QP form. + * + * @param integer[] $bytes + * @param int $size + * + * @return string + */ + protected function _encodeByteSequence(array $bytes, &$size) + { + $ret = ''; + $size=0; + foreach ($bytes as $b) { + if (isset($this->_safeMap[$b])) { + $ret .= $this->_safeMap[$b]; + ++$size; + } else { + $ret .= self::$_qpMap[$b]; + $size+=3; + } + } + + return $ret; + } + + /** + * Get the next sequence of bytes to read from the char stream. + * + * @param int $size number of bytes to read + * + * @return integer[] + */ + protected function _nextSequence($size = 4) + { + return $this->_charStream->readBytes($size); + } + + /** + * Make sure CRLF is correct and HT/SPACE are in valid places. + * + * @param string $string + * + * @return string + */ + protected function _standardize($string) + { + $string = str_replace(array("\t=0D=0A", " =0D=0A", "=0D=0A"), + array("=09\r\n", "=20\r\n", "\r\n"), $string + ); + switch ($end = ord(substr($string, -1))) { + case 0x09: + case 0x20: + $string = substr_replace($string, self::$_qpMap[$end], -1); + } + + return $string; + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Encoder/Rfc2231Encoder.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Encoder/Rfc2231Encoder.php new file mode 100755 index 0000000..aa914a8 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Encoder/Rfc2231Encoder.php @@ -0,0 +1,86 @@ +_charStream = $charStream; + } + + /** + * Takes an unencoded string and produces a string encoded according to + * RFC 2231 from it. + * + * @param string $string + * @param int $firstLineOffset + * @param int $maxLineLength optional, 0 indicates the default of 75 bytes + * + * @return string + */ + public function encodeString($string, $firstLineOffset = 0, $maxLineLength = 0) + { + $lines = array(); $lineCount = 0; + $lines[] = ''; + $currentLine =& $lines[$lineCount++]; + + if (0 >= $maxLineLength) { + $maxLineLength = 75; + } + + $this->_charStream->flushContents(); + $this->_charStream->importString($string); + + $thisLineLength = $maxLineLength - $firstLineOffset; + + while (false !== $char = $this->_charStream->read(4)) { + $encodedChar = rawurlencode($char); + if (0 != strlen($currentLine) + && strlen($currentLine . $encodedChar) > $thisLineLength) + { + $lines[] = ''; + $currentLine =& $lines[$lineCount++]; + $thisLineLength = $maxLineLength; + } + $currentLine .= $encodedChar; + } + + return implode("\r\n", $lines); + } + + /** + * Updates the charset used. + * + * @param string $charset + */ + public function charsetChanged($charset) + { + $this->_charStream->setCharacterSet($charset); + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Encoding.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Encoding.php new file mode 100755 index 0000000..9639194 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Encoding.php @@ -0,0 +1,66 @@ +lookup($key); + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Events/CommandEvent.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Events/CommandEvent.php new file mode 100755 index 0000000..fa4f444 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Events/CommandEvent.php @@ -0,0 +1,67 @@ +_command = $command; + $this->_successCodes = $successCodes; + } + + /** + * Get the command which was sent to the server. + * + * @return string + */ + public function getCommand() + { + return $this->_command; + } + + /** + * Get the numeric response codes which indicate success for this command. + * + * @return integer[] + */ + public function getSuccessCodes() + { + return $this->_successCodes; + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Events/CommandListener.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Events/CommandListener.php new file mode 100755 index 0000000..6800904 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Events/CommandListener.php @@ -0,0 +1,26 @@ +_source = $source; + } + + /** + * Get the source object of this event. + * + * @return object + */ + public function getSource() + { + return $this->_source; + } + + /** + * Prevent this Event from bubbling any further up the stack. + * + * @param bool $cancel, optional + */ + public function cancelBubble($cancel = true) + { + $this->_bubbleCancelled = $cancel; + } + + /** + * Returns true if this Event will not bubble any further up the stack. + * + * @return bool + */ + public function bubbleCancelled() + { + return $this->_bubbleCancelled; + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Events/ResponseEvent.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Events/ResponseEvent.php new file mode 100755 index 0000000..6d7eb27 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Events/ResponseEvent.php @@ -0,0 +1,68 @@ +_response = $response; + $this->_valid = $valid; + } + + /** + * Get the response which was received from the server. + * + * @return string + */ + public function getResponse() + { + return $this->_response; + } + + /** + * Get the success status of this Event. + * + * @return bool + */ + public function isValid() + { + return $this->_valid; + } + +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Events/ResponseListener.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Events/ResponseListener.php new file mode 100755 index 0000000..a39ba43 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Events/ResponseListener.php @@ -0,0 +1,26 @@ +_message = $message; + $this->_result = self::RESULT_PENDING; + } + + /** + * Get the Transport used to send the Message. + * + * @return Swift_Transport + */ + public function getTransport() + { + return $this->getSource(); + } + + /** + * Get the Message being sent. + * + * @return Swift_Mime_Message + */ + public function getMessage() + { + return $this->_message; + } + + /** + * Set the array of addresses that failed in sending. + * + * @param array $recipients + */ + public function setFailedRecipients($recipients) + { + $this->_failedRecipients = $recipients; + } + + /** + * Get an recipient addresses which were not accepted for delivery. + * + * @return string[] + */ + public function getFailedRecipients() + { + return $this->_failedRecipients; + } + + /** + * Set the result of sending. + * + * @param int $result + */ + public function setResult($result) + { + $this->_result = $result; + } + + /** + * Get the result of this Event. + * + * The return value is a bitmask from + * {@see RESULT_PENDING, RESULT_SUCCESS, RESULT_TENTATIVE, RESULT_FAILED} + * + * @return int + */ + public function getResult() + { + return $this->_result; + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Events/SendListener.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Events/SendListener.php new file mode 100755 index 0000000..bc914f5 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Events/SendListener.php @@ -0,0 +1,33 @@ +_eventMap = array( + 'Swift_Events_CommandEvent' => 'Swift_Events_CommandListener', + 'Swift_Events_ResponseEvent' => 'Swift_Events_ResponseListener', + 'Swift_Events_SendEvent' => 'Swift_Events_SendListener', + 'Swift_Events_TransportChangeEvent' => 'Swift_Events_TransportChangeListener', + 'Swift_Events_TransportExceptionEvent' => 'Swift_Events_TransportExceptionListener' + ); + } + + /** + * Create a new SendEvent for $source and $message. + * + * @param Swift_Transport $source + * @param Swift_Mime_Message + * + * @return Swift_Events_SendEvent + */ + public function createSendEvent(Swift_Transport $source, Swift_Mime_Message $message) + { + return new Swift_Events_SendEvent($source, $message); + } + + /** + * Create a new CommandEvent for $source and $command. + * + * @param Swift_Transport $source + * @param string $command That will be executed + * @param array $successCodes That are needed + * + * @return Swift_Events_CommandEvent + */ + public function createCommandEvent(Swift_Transport $source, $command, $successCodes = array()) + { + return new Swift_Events_CommandEvent($source, $command, $successCodes); + } + + /** + * Create a new ResponseEvent for $source and $response. + * + * @param Swift_Transport $source + * @param string $response + * @param bool $valid If the response is valid + * + * @return Swift_Events_ResponseEvent + */ + public function createResponseEvent(Swift_Transport $source, $response, $valid) + { + return new Swift_Events_ResponseEvent($source, $response, $valid); + } + + /** + * Create a new TransportChangeEvent for $source. + * + * @param Swift_Transport $source + * + * @return Swift_Events_TransportChangeEvent + */ + public function createTransportChangeEvent(Swift_Transport $source) + { + return new Swift_Events_TransportChangeEvent($source); + } + + /** + * Create a new TransportExceptionEvent for $source. + * + * @param Swift_Transport $source + * @param Swift_TransportException $ex + * + * @return Swift_Events_TransportExceptionEvent + */ + public function createTransportExceptionEvent(Swift_Transport $source, Swift_TransportException $ex) + { + return new Swift_Events_TransportExceptionEvent($source, $ex); + } + + /** + * Bind an event listener to this dispatcher. + * + * @param Swift_Events_EventListener $listener + */ + public function bindEventListener(Swift_Events_EventListener $listener) + { + foreach ($this->_listeners as $l) { + // Already loaded + if ($l === $listener) { + return; + } + } + $this->_listeners[] = $listener; + } + + /** + * Dispatch the given Event to all suitable listeners. + * + * @param Swift_Events_EventObject $evt + * @param string $target method + */ + public function dispatchEvent(Swift_Events_EventObject $evt, $target) + { + $this->_prepareBubbleQueue($evt); + $this->_bubble($evt, $target); + } + + // -- Private methods + + /** Queue listeners on a stack ready for $evt to be bubbled up it */ + private function _prepareBubbleQueue(Swift_Events_EventObject $evt) + { + $this->_bubbleQueue = array(); + $evtClass = get_class($evt); + foreach ($this->_listeners as $listener) { + if (array_key_exists($evtClass, $this->_eventMap) + && ($listener instanceof $this->_eventMap[$evtClass])) + { + $this->_bubbleQueue[] = $listener; + } + } + } + + /** Bubble $evt up the stack calling $target() on each listener */ + private function _bubble(Swift_Events_EventObject $evt, $target) + { + if (!$evt->bubbleCancelled() && $listener = array_shift($this->_bubbleQueue)) { + $listener->$target($evt); + $this->_bubble($evt, $target); + } + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Events/TransportChangeEvent.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Events/TransportChangeEvent.php new file mode 100755 index 0000000..d8b5316 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Events/TransportChangeEvent.php @@ -0,0 +1,29 @@ +getSource(); + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Events/TransportChangeListener.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Events/TransportChangeListener.php new file mode 100755 index 0000000..1555037 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Events/TransportChangeListener.php @@ -0,0 +1,47 @@ +_exception = $ex; + } + + /** + * Get the TransportException thrown. + * + * @return Swift_TransportException + */ + public function getException() + { + return $this->_exception; + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Events/TransportExceptionListener.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Events/TransportExceptionListener.php new file mode 100755 index 0000000..709abda --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Events/TransportExceptionListener.php @@ -0,0 +1,26 @@ +createDependenciesFor('transport.failover') + ); + + $this->setTransports($transports); + } + + /** + * Create a new FailoverTransport instance. + * + * @param Swift_Transport[] $transports + * + * @return Swift_FailoverTransport + */ + public static function newInstance($transports = array()) + { + return new self($transports); + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/FileSpool.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/FileSpool.php new file mode 100755 index 0000000..c2f8d7c --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/FileSpool.php @@ -0,0 +1,209 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +/** + * Stores Messages on the filesystem. + * + * @package Swift + * @author Fabien Potencier + * @author Xavier De Cock + */ +class Swift_FileSpool extends Swift_ConfigurableSpool +{ + /** The spool directory */ + private $_path; + + /** + * File WriteRetry Limit + * + * @var int + */ + private $_retryLimit=10; + + /** + * Create a new FileSpool. + * + * @param string $path + * + * @throws Swift_IoException + */ + public function __construct($path) + { + $this->_path = $path; + + if (!file_exists($this->_path)) { + if (!mkdir($this->_path, 0777, true)) { + throw new Swift_IoException('Unable to create Path ['.$this->_path.']'); + } + } + } + + /** + * Tests if this Spool mechanism has started. + * + * @return bool + */ + public function isStarted() + { + return true; + } + + /** + * Starts this Spool mechanism. + */ + public function start() + { + } + + /** + * Stops this Spool mechanism. + */ + public function stop() + { + } + + /** + * Allow to manage the enqueuing retry limit. + * + * Default, is ten and allows over 64^20 different fileNames + * + * @param int $limit + */ + public function setRetryLimit($limit) + { + $this->_retryLimit=$limit; + } + + /** + * Queues a message. + * + * @param Swift_Mime_Message $message The message to store + * + * @return bool + * + * @throws Swift_IoException + */ + public function queueMessage(Swift_Mime_Message $message) + { + $ser = serialize($message); + $fileName = $this->_path . '/' . $this->getRandomString(10); + for ($i = 0; $i < $this->_retryLimit; ++$i) { + /* We try an exclusive creation of the file. This is an atomic operation, it avoid locking mechanism */ + $fp = @fopen($fileName . '.message', 'x'); + if (false !== $fp) { + if (false === fwrite($fp, $ser)) { + return false; + } + + return fclose($fp); + } else { + /* The file already exists, we try a longer fileName */ + $fileName .= $this->getRandomString(1); + } + } + + throw new Swift_IoException('Unable to create a file for enqueuing Message'); + } + + /** + * Execute a recovery if for any reason a process is sending for too long. + * + * @param int $timeout in second Defaults is for very slow smtp responses + */ + public function recover($timeout = 900) + { + foreach (new DirectoryIterator($this->_path) as $file) { + $file = $file->getRealPath(); + + if (substr($file, - 16) == '.message.sending') { + $lockedtime = filectime($file); + if ((time() - $lockedtime) > $timeout) { + rename($file, substr($file, 0, - 8)); + } + } + } + } + + /** + * Sends messages using the given transport instance. + * + * @param Swift_Transport $transport A transport instance + * @param string[] $failedRecipients An array of failures by-reference + * + * @return int The number of sent e-mail's + */ + public function flushQueue(Swift_Transport $transport, &$failedRecipients = null) + { + $directoryIterator = new DirectoryIterator($this->_path); + + /* Start the transport only if there are queued files to send */ + if (!$transport->isStarted()) { + foreach ($directoryIterator as $file) { + if (substr($file->getRealPath(), -8) == '.message') { + $transport->start(); + break; + } + } + } + + $failedRecipients = (array) $failedRecipients; + $count = 0; + $time = time(); + foreach ($directoryIterator as $file) { + $file = $file->getRealPath(); + + if (substr($file, -8) != '.message') { + continue; + } + + /* We try a rename, it's an atomic operation, and avoid locking the file */ + if (rename($file, $file.'.sending')) { + $message = unserialize(file_get_contents($file.'.sending')); + + $count += $transport->send($message, $failedRecipients); + + unlink($file.'.sending'); + } else { + /* This message has just been catched by another process */ + continue; + } + + if ($this->getMessageLimit() && $count >= $this->getMessageLimit()) { + break; + } + + if ($this->getTimeLimit() && (time() - $time) >= $this->getTimeLimit()) { + break; + } + } + + return $count; + } + + /** + * Returns a random string needed to generate a fileName for the queue. + * + * @param int $count + * + * @return string + */ + protected function getRandomString($count) + { + // This string MUST stay FS safe, avoid special chars + $base = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-."; + $ret = ''; + $strlen = strlen($base); + for ($i = 0; $i < $count; ++$i) { + $ret .= $base[((int) rand(0, $strlen - 1))]; + } + + return $ret; + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/FileStream.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/FileStream.php new file mode 100755 index 0000000..567633e --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/FileStream.php @@ -0,0 +1,26 @@ +setFile( + new Swift_ByteStream_FileByteStream($path) + ); + + return $image; + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/InputByteStream.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/InputByteStream.php new file mode 100755 index 0000000..3506aca --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/InputByteStream.php @@ -0,0 +1,77 @@ +_stream = $stream; + } + + /** + * Set a string into the cache under $itemKey for the namespace $nsKey. + * + * @see MODE_WRITE, MODE_APPEND + * + * @param string $nsKey + * @param string $itemKey + * @param string $string + * @param int $mode + */ + public function setString($nsKey, $itemKey, $string, $mode) + { + $this->_prepareCache($nsKey); + switch ($mode) { + case self::MODE_WRITE: + $this->_contents[$nsKey][$itemKey] = $string; + break; + case self::MODE_APPEND: + if (!$this->hasKey($nsKey, $itemKey)) { + $this->_contents[$nsKey][$itemKey] = ''; + } + $this->_contents[$nsKey][$itemKey] .= $string; + break; + default: + throw new Swift_SwiftException( + 'Invalid mode [' . $mode . '] used to set nsKey='. + $nsKey . ', itemKey=' . $itemKey + ); + } + } + + /** + * Set a ByteStream into the cache under $itemKey for the namespace $nsKey. + * + * @see MODE_WRITE, MODE_APPEND + * + * @param string $nsKey + * @param string $itemKey + * @param Swift_OutputByteStream $os + * @param int $mode + */ + public function importFromByteStream($nsKey, $itemKey, Swift_OutputByteStream $os, $mode) + { + $this->_prepareCache($nsKey); + switch ($mode) { + case self::MODE_WRITE: + $this->clearKey($nsKey, $itemKey); + case self::MODE_APPEND: + if (!$this->hasKey($nsKey, $itemKey)) { + $this->_contents[$nsKey][$itemKey] = ''; + } + while (false !== $bytes = $os->read(8192)) { + $this->_contents[$nsKey][$itemKey] .= $bytes; + } + break; + default: + throw new Swift_SwiftException( + 'Invalid mode [' . $mode . '] used to set nsKey='. + $nsKey . ', itemKey=' . $itemKey + ); + } + } + + /** + * Provides a ByteStream which when written to, writes data to $itemKey. + * + * NOTE: The stream will always write in append mode. + * + * @param string $nsKey + * @param string $itemKey + * @param Swift_InputByteStream $writeThrough + * + * @return Swift_InputByteStream + */ + public function getInputByteStream($nsKey, $itemKey, Swift_InputByteStream $writeThrough = null) + { + $is = clone $this->_stream; + $is->setKeyCache($this); + $is->setNsKey($nsKey); + $is->setItemKey($itemKey); + if (isset($writeThrough)) { + $is->setWriteThroughStream($writeThrough); + } + + return $is; + } + + /** + * Get data back out of the cache as a string. + * + * @param string $nsKey + * @param string $itemKey + * + * @return string + */ + public function getString($nsKey, $itemKey) + { + $this->_prepareCache($nsKey); + if ($this->hasKey($nsKey, $itemKey)) { + return $this->_contents[$nsKey][$itemKey]; + } + } + + /** + * Get data back out of the cache as a ByteStream. + * + * @param string $nsKey + * @param string $itemKey + * @param Swift_InputByteStream $is to write the data to + */ + public function exportToByteStream($nsKey, $itemKey, Swift_InputByteStream $is) + { + $this->_prepareCache($nsKey); + $is->write($this->getString($nsKey, $itemKey)); + } + + /** + * Check if the given $itemKey exists in the namespace $nsKey. + * + * @param string $nsKey + * @param string $itemKey + * + * @return bool + */ + public function hasKey($nsKey, $itemKey) + { + $this->_prepareCache($nsKey); + + return array_key_exists($itemKey, $this->_contents[$nsKey]); + } + + /** + * Clear data for $itemKey in the namespace $nsKey if it exists. + * + * @param string $nsKey + * @param string $itemKey + */ + public function clearKey($nsKey, $itemKey) + { + unset($this->_contents[$nsKey][$itemKey]); + } + + /** + * Clear all data in the namespace $nsKey if it exists. + * + * @param string $nsKey + */ + public function clearAll($nsKey) + { + unset($this->_contents[$nsKey]); + } + + // -- Private methods + + /** + * Initialize the namespace of $nsKey if needed. + * + * @param string $nsKey + */ + private function _prepareCache($nsKey) + { + if (!array_key_exists($nsKey, $this->_contents)) { + $this->_contents[$nsKey] = array(); + } + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/KeyCache/DiskKeyCache.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/KeyCache/DiskKeyCache.php new file mode 100755 index 0000000..abd8611 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/KeyCache/DiskKeyCache.php @@ -0,0 +1,328 @@ +_stream = $stream; + $this->_path = $path; + + if (function_exists('get_magic_quotes_runtime') && @get_magic_quotes_runtime() == 1) { + $this->_quotes = true; + } + } + + /** + * Set a string into the cache under $itemKey for the namespace $nsKey. + * + * @see MODE_WRITE, MODE_APPEND + * + * @param string $nsKey + * @param string $itemKey + * @param string $string + * @param int $mode + * + * @throws Swift_IoException + */ + public function setString($nsKey, $itemKey, $string, $mode) + { + $this->_prepareCache($nsKey); + switch ($mode) { + case self::MODE_WRITE: + $fp = $this->_getHandle($nsKey, $itemKey, self::POSITION_START); + break; + case self::MODE_APPEND: + $fp = $this->_getHandle($nsKey, $itemKey, self::POSITION_END); + break; + default: + throw new Swift_SwiftException( + 'Invalid mode [' . $mode . '] used to set nsKey='. + $nsKey . ', itemKey=' . $itemKey + ); + break; + } + fwrite($fp, $string); + $this->_freeHandle($nsKey, $itemKey); + } + + /** + * Set a ByteStream into the cache under $itemKey for the namespace $nsKey. + * + * @see MODE_WRITE, MODE_APPEND + * + * @param string $nsKey + * @param string $itemKey + * @param Swift_OutputByteStream $os + * @param int $mode + * + * @throws Swift_IoException + */ + public function importFromByteStream($nsKey, $itemKey, Swift_OutputByteStream $os, $mode) + { + $this->_prepareCache($nsKey); + switch ($mode) { + case self::MODE_WRITE: + $fp = $this->_getHandle($nsKey, $itemKey, self::POSITION_START); + break; + case self::MODE_APPEND: + $fp = $this->_getHandle($nsKey, $itemKey, self::POSITION_END); + break; + default: + throw new Swift_SwiftException( + 'Invalid mode [' . $mode . '] used to set nsKey='. + $nsKey . ', itemKey=' . $itemKey + ); + break; + } + while (false !== $bytes = $os->read(8192)) { + fwrite($fp, $bytes); + } + $this->_freeHandle($nsKey, $itemKey); + } + + /** + * Provides a ByteStream which when written to, writes data to $itemKey. + * + * NOTE: The stream will always write in append mode. + * + * @param string $nsKey + * @param string $itemKey + * @param Swift_InputByteStream $writeThrough + * + * @return Swift_InputByteStream + */ + public function getInputByteStream($nsKey, $itemKey, Swift_InputByteStream $writeThrough = null) + { + $is = clone $this->_stream; + $is->setKeyCache($this); + $is->setNsKey($nsKey); + $is->setItemKey($itemKey); + if (isset($writeThrough)) { + $is->setWriteThroughStream($writeThrough); + } + + return $is; + } + + /** + * Get data back out of the cache as a string. + * + * @param string $nsKey + * @param string $itemKey + * + * @return string + * + * @throws Swift_IoException + */ + public function getString($nsKey, $itemKey) + { + $this->_prepareCache($nsKey); + if ($this->hasKey($nsKey, $itemKey)) { + $fp = $this->_getHandle($nsKey, $itemKey, self::POSITION_START); + if ($this->_quotes) { + ini_set('magic_quotes_runtime', 0); + } + $str = ''; + while (!feof($fp) && false !== $bytes = fread($fp, 8192)) { + $str .= $bytes; + } + if ($this->_quotes) { + ini_set('magic_quotes_runtime', 1); + } + $this->_freeHandle($nsKey, $itemKey); + + return $str; + } + } + + /** + * Get data back out of the cache as a ByteStream. + * + * @param string $nsKey + * @param string $itemKey + * @param Swift_InputByteStream $is to write the data to + */ + public function exportToByteStream($nsKey, $itemKey, Swift_InputByteStream $is) + { + if ($this->hasKey($nsKey, $itemKey)) { + $fp = $this->_getHandle($nsKey, $itemKey, self::POSITION_START); + if ($this->_quotes) { + ini_set('magic_quotes_runtime', 0); + } + while (!feof($fp) && false !== $bytes = fread($fp, 8192)) { + $is->write($bytes); + } + if ($this->_quotes) { + ini_set('magic_quotes_runtime', 1); + } + $this->_freeHandle($nsKey, $itemKey); + } + } + + /** + * Check if the given $itemKey exists in the namespace $nsKey. + * + * @param string $nsKey + * @param string $itemKey + * + * @return bool + */ + public function hasKey($nsKey, $itemKey) + { + return is_file($this->_path . '/' . $nsKey . '/' . $itemKey); + } + + /** + * Clear data for $itemKey in the namespace $nsKey if it exists. + * + * @param string $nsKey + * @param string $itemKey + */ + public function clearKey($nsKey, $itemKey) + { + if ($this->hasKey($nsKey, $itemKey)) { + $this->_freeHandle($nsKey, $itemKey); + unlink($this->_path . '/' . $nsKey . '/' . $itemKey); + } + } + + /** + * Clear all data in the namespace $nsKey if it exists. + * + * @param string $nsKey + */ + public function clearAll($nsKey) + { + if (array_key_exists($nsKey, $this->_keys)) { + foreach ($this->_keys[$nsKey] as $itemKey=>$null) { + $this->clearKey($nsKey, $itemKey); + } + if (is_dir($this->_path . '/' . $nsKey)) { + rmdir($this->_path . '/' . $nsKey); + } + unset($this->_keys[$nsKey]); + } + } + + // -- Private methods + + /** + * Initialize the namespace of $nsKey if needed. + * + * @param string $nsKey + */ + private function _prepareCache($nsKey) + { + $cacheDir = $this->_path . '/' . $nsKey; + if (!is_dir($cacheDir)) { + if (!mkdir($cacheDir)) { + throw new Swift_IoException('Failed to create cache directory ' . $cacheDir); + } + $this->_keys[$nsKey] = array(); + } + } + + /** + * Get a file handle on the cache item. + * + * @param string $nsKey + * @param string $itemKey + * @param int $position + * + * @return resource + */ + private function _getHandle($nsKey, $itemKey, $position) + { + if (!isset($this->_keys[$nsKey][$itemKey])) { + $openMode = $this->hasKey($nsKey, $itemKey) + ? 'r+b' + : 'w+b' + ; + $fp = fopen($this->_path . '/' . $nsKey . '/' . $itemKey, $openMode); + $this->_keys[$nsKey][$itemKey] = $fp; + } + if (self::POSITION_START == $position) { + fseek($this->_keys[$nsKey][$itemKey], 0, SEEK_SET); + } elseif (self::POSITION_END == $position) { + fseek($this->_keys[$nsKey][$itemKey], 0, SEEK_END); + } + + return $this->_keys[$nsKey][$itemKey]; + } + + private function _freeHandle($nsKey, $itemKey) + { + $fp = $this->_getHandle($nsKey, $itemKey, self::POSITION_CURRENT); + fclose($fp); + $this->_keys[$nsKey][$itemKey] = null; + } + + /** + * Destructor. + */ + public function __destruct() + { + foreach ($this->_keys as $nsKey=>$null) { + $this->clearAll($nsKey); + } + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/KeyCache/KeyCacheInputStream.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/KeyCache/KeyCacheInputStream.php new file mode 100755 index 0000000..f4f8adb --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/KeyCache/KeyCacheInputStream.php @@ -0,0 +1,53 @@ +_keyCache = $keyCache; + } + + /** + * Specify a stream to write through for each write(). + * + * @param Swift_InputByteStream $is + */ + public function setWriteThroughStream(Swift_InputByteStream $is) + { + $this->_writeThrough = $is; + } + + /** + * Writes $bytes to the end of the stream. + * + * @param string $bytes + * @param Swift_InputByteStream $is optional + */ + public function write($bytes, Swift_InputByteStream $is = null) + { + $this->_keyCache->setString( + $this->_nsKey, $this->_itemKey, $bytes, Swift_KeyCache::MODE_APPEND + ); + if (isset($is)) { + $is->write($bytes); + } + if (isset($this->_writeThrough)) { + $this->_writeThrough->write($bytes); + } + } + + /** + * Not used. + */ + public function commit() + { + } + + /** + * Not used. + */ + public function bind(Swift_InputByteStream $is) + { + } + + /** + * Not used. + */ + public function unbind(Swift_InputByteStream $is) + { + } + + /** + * Flush the contents of the stream (empty it) and set the internal pointer + * to the beginning. + */ + public function flushBuffers() + { + $this->_keyCache->clearKey($this->_nsKey, $this->_itemKey); + } + + /** + * Set the nsKey which will be written to. + * + * @param string $nsKey + */ + public function setNsKey($nsKey) + { + $this->_nsKey = $nsKey; + } + + /** + * Set the itemKey which will be written to. + * + * @param string $itemKey + */ + public function setItemKey($itemKey) + { + $this->_itemKey = $itemKey; + } + + /** + * Any implementation should be cloneable, allowing the clone to access a + * separate $nsKey and $itemKey. + */ + public function __clone() + { + $this->_writeThrough = null; + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/LoadBalancedTransport.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/LoadBalancedTransport.php new file mode 100755 index 0000000..6eb3db7 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/LoadBalancedTransport.php @@ -0,0 +1,47 @@ +createDependenciesFor('transport.loadbalanced') + ); + + $this->setTransports($transports); + } + + /** + * Create a new LoadBalancedTransport instance. + * + * @param array $transports + * + * @return Swift_LoadBalancedTransport + */ + public static function newInstance($transports = array()) + { + return new self($transports); + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/MailTransport.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/MailTransport.php new file mode 100755 index 0000000..6c57939 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/MailTransport.php @@ -0,0 +1,47 @@ +createDependenciesFor('transport.mail') + ); + + $this->setExtraParams($extraParams); + } + + /** + * Create a new MailTransport instance. + * + * @param string $extraParams To be passed to mail() + * + * @return Swift_MailTransport + */ + public static function newInstance($extraParams = '-f%s') + { + return new self($extraParams); + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mailer.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mailer.php new file mode 100755 index 0000000..f4e0512 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mailer.php @@ -0,0 +1,115 @@ +_transport = $transport; + } + + /** + * Create a new Mailer instance. + * + * @param Swift_Transport $transport + * + * @return Swift_Mailer + */ + public static function newInstance(Swift_Transport $transport) + { + return new self($transport); + } + + /** + * Create a new class instance of one of the message services. + * + * For example 'mimepart' would create a 'message.mimepart' instance + * + * @param string $service + * + * @return object + */ + public function createMessage($service = 'message') + { + return Swift_DependencyContainer::getInstance() + ->lookup('message.'.$service); + } + + /** + * Send the given Message like it would be sent in a mail client. + * + * All recipients (with the exception of Bcc) will be able to see the other + * recipients this message was sent to. + * + * Recipient/sender data will be retrieved from the Message object. + * + * The return value is the number of recipients who were accepted for + * delivery. + * + * @param Swift_Mime_Message $message + * @param array $failedRecipients An array of failures by-reference + * + * @return int + */ + public function send(Swift_Mime_Message $message, &$failedRecipients = null) + { + $failedRecipients = (array) $failedRecipients; + + if (!$this->_transport->isStarted()) { + $this->_transport->start(); + } + + $sent = 0; + + try { + $sent = $this->_transport->send($message, $failedRecipients); + } catch (Swift_RfcComplianceException $e) { + foreach ($message->getTo() as $address => $name) { + $failedRecipients[] = $address; + } + } + + return $sent; + } + + /** + * Register a plugin using a known unique key (e.g. myPlugin). + * + * @param Swift_Events_EventListener $plugin + */ + public function registerPlugin(Swift_Events_EventListener $plugin) + { + $this->_transport->registerPlugin($plugin); + } + + /** + * The Transport used to send messages. + * + * @return Swift_Transport + */ + public function getTransport() + { + return $this->_transport; + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mailer/ArrayRecipientIterator.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mailer/ArrayRecipientIterator.php new file mode 100755 index 0000000..1dd3241 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mailer/ArrayRecipientIterator.php @@ -0,0 +1,57 @@ +_recipients = $recipients; + } + + /** + * Returns true only if there are more recipients to send to. + * + * @return bool + */ + public function hasNext() + { + return !empty($this->_recipients); + } + + /** + * Returns an array where the keys are the addresses of recipients and the + * values are the names. e.g. ('foo@bar' => 'Foo') or ('foo@bar' => NULL) + * + * @return array + */ + public function nextRecipient() + { + return array_splice($this->_recipients, 0, 1); + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mailer/RecipientIterator.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mailer/RecipientIterator.php new file mode 100755 index 0000000..8f109fa --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mailer/RecipientIterator.php @@ -0,0 +1,34 @@ + 'Foo') or ('foo@bar' => NULL) + * + * @return array + */ + public function nextRecipient(); +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/MemorySpool.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/MemorySpool.php new file mode 100755 index 0000000..6e042cd --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/MemorySpool.php @@ -0,0 +1,84 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +/** + * Stores Messages in memory. + * + * @package Swift + * @author Fabien Potencier + */ +class Swift_MemorySpool implements Swift_Spool +{ + protected $messages = array(); + + /** + * Tests if this Transport mechanism has started. + * + * @return bool + */ + public function isStarted() + { + return true; + } + + /** + * Starts this Transport mechanism. + */ + public function start() + { + } + + /** + * Stops this Transport mechanism. + */ + public function stop() + { + } + + /** + * Stores a message in the queue. + * + * @param Swift_Mime_Message $message The message to store + * + * @return bool Whether the operation has succeeded + */ + public function queueMessage(Swift_Mime_Message $message) + { + $this->messages[] = $message; + + return true; + } + + /** + * Sends messages using the given transport instance. + * + * @param Swift_Transport $transport A transport instance + * @param string[] $failedRecipients An array of failures by-reference + * + * @return int The number of sent emails + */ + public function flushQueue(Swift_Transport $transport, &$failedRecipients = null) + { + if (!$this->messages) { + return 0; + } + + if (!$transport->isStarted()) { + $transport->start(); + } + + $count = 0; + while ($message = array_pop($this->messages)) { + $count += $transport->send($message, $failedRecipients); + } + + return $count; + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Message.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Message.php new file mode 100755 index 0000000..a5aac9e --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Message.php @@ -0,0 +1,273 @@ +createDependenciesFor('mime.message') + ); + + if (!isset($charset)) { + $charset = Swift_DependencyContainer::getInstance() + ->lookup('properties.charset'); + } + $this->setSubject($subject); + $this->setBody($body); + $this->setCharset($charset); + if ($contentType) { + $this->setContentType($contentType); + } + } + + /** + * Create a new Message. + * + * @param string $subject + * @param string $body + * @param string $contentType + * @param string $charset + * + * @return Swift_Message + */ + public static function newInstance($subject = null, $body = null, $contentType = null, $charset = null) + { + return new self($subject, $body, $contentType, $charset); + } + + /** + * Add a MimePart to this Message. + * + * @param string|Swift_OutputByteStream $body + * @param string $contentType + * @param string $charset + * + * @return Swift_Mime_SimpleMessage + */ + public function addPart($body, $contentType = null, $charset = null) + { + return $this->attach(Swift_MimePart::newInstance( + $body, $contentType, $charset + )); + } + + /** + * Attach a new signature handler to the message. + * + * @param Swift_Signer $signer + * @return Swift_Message + */ + public function attachSigner(Swift_Signer $signer) + { + if ($signer instanceof Swift_Signers_HeaderSigner) { + $this->headerSigners[] = $signer; + } elseif ($signer instanceof Swift_Signers_BodySigner) { + $this->bodySigners[] = $signer; + } + + return $this; + } + + /** + * Attach a new signature handler to the message. + * + * @param Swift_Signer $signer + * @return Swift_Message + */ + public function detachSigner(Swift_Signer $signer) + { + if ($signer instanceof Swift_Signers_HeaderSigner) { + foreach ($this->headerSigners as $k => $headerSigner) { + if ($headerSigner === $signer) { + unset($this->headerSigners[$k]); + return $this; + } + } + } elseif ($signer instanceof Swift_Signers_BodySigner) { + foreach ($this->bodySigners as $k => $bodySigner) { + if ($bodySigner === $signer) { + unset($this->bodySigners[$k]); + return $this; + } + } + } + + return $this; + } + + /** + * Get this message as a complete string. + * + * @return string + */ + public function toString() + { + if (empty($this->headerSigners) && empty($this->bodySigners)) { + return parent::toString(); + } + + $this->saveMessage(); + + $this->doSign(); + + $string = parent::toString(); + + $this->restoreMessage(); + + return $string; + } + + /** + * Write this message to a {@link Swift_InputByteStream}. + * + * @param Swift_InputByteStream $is + */ + public function toByteStream(Swift_InputByteStream $is) + { + if (empty($this->headerSigners) && empty($this->bodySigners)) { + parent::toByteStream($is); + return; + } + + $this->saveMessage(); + + $this->doSign(); + + parent::toByteStream($is); + + $this->restoreMessage(); + + } + + public function __wakeup() + { + Swift_DependencyContainer::getInstance()->createDependenciesFor('mime.message'); + } + + /* -- Protected Methods -- */ + + /** + * loops through signers and apply the signatures + */ + protected function doSign() + { + foreach ($this->bodySigners as $signer) { + $altered = $signer->getAlteredHeaders(); + $this->saveHeaders($altered); + $signer->signMessage($this); + } + + foreach ($this->headerSigners as $signer) { + $altered = $signer->getAlteredHeaders(); + $this->saveHeaders($altered); + $signer->reset(); + + $signer->setHeaders($this->getHeaders()); + + $signer->startBody(); + $this->_bodyToByteStream($signer); + $signer->endBody(); + + $signer->addSignature($this->getHeaders()); + } + } + + /** + * save the message before any signature is applied + */ + protected function saveMessage() + { + $this->savedMessage = array('headers'=> array()); + $this->savedMessage['body'] = $this->getBody(); + $this->savedMessage['children'] = $this->getChildren(); + if (count($this->savedMessage['children']) > 0 && $this->getBody() != '') { + $this->setChildren(array_merge(array($this->_becomeMimePart()), $this->savedMessage['children'])); + $this->setBody(''); + } + } + + /** + * save the original headers + * @param array $altered + */ + protected function saveHeaders(array $altered) + { + foreach ($altered as $head) { + $lc = strtolower($head); + + if (!isset($this->savedMessage['headers'][$lc])) { + $this->savedMessage['headers'][$lc] = $this->getHeaders()->getAll($head); + } + } + } + + /** + * Remove or restore altered headers + */ + protected function restoreHeaders() + { + foreach ($this->savedMessage['headers'] as $name => $savedValue) { + $headers = $this->getHeaders()->getAll($name); + + foreach ($headers as $key => $value) { + if (!isset($savedValue[$key])) { + $this->getHeaders()->remove($name, $key); + } + } + } + } + + /** + * Restore message body + */ + protected function restoreMessage() + { + $this->setBody($this->savedMessage['body']); + $this->setChildren($this->savedMessage['children']); + + $this->restoreHeaders(); + $this->savedMessage = array(); + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Attachment.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Attachment.php new file mode 100755 index 0000000..108a02a --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Attachment.php @@ -0,0 +1,155 @@ +setDisposition('attachment'); + $this->setContentType('application/octet-stream'); + $this->_mimeTypes = $mimeTypes; + } + + /** + * Get the nesting level used for this attachment. + * + * Always returns {@link LEVEL_MIXED}. + * + * @return int + */ + public function getNestingLevel() + { + return self::LEVEL_MIXED; + } + + /** + * Get the Content-Disposition of this attachment. + * + * By default attachments have a disposition of "attachment". + * + * @return string + */ + public function getDisposition() + { + return $this->_getHeaderFieldModel('Content-Disposition'); + } + + /** + * Set the Content-Disposition of this attachment. + * + * @param string $disposition + * + * @return Swift_Mime_Attachment + */ + public function setDisposition($disposition) + { + if (!$this->_setHeaderFieldModel('Content-Disposition', $disposition)) { + $this->getHeaders()->addParameterizedHeader( + 'Content-Disposition', $disposition + ); + } + + return $this; + } + + /** + * Get the filename of this attachment when downloaded. + * + * @return string + */ + public function getFilename() + { + return $this->_getHeaderParameter('Content-Disposition', 'filename'); + } + + /** + * Set the filename of this attachment. + * + * @param string $filename + * + * @return Swift_Mime_Attachment + */ + public function setFilename($filename) + { + $this->_setHeaderParameter('Content-Disposition', 'filename', $filename); + $this->_setHeaderParameter('Content-Type', 'name', $filename); + + return $this; + } + + /** + * Get the file size of this attachment. + * + * @return int + */ + public function getSize() + { + return $this->_getHeaderParameter('Content-Disposition', 'size'); + } + + /** + * Set the file size of this attachment. + * + * @param int $size + * + * @return Swift_Mime_Attachment + */ + public function setSize($size) + { + $this->_setHeaderParameter('Content-Disposition', 'size', $size); + + return $this; + } + + /** + * Set the file that this attachment is for. + * + * @param Swift_FileStream $file + * @param string $contentType optional + * + * @return Swift_Mime_Attachment + */ + public function setFile(Swift_FileStream $file, $contentType = null) + { + $this->setFilename(basename($file->getPath())); + $this->setBody($file, $contentType); + if (!isset($contentType)) { + $extension = strtolower(substr( + $file->getPath(), strrpos($file->getPath(), '.') + 1 + )); + + if (array_key_exists($extension, $this->_mimeTypes)) { + $this->setContentType($this->_mimeTypes[$extension]); + } + } + + return $this; + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/CharsetObserver.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/CharsetObserver.php new file mode 100755 index 0000000..bfd41ed --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/CharsetObserver.php @@ -0,0 +1,26 @@ += $maxLineLength || 76 < $maxLineLength) { + $maxLineLength = 76; + } + + $remainder = 0; + + while (false !== $bytes = $os->read(8190)) { + $encoded = base64_encode($bytes); + $encodedTransformed = ''; + $thisMaxLineLength = $maxLineLength - $remainder - $firstLineOffset; + + while ($thisMaxLineLength < strlen($encoded)) { + $encodedTransformed .= substr($encoded, 0, $thisMaxLineLength) . "\r\n"; + $firstLineOffset = 0; + $encoded = substr($encoded, $thisMaxLineLength); + $thisMaxLineLength = $maxLineLength; + $remainder = 0; + } + + if (0 < $remainingLength = strlen($encoded)) { + $remainder += $remainingLength; + $encodedTransformed .= $encoded; + $encoded = null; + } + + $is->write($encodedTransformed); + } + } + + /** + * Get the name of this encoding scheme. + * Returns the string 'base64'. + * + * @return string + */ + public function getName() + { + return 'base64'; + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/NativeQpContentEncoder.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/NativeQpContentEncoder.php new file mode 100755 index 0000000..ce7c31e --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/NativeQpContentEncoder.php @@ -0,0 +1,125 @@ +charset = $charset ? $charset : 'utf-8'; + } + + /** + * Notify this observer that the entity's charset has changed. + * + * @param string $charset + */ + public function charsetChanged($charset) + { + $this->charset = $charset; + } + + /** + * Encode $in to $out. + * + * @param Swift_OutputByteStream $os to read from + * @param Swift_InputByteStream $is to write to + * @param int $firstLineOffset + * @param int $maxLineLength 0 indicates the default length for this encoding + * + * @throws RuntimeException + */ + public function encodeByteStream(Swift_OutputByteStream $os, Swift_InputByteStream $is, $firstLineOffset = 0, $maxLineLength = 0) + { + if ($this->charset !== 'utf-8') { + throw new RuntimeException( + sprintf('Charset "%s" not supported. NativeQpContentEncoder only supports "utf-8"', $this->charset)); + } + + $string = ''; + + while (false !== $bytes = $os->read(8192)) { + $string .= $bytes; + } + + $is->write($this->encodeString($string)); + } + + /** + * Get the MIME name of this content encoding scheme. + * + * @return string + */ + public function getName() + { + return 'quoted-printable'; + } + + /** + * Encode a given string to produce an encoded string. + * + * @param string $string + * @param int $firstLineOffset if first line needs to be shorter + * @param int $maxLineLength 0 indicates the default length for this encoding + * + * @return string + * + * @throws RuntimeException + */ + public function encodeString($string, $firstLineOffset = 0, $maxLineLength = 0) + { + if ($this->charset !== 'utf-8') { + throw new RuntimeException( + sprintf('Charset "%s" not supported. NativeQpContentEncoder only supports "utf-8"', $this->charset)); + } + + return $this->_standardize(quoted_printable_encode($string)); + } + + /** + * Make sure CRLF is correct and HT/SPACE are in valid places. + * + * @param string $string + * + * @return string + */ + protected function _standardize($string) + { + // transform CR or LF to CRLF + $string = preg_replace('~=0D(?!=0A)|(?_name = $name; + $this->_canonical = $canonical; + } + + /** + * Encode a given string to produce an encoded string. + * + * @param string $string + * @param int $firstLineOffset ignored + * @param int $maxLineLength - 0 means no wrapping will occur + * + * @return string + */ + public function encodeString($string, $firstLineOffset = 0, $maxLineLength = 0) + { + if ($this->_canonical) { + $string = $this->_canonicalize($string); + } + + return $this->_safeWordWrap($string, $maxLineLength, "\r\n"); + } + + /** + * Encode stream $in to stream $out. + * + * @param Swift_OutputByteStream $os + * @param Swift_InputByteStream $is + * @param int $firstLineOffset ignored + * @param int $maxLineLength optional, 0 means no wrapping will occur + */ + public function encodeByteStream(Swift_OutputByteStream $os, Swift_InputByteStream $is, $firstLineOffset = 0, $maxLineLength = 0) + { + $leftOver = ''; + while (false !== $bytes = $os->read(8192)) { + $toencode = $leftOver . $bytes; + if ($this->_canonical) { + $toencode = $this->_canonicalize($toencode); + } + $wrapped = $this->_safeWordWrap($toencode, $maxLineLength, "\r\n"); + $lastLinePos = strrpos($wrapped, "\r\n"); + $leftOver = substr($wrapped, $lastLinePos); + $wrapped = substr($wrapped, 0, $lastLinePos); + + $is->write($wrapped); + } + if (strlen($leftOver)) { + $is->write($leftOver); + } + } + + /** + * Get the name of this encoding scheme. + * + * @return string + */ + public function getName() + { + return $this->_name; + } + + /** + * Not used. + */ + public function charsetChanged($charset) + { + } + + // -- Private methods + + /** + * A safer (but weaker) wordwrap for unicode. + * + * @param string $string + * @param int $length + * @param string $le + * + * @return string + */ + private function _safeWordwrap($string, $length = 75, $le = "\r\n") + { + if (0 >= $length) { + return $string; + } + + $originalLines = explode($le, $string); + + $lines = array(); + $lineCount = 0; + + foreach ($originalLines as $originalLine) { + $lines[] = ''; + $currentLine =& $lines[$lineCount++]; + + //$chunks = preg_split('/(?<=[\ \t,\.!\?\-&\+\/])/', $originalLine); + $chunks = preg_split('/(?<=\s)/', $originalLine); + + foreach ($chunks as $chunk) { + if (0 != strlen($currentLine) + && strlen($currentLine . $chunk) > $length) + { + $lines[] = ''; + $currentLine =& $lines[$lineCount++]; + } + $currentLine .= $chunk; + } + } + + return implode("\r\n", $lines); + } + + /** + * Canonicalize string input (fix CRLF). + * + * @param string $string + * + * @return string + */ + private function _canonicalize($string) + { + return str_replace( + array("\r\n", "\r", "\n"), + array("\n", "\n", "\r\n"), + $string + ); + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/QpContentEncoder.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/QpContentEncoder.php new file mode 100755 index 0000000..6df4a5f --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/QpContentEncoder.php @@ -0,0 +1,125 @@ +_dotEscape = $dotEscape; + parent::__construct($charStream, $filter); + } + + public function __sleep() + { + return array('_charStream', '_filter', '_dotEscape'); + } + + protected function getSafeMapShareId() + { + return get_class($this).($this->_dotEscape ? '.dotEscape' : ''); + } + + protected function initSafeMap() + { + parent::initSafeMap(); + if ($this->_dotEscape) { + /* Encode . as =2e for buggy remote servers */ + unset($this->_safeMap[0x2e]); + } + } + + /** + * Encode stream $in to stream $out. + * + * QP encoded strings have a maximum line length of 76 characters. + * If the first line needs to be shorter, indicate the difference with + * $firstLineOffset. + * + * @param Swift_OutputByteStream $os output stream + * @param Swift_InputByteStream $is input stream + * @param int $firstLineOffset + * @param int $maxLineLength + */ + public function encodeByteStream(Swift_OutputByteStream $os, Swift_InputByteStream $is, $firstLineOffset = 0, $maxLineLength = 0) + { + if ($maxLineLength > 76 || $maxLineLength <= 0) { + $maxLineLength = 76; + } + + $thisLineLength = $maxLineLength - $firstLineOffset; + + $this->_charStream->flushContents(); + $this->_charStream->importByteStream($os); + + $currentLine = ''; + $prepend = ''; + $size=$lineLen=0; + + while (false !== $bytes = $this->_nextSequence()) { + // If we're filtering the input + if (isset($this->_filter)) { + // If we can't filter because we need more bytes + while ($this->_filter->shouldBuffer($bytes)) { + // Then collect bytes into the buffer + if (false === $moreBytes = $this->_nextSequence(1)) { + break; + } + + foreach ($moreBytes as $b) { + $bytes[] = $b; + } + } + // And filter them + $bytes = $this->_filter->filter($bytes); + } + + $enc = $this->_encodeByteSequence($bytes, $size); + if ($currentLine && $lineLen+$size >= $thisLineLength) { + $is->write($prepend . $this->_standardize($currentLine)); + $currentLine = ''; + $prepend = "=\r\n"; + $thisLineLength = $maxLineLength; + $lineLen=0; + } + $lineLen+=$size; + $currentLine .= $enc; + } + if (strlen($currentLine)) { + $is->write($prepend . $this->_standardize($currentLine)); + } + } + + /** + * Get the name of this encoding scheme. + * Returns the string 'quoted-printable'. + * + * @return string + */ + public function getName() + { + return 'quoted-printable'; + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/QpContentEncoderProxy.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/QpContentEncoderProxy.php new file mode 100755 index 0000000..491409a --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/QpContentEncoderProxy.php @@ -0,0 +1,90 @@ + + */ +class Swift_Mime_ContentEncoder_QpContentEncoderProxy implements Swift_Mime_ContentEncoder +{ + /** + * @var Swift_Mime_ContentEncoder_QpContentEncoder + */ + private $safeEncoder; + + /** + * @var Swift_Mime_ContentEncoder_NativeQpContentEncoder + */ + private $nativeEncoder; + + /** + * @var null|string + */ + private $charset; + + /** + * Constructor. + * + * @param Swift_Mime_ContentEncoder_QpContentEncoder $safeEncoder + * @param Swift_Mime_ContentEncoder_NativeQpContentEncoder $nativeEncoder + * @param string|null $charset + */ + public function __construct(Swift_Mime_ContentEncoder_QpContentEncoder $safeEncoder, Swift_Mime_ContentEncoder_NativeQpContentEncoder $nativeEncoder, $charset) + { + $this->safeEncoder = $safeEncoder; + $this->nativeEncoder = $nativeEncoder; + $this->charset = $charset; + } + + /** + * {@inheritdoc} + */ + public function charsetChanged($charset) + { + $this->charset = $charset; + } + + /** + * {@inheritdoc} + */ + public function encodeByteStream(Swift_OutputByteStream $os, Swift_InputByteStream $is, $firstLineOffset = 0, $maxLineLength = 0) + { + $this->getEncoder()->encodeByteStream($os, $is, $firstLineOffset, $maxLineLength); + } + + /** + * {@inheritdoc} + */ + public function getName() + { + return 'quoted-printable'; + } + + /** + * {@inheritdoc} + */ + public function encodeString($string, $firstLineOffset = 0, $maxLineLength = 0) + { + return $this->getEncoder()->encodeString($string, $firstLineOffset, $maxLineLength); + } + + /** + * @return Swift_Mime_ContentEncoder + */ + private function getEncoder() + { + return 'utf-8' === $this->charset ? $this->nativeEncoder : $this->safeEncoder; + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/RawContentEncoder.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/RawContentEncoder.php new file mode 100755 index 0000000..8f1f9b5 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/ContentEncoder/RawContentEncoder.php @@ -0,0 +1,65 @@ + + */ +class Swift_Mime_ContentEncoder_RawContentEncoder implements Swift_Mime_ContentEncoder +{ + /** + * Encode a given string to produce an encoded string. + * + * @param string $string + * @param int $firstLineOffset ignored + * @param int $maxLineLength ignored + * @return string + */ + public function encodeString($string, $firstLineOffset = 0, $maxLineLength = 0) + { + return $string; + } + + /** + * Encode stream $in to stream $out. + * + * @param Swift_OutputByteStream $in + * @param Swift_InputByteStream $out + * @param int $firstLineOffset ignored + * @param int $maxLineLength ignored + */ + public function encodeByteStream(Swift_OutputByteStream $os, Swift_InputByteStream $is, $firstLineOffset = 0, $maxLineLength = 0) + { + while (false !== ($bytes = $os->read(8192))) { + $is->write($bytes); + } + } + + /** + * Get the name of this encoding scheme. + * + * @return string + */ + public function getName() + { + return 'raw'; + } + + /** + * Not used. + */ + public function charsetChanged($charset) + { + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/EmbeddedFile.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/EmbeddedFile.php new file mode 100755 index 0000000..9079fab --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/EmbeddedFile.php @@ -0,0 +1,47 @@ +setDisposition('inline'); + $this->setId($this->getId()); + } + + /** + * Get the nesting level of this EmbeddedFile. + * + * Returns {@see LEVEL_RELATED}. + * + * @return int + */ + public function getNestingLevel() + { + return self::LEVEL_RELATED; + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/EncodingObserver.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/EncodingObserver.php new file mode 100755 index 0000000..e7e6f20 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/EncodingObserver.php @@ -0,0 +1,26 @@ +init(); + } + + public function __wakeup() + { + $this->init(); + } + + protected function init() + { + if (count(self::$_specials) > 0) { + return; + } + + self::$_specials = array( + '(', ')', '<', '>', '[', ']', + ':', ';', '@', ',', '.', '"' + ); + + /*** Refer to RFC 2822 for ABNF grammar ***/ + + // All basic building blocks + self::$_grammar['NO-WS-CTL'] = '[\x01-\x08\x0B\x0C\x0E-\x19\x7F]'; + self::$_grammar['WSP'] = '[ \t]'; + self::$_grammar['CRLF'] = '(?:\r\n)'; + self::$_grammar['FWS'] = '(?:(?:' . self::$_grammar['WSP'] . '*' . + self::$_grammar['CRLF'] . ')?' . self::$_grammar['WSP'] . ')'; + self::$_grammar['text'] = '[\x00-\x08\x0B\x0C\x0E-\x7F]'; + self::$_grammar['quoted-pair'] = '(?:\\\\' . self::$_grammar['text'] . ')'; + self::$_grammar['ctext'] = '(?:' . self::$_grammar['NO-WS-CTL'] . + '|[\x21-\x27\x2A-\x5B\x5D-\x7E])'; + // Uses recursive PCRE (?1) -- could be a weak point?? + self::$_grammar['ccontent'] = '(?:' . self::$_grammar['ctext'] . '|' . + self::$_grammar['quoted-pair'] . '|(?1))'; + self::$_grammar['comment'] = '(\((?:' . self::$_grammar['FWS'] . '|' . + self::$_grammar['ccontent']. ')*' . self::$_grammar['FWS'] . '?\))'; + self::$_grammar['CFWS'] = '(?:(?:' . self::$_grammar['FWS'] . '?' . + self::$_grammar['comment'] . ')*(?:(?:' . self::$_grammar['FWS'] . '?' . + self::$_grammar['comment'] . ')|' . self::$_grammar['FWS'] . '))'; + self::$_grammar['qtext'] = '(?:' . self::$_grammar['NO-WS-CTL'] . + '|[\x21\x23-\x5B\x5D-\x7E])'; + self::$_grammar['qcontent'] = '(?:' . self::$_grammar['qtext'] . '|' . + self::$_grammar['quoted-pair'] . ')'; + self::$_grammar['quoted-string'] = '(?:' . self::$_grammar['CFWS'] . '?"' . + '(' . self::$_grammar['FWS'] . '?' . self::$_grammar['qcontent'] . ')*' . + self::$_grammar['FWS'] . '?"' . self::$_grammar['CFWS'] . '?)'; + self::$_grammar['atext'] = '[a-zA-Z0-9!#\$%&\'\*\+\-\/=\?\^_`\{\}\|~]'; + self::$_grammar['atom'] = '(?:' . self::$_grammar['CFWS'] . '?' . + self::$_grammar['atext'] . '+' . self::$_grammar['CFWS'] . '?)'; + self::$_grammar['dot-atom-text'] = '(?:' . self::$_grammar['atext'] . '+' . + '(\.' . self::$_grammar['atext'] . '+)*)'; + self::$_grammar['dot-atom'] = '(?:' . self::$_grammar['CFWS'] . '?' . + self::$_grammar['dot-atom-text'] . '+' . self::$_grammar['CFWS'] . '?)'; + self::$_grammar['word'] = '(?:' . self::$_grammar['atom'] . '|' . + self::$_grammar['quoted-string'] . ')'; + self::$_grammar['phrase'] = '(?:' . self::$_grammar['word'] . '+?)'; + self::$_grammar['no-fold-quote'] = '(?:"(?:' . self::$_grammar['qtext'] . + '|' . self::$_grammar['quoted-pair'] . ')*")'; + self::$_grammar['dtext'] = '(?:' . self::$_grammar['NO-WS-CTL'] . + '|[\x21-\x5A\x5E-\x7E])'; + self::$_grammar['no-fold-literal'] = '(?:\[(?:' . self::$_grammar['dtext'] . + '|' . self::$_grammar['quoted-pair'] . ')*\])'; + + // Message IDs + self::$_grammar['id-left'] = '(?:' . self::$_grammar['dot-atom-text'] . '|' . + self::$_grammar['no-fold-quote'] . ')'; + self::$_grammar['id-right'] = '(?:' . self::$_grammar['dot-atom-text'] . '|' . + self::$_grammar['no-fold-literal'] . ')'; + + // Addresses, mailboxes and paths + self::$_grammar['local-part'] = '(?:' . self::$_grammar['dot-atom'] . '|' . + self::$_grammar['quoted-string'] . ')'; + self::$_grammar['dcontent'] = '(?:' . self::$_grammar['dtext'] . '|' . + self::$_grammar['quoted-pair'] . ')'; + self::$_grammar['domain-literal'] = '(?:' . self::$_grammar['CFWS'] . '?\[(' . + self::$_grammar['FWS'] . '?' . self::$_grammar['dcontent'] . ')*?' . + self::$_grammar['FWS'] . '?\]' . self::$_grammar['CFWS'] . '?)'; + self::$_grammar['domain'] = '(?:' . self::$_grammar['dot-atom'] . '|' . + self::$_grammar['domain-literal'] . ')'; + self::$_grammar['addr-spec'] = '(?:' . self::$_grammar['local-part'] . '@' . + self::$_grammar['domain'] . ')'; + } + + /** + * Get the grammar defined for $name token. + * + * @param string $name exactly as written in the RFC + * + * @return string + */ + public function getDefinition($name) + { + if (array_key_exists($name, self::$_grammar)) { + return self::$_grammar[$name]; + } else { + throw new Swift_RfcComplianceException( + "No such grammar '" . $name . "' defined." + ); + } + } + + /** + * Returns the tokens defined in RFC 2822 (and some related RFCs). + * + * @return array + */ + public function getGrammarDefinitions() + { + return self::$_grammar; + } + + /** + * Returns the current special characters used in the syntax which need to be escaped. + * + * @return array + */ + public function getSpecials() + { + return self::$_specials; + } + + /** + * Escape special characters in a string (convert to quoted-pairs). + * + * @param string $token + * @param string[] $include additional chars to escape + * @param string[] $exclude chars from escaping + * + * @return string + */ + public function escapeSpecials($token, $include = array(), $exclude = array()) + { + foreach (array_merge(array('\\'), array_diff(self::$_specials, $exclude), $include) as $char) { + $token = str_replace($char, '\\' . $char, $token); + } + + return $token; + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Header.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Header.php new file mode 100755 index 0000000..8a3d05f --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Header.php @@ -0,0 +1,95 @@ +getName(), "\r\n"); + mb_internal_encoding($old); + + return $newstring; + } + + return parent::encodeString($string, $firstLineOffset, $maxLineLength); + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/HeaderEncoder/QpHeaderEncoder.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/HeaderEncoder/QpHeaderEncoder.php new file mode 100755 index 0000000..1527f4f --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/HeaderEncoder/QpHeaderEncoder.php @@ -0,0 +1,67 @@ +_safeMap[$byte] = chr($byte); + } + } + + /** + * Get the name of this encoding scheme. + * + * Returns the string 'Q'. + * + * @return string + */ + public function getName() + { + return 'Q'; + } + + /** + * Takes an unencoded string and produces a QP encoded string from it. + * + * @param string $string string to encode + * @param int $firstLineOffset optional + * @param int $maxLineLength optional, 0 indicates the default of 76 chars + * + * @return string + */ + public function encodeString($string, $firstLineOffset = 0, $maxLineLength = 0) + { + return str_replace(array(' ', '=20', "=\r\n"), array('_', '_', "\r\n"), + parent::encodeString($string, $firstLineOffset, $maxLineLength) + ); + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/HeaderFactory.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/HeaderFactory.php new file mode 100755 index 0000000..40a1e17 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/HeaderFactory.php @@ -0,0 +1,80 @@ +setGrammar($grammar); + } + + /** + * Set the character set used in this Header. + * + * @param string $charset + */ + public function setCharset($charset) + { + $this->clearCachedValueIf($charset != $this->_charset); + $this->_charset = $charset; + if (isset($this->_encoder)) { + $this->_encoder->charsetChanged($charset); + } + } + + /** + * Get the character set used in this Header. + * + * @return string + */ + public function getCharset() + { + return $this->_charset; + } + + /** + * Set the language used in this Header. + * + * For example, for US English, 'en-us'. + * This can be unspecified. + * + * @param string $lang + */ + public function setLanguage($lang) + { + $this->clearCachedValueIf($this->_lang != $lang); + $this->_lang = $lang; + } + + /** + * Get the language used in this Header. + * + * @return string + */ + public function getLanguage() + { + return $this->_lang; + } + + /** + * Set the encoder used for encoding the header. + * + * @param Swift_Mime_HeaderEncoder $encoder + */ + public function setEncoder(Swift_Mime_HeaderEncoder $encoder) + { + $this->_encoder = $encoder; + $this->setCachedValue(null); + } + + /** + * Get the encoder used for encoding this Header. + * + * @return Swift_Mime_HeaderEncoder + */ + public function getEncoder() + { + return $this->_encoder; + } + + /** + * Set the grammar used for the header. + * + * @param Swift_Mime_Grammar $grammar + */ + public function setGrammar(Swift_Mime_Grammar $grammar) + { + $this->_grammar = $grammar; + $this->setCachedValue(null); + } + + /** + * Get the grammar used for this Header. + * + * @return Swift_Mime_Grammar + */ + public function getGrammar() + { + return $this->_grammar; + } + + /** + * Get the name of this header (e.g. charset). + * + * @return string + */ + public function getFieldName() + { + return $this->_name; + } + + /** + * Set the maximum length of lines in the header (excluding EOL). + * + * @param int $lineLength + */ + public function setMaxLineLength($lineLength) + { + $this->clearCachedValueIf($this->_lineLength != $lineLength); + $this->_lineLength = $lineLength; + } + + /** + * Get the maximum permitted length of lines in this Header. + * + * @return int + */ + public function getMaxLineLength() + { + return $this->_lineLength; + } + + /** + * Get this Header rendered as a RFC 2822 compliant string. + * + * @return string + * + * @throws Swift_RfcComplianceException + */ + public function toString() + { + return $this->_tokensToString($this->toTokens()); + } + + /** + * Returns a string representation of this object. + * + * @return string + * + * @see toString() + */ + public function __toString() + { + return $this->toString(); + } + + // -- Points of extension + + /** + * Set the name of this Header field. + * + * @param string $name + */ + protected function setFieldName($name) + { + $this->_name = $name; + } + + /** + * Produces a compliant, formatted RFC 2822 'phrase' based on the string given. + * + * @param Swift_Mime_Header $header + * @param string $string as displayed + * @param string $charset of the text + * @param Swift_Mime_HeaderEncoder $encoder + * @param bool $shorten the first line to make remove for header name + * + * @return string + */ + protected function createPhrase(Swift_Mime_Header $header, $string, $charset, Swift_Mime_HeaderEncoder $encoder = null, $shorten = false) + { + // Treat token as exactly what was given + $phraseStr = $string; + // If it's not valid + if (!preg_match('/^' . $this->getGrammar()->getDefinition('phrase') . '$/D', $phraseStr)) { + // .. but it is just ascii text, try escaping some characters + // and make it a quoted-string + if (preg_match('/^' . $this->getGrammar()->getDefinition('text') . '*$/D', $phraseStr)) { + $phraseStr = $this->getGrammar()->escapeSpecials( + $phraseStr, array('"'), $this->getGrammar()->getSpecials() + ); + $phraseStr = '"' . $phraseStr . '"'; + } else { // ... otherwise it needs encoding + // Determine space remaining on line if first line + if ($shorten) { + $usedLength = strlen($header->getFieldName() . ': '); + } else { + $usedLength = 0; + } + $phraseStr = $this->encodeWords($header, $string, $usedLength); + } + } + + return $phraseStr; + } + + /** + * Encode needed word tokens within a string of input. + * + * @param Swift_Mime_Header $header + * @param string $input + * @param string $usedLength optional + * + * @return string + */ + protected function encodeWords(Swift_Mime_Header $header, $input, $usedLength = -1) + { + $value = ''; + + $tokens = $this->getEncodableWordTokens($input); + + foreach ($tokens as $token) { + // See RFC 2822, Sect 2.2 (really 2.2 ??) + if ($this->tokenNeedsEncoding($token)) { + // Don't encode starting WSP + $firstChar = substr($token, 0, 1); + switch ($firstChar) { + case ' ': + case "\t": + $value .= $firstChar; + $token = substr($token, 1); + } + + if (-1 == $usedLength) { + $usedLength = strlen($header->getFieldName() . ': ') + strlen($value); + } + $value .= $this->getTokenAsEncodedWord($token, $usedLength); + + $header->setMaxLineLength(76); // Forcefully override + } else { + $value .= $token; + } + } + + return $value; + } + + /** + * Test if a token needs to be encoded or not. + * + * @param string $token + * + * @return bool + */ + protected function tokenNeedsEncoding($token) + { + return preg_match('~[\x00-\x08\x10-\x19\x7F-\xFF\r\n]~', $token); + } + + /** + * Splits a string into tokens in blocks of words which can be encoded quickly. + * + * @param string $string + * + * @return string[] + */ + protected function getEncodableWordTokens($string) + { + $tokens = array(); + + $encodedToken = ''; + // Split at all whitespace boundaries + foreach (preg_split('~(?=[\t ])~', $string) as $token) { + if ($this->tokenNeedsEncoding($token)) { + $encodedToken .= $token; + } else { + if (strlen($encodedToken) > 0) { + $tokens[] = $encodedToken; + $encodedToken = ''; + } + $tokens[] = $token; + } + } + if (strlen($encodedToken)) { + $tokens[] = $encodedToken; + } + + return $tokens; + } + + /** + * Get a token as an encoded word for safe insertion into headers. + * + * @param string $token token to encode + * @param int $firstLineOffset optional + * + * @return string + */ + protected function getTokenAsEncodedWord($token, $firstLineOffset = 0) + { + // Adjust $firstLineOffset to account for space needed for syntax + $charsetDecl = $this->_charset; + if (isset($this->_lang)) { + $charsetDecl .= '*' . $this->_lang; + } + $encodingWrapperLength = strlen( + '=?' . $charsetDecl . '?' . $this->_encoder->getName() . '??=' + ); + + if ($firstLineOffset >= 75) { //Does this logic need to be here? + $firstLineOffset = 0; + } + + $encodedTextLines = explode("\r\n", + $this->_encoder->encodeString( + $token, $firstLineOffset, 75 - $encodingWrapperLength, $this->_charset + ) + ); + + if (strtolower($this->_charset) !== 'iso-2022-jp') { // special encoding for iso-2022-jp using mb_encode_mimeheader + foreach ($encodedTextLines as $lineNum => $line) { + $encodedTextLines[$lineNum] = '=?' . $charsetDecl . + '?' . $this->_encoder->getName() . + '?' . $line . '?='; + } + } + + return implode("\r\n ", $encodedTextLines); + } + + /** + * Generates tokens from the given string which include CRLF as individual tokens. + * + * @param string $token + * + * @return string[] + */ + protected function generateTokenLines($token) + { + return preg_split('~(\r\n)~', $token, -1, PREG_SPLIT_DELIM_CAPTURE); + } + + /** + * Set a value into the cache. + * + * @param string $value + */ + protected function setCachedValue($value) + { + $this->_cachedValue = $value; + } + + /** + * Get the value in the cache. + * + * @return string + */ + protected function getCachedValue() + { + return $this->_cachedValue; + } + + /** + * Clear the cached value if $condition is met. + * + * @param bool $condition + */ + protected function clearCachedValueIf($condition) + { + if ($condition) { + $this->setCachedValue(null); + } + } + + // -- Private methods + + /** + * Generate a list of all tokens in the final header. + * + * @param string $string The string to tokenize + * + * @return array An array of tokens as strings + */ + protected function toTokens($string = null) + { + if (is_null($string)) { + $string = $this->getFieldBody(); + } + + $tokens = array(); + + // Generate atoms; split at all invisible boundaries followed by WSP + foreach (preg_split('~(?=[ \t])~', $string) as $token) { + $newTokens = $this->generateTokenLines($token); + foreach ($newTokens as $newToken) { + $tokens[] = $newToken; + } + } + return $tokens; + } + + /** + * Takes an array of tokens which appear in the header and turns them into + * an RFC 2822 compliant string, adding FWSP where needed. + * + * @param string[] $tokens + * + * @return string + */ + private function _tokensToString(array $tokens) + { + $lineCount = 0; + $headerLines = array(); + $headerLines[] = $this->_name . ': '; + $currentLine =& $headerLines[$lineCount++]; + + // Build all tokens back into compliant header + foreach ($tokens as $i => $token) { + // Line longer than specified maximum or token was just a new line + if (("\r\n" == $token) || + ($i > 0 && strlen($currentLine . $token) > $this->_lineLength) + && 0 < strlen($currentLine)) + { + $headerLines[] = ''; + $currentLine =& $headerLines[$lineCount++]; + } + + // Append token to the line + if ("\r\n" != $token) { + $currentLine .= $token; + } + } + + // Implode with FWS (RFC 2822, 2.2.3) + return implode("\r\n", $headerLines) . "\r\n"; + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Headers/DateHeader.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Headers/DateHeader.php new file mode 100755 index 0000000..015bc44 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Headers/DateHeader.php @@ -0,0 +1,127 @@ + + * + * + * + * @param string $name of Header + * @param Swift_Mime_Grammar $grammar + */ + public function __construct($name, Swift_Mime_Grammar $grammar) + { + $this->setFieldName($name); + parent::__construct($grammar); + } + + /** + * Get the type of Header that this instance represents. + * + * @see TYPE_TEXT, TYPE_PARAMETERIZED, TYPE_MAILBOX + * @see TYPE_DATE, TYPE_ID, TYPE_PATH + * + * @return int + */ + public function getFieldType() + { + return self::TYPE_DATE; + } + + /** + * Set the model for the field body. + * + * This method takes a UNIX timestamp. + * + * @param int $model + */ + public function setFieldBodyModel($model) + { + $this->setTimestamp($model); + } + + /** + * Get the model for the field body. + * + * This method returns a UNIX timestamp. + * + * @return mixed + */ + public function getFieldBodyModel() + { + return $this->getTimestamp(); + } + + /** + * Get the UNIX timestamp of the Date in this Header. + * + * @return int + */ + public function getTimestamp() + { + return $this->_timestamp; + } + + /** + * Set the UNIX timestamp of the Date in this Header. + * + * @param int $timestamp + */ + public function setTimestamp($timestamp) + { + if (!is_null($timestamp)) { + $timestamp = (int) $timestamp; + } + $this->clearCachedValueIf($this->_timestamp != $timestamp); + $this->_timestamp = $timestamp; + } + + /** + * Get the string value of the body in this Header. + * + * This is not necessarily RFC 2822 compliant since folding white space will + * not be added at this stage (see {@link toString()} for that). + * + * @see toString() + * + * @return string + */ + public function getFieldBody() + { + if (!$this->getCachedValue()) { + if (isset($this->_timestamp)) { + $this->setCachedValue(date('r', $this->_timestamp)); + } + } + + return $this->getCachedValue(); + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Headers/IdentificationHeader.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Headers/IdentificationHeader.php new file mode 100755 index 0000000..1d00015 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Headers/IdentificationHeader.php @@ -0,0 +1,183 @@ +setFieldName($name); + parent::__construct($grammar); + } + + /** + * Get the type of Header that this instance represents. + * + * @see TYPE_TEXT, TYPE_PARAMETERIZED, TYPE_MAILBOX + * @see TYPE_DATE, TYPE_ID, TYPE_PATH + * + * @return int + */ + public function getFieldType() + { + return self::TYPE_ID; + } + + /** + * Set the model for the field body. + * + * This method takes a string ID, or an array of IDs. + * + * @param mixed $model + * + * @throws Swift_RfcComplianceException + */ + public function setFieldBodyModel($model) + { + $this->setId($model); + } + + /** + * Get the model for the field body. + * + * This method returns an array of IDs + * + * @return array + */ + public function getFieldBodyModel() + { + return $this->getIds(); + } + + /** + * Set the ID used in the value of this header. + * + * @param string|array $id + * + * @throws Swift_RfcComplianceException + */ + public function setId($id) + { + $this->setIds(is_array($id) ? $id : array($id)); + } + + /** + * Get the ID used in the value of this Header. + * + * If multiple IDs are set only the first is returned. + * + * @return string + */ + public function getId() + { + if (count($this->_ids) > 0) { + return $this->_ids[0]; + } + } + + /** + * Set a collection of IDs to use in the value of this Header. + * + * @param string[] $ids + * + * @throws Swift_RfcComplianceException + */ + public function setIds(array $ids) + { + $actualIds = array(); + + foreach ($ids as $id) { + $this->_assertValidId($id); + $actualIds[] = $id; + } + + $this->clearCachedValueIf($this->_ids != $actualIds); + $this->_ids = $actualIds; + } + + /** + * Get the list of IDs used in this Header. + * + * @return string[] + */ + public function getIds() + { + return $this->_ids; + } + + /** + * Get the string value of the body in this Header. + * + * This is not necessarily RFC 2822 compliant since folding white space will + * not be added at this stage (see {@see toString()} for that). + * + * @see toString() + * + * @return string + * + * @throws Swift_RfcComplianceException + */ + public function getFieldBody() + { + if (!$this->getCachedValue()) { + $angleAddrs = array(); + + foreach ($this->_ids as $id) { + $angleAddrs[] = '<' . $id . '>'; + } + + $this->setCachedValue(implode(' ', $angleAddrs)); + } + + return $this->getCachedValue(); + } + + /** + * Throws an Exception if the id passed does not comply with RFC 2822. + * + * @param string $id + * + * @throws Swift_RfcComplianceException + */ + private function _assertValidId($id) + { + if (!preg_match( + '/^' . $this->getGrammar()->getDefinition('id-left') . '@' . + $this->getGrammar()->getDefinition('id-right') . '$/D', + $id + )) + { + throw new Swift_RfcComplianceException( + 'Invalid ID given <' . $id . '>' + ); + } + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Headers/MailboxHeader.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Headers/MailboxHeader.php new file mode 100755 index 0000000..766d6a1 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Headers/MailboxHeader.php @@ -0,0 +1,358 @@ +setFieldName($name); + $this->setEncoder($encoder); + parent::__construct($grammar); + } + + /** + * Get the type of Header that this instance represents. + * + * @see TYPE_TEXT, TYPE_PARAMETERIZED, TYPE_MAILBOX + * @see TYPE_DATE, TYPE_ID, TYPE_PATH + * + * @return int + */ + public function getFieldType() + { + return self::TYPE_MAILBOX; + } + + /** + * Set the model for the field body. + * + * This method takes a string, or an array of addresses. + * + * @param mixed $model + * + * @throws Swift_RfcComplianceException + */ + public function setFieldBodyModel($model) + { + $this->setNameAddresses($model); + } + + /** + * Get the model for the field body. + * + * This method returns an associative array like {@link getNameAddresses()} + * + * @return array + * + * @throws Swift_RfcComplianceException + */ + public function getFieldBodyModel() + { + return $this->getNameAddresses(); + } + + /** + * Set a list of mailboxes to be shown in this Header. + * + * The mailboxes can be a simple array of addresses, or an array of + * key=>value pairs where (email => personalName). + * Example: + * + * setNameAddresses(array( + * 'chris@swiftmailer.org' => 'Chris Corbyn', + * 'mark@swiftmailer.org' //No associated personal name + * )); + * ?> + * + * + * @see __construct() + * @see setAddresses() + * @see setValue() + * + * @param string|string[] $mailboxes + * + * @throws Swift_RfcComplianceException + */ + public function setNameAddresses($mailboxes) + { + $this->_mailboxes = $this->normalizeMailboxes((array) $mailboxes); + $this->setCachedValue(null); //Clear any cached value + } + + /** + * Get the full mailbox list of this Header as an array of valid RFC 2822 strings. + * + * Example: + * + * 'Chris Corbyn', + * 'mark@swiftmailer.org' => 'Mark Corbyn') + * ); + * print_r($header->getNameAddressStrings()); + * // array ( + * // 0 => Chris Corbyn , + * // 1 => Mark Corbyn + * // ) + * ?> + * + * + * @see getNameAddresses() + * @see toString() + * + * @return string[] + * + * @throws Swift_RfcComplianceException + */ + public function getNameAddressStrings() + { + return $this->_createNameAddressStrings($this->getNameAddresses()); + } + + /** + * Get all mailboxes in this Header as key=>value pairs. + * + * The key is the address and the value is the name (or null if none set). + * Example: + * + * 'Chris Corbyn', + * 'mark@swiftmailer.org' => 'Mark Corbyn') + * ); + * print_r($header->getNameAddresses()); + * // array ( + * // chris@swiftmailer.org => Chris Corbyn, + * // mark@swiftmailer.org => Mark Corbyn + * // ) + * ?> + * + * + * @see getAddresses() + * @see getNameAddressStrings() + * + * @return string[] + */ + public function getNameAddresses() + { + return $this->_mailboxes; + } + + /** + * Makes this Header represent a list of plain email addresses with no names. + * + * Example: + * + * setAddresses( + * array('one@domain.tld', 'two@domain.tld', 'three@domain.tld') + * ); + * ?> + * + * + * @see setNameAddresses() + * @see setValue() + * + * @param string[] $addresses + * + * @throws Swift_RfcComplianceException + */ + public function setAddresses($addresses) + { + $this->setNameAddresses(array_values((array) $addresses)); + } + + /** + * Get all email addresses in this Header. + * + * @see getNameAddresses() + * + * @return string[] + */ + public function getAddresses() + { + return array_keys($this->_mailboxes); + } + + /** + * Remove one or more addresses from this Header. + * + * @param string|string[] $addresses + */ + public function removeAddresses($addresses) + { + $this->setCachedValue(null); + foreach ((array) $addresses as $address) { + unset($this->_mailboxes[$address]); + } + } + + /** + * Get the string value of the body in this Header. + * + * This is not necessarily RFC 2822 compliant since folding white space will + * not be added at this stage (see {@link toString()} for that). + * + * @see toString() + * + * @return string + * + * @throws Swift_RfcComplianceException + */ + public function getFieldBody() + { + // Compute the string value of the header only if needed + if (is_null($this->getCachedValue())) { + $this->setCachedValue($this->createMailboxListString($this->_mailboxes)); + } + + return $this->getCachedValue(); + } + + // -- Points of extension + + /** + * Normalizes a user-input list of mailboxes into consistent key=>value pairs. + * + * @param string[] $mailboxes + * + * @return string[] + */ + protected function normalizeMailboxes(array $mailboxes) + { + $actualMailboxes = array(); + + foreach ($mailboxes as $key => $value) { + if (is_string($key)) { //key is email addr + $address = $key; + $name = $value; + } else { + $address = $value; + $name = null; + } + $this->_assertValidAddress($address); + $actualMailboxes[$address] = $name; + } + + return $actualMailboxes; + } + + /** + * Produces a compliant, formatted display-name based on the string given. + * + * @param string $displayName as displayed + * @param bool $shorten the first line to make remove for header name + * + * @return string + */ + protected function createDisplayNameString($displayName, $shorten = false) + { + return $this->createPhrase($this, $displayName, + $this->getCharset(), $this->getEncoder(), $shorten + ); + } + + /** + * Creates a string form of all the mailboxes in the passed array. + * + * @param string[] $mailboxes + * + * @return string + * + * @throws Swift_RfcComplianceException + */ + protected function createMailboxListString(array $mailboxes) + { + return implode(', ', $this->_createNameAddressStrings($mailboxes)); + } + + /** + * Redefine the encoding requirements for mailboxes. + * + * Commas and semicolons are used to separate + * multiple addresses, and should therefore be encoded + * + * @param string $token + * + * @return bool + */ + protected function tokenNeedsEncoding($token) + { + return preg_match('/[,;]/', $token) || parent::tokenNeedsEncoding($token); + } + + // -- Private methods + + /** + * Return an array of strings conforming the the name-addr spec of RFC 2822. + * + * @param string[] $mailboxes + * + * @return string[] + */ + private function _createNameAddressStrings(array $mailboxes) + { + $strings = array(); + + foreach ($mailboxes as $email => $name) { + $mailboxStr = $email; + if (!is_null($name)) { + $nameStr = $this->createDisplayNameString($name, empty($strings)); + $mailboxStr = $nameStr . ' <' . $mailboxStr . '>'; + } + $strings[] = $mailboxStr; + } + + return $strings; + } + + /** + * Throws an Exception if the address passed does not comply with RFC 2822. + * + * @param string $address + * + * @throws Swift_RfcComplianceException If invalid. + */ + private function _assertValidAddress($address) + { + if (!preg_match('/^' . $this->getGrammar()->getDefinition('addr-spec') . '$/D', + $address)) + { + throw new Swift_RfcComplianceException( + 'Address in mailbox given [' . $address . + '] does not comply with RFC 2822, 3.6.2.' + ); + } + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Headers/OpenDKIMHeader.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Headers/OpenDKIMHeader.php new file mode 100755 index 0000000..ecab738 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Headers/OpenDKIMHeader.php @@ -0,0 +1,139 @@ + + */ +class Swift_Mime_Headers_OpenDKIMHeader implements Swift_Mime_Header +{ + /** + * The value of this Header. + * + * @var string + */ + private $_value; + + /** + * The name of this Header + * @var string + */ + private $_fieldName; + + /** + * Creates a new SimpleHeader with $name. + * + * @param string $name + * @param Swift_Mime_HeaderEncoder $encoder + * @param Swift_Mime_Grammar $grammar + */ + public function __construct($name) + { + $this->_fieldName = $name; + } + + /** + * Get the type of Header that this instance represents. + * + * @see TYPE_TEXT, TYPE_PARAMETERIZED, TYPE_MAILBOX + * @see TYPE_DATE, TYPE_ID, TYPE_PATH + * + * @return int + */ + public function getFieldType() + { + return self::TYPE_TEXT; + } + + /** + * Set the model for the field body. + * + * This method takes a string for the field value. + * + * @param string $model + */ + public function setFieldBodyModel($model) + { + $this->setValue($model); + } + + /** + * Get the model for the field body. + * + * This method returns a string. + * + * @return string + */ + public function getFieldBodyModel() + { + return $this->getValue(); + } + + /** + * Get the (unencoded) value of this header. + * + * @return string + */ + public function getValue() + { + return $this->_value; + } + + /** + * Set the (unencoded) value of this header. + * + * @param string $value + */ + public function setValue($value) + { + $this->_value = $value; + } + + /** + * Get the value of this header prepared for rendering. + * + * @return string + */ + public function getFieldBody() + { + return $this->_value; + } + + /** + * Get this Header rendered as a RFC 2822 compliant string. + * + * @return string + */ + public function toString() + { + return $this->_fieldName.': '.$this->_value; + } + + /** + * Set the Header FieldName + * @see Swift_Mime_Header::getFieldName() + */ + public function getFieldName() + { + return $this->_fieldName; + } + + /** + * Ignored + */ + public function setCharset($charset) + { + + } + +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Headers/ParameterizedHeader.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Headers/ParameterizedHeader.php new file mode 100755 index 0000000..7f52857 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Headers/ParameterizedHeader.php @@ -0,0 +1,265 @@ +_paramEncoder = $paramEncoder; + } + + /** + * Get the type of Header that this instance represents. + * + * @see TYPE_TEXT, TYPE_PARAMETERIZED, TYPE_MAILBOX + * @see TYPE_DATE, TYPE_ID, TYPE_PATH + * + * @return int + */ + public function getFieldType() + { + return self::TYPE_PARAMETERIZED; + } + + /** + * Set the character set used in this Header. + * + * @param string $charset + */ + public function setCharset($charset) + { + parent::setCharset($charset); + if (isset($this->_paramEncoder)) { + $this->_paramEncoder->charsetChanged($charset); + } + } + + /** + * Set the value of $parameter. + * + * @param string $parameter + * @param string $value + */ + public function setParameter($parameter, $value) + { + $this->setParameters(array_merge($this->getParameters(), array($parameter => $value))); + } + + /** + * Get the value of $parameter. + * + * @param string $parameter + * + * @return string + */ + public function getParameter($parameter) + { + $params = $this->getParameters(); + + return array_key_exists($parameter, $params) + ? $params[$parameter] + : null; + } + + /** + * Set an associative array of parameter names mapped to values. + * + * @param string[] $parameters + */ + public function setParameters(array $parameters) + { + $this->clearCachedValueIf($this->_params != $parameters); + $this->_params = $parameters; + } + + /** + * Returns an associative array of parameter names mapped to values. + * + * @return string[] + */ + public function getParameters() + { + return $this->_params; + } + + /** + * Get the value of this header prepared for rendering. + * + * @return string + */ + public function getFieldBody() //TODO: Check caching here + { + $body = parent::getFieldBody(); + foreach ($this->_params as $name => $value) { + if (!is_null($value)) { + // Add the parameter + $body .= '; ' . $this->_createParameter($name, $value); + } + } + + return $body; + } + + // -- Protected methods + + /** + * Generate a list of all tokens in the final header. + * + * This doesn't need to be overridden in theory, but it is for implementation + * reasons to prevent potential breakage of attributes. + * + * @param string $string The string to tokenize + * + * @return array An array of tokens as strings + */ + protected function toTokens($string = null) + { + $tokens = parent::toTokens(parent::getFieldBody()); + + // Try creating any parameters + foreach ($this->_params as $name => $value) { + if (!is_null($value)) { + // Add the semi-colon separator + $tokens[count($tokens)-1] .= ';'; + $tokens = array_merge($tokens, $this->generateTokenLines( + ' ' . $this->_createParameter($name, $value) + )); + } + } + + return $tokens; + } + + // -- Private methods + + /** + * Render a RFC 2047 compliant header parameter from the $name and $value. + * + * @param string $name + * @param string $value + * + * @return string + */ + private function _createParameter($name, $value) + { + $origValue = $value; + + $encoded = false; + // Allow room for parameter name, indices, "=" and DQUOTEs + $maxValueLength = $this->getMaxLineLength() - strlen($name . '=*N"";') - 1; + $firstLineOffset = 0; + + // If it's not already a valid parameter value... + if (!preg_match('/^' . self::TOKEN_REGEX . '$/D', $value)) { + // TODO: text, or something else?? + // ... and it's not ascii + if (!preg_match('/^' . $this->getGrammar()->getDefinition('text') . '*$/D', $value)) { + $encoded = true; + // Allow space for the indices, charset and language + $maxValueLength = $this->getMaxLineLength() - strlen($name . '*N*="";') - 1; + $firstLineOffset = strlen( + $this->getCharset() . "'" . $this->getLanguage() . "'" + ); + } + } + + // Encode if we need to + if ($encoded || strlen($value) > $maxValueLength) { + if (isset($this->_paramEncoder)) { + $value = $this->_paramEncoder->encodeString( + $origValue, $firstLineOffset, $maxValueLength, $this->getCharset() + ); + } else { // We have to go against RFC 2183/2231 in some areas for interoperability + $value = $this->getTokenAsEncodedWord($origValue); + $encoded = false; + } + } + + $valueLines = isset($this->_paramEncoder) ? explode("\r\n", $value) : array($value); + + // Need to add indices + if (count($valueLines) > 1) { + $paramLines = array(); + foreach ($valueLines as $i => $line) { + $paramLines[] = $name . '*' . $i . + $this->_getEndOfParameterValue($line, true, $i == 0); + } + + return implode(";\r\n ", $paramLines); + } else { + return $name . $this->_getEndOfParameterValue( + $valueLines[0], $encoded, true + ); + } + } + + /** + * Returns the parameter value from the "=" and beyond. + * + * @param string $value to append + * @param bool $encoded + * @param bool $firstLine + * + * @return string + */ + private function _getEndOfParameterValue($value, $encoded = false, $firstLine = false) + { + if (!preg_match('/^' . self::TOKEN_REGEX . '$/D', $value)) { + $value = '"' . $value . '"'; + } + $prepend = '='; + if ($encoded) { + $prepend = '*='; + if ($firstLine) { + $prepend = '*=' . $this->getCharset() . "'" . $this->getLanguage() . + "'"; + } + } + + return $prepend . $value; + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Headers/PathHeader.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Headers/PathHeader.php new file mode 100755 index 0000000..bfecf3f --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Headers/PathHeader.php @@ -0,0 +1,146 @@ +setFieldName($name); + parent::__construct($grammar); + } + + /** + * Get the type of Header that this instance represents. + * + * @see TYPE_TEXT, TYPE_PARAMETERIZED, TYPE_MAILBOX + * @see TYPE_DATE, TYPE_ID, TYPE_PATH + * + * @return int + */ + public function getFieldType() + { + return self::TYPE_PATH; + } + + /** + * Set the model for the field body. + * This method takes a string for an address. + * + * @param string $model + * + * @throws Swift_RfcComplianceException + */ + public function setFieldBodyModel($model) + { + $this->setAddress($model); + } + + /** + * Get the model for the field body. + * This method returns a string email address. + * + * @return mixed + */ + public function getFieldBodyModel() + { + return $this->getAddress(); + } + + /** + * Set the Address which should appear in this Header. + * + * @param string $address + * + * @throws Swift_RfcComplianceException + */ + public function setAddress($address) + { + if (is_null($address)) { + $this->_address = null; + } elseif ('' == $address) { + $this->_address = ''; + } else { + $this->_assertValidAddress($address); + $this->_address = $address; + } + $this->setCachedValue(null); + } + + /** + * Get the address which is used in this Header (if any). + * + * Null is returned if no address is set. + * + * @return string + */ + public function getAddress() + { + return $this->_address; + } + + /** + * Get the string value of the body in this Header. + * + * This is not necessarily RFC 2822 compliant since folding white space will + * not be added at this stage (see {@link toString()} for that). + * + * @see toString() + * + * @return string + */ + public function getFieldBody() + { + if (!$this->getCachedValue()) { + if (isset($this->_address)) { + $this->setCachedValue('<' . $this->_address . '>'); + } + } + + return $this->getCachedValue(); + } + + /** + * Throws an Exception if the address passed does not comply with RFC 2822. + * + * @param string $address + * + * @throws Swift_RfcComplianceException If address is invalid + */ + private function _assertValidAddress($address) + { + if (!preg_match('/^' . $this->getGrammar()->getDefinition('addr-spec') . '$/D', + $address)) + { + throw new Swift_RfcComplianceException( + 'Address set in PathHeader does not comply with addr-spec of RFC 2822.' + ); + } + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Headers/UnstructuredHeader.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Headers/UnstructuredHeader.php new file mode 100755 index 0000000..2de49b4 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Headers/UnstructuredHeader.php @@ -0,0 +1,114 @@ +setFieldName($name); + $this->setEncoder($encoder); + parent::__construct($grammar); + } + + /** + * Get the type of Header that this instance represents. + * + * @see TYPE_TEXT, TYPE_PARAMETERIZED, TYPE_MAILBOX + * @see TYPE_DATE, TYPE_ID, TYPE_PATH + * + * @return int + */ + public function getFieldType() + { + return self::TYPE_TEXT; + } + + /** + * Set the model for the field body. + * + * This method takes a string for the field value. + * + * @param string $model + */ + public function setFieldBodyModel($model) + { + $this->setValue($model); + } + + /** + * Get the model for the field body. + * + * This method returns a string. + * + * @return string + */ + public function getFieldBodyModel() + { + return $this->getValue(); + } + + /** + * Get the (unencoded) value of this header. + * + * @return string + */ + public function getValue() + { + return $this->_value; + } + + /** + * Set the (unencoded) value of this header. + * + * @param string $value + */ + public function setValue($value) + { + $this->clearCachedValueIf($this->_value != $value); + $this->_value = $value; + } + + /** + * Get the value of this header prepared for rendering. + * + * @return string + */ + public function getFieldBody() + { + if (!$this->getCachedValue()) { + $this->setCachedValue( + $this->encodeWords($this, $this->_value) + ); + } + + return $this->getCachedValue(); + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Message.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Message.php new file mode 100755 index 0000000..59df2f2 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Message.php @@ -0,0 +1,225 @@ + 'Real Name'). + * + * If the second parameter is provided and the first is a string, then $name + * is associated with the address. + * + * @param mixed $address + * @param string $name optional + */ + public function setSender($address, $name = null); + + /** + * Get the sender address for this message. + * + * This has a higher significance than the From address. + * + * @return string + */ + public function getSender(); + + /** + * Set the From address of this message. + * + * It is permissible for multiple From addresses to be set using an array. + * + * If multiple From addresses are used, you SHOULD set the Sender address and + * according to RFC 2822, MUST set the sender address. + * + * An array can be used if display names are to be provided: i.e. + * array('email@address.com' => 'Real Name'). + * + * If the second parameter is provided and the first is a string, then $name + * is associated with the address. + * + * @param mixed $addresses + * @param string $name optional + */ + public function setFrom($addresses, $name = null); + + /** + * Get the From address(es) of this message. + * + * This method always returns an associative array where the keys are the + * addresses. + * + * @return string[] + */ + public function getFrom(); + + /** + * Set the Reply-To address(es). + * + * Any replies from the receiver will be sent to this address. + * + * It is permissible for multiple reply-to addresses to be set using an array. + * + * This method has the same synopsis as {@link setFrom()} and {@link setTo()}. + * + * If the second parameter is provided and the first is a string, then $name + * is associated with the address. + * + * @param mixed $addresses + * @param string $name optional + */ + public function setReplyTo($addresses, $name = null); + + /** + * Get the Reply-To addresses for this message. + * + * This method always returns an associative array where the keys provide the + * email addresses. + * + * @return string[] + */ + public function getReplyTo(); + + /** + * Set the To address(es). + * + * Recipients set in this field will receive a copy of this message. + * + * This method has the same synopsis as {@link setFrom()} and {@link setCc()}. + * + * If the second parameter is provided and the first is a string, then $name + * is associated with the address. + * + * @param mixed $addresses + * @param string $name optional + */ + public function setTo($addresses, $name = null); + + /** + * Get the To addresses for this message. + * + * This method always returns an associative array, whereby the keys provide + * the actual email addresses. + * + * @return string[] + */ + public function getTo(); + + /** + * Set the Cc address(es). + * + * Recipients set in this field will receive a 'carbon-copy' of this message. + * + * This method has the same synopsis as {@link setFrom()} and {@link setTo()}. + * + * @param mixed $addresses + * @param string $name optional + */ + public function setCc($addresses, $name = null); + + /** + * Get the Cc addresses for this message. + * + * This method always returns an associative array, whereby the keys provide + * the actual email addresses. + * + * @return string[] + */ + public function getCc(); + + /** + * Set the Bcc address(es). + * + * Recipients set in this field will receive a 'blind-carbon-copy' of this + * message. + * + * In other words, they will get the message, but any other recipients of the + * message will have no such knowledge of their receipt of it. + * + * This method has the same synopsis as {@link setFrom()} and {@link setTo()}. + * + * @param mixed $addresses + * @param string $name optional + */ + public function setBcc($addresses, $name = null); + + /** + * Get the Bcc addresses for this message. + * + * This method always returns an associative array, whereby the keys provide + * the actual email addresses. + * + * @return string[] + */ + public function getBcc(); +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/MimeEntity.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/MimeEntity.php new file mode 100755 index 0000000..bc9f2ad --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/MimeEntity.php @@ -0,0 +1,117 @@ +setContentType('text/plain'); + if (!is_null($charset)) { + $this->setCharset($charset); + } + } + + /** + * Set the body of this entity, either as a string, or as an instance of + * {@link Swift_OutputByteStream}. + * + * @param mixed $body + * @param string $contentType optional + * @param string $charset optional + * + * @return Swift_Mime_MimePart + */ + public function setBody($body, $contentType = null, $charset = null) + { + if (isset($charset)) { + $this->setCharset($charset); + } + $body = $this->_convertString($body); + + parent::setBody($body, $contentType); + + return $this; + } + + /** + * Get the character set of this entity. + * + * @return string + */ + public function getCharset() + { + return $this->_getHeaderParameter('Content-Type', 'charset'); + } + + /** + * Set the character set of this entity. + * + * @param string $charset + * + * @return Swift_Mime_MimePart + */ + public function setCharset($charset) + { + $this->_setHeaderParameter('Content-Type', 'charset', $charset); + if ($charset !== $this->_userCharset) { + $this->_clearCache(); + } + $this->_userCharset = $charset; + parent::charsetChanged($charset); + + return $this; + } + + /** + * Get the format of this entity (i.e. flowed or fixed). + * + * @return string + */ + public function getFormat() + { + return $this->_getHeaderParameter('Content-Type', 'format'); + } + + /** + * Set the format of this entity (flowed or fixed). + * + * @param string $format + * + * @return Swift_Mime_MimePart + */ + public function setFormat($format) + { + $this->_setHeaderParameter('Content-Type', 'format', $format); + $this->_userFormat = $format; + + return $this; + } + + /** + * Test if delsp is being used for this entity. + * + * @return bool + */ + public function getDelSp() + { + return ($this->_getHeaderParameter('Content-Type', 'delsp') == 'yes') + ? true + : false; + } + + /** + * Turn delsp on or off for this entity. + * + * @param bool $delsp + * + * @return Swift_Mime_MimePart + */ + public function setDelSp($delsp = true) + { + $this->_setHeaderParameter('Content-Type', 'delsp', $delsp ? 'yes' : null); + $this->_userDelSp = $delsp; + + return $this; + } + + /** + * Get the nesting level of this entity. + * + * @see LEVEL_TOP, LEVEL_ALTERNATIVE, LEVEL_MIXED, LEVEL_RELATED + * + * @return int + */ + public function getNestingLevel() + { + return $this->_nestingLevel; + } + + /** + * Receive notification that the charset has changed on this document, or a + * parent document. + * + * @param string $charset + */ + public function charsetChanged($charset) + { + $this->setCharset($charset); + } + + // -- Protected methods + + /** Fix the content-type and encoding of this entity */ + protected function _fixHeaders() + { + parent::_fixHeaders(); + if (count($this->getChildren())) { + $this->_setHeaderParameter('Content-Type', 'charset', null); + $this->_setHeaderParameter('Content-Type', 'format', null); + $this->_setHeaderParameter('Content-Type', 'delsp', null); + } else { + $this->setCharset($this->_userCharset); + $this->setFormat($this->_userFormat); + $this->setDelSp($this->_userDelSp); + } + } + + /** Set the nesting level of this entity */ + protected function _setNestingLevel($level) + { + $this->_nestingLevel = $level; + } + + /** Encode charset when charset is not utf-8 */ + protected function _convertString($string) + { + $charset = strtolower($this->getCharset()); + if (!in_array($charset, array('utf-8', 'iso-8859-1', ''))) { + // mb_convert_encoding must be the first one to check, since iconv cannot convert some words. + if (function_exists('mb_convert_encoding')) { + $string = mb_convert_encoding($string, 'utf-8', $charset); + } elseif (function_exists('iconv')) { + $string = iconv($charset, 'utf-8//TRANSLIT//IGNORE', $string); + } else { + throw new Swift_SwiftException('No suitable convert encoding function (use UTF-8 as your charset or install the mbstring or iconv extension).'); + } + + return $string; + } + + return $string; + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/ParameterizedHeader.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/ParameterizedHeader.php new file mode 100755 index 0000000..95172ec --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/ParameterizedHeader.php @@ -0,0 +1,36 @@ +_encoder = $encoder; + $this->_paramEncoder = $paramEncoder; + $this->_grammar = $grammar; + $this->_charset = $charset; + } + + /** + * Create a new Mailbox Header with a list of $addresses. + * + * @param string $name + * @param array|string|null $addresses + * + * @return Swift_Mime_Header + */ + public function createMailboxHeader($name, $addresses = null) + { + $header = new Swift_Mime_Headers_MailboxHeader($name, $this->_encoder, $this->_grammar); + if (isset($addresses)) { + $header->setFieldBodyModel($addresses); + } + $this->_setHeaderCharset($header); + + return $header; + } + + /** + * Create a new Date header using $timestamp (UNIX time). + * @param string $name + * @param int|null $timestamp + * + * @return Swift_Mime_Header + */ + public function createDateHeader($name, $timestamp = null) + { + $header = new Swift_Mime_Headers_DateHeader($name, $this->_grammar); + if (isset($timestamp)) { + $header->setFieldBodyModel($timestamp); + } + $this->_setHeaderCharset($header); + + return $header; + } + + /** + * Create a new basic text header with $name and $value. + * + * @param string $name + * @param string $value + * + * @return Swift_Mime_Header + */ + public function createTextHeader($name, $value = null) + { + $header = new Swift_Mime_Headers_UnstructuredHeader($name, $this->_encoder, $this->_grammar); + if (isset($value)) { + $header->setFieldBodyModel($value); + } + $this->_setHeaderCharset($header); + + return $header; + } + + /** + * Create a new ParameterizedHeader with $name, $value and $params. + * + * @param string $name + * @param string $value + * @param array $params + * + * @return Swift_Mime_ParameterizedHeader + */ + public function createParameterizedHeader($name, $value = null, + $params = array()) + { + $header = new Swift_Mime_Headers_ParameterizedHeader($name, + $this->_encoder, (strtolower($name) == 'content-disposition') + ? $this->_paramEncoder + : null, + $this->_grammar + ); + if (isset($value)) { + $header->setFieldBodyModel($value); + } + foreach ($params as $k => $v) { + $header->setParameter($k, $v); + } + $this->_setHeaderCharset($header); + + return $header; + } + + /** + * Create a new ID header for Message-ID or Content-ID. + * + * @param string $name + * @param string|array $ids + * + * @return Swift_Mime_Header + */ + public function createIdHeader($name, $ids = null) + { + $header = new Swift_Mime_Headers_IdentificationHeader($name, $this->_grammar); + if (isset($ids)) { + $header->setFieldBodyModel($ids); + } + $this->_setHeaderCharset($header); + + return $header; + } + + /** + * Create a new Path header with an address (path) in it. + * + * @param string $name + * @param string $path + * + * @return Swift_Mime_Header + */ + public function createPathHeader($name, $path = null) + { + $header = new Swift_Mime_Headers_PathHeader($name, $this->_grammar); + if (isset($path)) { + $header->setFieldBodyModel($path); + } + $this->_setHeaderCharset($header); + + return $header; + } + + /** + * Notify this observer that the entity's charset has changed. + * + * @param string $charset + */ + public function charsetChanged($charset) + { + $this->_charset = $charset; + $this->_encoder->charsetChanged($charset); + $this->_paramEncoder->charsetChanged($charset); + } + + // -- Private methods + + /** Apply the charset to the Header */ + private function _setHeaderCharset(Swift_Mime_Header $header) + { + if (isset($this->_charset)) { + $header->setCharset($this->_charset); + } + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/SimpleHeaderSet.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/SimpleHeaderSet.php new file mode 100755 index 0000000..bd6ed6b --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/SimpleHeaderSet.php @@ -0,0 +1,387 @@ +_factory = $factory; + if (isset($charset)) { + $this->setCharset($charset); + } + } + + /** + * Set the charset used by these headers. + * + * @param string $charset + */ + public function setCharset($charset) + { + $this->_charset = $charset; + $this->_factory->charsetChanged($charset); + $this->_notifyHeadersOfCharset($charset); + } + + /** + * Add a new Mailbox Header with a list of $addresses. + * + * @param string $name + * @param array|string $addresses + */ + public function addMailboxHeader($name, $addresses = null) + { + $this->_storeHeader($name, + $this->_factory->createMailboxHeader($name, $addresses)); + } + + /** + * Add a new Date header using $timestamp (UNIX time). + * + * @param string $name + * @param int $timestamp + */ + public function addDateHeader($name, $timestamp = null) + { + $this->_storeHeader($name, + $this->_factory->createDateHeader($name, $timestamp)); + } + + /** + * Add a new basic text header with $name and $value. + * + * @param string $name + * @param string $value + */ + public function addTextHeader($name, $value = null) + { + $this->_storeHeader($name, + $this->_factory->createTextHeader($name, $value)); + } + + /** + * Add a new ParameterizedHeader with $name, $value and $params. + * + * @param string $name + * @param string $value + * @param array $params + */ + public function addParameterizedHeader($name, $value = null, $params = array()) + { + $this->_storeHeader($name, $this->_factory->createParameterizedHeader($name, $value, $params)); + } + + /** + * Add a new ID header for Message-ID or Content-ID. + * + * @param string $name + * @param string|array $ids + */ + public function addIdHeader($name, $ids = null) + { + $this->_storeHeader($name, $this->_factory->createIdHeader($name, $ids)); + } + + /** + * Add a new Path header with an address (path) in it. + * + * @param string $name + * @param string $path + */ + public function addPathHeader($name, $path = null) + { + $this->_storeHeader($name, $this->_factory->createPathHeader($name, $path)); + } + + /** + * Returns true if at least one header with the given $name exists. + * + * If multiple headers match, the actual one may be specified by $index. + * + * @param string $name + * @param int $index + * + * @return bool + */ + public function has($name, $index = 0) + { + $lowerName = strtolower($name); + + return array_key_exists($lowerName, $this->_headers) && array_key_exists($index, $this->_headers[$lowerName]); + } + + /** + * Set a header in the HeaderSet. + * + * The header may be a previously fetched header via {@link get()} or it may + * be one that has been created separately. + * + * If $index is specified, the header will be inserted into the set at this + * offset. + * + * @param Swift_Mime_Header $header + * @param int $index + */ + public function set(Swift_Mime_Header $header, $index = 0) + { + $this->_storeHeader($header->getFieldName(), $header, $index); + } + + /** + * Get the header with the given $name. + * + * If multiple headers match, the actual one may be specified by $index. + * Returns NULL if none present. + * + * @param string $name + * @param int $index + * + * @return Swift_Mime_Header + */ + public function get($name, $index = 0) + { + if ($this->has($name, $index)) { + $lowerName = strtolower($name); + + return $this->_headers[$lowerName][$index]; + } + } + + /** + * Get all headers with the given $name. + * + * @param string $name + * + * @return array + */ + public function getAll($name = null) + { + if (!isset($name)) { + $headers = array(); + foreach ($this->_headers as $collection) { + $headers = array_merge($headers, $collection); + } + + return $headers; + } + + $lowerName = strtolower($name); + if (!array_key_exists($lowerName, $this->_headers)) { + return array(); + } + + return $this->_headers[$lowerName]; + } + + /** + * Return the name of all Headers + * + * @return array + */ + public function listAll() + { + $headers = $this->_headers; + if ($this->_canSort()) { + uksort($headers, array($this, '_sortHeaders')); + } + + return array_keys($headers); + } + + /** + * Remove the header with the given $name if it's set. + * + * If multiple headers match, the actual one may be specified by $index. + * + * @param string $name + * @param int $index + */ + public function remove($name, $index = 0) + { + $lowerName = strtolower($name); + unset($this->_headers[$lowerName][$index]); + } + + /** + * Remove all headers with the given $name. + * + * @param string $name + */ + public function removeAll($name) + { + $lowerName = strtolower($name); + unset($this->_headers[$lowerName]); + } + + /** + * Create a new instance of this HeaderSet. + * + * @return Swift_Mime_HeaderSet + */ + public function newInstance() + { + return new self($this->_factory); + } + + /** + * Define a list of Header names as an array in the correct order. + * + * These Headers will be output in the given order where present. + * + * @param array $sequence + */ + public function defineOrdering(array $sequence) + { + $this->_order = array_flip(array_map('strtolower', $sequence)); + } + + /** + * Set a list of header names which must always be displayed when set. + * + * Usually headers without a field value won't be output unless set here. + * + * @param array $names + */ + public function setAlwaysDisplayed(array $names) + { + $this->_required = array_flip(array_map('strtolower', $names)); + } + + /** + * Notify this observer that the entity's charset has changed. + * + * @param string $charset + */ + public function charsetChanged($charset) + { + $this->setCharset($charset); + } + + /** + * Returns a string with a representation of all headers. + * + * @return string + */ + public function toString() + { + $string = ''; + $headers = $this->_headers; + if ($this->_canSort()) { + uksort($headers, array($this, '_sortHeaders')); + } + foreach ($headers as $collection) { + foreach ($collection as $header) { + if ($this->_isDisplayed($header) || $header->getFieldBody() != '') { + $string .= $header->toString(); + } + } + } + + return $string; + } + + /** + * Returns a string representation of this object. + * + * @return string + * + * @see toString() + */ + public function __toString() + { + return $this->toString(); + } + + // -- Private methods + + /** Save a Header to the internal collection */ + private function _storeHeader($name, Swift_Mime_Header $header, $offset = null) + { + if (!isset($this->_headers[strtolower($name)])) { + $this->_headers[strtolower($name)] = array(); + } + if (!isset($offset)) { + $this->_headers[strtolower($name)][] = $header; + } else { + $this->_headers[strtolower($name)][$offset] = $header; + } + } + + /** Test if the headers can be sorted */ + private function _canSort() + { + return count($this->_order) > 0; + } + + /** uksort() algorithm for Header ordering */ + private function _sortHeaders($a, $b) + { + $lowerA = strtolower($a); + $lowerB = strtolower($b); + $aPos = array_key_exists($lowerA, $this->_order) + ? $this->_order[$lowerA] + : -1; + $bPos = array_key_exists($lowerB, $this->_order) + ? $this->_order[$lowerB] + : -1; + + if ($aPos == -1) { + return 1; + } elseif ($bPos == -1) { + return -1; + } + + return ($aPos < $bPos) ? -1 : 1; + } + + /** Test if the given Header is always displayed */ + private function _isDisplayed(Swift_Mime_Header $header) + { + return array_key_exists(strtolower($header->getFieldName()), $this->_required); + } + + /** Notify all Headers of the new charset */ + private function _notifyHeadersOfCharset($charset) + { + foreach ($this->_headers as $headerGroup) { + foreach ($headerGroup as $header) { + $header->setCharset($charset); + } + } + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/SimpleMessage.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/SimpleMessage.php new file mode 100755 index 0000000..4b2c88b --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/SimpleMessage.php @@ -0,0 +1,656 @@ +getHeaders()->defineOrdering(array( + 'Return-Path', + 'Received', + 'DKIM-Signature', + 'DomainKey-Signature', + 'Sender', + 'Message-ID', + 'Date', + 'Subject', + 'From', + 'Reply-To', + 'To', + 'Cc', + 'Bcc', + 'MIME-Version', + 'Content-Type', + 'Content-Transfer-Encoding' + )); + $this->getHeaders()->setAlwaysDisplayed(array('Date', 'Message-ID', 'From')); + $this->getHeaders()->addTextHeader('MIME-Version', '1.0'); + $this->setDate(time()); + $this->setId($this->getId()); + $this->getHeaders()->addMailboxHeader('From'); + } + + /** + * Always returns {@link LEVEL_TOP} for a message instance. + * + * @return int + */ + public function getNestingLevel() + { + return self::LEVEL_TOP; + } + + /** + * Set the subject of this message. + * + * @param string $subject + * + * @return Swift_Mime_SimpleMessage + */ + public function setSubject($subject) + { + if (!$this->_setHeaderFieldModel('Subject', $subject)) { + $this->getHeaders()->addTextHeader('Subject', $subject); + } + + return $this; + } + + /** + * Get the subject of this message. + * + * @return string + */ + public function getSubject() + { + return $this->_getHeaderFieldModel('Subject'); + } + + /** + * Set the date at which this message was created. + * + * @param int $date + * + * @return Swift_Mime_SimpleMessage + */ + public function setDate($date) + { + if (!$this->_setHeaderFieldModel('Date', $date)) { + $this->getHeaders()->addDateHeader('Date', $date); + } + + return $this; + } + + /** + * Get the date at which this message was created. + * + * @return int + */ + public function getDate() + { + return $this->_getHeaderFieldModel('Date'); + } + + /** + * Set the return-path (the bounce address) of this message. + * + * @param string $address + * + * @return Swift_Mime_SimpleMessage + */ + public function setReturnPath($address) + { + if (!$this->_setHeaderFieldModel('Return-Path', $address)) { + $this->getHeaders()->addPathHeader('Return-Path', $address); + } + + return $this; + } + + /** + * Get the return-path (bounce address) of this message. + * + * @return string + */ + public function getReturnPath() + { + return $this->_getHeaderFieldModel('Return-Path'); + } + + /** + * Set the sender of this message. + * + * This does not override the From field, but it has a higher significance. + * + * @param string $address + * @param string $name optional + * + * @return Swift_Mime_SimpleMessage + */ + public function setSender($address, $name = null) + { + if (!is_array($address) && isset($name)) { + $address = array($address => $name); + } + + if (!$this->_setHeaderFieldModel('Sender', (array) $address)) { + $this->getHeaders()->addMailboxHeader('Sender', (array) $address); + } + + return $this; + } + + /** + * Get the sender of this message. + * + * @return string + */ + public function getSender() + { + return $this->_getHeaderFieldModel('Sender'); + } + + /** + * Add a From: address to this message. + * + * If $name is passed this name will be associated with the address. + * + * @param string $address + * @param string $name optional + * + * @return Swift_Mime_SimpleMessage + */ + public function addFrom($address, $name = null) + { + $current = $this->getFrom(); + $current[$address] = $name; + + return $this->setFrom($current); + } + + /** + * Set the from address of this message. + * + * You may pass an array of addresses if this message is from multiple people. + * + * If $name is passed and the first parameter is a string, this name will be + * associated with the address. + * + * @param string $addresses + * @param string $name optional + * + * @return Swift_Mime_SimpleMessage + */ + public function setFrom($addresses, $name = null) + { + if (!is_array($addresses) && isset($name)) { + $addresses = array($addresses => $name); + } + + if (!$this->_setHeaderFieldModel('From', (array) $addresses)) { + $this->getHeaders()->addMailboxHeader('From', (array) $addresses); + } + + return $this; + } + + /** + * Get the from address of this message. + * + * @return string + */ + public function getFrom() + { + return $this->_getHeaderFieldModel('From'); + } + + /** + * Add a Reply-To: address to this message. + * + * If $name is passed this name will be associated with the address. + * + * @param string $address + * @param string $name optional + * + * @return Swift_Mime_SimpleMessage + */ + public function addReplyTo($address, $name = null) + { + $current = $this->getReplyTo(); + $current[$address] = $name; + + return $this->setReplyTo($current); + } + + /** + * Set the reply-to address of this message. + * + * You may pass an array of addresses if replies will go to multiple people. + * + * If $name is passed and the first parameter is a string, this name will be + * associated with the address. + * + * @param string $addresses + * @param string $name optional + * + * @return Swift_Mime_SimpleMessage + */ + public function setReplyTo($addresses, $name = null) + { + if (!is_array($addresses) && isset($name)) { + $addresses = array($addresses => $name); + } + + if (!$this->_setHeaderFieldModel('Reply-To', (array) $addresses)) { + $this->getHeaders()->addMailboxHeader('Reply-To', (array) $addresses); + } + + return $this; + } + + /** + * Get the reply-to address of this message. + * + * @return string + */ + public function getReplyTo() + { + return $this->_getHeaderFieldModel('Reply-To'); + } + + /** + * Add a To: address to this message. + * + * If $name is passed this name will be associated with the address. + * + * @param string $address + * @param string $name optional + * + * @return Swift_Mime_SimpleMessage + */ + public function addTo($address, $name = null) + { + $current = $this->getTo(); + $current[$address] = $name; + + return $this->setTo($current); + } + + /** + * Set the to addresses of this message. + * + * If multiple recipients will receive the message an array should be used. + * Example: array('receiver@domain.org', 'other@domain.org' => 'A name') + * + * If $name is passed and the first parameter is a string, this name will be + * associated with the address. + * + * @param mixed $addresses + * @param string $name optional + * + * @return Swift_Mime_SimpleMessage + */ + public function setTo($addresses, $name = null) + { + if (!is_array($addresses) && isset($name)) { + $addresses = array($addresses => $name); + } + + if (!$this->_setHeaderFieldModel('To', (array) $addresses)) { + $this->getHeaders()->addMailboxHeader('To', (array) $addresses); + } + + return $this; + } + + /** + * Get the To addresses of this message. + * + * @return array + */ + public function getTo() + { + return $this->_getHeaderFieldModel('To'); + } + + /** + * Add a Cc: address to this message. + * + * If $name is passed this name will be associated with the address. + * + * @param string $address + * @param string $name optional + * + * @return Swift_Mime_SimpleMessage + */ + public function addCc($address, $name = null) + { + $current = $this->getCc(); + $current[$address] = $name; + + return $this->setCc($current); + } + + /** + * Set the Cc addresses of this message. + * + * If $name is passed and the first parameter is a string, this name will be + * associated with the address. + * + * @param mixed $addresses + * @param string $name optional + * + * @return Swift_Mime_SimpleMessage + */ + public function setCc($addresses, $name = null) + { + if (!is_array($addresses) && isset($name)) { + $addresses = array($addresses => $name); + } + + if (!$this->_setHeaderFieldModel('Cc', (array) $addresses)) { + $this->getHeaders()->addMailboxHeader('Cc', (array) $addresses); + } + + return $this; + } + + /** + * Get the Cc address of this message. + * + * @return array + */ + public function getCc() + { + return $this->_getHeaderFieldModel('Cc'); + } + + /** + * Add a Bcc: address to this message. + * + * If $name is passed this name will be associated with the address. + * + * @param string $address + * @param string $name optional + * + * @return Swift_Mime_SimpleMessage + */ + public function addBcc($address, $name = null) + { + $current = $this->getBcc(); + $current[$address] = $name; + + return $this->setBcc($current); + } + + /** + * Set the Bcc addresses of this message. + * + * If $name is passed and the first parameter is a string, this name will be + * associated with the address. + * + * @param mixed $addresses + * @param string $name optional + * + * @return Swift_Mime_SimpleMessage + */ + public function setBcc($addresses, $name = null) + { + if (!is_array($addresses) && isset($name)) { + $addresses = array($addresses => $name); + } + + if (!$this->_setHeaderFieldModel('Bcc', (array) $addresses)) { + $this->getHeaders()->addMailboxHeader('Bcc', (array) $addresses); + } + + return $this; + } + + /** + * Get the Bcc addresses of this message. + * + * @return array + */ + public function getBcc() + { + return $this->_getHeaderFieldModel('Bcc'); + } + + /** + * Set the priority of this message. + * + * The value is an integer where 1 is the highest priority and 5 is the lowest. + * + * @param int $priority + * + * @return Swift_Mime_SimpleMessage + */ + public function setPriority($priority) + { + $priorityMap = array( + 1 => 'Highest', + 2 => 'High', + 3 => 'Normal', + 4 => 'Low', + 5 => 'Lowest' + ); + $pMapKeys = array_keys($priorityMap); + if ($priority > max($pMapKeys)) { + $priority = max($pMapKeys); + } elseif ($priority < min($pMapKeys)) { + $priority = min($pMapKeys); + } + if (!$this->_setHeaderFieldModel('X-Priority', + sprintf('%d (%s)', $priority, $priorityMap[$priority]))) + { + $this->getHeaders()->addTextHeader('X-Priority', + sprintf('%d (%s)', $priority, $priorityMap[$priority])); + } + + return $this; + } + + /** + * Get the priority of this message. + * + * The returned value is an integer where 1 is the highest priority and 5 + * is the lowest. + * + * @return int + */ + public function getPriority() + { + list($priority) = sscanf($this->_getHeaderFieldModel('X-Priority'), + '%[1-5]' + ); + + return isset($priority) ? $priority : 3; + } + + /** + * Ask for a delivery receipt from the recipient to be sent to $addresses + * + * @param array $addresses + * + * @return Swift_Mime_SimpleMessage + */ + public function setReadReceiptTo($addresses) + { + if (!$this->_setHeaderFieldModel('Disposition-Notification-To', $addresses)) { + $this->getHeaders() + ->addMailboxHeader('Disposition-Notification-To', $addresses); + } + + return $this; + } + + /** + * Get the addresses to which a read-receipt will be sent. + * + * @return string + */ + public function getReadReceiptTo() + { + return $this->_getHeaderFieldModel('Disposition-Notification-To'); + } + + /** + * Attach a {@link Swift_Mime_MimeEntity} such as an Attachment or MimePart. + * + * @param Swift_Mime_MimeEntity $entity + * + * @return Swift_Mime_SimpleMessage + */ + public function attach(Swift_Mime_MimeEntity $entity) + { + $this->setChildren(array_merge($this->getChildren(), array($entity))); + + return $this; + } + + /** + * Remove an already attached entity. + * + * @param Swift_Mime_MimeEntity $entity + * + * @return Swift_Mime_SimpleMessage + */ + public function detach(Swift_Mime_MimeEntity $entity) + { + $newChildren = array(); + foreach ($this->getChildren() as $child) { + if ($entity !== $child) { + $newChildren[] = $child; + } + } + $this->setChildren($newChildren); + + return $this; + } + + /** + * Attach a {@link Swift_Mime_MimeEntity} and return it's CID source. + * This method should be used when embedding images or other data in a message. + * + * @param Swift_Mime_MimeEntity $entity + * + * @return string + */ + public function embed(Swift_Mime_MimeEntity $entity) + { + $this->attach($entity); + + return 'cid:' . $entity->getId(); + } + + /** + * Get this message as a complete string. + * + * @return string + */ + public function toString() + { + if (count($children = $this->getChildren()) > 0 && $this->getBody() != '') { + $this->setChildren(array_merge(array($this->_becomeMimePart()), $children)); + $string = parent::toString(); + $this->setChildren($children); + } else { + $string = parent::toString(); + } + + return $string; + } + + /** + * Returns a string representation of this object. + * + * @see toString() + * + * @return string + */ + public function __toString() + { + return $this->toString(); + } + + /** + * Write this message to a {@link Swift_InputByteStream}. + * + * @param Swift_InputByteStream $is + */ + public function toByteStream(Swift_InputByteStream $is) + { + if (count($children = $this->getChildren()) > 0 && $this->getBody() != '') { + $this->setChildren(array_merge(array($this->_becomeMimePart()), $children)); + parent::toByteStream($is); + $this->setChildren($children); + } else { + parent::toByteStream($is); + } + } + + // -- Protected methods + + /** @see Swift_Mime_SimpleMimeEntity::_getIdField() */ + protected function _getIdField() + { + return 'Message-ID'; + } + + /** Turn the body of this message into a child of itself if needed */ + protected function _becomeMimePart() + { + $part = new parent($this->getHeaders()->newInstance(), $this->getEncoder(), + $this->_getCache(), $this->_getGrammar(), $this->_userCharset + ); + $part->setContentType($this->_userContentType); + $part->setBody($this->getBody()); + $part->setFormat($this->_userFormat); + $part->setDelSp($this->_userDelSp); + $part->_setNestingLevel($this->_getTopNestingLevel()); + + return $part; + } + + // -- Private methods + + /** Get the highest nesting level nested inside this message */ + private function _getTopNestingLevel() + { + $highestLevel = $this->getNestingLevel(); + foreach ($this->getChildren() as $child) { + $childLevel = $child->getNestingLevel(); + if ($highestLevel < $childLevel) { + $highestLevel = $childLevel; + } + } + + return $highestLevel; + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/SimpleMimeEntity.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/SimpleMimeEntity.php new file mode 100755 index 0000000..e2fc729 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/SimpleMimeEntity.php @@ -0,0 +1,859 @@ + array(self::LEVEL_TOP, self::LEVEL_MIXED), + 'multipart/alternative' => array(self::LEVEL_MIXED, self::LEVEL_ALTERNATIVE), + 'multipart/related' => array(self::LEVEL_ALTERNATIVE, self::LEVEL_RELATED) + ); + + /** A set of filter rules to define what level an entity should be nested at */ + private $_compoundLevelFilters = array(); + + /** The nesting level of this entity */ + private $_nestingLevel = self::LEVEL_ALTERNATIVE; + + /** A KeyCache instance used during encoding and streaming */ + private $_cache; + + /** Direct descendants of this entity */ + private $_immediateChildren = array(); + + /** All descendants of this entity */ + private $_children = array(); + + /** The maximum line length of the body of this entity */ + private $_maxLineLength = 78; + + /** The order in which alternative mime types should appear */ + private $_alternativePartOrder = array( + 'text/plain' => 1, + 'text/html' => 2, + 'multipart/related' => 3 + ); + + /** The CID of this entity */ + private $_id; + + /** The key used for accessing the cache */ + private $_cacheKey; + + protected $_userContentType; + + /** + * Create a new SimpleMimeEntity with $headers, $encoder and $cache. + * + * @param Swift_Mime_HeaderSet $headers + * @param Swift_Mime_ContentEncoder $encoder + * @param Swift_KeyCache $cache + * @param Swift_Mime_Grammar $grammar + */ + public function __construct(Swift_Mime_HeaderSet $headers, Swift_Mime_ContentEncoder $encoder, Swift_KeyCache $cache, Swift_Mime_Grammar $grammar) + { + $this->_cacheKey = md5(uniqid(getmypid().mt_rand(), true)); + $this->_cache = $cache; + $this->_headers = $headers; + $this->_grammar = $grammar; + $this->setEncoder($encoder); + $this->_headers->defineOrdering(array('Content-Type', 'Content-Transfer-Encoding')); + + // This array specifies that, when the entire MIME document contains + // $compoundLevel, then for each child within $level, if its Content-Type + // is $contentType then it should be treated as if it's level is + // $neededLevel instead. I tried to write that unambiguously! :-\ + // Data Structure: + // array ( + // $compoundLevel => array( + // $level => array( + // $contentType => $neededLevel + // ) + // ) + // ) + + $this->_compoundLevelFilters = array( + (self::LEVEL_ALTERNATIVE + self::LEVEL_RELATED) => array( + self::LEVEL_ALTERNATIVE => array( + 'text/plain' => self::LEVEL_ALTERNATIVE, + 'text/html' => self::LEVEL_RELATED + ) + ) + ); + + $this->_id = $this->getRandomId(); + } + + /** + * Generate a new Content-ID or Message-ID for this MIME entity. + * + * @return string + */ + public function generateId() + { + $this->setId($this->getRandomId()); + + return $this->_id; + } + + /** + * Get the {@link Swift_Mime_HeaderSet} for this entity. + * + * @return Swift_Mime_HeaderSet + */ + public function getHeaders() + { + return $this->_headers; + } + + /** + * Get the nesting level of this entity. + * + * @see LEVEL_TOP, LEVEL_MIXED, LEVEL_RELATED, LEVEL_ALTERNATIVE + * + * @return int + */ + public function getNestingLevel() + { + return $this->_nestingLevel; + } + + /** + * Get the Content-type of this entity. + * + * @return string + */ + public function getContentType() + { + return $this->_getHeaderFieldModel('Content-Type'); + } + + /** + * Set the Content-type of this entity. + * + * @param string $type + * + * @return Swift_Mime_SimpleMimeEntity + */ + public function setContentType($type) + { + $this->_setContentTypeInHeaders($type); + // Keep track of the value so that if the content-type changes automatically + // due to added child entities, it can be restored if they are later removed + $this->_userContentType = $type; + + return $this; + } + + /** + * Get the CID of this entity. + * + * The CID will only be present in headers if a Content-ID header is present. + * + * @return string + */ + public function getId() + { + $tmp = (array) $this->_getHeaderFieldModel($this->_getIdField()); + + return $this->_headers->has($this->_getIdField()) ? current($tmp) : $this->_id; + } + + /** + * Set the CID of this entity. + * + * @param string $id + * + * @return Swift_Mime_SimpleMimeEntity + */ + public function setId($id) + { + if (!$this->_setHeaderFieldModel($this->_getIdField(), $id)) { + $this->_headers->addIdHeader($this->_getIdField(), $id); + } + $this->_id = $id; + + return $this; + } + + /** + * Get the description of this entity. + * + * This value comes from the Content-Description header if set. + * + * @return string + */ + public function getDescription() + { + return $this->_getHeaderFieldModel('Content-Description'); + } + + /** + * Set the description of this entity. + * + * This method sets a value in the Content-ID header. + * + * @param string $description + * + * @return Swift_Mime_SimpleMimeEntity + */ + public function setDescription($description) + { + if (!$this->_setHeaderFieldModel('Content-Description', $description)) { + $this->_headers->addTextHeader('Content-Description', $description); + } + + return $this; + } + + /** + * Get the maximum line length of the body of this entity. + * + * @return int + */ + public function getMaxLineLength() + { + return $this->_maxLineLength; + } + + /** + * Set the maximum line length of lines in this body. + * + * Though not enforced by the library, lines should not exceed 1000 chars. + * + * @param int $length + * + * @return Swift_Mime_SimpleMimeEntity + */ + public function setMaxLineLength($length) + { + $this->_maxLineLength = $length; + + return $this; + } + + /** + * Get all children added to this entity. + * + * @return array of Swift_Mime_Entity + */ + public function getChildren() + { + return $this->_children; + } + + /** + * Set all children of this entity. + * + * @param array $children Swift_Mime_Entity instances + * @param int $compoundLevel For internal use only + * + * @return Swift_Mime_SimpleMimeEntity + */ + public function setChildren(array $children, $compoundLevel = null) + { + // TODO: Try to refactor this logic + + $compoundLevel = isset($compoundLevel) + ? $compoundLevel + : $this->_getCompoundLevel($children) + ; + + $immediateChildren = array(); + $grandchildren = array(); + $newContentType = $this->_userContentType; + + foreach ($children as $child) { + $level = $this->_getNeededChildLevel($child, $compoundLevel); + if (empty($immediateChildren)) { //first iteration + $immediateChildren = array($child); + } else { + $nextLevel = $this->_getNeededChildLevel($immediateChildren[0], $compoundLevel); + if ($nextLevel == $level) { + $immediateChildren[] = $child; + } elseif ($level < $nextLevel) { + // Re-assign immediateChildren to grandchildren + $grandchildren = array_merge($grandchildren, $immediateChildren); + // Set new children + $immediateChildren = array($child); + } else { + $grandchildren[] = $child; + } + } + } + + if (!empty($immediateChildren)) { + $lowestLevel = $this->_getNeededChildLevel($immediateChildren[0], $compoundLevel); + + // Determine which composite media type is needed to accommodate the + // immediate children + foreach ($this->_compositeRanges as $mediaType => $range) { + if ($lowestLevel > $range[0] + && $lowestLevel <= $range[1]) + { + $newContentType = $mediaType; + break; + } + } + + // Put any grandchildren in a subpart + if (!empty($grandchildren)) { + $subentity = $this->_createChild(); + $subentity->_setNestingLevel($lowestLevel); + $subentity->setChildren($grandchildren, $compoundLevel); + array_unshift($immediateChildren, $subentity); + } + } + + $this->_immediateChildren = $immediateChildren; + $this->_children = $children; + $this->_setContentTypeInHeaders($newContentType); + $this->_fixHeaders(); + $this->_sortChildren(); + + return $this; + } + + /** + * Get the body of this entity as a string. + * + * @return string + */ + public function getBody() + { + return ($this->_body instanceof Swift_OutputByteStream) + ? $this->_readStream($this->_body) + : $this->_body; + } + + /** + * Set the body of this entity, either as a string, or as an instance of + * {@link Swift_OutputByteStream}. + * + * @param mixed $body + * @param string $contentType optional + * + * @return Swift_Mime_SimpleMimeEntity + */ + public function setBody($body, $contentType = null) + { + if ($body !== $this->_body) { + $this->_clearCache(); + } + + $this->_body = $body; + if (isset($contentType)) { + $this->setContentType($contentType); + } + + return $this; + } + + /** + * Get the encoder used for the body of this entity. + * + * @return Swift_Mime_ContentEncoder + */ + public function getEncoder() + { + return $this->_encoder; + } + + /** + * Set the encoder used for the body of this entity. + * + * @param Swift_Mime_ContentEncoder $encoder + * + * @return Swift_Mime_SimpleMimeEntity + */ + public function setEncoder(Swift_Mime_ContentEncoder $encoder) + { + if ($encoder !== $this->_encoder) { + $this->_clearCache(); + } + + $this->_encoder = $encoder; + $this->_setEncoding($encoder->getName()); + $this->_notifyEncoderChanged($encoder); + + return $this; + } + + /** + * Get the boundary used to separate children in this entity. + * + * @return string + */ + public function getBoundary() + { + if (!isset($this->_boundary)) { + $this->_boundary = '_=_swift_v4_' . time() . '_' . md5(getmypid().mt_rand().uniqid('', true)) . '_=_'; + } + + return $this->_boundary; + } + + /** + * Set the boundary used to separate children in this entity. + * + * @param string $boundary + * + * @return Swift_Mime_SimpleMimeEntity + * + * @throws Swift_RfcComplianceException + */ + public function setBoundary($boundary) + { + $this->_assertValidBoundary($boundary); + $this->_boundary = $boundary; + + return $this; + } + + /** + * Receive notification that the charset of this entity, or a parent entity + * has changed. + * + * @param string $charset + */ + public function charsetChanged($charset) + { + $this->_notifyCharsetChanged($charset); + } + + /** + * Receive notification that the encoder of this entity or a parent entity + * has changed. + * + * @param Swift_Mime_ContentEncoder $encoder + */ + public function encoderChanged(Swift_Mime_ContentEncoder $encoder) + { + $this->_notifyEncoderChanged($encoder); + } + + /** + * Get this entire entity as a string. + * + * @return string + */ + public function toString() + { + $string = $this->_headers->toString(); + $string .= $this->_bodyToString(); + + return $string; + } + + /** + * Get this entire entity as a string. + * + * @return string + */ + protected function _bodyToString() + { + $string = ''; + + if (isset($this->_body) && empty($this->_immediateChildren)) { + if ($this->_cache->hasKey($this->_cacheKey, 'body')) { + $body = $this->_cache->getString($this->_cacheKey, 'body'); + } else { + $body = "\r\n" . $this->_encoder->encodeString($this->getBody(), 0, + $this->getMaxLineLength() + ); + $this->_cache->setString($this->_cacheKey, 'body', $body, + Swift_KeyCache::MODE_WRITE + ); + } + $string .= $body; + } + + if (!empty($this->_immediateChildren)) { + foreach ($this->_immediateChildren as $child) { + $string .= "\r\n\r\n--" . $this->getBoundary() . "\r\n"; + $string .= $child->toString(); + } + $string .= "\r\n\r\n--" . $this->getBoundary() . "--\r\n"; + } + + return $string; + } + + /** + * Returns a string representation of this object. + * + * @see toString() + * + * @return string + */ + public function __toString() + { + return $this->toString(); + } + + /** + * Write this entire entity to a {@see Swift_InputByteStream}. + * + * @param Swift_InputByteStream + */ + public function toByteStream(Swift_InputByteStream $is) + { + $is->write($this->_headers->toString()); + $is->commit(); + + $this->_bodyToByteStream($is); + } + + /** + * Write this entire entity to a {@link Swift_InputByteStream}. + * + * @param Swift_InputByteStream + */ + protected function _bodyToByteStream(Swift_InputByteStream $is) + { + if (empty($this->_immediateChildren)) { + if (isset($this->_body)) { + if ($this->_cache->hasKey($this->_cacheKey, 'body')) { + $this->_cache->exportToByteStream($this->_cacheKey, 'body', $is); + } else { + $cacheIs = $this->_cache->getInputByteStream($this->_cacheKey, 'body'); + if ($cacheIs) { + $is->bind($cacheIs); + } + + $is->write("\r\n"); + + if ($this->_body instanceof Swift_OutputByteStream) { + $this->_body->setReadPointer(0); + + $this->_encoder->encodeByteStream($this->_body, $is, 0, $this->getMaxLineLength()); + } else { + $is->write($this->_encoder->encodeString($this->getBody(), 0, $this->getMaxLineLength())); + } + + if ($cacheIs) { + $is->unbind($cacheIs); + } + } + } + } + + if (!empty($this->_immediateChildren)) { + foreach ($this->_immediateChildren as $child) { + $is->write("\r\n\r\n--" . $this->getBoundary() . "\r\n"); + $child->toByteStream($is); + } + $is->write("\r\n\r\n--" . $this->getBoundary() . "--\r\n"); + } + } + + // -- Protected methods + + /** + * Get the name of the header that provides the ID of this entity + */ + protected function _getIdField() + { + return 'Content-ID'; + } + + /** + * Get the model data (usually an array or a string) for $field. + */ + protected function _getHeaderFieldModel($field) + { + if ($this->_headers->has($field)) { + return $this->_headers->get($field)->getFieldBodyModel(); + } + } + + /** + * Set the model data for $field. + */ + protected function _setHeaderFieldModel($field, $model) + { + if ($this->_headers->has($field)) { + $this->_headers->get($field)->setFieldBodyModel($model); + + return true; + } else { + return false; + } + } + + /** + * Get the parameter value of $parameter on $field header. + */ + protected function _getHeaderParameter($field, $parameter) + { + if ($this->_headers->has($field)) { + return $this->_headers->get($field)->getParameter($parameter); + } + } + + /** + * Set the parameter value of $parameter on $field header. + */ + protected function _setHeaderParameter($field, $parameter, $value) + { + if ($this->_headers->has($field)) { + $this->_headers->get($field)->setParameter($parameter, $value); + + return true; + } else { + return false; + } + } + + /** + * Re-evaluate what content type and encoding should be used on this entity. + */ + protected function _fixHeaders() + { + if (count($this->_immediateChildren)) { + $this->_setHeaderParameter('Content-Type', 'boundary', + $this->getBoundary() + ); + $this->_headers->remove('Content-Transfer-Encoding'); + } else { + $this->_setHeaderParameter('Content-Type', 'boundary', null); + $this->_setEncoding($this->_encoder->getName()); + } + } + + /** + * Get the KeyCache used in this entity. + * + * @return Swift_KeyCache + */ + protected function _getCache() + { + return $this->_cache; + } + + /** + * Get the grammar used for validation. + * + * @return Swift_Mime_Grammar + */ + protected function _getGrammar() + { + return $this->_grammar; + } + + /** + * Empty the KeyCache for this entity. + */ + protected function _clearCache() + { + $this->_cache->clearKey($this->_cacheKey, 'body'); + } + + /** + * Returns a random Content-ID or Message-ID. + * + * @return string + */ + protected function getRandomId() + { + $idLeft = md5(getmypid() . '.' . time() . '.' . uniqid(mt_rand(), true)); + $idRight = !empty($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : 'swift.generated'; + $id = $idLeft . '@' . $idRight; + + try { + $this->_assertValidId($id); + } catch (Swift_RfcComplianceException $e) { + $id = $idLeft . '@swift.generated'; + } + + return $id; + } + + // -- Private methods + + private function _readStream(Swift_OutputByteStream $os) + { + $string = ''; + while (false !== $bytes = $os->read(8192)) { + $string .= $bytes; + } + + return $string; + } + + private function _setEncoding($encoding) + { + if (!$this->_setHeaderFieldModel('Content-Transfer-Encoding', $encoding)) { + $this->_headers->addTextHeader('Content-Transfer-Encoding', $encoding); + } + } + + private function _assertValidBoundary($boundary) + { + if (!preg_match( + '/^[a-z0-9\'\(\)\+_\-,\.\/:=\?\ ]{0,69}[a-z0-9\'\(\)\+_\-,\.\/:=\?]$/Di', + $boundary)) + { + throw new Swift_RfcComplianceException('Mime boundary set is not RFC 2046 compliant.'); + } + } + + private function _setContentTypeInHeaders($type) + { + if (!$this->_setHeaderFieldModel('Content-Type', $type)) { + $this->_headers->addParameterizedHeader('Content-Type', $type); + } + } + + private function _setNestingLevel($level) + { + $this->_nestingLevel = $level; + } + + private function _getCompoundLevel($children) + { + $level = 0; + foreach ($children as $child) { + $level |= $child->getNestingLevel(); + } + + return $level; + } + + private function _getNeededChildLevel($child, $compoundLevel) + { + $filter = array(); + foreach ($this->_compoundLevelFilters as $bitmask => $rules) { + if (($compoundLevel & $bitmask) === $bitmask) { + $filter = $rules + $filter; + } + } + + $realLevel = $child->getNestingLevel(); + $lowercaseType = strtolower($child->getContentType()); + + if (isset($filter[$realLevel]) + && isset($filter[$realLevel][$lowercaseType])) + { + return $filter[$realLevel][$lowercaseType]; + } else { + return $realLevel; + } + } + + private function _createChild() + { + return new self($this->_headers->newInstance(), + $this->_encoder, $this->_cache, $this->_grammar); + } + + private function _notifyEncoderChanged(Swift_Mime_ContentEncoder $encoder) + { + foreach ($this->_immediateChildren as $child) { + $child->encoderChanged($encoder); + } + } + + private function _notifyCharsetChanged($charset) + { + $this->_encoder->charsetChanged($charset); + $this->_headers->charsetChanged($charset); + foreach ($this->_immediateChildren as $child) { + $child->charsetChanged($charset); + } + } + + private function _sortChildren() + { + $shouldSort = false; + foreach ($this->_immediateChildren as $child) { + // NOTE: This include alternative parts moved into a related part + if ($child->getNestingLevel() == self::LEVEL_ALTERNATIVE) { + $shouldSort = true; + break; + } + } + + // Sort in order of preference, if there is one + if ($shouldSort) { + usort($this->_immediateChildren, array($this, '_childSortAlgorithm')); + } + } + + private function _childSortAlgorithm($a, $b) + { + $typePrefs = array(); + $types = array( + strtolower($a->getContentType()), + strtolower($b->getContentType()) + ); + foreach ($types as $type) { + $typePrefs[] = (array_key_exists($type, $this->_alternativePartOrder)) + ? $this->_alternativePartOrder[$type] + : (max($this->_alternativePartOrder) + 1); + } + + return ($typePrefs[0] >= $typePrefs[1]) ? 1 : -1; + } + + // -- Destructor + + /** + * Empties it's own contents from the cache. + */ + public function __destruct() + { + $this->_cache->clearAll($this->_cacheKey); + } + + /** + * Throws an Exception if the id passed does not comply with RFC 2822. + * + * @param string $id + * + * @throws Swift_RfcComplianceException + */ + private function _assertValidId($id) + { + if (!preg_match( + '/^' . $this->_grammar->getDefinition('id-left') . '@' . + $this->_grammar->getDefinition('id-right') . '$/D', + $id + )) + { + throw new Swift_RfcComplianceException( + 'Invalid ID given <' . $id . '>' + ); + } + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/MimePart.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/MimePart.php new file mode 100755 index 0000000..10a4f3c --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/MimePart.php @@ -0,0 +1,61 @@ +createDependenciesFor('mime.part') + ); + + if (!isset($charset)) { + $charset = Swift_DependencyContainer::getInstance() + ->lookup('properties.charset'); + } + $this->setBody($body); + $this->setCharset($charset); + if ($contentType) { + $this->setContentType($contentType); + } + } + + /** + * Create a new MimePart. + * + * @param string $body + * @param string $contentType + * @param string $charset + * + * @return Swift_Mime_MimePart + */ + public static function newInstance($body = null, $contentType = null, $charset = null) + { + return new self($body, $contentType, $charset); + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/NullTransport.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/NullTransport.php new file mode 100755 index 0000000..335c479 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/NullTransport.php @@ -0,0 +1,40 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +/** + * Pretends messages have been sent, but just ignores them. + * + * @package Swift + * @author Fabien Potencier + */ +class Swift_NullTransport extends Swift_Transport_NullTransport +{ + /** + * Create a new NullTransport. + */ + public function __construct() + { + call_user_func_array( + array($this, 'Swift_Transport_NullTransport::__construct'), + Swift_DependencyContainer::getInstance() + ->createDependenciesFor('transport.null') + ); + } + + /** + * Create a new NullTransport instance. + * + * @return Swift_NullTransport + */ + public static function newInstance() + { + return new self(); + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/OutputByteStream.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/OutputByteStream.php new file mode 100755 index 0000000..47faa73 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/OutputByteStream.php @@ -0,0 +1,48 @@ +setThreshold($threshold); + $this->setSleepTime($sleep); + $this->_sleeper = $sleeper; + } + + /** + * Set the number of emails to send before restarting. + * + * @param int $threshold + */ + public function setThreshold($threshold) + { + $this->_threshold = $threshold; + } + + /** + * Get the number of emails to send before restarting. + * + * @return int + */ + public function getThreshold() + { + return $this->_threshold; + } + + /** + * Set the number of seconds to sleep for during a restart. + * + * @param int $sleep time + */ + public function setSleepTime($sleep) + { + $this->_sleep = $sleep; + } + + /** + * Get the number of seconds to sleep for during a restart. + * + * @return int + */ + public function getSleepTime() + { + return $this->_sleep; + } + + /** + * Invoked immediately before the Message is sent. + * + * @param Swift_Events_SendEvent $evt + */ + public function beforeSendPerformed(Swift_Events_SendEvent $evt) + { + } + + /** + * Invoked immediately after the Message is sent. + * + * @param Swift_Events_SendEvent $evt + */ + public function sendPerformed(Swift_Events_SendEvent $evt) + { + ++$this->_counter; + if ($this->_counter >= $this->_threshold) { + $transport = $evt->getTransport(); + $transport->stop(); + if ($this->_sleep) { + $this->sleep($this->_sleep); + } + $transport->start(); + $this->_counter = 0; + } + } + + /** + * Sleep for $seconds. + * + * @param int $seconds + */ + public function sleep($seconds) + { + if (isset($this->_sleeper)) { + $this->_sleeper->sleep($seconds); + } else { + sleep($seconds); + } + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/BandwidthMonitorPlugin.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/BandwidthMonitorPlugin.php new file mode 100755 index 0000000..8794aac --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/BandwidthMonitorPlugin.php @@ -0,0 +1,166 @@ +getMessage(); + $message->toByteStream($this); + } + + /** + * Invoked immediately following a command being sent. + * + * @param Swift_Events_CommandEvent $evt + */ + public function commandSent(Swift_Events_CommandEvent $evt) + { + $command = $evt->getCommand(); + $this->_out += strlen($command); + } + + /** + * Invoked immediately following a response coming back. + * + * @param Swift_Events_ResponseEvent $evt + */ + public function responseReceived(Swift_Events_ResponseEvent $evt) + { + $response = $evt->getResponse(); + $this->_in += strlen($response); + } + + /** + * Called when a message is sent so that the outgoing counter can be increased. + * + * @param string $bytes + */ + public function write($bytes) + { + $this->_out += strlen($bytes); + foreach ($this->_mirrors as $stream) { + $stream->write($bytes); + } + } + + /** + * Not used. + */ + public function commit() + { + } + + /** + * Attach $is to this stream. + * + * The stream acts as an observer, receiving all data that is written. + * All {@link write()} and {@link flushBuffers()} operations will be mirrored. + * + * @param Swift_InputByteStream $is + */ + public function bind(Swift_InputByteStream $is) + { + $this->_mirrors[] = $is; + } + + /** + * Remove an already bound stream. + * + * If $is is not bound, no errors will be raised. + * If the stream currently has any buffered data it will be written to $is + * before unbinding occurs. + * + * @param Swift_InputByteStream $is + */ + public function unbind(Swift_InputByteStream $is) + { + foreach ($this->_mirrors as $k => $stream) { + if ($is === $stream) { + unset($this->_mirrors[$k]); + } + } + } + + /** + * Not used. + */ + public function flushBuffers() + { + foreach ($this->_mirrors as $stream) { + $stream->flushBuffers(); + } + } + + /** + * Get the total number of bytes sent to the server. + * + * @return int + */ + public function getBytesOut() + { + return $this->_out; + } + + /** + * Get the total number of bytes received from the server. + * + * @return int + */ + public function getBytesIn() + { + return $this->_in; + } + + /** + * Reset the internal counters to zero. + */ + public function reset() + { + $this->_out = 0; + $this->_in = 0; + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Decorator/Replacements.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Decorator/Replacements.php new file mode 100755 index 0000000..3269c69 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Decorator/Replacements.php @@ -0,0 +1,33 @@ + + * $replacements = array( + * "address1@domain.tld" => array("{a}" => "b", "{c}" => "d"), + * "address2@domain.tld" => array("{a}" => "x", "{c}" => "y") + * ) + * + * + * When using an instance of {@link Swift_Plugins_Decorator_Replacements}, + * the object should return just the array of replacements for the address + * given to {@link Swift_Plugins_Decorator_Replacements::getReplacementsFor()}. + * + * @param mixed $replacements Array or Swift_Plugins_Decorator_Replacements + */ + public function __construct($replacements) + { + $this->setReplacements($replacements); + } + + /** + * Sets replacements. + * + * @param mixed $replacements Array or Swift_Plugins_Decorator_Replacements + * + * @see __construct() + */ + public function setReplacements($replacements) + { + if (!($replacements instanceof Swift_Plugins_Decorator_Replacements)) { + $this->_replacements = (array) $replacements; + } else { + $this->_replacements = $replacements; + } + } + + /** + * Invoked immediately before the Message is sent. + * + * @param Swift_Events_SendEvent $evt + */ + public function beforeSendPerformed(Swift_Events_SendEvent $evt) + { + $message = $evt->getMessage(); + $this->_restoreMessage($message); + $to = array_keys($message->getTo()); + $address = array_shift($to); + if ($replacements = $this->getReplacementsFor($address)) { + $body = $message->getBody(); + $search = array_keys($replacements); + $replace = array_values($replacements); + $bodyReplaced = str_replace( + $search, $replace, $body + ); + if ($body != $bodyReplaced) { + $this->_originalBody = $body; + $message->setBody($bodyReplaced); + } + + foreach ($message->getHeaders()->getAll() as $header) { + $body = $header->getFieldBodyModel(); + $count = 0; + if (is_array($body)) { + $bodyReplaced = array(); + foreach ($body as $key => $value) { + $count1 = 0; + $count2 = 0; + $key = is_string($key) ? str_replace($search, $replace, $key, $count1) : $key; + $value = is_string($value) ? str_replace($search, $replace, $value, $count2) : $value; + $bodyReplaced[$key] = $value; + + if (!$count && ($count1 || $count2)) { + $count = 1; + } + } + } else { + $bodyReplaced = str_replace($search, $replace, $body, $count); + } + + if ($count) { + $this->_originalHeaders[$header->getFieldName()] = $body; + $header->setFieldBodyModel($bodyReplaced); + } + } + + $children = (array) $message->getChildren(); + foreach ($children as $child) { + list($type, ) = sscanf($child->getContentType(), '%[^/]/%s'); + if ('text' == $type) { + $body = $child->getBody(); + $bodyReplaced = str_replace( + $search, $replace, $body + ); + if ($body != $bodyReplaced) { + $child->setBody($bodyReplaced); + $this->_originalChildBodies[$child->getId()] = $body; + } + } + } + $this->_lastMessage = $message; + } + } + + /** + * Find a map of replacements for the address. + * + * If this plugin was provided with a delegate instance of + * {@link Swift_Plugins_Decorator_Replacements} then the call will be + * delegated to it. Otherwise, it will attempt to find the replacements + * from the array provided in the constructor. + * + * If no replacements can be found, an empty value (NULL) is returned. + * + * @param string $address + * + * @return array + */ + public function getReplacementsFor($address) + { + if ($this->_replacements instanceof Swift_Plugins_Decorator_Replacements) { + return $this->_replacements->getReplacementsFor($address); + } else { + return isset($this->_replacements[$address]) + ? $this->_replacements[$address] + : null + ; + } + } + + /** + * Invoked immediately after the Message is sent. + * + * @param Swift_Events_SendEvent $evt + */ + public function sendPerformed(Swift_Events_SendEvent $evt) + { + $this->_restoreMessage($evt->getMessage()); + } + + // -- Private methods + + /** Restore a changed message back to its original state */ + private function _restoreMessage(Swift_Mime_Message $message) + { + if ($this->_lastMessage === $message) { + if (isset($this->_originalBody)) { + $message->setBody($this->_originalBody); + $this->_originalBody = null; + } + if (!empty($this->_originalHeaders)) { + foreach ($message->getHeaders()->getAll() as $header) { + if (array_key_exists($header->getFieldName(), $this->_originalHeaders)) { + $header->setFieldBodyModel($this->_originalHeaders[$header->getFieldName()]); + } + } + $this->_originalHeaders = array(); + } + if (!empty($this->_originalChildBodies)) { + $children = (array) $message->getChildren(); + foreach ($children as $child) { + $id = $child->getId(); + if (array_key_exists($id, $this->_originalChildBodies)) { + $child->setBody($this->_originalChildBodies[$id]); + } + } + $this->_originalChildBodies = array(); + } + $this->_lastMessage = null; + } + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/ImpersonatePlugin.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/ImpersonatePlugin.php new file mode 100755 index 0000000..1f1e443 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/ImpersonatePlugin.php @@ -0,0 +1,70 @@ +_sender = $sender; + } + + /** + * Invoked immediately before the Message is sent. + * + * @param Swift_Events_SendEvent $evt + */ + public function beforeSendPerformed(Swift_Events_SendEvent $evt) + { + $message = $evt->getMessage(); + $headers = $message->getHeaders(); + + // save current recipients + $headers->addPathHeader('X-Swift-Return-Path', $message->getReturnPath()); + + // replace them with the one to send to + $message->setReturnPath($this->_sender); + } + + /** + * Invoked immediately after the Message is sent. + * + * @param Swift_Events_SendEvent $evt + */ + public function sendPerformed(Swift_Events_SendEvent $evt) + { + $message = $evt->getMessage(); + + // restore original headers + $headers = $message->getHeaders(); + + if ($headers->has('X-Swift-Return-Path')) { + $message->setReturnPath($headers->get('X-Swift-Return-Path')->getAddress()); + $headers->removeAll('X-Swift-Return-Path'); + } + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Logger.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Logger.php new file mode 100755 index 0000000..81c1d9b --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Logger.php @@ -0,0 +1,38 @@ +_logger = $logger; + } + + /** + * Add a log entry. + * + * @param string $entry + */ + public function add($entry) + { + $this->_logger->add($entry); + } + + /** + * Clear the log contents. + */ + public function clear() + { + $this->_logger->clear(); + } + + /** + * Get this log as a string. + * + * @return string + */ + public function dump() + { + return $this->_logger->dump(); + } + + /** + * Invoked immediately following a command being sent. + * + * @param Swift_Events_CommandEvent $evt + */ + public function commandSent(Swift_Events_CommandEvent $evt) + { + $command = $evt->getCommand(); + $this->_logger->add(sprintf(">> %s", $command)); + } + + /** + * Invoked immediately following a response coming back. + * + * @param Swift_Events_ResponseEvent $evt + */ + public function responseReceived(Swift_Events_ResponseEvent $evt) + { + $response = $evt->getResponse(); + $this->_logger->add(sprintf("<< %s", $response)); + } + + /** + * Invoked just before a Transport is started. + * + * @param Swift_Events_TransportChangeEvent $evt + */ + public function beforeTransportStarted(Swift_Events_TransportChangeEvent $evt) + { + $transportName = get_class($evt->getSource()); + $this->_logger->add(sprintf("++ Starting %s", $transportName)); + } + + /** + * Invoked immediately after the Transport is started. + * + * @param Swift_Events_TransportChangeEvent $evt + */ + public function transportStarted(Swift_Events_TransportChangeEvent $evt) + { + $transportName = get_class($evt->getSource()); + $this->_logger->add(sprintf("++ %s started", $transportName)); + } + + /** + * Invoked just before a Transport is stopped. + * + * @param Swift_Events_TransportChangeEvent $evt + */ + public function beforeTransportStopped(Swift_Events_TransportChangeEvent $evt) + { + $transportName = get_class($evt->getSource()); + $this->_logger->add(sprintf("++ Stopping %s", $transportName)); + } + + /** + * Invoked immediately after the Transport is stopped. + * + * @param Swift_Events_TransportChangeEvent $evt + */ + public function transportStopped(Swift_Events_TransportChangeEvent $evt) + { + $transportName = get_class($evt->getSource()); + $this->_logger->add(sprintf("++ %s stopped", $transportName)); + } + + /** + * Invoked as a TransportException is thrown in the Transport system. + * + * @param Swift_Events_TransportExceptionEvent $evt + */ + public function exceptionThrown(Swift_Events_TransportExceptionEvent $evt) + { + $e = $evt->getException(); + $message = $e->getMessage(); + $this->_logger->add(sprintf("!! %s", $message)); + $message .= PHP_EOL; + $message .= 'Log data:' . PHP_EOL; + $message .= $this->_logger->dump(); + $evt->cancelBubble(); + throw new Swift_TransportException($message); + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Loggers/ArrayLogger.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Loggers/ArrayLogger.php new file mode 100755 index 0000000..eb362ef --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Loggers/ArrayLogger.php @@ -0,0 +1,74 @@ +_size = $size; + } + + /** + * Add a log entry. + * + * @param string $entry + */ + public function add($entry) + { + $this->_log[] = $entry; + while (count($this->_log) > $this->_size) { + array_shift($this->_log); + } + } + + /** + * Clear the log contents. + */ + public function clear() + { + $this->_log = array(); + } + + /** + * Get this log as a string. + * + * @return string + */ + public function dump() + { + return implode(PHP_EOL, $this->_log); + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Loggers/EchoLogger.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Loggers/EchoLogger.php new file mode 100755 index 0000000..73b9554 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Loggers/EchoLogger.php @@ -0,0 +1,60 @@ +_isHtml = $isHtml; + } + + /** + * Add a log entry. + * + * @param string $entry + */ + public function add($entry) + { + if ($this->_isHtml) { + printf('%s%s%s', htmlspecialchars($entry, ENT_QUOTES), '
    ', PHP_EOL); + } else { + printf('%s%s', $entry, PHP_EOL); + } + } + + /** + * Not implemented. + */ + public function clear() + { + } + + /** + * Not implemented. + */ + public function dump() + { + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/MessageLogger.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/MessageLogger.php new file mode 100755 index 0000000..b5dfa8b --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/MessageLogger.php @@ -0,0 +1,77 @@ +messages = array(); + } + + /** + * Get the message list + * + * @return array + */ + public function getMessages() + { + return $this->messages; + } + + /** + * Get the message count + * + * @return int count + */ + public function countMessages() + { + return count($this->messages); + } + + /** + * Empty the message list + * + */ + public function clear() + { + $this->messages = array(); + } + + /** + * Invoked immediately before the Message is sent. + * + * @param Swift_Events_SendEvent $evt + */ + public function beforeSendPerformed(Swift_Events_SendEvent $evt) + { + $this->messages[] = clone $evt->getMessage(); + } + + /** + * Invoked immediately after the Message is sent. + * + * @param Swift_Events_SendEvent $evt + */ + public function sendPerformed(Swift_Events_SendEvent $evt) + { + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Pop/Pop3Connection.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Pop/Pop3Connection.php new file mode 100755 index 0000000..d241721 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Pop/Pop3Connection.php @@ -0,0 +1,33 @@ +_host = $host; + $this->_port = $port; + $this->_crypto = $crypto; + } + + /** + * Create a new PopBeforeSmtpPlugin for $host and $port. + * + * @param string $host + * @param int $port + * @param string $crypto as "tls" or "ssl" + * + * @return Swift_Plugins_PopBeforeSmtpPlugin + */ + public static function newInstance($host, $port = 110, $crypto = null) + { + return new self($host, $port, $crypto); + } + + /** + * Set a Pop3Connection to delegate to instead of connecting directly. + * + * @param Swift_Plugins_Pop_Pop3Connection $connection + * + * @return Swift_Plugins_PopBeforeSmtpPlugin + */ + public function setConnection(Swift_Plugins_Pop_Pop3Connection $connection) + { + $this->_connection = $connection; + + return $this; + } + + /** + * Bind this plugin to a specific SMTP transport instance. + * + * @param Swift_Transport + */ + public function bindSmtp(Swift_Transport $smtp) + { + $this->_transport = $smtp; + } + + /** + * Set the connection timeout in seconds (default 10). + * + * @param int $timeout + * + * @return Swift_Plugins_PopBeforeSmtpPlugin + */ + public function setTimeout($timeout) + { + $this->_timeout = (int) $timeout; + + return $this; + } + + /** + * Set the username to use when connecting (if needed). + * + * @param string $username + * + * @return Swift_Plugins_PopBeforeSmtpPlugin + */ + public function setUsername($username) + { + $this->_username = $username; + + return $this; + } + + /** + * Set the password to use when connecting (if needed). + * + * @param string $password + * + * @return Swift_Plugins_PopBeforeSmtpPlugin + */ + public function setPassword($password) + { + $this->_password = $password; + + return $this; + } + + /** + * Connect to the POP3 host and authenticate. + * + * @throws Swift_Plugins_Pop_Pop3Exception if connection fails + */ + public function connect() + { + if (isset($this->_connection)) { + $this->_connection->connect(); + } else { + if (!isset($this->_socket)) { + if (!$socket = fsockopen( + $this->_getHostString(), $this->_port, $errno, $errstr, $this->_timeout)) + { + throw new Swift_Plugins_Pop_Pop3Exception( + sprintf('Failed to connect to POP3 host [%s]: %s', $this->_host, $errstr) + ); + } + $this->_socket = $socket; + + if (false === $greeting = fgets($this->_socket)) { + throw new Swift_Plugins_Pop_Pop3Exception( + sprintf('Failed to connect to POP3 host [%s]', trim($greeting)) + ); + } + + $this->_assertOk($greeting); + + if ($this->_username) { + $this->_command(sprintf("USER %s\r\n", $this->_username)); + $this->_command(sprintf("PASS %s\r\n", $this->_password)); + } + } + } + } + + /** + * Disconnect from the POP3 host. + */ + public function disconnect() + { + if (isset($this->_connection)) { + $this->_connection->disconnect(); + } else { + $this->_command("QUIT\r\n"); + if (!fclose($this->_socket)) { + throw new Swift_Plugins_Pop_Pop3Exception( + sprintf('POP3 host [%s] connection could not be stopped', $this->_host) + ); + } + $this->_socket = null; + } + } + + /** + * Invoked just before a Transport is started. + * + * @param Swift_Events_TransportChangeEvent $evt + */ + public function beforeTransportStarted(Swift_Events_TransportChangeEvent $evt) + { + if (isset($this->_transport)) { + if ($this->_transport !== $evt->getTransport()) { + return; + } + } + + $this->connect(); + $this->disconnect(); + } + + /** + * Not used. + */ + public function transportStarted(Swift_Events_TransportChangeEvent $evt) + { + } + + /** + * Not used. + */ + public function beforeTransportStopped(Swift_Events_TransportChangeEvent $evt) + { + } + + /** + * Not used. + */ + public function transportStopped(Swift_Events_TransportChangeEvent $evt) + { + } + + // -- Private Methods + + private function _command($command) + { + if (!fwrite($this->_socket, $command)) { + throw new Swift_Plugins_Pop_Pop3Exception( + sprintf('Failed to write command [%s] to POP3 host', trim($command)) + ); + } + + if (false === $response = fgets($this->_socket)) { + throw new Swift_Plugins_Pop_Pop3Exception( + sprintf('Failed to read from POP3 host after command [%s]', trim($command)) + ); + } + + $this->_assertOk($response); + + return $response; + } + + private function _assertOk($response) + { + if (substr($response, 0, 3) != '+OK') { + throw new Swift_Plugins_Pop_Pop3Exception( + sprintf('POP3 command failed [%s]', trim($response)) + ); + } + } + + private function _getHostString() + { + $host = $this->_host; + switch (strtolower($this->_crypto)) { + case 'ssl': + $host = 'ssl://' . $host; + break; + + case 'tls': + $host = 'tls://' . $host; + break; + } + + return $host; + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/RedirectingPlugin.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/RedirectingPlugin.php new file mode 100755 index 0000000..3b006b6 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/RedirectingPlugin.php @@ -0,0 +1,209 @@ +_recipient = $recipient; + $this->_whitelist = $whitelist; + } + + /** + * Set the recipient of all messages. + * + * @param mixed $recipient + */ + public function setRecipient($recipient) + { + $this->_recipient = $recipient; + } + + /** + * Get the recipient of all messages. + * + * @return mixed + */ + public function getRecipient() + { + return $this->_recipient; + } + + /** + * Set a list of regular expressions to whitelist certain recipients + * + * @param array $whitelist + */ + public function setWhitelist(array $whitelist) + { + $this->_whitelist = $whitelist; + } + + /** + * Get the whitelist + * + * @return array + */ + public function getWhitelist() + { + return $this->_whitelist; + } + + /** + * Invoked immediately before the Message is sent. + * + * @param Swift_Events_SendEvent $evt + */ + public function beforeSendPerformed(Swift_Events_SendEvent $evt) + { + $message = $evt->getMessage(); + $headers = $message->getHeaders(); + + // conditionally save current recipients + + if ($headers->has('to')) { + $headers->addMailboxHeader('X-Swift-To', $message->getTo()); + } + + if ($headers->has('cc')) { + $headers->addMailboxHeader('X-Swift-Cc', $message->getCc()); + } + + if ($headers->has('bcc')) { + $headers->addMailboxHeader('X-Swift-Bcc', $message->getBcc()); + } + + // Filter remaining headers against whitelist + $this->_filterHeaderSet($headers, 'To'); + $this->_filterHeaderSet($headers, 'Cc'); + $this->_filterHeaderSet($headers, 'Bcc'); + + // Add each hard coded recipient + foreach ( (array) $this->_recipient as $recipient) { + if (!array_key_exists($recipient, $message->getTo())) { + $message->addTo($recipient); + } + } + + } + + /** + * Filter header set against a whitelist of regular expressions + * + * @param Swift_Mime_HeaderSet $headerSet + * @param string $type + */ + private function _filterHeaderSet(Swift_Mime_HeaderSet $headerSet, $type) + { + foreach ($headerSet->getAll($type) as $headers) { + $headers->setNameAddresses($this->_filterNameAddresses($headers->getNameAddresses())); + } + } + + /** + * Filtered list of addresses => name pairs + * + * @param array $recipients + * @return array + */ + private function _filterNameAddresses(array $recipients) + { + $filtered = array(); + + foreach ($recipients as $address => $name) { + if ($this->_isWhitelisted($address)) { + $filtered[$address] = $name; + } + } + + return $filtered; + } + + /** + * Matches address against whitelist of regular expressions + * + * @param $recipient + * @return bool + */ + protected function _isWhitelisted($recipient) + { + if (in_array($recipient, (array) $this->_recipient)) { + return true; + } + + foreach ($this->_whitelist as $pattern) { + if (preg_match($pattern, $recipient)) { + return true; + } + } + + return false; + } + + /** + * Invoked immediately after the Message is sent. + * + * @param Swift_Events_SendEvent $evt + */ + public function sendPerformed(Swift_Events_SendEvent $evt) + { + $this->_restoreMessage($evt->getMessage()); + } + + // -- Private methods + + private function _restoreMessage(Swift_Mime_Message $message) + { + // restore original headers + $headers = $message->getHeaders(); + + if ($headers->has('X-Swift-To')) { + $message->setTo($headers->get('X-Swift-To')->getNameAddresses()); + $headers->removeAll('X-Swift-To'); + } + + if ($headers->has('X-Swift-Cc')) { + $message->setCc($headers->get('X-Swift-Cc')->getNameAddresses()); + $headers->removeAll('X-Swift-Cc'); + } + + if ($headers->has('X-Swift-Bcc')) { + $message->setBcc($headers->get('X-Swift-Bcc')->getNameAddresses()); + $headers->removeAll('X-Swift-Bcc'); + } + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Reporter.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Reporter.php new file mode 100755 index 0000000..504c0c8 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Reporter.php @@ -0,0 +1,34 @@ +_reporter = $reporter; + } + + /** + * Not used. + */ + public function beforeSendPerformed(Swift_Events_SendEvent $evt) + { + } + + /** + * Invoked immediately after the Message is sent. + * + * @param Swift_Events_SendEvent $evt + */ + public function sendPerformed(Swift_Events_SendEvent $evt) + { + $message = $evt->getMessage(); + $failures = array_flip($evt->getFailedRecipients()); + foreach ((array) $message->getTo() as $address => $null) { + $this->_reporter->notify( + $message, $address, (array_key_exists($address, $failures) + ? Swift_Plugins_Reporter::RESULT_FAIL + : Swift_Plugins_Reporter::RESULT_PASS) + ); + } + foreach ((array) $message->getCc() as $address => $null) { + $this->_reporter->notify( + $message, $address, (array_key_exists($address, $failures) + ? Swift_Plugins_Reporter::RESULT_FAIL + : Swift_Plugins_Reporter::RESULT_PASS) + ); + } + foreach ((array) $message->getBcc() as $address => $null) { + $this->_reporter->notify( + $message, $address, (array_key_exists($address, $failures) + ? Swift_Plugins_Reporter::RESULT_FAIL + : Swift_Plugins_Reporter::RESULT_PASS) + ); + } + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Reporters/HitReporter.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Reporters/HitReporter.php new file mode 100755 index 0000000..5890eea --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Reporters/HitReporter.php @@ -0,0 +1,61 @@ +_failures_cache[$address])) { + $this->_failures[] = $address; + $this->_failures_cache[$address] = true; + } + } + + /** + * Get an array of addresses for which delivery failed. + * + * @return array + */ + public function getFailedRecipients() + { + return $this->_failures; + } + + /** + * Clear the buffer (empty the list). + */ + public function clear() + { + $this->_failures = $this->_failures_cache = array(); + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Reporters/HtmlReporter.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Reporters/HtmlReporter.php new file mode 100755 index 0000000..cd3b984 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Reporters/HtmlReporter.php @@ -0,0 +1,41 @@ +" . PHP_EOL; + echo "PASS " . $address . PHP_EOL; + echo "" . PHP_EOL; + flush(); + } else { + echo "
    " . PHP_EOL; + echo "FAIL " . $address . PHP_EOL; + echo "
    " . PHP_EOL; + flush(); + } + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Sleeper.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Sleeper.php new file mode 100755 index 0000000..35a63b4 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Sleeper.php @@ -0,0 +1,26 @@ +_rate = $rate; + $this->_mode = $mode; + $this->_sleeper = $sleeper; + $this->_timer = $timer; + } + + /** + * Invoked immediately before the Message is sent. + * + * @param Swift_Events_SendEvent $evt + */ + public function beforeSendPerformed(Swift_Events_SendEvent $evt) + { + $time = $this->getTimestamp(); + if (!isset($this->_start)) { + $this->_start = $time; + } + $duration = $time - $this->_start; + + switch($this->_mode) { + case self::BYTES_PER_MINUTE : + $sleep = $this->_throttleBytesPerMinute($duration); + break; + case self::MESSAGES_PER_SECOND : + $sleep = $this->_throttleMessagesPerSecond($duration); + break; + case self::MESSAGES_PER_MINUTE : + $sleep = $this->_throttleMessagesPerMinute($duration); + break; + default : + $sleep = 0; + break; + } + + if ($sleep > 0) { + $this->sleep($sleep); + } + } + + /** + * Invoked when a Message is sent. + * + * @param Swift_Events_SendEvent $evt + */ + public function sendPerformed(Swift_Events_SendEvent $evt) + { + parent::sendPerformed($evt); + ++$this->_messages; + } + + /** + * Sleep for $seconds. + * + * @param int $seconds + */ + public function sleep($seconds) + { + if (isset($this->_sleeper)) { + $this->_sleeper->sleep($seconds); + } else { + sleep($seconds); + } + } + + /** + * Get the current UNIX timestamp. + * + * @return int + */ + public function getTimestamp() + { + if (isset($this->_timer)) { + return $this->_timer->getTimestamp(); + } else { + return time(); + } + } + + // -- Private methods + + /** + * Get a number of seconds to sleep for. + * + * @param int $timePassed + * + * @return int + */ + private function _throttleBytesPerMinute($timePassed) + { + $expectedDuration = $this->getBytesOut() / ($this->_rate / 60); + + return (int) ceil($expectedDuration - $timePassed); + } + + /** + * Get a number of seconds to sleep for. + * + * @param int $timePassed + * + * @return int + */ + private function _throttleMessagesPerSecond($timePassed) + { + $expectedDuration = $this->_messages / ($this->_rate); + + return (int) ceil($expectedDuration - $timePassed); + } + + /** + * Get a number of seconds to sleep for. + * + * @param int $timePassed + * + * @return int + */ + private function _throttleMessagesPerMinute($timePassed) + { + $expectedDuration = $this->_messages / ($this->_rate / 60); + + return (int) ceil($expectedDuration - $timePassed); + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Timer.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Timer.php new file mode 100755 index 0000000..12dd09b --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Plugins/Timer.php @@ -0,0 +1,26 @@ +register('properties.charset')->asValue($charset); + + return $this; + } + + /** + * Set the directory where temporary files can be saved. + * + * @param string $dir + * + * @return Swift_Preferences + */ + public function setTempDir($dir) + { + Swift_DependencyContainer::getInstance() + ->register('tempdir')->asValue($dir); + + return $this; + } + + /** + * Set the type of cache to use (i.e. "disk" or "array"). + * + * @param string $type + * + * @return Swift_Preferences + */ + public function setCacheType($type) + { + Swift_DependencyContainer::getInstance() + ->register('cache')->asAliasOf(sprintf('cache.%s', $type)); + + return $this; + } + + /** + * Set the QuotedPrintable dot escaper preference. + * + * @param bool $dotEscape + * + * @return Swift_Preferences + */ + public function setQPDotEscape($dotEscape) + { + $dotEscape = !empty($dotEscape); + Swift_DependencyContainer::getInstance() + ->register('mime.qpcontentencoder') + ->asNewInstanceOf('Swift_Mime_ContentEncoder_QpContentEncoder') + ->withDependencies(array('mime.charstream', 'mime.bytecanonicalizer')) + ->addConstructorValue($dotEscape); + + return $this; + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/ReplacementFilterFactory.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/ReplacementFilterFactory.php new file mode 100755 index 0000000..4b6eed5 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/ReplacementFilterFactory.php @@ -0,0 +1,28 @@ +createDependenciesFor('transport.sendmail') + ); + + $this->setCommand($command); + } + + /** + * Create a new SendmailTransport instance. + * + * @param string $command + * + * @return Swift_SendmailTransport + */ + public static function newInstance($command = '/usr/sbin/sendmail -bs') + { + return new self($command); + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/SignedMessage.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/SignedMessage.php new file mode 100755 index 0000000..c4fb2c7 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/SignedMessage.php @@ -0,0 +1,25 @@ + + * @deprecated + */ +class Swift_SignedMessage extends Swift_Message +{ + +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Signer.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Signer.php new file mode 100755 index 0000000..865f557 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Signer.php @@ -0,0 +1,22 @@ + + */ +interface Swift_Signer +{ + public function reset(); +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Signers/BodySigner.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Signers/BodySigner.php new file mode 100755 index 0000000..1d700fb --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Signers/BodySigner.php @@ -0,0 +1,35 @@ + + */ +interface Swift_Signers_BodySigner extends Swift_Signer +{ + /** + * Change the Swift_Signed_Message to apply the singing. + * + * @param Swift_Message $message + * + * @return Swift_Signers_BodySigner + */ + public function signMessage(Swift_Message $message); + + /** + * Return the list of header a signer might tamper + * + * @return array + */ + public function getAlteredHeaders(); +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Signers/DKIMSigner.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Signers/DKIMSigner.php new file mode 100755 index 0000000..75fc01b --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Signers/DKIMSigner.php @@ -0,0 +1,686 @@ + + */ +class Swift_Signers_DKIMSigner implements Swift_Signers_HeaderSigner +{ + /** + * PrivateKey + * + * @var string + */ + protected $_privateKey; + + /** + * DomainName + * + * @var string + */ + protected $_domainName; + + /** + * Selector + * + * @var string + */ + protected $_selector; + + /** + * Hash algorithm used + * + * @var string + */ + protected $_hashAlgorithm = 'rsa-sha1'; + + /** + * Body canon method + * + * @var string + */ + protected $_bodyCanon = 'simple'; + + /** + * Header canon method + * + * @var string + */ + protected $_headerCanon = 'simple'; + + /** + * Headers not being signed + * + * @var array + */ + protected $_ignoredHeaders = array(); + + /** + * Signer identity + * + * @var unknown_type + */ + protected $_signerIdentity; + + /** + * BodyLength + * + * @var int + */ + protected $_bodyLen = 0; + + /** + * Maximum signedLen + * + * @var int + */ + protected $_maxLen = PHP_INT_MAX; + + /** + * Embbed bodyLen in signature + * + * @var bool + */ + protected $_showLen = false; + + /** + * When the signature has been applied (true means time()), false means not embedded + * + * @var mixed + */ + protected $_signatureTimestamp = true; + + /** + * When will the signature expires false means not embedded, if sigTimestamp is auto + * Expiration is relative, otherwhise it's absolute + * + * @var int + */ + protected $_signatureExpiration = false; + + /** + * Must we embed signed headers? + * + * @var bool + */ + protected $_debugHeaders = false; + + // work variables + /** + * Headers used to generate hash + * + * @var array + */ + protected $_signedHeaders = array(); + + /** + * If debugHeaders is set store debugDatas here + * + * @var string + */ + private $_debugHeadersData = ''; + + /** + * Stores the bodyHash + * + * @var string + */ + private $_bodyHash = ''; + + /** + * Stores the signature header + * + * @var Swift_Mime_Headers_ParameterizedHeader + */ + protected $_dkimHeader; + + /** + * Hash Handler + * + * @var hash_ressource + */ + private $_headerHashHandler; + + private $_bodyHashHandler; + + private $_headerHash; + + private $_headerCanonData = ''; + + private $_bodyCanonEmptyCounter = 0; + + private $_bodyCanonIgnoreStart = 2; + + private $_bodyCanonSpace = false; + + private $_bodyCanonLastChar = null; + + private $_bodyCanonLine = ''; + + private $_bound = array(); + + /** + * Constructor + * + * @param string $privateKey + * @param string $domainName + * @param string $selector + */ + public function __construct($privateKey, $domainName, $selector) + { + $this->_privateKey = $privateKey; + $this->_domainName = $domainName; + $this->_signerIdentity = '@' . $domainName; + $this->_selector = $selector; + } + + /** + * Instanciate DKIMSigner + * + * @param string $privateKey + * @param string $domainName + * @param string $selector + * @return Swift_Signers_DKIMSigner + */ + public static function newInstance($privateKey, $domainName, $selector) + { + return new static($privateKey, $domainName, $selector); + } + + + /** + * Reset the Signer + * @see Swift_Signer::reset() + */ + public function reset() + { + $this->_headerHash = null; + $this->_signedHeaders = array(); + $this->_headerHashHandler = null; + $this->_bodyHash = null; + $this->_bodyHashHandler = null; + $this->_bodyCanonIgnoreStart = 2; + $this->_bodyCanonEmptyCounter = 0; + $this->_bodyCanonLastChar = NULL; + $this->_bodyCanonSpace = false; + } + + /** + * Writes $bytes to the end of the stream. + * + * Writing may not happen immediately if the stream chooses to buffer. If + * you want to write these bytes with immediate effect, call {@link commit()} + * after calling write(). + * + * This method returns the sequence ID of the write (i.e. 1 for first, 2 for + * second, etc etc). + * + * @param string $bytes + * @return int + * @throws Swift_IoException + */ + public function write($bytes) + { + $this->_canonicalizeBody($bytes); + foreach ($this->_bound as $is) { + $is->write($bytes); + } + } + + /** + * For any bytes that are currently buffered inside the stream, force them + * off the buffer. + * + * @throws Swift_IoException + */ + public function commit() + { + // Nothing to do + return; + } + + /** + * Attach $is to this stream. + * The stream acts as an observer, receiving all data that is written. + * All {@link write()} and {@link flushBuffers()} operations will be mirrored. + * + * @param Swift_InputByteStream $is + */ + public function bind(Swift_InputByteStream $is) + { + // Don't have to mirror anything + $this->_bound[] = $is; + + return; + } + + /** + * Remove an already bound stream. + * If $is is not bound, no errors will be raised. + * If the stream currently has any buffered data it will be written to $is + * before unbinding occurs. + * + * @param Swift_InputByteStream $is + */ + public function unbind(Swift_InputByteStream $is) + { + // Don't have to mirror anything + foreach ($this->_bound as $k => $stream) { + if ($stream === $is) { + unset($this->_bound[$k]); + return; + } + } + + return; + } + + /** + * Flush the contents of the stream (empty it) and set the internal pointer + * to the beginning. + * + * @throws Swift_IoException + */ + public function flushBuffers() + { + $this->reset(); + } + + /** + * Set hash_algorithm, must be one of rsa-sha256 | rsa-sha1 defaults to rsa-sha256 + * + * @param string $hash + * @return Swift_Signers_DKIMSigner + */ + public function setHashAlgorithm($hash) + { + // Unable to sign with rsa-sha256 + if ($hash == 'rsa-sha1') { + $this->_hashAlgorithm = 'rsa-sha1'; + } else { + $this->_hashAlgorithm = 'rsa-sha256'; + } + + return $this; + } + + /** + * Set the body canonicalization algorithm + * + * @param string $canon + * @return Swift_Signers_DKIMSigner + */ + public function setBodyCanon($canon) + { + if ($canon == 'relaxed') { + $this->_bodyCanon = 'relaxed'; + } else { + $this->_bodyCanon = 'simple'; + } + + return $this; + } + + /** + * Set the header canonicalization algorithm + * + * @param string $canon + * @return Swift_Signers_DKIMSigner + */ + public function setHeaderCanon($canon) + { + if ($canon == 'relaxed') { + $this->_headerCanon = 'relaxed'; + } else { + $this->_headerCanon = 'simple'; + } + + return $this; + } + + /** + * Set the signer identity + * + * @param string $identity + * @return Swift_Signers_DKIMSigner + */ + public function setSignerIdentity($identity) + { + $this->_signerIdentity = $identity; + + return $this; + } + + /** + * Set the length of the body to sign + * + * @param mixed $len (bool or int) + * @return Swift_Signers_DKIMSigner + */ + public function setBodySignedLen($len) + { + if ($len === true) { + $this->_showLen = true; + $this->_maxLen = PHP_INT_MAX; + } elseif ($len === false) { + $this->showLen = false; + $this->_maxLen = PHP_INT_MAX; + } else { + $this->_showLen = true; + $this->_maxLen = (int) $len; + } + + return $this; + } + + /** + * Set the signature timestamp + * + * @param timestamp $time + * @return Swift_Signers_DKIMSigner + */ + public function setSignatureTimestamp($time) + { + $this->_signatureTimestamp = $time; + + return $this; + } + + /** + * Set the signature expiration timestamp + * + * @param timestamp $time + * @return Swift_Signers_DKIMSigner + */ + public function setSignatureExpiration($time) + { + $this->_signatureExpiration = $time; + + return $this; + } + + /** + * Enable / disable the DebugHeaders + * + * @param bool $debug + * @return Swift_Signers_DKIMSigner + */ + public function setDebugHeaders($debug) + { + $this->_debugHeaders = (bool) $debug; + + return $this; + } + + /** + * Start Body + * + */ + public function startBody() + { + // Init + switch ($this->_hashAlgorithm) { + case 'rsa-sha256' : + $this->_bodyHashHandler = hash_init('sha256'); + break; + case 'rsa-sha1' : + $this->_bodyHashHandler = hash_init('sha1'); + break; + } + $this->_bodyCanonLine = ''; + } + + /** + * End Body + * + */ + public function endBody() + { + $this->_endOfBody(); + } + + /** + * Returns the list of Headers Tampered by this plugin + * + * @return array + */ + public function getAlteredHeaders() + { + if ($this->_debugHeaders) { + return array('DKIM-Signature', 'X-DebugHash'); + } else { + return array('DKIM-Signature'); + } + } + + /** + * Adds an ignored Header + * + * @param string $header_name + * @return Swift_Signers_DKIMSigner + */ + public function ignoreHeader($header_name) + { + $this->_ignoredHeaders[strtolower($header_name)] = true; + + return $this; + } + + /** + * Set the headers to sign + * + * @param Swift_Mime_HeaderSet $headers + * @return Swift_Signers_DKIMSigner + */ + public function setHeaders(Swift_Mime_HeaderSet $headers) + { + $this->_headerCanonData = ''; + // Loop through Headers + $listHeaders = $headers->listAll(); + foreach ($listHeaders as $hName) { + // Check if we need to ignore Header + if (! isset($this->_ignoredHeaders[strtolower($hName)])) { + if ($headers->has($hName)) { + $tmp = $headers->getAll($hName); + foreach ($tmp as $header) { + if ($header->getFieldBody() != '') { + $this->_addHeader($header->toString()); + $this->_signedHeaders[] = $header->getFieldName(); + } + } + } + } + } + + return $this; + } + + /** + * Add the signature to the given Headers + * + * @param Swift_Mime_HeaderSet $headers + * @return Swift_Signers_DKIMSigner + */ + public function addSignature(Swift_Mime_HeaderSet $headers) + { + // Prepare the DKIM-Signature + $params = array('v' => '1', 'a' => $this->_hashAlgorithm, 'bh' => base64_encode($this->_bodyHash), 'd' => $this->_domainName, 'h' => implode(': ', $this->_signedHeaders), 'i' => $this->_signerIdentity, 's' => $this->_selector); + if ($this->_bodyCanon != 'simple') { + $params['c'] = $this->_headerCanon . '/' . $this->_bodyCanon; + } elseif ($this->_headerCanon != 'simple') { + $params['c'] = $this->_headerCanon; + } + if ($this->_showLen) { + $params['l'] = $this->_bodyLen; + } + if ($this->_signatureTimestamp === true) { + $params['t'] = time(); + if ($this->_signatureExpiration !== false) { + $params['x'] = $params['t'] + $this->_signatureExpiration; + } + } else { + if ($this->_signatureTimestamp !== false) { + $params['t'] = $this->_signatureTimestamp; + } + if ($this->_signatureExpiration !== false) { + $params['x'] = $this->_signatureExpiration; + } + } + if ($this->_debugHeaders) { + $params['z'] = implode('|', $this->_debugHeadersData); + } + $string = ''; + foreach ($params as $k => $v) { + $string .= $k . '=' . $v . '; '; + } + $string = trim($string); + $headers->addTextHeader('DKIM-Signature', $string); + // Add the last DKIM-Signature + $tmp = $headers->getAll('DKIM-Signature'); + $this->_dkimHeader = end($tmp); + $this->_addHeader(trim($this->_dkimHeader->toString()) . "\r\n b=", true); + $this->_endOfHeaders(); + if ($this->_debugHeaders) { + $headers->addTextHeader('X-DebugHash', base64_encode($this->_headerHash)); + } + $this->_dkimHeader->setValue($string . " b=" . trim(chunk_split(base64_encode($this->_getEncryptedHash()), 73, " "))); + + return $this; + } + + /* Private helpers */ + + protected function _addHeader($header, $is_sig = false) + { + switch ($this->_headerCanon) { + case 'relaxed' : + // Prepare Header and cascade + $exploded = explode(':', $header, 2); + $name = strtolower(trim($exploded[0])); + $value = str_replace("\r\n", "", $exploded[1]); + $value = preg_replace("/[ \t][ \t]+/", " ", $value); + $header = $name . ":" . trim($value) . ($is_sig ? '' : "\r\n"); + case 'simple' : + // Nothing to do + } + $this->_addToHeaderHash($header); + } + + protected function _endOfHeaders() + { + //$this->_headerHash=hash_final($this->_headerHashHandler, true); + } + + protected function _canonicalizeBody($string) + { + $len = strlen($string); + $canon = ''; + $method = ($this->_bodyCanon == "relaxed"); + for ($i = 0; $i < $len; ++$i) { + if ($this->_bodyCanonIgnoreStart > 0) { + --$this->_bodyCanonIgnoreStart; + continue; + } + switch ($string[$i]) { + case "\r" : + $this->_bodyCanonLastChar = "\r"; + break; + case "\n" : + if ($this->_bodyCanonLastChar == "\r") { + if ($method) { + $this->_bodyCanonSpace = false; + } + if ($this->_bodyCanonLine == '') { + ++$this->_bodyCanonEmptyCounter; + } else { + $this->_bodyCanonLine = ''; + $canon .= "\r\n"; + } + } else { + // Wooops Error + // todo handle it but should never happen + } + break; + case " " : + case "\t" : + if ($method) { + $this->_bodyCanonSpace = true; + break; + } + default : + if ($this->_bodyCanonEmptyCounter > 0) { + $canon .= str_repeat("\r\n", $this->_bodyCanonEmptyCounter); + $this->_bodyCanonEmptyCounter = 0; + } + if ($this->_bodyCanonSpace) { + $this->_bodyCanonLine .= ' '; + $canon .= ' '; + $this->_bodyCanonSpace = false; + } + $this->_bodyCanonLine .= $string[$i]; + $canon .= $string[$i]; + } + } + $this->_addToBodyHash($canon); + } + + protected function _endOfBody() + { + // Add trailing Line return if last line is non empty + if (strlen($this->_bodyCanonLine) > 0) { + $this->_addToBodyHash("\r\n"); + } + $this->_bodyHash = hash_final($this->_bodyHashHandler, true); + } + + private function _addToBodyHash($string) + { + $len = strlen($string); + if ($len > ($new_len = ($this->_maxLen - $this->_bodyLen))) { + $string = substr($string, 0, $new_len); + $len = $new_len; + } + hash_update($this->_bodyHashHandler, $string); + $this->_bodyLen += $len; + } + + private function _addToHeaderHash($header) + { + if ($this->_debugHeaders) { + $this->_debugHeadersData[] = trim($header); + } + $this->_headerCanonData .= $header; + } + + private function _getEncryptedHash() + { + $signature = ''; + switch ($this->_hashAlgorithm) { + case 'rsa-sha1': + $algorithm = OPENSSL_ALGO_SHA1; + break; + case 'rsa-sha256': + $algorithm = OPENSSL_ALGO_SHA256; + break; + } + $pkeyId=openssl_get_privatekey($this->_privateKey); + if (!$pkeyId) { + throw new Swift_SwiftException('Unable to load DKIM Private Key ['.openssl_error_string().']'); + } + if (openssl_sign($this->_headerCanonData, $signature, $this->_privateKey, $algorithm)) { + return $signature; + } + throw new Swift_SwiftException('Unable to sign DKIM Hash ['.openssl_error_string().']'); + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Signers/DomainKeySigner.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Signers/DomainKeySigner.php new file mode 100755 index 0000000..dbfd292 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Signers/DomainKeySigner.php @@ -0,0 +1,516 @@ + + */ +class Swift_Signers_DomainKeySigner implements Swift_Signers_HeaderSigner +{ + /** + * PrivateKey + * + * @var string + */ + protected $_privateKey; + + /** + * DomainName + * + * @var string + */ + protected $_domainName; + + /** + * Selector + * + * @var string + */ + protected $_selector; + + /** + * Hash algorithm used + * + * @var string + */ + protected $_hashAlgorithm = 'rsa-sha1'; + + /** + * Canonisation method + * + * @var string + */ + protected $_canon = 'simple'; + + /** + * Headers not being signed + * + * @var array + */ + protected $_ignoredHeaders = array(); + + /** + * Signer identity + * + * @var unknown_type + */ + protected $_signerIdentity; + + /** + * Must we embed signed headers? + * + * @var bool + */ + protected $_debugHeaders = false; + + // work variables + /** + * Headers used to generate hash + * + * @var array + */ + private $_signedHeaders = array(); + + /** + * If debugHeaders is set store debugDatas here + * + * @var string + */ + private $_debugHeadersData = ''; + + /** + * Stores the signature header + * + * @var Swift_Mime_Headers_ParameterizedHeader + */ + protected $_domainKeyHeader; + + /** + * Hash Handler + * + * @var hash_ressource + */ + private $_hashHandler; + + private $_hash; + + private $_canonData = ''; + + private $_bodyCanonEmptyCounter = 0; + + private $_bodyCanonIgnoreStart = 2; + + private $_bodyCanonSpace = false; + + private $_bodyCanonLastChar = null; + + private $_bodyCanonLine = ''; + + private $_bound = array(); + + /** + * Constructor + * + * @param string $privateKey + * @param string $domainName + * @param string $selector + */ + public function __construct($privateKey, $domainName, $selector) + { + $this->_privateKey = $privateKey; + $this->_domainName = $domainName; + $this->_signerIdentity = '@' . $domainName; + $this->_selector = $selector; + } + + /** + * Instanciate DomainKeySigner + * + * @param string $privateKey + * @param string $domainName + * @param string $selector + * @return Swift_Signers_DomainKeySigner + */ + public static function newInstance($privateKey, $domainName, $selector) { + return new static($privateKey, $domainName, $selector); + } + + /** + * Resets internal states + * + * @return Swift_Signers_DomainKeysSigner + */ + public function reset() + { + $this->_hash = null; + $this->_hashHandler = null; + $this->_bodyCanonIgnoreStart = 2; + $this->_bodyCanonEmptyCounter = 0; + $this->_bodyCanonLastChar = NULL; + $this->_bodyCanonSpace = false; + + return $this; + } + + /** + * Writes $bytes to the end of the stream. + * + * Writing may not happen immediately if the stream chooses to buffer. If + * you want to write these bytes with immediate effect, call {@link commit()} + * after calling write(). + * + * This method returns the sequence ID of the write (i.e. 1 for first, 2 for + * second, etc etc). + * + * @param string $bytes + * @return int + * @throws Swift_IoException + * @return Swift_Signers_DomainKeysSigner + */ + public function write($bytes) + { + $this->_canonicalizeBody($bytes); + foreach ($this->_bound as $is) { + $is->write($bytes); + } + + return $this; + } + + /** + * For any bytes that are currently buffered inside the stream, force them + * off the buffer. + * + * @throws Swift_IoException + * @return Swift_Signers_DomainKeysSigner + */ + public function commit() + { + // Nothing to do + return $this; + } + + /** + * Attach $is to this stream. + * The stream acts as an observer, receiving all data that is written. + * All {@link write()} and {@link flushBuffers()} operations will be mirrored. + * + * @param Swift_InputByteStream $is + * @return Swift_Signers_DomainKeysSigner + */ + public function bind(Swift_InputByteStream $is) + { + // Don't have to mirror anything + $this->_bound[] = $is; + + return $this; + } + + /** + * Remove an already bound stream. + * If $is is not bound, no errors will be raised. + * If the stream currently has any buffered data it will be written to $is + * before unbinding occurs. + * + * @param Swift_InputByteStream $is + * @return Swift_Signers_DomainKeysSigner + */ + public function unbind(Swift_InputByteStream $is) + { + // Don't have to mirror anything + foreach ($this->_bound as $k => $stream) { + if ($stream === $is) { + unset($this->_bound[$k]); + + return; + } + } + + return $this; + } + + /** + * Flush the contents of the stream (empty it) and set the internal pointer + * to the beginning. + * + * @throws Swift_IoException + * @return Swift_Signers_DomainKeysSigner + */ + public function flushBuffers() + { + $this->reset(); + + return $this; + } + + /** + * Set hash_algorithm, must be one of rsa-sha256 | rsa-sha1 defaults to rsa-sha256 + * + * @param string $hash + * @return Swift_Signers_DomainKeysSigner + */ + public function setHashAlgorithm($hash) + { + $this->_hashAlgorithm = 'rsa-sha1'; + + return $this; + } + + /** + * Set the canonicalization algorithm + * + * @param string $canon simple | nofws defaults to simple + * @return Swift_Signers_DomainKeysSigner + */ + public function setCanon($canon) + { + if ($canon == 'nofws') { + $this->_canon = 'nofws'; + } else { + $this->_canon = 'simple'; + } + + return $this; + } + + /** + * Set the signer identity + * + * @param string $identity + * @return Swift_Signers_DomainKeySigner + */ + public function setSignerIdentity($identity) + { + $this->_signerIdentity = $identity; + + return $this; + } + + /** + * Enable / disable the DebugHeaders + * + * @param bool $debug + * @return Swift_Signers_DomainKeySigner + */ + public function setDebugHeaders($debug) + { + $this->_debugHeaders = (bool) $debug; + + return $this; + } + + /** + * Start Body + * + */ + public function startBody() + { + } + + /** + * End Body + * + */ + public function endBody() + { + $this->_endOfBody(); + } + + /** + * Returns the list of Headers Tampered by this plugin + * + * @return array + */ + public function getAlteredHeaders() + { + if ($this->_debugHeaders) { + return array('DomainKey-Signature', 'X-DebugHash'); + } else { + return array('DomainKey-Signature'); + } + } + + /** + * Adds an ignored Header + * + * @param string $header_name + * @return Swift_Signers_DomainKeySigner + */ + public function ignoreHeader($header_name) + { + $this->_ignoredHeaders[strtolower($header_name)] = true; + + return $this; + } + + /** + * Set the headers to sign + * + * @param Swift_Mime_HeaderSet $headers + * @return Swift_Signers_DomainKeySigner + */ + public function setHeaders(Swift_Mime_HeaderSet $headers) + { + $this->_startHash(); + $this->_canonData = ''; + // Loop through Headers + $listHeaders = $headers->listAll(); + foreach ($listHeaders as $hName) { + // Check if we need to ignore Header + if (! isset($this->_ignoredHeaders[strtolower($hName)])) { + if ($headers->has($hName)) { + $tmp = $headers->getAll($hName); + foreach ($tmp as $header) { + if ($header->getFieldBody() != '') { + $this->_addHeader($header->toString()); + $this->_signedHeaders[] = $header->getFieldName(); + } + } + } + } + } + $this->_endOfHeaders(); + + return $this; + } + + /** + * Add the signature to the given Headers + * + * @param Swift_Mime_HeaderSet $headers + * @return Swift_Signers_DomainKeySigner + */ + public function addSignature(Swift_Mime_HeaderSet $headers) + { + // Prepare the DomainKey-Signature Header + $params = array('a' => $this->_hashAlgorithm, 'b' => chunk_split(base64_encode($this->_getEncryptedHash()), 73, " "), 'c' => $this->_canon, 'd' => $this->_domainName, 'h' => implode(': ', $this->_signedHeaders), 'q' => 'dns', 's' => $this->_selector); + $string = ''; + foreach ($params as $k => $v) { + $string .= $k . '=' . $v . '; '; + } + $string = trim($string); + $headers->addTextHeader('DomainKey-Signature', $string); + + return $this; + } + + /* Private helpers */ + + protected function _addHeader($header) + { + switch ($this->_canon) { + case 'nofws' : + // Prepare Header and cascade + $exploded = explode(':', $header, 2); + $name = strtolower(trim($exploded[0])); + $value = str_replace("\r\n", "", $exploded[1]); + $value = preg_replace("/[ \t][ \t]+/", " ", $value); + $header = $name . ":" . trim($value) . "\r\n"; + case 'simple' : + // Nothing to do + } + $this->_addToHash($header); + } + + protected function _endOfHeaders() + { + $this->_bodyCanonEmptyCounter = 1; + } + + protected function _canonicalizeBody($string) + { + $len = strlen($string); + $canon = ''; + $nofws = ($this->_canon == "nofws"); + for ($i = 0; $i < $len; ++$i) { + if ($this->_bodyCanonIgnoreStart > 0) { + --$this->_bodyCanonIgnoreStart; + continue; + } + switch ($string[$i]) { + case "\r" : + $this->_bodyCanonLastChar = "\r"; + break; + case "\n" : + if ($this->_bodyCanonLastChar == "\r") { + if ($nofws) { + $this->_bodyCanonSpace = false; + } + if ($this->_bodyCanonLine == '') { + ++$this->_bodyCanonEmptyCounter; + } else { + $this->_bodyCanonLine = ''; + $canon .= "\r\n"; + } + } else { + // Wooops Error + throw new Swift_SwiftException('Invalid new line sequence in mail found \n without preceding \r'); + } + break; + case " " : + case "\t" : + case "\x09": //HTAB + if ($nofws) { + $this->_bodyCanonSpace = true; + break; + } + default : + if ($this->_bodyCanonEmptyCounter > 0) { + $canon .= str_repeat("\r\n", $this->_bodyCanonEmptyCounter); + $this->_bodyCanonEmptyCounter = 0; + } + $this->_bodyCanonLine .= $string[$i]; + $canon .= $string[$i]; + } + } + $this->_addToHash($canon); + } + + protected function _endOfBody() + { + if (strlen($this->_bodyCanonLine) > 0) { + $this->_addToHash("\r\n"); + } + $this->_hash = hash_final($this->_hashHandler, true); + } + + private function _addToHash($string) + { + $this->_canonData .= $string; + hash_update($this->_hashHandler, $string); + } + + private function _startHash() + { + // Init + switch ($this->_hashAlgorithm) { + case 'rsa-sha1' : + $this->_hashHandler = hash_init('sha1'); + break; + } + $this->_canonLine = ''; + } + + private function _getEncryptedHash() + { + $signature = ''; + $pkeyId=openssl_get_privatekey($this->_privateKey); + if (!$pkeyId) { + throw new Swift_SwiftException('Unable to load DomainKey Private Key ['.openssl_error_string().']'); + } + if (openssl_sign($this->_canonData, $signature, $pkeyId, OPENSSL_ALGO_SHA1)) { + return $signature; + } + throw new Swift_SwiftException('Unable to sign DomainKey Hash ['.openssl_error_string().']'); + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Signers/HeaderSigner.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Signers/HeaderSigner.php new file mode 100755 index 0000000..944deac --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Signers/HeaderSigner.php @@ -0,0 +1,67 @@ + + */ +interface Swift_Signers_HeaderSigner extends Swift_Signer, Swift_InputByteStream +{ + /** + * Exclude an header from the signed headers + * + * @param string $header_name + * + * @return Swift_Signers_HeaderSigner + */ + public function ignoreHeader($header_name); + + /** + * Prepare the Signer to get a new Body + * + * @return Swift_Signers_HeaderSigner + */ + public function startBody(); + + /** + * Give the signal that the body has finished streaming + * + * @return Swift_Signers_HeaderSigner + */ + public function endBody(); + + /** + * Give the headers already given + * + * @param Swift_Mime_SimpleHeaderSet $headers + * + * @return Swift_Signers_HeaderSigner + */ + public function setHeaders(Swift_Mime_HeaderSet $headers); + + /** + * Add the header(s) to the headerSet + * + * @param Swift_Mime_HeaderSet $headers + * + * @return Swift_Signers_HeaderSigner + */ + public function addSignature(Swift_Mime_HeaderSet $headers); + + /** + * Return the list of header a signer might tamper + * + * @return array + */ + public function getAlteredHeaders(); +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Signers/OpenDKIMSigner.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Signers/OpenDKIMSigner.php new file mode 100755 index 0000000..22b57cb --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Signers/OpenDKIMSigner.php @@ -0,0 +1,184 @@ + + */ +class Swift_Signers_OpenDKIMSigner extends Swift_Signers_DKIMSigner +{ + private $_peclLoaded = false; + + private $_dkimHandler = null; + + private $dropFirstLF = true; + + const CANON_RELAXED = 1; + const CANON_SIMPLE = 2; + const SIG_RSA_SHA1 = 3; + const SIG_RSA_SHA256 = 4; + + public function __construct($privateKey, $domainName, $selector) + { + if (extension_loaded('opendkim')) { + $this->_peclLoaded = true; + } else { + throw new Swift_SwiftException('php-opendkim extension not found'); + } + parent::__construct($privateKey, $domainName, $selector); + } + + public static function newInstance($privateKey, $domainName, $selector) + { + return new static($privateKey, $domainName, $selector); + } + + public function addSignature(Swift_Mime_HeaderSet $headers) + { + $header = new Swift_Mime_Headers_OpenDKIMHeader('DKIM-Signature'); + $headerVal=$this->_dkimHandler->getSignatureHeader(); + if (!$headerVal) { + throw new Swift_SwiftException('OpenDKIM Error: '.$this->_dkimHandler->getError()); + } + $header->setValue($headerVal); + $headers->set($header); + + return $this; + } + + public function setHeaders(Swift_Mime_HeaderSet $headers) + { + $bodyLen = $this->_bodyLen; + if (is_bool($bodyLen)) { + $bodyLen = - 1; + } + $hash = ($this->_hashAlgorithm == 'rsa-sha1') ? OpenDKIMSign::ALG_RSASHA1 : OpenDKIMSign::ALG_RSASHA256; + $bodyCanon = ($this->_bodyCanon == 'simple') ? OpenDKIMSign::CANON_SIMPLE : OpenDKIMSign::CANON_RELAXED; + $headerCanon = ($this->_headerCanon == 'simple') ? OpenDKIMSign::CANON_SIMPLE : OpenDKIMSign::CANON_RELAXED; + $this->_dkimHandler = new OpenDKIMSign($this->_privateKey, $this->_selector, $this->_domainName, $headerCanon, $bodyCanon, $hash, $bodyLen); + // Hardcode signature Margin for now + $this->_dkimHandler->setMargin(78); + + if (!is_numeric($this->_signatureTimestamp)) { + OpenDKIM::setOption(OpenDKIM::OPTS_FIXEDTIME, time()); + } else { + if (!OpenDKIM::setOption(OpenDKIM::OPTS_FIXEDTIME, $this->_signatureTimestamp)) { + throw new Swift_SwiftException('Unable to force signature timestamp ['.openssl_error_string().']'); + } + } + if (isset($this->_signerIdentity)) { + $this->_dkimHandler->setSigner($this->_signerIdentity); + } + $listHeaders = $headers->listAll(); + foreach ($listHeaders as $hName) { + // Check if we need to ignore Header + if (! isset($this->_ignoredHeaders[strtolower($hName)])) { + $tmp = $headers->getAll($hName); + if ($headers->has($hName)) { + foreach ($tmp as $header) { + if ($header->getFieldBody() != '') { + $htosign = $header->toString(); + $this->_dkimHandler->header($htosign); + $this->_signedHeaders[] = $header->getFieldName(); + } + } + } + } + } + return $this; + } + + public function startBody() + { + if (! $this->_peclLoaded) { + return parent::startBody(); + } + $this->dropFirstLF = true; + $this->_dkimHandler->eoh(); + return $this; + } + + public function endBody() + { + if (! $this->_peclLoaded) { + return parent::endBody(); + } + $this->_dkimHandler->eom(); + return $this; + } + + public function reset() + { + $this->_dkimHandler = null; + parent::reset(); + return $this; + } + + /** + * Set the signature timestamp + * + * @param timestamp $time + * @return Swift_Signers_DKIMSigner + */ + public function setSignatureTimestamp($time) + { + $this->_signatureTimestamp = $time; + return $this; + } + + /** + * Set the signature expiration timestamp + * + * @param timestamp $time + * @return Swift_Signers_DKIMSigner + */ + public function setSignatureExpiration($time) + { + $this->_signatureExpiration = $time; + + return $this; + } + + /** + * Enable / disable the DebugHeaders + * + * @param bool $debug + * @return Swift_Signers_DKIMSigner + */ + public function setDebugHeaders($debug) + { + $this->_debugHeaders = (bool) $debug; + + return $this; + } + + // Protected + + protected function _canonicalizeBody($string) + { + if (! $this->_peclLoaded) { + return parent::_canonicalizeBody($string); + } + if (false && $this->dropFirstLF === true) { + if ($string[0]=="\r" && $string[1]=="\n") { + $string=substr($string, 2); + } + } + $this->dropFirstLF = false; + if (strlen($string)) { + $this->_dkimHandler->body($string); + } + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Signers/SMimeSigner.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Signers/SMimeSigner.php new file mode 100755 index 0000000..5b75e9b --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Signers/SMimeSigner.php @@ -0,0 +1,430 @@ + + */ +class Swift_Signers_SMimeSigner implements Swift_Signers_BodySigner +{ + protected $signCertificate; + protected $signPrivateKey; + protected $encryptCert; + protected $signThenEncrypt = true; + protected $signLevel; + protected $encryptLevel; + protected $signOptions; + protected $encryptOptions; + protected $encryptCipher; + + /** + * @var Swift_StreamFilters_StringReplacementFilterFactory + */ + protected $replacementFactory; + + /** + * @var Swift_Mime_HeaderFactory + */ + protected $headerFactory; + + /** + * Constructor. + * + * @param string $certificate + * @param string $privateKey + * @param string $encryptCertificate + */ + public function __construct($signCertificate = null, $signPrivateKey = null, $encryptCertificate = null) + { + if (null !== $signPrivateKey) { + $this->setSignCertificate($signCertificate, $signPrivateKey); + } + + if (null !== $encryptCertificate) { + $this->setEncryptCertificate($encryptCertificate); + } + + $this->replacementFactory = Swift_DependencyContainer::getInstance() + ->lookup('transport.replacementfactory'); + + $this->signOptions = PKCS7_DETACHED; + + // Supported since php5.4 + if (defined('OPENSSL_CIPHER_AES_128_CBC')) { + $this->encryptCipher = OPENSSL_CIPHER_AES_128_CBC; + } else { + $this->encryptCipher = OPENSSL_CIPHER_RC2_128; + } + } + + /** + * Returns an new Swift_Signers_SMimeSigner instance. + * + * @param string $certificate + * @param string $privateKey + * + * @return Swift_Signers_SMimeSigner + */ + public static function newInstance($certificate = null, $privateKey = null) + { + return new self($certificate, $privateKey); + } + + /** + * Set the certificate location to use for signing. + * + * @link http://www.php.net/manual/en/openssl.pkcs7.flags.php + * + * @param string $certificate + * @param string|array $privateKey If the key needs an passphrase use array('file-location', 'passphrase') instead + * @param int $signOptions Bitwise operator options for openssl_pkcs7_sign() + * + * @return Swift_Signers_SMimeSigner + */ + public function setSignCertificate($certificate, $privateKey = null, $signOptions = PKCS7_DETACHED) + { + $this->signCertificate = 'file://' . str_replace('\\', '/', realpath($certificate)); + + if (null !== $privateKey) { + if (is_array($privateKey)) { + $this->signPrivateKey = $privateKey; + $this->signPrivateKey[0] = 'file://' . str_replace('\\', '/', realpath($privateKey[0])); + } else { + $this->signPrivateKey = 'file://' . str_replace('\\', '/', realpath($privateKey)); + } + } + + $this->signOptions = $signOptions; + + return $this; + } + + /** + * Set the certificate location to use for encryption. + * + * @link http://www.php.net/manual/en/openssl.pkcs7.flags.php + * @link http://nl3.php.net/manual/en/openssl.ciphers.php + * + * @param string|array $recipientCerts Either an single X.509 certificate, or an assoc array of X.509 certificates. + * @param int $cipher + * + * @return Swift_Signers_SMimeSigner + */ + public function setEncryptCertificate($recipientCerts, $cipher = null) + { + if (is_array($recipientCerts)) { + $this->encryptCert = array(); + + foreach ($recipientCerts as $cert) { + $this->encryptCert[] = 'file://' . str_replace('\\', '/', realpath($cert)); + } + } else { + $this->encryptCert = 'file://' . str_replace('\\', '/', realpath($recipientCerts)); + } + + if (null !== $cipher) { + $this->encryptCipher = $cipher; + } + + return $this; + } + + /** + * @return string + */ + public function getSignCertificate() + { + return $this->signCertificate; + } + + /** + * @return string + */ + public function getSignPrivateKey() + { + return $this->signPrivateKey; + } + + /** + * Set perform signing before encryption. + * + * The default is to first sign the message and then encrypt. + * But some older mail clients, namely Microsoft Outlook 2000 will work when the message first encrypted. + * As this goes against the official specs, its recommended to only use 'encryption -> signing' when specifically targeting these 'broken' clients. + * + * @param string $signThenEncrypt + * + * @return Swift_Signers_SMimeSigner + */ + public function setSignThenEncrypt($signThenEncrypt = true) + { + $this->signThenEncrypt = $signThenEncrypt; + + return $this; + } + + /** + * @return bool + */ + public function isSignThenEncrypt() + { + return $this->signThenEncrypt; + } + + /** + * Resets internal states. + * + * @return Swift_Signers_SMimeSigner + */ + public function reset() + { + return $this; + } + + /** + * Change the Swift_Message to apply the signing. + * + * @param Swift_Message $message + * + * @return Swift_Signers_SMimeSigner + */ + public function signMessage(Swift_Message $message) + { + if (null === $this->signCertificate && null === $this->encryptCert) { + return $this; + } + + // Store the message using ByteStream to a file{1} + // Remove all Children + // Sign file{1}, parse the new MIME headers and set them on the primary MimeEntity + // Set the singed-body as the new body (without boundary) + + $messageStream = new Swift_ByteStream_TemporaryFileByteStream(); + $this->toSMimeByteStream($messageStream, $message); + $message->setEncoder(Swift_DependencyContainer::getInstance()->lookup('mime.rawcontentencoder')); + + $message->setChildren(array()); + $this->streamToMime($messageStream, $message); + + } + + /** + * Return the list of header a signer might tamper. + * + * @return array + */ + public function getAlteredHeaders() + { + return array('Content-Type', 'Content-Transfer-Encoding', 'Content-Disposition'); + } + + /** + * @param Swift_InputByteStream $inputStream + * @param Swift_Message $mimeEntity + */ + protected function toSMimeByteStream(Swift_InputByteStream $inputStream, Swift_Message $message) + { + $mimeEntity = $this->createMessage($message); + $messageStream = new Swift_ByteStream_TemporaryFileByteStream(); + + $mimeEntity->toByteStream($messageStream); + $messageStream->commit(); + + if (null !== $this->signCertificate && null !== $this->encryptCert) { + $temporaryStream = new Swift_ByteStream_TemporaryFileByteStream(); + + if ($this->signThenEncrypt) { + $this->messageStreamToSignedByteStream($messageStream, $temporaryStream); + $this->messageStreamToEncryptedByteStream($temporaryStream, $inputStream); + } else { + $this->messageStreamToEncryptedByteStream($messageStream, $temporaryStream); + $this->messageStreamToSignedByteStream($temporaryStream, $inputStream); + } + } elseif ($this->signCertificate !== null) { + $this->messageStreamToSignedByteStream($messageStream, $inputStream); + } else { + $this->messageStreamToEncryptedByteStream($messageStream, $inputStream); + } + } + + /** + * @param Swift_Message $message + * + * @return Swift_Message + */ + protected function createMessage(Swift_Message $message) + { + $mimeEntity = new Swift_Message('', $message->getBody(), $message->getContentType(), $message->getCharset()); + $mimeEntity->setChildren($message->getChildren()); + + $messageHeaders = $mimeEntity->getHeaders(); + $messageHeaders->remove('Message-ID'); + $messageHeaders->remove('Date'); + $messageHeaders->remove('Subject'); + $messageHeaders->remove('MIME-Version'); + $messageHeaders->remove('To'); + $messageHeaders->remove('From'); + + return $mimeEntity; + } + + /** + * @param Swift_FileStream $outputStream + * @param Swift_InputByteStream $inputStream + * + * @throws Swift_IoException + */ + protected function messageStreamToSignedByteStream(Swift_FileStream $outputStream, Swift_InputByteStream $inputStream) + { + $signedMessageStream = new Swift_ByteStream_TemporaryFileByteStream(); + + if (!openssl_pkcs7_sign($outputStream->getPath(), $signedMessageStream->getPath(), $this->signCertificate, $this->signPrivateKey, array(), $this->signOptions)) { + throw new Swift_IoException(sprintf('Failed to sign S/Mime message. Error: "%s".', openssl_error_string())); + } + + $this->copyFromOpenSSLOutput($signedMessageStream, $inputStream); + } + + /** + * @param Swift_FileStream $outputStream + * @param Swift_InputByteStream $is + * + * @throws Swift_IoException + */ + protected function messageStreamToEncryptedByteStream(Swift_FileStream $outputStream, Swift_InputByteStream $is) + { + $encryptedMessageStream = new Swift_ByteStream_TemporaryFileByteStream(); + + if (!openssl_pkcs7_encrypt($outputStream->getPath(), $encryptedMessageStream->getPath(), $this->encryptCert, array(), 0, $this->encryptCipher)) { + throw new Swift_IoException(sprintf('Failed to encrypt S/Mime message. Error: "%s".', openssl_error_string())); + } + + $this->copyFromOpenSSLOutput($encryptedMessageStream, $is); + } + + /** + * @param Swift_OutputByteStream $fromStream + * @param Swift_InputByteStream $toStream + */ + protected function copyFromOpenSSLOutput(Swift_OutputByteStream $fromStream, Swift_InputByteStream $toStream) + { + $bufferLength = 4096; + $filteredStream = new Swift_ByteStream_TemporaryFileByteStream(); + $filteredStream->addFilter($this->replacementFactory->createFilter("\r\n", "\n"), 'CRLF to LF'); + $filteredStream->addFilter($this->replacementFactory->createFilter("\n", "\r\n"), 'LF to CRLF'); + + while (false !== ($buffer = $fromStream->read($bufferLength))) { + $filteredStream->write($buffer); + } + + $filteredStream->flushBuffers(); + + while (false !== ($buffer = $filteredStream->read($bufferLength))) { + $toStream->write($buffer); + } + + $toStream->commit(); + } + + /** + * Merges an OutputByteStream to Swift_Message. + * + * @param Swift_OutputByteStream $fromStream + * @param Swift_Message $message + */ + protected function streamToMime(Swift_OutputByteStream $fromStream, Swift_Message $message) + { + $bufferLength = 78; + $headerData = ''; + + $fromStream->setReadPointer(0); + + while (($buffer = $fromStream->read($bufferLength)) !== false) { + $headerData .= $buffer; + + if (false !== strpos($buffer, "\r\n\r\n")) { + break; + } + } + + $headersPosEnd = strpos($headerData, "\r\n\r\n"); + $headerData = trim($headerData); + $headerData = substr($headerData, 0, $headersPosEnd); + $headerLines = explode("\r\n", $headerData); + unset($headerData); + + $headers = array(); + $currentHeaderName = ''; + + foreach ($headerLines as $headerLine) { + // Line separated + if (ctype_space($headerLines[0]) || false === strpos($headerLine, ':')) { + $headers[$currentHeaderName] .= ' ' . trim($headerLine); + continue; + } + + $header = explode(':', $headerLine, 2); + $currentHeaderName = strtolower($header[0]); + $headers[$currentHeaderName] = trim($header[1]); + } + + $messageStream = new Swift_ByteStream_TemporaryFileByteStream(); + $messageStream->addFilter($this->replacementFactory->createFilter("\r\n", "\n"), 'CRLF to LF'); + $messageStream->addFilter($this->replacementFactory->createFilter("\n", "\r\n"), 'LF to CRLF'); + + $messageHeaders = $message->getHeaders(); + + // No need to check for 'application/pkcs7-mime', as this is always base64 + if ('multipart/signed;' === substr($headers['content-type'], 0, 17)) { + if (!preg_match('/boundary=("[^"]+"|(?:[^\s]+|$))/is', $headers['content-type'], $contentTypeData)) { + throw new Swift_SwiftException('Failed to find Boundary parameter'); + } + + $boundary = trim($contentTypeData['1'], '"'); + $boundaryLen = strlen($boundary); + + // Skip the header and CRLF CRLF + $fromStream->setReadPointer($headersPosEnd + 4); + + while (false !== ($buffer = $fromStream->read($bufferLength))) { + $messageStream->write($buffer); + } + + $messageStream->commit(); + + $messageHeaders->remove('Content-Transfer-Encoding'); + $message->setContentType($headers['content-type']); + $message->setBoundary($boundary); + $message->setBody($messageStream); + } else { + $fromStream->setReadPointer($headersPosEnd + 4); + + if (null === $this->headerFactory) { + $this->headerFactory = Swift_DependencyContainer::getInstance()->lookup('mime.headerfactory'); + } + + $message->setContentType($headers['content-type']); + $messageHeaders->set($this->headerFactory->createTextHeader('Content-Transfer-Encoding', $headers['content-transfer-encoding'])); + $messageHeaders->set($this->headerFactory->createTextHeader('Content-Disposition', $headers['content-disposition'])); + + while (false !== ($buffer = $fromStream->read($bufferLength))) { + $messageStream->write($buffer); + } + + $messageStream->commit(); + $message->setBody($messageStream); + } + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/SmtpTransport.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/SmtpTransport.php new file mode 100755 index 0000000..b369f04 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/SmtpTransport.php @@ -0,0 +1,59 @@ +createDependenciesFor('transport.smtp') + ); + + $this->setHost($host); + $this->setPort($port); + $this->setEncryption($security); + } + + /** + * Create a new SmtpTransport instance. + * + * @param string $host + * @param int $port + * @param string $security + * + * @return Swift_SmtpTransport + */ + public static function newInstance($host = 'localhost', $port = 25, $security = null) + { + return new self($host, $port, $security); + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Spool.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Spool.php new file mode 100755 index 0000000..670be25 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Spool.php @@ -0,0 +1,54 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +/** + * Interface for spools. + * + * @package Swift + * @author Fabien Potencier + */ +interface Swift_Spool +{ + /** + * Starts this Spool mechanism. + */ + public function start(); + + /** + * Stops this Spool mechanism. + */ + public function stop(); + + /** + * Tests if this Spool mechanism has started. + * + * @return bool + */ + public function isStarted(); + + /** + * Queues a message. + * + * @param Swift_Mime_Message $message The message to store + * + * @return bool Whether the operation has succeeded + */ + public function queueMessage(Swift_Mime_Message $message); + + /** + * Sends messages using the given transport instance. + * + * @param Swift_Transport $transport A transport instance + * @param string[] $failedRecipients An array of failures by-reference + * + * @return int The number of sent emails + */ + public function flushQueue(Swift_Transport $transport, &$failedRecipients = null); +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/SpoolTransport.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/SpoolTransport.php new file mode 100755 index 0000000..8a135d4 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/SpoolTransport.php @@ -0,0 +1,48 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +/** + * Stores Messages in a queue. + * + * @package Swift + * @author Fabien Potencier + */ +class Swift_SpoolTransport extends Swift_Transport_SpoolTransport +{ + /** + * Create a new SpoolTransport. + * + * @param Swift_Spool $spool + */ + public function __construct(Swift_Spool $spool) + { + $arguments = Swift_DependencyContainer::getInstance() + ->createDependenciesFor('transport.spool'); + + $arguments[] = $spool; + + call_user_func_array( + array($this, 'Swift_Transport_SpoolTransport::__construct'), + $arguments + ); + } + + /** + * Create a new SpoolTransport instance. + * + * @param Swift_Spool $spool + * + * @return Swift_SpoolTransport + */ + public static function newInstance(Swift_Spool $spool) + { + return new self($spool); + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/StreamFilter.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/StreamFilter.php new file mode 100755 index 0000000..b62e751 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/StreamFilter.php @@ -0,0 +1,36 @@ +_search = $search; + $this->_index = array(); + $this->_tree = array(); + $this->_replace = array(); + $this->_repSize = array(); + + $tree = null; + $i = null; + $last_size = $size = 0; + foreach ($search as $i => $search_element) { + if ($tree !== null) { + $tree[-1] = min (count($replace) - 1, $i - 1); + $tree[-2] = $last_size; + } + $tree = &$this->_tree; + if (is_array ($search_element)) { + foreach ($search_element as $k => $char) { + $this->_index[$char] = true; + if (!isset($tree[$char])) { + $tree[$char] = array(); + } + $tree = &$tree[$char]; + } + $last_size = $k+1; + $size = max($size, $last_size); + } else { + $last_size = 1; + if (!isset($tree[$search_element])) { + $tree[$search_element] = array(); + } + $tree = &$tree[$search_element]; + $size = max($last_size, $size); + $this->_index[$search_element] = true; + } + } + if ($i !== null) { + $tree[-1] = min (count ($replace) - 1, $i); + $tree[-2] = $last_size; + $this->_treeMaxLen = $size; + } + foreach ($replace as $rep) { + if (!is_array($rep)) { + $rep = array ($rep); + } + $this->_replace[] = $rep; + } + for ($i = count($this->_replace) - 1; $i >= 0; --$i) { + $this->_replace[$i] = $rep = $this->filter($this->_replace[$i], $i); + $this->_repSize[$i] = count($rep); + } + } + + /** + * Returns true if based on the buffer passed more bytes should be buffered. + * + * @param array $buffer + * + * @return bool + */ + public function shouldBuffer($buffer) + { + $endOfBuffer = end($buffer); + + return isset ($this->_index[$endOfBuffer]); + } + + /** + * Perform the actual replacements on $buffer and return the result. + * + * @param array $buffer + * @param int $_minReplaces + * + * @return array + */ + public function filter($buffer, $_minReplaces = -1) + { + if ($this->_treeMaxLen == 0) { + return $buffer; + } + + $newBuffer = array(); + $buf_size = count($buffer); + for ($i = 0; $i < $buf_size; ++$i) { + $search_pos = $this->_tree; + $last_found = PHP_INT_MAX; + // We try to find if the next byte is part of a search pattern + for ($j = 0; $j <= $this->_treeMaxLen; ++$j) { + // We have a new byte for a search pattern + if (isset ($buffer [$p = $i + $j]) && isset($search_pos[$buffer[$p]])) { + $search_pos = $search_pos[$buffer[$p]]; + // We have a complete pattern, save, in case we don't find a better match later + if (isset($search_pos[- 1]) && $search_pos[-1] < $last_found + && $search_pos[-1] > $_minReplaces) + { + $last_found = $search_pos[-1]; + $last_size = $search_pos[-2]; + } + } + // We got a complete pattern + elseif ($last_found !== PHP_INT_MAX) { + // Adding replacement datas to output buffer + $rep_size = $this->_repSize[$last_found]; + for ($j = 0; $j < $rep_size; ++$j) { + $newBuffer[] = $this->_replace[$last_found][$j]; + } + // We Move cursor forward + $i += $last_size - 1; + // Edge Case, last position in buffer + if ($i >= $buf_size) { + $newBuffer[] = $buffer[$i]; + } + + // We start the next loop + continue 2; + } else { + // this byte is not in a pattern and we haven't found another pattern + break; + } + } + // Normal byte, move it to output buffer + $newBuffer[] = $buffer[$i]; + } + + return $newBuffer; + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/StreamFilters/StringReplacementFilter.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/StreamFilters/StringReplacementFilter.php new file mode 100755 index 0000000..4075d08 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/StreamFilters/StringReplacementFilter.php @@ -0,0 +1,67 @@ +_search = $search; + $this->_replace = $replace; + } + + /** + * Returns true if based on the buffer passed more bytes should be buffered. + * + * @param string $buffer + * + * @return bool + */ + public function shouldBuffer($buffer) + { + $endOfBuffer = substr($buffer, -1); + foreach ((array) $this->_search as $needle) { + if (false !== strpos($needle, $endOfBuffer)) { + return true; + } + } + + return false; + } + + /** + * Perform the actual replacements on $buffer and return the result. + * + * @param string $buffer + * + * @return string + */ + public function filter($buffer) + { + return str_replace($this->_search, $this->_replace, $buffer); + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/StreamFilters/StringReplacementFilterFactory.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/StreamFilters/StringReplacementFilterFactory.php new file mode 100755 index 0000000..bb4af77 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/StreamFilters/StringReplacementFilterFactory.php @@ -0,0 +1,46 @@ +_filters[$search][$replace])) { + if (!isset($this->_filters[$search])) { + $this->_filters[$search] = array(); + } + + if (!isset($this->_filters[$search][$replace])) { + $this->_filters[$search][$replace] = array(); + } + + $this->_filters[$search][$replace] = new Swift_StreamFilters_StringReplacementFilter($search, $replace); + } + + return $this->_filters[$search][$replace]; + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/SwiftException.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/SwiftException.php new file mode 100755 index 0000000..f3bcbed --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/SwiftException.php @@ -0,0 +1,28 @@ +_eventDispatcher = $dispatcher; + $this->_buffer = $buf; + $this->_lookupHostname(); + } + + /** + * Set the name of the local domain which Swift will identify itself as. + * + * This should be a fully-qualified domain name and should be truly the domain + * you're using. + * + * If your server doesn't have a domain name, use the IP in square + * brackets (i.e. [127.0.0.1]). + * + * @param string $domain + * + * @return Swift_Transport_AbstractSmtpTransport + */ + public function setLocalDomain($domain) + { + $this->_domain = $domain; + + return $this; + } + + /** + * Get the name of the domain Swift will identify as. + * + * @return string + */ + public function getLocalDomain() + { + return $this->_domain; + } + + /** + * Sets the source IP. + * + * @param string $source + */ + public function setSourceIp($source) + { + $this->_sourceIp=$source; + } + + /** + * Returns the IP used to connect to the destination + * + * @return string + */ + public function getSourceIp() + { + return $this->_sourceIp; + } + + /** + * Start the SMTP connection. + */ + public function start() + { + if (!$this->_started) { + if ($evt = $this->_eventDispatcher->createTransportChangeEvent($this)) { + $this->_eventDispatcher->dispatchEvent($evt, 'beforeTransportStarted'); + if ($evt->bubbleCancelled()) { + return; + } + } + + try { + $this->_buffer->initialize($this->_getBufferParams()); + } catch (Swift_TransportException $e) { + $this->_throwException($e); + } + $this->_readGreeting(); + $this->_doHeloCommand(); + + if ($evt) { + $this->_eventDispatcher->dispatchEvent($evt, 'transportStarted'); + } + + $this->_started = true; + } + } + + /** + * Test if an SMTP connection has been established. + * + * @return bool + */ + public function isStarted() + { + return $this->_started; + } + + /** + * Send the given Message. + * + * Recipient/sender data will be retrieved from the Message API. + * The return value is the number of recipients who were accepted for delivery. + * + * @param Swift_Mime_Message $message + * @param string[] $failedRecipients An array of failures by-reference + * + * @return int + */ + public function send(Swift_Mime_Message $message, &$failedRecipients = null) + { + $sent = 0; + $failedRecipients = (array) $failedRecipients; + + if ($evt = $this->_eventDispatcher->createSendEvent($this, $message)) { + $this->_eventDispatcher->dispatchEvent($evt, 'beforeSendPerformed'); + if ($evt->bubbleCancelled()) { + return 0; + } + } + + if (!$reversePath = $this->_getReversePath($message)) { + throw new Swift_TransportException( + 'Cannot send message without a sender address' + ); + } + + $to = (array) $message->getTo(); + $cc = (array) $message->getCc(); + $bcc = (array) $message->getBcc(); + + $message->setBcc(array()); + + try { + $sent += $this->_sendTo($message, $reversePath, $to, $failedRecipients); + $sent += $this->_sendCc($message, $reversePath, $cc, $failedRecipients); + $sent += $this->_sendBcc($message, $reversePath, $bcc, $failedRecipients); + } catch (Exception $e) { + $message->setBcc($bcc); + throw $e; + } + + $message->setBcc($bcc); + + if ($evt) { + if ($sent == count($to) + count($cc) + count($bcc)) { + $evt->setResult(Swift_Events_SendEvent::RESULT_SUCCESS); + } elseif ($sent > 0) { + $evt->setResult(Swift_Events_SendEvent::RESULT_TENTATIVE); + } else { + $evt->setResult(Swift_Events_SendEvent::RESULT_FAILED); + } + $evt->setFailedRecipients($failedRecipients); + $this->_eventDispatcher->dispatchEvent($evt, 'sendPerformed'); + } + + $message->generateId(); //Make sure a new Message ID is used + + return $sent; + } + + /** + * Stop the SMTP connection. + */ + public function stop() + { + if ($this->_started) { + if ($evt = $this->_eventDispatcher->createTransportChangeEvent($this)) { + $this->_eventDispatcher->dispatchEvent($evt, 'beforeTransportStopped'); + if ($evt->bubbleCancelled()) { + return; + } + } + + try { + $this->executeCommand("QUIT\r\n", array(221)); + } catch (Swift_TransportException $e) {} + + try { + $this->_buffer->terminate(); + + if ($evt) { + $this->_eventDispatcher->dispatchEvent($evt, 'transportStopped'); + } + } catch (Swift_TransportException $e) { + $this->_throwException($e); + } + } + $this->_started = false; + } + + /** + * Register a plugin. + * + * @param Swift_Events_EventListener $plugin + */ + public function registerPlugin(Swift_Events_EventListener $plugin) + { + $this->_eventDispatcher->bindEventListener($plugin); + } + + /** + * Reset the current mail transaction. + */ + public function reset() + { + $this->executeCommand("RSET\r\n", array(250)); + } + + /** + * Get the IoBuffer where read/writes are occurring. + * + * @return Swift_Transport_IoBuffer + */ + public function getBuffer() + { + return $this->_buffer; + } + + /** + * Run a command against the buffer, expecting the given response codes. + * + * If no response codes are given, the response will not be validated. + * If codes are given, an exception will be thrown on an invalid response. + * + * @param string $command + * @param int[] $codes + * @param string[] $failures An array of failures by-reference + * + * @return string + */ + public function executeCommand($command, $codes = array(), &$failures = null) + { + $failures = (array) $failures; + $seq = $this->_buffer->write($command); + $response = $this->_getFullResponse($seq); + if ($evt = $this->_eventDispatcher->createCommandEvent($this, $command, $codes)) { + $this->_eventDispatcher->dispatchEvent($evt, 'commandSent'); + } + $this->_assertResponseCode($response, $codes); + + return $response; + } + + // -- Protected methods + + /** Read the opening SMTP greeting */ + protected function _readGreeting() + { + $this->_assertResponseCode($this->_getFullResponse(0), array(220)); + } + + /** Send the HELO welcome */ + protected function _doHeloCommand() + { + $this->executeCommand( + sprintf("HELO %s\r\n", $this->_domain), array(250) + ); + } + + /** Send the MAIL FROM command */ + protected function _doMailFromCommand($address) + { + $this->executeCommand( + sprintf("MAIL FROM: <%s>\r\n", $address), array(250) + ); + } + + /** Send the RCPT TO command */ + protected function _doRcptToCommand($address) + { + $this->executeCommand( + sprintf("RCPT TO: <%s>\r\n", $address), array(250, 251, 252) + ); + } + + /** Send the DATA command */ + protected function _doDataCommand() + { + $this->executeCommand("DATA\r\n", array(354)); + } + + /** Stream the contents of the message over the buffer */ + protected function _streamMessage(Swift_Mime_Message $message) + { + $this->_buffer->setWriteTranslations(array("\r\n." => "\r\n..")); + try { + $message->toByteStream($this->_buffer); + $this->_buffer->flushBuffers(); + } catch (Swift_TransportException $e) { + $this->_throwException($e); + } + $this->_buffer->setWriteTranslations(array()); + $this->executeCommand("\r\n.\r\n", array(250)); + } + + /** Determine the best-use reverse path for this message */ + protected function _getReversePath(Swift_Mime_Message $message) + { + $return = $message->getReturnPath(); + $sender = $message->getSender(); + $from = $message->getFrom(); + $path = null; + if (!empty($return)) { + $path = $return; + } elseif (!empty($sender)) { + // Don't use array_keys + reset($sender); // Reset Pointer to first pos + $path = key($sender); // Get key + } elseif (!empty($from)) { + reset($from); // Reset Pointer to first pos + $path = key($from); // Get key + } + + return $path; + } + + /** Throw a TransportException, first sending it to any listeners */ + protected function _throwException(Swift_TransportException $e) + { + if ($evt = $this->_eventDispatcher->createTransportExceptionEvent($this, $e)) { + $this->_eventDispatcher->dispatchEvent($evt, 'exceptionThrown'); + if (!$evt->bubbleCancelled()) { + throw $e; + } + } else { + throw $e; + } + } + + /** Throws an Exception if a response code is incorrect */ + protected function _assertResponseCode($response, $wanted) + { + list($code) = sscanf($response, '%3d'); + $valid = (empty($wanted) || in_array($code, $wanted)); + + if ($evt = $this->_eventDispatcher->createResponseEvent($this, $response, + $valid)) + { + $this->_eventDispatcher->dispatchEvent($evt, 'responseReceived'); + } + + if (!$valid) { + $this->_throwException( + new Swift_TransportException( + 'Expected response code ' . implode('/', $wanted) . ' but got code ' . + '"' . $code . '", with message "' . $response . '"', + $code) + ); + } + } + + /** Get an entire multi-line response using its sequence number */ + protected function _getFullResponse($seq) + { + $response = ''; + try { + do { + $line = $this->_buffer->readLine($seq); + $response .= $line; + } while (null !== $line && false !== $line && ' ' != $line{3}); + } catch (Swift_IoException $e) { + $this->_throwException( + new Swift_TransportException( + $e->getMessage()) + ); + } catch (Swift_TransportException $e) { + $this->_throwException($e); + } + + return $response; + } + + // -- Private methods + + /** Send an email to the given recipients from the given reverse path */ + private function _doMailTransaction($message, $reversePath, array $recipients, array &$failedRecipients) + { + $sent = 0; + $this->_doMailFromCommand($reversePath); + foreach ($recipients as $forwardPath) { + try { + $this->_doRcptToCommand($forwardPath); + $sent++; + } catch (Swift_TransportException $e) { + $failedRecipients[] = $forwardPath; + } + } + + if ($sent != 0) { + $this->_doDataCommand(); + $this->_streamMessage($message); + } else { + $this->reset(); + } + + return $sent; + } + + /** Send a message to the given To: recipients */ + private function _sendTo(Swift_Mime_Message $message, $reversePath, array $to, array &$failedRecipients) + { + if (empty($to)) { + return 0; + } + + return $this->_doMailTransaction($message, $reversePath, array_keys($to), + $failedRecipients); + } + + /** Send a message to the given Cc: recipients */ + private function _sendCc(Swift_Mime_Message $message, $reversePath, array $cc, array &$failedRecipients) + { + if (empty($cc)) { + return 0; + } + + return $this->_doMailTransaction($message, $reversePath, array_keys($cc), + $failedRecipients); + } + + /** Send a message to all Bcc: recipients */ + private function _sendBcc(Swift_Mime_Message $message, $reversePath, array $bcc, array &$failedRecipients) + { + $sent = 0; + foreach ($bcc as $forwardPath => $name) { + $message->setBcc(array($forwardPath => $name)); + $sent += $this->_doMailTransaction( + $message, $reversePath, array($forwardPath), $failedRecipients + ); + } + + return $sent; + } + + /** Try to determine the hostname of the server this is run on */ + private function _lookupHostname() + { + if (!empty($_SERVER['SERVER_NAME']) + && $this->_isFqdn($_SERVER['SERVER_NAME'])) + { + $this->_domain = $_SERVER['SERVER_NAME']; + } elseif (!empty($_SERVER['SERVER_ADDR'])) { + $this->_domain = sprintf('[%s]', $_SERVER['SERVER_ADDR']); + } + } + + /** Determine is the $hostname is a fully-qualified name */ + private function _isFqdn($hostname) + { + // We could do a really thorough check, but there's really no point + if (false !== $dotPos = strpos($hostname, '.')) { + return ($dotPos > 0) && ($dotPos != strlen($hostname) - 1); + } else { + return false; + } + } + + /** + * Destructor. + */ + public function __destruct() + { + $this->stop(); + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/CramMd5Authenticator.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/CramMd5Authenticator.php new file mode 100755 index 0000000..5c26e4b --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/CramMd5Authenticator.php @@ -0,0 +1,83 @@ +executeCommand("AUTH CRAM-MD5\r\n", array(334)); + $challenge = base64_decode(substr($challenge, 4)); + $message = base64_encode( + $username . ' ' . $this->_getResponse($password, $challenge) + ); + $agent->executeCommand(sprintf("%s\r\n", $message), array(235)); + + return true; + } catch (Swift_TransportException $e) { + $agent->executeCommand("RSET\r\n", array(250)); + + return false; + } + } + + /** + * Generate a CRAM-MD5 response from a server challenge. + * + * @param string $secret + * @param string $challenge + * + * @return string + */ + private function _getResponse($secret, $challenge) + { + if (strlen($secret) > 64) { + $secret = pack('H32', md5($secret)); + } + + if (strlen($secret) < 64) { + $secret = str_pad($secret, 64, chr(0)); + } + + $k_ipad = substr($secret, 0, 64) ^ str_repeat(chr(0x36), 64); + $k_opad = substr($secret, 0, 64) ^ str_repeat(chr(0x5C), 64); + + $inner = pack('H32', md5($k_ipad . $challenge)); + $digest = md5($k_opad . $inner); + + return $digest; + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/LoginAuthenticator.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/LoginAuthenticator.php new file mode 100755 index 0000000..8ff7dee --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/LoginAuthenticator.php @@ -0,0 +1,53 @@ +executeCommand("AUTH LOGIN\r\n", array(334)); + $agent->executeCommand(sprintf("%s\r\n", base64_encode($username)), array(334)); + $agent->executeCommand(sprintf("%s\r\n", base64_encode($password)), array(235)); + + return true; + } catch (Swift_TransportException $e) { + $agent->executeCommand("RSET\r\n", array(250)); + + return false; + } + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/NTLMAuthenticator.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/NTLMAuthenticator.php new file mode 100755 index 0000000..62eacdd --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/NTLMAuthenticator.php @@ -0,0 +1,701 @@ + + */ +class Swift_Transport_Esmtp_Auth_NTLMAuthenticator implements Swift_Transport_Esmtp_Authenticator +{ + const NTLMSIG = "NTLMSSP\x00"; + const DESCONST = "KGS!@#$%"; + + /** + * Get the name of the AUTH mechanism this Authenticator handles. + * + * @return string + */ + public function getAuthKeyword() + { + return 'NTLM'; + } + + /** + * Try to authenticate the user with $username and $password. + * + * @param Swift_Transport_SmtpAgent $agent + * @param string $username + * @param string $password + * + * @return bool + */ + public function authenticate(Swift_Transport_SmtpAgent $agent, $username, $password) + { + if (!function_exists('mcrypt_module_open')) { + throw new LogicException('The mcrypt functions need to be enabled to use the NTLM authenticator.'); + } + + if (!function_exists('openssl_random_pseudo_bytes')) { + throw new LogicException('The OpenSSL extension must be enabled to use the NTLM authenticator.'); + } + + if (!function_exists('bcmul')) { + throw new LogicException('The BCMatch functions must be enabled to use the NTLM authenticator.'); + } + + try { + // execute AUTH command and filter out the code at the beginning + // AUTH NTLM xxxx + $response = base64_decode(substr(trim($this->sendMessage1($agent)), 4)); + + // extra parameters for our unit cases + $timestamp = func_num_args() > 3 ? func_get_arg(3) : $this->getCorrectTimestamp(bcmul(microtime(true), "1000")); + $client = func_num_args() > 4 ? func_get_arg(4) : $this->getRandomBytes(8); + + // Message 3 response + $this->sendMessage3($response, $username, $password, $timestamp, $client, $agent); + + return true; + } catch (Swift_TransportException $e) { + $agent->executeCommand("RSET\r\n", array(250)); + + return false; + } + } + + protected function si2bin($si, $bits = 32) + { + $bin = null; + if ($si >= -pow(2, $bits - 1) && ($si <= pow(2, $bits - 1))) { + // positive or zero + if ($si >= 0) { + $bin = base_convert($si, 10, 2); + // pad to $bits bit + $bin_length = strlen($bin); + if ($bin_length < $bits) { + $bin = str_repeat("0", $bits - $bin_length) . $bin; + } + } else { // negative + $si = -$si - pow(2, $bits); + $bin = base_convert($si, 10, 2); + $bin_length = strlen($bin); + if ($bin_length > $bits) { + $bin = str_repeat("1", $bits - $bin_length) . $bin; + } + } + } + + return $bin; + } + + /** + * Send our auth message and returns the response + * + * @param Swift_Transport_SmtpAgent $agent + * @return string SMTP Response + */ + protected function sendMessage1(Swift_Transport_SmtpAgent $agent) + { + $message = $this->createMessage1(); + + return $agent->executeCommand(sprintf("AUTH %s %s\r\n", $this->getAuthKeyword(), base64_encode($message)), array(334)); + } + + /** + * Fetch all details of our response (message 2) + * + * @param string $response + * @return array our response parsed + */ + protected function parseMessage2($response) + { + $responseHex = bin2hex($response); + $length = floor(hexdec(substr($responseHex, 28, 4)) / 256) * 2; + $offset = floor(hexdec(substr($responseHex, 32, 4)) / 256) * 2; + $challenge = $this->hex2bin(substr($responseHex, 48, 16)); + $context = $this->hex2bin(substr($responseHex, 64, 16)); + $targetInfoH = $this->hex2bin(substr($responseHex, 80, 16)); + $targetName = $this->hex2bin(substr($responseHex, $offset, $length)); + $offset = floor(hexdec(substr($responseHex, 88, 4)) / 256) * 2; + $targetInfoBlock = substr($responseHex, $offset); + list($domainName, $serverName, $DNSDomainName, $DNSServerName, $terminatorByte) = $this->readSubBlock($targetInfoBlock); + + return array( + $challenge, + $context, + $targetInfoH, + $targetName, + $domainName, + $serverName, + $DNSDomainName, + $DNSServerName, + $this->hex2bin($targetInfoBlock), + $terminatorByte + ); + } + + /** + * Read the blob information in from message2 + * + * @param $block + * @return array + */ + protected function readSubBlock($block) + { + // remove terminatorByte cause it's always the same + $block = substr($block, 0, -8); + + $length = strlen($block); + $offset = 0; + $data = array(); + while ($offset < $length) { + $blockLength = hexdec(substr(substr($block, $offset, 8), -4)) / 256; + $offset += 8; + $data[] = $this->hex2bin(substr($block, $offset, $blockLength * 2)); + $offset += $blockLength * 2; + } + + if (count($data) == 3) { + $data[] = $data[2]; + $data[2] = ''; + } + + $data[] = $this->createByte('00'); + + return $data; + } + + /** + * Send our final message with all our data + * + * @param string $response Message 1 response (message 2) + * @param string $username + * @param string $password + * @param string $timestamp + * @param string $client + * @param Swift_Transport_SmtpAgent $agent + * @param bool $v2 Use version2 of the protocol + * @return string + */ + protected function sendMessage3($response, $username, $password, $timestamp, $client, Swift_Transport_SmtpAgent $agent, $v2 = true) + { + list($domain, $username) = $this->getDomainAndUsername($username); + //$challenge, $context, $targetInfoH, $targetName, $domainName, $workstation, $DNSDomainName, $DNSServerName, $blob, $ter + list($challenge, , , , , $workstation, , , $blob) = $this->parseMessage2($response); + + if (!$v2) { + // LMv1 + $lmResponse = $this->createLMPassword($password, $challenge); + // NTLMv1 + $ntlmResponse = $this->createNTLMPassword($password, $challenge); + } else { + // LMv2 + $lmResponse = $this->createLMv2Password($password, $username, $domain, $challenge, $client); + // NTLMv2 + $ntlmResponse = $this->createNTLMv2Hash($password, $username, $domain, $challenge, $blob, $timestamp, $client); + } + + $message = $this->createMessage3($domain, $username, $workstation, $lmResponse, $ntlmResponse); + + return $agent->executeCommand(sprintf("%s\r\n", base64_encode($message)), array(235)); + } + + /** + * Create our message 1 + * + * @return string + */ + protected function createMessage1() + { + return self::NTLMSIG + . $this->createByte('01') // Message 1 + . $this->createByte('0702'); // Flags + } + + /** + * Create our message 3 + * + * @param string $domain + * @param string $username + * @param string $workstation + * @param string $lmResponse + * @param string $ntlmResponse + * @return string + */ + protected function createMessage3($domain, $username, $workstation, $lmResponse, $ntlmResponse) + { + // Create security buffers + $domainSec = $this->createSecurityBuffer($domain, 64); + $domainInfo = $this->readSecurityBuffer(bin2hex($domainSec)); + $userSec = $this->createSecurityBuffer($username, ($domainInfo[0] + $domainInfo[1]) / 2); + $userInfo = $this->readSecurityBuffer(bin2hex($userSec)); + $workSec = $this->createSecurityBuffer($workstation, ($userInfo[0] + $userInfo[1]) / 2); + $workInfo = $this->readSecurityBuffer(bin2hex($workSec)); + $lmSec = $this->createSecurityBuffer($lmResponse, ($workInfo[0] + $workInfo[1]) / 2, true); + $lmInfo = $this->readSecurityBuffer(bin2hex($lmSec)); + $ntlmSec = $this->createSecurityBuffer($ntlmResponse, ($lmInfo[0] + $lmInfo[1]) / 2, true); + + return self::NTLMSIG + . $this->createByte('03') // TYPE 3 message + . $lmSec // LM response header + . $ntlmSec // NTLM response header + . $domainSec // Domain header + . $userSec // User header + . $workSec // Workstation header + . $this->createByte("000000009a", 8) // session key header (empty) + . $this->createByte('01020000') // FLAGS + . $this->convertTo16bit($domain) // domain name + . $this->convertTo16bit($username) // username + . $this->convertTo16bit($workstation) // workstation + . $lmResponse + . $ntlmResponse; + } + + /** + * @param string $timestamp Epoch timestamp in microseconds + * @param string $client Random bytes + * @param string $targetInfo + * @return string + */ + protected function createBlob($timestamp, $client, $targetInfo) + { + return $this->createByte('0101') + . $this->createByte('00') + . $timestamp + . $client + . $this->createByte('00') + . $targetInfo + . $this->createByte('00'); + } + + /** + * Get domain and username from our username + * + * @example DOMAIN\username + * + * @param string $name + * @return array + */ + protected function getDomainAndUsername($name) + { + if (strpos($name, '\\') !== false) { + return explode('\\', $name); + } + + list($user, $domain) = explode('@', $name); + + return array($domain, $user); + } + + /** + * Create LMv1 response + * + * @param string $password + * @param string $challenge + * @return string + */ + protected function createLMPassword($password, $challenge) + { + // FIRST PART + $password = $this->createByte(strtoupper($password), 14, false); + list($key1, $key2) = str_split($password, 7); + + $desKey1 = $this->createDesKey($key1); + $desKey2 = $this->createDesKey($key2); + + $constantDecrypt = $this->createByte($this->desEncrypt(self::DESCONST, $desKey1) . $this->desEncrypt(self::DESCONST, $desKey2), 21, false); + + // SECOND PART + list($key1, $key2, $key3) = str_split($constantDecrypt, 7); + + $desKey1 = $this->createDesKey($key1); + $desKey2 = $this->createDesKey($key2); + $desKey3 = $this->createDesKey($key3); + + return $this->desEncrypt($challenge, $desKey1) . $this->desEncrypt($challenge, $desKey2) . $this->desEncrypt($challenge, $desKey3); + } + + /** + * Create NTLMv1 response + * + * @param string $password + * @param string $challenge + * @return string + */ + protected function createNTLMPassword($password, $challenge) + { + // FIRST PART + $ntlmHash = $this->createByte($this->md4Encrypt($password), 21, false); + list($key1, $key2, $key3) = str_split($ntlmHash, 7); + + $desKey1 = $this->createDesKey($key1); + $desKey2 = $this->createDesKey($key2); + $desKey3 = $this->createDesKey($key3); + + return $this->desEncrypt($challenge, $desKey1) . $this->desEncrypt($challenge, $desKey2) . $this->desEncrypt($challenge, $desKey3); + } + + /** + * Convert a normal timestamp to a tenth of a microtime epoch time + * + * @param string $time + * @return string + */ + protected function getCorrectTimestamp($time) + { + // Get our timestamp (tricky!) + bcscale(0); + + $time = number_format($time, 0, '.', ''); // save microtime to string + $time = bcadd($time, "11644473600000"); // add epoch time + $time = bcmul($time, 10000); // tenths of a microsecond. + + $binary = $this->si2bin($time, 64); // create 64 bit binary string + $timestamp = ""; + for ($i = 0; $i < 8; $i++) { + $timestamp .= chr(bindec(substr($binary, -(($i + 1) * 8), 8))); + } + + return $timestamp; + } + + /** + * Create LMv2 response + * + * @param string $password + * @param string $username + * @param string $domain + * @param string $challenge NTLM Challenge + * @param string $client Random string + * @return string + */ + protected function createLMv2Password($password, $username, $domain, $challenge, $client) + { + $lmPass = '00'; // by default 00 + // if $password > 15 than we can't use this method + if (strlen($password) <= 15) { + $ntlmHash = $this->md4Encrypt($password); + $ntml2Hash = $this->md5Encrypt($ntlmHash, $this->convertTo16bit(strtoupper($username) . $domain)); + + $lmPass = bin2hex($this->md5Encrypt($ntml2Hash, $challenge . $client) . $client); + } + + return $this->createByte($lmPass, 24); + } + + /** + * Create NTLMv2 response + * + * @param string $password + * @param string $username + * @param string $domain + * @param string $challenge Hex values + * @param string $targetInfo Hex values + * @param string $timestamp + * @param string $client Random bytes + * @return string + * @see http://davenport.sourceforge.net/ntlm.html#theNtlmResponse + */ + protected function createNTLMv2Hash($password, $username, $domain, $challenge, $targetInfo, $timestamp, $client) + { + $ntlmHash = $this->md4Encrypt($password); + $ntml2Hash = $this->md5Encrypt($ntlmHash, $this->convertTo16bit(strtoupper($username) . $domain)); + + // create blob + $blob = $this->createBlob($timestamp, $client, $targetInfo); + + $ntlmv2Response = $this->md5Encrypt($ntml2Hash, $challenge . $blob); + + return $ntlmv2Response . $blob; + } + + protected function createDesKey($key) + { + $material = array(bin2hex($key[0])); + $len = strlen($key); + for ($i = 1; $i < $len; $i++) { + list($high, $low) = str_split(bin2hex($key[$i])); + $v = $this->castToByte(ord($key[$i - 1]) << (7 + 1 - $i) | $this->uRShift(hexdec(dechex(hexdec($high) & 0xf) . dechex(hexdec($low) & 0xf)), $i)); + $material[] = str_pad(substr(dechex($v), -2), 2, '0', STR_PAD_LEFT); // cast to byte + } + $material[] = str_pad(substr(dechex($this->castToByte(ord($key[6]) << 1)), -2), 2, '0'); + + // odd parity + foreach ($material as $k => $v) { + $b = $this->castToByte(hexdec($v)); + $needsParity = (($this->uRShift($b, 7) ^ $this->uRShift($b, 6) ^ $this->uRShift($b, 5) + ^ $this->uRShift($b, 4) ^ $this->uRShift($b, 3) ^ $this->uRShift($b, 2) + ^ $this->uRShift($b, 1)) & 0x01) == 0; + + list($high, $low) = str_split($v); + if ($needsParity) { + $material[$k] = dechex(hexdec($high) | 0x0) . dechex(hexdec($low) | 0x1); + } else { + $material[$k] = dechex(hexdec($high) & 0xf) . dechex(hexdec($low) & 0xe); + } + } + + return $this->hex2bin(implode('', $material)); + } + + /** HELPER FUNCTIONS */ + /** + * Create our security buffer depending on length and offset + * + * @param string $value Value we want to put in + * @param int $offset start of value + * @param bool $is16 Do we 16bit string or not? + * @return string + */ + protected function createSecurityBuffer($value, $offset, $is16 = false) + { + $length = strlen(bin2hex($value)); + $length = $is16 ? $length / 2 : $length; + $length = $this->createByte(str_pad(dechex($length), 2, '0', STR_PAD_LEFT), 2); + + return $length . $length . $this->createByte(dechex($offset), 4); + } + + /** + * Read our security buffer to fetch length and offset of our value + * + * @param string $value Securitybuffer in hex + * @return array array with length and offset + */ + protected function readSecurityBuffer($value) + { + $length = floor(hexdec(substr($value, 0, 4)) / 256) * 2; + $offset = floor(hexdec(substr($value, 8, 4)) / 256) * 2; + + return array($length, $offset); + } + + /** + * Cast to byte java equivalent to (byte) + * + * @param int $v + * @return int + */ + protected function castToByte($v) + { + return (($v + 128) % 256) - 128; + } + + /** + * Java unsigned right bitwise + * $a >>> $b + * + * @param int $a + * @param int $b + * @return int + */ + protected function uRShift($a, $b) + { + if ($b == 0) { + return $a; + } + + return ($a >> $b) & ~(1 << (8 * PHP_INT_SIZE - 1) >> ($b - 1)); + } + + /** + * Right padding with 0 to certain length + * + * @param string $input + * @param int $bytes Length of bytes + * @param bool $isHex Did we provided hex value + * @return string + */ + protected function createByte($input, $bytes = 4, $isHex = true) + { + if ($isHex) { + $byte = $this->hex2bin(str_pad($input, $bytes * 2, '00')); + } else { + $byte = str_pad($input, $bytes, "\x00"); + } + + return $byte; + } + + /** + * Create random bytes + * + * @param $length + * @return string + */ + protected function getRandomBytes($length) + { + $bytes = openssl_random_pseudo_bytes($length, $strong); + + if (false !== $bytes && true === $strong) { + return $bytes; + } + + throw new RuntimeException('OpenSSL did not produce a secure random number.'); + } + + /** ENCRYPTION ALGORITHMS */ + /** + * DES Encryption + * + * @param string $value + * @param string $key + * @return string + */ + protected function desEncrypt($value, $key) + { + $cipher = mcrypt_module_open(MCRYPT_DES, '', 'ecb', ''); + mcrypt_generic_init($cipher, $key, mcrypt_create_iv(mcrypt_enc_get_iv_size($cipher), MCRYPT_DEV_RANDOM)); + + return mcrypt_generic($cipher, $value); + } + + /** + * MD5 Encryption + * + * @param string $key Encryption key + * @param string $msg Message to encrypt + * @return string + */ + protected function md5Encrypt($key, $msg) + { + $blocksize = 64; + if (strlen($key) > $blocksize) { + $key = pack('H*', md5($key)); + } + + $key = str_pad($key, $blocksize, "\0"); + $ipadk = $key ^ str_repeat("\x36", $blocksize); + $opadk = $key ^ str_repeat("\x5c", $blocksize); + + return pack('H*', md5($opadk . pack('H*', md5($ipadk . $msg)))); + } + + /** + * MD4 Encryption + * + * @param string $input + * @return string + * @see http://php.net/manual/en/ref.hash.php + */ + protected function md4Encrypt($input) + { + $input = $this->convertTo16bit($input); + + return function_exists('hash') ? $this->hex2bin(hash('md4', $input)) : mhash(MHASH_MD4, $input); + } + + /** + * Convert UTF-8 to UTF-16 + * + * @param string $input + * @return string + */ + protected function convertTo16bit($input) + { + return iconv('UTF-8', 'UTF-16LE', $input); + } + + /** + * Hex2bin replacement for < PHP 5.4 + * @param string $hex + * @return string Binary + */ + protected function hex2bin($hex) + { + if (function_exists('hex2bin')) { + return hex2bin($hex); + } else { + return pack('H*', $hex); + } + } + + /** + * @param string $message + */ + protected function debug($message) + { + $message = bin2hex($message); + $messageId = substr($message, 16, 8); + echo substr($message, 0, 16) . " NTLMSSP Signature
    \n"; + echo $messageId . " Type Indicator
    \n"; + + if ($messageId == "02000000") { + $map = array( + 'Challenge', + 'Context', + 'Target Information Security Buffer', + 'Target Name Data', + 'NetBIOS Domain Name', + 'NetBIOS Server Name', + 'DNS Domain Name', + 'DNS Server Name', + 'BLOB', + 'Target Information Terminator', + ); + + $data = $this->parseMessage2($this->hex2bin($message)); + + foreach ($map as $key => $value) { + echo bin2hex($data[$key]) . ' - ' . $data[$key] . ' ||| ' . $value . "
    \n"; + } + } elseif ($messageId == "03000000") { + $i = 0; + $data[$i++] = substr($message, 24, 16); + list($lmLength, $lmOffset) = $this->readSecurityBuffer($data[$i - 1]); + + $data[$i++] = substr($message, 40, 16); + list($ntmlLength, $ntmlOffset) = $this->readSecurityBuffer($data[$i - 1]); + + $data[$i++] = substr($message, 56, 16); + list($targetLength, $targetOffset) = $this->readSecurityBuffer($data[$i - 1]); + + $data[$i++] = substr($message, 72, 16); + list($userLength, $userOffset) = $this->readSecurityBuffer($data[$i - 1]); + + $data[$i++] = substr($message, 88, 16); + list($workLength, $workOffset) = $this->readSecurityBuffer($data[$i - 1]); + + $data[$i++] = substr($message, 104, 16); + $data[$i++] = substr($message, 120, 8); + $data[$i++] = substr($message, $targetOffset, $targetLength); + $data[$i++] = substr($message, $userOffset, $userLength); + $data[$i++] = substr($message, $workOffset, $workLength); + $data[$i++] = substr($message, $lmOffset, $lmLength); + $data[$i] = substr($message, $ntmlOffset, $ntmlLength); + + $map = array( + 'LM Response Security Buffer', + 'NTLM Response Security Buffer', + 'Target Name Security Buffer', + 'User Name Security Buffer', + 'Workstation Name Security Buffer', + 'Session Key Security Buffer', + 'Flags', + 'Target Name Data', + 'User Name Data', + 'Workstation Name Data', + 'LM Response Data', + 'NTLM Response Data', + ); + + foreach ($map as $key => $value) { + echo $data[$key] . ' - ' . $this->hex2bin($data[$key]) . ' ||| ' . $value . "
    \n"; + } + } + + echo "

    "; + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/PlainAuthenticator.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/PlainAuthenticator.php new file mode 100755 index 0000000..6b5a9db --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/PlainAuthenticator.php @@ -0,0 +1,52 @@ +executeCommand(sprintf("AUTH PLAIN %s\r\n", $message), array(235)); + + return true; + } catch (Swift_TransportException $e) { + $agent->executeCommand("RSET\r\n", array(250)); + + return false; + } + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/XOAuth2Authenticator.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/XOAuth2Authenticator.php new file mode 100755 index 0000000..de19fc1 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/Esmtp/Auth/XOAuth2Authenticator.php @@ -0,0 +1,71 @@ + + * $transport = Swift_SmtpTransport::newInstance('smtp.gmail.com', 587, 'tls') + * ->setAuthMode('XOAUTH2') + * ->setUsername('YOUR_EMAIL_ADDRESS') + * ->setPassword('YOUR_ACCESS_TOKEN'); + * + * + * @package Swift + * @subpackage Transport + * @author xu.li + * @see https://developers.google.com/google-apps/gmail/xoauth2_protocol + */ +class Swift_Transport_Esmtp_Auth_XOAuth2Authenticator implements Swift_Transport_Esmtp_Authenticator +{ + /** + * Get the name of the AUTH mechanism this Authenticator handles. + * + * @return string + */ + public function getAuthKeyword() + { + return 'XOAUTH2'; + } + + /** + * Try to authenticate the user with $email and $token. + * + * @param Swift_Transport_SmtpAgent $agent + * @param string $email + * @param string $token + * + * @return bool + */ + public function authenticate(Swift_Transport_SmtpAgent $agent, $email, $token) + { + try { + $param = $this->constructXOAuth2Params($email, $token); + $agent->executeCommand("AUTH XOAUTH2 " . $param . "\r\n", array(235)); + + return true; + } catch (Swift_TransportException $e) { + $agent->executeCommand("RSET\r\n", array(250)); + + return false; + } + } + + /** + * Construct the auth parameter + * + * @see https://developers.google.com/google-apps/gmail/xoauth2_protocol#the_sasl_xoauth2_mechanism + */ + protected function constructXOAuth2Params($email, $token) + { + return base64_encode("user=$email\1auth=Bearer $token\1\1"); + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/Esmtp/AuthHandler.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/Esmtp/AuthHandler.php new file mode 100755 index 0000000..452ab82 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/Esmtp/AuthHandler.php @@ -0,0 +1,268 @@ +setAuthenticators($authenticators); + } + + /** + * Set the Authenticators which can process a login request. + * + * @param Swift_Transport_Esmtp_Authenticator[] $authenticators + */ + public function setAuthenticators(array $authenticators) + { + $this->_authenticators = $authenticators; + } + + /** + * Get the Authenticators which can process a login request. + * + * @return Swift_Transport_Esmtp_Authenticator[] + */ + public function getAuthenticators() + { + return $this->_authenticators; + } + + /** + * Set the username to authenticate with. + * + * @param string $username + */ + public function setUsername($username) + { + $this->_username = $username; + } + + /** + * Get the username to authenticate with. + * + * @return string + */ + public function getUsername() + { + return $this->_username; + } + + /** + * Set the password to authenticate with. + * + * @param string $password + */ + public function setPassword($password) + { + $this->_password = $password; + } + + /** + * Get the password to authenticate with. + * + * @return string + */ + public function getPassword() + { + return $this->_password; + } + + /** + * Set the auth mode to use to authenticate. + * + * @param string $mode + */ + public function setAuthMode($mode) + { + $this->_auth_mode = $mode; + } + + /** + * Get the auth mode to use to authenticate. + * + * @return string + */ + public function getAuthMode() + { + return $this->_auth_mode; + } + + /** + * Get the name of the ESMTP extension this handles. + * + * @return bool + */ + public function getHandledKeyword() + { + return 'AUTH'; + } + + /** + * Set the parameters which the EHLO greeting indicated. + * + * @param string[] $parameters + */ + public function setKeywordParams(array $parameters) + { + $this->_esmtpParams = $parameters; + } + + /** + * Runs immediately after a EHLO has been issued. + * + * @param Swift_Transport_SmtpAgent $agent to read/write + */ + public function afterEhlo(Swift_Transport_SmtpAgent $agent) + { + if ($this->_username) { + $count = 0; + foreach ($this->_getAuthenticatorsForAgent() as $authenticator) { + if (in_array(strtolower($authenticator->getAuthKeyword()), + array_map('strtolower', $this->_esmtpParams))) + { + $count++; + if ($authenticator->authenticate($agent, $this->_username, $this->_password)) { + return; + } + } + } + throw new Swift_TransportException( + 'Failed to authenticate on SMTP server with username "' . + $this->_username . '" using ' . $count . ' possible authenticators' + ); + } + } + + /** + * Not used. + */ + public function getMailParams() + { + return array(); + } + + /** + * Not used. + */ + public function getRcptParams() + { + return array(); + } + + /** + * Not used. + */ + public function onCommand(Swift_Transport_SmtpAgent $agent, $command, $codes = array(), &$failedRecipients = null, &$stop = false) + { + } + + /** + * Returns +1, -1 or 0 according to the rules for usort(). + * + * This method is called to ensure extensions can be execute in an appropriate order. + * + * @param string $esmtpKeyword to compare with + * + * @return int + */ + public function getPriorityOver($esmtpKeyword) + { + return 0; + } + + /** + * Returns an array of method names which are exposed to the Esmtp class. + * + * @return string[] + */ + public function exposeMixinMethods() + { + return array('setUsername', 'getUsername', 'setPassword', 'getPassword', 'setAuthMode', 'getAuthMode'); + } + + /** + * Not used. + */ + public function resetState() + { + } + + // -- Protected methods + + /** + * Returns the authenticator list for the given agent. + * + * @param Swift_Transport_SmtpAgent $agent + * + * @return array + */ + protected function _getAuthenticatorsForAgent() + { + if (!$mode = strtolower($this->_auth_mode)) { + return $this->_authenticators; + } + + foreach ($this->_authenticators as $authenticator) { + if (strtolower($authenticator->getAuthKeyword()) == $mode) { + return array($authenticator); + } + } + + throw new Swift_TransportException('Auth mode '.$mode.' is invalid'); + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/Esmtp/Authenticator.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/Esmtp/Authenticator.php new file mode 100755 index 0000000..c1d4a04 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/Esmtp/Authenticator.php @@ -0,0 +1,37 @@ +. + * + * @return string[] + */ + public function getMailParams(); + + /** + * Get params which are appended to RCPT TO:<>. + * + * @return string[] + */ + public function getRcptParams(); + + /** + * Runs when a command is due to be sent. + * + * @param Swift_Transport_SmtpAgent $agent to read/write + * @param string $command to send + * @param int[] $codes expected in response + * @param string[] $failedRecipients to collect failures + * @param bool $stop to be set true by-reference if the command is now sent + */ + public function onCommand(Swift_Transport_SmtpAgent $agent, $command, $codes = array(), &$failedRecipients = null, &$stop = false); + + /** + * Returns +1, -1 or 0 according to the rules for usort(). + * + * This method is called to ensure extensions can be execute in an appropriate order. + * + * @param string $esmtpKeyword to compare with + * + * @return int + */ + public function getPriorityOver($esmtpKeyword); + + /** + * Returns an array of method names which are exposed to the Esmtp class. + * + * @return string[] + */ + public function exposeMixinMethods(); + + /** + * Tells this handler to clear any buffers and reset its state. + */ + public function resetState(); +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/EsmtpTransport.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/EsmtpTransport.php new file mode 100755 index 0000000..6ad5b09 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/EsmtpTransport.php @@ -0,0 +1,393 @@ + 'tcp', + 'host' => 'localhost', + 'port' => 25, + 'timeout' => 30, + 'blocking' => 1, + 'tls' => false, + 'type' => Swift_Transport_IoBuffer::TYPE_SOCKET + ); + + /** + * Creates a new EsmtpTransport using the given I/O buffer. + * + * @param Swift_Transport_IoBuffer $buf + * @param Swift_Transport_EsmtpHandler[] $extensionHandlers + * @param Swift_Events_EventDispatcher $dispatcher + */ + public function __construct(Swift_Transport_IoBuffer $buf, array $extensionHandlers, Swift_Events_EventDispatcher $dispatcher) + { + parent::__construct($buf, $dispatcher); + $this->setExtensionHandlers($extensionHandlers); + } + + /** + * Set the host to connect to. + * + * @param string $host + * + * @return Swift_Transport_EsmtpTransport + */ + public function setHost($host) + { + $this->_params['host'] = $host; + + return $this; + } + + /** + * Get the host to connect to. + * + * @return string + */ + public function getHost() + { + return $this->_params['host']; + } + + /** + * Set the port to connect to. + * + * @param int $port + * + * @return Swift_Transport_EsmtpTransport + */ + public function setPort($port) + { + $this->_params['port'] = (int) $port; + + return $this; + } + + /** + * Get the port to connect to. + * + * @return int + */ + public function getPort() + { + return $this->_params['port']; + } + + /** + * Set the connection timeout. + * + * @param int $timeout seconds + * + * @return Swift_Transport_EsmtpTransport + */ + public function setTimeout($timeout) + { + $this->_params['timeout'] = (int) $timeout; + $this->_buffer->setParam('timeout', (int) $timeout); + + return $this; + } + + /** + * Get the connection timeout. + * + * @return int + */ + public function getTimeout() + { + return $this->_params['timeout']; + } + + /** + * Set the encryption type (tls or ssl) + * + * @param string $encryption + * + * @return Swift_Transport_EsmtpTransport + */ + public function setEncryption($encryption) + { + if ('tls' == $encryption) { + $this->_params['protocol'] = 'tcp'; + $this->_params['tls'] = true; + } else { + $this->_params['protocol'] = $encryption; + $this->_params['tls'] = false; + } + + return $this; + } + + /** + * Get the encryption type. + * + * @return string + */ + public function getEncryption() + { + return $this->_params['tls'] ? 'tls' : $this->_params['protocol']; + } + + /** + * Sets the source IP. + * + * @param string $source + * + * @return Swift_Transport_EsmtpTransport + */ + public function setSourceIp($source) + { + $this->_params['sourceIp']=$source; + + return $this; + } + + /** + * Returns the IP used to connect to the destination. + * + * @return string + */ + public function getSourceIp() + { + return $this->_params['sourceIp']; + } + + /** + * Set ESMTP extension handlers. + * + * @param Swift_Transport_EsmtpHandler[] $handlers + * + * @return Swift_Transport_EsmtpTransport + */ + public function setExtensionHandlers(array $handlers) + { + $assoc = array(); + foreach ($handlers as $handler) { + $assoc[$handler->getHandledKeyword()] = $handler; + } + uasort($assoc, array($this, '_sortHandlers')); + $this->_handlers = $assoc; + $this->_setHandlerParams(); + + return $this; + } + + /** + * Get ESMTP extension handlers. + * + * @return Swift_Transport_EsmtpHandler[] + */ + public function getExtensionHandlers() + { + return array_values($this->_handlers); + } + + /** + * Run a command against the buffer, expecting the given response codes. + * + * If no response codes are given, the response will not be validated. + * If codes are given, an exception will be thrown on an invalid response. + * + * @param string $command + * @param int[] $codes + * @param string[] $failures An array of failures by-reference + * + * @return string + */ + public function executeCommand($command, $codes = array(), &$failures = null) + { + $failures = (array) $failures; + $stopSignal = false; + $response = null; + foreach ($this->_getActiveHandlers() as $handler) { + $response = $handler->onCommand( + $this, $command, $codes, $failures, $stopSignal + ); + if ($stopSignal) { + return $response; + } + } + + return parent::executeCommand($command, $codes, $failures); + } + + // -- Mixin invocation code + + /** Mixin handling method for ESMTP handlers */ + public function __call($method, $args) + { + foreach ($this->_handlers as $handler) { + if (in_array(strtolower($method), + array_map('strtolower', (array) $handler->exposeMixinMethods()) + )) + { + $return = call_user_func_array(array($handler, $method), $args); + // Allow fluid method calls + if (is_null($return) && substr($method, 0, 3) == 'set') { + return $this; + } else { + return $return; + } + } + } + trigger_error('Call to undefined method ' . $method, E_USER_ERROR); + } + + // -- Protected methods + + /** Get the params to initialize the buffer */ + protected function _getBufferParams() + { + return $this->_params; + } + + /** Overridden to perform EHLO instead */ + protected function _doHeloCommand() + { + try { + $response = $this->executeCommand( + sprintf("EHLO %s\r\n", $this->_domain), array(250) + ); + } catch (Swift_TransportException $e) { + return parent::_doHeloCommand(); + } + + if ($this->_params['tls']) { + try { + $this->executeCommand("STARTTLS\r\n", array(220)); + + if (!$this->_buffer->startTLS()) { + throw new Swift_TransportException('Unable to connect with TLS encryption'); + } + + try { + $response = $this->executeCommand( + sprintf("EHLO %s\r\n", $this->_domain), array(250) + ); + } catch (Swift_TransportException $e) { + return parent::_doHeloCommand(); + } + } catch (Swift_TransportException $e) { + $this->_throwException($e); + } + } + + $this->_capabilities = $this->_getCapabilities($response); + $this->_setHandlerParams(); + foreach ($this->_getActiveHandlers() as $handler) { + $handler->afterEhlo($this); + } + } + + /** Overridden to add Extension support */ + protected function _doMailFromCommand($address) + { + $handlers = $this->_getActiveHandlers(); + $params = array(); + foreach ($handlers as $handler) { + $params = array_merge($params, (array) $handler->getMailParams()); + } + $paramStr = !empty($params) ? ' ' . implode(' ', $params) : ''; + $this->executeCommand( + sprintf("MAIL FROM: <%s>%s\r\n", $address, $paramStr), array(250) + ); + } + + /** Overridden to add Extension support */ + protected function _doRcptToCommand($address) + { + $handlers = $this->_getActiveHandlers(); + $params = array(); + foreach ($handlers as $handler) { + $params = array_merge($params, (array) $handler->getRcptParams()); + } + $paramStr = !empty($params) ? ' ' . implode(' ', $params) : ''; + $this->executeCommand( + sprintf("RCPT TO: <%s>%s\r\n", $address, $paramStr), array(250, 251, 252) + ); + } + + // -- Private methods + + /** Determine ESMTP capabilities by function group */ + private function _getCapabilities($ehloResponse) + { + $capabilities = array(); + $ehloResponse = trim($ehloResponse); + $lines = explode("\r\n", $ehloResponse); + array_shift($lines); + foreach ($lines as $line) { + if (preg_match('/^[0-9]{3}[ -]([A-Z0-9-]+)((?:[ =].*)?)$/Di', $line, $matches)) { + $keyword = strtoupper($matches[1]); + $paramStr = strtoupper(ltrim($matches[2], ' =')); + $params = !empty($paramStr) ? explode(' ', $paramStr) : array(); + $capabilities[$keyword] = $params; + } + } + + return $capabilities; + } + + /** Set parameters which are used by each extension handler */ + private function _setHandlerParams() + { + foreach ($this->_handlers as $keyword => $handler) { + if (array_key_exists($keyword, $this->_capabilities)) { + $handler->setKeywordParams($this->_capabilities[$keyword]); + } + } + } + + /** Get ESMTP handlers which are currently ok to use */ + private function _getActiveHandlers() + { + $handlers = array(); + foreach ($this->_handlers as $keyword => $handler) { + if (array_key_exists($keyword, $this->_capabilities)) { + $handlers[] = $handler; + } + } + + return $handlers; + } + + /** Custom sort for extension handler ordering */ + private function _sortHandlers($a, $b) + { + return $a->getPriorityOver($b->getHandledKeyword()); + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/FailoverTransport.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/FailoverTransport.php new file mode 100755 index 0000000..d0d3f69 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/FailoverTransport.php @@ -0,0 +1,90 @@ +_transports); + $sent = 0; + + for ($i = 0; $i < $maxTransports + && $transport = $this->_getNextTransport(); ++$i) + { + try { + if (!$transport->isStarted()) { + $transport->start(); + } + + return $transport->send($message, $failedRecipients); + } catch (Swift_TransportException $e) { + $this->_killCurrentTransport(); + } + } + + if (count($this->_transports) == 0) { + throw new Swift_TransportException( + 'All Transports in FailoverTransport failed, or no Transports available' + ); + } + + return $sent; + } + + // -- Protected methods + + protected function _getNextTransport() + { + if (!isset($this->_currentTransport)) { + $this->_currentTransport = parent::_getNextTransport(); + } + + return $this->_currentTransport; + } + + protected function _killCurrentTransport() + { + $this->_currentTransport = null; + parent::_killCurrentTransport(); + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/IoBuffer.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/IoBuffer.php new file mode 100755 index 0000000..8358951 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/IoBuffer.php @@ -0,0 +1,69 @@ +_transports = $transports; + $this->_deadTransports = array(); + } + + /** + * Get $transports to delegate to. + * + * @return Swift_Transport[] + */ + public function getTransports() + { + return array_merge($this->_transports, $this->_deadTransports); + } + + /** + * Test if this Transport mechanism has started. + * + * @return bool + */ + public function isStarted() + { + return count($this->_transports) > 0; + } + + /** + * Start this Transport mechanism. + */ + public function start() + { + $this->_transports = array_merge($this->_transports, $this->_deadTransports); + } + + /** + * Stop this Transport mechanism. + */ + public function stop() + { + foreach ($this->_transports as $transport) { + $transport->stop(); + } + } + + /** + * Send the given Message. + * + * Recipient/sender data will be retrieved from the Message API. + * The return value is the number of recipients who were accepted for delivery. + * + * @param Swift_Mime_Message $message + * @param string[] $failedRecipients An array of failures by-reference + * + * @return int + */ + public function send(Swift_Mime_Message $message, &$failedRecipients = null) + { + $maxTransports = count($this->_transports); + $sent = 0; + + for ($i = 0; $i < $maxTransports + && $transport = $this->_getNextTransport(); ++$i) + { + try { + if (!$transport->isStarted()) { + $transport->start(); + } + if ($sent = $transport->send($message, $failedRecipients)) { + break; + } + } catch (Swift_TransportException $e) { + $this->_killCurrentTransport(); + } + } + + if (count($this->_transports) == 0) { + throw new Swift_TransportException( + 'All Transports in LoadBalancedTransport failed, or no Transports available' + ); + } + + return $sent; + } + + /** + * Register a plugin. + * + * @param Swift_Events_EventListener $plugin + */ + public function registerPlugin(Swift_Events_EventListener $plugin) + { + foreach ($this->_transports as $transport) { + $transport->registerPlugin($plugin); + } + } + + // -- Protected methods + + /** + * Rotates the transport list around and returns the first instance. + * + * @return Swift_Transport + */ + protected function _getNextTransport() + { + if ($next = array_shift($this->_transports)) { + $this->_transports[] = $next; + } + + return $next; + } + + /** + * Tag the currently used (top of stack) transport as dead/useless. + */ + protected function _killCurrentTransport() + { + if ($transport = array_pop($this->_transports)) { + try { + $transport->stop(); + } catch (Exception $e) { + } + $this->_deadTransports[] = $transport; + } + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/MailInvoker.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/MailInvoker.php new file mode 100755 index 0000000..9103f79 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/MailInvoker.php @@ -0,0 +1,34 @@ +_invoker = $invoker; + $this->_eventDispatcher = $eventDispatcher; + } + + /** + * Not used. + */ + public function isStarted() + { + return false; + } + + /** + * Not used. + */ + public function start() + { + } + + /** + * Not used. + */ + public function stop() + { + } + + /** + * Set the additional parameters used on the mail() function. + * + * This string is formatted for sprintf() where %s is the sender address. + * + * @param string $params + * + * @return Swift_Transport_MailTransport + */ + public function setExtraParams($params) + { + $this->_extraParams = $params; + + return $this; + } + + /** + * Get the additional parameters used on the mail() function. + * + * This string is formatted for sprintf() where %s is the sender address. + * + * @return string + */ + public function getExtraParams() + { + return $this->_extraParams; + } + + /** + * Send the given Message. + * + * Recipient/sender data will be retrieved from the Message API. + * The return value is the number of recipients who were accepted for delivery. + * + * @param Swift_Mime_Message $message + * @param string[] $failedRecipients An array of failures by-reference + * + * @return int + */ + public function send(Swift_Mime_Message $message, &$failedRecipients = null) + { + $failedRecipients = (array) $failedRecipients; + + if ($evt = $this->_eventDispatcher->createSendEvent($this, $message)) { + $this->_eventDispatcher->dispatchEvent($evt, 'beforeSendPerformed'); + if ($evt->bubbleCancelled()) { + return 0; + } + } + + $count = ( + count((array) $message->getTo()) + + count((array) $message->getCc()) + + count((array) $message->getBcc()) + ); + + $toHeader = $message->getHeaders()->get('To'); + $subjectHeader = $message->getHeaders()->get('Subject'); + + if (!$toHeader) { + throw new Swift_TransportException( + 'Cannot send message without a recipient' + ); + } + $to = $toHeader->getFieldBody(); + $subject = $subjectHeader ? $subjectHeader->getFieldBody() : ''; + + $reversePath = $this->_getReversePath($message); + + // Remove headers that would otherwise be duplicated + $message->getHeaders()->remove('To'); + $message->getHeaders()->remove('Subject'); + + $messageStr = $message->toString(); + + $message->getHeaders()->set($toHeader); + $message->getHeaders()->set($subjectHeader); + + // Separate headers from body + if (false !== $endHeaders = strpos($messageStr, "\r\n\r\n")) { + $headers = substr($messageStr, 0, $endHeaders) . "\r\n"; //Keep last EOL + $body = substr($messageStr, $endHeaders + 4); + } else { + $headers = $messageStr . "\r\n"; + $body = ''; + } + + unset($messageStr); + + if ("\r\n" != PHP_EOL) { + // Non-windows (not using SMTP) + $headers = str_replace("\r\n", PHP_EOL, $headers); + $body = str_replace("\r\n", PHP_EOL, $body); + } else { + // Windows, using SMTP + $headers = str_replace("\r\n.", "\r\n..", $headers); + $body = str_replace("\r\n.", "\r\n..", $body); + } + + if ($this->_invoker->mail($to, $subject, $body, $headers, + sprintf($this->_extraParams, $reversePath))) + { + if ($evt) { + $evt->setResult(Swift_Events_SendEvent::RESULT_SUCCESS); + $evt->setFailedRecipients($failedRecipients); + $this->_eventDispatcher->dispatchEvent($evt, 'sendPerformed'); + } + } else { + $failedRecipients = array_merge( + $failedRecipients, + array_keys((array) $message->getTo()), + array_keys((array) $message->getCc()), + array_keys((array) $message->getBcc()) + ); + + if ($evt) { + $evt->setResult(Swift_Events_SendEvent::RESULT_FAILED); + $evt->setFailedRecipients($failedRecipients); + $this->_eventDispatcher->dispatchEvent($evt, 'sendPerformed'); + } + + $message->generateId(); + + $count = 0; + } + + return $count; + } + + /** + * Register a plugin. + * + * @param Swift_Events_EventListener $plugin + */ + public function registerPlugin(Swift_Events_EventListener $plugin) + { + $this->_eventDispatcher->bindEventListener($plugin); + } + + // -- Private methods + + /** Determine the best-use reverse path for this message */ + private function _getReversePath(Swift_Mime_Message $message) + { + $return = $message->getReturnPath(); + $sender = $message->getSender(); + $from = $message->getFrom(); + $path = null; + if (!empty($return)) { + $path = $return; + } elseif (!empty($sender)) { + $keys = array_keys($sender); + $path = array_shift($keys); + } elseif (!empty($from)) { + $keys = array_keys($from); + $path = array_shift($keys); + } + + return $path; + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/NullTransport.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/NullTransport.php new file mode 100755 index 0000000..fcfd921 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/NullTransport.php @@ -0,0 +1,94 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +/** + * Pretends messages have been sent, but just ignores them. + * + * @package Swift + * @author Fabien Potencier + */ +class Swift_Transport_NullTransport implements Swift_Transport +{ + /** The event dispatcher from the plugin API */ + private $_eventDispatcher; + + /** + * Constructor. + */ + public function __construct(Swift_Events_EventDispatcher $eventDispatcher) + { + $this->_eventDispatcher = $eventDispatcher; + } + + /** + * Tests if this Transport mechanism has started. + * + * @return bool + */ + public function isStarted() + { + return true; + } + + /** + * Starts this Transport mechanism. + */ + public function start() + { + } + + /** + * Stops this Transport mechanism. + */ + public function stop() + { + } + + /** + * Sends the given message. + * + * @param Swift_Mime_Message $message + * @param string[] $failedRecipients An array of failures by-reference + * + * @return int The number of sent emails + */ + public function send(Swift_Mime_Message $message, &$failedRecipients = null) + { + if ($evt = $this->_eventDispatcher->createSendEvent($this, $message)) { + $this->_eventDispatcher->dispatchEvent($evt, 'beforeSendPerformed'); + if ($evt->bubbleCancelled()) { + return 0; + } + } + + if ($evt) { + $evt->setResult(Swift_Events_SendEvent::RESULT_SUCCESS); + $this->_eventDispatcher->dispatchEvent($evt, 'sendPerformed'); + } + + $count = ( + count((array) $message->getTo()) + + count((array) $message->getCc()) + + count((array) $message->getBcc()) + ); + + return $count; + } + + /** + * Register a plugin. + * + * @param Swift_Events_EventListener $plugin + */ + public function registerPlugin(Swift_Events_EventListener $plugin) + { + $this->_eventDispatcher->bindEventListener($plugin); + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/SendmailTransport.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/SendmailTransport.php new file mode 100755 index 0000000..95c2e4a --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/SendmailTransport.php @@ -0,0 +1,163 @@ + 30, + 'blocking' => 1, + 'command' => '/usr/sbin/sendmail -bs', + 'type' => Swift_Transport_IoBuffer::TYPE_PROCESS + ); + + /** + * Create a new SendmailTransport with $buf for I/O. + * + * @param Swift_Transport_IoBuffer $buf + * @param Swift_Events_EventDispatcher $dispatcher + */ + public function __construct(Swift_Transport_IoBuffer $buf, Swift_Events_EventDispatcher $dispatcher) + { + parent::__construct($buf, $dispatcher); + } + + /** + * Start the standalone SMTP session if running in -bs mode. + */ + public function start() + { + if (false !== strpos($this->getCommand(), ' -bs')) { + parent::start(); + } + } + + /** + * Set the command to invoke. + * + * If using -t mode you are strongly advised to include -oi or -i in the flags. + * For example: /usr/sbin/sendmail -oi -t + * Swift will append a -f flag if one is not present. + * + * The recommended mode is "-bs" since it is interactive and failure notifications + * are hence possible. + * + * @param string $command + * + * @return Swift_Transport_SendmailTransport + */ + public function setCommand($command) + { + $this->_params['command'] = $command; + + return $this; + } + + /** + * Get the sendmail command which will be invoked. + * + * @return string + */ + public function getCommand() + { + return $this->_params['command']; + } + + /** + * Send the given Message. + * + * Recipient/sender data will be retrieved from the Message API. + * + * The return value is the number of recipients who were accepted for delivery. + * NOTE: If using 'sendmail -t' you will not be aware of any failures until + * they bounce (i.e. send() will always return 100% success). + * + * @param Swift_Mime_Message $message + * @param string[] $failedRecipients An array of failures by-reference + * + * @return int + */ + public function send(Swift_Mime_Message $message, &$failedRecipients = null) + { + $failedRecipients = (array) $failedRecipients; + $command = $this->getCommand(); + $buffer = $this->getBuffer(); + + if (false !== strpos($command, ' -t')) { + if ($evt = $this->_eventDispatcher->createSendEvent($this, $message)) { + $this->_eventDispatcher->dispatchEvent($evt, 'beforeSendPerformed'); + if ($evt->bubbleCancelled()) { + return 0; + } + } + + if (false === strpos($command, ' -f')) { + $command .= ' -f' . $this->_getReversePath($message); + } + + $buffer->initialize(array_merge($this->_params, array('command' => $command))); + + if (false === strpos($command, ' -i') && false === strpos($command, ' -oi')) { + $buffer->setWriteTranslations(array("\r\n" => "\n", "\n." => "\n..")); + } else { + $buffer->setWriteTranslations(array("\r\n"=>"\n")); + } + + $count = count((array) $message->getTo()) + + count((array) $message->getCc()) + + count((array) $message->getBcc()) + ; + $message->toByteStream($buffer); + $buffer->flushBuffers(); + $buffer->setWriteTranslations(array()); + $buffer->terminate(); + + if ($evt) { + $evt->setResult(Swift_Events_SendEvent::RESULT_SUCCESS); + $evt->setFailedRecipients($failedRecipients); + $this->_eventDispatcher->dispatchEvent($evt, 'sendPerformed'); + } + + $message->generateId(); + } elseif (false !== strpos($command, ' -bs')) { + $count = parent::send($message, $failedRecipients); + } else { + $this->_throwException(new Swift_TransportException( + 'Unsupported sendmail command flags [' . $command . ']. ' . + 'Must be one of "-bs" or "-t" but can include additional flags.' + )); + } + + return $count; + } + + // -- Protected methods + + /** Get the params to initialize the buffer */ + protected function _getBufferParams() + { + return $this->_params; + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/SimpleMailInvoker.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/SimpleMailInvoker.php new file mode 100755 index 0000000..0bf6c16 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/SimpleMailInvoker.php @@ -0,0 +1,41 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +/** + * Stores Messages in a queue. + * + * @package Swift + * @author Fabien Potencier + */ +class Swift_Transport_SpoolTransport implements Swift_Transport +{ + /** The spool instance */ + private $_spool; + + /** The event dispatcher from the plugin API */ + private $_eventDispatcher; + + /** + * Constructor. + */ + public function __construct(Swift_Events_EventDispatcher $eventDispatcher, Swift_Spool $spool = null) + { + $this->_eventDispatcher = $eventDispatcher; + $this->_spool = $spool; + } + + /** + * Sets the spool object. + * + * @param Swift_Spool $spool + * + * @return Swift_Transport_SpoolTransport + */ + public function setSpool(Swift_Spool $spool) + { + $this->_spool = $spool; + + return $this; + } + + /** + * Get the spool object. + * + * @return Swift_Spool + */ + public function getSpool() + { + return $this->_spool; + } + + /** + * Tests if this Transport mechanism has started. + * + * @return bool + */ + public function isStarted() + { + return true; + } + + /** + * Starts this Transport mechanism. + */ + public function start() + { + } + + /** + * Stops this Transport mechanism. + */ + public function stop() + { + } + + /** + * Sends the given message. + * + * @param Swift_Mime_Message $message + * @param string[] $failedRecipients An array of failures by-reference + * + * @return int The number of sent e-mail's + */ + public function send(Swift_Mime_Message $message, &$failedRecipients = null) + { + if ($evt = $this->_eventDispatcher->createSendEvent($this, $message)) { + $this->_eventDispatcher->dispatchEvent($evt, 'beforeSendPerformed'); + if ($evt->bubbleCancelled()) { + return 0; + } + } + + $success = $this->_spool->queueMessage($message); + + if ($evt) { + $evt->setResult($success ? Swift_Events_SendEvent::RESULT_SUCCESS : Swift_Events_SendEvent::RESULT_FAILED); + $this->_eventDispatcher->dispatchEvent($evt, 'sendPerformed'); + } + + return 1; + } + + /** + * Register a plugin. + * + * @param Swift_Events_EventListener $plugin + */ + public function registerPlugin(Swift_Events_EventListener $plugin) + { + $this->_eventDispatcher->bindEventListener($plugin); + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/StreamBuffer.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/StreamBuffer.php new file mode 100755 index 0000000..f11e344 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/StreamBuffer.php @@ -0,0 +1,327 @@ +_replacementFactory = $replacementFactory; + } + + /** + * Perform any initialization needed, using the given $params. + * + * Parameters will vary depending upon the type of IoBuffer used. + * + * @param array $params + */ + public function initialize(array $params) + { + $this->_params = $params; + switch ($params['type']) { + case self::TYPE_PROCESS: + $this->_establishProcessConnection(); + break; + case self::TYPE_SOCKET: + default: + $this->_establishSocketConnection(); + break; + } + } + + /** + * Set an individual param on the buffer (e.g. switching to SSL). + * + * @param string $param + * @param mixed $value + */ + public function setParam($param, $value) + { + if (isset($this->_stream)) { + switch ($param) { + case 'timeout': + if ($this->_stream) { + stream_set_timeout($this->_stream, $value); + } + break; + + case 'blocking': + if ($this->_stream) { + stream_set_blocking($this->_stream, 1); + } + + } + } + $this->_params[$param] = $value; + } + + public function startTLS() + { + return stream_socket_enable_crypto($this->_stream, true, STREAM_CRYPTO_METHOD_TLS_CLIENT); + } + + /** + * Perform any shutdown logic needed. + */ + public function terminate() + { + if (isset($this->_stream)) { + switch ($this->_params['type']) { + case self::TYPE_PROCESS: + fclose($this->_in); + fclose($this->_out); + proc_close($this->_stream); + break; + case self::TYPE_SOCKET: + default: + fclose($this->_stream); + break; + } + } + $this->_stream = null; + $this->_out = null; + $this->_in = null; + } + + /** + * Set an array of string replacements which should be made on data written + * to the buffer. + * + * This could replace LF with CRLF for example. + * + * @param string[] $replacements + */ + public function setWriteTranslations(array $replacements) + { + foreach ($this->_translations as $search => $replace) { + if (!isset($replacements[$search])) { + $this->removeFilter($search); + unset($this->_translations[$search]); + } + } + + foreach ($replacements as $search => $replace) { + if (!isset($this->_translations[$search])) { + $this->addFilter( + $this->_replacementFactory->createFilter($search, $replace), $search + ); + $this->_translations[$search] = true; + } + } + } + + /** + * Get a line of output (including any CRLF). + * + * The $sequence number comes from any writes and may or may not be used + * depending upon the implementation. + * + * @param int $sequence of last write to scan from + * + * @return string + * + * @throws Swift_IoException + */ + public function readLine($sequence) + { + if (isset($this->_out) && !feof($this->_out)) { + $line = fgets($this->_out); + if (strlen($line)==0) { + $metas = stream_get_meta_data($this->_out); + if ($metas['timed_out']) { + throw new Swift_IoException( + 'Connection to ' . + $this->_getReadConnectionDescription() . + ' Timed Out' + ); + } + } + + return $line; + } + } + + /** + * Reads $length bytes from the stream into a string and moves the pointer + * through the stream by $length. + * + * If less bytes exist than are requested the remaining bytes are given instead. + * If no bytes are remaining at all, boolean false is returned. + * + * @param int $length + * + * @return string|bool + * + * @throws Swift_IoException + */ + public function read($length) + { + if (isset($this->_out) && !feof($this->_out)) { + $ret = fread($this->_out, $length); + if (strlen($ret)==0) { + $metas = stream_get_meta_data($this->_out); + if ($metas['timed_out']) { + throw new Swift_IoException( + 'Connection to ' . + $this->_getReadConnectionDescription() . + ' Timed Out' + ); + } + } + + return $ret; + } + } + + /** Not implemented */ + public function setReadPointer($byteOffset) + { + } + + // -- Protected methods + + /** Flush the stream contents */ + protected function _flush() + { + if (isset($this->_in)) { + fflush($this->_in); + } + } + + /** Write this bytes to the stream */ + protected function _commit($bytes) + { + if (isset($this->_in)) { + $bytesToWrite = strlen($bytes); + $totalBytesWritten = 0; + + while ($totalBytesWritten < $bytesToWrite) { + $bytesWritten = fwrite($this->_in, substr($bytes, $totalBytesWritten)); + if (false === $bytesWritten || 0 === $bytesWritten) { + break; + } + + $totalBytesWritten += $bytesWritten; + } + + if ($totalBytesWritten > 0) { + return ++$this->_sequence; + } + } + } + + // -- Private methods + + /** + * Establishes a connection to a remote server. + */ + private function _establishSocketConnection() + { + $host = $this->_params['host']; + if (!empty($this->_params['protocol'])) { + $host = $this->_params['protocol'] . '://' . $host; + } + $timeout = 15; + if (!empty($this->_params['timeout'])) { + $timeout = $this->_params['timeout']; + } + $options = array(); + if (!empty($this->_params['sourceIp'])) { + $options['socket']['bindto']=$this->_params['sourceIp'].':0'; + } + $this->_stream = @stream_socket_client($host.':'.$this->_params['port'], $errno, $errstr, $timeout, STREAM_CLIENT_CONNECT, stream_context_create($options)); + if (false === $this->_stream) { + throw new Swift_TransportException( + 'Connection could not be established with host ' . $this->_params['host'] . + ' [' . $errstr . ' #' . $errno . ']' + ); + } + if (!empty($this->_params['blocking'])) { + stream_set_blocking($this->_stream, 1); + } else { + stream_set_blocking($this->_stream, 0); + } + stream_set_timeout($this->_stream, $timeout); + $this->_in =& $this->_stream; + $this->_out =& $this->_stream; + } + + /** + * Opens a process for input/output. + */ + private function _establishProcessConnection() + { + $command = $this->_params['command']; + $descriptorSpec = array( + 0 => array('pipe', 'r'), + 1 => array('pipe', 'w'), + 2 => array('pipe', 'w') + ); + $this->_stream = proc_open($command, $descriptorSpec, $pipes); + stream_set_blocking($pipes[2], 0); + if ($err = stream_get_contents($pipes[2])) { + throw new Swift_TransportException( + 'Process could not be started [' . $err . ']' + ); + } + $this->_in =& $pipes[0]; + $this->_out =& $pipes[1]; + } + + private function _getReadConnectionDescription() + { + switch ($this->_params['type']) { + case self::TYPE_PROCESS: + return 'Process '.$this->_params['command']; + break; + + case self::TYPE_SOCKET: + default: + $host = $this->_params['host']; + if (!empty($this->_params['protocol'])) { + $host = $this->_params['protocol'] . '://' . $host; + } + $host.=':'.$this->_params['port']; + + return $host; + break; + } + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/classes/Swift/TransportException.php b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/TransportException.php new file mode 100755 index 0000000..48e41d1 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/classes/Swift/TransportException.php @@ -0,0 +1,29 @@ + + */ +class Swift_Validate +{ + /** + * Grammar Object + * + * @var Swift_Mime_Grammar + */ + private static $grammar = null; + + /** + * Checks if an e-mail address matches the current grammars. + * + * @param string $email + * + * @return bool + */ + public static function email($email) + { + if (self::$grammar===null) { + self::$grammar = Swift_DependencyContainer::getInstance() + ->lookup('mime.grammar'); + } + + return (bool) preg_match( + '/^' . self::$grammar->getDefinition('addr-spec') . '$/D', + $email + ); + } +} diff --git a/vendor/swiftmailer/swiftmailer/lib/dependency_maps/cache_deps.php b/vendor/swiftmailer/swiftmailer/lib/dependency_maps/cache_deps.php new file mode 100755 index 0000000..6023448 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/dependency_maps/cache_deps.php @@ -0,0 +1,23 @@ +register('cache') + ->asAliasOf('cache.array') + + ->register('tempdir') + ->asValue('/tmp') + + ->register('cache.null') + ->asSharedInstanceOf('Swift_KeyCache_NullKeyCache') + + ->register('cache.array') + ->asSharedInstanceOf('Swift_KeyCache_ArrayKeyCache') + ->withDependencies(array('cache.inputstream')) + + ->register('cache.disk') + ->asSharedInstanceOf('Swift_KeyCache_DiskKeyCache') + ->withDependencies(array('cache.inputstream', 'tempdir')) + + ->register('cache.inputstream') + ->asNewInstanceOf('Swift_KeyCache_SimpleKeyCacheInputStream') +; diff --git a/vendor/swiftmailer/swiftmailer/lib/dependency_maps/message_deps.php b/vendor/swiftmailer/swiftmailer/lib/dependency_maps/message_deps.php new file mode 100755 index 0000000..64d69d2 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/dependency_maps/message_deps.php @@ -0,0 +1,9 @@ +register('message.message') + ->asNewInstanceOf('Swift_Message') + + ->register('message.mimepart') + ->asNewInstanceOf('Swift_MimePart') +; diff --git a/vendor/swiftmailer/swiftmailer/lib/dependency_maps/mime_deps.php b/vendor/swiftmailer/swiftmailer/lib/dependency_maps/mime_deps.php new file mode 100755 index 0000000..a13472e --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/dependency_maps/mime_deps.php @@ -0,0 +1,123 @@ +register('properties.charset') + ->asValue('utf-8') + + ->register('mime.grammar') + ->asSharedInstanceOf('Swift_Mime_Grammar') + + ->register('mime.message') + ->asNewInstanceOf('Swift_Mime_SimpleMessage') + ->withDependencies(array( + 'mime.headerset', + 'mime.qpcontentencoder', + 'cache', + 'mime.grammar', + 'properties.charset' + )) + + ->register('mime.part') + ->asNewInstanceOf('Swift_Mime_MimePart') + ->withDependencies(array( + 'mime.headerset', + 'mime.qpcontentencoder', + 'cache', + 'mime.grammar', + 'properties.charset' + )) + + ->register('mime.attachment') + ->asNewInstanceOf('Swift_Mime_Attachment') + ->withDependencies(array( + 'mime.headerset', + 'mime.base64contentencoder', + 'cache', + 'mime.grammar' + )) + ->addConstructorValue($swift_mime_types) + + ->register('mime.embeddedfile') + ->asNewInstanceOf('Swift_Mime_EmbeddedFile') + ->withDependencies(array( + 'mime.headerset', + 'mime.base64contentencoder', + 'cache', + 'mime.grammar' + )) + ->addConstructorValue($swift_mime_types) + + ->register('mime.headerfactory') + ->asNewInstanceOf('Swift_Mime_SimpleHeaderFactory') + ->withDependencies(array( + 'mime.qpheaderencoder', + 'mime.rfc2231encoder', + 'mime.grammar', + 'properties.charset' + )) + + ->register('mime.headerset') + ->asNewInstanceOf('Swift_Mime_SimpleHeaderSet') + ->withDependencies(array('mime.headerfactory', 'properties.charset')) + + ->register('mime.qpheaderencoder') + ->asNewInstanceOf('Swift_Mime_HeaderEncoder_QpHeaderEncoder') + ->withDependencies(array('mime.charstream')) + + ->register('mime.base64headerencoder') + ->asNewInstanceOf('Swift_Mime_HeaderEncoder_Base64HeaderEncoder') + ->withDependencies(array('mime.charstream')) + + ->register('mime.charstream') + ->asNewInstanceOf('Swift_CharacterStream_NgCharacterStream') + ->withDependencies(array('mime.characterreaderfactory', 'properties.charset')) + + ->register('mime.bytecanonicalizer') + ->asSharedInstanceOf('Swift_StreamFilters_ByteArrayReplacementFilter') + ->addConstructorValue(array(array(0x0D, 0x0A), array(0x0D), array(0x0A))) + ->addConstructorValue(array(array(0x0A), array(0x0A), array(0x0D, 0x0A))) + + ->register('mime.characterreaderfactory') + ->asSharedInstanceOf('Swift_CharacterReaderFactory_SimpleCharacterReaderFactory') + + ->register('mime.safeqpcontentencoder') + ->asNewInstanceOf('Swift_Mime_ContentEncoder_QpContentEncoder') + ->withDependencies(array('mime.charstream', 'mime.bytecanonicalizer')) + + ->register('mime.rawcontentencoder') + ->asNewInstanceOf('Swift_Mime_ContentEncoder_RawContentEncoder') + + ->register('mime.nativeqpcontentencoder') + ->withDependencies(array('properties.charset')) + ->asNewInstanceOf('Swift_Mime_ContentEncoder_NativeQpContentEncoder') + + ->register('mime.qpcontentencoderproxy') + ->asNewInstanceOf('Swift_Mime_ContentEncoder_QpContentEncoderProxy') + ->withDependencies(array('mime.safeqpcontentencoder', 'mime.nativeqpcontentencoder', 'properties.charset')) + + ->register('mime.7bitcontentencoder') + ->asNewInstanceOf('Swift_Mime_ContentEncoder_PlainContentEncoder') + ->addConstructorValue('7bit') + ->addConstructorValue(true) + + ->register('mime.8bitcontentencoder') + ->asNewInstanceOf('Swift_Mime_ContentEncoder_PlainContentEncoder') + ->addConstructorValue('8bit') + ->addConstructorValue(true) + + ->register('mime.base64contentencoder') + ->asSharedInstanceOf('Swift_Mime_ContentEncoder_Base64ContentEncoder') + + ->register('mime.rfc2231encoder') + ->asNewInstanceOf('Swift_Encoder_Rfc2231Encoder') + ->withDependencies(array('mime.charstream')) + + // As of PHP 5.4.7, the quoted_printable_encode() function behaves correctly. + // see https://github.com/php/php-src/commit/18bb426587d62f93c54c40bf8535eb8416603629 + ->register('mime.qpcontentencoder') + ->asAliasOf(version_compare(phpversion(), '5.4.7', '>=') ? 'mime.qpcontentencoderproxy' : 'mime.safeqpcontentencoder') +; + +unset($swift_mime_types); diff --git a/vendor/swiftmailer/swiftmailer/lib/dependency_maps/transport_deps.php b/vendor/swiftmailer/swiftmailer/lib/dependency_maps/transport_deps.php new file mode 100755 index 0000000..56ca059 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/dependency_maps/transport_deps.php @@ -0,0 +1,76 @@ +register('transport.smtp') + ->asNewInstanceOf('Swift_Transport_EsmtpTransport') + ->withDependencies(array( + 'transport.buffer', + array('transport.authhandler'), + 'transport.eventdispatcher' + )) + + ->register('transport.sendmail') + ->asNewInstanceOf('Swift_Transport_SendmailTransport') + ->withDependencies(array( + 'transport.buffer', + 'transport.eventdispatcher' + )) + + ->register('transport.mail') + ->asNewInstanceOf('Swift_Transport_MailTransport') + ->withDependencies(array('transport.mailinvoker', 'transport.eventdispatcher')) + + ->register('transport.loadbalanced') + ->asNewInstanceOf('Swift_Transport_LoadBalancedTransport') + + ->register('transport.failover') + ->asNewInstanceOf('Swift_Transport_FailoverTransport') + + ->register('transport.spool') + ->asNewInstanceOf('Swift_Transport_SpoolTransport') + ->withDependencies(array('transport.eventdispatcher')) + + ->register('transport.null') + ->asNewInstanceOf('Swift_Transport_NullTransport') + ->withDependencies(array('transport.eventdispatcher')) + + ->register('transport.mailinvoker') + ->asSharedInstanceOf('Swift_Transport_SimpleMailInvoker') + + ->register('transport.buffer') + ->asNewInstanceOf('Swift_Transport_StreamBuffer') + ->withDependencies(array('transport.replacementfactory')) + + ->register('transport.authhandler') + ->asNewInstanceOf('Swift_Transport_Esmtp_AuthHandler') + ->withDependencies(array( + array( + 'transport.crammd5auth', + 'transport.loginauth', + 'transport.plainauth', + 'transport.ntlmauth', + 'transport.xoauth2auth', + ) + )) + + ->register('transport.crammd5auth') + ->asNewInstanceOf('Swift_Transport_Esmtp_Auth_CramMd5Authenticator') + + ->register('transport.loginauth') + ->asNewInstanceOf('Swift_Transport_Esmtp_Auth_LoginAuthenticator') + + ->register('transport.plainauth') + ->asNewInstanceOf('Swift_Transport_Esmtp_Auth_PlainAuthenticator') + + ->register('transport.xoauth2auth') + ->asNewInstanceOf('Swift_Transport_Esmtp_Auth_XOAuth2Authenticator') + + ->register('transport.ntlmauth') + ->asNewInstanceOf('Swift_Transport_Esmtp_Auth_NTLMAuthenticator') + + ->register('transport.eventdispatcher') + ->asNewInstanceOf('Swift_Events_SimpleEventDispatcher') + + ->register('transport.replacementfactory') + ->asSharedInstanceOf('Swift_StreamFilters_StringReplacementFilterFactory') +; diff --git a/vendor/swiftmailer/swiftmailer/lib/mime_types.php b/vendor/swiftmailer/swiftmailer/lib/mime_types.php new file mode 100755 index 0000000..f31567d --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/mime_types.php @@ -0,0 +1,1007 @@ + 'text/vnd.in3d.3dml', + '3ds' => 'image/x-3ds', + '3g2' => 'video/3gpp2', + '3gp' => 'video/3gpp', + '7z' => 'application/x-7z-compressed', + 'aab' => 'application/x-authorware-bin', + 'aac' => 'audio/x-aac', + 'aam' => 'application/x-authorware-map', + 'aas' => 'application/x-authorware-seg', + 'abw' => 'application/x-abiword', + 'ac' => 'application/pkix-attr-cert', + 'acc' => 'application/vnd.americandynamics.acc', + 'ace' => 'application/x-ace-compressed', + 'acu' => 'application/vnd.acucobol', + 'acutc' => 'application/vnd.acucorp', + 'adp' => 'audio/adpcm', + 'aep' => 'application/vnd.audiograph', + 'afm' => 'application/x-font-type1', + 'afp' => 'application/vnd.ibm.modcap', + 'ahead' => 'application/vnd.ahead.space', + 'ai' => 'application/postscript', + 'aif' => 'audio/x-aiff', + 'aifc' => 'audio/x-aiff', + 'aiff' => 'audio/x-aiff', + 'air' => 'application/vnd.adobe.air-application-installer-package+zip', + 'ait' => 'application/vnd.dvb.ait', + 'ami' => 'application/vnd.amiga.ami', + 'apk' => 'application/vnd.android.package-archive', + 'appcache' => 'text/cache-manifest', + 'apr' => 'application/vnd.lotus-approach', + 'aps' => 'application/postscript', + 'arc' => 'application/x-freearc', + 'asc' => 'application/pgp-signature', + 'asf' => 'video/x-ms-asf', + 'asm' => 'text/x-asm', + 'aso' => 'application/vnd.accpac.simply.aso', + 'asx' => 'video/x-ms-asf', + 'atc' => 'application/vnd.acucorp', + 'atom' => 'application/atom+xml', + 'atomcat' => 'application/atomcat+xml', + 'atomsvc' => 'application/atomsvc+xml', + 'atx' => 'application/vnd.antix.game-component', + 'au' => 'audio/basic', + 'avi' => 'video/x-msvideo', + 'aw' => 'application/applixware', + 'azf' => 'application/vnd.airzip.filesecure.azf', + 'azs' => 'application/vnd.airzip.filesecure.azs', + 'azw' => 'application/vnd.amazon.ebook', + 'bat' => 'application/x-msdownload', + 'bcpio' => 'application/x-bcpio', + 'bdf' => 'application/x-font-bdf', + 'bdm' => 'application/vnd.syncml.dm+wbxml', + 'bed' => 'application/vnd.realvnc.bed', + 'bh2' => 'application/vnd.fujitsu.oasysprs', + 'bin' => 'application/octet-stream', + 'blb' => 'application/x-blorb', + 'blorb' => 'application/x-blorb', + 'bmi' => 'application/vnd.bmi', + 'bmp' => 'image/bmp', + 'book' => 'application/vnd.framemaker', + 'box' => 'application/vnd.previewsystems.box', + 'boz' => 'application/x-bzip2', + 'bpk' => 'application/octet-stream', + 'btif' => 'image/prs.btif', + 'bz' => 'application/x-bzip', + 'bz2' => 'application/x-bzip2', + 'c' => 'text/x-c', + 'c11amc' => 'application/vnd.cluetrust.cartomobile-config', + 'c11amz' => 'application/vnd.cluetrust.cartomobile-config-pkg', + 'c4d' => 'application/vnd.clonk.c4group', + 'c4f' => 'application/vnd.clonk.c4group', + 'c4g' => 'application/vnd.clonk.c4group', + 'c4p' => 'application/vnd.clonk.c4group', + 'c4u' => 'application/vnd.clonk.c4group', + 'cab' => 'application/vnd.ms-cab-compressed', + 'caf' => 'audio/x-caf', + 'cap' => 'application/vnd.tcpdump.pcap', + 'car' => 'application/vnd.curl.car', + 'cat' => 'application/vnd.ms-pki.seccat', + 'cb7' => 'application/x-cbr', + 'cba' => 'application/x-cbr', + 'cbr' => 'application/x-cbr', + 'cbt' => 'application/x-cbr', + 'cbz' => 'application/x-cbr', + 'cc' => 'text/x-c', + 'cct' => 'application/x-director', + 'ccxml' => 'application/ccxml+xml', + 'cdbcmsg' => 'application/vnd.contact.cmsg', + 'cdf' => 'application/x-netcdf', + 'cdkey' => 'application/vnd.mediastation.cdkey', + 'cdmia' => 'application/cdmi-capability', + 'cdmic' => 'application/cdmi-container', + 'cdmid' => 'application/cdmi-domain', + 'cdmio' => 'application/cdmi-object', + 'cdmiq' => 'application/cdmi-queue', + 'cdx' => 'chemical/x-cdx', + 'cdxml' => 'application/vnd.chemdraw+xml', + 'cdy' => 'application/vnd.cinderella', + 'cer' => 'application/pkix-cert', + 'cfs' => 'application/x-cfs-compressed', + 'cgm' => 'image/cgm', + 'chat' => 'application/x-chat', + 'chm' => 'application/vnd.ms-htmlhelp', + 'chrt' => 'application/vnd.kde.kchart', + 'cif' => 'chemical/x-cif', + 'cii' => 'application/vnd.anser-web-certificate-issue-initiation', + 'cil' => 'application/vnd.ms-artgalry', + 'cla' => 'application/vnd.claymore', + 'class' => 'application/java-vm', + 'clkk' => 'application/vnd.crick.clicker.keyboard', + 'clkp' => 'application/vnd.crick.clicker.palette', + 'clkt' => 'application/vnd.crick.clicker.template', + 'clkw' => 'application/vnd.crick.clicker.wordbank', + 'clkx' => 'application/vnd.crick.clicker', + 'clp' => 'application/x-msclip', + 'cmc' => 'application/vnd.cosmocaller', + 'cmdf' => 'chemical/x-cmdf', + 'cml' => 'chemical/x-cml', + 'cmp' => 'application/vnd.yellowriver-custom-menu', + 'cmx' => 'image/x-cmx', + 'cod' => 'application/vnd.rim.cod', + 'com' => 'application/x-msdownload', + 'conf' => 'text/plain', + 'cpio' => 'application/x-cpio', + 'cpp' => 'text/x-c', + 'cpt' => 'application/mac-compactpro', + 'crd' => 'application/x-mscardfile', + 'crl' => 'application/pkix-crl', + 'crt' => 'application/x-x509-ca-cert', + 'csh' => 'application/x-csh', + 'csml' => 'chemical/x-csml', + 'csp' => 'application/vnd.commonspace', + 'css' => 'text/css', + 'cst' => 'application/x-director', + 'csv' => 'text/csv', + 'cu' => 'application/cu-seeme', + 'curl' => 'text/vnd.curl', + 'cww' => 'application/prs.cww', + 'cxt' => 'application/x-director', + 'cxx' => 'text/x-c', + 'dae' => 'model/vnd.collada+xml', + 'daf' => 'application/vnd.mobius.daf', + 'dart' => 'application/vnd.dart', + 'dataless' => 'application/vnd.fdsn.seed', + 'davmount' => 'application/davmount+xml', + 'dbk' => 'application/docbook+xml', + 'dcr' => 'application/x-director', + 'dcurl' => 'text/vnd.curl.dcurl', + 'dd2' => 'application/vnd.oma.dd2+xml', + 'ddd' => 'application/vnd.fujixerox.ddd', + 'deb' => 'application/x-debian-package', + 'def' => 'text/plain', + 'deploy' => 'application/octet-stream', + 'der' => 'application/x-x509-ca-cert', + 'dfac' => 'application/vnd.dreamfactory', + 'dgc' => 'application/x-dgc-compressed', + 'dic' => 'text/x-c', + 'dir' => 'application/x-director', + 'dis' => 'application/vnd.mobius.dis', + 'dist' => 'application/octet-stream', + 'distz' => 'application/octet-stream', + 'djv' => 'image/vnd.djvu', + 'djvu' => 'image/vnd.djvu', + 'dll' => 'application/x-msdownload', + 'dmg' => 'application/x-apple-diskimage', + 'dmp' => 'application/vnd.tcpdump.pcap', + 'dms' => 'application/octet-stream', + 'dna' => 'application/vnd.dna', + 'doc' => 'application/msword', + 'docm' => 'application/vnd.ms-word.document.macroenabled.12', + 'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', + 'dot' => 'application/msword', + 'dotm' => 'application/vnd.ms-word.template.macroenabled.12', + 'dotx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.template', + 'dp' => 'application/vnd.osgi.dp', + 'dpg' => 'application/vnd.dpgraph', + 'dra' => 'audio/vnd.dra', + 'dsc' => 'text/prs.lines.tag', + 'dssc' => 'application/dssc+der', + 'dtb' => 'application/x-dtbook+xml', + 'dtd' => 'application/xml-dtd', + 'dts' => 'audio/vnd.dts', + 'dtshd' => 'audio/vnd.dts.hd', + 'dump' => 'application/octet-stream', + 'dvb' => 'video/vnd.dvb.file', + 'dvi' => 'application/x-dvi', + 'dwf' => 'model/vnd.dwf', + 'dwg' => 'image/vnd.dwg', + 'dxf' => 'image/vnd.dxf', + 'dxp' => 'application/vnd.spotfire.dxp', + 'dxr' => 'application/x-director', + 'ecelp4800' => 'audio/vnd.nuera.ecelp4800', + 'ecelp7470' => 'audio/vnd.nuera.ecelp7470', + 'ecelp9600' => 'audio/vnd.nuera.ecelp9600', + 'ecma' => 'application/ecmascript', + 'edm' => 'application/vnd.novadigm.edm', + 'edx' => 'application/vnd.novadigm.edx', + 'efif' => 'application/vnd.picsel', + 'ei6' => 'application/vnd.pg.osasli', + 'elc' => 'application/octet-stream', + 'emf' => 'application/x-msmetafile', + 'eml' => 'message/rfc822', + 'emma' => 'application/emma+xml', + 'emz' => 'application/x-msmetafile', + 'eol' => 'audio/vnd.digital-winds', + 'eot' => 'application/vnd.ms-fontobject', + 'eps' => 'application/postscript', + 'epub' => 'application/epub+zip', + 'es3' => 'application/vnd.eszigno3+xml', + 'esa' => 'application/vnd.osgi.subsystem', + 'esf' => 'application/vnd.epson.esf', + 'et3' => 'application/vnd.eszigno3+xml', + 'etx' => 'text/x-setext', + 'eva' => 'application/x-eva', + 'evy' => 'application/x-envoy', + 'exe' => 'application/x-msdownload', + 'exi' => 'application/exi', + 'ext' => 'application/vnd.novadigm.ext', + 'ez' => 'application/andrew-inset', + 'ez2' => 'application/vnd.ezpix-album', + 'ez3' => 'application/vnd.ezpix-package', + 'f' => 'text/x-fortran', + 'f4v' => 'video/x-f4v', + 'f77' => 'text/x-fortran', + 'f90' => 'text/x-fortran', + 'fbs' => 'image/vnd.fastbidsheet', + 'fcdt' => 'application/vnd.adobe.formscentral.fcdt', + 'fcs' => 'application/vnd.isac.fcs', + 'fdf' => 'application/vnd.fdf', + 'fe_launch' => 'application/vnd.denovo.fcselayout-link', + 'fg5' => 'application/vnd.fujitsu.oasysgp', + 'fgd' => 'application/x-director', + 'fh' => 'image/x-freehand', + 'fh4' => 'image/x-freehand', + 'fh5' => 'image/x-freehand', + 'fh7' => 'image/x-freehand', + 'fhc' => 'image/x-freehand', + 'fig' => 'application/x-xfig', + 'flac' => 'audio/x-flac', + 'fli' => 'video/x-fli', + 'flo' => 'application/vnd.micrografx.flo', + 'flv' => 'video/x-flv', + 'flw' => 'application/vnd.kde.kivio', + 'flx' => 'text/vnd.fmi.flexstor', + 'fly' => 'text/vnd.fly', + 'fm' => 'application/vnd.framemaker', + 'fnc' => 'application/vnd.frogans.fnc', + 'for' => 'text/x-fortran', + 'fpx' => 'image/vnd.fpx', + 'frame' => 'application/vnd.framemaker', + 'fsc' => 'application/vnd.fsc.weblaunch', + 'fst' => 'image/vnd.fst', + 'ftc' => 'application/vnd.fluxtime.clip', + 'fti' => 'application/vnd.anser-web-funds-transfer-initiation', + 'fvt' => 'video/vnd.fvt', + 'fxp' => 'application/vnd.adobe.fxp', + 'fxpl' => 'application/vnd.adobe.fxp', + 'fzs' => 'application/vnd.fuzzysheet', + 'g2w' => 'application/vnd.geoplan', + 'g3' => 'image/g3fax', + 'g3w' => 'application/vnd.geospace', + 'gac' => 'application/vnd.groove-account', + 'gam' => 'application/x-tads', + 'gbr' => 'application/rpki-ghostbusters', + 'gca' => 'application/x-gca-compressed', + 'gdl' => 'model/vnd.gdl', + 'geo' => 'application/vnd.dynageo', + 'gex' => 'application/vnd.geometry-explorer', + 'ggb' => 'application/vnd.geogebra.file', + 'ggt' => 'application/vnd.geogebra.tool', + 'ghf' => 'application/vnd.groove-help', + 'gif' => 'image/gif', + 'gim' => 'application/vnd.groove-identity-message', + 'gml' => 'application/gml+xml', + 'gmx' => 'application/vnd.gmx', + 'gnumeric' => 'application/x-gnumeric', + 'gph' => 'application/vnd.flographit', + 'gpx' => 'application/gpx+xml', + 'gqf' => 'application/vnd.grafeq', + 'gqs' => 'application/vnd.grafeq', + 'gram' => 'application/srgs', + 'gramps' => 'application/x-gramps-xml', + 'gre' => 'application/vnd.geometry-explorer', + 'grv' => 'application/vnd.groove-injector', + 'grxml' => 'application/srgs+xml', + 'gsf' => 'application/x-font-ghostscript', + 'gtar' => 'application/x-gtar', + 'gtm' => 'application/vnd.groove-tool-message', + 'gtw' => 'model/vnd.gtw', + 'gv' => 'text/vnd.graphviz', + 'gxf' => 'application/gxf', + 'gxt' => 'application/vnd.geonext', + 'gz' => 'application/x-gzip', + 'h' => 'text/x-c', + 'h261' => 'video/h261', + 'h263' => 'video/h263', + 'h264' => 'video/h264', + 'hal' => 'application/vnd.hal+xml', + 'hbci' => 'application/vnd.hbci', + 'hdf' => 'application/x-hdf', + 'hh' => 'text/x-c', + 'hlp' => 'application/winhlp', + 'hpgl' => 'application/vnd.hp-hpgl', + 'hpid' => 'application/vnd.hp-hpid', + 'hps' => 'application/vnd.hp-hps', + 'hqx' => 'application/mac-binhex40', + 'htke' => 'application/vnd.kenameaapp', + 'htm' => 'text/html', + 'html' => 'text/html', + 'hvd' => 'application/vnd.yamaha.hv-dic', + 'hvp' => 'application/vnd.yamaha.hv-voice', + 'hvs' => 'application/vnd.yamaha.hv-script', + 'i2g' => 'application/vnd.intergeo', + 'icc' => 'application/vnd.iccprofile', + 'ice' => 'x-conference/x-cooltalk', + 'icm' => 'application/vnd.iccprofile', + 'ico' => 'image/x-icon', + 'ics' => 'text/calendar', + 'ief' => 'image/ief', + 'ifb' => 'text/calendar', + 'ifm' => 'application/vnd.shana.informed.formdata', + 'iges' => 'model/iges', + 'igl' => 'application/vnd.igloader', + 'igm' => 'application/vnd.insors.igm', + 'igs' => 'model/iges', + 'igx' => 'application/vnd.micrografx.igx', + 'iif' => 'application/vnd.shana.informed.interchange', + 'imp' => 'application/vnd.accpac.simply.imp', + 'ims' => 'application/vnd.ms-ims', + 'in' => 'text/plain', + 'ink' => 'application/inkml+xml', + 'inkml' => 'application/inkml+xml', + 'install' => 'application/x-install-instructions', + 'iota' => 'application/vnd.astraea-software.iota', + 'ipfix' => 'application/ipfix', + 'ipk' => 'application/vnd.shana.informed.package', + 'irm' => 'application/vnd.ibm.rights-management', + 'irp' => 'application/vnd.irepository.package+xml', + 'iso' => 'application/x-iso9660-image', + 'itp' => 'application/vnd.shana.informed.formtemplate', + 'ivp' => 'application/vnd.immervision-ivp', + 'ivu' => 'application/vnd.immervision-ivu', + 'jad' => 'text/vnd.sun.j2me.app-descriptor', + 'jam' => 'application/vnd.jam', + 'jar' => 'application/java-archive', + 'java' => 'text/x-java-source', + 'jisp' => 'application/vnd.jisp', + 'jlt' => 'application/vnd.hp-jlyt', + 'jnlp' => 'application/x-java-jnlp-file', + 'joda' => 'application/vnd.joost.joda-archive', + 'jpe' => 'image/jpeg', + 'jpeg' => 'image/jpeg', + 'jpg' => 'image/jpeg', + 'jpgm' => 'video/jpm', + 'jpgv' => 'video/jpeg', + 'jpm' => 'video/jpm', + 'js' => 'application/javascript', + 'json' => 'application/json', + 'jsonml' => 'application/jsonml+json', + 'kar' => 'audio/midi', + 'karbon' => 'application/vnd.kde.karbon', + 'kfo' => 'application/vnd.kde.kformula', + 'kia' => 'application/vnd.kidspiration', + 'kml' => 'application/vnd.google-earth.kml+xml', + 'kmz' => 'application/vnd.google-earth.kmz', + 'kne' => 'application/vnd.kinar', + 'knp' => 'application/vnd.kinar', + 'kon' => 'application/vnd.kde.kontour', + 'kpr' => 'application/vnd.kde.kpresenter', + 'kpt' => 'application/vnd.kde.kpresenter', + 'kpxx' => 'application/vnd.ds-keypoint', + 'ksp' => 'application/vnd.kde.kspread', + 'ktr' => 'application/vnd.kahootz', + 'ktx' => 'image/ktx', + 'ktz' => 'application/vnd.kahootz', + 'kwd' => 'application/vnd.kde.kword', + 'kwt' => 'application/vnd.kde.kword', + 'lasxml' => 'application/vnd.las.las+xml', + 'latex' => 'application/x-latex', + 'lbd' => 'application/vnd.llamagraphics.life-balance.desktop', + 'lbe' => 'application/vnd.llamagraphics.life-balance.exchange+xml', + 'les' => 'application/vnd.hhe.lesson-player', + 'lha' => 'application/x-lzh-compressed', + 'link66' => 'application/vnd.route66.link66+xml', + 'list' => 'text/plain', + 'list3820' => 'application/vnd.ibm.modcap', + 'listafp' => 'application/vnd.ibm.modcap', + 'lnk' => 'application/x-ms-shortcut', + 'log' => 'text/plain', + 'lostxml' => 'application/lost+xml', + 'lrf' => 'application/octet-stream', + 'lrm' => 'application/vnd.ms-lrm', + 'ltf' => 'application/vnd.frogans.ltf', + 'lvp' => 'audio/vnd.lucent.voice', + 'lwp' => 'application/vnd.lotus-wordpro', + 'lzh' => 'application/x-lzh-compressed', + 'm13' => 'application/x-msmediaview', + 'm14' => 'application/x-msmediaview', + 'm1v' => 'video/mpeg', + 'm21' => 'application/mp21', + 'm2a' => 'audio/mpeg', + 'm2v' => 'video/mpeg', + 'm3a' => 'audio/mpeg', + 'm3u' => 'audio/x-mpegurl', + 'm3u8' => 'application/vnd.apple.mpegurl', + 'm4a' => 'audio/mp4', + 'm4u' => 'video/vnd.mpegurl', + 'm4v' => 'video/x-m4v', + 'ma' => 'application/mathematica', + 'mads' => 'application/mads+xml', + 'mag' => 'application/vnd.ecowin.chart', + 'maker' => 'application/vnd.framemaker', + 'man' => 'text/troff', + 'mar' => 'application/octet-stream', + 'mathml' => 'application/mathml+xml', + 'mb' => 'application/mathematica', + 'mbk' => 'application/vnd.mobius.mbk', + 'mbox' => 'application/mbox', + 'mc1' => 'application/vnd.medcalcdata', + 'mcd' => 'application/vnd.mcd', + 'mcurl' => 'text/vnd.curl.mcurl', + 'mdb' => 'application/x-msaccess', + 'mdi' => 'image/vnd.ms-modi', + 'me' => 'text/troff', + 'mesh' => 'model/mesh', + 'meta4' => 'application/metalink4+xml', + 'metalink' => 'application/metalink+xml', + 'mets' => 'application/mets+xml', + 'mfm' => 'application/vnd.mfmp', + 'mft' => 'application/rpki-manifest', + 'mgp' => 'application/vnd.osgeo.mapguide.package', + 'mgz' => 'application/vnd.proteus.magazine', + 'mid' => 'audio/midi', + 'midi' => 'audio/midi', + 'mie' => 'application/x-mie', + 'mif' => 'application/vnd.mif', + 'mime' => 'message/rfc822', + 'mj2' => 'video/mj2', + 'mjp2' => 'video/mj2', + 'mk3d' => 'video/x-matroska', + 'mka' => 'audio/x-matroska', + 'mks' => 'video/x-matroska', + 'mkv' => 'video/x-matroska', + 'mlp' => 'application/vnd.dolby.mlp', + 'mmd' => 'application/vnd.chipnuts.karaoke-mmd', + 'mmf' => 'application/vnd.smaf', + 'mmr' => 'image/vnd.fujixerox.edmics-mmr', + 'mng' => 'video/x-mng', + 'mny' => 'application/x-msmoney', + 'mobi' => 'application/x-mobipocket-ebook', + 'mods' => 'application/mods+xml', + 'mov' => 'video/quicktime', + 'movie' => 'video/x-sgi-movie', + 'mp2' => 'audio/mpeg', + 'mp21' => 'application/mp21', + 'mp2a' => 'audio/mpeg', + 'mp3' => 'audio/mpeg', + 'mp4' => 'video/mp4', + 'mp4a' => 'audio/mp4', + 'mp4s' => 'application/mp4', + 'mp4v' => 'video/mp4', + 'mpc' => 'application/vnd.mophun.certificate', + 'mpe' => 'video/mpeg', + 'mpeg' => 'video/mpeg', + 'mpg' => 'video/mpeg', + 'mpg4' => 'video/mp4', + 'mpga' => 'audio/mpeg', + 'mpkg' => 'application/vnd.apple.installer+xml', + 'mpm' => 'application/vnd.blueice.multipass', + 'mpn' => 'application/vnd.mophun.application', + 'mpp' => 'application/vnd.ms-project', + 'mpt' => 'application/vnd.ms-project', + 'mpy' => 'application/vnd.ibm.minipay', + 'mqy' => 'application/vnd.mobius.mqy', + 'mrc' => 'application/marc', + 'mrcx' => 'application/marcxml+xml', + 'ms' => 'text/troff', + 'mscml' => 'application/mediaservercontrol+xml', + 'mseed' => 'application/vnd.fdsn.mseed', + 'mseq' => 'application/vnd.mseq', + 'msf' => 'application/vnd.epson.msf', + 'msh' => 'model/mesh', + 'msi' => 'application/x-msdownload', + 'msl' => 'application/vnd.mobius.msl', + 'msty' => 'application/vnd.muvee.style', + 'mts' => 'model/vnd.mts', + 'mus' => 'application/vnd.musician', + 'musicxml' => 'application/vnd.recordare.musicxml+xml', + 'mvb' => 'application/x-msmediaview', + 'mwf' => 'application/vnd.mfer', + 'mxf' => 'application/mxf', + 'mxl' => 'application/vnd.recordare.musicxml', + 'mxml' => 'application/xv+xml', + 'mxs' => 'application/vnd.triscape.mxs', + 'mxu' => 'video/vnd.mpegurl', + 'n-gage' => 'application/vnd.nokia.n-gage.symbian.install', + 'n3' => 'text/n3', + 'nb' => 'application/mathematica', + 'nbp' => 'application/vnd.wolfram.player', + 'nc' => 'application/x-netcdf', + 'ncx' => 'application/x-dtbncx+xml', + 'nfo' => 'text/x-nfo', + 'ngdat' => 'application/vnd.nokia.n-gage.data', + 'nitf' => 'application/vnd.nitf', + 'nlu' => 'application/vnd.neurolanguage.nlu', + 'nml' => 'application/vnd.enliven', + 'nnd' => 'application/vnd.noblenet-directory', + 'nns' => 'application/vnd.noblenet-sealer', + 'nnw' => 'application/vnd.noblenet-web', + 'npx' => 'image/vnd.net-fpx', + 'nsc' => 'application/x-conference', + 'nsf' => 'application/vnd.lotus-notes', + 'ntf' => 'application/vnd.nitf', + 'nzb' => 'application/x-nzb', + 'oa2' => 'application/vnd.fujitsu.oasys2', + 'oa3' => 'application/vnd.fujitsu.oasys3', + 'oas' => 'application/vnd.fujitsu.oasys', + 'obd' => 'application/x-msbinder', + 'obj' => 'application/x-tgif', + 'oda' => 'application/oda', + 'odb' => 'application/vnd.oasis.opendocument.database', + 'odc' => 'application/vnd.oasis.opendocument.chart', + 'odf' => 'application/vnd.oasis.opendocument.formula', + 'odft' => 'application/vnd.oasis.opendocument.formula-template', + 'odg' => 'application/vnd.oasis.opendocument.graphics', + 'odi' => 'application/vnd.oasis.opendocument.image', + 'odm' => 'application/vnd.oasis.opendocument.text-master', + 'odp' => 'application/vnd.oasis.opendocument.presentation', + 'ods' => 'application/vnd.oasis.opendocument.spreadsheet', + 'odt' => 'application/vnd.oasis.opendocument.text', + 'oga' => 'audio/ogg', + 'ogg' => 'audio/ogg', + 'ogv' => 'video/ogg', + 'ogx' => 'application/ogg', + 'omdoc' => 'application/omdoc+xml', + 'onepkg' => 'application/onenote', + 'onetmp' => 'application/onenote', + 'onetoc' => 'application/onenote', + 'onetoc2' => 'application/onenote', + 'opf' => 'application/oebps-package+xml', + 'opml' => 'text/x-opml', + 'oprc' => 'application/vnd.palm', + 'org' => 'application/vnd.lotus-organizer', + 'osf' => 'application/vnd.yamaha.openscoreformat', + 'osfpvg' => 'application/vnd.yamaha.openscoreformat.osfpvg+xml', + 'otc' => 'application/vnd.oasis.opendocument.chart-template', + 'otf' => 'application/x-font-otf', + 'otg' => 'application/vnd.oasis.opendocument.graphics-template', + 'oth' => 'application/vnd.oasis.opendocument.text-web', + 'oti' => 'application/vnd.oasis.opendocument.image-template', + 'otp' => 'application/vnd.oasis.opendocument.presentation-template', + 'ots' => 'application/vnd.oasis.opendocument.spreadsheet-template', + 'ott' => 'application/vnd.oasis.opendocument.text-template', + 'oxps' => 'application/oxps', + 'oxt' => 'application/vnd.openofficeorg.extension', + 'p' => 'text/x-pascal', + 'p10' => 'application/pkcs10', + 'p12' => 'application/x-pkcs12', + 'p7b' => 'application/x-pkcs7-certificates', + 'p7c' => 'application/pkcs7-mime', + 'p7m' => 'application/pkcs7-mime', + 'p7r' => 'application/x-pkcs7-certreqresp', + 'p7s' => 'application/pkcs7-signature', + 'p8' => 'application/pkcs8', + 'pas' => 'text/x-pascal', + 'paw' => 'application/vnd.pawaafile', + 'pbd' => 'application/vnd.powerbuilder6', + 'pbm' => 'image/x-portable-bitmap', + 'pcap' => 'application/vnd.tcpdump.pcap', + 'pcf' => 'application/x-font-pcf', + 'pcl' => 'application/vnd.hp-pcl', + 'pclxl' => 'application/vnd.hp-pclxl', + 'pct' => 'image/x-pict', + 'pcurl' => 'application/vnd.curl.pcurl', + 'pcx' => 'image/x-pcx', + 'pdb' => 'application/vnd.palm', + 'pdf' => 'application/pdf', + 'pfa' => 'application/x-font-type1', + 'pfb' => 'application/x-font-type1', + 'pfm' => 'application/x-font-type1', + 'pfr' => 'application/font-tdpfr', + 'pfx' => 'application/x-pkcs12', + 'pgm' => 'image/x-portable-graymap', + 'pgn' => 'application/x-chess-pgn', + 'pgp' => 'application/pgp-encrypted', + 'php' => 'application/x-php', + 'php3' => 'application/x-php', + 'php4' => 'application/x-php', + 'php5' => 'application/x-php', + 'pic' => 'image/x-pict', + 'pkg' => 'application/octet-stream', + 'pki' => 'application/pkixcmp', + 'pkipath' => 'application/pkix-pkipath', + 'plb' => 'application/vnd.3gpp.pic-bw-large', + 'plc' => 'application/vnd.mobius.plc', + 'plf' => 'application/vnd.pocketlearn', + 'pls' => 'application/pls+xml', + 'pml' => 'application/vnd.ctc-posml', + 'png' => 'image/png', + 'pnm' => 'image/x-portable-anymap', + 'portpkg' => 'application/vnd.macports.portpkg', + 'pot' => 'application/vnd.ms-powerpoint', + 'potm' => 'application/vnd.ms-powerpoint.template.macroenabled.12', + 'potx' => 'application/vnd.openxmlformats-officedocument.presentationml.template', + 'ppam' => 'application/vnd.ms-powerpoint.addin.macroenabled.12', + 'ppd' => 'application/vnd.cups-ppd', + 'ppm' => 'image/x-portable-pixmap', + 'pps' => 'application/vnd.ms-powerpoint', + 'ppsm' => 'application/vnd.ms-powerpoint.slideshow.macroenabled.12', + 'ppsx' => 'application/vnd.openxmlformats-officedocument.presentationml.slideshow', + 'ppt' => 'application/vnd.ms-powerpoint', + 'pptm' => 'application/vnd.ms-powerpoint.presentation.macroenabled.12', + 'pptx' => 'application/vnd.openxmlformats-officedocument.presentationml.presentation', + 'pqa' => 'application/vnd.palm', + 'prc' => 'application/x-mobipocket-ebook', + 'pre' => 'application/vnd.lotus-freelance', + 'prf' => 'application/pics-rules', + 'ps' => 'application/postscript', + 'psb' => 'application/vnd.3gpp.pic-bw-small', + 'psd' => 'image/vnd.adobe.photoshop', + 'psf' => 'application/x-font-linux-psf', + 'pskcxml' => 'application/pskc+xml', + 'ptid' => 'application/vnd.pvi.ptid1', + 'pub' => 'application/x-mspublisher', + 'pvb' => 'application/vnd.3gpp.pic-bw-var', + 'pwn' => 'application/vnd.3m.post-it-notes', + 'pya' => 'audio/vnd.ms-playready.media.pya', + 'pyv' => 'video/vnd.ms-playready.media.pyv', + 'qam' => 'application/vnd.epson.quickanime', + 'qbo' => 'application/vnd.intu.qbo', + 'qfx' => 'application/vnd.intu.qfx', + 'qps' => 'application/vnd.publishare-delta-tree', + 'qt' => 'video/quicktime', + 'qwd' => 'application/vnd.quark.quarkxpress', + 'qwt' => 'application/vnd.quark.quarkxpress', + 'qxb' => 'application/vnd.quark.quarkxpress', + 'qxd' => 'application/vnd.quark.quarkxpress', + 'qxl' => 'application/vnd.quark.quarkxpress', + 'qxt' => 'application/vnd.quark.quarkxpress', + 'ra' => 'audio/x-pn-realaudio', + 'ram' => 'audio/x-pn-realaudio', + 'rar' => 'application/x-rar-compressed', + 'ras' => 'image/x-cmu-raster', + 'rcprofile' => 'application/vnd.ipunplugged.rcprofile', + 'rdf' => 'application/rdf+xml', + 'rdz' => 'application/vnd.data-vision.rdz', + 'rep' => 'application/vnd.businessobjects', + 'res' => 'application/x-dtbresource+xml', + 'rgb' => 'image/x-rgb', + 'rif' => 'application/reginfo+xml', + 'rip' => 'audio/vnd.rip', + 'ris' => 'application/x-research-info-systems', + 'rl' => 'application/resource-lists+xml', + 'rlc' => 'image/vnd.fujixerox.edmics-rlc', + 'rld' => 'application/resource-lists-diff+xml', + 'rm' => 'application/vnd.rn-realmedia', + 'rmi' => 'audio/midi', + 'rmp' => 'audio/x-pn-realaudio-plugin', + 'rms' => 'application/vnd.jcp.javame.midlet-rms', + 'rmvb' => 'application/vnd.rn-realmedia-vbr', + 'rnc' => 'application/relax-ng-compact-syntax', + 'roa' => 'application/rpki-roa', + 'roff' => 'text/troff', + 'rp9' => 'application/vnd.cloanto.rp9', + 'rpss' => 'application/vnd.nokia.radio-presets', + 'rpst' => 'application/vnd.nokia.radio-preset', + 'rq' => 'application/sparql-query', + 'rs' => 'application/rls-services+xml', + 'rsd' => 'application/rsd+xml', + 'rss' => 'application/rss+xml', + 'rtf' => 'application/rtf', + 'rtx' => 'text/richtext', + 's' => 'text/x-asm', + 's3m' => 'audio/s3m', + 'saf' => 'application/vnd.yamaha.smaf-audio', + 'sbml' => 'application/sbml+xml', + 'sc' => 'application/vnd.ibm.secure-container', + 'scd' => 'application/x-msschedule', + 'scm' => 'application/vnd.lotus-screencam', + 'scq' => 'application/scvp-cv-request', + 'scs' => 'application/scvp-cv-response', + 'scurl' => 'text/vnd.curl.scurl', + 'sda' => 'application/vnd.stardivision.draw', + 'sdc' => 'application/vnd.stardivision.calc', + 'sdd' => 'application/vnd.stardivision.impress', + 'sdkd' => 'application/vnd.solent.sdkm+xml', + 'sdkm' => 'application/vnd.solent.sdkm+xml', + 'sdp' => 'application/sdp', + 'sdw' => 'application/vnd.stardivision.writer', + 'see' => 'application/vnd.seemail', + 'seed' => 'application/vnd.fdsn.seed', + 'sema' => 'application/vnd.sema', + 'semd' => 'application/vnd.semd', + 'semf' => 'application/vnd.semf', + 'ser' => 'application/java-serialized-object', + 'setpay' => 'application/set-payment-initiation', + 'setreg' => 'application/set-registration-initiation', + 'sfd-hdstx' => 'application/vnd.hydrostatix.sof-data', + 'sfs' => 'application/vnd.spotfire.sfs', + 'sfv' => 'text/x-sfv', + 'sgi' => 'image/sgi', + 'sgl' => 'application/vnd.stardivision.writer-global', + 'sgm' => 'text/sgml', + 'sgml' => 'text/sgml', + 'sh' => 'application/x-sh', + 'shar' => 'application/x-shar', + 'shf' => 'application/shf+xml', + 'sid' => 'image/x-mrsid-image', + 'sig' => 'application/pgp-signature', + 'sil' => 'audio/silk', + 'silo' => 'model/mesh', + 'sis' => 'application/vnd.symbian.install', + 'sisx' => 'application/vnd.symbian.install', + 'sit' => 'application/x-stuffit', + 'sitx' => 'application/x-stuffitx', + 'skd' => 'application/vnd.koan', + 'skm' => 'application/vnd.koan', + 'skp' => 'application/vnd.koan', + 'skt' => 'application/vnd.koan', + 'sldm' => 'application/vnd.ms-powerpoint.slide.macroenabled.12', + 'sldx' => 'application/vnd.openxmlformats-officedocument.presentationml.slide', + 'slt' => 'application/vnd.epson.salt', + 'sm' => 'application/vnd.stepmania.stepchart', + 'smf' => 'application/vnd.stardivision.math', + 'smi' => 'application/smil+xml', + 'smil' => 'application/smil+xml', + 'smv' => 'video/x-smv', + 'smzip' => 'application/vnd.stepmania.package', + 'snd' => 'audio/basic', + 'snf' => 'application/x-font-snf', + 'so' => 'application/octet-stream', + 'spc' => 'application/x-pkcs7-certificates', + 'spf' => 'application/vnd.yamaha.smaf-phrase', + 'spl' => 'application/x-futuresplash', + 'spot' => 'text/vnd.in3d.spot', + 'spp' => 'application/scvp-vp-response', + 'spq' => 'application/scvp-vp-request', + 'spx' => 'audio/ogg', + 'sql' => 'application/x-sql', + 'src' => 'application/x-wais-source', + 'srt' => 'application/x-subrip', + 'sru' => 'application/sru+xml', + 'srx' => 'application/sparql-results+xml', + 'ssdl' => 'application/ssdl+xml', + 'sse' => 'application/vnd.kodak-descriptor', + 'ssf' => 'application/vnd.epson.ssf', + 'ssml' => 'application/ssml+xml', + 'st' => 'application/vnd.sailingtracker.track', + 'stc' => 'application/vnd.sun.xml.calc.template', + 'std' => 'application/vnd.sun.xml.draw.template', + 'stf' => 'application/vnd.wt.stf', + 'sti' => 'application/vnd.sun.xml.impress.template', + 'stk' => 'application/hyperstudio', + 'stl' => 'application/vnd.ms-pki.stl', + 'str' => 'application/vnd.pg.format', + 'stw' => 'application/vnd.sun.xml.writer.template', + 'sub' => 'text/vnd.dvb.subtitle', + 'sus' => 'application/vnd.sus-calendar', + 'susp' => 'application/vnd.sus-calendar', + 'sv4cpio' => 'application/x-sv4cpio', + 'sv4crc' => 'application/x-sv4crc', + 'svc' => 'application/vnd.dvb.service', + 'svd' => 'application/vnd.svd', + 'svg' => 'image/svg+xml', + 'svgz' => 'image/svg+xml', + 'swa' => 'application/x-director', + 'swf' => 'application/x-shockwave-flash', + 'swi' => 'application/vnd.aristanetworks.swi', + 'sxc' => 'application/vnd.sun.xml.calc', + 'sxd' => 'application/vnd.sun.xml.draw', + 'sxg' => 'application/vnd.sun.xml.writer.global', + 'sxi' => 'application/vnd.sun.xml.impress', + 'sxm' => 'application/vnd.sun.xml.math', + 'sxw' => 'application/vnd.sun.xml.writer', + 't' => 'text/troff', + 't3' => 'application/x-t3vm-image', + 'taglet' => 'application/vnd.mynfc', + 'tao' => 'application/vnd.tao.intent-module-archive', + 'tar' => 'application/x-tar', + 'tcap' => 'application/vnd.3gpp2.tcap', + 'tcl' => 'application/x-tcl', + 'teacher' => 'application/vnd.smart.teacher', + 'tei' => 'application/tei+xml', + 'teicorpus' => 'application/tei+xml', + 'tex' => 'application/x-tex', + 'texi' => 'application/x-texinfo', + 'texinfo' => 'application/x-texinfo', + 'text' => 'text/plain', + 'tfi' => 'application/thraud+xml', + 'tfm' => 'application/x-tex-tfm', + 'tga' => 'image/x-tga', + 'thmx' => 'application/vnd.ms-officetheme', + 'tif' => 'image/tiff', + 'tiff' => 'image/tiff', + 'tmo' => 'application/vnd.tmobile-livetv', + 'torrent' => 'application/x-bittorrent', + 'tpl' => 'application/vnd.groove-tool-template', + 'tpt' => 'application/vnd.trid.tpt', + 'tr' => 'text/troff', + 'tra' => 'application/vnd.trueapp', + 'trm' => 'application/x-msterminal', + 'tsd' => 'application/timestamped-data', + 'tsv' => 'text/tab-separated-values', + 'ttc' => 'application/x-font-ttf', + 'ttf' => 'application/x-font-ttf', + 'ttl' => 'text/turtle', + 'twd' => 'application/vnd.simtech-mindmapper', + 'twds' => 'application/vnd.simtech-mindmapper', + 'txd' => 'application/vnd.genomatix.tuxedo', + 'txf' => 'application/vnd.mobius.txf', + 'txt' => 'text/plain', + 'u32' => 'application/x-authorware-bin', + 'udeb' => 'application/x-debian-package', + 'ufd' => 'application/vnd.ufdl', + 'ufdl' => 'application/vnd.ufdl', + 'ulx' => 'application/x-glulx', + 'umj' => 'application/vnd.umajin', + 'unityweb' => 'application/vnd.unity', + 'uoml' => 'application/vnd.uoml+xml', + 'uri' => 'text/uri-list', + 'uris' => 'text/uri-list', + 'urls' => 'text/uri-list', + 'ustar' => 'application/x-ustar', + 'utz' => 'application/vnd.uiq.theme', + 'uu' => 'text/x-uuencode', + 'uva' => 'audio/vnd.dece.audio', + 'uvd' => 'application/vnd.dece.data', + 'uvf' => 'application/vnd.dece.data', + 'uvg' => 'image/vnd.dece.graphic', + 'uvh' => 'video/vnd.dece.hd', + 'uvi' => 'image/vnd.dece.graphic', + 'uvm' => 'video/vnd.dece.mobile', + 'uvp' => 'video/vnd.dece.pd', + 'uvs' => 'video/vnd.dece.sd', + 'uvt' => 'application/vnd.dece.ttml+xml', + 'uvu' => 'video/vnd.uvvu.mp4', + 'uvv' => 'video/vnd.dece.video', + 'uvva' => 'audio/vnd.dece.audio', + 'uvvd' => 'application/vnd.dece.data', + 'uvvf' => 'application/vnd.dece.data', + 'uvvg' => 'image/vnd.dece.graphic', + 'uvvh' => 'video/vnd.dece.hd', + 'uvvi' => 'image/vnd.dece.graphic', + 'uvvm' => 'video/vnd.dece.mobile', + 'uvvp' => 'video/vnd.dece.pd', + 'uvvs' => 'video/vnd.dece.sd', + 'uvvt' => 'application/vnd.dece.ttml+xml', + 'uvvu' => 'video/vnd.uvvu.mp4', + 'uvvv' => 'video/vnd.dece.video', + 'uvvx' => 'application/vnd.dece.unspecified', + 'uvvz' => 'application/vnd.dece.zip', + 'uvx' => 'application/vnd.dece.unspecified', + 'uvz' => 'application/vnd.dece.zip', + 'vcard' => 'text/vcard', + 'vcd' => 'application/x-cdlink', + 'vcf' => 'text/x-vcard', + 'vcg' => 'application/vnd.groove-vcard', + 'vcs' => 'text/x-vcalendar', + 'vcx' => 'application/vnd.vcx', + 'vis' => 'application/vnd.visionary', + 'viv' => 'video/vnd.vivo', + 'vob' => 'video/x-ms-vob', + 'vor' => 'application/vnd.stardivision.writer', + 'vox' => 'application/x-authorware-bin', + 'vrml' => 'model/vrml', + 'vsd' => 'application/vnd.visio', + 'vsf' => 'application/vnd.vsf', + 'vss' => 'application/vnd.visio', + 'vst' => 'application/vnd.visio', + 'vsw' => 'application/vnd.visio', + 'vtu' => 'model/vnd.vtu', + 'vxml' => 'application/voicexml+xml', + 'w3d' => 'application/x-director', + 'wad' => 'application/x-doom', + 'wav' => 'audio/x-wav', + 'wax' => 'audio/x-ms-wax', + 'wbmp' => 'image/vnd.wap.wbmp', + 'wbs' => 'application/vnd.criticaltools.wbs+xml', + 'wbxml' => 'application/vnd.wap.wbxml', + 'wcm' => 'application/vnd.ms-works', + 'wdb' => 'application/vnd.ms-works', + 'wdp' => 'image/vnd.ms-photo', + 'weba' => 'audio/webm', + 'webm' => 'video/webm', + 'webp' => 'image/webp', + 'wg' => 'application/vnd.pmi.widget', + 'wgt' => 'application/widget', + 'wks' => 'application/vnd.ms-works', + 'wm' => 'video/x-ms-wm', + 'wma' => 'audio/x-ms-wma', + 'wmd' => 'application/x-ms-wmd', + 'wmf' => 'application/x-msmetafile', + 'wml' => 'text/vnd.wap.wml', + 'wmlc' => 'application/vnd.wap.wmlc', + 'wmls' => 'text/vnd.wap.wmlscript', + 'wmlsc' => 'application/vnd.wap.wmlscriptc', + 'wmv' => 'video/x-ms-wmv', + 'wmx' => 'video/x-ms-wmx', + 'wmz' => 'application/x-msmetafile', + 'woff' => 'application/font-woff', + 'wpd' => 'application/vnd.wordperfect', + 'wpl' => 'application/vnd.ms-wpl', + 'wps' => 'application/vnd.ms-works', + 'wqd' => 'application/vnd.wqd', + 'wri' => 'application/x-mswrite', + 'wrl' => 'model/vrml', + 'wsdl' => 'application/wsdl+xml', + 'wspolicy' => 'application/wspolicy+xml', + 'wtb' => 'application/vnd.webturbo', + 'wvx' => 'video/x-ms-wvx', + 'x32' => 'application/x-authorware-bin', + 'x3d' => 'model/x3d+xml', + 'x3db' => 'model/x3d+binary', + 'x3dbz' => 'model/x3d+binary', + 'x3dv' => 'model/x3d+vrml', + 'x3dvz' => 'model/x3d+vrml', + 'x3dz' => 'model/x3d+xml', + 'xaml' => 'application/xaml+xml', + 'xap' => 'application/x-silverlight-app', + 'xar' => 'application/vnd.xara', + 'xbap' => 'application/x-ms-xbap', + 'xbd' => 'application/vnd.fujixerox.docuworks.binder', + 'xbm' => 'image/x-xbitmap', + 'xdf' => 'application/xcap-diff+xml', + 'xdm' => 'application/vnd.syncml.dm+xml', + 'xdp' => 'application/vnd.adobe.xdp+xml', + 'xdssc' => 'application/dssc+xml', + 'xdw' => 'application/vnd.fujixerox.docuworks', + 'xenc' => 'application/xenc+xml', + 'xer' => 'application/patch-ops-error+xml', + 'xfdf' => 'application/vnd.adobe.xfdf', + 'xfdl' => 'application/vnd.xfdl', + 'xht' => 'application/xhtml+xml', + 'xhtml' => 'application/xhtml+xml', + 'xhvml' => 'application/xv+xml', + 'xif' => 'image/vnd.xiff', + 'xla' => 'application/vnd.ms-excel', + 'xlam' => 'application/vnd.ms-excel.addin.macroenabled.12', + 'xlc' => 'application/vnd.ms-excel', + 'xlf' => 'application/x-xliff+xml', + 'xlm' => 'application/vnd.ms-excel', + 'xls' => 'application/vnd.ms-excel', + 'xlsb' => 'application/vnd.ms-excel.sheet.binary.macroenabled.12', + 'xlsm' => 'application/vnd.ms-excel.sheet.macroenabled.12', + 'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', + 'xlt' => 'application/vnd.ms-excel', + 'xltm' => 'application/vnd.ms-excel.template.macroenabled.12', + 'xltx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.template', + 'xlw' => 'application/vnd.ms-excel', + 'xm' => 'audio/xm', + 'xml' => 'application/xml', + 'xo' => 'application/vnd.olpc-sugar', + 'xop' => 'application/xop+xml', + 'xpi' => 'application/x-xpinstall', + 'xpl' => 'application/xproc+xml', + 'xpm' => 'image/x-xpixmap', + 'xpr' => 'application/vnd.is-xpr', + 'xps' => 'application/vnd.ms-xpsdocument', + 'xpw' => 'application/vnd.intercon.formnet', + 'xpx' => 'application/vnd.intercon.formnet', + 'xsl' => 'application/xml', + 'xslt' => 'application/xslt+xml', + 'xsm' => 'application/vnd.syncml+xml', + 'xspf' => 'application/xspf+xml', + 'xul' => 'application/vnd.mozilla.xul+xml', + 'xvm' => 'application/xv+xml', + 'xvml' => 'application/xv+xml', + 'xwd' => 'image/x-xwindowdump', + 'xyz' => 'chemical/x-xyz', + 'xz' => 'application/x-xz', + 'yang' => 'application/yang', + 'yin' => 'application/yin+xml', + 'z1' => 'application/x-zmachine', + 'z2' => 'application/x-zmachine', + 'z3' => 'application/x-zmachine', + 'z4' => 'application/x-zmachine', + 'z5' => 'application/x-zmachine', + 'z6' => 'application/x-zmachine', + 'z7' => 'application/x-zmachine', + 'z8' => 'application/x-zmachine', + 'zaz' => 'application/vnd.zzazz.deck+xml', + 'zip' => 'application/zip', + 'zir' => 'application/vnd.zul', + 'zirz' => 'application/vnd.zul', + 'zmm' => 'application/vnd.handheld-entertainment+xml', + '123' => 'application/vnd.lotus-1-2-3' +); diff --git a/vendor/swiftmailer/swiftmailer/lib/preferences.php b/vendor/swiftmailer/swiftmailer/lib/preferences.php new file mode 100755 index 0000000..4223943 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/preferences.php @@ -0,0 +1,35 @@ +setCharset('utf-8'); + +// Without these lines the default caching mechanism is "array" but this uses a lot of memory. +// If possible, use a disk cache to enable attaching large attachments etc. +// You can override the default temporary directory by setting the TMPDIR environment variable. + +// The @ operator in front of is_writable calls is to avoid PHP warnings +// when using open_basedir +$tmp = getenv('TMPDIR'); +if ($tmp && @is_writable($tmp)) { + $preferences + ->setTempDir($tmp) + ->setCacheType('disk'); +} elseif (function_exists('sys_get_temp_dir') && @is_writable(sys_get_temp_dir())) { + $preferences + ->setTempDir(sys_get_temp_dir()) + ->setCacheType('disk'); +} + +// this should only be done when Swiftmailer won't use the native QP content encoder +// see mime_deps.php +if (version_compare(phpversion(), '5.4.7', '<')) { + $preferences->setQPDotEscape(false); +} diff --git a/vendor/swiftmailer/swiftmailer/lib/swift_init.php b/vendor/swiftmailer/swiftmailer/lib/swift_init.php new file mode 100755 index 0000000..5c80b05 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/lib/swift_init.php @@ -0,0 +1,28 @@ + 'application/x-php', + 'php3' => 'application/x-php', + 'php4' => 'application/x-php', + 'php5' => 'application/x-php', + 'pdf' => 'application/pdf', + 'zip' => 'application/zip', + 'gif' => 'image/gif', + 'jpg' => 'image/jpeg', + 'png' => 'image/png', + 'css' => 'text/css', + 'html' => 'text/html', + 'js' => 'text/javascript', + 'txt' => 'text/plain', + 'xml' => 'text/xml', + 'aif' => 'audio/x-aiff', + 'aiff' => 'audio/x-aiff', + 'avi' => 'video/avi', + 'bmp' => 'image/bmp', + 'bz2' => 'application/x-bz2', + 'csv' => 'text/csv', + 'dmg' => 'application/x-apple-diskimage', + 'doc' => 'application/msword', + 'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', + 'eml' => 'message/rfc822', + 'aps' => 'application/postscript', + 'exe' => 'application/x-ms-dos-executable', + 'flv' => 'video/x-flv', + 'gif' => 'image/gif', + 'gz' => 'application/x-gzip', + 'hqx' => 'application/stuffit', + 'htm' => 'text/html', + 'html' => 'text/html', + 'jar' => 'application/x-java-archive', + 'jpeg' => 'image/jpeg', + 'jpg' => 'image/jpeg', + 'm3u' => 'audio/x-mpegurl', + 'm4a' => 'audio/mp4', + 'mdb' => 'application/x-msaccess', + 'mid' => 'audio/midi', + 'midi' => 'audio/midi', + 'mov' => 'video/quicktime', + 'mp3' => 'audio/mpeg', + 'mp4' => 'video/mp4', + 'mpeg' => 'video/mpeg', + 'mpg' => 'video/mpeg', + 'odg' => 'vnd.oasis.opendocument.graphics', + 'odp' => 'vnd.oasis.opendocument.presentation', + 'odt' => 'vnd.oasis.opendocument.text', + 'ods' => 'vnd.oasis.opendocument.spreadsheet', + 'ogg' => 'audio/ogg', + 'pdf' => 'application/pdf', + 'png' => 'image/png', + 'ppt' => 'application/vnd.ms-powerpoint', + 'pptx' => 'application/vnd.openxmlformats-officedocument.presentationml.presentation', + 'ps' => 'application/postscript', + 'rar' => 'application/x-rar-compressed', + 'rtf' => 'application/rtf', + 'tar' => 'application/x-tar', + 'sit' => 'application/x-stuffit', + 'svg' => 'image/svg+xml', + 'tif' => 'image/tiff', + 'tiff' => 'image/tiff', + 'ttf' => 'application/x-font-truetype', + 'txt' => 'text/plain', + 'vcf' => 'text/x-vcard', + 'wav' => 'audio/wav', + 'wma' => 'audio/x-ms-wma', + 'wmv' => 'audio/x-ms-wmv', + 'xls' => 'application/excel', + 'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', + 'xml' => 'application/xml', + 'zip' => 'application/zip' + ]; + + // wrap array for generating file + foreach ($valid_mime_types_preset as $extension => $mime_type) { + // generate array for mimetype to extension resolver (only first match) + $valid_mime_types[$extension] = "'{$extension}' => '{$mime_type}'"; + } + + // collect extensions + $valid_extensions = []; + + // all extensions from second match + foreach ($matches[2] as $i => $extensions) { + // explode multiple extensions from string + $extensions = explode(" ", strtolower($extensions)); + + // force array for foreach + if (!is_array($extensions)) { + $extensions = array($extensions); + } + + foreach ($extensions as $extension) { + // get mime type + $mime_type = $matches[1][$i]; + + // check if string length lower than 10 + if (strlen($extension) < 10) { + // add extension + $valid_extensions[] = $extension; + + if (!isset($valid_mime_types[$mime_type])) { + // generate array for mimetype to extension resolver (only first match) + $valid_mime_types[$extension] = "'{$extension}' => '{$mime_type}'"; + } + } + } + } + } + + $xml = simplexml_load_string($mime_xml); + + foreach ($xml as $node) { + // check if there is no pattern + if (!isset($node->glob["pattern"])) { + continue; + } + + // get all matching extensions from match + foreach ((array) $node->glob["pattern"] as $extension) { + // skip none glob extensions + if (strpos($extension, '.') === FALSE) { + continue; + } + + // remove get only last part + $extension = explode('.', strtolower($extension)); + $extension = end($extension); + + // maximum length in database column + if (strlen($extension) <= 9) { + $valid_extensions[] = $extension; + } + } + + if (isset($node->glob["pattern"][0])) { + // mime type + $mime_type = strtolower((string) $node["type"]); + + // get first extension + $extension = strtolower(trim($node->glob["ddpattern"][0], '*.')); + + // skip none glob extensions and check if string length between 1 and 10 + if (strpos($extension, '.') !== FALSE || strlen($extension) < 1 || strlen($extension) > 9) { + continue; + } + + // check if string length lower than 10 + if (!isset($valid_mime_types[$mime_type])) { + // generate array for mimetype to extension resolver (only first match) + $valid_mime_types[$extension] = "'{$extension}' => '{$mime_type}'"; + } + } + } + + // full list of valid extensions only + $valid_mime_types = array_unique($valid_mime_types); + ksort($valid_mime_types); + + // combine mime types and extensions array + $output = "$preamble\$swift_mime_types = array(\n ".implode($valid_mime_types, ",\n ")."\n);"; + + // write mime_types.php config file + @file_put_contents('./mime_types.php', $output); +} + +generateUpToDateMimeArray(); diff --git a/vendor/swiftmailer/swiftmailer/notes/APPS b/vendor/swiftmailer/swiftmailer/notes/APPS new file mode 100755 index 0000000..b06b4cc --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/notes/APPS @@ -0,0 +1,15 @@ +Applications I need to test with +--------------------------------- + +Standalone (can read .eml files): +--------------------------------- +Microsoft Entourage (can assume same as outlook) +Mozilla Thunderbird +Apple Mail + +Web-based: +---------- +Hotmail +Gmail +Yahoo! +Mail2Web diff --git a/vendor/swiftmailer/swiftmailer/notes/CHARSETS b/vendor/swiftmailer/swiftmailer/notes/CHARSETS new file mode 100755 index 0000000..6a97a89 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/notes/CHARSETS @@ -0,0 +1,46 @@ +Following is a list of character sets along with their widths: +-------------------------------------------------------------- + +1 Octet 8bit: +------------- +Windows 125* (CP125*) +CP* +ANSI +ISO-8859-* (IEC-8859-*) +Macintosh (Mac OS Roman) +KOI8-U (potentially KOI*8-*) +KOI8-R +MIK +Cork (T1) +ISCII +VISCII + + +1 Octet 7bit: +------------- +US-ASCII +K0I7 + +2 octets 16 bit: +---------------- +UCS-2 +UTF-16* (UTF-16BE etc) + +4-octets 32 bit: +---------------- +UCS-4 +UTF-32 + +Variable-width: +---------------------------- +Big5 - http://en.wikipedia.org/wiki/Big5 (1-2 bytes: 00-7f=1, 81-fe=2) +HKSCS - http://en.wikipedia.org/wiki/HKSCS (a big5 variant, but some variants use 10646) +ISO-10646 (IEC-10646) - http://en.wikipedia.org/wiki/ISO_10646 (unicode) +UTF-8 (1-5 bytes) +ISO-2022 (IEC-2022) - http://en.wikipedia.org/wiki/ISO_2022 +Shift-JIS - http://en.wikipedia.org/wiki/Shift-JIS + +A good resource: +---------------- +http://en.wikipedia.org/wiki/Character_encoding#Simple_character_sets + diff --git a/vendor/swiftmailer/swiftmailer/notes/message.xml b/vendor/swiftmailer/swiftmailer/notes/message.xml new file mode 100755 index 0000000..1183eca --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/notes/message.xml @@ -0,0 +1,22 @@ + + + Some test message + chris@w3style.co.uk + mark@swiftmailer.org + chris.corbyn@sitepoint.com + text/plain + + Here's a recipe for beef stifado + + + text/html + + This is the other part + + + + application/pdf + stifado.pdf + /path/to/stifado.pdf + + diff --git a/vendor/swiftmailer/swiftmailer/notes/rfc/rfc0821.txt b/vendor/swiftmailer/swiftmailer/notes/rfc/rfc0821.txt new file mode 100755 index 0000000..d877b72 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/notes/rfc/rfc0821.txt @@ -0,0 +1,4050 @@ + + + + RFC 821 + + + + + + SIMPLE MAIL TRANSFER PROTOCOL + + + + Jonathan B. Postel + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + August 1982 + + + + Information Sciences Institute + University of Southern California + 4676 Admiralty Way + Marina del Rey, California 90291 + + (213) 822-1511 + + + + +RFC 821 August 1982 + Simple Mail Transfer Protocol + + + + TABLE OF CONTENTS + + 1. INTRODUCTION .................................................. 1 + + 2. THE SMTP MODEL ................................................ 2 + + 3. THE SMTP PROCEDURE ............................................ 4 + + 3.1. Mail ..................................................... 4 + 3.2. Forwarding ............................................... 7 + 3.3. Verifying and Expanding .................................. 8 + 3.4. Sending and Mailing ..................................... 11 + 3.5. Opening and Closing ..................................... 13 + 3.6. Relaying ................................................ 14 + 3.7. Domains ................................................. 17 + 3.8. Changing Roles .......................................... 18 + + 4. THE SMTP SPECIFICATIONS ...................................... 19 + + 4.1. SMTP Commands ........................................... 19 + 4.1.1. Command Semantics ..................................... 19 + 4.1.2. Command Syntax ........................................ 27 + 4.2. SMTP Replies ............................................ 34 + 4.2.1. Reply Codes by Function Group ......................... 35 + 4.2.2. Reply Codes in Numeric Order .......................... 36 + 4.3. Sequencing of Commands and Replies ...................... 37 + 4.4. State Diagrams .......................................... 39 + 4.5. Details ................................................. 41 + 4.5.1. Minimum Implementation ................................ 41 + 4.5.2. Transparency .......................................... 41 + 4.5.3. Sizes ................................................. 42 + + APPENDIX A: TCP ................................................. 44 + APPENDIX B: NCP ................................................. 45 + APPENDIX C: NITS ................................................ 46 + APPENDIX D: X.25 ................................................ 47 + APPENDIX E: Theory of Reply Codes ............................... 48 + APPENDIX F: Scenarios ........................................... 51 + + GLOSSARY ......................................................... 64 + + REFERENCES ....................................................... 67 + + + + +Network Working Group J. Postel +Request for Comments: DRAFT ISI +Replaces: RFC 788, 780, 772 August 1982 + + SIMPLE MAIL TRANSFER PROTOCOL + + +1. INTRODUCTION + + The objective of Simple Mail Transfer Protocol (SMTP) is to transfer + mail reliably and efficiently. + + SMTP is independent of the particular transmission subsystem and + requires only a reliable ordered data stream channel. Appendices A, + B, C, and D describe the use of SMTP with various transport services. + A Glossary provides the definitions of terms as used in this + document. + + An important feature of SMTP is its capability to relay mail across + transport service environments. A transport service provides an + interprocess communication environment (IPCE). An IPCE may cover one + network, several networks, or a subset of a network. It is important + to realize that transport systems (or IPCEs) are not one-to-one with + networks. A process can communicate directly with another process + through any mutually known IPCE. Mail is an application or use of + interprocess communication. Mail can be communicated between + processes in different IPCEs by relaying through a process connected + to two (or more) IPCEs. More specifically, mail can be relayed + between hosts on different transport systems by a host on both + transport systems. + + + + + + + + + + + + + + + + + + + + + + + + +Postel [Page 1] + + + +August 1982 RFC 821 +Simple Mail Transfer Protocol + + + +2. THE SMTP MODEL + + The SMTP design is based on the following model of communication: as + the result of a user mail request, the sender-SMTP establishes a + two-way transmission channel to a receiver-SMTP. The receiver-SMTP + may be either the ultimate destination or an intermediate. SMTP + commands are generated by the sender-SMTP and sent to the + receiver-SMTP. SMTP replies are sent from the receiver-SMTP to the + sender-SMTP in response to the commands. + + Once the transmission channel is established, the SMTP-sender sends a + MAIL command indicating the sender of the mail. If the SMTP-receiver + can accept mail it responds with an OK reply. The SMTP-sender then + sends a RCPT command identifying a recipient of the mail. If the + SMTP-receiver can accept mail for that recipient it responds with an + OK reply; if not, it responds with a reply rejecting that recipient + (but not the whole mail transaction). The SMTP-sender and + SMTP-receiver may negotiate several recipients. When the recipients + have been negotiated the SMTP-sender sends the mail data, terminating + with a special sequence. If the SMTP-receiver successfully processes + the mail data it responds with an OK reply. The dialog is purposely + lock-step, one-at-a-time. + + ------------------------------------------------------------- + + + +----------+ +----------+ + +------+ | | | | + | User |<-->| | SMTP | | + +------+ | Sender- |Commands/Replies| Receiver-| + +------+ | SMTP |<-------------->| SMTP | +------+ + | File |<-->| | and Mail | |<-->| File | + |System| | | | | |System| + +------+ +----------+ +----------+ +------+ + + + Sender-SMTP Receiver-SMTP + + Model for SMTP Use + + Figure 1 + + ------------------------------------------------------------- + + The SMTP provides mechanisms for the transmission of mail; directly + from the sending user's host to the receiving user's host when the + + + +[Page 2] Postel + + + +RFC 821 August 1982 + Simple Mail Transfer Protocol + + + + two host are connected to the same transport service, or via one or + more relay SMTP-servers when the source and destination hosts are not + connected to the same transport service. + + To be able to provide the relay capability the SMTP-server must be + supplied with the name of the ultimate destination host as well as + the destination mailbox name. + + The argument to the MAIL command is a reverse-path, which specifies + who the mail is from. The argument to the RCPT command is a + forward-path, which specifies who the mail is to. The forward-path + is a source route, while the reverse-path is a return route (which + may be used to return a message to the sender when an error occurs + with a relayed message). + + When the same message is sent to multiple recipients the SMTP + encourages the transmission of only one copy of the data for all the + recipients at the same destination host. + + The mail commands and replies have a rigid syntax. Replies also have + a numeric code. In the following, examples appear which use actual + commands and replies. The complete lists of commands and replies + appears in Section 4 on specifications. + + Commands and replies are not case sensitive. That is, a command or + reply word may be upper case, lower case, or any mixture of upper and + lower case. Note that this is not true of mailbox user names. For + some hosts the user name is case sensitive, and SMTP implementations + must take case to preserve the case of user names as they appear in + mailbox arguments. Host names are not case sensitive. + + Commands and replies are composed of characters from the ASCII + character set [1]. When the transport service provides an 8-bit byte + (octet) transmission channel, each 7-bit character is transmitted + right justified in an octet with the high order bit cleared to zero. + + When specifying the general form of a command or reply, an argument + (or special symbol) will be denoted by a meta-linguistic variable (or + constant), for example, "" or "". Here the + angle brackets indicate these are meta-linguistic variables. + However, some arguments use the angle brackets literally. For + example, an actual reverse-path is enclosed in angle brackets, i.e., + "" is an instance of (the + angle brackets are actually transmitted in the command or reply). + + + + + +Postel [Page 3] + + + +August 1982 RFC 821 +Simple Mail Transfer Protocol + + + +3. THE SMTP PROCEDURES + + This section presents the procedures used in SMTP in several parts. + First comes the basic mail procedure defined as a mail transaction. + Following this are descriptions of forwarding mail, verifying mailbox + names and expanding mailing lists, sending to terminals instead of or + in combination with mailboxes, and the opening and closing exchanges. + At the end of this section are comments on relaying, a note on mail + domains, and a discussion of changing roles. Throughout this section + are examples of partial command and reply sequences, several complete + scenarios are presented in Appendix F. + + 3.1. MAIL + + There are three steps to SMTP mail transactions. The transaction + is started with a MAIL command which gives the sender + identification. A series of one or more RCPT commands follows + giving the receiver information. Then a DATA command gives the + mail data. And finally, the end of mail data indicator confirms + the transaction. + + The first step in the procedure is the MAIL command. The + contains the source mailbox. + + MAIL FROM: + + This command tells the SMTP-receiver that a new mail + transaction is starting and to reset all its state tables and + buffers, including any recipients or mail data. It gives the + reverse-path which can be used to report errors. If accepted, + the receiver-SMTP returns a 250 OK reply. + + The can contain more than just a mailbox. The + is a reverse source routing list of hosts and + source mailbox. The first host in the should be + the host sending this command. + + The second step in the procedure is the RCPT command. + + RCPT TO: + + This command gives a forward-path identifying one recipient. + If accepted, the receiver-SMTP returns a 250 OK reply, and + stores the forward-path. If the recipient is unknown the + receiver-SMTP returns a 550 Failure reply. This second step of + the procedure can be repeated any number of times. + + + +[Page 4] Postel + + + +RFC 821 August 1982 + Simple Mail Transfer Protocol + + + + The can contain more than just a mailbox. The + is a source routing list of hosts and the + destination mailbox. The first host in the + should be the host receiving this command. + + The third step in the procedure is the DATA command. + + DATA + + If accepted, the receiver-SMTP returns a 354 Intermediate reply + and considers all succeeding lines to be the message text. + When the end of text is received and stored the SMTP-receiver + sends a 250 OK reply. + + Since the mail data is sent on the transmission channel the end + of the mail data must be indicated so that the command and + reply dialog can be resumed. SMTP indicates the end of the + mail data by sending a line containing only a period. A + transparency procedure is used to prevent this from interfering + with the user's text (see Section 4.5.2). + + Please note that the mail data includes the memo header + items such as Date, Subject, To, Cc, From [2]. + + The end of mail data indicator also confirms the mail + transaction and tells the receiver-SMTP to now process the + stored recipients and mail data. If accepted, the + receiver-SMTP returns a 250 OK reply. The DATA command should + fail only if the mail transaction was incomplete (for example, + no recipients), or if resources are not available. + + The above procedure is an example of a mail transaction. These + commands must be used only in the order discussed above. + Example 1 (below) illustrates the use of these commands in a mail + transaction. + + + + + + + + + + + + + + +Postel [Page 5] + + + +August 1982 RFC 821 +Simple Mail Transfer Protocol + + + + ------------------------------------------------------------- + + Example of the SMTP Procedure + + This SMTP example shows mail sent by Smith at host Alpha.ARPA, + to Jones, Green, and Brown at host Beta.ARPA. Here we assume + that host Alpha contacts host Beta directly. + + S: MAIL FROM: + R: 250 OK + + S: RCPT TO: + R: 250 OK + + S: RCPT TO: + R: 550 No such user here + + S: RCPT TO: + R: 250 OK + + S: DATA + R: 354 Start mail input; end with . + S: Blah blah blah... + S: ...etc. etc. etc. + S: . + R: 250 OK + + The mail has now been accepted for Jones and Brown. Green did + not have a mailbox at host Beta. + + Example 1 + + ------------------------------------------------------------- + + + + + + + + + + + + + + + + +[Page 6] Postel + + + +RFC 821 August 1982 + Simple Mail Transfer Protocol + + + + 3.2. FORWARDING + + There are some cases where the destination information in the + is incorrect, but the receiver-SMTP knows the + correct destination. In such cases, one of the following replies + should be used to allow the sender to contact the correct + destination. + + 251 User not local; will forward to + + This reply indicates that the receiver-SMTP knows the user's + mailbox is on another host and indicates the correct + forward-path to use in the future. Note that either the + host or user or both may be different. The receiver takes + responsibility for delivering the message. + + 551 User not local; please try + + This reply indicates that the receiver-SMTP knows the user's + mailbox is on another host and indicates the correct + forward-path to use. Note that either the host or user or + both may be different. The receiver refuses to accept mail + for this user, and the sender must either redirect the mail + according to the information provided or return an error + response to the originating user. + + Example 2 illustrates the use of these responses. + + ------------------------------------------------------------- + + Example of Forwarding + + Either + + S: RCPT TO: + R: 251 User not local; will forward to + + Or + + S: RCPT TO: + R: 551 User not local; please try + + Example 2 + + ------------------------------------------------------------- + + + + +Postel [Page 7] + + + +August 1982 RFC 821 +Simple Mail Transfer Protocol + + + + 3.3. VERIFYING AND EXPANDING + + SMTP provides as additional features, commands to verify a user + name or expand a mailing list. This is done with the VRFY and + EXPN commands, which have character string arguments. For the + VRFY command, the string is a user name, and the response may + include the full name of the user and must include the mailbox of + the user. For the EXPN command, the string identifies a mailing + list, and the multiline response may include the full name of the + users and must give the mailboxes on the mailing list. + + "User name" is a fuzzy term and used purposely. If a host + implements the VRFY or EXPN commands then at least local mailboxes + must be recognized as "user names". If a host chooses to + recognize other strings as "user names" that is allowed. + + In some hosts the distinction between a mailing list and an alias + for a single mailbox is a bit fuzzy, since a common data structure + may hold both types of entries, and it is possible to have mailing + lists of one mailbox. If a request is made to verify a mailing + list a positive response can be given if on receipt of a message + so addressed it will be delivered to everyone on the list, + otherwise an error should be reported (e.g., "550 That is a + mailing list, not a user"). If a request is made to expand a user + name a positive response can be formed by returning a list + containing one name, or an error can be reported (e.g., "550 That + is a user name, not a mailing list"). + + In the case of a multiline reply (normal for EXPN) exactly one + mailbox is to be specified on each line of the reply. In the case + of an ambiguous request, for example, "VRFY Smith", where there + are two Smith's the response must be "553 User ambiguous". + + The case of verifying a user name is straightforward as shown in + example 3. + + + + + + + + + + + + + + +[Page 8] Postel + + + +RFC 821 August 1982 + Simple Mail Transfer Protocol + + + + ------------------------------------------------------------- + + Example of Verifying a User Name + + Either + + S: VRFY Smith + R: 250 Fred Smith + + Or + + S: VRFY Smith + R: 251 User not local; will forward to + + Or + + S: VRFY Jones + R: 550 String does not match anything. + + Or + + S: VRFY Jones + R: 551 User not local; please try + + Or + + S: VRFY Gourzenkyinplatz + R: 553 User ambiguous. + + Example 3 + + ------------------------------------------------------------- + + + + + + + + + + + + + + + + + +Postel [Page 9] + + + +August 1982 RFC 821 +Simple Mail Transfer Protocol + + + + The case of expanding a mailbox list requires a multiline reply as + shown in example 4. + + ------------------------------------------------------------- + + Example of Expanding a Mailing List + + Either + + S: EXPN Example-People + R: 250-Jon Postel + R: 250-Fred Fonebone + R: 250-Sam Q. Smith + R: 250-Quincy Smith <@USC-ISIF.ARPA:Q-Smith@ISI-VAXA.ARPA> + R: 250- + R: 250 + + Or + + S: EXPN Executive-Washroom-List + R: 550 Access Denied to You. + + Example 4 + + ------------------------------------------------------------- + + The character string arguments of the VRFY and EXPN commands + cannot be further restricted due to the variety of implementations + of the user name and mailbox list concepts. On some systems it + may be appropriate for the argument of the EXPN command to be a + file name for a file containing a mailing list, but again there is + a variety of file naming conventions in the Internet. + + The VRFY and EXPN commands are not included in the minimum + implementation (Section 4.5.1), and are not required to work + across relays when they are implemented. + + + + + + + + + + + + + +[Page 10] Postel + + + +RFC 821 August 1982 + Simple Mail Transfer Protocol + + + + 3.4. SENDING AND MAILING + + The main purpose of SMTP is to deliver messages to user's + mailboxes. A very similar service provided by some hosts is to + deliver messages to user's terminals (provided the user is active + on the host). The delivery to the user's mailbox is called + "mailing", the delivery to the user's terminal is called + "sending". Because in many hosts the implementation of sending is + nearly identical to the implementation of mailing these two + functions are combined in SMTP. However the sending commands are + not included in the required minimum implementation + (Section 4.5.1). Users should have the ability to control the + writing of messages on their terminals. Most hosts permit the + users to accept or refuse such messages. + + The following three command are defined to support the sending + options. These are used in the mail transaction instead of the + MAIL command and inform the receiver-SMTP of the special semantics + of this transaction: + + SEND FROM: + + The SEND command requires that the mail data be delivered to + the user's terminal. If the user is not active (or not + accepting terminal messages) on the host a 450 reply may + returned to a RCPT command. The mail transaction is + successful if the message is delivered the terminal. + + SOML FROM: + + The Send Or MaiL command requires that the mail data be + delivered to the user's terminal if the user is active (and + accepting terminal messages) on the host. If the user is + not active (or not accepting terminal messages) then the + mail data is entered into the user's mailbox. The mail + transaction is successful if the message is delivered either + to the terminal or the mailbox. + + SAML FROM: + + The Send And MaiL command requires that the mail data be + delivered to the user's terminal if the user is active (and + accepting terminal messages) on the host. In any case the + mail data is entered into the user's mailbox. The mail + transaction is successful if the message is delivered the + mailbox. + + + +Postel [Page 11] + + + +August 1982 RFC 821 +Simple Mail Transfer Protocol + + + + The same reply codes that are used for the MAIL commands are used + for these commands. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +[Page 12] Postel + + + +RFC 821 August 1982 + Simple Mail Transfer Protocol + + + + 3.5. OPENING AND CLOSING + + At the time the transmission channel is opened there is an + exchange to ensure that the hosts are communicating with the hosts + they think they are. + + The following two commands are used in transmission channel + opening and closing: + + HELO + + QUIT + + In the HELO command the host sending the command identifies + itself; the command may be interpreted as saying "Hello, I am + ". + + ------------------------------------------------------------- + + Example of Connection Opening + + R: 220 BBN-UNIX.ARPA Simple Mail Transfer Service Ready + S: HELO USC-ISIF.ARPA + R: 250 BBN-UNIX.ARPA + + Example 5 + + ------------------------------------------------------------- + + ------------------------------------------------------------- + + Example of Connection Closing + + S: QUIT + R: 221 BBN-UNIX.ARPA Service closing transmission channel + + Example 6 + + ------------------------------------------------------------- + + + + + + + + + + +Postel [Page 13] + + + +August 1982 RFC 821 +Simple Mail Transfer Protocol + + + + 3.6. RELAYING + + The forward-path may be a source route of the form + "@ONE,@TWO:JOE@THREE", where ONE, TWO, and THREE are hosts. This + form is used to emphasize the distinction between an address and a + route. The mailbox is an absolute address, and the route is + information about how to get there. The two concepts should not + be confused. + + Conceptually the elements of the forward-path are moved to the + reverse-path as the message is relayed from one server-SMTP to + another. The reverse-path is a reverse source route, (i.e., a + source route from the current location of the message to the + originator of the message). When a server-SMTP deletes its + identifier from the forward-path and inserts it into the + reverse-path, it must use the name it is known by in the + environment it is sending into, not the environment the mail came + from, in case the server-SMTP is known by different names in + different environments. + + If when the message arrives at an SMTP the first element of the + forward-path is not the identifier of that SMTP the element is not + deleted from the forward-path and is used to determine the next + SMTP to send the message to. In any case, the SMTP adds its own + identifier to the reverse-path. + + Using source routing the receiver-SMTP receives mail to be relayed + to another server-SMTP The receiver-SMTP may accept or reject the + task of relaying the mail in the same way it accepts or rejects + mail for a local user. The receiver-SMTP transforms the command + arguments by moving its own identifier from the forward-path to + the beginning of the reverse-path. The receiver-SMTP then becomes + a sender-SMTP, establishes a transmission channel to the next SMTP + in the forward-path, and sends it the mail. + + The first host in the reverse-path should be the host sending the + SMTP commands, and the first host in the forward-path should be + the host receiving the SMTP commands. + + Notice that the forward-path and reverse-path appear in the SMTP + commands and replies, but not necessarily in the message. That + is, there is no need for these paths and especially this syntax to + appear in the "To:" , "From:", "CC:", etc. fields of the message + header. + + If a server-SMTP has accepted the task of relaying the mail and + + + +[Page 14] Postel + + + +RFC 821 August 1982 + Simple Mail Transfer Protocol + + + + later finds that the forward-path is incorrect or that the mail + cannot be delivered for whatever reason, then it must construct an + "undeliverable mail" notification message and send it to the + originator of the undeliverable mail (as indicated by the + reverse-path). + + This notification message must be from the server-SMTP at this + host. Of course, server-SMTPs should not send notification + messages about problems with notification messages. One way to + prevent loops in error reporting is to specify a null reverse-path + in the MAIL command of a notification message. When such a + message is relayed it is permissible to leave the reverse-path + null. A MAIL command with a null reverse-path appears as follows: + + MAIL FROM:<> + + An undeliverable mail notification message is shown in example 7. + This notification is in response to a message originated by JOE at + HOSTW and sent via HOSTX to HOSTY with instructions to relay it on + to HOSTZ. What we see in the example is the transaction between + HOSTY and HOSTX, which is the first step in the return of the + notification message. + + + + + + + + + + + + + + + + + + + + + + + + + + + +Postel [Page 15] + + + +August 1982 RFC 821 +Simple Mail Transfer Protocol + + + + ------------------------------------------------------------- + + Example Undeliverable Mail Notification Message + + S: MAIL FROM:<> + R: 250 ok + S: RCPT TO:<@HOSTX.ARPA:JOE@HOSTW.ARPA> + R: 250 ok + S: DATA + R: 354 send the mail data, end with . + S: Date: 23 Oct 81 11:22:33 + S: From: SMTP@HOSTY.ARPA + S: To: JOE@HOSTW.ARPA + S: Subject: Mail System Problem + S: + S: Sorry JOE, your message to SAM@HOSTZ.ARPA lost. + S: HOSTZ.ARPA said this: + S: "550 No Such User" + S: . + R: 250 ok + + Example 7 + + ------------------------------------------------------------- + + + + + + + + + + + + + + + + + + + + + + + + + +[Page 16] Postel + + + +RFC 821 August 1982 + Simple Mail Transfer Protocol + + + + 3.7. DOMAINS + + Domains are a recently introduced concept in the ARPA Internet + mail system. The use of domains changes the address space from a + flat global space of simple character string host names to a + hierarchically structured rooted tree of global addresses. The + host name is replaced by a domain and host designator which is a + sequence of domain element strings separated by periods with the + understanding that the domain elements are ordered from the most + specific to the most general. + + For example, "USC-ISIF.ARPA", "Fred.Cambridge.UK", and + "PC7.LCS.MIT.ARPA" might be host-and-domain identifiers. + + Whenever domain names are used in SMTP only the official names are + used, the use of nicknames or aliases is not allowed. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Postel [Page 17] + + + +August 1982 RFC 821 +Simple Mail Transfer Protocol + + + + 3.8. CHANGING ROLES + + The TURN command may be used to reverse the roles of the two + programs communicating over the transmission channel. + + If program-A is currently the sender-SMTP and it sends the TURN + command and receives an ok reply (250) then program-A becomes the + receiver-SMTP. + + If program-B is currently the receiver-SMTP and it receives the + TURN command and sends an ok reply (250) then program-B becomes + the sender-SMTP. + + To refuse to change roles the receiver sends the 502 reply. + + Please note that this command is optional. It would not normally + be used in situations where the transmission channel is TCP. + However, when the cost of establishing the transmission channel is + high, this command may be quite useful. For example, this command + may be useful in supporting be mail exchange using the public + switched telephone system as a transmission channel, especially if + some hosts poll other hosts for mail exchanges. + + + + + + + + + + + + + + + + + + + + + + + + + + + +[Page 18] Postel + + + +RFC 821 August 1982 + Simple Mail Transfer Protocol + + + +4. THE SMTP SPECIFICATIONS + + 4.1. SMTP COMMANDS + + 4.1.1. COMMAND SEMANTICS + + The SMTP commands define the mail transfer or the mail system + function requested by the user. SMTP commands are character + strings terminated by . The command codes themselves are + alphabetic characters terminated by if parameters follow + and otherwise. The syntax of mailboxes must conform to + receiver site conventions. The SMTP commands are discussed + below. The SMTP replies are discussed in the Section 4.2. + + A mail transaction involves several data objects which are + communicated as arguments to different commands. The + reverse-path is the argument of the MAIL command, the + forward-path is the argument of the RCPT command, and the mail + data is the argument of the DATA command. These arguments or + data objects must be transmitted and held pending the + confirmation communicated by the end of mail data indication + which finalizes the transaction. The model for this is that + distinct buffers are provided to hold the types of data + objects, that is, there is a reverse-path buffer, a + forward-path buffer, and a mail data buffer. Specific commands + cause information to be appended to a specific buffer, or cause + one or more buffers to be cleared. + + HELLO (HELO) + + This command is used to identify the sender-SMTP to the + receiver-SMTP. The argument field contains the host name of + the sender-SMTP. + + The receiver-SMTP identifies itself to the sender-SMTP in + the connection greeting reply, and in the response to this + command. + + This command and an OK reply to it confirm that both the + sender-SMTP and the receiver-SMTP are in the initial state, + that is, there is no transaction in progress and all state + tables and buffers are cleared. + + + + + + + +Postel [Page 19] + + + +August 1982 RFC 821 +Simple Mail Transfer Protocol + + + + MAIL (MAIL) + + This command is used to initiate a mail transaction in which + the mail data is delivered to one or more mailboxes. The + argument field contains a reverse-path. + + The reverse-path consists of an optional list of hosts and + the sender mailbox. When the list of hosts is present, it + is a "reverse" source route and indicates that the mail was + relayed through each host on the list (the first host in the + list was the most recent relay). This list is used as a + source route to return non-delivery notices to the sender. + As each relay host adds itself to the beginning of the list, + it must use its name as known in the IPCE to which it is + relaying the mail rather than the IPCE from which the mail + came (if they are different). In some types of error + reporting messages (for example, undeliverable mail + notifications) the reverse-path may be null (see Example 7). + + This command clears the reverse-path buffer, the + forward-path buffer, and the mail data buffer; and inserts + the reverse-path information from this command into the + reverse-path buffer. + + RECIPIENT (RCPT) + + This command is used to identify an individual recipient of + the mail data; multiple recipients are specified by multiple + use of this command. + + The forward-path consists of an optional list of hosts and a + required destination mailbox. When the list of hosts is + present, it is a source route and indicates that the mail + must be relayed to the next host on the list. If the + receiver-SMTP does not implement the relay function it may + user the same reply it would for an unknown local user + (550). + + When mail is relayed, the relay host must remove itself from + the beginning forward-path and put itself at the beginning + of the reverse-path. When mail reaches its ultimate + destination (the forward-path contains only a destination + mailbox), the receiver-SMTP inserts it into the destination + mailbox in accordance with its host mail conventions. + + + + + +[Page 20] Postel + + + +RFC 821 August 1982 + Simple Mail Transfer Protocol + + + + For example, mail received at relay host A with arguments + + FROM: + TO:<@HOSTA.ARPA,@HOSTB.ARPA:USERC@HOSTD.ARPA> + + will be relayed on to host B with arguments + + FROM:<@HOSTA.ARPA:USERX@HOSTY.ARPA> + TO:<@HOSTB.ARPA:USERC@HOSTD.ARPA>. + + This command causes its forward-path argument to be appended + to the forward-path buffer. + + DATA (DATA) + + The receiver treats the lines following the command as mail + data from the sender. This command causes the mail data + from this command to be appended to the mail data buffer. + The mail data may contain any of the 128 ASCII character + codes. + + The mail data is terminated by a line containing only a + period, that is the character sequence "." (see + Section 4.5.2 on Transparency). This is the end of mail + data indication. + + The end of mail data indication requires that the receiver + must now process the stored mail transaction information. + This processing consumes the information in the reverse-path + buffer, the forward-path buffer, and the mail data buffer, + and on the completion of this command these buffers are + cleared. If the processing is successful the receiver must + send an OK reply. If the processing fails completely the + receiver must send a failure reply. + + When the receiver-SMTP accepts a message either for relaying + or for final delivery it inserts at the beginning of the + mail data a time stamp line. The time stamp line indicates + the identity of the host that sent the message, and the + identity of the host that received the message (and is + inserting this time stamp), and the date and time the + message was received. Relayed messages will have multiple + time stamp lines. + + When the receiver-SMTP makes the "final delivery" of a + message it inserts at the beginning of the mail data a + + + +Postel [Page 21] + + + +August 1982 RFC 821 +Simple Mail Transfer Protocol + + + + return path line. The return path line preserves the + information in the from the MAIL command. + Here, final delivery means the message leaves the SMTP + world. Normally, this would mean it has been delivered to + the destination user, but in some cases it may be further + processed and transmitted by another mail system. + + It is possible for the mailbox in the return path be + different from the actual sender's mailbox, for example, + if error responses are to be delivered a special error + handling mailbox rather than the message senders. + + The preceding two paragraphs imply that the final mail data + will begin with a return path line, followed by one or more + time stamp lines. These lines will be followed by the mail + data header and body [2]. See Example 8. + + Special mention is needed of the response and further action + required when the processing following the end of mail data + indication is partially successful. This could arise if + after accepting several recipients and the mail data, the + receiver-SMTP finds that the mail data can be successfully + delivered to some of the recipients, but it cannot be to + others (for example, due to mailbox space allocation + problems). In such a situation, the response to the DATA + command must be an OK reply. But, the receiver-SMTP must + compose and send an "undeliverable mail" notification + message to the originator of the message. Either a single + notification which lists all of the recipients that failed + to get the message, or separate notification messages must + be sent for each failed recipient (see Example 7). All + undeliverable mail notification messages are sent using the + MAIL command (even if they result from processing a SEND, + SOML, or SAML command). + + + + + + + + + + + + + + + +[Page 22] Postel + + + +RFC 821 August 1982 + Simple Mail Transfer Protocol + + + + ------------------------------------------------------------- + + Example of Return Path and Received Time Stamps + + Return-Path: <@GHI.ARPA,@DEF.ARPA,@ABC.ARPA:JOE@ABC.ARPA> + Received: from GHI.ARPA by JKL.ARPA ; 27 Oct 81 15:27:39 PST + Received: from DEF.ARPA by GHI.ARPA ; 27 Oct 81 15:15:13 PST + Received: from ABC.ARPA by DEF.ARPA ; 27 Oct 81 15:01:59 PST + Date: 27 Oct 81 15:01:01 PST + From: JOE@ABC.ARPA + Subject: Improved Mailing System Installed + To: SAM@JKL.ARPA + + This is to inform you that ... + + Example 8 + + ------------------------------------------------------------- + + SEND (SEND) + + This command is used to initiate a mail transaction in which + the mail data is delivered to one or more terminals. The + argument field contains a reverse-path. This command is + successful if the message is delivered to a terminal. + + The reverse-path consists of an optional list of hosts and + the sender mailbox. When the list of hosts is present, it + is a "reverse" source route and indicates that the mail was + relayed through each host on the list (the first host in the + list was the most recent relay). This list is used as a + source route to return non-delivery notices to the sender. + As each relay host adds itself to the beginning of the list, + it must use its name as known in the IPCE to which it is + relaying the mail rather than the IPCE from which the mail + came (if they are different). + + This command clears the reverse-path buffer, the + forward-path buffer, and the mail data buffer; and inserts + the reverse-path information from this command into the + reverse-path buffer. + + SEND OR MAIL (SOML) + + This command is used to initiate a mail transaction in which + the mail data is delivered to one or more terminals or + + + +Postel [Page 23] + + + +August 1982 RFC 821 +Simple Mail Transfer Protocol + + + + mailboxes. For each recipient the mail data is delivered to + the recipient's terminal if the recipient is active on the + host (and accepting terminal messages), otherwise to the + recipient's mailbox. The argument field contains a + reverse-path. This command is successful if the message is + delivered to a terminal or the mailbox. + + The reverse-path consists of an optional list of hosts and + the sender mailbox. When the list of hosts is present, it + is a "reverse" source route and indicates that the mail was + relayed through each host on the list (the first host in the + list was the most recent relay). This list is used as a + source route to return non-delivery notices to the sender. + As each relay host adds itself to the beginning of the list, + it must use its name as known in the IPCE to which it is + relaying the mail rather than the IPCE from which the mail + came (if they are different). + + This command clears the reverse-path buffer, the + forward-path buffer, and the mail data buffer; and inserts + the reverse-path information from this command into the + reverse-path buffer. + + SEND AND MAIL (SAML) + + This command is used to initiate a mail transaction in which + the mail data is delivered to one or more terminals and + mailboxes. For each recipient the mail data is delivered to + the recipient's terminal if the recipient is active on the + host (and accepting terminal messages), and for all + recipients to the recipient's mailbox. The argument field + contains a reverse-path. This command is successful if the + message is delivered to the mailbox. + + The reverse-path consists of an optional list of hosts and + the sender mailbox. When the list of hosts is present, it + is a "reverse" source route and indicates that the mail was + relayed through each host on the list (the first host in the + list was the most recent relay). This list is used as a + source route to return non-delivery notices to the sender. + As each relay host adds itself to the beginning of the list, + it must use its name as known in the IPCE to which it is + relaying the mail rather than the IPCE from which the mail + came (if they are different). + + This command clears the reverse-path buffer, the + + + +[Page 24] Postel + + + +RFC 821 August 1982 + Simple Mail Transfer Protocol + + + + forward-path buffer, and the mail data buffer; and inserts + the reverse-path information from this command into the + reverse-path buffer. + + RESET (RSET) + + This command specifies that the current mail transaction is + to be aborted. Any stored sender, recipients, and mail data + must be discarded, and all buffers and state tables cleared. + The receiver must send an OK reply. + + VERIFY (VRFY) + + This command asks the receiver to confirm that the argument + identifies a user. If it is a user name, the full name of + the user (if known) and the fully specified mailbox are + returned. + + This command has no effect on any of the reverse-path + buffer, the forward-path buffer, or the mail data buffer. + + EXPAND (EXPN) + + This command asks the receiver to confirm that the argument + identifies a mailing list, and if so, to return the + membership of that list. The full name of the users (if + known) and the fully specified mailboxes are returned in a + multiline reply. + + This command has no effect on any of the reverse-path + buffer, the forward-path buffer, or the mail data buffer. + + HELP (HELP) + + This command causes the receiver to send helpful information + to the sender of the HELP command. The command may take an + argument (e.g., any command name) and return more specific + information as a response. + + This command has no effect on any of the reverse-path + buffer, the forward-path buffer, or the mail data buffer. + + + + + + + + +Postel [Page 25] + + + +August 1982 RFC 821 +Simple Mail Transfer Protocol + + + + NOOP (NOOP) + + This command does not affect any parameters or previously + entered commands. It specifies no action other than that + the receiver send an OK reply. + + This command has no effect on any of the reverse-path + buffer, the forward-path buffer, or the mail data buffer. + + QUIT (QUIT) + + This command specifies that the receiver must send an OK + reply, and then close the transmission channel. + + The receiver should not close the transmission channel until + it receives and replies to a QUIT command (even if there was + an error). The sender should not close the transmission + channel until it send a QUIT command and receives the reply + (even if there was an error response to a previous command). + If the connection is closed prematurely the receiver should + act as if a RSET command had been received (canceling any + pending transaction, but not undoing any previously + completed transaction), the sender should act as if the + command or transaction in progress had received a temporary + error (4xx). + + TURN (TURN) + + This command specifies that the receiver must either (1) + send an OK reply and then take on the role of the + sender-SMTP, or (2) send a refusal reply and retain the role + of the receiver-SMTP. + + If program-A is currently the sender-SMTP and it sends the + TURN command and receives an OK reply (250) then program-A + becomes the receiver-SMTP. Program-A is then in the initial + state as if the transmission channel just opened, and it + then sends the 220 service ready greeting. + + If program-B is currently the receiver-SMTP and it receives + the TURN command and sends an OK reply (250) then program-B + becomes the sender-SMTP. Program-B is then in the initial + state as if the transmission channel just opened, and it + then expects to receive the 220 service ready greeting. + + To refuse to change roles the receiver sends the 502 reply. + + + +[Page 26] Postel + + + +RFC 821 August 1982 + Simple Mail Transfer Protocol + + + + There are restrictions on the order in which these command may + be used. + + The first command in a session must be the HELO command. + The HELO command may be used later in a session as well. If + the HELO command argument is not acceptable a 501 failure + reply must be returned and the receiver-SMTP must stay in + the same state. + + The NOOP, HELP, EXPN, and VRFY commands can be used at any + time during a session. + + The MAIL, SEND, SOML, or SAML commands begin a mail + transaction. Once started a mail transaction consists of + one of the transaction beginning commands, one or more RCPT + commands, and a DATA command, in that order. A mail + transaction may be aborted by the RSET command. There may + be zero or more transactions in a session. + + If the transaction beginning command argument is not + acceptable a 501 failure reply must be returned and the + receiver-SMTP must stay in the same state. If the commands + in a transaction are out of order a 503 failure reply must + be returned and the receiver-SMTP must stay in the same + state. + + The last command in a session must be the QUIT command. The + QUIT command can not be used at any other time in a session. + + 4.1.2. COMMAND SYNTAX + + The commands consist of a command code followed by an argument + field. Command codes are four alphabetic characters. Upper + and lower case alphabetic characters are to be treated + identically. Thus, any of the following may represent the mail + command: + + MAIL Mail mail MaIl mAIl + + This also applies to any symbols representing parameter values, + such as "TO" or "to" for the forward-path. Command codes and + the argument fields are separated by one or more spaces. + However, within the reverse-path and forward-path arguments + case is important. In particular, in some hosts the user + "smith" is different from the user "Smith". + + + + +Postel [Page 27] + + + +August 1982 RFC 821 +Simple Mail Transfer Protocol + + + + The argument field consists of a variable length character + string ending with the character sequence . The receiver + is to take no action until this sequence is received. + + Square brackets denote an optional argument field. If the + option is not taken, the appropriate default is implied. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +[Page 28] Postel + + + +RFC 821 August 1982 + Simple Mail Transfer Protocol + + + + The following are the SMTP commands: + + HELO + + MAIL FROM: + + RCPT TO: + + DATA + + RSET + + SEND FROM: + + SOML FROM: + + SAML FROM: + + VRFY + + EXPN + + HELP [ ] + + NOOP + + QUIT + + TURN + + + + + + + + + + + + + + + + + + + + +Postel [Page 29] + + + +August 1982 RFC 821 +Simple Mail Transfer Protocol + + + + The syntax of the above argument fields (using BNF notation + where applicable) is given below. The "..." notation indicates + that a field may be repeated one or more times. + + ::= + + ::= + + ::= "<" [ ":" ] ">" + + ::= | "," + + ::= "@" + + ::= | "." + + ::= | "#" | "[" "]" + + ::= "@" + + ::= | + + ::=
    + + ::= | + + ::= | + + ::= | | "-" + + ::= | "." + + ::= | + + ::= """ """ + + ::= "\" | "\" | | + + ::= | "\" + + ::= "." "." "." + + ::= | + + ::= + + + + +[Page 30] Postel + + + +RFC 821 August 1982 + Simple Mail Transfer Protocol + + + + ::= the carriage return character (ASCII code 13) + + ::= the line feed character (ASCII code 10) + + ::= the space character (ASCII code 32) + + ::= one, two, or three digits representing a decimal + integer value in the range 0 through 255 + + ::= any one of the 52 alphabetic characters A through Z + in upper case and a through z in lower case + + ::= any one of the 128 ASCII characters, but not any + or + + ::= any one of the ten digits 0 through 9 + + ::= any one of the 128 ASCII characters except , + , quote ("), or backslash (\) + + ::= any one of the 128 ASCII characters (no exceptions) + + ::= "<" | ">" | "(" | ")" | "[" | "]" | "\" | "." + | "," | ";" | ":" | "@" """ | the control + characters (ASCII codes 0 through 31 inclusive and + 127) + + Note that the backslash, "\", is a quote character, which is + used to indicate that the next character is to be used + literally (instead of its normal interpretation). For example, + "Joe\,Smith" could be used to indicate a single nine character + user field with comma being the fourth character of the field. + + Hosts are generally known by names which are translated to + addresses in each host. Note that the name elements of domains + are the official names -- no use of nicknames or aliases is + allowed. + + Sometimes a host is not known to the translation function and + communication is blocked. To bypass this barrier two numeric + forms are also allowed for host "names". One form is a decimal + integer prefixed by a pound sign, "#", which indicates the + number is the address of the host. Another form is four small + decimal integers separated by dots and enclosed by brackets, + e.g., "[123.255.37.2]", which indicates a 32-bit ARPA Internet + Address in four 8-bit fields. + + + +Postel [Page 31] + + + +August 1982 RFC 821 +Simple Mail Transfer Protocol + + + + The time stamp line and the return path line are formally + defined as follows: + + ::= "Return-Path:" + + ::= "Received:" + + ::= ";" + + + ::= "FROM" + + ::= "BY" + + ::= [] [] [] [] + + ::= "VIA" + + ::= "WITH" + + ::= "ID" + + ::= "FOR" + + ::= The standard names for links are registered with + the Network Information Center. + + ::= The standard names for protocols are + registered with the Network Information Center. + + ::=
    ::= the one or two decimal integer day of the month in + the range 1 to 31. + + ::= "JAN" | "FEB" | "MAR" | "APR" | "MAY" | "JUN" | + "JUL" | "AUG" | "SEP" | "OCT" | "NOV" | "DEC" + + ::= the two decimal integer year of the century in the + range 00 to 99. + + + + + +[Page 32] Postel + + + +RFC 821 August 1982 + Simple Mail Transfer Protocol + + + + ::= the two decimal integer hour of the day in the + range 00 to 24. + + ::= the two decimal integer minute of the hour in the + range 00 to 59. + + ::= the two decimal integer second of the minute in the + range 00 to 59. + + ::= "UT" for Universal Time (the default) or other + time zone designator (as in [2]). + + + + ------------------------------------------------------------- + + Return Path Example + + Return-Path: <@CHARLIE.ARPA,@BAKER.ARPA:JOE@ABLE.ARPA> + + Example 9 + + ------------------------------------------------------------- + + ------------------------------------------------------------- + + Time Stamp Line Example + + Received: FROM ABC.ARPA BY XYZ.ARPA ; 22 OCT 81 09:23:59 PDT + + Received: from ABC.ARPA by XYZ.ARPA via TELENET with X25 + id M12345 for Smith@PDQ.ARPA ; 22 OCT 81 09:23:59 PDT + + Example 10 + + ------------------------------------------------------------- + + + + + + + + + + + + + +Postel [Page 33] + + + +August 1982 RFC 821 +Simple Mail Transfer Protocol + + + + 4.2. SMTP REPLIES + + Replies to SMTP commands are devised to ensure the synchronization + of requests and actions in the process of mail transfer, and to + guarantee that the sender-SMTP always knows the state of the + receiver-SMTP. Every command must generate exactly one reply. + + The details of the command-reply sequence are made explicit in + Section 5.3 on Sequencing and Section 5.4 State Diagrams. + + An SMTP reply consists of a three digit number (transmitted as + three alphanumeric characters) followed by some text. The number + is intended for use by automata to determine what state to enter + next; the text is meant for the human user. It is intended that + the three digits contain enough encoded information that the + sender-SMTP need not examine the text and may either discard it or + pass it on to the user, as appropriate. In particular, the text + may be receiver-dependent and context dependent, so there are + likely to be varying texts for each reply code. A discussion of + the theory of reply codes is given in Appendix E. Formally, a + reply is defined to be the sequence: a three-digit code, , + one line of text, and , or a multiline reply (as defined in + Appendix E). Only the EXPN and HELP commands are expected to + result in multiline replies in normal circumstances, however + multiline replies are allowed for any command. + + + + + + + + + + + + + + + + + + + + + + + + +[Page 34] Postel + + + +RFC 821 August 1982 + Simple Mail Transfer Protocol + + + + 4.2.1. REPLY CODES BY FUNCTION GROUPS + + 500 Syntax error, command unrecognized + [This may include errors such as command line too long] + 501 Syntax error in parameters or arguments + 502 Command not implemented + 503 Bad sequence of commands + 504 Command parameter not implemented + + 211 System status, or system help reply + 214 Help message + [Information on how to use the receiver or the meaning of a + particular non-standard command; this reply is useful only + to the human user] + + 220 Service ready + 221 Service closing transmission channel + 421 Service not available, + closing transmission channel + [This may be a reply to any command if the service knows it + must shut down] + + 250 Requested mail action okay, completed + 251 User not local; will forward to + 450 Requested mail action not taken: mailbox unavailable + [E.g., mailbox busy] + 550 Requested action not taken: mailbox unavailable + [E.g., mailbox not found, no access] + 451 Requested action aborted: error in processing + 551 User not local; please try + 452 Requested action not taken: insufficient system storage + 552 Requested mail action aborted: exceeded storage allocation + 553 Requested action not taken: mailbox name not allowed + [E.g., mailbox syntax incorrect] + 354 Start mail input; end with . + 554 Transaction failed + + + + + + + + + + + + + +Postel [Page 35] + + + +August 1982 RFC 821 +Simple Mail Transfer Protocol + + + + 4.2.2. NUMERIC ORDER LIST OF REPLY CODES + + 211 System status, or system help reply + 214 Help message + [Information on how to use the receiver or the meaning of a + particular non-standard command; this reply is useful only + to the human user] + 220 Service ready + 221 Service closing transmission channel + 250 Requested mail action okay, completed + 251 User not local; will forward to + + 354 Start mail input; end with . + + 421 Service not available, + closing transmission channel + [This may be a reply to any command if the service knows it + must shut down] + 450 Requested mail action not taken: mailbox unavailable + [E.g., mailbox busy] + 451 Requested action aborted: local error in processing + 452 Requested action not taken: insufficient system storage + + 500 Syntax error, command unrecognized + [This may include errors such as command line too long] + 501 Syntax error in parameters or arguments + 502 Command not implemented + 503 Bad sequence of commands + 504 Command parameter not implemented + 550 Requested action not taken: mailbox unavailable + [E.g., mailbox not found, no access] + 551 User not local; please try + 552 Requested mail action aborted: exceeded storage allocation + 553 Requested action not taken: mailbox name not allowed + [E.g., mailbox syntax incorrect] + 554 Transaction failed + + + + + + + + + + + + + +[Page 36] Postel + + + +RFC 821 August 1982 + Simple Mail Transfer Protocol + + + + 4.3. SEQUENCING OF COMMANDS AND REPLIES + + The communication between the sender and receiver is intended to + be an alternating dialogue, controlled by the sender. As such, + the sender issues a command and the receiver responds with a + reply. The sender must wait for this response before sending + further commands. + + One important reply is the connection greeting. Normally, a + receiver will send a 220 "Service ready" reply when the connection + is completed. The sender should wait for this greeting message + before sending any commands. + + Note: all the greeting type replies have the official name of + the server host as the first word following the reply code. + + For example, + + 220 USC-ISIF.ARPA Service ready + + The table below lists alternative success and failure replies for + each command. These must be strictly adhered to; a receiver may + substitute text in the replies, but the meaning and action implied + by the code numbers and by the specific command reply sequence + cannot be altered. + + COMMAND-REPLY SEQUENCES + + Each command is listed with its possible replies. The prefixes + used before the possible replies are "P" for preliminary (not + used in SMTP), "I" for intermediate, "S" for success, "F" for + failure, and "E" for error. The 421 reply (service not + available, closing transmission channel) may be given to any + command if the SMTP-receiver knows it must shut down. This + listing forms the basis for the State Diagrams in Section 4.4. + + CONNECTION ESTABLISHMENT + S: 220 + F: 421 + HELO + S: 250 + E: 500, 501, 504, 421 + MAIL + S: 250 + F: 552, 451, 452 + E: 500, 501, 421 + + + +Postel [Page 37] + + + +August 1982 RFC 821 +Simple Mail Transfer Protocol + + + + RCPT + S: 250, 251 + F: 550, 551, 552, 553, 450, 451, 452 + E: 500, 501, 503, 421 + DATA + I: 354 -> data -> S: 250 + F: 552, 554, 451, 452 + F: 451, 554 + E: 500, 501, 503, 421 + RSET + S: 250 + E: 500, 501, 504, 421 + SEND + S: 250 + F: 552, 451, 452 + E: 500, 501, 502, 421 + SOML + S: 250 + F: 552, 451, 452 + E: 500, 501, 502, 421 + SAML + S: 250 + F: 552, 451, 452 + E: 500, 501, 502, 421 + VRFY + S: 250, 251 + F: 550, 551, 553 + E: 500, 501, 502, 504, 421 + EXPN + S: 250 + F: 550 + E: 500, 501, 502, 504, 421 + HELP + S: 211, 214 + E: 500, 501, 502, 504, 421 + NOOP + S: 250 + E: 500, 421 + QUIT + S: 221 + E: 500 + TURN + S: 250 + F: 502 + E: 500, 503 + + + + +[Page 38] Postel + + + +RFC 821 August 1982 + Simple Mail Transfer Protocol + + + + 4.4. STATE DIAGRAMS + + Following are state diagrams for a simple-minded SMTP + implementation. Only the first digit of the reply codes is used. + There is one state diagram for each group of SMTP commands. The + command groupings were determined by constructing a model for each + command and then collecting together the commands with + structurally identical models. + + For each command there are three possible outcomes: "success" + (S), "failure" (F), and "error" (E). In the state diagrams below + we use the symbol B for "begin", and the symbol W for "wait for + reply". + + First, the diagram that represents most of the SMTP commands: + + + 1,3 +---+ + ----------->| E | + | +---+ + | + +---+ cmd +---+ 2 +---+ + | B |---------->| W |---------->| S | + +---+ +---+ +---+ + | + | 4,5 +---+ + ----------->| F | + +---+ + + + This diagram models the commands: + + HELO, MAIL, RCPT, RSET, SEND, SOML, SAML, VRFY, EXPN, HELP, + NOOP, QUIT, TURN. + + + + + + + + + + + + + + + +Postel [Page 39] + + + +August 1982 RFC 821 +Simple Mail Transfer Protocol + + + + A more complex diagram models the DATA command: + + + +---+ DATA +---+ 1,2 +---+ + | B |---------->| W |-------------------->| E | + +---+ +---+ ------------>+---+ + 3| |4,5 | + | | | + -------------- ----- | + | | | +---+ + | ---------- -------->| S | + | | | | +---+ + | | ------------ + | | | | + V 1,3| |2 | + +---+ data +---+ --------------->+---+ + | |---------->| W | | F | + +---+ +---+-------------------->+---+ + 4,5 + + + Note that the "data" here is a series of lines sent from the + sender to the receiver with no response expected until the last + line is sent. + + + + + + + + + + + + + + + + + + + + + + + + + +[Page 40] Postel + + + +RFC 821 August 1982 + Simple Mail Transfer Protocol + + + + 4.5. DETAILS + + 4.5.1. MINIMUM IMPLEMENTATION + + In order to make SMTP workable, the following minimum + implementation is required for all receivers: + + COMMANDS -- HELO + MAIL + RCPT + DATA + RSET + NOOP + QUIT + + 4.5.2. TRANSPARENCY + + Without some provision for data transparency the character + sequence "." ends the mail text and cannot be sent + by the user. In general, users are not aware of such + "forbidden" sequences. To allow all user composed text to be + transmitted transparently the following procedures are used. + + 1. Before sending a line of mail text the sender-SMTP checks + the first character of the line. If it is a period, one + additional period is inserted at the beginning of the line. + + 2. When a line of mail text is received by the receiver-SMTP + it checks the line. If the line is composed of a single + period it is the end of mail. If the first character is a + period and there are other characters on the line, the first + character is deleted. + + The mail data may contain any of the 128 ASCII characters. All + characters are to be delivered to the recipient's mailbox + including format effectors and other control characters. If + the transmission channel provides an 8-bit byte (octets) data + stream, the 7-bit ASCII codes are transmitted right justified + in the octets with the high order bits cleared to zero. + + In some systems it may be necessary to transform the data as + it is received and stored. This may be necessary for hosts + that use a different character set than ASCII as their local + character set, or that store data in records rather than + + + + + +Postel [Page 41] + + + +August 1982 RFC 821 +Simple Mail Transfer Protocol + + + + strings. If such transforms are necessary, they must be + reversible -- especially if such transforms are applied to + mail being relayed. + + 4.5.3. SIZES + + There are several objects that have required minimum maximum + sizes. That is, every implementation must be able to receive + objects of at least these sizes, but must not send objects + larger than these sizes. + + + **************************************************** + * * + * TO THE MAXIMUM EXTENT POSSIBLE, IMPLEMENTATION * + * TECHNIQUES WHICH IMPOSE NO LIMITS ON THE LENGTH * + * OF THESE OBJECTS SHOULD BE USED. * + * * + **************************************************** + + user + + The maximum total length of a user name is 64 characters. + + domain + + The maximum total length of a domain name or number is 64 + characters. + + path + + The maximum total length of a reverse-path or + forward-path is 256 characters (including the punctuation + and element separators). + + command line + + The maximum total length of a command line including the + command word and the is 512 characters. + + reply line + + The maximum total length of a reply line including the + reply code and the is 512 characters. + + + + + +[Page 42] Postel + + + +RFC 821 August 1982 + Simple Mail Transfer Protocol + + + + text line + + The maximum total length of a text line including the + is 1000 characters (but not counting the leading + dot duplicated for transparency). + + recipients buffer + + The maximum total number of recipients that must be + buffered is 100 recipients. + + + **************************************************** + * * + * TO THE MAXIMUM EXTENT POSSIBLE, IMPLEMENTATION * + * TECHNIQUES WHICH IMPOSE NO LIMITS ON THE LENGTH * + * OF THESE OBJECTS SHOULD BE USED. * + * * + **************************************************** + + Errors due to exceeding these limits may be reported by using + the reply codes, for example: + + 500 Line too long. + + 501 Path too long + + 552 Too many recipients. + + 552 Too much mail data. + + + + + + + + + + + + + + + + + + + +Postel [Page 43] + + + +August 1982 RFC 821 +Simple Mail Transfer Protocol + + + +APPENDIX A + + TCP Transport service + + The Transmission Control Protocol [3] is used in the ARPA + Internet, and in any network following the US DoD standards for + internetwork protocols. + + Connection Establishment + + The SMTP transmission channel is a TCP connection established + between the sender process port U and the receiver process port + L. This single full duplex connection is used as the + transmission channel. This protocol is assigned the service + port 25 (31 octal), that is L=25. + + Data Transfer + + The TCP connection supports the transmission of 8-bit bytes. + The SMTP data is 7-bit ASCII characters. Each character is + transmitted as an 8-bit byte with the high-order bit cleared to + zero. + + + + + + + + + + + + + + + + + + + + + + + + + + + +[Page 44] Postel + + + +RFC 821 August 1982 + Simple Mail Transfer Protocol + + + +APPENDIX B + + NCP Transport service + + The ARPANET Host-to-Host Protocol [4] (implemented by the Network + Control Program) may be used in the ARPANET. + + Connection Establishment + + The SMTP transmission channel is established via NCP between + the sender process socket U and receiver process socket L. The + Initial Connection Protocol [5] is followed resulting in a pair + of simplex connections. This pair of connections is used as + the transmission channel. This protocol is assigned the + contact socket 25 (31 octal), that is L=25. + + Data Transfer + + The NCP data connections are established in 8-bit byte mode. + The SMTP data is 7-bit ASCII characters. Each character is + transmitted as an 8-bit byte with the high-order bit cleared to + zero. + + + + + + + + + + + + + + + + + + + + + + + + + + + +Postel [Page 45] + + + +August 1982 RFC 821 +Simple Mail Transfer Protocol + + + +APPENDIX C + + NITS + + The Network Independent Transport Service [6] may be used. + + Connection Establishment + + The SMTP transmission channel is established via NITS between + the sender process and receiver process. The sender process + executes the CONNECT primitive, and the waiting receiver + process executes the ACCEPT primitive. + + Data Transfer + + The NITS connection supports the transmission of 8-bit bytes. + The SMTP data is 7-bit ASCII characters. Each character is + transmitted as an 8-bit byte with the high-order bit cleared to + zero. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +[Page 46] Postel + + + +RFC 821 August 1982 + Simple Mail Transfer Protocol + + + +APPENDIX D + + X.25 Transport service + + It may be possible to use the X.25 service [7] as provided by the + Public Data Networks directly, however, it is suggested that a + reliable end-to-end protocol such as TCP be used on top of X.25 + connections. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Postel [Page 47] + + + +August 1982 RFC 821 +Simple Mail Transfer Protocol + + + +APPENDIX E + + Theory of Reply Codes + + The three digits of the reply each have a special significance. + The first digit denotes whether the response is good, bad or + incomplete. An unsophisticated sender-SMTP will be able to + determine its next action (proceed as planned, redo, retrench, + etc.) by simply examining this first digit. A sender-SMTP that + wants to know approximately what kind of error occurred (e.g., + mail system error, command syntax error) may examine the second + digit, reserving the third digit for the finest gradation of + information. + + There are five values for the first digit of the reply code: + + 1yz Positive Preliminary reply + + The command has been accepted, but the requested action + is being held in abeyance, pending confirmation of the + information in this reply. The sender-SMTP should send + another command specifying whether to continue or abort + the action. + + [Note: SMTP does not have any commands that allow this + type of reply, and so does not have the continue or + abort commands.] + + 2yz Positive Completion reply + + The requested action has been successfully completed. A + new request may be initiated. + + 3yz Positive Intermediate reply + + The command has been accepted, but the requested action + is being held in abeyance, pending receipt of further + information. The sender-SMTP should send another command + specifying this information. This reply is used in + command sequence groups. + + 4yz Transient Negative Completion reply + + The command was not accepted and the requested action did + not occur. However, the error condition is temporary and + the action may be requested again. The sender should + + + +[Page 48] Postel + + + +RFC 821 August 1982 + Simple Mail Transfer Protocol + + + + return to the beginning of the command sequence (if any). + It is difficult to assign a meaning to "transient" when + two different sites (receiver- and sender- SMTPs) must + agree on the interpretation. Each reply in this category + might have a different time value, but the sender-SMTP is + encouraged to try again. A rule of thumb to determine if + a reply fits into the 4yz or the 5yz category (see below) + is that replies are 4yz if they can be repeated without + any change in command form or in properties of the sender + or receiver. (E.g., the command is repeated identically + and the receiver does not put up a new implementation.) + + 5yz Permanent Negative Completion reply + + The command was not accepted and the requested action did + not occur. The sender-SMTP is discouraged from repeating + the exact request (in the same sequence). Even some + "permanent" error conditions can be corrected, so the + human user may want to direct the sender-SMTP to + reinitiate the command sequence by direct action at some + point in the future (e.g., after the spelling has been + changed, or the user has altered the account status). + + The second digit encodes responses in specific categories: + + x0z Syntax -- These replies refer to syntax errors, + syntactically correct commands that don't fit any + functional category, and unimplemented or superfluous + commands. + + x1z Information -- These are replies to requests for + information, such as status or help. + + x2z Connections -- These are replies referring to the + transmission channel. + + x3z Unspecified as yet. + + x4z Unspecified as yet. + + x5z Mail system -- These replies indicate the status of + the receiver mail system vis-a-vis the requested + transfer or other mail system action. + + The third digit gives a finer gradation of meaning in each + category specified by the second digit. The list of replies + + + +Postel [Page 49] + + + +August 1982 RFC 821 +Simple Mail Transfer Protocol + + + + illustrates this. Each reply text is recommended rather than + mandatory, and may even change according to the command with + which it is associated. On the other hand, the reply codes + must strictly follow the specifications in this section. + Receiver implementations should not invent new codes for + slightly different situations from the ones described here, but + rather adapt codes already defined. + + For example, a command such as NOOP whose successful execution + does not offer the sender-SMTP any new information will return + a 250 reply. The response is 502 when the command requests an + unimplemented non-site-specific action. A refinement of that + is the 504 reply for a command that is implemented, but that + requests an unimplemented parameter. + + The reply text may be longer than a single line; in these cases + the complete text must be marked so the sender-SMTP knows when it + can stop reading the reply. This requires a special format to + indicate a multiple line reply. + + The format for multiline replies requires that every line, + except the last, begin with the reply code, followed + immediately by a hyphen, "-" (also known as minus), followed by + text. The last line will begin with the reply code, followed + immediately by , optionally some text, and . + + For example: + 123-First line + 123-Second line + 123-234 text beginning with numbers + 123 The last line + + In many cases the sender-SMTP then simply needs to search for + the reply code followed by at the beginning of a line, and + ignore all preceding lines. In a few cases, there is important + data for the sender in the reply "text". The sender will know + these cases from the current context. + + + + + + + + + + + + +[Page 50] Postel + + + +RFC 821 August 1982 + Simple Mail Transfer Protocol + + + +APPENDIX F + + Scenarios + + This section presents complete scenarios of several types of SMTP + sessions. + + A Typical SMTP Transaction Scenario + + This SMTP example shows mail sent by Smith at host USC-ISIF, to + Jones, Green, and Brown at host BBN-UNIX. Here we assume that + host USC-ISIF contacts host BBN-UNIX directly. The mail is + accepted for Jones and Brown. Green does not have a mailbox at + host BBN-UNIX. + + ------------------------------------------------------------- + + R: 220 BBN-UNIX.ARPA Simple Mail Transfer Service Ready + S: HELO USC-ISIF.ARPA + R: 250 BBN-UNIX.ARPA + + S: MAIL FROM: + R: 250 OK + + S: RCPT TO: + R: 250 OK + + S: RCPT TO: + R: 550 No such user here + + S: RCPT TO: + R: 250 OK + + S: DATA + R: 354 Start mail input; end with . + S: Blah blah blah... + S: ...etc. etc. etc. + S: . + R: 250 OK + + S: QUIT + R: 221 BBN-UNIX.ARPA Service closing transmission channel + + Scenario 1 + + ------------------------------------------------------------- + + + +Postel [Page 51] + + + +August 1982 RFC 821 +Simple Mail Transfer Protocol + + + + Aborted SMTP Transaction Scenario + + ------------------------------------------------------------- + + R: 220 MIT-Multics.ARPA Simple Mail Transfer Service Ready + S: HELO ISI-VAXA.ARPA + R: 250 MIT-Multics.ARPA + + S: MAIL FROM: + R: 250 OK + + S: RCPT TO: + R: 250 OK + + S: RCPT TO: + R: 550 No such user here + + S: RSET + R: 250 OK + + S: QUIT + R: 221 MIT-Multics.ARPA Service closing transmission channel + + Scenario 2 + + ------------------------------------------------------------- + + + + + + + + + + + + + + + + + + + + + + + +[Page 52] Postel + + + +RFC 821 August 1982 + Simple Mail Transfer Protocol + + + + Relayed Mail Scenario + + ------------------------------------------------------------- + + Step 1 -- Source Host to Relay Host + + R: 220 USC-ISIE.ARPA Simple Mail Transfer Service Ready + S: HELO MIT-AI.ARPA + R: 250 USC-ISIE.ARPA + + S: MAIL FROM: + R: 250 OK + + S: RCPT TO:<@USC-ISIE.ARPA:Jones@BBN-VAX.ARPA> + R: 250 OK + + S: DATA + R: 354 Start mail input; end with . + S: Date: 2 Nov 81 22:33:44 + S: From: John Q. Public + S: Subject: The Next Meeting of the Board + S: To: Jones@BBN-Vax.ARPA + S: + S: Bill: + S: The next meeting of the board of directors will be + S: on Tuesday. + S: John. + S: . + R: 250 OK + + S: QUIT + R: 221 USC-ISIE.ARPA Service closing transmission channel + + + + + + + + + + + + + + + + + +Postel [Page 53] + + + +August 1982 RFC 821 +Simple Mail Transfer Protocol + + + + Step 2 -- Relay Host to Destination Host + + R: 220 BBN-VAX.ARPA Simple Mail Transfer Service Ready + S: HELO USC-ISIE.ARPA + R: 250 BBN-VAX.ARPA + + S: MAIL FROM:<@USC-ISIE.ARPA:JQP@MIT-AI.ARPA> + R: 250 OK + + S: RCPT TO: + R: 250 OK + + S: DATA + R: 354 Start mail input; end with . + S: Received: from MIT-AI.ARPA by USC-ISIE.ARPA ; + 2 Nov 81 22:40:10 UT + S: Date: 2 Nov 81 22:33:44 + S: From: John Q. Public + S: Subject: The Next Meeting of the Board + S: To: Jones@BBN-Vax.ARPA + S: + S: Bill: + S: The next meeting of the board of directors will be + S: on Tuesday. + S: John. + S: . + R: 250 OK + + S: QUIT + R: 221 USC-ISIE.ARPA Service closing transmission channel + + Scenario 3 + + ------------------------------------------------------------- + + + + + + + + + + + + + + + +[Page 54] Postel + + + +RFC 821 August 1982 + Simple Mail Transfer Protocol + + + + Verifying and Sending Scenario + + ------------------------------------------------------------- + + R: 220 SU-SCORE.ARPA Simple Mail Transfer Service Ready + S: HELO MIT-MC.ARPA + R: 250 SU-SCORE.ARPA + + S: VRFY Crispin + R: 250 Mark Crispin + + S: SEND FROM: + R: 250 OK + + S: RCPT TO: + R: 250 OK + + S: DATA + R: 354 Start mail input; end with . + S: Blah blah blah... + S: ...etc. etc. etc. + S: . + R: 250 OK + + S: QUIT + R: 221 SU-SCORE.ARPA Service closing transmission channel + + Scenario 4 + + ------------------------------------------------------------- + + + + + + + + + + + + + + + + + + + +Postel [Page 55] + + + +August 1982 RFC 821 +Simple Mail Transfer Protocol + + + + Sending and Mailing Scenarios + + First the user's name is verified, then an attempt is made to + send to the user's terminal. When that fails, the messages is + mailed to the user's mailbox. + + ------------------------------------------------------------- + + R: 220 SU-SCORE.ARPA Simple Mail Transfer Service Ready + S: HELO MIT-MC.ARPA + R: 250 SU-SCORE.ARPA + + S: VRFY Crispin + R: 250 Mark Crispin + + S: SEND FROM: + R: 250 OK + + S: RCPT TO: + R: 450 User not active now + + S: RSET + R: 250 OK + + S: MAIL FROM: + R: 250 OK + + S: RCPT TO: + R: 250 OK + + S: DATA + R: 354 Start mail input; end with . + S: Blah blah blah... + S: ...etc. etc. etc. + S: . + R: 250 OK + + S: QUIT + R: 221 SU-SCORE.ARPA Service closing transmission channel + + Scenario 5 + + ------------------------------------------------------------- + + + + + + +[Page 56] Postel + + + +RFC 821 August 1982 + Simple Mail Transfer Protocol + + + + Doing the preceding scenario more efficiently. + + ------------------------------------------------------------- + + R: 220 SU-SCORE.ARPA Simple Mail Transfer Service Ready + S: HELO MIT-MC.ARPA + R: 250 SU-SCORE.ARPA + + S: VRFY Crispin + R: 250 Mark Crispin + + S: SOML FROM: + R: 250 OK + + S: RCPT TO: + R: 250 User not active now, so will do mail. + + S: DATA + R: 354 Start mail input; end with . + S: Blah blah blah... + S: ...etc. etc. etc. + S: . + R: 250 OK + + S: QUIT + R: 221 SU-SCORE.ARPA Service closing transmission channel + + Scenario 6 + + ------------------------------------------------------------- + + + + + + + + + + + + + + + + + + + +Postel [Page 57] + + + +August 1982 RFC 821 +Simple Mail Transfer Protocol + + + + Mailing List Scenario + + First each of two mailing lists are expanded in separate sessions + with different hosts. Then the message is sent to everyone that + appeared on either list (but no duplicates) via a relay host. + + ------------------------------------------------------------- + + Step 1 -- Expanding the First List + + R: 220 MIT-AI.ARPA Simple Mail Transfer Service Ready + S: HELO SU-SCORE.ARPA + R: 250 MIT-AI.ARPA + + S: EXPN Example-People + R: 250- + R: 250-Fred Fonebone + R: 250-Xenon Y. Zither + R: 250-Quincy Smith <@USC-ISIF.ARPA:Q-Smith@ISI-VAXA.ARPA> + R: 250- + R: 250 + + S: QUIT + R: 221 MIT-AI.ARPA Service closing transmission channel + + + + + + + + + + + + + + + + + + + + + + + + + +[Page 58] Postel + + + +RFC 821 August 1982 + Simple Mail Transfer Protocol + + + + Step 2 -- Expanding the Second List + + R: 220 MIT-MC.ARPA Simple Mail Transfer Service Ready + S: HELO SU-SCORE.ARPA + R: 250 MIT-MC.ARPA + + S: EXPN Interested-Parties + R: 250-Al Calico + R: 250- + R: 250-Quincy Smith <@USC-ISIF.ARPA:Q-Smith@ISI-VAXA.ARPA> + R: 250- + R: 250 + + S: QUIT + R: 221 MIT-MC.ARPA Service closing transmission channel + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Postel [Page 59] + + + +August 1982 RFC 821 +Simple Mail Transfer Protocol + + + + Step 3 -- Mailing to All via a Relay Host + + R: 220 USC-ISIE.ARPA Simple Mail Transfer Service Ready + S: HELO SU-SCORE.ARPA + R: 250 USC-ISIE.ARPA + + S: MAIL FROM: + R: 250 OK + S: RCPT TO:<@USC-ISIE.ARPA:ABC@MIT-MC.ARPA> + R: 250 OK + S: RCPT TO:<@USC-ISIE.ARPA:Fonebone@USC-ISIQA.ARPA> + R: 250 OK + S: RCPT TO:<@USC-ISIE.ARPA:XYZ@MIT-AI.ARPA> + R: 250 OK + S: RCPT + TO:<@USC-ISIE.ARPA,@USC-ISIF.ARPA:Q-Smith@ISI-VAXA.ARPA> + R: 250 OK + S: RCPT TO:<@USC-ISIE.ARPA:joe@FOO-UNIX.ARPA> + R: 250 OK + S: RCPT TO:<@USC-ISIE.ARPA:xyz@BAR-UNIX.ARPA> + R: 250 OK + S: RCPT TO:<@USC-ISIE.ARPA:fred@BBN-UNIX.ARPA> + R: 250 OK + + S: DATA + R: 354 Start mail input; end with . + S: Blah blah blah... + S: ...etc. etc. etc. + S: . + R: 250 OK + + S: QUIT + R: 221 USC-ISIE.ARPA Service closing transmission channel + + Scenario 7 + + ------------------------------------------------------------- + + + + + + + + + + + + +[Page 60] Postel + + + +RFC 821 August 1982 + Simple Mail Transfer Protocol + + + + Forwarding Scenarios + + ------------------------------------------------------------- + + R: 220 USC-ISIF.ARPA Simple Mail Transfer Service Ready + S: HELO LBL-UNIX.ARPA + R: 250 USC-ISIF.ARPA + + S: MAIL FROM: + R: 250 OK + + S: RCPT TO: + R: 251 User not local; will forward to + + S: DATA + R: 354 Start mail input; end with . + S: Blah blah blah... + S: ...etc. etc. etc. + S: . + R: 250 OK + + S: QUIT + R: 221 USC-ISIF.ARPA Service closing transmission channel + + Scenario 8 + + ------------------------------------------------------------- + + + + + + + + + + + + + + + + + + + + + + +Postel [Page 61] + + + +August 1982 RFC 821 +Simple Mail Transfer Protocol + + + + ------------------------------------------------------------- + + Step 1 -- Trying the Mailbox at the First Host + + R: 220 USC-ISIF.ARPA Simple Mail Transfer Service Ready + S: HELO LBL-UNIX.ARPA + R: 250 USC-ISIF.ARPA + + S: MAIL FROM: + R: 250 OK + + S: RCPT TO: + R: 251 User not local; will forward to + + S: RSET + R: 250 OK + + S: QUIT + R: 221 USC-ISIF.ARPA Service closing transmission channel + + Step 2 -- Delivering the Mail at the Second Host + + R: 220 USC-ISI.ARPA Simple Mail Transfer Service Ready + S: HELO LBL-UNIX.ARPA + R: 250 USC-ISI.ARPA + + S: MAIL FROM: + R: 250 OK + + S: RCPT TO: + R: OK + + S: DATA + R: 354 Start mail input; end with . + S: Blah blah blah... + S: ...etc. etc. etc. + S: . + R: 250 OK + + S: QUIT + R: 221 USC-ISI.ARPA Service closing transmission channel + + Scenario 9 + + ------------------------------------------------------------- + + + + +[Page 62] Postel + + + +RFC 821 August 1982 + Simple Mail Transfer Protocol + + + + Too Many Recipients Scenario + + ------------------------------------------------------------- + + R: 220 BERKELEY.ARPA Simple Mail Transfer Service Ready + S: HELO USC-ISIF.ARPA + R: 250 BERKELEY.ARPA + + S: MAIL FROM: + R: 250 OK + + S: RCPT TO: + R: 250 OK + + S: RCPT TO: + R: 552 Recipient storage full, try again in another transaction + + S: DATA + R: 354 Start mail input; end with . + S: Blah blah blah... + S: ...etc. etc. etc. + S: . + R: 250 OK + + S: MAIL FROM: + R: 250 OK + + S: RCPT TO: + R: 250 OK + + S: DATA + R: 354 Start mail input; end with . + S: Blah blah blah... + S: ...etc. etc. etc. + S: . + R: 250 OK + + S: QUIT + R: 221 BERKELEY.ARPA Service closing transmission channel + + Scenario 10 + + ------------------------------------------------------------- + + Note that a real implementation must handle many recipients as + specified in Section 4.5.3. + + + +Postel [Page 63] + + + +August 1982 RFC 821 +Simple Mail Transfer Protocol + + + +GLOSSARY + + ASCII + + American Standard Code for Information Interchange [1]. + + command + + A request for a mail service action sent by the sender-SMTP to the + receiver-SMTP. + + domain + + The hierarchially structured global character string address of a + host computer in the mail system. + + end of mail data indication + + A special sequence of characters that indicates the end of the + mail data. In particular, the five characters carriage return, + line feed, period, carriage return, line feed, in that order. + + host + + A computer in the internetwork environment on which mailboxes or + SMTP processes reside. + + line + + A a sequence of ASCII characters ending with a . + + mail data + + A sequence of ASCII characters of arbitrary length, which conforms + to the standard set in the Standard for the Format of ARPA + Internet Text Messages (RFC 822 [2]). + + mailbox + + A character string (address) which identifies a user to whom mail + is to be sent. Mailbox normally consists of the host and user + specifications. The standard mailbox naming convention is defined + to be "user@domain". Additionally, the "container" in which mail + is stored. + + + + + +[Page 64] Postel + + + +RFC 821 August 1982 + Simple Mail Transfer Protocol + + + + receiver-SMTP process + + A process which transfers mail in cooperation with a sender-SMTP + process. It waits for a connection to be established via the + transport service. It receives SMTP commands from the + sender-SMTP, sends replies, and performs the specified operations. + + reply + + A reply is an acknowledgment (positive or negative) sent from + receiver to sender via the transmission channel in response to a + command. The general form of a reply is a completion code + (including error codes) followed by a text string. The codes are + for use by programs and the text is usually intended for human + users. + + sender-SMTP process + + A process which transfers mail in cooperation with a receiver-SMTP + process. A local language may be used in the user interface + command/reply dialogue. The sender-SMTP initiates the transport + service connection. It initiates SMTP commands, receives replies, + and governs the transfer of mail. + + session + + The set of exchanges that occur while the transmission channel is + open. + + transaction + + The set of exchanges required for one message to be transmitted + for one or more recipients. + + transmission channel + + A full-duplex communication path between a sender-SMTP and a + receiver-SMTP for the exchange of commands, replies, and mail + text. + + transport service + + Any reliable stream-oriented data communication services. For + example, NCP, TCP, NITS. + + + + + +Postel [Page 65] + + + +August 1982 RFC 821 +Simple Mail Transfer Protocol + + + + user + + A human being (or a process on behalf of a human being) wishing to + obtain mail transfer service. In addition, a recipient of + computer mail. + + word + + A sequence of printing characters. + + + + The characters carriage return and line feed (in that order). + + + + The space character. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +[Page 66] Postel + + + +RFC 821 August 1982 + Simple Mail Transfer Protocol + + + +REFERENCES + + [1] ASCII + + ASCII, "USA Code for Information Interchange", United States of + America Standards Institute, X3.4, 1968. Also in: Feinler, E. + and J. Postel, eds., "ARPANET Protocol Handbook", NIC 7104, for + the Defense Communications Agency by SRI International, Menlo + Park, California, Revised January 1978. + + [2] RFC 822 + + Crocker, D., "Standard for the Format of ARPA Internet Text + Messages," RFC 822, Department of Electrical Engineering, + University of Delaware, August 1982. + + [3] TCP + + Postel, J., ed., "Transmission Control Protocol - DARPA Internet + Program Protocol Specification", RFC 793, USC/Information Sciences + Institute, NTIS AD Number A111091, September 1981. Also in: + Feinler, E. and J. Postel, eds., "Internet Protocol Transition + Workbook", SRI International, Menlo Park, California, March 1982. + + [4] NCP + + McKenzie,A., "Host/Host Protocol for the ARPA Network", NIC 8246, + January 1972. Also in: Feinler, E. and J. Postel, eds., "ARPANET + Protocol Handbook", NIC 7104, for the Defense Communications + Agency by SRI International, Menlo Park, California, Revised + January 1978. + + [5] Initial Connection Protocol + + Postel, J., "Official Initial Connection Protocol", NIC 7101, + 11 June 1971. Also in: Feinler, E. and J. Postel, eds., "ARPANET + Protocol Handbook", NIC 7104, for the Defense Communications + Agency by SRI International, Menlo Park, California, Revised + January 1978. + + [6] NITS + + PSS/SG3, "A Network Independent Transport Service", Study Group 3, + The Post Office PSS Users Group, February 1980. Available from + the DCPU, National Physical Laboratory, Teddington, UK. + + + + +Postel [Page 67] + + + +August 1982 RFC 821 +Simple Mail Transfer Protocol + + + + [7] X.25 + + CCITT, "Recommendation X.25 - Interface Between Data Terminal + Equipment (DTE) and Data Circuit-terminating Equipment (DCE) for + Terminals Operating in the Packet Mode on Public Data Networks," + CCITT Orange Book, Vol. VIII.2, International Telephone and + Telegraph Consultative Committee, Geneva, 1976. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +[Page 68] Postel + diff --git a/vendor/swiftmailer/swiftmailer/notes/rfc/rfc0822.txt b/vendor/swiftmailer/swiftmailer/notes/rfc/rfc0822.txt new file mode 100755 index 0000000..35b09a3 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/notes/rfc/rfc0822.txt @@ -0,0 +1,2901 @@ + + + + + + + RFC # 822 + + Obsoletes: RFC #733 (NIC #41952) + + + + + + + + + + + + + STANDARD FOR THE FORMAT OF + + ARPA INTERNET TEXT MESSAGES + + + + + + + August 13, 1982 + + + + + + + Revised by + + David H. Crocker + + + Dept. of Electrical Engineering + University of Delaware, Newark, DE 19711 + Network: DCrocker @ UDel-Relay + + + + + + + + + + + + + + + + Standard for ARPA Internet Text Messages + + + TABLE OF CONTENTS + + + PREFACE .................................................... ii + + 1. INTRODUCTION ........................................... 1 + + 1.1. Scope ............................................ 1 + 1.2. Communication Framework .......................... 2 + + 2. NOTATIONAL CONVENTIONS ................................. 3 + + 3. LEXICAL ANALYSIS OF MESSAGES ........................... 5 + + 3.1. General Description .............................. 5 + 3.2. Header Field Definitions ......................... 9 + 3.3. Lexical Tokens ................................... 10 + 3.4. Clarifications ................................... 11 + + 4. MESSAGE SPECIFICATION .................................. 17 + + 4.1. Syntax ........................................... 17 + 4.2. Forwarding ....................................... 19 + 4.3. Trace Fields ..................................... 20 + 4.4. Originator Fields ................................ 21 + 4.5. Receiver Fields .................................. 23 + 4.6. Reference Fields ................................. 23 + 4.7. Other Fields ..................................... 24 + + 5. DATE AND TIME SPECIFICATION ............................ 26 + + 5.1. Syntax ........................................... 26 + 5.2. Semantics ........................................ 26 + + 6. ADDRESS SPECIFICATION .................................. 27 + + 6.1. Syntax ........................................... 27 + 6.2. Semantics ........................................ 27 + 6.3. Reserved Address ................................. 33 + + 7. BIBLIOGRAPHY ........................................... 34 + + + APPENDIX + + A. EXAMPLES ............................................... 36 + B. SIMPLE FIELD PARSING ................................... 40 + C. DIFFERENCES FROM RFC #733 .............................. 41 + D. ALPHABETICAL LISTING OF SYNTAX RULES ................... 44 + + + August 13, 1982 - i - RFC #822 + + + + + Standard for ARPA Internet Text Messages + + + PREFACE + + + By 1977, the Arpanet employed several informal standards for + the text messages (mail) sent among its host computers. It was + felt necessary to codify these practices and provide for those + features that seemed imminent. The result of that effort was + Request for Comments (RFC) #733, "Standard for the Format of ARPA + Network Text Message", by Crocker, Vittal, Pogran, and Henderson. + The specification attempted to avoid major changes in existing + software, while permitting several new features. + + This document revises the specifications in RFC #733, in + order to serve the needs of the larger and more complex ARPA + Internet. Some of RFC #733's features failed to gain adequate + acceptance. In order to simplify the standard and the software + that follows it, these features have been removed. A different + addressing scheme is used, to handle the case of inter-network + mail; and the concept of re-transmission has been introduced. + + This specification is intended for use in the ARPA Internet. + However, an attempt has been made to free it of any dependence on + that environment, so that it can be applied to other network text + message systems. + + The specification of RFC #733 took place over the course of + one year, using the ARPANET mail environment, itself, to provide + an on-going forum for discussing the capabilities to be included. + More than twenty individuals, from across the country, partici- + pated in the original discussion. The development of this + revised specification has, similarly, utilized network mail-based + group discussion. Both specification efforts greatly benefited + from the comments and ideas of the participants. + + The syntax of the standard, in RFC #733, was originally + specified in the Backus-Naur Form (BNF) meta-language. Ken L. + Harrenstien, of SRI International, was responsible for re-coding + the BNF into an augmented BNF that makes the representation + smaller and easier to understand. + + + + + + + + + + + + + August 13, 1982 - ii - RFC #822 + + + + Standard for ARPA Internet Text Messages + + + 1. INTRODUCTION + + 1.1. SCOPE + + This standard specifies a syntax for text messages that are + sent among computer users, within the framework of "electronic + mail". The standard supersedes the one specified in ARPANET + Request for Comments #733, "Standard for the Format of ARPA Net- + work Text Messages". + + In this context, messages are viewed as having an envelope + and contents. The envelope contains whatever information is + needed to accomplish transmission and delivery. The contents + compose the object to be delivered to the recipient. This stan- + dard applies only to the format and some of the semantics of mes- + sage contents. It contains no specification of the information + in the envelope. + + However, some message systems may use information from the + contents to create the envelope. It is intended that this stan- + dard facilitate the acquisition of such information by programs. + + Some message systems may store messages in formats that + differ from the one specified in this standard. This specifica- + tion is intended strictly as a definition of what message content + format is to be passed BETWEEN hosts. + + Note: This standard is NOT intended to dictate the internal for- + mats used by sites, the specific message system features + that they are expected to support, or any of the charac- + teristics of user interface programs that create or read + messages. + + A distinction should be made between what the specification + REQUIRES and what it ALLOWS. Messages can be made complex and + rich with formally-structured components of information or can be + kept small and simple, with a minimum of such information. Also, + the standard simplifies the interpretation of differing visual + formats in messages; only the visual aspect of a message is + affected and not the interpretation of information within it. + Implementors may choose to retain such visual distinctions. + + The formal definition is divided into four levels. The bot- + tom level describes the meta-notation used in this document. The + second level describes basic lexical analyzers that feed tokens + to higher-level parsers. Next is an overall specification for + messages; it permits distinguishing individual fields. Finally, + there is definition of the contents of several structured fields. + + + + August 13, 1982 - 1 - RFC #822 + + + + Standard for ARPA Internet Text Messages + + + 1.2. COMMUNICATION FRAMEWORK + + Messages consist of lines of text. No special provisions + are made for encoding drawings, facsimile, speech, or structured + text. No significant consideration has been given to questions + of data compression or to transmission and storage efficiency, + and the standard tends to be free with the number of bits con- + sumed. For example, field names are specified as free text, + rather than special terse codes. + + A general "memo" framework is used. That is, a message con- + sists of some information in a rigid format, followed by the main + part of the message, with a format that is not specified in this + document. The syntax of several fields of the rigidly-formated + ("headers") section is defined in this specification; some of + these fields must be included in all messages. + + The syntax that distinguishes between header fields is + specified separately from the internal syntax for particular + fields. This separation is intended to allow simple parsers to + operate on the general structure of messages, without concern for + the detailed structure of individual header fields. Appendix B + is provided to facilitate construction of these parsers. + + In addition to the fields specified in this document, it is + expected that other fields will gain common use. As necessary, + the specifications for these "extension-fields" will be published + through the same mechanism used to publish this document. Users + may also wish to extend the set of fields that they use + privately. Such "user-defined fields" are permitted. + + The framework severely constrains document tone and appear- + ance and is primarily useful for most intra-organization communi- + cations and well-structured inter-organization communication. + It also can be used for some types of inter-process communica- + tion, such as simple file transfer and remote job entry. A more + robust framework might allow for multi-font, multi-color, multi- + dimension encoding of information. A less robust one, as is + present in most single-machine message systems, would more + severely constrain the ability to add fields and the decision to + include specific fields. In contrast with paper-based communica- + tion, it is interesting to note that the RECEIVER of a message + can exercise an extraordinary amount of control over the + message's appearance. The amount of actual control available to + message receivers is contingent upon the capabilities of their + individual message systems. + + + + + + August 13, 1982 - 2 - RFC #822 + + + + Standard for ARPA Internet Text Messages + + + 2. NOTATIONAL CONVENTIONS + + This specification uses an augmented Backus-Naur Form (BNF) + notation. The differences from standard BNF involve naming rules + and indicating repetition and "local" alternatives. + + 2.1. RULE NAMING + + Angle brackets ("<", ">") are not used, in general. The + name of a rule is simply the name itself, rather than "". + Quotation-marks enclose literal text (which may be upper and/or + lower case). Certain basic rules are in uppercase, such as + SPACE, TAB, CRLF, DIGIT, ALPHA, etc. Angle brackets are used in + rule definitions, and in the rest of this document, whenever + their presence will facilitate discerning the use of rule names. + + 2.2. RULE1 / RULE2: ALTERNATIVES + + Elements separated by slash ("/") are alternatives. There- + fore "foo / bar" will accept foo or bar. + + 2.3. (RULE1 RULE2): LOCAL ALTERNATIVES + + Elements enclosed in parentheses are treated as a single + element. Thus, "(elem (foo / bar) elem)" allows the token + sequences "elem foo elem" and "elem bar elem". + + 2.4. *RULE: REPETITION + + The character "*" preceding an element indicates repetition. + The full form is: + + *element + + indicating at least and at most occurrences of element. + Default values are 0 and infinity so that "*(element)" allows any + number, including zero; "1*element" requires at least one; and + "1*2element" allows one or two. + + 2.5. [RULE]: OPTIONAL + + Square brackets enclose optional elements; "[foo bar]" is + equivalent to "*1(foo bar)". + + 2.6. NRULE: SPECIFIC REPETITION + + "(element)" is equivalent to "*(element)"; that is, + exactly occurrences of (element). Thus 2DIGIT is a 2-digit + number, and 3ALPHA is a string of three alphabetic characters. + + + August 13, 1982 - 3 - RFC #822 + + + + Standard for ARPA Internet Text Messages + + + 2.7. #RULE: LISTS + + A construct "#" is defined, similar to "*", as follows: + + #element + + indicating at least and at most elements, each separated + by one or more commas (","). This makes the usual form of lists + very easy; a rule such as '(element *("," element))' can be shown + as "1#element". Wherever this construct is used, null elements + are allowed, but do not contribute to the count of elements + present. That is, "(element),,(element)" is permitted, but + counts as only two elements. Therefore, where at least one ele- + ment is required, at least one non-null element must be present. + Default values are 0 and infinity so that "#(element)" allows any + number, including zero; "1#element" requires at least one; and + "1#2element" allows one or two. + + 2.8. ; COMMENTS + + A semi-colon, set off some distance to the right of rule + text, starts a comment that continues to the end of line. This + is a simple way of including useful notes in parallel with the + specifications. + + + + + + + + + + + + + + + + + + + + + + + + + + + + August 13, 1982 - 4 - RFC #822 + + + + Standard for ARPA Internet Text Messages + + + 3. LEXICAL ANALYSIS OF MESSAGES + + 3.1. GENERAL DESCRIPTION + + A message consists of header fields and, optionally, a body. + The body is simply a sequence of lines containing ASCII charac- + ters. It is separated from the headers by a null line (i.e., a + line with nothing preceding the CRLF). + + 3.1.1. LONG HEADER FIELDS + + Each header field can be viewed as a single, logical line of + ASCII characters, comprising a field-name and a field-body. + For convenience, the field-body portion of this conceptual + entity can be split into a multiple-line representation; this + is called "folding". The general rule is that wherever there + may be linear-white-space (NOT simply LWSP-chars), a CRLF + immediately followed by AT LEAST one LWSP-char may instead be + inserted. Thus, the single line + + To: "Joe & J. Harvey" , JJV @ BBN + + can be represented as: + + To: "Joe & J. Harvey" , + JJV@BBN + + and + + To: "Joe & J. Harvey" + , JJV + @BBN + + and + + To: "Joe & + J. Harvey" , JJV @ BBN + + The process of moving from this folded multiple-line + representation of a header field to its single line represen- + tation is called "unfolding". Unfolding is accomplished by + regarding CRLF immediately followed by a LWSP-char as + equivalent to the LWSP-char. + + Note: While the standard permits folding wherever linear- + white-space is permitted, it is recommended that struc- + tured fields, such as those containing addresses, limit + folding to higher-level syntactic breaks. For address + fields, it is recommended that such folding occur + + + August 13, 1982 - 5 - RFC #822 + + + + Standard for ARPA Internet Text Messages + + + between addresses, after the separating comma. + + 3.1.2. STRUCTURE OF HEADER FIELDS + + Once a field has been unfolded, it may be viewed as being com- + posed of a field-name followed by a colon (":"), followed by a + field-body, and terminated by a carriage-return/line-feed. + The field-name must be composed of printable ASCII characters + (i.e., characters that have values between 33. and 126., + decimal, except colon). The field-body may be composed of any + ASCII characters, except CR or LF. (While CR and/or LF may be + present in the actual text, they are removed by the action of + unfolding the field.) + + Certain field-bodies of headers may be interpreted according + to an internal syntax that some systems may wish to parse. + These fields are called "structured fields". Examples + include fields containing dates and addresses. Other fields, + such as "Subject" and "Comments", are regarded simply as + strings of text. + + Note: Any field which has a field-body that is defined as + other than simply is to be treated as a struc- + tured field. + + Field-names, unstructured field bodies and structured + field bodies each are scanned by their own, independent + "lexical" analyzers. + + 3.1.3. UNSTRUCTURED FIELD BODIES + + For some fields, such as "Subject" and "Comments", no struc- + turing is assumed, and they are treated simply as s, as + in the message body. Rules of folding apply to these fields, + so that such field bodies which occupy several lines must + therefore have the second and successive lines indented by at + least one LWSP-char. + + 3.1.4. STRUCTURED FIELD BODIES + + To aid in the creation and reading of structured fields, the + free insertion of linear-white-space (which permits folding + by inclusion of CRLFs) is allowed between lexical tokens. + Rather than obscuring the syntax specifications for these + structured fields with explicit syntax for this linear-white- + space, the existence of another "lexical" analyzer is assumed. + This analyzer does not apply for unstructured field bodies + that are simply strings of text, as described above. The + analyzer provides an interpretation of the unfolded text + + + August 13, 1982 - 6 - RFC #822 + + + + Standard for ARPA Internet Text Messages + + + composing the body of the field as a sequence of lexical sym- + bols. + + These symbols are: + + - individual special characters + - quoted-strings + - domain-literals + - comments + - atoms + + The first four of these symbols are self-delimiting. Atoms + are not; they are delimited by the self-delimiting symbols and + by linear-white-space. For the purposes of regenerating + sequences of atoms and quoted-strings, exactly one SPACE is + assumed to exist, and should be used, between them. (Also, in + the "Clarifications" section on "White Space", below, note the + rules about treatment of multiple contiguous LWSP-chars.) + + So, for example, the folded body of an address field + + ":sysmail"@ Some-Group. Some-Org, + Muhammed.(I am the greatest) Ali @(the)Vegas.WBA + + + + + + + + + + + + + + + + + + + + + + + + + + + + + August 13, 1982 - 7 - RFC #822 + + + + Standard for ARPA Internet Text Messages + + + is analyzed into the following lexical symbols and types: + + :sysmail quoted string + @ special + Some-Group atom + . special + Some-Org atom + , special + Muhammed atom + . special + (I am the greatest) comment + Ali atom + @ atom + (the) comment + Vegas atom + . special + WBA atom + + The canonical representations for the data in these addresses + are the following strings: + + ":sysmail"@Some-Group.Some-Org + + and + + Muhammed.Ali@Vegas.WBA + + Note: For purposes of display, and when passing such struc- + tured information to other systems, such as mail proto- + col services, there must be NO linear-white-space + between s that are separated by period (".") or + at-sign ("@") and exactly one SPACE between all other + s. Also, headers should be in a folded form. + + + + + + + + + + + + + + + + + + + August 13, 1982 - 8 - RFC #822 + + + + Standard for ARPA Internet Text Messages + + + 3.2. HEADER FIELD DEFINITIONS + + These rules show a field meta-syntax, without regard for the + particular type or internal syntax. Their purpose is to permit + detection of fields; also, they present to higher-level parsers + an image of each field as fitting on one line. + + field = field-name ":" [ field-body ] CRLF + + field-name = 1* + + field-body = field-body-contents + [CRLF LWSP-char field-body] + + field-body-contents = + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + August 13, 1982 - 9 - RFC #822 + + + + Standard for ARPA Internet Text Messages + + + 3.3. LEXICAL TOKENS + + The following rules are used to define an underlying lexical + analyzer, which feeds tokens to higher level parsers. See the + ANSI references, in the Bibliography. + + ; ( Octal, Decimal.) + CHAR = ; ( 0-177, 0.-127.) + ALPHA = + ; (101-132, 65.- 90.) + ; (141-172, 97.-122.) + DIGIT = ; ( 60- 71, 48.- 57.) + CTL = ; ( 177, 127.) + CR = ; ( 15, 13.) + LF = ; ( 12, 10.) + SPACE = ; ( 40, 32.) + HTAB = ; ( 11, 9.) + <"> = ; ( 42, 34.) + CRLF = CR LF + + LWSP-char = SPACE / HTAB ; semantics = SPACE + + linear-white-space = 1*([CRLF] LWSP-char) ; semantics = SPACE + ; CRLF => folding + + specials = "(" / ")" / "<" / ">" / "@" ; Must be in quoted- + / "," / ";" / ":" / "\" / <"> ; string, to use + / "." / "[" / "]" ; within a word. + + delimiters = specials / linear-white-space / comment + + text = atoms, specials, + CR & bare LF, but NOT ; comments and + including CRLF> ; quoted-strings are + ; NOT recognized. + + atom = 1* + + quoted-string = <"> *(qtext/quoted-pair) <">; Regular qtext or + ; quoted chars. + + qtext = , ; => may be folded + "\" & CR, and including + linear-white-space> + + domain-literal = "[" *(dtext / quoted-pair) "]" + + + + + August 13, 1982 - 10 - RFC #822 + + + + Standard for ARPA Internet Text Messages + + + dtext = may be folded + "]", "\" & CR, & including + linear-white-space> + + comment = "(" *(ctext / quoted-pair / comment) ")" + + ctext = may be folded + ")", "\" & CR, & including + linear-white-space> + + quoted-pair = "\" CHAR ; may quote any char + + phrase = 1*word ; Sequence of words + + word = atom / quoted-string + + + 3.4. CLARIFICATIONS + + 3.4.1. QUOTING + + Some characters are reserved for special interpretation, such + as delimiting lexical tokens. To permit use of these charac- + ters as uninterpreted data, a quoting mechanism is provided. + To quote a character, precede it with a backslash ("\"). + + This mechanism is not fully general. Characters may be quoted + only within a subset of the lexical constructs. In particu- + lar, quoting is limited to use within: + + - quoted-string + - domain-literal + - comment + + Within these constructs, quoting is REQUIRED for CR and "\" + and for the character(s) that delimit the token (e.g., "(" and + ")" for a comment). However, quoting is PERMITTED for any + character. + + Note: In particular, quoting is NOT permitted within atoms. + For example when the local-part of an addr-spec must + contain a special character, a quoted string must be + used. Therefore, a specification such as: + + Full\ Name@Domain + + is not legal and must be specified as: + + "Full Name"@Domain + + + August 13, 1982 - 11 - RFC #822 + + + + Standard for ARPA Internet Text Messages + + + 3.4.2. WHITE SPACE + + Note: In structured field bodies, multiple linear space ASCII + characters (namely HTABs and SPACEs) are treated as + single spaces and may freely surround any symbol. In + all header fields, the only place in which at least one + LWSP-char is REQUIRED is at the beginning of continua- + tion lines in a folded field. + + When passing text to processes that do not interpret text + according to this standard (e.g., mail protocol servers), then + NO linear-white-space characters should occur between a period + (".") or at-sign ("@") and a . Exactly ONE SPACE should + be used in place of arbitrary linear-white-space and comment + sequences. + + Note: Within systems conforming to this standard, wherever a + member of the list of delimiters is allowed, LWSP-chars + may also occur before and/or after it. + + Writers of mail-sending (i.e., header-generating) programs + should realize that there is no network-wide definition of the + effect of ASCII HT (horizontal-tab) characters on the appear- + ance of text at another network host; therefore, the use of + tabs in message headers, though permitted, is discouraged. + + 3.4.3. COMMENTS + + A comment is a set of ASCII characters, which is enclosed in + matching parentheses and which is not within a quoted-string + The comment construct permits message originators to add text + which will be useful for human readers, but which will be + ignored by the formal semantics. Comments should be retained + while the message is subject to interpretation according to + this standard. However, comments must NOT be included in + other cases, such as during protocol exchanges with mail + servers. + + Comments nest, so that if an unquoted left parenthesis occurs + in a comment string, there must also be a matching right + parenthesis. When a comment acts as the delimiter between a + sequence of two lexical symbols, such as two atoms, it is lex- + ically equivalent with a single SPACE, for the purposes of + regenerating the sequence, such as when passing the sequence + onto a mail protocol server. Comments are detected as such + only within field-bodies of structured fields. + + If a comment is to be "folded" onto multiple lines, then the + syntax for folding must be adhered to. (See the "Lexical + + + August 13, 1982 - 12 - RFC #822 + + + + Standard for ARPA Internet Text Messages + + + Analysis of Messages" section on "Folding Long Header Fields" + above, and the section on "Case Independence" below.) Note + that the official semantics therefore do not "see" any + unquoted CRLFs that are in comments, although particular pars- + ing programs may wish to note their presence. For these pro- + grams, it would be reasonable to interpret a "CRLF LWSP-char" + as being a CRLF that is part of the comment; i.e., the CRLF is + kept and the LWSP-char is discarded. Quoted CRLFs (i.e., a + backslash followed by a CR followed by a LF) still must be + followed by at least one LWSP-char. + + 3.4.4. DELIMITING AND QUOTING CHARACTERS + + The quote character (backslash) and characters that delimit + syntactic units are not, generally, to be taken as data that + are part of the delimited or quoted unit(s). In particular, + the quotation-marks that define a quoted-string, the + parentheses that define a comment and the backslash that + quotes a following character are NOT part of the quoted- + string, comment or quoted character. A quotation-mark that is + to be part of a quoted-string, a parenthesis that is to be + part of a comment and a backslash that is to be part of either + must each be preceded by the quote-character backslash ("\"). + Note that the syntax allows any character to be quoted within + a quoted-string or comment; however only certain characters + MUST be quoted to be included as data. These characters are + the ones that are not part of the alternate text group (i.e., + ctext or qtext). + + The one exception to this rule is that a single SPACE is + assumed to exist between contiguous words in a phrase, and + this interpretation is independent of the actual number of + LWSP-chars that the creator places between the words. To + include more than one SPACE, the creator must make the LWSP- + chars be part of a quoted-string. + + Quotation marks that delimit a quoted string and backslashes + that quote the following character should NOT accompany the + quoted-string when the string is passed to processes that do + not interpret data according to this specification (e.g., mail + protocol servers). + + 3.4.5. QUOTED-STRINGS + + Where permitted (i.e., in words in structured fields) quoted- + strings are treated as a single symbol. That is, a quoted- + string is equivalent to an atom, syntactically. If a quoted- + string is to be "folded" onto multiple lines, then the syntax + for folding must be adhered to. (See the "Lexical Analysis of + + + August 13, 1982 - 13 - RFC #822 + + + + Standard for ARPA Internet Text Messages + + + Messages" section on "Folding Long Header Fields" above, and + the section on "Case Independence" below.) Therefore, the + official semantics do not "see" any bare CRLFs that are in + quoted-strings; however particular parsing programs may wish + to note their presence. For such programs, it would be rea- + sonable to interpret a "CRLF LWSP-char" as being a CRLF which + is part of the quoted-string; i.e., the CRLF is kept and the + LWSP-char is discarded. Quoted CRLFs (i.e., a backslash fol- + lowed by a CR followed by a LF) are also subject to rules of + folding, but the presence of the quoting character (backslash) + explicitly indicates that the CRLF is data to the quoted + string. Stripping off the first following LWSP-char is also + appropriate when parsing quoted CRLFs. + + 3.4.6. BRACKETING CHARACTERS + + There is one type of bracket which must occur in matched pairs + and may have pairs nested within each other: + + o Parentheses ("(" and ")") are used to indicate com- + ments. + + There are three types of brackets which must occur in matched + pairs, and which may NOT be nested: + + o Colon/semi-colon (":" and ";") are used in address + specifications to indicate that the included list of + addresses are to be treated as a group. + + o Angle brackets ("<" and ">") are generally used to + indicate the presence of a one machine-usable refer- + ence (e.g., delimiting mailboxes), possibly including + source-routing to the machine. + + o Square brackets ("[" and "]") are used to indicate the + presence of a domain-literal, which the appropriate + name-domain is to use directly, bypassing normal + name-resolution mechanisms. + + 3.4.7. CASE INDEPENDENCE + + Except as noted, alphabetic strings may be represented in any + combination of upper and lower case. The only syntactic units + + + + + + + + + August 13, 1982 - 14 - RFC #822 + + + + Standard for ARPA Internet Text Messages + + + which requires preservation of case information are: + + - text + - qtext + - dtext + - ctext + - quoted-pair + - local-part, except "Postmaster" + + When matching any other syntactic unit, case is to be ignored. + For example, the field-names "From", "FROM", "from", and even + "FroM" are semantically equal and should all be treated ident- + ically. + + When generating these units, any mix of upper and lower case + alphabetic characters may be used. The case shown in this + specification is suggested for message-creating processes. + + Note: The reserved local-part address unit, "Postmaster", is + an exception. When the value "Postmaster" is being + interpreted, it must be accepted in any mixture of + case, including "POSTMASTER", and "postmaster". + + 3.4.8. FOLDING LONG HEADER FIELDS + + Each header field may be represented on exactly one line con- + sisting of the name of the field and its body, and terminated + by a CRLF; this is what the parser sees. For readability, the + field-body portion of long header fields may be "folded" onto + multiple lines of the actual field. "Long" is commonly inter- + preted to mean greater than 65 or 72 characters. The former + length serves as a limit, when the message is to be viewed on + most simple terminals which use simple display software; how- + ever, the limit is not imposed by this standard. + + Note: Some display software often can selectively fold lines, + to suit the display terminal. In such cases, sender- + provided folding can interfere with the display + software. + + 3.4.9. BACKSPACE CHARACTERS + + ASCII BS characters (Backspace, decimal 8) may be included in + texts and quoted-strings to effect overstriking. However, any + use of backspaces which effects an overstrike to the left of + the beginning of the text or quoted-string is prohibited. + + + + + + August 13, 1982 - 15 - RFC #822 + + + + Standard for ARPA Internet Text Messages + + + 3.4.10. NETWORK-SPECIFIC TRANSFORMATIONS + + During transmission through heterogeneous networks, it may be + necessary to force data to conform to a network's local con- + ventions. For example, it may be required that a CR be fol- + lowed either by LF, making a CRLF, or by , if the CR is + to stand alone). Such transformations are reversed, when the + message exits that network. + + When crossing network boundaries, the message should be + treated as passing through two modules. It will enter the + first module containing whatever network-specific transforma- + tions that were necessary to permit migration through the + "current" network. It then passes through the modules: + + o Transformation Reversal + + The "current" network's idiosyncracies are removed and + the message is returned to the canonical form speci- + fied in this standard. + + o Transformation + + The "next" network's local idiosyncracies are imposed + on the message. + + ------------------ + From ==> | Remove Net-A | + Net-A | idiosyncracies | + ------------------ + || + \/ + Conformance + with standard + || + \/ + ------------------ + | Impose Net-B | ==> To + | idiosyncracies | Net-B + ------------------ + + + + + + + + + + + + August 13, 1982 - 16 - RFC #822 + + + + Standard for ARPA Internet Text Messages + + + 4. MESSAGE SPECIFICATION + + 4.1. SYNTAX + + Note: Due to an artifact of the notational conventions, the syn- + tax indicates that, when present, some fields, must be in + a particular order. Header fields are NOT required to + occur in any particular order, except that the message + body must occur AFTER the headers. It is recommended + that, if present, headers be sent in the order "Return- + Path", "Received", "Date", "From", "Subject", "Sender", + "To", "cc", etc. + + This specification permits multiple occurrences of most + fields. Except as noted, their interpretation is not + specified here, and their use is discouraged. + + The following syntax for the bodies of various fields should + be thought of as describing each field body as a single long + string (or line). The "Lexical Analysis of Message" section on + "Long Header Fields", above, indicates how such long strings can + be represented on more than one line in the actual transmitted + message. + + message = fields *( CRLF *text ) ; Everything after + ; first null line + ; is message body + + fields = dates ; Creation time, + source ; author id & one + 1*destination ; address required + *optional-field ; others optional + + source = [ trace ] ; net traversals + originator ; original mail + [ resent ] ; forwarded + + trace = return ; path to sender + 1*received ; receipt tags + + return = "Return-path" ":" route-addr ; return address + + received = "Received" ":" ; one per relay + ["from" domain] ; sending host + ["by" domain] ; receiving host + ["via" atom] ; physical path + *("with" atom) ; link/mail protocol + ["id" msg-id] ; receiver msg id + ["for" addr-spec] ; initial form + + + August 13, 1982 - 17 - RFC #822 + + + + Standard for ARPA Internet Text Messages + + + ";" date-time ; time received + + originator = authentic ; authenticated addr + [ "Reply-To" ":" 1#address] ) + + authentic = "From" ":" mailbox ; Single author + / ( "Sender" ":" mailbox ; Actual submittor + "From" ":" 1#mailbox) ; Multiple authors + ; or not sender + + resent = resent-authentic + [ "Resent-Reply-To" ":" 1#address] ) + + resent-authentic = + = "Resent-From" ":" mailbox + / ( "Resent-Sender" ":" mailbox + "Resent-From" ":" 1#mailbox ) + + dates = orig-date ; Original + [ resent-date ] ; Forwarded + + orig-date = "Date" ":" date-time + + resent-date = "Resent-Date" ":" date-time + + destination = "To" ":" 1#address ; Primary + / "Resent-To" ":" 1#address + / "cc" ":" 1#address ; Secondary + / "Resent-cc" ":" 1#address + / "bcc" ":" #address ; Blind carbon + / "Resent-bcc" ":" #address + + optional-field = + / "Message-ID" ":" msg-id + / "Resent-Message-ID" ":" msg-id + / "In-Reply-To" ":" *(phrase / msg-id) + / "References" ":" *(phrase / msg-id) + / "Keywords" ":" #phrase + / "Subject" ":" *text + / "Comments" ":" *text + / "Encrypted" ":" 1#2word + / extension-field ; To be defined + / user-defined-field ; May be pre-empted + + msg-id = "<" addr-spec ">" ; Unique message id + + + + + + + August 13, 1982 - 18 - RFC #822 + + + + Standard for ARPA Internet Text Messages + + + extension-field = + + + user-defined-field = + + + 4.2. FORWARDING + + Some systems permit mail recipients to forward a message, + retaining the original headers, by adding some new fields. This + standard supports such a service, through the "Resent-" prefix to + field names. + + Whenever the string "Resent-" begins a field name, the field + has the same semantics as a field whose name does not have the + prefix. However, the message is assumed to have been forwarded + by an original recipient who attached the "Resent-" field. This + new field is treated as being more recent than the equivalent, + original field. For example, the "Resent-From", indicates the + person that forwarded the message, whereas the "From" field indi- + cates the original author. + + Use of such precedence information depends upon partici- + pants' communication needs. For example, this standard does not + dictate when a "Resent-From:" address should receive replies, in + lieu of sending them to the "From:" address. + + Note: In general, the "Resent-" fields should be treated as con- + taining a set of information that is independent of the + set of original fields. Information for one set should + not automatically be taken from the other. The interpre- + tation of multiple "Resent-" fields, of the same type, is + undefined. + + In the remainder of this specification, occurrence of legal + "Resent-" fields are treated identically with the occurrence of + + + + + + + + + August 13, 1982 - 19 - RFC #822 + + + + Standard for ARPA Internet Text Messages + + + fields whose names do not contain this prefix. + + 4.3. TRACE FIELDS + + Trace information is used to provide an audit trail of mes- + sage handling. In addition, it indicates a route back to the + sender of the message. + + The list of known "via" and "with" values are registered + with the Network Information Center, SRI International, Menlo + Park, California. + + 4.3.1. RETURN-PATH + + This field is added by the final transport system that + delivers the message to its recipient. The field is intended + to contain definitive information about the address and route + back to the message's originator. + + Note: The "Reply-To" field is added by the originator and + serves to direct replies, whereas the "Return-Path" + field is used to identify a path back to the origina- + tor. + + While the syntax indicates that a route specification is + optional, every attempt should be made to provide that infor- + mation in this field. + + 4.3.2. RECEIVED + + A copy of this field is added by each transport service that + relays the message. The information in the field can be quite + useful for tracing transport problems. + + The names of the sending and receiving hosts and time-of- + receipt may be specified. The "via" parameter may be used, to + indicate what physical mechanism the message was sent over, + such as Arpanet or Phonenet, and the "with" parameter may be + used to indicate the mail-, or connection-, level protocol + that was used, such as the SMTP mail protocol, or X.25 tran- + sport protocol. + + Note: Several "with" parameters may be included, to fully + specify the set of protocols that were used. + + Some transport services queue mail; the internal message iden- + tifier that is assigned to the message may be noted, using the + "id" parameter. When the sending host uses a destination + address specification that the receiving host reinterprets, by + + + August 13, 1982 - 20 - RFC #822 + + + + Standard for ARPA Internet Text Messages + + + expansion or transformation, the receiving host may wish to + record the original specification, using the "for" parameter. + For example, when a copy of mail is sent to the member of a + distribution list, this parameter may be used to record the + original address that was used to specify the list. + + 4.4. ORIGINATOR FIELDS + + The standard allows only a subset of the combinations possi- + ble with the From, Sender, Reply-To, Resent-From, Resent-Sender, + and Resent-Reply-To fields. The limitation is intentional. + + 4.4.1. FROM / RESENT-FROM + + This field contains the identity of the person(s) who wished + this message to be sent. The message-creation process should + default this field to be a single, authenticated machine + address, indicating the AGENT (person, system or process) + entering the message. If this is not done, the "Sender" field + MUST be present. If the "From" field IS defaulted this way, + the "Sender" field is optional and is redundant with the + "From" field. In all cases, addresses in the "From" field + must be machine-usable (addr-specs) and may not contain named + lists (groups). + + 4.4.2. SENDER / RESENT-SENDER + + This field contains the authenticated identity of the AGENT + (person, system or process) that sends the message. It is + intended for use when the sender is not the author of the mes- + sage, or to indicate who among a group of authors actually + sent the message. If the contents of the "Sender" field would + be completely redundant with the "From" field, then the + "Sender" field need not be present and its use is discouraged + (though still legal). In particular, the "Sender" field MUST + be present if it is NOT the same as the "From" Field. + + The Sender mailbox specification includes a word sequence + which must correspond to a specific agent (i.e., a human user + or a computer program) rather than a standard address. This + indicates the expectation that the field will identify the + single AGENT (person, system, or process) responsible for + sending the mail and not simply include the name of a mailbox + from which the mail was sent. For example in the case of a + shared login name, the name, by itself, would not be adequate. + The local-part address unit, which refers to this agent, is + expected to be a computer system term, and not (for example) a + generalized person reference which can be used outside the + network text message context. + + + August 13, 1982 - 21 - RFC #822 + + + + Standard for ARPA Internet Text Messages + + + Since the critical function served by the "Sender" field is + identification of the agent responsible for sending mail and + since computer programs cannot be held accountable for their + behavior, it is strongly recommended that when a computer pro- + gram generates a message, the HUMAN who is responsible for + that program be referenced as part of the "Sender" field mail- + box specification. + + 4.4.3. REPLY-TO / RESENT-REPLY-TO + + This field provides a general mechanism for indicating any + mailbox(es) to which responses are to be sent. Three typical + uses for this feature can be distinguished. In the first + case, the author(s) may not have regular machine-based mail- + boxes and therefore wish(es) to indicate an alternate machine + address. In the second case, an author may wish additional + persons to be made aware of, or responsible for, replies. A + somewhat different use may be of some help to "text message + teleconferencing" groups equipped with automatic distribution + services: include the address of that service in the "Reply- + To" field of all messages submitted to the teleconference; + then participants can "reply" to conference submissions to + guarantee the correct distribution of any submission of their + own. + + Note: The "Return-Path" field is added by the mail transport + service, at the time of final deliver. It is intended + to identify a path back to the orginator of the mes- + sage. The "Reply-To" field is added by the message + originator and is intended to direct replies. + + 4.4.4. AUTOMATIC USE OF FROM / SENDER / REPLY-TO + + For systems which automatically generate address lists for + replies to messages, the following recommendations are made: + + o The "Sender" field mailbox should be sent notices of + any problems in transport or delivery of the original + messages. If there is no "Sender" field, then the + "From" field mailbox should be used. + + o The "Sender" field mailbox should NEVER be used + automatically, in a recipient's reply message. + + o If the "Reply-To" field exists, then the reply should + go to the addresses indicated in that field and not to + the address(es) indicated in the "From" field. + + + + + August 13, 1982 - 22 - RFC #822 + + + + Standard for ARPA Internet Text Messages + + + o If there is a "From" field, but no "Reply-To" field, + the reply should be sent to the address(es) indicated + in the "From" field. + + Sometimes, a recipient may actually wish to communicate with + the person that initiated the message transfer. In such + cases, it is reasonable to use the "Sender" address. + + This recommendation is intended only for automated use of + originator-fields and is not intended to suggest that replies + may not also be sent to other recipients of messages. It is + up to the respective mail-handling programs to decide what + additional facilities will be provided. + + Examples are provided in Appendix A. + + 4.5. RECEIVER FIELDS + + 4.5.1. TO / RESENT-TO + + This field contains the identity of the primary recipients of + the message. + + 4.5.2. CC / RESENT-CC + + This field contains the identity of the secondary (informa- + tional) recipients of the message. + + 4.5.3. BCC / RESENT-BCC + + This field contains the identity of additional recipients of + the message. The contents of this field are not included in + copies of the message sent to the primary and secondary reci- + pients. Some systems may choose to include the text of the + "Bcc" field only in the author(s)'s copy, while others may + also include it in the text sent to all those indicated in the + "Bcc" list. + + 4.6. REFERENCE FIELDS + + 4.6.1. MESSAGE-ID / RESENT-MESSAGE-ID + + This field contains a unique identifier (the local-part + address unit) which refers to THIS version of THIS message. + The uniqueness of the message identifier is guaranteed by the + host which generates it. This identifier is intended to be + machine readable and not necessarily meaningful to humans. A + message identifier pertains to exactly one instantiation of a + particular message; subsequent revisions to the message should + + + August 13, 1982 - 23 - RFC #822 + + + + Standard for ARPA Internet Text Messages + + + each receive new message identifiers. + + 4.6.2. IN-REPLY-TO + + The contents of this field identify previous correspon- + dence which this message answers. Note that if message iden- + tifiers are used in this field, they must use the msg-id + specification format. + + 4.6.3. REFERENCES + + The contents of this field identify other correspondence + which this message references. Note that if message identif- + iers are used, they must use the msg-id specification format. + + 4.6.4. KEYWORDS + + This field contains keywords or phrases, separated by + commas. + + 4.7. OTHER FIELDS + + 4.7.1. SUBJECT + + This is intended to provide a summary, or indicate the + nature, of the message. + + 4.7.2. COMMENTS + + Permits adding text comments onto the message without + disturbing the contents of the message's body. + + 4.7.3. ENCRYPTED + + Sometimes, data encryption is used to increase the + privacy of message contents. If the body of a message has + been encrypted, to keep its contents private, the "Encrypted" + field can be used to note the fact and to indicate the nature + of the encryption. The first parameter indicates the + software used to encrypt the body, and the second, optional + is intended to aid the recipient in selecting the + proper decryption key. This code word may be viewed as an + index to a table of keys held by the recipient. + + Note: Unfortunately, headers must contain envelope, as well + as contents, information. Consequently, it is neces- + sary that they remain unencrypted, so that mail tran- + sport services may access them. Since names, + addresses, and "Subject" field contents may contain + + + August 13, 1982 - 24 - RFC #822 + + + + Standard for ARPA Internet Text Messages + + + sensitive information, this requirement limits total + message privacy. + + Names of encryption software are registered with the Net- + work Information Center, SRI International, Menlo Park, Cali- + fornia. + + 4.7.4. EXTENSION-FIELD + + A limited number of common fields have been defined in + this document. As network mail requirements dictate, addi- + tional fields may be standardized. To provide user-defined + fields with a measure of safety, in name selection, such + extension-fields will never have names that begin with the + string "X-". + + Names of Extension-fields are registered with the Network + Information Center, SRI International, Menlo Park, California. + + 4.7.5. USER-DEFINED-FIELD + + Individual users of network mail are free to define and + use additional header fields. Such fields must have names + which are not already used in the current specification or in + any definitions of extension-fields, and the overall syntax of + these user-defined-fields must conform to this specification's + rules for delimiting and folding fields. Due to the + extension-field publishing process, the name of a user- + defined-field may be pre-empted + + Note: The prefatory string "X-" will never be used in the + names of Extension-fields. This provides user-defined + fields with a protected set of names. + + + + + + + + + + + + + + + + + + + August 13, 1982 - 25 - RFC #822 + + + + Standard for ARPA Internet Text Messages + + + 5. DATE AND TIME SPECIFICATION + + 5.1. SYNTAX + + date-time = [ day "," ] date time ; dd mm yy + ; hh:mm:ss zzz + + day = "Mon" / "Tue" / "Wed" / "Thu" + / "Fri" / "Sat" / "Sun" + + date = 1*2DIGIT month 2DIGIT ; day month year + ; e.g. 20 Jun 82 + + month = "Jan" / "Feb" / "Mar" / "Apr" + / "May" / "Jun" / "Jul" / "Aug" + / "Sep" / "Oct" / "Nov" / "Dec" + + time = hour zone ; ANSI and Military + + hour = 2DIGIT ":" 2DIGIT [":" 2DIGIT] + ; 00:00:00 - 23:59:59 + + zone = "UT" / "GMT" ; Universal Time + ; North American : UT + / "EST" / "EDT" ; Eastern: - 5/ - 4 + / "CST" / "CDT" ; Central: - 6/ - 5 + / "MST" / "MDT" ; Mountain: - 7/ - 6 + / "PST" / "PDT" ; Pacific: - 8/ - 7 + / 1ALPHA ; Military: Z = UT; + ; A:-1; (J not used) + ; M:-12; N:+1; Y:+12 + / ( ("+" / "-") 4DIGIT ) ; Local differential + ; hours+min. (HHMM) + + 5.2. SEMANTICS + + If included, day-of-week must be the day implied by the date + specification. + + Time zone may be indicated in several ways. "UT" is Univer- + sal Time (formerly called "Greenwich Mean Time"); "GMT" is per- + mitted as a reference to Universal Time. The military standard + uses a single character for each zone. "Z" is Universal Time. + "A" indicates one hour earlier, and "M" indicates 12 hours ear- + lier; "N" is one hour later, and "Y" is 12 hours later. The + letter "J" is not used. The other remaining two forms are taken + from ANSI standard X3.51-1975. One allows explicit indication of + the amount of offset from UT; the other uses common 3-character + strings for indicating time zones in North America. + + + August 13, 1982 - 26 - RFC #822 + + + + Standard for ARPA Internet Text Messages + + + 6. ADDRESS SPECIFICATION + + 6.1. SYNTAX + + address = mailbox ; one addressee + / group ; named list + + group = phrase ":" [#mailbox] ";" + + mailbox = addr-spec ; simple address + / phrase route-addr ; name & addr-spec + + route-addr = "<" [route] addr-spec ">" + + route = 1#("@" domain) ":" ; path-relative + + addr-spec = local-part "@" domain ; global address + + local-part = word *("." word) ; uninterpreted + ; case-preserved + + domain = sub-domain *("." sub-domain) + + sub-domain = domain-ref / domain-literal + + domain-ref = atom ; symbolic reference + + 6.2. SEMANTICS + + A mailbox receives mail. It is a conceptual entity which + does not necessarily pertain to file storage. For example, some + sites may choose to print mail on their line printer and deliver + the output to the addressee's desk. + + A mailbox specification comprises a person, system or pro- + cess name reference, a domain-dependent string, and a name-domain + reference. The name reference is optional and is usually used to + indicate the human name of a recipient. The name-domain refer- + ence specifies a sequence of sub-domains. The domain-dependent + string is uninterpreted, except by the final sub-domain; the rest + of the mail service merely transmits it as a literal string. + + 6.2.1. DOMAINS + + A name-domain is a set of registered (mail) names. A name- + domain specification resolves to a subordinate name-domain + specification or to a terminal domain-dependent string. + Hence, domain specification is extensible, permitting any + number of registration levels. + + + August 13, 1982 - 27 - RFC #822 + + + + Standard for ARPA Internet Text Messages + + + Name-domains model a global, logical, hierarchical addressing + scheme. The model is logical, in that an address specifica- + tion is related to name registration and is not necessarily + tied to transmission path. The model's hierarchy is a + directed graph, called an in-tree, such that there is a single + path from the root of the tree to any node in the hierarchy. + If more than one path actually exists, they are considered to + be different addresses. + + The root node is common to all addresses; consequently, it is + not referenced. Its children constitute "top-level" name- + domains. Usually, a service has access to its own full domain + specification and to the names of all top-level name-domains. + + The "top" of the domain addressing hierarchy -- a child of the + root -- is indicated by the right-most field, in a domain + specification. Its child is specified to the left, its child + to the left, and so on. + + Some groups provide formal registration services; these con- + stitute name-domains that are independent logically of + specific machines. In addition, networks and machines impli- + citly compose name-domains, since their membership usually is + registered in name tables. + + In the case of formal registration, an organization implements + a (distributed) data base which provides an address-to-route + mapping service for addresses of the form: + + person@registry.organization + + Note that "organization" is a logical entity, separate from + any particular communication network. + + A mechanism for accessing "organization" is universally avail- + able. That mechanism, in turn, seeks an instantiation of the + registry; its location is not indicated in the address specif- + ication. It is assumed that the system which operates under + the name "organization" knows how to find a subordinate regis- + try. The registry will then use the "person" string to deter- + mine where to send the mail specification. + + The latter, network-oriented case permits simple, direct, + attachment-related address specification, such as: + + user@host.network + + Once the network is accessed, it is expected that a message + will go directly to the host and that the host will resolve + + + August 13, 1982 - 28 - RFC #822 + + + + Standard for ARPA Internet Text Messages + + + the user name, placing the message in the user's mailbox. + + 6.2.2. ABBREVIATED DOMAIN SPECIFICATION + + Since any number of levels is possible within the domain + hierarchy, specification of a fully qualified address can + become inconvenient. This standard permits abbreviated domain + specification, in a special case: + + For the address of the sender, call the left-most + sub-domain Level N. In a header address, if all of + the sub-domains above (i.e., to the right of) Level N + are the same as those of the sender, then they do not + have to appear in the specification. Otherwise, the + address must be fully qualified. + + This feature is subject to approval by local sub- + domains. Individual sub-domains may require their + member systems, which originate mail, to provide full + domain specification only. When permitted, abbrevia- + tions may be present only while the message stays + within the sub-domain of the sender. + + Use of this mechanism requires the sender's sub-domain + to reserve the names of all top-level domains, so that + full specifications can be distinguished from abbrevi- + ated specifications. + + For example, if a sender's address is: + + sender@registry-A.registry-1.organization-X + + and one recipient's address is: + + recipient@registry-B.registry-1.organization-X + + and another's is: + + recipient@registry-C.registry-2.organization-X + + then ".registry-1.organization-X" need not be specified in the + the message, but "registry-C.registry-2" DOES have to be + specified. That is, the first two addresses may be abbrevi- + ated, but the third address must be fully specified. + + When a message crosses a domain boundary, all addresses must + be specified in the full format, ending with the top-level + name-domain in the right-most field. It is the responsibility + of mail forwarding services to ensure that addresses conform + + + August 13, 1982 - 29 - RFC #822 + + + + Standard for ARPA Internet Text Messages + + + with this requirement. In the case of abbreviated addresses, + the relaying service must make the necessary expansions. It + should be noted that it often is difficult for such a service + to locate all occurrences of address abbreviations. For exam- + ple, it will not be possible to find such abbreviations within + the body of the message. The "Return-Path" field can aid + recipients in recovering from these errors. + + Note: When passing any portion of an addr-spec onto a process + which does not interpret data according to this stan- + dard (e.g., mail protocol servers). There must be NO + LWSP-chars preceding or following the at-sign or any + delimiting period ("."), such as shown in the above + examples, and only ONE SPACE between contiguous + s. + + 6.2.3. DOMAIN TERMS + + A domain-ref must be THE official name of a registry, network, + or host. It is a symbolic reference, within a name sub- + domain. At times, it is necessary to bypass standard mechan- + isms for resolving such references, using more primitive + information, such as a network host address rather than its + associated host name. + + To permit such references, this standard provides the domain- + literal construct. Its contents must conform with the needs + of the sub-domain in which it is interpreted. + + Domain-literals which refer to domains within the ARPA Inter- + net specify 32-bit Internet addresses, in four 8-bit fields + noted in decimal, as described in Request for Comments #820, + "Assigned Numbers." For example: + + [10.0.3.19] + + Note: THE USE OF DOMAIN-LITERALS IS STRONGLY DISCOURAGED. It + is permitted only as a means of bypassing temporary + system limitations, such as name tables which are not + complete. + + The names of "top-level" domains, and the names of domains + under in the ARPA Internet, are registered with the Network + Information Center, SRI International, Menlo Park, California. + + 6.2.4. DOMAIN-DEPENDENT LOCAL STRING + + The local-part of an addr-spec in a mailbox specification + (i.e., the host's name for the mailbox) is understood to be + + + August 13, 1982 - 30 - RFC #822 + + + + Standard for ARPA Internet Text Messages + + + whatever the receiving mail protocol server allows. For exam- + ple, some systems do not understand mailbox references of the + form "P. D. Q. Bach", but others do. + + This specification treats periods (".") as lexical separators. + Hence, their presence in local-parts which are not quoted- + strings, is detected. However, such occurrences carry NO + semantics. That is, if a local-part has periods within it, an + address parser will divide the local-part into several tokens, + but the sequence of tokens will be treated as one uninter- + preted unit. The sequence will be re-assembled, when the + address is passed outside of the system such as to a mail pro- + tocol service. + + For example, the address: + + First.Last@Registry.Org + + is legal and does not require the local-part to be surrounded + with quotation-marks. (However, "First Last" DOES require + quoting.) The local-part of the address, when passed outside + of the mail system, within the Registry.Org domain, is + "First.Last", again without quotation marks. + + 6.2.5. BALANCING LOCAL-PART AND DOMAIN + + In some cases, the boundary between local-part and domain can + be flexible. The local-part may be a simple string, which is + used for the final determination of the recipient's mailbox. + All other levels of reference are, therefore, part of the + domain. + + For some systems, in the case of abbreviated reference to the + local and subordinate sub-domains, it may be possible to + specify only one reference within the domain part and place + the other, subordinate name-domain references within the + local-part. This would appear as: + + mailbox.sub1.sub2@this-domain + + Such a specification would be acceptable to address parsers + which conform to RFC #733, but do not support this newer + Internet standard. While contrary to the intent of this stan- + dard, the form is legal. + + Also, some sub-domains have a specification syntax which does + not conform to this standard. For example: + + sub-net.mailbox@sub-domain.domain + + + August 13, 1982 - 31 - RFC #822 + + + + Standard for ARPA Internet Text Messages + + + uses a different parsing sequence for local-part than for + domain. + + Note: As a rule, the domain specification should contain + fields which are encoded according to the syntax of + this standard and which contain generally-standardized + information. The local-part specification should con- + tain only that portion of the address which deviates + from the form or intention of the domain field. + + 6.2.6. MULTIPLE MAILBOXES + + An individual may have several mailboxes and wish to receive + mail at whatever mailbox is convenient for the sender to + access. This standard does not provide a means of specifying + "any member of" a list of mailboxes. + + A set of individuals may wish to receive mail as a single unit + (i.e., a distribution list). The construct permits + specification of such a list. Recipient mailboxes are speci- + fied within the bracketed part (":" - ";"). A copy of the + transmitted message is to be sent to each mailbox listed. + This standard does not permit recursive specification of + groups within groups. + + While a list must be named, it is not required that the con- + tents of the list be included. In this case, the
    + serves only as an indication of group distribution and would + appear in the form: + + name:; + + Some mail services may provide a group-list distribution + facility, accepting a single mailbox reference, expanding it + to the full distribution list, and relaying the mail to the + list's members. This standard provides no additional syntax + for indicating such a service. Using the address + alternative, while listing one mailbox in it, can mean either + that the mailbox reference will be expanded to a list or that + there is a group with one member. + + 6.2.7. EXPLICIT PATH SPECIFICATION + + At times, a message originator may wish to indicate the + transmission path that a message should follow. This is + called source routing. The normal addressing scheme, used in + an addr-spec, is carefully separated from such information; + the portion of a route-addr is provided for such occa- + sions. It specifies the sequence of hosts and/or transmission + + + August 13, 1982 - 32 - RFC #822 + + + + Standard for ARPA Internet Text Messages + + + services that are to be traversed. Both domain-refs and + domain-literals may be used. + + Note: The use of source routing is discouraged. Unless the + sender has special need of path restriction, the choice + of transmission route should be left to the mail tran- + sport service. + + 6.3. RESERVED ADDRESS + + It often is necessary to send mail to a site, without know- + ing any of its valid addresses. For example, there may be mail + system dysfunctions, or a user may wish to find out a person's + correct address, at that site. + + This standard specifies a single, reserved mailbox address + (local-part) which is to be valid at each site. Mail sent to + that address is to be routed to a person responsible for the + site's mail system or to a person with responsibility for general + site operation. The name of the reserved local-part address is: + + Postmaster + + so that "Postmaster@domain" is required to be valid. + + Note: This reserved local-part must be matched without sensi- + tivity to alphabetic case, so that "POSTMASTER", "postmas- + ter", and even "poStmASteR" is to be accepted. + + + + + + + + + + + + + + + + + + + + + + + + August 13, 1982 - 33 - RFC #822 + + + + Standard for ARPA Internet Text Messages + + + 7. BIBLIOGRAPHY + + + ANSI. "USA Standard Code for Information Interchange," X3.4. + American National Standards Institute: New York (1968). Also + in: Feinler, E. and J. Postel, eds., "ARPANET Protocol Hand- + book", NIC 7104. + + ANSI. "Representations of Universal Time, Local Time Differen- + tials, and United States Time Zone References for Information + Interchange," X3.51-1975. American National Standards Insti- + tute: New York (1975). + + Bemer, R.W., "Time and the Computer." In: Interface Age (Feb. + 1979). + + Bennett, C.J. "JNT Mail Protocol". Joint Network Team, Ruther- + ford and Appleton Laboratory: Didcot, England. + + Bhushan, A.K., Pogran, K.T., Tomlinson, R.S., and White, J.E. + "Standardizing Network Mail Headers," ARPANET Request for + Comments No. 561, Network Information Center No. 18516; SRI + International: Menlo Park (September 1973). + + Birrell, A.D., Levin, R., Needham, R.M., and Schroeder, M.D. + "Grapevine: An Exercise in Distributed Computing," Communica- + tions of the ACM 25, 4 (April 1982), 260-274. + + Crocker, D.H., Vittal, J.J., Pogran, K.T., Henderson, D.A. + "Standard for the Format of ARPA Network Text Message," + ARPANET Request for Comments No. 733, Network Information + Center No. 41952. SRI International: Menlo Park (November + 1977). + + Feinler, E.J. and Postel, J.B. ARPANET Protocol Handbook, Net- + work Information Center No. 7104 (NTIS AD A003890). SRI + International: Menlo Park (April 1976). + + Harary, F. "Graph Theory". Addison-Wesley: Reading, Mass. + (1969). + + Levin, R. and Schroeder, M. "Transport of Electronic Messages + through a Network," TeleInformatics 79, pp. 29-33. North + Holland (1979). Also as Xerox Palo Alto Research Center + Technical Report CSL-79-4. + + Myer, T.H. and Henderson, D.A. "Message Transmission Protocol," + ARPANET Request for Comments, No. 680, Network Information + Center No. 32116. SRI International: Menlo Park (1975). + + + August 13, 1982 - 34 - RFC #822 + + + + Standard for ARPA Internet Text Messages + + + NBS. "Specification of Message Format for Computer Based Message + Systems, Recommended Federal Information Processing Standard." + National Bureau of Standards: Gaithersburg, Maryland + (October 1981). + + NIC. Internet Protocol Transition Workbook. Network Information + Center, SRI-International, Menlo Park, California (March + 1982). + + Oppen, D.C. and Dalal, Y.K. "The Clearinghouse: A Decentralized + Agent for Locating Named Objects in a Distributed Environ- + ment," OPD-T8103. Xerox Office Products Division: Palo Alto, + CA. (October 1981). + + Postel, J.B. "Assigned Numbers," ARPANET Request for Comments, + No. 820. SRI International: Menlo Park (August 1982). + + Postel, J.B. "Simple Mail Transfer Protocol," ARPANET Request + for Comments, No. 821. SRI International: Menlo Park (August + 1982). + + Shoch, J.F. "Internetwork naming, addressing and routing," in + Proc. 17th IEEE Computer Society International Conference, pp. + 72-79, Sept. 1978, IEEE Cat. No. 78 CH 1388-8C. + + Su, Z. and Postel, J. "The Domain Naming Convention for Internet + User Applications," ARPANET Request for Comments, No. 819. + SRI International: Menlo Park (August 1982). + + + + + + + + + + + + + + + + + + + + + + + + August 13, 1982 - 35 - RFC #822 + + + + Standard for ARPA Internet Text Messages + + + APPENDIX + + + A. EXAMPLES + + A.1. ADDRESSES + + A.1.1. Alfred Neuman + + A.1.2. Neuman@BBN-TENEXA + + These two "Alfred Neuman" examples have identical seman- + tics, as far as the operation of the local host's mail sending + (distribution) program (also sometimes called its "mailer") + and the remote host's mail protocol server are concerned. In + the first example, the "Alfred Neuman" is ignored by the + mailer, as "Neuman@BBN-TENEXA" completely specifies the reci- + pient. The second example contains no superfluous informa- + tion, and, again, "Neuman@BBN-TENEXA" is the intended reci- + pient. + + Note: When the message crosses name-domain boundaries, then + these specifications must be changed, so as to indicate + the remainder of the hierarchy, starting with the top + level. + + A.1.3. "George, Ted" + + This form might be used to indicate that a single mailbox + is shared by several users. The quoted string is ignored by + the originating host's mailer, because "Shared@Group.Arpanet" + completely specifies the destination mailbox. + + A.1.4. Wilt . (the Stilt) Chamberlain@NBA.US + + The "(the Stilt)" is a comment, which is NOT included in + the destination mailbox address handed to the originating + system's mailer. The local-part of the address is the string + "Wilt.Chamberlain", with NO space between the first and second + words. + + A.1.5. Address Lists + + Gourmets: Pompous Person , + Childs@WGBH.Boston, Galloping Gourmet@ + ANT.Down-Under (Australian National Television), + Cheapie@Discount-Liquors;, + Cruisers: Port@Portugal, Jones@SEA;, + Another@Somewhere.SomeOrg + + + August 13, 1982 - 36 - RFC #822 + + + + Standard for ARPA Internet Text Messages + + + This group list example points out the use of comments and the + mixing of addresses and groups. + + A.2. ORIGINATOR ITEMS + + A.2.1. Author-sent + + George Jones logs into his host as "Jones". He sends + mail himself. + + From: Jones@Group.Org + + or + + From: George Jones + + A.2.2. Secretary-sent + + George Jones logs in as Jones on his host. His secre- + tary, who logs in as Secy sends mail for him. Replies to the + mail should go to George. + + From: George Jones + Sender: Secy@Other-Group + + A.2.3. Secretary-sent, for user of shared directory + + George Jones' secretary sends mail for George. Replies + should go to George. + + From: George Jones + Sender: Secy@Other-Group + + Note that there need not be a space between "Jones" and the + "<", but adding a space enhances readability (as is the case + in other examples. + + A.2.4. Committee activity, with one author + + George is a member of a committee. He wishes to have any + replies to his message go to all committee members. + + From: George Jones + Sender: Jones@Host + Reply-To: The Committee: Jones@Host.Net, + Smith@Other.Org, + Doe@Somewhere-Else; + + Note that if George had not included himself in the + + + August 13, 1982 - 37 - RFC #822 + + + + Standard for ARPA Internet Text Messages + + + enumeration of The Committee, he would not have gotten an + implicit reply; the presence of the "Reply-to" field SUPER- + SEDES the sending of a reply to the person named in the "From" + field. + + A.2.5. Secretary acting as full agent of author + + George Jones asks his secretary (Secy@Host) to send a + message for him in his capacity as Group. He wants his secre- + tary to handle all replies. + + From: George Jones + Sender: Secy@Host + Reply-To: Secy@Host + + A.2.6. Agent for user without online mailbox + + A friend of George's, Sarah, is visiting. George's + secretary sends some mail to a friend of Sarah in computer- + land. Replies should go to George, whose mailbox is Jones at + Registry. + + From: Sarah Friendly + Sender: Secy-Name + Reply-To: Jones@Registry. + + A.2.7. Agent for member of a committee + + George's secretary sends out a message which was authored + jointly by all the members of a committee. Note that the name + of the committee cannot be specified, since names are + not permitted in the From field. + + From: Jones@Host, + Smith@Other-Host, + Doe@Somewhere-Else + Sender: Secy@SHost + + + + + + + + + + + + + + + August 13, 1982 - 38 - RFC #822 + + + + Standard for ARPA Internet Text Messages + + + A.3. COMPLETE HEADERS + + A.3.1. Minimum required + + Date: 26 Aug 76 1429 EDT Date: 26 Aug 76 1429 EDT + From: Jones@Registry.Org or From: Jones@Registry.Org + Bcc: To: Smith@Registry.Org + + Note that the "Bcc" field may be empty, while the "To" field + is required to have at least one address. + + A.3.2. Using some of the additional fields + + Date: 26 Aug 76 1430 EDT + From: George Jones + Sender: Secy@SHOST + To: "Al Neuman"@Mad-Host, + Sam.Irving@Other-Host + Message-ID: + + A.3.3. About as complex as you're going to get + + Date : 27 Aug 76 0932 PDT + From : Ken Davis + Subject : Re: The Syntax in the RFC + Sender : KSecy@Other-Host + Reply-To : Sam.Irving@Reg.Organization + To : George Jones , + Al.Neuman@MAD.Publisher + cc : Important folk: + Tom Softwood , + "Sam Irving"@Other-Host;, + Standard Distribution: + /main/davis/people/standard@Other-Host, + "standard.dist.3"@Tops-20-Host>; + Comment : Sam is away on business. He asked me to handle + his mail for him. He'll be able to provide a + more accurate explanation when he returns + next week. + In-Reply-To: , George's message + X-Special-action: This is a sample of user-defined field- + names. There could also be a field-name + "Special-action", but its name might later be + preempted + Message-ID: <4231.629.XYzi-What@Other-Host> + + + + + + + August 13, 1982 - 39 - RFC #822 + + + + Standard for ARPA Internet Text Messages + + + B. SIMPLE FIELD PARSING + + Some mail-reading software systems may wish to perform only + minimal processing, ignoring the internal syntax of structured + field-bodies and treating them the same as unstructured-field- + bodies. Such software will need only to distinguish: + + o Header fields from the message body, + + o Beginnings of fields from lines which continue fields, + + o Field-names from field-contents. + + The abbreviated set of syntactic rules which follows will + suffice for this purpose. It describes a limited view of mes- + sages and is a subset of the syntactic rules provided in the main + part of this specification. One small exception is that the con- + tents of field-bodies consist only of text: + + B.1. SYNTAX + + + message = *field *(CRLF *text) + + field = field-name ":" [field-body] CRLF + + field-name = 1* + + field-body = *text [CRLF LWSP-char field-body] + + + B.2. SEMANTICS + + Headers occur before the message body and are terminated by + a null line (i.e., two contiguous CRLFs). + + A line which continues a header field begins with a SPACE or + HTAB character, while a line beginning a field starts with a + printable character which is not a colon. + + A field-name consists of one or more printable characters + (excluding colon, space, and control-characters). A field-name + MUST be contained on one line. Upper and lower case are not dis- + tinguished when comparing field-names. + + + + + + + + August 13, 1982 - 40 - RFC #822 + + + + Standard for ARPA Internet Text Messages + + + C. DIFFERENCES FROM RFC #733 + + The following summarizes the differences between this stan- + dard and the one specified in Arpanet Request for Comments #733, + "Standard for the Format of ARPA Network Text Messages". The + differences are listed in the order of their occurrence in the + current specification. + + C.1. FIELD DEFINITIONS + + C.1.1. FIELD NAMES + + These now must be a sequence of printable characters. They + may not contain any LWSP-chars. + + C.2. LEXICAL TOKENS + + C.2.1. SPECIALS + + The characters period ("."), left-square bracket ("["), and + right-square bracket ("]") have been added. For presentation + purposes, and when passing a specification to a system that + does not conform to this standard, periods are to be contigu- + ous with their surrounding lexical tokens. No linear-white- + space is permitted between them. The presence of one LWSP- + char between other tokens is still directed. + + C.2.2. ATOM + + Atoms may not contain SPACE. + + C.2.3. SPECIAL TEXT + + ctext and qtext have had backslash ("\") added to the list of + prohibited characters. + + C.2.4. DOMAINS + + The lexical tokens and have been + added. + + C.3. MESSAGE SPECIFICATION + + C.3.1. TRACE + + The "Return-path:" and "Received:" fields have been specified. + + + + + + August 13, 1982 - 41 - RFC #822 + + + + Standard for ARPA Internet Text Messages + + + C.3.2. FROM + + The "From" field must contain machine-usable addresses (addr- + spec). Multiple addresses may be specified, but named-lists + (groups) may not. + + C.3.3. RESENT + + The meta-construct of prefacing field names with the string + "Resent-" has been added, to indicate that a message has been + forwarded by an intermediate recipient. + + C.3.4. DESTINATION + + A message must contain at least one destination address field. + "To" and "CC" are required to contain at least one address. + + C.3.5. IN-REPLY-TO + + The field-body is no longer a comma-separated list, although a + sequence is still permitted. + + C.3.6. REFERENCE + + The field-body is no longer a comma-separated list, although a + sequence is still permitted. + + C.3.7. ENCRYPTED + + A field has been specified that permits senders to indicate + that the body of a message has been encrypted. + + C.3.8. EXTENSION-FIELD + + Extension fields are prohibited from beginning with the char- + acters "X-". + + C.4. DATE AND TIME SPECIFICATION + + C.4.1. SIMPLIFICATION + + Fewer optional forms are permitted and the list of three- + letter time zones has been shortened. + + C.5. ADDRESS SPECIFICATION + + + + + + + August 13, 1982 - 42 - RFC #822 + + + + Standard for ARPA Internet Text Messages + + + C.5.1. ADDRESS + + The use of quoted-string, and the ":"-atom-":" construct, have + been removed. An address now is either a single mailbox + reference or is a named list of addresses. The latter indi- + cates a group distribution. + + C.5.2. GROUPS + + Group lists are now required to to have a name. Group lists + may not be nested. + + C.5.3. MAILBOX + + A mailbox specification may indicate a person's name, as + before. Such a named list no longer may specify multiple + mailboxes and may not be nested. + + C.5.4. ROUTE ADDRESSING + + Addresses now are taken to be absolute, global specifications, + independent of transmission paths. The construct has + been provided, to permit explicit specification of transmis- + sion path. RFC #733's use of multiple at-signs ("@") was + intended as a general syntax for indicating routing and/or + hierarchical addressing. The current standard separates these + specifications and only one at-sign is permitted. + + C.5.5. AT-SIGN + + The string " at " no longer is used as an address delimiter. + Only at-sign ("@") serves the function. + + C.5.6. DOMAINS + + Hierarchical, logical name-domains have been added. + + C.6. RESERVED ADDRESS + + The local-part "Postmaster" has been reserved, so that users can + be guaranteed at least one valid address at a site. + + + + + + + + + + + August 13, 1982 - 43 - RFC #822 + + + + Standard for ARPA Internet Text Messages + + + D. ALPHABETICAL LISTING OF SYNTAX RULES + + address = mailbox ; one addressee + / group ; named list + addr-spec = local-part "@" domain ; global address + ALPHA = + ; (101-132, 65.- 90.) + ; (141-172, 97.-122.) + atom = 1* + authentic = "From" ":" mailbox ; Single author + / ( "Sender" ":" mailbox ; Actual submittor + "From" ":" 1#mailbox) ; Multiple authors + ; or not sender + CHAR = ; ( 0-177, 0.-127.) + comment = "(" *(ctext / quoted-pair / comment) ")" + CR = ; ( 15, 13.) + CRLF = CR LF + ctext = may be folded + ")", "\" & CR, & including + linear-white-space> + CTL = ; ( 177, 127.) + date = 1*2DIGIT month 2DIGIT ; day month year + ; e.g. 20 Jun 82 + dates = orig-date ; Original + [ resent-date ] ; Forwarded + date-time = [ day "," ] date time ; dd mm yy + ; hh:mm:ss zzz + day = "Mon" / "Tue" / "Wed" / "Thu" + / "Fri" / "Sat" / "Sun" + delimiters = specials / linear-white-space / comment + destination = "To" ":" 1#address ; Primary + / "Resent-To" ":" 1#address + / "cc" ":" 1#address ; Secondary + / "Resent-cc" ":" 1#address + / "bcc" ":" #address ; Blind carbon + / "Resent-bcc" ":" #address + DIGIT = ; ( 60- 71, 48.- 57.) + domain = sub-domain *("." sub-domain) + domain-literal = "[" *(dtext / quoted-pair) "]" + domain-ref = atom ; symbolic reference + dtext = may be folded + "]", "\" & CR, & including + linear-white-space> + extension-field = + + + + August 13, 1982 - 44 - RFC #822 + + + + Standard for ARPA Internet Text Messages + + + field = field-name ":" [ field-body ] CRLF + fields = dates ; Creation time, + source ; author id & one + 1*destination ; address required + *optional-field ; others optional + field-body = field-body-contents + [CRLF LWSP-char field-body] + field-body-contents = + + field-name = 1* + group = phrase ":" [#mailbox] ";" + hour = 2DIGIT ":" 2DIGIT [":" 2DIGIT] + ; 00:00:00 - 23:59:59 + HTAB = ; ( 11, 9.) + LF = ; ( 12, 10.) + linear-white-space = 1*([CRLF] LWSP-char) ; semantics = SPACE + ; CRLF => folding + local-part = word *("." word) ; uninterpreted + ; case-preserved + LWSP-char = SPACE / HTAB ; semantics = SPACE + mailbox = addr-spec ; simple address + / phrase route-addr ; name & addr-spec + message = fields *( CRLF *text ) ; Everything after + ; first null line + ; is message body + month = "Jan" / "Feb" / "Mar" / "Apr" + / "May" / "Jun" / "Jul" / "Aug" + / "Sep" / "Oct" / "Nov" / "Dec" + msg-id = "<" addr-spec ">" ; Unique message id + optional-field = + / "Message-ID" ":" msg-id + / "Resent-Message-ID" ":" msg-id + / "In-Reply-To" ":" *(phrase / msg-id) + / "References" ":" *(phrase / msg-id) + / "Keywords" ":" #phrase + / "Subject" ":" *text + / "Comments" ":" *text + / "Encrypted" ":" 1#2word + / extension-field ; To be defined + / user-defined-field ; May be pre-empted + orig-date = "Date" ":" date-time + originator = authentic ; authenticated addr + [ "Reply-To" ":" 1#address] ) + phrase = 1*word ; Sequence of words + + + + + August 13, 1982 - 45 - RFC #822 + + + + Standard for ARPA Internet Text Messages + + + qtext = , ; => may be folded + "\" & CR, and including + linear-white-space> + quoted-pair = "\" CHAR ; may quote any char + quoted-string = <"> *(qtext/quoted-pair) <">; Regular qtext or + ; quoted chars. + received = "Received" ":" ; one per relay + ["from" domain] ; sending host + ["by" domain] ; receiving host + ["via" atom] ; physical path + *("with" atom) ; link/mail protocol + ["id" msg-id] ; receiver msg id + ["for" addr-spec] ; initial form + ";" date-time ; time received + + resent = resent-authentic + [ "Resent-Reply-To" ":" 1#address] ) + resent-authentic = + = "Resent-From" ":" mailbox + / ( "Resent-Sender" ":" mailbox + "Resent-From" ":" 1#mailbox ) + resent-date = "Resent-Date" ":" date-time + return = "Return-path" ":" route-addr ; return address + route = 1#("@" domain) ":" ; path-relative + route-addr = "<" [route] addr-spec ">" + source = [ trace ] ; net traversals + originator ; original mail + [ resent ] ; forwarded + SPACE = ; ( 40, 32.) + specials = "(" / ")" / "<" / ">" / "@" ; Must be in quoted- + / "," / ";" / ":" / "\" / <"> ; string, to use + / "." / "[" / "]" ; within a word. + sub-domain = domain-ref / domain-literal + text = atoms, specials, + CR & bare LF, but NOT ; comments and + including CRLF> ; quoted-strings are + ; NOT recognized. + time = hour zone ; ANSI and Military + trace = return ; path to sender + 1*received ; receipt tags + user-defined-field = + + word = atom / quoted-string + + + + + August 13, 1982 - 46 - RFC #822 + + + + Standard for ARPA Internet Text Messages + + + zone = "UT" / "GMT" ; Universal Time + ; North American : UT + / "EST" / "EDT" ; Eastern: - 5/ - 4 + / "CST" / "CDT" ; Central: - 6/ - 5 + / "MST" / "MDT" ; Mountain: - 7/ - 6 + / "PST" / "PDT" ; Pacific: - 8/ - 7 + / 1ALPHA ; Military: Z = UT; + <"> = ; ( 42, 34.) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + August 13, 1982 - 47 - RFC #822 + diff --git a/vendor/swiftmailer/swiftmailer/notes/rfc/rfc1341.txt b/vendor/swiftmailer/swiftmailer/notes/rfc/rfc1341.txt new file mode 100755 index 0000000..1be6f7d --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/notes/rfc/rfc1341.txt @@ -0,0 +1,5265 @@ + + + + + + + Network Working Group N. Borenstein, Bellcore + Request for Comments: 1341 N. Freed, Innosoft + June 1992 + + + + MIME (Multipurpose Internet Mail Extensions): + + + Mechanisms for Specifying and Describing + the Format of Internet Message Bodies + + + Status of this Memo + + This RFC specifies an IAB standards track protocol for the + Internet community, and requests discussion and suggestions + for improvements. Please refer to the current edition of + the "IAB Official Protocol Standards" for the + standardization state and status of this protocol. + Distribution of this memo is unlimited. + + Abstract + + RFC 822 defines a message representation protocol which + specifies considerable detail about message headers, but + which leaves the message content, or message body, as flat + ASCII text. This document redefines the format of message + bodies to allow multi-part textual and non-textual message + bodies to be represented and exchanged without loss of + information. This is based on earlier work documented in + RFC 934 and RFC 1049, but extends and revises that work. + Because RFC 822 said so little about message bodies, this + document is largely orthogonal to (rather than a revision + of) RFC 822. + + In particular, this document is designed to provide + facilities to include multiple objects in a single message, + to represent body text in character sets other than US- + ASCII, to represent formatted multi-font text messages, to + represent non-textual material such as images and audio + fragments, and generally to facilitate later extensions + defining new types of Internet mail for use by cooperating + mail agents. + + This document does NOT extend Internet mail header fields to + permit anything other than US-ASCII text data. It is + recognized that such extensions are necessary, and they are + the subject of a companion document [RFC -1342]. + + A table of contents appears at the end of this document. + + + + + + + Borenstein & Freed [Page i] + + + + + + + + 1 Introduction + + Since its publication in 1982, RFC 822 [RFC-822] has defined + the standard format of textual mail messages on the + Internet. Its success has been such that the RFC 822 format + has been adopted, wholly or partially, well beyond the + confines of the Internet and the Internet SMTP transport + defined by RFC 821 [RFC-821]. As the format has seen wider + use, a number of limitations have proven increasingly + restrictive for the user community. + + RFC 822 was intended to specify a format for text messages. + As such, non-text messages, such as multimedia messages that + might include audio or images, are simply not mentioned. + Even in the case of text, however, RFC 822 is inadequate for + the needs of mail users whose languages require the use of + character sets richer than US ASCII [US-ASCII]. Since RFC + 822 does not specify mechanisms for mail containing audio, + video, Asian language text, or even text in most European + languages, additional specifications are needed + + One of the notable limitations of RFC 821/822 based mail + systems is the fact that they limit the contents of + electronic mail messages to relatively short lines of + seven-bit ASCII. This forces users to convert any non- + textual data that they may wish to send into seven-bit bytes + representable as printable ASCII characters before invoking + a local mail UA (User Agent, a program with which human + users send and receive mail). Examples of such encodings + currently used in the Internet include pure hexadecimal, + uuencode, the 3-in-4 base 64 scheme specified in RFC 1113, + the Andrew Toolkit Representation [ATK], and many others. + + The limitations of RFC 822 mail become even more apparent as + gateways are designed to allow for the exchange of mail + messages between RFC 822 hosts and X.400 hosts. X.400 [X400] + specifies mechanisms for the inclusion of non-textual body + parts within electronic mail messages. The current + standards for the mapping of X.400 messages to RFC 822 + messages specify that either X.400 non-textual body parts + should be converted to (not encoded in) an ASCII format, or + that they should be discarded, notifying the RFC 822 user + that discarding has occurred. This is clearly undesirable, + as information that a user may wish to receive is lost. + Even though a user's UA may not have the capability of + dealing with the non-textual body part, the user might have + some mechanism external to the UA that can extract useful + information from the body part. Moreover, it does not allow + for the fact that the message may eventually be gatewayed + back into an X.400 message handling system (i.e., the X.400 + message is "tunneled" through Internet mail), where the + non-textual information would definitely become useful + again. + + + + + Borenstein & Freed [Page 1] + + + + + RFC 1341MIME: Multipurpose Internet Mail ExtensionsJune 1992 + + + This document describes several mechanisms that combine to + solve most of these problems without introducing any serious + incompatibilities with the existing world of RFC 822 mail. + In particular, it describes: + + 1. A MIME-Version header field, which uses a version number + to declare a message to be conformant with this + specification and allows mail processing agents to + distinguish between such messages and those generated + by older or non-conformant software, which is presumed + to lack such a field. + + 2. A Content-Type header field, generalized from RFC 1049 + [RFC-1049], which can be used to specify the type and + subtype of data in the body of a message and to fully + specify the native representation (encoding) of such + data. + + 2.a. A "text" Content-Type value, which can be used to + represent textual information in a number of + character sets and formatted text description + languages in a standardized manner. + + 2.b. A "multipart" Content-Type value, which can be + used to combine several body parts, possibly of + differing types of data, into a single message. + + 2.c. An "application" Content-Type value, which can be + used to transmit application data or binary data, + and hence, among other uses, to implement an + electronic mail file transfer service. + + 2.d. A "message" Content-Type value, for encapsulating + a mail message. + + 2.e An "image" Content-Type value, for transmitting + still image (picture) data. + + 2.f. An "audio" Content-Type value, for transmitting + audio or voice data. + + 2.g. A "video" Content-Type value, for transmitting + video or moving image data, possibly with audio as + part of the composite video data format. + + 3. A Content-Transfer-Encoding header field, which can be + used to specify an auxiliary encoding that was applied + to the data in order to allow it to pass through mail + transport mechanisms which may have data or character + set limitations. + + 4. Two optional header fields that can be used to further + describe the data in a message body, the Content-ID and + Content-Description header fields. + + + + Borenstein & Freed [Page 2] + + + + + RFC 1341MIME: Multipurpose Internet Mail ExtensionsJune 1992 + + + MIME has been carefully designed as an extensible mechanism, + and it is expected that the set of content-type/subtype + pairs and their associated parameters will grow + significantly with time. Several other MIME fields, notably + including character set names, are likely to have new values + defined over time. In order to ensure that the set of such + values is developed in an orderly, well-specified, and + public manner, MIME defines a registration process which + uses the Internet Assigned Numbers Authority (IANA) as a + central registry for such values. Appendix F provides + details about how IANA registration is accomplished. + + Finally, to specify and promote interoperability, Appendix A + of this document provides a basic applicability statement + for a subset of the above mechanisms that defines a minimal + level of "conformance" with this document. + + HISTORICAL NOTE: Several of the mechanisms described in + this document may seem somewhat strange or even baroque at + first reading. It is important to note that compatibility + with existing standards AND robustness across existing + practice were two of the highest priorities of the working + group that developed this document. In particular, + compatibility was always favored over elegance. + + 2 Notations, Conventions, and Generic BNF Grammar + + This document is being published in two versions, one as + plain ASCII text and one as PostScript. The latter is + recommended, though the textual contents are identical. An + Andrew-format copy of this document is also available from + the first author (Borenstein). + + Although the mechanisms specified in this document are all + described in prose, most are also described formally in the + modified BNF notation of RFC 822. Implementors will need to + be familiar with this notation in order to understand this + specification, and are referred to RFC 822 for a complete + explanation of the modified BNF notation. + + Some of the modified BNF in this document makes reference to + syntactic entities that are defined in RFC 822 and not in + this document. A complete formal grammar, then, is obtained + by combining the collected grammar appendix of this document + with that of RFC 822. + + The term CRLF, in this document, refers to the sequence of + the two ASCII characters CR (13) and LF (10) which, taken + together, in this order, denote a line break in RFC 822 + mail. + + The term "character set", wherever it is used in this + document, refers to a coded character set, in the sense of + ISO character set standardization work, and must not be + + + + Borenstein & Freed [Page 3] + + + + + RFC 1341MIME: Multipurpose Internet Mail ExtensionsJune 1992 + + + misinterpreted as meaning "a set of characters." + + The term "message", when not further qualified, means either + the (complete or "top-level") message being transferred on a + network, or a message encapsulated in a body of type + "message". + + The term "body part", in this document, means one of the + parts of the body of a multipart entity. A body part has a + header and a body, so it makes sense to speak about the body + of a body part. + + The term "entity", in this document, means either a message + or a body part. All kinds of entities share the property + that they have a header and a body. + + The term "body", when not further qualified, means the body + of an entity, that is the body of either a message or of a + body part. + + Note : the previous four definitions are clearly circular. + This is unavoidable, since the overal structure of a MIME + message is indeed recursive. + + In this document, all numeric and octet values are given in + decimal notation. + + It must be noted that Content-Type values, subtypes, and + parameter names as defined in this document are case- + insensitive. However, parameter values are case-sensitive + unless otherwise specified for the specific parameter. + + FORMATTING NOTE: This document has been carefully formatted + for ease of reading. The PostScript version of this + document, in particular, places notes like this one, which + may be skipped by the reader, in a smaller, italicized, + font, and indents it as well. In the text version, only the + indentation is preserved, so if you are reading the text + version of this you might consider using the PostScript + version instead. However, all such notes will be indented + and preceded by "NOTE:" or some similar introduction, even + in the text version. + + The primary purpose of these non-essential notes is to + convey information about the rationale of this document, or + to place this document in the proper historical or + evolutionary context. Such information may be skipped by + those who are focused entirely on building a compliant + implementation, but may be of use to those who wish to + understand why this document is written as it is. + + For ease of recognition, all BNF definitions have been + placed in a fixed-width font in the PostScript version of + this document. + + + + Borenstein & Freed [Page 4] + + + + + RFC 1341MIME: Multipurpose Internet Mail ExtensionsJune 1992 + + + 3 The MIME-Version Header Field + + Since RFC 822 was published in 1982, there has really been + only one format standard for Internet messages, and there + has been little perceived need to declare the format + standard in use. This document is an independent document + that complements RFC 822. Although the extensions in this + document have been defined in such a way as to be compatible + with RFC 822, there are still circumstances in which it + might be desirable for a mail-processing agent to know + whether a message was composed with the new standard in + mind. + + Therefore, this document defines a new header field, "MIME- + Version", which is to be used to declare the version of the + Internet message body format standard in use. + + Messages composed in accordance with this document MUST + include such a header field, with the following verbatim + text: + + MIME-Version: 1.0 + + The presence of this header field is an assertion that the + message has been composed in compliance with this document. + + Since it is possible that a future document might extend the + message format standard again, a formal BNF is given for the + content of the MIME-Version field: + + MIME-Version := text + + Thus, future format specifiers, which might replace or + extend "1.0", are (minimally) constrained by the definition + of "text", which appears in RFC 822. + + Note that the MIME-Version header field is required at the + top level of a message. It is not required for each body + part of a multipart entity. It is required for the embedded + headers of a body of type "message" if and only if the + embedded message is itself claimed to be MIME-compliant. + + + + + + + + + + + + + + + + + Borenstein & Freed [Page 5] + + + + + RFC 1341MIME: Multipurpose Internet Mail ExtensionsJune 1992 + + + 4 The Content-Type Header Field + + The purpose of the Content-Type field is to describe the + data contained in the body fully enough that the receiving + user agent can pick an appropriate agent or mechanism to + present the data to the user, or otherwise deal with the + data in an appropriate manner. + + HISTORICAL NOTE: The Content-Type header field was first + defined in RFC 1049. RFC 1049 Content-types used a simpler + and less powerful syntax, but one that is largely compatible + with the mechanism given here. + + The Content-Type header field is used to specify the nature + of the data in the body of an entity, by giving type and + subtype identifiers, and by providing auxiliary information + that may be required for certain types. After the type and + subtype names, the remainder of the header field is simply a + set of parameters, specified in an attribute/value notation. + The set of meaningful parameters differs for the different + types. The ordering of parameters is not significant. + Among the defined parameters is a "charset" parameter by + which the character set used in the body may be declared. + Comments are allowed in accordance with RFC 822 rules for + structured header fields. + + In general, the top-level Content-Type is used to declare + the general type of data, while the subtype specifies a + specific format for that type of data. Thus, a Content-Type + of "image/xyz" is enough to tell a user agent that the data + is an image, even if the user agent has no knowledge of the + specific image format "xyz". Such information can be used, + for example, to decide whether or not to show a user the raw + data from an unrecognized subtype -- such an action might be + reasonable for unrecognized subtypes of text, but not for + unrecognized subtypes of image or audio. For this reason, + registered subtypes of audio, image, text, and video, should + not contain embedded information that is really of a + different type. Such compound types should be represented + using the "multipart" or "application" types. + + Parameters are modifiers of the content-subtype, and do not + fundamentally affect the requirements of the host system. + Although most parameters make sense only with certain + content-types, others are "global" in the sense that they + might apply to any subtype. For example, the "boundary" + parameter makes sense only for the "multipart" content-type, + but the "charset" parameter might make sense with several + content-types. + + An initial set of seven Content-Types is defined by this + document. This set of top-level names is intended to be + substantially complete. It is expected that additions to + the larger set of supported types can generally be + + + + Borenstein & Freed [Page 6] + + + + + RFC 1341MIME: Multipurpose Internet Mail ExtensionsJune 1992 + + + accomplished by the creation of new subtypes of these + initial types. In the future, more top-level types may be + defined only by an extension to this standard. If another + primary type is to be used for any reason, it must be given + a name starting with "X-" to indicate its non-standard + status and to avoid a potential conflict with a future + official name. + + In the Extended BNF notation of RFC 822, a Content-Type + header field value is defined as follows: + + Content-Type := type "/" subtype *[";" parameter] + + type := "application" / "audio" + / "image" / "message" + / "multipart" / "text" + / "video" / x-token + + x-token := + + subtype := token + + parameter := attribute "=" value + + attribute := token + + value := token / quoted-string + + token := 1* + + tspecials := "(" / ")" / "<" / ">" / "@" ; Must be in + / "," / ";" / ":" / "\" / <"> ; quoted-string, + / "/" / "[" / "]" / "?" / "." ; to use within + / "=" ; parameter values + + Note that the definition of "tspecials" is the same as the + RFC 822 definition of "specials" with the addition of the + three characters "/", "?", and "=". + + Note also that a subtype specification is MANDATORY. There + are no default subtypes. + + The type, subtype, and parameter names are not case + sensitive. For example, TEXT, Text, and TeXt are all + equivalent. Parameter values are normally case sensitive, + but certain parameters are interpreted to be case- + insensitive, depending on the intended use. (For example, + multipart boundaries are case-sensitive, but the "access- + type" for message/External-body is not case-sensitive.) + + Beyond this syntax, the only constraint on the definition of + subtype names is the desire that their uses must not + conflict. That is, it would be undesirable to have two + + + + Borenstein & Freed [Page 7] + + + + + RFC 1341MIME: Multipurpose Internet Mail ExtensionsJune 1992 + + + different communities using "Content-Type: + application/foobar" to mean two different things. The + process of defining new content-subtypes, then, is not + intended to be a mechanism for imposing restrictions, but + simply a mechanism for publicizing the usages. There are, + therefore, two acceptable mechanisms for defining new + Content-Type subtypes: + + 1. Private values (starting with "X-") may be + defined bilaterally between two cooperating + agents without outside registration or + standardization. + + 2. New standard values must be documented, + registered with, and approved by IANA, as + described in Appendix F. Where intended for + public use, the formats they refer to must + also be defined by a published specification, + and possibly offered for standardization. + + The seven standard initial predefined Content-Types are + detailed in the bulk of this document. They are: + + text -- textual information. The primary subtype, + "plain", indicates plain (unformatted) text. No + special software is required to get the full + meaning of the text, aside from support for the + indicated character set. Subtypes are to be used + for enriched text in forms where application + software may enhance the appearance of the text, + but such software must not be required in order to + get the general idea of the content. Possible + subtypes thus include any readable word processor + format. A very simple and portable subtype, + richtext, is defined in this document. + multipart -- data consisting of multiple parts of + independent data types. Four initial subtypes + are defined, including the primary "mixed" + subtype, "alternative" for representing the same + data in multiple formats, "parallel" for parts + intended to be viewed simultaneously, and "digest" + for multipart entities in which each part is of + type "message". + message -- an encapsulated message. A body of + Content-Type "message" is itself a fully formatted + RFC 822 conformant message which may contain its + own different Content-Type header field. The + primary subtype is "rfc822". The "partial" + subtype is defined for partial messages, to permit + the fragmented transmission of bodies that are + thought to be too large to be passed through mail + transport facilities. Another subtype, + "External-body", is defined for specifying large + bodies by reference to an external data source. + + + + Borenstein & Freed [Page 8] + + + + + RFC 1341MIME: Multipurpose Internet Mail ExtensionsJune 1992 + + + image -- image data. Image requires a display device + (such as a graphical display, a printer, or a FAX + machine) to view the information. Initial + subtypes are defined for two widely-used image + formats, jpeg and gif. + audio -- audio data, with initial subtype "basic". + Audio requires an audio output device (such as a + speaker or a telephone) to "display" the contents. + video -- video data. Video requires the capability to + display moving images, typically including + specialized hardware and software. The initial + subtype is "mpeg". + application -- some other kind of data, typically + either uninterpreted binary data or information to + be processed by a mail-based application. The + primary subtype, "octet-stream", is to be used in + the case of uninterpreted binary data, in which + case the simplest recommended action is to offer + to write the information into a file for the user. + Two additional subtypes, "ODA" and "PostScript", + are defined for transporting ODA and PostScript + documents in bodies. Other expected uses for + "application" include spreadsheets, data for + mail-based scheduling systems, and languages for + "active" (computational) email. (Note that active + email entails several securityconsiderations, + which are discussed later in this memo, + particularly in the context of + application/PostScript.) + + Default RFC 822 messages are typed by this protocol as plain + text in the US-ASCII character set, which can be explicitly + specified as "Content-type: text/plain; charset=us-ascii". + If no Content-Type is specified, either by error or by an + older user agent, this default is assumed. In the presence + of a MIME-Version header field, a receiving User Agent can + also assume that plain US-ASCII text was the sender's + intent. In the absence of a MIME-Version specification, + plain US-ASCII text must still be assumed, but the sender's + intent might have been otherwise. + + RATIONALE: In the absence of any Content-Type header field + or MIME-Version header field, it is impossible to be certain + that a message is actually text in the US-ASCII character + set, since it might well be a message that, using the + conventions that predate this document, includes text in + another character set or non-textual data in a manner that + cannot be automatically recognized (e.g., a uuencoded + compressed UNIX tar file). Although there is no fully + acceptable alternative to treating such untyped messages as + "text/plain; charset=us-ascii", implementors should remain + aware that if a message lacks both the MIME-Version and the + Content-Type header fields, it may in practice contain + almost anything. + + + + Borenstein & Freed [Page 9] + + + + + RFC 1341MIME: Multipurpose Internet Mail ExtensionsJune 1992 + + + It should be noted that the list of Content-Type values + given here may be augmented in time, via the mechanisms + described above, and that the set of subtypes is expected to + grow substantially. + + When a mail reader encounters mail with an unknown Content- + type value, it should generally treat it as equivalent to + "application/octet-stream", as described later in this + document. + + 5 The Content-Transfer-Encoding Header Field + + Many Content-Types which could usefully be transported via + email are represented, in their "natural" format, as 8-bit + character or binary data. Such data cannot be transmitted + over some transport protocols. For example, RFC 821 + restricts mail messages to 7-bit US-ASCII data with 1000 + character lines. + + It is necessary, therefore, to define a standard mechanism + for re-encoding such data into a 7-bit short-line format. + This document specifies that such encodings will be + indicated by a new "Content-Transfer-Encoding" header field. + The Content-Transfer-Encoding field is used to indicate the + type of transformation that has been used in order to + represent the body in an acceptable manner for transport. + + Unlike Content-Types, a proliferation of Content-Transfer- + Encoding values is undesirable and unnecessary. However, + establishing only a single Content-Transfer-Encoding + mechanism does not seem possible. There is a tradeoff + between the desire for a compact and efficient encoding of + largely-binary data and the desire for a readable encoding + of data that is mostly, but not entirely, 7-bit data. For + this reason, at least two encoding mechanisms are necessary: + a "readable" encoding and a "dense" encoding. + + The Content-Transfer-Encoding field is designed to specify + an invertible mapping between the "native" representation of + a type of data and a representation that can be readily + exchanged using 7 bit mail transport protocols, such as + those defined by RFC 821 (SMTP). This field has not been + defined by any previous standard. The field's value is a + single token specifying the type of encoding, as enumerated + below. Formally: + + Content-Transfer-Encoding := "BASE64" / "QUOTED-PRINTABLE" / + "8BIT" / "7BIT" / + "BINARY" / x-token + + These values are not case sensitive. That is, Base64 and + BASE64 and bAsE64 are all equivalent. An encoding type of + 7BIT requires that the body is already in a seven-bit mail- + ready representation. This is the default value -- that is, + + + + Borenstein & Freed [Page 10] + + + + + RFC 1341MIME: Multipurpose Internet Mail ExtensionsJune 1992 + + + "Content-Transfer-Encoding: 7BIT" is assumed if the + Content-Transfer-Encoding header field is not present. + + The values "8bit", "7bit", and "binary" all imply that NO + encoding has been performed. However, they are potentially + useful as indications of the kind of data contained in the + object, and therefore of the kind of encoding that might + need to be performed for transmission in a given transport + system. "7bit" means that the data is all represented as + short lines of US-ASCII data. "8bit" means that the lines + are short, but there may be non-ASCII characters (octets + with the high-order bit set). "Binary" means that not only + may non-ASCII characters be present, but also that the lines + are not necessarily short enough for SMTP transport. + + The difference between "8bit" (or any other conceivable + bit-width token) and the "binary" token is that "binary" + does not require adherence to any limits on line length or + to the SMTP CRLF semantics, while the bit-width tokens do + require such adherence. If the body contains data in any + bit-width other than 7-bit, the appropriate bit-width + Content-Transfer-Encoding token must be used (e.g., "8bit" + for unencoded 8 bit wide data). If the body contains binary + data, the "binary" Content-Transfer-Encoding token must be + used. + + NOTE: The distinction between the Content-Transfer-Encoding + values of "binary," "8bit," etc. may seem unimportant, in + that all of them really mean "none" -- that is, there has + been no encoding of the data for transport. However, clear + labeling will be of enormous value to gateways between + future mail transport systems with differing capabilities in + transporting data that do not meet the restrictions of RFC + 821 transport. + + As of the publication of this document, there are no + standardized Internet transports for which it is legitimate + to include unencoded 8-bit or binary data in mail bodies. + Thus there are no circumstances in which the "8bit" or + "binary" Content-Transfer-Encoding is actually legal on the + Internet. However, in the event that 8-bit or binary mail + transport becomes a reality in Internet mail, or when this + document is used in conjunction with any other 8-bit or + binary-capable transport mechanism, 8-bit or binary bodies + should be labeled as such using this mechanism. + + NOTE: The five values defined for the Content-Transfer- + Encoding field imply nothing about the Content-Type other + than the algorithm by which it was encoded or the transport + system requirements if unencoded. + + Implementors may, if necessary, define new Content- + Transfer-Encoding values, but must use an x-token, which is + a name prefixed by "X-" to indicate its non-standard status, + + + + Borenstein & Freed [Page 11] + + + + + RFC 1341MIME: Multipurpose Internet Mail ExtensionsJune 1992 + + + e.g., "Content-Transfer-Encoding: x-my-new-encoding". + However, unlike Content-Types and subtypes, the creation of + new Content-Transfer-Encoding values is explicitly and + strongly discouraged, as it seems likely to hinder + interoperability with little potential benefit. Their use + is allowed only as the result of an agreement between + cooperating user agents. + + If a Content-Transfer-Encoding header field appears as part + of a message header, it applies to the entire body of that + message. If a Content-Transfer-Encoding header field + appears as part of a body part's headers, it applies only to + the body of that body part. If an entity is of type + "multipart" or "message", the Content-Transfer-Encoding is + not permitted to have any value other than a bit width + (e.g., "7bit", "8bit", etc.) or "binary". + + It should be noted that email is character-oriented, so that + the mechanisms described here are mechanisms for encoding + arbitrary byte streams, not bit streams. If a bit stream is + to be encoded via one of these mechanisms, it must first be + converted to an 8-bit byte stream using the network standard + bit order ("big-endian"), in which the earlier bits in a + stream become the higher-order bits in a byte. A bit stream + not ending at an 8-bit boundary must be padded with zeroes. + This document provides a mechanism for noting the addition + of such padding in the case of the application Content-Type, + which has a "padding" parameter. + + The encoding mechanisms defined here explicitly encode all + data in ASCII. Thus, for example, suppose an entity has + header fields such as: + + Content-Type: text/plain; charset=ISO-8859-1 + Content-transfer-encoding: base64 + + This should be interpreted to mean that the body is a base64 + ASCII encoding of data that was originally in ISO-8859-1, + and will be in that character set again after decoding. + + The following sections will define the two standard encoding + mechanisms. The definition of new content-transfer- + encodings is explicitly discouraged and should only occur + when absolutely necessary. All content-transfer-encoding + namespace except that beginning with "X-" is explicitly + reserved to the IANA for future use. Private agreements + about content-transfer-encodings are also explicitly + discouraged. + + Certain Content-Transfer-Encoding values may only be used on + certain Content-Types. In particular, it is expressly + forbidden to use any encodings other than "7bit", "8bit", or + "binary" with any Content-Type that recursively includes + other Content-Type fields, notably the "multipart" and + + + + Borenstein & Freed [Page 12] + + + + + RFC 1341MIME: Multipurpose Internet Mail ExtensionsJune 1992 + + + "message" Content-Types. All encodings that are desired for + bodies of type multipart or message must be done at the + innermost level, by encoding the actual body that needs to + be encoded. + + NOTE ON ENCODING RESTRICTIONS: Though the prohibition + against using content-transfer-encodings on data of type + multipart or message may seem overly restrictive, it is + necessary to prevent nested encodings, in which data are + passed through an encoding algorithm multiple times, and + must be decoded multiple times in order to be properly + viewed. Nested encodings add considerable complexity to + user agents: aside from the obvious efficiency problems + with such multiple encodings, they can obscure the basic + structure of a message. In particular, they can imply that + several decoding operations are necessary simply to find out + what types of objects a message contains. Banning nested + encodings may complicate the job of certain mail gateways, + but this seems less of a problem than the effect of nested + encodings on user agents. + + NOTE ON THE RELATIONSHIP BETWEEN CONTENT-TYPE AND CONTENT- + TRANSFER-ENCODING: It may seem that the Content-Transfer- + Encoding could be inferred from the characteristics of the + Content-Type that is to be encoded, or, at the very least, + that certain Content-Transfer-Encodings could be mandated + for use with specific Content-Types. There are several + reasons why this is not the case. First, given the varying + types of transports used for mail, some encodings may be + appropriate for some Content-Type/transport combinations and + not for others. (For example, in an 8-bit transport, no + encoding would be required for text in certain character + sets, while such encodings are clearly required for 7-bit + SMTP.) Second, certain Content-Types may require different + types of transfer encoding under different circumstances. + For example, many PostScript bodies might consist entirely + of short lines of 7-bit data and hence require little or no + encoding. Other PostScript bodies (especially those using + Level 2 PostScript's binary encoding mechanism) may only be + reasonably represented using a binary transport encoding. + Finally, since Content-Type is intended to be an open-ended + specification mechanism, strict specification of an + association between Content-Types and encodings effectively + couples the specification of an application protocol with a + specific lower-level transport. This is not desirable since + the developers of a Content-Type should not have to be aware + of all the transports in use and what their limitations are. + + NOTE ON TRANSLATING ENCODINGS: The quoted-printable and + base64 encodings are designed so that conversion between + them is possible. The only issue that arises in such a + conversion is the handling of line breaks. When converting + from quoted-printable to base64 a line break must be + converted into a CRLF sequence. Similarly, a CRLF sequence + + + + Borenstein & Freed [Page 13] + + + + + RFC 1341MIME: Multipurpose Internet Mail ExtensionsJune 1992 + + + in base64 data should be converted to a quoted-printable + line break, but ONLY when converting text data. + + NOTE ON CANONICAL ENCODING MODEL: There was some + confusion, in earlier drafts of this memo, regarding the + model for when email data was to be converted to canonical + form and encoded, and in particular how this process would + affect the treatment of CRLFs, given that the representation + of newlines varies greatly from system to system. For this + reason, a canonical model for encoding is presented as + Appendix H. + + 5.1 Quoted-Printable Content-Transfer-Encoding + + The Quoted-Printable encoding is intended to represent data + that largely consists of octets that correspond to printable + characters in the ASCII character set. It encodes the data + in such a way that the resulting octets are unlikely to be + modified by mail transport. If the data being encoded are + mostly ASCII text, the encoded form of the data remains + largely recognizable by humans. A body which is entirely + ASCII may also be encoded in Quoted-Printable to ensure the + integrity of the data should the message pass through a + character-translating, and/or line-wrapping gateway. + + In this encoding, octets are to be represented as determined + by the following rules: + + Rule #1: (General 8-bit representation) Any octet, + except those indicating a line break according to the + newline convention of the canonical form of the data + being encoded, may be represented by an "=" followed by + a two digit hexadecimal representation of the octet's + value. The digits of the hexadecimal alphabet, for this + purpose, are "0123456789ABCDEF". Uppercase letters must + be + used when sending hexadecimal data, though a robust + implementation may choose to recognize lowercase + letters on receipt. Thus, for example, the value 12 + (ASCII form feed) can be represented by "=0C", and the + value 61 (ASCII EQUAL SIGN) can be represented by + "=3D". Except when the following rules allow an + alternative encoding, this rule is mandatory. + + Rule #2: (Literal representation) Octets with decimal + values of 33 through 60 inclusive, and 62 through 126, + inclusive, MAY be represented as the ASCII characters + which correspond to those octets (EXCLAMATION POINT + through LESS THAN, and GREATER THAN through TILDE, + respectively). + + Rule #3: (White Space): Octets with values of 9 and 32 + MAY be represented as ASCII TAB (HT) and SPACE + characters, respectively, but MUST NOT be so + + + + Borenstein & Freed [Page 14] + + + + + RFC 1341MIME: Multipurpose Internet Mail ExtensionsJune 1992 + + + represented at the end of an encoded line. Any TAB (HT) + or SPACE characters on an encoded line MUST thus be + followed on that line by a printable character. In + particular, an "=" at the end of an encoded line, + indicating a soft line break (see rule #5) may follow + one or more TAB (HT) or SPACE characters. It follows + that an octet with value 9 or 32 appearing at the end + of an encoded line must be represented according to + Rule #1. This rule is necessary because some MTAs + (Message Transport Agents, programs which transport + messages from one user to another, or perform a part of + such transfers) are known to pad lines of text with + SPACEs, and others are known to remove "white space" + characters from the end of a line. Therefore, when + decoding a Quoted-Printable body, any trailing white + space on a line must be deleted, as it will necessarily + have been added by intermediate transport agents. + + Rule #4 (Line Breaks): A line break in a text body + part, independent of what its representation is + following the canonical representation of the data + being encoded, must be represented by a (RFC 822) line + break, which is a CRLF sequence, in the Quoted- + Printable encoding. If isolated CRs and LFs, or LF CR + and CR LF sequences are allowed to appear in binary + data according to the canonical form, they must be + represented using the "=0D", "=0A", "=0A=0D" and + "=0D=0A" notations respectively. + + Note that many implementation may elect to encode the + local representation of various content types directly. + In particular, this may apply to plain text material on + systems that use newline conventions other than CRLF + delimiters. Such an implementation is permissible, but + the generation of line breaks must be generalized to + account for the case where alternate representations of + newline sequences are used. + + Rule #5 (Soft Line Breaks): The Quoted-Printable + encoding REQUIRES that encoded lines be no more than 76 + characters long. If longer lines are to be encoded with + the Quoted-Printable encoding, 'soft' line breaks must + be used. An equal sign as the last character on a + encoded line indicates such a non-significant ('soft') + line break in the encoded text. Thus if the "raw" form + of the line is a single unencoded line that says: + + Now's the time for all folk to come to the aid of + their country. + + This can be represented, in the Quoted-Printable + encoding, as + + + + + + Borenstein & Freed [Page 15] + + + + + RFC 1341MIME: Multipurpose Internet Mail ExtensionsJune 1992 + + + Now's the time = + for all folk to come= + to the aid of their country. + + This provides a mechanism with which long lines are + encoded in such a way as to be restored by the user + agent. The 76 character limit does not count the + trailing CRLF, but counts all other characters, + including any equal signs. + + Since the hyphen character ("-") is represented as itself in + the Quoted-Printable encoding, care must be taken, when + encapsulating a quoted-printable encoded body in a multipart + entity, to ensure that the encapsulation boundary does not + appear anywhere in the encoded body. (A good strategy is to + choose a boundary that includes a character sequence such as + "=_" which can never appear in a quoted-printable body. See + the definition of multipart messages later in this + document.) + + NOTE: The quoted-printable encoding represents something of + a compromise between readability and reliability in + transport. Bodies encoded with the quoted-printable + encoding will work reliably over most mail gateways, but may + not work perfectly over a few gateways, notably those + involving translation into EBCDIC. (In theory, an EBCDIC + gateway could decode a quoted-printable body and re-encode + it using base64, but such gateways do not yet exist.) A + higher level of confidence is offered by the base64 + Content-Transfer-Encoding. A way to get reasonably reliable + transport through EBCDIC gateways is to also quote the ASCII + characters + + !"#$@[\]^`{|}~ + + according to rule #1. See Appendix B for more information. + + Because quoted-printable data is generally assumed to be + line-oriented, it is to be expected that the breaks between + the lines of quoted printable data may be altered in + transport, in the same manner that plain text mail has + always been altered in Internet mail when passing between + systems with differing newline conventions. If such + alterations are likely to constitute a corruption of the + data, it is probably more sensible to use the base64 + encoding rather than the quoted-printable encoding. + + + + + + + + + + + + Borenstein & Freed [Page 16] + + + + + RFC 1341MIME: Multipurpose Internet Mail ExtensionsJune 1992 + + + 5.2 Base64 Content-Transfer-Encoding + + The Base64 Content-Transfer-Encoding is designed to + represent arbitrary sequences of octets in a form that is + not humanly readable. The encoding and decoding algorithms + are simple, but the encoded data are consistently only about + 33 percent larger than the unencoded data. This encoding is + based on the one used in Privacy Enhanced Mail applications, + as defined in RFC 1113. The base64 encoding is adapted + from RFC 1113, with one change: base64 eliminates the "*" + mechanism for embedded clear text. + + A 65-character subset of US-ASCII is used, enabling 6 bits + to be represented per printable character. (The extra 65th + character, "=", is used to signify a special processing + function.) + + NOTE: This subset has the important property that it is + represented identically in all versions of ISO 646, + including US ASCII, and all characters in the subset are + also represented identically in all versions of EBCDIC. + Other popular encodings, such as the encoding used by the + UUENCODE utility and the base85 encoding specified as part + of Level 2 PostScript, do not share these properties, and + thus do not fulfill the portability requirements a binary + transport encoding for mail must meet. + + The encoding process represents 24-bit groups of input bits + as output strings of 4 encoded characters. Proceeding from + left to right, a 24-bit input group is formed by + concatenating 3 8-bit input groups. These 24 bits are then + treated as 4 concatenated 6-bit groups, each of which is + translated into a single digit in the base64 alphabet. When + encoding a bit stream via the base64 encoding, the bit + stream must be presumed to be ordered with the most- + significant-bit first. That is, the first bit in the stream + will be the high-order bit in the first byte, and the eighth + bit will be the low-order bit in the first byte, and so on. + + Each 6-bit group is used as an index into an array of 64 + printable characters. The character referenced by the index + is placed in the output string. These characters, identified + in Table 1, below, are selected so as to be universally + representable, and the set excludes characters with + particular significance to SMTP (e.g., ".", "CR", "LF") and + to the encapsulation boundaries defined in this document + (e.g., "-"). + + + + + + + + + + + Borenstein & Freed [Page 17] + + + + + RFC 1341MIME: Multipurpose Internet Mail ExtensionsJune 1992 + + + Table 1: The Base64 Alphabet + + Value Encoding Value Encoding Value Encoding Value + Encoding + 0 A 17 R 34 i 51 z + 1 B 18 S 35 j 52 0 + 2 C 19 T 36 k 53 1 + 3 D 20 U 37 l 54 2 + 4 E 21 V 38 m 55 3 + 5 F 22 W 39 n 56 4 + 6 G 23 X 40 o 57 5 + 7 H 24 Y 41 p 58 6 + 8 I 25 Z 42 q 59 7 + 9 J 26 a 43 r 60 8 + 10 K 27 b 44 s 61 9 + 11 L 28 c 45 t 62 + + 12 M 29 d 46 u 63 / + 13 N 30 e 47 v + 14 O 31 f 48 w (pad) = + 15 P 32 g 49 x + 16 Q 33 h 50 y + + The output stream (encoded bytes) must be represented in + lines of no more than 76 characters each. All line breaks + or other characters not found in Table 1 must be ignored by + decoding software. In base64 data, characters other than + those in Table 1, line breaks, and other white space + probably indicate a transmission error, about which a + warning message or even a message rejection might be + appropriate under some circumstances. + + Special processing is performed if fewer than 24 bits are + available at the end of the data being encoded. A full + encoding quantum is always completed at the end of a body. + When fewer than 24 input bits are available in an input + group, zero bits are added (on the right) to form an + integral number of 6-bit groups. Output character positions + which are not required to represent actual input data are + set to the character "=". Since all base64 input is an + integral number of octets, only the following cases can + arise: (1) the final quantum of encoding input is an + integral multiple of 24 bits; here, the final unit of + encoded output will be an integral multiple of 4 characters + with no "=" padding, (2) the final quantum of encoding input + is exactly 8 bits; here, the final unit of encoded output + will be two characters followed by two "=" padding + characters, or (3) the final quantum of encoding input is + exactly 16 bits; here, the final unit of encoded output will + be three characters followed by one "=" padding character. + + Care must be taken to use the proper octets for line breaks + if base64 encoding is applied directly to text material that + has not been converted to canonical form. In particular, + text line breaks should be converted into CRLF sequences + + + + Borenstein & Freed [Page 18] + + + + + RFC 1341MIME: Multipurpose Internet Mail ExtensionsJune 1992 + + + prior to base64 encoding. The important thing to note is + that this may be done directly by the encoder rather than in + a prior canonicalization step in some implementations. + + NOTE: There is no need to worry about quoting apparent + encapsulation boundaries within base64-encoded parts of + multipart entities because no hyphen characters are used in + the base64 encoding. + + 6 Additional Optional Content- Header Fields + + 6.1 Optional Content-ID Header Field + + In constructing a high-level user agent, it may be desirable + to allow one body to make reference to another. + Accordingly, bodies may be labeled using the "Content-ID" + header field, which is syntactically identical to the + "Message-ID" header field: + + Content-ID := msg-id + + Like the Message-ID values, Content-ID values must be + generated to be as unique as possible. + + 6.2 Optional Content-Description Header Field + + The ability to associate some descriptive information with a + given body is often desirable. For example, it may be useful + to mark an "image" body as "a picture of the Space Shuttle + Endeavor." Such text may be placed in the Content- + Description header field. + + Content-Description := *text + + The description is presumed to be given in the US-ASCII + character set, although the mechanism specified in [RFC- + 1342] may be used for non-US-ASCII Content-Description + values. + + + + + + + + + + + + + + + + + + + + Borenstein & Freed [Page 19] + + + + + RFC 1341MIME: Multipurpose Internet Mail ExtensionsJune 1992 + + + 7 The Predefined Content-Type Values + + This document defines seven initial Content-Type values and + an extension mechanism for private or experimental types. + Further standard types must be defined by new published + specifications. It is expected that most innovation in new + types of mail will take place as subtypes of the seven types + defined here. The most essential characteristics of the + seven content-types are summarized in Appendix G. + + 7.1 The Text Content-Type + + The text Content-Type is intended for sending material which + is principally textual in form. It is the default Content- + Type. A "charset" parameter may be used to indicate the + character set of the body text. The primary subtype of text + is "plain". This indicates plain (unformatted) text. The + default Content-Type for Internet mail is "text/plain; + charset=us-ascii". + + Beyond plain text, there are many formats for representing + what might be known as "extended text" -- text with embedded + formatting and presentation information. An interesting + characteristic of many such representations is that they are + to some extent readable even without the software that + interprets them. It is useful, then, to distinguish them, + at the highest level, from such unreadable data as images, + audio, or text represented in an unreadable form. In the + absence of appropriate interpretation software, it is + reasonable to show subtypes of text to the user, while it is + not reasonable to do so with most nontextual data. + + Such formatted textual data should be represented using + subtypes of text. Plausible subtypes of text are typically + given by the common name of the representation format, e.g., + "text/richtext". + + 7.1.1 The charset parameter + + A critical parameter that may be specified in the Content- + Type field for text data is the character set. This is + specified with a "charset" parameter, as in: + + Content-type: text/plain; charset=us-ascii + + Unlike some other parameter values, the values of the + charset parameter are NOT case sensitive. The default + character set, which must be assumed in the absence of a + charset parameter, is US-ASCII. + + An initial list of predefined character set names can be + found at the end of this section. Additional character sets + may be registered with IANA as described in Appendix F, + although the standardization of their use requires the usual + + + + Borenstein & Freed [Page 20] + + + + + RFC 1341MIME: Multipurpose Internet Mail ExtensionsJune 1992 + + + IAB review and approval. Note that if the specified + character set includes 8-bit data, a Content-Transfer- + Encoding header field and a corresponding encoding on the + data are required in order to transmit the body via some + mail transfer protocols, such as SMTP. + + The default character set, US-ASCII, has been the subject of + some confusion and ambiguity in the past. Not only were + there some ambiguities in the definition, there have been + wide variations in practice. In order to eliminate such + ambiguity and variations in the future, it is strongly + recommended that new user agents explicitly specify a + character set via the Content-Type header field. "US-ASCII" + does not indicate an arbitrary seven-bit character code, but + specifies that the body uses character coding that uses the + exact correspondence of codes to characters specified in + ASCII. National use variations of ISO 646 [ISO-646] are NOT + ASCII and their use in Internet mail is explicitly + discouraged. The omission of the ISO 646 character set is + deliberate in this regard. The character set name of "US- + ASCII" explicitly refers to ANSI X3.4-1986 [US-ASCII] only. + The character set name "ASCII" is reserved and must not be + used for any purpose. + + NOTE: RFC 821 explicitly specifies "ASCII", and references + an earlier version of the American Standard. Insofar as one + of the purposes of specifying a Content-Type and character + set is to permit the receiver to unambiguously determine how + the sender intended the coded message to be interpreted, + assuming anything other than "strict ASCII" as the default + would risk unintentional and incompatible changes to the + semantics of messages now being transmitted. This also + implies that messages containing characters coded according + to national variations on ISO 646, or using code-switching + procedures (e.g., those of ISO 2022), as well as 8-bit or + multiple octet character encodings MUST use an appropriate + character set specification to be consistent with this + specification. + + The complete US-ASCII character set is listed in [US-ASCII]. + Note that the control characters including DEL (0-31, 127) + have no defined meaning apart from the combination CRLF + (ASCII values 13 and 10) indicating a new line. Two of the + characters have de facto meanings in wide use: FF (12) often + means "start subsequent text on the beginning of a new + page"; and TAB or HT (9) often (though not always) means + "move the cursor to the next available column after the + current position where the column number is a multiple of 8 + (counting the first column as column 0)." Apart from this, + any use of the control characters or DEL in a body must be + part of a private agreement between the sender and + recipient. Such private agreements are discouraged and + should be replaced by the other capabilities of this + document. + + + + Borenstein & Freed [Page 21] + + + + + RFC 1341MIME: Multipurpose Internet Mail ExtensionsJune 1992 + + + NOTE: Beyond US-ASCII, an enormous proliferation of + character sets is possible. It is the opinion of the IETF + working group that a large number of character sets is NOT a + good thing. We would prefer to specify a single character + set that can be used universally for representing all of the + world's languages in electronic mail. Unfortunately, + existing practice in several communities seems to point to + the continued use of multiple character sets in the near + future. For this reason, we define names for a small number + of character sets for which a strong constituent base + exists. It is our hope that ISO 10646 or some other + effort will eventually define a single world character set + which can then be specified for use in Internet mail, but in + the advance of that definition we cannot specify the use of + ISO 10646, Unicode, or any other character set whose + definition is, as of this writing, incomplete. + + The defined charset values are: + + US-ASCII -- as defined in [US-ASCII]. + + ISO-8859-X -- where "X" is to be replaced, as + necessary, for the parts of ISO-8859 [ISO- + 8859]. Note that the ISO 646 character sets + have deliberately been omitted in favor of + their 8859 replacements, which are the + designated character sets for Internet mail. + As of the publication of this document, the + legitimate values for "X" are the digits 1 + through 9. + + Note that the character set used, if anything other than + US-ASCII, must always be explicitly specified in the + Content-Type field. + + No other character set name may be used in Internet mail + without the publication of a formal specification and its + registration with IANA as described in Appendix F, or by + private agreement, in which case the character set name must + begin with "X-". + + Implementors are discouraged from defining new character + sets for mail use unless absolutely necessary. + + The "charset" parameter has been defined primarily for the + purpose of textual data, and is described in this section + for that reason. However, it is conceivable that non- + textual data might also wish to specify a charset value for + some purpose, in which case the same syntax and values + should be used. + + In general, mail-sending software should always use the + "lowest common denominator" character set possible. For + example, if a body contains only US-ASCII characters, it + + + + Borenstein & Freed [Page 22] + + + + + RFC 1341MIME: Multipurpose Internet Mail ExtensionsJune 1992 + + + should be marked as being in the US-ASCII character set, not + ISO-8859-1, which, like all the ISO-8859 family of character + sets, is a superset of US-ASCII. More generally, if a + widely-used character set is a subset of another character + set, and a body contains only characters in the widely-used + subset, it should be labeled as being in that subset. This + will increase the chances that the recipient will be able to + view the mail correctly. + + 7.1.2 The Text/plain subtype + + The primary subtype of text is "plain". This indicates + plain (unformatted) text. The default Content-Type for + Internet mail, "text/plain; charset=us-ascii", describes + existing Internet practice, that is, it is the type of body + defined by RFC 822. + + 7.1.3 The Text/richtext subtype + + In order to promote the wider interoperability of simple + formatted text, this document defines an extremely simple + subtype of "text", the "richtext" subtype. This subtype was + designed to meet the following criteria: + + 1. The syntax must be extremely simple to parse, + so that even teletype-oriented mail systems can + easily strip away the formatting information and + leave only the readable text. + + 2. The syntax must be extensible to allow for new + formatting commands that are deemed essential. + + 3. The capabilities must be extremely limited, to + ensure that it can represent no more than is + likely to be representable by the user's primary + word processor. While this limits what can be + sent, it increases the likelihood that what is + sent can be properly displayed. + + 4. The syntax must be compatible with SGML, so + that, with an appropriate DTD (Document Type + Definition, the standard mechanism for defining a + document type using SGML), a general SGML parser + could be made to parse richtext. However, despite + this compatibility, the syntax should be far + simpler than full SGML, so that no SGML knowledge + is required in order to implement it. + + The syntax of "richtext" is very simple. It is assumed, at + the top-level, to be in the US-ASCII character set, unless + of course a different charset parameter was specified in the + Content-type field. All characters represent themselves, + with the exception of the "<" character (ASCII 60), which is + used to mark the beginning of a formatting command. + + + + Borenstein & Freed [Page 23] + + + + + RFC 1341MIME: Multipurpose Internet Mail ExtensionsJune 1992 + + + Formatting instructions consist of formatting commands + surrounded by angle brackets ("<>", ASCII 60 and 62). Each + formatting command may be no more than 40 characters in + length, all in US-ASCII, restricted to the alphanumeric and + hyphen ("-") characters. Formatting commands may be preceded + by a forward slash or solidus ("/", ASCII 47), making them + negations, and such negations must always exist to balance + the initial opening commands, except as noted below. Thus, + if the formatting command "" appears at some point, + there must later be a "" to balance it. There are + only three exceptions to this "balancing" rule: First, the + command "" is used to represent a literal "<" character. + Second, the command "" is used to represent a required + line break. (Otherwise, CRLFs in the data are treated as + equivalent to a single SPACE character.) Finally, the + command "" is used to represent a page break. (NOTE: + The 40 character limit on formatting commands does not + include the "<", ">", or "/" characters that might be + attached to such commands.) + + Initially defined formatting commands, not all of which will + be implemented by all richtext implementations, include: + + Bold -- causes the subsequent text to be in a bold + font. + Italic -- causes the subsequent text to be in an italic + font. + Fixed -- causes the subsequent text to be in a fixed + width font. + Smaller -- causes the subsequent text to be in a + smaller font. + Bigger -- causes the subsequent text to be in a bigger + font. + Underline -- causes the subsequent text to be + underlined. + Center -- causes the subsequent text to be centered. + FlushLeft -- causes the subsequent text to be left + justified. + FlushRight -- causes the subsequent text to be right + justified. + Indent -- causes the subsequent text to be indented at + the left margin. + IndentRight -- causes the subsequent text to be + indented at the right margin. + Outdent -- causes the subsequent text to be outdented + at the left margin. + OutdentRight -- causes the subsequent text to be + outdented at the right margin. + SamePage -- causes the subsequent text to be grouped, + if possible, on one page. + Subscript -- causes the subsequent text to be + interpreted as a subscript. + + + + + + Borenstein & Freed [Page 24] + + + + + RFC 1341MIME: Multipurpose Internet Mail ExtensionsJune 1992 + + + Superscript -- causes the subsequent text to be + interpreted as a superscript. + Heading -- causes the subsequent text to be interpreted + as a page heading. + Footing -- causes the subsequent text to be interpreted + as a page footing. + ISO-8859-X (for any value of X that is legal as a + "charset" parameter) -- causes the subsequent text + to be interpreted as text in the appropriate + character set. + US-ASCII -- causes the subsequent text to be + interpreted as text in the US-ASCII character set. + Excerpt -- causes the subsequent text to be interpreted + as a textual excerpt from another source. + Typically this will be displayed using indentation + and an alternate font, but such decisions are up + to the viewer. + Paragraph -- causes the subsequent text to be + interpreted as a single paragraph, with + appropriate paragraph breaks (typically blank + space) before and after. + Signature -- causes the subsequent text to be + interpreted as a "signature". Some systems may + wish to display signatures in a smaller font or + otherwise set them apart from the main text of the + message. + Comment -- causes the subsequent text to be interpreted + as a comment, and hence not shown to the reader. + No-op -- has no effect on the subsequent text. + lt -- is replaced by a literal "<" character. No + balancing is allowed. + nl -- causes a line break. No balancing is + allowed. + np -- causes a page break. No balancing is + allowed. + + Each positive formatting command affects all subsequent text + until the matching negative formatting command. Such pairs + of formatting commands must be properly balanced and nested. + Thus, a proper way to describe text in bold italics is: + + the-text + + or, alternately, + + the-text + + but, in particular, the following is illegal + richtext: + + the-text + + NOTE: The nesting requirement for formatting commands + imposes a slightly higher burden upon the composers of + + + + Borenstein & Freed [Page 25] + + + + + RFC 1341MIME: Multipurpose Internet Mail ExtensionsJune 1992 + + + richtext bodies, but potentially simplifies richtext + displayers by allowing them to be stack-based. The main + goal of richtext is to be simple enough to make multifont, + formatted email widely readable, so that those with the + capability of sending it will be able to do so with + confidence. Thus slightly increased complexity in the + composing software was deemed a reasonable tradeoff for + simplified reading software. Nonetheless, implementors of + richtext readers are encouraged to follow the general + Internet guidelines of being conservative in what you send + and liberal in what you accept. Those implementations that + can do so are encouraged to deal reasonably with improperly + nested richtext. + + Implementations must regard any unrecognized formatting + command as equivalent to "No-op", thus facilitating future + extensions to "richtext". Private extensions may be defined + using formatting commands that begin with "X-", by analogy + to Internet mail header field names. + + It is worth noting that no special behavior is required for + the TAB (HT) character. It is recommended, however, that, at + least when fixed-width fonts are in use, the common + semantics of the TAB (HT) character should be observed, + namely that it moves to the next column position that is a + multiple of 8. (In other words, if a TAB (HT) occurs in + column n, where the leftmost column is column 0, then that + TAB (HT) should be replaced by 8-(n mod 8) SPACE + characters.) + + Richtext also differentiates between "hard" and "soft" line + breaks. A line break (CRLF) in the richtext data stream is + interpreted as a "soft" line break, one that is included + only for purposes of mail transport, and is to be treated as + white space by richtext interpreters. To include a "hard" + line break (one that must be displayed as such), the "" + or " formatting constructs should be used. In + general, a soft line break should be treated as white space, + but when soft line breaks immediately follow a or a + tag they should be ignored rather than treated + as white space. + + Putting all this together, the following "text/richtext" + body fragment: + + Now is the time for + all good men + (and women>) to + come + + to the aid of their + + + + + + + Borenstein & Freed [Page 26] + + + + + RFC 1341MIME: Multipurpose Internet Mail ExtensionsJune 1992 + + + beloved country. Stupid + quote! -- the end + + represents the following formatted text (which will, no + doubt, look cryptic in the text-only version of this + document): + + Now is the time for all good men (and ) to + come to the aid of their + beloved + + country. -- the end + + Richtext conformance: A minimal richtext implementation is + one that simply converts "" to "<", converts CRLFs to + SPACE, converts to a newline according to local newline + convention, removes everything between a command + and the next balancing command, and removes all + other formatting commands (all text enclosed in angle + brackets). + + NOTE ON THE RELATIONSHIP OF RICHTEXT TO SGML: Richtext is + decidedly not SGML, and must not be used to transport + arbitrary SGML documents. Those who wish to use SGML + document types as a mail transport format must define a new + text or application subtype, e.g., "text/sgml-dtd-whatever" + or "application/sgml-dtd-whatever", depending on the + perceived readability of the DTD in use. Richtext is + designed to be compatible with SGML, and specifically so + that it will be possible to define a richtext DTD if one is + needed. However, this does not imply that arbitrary SGML + can be called richtext, nor that richtext implementors have + any need to understand SGML; the description in this + document is a complete definition of richtext, which is far + simpler than complete SGML. + + NOTE ON THE INTENDED USE OF RICHTEXT: It is recognized that + implementors of future mail systems will want rich text + functionality far beyond that currently defined for + richtext. The intent of richtext is to provide a common + format for expressing that functionality in a form in which + much of it, at least, will be understood by interoperating + software. Thus, in particular, software with a richer + notion of formatted text than richtext can still use + richtext as its basic representation, but can extend it with + new formatting commands and by hiding information specific + to that software system in richtext comments. As such + systems evolve, it is expected that the definition of + richtext will be further refined by future published + specifications, but richtext as defined here provides a + platform on which evolutionary refinements can be based. + + IMPLEMENTATION NOTE: In some environments, it might be + impossible to combine certain richtext formatting commands, + + + + Borenstein & Freed [Page 27] + + + + + RFC 1341MIME: Multipurpose Internet Mail ExtensionsJune 1992 + + + whereas in others they might be combined easily. For + example, the combination of and might + produce bold italics on systems that support such fonts, but + there exist systems that can make text bold or italicized, + but not both. In such cases, the most recently issued + recognized formatting command should be preferred. + + One of the major goals in the design of richtext was to make + it so simple that even text-only mailers will implement + richtext-to-plain-text translators, thus increasing the + likelihood that multifont text will become "safe" to use + very widely. To demonstrate this simplicity, an extremely + simple 35-line C program that converts richtext input into + plain text output is included in Appendix D. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Borenstein & Freed [Page 28] + + + + + RFC 1341MIME: Multipurpose Internet Mail ExtensionsJune 1992 + + + 7.2 The Multipart Content-Type + + In the case of multiple part messages, in which one or more + different sets of data are combined in a single body, a + "multipart" Content-Type field must appear in the entity's + header. The body must then contain one or more "body parts," + each preceded by an encapsulation boundary, and the last one + followed by a closing boundary. Each part starts with an + encapsulation boundary, and then contains a body part + consisting of header area, a blank line, and a body area. + Thus a body part is similar to an RFC 822 message in syntax, + but different in meaning. + + A body part is NOT to be interpreted as actually being an + RFC 822 message. To begin with, NO header fields are + actually required in body parts. A body part that starts + with a blank line, therefore, is allowed and is a body part + for which all default values are to be assumed. In such a + case, the absence of a Content-Type header field implies + that the encapsulation is plain US-ASCII text. The only + header fields that have defined meaning for body parts are + those the names of which begin with "Content-". All other + header fields are generally to be ignored in body parts. + Although they should generally be retained in mail + processing, they may be discarded by gateways if necessary. + Such other fields are permitted to appear in body parts but + should not be depended on. "X-" fields may be created for + experimental or private purposes, with the recognition that + the information they contain may be lost at some gateways. + + The distinction between an RFC 822 message and a body part + is subtle, but important. A gateway between Internet and + X.400 mail, for example, must be able to tell the difference + between a body part that contains an image and a body part + that contains an encapsulated message, the body of which is + an image. In order to represent the latter, the body part + must have "Content-Type: message", and its body (after the + blank line) must be the encapsulated message, with its own + "Content-Type: image" header field. The use of similar + syntax facilitates the conversion of messages to body parts, + and vice versa, but the distinction between the two must be + understood by implementors. (For the special case in which + all parts actually are messages, a "digest" subtype is also + defined.) + + As stated previously, each body part is preceded by an + encapsulation boundary. The encapsulation boundary MUST NOT + appear inside any of the encapsulated parts. Thus, it is + crucial that the composing agent be able to choose and + specify the unique boundary that will separate the parts. + + All present and future subtypes of the "multipart" type must + use an identical syntax. Subtypes may differ in their + semantics, and may impose additional restrictions on syntax, + + + + Borenstein & Freed [Page 29] + + + + + RFC 1341MIME: Multipurpose Internet Mail ExtensionsJune 1992 + + + but must conform to the required syntax for the multipart + type. This requirement ensures that all conformant user + agents will at least be able to recognize and separate the + parts of any multipart entity, even of an unrecognized + subtype. + + As stated in the definition of the Content-Transfer-Encoding + field, no encoding other than "7bit", "8bit", or "binary" is + permitted for entities of type "multipart". The multipart + delimiters and header fields are always 7-bit ASCII in any + case, and data within the body parts can be encoded on a + part-by-part basis, with Content-Transfer-Encoding fields + for each appropriate body part. + + Mail gateways, relays, and other mail handling agents are + commonly known to alter the top-level header of an RFC 822 + message. In particular, they frequently add, remove, or + reorder header fields. Such alterations are explicitly + forbidden for the body part headers embedded in the bodies + of messages of type "multipart." + + 7.2.1 Multipart: The common syntax + + All subtypes of "multipart" share a common syntax, defined + in this section. A simple example of a multipart message + also appears in this section. An example of a more complex + multipart message is given in Appendix C. + + The Content-Type field for multipart entities requires one + parameter, "boundary", which is used to specify the + encapsulation boundary. The encapsulation boundary is + defined as a line consisting entirely of two hyphen + characters ("-", decimal code 45) followed by the boundary + parameter value from the Content-Type header field. + + NOTE: The hyphens are for rough compatibility with the + earlier RFC 934 method of message encapsulation, and for + ease of searching for the boundaries in some + implementations. However, it should be noted that multipart + messages are NOT completely compatible with RFC 934 + encapsulations; in particular, they do not obey RFC 934 + quoting conventions for embedded lines that begin with + hyphens. This mechanism was chosen over the RFC 934 + mechanism because the latter causes lines to grow with each + level of quoting. The combination of this growth with the + fact that SMTP implementations sometimes wrap long lines + made the RFC 934 mechanism unsuitable for use in the event + that deeply-nested multipart structuring is ever desired. + + Thus, a typical multipart Content-Type header field might + look like this: + + Content-Type: multipart/mixed; + + + + + Borenstein & Freed [Page 30] + + + + + RFC 1341MIME: Multipurpose Internet Mail ExtensionsJune 1992 + + + boundary=gc0p4Jq0M2Yt08jU534c0p + + This indicates that the entity consists of several parts, + each itself with a structure that is syntactically identical + to an RFC 822 message, except that the header area might be + completely empty, and that the parts are each preceded by + the line + + --gc0p4Jq0M2Yt08jU534c0p + + Note that the encapsulation boundary must occur at the + beginning of a line, i.e., following a CRLF, and that that + initial CRLF is considered to be part of the encapsulation + boundary rather than part of the preceding part. The + boundary must be followed immediately either by another CRLF + and the header fields for the next part, or by two CRLFs, in + which case there are no header fields for the next part (and + it is therefore assumed to be of Content-Type text/plain). + + NOTE: The CRLF preceding the encapsulation line is + considered part of the boundary so that it is possible to + have a part that does not end with a CRLF (line break). + Body parts that must be considered to end with line breaks, + therefore, should have two CRLFs preceding the encapsulation + line, the first of which is part of the preceding body part, + and the second of which is part of the encapsulation + boundary. + + The requirement that the encapsulation boundary begins with + a CRLF implies that the body of a multipart entity must + itself begin with a CRLF before the first encapsulation line + -- that is, if the "preamble" area is not used, the entity + headers must be followed by TWO CRLFs. This is indeed how + such entities should be composed. A tolerant mail reading + program, however, may interpret a body of type multipart + that begins with an encapsulation line NOT initiated by a + CRLF as also being an encapsulation boundary, but a + compliant mail sending program must not generate such + entities. + + Encapsulation boundaries must not appear within the + encapsulations, and must be no longer than 70 characters, + not counting the two leading hyphens. + + The encapsulation boundary following the last body part is a + distinguished delimiter that indicates that no further body + parts will follow. Such a delimiter is identical to the + previous delimiters, with the addition of two more hyphens + at the end of the line: + + --gc0p4Jq0M2Yt08jU534c0p-- + + There appears to be room for additional information prior to + the first encapsulation boundary and following the final + + + + Borenstein & Freed [Page 31] + + + + + RFC 1341MIME: Multipurpose Internet Mail ExtensionsJune 1992 + + + boundary. These areas should generally be left blank, and + implementations should ignore anything that appears before + the first boundary or after the last one. + + NOTE: These "preamble" and "epilogue" areas are not used + because of the lack of proper typing of these parts and the + lack of clear semantics for handling these areas at + gateways, particularly X.400 gateways. + + NOTE: Because encapsulation boundaries must not appear in + the body parts being encapsulated, a user agent must + exercise care to choose a unique boundary. The boundary in + the example above could have been the result of an algorithm + designed to produce boundaries with a very low probability + of already existing in the data to be encapsulated without + having to prescan the data. Alternate algorithms might + result in more 'readable' boundaries for a recipient with an + old user agent, but would require more attention to the + possibility that the boundary might appear in the + encapsulated part. The simplest boundary possible is + something like "---", with a closing boundary of "-----". + + As a very simple example, the following multipart message + has two parts, both of them plain text, one of them + explicitly typed and one of them implicitly typed: + + From: Nathaniel Borenstein + To: Ned Freed + Subject: Sample message + MIME-Version: 1.0 + Content-type: multipart/mixed; boundary="simple + boundary" + + This is the preamble. It is to be ignored, though it + is a handy place for mail composers to include an + explanatory note to non-MIME compliant readers. + --simple boundary + + This is implicitly typed plain ASCII text. + It does NOT end with a linebreak. + --simple boundary + Content-type: text/plain; charset=us-ascii + + This is explicitly typed plain ASCII text. + It DOES end with a linebreak. + + --simple boundary-- + This is the epilogue. It is also to be ignored. + + The use of a Content-Type of multipart in a body part within + another multipart entity is explicitly allowed. In such + cases, for obvious reasons, care must be taken to ensure + that each nested multipart entity must use a different + boundary delimiter. See Appendix C for an example of nested + + + + Borenstein & Freed [Page 32] + + + + + RFC 1341MIME: Multipurpose Internet Mail ExtensionsJune 1992 + + + multipart entities. + + The use of the multipart Content-Type with only a single + body part may be useful in certain contexts, and is + explicitly permitted. + + The only mandatory parameter for the multipart Content-Type + is the boundary parameter, which consists of 1 to 70 + characters from a set of characters known to be very robust + through email gateways, and NOT ending with white space. + (If a boundary appears to end with white space, the white + space must be presumed to have been added by a gateway, and + should be deleted.) It is formally specified by the + following BNF: + + boundary := 0*69 bcharsnospace + + bchars := bcharsnospace / " " + + bcharsnospace := DIGIT / ALPHA / "'" / "(" / ")" / "+" / + "_" + / "," / "-" / "." / "/" / ":" / "=" / "?" + + Overall, the body of a multipart entity may be specified as + follows: + + multipart-body := preamble 1*encapsulation + close-delimiter epilogue + + encapsulation := delimiter CRLF body-part + + delimiter := CRLF "--" boundary ; taken from Content-Type + field. + ; when content-type is + multipart + ; There must be no space + ; between "--" and boundary. + + close-delimiter := delimiter "--" ; Again, no space before + "--" + + preamble := *text ; to be ignored upon + receipt. + + epilogue := *text ; to be ignored upon + receipt. + + body-part = <"message" as defined in RFC 822, + with all header fields optional, and with the + specified delimiter not occurring anywhere in + the message body, either on a line by itself + or as a substring anywhere. Note that the + + + + + + Borenstein & Freed [Page 33] + + + + + RFC 1341MIME: Multipurpose Internet Mail ExtensionsJune 1992 + + + semantics of a part differ from the semantics + of a message, as described in the text.> + + NOTE: Conspicuously missing from the multipart type is a + notion of structured, related body parts. In general, it + seems premature to try to standardize interpart structure + yet. It is recommended that those wishing to provide a more + structured or integrated multipart messaging facility should + define a subtype of multipart that is syntactically + identical, but that always expects the inclusion of a + distinguished part that can be used to specify the structure + and integration of the other parts, probably referring to + them by their Content-ID field. If this approach is used, + other implementations will not recognize the new subtype, + but will treat it as the primary subtype (multipart/mixed) + and will thus be able to show the user the parts that are + recognized. + + 7.2.2 The Multipart/mixed (primary) subtype + + The primary subtype for multipart, "mixed", is intended for + use when the body parts are independent and intended to be + displayed serially. Any multipart subtypes that an + implementation does not recognize should be treated as being + of subtype "mixed". + + 7.2.3 The Multipart/alternative subtype + + The multipart/alternative type is syntactically identical to + multipart/mixed, but the semantics are different. In + particular, each of the parts is an "alternative" version of + the same information. User agents should recognize that the + content of the various parts are interchangeable. The user + agent should either choose the "best" type based on the + user's environment and preferences, or offer the user the + available alternatives. In general, choosing the best type + means displaying only the LAST part that can be displayed. + This may be used, for example, to send mail in a fancy text + format in such a way that it can easily be displayed + anywhere: + + From: Nathaniel Borenstein + To: Ned Freed + Subject: Formatted text mail + MIME-Version: 1.0 + Content-Type: multipart/alternative; boundary=boundary42 + + + --boundary42 + Content-Type: text/plain; charset=us-ascii + + ...plain text version of message goes here.... + + + + + + Borenstein & Freed [Page 34] + + + + + RFC 1341MIME: Multipurpose Internet Mail ExtensionsJune 1992 + + + --boundary42 + Content-Type: text/richtext + + .... richtext version of same message goes here ... + --boundary42 + Content-Type: text/x-whatever + + .... fanciest formatted version of same message goes here + ... + --boundary42-- + + In this example, users whose mail system understood the + "text/x-whatever" format would see only the fancy version, + while other users would see only the richtext or plain text + version, depending on the capabilities of their system. + + In general, user agents that compose multipart/alternative + entities should place the body parts in increasing order of + preference, that is, with the preferred format last. For + fancy text, the sending user agent should put the plainest + format first and the richest format last. Receiving user + agents should pick and display the last format they are + capable of displaying. In the case where one of the + alternatives is itself of type "multipart" and contains + unrecognized sub-parts, the user agent may choose either to + show that alternative, an earlier alternative, or both. + + NOTE: From an implementor's perspective, it might seem more + sensible to reverse this ordering, and have the plainest + alternative last. However, placing the plainest alternative + first is the friendliest possible option when + mutlipart/alternative entities are viewed using a non-MIME- + compliant mail reader. While this approach does impose some + burden on compliant mail readers, interoperability with + older mail readers was deemed to be more important in this + case. + + It may be the case that some user agents, if they can + recognize more than one of the formats, will prefer to offer + the user the choice of which format to view. This makes + sense, for example, if mail includes both a nicely-formatted + image version and an easily-edited text version. What is + most critical, however, is that the user not automatically + be shown multiple versions of the same data. Either the + user should be shown the last recognized version or should + explicitly be given the choice. + + + + + + + + + + + + Borenstein & Freed [Page 35] + + + + + RFC 1341MIME: Multipurpose Internet Mail ExtensionsJune 1992 + + + 7.2.4 The Multipart/digest subtype + + This document defines a "digest" subtype of the multipart + Content-Type. This type is syntactically identical to + multipart/mixed, but the semantics are different. In + particular, in a digest, the default Content-Type value for + a body part is changed from "text/plain" to + "message/rfc822". This is done to allow a more readable + digest format that is largely compatible (except for the + quoting convention) with RFC 934. + + A digest in this format might, then, look something like + this: + + From: Moderator-Address + MIME-Version: 1.0 + Subject: Internet Digest, volume 42 + Content-Type: multipart/digest; + boundary="---- next message ----" + + + ------ next message ---- + + From: someone-else + Subject: my opinion + + ...body goes here ... + + ------ next message ---- + + From: someone-else-again + Subject: my different opinion + + ... another body goes here... + + ------ next message ------ + + 7.2.5 The Multipart/parallel subtype + + This document defines a "parallel" subtype of the multipart + Content-Type. This type is syntactically identical to + multipart/mixed, but the semantics are different. In + particular, in a parallel entity, all of the parts are + intended to be presented in parallel, i.e., simultaneously, + on hardware and software that are capable of doing so. + Composing agents should be aware that many mail readers will + lack this capability and will show the parts serially in any + event. + + + + + + + + + + Borenstein & Freed [Page 36] + + + + + RFC 1341MIME: Multipurpose Internet Mail ExtensionsJune 1992 + + + 7.3 The Message Content-Type + + It is frequently desirable, in sending mail, to encapsulate + another mail message. For this common operation, a special + Content-Type, "message", is defined. The primary subtype, + message/rfc822, has no required parameters in the Content- + Type field. Additional subtypes, "partial" and "External- + body", do have required parameters. These subtypes are + explained below. + + NOTE: It has been suggested that subtypes of message might + be defined for forwarded or rejected messages. However, + forwarded and rejected messages can be handled as multipart + messages in which the first part contains any control or + descriptive information, and a second part, of type + message/rfc822, is the forwarded or rejected message. + Composing rejection and forwarding messages in this manner + will preserve the type information on the original message + and allow it to be correctly presented to the recipient, and + hence is strongly encouraged. + + As stated in the definition of the Content-Transfer-Encoding + field, no encoding other than "7bit", "8bit", or "binary" is + permitted for messages or parts of type "message". The + message header fields are always US-ASCII in any case, and + data within the body can still be encoded, in which case the + Content-Transfer-Encoding header field in the encapsulated + message will reflect this. Non-ASCII text in the headers of + an encapsulated message can be specified using the + mechanisms described in [RFC-1342]. + + Mail gateways, relays, and other mail handling agents are + commonly known to alter the top-level header of an RFC 822 + message. In particular, they frequently add, remove, or + reorder header fields. Such alterations are explicitly + forbidden for the encapsulated headers embedded in the + bodies of messages of type "message." + + 7.3.1 The Message/rfc822 (primary) subtype + + A Content-Type of "message/rfc822" indicates that the body + contains an encapsulated message, with the syntax of an RFC + 822 message. + + 7.3.2 The Message/Partial subtype + + A subtype of message, "partial", is defined in order to + allow large objects to be delivered as several separate + pieces of mail and automatically reassembled by the + receiving user agent. (The concept is similar to IP + fragmentation/reassembly in the basic Internet Protocols.) + This mechanism can be used when intermediate transport + agents limit the size of individual messages that can be + sent. Content-Type "message/partial" thus indicates that + + + + Borenstein & Freed [Page 37] + + + + + RFC 1341MIME: Multipurpose Internet Mail ExtensionsJune 1992 + + + the body contains a fragment of a larger message. + + Three parameters must be specified in the Content-Type field + of type message/partial: The first, "id", is a unique + identifier, as close to a world-unique identifier as + possible, to be used to match the parts together. (In + general, the identifier is essentially a message-id; if + placed in double quotes, it can be any message-id, in + accordance with the BNF for "parameter" given earlier in + this specification.) The second, "number", an integer, is + the part number, which indicates where this part fits into + the sequence of fragments. The third, "total", another + integer, is the total number of parts. This third subfield + is required on the final part, and is optional on the + earlier parts. Note also that these parameters may be given + in any order. + + Thus, part 2 of a 3-part message may have either of the + following header fields: + + Content-Type: Message/Partial; + number=2; total=3; + id="oc=jpbe0M2Yt4s@thumper.bellcore.com"; + + Content-Type: Message/Partial; + id="oc=jpbe0M2Yt4s@thumper.bellcore.com"; + number=2 + + But part 3 MUST specify the total number of parts: + + Content-Type: Message/Partial; + number=3; total=3; + id="oc=jpbe0M2Yt4s@thumper.bellcore.com"; + + Note that part numbering begins with 1, not 0. + + When the parts of a message broken up in this manner are put + together, the result is a complete RFC 822 format message, + which may have its own Content-Type header field, and thus + may contain any other data type. + + Message fragmentation and reassembly: The semantics of a + reassembled partial message must be those of the "inner" + message, rather than of a message containing the inner + message. This makes it possible, for example, to send a + large audio message as several partial messages, and still + have it appear to the recipient as a simple audio message + rather than as an encapsulated message containing an audio + message. That is, the encapsulation of the message is + considered to be "transparent". + + When generating and reassembling the parts of a + message/partial message, the headers of the encapsulated + message must be merged with the headers of the enclosing + + + + Borenstein & Freed [Page 38] + + + + + RFC 1341MIME: Multipurpose Internet Mail ExtensionsJune 1992 + + + entities. In this process the following rules must be + observed: + + (1) All of the headers from the initial enclosing + entity (part one), except those that start with + "Content-" and "Message-ID", must be copied, in + order, to the new message. + + (2) Only those headers in the enclosed message + which start with "Content-" and "Message-ID" must + be appended, in order, to the headers of the new + message. Any headers in the enclosed message + which do not start with "Content-" (except for + "Message-ID") will be ignored. + + (3) All of the headers from the second and any + subsequent messages will be ignored. + + For example, if an audio message is broken into two parts, + the first part might look something like this: + + X-Weird-Header-1: Foo + From: Bill@host.com + To: joe@otherhost.com + Subject: Audio mail + Message-ID: id1@host.com + MIME-Version: 1.0 + Content-type: message/partial; + id="ABC@host.com"; + number=1; total=2 + + X-Weird-Header-1: Bar + X-Weird-Header-2: Hello + Message-ID: anotherid@foo.com + Content-type: audio/basic + Content-transfer-encoding: base64 + + ... first half of encoded audio data goes here... + + and the second half might look something like this: + + From: Bill@host.com + To: joe@otherhost.com + Subject: Audio mail + MIME-Version: 1.0 + Message-ID: id2@host.com + Content-type: message/partial; + id="ABC@host.com"; number=2; total=2 + + ... second half of encoded audio data goes here... + + Then, when the fragmented message is reassembled, the + resulting message to be displayed to the user should look + something like this: + + + + Borenstein & Freed [Page 39] + + + + + RFC 1341MIME: Multipurpose Internet Mail ExtensionsJune 1992 + + + X-Weird-Header-1: Foo + From: Bill@host.com + To: joe@otherhost.com + Subject: Audio mail + Message-ID: anotherid@foo.com + MIME-Version: 1.0 + Content-type: audio/basic + Content-transfer-encoding: base64 + + ... first half of encoded audio data goes here... + ... second half of encoded audio data goes here... + + It should be noted that, because some message transfer + agents may choose to automatically fragment large messages, + and because such agents may use different fragmentation + thresholds, it is possible that the pieces of a partial + message, upon reassembly, may prove themselves to comprise a + partial message. This is explicitly permitted. + + It should also be noted that the inclusion of a "References" + field in the headers of the second and subsequent pieces of + a fragmented message that references the Message-Id on the + previous piece may be of benefit to mail readers that + understand and track references. However, the generation of + such "References" fields is entirely optional. + + 7.3.3 The Message/External-Body subtype + + The external-body subtype indicates that the actual body + data are not included, but merely referenced. In this case, + the parameters describe a mechanism for accessing the + external data. + + When a message body or body part is of type + "message/external-body", it consists of a header, two + consecutive CRLFs, and the message header for the + encapsulated message. If another pair of consecutive CRLFs + appears, this of course ends the message header for the + encapsulated message. However, since the encapsulated + message's body is itself external, it does NOT appear in the + area that follows. For example, consider the following + message: + + Content-type: message/external-body; access- + type=local-file; + name=/u/nsb/Me.gif + + Content-type: image/gif + + THIS IS NOT REALLY THE BODY! + + The area at the end, which might be called the "phantom + body", is ignored for most external-body messages. However, + it may be used to contain auxilliary information for some + + + + Borenstein & Freed [Page 40] + + + + + RFC 1341MIME: Multipurpose Internet Mail ExtensionsJune 1992 + + + such messages, as indeed it is when the access-type is + "mail-server". Of the access-types defined by this + document, the phantom body is used only when the access-type + is "mail-server". In all other cases, the phantom body is + ignored. + + The only always-mandatory parameter for message/external- + body is "access-type"; all of the other parameters may be + mandatory or optional depending on the value of access-type. + + ACCESS-TYPE -- One or more case-insensitive words, + comma-separated, indicating supported access + mechanisms by which the file or data may be + obtained. Values include, but are not limited to, + "FTP", "ANON-FTP", "TFTP", "AFS", "LOCAL-FILE", + and "MAIL-SERVER". Future values, except for + experimental values beginning with "X-", must be + registered with IANA, as described in Appendix F . + + In addition, the following two parameters are optional for + ALL access-types: + + EXPIRATION -- The date (in the RFC 822 "date-time" + syntax, as extended by RFC 1123 to permit 4 digits + in the date field) after which the existence of + the external data is not guaranteed. + + SIZE -- The size (in octets) of the data. The + intent of this parameter is to help the recipient + decide whether or not to expend the necessary + resources to retrieve the external data. + + PERMISSION -- A field that indicates whether or + not it is expected that clients might also attempt + to overwrite the data. By default, or if + permission is "read", the assumption is that they + are not, and that if the data is retrieved once, + it is never needed again. If PERMISSION is "read- + write", this assumption is invalid, and any local + copy must be considered no more than a cache. + "Read" and "Read-write" are the only defined + values of permission. + + The precise semantics of the access-types defined here are + described in the sections that follow. + + 7.3.3.1 The "ftp" and "tftp" access-types + + An access-type of FTP or TFTP indicates that the message + body is accessible as a file using the FTP [RFC-959] or TFTP + [RFC-783] protocols, respectively. For these access-types, + the following additional parameters are mandatory: + + + + + + Borenstein & Freed [Page 41] + + + + + RFC 1341MIME: Multipurpose Internet Mail ExtensionsJune 1992 + + + NAME -- The name of the file that contains the + actual body data. + + SITE -- A machine from which the file may be + obtained, using the given protocol + + Before the data is retrieved, using these protocols, the + user will generally need to be asked to provide a login id + and a password for the machine named by the site parameter. + + In addition, the following optional parameters may also + appear when the access-type is FTP or ANON-FTP: + + DIRECTORY -- A directory from which the data named + by NAME should be retrieved. + + MODE -- A transfer mode for retrieving the + information, e.g. "image". + + 7.3.3.2 The "anon-ftp" access-type + + The "anon-ftp" access-type is identical to the "ftp" access + type, except that the user need not be asked to provide a + name and password for the specified site. Instead, the ftp + protocol will be used with login "anonymous" and a password + that corresponds to the user's email address. + + 7.3.3.3 The "local-file" and "afs" access-types + + An access-type of "local-file" indicates that the actual + body is accessible as a file on the local machine. An + access-type of "afs" indicates that the file is accessible + via the global AFS file system. In both cases, only a + single parameter is required: + + NAME -- The name of the file that contains the + actual body data. + + The following optional parameter may be used to describe the + locality of reference for the data, that is, the site or + sites at which the file is expected to be visible: + + SITE -- A domain specifier for a machine or set of + machines that are known to have access to the data + file. Asterisks may be used for wildcard matching + to a part of a domain name, such as + "*.bellcore.com", to indicate a set of machines on + which the data should be directly visible, while a + single asterisk may be used to indicate a file + that is expected to be universally available, + e.g., via a global file system. + + 7.3.3.4 The "mail-server" access-type + + + + + Borenstein & Freed [Page 42] + + + + + RFC 1341MIME: Multipurpose Internet Mail ExtensionsJune 1992 + + + The "mail-server" access-type indicates that the actual body + is available from a mail server. The mandatory parameter + for this access-type is: + + SERVER -- The email address of the mail server + from which the actual body data can be obtained. + + Because mail servers accept a variety of syntax, some of + which is multiline, the full command to be sent to a mail + server is not included as a parameter on the content-type + line. Instead, it may be provided as the "phantom body" + when the content-type is message/external-body and the + access-type is mail-server. + + Note that MIME does not define a mail server syntax. + Rather, it allows the inclusion of arbitrary mail server + commands in the phantom body. Implementations should + include the phantom body in the body of the message it sends + to the mail server address to retrieve the relevant data. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Borenstein & Freed [Page 43] + + + + + RFC 1341MIME: Multipurpose Internet Mail ExtensionsJune 1992 + + + 7.3.3.5 Examples and Further Explanations + + With the emerging possibility of very wide-area file + systems, it becomes very hard to know in advance the set of + machines where a file will and will not be accessible + directly from the file system. Therefore it may make sense + to provide both a file name, to be tried directly, and the + name of one or more sites from which the file is known to be + accessible. An implementation can try to retrieve remote + files using FTP or any other protocol, using anonymous file + retrieval or prompting the user for the necessary name and + password. If an external body is accessible via multiple + mechanisms, the sender may include multiple parts of type + message/external-body within an entity of type + multipart/alternative. + + However, the external-body mechanism is not intended to be + limited to file retrieval, as shown by the mail-server + access-type. Beyond this, one can imagine, for example, + using a video server for external references to video clips. + + If an entity is of type "message/external-body", then the + body of the entity will contain the header fields of the + encapsulated message. The body itself is to be found in the + external location. This means that if the body of the + "message/external-body" message contains two consecutive + CRLFs, everything after those pairs is NOT part of the + message itself. For most message/external-body messages, + this trailing area must simply be ignored. However, it is a + convenient place for additional data that cannot be included + in the content-type header field. In particular, if the + "access-type" value is "mail-server", then the trailing area + must contain commands to be sent to the mail server at the + address given by NAME@SITE, where NAME and SITE are the + values of the NAME and SITE parameters, respectively. + + The embedded message header fields which appear in the body + of the message/external-body data can be used to declare the + Content-type of the external body. Thus a complete + message/external-body message, referring to a document in + PostScript format, might look like this: + + From: Whomever + Subject: whatever + MIME-Version: 1.0 + Message-ID: id1@host.com + Content-Type: multipart/alternative; boundary=42 + + + --42 + Content-Type: message/external-body; + name="BodyFormats.ps"; + + + + + + Borenstein & Freed [Page 44] + + + + + RFC 1341MIME: Multipurpose Internet Mail ExtensionsJune 1992 + + + site="thumper.bellcore.com"; + access-type=ANON-FTP; + directory="pub"; + mode="image"; + expiration="Fri, 14 Jun 1991 19:13:14 -0400 (EDT)" + + Content-type: application/postscript + + --42 + Content-Type: message/external-body; + name="/u/nsb/writing/rfcs/RFC-XXXX.ps"; + site="thumper.bellcore.com"; + access-type=AFS + expiration="Fri, 14 Jun 1991 19:13:14 -0400 (EDT)" + + Content-type: application/postscript + + --42 + Content-Type: message/external-body; + access-type=mail-server + server="listserv@bogus.bitnet"; + expiration="Fri, 14 Jun 1991 19:13:14 -0400 (EDT)" + + Content-type: application/postscript + + get rfc-xxxx doc + + --42-- + + Like the message/partial type, the message/external-body + type is intended to be transparent, that is, to convey the + data type in the external body rather than to convey a + message with a body of that type. Thus the headers on the + outer and inner parts must be merged using the same rules as + for message/partial. In particular, this means that the + Content-type header is overridden, but the From and Subject + headers are preserved. + + Note that since the external bodies are not transported as + mail, they need not conform to the 7-bit and line length + requirements, but might in fact be binary files. Thus a + Content-Transfer-Encoding is not generally necessary, though + it is permitted. + + Note that the body of a message of type "message/external- + body" is governed by the basic syntax for an RFC 822 + message. In particular, anything before the first + consecutive pair of CRLFs is header information, while + anything after it is body information, which is ignored for + most access-types. + + + + + + + + Borenstein & Freed [Page 45] + + + + + RFC 1341MIME: Multipurpose Internet Mail ExtensionsJune 1992 + + + 7.4 The Application Content-Type + + The "application" Content-Type is to be used for data which + do not fit in any of the other categories, and particularly + for data to be processed by mail-based uses of application + programs. This is information which must be processed by an + application before it is viewable or usable to a user. + Expected uses for Content-Type application include mail- + based file transfer, spreadsheets, data for mail-based + scheduling systems, and languages for "active" + (computational) email. (The latter, in particular, can pose + security problems which should be understood by + implementors, and are considered in detail in the discussion + of the application/PostScript content-type.) + + For example, a meeting scheduler might define a standard + representation for information about proposed meeting dates. + An intelligent user agent would use this information to + conduct a dialog with the user, and might then send further + mail based on that dialog. More generally, there have been + several "active" messaging languages developed in which + programs in a suitably specialized language are sent through + the mail and automatically run in the recipient's + environment. + + Such applications may be defined as subtypes of the + "application" Content-Type. This document defines three + subtypes: octet-stream, ODA, and PostScript. + + In general, the subtype of application will often be the + name of the application for which the data are intended. + This does not mean, however, that any application program + name may be used freely as a subtype of application. Such + usages must be registered with IANA, as described in + Appendix F. + + 7.4.1 The Application/Octet-Stream (primary) subtype + + The primary subtype of application, "octet-stream", may be + used to indicate that a body contains binary data. The set + of possible parameters includes, but is not limited to: + + NAME -- a suggested name for the binary data if + stored as a file. + + TYPE -- the general type or category of binary + data. This is intended as information for the + human recipient rather than for any automatic + processing. + + CONVERSIONS -- the set of operations that have + been performed on the data before putting it in + the mail (and before any Content-Transfer-Encoding + that might have been applied). If multiple + + + + Borenstein & Freed [Page 46] + + + + + RFC 1341MIME: Multipurpose Internet Mail ExtensionsJune 1992 + + + conversions have occurred, they must be separated + by commas and specified in the order they were + applied -- that is, the leftmost conversion must + have occurred first, and conversions are undone + from right to left. Note that NO conversion + values are defined by this document. Any + conversion values that that do not begin with "X-" + must be preceded by a published specification and + by registration with IANA, as described in + Appendix F. + + PADDING -- the number of bits of padding that were + appended to the bitstream comprising the actual + contents to produce the enclosed byte-oriented + data. This is useful for enclosing a bitstream in + a body when the total number of bits is not a + multiple of the byte size. + + The values for these attributes are left undefined at + present, but may require specification in the future. An + example of a common (though UNIX-specific) usage might be: + + Content-Type: application/octet-stream; + name=foo.tar.Z; type=tar; + conversions="x-encrypt,x-compress" + + However, it should be noted that the use of such conversions + is explicitly discouraged due to a lack of portability and + standardization. The use of uuencode is particularly + discouraged, in favor of the Content-Transfer-Encoding + mechanism, which is both more standardized and more portable + across mail boundaries. + + The recommended action for an implementation that receives + application/octet-stream mail is to simply offer to put the + data in a file, with any Content-Transfer-Encoding undone, + or perhaps to use it as input to a user-specified process. + + To reduce the danger of transmitting rogue programs through + the mail, it is strongly recommended that implementations + NOT implement a path-search mechanism whereby an arbitrary + program named in the Content-Type parameter (e.g., an + "interpreter=" parameter) is found and executed using the + mail body as input. + + 7.4.2 The Application/PostScript subtype + + A Content-Type of "application/postscript" indicates a + PostScript program. The language is defined in + [POSTSCRIPT]. It is recommended that Postscript as sent + through email should use Postscript document structuring + conventions if at all possible, and correctly. + + + + + + Borenstein & Freed [Page 47] + + + + + RFC 1341MIME: Multipurpose Internet Mail ExtensionsJune 1992 + + + The execution of general-purpose PostScript interpreters + entails serious security risks, and implementors are + discouraged from simply sending PostScript email bodies to + "off-the-shelf" interpreters. While it is usually safe to + send PostScript to a printer, where the potential for harm + is greatly constrained, implementors should consider all of + the following before they add interactive display of + PostScript bodies to their mail readers. + + The remainder of this section outlines some, though probably + not all, of the possible problems with sending PostScript + through the mail. + + Dangerous operations in the PostScript language include, but + may not be limited to, the PostScript operators deletefile, + renamefile, filenameforall, and file. File is only + dangerous when applied to something other than standard + input or output. Implementations may also define additional + nonstandard file operators; these may also pose a threat to + security. Filenameforall, the wildcard file search + operator, may appear at first glance to be harmless. Note, + however, that this operator has the potential to reveal + information about what files the recipient has access to, + and this information may itself be sensitive. Message + senders should avoid the use of potentially dangerous file + operators, since these operators are quite likely to be + unavailable in secure PostScript implementations. Message- + receiving and -displaying software should either completely + disable all potentially dangerous file operators or take + special care not to delegate any special authority to their + operation. These operators should be viewed as being done by + an outside agency when interpreting PostScript documents. + Such disabling and/or checking should be done completely + outside of the reach of the PostScript language itself; care + should be taken to insure that no method exists for + reenabling full-function versions of these operators. + + The PostScript language provides facilities for exiting the + normal interpreter, or server, loop. Changes made in this + "outer" environment are customarily retained across + documents, and may in some cases be retained semipermanently + in nonvolatile memory. The operators associated with exiting + the interpreter loop have the potential to interfere with + subsequent document processing. As such, their unrestrained + use constitutes a threat of service denial. PostScript + operators that exit the interpreter loop include, but may + not be limited to, the exitserver and startjob operators. + Message-sending software should not generate PostScript that + depends on exiting the interpreter loop to operate. The + ability to exit will probably be unavailable in secure + PostScript implementations. Message-receiving and + -displaying software should, if possible, disable the + ability to make retained changes to the PostScript + environment. Eliminate the startjob and exitserver commands. + + + + Borenstein & Freed [Page 48] + + + + + RFC 1341MIME: Multipurpose Internet Mail ExtensionsJune 1992 + + + If these commands cannot be eliminated, at least set the + password associated with them to a hard-to-guess value. + + PostScript provides operators for setting system-wide and + device-specific parameters. These parameter settings may be + retained across jobs and may potentially pose a threat to + the correct operation of the interpreter. The PostScript + operators that set system and device parameters include, but + may not be limited to, the setsystemparams and setdevparams + operators. Message-sending software should not generate + PostScript that depends on the setting of system or device + parameters to operate correctly. The ability to set these + parameters will probably be unavailable in secure PostScript + implementations. Message-receiving and -displaying software + should, if possible, disable the ability to change system + and device parameters. If these operators cannot be + disabled, at least set the password associated with them to + a hard-to-guess value. + + Some PostScript implementations provide nonstandard + facilities for the direct loading and execution of machine + code. Such facilities are quite obviously open to + substantial abuse. Message-sending software should not + make use of such features. Besides being totally hardware- + specific, they are also likely to be unavailable in secure + implementations of PostScript. Message-receiving and + -displaying software should not allow such operators to be + used if they exist. + + PostScript is an extensible language, and many, if not most, + implementations of it provide a number of their own + extensions. This document does not deal with such extensions + explicitly since they constitute an unknown factor. + Message-sending software should not make use of nonstandard + extensions; they are likely to be missing from some + implementations. Message-receiving and -displaying software + should make sure that any nonstandard PostScript operators + are secure and don't present any kind of threat. + + It is possible to write PostScript that consumes huge + amounts of various system resources. It is also possible to + write PostScript programs that loop infinitely. Both types + of programs have the potential to cause damage if sent to + unsuspecting recipients. Message-sending software should + avoid the construction and dissemination of such programs, + which is antisocial. Message-receiving and -displaying + software should provide appropriate mechanisms to abort + processing of a document after a reasonable amount of time + has elapsed. In addition, PostScript interpreters should be + limited to the consumption of only a reasonable amount of + any given system resource. + + Finally, bugs may exist in some PostScript interpreters + which could possibly be exploited to gain unauthorized + + + + Borenstein & Freed [Page 49] + + + + + RFC 1341MIME: Multipurpose Internet Mail ExtensionsJune 1992 + + + access to a recipient's system. Apart from noting this + possibility, there is no specific action to take to prevent + this, apart from the timely correction of such bugs if any + are found. + + 7.4.3 The Application/ODA subtype + + The "ODA" subtype of application is used to indicate that a + body contains information encoded according to the Office + Document Architecture [ODA] standards, using the ODIF + representation format. For application/oda, the Content- + Type line should also specify an attribute/value pair that + indicates the document application profile (DAP), using the + key word "profile". Thus an appropriate header field might + look like this: + + Content-Type: application/oda; profile=Q112 + + Consult the ODA standard [ODA] for further information. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Borenstein & Freed [Page 50] + + + + + RFC 1341MIME: Multipurpose Internet Mail ExtensionsJune 1992 + + + 7.5 The Image Content-Type + + A Content-Type of "image" indicates that the bodycontains an + image. The subtype names the specific image format. These + names are case insensitive. Two initial subtypes are "jpeg" + for the JPEG format, JFIF encoding, and "gif" for GIF format + [GIF]. + + The list of image subtypes given here is neither exclusive + nor exhaustive, and is expected to grow as more types are + registered with IANA, as described in Appendix F. + + 7.6 The Audio Content-Type + + A Content-Type of "audio" indicates that the body contains + audio data. Although there is not yet a consensus on an + "ideal" audio format for use with computers, there is a + pressing need for a format capable of providing + interoperable behavior. + + The initial subtype of "basic" is specified to meet this + requirement by providing an absolutely minimal lowest common + denominator audio format. It is expected that richer + formats for higher quality and/or lower bandwidth audio will + be defined by a later document. + + The content of the "audio/basic" subtype is audio encoded + using 8-bit ISDN u-law [PCM]. When this subtype is present, + a sample rate of 8000 Hz and a single channel is assumed. + + 7.7 The Video Content-Type + + A Content-Type of "video" indicates that the body contains a + time-varying-picture image, possibly with color and + coordinated sound. The term "video" is used extremely + generically, rather than with reference to any particular + technology or format, and is not meant to preclude subtypes + such as animated drawings encoded compactly. The subtype + "mpeg" refers to video coded according to the MPEG standard + [MPEG]. + + Note that although in general this document strongly + discourages the mixing of multiple media in a single body, + it is recognized that many so-called "video" formats include + a representation for synchronized audio, and this is + explicitly permitted for subtypes of "video". + + 7.8 Experimental Content-Type Values + + A Content-Type value beginning with the characters "X-" is a + private value, to be used by consenting mail systems by + mutual agreement. Any format without a rigorous and public + definition must be named with an "X-" prefix, and publicly + specified values shall never begin with "X-". (Older + + + + Borenstein & Freed [Page 51] + + + + + RFC 1341MIME: Multipurpose Internet Mail ExtensionsJune 1992 + + + versions of the widely-used Andrew system use the "X-BE2" + name, so new systems should probably choose a different + name.) + + In general, the use of "X-" top-level types is strongly + discouraged. Implementors should invent subtypes of the + existing types whenever possible. The invention of new + types is intended to be restricted primarily to the + development of new media types for email, such as digital + odors or holography, and not for new data formats in + general. In many cases, a subtype of application will be + more appropriate than a new top-level type. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Borenstein & Freed [Page 52] + + + + + RFC 1341MIME: Multipurpose Internet Mail ExtensionsJune 1992 + + + Summary + + Using the MIME-Version, Content-Type, and Content-Transfer- + Encoding header fields, it is possible to include, in a + standardized way, arbitrary types of data objects with RFC + 822 conformant mail messages. No restrictions imposed by + either RFC 821 or RFC 822 are violated, and care has been + taken to avoid problems caused by additional restrictions + imposed by the characteristics of some Internet mail + transport mechanisms (see Appendix B). The "multipart" and + "message" Content-Types allow mixing and hierarchical + structuring of objects of different types in a single + message. Further Content-Types provide a standardized + mechanism for tagging messages or body parts as audio, + image, or several other kinds of data. A distinguished + parameter syntax allows further specification of data format + details, particularly the specification of alternate + character sets. Additional optional header fields provide + mechanisms for certain extensions deemed desirable by many + implementors. Finally, a number of useful Content-Types are + defined for general use by consenting user agents, notably + text/richtext, message/partial, and message/external-body. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Borenstein & Freed [Page 53] + + + + + RFC 1341MIME: Multipurpose Internet Mail ExtensionsJune 1992 + + + Acknowledgements + + This document is the result of the collective effort of a + large number of people, at several IETF meetings, on the + IETF-SMTP and IETF-822 mailing lists, and elsewhere. + Although any enumeration seems doomed to suffer from + egregious omissions, the following are among the many + contributors to this effort: + + Harald Tveit Alvestrand Timo Lehtinen + Randall Atkinson John R. MacMillan + Philippe Brandon Rick McGowan + Kevin Carosso Leo Mclaughlin + Uhhyung Choi Goli Montaser-Kohsari + Cristian Constantinof Keith Moore + Mark Crispin Tom Moore + Dave Crocker Erik Naggum + Terry Crowley Mark Needleman + Walt Daniels John Noerenberg + Frank Dawson Mats Ohrman + Hitoshi Doi Julian Onions + Kevin Donnelly Michael Patton + Keith Edwards David J. Pepper + Chris Eich Blake C. Ramsdell + Johnny Eriksson Luc Rooijakkers + Craig Everhart Marshall T. Rose + Patrik Faeltstroem Jonathan Rosenberg + Erik E. Fair Jan Rynning + Roger Fajman Harri Salminen + Alain Fontaine Michael Sanderson + James M. Galvin Masahiro Sekiguchi + Philip Gladstone Mark Sherman + Thomas Gordon Keld Simonsen + Phill Gross Bob Smart + James Hamilton Peter Speck + Steve Hardcastle-Kille Henry Spencer + David Herron Einar Stefferud + Bruce Howard Michael Stein + Bill Janssen Klaus Steinberger + Olle Jaernefors Peter Svanberg + Risto Kankkunen James Thompson + Phil Karn Steve Uhler + Alan Katz Stuart Vance + Tim Kehres Erik van der Poel + Neil Katin Guido van Rossum + Kyuho Kim Peter Vanderbilt + Anders Klemets Greg Vaudreuil + John Klensin Ed Vielmetti + Valdis Kletniek Ryan Waldron + Jim Knowles Wally Wedel + Stev Knowles Sven-Ove Westberg + Bob Kummerfeld Brian Wideen + + + + + + Borenstein & Freed [Page 54] + + + + + RFC 1341MIME: Multipurpose Internet Mail ExtensionsJune 1992 + + + Pekka Kytolaakso John Wobus + Stellan Lagerstr.m Glenn Wright + Vincent Lau Rayan Zachariassen + Donald Lindsay David Zimmerman + The authors apologize for any omissions from this list, + which are certainly unintentional. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Borenstein & Freed [Page 55] + + + + + RFC 1341MIME: Multipurpose Internet Mail ExtensionsJune 1992 + + + Appendix A -- Minimal MIME-Conformance + + The mechanisms described in this document are open-ended. + It is definitely not expected that all implementations will + support all of the Content-Types described, nor that they + will all share the same extensions. In order to promote + interoperability, however, it is useful to define the + concept of "MIME-conformance" to define a certain level of + implementation that allows the useful interworking of + messages with content that differs from US ASCII text. In + this section, we specify the requirements for such + conformance. + + A mail user agent that is MIME-conformant MUST: + + 1. Always generate a "MIME-Version: 1.0" header + field. + + 2. Recognize the Content-Transfer-Encoding header + field, and decode all received data encoded with + either the quoted-printable or base64 + implementations. Encode any data sent that is + not in seven-bit mail-ready representation using + one of these transformations and include the + appropriate Content-Transfer-Encoding header + field, unless the underlying transport mechanism + supports non-seven-bit data, as SMTP does not. + + 3. Recognize and interpret the Content-Type + header field, and avoid showing users raw data + with a Content-Type field other than text. Be + able to send at least text/plain messages, with + the character set specified as a parameter if it + is not US-ASCII. + + 4. Explicitly handle the following Content-Type + values, to at least the following extents: + + Text: + -- Recognize and display "text" mail + with the character set "US-ASCII." + -- Recognize other character sets at + least to the extent of being able + to inform the user about what + character set the message uses. + -- Recognize the "ISO-8859-*" character + sets to the extent of being able to + display those characters that are + common to ISO-8859-* and US-ASCII, + namely all characters represented + by octet values 0-127. + -- For unrecognized subtypes, show or + offer to show the user the "raw" + version of the data. An ability at + + + + Borenstein & Freed [Page 56] + + + + + RFC 1341MIME: Multipurpose Internet Mail ExtensionsJune 1992 + + + least to convert "text/richtext" to + plain text, as shown in Appendix D, + is encouraged, but not required for + conformance. + Message: + --Recognize and display at least the + primary (822) encapsulation. + Multipart: + -- Recognize the primary (mixed) + subtype. Display all relevant + information on the message level + and the body part header level and + then display or offer to display + each of the body parts + individually. + -- Recognize the "alternative" subtype, + and avoid showing the user + redundant parts of + multipart/alternative mail. + -- Treat any unrecognized subtypes as if + they were "mixed". + Application: + -- Offer the ability to remove either of + the two types of Content-Transfer- + Encoding defined in this document + and put the resulting information + in a user file. + + 5. Upon encountering any unrecognized Content- + Type, an implementation must treat it as if it had + a Content-Type of "application/octet-stream" with + no parameter sub-arguments. How such data are + handled is up to an implementation, but likely + options for handling such unrecognized data + include offering the user to write it into a file + (decoded from its mail transport format) or + offering the user to name a program to which the + decoded data should be passed as input. + Unrecognized predefined types, which in a MIME- + conformant mailer might still include audio, + image, or video, should also be treated in this + way. + + A user agent that meets the above conditions is said to be + MIME-conformant. The meaning of this phrase is that it is + assumed to be "safe" to send virtually any kind of + properly-marked data to users of such mail systems, because + such systems will at least be able to treat the data as + undifferentiated binary, and will not simply splash it onto + the screen of unsuspecting users. There is another sense + in which it is always "safe" to send data in a format that + is MIME-conformant, which is that such data will not break + or be broken by any known systems that are conformant with + RFC 821 and RFC 822. User agents that are MIME-conformant + + + + Borenstein & Freed [Page 57] + + + + + RFC 1341MIME: Multipurpose Internet Mail ExtensionsJune 1992 + + + have the additional guarantee that the user will not be + shown data that were never intended to be viewed as text. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Borenstein & Freed [Page 58] + + + + + RFC 1341MIME: Multipurpose Internet Mail ExtensionsJune 1992 + + + Appendix B -- General Guidelines For Sending Email Data + + Internet email is not a perfect, homogeneous system. Mail + may become corrupted at several stages in its travel to a + final destination. Specifically, email sent throughout the + Internet may travel across many networking technologies. + Many networking and mail technologies do not support the + full functionality possible in the SMTP transport + environment. Mail traversing these systems is likely to be + modified in such a way that it can be transported. + + There exist many widely-deployed non-conformant MTAs in the + Internet. These MTAs, speaking the SMTP protocol, alter + messages on the fly to take advantage of the internal data + structure of the hosts they are implemented on, or are just + plain broken. + + The following guidelines may be useful to anyone devising a + data format (Content-Type) that will survive the widest + range of networking technologies and known broken MTAs + unscathed. Note that anything encoded in the base64 + encoding will satisfy these rules, but that some well-known + mechanisms, notably the UNIX uuencode facility, will not. + Note also that anything encoded in the Quoted-Printable + encoding will survive most gateways intact, but possibly not + some gateways to systems that use the EBCDIC character set. + + (1) Under some circumstances the encoding used for + data may change as part of normal gateway or user + agent operation. In particular, conversion from + base64 to quoted-printable and vice versa may be + necessary. This may result in the confusion of + CRLF sequences with line breaks in text body + parts. As such, the persistence of CRLF as + something other than a line break should not be + relied on. + + (2) Many systems may elect to represent and store + text data using local newline conventions. Local + newline conventions may not match the RFC822 CRLF + convention -- systems are known that use plain CR, + plain LF, CRLF, or counted records. The result is + that isolated CR and LF characters are not well + tolerated in general; they may be lost or + converted to delimiters on some systems, and hence + should not be relied on. + + (3) TAB (HT) characters may be misinterpreted or + may be automatically converted to variable numbers + of spaces. This is unavoidable in some + environments, notably those not based on the ASCII + character set. Such conversion is STRONGLY + DISCOURAGED, but it may occur, and mail formats + should not rely on the persistence of TAB (HT) + + + + Borenstein & Freed [Page 59] + + + + + RFC 1341MIME: Multipurpose Internet Mail ExtensionsJune 1992 + + + characters. + + (4) Lines longer than 76 characters may be wrapped + or truncated in some environments. Line wrapping + and line truncation are STRONGLY DISCOURAGED, but + unavoidable in some cases. Applications which + require long lines should somehow differentiate + between soft and hard line breaks. (A simple way + to do this is to use the quoted-printable + encoding.) + + (5) Trailing "white space" characters (SPACE, TAB + (HT)) on a line may be discarded by some transport + agents, while other transport agents may pad lines + with these characters so that all lines in a mail + file are of equal length. The persistence of + trailing white space, therefore, should not be + relied on. + + (6) Many mail domains use variations on the ASCII + character set, or use character sets such as + EBCDIC which contain most but not all of the US- + ASCII characters. The correct translation of + characters not in the "invariant" set cannot be + depended on across character converting gateways. + For example, this situation is a problem when + sending uuencoded information across BITNET, an + EBCDIC system. Similar problems can occur without + crossing a gateway, since many Internet hosts use + character sets other than ASCII internally. The + definition of Printable Strings in X.400 adds + further restrictions in certain special cases. In + particular, the only characters that are known to + be consistent across all gateways are the 73 + characters that correspond to the upper and lower + case letters A-Z and a-z, the 10 digits 0-9, and + the following eleven special characters: + + "'" (ASCII code 39) + "(" (ASCII code 40) + ")" (ASCII code 41) + "+" (ASCII code 43) + "," (ASCII code 44) + "-" (ASCII code 45) + "." (ASCII code 46) + "/" (ASCII code 47) + ":" (ASCII code 58) + "=" (ASCII code 61) + "?" (ASCII code 63) + + A maximally portable mail representation, such as + the base64 encoding, will confine itself to + relatively short lines of text in which the only + meaningful characters are taken from this set of + + + + Borenstein & Freed [Page 60] + + + + + RFC 1341MIME: Multipurpose Internet Mail ExtensionsJune 1992 + + + 73 characters. + + Please note that the above list is NOT a list of recommended + practices for MTAs. RFC 821 MTAs are prohibited from + altering the character of white space or wrapping long + lines. These BAD and illegal practices are known to occur + on established networks, and implementions should be robust + in dealing with the bad effects they can cause. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Borenstein & Freed [Page 61] + + + + + RFC 1341MIME: Multipurpose Internet Mail ExtensionsJune 1992 + + + Appendix C -- A Complex Multipart Example + + What follows is the outline of a complex multipart message. + This message has five parts to be displayed serially: two + introductory plain text parts, an embedded multipart + message, a richtext part, and a closing encapsulated text + message in a non-ASCII character set. The embedded + multipart message has two parts to be displayed in parallel, + a picture and an audio fragment. + + MIME-Version: 1.0 + From: Nathaniel Borenstein + Subject: A multipart example + Content-Type: multipart/mixed; + boundary=unique-boundary-1 + + This is the preamble area of a multipart message. + Mail readers that understand multipart format + should ignore this preamble. + If you are reading this text, you might want to + consider changing to a mail reader that understands + how to properly display multipart messages. + --unique-boundary-1 + + ...Some text appears here... + [Note that the preceding blank line means + no header fields were given and this is text, + with charset US ASCII. It could have been + done with explicit typing as in the next part.] + + --unique-boundary-1 + Content-type: text/plain; charset=US-ASCII + + This could have been part of the previous part, + but illustrates explicit versus implicit + typing of body parts. + + --unique-boundary-1 + Content-Type: multipart/parallel; + boundary=unique-boundary-2 + + + --unique-boundary-2 + Content-Type: audio/basic + Content-Transfer-Encoding: base64 + + ... base64-encoded 8000 Hz single-channel + u-law-format audio data goes here.... + + --unique-boundary-2 + Content-Type: image/gif + Content-Transfer-Encoding: Base64 + + + + + + Borenstein & Freed [Page 62] + + + + + RFC 1341MIME: Multipurpose Internet Mail ExtensionsJune 1992 + + + ... base64-encoded image data goes here.... + + --unique-boundary-2-- + + --unique-boundary-1 + Content-type: text/richtext + + This is richtext. + Isn't it + cool? + + --unique-boundary-1 + Content-Type: message/rfc822 + + From: (name in US-ASCII) + Subject: (subject in US-ASCII) + Content-Type: Text/plain; charset=ISO-8859-1 + Content-Transfer-Encoding: Quoted-printable + + ... Additional text in ISO-8859-1 goes here ... + + --unique-boundary-1-- + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Borenstein & Freed [Page 63] + + + + + RFC 1341MIME: Multipurpose Internet Mail ExtensionsJune 1992 + + + Appendix D -- A Simple Richtext-to-Text Translator in C + + One of the major goals in the design of the richtext subtype + of the text Content-Type is to make formatted text so simple + that even text-only mailers will implement richtext-to- + plain-text translators, thus increasing the likelihood that + multifont text will become "safe" to use very widely. To + demonstrate this simplicity, what follows is an extremely + simple 44-line C program that converts richtext input into + plain text output: + + #include + #include + main() { + int c, i; + char token[50]; + + while((c = getc(stdin)) != EOF) { + if (c == '<') { + for (i=0; (i<49 && (c = getc(stdin)) != '>' + && c != EOF); ++i) { + token[i] = isupper(c) ? tolower(c) : c; + } + if (c == EOF) break; + if (c != '>') while ((c = getc(stdin)) != + '>' + && c != EOF) {;} + if (c == EOF) break; + token[i] = '\0'; + if (!strcmp(token, "lt")) { + putc('<', stdout); + } else if (!strcmp(token, "nl")) { + putc('\n', stdout); + } else if (!strcmp(token, "/paragraph")) { + fputs("\n\n", stdout); + } else if (!strcmp(token, "comment")) { + int commct=1; + while (commct > 0) { + while ((c = getc(stdin)) != '<' + && c != EOF) ; + if (c == EOF) break; + for (i=0; (c = getc(stdin)) != '>' + && c != EOF; ++i) { + token[i] = isupper(c) ? + tolower(c) : c; + } + if (c== EOF) break; + token[i] = NULL; + if (!strcmp(token, "/comment")) -- + commct; + if (!strcmp(token, "comment")) + ++commct; + + + + + + Borenstein & Freed [Page 64] + + + + + RFC 1341MIME: Multipurpose Internet Mail ExtensionsJune 1992 + + + } + } /* Ignore all other tokens */ + } else if (c != '\n') putc(c, stdout); + } + putc('\n', stdout); /* for good measure */ + } + It should be noted that one can do considerably better than + this in displaying richtext data on a dumb terminal. In + particular, one can replace font information such as "bold" + with textual emphasis (like *this* or _T_H_I_S_). One can + also properly handle the richtext formatting commands + regarding indentation, justification, and others. However, + the above program is all that is necessary in order to + present richtext on a dumb terminal. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Borenstein & Freed [Page 65] + + + + + RFC 1341MIME: Multipurpose Internet Mail ExtensionsJune 1992 + + + Appendix E -- Collected Grammar + + This appendix contains the complete BNF grammar for all the + syntax specified by this document. + + By itself, however, this grammar is incomplete. It refers + to several entities that are defined by RFC 822. Rather + than reproduce those definitions here, and risk + unintentional differences between the two, this document + simply refers the reader to RFC 822 for the remaining + definitions. Wherever a term is undefined, it refers to the + RFC 822 definition. + + attribute := token + + body-part = <"message" as defined in RFC 822, + with all header fields optional, and with the + specified delimiter not occurring anywhere in + the message body, either on a line by itself + or as a substring anywhere.> + + boundary := 0*69 bcharsnospace + + bchars := bcharsnospace / " " + + bcharsnospace := DIGIT / ALPHA / "'" / "(" / ")" / "+" / + "_" + / "," / "-" / "." / "/" / ":" / "=" / "?" + + close-delimiter := delimiter "--" + + Content-Description := *text + + Content-ID := msg-id + + Content-Transfer-Encoding := "BASE64" / "QUOTED- + PRINTABLE" / + "8BIT" / "7BIT" / + "BINARY" / x-token + + Content-Type := type "/" subtype *[";" parameter] + + delimiter := CRLF "--" boundary ; taken from Content-Type + field. + ; when content-type is + multipart + ; There should be no space + ; between "--" and boundary. + + encapsulation := delimiter CRLF body-part + + epilogue := *text ; to be ignored upon + receipt. + + + + + Borenstein & Freed [Page 66] + + + + + RFC 1341MIME: Multipurpose Internet Mail ExtensionsJune 1992 + + + MIME-Version := 1*text + + multipart-body := preamble 1*encapsulation close-delimiter + epilogue + + parameter := attribute "=" value + + preamble := *text ; to be ignored upon + receipt. + + subtype := token + + token := 1* + + tspecials := "(" / ")" / "<" / ">" / "@" ; Must be in + / "," / ";" / ":" / "\" / <"> ; quoted-string, + / "/" / "[" / "]" / "?" / "." ; to use within + / "=" ; parameter values + + + type := "application" / "audio" ; case- + insensitive + / "image" / "message" + / "multipart" / "text" + / "video" / x-token + + value := token / quoted-string + + x-token := + + + + + + + + + + + + + + + + + + + + + + + + + + + + Borenstein & Freed [Page 67] + + + + + RFC 1341MIME: Multipurpose Internet Mail ExtensionsJune 1992 + + + Appendix F -- IANA Registration Procedures + + MIME has been carefully designed to have extensible + mechanisms, and it is expected that the set of content- + type/subtype pairs and their associated parameters will grow + significantly with time. Several other MIME fields, notably + character set names, access-type parameters for the + message/external-body type, conversions parameters for the + application type, and possibly even Content-Transfer- + Encoding values, are likely to have new values defined over + time. In order to ensure that the set of such values is + developed in an orderly, well-specified, and public manner, + MIME defines a registration process which uses the Internet + Assigned Numbers Authority (IANA) as a central registry for + such values. + + In general, parameters in the content-type header field are + used to convey supplemental information for various content + types, and their use is defined when the content-type and + subtype are defined. New parameters should not be defined + as a way to introduce new functionality. + + In order to simplify and standardize the registration + process, this appendix gives templates for the registration + of new values with IANA. Each of these is given in the form + of an email message template, to be filled in by the + registering party. + + F.1 Registration of New Content-type/subtype Values + + Note that MIME is generally expected to be extended by + subtypes. If a new fundamental top-level type is needed, + its specification should be published as an RFC or + submitted in a form suitable to become an RFC, and be + subject to the Internet standards process. + + To: IANA@isi.edu + Subject: Registration of new MIME content-type/subtype + + MIME type name: + + (If the above is not an existing top-level MIME type, + please explain why an existing type cannot be used.) + + MIME subtype name: + + Required parameters: + + Optional parameters: + + Encoding considerations: + + Security considerations: + + + + + Borenstein & Freed [Page 68] + + + + + RFC 1341MIME: Multipurpose Internet Mail ExtensionsJune 1992 + + + Published specification: + + (The published specification must be an Internet RFC or + RFC-to-be if a new top-level type is being defined, and + must be a publicly available specification in any + case.) + + Person & email address to contact for further + information: + F.2 Registration of New Character Set Values + + To: IANA@isi.edu + Subject: Registration of new MIME character set value + + MIME character set name: + + Published specification: + + (The published specification must be an Internet RFC or + RFC-to-be or an international standard.) + + Person & email address to contact for further + information: + + F.3 Registration of New Access-type Values for + Message/external-body + + To: IANA@isi.edu + Subject: Registration of new MIME Access-type for + Message/external-body content-type + + MIME access-type name: + + Required parameters: + + Optional parameters: + + Published specification: + + (The published specification must be an Internet RFC or + RFC-to-be.) + + Person & email address to contact for further + information: + + + F.4 Registration of New Conversions Values for Application + + To: IANA@isi.edu + Subject: Registration of new MIME Conversions value + for Application content-type + + MIME Conversions name: + + + + + Borenstein & Freed [Page 69] + + + + + RFC 1341MIME: Multipurpose Internet Mail ExtensionsJune 1992 + + + Published specification: + + (The published specification must be an Internet RFC or + RFC-to-be.) + + Person & email address to contact for further + information: + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Borenstein & Freed [Page 70] + + + + + RFC 1341MIME: Multipurpose Internet Mail ExtensionsJune 1992 + + + Appendix G -- Summary of the Seven Content-types + + Content-type: text + + Subtypes defined by this document: plain, richtext + + Important Parameters: charset + + Encoding notes: quoted-printable generally preferred if an + encoding is needed and the character set is mostly an + ASCII superset. + + Security considerations: Rich text formats such as TeX and + Troff often contain mechanisms for executing arbitrary + commands or file system operations, and should not be + used automatically unless these security problems have + been addressed. Even plain text may contain control + characters that can be used to exploit the capabilities + of "intelligent" terminals and cause security + violations. User interfaces designed to run on such + terminals should be aware of and try to prevent such + problems. + ________________________________________________________________ + + Content-type: multipart + + Subtypes defined by this document: mixed, alternative, + digest, parallel. + + Important Parameters: boundary + + Encoding notes: No content-transfer-encoding is permitted. + + ________________________________________________________________ + + Content-type: message + + Subtypes defined by this document: rfc822, partial, + external-body + + Important Parameters: id, number, total + + Encoding notes: No content-transfer-encoding is permitted. + + ________________________________________________________________ + + Content-type: application + + Subtypes defined by this document: octet-stream, + postscript, oda + + Important Parameters: profile + + + + + + Borenstein & Freed [Page 71] + + + + + RFC 1341MIME: Multipurpose Internet Mail ExtensionsJune 1992 + + + Encoding notes: base64 generally preferred for octet-stream + or other unreadable subtypes. + + Security considerations: This type is intended for the + transmission of data to be interpreted by locally-installed + programs. If used, for example, to transmit executable + binary programs or programs in general-purpose interpreted + languages, such as LISP programs or shell scripts, severe + security problems could result. In general, authors of + mail-reading agents are cautioned against giving their + systems the power to execute mail-based application data + without carefully considering the security implications. + While it is certainly possible to define safe application + formats and even safe interpreters for unsafe formats, each + interpreter should be evaluated separately for possible + security problems. + ________________________________________________________________ + + Content-type: image + + Subtypes defined by this document: jpeg, gif + + Important Parameters: none + + Encoding notes: base64 generally preferred + + ________________________________________________________________ + + Content-type: audio + + Subtypes defined by this document: basic + + Important Parameters: none + + Encoding notes: base64 generally preferred + + ________________________________________________________________ + + Content-type: video + + Subtypes defined by this document: mpeg + + Important Parameters: none + + Encoding notes: base64 generally preferred + + + + + + + + + + + + + Borenstein & Freed [Page 72] + + + + + RFC 1341MIME: Multipurpose Internet Mail ExtensionsJune 1992 + + + Appendix H -- Canonical Encoding Model + + + + There was some confusion, in earlier drafts of this memo, + regarding the model for when email data was to be converted + to canonical form and encoded, and in particular how this + process would affect the treatment of CRLFs, given that the + representation of newlines varies greatly from system to + system. For this reason, a canonical model for encoding is + presented below. + + The process of composing a MIME message part can be modelled + as being done in a number of steps. Note that these steps + are roughly similar to those steps used in RFC1113: + + Step 1. Creation of local form. + + The body part to be transmitted is created in the system's + native format. The native character set is used, and where + appropriate local end of line conventions are used as well. + The may be a UNIX-style text file, or a Sun raster image, or + a VMS indexed file, or audio data in a system-dependent + format stored only in memory, or anything else that + corresponds to the local model for the representation of + some form of information. + + Step 2. Conversion to canonical form. + + The entire body part, including "out-of-band" information + such as record lengths and possibly file attribute + information, is converted to a universal canonical form. + The specific content type of the body part as well as its + associated attributes dictate the nature of the canonical + form that is used. Conversion to the proper canonical form + may involve character set conversion, transformation of + audio data, compression, or various other operations + specific to the various content types. + + For example, in the case of text/plain data, the text must + be converted to a supported character set and lines must be + delimited with CRLF delimiters in accordance with RFC822. + Note that the restriction on line lengths implied by RFC822 + is eliminated if the next step employs either quoted- + printable or base64 encoding. + + Step 3. Apply transfer encoding. + + A Content-Transfer-Encoding appropriate for this body part + is applied. Note that there is no fixed relationship + between the content type and the transfer encoding. In + particular, it may be appropriate to base the choice of + base64 or quoted-printable on character frequency counts + which are specific to a given instance of body part. + + + + Borenstein & Freed [Page 73] + + + + + RFC 1341MIME: Multipurpose Internet Mail ExtensionsJune 1992 + + + Step 4. Insertion into message. + + The encoded object is inserted into a MIME message with + appropriate body part headers and boundary markers. + + It is vital to note that these steps are only a model; they + are specifically NOT a blueprint for how an actual system + would be built. In particular, the model fails to account + for two common designs: + + 1. In many cases the conversion to a canonical + form prior to encoding will be subsumed into the + encoder itself, which understands local formats + directly. For example, the local newline + convention for text bodyparts might be carried + through to the encoder itself along with knowledge + of what that format is. + + 2. The output of the encoders may have to pass + through one or more additional steps prior to + being transmitted as a message. As such, the + output of the encoder may not be compliant with + the formats specified by RFC822. In particular, + once again it may be appropriate for the + converter's output to be expressed using local + newline conventions rather than using the standard + RFC822 CRLF delimiters. + + Other implementation variations are conceivable as well. + The only important aspect of this discussion is that the + resulting messages are consistent with those produced by the + model described here. + + + + + + + + + + + + + + + + + + + + + + + + + + Borenstein & Freed [Page 74] + + + + + RFC 1341MIME: Multipurpose Internet Mail ExtensionsJune 1992 + + + References + + [US-ASCII] Coded Character Set--7-Bit American Standard Code + for Information Interchange, ANSI X3.4-1986. + + [ATK] Borenstein, Nathaniel S., Multimedia Applications + Development with the Andrew Toolkit, Prentice-Hall, 1990. + + [GIF] Graphics Interchange Format (Version 89a), Compuserve, + Inc., Columbus, Ohio, 1990. + + [ISO-2022] International Standard--Information Processing-- + ISO 7-bit and 8-bit coded character sets--Code extension + techniques, ISO 2022:1986. + + [ISO-8859] Information Processing -- 8-bit Single-Byte Coded + Graphic Character Sets -- Part 1: Latin Alphabet No. 1, ISO + 8859-1:1987. Part 2: Latin alphabet No. 2, ISO 8859-2, + 1987. Part 3: Latin alphabet No. 3, ISO 8859-3, 1988. Part + 4: Latin alphabet No. 4, ISO 8859-4, 1988. Part 5: + Latin/Cyrillic alphabet, ISO 8859-5, 1988. Part 6: + Latin/Arabic alphabet, ISO 8859-6, 1987. Part 7: + Latin/Greek alphabet, ISO 8859-7, 1987. Part 8: + Latin/Hebrew alphabet, ISO 8859-8, 1988. Part 9: Latin + alphabet No. 5, ISO 8859-9, 1990. + + [ISO-646] International Standard--Information Processing-- + ISO 7-bit coded character set for information interchange, + ISO 646:1983. + + [MPEG] Video Coding Draft Standard ISO 11172 CD, ISO + IEC/TJC1/SC2/WG11 (Motion Picture Experts Group), May, 1991. + + [ODA] ISO 8613; Information Processing: Text and Office + System; Office Document Architecture (ODA) and Interchange + Format (ODIF), Part 1-8, 1989. + + [PCM] CCITT, Fascicle III.4 - Recommendation G.711, Geneva, + 1972, "Pulse Code Modulation (PCM) of Voice Frequencies". + + [POSTSCRIPT] Adobe Systems, Inc., PostScript Language + Reference Manual, Addison-Wesley, 1985. + + [X400] Schicker, Pietro, "Message Handling Systems, X.400", + Message Handling Systems and Distributed Applications, E. + Stefferud, O-j. Jacobsen, and P. Schicker, eds., North- + Holland, 1989, pp. 3-41. + + [RFC-783] Sollins, K.R. TFTP Protocol (revision 2). June, + 1981, MIT, RFC-783. + + [RFC-821] Postel, J.B. Simple Mail Transfer Protocol. + August, 1982, USC/Information Sciences Institute, RFC-821. + + + + + Borenstein & Freed [Page 75] + + + + + RFC 1341MIME: Multipurpose Internet Mail ExtensionsJune 1992 + + + [RFC-822] Crocker, D. Standard for the format of ARPA + Internet text messages. August, 1982, UDEL, RFC-822. + + [RFC-934] Rose, M.T.; Stefferud, E.A. Proposed standard + for message encapsulation. January, 1985, Delaware + and NMA, RFC-934. + + [RFC-959] Postel, J.B.; Reynolds, J.K. File Transfer + Protocol. October, 1985, USC/Information Sciences + Institute, RFC-959. + + [RFC-1049] Sirbu, M.A. Content-Type header field for + Internet messages. March, 1988, CMU, RFC-1049. + + [RFC-1113] Linn, J. Privacy enhancement for Internet + electronic mail: Part I - message encipherment and + authentication procedures. August, 1989, IAB Privacy Task + Force, RFC-1113. + + [RFC-1154] Robinson, D.; Ullmann, R. Encoding header field + for Internet messages. April, 1990, Prime Computer, + Inc., RFC-1154. + + [RFC-1342] Moore, Keith, Representation of Non-Ascii Text in + Internet Message Headers. June, 1992, University of + Tennessee, RFC-1342. + + Security Considerations + + Security issues are discussed in Section 7.4.2 and in + Appendix G. Implementors should pay special attention to + the security implications of any mail content-types that can + cause the remote execution of any actions in the recipient's + environment. In such cases, the discussion of the + applicaton/postscript content-type in Section 7.4.2 may + serve as a model for considering other content-types with + remote execution capabilities. + + + + + + + + + + + + + + + + + + + + + Borenstein & Freed [Page 76] + + + + + RFC 1341MIME: Multipurpose Internet Mail ExtensionsJune 1992 + + + Authors' Addresses + + For more information, the authors of this document may be + contacted via Internet mail: + + Nathaniel S. Borenstein + MRE 2D-296, Bellcore + 445 South St. + Morristown, NJ 07962-1910 + + Phone: +1 201 829 4270 + Fax: +1 201 829 7019 + Email: nsb@bellcore.com + + + Ned Freed + Innosoft International, Inc. + 250 West First Street + Suite 240 + Claremont, CA 91711 + + Phone: +1 714 624 7907 + Fax: +1 714 621 5319 + Email: ned@innosoft.com + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Borenstein & Freed [Page 77] + + + + + RFC 1341MIME: Multipurpose Internet Mail ExtensionsJune 1992 + + + + + + THIS PAGE INTENTIONALLY LEFT BLANK. + + Please discard this page and place the following table of + contents after the title page. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Borenstein & Freed [Page i] + + + + + + + + + Table of Contents + + + 1 Introduction....................................... 1 + 2 Notations, Conventions, and Generic BNF Grammar.... 3 + 3 The MIME-Version Header Field...................... 5 + 4 The Content-Type Header Field...................... 6 + 5 The Content-Transfer-Encoding Header Field......... 10 + 5.1 Quoted-Printable Content-Transfer-Encoding......... 14 + 5.2 Base64 Content-Transfer-Encoding................... 17 + 6 Additional Optional Content- Header Fields......... 19 + 6.1 Optional Content-ID Header Field................... 19 + 6.2 Optional Content-Description Header Field.......... 19 + 7 The Predefined Content-Type Values................. 20 + 7.1 The Text Content-Type.............................. 20 + 7.1.1 The charset parameter.............................. 20 + 7.1.2 The Text/plain subtype............................. 23 + 7.1.3 The Text/richtext subtype.......................... 23 + 7.2 The Multipart Content-Type......................... 29 + 7.2.1 Multipart: The common syntax...................... 30 + 7.2.2 The Multipart/mixed (primary) subtype.............. 34 + 7.2.3 The Multipart/alternative subtype.................. 34 + 7.2.4 The Multipart/digest subtype....................... 36 + 7.2.5 The Multipart/parallel subtype..................... 36 + 7.3 The Message Content-Type........................... 37 + 7.3.1 The Message/rfc822 (primary) subtype............... 37 + 7.3.2 The Message/Partial subtype........................ 37 + 7.3.3 The Message/External-Body subtype.................. 40 + 7.4 The Application Content-Type....................... 46 + 7.4.1 The Application/Octet-Stream (primary) subtype..... 46 + 7.4.2 The Application/PostScript subtype................. 47 + 7.4.3 The Application/ODA subtype........................ 50 + 7.5 The Image Content-Type............................. 51 + 7.6 The Audio Content-Type............................. 51 + 7.7 The Video Content-Type............................. 51 + 7.8 Experimental Content-Type Values................... 51 + Summary............................................ 53 + Acknowledgements................................... 54 + Appendix A -- Minimal MIME-Conformance............. 56 + Appendix B -- General Guidelines For Sending Email Data59 + Appendix C -- A Complex Multipart Example.......... 62 + Appendix D -- A Simple Richtext-to-Text Translator in C64 + Appendix E -- Collected Grammar.................... 66 + Appendix F -- IANA Registration Procedures......... 68 + F.1 Registration of New Content-type/subtype Values..68 + F.2 Registration of New Character Set Values...... 69 + F.3 Registration of New Access-type Values for Message/external-body69 + F.4 Registration of New Conversions Values for Application69 + Appendix G -- Summary of the Seven Content-types... 71 + Appendix H -- Canonical Encoding Model............. 73 + References......................................... 75 + Security Considerations............................ 76 + Authors' Addresses................................. 77 + + + + Borenstein & Freed [Page ii] + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Borenstein & Freed [Page iii] + diff --git a/vendor/swiftmailer/swiftmailer/notes/rfc/rfc1521.txt b/vendor/swiftmailer/swiftmailer/notes/rfc/rfc1521.txt new file mode 100755 index 0000000..074ba41 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/notes/rfc/rfc1521.txt @@ -0,0 +1,4539 @@ + + + + + + +Network Working Group N. Borenstein +Request for Comments: 1521 Bellcore +Obsoletes: 1341 N. Freed +Category: Standards Track Innosoft + September 1993 + + + MIME (Multipurpose Internet Mail Extensions) Part One: + Mechanisms for Specifying and Describing + the Format of Internet Message Bodies + +Status of this Memo + + This RFC specifies an Internet standards track protocol for the + Internet community, and requests discussion and suggestions for + improvements. Please refer to the current edition of the "Internet + Official Protocol Standards" for the standardization state and status + of this protocol. Distribution of this memo is unlimited. + +Abstract + + STD 11, RFC 822 defines a message representation protocol which + specifies considerable detail about message headers, but which leaves + the message content, or message body, as flat ASCII text. This + document redefines the format of message bodies to allow multi-part + textual and non-textual message bodies to be represented and + exchanged without loss of information. This is based on earlier work + documented in RFC 934 and STD 11, RFC 1049, but extends and revises + that work. Because RFC 822 said so little about message bodies, this + document is largely orthogonal to (rather than a revision of) RFC + 822. + + In particular, this document is designed to provide facilities to + include multiple objects in a single message, to represent body text + in character sets other than US-ASCII, to represent formatted multi- + font text messages, to represent non-textual material such as images + and audio fragments, and generally to facilitate later extensions + defining new types of Internet mail for use by cooperating mail + agents. + + This document does NOT extend Internet mail header fields to permit + anything other than US-ASCII text data. Such extensions are the + subject of a companion document [RFC-1522]. + + This document is a revision of RFC 1341. Significant differences + from RFC 1341 are summarized in Appendix H. + + + + + +Borenstein & Freed [Page 1] + +RFC 1521 MIME September 1993 + + +Table of Contents + + 1. Introduction....................................... 3 + 2. Notations, Conventions, and Generic BNF Grammar.... 6 + 3. The MIME-Version Header Field...................... 7 + 4. The Content-Type Header Field...................... 9 + 5. The Content-Transfer-Encoding Header Field......... 13 + 5.1. Quoted-Printable Content-Transfer-Encoding......... 18 + 5.2. Base64 Content-Transfer-Encoding................... 21 + 6. Additional Content-Header Fields................... 23 + 6.1. Optional Content-ID Header Field................... 23 + 6.2. Optional Content-Description Header Field.......... 24 + 7. The Predefined Content-Type Values................. 24 + 7.1. The Text Content-Type.............................. 24 + 7.1.1. The charset parameter.............................. 25 + 7.1.2. The Text/plain subtype............................. 28 + 7.2. The Multipart Content-Type......................... 28 + 7.2.1. Multipart: The common syntax...................... 29 + 7.2.2. The Multipart/mixed (primary) subtype.............. 34 + 7.2.3. The Multipart/alternative subtype.................. 34 + 7.2.4. The Multipart/digest subtype....................... 36 + 7.2.5. The Multipart/parallel subtype..................... 37 + 7.2.6. Other Multipart subtypes........................... 37 + 7.3. The Message Content-Type........................... 38 + 7.3.1. The Message/rfc822 (primary) subtype............... 38 + 7.3.2. The Message/Partial subtype........................ 39 + 7.3.3. The Message/External-Body subtype.................. 42 + 7.3.3.1. The "ftp" and "tftp" access-types............... 44 + 7.3.3.2. The "anon-ftp" access-type...................... 45 + 7.3.3.3. The "local-file" and "afs" access-types......... 45 + 7.3.3.4. The "mail-server" access-type................... 45 + 7.3.3.5. Examples and Further Explanations............... 46 + 7.4. The Application Content-Type....................... 49 + 7.4.1. The Application/Octet-Stream (primary) subtype..... 50 + 7.4.2. The Application/PostScript subtype................. 50 + 7.4.3. Other Application subtypes......................... 53 + 7.5. The Image Content-Type............................. 53 + 7.6. The Audio Content-Type............................. 54 + 7.7. The Video Content-Type............................. 54 + 7.8. Experimental Content-Type Values................... 54 + 8. Summary............................................ 56 + 9. Security Considerations............................ 56 + 10. Authors' Addresses................................. 57 + 11. Acknowledgements................................... 58 + Appendix A -- Minimal MIME-Conformance.................... 60 + Appendix B -- General Guidelines For Sending Email Data... 63 + Appendix C -- A Complex Multipart Example................. 66 + Appendix D -- Collected Grammar........................... 68 + + + +Borenstein & Freed [Page 2] + +RFC 1521 MIME September 1993 + + + Appendix E -- IANA Registration Procedures................ 72 + E.1 Registration of New Content-type/subtype Values...... 72 + E.2 Registration of New Access-type Values + for Message/external-body............................ 73 + Appendix F -- Summary of the Seven Content-types.......... 74 + Appendix G -- Canonical Encoding Model.................... 76 + Appendix H -- Changes from RFC 1341....................... 78 + References................................................ 80 + +1. Introduction + + Since its publication in 1982, STD 11, RFC 822 [RFC-822] has defined + the standard format of textual mail messages on the Internet. Its + success has been such that the RFC 822 format has been adopted, + wholly or partially, well beyond the confines of the Internet and the + Internet SMTP transport defined by STD 10, RFC 821 [RFC-821]. As the + format has seen wider use, a number of limitations have proven + increasingly restrictive for the user community. + + RFC 822 was intended to specify a format for text messages. As such, + non-text messages, such as multimedia messages that might include + audio or images, are simply not mentioned. Even in the case of text, + however, RFC 822 is inadequate for the needs of mail users whose + languages require the use of character sets richer than US ASCII + [US-ASCII]. Since RFC 822 does not specify mechanisms for mail + containing audio, video, Asian language text, or even text in most + European languages, additional specifications are needed. + + One of the notable limitations of RFC 821/822 based mail systems is + the fact that they limit the contents of electronic mail messages to + relatively short lines of seven-bit ASCII. This forces users to + convert any non-textual data that they may wish to send into seven- + bit bytes representable as printable ASCII characters before invoking + a local mail UA (User Agent, a program with which human users send + and receive mail). Examples of such encodings currently used in the + Internet include pure hexadecimal, uuencode, the 3-in-4 base 64 + scheme specified in RFC 1421, the Andrew Toolkit Representation + [ATK], and many others. + + The limitations of RFC 822 mail become even more apparent as gateways + are designed to allow for the exchange of mail messages between RFC + 822 hosts and X.400 hosts. X.400 [X400] specifies mechanisms for the + inclusion of non-textual body parts within electronic mail messages. + The current standards for the mapping of X.400 messages to RFC 822 + messages specify either that X.400 non-textual body parts must be + converted to (not encoded in) an ASCII format, or that they must be + discarded, notifying the RFC 822 user that discarding has occurred. + This is clearly undesirable, as information that a user may wish to + + + +Borenstein & Freed [Page 3] + +RFC 1521 MIME September 1993 + + + receive is lost. Even though a user's UA may not have the capability + of dealing with the non-textual body part, the user might have some + mechanism external to the UA that can extract useful information from + the body part. Moreover, it does not allow for the fact that the + message may eventually be gatewayed back into an X.400 message + handling system (i.e., the X.400 message is "tunneled" through + Internet mail), where the non-textual information would definitely + become useful again. + + This document describes several mechanisms that combine to solve most + of these problems without introducing any serious incompatibilities + with the existing world of RFC 822 mail. In particular, it + describes: + + 1. A MIME-Version header field, which uses a version number to + declare a message to be conformant with this specification and + allows mail processing agents to distinguish between such + messages and those generated by older or non-conformant software, + which is presumed to lack such a field. + + 2. A Content-Type header field, generalized from RFC 1049 [RFC-1049], + which can be used to specify the type and subtype of data in the + body of a message and to fully specify the native representation + (encoding) of such data. + + 2.a. A "text" Content-Type value, which can be used to represent + textual information in a number of character sets and + formatted text description languages in a standardized + manner. + + 2.b. A "multipart" Content-Type value, which can be used to + combine several body parts, possibly of differing types of + data, into a single message. + + 2.c. An "application" Content-Type value, which can be used to + transmit application data or binary data, and hence, among + other uses, to implement an electronic mail file transfer + service. + + 2.d. A "message" Content-Type value, for encapsulating another + mail message. + + 2.e An "image" Content-Type value, for transmitting still image + (picture) data. + + 2.f. An "audio" Content-Type value, for transmitting audio or + voice data. + + + + +Borenstein & Freed [Page 4] + +RFC 1521 MIME September 1993 + + + 2.g. A "video" Content-Type value, for transmitting video or + moving image data, possibly with audio as part of the + composite video data format. + + 3. A Content-Transfer-Encoding header field, which can be used to + specify an auxiliary encoding that was applied to the data in + order to allow it to pass through mail transport mechanisms which + may have data or character set limitations. + + 4. Two additional header fields that can be used to further describe + the data in a message body, the Content-ID and Content- + Description header fields. + + MIME has been carefully designed as an extensible mechanism, and it + is expected that the set of content-type/subtype pairs and their + associated parameters will grow significantly with time. Several + other MIME fields, notably including character set names, are likely + to have new values defined over time. In order to ensure that the + set of such values is developed in an orderly, well-specified, and + public manner, MIME defines a registration process which uses the + Internet Assigned Numbers Authority (IANA) as a central registry for + such values. Appendix E provides details about how IANA registration + is accomplished. + + Finally, to specify and promote interoperability, Appendix A of this + document provides a basic applicability statement for a subset of the + above mechanisms that defines a minimal level of "conformance" with + this document. + + HISTORICAL NOTE: Several of the mechanisms described in this + document may seem somewhat strange or even baroque at first + reading. It is important to note that compatibility with existing + standards AND robustness across existing practice were two of the + highest priorities of the working group that developed this + document. In particular, compatibility was always favored over + elegance. + + MIME was first defined and published as RFCs 1341 and 1342 [RFC-1341] + [RFC-1342]. This document is a relatively minor updating of RFC + 1341, and is intended to supersede it. The differences between this + document and RFC 1341 are summarized in Appendix H. Please refer to + the current edition of the "IAB Official Protocol Standards" for the + standardization state and status of this protocol. Several other RFC + documents will be of interest to the MIME implementor, in particular + [RFC 1343], [RFC-1344], and [RFC-1345]. + + + + + + +Borenstein & Freed [Page 5] + +RFC 1521 MIME September 1993 + + +2. Notations, Conventions, and Generic BNF Grammar + + This document is being published in two versions, one as plain ASCII + text and one as PostScript (PostScript is a trademark of Adobe + Systems Incorporated.). While the text version is the official + specification, some will find the PostScript version easier to read. + The textual contents are identical. An Andrew-format copy of this + document is also available from the first author (Borenstein). + + Although the mechanisms specified in this document are all described + in prose, most are also described formally in the modified BNF + notation of RFC 822. Implementors will need to be familiar with this + notation in order to understand this specification, and are referred + to RFC 822 for a complete explanation of the modified BNF notation. + + Some of the modified BNF in this document makes reference to + syntactic entities that are defined in RFC 822 and not in this + document. A complete formal grammar, then, is obtained by combining + the collected grammar appendix of this document with that of RFC 822 + plus the modifications to RFC 822 defined in RFC 1123, which + specifically changes the syntax for `return', `date' and `mailbox'. + + The term CRLF, in this document, refers to the sequence of the two + ASCII characters CR (13) and LF (10) which, taken together, in this + order, denote a line break in RFC 822 mail. + + The term "character set" is used in this document to refer to a + method used with one or more tables to convert encoded text to a + series of octets. This definition is intended to allow various kinds + of text encodings, from simple single-table mappings such as ASCII to + complex table switching methods such as those that use ISO 2022's + techniques. However, a MIME character set name must fully specify + the mapping to be performed. + + The term "message", when not further qualified, means either the + (complete or "top-level") message being transferred on a network, or + a message encapsulated in a body of type "message". + + The term "body part", in this document, means one of the parts of the + body of a multipart entity. A body part has a header and a body, so + it makes sense to speak about the body of a body part. + + The term "entity", in this document, means either a message or a body + part. All kinds of entities share the property that they have a + header and a body. + + The term "body", when not further qualified, means the body of an + entity, that is the body of either a message or of a body part. + + + +Borenstein & Freed [Page 6] + +RFC 1521 MIME September 1993 + + + NOTE: The previous four definitions are clearly circular. This is + unavoidable, since the overall structure of a MIME message is + indeed recursive. + + In this document, all numeric and octet values are given in decimal + notation. + + It must be noted that Content-Type values, subtypes, and parameter + names as defined in this document are case-insensitive. However, + parameter values are case-sensitive unless otherwise specified for + the specific parameter. + + FORMATTING NOTE: This document has been carefully formatted for + ease of reading. The PostScript version of this document, in + particular, places notes like this one, which may be skipped by + the reader, in a smaller, italicized, font, and indents it as + well. In the text version, only the indentation is preserved, so + if you are reading the text version of this you might consider + using the PostScript version instead. However, all such notes will + be indented and preceded by "NOTE:" or some similar introduction, + even in the text version. + + The primary purpose of these non-essential notes is to convey + information about the rationale of this document, or to place this + document in the proper historical or evolutionary context. Such + information may be skipped by those who are focused entirely on + building a conformant implementation, but may be of use to those + who wish to understand why this document is written as it is. + + For ease of recognition, all BNF definitions have been placed in a + fixed-width font in the PostScript version of this document. + +3. The MIME-Version Header Field + + Since RFC 822 was published in 1982, there has really been only one + format standard for Internet messages, and there has been little + perceived need to declare the format standard in use. This document + is an independent document that complements RFC 822. Although the + extensions in this document have been defined in such a way as to be + compatible with RFC 822, there are still circumstances in which it + might be desirable for a mail-processing agent to know whether a + message was composed with the new standard in mind. + + Therefore, this document defines a new header field, "MIME-Version", + which is to be used to declare the version of the Internet message + body format standard in use. + + Messages composed in accordance with this document MUST include such + + + +Borenstein & Freed [Page 7] + +RFC 1521 MIME September 1993 + + + a header field, with the following verbatim text: + + MIME-Version: 1.0 + + The presence of this header field is an assertion that the message + has been composed in compliance with this document. + + Since it is possible that a future document might extend the message + format standard again, a formal BNF is given for the content of the + MIME-Version field: + + version := "MIME-Version" ":" 1*DIGIT "." 1*DIGIT + + Thus, future format specifiers, which might replace or extend "1.0", + are constrained to be two integer fields, separated by a period. If + a message is received with a MIME-version value other than "1.0", it + cannot be assumed to conform with this specification. + + Note that the MIME-Version header field is required at the top level + of a message. It is not required for each body part of a multipart + entity. It is required for the embedded headers of a body of type + "message" if and only if the embedded message is itself claimed to be + MIME-conformant. + + It is not possible to fully specify how a mail reader that conforms + with MIME as defined in this document should treat a message that + might arrive in the future with some value of MIME-Version other than + "1.0". However, conformant software is encouraged to check the + version number and at least warn the user if an unrecognized MIME- + version is encountered. + + It is also worth noting that version control for specific content- + types is not accomplished using the MIME-Version mechanism. In + particular, some formats (such as application/postscript) have + version numbering conventions that are internal to the document + format. Where such conventions exist, MIME does nothing to supersede + them. Where no such conventions exist, a MIME type might use a + "version" parameter in the content-type field if necessary. + + NOTE TO IMPLEMENTORS: All header fields defined in this document, + including MIME-Version, Content-type, etc., are subject to the + general syntactic rules for header fields specified in RFC 822. In + particular, all can include comments, which means that the following + two MIME-Version fields are equivalent: + + MIME-Version: 1.0 + MIME-Version: 1.0 (Generated by GBD-killer 3.7) + + + + +Borenstein & Freed [Page 8] + +RFC 1521 MIME September 1993 + + +4. The Content-Type Header Field + + The purpose of the Content-Type field is to describe the data + contained in the body fully enough that the receiving user agent can + pick an appropriate agent or mechanism to present the data to the + user, or otherwise deal with the data in an appropriate manner. + + HISTORICAL NOTE: The Content-Type header field was first defined in + RFC 1049. RFC 1049 Content-types used a simpler and less powerful + syntax, but one that is largely compatible with the mechanism given + here. + + The Content-Type header field is used to specify the nature of the + data in the body of an entity, by giving type and subtype + identifiers, and by providing auxiliary information that may be + required for certain types. After the type and subtype names, the + remainder of the header field is simply a set of parameters, + specified in an attribute/value notation. The set of meaningful + parameters differs for the different types. In particular, there are + NO globally-meaningful parameters that apply to all content-types. + Global mechanisms are best addressed, in the MIME model, by the + definition of additional Content-* header fields. The ordering of + parameters is not significant. Among the defined parameters is a + "charset" parameter by which the character set used in the body may + be declared. Comments are allowed in accordance with RFC 822 rules + for structured header fields. + + In general, the top-level Content-Type is used to declare the general + type of data, while the subtype specifies a specific format for that + type of data. Thus, a Content-Type of "image/xyz" is enough to tell + a user agent that the data is an image, even if the user agent has no + knowledge of the specific image format "xyz". Such information can + be used, for example, to decide whether or not to show a user the raw + data from an unrecognized subtype -- such an action might be + reasonable for unrecognized subtypes of text, but not for + unrecognized subtypes of image or audio. For this reason, registered + subtypes of audio, image, text, and video, should not contain + embedded information that is really of a different type. Such + compound types should be represented using the "multipart" or + "application" types. + + Parameters are modifiers of the content-subtype, and do not + fundamentally affect the requirements of the host system. Although + most parameters make sense only with certain content-types, others + are "global" in the sense that they might apply to any subtype. For + example, the "boundary" parameter makes sense only for the + "multipart" content-type, but the "charset" parameter might make + sense with several content-types. + + + +Borenstein & Freed [Page 9] + +RFC 1521 MIME September 1993 + + + An initial set of seven Content-Types is defined by this document. + This set of top-level names is intended to be substantially complete. + It is expected that additions to the larger set of supported types + can generally be accomplished by the creation of new subtypes of + these initial types. In the future, more top-level types may be + defined only by an extension to this standard. If another primary + type is to be used for any reason, it must be given a name starting + with "X-" to indicate its non-standard status and to avoid a + potential conflict with a future official name. + + In the Augmented BNF notation of RFC 822, a Content-Type header field + value is defined as follows: + + content := "Content-Type" ":" type "/" subtype *(";" + parameter) + ; case-insensitive matching of type and subtype + + type := "application" / "audio" + / "image" / "message" + / "multipart" / "text" + / "video" / extension-token + ; All values case-insensitive + + extension-token := x-token / iana-token + + iana-token := + + x-token := + + subtype := token ; case-insensitive + + parameter := attribute "=" value + + attribute := token ; case-insensitive + + value := token / quoted-string + + token := 1* + + tspecials := "(" / ")" / "<" / ">" / "@" + / "," / ";" / ":" / "\" / <"> + / "/" / "[" / "]" / "?" / "=" + ; Must be in quoted-string, + ; to use within parameter values + + + +Borenstein & Freed [Page 10] + +RFC 1521 MIME September 1993 + + + Note that the definition of "tspecials" is the same as the RFC 822 + definition of "specials" with the addition of the three characters + "/", "?", and "=", and the removal of ".". + + Note also that a subtype specification is MANDATORY. There are no + default subtypes. + + The type, subtype, and parameter names are not case sensitive. For + example, TEXT, Text, and TeXt are all equivalent. Parameter values + are normally case sensitive, but certain parameters are interpreted + to be case-insensitive, depending on the intended use. (For example, + multipart boundaries are case-sensitive, but the "access-type" for + message/External-body is not case-sensitive.) + + Beyond this syntax, the only constraint on the definition of subtype + names is the desire that their uses must not conflict. That is, it + would be undesirable to have two different communities using + "Content-Type: application/foobar" to mean two different things. The + process of defining new content-subtypes, then, is not intended to be + a mechanism for imposing restrictions, but simply a mechanism for + publicizing the usages. There are, therefore, two acceptable + mechanisms for defining new Content-Type subtypes: + + 1. Private values (starting with "X-") may be + defined bilaterally between two cooperating + agents without outside registration or + standardization. + + 2. New standard values must be documented, + registered with, and approved by IANA, as + described in Appendix E. Where intended for + public use, the formats they refer to must + also be defined by a published specification, + and possibly offered for standardization. + + The seven standard initial predefined Content-Types are detailed in + the bulk of this document. They are: + + text -- textual information. The primary subtype, + "plain", indicates plain (unformatted) text. No + special software is required to get the full + meaning of the text, aside from support for the + indicated character set. Subtypes are to be used + for enriched text in forms where application + software may enhance the appearance of the text, + but such software must not be required in order to + get the general idea of the content. Possible + subtypes thus include any readable word processor + + + +Borenstein & Freed [Page 11] + +RFC 1521 MIME September 1993 + + + format. A very simple and portable subtype, + richtext, was defined in RFC 1341, with a future + revision expected. + + multipart -- data consisting of multiple parts of + independent data types. Four initial subtypes + are defined, including the primary "mixed" + subtype, "alternative" for representing the same + data in multiple formats, "parallel" for parts + intended to be viewed simultaneously, and "digest" + for multipart entities in which each part is of + type "message". + + message -- an encapsulated message. A body of + Content-Type "message" is itself all or part of a + fully formatted RFC 822 conformant message which + may contain its own different Content-Type header + field. The primary subtype is "rfc822". The + "partial" subtype is defined for partial messages, + to permit the fragmented transmission of bodies + that are thought to be too large to be passed + through mail transport facilities. Another + subtype, "External-body", is defined for + specifying large bodies by reference to an + external data source. + + image -- image data. Image requires a display device + (such as a graphical display, a printer, or a FAX + machine) to view the information. Initial + subtypes are defined for two widely-used image + formats, jpeg and gif. + + audio -- audio data, with initial subtype "basic". + Audio requires an audio output device (such as a + speaker or a telephone) to "display" the contents. + + video -- video data. Video requires the capability to + display moving images, typically including + specialized hardware and software. The initial + subtype is "mpeg". + + application -- some other kind of data, typically + either uninterpreted binary data or information to + be processed by a mail-based application. The + primary subtype, "octet-stream", is to be used in + the case of uninterpreted binary data, in which + case the simplest recommended action is to offer + to write the information into a file for the user. + + + +Borenstein & Freed [Page 12] + +RFC 1521 MIME September 1993 + + + An additional subtype, "PostScript", is defined + for transporting PostScript documents in bodies. + Other expected uses for "application" include + spreadsheets, data for mail-based scheduling + systems, and languages for "active" + (computational) email. (Note that active email + and other application data may entail several + security considerations, which are discussed later + in this memo, particularly in the context of + application/PostScript.) + + Default RFC 822 messages are typed by this protocol as plain text in + the US-ASCII character set, which can be explicitly specified as + "Content-type: text/plain; charset=us-ascii". If no Content-Type is + specified, this default is assumed. In the presence of a MIME- + Version header field, a receiving User Agent can also assume that + plain US-ASCII text was the sender's intent. In the absence of a + MIME-Version specification, plain US-ASCII text must still be + assumed, but the sender's intent might have been otherwise. + + RATIONALE: In the absence of any Content-Type header field or + MIME-Version header field, it is impossible to be certain that a + message is actually text in the US-ASCII character set, since it + might well be a message that, using the conventions that predate + this document, includes text in another character set or non- + textual data in a manner that cannot be automatically recognized + (e.g., a uuencoded compressed UNIX tar file). Although there is + no fully acceptable alternative to treating such untyped messages + as "text/plain; charset=us-ascii", implementors should remain + aware that if a message lacks both the MIME-Version and the + Content-Type header fields, it may in practice contain almost + anything. + + It should be noted that the list of Content-Type values given here + may be augmented in time, via the mechanisms described above, and + that the set of subtypes is expected to grow substantially. + + When a mail reader encounters mail with an unknown Content-type + value, it should generally treat it as equivalent to + "application/octet-stream", as described later in this document. + +5. The Content-Transfer-Encoding Header Field + + Many Content-Types which could usefully be transported via email are + represented, in their "natural" format, as 8-bit character or binary + data. Such data cannot be transmitted over some transport protocols. + For example, RFC 821 restricts mail messages to 7-bit US-ASCII data + with lines no longer than 1000 characters. + + + +Borenstein & Freed [Page 13] + +RFC 1521 MIME September 1993 + + + It is necessary, therefore, to define a standard mechanism for re- + encoding such data into a 7-bit short-line format. This document + specifies that such encodings will be indicated by a new "Content- + Transfer-Encoding" header field. The Content-Transfer-Encoding field + is used to indicate the type of transformation that has been used in + order to represent the body in an acceptable manner for transport. + + Unlike Content-Types, a proliferation of Content-Transfer-Encoding + values is undesirable and unnecessary. However, establishing only a + single Content-Transfer-Encoding mechanism does not seem possible. + There is a tradeoff between the desire for a compact and efficient + encoding of largely-binary data and the desire for a readable + encoding of data that is mostly, but not entirely, 7-bit data. For + this reason, at least two encoding mechanisms are necessary: a + "readable" encoding and a "dense" encoding. + + The Content-Transfer-Encoding field is designed to specify an + invertible mapping between the "native" representation of a type of + data and a representation that can be readily exchanged using 7 bit + mail transport protocols, such as those defined by RFC 821 (SMTP). + This field has not been defined by any previous standard. The field's + value is a single token specifying the type of encoding, as + enumerated below. Formally: + + encoding := "Content-Transfer-Encoding" ":" mechanism + + mechanism := "7bit" ; case-insensitive + / "quoted-printable" + / "base64" + / "8bit" + / "binary" + / x-token + + These values are not case sensitive. That is, Base64 and BASE64 and + bAsE64 are all equivalent. An encoding type of 7BIT requires that + the body is already in a seven-bit mail-ready representation. This + is the default value -- that is, "Content-Transfer-Encoding: 7BIT" is + assumed if the Content-Transfer-Encoding header field is not present. + + The values "8bit", "7bit", and "binary" all mean that NO encoding has + been performed. However, they are potentially useful as indications + of the kind of data contained in the object, and therefore of the + kind of encoding that might need to be performed for transmission in + a given transport system. In particular: + + "7bit" means that the data is all represented as short + lines of US-ASCII data. + + + + +Borenstein & Freed [Page 14] + +RFC 1521 MIME September 1993 + + + "8bit" means that the lines are short, but there may be + non-ASCII characters (octets with the high-order + bit set). + + "Binary" means that not only may non-ASCII characters + be present, but also that the lines are not + necessarily short enough for SMTP transport. + + The difference between "8bit" (or any other conceivable bit-width + token) and the "binary" token is that "binary" does not require + adherence to any limits on line length or to the SMTP CRLF semantics, + while the bit-width tokens do require such adherence. If the body + contains data in any bit-width other than 7-bit, the appropriate + bit-width Content-Transfer-Encoding token must be used (e.g., "8bit" + for unencoded 8 bit wide data). If the body contains binary data, + the "binary" Content-Transfer-Encoding token must be used. + + NOTE: The distinction between the Content-Transfer-Encoding values + of "binary", "8bit", etc. may seem unimportant, in that all of + them really mean "none" -- that is, there has been no encoding of + the data for transport. However, clear labeling will be of + enormous value to gateways between future mail transport systems + with differing capabilities in transporting data that do not meet + the restrictions of RFC 821 transport. + + Mail transport for unencoded 8-bit data is defined in RFC-1426 + [RFC-1426]. As of the publication of this document, there are no + standardized Internet mail transports for which it is legitimate + to include unencoded binary data in mail bodies. Thus there are + no circumstances in which the "binary" Content-Transfer-Encoding + is actually legal on the Internet. However, in the event that + binary mail transport becomes a reality in Internet mail, or when + this document is used in conjunction with any other binary-capable + transport mechanism, binary bodies should be labeled as such using + this mechanism. + + NOTE: The five values defined for the Content-Transfer-Encoding + field imply nothing about the Content-Type other than the + algorithm by which it was encoded or the transport system + requirements if unencoded. + + Implementors may, if necessary, define new Content-Transfer-Encoding + values, but must use an x-token, which is a name prefixed by "X-" to + indicate its non-standard status, e.g., "Content-Transfer-Encoding: + x-my-new-encoding". However, unlike Content-Types and subtypes, the + creation of new Content-Transfer-Encoding values is explicitly and + strongly discouraged, as it seems likely to hinder interoperability + with little potential benefit. Their use is allowed only as the + + + +Borenstein & Freed [Page 15] + +RFC 1521 MIME September 1993 + + + result of an agreement between cooperating user agents. + + If a Content-Transfer-Encoding header field appears as part of a + message header, it applies to the entire body of that message. If a + Content-Transfer-Encoding header field appears as part of a body + part's headers, it applies only to the body of that body part. If an + entity is of type "multipart" or "message", the Content-Transfer- + Encoding is not permitted to have any value other than a bit width + (e.g., "7bit", "8bit", etc.) or "binary". + + It should be noted that email is character-oriented, so that the + mechanisms described here are mechanisms for encoding arbitrary octet + streams, not bit streams. If a bit stream is to be encoded via one + of these mechanisms, it must first be converted to an 8-bit byte + stream using the network standard bit order ("big-endian"), in which + the earlier bits in a stream become the higher-order bits in a byte. + A bit stream not ending at an 8-bit boundary must be padded with + zeroes. This document provides a mechanism for noting the addition + of such padding in the case of the application Content-Type, which + has a "padding" parameter. + + The encoding mechanisms defined here explicitly encode all data in + ASCII. Thus, for example, suppose an entity has header fields such + as: + + Content-Type: text/plain; charset=ISO-8859-1 + Content-transfer-encoding: base64 + + This must be interpreted to mean that the body is a base64 ASCII + encoding of data that was originally in ISO-8859-1, and will be in + that character set again after decoding. + + The following sections will define the two standard encoding + mechanisms. The definition of new content-transfer-encodings is + explicitly discouraged and should only occur when absolutely + necessary. All content-transfer-encoding namespace except that + beginning with "X-" is explicitly reserved to the IANA for future + use. Private agreements about content-transfer-encodings are also + explicitly discouraged. + + Certain Content-Transfer-Encoding values may only be used on certain + Content-Types. In particular, it is expressly forbidden to use any + encodings other than "7bit", "8bit", or "binary" with any Content- + Type that recursively includes other Content-Type fields, notably the + "multipart" and "message" Content-Types. All encodings that are + desired for bodies of type multipart or message must be done at the + innermost level, by encoding the actual body that needs to be + encoded. + + + +Borenstein & Freed [Page 16] + +RFC 1521 MIME September 1993 + + + NOTE ON ENCODING RESTRICTIONS: Though the prohibition against + using content-transfer-encodings on data of type multipart or + message may seem overly restrictive, it is necessary to prevent + nested encodings, in which data are passed through an encoding + algorithm multiple times, and must be decoded multiple times in + order to be properly viewed. Nested encodings add considerable + complexity to user agents: aside from the obvious efficiency + problems with such multiple encodings, they can obscure the basic + structure of a message. In particular, they can imply that + several decoding operations are necessary simply to find out what + types of objects a message contains. Banning nested encodings may + complicate the job of certain mail gateways, but this seems less + of a problem than the effect of nested encodings on user agents. + + NOTE ON THE RELATIONSHIP BETWEEN CONTENT-TYPE AND CONTENT- + TRANSFER-ENCODING: It may seem that the Content-Transfer-Encoding + could be inferred from the characteristics of the Content-Type + that is to be encoded, or, at the very least, that certain + Content-Transfer-Encodings could be mandated for use with specific + Content-Types. There are several reasons why this is not the case. + First, given the varying types of transports used for mail, some + encodings may be appropriate for some Content-Type/transport + combinations and not for others. (For example, in an 8-bit + transport, no encoding would be required for text in certain + character sets, while such encodings are clearly required for 7- + bit SMTP.) Second, certain Content-Types may require different + types of transfer encoding under different circumstances. For + example, many PostScript bodies might consist entirely of short + lines of 7-bit data and hence require little or no encoding. + Other PostScript bodies (especially those using Level 2 + PostScript's binary encoding mechanism) may only be reasonably + represented using a binary transport encoding. Finally, since + Content-Type is intended to be an open-ended specification + mechanism, strict specification of an association between + Content-Types and encodings effectively couples the specification + of an application protocol with a specific lower-level transport. + This is not desirable since the developers of a Content-Type + should not have to be aware of all the transports in use and what + their limitations are. + + NOTE ON TRANSLATING ENCODINGS: The quoted-printable and base64 + encodings are designed so that conversion between them is + possible. The only issue that arises in such a conversion is the + handling of line breaks. When converting from quoted-printable to + base64 a line break must be converted into a CRLF sequence. + Similarly, a CRLF sequence in base64 data must be converted to a + quoted-printable line break, but ONLY when converting text data. + + + + +Borenstein & Freed [Page 17] + +RFC 1521 MIME September 1993 + + + NOTE ON CANONICAL ENCODING MODEL: There was some confusion, in + earlier drafts of this memo, regarding the model for when email + data was to be converted to canonical form and encoded, and in + particular how this process would affect the treatment of CRLFs, + given that the representation of newlines varies greatly from + system to system, and the relationship between content-transfer- + encodings and character sets. For this reason, a canonical model + for encoding is presented as Appendix G. + +5.1. Quoted-Printable Content-Transfer-Encoding + + The Quoted-Printable encoding is intended to represent data that + largely consists of octets that correspond to printable characters in + the ASCII character set. It encodes the data in such a way that the + resulting octets are unlikely to be modified by mail transport. If + the data being encoded are mostly ASCII text, the encoded form of the + data remains largely recognizable by humans. A body which is + entirely ASCII may also be encoded in Quoted-Printable to ensure the + integrity of the data should the message pass through a character- + translating, and/or line-wrapping gateway. + + In this encoding, octets are to be represented as determined by the + following rules: + + Rule #1: (General 8-bit representation) Any octet, except those + indicating a line break according to the newline convention of the + canonical (standard) form of the data being encoded, may be + represented by an "=" followed by a two digit hexadecimal + representation of the octet's value. The digits of the + hexadecimal alphabet, for this purpose, are "0123456789ABCDEF". + Uppercase letters must be used when sending hexadecimal data, + though a robust implementation may choose to recognize lowercase + letters on receipt. Thus, for example, the value 12 (ASCII form + feed) can be represented by "=0C", and the value 61 (ASCII EQUAL + SIGN) can be represented by "=3D". Except when the following + rules allow an alternative encoding, this rule is mandatory. + + Rule #2: (Literal representation) Octets with decimal values of 33 + through 60 inclusive, and 62 through 126, inclusive, MAY be + represented as the ASCII characters which correspond to those + octets (EXCLAMATION POINT through LESS THAN, and GREATER THAN + through TILDE, respectively). + + Rule #3: (White Space): Octets with values of 9 and 32 MAY be + represented as ASCII TAB (HT) and SPACE characters, respectively, + but MUST NOT be so represented at the end of an encoded line. Any + TAB (HT) or SPACE characters on an encoded line MUST thus be + followed on that line by a printable character. In particular, an + + + +Borenstein & Freed [Page 18] + +RFC 1521 MIME September 1993 + + + "=" at the end of an encoded line, indicating a soft line break + (see rule #5) may follow one or more TAB (HT) or SPACE characters. + It follows that an octet with value 9 or 32 appearing at the end + of an encoded line must be represented according to Rule #1. This + rule is necessary because some MTAs (Message Transport Agents, + programs which transport messages from one user to another, or + perform a part of such transfers) are known to pad lines of text + with SPACEs, and others are known to remove "white space" + characters from the end of a line. Therefore, when decoding a + Quoted-Printable body, any trailing white space on a line must be + deleted, as it will necessarily have been added by intermediate + transport agents. + + Rule #4 (Line Breaks): A line break in a text body, independent of + what its representation is following the canonical representation + of the data being encoded, must be represented by a (RFC 822) line + break, which is a CRLF sequence, in the Quoted-Printable encoding. + Since the canonical representation of types other than text do not + generally include the representation of line breaks, no hard line + breaks (i.e. line breaks that are intended to be meaningful and + to be displayed to the user) should occur in the quoted-printable + encoding of such types. Of course, occurrences of "=0D", "=0A", + "0A=0D" and "=0D=0A" will eventually be encountered. In general, + however, base64 is preferred over quoted-printable for binary + data. + + Note that many implementations may elect to encode the local + representation of various content types directly, as described in + Appendix G. In particular, this may apply to plain text material + on systems that use newline conventions other than CRLF + delimiters. Such an implementation is permissible, but the + generation of line breaks must be generalized to account for the + case where alternate representations of newline sequences are + used. + + Rule #5 (Soft Line Breaks): The Quoted-Printable encoding REQUIRES + that encoded lines be no more than 76 characters long. If longer + lines are to be encoded with the Quoted-Printable encoding, 'soft' + line breaks must be used. An equal sign as the last character on a + encoded line indicates such a non-significant ('soft') line break + in the encoded text. Thus if the "raw" form of the line is a + single unencoded line that says: + + Now's the time for all folk to come to the aid of + their country. + + This can be represented, in the Quoted-Printable encoding, as + + + + +Borenstein & Freed [Page 19] + +RFC 1521 MIME September 1993 + + + Now's the time = + for all folk to come= + to the aid of their country. + + This provides a mechanism with which long lines are encoded in + such a way as to be restored by the user agent. The 76 character + limit does not count the trailing CRLF, but counts all other + characters, including any equal signs. + + Since the hyphen character ("-") is represented as itself in the + Quoted-Printable encoding, care must be taken, when encapsulating a + quoted-printable encoded body in a multipart entity, to ensure that + the encapsulation boundary does not appear anywhere in the encoded + body. (A good strategy is to choose a boundary that includes a + character sequence such as "=_" which can never appear in a quoted- + printable body. See the definition of multipart messages later in + this document.) + + NOTE: The quoted-printable encoding represents something of a + compromise between readability and reliability in transport. + Bodies encoded with the quoted-printable encoding will work + reliably over most mail gateways, but may not work perfectly over + a few gateways, notably those involving translation into EBCDIC. + (In theory, an EBCDIC gateway could decode a quoted-printable body + and re-encode it using base64, but such gateways do not yet + exist.) A higher level of confidence is offered by the base64 + Content-Transfer-Encoding. A way to get reasonably reliable + transport through EBCDIC gateways is to also quote the ASCII + characters + + !"#$@[\]^`{|}~ + + according to rule #1. See Appendix B for more information. + + Because quoted-printable data is generally assumed to be line- + oriented, it is to be expected that the representation of the breaks + between the lines of quoted printable data may be altered in + transport, in the same manner that plain text mail has always been + altered in Internet mail when passing between systems with differing + newline conventions. If such alterations are likely to constitute a + corruption of the data, it is probably more sensible to use the + base64 encoding rather than the quoted-printable encoding. + + WARNING TO IMPLEMENTORS: If binary data are encoded in quoted- + printable, care must be taken to encode CR and LF characters as "=0D" + and "=0A", respectively. In particular, a CRLF sequence in binary + data should be encoded as "=0D=0A". Otherwise, if CRLF were + represented as a hard line break, it might be incorrectly decoded on + + + +Borenstein & Freed [Page 20] + +RFC 1521 MIME September 1993 + + + platforms with different line break conventions. + + For formalists, the syntax of quoted-printable data is described by + the following grammar: + + quoted-printable := ([*(ptext / SPACE / TAB) ptext] ["="] CRLF) + ; Maximum line length of 76 characters excluding CRLF + + ptext := octet / 127, =, SPACE, or TAB, + ; and is recommended for any characters not listed in + ; Appendix B as "mail-safe". + +5.2. Base64 Content-Transfer-Encoding + + The Base64 Content-Transfer-Encoding is designed to represent + arbitrary sequences of octets in a form that need not be humanly + readable. The encoding and decoding algorithms are simple, but the + encoded data are consistently only about 33 percent larger than the + unencoded data. This encoding is virtually identical to the one used + in Privacy Enhanced Mail (PEM) applications, as defined in RFC 1421. + The base64 encoding is adapted from RFC 1421, with one change: base64 + eliminates the "*" mechanism for embedded clear text. + + A 65-character subset of US-ASCII is used, enabling 6 bits to be + represented per printable character. (The extra 65th character, "=", + is used to signify a special processing function.) + + NOTE: This subset has the important property that it is + represented identically in all versions of ISO 646, including US + ASCII, and all characters in the subset are also represented + identically in all versions of EBCDIC. Other popular encodings, + such as the encoding used by the uuencode utility and the base85 + encoding specified as part of Level 2 PostScript, do not share + these properties, and thus do not fulfill the portability + requirements a binary transport encoding for mail must meet. + + The encoding process represents 24-bit groups of input bits as output + strings of 4 encoded characters. Proceeding from left to right, a + 24-bit input group is formed by concatenating 3 8-bit input groups. + These 24 bits are then treated as 4 concatenated 6-bit groups, each + of which is translated into a single digit in the base64 alphabet. + When encoding a bit stream via the base64 encoding, the bit stream + must be presumed to be ordered with the most-significant-bit first. + + + +Borenstein & Freed [Page 21] + +RFC 1521 MIME September 1993 + + + That is, the first bit in the stream will be the high-order bit in + the first byte, and the eighth bit will be the low-order bit in the + first byte, and so on. + + Each 6-bit group is used as an index into an array of 64 printable + characters. The character referenced by the index is placed in the + output string. These characters, identified in Table 1, below, are + selected so as to be universally representable, and the set excludes + characters with particular significance to SMTP (e.g., ".", CR, LF) + and to the encapsulation boundaries defined in this document (e.g., + "-"). + + Table 1: The Base64 Alphabet + + Value Encoding Value Encoding Value Encoding Value Encoding + 0 A 17 R 34 i 51 z + 1 B 18 S 35 j 52 0 + 2 C 19 T 36 k 53 1 + 3 D 20 U 37 l 54 2 + 4 E 21 V 38 m 55 3 + 5 F 22 W 39 n 56 4 + 6 G 23 X 40 o 57 5 + 7 H 24 Y 41 p 58 6 + 8 I 25 Z 42 q 59 7 + 9 J 26 a 43 r 60 8 + 10 K 27 b 44 s 61 9 + 11 L 28 c 45 t 62 + + 12 M 29 d 46 u 63 / + 13 N 30 e 47 v + 14 O 31 f 48 w (pad) = + 15 P 32 g 49 x + 16 Q 33 h 50 y + + The output stream (encoded bytes) must be represented in lines of no + more than 76 characters each. All line breaks or other characters + not found in Table 1 must be ignored by decoding software. In base64 + data, characters other than those in Table 1, line breaks, and other + white space probably indicate a transmission error, about which a + warning message or even a message rejection might be appropriate + under some circumstances. + + Special processing is performed if fewer than 24 bits are available + at the end of the data being encoded. A full encoding quantum is + always completed at the end of a body. When fewer than 24 input bits + are available in an input group, zero bits are added (on the right) + to form an integral number of 6-bit groups. Padding at the end of + the data is performed using the '=' character. Since all base64 + input is an integral number of octets, only the following cases can + + + +Borenstein & Freed [Page 22] + +RFC 1521 MIME September 1993 + + + arise: (1) the final quantum of encoding input is an integral + multiple of 24 bits; here, the final unit of encoded output will be + an integral multiple of 4 characters with no "=" padding, (2) the + final quantum of encoding input is exactly 8 bits; here, the final + unit of encoded output will be two characters followed by two "=" + padding characters, or (3) the final quantum of encoding input is + exactly 16 bits; here, the final unit of encoded output will be three + characters followed by one "=" padding character. + + Because it is used only for padding at the end of the data, the + occurrence of any '=' characters may be taken as evidence that the + end of the data has been reached (without truncation in transit). No + such assurance is possible, however, when the number of octets + transmitted was a multiple of three. + + Any characters outside of the base64 alphabet are to be ignored in + base64-encoded data. The same applies to any illegal sequence of + characters in the base64 encoding, such as "=====" + + Care must be taken to use the proper octets for line breaks if base64 + encoding is applied directly to text material that has not been + converted to canonical form. In particular, text line breaks must be + converted into CRLF sequences prior to base64 encoding. The important + thing to note is that this may be done directly by the encoder rather + than in a prior canonicalization step in some implementations. + + NOTE: There is no need to worry about quoting apparent + encapsulation boundaries within base64-encoded parts of multipart + entities because no hyphen characters are used in the base64 + encoding. + +6. Additional Content-Header Fields + +6.1. Optional Content-ID Header Field + + In constructing a high-level user agent, it may be desirable to allow + one body to make reference to another. Accordingly, bodies may be + labeled using the "Content-ID" header field, which is syntactically + identical to the "Message-ID" header field: + + id := "Content-ID" ":" msg-id + Like the Message-ID values, Content-ID values must be generated to be + world-unique. + + The Content-ID value may be used for uniquely identifying MIME + entities in several contexts, particularly for cacheing data + referenced by the message/external-body mechanism. Although the + Content-ID header is generally optional, its use is mandatory in + + + +Borenstein & Freed [Page 23] + +RFC 1521 MIME September 1993 + + + implementations which generate data of the optional MIME Content-type + "message/external-body". That is, each message/external-body entity + must have a Content-ID field to permit cacheing of such data. + + It is also worth noting that the Content-ID value has special + semantics in the case of the multipart/alternative content-type. + This is explained in the section of this document dealing with + multipart/alternative. + +6.2. Optional Content-Description Header Field + + The ability to associate some descriptive information with a given + body is often desirable. For example, it may be useful to mark an + "image" body as "a picture of the Space Shuttle Endeavor." Such text + may be placed in the Content-Description header field. + + description := "Content-Description" ":" *text + + The description is presumed to be given in the US-ASCII character + set, although the mechanism specified in [RFC-1522] may be used for + non-US-ASCII Content-Description values. + +7. The Predefined Content-Type Values + + This document defines seven initial Content-Type values and an + extension mechanism for private or experimental types. Further + standard types must be defined by new published specifications. It + is expected that most innovation in new types of mail will take place + as subtypes of the seven types defined here. The most essential + characteristics of the seven content-types are summarized in Appendix + F. + +7.1 The Text Content-Type + + The text Content-Type is intended for sending material which is + principally textual in form. It is the default Content-Type. A + "charset" parameter may be used to indicate the character set of the + body text for some text subtypes, notably including the primary + subtype, "text/plain", which indicates plain (unformatted) text. The + default Content-Type for Internet mail is "text/plain; charset=us- + ascii". + + Beyond plain text, there are many formats for representing what might + be known as "extended text" -- text with embedded formatting and + presentation information. An interesting characteristic of many such + representations is that they are to some extent readable even without + the software that interprets them. It is useful, then, to + distinguish them, at the highest level, from such unreadable data as + + + +Borenstein & Freed [Page 24] + +RFC 1521 MIME September 1993 + + + images, audio, or text represented in an unreadable form. In the + absence of appropriate interpretation software, it is reasonable to + show subtypes of text to the user, while it is not reasonable to do + so with most nontextual data. + + Such formatted textual data should be represented using subtypes of + text. Plausible subtypes of text are typically given by the common + name of the representation format, e.g., "text/richtext" [RFC-1341]. + +7.1.1. The charset parameter + + A critical parameter that may be specified in the Content-Type field + for text/plain data is the character set. This is specified with a + "charset" parameter, as in: + + Content-type: text/plain; charset=us-ascii + + Unlike some other parameter values, the values of the charset + parameter are NOT case sensitive. The default character set, which + must be assumed in the absence of a charset parameter, is US-ASCII. + + The specification for any future subtypes of "text" must specify + whether or not they will also utilize a "charset" parameter, and may + possibly restrict its values as well. When used with a particular + body, the semantics of the "charset" parameter should be identical to + those specified here for "text/plain", i.e., the body consists + entirely of characters in the given charset. In particular, definers + of future text subtypes should pay close attention the the + implications of multibyte character sets for their subtype + definitions. + + This RFC specifies the definition of the charset parameter for the + purposes of MIME to be a unique mapping of a byte stream to glyphs, a + mapping which does not require external profiling information. + + An initial list of predefined character set names can be found at the + end of this section. Additional character sets may be registered + with IANA, although the standardization of their use requires the + usual IESG [RFC-1340] review and approval. Note that if the + specified character set includes 8-bit data, a Content-Transfer- + Encoding header field and a corresponding encoding on the data are + required in order to transmit the body via some mail transfer + protocols, such as SMTP. + + The default character set, US-ASCII, has been the subject of some + confusion and ambiguity in the past. Not only were there some + ambiguities in the definition, there have been wide variations in + practice. In order to eliminate such ambiguity and variations in the + + + +Borenstein & Freed [Page 25] + +RFC 1521 MIME September 1993 + + + future, it is strongly recommended that new user agents explicitly + specify a character set via the Content-Type header field. "US- + ASCII" does not indicate an arbitrary seven-bit character code, but + specifies that the body uses character coding that uses the exact + correspondence of codes to characters specified in ASCII. National + use variations of ISO 646 [ISO-646] are NOT ASCII and their use in + Internet mail is explicitly discouraged. The omission of the ISO 646 + character set is deliberate in this regard. The character set name + of "US-ASCII" explicitly refers to ANSI X3.4-1986 [US-ASCII] only. + The character set name "ASCII" is reserved and must not be used for + any purpose. + + NOTE: RFC 821 explicitly specifies "ASCII", and references an + earlier version of the American Standard. Insofar as one of the + purposes of specifying a Content-Type and character set is to + permit the receiver to unambiguously determine how the sender + intended the coded message to be interpreted, assuming anything + other than "strict ASCII" as the default would risk unintentional + and incompatible changes to the semantics of messages now being + transmitted. This also implies that messages containing + characters coded according to national variations on ISO 646, or + using code-switching procedures (e.g., those of ISO 2022), as well + as 8-bit or multiple octet character encodings MUST use an + appropriate character set specification to be consistent with this + specification. + + The complete US-ASCII character set is listed in [US-ASCII]. Note + that the control characters including DEL (0-31, 127) have no defined + meaning apart from the combination CRLF (ASCII values 13 and 10) + indicating a new line. Two of the characters have de facto meanings + in wide use: FF (12) often means "start subsequent text on the + beginning of a new page"; and TAB or HT (9) often (though not always) + means "move the cursor to the next available column after the current + position where the column number is a multiple of 8 (counting the + first column as column 0)." Apart from this, any use of the control + characters or DEL in a body must be part of a private agreement + between the sender and recipient. Such private agreements are + discouraged and should be replaced by the other capabilities of this + document. + + NOTE: Beyond US-ASCII, an enormous proliferation of character sets + is possible. It is the opinion of the IETF working group that a + large number of character sets is NOT a good thing. We would + prefer to specify a single character set that can be used + universally for representing all of the world's languages in + electronic mail. Unfortunately, existing practice in several + communities seems to point to the continued use of multiple + character sets in the near future. For this reason, we define + + + +Borenstein & Freed [Page 26] + +RFC 1521 MIME September 1993 + + + names for a small number of character sets for which a strong + constituent base exists. + + The defined charset values are: + + US-ASCII -- as defined in [US-ASCII]. + + ISO-8859-X -- where "X" is to be replaced, as necessary, for the + parts of ISO-8859 [ISO-8859]. Note that the ISO 646 + character sets have deliberately been omitted in favor of + their 8859 replacements, which are the designated character + sets for Internet mail. As of the publication of this + document, the legitimate values for "X" are the digits 1 + through 9. + + The character sets specified above are the ones that were relatively + uncontroversial during the drafting of MIME. This document does not + endorse the use of any particular character set other than US-ASCII, + and recognizes that the future evolution of world character sets + remains unclear. It is expected that in the future, additional + character sets will be registered for use in MIME. + + Note that the character set used, if anything other than US-ASCII, + must always be explicitly specified in the Content-Type field. + + No other character set name may be used in Internet mail without the + publication of a formal specification and its registration with IANA, + or by private agreement, in which case the character set name must + begin with "X-". + + Implementors are discouraged from defining new character sets for + mail use unless absolutely necessary. + + The "charset" parameter has been defined primarily for the purpose of + textual data, and is described in this section for that reason. + However, it is conceivable that non-textual data might also wish to + specify a charset value for some purpose, in which case the same + syntax and values should be used. + + In general, mail-sending software must always use the "lowest common + denominator" character set possible. For example, if a body contains + only US-ASCII characters, it must be marked as being in the US-ASCII + character set, not ISO-8859-1, which, like all the ISO-8859 family of + character sets, is a superset of US-ASCII. More generally, if a + widely-used character set is a subset of another character set, and a + body contains only characters in the widely-used subset, it must be + labeled as being in that subset. This will increase the chances that + the recipient will be able to view the mail correctly. + + + +Borenstein & Freed [Page 27] + +RFC 1521 MIME September 1993 + + +7.1.2. The Text/plain subtype + + The primary subtype of text is "plain". This indicates plain + (unformatted) text. The default Content-Type for Internet mail, + "text/plain; charset=us-ascii", describes existing Internet practice. + That is, it is the type of body defined by RFC 822. + + No other text subtype is defined by this document. + + The formal grammar for the content-type header field for text is as + follows: + + text-type := "text" "/" text-subtype [";" "charset" "=" charset] + + text-subtype := "plain" / extension-token + + charset := "us-ascii"/ "iso-8859-1"/ "iso-8859-2"/ "iso-8859-3" + / "iso-8859-4"/ "iso-8859-5"/ "iso-8859-6"/ "iso-8859-7" + / "iso-8859-8" / "iso-8859-9" / extension-token + ; case insensitive + +7.2. The Multipart Content-Type + + In the case of multiple part entities, in which one or more different + sets of data are combined in a single body, a "multipart" Content- + Type field must appear in the entity's header. The body must then + contain one or more "body parts," each preceded by an encapsulation + boundary, and the last one followed by a closing boundary. Each part + starts with an encapsulation boundary, and then contains a body part + consisting of header area, a blank line, and a body area. Thus a + body part is similar to an RFC 822 message in syntax, but different + in meaning. + + A body part is NOT to be interpreted as actually being an RFC 822 + message. To begin with, NO header fields are actually required in + body parts. A body part that starts with a blank line, therefore, is + allowed and is a body part for which all default values are to be + assumed. In such a case, the absence of a Content-Type header field + implies that the corresponding body is plain US-ASCII text. The only + header fields that have defined meaning for body parts are those the + names of which begin with "Content-". All other header fields are + generally to be ignored in body parts. Although they should + generally be retained in mail processing, they may be discarded by + gateways if necessary. Such other fields are permitted to appear in + body parts but must not be depended on. "X-" fields may be created + for experimental or private purposes, with the recognition that the + information they contain may be lost at some gateways. + + + + +Borenstein & Freed [Page 28] + +RFC 1521 MIME September 1993 + + + NOTE: The distinction between an RFC 822 message and a body part + is subtle, but important. A gateway between Internet and X.400 + mail, for example, must be able to tell the difference between a + body part that contains an image and a body part that contains an + encapsulated message, the body of which is an image. In order to + represent the latter, the body part must have "Content-Type: + message", and its body (after the blank line) must be the + encapsulated message, with its own "Content-Type: image" header + field. The use of similar syntax facilitates the conversion of + messages to body parts, and vice versa, but the distinction + between the two must be understood by implementors. (For the + special case in which all parts actually are messages, a "digest" + subtype is also defined.) + + As stated previously, each body part is preceded by an encapsulation + boundary. The encapsulation boundary MUST NOT appear inside any of + the encapsulated parts. Thus, it is crucial that the composing agent + be able to choose and specify the unique boundary that will separate + the parts. + + All present and future subtypes of the "multipart" type must use an + identical syntax. Subtypes may differ in their semantics, and may + impose additional restrictions on syntax, but must conform to the + required syntax for the multipart type. This requirement ensures + that all conformant user agents will at least be able to recognize + and separate the parts of any multipart entity, even of an + unrecognized subtype. + + As stated in the definition of the Content-Transfer-Encoding field, + no encoding other than "7bit", "8bit", or "binary" is permitted for + entities of type "multipart". The multipart delimiters and header + fields are always represented as 7-bit ASCII in any case (though the + header fields may encode non-ASCII header text as per [RFC-1522]), + and data within the body parts can be encoded on a part-by-part + basis, with Content-Transfer-Encoding fields for each appropriate + body part. + + Mail gateways, relays, and other mail handling agents are commonly + known to alter the top-level header of an RFC 822 message. In + particular, they frequently add, remove, or reorder header fields. + Such alterations are explicitly forbidden for the body part headers + embedded in the bodies of messages of type "multipart." + +7.2.1. Multipart: The common syntax + + All subtypes of "multipart" share a common syntax, defined in this + section. A simple example of a multipart message also appears in + this section. An example of a more complex multipart message is + + + +Borenstein & Freed [Page 29] + +RFC 1521 MIME September 1993 + + + given in Appendix C. + + The Content-Type field for multipart entities requires one parameter, + "boundary", which is used to specify the encapsulation boundary. The + encapsulation boundary is defined as a line consisting entirely of + two hyphen characters ("-", decimal code 45) followed by the boundary + parameter value from the Content-Type header field. + + NOTE: The hyphens are for rough compatibility with the earlier RFC + 934 method of message encapsulation, and for ease of searching for + the boundaries in some implementations. However, it should be + noted that multipart messages are NOT completely compatible with + RFC 934 encapsulations; in particular, they do not obey RFC 934 + quoting conventions for embedded lines that begin with hyphens. + This mechanism was chosen over the RFC 934 mechanism because the + latter causes lines to grow with each level of quoting. The + combination of this growth with the fact that SMTP implementations + sometimes wrap long lines made the RFC 934 mechanism unsuitable + for use in the event that deeply-nested multipart structuring is + ever desired. + + WARNING TO IMPLEMENTORS: The grammar for parameters on the Content- + type field is such that it is often necessary to enclose the + boundaries in quotes on the Content-type line. This is not always + necessary, but never hurts. Implementors should be sure to study the + grammar carefully in order to avoid producing illegal Content-type + fields. Thus, a typical multipart Content-Type header field might + look like this: + + Content-Type: multipart/mixed; + boundary=gc0p4Jq0M2Yt08jU534c0p + + But the following is illegal: + + Content-Type: multipart/mixed; + boundary=gc0p4Jq0M:2Yt08jU534c0p + + (because of the colon) and must instead be represented as + + Content-Type: multipart/mixed; + boundary="gc0p4Jq0M:2Yt08jU534c0p" + + This indicates that the entity consists of several parts, each itself + with a structure that is syntactically identical to an RFC 822 + message, except that the header area might be completely empty, and + that the parts are each preceded by the line + + --gc0p4Jq0M:2Yt08jU534c0p + + + +Borenstein & Freed [Page 30] + +RFC 1521 MIME September 1993 + + + Note that the encapsulation boundary must occur at the beginning of a + line, i.e., following a CRLF, and that the initial CRLF is considered + to be attached to the encapsulation boundary rather than part of the + preceding part. The boundary must be followed immediately either by + another CRLF and the header fields for the next part, or by two + CRLFs, in which case there are no header fields for the next part + (and it is therefore assumed to be of Content-Type text/plain). + + NOTE: The CRLF preceding the encapsulation line is conceptually + attached to the boundary so that it is possible to have a part + that does not end with a CRLF (line break). Body parts that must + be considered to end with line breaks, therefore, must have two + CRLFs preceding the encapsulation line, the first of which is part + of the preceding body part, and the second of which is part of the + encapsulation boundary. + + Encapsulation boundaries must not appear within the encapsulations, + and must be no longer than 70 characters, not counting the two + leading hyphens. + + The encapsulation boundary following the last body part is a + distinguished delimiter that indicates that no further body parts + will follow. Such a delimiter is identical to the previous + delimiters, with the addition of two more hyphens at the end of the + line: + + --gc0p4Jq0M2Yt08jU534c0p-- + + There appears to be room for additional information prior to the + first encapsulation boundary and following the final boundary. These + areas should generally be left blank, and implementations must ignore + anything that appears before the first boundary or after the last + one. + + NOTE: These "preamble" and "epilogue" areas are generally not used + because of the lack of proper typing of these parts and the lack + of clear semantics for handling these areas at gateways, + particularly X.400 gateways. However, rather than leaving the + preamble area blank, many MIME implementations have found this to + be a convenient place to insert an explanatory note for recipients + who read the message with pre-MIME software, since such notes will + be ignored by MIME-compliant software. + + NOTE: Because encapsulation boundaries must not appear in the body + parts being encapsulated, a user agent must exercise care to + choose a unique boundary. The boundary in the example above could + have been the result of an algorithm designed to produce + boundaries with a very low probability of already existing in the + + + +Borenstein & Freed [Page 31] + +RFC 1521 MIME September 1993 + + + data to be encapsulated without having to prescan the data. + Alternate algorithms might result in more 'readable' boundaries + for a recipient with an old user agent, but would require more + attention to the possibility that the boundary might appear in the + encapsulated part. The simplest boundary possible is something + like "---", with a closing boundary of "-----". + + As a very simple example, the following multipart message has two + parts, both of them plain text, one of them explicitly typed and one + of them implicitly typed: + + From: Nathaniel Borenstein + To: Ned Freed + Subject: Sample message + MIME-Version: 1.0 + Content-type: multipart/mixed; boundary="simple + boundary" + + This is the preamble. It is to be ignored, though it + is a handy place for mail composers to include an + explanatory note to non-MIME conformant readers. + --simple boundary + + This is implicitly typed plain ASCII text. + It does NOT end with a linebreak. + --simple boundary + Content-type: text/plain; charset=us-ascii + + This is explicitly typed plain ASCII text. + It DOES end with a linebreak. + + --simple boundary-- + This is the epilogue. It is also to be ignored. + + The use of a Content-Type of multipart in a body part within another + multipart entity is explicitly allowed. In such cases, for obvious + reasons, care must be taken to ensure that each nested multipart + entity must use a different boundary delimiter. See Appendix C for an + example of nested multipart entities. + + The use of the multipart Content-Type with only a single body part + may be useful in certain contexts, and is explicitly permitted. + + The only mandatory parameter for the multipart Content-Type is the + boundary parameter, which consists of 1 to 70 characters from a set + of characters known to be very robust through email gateways, and NOT + ending with white space. (If a boundary appears to end with white + space, the white space must be presumed to have been added by a + + + +Borenstein & Freed [Page 32] + +RFC 1521 MIME September 1993 + + + gateway, and must be deleted.) It is formally specified by the + following BNF: + + boundary := 0*69 bcharsnospace + + bchars := bcharsnospace / " " + + bcharsnospace := DIGIT / ALPHA / "'" / "(" / ")" / "+" /"_" + / "," / "-" / "." / "/" / ":" / "=" / "?" + + Overall, the body of a multipart entity may be specified as + follows: + + multipart-body := preamble 1*encapsulation + close-delimiter epilogue + + encapsulation := delimiter body-part CRLF + + delimiter := "--" boundary CRLF ; taken from Content-Type field. + ; There must be no space + ; between "--" and boundary. + + close-delimiter := "--" boundary "--" CRLF ; Again, no space + by "--", + + preamble := discard-text ; to be ignored upon receipt. + + epilogue := discard-text ; to be ignored upon receipt. + + discard-text := *(*text CRLF) + + body-part := <"message" as defined in RFC 822, + with all header fields optional, and with the + specified delimiter not occurring anywhere in + the message body, either on a line by itself + or as a substring anywhere. Note that the + semantics of a part differ from the semantics + of a message, as described in the text.> + + NOTE: In certain transport enclaves, RFC 822 restrictions such as + the one that limits bodies to printable ASCII characters may not + be in force. (That is, the transport domains may resemble + standard Internet mail transport as specified in RFC821 and + assumed by RFC822, but without certain restrictions.) The + relaxation of these restrictions should be construed as locally + extending the definition of bodies, for example to include octets + outside of the ASCII range, as long as these extensions are + supported by the transport and adequately documented in the + + + +Borenstein & Freed [Page 33] + +RFC 1521 MIME September 1993 + + + Content-Transfer-Encoding header field. However, in no event are + headers (either message headers or body-part headers) allowed to + contain anything other than ASCII characters. + + NOTE: Conspicuously missing from the multipart type is a notion of + structured, related body parts. In general, it seems premature to + try to standardize interpart structure yet. It is recommended + that those wishing to provide a more structured or integrated + multipart messaging facility should define a subtype of multipart + that is syntactically identical, but that always expects the + inclusion of a distinguished part that can be used to specify the + structure and integration of the other parts, probably referring + to them by their Content-ID field. If this approach is used, + other implementations will not recognize the new subtype, but will + treat it as the primary subtype (multipart/mixed) and will thus be + able to show the user the parts that are recognized. + +7.2.2. The Multipart/mixed (primary) subtype + + The primary subtype for multipart, "mixed", is intended for use when + the body parts are independent and need to be bundled in a particular + order. Any multipart subtypes that an implementation does not + recognize must be treated as being of subtype "mixed". + +7.2.3. The Multipart/alternative subtype + + The multipart/alternative type is syntactically identical to + multipart/mixed, but the semantics are different. In particular, + each of the parts is an "alternative" version of the same + information. + + Systems should recognize that the content of the various parts are + interchangeable. Systems should choose the "best" type based on the + local environment and preferences, in some cases even through user + interaction. As with multipart/mixed, the order of body parts is + significant. In this case, the alternatives appear in an order of + increasing faithfulness to the original content. In general, the best + choice is the LAST part of a type supported by the recipient system's + local environment. + + Multipart/alternative may be used, for example, to send mail in a + fancy text format in such a way that it can easily be displayed + anywhere: + + + + + + + + +Borenstein & Freed [Page 34] + +RFC 1521 MIME September 1993 + + + From: Nathaniel Borenstein + To: Ned Freed + Subject: Formatted text mail + MIME-Version: 1.0 + Content-Type: multipart/alternative; boundary=boundary42 + + --boundary42 + + Content-Type: text/plain; charset=us-ascii + + ...plain text version of message goes here.... + --boundary42 + Content-Type: text/richtext + + .... RFC 1341 richtext version of same message goes here ... + --boundary42 + Content-Type: text/x-whatever + + .... fanciest formatted version of same message goes here + ... + --boundary42-- + + In this example, users whose mail system understood the "text/x- + whatever" format would see only the fancy version, while other users + would see only the richtext or plain text version, depending on the + capabilities of their system. + + In general, user agents that compose multipart/alternative entities + must place the body parts in increasing order of preference, that is, + with the preferred format last. For fancy text, the sending user + agent should put the plainest format first and the richest format + last. Receiving user agents should pick and display the last format + they are capable of displaying. In the case where one of the + alternatives is itself of type "multipart" and contains unrecognized + sub-parts, the user agent may choose either to show that alternative, + an earlier alternative, or both. + + NOTE: From an implementor's perspective, it might seem more + sensible to reverse this ordering, and have the plainest + alternative last. However, placing the plainest alternative first + is the friendliest possible option when multipart/alternative + entities are viewed using a non-MIME-conformant mail reader. + While this approach does impose some burden on conformant mail + readers, interoperability with older mail readers was deemed to be + more important in this case. + + It may be the case that some user agents, if they can recognize more + than one of the formats, will prefer to offer the user the choice of + + + +Borenstein & Freed [Page 35] + +RFC 1521 MIME September 1993 + + + which format to view. This makes sense, for example, if mail + includes both a nicely-formatted image version and an easily-edited + text version. What is most critical, however, is that the user not + automatically be shown multiple versions of the same data. Either + the user should be shown the last recognized version or should be + given the choice. + + NOTE ON THE SEMANTICS OF CONTENT-ID IN MULTIPART/ALTERNATIVE: Each + part of a multipart/alternative entity represents the same data, but + the mappings between the two are not necessarily without information + loss. For example, information is lost when translating ODA to + PostScript or plain text. It is recommended that each part should + have a different Content-ID value in the case where the information + content of the two parts is not identical. However, where the + information content is identical -- for example, where several parts + of type "application/external- body" specify alternate ways to access + the identical data -- the same Content-ID field value should be used, + to optimize any cacheing mechanisms that might be present on the + recipient's end. However, it is recommended that the Content-ID + values used by the parts should not be the same Content-ID value that + describes the multipart/alternative as a whole, if there is any such + Content-ID field. That is, one Content-ID value will refer to the + multipart/alternative entity, while one or more other Content-ID + values will refer to the parts inside it. + +7.2.4. The Multipart/digest subtype + + This document defines a "digest" subtype of the multipart Content- + Type. This type is syntactically identical to multipart/mixed, but + the semantics are different. In particular, in a digest, the default + Content-Type value for a body part is changed from "text/plain" to + "message/rfc822". This is done to allow a more readable digest + format that is largely compatible (except for the quoting convention) + with RFC 934. + + + + + + + + + + + + + + + + + +Borenstein & Freed [Page 36] + +RFC 1521 MIME September 1993 + + + A digest in this format might, then, look something like this: + + From: Moderator-Address + To: Recipient-List + MIME-Version: 1.0 + Subject: Internet Digest, volume 42 + Content-Type: multipart/digest; + boundary="---- next message ----" + + ------ next message ---- + + From: someone-else + Subject: my opinion + + ...body goes here ... + + ------ next message ---- + + From: someone-else-again + Subject: my different opinion + + ... another body goes here... + + ------ next message ------ + +7.2.5. The Multipart/parallel subtype + + This document defines a "parallel" subtype of the multipart Content- + Type. This type is syntactically identical to multipart/mixed, but + the semantics are different. In particular, in a parallel entity, + the order of body parts is not significant. + + A common presentation of this type is to display all of the parts + simultaneously on hardware and software that are capable of doing so. + However, composing agents should be aware that many mail readers will + lack this capability and will show the parts serially in any event. + +7.2.6. Other Multipart subtypes + + Other multipart subtypes are expected in the future. MIME + implementations must in general treat unrecognized subtypes of + multipart as being equivalent to "multipart/mixed". + + The formal grammar for content-type header fields for multipart data + is given by: + + multipart-type := "multipart" "/" multipart-subtype + ";" "boundary" "=" boundary + + + +Borenstein & Freed [Page 37] + +RFC 1521 MIME September 1993 + + + multipart-subtype := "mixed" / "parallel" / "digest" + / "alternative" / extension-token + +7.3. The Message Content-Type + + It is frequently desirable, in sending mail, to encapsulate another + mail message. For this common operation, a special Content-Type, + "message", is defined. The primary subtype, message/rfc822, has no + required parameters in the Content-Type field. Additional subtypes, + "partial" and "External-body", do have required parameters. These + subtypes are explained below. + + NOTE: It has been suggested that subtypes of message might be + defined for forwarded or rejected messages. However, forwarded + and rejected messages can be handled as multipart messages in + which the first part contains any control or descriptive + information, and a second part, of type message/rfc822, is the + forwarded or rejected message. Composing rejection and forwarding + messages in this manner will preserve the type information on the + original message and allow it to be correctly presented to the + recipient, and hence is strongly encouraged. + + As stated in the definition of the Content-Transfer-Encoding field, + no encoding other than "7bit", "8bit", or "binary" is permitted for + messages or parts of type "message". Even stronger restrictions + apply to the subtypes "message/partial" and "message/external-body", + as specified below. The message header fields are always US-ASCII in + any case, and data within the body can still be encoded, in which + case the Content-Transfer-Encoding header field in the encapsulated + message will reflect this. Non-ASCII text in the headers of an + encapsulated message can be specified using the mechanisms described + in [RFC-1522]. + + Mail gateways, relays, and other mail handling agents are commonly + known to alter the top-level header of an RFC 822 message. In + particular, they frequently add, remove, or reorder header fields. + Such alterations are explicitly forbidden for the encapsulated + headers embedded in the bodies of messages of type "message." + +7.3.1. The Message/rfc822 (primary) subtype + + A Content-Type of "message/rfc822" indicates that the body contains + an encapsulated message, with the syntax of an RFC 822 message. + However, unlike top-level RFC 822 messages, it is not required that + each message/rfc822 body must include a "From", "Subject", and at + least one destination header. + + It should be noted that, despite the use of the numbers "822", a + + + +Borenstein & Freed [Page 38] + +RFC 1521 MIME September 1993 + + + message/rfc822 entity can include enhanced information as defined in + this document. In other words, a message/rfc822 message may be a + MIME message. + +7.3.2. The Message/Partial subtype + + A subtype of message, "partial", is defined in order to allow large + objects to be delivered as several separate pieces of mail and + automatically reassembled by the receiving user agent. (The concept + is similar to IP fragmentation/reassembly in the basic Internet + Protocols.) This mechanism can be used when intermediate transport + agents limit the size of individual messages that can be sent. + Content-Type "message/partial" thus indicates that the body contains + a fragment of a larger message. + + Three parameters must be specified in the Content-Type field of type + message/partial: The first, "id", is a unique identifier, as close to + a world-unique identifier as possible, to be used to match the parts + together. (In general, the identifier is essentially a message-id; + if placed in double quotes, it can be any message-id, in accordance + with the BNF for "parameter" given earlier in this specification.) + The second, "number", an integer, is the part number, which indicates + where this part fits into the sequence of fragments. The third, + "total", another integer, is the total number of parts. This third + subfield is required on the final part, and is optional (though + encouraged) on the earlier parts. Note also that these parameters + may be given in any order. + + Thus, part 2 of a 3-part message may have either of the following + header fields: + + Content-Type: Message/Partial; + number=2; total=3; + id="oc=jpbe0M2Yt4s@thumper.bellcore.com" + + Content-Type: Message/Partial; + id="oc=jpbe0M2Yt4s@thumper.bellcore.com"; + number=2 + + But part 3 MUST specify the total number of parts: + + Content-Type: Message/Partial; + number=3; total=3; + id="oc=jpbe0M2Yt4s@thumper.bellcore.com" + + Note that part numbering begins with 1, not 0. + + When the parts of a message broken up in this manner are put + + + +Borenstein & Freed [Page 39] + +RFC 1521 MIME September 1993 + + + together, the result is a complete MIME entity, which may have its + own Content-Type header field, and thus may contain any other data + type. + + Message fragmentation and reassembly: The semantics of a reassembled + partial message must be those of the "inner" message, rather than of + a message containing the inner message. This makes it possible, for + example, to send a large audio message as several partial messages, + and still have it appear to the recipient as a simple audio message + rather than as an encapsulated message containing an audio message. + That is, the encapsulation of the message is considered to be + "transparent". + + When generating and reassembling the parts of a message/partial + message, the headers of the encapsulated message must be merged with + the headers of the enclosing entities. In this process the following + rules must be observed: + + (1) All of the header fields from the initial enclosing entity + (part one), except those that start with "Content-" and the + specific header fields "Message-ID", "Encrypted", and "MIME- + Version", must be copied, in order, to the new message. + + (2) Only those header fields in the enclosed message which start + with "Content-" and "Message-ID", "Encrypted", and "MIME-Version" + must be appended, in order, to the header fields of the new + message. Any header fields in the enclosed message which do not + start with "Content-" (except for "Message-ID", "Encrypted", and + "MIME-Version") will be ignored. + + (3) All of the header fields from the second and any subsequent + messages will be ignored. + + For example, if an audio message is broken into two parts, the first + part might look something like this: + + X-Weird-Header-1: Foo + From: Bill@host.com + To: joe@otherhost.com + Subject: Audio mail + Message-ID: + MIME-Version: 1.0 + Content-type: message/partial; + id="ABC@host.com"; + number=1; total=2 + + X-Weird-Header-1: Bar + X-Weird-Header-2: Hello + + + +Borenstein & Freed [Page 40] + +RFC 1521 MIME September 1993 + + + Message-ID: + MIME-Version: 1.0 + Content-type: audio/basic + Content-transfer-encoding: base64 + + ... first half of encoded audio data goes here... + + and the second half might look something like this: + + From: Bill@host.com + To: joe@otherhost.com + Subject: Audio mail + MIME-Version: 1.0 + Message-ID: + Content-type: message/partial; + id="ABC@host.com"; number=2; total=2 + + ... second half of encoded audio data goes here... + + Then, when the fragmented message is reassembled, the resulting + message to be displayed to the user should look something like this: + + X-Weird-Header-1: Foo + From: Bill@host.com + To: joe@otherhost.com + Subject: Audio mail + Message-ID: + MIME-Version: 1.0 + Content-type: audio/basic + Content-transfer-encoding: base64 + + ... first half of encoded audio data goes here... + ... second half of encoded audio data goes here... + + Note on encoding of MIME entities encapsulated inside message/partial + entities: Because data of type "message" may never be encoded in + base64 or quoted-printable, a problem might arise if message/partial + entities are constructed in an environment that supports binary or + 8-bit transport. The problem is that the binary data would be split + into multiple message/partial objects, each of them requiring binary + transport. If such objects were encountered at a gateway into a 7- + bit transport environment, there would be no way to properly encode + them for the 7-bit world, aside from waiting for all of the parts, + reassembling the message, and then encoding the reassembled data in + base64 or quoted-printable. Since it is possible that different + parts might go through different gateways, even this is not an + acceptable solution. For this reason, it is specified that MIME + entities of type message/partial must always have a content- + + + +Borenstein & Freed [Page 41] + +RFC 1521 MIME September 1993 + + + transfer-encoding of 7-bit (the default). In particular, even in + environments that support binary or 8-bit transport, the use of a + content-transfer-encoding of "8bit" or "binary" is explicitly + prohibited for entities of type message/partial. + + It should be noted that, because some message transfer agents may + choose to automatically fragment large messages, and because such + agents may use different fragmentation thresholds, it is possible + that the pieces of a partial message, upon reassembly, may prove + themselves to comprise a partial message. This is explicitly + permitted. + + It should also be noted that the inclusion of a "References" field in + the headers of the second and subsequent pieces of a fragmented + message that references the Message-Id on the previous piece may be + of benefit to mail readers that understand and track references. + However, the generation of such "References" fields is entirely + optional. + + Finally, it should be noted that the "Encrypted" header field has + been made obsolete by Privacy Enhanced Messaging (PEM), but the rules + above are believed to describe the correct way to treat it if it is + encountered in the context of conversion to and from message/partial + fragments. + +7.3.3. The Message/External-Body subtype + + The external-body subtype indicates that the actual body data are not + included, but merely referenced. In this case, the parameters + describe a mechanism for accessing the external data. + + When an entity is of type "message/external-body", it consists of a + header, two consecutive CRLFs, and the message header for the + encapsulated message. If another pair of consecutive CRLFs appears, + this of course ends the message header for the encapsulated message. + However, since the encapsulated message's body is itself external, it + does NOT appear in the area that follows. For example, consider the + following message: + + Content-type: message/external-body; access- + type=local-file; + + name="/u/nsb/Me.gif" + + Content-type: image/gif + Content-ID: + Content-Transfer-Encoding: binary + + + + +Borenstein & Freed [Page 42] + +RFC 1521 MIME September 1993 + + + THIS IS NOT REALLY THE BODY! + + The area at the end, which might be called the "phantom body", is + ignored for most external-body messages. However, it may be used to + contain auxiliary information for some such messages, as indeed it is + when the access-type is "mail-server". Of the access-types defined + by this document, the phantom body is used only when the access-type + is "mail-server". In all other cases, the phantom body is ignored. + + The only always-mandatory parameter for message/external-body is + "access-type"; all of the other parameters may be mandatory or + optional depending on the value of access-type. + + ACCESS-TYPE -- A case-insensitive word, indicating the supported + access mechanism by which the file or data may be obtained. + Values include, but are not limited to, "FTP", "ANON-FTP", "TFTP", + "AFS", "LOCAL-FILE", and "MAIL-SERVER". Future values, except for + experimental values beginning with "X-" must be registered with + IANA, as described in Appendix E . + + In addition, the following three parameters are optional for ALL + access-types: + + EXPIRATION -- The date (in the RFC 822 "date-time" syntax, as + extended by RFC 1123 to permit 4 digits in the year field) after + which the existence of the external data is not guaranteed. + + SIZE -- The size (in octets) of the data. The intent of this + parameter is to help the recipient decide whether or not to expend + the necessary resources to retrieve the external data. Note that + this describes the size of the data in its canonical form, that + is, before any Content- Transfer-Encoding has been applied or + after the data have been decoded. + + PERMISSION -- A case-insensitive field that indicates whether or + not it is expected that clients might also attempt to overwrite + the data. By default, or if permission is "read", the assumption + is that they are not, and that if the data is retrieved once, it + is never needed again. If PERMISSION is "read-write", this + assumption is invalid, and any local copy must be considered no + more than a cache. "Read" and "Read-write" are the only defined + values of permission. + + The precise semantics of the access-types defined here are described + in the sections that follow. + + The encapsulated headers in ALL message/external-body entities MUST + include a Content-ID header field to give a unique identifier by + + + +Borenstein & Freed [Page 43] + +RFC 1521 MIME September 1993 + + + which to reference the data. This identifier may be used for + cacheing mechanisms, and for recognizing the receipt of the data when + the access-type is "mail-server". + + Note that, as specified here, the tokens that describe external-body + data, such as file names and mail server commands, are required to be + in the US-ASCII character set. If this proves problematic in + practice, a new mechanism may be required as a future extension to + MIME, either as newly defined access-types for message/external-body + or by some other mechanism. + + As with message/partial, it is specified that MIME entities of type + message/external-body must always have a content-transfer-encoding of + 7-bit (the default). In particular, even in environments that + support binary or 8-bit transport, the use of a content-transfer- + encoding of "8bit" or "binary" is explicitly prohibited for entities + of type message/external-body. + +7.3.3.1. The "ftp" and "tftp" access-types + + An access-type of FTP or TFTP indicates that the message body is + accessible as a file using the FTP [RFC-959] or TFTP [RFC-783] + protocols, respectively. For these access-types, the following + additional parameters are mandatory: + + NAME -- The name of the file that contains the actual body data. + + SITE -- A machine from which the file may be obtained, using the + given protocol. This must be a fully qualified domain name, not a + nickname. + + Before any data are retrieved, using FTP, the user will generally + need to be asked to provide a login id and a password for the machine + named by the site parameter. For security reasons, such an id and + password are not specified as content-type parameters, but must be + obtained from the user. + + In addition, the following parameters are optional: + + DIRECTORY -- A directory from which the data named by NAME should + be retrieved. + + MODE -- A case-insensitive string indicating the mode to be used + when retrieving the information. The legal values for access-type + "TFTP" are "NETASCII", "OCTET", and "MAIL", as specified by the + TFTP protocol [RFC-783]. The legal values for access-type "FTP" + are "ASCII", "EBCDIC", "IMAGE", and "LOCALn" where "n" is a + decimal integer, typically 8. These correspond to the + + + +Borenstein & Freed [Page 44] + +RFC 1521 MIME September 1993 + + + representation types "A" "E" "I" and "L n" as specified by the FTP + protocol [RFC-959]. Note that "BINARY" and "TENEX" are not valid + values for MODE, but that "OCTET" or "IMAGE" or "LOCAL8" should be + used instead. IF MODE is not specified, the default value is + "NETASCII" for TFTP and "ASCII" otherwise. + +7.3.3.2. The "anon-ftp" access-type + + The "anon-ftp" access-type is identical to the "ftp" access type, + except that the user need not be asked to provide a name and password + for the specified site. Instead, the ftp protocol will be used with + login "anonymous" and a password that corresponds to the user's email + address. + +7.3.3.3. The "local-file" and "afs" access-types + + An access-type of "local-file" indicates that the actual body is + accessible as a file on the local machine. An access-type of "afs" + indicates that the file is accessible via the global AFS file system. + In both cases, only a single parameter is required: + + NAME -- The name of the file that contains the actual body data. + + The following optional parameter may be used to describe the locality + of reference for the data, that is, the site or sites at which the + file is expected to be visible: + + SITE -- A domain specifier for a machine or set of machines that + are known to have access to the data file. Asterisks may be used + for wildcard matching to a part of a domain name, such as + "*.bellcore.com", to indicate a set of machines on which the data + should be directly visible, while a single asterisk may be used to + indicate a file that is expected to be universally available, + e.g., via a global file system. + +7.3.3.4. The "mail-server" access-type + + The "mail-server" access-type indicates that the actual body is + available from a mail server. The mandatory parameter for this + access-type is: + + SERVER -- The email address of the mail server from which the + actual body data can be obtained. + + Because mail servers accept a variety of syntaxes, some of which is + multiline, the full command to be sent to a mail server is not + included as a parameter on the content-type line. Instead, it is + provided as the "phantom body" when the content-type is + + + +Borenstein & Freed [Page 45] + +RFC 1521 MIME September 1993 + + + message/external-body and the access- type is mail-server. + + An optional parameter for this access-type is: + + SUBJECT -- The subject that is to be used in the mail that is sent + to obtain the data. Note that keying mail servers on Subject lines + is NOT recommended, but such mail servers are known to exist. + + Note that MIME does not define a mail server syntax. Rather, it + allows the inclusion of arbitrary mail server commands in the phantom + body. Implementations must include the phantom body in the body of + the message it sends to the mail server address to retrieve the + relevant data. + + It is worth noting that, unlike other access-types, mail-server + access is asynchronous and will happen at an unpredictable time in + the future. For this reason, it is important that there be a + mechanism by which the returned data can be matched up with the + original message/external-body entity. MIME mailservers must use the + same Content-ID field on the returned message that was used in the + original message/external-body entity, to facilitate such matching. + +7.3.3.5. Examples and Further Explanations + + With the emerging possibility of very wide-area file systems, it + becomes very hard to know in advance the set of machines where a file + will and will not be accessible directly from the file system. + Therefore it may make sense to provide both a file name, to be tried + directly, and the name of one or more sites from which the file is + known to be accessible. An implementation can try to retrieve remote + files using FTP or any other protocol, using anonymous file retrieval + or prompting the user for the necessary name and password. If an + external body is accessible via multiple mechanisms, the sender may + include multiple parts of type message/external-body within an entity + of type multipart/alternative. + + However, the external-body mechanism is not intended to be limited to + file retrieval, as shown by the mail-server access-type. Beyond + this, one can imagine, for example, using a video server for external + references to video clips. + + If an entity is of type "message/external-body", then the body of the + entity will contain the header fields of the encapsulated message. + The body itself is to be found in the external location. This means + that if the body of the "message/external-body" message contains two + consecutive CRLFs, everything after those pairs is NOT part of the + message itself. For most message/external-body messages, this + trailing area must simply be ignored. However, it is a convenient + + + +Borenstein & Freed [Page 46] + +RFC 1521 MIME September 1993 + + + place for additional data that cannot be included in the content-type + header field. In particular, if the "access-type" value is "mail- + server", then the trailing area must contain commands to be sent to + the mail server at the address given by the value of the SERVER + parameter. + + The embedded message header fields which appear in the body of the + message/external-body data must be used to declare the Content-type + of the external body if it is anything other than plain ASCII text, + since the external body does not have a header section to declare its + type. Similarly, any Content-transfer-encoding other than "7bit" + must also be declared here. Thus a complete message/external-body + message, referring to a document in PostScript format, might look + like this: + + From: Whomever + To: Someone + Subject: whatever + MIME-Version: 1.0 + Message-ID: + Content-Type: multipart/alternative; boundary=42 + Content-ID: + + --42 + Content-Type: message/external-body; + name="BodyFormats.ps"; + site="thumper.bellcore.com"; + access-type=ANON-FTP; + directory="pub"; + mode="image"; + expiration="Fri, 14 Jun 1991 19:13:14 -0400 (EDT)" + + Content-type: application/postscript + Content-ID: + + --42 + Content-Type: message/external-body; + name="/u/nsb/writing/rfcs/RFC-MIME.ps"; + site="thumper.bellcore.com"; + access-type=AFS + expiration="Fri, 14 Jun 1991 19:13:14 -0400 (EDT)" + + Content-type: application/postscript + Content-ID: + + --42 + Content-Type: message/external-body; + access-type=mail-server + + + +Borenstein & Freed [Page 47] + +RFC 1521 MIME September 1993 + + + server="listserv@bogus.bitnet"; + expiration="Fri, 14 Jun 1991 19:13:14 -0400 (EDT)" + + Content-type: application/postscript + Content-ID: + + get RFC-MIME.DOC + + --42-- + + Note that in the above examples, the default Content-transfer- + encoding of "7bit" is assumed for the external postscript data. + + Like the message/partial type, the message/external-body type is + intended to be transparent, that is, to convey the data type in the + external body rather than to convey a message with a body of that + type. Thus the headers on the outer and inner parts must be merged + using the same rules as for message/partial. In particular, this + means that the Content-type header is overridden, but the From and + Subject headers are preserved. + + Note that since the external bodies are not transported as mail, they + need not conform to the 7-bit and line length requirements, but might + in fact be binary files. Thus a Content-Transfer-Encoding is not + generally necessary, though it is permitted. + + Note that the body of a message of type "message/external-body" is + governed by the basic syntax for an RFC 822 message. In particular, + anything before the first consecutive pair of CRLFs is header + information, while anything after it is body information, which is + ignored for most access-types. + + The formal grammar for content-type header fields for data of type + message is given by: + + message-type := "message" "/" message-subtype + + message-subtype := "rfc822" + / "partial" 2#3partial-param + / "external-body" 1*external-param + / extension-token + + partial-param := (";" "id" "=" value) + / (";" "number" "=" 1*DIGIT) + / (";" "total" "=" 1*DIGIT) + ; id & number required; total required for last part + + external-param := (";" "access-type" "=" atype) + + + +Borenstein & Freed [Page 48] + +RFC 1521 MIME September 1993 + + + / (";" "expiration" "=" date-time) + ; Note that date-time is quoted + / (";" "size" "=" 1*DIGIT) + / (";" "permission" "=" ("read" / "read-write")) + ; Permission is case-insensitive + / (";" "name" "=" value) + / (";" "site" "=" value) + / (";" "dir" "=" value) + / (";" "mode" "=" value) + / (";" "server" "=" value) + / (";" "subject" "=" value) + ; access-type required;others required based on access-type + + atype := "ftp" / "anon-ftp" / "tftp" / "local-file" + / "afs" / "mail-server" / extension-token + ; Case-insensitive + +7.4. The Application Content-Type + + The "application" Content-Type is to be used for data which do not + fit in any of the other categories, and particularly for data to be + processed by mail-based uses of application programs. This is + information which must be processed by an application before it is + viewable or usable to a user. Expected uses for Content-Type + application include mail-based file transfer, spreadsheets, data for + mail-based scheduling systems, and languages for "active" + (computational) email. (The latter, in particular, can pose security + problems which must be understood by implementors, and are considered + in detail in the discussion of the application/PostScript content- + type.) + + For example, a meeting scheduler might define a standard + representation for information about proposed meeting dates. An + intelligent user agent would use this information to conduct a dialog + with the user, and might then send further mail based on that dialog. + More generally, there have been several "active" messaging languages + developed in which programs in a suitably specialized language are + sent through the mail and automatically run in the recipient's + environment. + + Such applications may be defined as subtypes of the "application" + Content-Type. This document defines two subtypes: octet-stream, and + PostScript. + + In general, the subtype of application will often be the name of the + application for which the data are intended. This does not mean, + however, that any application program name may be used freely as a + subtype of application. Such usages (other than subtypes beginning + + + +Borenstein & Freed [Page 49] + +RFC 1521 MIME September 1993 + + + with "x-") must be registered with IANA, as described in Appendix E. + +7.4.1. The Application/Octet-Stream (primary) subtype + + The primary subtype of application, "octet-stream", may be used to + indicate that a body contains binary data. The set of possible + parameters includes, but is not limited to: + + TYPE -- the general type or category of binary data. This is + intended as information for the human recipient rather than for + any automatic processing. + + PADDING -- the number of bits of padding that were appended to the + bit-stream comprising the actual contents to produce the enclosed + byte-oriented data. This is useful for enclosing a bit-stream in + a body when the total number of bits is not a multiple of the byte + size. + + An additional parameter, "conversions", was defined in [RFC-1341] but + has been removed. + + RFC 1341 also defined the use of a "NAME" parameter which gave a + suggested file name to be used if the data were to be written to a + file. This has been deprecated in anticipation of a separate + Content-Disposition header field, to be defined in a subsequent RFC. + + The recommended action for an implementation that receives + application/octet-stream mail is to simply offer to put the data in a + file, with any Content-Transfer-Encoding undone, or perhaps to use it + as input to a user-specified process. + + To reduce the danger of transmitting rogue programs through the mail, + it is strongly recommended that implementations NOT implement a + path-search mechanism whereby an arbitrary program named in the + Content-Type parameter (e.g., an "interpreter=" parameter) is found + and executed using the mail body as input. + +7.4.2. The Application/PostScript subtype + + A Content-Type of "application/postscript" indicates a PostScript + program. Currently two variants of the PostScript language are + allowed; the original level 1 variant is described in [POSTSCRIPT] + and the more recent level 2 variant is described in [POSTSCRIPT2]. + + PostScript is a registered trademark of Adobe Systems, Inc. Use of + the MIME content-type "application/postscript" implies recognition of + that trademark and all the rights it entails. + + + + +Borenstein & Freed [Page 50] + +RFC 1521 MIME September 1993 + + + The PostScript language definition provides facilities for internal + labeling of the specific language features a given program uses. This + labeling, called the PostScript document structuring conventions, is + very general and provides substantially more information than just + the language level. + + The use of document structuring conventions, while not required, is + strongly recommended as an aid to interoperability. Documents which + lack proper structuring conventions cannot be tested to see whether + or not they will work in a given environment. As such, some systems + may assume the worst and refuse to process unstructured documents. + + The execution of general-purpose PostScript interpreters entails + serious security risks, and implementors are discouraged from simply + sending PostScript email bodies to "off-the-shelf" interpreters. + While it is usually safe to send PostScript to a printer, where the + potential for harm is greatly constrained, implementors should + consider all of the following before they add interactive display of + PostScript bodies to their mail readers. + + The remainder of this section outlines some, though probably not all, + of the possible problems with sending PostScript through the mail. + + Dangerous operations in the PostScript language include, but may not + be limited to, the PostScript operators deletefile, renamefile, + filenameforall, and file. File is only dangerous when applied to + something other than standard input or output. Implementations may + also define additional nonstandard file operators; these may also + pose a threat to security. Filenameforall, the wildcard file search + operator, may appear at first glance to be harmless. Note, however, + that this operator has the potential to reveal information about what + files the recipient has access to, and this information may itself be + sensitive. Message senders should avoid the use of potentially + dangerous file operators, since these operators are quite likely to + be unavailable in secure PostScript implementations. Message- + receiving and -displaying software should either completely disable + all potentially dangerous file operators or take special care not to + delegate any special authority to their operation. These operators + should be viewed as being done by an outside agency when interpreting + PostScript documents. Such disabling and/or checking should be done + completely outside of the reach of the PostScript language itself; + care should be taken to insure that no method exists for re-enabling + full-function versions of these operators. + + The PostScript language provides facilities for exiting the normal + interpreter, or server, loop. Changes made in this "outer" + environment are customarily retained across documents, and may in + some cases be retained semipermanently in nonvolatile memory. The + + + +Borenstein & Freed [Page 51] + +RFC 1521 MIME September 1993 + + + operators associated with exiting the interpreter loop have the + potential to interfere with subsequent document processing. As such, + their unrestrained use constitutes a threat of service denial. + PostScript operators that exit the interpreter loop include, but may + not be limited to, the exitserver and startjob operators. Message- + sending software should not generate PostScript that depends on + exiting the interpreter loop to operate. The ability to exit will + probably be unavailable in secure PostScript implementations. + Message-receiving and -displaying software should, if possible, + disable the ability to make retained changes to the PostScript + environment, and eliminate the startjob and exitserver commands. If + these commands cannot be eliminated, the password associated with + them should at least be set to a hard-to-guess value. + + PostScript provides operators for setting system-wide and device- + specific parameters. These parameter settings may be retained across + jobs and may potentially pose a threat to the correct operation of + the interpreter. The PostScript operators that set system and device + parameters include, but may not be limited to, the setsystemparams + and setdevparams operators. Message-sending software should not + generate PostScript that depends on the setting of system or device + parameters to operate correctly. The ability to set these parameters + will probably be unavailable in secure PostScript implementations. + Message-receiving and -displaying software should, if possible, + disable the ability to change system and device parameters. If these + operators cannot be disabled, the password associated with them + should at least be set to a hard-to-guess value. + + Some PostScript implementations provide nonstandard facilities for + the direct loading and execution of machine code. Such facilities + are quite obviously open to substantial abuse. Message-sending + software should not make use of such features. Besides being totally + hardware- specific, they are also likely to be unavailable in secure + implementations of PostScript. Message-receiving and -displaying + software should not allow such operators to be used if they exist. + + PostScript is an extensible language, and many, if not most, + implementations of it provide a number of their own extensions. This + document does not deal with such extensions explicitly since they + constitute an unknown factor. Message-sending software should not + make use of nonstandard extensions; they are likely to be missing + from some implementations. Message-receiving and -displaying software + should make sure that any nonstandard PostScript operators are secure + and don't present any kind of threat. + + It is possible to write PostScript that consumes huge amounts of + various system resources. It is also possible to write PostScript + programs that loop infinitely. Both types of programs have the + + + +Borenstein & Freed [Page 52] + +RFC 1521 MIME September 1993 + + + potential to cause damage if sent to unsuspecting recipients. + Message-sending software should avoid the construction and + dissemination of such programs, which is antisocial. Message- + receiving and -displaying software should provide appropriate + mechanisms to abort processing of a document after a reasonable + amount of time has elapsed. In addition, PostScript interpreters + should be limited to the consumption of only a reasonable amount of + any given system resource. + + Finally, bugs may exist in some PostScript interpreters which could + possibly be exploited to gain unauthorized access to a recipient's + system. Apart from noting this possibility, there is no specific + action to take to prevent this, apart from the timely correction of + such bugs if any are found. + +7.4.3. Other Application subtypes + + It is expected that many other subtypes of application will be + defined in the future. MIME implementations must generally treat any + unrecognized subtypes as being equivalent to application/octet- + stream. + + The formal grammar for content-type header fields for application + data is given by: + + application-type := "application" "/" application-subtype + + application-subtype := ("octet-stream" *stream-param) + / "postscript" / extension-token + + stream-param := (";" "type" "=" value) + / (";" "padding" "=" padding) + + padding := "0" / "1" / "2" / "3" / "4" / "5" / "6" / "7" + +7.5. The Image Content-Type + + A Content-Type of "image" indicates that the body contains an image. + The subtype names the specific image format. These names are case + insensitive. Two initial subtypes are "jpeg" for the JPEG format, + JFIF encoding, and "gif" for GIF format [GIF]. + + The list of image subtypes given here is neither exclusive nor + exhaustive, and is expected to grow as more types are registered with + IANA, as described in Appendix E. + + The formal grammar for the content-type header field for data of type + image is given by: + + + +Borenstein & Freed [Page 53] + +RFC 1521 MIME September 1993 + + + image-type := "image" "/" ("gif" / "jpeg" / extension-token) + +7.6. The Audio Content-Type + + A Content-Type of "audio" indicates that the body contains audio + data. Although there is not yet a consensus on an "ideal" audio + format for use with computers, there is a pressing need for a format + capable of providing interoperable behavior. + + The initial subtype of "basic" is specified to meet this requirement + by providing an absolutely minimal lowest common denominator audio + format. It is expected that richer formats for higher quality and/or + lower bandwidth audio will be defined by a later document. + + The content of the "audio/basic" subtype is audio encoded using 8-bit + ISDN mu-law [PCM]. When this subtype is present, a sample rate of + 8000 Hz and a single channel is assumed. + + The formal grammar for the content-type header field for data of type + audio is given by: + + audio-type := "audio" "/" ("basic" / extension-token) + +7.7. The Video Content-Type + + A Content-Type of "video" indicates that the body contains a time- + varying-picture image, possibly with color and coordinated sound. + The term "video" is used extremely generically, rather than with + reference to any particular technology or format, and is not meant to + preclude subtypes such as animated drawings encoded compactly. The + subtype "mpeg" refers to video coded according to the MPEG standard + [MPEG]. + + Note that although in general this document strongly discourages the + mixing of multiple media in a single body, it is recognized that many + so-called "video" formats include a representation for synchronized + audio, and this is explicitly permitted for subtypes of "video". + + The formal grammar for the content-type header field for data of type + video is given by: + + video-type := "video" "/" ("mpeg" / extension-token) + +7.8. Experimental Content-Type Values + + A Content-Type value beginning with the characters "X-" is a private + value, to be used by consenting mail systems by mutual agreement. + Any format without a rigorous and public definition must be named + + + +Borenstein & Freed [Page 54] + +RFC 1521 MIME September 1993 + + + with an "X-" prefix, and publicly specified values shall never begin + with "X-". (Older versions of the widely-used Andrew system use the + "X-BE2" name, so new systems should probably choose a different + name.) + + In general, the use of "X-" top-level types is strongly discouraged. + Implementors should invent subtypes of the existing types whenever + possible. The invention of new types is intended to be restricted + primarily to the development of new media types for email, such as + digital odors or holography, and not for new data formats in general. + In many cases, a subtype of application will be more appropriate than + a new top-level type. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Borenstein & Freed [Page 55] + +RFC 1521 MIME September 1993 + + +8. Summary + + Using the MIME-Version, Content-Type, and Content-Transfer-Encoding + header fields, it is possible to include, in a standardized way, + arbitrary types of data objects with RFC 822 conformant mail + messages. No restrictions imposed by either RFC 821 or RFC 822 are + violated, and care has been taken to avoid problems caused by + additional restrictions imposed by the characteristics of some + Internet mail transport mechanisms (see Appendix B). The "multipart" + and "message" Content-Types allow mixing and hierarchical structuring + of objects of different types in a single message. Further Content- + Types provide a standardized mechanism for tagging messages or body + parts as audio, image, or several other kinds of data. A + distinguished parameter syntax allows further specification of data + format details, particularly the specification of alternate character + sets. Additional optional header fields provide mechanisms for + certain extensions deemed desirable by many implementors. Finally, a + number of useful Content-Types are defined for general use by + consenting user agents, notably message/partial, and + message/external-body. + +9. Security Considerations + + Security issues are discussed in Section 7.4.2 and in Appendix F. + Implementors should pay special attention to the security + implications of any mail content-types that can cause the remote + execution of any actions in the recipient's environment. In such + cases, the discussion of the application/postscript content-type in + Section 7.4.2 may serve as a model for considering other content- + types with remote execution capabilities. + + + + + + + + + + + + + + + + + + + + + +Borenstein & Freed [Page 56] + +RFC 1521 MIME September 1993 + + +10. Authors' Addresses + + For more information, the authors of this document may be contacted + via Internet mail: + + Nathaniel S. Borenstein + MRE 2D-296, Bellcore + 445 South St. + Morristown, NJ 07962-1910 + + Phone: +1 201 829 4270 + Fax: +1 201 829 7019 + Email: nsb@bellcore.com + + + Ned Freed + Innosoft International, Inc. + 250 West First Street + Suite 240 + Claremont, CA 91711 + + Phone: +1 909 624 7907 + Fax: +1 909 621 5319 + Email: ned@innosoft.com + + MIME is a result of the work of the Internet Engineering Task Force + Working Group on Email Extensions. The chairman of that group, Greg + Vaudreuil, may be reached at: + + Gregory M. Vaudreuil + Tigon Corporation + 17060 Dallas Parkway + Dallas Texas, 75248 + + Phone: +1 214-733-2722 + EMail: gvaudre@cnri.reston.va.us + + + + + + + + + + + + + + + +Borenstein & Freed [Page 57] + +RFC 1521 MIME September 1993 + + +11. Acknowledgements + + This document is the result of the collective effort of a large + number of people, at several IETF meetings, on the IETF-SMTP and + IETF-822 mailing lists, and elsewhere. Although any enumeration + seems doomed to suffer from egregious omissions, the following are + among the many contributors to this effort: + + Harald Tveit Alvestrand Timo Lehtinen + Randall Atkinson John R. MacMillan + Philippe Brandon Rick McGowan + Kevin Carosso Leo Mclaughlin + Uhhyung Choi Goli Montaser-Kohsari + Cristian Constantinof Keith Moore + Mark Crispin Tom Moore + Dave Crocker Erik Naggum + Terry Crowley Mark Needleman + Walt Daniels John Noerenberg + Frank Dawson Mats Ohrman + Hitoshi Doi Julian Onions + Kevin Donnelly Michael Patton + Keith Edwards David J. Pepper + Chris Eich Blake C. Ramsdell + Johnny Eriksson Luc Rooijakkers + Craig Everhart Marshall T. Rose + Patrik Faeltstroem Jonathan Rosenberg + Erik E. Fair Jan Rynning + Roger Fajman Harri Salminen + Alain Fontaine Michael Sanderson + James M. Galvin Masahiro Sekiguchi + Philip Gladstone Mark Sherman + Thomas Gordon Keld Simonsen + Phill Gross Bob Smart + James Hamilton Peter Speck + Steve Hardcastle-Kille Henry Spencer + David Herron Einar Stefferud + Bruce Howard Michael Stein + Bill Janssen Klaus Steinberger + Olle Jaernefors Peter Svanberg + Risto Kankkunen James Thompson + Phil Karn Steve Uhler + Alan Katz Stuart Vance + Tim Kehres Erik van der Poel + Neil Katin Guido van Rossum + Kyuho Kim Peter Vanderbilt + Anders Klemets Greg Vaudreuil + John Klensin Ed Vielmetti + Valdis Kletniek Ryan Waldron + + + +Borenstein & Freed [Page 58] + +RFC 1521 MIME September 1993 + + + Jim Knowles Wally Wedel + Stev Knowles Sven-Ove Westberg + Bob Kummerfeld Brian Wideen + Pekka Kytolaakso John Wobus + Stellan Lagerstrom Glenn Wright + Vincent Lau Rayan Zachariassen + Donald Lindsay David Zimmerman + Marc Andreessen Bob Braden + Brian Capouch Peter Clitherow + Dave Collier-Brown John Coonrod + Stephen Crocker Jim Davis + Axel Deininger Dana S Emery + Martin Forssen Stephen Gildea + Terry Gray Mark Horton + Warner Losh Carlyn Lowery + Laurence Lundblade Charles Lynn + Larry Masinter Michael J. McInerny + Jon Postel Christer Romson + Yutaka Sato Markku Savela + Richard Alan Schafer Larry W. Virden + Rhys Weatherly Jay Weber + Dave Wecker + +The authors apologize for any omissions from this list, which are +certainly unintentional. + + + + + + + + + + + + + + + + + + + + + + + + + + +Borenstein & Freed [Page 59] + +RFC 1521 MIME September 1993 + + +Appendix A -- Minimal MIME-Conformance + + The mechanisms described in this document are open-ended. It is + definitely not expected that all implementations will support all of + the Content-Types described, nor that they will all share the same + extensions. In order to promote interoperability, however, it is + useful to define the concept of "MIME-conformance" to define a + certain level of implementation that allows the useful interworking + of messages with content that differs from US ASCII text. In this + section, we specify the requirements for such conformance. + + A mail user agent that is MIME-conformant MUST: + + 1. Always generate a "MIME-Version: 1.0" header field. + + 2. Recognize the Content-Transfer-Encoding header field, and + decode all received data encoded with either the quoted-printable + or base64 implementations. Encode any data sent that is not in + seven-bit mail-ready representation using one of these + transformations and include the appropriate Content-Transfer- + Encoding header field, unless the underlying transport mechanism + supports non-seven-bit data, as SMTP does not. + + 3. Recognize and interpret the Content-Type header field, and + avoid showing users raw data with a Content-Type field other than + text. Be able to send at least text/plain messages, with the + character set specified as a parameter if it is not US-ASCII. + + 4. Explicitly handle the following Content-Type values, to at + least the following extents: + + Text: + + -- Recognize and display "text" mail + with the character set "US-ASCII." + + -- Recognize other character sets at + least to the extent of being able + to inform the user about what + character set the message uses. + + -- Recognize the "ISO-8859-*" character + sets to the extent of being able to + display those characters that are + common to ISO-8859-* and US-ASCII, + namely all characters represented + by octet values 0-127. + + + + +Borenstein & Freed [Page 60] + +RFC 1521 MIME September 1993 + + + -- For unrecognized subtypes, show or + offer to show the user the "raw" + version of the data after + conversion of the content from + canonical form to local form. + + Message: + + -- Recognize and display at least the + primary (822) encapsulation. + + Multipart: + + -- Recognize the primary (mixed) + subtype. Display all relevant + information on the message level + and the body part header level and + then display or offer to display + each of the body parts individually. + + -- Recognize the "alternative" subtype, + and avoid showing the user + redundant parts of + multipart/alternative mail. + + -- Treat any unrecognized subtypes as if + they were "mixed". + + Application: + + -- Offer the ability to remove either of + the two types of Content-Transfer- + Encoding defined in this document + and put the resulting information + in a user file. + + 5. Upon encountering any unrecognized Content- Type, an + implementation must treat it as if it had a Content-Type of + "application/octet-stream" with no parameter sub-arguments. How + such data are handled is up to an implementation, but likely + options for handling such unrecognized data include offering the + user to write it into a file (decoded from its mail transport + format) or offering the user to name a program to which the + decoded data should be passed as input. Unrecognized predefined + types, which in a MIME-conformant mailer might still include + audio, image, or video, should also be treated in this way. + + A user agent that meets the above conditions is said to be MIME- + + + +Borenstein & Freed [Page 61] + +RFC 1521 MIME September 1993 + + + conformant. The meaning of this phrase is that it is assumed to be + "safe" to send virtually any kind of properly-marked data to users of + such mail systems, because such systems will at least be able to + treat the data as undifferentiated binary, and will not simply splash + it onto the screen of unsuspecting users. There is another sense in + which it is always "safe" to send data in a format that is MIME- + conformant, which is that such data will not break or be broken by + any known systems that are conformant with RFC 821 and RFC 822. User + agents that are MIME-conformant have the additional guarantee that + the user will not be shown data that were never intended to be viewed + as text. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Borenstein & Freed [Page 62] + +RFC 1521 MIME September 1993 + + +Appendix B -- General Guidelines For Sending Email Data + + Internet email is not a perfect, homogeneous system. Mail may become + corrupted at several stages in its travel to a final destination. + Specifically, email sent throughout the Internet may travel across + many networking technologies. Many networking and mail technologies + do not support the full functionality possible in the SMTP transport + environment. Mail traversing these systems is likely to be modified + in such a way that it can be transported. + + There exist many widely-deployed non-conformant MTAs in the Internet. + These MTAs, speaking the SMTP protocol, alter messages on the fly to + take advantage of the internal data structure of the hosts they are + implemented on, or are just plain broken. + + The following guidelines may be useful to anyone devising a data + format (Content-Type) that will survive the widest range of + networking technologies and known broken MTAs unscathed. Note that + anything encoded in the base64 encoding will satisfy these rules, but + that some well-known mechanisms, notably the UNIX uuencode facility, + will not. Note also that anything encoded in the Quoted-Printable + encoding will survive most gateways intact, but possibly not some + gateways to systems that use the EBCDIC character set. + + (1) Under some circumstances the encoding used for data may change + as part of normal gateway or user agent operation. In particular, + conversion from base64 to quoted-printable and vice versa may be + necessary. This may result in the confusion of CRLF sequences with + line breaks in text bodies. As such, the persistence of CRLF as + something other than a line break must not be relied on. + + (2) Many systems may elect to represent and store text data using + local newline conventions. Local newline conventions may not match + the RFC822 CRLF convention -- systems are known that use plain CR, + plain LF, CRLF, or counted records. The result is that isolated + CR and LF characters are not well tolerated in general; they may + be lost or converted to delimiters on some systems, and hence must + not be relied on. + + (3) TAB (HT) characters may be misinterpreted or may be + automatically converted to variable numbers of spaces. This is + unavoidable in some environments, notably those not based on the + ASCII character set. Such conversion is STRONGLY DISCOURAGED, but + it may occur, and mail formats must not rely on the persistence of + TAB (HT) characters. + + (4) Lines longer than 76 characters may be wrapped or truncated in + some environments. Line wrapping and line truncation are STRONGLY + + + +Borenstein & Freed [Page 63] + +RFC 1521 MIME September 1993 + + + DISCOURAGED, but unavoidable in some cases. Applications which + require long lines must somehow differentiate between soft and + hard line breaks. (A simple way to do this is to use the quoted- + printable encoding.) + + (5) Trailing "white space" characters (SPACE, TAB (HT)) on a line + may be discarded by some transport agents, while other transport + agents may pad lines with these characters so that all lines in a + mail file are of equal length. The persistence of trailing white + space, therefore, must not be relied on. + + (6) Many mail domains use variations on the ASCII character set, + or use character sets such as EBCDIC which contain most but not + all of the US-ASCII characters. The correct translation of + characters not in the "invariant" set cannot be depended on across + character converting gateways. For example, this situation is a + problem when sending uuencoded information across BITNET, an + EBCDIC system. Similar problems can occur without crossing a + gateway, since many Internet hosts use character sets other than + ASCII internally. The definition of Printable Strings in X.400 + adds further restrictions in certain special cases. In + particular, the only characters that are known to be consistent + across all gateways are the 73 characters that correspond to the + upper and lower case letters A-Z and a-z, the 10 digits 0-9, and + the following eleven special characters: + + "'" (ASCII code 39) + "(" (ASCII code 40) + ")" (ASCII code 41) + "+" (ASCII code 43) + "," (ASCII code 44) + "-" (ASCII code 45) + "." (ASCII code 46) + "/" (ASCII code 47) + ":" (ASCII code 58) + "=" (ASCII code 61) + "?" (ASCII code 63) + + A maximally portable mail representation, such as the base64 + encoding, will confine itself to relatively short lines of text in + which the only meaningful characters are taken from this set of 73 + characters. + + (7) Some mail transport agents will corrupt data that includes + certain literal strings. In particular, a period (".") alone on a + line is known to be corrupted by some (incorrect) SMTP + implementations, and a line that starts with the five characters + "From " (the fifth character is a SPACE) are commonly corrupted as + + + +Borenstein & Freed [Page 64] + +RFC 1521 MIME September 1993 + + + well. A careful composition agent can prevent these corruptions + by encoding the data (e.g., in the quoted-printable encoding, + "=46rom " in place of "From " at the start of a line, and "=2E" in + place of "." alone on a line. + + Please note that the above list is NOT a list of recommended + practices for MTAs. RFC 821 MTAs are prohibited from altering the + character of white space or wrapping long lines. These BAD and + illegal practices are known to occur on established networks, and + implementations should be robust in dealing with the bad effects they + can cause. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Borenstein & Freed [Page 65] + +RFC 1521 MIME September 1993 + + +Appendix C -- A Complex Multipart Example + + What follows is the outline of a complex multipart message. This + message has five parts to be displayed serially: two introductory + plain text parts, an embedded multipart message, a richtext part, and + a closing encapsulated text message in a non-ASCII character set. + The embedded multipart message has two parts to be displayed in + parallel, a picture and an audio fragment. + + MIME-Version: 1.0 + From: Nathaniel Borenstein + To: Ned Freed + Subject: A multipart example + Content-Type: multipart/mixed; + boundary=unique-boundary-1 + + This is the preamble area of a multipart message. + Mail readers that understand multipart format + should ignore this preamble. + If you are reading this text, you might want to + consider changing to a mail reader that understands + how to properly display multipart messages. + --unique-boundary-1 + + ...Some text appears here... + [Note that the preceding blank line means + no header fields were given and this is text, + with charset US ASCII. It could have been + done with explicit typing as in the next part.] + + --unique-boundary-1 + Content-type: text/plain; charset=US-ASCII + + This could have been part of the previous part, + but illustrates explicit versus implicit + typing of body parts. + + --unique-boundary-1 + Content-Type: multipart/parallel; + boundary=unique-boundary-2 + + + --unique-boundary-2 + Content-Type: audio/basic + Content-Transfer-Encoding: base64 + + ... base64-encoded 8000 Hz single-channel + mu-law-format audio data goes here.... + + + +Borenstein & Freed [Page 66] + +RFC 1521 MIME September 1993 + + + --unique-boundary-2 + Content-Type: image/gif + Content-Transfer-Encoding: base64 + + ... base64-encoded image data goes here.... + + --unique-boundary-2-- + + --unique-boundary-1 + Content-type: text/richtext + + This is richtext. + as defined in RFC 1341 + Isn't it + cool? + + --unique-boundary-1 + Content-Type: message/rfc822 + + From: (mailbox in US-ASCII) + To: (address in US-ASCII) + Subject: (subject in US-ASCII) + Content-Type: Text/plain; charset=ISO-8859-1 + Content-Transfer-Encoding: Quoted-printable + + ... Additional text in ISO-8859-1 goes here ... + + --unique-boundary-1-- + + + + + + + + + + + + + + + + + + + + + + + +Borenstein & Freed [Page 67] + +RFC 1521 MIME September 1993 + + +Appendix D -- Collected Grammar + + This appendix contains the complete BNF grammar for all the syntax + specified by this document. + + By itself, however, this grammar is incomplete. It refers to several + entities that are defined by RFC 822. Rather than reproduce those + definitions here, and risk unintentional differences between the two, + this document simply refers the reader to RFC 822 for the remaining + definitions. Wherever a term is undefined, it refers to the RFC 822 + definition. + + application-subtype := ("octet-stream" *stream-param) + / "postscript" / extension-token + + application-type := "application" "/" application-subtype + + attribute := token ; case-insensitive + + atype := "ftp" / "anon-ftp" / "tftp" / "local-file" + / "afs" / "mail-server" / extension-token + ; Case-insensitive + + audio-type := "audio" "/" ("basic" / extension-token) + + body-part := <"message" as defined in RFC 822, + with all header fields optional, and with the + specified delimiter not occurring anywhere in + the message body, either on a line by itself + or as a substring anywhere.> + + NOTE: In certain transport enclaves, RFC 822 restrictions such as + the one that limits bodies to printable ASCII characters may not + be in force. (That is, the transport domains may resemble + standard Internet mail transport as specified in RFC821 and + assumed by RFC822, but without certain restrictions.) The + relaxation of these restrictions should be construed as locally + extending the definition of bodies, for example to include octets + outside of the ASCII range, as long as these extensions are + supported by the transport and adequately documented in the + Content-Transfer-Encoding header field. However, in no event are + headers (either message headers or body-part headers) allowed to + contain anything other than ASCII characters. + + + + + + + + +Borenstein & Freed [Page 68] + +RFC 1521 MIME September 1993 + + + boundary := 0*69 bcharsnospace + + bchars := bcharsnospace / " " + + bcharsnospace := DIGIT / ALPHA / "'" / "(" / ")" / "+" / "_" + / "," / "-" / "." / "/" / ":" / "=" / "?" + + charset := "us-ascii" / "iso-8859-1" / "iso-8859-2"/ "iso-8859-3" + / "iso-8859-4" / "iso-8859-5" / "iso-8859-6" / "iso-8859-7" + / "iso-8859-8" / "iso-8859-9" / extension-token + ; case insensitive + + close-delimiter := "--" boundary "--" CRLF;Again,no space by "--", + + content := "Content-Type" ":" type "/" subtype *(";" parameter) + ; case-insensitive matching of type and subtype + + delimiter := "--" boundary CRLF ;taken from Content-Type field. + ; There must be no space + ; between "--" and boundary. + + description := "Content-Description" ":" *text + + discard-text := *(*text CRLF) + + encapsulation := delimiter body-part CRLF + + encoding := "Content-Transfer-Encoding" ":" mechanism + + epilogue := discard-text ; to be ignored upon receipt. + + extension-token := x-token / iana-token + + external-param := (";" "access-type" "=" atype) + / (";" "expiration" "=" date-time) + + ; Note that date-time is quoted + / (";" "size" "=" 1*DIGIT) + / (";" "permission" "=" ("read" / "read-write")) + ; Permission is case-insensitive + / (";" "name" "=" value) + / (";" "site" "=" value) + / (";" "dir" "=" value) + / (";" "mode" "=" value) + / (";" "server" "=" value) + / (";" "subject" "=" value) + ;access-type required; others required based on access-type + + + + +Borenstein & Freed [Page 69] + +RFC 1521 MIME September 1993 + + + iana-token := + + id := "Content-ID" ":" msg-id + + image-type := "image" "/" ("gif" / "jpeg" / extension-token) + + mechanism := "7bit" ; case-insensitive + / "quoted-printable" + / "base64" + / "8bit" + / "binary" + / x-token + + message-subtype := "rfc822" + / "partial" 2#3partial-param + / "external-body" 1*external-param + / extension-token + + message-type := "message" "/" message-subtype + + multipart-body :=preamble 1*encapsulation close-delimiter epilogue + + multipart-subtype := "mixed" / "parallel" / "digest" + / "alternative" / extension-token + + multipart-type := "multipart" "/" multipart-subtype + ";" "boundary" "=" boundary + + octet := "=" 2(DIGIT / "A" / "B" / "C" / "D" / "E" / "F") + ; octet must be used for characters > 127, =, SPACE, or + TAB, + ; and is recommended for any characters not listed in + ; Appendix B as "mail-safe". + + padding := "0" / "1" / "2" / "3" / "4" / "5" / "6" / "7" + + parameter := attribute "=" value + + partial-param := (";" "id" "=" value) + / (";" "number" "=" 1*DIGIT) + / (";" "total" "=" 1*DIGIT) + ; id & number required;total required for last part + + preamble := discard-text ; to be ignored upon receipt. + + ptext := octet / " / "@" + / "," / ";" / ":" / "\" / <"> + / "/" / "[" / "]" / "?" / "=" + ; Must be in quoted-string, + ; to use within parameter values + + + type := "application" / "audio" ; case-insensitive + / "image" / "message" + / "multipart" / "text" + / "video" / extension-token + ; All values case-insensitive + + value := token / quoted-string + + version := "MIME-Version" ":" 1*DIGIT "." 1*DIGIT + + video-type := "video" "/" ("mpeg" / extension-token) + + x-token := + + + + + + + + + + + + + +Borenstein & Freed [Page 71] + +RFC 1521 MIME September 1993 + + +Appendix E -- IANA Registration Procedures + + MIME has been carefully designed to have extensible mechanisms, and + it is expected that the set of content-type/subtype pairs and their + associated parameters will grow significantly with time. Several + other MIME fields, notably character set names, access-type + parameters for the message/external-body type, and possibly even + Content-Transfer-Encoding values, are likely to have new values + defined over time. In order to ensure that the set of such values is + developed in an orderly, well-specified, and public manner, MIME + defines a registration process which uses the Internet Assigned + Numbers Authority (IANA) as a central registry for such values. + + In general, parameters in the content-type header field are used to + convey supplemental information for various content types, and their + use is defined when the content-type and subtype are defined. New + parameters should not be defined as a way to introduce new + functionality. + + In order to simplify and standardize the registration process, this + appendix gives templates for the registration of new values with + IANA. Each of these is given in the form of an email message + template, to be filled in by the registering party. + + E.1 Registration of New Content-type/subtype Values + + Note that MIME is generally expected to be extended by subtypes. If + a new fundamental top-level type is needed, its specification must be + published as an RFC or submitted in a form suitable to become an RFC, + and be subject to the Internet standards process. + + To: IANA@isi.edu + Subject: Registration of new MIME + content-type/subtype + + MIME type name: + + (If the above is not an existing top-level MIME type, + please explain why an existing type cannot be used.) + + MIME subtype name: + + Required parameters: + + Optional parameters: + + Encoding considerations: + + + + +Borenstein & Freed [Page 72] + +RFC 1521 MIME September 1993 + + + Security considerations: + + Published specification: + + (The published specification must be an Internet RFC or + RFC-to-be if a new top-level type is being defined, and + must be a publicly available specification in any + case.) + + Person & email address to contact for further information: + + E.2 Registration of New Access-type Values + for Message/external-body + + To: IANA@isi.edu + Subject: Registration of new MIME Access-type for + Message/external-body content-type + + MIME access-type name: + + Required parameters: + + Optional parameters: + + Published specification: + + (The published specification must be an Internet RFC or + RFC-to-be.) + + Person & email address to contact for further information: + + + + + + + + + + + + + + + + + + + + + +Borenstein & Freed [Page 73] + +RFC 1521 MIME September 1993 + + +Appendix F -- Summary of the Seven Content-types + + Content-type: text + + Subtypes defined by this document: plain + + Important Parameters: charset + + Encoding notes: quoted-printable generally preferred if an encoding + is needed and the character set is mostly an ASCII superset. + + Security considerations: Rich text formats such as TeX and Troff + often contain mechanisms for executing arbitrary commands or file + system operations, and should not be used automatically unless + these security problems have been addressed. Even plain text may + contain control characters that can be used to exploit the + capabilities of "intelligent" terminals and cause security + violations. User interfaces designed to run on such terminals + should be aware of and try to prevent such problems. + + ________________________________________________________ + Content-type: multipart + + Subtypes defined by this document: mixed, alternative, + digest, parallel. + + Important Parameters: boundary + + Encoding notes: No content-transfer-encoding is permitted. + + ________________________________________________________ + Content-type: message + + Subtypes defined by this document: rfc822, partial, external-body + + Important Parameters: id, number, total, access-type, expiration, + size, permission, name, site, directory, mode, server, subject + + Encoding notes: No content-transfer-encoding is permitted. + Specifically, only "7bit" is permitted for "message/partial" or + "message/external-body", and only "7bit", "8bit", or "binary" are + permitted for other subtypes of "message". + ______________________________________________________________ + Content-type: application + + Subtypes defined by this document: octet-stream, postscript + + Important Parameters: type, padding + + + +Borenstein & Freed [Page 74] + +RFC 1521 MIME September 1993 + + + Deprecated Parameters: name and conversions were + defined in RFC 1341. + + Encoding notes: base64 preferred for unreadable subtypes. + + Security considerations: This type is intended for the + transmission of data to be interpreted by locally-installed + programs. If used, for example, to transmit executable + binary programs or programs in general-purpose interpreted + languages, such as LISP programs or shell scripts, severe + security problems could result. Authors of mail-reading + agents are cautioned against giving their systems the power + to execute mail-based application data without carefully + considering the security implications. While it is + certainly possible to define safe application formats and + even safe interpreters for unsafe formats, each interpreter + should be evaluated separately for possible security + problems. + ________________________________________________________________ + Content-type: image + + Subtypes defined by this document: jpeg, gif + + Important Parameters: none + + Encoding notes: base64 generally preferred + ________________________________________________________________ + Content-type: audio + + Subtypes defined by this document: basic + + Important Parameters: none + + Encoding notes: base64 generally preferred + ________________________________________________________________ + Content-type: video + + Subtypes defined by this document: mpeg + + Important Parameters: none + + Encoding notes: base64 generally preferred + + + + + + + + + +Borenstein & Freed [Page 75] + +RFC 1521 MIME September 1993 + + +Appendix G -- Canonical Encoding Model + + There was some confusion, in earlier drafts of this memo, regarding + the model for when email data was to be converted to canonical form + and encoded, and in particular how this process would affect the + treatment of CRLFs, given that the representation of newlines varies + greatly from system to system. For this reason, a canonical model + for encoding is presented below. + + The process of composing a MIME entity can be modeled as being done + in a number of steps. Note that these steps are roughly similar to + those steps used in RFC 1421 and are performed for each 'innermost + level' body: + + Step 1. Creation of local form. + + The body to be transmitted is created in the system's native format. + The native character set is used, and where appropriate local end of + line conventions are used as well. The body may be a UNIX-style text + file, or a Sun raster image, or a VMS indexed file, or audio data in + a system-dependent format stored only in memory, or anything else + that corresponds to the local model for the representation of some + form of information. Fundamentally, the data is created in the + "native" form specified by the type/subtype information. + + Step 2. Conversion to canonical form. + + The entire body, including "out-of-band" information such as record + lengths and possibly file attribute information, is converted to a + universal canonical form. The specific content type of the body as + well as its associated attributes dictate the nature of the canonical + form that is used. Conversion to the proper canonical form may + involve character set conversion, transformation of audio data, + compression, or various other operations specific to the various + content types. If character set conversion is involved, however, + care must be taken to understand the semantics of the content-type, + which may have strong implications for any character set conversion, + e.g. with regard to syntactically meaningful characters in a text + subtype other than "plain". + + For example, in the case of text/plain data, the text must be + converted to a supported character set and lines must be delimited + with CRLF delimiters in accordance with RFC822. Note that the + restriction on line lengths implied by RFC822 is eliminated if the + next step employs either quoted-printable or base64 encoding. + + + + + + +Borenstein & Freed [Page 76] + +RFC 1521 MIME September 1993 + + + Step 3. Apply transfer encoding. + + A Content-Transfer-Encoding appropriate for this body is applied. + Note that there is no fixed relationship between the content type and + the transfer encoding. In particular, it may be appropriate to base + the choice of base64 or quoted-printable on character frequency + counts which are specific to a given instance of a body. + + Step 4. Insertion into entity. + + The encoded object is inserted into a MIME entity with appropriate + headers. The entity is then inserted into the body of a higher-level + entity (message or multipart) if needed. + + It is vital to note that these steps are only a model; they are + specifically NOT a blueprint for how an actual system would be built. + In particular, the model fails to account for two common designs: + + 1. In many cases the conversion to a canonical form prior to + encoding will be subsumed into the encoder itself, which + understands local formats directly. For example, the local + newline convention for text bodies might be carried through to the + encoder itself along with knowledge of what that format is. + + 2. The output of the encoders may have to pass through one or + more additional steps prior to being transmitted as a message. As + such, the output of the encoder may not be conformant with the + formats specified by RFC822. In particular, once again it may be + appropriate for the converter's output to be expressed using local + newline conventions rather than using the standard RFC822 CRLF + delimiters. + + Other implementation variations are conceivable as well. The vital + aspect of this discussion is that, in spite of any optimizations, + collapsings of required steps, or insertion of additional processing, + the resulting messages must be consistent with those produced by the + model described here. For example, a message with the following + header fields: + + Content-type: text/foo; charset=bar + Content-Transfer-Encoding: base64 + + must be first represented in the text/foo form, then (if necessary) + represented in the "bar" character set, and finally transformed via + the base64 algorithm into a mail-safe form. + + + + + + +Borenstein & Freed [Page 77] + +RFC 1521 MIME September 1993 + + +Appendix H -- Changes from RFC 1341 + + This document is a relatively minor revision of RFC 1341. For + the convenience of those familiar with RFC 1341, the technical + changes from that document are summarized in this appendix. + + 1. The definition of "tspecials" has been changed to no longer + include ".". + + 2. The Content-ID field is now mandatory for message/external-body + parts. + + 3. The text/richtext type (including the old Section 7.1.3 and + Appendix D) has been moved to a separate document. + + 4. The rules on header merging for message/partial data have been + changed to treat the Encrypted and MIME-Version headers as special + cases. + + 5. The definition of the external-body access-type parameter has + been changed so that it can only indicate a single access method + (which was all that made sense). + + 6. There is a new "Subject" parameter for message/external-body, + access-type mail-server, to permit MIME-based use of mail servers + that rely on Subject field information. + + 7. The "conversions" parameter for application/octet-stream has been + removed. + + 8. Section 7.4.1 now deprecates the use of the "name" parameter for + application/octet-stream, as this will be superseded in the future by + a Content-Disposition header. + + 9. The formal grammar for multipart bodies has been changed so that + a CRLF is no longer required before the first boundary line. + + 10. MIME entities of type "message/partial" and "message/external- + body" are now required to use only the "7bit" transfer-encoding. + (Specifically, "binary" and "8bit" are not permitted.) + + 11. The "application/oda" content-type has been removed. + + 12. A note has been added to the end of section 7.2.3, explaining + the semantics of Content-ID in a multipart/alternative MIME entity. + + 13. The formal syntax for the "MIME-Version" field has been + tightened, but in a way that is completely compatible with the only + + + +Borenstein & Freed [Page 78] + +RFC 1521 MIME September 1993 + + + version number defined in RFC 1341. + + 14. In Section 7.3.1, the definition of message/rfc822 has been + relaxed regarding mandatory fields. + + All other changes from RFC 1341 were editorial changes and do not + affect the technical content of MIME. Considerable formal grammar + has been added, but this reflects the prose specification that was + already in place. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Borenstein & Freed [Page 79] + +RFC 1521 MIME September 1993 + + +References + + [US-ASCII] Coded Character Set--7-Bit American Standard Code for + Information Interchange, ANSI X3.4-1986. + + [ATK] Borenstein, Nathaniel S., Multimedia Applications Development + with the Andrew Toolkit, Prentice-Hall, 1990. + + [GIF] Graphics Interchange Format (Version 89a), Compuserve, Inc., + Columbus, Ohio, 1990. + + [ISO-2022] International Standard--Information Processing--ISO 7-bit + and 8-bit coded character sets--Code extension techniques, ISO + 2022:1986. + + [ISO-8859] Information Processing -- 8-bit Single-Byte Coded Graphic + Character Sets -- Part 1: Latin Alphabet No. 1, ISO 8859-1:1987. Part + 2: Latin alphabet No. 2, ISO 8859-2, 1987. Part 3: Latin alphabet + No. 3, ISO 8859-3, 1988. Part 4: Latin alphabet No. 4, ISO 8859-4, + 1988. Part 5: Latin/Cyrillic alphabet, ISO 8859-5, 1988. Part 6: + Latin/Arabic alphabet, ISO 8859-6, 1987. Part 7: Latin/Greek + alphabet, ISO 8859-7, 1987. Part 8: Latin/Hebrew alphabet, ISO + 8859-8, 1988. Part 9: Latin alphabet No. 5, ISO 8859-9, 1990. + + [ISO-646] International Standard--Information Processing--ISO 7-bit + coded character set for information interchange, ISO 646:1983. + + [MPEG] Video Coding Draft Standard ISO 11172 CD, ISO IEC/TJC1/SC2/WG11 + (Motion Picture Experts Group), May, 1991. + + [PCM] CCITT, Fascicle III.4 - Recommendation G.711, Geneva, 1972, + "Pulse Code Modulation (PCM) of Voice Frequencies". + + [POSTSCRIPT] Adobe Systems, Inc., PostScript Language Reference + Manual, Addison-Wesley, 1985. + + [POSTSCRIPT2] Adobe Systems, Inc., PostScript Language Reference + Manual, Addison-Wesley, Second Edition, 1990. + + [X400] Schicker, Pietro, "Message Handling Systems, X.400", Message + Handling Systems and Distributed Applications, E. Stefferud, O-j. + Jacobsen, and P. Schicker, eds., North-Holland, 1989, pp. 3-41. + + [RFC-783] Sollins, K., "TFTP Protocol (revision 2)", RFC 783, MIT, + June 1981. + + [RFC-821] Postel, J., "Simple Mail Transfer Protocol", STD 10, RFC + 821, USC/Information Sciences Institute, August 1982. + + + +Borenstein & Freed [Page 80] + +RFC 1521 MIME September 1993 + + + [RFC-822] Crocker, D., "Standard for the Format of ARPA Internet Text + Messages", STD 11, RFC 822, UDEL, August 1982. + + [RFC-934] Rose, M., and E. Stefferud, "Proposed Standard for Message + Encapsulation", RFC 934, Delaware and NMA, January 1985. + + [RFC-959] Postel, J. and J. Reynolds, "File Transfer Protocol", + STD 9, RFC 959, USC/Information Sciences Institute, October 1985. + + [RFC-1049] Sirbu, M., "Content-Type Header Field for Internet + Messages", STD 11, RFC 1049, CMU, March 1988. + + [RFC-1421] Linn, J., "Privacy Enhancement for Internet Electronic Mail: + Part I - Message Encryption and Authentication Procedures", RFC + 1421, IAB IRTF PSRG, IETF PEM WG, February 1993. + + [RFC-1154] Robinson, D. and R. Ullmann, "Encoding Header Field for + Internet Messages", RFC 1154, Prime Computer, Inc., April 1990. + + [RFC-1341] Borenstein, N., and N. Freed, "MIME (Multipurpose Internet + Mail Extensions): Mechanisms for Specifying and Describing the Format + of Internet Message Bodies", RFC 1341, Bellcore, Innosoft, June 1992. + + [RFC-1342] Moore, K., "Representation of Non-Ascii Text in Internet + Message Headers", RFC 1342, University of Tennessee, June 1992. + + [RFC-1343] Borenstein, N., "A User Agent Configuration Mechanism + for Multimedia Mail Format Information", RFC 1343, Bellcore, June + 1992. + + [RFC-1344] Borenstein, N., "Implications of MIME for Internet + Mail Gateways", RFC 1344, Bellcore, June 1992. + + [RFC-1345] Simonsen, K., "Character Mnemonics & Character Sets", + RFC 1345, Rationel Almen Planlaegning, June 1992. + + [RFC-1426] Klensin, J., (WG Chair), Freed, N., (Editor), Rose, M., + Stefferud, E., and D. Crocker, "SMTP Service Extension for 8bit-MIME + transport", RFC 1426, United Nations Universit, Innosoft, Dover Beach + Consulting, Inc., Network Management Associates, Inc., The Branch + Office, February 1993. + + [RFC-1522] Moore, K., "Representation of Non-Ascii Text in Internet + Message Headers" RFC 1522, University of Tennessee, September 1993. + + [RFC-1340] Reynolds, J., and J. Postel, "Assigned Numbers", STD 2, RFC + 1340, USC/Information Sciences Institute, July 1992. + + + + +Borenstein & Freed [Page 81] + \ No newline at end of file diff --git a/vendor/swiftmailer/swiftmailer/notes/rfc/rfc1854.txt b/vendor/swiftmailer/swiftmailer/notes/rfc/rfc1854.txt new file mode 100755 index 0000000..7b1a975 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/notes/rfc/rfc1854.txt @@ -0,0 +1,395 @@ + + + + + + +Network Working Group N. Freed +Request For Comments: 1854 Innosoft International, Inc. +Category: Standards Track A. Cargille, WG Chair + October 1995 + + + SMTP Service Extension + for Command Pipelining + +Status of this Memo + + This document specifies an Internet standards track protocol for the + Internet community, and requests discussion and suggestions for + improvements. Please refer to the current edition of the "Internet + Official Protocol Standards" (STD 1) for the standardization state + and status of this protocol. Distribution of this memo is unlimited. + +Abstract + + This memo defines an extension to the SMTP service whereby a server + can indicate the extent of its ability to accept multiple commands in + a single TCP send operation. Using a single TCP send operation for + multiple commands can improve SMTP performance significantly. + +Introduction + + Although SMTP is widely and robustly deployed, certain extensions may + nevertheless prove useful. In particular, many parts of the Internet + make use of high latency network links. + + SMTP's intrinsic one command-one response structure is significantly + penalized by high latency links, often to the point where the factors + contributing to overall connection time are dominated by the time + spent waiting for responses to individual commands (turnaround time). + + In the best of all worlds it would be possible to simply deploy SMTP + client software that makes use of command pipelining: batching up + multiple commands into single TCP send operations. Unfortunately, the + original SMTP specification [1] did not explicitly state that SMTP + servers must support this. As a result a non-trivial number of + Internet SMTP servers cannot adequately handle command pipelining. + Flaws known to exist in deployed servers include: + + (1) Connection handoff and buffer flushes in the middle of + the SMTP dialogue. Creation of server processes for + incoming SMTP connections is a useful, obvious, and + harmless implementation technique. However, some SMTP + servers defer process forking and connection handoff + + + +Freed & Cargille Standards Track [Page 1] + +RFC 1854 SMTP Pipelining October 1995 + + + until some intermediate point in the SMTP dialogue. + When this is done material read from the TCP connection + and kept in process buffers can be lost. + + (2) Flushing the TCP input buffer when an SMTP command + fails. SMTP commands often fail but there is no reason + to flush the TCP input buffer when this happens. + Nevertheless, some SMTP servers do this. + + (3) Improper processing and promulgation of SMTP command + failures. For example, some SMTP servers will refuse to + accept a DATA command if the last RCPT TO command + fails, paying no attention to the success or failure of + prior RCPT TO command results. Other servers will + accept a DATA command even when all previous RCPT TO + commands have failed. Although it is possible to + accommodate this sort of behavior in a client that + employs command pipelining, it does complicate the + construction of the client unnecessarily. + + This memo uses the mechanism described in [2] to define an extension + to the SMTP service whereby an SMTP server can declare that it is + capable of handling pipelined commands. The SMTP client can then + check for this declaration and use pipelining only when the server + declares itself capable of handling it. + +1. Framework for the Command Pipelining Extension + + The Command Pipelining extension is defined as follows: + + (1) the name of the SMTP service extension is Pipelining; + + (2) the EHLO keyword value associated with the extension is + PIPELINING; + + (3) no parameter is used with the PIPELINING EHLO keyword; + + (4) no additional parameters are added to either the MAIL + FROM or RCPT TO commands. + + (5) no additional SMTP verbs are defined by this extension; + and, + + (6) the next section specifies how support for the + extension affects the behavior of a server and client + SMTP. + + + + + +Freed & Cargille Standards Track [Page 2] + +RFC 1854 SMTP Pipelining October 1995 + + +2. The Pipelining Service Extension + + When a client SMTP wishes to employ command pipelining, it first + issues the EHLO command to the server SMTP. If the server SMTP + responds with code 250 to the EHLO command, and the response includes + the EHLO keyword value PIPELINING, then the server SMTP has indicated + that it can accommodate SMTP command pipelining. + +2.1. Client use of pipelining + + Once the client SMTP has confirmed that support exists for the + pipelining extension, the client SMTP may then elect to transmit + groups of SMTP commands in batches without waiting for a response to + each individual command. In particular, the commands RSET, MAIL FROM, + SEND FROM, SOML FROM, SAML FROM, and RCPT TO can all appear anywhere + in a pipelined command group. The EHLO, DATA, VRFY, EXPN, TURN, + QUIT, and NOOP commands can only appear as the last command in a + group since their success or failure produces a change of state which + the client SMTP must accommodate. (NOOP is included in this group so + it can be used as a synchronization point.) + + Additional commands added by other SMTP extensions may only appear as + the last command in a group unless otherwise specified by the + extensions that define the commands. + + The actual transfer of message content is explicitly allowed to be + the first "command" in a group. That is, the RSET/MAIL FROM sequence + necessary to initiate a new message transaction can be placed in the + same group as the final transfer of the headers and body of the + previous message. + + Client SMTP implementations that employ pipelining MUST check ALL + statuses associated with each command in a group. For example, if + none of the RCPT TO recipient addresses were accepted the client must + then check the response to the DATA command -- the client cannot + assume that the DATA command will be rejected just because none of + the RCPT TO commands worked. If the DATA command was properly + rejected the client SMTP can just issue RSET, but if the DATA command + was accepted the client SMTP should send a single dot. + + Command statuses MUST be coordinated with responses by counting each + separate response and correlating that count with the number of + commands known to have been issued. Multiline responses MUST be + supported. Matching on the basis of either the error code value or + associated text is expressly forbidden. + + Client SMTP implementations MAY elect to operate in a nonblocking + fashion, processing server responses immediately upon receipt, even + + + +Freed & Cargille Standards Track [Page 3] + +RFC 1854 SMTP Pipelining October 1995 + + + if there is still data pending transmission from the client's + previous TCP send operation. If nonblocking operation is not + supported, however, client SMTP implementations MUST also check the + TCP window size and make sure that each group of commands fits + entirely within the window. The window size is usually, but not + always, 4K octets. Failure to perform this check can lead to + deadlock conditions. + + Clients MUST NOT confuse responses to multiple commands with + multiline responses. Each command requires one or more lines of + response, the last line not containing a dash between the response + code and the response string. + +2.2. Server support of pipelining + + A server SMTP implementation that offers the pipelining extension: + + (1) MUST NOT flush or otherwise lose the contents of the + TCP input buffer under any circumstances whatsoever. + + (2) SHOULD issue a positive response to the DATA command if + and only if one or more valid RCPT TO addresses have + been previously received. + + (3) MUST NOT, after issuing a positive response to a DATA + command with no valid recipients and subsequently + receiving an empty message, send any message whatsoever + to anybody. + + (4) SHOULD elect to store responses to grouped RSET, MAIL + FROM, SEND FROM, SOML FROM, SAML FROM, and RCPT TO + commands in an internal buffer so they can sent as a + unit. + + (5) MUST NOT buffer responses to EHLO, DATA, VRFY, EXPN, + TURN, QUIT, and NOOP. + + (6) MUST NOT buffer responses to unrecognized commands. + + (7) MUST send all pending responses immediately whenever + the local TCP input buffer is emptied. + + (8) MUST NOT make assumptions about commands that are yet + to be received. + + (9) SHOULD issue response text that indicates, either + implicitly or explicitly, what command the response + matches. + + + +Freed & Cargille Standards Track [Page 4] + +RFC 1854 SMTP Pipelining October 1995 + + + The overriding intent of these server requirements is to make it as + easy as possible for servers to conform to these pipelining + extensions. + +3. Examples + + Consider the following SMTP dialogue that does not use pipelining: + + S: + C: + S: 220 innosoft.com SMTP service ready + C: HELO dbc.mtview.ca.us + S: 250 innosoft.com + C: MAIL FROM: + S: 250 sender OK + C: RCPT TO: + S: 250 recipient OK + C: RCPT TO: + S: 250 recipient OK + C: RCPT TO: + S: 250 recipient OK + C: DATA + S: 354 enter mail, end with line containing only "." + ... + C: . + S: 250 message sent + C: QUIT + S: 221 goodbye + + The client waits for a server response a total of 9 times in this + simple example. But if pipelining is employed the following dialogue + is possible: + + S: + C: + S: 220 innosoft.com SMTP service ready + C: EHLO dbc.mtview.ca.us + S: 250-innosoft.com + S: 250 PIPELINING + C: MAIL FROM: + C: RCPT TO: + C: RCPT TO: + C: RCPT TO: + C: DATA + S: 250 sender OK + S: 250 recipient OK + S: 250 recipient OK + S: 250 recipient OK + + + +Freed & Cargille Standards Track [Page 5] + +RFC 1854 SMTP Pipelining October 1995 + + + S: 354 enter mail, end with line containing only "." + ... + C: . + C: QUIT + S: 250 message sent + S: 221 goodbye + + The total number of turnarounds has been reduced from 9 to 4. + + The next example illustrates one possible form of behavior when + pipelining is used and all recipients are rejected: + + S: + C: + S: 220 innosoft.com SMTP service ready + C: EHLO dbc.mtview.ca.us + S: 250-innosoft.com + S: 250 PIPELINING + C: MAIL FROM: + C: RCPT TO: + C: RCPT TO: + C: DATA + S: 250 sender OK + S: 550 remote mail to not allowed + S: 550 remote mail to not allowed + S: 554 no valid recipients given + C: QUIT + S: 221 goodbye + + The client SMTP waits for the server 4 times here as well. If the + server SMTP does not check for at least one valid recipient prior to + accepting the DATA command, the following dialogue would result: + + S: + C: + S: 220 innosoft.com SMTP service ready + C: EHLO dbc.mtview.ca.us + S: 250-innosoft.com + S: 250 PIPELINING + C: MAIL FROM: + C: RCPT TO: + C: RCPT TO: + C: DATA + S: 250 sender OK + S: 550 remote mail to not allowed + S: 550 remote mail to not allowed + S: 354 enter mail, end with line containing only "." + C: . + + + +Freed & Cargille Standards Track [Page 6] + +RFC 1854 SMTP Pipelining October 1995 + + + C: QUIT + S: 554 no valid recipients + S: 221 goodbye + +4. Security Considerations + + This RFC does not discuss security issues and is not believed to + raise any security issues not endemic in electronic mail and present + in fully conforming implementations of [1]. + +5. Acknowledgements + + This document is based on the SMTP service extension model presented + in RFC 1425. Marshall Rose's description of SMTP command pipelining + in his book "The Internet Message" also served as a source of + inspiration for this extension. + +6. References + + [1] Postel, J., "Simple Mail Transfer Protocol", STD 10 + RFC 821, USC/Information Sciences Institute, August + 1982. + + [2] Klensin, J., Freed, N., Rose, M., Stefferud, E., + and D. Crocker, "SMTP Service Extensions", RFC 1651, + MCI, Innosoft, Dover Beach Consulting, Inc., + Network Management Associates, Inc., Silicon Graphics, + Inc., July 1994. + +7. Author's Address + + Ned Freed + Innosoft International, Inc. + 1050 East Garvey Avenue South + West Covina, CA 91790 + USA + + Phone: +1 818 919 3600 + Fax: +1 818 919 3614 + EMail: ned@innosoft.com + + + + + + + + + + + +Freed & Cargille Standards Track [Page 7] + diff --git a/vendor/swiftmailer/swiftmailer/notes/rfc/rfc2015.txt b/vendor/swiftmailer/swiftmailer/notes/rfc/rfc2015.txt new file mode 100755 index 0000000..d075983 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/notes/rfc/rfc2015.txt @@ -0,0 +1,450 @@ + + + + + +Network Working Group M. Elkins +Request for Comments: 2015 The Aerospace Corporation +Category: Standards Track October 1996 + + + MIME Security with Pretty Good Privacy (PGP) + +Status of this Memo + + This document specifies an Internet standards track protocol for the + Internet community, and requests discussion and suggestions for + improvements. Please refer to the current edition of the "Internet + Official Protocol Standards" (STD 1) for the standardization state + and status of this protocol. Distribution of this memo is unlimited. + +Abstract + + This document describes how Pretty Good Privacy (PGP) can be used to + provide privacy and authentication using the Multipurpose Internet + Mail Extensions (MIME) security content types described in RFC1847. + +1. Introduction + + Previous work on integrating PGP with MIME (including the since + withdrawn application/pgp content type) has suffered from a number of + problems, the most significant of which is the inability to recover + signed message bodies without parsing data structures specific to + PGP. This work makes use of the elegant solution proposed in + RFC1847, which defines security multipart formats for MIME. The + security multiparts clearly separate the signed message body from the + signature, and have a number of other desirable properties. This + document is styled after RFC 1848, which defines MIME Object Security + Services (MOSS) for providing security and authentication. + + This document defines three new content types for implementing + security and privacy with PGP: application/pgp-encrypted, + application/pgp-signature and application/pgp-keys. + +1.1 Compliance + + In order for an implementation to be compliant with this + specification, is it absolutely necessary for it to obey all items + labeled as MUST or REQUIRED. + + + + + + + + +Elkins Standards Track [Page 1] + +RFC 2015 MIME Security with PGP October 1996 + + +2. PGP data formats + + PGP can generate either ASCII armor (described in [3]) or 8-bit + binary output when encrypting data, generating a digital signature, + or extracting public key data. The ASCII armor output is the + REQUIRED method for data transfer. This allows those users who do + not have the means to interpret the formats described in this + document to be able extract and use the PGP information in the + message. + + When the amount of data to be transmitted requires that it be sent in + many parts, the MIME message/partial mechanism should be used rather + than the multipart ASCII armor PGP format. + +3. Content-Transfer-Encoding restrictions + + Multipart/signed and multipart/encrypted are to be treated by agents + as opaque, meaning that the data is not to be altered in any way [1]. + However, many existing mail gateways will detect if the next hop does + not support MIME or 8-bit data and perform conversion to either + Quoted-Printable or Base64. This presents serious problems for + multipart/signed, in particular, where the signature is invalidated + when such an operation occurs. For this reason all data signed + according to this protocol MUST be constrained to 7 bits (8- bit data + should be encoded using either Quoted-Printable or Base64). Note + that this also includes the case where a signed object is also + encrypted (see section 6). This restriction will increase the + likelihood that the signature will be valid upon receipt. + + Data that is ONLY to be encrypted is allowed to contain 8-bit + characters and therefore need not be converted to a 7-bit format. + + Implementor's note: It cannot be stressed enough that applications + using this standard should follow MIME's suggestion that you "be + conservative in what you generate, and liberal in what you accept." + In this particular case it means it would be wise for an + implementation to accept messages with any content-transfer- + encoding, but restrict generation to the 7-bit format required by + this memo. This will allow future compatibility in the event the + Internet SMTP framework becomes 8-bit friendly. + +4. PGP encrypted data + + Before encryption with PGP, the data should be written in MIME + canonical format (body and headers). + + PGP encrypted data is denoted by the "multipart/encrypted" content + type, described in [1], and MUST have a "protocol" parameter value of + + + +Elkins Standards Track [Page 2] + +RFC 2015 MIME Security with PGP October 1996 + + + "application/pgp-encrypted". Note that the value of the parameter + MUST be enclosed in quotes. + + The multipart/encrypted MUST consist of exactly two parts. The first + MIME body part must have a content type of "application/pgp- + encrypted". This body contains the control information. A message + complying with this standard MUST contain a "Version: 1" field in + this body. Since the PGP packet format contains all other + information necessary for decrypting, no other information is + required here. + + The second MIME body part MUST contain the actual encrypted data. It + must be labeled with a content type of "application/octet- stream". + + Example message: + + From: Michael Elkins + To: Michael Elkins + Mime-Version: 1.0 + Content-Type: multipart/encrypted; boundary=foo; + protocol="application/pgp-encrypted" + + --foo + Content-Type: application/pgp-encrypted + + Version: 1 + + --foo + Content-Type: application/octet-stream + + -----BEGIN PGP MESSAGE----- + Version: 2.6.2 + + hIwDY32hYGCE8MkBA/wOu7d45aUxF4Q0RKJprD3v5Z9K1YcRJ2fve87lMlDlx4Oj + eW4GDdBfLbJE7VUpp13N19GL8e/AqbyyjHH4aS0YoTk10QQ9nnRvjY8nZL3MPXSZ + g9VGQxFeGqzykzmykU6A26MSMexR4ApeeON6xzZWfo+0yOqAq6lb46wsvldZ96YA + AABH78hyX7YX4uT1tNCWEIIBoqqvCeIMpp7UQ2IzBrXg6GtukS8NxbukLeamqVW3 + 1yt21DYOjuLzcMNe/JNsD9vDVCvOOG3OCi8= + =zzaA + -----END PGP MESSAGE----- + + --foo-- + +5. PGP signed data + + PGP signed messages are denoted by the "multipart/signed" content + type, described in [1], with a "protocol" parameter which MUST have a + value of "application/pgp-signature" (MUST be quoted). The "micalg" + + + +Elkins Standards Track [Page 3] + +RFC 2015 MIME Security with PGP October 1996 + + + parameter MUST have a value of "pgp-", where identifies the message integrity check (MIC) used to generate + the signature. The currently defined values for are + "md5" for the MD5 checksum, and "sha1" for the SHA.1 algorithm. + + The multipart/signed body MUST consist of exactly two parts. The + first part contains the signed data in MIME canonical format, + including a set of appropriate content headers describing the data. + + The second body MUST contain the PGP digital signature. It MUST be + labeled with a content type of "application/pgp-signature". + + When the PGP digital signature is generated: + + (1) The data to be signed must first be converted to its + type/subtype specific canonical form. For text/plain, this + means conversion to an appropriate character set and conversion + of line endings to the canonical sequence. + + (2) An appropriate Content-Transfer-Encoding is then applied. Each + line of the encoded data MUST end with the canonical + sequence. + + (3) MIME content headers are then added to the body, each ending + with the canonical sequence. + + (4) As described in [1], the digital signature MUST be calculated + over both the data to be signed and its set of content headers. + + (5) The signature MUST be generated detached from the signed data + so that the process does not alter the signed data in any way. + + Example message: + + From: Michael Elkins + To: Michael Elkins + Mime-Version: 1.0 + Content-Type: multipart/signed; boundary=bar; micalg=pgp-md5; + protocol="application/pgp-signature" + + --bar + & Content-Type: text/plain; charset=iso-8859-1 + & Content-Transfer-Encoding: quoted-printable + & + & =A1Hola! + & + & Did you know that talking to yourself is a sign of senility? + & + + + +Elkins Standards Track [Page 4] + +RFC 2015 MIME Security with PGP October 1996 + + + & It's generally a good idea to encode lines that begin with + & From=20because some mail transport agents will insert a greater- + & than (>) sign, thus invalidating the signature. + & + & Also, in some cases it might be desirable to encode any =20 + &railing whitespace that occurs on lines in order to ensure =20 + & that the message signature is not invalidated when passing =20 + & a gateway that modifies such whitespace (like BITNET). =20 + & + & me + + --bar + Content-Type: application/pgp-signature + + -----BEGIN PGP MESSAGE----- + Version: 2.6.2 + + iQCVAwUBMJrRF2N9oWBghPDJAQE9UQQAtl7LuRVndBjrk4EqYBIb3h5QXIX/LC// + jJV5bNvkZIGPIcEmI5iFd9boEgvpirHtIREEqLQRkYNoBActFBZmh9GC3C041WGq + uMbrbxc+nIs1TIKlA08rVi9ig/2Yh7LFrK5Ein57U/W72vgSxLhe/zhdfolT9Brn + HOxEa44b+EI= + =ndaj + -----END PGP MESSAGE----- + + --bar-- + + The "&"s in the previous example indicate the portion of the data + over which the signature was calculated. + + Though not required, it is generally a good idea to use Quoted- + Printable encoding in the first step (writing out the data to be + signed in MIME canonical format) if any of the lines in the data + begin with "From ", and encode the "F". This will avoid an MTA + inserting a ">" in front of the line, thus invalidating the + signature! + + Upon receipt of a signed message, an application MUST: + + (1) Convert line endings to the canonical sequence before + the signature can be verified. This is necessary since the + local MTA may have converted to a local end of line convention. + + (2) Pass both the signed data and its associated content headers + along with the PGP signature to the signature verification + service. + + + + + + +Elkins Standards Track [Page 5] + +RFC 2015 MIME Security with PGP October 1996 + + +6. Encrypted and Signed Data + + Sometimes it is desirable to both digitally sign and then encrypt a + message to be sent. This protocol allows for two methods of + accomplishing this task. + +6.1 RFC1847 Encapsulation + + [1], it is stated that the data should first be signed as a + multipart/signature body, and then encrypted to form the final + multipart/encrypted body, i.e., + + Content-Type: multipart/encrypted; + protocol="application/pgp-encrypted"; boundary=foo + + --foo + Content-Type: application/pgp-encrypted + + Version: 1 + + --foo + Content-Type: application/octet-stream + + -----BEGIN PGP MESSAGE----- + & Content-Type: multipart/signed; micalg=pgp-md5 + & protocol="application/pgp-signature"; boundary=bar + & + & --bar + & Content-Type: text/plain; charset=us-ascii + & + & This message was first signed, and then encrypted. + & + & --bar + & Content-Type: application/pgp-signature + & + & -----BEGIN PGP MESSAGE----- + & Version: 2.6.2 + & + & iQCVAwUBMJrRF2N9oWBghPDJAQE9UQQAtl7LuRVndBjrk4EqYBIb3h5QXIX/LC// + & jJV5bNvkZIGPIcEmI5iFd9boEgvpirHtIREEqLQRkYNoBActFBZmh9GC3C041WGq + & uMbrbxc+nIs1TIKlA08rVi9ig/2Yh7LFrK5Ein57U/W72vgSxLhe/zhdfolT9Brn + & HOxEa44b+EI= + & =ndaj + & -----END PGP MESSAGE----- + & + & --bar-- + -----END PGP MESSAGE----- + + + + +Elkins Standards Track [Page 6] + +RFC 2015 MIME Security with PGP October 1996 + + + --foo-- + + (The text preceded by '&' indicates that it is really + encrypted, but presented as text for clarity.) + +6.2 Combined method + + Versions 2.x of PGP also allow data to be signed and encrypted in one + operation. This method is an acceptable shortcut, and has the + benefit of less overhead. The resulting data should be formed as a + "multipart/encrypted" object as described above. + + Messages which are encrypted and signed in this combined fashion are + REQUIRED to follow the same canonicalization rules as for + multipart/signed objects. + + It is explicitly allowed for an agent to decrypt a combined message + and rewrite it as a multipart/signed object using the signature data + embedded in the encrypted version. + +7. Distribution of PGP public keys + + Content-Type: application/pgp-keys + Required parameters: none + Optional parameters: none + + This is the content type which should be used for relaying public key + blocks. + +8. Notes + + PGP and Pretty Good Privacy are trademarks of Philip Zimmermann. + +9. Security Considerations + + Use of this protocol has the same security considerations as PGP, and + is not known to either increase or decrease the security of messages + using it; see [3] for more information. + +10. Author's Address + + Michael Elkins + P.O. Box 92957 - M1/102 + Los Angeles, CA 90009-2957 + + Phone: +1 310 336 8040 + Fax: +1 310 336 4402 + + + + +Elkins Standards Track [Page 7] + +RFC 2015 MIME Security with PGP October 1996 + + +References + + [1] Galvin, J., Murphy, G., Crocker, S., and N. Freed, "Security + Multiparts for MIME: Multipart/Signed and Multipart/Encrypted", + RFC 1847, October 1995. + + [2] Galvin, J., Murphy, G., Crocker, S., and N. Freed, "MIME Object + Security Services", RFC 1848, October 1995. + + [3] Atkins, D., Stallings, W., and P. Zimmermann, "PGP Message + Exchange Formats", RFC 1991, August 1996. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Elkins Standards Track [Page 8] + diff --git a/vendor/swiftmailer/swiftmailer/notes/rfc/rfc2045.txt b/vendor/swiftmailer/swiftmailer/notes/rfc/rfc2045.txt new file mode 100755 index 0000000..9f286b1 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/notes/rfc/rfc2045.txt @@ -0,0 +1,1739 @@ + + + + + + +Network Working Group N. Freed +Request for Comments: 2045 Innosoft +Obsoletes: 1521, 1522, 1590 N. Borenstein +Category: Standards Track First Virtual + November 1996 + + + Multipurpose Internet Mail Extensions + (MIME) Part One: + Format of Internet Message Bodies + +Status of this Memo + + This document specifies an Internet standards track protocol for the + Internet community, and requests discussion and suggestions for + improvements. Please refer to the current edition of the "Internet + Official Protocol Standards" (STD 1) for the standardization state + and status of this protocol. Distribution of this memo is unlimited. + +Abstract + + STD 11, RFC 822, defines a message representation protocol specifying + considerable detail about US-ASCII message headers, and leaves the + message content, or message body, as flat US-ASCII text. This set of + documents, collectively called the Multipurpose Internet Mail + Extensions, or MIME, redefines the format of messages to allow for + + (1) textual message bodies in character sets other than + US-ASCII, + + (2) an extensible set of different formats for non-textual + message bodies, + + (3) multi-part message bodies, and + + (4) textual header information in character sets other than + US-ASCII. + + These documents are based on earlier work documented in RFC 934, STD + 11, and RFC 1049, but extends and revises them. Because RFC 822 said + so little about message bodies, these documents are largely + orthogonal to (rather than a revision of) RFC 822. + + This initial document specifies the various headers used to describe + the structure of MIME messages. The second document, RFC 2046, + defines the general structure of the MIME media typing system and + defines an initial set of media types. The third document, RFC 2047, + describes extensions to RFC 822 to allow non-US-ASCII text data in + + + +Freed & Borenstein Standards Track [Page 1] + +RFC 2045 Internet Message Bodies November 1996 + + + Internet mail header fields. The fourth document, RFC 2048, specifies + various IANA registration procedures for MIME-related facilities. The + fifth and final document, RFC 2049, describes MIME conformance + criteria as well as providing some illustrative examples of MIME + message formats, acknowledgements, and the bibliography. + + These documents are revisions of RFCs 1521, 1522, and 1590, which + themselves were revisions of RFCs 1341 and 1342. An appendix in RFC + 2049 describes differences and changes from previous versions. + +Table of Contents + + 1. Introduction ......................................... 3 + 2. Definitions, Conventions, and Generic BNF Grammar .... 5 + 2.1 CRLF ................................................ 5 + 2.2 Character Set ....................................... 6 + 2.3 Message ............................................. 6 + 2.4 Entity .............................................. 6 + 2.5 Body Part ........................................... 7 + 2.6 Body ................................................ 7 + 2.7 7bit Data ........................................... 7 + 2.8 8bit Data ........................................... 7 + 2.9 Binary Data ......................................... 7 + 2.10 Lines .............................................. 7 + 3. MIME Header Fields ................................... 8 + 4. MIME-Version Header Field ............................ 8 + 5. Content-Type Header Field ............................ 10 + 5.1 Syntax of the Content-Type Header Field ............. 12 + 5.2 Content-Type Defaults ............................... 14 + 6. Content-Transfer-Encoding Header Field ............... 14 + 6.1 Content-Transfer-Encoding Syntax .................... 14 + 6.2 Content-Transfer-Encodings Semantics ................ 15 + 6.3 New Content-Transfer-Encodings ...................... 16 + 6.4 Interpretation and Use .............................. 16 + 6.5 Translating Encodings ............................... 18 + 6.6 Canonical Encoding Model ............................ 19 + 6.7 Quoted-Printable Content-Transfer-Encoding .......... 19 + 6.8 Base64 Content-Transfer-Encoding .................... 24 + 7. Content-ID Header Field .............................. 26 + 8. Content-Description Header Field ..................... 27 + 9. Additional MIME Header Fields ........................ 27 + 10. Summary ............................................. 27 + 11. Security Considerations ............................. 27 + 12. Authors' Addresses .................................. 28 + A. Collected Grammar .................................... 29 + + + + + + +Freed & Borenstein Standards Track [Page 2] + +RFC 2045 Internet Message Bodies November 1996 + + +1. Introduction + + Since its publication in 1982, RFC 822 has defined the standard + format of textual mail messages on the Internet. Its success has + been such that the RFC 822 format has been adopted, wholly or + partially, well beyond the confines of the Internet and the Internet + SMTP transport defined by RFC 821. As the format has seen wider use, + a number of limitations have proven increasingly restrictive for the + user community. + + RFC 822 was intended to specify a format for text messages. As such, + non-text messages, such as multimedia messages that might include + audio or images, are simply not mentioned. Even in the case of text, + however, RFC 822 is inadequate for the needs of mail users whose + languages require the use of character sets richer than US-ASCII. + Since RFC 822 does not specify mechanisms for mail containing audio, + video, Asian language text, or even text in most European languages, + additional specifications are needed. + + One of the notable limitations of RFC 821/822 based mail systems is + the fact that they limit the contents of electronic mail messages to + relatively short lines (e.g. 1000 characters or less [RFC-821]) of + 7bit US-ASCII. This forces users to convert any non-textual data + that they may wish to send into seven-bit bytes representable as + printable US-ASCII characters before invoking a local mail UA (User + Agent, a program with which human users send and receive mail). + Examples of such encodings currently used in the Internet include + pure hexadecimal, uuencode, the 3-in-4 base 64 scheme specified in + RFC 1421, the Andrew Toolkit Representation [ATK], and many others. + + The limitations of RFC 822 mail become even more apparent as gateways + are designed to allow for the exchange of mail messages between RFC + 822 hosts and X.400 hosts. X.400 [X400] specifies mechanisms for the + inclusion of non-textual material within electronic mail messages. + The current standards for the mapping of X.400 messages to RFC 822 + messages specify either that X.400 non-textual material must be + converted to (not encoded in) IA5Text format, or that they must be + discarded, notifying the RFC 822 user that discarding has occurred. + This is clearly undesirable, as information that a user may wish to + receive is lost. Even though a user agent may not have the + capability of dealing with the non-textual material, the user might + have some mechanism external to the UA that can extract useful + information from the material. Moreover, it does not allow for the + fact that the message may eventually be gatewayed back into an X.400 + message handling system (i.e., the X.400 message is "tunneled" + through Internet mail), where the non-textual information would + definitely become useful again. + + + + +Freed & Borenstein Standards Track [Page 3] + +RFC 2045 Internet Message Bodies November 1996 + + + This document describes several mechanisms that combine to solve most + of these problems without introducing any serious incompatibilities + with the existing world of RFC 822 mail. In particular, it + describes: + + (1) A MIME-Version header field, which uses a version + number to declare a message to be conformant with MIME + and allows mail processing agents to distinguish + between such messages and those generated by older or + non-conformant software, which are presumed to lack + such a field. + + (2) A Content-Type header field, generalized from RFC 1049, + which can be used to specify the media type and subtype + of data in the body of a message and to fully specify + the native representation (canonical form) of such + data. + + (3) A Content-Transfer-Encoding header field, which can be + used to specify both the encoding transformation that + was applied to the body and the domain of the result. + Encoding transformations other than the identity + transformation are usually applied to data in order to + allow it to pass through mail transport mechanisms + which may have data or character set limitations. + + (4) Two additional header fields that can be used to + further describe the data in a body, the Content-ID and + Content-Description header fields. + + All of the header fields defined in this document are subject to the + general syntactic rules for header fields specified in RFC 822. In + particular, all of these header fields except for Content-Disposition + can include RFC 822 comments, which have no semantic content and + should be ignored during MIME processing. + + Finally, to specify and promote interoperability, RFC 2049 provides a + basic applicability statement for a subset of the above mechanisms + that defines a minimal level of "conformance" with this document. + + HISTORICAL NOTE: Several of the mechanisms described in this set of + documents may seem somewhat strange or even baroque at first reading. + It is important to note that compatibility with existing standards + AND robustness across existing practice were two of the highest + priorities of the working group that developed this set of documents. + In particular, compatibility was always favored over elegance. + + + + + +Freed & Borenstein Standards Track [Page 4] + +RFC 2045 Internet Message Bodies November 1996 + + + Please refer to the current edition of the "Internet Official + Protocol Standards" for the standardization state and status of this + protocol. RFC 822 and STD 3, RFC 1123 also provide essential + background for MIME since no conforming implementation of MIME can + violate them. In addition, several other informational RFC documents + will be of interest to the MIME implementor, in particular RFC 1344, + RFC 1345, and RFC 1524. + +2. Definitions, Conventions, and Generic BNF Grammar + + Although the mechanisms specified in this set of documents are all + described in prose, most are also described formally in the augmented + BNF notation of RFC 822. Implementors will need to be familiar with + this notation in order to understand this set of documents, and are + referred to RFC 822 for a complete explanation of the augmented BNF + notation. + + Some of the augmented BNF in this set of documents makes named + references to syntax rules defined in RFC 822. A complete formal + grammar, then, is obtained by combining the collected grammar + appendices in each document in this set with the BNF of RFC 822 plus + the modifications to RFC 822 defined in RFC 1123 (which specifically + changes the syntax for `return', `date' and `mailbox'). + + All numeric and octet values are given in decimal notation in this + set of documents. All media type values, subtype values, and + parameter names as defined are case-insensitive. However, parameter + values are case-sensitive unless otherwise specified for the specific + parameter. + + FORMATTING NOTE: Notes, such at this one, provide additional + nonessential information which may be skipped by the reader without + missing anything essential. The primary purpose of these non- + essential notes is to convey information about the rationale of this + set of documents, or to place these documents in the proper + historical or evolutionary context. Such information may in + particular be skipped by those who are focused entirely on building a + conformant implementation, but may be of use to those who wish to + understand why certain design choices were made. + +2.1. CRLF + + The term CRLF, in this set of documents, refers to the sequence of + octets corresponding to the two US-ASCII characters CR (decimal value + 13) and LF (decimal value 10) which, taken together, in this order, + denote a line break in RFC 822 mail. + + + + + +Freed & Borenstein Standards Track [Page 5] + +RFC 2045 Internet Message Bodies November 1996 + + +2.2. Character Set + + The term "character set" is used in MIME to refer to a method of + converting a sequence of octets into a sequence of characters. Note + that unconditional and unambiguous conversion in the other direction + is not required, in that not all characters may be representable by a + given character set and a character set may provide more than one + sequence of octets to represent a particular sequence of characters. + + This definition is intended to allow various kinds of character + encodings, from simple single-table mappings such as US-ASCII to + complex table switching methods such as those that use ISO 2022's + techniques, to be used as character sets. However, the definition + associated with a MIME character set name must fully specify the + mapping to be performed. In particular, use of external profiling + information to determine the exact mapping is not permitted. + + NOTE: The term "character set" was originally to describe such + straightforward schemes as US-ASCII and ISO-8859-1 which have a + simple one-to-one mapping from single octets to single characters. + Multi-octet coded character sets and switching techniques make the + situation more complex. For example, some communities use the term + "character encoding" for what MIME calls a "character set", while + using the phrase "coded character set" to denote an abstract mapping + from integers (not octets) to characters. + +2.3. Message + + The term "message", when not further qualified, means either a + (complete or "top-level") RFC 822 message being transferred on a + network, or a message encapsulated in a body of type "message/rfc822" + or "message/partial". + +2.4. Entity + + The term "entity", refers specifically to the MIME-defined header + fields and contents of either a message or one of the parts in the + body of a multipart entity. The specification of such entities is + the essence of MIME. Since the contents of an entity are often + called the "body", it makes sense to speak about the body of an + entity. Any sort of field may be present in the header of an entity, + but only those fields whose names begin with "content-" actually have + any MIME-related meaning. Note that this does NOT imply thay they + have no meaning at all -- an entity that is also a message has non- + MIME header fields whose meanings are defined by RFC 822. + + + + + + +Freed & Borenstein Standards Track [Page 6] + +RFC 2045 Internet Message Bodies November 1996 + + +2.5. Body Part + + The term "body part" refers to an entity inside of a multipart + entity. + +2.6. Body + + The term "body", when not further qualified, means the body of an + entity, that is, the body of either a message or of a body part. + + NOTE: The previous four definitions are clearly circular. This is + unavoidable, since the overall structure of a MIME message is indeed + recursive. + +2.7. 7bit Data + + "7bit data" refers to data that is all represented as relatively + short lines with 998 octets or less between CRLF line separation + sequences [RFC-821]. No octets with decimal values greater than 127 + are allowed and neither are NULs (octets with decimal value 0). CR + (decimal value 13) and LF (decimal value 10) octets only occur as + part of CRLF line separation sequences. + +2.8. 8bit Data + + "8bit data" refers to data that is all represented as relatively + short lines with 998 octets or less between CRLF line separation + sequences [RFC-821]), but octets with decimal values greater than 127 + may be used. As with "7bit data" CR and LF octets only occur as part + of CRLF line separation sequences and no NULs are allowed. + +2.9. Binary Data + + "Binary data" refers to data where any sequence of octets whatsoever + is allowed. + +2.10. Lines + + "Lines" are defined as sequences of octets separated by a CRLF + sequences. This is consistent with both RFC 821 and RFC 822. + "Lines" only refers to a unit of data in a message, which may or may + not correspond to something that is actually displayed by a user + agent. + + + + + + + + +Freed & Borenstein Standards Track [Page 7] + +RFC 2045 Internet Message Bodies November 1996 + + +3. MIME Header Fields + + MIME defines a number of new RFC 822 header fields that are used to + describe the content of a MIME entity. These header fields occur in + at least two contexts: + + (1) As part of a regular RFC 822 message header. + + (2) In a MIME body part header within a multipart + construct. + + The formal definition of these header fields is as follows: + + entity-headers := [ content CRLF ] + [ encoding CRLF ] + [ id CRLF ] + [ description CRLF ] + *( MIME-extension-field CRLF ) + + MIME-message-headers := entity-headers + fields + version CRLF + ; The ordering of the header + ; fields implied by this BNF + ; definition should be ignored. + + MIME-part-headers := entity-headers + [ fields ] + ; Any field not beginning with + ; "content-" can have no defined + ; meaning and may be ignored. + ; The ordering of the header + ; fields implied by this BNF + ; definition should be ignored. + + The syntax of the various specific MIME header fields will be + described in the following sections. + +4. MIME-Version Header Field + + Since RFC 822 was published in 1982, there has really been only one + format standard for Internet messages, and there has been little + perceived need to declare the format standard in use. This document + is an independent specification that complements RFC 822. Although + the extensions in this document have been defined in such a way as to + be compatible with RFC 822, there are still circumstances in which it + might be desirable for a mail-processing agent to know whether a + message was composed with the new standard in mind. + + + +Freed & Borenstein Standards Track [Page 8] + +RFC 2045 Internet Message Bodies November 1996 + + + Therefore, this document defines a new header field, "MIME-Version", + which is to be used to declare the version of the Internet message + body format standard in use. + + Messages composed in accordance with this document MUST include such + a header field, with the following verbatim text: + + MIME-Version: 1.0 + + The presence of this header field is an assertion that the message + has been composed in compliance with this document. + + Since it is possible that a future document might extend the message + format standard again, a formal BNF is given for the content of the + MIME-Version field: + + version := "MIME-Version" ":" 1*DIGIT "." 1*DIGIT + + Thus, future format specifiers, which might replace or extend "1.0", + are constrained to be two integer fields, separated by a period. If + a message is received with a MIME-version value other than "1.0", it + cannot be assumed to conform with this document. + + Note that the MIME-Version header field is required at the top level + of a message. It is not required for each body part of a multipart + entity. It is required for the embedded headers of a body of type + "message/rfc822" or "message/partial" if and only if the embedded + message is itself claimed to be MIME-conformant. + + It is not possible to fully specify how a mail reader that conforms + with MIME as defined in this document should treat a message that + might arrive in the future with some value of MIME-Version other than + "1.0". + + It is also worth noting that version control for specific media types + is not accomplished using the MIME-Version mechanism. In particular, + some formats (such as application/postscript) have version numbering + conventions that are internal to the media format. Where such + conventions exist, MIME does nothing to supersede them. Where no + such conventions exist, a MIME media type might use a "version" + parameter in the content-type field if necessary. + + + + + + + + + + +Freed & Borenstein Standards Track [Page 9] + +RFC 2045 Internet Message Bodies November 1996 + + + NOTE TO IMPLEMENTORS: When checking MIME-Version values any RFC 822 + comment strings that are present must be ignored. In particular, the + following four MIME-Version fields are equivalent: + + MIME-Version: 1.0 + + MIME-Version: 1.0 (produced by MetaSend Vx.x) + + MIME-Version: (produced by MetaSend Vx.x) 1.0 + + MIME-Version: 1.(produced by MetaSend Vx.x)0 + + In the absence of a MIME-Version field, a receiving mail user agent + (whether conforming to MIME requirements or not) may optionally + choose to interpret the body of the message according to local + conventions. Many such conventions are currently in use and it + should be noted that in practice non-MIME messages can contain just + about anything. + + It is impossible to be certain that a non-MIME mail message is + actually plain text in the US-ASCII character set since it might well + be a message that, using some set of nonstandard local conventions + that predate MIME, includes text in another character set or non- + textual data presented in a manner that cannot be automatically + recognized (e.g., a uuencoded compressed UNIX tar file). + +5. Content-Type Header Field + + The purpose of the Content-Type field is to describe the data + contained in the body fully enough that the receiving user agent can + pick an appropriate agent or mechanism to present the data to the + user, or otherwise deal with the data in an appropriate manner. The + value in this field is called a media type. + + HISTORICAL NOTE: The Content-Type header field was first defined in + RFC 1049. RFC 1049 used a simpler and less powerful syntax, but one + that is largely compatible with the mechanism given here. + + The Content-Type header field specifies the nature of the data in the + body of an entity by giving media type and subtype identifiers, and + by providing auxiliary information that may be required for certain + media types. After the media type and subtype names, the remainder + of the header field is simply a set of parameters, specified in an + attribute=value notation. The ordering of parameters is not + significant. + + + + + + +Freed & Borenstein Standards Track [Page 10] + +RFC 2045 Internet Message Bodies November 1996 + + + In general, the top-level media type is used to declare the general + type of data, while the subtype specifies a specific format for that + type of data. Thus, a media type of "image/xyz" is enough to tell a + user agent that the data is an image, even if the user agent has no + knowledge of the specific image format "xyz". Such information can + be used, for example, to decide whether or not to show a user the raw + data from an unrecognized subtype -- such an action might be + reasonable for unrecognized subtypes of text, but not for + unrecognized subtypes of image or audio. For this reason, registered + subtypes of text, image, audio, and video should not contain embedded + information that is really of a different type. Such compound + formats should be represented using the "multipart" or "application" + types. + + Parameters are modifiers of the media subtype, and as such do not + fundamentally affect the nature of the content. The set of + meaningful parameters depends on the media type and subtype. Most + parameters are associated with a single specific subtype. However, a + given top-level media type may define parameters which are applicable + to any subtype of that type. Parameters may be required by their + defining content type or subtype or they may be optional. MIME + implementations must ignore any parameters whose names they do not + recognize. + + For example, the "charset" parameter is applicable to any subtype of + "text", while the "boundary" parameter is required for any subtype of + the "multipart" media type. + + There are NO globally-meaningful parameters that apply to all media + types. Truly global mechanisms are best addressed, in the MIME + model, by the definition of additional Content-* header fields. + + An initial set of seven top-level media types is defined in RFC 2046. + Five of these are discrete types whose content is essentially opaque + as far as MIME processing is concerned. The remaining two are + composite types whose contents require additional handling by MIME + processors. + + This set of top-level media types is intended to be substantially + complete. It is expected that additions to the larger set of + supported types can generally be accomplished by the creation of new + subtypes of these initial types. In the future, more top-level types + may be defined only by a standards-track extension to this standard. + If another top-level type is to be used for any reason, it must be + given a name starting with "X-" to indicate its non-standard status + and to avoid a potential conflict with a future official name. + + + + + +Freed & Borenstein Standards Track [Page 11] + +RFC 2045 Internet Message Bodies November 1996 + + +5.1. Syntax of the Content-Type Header Field + + In the Augmented BNF notation of RFC 822, a Content-Type header field + value is defined as follows: + + content := "Content-Type" ":" type "/" subtype + *(";" parameter) + ; Matching of media type and subtype + ; is ALWAYS case-insensitive. + + type := discrete-type / composite-type + + discrete-type := "text" / "image" / "audio" / "video" / + "application" / extension-token + + composite-type := "message" / "multipart" / extension-token + + extension-token := ietf-token / x-token + + ietf-token := + + x-token := + + subtype := extension-token / iana-token + + iana-token := + + parameter := attribute "=" value + + attribute := token + ; Matching of attributes + ; is ALWAYS case-insensitive. + + value := token / quoted-string + + token := 1* + + tspecials := "(" / ")" / "<" / ">" / "@" / + "," / ";" / ":" / "\" / <"> + "/" / "[" / "]" / "?" / "=" + ; Must be in quoted-string, + ; to use within parameter values + + + +Freed & Borenstein Standards Track [Page 12] + +RFC 2045 Internet Message Bodies November 1996 + + + Note that the definition of "tspecials" is the same as the RFC 822 + definition of "specials" with the addition of the three characters + "/", "?", and "=", and the removal of ".". + + Note also that a subtype specification is MANDATORY -- it may not be + omitted from a Content-Type header field. As such, there are no + default subtypes. + + The type, subtype, and parameter names are not case sensitive. For + example, TEXT, Text, and TeXt are all equivalent top-level media + types. Parameter values are normally case sensitive, but sometimes + are interpreted in a case-insensitive fashion, depending on the + intended use. (For example, multipart boundaries are case-sensitive, + but the "access-type" parameter for message/External-body is not + case-sensitive.) + + Note that the value of a quoted string parameter does not include the + quotes. That is, the quotation marks in a quoted-string are not a + part of the value of the parameter, but are merely used to delimit + that parameter value. In addition, comments are allowed in + accordance with RFC 822 rules for structured header fields. Thus the + following two forms + + Content-type: text/plain; charset=us-ascii (Plain text) + + Content-type: text/plain; charset="us-ascii" + + are completely equivalent. + + Beyond this syntax, the only syntactic constraint on the definition + of subtype names is the desire that their uses must not conflict. + That is, it would be undesirable to have two different communities + using "Content-Type: application/foobar" to mean two different + things. The process of defining new media subtypes, then, is not + intended to be a mechanism for imposing restrictions, but simply a + mechanism for publicizing their definition and usage. There are, + therefore, two acceptable mechanisms for defining new media subtypes: + + (1) Private values (starting with "X-") may be defined + bilaterally between two cooperating agents without + outside registration or standardization. Such values + cannot be registered or standardized. + + (2) New standard values should be registered with IANA as + described in RFC 2048. + + The second document in this set, RFC 2046, defines the initial set of + media types for MIME. + + + +Freed & Borenstein Standards Track [Page 13] + +RFC 2045 Internet Message Bodies November 1996 + + +5.2. Content-Type Defaults + + Default RFC 822 messages without a MIME Content-Type header are taken + by this protocol to be plain text in the US-ASCII character set, + which can be explicitly specified as: + + Content-type: text/plain; charset=us-ascii + + This default is assumed if no Content-Type header field is specified. + It is also recommend that this default be assumed when a + syntactically invalid Content-Type header field is encountered. In + the presence of a MIME-Version header field and the absence of any + Content-Type header field, a receiving User Agent can also assume + that plain US-ASCII text was the sender's intent. Plain US-ASCII + text may still be assumed in the absence of a MIME-Version or the + presence of an syntactically invalid Content-Type header field, but + the sender's intent might have been otherwise. + +6. Content-Transfer-Encoding Header Field + + Many media types which could be usefully transported via email are + represented, in their "natural" format, as 8bit character or binary + data. Such data cannot be transmitted over some transfer protocols. + For example, RFC 821 (SMTP) restricts mail messages to 7bit US-ASCII + data with lines no longer than 1000 characters including any trailing + CRLF line separator. + + It is necessary, therefore, to define a standard mechanism for + encoding such data into a 7bit short line format. Proper labelling + of unencoded material in less restrictive formats for direct use over + less restrictive transports is also desireable. This document + specifies that such encodings will be indicated by a new "Content- + Transfer-Encoding" header field. This field has not been defined by + any previous standard. + +6.1. Content-Transfer-Encoding Syntax + + The Content-Transfer-Encoding field's value is a single token + specifying the type of encoding, as enumerated below. Formally: + + encoding := "Content-Transfer-Encoding" ":" mechanism + + mechanism := "7bit" / "8bit" / "binary" / + "quoted-printable" / "base64" / + ietf-token / x-token + + These values are not case sensitive -- Base64 and BASE64 and bAsE64 + are all equivalent. An encoding type of 7BIT requires that the body + + + +Freed & Borenstein Standards Track [Page 14] + +RFC 2045 Internet Message Bodies November 1996 + + + is already in a 7bit mail-ready representation. This is the default + value -- that is, "Content-Transfer-Encoding: 7BIT" is assumed if the + Content-Transfer-Encoding header field is not present. + +6.2. Content-Transfer-Encodings Semantics + + This single Content-Transfer-Encoding token actually provides two + pieces of information. It specifies what sort of encoding + transformation the body was subjected to and hence what decoding + operation must be used to restore it to its original form, and it + specifies what the domain of the result is. + + The transformation part of any Content-Transfer-Encodings specifies, + either explicitly or implicitly, a single, well-defined decoding + algorithm, which for any sequence of encoded octets either transforms + it to the original sequence of octets which was encoded, or shows + that it is illegal as an encoded sequence. Content-Transfer- + Encodings transformations never depend on any additional external + profile information for proper operation. Note that while decoders + must produce a single, well-defined output for a valid encoding no + such restrictions exist for encoders: Encoding a given sequence of + octets to different, equivalent encoded sequences is perfectly legal. + + Three transformations are currently defined: identity, the "quoted- + printable" encoding, and the "base64" encoding. The domains are + "binary", "8bit" and "7bit". + + The Content-Transfer-Encoding values "7bit", "8bit", and "binary" all + mean that the identity (i.e. NO) encoding transformation has been + performed. As such, they serve simply as indicators of the domain of + the body data, and provide useful information about the sort of + encoding that might be needed for transmission in a given transport + system. The terms "7bit data", "8bit data", and "binary data" are + all defined in Section 2. + + The quoted-printable and base64 encodings transform their input from + an arbitrary domain into material in the "7bit" range, thus making it + safe to carry over restricted transports. The specific definition of + the transformations are given below. + + The proper Content-Transfer-Encoding label must always be used. + Labelling unencoded data containing 8bit characters as "7bit" is not + allowed, nor is labelling unencoded non-line-oriented data as + anything other than "binary" allowed. + + Unlike media subtypes, a proliferation of Content-Transfer-Encoding + values is both undesirable and unnecessary. However, establishing + only a single transformation into the "7bit" domain does not seem + + + +Freed & Borenstein Standards Track [Page 15] + +RFC 2045 Internet Message Bodies November 1996 + + + possible. There is a tradeoff between the desire for a compact and + efficient encoding of largely- binary data and the desire for a + somewhat readable encoding of data that is mostly, but not entirely, + 7bit. For this reason, at least two encoding mechanisms are + necessary: a more or less readable encoding (quoted-printable) and a + "dense" or "uniform" encoding (base64). + + Mail transport for unencoded 8bit data is defined in RFC 1652. As of + the initial publication of this document, there are no standardized + Internet mail transports for which it is legitimate to include + unencoded binary data in mail bodies. Thus there are no + circumstances in which the "binary" Content-Transfer-Encoding is + actually valid in Internet mail. However, in the event that binary + mail transport becomes a reality in Internet mail, or when MIME is + used in conjunction with any other binary-capable mail transport + mechanism, binary bodies must be labelled as such using this + mechanism. + + NOTE: The five values defined for the Content-Transfer-Encoding field + imply nothing about the media type other than the algorithm by which + it was encoded or the transport system requirements if unencoded. + +6.3. New Content-Transfer-Encodings + + Implementors may, if necessary, define private Content-Transfer- + Encoding values, but must use an x-token, which is a name prefixed by + "X-", to indicate its non-standard status, e.g., "Content-Transfer- + Encoding: x-my-new-encoding". Additional standardized Content- + Transfer-Encoding values must be specified by a standards-track RFC. + The requirements such specifications must meet are given in RFC 2048. + As such, all content-transfer-encoding namespace except that + beginning with "X-" is explicitly reserved to the IETF for future + use. + + Unlike media types and subtypes, the creation of new Content- + Transfer-Encoding values is STRONGLY discouraged, as it seems likely + to hinder interoperability with little potential benefit + +6.4. Interpretation and Use + + If a Content-Transfer-Encoding header field appears as part of a + message header, it applies to the entire body of that message. If a + Content-Transfer-Encoding header field appears as part of an entity's + headers, it applies only to the body of that entity. If an entity is + of type "multipart" the Content-Transfer-Encoding is not permitted to + have any value other than "7bit", "8bit" or "binary". Even more + severe restrictions apply to some subtypes of the "message" type. + + + + +Freed & Borenstein Standards Track [Page 16] + +RFC 2045 Internet Message Bodies November 1996 + + + It should be noted that most media types are defined in terms of + octets rather than bits, so that the mechanisms described here are + mechanisms for encoding arbitrary octet streams, not bit streams. If + a bit stream is to be encoded via one of these mechanisms, it must + first be converted to an 8bit byte stream using the network standard + bit order ("big-endian"), in which the earlier bits in a stream + become the higher-order bits in a 8bit byte. A bit stream not ending + at an 8bit boundary must be padded with zeroes. RFC 2046 provides a + mechanism for noting the addition of such padding in the case of the + application/octet-stream media type, which has a "padding" parameter. + + The encoding mechanisms defined here explicitly encode all data in + US-ASCII. Thus, for example, suppose an entity has header fields + such as: + + Content-Type: text/plain; charset=ISO-8859-1 + Content-transfer-encoding: base64 + + This must be interpreted to mean that the body is a base64 US-ASCII + encoding of data that was originally in ISO-8859-1, and will be in + that character set again after decoding. + + Certain Content-Transfer-Encoding values may only be used on certain + media types. In particular, it is EXPRESSLY FORBIDDEN to use any + encodings other than "7bit", "8bit", or "binary" with any composite + media type, i.e. one that recursively includes other Content-Type + fields. Currently the only composite media types are "multipart" and + "message". All encodings that are desired for bodies of type + multipart or message must be done at the innermost level, by encoding + the actual body that needs to be encoded. + + It should also be noted that, by definition, if a composite entity + has a transfer-encoding value such as "7bit", but one of the enclosed + entities has a less restrictive value such as "8bit", then either the + outer "7bit" labelling is in error, because 8bit data are included, + or the inner "8bit" labelling placed an unnecessarily high demand on + the transport system because the actual included data were actually + 7bit-safe. + + NOTE ON ENCODING RESTRICTIONS: Though the prohibition against using + content-transfer-encodings on composite body data may seem overly + restrictive, it is necessary to prevent nested encodings, in which + data are passed through an encoding algorithm multiple times, and + must be decoded multiple times in order to be properly viewed. + Nested encodings add considerable complexity to user agents: Aside + from the obvious efficiency problems with such multiple encodings, + they can obscure the basic structure of a message. In particular, + they can imply that several decoding operations are necessary simply + + + +Freed & Borenstein Standards Track [Page 17] + +RFC 2045 Internet Message Bodies November 1996 + + + to find out what types of bodies a message contains. Banning nested + encodings may complicate the job of certain mail gateways, but this + seems less of a problem than the effect of nested encodings on user + agents. + + Any entity with an unrecognized Content-Transfer-Encoding must be + treated as if it has a Content-Type of "application/octet-stream", + regardless of what the Content-Type header field actually says. + + NOTE ON THE RELATIONSHIP BETWEEN CONTENT-TYPE AND CONTENT-TRANSFER- + ENCODING: It may seem that the Content-Transfer-Encoding could be + inferred from the characteristics of the media that is to be encoded, + or, at the very least, that certain Content-Transfer-Encodings could + be mandated for use with specific media types. There are several + reasons why this is not the case. First, given the varying types of + transports used for mail, some encodings may be appropriate for some + combinations of media types and transports but not for others. (For + example, in an 8bit transport, no encoding would be required for text + in certain character sets, while such encodings are clearly required + for 7bit SMTP.) + + Second, certain media types may require different types of transfer + encoding under different circumstances. For example, many PostScript + bodies might consist entirely of short lines of 7bit data and hence + require no encoding at all. Other PostScript bodies (especially + those using Level 2 PostScript's binary encoding mechanism) may only + be reasonably represented using a binary transport encoding. + Finally, since the Content-Type field is intended to be an open-ended + specification mechanism, strict specification of an association + between media types and encodings effectively couples the + specification of an application protocol with a specific lower-level + transport. This is not desirable since the developers of a media + type should not have to be aware of all the transports in use and + what their limitations are. + +6.5. Translating Encodings + + The quoted-printable and base64 encodings are designed so that + conversion between them is possible. The only issue that arises in + such a conversion is the handling of hard line breaks in quoted- + printable encoding output. When converting from quoted-printable to + base64 a hard line break in the quoted-printable form represents a + CRLF sequence in the canonical form of the data. It must therefore be + converted to a corresponding encoded CRLF in the base64 form of the + data. Similarly, a CRLF sequence in the canonical form of the data + obtained after base64 decoding must be converted to a quoted- + printable hard line break, but ONLY when converting text data. + + + + +Freed & Borenstein Standards Track [Page 18] + +RFC 2045 Internet Message Bodies November 1996 + + +6.6. Canonical Encoding Model + + There was some confusion, in the previous versions of this RFC, + regarding the model for when email data was to be converted to + canonical form and encoded, and in particular how this process would + affect the treatment of CRLFs, given that the representation of + newlines varies greatly from system to system, and the relationship + between content-transfer-encodings and character sets. A canonical + model for encoding is presented in RFC 2049 for this reason. + +6.7. Quoted-Printable Content-Transfer-Encoding + + The Quoted-Printable encoding is intended to represent data that + largely consists of octets that correspond to printable characters in + the US-ASCII character set. It encodes the data in such a way that + the resulting octets are unlikely to be modified by mail transport. + If the data being encoded are mostly US-ASCII text, the encoded form + of the data remains largely recognizable by humans. A body which is + entirely US-ASCII may also be encoded in Quoted-Printable to ensure + the integrity of the data should the message pass through a + character-translating, and/or line-wrapping gateway. + + In this encoding, octets are to be represented as determined by the + following rules: + + (1) (General 8bit representation) Any octet, except a CR or + LF that is part of a CRLF line break of the canonical + (standard) form of the data being encoded, may be + represented by an "=" followed by a two digit + hexadecimal representation of the octet's value. The + digits of the hexadecimal alphabet, for this purpose, + are "0123456789ABCDEF". Uppercase letters must be + used; lowercase letters are not allowed. Thus, for + example, the decimal value 12 (US-ASCII form feed) can + be represented by "=0C", and the decimal value 61 (US- + ASCII EQUAL SIGN) can be represented by "=3D". This + rule must be followed except when the following rules + allow an alternative encoding. + + (2) (Literal representation) Octets with decimal values of + 33 through 60 inclusive, and 62 through 126, inclusive, + MAY be represented as the US-ASCII characters which + correspond to those octets (EXCLAMATION POINT through + LESS THAN, and GREATER THAN through TILDE, + respectively). + + (3) (White Space) Octets with values of 9 and 32 MAY be + represented as US-ASCII TAB (HT) and SPACE characters, + + + +Freed & Borenstein Standards Track [Page 19] + +RFC 2045 Internet Message Bodies November 1996 + + + respectively, but MUST NOT be so represented at the end + of an encoded line. Any TAB (HT) or SPACE characters + on an encoded line MUST thus be followed on that line + by a printable character. In particular, an "=" at the + end of an encoded line, indicating a soft line break + (see rule #5) may follow one or more TAB (HT) or SPACE + characters. It follows that an octet with decimal + value 9 or 32 appearing at the end of an encoded line + must be represented according to Rule #1. This rule is + necessary because some MTAs (Message Transport Agents, + programs which transport messages from one user to + another, or perform a portion of such transfers) are + known to pad lines of text with SPACEs, and others are + known to remove "white space" characters from the end + of a line. Therefore, when decoding a Quoted-Printable + body, any trailing white space on a line must be + deleted, as it will necessarily have been added by + intermediate transport agents. + + (4) (Line Breaks) A line break in a text body, represented + as a CRLF sequence in the text canonical form, must be + represented by a (RFC 822) line break, which is also a + CRLF sequence, in the Quoted-Printable encoding. Since + the canonical representation of media types other than + text do not generally include the representation of + line breaks as CRLF sequences, no hard line breaks + (i.e. line breaks that are intended to be meaningful + and to be displayed to the user) can occur in the + quoted-printable encoding of such types. Sequences + like "=0D", "=0A", "=0A=0D" and "=0D=0A" will routinely + appear in non-text data represented in quoted- + printable, of course. + + Note that many implementations may elect to encode the + local representation of various content types directly + rather than converting to canonical form first, + encoding, and then converting back to local + representation. In particular, this may apply to plain + text material on systems that use newline conventions + other than a CRLF terminator sequence. Such an + implementation optimization is permissible, but only + when the combined canonicalization-encoding step is + equivalent to performing the three steps separately. + + (5) (Soft Line Breaks) The Quoted-Printable encoding + REQUIRES that encoded lines be no more than 76 + characters long. If longer lines are to be encoded + with the Quoted-Printable encoding, "soft" line breaks + + + +Freed & Borenstein Standards Track [Page 20] + +RFC 2045 Internet Message Bodies November 1996 + + + must be used. An equal sign as the last character on a + encoded line indicates such a non-significant ("soft") + line break in the encoded text. + + Thus if the "raw" form of the line is a single unencoded line that + says: + + Now's the time for all folk to come to the aid of their country. + + This can be represented, in the Quoted-Printable encoding, as: + + Now's the time = + for all folk to come= + to the aid of their country. + + This provides a mechanism with which long lines are encoded in such a + way as to be restored by the user agent. The 76 character limit does + not count the trailing CRLF, but counts all other characters, + including any equal signs. + + Since the hyphen character ("-") may be represented as itself in the + Quoted-Printable encoding, care must be taken, when encapsulating a + quoted-printable encoded body inside one or more multipart entities, + to ensure that the boundary delimiter does not appear anywhere in the + encoded body. (A good strategy is to choose a boundary that includes + a character sequence such as "=_" which can never appear in a + quoted-printable body. See the definition of multipart messages in + RFC 2046.) + + NOTE: The quoted-printable encoding represents something of a + compromise between readability and reliability in transport. Bodies + encoded with the quoted-printable encoding will work reliably over + most mail gateways, but may not work perfectly over a few gateways, + notably those involving translation into EBCDIC. A higher level of + confidence is offered by the base64 Content-Transfer-Encoding. A way + to get reasonably reliable transport through EBCDIC gateways is to + also quote the US-ASCII characters + + !"#$@[\]^`{|}~ + + according to rule #1. + + Because quoted-printable data is generally assumed to be line- + oriented, it is to be expected that the representation of the breaks + between the lines of quoted-printable data may be altered in + transport, in the same manner that plain text mail has always been + altered in Internet mail when passing between systems with differing + newline conventions. If such alterations are likely to constitute a + + + +Freed & Borenstein Standards Track [Page 21] + +RFC 2045 Internet Message Bodies November 1996 + + + corruption of the data, it is probably more sensible to use the + base64 encoding rather than the quoted-printable encoding. + + NOTE: Several kinds of substrings cannot be generated according to + the encoding rules for the quoted-printable content-transfer- + encoding, and hence are formally illegal if they appear in the output + of a quoted-printable encoder. This note enumerates these cases and + suggests ways to handle such illegal substrings if any are + encountered in quoted-printable data that is to be decoded. + + (1) An "=" followed by two hexadecimal digits, one or both + of which are lowercase letters in "abcdef", is formally + illegal. A robust implementation might choose to + recognize them as the corresponding uppercase letters. + + (2) An "=" followed by a character that is neither a + hexadecimal digit (including "abcdef") nor the CR + character of a CRLF pair is illegal. This case can be + the result of US-ASCII text having been included in a + quoted-printable part of a message without itself + having been subjected to quoted-printable encoding. A + reasonable approach by a robust implementation might be + to include the "=" character and the following + character in the decoded data without any + transformation and, if possible, indicate to the user + that proper decoding was not possible at this point in + the data. + + (3) An "=" cannot be the ultimate or penultimate character + in an encoded object. This could be handled as in case + (2) above. + + (4) Control characters other than TAB, or CR and LF as + parts of CRLF pairs, must not appear. The same is true + for octets with decimal values greater than 126. If + found in incoming quoted-printable data by a decoder, a + robust implementation might exclude them from the + decoded data and warn the user that illegal characters + were discovered. + + (5) Encoded lines must not be longer than 76 characters, + not counting the trailing CRLF. If longer lines are + found in incoming, encoded data, a robust + implementation might nevertheless decode the lines, and + might report the erroneous encoding to the user. + + + + + + +Freed & Borenstein Standards Track [Page 22] + +RFC 2045 Internet Message Bodies November 1996 + + + WARNING TO IMPLEMENTORS: If binary data is encoded in quoted- + printable, care must be taken to encode CR and LF characters as "=0D" + and "=0A", respectively. In particular, a CRLF sequence in binary + data should be encoded as "=0D=0A". Otherwise, if CRLF were + represented as a hard line break, it might be incorrectly decoded on + platforms with different line break conventions. + + For formalists, the syntax of quoted-printable data is described by + the following grammar: + + quoted-printable := qp-line *(CRLF qp-line) + + qp-line := *(qp-segment transport-padding CRLF) + qp-part transport-padding + + qp-part := qp-section + ; Maximum length of 76 characters + + qp-segment := qp-section *(SPACE / TAB) "=" + ; Maximum length of 76 characters + + qp-section := [*(ptext / SPACE / TAB) ptext] + + ptext := hex-octet / safe-char + + safe-char := + ; Characters not listed as "mail-safe" in + ; RFC 2049 are also not recommended. + + hex-octet := "=" 2(DIGIT / "A" / "B" / "C" / "D" / "E" / "F") + ; Octet must be used for characters > 127, =, + ; SPACEs or TABs at the ends of lines, and is + ; recommended for any character not listed in + ; RFC 2049 as "mail-safe". + + transport-padding := *LWSP-char + ; Composers MUST NOT generate + ; non-zero length transport + ; padding, but receivers MUST + ; be able to handle padding + ; added by message transports. + + IMPORTANT: The addition of LWSP between the elements shown in this + BNF is NOT allowed since this BNF does not specify a structured + header field. + + + + + +Freed & Borenstein Standards Track [Page 23] + +RFC 2045 Internet Message Bodies November 1996 + + +6.8. Base64 Content-Transfer-Encoding + + The Base64 Content-Transfer-Encoding is designed to represent + arbitrary sequences of octets in a form that need not be humanly + readable. The encoding and decoding algorithms are simple, but the + encoded data are consistently only about 33 percent larger than the + unencoded data. This encoding is virtually identical to the one used + in Privacy Enhanced Mail (PEM) applications, as defined in RFC 1421. + + A 65-character subset of US-ASCII is used, enabling 6 bits to be + represented per printable character. (The extra 65th character, "=", + is used to signify a special processing function.) + + NOTE: This subset has the important property that it is represented + identically in all versions of ISO 646, including US-ASCII, and all + characters in the subset are also represented identically in all + versions of EBCDIC. Other popular encodings, such as the encoding + used by the uuencode utility, Macintosh binhex 4.0 [RFC-1741], and + the base85 encoding specified as part of Level 2 PostScript, do not + share these properties, and thus do not fulfill the portability + requirements a binary transport encoding for mail must meet. + + The encoding process represents 24-bit groups of input bits as output + strings of 4 encoded characters. Proceeding from left to right, a + 24-bit input group is formed by concatenating 3 8bit input groups. + These 24 bits are then treated as 4 concatenated 6-bit groups, each + of which is translated into a single digit in the base64 alphabet. + When encoding a bit stream via the base64 encoding, the bit stream + must be presumed to be ordered with the most-significant-bit first. + That is, the first bit in the stream will be the high-order bit in + the first 8bit byte, and the eighth bit will be the low-order bit in + the first 8bit byte, and so on. + + Each 6-bit group is used as an index into an array of 64 printable + characters. The character referenced by the index is placed in the + output string. These characters, identified in Table 1, below, are + selected so as to be universally representable, and the set excludes + characters with particular significance to SMTP (e.g., ".", CR, LF) + and to the multipart boundary delimiters defined in RFC 2046 (e.g., + "-"). + + + + + + + + + + + +Freed & Borenstein Standards Track [Page 24] + +RFC 2045 Internet Message Bodies November 1996 + + + Table 1: The Base64 Alphabet + + Value Encoding Value Encoding Value Encoding Value Encoding + 0 A 17 R 34 i 51 z + 1 B 18 S 35 j 52 0 + 2 C 19 T 36 k 53 1 + 3 D 20 U 37 l 54 2 + 4 E 21 V 38 m 55 3 + 5 F 22 W 39 n 56 4 + 6 G 23 X 40 o 57 5 + 7 H 24 Y 41 p 58 6 + 8 I 25 Z 42 q 59 7 + 9 J 26 a 43 r 60 8 + 10 K 27 b 44 s 61 9 + 11 L 28 c 45 t 62 + + 12 M 29 d 46 u 63 / + 13 N 30 e 47 v + 14 O 31 f 48 w (pad) = + 15 P 32 g 49 x + 16 Q 33 h 50 y + + The encoded output stream must be represented in lines of no more + than 76 characters each. All line breaks or other characters not + found in Table 1 must be ignored by decoding software. In base64 + data, characters other than those in Table 1, line breaks, and other + white space probably indicate a transmission error, about which a + warning message or even a message rejection might be appropriate + under some circumstances. + + Special processing is performed if fewer than 24 bits are available + at the end of the data being encoded. A full encoding quantum is + always completed at the end of a body. When fewer than 24 input bits + are available in an input group, zero bits are added (on the right) + to form an integral number of 6-bit groups. Padding at the end of + the data is performed using the "=" character. Since all base64 + input is an integral number of octets, only the following cases can + arise: (1) the final quantum of encoding input is an integral + multiple of 24 bits; here, the final unit of encoded output will be + an integral multiple of 4 characters with no "=" padding, (2) the + final quantum of encoding input is exactly 8 bits; here, the final + unit of encoded output will be two characters followed by two "=" + padding characters, or (3) the final quantum of encoding input is + exactly 16 bits; here, the final unit of encoded output will be three + characters followed by one "=" padding character. + + Because it is used only for padding at the end of the data, the + occurrence of any "=" characters may be taken as evidence that the + end of the data has been reached (without truncation in transit). No + + + +Freed & Borenstein Standards Track [Page 25] + +RFC 2045 Internet Message Bodies November 1996 + + + such assurance is possible, however, when the number of octets + transmitted was a multiple of three and no "=" characters are + present. + + Any characters outside of the base64 alphabet are to be ignored in + base64-encoded data. + + Care must be taken to use the proper octets for line breaks if base64 + encoding is applied directly to text material that has not been + converted to canonical form. In particular, text line breaks must be + converted into CRLF sequences prior to base64 encoding. The + important thing to note is that this may be done directly by the + encoder rather than in a prior canonicalization step in some + implementations. + + NOTE: There is no need to worry about quoting potential boundary + delimiters within base64-encoded bodies within multipart entities + because no hyphen characters are used in the base64 encoding. + +7. Content-ID Header Field + + In constructing a high-level user agent, it may be desirable to allow + one body to make reference to another. Accordingly, bodies may be + labelled using the "Content-ID" header field, which is syntactically + identical to the "Message-ID" header field: + + id := "Content-ID" ":" msg-id + + Like the Message-ID values, Content-ID values must be generated to be + world-unique. + + The Content-ID value may be used for uniquely identifying MIME + entities in several contexts, particularly for caching data + referenced by the message/external-body mechanism. Although the + Content-ID header is generally optional, its use is MANDATORY in + implementations which generate data of the optional MIME media type + "message/external-body". That is, each message/external-body entity + must have a Content-ID field to permit caching of such data. + + It is also worth noting that the Content-ID value has special + semantics in the case of the multipart/alternative media type. This + is explained in the section of RFC 2046 dealing with + multipart/alternative. + + + + + + + + +Freed & Borenstein Standards Track [Page 26] + +RFC 2045 Internet Message Bodies November 1996 + + +8. Content-Description Header Field + + The ability to associate some descriptive information with a given + body is often desirable. For example, it may be useful to mark an + "image" body as "a picture of the Space Shuttle Endeavor." Such text + may be placed in the Content-Description header field. This header + field is always optional. + + description := "Content-Description" ":" *text + + The description is presumed to be given in the US-ASCII character + set, although the mechanism specified in RFC 2047 may be used for + non-US-ASCII Content-Description values. + +9. Additional MIME Header Fields + + Future documents may elect to define additional MIME header fields + for various purposes. Any new header field that further describes + the content of a message should begin with the string "Content-" to + allow such fields which appear in a message header to be + distinguished from ordinary RFC 822 message header fields. + + MIME-extension-field := + +10. Summary + + Using the MIME-Version, Content-Type, and Content-Transfer-Encoding + header fields, it is possible to include, in a standardized way, + arbitrary types of data with RFC 822 conformant mail messages. No + restrictions imposed by either RFC 821 or RFC 822 are violated, and + care has been taken to avoid problems caused by additional + restrictions imposed by the characteristics of some Internet mail + transport mechanisms (see RFC 2049). + + The next document in this set, RFC 2046, specifies the initial set of + media types that can be labelled and transported using these headers. + +11. Security Considerations + + Security issues are discussed in the second document in this set, RFC + 2046. + + + + + + + + +Freed & Borenstein Standards Track [Page 27] + +RFC 2045 Internet Message Bodies November 1996 + + +12. Authors' Addresses + + For more information, the authors of this document are best contacted + via Internet mail: + + Ned Freed + Innosoft International, Inc. + 1050 East Garvey Avenue South + West Covina, CA 91790 + USA + + Phone: +1 818 919 3600 + Fax: +1 818 919 3614 + EMail: ned@innosoft.com + + + Nathaniel S. Borenstein + First Virtual Holdings + 25 Washington Avenue + Morristown, NJ 07960 + USA + + Phone: +1 201 540 8967 + Fax: +1 201 993 3032 + EMail: nsb@nsb.fv.com + + + MIME is a result of the work of the Internet Engineering Task Force + Working Group on RFC 822 Extensions. The chairman of that group, + Greg Vaudreuil, may be reached at: + + Gregory M. Vaudreuil + Octel Network Services + 17080 Dallas Parkway + Dallas, TX 75248-1905 + USA + + EMail: Greg.Vaudreuil@Octel.Com + + + + + + + + + + + + + +Freed & Borenstein Standards Track [Page 28] + +RFC 2045 Internet Message Bodies November 1996 + + +Appendix A -- Collected Grammar + + This appendix contains the complete BNF grammar for all the syntax + specified by this document. + + By itself, however, this grammar is incomplete. It refers by name to + several syntax rules that are defined by RFC 822. Rather than + reproduce those definitions here, and risk unintentional differences + between the two, this document simply refers the reader to RFC 822 + for the remaining definitions. Wherever a term is undefined, it + refers to the RFC 822 definition. + + attribute := token + ; Matching of attributes + ; is ALWAYS case-insensitive. + + composite-type := "message" / "multipart" / extension-token + + content := "Content-Type" ":" type "/" subtype + *(";" parameter) + ; Matching of media type and subtype + ; is ALWAYS case-insensitive. + + description := "Content-Description" ":" *text + + discrete-type := "text" / "image" / "audio" / "video" / + "application" / extension-token + + encoding := "Content-Transfer-Encoding" ":" mechanism + + entity-headers := [ content CRLF ] + [ encoding CRLF ] + [ id CRLF ] + [ description CRLF ] + *( MIME-extension-field CRLF ) + + extension-token := ietf-token / x-token + + hex-octet := "=" 2(DIGIT / "A" / "B" / "C" / "D" / "E" / "F") + ; Octet must be used for characters > 127, =, + ; SPACEs or TABs at the ends of lines, and is + ; recommended for any character not listed in + ; RFC 2049 as "mail-safe". + + iana-token := + + + + +Freed & Borenstein Standards Track [Page 29] + +RFC 2045 Internet Message Bodies November 1996 + + + ietf-token := + + id := "Content-ID" ":" msg-id + + mechanism := "7bit" / "8bit" / "binary" / + "quoted-printable" / "base64" / + ietf-token / x-token + + MIME-extension-field := + + MIME-message-headers := entity-headers + fields + version CRLF + ; The ordering of the header + ; fields implied by this BNF + ; definition should be ignored. + + MIME-part-headers := entity-headers + [fields] + ; Any field not beginning with + ; "content-" can have no defined + ; meaning and may be ignored. + ; The ordering of the header + ; fields implied by this BNF + ; definition should be ignored. + + parameter := attribute "=" value + + ptext := hex-octet / safe-char + + qp-line := *(qp-segment transport-padding CRLF) + qp-part transport-padding + + qp-part := qp-section + ; Maximum length of 76 characters + + qp-section := [*(ptext / SPACE / TAB) ptext] + + qp-segment := qp-section *(SPACE / TAB) "=" + ; Maximum length of 76 characters + + quoted-printable := qp-line *(CRLF qp-line) + + + + + +Freed & Borenstein Standards Track [Page 30] + +RFC 2045 Internet Message Bodies November 1996 + + + safe-char := + ; Characters not listed as "mail-safe" in + ; RFC 2049 are also not recommended. + + subtype := extension-token / iana-token + + token := 1* + + transport-padding := *LWSP-char + ; Composers MUST NOT generate + ; non-zero length transport + ; padding, but receivers MUST + ; be able to handle padding + ; added by message transports. + + tspecials := "(" / ")" / "<" / ">" / "@" / + "," / ";" / ":" / "\" / <"> + "/" / "[" / "]" / "?" / "=" + ; Must be in quoted-string, + ; to use within parameter values + + type := discrete-type / composite-type + + value := token / quoted-string + + version := "MIME-Version" ":" 1*DIGIT "." 1*DIGIT + + x-token := + + + + + + + + + + + + + + + + + + + + +Freed & Borenstein Standards Track [Page 31] + diff --git a/vendor/swiftmailer/swiftmailer/notes/rfc/rfc2046.txt b/vendor/swiftmailer/swiftmailer/notes/rfc/rfc2046.txt new file mode 100755 index 0000000..84d90c1 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/notes/rfc/rfc2046.txt @@ -0,0 +1,2467 @@ + + + + + + +Network Working Group N. Freed +Request for Comments: 2046 Innosoft +Obsoletes: 1521, 1522, 1590 N. Borenstein +Category: Standards Track First Virtual + November 1996 + + + Multipurpose Internet Mail Extensions + (MIME) Part Two: + Media Types + +Status of this Memo + + This document specifies an Internet standards track protocol for the + Internet community, and requests discussion and suggestions for + improvements. Please refer to the current edition of the "Internet + Official Protocol Standards" (STD 1) for the standardization state + and status of this protocol. Distribution of this memo is unlimited. + +Abstract + + STD 11, RFC 822 defines a message representation protocol specifying + considerable detail about US-ASCII message headers, but which leaves + the message content, or message body, as flat US-ASCII text. This + set of documents, collectively called the Multipurpose Internet Mail + Extensions, or MIME, redefines the format of messages to allow for + + (1) textual message bodies in character sets other than + US-ASCII, + + (2) an extensible set of different formats for non-textual + message bodies, + + (3) multi-part message bodies, and + + (4) textual header information in character sets other than + US-ASCII. + + These documents are based on earlier work documented in RFC 934, STD + 11, and RFC 1049, but extends and revises them. Because RFC 822 said + so little about message bodies, these documents are largely + orthogonal to (rather than a revision of) RFC 822. + + The initial document in this set, RFC 2045, specifies the various + headers used to describe the structure of MIME messages. This second + document defines the general structure of the MIME media typing + system and defines an initial set of media types. The third document, + RFC 2047, describes extensions to RFC 822 to allow non-US-ASCII text + + + +Freed & Borenstein Standards Track [Page 1] + +RFC 2046 Media Types November 1996 + + + data in Internet mail header fields. The fourth document, RFC 2048, + specifies various IANA registration procedures for MIME-related + facilities. The fifth and final document, RFC 2049, describes MIME + conformance criteria as well as providing some illustrative examples + of MIME message formats, acknowledgements, and the bibliography. + + These documents are revisions of RFCs 1521 and 1522, which themselves + were revisions of RFCs 1341 and 1342. An appendix in RFC 2049 + describes differences and changes from previous versions. + +Table of Contents + + 1. Introduction ......................................... 3 + 2. Definition of a Top-Level Media Type ................. 4 + 3. Overview Of The Initial Top-Level Media Types ........ 4 + 4. Discrete Media Type Values ........................... 6 + 4.1 Text Media Type ..................................... 6 + 4.1.1 Representation of Line Breaks ..................... 7 + 4.1.2 Charset Parameter ................................. 7 + 4.1.3 Plain Subtype ..................................... 11 + 4.1.4 Unrecognized Subtypes ............................. 11 + 4.2 Image Media Type .................................... 11 + 4.3 Audio Media Type .................................... 11 + 4.4 Video Media Type .................................... 12 + 4.5 Application Media Type .............................. 12 + 4.5.1 Octet-Stream Subtype .............................. 13 + 4.5.2 PostScript Subtype ................................ 14 + 4.5.3 Other Application Subtypes ........................ 17 + 5. Composite Media Type Values .......................... 17 + 5.1 Multipart Media Type ................................ 17 + 5.1.1 Common Syntax ..................................... 19 + 5.1.2 Handling Nested Messages and Multiparts ........... 24 + 5.1.3 Mixed Subtype ..................................... 24 + 5.1.4 Alternative Subtype ............................... 24 + 5.1.5 Digest Subtype .................................... 26 + 5.1.6 Parallel Subtype .................................. 27 + 5.1.7 Other Multipart Subtypes .......................... 28 + 5.2 Message Media Type .................................. 28 + 5.2.1 RFC822 Subtype .................................... 28 + 5.2.2 Partial Subtype ................................... 29 + 5.2.2.1 Message Fragmentation and Reassembly ............ 30 + 5.2.2.2 Fragmentation and Reassembly Example ............ 31 + 5.2.3 External-Body Subtype ............................. 33 + 5.2.4 Other Message Subtypes ............................ 40 + 6. Experimental Media Type Values ....................... 40 + 7. Summary .............................................. 41 + 8. Security Considerations .............................. 41 + 9. Authors' Addresses ................................... 42 + + + +Freed & Borenstein Standards Track [Page 2] + +RFC 2046 Media Types November 1996 + + + A. Collected Grammar .................................... 43 + +1. Introduction + + The first document in this set, RFC 2045, defines a number of header + fields, including Content-Type. The Content-Type field is used to + specify the nature of the data in the body of a MIME entity, by + giving media type and subtype identifiers, and by providing auxiliary + information that may be required for certain media types. After the + type and subtype names, the remainder of the header field is simply a + set of parameters, specified in an attribute/value notation. The + ordering of parameters is not significant. + + In general, the top-level media type is used to declare the general + type of data, while the subtype specifies a specific format for that + type of data. Thus, a media type of "image/xyz" is enough to tell a + user agent that the data is an image, even if the user agent has no + knowledge of the specific image format "xyz". Such information can + be used, for example, to decide whether or not to show a user the raw + data from an unrecognized subtype -- such an action might be + reasonable for unrecognized subtypes of "text", but not for + unrecognized subtypes of "image" or "audio". For this reason, + registered subtypes of "text", "image", "audio", and "video" should + not contain embedded information that is really of a different type. + Such compound formats should be represented using the "multipart" or + "application" types. + + Parameters are modifiers of the media subtype, and as such do not + fundamentally affect the nature of the content. The set of + meaningful parameters depends on the media type and subtype. Most + parameters are associated with a single specific subtype. However, a + given top-level media type may define parameters which are applicable + to any subtype of that type. Parameters may be required by their + defining media type or subtype or they may be optional. MIME + implementations must also ignore any parameters whose names they do + not recognize. + + MIME's Content-Type header field and media type mechanism has been + carefully designed to be extensible, and it is expected that the set + of media type/subtype pairs and their associated parameters will grow + significantly over time. Several other MIME facilities, such as + transfer encodings and "message/external-body" access types, are + likely to have new values defined over time. In order to ensure that + the set of such values is developed in an orderly, well-specified, + and public manner, MIME sets up a registration process which uses the + Internet Assigned Numbers Authority (IANA) as a central registry for + MIME's various areas of extensibility. The registration process for + these areas is described in a companion document, RFC 2048. + + + +Freed & Borenstein Standards Track [Page 3] + +RFC 2046 Media Types November 1996 + + + The initial seven standard top-level media type are defined and + described in the remainder of this document. + +2. Definition of a Top-Level Media Type + + The definition of a top-level media type consists of: + + (1) a name and a description of the type, including + criteria for whether a particular type would qualify + under that type, + + (2) the names and definitions of parameters, if any, which + are defined for all subtypes of that type (including + whether such parameters are required or optional), + + (3) how a user agent and/or gateway should handle unknown + subtypes of this type, + + (4) general considerations on gatewaying entities of this + top-level type, if any, and + + (5) any restrictions on content-transfer-encodings for + entities of this top-level type. + +3. Overview Of The Initial Top-Level Media Types + + The five discrete top-level media types are: + + (1) text -- textual information. The subtype "plain" in + particular indicates plain text containing no + formatting commands or directives of any sort. Plain + text is intended to be displayed "as-is". No special + software is required to get the full meaning of the + text, aside from support for the indicated character + set. Other subtypes are to be used for enriched text in + forms where application software may enhance the + appearance of the text, but such software must not be + required in order to get the general idea of the + content. Possible subtypes of "text" thus include any + word processor format that can be read without + resorting to software that understands the format. In + particular, formats that employ embeddded binary + formatting information are not considered directly + readable. A very simple and portable subtype, + "richtext", was defined in RFC 1341, with a further + revision in RFC 1896 under the name "enriched". + + + + + +Freed & Borenstein Standards Track [Page 4] + +RFC 2046 Media Types November 1996 + + + (2) image -- image data. "Image" requires a display device + (such as a graphical display, a graphics printer, or a + FAX machine) to view the information. An initial + subtype is defined for the widely-used image format + JPEG. . subtypes are defined for two widely-used image + formats, jpeg and gif. + + (3) audio -- audio data. "Audio" requires an audio output + device (such as a speaker or a telephone) to "display" + the contents. An initial subtype "basic" is defined in + this document. + + (4) video -- video data. "Video" requires the capability + to display moving images, typically including + specialized hardware and software. An initial subtype + "mpeg" is defined in this document. + + (5) application -- some other kind of data, typically + either uninterpreted binary data or information to be + processed by an application. The subtype "octet- + stream" is to be used in the case of uninterpreted + binary data, in which case the simplest recommended + action is to offer to write the information into a file + for the user. The "PostScript" subtype is also defined + for the transport of PostScript material. Other + expected uses for "application" include spreadsheets, + data for mail-based scheduling systems, and languages + for "active" (computational) messaging, and word + processing formats that are not directly readable. + Note that security considerations may exist for some + types of application data, most notably + "application/PostScript" and any form of active + messaging. These issues are discussed later in this + document. + + The two composite top-level media types are: + + (1) multipart -- data consisting of multiple entities of + independent data types. Four subtypes are initially + defined, including the basic "mixed" subtype specifying + a generic mixed set of parts, "alternative" for + representing the same data in multiple formats, + "parallel" for parts intended to be viewed + simultaneously, and "digest" for multipart entities in + which each part has a default type of "message/rfc822". + + + + + + +Freed & Borenstein Standards Track [Page 5] + +RFC 2046 Media Types November 1996 + + + (2) message -- an encapsulated message. A body of media + type "message" is itself all or a portion of some kind + of message object. Such objects may or may not in turn + contain other entities. The "rfc822" subtype is used + when the encapsulated content is itself an RFC 822 + message. The "partial" subtype is defined for partial + RFC 822 messages, to permit the fragmented transmission + of bodies that are thought to be too large to be passed + through transport facilities in one piece. Another + subtype, "external-body", is defined for specifying + large bodies by reference to an external data source. + + It should be noted that the list of media type values given here may + be augmented in time, via the mechanisms described above, and that + the set of subtypes is expected to grow substantially. + +4. Discrete Media Type Values + + Five of the seven initial media type values refer to discrete bodies. + The content of these types must be handled by non-MIME mechanisms; + they are opaque to MIME processors. + +4.1. Text Media Type + + The "text" media type is intended for sending material which is + principally textual in form. A "charset" parameter may be used to + indicate the character set of the body text for "text" subtypes, + notably including the subtype "text/plain", which is a generic + subtype for plain text. Plain text does not provide for or allow + formatting commands, font attribute specifications, processing + instructions, interpretation directives, or content markup. Plain + text is seen simply as a linear sequence of characters, possibly + interrupted by line breaks or page breaks. Plain text may allow the + stacking of several characters in the same position in the text. + Plain text in scripts like Arabic and Hebrew may also include + facilitites that allow the arbitrary mixing of text segments with + opposite writing directions. + + Beyond plain text, there are many formats for representing what might + be known as "rich text". An interesting characteristic of many such + representations is that they are to some extent readable even without + the software that interprets them. It is useful, then, to + distinguish them, at the highest level, from such unreadable data as + images, audio, or text represented in an unreadable form. In the + absence of appropriate interpretation software, it is reasonable to + show subtypes of "text" to the user, while it is not reasonable to do + so with most nontextual data. Such formatted textual data should be + represented using subtypes of "text". + + + +Freed & Borenstein Standards Track [Page 6] + +RFC 2046 Media Types November 1996 + + +4.1.1. Representation of Line Breaks + + The canonical form of any MIME "text" subtype MUST always represent a + line break as a CRLF sequence. Similarly, any occurrence of CRLF in + MIME "text" MUST represent a line break. Use of CR and LF outside of + line break sequences is also forbidden. + + This rule applies regardless of format or character set or sets + involved. + + NOTE: The proper interpretation of line breaks when a body is + displayed depends on the media type. In particular, while it is + appropriate to treat a line break as a transition to a new line when + displaying a "text/plain" body, this treatment is actually incorrect + for other subtypes of "text" like "text/enriched" [RFC-1896]. + Similarly, whether or not line breaks should be added during display + operations is also a function of the media type. It should not be + necessary to add any line breaks to display "text/plain" correctly, + whereas proper display of "text/enriched" requires the appropriate + addition of line breaks. + + NOTE: Some protocols defines a maximum line length. E.g. SMTP [RFC- + 821] allows a maximum of 998 octets before the next CRLF sequence. + To be transported by such protocols, data which includes too long + segments without CRLF sequences must be encoded with a suitable + content-transfer-encoding. + +4.1.2. Charset Parameter + + A critical parameter that may be specified in the Content-Type field + for "text/plain" data is the character set. This is specified with a + "charset" parameter, as in: + + Content-type: text/plain; charset=iso-8859-1 + + Unlike some other parameter values, the values of the charset + parameter are NOT case sensitive. The default character set, which + must be assumed in the absence of a charset parameter, is US-ASCII. + + The specification for any future subtypes of "text" must specify + whether or not they will also utilize a "charset" parameter, and may + possibly restrict its values as well. For other subtypes of "text" + than "text/plain", the semantics of the "charset" parameter should be + defined to be identical to those specified here for "text/plain", + i.e., the body consists entirely of characters in the given charset. + In particular, definers of future "text" subtypes should pay close + attention to the implications of multioctet character sets for their + subtype definitions. + + + +Freed & Borenstein Standards Track [Page 7] + +RFC 2046 Media Types November 1996 + + + The charset parameter for subtypes of "text" gives a name of a + character set, as "character set" is defined in RFC 2045. The rules + regarding line breaks detailed in the previous section must also be + observed -- a character set whose definition does not conform to + these rules cannot be used in a MIME "text" subtype. + + An initial list of predefined character set names can be found at the + end of this section. Additional character sets may be registered + with IANA. + + Other media types than subtypes of "text" might choose to employ the + charset parameter as defined here, but with the CRLF/line break + restriction removed. Therefore, all character sets that conform to + the general definition of "character set" in RFC 2045 can be + registered for MIME use. + + Note that if the specified character set includes 8-bit characters + and such characters are used in the body, a Content-Transfer-Encoding + header field and a corresponding encoding on the data are required in + order to transmit the body via some mail transfer protocols, such as + SMTP [RFC-821]. + + The default character set, US-ASCII, has been the subject of some + confusion and ambiguity in the past. Not only were there some + ambiguities in the definition, there have been wide variations in + practice. In order to eliminate such ambiguity and variations in the + future, it is strongly recommended that new user agents explicitly + specify a character set as a media type parameter in the Content-Type + header field. "US-ASCII" does not indicate an arbitrary 7-bit + character set, but specifies that all octets in the body must be + interpreted as characters according to the US-ASCII character set. + National and application-oriented versions of ISO 646 [ISO-646] are + usually NOT identical to US-ASCII, and in that case their use in + Internet mail is explicitly discouraged. The omission of the ISO 646 + character set from this document is deliberate in this regard. The + character set name of "US-ASCII" explicitly refers to the character + set defined in ANSI X3.4-1986 [US- ASCII]. The new international + reference version (IRV) of the 1991 edition of ISO 646 is identical + to US-ASCII. The character set name "ASCII" is reserved and must not + be used for any purpose. + + NOTE: RFC 821 explicitly specifies "ASCII", and references an earlier + version of the American Standard. Insofar as one of the purposes of + specifying a media type and character set is to permit the receiver + to unambiguously determine how the sender intended the coded message + to be interpreted, assuming anything other than "strict ASCII" as the + default would risk unintentional and incompatible changes to the + semantics of messages now being transmitted. This also implies that + + + +Freed & Borenstein Standards Track [Page 8] + +RFC 2046 Media Types November 1996 + + + messages containing characters coded according to other versions of + ISO 646 than US-ASCII and the 1991 IRV, or using code-switching + procedures (e.g., those of ISO 2022), as well as 8bit or multiple + octet character encodings MUST use an appropriate character set + specification to be consistent with MIME. + + The complete US-ASCII character set is listed in ANSI X3.4- 1986. + Note that the control characters including DEL (0-31, 127) have no + defined meaning in apart from the combination CRLF (US-ASCII values + 13 and 10) indicating a new line. Two of the characters have de + facto meanings in wide use: FF (12) often means "start subsequent + text on the beginning of a new page"; and TAB or HT (9) often (though + not always) means "move the cursor to the next available column after + the current position where the column number is a multiple of 8 + (counting the first column as column 0)." Aside from these + conventions, any use of the control characters or DEL in a body must + either occur + + (1) because a subtype of text other than "plain" + specifically assigns some additional meaning, or + + (2) within the context of a private agreement between the + sender and recipient. Such private agreements are + discouraged and should be replaced by the other + capabilities of this document. + + NOTE: An enormous proliferation of character sets exist beyond US- + ASCII. A large number of partially or totally overlapping character + sets is NOT a good thing. A SINGLE character set that can be used + universally for representing all of the world's languages in Internet + mail would be preferrable. Unfortunately, existing practice in + several communities seems to point to the continued use of multiple + character sets in the near future. A small number of standard + character sets are, therefore, defined for Internet use in this + document. + + The defined charset values are: + + (1) US-ASCII -- as defined in ANSI X3.4-1986 [US-ASCII]. + + (2) ISO-8859-X -- where "X" is to be replaced, as + necessary, for the parts of ISO-8859 [ISO-8859]. Note + that the ISO 646 character sets have deliberately been + omitted in favor of their 8859 replacements, which are + the designated character sets for Internet mail. As of + the publication of this document, the legitimate values + for "X" are the digits 1 through 10. + + + + +Freed & Borenstein Standards Track [Page 9] + +RFC 2046 Media Types November 1996 + + + Characters in the range 128-159 has no assigned meaning in ISO-8859- + X. Characters with values below 128 in ISO-8859-X have the same + assigned meaning as they do in US-ASCII. + + Part 6 of ISO 8859 (Latin/Arabic alphabet) and part 8 (Latin/Hebrew + alphabet) includes both characters for which the normal writing + direction is right to left and characters for which it is left to + right, but do not define a canonical ordering method for representing + bi-directional text. The charset values "ISO-8859-6" and "ISO-8859- + 8", however, specify that the visual method is used [RFC-1556]. + + All of these character sets are used as pure 7bit or 8bit sets + without any shift or escape functions. The meaning of shift and + escape sequences in these character sets is not defined. + + The character sets specified above are the ones that were relatively + uncontroversial during the drafting of MIME. This document does not + endorse the use of any particular character set other than US-ASCII, + and recognizes that the future evolution of world character sets + remains unclear. + + Note that the character set used, if anything other than US- ASCII, + must always be explicitly specified in the Content-Type field. + + No character set name other than those defined above may be used in + Internet mail without the publication of a formal specification and + its registration with IANA, or by private agreement, in which case + the character set name must begin with "X-". + + Implementors are discouraged from defining new character sets unless + absolutely necessary. + + The "charset" parameter has been defined primarily for the purpose of + textual data, and is described in this section for that reason. + However, it is conceivable that non-textual data might also wish to + specify a charset value for some purpose, in which case the same + syntax and values should be used. + + In general, composition software should always use the "lowest common + denominator" character set possible. For example, if a body contains + only US-ASCII characters, it SHOULD be marked as being in the US- + ASCII character set, not ISO-8859-1, which, like all the ISO-8859 + family of character sets, is a superset of US-ASCII. More generally, + if a widely-used character set is a subset of another character set, + and a body contains only characters in the widely-used subset, it + should be labelled as being in that subset. This will increase the + chances that the recipient will be able to view the resulting entity + correctly. + + + +Freed & Borenstein Standards Track [Page 10] + +RFC 2046 Media Types November 1996 + + +4.1.3. Plain Subtype + + The simplest and most important subtype of "text" is "plain". This + indicates plain text that does not contain any formatting commands or + directives. Plain text is intended to be displayed "as-is", that is, + no interpretation of embedded formatting commands, font attribute + specifications, processing instructions, interpretation directives, + or content markup should be necessary for proper display. The + default media type of "text/plain; charset=us-ascii" for Internet + mail describes existing Internet practice. That is, it is the type + of body defined by RFC 822. + + No other "text" subtype is defined by this document. + +4.1.4. Unrecognized Subtypes + + Unrecognized subtypes of "text" should be treated as subtype "plain" + as long as the MIME implementation knows how to handle the charset. + Unrecognized subtypes which also specify an unrecognized charset + should be treated as "application/octet- stream". + +4.2. Image Media Type + + A media type of "image" indicates that the body contains an image. + The subtype names the specific image format. These names are not + case sensitive. An initial subtype is "jpeg" for the JPEG format + using JFIF encoding [JPEG]. + + The list of "image" subtypes given here is neither exclusive nor + exhaustive, and is expected to grow as more types are registered with + IANA, as described in RFC 2048. + + Unrecognized subtypes of "image" should at a miniumum be treated as + "application/octet-stream". Implementations may optionally elect to + pass subtypes of "image" that they do not specifically recognize to a + secure and robust general-purpose image viewing application, if such + an application is available. + + NOTE: Using of a generic-purpose image viewing application this way + inherits the security problems of the most dangerous type supported + by the application. + +4.3. Audio Media Type + + A media type of "audio" indicates that the body contains audio data. + Although there is not yet a consensus on an "ideal" audio format for + use with computers, there is a pressing need for a format capable of + providing interoperable behavior. + + + +Freed & Borenstein Standards Track [Page 11] + +RFC 2046 Media Types November 1996 + + + The initial subtype of "basic" is specified to meet this requirement + by providing an absolutely minimal lowest common denominator audio + format. It is expected that richer formats for higher quality and/or + lower bandwidth audio will be defined by a later document. + + The content of the "audio/basic" subtype is single channel audio + encoded using 8bit ISDN mu-law [PCM] at a sample rate of 8000 Hz. + + Unrecognized subtypes of "audio" should at a miniumum be treated as + "application/octet-stream". Implementations may optionally elect to + pass subtypes of "audio" that they do not specifically recognize to a + robust general-purpose audio playing application, if such an + application is available. + +4.4. Video Media Type + + A media type of "video" indicates that the body contains a time- + varying-picture image, possibly with color and coordinated sound. + The term 'video' is used in its most generic sense, rather than with + reference to any particular technology or format, and is not meant to + preclude subtypes such as animated drawings encoded compactly. The + subtype "mpeg" refers to video coded according to the MPEG standard + [MPEG]. + + Note that although in general this document strongly discourages the + mixing of multiple media in a single body, it is recognized that many + so-called video formats include a representation for synchronized + audio, and this is explicitly permitted for subtypes of "video". + + Unrecognized subtypes of "video" should at a minumum be treated as + "application/octet-stream". Implementations may optionally elect to + pass subtypes of "video" that they do not specifically recognize to a + robust general-purpose video display application, if such an + application is available. + +4.5. Application Media Type + + The "application" media type is to be used for discrete data which do + not fit in any of the other categories, and particularly for data to + be processed by some type of application program. This is + information which must be processed by an application before it is + viewable or usable by a user. Expected uses for the "application" + media type include file transfer, spreadsheets, data for mail-based + scheduling systems, and languages for "active" (computational) + material. (The latter, in particular, can pose security problems + which must be understood by implementors, and are considered in + detail in the discussion of the "application/PostScript" media type.) + + + + +Freed & Borenstein Standards Track [Page 12] + +RFC 2046 Media Types November 1996 + + + For example, a meeting scheduler might define a standard + representation for information about proposed meeting dates. An + intelligent user agent would use this information to conduct a dialog + with the user, and might then send additional material based on that + dialog. More generally, there have been several "active" messaging + languages developed in which programs in a suitably specialized + language are transported to a remote location and automatically run + in the recipient's environment. + + Such applications may be defined as subtypes of the "application" + media type. This document defines two subtypes: + + octet-stream, and PostScript. + + The subtype of "application" will often be either the name or include + part of the name of the application for which the data are intended. + This does not mean, however, that any application program name may be + used freely as a subtype of "application". + +4.5.1. Octet-Stream Subtype + + The "octet-stream" subtype is used to indicate that a body contains + arbitrary binary data. The set of currently defined parameters is: + + (1) TYPE -- the general type or category of binary data. + This is intended as information for the human recipient + rather than for any automatic processing. + + (2) PADDING -- the number of bits of padding that were + appended to the bit-stream comprising the actual + contents to produce the enclosed 8bit byte-oriented + data. This is useful for enclosing a bit-stream in a + body when the total number of bits is not a multiple of + 8. + + Both of these parameters are optional. + + An additional parameter, "CONVERSIONS", was defined in RFC 1341 but + has since been removed. RFC 1341 also defined the use of a "NAME" + parameter which gave a suggested file name to be used if the data + were to be written to a file. This has been deprecated in + anticipation of a separate Content-Disposition header field, to be + defined in a subsequent RFC. + + The recommended action for an implementation that receives an + "application/octet-stream" entity is to simply offer to put the data + in a file, with any Content-Transfer-Encoding undone, or perhaps to + use it as input to a user-specified process. + + + +Freed & Borenstein Standards Track [Page 13] + +RFC 2046 Media Types November 1996 + + + To reduce the danger of transmitting rogue programs, it is strongly + recommended that implementations NOT implement a path-search + mechanism whereby an arbitrary program named in the Content-Type + parameter (e.g., an "interpreter=" parameter) is found and executed + using the message body as input. + +4.5.2. PostScript Subtype + + A media type of "application/postscript" indicates a PostScript + program. Currently two variants of the PostScript language are + allowed; the original level 1 variant is described in [POSTSCRIPT] + and the more recent level 2 variant is described in [POSTSCRIPT2]. + + PostScript is a registered trademark of Adobe Systems, Inc. Use of + the MIME media type "application/postscript" implies recognition of + that trademark and all the rights it entails. + + The PostScript language definition provides facilities for internal + labelling of the specific language features a given program uses. + This labelling, called the PostScript document structuring + conventions, or DSC, is very general and provides substantially more + information than just the language level. The use of document + structuring conventions, while not required, is strongly recommended + as an aid to interoperability. Documents which lack proper + structuring conventions cannot be tested to see whether or not they + will work in a given environment. As such, some systems may assume + the worst and refuse to process unstructured documents. + + The execution of general-purpose PostScript interpreters entails + serious security risks, and implementors are discouraged from simply + sending PostScript bodies to "off- the-shelf" interpreters. While it + is usually safe to send PostScript to a printer, where the potential + for harm is greatly constrained by typical printer environments, + implementors should consider all of the following before they add + interactive display of PostScript bodies to their MIME readers. + + The remainder of this section outlines some, though probably not all, + of the possible problems with the transport of PostScript entities. + + (1) Dangerous operations in the PostScript language + include, but may not be limited to, the PostScript + operators "deletefile", "renamefile", "filenameforall", + and "file". "File" is only dangerous when applied to + something other than standard input or output. + Implementations may also define additional nonstandard + file operators; these may also pose a threat to + security. "Filenameforall", the wildcard file search + operator, may appear at first glance to be harmless. + + + +Freed & Borenstein Standards Track [Page 14] + +RFC 2046 Media Types November 1996 + + + Note, however, that this operator has the potential to + reveal information about what files the recipient has + access to, and this information may itself be + sensitive. Message senders should avoid the use of + potentially dangerous file operators, since these + operators are quite likely to be unavailable in secure + PostScript implementations. Message receiving and + displaying software should either completely disable + all potentially dangerous file operators or take + special care not to delegate any special authority to + their operation. These operators should be viewed as + being done by an outside agency when interpreting + PostScript documents. Such disabling and/or checking + should be done completely outside of the reach of the + PostScript language itself; care should be taken to + insure that no method exists for re-enabling full- + function versions of these operators. + + (2) The PostScript language provides facilities for exiting + the normal interpreter, or server, loop. Changes made + in this "outer" environment are customarily retained + across documents, and may in some cases be retained + semipermanently in nonvolatile memory. The operators + associated with exiting the interpreter loop have the + potential to interfere with subsequent document + processing. As such, their unrestrained use + constitutes a threat of service denial. PostScript + operators that exit the interpreter loop include, but + may not be limited to, the exitserver and startjob + operators. Message sending software should not + generate PostScript that depends on exiting the + interpreter loop to operate, since the ability to exit + will probably be unavailable in secure PostScript + implementations. Message receiving and displaying + software should completely disable the ability to make + retained changes to the PostScript environment by + eliminating or disabling the "startjob" and + "exitserver" operations. If these operations cannot be + eliminated or completely disabled the password + associated with them should at least be set to a hard- + to-guess value. + + (3) PostScript provides operators for setting system-wide + and device-specific parameters. These parameter + settings may be retained across jobs and may + potentially pose a threat to the correct operation of + the interpreter. The PostScript operators that set + system and device parameters include, but may not be + + + +Freed & Borenstein Standards Track [Page 15] + +RFC 2046 Media Types November 1996 + + + limited to, the "setsystemparams" and "setdevparams" + operators. Message sending software should not + generate PostScript that depends on the setting of + system or device parameters to operate correctly. The + ability to set these parameters will probably be + unavailable in secure PostScript implementations. + Message receiving and displaying software should + disable the ability to change system and device + parameters. If these operators cannot be completely + disabled the password associated with them should at + least be set to a hard-to-guess value. + + (4) Some PostScript implementations provide nonstandard + facilities for the direct loading and execution of + machine code. Such facilities are quite obviously open + to substantial abuse. Message sending software should + not make use of such features. Besides being totally + hardware-specific, they are also likely to be + unavailable in secure implementations of PostScript. + Message receiving and displaying software should not + allow such operators to be used if they exist. + + (5) PostScript is an extensible language, and many, if not + most, implementations of it provide a number of their + own extensions. This document does not deal with such + extensions explicitly since they constitute an unknown + factor. Message sending software should not make use + of nonstandard extensions; they are likely to be + missing from some implementations. Message receiving + and displaying software should make sure that any + nonstandard PostScript operators are secure and don't + present any kind of threat. + + (6) It is possible to write PostScript that consumes huge + amounts of various system resources. It is also + possible to write PostScript programs that loop + indefinitely. Both types of programs have the + potential to cause damage if sent to unsuspecting + recipients. Message-sending software should avoid the + construction and dissemination of such programs, which + is antisocial. Message receiving and displaying + software should provide appropriate mechanisms to abort + processing after a reasonable amount of time has + elapsed. In addition, PostScript interpreters should be + limited to the consumption of only a reasonable amount + of any given system resource. + + + + + +Freed & Borenstein Standards Track [Page 16] + +RFC 2046 Media Types November 1996 + + + (7) It is possible to include raw binary information inside + PostScript in various forms. This is not recommended + for use in Internet mail, both because it is not + supported by all PostScript interpreters and because it + significantly complicates the use of a MIME Content- + Transfer-Encoding. (Without such binary, PostScript + may typically be viewed as line-oriented data. The + treatment of CRLF sequences becomes extremely + problematic if binary and line-oriented data are mixed + in a single Postscript data stream.) + + (8) Finally, bugs may exist in some PostScript interpreters + which could possibly be exploited to gain unauthorized + access to a recipient's system. Apart from noting this + possibility, there is no specific action to take to + prevent this, apart from the timely correction of such + bugs if any are found. + +4.5.3. Other Application Subtypes + + It is expected that many other subtypes of "application" will be + defined in the future. MIME implementations must at a minimum treat + any unrecognized subtypes as being equivalent to "application/octet- + stream". + +5. Composite Media Type Values + + The remaining two of the seven initial Content-Type values refer to + composite entities. Composite entities are handled using MIME + mechanisms -- a MIME processor typically handles the body directly. + +5.1. Multipart Media Type + + In the case of multipart entities, in which one or more different + sets of data are combined in a single body, a "multipart" media type + field must appear in the entity's header. The body must then contain + one or more body parts, each preceded by a boundary delimiter line, + and the last one followed by a closing boundary delimiter line. + After its boundary delimiter line, each body part then consists of a + header area, a blank line, and a body area. Thus a body part is + similar to an RFC 822 message in syntax, but different in meaning. + + A body part is an entity and hence is NOT to be interpreted as + actually being an RFC 822 message. To begin with, NO header fields + are actually required in body parts. A body part that starts with a + blank line, therefore, is allowed and is a body part for which all + default values are to be assumed. In such a case, the absence of a + Content-Type header usually indicates that the corresponding body has + + + +Freed & Borenstein Standards Track [Page 17] + +RFC 2046 Media Types November 1996 + + + a content-type of "text/plain; charset=US-ASCII". + + The only header fields that have defined meaning for body parts are + those the names of which begin with "Content-". All other header + fields may be ignored in body parts. Although they should generally + be retained if at all possible, they may be discarded by gateways if + necessary. Such other fields are permitted to appear in body parts + but must not be depended on. "X-" fields may be created for + experimental or private purposes, with the recognition that the + information they contain may be lost at some gateways. + + NOTE: The distinction between an RFC 822 message and a body part is + subtle, but important. A gateway between Internet and X.400 mail, + for example, must be able to tell the difference between a body part + that contains an image and a body part that contains an encapsulated + message, the body of which is a JPEG image. In order to represent + the latter, the body part must have "Content-Type: message/rfc822", + and its body (after the blank line) must be the encapsulated message, + with its own "Content-Type: image/jpeg" header field. The use of + similar syntax facilitates the conversion of messages to body parts, + and vice versa, but the distinction between the two must be + understood by implementors. (For the special case in which parts + actually are messages, a "digest" subtype is also defined.) + + As stated previously, each body part is preceded by a boundary + delimiter line that contains the boundary delimiter. The boundary + delimiter MUST NOT appear inside any of the encapsulated parts, on a + line by itself or as the prefix of any line. This implies that it is + crucial that the composing agent be able to choose and specify a + unique boundary parameter value that does not contain the boundary + parameter value of an enclosing multipart as a prefix. + + All present and future subtypes of the "multipart" type must use an + identical syntax. Subtypes may differ in their semantics, and may + impose additional restrictions on syntax, but must conform to the + required syntax for the "multipart" type. This requirement ensures + that all conformant user agents will at least be able to recognize + and separate the parts of any multipart entity, even those of an + unrecognized subtype. + + As stated in the definition of the Content-Transfer-Encoding field + [RFC 2045], no encoding other than "7bit", "8bit", or "binary" is + permitted for entities of type "multipart". The "multipart" boundary + delimiters and header fields are always represented as 7bit US-ASCII + in any case (though the header fields may encode non-US-ASCII header + text as per RFC 2047) and data within the body parts can be encoded + on a part-by-part basis, with Content-Transfer-Encoding fields for + each appropriate body part. + + + +Freed & Borenstein Standards Track [Page 18] + +RFC 2046 Media Types November 1996 + + +5.1.1. Common Syntax + + This section defines a common syntax for subtypes of "multipart". + All subtypes of "multipart" must use this syntax. A simple example + of a multipart message also appears in this section. An example of a + more complex multipart message is given in RFC 2049. + + The Content-Type field for multipart entities requires one parameter, + "boundary". The boundary delimiter line is then defined as a line + consisting entirely of two hyphen characters ("-", decimal value 45) + followed by the boundary parameter value from the Content-Type header + field, optional linear whitespace, and a terminating CRLF. + + NOTE: The hyphens are for rough compatibility with the earlier RFC + 934 method of message encapsulation, and for ease of searching for + the boundaries in some implementations. However, it should be noted + that multipart messages are NOT completely compatible with RFC 934 + encapsulations; in particular, they do not obey RFC 934 quoting + conventions for embedded lines that begin with hyphens. This + mechanism was chosen over the RFC 934 mechanism because the latter + causes lines to grow with each level of quoting. The combination of + this growth with the fact that SMTP implementations sometimes wrap + long lines made the RFC 934 mechanism unsuitable for use in the event + that deeply-nested multipart structuring is ever desired. + + WARNING TO IMPLEMENTORS: The grammar for parameters on the Content- + type field is such that it is often necessary to enclose the boundary + parameter values in quotes on the Content-type line. This is not + always necessary, but never hurts. Implementors should be sure to + study the grammar carefully in order to avoid producing invalid + Content-type fields. Thus, a typical "multipart" Content-Type header + field might look like this: + + Content-Type: multipart/mixed; boundary=gc0p4Jq0M2Yt08j34c0p + + But the following is not valid: + + Content-Type: multipart/mixed; boundary=gc0pJq0M:08jU534c0p + + (because of the colon) and must instead be represented as + + Content-Type: multipart/mixed; boundary="gc0pJq0M:08jU534c0p" + + This Content-Type value indicates that the content consists of one or + more parts, each with a structure that is syntactically identical to + an RFC 822 message, except that the header area is allowed to be + completely empty, and that the parts are each preceded by the line + + + + +Freed & Borenstein Standards Track [Page 19] + +RFC 2046 Media Types November 1996 + + + --gc0pJq0M:08jU534c0p + + The boundary delimiter MUST occur at the beginning of a line, i.e., + following a CRLF, and the initial CRLF is considered to be attached + to the boundary delimiter line rather than part of the preceding + part. The boundary may be followed by zero or more characters of + linear whitespace. It is then terminated by either another CRLF and + the header fields for the next part, or by two CRLFs, in which case + there are no header fields for the next part. If no Content-Type + field is present it is assumed to be "message/rfc822" in a + "multipart/digest" and "text/plain" otherwise. + + NOTE: The CRLF preceding the boundary delimiter line is conceptually + attached to the boundary so that it is possible to have a part that + does not end with a CRLF (line break). Body parts that must be + considered to end with line breaks, therefore, must have two CRLFs + preceding the boundary delimiter line, the first of which is part of + the preceding body part, and the second of which is part of the + encapsulation boundary. + + Boundary delimiters must not appear within the encapsulated material, + and must be no longer than 70 characters, not counting the two + leading hyphens. + + The boundary delimiter line following the last body part is a + distinguished delimiter that indicates that no further body parts + will follow. Such a delimiter line is identical to the previous + delimiter lines, with the addition of two more hyphens after the + boundary parameter value. + + --gc0pJq0M:08jU534c0p-- + + NOTE TO IMPLEMENTORS: Boundary string comparisons must compare the + boundary value with the beginning of each candidate line. An exact + match of the entire candidate line is not required; it is sufficient + that the boundary appear in its entirety following the CRLF. + + There appears to be room for additional information prior to the + first boundary delimiter line and following the final boundary + delimiter line. These areas should generally be left blank, and + implementations must ignore anything that appears before the first + boundary delimiter line or after the last one. + + NOTE: These "preamble" and "epilogue" areas are generally not used + because of the lack of proper typing of these parts and the lack of + clear semantics for handling these areas at gateways, particularly + X.400 gateways. However, rather than leaving the preamble area + blank, many MIME implementations have found this to be a convenient + + + +Freed & Borenstein Standards Track [Page 20] + +RFC 2046 Media Types November 1996 + + + place to insert an explanatory note for recipients who read the + message with pre-MIME software, since such notes will be ignored by + MIME-compliant software. + + NOTE: Because boundary delimiters must not appear in the body parts + being encapsulated, a user agent must exercise care to choose a + unique boundary parameter value. The boundary parameter value in the + example above could have been the result of an algorithm designed to + produce boundary delimiters with a very low probability of already + existing in the data to be encapsulated without having to prescan the + data. Alternate algorithms might result in more "readable" boundary + delimiters for a recipient with an old user agent, but would require + more attention to the possibility that the boundary delimiter might + appear at the beginning of some line in the encapsulated part. The + simplest boundary delimiter line possible is something like "---", + with a closing boundary delimiter line of "-----". + + As a very simple example, the following multipart message has two + parts, both of them plain text, one of them explicitly typed and one + of them implicitly typed: + + From: Nathaniel Borenstein + To: Ned Freed + Date: Sun, 21 Mar 1993 23:56:48 -0800 (PST) + Subject: Sample message + MIME-Version: 1.0 + Content-type: multipart/mixed; boundary="simple boundary" + + This is the preamble. It is to be ignored, though it + is a handy place for composition agents to include an + explanatory note to non-MIME conformant readers. + + --simple boundary + + This is implicitly typed plain US-ASCII text. + It does NOT end with a linebreak. + --simple boundary + Content-type: text/plain; charset=us-ascii + + This is explicitly typed plain US-ASCII text. + It DOES end with a linebreak. + + --simple boundary-- + + This is the epilogue. It is also to be ignored. + + + + + + +Freed & Borenstein Standards Track [Page 21] + +RFC 2046 Media Types November 1996 + + + The use of a media type of "multipart" in a body part within another + "multipart" entity is explicitly allowed. In such cases, for obvious + reasons, care must be taken to ensure that each nested "multipart" + entity uses a different boundary delimiter. See RFC 2049 for an + example of nested "multipart" entities. + + The use of the "multipart" media type with only a single body part + may be useful in certain contexts, and is explicitly permitted. + + NOTE: Experience has shown that a "multipart" media type with a + single body part is useful for sending non-text media types. It has + the advantage of providing the preamble as a place to include + decoding instructions. In addition, a number of SMTP gateways move + or remove the MIME headers, and a clever MIME decoder can take a good + guess at multipart boundaries even in the absence of the Content-Type + header and thereby successfully decode the message. + + The only mandatory global parameter for the "multipart" media type is + the boundary parameter, which consists of 1 to 70 characters from a + set of characters known to be very robust through mail gateways, and + NOT ending with white space. (If a boundary delimiter line appears to + end with white space, the white space must be presumed to have been + added by a gateway, and must be deleted.) It is formally specified + by the following BNF: + + boundary := 0*69 bcharsnospace + + bchars := bcharsnospace / " " + + bcharsnospace := DIGIT / ALPHA / "'" / "(" / ")" / + "+" / "_" / "," / "-" / "." / + "/" / ":" / "=" / "?" + + Overall, the body of a "multipart" entity may be specified as + follows: + + dash-boundary := "--" boundary + ; boundary taken from the value of + ; boundary parameter of the + ; Content-Type field. + + multipart-body := [preamble CRLF] + dash-boundary transport-padding CRLF + body-part *encapsulation + close-delimiter transport-padding + [CRLF epilogue] + + + + + +Freed & Borenstein Standards Track [Page 22] + +RFC 2046 Media Types November 1996 + + + transport-padding := *LWSP-char + ; Composers MUST NOT generate + ; non-zero length transport + ; padding, but receivers MUST + ; be able to handle padding + ; added by message transports. + + encapsulation := delimiter transport-padding + CRLF body-part + + delimiter := CRLF dash-boundary + + close-delimiter := delimiter "--" + + preamble := discard-text + + epilogue := discard-text + + discard-text := *(*text CRLF) *text + ; May be ignored or discarded. + + body-part := MIME-part-headers [CRLF *OCTET] + ; Lines in a body-part must not start + ; with the specified dash-boundary and + ; the delimiter must not appear anywhere + ; in the body part. Note that the + ; semantics of a body-part differ from + ; the semantics of a message, as + ; described in the text. + + OCTET := + + IMPORTANT: The free insertion of linear-white-space and RFC 822 + comments between the elements shown in this BNF is NOT allowed since + this BNF does not specify a structured header field. + + NOTE: In certain transport enclaves, RFC 822 restrictions such as + the one that limits bodies to printable US-ASCII characters may not + be in force. (That is, the transport domains may exist that resemble + standard Internet mail transport as specified in RFC 821 and assumed + by RFC 822, but without certain restrictions.) The relaxation of + these restrictions should be construed as locally extending the + definition of bodies, for example to include octets outside of the + US-ASCII range, as long as these extensions are supported by the + transport and adequately documented in the Content- Transfer-Encoding + header field. However, in no event are headers (either message + headers or body part headers) allowed to contain anything other than + US-ASCII characters. + + + +Freed & Borenstein Standards Track [Page 23] + +RFC 2046 Media Types November 1996 + + + NOTE: Conspicuously missing from the "multipart" type is a notion of + structured, related body parts. It is recommended that those wishing + to provide more structured or integrated multipart messaging + facilities should define subtypes of multipart that are syntactically + identical but define relationships between the various parts. For + example, subtypes of multipart could be defined that include a + distinguished part which in turn is used to specify the relationships + between the other parts, probably referring to them by their + Content-ID field. Old implementations will not recognize the new + subtype if this approach is used, but will treat it as + multipart/mixed and will thus be able to show the user the parts that + are recognized. + +5.1.2. Handling Nested Messages and Multiparts + + The "message/rfc822" subtype defined in a subsequent section of this + document has no terminating condition other than running out of data. + Similarly, an improperly truncated "multipart" entity may not have + any terminating boundary marker, and can turn up operationally due to + mail system malfunctions. + + It is essential that such entities be handled correctly when they are + themselves imbedded inside of another "multipart" structure. MIME + implementations are therefore required to recognize outer level + boundary markers at ANY level of inner nesting. It is not sufficient + to only check for the next expected marker or other terminating + condition. + +5.1.3. Mixed Subtype + + The "mixed" subtype of "multipart" is intended for use when the body + parts are independent and need to be bundled in a particular order. + Any "multipart" subtypes that an implementation does not recognize + must be treated as being of subtype "mixed". + +5.1.4. Alternative Subtype + + The "multipart/alternative" type is syntactically identical to + "multipart/mixed", but the semantics are different. In particular, + each of the body parts is an "alternative" version of the same + information. + + Systems should recognize that the content of the various parts are + interchangeable. Systems should choose the "best" type based on the + local environment and references, in some cases even through user + interaction. As with "multipart/mixed", the order of body parts is + significant. In this case, the alternatives appear in an order of + increasing faithfulness to the original content. In general, the + + + +Freed & Borenstein Standards Track [Page 24] + +RFC 2046 Media Types November 1996 + + + best choice is the LAST part of a type supported by the recipient + system's local environment. + + "Multipart/alternative" may be used, for example, to send a message + in a fancy text format in such a way that it can easily be displayed + anywhere: + + From: Nathaniel Borenstein + To: Ned Freed + Date: Mon, 22 Mar 1993 09:41:09 -0800 (PST) + Subject: Formatted text mail + MIME-Version: 1.0 + Content-Type: multipart/alternative; boundary=boundary42 + + --boundary42 + Content-Type: text/plain; charset=us-ascii + + ... plain text version of message goes here ... + + --boundary42 + Content-Type: text/enriched + + ... RFC 1896 text/enriched version of same message + goes here ... + + --boundary42 + Content-Type: application/x-whatever + + ... fanciest version of same message goes here ... + + --boundary42-- + + In this example, users whose mail systems understood the + "application/x-whatever" format would see only the fancy version, + while other users would see only the enriched or plain text version, + depending on the capabilities of their system. + + In general, user agents that compose "multipart/alternative" entities + must place the body parts in increasing order of preference, that is, + with the preferred format last. For fancy text, the sending user + agent should put the plainest format first and the richest format + last. Receiving user agents should pick and display the last format + they are capable of displaying. In the case where one of the + alternatives is itself of type "multipart" and contains unrecognized + sub-parts, the user agent may choose either to show that alternative, + an earlier alternative, or both. + + + + + +Freed & Borenstein Standards Track [Page 25] + +RFC 2046 Media Types November 1996 + + + NOTE: From an implementor's perspective, it might seem more sensible + to reverse this ordering, and have the plainest alternative last. + However, placing the plainest alternative first is the friendliest + possible option when "multipart/alternative" entities are viewed + using a non-MIME-conformant viewer. While this approach does impose + some burden on conformant MIME viewers, interoperability with older + mail readers was deemed to be more important in this case. + + It may be the case that some user agents, if they can recognize more + than one of the formats, will prefer to offer the user the choice of + which format to view. This makes sense, for example, if a message + includes both a nicely- formatted image version and an easily-edited + text version. What is most critical, however, is that the user not + automatically be shown multiple versions of the same data. Either + the user should be shown the last recognized version or should be + given the choice. + + THE SEMANTICS OF CONTENT-ID IN MULTIPART/ALTERNATIVE: Each part of a + "multipart/alternative" entity represents the same data, but the + mappings between the two are not necessarily without information + loss. For example, information is lost when translating ODA to + PostScript or plain text. It is recommended that each part should + have a different Content-ID value in the case where the information + content of the two parts is not identical. And when the information + content is identical -- for example, where several parts of type + "message/external-body" specify alternate ways to access the + identical data -- the same Content-ID field value should be used, to + optimize any caching mechanisms that might be present on the + recipient's end. However, the Content-ID values used by the parts + should NOT be the same Content-ID value that describes the + "multipart/alternative" as a whole, if there is any such Content-ID + field. That is, one Content-ID value will refer to the + "multipart/alternative" entity, while one or more other Content-ID + values will refer to the parts inside it. + +5.1.5. Digest Subtype + + This document defines a "digest" subtype of the "multipart" Content- + Type. This type is syntactically identical to "multipart/mixed", but + the semantics are different. In particular, in a digest, the default + Content-Type value for a body part is changed from "text/plain" to + "message/rfc822". This is done to allow a more readable digest + format that is largely compatible (except for the quoting convention) + with RFC 934. + + Note: Though it is possible to specify a Content-Type value for a + body part in a digest which is other than "message/rfc822", such as a + "text/plain" part containing a description of the material in the + + + +Freed & Borenstein Standards Track [Page 26] + +RFC 2046 Media Types November 1996 + + + digest, actually doing so is undesireble. The "multipart/digest" + Content-Type is intended to be used to send collections of messages. + If a "text/plain" part is needed, it should be included as a seperate + part of a "multipart/mixed" message. + + A digest in this format might, then, look something like this: + + From: Moderator-Address + To: Recipient-List + Date: Mon, 22 Mar 1994 13:34:51 +0000 + Subject: Internet Digest, volume 42 + MIME-Version: 1.0 + Content-Type: multipart/mixed; + boundary="---- main boundary ----" + + ------ main boundary ---- + + ...Introductory text or table of contents... + + ------ main boundary ---- + Content-Type: multipart/digest; + boundary="---- next message ----" + + ------ next message ---- + + From: someone-else + Date: Fri, 26 Mar 1993 11:13:32 +0200 + Subject: my opinion + + ...body goes here ... + + ------ next message ---- + + From: someone-else-again + Date: Fri, 26 Mar 1993 10:07:13 -0500 + Subject: my different opinion + + ... another body goes here ... + + ------ next message ------ + + ------ main boundary ------ + +5.1.6. Parallel Subtype + + This document defines a "parallel" subtype of the "multipart" + Content-Type. This type is syntactically identical to + "multipart/mixed", but the semantics are different. In particular, + + + +Freed & Borenstein Standards Track [Page 27] + +RFC 2046 Media Types November 1996 + + + in a parallel entity, the order of body parts is not significant. + + A common presentation of this type is to display all of the parts + simultaneously on hardware and software that are capable of doing so. + However, composing agents should be aware that many mail readers will + lack this capability and will show the parts serially in any event. + +5.1.7. Other Multipart Subtypes + + Other "multipart" subtypes are expected in the future. MIME + implementations must in general treat unrecognized subtypes of + "multipart" as being equivalent to "multipart/mixed". + +5.2. Message Media Type + + It is frequently desirable, in sending mail, to encapsulate another + mail message. A special media type, "message", is defined to + facilitate this. In particular, the "rfc822" subtype of "message" is + used to encapsulate RFC 822 messages. + + NOTE: It has been suggested that subtypes of "message" might be + defined for forwarded or rejected messages. However, forwarded and + rejected messages can be handled as multipart messages in which the + first part contains any control or descriptive information, and a + second part, of type "message/rfc822", is the forwarded or rejected + message. Composing rejection and forwarding messages in this manner + will preserve the type information on the original message and allow + it to be correctly presented to the recipient, and hence is strongly + encouraged. + + Subtypes of "message" often impose restrictions on what encodings are + allowed. These restrictions are described in conjunction with each + specific subtype. + + Mail gateways, relays, and other mail handling agents are commonly + known to alter the top-level header of an RFC 822 message. In + particular, they frequently add, remove, or reorder header fields. + These operations are explicitly forbidden for the encapsulated + headers embedded in the bodies of messages of type "message." + +5.2.1. RFC822 Subtype + + A media type of "message/rfc822" indicates that the body contains an + encapsulated message, with the syntax of an RFC 822 message. + However, unlike top-level RFC 822 messages, the restriction that each + "message/rfc822" body must include a "From", "Date", and at least one + destination header is removed and replaced with the requirement that + at least one of "From", "Subject", or "Date" must be present. + + + +Freed & Borenstein Standards Track [Page 28] + +RFC 2046 Media Types November 1996 + + + It should be noted that, despite the use of the numbers "822", a + "message/rfc822" entity isn't restricted to material in strict + conformance to RFC822, nor are the semantics of "message/rfc822" + objects restricted to the semantics defined in RFC822. More + specifically, a "message/rfc822" message could well be a News article + or a MIME message. + + No encoding other than "7bit", "8bit", or "binary" is permitted for + the body of a "message/rfc822" entity. The message header fields are + always US-ASCII in any case, and data within the body can still be + encoded, in which case the Content-Transfer-Encoding header field in + the encapsulated message will reflect this. Non-US-ASCII text in the + headers of an encapsulated message can be specified using the + mechanisms described in RFC 2047. + +5.2.2. Partial Subtype + + The "partial" subtype is defined to allow large entities to be + delivered as several separate pieces of mail and automatically + reassembled by a receiving user agent. (The concept is similar to IP + fragmentation and reassembly in the basic Internet Protocols.) This + mechanism can be used when intermediate transport agents limit the + size of individual messages that can be sent. The media type + "message/partial" thus indicates that the body contains a fragment of + a larger entity. + + Because data of type "message" may never be encoded in base64 or + quoted-printable, a problem might arise if "message/partial" entities + are constructed in an environment that supports binary or 8bit + transport. The problem is that the binary data would be split into + multiple "message/partial" messages, each of them requiring binary + transport. If such messages were encountered at a gateway into a + 7bit transport environment, there would be no way to properly encode + them for the 7bit world, aside from waiting for all of the fragments, + reassembling the inner message, and then encoding the reassembled + data in base64 or quoted-printable. Since it is possible that + different fragments might go through different gateways, even this is + not an acceptable solution. For this reason, it is specified that + entities of type "message/partial" must always have a content- + transfer-encoding of 7bit (the default). In particular, even in + environments that support binary or 8bit transport, the use of a + content- transfer-encoding of "8bit" or "binary" is explicitly + prohibited for MIME entities of type "message/partial". This in turn + implies that the inner message must not use "8bit" or "binary" + encoding. + + + + + + +Freed & Borenstein Standards Track [Page 29] + +RFC 2046 Media Types November 1996 + + + Because some message transfer agents may choose to automatically + fragment large messages, and because such agents may use very + different fragmentation thresholds, it is possible that the pieces of + a partial message, upon reassembly, may prove themselves to comprise + a partial message. This is explicitly permitted. + + Three parameters must be specified in the Content-Type field of type + "message/partial": The first, "id", is a unique identifier, as close + to a world-unique identifier as possible, to be used to match the + fragments together. (In general, the identifier is essentially a + message-id; if placed in double quotes, it can be ANY message-id, in + accordance with the BNF for "parameter" given in RFC 2045.) The + second, "number", an integer, is the fragment number, which indicates + where this fragment fits into the sequence of fragments. The third, + "total", another integer, is the total number of fragments. This + third subfield is required on the final fragment, and is optional + (though encouraged) on the earlier fragments. Note also that these + parameters may be given in any order. + + Thus, the second piece of a 3-piece message may have either of the + following header fields: + + Content-Type: Message/Partial; number=2; total=3; + id="oc=jpbe0M2Yt4s@thumper.bellcore.com" + + Content-Type: Message/Partial; + id="oc=jpbe0M2Yt4s@thumper.bellcore.com"; + number=2 + + But the third piece MUST specify the total number of fragments: + + Content-Type: Message/Partial; number=3; total=3; + id="oc=jpbe0M2Yt4s@thumper.bellcore.com" + + Note that fragment numbering begins with 1, not 0. + + When the fragments of an entity broken up in this manner are put + together, the result is always a complete MIME entity, which may have + its own Content-Type header field, and thus may contain any other + data type. + +5.2.2.1. Message Fragmentation and Reassembly + + The semantics of a reassembled partial message must be those of the + "inner" message, rather than of a message containing the inner + message. This makes it possible, for example, to send a large audio + message as several partial messages, and still have it appear to the + recipient as a simple audio message rather than as an encapsulated + + + +Freed & Borenstein Standards Track [Page 30] + +RFC 2046 Media Types November 1996 + + + message containing an audio message. That is, the encapsulation of + the message is considered to be "transparent". + + When generating and reassembling the pieces of a "message/partial" + message, the headers of the encapsulated message must be merged with + the headers of the enclosing entities. In this process the following + rules must be observed: + + (1) Fragmentation agents must split messages at line + boundaries only. This restriction is imposed because + splits at points other than the ends of lines in turn + depends on message transports being able to preserve + the semantics of messages that don't end with a CRLF + sequence. Many transports are incapable of preserving + such semantics. + + (2) All of the header fields from the initial enclosing + message, except those that start with "Content-" and + the specific header fields "Subject", "Message-ID", + "Encrypted", and "MIME-Version", must be copied, in + order, to the new message. + + (3) The header fields in the enclosed message which start + with "Content-", plus the "Subject", "Message-ID", + "Encrypted", and "MIME-Version" fields, must be + appended, in order, to the header fields of the new + message. Any header fields in the enclosed message + which do not start with "Content-" (except for the + "Subject", "Message-ID", "Encrypted", and "MIME- + Version" fields) will be ignored and dropped. + + (4) All of the header fields from the second and any + subsequent enclosing messages are discarded by the + reassembly process. + +5.2.2.2. Fragmentation and Reassembly Example + + If an audio message is broken into two pieces, the first piece might + look something like this: + + X-Weird-Header-1: Foo + From: Bill@host.com + To: joe@otherhost.com + Date: Fri, 26 Mar 1993 12:59:38 -0500 (EST) + Subject: Audio mail (part 1 of 2) + Message-ID: + MIME-Version: 1.0 + Content-type: message/partial; id="ABC@host.com"; + + + +Freed & Borenstein Standards Track [Page 31] + +RFC 2046 Media Types November 1996 + + + number=1; total=2 + + X-Weird-Header-1: Bar + X-Weird-Header-2: Hello + Message-ID: + Subject: Audio mail + MIME-Version: 1.0 + Content-type: audio/basic + Content-transfer-encoding: base64 + + ... first half of encoded audio data goes here ... + + and the second half might look something like this: + + From: Bill@host.com + To: joe@otherhost.com + Date: Fri, 26 Mar 1993 12:59:38 -0500 (EST) + Subject: Audio mail (part 2 of 2) + MIME-Version: 1.0 + Message-ID: + Content-type: message/partial; + id="ABC@host.com"; number=2; total=2 + + ... second half of encoded audio data goes here ... + + Then, when the fragmented message is reassembled, the resulting + message to be displayed to the user should look something like this: + + X-Weird-Header-1: Foo + From: Bill@host.com + To: joe@otherhost.com + Date: Fri, 26 Mar 1993 12:59:38 -0500 (EST) + Subject: Audio mail + Message-ID: + MIME-Version: 1.0 + Content-type: audio/basic + Content-transfer-encoding: base64 + + ... first half of encoded audio data goes here ... + ... second half of encoded audio data goes here ... + + The inclusion of a "References" field in the headers of the second + and subsequent pieces of a fragmented message that references the + Message-Id on the previous piece may be of benefit to mail readers + that understand and track references. However, the generation of + such "References" fields is entirely optional. + + + + + +Freed & Borenstein Standards Track [Page 32] + +RFC 2046 Media Types November 1996 + + + Finally, it should be noted that the "Encrypted" header field has + been made obsolete by Privacy Enhanced Messaging (PEM) [RFC-1421, + RFC-1422, RFC-1423, RFC-1424], but the rules above are nevertheless + believed to describe the correct way to treat it if it is encountered + in the context of conversion to and from "message/partial" fragments. + +5.2.3. External-Body Subtype + + The external-body subtype indicates that the actual body data are not + included, but merely referenced. In this case, the parameters + describe a mechanism for accessing the external data. + + When a MIME entity is of type "message/external-body", it consists of + a header, two consecutive CRLFs, and the message header for the + encapsulated message. If another pair of consecutive CRLFs appears, + this of course ends the message header for the encapsulated message. + However, since the encapsulated message's body is itself external, it + does NOT appear in the area that follows. For example, consider the + following message: + + Content-type: message/external-body; + access-type=local-file; + name="/u/nsb/Me.jpeg" + + Content-type: image/jpeg + Content-ID: + Content-Transfer-Encoding: binary + + THIS IS NOT REALLY THE BODY! + + The area at the end, which might be called the "phantom body", is + ignored for most external-body messages. However, it may be used to + contain auxiliary information for some such messages, as indeed it is + when the access-type is "mail- server". The only access-type defined + in this document that uses the phantom body is "mail-server", but + other access-types may be defined in the future in other + specifications that use this area. + + The encapsulated headers in ALL "message/external-body" entities MUST + include a Content-ID header field to give a unique identifier by + which to reference the data. This identifier may be used for caching + mechanisms, and for recognizing the receipt of the data when the + access-type is "mail-server". + + Note that, as specified here, the tokens that describe external-body + data, such as file names and mail server commands, are required to be + in the US-ASCII character set. + + + + +Freed & Borenstein Standards Track [Page 33] + +RFC 2046 Media Types November 1996 + + + If this proves problematic in practice, a new mechanism may be + required as a future extension to MIME, either as newly defined + access-types for "message/external-body" or by some other mechanism. + + As with "message/partial", MIME entities of type "message/external- + body" MUST have a content-transfer-encoding of 7bit (the default). + In particular, even in environments that support binary or 8bit + transport, the use of a content- transfer-encoding of "8bit" or + "binary" is explicitly prohibited for entities of type + "message/external-body". + +5.2.3.1. General External-Body Parameters + + The parameters that may be used with any "message/external- body" + are: + + (1) ACCESS-TYPE -- A word indicating the supported access + mechanism by which the file or data may be obtained. + This word is not case sensitive. Values include, but + are not limited to, "FTP", "ANON-FTP", "TFTP", "LOCAL- + FILE", and "MAIL-SERVER". Future values, except for + experimental values beginning with "X-", must be + registered with IANA, as described in RFC 2048. + This parameter is unconditionally mandatory and MUST be + present on EVERY "message/external-body". + + (2) EXPIRATION -- The date (in the RFC 822 "date-time" + syntax, as extended by RFC 1123 to permit 4 digits in + the year field) after which the existence of the + external data is not guaranteed. This parameter may be + used with ANY access-type and is ALWAYS optional. + + (3) SIZE -- The size (in octets) of the data. The intent + of this parameter is to help the recipient decide + whether or not to expend the necessary resources to + retrieve the external data. Note that this describes + the size of the data in its canonical form, that is, + before any Content-Transfer-Encoding has been applied + or after the data have been decoded. This parameter + may be used with ANY access-type and is ALWAYS + optional. + + (4) PERMISSION -- A case-insensitive field that indicates + whether or not it is expected that clients might also + attempt to overwrite the data. By default, or if + permission is "read", the assumption is that they are + not, and that if the data is retrieved once, it is + never needed again. If PERMISSION is "read-write", + + + +Freed & Borenstein Standards Track [Page 34] + +RFC 2046 Media Types November 1996 + + + this assumption is invalid, and any local copy must be + considered no more than a cache. "Read" and "Read- + write" are the only defined values of permission. This + parameter may be used with ANY access-type and is + ALWAYS optional. + + The precise semantics of the access-types defined here are described + in the sections that follow. + +5.2.3.2. The 'ftp' and 'tftp' Access-Types + + An access-type of FTP or TFTP indicates that the message body is + accessible as a file using the FTP [RFC-959] or TFTP [RFC- 783] + protocols, respectively. For these access-types, the following + additional parameters are mandatory: + + (1) NAME -- The name of the file that contains the actual + body data. + + (2) SITE -- A machine from which the file may be obtained, + using the given protocol. This must be a fully + qualified domain name, not a nickname. + + (3) Before any data are retrieved, using FTP, the user will + generally need to be asked to provide a login id and a + password for the machine named by the site parameter. + For security reasons, such an id and password are not + specified as content-type parameters, but must be + obtained from the user. + + In addition, the following parameters are optional: + + (1) DIRECTORY -- A directory from which the data named by + NAME should be retrieved. + + (2) MODE -- A case-insensitive string indicating the mode + to be used when retrieving the information. The valid + values for access-type "TFTP" are "NETASCII", "OCTET", + and "MAIL", as specified by the TFTP protocol [RFC- + 783]. The valid values for access-type "FTP" are + "ASCII", "EBCDIC", "IMAGE", and "LOCALn" where "n" is a + decimal integer, typically 8. These correspond to the + representation types "A" "E" "I" and "L n" as specified + by the FTP protocol [RFC-959]. Note that "BINARY" and + "TENEX" are not valid values for MODE and that "OCTET" + or "IMAGE" or "LOCAL8" should be used instead. IF MODE + is not specified, the default value is "NETASCII" for + TFTP and "ASCII" otherwise. + + + +Freed & Borenstein Standards Track [Page 35] + +RFC 2046 Media Types November 1996 + + +5.2.3.3. The 'anon-ftp' Access-Type + + The "anon-ftp" access-type is identical to the "ftp" access type, + except that the user need not be asked to provide a name and password + for the specified site. Instead, the ftp protocol will be used with + login "anonymous" and a password that corresponds to the user's mail + address. + +5.2.3.4. The 'local-file' Access-Type + + An access-type of "local-file" indicates that the actual body is + accessible as a file on the local machine. Two additional parameters + are defined for this access type: + + (1) NAME -- The name of the file that contains the actual + body data. This parameter is mandatory for the + "local-file" access-type. + + (2) SITE -- A domain specifier for a machine or set of + machines that are known to have access to the data + file. This optional parameter is used to describe the + locality of reference for the data, that is, the site + or sites at which the file is expected to be visible. + Asterisks may be used for wildcard matching to a part + of a domain name, such as "*.bellcore.com", to indicate + a set of machines on which the data should be directly + visible, while a single asterisk may be used to + indicate a file that is expected to be universally + available, e.g., via a global file system. + +5.2.3.5. The 'mail-server' Access-Type + + The "mail-server" access-type indicates that the actual body is + available from a mail server. Two additional parameters are defined + for this access-type: + + (1) SERVER -- The addr-spec of the mail server from which + the actual body data can be obtained. This parameter + is mandatory for the "mail-server" access-type. + + (2) SUBJECT -- The subject that is to be used in the mail + that is sent to obtain the data. Note that keying mail + servers on Subject lines is NOT recommended, but such + mail servers are known to exist. This is an optional + parameter. + + + + + + +Freed & Borenstein Standards Track [Page 36] + +RFC 2046 Media Types November 1996 + + + Because mail servers accept a variety of syntaxes, some of which is + multiline, the full command to be sent to a mail server is not + included as a parameter in the content-type header field. Instead, + it is provided as the "phantom body" when the media type is + "message/external-body" and the access-type is mail-server. + + Note that MIME does not define a mail server syntax. Rather, it + allows the inclusion of arbitrary mail server commands in the phantom + body. Implementations must include the phantom body in the body of + the message it sends to the mail server address to retrieve the + relevant data. + + Unlike other access-types, mail-server access is asynchronous and + will happen at an unpredictable time in the future. For this reason, + it is important that there be a mechanism by which the returned data + can be matched up with the original "message/external-body" entity. + MIME mail servers must use the same Content-ID field on the returned + message that was used in the original "message/external-body" + entities, to facilitate such matching. + +5.2.3.6. External-Body Security Issues + + "Message/external-body" entities give rise to two important security + issues: + + (1) Accessing data via a "message/external-body" reference + effectively results in the message recipient performing + an operation that was specified by the message + originator. It is therefore possible for the message + originator to trick a recipient into doing something + they would not have done otherwise. For example, an + originator could specify a action that attempts + retrieval of material that the recipient is not + authorized to obtain, causing the recipient to + unwittingly violate some security policy. For this + reason, user agents capable of resolving external + references must always take steps to describe the + action they are to take to the recipient and ask for + explicit permisssion prior to performing it. + + The 'mail-server' access-type is particularly + vulnerable, in that it causes the recipient to send a + new message whose contents are specified by the + original message's originator. Given the potential for + abuse, any such request messages that are constructed + should contain a clear indication that they were + generated automatically (e.g. in a Comments: header + field) in an attempt to resolve a MIME + + + +Freed & Borenstein Standards Track [Page 37] + +RFC 2046 Media Types November 1996 + + + "message/external-body" reference. + + (2) MIME will sometimes be used in environments that + provide some guarantee of message integrity and + authenticity. If present, such guarantees may apply + only to the actual direct content of messages -- they + may or may not apply to data accessed through MIME's + "message/external-body" mechanism. In particular, it + may be possible to subvert certain access mechanisms + even when the messaging system itself is secure. + + It should be noted that this problem exists either with + or without the availabilty of MIME mechanisms. A + casual reference to an FTP site containing a document + in the text of a secure message brings up similar + issues -- the only difference is that MIME provides for + automatic retrieval of such material, and users may + place unwarranted trust is such automatic retrieval + mechanisms. + +5.2.3.7. Examples and Further Explanations + + When the external-body mechanism is used in conjunction with the + "multipart/alternative" media type it extends the functionality of + "multipart/alternative" to include the case where the same entity is + provided in the same format but via different accces mechanisms. + When this is done the originator of the message must order the parts + first in terms of preferred formats and then by preferred access + mechanisms. The recipient's viewer should then evaluate the list + both in terms of format and access mechanisms. + + With the emerging possibility of very wide-area file systems, it + becomes very hard to know in advance the set of machines where a file + will and will not be accessible directly from the file system. + Therefore it may make sense to provide both a file name, to be tried + directly, and the name of one or more sites from which the file is + known to be accessible. An implementation can try to retrieve remote + files using FTP or any other protocol, using anonymous file retrieval + or prompting the user for the necessary name and password. If an + external body is accessible via multiple mechanisms, the sender may + include multiple entities of type "message/external-body" within the + body parts of an enclosing "multipart/alternative" entity. + + However, the external-body mechanism is not intended to be limited to + file retrieval, as shown by the mail-server access-type. Beyond + this, one can imagine, for example, using a video server for external + references to video clips. + + + + +Freed & Borenstein Standards Track [Page 38] + +RFC 2046 Media Types November 1996 + + + The embedded message header fields which appear in the body of the + "message/external-body" data must be used to declare the media type + of the external body if it is anything other than plain US-ASCII + text, since the external body does not have a header section to + declare its type. Similarly, any Content-transfer-encoding other + than "7bit" must also be declared here. Thus a complete + "message/external-body" message, referring to an object in PostScript + format, might look like this: + + From: Whomever + To: Someone + Date: Whenever + Subject: whatever + MIME-Version: 1.0 + Message-ID: + Content-Type: multipart/alternative; boundary=42 + Content-ID: + + --42 + Content-Type: message/external-body; name="BodyFormats.ps"; + site="thumper.bellcore.com"; mode="image"; + access-type=ANON-FTP; directory="pub"; + expiration="Fri, 14 Jun 1991 19:13:14 -0400 (EDT)" + + Content-type: application/postscript + Content-ID: + + --42 + Content-Type: message/external-body; access-type=local-file; + name="/u/nsb/writing/rfcs/RFC-MIME.ps"; + site="thumper.bellcore.com"; + expiration="Fri, 14 Jun 1991 19:13:14 -0400 (EDT)" + + Content-type: application/postscript + Content-ID: + + --42 + Content-Type: message/external-body; + access-type=mail-server + server="listserv@bogus.bitnet"; + expiration="Fri, 14 Jun 1991 19:13:14 -0400 (EDT)" + + Content-type: application/postscript + Content-ID: + + get RFC-MIME.DOC + + --42-- + + + +Freed & Borenstein Standards Track [Page 39] + +RFC 2046 Media Types November 1996 + + + Note that in the above examples, the default Content-transfer- + encoding of "7bit" is assumed for the external postscript data. + + Like the "message/partial" type, the "message/external-body" media + type is intended to be transparent, that is, to convey the data type + in the external body rather than to convey a message with a body of + that type. Thus the headers on the outer and inner parts must be + merged using the same rules as for "message/partial". In particular, + this means that the Content-type and Subject fields are overridden, + but the From field is preserved. + + Note that since the external bodies are not transported along with + the external body reference, they need not conform to transport + limitations that apply to the reference itself. In particular, + Internet mail transports may impose 7bit and line length limits, but + these do not automatically apply to binary external body references. + Thus a Content-Transfer-Encoding is not generally necessary, though + it is permitted. + + Note that the body of a message of type "message/external-body" is + governed by the basic syntax for an RFC 822 message. In particular, + anything before the first consecutive pair of CRLFs is header + information, while anything after it is body information, which is + ignored for most access-types. + +5.2.4. Other Message Subtypes + + MIME implementations must in general treat unrecognized subtypes of + "message" as being equivalent to "application/octet-stream". + + Future subtypes of "message" intended for use with email should be + restricted to "7bit" encoding. A type other than "message" should be + used if restriction to "7bit" is not possible. + +6. Experimental Media Type Values + + A media type value beginning with the characters "X-" is a private + value, to be used by consenting systems by mutual agreement. Any + format without a rigorous and public definition must be named with an + "X-" prefix, and publicly specified values shall never begin with + "X-". (Older versions of the widely used Andrew system use the "X- + BE2" name, so new systems should probably choose a different name.) + + In general, the use of "X-" top-level types is strongly discouraged. + Implementors should invent subtypes of the existing types whenever + possible. In many cases, a subtype of "application" will be more + appropriate than a new top-level type. + + + + +Freed & Borenstein Standards Track [Page 40] + +RFC 2046 Media Types November 1996 + + +7. Summary + + The five discrete media types provide provide a standardized + mechanism for tagging entities as "audio", "image", or several other + kinds of data. The composite "multipart" and "message" media types + allow mixing and hierarchical structuring of entities of different + types in a single message. A distinguished parameter syntax allows + further specification of data format details, particularly the + specification of alternate character sets. Additional optional + header fields provide mechanisms for certain extensions deemed + desirable by many implementors. Finally, a number of useful media + types are defined for general use by consenting user agents, notably + "message/partial" and "message/external-body". + +9. Security Considerations + + Security issues are discussed in the context of the + "application/postscript" type, the "message/external-body" type, and + in RFC 2048. Implementors should pay special attention to the + security implications of any media types that can cause the remote + execution of any actions in the recipient's environment. In such + cases, the discussion of the "application/postscript" type may serve + as a model for considering other media types with remote execution + capabilities. + + + + + + + + + + + + + + + + + + + + + + + + + + + +Freed & Borenstein Standards Track [Page 41] + +RFC 2046 Media Types November 1996 + + +9. Authors' Addresses + + For more information, the authors of this document are best contacted + via Internet mail: + + Ned Freed + Innosoft International, Inc. + 1050 East Garvey Avenue South + West Covina, CA 91790 + USA + + Phone: +1 818 919 3600 + Fax: +1 818 919 3614 + EMail: ned@innosoft.com + + + Nathaniel S. Borenstein + First Virtual Holdings + 25 Washington Avenue + Morristown, NJ 07960 + USA + + Phone: +1 201 540 8967 + Fax: +1 201 993 3032 + EMail: nsb@nsb.fv.com + + + MIME is a result of the work of the Internet Engineering Task Force + Working Group on RFC 822 Extensions. The chairman of that group, + Greg Vaudreuil, may be reached at: + + Gregory M. Vaudreuil + Octel Network Services + 17080 Dallas Parkway + Dallas, TX 75248-1905 + USA + + EMail: Greg.Vaudreuil@Octel.Com + + + + + + + + + + + + + +Freed & Borenstein Standards Track [Page 42] + +RFC 2046 Media Types November 1996 + + +Appendix A -- Collected Grammar + + This appendix contains the complete BNF grammar for all the syntax + specified by this document. + + By itself, however, this grammar is incomplete. It refers by name to + several syntax rules that are defined by RFC 822. Rather than + reproduce those definitions here, and risk unintentional differences + between the two, this document simply refers the reader to RFC 822 + for the remaining definitions. Wherever a term is undefined, it + refers to the RFC 822 definition. + + boundary := 0*69 bcharsnospace + + bchars := bcharsnospace / " " + + bcharsnospace := DIGIT / ALPHA / "'" / "(" / ")" / + "+" / "_" / "," / "-" / "." / + "/" / ":" / "=" / "?" + + body-part := <"message" as defined in RFC 822, with all + header fields optional, not starting with the + specified dash-boundary, and with the + delimiter not occurring anywhere in the + body part. Note that the semantics of a + part differ from the semantics of a message, + as described in the text.> + + close-delimiter := delimiter "--" + + dash-boundary := "--" boundary + ; boundary taken from the value of + ; boundary parameter of the + ; Content-Type field. + + delimiter := CRLF dash-boundary + + discard-text := *(*text CRLF) + ; May be ignored or discarded. + + encapsulation := delimiter transport-padding + CRLF body-part + + epilogue := discard-text + + multipart-body := [preamble CRLF] + dash-boundary transport-padding CRLF + body-part *encapsulation + + + +Freed & Borenstein Standards Track [Page 43] + +RFC 2046 Media Types November 1996 + + + close-delimiter transport-padding + [CRLF epilogue] + + preamble := discard-text + + transport-padding := *LWSP-char + ; Composers MUST NOT generate + ; non-zero length transport + ; padding, but receivers MUST + ; be able to handle padding + ; added by message transports. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Freed & Borenstein Standards Track [Page 44] + diff --git a/vendor/swiftmailer/swiftmailer/notes/rfc/rfc2047.txt b/vendor/swiftmailer/swiftmailer/notes/rfc/rfc2047.txt new file mode 100755 index 0000000..ff9a744 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/notes/rfc/rfc2047.txt @@ -0,0 +1,843 @@ + + + + + + +Network Working Group K. Moore +Request for Comments: 2047 University of Tennessee +Obsoletes: 1521, 1522, 1590 November 1996 +Category: Standards Track + + + MIME (Multipurpose Internet Mail Extensions) Part Three: + Message Header Extensions for Non-ASCII Text + +Status of this Memo + + This document specifies an Internet standards track protocol for the + Internet community, and requests discussion and suggestions for + improvements. Please refer to the current edition of the "Internet + Official Protocol Standards" (STD 1) for the standardization state + and status of this protocol. Distribution of this memo is unlimited. + +Abstract + + STD 11, RFC 822, defines a message representation protocol specifying + considerable detail about US-ASCII message headers, and leaves the + message content, or message body, as flat US-ASCII text. This set of + documents, collectively called the Multipurpose Internet Mail + Extensions, or MIME, redefines the format of messages to allow for + + (1) textual message bodies in character sets other than US-ASCII, + + (2) an extensible set of different formats for non-textual message + bodies, + + (3) multi-part message bodies, and + + (4) textual header information in character sets other than US-ASCII. + + These documents are based on earlier work documented in RFC 934, STD + 11, and RFC 1049, but extends and revises them. Because RFC 822 said + so little about message bodies, these documents are largely + orthogonal to (rather than a revision of) RFC 822. + + This particular document is the third document in the series. It + describes extensions to RFC 822 to allow non-US-ASCII text data in + Internet mail header fields. + + + + + + + + + +Moore Standards Track [Page 1] + +RFC 2047 Message Header Extensions November 1996 + + + Other documents in this series include: + + + RFC 2045, which specifies the various headers used to describe + the structure of MIME messages. + + + RFC 2046, which defines the general structure of the MIME media + typing system and defines an initial set of media types, + + + RFC 2048, which specifies various IANA registration procedures + for MIME-related facilities, and + + + RFC 2049, which describes MIME conformance criteria and + provides some illustrative examples of MIME message formats, + acknowledgements, and the bibliography. + + These documents are revisions of RFCs 1521, 1522, and 1590, which + themselves were revisions of RFCs 1341 and 1342. An appendix in RFC + 2049 describes differences and changes from previous versions. + +1. Introduction + + RFC 2045 describes a mechanism for denoting textual body parts which + are coded in various character sets, as well as methods for encoding + such body parts as sequences of printable US-ASCII characters. This + memo describes similar techniques to allow the encoding of non-ASCII + text in various portions of a RFC 822 [2] message header, in a manner + which is unlikely to confuse existing message handling software. + + Like the encoding techniques described in RFC 2045, the techniques + outlined here were designed to allow the use of non-ASCII characters + in message headers in a way which is unlikely to be disturbed by the + quirks of existing Internet mail handling programs. In particular, + some mail relaying programs are known to (a) delete some message + header fields while retaining others, (b) rearrange the order of + addresses in To or Cc fields, (c) rearrange the (vertical) order of + header fields, and/or (d) "wrap" message headers at different places + than those in the original message. In addition, some mail reading + programs are known to have difficulty correctly parsing message + headers which, while legal according to RFC 822, make use of + backslash-quoting to "hide" special characters such as "<", ",", or + ":", or which exploit other infrequently-used features of that + specification. + + While it is unfortunate that these programs do not correctly + interpret RFC 822 headers, to "break" these programs would cause + severe operational problems for the Internet mail system. The + extensions described in this memo therefore do not rely on little- + used features of RFC 822. + + + +Moore Standards Track [Page 2] + +RFC 2047 Message Header Extensions November 1996 + + + Instead, certain sequences of "ordinary" printable ASCII characters + (known as "encoded-words") are reserved for use as encoded data. The + syntax of encoded-words is such that they are unlikely to + "accidentally" appear as normal text in message headers. + Furthermore, the characters used in encoded-words are restricted to + those which do not have special meanings in the context in which the + encoded-word appears. + + Generally, an "encoded-word" is a sequence of printable ASCII + characters that begins with "=?", ends with "?=", and has two "?"s in + between. It specifies a character set and an encoding method, and + also includes the original text encoded as graphic ASCII characters, + according to the rules for that encoding method. + + A mail composer that implements this specification will provide a + means of inputting non-ASCII text in header fields, but will + translate these fields (or appropriate portions of these fields) into + encoded-words before inserting them into the message header. + + A mail reader that implements this specification will recognize + encoded-words when they appear in certain portions of the message + header. Instead of displaying the encoded-word "as is", it will + reverse the encoding and display the original text in the designated + character set. + +NOTES + + This memo relies heavily on notation and terms defined RFC 822 and + RFC 2045. In particular, the syntax for the ABNF used in this memo + is defined in RFC 822, as well as many of the terminal or nonterminal + symbols from RFC 822 are used in the grammar for the header + extensions defined here. Among the symbols defined in RFC 822 and + referenced in this memo are: 'addr-spec', 'atom', 'CHAR', 'comment', + 'CTLs', 'ctext', 'linear-white-space', 'phrase', 'quoted-pair'. + 'quoted-string', 'SPACE', and 'word'. Successful implementation of + this protocol extension requires careful attention to the RFC 822 + definitions of these terms. + + When the term "ASCII" appears in this memo, it refers to the "7-Bit + American Standard Code for Information Interchange", ANSI X3.4-1986. + The MIME charset name for this character set is "US-ASCII". When not + specifically referring to the MIME charset name, this document uses + the term "ASCII", both for brevity and for consistency with RFC 822. + However, implementors are warned that the character set name must be + spelled "US-ASCII" in MIME message and body part headers. + + + + + + +Moore Standards Track [Page 3] + +RFC 2047 Message Header Extensions November 1996 + + + This memo specifies a protocol for the representation of non-ASCII + text in message headers. It specifically DOES NOT define any + translation between "8-bit headers" and pure ASCII headers, nor is + any such translation assumed to be possible. + +2. Syntax of encoded-words + + An 'encoded-word' is defined by the following ABNF grammar. The + notation of RFC 822 is used, with the exception that white space + characters MUST NOT appear between components of an 'encoded-word'. + + encoded-word = "=?" charset "?" encoding "?" encoded-text "?=" + + charset = token ; see section 3 + + encoding = token ; see section 4 + + token = 1* + + especials = "(" / ")" / "<" / ">" / "@" / "," / ";" / ":" / " + <"> / "/" / "[" / "]" / "?" / "." / "=" + + encoded-text = 1* + ; (but see "Use of encoded-words in message + ; headers", section 5) + + Both 'encoding' and 'charset' names are case-independent. Thus the + charset name "ISO-8859-1" is equivalent to "iso-8859-1", and the + encoding named "Q" may be spelled either "Q" or "q". + + An 'encoded-word' may not be more than 75 characters long, including + 'charset', 'encoding', 'encoded-text', and delimiters. If it is + desirable to encode more text than will fit in an 'encoded-word' of + 75 characters, multiple 'encoded-word's (separated by CRLF SPACE) may + be used. + + While there is no limit to the length of a multiple-line header + field, each line of a header field that contains one or more + 'encoded-word's is limited to 76 characters. + + The length restrictions are included both to ease interoperability + through internetwork mail gateways, and to impose a limit on the + amount of lookahead a header parser must employ (while looking for a + final ?= delimiter) before it can decide whether a token is an + "encoded-word" or something else. + + + + + +Moore Standards Track [Page 4] + +RFC 2047 Message Header Extensions November 1996 + + + IMPORTANT: 'encoded-word's are designed to be recognized as 'atom's + by an RFC 822 parser. As a consequence, unencoded white space + characters (such as SPACE and HTAB) are FORBIDDEN within an + 'encoded-word'. For example, the character sequence + + =?iso-8859-1?q?this is some text?= + + would be parsed as four 'atom's, rather than as a single 'atom' (by + an RFC 822 parser) or 'encoded-word' (by a parser which understands + 'encoded-words'). The correct way to encode the string "this is some + text" is to encode the SPACE characters as well, e.g. + + =?iso-8859-1?q?this=20is=20some=20text?= + + The characters which may appear in 'encoded-text' are further + restricted by the rules in section 5. + +3. Character sets + + The 'charset' portion of an 'encoded-word' specifies the character + set associated with the unencoded text. A 'charset' can be any of + the character set names allowed in an MIME "charset" parameter of a + "text/plain" body part, or any character set name registered with + IANA for use with the MIME text/plain content-type. + + Some character sets use code-switching techniques to switch between + "ASCII mode" and other modes. If unencoded text in an 'encoded-word' + contains a sequence which causes the charset interpreter to switch + out of ASCII mode, it MUST contain additional control codes such that + ASCII mode is again selected at the end of the 'encoded-word'. (This + rule applies separately to each 'encoded-word', including adjacent + 'encoded-word's within a single header field.) + + When there is a possibility of using more than one character set to + represent the text in an 'encoded-word', and in the absence of + private agreements between sender and recipients of a message, it is + recommended that members of the ISO-8859-* series be used in + preference to other character sets. + +4. Encodings + + Initially, the legal values for "encoding" are "Q" and "B". These + encodings are described below. The "Q" encoding is recommended for + use when most of the characters to be encoded are in the ASCII + character set; otherwise, the "B" encoding should be used. + Nevertheless, a mail reader which claims to recognize 'encoded-word's + MUST be able to accept either encoding for any character set which it + supports. + + + +Moore Standards Track [Page 5] + +RFC 2047 Message Header Extensions November 1996 + + + Only a subset of the printable ASCII characters may be used in + 'encoded-text'. Space and tab characters are not allowed, so that + the beginning and end of an 'encoded-word' are obvious. The "?" + character is used within an 'encoded-word' to separate the various + portions of the 'encoded-word' from one another, and thus cannot + appear in the 'encoded-text' portion. Other characters are also + illegal in certain contexts. For example, an 'encoded-word' in a + 'phrase' preceding an address in a From header field may not contain + any of the "specials" defined in RFC 822. Finally, certain other + characters are disallowed in some contexts, to ensure reliability for + messages that pass through internetwork mail gateways. + + The "B" encoding automatically meets these requirements. The "Q" + encoding allows a wide range of printable characters to be used in + non-critical locations in the message header (e.g., Subject), with + fewer characters available for use in other locations. + +4.1. The "B" encoding + + The "B" encoding is identical to the "BASE64" encoding defined by RFC + 2045. + +4.2. The "Q" encoding + + The "Q" encoding is similar to the "Quoted-Printable" content- + transfer-encoding defined in RFC 2045. It is designed to allow text + containing mostly ASCII characters to be decipherable on an ASCII + terminal without decoding. + + (1) Any 8-bit value may be represented by a "=" followed by two + hexadecimal digits. For example, if the character set in use + were ISO-8859-1, the "=" character would thus be encoded as + "=3D", and a SPACE by "=20". (Upper case should be used for + hexadecimal digits "A" through "F".) + + (2) The 8-bit hexadecimal value 20 (e.g., ISO-8859-1 SPACE) may be + represented as "_" (underscore, ASCII 95.). (This character may + not pass through some internetwork mail gateways, but its use + will greatly enhance readability of "Q" encoded data with mail + readers that do not support this encoding.) Note that the "_" + always represents hexadecimal 20, even if the SPACE character + occupies a different code position in the character set in use. + + (3) 8-bit values which correspond to printable ASCII characters other + than "=", "?", and "_" (underscore), MAY be represented as those + characters. (But see section 5 for restrictions.) In + particular, SPACE and TAB MUST NOT be represented as themselves + within encoded words. + + + +Moore Standards Track [Page 6] + +RFC 2047 Message Header Extensions November 1996 + + +5. Use of encoded-words in message headers + + An 'encoded-word' may appear in a message header or body part header + according to the following rules: + +(1) An 'encoded-word' may replace a 'text' token (as defined by RFC 822) + in any Subject or Comments header field, any extension message + header field, or any MIME body part field for which the field body + is defined as '*text'. An 'encoded-word' may also appear in any + user-defined ("X-") message or body part header field. + + Ordinary ASCII text and 'encoded-word's may appear together in the + same header field. However, an 'encoded-word' that appears in a + header field defined as '*text' MUST be separated from any adjacent + 'encoded-word' or 'text' by 'linear-white-space'. + +(2) An 'encoded-word' may appear within a 'comment' delimited by "(" and + ")", i.e., wherever a 'ctext' is allowed. More precisely, the RFC + 822 ABNF definition for 'comment' is amended as follows: + + comment = "(" *(ctext / quoted-pair / comment / encoded-word) ")" + + A "Q"-encoded 'encoded-word' which appears in a 'comment' MUST NOT + contain the characters "(", ")" or " + 'encoded-word' that appears in a 'comment' MUST be separated from + any adjacent 'encoded-word' or 'ctext' by 'linear-white-space'. + + It is important to note that 'comment's are only recognized inside + "structured" field bodies. In fields whose bodies are defined as + '*text', "(" and ")" are treated as ordinary characters rather than + comment delimiters, and rule (1) of this section applies. (See RFC + 822, sections 3.1.2 and 3.1.3) + +(3) As a replacement for a 'word' entity within a 'phrase', for example, + one that precedes an address in a From, To, or Cc header. The ABNF + definition for 'phrase' from RFC 822 thus becomes: + + phrase = 1*( encoded-word / word ) + + In this case the set of characters that may be used in a "Q"-encoded + 'encoded-word' is restricted to: . An 'encoded-word' that appears within a + 'phrase' MUST be separated from any adjacent 'word', 'text' or + 'special' by 'linear-white-space'. + + + + + + +Moore Standards Track [Page 7] + +RFC 2047 Message Header Extensions November 1996 + + + These are the ONLY locations where an 'encoded-word' may appear. In + particular: + + + An 'encoded-word' MUST NOT appear in any portion of an 'addr-spec'. + + + An 'encoded-word' MUST NOT appear within a 'quoted-string'. + + + An 'encoded-word' MUST NOT be used in a Received header field. + + + An 'encoded-word' MUST NOT be used in parameter of a MIME + Content-Type or Content-Disposition field, or in any structured + field body except within a 'comment' or 'phrase'. + + The 'encoded-text' in an 'encoded-word' must be self-contained; + 'encoded-text' MUST NOT be continued from one 'encoded-word' to + another. This implies that the 'encoded-text' portion of a "B" + 'encoded-word' will be a multiple of 4 characters long; for a "Q" + 'encoded-word', any "=" character that appears in the 'encoded-text' + portion will be followed by two hexadecimal characters. + + Each 'encoded-word' MUST encode an integral number of octets. The + 'encoded-text' in each 'encoded-word' must be well-formed according + to the encoding specified; the 'encoded-text' may not be continued in + the next 'encoded-word'. (For example, "=?charset?Q?=?= + =?charset?Q?AB?=" would be illegal, because the two hex digits "AB" + must follow the "=" in the same 'encoded-word'.) + + Each 'encoded-word' MUST represent an integral number of characters. + A multi-octet character may not be split across adjacent 'encoded- + word's. + + Only printable and white space character data should be encoded using + this scheme. However, since these encoding schemes allow the + encoding of arbitrary octet values, mail readers that implement this + decoding should also ensure that display of the decoded data on the + recipient's terminal will not cause unwanted side-effects. + + Use of these methods to encode non-textual data (e.g., pictures or + sounds) is not defined by this memo. Use of 'encoded-word's to + represent strings of purely ASCII characters is allowed, but + discouraged. In rare cases it may be necessary to encode ordinary + text that looks like an 'encoded-word'. + + + + + + + + + +Moore Standards Track [Page 8] + +RFC 2047 Message Header Extensions November 1996 + + +6. Support of 'encoded-word's by mail readers + +6.1. Recognition of 'encoded-word's in message headers + + A mail reader must parse the message and body part headers according + to the rules in RFC 822 to correctly recognize 'encoded-word's. + + 'encoded-word's are to be recognized as follows: + + (1) Any message or body part header field defined as '*text', or any + user-defined header field, should be parsed as follows: Beginning + at the start of the field-body and immediately following each + occurrence of 'linear-white-space', each sequence of up to 75 + printable characters (not containing any 'linear-white-space') + should be examined to see if it is an 'encoded-word' according to + the syntax rules in section 2. Any other sequence of printable + characters should be treated as ordinary ASCII text. + + (2) Any header field not defined as '*text' should be parsed + according to the syntax rules for that header field. However, + any 'word' that appears within a 'phrase' should be treated as an + 'encoded-word' if it meets the syntax rules in section 2. + Otherwise it should be treated as an ordinary 'word'. + + (3) Within a 'comment', any sequence of up to 75 printable characters + (not containing 'linear-white-space'), that meets the syntax + rules in section 2, should be treated as an 'encoded-word'. + Otherwise it should be treated as normal comment text. + + (4) A MIME-Version header field is NOT required to be present for + 'encoded-word's to be interpreted according to this + specification. One reason for this is that the mail reader is + not expected to parse the entire message header before displaying + lines that may contain 'encoded-word's. + +6.2. Display of 'encoded-word's + + Any 'encoded-word's so recognized are decoded, and if possible, the + resulting unencoded text is displayed in the original character set. + + NOTE: Decoding and display of encoded-words occurs *after* a + structured field body is parsed into tokens. It is therefore + possible to hide 'special' characters in encoded-words which, when + displayed, will be indistinguishable from 'special' characters in the + surrounding text. For this and other reasons, it is NOT generally + possible to translate a message header containing 'encoded-word's to + an unencoded form which can be parsed by an RFC 822 mail reader. + + + + +Moore Standards Track [Page 9] + +RFC 2047 Message Header Extensions November 1996 + + + When displaying a particular header field that contains multiple + 'encoded-word's, any 'linear-white-space' that separates a pair of + adjacent 'encoded-word's is ignored. (This is to allow the use of + multiple 'encoded-word's to represent long strings of unencoded text, + without having to separate 'encoded-word's where spaces occur in the + unencoded text.) + + In the event other encodings are defined in the future, and the mail + reader does not support the encoding used, it may either (a) display + the 'encoded-word' as ordinary text, or (b) substitute an appropriate + message indicating that the text could not be decoded. + + If the mail reader does not support the character set used, it may + (a) display the 'encoded-word' as ordinary text (i.e., as it appears + in the header), (b) make a "best effort" to display using such + characters as are available, or (c) substitute an appropriate message + indicating that the decoded text could not be displayed. + + If the character set being used employs code-switching techniques, + display of the encoded text implicitly begins in "ASCII mode". In + addition, the mail reader must ensure that the output device is once + again in "ASCII mode" after the 'encoded-word' is displayed. + +6.3. Mail reader handling of incorrectly formed 'encoded-word's + + It is possible that an 'encoded-word' that is legal according to the + syntax defined in section 2, is incorrectly formed according to the + rules for the encoding being used. For example: + + (1) An 'encoded-word' which contains characters which are not legal + for a particular encoding (for example, a "-" in the "B" + encoding, or a SPACE or HTAB in either the "B" or "Q" encoding), + is incorrectly formed. + + (2) Any 'encoded-word' which encodes a non-integral number of + characters or octets is incorrectly formed. + + A mail reader need not attempt to display the text associated with an + 'encoded-word' that is incorrectly formed. However, a mail reader + MUST NOT prevent the display or handling of a message because an + 'encoded-word' is incorrectly formed. + +7. Conformance + + A mail composing program claiming compliance with this specification + MUST ensure that any string of non-white-space printable ASCII + characters within a '*text' or '*ctext' that begins with "=?" and + ends with "?=" be a valid 'encoded-word'. ("begins" means: at the + + + +Moore Standards Track [Page 10] + +RFC 2047 Message Header Extensions November 1996 + + + start of the field-body, immediately following 'linear-white-space', + or immediately following a "(" for an 'encoded-word' within '*ctext'; + "ends" means: at the end of the field-body, immediately preceding + 'linear-white-space', or immediately preceding a ")" for an + 'encoded-word' within '*ctext'.) In addition, any 'word' within a + 'phrase' that begins with "=?" and ends with "?=" must be a valid + 'encoded-word'. + + A mail reading program claiming compliance with this specification + must be able to distinguish 'encoded-word's from 'text', 'ctext', or + 'word's, according to the rules in section 6, anytime they appear in + appropriate places in message headers. It must support both the "B" + and "Q" encodings for any character set which it supports. The + program must be able to display the unencoded text if the character + set is "US-ASCII". For the ISO-8859-* character sets, the mail + reading program must at least be able to display the characters which + are also in the ASCII set. + +8. Examples + + The following are examples of message headers containing 'encoded- + word's: + + From: =?US-ASCII?Q?Keith_Moore?= + To: =?ISO-8859-1?Q?Keld_J=F8rn_Simonsen?= + CC: =?ISO-8859-1?Q?Andr=E9?= Pirard + Subject: =?ISO-8859-1?B?SWYgeW91IGNhbiByZWFkIHRoaXMgeW8=?= + =?ISO-8859-2?B?dSB1bmRlcnN0YW5kIHRoZSBleGFtcGxlLg==?= + + Note: In the first 'encoded-word' of the Subject field above, the + last "=" at the end of the 'encoded-text' is necessary because each + 'encoded-word' must be self-contained (the "=" character completes a + group of 4 base64 characters representing 2 octets). An additional + octet could have been encoded in the first 'encoded-word' (so that + the encoded-word would contain an exact multiple of 3 encoded + octets), except that the second 'encoded-word' uses a different + 'charset' than the first one. + + From: =?ISO-8859-1?Q?Olle_J=E4rnefors?= + To: ietf-822@dimacs.rutgers.edu, ojarnef@admin.kth.se + Subject: Time for ISO 10646? + + To: Dave Crocker + Cc: ietf-822@dimacs.rutgers.edu, paf@comsol.se + From: =?ISO-8859-1?Q?Patrik_F=E4ltstr=F6m?= + Subject: Re: RFC-HDR care and feeding + + + + + +Moore Standards Track [Page 11] + +RFC 2047 Message Header Extensions November 1996 + + + From: Nathaniel Borenstein + (=?iso-8859-8?b?7eXs+SDv4SDp7Oj08A==?=) + To: Greg Vaudreuil , Ned Freed + , Keith Moore + Subject: Test of new header generator + MIME-Version: 1.0 + Content-type: text/plain; charset=ISO-8859-1 + + The following examples illustrate how text containing 'encoded-word's + which appear in a structured field body. The rules are slightly + different for fields defined as '*text' because "(" and ")" are not + recognized as 'comment' delimiters. [Section 5, paragraph (1)]. + + In each of the following examples, if the same sequence were to occur + in a '*text' field, the "displayed as" form would NOT be treated as + encoded words, but be identical to the "encoded form". This is + because each of the encoded-words in the following examples is + adjacent to a "(" or ")" character. + + encoded form displayed as + --------------------------------------------------------------------- + (=?ISO-8859-1?Q?a?=) (a) + + (=?ISO-8859-1?Q?a?= b) (a b) + + Within a 'comment', white space MUST appear between an + 'encoded-word' and surrounding text. [Section 5, + paragraph (2)]. However, white space is not needed between + the initial "(" that begins the 'comment', and the + 'encoded-word'. + + + (=?ISO-8859-1?Q?a?= =?ISO-8859-1?Q?b?=) (ab) + + White space between adjacent 'encoded-word's is not + displayed. + + (=?ISO-8859-1?Q?a?= =?ISO-8859-1?Q?b?=) (ab) + + Even multiple SPACEs between 'encoded-word's are ignored + for the purpose of display. + + (=?ISO-8859-1?Q?a?= (ab) + =?ISO-8859-1?Q?b?=) + + Any amount of linear-space-white between 'encoded-word's, + even if it includes a CRLF followed by one or more SPACEs, + is ignored for the purposes of display. + + + +Moore Standards Track [Page 12] + +RFC 2047 Message Header Extensions November 1996 + + + (=?ISO-8859-1?Q?a_b?=) (a b) + + In order to cause a SPACE to be displayed within a portion + of encoded text, the SPACE MUST be encoded as part of the + 'encoded-word'. + + (=?ISO-8859-1?Q?a?= =?ISO-8859-2?Q?_b?=) (a b) + + In order to cause a SPACE to be displayed between two strings + of encoded text, the SPACE MAY be encoded as part of one of + the 'encoded-word's. + +9. References + + [RFC 822] Crocker, D., "Standard for the Format of ARPA Internet Text + Messages", STD 11, RFC 822, UDEL, August 1982. + + [RFC 2049] Borenstein, N., and N. Freed, "Multipurpose Internet Mail + Extensions (MIME) Part Five: Conformance Criteria and Examples", + RFC 2049, November 1996. + + [RFC 2045] Borenstein, N., and N. Freed, "Multipurpose Internet Mail + Extensions (MIME) Part One: Format of Internet Message Bodies", + RFC 2045, November 1996. + + [RFC 2046] Borenstein N., and N. Freed, "Multipurpose Internet Mail + Extensions (MIME) Part Two: Media Types", RFC 2046, + November 1996. + + [RFC 2048] Freed, N., Klensin, J., and J. Postel, "Multipurpose + Internet Mail Extensions (MIME) Part Four: Registration + Procedures", RFC 2048, November 1996. + + + + + + + + + + + + + + + + + + + +Moore Standards Track [Page 13] + +RFC 2047 Message Header Extensions November 1996 + + +10. Security Considerations + + Security issues are not discussed in this memo. + +11. Acknowledgements + + The author wishes to thank Nathaniel Borenstein, Issac Chan, Lutz + Donnerhacke, Paul Eggert, Ned Freed, Andreas M. Kirchwitz, Olle + Jarnefors, Mike Rosin, Yutaka Sato, Bart Schaefer, and Kazuhiko + Yamamoto, for their helpful advice, insightful comments, and + illuminating questions in response to earlier versions of this + specification. + +12. Author's Address + + Keith Moore + University of Tennessee + 107 Ayres Hall + Knoxville TN 37996-1301 + + EMail: moore@cs.utk.edu + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Moore Standards Track [Page 14] + +RFC 2047 Message Header Extensions November 1996 + + +Appendix - changes since RFC 1522 (in no particular order) + + + explicitly state that the MIME-Version is not requried to use + 'encoded-word's. + + + add explicit note that SPACEs and TABs are not allowed within + 'encoded-word's, explaining that an 'encoded-word' must look like an + 'atom' to an RFC822 parser.values, to be precise). + + + add examples from Olle Jarnefors (thanks!) which illustrate how + encoded-words with adjacent linear-white-space are displayed. + + + explicitly list terms defined in RFC822 and referenced in this memo + + + fix transcription typos that caused one or two lines and a couple of + characters to disappear in the resulting text, due to nroff quirks. + + + clarify that encoded-words are allowed in '*text' fields in both + RFC822 headers and MIME body part headers, but NOT as parameter + values. + + + clarify the requirement to switch back to ASCII within the encoded + portion of an 'encoded-word', for any charset that uses code switching + sequences. + + + add a note about 'encoded-word's being delimited by "(" and ")" + within a comment, but not in a *text (how bizarre!). + + + fix the Andre Pirard example to get rid of the trailing "_" after + the =E9. (no longer needed post-1342). + + + clarification: an 'encoded-word' may appear immediately following + the initial "(" or immediately before the final ")" that delimits a + comment, not just adjacent to "(" and ")" *within* *ctext. + + + add a note to explain that a "B" 'encoded-word' will always have a + multiple of 4 characters in the 'encoded-text' portion. + + + add note about the "=" in the examples + + + note that processing of 'encoded-word's occurs *after* parsing, and + some of the implications thereof. + + + explicitly state that you can't expect to translate between + 1522 and either vanilla 822 or so-called "8-bit headers". + + + explicitly state that 'encoded-word's are not valid within a + 'quoted-string'. + + + +Moore Standards Track [Page 15] + diff --git a/vendor/swiftmailer/swiftmailer/notes/rfc/rfc2048.txt b/vendor/swiftmailer/swiftmailer/notes/rfc/rfc2048.txt new file mode 100755 index 0000000..a3b18b3 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/notes/rfc/rfc2048.txt @@ -0,0 +1,1180 @@ + + + + + + +Network Working Group N. Freed +Request for Comments: 2048 Innosoft +BCP: 13 J. Klensin +Obsoletes: 1521, 1522, 1590 MCI +Category: Best Current Practice J. Postel + ISI + November 1996 + + + Multipurpose Internet Mail Extensions + (MIME) Part Four: + Registration Procedures + +Status of this Memo + + This document specifies an Internet Best Current Practices for the + Internet Community, and requests discussion and suggestions for + improvements. Distribution of this memo is unlimited. + +Abstract + + STD 11, RFC 822, defines a message representation protocol specifying + considerable detail about US-ASCII message headers, and leaves the + message content, or message body, as flat US-ASCII text. This set of + documents, collectively called the Multipurpose Internet Mail + Extensions, or MIME, redefines the format of messages to allow for + + (1) textual message bodies in character sets other than + US-ASCII, + + (2) an extensible set of different formats for non-textual + message bodies, + + (3) multi-part message bodies, and + + (4) textual header information in character sets other than + US-ASCII. + + These documents are based on earlier work documented in RFC 934, STD + 11, and RFC 1049, but extends and revises them. Because RFC 822 said + so little about message bodies, these documents are largely + orthogonal to (rather than a revision of) RFC 822. + + + + + + + + + +Freed, et. al. Best Current Practice [Page 1] + +RFC 2048 MIME Registration Procedures November 1996 + + + This fourth document, RFC 2048, specifies various IANA registration + procedures for the following MIME facilities: + + (1) media types, + + (2) external body access types, + + (3) content-transfer-encodings. + + Registration of character sets for use in MIME is covered elsewhere + and is no longer addressed by this document. + + These documents are revisions of RFCs 1521 and 1522, which themselves + were revisions of RFCs 1341 and 1342. An appendix in RFC 2049 + describes differences and changes from previous versions. + +Table of Contents + + 1. Introduction ......................................... 3 + 2. Media Type Registration .............................. 4 + 2.1 Registration Trees and Subtype Names ................ 4 + 2.1.1 IETF Tree ......................................... 4 + 2.1.2 Vendor Tree ....................................... 4 + 2.1.3 Personal or Vanity Tree ........................... 5 + 2.1.4 Special `x.' Tree ................................. 5 + 2.1.5 Additional Registration Trees ..................... 6 + 2.2 Registration Requirements ........................... 6 + 2.2.1 Functionality Requirement ......................... 6 + 2.2.2 Naming Requirements ............................... 6 + 2.2.3 Parameter Requirements ............................ 7 + 2.2.4 Canonicalization and Format Requirements .......... 7 + 2.2.5 Interchange Recommendations ....................... 8 + 2.2.6 Security Requirements ............................. 8 + 2.2.7 Usage and Implementation Non-requirements ......... 9 + 2.2.8 Publication Requirements .......................... 10 + 2.2.9 Additional Information ............................ 10 + 2.3 Registration Procedure .............................. 11 + 2.3.1 Present the Media Type to the Community for Review 11 + 2.3.2 IESG Approval ..................................... 12 + 2.3.3 IANA Registration ................................. 12 + 2.4 Comments on Media Type Registrations ................ 12 + 2.5 Location of Registered Media Type List .............. 12 + 2.6 IANA Procedures for Registering Media Types ......... 12 + 2.7 Change Control ...................................... 13 + 2.8 Registration Template ............................... 14 + 3. External Body Access Types ........................... 14 + 3.1 Registration Requirements ........................... 15 + 3.1.1 Naming Requirements ............................... 15 + + + +Freed, et. al. Best Current Practice [Page 2] + +RFC 2048 MIME Registration Procedures November 1996 + + + 3.1.2 Mechanism Specification Requirements .............. 15 + 3.1.3 Publication Requirements .......................... 15 + 3.1.4 Security Requirements ............................. 15 + 3.2 Registration Procedure .............................. 15 + 3.2.1 Present the Access Type to the Community .......... 16 + 3.2.2 Access Type Reviewer .............................. 16 + 3.2.3 IANA Registration ................................. 16 + 3.3 Location of Registered Access Type List ............. 16 + 3.4 IANA Procedures for Registering Access Types ........ 16 + 4. Transfer Encodings ................................... 17 + 4.1 Transfer Encoding Requirements ...................... 17 + 4.1.1 Naming Requirements ............................... 17 + 4.1.2 Algorithm Specification Requirements .............. 18 + 4.1.3 Input Domain Requirements ......................... 18 + 4.1.4 Output Range Requirements ......................... 18 + 4.1.5 Data Integrity and Generality Requirements ........ 18 + 4.1.6 New Functionality Requirements .................... 18 + 4.2 Transfer Encoding Definition Procedure .............. 19 + 4.3 IANA Procedures for Transfer Encoding Registration... 19 + 4.4 Location of Registered Transfer Encodings List ...... 19 + 5. Authors' Addresses ................................... 20 + A. Grandfathered Media Types ............................ 21 + +1. Introduction + + Recent Internet protocols have been carefully designed to be easily + extensible in certain areas. In particular, MIME [RFC 2045] is an + open-ended framework and can accommodate additional object types, + character sets, and access methods without any changes to the basic + protocol. A registration process is needed, however, to ensure that + the set of such values is developed in an orderly, well-specified, + and public manner. + + This document defines registration procedures which use the Internet + Assigned Numbers Authority (IANA) as a central registry for such + values. + + Historical Note: The registration process for media types was + initially defined in the context of the asynchronous Internet mail + environment. In this mail environment there is a need to limit the + number of possible media types to increase the likelihood of + interoperability when the capabilities of the remote mail system are + not known. As media types are used in new environments, where the + proliferation of media types is not a hindrance to interoperability, + the original procedure was excessively restrictive and had to be + generalized. + + + + + +Freed, et. al. Best Current Practice [Page 3] + +RFC 2048 MIME Registration Procedures November 1996 + + +2. Media Type Registration + + Registration of a new media type or types starts with the + construction of a registration proposal. Registration may occur in + several different registration trees, which have different + requirements as discussed below. In general, the new registration + proposal is circulated and reviewed in a fashion appropriate to the + tree involved. The media type is then registered if the proposal is + acceptable. The following sections describe the requirements and + procedures used for each of the different registration trees. + +2.1. Registration Trees and Subtype Names + + In order to increase the efficiency and flexibility of the + registration process, different structures of subtype names may be + registered to accomodate the different natural requirements for, + e.g., a subtype that will be recommended for wide support and + implementation by the Internet Community or a subtype that is used to + move files associated with proprietary software. The following + subsections define registration "trees", distinguished by the use of + faceted names (e.g., names of the form "tree.subtree...type"). Note + that some media types defined prior to this document do not conform + to the naming conventions described below. See Appendix A for a + discussion of them. + +2.1.1. IETF Tree + + The IETF tree is intended for types of general interest to the + Internet Community. Registration in the IETF tree requires approval + by the IESG and publication of the media type registration as some + form of RFC. + + Media types in the IETF tree are normally denoted by names that are + not explicitly faceted, i.e., do not contain period (".", full stop) + characters. + + The "owner" of a media type registration in the IETF tree is assumed + to be the IETF itself. Modification or alteration of the + specification requires the same level of processing (e.g. standards + track) required for the initial registration. + +2.1.2. Vendor Tree + + The vendor tree is used for media types associated with commercially + available products. "Vendor" or "producer" are construed as + equivalent and very broadly in this context. + + + + + +Freed, et. al. Best Current Practice [Page 4] + +RFC 2048 MIME Registration Procedures November 1996 + + + A registration may be placed in the vendor tree by anyone who has + need to interchange files associated with the particular product. + However, the registration formally belongs to the vendor or + organization producing the software or file format. Changes to the + specification will be made at their request, as discussed in + subsequent sections. + + Registrations in the vendor tree will be distinguished by the leading + facet "vnd.". That may be followed, at the discretion of the + registration, by either a media type name from a well-known producer + (e.g., "vnd.mudpie") or by an IANA-approved designation of the + producer's name which is then followed by a media type or product + designation (e.g., vnd.bigcompany.funnypictures). + + While public exposure and review of media types to be registered in + the vendor tree is not required, using the ietf-types list for review + is strongly encouraged to improve the quality of those + specifications. Registrations in the vendor tree may be submitted + directly to the IANA. + +2.1.3. Personal or Vanity Tree + + Registrations for media types created experimentally or as part of + products that are not distributed commercially may be registered in + the personal or vanity tree. The registrations are distinguished by + the leading facet "prs.". + + The owner of "personal" registrations and associated specifications + is the person or entity making the registration, or one to whom + responsibility has been transferred as described below. + + While public exposure and review of media types to be registered in + the personal tree is not required, using the ietf-types list for + review is strongly encouraged to improve the quality of those + specifications. Registrations in the personl tree may be submitted + directly to the IANA. + +2.1.4. Special `x.' Tree + + For convenience and symmetry with this registration scheme, media + type names with "x." as the first facet may be used for the same + purposes for which names starting in "x-" are normally used. These + types are unregistered, experimental, and should be used only with + the active agreement of the parties exchanging them. + + + + + + + +Freed, et. al. Best Current Practice [Page 5] + +RFC 2048 MIME Registration Procedures November 1996 + + + However, with the simplified registration procedures described above + for vendor and personal trees, it should rarely, if ever, be + necessary to use unregistered experimental types, and as such use of + both "x-" and "x." forms is discouraged. + +2.1.5. Additional Registration Trees + + From time to time and as required by the community, the IANA may, + with the advice and consent of the IESG, create new top-level + registration trees. It is explicitly assumed that these trees may be + created for external registration and management by well-known + permanent bodies, such as scientific societies for media types + specific to the sciences they cover. In general, the quality of + review of specifications for one of these additional registration + trees is expected to be equivalent to that which IETF would give to + registrations in its own tree. Establishment of these new trees will + be announced through RFC publication approved by the IESG. + +2.2. Registration Requirements + + Media type registration proposals are all expected to conform to + various requirements laid out in the following sections. Note that + requirement specifics sometimes vary depending on the registration + tree, again as detailed in the following sections. + +2.2.1. Functionality Requirement + + Media types must function as an actual media format: Registration of + things that are better thought of as a transfer encoding, as a + character set, or as a collection of separate entities of another + type, is not allowed. For example, although applications exist to + decode the base64 transfer encoding [RFC 2045], base64 cannot be + registered as a media type. + + This requirement applies regardless of the registration tree + involved. + +2.2.2. Naming Requirements + + All registered media types must be assigned MIME type and subtype + names. The combination of these names then serves to uniquely + identify the media type and the format of the subtype name identifies + the registration tree. + + The choice of top-level type name must take the nature of media type + involved into account. For example, media normally used for + representing still images should be a subtype of the image content + type, whereas media capable of representing audio information belongs + + + +Freed, et. al. Best Current Practice [Page 6] + +RFC 2048 MIME Registration Procedures November 1996 + + + under the audio content type. See RFC 2046 for additional information + on the basic set of top-level types and their characteristics. + + New subtypes of top-level types must conform to the restrictions of + the top-level type, if any. For example, all subtypes of the + multipart content type must use the same encapsulation syntax. + + In some cases a new media type may not "fit" under any currently + defined top-level content type. Such cases are expected to be quite + rare. However, if such a case arises a new top-level type can be + defined to accommodate it. Such a definition must be done via + standards-track RFC; no other mechanism can be used to define + additional top-level content types. + + These requirements apply regardless of the registration tree + involved. + +2.2.3. Parameter Requirements + + Media types may elect to use one or more MIME content type + parameters, or some parameters may be automatically made available to + the media type by virtue of being a subtype of a content type that + defines a set of parameters applicable to any of its subtypes. In + either case, the names, values, and meanings of any parameters must + be fully specified when a media type is registered in the IETF tree, + and should be specified as completely as possible when media types + are registered in the vendor or personal trees. + + New parameters must not be defined as a way to introduce new + functionality in types registered in the IETF tree, although new + parameters may be added to convey additional information that does + not otherwise change existing functionality. An example of this + would be a "revision" parameter to indicate a revision level of an + external specification such as JPEG. Similar behavior is encouraged + for media types registered in the vendor or personal trees but is not + required. + +2.2.4. Canonicalization and Format Requirements + + All registered media types must employ a single, canonical data + format, regardless of registration tree. + + A precise and openly available specification of the format of each + media type is required for all types registered in the IETF tree and + must at a minimum be referenced by, if it isn't actually included in, + the media type registration proposal itself. + + + + + +Freed, et. al. Best Current Practice [Page 7] + +RFC 2048 MIME Registration Procedures November 1996 + + + The specifications of format and processing particulars may or may + not be publically available for media types registered in the vendor + tree, and such registration proposals are explicitly permitted to + include only a specification of which software and version produce or + process such media types. References to or inclusion of format + specifications in registration proposals is encouraged but not + required. + + Format specifications are still required for registration in the + personal tree, but may be either published as RFCs or otherwise + deposited with IANA. The deposited specifications will meet the same + criteria as those required to register a well-known TCP port and, in + particular, need not be made public. + + Some media types involve the use of patented technology. The + registration of media types involving patented technology is + specifically permitted. However, the restrictions set forth in RFC + 1602 on the use of patented technology in standards-track protocols + must be respected when the specification of a media type is part of a + standards-track protocol. + +2.2.5. Interchange Recommendations + + Media types should, whenever possible, interoperate across as many + systems and applications as possible. However, some media types will + inevitably have problems interoperating across different platforms. + Problems with different versions, byte ordering, and specifics of + gateway handling can and will arise. + + Universal interoperability of media types is not required, but known + interoperability issues should be identified whenever possible. + Publication of a media type does not require an exhaustive review of + interoperability, and the interoperability considerations section is + subject to continuing evaluation. + + These recommendations apply regardless of the registration tree + involved. + +2.2.6. Security Requirements + + An analysis of security issues is required for for all types + registered in the IETF Tree. (This is in accordance with the basic + requirements for all IETF protocols.) A similar analysis for media + types registered in the vendor or personal trees is encouraged but + not required. However, regardless of what security analysis has or + has not been done, all descriptions of security issues must be as + accurate as possible regardless of registration tree. In particular, + a statement that there are "no security issues associated with this + + + +Freed, et. al. Best Current Practice [Page 8] + +RFC 2048 MIME Registration Procedures November 1996 + + + type" must not be confused with "the security issues associates with + this type have not been assessed". + + There is absolutely no requirement that media types registered in any + tree be secure or completely free from risks. Nevertheless, all + known security risks must be identified in the registration of a + media type, again regardless of registration tree. + + The security considerations section of all registrations is subject + to continuing evaluation and modification, and in particular may be + extended by use of the "comments on media types" mechanism described + in subsequent sections. + + Some of the issues that should be looked at in a security analysis of + a media type are: + + (1) Complex media types may include provisions for + directives that institute actions on a recipient's + files or other resources. In many cases provision is + made for originators to specify arbitrary actions in an + unrestricted fashion which may then have devastating + effects. See the registration of the + application/postscript media type in RFC 2046 for + an example of such directives and how to handle them. + + (2) Complex media types may include provisions for + directives that institute actions which, while not + directly harmful to the recipient, may result in + disclosure of information that either facilitates a + subsequent attack or else violates a recipient's + privacy in some way. Again, the registration of the + application/postscript media type illustrates how such + directives can be handled. + + (3) A media type might be targeted for applications that + require some sort of security assurance but not provide + the necessary security mechanisms themselves. For + example, a media type could be defined for storage of + confidential medical information which in turn requires + an external confidentiality service. + +2.2.7. Usage and Implementation Non-requirements + + In the asynchronous mail environment, where information on the + capabilities of the remote mail agent is frequently not available to + the sender, maximum interoperability is attained by restricting the + number of media types used to those "common" formats expected to be + widely implemented. This was asserted in the past as a reason to + + + +Freed, et. al. Best Current Practice [Page 9] + +RFC 2048 MIME Registration Procedures November 1996 + + + limit the number of possible media types and resulted in a + registration process with a significant hurdle and delay for those + registering media types. + + However, the need for "common" media types does not require limiting + the registration of new media types. If a limited set of media types + is recommended for a particular application, that should be asserted + by a separate applicability statement specific for the application + and/or environment. + + As such, universal support and implementation of a media type is NOT + a requirement for registration. If, however, a media type is + explicitly intended for limited use, this should be noted in its + registration. + +2.2.8. Publication Requirements + + Proposals for media types registered in the IETF tree must be + published as RFCs. RFC publication of vendor and personal media type + proposals is encouraged but not required. In all cases IANA will + retain copies of all media type proposals and "publish" them as part + of the media types registration tree itself. + + Other than in the IETF tree, the registration of a data type does not + imply endorsement, approval, or recommendation by IANA or IETF or + even certification that the specification is adequate. To become + Internet Standards, protocol, data objects, or whatever must go + through the IETF standards process. This is too difficult and too + lengthy a process for the convenient registration of media types. + + The IETF tree exists for media types that do require require a + substantive review and approval process with the vendor and personal + trees exist for those that do not. It is expected that applicability + statements for particular applications will be published from time to + time that recommend implementation of, and support for, media types + that have proven particularly useful in those contexts. + + As discussed above, registration of a top-level type requires + standards-track processing and, hence, RFC publication. + +2.2.9. Additional Information + + Various sorts of optional information may be included in the + specification of a media type if it is available: + + (1) Magic number(s) (length, octet values). Magic numbers + are byte sequences that are always present and thus can + be used to identify entities as being of a given media + + + +Freed, et. al. Best Current Practice [Page 10] + +RFC 2048 MIME Registration Procedures November 1996 + + + type. + + (2) File extension(s) commonly used on one or more + platforms to indicate that some file containing a given + type of media. + + (3) Macintosh File Type code(s) (4 octets) used to label + files containing a given type of media. + + Such information is often quite useful to implementors and if + available should be provided. + +2.3. Registration Procedure + + The following procedure has been implemented by the IANA for review + and approval of new media types. This is not a formal standards + process, but rather an administrative procedure intended to allow + community comment and sanity checking without excessive time delay. + For registration in the IETF tree, the normal IETF processes should + be followed, treating posting of an internet-draft and announcement + on the ietf-types list (as described in the next subsection) as a + first step. For registrations in the vendor or personal tree, the + initial review step described below may be omitted and the type + registered directly by submitting the template and an explanation + directly to IANA (at iana@iana.org). However, authors of vendor or + personal media type specifications are encouraged to seek community + review and comment whenever that is feasible. + +2.3.1. Present the Media Type to the Community for Review + + Send a proposed media type registration to the "ietf-types@iana.org" + mailing list for a two week review period. This mailing list has + been established for the purpose of reviewing proposed media and + access types. Proposed media types are not formally registered and + must not be used; the "x-" prefix specified in RFC 2045 can be used + until registration is complete. + + The intent of the public posting is to solicit comments and feedback + on the choice of type/subtype name, the unambiguity of the references + with respect to versions and external profiling information, and a + review of any interoperability or security considerations. The + submitter may submit a revised registration, or withdraw the + registration completely, at any time. + + + + + + + + +Freed, et. al. Best Current Practice [Page 11] + +RFC 2048 MIME Registration Procedures November 1996 + + +2.3.2. IESG Approval + + Media types registered in the IETF tree must be submitted to the IESG + for approval. + +2.3.3. IANA Registration + + Provided that the media type meets the requirements for media types + and has obtained approval that is necessary, the author may submit + the registration request to the IANA, which will register the media + type and make the media type registration available to the community. + +2.4. Comments on Media Type Registrations + + Comments on registered media types may be submitted by members of the + community to IANA. These comments will be passed on to the "owner" + of the media type if possible. Submitters of comments may request + that their comment be attached to the media type registration itself, + and if IANA approves of this the comment will be made accessible in + conjunction with the type registration itself. + +2.5. Location of Registered Media Type List + + Media type registrations will be posted in the anonymous FTP + directory "ftp://ftp.isi.edu/in-notes/iana/assignments/media-types/" + and all registered media types will be listed in the periodically + issued "Assigned Numbers" RFC [currently STD 2, RFC 1700]. The media + type description and other supporting material may also be published + as an Informational RFC by sending it to "rfc-editor@isi.edu" (please + follow the instructions to RFC authors [RFC-1543]). + +2.6. IANA Procedures for Registering Media Types + + The IANA will only register media types in the IETF tree in response + to a communication from the IESG stating that a given registration + has been approved. Vendor and personal types will be registered by + the IANA automatically and without any formal review as long as the + following minimal conditions are met: + + (1) Media types must function as an actual media format. + In particular, character sets and transfer encodings + may not be registered as media types. + + (2) All media types must have properly formed type and + subtype names. All type names must be defined by a + standards-track RFC. All subtype names must be unique, + must conform to the MIME grammar for such names, and + must contain the proper tree prefix. + + + +Freed, et. al. Best Current Practice [Page 12] + +RFC 2048 MIME Registration Procedures November 1996 + + + (3) Types registered in the personal tree must either + provide a format specification or a pointer to one. + + (4) Any security considerations given must not be obviously + bogus. (It is neither possible nor necessary for the + IANA to conduct a comprehensive security review of + media type registrations. Nevertheless, IANA has the + authority to identify obviously incompetent material + and exclude it.) + +2.7. Change Control + + Once a media type has been published by IANA, the author may request + a change to its definition. The descriptions of the different + registration trees above designate the "owners" of each type of + registration. The change request follows the same procedure as the + registration request: + + (1) Publish the revised template on the ietf-types list. + + (2) Leave at least two weeks for comments. + + (3) Publish using IANA after formal review if required. + + Changes should be requested only when there are serious omission or + errors in the published specification. When review is required, a + change request may be denied if it renders entities that were valid + under the previous definition invalid under the new definition. + + The owner of a content type may pass responsibility for the content + type to another person or agency by informing IANA and the ietf-types + list; this can be done without discussion or review. + + The IESG may reassign responsibility for a media type. The most + common case of this will be to enable changes to be made to types + where the author of the registration has died, moved out of contact + or is otherwise unable to make changes that are important to the + community. + + Media type registrations may not be deleted; media types which are no + longer believed appropriate for use can be declared OBSOLETE by a + change to their "intended use" field; such media types will be + clearly marked in the lists published by IANA. + + + + + + + + +Freed, et. al. Best Current Practice [Page 13] + +RFC 2048 MIME Registration Procedures November 1996 + + +2.8. Registration Template + + To: ietf-types@iana.org + Subject: Registration of MIME media type XXX/YYY + + MIME media type name: + + MIME subtype name: + + Required parameters: + + Optional parameters: + + Encoding considerations: + + Security considerations: + + Interoperability considerations: + + Published specification: + + Applications which use this media type: + + Additional information: + + Magic number(s): + File extension(s): + Macintosh File Type Code(s): + + Person & email address to contact for further information: + + Intended usage: + + (One of COMMON, LIMITED USE or OBSOLETE) + + Author/Change controller: + + (Any other information that the author deems interesting may be + added below this line.) + +3. External Body Access Types + + RFC 2046 defines the message/external-body media type, whereby a MIME + entity can act as pointer to the actual body data in lieu of + including the data directly in the entity body. Each + message/external-body reference specifies an access type, which + determines the mechanism used to retrieve the actual body data. RFC + 2046 defines an initial set of access types, but allows for the + + + +Freed, et. al. Best Current Practice [Page 14] + +RFC 2048 MIME Registration Procedures November 1996 + + + registration of additional access types to accommodate new retrieval + mechanisms. + +3.1. Registration Requirements + + New access type specifications must conform to a number of + requirements as described below. + +3.1.1. Naming Requirements + + Each access type must have a unique name. This name appears in the + access-type parameter in the message/external-body content-type + header field, and must conform to MIME content type parameter syntax. + +3.1.2. Mechanism Specification Requirements + + All of the protocols, transports, and procedures used by a given + access type must be described, either in the specification of the + access type itself or in some other publicly available specification, + in sufficient detail for the access type to be implemented by any + competent implementor. Use of secret and/or proprietary methods in + access types are expressly prohibited. The restrictions imposed by + RFC 1602 on the standardization of patented algorithms must be + respected as well. + +3.1.3. Publication Requirements + + All access types must be described by an RFC. The RFC may be + informational rather than standards-track, although standard-track + review and approval are encouraged for all access types. + +3.1.4. Security Requirements + + Any known security issues that arise from the use of the access type + must be completely and fully described. It is not required that the + access type be secure or that it be free from risks, but that the + known risks be identified. Publication of a new access type does not + require an exhaustive security review, and the security + considerations section is subject to continuing evaluation. + Additional security considerations should be addressed by publishing + revised versions of the access type specification. + +3.2. Registration Procedure + + Registration of a new access type starts with the construction of a + draft of an RFC. + + + + + +Freed, et. al. Best Current Practice [Page 15] + +RFC 2048 MIME Registration Procedures November 1996 + + +3.2.1. Present the Access Type to the Community + + Send a proposed access type specification to the "ietf- + types@iana.org" mailing list for a two week review period. This + mailing list has been established for the purpose of reviewing + proposed access and media types. Proposed access types are not + formally registered and must not be used. + + The intent of the public posting is to solicit comments and feedback + on the access type specification and a review of any security + considerations. + +3.2.2. Access Type Reviewer + + When the two week period has passed, the access type reviewer, who is + appointed by the IETF Applications Area Director, either forwards the + request to iana@isi.edu, or rejects it because of significant + objections raised on the list. + + Decisions made by the reviewer must be posted to the ietf-types + mailing list within 14 days. Decisions made by the reviewer may be + appealed to the IESG. + +3.2.3. IANA Registration + + Provided that the access type has either passed review or has been + successfully appealed to the IESG, the IANA will register the access + type and make the registration available to the community. The + specification of the access type must also be published as an RFC. + Informational RFCs are published by sending them to "rfc- + editor@isi.edu" (please follow the instructions to RFC authors [RFC- + 1543]). + +3.3. Location of Registered Access Type List + + Access type registrations will be posted in the anonymous FTP + directory "ftp://ftp.isi.edu/in-notes/iana/assignments/access-types/" + and all registered access types will be listed in the periodically + issued "Assigned Numbers" RFC [currently RFC-1700]. + +3.4. IANA Procedures for Registering Access Types + + The identity of the access type reviewer is communicated to the IANA + by the IESG. The IANA then only acts in response to access type + definitions that either are approved by the access type reviewer and + forwarded by the reviewer to the IANA for registration, or in + response to a communication from the IESG that an access type + definition appeal has overturned the access type reviewer's ruling. + + + +Freed, et. al. Best Current Practice [Page 16] + +RFC 2048 MIME Registration Procedures November 1996 + + +4. Transfer Encodings + + Transfer encodings are tranformations applied to MIME media types + after conversion to the media type's canonical form. Transfer + encodings are used for several purposes: + + (1) Many transports, especially message transports, can + only handle data consisting of relatively short lines + of text. There can also be severe restrictions on what + characters can be used in these lines of text -- some + transports are restricted to a small subset of US-ASCII + and others cannot handle certain character sequences. + Transfer encodings are used to transform binary data + into textual form that can survive such transports. + Examples of this sort of transfer encoding include the + base64 and quoted-printable transfer encodings defined + in RFC 2045. + + (2) Image, audio, video, and even application entities are + sometimes quite large. Compression algorithms are often + quite effective in reducing the size of large entities. + Transfer encodings can be used to apply general-purpose + non-lossy compression algorithms to MIME entities. + + (3) Transport encodings can be defined as a means of + representing existing encoding formats in a MIME + context. + + IMPORTANT: The standardization of a large numbers of different + transfer encodings is seen as a significant barrier to widespread + interoperability and is expressely discouraged. Nevertheless, the + following procedure has been defined to provide a means of defining + additional transfer encodings, should standardization actually be + justified. + +4.1. Transfer Encoding Requirements + + Transfer encoding specifications must conform to a number of + requirements as described below. + +4.1.1. Naming Requirements + + Each transfer encoding must have a unique name. This name appears in + the Content-Transfer-Encoding header field and must conform to the + syntax of that field. + + + + + + +Freed, et. al. Best Current Practice [Page 17] + +RFC 2048 MIME Registration Procedures November 1996 + + +4.1.2. Algorithm Specification Requirements + + All of the algorithms used in a transfer encoding (e.g. conversion + to printable form, compression) must be described in their entirety + in the transfer encoding specification. Use of secret and/or + proprietary algorithms in standardized transfer encodings are + expressly prohibited. The restrictions imposed by RFC 1602 on the + standardization of patented algorithms must be respected as well. + +4.1.3. Input Domain Requirements + + All transfer encodings must be applicable to an arbitrary sequence of + octets of any length. Dependence on particular input forms is not + allowed. + + It should be noted that the 7bit and 8bit encodings do not conform to + this requirement. Aside from the undesireability of having + specialized encodings, the intent here is to forbid the addition of + additional encodings along the lines of 7bit and 8bit. + +4.1.4. Output Range Requirements + + There is no requirement that a particular tranfer encoding produce a + particular form of encoded output. However, the output format for + each transfer encoding must be fully and completely documented. In + particular, each specification must clearly state whether the output + format always lies within the confines of 7bit data, 8bit data, or is + simply pure binary data. + +4.1.5. Data Integrity and Generality Requirements + + All transfer encodings must be fully invertible on any platform; it + must be possible for anyone to recover the original data by + performing the corresponding decoding operation. Note that this + requirement effectively excludes all forms of lossy compression as + well as all forms of encryption from use as a transfer encoding. + +4.1.6. New Functionality Requirements + + All transfer encodings must provide some sort of new functionality. + Some degree of functionality overlap with previously defined transfer + encodings is acceptable, but any new transfer encoding must also + offer something no other transfer encoding provides. + + + + + + + + +Freed, et. al. Best Current Practice [Page 18] + +RFC 2048 MIME Registration Procedures November 1996 + + +4.2. Transfer Encoding Definition Procedure + + Definition of a new transfer encoding starts with the construction of + a draft of a standards-track RFC. The RFC must define the transfer + encoding precisely and completely, and must also provide substantial + justification for defining and standardizing a new transfer encoding. + This specification must then be presented to the IESG for + consideration. The IESG can + + (1) reject the specification outright as being + inappropriate for standardization, + + (2) approve the formation of an IETF working group to work + on the specification in accordance with IETF + procedures, or, + + (3) accept the specification as-is and put it directly on + the standards track. + + Transfer encoding specifications on the standards track follow normal + IETF rules for standards track documents. A transfer encoding is + considered to be defined and available for use once it is on the + standards track. + +4.3. IANA Procedures for Transfer Encoding Registration + + There is no need for a special procedure for registering Transfer + Encodings with the IANA. All legitimate transfer encoding + registrations must appear as a standards-track RFC, so it is the + IESG's responsibility to notify the IANA when a new transfer encoding + has been approved. + +4.4. Location of Registered Transfer Encodings List + + Transfer encoding registrations will be posted in the anonymous FTP + directory "ftp://ftp.isi.edu/in-notes/iana/assignments/transfer- + encodings/" and all registered transfer encodings will be listed in + the periodically issued "Assigned Numbers" RFC [currently RFC-1700]. + + + + + + + + + + + + + +Freed, et. al. Best Current Practice [Page 19] + +RFC 2048 MIME Registration Procedures November 1996 + + +5. Authors' Addresses + + For more information, the authors of this document are best + contacted via Internet mail: + + Ned Freed + Innosoft International, Inc. + 1050 East Garvey Avenue South + West Covina, CA 91790 + USA + + Phone: +1 818 919 3600 + Fax: +1 818 919 3614 + EMail: ned@innosoft.com + + + John Klensin + MCI + 2100 Reston Parkway + Reston, VA 22091 + + Phone: +1 703 715-7361 + Fax: +1 703 715-7436 + EMail: klensin@mci.net + + + Jon Postel + USC/Information Sciences Institute + 4676 Admiralty Way + Marina del Rey, CA 90292 + USA + + + Phone: +1 310 822 1511 + Fax: +1 310 823 6714 + EMail: Postel@ISI.EDU + + + + + + + + + + + + + + + +Freed, et. al. Best Current Practice [Page 20] + +RFC 2048 MIME Registration Procedures November 1996 + + +Appendix A -- Grandfathered Media Types + + A number of media types, registered prior to 1996, would, if + registered under the guidelines in this document, be placed into + either the vendor or personal trees. Reregistration of those types + to reflect the appropriate trees is encouraged, but not required. + Ownership and change control principles outlined in this document + apply to those types as if they had been registered in the trees + described above. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Freed, et. al. Best Current Practice [Page 21] + diff --git a/vendor/swiftmailer/swiftmailer/notes/rfc/rfc2049.txt b/vendor/swiftmailer/swiftmailer/notes/rfc/rfc2049.txt new file mode 100755 index 0000000..99f174b --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/notes/rfc/rfc2049.txt @@ -0,0 +1,1347 @@ + + + + + + +Network Working Group N. Freed +Request for Comments: 2049 Innosoft +Obsoletes: 1521, 1522, 1590 N. Borenstein +Category: Standards Track First Virtual + November 1996 + + + Multipurpose Internet Mail Extensions + (MIME) Part Five: + Conformance Criteria and Examples + +Status of this Memo + + This document specifies an Internet standards track protocol for the + Internet community, and requests discussion and suggestions for + improvements. Please refer to the current edition of the "Internet + Official Protocol Standards" (STD 1) for the standardization state + and status of this protocol. Distribution of this memo is unlimited. + +Abstract + + STD 11, RFC 822, defines a message representation protocol specifying + considerable detail about US-ASCII message headers, and leaves the + message content, or message body, as flat US-ASCII text. This set of + documents, collectively called the Multipurpose Internet Mail + Extensions, or MIME, redefines the format of messages to allow for + + (1) textual message bodies in character sets other than + US-ASCII, + + (2) an extensible set of different formats for non-textual + message bodies, + + (3) multi-part message bodies, and + + (4) textual header information in character sets other than + US-ASCII. + + These documents are based on earlier work documented in RFC 934, STD + 11, and RFC 1049, but extends and revises them. Because RFC 822 said + so little about message bodies, these documents are largely + orthogonal to (rather than a revision of) RFC 822. + + The initial document in this set, RFC 2045, specifies the various + headers used to describe the structure of MIME messages. The second + document defines the general structure of the MIME media typing + system and defines an initial set of media types. The third + document, RFC 2047, describes extensions to RFC 822 to allow non-US- + + + +Freed & Borenstein Standards Track [Page 1] + +RFC 2049 MIME Conformance November 1996 + + + ASCII text data in Internet mail header fields. The fourth document, + RFC 2048, specifies various IANA registration procedures for MIME- + related facilities. This fifth and final document describes MIME + conformance criteria as well as providing some illustrative examples + of MIME message formats, acknowledgements, and the bibliography. + + These documents are revisions of RFCs 1521, 1522, and 1590, which + themselves were revisions of RFCs 1341 and 1342. Appendix B of this + document describes differences and changes from previous versions. + +Table of Contents + + 1. Introduction .......................................... 2 + 2. MIME Conformance ...................................... 2 + 3. Guidelines for Sending Email Data ..................... 6 + 4. Canonical Encoding Model .............................. 9 + 5. Summary ............................................... 12 + 6. Security Considerations ............................... 12 + 7. Authors' Addresses .................................... 12 + 8. Acknowledgements ...................................... 13 + A. A Complex Multipart Example ........................... 15 + B. Changes from RFC 1521, 1522, and 1590 ................. 16 + C. References ............................................ 20 + +1. Introduction + + The first and second documents in this set define MIME header fields + and the initial set of MIME media types. The third document + describes extensions to RFC822 formats to allow for character sets + other than US-ASCII. This document describes what portions of MIME + must be supported by a conformant MIME implementation. It also + describes various pitfalls of contemporary messaging systems as well + as the canonical encoding model MIME is based on. + +2. MIME Conformance + + The mechanisms described in these documents are open-ended. It is + definitely not expected that all implementations will support all + available media types, nor that they will all share the same + extensions. In order to promote interoperability, however, it is + useful to define the concept of "MIME-conformance" to define a + certain level of implementation that allows the useful interworking + of messages with content that differs from US-ASCII text. In this + section, we specify the requirements for such conformance. + + + + + + + +Freed & Borenstein Standards Track [Page 2] + +RFC 2049 MIME Conformance November 1996 + + + A mail user agent that is MIME-conformant MUST: + + (1) Always generate a "MIME-Version: 1.0" header field in + any message it creates. + + (2) Recognize the Content-Transfer-Encoding header field + and decode all received data encoded by either quoted- + printable or base64 implementations. The identity + transformations 7bit, 8bit, and binary must also be + recognized. + + Any non-7bit data that is sent without encoding must be + properly labelled with a content-transfer-encoding of + 8bit or binary, as appropriate. If the underlying + transport does not support 8bit or binary (as SMTP + [RFC-821] does not), the sender is required to both + encode and label data using an appropriate Content- + Transfer-Encoding such as quoted-printable or base64. + + (3) Must treat any unrecognized Content-Transfer-Encoding + as if it had a Content-Type of "application/octet- + stream", regardless of whether or not the actual + Content-Type is recognized. + + (4) Recognize and interpret the Content-Type header field, + and avoid showing users raw data with a Content-Type + field other than text. Implementations must be able + to send at least text/plain messages, with the + character set specified with the charset parameter if + it is not US-ASCII. + + (5) Ignore any content type parameters whose names they do + not recognize. + + (6) Explicitly handle the following media type values, to + at least the following extents: + + Text: + + -- Recognize and display "text" mail with the + character set "US-ASCII." + + -- Recognize other character sets at least to the + extent of being able to inform the user about what + character set the message uses. + + + + + + +Freed & Borenstein Standards Track [Page 3] + +RFC 2049 MIME Conformance November 1996 + + + -- Recognize the "ISO-8859-*" character sets to the + extent of being able to display those characters that + are common to ISO-8859-* and US-ASCII, namely all + characters represented by octet values 1-127. + + -- For unrecognized subtypes in a known character + set, show or offer to show the user the "raw" version + of the data after conversion of the content from + canonical form to local form. + + -- Treat material in an unknown character set as if + it were "application/octet-stream". + + Image, audio, and video: + + -- At a minumum provide facilities to treat any + unrecognized subtypes as if they were + "application/octet-stream". + + Application: + + -- Offer the ability to remove either of the quoted- + printable or base64 encodings defined in this + document if they were used and put the resulting + information in a user file. + + Multipart: + + -- Recognize the mixed subtype. Display all relevant + information on the message level and the body part + header level and then display or offer to display + each of the body parts individually. + + -- Recognize the "alternative" subtype, and avoid + showing the user redundant parts of + multipart/alternative mail. + + -- Recognize the "multipart/digest" subtype, + specifically using "message/rfc822" rather than + "text/plain" as the default media type for body parts + inside "multipart/digest" entities. + + -- Treat any unrecognized subtypes as if they were + "mixed". + + + + + + + +Freed & Borenstein Standards Track [Page 4] + +RFC 2049 MIME Conformance November 1996 + + + Message: + + -- Recognize and display at least the RFC822 message + encapsulation (message/rfc822) in such a way as to + preserve any recursive structure, that is, displaying + or offering to display the encapsulated data in + accordance with its media type. + + -- Treat any unrecognized subtypes as if they were + "application/octet-stream". + + (7) Upon encountering any unrecognized Content-Type field, + an implementation must treat it as if it had a media + type of "application/octet-stream" with no parameter + sub-arguments. How such data are handled is up to an + implementation, but likely options for handling such + unrecognized data include offering the user to write it + into a file (decoded from its mail transport format) or + offering the user to name a program to which the + decoded data should be passed as input. + + (8) Conformant user agents are required, if they provide + non-standard support for non-MIME messages employing + character sets other than US-ASCII, to do so on + received messages only. Conforming user agents must not + send non-MIME messages containing anything other than + US-ASCII text. + + In particular, the use of non-US-ASCII text in mail + messages without a MIME-Version field is strongly + discouraged as it impedes interoperability when sending + messages between regions with different localization + conventions. Conforming user agents MUST include proper + MIME labelling when sending anything other than plain + text in the US-ASCII character set. + + In addition, non-MIME user agents should be upgraded if + at all possible to include appropriate MIME header + information in the messages they send even if nothing + else in MIME is supported. This upgrade will have + little, if any, effect on non-MIME recipients and will + aid MIME in correctly displaying such messages. It + also provides a smooth transition path to eventual + adoption of other MIME capabilities. + + (9) Conforming user agents must ensure that any string of + non-white-space printable US-ASCII characters within a + "*text" or "*ctext" that begins with "=?" and ends with + + + +Freed & Borenstein Standards Track [Page 5] + +RFC 2049 MIME Conformance November 1996 + + + "?=" be a valid encoded-word. ("begins" means: At the + start of the field-body or immediately following + linear-white-space; "ends" means: At the end of the + field-body or immediately preceding linear-white- + space.) In addition, any "word" within a "phrase" that + begins with "=?" and ends with "?=" must be a valid + encoded-word. + + (10) Conforming user agents must be able to distinguish + encoded-words from "text", "ctext", or "word"s, + according to the rules in section 4, anytime they + appear in appropriate places in message headers. It + must support both the "B" and "Q" encodings for any + character set which it supports. The program must be + able to display the unencoded text if the character set + is "US-ASCII". For the ISO-8859-* character sets, the + mail reading program must at least be able to display + the characters which are also in the US-ASCII set. + + A user agent that meets the above conditions is said to be MIME- + conformant. The meaning of this phrase is that it is assumed to be + "safe" to send virtually any kind of properly-marked data to users of + such mail systems, because such systems will at least be able to + treat the data as undifferentiated binary, and will not simply splash + it onto the screen of unsuspecting users. + + There is another sense in which it is always "safe" to send data in a + format that is MIME-conformant, which is that such data will not + break or be broken by any known systems that are conformant with RFC + 821 and RFC 822. User agents that are MIME-conformant have the + additional guarantee that the user will not be shown data that were + never intended to be viewed as text. + +3. Guidelines for Sending Email Data + + Internet email is not a perfect, homogeneous system. Mail may become + corrupted at several stages in its travel to a final destination. + Specifically, email sent throughout the Internet may travel across + many networking technologies. Many networking and mail technologies + do not support the full functionality possible in the SMTP transport + environment. Mail traversing these systems is likely to be modified + in order that it can be transported. + + There exist many widely-deployed non-conformant MTAs in the Internet. + These MTAs, speaking the SMTP protocol, alter messages on the fly to + take advantage of the internal data structure of the hosts they are + implemented on, or are just plain broken. + + + + +Freed & Borenstein Standards Track [Page 6] + +RFC 2049 MIME Conformance November 1996 + + + The following guidelines may be useful to anyone devising a data + format (media type) that is supposed to survive the widest range of + networking technologies and known broken MTAs unscathed. Note that + anything encoded in the base64 encoding will satisfy these rules, but + that some well-known mechanisms, notably the UNIX uuencode facility, + will not. Note also that anything encoded in the Quoted-Printable + encoding will survive most gateways intact, but possibly not some + gateways to systems that use the EBCDIC character set. + + (1) Under some circumstances the encoding used for data may + change as part of normal gateway or user agent + operation. In particular, conversion from base64 to + quoted-printable and vice versa may be necessary. This + may result in the confusion of CRLF sequences with line + breaks in text bodies. As such, the persistence of + CRLF as something other than a line break must not be + relied on. + + (2) Many systems may elect to represent and store text data + using local newline conventions. Local newline + conventions may not match the RFC822 CRLF convention -- + systems are known that use plain CR, plain LF, CRLF, or + counted records. The result is that isolated CR and LF + characters are not well tolerated in general; they may + be lost or converted to delimiters on some systems, and + hence must not be relied on. + + (3) The transmission of NULs (US-ASCII value 0) is + problematic in Internet mail. (This is largely the + result of NULs being used as a termination character by + many of the standard runtime library routines in the C + programming language.) The practice of using NULs as + termination characters is so entrenched now that + messages should not rely on them being preserved. + + (4) TAB (HT) characters may be misinterpreted or may be + automatically converted to variable numbers of spaces. + This is unavoidable in some environments, notably those + not based on the US-ASCII character set. Such + conversion is STRONGLY DISCOURAGED, but it may occur, + and mail formats must not rely on the persistence of + TAB (HT) characters. + + (5) Lines longer than 76 characters may be wrapped or + truncated in some environments. Line wrapping or line + truncation imposed by mail transports is STRONGLY + DISCOURAGED, but unavoidable in some cases. + Applications which require long lines must somehow + + + +Freed & Borenstein Standards Track [Page 7] + +RFC 2049 MIME Conformance November 1996 + + + differentiate between soft and hard line breaks. (A + simple way to do this is to use the quoted-printable + encoding.) + + (6) Trailing "white space" characters (SPACE, TAB (HT)) on + a line may be discarded by some transport agents, while + other transport agents may pad lines with these + characters so that all lines in a mail file are of + equal length. The persistence of trailing white space, + therefore, must not be relied on. + + (7) Many mail domains use variations on the US-ASCII + character set, or use character sets such as EBCDIC + which contain most but not all of the US-ASCII + characters. The correct translation of characters not + in the "invariant" set cannot be depended on across + character converting gateways. For example, this + situation is a problem when sending uuencoded + information across BITNET, an EBCDIC system. Similar + problems can occur without crossing a gateway, since + many Internet hosts use character sets other than US- + ASCII internally. The definition of Printable Strings + in X.400 adds further restrictions in certain special + cases. In particular, the only characters that are + known to be consistent across all gateways are the 73 + characters that correspond to the upper and lower case + letters A-Z and a-z, the 10 digits 0-9, and the + following eleven special characters: + + "'" (US-ASCII decimal value 39) + "(" (US-ASCII decimal value 40) + ")" (US-ASCII decimal value 41) + "+" (US-ASCII decimal value 43) + "," (US-ASCII decimal value 44) + "-" (US-ASCII decimal value 45) + "." (US-ASCII decimal value 46) + "/" (US-ASCII decimal value 47) + ":" (US-ASCII decimal value 58) + "=" (US-ASCII decimal value 61) + "?" (US-ASCII decimal value 63) + + A maximally portable mail representation will confine + itself to relatively short lines of text in which the + only meaningful characters are taken from this set of + 73 characters. The base64 encoding follows this rule. + + (8) Some mail transport agents will corrupt data that + includes certain literal strings. In particular, a + + + +Freed & Borenstein Standards Track [Page 8] + +RFC 2049 MIME Conformance November 1996 + + + period (".") alone on a line is known to be corrupted + by some (incorrect) SMTP implementations, and a line + that starts with the five characters "From " (the fifth + character is a SPACE) are commonly corrupted as well. + A careful composition agent can prevent these + corruptions by encoding the data (e.g., in the quoted- + printable encoding using "=46rom " in place of "From " + at the start of a line, and "=2E" in place of "." alone + on a line). + + Please note that the above list is NOT a list of recommended + practices for MTAs. RFC 821 MTAs are prohibited from altering the + character of white space or wrapping long lines. These BAD and + invalid practices are known to occur on established networks, and + implementations should be robust in dealing with the bad effects they + can cause. + +4. Canonical Encoding Model + + There was some confusion, in earlier versions of these documents, + regarding the model for when email data was to be converted to + canonical form and encoded, and in particular how this process would + affect the treatment of CRLFs, given that the representation of + newlines varies greatly from system to system. For this reason, a + canonical model for encoding is presented below. + + The process of composing a MIME entity can be modeled as being done + in a number of steps. Note that these steps are roughly similar to + those steps used in PEM [RFC-1421] and are performed for each + "innermost level" body: + + (1) Creation of local form. + + The body to be transmitted is created in the system's + native format. The native character set is used and, + where appropriate, local end of line conventions are + used as well. The body may be a UNIX-style text file, + or a Sun raster image, or a VMS indexed file, or audio + data in a system-dependent format stored only in + memory, or anything else that corresponds to the local + model for the representation of some form of + information. Fundamentally, the data is created in the + "native" form that corresponds to the type specified by + the media type. + + + + + + + +Freed & Borenstein Standards Track [Page 9] + +RFC 2049 MIME Conformance November 1996 + + + (2) Conversion to canonical form. + + The entire body, including "out-of-band" information + such as record lengths and possibly file attribute + information, is converted to a universal canonical + form. The specific media type of the body as well as + its associated attributes dictate the nature of the + canonical form that is used. Conversion to the proper + canonical form may involve character set conversion, + transformation of audio data, compression, or various + other operations specific to the various media types. + If character set conversion is involved, however, care + must be taken to understand the semantics of the media + type, which may have strong implications for any + character set conversion, e.g. with regard to + syntactically meaningful characters in a text subtype + other than "plain". + + For example, in the case of text/plain data, the text + must be converted to a supported character set and + lines must be delimited with CRLF delimiters in + accordance with RFC 822. Note that the restriction on + line lengths implied by RFC 822 is eliminated if the + next step employs either quoted-printable or base64 + encoding. + + (3) Apply transfer encoding. + + A Content-Transfer-Encoding appropriate for this body + is applied. Note that there is no fixed relationship + between the media type and the transfer encoding. In + particular, it may be appropriate to base the choice of + base64 or quoted-printable on character frequency + counts which are specific to a given instance of a + body. + + (4) Insertion into entity. + + The encoded body is inserted into a MIME entity with + appropriate headers. The entity is then inserted into + the body of a higher-level entity (message or + multipart) as needed. + + Conversion from entity form to local form is accomplished by + reversing these steps. Note that reversal of these steps may produce + differing results since there is no guarantee that the original and + final local forms are the same. + + + + +Freed & Borenstein Standards Track [Page 10] + +RFC 2049 MIME Conformance November 1996 + + + It is vital to note that these steps are only a model; they are + specifically NOT a blueprint for how an actual system would be built. + In particular, the model fails to account for two common designs: + + (1) In many cases the conversion to a canonical form prior + to encoding will be subsumed into the encoder itself, + which understands local formats directly. For example, + the local newline convention for text bodies might be + carried through to the encoder itself along with + knowledge of what that format is. + + (2) The output of the encoders may have to pass through one + or more additional steps prior to being transmitted as + a message. As such, the output of the encoder may not + be conformant with the formats specified by RFC 822. + In particular, once again it may be appropriate for the + converter's output to be expressed using local newline + conventions rather than using the standard RFC 822 CRLF + delimiters. + + Other implementation variations are conceivable as well. The vital + aspect of this discussion is that, in spite of any optimizations, + collapsings of required steps, or insertion of additional processing, + the resulting messages must be consistent with those produced by the + model described here. For example, a message with the following + header fields: + + Content-type: text/foo; charset=bar + Content-Transfer-Encoding: base64 + + must be first represented in the text/foo form, then (if necessary) + represented in the "bar" character set, and finally transformed via + the base64 algorithm into a mail-safe form. + + NOTE: Some confusion has been caused by systems that represent + messages in a format which uses local newline conventions which + differ from the RFC822 CRLF convention. It is important to note that + these formats are not canonical RFC822/MIME. These formats are + instead *encodings* of RFC822, where CRLF sequences in the canonical + representation of the message are encoded as the local newline + convention. Note that formats which encode CRLF sequences as, for + example, LF are not capable of representing MIME messages containing + binary data which contains LF octets not part of CRLF line separation + sequences. + + + + + + + +Freed & Borenstein Standards Track [Page 11] + +RFC 2049 MIME Conformance November 1996 + + +5. Summary + + This document defines what is meant by MIME Conformance. It also + details various problems known to exist in the Internet email system + and how to use MIME to overcome them. Finally, it describes MIME's + canonical encoding model. + +6. Security Considerations + + Security issues are discussed in the second document in this set, RFC + 2046. + +7. Authors' Addresses + + For more information, the authors of this document are best contacted + via Internet mail: + + Ned Freed + Innosoft International, Inc. + 1050 East Garvey Avenue South + West Covina, CA 91790 + USA + + Phone: +1 818 919 3600 + Fax: +1 818 919 3614 + EMail: ned@innosoft.com + + Nathaniel S. Borenstein + First Virtual Holdings + 25 Washington Avenue + Morristown, NJ 07960 + USA + + Phone: +1 201 540 8967 + Fax: +1 201 993 3032 + EMail: nsb@nsb.fv.com + + MIME is a result of the work of the Internet Engineering Task Force + Working Group on RFC 822 Extensions. The chairman of that group, + Greg Vaudreuil, may be reached at: + + Gregory M. Vaudreuil + Octel Network Services + 17080 Dallas Parkway + Dallas, TX 75248-1905 + USA + + EMail: Greg.Vaudreuil@Octel.Com + + + +Freed & Borenstein Standards Track [Page 12] + +RFC 2049 MIME Conformance November 1996 + + +8. Acknowledgements + + This document is the result of the collective effort of a large + number of people, at several IETF meetings, on the IETF-SMTP and + IETF-822 mailing lists, and elsewhere. Although any enumeration + seems doomed to suffer from egregious omissions, the following are + among the many contributors to this effort: + + Harald Tveit Alvestrand Marc Andreessen + Randall Atkinson Bob Braden + Philippe Brandon Brian Capouch + Kevin Carosso Uhhyung Choi + Peter Clitherow Dave Collier-Brown + Cristian Constantinof John Coonrod + Mark Crispin Dave Crocker + Stephen Crocker Terry Crowley + Walt Daniels Jim Davis + Frank Dawson Axel Deininger + Hitoshi Doi Kevin Donnelly + Steve Dorner Keith Edwards + Chris Eich Dana S. Emery + Johnny Eriksson Craig Everhart + Patrik Faltstrom Erik E. Fair + Roger Fajman Alain Fontaine + Martin Forssen James M. Galvin + Stephen Gildea Philip Gladstone + Thomas Gordon Keld Simonsen + Terry Gray Phill Gross + James Hamilton David Herron + Mark Horton Bruce Howard + Bill Janssen Olle Jarnefors + Risto Kankkunen Phil Karn + Alan Katz Tim Kehres + Neil Katin Steve Kille + Kyuho Kim Anders Klemets + John Klensin Valdis Kletniek + Jim Knowles Stev Knowles + Bob Kummerfeld Pekka Kytolaakso + Stellan Lagerstrom Vincent Lau + Timo Lehtinen Donald Lindsay + Warner Losh Carlyn Lowery + Laurence Lundblade Charles Lynn + John R. MacMillan Larry Masinter + Rick McGowan Michael J. McInerny + Leo Mclaughlin Goli Montaser-Kohsari + Tom Moore John Gardiner Myers + Erik Naggum Mark Needleman + Chris Newman John Noerenberg + + + +Freed & Borenstein Standards Track [Page 13] + +RFC 2049 MIME Conformance November 1996 + + + Mats Ohrman Julian Onions + Michael Patton David J. Pepper + Erik van der Poel Blake C. Ramsdell + Christer Romson Luc Rooijakkers + Marshall T. Rose Jonathan Rosenberg + Guido van Rossum Jan Rynning + Harri Salminen Michael Sanderson + Yutaka Sato Markku Savela + Richard Alan Schafer Masahiro Sekiguchi + Mark Sherman Bob Smart + Peter Speck Henry Spencer + Einar Stefferud Michael Stein + Klaus Steinberger Peter Svanberg + James Thompson Steve Uhler + Stuart Vance Peter Vanderbilt + Greg Vaudreuil Ed Vielmetti + Larry W. Virden Ryan Waldron + Rhys Weatherly Jay Weber + Dave Wecker Wally Wedel + Sven-Ove Westberg Brian Wideen + John Wobus Glenn Wright + Rayan Zachariassen David Zimmerman + + The authors apologize for any omissions from this list, which are + certainly unintentional. + + + + + + + + + + + + + + + + + + + + + + + + + + +Freed & Borenstein Standards Track [Page 14] + +RFC 2049 MIME Conformance November 1996 + + +Appendix A -- A Complex Multipart Example + + What follows is the outline of a complex multipart message. This + message contains five parts that are to be displayed serially: two + introductory plain text objects, an embedded multipart message, a + text/enriched object, and a closing encapsulated text message in a + non-ASCII character set. The embedded multipart message itself + contains two objects to be displayed in parallel, a picture and an + audio fragment. + + MIME-Version: 1.0 + From: Nathaniel Borenstein + To: Ned Freed + Date: Fri, 07 Oct 1994 16:15:05 -0700 (PDT) + Subject: A multipart example + Content-Type: multipart/mixed; + boundary=unique-boundary-1 + + This is the preamble area of a multipart message. + Mail readers that understand multipart format + should ignore this preamble. + + If you are reading this text, you might want to + consider changing to a mail reader that understands + how to properly display multipart messages. + + --unique-boundary-1 + + ... Some text appears here ... + + [Note that the blank between the boundary and the start + of the text in this part means no header fields were + given and this is text in the US-ASCII character set. + It could have been done with explicit typing as in the + next part.] + + --unique-boundary-1 + Content-type: text/plain; charset=US-ASCII + + This could have been part of the previous part, but + illustrates explicit versus implicit typing of body + parts. + + --unique-boundary-1 + Content-Type: multipart/parallel; boundary=unique-boundary-2 + + --unique-boundary-2 + Content-Type: audio/basic + + + +Freed & Borenstein Standards Track [Page 15] + +RFC 2049 MIME Conformance November 1996 + + + Content-Transfer-Encoding: base64 + + ... base64-encoded 8000 Hz single-channel + mu-law-format audio data goes here ... + + --unique-boundary-2 + Content-Type: image/jpeg + Content-Transfer-Encoding: base64 + + ... base64-encoded image data goes here ... + + --unique-boundary-2-- + + --unique-boundary-1 + Content-type: text/enriched + + This is enriched. + as defined in RFC 1896 + + Isn't it + cool? + + --unique-boundary-1 + Content-Type: message/rfc822 + + From: (mailbox in US-ASCII) + To: (address in US-ASCII) + Subject: (subject in US-ASCII) + Content-Type: Text/plain; charset=ISO-8859-1 + Content-Transfer-Encoding: Quoted-printable + + ... Additional text in ISO-8859-1 goes here ... + + --unique-boundary-1-- + +Appendix B -- Changes from RFC 1521, 1522, and 1590 + + These documents are a revision of RFC 1521, 1522, and 1590. For the + convenience of those familiar with the earlier documents, the changes + from those documents are summarized in this appendix. For further + history, note that Appendix H in RFC 1521 specified how that document + differed from its predecessor, RFC 1341. + + (1) This document has been completely reformatted and split + into multiple documents. This was done to improve the + quality of the plain text version of this document, + which is required to be the reference copy. + + + + +Freed & Borenstein Standards Track [Page 16] + +RFC 2049 MIME Conformance November 1996 + + + (2) BNF describing the overall structure of MIME object + headers has been added. This is a documentation change + only -- the underlying syntax has not changed in any + way. + + (3) The specific BNF for the seven media types in MIME has + been removed. This BNF was incorrect, incomplete, amd + inconsistent with the type-indendependent BNF. And + since the type-independent BNF already fully specifies + the syntax of the various MIME headers, the type- + specific BNF was, in the final analysis, completely + unnecessary and caused more problems than it solved. + + (4) The more specific "US-ASCII" character set name has + replaced the use of the informal term ASCII in many + parts of these documents. + + (5) The informal concept of a primary subtype has been + removed. + + (6) The term "object" was being used inconsistently. The + definition of this term has been clarified, along with + the related terms "body", "body part", and "entity", + and usage has been corrected where appropriate. + + (7) The BNF for the multipart media type has been + rearranged to make it clear that the CRLF preceeding + the boundary marker is actually part of the marker + itself rather than the preceeding body part. + + (8) The prose and BNF describing the multipart media type + have been changed to make it clear that the body parts + within a multipart object MUST NOT contain any lines + beginning with the boundary parameter string. + + (9) In the rules on reassembling "message/partial" MIME + entities, "Subject" is added to the list of headers to + take from the inner message, and the example is + modified to clarify this point. + + (10) "Message/partial" fragmenters are restricted to + splitting MIME objects only at line boundaries. + + (11) In the discussion of the application/postscript type, + an additional paragraph has been added warning about + possible interoperability problems caused by embedding + of binary data inside a PostScript MIME entity. + + + + +Freed & Borenstein Standards Track [Page 17] + +RFC 2049 MIME Conformance November 1996 + + + (12) Added a clarifying note to the basic syntax rules for + the Content-Type header field to make it clear that the + following two forms: + + Content-type: text/plain; charset=us-ascii (comment) + + Content-type: text/plain; charset="us-ascii" + + are completely equivalent. + + (13) The following sentence has been removed from the + discussion of the MIME-Version header: "However, + conformant software is encouraged to check the version + number and at least warn the user if an unrecognized + MIME-version is encountered." + + (14) A typo was fixed that said "application/external-body" + instead of "message/external-body". + + (15) The definition of a character set has been reorganized + to make the requirements clearer. + + (16) The definition of the "image/gif" media type has been + moved to a separate document. This change was made + because of potential conflicts with IETF rules + governing the standardization of patented technology. + + (17) The definitions of "7bit" and "8bit" have been + tightened so that use of bare CR, LF can only be used + as end-of-line sequences. The document also no longer + requires that NUL characters be preserved, which brings + MIME into alignment with real-world implementations. + + (18) The definition of canonical text in MIME has been + tightened so that line breaks must be represented by a + CRLF sequence. CR and LF characters are not allowed + outside of this usage. The definition of quoted- + printable encoding has been altered accordingly. + + (19) The definition of the quoted-printable encoding now + includes a number of suggestions for how quoted- + printable encoders might best handle improperly encoded + material. + + (20) Prose was added to clarify the use of the "7bit", + "8bit", and "binary" transfer-encodings on multipart or + message entities encapsulating "8bit" or "binary" data. + + + + +Freed & Borenstein Standards Track [Page 18] + +RFC 2049 MIME Conformance November 1996 + + + (21) In the section on MIME Conformance, "multipart/digest" + support was added to the list of requirements for + minimal MIME conformance. Also, the requirement for + "message/rfc822" support were strengthened to clarify + the importance of recognizing recursive structure. + + (22) The various restrictions on subtypes of "message" are + now specified entirely on a subtype by subtype basis. + + (23) The definition of "message/rfc822" was changed to + indicate that at least one of the "From", "Subject", or + "Date" headers must be present. + + (24) The required handling of unrecognized subtypes as + "application/octet-stream" has been made more explicit + in both the type definitions sections and the + conformance guidelines. + + (25) Examples using text/richtext were changed to + text/enriched. + + (26) The BNF definition of subtype has been changed to make + it clear that either an IANA registered subtype or a + nonstandard "X-" subtype must be used in a Content-Type + header field. + + (27) MIME media types that are simply registered for use and + those that are standardized by the IETF are now + distinguished in the MIME BNF. + + (28) All of the various MIME registration procedures have + been extensively revised. IANA registration procedures + for character sets have been moved to a separate + document that is no included in this set of documents. + + (29) The use of escape and shift mechanisms in the US-ASCII + and ISO-8859-X character sets these documents define + have been clarified: Such mechanisms should never be + used in conjunction with these character sets and their + effect if they are used is undefined. + + (30) The definition of the AFS access-type for + message/external-body has been removed. + + (31) The handling of the combination of + multipart/alternative and message/external-body is now + specifically addressed. + + + + +Freed & Borenstein Standards Track [Page 19] + +RFC 2049 MIME Conformance November 1996 + + + (32) Security issues specific to message/external-body are + now discussed in some detail. + +Appendix C -- References + + [ATK] + Borenstein, Nathaniel S., Multimedia Applications + Development with the Andrew Toolkit, Prentice-Hall, 1990. + + [ISO-2022] + International Standard -- Information Processing -- + Character Code Structure and Extension Techniques, + ISO/IEC 2022:1994, 4th ed. + + [ISO-8859] + International Standard -- Information Processing -- 8-bit + Single-Byte Coded Graphic Character Sets + - Part 1: Latin Alphabet No. 1, ISO 8859-1:1987, 1st ed. + - Part 2: Latin Alphabet No. 2, ISO 8859-2:1987, 1st ed. + - Part 3: Latin Alphabet No. 3, ISO 8859-3:1988, 1st ed. + - Part 4: Latin Alphabet No. 4, ISO 8859-4:1988, 1st ed. + - Part 5: Latin/Cyrillic Alphabet, ISO 8859-5:1988, 1st + ed. + - Part 6: Latin/Arabic Alphabet, ISO 8859-6:1987, 1st ed. + - Part 7: Latin/Greek Alphabet, ISO 8859-7:1987, 1st ed. + - Part 8: Latin/Hebrew Alphabet, ISO 8859-8:1988, 1st ed. + - Part 9: Latin Alphabet No. 5, ISO/IEC 8859-9:1989, 1st + ed. + International Standard -- Information Technology -- 8-bit + Single-Byte Coded Graphic Character Sets + - Part 10: Latin Alphabet No. 6, ISO/IEC 8859-10:1992, + 1st ed. + + [ISO-646] + International Standard -- Information Technology -- ISO + 7-bit Coded Character Set for Information Interchange, + ISO 646:1991, 3rd ed.. + + [JPEG] + JPEG Draft Standard ISO 10918-1 CD. + + [MPEG] + Video Coding Draft Standard ISO 11172 CD, ISO + IEC/JTC1/SC2/WG11 (Motion Picture Experts Group), May, + 1991. + + + + + + +Freed & Borenstein Standards Track [Page 20] + +RFC 2049 MIME Conformance November 1996 + + + [PCM] + CCITT, Fascicle III.4 - Recommendation G.711, "Pulse Code + Modulation (PCM) of Voice Frequencies", Geneva, 1972. + + [POSTSCRIPT] + Adobe Systems, Inc., PostScript Language Reference + Manual, Addison-Wesley, 1985. + + [POSTSCRIPT2] + Adobe Systems, Inc., PostScript Language Reference + Manual, Addison-Wesley, Second Ed., 1990. + + [RFC-783] + Sollins, K.R., "TFTP Protocol (revision 2)", RFC-783, + MIT, June 1981. + + [RFC-821] + Postel, J.B., "Simple Mail Transfer Protocol", STD 10, + RFC 821, USC/Information Sciences Institute, August 1982. + + [RFC-822] + Crocker, D., "Standard for the Format of ARPA Internet + Text Messages", STD 11, RFC 822, UDEL, August 1982. + + [RFC-934] + Rose, M. and E. Stefferud, "Proposed Standard for Message + Encapsulation", RFC 934, Delaware and NMA, January 1985. + + [RFC-959] + Postel, J. and J. Reynolds, "File Transfer Protocol", STD + 9, RFC 959, USC/Information Sciences Institute, October + 1985. + + [RFC-1049] + Sirbu, M., "Content-Type Header Field for Internet + Messages", RFC 1049, CMU, March 1988. + + [RFC-1154] + Robinson, D., and R. Ullmann, "Encoding Header Field for + Internet Messages", RFC 1154, Prime Computer, Inc., April + 1990. + + [RFC-1341] + Borenstein, N., and N. Freed, "MIME (Multipurpose + Internet Mail Extensions): Mechanisms for Specifying and + Describing the Format of Internet Message Bodies", RFC + 1341, Bellcore, Innosoft, June 1992. + + + + +Freed & Borenstein Standards Track [Page 21] + +RFC 2049 MIME Conformance November 1996 + + + [RFC-1342] + Moore, K., "Representation of Non-Ascii Text in Internet + Message Headers", RFC 1342, University of Tennessee, June + 1992. + + [RFC-1344] + Borenstein, N., "Implications of MIME for Internet Mail + Gateways", RFC 1344, Bellcore, June 1992. + + [RFC-1345] + Simonsen, K., "Character Mnemonics & Character Sets", RFC + 1345, Rationel Almen Planlaegning, June 1992. + + [RFC-1421] + Linn, J., "Privacy Enhancement for Internet Electronic + Mail: Part I -- Message Encryption and Authentication + Procedures", RFC 1421, IAB IRTF PSRG, IETF PEM WG, + February 1993. + + [RFC-1422] + Kent, S., "Privacy Enhancement for Internet Electronic + Mail: Part II -- Certificate-Based Key Management", RFC + 1422, IAB IRTF PSRG, IETF PEM WG, February 1993. + + [RFC-1423] + Balenson, D., "Privacy Enhancement for Internet + Electronic Mail: Part III -- Algorithms, Modes, and + Identifiers", IAB IRTF PSRG, IETF PEM WG, February 1993. + + [RFC-1424] + Kaliski, B., "Privacy Enhancement for Internet Electronic + Mail: Part IV -- Key Certification and Related + Services", IAB IRTF PSRG, IETF PEM WG, February 1993. + + [RFC-1521] + Borenstein, N., and Freed, N., "MIME (Multipurpose + Internet Mail Extensions): Mechanisms for Specifying and + Describing the Format of Internet Message Bodies", RFC + 1521, Bellcore, Innosoft, September, 1993. + + [RFC-1522] + Moore, K., "Representation of Non-ASCII Text in Internet + Message Headers", RFC 1522, University of Tennessee, + September 1993. + + + + + + + +Freed & Borenstein Standards Track [Page 22] + +RFC 2049 MIME Conformance November 1996 + + + [RFC-1524] + Borenstein, N., "A User Agent Configuration Mechanism for + Multimedia Mail Format Information", RFC 1524, Bellcore, + September 1993. + + [RFC-1543] + Postel, J., "Instructions to RFC Authors", RFC 1543, + USC/Information Sciences Institute, October 1993. + + [RFC-1556] + Nussbacher, H., "Handling of Bi-directional Texts in + MIME", RFC 1556, Israeli Inter-University Computer + Center, December 1993. + + [RFC-1590] + Postel, J., "Media Type Registration Procedure", RFC + 1590, USC/Information Sciences Institute, March 1994. + + [RFC-1602] + Internet Architecture Board, Internet Engineering + Steering Group, Huitema, C., Gross, P., "The Internet + Standards Process -- Revision 2", March 1994. + + [RFC-1652] + Klensin, J., (WG Chair), Freed, N., (Editor), Rose, M., + Stefferud, E., and Crocker, D., "SMTP Service Extension + for 8bit-MIME transport", RFC 1652, United Nations + University, Innosoft, Dover Beach Consulting, Inc., + Network Management Associates, Inc., The Branch Office, + March 1994. + + [RFC-1700] + Reynolds, J. and J. Postel, "Assigned Numbers", STD 2, + RFC 1700, USC/Information Sciences Institute, October + 1994. + + [RFC-1741] + Faltstrom, P., Crocker, D., and Fair, E., "MIME Content + Type for BinHex Encoded Files", December 1994. + + [RFC-1896] + Resnick, P., and A. Walker, "The text/enriched MIME + Content-type", RFC 1896, February, 1996. + + + + + + + + +Freed & Borenstein Standards Track [Page 23] + +RFC 2049 MIME Conformance November 1996 + + + [RFC-2045] + Freed, N., and and N. Borenstein, "Multipurpose Internet Mail + Extensions (MIME) Part One: Format of Internet Message + Bodies", RFC 2045, Innosoft, First Virtual Holdings, + November 1996. + + [RFC-2046] + Freed, N., and N. Borenstein, "Multipurpose Internet Mail + Extensions (MIME) Part Two: Media Types", RFC 2046, + Innosoft, First Virtual Holdings, November 1996. + + [RFC-2047] + Moore, K., "Multipurpose Internet Mail Extensions (MIME) + Part Three: Representation of Non-ASCII Text in Internet + Message Headers", RFC 2047, University of + Tennessee, November 1996. + + [RFC-2048] + Freed, N., Klensin, J., and J. Postel, "Multipurpose + Internet Mail Extensions (MIME) Part Four: MIME + Registration Procedures", RFC 2048, Innosoft, MCI, + ISI, November 1996. + + [RFC-2049] + Freed, N. and N. Borenstein, "Multipurpose Internet Mail + Extensions (MIME) Part Five: Conformance Criteria and + Examples", RFC 2049 (this document), Innosoft, First + Virtual Holdings, November 1996. + + [US-ASCII] + Coded Character Set -- 7-Bit American Standard Code for + Information Interchange, ANSI X3.4-1986. + + [X400] + Schicker, Pietro, "Message Handling Systems, X.400", + Message Handling Systems and Distributed Applications, E. + Stefferud, O-j. Jacobsen, and P. Schicker, eds., North- + Holland, 1989, pp. 3-41. + + + + + + + + + + + + + +Freed & Borenstein Standards Track [Page 24] + diff --git a/vendor/swiftmailer/swiftmailer/notes/rfc/rfc2183.txt b/vendor/swiftmailer/swiftmailer/notes/rfc/rfc2183.txt new file mode 100755 index 0000000..f16f127 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/notes/rfc/rfc2183.txt @@ -0,0 +1,675 @@ + + + + + + +Network Working Group R. Troost +Request for Comments: 2183 New Century Systems +Updates: 1806 S. Dorner +Category: Standards Track QUALCOMM Incorporated + K. Moore, Editor + University of Tennessee + August 1997 + + + Communicating Presentation Information in + Internet Messages: + The Content-Disposition Header Field + +Status of this Memo + + This document specifies an Internet standards track protocol for the + Internet community, and requests discussion and suggestions for + improvements. Please refer to the current edition of the "Internet + Official Protocol Standards" (STD 1) for the standardization state + and status of this protocol. Distribution of this memo is unlimited. + +Abstract + + This memo provides a mechanism whereby messages conforming to the + MIME specifications [RFC 2045, RFC 2046, RFC 2047, RFC 2048, RFC + 2049] can convey presentational information. It specifies the + "Content-Disposition" header field, which is optional and valid for + any MIME entity ("message" or "body part"). Two values for this + header field are described in this memo; one for the ordinary linear + presentation of the body part, and another to facilitate the use of + mail to transfer files. It is expected that more values will be + defined in the future, and procedures are defined for extending this + set of values. + + This document is intended as an extension to MIME. As such, the + reader is assumed to be familiar with the MIME specifications, and + [RFC 822]. The information presented herein supplements but does not + replace that found in those documents. + + This document is a revision to the Experimental protocol defined in + RFC 1806. As compared to RFC 1806, this document contains minor + editorial updates, adds new parameters needed to support the File + Transfer Body Part, and references a separate specification for the + handling of non-ASCII and/or very long parameter values. + + + + + + + +Troost, et. al. Standards Track [Page 1] + +RFC 2183 Content-Disposition August 1997 + + +1. Introduction + + MIME specifies a standard format for encapsulating multiple pieces of + data into a single Internet message. That document does not address + the issue of presentation styles; it provides a framework for the + interchange of message content, but leaves presentation issues solely + in the hands of mail user agent (MUA) implementors. + + Two common ways of presenting multipart electronic messages are as a + main document with a list of separate attachments, and as a single + document with the various parts expanded (displayed) inline. The + display of an attachment is generally construed to require positive + action on the part of the recipient, while inline message components + are displayed automatically when the message is viewed. A mechanism + is needed to allow the sender to transmit this sort of presentational + information to the recipient; the Content-Disposition header provides + this mechanism, allowing each component of a message to be tagged + with an indication of its desired presentation semantics. + + Tagging messages in this manner will often be sufficient for basic + message formatting. However, in many cases a more powerful and + flexible approach will be necessary. The definition of such + approaches is beyond the scope of this memo; however, such approaches + can benefit from additional Content-Disposition values and + parameters, to be defined at a later date. + + In addition to allowing the sender to specify the presentational + disposition of a message component, it is desirable to allow her to + indicate a default archival disposition; a filename. The optional + "filename" parameter provides for this. Further, the creation-date, + modification-date, and read-date parameters allow preservation of + those file attributes when the file is transmitted over MIME email. + + NB: The keywords MUST, MUST NOT, REQUIRED, SHALL, SHALL NOT, SHOULD, + SHOULD NOT, RECOMMENDED, MAY, and OPTIONAL, when they appear in this + document, are to be interpreted as described in [RFC 2119]. + +2. The Content-Disposition Header Field + + Content-Disposition is an optional header field. In its absence, the + MUA may use whatever presentation method it deems suitable. + + It is desirable to keep the set of possible disposition types small + and well defined, to avoid needless complexity. Even so, evolving + usage will likely require the definition of additional disposition + types or parameters, so the set of disposition values is extensible; + see below. + + + + +Troost, et. al. Standards Track [Page 2] + +RFC 2183 Content-Disposition August 1997 + + + In the extended BNF notation of [RFC 822], the Content-Disposition + header field is defined as follows: + + disposition := "Content-Disposition" ":" + disposition-type + *(";" disposition-parm) + + disposition-type := "inline" + / "attachment" + / extension-token + ; values are not case-sensitive + + disposition-parm := filename-parm + / creation-date-parm + / modification-date-parm + / read-date-parm + / size-parm + / parameter + + filename-parm := "filename" "=" value + + creation-date-parm := "creation-date" "=" quoted-date-time + + modification-date-parm := "modification-date" "=" quoted-date-time + + read-date-parm := "read-date" "=" quoted-date-time + + size-parm := "size" "=" 1*DIGIT + + quoted-date-time := quoted-string + ; contents MUST be an RFC 822 `date-time' + ; numeric timezones (+HHMM or -HHMM) MUST be used + + + + NOTE ON PARAMETER VALUE LENGHTS: A short (length <= 78 characters) + parameter value containing only non-`tspecials' characters SHOULD be + represented as a single `token'. A short parameter value containing + only ASCII characters, but including `tspecials' characters, SHOULD + be represented as `quoted-string'. Parameter values longer than 78 + characters, or which contain non-ASCII characters, MUST be encoded as + specified in [RFC 2184]. + + `Extension-token', `parameter', `tspecials' and `value' are defined + according to [RFC 2045] (which references [RFC 822] in the definition + of some of these tokens). `quoted-string' and `DIGIT' are defined in + [RFC 822]. + + + + +Troost, et. al. Standards Track [Page 3] + +RFC 2183 Content-Disposition August 1997 + + +2.1 The Inline Disposition Type + + A bodypart should be marked `inline' if it is intended to be + displayed automatically upon display of the message. Inline + bodyparts should be presented in the order in which they occur, + subject to the normal semantics of multipart messages. + +2.2 The Attachment Disposition Type + + Bodyparts can be designated `attachment' to indicate that they are + separate from the main body of the mail message, and that their + display should not be automatic, but contingent upon some further + action of the user. The MUA might instead present the user of a + bitmap terminal with an iconic representation of the attachments, or, + on character terminals, with a list of attachments from which the + user could select for viewing or storage. + +2.3 The Filename Parameter + + The sender may want to suggest a filename to be used if the entity is + detached and stored in a separate file. If the receiving MUA writes + the entity to a file, the suggested filename should be used as a + basis for the actual filename, where possible. + + It is important that the receiving MUA not blindly use the suggested + filename. The suggested filename SHOULD be checked (and possibly + changed) to see that it conforms to local filesystem conventions, + does not overwrite an existing file, and does not present a security + problem (see Security Considerations below). + + The receiving MUA SHOULD NOT respect any directory path information + that may seem to be present in the filename parameter. The filename + should be treated as a terminal component only. Portable + specification of directory paths might possibly be done in the future + via a separate Content-Disposition parameter, but no provision is + made for it in this draft. + + Current [RFC 2045] grammar restricts parameter values (and hence + Content-Disposition filenames) to US-ASCII. We recognize the great + desirability of allowing arbitrary character sets in filenames, but + it is beyond the scope of this document to define the necessary + mechanisms. We expect that the basic [RFC 1521] `value' + specification will someday be amended to allow use of non-US-ASCII + characters, at which time the same mechanism should be used in the + Content-Disposition filename parameter. + + + + + + +Troost, et. al. Standards Track [Page 4] + +RFC 2183 Content-Disposition August 1997 + + + Beyond the limitation to US-ASCII, the sending MUA may wish to bear + in mind the limitations of common filesystems. Many have severe + length and character set restrictions. Short alphanumeric filenames + are least likely to require modification by the receiving system. + + The presence of the filename parameter does not force an + implementation to write the entity to a separate file. It is + perfectly acceptable for implementations to leave the entity as part + of the normal mail stream unless the user requests otherwise. As a + consequence, the parameter may be used on any MIME entity, even + `inline' ones. These will not normally be written to files, but the + parameter could be used to provide a filename if the receiving user + should choose to write the part to a file. + +2.4 The Creation-Date parameter + + The creation-date parameter MAY be used to indicate the date at which + the file was created. If this parameter is included, the paramter + value MUST be a quoted-string which contains a representation of the + creation date of the file in [RFC 822] `date-time' format. + + UNIX and POSIX implementors are cautioned that the `st_ctime' file + attribute of the `stat' structure is not the creation time of the + file; it is thus not appropriate as a source for the creation-date + parameter value. + +2.5 The Modification-Date parameter + + The modification-date parameter MAY be used to indicate the date at + which the file was last modified. If the modification-date parameter + is included, the paramter value MUST be a quoted-string which + contains a representation of the last modification date of the file + in [RFC 822] `date-time' format. + +2.6 The Read-Date parameter + + The read-date parameter MAY be used to indicate the date at which the + file was last read. If the read-date parameter is included, the + parameter value MUST be a quoted-string which contains a + representation of the last-read date of the file in [RFC 822] `date- + time' format. + +2.7 The Size parameter + + The size parameter indicates an approximate size of the file in + octets. It can be used, for example, to pre-allocate space before + attempting to store the file, or to determine whether enough space + exists. + + + +Troost, et. al. Standards Track [Page 5] + +RFC 2183 Content-Disposition August 1997 + + +2.8 Future Extensions and Unrecognized Disposition Types + + In the likely event that new parameters or disposition types are + needed, they should be registered with the Internet Assigned Numbers + Authority (IANA), in the manner specified in Section 9 of this memo. + + Once new disposition types and parameters are defined, there is of + course the likelihood that implementations will see disposition types + and parameters they do not understand. Furthermore, since x-tokens + are allowed, implementations may also see entirely unregistered + disposition types and parameters. + + Unrecognized parameters should be ignored. Unrecognized disposition + types should be treated as `attachment'. The choice of `attachment' + for unrecognized types is made because a sender who goes to the + trouble of producing a Content-Disposition header with a new + disposition type is more likely aiming for something more elaborate + than inline presentation. + + Unless noted otherwise in the definition of a parameter, Content- + Disposition parameters are valid for all dispositions. (In contrast + to MIME content-type parameters, which are defined on a per-content- + type basis.) Thus, for example, the `filename' parameter still means + the name of the file to which the part should be written, even if the + disposition itself is unrecognized. + +2.9 Content-Disposition and Multipart + + If a Content-Disposition header is used on a multipart body part, it + applies to the multipart as a whole, not the individual subparts. + The disposition types of the subparts do not need to be consulted + until the multipart itself is presented. When the multipart is + displayed, then the dispositions of the subparts should be respected. + + If the `inline' disposition is used, the multipart should be + displayed as normal; however, an `attachment' subpart should require + action from the user to display. + + If the `attachment' disposition is used, presentation of the + multipart should not proceed without explicit user action. Once the + user has chosen to display the multipart, the individual subpart + dispositions should be consulted to determine how to present the + subparts. + + + + + + + + +Troost, et. al. Standards Track [Page 6] + +RFC 2183 Content-Disposition August 1997 + + +2.10 Content-Disposition and the Main Message + + It is permissible to use Content-Disposition on the main body of an + [RFC 822] message. + +3. Examples + + Here is a an example of a body part containing a JPEG image that is + intended to be viewed by the user immediately: + + Content-Type: image/jpeg + Content-Disposition: inline + Content-Description: just a small picture of me + + + + The following body part contains a JPEG image that should be + displayed to the user only if the user requests it. If the JPEG is + written to a file, the file should be named "genome.jpg". The + recipient's user might also choose to set the last-modified date of + the stored file to date in the modification-date parameter: + + Content-Type: image/jpeg + Content-Disposition: attachment; filename=genome.jpeg; + modification-date="Wed, 12 Feb 1997 16:29:51 -0500"; + Content-Description: a complete map of the human genome + + + + The following is an example of the use of the `attachment' + disposition with a multipart body part. The user should see text- + part-1 immediately, then take some action to view multipart-2. After + taking action to view multipart-2, the user will see text-part-2 + right away, and be required to take action to view jpeg-1. Subparts + are indented for clarity; they would not be so indented in a real + message. + + + + + + + + + + + + + + + +Troost, et. al. Standards Track [Page 7] + +RFC 2183 Content-Disposition August 1997 + + + Content-Type: multipart/mixed; boundary=outer + Content-Description: multipart-1 + + --outer + Content-Type: text/plain + Content-Disposition: inline + Content-Description: text-part-1 + + Some text goes here + + --outer + Content-Type: multipart/mixed; boundary=inner + Content-Disposition: attachment + Content-Description: multipart-2 + + --inner + Content-Type: text/plain + Content-Disposition: inline + Content-Description: text-part-2 + + Some more text here. + + --inner + Content-Type: image/jpeg + Content-Disposition: attachment + Content-Description: jpeg-1 + + + --inner-- + --outer-- + +4. Summary + + Content-Disposition takes one of two values, `inline' and + `attachment'. `Inline' indicates that the entity should be + immediately displayed to the user, whereas `attachment' means that + the user should take additional action to view the entity. + + The `filename' parameter can be used to suggest a filename for + storing the bodypart, if the user wishes to store it in an external + file. + + + + + + + + + + +Troost, et. al. Standards Track [Page 8] + +RFC 2183 Content-Disposition August 1997 + + +5. Security Considerations + + There are security issues involved any time users exchange data. + While these are not to be minimized, neither does this memo change + the status quo in that regard, except in one instance. + + Since this memo provides a way for the sender to suggest a filename, + a receiving MUA must take care that the sender's suggested filename + does not represent a hazard. Using UNIX as an example, some hazards + would be: + + + Creating startup files (e.g., ".login"). + + + Creating or overwriting system files (e.g., "/etc/passwd"). + + + Overwriting any existing file. + + + Placing executable files into any command search path + (e.g., "~/bin/more"). + + + Sending the file to a pipe (e.g., "| sh"). + + In general, the receiving MUA should not name or place the file such + that it will get interpreted or executed without the user explicitly + initiating the action. + + It is very important to note that this is not an exhaustive list; it + is intended as a small set of examples only. Implementors must be + alert to the potential hazards on their target systems. + +6. References + + [RFC 2119] + Bradner, S., "Key words for use in RFCs to Indicate Requirement + Levels", RFC 2119, March 1997. + + [RFC 2184] + Freed, N. and K. Moore, "MIME Parameter value and Encoded Words: + Character Sets, Lanaguage, and Continuations", RFC 2184, August + 1997. + + [RFC 2045] + Freed, N. and N. Borenstein, "MIME (Multipurpose Internet Mail + Extensions) Part One: Format of Internet Message Bodies", RFC + 2045, December 1996. + + + + + + +Troost, et. al. Standards Track [Page 9] + +RFC 2183 Content-Disposition August 1997 + + + [RFC 2046] + Freed, N. and N. Borenstein, "MIME (Multipurpose Internet Mail + Extensions) Part Two: Media Types", RFC 2046, December 1996. + + [RFC 2047] + Moore, K., "MIME (Multipurpose Internet Mail Extensions) Part + Three: Message Header Extensions for non-ASCII Text", RFC 2047, + December 1996. + + [RFC 2048] + Freed, N., Klensin, J. and J. Postel, "MIME (Multipurpose + Internet Mail Extensions) Part Four: Registration Procedures", + RFC 2048, December 1996. + + [RFC 2049] + Freed, N. and N. Borenstein, "MIME (Multipurpose Internet Mail + Extensions) Part Five: Conformance Criteria and Examples", RFC + 2049, December 1996. + + [RFC 822] + Crocker, D., "Standard for the Format of ARPA Internet Text + Messages", STD 11, RFC 822, UDEL, August 1982. + +7. Acknowledgements + + We gratefully acknowledge the help these people provided during the + preparation of this draft: + + Nathaniel Borenstein + Ned Freed + Keith Moore + Dave Crocker + Dan Pritchett + + + + + + + + + + + + + + + + + + +Troost, et. al. Standards Track [Page 10] + +RFC 2183 Content-Disposition August 1997 + + +8. Authors' Addresses + + You should blame the editor of this version of the document for any + changes since RFC 1806: + + Keith Moore + Department of Computer Science + University of Tennessee, Knoxville + 107 Ayres Hall + Knoxville TN 37996-1301 + USA + + Phone: +1 (423) 974-5067 + Fax: +1 (423) 974-8296 + Email: moore@cs.utk.edu + + + The authors of RFC 1806 are: + + Rens Troost + New Century Systems + 324 East 41st Street #804 + New York, NY, 10017 USA + + Phone: +1 (212) 557-2050 + Fax: +1 (212) 557-2049 + EMail: rens@century.com + + + Steve Dorner + QUALCOMM Incorporated + 6455 Lusk Boulevard + San Diego, CA 92121 + USA + + EMail: sdorner@qualcomm.com + + +9. Registration of New Content-Disposition Values and Parameters + + New Content-Disposition values (besides "inline" and "attachment") + may be defined only by Internet standards-track documents, or in + Experimental documents approved by the Internet Engineering Steering + Group. + + + + + + + +Troost, et. al. Standards Track [Page 11] + +RFC 2183 Content-Disposition August 1997 + + + New content-disposition parameters may be registered by supplying the + information in the following template and sending it via electronic + mail to IANA@IANA.ORG: + + To: IANA@IANA.ORG + Subject: Registration of new Content-Disposition parameter + + Content-Disposition parameter name: + + Allowable values for this parameter: + (If the parameter can only assume a small number of values, + list each of those values. Otherwise, describe the values + that the parameter can assume.) + Description: + (What is the purpose of this parameter and how is it used?) + +10. Changes since RFC 1806 + + The following changes have been made since the earlier version of + this document, published in RFC 1806 as an Experimental protocol: + + + Updated references to MIME documents. In some cases this + involved substituting a reference to one of the current MIME + RFCs for a reference to RFC 1521; in other cases, a reference to + RFC 1521 was simply replaced with the word "MIME". + + + Added a section on registration procedures, since none of the + procedures in RFC 2048 seemed to be appropriate. + + + Added new parameter types: creation-date, modification-date, + read-date, and size. + + + + Incorporated a reference to draft-freed-pvcsc-* for encoding + long or non-ASCII parameter values. + + + Added reference to RFC 2119 to define MUST, SHOULD, etc. + keywords. + + + + + + + + + + + + + +Troost, et. al. Standards Track [Page 12] + diff --git a/vendor/swiftmailer/swiftmailer/notes/rfc/rfc2222.txt b/vendor/swiftmailer/swiftmailer/notes/rfc/rfc2222.txt new file mode 100755 index 0000000..2b0a2ab --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/notes/rfc/rfc2222.txt @@ -0,0 +1,899 @@ + + + + + + +Network Working Group J. Myers +Request for Comments: 2222 Netscape Communications +Category: Standards Track October 1997 + + + Simple Authentication and Security Layer (SASL) + +Status of this Memo + + This document specifies an Internet standards track protocol for the + Internet community, and requests discussion and suggestions for + improvements. Please refer to the current edition of the "Internet + Official Protocol Standards" (STD 1) for the standardization state + and status of this protocol. Distribution of this memo is unlimited. + +Copyright Notice + + Copyright (C) The Internet Society (1997). All Rights Reserved. + +Table of Contents + + 1. Abstract .............................................. 2 + 2. Organization of this Document ......................... 2 + 2.1. How to Read This Document ............................. 2 + 2.2. Conventions Used in this Document ..................... 2 + 2.3. Examples .............................................. 3 + 3. Introduction and Overview ............................. 3 + 4. Profiling requirements ................................ 4 + 5. Specific issues ....................................... 5 + 5.1. Client sends data first ............................... 5 + 5.2. Server returns success with additional data ........... 5 + 5.3. Multiple authentications .............................. 5 + 6. Registration procedures ............................... 6 + 6.1. Comments on SASL mechanism registrations .............. 6 + 6.2. Location of Registered SASL Mechanism List ............ 6 + 6.3. Change Control ........................................ 7 + 6.4. Registration Template ................................. 7 + 7. Mechanism definitions ................................. 8 + 7.1. Kerberos version 4 mechanism .......................... 8 + 7.2. GSSAPI mechanism ...................................... 9 + 7.2.1 Client side of authentication protocol exchange ....... 9 + 7.2.2 Server side of authentication protocol exchange ....... 10 + 7.2.3 Security layer ........................................ 11 + 7.3. S/Key mechanism ....................................... 11 + 7.4. External mechanism .................................... 12 + 8. References ............................................ 13 + 9. Security Considerations ............................... 13 + 10. Author's Address ...................................... 14 + + + +Myers Standards Track [Page 1] + +RFC 2222 SASL October 1997 + + + Appendix A. Relation of SASL to Transport Security .......... 15 + Full Copyright Statement .................................... 16 + +1. Abstract + + This document describes a method for adding authentication support to + connection-based protocols. To use this specification, a protocol + includes a command for identifying and authenticating a user to a + server and for optionally negotiating protection of subsequent + protocol interactions. If its use is negotiated, a security layer is + inserted between the protocol and the connection. This document + describes how a protocol specifies such a command, defines several + mechanisms for use by the command, and defines the protocol used for + carrying a negotiated security layer over the connection. + +2. Organization of this Document + +2.1. How to Read This Document + + This document is written to serve two different audiences, protocol + designers using this specification to support authentication in their + protocol, and implementors of clients or servers for those protocols + using this specification. + + The sections "Introduction and Overview", "Profiling requirements", + and "Security Considerations" cover issues that protocol designers + need to understand and address in profiling this specification for + use in a specific protocol. + + Implementors of a protocol using this specification need the + protocol-specific profiling information in addition to the + information in this document. + +2.2. Conventions Used in this Document + + In examples, "C:" and "S:" indicate lines sent by the client and + server respectively. + + The key words "MUST", "MUST NOT", "SHOULD", "SHOULD NOT", and "MAY" + in this document are to be interpreted as defined in "Key words for + use in RFCs to Indicate Requirement Levels" [RFC 2119]. + + + + + + + + + + +Myers Standards Track [Page 2] + +RFC 2222 SASL October 1997 + + +2.3. Examples + + Examples in this document are for the IMAP profile [RFC 2060] of this + specification. The base64 encoding of challenges and responses, as + well as the "+ " preceding the responses are part of the IMAP4 + profile, not part of the SASL specification itself. + +3. Introduction and Overview + + The Simple Authentication and Security Layer (SASL) is a method for + adding authentication support to connection-based protocols. To use + this specification, a protocol includes a command for identifying and + authenticating a user to a server and for optionally negotiating a + security layer for subsequent protocol interactions. + + The command has a required argument identifying a SASL mechanism. + SASL mechanisms are named by strings, from 1 to 20 characters in + length, consisting of upper-case letters, digits, hyphens, and/or + underscores. SASL mechanism names must be registered with the IANA. + Procedures for registering new SASL mechanisms are given in the + section "Registration procedures" + + If a server supports the requested mechanism, it initiates an + authentication protocol exchange. This consists of a series of + server challenges and client responses that are specific to the + requested mechanism. The challenges and responses are defined by the + mechanisms as binary tokens of arbitrary length. The protocol's + profile then specifies how these binary tokens are then encoded for + transfer over the connection. + + After receiving the authentication command or any client response, a + server may issue a challenge, indicate failure, or indicate + completion. The protocol's profile specifies how the server + indicates which of the above it is doing. + + After receiving a challenge, a client may issue a response or abort + the exchange. The protocol's profile specifies how the client + indicates which of the above it is doing. + + During the authentication protocol exchange, the mechanism performs + authentication, transmits an authorization identity (frequently known + as a userid) from the client to server, and negotiates the use of a + mechanism-specific security layer. If the use of a security layer is + agreed upon, then the mechanism must also define or negotiate the + maximum cipher-text buffer size that each side is able to receive. + + + + + + +Myers Standards Track [Page 3] + +RFC 2222 SASL October 1997 + + + The transmitted authorization identity may be different than the + identity in the client's authentication credentials. This permits + agents such as proxy servers to authenticate using their own + credentials, yet request the access privileges of the identity for + which they are proxying. With any mechanism, transmitting an + authorization identity of the empty string directs the server to + derive an authorization identity from the client's authentication + credentials. + + If use of a security layer is negotiated, it is applied to all + subsequent data sent over the connection. The security layer takes + effect immediately following the last response of the authentication + exchange for data sent by the client and the completion indication + for data sent by the server. Once the security layer is in effect, + the protocol stream is processed by the security layer into buffers + of cipher-text. Each buffer is transferred over the connection as a + stream of octets prepended with a four octet field in network byte + order that represents the length of the following buffer. The length + of the cipher-text buffer must be no larger than the maximum size + that was defined or negotiated by the other side. + +4. Profiling requirements + + In order to use this specification, a protocol definition must supply + the following information: + + 1. A service name, to be selected from the IANA registry of "service" + elements for the GSSAPI host-based service name form [RFC 2078]. + + 2. A definition of the command to initiate the authentication + protocol exchange. This command must have as a parameter the + mechanism name being selected by the client. + + The command SHOULD have an optional parameter giving an initial + response. This optional parameter allows the client to avoid a + round trip when using a mechanism which is defined to have the + client send data first. When this initial response is sent by the + client and the selected mechanism is defined to have the server + start with an initial challenge, the command fails. See section + 5.1 of this document for further information. + + 3. A definition of the method by which the authentication protocol + exchange is carried out, including how the challenges and + responses are encoded, how the server indicates completion or + failure of the exchange, how the client aborts an exchange, and + how the exchange method interacts with any line length limits in + the protocol. + + + + +Myers Standards Track [Page 4] + +RFC 2222 SASL October 1997 + + + 4. Identification of the octet where any negotiated security layer + starts to take effect, in both directions. + + 5. A specification of how the authorization identity passed from the + client to the server is to be interpreted. + +5. Specific issues + +5.1. Client sends data first + + Some mechanisms specify that the first data sent in the + authentication protocol exchange is from the client to the server. + + If a protocol's profile permits the command which initiates an + authentication protocol exchange to contain an initial client + response, this parameter SHOULD be used with such mechanisms. + + If the initial client response parameter is not given, or if a + protocol's profile does not permit the command which initiates an + authentication protocol exchange to contain an initial client + response, then the server issues a challenge with no data. The + client's response to this challenge is then used as the initial + client response. (The server then proceeds to send the next + challenge, indicates completion, or indicates failure.) + +5.2. Server returns success with additional data + + Some mechanisms may specify that server challenge data be sent to the + client along with an indication of successful completion of the + exchange. This data would, for example, authenticate the server to + the client. + + If a protocol's profile does not permit this server challenge to be + returned with a success indication, then the server issues the server + challenge without an indication of successful completion. The client + then responds with no data. After receiving this empty response, the + server then indicates successful completion. + +5.3. Multiple authentications + + Unless otherwise stated by the protocol's profile, only one + successful SASL negotiation may occur in a protocol session. In this + case, once an authentication protocol exchange has successfully + completed, further attempts to initiate an authentication protocol + exchange fail. + + + + + + +Myers Standards Track [Page 5] + +RFC 2222 SASL October 1997 + + + In the case that a profile explicitly permits multiple successful + SASL negotiations to occur, then in no case may multiple security + layers be simultaneously in effect. If a security layer is in effect + and a subsequent SASL negotiation selects no security layer, the + original security layer remains in effect. If a security layer is in + effect and a subsequent SASL negotiation selects a second security + layer, then the second security layer replaces the first. + +6. Registration procedures + + Registration of a SASL mechanism is done by filling in the template + in section 6.4 and sending it in to iana@isi.edu. IANA has the right + to reject obviously bogus registrations, but will perform no review + of clams made in the registration form. + + There is no naming convention for SASL mechanisms; any name that + conforms to the syntax of a SASL mechanism name can be registered. + + While the registration procedures do not require it, authors of SASL + mechanisms are encouraged to seek community review and comment + whenever that is feasible. Authors may seek community review by + posting a specification of their proposed mechanism as an internet- + draft. SASL mechanisms intended for widespread use should be + standardized through the normal IETF process, when appropriate. + +6.1. Comments on SASL mechanism registrations + + Comments on registered SASL mechanisms should first be sent to the + "owner" of the mechanism. Submitters of comments may, after a + reasonable attempt to contact the owner, request IANA to attach their + comment to the SASL mechanism registration itself. If IANA approves + of this the comment will be made accessible in conjunction with the + SASL mechanism registration itself. + +6.2. Location of Registered SASL Mechanism List + + SASL mechanism registrations will be posted in the anonymous FTP + directory "ftp://ftp.isi.edu/in-notes/iana/assignments/sasl- + mechanisms/" and all registered SASL mechanisms will be listed in the + periodically issued "Assigned Numbers" RFC [currently STD 2, RFC + 1700]. The SASL mechanism description and other supporting material + may also be published as an Informational RFC by sending it to "rfc- + editor@isi.edu" (please follow the instructions to RFC authors [RFC + 2223]). + + + + + + + +Myers Standards Track [Page 6] + +RFC 2222 SASL October 1997 + + +6.3. Change Control + + Once a SASL mechanism registration has been published by IANA, the + author may request a change to its definition. The change request + follows the same procedure as the registration request. + + The owner of a SASL mechanism may pass responsibility for the SASL + mechanism to another person or agency by informing IANA; this can be + done without discussion or review. + + The IESG may reassign responsibility for a SASL mechanism. The most + common case of this will be to enable changes to be made to + mechanisms where the author of the registration has died, moved out + of contact or is otherwise unable to make changes that are important + to the community. + + SASL mechanism registrations may not be deleted; mechanisms which are + no longer believed appropriate for use can be declared OBSOLETE by a + change to their "intended use" field; such SASL mechanisms will be + clearly marked in the lists published by IANA. + + The IESG is considered to be the owner of all SASL mechanisms which + are on the IETF standards track. + +6.4. Registration Template + + To: iana@iana.org + Subject: Registration of SASL mechanism X + + SASL mechanism name: + + Security considerations: + + Published specification (optional, recommended): + + Person & email address to contact for further information: + + Intended usage: + + (One of COMMON, LIMITED USE or OBSOLETE) + + Author/Change controller: + + (Any other information that the author deems interesting may be + added below this line.) + + + + + + +Myers Standards Track [Page 7] + +RFC 2222 SASL October 1997 + + +7. Mechanism definitions + + The following mechanisms are hereby defined. + +7.1. Kerberos version 4 mechanism + + The mechanism name associated with Kerberos version 4 is + "KERBEROS_V4". + + The first challenge consists of a random 32-bit number in network + byte order. The client responds with a Kerberos ticket and an + authenticator for the principal "service.hostname@realm", where + "service" is the service name specified in the protocol's profile, + "hostname" is the first component of the host name of the server with + all letters in lower case, and where "realm" is the Kerberos realm of + the server. The encrypted checksum field included within the + Kerberos authenticator contains the server provided challenge in + network byte order. + + Upon decrypting and verifying the ticket and authenticator, the + server verifies that the contained checksum field equals the original + server provided random 32-bit number. Should the verification be + successful, the server must add one to the checksum and construct 8 + octets of data, with the first four octets containing the incremented + checksum in network byte order, the fifth octet containing a bit-mask + specifying the security layers supported by the server, and the sixth + through eighth octets containing, in network byte order, the maximum + cipher-text buffer size the server is able to receive. The server + must encrypt using DES ECB mode the 8 octets of data in the session + key and issue that encrypted data in a second challenge. The client + considers the server authenticated if the first four octets of the + un-encrypted data is equal to one plus the checksum it previously + sent. + + The client must construct data with the first four octets containing + the original server-issued checksum in network byte order, the fifth + octet containing the bit-mask specifying the selected security layer, + the sixth through eighth octets containing in network byte order the + maximum cipher-text buffer size the client is able to receive, and + the following octets containing the authorization identity. The + client must then append from one to eight zero-valued octets so that + the length of the data is a multiple of eight octets. The client must + then encrypt using DES PCBC mode the data with the session key and + respond with the encrypted data. The server decrypts the data and + verifies the contained checksum. The server must verify that the + principal identified in the Kerberos ticket is authorized to connect + as that authorization identity. After this verification, the + authentication process is complete. + + + +Myers Standards Track [Page 8] + +RFC 2222 SASL October 1997 + + + The security layers and their corresponding bit-masks are as follows: + + 1 No security layer + 2 Integrity (krb_mk_safe) protection + 4 Privacy (krb_mk_priv) protection + + Other bit-masks may be defined in the future; bits which are not + understood must be negotiated off. + + EXAMPLE: The following are two Kerberos version 4 login scenarios to + the IMAP4 protocol (note that the line breaks in the sample + authenticators are for editorial clarity and are not in real + authenticators) + + S: * OK IMAP4 Server + C: A001 AUTHENTICATE KERBEROS_V4 + S: + AmFYig== + C: BAcAQU5EUkVXLkNNVS5FRFUAOCAsho84kLN3/IJmrMG+25a4DT + +nZImJjnTNHJUtxAA+o0KPKfHEcAFs9a3CL5Oebe/ydHJUwYFd + WwuQ1MWiy6IesKvjL5rL9WjXUb9MwT9bpObYLGOKi1Qh + S: + or//EoAADZI= + C: DiAF5A4gA+oOIALuBkAAmw== + S: A001 OK Kerberos V4 authentication successful + + + S: * OK IMAP4 Server + C: A001 AUTHENTICATE KERBEROS_V4 + S: + gcfgCA== + C: BAcAQU5EUkVXLkNNVS5FRFUAOCAsho84kLN3/IJmrMG+25a4DT + +nZImJjnTNHJUtxAA+o0KPKfHEcAFs9a3CL5Oebe/ydHJUwYFd + WwuQ1MWiy6IesKvjL5rL9WjXUb9MwT9bpObYLGOKi1Qh + S: A001 NO Kerberos V4 authentication failed + +7.2. GSSAPI mechanism + + The mechanism name associated with all mechanisms employing the + GSSAPI [RFC 2078] is "GSSAPI". + +7.2.1 Client side of authentication protocol exchange + + The client calls GSS_Init_sec_context, passing in 0 for + input_context_handle (initially) and a targ_name equal to output_name + from GSS_Import_Name called with input_name_type of + GSS_C_NT_HOSTBASED_SERVICE and input_name_string of + "service@hostname" where "service" is the service name specified in + the protocol's profile, and "hostname" is the fully qualified host + name of the server. The client then responds with the resulting + output_token. If GSS_Init_sec_context returns GSS_S_CONTINUE_NEEDED, + + + +Myers Standards Track [Page 9] + +RFC 2222 SASL October 1997 + + + then the client should expect the server to issue a token in a + subsequent challenge. The client must pass the token to another call + to GSS_Init_sec_context, repeating the actions in this paragraph. + + When GSS_Init_sec_context returns GSS_S_COMPLETE, the client takes + the following actions: If the last call to GSS_Init_sec_context + returned an output_token, then the client responds with the + output_token, otherwise the client responds with no data. The client + should then expect the server to issue a token in a subsequent + challenge. The client passes this token to GSS_Unwrap and interprets + the first octet of resulting cleartext as a bit-mask specifying the + security layers supported by the server and the second through fourth + octets as the maximum size output_message to send to the server. The + client then constructs data, with the first octet containing the + bit-mask specifying the selected security layer, the second through + fourth octets containing in network byte order the maximum size + output_message the client is able to receive, and the remaining + octets containing the authorization identity. The client passes the + data to GSS_Wrap with conf_flag set to FALSE, and responds with the + generated output_message. The client can then consider the server + authenticated. + +7.2.2 Server side of authentication protocol exchange + + The server passes the initial client response to + GSS_Accept_sec_context as input_token, setting input_context_handle + to 0 (initially). If GSS_Accept_sec_context returns + GSS_S_CONTINUE_NEEDED, the server returns the generated output_token + to the client in challenge and passes the resulting response to + another call to GSS_Accept_sec_context, repeating the actions in this + paragraph. + + When GSS_Accept_sec_context returns GSS_S_COMPLETE, the client takes + the following actions: If the last call to GSS_Accept_sec_context + returned an output_token, the server returns it to the client in a + challenge and expects a reply from the client with no data. Whether + or not an output_token was returned (and after receipt of any + response from the client to such an output_token), the server then + constructs 4 octets of data, with the first octet containing a bit- + mask specifying the security layers supported by the server and the + second through fourth octets containing in network byte order the + maximum size output_token the server is able to receive. The server + must then pass the plaintext to GSS_Wrap with conf_flag set to FALSE + and issue the generated output_message to the client in a challenge. + The server must then pass the resulting response to GSS_Unwrap and + interpret the first octet of resulting cleartext as the bit-mask for + the selected security layer, the second through fourth octets as the + maximum size output_message to send to the client, and the remaining + + + +Myers Standards Track [Page 10] + +RFC 2222 SASL October 1997 + + + octets as the authorization identity. The server must verify that + the src_name is authorized to authenticate as the authorization + identity. After these verifications, the authentication process is + complete. + +7.2.3 Security layer + + The security layers and their corresponding bit-masks are as follows: + + 1 No security layer + 2 Integrity protection. + Sender calls GSS_Wrap with conf_flag set to FALSE + 4 Privacy protection. + Sender calls GSS_Wrap with conf_flag set to TRUE + + Other bit-masks may be defined in the future; bits which are not + understood must be negotiated off. + +7.3. S/Key mechanism + + The mechanism name associated with S/Key [RFC 1760] using the MD4 + digest algorithm is "SKEY". + + The client sends an initial response with the authorization identity. + + The server then issues a challenge which contains the decimal + sequence number followed by a single space and the seed string for + the indicated authorization identity. The client responds with the + one-time-password, as either a 64-bit value in network byte order or + encoded in the "six English words" format. + + The server must verify the one-time-password. After this + verification, the authentication process is complete. + + S/Key authentication does not provide for any security layers. + + EXAMPLE: The following are two S/Key login scenarios in the IMAP4 + protocol. + + S: * OK IMAP4 Server + C: A001 AUTHENTICATE SKEY + S: + + C: bW9yZ2Fu + S: + OTUgUWE1ODMwOA== + C: Rk9VUiBNQU5OIFNPT04gRklSIFZBUlkgTUFTSA== + S: A001 OK S/Key authentication successful + + + + + +Myers Standards Track [Page 11] + +RFC 2222 SASL October 1997 + + + S: * OK IMAP4 Server + C: A001 AUTHENTICATE SKEY + S: + + C: c21pdGg= + S: + OTUgUWE1ODMwOA== + C: BsAY3g4gBNo= + S: A001 NO S/Key authentication failed + + The following is an S/Key login scenario in an IMAP4-like protocol + which has an optional "initial response" argument to the AUTHENTICATE + command. + + S: * OK IMAP4-Like Server + C: A001 AUTHENTICATE SKEY bW9yZ2Fu + S: + OTUgUWE1ODMwOA== + C: Rk9VUiBNQU5OIFNPT04gRklSIFZBUlkgTUFTSA== + S: A001 OK S/Key authentication successful + +7.4. External mechanism + + The mechanism name associated with external authentication is + "EXTERNAL". + + The client sends an initial response with the authorization identity. + + The server uses information, external to SASL, to determine whether + the client is authorized to authenticate as the authorization + identity. If the client is so authorized, the server indicates + successful completion of the authentication exchange; otherwise the + server indicates failure. + + The system providing this external information may be, for example, + IPsec or TLS. + + If the client sends the empty string as the authorization identity + (thus requesting the authorization identity be derived from the + client's authentication credentials), the authorization identity is + to be derived from authentication credentials which exist in the + system which is providing the external authentication. + + + + + + + + + + + + +Myers Standards Track [Page 12] + +RFC 2222 SASL October 1997 + + +8. References + + [RFC 2060] Crispin, M., "Internet Message Access Protocol - Version + 4rev1", RFC 2060, December 1996. + + [RFC 2078] Linn, J., "Generic Security Service Application Program + Interface, Version 2", RFC 2078, January 1997. + + [RFC 2119] Bradner, S., "Key words for use in RFCs to Indicate + Requirement Levels", RFC 2119, March 1997. + + [RFC 2223] Postel, J., and J. Reynolds, "Instructions to RFC + Authors", RFC 2223, October 1997. + + [RFC 1760] Haller, N., "The S/Key One-Time Password System", RFC + 1760, February 1995. + + [RFC 1700] Reynolds, J., and J. Postel, "Assigned Numbers", STD 2, + RFC 1700, October 1994. + +9. Security Considerations + + Security issues are discussed throughout this memo. + + The mechanisms that support integrity protection are designed such + that the negotiation of the security layer and authorization identity + is integrity protected. When the client selects a security layer + with at least integrity protection, this protects against an active + attacker hijacking the connection and modifying the authentication + exchange to negotiate a plaintext connection. + + When a server or client supports multiple authentication mechanisms, + each of which has a different security strength, it is possible for + an active attacker to cause a party to use the least secure mechanism + supported. To protect against this sort of attack, a client or + server which supports mechanisms of different strengths should have a + configurable minimum strength that it will use. It is not sufficient + for this minimum strength check to only be on the server, since an + active attacker can change which mechanisms the client sees as being + supported, causing the client to send authentication credentials for + its weakest supported mechanism. + + + + + + + + + + +Myers Standards Track [Page 13] + +RFC 2222 SASL October 1997 + + + The client's selection of a SASL mechanism is done in the clear and + may be modified by an active attacker. It is important for any new + SASL mechanisms to be designed such that an active attacker cannot + obtain an authentication with weaker security properties by modifying + the SASL mechanism name and/or the challenges and responses. + + Any protocol interactions prior to authentication are performed in + the clear and may be modified by an active attacker. In the case + where a client selects integrity protection, it is important that any + security-sensitive protocol negotiations be performed after + authentication is complete. Protocols should be designed such that + negotiations performed prior to authentication should be either + ignored or revalidated once authentication is complete. + +10. Author's Address + + John G. Myers + Netscape Communications + 501 E. Middlefield Road + Mail Stop MV-029 + Mountain View, CA 94043-4042 + + EMail: jgmyers@netscape.com + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Myers Standards Track [Page 14] + +RFC 2222 SASL October 1997 + + +Appendix A. Relation of SASL to Transport Security + + Questions have been raised about the relationship between SASL and + various services (such as IPsec and TLS) which provide a secured + connection. + + Two of the key features of SASL are: + + 1. The separation of the authorization identity from the identity in + the client's credentials. This permits agents such as proxy + servers to authenticate using their own credentials, yet request + the access privileges of the identity for which they are proxying. + + 2. Upon successful completion of an authentication exchange, the + server knows the authorization identity the client wishes to use. + This allows servers to move to a "user is authenticated" state in + the protocol. + + These features are extremely important to some application protocols, + yet Transport Security services do not always provide them. To + define SASL mechanisms based on these services would be a very messy + task, as the framing of these services would be redundant with the + framing of SASL and some method of providing these important SASL + features would have to be devised. + + Sometimes it is desired to enable within an existing connection the + use of a security service which does not fit the SASL model. (TLS is + an example of such a service.) This can be done by adding a command, + for example "STARTTLS", to the protocol. Such a command is outside + the scope of SASL, and should be different from the command which + starts a SASL authentication protocol exchange. + + In certain situations, it is reasonable to use SASL underneath one of + these Transport Security services. The transport service would + secure the connection, either service would authenticate the client, + and SASL would negotiate the authorization identity. The SASL + negotiation would be what moves the protocol from "unauthenticated" + to "authenticated" state. The "EXTERNAL" SASL mechanism is + explicitly intended to handle the case where the transport service + secures the connection and authenticates the client and SASL + negotiates the authorization identity. + + When using SASL underneath a sufficiently strong Transport Security + service, a SASL security layer would most likely be redundant. The + client and server would thus probably want to negotiate off the use + of a SASL security layer. + + + + + +Myers Standards Track [Page 15] + +RFC 2222 SASL October 1997 + + +Full Copyright Statement + + Copyright (C) The Internet Society (1997). All Rights Reserved. + + This document and translations of it may be copied and furnished to + others, and derivative works that comment on or otherwise explain it + or assist in its implmentation may be prepared, copied, published + andand distributed, in whole or in part, without restriction of any + kind, provided that the above copyright notice and this paragraph are + included on all such copies and derivative works. However, this + document itself may not be modified in any way, such as by removing + the copyright notice or references to the Internet Society or other + Internet organizations, except as needed for the purpose of + developing Internet standards in which case the procedures for + copyrights defined in the Internet Standards process must be + followed, or as required to translate it into languages other than + English. + + The limited permissions granted above are perpetual and will not be + revoked by the Internet Society or its successors or assigns. + + This document and the information contained herein is provided on an + "AS IS" basis and THE INTERNET SOCIETY AND THE INTERNET ENGINEERING + TASK FORCE DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING + BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION + HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF + MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + + + + + + + + + + + + + + + + + + + + + + + + +Myers Standards Track [Page 16] + diff --git a/vendor/swiftmailer/swiftmailer/notes/rfc/rfc2231.txt b/vendor/swiftmailer/swiftmailer/notes/rfc/rfc2231.txt new file mode 100755 index 0000000..120f98f --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/notes/rfc/rfc2231.txt @@ -0,0 +1,563 @@ + + + + + + +Network Working Group N. Freed +Request for Comments: 2231 Innosoft +Updates: 2045, 2047, 2183 K. Moore +Obsoletes: 2184 University of Tennessee +Category: Standards Track November 1997 + + + MIME Parameter Value and Encoded Word Extensions: + Character Sets, Languages, and Continuations + + +Status of this Memo + + This document specifies an Internet standards track protocol for the + Internet community, and requests discussion and suggestions for + improvements. Please refer to the current edition of the "Internet + Official Protocol Standards" (STD 1) for the standardization state + and status of this protocol. Distribution of this memo is unlimited. + +Copyright Notice + + Copyright (C) The Internet Society (1997). All Rights Reserved. + +1. Abstract + + This memo defines extensions to the RFC 2045 media type and RFC 2183 + disposition parameter value mechanisms to provide + + (1) a means to specify parameter values in character sets + other than US-ASCII, + + (2) to specify the language to be used should the value be + displayed, and + + (3) a continuation mechanism for long parameter values to + avoid problems with header line wrapping. + + This memo also defines an extension to the encoded words defined in + RFC 2047 to allow the specification of the language to be used for + display as well as the character set. + +2. Introduction + + The Multipurpose Internet Mail Extensions, or MIME [RFC-2045, RFC- + 2046, RFC-2047, RFC-2048, RFC-2049], define a message format that + allows for: + + + + + +Freed & Moore Standards Track [Page 1] + +RFC 2231 MIME Value and Encoded Word Extensions November 1997 + + + (1) textual message bodies in character sets other than + US-ASCII, + + (2) non-textual message bodies, + + (3) multi-part message bodies, and + + (4) textual header information in character sets other than + US-ASCII. + + MIME is now widely deployed and is used by a variety of Internet + protocols, including, of course, Internet email. However, MIME's + success has resulted in the need for additional mechanisms that were + not provided in the original protocol specification. + + In particular, existing MIME mechanisms provide for named media type + (content-type field) parameters as well as named disposition + (content-disposition field). A MIME media type may specify any + number of parameters associated with all of its subtypes, and any + specific subtype may specify additional parameters for its own use. A + MIME disposition value may specify any number of associated + parameters, the most important of which is probably the attachment + disposition's filename parameter. + + These parameter names and values end up appearing in the content-type + and content-disposition header fields in Internet email. This + inherently imposes three crucial limitations: + + (1) Lines in Internet email header fields are folded + according to RFC 822 folding rules. This makes long + parameter values problematic. + + (2) MIME headers, like the RFC 822 headers they often + appear in, are limited to 7bit US-ASCII, and the + encoded-word mechanisms of RFC 2047 are not available + to parameter values. This makes it impossible to have + parameter values in character sets other than US-ASCII + without specifying some sort of private per-parameter + encoding. + + (3) It has recently become clear that character set + information is not sufficient to properly display some + sorts of information -- language information is also + needed [RFC-2130]. For example, support for + handicapped users may require reading text string + + + + + + +Freed & Moore Standards Track [Page 2] + +RFC 2231 MIME Value and Encoded Word Extensions November 1997 + + + aloud. The language the text is written in is needed + for this to be done correctly. Some parameter values + may need to be displayed, hence there is a need to + allow for the inclusion of language information. + + The last problem on this list is also an issue for the encoded words + defined by RFC 2047, as encoded words are intended primarily for + display purposes. + + This document defines extensions that address all of these + limitations. All of these extensions are implemented in a fashion + that is completely compatible at a syntactic level with existing MIME + implementations. In addition, the extensions are designed to have as + little impact as possible on existing uses of MIME. + + IMPORTANT NOTE: These mechanisms end up being somewhat gibbous when + they actually are used. As such, these mechanisms should not be used + lightly; they should be reserved for situations where a real need for + them exists. + +2.1. Requirements notation + + This document occasionally uses terms that appear in capital letters. + When the terms "MUST", "SHOULD", "MUST NOT", "SHOULD NOT", and "MAY" + appear capitalized, they are being used to indicate particular + requirements of this specification. A discussion of the meanings of + these terms appears in [RFC- 2119]. + +3. Parameter Value Continuations + + Long MIME media type or disposition parameter values do not interact + well with header line wrapping conventions. In particular, proper + header line wrapping depends on there being places where linear + whitespace (LWSP) is allowed, which may or may not be present in a + parameter value, and even if present may not be recognizable as such + since specific knowledge of parameter value syntax may not be + available to the agent doing the line wrapping. The result is that + long parameter values may end up getting truncated or otherwise + damaged by incorrect line wrapping implementations. + + A mechanism is therefore needed to break up parameter values into + smaller units that are amenable to line wrapping. Any such mechanism + MUST be compatible with existing MIME processors. This means that + + (1) the mechanism MUST NOT change the syntax of MIME media + type and disposition lines, and + + + + + +Freed & Moore Standards Track [Page 3] + +RFC 2231 MIME Value and Encoded Word Extensions November 1997 + + + (2) the mechanism MUST NOT depend on parameter ordering + since MIME states that parameters are not order + sensitive. Note that while MIME does prohibit + modification of MIME headers during transport, it is + still possible that parameters will be reordered when + user agent level processing is done. + + The obvious solution, then, is to use multiple parameters to contain + a single parameter value and to use some kind of distinguished name + to indicate when this is being done. And this obvious solution is + exactly what is specified here: The asterisk character ("*") followed + by a decimal count is employed to indicate that multiple parameters + are being used to encapsulate a single parameter value. The count + starts at 0 and increments by 1 for each subsequent section of the + parameter value. Decimal values are used and neither leading zeroes + nor gaps in the sequence are allowed. + + The original parameter value is recovered by concatenating the + various sections of the parameter, in order. For example, the + content-type field + + Content-Type: message/external-body; access-type=URL; + URL*0="ftp://"; + URL*1="cs.utk.edu/pub/moore/bulk-mailer/bulk-mailer.tar" + + is semantically identical to + + Content-Type: message/external-body; access-type=URL; + URL="ftp://cs.utk.edu/pub/moore/bulk-mailer/bulk-mailer.tar" + + Note that quotes around parameter values are part of the value + syntax; they are NOT part of the value itself. Furthermore, it is + explicitly permitted to have a mixture of quoted and unquoted + continuation fields. + +4. Parameter Value Character Set and Language Information + + Some parameter values may need to be qualified with character set or + language information. It is clear that a distinguished parameter + name is needed to identify when this information is present along + with a specific syntax for the information in the value itself. In + addition, a lightweight encoding mechanism is needed to accommodate 8 + bit information in parameter values. + + + + + + + + +Freed & Moore Standards Track [Page 4] + +RFC 2231 MIME Value and Encoded Word Extensions November 1997 + + + Asterisks ("*") are reused to provide the indicator that language and + character set information is present and encoding is being used. A + single quote ("'") is used to delimit the character set and language + information at the beginning of the parameter value. Percent signs + ("%") are used as the encoding flag, which agrees with RFC 2047. + + Specifically, an asterisk at the end of a parameter name acts as an + indicator that character set and language information may appear at + the beginning of the parameter value. A single quote is used to + separate the character set, language, and actual value information in + the parameter value string, and an percent sign is used to flag + octets encoded in hexadecimal. For example: + + Content-Type: application/x-stuff; + title*=us-ascii'en-us'This%20is%20%2A%2A%2Afun%2A%2A%2A + + Note that it is perfectly permissible to leave either the character + set or language field blank. Note also that the single quote + delimiters MUST be present even when one of the field values is + omitted. This is done when either character set, language, or both + are not relevant to the parameter value at hand. This MUST NOT be + done in order to indicate a default character set or language -- + parameter field definitions MUST NOT assign a default character set + or language. + +4.1. Combining Character Set, Language, and Parameter Continuations + + Character set and language information may be combined with the + parameter continuation mechanism. For example: + + Content-Type: application/x-stuff + title*0*=us-ascii'en'This%20is%20even%20more%20 + title*1*=%2A%2A%2Afun%2A%2A%2A%20 + title*2="isn't it!" + + Note that: + + (1) Language and character set information only appear at + the beginning of a given parameter value. + + (2) Continuations do not provide a facility for using more + than one character set or language in the same + parameter value. + + (3) A value presented using multiple continuations may + contain a mixture of encoded and unencoded segments. + + + + + +Freed & Moore Standards Track [Page 5] + +RFC 2231 MIME Value and Encoded Word Extensions November 1997 + + + (4) The first segment of a continuation MUST be encoded if + language and character set information are given. + + (5) If the first segment of a continued parameter value is + encoded the language and character set field delimiters + MUST be present even when the fields are left blank. + +5. Language specification in Encoded Words + + RFC 2047 provides support for non-US-ASCII character sets in RFC 822 + message header comments, phrases, and any unstructured text field. + This is done by defining an encoded word construct which can appear + in any of these places. Given that these are fields intended for + display, it is sometimes necessary to associate language information + with encoded words as well as just the character set. This + specification extends the definition of an encoded word to allow the + inclusion of such information. This is simply done by suffixing the + character set specification with an asterisk followed by the language + tag. For example: + + From: =?US-ASCII*EN?Q?Keith_Moore?= + +6. IMAP4 Handling of Parameter Values + + IMAP4 [RFC-2060] servers SHOULD decode parameter value continuations + when generating the BODY and BODYSTRUCTURE fetch attributes. + +7. Modifications to MIME ABNF + + The ABNF for MIME parameter values given in RFC 2045 is: + + parameter := attribute "=" value + + attribute := token + ; Matching of attributes + ; is ALWAYS case-insensitive. + + This specification changes this ABNF to: + + parameter := regular-parameter / extended-parameter + + regular-parameter := regular-parameter-name "=" value + + regular-parameter-name := attribute [section] + + attribute := 1*attribute-char + + + + + +Freed & Moore Standards Track [Page 6] + +RFC 2231 MIME Value and Encoded Word Extensions November 1997 + + + attribute-char := + + section := initial-section / other-sections + + initial-section := "*0" + + other-sections := "*" ("1" / "2" / "3" / "4" / "5" / + "6" / "7" / "8" / "9") *DIGIT) + + extended-parameter := (extended-initial-name "=" + extended-value) / + (extended-other-names "=" + extended-other-values) + + extended-initial-name := attribute [initial-section] "*" + + extended-other-names := attribute other-sections "*" + + extended-initial-value := [charset] "'" [language] "'" + extended-other-values + + extended-other-values := *(ext-octet / attribute-char) + + ext-octet := "%" 2(DIGIT / "A" / "B" / "C" / "D" / "E" / "F") + + charset := + + language := + + The ABNF given in RFC 2047 for encoded-words is: + + encoded-word := "=?" charset "?" encoding "?" encoded-text "?=" + + This specification changes this ABNF to: + + encoded-word := "=?" charset ["*" language] "?" encoded-text "?=" + +8. Character sets which allow specification of language + + In the future it is likely that some character sets will provide + facilities for inline language labeling. Such facilities are + inherently more flexible than those defined here as they allow for + language switching in the middle of a string. + + + + + + + +Freed & Moore Standards Track [Page 7] + +RFC 2231 MIME Value and Encoded Word Extensions November 1997 + + + If and when such facilities are developed they SHOULD be used in + preference to the language labeling facilities specified here. Note + that all the mechanisms defined here allow for the omission of + language labels so as to be able to accommodate this possible future + usage. + +9. Security Considerations + + This RFC does not discuss security issues and is not believed to + raise any security issues not already endemic in electronic mail and + present in fully conforming implementations of MIME. + +10. References + + [RFC-822] + Crocker, D., "Standard for the Format of ARPA Internet + Text Messages", STD 11, RFC 822 August 1982. + + [RFC-1766] + Alvestrand, H., "Tags for the Identification of + Languages", RFC 1766, March 1995. + + [RFC-2045] + Freed, N., and N. Borenstein, "Multipurpose Internet Mail + Extensions (MIME) Part One: Format of Internet Message + Bodies", RFC 2045, December 1996. + + [RFC-2046] + Freed, N. and N. Borenstein, "Multipurpose Internet Mail + Extensions (MIME) Part Two: Media Types", RFC 2046, + December 1996. + + [RFC-2047] + Moore, K., "Multipurpose Internet Mail Extensions (MIME) + Part Three: Representation of Non-ASCII Text in Internet + Message Headers", RFC 2047, December 1996. + + [RFC-2048] + Freed, N., Klensin, J. and J. Postel, "Multipurpose + Internet Mail Extensions (MIME) Part Four: MIME + Registration Procedures", RFC 2048, December 1996. + + [RFC-2049] + Freed, N. and N. Borenstein, "Multipurpose Internet Mail + Extensions (MIME) Part Five: Conformance Criteria and + Examples", RFC 2049, December 1996. + + + + + +Freed & Moore Standards Track [Page 8] + +RFC 2231 MIME Value and Encoded Word Extensions November 1997 + + + [RFC-2060] + Crispin, M., "Internet Message Access Protocol - Version + 4rev1", RFC 2060, December 1996. + + [RFC-2119] + Bradner, S., "Key words for use in RFCs to Indicate + Requirement Levels", RFC 2119, March 1997. + + [RFC-2130] + Weider, C., Preston, C., Simonsen, K., Alvestrand, H., + Atkinson, R., Crispin, M., and P. Svanberg, "Report from the + IAB Character Set Workshop", RFC 2130, April 1997. + + [RFC-2183] + Troost, R., Dorner, S. and K. Moore, "Communicating + Presentation Information in Internet Messages: The + Content-Disposition Header", RFC 2183, August 1997. + +11. Authors' Addresses + + Ned Freed + Innosoft International, Inc. + 1050 Lakes Drive + West Covina, CA 91790 + USA + + Phone: +1 626 919 3600 + Fax: +1 626 919 3614 + EMail: ned.freed@innosoft.com + + + Keith Moore + Computer Science Dept. + University of Tennessee + 107 Ayres Hall + Knoxville, TN 37996-1301 + USA + + EMail: moore@cs.utk.edu + + + + + + + + + + + + +Freed & Moore Standards Track [Page 9] + +RFC 2231 MIME Value and Encoded Word Extensions November 1997 + + +12. Full Copyright Statement + + Copyright (C) The Internet Society (1997). All Rights Reserved. + + This document and translations of it may be copied and furnished to + others, and derivative works that comment on or otherwise explain it + or assist in its implementation may be prepared, copied, published + and distributed, in whole or in part, without restriction of any + kind, provided that the above copyright notice and this paragraph are + included on all such copies and derivative works. However, this + document itself may not be modified in any way, such as by removing + the copyright notice or references to the Internet Society or other + Internet organizations, except as needed for the purpose of + developing Internet standards in which case the procedures for + copyrights defined in the Internet Standards process must be + followed, or as required to translate it into languages other than + English. + + The limited permissions granted above are perpetual and will not be + revoked by the Internet Society or its successors or assigns. + + This document and the information contained herein is provided on an + "AS IS" basis and THE INTERNET SOCIETY AND THE INTERNET ENGINEERING + TASK FORCE DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING + BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION + HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF + MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + + + + + + + + + + + + + + + + + + + + + + + + +Freed & Moore Standards Track [Page 10] + diff --git a/vendor/swiftmailer/swiftmailer/notes/rfc/rfc2234.txt b/vendor/swiftmailer/swiftmailer/notes/rfc/rfc2234.txt new file mode 100755 index 0000000..edea302 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/notes/rfc/rfc2234.txt @@ -0,0 +1,787 @@ + + + + + + +Network Working Group D. Crocker, Ed. +Request for Comments: 2234 Internet Mail Consortium +Category: Standards Track P. Overell + Demon Internet Ltd. + November 1997 + + + Augmented BNF for Syntax Specifications: ABNF + + +Status of this Memo + + This document specifies an Internet standards track protocol for the + Internet community, and requests discussion and suggestions for + improvements. Please refer to the current edition of the "Internet + Official Protocol Standards" (STD 1) for the standardization state + and status of this protocol. Distribution of this memo is unlimited. + +Copyright Notice + + Copyright (C) The Internet Society (1997). All Rights Reserved. + +TABLE OF CONTENTS + + 1. INTRODUCTION .................................................. 2 + + 2. RULE DEFINITION ............................................... 2 + 2.1 RULE NAMING .................................................. 2 + 2.2 RULE FORM .................................................... 3 + 2.3 TERMINAL VALUES .............................................. 3 + 2.4 EXTERNAL ENCODINGS ........................................... 5 + + 3. OPERATORS ..................................................... 5 + 3.1 CONCATENATION RULE1 RULE2 ............................. 5 + 3.2 ALTERNATIVES RULE1 / RULE2 ................................... 6 + 3.3 INCREMENTAL ALTERNATIVES RULE1 =/ RULE2 .................... 6 + 3.4 VALUE RANGE ALTERNATIVES %C##-## ........................... 7 + 3.5 SEQUENCE GROUP (RULE1 RULE2) ................................. 7 + 3.6 VARIABLE REPETITION *RULE .................................... 8 + 3.7 SPECIFIC REPETITION NRULE .................................... 8 + 3.8 OPTIONAL SEQUENCE [RULE] ..................................... 8 + 3.9 ; COMMENT .................................................... 8 + 3.10 OPERATOR PRECEDENCE ......................................... 9 + + 4. ABNF DEFINITION OF ABNF ....................................... 9 + + 5. SECURITY CONSIDERATIONS ....................................... 10 + + + + +Crocker & Overell Standards Track [Page 1] + +RFC 2234 ABNF for Syntax Specifications November 1997 + + + 6. APPENDIX A - CORE ............................................. 11 + 6.1 CORE RULES ................................................... 11 + 6.2 COMMON ENCODING .............................................. 12 + + 7. ACKNOWLEDGMENTS ............................................... 12 + + 8. REFERENCES .................................................... 13 + + 9. CONTACT ....................................................... 13 + + 10. FULL COPYRIGHT STATEMENT ..................................... 14 + +1. INTRODUCTION + + Internet technical specifications often need to define a format + syntax and are free to employ whatever notation their authors deem + useful. Over the years, a modified version of Backus-Naur Form + (BNF), called Augmented BNF (ABNF), has been popular among many + Internet specifications. It balances compactness and simplicity, + with reasonable representational power. In the early days of the + Arpanet, each specification contained its own definition of ABNF. + This included the email specifications, RFC733 and then RFC822 which + have come to be the common citations for defining ABNF. The current + document separates out that definition, to permit selective + reference. Predictably, it also provides some modifications and + enhancements. + + The differences between standard BNF and ABNF involve naming rules, + repetition, alternatives, order-independence, and value ranges. + Appendix A (Core) supplies rule definitions and encoding for a core + lexical analyzer of the type common to several Internet + specifications. It is provided as a convenience and is otherwise + separate from the meta language defined in the body of this document, + and separate from its formal status. + +2. RULE DEFINITION + +2.1 Rule Naming + + The name of a rule is simply the name itself; that is, a sequence of + characters, beginning with an alphabetic character, and followed by + a combination of alphabetics, digits and hyphens (dashes). + + NOTE: Rule names are case-insensitive + + The names , , and all refer + to the same rule. + + + + +Crocker & Overell Standards Track [Page 2] + +RFC 2234 ABNF for Syntax Specifications November 1997 + + + Unlike original BNF, angle brackets ("<", ">") are not required. + However, angle brackets may be used around a rule name whenever their + presence will facilitate discerning the use of a rule name. This is + typically restricted to rule name references in free-form prose, or + to distinguish partial rules that combine into a string not separated + by white space, such as shown in the discussion about repetition, + below. + +2.2 Rule Form + + A rule is defined by the following sequence: + + name = elements crlf + + where is the name of the rule, is one or more rule + names or terminal specifications and is the end-of- line + indicator, carriage return followed by line feed. The equal sign + separates the name from the definition of the rule. The elements + form a sequence of one or more rule names and/or value definitions, + combined according to the various operators, defined in this + document, such as alternative and repetition. + + For visual ease, rule definitions are left aligned. When a rule + requires multiple lines, the continuation lines are indented. The + left alignment and indentation are relative to the first lines of the + ABNF rules and need not match the left margin of the document. + +2.3 Terminal Values + + Rules resolve into a string of terminal values, sometimes called + characters. In ABNF a character is merely a non-negative integer. + In certain contexts a specific mapping (encoding) of values into a + character set (such as ASCII) will be specified. + + Terminals are specified by one or more numeric characters with the + base interpretation of those characters indicated explicitly. The + following bases are currently defined: + + b = binary + + d = decimal + + x = hexadecimal + + + + + + + + +Crocker & Overell Standards Track [Page 3] + +RFC 2234 ABNF for Syntax Specifications November 1997 + + + Hence: + + CR = %d13 + + CR = %x0D + + respectively specify the decimal and hexadecimal representation of + [US-ASCII] for carriage return. + + A concatenated string of such values is specified compactly, using a + period (".") to indicate separation of characters within that value. + Hence: + + CRLF = %d13.10 + + ABNF permits specifying literal text string directly, enclosed in + quotation-marks. Hence: + + command = "command string" + + Literal text strings are interpreted as a concatenated set of + printable characters. + + NOTE: ABNF strings are case-insensitive and + the character set for these strings is us-ascii. + + Hence: + + rulename = "abc" + + and: + + rulename = "aBc" + + will match "abc", "Abc", "aBc", "abC", "ABc", "aBC", "AbC" and "ABC". + + To specify a rule which IS case SENSITIVE, + specify the characters individually. + + For example: + + rulename = %d97 %d98 %d99 + + or + + rulename = %d97.98.99 + + + + + +Crocker & Overell Standards Track [Page 4] + +RFC 2234 ABNF for Syntax Specifications November 1997 + + + will match only the string which comprises only lowercased + characters, abc. + +2.4 External Encodings + + External representations of terminal value characters will vary + according to constraints in the storage or transmission environment. + Hence, the same ABNF-based grammar may have multiple external + encodings, such as one for a 7-bit US-ASCII environment, another for + a binary octet environment and still a different one when 16-bit + Unicode is used. Encoding details are beyond the scope of ABNF, + although Appendix A (Core) provides definitions for a 7-bit US-ASCII + environment as has been common to much of the Internet. + + By separating external encoding from the syntax, it is intended that + alternate encoding environments can be used for the same syntax. + +3. OPERATORS + +3.1 Concatenation Rule1 Rule2 + + A rule can define a simple, ordered string of values -- i.e., a + concatenation of contiguous characters -- by listing a sequence of + rule names. For example: + + foo = %x61 ; a + + bar = %x62 ; b + + mumble = foo bar foo + + So that the rule matches the lowercase string "aba". + + LINEAR WHITE SPACE: Concatenation is at the core of the ABNF + parsing model. A string of contiguous characters (values) is + parsed according to the rules defined in ABNF. For Internet + specifications, there is some history of permitting linear white + space (space and horizontal tab) to be freelyPand + implicitlyPinterspersed around major constructs, such as + delimiting special characters or atomic strings. + + NOTE: This specification for ABNF does not + provide for implicit specification of linear white + space. + + Any grammar which wishes to permit linear white space around + delimiters or string segments must specify it explicitly. It is + often useful to provide for such white space in "core" rules that are + + + +Crocker & Overell Standards Track [Page 5] + +RFC 2234 ABNF for Syntax Specifications November 1997 + + + then used variously among higher-level rules. The "core" rules might + be formed into a lexical analyzer or simply be part of the main + ruleset. + +3.2 Alternatives Rule1 / Rule2 + + Elements separated by forward slash ("/") are alternatives. + Therefore, + + foo / bar + + will accept or . + + NOTE: A quoted string containing alphabetic + characters is special form for specifying alternative + characters and is interpreted as a non-terminal + representing the set of combinatorial strings with the + contained characters, in the specified order but with + any mixture of upper and lower case.. + +3.3 Incremental Alternatives Rule1 =/ Rule2 + + It is sometimes convenient to specify a list of alternatives in + fragments. That is, an initial rule may match one or more + alternatives, with later rule definitions adding to the set of + alternatives. This is particularly useful for otherwise- independent + specifications which derive from the same parent rule set, such as + often occurs with parameter lists. ABNF permits this incremental + definition through the construct: + + oldrule =/ additional-alternatives + + So that the rule set + + ruleset = alt1 / alt2 + + ruleset =/ alt3 + + ruleset =/ alt4 / alt5 + + is the same as specifying + + ruleset = alt1 / alt2 / alt3 / alt4 / alt5 + + + + + + + + +Crocker & Overell Standards Track [Page 6] + +RFC 2234 ABNF for Syntax Specifications November 1997 + + +3.4 Value Range Alternatives %c##-## + + A range of alternative numeric values can be specified compactly, + using dash ("-") to indicate the range of alternative values. Hence: + + DIGIT = %x30-39 + + is equivalent to: + + DIGIT = "0" / "1" / "2" / "3" / "4" / "5" / "6" / + + "7" / "8" / "9" + + Concatenated numeric values and numeric value ranges can not be + specified in the same string. A numeric value may use the dotted + notation for concatenation or it may use the dash notation to specify + one value range. Hence, to specify one printable character, between + end of line sequences, the specification could be: + + char-line = %x0D.0A %x20-7E %x0D.0A + +3.5 Sequence Group (Rule1 Rule2) + + Elements enclosed in parentheses are treated as a single element, + whose contents are STRICTLY ORDERED. Thus, + + elem (foo / bar) blat + + which matches (elem foo blat) or (elem bar blat). + + elem foo / bar blat + + matches (elem foo) or (bar blat). + + NOTE: It is strongly advised to use grouping + notation, rather than to rely on proper reading of + "bare" alternations, when alternatives consist of + multiple rule names or literals. + + Hence it is recommended that instead of the above form, the form: + + (elem foo) / (bar blat) + + be used. It will avoid misinterpretation by casual readers. + + The sequence group notation is also used within free text to set off + an element sequence from the prose. + + + + +Crocker & Overell Standards Track [Page 7] + +RFC 2234 ABNF for Syntax Specifications November 1997 + + +3.6 Variable Repetition *Rule + + The operator "*" preceding an element indicates repetition. The full + form is: + + *element + + where and are optional decimal values, indicating at least + and at most occurrences of element. + + Default values are 0 and infinity so that * allows any + number, including zero; 1* requires at least one; + 3*3 allows exactly 3 and 1*2 allows one or two. + +3.7 Specific Repetition nRule + + A rule of the form: + + element + + is equivalent to + + *element + + That is, exactly occurrences of . Thus 2DIGIT is a + 2-digit number, and 3ALPHA is a string of three alphabetic + characters. + +3.8 Optional Sequence [RULE] + + Square brackets enclose an optional element sequence: + + [foo bar] + + is equivalent to + + *1(foo bar). + +3.9 ; Comment + + A semi-colon starts a comment that continues to the end of line. + This is a simple way of including useful notes in parallel with the + specifications. + + + + + + + + +Crocker & Overell Standards Track [Page 8] + +RFC 2234 ABNF for Syntax Specifications November 1997 + + +3.10 Operator Precedence + + The various mechanisms described above have the following precedence, + from highest (binding tightest) at the top, to lowest and loosest at + the bottom: + + Strings, Names formation + Comment + Value range + Repetition + Grouping, Optional + Concatenation + Alternative + + Use of the alternative operator, freely mixed with concatenations can + be confusing. + + Again, it is recommended that the grouping operator be used to + make explicit concatenation groups. + +4. ABNF DEFINITION OF ABNF + + This syntax uses the rules provided in Appendix A (Core). + + rulelist = 1*( rule / (*c-wsp c-nl) ) + + rule = rulename defined-as elements c-nl + ; continues if next line starts + ; with white space + + rulename = ALPHA *(ALPHA / DIGIT / "-") + + defined-as = *c-wsp ("=" / "=/") *c-wsp + ; basic rules definition and + ; incremental alternatives + + elements = alternation *c-wsp + + c-wsp = WSP / (c-nl WSP) + + c-nl = comment / CRLF + ; comment or newline + + comment = ";" *(WSP / VCHAR) CRLF + + alternation = concatenation + *(*c-wsp "/" *c-wsp concatenation) + + + + +Crocker & Overell Standards Track [Page 9] + +RFC 2234 ABNF for Syntax Specifications November 1997 + + + concatenation = repetition *(1*c-wsp repetition) + + repetition = [repeat] element + + repeat = 1*DIGIT / (*DIGIT "*" *DIGIT) + + element = rulename / group / option / + char-val / num-val / prose-val + + group = "(" *c-wsp alternation *c-wsp ")" + + option = "[" *c-wsp alternation *c-wsp "]" + + char-val = DQUOTE *(%x20-21 / %x23-7E) DQUOTE + ; quoted string of SP and VCHAR + without DQUOTE + + num-val = "%" (bin-val / dec-val / hex-val) + + bin-val = "b" 1*BIT + [ 1*("." 1*BIT) / ("-" 1*BIT) ] + ; series of concatenated bit values + ; or single ONEOF range + + dec-val = "d" 1*DIGIT + [ 1*("." 1*DIGIT) / ("-" 1*DIGIT) ] + + hex-val = "x" 1*HEXDIG + [ 1*("." 1*HEXDIG) / ("-" 1*HEXDIG) ] + + prose-val = "<" *(%x20-3D / %x3F-7E) ">" + ; bracketed string of SP and VCHAR + without angles + ; prose description, to be used as + last resort + + +5. SECURITY CONSIDERATIONS + + Security is truly believed to be irrelevant to this document. + + + + + + + + + + + +Crocker & Overell Standards Track [Page 10] + +RFC 2234 ABNF for Syntax Specifications November 1997 + + +6. APPENDIX A - CORE + + This Appendix is provided as a convenient core for specific grammars. + The definitions may be used as a core set of rules. + +6.1 Core Rules + + Certain basic rules are in uppercase, such as SP, HTAB, CRLF, + DIGIT, ALPHA, etc. + + ALPHA = %x41-5A / %x61-7A ; A-Z / a-z + + BIT = "0" / "1" + + CHAR = %x01-7F + ; any 7-bit US-ASCII character, + excluding NUL + + CR = %x0D + ; carriage return + + CRLF = CR LF + ; Internet standard newline + + CTL = %x00-1F / %x7F + ; controls + + DIGIT = %x30-39 + ; 0-9 + + DQUOTE = %x22 + ; " (Double Quote) + + HEXDIG = DIGIT / "A" / "B" / "C" / "D" / "E" / "F" + + HTAB = %x09 + ; horizontal tab + + LF = %x0A + ; linefeed + + LWSP = *(WSP / CRLF WSP) + ; linear white space (past newline) + + OCTET = %x00-FF + ; 8 bits of data + + SP = %x20 + + + +Crocker & Overell Standards Track [Page 11] + +RFC 2234 ABNF for Syntax Specifications November 1997 + + + ; space + + VCHAR = %x21-7E + ; visible (printing) characters + + WSP = SP / HTAB + ; white space + +6.2 Common Encoding + + Externally, data are represented as "network virtual ASCII", namely + 7-bit US-ASCII in an 8-bit field, with the high (8th) bit set to + zero. A string of values is in "network byte order" with the + higher-valued bytes represented on the left-hand side and being sent + over the network first. + +7. ACKNOWLEDGMENTS + + The syntax for ABNF was originally specified in RFC 733. Ken L. + Harrenstien, of SRI International, was responsible for re-coding the + BNF into an augmented BNF that makes the representation smaller and + easier to understand. + + This recent project began as a simple effort to cull out the portion + of RFC 822 which has been repeatedly cited by non-email specification + writers, namely the description of augmented BNF. Rather than simply + and blindly converting the existing text into a separate document, + the working group chose to give careful consideration to the + deficiencies, as well as benefits, of the existing specification and + related specifications available over the last 15 years and therefore + to pursue enhancement. This turned the project into something rather + more ambitious than first intended. Interestingly the result is not + massively different from that original, although decisions such as + removing the list notation came as a surprise. + + The current round of specification was part of the DRUMS working + group, with significant contributions from Jerome Abela , Harald + Alvestrand, Robert Elz, Roger Fajman, Aviva Garrett, Tom Harsch, Dan + Kohn, Bill McQuillan, Keith Moore, Chris Newman , Pete Resnick and + Henning Schulzrinne. + + + + + + + + + + + +Crocker & Overell Standards Track [Page 12] + +RFC 2234 ABNF for Syntax Specifications November 1997 + + +8. REFERENCES + + [US-ASCII] Coded Character Set--7-Bit American Standard Code for + Information Interchange, ANSI X3.4-1986. + + [RFC733] Crocker, D., Vittal, J., Pogran, K., and D. Henderson, + "Standard for the Format of ARPA Network Text Message," RFC 733, + November 1977. + + [RFC822] Crocker, D., "Standard for the Format of ARPA Internet Text + Messages", STD 11, RFC 822, August 1982. + +9. CONTACT + + David H. Crocker Paul Overell + + Internet Mail Consortium Demon Internet Ltd + 675 Spruce Dr. Dorking Business Park + Sunnyvale, CA 94086 USA Dorking + Surrey, RH4 1HN + UK + + Phone: +1 408 246 8253 + Fax: +1 408 249 6205 + EMail: dcrocker@imc.org paulo@turnpike.com + + + + + + + + + + + + + + + + + + + + + + + + + + +Crocker & Overell Standards Track [Page 13] + +RFC 2234 ABNF for Syntax Specifications November 1997 + + +10. Full Copyright Statement + + Copyright (C) The Internet Society (1997). All Rights Reserved. + + This document and translations of it may be copied and furnished to + others, and derivative works that comment on or otherwise explain it + or assist in its implementation may be prepared, copied, published + and distributed, in whole or in part, without restriction of any + kind, provided that the above copyright notice and this paragraph are + included on all such copies and derivative works. However, this + document itself may not be modified in any way, such as by removing + the copyright notice or references to the Internet Society or other + Internet organizations, except as needed for the purpose of + developing Internet standards in which case the procedures for + copyrights defined in the Internet Standards process must be + followed, or as required to translate it into languages other than + English. + + The limited permissions granted above are perpetual and will not be + revoked by the Internet Society or its successors or assigns. + + This document and the information contained herein is provided on an + "AS IS" basis and THE INTERNET SOCIETY AND THE INTERNET ENGINEERING + TASK FORCE DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING + BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION + HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF + MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + + + + + + + + + + + + + + + + + + + + + + + + +Crocker & Overell Standards Track [Page 14] + diff --git a/vendor/swiftmailer/swiftmailer/notes/rfc/rfc2440.txt b/vendor/swiftmailer/swiftmailer/notes/rfc/rfc2440.txt new file mode 100755 index 0000000..902ecee --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/notes/rfc/rfc2440.txt @@ -0,0 +1,3642 @@ + + + + + +Network Working Group J. Callas +Request for Comments: 2440 Network Associates +Category: Standards Track L. Donnerhacke + IN-Root-CA Individual Network e.V. + H. Finney + Network Associates + R. Thayer + EIS Corporation + November 1998 + + + OpenPGP Message Format + +Status of this Memo + + This document specifies an Internet standards track protocol for the + Internet community, and requests discussion and suggestions for + improvements. Please refer to the current edition of the "Internet + Official Protocol Standards" (STD 1) for the standardization state + and status of this protocol. Distribution of this memo is unlimited. + +Copyright Notice + + Copyright (C) The Internet Society (1998). All Rights Reserved. + +IESG Note + + This document defines many tag values, yet it doesn't describe a + mechanism for adding new tags (for new features). Traditionally the + Internet Assigned Numbers Authority (IANA) handles the allocation of + new values for future expansion and RFCs usually define the procedure + to be used by the IANA. However, there are subtle (and not so + subtle) interactions that may occur in this protocol between new + features and existing features which result in a significant + reduction in over all security. Therefore, this document does not + define an extension procedure. Instead requests to define new tag + values (say for new encryption algorithms for example) should be + forwarded to the IESG Security Area Directors for consideration or + forwarding to the appropriate IETF Working Group for consideration. + +Abstract + + This document is maintained in order to publish all necessary + information needed to develop interoperable applications based on the + OpenPGP format. It is not a step-by-step cookbook for writing an + application. It describes only the format and methods needed to read, + check, generate, and write conforming packets crossing any network. + It does not deal with storage and implementation questions. It does, + + + +Callas, et. al. Standards Track [Page 1] + +RFC 2440 OpenPGP Message Format November 1998 + + + however, discuss implementation issues necessary to avoid security + flaws. + + Open-PGP software uses a combination of strong public-key and + symmetric cryptography to provide security services for electronic + communications and data storage. These services include + confidentiality, key management, authentication, and digital + signatures. This document specifies the message formats used in + OpenPGP. + +Table of Contents + + Status of this Memo 1 + IESG Note 1 + Abstract 1 + Table of Contents 2 + 1. Introduction 4 + 1.1. Terms 5 + 2. General functions 5 + 2.1. Confidentiality via Encryption 5 + 2.2. Authentication via Digital signature 6 + 2.3. Compression 7 + 2.4. Conversion to Radix-64 7 + 2.5. Signature-Only Applications 7 + 3. Data Element Formats 7 + 3.1. Scalar numbers 8 + 3.2. Multi-Precision Integers 8 + 3.3. Key IDs 8 + 3.4. Text 8 + 3.5. Time fields 9 + 3.6. String-to-key (S2K) specifiers 9 + 3.6.1. String-to-key (S2k) specifier types 9 + 3.6.1.1. Simple S2K 9 + 3.6.1.2. Salted S2K 10 + 3.6.1.3. Iterated and Salted S2K 10 + 3.6.2. String-to-key usage 11 + 3.6.2.1. Secret key encryption 11 + 3.6.2.2. Symmetric-key message encryption 11 + 4. Packet Syntax 12 + 4.1. Overview 12 + 4.2. Packet Headers 12 + 4.2.1. Old-Format Packet Lengths 13 + 4.2.2. New-Format Packet Lengths 13 + 4.2.2.1. One-Octet Lengths 14 + 4.2.2.2. Two-Octet Lengths 14 + 4.2.2.3. Five-Octet Lengths 14 + 4.2.2.4. Partial Body Lengths 14 + 4.2.3. Packet Length Examples 14 + + + +Callas, et. al. Standards Track [Page 2] + +RFC 2440 OpenPGP Message Format November 1998 + + + 4.3. Packet Tags 15 + 5. Packet Types 16 + 5.1. Public-Key Encrypted Session Key Packets (Tag 1) 16 + 5.2. Signature Packet (Tag 2) 17 + 5.2.1. Signature Types 17 + 5.2.2. Version 3 Signature Packet Format 19 + 5.2.3. Version 4 Signature Packet Format 21 + 5.2.3.1. Signature Subpacket Specification 22 + 5.2.3.2. Signature Subpacket Types 24 + 5.2.3.3. Signature creation time 25 + 5.2.3.4. Issuer 25 + 5.2.3.5. Key expiration time 25 + 5.2.3.6. Preferred symmetric algorithms 25 + 5.2.3.7. Preferred hash algorithms 25 + 5.2.3.8. Preferred compression algorithms 26 + 5.2.3.9. Signature expiration time 26 + 5.2.3.10.Exportable Certification 26 + 5.2.3.11.Revocable 27 + 5.2.3.12.Trust signature 27 + 5.2.3.13.Regular expression 27 + 5.2.3.14.Revocation key 27 + 5.2.3.15.Notation Data 28 + 5.2.3.16.Key server preferences 28 + 5.2.3.17.Preferred key server 29 + 5.2.3.18.Primary user id 29 + 5.2.3.19.Policy URL 29 + 5.2.3.20.Key Flags 29 + 5.2.3.21.Signer's User ID 30 + 5.2.3.22.Reason for Revocation 30 + 5.2.4. Computing Signatures 31 + 5.2.4.1. Subpacket Hints 32 + 5.3. Symmetric-Key Encrypted Session-Key Packets (Tag 3) 32 + 5.4. One-Pass Signature Packets (Tag 4) 33 + 5.5. Key Material Packet 34 + 5.5.1. Key Packet Variants 34 + 5.5.1.1. Public Key Packet (Tag 6) 34 + 5.5.1.2. Public Subkey Packet (Tag 14) 34 + 5.5.1.3. Secret Key Packet (Tag 5) 35 + 5.5.1.4. Secret Subkey Packet (Tag 7) 35 + 5.5.2. Public Key Packet Formats 35 + 5.5.3. Secret Key Packet Formats 37 + 5.6. Compressed Data Packet (Tag 8) 38 + 5.7. Symmetrically Encrypted Data Packet (Tag 9) 39 + 5.8. Marker Packet (Obsolete Literal Packet) (Tag 10) 39 + 5.9. Literal Data Packet (Tag 11) 40 + 5.10. Trust Packet (Tag 12) 40 + 5.11. User ID Packet (Tag 13) 41 + 6. Radix-64 Conversions 41 + + + +Callas, et. al. Standards Track [Page 3] + +RFC 2440 OpenPGP Message Format November 1998 + + + 6.1. An Implementation of the CRC-24 in "C" 42 + 6.2. Forming ASCII Armor 42 + 6.3. Encoding Binary in Radix-64 44 + 6.4. Decoding Radix-64 46 + 6.5. Examples of Radix-64 46 + 6.6. Example of an ASCII Armored Message 47 + 7. Cleartext signature framework 47 + 7.1. Dash-Escaped Text 47 + 8. Regular Expressions 48 + 9. Constants 49 + 9.1. Public Key Algorithms 49 + 9.2. Symmetric Key Algorithms 49 + 9.3. Compression Algorithms 50 + 9.4. Hash Algorithms 50 + 10. Packet Composition 50 + 10.1. Transferable Public Keys 50 + 10.2. OpenPGP Messages 52 + 10.3. Detached Signatures 52 + 11. Enhanced Key Formats 52 + 11.1. Key Structures 52 + 11.2. Key IDs and Fingerprints 53 + 12. Notes on Algorithms 54 + 12.1. Symmetric Algorithm Preferences 54 + 12.2. Other Algorithm Preferences 55 + 12.2.1. Compression Preferences 56 + 12.2.2. Hash Algorithm Preferences 56 + 12.3. Plaintext 56 + 12.4. RSA 56 + 12.5. Elgamal 57 + 12.6. DSA 58 + 12.7. Reserved Algorithm Numbers 58 + 12.8. OpenPGP CFB mode 58 + 13. Security Considerations 59 + 14. Implementation Nits 60 + 15. Authors and Working Group Chair 62 + 16. References 63 + 17. Full Copyright Statement 65 + +1. Introduction + + This document provides information on the message-exchange packet + formats used by OpenPGP to provide encryption, decryption, signing, + and key management functions. It builds on the foundation provided in + RFC 1991 "PGP Message Exchange Formats." + + + + + + + +Callas, et. al. Standards Track [Page 4] + +RFC 2440 OpenPGP Message Format November 1998 + + +1.1. Terms + + * OpenPGP - This is a definition for security software that uses + PGP 5.x as a basis. + + * PGP - Pretty Good Privacy. PGP is a family of software systems + developed by Philip R. Zimmermann from which OpenPGP is based. + + * PGP 2.6.x - This version of PGP has many variants, hence the term + PGP 2.6.x. It used only RSA, MD5, and IDEA for its cryptographic + transforms. An informational RFC, RFC 1991, was written + describing this version of PGP. + + * PGP 5.x - This version of PGP is formerly known as "PGP 3" in the + community and also in the predecessor of this document, RFC 1991. + It has new formats and corrects a number of problems in the PGP + 2.6.x design. It is referred to here as PGP 5.x because that + software was the first release of the "PGP 3" code base. + + "PGP", "Pretty Good", and "Pretty Good Privacy" are trademarks of + Network Associates, Inc. and are used with permission. + + This document uses the terms "MUST", "SHOULD", and "MAY" as defined + in RFC 2119, along with the negated forms of those terms. + +2. General functions + + OpenPGP provides data integrity services for messages and data files + by using these core technologies: + + - digital signatures + + - encryption + + - compression + + - radix-64 conversion + + In addition, OpenPGP provides key management and certificate + services, but many of these are beyond the scope of this document. + +2.1. Confidentiality via Encryption + + OpenPGP uses two encryption methods to provide confidentiality: + symmetric-key encryption and public key encryption. With public-key + encryption, the object is encrypted using a symmetric encryption + algorithm. Each symmetric key is used only once. A new "session key" + is generated as a random number for each message. Since it is used + + + +Callas, et. al. Standards Track [Page 5] + +RFC 2440 OpenPGP Message Format November 1998 + + + only once, the session key is bound to the message and transmitted + with it. To protect the key, it is encrypted with the receiver's + public key. The sequence is as follows: + + 1. The sender creates a message. + + 2. The sending OpenPGP generates a random number to be used as a + session key for this message only. + + 3. The session key is encrypted using each recipient's public key. + These "encrypted session keys" start the message. + + 4. The sending OpenPGP encrypts the message using the session key, + which forms the remainder of the message. Note that the message + is also usually compressed. + + 5. The receiving OpenPGP decrypts the session key using the + recipient's private key. + + 6. The receiving OpenPGP decrypts the message using the session key. + If the message was compressed, it will be decompressed. + + With symmetric-key encryption, an object may be encrypted with a + symmetric key derived from a passphrase (or other shared secret), or + a two-stage mechanism similar to the public-key method described + above in which a session key is itself encrypted with a symmetric + algorithm keyed from a shared secret. + + Both digital signature and confidentiality services may be applied to + the same message. First, a signature is generated for the message and + attached to the message. Then, the message plus signature is + encrypted using a symmetric session key. Finally, the session key is + encrypted using public-key encryption and prefixed to the encrypted + block. + +2.2. Authentication via Digital signature + + The digital signature uses a hash code or message digest algorithm, + and a public-key signature algorithm. The sequence is as follows: + + 1. The sender creates a message. + + 2. The sending software generates a hash code of the message. + + 3. The sending software generates a signature from the hash code + using the sender's private key. + + 4. The binary signature is attached to the message. + + + +Callas, et. al. Standards Track [Page 6] + +RFC 2440 OpenPGP Message Format November 1998 + + + 5. The receiving software keeps a copy of the message signature. + + 6. The receiving software generates a new hash code for the + received message and verifies it using the message's signature. + If the verification is successful, the message is accepted as + authentic. + +2.3. Compression + + OpenPGP implementations MAY compress the message after applying the + signature but before encryption. + +2.4. Conversion to Radix-64 + + OpenPGP's underlying native representation for encrypted messages, + signature certificates, and keys is a stream of arbitrary octets. + Some systems only permit the use of blocks consisting of seven-bit, + printable text. For transporting OpenPGP's native raw binary octets + through channels that are not safe to raw binary data, a printable + encoding of these binary octets is needed. OpenPGP provides the + service of converting the raw 8-bit binary octet stream to a stream + of printable ASCII characters, called Radix-64 encoding or ASCII + Armor. + + Implementations SHOULD provide Radix-64 conversions. + + Note that many applications, particularly messaging applications, + will want more advanced features as described in the OpenPGP-MIME + document, RFC 2015. An application that implements OpenPGP for + messaging SHOULD implement OpenPGP-MIME. + +2.5. Signature-Only Applications + + OpenPGP is designed for applications that use both encryption and + signatures, but there are a number of problems that are solved by a + signature-only implementation. Although this specification requires + both encryption and signatures, it is reasonable for there to be + subset implementations that are non-comformant only in that they omit + encryption. + +3. Data Element Formats + + This section describes the data elements used by OpenPGP. + + + + + + + + +Callas, et. al. Standards Track [Page 7] + +RFC 2440 OpenPGP Message Format November 1998 + + +3.1. Scalar numbers + + Scalar numbers are unsigned, and are always stored in big-endian + format. Using n[k] to refer to the kth octet being interpreted, the + value of a two-octet scalar is ((n[0] << 8) + n[1]). The value of a + four-octet scalar is ((n[0] << 24) + (n[1] << 16) + (n[2] << 8) + + n[3]). + +3.2. Multi-Precision Integers + + Multi-Precision Integers (also called MPIs) are unsigned integers + used to hold large integers such as the ones used in cryptographic + calculations. + + An MPI consists of two pieces: a two-octet scalar that is the length + of the MPI in bits followed by a string of octets that contain the + actual integer. + + These octets form a big-endian number; a big-endian number can be + made into an MPI by prefixing it with the appropriate length. + + Examples: + + (all numbers are in hexadecimal) + + The string of octets [00 01 01] forms an MPI with the value 1. The + string [00 09 01 FF] forms an MPI with the value of 511. + + Additional rules: + + The size of an MPI is ((MPI.length + 7) / 8) + 2 octets. + + The length field of an MPI describes the length starting from its + most significant non-zero bit. Thus, the MPI [00 02 01] is not formed + correctly. It should be [00 01 01]. + +3.3. Key IDs + + A Key ID is an eight-octet scalar that identifies a key. + Implementations SHOULD NOT assume that Key IDs are unique. The + section, "Enhanced Key Formats" below describes how Key IDs are + formed. + +3.4. Text + + The default character set for text is the UTF-8 [RFC2279] encoding of + Unicode [ISO10646]. + + + + +Callas, et. al. Standards Track [Page 8] + +RFC 2440 OpenPGP Message Format November 1998 + + +3.5. Time fields + + A time field is an unsigned four-octet number containing the number + of seconds elapsed since midnight, 1 January 1970 UTC. + +3.6. String-to-key (S2K) specifiers + + String-to-key (S2K) specifiers are used to convert passphrase strings + into symmetric-key encryption/decryption keys. They are used in two + places, currently: to encrypt the secret part of private keys in the + private keyring, and to convert passphrases to encryption keys for + symmetrically encrypted messages. + +3.6.1. String-to-key (S2k) specifier types + + There are three types of S2K specifiers currently supported, as + follows: + +3.6.1.1. Simple S2K + + This directly hashes the string to produce the key data. See below + for how this hashing is done. + + Octet 0: 0x00 + Octet 1: hash algorithm + + Simple S2K hashes the passphrase to produce the session key. The + manner in which this is done depends on the size of the session key + (which will depend on the cipher used) and the size of the hash + algorithm's output. If the hash size is greater than or equal to the + session key size, the high-order (leftmost) octets of the hash are + used as the key. + + If the hash size is less than the key size, multiple instances of the + hash context are created -- enough to produce the required key data. + These instances are preloaded with 0, 1, 2, ... octets of zeros (that + is to say, the first instance has no preloading, the second gets + preloaded with 1 octet of zero, the third is preloaded with two + octets of zeros, and so forth). + + As the data is hashed, it is given independently to each hash + context. Since the contexts have been initialized differently, they + will each produce different hash output. Once the passphrase is + hashed, the output data from the multiple hashes is concatenated, + first hash leftmost, to produce the key data, with any excess octets + on the right discarded. + + + + + +Callas, et. al. Standards Track [Page 9] + +RFC 2440 OpenPGP Message Format November 1998 + + +3.6.1.2. Salted S2K + + This includes a "salt" value in the S2K specifier -- some arbitrary + data -- that gets hashed along with the passphrase string, to help + prevent dictionary attacks. + + Octet 0: 0x01 + Octet 1: hash algorithm + Octets 2-9: 8-octet salt value + + Salted S2K is exactly like Simple S2K, except that the input to the + hash function(s) consists of the 8 octets of salt from the S2K + specifier, followed by the passphrase. + +3.6.1.3. Iterated and Salted S2K + + This includes both a salt and an octet count. The salt is combined + with the passphrase and the resulting value is hashed repeatedly. + This further increases the amount of work an attacker must do to try + dictionary attacks. + + Octet 0: 0x03 + Octet 1: hash algorithm + Octets 2-9: 8-octet salt value + Octet 10: count, a one-octet, coded value + + The count is coded into a one-octet number using the following + formula: + + #define EXPBIAS 6 + count = ((Int32)16 + (c & 15)) << ((c >> 4) + EXPBIAS); + + The above formula is in C, where "Int32" is a type for a 32-bit + integer, and the variable "c" is the coded count, Octet 10. + + Iterated-Salted S2K hashes the passphrase and salt data multiple + times. The total number of octets to be hashed is specified in the + encoded count in the S2K specifier. Note that the resulting count + value is an octet count of how many octets will be hashed, not an + iteration count. + + Initially, one or more hash contexts are set up as with the other S2K + algorithms, depending on how many octets of key data are needed. + Then the salt, followed by the passphrase data is repeatedly hashed + until the number of octets specified by the octet count has been + hashed. The one exception is that if the octet count is less than + the size of the salt plus passphrase, the full salt plus passphrase + will be hashed even though that is greater than the octet count. + + + +Callas, et. al. Standards Track [Page 10] + +RFC 2440 OpenPGP Message Format November 1998 + + + After the hashing is done the data is unloaded from the hash + context(s) as with the other S2K algorithms. + +3.6.2. String-to-key usage + + Implementations SHOULD use salted or iterated-and-salted S2K + specifiers, as simple S2K specifiers are more vulnerable to + dictionary attacks. + +3.6.2.1. Secret key encryption + + An S2K specifier can be stored in the secret keyring to specify how + to convert the passphrase to a key that unlocks the secret data. + Older versions of PGP just stored a cipher algorithm octet preceding + the secret data or a zero to indicate that the secret data was + unencrypted. The MD5 hash function was always used to convert the + passphrase to a key for the specified cipher algorithm. + + For compatibility, when an S2K specifier is used, the special value + 255 is stored in the position where the hash algorithm octet would + have been in the old data structure. This is then followed + immediately by a one-octet algorithm identifier, and then by the S2K + specifier as encoded above. + + Therefore, preceding the secret data there will be one of these + possibilities: + + 0: secret data is unencrypted (no pass phrase) + 255: followed by algorithm octet and S2K specifier + Cipher alg: use Simple S2K algorithm using MD5 hash + + This last possibility, the cipher algorithm number with an implicit + use of MD5 and IDEA, is provided for backward compatibility; it MAY + be understood, but SHOULD NOT be generated, and is deprecated. + + These are followed by an 8-octet Initial Vector for the decryption of + the secret values, if they are encrypted, and then the secret key + values themselves. + +3.6.2.2. Symmetric-key message encryption + + OpenPGP can create a Symmetric-key Encrypted Session Key (ESK) packet + at the front of a message. This is used to allow S2K specifiers to + be used for the passphrase conversion or to create messages with a + mix of symmetric-key ESKs and public-key ESKs. This allows a message + to be decrypted either with a passphrase or a public key. + + + + + +Callas, et. al. Standards Track [Page 11] + +RFC 2440 OpenPGP Message Format November 1998 + + + PGP 2.X always used IDEA with Simple string-to-key conversion when + encrypting a message with a symmetric algorithm. This is deprecated, + but MAY be used for backward-compatibility. + +4. Packet Syntax + + This section describes the packets used by OpenPGP. + +4.1. Overview + + An OpenPGP message is constructed from a number of records that are + traditionally called packets. A packet is a chunk of data that has a + tag specifying its meaning. An OpenPGP message, keyring, certificate, + and so forth consists of a number of packets. Some of those packets + may contain other OpenPGP packets (for example, a compressed data + packet, when uncompressed, contains OpenPGP packets). + + Each packet consists of a packet header, followed by the packet body. + The packet header is of variable length. + +4.2. Packet Headers + + The first octet of the packet header is called the "Packet Tag." It + determines the format of the header and denotes the packet contents. + The remainder of the packet header is the length of the packet. + + Note that the most significant bit is the left-most bit, called bit + 7. A mask for this bit is 0x80 in hexadecimal. + + +---------------+ + PTag |7 6 5 4 3 2 1 0| + +---------------+ + Bit 7 -- Always one + Bit 6 -- New packet format if set + + PGP 2.6.x only uses old format packets. Thus, software that + interoperates with those versions of PGP must only use old format + packets. If interoperability is not an issue, either format may be + used. Note that old format packets have four bits of content tags, + and new format packets have six; some features cannot be used and + still be backward-compatible. + + Old format packets contain: + + Bits 5-2 -- content tag + Bits 1-0 - length-type + + + + + +Callas, et. al. Standards Track [Page 12] + +RFC 2440 OpenPGP Message Format November 1998 + + + New format packets contain: + + Bits 5-0 -- content tag + +4.2.1. Old-Format Packet Lengths + + The meaning of the length-type in old-format packets is: + + 0 - The packet has a one-octet length. The header is 2 octets long. + + 1 - The packet has a two-octet length. The header is 3 octets long. + + 2 - The packet has a four-octet length. The header is 5 octets long. + + 3 - The packet is of indeterminate length. The header is 1 octet + long, and the implementation must determine how long the packet + is. If the packet is in a file, this means that the packet + extends until the end of the file. In general, an implementation + SHOULD NOT use indeterminate length packets except where the end + of the data will be clear from the context, and even then it is + better to use a definite length, or a new-format header. The + new-format headers described below have a mechanism for precisely + encoding data of indeterminate length. + +4.2.2. New-Format Packet Lengths + + New format packets have four possible ways of encoding length: + + 1. A one-octet Body Length header encodes packet lengths of up to + 191 octets. + + 2. A two-octet Body Length header encodes packet lengths of 192 to + 8383 octets. + + 3. A five-octet Body Length header encodes packet lengths of up to + 4,294,967,295 (0xFFFFFFFF) octets in length. (This actually + encodes a four-octet scalar number.) + + 4. When the length of the packet body is not known in advance by the + issuer, Partial Body Length headers encode a packet of + indeterminate length, effectively making it a stream. + + + + + + + + + + +Callas, et. al. Standards Track [Page 13] + +RFC 2440 OpenPGP Message Format November 1998 + + +4.2.2.1. One-Octet Lengths + + A one-octet Body Length header encodes a length of from 0 to 191 + octets. This type of length header is recognized because the one + octet value is less than 192. The body length is equal to: + + bodyLen = 1st_octet; + +4.2.2.2. Two-Octet Lengths + + A two-octet Body Length header encodes a length of from 192 to 8383 + octets. It is recognized because its first octet is in the range 192 + to 223. The body length is equal to: + + bodyLen = ((1st_octet - 192) << 8) + (2nd_octet) + 192 + +4.2.2.3. Five-Octet Lengths + + A five-octet Body Length header consists of a single octet holding + the value 255, followed by a four-octet scalar. The body length is + equal to: + + bodyLen = (2nd_octet << 24) | (3rd_octet << 16) | + (4th_octet << 8) | 5th_octet + +4.2.2.4. Partial Body Lengths + + A Partial Body Length header is one octet long and encodes the length + of only part of the data packet. This length is a power of 2, from 1 + to 1,073,741,824 (2 to the 30th power). It is recognized by its one + octet value that is greater than or equal to 224, and less than 255. + The partial body length is equal to: + + partialBodyLen = 1 << (1st_octet & 0x1f); + + Each Partial Body Length header is followed by a portion of the + packet body data. The Partial Body Length header specifies this + portion's length. Another length header (of one of the three types -- + one octet, two-octet, or partial) follows that portion. The last + length header in the packet MUST NOT be a partial Body Length header. + Partial Body Length headers may only be used for the non-final parts + of the packet. + +4.2.3. Packet Length Examples + + These examples show ways that new-format packets might encode the + packet lengths. + + + + +Callas, et. al. Standards Track [Page 14] + +RFC 2440 OpenPGP Message Format November 1998 + + + A packet with length 100 may have its length encoded in one octet: + 0x64. This is followed by 100 octets of data. + + A packet with length 1723 may have its length coded in two octets: + 0xC5, 0xFB. This header is followed by the 1723 octets of data. + + A packet with length 100000 may have its length encoded in five + octets: 0xFF, 0x00, 0x01, 0x86, 0xA0. + + It might also be encoded in the following octet stream: 0xEF, first + 32768 octets of data; 0xE1, next two octets of data; 0xE0, next one + octet of data; 0xF0, next 65536 octets of data; 0xC5, 0xDD, last 1693 + octets of data. This is just one possible encoding, and many + variations are possible on the size of the Partial Body Length + headers, as long as a regular Body Length header encodes the last + portion of the data. Note also that the last Body Length header can + be a zero-length header. + + An implementation MAY use Partial Body Lengths for data packets, be + they literal, compressed, or encrypted. The first partial length MUST + be at least 512 octets long. Partial Body Lengths MUST NOT be used + for any other packet types. + + Please note that in all of these explanations, the total length of + the packet is the length of the header(s) plus the length of the + body. + +4.3. Packet Tags + + The packet tag denotes what type of packet the body holds. Note that + old format headers can only have tags less than 16, whereas new + format headers can have tags as great as 63. The defined tags (in + decimal) are: + + 0 -- Reserved - a packet tag must not have this value + 1 -- Public-Key Encrypted Session Key Packet + 2 -- Signature Packet + 3 -- Symmetric-Key Encrypted Session Key Packet + 4 -- One-Pass Signature Packet + 5 -- Secret Key Packet + 6 -- Public Key Packet + 7 -- Secret Subkey Packet + 8 -- Compressed Data Packet + 9 -- Symmetrically Encrypted Data Packet + 10 -- Marker Packet + 11 -- Literal Data Packet + 12 -- Trust Packet + + + + +Callas, et. al. Standards Track [Page 15] + +RFC 2440 OpenPGP Message Format November 1998 + + + 13 -- User ID Packet + 14 -- Public Subkey Packet + 60 to 63 -- Private or Experimental Values + +5. Packet Types + +5.1. Public-Key Encrypted Session Key Packets (Tag 1) + + A Public-Key Encrypted Session Key packet holds the session key used + to encrypt a message. Zero or more Encrypted Session Key packets + (either Public-Key or Symmetric-Key) may precede a Symmetrically + Encrypted Data Packet, which holds an encrypted message. The message + is encrypted with the session key, and the session key is itself + encrypted and stored in the Encrypted Session Key packet(s). The + Symmetrically Encrypted Data Packet is preceded by one Public-Key + Encrypted Session Key packet for each OpenPGP key to which the + message is encrypted. The recipient of the message finds a session + key that is encrypted to their public key, decrypts the session key, + and then uses the session key to decrypt the message. + + The body of this packet consists of: + + - A one-octet number giving the version number of the packet type. + The currently defined value for packet version is 3. An + implementation should accept, but not generate a version of 2, + which is equivalent to V3 in all other respects. + + - An eight-octet number that gives the key ID of the public key + that the session key is encrypted to. + + - A one-octet number giving the public key algorithm used. + + - A string of octets that is the encrypted session key. This string + takes up the remainder of the packet, and its contents are + dependent on the public key algorithm used. + + Algorithm Specific Fields for RSA encryption + + - multiprecision integer (MPI) of RSA encrypted value m**e mod n. + + Algorithm Specific Fields for Elgamal encryption: + + - MPI of Elgamal (Diffie-Hellman) value g**k mod p. + + - MPI of Elgamal (Diffie-Hellman) value m * y**k mod p. + + + + + + +Callas, et. al. Standards Track [Page 16] + +RFC 2440 OpenPGP Message Format November 1998 + + + The value "m" in the above formulas is derived from the session key + as follows. First the session key is prefixed with a one-octet + algorithm identifier that specifies the symmetric encryption + algorithm used to encrypt the following Symmetrically Encrypted Data + Packet. Then a two-octet checksum is appended which is equal to the + sum of the preceding session key octets, not including the algorithm + identifier, modulo 65536. This value is then padded as described in + PKCS-1 block type 02 [RFC2313] to form the "m" value used in the + formulas above. + + Note that when an implementation forms several PKESKs with one + session key, forming a message that can be decrypted by several keys, + the implementation MUST make new PKCS-1 padding for each key. + + An implementation MAY accept or use a Key ID of zero as a "wild card" + or "speculative" Key ID. In this case, the receiving implementation + would try all available private keys, checking for a valid decrypted + session key. This format helps reduce traffic analysis of messages. + +5.2. Signature Packet (Tag 2) + + A signature packet describes a binding between some public key and + some data. The most common signatures are a signature of a file or a + block of text, and a signature that is a certification of a user ID. + + Two versions of signature packets are defined. Version 3 provides + basic signature information, while version 4 provides an expandable + format with subpackets that can specify more information about the + signature. PGP 2.6.x only accepts version 3 signatures. + + Implementations MUST accept V3 signatures. Implementations SHOULD + generate V4 signatures. Implementations MAY generate a V3 signature + that can be verified by PGP 2.6.x. + + Note that if an implementation is creating an encrypted and signed + message that is encrypted to a V3 key, it is reasonable to create a + V3 signature. + +5.2.1. Signature Types + + There are a number of possible meanings for a signature, which are + specified in a signature type octet in any given signature. These + meanings are: + + 0x00: Signature of a binary document. + Typically, this means the signer owns it, created it, or + certifies that it has not been modified. + + + + +Callas, et. al. Standards Track [Page 17] + +RFC 2440 OpenPGP Message Format November 1998 + + + 0x01: Signature of a canonical text document. + Typically, this means the signer owns it, created it, or + certifies that it has not been modified. The signature is + calculated over the text data with its line endings converted + to and trailing blanks removed. + + 0x02: Standalone signature. + This signature is a signature of only its own subpacket + contents. It is calculated identically to a signature over a + zero-length binary document. Note that it doesn't make sense to + have a V3 standalone signature. + + 0x10: Generic certification of a User ID and Public Key packet. + The issuer of this certification does not make any particular + assertion as to how well the certifier has checked that the + owner of the key is in fact the person described by the user + ID. Note that all PGP "key signatures" are this type of + certification. + + 0x11: Persona certification of a User ID and Public Key packet. + The issuer of this certification has not done any verification + of the claim that the owner of this key is the user ID + specified. + + 0x12: Casual certification of a User ID and Public Key packet. + The issuer of this certification has done some casual + verification of the claim of identity. + + 0x13: Positive certification of a User ID and Public Key packet. + The issuer of this certification has done substantial + verification of the claim of identity. + + Please note that the vagueness of these certification claims is + not a flaw, but a feature of the system. Because PGP places + final authority for validity upon the receiver of a + certification, it may be that one authority's casual + certification might be more rigorous than some other + authority's positive certification. These classifications allow + a certification authority to issue fine-grained claims. + + 0x18: Subkey Binding Signature + This signature is a statement by the top-level signing key + indicates that it owns the subkey. This signature is calculated + directly on the subkey itself, not on any User ID or other + packets. + + + + + + +Callas, et. al. Standards Track [Page 18] + +RFC 2440 OpenPGP Message Format November 1998 + + + 0x1F: Signature directly on a key + This signature is calculated directly on a key. It binds the + information in the signature subpackets to the key, and is + appropriate to be used for subpackets that provide information + about the key, such as the revocation key subpacket. It is also + appropriate for statements that non-self certifiers want to + make about the key itself, rather than the binding between a + key and a name. + + 0x20: Key revocation signature + The signature is calculated directly on the key being revoked. + A revoked key is not to be used. Only revocation signatures by + the key being revoked, or by an authorized revocation key, + should be considered valid revocation signatures. + + 0x28: Subkey revocation signature + The signature is calculated directly on the subkey being + revoked. A revoked subkey is not to be used. Only revocation + signatures by the top-level signature key that is bound to this + subkey, or by an authorized revocation key, should be + considered valid revocation signatures. + + 0x30: Certification revocation signature + This signature revokes an earlier user ID certification + signature (signature class 0x10 through 0x13). It should be + issued by the same key that issued the revoked signature or an + authorized revocation key The signature should have a later + creation date than the signature it revokes. + + 0x40: Timestamp signature. + This signature is only meaningful for the timestamp contained + in it. + +5.2.2. Version 3 Signature Packet Format + + The body of a version 3 Signature Packet contains: + + - One-octet version number (3). + + - One-octet length of following hashed material. MUST be 5. + + - One-octet signature type. + + - Four-octet creation time. + + - Eight-octet key ID of signer. + + - One-octet public key algorithm. + + + +Callas, et. al. Standards Track [Page 19] + +RFC 2440 OpenPGP Message Format November 1998 + + + - One-octet hash algorithm. + + - Two-octet field holding left 16 bits of signed hash value. + + - One or more multi-precision integers comprising the signature. + This portion is algorithm specific, as described below. + + The data being signed is hashed, and then the signature type and + creation time from the signature packet are hashed (5 additional + octets). The resulting hash value is used in the signature + algorithm. The high 16 bits (first two octets) of the hash are + included in the signature packet to provide a quick test to reject + some invalid signatures. + + Algorithm Specific Fields for RSA signatures: + + - multiprecision integer (MPI) of RSA signature value m**d. + + Algorithm Specific Fields for DSA signatures: + + - MPI of DSA value r. + + - MPI of DSA value s. + + The signature calculation is based on a hash of the signed data, as + described above. The details of the calculation are different for + DSA signature than for RSA signatures. + + With RSA signatures, the hash value is encoded as described in PKCS-1 + section 10.1.2, "Data encoding", producing an ASN.1 value of type + DigestInfo, and then padded using PKCS-1 block type 01 [RFC2313]. + This requires inserting the hash value as an octet string into an + ASN.1 structure. The object identifier for the type of hash being + used is included in the structure. The hexadecimal representations + for the currently defined hash algorithms are: + + - MD2: 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x02, 0x02 + + - MD5: 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x02, 0x05 + + - RIPEMD-160: 0x2B, 0x24, 0x03, 0x02, 0x01 + + - SHA-1: 0x2B, 0x0E, 0x03, 0x02, 0x1A + + + + + + + + +Callas, et. al. Standards Track [Page 20] + +RFC 2440 OpenPGP Message Format November 1998 + + + The ASN.1 OIDs are: + + - MD2: 1.2.840.113549.2.2 + + - MD5: 1.2.840.113549.2.5 + + - RIPEMD-160: 1.3.36.3.2.1 + + - SHA-1: 1.3.14.3.2.26 + + The full hash prefixes for these are: + + MD2: 0x30, 0x20, 0x30, 0x0C, 0x06, 0x08, 0x2A, 0x86, + 0x48, 0x86, 0xF7, 0x0D, 0x02, 0x02, 0x05, 0x00, + 0x04, 0x10 + + MD5: 0x30, 0x20, 0x30, 0x0C, 0x06, 0x08, 0x2A, 0x86, + 0x48, 0x86, 0xF7, 0x0D, 0x02, 0x05, 0x05, 0x00, + 0x04, 0x10 + + RIPEMD-160: 0x30, 0x21, 0x30, 0x09, 0x06, 0x05, 0x2B, 0x24, + 0x03, 0x02, 0x01, 0x05, 0x00, 0x04, 0x14 + + SHA-1: 0x30, 0x21, 0x30, 0x09, 0x06, 0x05, 0x2b, 0x0E, + 0x03, 0x02, 0x1A, 0x05, 0x00, 0x04, 0x14 + + DSA signatures MUST use hashes with a size of 160 bits, to match q, + the size of the group generated by the DSA key's generator value. + The hash function result is treated as a 160 bit number and used + directly in the DSA signature algorithm. + +5.2.3. Version 4 Signature Packet Format + + The body of a version 4 Signature Packet contains: + + - One-octet version number (4). + + - One-octet signature type. + + - One-octet public key algorithm. + + - One-octet hash algorithm. + + - Two-octet scalar octet count for following hashed subpacket + data. Note that this is the length in octets of all of the hashed + subpackets; a pointer incremented by this number will skip over + the hashed subpackets. + + + + +Callas, et. al. Standards Track [Page 21] + +RFC 2440 OpenPGP Message Format November 1998 + + + - Hashed subpacket data. (zero or more subpackets) + + - Two-octet scalar octet count for following unhashed subpacket + data. Note that this is the length in octets of all of the + unhashed subpackets; a pointer incremented by this number will + skip over the unhashed subpackets. + + - Unhashed subpacket data. (zero or more subpackets) + + - Two-octet field holding left 16 bits of signed hash value. + + - One or more multi-precision integers comprising the signature. + This portion is algorithm specific, as described above. + + The data being signed is hashed, and then the signature data from the + version number through the hashed subpacket data (inclusive) is + hashed. The resulting hash value is what is signed. The left 16 bits + of the hash are included in the signature packet to provide a quick + test to reject some invalid signatures. + + There are two fields consisting of signature subpackets. The first + field is hashed with the rest of the signature data, while the second + is unhashed. The second set of subpackets is not cryptographically + protected by the signature and should include only advisory + information. + + The algorithms for converting the hash function result to a signature + are described in a section below. + +5.2.3.1. Signature Subpacket Specification + + The subpacket fields consist of zero or more signature subpackets. + Each set of subpackets is preceded by a two-octet scalar count of the + length of the set of subpackets. + + Each subpacket consists of a subpacket header and a body. The header + consists of: + + - the subpacket length (1, 2, or 5 octets) + + - the subpacket type (1 octet) + + and is followed by the subpacket specific data. + + The length includes the type octet but not this length. Its format is + similar to the "new" format packet header lengths, but cannot have + partial body lengths. That is: + + + + +Callas, et. al. Standards Track [Page 22] + +RFC 2440 OpenPGP Message Format November 1998 + + + if the 1st octet < 192, then + lengthOfLength = 1 + subpacketLen = 1st_octet + + if the 1st octet >= 192 and < 255, then + lengthOfLength = 2 + subpacketLen = ((1st_octet - 192) << 8) + (2nd_octet) + 192 + + if the 1st octet = 255, then + lengthOfLength = 5 + subpacket length = [four-octet scalar starting at 2nd_octet] + + The value of the subpacket type octet may be: + + 2 = signature creation time + 3 = signature expiration time + 4 = exportable certification + 5 = trust signature + 6 = regular expression + 7 = revocable + 9 = key expiration time + 10 = placeholder for backward compatibility + 11 = preferred symmetric algorithms + 12 = revocation key + 16 = issuer key ID + 20 = notation data + 21 = preferred hash algorithms + 22 = preferred compression algorithms + 23 = key server preferences + 24 = preferred key server + 25 = primary user id + 26 = policy URL + 27 = key flags + 28 = signer's user id + 29 = reason for revocation + 100 to 110 = internal or user-defined + + An implementation SHOULD ignore any subpacket of a type that it does + not recognize. + + Bit 7 of the subpacket type is the "critical" bit. If set, it + denotes that the subpacket is one that is critical for the evaluator + of the signature to recognize. If a subpacket is encountered that is + marked critical but is unknown to the evaluating software, the + evaluator SHOULD consider the signature to be in error. + + + + + + +Callas, et. al. Standards Track [Page 23] + +RFC 2440 OpenPGP Message Format November 1998 + + + An evaluator may "recognize" a subpacket, but not implement it. The + purpose of the critical bit is to allow the signer to tell an + evaluator that it would prefer a new, unknown feature to generate an + error than be ignored. + + Implementations SHOULD implement "preferences". + +5.2.3.2. Signature Subpacket Types + + A number of subpackets are currently defined. Some subpackets apply + to the signature itself and some are attributes of the key. + Subpackets that are found on a self-signature are placed on a user id + certification made by the key itself. Note that a key may have more + than one user id, and thus may have more than one self-signature, and + differing subpackets. + + A self-signature is a binding signature made by the key the signature + refers to. There are three types of self-signatures, the + certification signatures (types 0x10-0x13), the direct-key signature + (type 0x1f), and the subkey binding signature (type 0x18). For + certification self-signatures, each user ID may have a self- + signature, and thus different subpackets in those self-signatures. + For subkey binding signatures, each subkey in fact has a self- + signature. Subpackets that appear in a certification self-signature + apply to the username, and subpackets that appear in the subkey + self-signature apply to the subkey. Lastly, subpackets on the direct + key signature apply to the entire key. + + Implementing software should interpret a self-signature's preference + subpackets as narrowly as possible. For example, suppose a key has + two usernames, Alice and Bob. Suppose that Alice prefers the + symmetric algorithm CAST5, and Bob prefers IDEA or Triple-DES. If the + software locates this key via Alice's name, then the preferred + algorithm is CAST5, if software locates the key via Bob's name, then + the preferred algorithm is IDEA. If the key is located by key id, + then algorithm of the default user id of the key provides the default + symmetric algorithm. + + A subpacket may be found either in the hashed or unhashed subpacket + sections of a signature. If a subpacket is not hashed, then the + information in it cannot be considered definitive because it is not + part of the signature proper. + + + + + + + + + +Callas, et. al. Standards Track [Page 24] + +RFC 2440 OpenPGP Message Format November 1998 + + +5.2.3.3. Signature creation time + + (4 octet time field) + + The time the signature was made. + + MUST be present in the hashed area. + +5.2.3.4. Issuer + + (8 octet key ID) + + The OpenPGP key ID of the key issuing the signature. + +5.2.3.5. Key expiration time + + (4 octet time field) + + The validity period of the key. This is the number of seconds after + the key creation time that the key expires. If this is not present + or has a value of zero, the key never expires. This is found only on + a self-signature. + +5.2.3.6. Preferred symmetric algorithms + + (sequence of one-octet values) + + Symmetric algorithm numbers that indicate which algorithms the key + holder prefers to use. The subpacket body is an ordered list of + octets with the most preferred listed first. It is assumed that only + algorithms listed are supported by the recipient's software. + Algorithm numbers in section 9. This is only found on a self- + signature. + +5.2.3.7. Preferred hash algorithms + + (array of one-octet values) + + Message digest algorithm numbers that indicate which algorithms the + key holder prefers to receive. Like the preferred symmetric + algorithms, the list is ordered. Algorithm numbers are in section 6. + This is only found on a self-signature. + + + + + + + + + +Callas, et. al. Standards Track [Page 25] + +RFC 2440 OpenPGP Message Format November 1998 + + +5.2.3.8. Preferred compression algorithms + + (array of one-octet values) + + Compression algorithm numbers that indicate which algorithms the key + holder prefers to use. Like the preferred symmetric algorithms, the + list is ordered. Algorithm numbers are in section 6. If this + subpacket is not included, ZIP is preferred. A zero denotes that + uncompressed data is preferred; the key holder's software might have + no compression software in that implementation. This is only found on + a self-signature. + +5.2.3.9. Signature expiration time + + (4 octet time field) + + The validity period of the signature. This is the number of seconds + after the signature creation time that the signature expires. If this + is not present or has a value of zero, it never expires. + +5.2.3.10. Exportable Certification + + (1 octet of exportability, 0 for not, 1 for exportable) + + This subpacket denotes whether a certification signature is + "exportable", to be used by other users than the signature's issuer. + The packet body contains a boolean flag indicating whether the + signature is exportable. If this packet is not present, the + certification is exportable; it is equivalent to a flag containing a + 1. + + Non-exportable, or "local", certifications are signatures made by a + user to mark a key as valid within that user's implementation only. + Thus, when an implementation prepares a user's copy of a key for + transport to another user (this is the process of "exporting" the + key), any local certification signatures are deleted from the key. + + The receiver of a transported key "imports" it, and likewise trims + any local certifications. In normal operation, there won't be any, + assuming the import is performed on an exported key. However, there + are instances where this can reasonably happen. For example, if an + implementation allows keys to be imported from a key database in + addition to an exported key, then this situation can arise. + + Some implementations do not represent the interest of a single user + (for example, a key server). Such implementations always trim local + certifications from any key they handle. + + + + +Callas, et. al. Standards Track [Page 26] + +RFC 2440 OpenPGP Message Format November 1998 + + +5.2.3.11. Revocable + + (1 octet of revocability, 0 for not, 1 for revocable) + + Signature's revocability status. Packet body contains a boolean flag + indicating whether the signature is revocable. Signatures that are + not revocable have any later revocation signatures ignored. They + represent a commitment by the signer that he cannot revoke his + signature for the life of his key. If this packet is not present, + the signature is revocable. + +5.2.3.12. Trust signature + + (1 octet "level" (depth), 1 octet of trust amount) + + Signer asserts that the key is not only valid, but also trustworthy, + at the specified level. Level 0 has the same meaning as an ordinary + validity signature. Level 1 means that the signed key is asserted to + be a valid trusted introducer, with the 2nd octet of the body + specifying the degree of trust. Level 2 means that the signed key is + asserted to be trusted to issue level 1 trust signatures, i.e. that + it is a "meta introducer". Generally, a level n trust signature + asserts that a key is trusted to issue level n-1 trust signatures. + The trust amount is in a range from 0-255, interpreted such that + values less than 120 indicate partial trust and values of 120 or + greater indicate complete trust. Implementations SHOULD emit values + of 60 for partial trust and 120 for complete trust. + +5.2.3.13. Regular expression + + (null-terminated regular expression) + + Used in conjunction with trust signature packets (of level > 0) to + limit the scope of trust that is extended. Only signatures by the + target key on user IDs that match the regular expression in the body + of this packet have trust extended by the trust signature subpacket. + The regular expression uses the same syntax as the Henry Spencer's + "almost public domain" regular expression package. A description of + the syntax is found in a section below. + +5.2.3.14. Revocation key + + (1 octet of class, 1 octet of algid, 20 octets of fingerprint) + + Authorizes the specified key to issue revocation signatures for this + key. Class octet must have bit 0x80 set. If the bit 0x40 is set, + then this means that the revocation information is sensitive. Other + bits are for future expansion to other kinds of authorizations. This + + + +Callas, et. al. Standards Track [Page 27] + +RFC 2440 OpenPGP Message Format November 1998 + + + is found on a self-signature. + + If the "sensitive" flag is set, the keyholder feels this subpacket + contains private trust information that describes a real-world + sensitive relationship. If this flag is set, implementations SHOULD + NOT export this signature to other users except in cases where the + data needs to be available: when the signature is being sent to the + designated revoker, or when it is accompanied by a revocation + signature from that revoker. Note that it may be appropriate to + isolate this subpacket within a separate signature so that it is not + combined with other subpackets that need to be exported. + +5.2.3.15. Notation Data + + (4 octets of flags, 2 octets of name length (M), + 2 octets of value length (N), + M octets of name data, + N octets of value data) + + This subpacket describes a "notation" on the signature that the + issuer wishes to make. The notation has a name and a value, each of + which are strings of octets. There may be more than one notation in a + signature. Notations can be used for any extension the issuer of the + signature cares to make. The "flags" field holds four octets of + flags. + + All undefined flags MUST be zero. Defined flags are: + + First octet: 0x80 = human-readable. This note is text, a note + from one person to another, and has no + meaning to software. + Other octets: none. + +5.2.3.16. Key server preferences + + (N octets of flags) + + This is a list of flags that indicate preferences that the key holder + has about how the key is handled on a key server. All undefined flags + MUST be zero. + + First octet: 0x80 = No-modify + the key holder requests that this key only be modified or updated + by the key holder or an administrator of the key server. + + This is found only on a self-signature. + + + + + +Callas, et. al. Standards Track [Page 28] + +RFC 2440 OpenPGP Message Format November 1998 + + +5.2.3.17. Preferred key server + + (String) + + This is a URL of a key server that the key holder prefers be used for + updates. Note that keys with multiple user ids can have a preferred + key server for each user id. Note also that since this is a URL, the + key server can actually be a copy of the key retrieved by ftp, http, + finger, etc. + +5.2.3.18. Primary user id + + (1 octet, boolean) + + This is a flag in a user id's self signature that states whether this + user id is the main user id for this key. It is reasonable for an + implementation to resolve ambiguities in preferences, etc. by + referring to the primary user id. If this flag is absent, its value + is zero. If more than one user id in a key is marked as primary, the + implementation may resolve the ambiguity in any way it sees fit. + +5.2.3.19. Policy URL + + (String) + + This subpacket contains a URL of a document that describes the policy + that the signature was issued under. + +5.2.3.20. Key Flags + + (Octet string) + + This subpacket contains a list of binary flags that hold information + about a key. It is a string of octets, and an implementation MUST NOT + assume a fixed size. This is so it can grow over time. If a list is + shorter than an implementation expects, the unstated flags are + considered to be zero. The defined flags are: + + First octet: + + 0x01 - This key may be used to certify other keys. + + 0x02 - This key may be used to sign data. + + 0x04 - This key may be used to encrypt communications. + + 0x08 - This key may be used to encrypt storage. + + + + +Callas, et. al. Standards Track [Page 29] + +RFC 2440 OpenPGP Message Format November 1998 + + + 0x10 - The private component of this key may have been split by a + secret-sharing mechanism. + + 0x80 - The private component of this key may be in the possession + of more than one person. + + Usage notes: + + The flags in this packet may appear in self-signatures or in + certification signatures. They mean different things depending on who + is making the statement -- for example, a certification signature + that has the "sign data" flag is stating that the certification is + for that use. On the other hand, the "communications encryption" flag + in a self-signature is stating a preference that a given key be used + for communications. Note however, that it is a thorny issue to + determine what is "communications" and what is "storage." This + decision is left wholly up to the implementation; the authors of this + document do not claim any special wisdom on the issue, and realize + that accepted opinion may change. + + The "split key" (0x10) and "group key" (0x80) flags are placed on a + self-signature only; they are meaningless on a certification + signature. They SHOULD be placed only on a direct-key signature (type + 0x1f) or a subkey signature (type 0x18), one that refers to the key + the flag applies to. + +5.2.3.21. Signer's User ID + + This subpacket allows a keyholder to state which user id is + responsible for the signing. Many keyholders use a single key for + different purposes, such as business communications as well as + personal communications. This subpacket allows such a keyholder to + state which of their roles is making a signature. + +5.2.3.22. Reason for Revocation + + (1 octet of revocation code, N octets of reason string) + + This subpacket is used only in key revocation and certification + revocation signatures. It describes the reason why the key or + certificate was revoked. + + The first octet contains a machine-readable code that denotes the + reason for the revocation: + + + + + + + +Callas, et. al. Standards Track [Page 30] + +RFC 2440 OpenPGP Message Format November 1998 + + + 0x00 - No reason specified (key revocations or cert revocations) + 0x01 - Key is superceded (key revocations) + 0x02 - Key material has been compromised (key revocations) + 0x03 - Key is no longer used (key revocations) + 0x20 - User id information is no longer valid (cert revocations) + + Following the revocation code is a string of octets which gives + information about the reason for revocation in human-readable form + (UTF-8). The string may be null, that is, of zero length. The length + of the subpacket is the length of the reason string plus one. + +5.2.4. Computing Signatures + + All signatures are formed by producing a hash over the signature + data, and then using the resulting hash in the signature algorithm. + + The signature data is simple to compute for document signatures + (types 0x00 and 0x01), for which the document itself is the data. + For standalone signatures, this is a null string. + + When a signature is made over a key, the hash data starts with the + octet 0x99, followed by a two-octet length of the key, and then body + of the key packet. (Note that this is an old-style packet header for + a key packet with two-octet length.) A subkey signature (type 0x18) + then hashes the subkey, using the same format as the main key. Key + revocation signatures (types 0x20 and 0x28) hash only the key being + revoked. + + A certification signature (type 0x10 through 0x13) hashes the user id + being bound to the key into the hash context after the above data. A + V3 certification hashes the contents of the name packet, without any + header. A V4 certification hashes the constant 0xb4 (which is an + old-style packet header with the length-of-length set to zero), a + four-octet number giving the length of the username, and then the + username data. + + Once the data body is hashed, then a trailer is hashed. A V3 + signature hashes five octets of the packet body, starting from the + signature type field. This data is the signature type, followed by + the four-octet signature time. A V4 signature hashes the packet body + starting from its first field, the version number, through the end of + the hashed subpacket data. Thus, the fields hashed are the signature + version, the signature type, the public key algorithm, the hash + algorithm, the hashed subpacket length, and the hashed subpacket + body. + + + + + + +Callas, et. al. Standards Track [Page 31] + +RFC 2440 OpenPGP Message Format November 1998 + + + V4 signatures also hash in a final trailer of six octets: the version + of the signature packet, i.e. 0x04; 0xFF; a four-octet, big-endian + number that is the length of the hashed data from the signature + packet (note that this number does not include these final six + octets. + + After all this has been hashed, the resulting hash field is used in + the signature algorithm, and placed at the end of the signature + packet. + +5.2.4.1. Subpacket Hints + + An implementation SHOULD put the two mandatory subpackets, creation + time and issuer, as the first subpackets in the subpacket list, + simply to make it easier for the implementer to find them. + + It is certainly possible for a signature to contain conflicting + information in subpackets. For example, a signature may contain + multiple copies of a preference or multiple expiration times. In most + cases, an implementation SHOULD use the last subpacket in the + signature, but MAY use any conflict resolution scheme that makes more + sense. Please note that we are intentionally leaving conflict + resolution to the implementer; most conflicts are simply syntax + errors, and the wishy-washy language here allows a receiver to be + generous in what they accept, while putting pressure on a creator to + be stingy in what they generate. + + Some apparent conflicts may actually make sense -- for example, + suppose a keyholder has an V3 key and a V4 key that share the same + RSA key material. Either of these keys can verify a signature created + by the other, and it may be reasonable for a signature to contain an + issuer subpacket for each key, as a way of explicitly tying those + keys to the signature. + +5.3. Symmetric-Key Encrypted Session-Key Packets (Tag 3) + + The Symmetric-Key Encrypted Session Key packet holds the symmetric- + key encryption of a session key used to encrypt a message. Zero or + more Encrypted Session Key packets and/or Symmetric-Key Encrypted + Session Key packets may precede a Symmetrically Encrypted Data Packet + that holds an encrypted message. The message is encrypted with a + session key, and the session key is itself encrypted and stored in + the Encrypted Session Key packet or the Symmetric-Key Encrypted + Session Key packet. + + If the Symmetrically Encrypted Data Packet is preceded by one or more + Symmetric-Key Encrypted Session Key packets, each specifies a + passphrase that may be used to decrypt the message. This allows a + + + +Callas, et. al. Standards Track [Page 32] + +RFC 2440 OpenPGP Message Format November 1998 + + + message to be encrypted to a number of public keys, and also to one + or more pass phrases. This packet type is new, and is not generated + by PGP 2.x or PGP 5.0. + + The body of this packet consists of: + + - A one-octet version number. The only currently defined version + is 4. + + - A one-octet number describing the symmetric algorithm used. + + - A string-to-key (S2K) specifier, length as defined above. + + - Optionally, the encrypted session key itself, which is decrypted + with the string-to-key object. + + If the encrypted session key is not present (which can be detected on + the basis of packet length and S2K specifier size), then the S2K + algorithm applied to the passphrase produces the session key for + decrypting the file, using the symmetric cipher algorithm from the + Symmetric-Key Encrypted Session Key packet. + + If the encrypted session key is present, the result of applying the + S2K algorithm to the passphrase is used to decrypt just that + encrypted session key field, using CFB mode with an IV of all zeros. + The decryption result consists of a one-octet algorithm identifier + that specifies the symmetric-key encryption algorithm used to encrypt + the following Symmetrically Encrypted Data Packet, followed by the + session key octets themselves. + + Note: because an all-zero IV is used for this decryption, the S2K + specifier MUST use a salt value, either a Salted S2K or an Iterated- + Salted S2K. The salt value will insure that the decryption key is + not repeated even if the passphrase is reused. + +5.4. One-Pass Signature Packets (Tag 4) + + The One-Pass Signature packet precedes the signed data and contains + enough information to allow the receiver to begin calculating any + hashes needed to verify the signature. It allows the Signature + Packet to be placed at the end of the message, so that the signer can + compute the entire signed message in one pass. + + A One-Pass Signature does not interoperate with PGP 2.6.x or earlier. + + The body of this packet consists of: + + + + + +Callas, et. al. Standards Track [Page 33] + +RFC 2440 OpenPGP Message Format November 1998 + + + - A one-octet version number. The current version is 3. + + - A one-octet signature type. Signature types are described in + section 5.2.1. + + - A one-octet number describing the hash algorithm used. + + - A one-octet number describing the public key algorithm used. + + - An eight-octet number holding the key ID of the signing key. + + - A one-octet number holding a flag showing whether the signature + is nested. A zero value indicates that the next packet is + another One-Pass Signature packet that describes another + signature to be applied to the same message data. + + Note that if a message contains more than one one-pass signature, + then the signature packets bracket the message; that is, the first + signature packet after the message corresponds to the last one-pass + packet and the final signature packet corresponds to the first one- + pass packet. + +5.5. Key Material Packet + + A key material packet contains all the information about a public or + private key. There are four variants of this packet type, and two + major versions. Consequently, this section is complex. + +5.5.1. Key Packet Variants + +5.5.1.1. Public Key Packet (Tag 6) + + A Public Key packet starts a series of packets that forms an OpenPGP + key (sometimes called an OpenPGP certificate). + +5.5.1.2. Public Subkey Packet (Tag 14) + + A Public Subkey packet (tag 14) has exactly the same format as a + Public Key packet, but denotes a subkey. One or more subkeys may be + associated with a top-level key. By convention, the top-level key + provides signature services, and the subkeys provide encryption + services. + + Note: in PGP 2.6.x, tag 14 was intended to indicate a comment packet. + This tag was selected for reuse because no previous version of PGP + ever emitted comment packets but they did properly ignore them. + Public Subkey packets are ignored by PGP 2.6.x and do not cause it to + fail, providing a limited degree of backward compatibility. + + + +Callas, et. al. Standards Track [Page 34] + +RFC 2440 OpenPGP Message Format November 1998 + + +5.5.1.3. Secret Key Packet (Tag 5) + + A Secret Key packet contains all the information that is found in a + Public Key packet, including the public key material, but also + includes the secret key material after all the public key fields. + +5.5.1.4. Secret Subkey Packet (Tag 7) + + A Secret Subkey packet (tag 7) is the subkey analog of the Secret Key + packet, and has exactly the same format. + +5.5.2. Public Key Packet Formats + + There are two versions of key-material packets. Version 3 packets + were first generated by PGP 2.6. Version 2 packets are identical in + format to Version 3 packets, but are generated by PGP 2.5 or before. + V2 packets are deprecated and they MUST NOT be generated. PGP 5.0 + introduced version 4 packets, with new fields and semantics. PGP + 2.6.x will not accept key-material packets with versions greater than + 3. + + OpenPGP implementations SHOULD create keys with version 4 format. An + implementation MAY generate a V3 key to ensure interoperability with + old software; note, however, that V4 keys correct some security + deficiencies in V3 keys. These deficiencies are described below. An + implementation MUST NOT create a V3 key with a public key algorithm + other than RSA. + + A version 3 public key or public subkey packet contains: + + - A one-octet version number (3). + + - A four-octet number denoting the time that the key was created. + + - A two-octet number denoting the time in days that this key is + valid. If this number is zero, then it does not expire. + + - A one-octet number denoting the public key algorithm of this key + + - A series of multi-precision integers comprising the key + material: + + - a multiprecision integer (MPI) of RSA public modulus n; + + - an MPI of RSA public encryption exponent e. + + + + + + +Callas, et. al. Standards Track [Page 35] + +RFC 2440 OpenPGP Message Format November 1998 + + + V3 keys SHOULD only be used for backward compatibility because of + three weaknesses in them. First, it is relatively easy to construct a + V3 key that has the same key ID as any other key because the key ID + is simply the low 64 bits of the public modulus. Secondly, because + the fingerprint of a V3 key hashes the key material, but not its + length, which increases the opportunity for fingerprint collisions. + Third, there are minor weaknesses in the MD5 hash algorithm that make + developers prefer other algorithms. See below for a fuller discussion + of key IDs and fingerprints. + + The version 4 format is similar to the version 3 format except for + the absence of a validity period. This has been moved to the + signature packet. In addition, fingerprints of version 4 keys are + calculated differently from version 3 keys, as described in section + "Enhanced Key Formats." + + A version 4 packet contains: + + - A one-octet version number (4). + + - A four-octet number denoting the time that the key was created. + + - A one-octet number denoting the public key algorithm of this key + + - A series of multi-precision integers comprising the key + material. This algorithm-specific portion is: + + Algorithm Specific Fields for RSA public keys: + + - multiprecision integer (MPI) of RSA public modulus n; + + - MPI of RSA public encryption exponent e. + + Algorithm Specific Fields for DSA public keys: + + - MPI of DSA prime p; + + - MPI of DSA group order q (q is a prime divisor of p-1); + + - MPI of DSA group generator g; + + - MPI of DSA public key value y (= g**x where x is secret). + + Algorithm Specific Fields for Elgamal public keys: + + - MPI of Elgamal prime p; + + - MPI of Elgamal group generator g; + + + +Callas, et. al. Standards Track [Page 36] + +RFC 2440 OpenPGP Message Format November 1998 + + + - MPI of Elgamal public key value y (= g**x where x is + secret). + +5.5.3. Secret Key Packet Formats + + The Secret Key and Secret Subkey packets contain all the data of the + Public Key and Public Subkey packets, with additional algorithm- + specific secret key data appended, in encrypted form. + + The packet contains: + + - A Public Key or Public Subkey packet, as described above + + - One octet indicating string-to-key usage conventions. 0 + indicates that the secret key data is not encrypted. 255 + indicates that a string-to-key specifier is being given. Any + other value is a symmetric-key encryption algorithm specifier. + + - [Optional] If string-to-key usage octet was 255, a one-octet + symmetric encryption algorithm. + + - [Optional] If string-to-key usage octet was 255, a string-to-key + specifier. The length of the string-to-key specifier is implied + by its type, as described above. + + - [Optional] If secret data is encrypted, eight-octet Initial + Vector (IV). + + - Encrypted multi-precision integers comprising the secret key + data. These algorithm-specific fields are as described below. + + - Two-octet checksum of the plaintext of the algorithm-specific + portion (sum of all octets, mod 65536). + + Algorithm Specific Fields for RSA secret keys: + + - multiprecision integer (MPI) of RSA secret exponent d. + + - MPI of RSA secret prime value p. + + - MPI of RSA secret prime value q (p < q). + + - MPI of u, the multiplicative inverse of p, mod q. + + Algorithm Specific Fields for DSA secret keys: + + - MPI of DSA secret exponent x. + + + + +Callas, et. al. Standards Track [Page 37] + +RFC 2440 OpenPGP Message Format November 1998 + + + Algorithm Specific Fields for Elgamal secret keys: + + - MPI of Elgamal secret exponent x. + + Secret MPI values can be encrypted using a passphrase. If a string- + to-key specifier is given, that describes the algorithm for + converting the passphrase to a key, else a simple MD5 hash of the + passphrase is used. Implementations SHOULD use a string-to-key + specifier; the simple hash is for backward compatibility. The cipher + for encrypting the MPIs is specified in the secret key packet. + + Encryption/decryption of the secret data is done in CFB mode using + the key created from the passphrase and the Initial Vector from the + packet. A different mode is used with V3 keys (which are only RSA) + than with other key formats. With V3 keys, the MPI bit count prefix + (i.e., the first two octets) is not encrypted. Only the MPI non- + prefix data is encrypted. Furthermore, the CFB state is + resynchronized at the beginning of each new MPI value, so that the + CFB block boundary is aligned with the start of the MPI data. + + With V4 keys, a simpler method is used. All secret MPI values are + encrypted in CFB mode, including the MPI bitcount prefix. + + The 16-bit checksum that follows the algorithm-specific portion is + the algebraic sum, mod 65536, of the plaintext of all the algorithm- + specific octets (including MPI prefix and data). With V3 keys, the + checksum is stored in the clear. With V4 keys, the checksum is + encrypted like the algorithm-specific data. This value is used to + check that the passphrase was correct. + +5.6. Compressed Data Packet (Tag 8) + + The Compressed Data packet contains compressed data. Typically, this + packet is found as the contents of an encrypted packet, or following + a Signature or One-Pass Signature packet, and contains literal data + packets. + + The body of this packet consists of: + + - One octet that gives the algorithm used to compress the packet. + + - The remainder of the packet is compressed data. + + A Compressed Data Packet's body contains an block that compresses + some set of packets. See section "Packet Composition" for details on + how messages are formed. + + + + + +Callas, et. al. Standards Track [Page 38] + +RFC 2440 OpenPGP Message Format November 1998 + + + ZIP-compressed packets are compressed with raw RFC 1951 DEFLATE + blocks. Note that PGP V2.6 uses 13 bits of compression. If an + implementation uses more bits of compression, PGP V2.6 cannot + decompress it. + + ZLIB-compressed packets are compressed with RFC 1950 ZLIB-style + blocks. + +5.7. Symmetrically Encrypted Data Packet (Tag 9) + + The Symmetrically Encrypted Data packet contains data encrypted with + a symmetric-key algorithm. When it has been decrypted, it will + typically contain other packets (often literal data packets or + compressed data packets). + + The body of this packet consists of: + + - Encrypted data, the output of the selected symmetric-key cipher + operating in PGP's variant of Cipher Feedback (CFB) mode. + + The symmetric cipher used may be specified in an Public-Key or + Symmetric-Key Encrypted Session Key packet that precedes the + Symmetrically Encrypted Data Packet. In that case, the cipher + algorithm octet is prefixed to the session key before it is + encrypted. If no packets of these types precede the encrypted data, + the IDEA algorithm is used with the session key calculated as the MD5 + hash of the passphrase. + + The data is encrypted in CFB mode, with a CFB shift size equal to the + cipher's block size. The Initial Vector (IV) is specified as all + zeros. Instead of using an IV, OpenPGP prefixes a 10-octet string to + the data before it is encrypted. The first eight octets are random, + and the 9th and 10th octets are copies of the 7th and 8th octets, + respectively. After encrypting the first 10 octets, the CFB state is + resynchronized if the cipher block size is 8 octets or less. The + last 8 octets of ciphertext are passed through the cipher and the + block boundary is reset. + + The repetition of 16 bits in the 80 bits of random data prefixed to + the message allows the receiver to immediately check whether the + session key is incorrect. + +5.8. Marker Packet (Obsolete Literal Packet) (Tag 10) + + An experimental version of PGP used this packet as the Literal + packet, but no released version of PGP generated Literal packets with + this tag. With PGP 5.x, this packet has been re-assigned and is + reserved for use as the Marker packet. + + + +Callas, et. al. Standards Track [Page 39] + +RFC 2440 OpenPGP Message Format November 1998 + + + The body of this packet consists of: + + - The three octets 0x50, 0x47, 0x50 (which spell "PGP" in UTF-8). + + Such a packet MUST be ignored when received. It may be placed at the + beginning of a message that uses features not available in PGP 2.6.x + in order to cause that version to report that newer software is + necessary to process the message. + +5.9. Literal Data Packet (Tag 11) + + A Literal Data packet contains the body of a message; data that is + not to be further interpreted. + + The body of this packet consists of: + + - A one-octet field that describes how the data is formatted. + + If it is a 'b' (0x62), then the literal packet contains binary data. + If it is a 't' (0x74), then it contains text data, and thus may need + line ends converted to local form, or other text-mode changes. RFC + 1991 also defined a value of 'l' as a 'local' mode for machine-local + conversions. This use is now deprecated. + + - File name as a string (one-octet length, followed by file name), + if the encrypted data should be saved as a file. + + If the special name "_CONSOLE" is used, the message is considered to + be "for your eyes only". This advises that the message data is + unusually sensitive, and the receiving program should process it more + carefully, perhaps avoiding storing the received data to disk, for + example. + + - A four-octet number that indicates the modification date of the + file, or the creation time of the packet, or a zero that + indicates the present time. + + - The remainder of the packet is literal data. + + Text data is stored with text endings (i.e. network-normal + line endings). These should be converted to native line endings by + the receiving software. + +5.10. Trust Packet (Tag 12) + + The Trust packet is used only within keyrings and is not normally + exported. Trust packets contain data that record the user's + specifications of which key holders are trustworthy introducers, + + + +Callas, et. al. Standards Track [Page 40] + +RFC 2440 OpenPGP Message Format November 1998 + + + along with other information that implementing software uses for + trust information. + + Trust packets SHOULD NOT be emitted to output streams that are + transferred to other users, and they SHOULD be ignored on any input + other than local keyring files. + +5.11. User ID Packet (Tag 13) + + A User ID packet consists of data that is intended to represent the + name and email address of the key holder. By convention, it includes + an RFC 822 mail name, but there are no restrictions on its content. + The packet length in the header specifies the length of the user id. + If it is text, it is encoded in UTF-8. + +6. Radix-64 Conversions + + As stated in the introduction, OpenPGP's underlying native + representation for objects is a stream of arbitrary octets, and some + systems desire these objects to be immune to damage caused by + character set translation, data conversions, etc. + + In principle, any printable encoding scheme that met the requirements + of the unsafe channel would suffice, since it would not change the + underlying binary bit streams of the native OpenPGP data structures. + The OpenPGP standard specifies one such printable encoding scheme to + ensure interoperability. + + OpenPGP's Radix-64 encoding is composed of two parts: a base64 + encoding of the binary data, and a checksum. The base64 encoding is + identical to the MIME base64 content-transfer-encoding [RFC2231, + Section 6.8]. An OpenPGP implementation MAY use ASCII Armor to + protect the raw binary data. + + The checksum is a 24-bit CRC converted to four characters of radix-64 + encoding by the same MIME base64 transformation, preceded by an + equals sign (=). The CRC is computed by using the generator 0x864CFB + and an initialization of 0xB704CE. The accumulation is done on the + data before it is converted to radix-64, rather than on the converted + data. A sample implementation of this algorithm is in the next + section. + + The checksum with its leading equal sign MAY appear on the first line + after the Base64 encoded data. + + Rationale for CRC-24: The size of 24 bits fits evenly into printable + base64. The nonzero initialization can detect more errors than a + zero initialization. + + + +Callas, et. al. Standards Track [Page 41] + +RFC 2440 OpenPGP Message Format November 1998 + + +6.1. An Implementation of the CRC-24 in "C" + + #define CRC24_INIT 0xb704ceL + #define CRC24_POLY 0x1864cfbL + + typedef long crc24; + crc24 crc_octets(unsigned char *octets, size_t len) + { + crc24 crc = CRC24_INIT; + int i; + + while (len--) { + crc ^= (*octets++) << 16; + for (i = 0; i < 8; i++) { + crc <<= 1; + if (crc & 0x1000000) + crc ^= CRC24_POLY; + } + } + return crc & 0xffffffL; + } + +6.2. Forming ASCII Armor + + When OpenPGP encodes data into ASCII Armor, it puts specific headers + around the data, so OpenPGP can reconstruct the data later. OpenPGP + informs the user what kind of data is encoded in the ASCII armor + through the use of the headers. + + Concatenating the following data creates ASCII Armor: + + - An Armor Header Line, appropriate for the type of data + + - Armor Headers + + - A blank (zero-length, or containing only whitespace) line + + - The ASCII-Armored data + + - An Armor Checksum + + - The Armor Tail, which depends on the Armor Header Line. + + An Armor Header Line consists of the appropriate header line text + surrounded by five (5) dashes ('-', 0x2D) on either side of the + header line text. The header line text is chosen based upon the type + of data that is being encoded in Armor, and how it is being encoded. + Header line texts include the following strings: + + + +Callas, et. al. Standards Track [Page 42] + +RFC 2440 OpenPGP Message Format November 1998 + + + BEGIN PGP MESSAGE + Used for signed, encrypted, or compressed files. + + BEGIN PGP PUBLIC KEY BLOCK + Used for armoring public keys + + BEGIN PGP PRIVATE KEY BLOCK + Used for armoring private keys + + BEGIN PGP MESSAGE, PART X/Y + Used for multi-part messages, where the armor is split amongst Y + parts, and this is the Xth part out of Y. + + BEGIN PGP MESSAGE, PART X + Used for multi-part messages, where this is the Xth part of an + unspecified number of parts. Requires the MESSAGE-ID Armor Header + to be used. + + BEGIN PGP SIGNATURE + Used for detached signatures, OpenPGP/MIME signatures, and + natures following clearsigned messages. Note that PGP 2.x s BEGIN + PGP MESSAGE for detached signatures. + + The Armor Headers are pairs of strings that can give the user or the + receiving OpenPGP implementation some information about how to decode + or use the message. The Armor Headers are a part of the armor, not a + part of the message, and hence are not protected by any signatures + applied to the message. + + The format of an Armor Header is that of a key-value pair. A colon + (':' 0x38) and a single space (0x20) separate the key and value. + OpenPGP should consider improperly formatted Armor Headers to be + corruption of the ASCII Armor. Unknown keys should be reported to + the user, but OpenPGP should continue to process the message. + + Currently defined Armor Header Keys are: + + - "Version", that states the OpenPGP Version used to encode the + message. + + - "Comment", a user-defined comment. + + - "MessageID", a 32-character string of printable characters. The + string must be the same for all parts of a multi-part message + that uses the "PART X" Armor Header. MessageID strings should be + + + + + + +Callas, et. al. Standards Track [Page 43] + +RFC 2440 OpenPGP Message Format November 1998 + + + unique enough that the recipient of the mail can associate all + the parts of a message with each other. A good checksum or + cryptographic hash function is sufficient. + + - "Hash", a comma-separated list of hash algorithms used in this + message. This is used only in clear-signed messages. + + - "Charset", a description of the character set that the plaintext + is in. Please note that OpenPGP defines text to be in UTF-8 by + default. An implementation will get best results by translating + into and out of UTF-8. However, there are many instances where + this is easier said than done. Also, there are communities of + users who have no need for UTF-8 because they are all happy with + a character set like ISO Latin-5 or a Japanese character set. In + such instances, an implementation MAY override the UTF-8 default + by using this header key. An implementation MAY implement this + key and any translations it cares to; an implementation MAY + ignore it and assume all text is UTF-8. + + The MessageID SHOULD NOT appear unless it is in a multi-part + message. If it appears at all, it MUST be computed from the + finished (encrypted, signed, etc.) message in a deterministic + fashion, rather than contain a purely random value. This is to + allow the legitimate recipient to determine that the MessageID + cannot serve as a covert means of leaking cryptographic key + information. + + The Armor Tail Line is composed in the same manner as the Armor + Header Line, except the string "BEGIN" is replaced by the string + "END." + +6.3. Encoding Binary in Radix-64 + + The encoding process represents 24-bit groups of input bits as output + strings of 4 encoded characters. Proceeding from left to right, a + 24-bit input group is formed by concatenating three 8-bit input + groups. These 24 bits are then treated as four concatenated 6-bit + groups, each of which is translated into a single digit in the + Radix-64 alphabet. When encoding a bit stream with the Radix-64 + encoding, the bit stream must be presumed to be ordered with the + most-significant-bit first. That is, the first bit in the stream will + be the high-order bit in the first 8-bit octet, and the eighth bit + will be the low-order bit in the first 8-bit octet, and so on. + + + + + + + + +Callas, et. al. Standards Track [Page 44] + +RFC 2440 OpenPGP Message Format November 1998 + + + +--first octet--+-second octet--+--third octet--+ + |7 6 5 4 3 2 1 0|7 6 5 4 3 2 1 0|7 6 5 4 3 2 1 0| + +-----------+---+-------+-------+---+-----------+ + |5 4 3 2 1 0|5 4 3 2 1 0|5 4 3 2 1 0|5 4 3 2 1 0| + +--1.index--+--2.index--+--3.index--+--4.index--+ + + Each 6-bit group is used as an index into an array of 64 printable + characters from the table below. The character referenced by the + index is placed in the output string. + + Value Encoding Value Encoding Value Encoding Value Encoding + 0 A 17 R 34 i 51 z + 1 B 18 S 35 j 52 0 + 2 C 19 T 36 k 53 1 + 3 D 20 U 37 l 54 2 + 4 E 21 V 38 m 55 3 + 5 F 22 W 39 n 56 4 + 6 G 23 X 40 o 57 5 + 7 H 24 Y 41 p 58 6 + 8 I 25 Z 42 q 59 7 + 9 J 26 a 43 r 60 8 + 10 K 27 b 44 s 61 9 + 11 L 28 c 45 t 62 + + 12 M 29 d 46 u 63 / + 13 N 30 e 47 v + 14 O 31 f 48 w (pad) = + 15 P 32 g 49 x + 16 Q 33 h 50 y + + The encoded output stream must be represented in lines of no more + than 76 characters each. + + Special processing is performed if fewer than 24 bits are available + at the end of the data being encoded. There are three possibilities: + + 1. The last data group has 24 bits (3 octets). No special + processing is needed. + + 2. The last data group has 16 bits (2 octets). The first two 6-bit + groups are processed as above. The third (incomplete) data group + has two zero-value bits added to it, and is processed as above. + A pad character (=) is added to the output. + + 3. The last data group has 8 bits (1 octet). The first 6-bit group + is processed as above. The second (incomplete) data group has + four zero-value bits added to it, and is processed as above. Two + pad characters (=) are added to the output. + + + + +Callas, et. al. Standards Track [Page 45] + +RFC 2440 OpenPGP Message Format November 1998 + + +6.4. Decoding Radix-64 + + Any characters outside of the base64 alphabet are ignored in Radix-64 + data. Decoding software must ignore all line breaks or other + characters not found in the table above. + + In Radix-64 data, characters other than those in the table, line + breaks, and other white space probably indicate a transmission error, + about which a warning message or even a message rejection might be + appropriate under some circumstances. + + Because it is used only for padding at the end of the data, the + occurrence of any "=" characters may be taken as evidence that the + end of the data has been reached (without truncation in transit). No + such assurance is possible, however, when the number of octets + transmitted was a multiple of three and no "=" characters are + present. + +6.5. Examples of Radix-64 + + Input data: 0x14fb9c03d97e + Hex: 1 4 f b 9 c | 0 3 d 9 7 e + 8-bit: 00010100 11111011 10011100 | 00000011 11011001 + 11111110 + 6-bit: 000101 001111 101110 011100 | 000000 111101 100111 + 111110 + Decimal: 5 15 46 28 0 61 37 62 + Output: F P u c A 9 l + + + Input data: 0x14fb9c03d9 + Hex: 1 4 f b 9 c | 0 3 d 9 + 8-bit: 00010100 11111011 10011100 | 00000011 11011001 + pad with 00 + 6-bit: 000101 001111 101110 011100 | 000000 111101 100100 + Decimal: 5 15 46 28 0 61 36 + pad with = + Output: F P u c A 9 k = + + Input data: 0x14fb9c03 + Hex: 1 4 f b 9 c | 0 3 + 8-bit: 00010100 11111011 10011100 | 00000011 + pad with 0000 + 6-bit: 000101 001111 101110 011100 | 000000 110000 + Decimal: 5 15 46 28 0 48 + pad with = = + Output: F P u c A w = = + + + + + +Callas, et. al. Standards Track [Page 46] + +RFC 2440 OpenPGP Message Format November 1998 + + +6.6. Example of an ASCII Armored Message + + + -----BEGIN PGP MESSAGE----- + Version: OpenPrivacy 0.99 + + yDgBO22WxBHv7O8X7O/jygAEzol56iUKiXmV+XmpCtmpqQUKiQrFqclFqUDBovzS + vBSFjNSiVHsuAA== + =njUN + -----END PGP MESSAGE----- + + Note that this example is indented by two spaces. + +7. Cleartext signature framework + + It is desirable to sign a textual octet stream without ASCII armoring + the stream itself, so the signed text is still readable without + special software. In order to bind a signature to such a cleartext, + this framework is used. (Note that RFC 2015 defines another way to + clear sign messages for environments that support MIME.) + + The cleartext signed message consists of: + + - The cleartext header '-----BEGIN PGP SIGNED MESSAGE-----' on a + single line, + + - One or more "Hash" Armor Headers, + + - Exactly one empty line not included into the message digest, + + - The dash-escaped cleartext that is included into the message + digest, + + - The ASCII armored signature(s) including the '-----BEGIN PGP + SIGNATURE-----' Armor Header and Armor Tail Lines. + + If the "Hash" armor header is given, the specified message digest + algorithm is used for the signature. If there are no such headers, + MD5 is used, an implementation MAY omit them for V2.x compatibility. + If more than one message digest is used in the signature, the "Hash" + armor header contains a comma-delimited list of used message digests. + + Current message digest names are described below with the algorithm + IDs. + +7.1. Dash-Escaped Text + + The cleartext content of the message must also be dash-escaped. + + + +Callas, et. al. Standards Track [Page 47] + +RFC 2440 OpenPGP Message Format November 1998 + + + Dash escaped cleartext is the ordinary cleartext where every line + starting with a dash '-' (0x2D) is prefixed by the sequence dash '-' + (0x2D) and space ' ' (0x20). This prevents the parser from + recognizing armor headers of the cleartext itself. The message digest + is computed using the cleartext itself, not the dash escaped form. + + As with binary signatures on text documents, a cleartext signature is + calculated on the text using canonical line endings. The + line ending (i.e. the ) before the '-----BEGIN PGP + SIGNATURE-----' line that terminates the signed text is not + considered part of the signed text. + + Also, any trailing whitespace (spaces, and tabs, 0x09) at the end of + any line is ignored when the cleartext signature is calculated. + +8. Regular Expressions + + A regular expression is zero or more branches, separated by '|'. It + matches anything that matches one of the branches. + + A branch is zero or more pieces, concatenated. It matches a match for + the first, followed by a match for the second, etc. + + A piece is an atom possibly followed by '*', '+', or '?'. An atom + followed by '*' matches a sequence of 0 or more matches of the atom. + An atom followed by '+' matches a sequence of 1 or more matches of + the atom. An atom followed by '?' matches a match of the atom, or the + null string. + + An atom is a regular expression in parentheses (matching a match for + the regular expression), a range (see below), '.' (matching any + single character), '^' (matching the null string at the beginning of + the input string), '$' (matching the null string at the end of the + input string), a '\' followed by a single character (matching that + character), or a single character with no other significance + (matching that character). + + A range is a sequence of characters enclosed in '[]'. It normally + matches any single character from the sequence. If the sequence + begins with '^', it matches any single character not from the rest of + the sequence. If two characters in the sequence are separated by '-', + this is shorthand for the full list of ASCII characters between them + (e.g. '[0-9]' matches any decimal digit). To include a literal ']' in + the sequence, make it the first character (following a possible '^'). + To include a literal '-', make it the first or last character. + + + + + + +Callas, et. al. Standards Track [Page 48] + +RFC 2440 OpenPGP Message Format November 1998 + + +9. Constants + + This section describes the constants used in OpenPGP. + + Note that these tables are not exhaustive lists; an implementation + MAY implement an algorithm not on these lists. + + See the section "Notes on Algorithms" below for more discussion of + the algorithms. + +9.1. Public Key Algorithms + + ID Algorithm + -- --------- + 1 - RSA (Encrypt or Sign) + 2 - RSA Encrypt-Only + 3 - RSA Sign-Only + 16 - Elgamal (Encrypt-Only), see [ELGAMAL] + 17 - DSA (Digital Signature Standard) + 18 - Reserved for Elliptic Curve + 19 - Reserved for ECDSA + 20 - Elgamal (Encrypt or Sign) + + + + + + 21 - Reserved for Diffie-Hellman (X9.42, + as defined for IETF-S/MIME) + 100 to 110 - Private/Experimental algorithm. + + Implementations MUST implement DSA for signatures, and Elgamal for + encryption. Implementations SHOULD implement RSA keys. + Implementations MAY implement any other algorithm. + +9.2. Symmetric Key Algorithms + + ID Algorithm + -- --------- + 0 - Plaintext or unencrypted data + 1 - IDEA [IDEA] + 2 - Triple-DES (DES-EDE, as per spec - + 168 bit key derived from 192) + 3 - CAST5 (128 bit key, as per RFC 2144) + 4 - Blowfish (128 bit key, 16 rounds) [BLOWFISH] + 5 - SAFER-SK128 (13 rounds) [SAFER] + 6 - Reserved for DES/SK + 7 - Reserved for AES with 128-bit key + + + +Callas, et. al. Standards Track [Page 49] + +RFC 2440 OpenPGP Message Format November 1998 + + + 8 - Reserved for AES with 192-bit key + 9 - Reserved for AES with 256-bit key + 100 to 110 - Private/Experimental algorithm. + + Implementations MUST implement Triple-DES. Implementations SHOULD + implement IDEA and CAST5.Implementations MAY implement any other + algorithm. + +9.3. Compression Algorithms + + ID Algorithm + -- --------- + 0 - Uncompressed + 1 - ZIP (RFC 1951) + 2 - ZLIB (RFC 1950) + 100 to 110 - Private/Experimental algorithm. + + Implementations MUST implement uncompressed data. Implementations + SHOULD implement ZIP. Implementations MAY implement ZLIB. + +9.4. Hash Algorithms + + ID Algorithm Text Name + -- --------- ---- ---- + 1 - MD5 "MD5" + 2 - SHA-1 "SHA1" + 3 - RIPE-MD/160 "RIPEMD160" + 4 - Reserved for double-width SHA (experimental) + 5 - MD2 "MD2" + 6 - Reserved for TIGER/192 "TIGER192" + 7 - Reserved for HAVAL (5 pass, 160-bit) + "HAVAL-5-160" + 100 to 110 - Private/Experimental algorithm. + + Implementations MUST implement SHA-1. Implementations SHOULD + implement MD5. + +10. Packet Composition + + OpenPGP packets are assembled into sequences in order to create + messages and to transfer keys. Not all possible packet sequences are + meaningful and correct. This describes the rules for how packets + should be placed into sequences. + +10.1. Transferable Public Keys + + OpenPGP users may transfer public keys. The essential elements of a + transferable public key are: + + + +Callas, et. al. Standards Track [Page 50] + +RFC 2440 OpenPGP Message Format November 1998 + + + - One Public Key packet + + - Zero or more revocation signatures + + - One or more User ID packets + + - After each User ID packet, zero or more signature packets + (certifications) + + - Zero or more Subkey packets + + - After each Subkey packet, one signature packet, optionally a + revocation. + + The Public Key packet occurs first. Each of the following User ID + packets provides the identity of the owner of this public key. If + there are multiple User ID packets, this corresponds to multiple + means of identifying the same unique individual user; for example, a + user may have more than one email address, and construct a User ID + for each one. + + Immediately following each User ID packet, there are zero or more + signature packets. Each signature packet is calculated on the + immediately preceding User ID packet and the initial Public Key + packet. The signature serves to certify the corresponding public key + and user ID. In effect, the signer is testifying to his or her + belief that this public key belongs to the user identified by this + user ID. + + After the User ID packets there may be one or more Subkey packets. + In general, subkeys are provided in cases where the top-level public + key is a signature-only key. However, any V4 key may have subkeys, + and the subkeys may be encryption-only keys, signature-only keys, or + general-purpose keys. + + Each Subkey packet must be followed by one Signature packet, which + should be a subkey binding signature issued by the top level key. + + Subkey and Key packets may each be followed by a revocation Signature + packet to indicate that the key is revoked. Revocation signatures + are only accepted if they are issued by the key itself, or by a key + that is authorized to issue revocations via a revocation key + subpacket in a self-signature by the top level key. + + Transferable public key packet sequences may be concatenated to allow + transferring multiple public keys in one operation. + + + + + +Callas, et. al. Standards Track [Page 51] + +RFC 2440 OpenPGP Message Format November 1998 + + +10.2. OpenPGP Messages + + An OpenPGP message is a packet or sequence of packets that + corresponds to the following grammatical rules (comma represents + sequential composition, and vertical bar separates alternatives): + + OpenPGP Message :- Encrypted Message | Signed Message | + Compressed Message | Literal Message. + + Compressed Message :- Compressed Data Packet. + + Literal Message :- Literal Data Packet. + + ESK :- Public Key Encrypted Session Key Packet | + Symmetric-Key Encrypted Session Key Packet. + + ESK Sequence :- ESK | ESK Sequence, ESK. + + Encrypted Message :- Symmetrically Encrypted Data Packet | + ESK Sequence, Symmetrically Encrypted Data Packet. + + One-Pass Signed Message :- One-Pass Signature Packet, + OpenPGP Message, Corresponding Signature Packet. + + Signed Message :- Signature Packet, OpenPGP Message | + One-Pass Signed Message. + + In addition, decrypting a Symmetrically Encrypted Data packet and + + decompressing a Compressed Data packet must yield a valid OpenPGP + Message. + +10.3. Detached Signatures + + Some OpenPGP applications use so-called "detached signatures." For + example, a program bundle may contain a file, and with it a second + file that is a detached signature of the first file. These detached + signatures are simply a signature packet stored separately from the + data that they are a signature of. + +11. Enhanced Key Formats + +11.1. Key Structures + + The format of an OpenPGP V3 key is as follows. Entries in square + brackets are optional and ellipses indicate repetition. + + + + + +Callas, et. al. Standards Track [Page 52] + +RFC 2440 OpenPGP Message Format November 1998 + + + RSA Public Key + [Revocation Self Signature] + User ID [Signature ...] + [User ID [Signature ...] ...] + + Each signature certifies the RSA public key and the preceding user + ID. The RSA public key can have many user IDs and each user ID can + have many signatures. + + The format of an OpenPGP V4 key that uses two public keys is similar + except that the other keys are added to the end as 'subkeys' of the + primary key. + + Primary-Key + [Revocation Self Signature] + [Direct Key Self Signature...] + User ID [Signature ...] + [User ID [Signature ...] ...] + [[Subkey [Binding-Signature-Revocation] + Primary-Key-Binding-Signature] ...] + + A subkey always has a single signature after it that is issued using + the primary key to tie the two keys together. This binding signature + may be in either V3 or V4 format, but V4 is preferred, of course. + + In the above diagram, if the binding signature of a subkey has been + revoked, the revoked binding signature may be removed, leaving only + one signature. + + In a key that has a main key and subkeys, the primary key MUST be a + key capable of signing. The subkeys may be keys of any other type. + There may be other constructions of V4 keys, too. For example, there + may be a single-key RSA key in V4 format, a DSA primary key with an + RSA encryption key, or RSA primary key with an Elgamal subkey, etc. + + It is also possible to have a signature-only subkey. This permits a + primary key that collects certifications (key signatures) but is used + only used for certifying subkeys that are used for encryption and + signatures. + +11.2. Key IDs and Fingerprints + + For a V3 key, the eight-octet key ID consists of the low 64 bits of + the public modulus of the RSA key. + + The fingerprint of a V3 key is formed by hashing the body (but not + the two-octet length) of the MPIs that form the key material (public + modulus n, followed by exponent e) with MD5. + + + +Callas, et. al. Standards Track [Page 53] + +RFC 2440 OpenPGP Message Format November 1998 + + + A V4 fingerprint is the 160-bit SHA-1 hash of the one-octet Packet + Tag, followed by the two-octet packet length, followed by the entire + Public Key packet starting with the version field. The key ID is the + low order 64 bits of the fingerprint. Here are the fields of the + hash material, with the example of a DSA key: + + a.1) 0x99 (1 octet) + + a.2) high order length octet of (b)-(f) (1 octet) + + a.3) low order length octet of (b)-(f) (1 octet) + + b) version number = 4 (1 octet); + + c) time stamp of key creation (4 octets); + + d) algorithm (1 octet): 17 = DSA (example); + + e) Algorithm specific fields. + + Algorithm Specific Fields for DSA keys (example): + + e.1) MPI of DSA prime p; + + e.2) MPI of DSA group order q (q is a prime divisor of p-1); + + e.3) MPI of DSA group generator g; + + e.4) MPI of DSA public key value y (= g**x where x is secret). + + Note that it is possible for there to be collisions of key IDs -- two + different keys with the same key ID. Note that there is a much + smaller, but still non-zero probability that two different keys have + the same fingerprint. + + Also note that if V3 and V4 format keys share the same RSA key + material, they will have different key ids as well as different + fingerprints. + +12. Notes on Algorithms + +12.1. Symmetric Algorithm Preferences + + The symmetric algorithm preference is an ordered list of algorithms + that the keyholder accepts. Since it is found on a self-signature, it + is possible that a keyholder may have different preferences. For + example, Alice may have TripleDES only specified for "alice@work.com" + but CAST5, Blowfish, and TripleDES specified for "alice@home.org". + + + +Callas, et. al. Standards Track [Page 54] + +RFC 2440 OpenPGP Message Format November 1998 + + + Note that it is also possible for preferences to be in a subkey's + binding signature. + + Since TripleDES is the MUST-implement algorithm, if it is not + explicitly in the list, it is tacitly at the end. However, it is good + form to place it there explicitly. Note also that if an + implementation does not implement the preference, then it is + implicitly a TripleDES-only implementation. + + An implementation MUST not use a symmetric algorithm that is not in + the recipient's preference list. When encrypting to more than one + recipient, the implementation finds a suitable algorithm by taking + the intersection of the preferences of the recipients. Note that the + MUST-implement algorithm, TripleDES, ensures that the intersection is + not null. The implementation may use any mechanism to pick an + algorithm in the intersection. + + If an implementation can decrypt a message that a keyholder doesn't + have in their preferences, the implementation SHOULD decrypt the + message anyway, but MUST warn the keyholder than protocol has been + violated. (For example, suppose that Alice, above, has software that + implements all algorithms in this specification. Nonetheless, she + prefers subsets for work or home. If she is sent a message encrypted + with IDEA, which is not in her preferences, the software warns her + that someone sent her an IDEA-encrypted message, but it would ideally + decrypt it anyway.) + + An implementation that is striving for backward compatibility MAY + consider a V3 key with a V3 self-signature to be an implicit + preference for IDEA, and no ability to do TripleDES. This is + technically non-compliant, but an implementation MAY violate the + above rule in this case only and use IDEA to encrypt the message, + provided that the message creator is warned. Ideally, though, the + implementation would follow the rule by actually generating two + messages, because it is possible that the OpenPGP user's + implementation does not have IDEA, and thus could not read the + message. Consequently, an implementation MAY, but SHOULD NOT use IDEA + in an algorithm conflict with a V3 key. + +12.2. Other Algorithm Preferences + + Other algorithm preferences work similarly to the symmetric algorithm + preference, in that they specify which algorithms the keyholder + accepts. There are two interesting cases that other comments need to + be made about, though, the compression preferences and the hash + preferences. + + + + + +Callas, et. al. Standards Track [Page 55] + +RFC 2440 OpenPGP Message Format November 1998 + + +12.2.1. Compression Preferences + + Compression has been an integral part of PGP since its first days. + OpenPGP and all previous versions of PGP have offered compression. + And in this specification, the default is for messages to be + compressed, although an implementation is not required to do so. + Consequently, the compression preference gives a way for a keyholder + to request that messages not be compressed, presumably because they + are using a minimal implementation that does not include compression. + Additionally, this gives a keyholder a way to state that it can + support alternate algorithms. + + Like the algorithm preferences, an implementation MUST NOT use an + algorithm that is not in the preference vector. If the preferences + are not present, then they are assumed to be [ZIP(1), + UNCOMPRESSED(0)]. + +12.2.2. Hash Algorithm Preferences + + Typically, the choice of a hash algorithm is something the signer + does, rather than the verifier, because a signer does not typically + know who is going to be verifying the signature. This preference, + though, allows a protocol based upon digital signatures ease in + negotiation. + + Thus, if Alice is authenticating herself to Bob with a signature, it + makes sense for her to use a hash algorithm that Bob's software uses. + This preference allows Bob to state in his key which algorithms Alice + may use. + +12.3. Plaintext + + Algorithm 0, "plaintext", may only be used to denote secret keys that + are stored in the clear. Implementations must not use plaintext in + Symmetrically Encrypted Data Packets; they must use Literal Data + Packets to encode unencrypted or literal data. + +12.4. RSA + + There are algorithm types for RSA-signature-only, and RSA-encrypt- + only keys. These types are deprecated. The "key flags" subpacket in a + signature is a much better way to express the same idea, and + generalizes it to all algorithms. An implementation SHOULD NOT create + such a key, but MAY interpret it. + + An implementation SHOULD NOT implement RSA keys of size less than 768 + bits. + + + + +Callas, et. al. Standards Track [Page 56] + +RFC 2440 OpenPGP Message Format November 1998 + + + It is permissible for an implementation to support RSA merely for + backward compatibility; for example, such an implementation would + support V3 keys with IDEA symmetric cryptography. Note that this is + an exception to the other MUST-implement rules. An implementation + that supports RSA in V4 keys MUST implement the MUST-implement + features. + +12.5. Elgamal + + If an Elgamal key is to be used for both signing and encryption, + extra care must be taken in creating the key. + + An ElGamal key consists of a generator g, a prime modulus p, a secret + exponent x, and a public value y = g^x mod p. + + The generator and prime must be chosen so that solving the discrete + log problem is intractable. The group g should generate the + multiplicative group mod p-1 or a large subgroup of it, and the order + of g should have at least one large prime factor. A good choice is + to use a "strong" Sophie-Germain prime in choosing p, so that both p + and (p-1)/2 are primes. In fact, this choice is so good that + implementors SHOULD do it, as it avoids a small subgroup attack. + + In addition, a result of Bleichenbacher [BLEICHENBACHER] shows that + if the generator g has only small prime factors, and if g divides the + order of the group it generates, then signatures can be forged. In + particular, choosing g=2 is a bad choice if the group order may be + even. On the other hand, a generator of 2 is a fine choice for an + encryption-only key, as this will make the encryption faster. + + While verifying Elgamal signatures, note that it is important to test + that r and s are less than p. If this test is not done then + signatures can be trivially forged by using large r values of + approximately twice the length of p. This attack is also discussed + in the Bleichenbacher paper. + + Details on safe use of Elgamal signatures may be found in [MENEZES], + which discusses all the weaknesses described above. + + If an implementation allows Elgamal signatures, then it MUST use the + algorithm identifier 20 for an Elgamal public key that can sign. + + An implementation SHOULD NOT implement Elgamal keys of size less than + 768 bits. For long-term security, Elgamal keys should be 1024 bits or + longer. + + + + + + +Callas, et. al. Standards Track [Page 57] + +RFC 2440 OpenPGP Message Format November 1998 + + +12.6. DSA + + An implementation SHOULD NOT implement DSA keys of size less than 768 + bits. Note that present DSA is limited to a maximum of 1024 bit keys, + which are recommended for long-term use. + +12.7. Reserved Algorithm Numbers + + A number of algorithm IDs have been reserved for algorithms that + would be useful to use in an OpenPGP implementation, yet there are + issues that prevent an implementor from actually implementing the + algorithm. These are marked in the Public Algorithms section as + "(reserved for)". + + The reserved public key algorithms, Elliptic Curve (18), ECDSA (19), + and X9.42 (21) do not have the necessary parameters, parameter order, + or semantics defined. + + The reserved symmetric key algorithm, DES/SK (6), does not have + semantics defined. + + The reserved hash algorithms, TIGER192 (6), and HAVAL-5-160 (7), do + not have OIDs. The reserved algorithm number 4, reserved for a + double-width variant of SHA1, is not presently defined. + + We have reserver three algorithm IDs for the US NIST's Advanced + Encryption Standard. This algorithm will work with (at least) 128, + 192, and 256-bit keys. We expect that this algorithm will be selected + from the candidate algorithms in the year 2000. + +12.8. OpenPGP CFB mode + + OpenPGP does symmetric encryption using a variant of Cipher Feedback + Mode (CFB mode). This section describes the procedure it uses in + detail. This mode is what is used for Symmetrically Encrypted Data + Packets; the mechanism used for encrypting secret key material is + similar, but described in those sections above. + + OpenPGP CFB mode uses an initialization vector (IV) of all zeros, and + prefixes the plaintext with ten octets of random data, such that + octets 9 and 10 match octets 7 and 8. It does a CFB "resync" after + encrypting those ten octets. + + Note that for an algorithm that has a larger block size than 64 bits, + the equivalent function will be done with that entire block. For + example, a 16-octet block algorithm would operate on 16 octets, and + then produce two octets of check, and then work on 16-octet blocks. + + + + +Callas, et. al. Standards Track [Page 58] + +RFC 2440 OpenPGP Message Format November 1998 + + + Step by step, here is the procedure: + + 1. The feedback register (FR) is set to the IV, which is all zeros. + + 2. FR is encrypted to produce FRE (FR Encrypted). This is the + encryption of an all-zero value. + + 3. FRE is xored with the first 8 octets of random data prefixed to + the plaintext to produce C1-C8, the first 8 octets of ciphertext. + + 4. FR is loaded with C1-C8. + + 5. FR is encrypted to produce FRE, the encryption of the first 8 + octets of ciphertext. + + 6. The left two octets of FRE get xored with the next two octets of + data that were prefixed to the plaintext. This produces C9-C10, + the next two octets of ciphertext. + + 7. (The resync step) FR is loaded with C3-C10. + + 8. FR is encrypted to produce FRE. + + 9. FRE is xored with the first 8 octets of the given plaintext, now + that we have finished encrypting the 10 octets of prefixed data. + This produces C11-C18, the next 8 octets of ciphertext. + + 10. FR is loaded with C11-C18 + + 11. FR is encrypted to produce FRE. + + 12. FRE is xored with the next 8 octets of plaintext, to produce the + next 8 octets of ciphertext. These are loaded into FR and the + process is repeated until the plaintext is used up. + +13. Security Considerations + + As with any technology involving cryptography, you should check the + current literature to determine if any algorithms used here have been + found to be vulnerable to attack. + + This specification uses Public Key Cryptography technologies. + Possession of the private key portion of a public-private key pair is + assumed to be controlled by the proper party or parties. + + Certain operations in this specification involve the use of random + numbers. An appropriate entropy source should be used to generate + these numbers. See RFC 1750. + + + +Callas, et. al. Standards Track [Page 59] + +RFC 2440 OpenPGP Message Format November 1998 + + + The MD5 hash algorithm has been found to have weaknesses (pseudo- + collisions in the compress function) that make some people deprecate + its use. They consider the SHA-1 algorithm better. + + Many security protocol designers think that it is a bad idea to use a + single key for both privacy (encryption) and integrity (signatures). + In fact, this was one of the motivating forces behind the V4 key + format with separate signature and encryption keys. If you as an + implementor promote dual-use keys, you should at least be aware of + this controversy. + + The DSA algorithm will work with any 160-bit hash, but it is + sensitive to the quality of the hash algorithm, if the hash algorithm + is broken, it can leak the secret key. The Digital Signature Standard + (DSS) specifies that DSA be used with SHA-1. RIPEMD-160 is + considered by many cryptographers to be as strong. An implementation + should take care which hash algorithms are used with DSA, as a weak + hash can not only allow a signature to be forged, but could leak the + secret key. These same considerations about the quality of the hash + algorithm apply to Elgamal signatures. + + If you are building an authentication system, the recipient may + specify a preferred signing algorithm. However, the signer would be + foolish to use a weak algorithm simply because the recipient requests + it. + + Some of the encryption algorithms mentioned in this document have + been analyzed less than others. For example, although CAST5 is + presently considered strong, it has been analyzed less than Triple- + DES. Other algorithms may have other controversies surrounding them. + + Some technologies mentioned here may be subject to government control + in some countries. + +14. Implementation Nits + + This section is a collection of comments to help an implementer, + particularly with an eye to backward compatibility. Previous + implementations of PGP are not OpenPGP-compliant. Often the + differences are small, but small differences are frequently more + vexing than large differences. Thus, this list of potential problems + and gotchas for a developer who is trying to be backward-compatible. + + * PGP 5.x does not accept V4 signatures for anything other than + key material. + + * PGP 5.x does not recognize the "five-octet" lengths in new-format + headers or in signature subpacket lengths. + + + +Callas, et. al. Standards Track [Page 60] + +RFC 2440 OpenPGP Message Format November 1998 + + + * PGP 5.0 rejects an encrypted session key if the keylength differs + from the S2K symmetric algorithm. This is a bug in its validation + function. + + * PGP 5.0 does not handle multiple one-pass signature headers and + trailers. Signing one will compress the one-pass signed literal + and prefix a V3 signature instead of doing a nested one-pass + signature. + + * When exporting a private key, PGP 2.x generates the header "BEGIN + PGP SECRET KEY BLOCK" instead of "BEGIN PGP PRIVATE KEY BLOCK". + All previous versions ignore the implied data type, and look + directly at the packet data type. + + * In a clear-signed signature, PGP 5.0 will figure out the correct + hash algorithm if there is no "Hash:" header, but it will reject + a mismatch between the header and the actual algorithm used. The + "standard" (i.e. Zimmermann/Finney/et al.) version of PGP 2.x + rejects the "Hash:" header and assumes MD5. There are a number of + enhanced variants of PGP 2.6.x that have been modified for SHA-1 + signatures. + + * PGP 5.0 can read an RSA key in V4 format, but can only recognize + it with a V3 keyid, and can properly use only a V3 format RSA + key. + + * Neither PGP 5.x nor PGP 6.0 recognize Elgamal Encrypt and Sign + keys. They only handle Elgamal Encrypt-only keys. + + * There are many ways possible for two keys to have the same key + material, but different fingerprints (and thus key ids). Perhaps + the most interesting is an RSA key that has been "upgraded" to V4 + format, but since a V4 fingerprint is constructed by hashing the + key creation time along with other things, two V4 keys created at + different times, yet with the same key material will have + different fingerprints. + + * If an implementation is using zlib to interoperate with PGP 2.x, + then the "windowBits" parameter should be set to -13. + + + + + + + + + + + + +Callas, et. al. Standards Track [Page 61] + +RFC 2440 OpenPGP Message Format November 1998 + + +15. Authors and Working Group Chair + + The working group can be contacted via the current chair: + + John W. Noerenberg, II + Qualcomm, Inc + 6455 Lusk Blvd + San Diego, CA 92131 USA + + Phone: +1 619-658-3510 + EMail: jwn2@qualcomm.com + + + The principal authors of this memo are: + + Jon Callas + Network Associates, Inc. + 3965 Freedom Circle + Santa Clara, CA 95054, USA + + Phone: +1 408-346-5860 + EMail: jon@pgp.com, jcallas@nai.com + + + Lutz Donnerhacke + IKS GmbH + Wildenbruchstr. 15 + 07745 Jena, Germany + + Phone: +49-3641-675642 + EMail: lutz@iks-jena.de + + + Hal Finney + Network Associates, Inc. + 3965 Freedom Circle + Santa Clara, CA 95054, USA + + EMail: hal@pgp.com + + + Rodney Thayer + EIS Corporation + Clearwater, FL 33767, USA + + EMail: rodney@unitran.com + + + + + +Callas, et. al. Standards Track [Page 62] + +RFC 2440 OpenPGP Message Format November 1998 + + + This memo also draws on much previous work from a number of other + authors who include: Derek Atkins, Charles Breed, Dave Del Torto, + Marc Dyksterhouse, Gail Haspert, Gene Hoffman, Paul Hoffman, Raph + Levien, Colin Plumb, Will Price, William Stallings, Mark Weaver, and + Philip R. Zimmermann. + +16. References + + [BLEICHENBACHER] Bleichenbacher, Daniel, "Generating ElGamal + signatures without knowing the secret key," + Eurocrypt 96. Note that the version in the + proceedings has an error. A revised version is + available at the time of writing from + + + [BLOWFISH] Schneier, B. "Description of a New Variable-Length + Key, 64-Bit Block Cipher (Blowfish)" Fast Software + Encryption, Cambridge Security Workshop Proceedings + (December 1993), Springer-Verlag, 1994, pp191-204 + + + + [DONNERHACKE] Donnerhacke, L., et. al, "PGP263in - an improved + international version of PGP", ftp://ftp.iks- + jena.de/mitarb/lutz/crypt/software/pgp/ + + [ELGAMAL] T. ElGamal, "A Public-Key Cryptosystem and a + Signature Scheme Based on Discrete Logarithms," IEEE + Transactions on Information Theory, v. IT-31, n. 4, + 1985, pp. 469-472. + + [IDEA] Lai, X, "On the design and security of block + ciphers", ETH Series in Information Processing, J.L. + Massey (editor), Vol. 1, Hartung-Gorre Verlag + Knostanz, Technische Hochschule (Zurich), 1992 + + [ISO-10646] ISO/IEC 10646-1:1993. International Standard -- + Information technology -- Universal Multiple-Octet + Coded Character Set (UCS) -- Part 1: Architecture + and Basic Multilingual Plane. UTF-8 is described in + Annex R, adopted but not yet published. UTF-16 is + described in Annex Q, adopted but not yet published. + + [MENEZES] Alfred Menezes, Paul van Oorschot, and Scott + Vanstone, "Handbook of Applied Cryptography," CRC + Press, 1996. + + + + +Callas, et. al. Standards Track [Page 63] + +RFC 2440 OpenPGP Message Format November 1998 + + + [RFC822] Crocker, D., "Standard for the format of ARPA + Internet text messages", STD 11, RFC 822, August + 1982. + + [RFC1423] Balenson, D., "Privacy Enhancement for Internet + Electronic Mail: Part III: Algorithms, Modes, and + Identifiers", RFC 1423, October 1993. + + [RFC1641] Goldsmith, D. and M. Davis, "Using Unicode with + MIME", RFC 1641, July 1994. + + [RFC1750] Eastlake, D., Crocker, S. and J. Schiller, + "Randomness Recommendations for Security", RFC 1750, + December 1994. + + [RFC1951] Deutsch, P., "DEFLATE Compressed Data Format + Specification version 1.3.", RFC 1951, May 1996. + + [RFC1983] Malkin, G., "Internet Users' Glossary", FYI 18, RFC + 1983, August 1996. + + [RFC1991] Atkins, D., Stallings, W. and P. Zimmermann, "PGP + Message Exchange Formats", RFC 1991, August 1996. + + [RFC2015] Elkins, M., "MIME Security with Pretty Good Privacy + (PGP)", RFC 2015, October 1996. + + [RFC2231] Borenstein, N. and N. Freed, "Multipurpose Internet + Mail Extensions (MIME) Part One: Format of Internet + Message Bodies.", RFC 2231, November 1996. + + [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate + Requirement Level", BCP 14, RFC 2119, March 1997. + + [RFC2144] Adams, C., "The CAST-128 Encryption Algorithm", RFC + 2144, May 1997. + + [RFC2279] Yergeau., F., "UTF-8, a transformation format of + Unicode and ISO 10646", RFC 2279, January 1998. + + [RFC2313] Kaliski, B., "PKCS #1: RSA Encryption Standard + version 1.5", RFC 2313, March 1998. + + [SAFER] Massey, J.L. "SAFER K-64: One Year Later", B. + Preneel, editor, Fast Software Encryption, Second + International Workshop (LNCS 1008) pp212-241, + Springer-Verlag 1995 + + + + +Callas, et. al. Standards Track [Page 64] + +RFC 2440 OpenPGP Message Format November 1998 + + +17. Full Copyright Statement + + Copyright (C) The Internet Society (1998). All Rights Reserved. + + This document and translations of it may be copied and furnished to + others, and derivative works that comment on or otherwise explain it + or assist in its implementation may be prepared, copied, published + and distributed, in whole or in part, without restriction of any + kind, provided that the above copyright notice and this paragraph are + included on all such copies and derivative works. However, this + document itself may not be modified in any way, such as by removing + the copyright notice or references to the Internet Society or other + Internet organizations, except as needed for the purpose of + developing Internet standards in which case the procedures for + copyrights defined in the Internet Standards process must be + followed, or as required to translate it into languages other than + English. + + The limited permissions granted above are perpetual and will not be + revoked by the Internet Society or its successors or assigns. + + This document and the information contained herein is provided on an + "AS IS" basis and THE INTERNET SOCIETY AND THE INTERNET ENGINEERING + TASK FORCE DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING + BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION + HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF + MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + + + + + + + + + + + + + + + + + + + + + + + + +Callas, et. al. Standards Track [Page 65] + diff --git a/vendor/swiftmailer/swiftmailer/notes/rfc/rfc2487.txt b/vendor/swiftmailer/swiftmailer/notes/rfc/rfc2487.txt new file mode 100755 index 0000000..fb1305f --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/notes/rfc/rfc2487.txt @@ -0,0 +1,451 @@ + + + + + + +Network Working Group P. Hoffman +Request for Comments: 2487 Internet Mail Consortium +Category: Standards Track January 1999 + + + SMTP Service Extension for Secure SMTP over TLS + +Status of this Memo + + This document specifies an Internet standards track protocol for the + Internet community, and requests discussion and suggestions for + improvements. Please refer to the current edition of the "Internet + Official Protocol Standards" (STD 1) for the standardization state + and status of this protocol. Distribution of this memo is unlimited. + +Copyright Notice + + Copyright (C) The Internet Society (1999). All Rights Reserved. + +1. Abstract + + This document describes an extension to the SMTP service that allows + an SMTP server and client to use transport-layer security to provide + private, authenticated communication over the Internet. This gives + SMTP agents the ability to protect some or all of their + communications from eavesdroppers and attackers. + +2. Introduction + + SMTP [RFC-821] servers and clients normally communicate in the clear + over the Internet. In many cases, this communication goes through one + or more router that is not controlled or trusted by either entity. + Such an untrusted router might allow a third party to monitor or + alter the communications between the server and client. + + Further, there is often a desire for two SMTP agents to be able to + authenticate each others' identities. For example, a secure SMTP + server might only allow communications from other SMTP agents it + knows, or it might act differently for messages received from an + agent it knows than from one it doesn't know. + + TLS [TLS], more commonly known as SSL, is a popular mechanism for + enhancing TCP communications with privacy and authentication. TLS is + in wide use with the HTTP protocol, and is also being used for adding + security to many other common protocols that run over TCP. + + + + + + +Hoffman Standards Track [Page 1] + +RFC 2487 SMTP Service Extension January 1999 + + +2.1 Terminology + + The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", + "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this + document are to be interpreted as described in [RFC-2119]. + +3. STARTTLS Extension + + The STARTTLS extension to SMTP is laid out as follows: + + (1) the name of the SMTP service defined here is STARTTLS; + + (2) the EHLO keyword value associated with the extension is STARTTLS; + + (3) the STARTTLS keyword has no parameters; + + (4) a new SMTP verb, "STARTTLS", is defined; + + (5) no additional parameters are added to any SMTP command. + +4. The STARTTLS Keyword + + The STARTTLS keyword is used to tell the SMTP client that the SMTP + server allows use of TLS. It takes no parameters. + +5. The STARTTLS Command + + The format for the STARTTLS command is: + + STARTTLS + + with no parameters. + + After the client gives the STARTTLS command, the server responds with + one of the following reply codes: + + 220 Ready to start TLS + 501 Syntax error (no parameters allowed) + 454 TLS not available due to temporary reason + + A publicly-referenced SMTP server MUST NOT require use of the + STARTTLS extension in order to deliver mail locally. This rule + prevents the STARTTLS extension from damaging the interoperability of + the Internet's SMTP infrastructure. A publicly-referenced SMTP server + is an SMTP server which runs on port 25 of an Internet host listed in + the MX record (or A record if an MX record is not present) for the + domain name on the right hand side of an Internet mail address. + + + + +Hoffman Standards Track [Page 2] + +RFC 2487 SMTP Service Extension January 1999 + + + Any SMTP server may refuse to accept messages for relay based on + authentication supplied during the TLS negotiation. An SMTP server + that is not publicly referenced may refuse to accept any messages for + relay or local delivery based on authentication supplied during the + TLS negotiation. + + A SMTP server that is not publicly referenced may choose to require + that the client perform a TLS negotiation before accepting any + commands. In this case, the server SHOULD return the reply code: + + 530 Must issue a STARTTLS command first + + to every command other than NOOP, EHLO, STARTTLS, or QUIT. If the + client and server are using the ENHANCEDSTATUSCODES ESMTP extension + [RFC-2034], the status code to be returned SHOULD be 5.7.0. + + After receiving a 220 response to a STARTTLS command, the client + SHOULD start the TLS negotiation before giving any other SMTP + commands. + + If the SMTP client is using pipelining as defined in RFC 1854, the + STARTTLS command must be the last command in a group. + +5.1 Processing After the STARTTLS Command + + After the TLS handshake has been completed, both parties MUST + immediately decide whether or not to continue based on the + authentication and privacy achieved. The SMTP client and server may + decide to move ahead even if the TLS negotiation ended with no + authentication and/or no privacy because most SMTP services are + performed with no authentication and no privacy, but some SMTP + clients or servers may want to continue only if a particular level of + authentication and/or privacy was achieved. + + If the SMTP client decides that the level of authentication or + privacy is not high enough for it to continue, it SHOULD issue an + SMTP QUIT command immediately after the TLS negotiation is complete. + If the SMTP server decides that the level of authentication or + privacy is not high enough for it to continue, it SHOULD reply to + every SMTP command from the client (other than a QUIT command) with + the 554 reply code (with a possible text string such as "Command + refused due to lack of security"). + + The decision of whether or not to believe the authenticity of the + other party in a TLS negotiation is a local matter. However, some + general rules for the decisions are: + + + + + +Hoffman Standards Track [Page 3] + +RFC 2487 SMTP Service Extension January 1999 + + + - A SMTP client would probably only want to authenticate an SMTP + server whose server certificate has a domain name that is the + domain name that the client thought it was connecting to. + - A publicly-referenced SMTP server would probably want to accept + any certificate from an SMTP client, and would possibly want to + put distinguishing information about the certificate in the + Received header of messages that were relayed or submitted from + the client. + +5.2 Result of the STARTTLS Command + + Upon completion of the TLS handshake, the SMTP protocol is reset to + the initial state (the state in SMTP after a server issues a 220 + service ready greeting). The server MUST discard any knowledge + obtained from the client, such as the argument to the EHLO command, + which was not obtained from the TLS negotiation itself. The client + MUST discard any knowledge obtained from the server, such as the list + of SMTP service extensions, which was not obtained from the TLS + negotiation itself. The client SHOULD send an EHLO command as the + first command after a successful TLS negotiation. + + The list of SMTP service extensions returned in response to an EHLO + command received after the TLS handshake MAY be different than the + list returned before the TLS handshake. For example, an SMTP server + might not want to advertise support for a particular SASL mechanism + [SASL] unless a client has sent an appropriate client certificate + during a TLS handshake. + + Both the client and the server MUST know if there is a TLS session + active. A client MUST NOT attempt to start a TLS session if a TLS + session is already active. A server MUST NOT return the TLS extension + in response to an EHLO command received after a TLS handshake has + completed. + +6. Usage Example + + The following dialog illustrates how a client and server can start a + TLS session: + + S: + C: + S: 220 mail.imc.org SMTP service ready + C: EHLO mail.ietf.org + S: 250-mail.imc.org offers a warm hug of welcome + S: 250 STARTTLS + C: STARTTLS + S: 220 Go ahead + C: + + + +Hoffman Standards Track [Page 4] + +RFC 2487 SMTP Service Extension January 1999 + + + C & S: + C & S: + C: + . . . + +7. Security Considerations + + It should be noted that SMTP is not an end-to-end mechanism. Thus, if + an SMTP client/server pair decide to add TLS privacy, they are not + securing the transport from the originating mail user agent to the + recipient. Further, because delivery of a single piece of mail may + go between more than two SMTP servers, adding TLS privacy to one pair + of servers does not mean that the entire SMTP chain has been made + private. Further, just because an SMTP server can authenticate an + SMTP client, it does not mean that the mail from the SMTP client was + authenticated by the SMTP client when the client received it. + + Both the STMP client and server must check the result of the TLS + negotiation to see whether acceptable authentication or privacy was + achieved. Ignoring this step completely invalidates using TLS for + security. The decision about whether acceptable authentication or + privacy was achieved is made locally, is implementation-dependant, + and is beyond the scope of this document. + + The SMTP client and server should note carefully the result of the + TLS negotiation. If the negotiation results in no privacy, or if it + results in privacy using algorithms or key lengths that are deemed + not strong enough, or if the authentication is not good enough for + either party, the client may choose to end the SMTP session with an + immediate QUIT command, or the server may choose to not accept any + more SMTP commands. + + A server announcing in an EHLO response that it uses a particular TLS + protocol should not pose any security issues, since any use of TLS + will be at least as secure as no use of TLS. + + A man-in-the-middle attack can be launched by deleting the "250 + STARTTLS" response from the server. This would cause the client not + to try to start a TLS session. An SMTP client can protect against + this attack by recording the fact that a particular SMTP server + offers TLS during one session and generating an alarm if it does not + appear in the EHLO response for a later session. The lack of TLS + during a session SHOULD NOT result in the bouncing of email, although + it could result in delayed processing. + + + + + + + +Hoffman Standards Track [Page 5] + +RFC 2487 SMTP Service Extension January 1999 + + + Before the TLS handshake has begun, any protocol interactions are + performed in the clear and may be modified by an active attacker. For + this reason, clients and servers MUST discard any knowledge obtained + prior to the start of the TLS handshake upon completion of the TLS + handshake. + + The STARTTLS extension is not suitable for authenticating the author + of an email message unless every hop in the delivery chain, including + the submission to the first SMTP server, is authenticated. Another + proposal [SMTP-AUTH] can be used to authenticate delivery and MIME + security multiparts [MIME-SEC] can be used to authenticate the author + of an email message. In addition, the [SMTP-AUTH] proposal offers + simpler and more flexible options to authenticate an SMTP client and + the SASL EXTERNAL mechanism [SASL] MAY be used in conjunction with + the STARTTLS command to provide an authorization identity. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Hoffman Standards Track [Page 6] + +RFC 2487 SMTP Service Extension January 1999 + + +A. References + + [RFC-821] Postel, J., "Simple Mail Transfer Protocol", RFC 821, + August 1982. + + [RFC-1869] Klensin, J., Freed, N, Rose, M, Stefferud, E. and D. + Crocker, "SMTP Service Extensions", STD 10, RFC 1869, + November 1995. + + [RFC-2034] Freed, N., "SMTP Service Extension for Returning Enhanced + Error Codes", RFC 2034, October 1996. + + [RFC-2119] Bradner, S., "Key words for use in RFCs to Indicate + Requirement Levels", BCP 14, RFC 2119, March 1997. + + [SASL] Myers, J., "Simple Authentication and Security Layer + (SASL)", RFC 2222, October 1997. + + [SMTP-AUTH] "SMTP Service Extension for Authentication", Work in + Progress. + + [TLS] Dierks, T. and C. Allen, "The TLS Protocol Version 1.0", + RFC 2246, January 1999. + +B. Author's Address + + Paul Hoffman + Internet Mail Consortium + 127 Segre Place + Santa Cruz, CA 95060 + + Phone: (831) 426-9827 + EMail: phoffman@imc.org + + + + + + + + + + + + + + + + + + +Hoffman Standards Track [Page 7] + +RFC 2487 SMTP Service Extension January 1999 + + +C. Full Copyright Statement + + Copyright (C) The Internet Society (1999). All Rights Reserved. + + This document and translations of it may be copied and furnished to + others, and derivative works that comment on or otherwise explain it + or assist in its implementation may be prepared, copied, published + and distributed, in whole or in part, without restriction of any + kind, provided that the above copyright notice and this paragraph are + included on all such copies and derivative works. However, this + document itself may not be modified in any way, such as by removing + the copyright notice or references to the Internet Society or other + Internet organizations, except as needed for the purpose of + developing Internet standards in which case the procedures for + copyrights defined in the Internet Standards process must be + followed, or as required to translate it into languages other than + English. + + The limited permissions granted above are perpetual and will not be + revoked by the Internet Society or its successors or assigns. + + This document and the information contained herein is provided on an + "AS IS" basis and THE INTERNET SOCIETY AND THE INTERNET ENGINEERING + TASK FORCE DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING + BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION + HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF + MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + + + + + + + + + + + + + + + + + + + + + + + + +Hoffman Standards Track [Page 8] + diff --git a/vendor/swiftmailer/swiftmailer/notes/rfc/rfc2554.txt b/vendor/swiftmailer/swiftmailer/notes/rfc/rfc2554.txt new file mode 100755 index 0000000..2922dea --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/notes/rfc/rfc2554.txt @@ -0,0 +1,619 @@ + + + + + + +Network Working Group J. Myers +Request for Comments: 2554 Netscape Communications +Category: Standards Track March 1999 + + + SMTP Service Extension + for Authentication + +Status of this Memo + + This document specifies an Internet standards track protocol for the + Internet community, and requests discussion and suggestions for + improvements. Please refer to the current edition of the "Internet + Official Protocol Standards" (STD 1) for the standardization state + and status of this protocol. Distribution of this memo is unlimited. + +Copyright Notice + + Copyright (C) The Internet Society (1999). All Rights Reserved. + + +1. Introduction + + This document defines an SMTP service extension [ESMTP] whereby an + SMTP client may indicate an authentication mechanism to the server, + perform an authentication protocol exchange, and optionally negotiate + a security layer for subsequent protocol interactions. This + extension is a profile of the Simple Authentication and Security + Layer [SASL]. + + +2. Conventions Used in this Document + + In examples, "C:" and "S:" indicate lines sent by the client and + server respectively. + + The key words "MUST", "MUST NOT", "SHOULD", "SHOULD NOT", and "MAY" + in this document are to be interpreted as defined in "Key words for + use in RFCs to Indicate Requirement Levels" [KEYWORDS]. + + +3. The Authentication service extension + + + (1) the name of the SMTP service extension is "Authentication" + + (2) the EHLO keyword value associated with this extension is "AUTH" + + + + +Myers Standards Track [Page 1] + +RFC 2554 SMTP Authentication March 1999 + + + (3) The AUTH EHLO keyword contains as a parameter a space separated + list of the names of supported SASL mechanisms. + + (4) a new SMTP verb "AUTH" is defined + + (5) an optional parameter using the keyword "AUTH" is added to the + MAIL FROM command, and extends the maximum line length of the + MAIL FROM command by 500 characters. + + (6) this extension is appropriate for the submission protocol + [SUBMIT]. + + +4. The AUTH command + + AUTH mechanism [initial-response] + + Arguments: + a string identifying a SASL authentication mechanism. + an optional base64-encoded response + + Restrictions: + After an AUTH command has successfully completed, no more AUTH + commands may be issued in the same session. After a successful + AUTH command completes, a server MUST reject any further AUTH + commands with a 503 reply. + + The AUTH command is not permitted during a mail transaction. + + Discussion: + The AUTH command indicates an authentication mechanism to the + server. If the server supports the requested authentication + mechanism, it performs an authentication protocol exchange to + authenticate and identify the user. Optionally, it also + negotiates a security layer for subsequent protocol + interactions. If the requested authentication mechanism is not + supported, the server rejects the AUTH command with a 504 + reply. + + The authentication protocol exchange consists of a series of + server challenges and client answers that are specific to the + authentication mechanism. A server challenge, otherwise known + as a ready response, is a 334 reply with the text part + containing a BASE64 encoded string. The client answer consists + of a line containing a BASE64 encoded string. If the client + wishes to cancel an authentication exchange, it issues a line + with a single "*". If the server receives such an answer, it + MUST reject the AUTH command by sending a 501 reply. + + + +Myers Standards Track [Page 2] + +RFC 2554 SMTP Authentication March 1999 + + + The optional initial-response argument to the AUTH command is + used to save a round trip when using authentication mechanisms + that are defined to send no data in the initial challenge. + When the initial-response argument is used with such a + mechanism, the initial empty challenge is not sent to the + client and the server uses the data in the initial-response + argument as if it were sent in response to the empty challenge. + Unlike a zero-length client answer to a 334 reply, a zero- + length initial response is sent as a single equals sign ("="). + If the client uses an initial-response argument to the AUTH + command with a mechanism that sends data in the initial + challenge, the server rejects the AUTH command with a 535 + reply. + + If the server cannot BASE64 decode the argument, it rejects the + AUTH command with a 501 reply. If the server rejects the + authentication data, it SHOULD reject the AUTH command with a + 535 reply unless a more specific error code, such as one listed + in section 6, is appropriate. Should the client successfully + complete the authentication exchange, the SMTP server issues a + 235 reply. + + The service name specified by this protocol's profile of SASL + is "smtp". + + If a security layer is negotiated through the SASL + authentication exchange, it takes effect immediately following + the CRLF that concludes the authentication exchange for the + client, and the CRLF of the success reply for the server. Upon + a security layer's taking effect, the SMTP protocol is reset to + the initial state (the state in SMTP after a server issues a + 220 service ready greeting). The server MUST discard any + knowledge obtained from the client, such as the argument to the + EHLO command, which was not obtained from the SASL negotiation + itself. The client MUST discard any knowledge obtained from + the server, such as the list of SMTP service extensions, which + was not obtained from the SASL negotiation itself (with the + exception that a client MAY compare the list of advertised SASL + mechanisms before and after authentication in order to detect + an active down-negotiation attack). The client SHOULD send an + EHLO command as the first command after a successful SASL + negotiation which results in the enabling of a security layer. + + The server is not required to support any particular + authentication mechanism, nor are authentication mechanisms + required to support any security layers. If an AUTH command + fails, the client may try another authentication mechanism by + issuing another AUTH command. + + + +Myers Standards Track [Page 3] + +RFC 2554 SMTP Authentication March 1999 + + + If an AUTH command fails, the server MUST behave the same as if + the client had not issued the AUTH command. + + The BASE64 string may in general be arbitrarily long. Clients + and servers MUST be able to support challenges and responses + that are as long as are generated by the authentication + mechanisms they support, independent of any line length + limitations the client or server may have in other parts of its + protocol implementation. + + Examples: + S: 220 smtp.example.com ESMTP server ready + C: EHLO jgm.example.com + S: 250-smtp.example.com + S: 250 AUTH CRAM-MD5 DIGEST-MD5 + C: AUTH FOOBAR + S: 504 Unrecognized authentication type. + C: AUTH CRAM-MD5 + S: 334 + PENCeUxFREJoU0NnbmhNWitOMjNGNndAZWx3b29kLmlubm9zb2Z0LmNvbT4= + C: ZnJlZCA5ZTk1YWVlMDljNDBhZjJiODRhMGMyYjNiYmFlNzg2ZQ== + S: 235 Authentication successful. + + + +5. The AUTH parameter to the MAIL FROM command + + AUTH=addr-spec + + Arguments: + An addr-spec containing the identity which submitted the message + to the delivery system, or the two character sequence "<>" + indicating such an identity is unknown or insufficiently + authenticated. To comply with the restrictions imposed on ESMTP + parameters, the addr-spec is encoded inside an xtext. The syntax + of an xtext is described in section 5 of [ESMTP-DSN]. + + Discussion: + The optional AUTH parameter to the MAIL FROM command allows + cooperating agents in a trusted environment to communicate the + authentication of individual messages. + + If the server trusts the authenticated identity of the client to + assert that the message was originally submitted by the supplied + addr-spec, then the server SHOULD supply the same addr-spec in an + AUTH parameter when relaying the message to any server which + supports the AUTH extension. + + + + +Myers Standards Track [Page 4] + +RFC 2554 SMTP Authentication March 1999 + + + A MAIL FROM parameter of AUTH=<> indicates that the original + submitter of the message is not known. The server MUST NOT treat + the message as having been originally submitted by the client. + + If the AUTH parameter to the MAIL FROM is not supplied, the + client has authenticated, and the server believes the message is + an original submission by the client, the server MAY supply the + client's identity in the addr-spec in an AUTH parameter when + relaying the message to any server which supports the AUTH + extension. + + If the server does not sufficiently trust the authenticated + identity of the client, or if the client is not authenticated, + then the server MUST behave as if the AUTH=<> parameter was + supplied. The server MAY, however, write the value of the AUTH + parameter to a log file. + + If an AUTH=<> parameter was supplied, either explicitly or due to + the requirement in the previous paragraph, then the server MUST + supply the AUTH=<> parameter when relaying the message to any + server which it has authenticated to using the AUTH extension. + + A server MAY treat expansion of a mailing list as a new + submission, setting the AUTH parameter to the mailing list + address or mailing list administration address when relaying the + message to list subscribers. + + It is conforming for an implementation to be hard-coded to treat + all clients as being insufficiently trusted. In that case, the + implementation does nothing more than parse and discard + syntactically valid AUTH parameters to the MAIL FROM command and + supply AUTH=<> parameters to any servers to which it + authenticates using the AUTH extension. + + Examples: + C: MAIL FROM: AUTH=e+3Dmc2@example.com + S: 250 OK + + + + + + + + + + + + + + +Myers Standards Track [Page 5] + +RFC 2554 SMTP Authentication March 1999 + + +6. Error Codes + + The following error codes may be used to indicate various conditions + as described. + + 432 A password transition is needed + + This response to the AUTH command indicates that the user needs to + transition to the selected authentication mechanism. This typically + done by authenticating once using the PLAIN authentication mechanism. + + 534 Authentication mechanism is too weak + + This response to the AUTH command indicates that the selected + authentication mechanism is weaker than server policy permits for + that user. + + 538 Encryption required for requested authentication mechanism + + This response to the AUTH command indicates that the selected + authentication mechanism may only be used when the underlying SMTP + connection is encrypted. + + 454 Temporary authentication failure + + This response to the AUTH command indicates that the authentication + failed due to a temporary server failure. + + 530 Authentication required + + This response may be returned by any command other than AUTH, EHLO, + HELO, NOOP, RSET, or QUIT. It indicates that server policy requires + authentication in order to perform the requested action. + + + + + + + + + + + + + + + + + + +Myers Standards Track [Page 6] + +RFC 2554 SMTP Authentication March 1999 + + +7. Formal Syntax + + The following syntax specification uses the augmented Backus-Naur + Form (BNF) notation as specified in [ABNF]. + + Except as noted otherwise, all alphabetic characters are case- + insensitive. The use of upper or lower case characters to define + token strings is for editorial clarity only. Implementations MUST + accept these strings in a case-insensitive fashion. + + UPALPHA = %x41-5A ;; Uppercase: A-Z + + LOALPHA = %x61-7A ;; Lowercase: a-z + + ALPHA = UPALPHA / LOALPHA ;; case insensitive + + DIGIT = %x30-39 ;; Digits 0-9 + + HEXDIGIT = %x41-46 / DIGIT ;; hexidecimal digit (uppercase) + + hexchar = "+" HEXDIGIT HEXDIGIT + + xchar = %x21-2A / %x2C-3C / %x3E-7E + ;; US-ASCII except for "+", "=", SPACE and CTL + + xtext = *(xchar / hexchar) + + AUTH_CHAR = ALPHA / DIGIT / "-" / "_" + + auth_type = 1*20AUTH_CHAR + + auth_command = "AUTH" SPACE auth_type [SPACE (base64 / "=")] + *(CRLF [base64]) CRLF + + auth_param = "AUTH=" xtext + ;; The decoded form of the xtext MUST be either + ;; an addr-spec or the two characters "<>" + + base64 = base64_terminal / + ( 1*(4base64_CHAR) [base64_terminal] ) + + base64_char = UPALPHA / LOALPHA / DIGIT / "+" / "/" + ;; Case-sensitive + + base64_terminal = (2base64_char "==") / (3base64_char "=") + + continue_req = "334" SPACE [base64] CRLF + + + + +Myers Standards Track [Page 7] + +RFC 2554 SMTP Authentication March 1999 + + + CR = %x0C ;; ASCII CR, carriage return + + CRLF = CR LF + + CTL = %x00-1F / %x7F ;; any ASCII control character and DEL + + LF = %x0A ;; ASCII LF, line feed + + SPACE = %x20 ;; ASCII SP, space + + + + +8. References + + [ABNF] Crocker, D. and P. Overell, "Augmented BNF for Syntax + Specifications: ABNF", RFC 2234, November 1997. + + [CRAM-MD5] Klensin, J., Catoe, R. and P. Krumviede, "IMAP/POP + AUTHorize Extension for Simple Challenge/Response", RFC + 2195, September 1997. + + [ESMTP] Klensin, J., Freed, N., Rose, M., Stefferud, E. and D. + Crocker, "SMTP Service Extensions", RFC 1869, November + 1995. + + [ESMTP-DSN] Moore, K, "SMTP Service Extension for Delivery Status + Notifications", RFC 1891, January 1996. + + [KEYWORDS] Bradner, S., "Key words for use in RFCs to Indicate + Requirement Levels", BCP 14, RFC 2119, March 1997. + + [SASL] Myers, J., "Simple Authentication and Security Layer + (SASL)", RFC 2222, October 1997. + + [SUBMIT] Gellens, R. and J. Klensin, "Message Submission", RFC + 2476, December 1998. + + [RFC821] Postel, J., "Simple Mail Transfer Protocol", STD 10, RFC + 821, August 1982. + + [RFC822] Crocker, D., "Standard for the Format of ARPA Internet + Text Messages", STD 11, RFC 822, August 1982. + + + + + + + + +Myers Standards Track [Page 8] + +RFC 2554 SMTP Authentication March 1999 + + +9. Security Considerations + + Security issues are discussed throughout this memo. + + If a client uses this extension to get an encrypted tunnel through an + insecure network to a cooperating server, it needs to be configured + to never send mail to that server when the connection is not mutually + authenticated and encrypted. Otherwise, an attacker could steal the + client's mail by hijacking the SMTP connection and either pretending + the server does not support the Authentication extension or causing + all AUTH commands to fail. + + Before the SASL negotiation has begun, any protocol interactions are + performed in the clear and may be modified by an active attacker. + For this reason, clients and servers MUST discard any knowledge + obtained prior to the start of the SASL negotiation upon completion + of a SASL negotiation which results in a security layer. + + This mechanism does not protect the TCP port, so an active attacker + may redirect a relay connection attempt to the submission port + [SUBMIT]. The AUTH=<> parameter prevents such an attack from causing + an relayed message without an envelope authentication to pick up the + authentication of the relay client. + + A message submission client may require the user to authenticate + whenever a suitable SASL mechanism is advertised. Therefore, it may + not be desirable for a submission server [SUBMIT] to advertise a SASL + mechanism when use of that mechanism grants the client no benefits + over anonymous submission. + + This extension is not intended to replace or be used instead of end- + to-end message signature and encryption systems such as S/MIME or + PGP. This extension addresses a different problem than end-to-end + systems; it has the following key differences: + + (1) it is generally useful only within a trusted enclave + + (2) it protects the entire envelope of a message, not just the + message's body. + + (3) it authenticates the message submission, not authorship of the + message content + + (4) it can give the sender some assurance the message was + delivered to the next hop in the case where the sender + mutually authenticates with the next hop and negotiates an + appropriate security layer. + + + + +Myers Standards Track [Page 9] + +RFC 2554 SMTP Authentication March 1999 + + + Additional security considerations are mentioned in the SASL + specification [SASL]. + + + +10. Author's Address + + John Gardiner Myers + Netscape Communications + 501 East Middlefield Road + Mail Stop MV-029 + Mountain View, CA 94043 + + EMail: jgmyers@netscape.com + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Myers Standards Track [Page 10] + +RFC 2554 SMTP Authentication March 1999 + + +11. Full Copyright Statement + + Copyright (C) The Internet Society (1999). All Rights Reserved. + + This document and translations of it may be copied and furnished to + others, and derivative works that comment on or otherwise explain it + or assist in its implementation may be prepared, copied, published + and distributed, in whole or in part, without restriction of any + kind, provided that the above copyright notice and this paragraph are + included on all such copies and derivative works. However, this + document itself may not be modified in any way, such as by removing + the copyright notice or references to the Internet Society or other + Internet organizations, except as needed for the purpose of + developing Internet standards in which case the procedures for + copyrights defined in the Internet Standards process must be + followed, or as required to translate it into languages other than + English. + + The limited permissions granted above are perpetual and will not be + revoked by the Internet Society or its successors or assigns. + + This document and the information contained herein is provided on an + "AS IS" basis and THE INTERNET SOCIETY AND THE INTERNET ENGINEERING + TASK FORCE DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING + BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION + HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF + MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + + + + + + + + + + + + + + + + + + + + + + + + +Myers Standards Track [Page 11] + diff --git a/vendor/swiftmailer/swiftmailer/notes/rfc/rfc2821.txt b/vendor/swiftmailer/swiftmailer/notes/rfc/rfc2821.txt new file mode 100755 index 0000000..0eac911 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/notes/rfc/rfc2821.txt @@ -0,0 +1,4427 @@ + + + + + + +Network Working Group J. Klensin, Editor +Request for Comments: 2821 AT&T Laboratories +Obsoletes: 821, 974, 1869 April 2001 +Updates: 1123 +Category: Standards Track + + + Simple Mail Transfer Protocol + +Status of this Memo + + This document specifies an Internet standards track protocol for the + Internet community, and requests discussion and suggestions for + improvements. Please refer to the current edition of the "Internet + Official Protocol Standards" (STD 1) for the standardization state + and status of this protocol. Distribution of this memo is unlimited. + +Copyright Notice + + Copyright (C) The Internet Society (2001). All Rights Reserved. + +Abstract + + This document is a self-contained specification of the basic protocol + for the Internet electronic mail transport. It consolidates, updates + and clarifies, but doesn't add new or change existing functionality + of the following: + + - the original SMTP (Simple Mail Transfer Protocol) specification of + RFC 821 [30], + + - domain name system requirements and implications for mail + transport from RFC 1035 [22] and RFC 974 [27], + + - the clarifications and applicability statements in RFC 1123 [2], + and + + - material drawn from the SMTP Extension mechanisms [19]. + + It obsoletes RFC 821, RFC 974, and updates RFC 1123 (replaces the + mail transport materials of RFC 1123). However, RFC 821 specifies + some features that were not in significant use in the Internet by the + mid-1990s and (in appendices) some additional transport models. + Those sections are omitted here in the interest of clarity and + brevity; readers needing them should refer to RFC 821. + + + + + + +Klensin Standards Track [Page 1] + +RFC 2821 Simple Mail Transfer Protocol April 2001 + + + It also includes some additional material from RFC 1123 that required + amplification. This material has been identified in multiple ways, + mostly by tracking flaming on various lists and newsgroups and + problems of unusual readings or interpretations that have appeared as + the SMTP extensions have been deployed. Where this specification + moves beyond consolidation and actually differs from earlier + documents, it supersedes them technically as well as textually. + + Although SMTP was designed as a mail transport and delivery protocol, + this specification also contains information that is important to its + use as a 'mail submission' protocol, as recommended for POP [3, 26] + and IMAP [6]. Additional submission issues are discussed in RFC 2476 + [15]. + + Section 2.3 provides definitions of terms specific to this document. + Except when the historical terminology is necessary for clarity, this + document uses the current 'client' and 'server' terminology to + identify the sending and receiving SMTP processes, respectively. + + A companion document [32] discusses message headers, message bodies + and formats and structures for them, and their relationship. + +Table of Contents + + 1. Introduction .................................................. 4 + 2. The SMTP Model ................................................ 5 + 2.1 Basic Structure .............................................. 5 + 2.2 The Extension Model .......................................... 7 + 2.2.1 Background ................................................. 7 + 2.2.2 Definition and Registration of Extensions .................. 8 + 2.3 Terminology .................................................. 9 + 2.3.1 Mail Objects ............................................... 10 + 2.3.2 Senders and Receivers ...................................... 10 + 2.3.3 Mail Agents and Message Stores ............................. 10 + 2.3.4 Host ....................................................... 11 + 2.3.5 Domain ..................................................... 11 + 2.3.6 Buffer and State Table ..................................... 11 + 2.3.7 Lines ...................................................... 12 + 2.3.8 Originator, Delivery, Relay, and Gateway Systems ........... 12 + 2.3.9 Message Content and Mail Data .............................. 13 + 2.3.10 Mailbox and Address ....................................... 13 + 2.3.11 Reply ..................................................... 13 + 2.4 General Syntax Principles and Transaction Model .............. 13 + 3. The SMTP Procedures: An Overview .............................. 15 + 3.1 Session Initiation ........................................... 15 + 3.2 Client Initiation ............................................ 16 + 3.3 Mail Transactions ............................................ 16 + 3.4 Forwarding for Address Correction or Updating ................ 19 + + + +Klensin Standards Track [Page 2] + +RFC 2821 Simple Mail Transfer Protocol April 2001 + + + 3.5 Commands for Debugging Addresses ............................. 20 + 3.5.1 Overview ................................................... 20 + 3.5.2 VRFY Normal Response ....................................... 22 + 3.5.3 Meaning of VRFY or EXPN Success Response ................... 22 + 3.5.4 Semantics and Applications of EXPN ......................... 23 + 3.6 Domains ...................................................... 23 + 3.7 Relaying ..................................................... 24 + 3.8 Mail Gatewaying .............................................. 25 + 3.8.1 Header Fields in Gatewaying ................................ 26 + 3.8.2 Received Lines in Gatewaying ............................... 26 + 3.8.3 Addresses in Gatewaying .................................... 26 + 3.8.4 Other Header Fields in Gatewaying .......................... 27 + 3.8.5 Envelopes in Gatewaying .................................... 27 + 3.9 Terminating Sessions and Connections ......................... 27 + 3.10 Mailing Lists and Aliases ................................... 28 + 3.10.1 Alias ..................................................... 28 + 3.10.2 List ...................................................... 28 + 4. The SMTP Specifications ....................................... 29 + 4.1 SMTP Commands ................................................ 29 + 4.1.1 Command Semantics and Syntax ............................... 29 + 4.1.1.1 Extended HELLO (EHLO) or HELLO (HELO) ................... 29 + 4.1.1.2 MAIL (MAIL) .............................................. 31 + 4.1.1.3 RECIPIENT (RCPT) ......................................... 31 + 4.1.1.4 DATA (DATA) .............................................. 33 + 4.1.1.5 RESET (RSET) ............................................. 34 + 4.1.1.6 VERIFY (VRFY) ............................................ 35 + 4.1.1.7 EXPAND (EXPN) ............................................ 35 + 4.1.1.8 HELP (HELP) .............................................. 35 + 4.1.1.9 NOOP (NOOP) .............................................. 35 + 4.1.1.10 QUIT (QUIT) ............................................. 36 + 4.1.2 Command Argument Syntax .................................... 36 + 4.1.3 Address Literals ........................................... 38 + 4.1.4 Order of Commands .......................................... 39 + 4.1.5 Private-use Commands ....................................... 40 + 4.2 SMTP Replies ................................................ 40 + 4.2.1 Reply Code Severities and Theory ........................... 42 + 4.2.2 Reply Codes by Function Groups ............................. 44 + 4.2.3 Reply Codes in Numeric Order .............................. 45 + 4.2.4 Reply Code 502 ............................................. 46 + 4.2.5 Reply Codes After DATA and the Subsequent . .... 46 + 4.3 Sequencing of Commands and Replies ........................... 47 + 4.3.1 Sequencing Overview ........................................ 47 + 4.3.2 Command-Reply Sequences .................................... 48 + 4.4 Trace Information ............................................ 49 + 4.5 Additional Implementation Issues ............................. 53 + 4.5.1 Minimum Implementation ..................................... 53 + 4.5.2 Transparency ............................................... 53 + 4.5.3 Sizes and Timeouts ......................................... 54 + + + +Klensin Standards Track [Page 3] + +RFC 2821 Simple Mail Transfer Protocol April 2001 + + + 4.5.3.1 Size limits and minimums ................................. 54 + 4.5.3.2 Timeouts ................................................. 56 + 4.5.4 Retry Strategies ........................................... 57 + 4.5.4.1 Sending Strategy ......................................... 58 + 4.5.4.2 Receiving Strategy ....................................... 59 + 4.5.5 Messages with a null reverse-path .......................... 59 + 5. Address Resolution and Mail Handling .......................... 60 + 6. Problem Detection and Handling ................................ 62 + 6.1 Reliable Delivery and Replies by Email ....................... 62 + 6.2 Loop Detection ............................................... 63 + 6.3 Compensating for Irregularities .............................. 63 + 7. Security Considerations ....................................... 64 + 7.1 Mail Security and Spoofing ................................... 64 + 7.2 "Blind" Copies ............................................... 65 + 7.3 VRFY, EXPN, and Security ..................................... 65 + 7.4 Information Disclosure in Announcements ...................... 66 + 7.5 Information Disclosure in Trace Fields ....................... 66 + 7.6 Information Disclosure in Message Forwarding ................. 67 + 7.7 Scope of Operation of SMTP Servers ........................... 67 + 8. IANA Considerations ........................................... 67 + 9. References .................................................... 68 + 10. Editor's Address ............................................. 70 + 11. Acknowledgments .............................................. 70 + Appendices ....................................................... 71 + A. TCP Transport Service ......................................... 71 + B. Generating SMTP Commands from RFC 822 Headers ................. 71 + C. Source Routes ................................................. 72 + D. Scenarios ..................................................... 73 + E. Other Gateway Issues .......................................... 76 + F. Deprecated Features of RFC 821 ................................ 76 + Full Copyright Statement ......................................... 79 + +1. Introduction + + The objective of the Simple Mail Transfer Protocol (SMTP) is to + transfer mail reliably and efficiently. + + SMTP is independent of the particular transmission subsystem and + requires only a reliable ordered data stream channel. While this + document specifically discusses transport over TCP, other transports + are possible. Appendices to RFC 821 describe some of them. + + An important feature of SMTP is its capability to transport mail + across networks, usually referred to as "SMTP mail relaying" (see + section 3.8). A network consists of the mutually-TCP-accessible + hosts on the public Internet, the mutually-TCP-accessible hosts on a + firewall-isolated TCP/IP Intranet, or hosts in some other LAN or WAN + environment utilizing a non-TCP transport-level protocol. Using + + + +Klensin Standards Track [Page 4] + +RFC 2821 Simple Mail Transfer Protocol April 2001 + + + SMTP, a process can transfer mail to another process on the same + network or to some other network via a relay or gateway process + accessible to both networks. + + In this way, a mail message may pass through a number of intermediate + relay or gateway hosts on its path from sender to ultimate recipient. + The Mail eXchanger mechanisms of the domain name system [22, 27] (and + section 5 of this document) are used to identify the appropriate + next-hop destination for a message being transported. + +2. The SMTP Model + +2.1 Basic Structure + + The SMTP design can be pictured as: + + +----------+ +----------+ + +------+ | | | | + | User |<-->| | SMTP | | + +------+ | Client- |Commands/Replies| Server- | + +------+ | SMTP |<-------------->| SMTP | +------+ + | File |<-->| | and Mail | |<-->| File | + |System| | | | | |System| + +------+ +----------+ +----------+ +------+ + SMTP client SMTP server + + When an SMTP client has a message to transmit, it establishes a two- + way transmission channel to an SMTP server. The responsibility of an + SMTP client is to transfer mail messages to one or more SMTP servers, + or report its failure to do so. + + The means by which a mail message is presented to an SMTP client, and + how that client determines the domain name(s) to which mail messages + are to be transferred is a local matter, and is not addressed by this + document. In some cases, the domain name(s) transferred to, or + determined by, an SMTP client will identify the final destination(s) + of the mail message. In other cases, common with SMTP clients + associated with implementations of the POP [3, 26] or IMAP [6] + protocols, or when the SMTP client is inside an isolated transport + service environment, the domain name determined will identify an + intermediate destination through which all mail messages are to be + relayed. SMTP clients that transfer all traffic, regardless of the + target domain names associated with the individual messages, or that + do not maintain queues for retrying message transmissions that + initially cannot be completed, may otherwise conform to this + specification but are not considered fully-capable. Fully-capable + SMTP implementations, including the relays used by these less capable + + + + +Klensin Standards Track [Page 5] + +RFC 2821 Simple Mail Transfer Protocol April 2001 + + + ones, and their destinations, are expected to support all of the + queuing, retrying, and alternate address functions discussed in this + specification. + + The means by which an SMTP client, once it has determined a target + domain name, determines the identity of an SMTP server to which a + copy of a message is to be transferred, and then performs that + transfer, is covered by this document. To effect a mail transfer to + an SMTP server, an SMTP client establishes a two-way transmission + channel to that SMTP server. An SMTP client determines the address + of an appropriate host running an SMTP server by resolving a + destination domain name to either an intermediate Mail eXchanger host + or a final target host. + + An SMTP server may be either the ultimate destination or an + intermediate "relay" (that is, it may assume the role of an SMTP + client after receiving the message) or "gateway" (that is, it may + transport the message further using some protocol other than SMTP). + SMTP commands are generated by the SMTP client and sent to the SMTP + server. SMTP replies are sent from the SMTP server to the SMTP + client in response to the commands. + + In other words, message transfer can occur in a single connection + between the original SMTP-sender and the final SMTP-recipient, or can + occur in a series of hops through intermediary systems. In either + case, a formal handoff of responsibility for the message occurs: the + protocol requires that a server accept responsibility for either + delivering a message or properly reporting the failure to do so. + + Once the transmission channel is established and initial handshaking + completed, the SMTP client normally initiates a mail transaction. + Such a transaction consists of a series of commands to specify the + originator and destination of the mail and transmission of the + message content (including any headers or other structure) itself. + When the same message is sent to multiple recipients, this protocol + encourages the transmission of only one copy of the data for all + recipients at the same destination (or intermediate relay) host. + + The server responds to each command with a reply; replies may + indicate that the command was accepted, that additional commands are + expected, or that a temporary or permanent error condition exists. + Commands specifying the sender or recipients may include server- + permitted SMTP service extension requests as discussed in section + 2.2. The dialog is purposely lock-step, one-at-a-time, although this + can be modified by mutually-agreed extension requests such as command + pipelining [13]. + + + + + +Klensin Standards Track [Page 6] + +RFC 2821 Simple Mail Transfer Protocol April 2001 + + + Once a given mail message has been transmitted, the client may either + request that the connection be shut down or may initiate other mail + transactions. In addition, an SMTP client may use a connection to an + SMTP server for ancillary services such as verification of email + addresses or retrieval of mailing list subscriber addresses. + + As suggested above, this protocol provides mechanisms for the + transmission of mail. This transmission normally occurs directly + from the sending user's host to the receiving user's host when the + two hosts are connected to the same transport service. When they are + not connected to the same transport service, transmission occurs via + one or more relay SMTP servers. An intermediate host that acts as + either an SMTP relay or as a gateway into some other transmission + environment is usually selected through the use of the domain name + service (DNS) Mail eXchanger mechanism. + + Usually, intermediate hosts are determined via the DNS MX record, not + by explicit "source" routing (see section 5 and appendices C and + F.2). + +2.2 The Extension Model + +2.2.1 Background + + In an effort that started in 1990, approximately a decade after RFC + 821 was completed, the protocol was modified with a "service + extensions" model that permits the client and server to agree to + utilize shared functionality beyond the original SMTP requirements. + The SMTP extension mechanism defines a means whereby an extended SMTP + client and server may recognize each other, and the server can inform + the client as to the service extensions that it supports. + + Contemporary SMTP implementations MUST support the basic extension + mechanisms. For instance, servers MUST support the EHLO command even + if they do not implement any specific extensions and clients SHOULD + preferentially utilize EHLO rather than HELO. (However, for + compatibility with older conforming implementations, SMTP clients and + servers MUST support the original HELO mechanisms as a fallback.) + Unless the different characteristics of HELO must be identified for + interoperability purposes, this document discusses only EHLO. + + SMTP is widely deployed and high-quality implementations have proven + to be very robust. However, the Internet community now considers + some services to be important that were not anticipated when the + protocol was first designed. If support for those services is to be + added, it must be done in a way that permits older implementations to + continue working acceptably. The extension framework consists of: + + + + +Klensin Standards Track [Page 7] + +RFC 2821 Simple Mail Transfer Protocol April 2001 + + + - The SMTP command EHLO, superseding the earlier HELO, + + - a registry of SMTP service extensions, + + - additional parameters to the SMTP MAIL and RCPT commands, and + + - optional replacements for commands defined in this protocol, such + as for DATA in non-ASCII transmissions [33]. + + SMTP's strength comes primarily from its simplicity. Experience with + many protocols has shown that protocols with few options tend towards + ubiquity, whereas protocols with many options tend towards obscurity. + + Each and every extension, regardless of its benefits, must be + carefully scrutinized with respect to its implementation, deployment, + and interoperability costs. In many cases, the cost of extending the + SMTP service will likely outweigh the benefit. + +2.2.2 Definition and Registration of Extensions + + The IANA maintains a registry of SMTP service extensions. A + corresponding EHLO keyword value is associated with each extension. + Each service extension registered with the IANA must be defined in a + formal standards-track or IESG-approved experimental protocol + document. The definition must include: + + - the textual name of the SMTP service extension; + + - the EHLO keyword value associated with the extension; + + - the syntax and possible values of parameters associated with the + EHLO keyword value; + + - any additional SMTP verbs associated with the extension + (additional verbs will usually be, but are not required to be, the + same as the EHLO keyword value); + + - any new parameters the extension associates with the MAIL or RCPT + verbs; + + - a description of how support for the extension affects the + behavior of a server and client SMTP; and, + + - the increment by which the extension is increasing the maximum + length of the commands MAIL and/or RCPT, over that specified in + this standard. + + + + + +Klensin Standards Track [Page 8] + +RFC 2821 Simple Mail Transfer Protocol April 2001 + + + In addition, any EHLO keyword value starting with an upper or lower + case "X" refers to a local SMTP service extension used exclusively + through bilateral agreement. Keywords beginning with "X" MUST NOT be + used in a registered service extension. Conversely, keyword values + presented in the EHLO response that do not begin with "X" MUST + correspond to a standard, standards-track, or IESG-approved + experimental SMTP service extension registered with IANA. A + conforming server MUST NOT offer non-"X"-prefixed keyword values that + are not described in a registered extension. + + Additional verbs and parameter names are bound by the same rules as + EHLO keywords; specifically, verbs beginning with "X" are local + extensions that may not be registered or standardized. Conversely, + verbs not beginning with "X" must always be registered. + +2.3 Terminology + + The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", + "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this + document are to be interpreted as described below. + + 1. MUST This word, or the terms "REQUIRED" or "SHALL", mean that + the definition is an absolute requirement of the specification. + + 2. MUST NOT This phrase, or the phrase "SHALL NOT", mean that the + definition is an absolute prohibition of the specification. + + 3. SHOULD This word, or the adjective "RECOMMENDED", mean that + there may exist valid reasons in particular circumstances to + ignore a particular item, but the full implications must be + understood and carefully weighed before choosing a different + course. + + 4. SHOULD NOT This phrase, or the phrase "NOT RECOMMENDED" mean + that there may exist valid reasons in particular circumstances + when the particular behavior is acceptable or even useful, but the + full implications should be understood and the case carefully + weighed before implementing any behavior described with this + label. + + 5. MAY This word, or the adjective "OPTIONAL", mean that an item is + truly optional. One vendor may choose to include the item because + a particular marketplace requires it or because the vendor feels + that it enhances the product while another vendor may omit the + same item. An implementation which does not include a particular + option MUST be prepared to interoperate with another + implementation which does include the option, though perhaps with + reduced functionality. In the same vein an implementation which + + + +Klensin Standards Track [Page 9] + +RFC 2821 Simple Mail Transfer Protocol April 2001 + + + does include a particular option MUST be prepared to interoperate + with another implementation which does not include the option + (except, of course, for the feature the option provides.) + +2.3.1 Mail Objects + + SMTP transports a mail object. A mail object contains an envelope + and content. + + The SMTP envelope is sent as a series of SMTP protocol units + (described in section 3). It consists of an originator address (to + which error reports should be directed); one or more recipient + addresses; and optional protocol extension material. Historically, + variations on the recipient address specification command (RCPT TO) + could be used to specify alternate delivery modes, such as immediate + display; those variations have now been deprecated (see appendix F, + section F.6). + + The SMTP content is sent in the SMTP DATA protocol unit and has two + parts: the headers and the body. If the content conforms to other + contemporary standards, the headers form a collection of field/value + pairs structured as in the message format specification [32]; the + body, if structured, is defined according to MIME [12]. The content + is textual in nature, expressed using the US-ASCII repertoire [1]. + Although SMTP extensions (such as "8BITMIME" [20]) may relax this + restriction for the content body, the content headers are always + encoded using the US-ASCII repertoire. A MIME extension [23] defines + an algorithm for representing header values outside the US-ASCII + repertoire, while still encoding them using the US-ASCII repertoire. + +2.3.2 Senders and Receivers + + In RFC 821, the two hosts participating in an SMTP transaction were + described as the "SMTP-sender" and "SMTP-receiver". This document + has been changed to reflect current industry terminology and hence + refers to them as the "SMTP client" (or sometimes just "the client") + and "SMTP server" (or just "the server"), respectively. Since a + given host may act both as server and client in a relay situation, + "receiver" and "sender" terminology is still used where needed for + clarity. + +2.3.3 Mail Agents and Message Stores + + Additional mail system terminology became common after RFC 821 was + published and, where convenient, is used in this specification. In + particular, SMTP servers and clients provide a mail transport service + and therefore act as "Mail Transfer Agents" (MTAs). "Mail User + Agents" (MUAs or UAs) are normally thought of as the sources and + + + +Klensin Standards Track [Page 10] + +RFC 2821 Simple Mail Transfer Protocol April 2001 + + + targets of mail. At the source, an MUA might collect mail to be + transmitted from a user and hand it off to an MTA; the final + ("delivery") MTA would be thought of as handing the mail off to an + MUA (or at least transferring responsibility to it, e.g., by + depositing the message in a "message store"). However, while these + terms are used with at least the appearance of great precision in + other environments, the implied boundaries between MUAs and MTAs + often do not accurately match common, and conforming, practices with + Internet mail. Hence, the reader should be cautious about inferring + the strong relationships and responsibilities that might be implied + if these terms were used elsewhere. + +2.3.4 Host + + For the purposes of this specification, a host is a computer system + attached to the Internet (or, in some cases, to a private TCP/IP + network) and supporting the SMTP protocol. Hosts are known by names + (see "domain"); identifying them by numerical address is discouraged. + +2.3.5 Domain + + A domain (or domain name) consists of one or more dot-separated + components. These components ("labels" in DNS terminology [22]) are + restricted for SMTP purposes to consist of a sequence of letters, + digits, and hyphens drawn from the ASCII character set [1]. Domain + names are used as names of hosts and of other entities in the domain + name hierarchy. For example, a domain may refer to an alias (label + of a CNAME RR) or the label of Mail eXchanger records to be used to + deliver mail instead of representing a host name. See [22] and + section 5 of this specification. + + The domain name, as described in this document and in [22], is the + entire, fully-qualified name (often referred to as an "FQDN"). A + domain name that is not in FQDN form is no more than a local alias. + Local aliases MUST NOT appear in any SMTP transaction. + +2.3.6 Buffer and State Table + + SMTP sessions are stateful, with both parties carefully maintaining a + common view of the current state. In this document we model this + state by a virtual "buffer" and a "state table" on the server which + may be used by the client to, for example, "clear the buffer" or + "reset the state table," causing the information in the buffer to be + discarded and the state to be returned to some previous state. + + + + + + + +Klensin Standards Track [Page 11] + +RFC 2821 Simple Mail Transfer Protocol April 2001 + + +2.3.7 Lines + + SMTP commands and, unless altered by a service extension, message + data, are transmitted in "lines". Lines consist of zero or more data + characters terminated by the sequence ASCII character "CR" (hex value + 0D) followed immediately by ASCII character "LF" (hex value 0A). + This termination sequence is denoted as in this document. + Conforming implementations MUST NOT recognize or generate any other + character or character sequence as a line terminator. Limits MAY be + imposed on line lengths by servers (see section 4.5.3). + + In addition, the appearance of "bare" "CR" or "LF" characters in text + (i.e., either without the other) has a long history of causing + problems in mail implementations and applications that use the mail + system as a tool. SMTP client implementations MUST NOT transmit + these characters except when they are intended as line terminators + and then MUST, as indicated above, transmit them only as a + sequence. + +2.3.8 Originator, Delivery, Relay, and Gateway Systems + + This specification makes a distinction among four types of SMTP + systems, based on the role those systems play in transmitting + electronic mail. An "originating" system (sometimes called an SMTP + originator) introduces mail into the Internet or, more generally, + into a transport service environment. A "delivery" SMTP system is + one that receives mail from a transport service environment and + passes it to a mail user agent or deposits it in a message store + which a mail user agent is expected to subsequently access. A + "relay" SMTP system (usually referred to just as a "relay") receives + mail from an SMTP client and transmits it, without modification to + the message data other than adding trace information, to another SMTP + server for further relaying or for delivery. + + A "gateway" SMTP system (usually referred to just as a "gateway") + receives mail from a client system in one transport environment and + transmits it to a server system in another transport environment. + Differences in protocols or message semantics between the transport + environments on either side of a gateway may require that the gateway + system perform transformations to the message that are not permitted + to SMTP relay systems. For the purposes of this specification, + firewalls that rewrite addresses should be considered as gateways, + even if SMTP is used on both sides of them (see [11]). + + + + + + + + +Klensin Standards Track [Page 12] + +RFC 2821 Simple Mail Transfer Protocol April 2001 + + +2.3.9 Message Content and Mail Data + + The terms "message content" and "mail data" are used interchangeably + in this document to describe the material transmitted after the DATA + command is accepted and before the end of data indication is + transmitted. Message content includes message headers and the + possibly-structured message body. The MIME specification [12] + provides the standard mechanisms for structured message bodies. + +2.3.10 Mailbox and Address + + As used in this specification, an "address" is a character string + that identifies a user to whom mail will be sent or a location into + which mail will be deposited. The term "mailbox" refers to that + depository. The two terms are typically used interchangeably unless + the distinction between the location in which mail is placed (the + mailbox) and a reference to it (the address) is important. An + address normally consists of user and domain specifications. The + standard mailbox naming convention is defined to be "local- + part@domain": contemporary usage permits a much broader set of + applications than simple "user names". Consequently, and due to a + long history of problems when intermediate hosts have attempted to + optimize transport by modifying them, the local-part MUST be + interpreted and assigned semantics only by the host specified in the + domain part of the address. + +2.3.11 Reply + + An SMTP reply is an acknowledgment (positive or negative) sent from + receiver to sender via the transmission channel in response to a + command. The general form of a reply is a numeric completion code + (indicating failure or success) usually followed by a text string. + The codes are for use by programs and the text is usually intended + for human users. Recent work [34] has specified further structuring + of the reply strings, including the use of supplemental and more + specific completion codes. + +2.4 General Syntax Principles and Transaction Model + + SMTP commands and replies have a rigid syntax. All commands begin + with a command verb. All Replies begin with a three digit numeric + code. In some commands and replies, arguments MUST follow the verb + or reply code. Some commands do not accept arguments (after the + verb), and some reply codes are followed, sometimes optionally, by + free form text. In both cases, where text appears, it is separated + from the verb or reply code by a space character. Complete + definitions of commands and replies appear in section 4. + + + + +Klensin Standards Track [Page 13] + +RFC 2821 Simple Mail Transfer Protocol April 2001 + + + Verbs and argument values (e.g., "TO:" or "to:" in the RCPT command + and extension name keywords) are not case sensitive, with the sole + exception in this specification of a mailbox local-part (SMTP + Extensions may explicitly specify case-sensitive elements). That is, + a command verb, an argument value other than a mailbox local-part, + and free form text MAY be encoded in upper case, lower case, or any + mixture of upper and lower case with no impact on its meaning. This + is NOT true of a mailbox local-part. The local-part of a mailbox + MUST BE treated as case sensitive. Therefore, SMTP implementations + MUST take care to preserve the case of mailbox local-parts. Mailbox + domains are not case sensitive. In particular, for some hosts the + user "smith" is different from the user "Smith". However, exploiting + the case sensitivity of mailbox local-parts impedes interoperability + and is discouraged. + + A few SMTP servers, in violation of this specification (and RFC 821) + require that command verbs be encoded by clients in upper case. + Implementations MAY wish to employ this encoding to accommodate those + servers. + + The argument field consists of a variable length character string + ending with the end of the line, i.e., with the character sequence + . The receiver will take no action until this sequence is + received. + + The syntax for each command is shown with the discussion of that + command. Common elements and parameters are shown in section 4.1.2. + + Commands and replies are composed of characters from the ASCII + character set [1]. When the transport service provides an 8-bit byte + (octet) transmission channel, each 7-bit character is transmitted + right justified in an octet with the high order bit cleared to zero. + More specifically, the unextended SMTP service provides seven bit + transport only. An originating SMTP client which has not + successfully negotiated an appropriate extension with a particular + server MUST NOT transmit messages with information in the high-order + bit of octets. If such messages are transmitted in violation of this + rule, receiving SMTP servers MAY clear the high-order bit or reject + the message as invalid. In general, a relay SMTP SHOULD assume that + the message content it has received is valid and, assuming that the + envelope permits doing so, relay it without inspecting that content. + Of course, if the content is mislabeled and the data path cannot + accept the actual content, this may result in ultimate delivery of a + severely garbled message to the recipient. Delivery SMTP systems MAY + reject ("bounce") such messages rather than deliver them. No sending + SMTP system is permitted to send envelope commands in any character + + + + + +Klensin Standards Track [Page 14] + +RFC 2821 Simple Mail Transfer Protocol April 2001 + + + set other than US-ASCII; receiving systems SHOULD reject such + commands, normally using "500 syntax error - invalid character" + replies. + + Eight-bit message content transmission MAY be requested of the server + by a client using extended SMTP facilities, notably the "8BITMIME" + extension [20]. 8BITMIME SHOULD be supported by SMTP servers. + However, it MUST not be construed as authorization to transmit + unrestricted eight bit material. 8BITMIME MUST NOT be requested by + senders for material with the high bit on that is not in MIME format + with an appropriate content-transfer encoding; servers MAY reject + such messages. + + The metalinguistic notation used in this document corresponds to the + "Augmented BNF" used in other Internet mail system documents. The + reader who is not familiar with that syntax should consult the ABNF + specification [8]. Metalanguage terms used in running text are + surrounded by pointed brackets (e.g., ) for clarity. + +3. The SMTP Procedures: An Overview + + This section contains descriptions of the procedures used in SMTP: + session initiation, the mail transaction, forwarding mail, verifying + mailbox names and expanding mailing lists, and the opening and + closing exchanges. Comments on relaying, a note on mail domains, and + a discussion of changing roles are included at the end of this + section. Several complete scenarios are presented in appendix D. + +3.1 Session Initiation + + An SMTP session is initiated when a client opens a connection to a + server and the server responds with an opening message. + + SMTP server implementations MAY include identification of their + software and version information in the connection greeting reply + after the 220 code, a practice that permits more efficient isolation + and repair of any problems. Implementations MAY make provision for + SMTP servers to disable the software and version announcement where + it causes security concerns. While some systems also identify their + contact point for mail problems, this is not a substitute for + maintaining the required "postmaster" address (see section 4.5.1). + + The SMTP protocol allows a server to formally reject a transaction + while still allowing the initial connection as follows: a 554 + response MAY be given in the initial connection opening message + instead of the 220. A server taking this approach MUST still wait + for the client to send a QUIT (see section 4.1.1.10) before closing + the connection and SHOULD respond to any intervening commands with + + + +Klensin Standards Track [Page 15] + +RFC 2821 Simple Mail Transfer Protocol April 2001 + + + "503 bad sequence of commands". Since an attempt to make an SMTP + connection to such a system is probably in error, a server returning + a 554 response on connection opening SHOULD provide enough + information in the reply text to facilitate debugging of the sending + system. + +3.2 Client Initiation + + Once the server has sent the welcoming message and the client has + received it, the client normally sends the EHLO command to the + server, indicating the client's identity. In addition to opening the + session, use of EHLO indicates that the client is able to process + service extensions and requests that the server provide a list of the + extensions it supports. Older SMTP systems which are unable to + support service extensions and contemporary clients which do not + require service extensions in the mail session being initiated, MAY + use HELO instead of EHLO. Servers MUST NOT return the extended + EHLO-style response to a HELO command. For a particular connection + attempt, if the server returns a "command not recognized" response to + EHLO, the client SHOULD be able to fall back and send HELO. + + In the EHLO command the host sending the command identifies itself; + the command may be interpreted as saying "Hello, I am " (and, + in the case of EHLO, "and I support service extension requests"). + +3.3 Mail Transactions + + There are three steps to SMTP mail transactions. The transaction + starts with a MAIL command which gives the sender identification. + (In general, the MAIL command may be sent only when no mail + transaction is in progress; see section 4.1.4.) A series of one or + more RCPT commands follows giving the receiver information. Then a + DATA command initiates transfer of the mail data and is terminated by + the "end of mail" data indicator, which also confirms the + transaction. + + The first step in the procedure is the MAIL command. + + MAIL FROM: [SP ] + + This command tells the SMTP-receiver that a new mail transaction is + starting and to reset all its state tables and buffers, including any + recipients or mail data. The portion of the first or + only argument contains the source mailbox (between "<" and ">" + brackets), which can be used to report errors (see section 4.2 for a + discussion of error reporting). If accepted, the SMTP server returns + a 250 OK reply. If the mailbox specification is not acceptable for + some reason, the server MUST return a reply indicating whether the + + + +Klensin Standards Track [Page 16] + +RFC 2821 Simple Mail Transfer Protocol April 2001 + + + failure is permanent (i.e., will occur again if the client tries to + send the same address again) or temporary (i.e., the address might be + accepted if the client tries again later). Despite the apparent + scope of this requirement, there are circumstances in which the + acceptability of the reverse-path may not be determined until one or + more forward-paths (in RCPT commands) can be examined. In those + cases, the server MAY reasonably accept the reverse-path (with a 250 + reply) and then report problems after the forward-paths are received + and examined. Normally, failures produce 550 or 553 replies. + + Historically, the can contain more than just a + mailbox, however, contemporary systems SHOULD NOT use source routing + (see appendix C). + + The optional are associated with negotiated SMTP + service extensions (see section 2.2). + + The second step in the procedure is the RCPT command. + + RCPT TO: [ SP ] + + The first or only argument to this command includes a forward-path + (normally a mailbox and domain, always surrounded by "<" and ">" + brackets) identifying one recipient. If accepted, the SMTP server + returns a 250 OK reply and stores the forward-path. If the recipient + is known not to be a deliverable address, the SMTP server returns a + 550 reply, typically with a string such as "no such user - " and the + mailbox name (other circumstances and reply codes are possible). + This step of the procedure can be repeated any number of times. + + The can contain more than just a mailbox. + Historically, the can be a source routing list of + hosts and the destination mailbox, however, contemporary SMTP clients + SHOULD NOT utilize source routes (see appendix C). Servers MUST be + prepared to encounter a list of source routes in the forward path, + but SHOULD ignore the routes or MAY decline to support the relaying + they imply. Similarly, servers MAY decline to accept mail that is + destined for other hosts or systems. These restrictions make a + server useless as a relay for clients that do not support full SMTP + functionality. Consequently, restricted-capability clients MUST NOT + assume that any SMTP server on the Internet can be used as their mail + processing (relaying) site. If a RCPT command appears without a + previous MAIL command, the server MUST return a 503 "Bad sequence of + commands" response. The optional are associated + with negotiated SMTP service extensions (see section 2.2). + + The third step in the procedure is the DATA command (or some + alternative specified in a service extension). + + + +Klensin Standards Track [Page 17] + +RFC 2821 Simple Mail Transfer Protocol April 2001 + + + DATA + + If accepted, the SMTP server returns a 354 Intermediate reply and + considers all succeeding lines up to but not including the end of + mail data indicator to be the message text. When the end of text is + successfully received and stored the SMTP-receiver sends a 250 OK + reply. + + Since the mail data is sent on the transmission channel, the end of + mail data must be indicated so that the command and reply dialog can + be resumed. SMTP indicates the end of the mail data by sending a + line containing only a "." (period or full stop). A transparency + procedure is used to prevent this from interfering with the user's + text (see section 4.5.2). + + The end of mail data indicator also confirms the mail transaction and + tells the SMTP server to now process the stored recipients and mail + data. If accepted, the SMTP server returns a 250 OK reply. The DATA + command can fail at only two points in the protocol exchange: + + - If there was no MAIL, or no RCPT, command, or all such commands + were rejected, the server MAY return a "command out of sequence" + (503) or "no valid recipients" (554) reply in response to the DATA + command. If one of those replies (or any other 5yz reply) is + received, the client MUST NOT send the message data; more + generally, message data MUST NOT be sent unless a 354 reply is + received. + + - If the verb is initially accepted and the 354 reply issued, the + DATA command should fail only if the mail transaction was + incomplete (for example, no recipients), or if resources were + unavailable (including, of course, the server unexpectedly + becoming unavailable), or if the server determines that the + message should be rejected for policy or other reasons. + + However, in practice, some servers do not perform recipient + verification until after the message text is received. These servers + SHOULD treat a failure for one or more recipients as a "subsequent + failure" and return a mail message as discussed in section 6. Using + a "550 mailbox not found" (or equivalent) reply code after the data + are accepted makes it difficult or impossible for the client to + determine which recipients failed. + + When RFC 822 format [7, 32] is being used, the mail data include the + memo header items such as Date, Subject, To, Cc, From. Server SMTP + systems SHOULD NOT reject messages based on perceived defects in the + RFC 822 or MIME [12] message header or message body. In particular, + + + + +Klensin Standards Track [Page 18] + +RFC 2821 Simple Mail Transfer Protocol April 2001 + + + they MUST NOT reject messages in which the numbers of Resent-fields + do not match or Resent-to appears without Resent-from and/or Resent- + date. + + Mail transaction commands MUST be used in the order discussed above. + +3.4 Forwarding for Address Correction or Updating + + Forwarding support is most often required to consolidate and simplify + addresses within, or relative to, some enterprise and less frequently + to establish addresses to link a person's prior address with current + one. Silent forwarding of messages (without server notification to + the sender), for security or non-disclosure purposes, is common in + the contemporary Internet. + + In both the enterprise and the "new address" cases, information + hiding (and sometimes security) considerations argue against exposure + of the "final" address through the SMTP protocol as a side-effect of + the forwarding activity. This may be especially important when the + final address may not even be reachable by the sender. Consequently, + the "forwarding" mechanisms described in section 3.2 of RFC 821, and + especially the 251 (corrected destination) and 551 reply codes from + RCPT must be evaluated carefully by implementers and, when they are + available, by those configuring systems. + + In particular: + + * Servers MAY forward messages when they are aware of an address + change. When they do so, they MAY either provide address-updating + information with a 251 code, or may forward "silently" and return + a 250 code. But, if a 251 code is used, they MUST NOT assume that + the client will actually update address information or even return + that information to the user. + + Alternately, + + * Servers MAY reject or bounce messages when they are not + deliverable when addressed. When they do so, they MAY either + provide address-updating information with a 551 code, or may + reject the message as undeliverable with a 550 code and no + address-specific information. But, if a 551 code is used, they + MUST NOT assume that the client will actually update address + information or even return that information to the user. + + SMTP server implementations that support the 251 and/or 551 reply + codes are strongly encouraged to provide configuration mechanisms so + that sites which conclude that they would undesirably disclose + information can disable or restrict their use. + + + +Klensin Standards Track [Page 19] + +RFC 2821 Simple Mail Transfer Protocol April 2001 + + +3.5 Commands for Debugging Addresses + +3.5.1 Overview + + SMTP provides commands to verify a user name or obtain the content of + a mailing list. This is done with the VRFY and EXPN commands, which + have character string arguments. Implementations SHOULD support VRFY + and EXPN (however, see section 3.5.2 and 7.3). + + For the VRFY command, the string is a user name or a user name and + domain (see below). If a normal (i.e., 250) response is returned, + the response MAY include the full name of the user and MUST include + the mailbox of the user. It MUST be in either of the following + forms: + + User Name + local-part@domain + + When a name that is the argument to VRFY could identify more than one + mailbox, the server MAY either note the ambiguity or identify the + alternatives. In other words, any of the following are legitimate + response to VRFY: + + 553 User ambiguous + + or + + 553- Ambiguous; Possibilities are + 553-Joe Smith + 553-Harry Smith + 553 Melvin Smith + + or + + 553-Ambiguous; Possibilities + 553- + 553- + 553 + + Under normal circumstances, a client receiving a 553 reply would be + expected to expose the result to the user. Use of exactly the forms + given, and the "user ambiguous" or "ambiguous" keywords, possibly + supplemented by extended reply codes such as those described in [34], + will facilitate automated translation into other languages as needed. + Of course, a client that was highly automated or that was operating + in another language than English, might choose to try to translate + the response, to return some other indication to the user than the + + + + +Klensin Standards Track [Page 20] + +RFC 2821 Simple Mail Transfer Protocol April 2001 + + + literal text of the reply, or to take some automated action such as + consulting a directory service for additional information before + reporting to the user. + + For the EXPN command, the string identifies a mailing list, and the + successful (i.e., 250) multiline response MAY include the full name + of the users and MUST give the mailboxes on the mailing list. + + In some hosts the distinction between a mailing list and an alias for + a single mailbox is a bit fuzzy, since a common data structure may + hold both types of entries, and it is possible to have mailing lists + containing only one mailbox. If a request is made to apply VRFY to a + mailing list, a positive response MAY be given if a message so + addressed would be delivered to everyone on the list, otherwise an + error SHOULD be reported (e.g., "550 That is a mailing list, not a + user" or "252 Unable to verify members of mailing list"). If a + request is made to expand a user name, the server MAY return a + positive response consisting of a list containing one name, or an + error MAY be reported (e.g., "550 That is a user name, not a mailing + list"). + + In the case of a successful multiline reply (normal for EXPN) exactly + one mailbox is to be specified on each line of the reply. The case + of an ambiguous request is discussed above. + + "User name" is a fuzzy term and has been used deliberately. An + implementation of the VRFY or EXPN commands MUST include at least + recognition of local mailboxes as "user names". However, since + current Internet practice often results in a single host handling + mail for multiple domains, hosts, especially hosts that provide this + functionality, SHOULD accept the "local-part@domain" form as a "user + name"; hosts MAY also choose to recognize other strings as "user + names". + + The case of expanding a mailbox list requires a multiline reply, such + as: + + C: EXPN Example-People + S: 250-Jon Postel + S: 250-Fred Fonebone + S: 250 Sam Q. Smith + + or + + C: EXPN Executive-Washroom-List + S: 550 Access Denied to You. + + + + + +Klensin Standards Track [Page 21] + +RFC 2821 Simple Mail Transfer Protocol April 2001 + + + The character string arguments of the VRFY and EXPN commands cannot + be further restricted due to the variety of implementations of the + user name and mailbox list concepts. On some systems it may be + appropriate for the argument of the EXPN command to be a file name + for a file containing a mailing list, but again there are a variety + of file naming conventions in the Internet. Similarly, historical + variations in what is returned by these commands are such that the + response SHOULD be interpreted very carefully, if at all, and SHOULD + generally only be used for diagnostic purposes. + +3.5.2 VRFY Normal Response + + When normal (2yz or 551) responses are returned from a VRFY or EXPN + request, the reply normally includes the mailbox name, i.e., + "", where "domain" is a fully qualified domain + name, MUST appear in the syntax. In circumstances exceptional enough + to justify violating the intent of this specification, free-form text + MAY be returned. In order to facilitate parsing by both computers + and people, addresses SHOULD appear in pointed brackets. When + addresses, rather than free-form debugging information, are returned, + EXPN and VRFY MUST return only valid domain addresses that are usable + in SMTP RCPT commands. Consequently, if an address implies delivery + to a program or other system, the mailbox name used to reach that + target MUST be given. Paths (explicit source routes) MUST NOT be + returned by VRFY or EXPN. + + Server implementations SHOULD support both VRFY and EXPN. For + security reasons, implementations MAY provide local installations a + way to disable either or both of these commands through configuration + options or the equivalent. When these commands are supported, they + are not required to work across relays when relaying is supported. + Since they were both optional in RFC 821, they MUST be listed as + service extensions in an EHLO response, if they are supported. + +3.5.3 Meaning of VRFY or EXPN Success Response + + A server MUST NOT return a 250 code in response to a VRFY or EXPN + command unless it has actually verified the address. In particular, + a server MUST NOT return 250 if all it has done is to verify that the + syntax given is valid. In that case, 502 (Command not implemented) + or 500 (Syntax error, command unrecognized) SHOULD be returned. As + stated elsewhere, implementation (in the sense of actually validating + addresses and returning information) of VRFY and EXPN are strongly + recommended. Hence, implementations that return 500 or 502 for VRFY + are not in full compliance with this specification. + + + + + + +Klensin Standards Track [Page 22] + +RFC 2821 Simple Mail Transfer Protocol April 2001 + + + There may be circumstances where an address appears to be valid but + cannot reasonably be verified in real time, particularly when a + server is acting as a mail exchanger for another server or domain. + "Apparent validity" in this case would normally involve at least + syntax checking and might involve verification that any domains + specified were ones to which the host expected to be able to relay + mail. In these situations, reply code 252 SHOULD be returned. These + cases parallel the discussion of RCPT verification discussed in + section 2.1. Similarly, the discussion in section 3.4 applies to the + use of reply codes 251 and 551 with VRFY (and EXPN) to indicate + addresses that are recognized but that would be forwarded or bounced + were mail received for them. Implementations generally SHOULD be + more aggressive about address verification in the case of VRFY than + in the case of RCPT, even if it takes a little longer to do so. + +3.5.4 Semantics and Applications of EXPN + + EXPN is often very useful in debugging and understanding problems + with mailing lists and multiple-target-address aliases. Some systems + have attempted to use source expansion of mailing lists as a means of + eliminating duplicates. The propagation of aliasing systems with + mail on the Internet, for hosts (typically with MX and CNAME DNS + records), for mailboxes (various types of local host aliases), and in + various proxying arrangements, has made it nearly impossible for + these strategies to work consistently, and mail systems SHOULD NOT + attempt them. + +3.6 Domains + + Only resolvable, fully-qualified, domain names (FQDNs) are permitted + when domain names are used in SMTP. In other words, names that can + be resolved to MX RRs or A RRs (as discussed in section 5) are + permitted, as are CNAME RRs whose targets can be resolved, in turn, + to MX or A RRs. Local nicknames or unqualified names MUST NOT be + used. There are two exceptions to the rule requiring FQDNs: + + - The domain name given in the EHLO command MUST BE either a primary + host name (a domain name that resolves to an A RR) or, if the host + has no name, an address literal as described in section 4.1.1.1. + + - The reserved mailbox name "postmaster" may be used in a RCPT + command without domain qualification (see section 4.1.1.3) and + MUST be accepted if so used. + + + + + + + + +Klensin Standards Track [Page 23] + +RFC 2821 Simple Mail Transfer Protocol April 2001 + + +3.7 Relaying + + In general, the availability of Mail eXchanger records in the domain + name system [22, 27] makes the use of explicit source routes in the + Internet mail system unnecessary. Many historical problems with + their interpretation have made their use undesirable. SMTP clients + SHOULD NOT generate explicit source routes except under unusual + circumstances. SMTP servers MAY decline to act as mail relays or to + accept addresses that specify source routes. When route information + is encountered, SMTP servers are also permitted to ignore the route + information and simply send to the final destination specified as the + last element in the route and SHOULD do so. There has been an + invalid practice of using names that do not appear in the DNS as + destination names, with the senders counting on the intermediate + hosts specified in source routing to resolve any problems. If source + routes are stripped, this practice will cause failures. This is one + of several reasons why SMTP clients MUST NOT generate invalid source + routes or depend on serial resolution of names. + + When source routes are not used, the process described in RFC 821 for + constructing a reverse-path from the forward-path is not applicable + and the reverse-path at the time of delivery will simply be the + address that appeared in the MAIL command. + + A relay SMTP server is usually the target of a DNS MX record that + designates it, rather than the final delivery system. The relay + server may accept or reject the task of relaying the mail in the same + way it accepts or rejects mail for a local user. If it accepts the + task, it then becomes an SMTP client, establishes a transmission + channel to the next SMTP server specified in the DNS (according to + the rules in section 5), and sends it the mail. If it declines to + relay mail to a particular address for policy reasons, a 550 response + SHOULD be returned. + + Many mail-sending clients exist, especially in conjunction with + facilities that receive mail via POP3 or IMAP, that have limited + capability to support some of the requirements of this specification, + such as the ability to queue messages for subsequent delivery + attempts. For these clients, it is common practice to make private + arrangements to send all messages to a single server for processing + and subsequent distribution. SMTP, as specified here, is not ideally + suited for this role, and work is underway on standardized mail + submission protocols that might eventually supercede the current + practices. In any event, because these arrangements are private and + fall outside the scope of this specification, they are not described + here. + + + + + +Klensin Standards Track [Page 24] + +RFC 2821 Simple Mail Transfer Protocol April 2001 + + + It is important to note that MX records can point to SMTP servers + which act as gateways into other environments, not just SMTP relays + and final delivery systems; see sections 3.8 and 5. + + If an SMTP server has accepted the task of relaying the mail and + later finds that the destination is incorrect or that the mail cannot + be delivered for some other reason, then it MUST construct an + "undeliverable mail" notification message and send it to the + originator of the undeliverable mail (as indicated by the reverse- + path). Formats specified for non-delivery reports by other standards + (see, for example, [24, 25]) SHOULD be used if possible. + + This notification message must be from the SMTP server at the relay + host or the host that first determines that delivery cannot be + accomplished. Of course, SMTP servers MUST NOT send notification + messages about problems transporting notification messages. One way + to prevent loops in error reporting is to specify a null reverse-path + in the MAIL command of a notification message. When such a message + is transmitted the reverse-path MUST be set to null (see section + 4.5.5 for additional discussion). A MAIL command with a null + reverse-path appears as follows: + + MAIL FROM:<> + + As discussed in section 2.4.1, a relay SMTP has no need to inspect or + act upon the headers or body of the message data and MUST NOT do so + except to add its own "Received:" header (section 4.4) and, + optionally, to attempt to detect looping in the mail system (see + section 6.2). + +3.8 Mail Gatewaying + + While the relay function discussed above operates within the Internet + SMTP transport service environment, MX records or various forms of + explicit routing may require that an intermediate SMTP server perform + a translation function between one transport service and another. As + discussed in section 2.3.8, when such a system is at the boundary + between two transport service environments, we refer to it as a + "gateway" or "gateway SMTP". + + Gatewaying mail between different mail environments, such as + different mail formats and protocols, is complex and does not easily + yield to standardization. However, some general requirements may be + given for a gateway between the Internet and another mail + environment. + + + + + + +Klensin Standards Track [Page 25] + +RFC 2821 Simple Mail Transfer Protocol April 2001 + + +3.8.1 Header Fields in Gatewaying + + Header fields MAY be rewritten when necessary as messages are + gatewayed across mail environment boundaries. This may involve + inspecting the message body or interpreting the local-part of the + destination address in spite of the prohibitions in section 2.4.1. + + Other mail systems gatewayed to the Internet often use a subset of + RFC 822 headers or provide similar functionality with a different + syntax, but some of these mail systems do not have an equivalent to + the SMTP envelope. Therefore, when a message leaves the Internet + environment, it may be necessary to fold the SMTP envelope + information into the message header. A possible solution would be to + create new header fields to carry the envelope information (e.g., + "X-SMTP-MAIL:" and "X-SMTP-RCPT:"); however, this would require + changes in mail programs in foreign environments and might risk + disclosure of private information (see section 7.2). + +3.8.2 Received Lines in Gatewaying + + When forwarding a message into or out of the Internet environment, a + gateway MUST prepend a Received: line, but it MUST NOT alter in any + way a Received: line that is already in the header. + + "Received:" fields of messages originating from other environments + may not conform exactly to this specification. However, the most + important use of Received: lines is for debugging mail faults, and + this debugging can be severely hampered by well-meaning gateways that + try to "fix" a Received: line. As another consequence of trace + fields arising in non-SMTP environments, receiving systems MUST NOT + reject mail based on the format of a trace field and SHOULD be + extremely robust in the light of unexpected information or formats in + those fields. + + The gateway SHOULD indicate the environment and protocol in the "via" + clauses of Received field(s) that it supplies. + +3.8.3 Addresses in Gatewaying + + From the Internet side, the gateway SHOULD accept all valid address + formats in SMTP commands and in RFC 822 headers, and all valid RFC + 822 messages. Addresses and headers generated by gateways MUST + conform to applicable Internet standards (including this one and RFC + 822). Gateways are, of course, subject to the same rules for + handling source routes as those described for other SMTP systems in + section 3.3. + + + + + +Klensin Standards Track [Page 26] + +RFC 2821 Simple Mail Transfer Protocol April 2001 + + +3.8.4 Other Header Fields in Gatewaying + + The gateway MUST ensure that all header fields of a message that it + forwards into the Internet mail environment meet the requirements for + Internet mail. In particular, all addresses in "From:", "To:", + "Cc:", etc., fields MUST be transformed (if necessary) to satisfy RFC + 822 syntax, MUST reference only fully-qualified domain names, and + MUST be effective and useful for sending replies. The translation + algorithm used to convert mail from the Internet protocols to another + environment's protocol SHOULD ensure that error messages from the + foreign mail environment are delivered to the return path from the + SMTP envelope, not to the sender listed in the "From:" field (or + other fields) of the RFC 822 message. + +3.8.5 Envelopes in Gatewaying + + Similarly, when forwarding a message from another environment into + the Internet, the gateway SHOULD set the envelope return path in + accordance with an error message return address, if supplied by the + foreign environment. If the foreign environment has no equivalent + concept, the gateway must select and use a best approximation, with + the message originator's address as the default of last resort. + +3.9 Terminating Sessions and Connections + + An SMTP connection is terminated when the client sends a QUIT + command. The server responds with a positive reply code, after which + it closes the connection. + + An SMTP server MUST NOT intentionally close the connection except: + + - After receiving a QUIT command and responding with a 221 reply. + + - After detecting the need to shut down the SMTP service and + returning a 421 response code. This response code can be issued + after the server receives any command or, if necessary, + asynchronously from command receipt (on the assumption that the + client will receive it after the next command is issued). + + In particular, a server that closes connections in response to + commands that are not understood is in violation of this + specification. Servers are expected to be tolerant of unknown + commands, issuing a 500 reply and awaiting further instructions from + the client. + + + + + + + +Klensin Standards Track [Page 27] + +RFC 2821 Simple Mail Transfer Protocol April 2001 + + + An SMTP server which is forcibly shut down via external means SHOULD + attempt to send a line containing a 421 response code to the SMTP + client before exiting. The SMTP client will normally read the 421 + response code after sending its next command. + + SMTP clients that experience a connection close, reset, or other + communications failure due to circumstances not under their control + (in violation of the intent of this specification but sometimes + unavoidable) SHOULD, to maintain the robustness of the mail system, + treat the mail transaction as if a 451 response had been received and + act accordingly. + +3.10 Mailing Lists and Aliases + + An SMTP-capable host SHOULD support both the alias and the list + models of address expansion for multiple delivery. When a message is + delivered or forwarded to each address of an expanded list form, the + return address in the envelope ("MAIL FROM:") MUST be changed to be + the address of a person or other entity who administers the list. + However, in this case, the message header [32] MUST be left + unchanged; in particular, the "From" field of the message header is + unaffected. + + An important mail facility is a mechanism for multi-destination + delivery of a single message, by transforming (or "expanding" or + "exploding") a pseudo-mailbox address into a list of destination + mailbox addresses. When a message is sent to such a pseudo-mailbox + (sometimes called an "exploder"), copies are forwarded or + redistributed to each mailbox in the expanded list. Servers SHOULD + simply utilize the addresses on the list; application of heuristics + or other matching rules to eliminate some addresses, such as that of + the originator, is strongly discouraged. We classify such a pseudo- + mailbox as an "alias" or a "list", depending upon the expansion + rules. + +3.10.1 Alias + + To expand an alias, the recipient mailer simply replaces the pseudo- + mailbox address in the envelope with each of the expanded addresses + in turn; the rest of the envelope and the message body are left + unchanged. The message is then delivered or forwarded to each + expanded address. + +3.10.2 List + + A mailing list may be said to operate by "redistribution" rather than + by "forwarding". To expand a list, the recipient mailer replaces the + pseudo-mailbox address in the envelope with all of the expanded + + + +Klensin Standards Track [Page 28] + +RFC 2821 Simple Mail Transfer Protocol April 2001 + + + addresses. The return address in the envelope is changed so that all + error messages generated by the final deliveries will be returned to + a list administrator, not to the message originator, who generally + has no control over the contents of the list and will typically find + error messages annoying. + +4. The SMTP Specifications + +4.1 SMTP Commands + +4.1.1 Command Semantics and Syntax + + The SMTP commands define the mail transfer or the mail system + function requested by the user. SMTP commands are character strings + terminated by . The commands themselves are alphabetic + characters terminated by if parameters follow and + otherwise. (In the interest of improved interoperability, SMTP + receivers are encouraged to tolerate trailing white space before the + terminating .) The syntax of the local part of a mailbox must + conform to receiver site conventions and the syntax specified in + section 4.1.2. The SMTP commands are discussed below. The SMTP + replies are discussed in section 4.2. + + A mail transaction involves several data objects which are + communicated as arguments to different commands. The reverse-path is + the argument of the MAIL command, the forward-path is the argument of + the RCPT command, and the mail data is the argument of the DATA + command. These arguments or data objects must be transmitted and + held pending the confirmation communicated by the end of mail data + indication which finalizes the transaction. The model for this is + that distinct buffers are provided to hold the types of data objects, + that is, there is a reverse-path buffer, a forward-path buffer, and a + mail data buffer. Specific commands cause information to be appended + to a specific buffer, or cause one or more buffers to be cleared. + + Several commands (RSET, DATA, QUIT) are specified as not permitting + parameters. In the absence of specific extensions offered by the + server and accepted by the client, clients MUST NOT send such + parameters and servers SHOULD reject commands containing them as + having invalid syntax. + +4.1.1.1 Extended HELLO (EHLO) or HELLO (HELO) + + These commands are used to identify the SMTP client to the SMTP + server. The argument field contains the fully-qualified domain name + of the SMTP client if one is available. In situations in which the + SMTP client system does not have a meaningful domain name (e.g., when + its address is dynamically allocated and no reverse mapping record is + + + +Klensin Standards Track [Page 29] + +RFC 2821 Simple Mail Transfer Protocol April 2001 + + + available), the client SHOULD send an address literal (see section + 4.1.3), optionally followed by information that will help to identify + the client system. y The SMTP server identifies itself to the SMTP + client in the connection greeting reply and in the response to this + command. + + A client SMTP SHOULD start an SMTP session by issuing the EHLO + command. If the SMTP server supports the SMTP service extensions it + will give a successful response, a failure response, or an error + response. If the SMTP server, in violation of this specification, + does not support any SMTP service extensions it will generate an + error response. Older client SMTP systems MAY, as discussed above, + use HELO (as specified in RFC 821) instead of EHLO, and servers MUST + support the HELO command and reply properly to it. In any event, a + client MUST issue HELO or EHLO before starting a mail transaction. + + These commands, and a "250 OK" reply to one of them, confirm that + both the SMTP client and the SMTP server are in the initial state, + that is, there is no transaction in progress and all state tables and + buffers are cleared. + + Syntax: + + ehlo = "EHLO" SP Domain CRLF + helo = "HELO" SP Domain CRLF + + Normally, the response to EHLO will be a multiline reply. Each line + of the response contains a keyword and, optionally, one or more + parameters. Following the normal syntax for multiline replies, these + keyworks follow the code (250) and a hyphen for all but the last + line, and the code and a space for the last line. The syntax for a + positive response, using the ABNF notation and terminal symbols of + [8], is: + + ehlo-ok-rsp = ( "250" domain [ SP ehlo-greet ] CRLF ) + / ( "250-" domain [ SP ehlo-greet ] CRLF + *( "250-" ehlo-line CRLF ) + "250" SP ehlo-line CRLF ) + + ehlo-greet = 1*(%d0-9 / %d11-12 / %d14-127) + ; string of any characters other than CR or LF + + ehlo-line = ehlo-keyword *( SP ehlo-param ) + + ehlo-keyword = (ALPHA / DIGIT) *(ALPHA / DIGIT / "-") + ; additional syntax of ehlo-params depends on + ; ehlo-keyword + + + + +Klensin Standards Track [Page 30] + +RFC 2821 Simple Mail Transfer Protocol April 2001 + + + ehlo-param = 1*(%d33-127) + ; any CHAR excluding and all + ; control characters (US-ASCII 0-31 inclusive) + + Although EHLO keywords may be specified in upper, lower, or mixed + case, they MUST always be recognized and processed in a case- + insensitive manner. This is simply an extension of practices + specified in RFC 821 and section 2.4.1. + +4.1.1.2 MAIL (MAIL) + + This command is used to initiate a mail transaction in which the mail + data is delivered to an SMTP server which may, in turn, deliver it to + one or more mailboxes or pass it on to another system (possibly using + SMTP). The argument field contains a reverse-path and may contain + optional parameters. In general, the MAIL command may be sent only + when no mail transaction is in progress, see section 4.1.4. + + The reverse-path consists of the sender mailbox. Historically, that + mailbox might optionally have been preceded by a list of hosts, but + that behavior is now deprecated (see appendix C). In some types of + reporting messages for which a reply is likely to cause a mail loop + (for example, mail delivery and nondelivery notifications), the + reverse-path may be null (see section 3.7). + + This command clears the reverse-path buffer, the forward-path buffer, + and the mail data buffer; and inserts the reverse-path information + from this command into the reverse-path buffer. + + If service extensions were negotiated, the MAIL command may also + carry parameters associated with a particular service extension. + + Syntax: + + "MAIL FROM:" ("<>" / Reverse-Path) + [SP Mail-parameters] CRLF + +4.1.1.3 RECIPIENT (RCPT) + + This command is used to identify an individual recipient of the mail + data; multiple recipients are specified by multiple use of this + command. The argument field contains a forward-path and may contain + optional parameters. + + The forward-path normally consists of the required destination + mailbox. Sending systems SHOULD not generate the optional list of + hosts known as a source route. Receiving systems MUST recognize + + + + +Klensin Standards Track [Page 31] + +RFC 2821 Simple Mail Transfer Protocol April 2001 + + + source route syntax but SHOULD strip off the source route + specification and utilize the domain name associated with the mailbox + as if the source route had not been provided. + + Similarly, relay hosts SHOULD strip or ignore source routes, and + names MUST NOT be copied into the reverse-path. When mail reaches + its ultimate destination (the forward-path contains only a + destination mailbox), the SMTP server inserts it into the destination + mailbox in accordance with its host mail conventions. + + For example, mail received at relay host xyz.com with envelope + commands + + MAIL FROM: + RCPT TO:<@hosta.int,@jkl.org:userc@d.bar.org> + + will normally be sent directly on to host d.bar.org with envelope + commands + + MAIL FROM: + RCPT TO: + + As provided in appendix C, xyz.com MAY also choose to relay the + message to hosta.int, using the envelope commands + + MAIL FROM: + RCPT TO:<@hosta.int,@jkl.org:userc@d.bar.org> + + or to jkl.org, using the envelope commands + + MAIL FROM: + RCPT TO:<@jkl.org:userc@d.bar.org> + + Of course, since hosts are not required to relay mail at all, xyz.com + may also reject the message entirely when the RCPT command is + received, using a 550 code (since this is a "policy reason"). + + If service extensions were negotiated, the RCPT command may also + carry parameters associated with a particular service extension + offered by the server. The client MUST NOT transmit parameters other + than those associated with a service extension offered by the server + in its EHLO response. + +Syntax: + "RCPT TO:" ("" / "" / Forward-Path) + [SP Rcpt-parameters] CRLF + + + + + +Klensin Standards Track [Page 32] + +RFC 2821 Simple Mail Transfer Protocol April 2001 + + +4.1.1.4 DATA (DATA) + + The receiver normally sends a 354 response to DATA, and then treats + the lines (strings ending in sequences, as described in + section 2.3.7) following the command as mail data from the sender. + This command causes the mail data to be appended to the mail data + buffer. The mail data may contain any of the 128 ASCII character + codes, although experience has indicated that use of control + characters other than SP, HT, CR, and LF may cause problems and + SHOULD be avoided when possible. + + The mail data is terminated by a line containing only a period, that + is, the character sequence "." (see section 4.5.2). This + is the end of mail data indication. Note that the first of + this terminating sequence is also the that ends the final line + of the data (message text) or, if there was no data, ends the DATA + command itself. An extra MUST NOT be added, as that would + cause an empty line to be added to the message. The only exception + to this rule would arise if the message body were passed to the + originating SMTP-sender with a final "line" that did not end in + ; in that case, the originating SMTP system MUST either reject + the message as invalid or add in order to have the receiving + SMTP server recognize the "end of data" condition. + + The custom of accepting lines ending only in , as a concession to + non-conforming behavior on the part of some UNIX systems, has proven + to cause more interoperability problems than it solves, and SMTP + server systems MUST NOT do this, even in the name of improved + robustness. In particular, the sequence "." (bare line + feeds, without carriage returns) MUST NOT be treated as equivalent to + . as the end of mail data indication. + + Receipt of the end of mail data indication requires the server to + process the stored mail transaction information. This processing + consumes the information in the reverse-path buffer, the forward-path + buffer, and the mail data buffer, and on the completion of this + command these buffers are cleared. If the processing is successful, + the receiver MUST send an OK reply. If the processing fails the + receiver MUST send a failure reply. The SMTP model does not allow + for partial failures at this point: either the message is accepted by + the server for delivery and a positive response is returned or it is + not accepted and a failure reply is returned. In sending a positive + completion reply to the end of data indication, the receiver takes + full responsibility for the message (see section 6.1). Errors that + are diagnosed subsequently MUST be reported in a mail message, as + discussed in section 4.4. + + + + + +Klensin Standards Track [Page 33] + +RFC 2821 Simple Mail Transfer Protocol April 2001 + + + When the SMTP server accepts a message either for relaying or for + final delivery, it inserts a trace record (also referred to + interchangeably as a "time stamp line" or "Received" line) at the top + of the mail data. This trace record indicates the identity of the + host that sent the message, the identity of the host that received + the message (and is inserting this time stamp), and the date and time + the message was received. Relayed messages will have multiple time + stamp lines. Details for formation of these lines, including their + syntax, is specified in section 4.4. + + Additional discussion about the operation of the DATA command appears + in section 3.3. + + Syntax: + "DATA" CRLF + +4.1.1.5 RESET (RSET) + + This command specifies that the current mail transaction will be + aborted. Any stored sender, recipients, and mail data MUST be + discarded, and all buffers and state tables cleared. The receiver + MUST send a "250 OK" reply to a RSET command with no arguments. A + reset command may be issued by the client at any time. It is + effectively equivalent to a NOOP (i.e., if has no effect) if issued + immediately after EHLO, before EHLO is issued in the session, after + an end-of-data indicator has been sent and acknowledged, or + immediately before a QUIT. An SMTP server MUST NOT close the + connection as the result of receiving a RSET; that action is reserved + for QUIT (see section 4.1.1.10). + + Since EHLO implies some additional processing and response by the + server, RSET will normally be more efficient than reissuing that + command, even though the formal semantics are the same. + + There are circumstances, contrary to the intent of this + specification, in which an SMTP server may receive an indication that + the underlying TCP connection has been closed or reset. To preserve + the robustness of the mail system, SMTP servers SHOULD be prepared + for this condition and SHOULD treat it as if a QUIT had been received + before the connection disappeared. + + Syntax: + "RSET" CRLF + + + + + + + + +Klensin Standards Track [Page 34] + +RFC 2821 Simple Mail Transfer Protocol April 2001 + + +4.1.1.6 VERIFY (VRFY) + + This command asks the receiver to confirm that the argument + identifies a user or mailbox. If it is a user name, information is + returned as specified in section 3.5. + + This command has no effect on the reverse-path buffer, the forward- + path buffer, or the mail data buffer. + + Syntax: + "VRFY" SP String CRLF + +4.1.1.7 EXPAND (EXPN) + + This command asks the receiver to confirm that the argument + identifies a mailing list, and if so, to return the membership of + that list. If the command is successful, a reply is returned + containing information as described in section 3.5. This reply will + have multiple lines except in the trivial case of a one-member list. + + This command has no effect on the reverse-path buffer, the forward- + path buffer, or the mail data buffer and may be issued at any time. + + Syntax: + "EXPN" SP String CRLF + +4.1.1.8 HELP (HELP) + + This command causes the server to send helpful information to the + client. The command MAY take an argument (e.g., any command name) + and return more specific information as a response. + + This command has no effect on the reverse-path buffer, the forward- + path buffer, or the mail data buffer and may be issued at any time. + + SMTP servers SHOULD support HELP without arguments and MAY support it + with arguments. + + Syntax: + "HELP" [ SP String ] CRLF + +4.1.1.9 NOOP (NOOP) + + This command does not affect any parameters or previously entered + commands. It specifies no action other than that the receiver send + an OK reply. + + + + + +Klensin Standards Track [Page 35] + +RFC 2821 Simple Mail Transfer Protocol April 2001 + + + This command has no effect on the reverse-path buffer, the forward- + path buffer, or the mail data buffer and may be issued at any time. + If a parameter string is specified, servers SHOULD ignore it. + + Syntax: + "NOOP" [ SP String ] CRLF + +4.1.1.10 QUIT (QUIT) + + This command specifies that the receiver MUST send an OK reply, and + then close the transmission channel. + + The receiver MUST NOT intentionally close the transmission channel + until it receives and replies to a QUIT command (even if there was an + error). The sender MUST NOT intentionally close the transmission + channel until it sends a QUIT command and SHOULD wait until it + receives the reply (even if there was an error response to a previous + command). If the connection is closed prematurely due to violations + of the above or system or network failure, the server MUST cancel any + pending transaction, but not undo any previously completed + transaction, and generally MUST act as if the command or transaction + in progress had received a temporary error (i.e., a 4yz response). + + The QUIT command may be issued at any time. + + Syntax: + "QUIT" CRLF + +4.1.2 Command Argument Syntax + + The syntax of the argument fields of the above commands (using the + syntax specified in [8] where applicable) is given below. Some of + the productions given below are used only in conjunction with source + routes as described in appendix C. Terminals not defined in this + document, such as ALPHA, DIGIT, SP, CR, LF, CRLF, are as defined in + the "core" syntax [8 (section 6)] or in the message format syntax + [32]. + + Reverse-path = Path + Forward-path = Path + Path = "<" [ A-d-l ":" ] Mailbox ">" + A-d-l = At-domain *( "," A-d-l ) + ; Note that this form, the so-called "source route", + ; MUST BE accepted, SHOULD NOT be generated, and SHOULD be + ; ignored. + At-domain = "@" domain + Mail-parameters = esmtp-param *(SP esmtp-param) + Rcpt-parameters = esmtp-param *(SP esmtp-param) + + + +Klensin Standards Track [Page 36] + +RFC 2821 Simple Mail Transfer Protocol April 2001 + + + esmtp-param = esmtp-keyword ["=" esmtp-value] + esmtp-keyword = (ALPHA / DIGIT) *(ALPHA / DIGIT / "-") + esmtp-value = 1*(%d33-60 / %d62-127) + ; any CHAR excluding "=", SP, and control characters + Keyword = Ldh-str + Argument = Atom + Domain = (sub-domain 1*("." sub-domain)) / address-literal + sub-domain = Let-dig [Ldh-str] + + address-literal = "[" IPv4-address-literal / + IPv6-address-literal / + General-address-literal "]" + ; See section 4.1.3 + + Mailbox = Local-part "@" Domain + + Local-part = Dot-string / Quoted-string + ; MAY be case-sensitive + + Dot-string = Atom *("." Atom) + + Atom = 1*atext + + Quoted-string = DQUOTE *qcontent DQUOTE + + String = Atom / Quoted-string + + While the above definition for Local-part is relatively permissive, + for maximum interoperability, a host that expects to receive mail + SHOULD avoid defining mailboxes where the Local-part requires (or + uses) the Quoted-string form or where the Local-part is case- + sensitive. For any purposes that require generating or comparing + Local-parts (e.g., to specific mailbox names), all quoted forms MUST + be treated as equivalent and the sending system SHOULD transmit the + form that uses the minimum quoting possible. + + Systems MUST NOT define mailboxes in such a way as to require the use + in SMTP of non-ASCII characters (octets with the high order bit set + to one) or ASCII "control characters" (decimal value 0-31 and 127). + These characters MUST NOT be used in MAIL or RCPT commands or other + commands that require mailbox names. + + Note that the backslash, "\", is a quote character, which is used to + indicate that the next character is to be used literally (instead of + its normal interpretation). For example, "Joe\,Smith" indicates a + single nine character user field with the comma being the fourth + character of the field. + + + + +Klensin Standards Track [Page 37] + +RFC 2821 Simple Mail Transfer Protocol April 2001 + + + To promote interoperability and consistent with long-standing + guidance about conservative use of the DNS in naming and applications + (e.g., see section 2.3.1 of the base DNS document, RFC1035 [22]), + characters outside the set of alphas, digits, and hyphen MUST NOT + appear in domain name labels for SMTP clients or servers. In + particular, the underscore character is not permitted. SMTP servers + that receive a command in which invalid character codes have been + employed, and for which there are no other reasons for rejection, + MUST reject that command with a 501 response. + +4.1.3 Address Literals + + Sometimes a host is not known to the domain name system and + communication (and, in particular, communication to report and repair + the error) is blocked. To bypass this barrier a special literal form + of the address is allowed as an alternative to a domain name. For + IPv4 addresses, this form uses four small decimal integers separated + by dots and enclosed by brackets such as [123.255.37.2], which + indicates an (IPv4) Internet Address in sequence-of-octets form. For + IPv6 and other forms of addressing that might eventually be + standardized, the form consists of a standardized "tag" that + identifies the address syntax, a colon, and the address itself, in a + format specified as part of the IPv6 standards [17]. + + Specifically: + + IPv4-address-literal = Snum 3("." Snum) + IPv6-address-literal = "IPv6:" IPv6-addr + General-address-literal = Standardized-tag ":" 1*dcontent + Standardized-tag = Ldh-str + ; MUST be specified in a standards-track RFC + ; and registered with IANA + + Snum = 1*3DIGIT ; representing a decimal integer + ; value in the range 0 through 255 + Let-dig = ALPHA / DIGIT + Ldh-str = *( ALPHA / DIGIT / "-" ) Let-dig + + IPv6-addr = IPv6-full / IPv6-comp / IPv6v4-full / IPv6v4-comp + IPv6-hex = 1*4HEXDIG + IPv6-full = IPv6-hex 7(":" IPv6-hex) + IPv6-comp = [IPv6-hex *5(":" IPv6-hex)] "::" [IPv6-hex *5(":" + IPv6-hex)] + ; The "::" represents at least 2 16-bit groups of zeros + ; No more than 6 groups in addition to the "::" may be + ; present + IPv6v4-full = IPv6-hex 5(":" IPv6-hex) ":" IPv4-address-literal + IPv6v4-comp = [IPv6-hex *3(":" IPv6-hex)] "::" + + + +Klensin Standards Track [Page 38] + +RFC 2821 Simple Mail Transfer Protocol April 2001 + + + [IPv6-hex *3(":" IPv6-hex) ":"] IPv4-address-literal + ; The "::" represents at least 2 16-bit groups of zeros + ; No more than 4 groups in addition to the "::" and + ; IPv4-address-literal may be present + +4.1.4 Order of Commands + + There are restrictions on the order in which these commands may be + used. + + A session that will contain mail transactions MUST first be + initialized by the use of the EHLO command. An SMTP server SHOULD + accept commands for non-mail transactions (e.g., VRFY or EXPN) + without this initialization. + + An EHLO command MAY be issued by a client later in the session. If + it is issued after the session begins, the SMTP server MUST clear all + buffers and reset the state exactly as if a RSET command had been + issued. In other words, the sequence of RSET followed immediately by + EHLO is redundant, but not harmful other than in the performance cost + of executing unnecessary commands. + + If the EHLO command is not acceptable to the SMTP server, 501, 500, + or 502 failure replies MUST be returned as appropriate. The SMTP + server MUST stay in the same state after transmitting these replies + that it was in before the EHLO was received. + + The SMTP client MUST, if possible, ensure that the domain parameter + to the EHLO command is a valid principal host name (not a CNAME or MX + name) for its host. If this is not possible (e.g., when the client's + address is dynamically assigned and the client does not have an + obvious name), an address literal SHOULD be substituted for the + domain name and supplemental information provided that will assist in + identifying the client. + + An SMTP server MAY verify that the domain name parameter in the EHLO + command actually corresponds to the IP address of the client. + However, the server MUST NOT refuse to accept a message for this + reason if the verification fails: the information about verification + failure is for logging and tracing only. + + The NOOP, HELP, EXPN, VRFY, and RSET commands can be used at any time + during a session, or without previously initializing a session. SMTP + servers SHOULD process these normally (that is, not return a 503 + code) even if no EHLO command has yet been received; clients SHOULD + open a session with EHLO before sending these commands. + + + + + +Klensin Standards Track [Page 39] + +RFC 2821 Simple Mail Transfer Protocol April 2001 + + + If these rules are followed, the example in RFC 821 that shows "550 + access denied to you" in response to an EXPN command is incorrect + unless an EHLO command precedes the EXPN or the denial of access is + based on the client's IP address or other authentication or + authorization-determining mechanisms. + + The MAIL command (or the obsolete SEND, SOML, or SAML commands) + begins a mail transaction. Once started, a mail transaction consists + of a transaction beginning command, one or more RCPT commands, and a + DATA command, in that order. A mail transaction may be aborted by + the RSET (or a new EHLO) command. There may be zero or more + transactions in a session. MAIL (or SEND, SOML, or SAML) MUST NOT be + sent if a mail transaction is already open, i.e., it should be sent + only if no mail transaction had been started in the session, or it + the previous one successfully concluded with a successful DATA + command, or if the previous one was aborted with a RSET. + + If the transaction beginning command argument is not acceptable, a + 501 failure reply MUST be returned and the SMTP server MUST stay in + the same state. If the commands in a transaction are out of order to + the degree that they cannot be processed by the server, a 503 failure + reply MUST be returned and the SMTP server MUST stay in the same + state. + + The last command in a session MUST be the QUIT command. The QUIT + command cannot be used at any other time in a session, but SHOULD be + used by the client SMTP to request connection closure, even when no + session opening command was sent and accepted. + +4.1.5 Private-use Commands + + As specified in section 2.2.2, commands starting in "X" may be used + by bilateral agreement between the client (sending) and server + (receiving) SMTP agents. An SMTP server that does not recognize such + a command is expected to reply with "500 Command not recognized". An + extended SMTP server MAY list the feature names associated with these + private commands in the response to the EHLO command. + + Commands sent or accepted by SMTP systems that do not start with "X" + MUST conform to the requirements of section 2.2.2. + +4.2 SMTP Replies + + Replies to SMTP commands serve to ensure the synchronization of + requests and actions in the process of mail transfer and to guarantee + that the SMTP client always knows the state of the SMTP server. + Every command MUST generate exactly one reply. + + + + +Klensin Standards Track [Page 40] + +RFC 2821 Simple Mail Transfer Protocol April 2001 + + + The details of the command-reply sequence are described in section + 4.3. + + An SMTP reply consists of a three digit number (transmitted as three + numeric characters) followed by some text unless specified otherwise + in this document. The number is for use by automata to determine + what state to enter next; the text is for the human user. The three + digits contain enough encoded information that the SMTP client need + not examine the text and may either discard it or pass it on to the + user, as appropriate. Exceptions are as noted elsewhere in this + document. In particular, the 220, 221, 251, 421, and 551 reply codes + are associated with message text that must be parsed and interpreted + by machines. In the general case, the text may be receiver dependent + and context dependent, so there are likely to be varying texts for + each reply code. A discussion of the theory of reply codes is given + in section 4.2.1. Formally, a reply is defined to be the sequence: a + three-digit code, , one line of text, and , or a multiline + reply (as defined in section 4.2.1). Since, in violation of this + specification, the text is sometimes not sent, clients which do not + receive it SHOULD be prepared to process the code alone (with or + without a trailing space character). Only the EHLO, EXPN, and HELP + commands are expected to result in multiline replies in normal + circumstances, however, multiline replies are allowed for any + command. + + In ABNF, server responses are: + + Greeting = "220 " Domain [ SP text ] CRLF + Reply-line = Reply-code [ SP text ] CRLF + + where "Greeting" appears only in the 220 response that announces that + the server is opening its part of the connection. + + An SMTP server SHOULD send only the reply codes listed in this + document. An SMTP server SHOULD use the text shown in the examples + whenever appropriate. + + An SMTP client MUST determine its actions only by the reply code, not + by the text (except for the "change of address" 251 and 551 and, if + necessary, 220, 221, and 421 replies); in the general case, any text, + including no text at all (although senders SHOULD NOT send bare + codes), MUST be acceptable. The space (blank) following the reply + code is considered part of the text. Whenever possible, a receiver- + SMTP SHOULD test the first digit (severity indication) of the reply + code. + + + + + + +Klensin Standards Track [Page 41] + +RFC 2821 Simple Mail Transfer Protocol April 2001 + + + The list of codes that appears below MUST NOT be construed as + permanent. While the addition of new codes should be a rare and + significant activity, with supplemental information in the textual + part of the response being preferred, new codes may be added as the + result of new Standards or Standards-track specifications. + Consequently, a sender-SMTP MUST be prepared to handle codes not + specified in this document and MUST do so by interpreting the first + digit only. + +4.2.1 Reply Code Severities and Theory + + The three digits of the reply each have a special significance. The + first digit denotes whether the response is good, bad or incomplete. + An unsophisticated SMTP client, or one that receives an unexpected + code, will be able to determine its next action (proceed as planned, + redo, retrench, etc.) by examining this first digit. An SMTP client + that wants to know approximately what kind of error occurred (e.g., + mail system error, command syntax error) may examine the second + digit. The third digit and any supplemental information that may be + present is reserved for the finest gradation of information. + + There are five values for the first digit of the reply code: + + 1yz Positive Preliminary reply + The command has been accepted, but the requested action is being + held in abeyance, pending confirmation of the information in this + reply. The SMTP client should send another command specifying + whether to continue or abort the action. Note: unextended SMTP + does not have any commands that allow this type of reply, and so + does not have continue or abort commands. + + 2yz Positive Completion reply + The requested action has been successfully completed. A new + request may be initiated. + + 3yz Positive Intermediate reply + The command has been accepted, but the requested action is being + held in abeyance, pending receipt of further information. The + SMTP client should send another command specifying this + information. This reply is used in command sequence groups (i.e., + in DATA). + + 4yz Transient Negative Completion reply + The command was not accepted, and the requested action did not + occur. However, the error condition is temporary and the action + may be requested again. The sender should return to the beginning + of the command sequence (if any). It is difficult to assign a + meaning to "transient" when two different sites (receiver- and + + + +Klensin Standards Track [Page 42] + +RFC 2821 Simple Mail Transfer Protocol April 2001 + + + sender-SMTP agents) must agree on the interpretation. Each reply + in this category might have a different time value, but the SMTP + client is encouraged to try again. A rule of thumb to determine + whether a reply fits into the 4yz or the 5yz category (see below) + is that replies are 4yz if they can be successful if repeated + without any change in command form or in properties of the sender + or receiver (that is, the command is repeated identically and the + receiver does not put up a new implementation.) + + 5yz Permanent Negative Completion reply + The command was not accepted and the requested action did not + occur. The SMTP client is discouraged from repeating the exact + request (in the same sequence). Even some "permanent" error + conditions can be corrected, so the human user may want to direct + the SMTP client to reinitiate the command sequence by direct + action at some point in the future (e.g., after the spelling has + been changed, or the user has altered the account status). + + The second digit encodes responses in specific categories: + + x0z Syntax: These replies refer to syntax errors, syntactically + correct commands that do not fit any functional category, and + unimplemented or superfluous commands. + + x1z Information: These are replies to requests for information, + such as status or help. + + x2z Connections: These are replies referring to the transmission + channel. + + x3z Unspecified. + + x4z Unspecified. + + x5z Mail system: These replies indicate the status of the receiver + mail system vis-a-vis the requested transfer or other mail system + action. + + The third digit gives a finer gradation of meaning in each category + specified by the second digit. The list of replies illustrates this. + Each reply text is recommended rather than mandatory, and may even + change according to the command with which it is associated. On the + other hand, the reply codes must strictly follow the specifications + in this section. Receiver implementations should not invent new + codes for slightly different situations from the ones described here, + but rather adapt codes already defined. + + + + + +Klensin Standards Track [Page 43] + +RFC 2821 Simple Mail Transfer Protocol April 2001 + + + For example, a command such as NOOP, whose successful execution does + not offer the SMTP client any new information, will return a 250 + reply. The reply is 502 when the command requests an unimplemented + non-site-specific action. A refinement of that is the 504 reply for + a command that is implemented, but that requests an unimplemented + parameter. + + The reply text may be longer than a single line; in these cases the + complete text must be marked so the SMTP client knows when it can + stop reading the reply. This requires a special format to indicate a + multiple line reply. + + The format for multiline replies requires that every line, except the + last, begin with the reply code, followed immediately by a hyphen, + "-" (also known as minus), followed by text. The last line will + begin with the reply code, followed immediately by , optionally + some text, and . As noted above, servers SHOULD send the + if subsequent text is not sent, but clients MUST be prepared for it + to be omitted. + + For example: + + 123-First line + 123-Second line + 123-234 text beginning with numbers + 123 The last line + + In many cases the SMTP client then simply needs to search for a line + beginning with the reply code followed by or and ignore + all preceding lines. In a few cases, there is important data for the + client in the reply "text". The client will be able to identify + these cases from the current context. + +4.2.2 Reply Codes by Function Groups + + 500 Syntax error, command unrecognized + (This may include errors such as command line too long) + 501 Syntax error in parameters or arguments + 502 Command not implemented (see section 4.2.4) + 503 Bad sequence of commands + 504 Command parameter not implemented + + 211 System status, or system help reply + 214 Help message + (Information on how to use the receiver or the meaning of a + particular non-standard command; this reply is useful only + to the human user) + + + + +Klensin Standards Track [Page 44] + +RFC 2821 Simple Mail Transfer Protocol April 2001 + + + 220 Service ready + 221 Service closing transmission channel + 421 Service not available, closing transmission channel + (This may be a reply to any command if the service knows it + must shut down) + + 250 Requested mail action okay, completed + 251 User not local; will forward to + (See section 3.4) + 252 Cannot VRFY user, but will accept message and attempt + delivery + (See section 3.5.3) + 450 Requested mail action not taken: mailbox unavailable + (e.g., mailbox busy) + 550 Requested action not taken: mailbox unavailable + (e.g., mailbox not found, no access, or command rejected + for policy reasons) + 451 Requested action aborted: error in processing + 551 User not local; please try + (See section 3.4) + 452 Requested action not taken: insufficient system storage + 552 Requested mail action aborted: exceeded storage allocation + 553 Requested action not taken: mailbox name not allowed + (e.g., mailbox syntax incorrect) + 354 Start mail input; end with . + 554 Transaction failed (Or, in the case of a connection-opening + response, "No SMTP service here") + +4.2.3 Reply Codes in Numeric Order + + 211 System status, or system help reply + 214 Help message + (Information on how to use the receiver or the meaning of a + particular non-standard command; this reply is useful only + to the human user) + 220 Service ready + 221 Service closing transmission channel + 250 Requested mail action okay, completed + 251 User not local; will forward to + (See section 3.4) + 252 Cannot VRFY user, but will accept message and attempt + delivery + (See section 3.5.3) + + 354 Start mail input; end with . + + + + + + +Klensin Standards Track [Page 45] + +RFC 2821 Simple Mail Transfer Protocol April 2001 + + + 421 Service not available, closing transmission channel + (This may be a reply to any command if the service knows it + must shut down) + 450 Requested mail action not taken: mailbox unavailable + (e.g., mailbox busy) + 451 Requested action aborted: local error in processing + 452 Requested action not taken: insufficient system storage + 500 Syntax error, command unrecognized + (This may include errors such as command line too long) + 501 Syntax error in parameters or arguments + 502 Command not implemented (see section 4.2.4) + 503 Bad sequence of commands + 504 Command parameter not implemented + 550 Requested action not taken: mailbox unavailable + (e.g., mailbox not found, no access, or command rejected + for policy reasons) + 551 User not local; please try + (See section 3.4) + 552 Requested mail action aborted: exceeded storage allocation + 553 Requested action not taken: mailbox name not allowed + (e.g., mailbox syntax incorrect) + 554 Transaction failed (Or, in the case of a connection-opening + response, "No SMTP service here") + +4.2.4 Reply Code 502 + + Questions have been raised as to when reply code 502 (Command not + implemented) SHOULD be returned in preference to other codes. 502 + SHOULD be used when the command is actually recognized by the SMTP + server, but not implemented. If the command is not recognized, code + 500 SHOULD be returned. Extended SMTP systems MUST NOT list + capabilities in response to EHLO for which they will return 502 (or + 500) replies. + +4.2.5 Reply Codes After DATA and the Subsequent . + + When an SMTP server returns a positive completion status (2yz code) + after the DATA command is completed with ., it accepts + responsibility for: + + - delivering the message (if the recipient mailbox exists), or + + - if attempts to deliver the message fail due to transient + conditions, retrying delivery some reasonable number of times at + intervals as specified in section 4.5.4. + + + + + + +Klensin Standards Track [Page 46] + +RFC 2821 Simple Mail Transfer Protocol April 2001 + + + - if attempts to deliver the message fail due to permanent + conditions, or if repeated attempts to deliver the message fail + due to transient conditions, returning appropriate notification to + the sender of the original message (using the address in the SMTP + MAIL command). + + When an SMTP server returns a permanent error status (5yz) code after + the DATA command is completed with ., it MUST NOT make + any subsequent attempt to deliver that message. The SMTP client + retains responsibility for delivery of that message and may either + return it to the user or requeue it for a subsequent attempt (see + section 4.5.4.1). + + The user who originated the message SHOULD be able to interpret the + return of a transient failure status (by mail message or otherwise) + as a non-delivery indication, just as a permanent failure would be + interpreted. I.e., if the client SMTP successfully handles these + conditions, the user will not receive such a reply. + + When an SMTP server returns a permanent error status (5yz) code after + the DATA command is completely with ., it MUST NOT make + any subsequent attempt to deliver the message. As with temporary + error status codes, the SMTP client retains responsibility for the + message, but SHOULD not again attempt delivery to the same server + without user review and intervention of the message. + +4.3 Sequencing of Commands and Replies + +4.3.1 Sequencing Overview + + The communication between the sender and receiver is an alternating + dialogue, controlled by the sender. As such, the sender issues a + command and the receiver responds with a reply. Unless other + arrangements are negotiated through service extensions, the sender + MUST wait for this response before sending further commands. + + One important reply is the connection greeting. Normally, a receiver + will send a 220 "Service ready" reply when the connection is + completed. The sender SHOULD wait for this greeting message before + sending any commands. + + Note: all the greeting-type replies have the official name (the + fully-qualified primary domain name) of the server host as the first + word following the reply code. Sometimes the host will have no + meaningful name. See 4.1.3 for a discussion of alternatives in these + situations. + + + + + +Klensin Standards Track [Page 47] + +RFC 2821 Simple Mail Transfer Protocol April 2001 + + + For example, + + 220 ISIF.USC.EDU Service ready + or + 220 mail.foo.com SuperSMTP v 6.1.2 Service ready + or + 220 [10.0.0.1] Clueless host service ready + + The table below lists alternative success and failure replies for + each command. These SHOULD be strictly adhered to: a receiver may + substitute text in the replies, but the meaning and action implied by + the code numbers and by the specific command reply sequence cannot be + altered. + +4.3.2 Command-Reply Sequences + + Each command is listed with its usual possible replies. The prefixes + used before the possible replies are "I" for intermediate, "S" for + success, and "E" for error. Since some servers may generate other + replies under special circumstances, and to allow for future + extension, SMTP clients SHOULD, when possible, interpret only the + first digit of the reply and MUST be prepared to deal with + unrecognized reply codes by interpreting the first digit only. + Unless extended using the mechanisms described in section 2.2, SMTP + servers MUST NOT transmit reply codes to an SMTP client that are + other than three digits or that do not start in a digit between 2 and + 5 inclusive. + + These sequencing rules and, in principle, the codes themselves, can + be extended or modified by SMTP extensions offered by the server and + accepted (requested) by the client. + + In addition to the codes listed below, any SMTP command can return + any of the following codes if the corresponding unusual circumstances + are encountered: + + 500 For the "command line too long" case or if the command name was + not recognized. Note that producing a "command not recognized" + error in response to the required subset of these commands is a + violation of this specification. + + 501 Syntax error in command or arguments. In order to provide for + future extensions, commands that are specified in this document as + not accepting arguments (DATA, RSET, QUIT) SHOULD return a 501 + message if arguments are supplied in the absence of EHLO- + advertised extensions. + + 421 Service shutting down and closing transmission channel + + + +Klensin Standards Track [Page 48] + +RFC 2821 Simple Mail Transfer Protocol April 2001 + + + Specific sequences are: + + CONNECTION ESTABLISHMENT + S: 220 + E: 554 + EHLO or HELO + S: 250 + E: 504, 550 + MAIL + S: 250 + E: 552, 451, 452, 550, 553, 503 + RCPT + S: 250, 251 (but see section 3.4 for discussion of 251 and 551) + E: 550, 551, 552, 553, 450, 451, 452, 503, 550 + DATA + I: 354 -> data -> S: 250 + E: 552, 554, 451, 452 + E: 451, 554, 503 + RSET + S: 250 + VRFY + S: 250, 251, 252 + E: 550, 551, 553, 502, 504 + EXPN + S: 250, 252 + E: 550, 500, 502, 504 + HELP + S: 211, 214 + E: 502, 504 + NOOP + S: 250 + QUIT + S: 221 + +4.4 Trace Information + + When an SMTP server receives a message for delivery or further + processing, it MUST insert trace ("time stamp" or "Received") + information at the beginning of the message content, as discussed in + section 4.1.1.4. + + This line MUST be structured as follows: + + - The FROM field, which MUST be supplied in an SMTP environment, + SHOULD contain both (1) the name of the source host as presented + in the EHLO command and (2) an address literal containing the IP + address of the source, determined from the TCP connection. + + + + +Klensin Standards Track [Page 49] + +RFC 2821 Simple Mail Transfer Protocol April 2001 + + + - The ID field MAY contain an "@" as suggested in RFC 822, but this + is not required. + + - The FOR field MAY contain a list of entries when multiple + RCPT commands have been given. This may raise some security + issues and is usually not desirable; see section 7.2. + + An Internet mail program MUST NOT change a Received: line that was + previously added to the message header. SMTP servers MUST prepend + Received lines to messages; they MUST NOT change the order of + existing lines or insert Received lines in any other location. + + As the Internet grows, comparability of Received fields is important + for detecting problems, especially slow relays. SMTP servers that + create Received fields SHOULD use explicit offsets in the dates + (e.g., -0800), rather than time zone names of any type. Local time + (with an offset) is preferred to UT when feasible. This formulation + allows slightly more information about local circumstances to be + specified. If UT is needed, the receiver need merely do some simple + arithmetic to convert the values. Use of UT loses information about + the time zone-location of the server. If it is desired to supply a + time zone name, it SHOULD be included in a comment. + + When the delivery SMTP server makes the "final delivery" of a + message, it inserts a return-path line at the beginning of the mail + data. This use of return-path is required; mail systems MUST support + it. The return-path line preserves the information in the from the MAIL command. Here, final delivery means the message + has left the SMTP environment. Normally, this would mean it had been + delivered to the destination user or an associated mail drop, but in + some cases it may be further processed and transmitted by another + mail system. + + It is possible for the mailbox in the return path to be different + from the actual sender's mailbox, for example, if error responses are + to be delivered to a special error handling mailbox rather than to + the message sender. When mailing lists are involved, this + arrangement is common and useful as a means of directing errors to + the list maintainer rather than the message originator. + + The text above implies that the final mail data will begin with a + return path line, followed by one or more time stamp lines. These + lines will be followed by the mail data headers and body [32]. + + It is sometimes difficult for an SMTP server to determine whether or + not it is making final delivery since forwarding or other operations + may occur after the message is accepted for delivery. Consequently, + + + + +Klensin Standards Track [Page 50] + +RFC 2821 Simple Mail Transfer Protocol April 2001 + + + any further (forwarding, gateway, or relay) systems MAY remove the + return path and rebuild the MAIL command as needed to ensure that + exactly one such line appears in a delivered message. + + A message-originating SMTP system SHOULD NOT send a message that + already contains a Return-path header. SMTP servers performing a + relay function MUST NOT inspect the message data, and especially not + to the extent needed to determine if Return-path headers are present. + SMTP servers making final delivery MAY remove Return-path headers + before adding their own. + + The primary purpose of the Return-path is to designate the address to + which messages indicating non-delivery or other mail system failures + are to be sent. For this to be unambiguous, exactly one return path + SHOULD be present when the message is delivered. Systems using RFC + 822 syntax with non-SMTP transports SHOULD designate an unambiguous + address, associated with the transport envelope, to which error + reports (e.g., non-delivery messages) should be sent. + + Historical note: Text in RFC 822 that appears to contradict the use + of the Return-path header (or the envelope reverse path address from + the MAIL command) as the destination for error messages is not + applicable on the Internet. The reverse path address (as copied into + the Return-path) MUST be used as the target of any mail containing + delivery error messages. + + In particular: + + - a gateway from SMTP->elsewhere SHOULD insert a return-path header, + unless it is known that the "elsewhere" transport also uses + Internet domain addresses and maintains the envelope sender + address separately. + + - a gateway from elsewhere->SMTP SHOULD delete any return-path + header present in the message, and either copy that information to + the SMTP envelope or combine it with information present in the + envelope of the other transport system to construct the reverse + path argument to the MAIL command in the SMTP envelope. + + The server must give special treatment to cases in which the + processing following the end of mail data indication is only + partially successful. This could happen if, after accepting several + recipients and the mail data, the SMTP server finds that the mail + data could be successfully delivered to some, but not all, of the + recipients. In such cases, the response to the DATA command MUST be + an OK reply. However, the SMTP server MUST compose and send an + "undeliverable mail" notification message to the originator of the + message. + + + +Klensin Standards Track [Page 51] + +RFC 2821 Simple Mail Transfer Protocol April 2001 + + + A single notification listing all of the failed recipients or + separate notification messages MUST be sent for each failed + recipient. For economy of processing by the sender, the former is + preferred when possible. All undeliverable mail notification + messages are sent using the MAIL command (even if they result from + processing the obsolete SEND, SOML, or SAML commands) and use a null + return path as discussed in section 3.7. + + The time stamp line and the return path line are formally defined as + follows: + +Return-path-line = "Return-Path:" FWS Reverse-path + +Time-stamp-line = "Received:" FWS Stamp + +Stamp = From-domain By-domain Opt-info ";" FWS date-time + + ; where "date-time" is as defined in [32] + ; but the "obs-" forms, especially two-digit + ; years, are prohibited in SMTP and MUST NOT be used. + +From-domain = "FROM" FWS Extended-Domain CFWS + +By-domain = "BY" FWS Extended-Domain CFWS + +Extended-Domain = Domain / + ( Domain FWS "(" TCP-info ")" ) / + ( Address-literal FWS "(" TCP-info ")" ) + +TCP-info = Address-literal / ( Domain FWS Address-literal ) + ; Information derived by server from TCP connection + ; not client EHLO. + +Opt-info = [Via] [With] [ID] [For] + +Via = "VIA" FWS Link CFWS + +With = "WITH" FWS Protocol CFWS + +ID = "ID" FWS String / msg-id CFWS + +For = "FOR" FWS 1*( Path / Mailbox ) CFWS + +Link = "TCP" / Addtl-Link +Addtl-Link = Atom + ; Additional standard names for links are registered with the + ; Internet Assigned Numbers Authority (IANA). "Via" is + ; primarily of value with non-Internet transports. SMTP + + + +Klensin Standards Track [Page 52] + +RFC 2821 Simple Mail Transfer Protocol April 2001 + + + ; servers SHOULD NOT use unregistered names. +Protocol = "ESMTP" / "SMTP" / Attdl-Protocol +Attdl-Protocol = Atom + ; Additional standard names for protocols are registered with the + ; Internet Assigned Numbers Authority (IANA). SMTP servers + ; SHOULD NOT use unregistered names. + +4.5 Additional Implementation Issues + +4.5.1 Minimum Implementation + + In order to make SMTP workable, the following minimum implementation + is required for all receivers. The following commands MUST be + supported to conform to this specification: + + EHLO + HELO + MAIL + RCPT + DATA + RSET + NOOP + QUIT + VRFY + + Any system that includes an SMTP server supporting mail relaying or + delivery MUST support the reserved mailbox "postmaster" as a case- + insensitive local name. This postmaster address is not strictly + necessary if the server always returns 554 on connection opening (as + described in section 3.1). The requirement to accept mail for + postmaster implies that RCPT commands which specify a mailbox for + postmaster at any of the domains for which the SMTP server provides + mail service, as well as the special case of "RCPT TO:" + (with no domain specification), MUST be supported. + + SMTP systems are expected to make every reasonable effort to accept + mail directed to Postmaster from any other system on the Internet. + In extreme cases --such as to contain a denial of service attack or + other breach of security-- an SMTP server may block mail directed to + Postmaster. However, such arrangements SHOULD be narrowly tailored + so as to avoid blocking messages which are not part of such attacks. + +4.5.2 Transparency + + Without some provision for data transparency, the character sequence + "." ends the mail text and cannot be sent by the user. + In general, users are not aware of such "forbidden" sequences. To + + + + +Klensin Standards Track [Page 53] + +RFC 2821 Simple Mail Transfer Protocol April 2001 + + + allow all user composed text to be transmitted transparently, the + following procedures are used: + + - Before sending a line of mail text, the SMTP client checks the + first character of the line. If it is a period, one additional + period is inserted at the beginning of the line. + + - When a line of mail text is received by the SMTP server, it checks + the line. If the line is composed of a single period, it is + treated as the end of mail indicator. If the first character is a + period and there are other characters on the line, the first + character is deleted. + + The mail data may contain any of the 128 ASCII characters. All + characters are to be delivered to the recipient's mailbox, including + spaces, vertical and horizontal tabs, and other control characters. + If the transmission channel provides an 8-bit byte (octet) data + stream, the 7-bit ASCII codes are transmitted right justified in the + octets, with the high order bits cleared to zero. See 3.7 for + special treatment of these conditions in SMTP systems serving a relay + function. + + In some systems it may be necessary to transform the data as it is + received and stored. This may be necessary for hosts that use a + different character set than ASCII as their local character set, that + store data in records rather than strings, or which use special + character sequences as delimiters inside mailboxes. If such + transformations are necessary, they MUST be reversible, especially if + they are applied to mail being relayed. + +4.5.3 Sizes and Timeouts + +4.5.3.1 Size limits and minimums + + There are several objects that have required minimum/maximum sizes. + Every implementation MUST be able to receive objects of at least + these sizes. Objects larger than these sizes SHOULD be avoided when + possible. However, some Internet mail constructs such as encoded + X.400 addresses [16] will often require larger objects: clients MAY + attempt to transmit these, but MUST be prepared for a server to + reject them if they cannot be handled by it. To the maximum extent + possible, implementation techniques which impose no limits on the + length of these objects should be used. + + local-part + The maximum total length of a user name or other local-part is 64 + characters. + + + + +Klensin Standards Track [Page 54] + +RFC 2821 Simple Mail Transfer Protocol April 2001 + + + domain + The maximum total length of a domain name or number is 255 + characters. + + path + The maximum total length of a reverse-path or forward-path is 256 + characters (including the punctuation and element separators). + + command line + The maximum total length of a command line including the command + word and the is 512 characters. SMTP extensions may be + used to increase this limit. + + reply line + The maximum total length of a reply line including the reply code + and the is 512 characters. More information may be + conveyed through multiple-line replies. + + text line + The maximum total length of a text line including the is + 1000 characters (not counting the leading dot duplicated for + transparency). This number may be increased by the use of SMTP + Service Extensions. + + message content + The maximum total length of a message content (including any + message headers as well as the message body) MUST BE at least 64K + octets. Since the introduction of Internet standards for + multimedia mail [12], message lengths on the Internet have grown + dramatically, and message size restrictions should be avoided if + at all possible. SMTP server systems that must impose + restrictions SHOULD implement the "SIZE" service extension [18], + and SMTP client systems that will send large messages SHOULD + utilize it when possible. + + recipients buffer + The minimum total number of recipients that must be buffered is + 100 recipients. Rejection of messages (for excessive recipients) + with fewer than 100 RCPT commands is a violation of this + specification. The general principle that relaying SMTP servers + MUST NOT, and delivery SMTP servers SHOULD NOT, perform validation + tests on message headers suggests that rejecting a message based + on the total number of recipients shown in header fields is to be + discouraged. A server which imposes a limit on the number of + recipients MUST behave in an orderly fashion, such as to reject + additional addresses over its limit rather than silently + discarding addresses previously accepted. A client that needs to + + + + +Klensin Standards Track [Page 55] + +RFC 2821 Simple Mail Transfer Protocol April 2001 + + + deliver a message containing over 100 RCPT commands SHOULD be + prepared to transmit in 100-recipient "chunks" if the server + declines to accept more than 100 recipients in a single message. + + Errors due to exceeding these limits may be reported by using the + reply codes. Some examples of reply codes are: + + 500 Line too long. + or + 501 Path too long + or + 452 Too many recipients (see below) + or + 552 Too much mail data. + + RFC 821 [30] incorrectly listed the error where an SMTP server + exhausts its implementation limit on the number of RCPT commands + ("too many recipients") as having reply code 552. The correct reply + code for this condition is 452. Clients SHOULD treat a 552 code in + this case as a temporary, rather than permanent, failure so the logic + below works. + + When a conforming SMTP server encounters this condition, it has at + least 100 successful RCPT commands in its recipients buffer. If the + server is able to accept the message, then at least these 100 + addresses will be removed from the SMTP client's queue. When the + client attempts retransmission of those addresses which received 452 + responses, at least 100 of these will be able to fit in the SMTP + server's recipients buffer. Each retransmission attempt which is + able to deliver anything will be able to dispose of at least 100 of + these recipients. + + If an SMTP server has an implementation limit on the number of RCPT + commands and this limit is exhausted, it MUST use a response code of + 452 (but the client SHOULD also be prepared for a 552, as noted + above). If the server has a configured site-policy limitation on the + number of RCPT commands, it MAY instead use a 5XX response code. + This would be most appropriate if the policy limitation was intended + to apply if the total recipient count for a particular message body + were enforced even if that message body was sent in multiple mail + transactions. + +4.5.3.2 Timeouts + + An SMTP client MUST provide a timeout mechanism. It MUST use per- + command timeouts rather than somehow trying to time the entire mail + transaction. Timeouts SHOULD be easily reconfigurable, preferably + without recompiling the SMTP code. To implement this, a timer is set + + + +Klensin Standards Track [Page 56] + +RFC 2821 Simple Mail Transfer Protocol April 2001 + + + for each SMTP command and for each buffer of the data transfer. The + latter means that the overall timeout is inherently proportional to + the size of the message. + + Based on extensive experience with busy mail-relay hosts, the minimum + per-command timeout values SHOULD be as follows: + + Initial 220 Message: 5 minutes + An SMTP client process needs to distinguish between a failed TCP + connection and a delay in receiving the initial 220 greeting + message. Many SMTP servers accept a TCP connection but delay + delivery of the 220 message until their system load permits more + mail to be processed. + + MAIL Command: 5 minutes + + RCPT Command: 5 minutes + A longer timeout is required if processing of mailing lists and + aliases is not deferred until after the message was accepted. + + DATA Initiation: 2 minutes + This is while awaiting the "354 Start Input" reply to a DATA + command. + + Data Block: 3 minutes + This is while awaiting the completion of each TCP SEND call + transmitting a chunk of data. + + DATA Termination: 10 minutes. + This is while awaiting the "250 OK" reply. When the receiver gets + the final period terminating the message data, it typically + performs processing to deliver the message to a user mailbox. A + spurious timeout at this point would be very wasteful and would + typically result in delivery of multiple copies of the message, + since it has been successfully sent and the server has accepted + responsibility for delivery. See section 6.1 for additional + discussion. + + An SMTP server SHOULD have a timeout of at least 5 minutes while it + is awaiting the next command from the sender. + +4.5.4 Retry Strategies + + The common structure of a host SMTP implementation includes user + mailboxes, one or more areas for queuing messages in transit, and one + or more daemon processes for sending and receiving mail. The exact + structure will vary depending on the needs of the users on the host + + + + +Klensin Standards Track [Page 57] + +RFC 2821 Simple Mail Transfer Protocol April 2001 + + + and the number and size of mailing lists supported by the host. We + describe several optimizations that have proved helpful, particularly + for mailers supporting high traffic levels. + + Any queuing strategy MUST include timeouts on all activities on a + per-command basis. A queuing strategy MUST NOT send error messages + in response to error messages under any circumstances. + +4.5.4.1 Sending Strategy + + The general model for an SMTP client is one or more processes that + periodically attempt to transmit outgoing mail. In a typical system, + the program that composes a message has some method for requesting + immediate attention for a new piece of outgoing mail, while mail that + cannot be transmitted immediately MUST be queued and periodically + retried by the sender. A mail queue entry will include not only the + message itself but also the envelope information. + + The sender MUST delay retrying a particular destination after one + attempt has failed. In general, the retry interval SHOULD be at + least 30 minutes; however, more sophisticated and variable strategies + will be beneficial when the SMTP client can determine the reason for + non-delivery. + + Retries continue until the message is transmitted or the sender gives + up; the give-up time generally needs to be at least 4-5 days. The + parameters to the retry algorithm MUST be configurable. + + A client SHOULD keep a list of hosts it cannot reach and + corresponding connection timeouts, rather than just retrying queued + mail items. + + Experience suggests that failures are typically transient (the target + system or its connection has crashed), favoring a policy of two + connection attempts in the first hour the message is in the queue, + and then backing off to one every two or three hours. + + The SMTP client can shorten the queuing delay in cooperation with the + SMTP server. For example, if mail is received from a particular + address, it is likely that mail queued for that host can now be sent. + Application of this principle may, in many cases, eliminate the + requirement for an explicit "send queues now" function such as ETRN + [9]. + + The strategy may be further modified as a result of multiple + addresses per host (see below) to optimize delivery time vs. resource + usage. + + + + +Klensin Standards Track [Page 58] + +RFC 2821 Simple Mail Transfer Protocol April 2001 + + + An SMTP client may have a large queue of messages for each + unavailable destination host. If all of these messages were retried + in every retry cycle, there would be excessive Internet overhead and + the sending system would be blocked for a long period. Note that an + SMTP client can generally determine that a delivery attempt has + failed only after a timeout of several minutes and even a one-minute + timeout per connection will result in a very large delay if retries + are repeated for dozens, or even hundreds, of queued messages to the + same host. + + At the same time, SMTP clients SHOULD use great care in caching + negative responses from servers. In an extreme case, if EHLO is + issued multiple times during the same SMTP connection, different + answers may be returned by the server. More significantly, 5yz + responses to the MAIL command MUST NOT be cached. + + When a mail message is to be delivered to multiple recipients, and + the SMTP server to which a copy of the message is to be sent is the + same for multiple recipients, then only one copy of the message + SHOULD be transmitted. That is, the SMTP client SHOULD use the + command sequence: MAIL, RCPT, RCPT,... RCPT, DATA instead of the + sequence: MAIL, RCPT, DATA, ..., MAIL, RCPT, DATA. However, if there + are very many addresses, a limit on the number of RCPT commands per + MAIL command MAY be imposed. Implementation of this efficiency + feature is strongly encouraged. + + Similarly, to achieve timely delivery, the SMTP client MAY support + multiple concurrent outgoing mail transactions. However, some limit + may be appropriate to protect the host from devoting all its + resources to mail. + +4.5.4.2 Receiving Strategy + + The SMTP server SHOULD attempt to keep a pending listen on the SMTP + port at all times. This requires the support of multiple incoming + TCP connections for SMTP. Some limit MAY be imposed but servers that + cannot handle more than one SMTP transaction at a time are not in + conformance with the intent of this specification. + + As discussed above, when the SMTP server receives mail from a + particular host address, it could activate its own SMTP queuing + mechanisms to retry any mail pending for that host address. + +4.5.5 Messages with a null reverse-path + + There are several types of notification messages which are required + by existing and proposed standards to be sent with a null reverse + path, namely non-delivery notifications as discussed in section 3.7, + + + +Klensin Standards Track [Page 59] + +RFC 2821 Simple Mail Transfer Protocol April 2001 + + + other kinds of Delivery Status Notifications (DSNs) [24], and also + Message Disposition Notifications (MDNs) [10]. All of these kinds of + messages are notifications about a previous message, and they are + sent to the reverse-path of the previous mail message. (If the + delivery of such a notification message fails, that usually indicates + a problem with the mail system of the host to which the notification + message is addressed. For this reason, at some hosts the MTA is set + up to forward such failed notification messages to someone who is + able to fix problems with the mail system, e.g., via the postmaster + alias.) + + All other types of messages (i.e., any message which is not required + by a standards-track RFC to have a null reverse-path) SHOULD be sent + with with a valid, non-null reverse-path. + + Implementors of automated email processors should be careful to make + sure that the various kinds of messages with null reverse-path are + handled correctly, in particular such systems SHOULD NOT reply to + messages with null reverse-path. + +5. Address Resolution and Mail Handling + + Once an SMTP client lexically identifies a domain to which mail will + be delivered for processing (as described in sections 3.6 and 3.7), a + DNS lookup MUST be performed to resolve the domain name [22]. The + names are expected to be fully-qualified domain names (FQDNs): + mechanisms for inferring FQDNs from partial names or local aliases + are outside of this specification and, due to a history of problems, + are generally discouraged. The lookup first attempts to locate an MX + record associated with the name. If a CNAME record is found instead, + the resulting name is processed as if it were the initial name. If + no MX records are found, but an A RR is found, the A RR is treated as + if it was associated with an implicit MX RR, with a preference of 0, + pointing to that host. If one or more MX RRs are found for a given + name, SMTP systems MUST NOT utilize any A RRs associated with that + name unless they are located using the MX RRs; the "implicit MX" rule + above applies only if there are no MX records present. If MX records + are present, but none of them are usable, this situation MUST be + reported as an error. + + When the lookup succeeds, the mapping can result in a list of + alternative delivery addresses rather than a single address, because + of multiple MX records, multihoming, or both. To provide reliable + mail transmission, the SMTP client MUST be able to try (and retry) + each of the relevant addresses in this list in order, until a + delivery attempt succeeds. However, there MAY also be a configurable + limit on the number of alternate addresses that can be tried. In any + case, the SMTP client SHOULD try at least two addresses. + + + +Klensin Standards Track [Page 60] + +RFC 2821 Simple Mail Transfer Protocol April 2001 + + + Two types of information is used to rank the host addresses: multiple + MX records, and multihomed hosts. + + Multiple MX records contain a preference indication that MUST be used + in sorting (see below). Lower numbers are more preferred than higher + ones. If there are multiple destinations with the same preference + and there is no clear reason to favor one (e.g., by recognition of an + easily-reached address), then the sender-SMTP MUST randomize them to + spread the load across multiple mail exchangers for a specific + organization. + + The destination host (perhaps taken from the preferred MX record) may + be multihomed, in which case the domain name resolver will return a + list of alternative IP addresses. It is the responsibility of the + domain name resolver interface to have ordered this list by + decreasing preference if necessary, and SMTP MUST try them in the + order presented. + + Although the capability to try multiple alternative addresses is + required, specific installations may want to limit or disable the use + of alternative addresses. The question of whether a sender should + attempt retries using the different addresses of a multihomed host + has been controversial. The main argument for using the multiple + addresses is that it maximizes the probability of timely delivery, + and indeed sometimes the probability of any delivery; the counter- + argument is that it may result in unnecessary resource use. Note + that resource use is also strongly determined by the sending strategy + discussed in section 4.5.4.1. + + If an SMTP server receives a message with a destination for which it + is a designated Mail eXchanger, it MAY relay the message (potentially + after having rewritten the MAIL FROM and/or RCPT TO addresses), make + final delivery of the message, or hand it off using some mechanism + outside the SMTP-provided transport environment. Of course, neither + of the latter require that the list of MX records be examined + further. + + If it determines that it should relay the message without rewriting + the address, it MUST sort the MX records to determine candidates for + delivery. The records are first ordered by preference, with the + lowest-numbered records being most preferred. The relay host MUST + then inspect the list for any of the names or addresses by which it + might be known in mail transactions. If a matching record is found, + all records at that preference level and higher-numbered ones MUST be + discarded from consideration. If there are no records left at that + point, it is an error condition, and the message MUST be returned as + undeliverable. If records do remain, they SHOULD be tried, best + preference first, as described above. + + + +Klensin Standards Track [Page 61] + +RFC 2821 Simple Mail Transfer Protocol April 2001 + + +6. Problem Detection and Handling + +6.1 Reliable Delivery and Replies by Email + + When the receiver-SMTP accepts a piece of mail (by sending a "250 OK" + message in response to DATA), it is accepting responsibility for + delivering or relaying the message. It must take this responsibility + seriously. It MUST NOT lose the message for frivolous reasons, such + as because the host later crashes or because of a predictable + resource shortage. + + If there is a delivery failure after acceptance of a message, the + receiver-SMTP MUST formulate and mail a notification message. This + notification MUST be sent using a null ("<>") reverse path in the + envelope. The recipient of this notification MUST be the address + from the envelope return path (or the Return-Path: line). However, + if this address is null ("<>"), the receiver-SMTP MUST NOT send a + notification. Obviously, nothing in this section can or should + prohibit local decisions (i.e., as part of the same system + environment as the receiver-SMTP) to log or otherwise transmit + information about null address events locally if that is desired. If + the address is an explicit source route, it MUST be stripped down to + its final hop. + + For example, suppose that an error notification must be sent for a + message that arrived with: + + MAIL FROM:<@a,@b:user@d> + + The notification message MUST be sent using: + + RCPT TO: + + Some delivery failures after the message is accepted by SMTP will be + unavoidable. For example, it may be impossible for the receiving + SMTP server to validate all the delivery addresses in RCPT command(s) + due to a "soft" domain system error, because the target is a mailing + list (see earlier discussion of RCPT), or because the server is + acting as a relay and has no immediate access to the delivering + system. + + To avoid receiving duplicate messages as the result of timeouts, a + receiver-SMTP MUST seek to minimize the time required to respond to + the final . end of data indicator. See RFC 1047 [28] for + a discussion of this problem. + + + + + + +Klensin Standards Track [Page 62] + +RFC 2821 Simple Mail Transfer Protocol April 2001 + + +6.2 Loop Detection + + Simple counting of the number of "Received:" headers in a message has + proven to be an effective, although rarely optimal, method of + detecting loops in mail systems. SMTP servers using this technique + SHOULD use a large rejection threshold, normally at least 100 + Received entries. Whatever mechanisms are used, servers MUST contain + provisions for detecting and stopping trivial loops. + +6.3 Compensating for Irregularities + + Unfortunately, variations, creative interpretations, and outright + violations of Internet mail protocols do occur; some would suggest + that they occur quite frequently. The debate as to whether a well- + behaved SMTP receiver or relay should reject a malformed message, + attempt to pass it on unchanged, or attempt to repair it to increase + the odds of successful delivery (or subsequent reply) began almost + with the dawn of structured network mail and shows no signs of + abating. Advocates of rejection claim that attempted repairs are + rarely completely adequate and that rejection of bad messages is the + only way to get the offending software repaired. Advocates of + "repair" or "deliver no matter what" argue that users prefer that + mail go through it if at all possible and that there are significant + market pressures in that direction. In practice, these market + pressures may be more important to particular vendors than strict + conformance to the standards, regardless of the preference of the + actual developers. + + The problems associated with ill-formed messages were exacerbated by + the introduction of the split-UA mail reading protocols [3, 26, 5, + 21]. These protocols have encouraged the use of SMTP as a posting + protocol, and SMTP servers as relay systems for these client hosts + (which are often only intermittently connected to the Internet). + Historically, many of those client machines lacked some of the + mechanisms and information assumed by SMTP (and indeed, by the mail + format protocol [7]). Some could not keep adequate track of time; + others had no concept of time zones; still others could not identify + their own names or addresses; and, of course, none could satisfy the + assumptions that underlay RFC 822's conception of authenticated + addresses. + + In response to these weak SMTP clients, many SMTP systems now + complete messages that are delivered to them in incomplete or + incorrect form. This strategy is generally considered appropriate + when the server can identify or authenticate the client, and there + are prior agreements between them. By contrast, there is at best + great concern about fixes applied by a relay or delivery SMTP server + that has little or no knowledge of the user or client machine. + + + +Klensin Standards Track [Page 63] + +RFC 2821 Simple Mail Transfer Protocol April 2001 + + + The following changes to a message being processed MAY be applied + when necessary by an originating SMTP server, or one used as the + target of SMTP as an initial posting protocol: + + - Addition of a message-id field when none appears + + - Addition of a date, time or time zone when none appears + + - Correction of addresses to proper FQDN format + + The less information the server has about the client, the less likely + these changes are to be correct and the more caution and conservatism + should be applied when considering whether or not to perform fixes + and how. These changes MUST NOT be applied by an SMTP server that + provides an intermediate relay function. + + In all cases, properly-operating clients supplying correct + information are preferred to corrections by the SMTP server. In all + cases, documentation of actions performed by the servers (in trace + fields and/or header comments) is strongly encouraged. + +7. Security Considerations + +7.1 Mail Security and Spoofing + + SMTP mail is inherently insecure in that it is feasible for even + fairly casual users to negotiate directly with receiving and relaying + SMTP servers and create messages that will trick a naive recipient + into believing that they came from somewhere else. Constructing such + a message so that the "spoofed" behavior cannot be detected by an + expert is somewhat more difficult, but not sufficiently so as to be a + deterrent to someone who is determined and knowledgeable. + Consequently, as knowledge of Internet mail increases, so does the + knowledge that SMTP mail inherently cannot be authenticated, or + integrity checks provided, at the transport level. Real mail + security lies only in end-to-end methods involving the message + bodies, such as those which use digital signatures (see [14] and, + e.g., PGP [4] or S/MIME [31]). + + Various protocol extensions and configuration options that provide + authentication at the transport level (e.g., from an SMTP client to + an SMTP server) improve somewhat on the traditional situation + described above. However, unless they are accompanied by careful + handoffs of responsibility in a carefully-designed trust environment, + they remain inherently weaker than end-to-end mechanisms which use + digitally signed messages rather than depending on the integrity of + the transport system. + + + + +Klensin Standards Track [Page 64] + +RFC 2821 Simple Mail Transfer Protocol April 2001 + + + Efforts to make it more difficult for users to set envelope return + path and header "From" fields to point to valid addresses other than + their own are largely misguided: they frustrate legitimate + applications in which mail is sent by one user on behalf of another + or in which error (or normal) replies should be directed to a special + address. (Systems that provide convenient ways for users to alter + these fields on a per-message basis should attempt to establish a + primary and permanent mailbox address for the user so that Sender + fields within the message data can be generated sensibly.) + + This specification does not further address the authentication issues + associated with SMTP other than to advocate that useful functionality + not be disabled in the hope of providing some small margin of + protection against an ignorant user who is trying to fake mail. + +7.2 "Blind" Copies + + Addresses that do not appear in the message headers may appear in the + RCPT commands to an SMTP server for a number of reasons. The two + most common involve the use of a mailing address as a "list exploder" + (a single address that resolves into multiple addresses) and the + appearance of "blind copies". Especially when more than one RCPT + command is present, and in order to avoid defeating some of the + purpose of these mechanisms, SMTP clients and servers SHOULD NOT copy + the full set of RCPT command arguments into the headers, either as + part of trace headers or as informational or private-extension + headers. Since this rule is often violated in practice, and cannot + be enforced, sending SMTP systems that are aware of "bcc" use MAY + find it helpful to send each blind copy as a separate message + transaction containing only a single RCPT command. + + There is no inherent relationship between either "reverse" (from + MAIL, SAML, etc., commands) or "forward" (RCPT) addresses in the SMTP + transaction ("envelope") and the addresses in the headers. Receiving + systems SHOULD NOT attempt to deduce such relationships and use them + to alter the headers of the message for delivery. The popular + "Apparently-to" header is a violation of this principle as well as a + common source of unintended information disclosure and SHOULD NOT be + used. + +7.3 VRFY, EXPN, and Security + + As discussed in section 3.5, individual sites may want to disable + either or both of VRFY or EXPN for security reasons. As a corollary + to the above, implementations that permit this MUST NOT appear to + have verified addresses that are not, in fact, verified. If a site + + + + + +Klensin Standards Track [Page 65] + +RFC 2821 Simple Mail Transfer Protocol April 2001 + + + disables these commands for security reasons, the SMTP server MUST + return a 252 response, rather than a code that could be confused with + successful or unsuccessful verification. + + Returning a 250 reply code with the address listed in the VRFY + command after having checked it only for syntax violates this rule. + Of course, an implementation that "supports" VRFY by always returning + 550 whether or not the address is valid is equally not in + conformance. + + Within the last few years, the contents of mailing lists have become + popular as an address information source for so-called "spammers." + The use of EXPN to "harvest" addresses has increased as list + administrators have installed protections against inappropriate uses + of the lists themselves. Implementations SHOULD still provide + support for EXPN, but sites SHOULD carefully evaluate the tradeoffs. + As authentication mechanisms are introduced into SMTP, some sites may + choose to make EXPN available only to authenticated requestors. + +7.4 Information Disclosure in Announcements + + There has been an ongoing debate about the tradeoffs between the + debugging advantages of announcing server type and version (and, + sometimes, even server domain name) in the greeting response or in + response to the HELP command and the disadvantages of exposing + information that might be useful in a potential hostile attack. The + utility of the debugging information is beyond doubt. Those who + argue for making it available point out that it is far better to + actually secure an SMTP server rather than hope that trying to + conceal known vulnerabilities by hiding the server's precise identity + will provide more protection. Sites are encouraged to evaluate the + tradeoff with that issue in mind; implementations are strongly + encouraged to minimally provide for making type and version + information available in some way to other network hosts. + +7.5 Information Disclosure in Trace Fields + + In some circumstances, such as when mail originates from within a LAN + whose hosts are not directly on the public Internet, trace + ("Received") fields produced in conformance with this specification + may disclose host names and similar information that would not + normally be available. This ordinarily does not pose a problem, but + sites with special concerns about name disclosure should be aware of + it. Also, the optional FOR clause should be supplied with caution or + not at all when multiple recipients are involved lest it + inadvertently disclose the identities of "blind copy" recipients to + others. + + + + +Klensin Standards Track [Page 66] + +RFC 2821 Simple Mail Transfer Protocol April 2001 + + +7.6 Information Disclosure in Message Forwarding + + As discussed in section 3.4, use of the 251 or 551 reply codes to + identify the replacement address associated with a mailbox may + inadvertently disclose sensitive information. Sites that are + concerned about those issues should ensure that they select and + configure servers appropriately. + +7.7 Scope of Operation of SMTP Servers + + It is a well-established principle that an SMTP server may refuse to + accept mail for any operational or technical reason that makes sense + to the site providing the server. However, cooperation among sites + and installations makes the Internet possible. If sites take + excessive advantage of the right to reject traffic, the ubiquity of + email availability (one of the strengths of the Internet) will be + threatened; considerable care should be taken and balance maintained + if a site decides to be selective about the traffic it will accept + and process. + + In recent years, use of the relay function through arbitrary sites + has been used as part of hostile efforts to hide the actual origins + of mail. Some sites have decided to limit the use of the relay + function to known or identifiable sources, and implementations SHOULD + provide the capability to perform this type of filtering. When mail + is rejected for these or other policy reasons, a 550 code SHOULD be + used in response to EHLO, MAIL, or RCPT as appropriate. + +8. IANA Considerations + + IANA will maintain three registries in support of this specification. + The first consists of SMTP service extensions with the associated + keywords, and, as needed, parameters and verbs. As specified in + section 2.2.2, no entry may be made in this registry that starts in + an "X". Entries may be made only for service extensions (and + associated keywords, parameters, or verbs) that are defined in + standards-track or experimental RFCs specifically approved by the + IESG for this purpose. + + The second registry consists of "tags" that identify forms of domain + literals other than those for IPv4 addresses (specified in RFC 821 + and in this document) and IPv6 addresses (specified in this + document). Additional literal types require standardization before + being used; none are anticipated at this time. + + The third, established by RFC 821 and renewed by this specification, + is a registry of link and protocol identifiers to be used with the + "via" and "with" subclauses of the time stamp ("Received: header") + + + +Klensin Standards Track [Page 67] + +RFC 2821 Simple Mail Transfer Protocol April 2001 + + + described in section 4.4. Link and protocol identifiers in addition + to those specified in this document may be registered only by + standardization or by way of an RFC-documented, IESG-approved, + Experimental protocol extension. + +9. References + + [1] American National Standards Institute (formerly United States of + America Standards Institute), X3.4, 1968, "USA Code for + Information Interchange". ANSI X3.4-1968 has been replaced by + newer versions with slight modifications, but the 1968 version + remains definitive for the Internet. + + [2] Braden, R., "Requirements for Internet hosts - application and + support", STD 3, RFC 1123, October 1989. + + [3] Butler, M., Chase, D., Goldberger, J., Postel, J. and J. + Reynolds, "Post Office Protocol - version 2", RFC 937, February + 1985. + + [4] Callas, J., Donnerhacke, L., Finney, H. and R. Thayer, "OpenPGP + Message Format", RFC 2440, November 1998. + + [5] Crispin, M., "Interactive Mail Access Protocol - Version 2", RFC + 1176, August 1990. + + [6] Crispin, M., "Internet Message Access Protocol - Version 4", RFC + 2060, December 1996. + + [7] Crocker, D., "Standard for the Format of ARPA Internet Text + Messages", RFC 822, August 1982. + + [8] Crocker, D. and P. Overell, Eds., "Augmented BNF for Syntax + Specifications: ABNF", RFC 2234, November 1997. + + [9] De Winter, J., "SMTP Service Extension for Remote Message Queue + Starting", RFC 1985, August 1996. + + [10] Fajman, R., "An Extensible Message Format for Message + Disposition Notifications", RFC 2298, March 1998. + + [11] Freed, N, "Behavior of and Requirements for Internet Firewalls", + RFC 2979, October 2000. + + [12] Freed, N. and N. Borenstein, "Multipurpose Internet Mail + Extensions (MIME) Part One: Format of Internet Message Bodies", + RFC 2045, December 1996. + + + + +Klensin Standards Track [Page 68] + +RFC 2821 Simple Mail Transfer Protocol April 2001 + + + [13] Freed, N., "SMTP Service Extension for Command Pipelining", RFC + 2920, September 2000. + + [14] Galvin, J., Murphy, S., Crocker, S. and N. Freed, "Security + Multiparts for MIME: Multipart/Signed and Multipart/Encrypted", + RFC 1847, October 1995. + + [15] Gellens, R. and J. Klensin, "Message Submission", RFC 2476, + December 1998. + + [16] Kille, S., "Mapping between X.400 and RFC822/MIME", RFC 2156, + January 1998. + + [17] Hinden, R and S. Deering, Eds. "IP Version 6 Addressing + Architecture", RFC 2373, July 1998. + + [18] Klensin, J., Freed, N. and K. Moore, "SMTP Service Extension for + Message Size Declaration", STD 10, RFC 1870, November 1995. + + [19] Klensin, J., Freed, N., Rose, M., Stefferud, E. and D. Crocker, + "SMTP Service Extensions", STD 10, RFC 1869, November 1995. + + [20] Klensin, J., Freed, N., Rose, M., Stefferud, E. and D. Crocker, + "SMTP Service Extension for 8bit-MIMEtransport", RFC 1652, July + 1994. + + [21] Lambert, M., "PCMAIL: A distributed mail system for personal + computers", RFC 1056, July 1988. + + [22] Mockapetris, P., "Domain names - implementation and + specification", STD 13, RFC 1035, November 1987. + + Mockapetris, P., "Domain names - concepts and facilities", STD + 13, RFC 1034, November 1987. + + [23] Moore, K., "MIME (Multipurpose Internet Mail Extensions) Part + Three: Message Header Extensions for Non-ASCII Text", RFC 2047, + December 1996. + + [24] Moore, K., "SMTP Service Extension for Delivery Status + Notifications", RFC 1891, January 1996. + + [25] Moore, K., and G. Vaudreuil, "An Extensible Message Format for + Delivery Status Notifications", RFC 1894, January 1996. + + [26] Myers, J. and M. Rose, "Post Office Protocol - Version 3", STD + 53, RFC 1939, May 1996. + + + + +Klensin Standards Track [Page 69] + +RFC 2821 Simple Mail Transfer Protocol April 2001 + + + [27] Partridge, C., "Mail routing and the domain system", RFC 974, + January 1986. + + [28] Partridge, C., "Duplicate messages and SMTP", RFC 1047, February + 1988. + + [29] Postel, J., ed., "Transmission Control Protocol - DARPA Internet + Program Protocol Specification", STD 7, RFC 793, September 1981. + + [30] Postel, J., "Simple Mail Transfer Protocol", RFC 821, August + 1982. + + [31] Ramsdell, B., Ed., "S/MIME Version 3 Message Specification", RFC + 2633, June 1999. + + [32] Resnick, P., Ed., "Internet Message Format", RFC 2822, April + 2001. + + [33] Vaudreuil, G., "SMTP Service Extensions for Transmission of + Large and Binary MIME Messages", RFC 1830, August 1995. + + [34] Vaudreuil, G., "Enhanced Mail System Status Codes", RFC 1893, + January 1996. + +10. Editor's Address + + John C. Klensin + AT&T Laboratories + 99 Bedford St + Boston, MA 02111 USA + + Phone: 617-574-3076 + EMail: klensin@research.att.com + +11. Acknowledgments + + Many people worked long and hard on the many iterations of this + document. There was wide-ranging debate in the IETF DRUMS Working + Group, both on its mailing list and in face to face discussions, + about many technical issues and the role of a revised standard for + Internet mail transport, and many contributors helped form the + wording in this specification. The hundreds of participants in the + many discussions since RFC 821 was produced are too numerous to + mention, but they all helped this document become what it is. + + + + + + + +Klensin Standards Track [Page 70] + +RFC 2821 Simple Mail Transfer Protocol April 2001 + + +APPENDICES + +A. TCP Transport Service + + The TCP connection supports the transmission of 8-bit bytes. The + SMTP data is 7-bit ASCII characters. Each character is transmitted + as an 8-bit byte with the high-order bit cleared to zero. Service + extensions may modify this rule to permit transmission of full 8-bit + data bytes as part of the message body, but not in SMTP commands or + responses. + +B. Generating SMTP Commands from RFC 822 Headers + + Some systems use RFC 822 headers (only) in a mail submission + protocol, or otherwise generate SMTP commands from RFC 822 headers + when such a message is handed to an MTA from a UA. While the MTA-UA + protocol is a private matter, not covered by any Internet Standard, + there are problems with this approach. For example, there have been + repeated problems with proper handling of "bcc" copies and + redistribution lists when information that conceptually belongs to a + mail envelopes is not separated early in processing from header + information (and kept separate). + + It is recommended that the UA provide its initial ("submission + client") MTA with an envelope separate from the message itself. + However, if the envelope is not supplied, SMTP commands SHOULD be + generated as follows: + + 1. Each recipient address from a TO, CC, or BCC header field SHOULD + be copied to a RCPT command (generating multiple message copies if + that is required for queuing or delivery). This includes any + addresses listed in a RFC 822 "group". Any BCC fields SHOULD then + be removed from the headers. Once this process is completed, the + remaining headers SHOULD be checked to verify that at least one + To:, Cc:, or Bcc: header remains. If none do, then a bcc: header + with no additional information SHOULD be inserted as specified in + [32]. + + 2. The return address in the MAIL command SHOULD, if possible, be + derived from the system's identity for the submitting (local) + user, and the "From:" header field otherwise. If there is a + system identity available, it SHOULD also be copied to the Sender + header field if it is different from the address in the From + header field. (Any Sender field that was already there SHOULD be + removed.) Systems may provide a way for submitters to override + the envelope return address, but may want to restrict its use to + privileged users. This will not prevent mail forgery, but may + lessen its incidence; see section 7.1. + + + +Klensin Standards Track [Page 71] + +RFC 2821 Simple Mail Transfer Protocol April 2001 + + + When an MTA is being used in this way, it bears responsibility for + ensuring that the message being transmitted is valid. The mechanisms + for checking that validity, and for handling (or returning) messages + that are not valid at the time of arrival, are part of the MUA-MTA + interface and not covered by this specification. + + A submission protocol based on Standard RFC 822 information alone + MUST NOT be used to gateway a message from a foreign (non-SMTP) mail + system into an SMTP environment. Additional information to construct + an envelope must come from some source in the other environment, + whether supplemental headers or the foreign system's envelope. + + Attempts to gateway messages using only their header "to" and "cc" + fields have repeatedly caused mail loops and other behavior adverse + to the proper functioning of the Internet mail environment. These + problems have been especially common when the message originates from + an Internet mailing list and is distributed into the foreign + environment using envelope information. When these messages are then + processed by a header-only remailer, loops back to the Internet + environment (and the mailing list) are almost inevitable. + +C. Source Routes + + Historically, the was a reverse source routing list of + hosts and a source mailbox. The first host in the + SHOULD be the host sending the MAIL command. Similarly, the + may be a source routing lists of hosts and a + destination mailbox. However, in general, the SHOULD + contain only a mailbox and domain name, relying on the domain name + system to supply routing information if required. The use of source + routes is deprecated; while servers MUST be prepared to receive and + handle them as discussed in section 3.3 and F.2, clients SHOULD NOT + transmit them and this section was included only to provide context. + + For relay purposes, the forward-path may be a source route of the + form "@ONE,@TWO:JOE@THREE", where ONE, TWO, and THREE MUST BE fully- + qualified domain names. This form is used to emphasize the + distinction between an address and a route. The mailbox is an + absolute address, and the route is information about how to get + there. The two concepts should not be confused. + + If source routes are used, RFC 821 and the text below should be + consulted for the mechanisms for constructing and updating the + forward- and reverse-paths. + + + + + + + +Klensin Standards Track [Page 72] + +RFC 2821 Simple Mail Transfer Protocol April 2001 + + + The SMTP server transforms the command arguments by moving its own + identifier (its domain name or that of any domain for which it is + acting as a mail exchanger), if it appears, from the forward-path to + the beginning of the reverse-path. + + Notice that the forward-path and reverse-path appear in the SMTP + commands and replies, but not necessarily in the message. That is, + there is no need for these paths and especially this syntax to appear + in the "To:" , "From:", "CC:", etc. fields of the message header. + Conversely, SMTP servers MUST NOT derive final message delivery + information from message header fields. + + When the list of hosts is present, it is a "reverse" source route and + indicates that the mail was relayed through each host on the list + (the first host in the list was the most recent relay). This list is + used as a source route to return non-delivery notices to the sender. + As each relay host adds itself to the beginning of the list, it MUST + use its name as known in the transport environment to which it is + relaying the mail rather than that of the transport environment from + which the mail came (if they are different). + +D. Scenarios + + This section presents complete scenarios of several types of SMTP + sessions. In the examples, "C:" indicates what is said by the SMTP + client, and "S:" indicates what is said by the SMTP server. + +D.1 A Typical SMTP Transaction Scenario + + This SMTP example shows mail sent by Smith at host bar.com, to Jones, + Green, and Brown at host foo.com. Here we assume that host bar.com + contacts host foo.com directly. The mail is accepted for Jones and + Brown. Green does not have a mailbox at host foo.com. + + S: 220 foo.com Simple Mail Transfer Service Ready + C: EHLO bar.com + S: 250-foo.com greets bar.com + S: 250-8BITMIME + S: 250-SIZE + S: 250-DSN + S: 250 HELP + C: MAIL FROM: + S: 250 OK + C: RCPT TO: + S: 250 OK + C: RCPT TO: + S: 550 No such user here + C: RCPT TO: + + + +Klensin Standards Track [Page 73] + +RFC 2821 Simple Mail Transfer Protocol April 2001 + + + S: 250 OK + C: DATA + S: 354 Start mail input; end with . + C: Blah blah blah... + C: ...etc. etc. etc. + C: . + S: 250 OK + C: QUIT + S: 221 foo.com Service closing transmission channel + +D.2 Aborted SMTP Transaction Scenario + + S: 220 foo.com Simple Mail Transfer Service Ready + C: EHLO bar.com + S: 250-foo.com greets bar.com + S: 250-8BITMIME + S: 250-SIZE + S: 250-DSN + S: 250 HELP + C: MAIL FROM: + S: 250 OK + C: RCPT TO: + S: 250 OK + C: RCPT TO: + S: 550 No such user here + C: RSET + S: 250 OK + C: QUIT + S: 221 foo.com Service closing transmission channel + +D.3 Relayed Mail Scenario + + Step 1 -- Source Host to Relay Host + + S: 220 foo.com Simple Mail Transfer Service Ready + C: EHLO bar.com + S: 250-foo.com greets bar.com + S: 250-8BITMIME + S: 250-SIZE + S: 250-DSN + S: 250 HELP + C: MAIL FROM: + S: 250 OK + C: RCPT TO:<@foo.com:Jones@XYZ.COM> + S: 250 OK + C: DATA + S: 354 Start mail input; end with . + C: Date: Thu, 21 May 1998 05:33:29 -0700 + + + +Klensin Standards Track [Page 74] + +RFC 2821 Simple Mail Transfer Protocol April 2001 + + + C: From: John Q. Public + C: Subject: The Next Meeting of the Board + C: To: Jones@xyz.com + C: + C: Bill: + C: The next meeting of the board of directors will be + C: on Tuesday. + C: John. + C: . + S: 250 OK + C: QUIT + S: 221 foo.com Service closing transmission channel + + Step 2 -- Relay Host to Destination Host + + S: 220 xyz.com Simple Mail Transfer Service Ready + C: EHLO foo.com + S: 250 xyz.com is on the air + C: MAIL FROM:<@foo.com:JQP@bar.com> + S: 250 OK + C: RCPT TO: + S: 250 OK + C: DATA + S: 354 Start mail input; end with . + C: Received: from bar.com by foo.com ; Thu, 21 May 1998 + C: 05:33:29 -0700 + C: Date: Thu, 21 May 1998 05:33:22 -0700 + C: From: John Q. Public + C: Subject: The Next Meeting of the Board + C: To: Jones@xyz.com + C: + C: Bill: + C: The next meeting of the board of directors will be + C: on Tuesday. + C: John. + C: . + S: 250 OK + C: QUIT + S: 221 foo.com Service closing transmission channel + +D.4 Verifying and Sending Scenario + + S: 220 foo.com Simple Mail Transfer Service Ready + C: EHLO bar.com + S: 250-foo.com greets bar.com + S: 250-8BITMIME + S: 250-SIZE + S: 250-DSN + + + +Klensin Standards Track [Page 75] + +RFC 2821 Simple Mail Transfer Protocol April 2001 + + + S: 250-VRFY + S: 250 HELP + C: VRFY Crispin + S: 250 Mark Crispin + C: SEND FROM: + S: 250 OK + C: RCPT TO: + S: 250 OK + C: DATA + S: 354 Start mail input; end with . + C: Blah blah blah... + C: ...etc. etc. etc. + C: . + S: 250 OK + C: QUIT + S: 221 foo.com Service closing transmission channel + +E. Other Gateway Issues + + In general, gateways between the Internet and other mail systems + SHOULD attempt to preserve any layering semantics across the + boundaries between the two mail systems involved. Gateway- + translation approaches that attempt to take shortcuts by mapping, + (such as envelope information from one system to the message headers + or body of another) have generally proven to be inadequate in + important ways. Systems translating between environments that do not + support both envelopes and headers and Internet mail must be written + with the understanding that some information loss is almost + inevitable. + +F. Deprecated Features of RFC 821 + + A few features of RFC 821 have proven to be problematic and SHOULD + NOT be used in Internet mail. + +F.1 TURN + + This command, described in RFC 821, raises important security issues + since, in the absence of strong authentication of the host requesting + that the client and server switch roles, it can easily be used to + divert mail from its correct destination. Its use is deprecated; + SMTP systems SHOULD NOT use it unless the server can authenticate the + client. + + + + + + + + +Klensin Standards Track [Page 76] + +RFC 2821 Simple Mail Transfer Protocol April 2001 + + +F.2 Source Routing + + RFC 821 utilized the concept of explicit source routing to get mail + from one host to another via a series of relays. The requirement to + utilize source routes in regular mail traffic was eliminated by the + introduction of the domain name system "MX" record and the last + significant justification for them was eliminated by the + introduction, in RFC 1123, of a clear requirement that addresses + following an "@" must all be fully-qualified domain names. + Consequently, the only remaining justifications for the use of source + routes are support for very old SMTP clients or MUAs and in mail + system debugging. They can, however, still be useful in the latter + circumstance and for routing mail around serious, but temporary, + problems such as problems with the relevant DNS records. + + SMTP servers MUST continue to accept source route syntax as specified + in the main body of this document and in RFC 1123. They MAY, if + necessary, ignore the routes and utilize only the target domain in + the address. If they do utilize the source route, the message MUST + be sent to the first domain shown in the address. In particular, a + server MUST NOT guess at shortcuts within the source route. + + Clients SHOULD NOT utilize explicit source routing except under + unusual circumstances, such as debugging or potentially relaying + around firewall or mail system configuration errors. + +F.3 HELO + + As discussed in sections 3.1 and 4.1.1, EHLO is strongly preferred to + HELO when the server will accept the former. Servers must continue + to accept and process HELO in order to support older clients. + +F.4 #-literals + + RFC 821 provided for specifying an Internet address as a decimal + integer host number prefixed by a pound sign, "#". In practice, that + form has been obsolete since the introduction of TCP/IP. It is + deprecated and MUST NOT be used. + +F.5 Dates and Years + + When dates are inserted into messages by SMTP clients or servers + (e.g., in trace fields), four-digit years MUST BE used. Two-digit + years are deprecated; three-digit years were never permitted in the + Internet mail system. + + + + + + +Klensin Standards Track [Page 77] + +RFC 2821 Simple Mail Transfer Protocol April 2001 + + +F.6 Sending versus Mailing + + In addition to specifying a mechanism for delivering messages to + user's mailboxes, RFC 821 provided additional, optional, commands to + deliver messages directly to the user's terminal screen. These + commands (SEND, SAML, SOML) were rarely implemented, and changes in + workstation technology and the introduction of other protocols may + have rendered them obsolete even where they are implemented. + + Clients SHOULD NOT provide SEND, SAML, or SOML as services. Servers + MAY implement them. If they are implemented by servers, the + implementation model specified in RFC 821 MUST be used and the + command names MUST be published in the response to the EHLO command. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Klensin Standards Track [Page 78] + +RFC 2821 Simple Mail Transfer Protocol April 2001 + + +Full Copyright Statement + + Copyright (C) The Internet Society (2001). All Rights Reserved. + + This document and translations of it may be copied and furnished to + others, and derivative works that comment on or otherwise explain it + or assist in its implementation may be prepared, copied, published + and distributed, in whole or in part, without restriction of any + kind, provided that the above copyright notice and this paragraph are + included on all such copies and derivative works. However, this + document itself may not be modified in any way, such as by removing + the copyright notice or references to the Internet Society or other + Internet organizations, except as needed for the purpose of + developing Internet standards in which case the procedures for + copyrights defined in the Internet Standards process must be + followed, or as required to translate it into languages other than + English. + + The limited permissions granted above are perpetual and will not be + revoked by the Internet Society or its successors or assigns. + + This document and the information contained herein is provided on an + "AS IS" basis and THE INTERNET SOCIETY AND THE INTERNET ENGINEERING + TASK FORCE DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING + BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION + HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF + MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + +Acknowledgement + + Funding for the RFC Editor function is currently provided by the + Internet Society. + + + + + + + + + + + + + + + + + + + +Klensin Standards Track [Page 79] + diff --git a/vendor/swiftmailer/swiftmailer/notes/rfc/rfc2822.txt b/vendor/swiftmailer/swiftmailer/notes/rfc/rfc2822.txt new file mode 100755 index 0000000..9f698f7 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/notes/rfc/rfc2822.txt @@ -0,0 +1,2859 @@ + + + + + + +Network Working Group P. Resnick, Editor +Request for Comments: 2822 QUALCOMM Incorporated +Obsoletes: 822 April 2001 +Category: Standards Track + + + Internet Message Format + +Status of this Memo + + This document specifies an Internet standards track protocol for the + Internet community, and requests discussion and suggestions for + improvements. Please refer to the current edition of the "Internet + Official Protocol Standards" (STD 1) for the standardization state + and status of this protocol. Distribution of this memo is unlimited. + +Copyright Notice + + Copyright (C) The Internet Society (2001). All Rights Reserved. + +Abstract + + This standard specifies a syntax for text messages that are sent + between computer users, within the framework of "electronic mail" + messages. This standard supersedes the one specified in Request For + Comments (RFC) 822, "Standard for the Format of ARPA Internet Text + Messages", updating it to reflect current practice and incorporating + incremental changes that were specified in other RFCs. + +Table of Contents + + 1. Introduction ............................................... 3 + 1.1. Scope .................................................... 3 + 1.2. Notational conventions ................................... 4 + 1.2.1. Requirements notation .................................. 4 + 1.2.2. Syntactic notation ..................................... 4 + 1.3. Structure of this document ............................... 4 + 2. Lexical Analysis of Messages ............................... 5 + 2.1. General Description ...................................... 5 + 2.1.1. Line Length Limits ..................................... 6 + 2.2. Header Fields ............................................ 7 + 2.2.1. Unstructured Header Field Bodies ....................... 7 + 2.2.2. Structured Header Field Bodies ......................... 7 + 2.2.3. Long Header Fields ..................................... 7 + 2.3. Body ..................................................... 8 + 3. Syntax ..................................................... 9 + 3.1. Introduction ............................................. 9 + 3.2. Lexical Tokens ........................................... 9 + + + +Resnick Standards Track [Page 1] + +RFC 2822 Internet Message Format April 2001 + + + 3.2.1. Primitive Tokens ....................................... 9 + 3.2.2. Quoted characters ......................................10 + 3.2.3. Folding white space and comments .......................11 + 3.2.4. Atom ...................................................12 + 3.2.5. Quoted strings .........................................13 + 3.2.6. Miscellaneous tokens ...................................13 + 3.3. Date and Time Specification ..............................14 + 3.4. Address Specification ....................................15 + 3.4.1. Addr-spec specification ................................16 + 3.5 Overall message syntax ....................................17 + 3.6. Field definitions ........................................18 + 3.6.1. The origination date field .............................20 + 3.6.2. Originator fields ......................................21 + 3.6.3. Destination address fields .............................22 + 3.6.4. Identification fields ..................................23 + 3.6.5. Informational fields ...................................26 + 3.6.6. Resent fields ..........................................26 + 3.6.7. Trace fields ...........................................28 + 3.6.8. Optional fields ........................................29 + 4. Obsolete Syntax ............................................29 + 4.1. Miscellaneous obsolete tokens ............................30 + 4.2. Obsolete folding white space .............................31 + 4.3. Obsolete Date and Time ...................................31 + 4.4. Obsolete Addressing ......................................33 + 4.5. Obsolete header fields ...................................33 + 4.5.1. Obsolete origination date field ........................34 + 4.5.2. Obsolete originator fields .............................34 + 4.5.3. Obsolete destination address fields ....................34 + 4.5.4. Obsolete identification fields .........................35 + 4.5.5. Obsolete informational fields ..........................35 + 4.5.6. Obsolete resent fields .................................35 + 4.5.7. Obsolete trace fields ..................................36 + 4.5.8. Obsolete optional fields ...............................36 + 5. Security Considerations ....................................36 + 6. Bibliography ...............................................37 + 7. Editor's Address ...........................................38 + 8. Acknowledgements ...........................................39 + Appendix A. Example messages ..................................41 + A.1. Addressing examples ......................................41 + A.1.1. A message from one person to another with simple + addressing .............................................41 + A.1.2. Different types of mailboxes ...........................42 + A.1.3. Group addresses ........................................43 + A.2. Reply messages ...........................................43 + A.3. Resent messages ..........................................44 + A.4. Messages with trace fields ...............................46 + A.5. White space, comments, and other oddities ................47 + A.6. Obsoleted forms ..........................................47 + + + +Resnick Standards Track [Page 2] + +RFC 2822 Internet Message Format April 2001 + + + A.6.1. Obsolete addressing ....................................48 + A.6.2. Obsolete dates .........................................48 + A.6.3. Obsolete white space and comments ......................48 + Appendix B. Differences from earlier standards ................49 + Appendix C. Notices ...........................................50 + Full Copyright Statement ......................................51 + +1. Introduction + +1.1. Scope + + This standard specifies a syntax for text messages that are sent + between computer users, within the framework of "electronic mail" + messages. This standard supersedes the one specified in Request For + Comments (RFC) 822, "Standard for the Format of ARPA Internet Text + Messages" [RFC822], updating it to reflect current practice and + incorporating incremental changes that were specified in other RFCs + [STD3]. + + This standard specifies a syntax only for text messages. In + particular, it makes no provision for the transmission of images, + audio, or other sorts of structured data in electronic mail messages. + There are several extensions published, such as the MIME document + series [RFC2045, RFC2046, RFC2049], which describe mechanisms for the + transmission of such data through electronic mail, either by + extending the syntax provided here or by structuring such messages to + conform to this syntax. Those mechanisms are outside of the scope of + this standard. + + In the context of electronic mail, messages are viewed as having an + envelope and contents. The envelope contains whatever information is + needed to accomplish transmission and delivery. (See [RFC2821] for a + discussion of the envelope.) The contents comprise the object to be + delivered to the recipient. This standard applies only to the format + and some of the semantics of message contents. It contains no + specification of the information in the envelope. + + However, some message systems may use information from the contents + to create the envelope. It is intended that this standard facilitate + the acquisition of such information by programs. + + This specification is intended as a definition of what message + content format is to be passed between systems. Though some message + systems locally store messages in this format (which eliminates the + need for translation between formats) and others use formats that + differ from the one specified in this standard, local storage is + outside of the scope of this standard. + + + + +Resnick Standards Track [Page 3] + +RFC 2822 Internet Message Format April 2001 + + + Note: This standard is not intended to dictate the internal formats + used by sites, the specific message system features that they are + expected to support, or any of the characteristics of user interface + programs that create or read messages. In addition, this standard + does not specify an encoding of the characters for either transport + or storage; that is, it does not specify the number of bits used or + how those bits are specifically transferred over the wire or stored + on disk. + +1.2. Notational conventions + +1.2.1. Requirements notation + + This document occasionally uses terms that appear in capital letters. + When the terms "MUST", "SHOULD", "RECOMMENDED", "MUST NOT", "SHOULD + NOT", and "MAY" appear capitalized, they are being used to indicate + particular requirements of this specification. A discussion of the + meanings of these terms appears in [RFC2119]. + +1.2.2. Syntactic notation + + This standard uses the Augmented Backus-Naur Form (ABNF) notation + specified in [RFC2234] for the formal definitions of the syntax of + messages. Characters will be specified either by a decimal value + (e.g., the value %d65 for uppercase A and %d97 for lowercase A) or by + a case-insensitive literal value enclosed in quotation marks (e.g., + "A" for either uppercase or lowercase A). See [RFC2234] for the full + description of the notation. + +1.3. Structure of this document + + This document is divided into several sections. + + This section, section 1, is a short introduction to the document. + + Section 2 lays out the general description of a message and its + constituent parts. This is an overview to help the reader understand + some of the general principles used in the later portions of this + document. Any examples in this section MUST NOT be taken as + specification of the formal syntax of any part of a message. + + Section 3 specifies formal ABNF rules for the structure of each part + of a message (the syntax) and describes the relationship between + those parts and their meaning in the context of a message (the + semantics). That is, it describes the actual rules for the structure + of each part of a message (the syntax) as well as a description of + the parts and instructions on how they ought to be interpreted (the + semantics). This includes analysis of the syntax and semantics of + + + +Resnick Standards Track [Page 4] + +RFC 2822 Internet Message Format April 2001 + + + subparts of messages that have specific structure. The syntax + included in section 3 represents messages as they MUST be created. + There are also notes in section 3 to indicate if any of the options + specified in the syntax SHOULD be used over any of the others. + + Both sections 2 and 3 describe messages that are legal to generate + for purposes of this standard. + + Section 4 of this document specifies an "obsolete" syntax. There are + references in section 3 to these obsolete syntactic elements. The + rules of the obsolete syntax are elements that have appeared in + earlier revisions of this standard or have previously been widely + used in Internet messages. As such, these elements MUST be + interpreted by parsers of messages in order to be conformant to this + standard. However, since items in this syntax have been determined + to be non-interoperable or to cause significant problems for + recipients of messages, they MUST NOT be generated by creators of + conformant messages. + + Section 5 details security considerations to take into account when + implementing this standard. + + Section 6 is a bibliography of references in this document. + + Section 7 contains the editor's address. + + Section 8 contains acknowledgements. + + Appendix A lists examples of different sorts of messages. These + examples are not exhaustive of the types of messages that appear on + the Internet, but give a broad overview of certain syntactic forms. + + Appendix B lists the differences between this standard and earlier + standards for Internet messages. + + Appendix C has copyright and intellectual property notices. + +2. Lexical Analysis of Messages + +2.1. General Description + + At the most basic level, a message is a series of characters. A + message that is conformant with this standard is comprised of + characters with values in the range 1 through 127 and interpreted as + US-ASCII characters [ASCII]. For brevity, this document sometimes + refers to this range of characters as simply "US-ASCII characters". + + + + + +Resnick Standards Track [Page 5] + +RFC 2822 Internet Message Format April 2001 + + + Note: This standard specifies that messages are made up of characters + in the US-ASCII range of 1 through 127. There are other documents, + specifically the MIME document series [RFC2045, RFC2046, RFC2047, + RFC2048, RFC2049], that extend this standard to allow for values + outside of that range. Discussion of those mechanisms is not within + the scope of this standard. + + Messages are divided into lines of characters. A line is a series of + characters that is delimited with the two characters carriage-return + and line-feed; that is, the carriage return (CR) character (ASCII + value 13) followed immediately by the line feed (LF) character (ASCII + value 10). (The carriage-return/line-feed pair is usually written in + this document as "CRLF".) + + A message consists of header fields (collectively called "the header + of the message") followed, optionally, by a body. The header is a + sequence of lines of characters with special syntax as defined in + this standard. The body is simply a sequence of characters that + follows the header and is separated from the header by an empty line + (i.e., a line with nothing preceding the CRLF). + +2.1.1. Line Length Limits + + There are two limits that this standard places on the number of + characters in a line. Each line of characters MUST be no more than + 998 characters, and SHOULD be no more than 78 characters, excluding + the CRLF. + + The 998 character limit is due to limitations in many implementations + which send, receive, or store Internet Message Format messages that + simply cannot handle more than 998 characters on a line. Receiving + implementations would do well to handle an arbitrarily large number + of characters in a line for robustness sake. However, there are so + many implementations which (in compliance with the transport + requirements of [RFC2821]) do not accept messages containing more + than 1000 character including the CR and LF per line, it is important + for implementations not to create such messages. + + The more conservative 78 character recommendation is to accommodate + the many implementations of user interfaces that display these + messages which may truncate, or disastrously wrap, the display of + more than 78 characters per line, in spite of the fact that such + implementations are non-conformant to the intent of this + specification (and that of [RFC2821] if they actually cause + information to be lost). Again, even though this limitation is put on + messages, it is encumbant upon implementations which display messages + + + + + +Resnick Standards Track [Page 6] + +RFC 2822 Internet Message Format April 2001 + + + to handle an arbitrarily large number of characters in a line + (certainly at least up to the 998 character limit) for the sake of + robustness. + +2.2. Header Fields + + Header fields are lines composed of a field name, followed by a colon + (":"), followed by a field body, and terminated by CRLF. A field + name MUST be composed of printable US-ASCII characters (i.e., + characters that have values between 33 and 126, inclusive), except + colon. A field body may be composed of any US-ASCII characters, + except for CR and LF. However, a field body may contain CRLF when + used in header "folding" and "unfolding" as described in section + 2.2.3. All field bodies MUST conform to the syntax described in + sections 3 and 4 of this standard. + +2.2.1. Unstructured Header Field Bodies + + Some field bodies in this standard are defined simply as + "unstructured" (which is specified below as any US-ASCII characters, + except for CR and LF) with no further restrictions. These are + referred to as unstructured field bodies. Semantically, unstructured + field bodies are simply to be treated as a single line of characters + with no further processing (except for header "folding" and + "unfolding" as described in section 2.2.3). + +2.2.2. Structured Header Field Bodies + + Some field bodies in this standard have specific syntactical + structure more restrictive than the unstructured field bodies + described above. These are referred to as "structured" field bodies. + Structured field bodies are sequences of specific lexical tokens as + described in sections 3 and 4 of this standard. Many of these tokens + are allowed (according to their syntax) to be introduced or end with + comments (as described in section 3.2.3) as well as the space (SP, + ASCII value 32) and horizontal tab (HTAB, ASCII value 9) characters + (together known as the white space characters, WSP), and those WSP + characters are subject to header "folding" and "unfolding" as + described in section 2.2.3. Semantic analysis of structured field + bodies is given along with their syntax. + +2.2.3. Long Header Fields + + Each header field is logically a single line of characters comprising + the field name, the colon, and the field body. For convenience + however, and to deal with the 998/78 character limitations per line, + the field body portion of a header field can be split into a multiple + line representation; this is called "folding". The general rule is + + + +Resnick Standards Track [Page 7] + +RFC 2822 Internet Message Format April 2001 + + + that wherever this standard allows for folding white space (not + simply WSP characters), a CRLF may be inserted before any WSP. For + example, the header field: + + Subject: This is a test + + can be represented as: + + Subject: This + is a test + + Note: Though structured field bodies are defined in such a way that + folding can take place between many of the lexical tokens (and even + within some of the lexical tokens), folding SHOULD be limited to + placing the CRLF at higher-level syntactic breaks. For instance, if + a field body is defined as comma-separated values, it is recommended + that folding occur after the comma separating the structured items in + preference to other places where the field could be folded, even if + it is allowed elsewhere. + + The process of moving from this folded multiple-line representation + of a header field to its single line representation is called + "unfolding". Unfolding is accomplished by simply removing any CRLF + that is immediately followed by WSP. Each header field should be + treated in its unfolded form for further syntactic and semantic + evaluation. + +2.3. Body + + The body of a message is simply lines of US-ASCII characters. The + only two limitations on the body are as follows: + + - CR and LF MUST only occur together as CRLF; they MUST NOT appear + independently in the body. + + - Lines of characters in the body MUST be limited to 998 characters, + and SHOULD be limited to 78 characters, excluding the CRLF. + + Note: As was stated earlier, there are other standards documents, + specifically the MIME documents [RFC2045, RFC2046, RFC2048, RFC2049] + that extend this standard to allow for different sorts of message + bodies. Again, these mechanisms are beyond the scope of this + document. + + + + + + + + +Resnick Standards Track [Page 8] + +RFC 2822 Internet Message Format April 2001 + + +3. Syntax + +3.1. Introduction + + The syntax as given in this section defines the legal syntax of + Internet messages. Messages that are conformant to this standard + MUST conform to the syntax in this section. If there are options in + this section where one option SHOULD be generated, that is indicated + either in the prose or in a comment next to the syntax. + + For the defined expressions, a short description of the syntax and + use is given, followed by the syntax in ABNF, followed by a semantic + analysis. Primitive tokens that are used but otherwise unspecified + come from [RFC2234]. + + In some of the definitions, there will be nonterminals whose names + start with "obs-". These "obs-" elements refer to tokens defined in + the obsolete syntax in section 4. In all cases, these productions + are to be ignored for the purposes of generating legal Internet + messages and MUST NOT be used as part of such a message. However, + when interpreting messages, these tokens MUST be honored as part of + the legal syntax. In this sense, section 3 defines a grammar for + generation of messages, with "obs-" elements that are to be ignored, + while section 4 adds grammar for interpretation of messages. + +3.2. Lexical Tokens + + The following rules are used to define an underlying lexical + analyzer, which feeds tokens to the higher-level parsers. This + section defines the tokens used in structured header field bodies. + + Note: Readers of this standard need to pay special attention to how + these lexical tokens are used in both the lower-level and + higher-level syntax later in the document. Particularly, the white + space tokens and the comment tokens defined in section 3.2.3 get used + in the lower-level tokens defined here, and those lower-level tokens + are in turn used as parts of the higher-level tokens defined later. + Therefore, the white space and comments may be allowed in the + higher-level tokens even though they may not explicitly appear in a + particular definition. + +3.2.1. Primitive Tokens + + The following are primitive tokens referred to elsewhere in this + standard, but not otherwise defined in [RFC2234]. Some of them will + not appear anywhere else in the syntax, but they are convenient to + refer to in other parts of this document. + + + + +Resnick Standards Track [Page 9] + +RFC 2822 Internet Message Format April 2001 + + + Note: The "specials" below are just such an example. Though the + specials token does not appear anywhere else in this standard, it is + useful for implementers who use tools that lexically analyze + messages. Each of the characters in specials can be used to indicate + a tokenization point in lexical analysis. + +NO-WS-CTL = %d1-8 / ; US-ASCII control characters + %d11 / ; that do not include the + %d12 / ; carriage return, line feed, + %d14-31 / ; and white space characters + %d127 + +text = %d1-9 / ; Characters excluding CR and LF + %d11 / + %d12 / + %d14-127 / + obs-text + +specials = "(" / ")" / ; Special characters used in + "<" / ">" / ; other parts of the syntax + "[" / "]" / + ":" / ";" / + "@" / "\" / + "," / "." / + DQUOTE + + No special semantics are attached to these tokens. They are simply + single characters. + +3.2.2. Quoted characters + + Some characters are reserved for special interpretation, such as + delimiting lexical tokens. To permit use of these characters as + uninterpreted data, a quoting mechanism is provided. + +quoted-pair = ("\" text) / obs-qp + + Where any quoted-pair appears, it is to be interpreted as the text + character alone. That is to say, the "\" character that appears as + part of a quoted-pair is semantically "invisible". + + Note: The "\" character may appear in a message where it is not part + of a quoted-pair. A "\" character that does not appear in a + quoted-pair is not semantically invisible. The only places in this + standard where quoted-pair currently appears are ccontent, qcontent, + dcontent, no-fold-quote, and no-fold-literal. + + + + + +Resnick Standards Track [Page 10] + +RFC 2822 Internet Message Format April 2001 + + +3.2.3. Folding white space and comments + + White space characters, including white space used in folding + (described in section 2.2.3), may appear between many elements in + header field bodies. Also, strings of characters that are treated as + comments may be included in structured field bodies as characters + enclosed in parentheses. The following defines the folding white + space (FWS) and comment constructs. + + Strings of characters enclosed in parentheses are considered comments + so long as they do not appear within a "quoted-string", as defined in + section 3.2.5. Comments may nest. + + There are several places in this standard where comments and FWS may + be freely inserted. To accommodate that syntax, an additional token + for "CFWS" is defined for places where comments and/or FWS can occur. + However, where CFWS occurs in this standard, it MUST NOT be inserted + in such a way that any line of a folded header field is made up + entirely of WSP characters and nothing else. + +FWS = ([*WSP CRLF] 1*WSP) / ; Folding white space + obs-FWS + +ctext = NO-WS-CTL / ; Non white space controls + + %d33-39 / ; The rest of the US-ASCII + %d42-91 / ; characters not including "(", + %d93-126 ; ")", or "\" + +ccontent = ctext / quoted-pair / comment + +comment = "(" *([FWS] ccontent) [FWS] ")" + +CFWS = *([FWS] comment) (([FWS] comment) / FWS) + + Throughout this standard, where FWS (the folding white space token) + appears, it indicates a place where header folding, as discussed in + section 2.2.3, may take place. Wherever header folding appears in a + message (that is, a header field body containing a CRLF followed by + any WSP), header unfolding (removal of the CRLF) is performed before + any further lexical analysis is performed on that header field + according to this standard. That is to say, any CRLF that appears in + FWS is semantically "invisible." + + A comment is normally used in a structured field body to provide some + human readable informational text. Since a comment is allowed to + contain FWS, folding is permitted within the comment. Also note that + since quoted-pair is allowed in a comment, the parentheses and + + + +Resnick Standards Track [Page 11] + +RFC 2822 Internet Message Format April 2001 + + + backslash characters may appear in a comment so long as they appear + as a quoted-pair. Semantically, the enclosing parentheses are not + part of the comment; the comment is what is contained between the two + parentheses. As stated earlier, the "\" in any quoted-pair and the + CRLF in any FWS that appears within the comment are semantically + "invisible" and therefore not part of the comment either. + + Runs of FWS, comment or CFWS that occur between lexical tokens in a + structured field header are semantically interpreted as a single + space character. + +3.2.4. Atom + + Several productions in structured header field bodies are simply + strings of certain basic characters. Such productions are called + atoms. + + Some of the structured header field bodies also allow the period + character (".", ASCII value 46) within runs of atext. An additional + "dot-atom" token is defined for those purposes. + +atext = ALPHA / DIGIT / ; Any character except controls, + "!" / "#" / ; SP, and specials. + "$" / "%" / ; Used for atoms + "&" / "'" / + "*" / "+" / + "-" / "/" / + "=" / "?" / + "^" / "_" / + "`" / "{" / + "|" / "}" / + "~" + +atom = [CFWS] 1*atext [CFWS] + +dot-atom = [CFWS] dot-atom-text [CFWS] + +dot-atom-text = 1*atext *("." 1*atext) + + Both atom and dot-atom are interpreted as a single unit, comprised of + the string of characters that make it up. Semantically, the optional + comments and FWS surrounding the rest of the characters are not part + of the atom; the atom is only the run of atext characters in an atom, + or the atext and "." characters in a dot-atom. + + + + + + + +Resnick Standards Track [Page 12] + +RFC 2822 Internet Message Format April 2001 + + +3.2.5. Quoted strings + + Strings of characters that include characters other than those + allowed in atoms may be represented in a quoted string format, where + the characters are surrounded by quote (DQUOTE, ASCII value 34) + characters. + +qtext = NO-WS-CTL / ; Non white space controls + + %d33 / ; The rest of the US-ASCII + %d35-91 / ; characters not including "\" + %d93-126 ; or the quote character + +qcontent = qtext / quoted-pair + +quoted-string = [CFWS] + DQUOTE *([FWS] qcontent) [FWS] DQUOTE + [CFWS] + + A quoted-string is treated as a unit. That is, quoted-string is + identical to atom, semantically. Since a quoted-string is allowed to + contain FWS, folding is permitted. Also note that since quoted-pair + is allowed in a quoted-string, the quote and backslash characters may + appear in a quoted-string so long as they appear as a quoted-pair. + + Semantically, neither the optional CFWS outside of the quote + characters nor the quote characters themselves are part of the + quoted-string; the quoted-string is what is contained between the two + quote characters. As stated earlier, the "\" in any quoted-pair and + the CRLF in any FWS/CFWS that appears within the quoted-string are + semantically "invisible" and therefore not part of the quoted-string + either. + +3.2.6. Miscellaneous tokens + + Three additional tokens are defined, word and phrase for combinations + of atoms and/or quoted-strings, and unstructured for use in + unstructured header fields and in some places within structured + header fields. + +word = atom / quoted-string + +phrase = 1*word / obs-phrase + + + + + + + + +Resnick Standards Track [Page 13] + +RFC 2822 Internet Message Format April 2001 + + +utext = NO-WS-CTL / ; Non white space controls + %d33-126 / ; The rest of US-ASCII + obs-utext + +unstructured = *([FWS] utext) [FWS] + +3.3. Date and Time Specification + + Date and time occur in several header fields. This section specifies + the syntax for a full date and time specification. Though folding + white space is permitted throughout the date-time specification, it + is RECOMMENDED that a single space be used in each place that FWS + appears (whether it is required or optional); some older + implementations may not interpret other occurrences of folding white + space correctly. + +date-time = [ day-of-week "," ] date FWS time [CFWS] + +day-of-week = ([FWS] day-name) / obs-day-of-week + +day-name = "Mon" / "Tue" / "Wed" / "Thu" / + "Fri" / "Sat" / "Sun" + +date = day month year + +year = 4*DIGIT / obs-year + +month = (FWS month-name FWS) / obs-month + +month-name = "Jan" / "Feb" / "Mar" / "Apr" / + "May" / "Jun" / "Jul" / "Aug" / + "Sep" / "Oct" / "Nov" / "Dec" + +day = ([FWS] 1*2DIGIT) / obs-day + +time = time-of-day FWS zone + +time-of-day = hour ":" minute [ ":" second ] + +hour = 2DIGIT / obs-hour + +minute = 2DIGIT / obs-minute + +second = 2DIGIT / obs-second + +zone = (( "+" / "-" ) 4DIGIT) / obs-zone + + + + + +Resnick Standards Track [Page 14] + +RFC 2822 Internet Message Format April 2001 + + + The day is the numeric day of the month. The year is any numeric + year 1900 or later. + + The time-of-day specifies the number of hours, minutes, and + optionally seconds since midnight of the date indicated. + + The date and time-of-day SHOULD express local time. + + The zone specifies the offset from Coordinated Universal Time (UTC, + formerly referred to as "Greenwich Mean Time") that the date and + time-of-day represent. The "+" or "-" indicates whether the + time-of-day is ahead of (i.e., east of) or behind (i.e., west of) + Universal Time. The first two digits indicate the number of hours + difference from Universal Time, and the last two digits indicate the + number of minutes difference from Universal Time. (Hence, +hhmm + means +(hh * 60 + mm) minutes, and -hhmm means -(hh * 60 + mm) + minutes). The form "+0000" SHOULD be used to indicate a time zone at + Universal Time. Though "-0000" also indicates Universal Time, it is + used to indicate that the time was generated on a system that may be + in a local time zone other than Universal Time and therefore + indicates that the date-time contains no information about the local + time zone. + + A date-time specification MUST be semantically valid. That is, the + day-of-the-week (if included) MUST be the day implied by the date, + the numeric day-of-month MUST be between 1 and the number of days + allowed for the specified month (in the specified year), the + time-of-day MUST be in the range 00:00:00 through 23:59:60 (the + number of seconds allowing for a leap second; see [STD12]), and the + zone MUST be within the range -9959 through +9959. + +3.4. Address Specification + + Addresses occur in several message header fields to indicate senders + and recipients of messages. An address may either be an individual + mailbox, or a group of mailboxes. + +address = mailbox / group + +mailbox = name-addr / addr-spec + +name-addr = [display-name] angle-addr + +angle-addr = [CFWS] "<" addr-spec ">" [CFWS] / obs-angle-addr + +group = display-name ":" [mailbox-list / CFWS] ";" + [CFWS] + + + + +Resnick Standards Track [Page 15] + +RFC 2822 Internet Message Format April 2001 + + +display-name = phrase + +mailbox-list = (mailbox *("," mailbox)) / obs-mbox-list + +address-list = (address *("," address)) / obs-addr-list + + A mailbox receives mail. It is a conceptual entity which does not + necessarily pertain to file storage. For example, some sites may + choose to print mail on a printer and deliver the output to the + addressee's desk. Normally, a mailbox is comprised of two parts: (1) + an optional display name that indicates the name of the recipient + (which could be a person or a system) that could be displayed to the + user of a mail application, and (2) an addr-spec address enclosed in + angle brackets ("<" and ">"). There is also an alternate simple form + of a mailbox where the addr-spec address appears alone, without the + recipient's name or the angle brackets. The Internet addr-spec + address is described in section 3.4.1. + + Note: Some legacy implementations used the simple form where the + addr-spec appears without the angle brackets, but included the name + of the recipient in parentheses as a comment following the addr-spec. + Since the meaning of the information in a comment is unspecified, + implementations SHOULD use the full name-addr form of the mailbox, + instead of the legacy form, to specify the display name associated + with a mailbox. Also, because some legacy implementations interpret + the comment, comments generally SHOULD NOT be used in address fields + to avoid confusing such implementations. + + When it is desirable to treat several mailboxes as a single unit + (i.e., in a distribution list), the group construct can be used. The + group construct allows the sender to indicate a named group of + recipients. This is done by giving a display name for the group, + followed by a colon, followed by a comma separated list of any number + of mailboxes (including zero and one), and ending with a semicolon. + Because the list of mailboxes can be empty, using the group construct + is also a simple way to communicate to recipients that the message + was sent to one or more named sets of recipients, without actually + providing the individual mailbox address for each of those + recipients. + +3.4.1. Addr-spec specification + + An addr-spec is a specific Internet identifier that contains a + locally interpreted string followed by the at-sign character ("@", + ASCII value 64) followed by an Internet domain. The locally + interpreted string is either a quoted-string or a dot-atom. If the + string can be represented as a dot-atom (that is, it contains no + characters other than atext characters or "." surrounded by atext + + + +Resnick Standards Track [Page 16] + +RFC 2822 Internet Message Format April 2001 + + + characters), then the dot-atom form SHOULD be used and the + quoted-string form SHOULD NOT be used. Comments and folding white + space SHOULD NOT be used around the "@" in the addr-spec. + +addr-spec = local-part "@" domain + +local-part = dot-atom / quoted-string / obs-local-part + +domain = dot-atom / domain-literal / obs-domain + +domain-literal = [CFWS] "[" *([FWS] dcontent) [FWS] "]" [CFWS] + +dcontent = dtext / quoted-pair + +dtext = NO-WS-CTL / ; Non white space controls + + %d33-90 / ; The rest of the US-ASCII + %d94-126 ; characters not including "[", + ; "]", or "\" + + The domain portion identifies the point to which the mail is + delivered. In the dot-atom form, this is interpreted as an Internet + domain name (either a host name or a mail exchanger name) as + described in [STD3, STD13, STD14]. In the domain-literal form, the + domain is interpreted as the literal Internet address of the + particular host. In both cases, how addressing is used and how + messages are transported to a particular host is covered in the mail + transport document [RFC2821]. These mechanisms are outside of the + scope of this document. + + The local-part portion is a domain dependent string. In addresses, + it is simply interpreted on the particular host as a name of a + particular mailbox. + +3.5 Overall message syntax + + A message consists of header fields, optionally followed by a message + body. Lines in a message MUST be a maximum of 998 characters + excluding the CRLF, but it is RECOMMENDED that lines be limited to 78 + characters excluding the CRLF. (See section 2.1.1 for explanation.) + In a message body, though all of the characters listed in the text + rule MAY be used, the use of US-ASCII control characters (values 1 + through 8, 11, 12, and 14 through 31) is discouraged since their + interpretation by receivers for display is not guaranteed. + + + + + + + +Resnick Standards Track [Page 17] + +RFC 2822 Internet Message Format April 2001 + + +message = (fields / obs-fields) + [CRLF body] + +body = *(*998text CRLF) *998text + + The header fields carry most of the semantic information and are + defined in section 3.6. The body is simply a series of lines of text + which are uninterpreted for the purposes of this standard. + +3.6. Field definitions + + The header fields of a message are defined here. All header fields + have the same general syntactic structure: A field name, followed by + a colon, followed by the field body. The specific syntax for each + header field is defined in the subsequent sections. + + Note: In the ABNF syntax for each field in subsequent sections, each + field name is followed by the required colon. However, for brevity + sometimes the colon is not referred to in the textual description of + the syntax. It is, nonetheless, required. + + It is important to note that the header fields are not guaranteed to + be in a particular order. They may appear in any order, and they + have been known to be reordered occasionally when transported over + the Internet. However, for the purposes of this standard, header + fields SHOULD NOT be reordered when a message is transported or + transformed. More importantly, the trace header fields and resent + header fields MUST NOT be reordered, and SHOULD be kept in blocks + prepended to the message. See sections 3.6.6 and 3.6.7 for more + information. + + The only required header fields are the origination date field and + the originator address field(s). All other header fields are + syntactically optional. More information is contained in the table + following this definition. + +fields = *(trace + *(resent-date / + resent-from / + resent-sender / + resent-to / + resent-cc / + resent-bcc / + resent-msg-id)) + *(orig-date / + from / + sender / + reply-to / + + + +Resnick Standards Track [Page 18] + +RFC 2822 Internet Message Format April 2001 + + + to / + cc / + bcc / + message-id / + in-reply-to / + references / + subject / + comments / + keywords / + optional-field) + + The following table indicates limits on the number of times each + field may occur in a message header as well as any special + limitations on the use of those fields. An asterisk next to a value + in the minimum or maximum column indicates that a special restriction + appears in the Notes column. + +Field Min number Max number Notes + +trace 0 unlimited Block prepended - see + 3.6.7 + +resent-date 0* unlimited* One per block, required + if other resent fields + present - see 3.6.6 + +resent-from 0 unlimited* One per block - see + 3.6.6 + +resent-sender 0* unlimited* One per block, MUST + occur with multi-address + resent-from - see 3.6.6 + +resent-to 0 unlimited* One per block - see + 3.6.6 + +resent-cc 0 unlimited* One per block - see + 3.6.6 + +resent-bcc 0 unlimited* One per block - see + 3.6.6 + +resent-msg-id 0 unlimited* One per block - see + 3.6.6 + +orig-date 1 1 + +from 1 1 See sender and 3.6.2 + + + +Resnick Standards Track [Page 19] + +RFC 2822 Internet Message Format April 2001 + + +sender 0* 1 MUST occur with multi- + address from - see 3.6.2 + +reply-to 0 1 + +to 0 1 + +cc 0 1 + +bcc 0 1 + +message-id 0* 1 SHOULD be present - see + 3.6.4 + +in-reply-to 0* 1 SHOULD occur in some + replies - see 3.6.4 + +references 0* 1 SHOULD occur in some + replies - see 3.6.4 + +subject 0 1 + +comments 0 unlimited + +keywords 0 unlimited + +optional-field 0 unlimited + + The exact interpretation of each field is described in subsequent + sections. + +3.6.1. The origination date field + + The origination date field consists of the field name "Date" followed + by a date-time specification. + +orig-date = "Date:" date-time CRLF + + The origination date specifies the date and time at which the creator + of the message indicated that the message was complete and ready to + enter the mail delivery system. For instance, this might be the time + that a user pushes the "send" or "submit" button in an application + program. In any case, it is specifically not intended to convey the + time that the message is actually transported, but rather the time at + which the human or other creator of the message has put the message + into its final form, ready for transport. (For example, a portable + computer user who is not connected to a network might queue a message + + + + +Resnick Standards Track [Page 20] + +RFC 2822 Internet Message Format April 2001 + + + for delivery. The origination date is intended to contain the date + and time that the user queued the message, not the time when the user + connected to the network to send the message.) + +3.6.2. Originator fields + + The originator fields of a message consist of the from field, the + sender field (when applicable), and optionally the reply-to field. + The from field consists of the field name "From" and a + comma-separated list of one or more mailbox specifications. If the + from field contains more than one mailbox specification in the + mailbox-list, then the sender field, containing the field name + "Sender" and a single mailbox specification, MUST appear in the + message. In either case, an optional reply-to field MAY also be + included, which contains the field name "Reply-To" and a + comma-separated list of one or more addresses. + +from = "From:" mailbox-list CRLF + +sender = "Sender:" mailbox CRLF + +reply-to = "Reply-To:" address-list CRLF + + The originator fields indicate the mailbox(es) of the source of the + message. The "From:" field specifies the author(s) of the message, + that is, the mailbox(es) of the person(s) or system(s) responsible + for the writing of the message. The "Sender:" field specifies the + mailbox of the agent responsible for the actual transmission of the + message. For example, if a secretary were to send a message for + another person, the mailbox of the secretary would appear in the + "Sender:" field and the mailbox of the actual author would appear in + the "From:" field. If the originator of the message can be indicated + by a single mailbox and the author and transmitter are identical, the + "Sender:" field SHOULD NOT be used. Otherwise, both fields SHOULD + appear. + + The originator fields also provide the information required when + replying to a message. When the "Reply-To:" field is present, it + indicates the mailbox(es) to which the author of the message suggests + that replies be sent. In the absence of the "Reply-To:" field, + replies SHOULD by default be sent to the mailbox(es) specified in the + "From:" field unless otherwise specified by the person composing the + reply. + + In all cases, the "From:" field SHOULD NOT contain any mailbox that + does not belong to the author(s) of the message. See also section + 3.6.3 for more information on forming the destination addresses for a + reply. + + + +Resnick Standards Track [Page 21] + +RFC 2822 Internet Message Format April 2001 + + +3.6.3. Destination address fields + + The destination fields of a message consist of three possible fields, + each of the same form: The field name, which is either "To", "Cc", or + "Bcc", followed by a comma-separated list of one or more addresses + (either mailbox or group syntax). + +to = "To:" address-list CRLF + +cc = "Cc:" address-list CRLF + +bcc = "Bcc:" (address-list / [CFWS]) CRLF + + The destination fields specify the recipients of the message. Each + destination field may have one or more addresses, and each of the + addresses indicate the intended recipients of the message. The only + difference between the three fields is how each is used. + + The "To:" field contains the address(es) of the primary recipient(s) + of the message. + + The "Cc:" field (where the "Cc" means "Carbon Copy" in the sense of + making a copy on a typewriter using carbon paper) contains the + addresses of others who are to receive the message, though the + content of the message may not be directed at them. + + The "Bcc:" field (where the "Bcc" means "Blind Carbon Copy") contains + addresses of recipients of the message whose addresses are not to be + revealed to other recipients of the message. There are three ways in + which the "Bcc:" field is used. In the first case, when a message + containing a "Bcc:" field is prepared to be sent, the "Bcc:" line is + removed even though all of the recipients (including those specified + in the "Bcc:" field) are sent a copy of the message. In the second + case, recipients specified in the "To:" and "Cc:" lines each are sent + a copy of the message with the "Bcc:" line removed as above, but the + recipients on the "Bcc:" line get a separate copy of the message + containing a "Bcc:" line. (When there are multiple recipient + addresses in the "Bcc:" field, some implementations actually send a + separate copy of the message to each recipient with a "Bcc:" + containing only the address of that particular recipient.) Finally, + since a "Bcc:" field may contain no addresses, a "Bcc:" field can be + sent without any addresses indicating to the recipients that blind + copies were sent to someone. Which method to use with "Bcc:" fields + is implementation dependent, but refer to the "Security + Considerations" section of this document for a discussion of each. + + + + + + +Resnick Standards Track [Page 22] + +RFC 2822 Internet Message Format April 2001 + + + When a message is a reply to another message, the mailboxes of the + authors of the original message (the mailboxes in the "From:" field) + or mailboxes specified in the "Reply-To:" field (if it exists) MAY + appear in the "To:" field of the reply since these would normally be + the primary recipients of the reply. If a reply is sent to a message + that has destination fields, it is often desirable to send a copy of + the reply to all of the recipients of the message, in addition to the + author. When such a reply is formed, addresses in the "To:" and + "Cc:" fields of the original message MAY appear in the "Cc:" field of + the reply, since these are normally secondary recipients of the + reply. If a "Bcc:" field is present in the original message, + addresses in that field MAY appear in the "Bcc:" field of the reply, + but SHOULD NOT appear in the "To:" or "Cc:" fields. + + Note: Some mail applications have automatic reply commands that + include the destination addresses of the original message in the + destination addresses of the reply. How those reply commands behave + is implementation dependent and is beyond the scope of this document. + In particular, whether or not to include the original destination + addresses when the original message had a "Reply-To:" field is not + addressed here. + +3.6.4. Identification fields + + Though optional, every message SHOULD have a "Message-ID:" field. + Furthermore, reply messages SHOULD have "In-Reply-To:" and + "References:" fields as appropriate, as described below. + + The "Message-ID:" field contains a single unique message identifier. + The "References:" and "In-Reply-To:" field each contain one or more + unique message identifiers, optionally separated by CFWS. + + The message identifier (msg-id) is similar in syntax to an angle-addr + construct without the internal CFWS. + +message-id = "Message-ID:" msg-id CRLF + +in-reply-to = "In-Reply-To:" 1*msg-id CRLF + +references = "References:" 1*msg-id CRLF + +msg-id = [CFWS] "<" id-left "@" id-right ">" [CFWS] + +id-left = dot-atom-text / no-fold-quote / obs-id-left + +id-right = dot-atom-text / no-fold-literal / obs-id-right + +no-fold-quote = DQUOTE *(qtext / quoted-pair) DQUOTE + + + +Resnick Standards Track [Page 23] + +RFC 2822 Internet Message Format April 2001 + + +no-fold-literal = "[" *(dtext / quoted-pair) "]" + + The "Message-ID:" field provides a unique message identifier that + refers to a particular version of a particular message. The + uniqueness of the message identifier is guaranteed by the host that + generates it (see below). This message identifier is intended to be + machine readable and not necessarily meaningful to humans. A message + identifier pertains to exactly one instantiation of a particular + message; subsequent revisions to the message each receive new message + identifiers. + + Note: There are many instances when messages are "changed", but those + changes do not constitute a new instantiation of that message, and + therefore the message would not get a new message identifier. For + example, when messages are introduced into the transport system, they + are often prepended with additional header fields such as trace + fields (described in section 3.6.7) and resent fields (described in + section 3.6.6). The addition of such header fields does not change + the identity of the message and therefore the original "Message-ID:" + field is retained. In all cases, it is the meaning that the sender + of the message wishes to convey (i.e., whether this is the same + message or a different message) that determines whether or not the + "Message-ID:" field changes, not any particular syntactic difference + that appears (or does not appear) in the message. + + The "In-Reply-To:" and "References:" fields are used when creating a + reply to a message. They hold the message identifier of the original + message and the message identifiers of other messages (for example, + in the case of a reply to a message which was itself a reply). The + "In-Reply-To:" field may be used to identify the message (or + messages) to which the new message is a reply, while the + "References:" field may be used to identify a "thread" of + conversation. + + When creating a reply to a message, the "In-Reply-To:" and + "References:" fields of the resultant message are constructed as + follows: + + The "In-Reply-To:" field will contain the contents of the "Message- + ID:" field of the message to which this one is a reply (the "parent + message"). If there is more than one parent message, then the "In- + Reply-To:" field will contain the contents of all of the parents' + "Message-ID:" fields. If there is no "Message-ID:" field in any of + the parent messages, then the new message will have no "In-Reply-To:" + field. + + + + + + +Resnick Standards Track [Page 24] + +RFC 2822 Internet Message Format April 2001 + + + The "References:" field will contain the contents of the parent's + "References:" field (if any) followed by the contents of the parent's + "Message-ID:" field (if any). If the parent message does not contain + a "References:" field but does have an "In-Reply-To:" field + containing a single message identifier, then the "References:" field + will contain the contents of the parent's "In-Reply-To:" field + followed by the contents of the parent's "Message-ID:" field (if + any). If the parent has none of the "References:", "In-Reply-To:", + or "Message-ID:" fields, then the new message will have no + "References:" field. + + Note: Some implementations parse the "References:" field to display + the "thread of the discussion". These implementations assume that + each new message is a reply to a single parent and hence that they + can walk backwards through the "References:" field to find the parent + of each message listed there. Therefore, trying to form a + "References:" field for a reply that has multiple parents is + discouraged and how to do so is not defined in this document. + + The message identifier (msg-id) itself MUST be a globally unique + identifier for a message. The generator of the message identifier + MUST guarantee that the msg-id is unique. There are several + algorithms that can be used to accomplish this. Since the msg-id has + a similar syntax to angle-addr (identical except that comments and + folding white space are not allowed), a good method is to put the + domain name (or a domain literal IP address) of the host on which the + message identifier was created on the right hand side of the "@", and + put a combination of the current absolute date and time along with + some other currently unique (perhaps sequential) identifier available + on the system (for example, a process id number) on the left hand + side. Using a date on the left hand side and a domain name or domain + literal on the right hand side makes it possible to guarantee + uniqueness since no two hosts use the same domain name or IP address + at the same time. Though other algorithms will work, it is + RECOMMENDED that the right hand side contain some domain identifier + (either of the host itself or otherwise) such that the generator of + the message identifier can guarantee the uniqueness of the left hand + side within the scope of that domain. + + Semantically, the angle bracket characters are not part of the + msg-id; the msg-id is what is contained between the two angle bracket + characters. + + + + + + + + + +Resnick Standards Track [Page 25] + +RFC 2822 Internet Message Format April 2001 + + +3.6.5. Informational fields + + The informational fields are all optional. The "Keywords:" field + contains a comma-separated list of one or more words or + quoted-strings. The "Subject:" and "Comments:" fields are + unstructured fields as defined in section 2.2.1, and therefore may + contain text or folding white space. + +subject = "Subject:" unstructured CRLF + +comments = "Comments:" unstructured CRLF + +keywords = "Keywords:" phrase *("," phrase) CRLF + + These three fields are intended to have only human-readable content + with information about the message. The "Subject:" field is the most + common and contains a short string identifying the topic of the + message. When used in a reply, the field body MAY start with the + string "Re: " (from the Latin "res", in the matter of) followed by + the contents of the "Subject:" field body of the original message. + If this is done, only one instance of the literal string "Re: " ought + to be used since use of other strings or more than one instance can + lead to undesirable consequences. The "Comments:" field contains any + additional comments on the text of the body of the message. The + "Keywords:" field contains a comma-separated list of important words + and phrases that might be useful for the recipient. + +3.6.6. Resent fields + + Resent fields SHOULD be added to any message that is reintroduced by + a user into the transport system. A separate set of resent fields + SHOULD be added each time this is done. All of the resent fields + corresponding to a particular resending of the message SHOULD be + together. Each new set of resent fields is prepended to the message; + that is, the most recent set of resent fields appear earlier in the + message. No other fields in the message are changed when resent + fields are added. + + Each of the resent fields corresponds to a particular field elsewhere + in the syntax. For instance, the "Resent-Date:" field corresponds to + the "Date:" field and the "Resent-To:" field corresponds to the "To:" + field. In each case, the syntax for the field body is identical to + the syntax given previously for the corresponding field. + + When resent fields are used, the "Resent-From:" and "Resent-Date:" + fields MUST be sent. The "Resent-Message-ID:" field SHOULD be sent. + "Resent-Sender:" SHOULD NOT be used if "Resent-Sender:" would be + identical to "Resent-From:". + + + +Resnick Standards Track [Page 26] + +RFC 2822 Internet Message Format April 2001 + + +resent-date = "Resent-Date:" date-time CRLF + +resent-from = "Resent-From:" mailbox-list CRLF + +resent-sender = "Resent-Sender:" mailbox CRLF + +resent-to = "Resent-To:" address-list CRLF + +resent-cc = "Resent-Cc:" address-list CRLF + +resent-bcc = "Resent-Bcc:" (address-list / [CFWS]) CRLF + +resent-msg-id = "Resent-Message-ID:" msg-id CRLF + + Resent fields are used to identify a message as having been + reintroduced into the transport system by a user. The purpose of + using resent fields is to have the message appear to the final + recipient as if it were sent directly by the original sender, with + all of the original fields remaining the same. Each set of resent + fields correspond to a particular resending event. That is, if a + message is resent multiple times, each set of resent fields gives + identifying information for each individual time. Resent fields are + strictly informational. They MUST NOT be used in the normal + processing of replies or other such automatic actions on messages. + + Note: Reintroducing a message into the transport system and using + resent fields is a different operation from "forwarding". + "Forwarding" has two meanings: One sense of forwarding is that a mail + reading program can be told by a user to forward a copy of a message + to another person, making the forwarded message the body of the new + message. A forwarded message in this sense does not appear to have + come from the original sender, but is an entirely new message from + the forwarder of the message. On the other hand, forwarding is also + used to mean when a mail transport program gets a message and + forwards it on to a different destination for final delivery. Resent + header fields are not intended for use with either type of + forwarding. + + The resent originator fields indicate the mailbox of the person(s) or + system(s) that resent the message. As with the regular originator + fields, there are two forms: a simple "Resent-From:" form which + contains the mailbox of the individual doing the resending, and the + more complex form, when one individual (identified in the + "Resent-Sender:" field) resends a message on behalf of one or more + others (identified in the "Resent-From:" field). + + Note: When replying to a resent message, replies behave just as they + would with any other message, using the original "From:", + + + +Resnick Standards Track [Page 27] + +RFC 2822 Internet Message Format April 2001 + + + "Reply-To:", "Message-ID:", and other fields. The resent fields are + only informational and MUST NOT be used in the normal processing of + replies. + + The "Resent-Date:" indicates the date and time at which the resent + message is dispatched by the resender of the message. Like the + "Date:" field, it is not the date and time that the message was + actually transported. + + The "Resent-To:", "Resent-Cc:", and "Resent-Bcc:" fields function + identically to the "To:", "Cc:", and "Bcc:" fields respectively, + except that they indicate the recipients of the resent message, not + the recipients of the original message. + + The "Resent-Message-ID:" field provides a unique identifier for the + resent message. + +3.6.7. Trace fields + + The trace fields are a group of header fields consisting of an + optional "Return-Path:" field, and one or more "Received:" fields. + The "Return-Path:" header field contains a pair of angle brackets + that enclose an optional addr-spec. The "Received:" field contains a + (possibly empty) list of name/value pairs followed by a semicolon and + a date-time specification. The first item of the name/value pair is + defined by item-name, and the second item is either an addr-spec, an + atom, a domain, or a msg-id. Further restrictions may be applied to + the syntax of the trace fields by standards that provide for their + use, such as [RFC2821]. + +trace = [return] + 1*received + +return = "Return-Path:" path CRLF + +path = ([CFWS] "<" ([CFWS] / addr-spec) ">" [CFWS]) / + obs-path + +received = "Received:" name-val-list ";" date-time CRLF + +name-val-list = [CFWS] [name-val-pair *(CFWS name-val-pair)] + +name-val-pair = item-name CFWS item-value + +item-name = ALPHA *(["-"] (ALPHA / DIGIT)) + +item-value = 1*angle-addr / addr-spec / + atom / domain / msg-id + + + +Resnick Standards Track [Page 28] + +RFC 2822 Internet Message Format April 2001 + + + A full discussion of the Internet mail use of trace fields is + contained in [RFC2821]. For the purposes of this standard, the trace + fields are strictly informational, and any formal interpretation of + them is outside of the scope of this document. + +3.6.8. Optional fields + + Fields may appear in messages that are otherwise unspecified in this + standard. They MUST conform to the syntax of an optional-field. + This is a field name, made up of the printable US-ASCII characters + except SP and colon, followed by a colon, followed by any text which + conforms to unstructured. + + The field names of any optional-field MUST NOT be identical to any + field name specified elsewhere in this standard. + +optional-field = field-name ":" unstructured CRLF + +field-name = 1*ftext + +ftext = %d33-57 / ; Any character except + %d59-126 ; controls, SP, and + ; ":". + + For the purposes of this standard, any optional field is + uninterpreted. + +4. Obsolete Syntax + + Earlier versions of this standard allowed for different (usually more + liberal) syntax than is allowed in this version. Also, there have + been syntactic elements used in messages on the Internet whose + interpretation have never been documented. Though some of these + syntactic forms MUST NOT be generated according to the grammar in + section 3, they MUST be accepted and parsed by a conformant receiver. + This section documents many of these syntactic elements. Taking the + grammar in section 3 and adding the definitions presented in this + section will result in the grammar to use for interpretation of + messages. + + Note: This section identifies syntactic forms that any implementation + MUST reasonably interpret. However, there are certainly Internet + messages which do not conform to even the additional syntax given in + this section. The fact that a particular form does not appear in any + section of this document is not justification for computer programs + to crash or for malformed data to be irretrievably lost by any + implementation. To repeat an example, though this document requires + lines in messages to be no longer than 998 characters, silently + + + +Resnick Standards Track [Page 29] + +RFC 2822 Internet Message Format April 2001 + + + discarding the 999th and subsequent characters in a line without + warning would still be bad behavior for an implementation. It is up + to the implementation to deal with messages robustly. + + One important difference between the obsolete (interpreting) and the + current (generating) syntax is that in structured header field bodies + (i.e., between the colon and the CRLF of any structured header + field), white space characters, including folding white space, and + comments can be freely inserted between any syntactic tokens. This + allows many complex forms that have proven difficult for some + implementations to parse. + + Another key difference between the obsolete and the current syntax is + that the rule in section 3.2.3 regarding lines composed entirely of + white space in comments and folding white space does not apply. See + the discussion of folding white space in section 4.2 below. + + Finally, certain characters that were formerly allowed in messages + appear in this section. The NUL character (ASCII value 0) was once + allowed, but is no longer for compatibility reasons. CR and LF were + allowed to appear in messages other than as CRLF; this use is also + shown here. + + Other differences in syntax and semantics are noted in the following + sections. + +4.1. Miscellaneous obsolete tokens + + These syntactic elements are used elsewhere in the obsolete syntax or + in the main syntax. The obs-char and obs-qp elements each add ASCII + value 0. Bare CR and bare LF are added to obs-text and obs-utext. + The period character is added to obs-phrase. The obs-phrase-list + provides for "empty" elements in a comma-separated list of phrases. + + Note: The "period" (or "full stop") character (".") in obs-phrase is + not a form that was allowed in earlier versions of this or any other + standard. Period (nor any other character from specials) was not + allowed in phrase because it introduced a parsing difficulty + distinguishing between phrases and portions of an addr-spec (see + section 4.4). It appears here because the period character is + currently used in many messages in the display-name portion of + addresses, especially for initials in names, and therefore must be + interpreted properly. In the future, period may appear in the + regular syntax of phrase. + +obs-qp = "\" (%d0-127) + +obs-text = *LF *CR *(obs-char *LF *CR) + + + +Resnick Standards Track [Page 30] + +RFC 2822 Internet Message Format April 2001 + + +obs-char = %d0-9 / %d11 / ; %d0-127 except CR and + %d12 / %d14-127 ; LF + +obs-utext = obs-text + +obs-phrase = word *(word / "." / CFWS) + +obs-phrase-list = phrase / 1*([phrase] [CFWS] "," [CFWS]) [phrase] + + Bare CR and bare LF appear in messages with two different meanings. + In many cases, bare CR or bare LF are used improperly instead of CRLF + to indicate line separators. In other cases, bare CR and bare LF are + used simply as ASCII control characters with their traditional ASCII + meanings. + +4.2. Obsolete folding white space + + In the obsolete syntax, any amount of folding white space MAY be + inserted where the obs-FWS rule is allowed. This creates the + possibility of having two consecutive "folds" in a line, and + therefore the possibility that a line which makes up a folded header + field could be composed entirely of white space. + + obs-FWS = 1*WSP *(CRLF 1*WSP) + +4.3. Obsolete Date and Time + + The syntax for the obsolete date format allows a 2 digit year in the + date field and allows for a list of alphabetic time zone + specifications that were used in earlier versions of this standard. + It also permits comments and folding white space between many of the + tokens. + +obs-day-of-week = [CFWS] day-name [CFWS] + +obs-year = [CFWS] 2*DIGIT [CFWS] + +obs-month = CFWS month-name CFWS + +obs-day = [CFWS] 1*2DIGIT [CFWS] + +obs-hour = [CFWS] 2DIGIT [CFWS] + +obs-minute = [CFWS] 2DIGIT [CFWS] + +obs-second = [CFWS] 2DIGIT [CFWS] + +obs-zone = "UT" / "GMT" / ; Universal Time + + + +Resnick Standards Track [Page 31] + +RFC 2822 Internet Message Format April 2001 + + + ; North American UT + ; offsets + "EST" / "EDT" / ; Eastern: - 5/ - 4 + "CST" / "CDT" / ; Central: - 6/ - 5 + "MST" / "MDT" / ; Mountain: - 7/ - 6 + "PST" / "PDT" / ; Pacific: - 8/ - 7 + + %d65-73 / ; Military zones - "A" + %d75-90 / ; through "I" and "K" + %d97-105 / ; through "Z", both + %d107-122 ; upper and lower case + + Where a two or three digit year occurs in a date, the year is to be + interpreted as follows: If a two digit year is encountered whose + value is between 00 and 49, the year is interpreted by adding 2000, + ending up with a value between 2000 and 2049. If a two digit year is + encountered with a value between 50 and 99, or any three digit year + is encountered, the year is interpreted by adding 1900. + + In the obsolete time zone, "UT" and "GMT" are indications of + "Universal Time" and "Greenwich Mean Time" respectively and are both + semantically identical to "+0000". + + The remaining three character zones are the US time zones. The first + letter, "E", "C", "M", or "P" stands for "Eastern", "Central", + "Mountain" and "Pacific". The second letter is either "S" for + "Standard" time, or "D" for "Daylight" (or summer) time. Their + interpretations are as follows: + + EDT is semantically equivalent to -0400 + EST is semantically equivalent to -0500 + CDT is semantically equivalent to -0500 + CST is semantically equivalent to -0600 + MDT is semantically equivalent to -0600 + MST is semantically equivalent to -0700 + PDT is semantically equivalent to -0700 + PST is semantically equivalent to -0800 + + The 1 character military time zones were defined in a non-standard + way in [RFC822] and are therefore unpredictable in their meaning. + The original definitions of the military zones "A" through "I" are + equivalent to "+0100" through "+0900" respectively; "K", "L", and "M" + are equivalent to "+1000", "+1100", and "+1200" respectively; "N" + through "Y" are equivalent to "-0100" through "-1200" respectively; + and "Z" is equivalent to "+0000". However, because of the error in + [RFC822], they SHOULD all be considered equivalent to "-0000" unless + there is out-of-band information confirming their meaning. + + + + +Resnick Standards Track [Page 32] + +RFC 2822 Internet Message Format April 2001 + + + Other multi-character (usually between 3 and 5) alphabetic time zones + have been used in Internet messages. Any such time zone whose + meaning is not known SHOULD be considered equivalent to "-0000" + unless there is out-of-band information confirming their meaning. + +4.4. Obsolete Addressing + + There are three primary differences in addressing. First, mailbox + addresses were allowed to have a route portion before the addr-spec + when enclosed in "<" and ">". The route is simply a comma-separated + list of domain names, each preceded by "@", and the list terminated + by a colon. Second, CFWS were allowed between the period-separated + elements of local-part and domain (i.e., dot-atom was not used). In + addition, local-part is allowed to contain quoted-string in addition + to just atom. Finally, mailbox-list and address-list were allowed to + have "null" members. That is, there could be two or more commas in + such a list with nothing in between them. + +obs-angle-addr = [CFWS] "<" [obs-route] addr-spec ">" [CFWS] + +obs-route = [CFWS] obs-domain-list ":" [CFWS] + +obs-domain-list = "@" domain *(*(CFWS / "," ) [CFWS] "@" domain) + +obs-local-part = word *("." word) + +obs-domain = atom *("." atom) + +obs-mbox-list = 1*([mailbox] [CFWS] "," [CFWS]) [mailbox] + +obs-addr-list = 1*([address] [CFWS] "," [CFWS]) [address] + + When interpreting addresses, the route portion SHOULD be ignored. + +4.5. Obsolete header fields + + Syntactically, the primary difference in the obsolete field syntax is + that it allows multiple occurrences of any of the fields and they may + occur in any order. Also, any amount of white space is allowed + before the ":" at the end of the field name. + +obs-fields = *(obs-return / + obs-received / + obs-orig-date / + obs-from / + obs-sender / + obs-reply-to / + obs-to / + + + +Resnick Standards Track [Page 33] + +RFC 2822 Internet Message Format April 2001 + + + obs-cc / + obs-bcc / + obs-message-id / + obs-in-reply-to / + obs-references / + obs-subject / + obs-comments / + obs-keywords / + obs-resent-date / + obs-resent-from / + obs-resent-send / + obs-resent-rply / + obs-resent-to / + obs-resent-cc / + obs-resent-bcc / + obs-resent-mid / + obs-optional) + + Except for destination address fields (described in section 4.5.3), + the interpretation of multiple occurrences of fields is unspecified. + Also, the interpretation of trace fields and resent fields which do + not occur in blocks prepended to the message is unspecified as well. + Unless otherwise noted in the following sections, interpretation of + other fields is identical to the interpretation of their non-obsolete + counterparts in section 3. + +4.5.1. Obsolete origination date field + +obs-orig-date = "Date" *WSP ":" date-time CRLF + +4.5.2. Obsolete originator fields + +obs-from = "From" *WSP ":" mailbox-list CRLF + +obs-sender = "Sender" *WSP ":" mailbox CRLF + +obs-reply-to = "Reply-To" *WSP ":" mailbox-list CRLF + +4.5.3. Obsolete destination address fields + +obs-to = "To" *WSP ":" address-list CRLF + +obs-cc = "Cc" *WSP ":" address-list CRLF + +obs-bcc = "Bcc" *WSP ":" (address-list / [CFWS]) CRLF + + + + + + +Resnick Standards Track [Page 34] + +RFC 2822 Internet Message Format April 2001 + + + When multiple occurrences of destination address fields occur in a + message, they SHOULD be treated as if the address-list in the first + occurrence of the field is combined with the address lists of the + subsequent occurrences by adding a comma and concatenating. + +4.5.4. Obsolete identification fields + + The obsolete "In-Reply-To:" and "References:" fields differ from the + current syntax in that they allow phrase (words or quoted strings) to + appear. The obsolete forms of the left and right sides of msg-id + allow interspersed CFWS, making them syntactically identical to + local-part and domain respectively. + +obs-message-id = "Message-ID" *WSP ":" msg-id CRLF + +obs-in-reply-to = "In-Reply-To" *WSP ":" *(phrase / msg-id) CRLF + +obs-references = "References" *WSP ":" *(phrase / msg-id) CRLF + +obs-id-left = local-part + +obs-id-right = domain + + For purposes of interpretation, the phrases in the "In-Reply-To:" and + "References:" fields are ignored. + + Semantically, none of the optional CFWS surrounding the local-part + and the domain are part of the obs-id-left and obs-id-right + respectively. + +4.5.5. Obsolete informational fields + +obs-subject = "Subject" *WSP ":" unstructured CRLF + +obs-comments = "Comments" *WSP ":" unstructured CRLF + +obs-keywords = "Keywords" *WSP ":" obs-phrase-list CRLF + +4.5.6. Obsolete resent fields + + The obsolete syntax adds a "Resent-Reply-To:" field, which consists + of the field name, the optional comments and folding white space, the + colon, and a comma separated list of addresses. + +obs-resent-from = "Resent-From" *WSP ":" mailbox-list CRLF + +obs-resent-send = "Resent-Sender" *WSP ":" mailbox CRLF + + + + +Resnick Standards Track [Page 35] + +RFC 2822 Internet Message Format April 2001 + + +obs-resent-date = "Resent-Date" *WSP ":" date-time CRLF + +obs-resent-to = "Resent-To" *WSP ":" address-list CRLF + +obs-resent-cc = "Resent-Cc" *WSP ":" address-list CRLF + +obs-resent-bcc = "Resent-Bcc" *WSP ":" + (address-list / [CFWS]) CRLF + +obs-resent-mid = "Resent-Message-ID" *WSP ":" msg-id CRLF + +obs-resent-rply = "Resent-Reply-To" *WSP ":" address-list CRLF + + As with other resent fields, the "Resent-Reply-To:" field is to be + treated as trace information only. + +4.5.7. Obsolete trace fields + + The obs-return and obs-received are again given here as template + definitions, just as return and received are in section 3. Their + full syntax is given in [RFC2821]. + +obs-return = "Return-Path" *WSP ":" path CRLF + +obs-received = "Received" *WSP ":" name-val-list CRLF + +obs-path = obs-angle-addr + +4.5.8. Obsolete optional fields + +obs-optional = field-name *WSP ":" unstructured CRLF + +5. Security Considerations + + Care needs to be taken when displaying messages on a terminal or + terminal emulator. Powerful terminals may act on escape sequences + and other combinations of ASCII control characters with a variety of + consequences. They can remap the keyboard or permit other + modifications to the terminal which could lead to denial of service + or even damaged data. They can trigger (sometimes programmable) + answerback messages which can allow a message to cause commands to be + issued on the recipient's behalf. They can also effect the operation + of terminal attached devices such as printers. Message viewers may + wish to strip potentially dangerous terminal escape sequences from + the message prior to display. However, other escape sequences appear + in messages for useful purposes (cf. [RFC2045, RFC2046, RFC2047, + RFC2048, RFC2049, ISO2022]) and therefore should not be stripped + indiscriminately. + + + +Resnick Standards Track [Page 36] + +RFC 2822 Internet Message Format April 2001 + + + Transmission of non-text objects in messages raises additional + security issues. These issues are discussed in [RFC2045, RFC2046, + RFC2047, RFC2048, RFC2049]. + + Many implementations use the "Bcc:" (blind carbon copy) field + described in section 3.6.3 to facilitate sending messages to + recipients without revealing the addresses of one or more of the + addressees to the other recipients. Mishandling this use of "Bcc:" + has implications for confidential information that might be revealed, + which could eventually lead to security problems through knowledge of + even the existence of a particular mail address. For example, if + using the first method described in section 3.6.3, where the "Bcc:" + line is removed from the message, blind recipients have no explicit + indication that they have been sent a blind copy, except insofar as + their address does not appear in the message header. Because of + this, one of the blind addressees could potentially send a reply to + all of the shown recipients and accidentally reveal that the message + went to the blind recipient. When the second method from section + 3.6.3 is used, the blind recipient's address appears in the "Bcc:" + field of a separate copy of the message. If the "Bcc:" field sent + contains all of the blind addressees, all of the "Bcc:" recipients + will be seen by each "Bcc:" recipient. Even if a separate message is + sent to each "Bcc:" recipient with only the individual's address, + implementations still need to be careful to process replies to the + message as per section 3.6.3 so as not to accidentally reveal the + blind recipient to other recipients. + +6. Bibliography + + [ASCII] American National Standards Institute (ANSI), Coded + Character Set - 7-Bit American National Standard Code for + Information Interchange, ANSI X3.4, 1986. + + [ISO2022] International Organization for Standardization (ISO), + Information processing - ISO 7-bit and 8-bit coded + character sets - Code extension techniques, Third edition + - 1986-05-01, ISO 2022, 1986. + + [RFC822] Crocker, D., "Standard for the Format of ARPA Internet + Text Messages", RFC 822, August 1982. + + [RFC2045] Freed, N. and N. Borenstein, "Multipurpose Internet Mail + Extensions (MIME) Part One: Format of Internet Message + Bodies", RFC 2045, November 1996. + + [RFC2046] Freed, N. and N. Borenstein, "Multipurpose Internet Mail + Extensions (MIME) Part Two: Media Types", RFC 2046, + November 1996. + + + +Resnick Standards Track [Page 37] + +RFC 2822 Internet Message Format April 2001 + + + [RFC2047] Moore, K., "Multipurpose Internet Mail Extensions (MIME) + Part Three: Message Header Extensions for Non-ASCII Text", + RFC 2047, November 1996. + + [RFC2048] Freed, N., Klensin, J. and J. Postel, "Multipurpose + Internet Mail Extensions (MIME) Part Four: Format of + Internet Message Bodies", RFC 2048, November 1996. + + [RFC2049] Freed, N. and N. Borenstein, "Multipurpose Internet Mail + Extensions (MIME) Part Five: Conformance Criteria and + Examples", RFC 2049, November 1996. + + [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate + Requirement Levels", BCP 14, RFC 2119, March 1997. + + [RFC2234] Crocker, D., Editor, and P. Overell, "Augmented BNF for + Syntax Specifications: ABNF", RFC 2234, November 1997. + + [RFC2821] Klensin, J., Editor, "Simple Mail Transfer Protocol", RFC + 2821, March 2001. + + [STD3] Braden, R., "Host Requirements", STD 3, RFC 1122 and RFC + 1123, October 1989. + + [STD12] Mills, D., "Network Time Protocol", STD 12, RFC 1119, + September 1989. + + [STD13] Mockapetris, P., "Domain Name System", STD 13, RFC 1034 + and RFC 1035, November 1987. + + [STD14] Partridge, C., "Mail Routing and the Domain System", STD + 14, RFC 974, January 1986. + +7. Editor's Address + + Peter W. Resnick + QUALCOMM Incorporated + 5775 Morehouse Drive + San Diego, CA 92121-1714 + USA + + Phone: +1 858 651 4478 + Fax: +1 858 651 1102 + EMail: presnick@qualcomm.com + + + + + + + +Resnick Standards Track [Page 38] + +RFC 2822 Internet Message Format April 2001 + + +8. Acknowledgements + + Many people contributed to this document. They included folks who + participated in the Detailed Revision and Update of Messaging + Standards (DRUMS) Working Group of the Internet Engineering Task + Force (IETF), the chair of DRUMS, the Area Directors of the IETF, and + people who simply sent their comments in via e-mail. The editor is + deeply indebted to them all and thanks them sincerely. The below + list includes everyone who sent e-mail concerning this document. + Hopefully, everyone who contributed is named here: + + Matti Aarnio Barry Finkel Larry Masinter + Tanaka Akira Erik Forsberg Denis McKeon + Russ Allbery Chuck Foster William P McQuillan + Eric Allman Paul Fox Alexey Melnikov + Harald Tveit Alvestrand Klaus M. Frank Perry E. Metzger + Ran Atkinson Ned Freed Steven Miller + Jos Backus Jochen Friedrich Keith Moore + Bruce Balden Randall C. Gellens John Gardiner Myers + Dave Barr Sukvinder Singh Gill Chris Newman + Alan Barrett Tim Goodwin John W. Noerenberg + John Beck Philip Guenther Eric Norman + J. Robert von Behren Tony Hansen Mike O'Dell + Jos den Bekker John Hawkinson Larry Osterman + D. J. Bernstein Philip Hazel Paul Overell + James Berriman Kai Henningsen Jacob Palme + Norbert Bollow Robert Herriot Michael A. Patton + Raj Bose Paul Hethmon Uzi Paz + Antony Bowesman Jim Hill Michael A. Quinlan + Scott Bradner Paul E. Hoffman Eric S. Raymond + Randy Bush Steve Hole Sam Roberts + Tom Byrer Kari Hurtta Hugh Sasse + Bruce Campbell Marco S. Hyman Bart Schaefer + Larry Campbell Ofer Inbar Tom Scola + W. J. Carpenter Olle Jarnefors Wolfgang Segmuller + Michael Chapman Kevin Johnson Nick Shelness + Richard Clayton Sudish Joseph John Stanley + Maurizio Codogno Maynard Kang Einar Stefferud + Jim Conklin Prabhat Keni Jeff Stephenson + R. Kelley Cook John C. Klensin Bernard Stern + Steve Coya Graham Klyne Peter Sylvester + Mark Crispin Brad Knowles Mark Symons + Dave Crocker Shuhei Kobayashi Eric Thomas + Matt Curtin Peter Koch Lee Thompson + Michael D'Errico Dan Kohn Karel De Vriendt + Cyrus Daboo Christian Kuhtz Matthew Wall + Jutta Degener Anand Kumria Rolf Weber + Mark Delany Steen Larsen Brent B. Welch + + + +Resnick Standards Track [Page 39] + +RFC 2822 Internet Message Format April 2001 + + + Steve Dorner Eliot Lear Dan Wing + Harold A. Driscoll Barry Leiba Jack De Winter + Michael Elkins Jay Levitt Gregory J. Woodhouse + Robert Elz Lars-Johan Liman Greg A. Woods + Johnny Eriksson Charles Lindsey Kazu Yamamoto + Erik E. Fair Pete Loshin Alain Zahm + Roger Fajman Simon Lyall Jamie Zawinski + Patrik Faltstrom Bill Manning Timothy S. Zurcher + Claus Andre Farber John Martin + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Resnick Standards Track [Page 40] + +RFC 2822 Internet Message Format April 2001 + + +Appendix A. Example messages + + This section presents a selection of messages. These are intended to + assist in the implementation of this standard, but should not be + taken as normative; that is to say, although the examples in this + section were carefully reviewed, if there happens to be a conflict + between these examples and the syntax described in sections 3 and 4 + of this document, the syntax in those sections is to be taken as + correct. + + Messages are delimited in this section between lines of "----". The + "----" lines are not part of the message itself. + +A.1. Addressing examples + + The following are examples of messages that might be sent between two + individuals. + +A.1.1. A message from one person to another with simple addressing + + This could be called a canonical message. It has a single author, + John Doe, a single recipient, Mary Smith, a subject, the date, a + message identifier, and a textual message in the body. + +---- +From: John Doe +To: Mary Smith +Subject: Saying Hello +Date: Fri, 21 Nov 1997 09:55:06 -0600 +Message-ID: <1234@local.machine.example> + +This is a message just to say hello. +So, "Hello". +---- + + + + + + + + + + + + + + + + + +Resnick Standards Track [Page 41] + +RFC 2822 Internet Message Format April 2001 + + + If John's secretary Michael actually sent the message, though John + was the author and replies to this message should go back to him, the + sender field would be used: + +---- +From: John Doe +Sender: Michael Jones +To: Mary Smith +Subject: Saying Hello +Date: Fri, 21 Nov 1997 09:55:06 -0600 +Message-ID: <1234@local.machine.example> + +This is a message just to say hello. +So, "Hello". +---- + +A.1.2. Different types of mailboxes + + This message includes multiple addresses in the destination fields + and also uses several different forms of addresses. + +---- +From: "Joe Q. Public" +To: Mary Smith , jdoe@example.org, Who? +Cc: , "Giant; \"Big\" Box" +Date: Tue, 1 Jul 2003 10:52:37 +0200 +Message-ID: <5678.21-Nov-1997@example.com> + +Hi everyone. +---- + + Note that the display names for Joe Q. Public and Giant; "Big" Box + needed to be enclosed in double-quotes because the former contains + the period and the latter contains both semicolon and double-quote + characters (the double-quote characters appearing as quoted-pair + construct). Conversely, the display name for Who? could appear + without them because the question mark is legal in an atom. Notice + also that jdoe@example.org and boss@nil.test have no display names + associated with them at all, and jdoe@example.org uses the simpler + address form without the angle brackets. + + + + + + + + + + + +Resnick Standards Track [Page 42] + +RFC 2822 Internet Message Format April 2001 + + +A.1.3. Group addresses + +---- +From: Pete +To: A Group:Chris Jones ,joe@where.test,John ; +Cc: Undisclosed recipients:; +Date: Thu, 13 Feb 1969 23:32:54 -0330 +Message-ID: + +Testing. +---- + + In this message, the "To:" field has a single group recipient named A + Group which contains 3 addresses, and a "Cc:" field with an empty + group recipient named Undisclosed recipients. + +A.2. Reply messages + + The following is a series of three messages that make up a + conversation thread between John and Mary. John firsts sends a + message to Mary, Mary then replies to John's message, and then John + replies to Mary's reply message. + + Note especially the "Message-ID:", "References:", and "In-Reply-To:" + fields in each message. + +---- +From: John Doe +To: Mary Smith +Subject: Saying Hello +Date: Fri, 21 Nov 1997 09:55:06 -0600 +Message-ID: <1234@local.machine.example> + +This is a message just to say hello. +So, "Hello". +---- + + + + + + + + + + + + + + + +Resnick Standards Track [Page 43] + +RFC 2822 Internet Message Format April 2001 + + + When sending replies, the Subject field is often retained, though + prepended with "Re: " as described in section 3.6.5. + +---- +From: Mary Smith +To: John Doe +Reply-To: "Mary Smith: Personal Account" +Subject: Re: Saying Hello +Date: Fri, 21 Nov 1997 10:01:10 -0600 +Message-ID: <3456@example.net> +In-Reply-To: <1234@local.machine.example> +References: <1234@local.machine.example> + +This is a reply to your hello. +---- + + Note the "Reply-To:" field in the above message. When John replies + to Mary's message above, the reply should go to the address in the + "Reply-To:" field instead of the address in the "From:" field. + +---- +To: "Mary Smith: Personal Account" +From: John Doe +Subject: Re: Saying Hello +Date: Fri, 21 Nov 1997 11:00:00 -0600 +Message-ID: +In-Reply-To: <3456@example.net> +References: <1234@local.machine.example> <3456@example.net> + +This is a reply to your reply. +---- + +A.3. Resent messages + + Start with the message that has been used as an example several + times: + +---- +From: John Doe +To: Mary Smith +Subject: Saying Hello +Date: Fri, 21 Nov 1997 09:55:06 -0600 +Message-ID: <1234@local.machine.example> + +This is a message just to say hello. +So, "Hello". +---- + + + + +Resnick Standards Track [Page 44] + +RFC 2822 Internet Message Format April 2001 + + + Say that Mary, upon receiving this message, wishes to send a copy of + the message to Jane such that (a) the message would appear to have + come straight from John; (b) if Jane replies to the message, the + reply should go back to John; and (c) all of the original + information, like the date the message was originally sent to Mary, + the message identifier, and the original addressee, is preserved. In + this case, resent fields are prepended to the message: + +---- +Resent-From: Mary Smith +Resent-To: Jane Brown +Resent-Date: Mon, 24 Nov 1997 14:22:01 -0800 +Resent-Message-ID: <78910@example.net> +From: John Doe +To: Mary Smith +Subject: Saying Hello +Date: Fri, 21 Nov 1997 09:55:06 -0600 +Message-ID: <1234@local.machine.example> + +This is a message just to say hello. +So, "Hello". +---- + + If Jane, in turn, wished to resend this message to another person, + she would prepend her own set of resent header fields to the above + and send that. + + + + + + + + + + + + + + + + + + + + + + + + + +Resnick Standards Track [Page 45] + +RFC 2822 Internet Message Format April 2001 + + +A.4. Messages with trace fields + + As messages are sent through the transport system as described in + [RFC2821], trace fields are prepended to the message. The following + is an example of what those trace fields might look like. Note that + there is some folding white space in the first one since these lines + can be long. + +---- +Received: from x.y.test + by example.net + via TCP + with ESMTP + id ABC12345 + for ; 21 Nov 1997 10:05:43 -0600 +Received: from machine.example by x.y.test; 21 Nov 1997 10:01:22 -0600 +From: John Doe +To: Mary Smith +Subject: Saying Hello +Date: Fri, 21 Nov 1997 09:55:06 -0600 +Message-ID: <1234@local.machine.example> + +This is a message just to say hello. +So, "Hello". +---- + + + + + + + + + + + + + + + + + + + + + + + + + + +Resnick Standards Track [Page 46] + +RFC 2822 Internet Message Format April 2001 + + +A.5. White space, comments, and other oddities + + White space, including folding white space, and comments can be + inserted between many of the tokens of fields. Taking the example + from A.1.3, white space and comments can be inserted into all of the + fields. + +---- +From: Pete(A wonderful \) chap) +To:A Group(Some people) + :Chris Jones , + joe@example.org, + John (my dear friend); (the end of the group) +Cc:(Empty list)(start)Undisclosed recipients :(nobody(that I know)) ; +Date: Thu, + 13 + Feb + 1969 + 23:32 + -0330 (Newfoundland Time) +Message-ID: + +Testing. +---- + + The above example is aesthetically displeasing, but perfectly legal. + Note particularly (1) the comments in the "From:" field (including + one that has a ")" character appearing as part of a quoted-pair); (2) + the white space absent after the ":" in the "To:" field as well as + the comment and folding white space after the group name, the special + character (".") in the comment in Chris Jones's address, and the + folding white space before and after "joe@example.org,"; (3) the + multiple and nested comments in the "Cc:" field as well as the + comment immediately following the ":" after "Cc"; (4) the folding + white space (but no comments except at the end) and the missing + seconds in the time of the date field; and (5) the white space before + (but not within) the identifier in the "Message-ID:" field. + +A.6. Obsoleted forms + + The following are examples of obsolete (that is, the "MUST NOT + generate") syntactic elements described in section 4 of this + document. + + + + + + + + +Resnick Standards Track [Page 47] + +RFC 2822 Internet Message Format April 2001 + + +A.6.1. Obsolete addressing + + Note in the below example the lack of quotes around Joe Q. Public, + the route that appears in the address for Mary Smith, the two commas + that appear in the "To:" field, and the spaces that appear around the + "." in the jdoe address. + +---- +From: Joe Q. Public +To: Mary Smith <@machine.tld:mary@example.net>, , jdoe@test . example +Date: Tue, 1 Jul 2003 10:52:37 +0200 +Message-ID: <5678.21-Nov-1997@example.com> + +Hi everyone. +---- + +A.6.2. Obsolete dates + + The following message uses an obsolete date format, including a non- + numeric time zone and a two digit year. Note that although the + day-of-week is missing, that is not specific to the obsolete syntax; + it is optional in the current syntax as well. + +---- +From: John Doe +To: Mary Smith +Subject: Saying Hello +Date: 21 Nov 97 09:55:06 GMT +Message-ID: <1234@local.machine.example> + +This is a message just to say hello. +So, "Hello". +---- + +A.6.3. Obsolete white space and comments + + White space and comments can appear between many more elements than + in the current syntax. Also, folding lines that are made up entirely + of white space are legal. + + + + + + + + + + + + +Resnick Standards Track [Page 48] + +RFC 2822 Internet Message Format April 2001 + + +---- +From : John Doe +To : Mary Smith +__ + +Subject : Saying Hello +Date : Fri, 21 Nov 1997 09(comment): 55 : 06 -0600 +Message-ID : <1234 @ local(blah) .machine .example> + +This is a message just to say hello. +So, "Hello". +---- + + Note especially the second line of the "To:" field. It starts with + two space characters. (Note that "__" represent blank spaces.) + Therefore, it is considered part of the folding as described in + section 4.2. Also, the comments and white space throughout + addresses, dates, and message identifiers are all part of the + obsolete syntax. + +Appendix B. Differences from earlier standards + + This appendix contains a list of changes that have been made in the + Internet Message Format from earlier standards, specifically [RFC822] + and [STD3]. Items marked with an asterisk (*) below are items which + appear in section 4 of this document and therefore can no longer be + generated. + + 1. Period allowed in obsolete form of phrase. + 2. ABNF moved out of document to [RFC2234]. + 3. Four or more digits allowed for year. + 4. Header field ordering (and lack thereof) made explicit. + 5. Encrypted header field removed. + 6. Received syntax loosened to allow any token/value pair. + 7. Specifically allow and give meaning to "-0000" time zone. + 8. Folding white space is not allowed between every token. + 9. Requirement for destinations removed. + 10. Forwarding and resending redefined. + 11. Extension header fields no longer specifically called out. + 12. ASCII 0 (null) removed.* + 13. Folding continuation lines cannot contain only white space.* + 14. Free insertion of comments not allowed in date.* + 15. Non-numeric time zones not allowed.* + 16. Two digit years not allowed.* + 17. Three digit years interpreted, but not allowed for generation. + 18. Routes in addresses not allowed.* + 19. CFWS within local-parts and domains not allowed.* + 20. Empty members of address lists not allowed.* + + + +Resnick Standards Track [Page 49] + +RFC 2822 Internet Message Format April 2001 + + + 21. Folding white space between field name and colon not allowed.* + 22. Comments between field name and colon not allowed. + 23. Tightened syntax of in-reply-to and references.* + 24. CFWS within msg-id not allowed.* + 25. Tightened semantics of resent fields as informational only. + 26. Resent-Reply-To not allowed.* + 27. No multiple occurrences of fields (except resent and received).* + 28. Free CR and LF not allowed.* + 29. Routes in return path not allowed.* + 30. Line length limits specified. + 31. Bcc more clearly specified. + +Appendix C. Notices + + Intellectual Property + + The IETF takes no position regarding the validity or scope of any + intellectual property or other rights that might be claimed to + pertain to the implementation or use of the technology described in + this document or the extent to which any license under such rights + might or might not be available; neither does it represent that it + has made any effort to identify any such rights. Information on the + IETF's procedures with respect to rights in standards-track and + standards-related documentation can be found in BCP-11. Copies of + claims of rights made available for publication and any assurances of + licenses to be made available, or the result of an attempt made to + obtain a general license or permission for the use of such + proprietary rights by implementors or users of this specification can + be obtained from the IETF Secretariat. + + + + + + + + + + + + + + + + + + + + + + +Resnick Standards Track [Page 50] + +RFC 2822 Internet Message Format April 2001 + + +Full Copyright Statement + + Copyright (C) The Internet Society (2001). All Rights Reserved. + + This document and translations of it may be copied and furnished to + others, and derivative works that comment on or otherwise explain it + or assist in its implementation may be prepared, copied, published + and distributed, in whole or in part, without restriction of any + kind, provided that the above copyright notice and this paragraph are + included on all such copies and derivative works. However, this + document itself may not be modified in any way, such as by removing + the copyright notice or references to the Internet Society or other + Internet organizations, except as needed for the purpose of + developing Internet standards in which case the procedures for + copyrights defined in the Internet Standards process must be + followed, or as required to translate it into languages other than + English. + + The limited permissions granted above are perpetual and will not be + revoked by the Internet Society or its successors or assigns. + + This document and the information contained herein is provided on an + "AS IS" basis and THE INTERNET SOCIETY AND THE INTERNET ENGINEERING + TASK FORCE DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING + BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION + HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF + MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + +Acknowledgement + + Funding for the RFC Editor function is currently provided by the + Internet Society. + + + + + + + + + + + + + + + + + + + +Resnick Standards Track [Page 51] + diff --git a/vendor/swiftmailer/swiftmailer/notes/rfc/rfc3156.txt b/vendor/swiftmailer/swiftmailer/notes/rfc/rfc3156.txt new file mode 100755 index 0000000..c8ca1d5 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/notes/rfc/rfc3156.txt @@ -0,0 +1,842 @@ + + + + + +Network Working Group M. Elkins +Request for Comments: 3156 Network Associates, Inc. +Updates: 2015 D. Del Torto +Category: Standards Track CryptoRights Foundation + R. Levien + University of California at Berkeley + T. Roessler + August 2001 + + + MIME Security with OpenPGP + +Status of this Memo + + This document specifies an Internet standards track protocol for the + Internet community, and requests discussion and suggestions for + improvements. Please refer to the current edition of the "Internet + Official Protocol Standards" (STD 1) for the standardization state + and status of this protocol. Distribution of this memo is unlimited. + +Copyright Notice + + Copyright (C) The Internet Society (2001). All Rights Reserved. + +Abstract + + This document describes how the OpenPGP Message Format can be used to + provide privacy and authentication using the Multipurpose Internet + Mail Extensions (MIME) security content types described in RFC 1847. + +1. Introduction + + Work on integrating PGP (Pretty Good Privacy) with MIME [3] + (including the since withdrawn "application/pgp" content type) prior + to RFC 2015 suffered from a number of problems, the most significant + of which is the inability to recover signed message bodies without + parsing data structures specific to PGP. RFC 2015 makes use of the + elegant solution proposed in RFC 1847, which defines security + multipart formats for MIME. The security multiparts clearly separate + the signed message body from the signature, and have a number of + other desirable properties. This document revises RFC 2015 to adopt + the integration of PGP and MIME to the needs which emerged during the + work on the OpenPGP specification. + + This document defines three content types for implementing security + and privacy with OpenPGP: "application/pgp-encrypted", + "application/pgp-signature" and "application/pgp-keys". + + + + +Elkins, et al. Standards Track [Page 1] + +RFC 3156 MIME Security with OpenPGP August 2001 + + + The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", + "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this + document are to be interpreted as described in RFC 2119. + +2. OpenPGP data formats + + OpenPGP implementations can generate either ASCII armor (described in + [1]) or 8-bit binary output when encrypting data, generating a + digital signature, or extracting public key data. The ASCII armor + output is the REQUIRED method for data transfer. This allows those + users who do not have the means to interpret the formats described in + this document to be able to extract and use the OpenPGP information + in the message. + + When the amount of data to be transmitted requires that it be sent in + many parts, the MIME message/partial mechanism SHOULD be used rather + than the multi-part ASCII armor OpenPGP format. + +3. Content-Transfer-Encoding restrictions + + Multipart/signed and multipart/encrypted are to be treated by agents + as opaque, meaning that the data is not to be altered in any way [2], + [7]. However, many existing mail gateways will detect if the next + hop does not support MIME or 8-bit data and perform conversion to + either Quoted-Printable or Base64. This presents serious problems + for multipart/signed, in particular, where the signature is + invalidated when such an operation occurs. For this reason all data + signed according to this protocol MUST be constrained to 7 bits (8- + bit data MUST be encoded using either Quoted-Printable or Base64). + Note that this also includes the case where a signed object is also + encrypted (see section 6). This restriction will increase the + likelihood that the signature will be valid upon receipt. + + Additionally, implementations MUST make sure that no trailing + whitespace is present after the MIME encoding has been applied. + + Note: In most cases, trailing whitespace can either be removed, or + protected by applying an appropriate content-transfer-encoding. + However, special care must be taken when any header lines - either + in MIME entity headers, or in embedded RFC 822 headers - are + present which only consist of whitespace: Such lines must be + removed entirely, since replacing them by empty lines would turn + them into header delimiters, and change the semantics of the + message. The restrictions on whitespace are necessary in order to + make the hash calculated invariant under the text and binary mode + signature mechanisms provided by OpenPGP [1]. Also, they help to + avoid compatibility problems with PGP implementations which + predate the OpenPGP specification. + + + +Elkins, et al. Standards Track [Page 2] + +RFC 3156 MIME Security with OpenPGP August 2001 + + + Note: If any line begins with the string "From ", it is strongly + suggested that either the Quoted-Printable or Base64 MIME encoding + be applied. If Quoted-Printable is used, at least one of the + characters in the string should be encoded using the hexadecimal + coding rule. This is because many mail transfer and delivery + agents treat "From " (the word "from" followed immediately by a + space character) as the start of a new message and thus insert a + right angle-bracket (>) in front of any line beginning with + "From " to distinguish this case, invalidating the signature. + + Data that is ONLY to be encrypted is allowed to contain 8-bit + characters and trailing whitespace and therefore need not undergo the + conversion to a 7bit format, and the stripping of whitespace. + + Implementor's note: It cannot be stressed enough that applications + using this standard follow MIME's suggestion that you "be + conservative in what you generate, and liberal in what you + accept." In this particular case it means it would be wise for an + implementation to accept messages with any content-transfer- + encoding, but restrict generation to the 7-bit format required by + this memo. This will allow future compatibility in the event the + Internet SMTP framework becomes 8-bit friendly. + +4. OpenPGP encrypted data + + Before OpenPGP encryption, the data is written in MIME canonical + format (body and headers). + + OpenPGP encrypted data is denoted by the "multipart/encrypted" + content type, described in [2], and MUST have a "protocol" parameter + value of "application/pgp-encrypted". Note that the value of the + parameter MUST be enclosed in quotes. + + The multipart/encrypted MIME body MUST consist of exactly two body + parts, the first with content type "application/pgp-encrypted". This + body contains the control information. A message complying with this + standard MUST contain a "Version: 1" field in this body. Since the + OpenPGP packet format contains all other information necessary for + decrypting, no other information is required here. + + The second MIME body part MUST contain the actual encrypted data. It + MUST be labeled with a content type of "application/octet-stream". + + Example message: + + From: Michael Elkins + To: Michael Elkins + Mime-Version: 1.0 + + + +Elkins, et al. Standards Track [Page 3] + +RFC 3156 MIME Security with OpenPGP August 2001 + + + Content-Type: multipart/encrypted; boundary=foo; + protocol="application/pgp-encrypted" + + --foo + Content-Type: application/pgp-encrypted + + Version: 1 + + --foo + Content-Type: application/octet-stream + + -----BEGIN PGP MESSAGE----- + Version: 2.6.2 + + hIwDY32hYGCE8MkBA/wOu7d45aUxF4Q0RKJprD3v5Z9K1YcRJ2fve87lMlDlx4Oj + eW4GDdBfLbJE7VUpp13N19GL8e/AqbyyjHH4aS0YoTk10QQ9nnRvjY8nZL3MPXSZ + g9VGQxFeGqzykzmykU6A26MSMexR4ApeeON6xzZWfo+0yOqAq6lb46wsvldZ96YA + AABH78hyX7YX4uT1tNCWEIIBoqqvCeIMpp7UQ2IzBrXg6GtukS8NxbukLeamqVW3 + 1yt21DYOjuLzcMNe/JNsD9vDVCvOOG3OCi8= + =zzaA + -----END PGP MESSAGE----- + + --foo-- + +5. OpenPGP signed data + + OpenPGP signed messages are denoted by the "multipart/signed" content + type, described in [2], with a "protocol" parameter which MUST have a + value of "application/pgp-signature" (MUST be quoted). + + The "micalg" parameter for the "application/pgp-signature" protocol + MUST contain exactly one hash-symbol of the format "pgp-", where identifies the Message + Integrity Check (MIC) algorithm used to generate the signature. + Hash-symbols are constructed from the text names registered in [1] or + according to the mechanism defined in that document by converting the + text name to lower case and prefixing it with the four characters + "pgp-". + + Currently defined values are "pgp-md5", "pgp-sha1", "pgp-ripemd160", + "pgp-md2", "pgp-tiger192", and "pgp-haval-5-160". + + The multipart/signed body MUST consist of exactly two parts. The + first part contains the signed data in MIME canonical format, + including a set of appropriate content headers describing the data. + + The second body MUST contain the OpenPGP digital signature. It MUST + be labeled with a content type of "application/pgp-signature". + + + +Elkins, et al. Standards Track [Page 4] + +RFC 3156 MIME Security with OpenPGP August 2001 + + + Note: Implementations can either generate "signatures of a + canonical text document" or "signatures of a binary document", as + defined in [1]. The restrictions on the signed material put forth + in section 3 and in this section will make sure that the various + MIC algorithm variants specified in [1] and [5] will all produce + the same result. + + When the OpenPGP digital signature is generated: + + (1) The data to be signed MUST first be converted to its content- + type specific canonical form. For text/plain, this means + conversion to an appropriate character set and conversion of + line endings to the canonical sequence. + + (2) An appropriate Content-Transfer-Encoding is then applied; see + section 3. In particular, line endings in the encoded data + MUST use the canonical sequence where appropriate + (note that the canonical line ending may or may not be present + on the last line of encoded data and MUST NOT be included in + the signature if absent). + + (3) MIME content headers are then added to the body, each ending + with the canonical sequence. + + (4) As described in section 3 of this document, any trailing + whitespace MUST then be removed from the signed material. + + (5) As described in [2], the digital signature MUST be calculated + over both the data to be signed and its set of content headers. + + (6) The signature MUST be generated detached from the signed data + so that the process does not alter the signed data in any way. + + Note: The accepted OpenPGP convention is for signed data to end + with a sequence. Note that the sequence + immediately preceding a MIME boundary delimiter line is considered + to be part of the delimiter in [3], 5.1. Thus, it is not part of + the signed data preceding the delimiter line. An implementation + which elects to adhere to the OpenPGP convention has to make sure + it inserts a pair on the last line of the data to be + signed and transmitted (signed message and transmitted message + MUST be identical). + + Example message: + + From: Michael Elkins + To: Michael Elkins + Mime-Version: 1.0 + + + +Elkins, et al. Standards Track [Page 5] + +RFC 3156 MIME Security with OpenPGP August 2001 + + + Content-Type: multipart/signed; boundary=bar; micalg=pgp-md5; + protocol="application/pgp-signature" + + --bar + & Content-Type: text/plain; charset=iso-8859-1 + & Content-Transfer-Encoding: quoted-printable + & + & =A1Hola! + & + & Did you know that talking to yourself is a sign of senility? + & + & It's generally a good idea to encode lines that begin with + & From=20because some mail transport agents will insert a greater- + & than (>) sign, thus invalidating the signature. + & + & Also, in some cases it might be desirable to encode any =20 + & trailing whitespace that occurs on lines in order to ensure =20 + & that the message signature is not invalidated when passing =20 + & a gateway that modifies such whitespace (like BITNET). =20 + & + & me + + --bar + + Content-Type: application/pgp-signature + + -----BEGIN PGP MESSAGE----- + Version: 2.6.2 + + iQCVAwUBMJrRF2N9oWBghPDJAQE9UQQAtl7LuRVndBjrk4EqYBIb3h5QXIX/LC// + jJV5bNvkZIGPIcEmI5iFd9boEgvpirHtIREEqLQRkYNoBActFBZmh9GC3C041WGq + uMbrbxc+nIs1TIKlA08rVi9ig/2Yh7LFrK5Ein57U/W72vgSxLhe/zhdfolT9Brn + HOxEa44b+EI= + =ndaj + -----END PGP MESSAGE----- + + --bar-- + + The "&"s in the previous example indicate the portion of the data + over which the signature was calculated. + + Upon receipt of a signed message, an application MUST: + + (1) Convert line endings to the canonical sequence before + the signature can be verified. This is necessary since the + local MTA may have converted to a local end of line convention. + + + + + +Elkins, et al. Standards Track [Page 6] + +RFC 3156 MIME Security with OpenPGP August 2001 + + + (2) Pass both the signed data and its associated content headers + along with the OpenPGP signature to the signature verification + service. + +6. Encrypted and Signed Data + + Sometimes it is desirable to both digitally sign and then encrypt a + message to be sent. This protocol allows for two methods of + accomplishing this task. + +6.1. RFC 1847 Encapsulation + + In [2], it is stated that the data is first signed as a + multipart/signature body, and then encrypted to form the final + multipart/encrypted body. This is most useful for standard MIME- + compliant message forwarding. + + Example: + + Content-Type: multipart/encrypted; + protocol="application/pgp-encrypted"; boundary=foo + + --foo + Content-Type: application/pgp-encrypted + + Version: 1 + + --foo + Content-Type: application/octet-stream + + -----BEGIN PGP MESSAGE----- + & Content-Type: multipart/signed; micalg=pgp-md5 + & protocol="application/pgp-signature"; boundary=bar + & + & --bar + & Content-Type: text/plain; charset=us-ascii + & + & This message was first signed, and then encrypted. + & + & --bar + & Content-Type: application/pgp-signature + & + & -----BEGIN PGP MESSAGE----- + & Version: 2.6.2 + & + & iQCVAwUBMJrRF2N9oWBghPDJAQE9UQQAtl7LuRVndBjrk4EqYBIb3h5QXIX/LC// + & jJV5bNvkZIGPIcEmI5iFd9boEgvpirHtIREEqLQRkYNoBActFBZmh9GC3C041WGq + & uMbrbxc+nIs1TIKlA08rVi9ig/2Yh7LFrK5Ein57U/W72vgSxLhe/zhdfolT9Brn + + + +Elkins, et al. Standards Track [Page 7] + +RFC 3156 MIME Security with OpenPGP August 2001 + + + & HOxEa44b+EI= + & =ndaj + & -----END PGP MESSAGE----- + & + & --bar-- + -----END PGP MESSAGE----- + + --foo-- + + (The text preceded by '&' indicates that it is really encrypted, but + presented as text for clarity.) + +6.2. Combined method + + The OpenPGP packet format [1] describes a method for signing and + encrypting data in a single OpenPGP message. This method is allowed + in order to reduce processing overhead and increase compatibility + with non-MIME implementations of OpenPGP. The resulting data is + formatted as a "multipart/encrypted" object as described in Section + 4. + + Messages which are encrypted and signed in this combined fashion are + REQUIRED to follow the same canonicalization rules as + multipart/signed objects. + + It is explicitly allowed for an agent to decrypt a combined message + and rewrite it as a multipart/signed object using the signature data + embedded in the encrypted version. + +7. Distribution of OpenPGP public keys + + Content-Type: application/pgp-keys + Required parameters: none + Optional parameters: none + + A MIME body part of the content type "application/pgp-keys" contains + ASCII-armored transferable Public Key Packets as defined in [1], + section 10.1. + +8. Security Considerations + + Signatures of a canonical text document as defined in [1] ignore + trailing white space in signed material. Implementations which + choose to use signatures of canonical text documents will not be able + to detect the addition of whitespace in transit. + + See [3], [4] for more information on the security considerations + concerning the underlying protocols. + + + +Elkins, et al. Standards Track [Page 8] + +RFC 3156 MIME Security with OpenPGP August 2001 + + +9. IANA Considerations + + This document defines three media types: "application/pgp-encrypted", + "application/pgp-signature" and "application/pgp-keys". The + following sections specify the IANA registrations for these types. + +9.1. Registration of the application/pgp-encrypted media type + + MIME media type name: application + MIME subtype name: pgp-encrypted + Required parameters: none + Optional parameters: none + + Encoding considerations: + + Currently this media type always consists of a single 7bit text + string. + + Security considerations: + + See Section 8 and RFC 2440 Section 13. + + Interoperability considerations: none + + Published specification: + + This document. + + Additional information: + + Magic number(s): none + File extension(s): none + Macintosh File Type Code(s): none + + Person & email address to contact for further information: + + Michael Elkins + Email: me@cs.hmc.edu + + Intended usage: common + + Author/Change controller: + + Michael Elkins + Email: me@cs.hmc.edu + + + + + + +Elkins, et al. Standards Track [Page 9] + +RFC 3156 MIME Security with OpenPGP August 2001 + + +9.2. Registration of the application/pgp-signature media type + + MIME media type name: application + MIME subtype name: pgp-signature + Required parameters: none + Optional parameters: none + + Encoding considerations: + + The content of this media type always consists of 7bit text. + + Security considerations: + + See Section 8 and RFC 2440 Section 13. + + Interoperability considerations: none + + Published specification: + + RFC 2440 and this document. + + Additional information: + + Magic number(s): none + File extension(s): asc, sig + Macintosh File Type Code(s): pgDS + + Person & email address to contact for further information: + + Michael Elkins + Email: me@cs.hmc.edu + + Intended usage: common + + Author/Change controller: + + Michael Elkins + Email: me@cs.hmc.edu + +9.3. Registration of the application/pgp-keys media type + + MIME media type name: application + MIME subtype name: pgp-keys + Required parameters: none + Optional parameters: none + + + + + + +Elkins, et al. Standards Track [Page 10] + +RFC 3156 MIME Security with OpenPGP August 2001 + + + Encoding considerations: + + The content of this media type always consists of 7bit text. + + Security considerations: + + See Section 8 and RFC 2440 Section 13. + + Interoperability considerations: none + + Published specification: + + RFC 2440 and this document. + + Additional information: + + Magic number(s): none + File extension(s): asc + Macintosh File Type Code(s): none + + Person & email address to contact for further information: + + Michael Elkins + Email: me@cs.hmc.edu + + Intended usage: common + + Author/Change controller: + + Michael Elkins + Email: me@cs.hmc.edu + + + + + + + + + + + + + + + + + + + + +Elkins, et al. Standards Track [Page 11] + +RFC 3156 MIME Security with OpenPGP August 2001 + + +10. Notes + + "PGP" and "Pretty Good Privacy" are registered trademarks of Network + Associates, Inc. + +11. Acknowledgements + + This document relies on the work of the IETF's OpenPGP Working + Group's definitions of the OpenPGP Message Format. The OpenPGP + message format is currently described in RFC 2440 [1]. + + Special thanks are due: to Philip Zimmermann for his original and + ongoing work on PGP; to Charles Breed, Jon Callas and Dave Del Torto + for originally proposing the formation of the OpenPGP Working Group; + and to Steve Schoenfeld for helpful feedback during the draft + process. The authors would also like to thank the engineers at + Pretty Good Privacy, Inc (now Network Associates, Inc), including + Colin Plumb, Hal Finney, Jon Callas, Mark Elrod, Mark Weaver and + Lloyd Chambers, for their technical commentary. + + Additional thanks are due to Jeff Schiller and Derek Atkins for their + continuing support of strong cryptography and PGP freeware at MIT; to + Rodney Thayer of Sable Technology; to John Noerenberg, Steve Dorner + and Laurence Lundblade of the Eudora team at QUALCOMM, Inc; to Bodo + Moeller for proposing the approach followed with respect to trailing + whitespace; to John Gilmore, Hugh Daniel and Fred Ringel (at + Rivertown) and Ian Bell (at Turnpike) for their timely critical + commentary; and to the international members of the IETF's OpenPGP + mailing list, including William Geiger, Lutz Donnerhacke and Kazu + Yamamoto. The idea to use multipart/mixed with multipart/signed has + been attributed to James Galvin. Finally, our gratitude is due to + the many members of the "Cypherpunks," "Coderpunks" and "pgp-users" + mailing lists and the many users + of PGP worldwide for helping keep the path to privacy open. + + + + + + + + + + + + + + + + + +Elkins, et al. Standards Track [Page 12] + +RFC 3156 MIME Security with OpenPGP August 2001 + + +12. Addresses of the Authors and OpenPGP Working Group Chair + + The OpenPGP working group can be contacted via the current chair: + + John W. Noerenberg II + Qualcomm, Inc. + 5775 Morehouse Dr. + San Diego, CA 92121 USA + + Phone: +1 619 658 3510 + EMail: jwn2@qualcomm.com + + The principal authors of this document are: + + Dave Del Torto + CryptoRights Foundation + 80 Alviso Street, Mailstop: CRF + San Francisco, CA 94127 USA + + Phone: +1.415.334.5533, vm: #2 + EMail: ddt@cryptorights.org, ddt@openpgp.net + + + Michael Elkins + Network Associates, Inc. + 3415 S. Sepulveda Blvd Suite 700 + Los Angeles, CA 90034 USA + + Phone: +1.310.737.1663 + Fax: +1.310.737.1755 + Email: me@cs.hmc.edu, Michael_Elkins@NAI.com + + + Raph Levien + University of California at Berkeley + 579 Soda Hall + Berkeley, CA 94720 USA + + Phone: +1.510.642.6509 + EMail: raph@acm.org + + + Thomas Roessler + Nordstrasse 99 + D-53111 Bonn, Germany + + Phone: +49-228-638007 + EMail: roessler@does-not-exist.org + + + +Elkins, et al. Standards Track [Page 13] + +RFC 3156 MIME Security with OpenPGP August 2001 + + +References + + [1] Callas, J., Donnerhacke, L., Finney, H. and R. Thayer, "OpenPGP + Message Format", RFC 2440, November 1998. + + [2] Galvin, J., Murphy, G., Crocker, S. and N. Freed, "Security + Multiparts for MIME: Multipart/Signed and Multipart/Encrypted", + RFC 1847, October 1995. + + [3] Freed, N. and N. Borenstein, "Multipurpose Internet Mail + Extensions (MIME) Part Two: Media Types", RFC 2046, November + 1996. + + [4] Galvin, J., Murphy, G., Crocker, S. and N. Freed, "MIME Object + Security Services", RFC 1848, October 1995. + + [5] Atkins, D., Stallings, W. and P. Zimmermann, "PGP Message + Exchange Formats", RFC 1991, August 1996. + + [6] Elkins, M., "MIME Security with Pretty Good Privacy (PGP)", RFC + 2015, October 1996. + + [7] Freed, N., "Gateways and MIME Security Multiparts", RFC 2480, + January 1999. + + + + + + + + + + + + + + + + + + + + + + + + + + + +Elkins, et al. Standards Track [Page 14] + +RFC 3156 MIME Security with OpenPGP August 2001 + + +Full Copyright Statement + + Copyright (C) The Internet Society (2001). All Rights Reserved. + + This document and translations of it may be copied and furnished to + others, and derivative works that comment on or otherwise explain it + or assist in its implementation may be prepared, copied, published + and distributed, in whole or in part, without restriction of any + kind, provided that the above copyright notice and this paragraph are + included on all such copies and derivative works. However, this + document itself may not be modified in any way, such as by removing + the copyright notice or references to the Internet Society or other + Internet organizations, except as needed for the purpose of + developing Internet standards in which case the procedures for + copyrights defined in the Internet Standards process must be + followed, or as required to translate it into languages other than + English. + + The limited permissions granted above are perpetual and will not be + revoked by the Internet Society or its successors or assigns. + + This document and the information contained herein is provided on an + "AS IS" basis and THE INTERNET SOCIETY AND THE INTERNET ENGINEERING + TASK FORCE DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING + BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION + HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF + MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + +Acknowledgement + + Funding for the RFC Editor function is currently provided by the + Internet Society. + + + + + + + + + + + + + + + + + + + +Elkins, et al. Standards Track [Page 15] + diff --git a/vendor/swiftmailer/swiftmailer/notes/rfc/rfc3676.txt b/vendor/swiftmailer/swiftmailer/notes/rfc/rfc3676.txt new file mode 100755 index 0000000..bc08fba --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/notes/rfc/rfc3676.txt @@ -0,0 +1,1123 @@ + + + + + + +Network Working Group R. Gellens +Request for Comments: 3676 Qualcomm +Obsoletes: 2646 February 2004 +Category: Standards Track + + + The Text/Plain Format and DelSp Parameters + +Status of this Memo + + This document specifies an Internet standards track protocol for the + Internet community, and requests discussion and suggestions for + improvements. Please refer to the current edition of the "Internet + Official Protocol Standards" (STD 1) for the standardization state + and status of this protocol. Distribution of this memo is unlimited. + +Copyright Notice + + Copyright (C) The Internet Society (2004). All Rights Reserved. + +Abstract + + This specification establishes two parameters (Format and DelSP) to + be used with the Text/Plain media type. In the presence of these + parameters, trailing whitespace is used to indicate flowed lines and + a canonical quote indicator is used to indicate quoted lines. This + results in an encoding which appears as normal Text/Plain in older + implementations, since it is in fact normal Text/Plain, yet provides + for superior wrapping/flowing, and quoting. + + This document supersedes the one specified in RFC 2646, "The + Text/Plain Format Parameter", and adds the DelSp parameter to + accommodate languages/coded character sets in which ASCII spaces are + not used or appear rarely. + +Table of Contents + + 1. Introduction. . . . . . . . . . . . . . . . . . . . . . . . . 2 + 2. Conventions Used in this Document . . . . . . . . . . . . . . 2 + 3. The Problem . . . . . . . . . . . . . . . . . . . . . . . . . 3 + 3.1. Paragraph Text. . . . . . . . . . . . . . . . . . . . . 3 + 3.2. Embarrassing Line Wrap . . . . . . . . . . . . . . . . 3 + 3.3. New Media Types . . . . . . . . . . . . . . . . . . . . 4 + 4. The Format and DelSp Parameters . . . . . . . . . . . . . . . 5 + 4.1. Interpreting Format=Flowed. . . . . . . . . . . . . . . 6 + 4.2. Generating Format=Flowed . . . . . . . . . . . . . . . 7 + 4.3. Usenet Signature Convention . . . . . . . . . . . . . . 9 + 4.4. Space-Stuffing . . . . . . . . . . . . . . . . . . . . 9 + + + +Gellens Standards Track [Page 1] + +RFC 3676 Text/Plain Format and DelSp Parameters February 2004 + + + 4.5. Quoting . . . . . . . . . . . . . . . . . . . . . . . . 9 + 4.6. Digital Signatures and Encryption . . . . . . . . . . . 11 + 4.7. Examples. . . . . . . . . . . . . . . . . . . . . . . . 12 + 5. Interoperability. . . . . . . . . . . . . . . . . . . . . . . 12 + 6. ABNF. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 + 7. Failure Modes . . . . . . . . . . . . . . . . . . . . . . . . 14 + 7.1. Trailing White Space Corruption . . . . . . . . . . . . 14 + 8. Security Considerations . . . . . . . . . . . . . . . . . . . 15 + 9. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 15 + 10. Internationalization Considerations . . . . . . . . . . . . . 15 + 11. Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . 15 + 12. Normative References. . . . . . . . . . . . . . . . . . . . . 16 + 13. Informative References. . . . . . . . . . . . . . . . . . . . 16 + Appendix A: Changes from RFC 2646 . . . . . . . . . . . . . . . . 18 + Author's Address. . . . . . . . . . . . . . . . . . . . . . . . . 19 + Full Copyright Statement. . . . . . . . . . . . . . . . . . . . . 20 + +1. Introduction + + Interoperability problems have been observed with erroneous labelling + of paragraph text as Text/Plain, and with various forms of + "embarrassing line wrap". (See Section 3.) + + Attempts to deploy new media types, such as Text/Enriched [Rich] and + Text/HTML [HTML] have suffered from a lack of backwards compatibility + and an often hostile user reaction at the receiving end. + + What is required is a format which is in all significant ways + Text/Plain, and therefore is quite suitable for display as + Text/Plain, and yet allows the sender to express to the receiver + which lines are quoted and which lines are considered a logical + paragraph, and thus eligible to be flowed (wrapped and joined) as + appropriate. + +2. Conventions Used in this Document + + The key words "REQUIRED", "MUST", "MUST NOT", "SHOULD", "SHOULD NOT", + and "MAY" in this document are to be interpreted as described in "Key + words for use in RFCs to Indicate Requirement Levels" [KEYWORDS]. + + The term "paragraph" is used here to mean a series of lines which are + logically to be treated as a unit for display purposes and eligible + to be flowed (wrapped and joined) as appropriate to fit in the + display window and when creating text for replies, forwarding, etc. + + + + + + + +Gellens Standards Track [Page 2] + +RFC 3676 Text/Plain Format and DelSp Parameters February 2004 + + +3. The Problem + + The Text/Plain media type is the lowest common denominator of + Internet email, with lines of no more than 998 characters (by + convention usually no more than 78), and where the carriage-return + and line-feed (CRLF) sequence represents a line break (see [MIME-IMT] + and [MSG-FMT]). + + Text/Plain is usually displayed as preformatted text, often in a + fixed font. That is, the characters start at the left margin of the + display window, and advance to the right until a CRLF sequence is + seen, at which point a new line is started, again at the left margin. + When a line length exceeds the display window, some clients will wrap + the line, while others invoke a horizontal scroll bar. + + Text which meets this description is defined by this memo as "fixed". + + Some interoperability problems have been observed with this format: + +3.1. Paragraph Text + + Many modern programs use a proportional-spaced font, and use CRLF to + represent paragraph breaks. Line breaks are "soft", occurring as + needed on display. That is, characters are grouped into a paragraph + until a CRLF sequence is seen, at which point a new paragraph is + started. Each paragraph is displayed, starting at the left margin + (or paragraph indent), and continuing to the right until a word is + encountered which does not fit in the remaining display width. This + word is displayed at the left margin of the next line. This + continues until the paragraph ends (a CRLF is seen). Extra vertical + space is left between paragraphs. + + Text which meets this description is defined by this memo as + "flowed". + + Numerous software products erroneously label this format as + Text/Plain, resulting in much user discomfort. + +3.2. Embarrassing Line Wrap + + As Text/Plain messages are quoted in replies or forwarded messages, + each line gradually increases in length, eventually being arbitrarily + hard wrapped, resulting in "embarrassing line wrap". This produces + text which is, at best, hard to read, and often confuses + attributions. + + + + + + +Gellens Standards Track [Page 3] + +RFC 3676 Text/Plain Format and DelSp Parameters February 2004 + + + Example: + + >>>>>>This is a comment from the first message to show a + >quoting example. + >>>>>This is a comment from the second message to show a + >quoting example. + >>>>This is a comment from the third message. + >>>This is a comment from the fourth message. + + It can be confusing to assign attribution to lines 2 and 4 above. + + In addition, as devices with display widths smaller than 79 or 80 + characters become more popular, embarrassing line wrap has become + even more prevalent, even with unquoted text. + + Example: + + This is paragraph text that is + meant to be flowed across + several lines. + However, the sending mailer is + converting it to fixed text at + a width of 72 + characters, which causes it to + look like this when shown on a + PDA with only + 30 character lines. + +3.3. New Media Types + + Attempts to deploy new media types, such as Text/Enriched [Rich] and + Text/HTML [HTML] have suffered from a lack of backwards compatibility + and an often hostile user reaction at the receiving end. + + In particular, Text/Enriched requires that open angle brackets ("<") + and hard line breaks be doubled, with resulting user unhappiness when + viewed as Text/Plain. Text/HTML requires even more alteration of + text, with a corresponding increase in user complaints. + + A proposal to define a new media type to explicitly represent the + paragraph form suffered from a lack of interoperability with + currently deployed software. Some programs treat unknown subtypes of + TEXT as an attachment. + + + + + + + + +Gellens Standards Track [Page 4] + +RFC 3676 Text/Plain Format and DelSp Parameters February 2004 + + + What is desired is a format which is in all significant ways + Text/Plain, and therefore is quite suitable for display as + Text/Plain, and yet allows the sender to express to the receiver + which lines can be considered a logical paragraph, and thus flowed + (wrapped and joined) as appropriate. + +4. The Format and DelSp Parameters + + This specification defines two MIME parameters for use with + Text/Plain: + + Name: Format + Value: Fixed, Flowed + + Name: DelSp + Value: Yes, No + + (Neither the parameter names nor values are case sensitive.) + + If Format is not specified, or if the value is not recognized, a + value of Fixed is assumed. The semantics of the Fixed value are the + usual associated with Text/Plain [MIME-IMT]. + + A Format value of Flowed indicates that the definition of flowed text + (as specified in this memo) was used on generation, and MAY be used + on reception. + + Note that because Format is a parameter of the Text/Plain content- + type, any content-transfer-encoding used is irrelevant to the + processing of flowed text. + + If DelSp is not specified, or if its value is not recognized, a value + of No is assumed. The use of DelSp without a Format value of Flowed + is undefined. When creating messages, DelSp SHOULD NOT be specified + in Text content types other than Text/Plain with Format = Flowed. + When receiving messages, DelSp SHOULD be ignored if used in a Text + content type other than Text/Plain with Format = Flowed. + + This section discusses flowed text; section 6 provides a formal + definition. + + Section 5 discusses interoperability. + + Note that this memo describes an on-the-wire format. It does not + address formats for local file storage. + + + + + + +Gellens Standards Track [Page 5] + +RFC 3676 Text/Plain Format and DelSp Parameters February 2004 + + +4.1. Interpreting Format=Flowed + + If the first character of a line is a quote mark (">"), the line is + considered to be quoted (see Section 4.5). Logically, all quote + marks are counted and deleted, resulting in a line with a non-zero + quote depth, and content. (The agent is of course free to display + the content with quote marks or excerpt bars or anything else.) + Logically, this test for quoted lines is done before any other tests + (that is, before checking for space-stuffed and flowed). + + If the first character of a line is a space, the line has been + space-stuffed (see Section 4.4). Logically, this leading space is + deleted before examining the line further (that is, before checking + for flowed). + + If the line ends in a space, the line is flowed. Otherwise it is + fixed. The exception to this rule is a signature separator line, + described in Section 4.3. Such lines end in a space but are neither + flowed nor fixed. + + If the line is flowed and DelSp is "yes", the trailing space + immediately prior to the line's CRLF is logically deleted. If the + DelSp parameter is "no" (or not specified, or set to an unrecognized + value), the trailing space is not deleted. + + Any remaining trailing spaces are part of the line's content, but the + CRLF of a soft line break is not. + + A series of one or more flowed lines followed by one fixed line is + considered a paragraph, and MAY be flowed (wrapped and unwrapped) as + appropriate on display and in the construction of new messages (see + Section 4.5). + + An interpreting agent SHOULD allow for three exceptions to the rule + that paragraphs end with a fixed line. These exceptions are + improperly constructed messages: a flowed line SHOULD be considered + to end the paragraph if it is followed by a line of a different quote + depth (see 4.5) or by a signature separator (see 4.3); the end of the + body also ends the paragraph. + + A line consisting of one or more spaces (after deleting a space + acting as stuffing) is considered a flowed line. + + An empty line (just a CRLF) is a fixed line. + + Note that, for Unicode text, [Annex-14] provides guidance for + choosing at which characters to wrap a line. + + + + +Gellens Standards Track [Page 6] + +RFC 3676 Text/Plain Format and DelSp Parameters February 2004 + + +4.2. Generating Format=Flowed + + When generating Format=Flowed text, lines SHOULD be 78 characters or + shorter, including any trailing white space and also including any + space added as part of stuffing (see Section 4.4). As suggested + values, any paragraph longer than 78 characters in total length could + be wrapped using lines of 72 or fewer characters. While the specific + line length used is a matter of aesthetics and preference, longer + lines are more likely to require rewrapping and to encounter + difficulties with older mailers. (It has been suggested that 66 + character lines are the most readable.) + + The restriction to 78 or fewer characters between CRLFs on the wire + is to conform to [MSG-FMT]. + + (In addition to conformance to [MSG-FMT], there is a historical need + that all lines, even when displayed by a non-flowed-aware program, + will fit in a standard 79- or 80-column screen without having to be + wrapped. The limit is 78, not 79 or 80, because while 79 or 80 fit + on a line, the last column is often reserved for a line-wrap + indicator.) + + When creating flowed text, the generating agent wraps, that is, + inserts 'soft' line breaks as needed. Soft line breaks are added at + natural wrapping points, such as between words. A soft line break is + a SP CRLF sequence. + + There are two techniques for inserting soft line breaks. The older + technique, established by RFC 2646, creates a soft line break by + inserting a CRLF after the occurrence of a space. With this + technique, soft line breaks are only possible where spaces already + occur. When this technique is used, the DelSp parameter SHOULD be + used; if used it MUST be set to "no". + + The newer technique, suitable for use even with languages/coded + character sets in which the ASCII space character is rare or not + used, creates a soft line break by inserting a SP CRLF sequence. + When this technique is used, the DelSp parameter MUST be used and + MUST be set to "yes". Note that because of space-stuffing (see + Section 4.4), when this technique is used and a soft line break is + inserted at a point where a SP already exists (such as between + words), if the SP CRLF sequence is added immediately before the SP, + the pre-existing SP becomes leading and thus requires stuffing. It + is RECOMMENDED that agents avoid this by inserting the SP CRLF + sequence following the existing SP. + + Generating agents MAY use either method within each Text/Plain body + part. + + + +Gellens Standards Track [Page 7] + +RFC 3676 Text/Plain Format and DelSp Parameters February 2004 + + + Regardless of which technique is used, a generating agent SHOULD NOT + insert a space in an unnatural location, such as into a word (a + sequence of printable characters, not containing spaces, in a + language/coded character set in which spaces are common). If faced + with such a word which exceeds 78 characters (but less than 998 + characters, the [SMTP] limit on line length), the agent SHOULD send + the word as is and exceed the 78-character limit on line length. + + A generating agent SHOULD: + + o Ensure all lines (fixed and flowed) are 78 characters or fewer in + length, counting any trailing space as well as a space added as + stuffing, but not counting the CRLF, unless a word by itself + exceeds 78 characters. + + o Trim spaces before user-inserted hard line breaks. + + A generating agent MUST: + + o Space-stuff lines which start with a space, "From ", or ">". + + In order to create messages which do not require space-stuffing, and + are thus more aesthetically pleasing when viewed as Format=Fixed, a + generating agent MAY avoid wrapping immediately before ">", "From ", + or space. + + (See Sections 4.4 and 4.5 for more information on space-stuffing and + quoting, respectively.) + + A Format=Flowed message consists of zero or more paragraphs, each + containing one or more flowed lines followed by one fixed line. The + usual case is a series of flowed text lines with blank (empty) fixed + lines between them. + + Any number of fixed lines can appear between paragraphs. + + When placing soft line breaks in a paragraph, generating agents MUST + NOT place them in a way that causes any line of the paragraph to be a + signature separator line, because paragraphs cannot contain signature + separator lines (see Sections 4.3 and 6). + + [Quoted-Printable] encoding SHOULD NOT be used with Format=Flowed + unless absolutely necessary (for example, non-US-ASCII (8-bit) + characters over a strictly 7-bit transport such as unextended + [SMTP]). In particular, a message SHOULD NOT be encoded in Quoted- + Printable for the sole purpose of protecting the trailing space on + flowed lines unless the body part is cryptographically signed or + encrypted (see Section 4.6). + + + +Gellens Standards Track [Page 8] + +RFC 3676 Text/Plain Format and DelSp Parameters February 2004 + + + The intent of Format=Flowed is to allow user agents to generate + flowed text which is non-obnoxious when viewed as pure, raw + Text/Plain (without any decoding); use of Quoted-Printable hinders + this and may cause Format=Flowed to be rejected by end users. + +4.3. Usenet Signature Convention + + There is a long-standing convention in Usenet news which also + commonly appears in Internet mail of using "-- " as the separator + line between the body and the signature of a message. When + generating a Format=Flowed message containing a Usenet-style + separator before the signature, the separator line is sent as-is. + This is a special case; an (optionally quoted or quoted and stuffed) + line consisting of DASH DASH SP is neither fixed nor flowed. + + Generating agents MUST NOT end a paragraph with such a signature + line. + + A receiving agent needs to test for a signature line both before the + test for a quoted line (see Section 4.5) and also after logically + counting and deleting quote marks and stuffing (see Section 4.4) from + a quoted line. + +4.4. Space-Stuffing + + In order to allow for unquoted lines which start with ">", and to + protect against systems which "From-munge" in-transit messages + (modifying any line which starts with "From " to ">From "), + Format=Flowed provides for space-stuffing. + + Space-stuffing adds a single space to the start of any line which + needs protection when the message is generated. On reception, if the + first character of a line is a space, it is logically deleted. This + occurs after the test for a quoted line (which logically counts and + deletes any quote marks), and before the test for a flowed line. + + On generation, any unquoted lines which start with ">", and any lines + which start with a space or "From " MUST be space-stuffed. Other + lines MAY be space-stuffed as desired. + + (Note that space-stuffing is conceptually similar to dot-stuffing as + specified in [SMTP].) + +4.5. Quoting + + In Format=Flowed, the canonical quote indicator (or quote mark) is + one or more close angle bracket (">") characters. Lines which start + with the quote indicator are considered quoted. The number of ">" + + + +Gellens Standards Track [Page 9] + +RFC 3676 Text/Plain Format and DelSp Parameters February 2004 + + + characters at the start of the line specifies the quote depth. + Flowed lines which are also quoted may require special handling on + display and when copied to new messages. + + When creating quoted flowed lines, each such line starts with the + quote indicator. + + Note that because of space-stuffing, the lines + >> Exit, Stage Left + and + >>Exit, Stage Left + are semantically identical; both have a quote-depth of two, and a + content of "Exit, Stage Left". + + However, the line + > > Exit, Stage Left + is different. It has a quote-depth of one, and a content of + "> Exit, Stage Left". + + When generating quoted flowed lines, an agent needs to pay attention + to changes in quote depth. All lines of a paragraph MUST be + unquoted, or else they MUST all be quoted and have the same quote + depth. Therefore, whenever there is a change in quote depth, or a + change from quoted to unquoted, or change from unquoted to quoted, + the line immediately preceding the change MUST NOT be a flowed line. + + If a receiving agent wishes to reformat flowed quoted lines (joining + and/or wrapping them) on display or when generating new messages, the + lines SHOULD be de-quoted, reformatted, and then re-quoted. To de- + quote, the number of close angle brackets in the quote indicator at + the start of each line is counted. To re-quote after reformatting, a + quote indicator containing the same number of close angle brackets + originally present are prefixed to each line. + + On reception, if a change in quote depth occurs on a flowed line, + this is an improperly formatted message. The receiver SHOULD handle + this error by using the 'quote-depth-wins' rule, which is to consider + the paragraph to end with the flowed line immediately preceding the + change in quote depth. + + In other words, whenever two adjacent lines have different quote + depths, senders MUST ensure that the earlier line is not flowed (does + not end in a space), and receivers finding a flowed line there SHOULD + treat it as the last line of a paragraph. + + For example, consider the following sequence of lines (using '*' to + indicate a soft line break, i.e., SP CRLF, and '#' to indicate a hard + line break, i.e., CRLF): + + + +Gellens Standards Track [Page 10] + +RFC 3676 Text/Plain Format and DelSp Parameters February 2004 + + + > Thou villainous ill-breeding spongy dizzy-eyed* + > reeky elf-skinned pigeon-egg!* <--- problem ---< + >> Thou artless swag-bellied milk-livered* + >> dismal-dreaming idle-headed scut!# + >>> Thou errant folly-fallen spleeny reeling-ripe* + >>> unmuzzled ratsbane!# + >>>> Henceforth, the coding style is to be strictly* + >>>> enforced, including the use of only upper case.# + >>>>> I've noticed a lack of adherence to the coding* + >>>>> styles, of late.# + >>>>>> Any complaints?# + + The second line ends in a soft line break, even though it is the last + line of the one-deep quote block. The question then arises as to how + this line is to be interpreted, considering that the next line is the + first line of the two-deep quote block. + + The example text above, when processed according to quote-depth wins, + results in the first two lines being considered as one quoted, flowed + section, with a quote depth of 1; the third and fourth lines become a + quoted, flowed section, with a quote depth of 2. + + A generating agent MUST NOT create this situation; a receiving agent + SHOULD handle it by giving preference to the quote depth. + +4.6. Digital Signatures and Encryption + + If a message is digitally signed or encrypted it is important that + cryptographic processing use the same text for signature verification + and/or decryption as was used for signature generation and/or + encryption. Since the use of format=flowed allows text to be altered + (by adding or removing line breaks and trailing spaces) between + composition and transmission, and between reception and display, + interoperability problems or security vulnerabilities may arise if + originator and recipient do not both use the on-the-wire format for + cryptographic processing. + + The implications of the interaction between format=flowed and any + specific cryptographic process depend on the details of the + cryptographic processing and should be understood before using + format=flowed in conjunction with signed and/or encrypted messages. + + Note that [OpenPGP] specifies (in Section 7.1) that "any trailing + whitespace (spaces, and tabs, 0x09) at the end of any line is ignored + when the cleartext signature is calculated." + + + + + + +Gellens Standards Track [Page 11] + +RFC 3676 Text/Plain Format and DelSp Parameters February 2004 + + + Thus it would be possible to add, in transit, a format=flowed header + to a regular, format=fixed vanilla PGP (not [OpenPGP-MIME]) signed + message and add arbitrary trailing space characters without this + addition being detected. This would change the rendering of the + article by a client which supported format=flowed. + + Therefore, the use of [OpenPGP] with format=flowed messages is + strongly discouraged. [OpenPGP-MIME] is recommended instead. + +4.7. Examples + + The following example contains three paragraphs: + + `Take some more tea,' the March Hare said to Alice, very + earnestly. + + `I've had nothing yet,' Alice replied in an offended tone, `so I + can't take more.' + + `You mean you can't take LESS,' said the Hatter: `it's very easy + to take MORE than nothing.' + + This could be encoded as follows (using '*' to indicate a soft line + break, that is, SP CRLF sequence, and '#' to indicate a hard line + break, that is, CRLF): + + `Take some more tea,' the March Hare said to Alice, very* + earnestly.# + # + `I've had nothing yet,' Alice replied in an offended tone, `so* + I can't take more.'# + # + `You mean you can't take LESS,' said the Hatter: `it's very* + easy to take MORE than nothing.'# + + To show an example of quoting, here we have the same exchange, + presented as a series of direct quotes: + + >>>Take some more tea.# + >>I've had nothing yet, so I can't take more.# + >You mean you can't take LESS, it's very easy to take* + >MORE than nothing.# + +5. Interoperability + + Because flowed lines are all-but-indistinguishable from fixed lines, + software which does not recognize Format=Flowed treats flowed lines + as normal Text/Plain (which is what they are). Thus, Format=Flowed + + + +Gellens Standards Track [Page 12] + +RFC 3676 Text/Plain Format and DelSp Parameters February 2004 + + + interoperates with older clients, although flowed lines will have + trailing white space inserted. + + If a space-stuffed message is received by an agent which handles + Format=Flowed, the space-stuffing is reversed and thus the message + appears unchanged. An agent which is not aware of Format=Flowed will + of course not undo any space-stuffing; thus Format=Flowed messages + may appear with a leading space on some lines (those which start with + a space, ">" which is not a quote indicator, or "From "). Since + lines which require space-stuffing rarely occur, and the aesthetic + consequences of unreversed space-stuffing are minimal, this is not + expected to be a significant problem. + + If some lines begin with one or more spaces, the generating agent MAY + space-stuff all lines, to maintain the relative indentation of the + lines when viewed by clients which are not aware of Format=Flowed. + + Messages generated with DelSp=yes and received by clients which are + aware of Format=Flowed but are not aware of the DelSp parameter will + have an extra space remaining after removal of soft line breaks. + Thus, when generating text in languages/coded character sets in which + spaces are common, the generating agent MAY always use the DelSp=no + method. + + Hand-aligned text, such as ASCII tables or art, source code, etc., + SHOULD be sent as fixed, not flowed lines. + +6. ABNF + + The constructs used in Text/Plain; Format=Flowed body parts are + described using Augmented Backus-Naur Form [ABNF], including the core + rules defined in Appendix A. + + Note that the SP (space) and ">" characters are encoded according to + the charset parameter. + +flowed-body = *( paragraph / fixed-line / sig-sep ) +paragraph = 1*flowed-line fixed-line + ; all lines in paragraph MUST be unquoted or + ; have same quote depth +flowed-line = ( flowed-line-qt / flowed-line-unqt ) flow CRLF +flowed-line-qt = quote ( ( stuffing stuffed-flowed ) / + unstuffed-flowed ) +flowed-line-unqt = ( stuffing stuffed-flowed ) / unstuffed-flowed +stuffed-flowed = *text-char +unstuffed-flowed = non-sp-quote *text-char +fixed-line = fixed-line-qt / fixed-line-unqt +fixed-line-qt = quote ( ( stuffing stuffed-fixed ) / + + + +Gellens Standards Track [Page 13] + +RFC 3676 Text/Plain Format and DelSp Parameters February 2004 + + + unstuffed-fixed ) CRLF +fixed-line-unqt = ( stuffed-fixed / unstuffed-fixed ) CRLF +stuffed-fixed = *text-char non-sp +unstuffed-fixed = non-sp-quote [ *text-char non-sp ] +sig-sep = [ quote [stuffing] ] "--" SP CRLF +quote-mark = ">" +quote = 1*quote-mark +stuffing = SP ; space-stuffed, added on generation if + ; needed, deleted on reception +flow = SP ; space before CRLF indicates flowed line, + ; if DelSp=yes, space was added on generation + ; and is deleted on reception +non-sp-quote = < any character except NUL, CR, LF, SP, quote-mark > +non-sp = non-sp-quote / quote-mark +text-char = non-sp / SP + + That is, a Format=Flowed message body consists of any number of + paragraphs and/or fixed lines and/or signature separator lines; + paragraphs need at least one flowed line and are terminated by a + fixed line; the fixed line terminating the paragraph is part of the + paragraph. (There are some exceptions to this described in the + text.) + + Without at least one flowed line, there is a series of fixed lines, + each independent. There is no paragraph. + + With at least one flowed line, there is a paragraph, and the received + lines can be reformed and flowed to fit the display window size. + This can only be done if the lines are part of a logical grouping, + the paragraph. + + Note that the definitions of flowed-line and sig-sep are potentially + ambiguous: a signature separator line matches both, but is treated as + a signature separator line and not a flowed line. + +7. Failure Modes + +7.1. Trailing White Space Corruption + + There are systems in existence which alter trailing whitespace on + messages which pass through them. Such systems may strip, or in + rarer cases, add trailing whitespace, in violation of RFC 2821 [SMTP] + Section 4.5.2. + + Stripping trailing whitespace has the effect of converting flowed + lines to fixed lines, which results in a message no worse than if + Format=Flowed had not been used. + + + + +Gellens Standards Track [Page 14] + +RFC 3676 Text/Plain Format and DelSp Parameters February 2004 + + + Adding trailing whitespace to a Format=Flowed message may result in a + malformed display or reply. + + Since most systems which add trailing white space do so to create a + line which fills an internal record format, the result is almost + always a line which contains an even number of characters (counting + the added trailing white space). + + One possible avoidance, therefore, would be to define Format=Flowed + lines to use either one or two trailing space characters to indicate + a flowed line, such that the total line length is odd. However, + considering the scarcity of such systems today, it is not worth the + added complexity. + +8. Security Considerations + + Any security considerations which apply to Text/Plain also apply to + Text/Plain with Format=Flowed. + + Section 4.6 discusses the interaction between Format=Flowed and + digital signatures or encryption. + +9. IANA Considerations + + IANA has added a reference to this specification in the Text/Plain + Media Type registration. + +10. Internationalization Considerations + + The line wrap and quoting specifications of Format=Flowed may not be + suitable for certain charsets, such as for Arabic and Hebrew + characters that read from right to left. Care needs to be taken in + applying format=flowed in these cases, as format=fixed combined with + [quoted-printable] encoding may be more suitable. + + The DelSp parameter was added specifically to permit Format=Flowed to + be used with languages/coded character sets in which the ASCII space + character is rarely used, or not used at all. + +11. Acknowledgments + + The DelSp parameter was developed during a series of discussions + among a number of people, including Harald Alvestrand, Grant Baillie, + Ian Bell, Steve Dorner, Patrik Faltstrom, Eric Fischer, Ned Freed, + Alexey Melnikov, John Myers, and Pete Resnick. + + + + + + +Gellens Standards Track [Page 15] + +RFC 3676 Text/Plain Format and DelSp Parameters February 2004 + + + Corrections and clarifications to RFC 2646 and early versions of this + document were pointed out by several people, including Adam Costello, + Jutta Degener, Tony Hansen, Simon Josefsson, Dan Kohn, Ragho + Mahalingam, Keith Moore, Greg Troxel, and Dan Wing. + + I'm told that NeXT's mail application used a very similar mechanism + (without support for non-Western languages) in 1992. + +12. Normative References + + [ABNF] Crocker, D., Ed. and P. Overell, "Augmented BNF + for Syntax Specifications: ABNF", RFC 2234, + November 1997. + + [KEYWORDS] Bradner, S., "Key words for use in RFCs to + Indicate Requirement Levels", BCP 14, RFC 2119, + March 1997. + + [MIME-IMT] Freed, N. and N. Borenstein, "Multipurpose + Internet Mail Extensions (MIME) Part Two: Media + Types", RFC 2046, November 1996. + + [Quoted-Printable] Freed, N. and N. Borenstein, "Multipurpose + Internet Mail Extensions (MIME) Part One: Format + of Internet Message Bodies", RFC 2045, November + 1996. + +13. Informative References + + [Annex-14] Unicode Standard Annex #14, "Line Breaking + Properties" + + + [MSG-FMT] Resnick, P., Ed., "Internet Message Format", RFC + 2822, April 2001. + + [OpenPGP] Callas, J., Donnerhacke, L., Finney, H. and R. + Thayer, "OpenPGP Message Format", RFC 2440, + November 1998. + + [OpenPGP-MIME] Elkins, M., "MIME Security with Pretty Good + Privacy (PGP)", RFC 2015, October 1996. + + Elkins, M., Del Torto, D., Levien, R. and J. + Roessler, "MIME Security with OpenPGP", RFC 3156, + August 2001. + + + + + +Gellens Standards Track [Page 16] + +RFC 3676 Text/Plain Format and DelSp Parameters February 2004 + + + [Rich] Resnick, P. and A. Walker, "The text/enriched MIME + Content-type", RFC 1896, February 1996. + + [SMTP] Klensin, J., Ed., "Simple Mail Transfer Protocol", + RFC 2821, April 2001. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Gellens Standards Track [Page 17] + +RFC 3676 Text/Plain Format and DelSp Parameters February 2004 + + +Appendix A: Changes from RFC 2646 + + Substantive: + + o Added DelSp parameter to handle languages and coded character sets + in which space is less common or not used. + o Updated text on generating and interpreting to accommodate the + DelSp parameter. + o Changed the limits of 79 or 80 to be 78 in conformance with RFC + 2822. + o Added text on generating to clarify that the 78-character limit + includes trailing white space and stuffing. + o Changed sig-sep in ABNF to allow stuffing. + o Changed fixed-line to allow empty lines in ABNF. + o Added explanatory text following ABNF. + o Moved text from Abstract to new Introduction; rewrote Abstract. + o Moved interoperability text to new section, and updated. + o Clarified Security Considerations. + o Text on digital signatures now discusses that OpenPGP ignores + trailing white space. + o Mention Unicode Annex 14. + o Added mention of quoting to Abstract and Introduction. + o Deleted line analysis table. + o Added recommendations for OpenPGP and OpenPGP-MIME. + o Rewrote ABNF rules to remove most ambiguity and note remaining + case. + o Added note that c-t-e is irrelevant to flowed text processing. + o Added text indicating that end of data terminates a paragraph. + o Moved sig-sep out of fixed-line ABNF. + o Changed some SHOULDs to MUSTs (space-stuffing, quoted paragraphs). + o Added note to ABNF that space and ">" are encoded according to + charset. + o Mentioned exceptions in section on interpreting. + o Clarified and made consistent treatment of signature separator + lines. + + Editorial: + + o Added mention of NeXT's mail application to Acknowledgments. + o Updated Acknowledgments. + o Updated [SMTP] reference to 2821. + o Added Notices. + o Split References into Normative and Informative. + o Improved text wording in some areas. + o Standardize on "quote depth", not "quoting depth". + o Moved section on interpreting before section on generating. + o Reworded non-normative "should"s. + o Noted meaning of "paragraph". + + + +Gellens Standards Track [Page 18] + +RFC 3676 Text/Plain Format and DelSp Parameters February 2004 + + + The DelSp parameter was added specifically to permit Format=Flowed to + be used with languages/coded character sets in which the ASCII space + character is rarely used, or not used at all. The DelSp mechanism + was selected despite having been initially rejected as too much of a + kludge, because among the many different techniques proposed, it + allows for maximum interoperability among clients which support + neither this specification nor RFC 2646, those which do support RFC + 2646 but not this specification, and those that do support this + specification; this set is multiplied by those that handle + languages/coded character sets in which spaces are common, and in + which they are uncommon or not used. + +Author's Address + + Randall Gellens + QUALCOMM Incorporated + 5775 Morehouse Drive + San Diego, CA 92121 + USA + + Phone: +1 858 651 5115 + EMail: randy@qualcomm.com + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Gellens Standards Track [Page 19] + +RFC 3676 Text/Plain Format and DelSp Parameters February 2004 + + +Full Copyright Statement + + Copyright (C) The Internet Society (2004). This document is subject + to the rights, licenses and restrictions contained in BCP 78 and + except as set forth therein, the authors retain all their rights. + + This document and the information contained herein are provided on an + "AS IS" basis and THE CONTRIBUTOR, THE ORGANIZATION HE/SHE + REPRESENTS OR IS SPONSORED BY (IF ANY), THE INTERNET SOCIETY AND THE + INTERNET ENGINEERING TASK FORCE DISCLAIM ALL WARRANTIES, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF + THE INFORMATION HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED + WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + +Intellectual Property + + The IETF takes no position regarding the validity or scope of any + Intellectual Property Rights or other rights that might be claimed + to pertain to the implementation or use of the technology + described in this document or the extent to which any license + under such rights might or might not be available; nor does it + represent that it has made any independent effort to identify any + such rights. Information on the procedures with respect to + rights in RFC documents can be found in BCP 78 and BCP 79. + + Copies of IPR disclosures made to the IETF Secretariat and any + assurances of licenses to be made available, or the result of an + attempt made to obtain a general license or permission for the use + of such proprietary rights by implementers or users of this + specification can be obtained from the IETF on-line IPR repository + at http://www.ietf.org/ipr. + + The IETF invites any interested party to bring to its attention + any copyrights, patents or patent applications, or other + proprietary rights that may cover technology that may be required + to implement this standard. Please address the information to the + IETF at ietf-ipr@ietf.org. + +Acknowledgement + + Funding for the RFC Editor function is currently provided by the + Internet Society. + + + + + + + + + +Gellens Standards Track [Page 20] + diff --git a/vendor/swiftmailer/swiftmailer/notes/rfc/rfc4505.txt b/vendor/swiftmailer/swiftmailer/notes/rfc/rfc4505.txt new file mode 100755 index 0000000..6b8a4a1 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/notes/rfc/rfc4505.txt @@ -0,0 +1,507 @@ + + + + + + +Network Working Group K. Zeilenga, Ed. +Request for Comments: 4505 OpenLDAP Foundation +Obsoletes: 2245 June 2006 +Category: Standards Track + + + Anonymous Simple Authentication and Security Layer (SASL) Mechanism + +Status of This Memo + + This document specifies an Internet standards track protocol for the + Internet community, and requests discussion and suggestions for + improvements. Please refer to the current edition of the "Internet + Official Protocol Standards" (STD 1) for the standardization state + and status of this protocol. Distribution of this memo is unlimited. + +Copyright Notice + + Copyright (C) The Internet Society (2006). + +Abstract + + On the Internet, it is common practice to permit anonymous access to + various services. Traditionally, this has been done with a plain- + text password mechanism using "anonymous" as the user name and using + optional trace information, such as an email address, as the + password. As plain-text login commands are not permitted in new IETF + protocols, a new way to provide anonymous login is needed within the + context of the Simple Authentication and Security Layer (SASL) + framework. + +1. Introduction + + This document defines an anonymous mechanism for the Simple + Authentication and Security Layer ([SASL]) framework. The name + associated with this mechanism is "ANONYMOUS". + + Unlike many other SASL mechanisms, whose purpose is to authenticate + and identify the user to a server, the purpose of this SASL mechanism + is to allow the user to gain access to services or resources without + requiring the user to establish or otherwise disclose their identity + to the server. That is, this mechanism provides an anonymous login + method. + + This mechanism does not provide a security layer. + + This document replaces RFC 2245. Changes since RFC 2245 are detailed + in Appendix A. + + + +Zeilenga Standards Track [Page 1] + +RFC 4505 Anonymous SASL Mechanism June 2006 + + +2. The Anonymous Mechanism + + The mechanism consists of a single message from the client to the + server. The client may include in this message trace information in + the form of a string of [UTF-8]-encoded [Unicode] characters prepared + in accordance with [StringPrep] and the "trace" stringprep profile + defined in Section 3 of this document. The trace information, which + has no semantical value, should take one of two forms: an Internet + email address, or an opaque string that does not contain the '@' + (U+0040) character and that can be interpreted by the system + administrator of the client's domain. For privacy reasons, an + Internet email address or other information identifying the user + should only be used with permission from the user. + + A server that permits anonymous access will announce support for the + ANONYMOUS mechanism and allow anyone to log in using that mechanism, + usually with restricted access. + + A formal grammar for the client message using Augmented BNF [ABNF] is + provided below as a tool for understanding this technical + specification. + + message = [ email / token ] + ;; to be prepared in accordance with Section 3 + + UTF1 = %x00-3F / %x41-7F ;; less '@' (U+0040) + UTF2 = %xC2-DF UTF0 + UTF3 = %xE0 %xA0-BF UTF0 / %xE1-EC 2(UTF0) / + %xED %x80-9F UTF0 / %xEE-EF 2(UTF0) + UTF4 = %xF0 %x90-BF 2(UTF0) / %xF1-F3 3(UTF0) / + %xF4 %x80-8F 2(UTF0) + UTF0 = %x80-BF + + TCHAR = UTF1 / UTF2 / UTF3 / UTF4 + ;; any UTF-8 encoded Unicode character + ;; except '@' (U+0040) + + email = addr-spec + ;; as defined in [IMAIL] + + token = 1*255TCHAR + + Note to implementors: + The production is restricted to 255 UTF-8-encoded Unicode + characters. As the encoding of a characters uses a sequence of 1 + to 4 octets, a token may be as long as 1020 octets. + + + + + +Zeilenga Standards Track [Page 2] + +RFC 4505 Anonymous SASL Mechanism June 2006 + + +3. The "trace" Profile of "Stringprep" + + This section defines the "trace" profile of [StringPrep]. This + profile is designed for use with the SASL ANONYMOUS Mechanism. + Specifically, the client is to prepare the production in + accordance with this profile. + + The character repertoire of this profile is Unicode 3.2 [Unicode]. + + No mapping is required by this profile. + + No Unicode normalization is required by this profile. + + The list of unassigned code points for this profile is that provided + in Appendix A of [StringPrep]. Unassigned code points are not + prohibited. + + Characters from the following tables of [StringPrep] are prohibited: + + - C.2.1 (ASCII control characters) + - C.2.2 (Non-ASCII control characters) + - C.3 (Private use characters) + - C.4 (Non-character code points) + - C.5 (Surrogate codes) + - C.6 (Inappropriate for plain text) + - C.8 (Change display properties are deprecated) + - C.9 (Tagging characters) + + No additional characters are prohibited. + + This profile requires bidirectional character checking per Section 6 + of [StringPrep]. + +4. Example + + Here is a sample ANONYMOUS login between an IMAP client and server. + In this example, "C:" and "S:" indicate lines sent by the client and + server, respectively. If such lines are wrapped without a new "C:" + or "S:" label, then the wrapping is for editorial clarity and is not + part of the command. + + Note that this example uses the IMAP profile [IMAP4] of SASL. The + base64 encoding of challenges and responses as well as the "+ " + preceding the responses are part of the IMAP4 profile, not part of + SASL itself. Additionally, protocols with SASL profiles permitting + an initial client response will be able to avoid the extra round trip + below (the server response with an empty "+ "). + + + + +Zeilenga Standards Track [Page 3] + +RFC 4505 Anonymous SASL Mechanism June 2006 + + + In this example, the trace information is "sirhc". + + S: * OK IMAP4 server ready + C: A001 CAPABILITY + S: * CAPABILITY IMAP4 IMAP4rev1 AUTH=DIGEST-MD5 AUTH=ANONYMOUS + S: A001 OK done + C: A002 AUTHENTICATE ANONYMOUS + S: + + C: c2lyaGM= + S: A003 OK Welcome, trace information has been logged. + +5. Security Considerations + + The ANONYMOUS mechanism grants access to services and/or resources by + anyone. For this reason, it should be disabled by default so that + the administrator can make an explicit decision to enable it. + + If the anonymous user has any write privileges, a denial-of-service + attack is possible by filling up all available space. This can be + prevented by disabling all write access by anonymous users. + + If anonymous users have read and write access to the same area, the + server can be used as a communication mechanism to exchange + information anonymously. Servers that accept anonymous submissions + should implement the common "drop box" model, which forbids anonymous + read access to the area where anonymous submissions are accepted. + + If the anonymous user can run many expensive operations (e.g., an + IMAP SEARCH BODY command), this could enable a denial-of-service + attack. Servers are encouraged to reduce the priority of anonymous + users or limit their resource usage. + + While servers may impose a limit on the number of anonymous users, + note that such limits enable denial-of-service attacks and should be + used with caution. + + The trace information is not authenticated, so it can be falsified. + This can be used as an attempt to get someone else in trouble for + access to questionable information. Administrators investigating + abuse need to realize that this trace information may be falsified. + + A client that uses the user's correct email address as trace + information without explicit permission may violate that user's + privacy. Anyone who accesses an anonymous archive on a sensitive + subject (e.g., sexual abuse) likely has strong privacy needs. + Clients should not send the email address without the explicit + permission of the user and should offer the option of supplying no + trace information, thus only exposing the source IP address and time. + + + +Zeilenga Standards Track [Page 4] + +RFC 4505 Anonymous SASL Mechanism June 2006 + + + Anonymous proxy servers could enhance this privacy but would have to + consider the resulting potential denial-of-service attacks. + + Anonymous connections are susceptible to man-in-the-middle attacks + that view or alter the data transferred. Clients and servers are + encouraged to support external data security services. + + Protocols that fail to require an explicit anonymous login are more + susceptible to break-ins given certain common implementation + techniques. Specifically, Unix servers that offer user login may + initially start up as root and switch to the appropriate user id + after an explicit login command. Normally, such servers refuse all + data access commands prior to explicit login and may enter a + restricted security environment (e.g., the Unix chroot(2) function) + for anonymous users. If anonymous access is not explicitly + requested, the entire data access machinery is exposed to external + security attacks without the chance for explicit protective measures. + Protocols that offer restricted data access should not allow + anonymous data access without an explicit login step. + + General [SASL] security considerations apply to this mechanism. + + [StringPrep] security considerations and [Unicode] security + considerations discussed in [StringPrep] apply to this mechanism. + [UTF-8] security considerations also apply. + +6. IANA Considerations + + The SASL Mechanism registry [IANA-SASL] entry for the ANONYMOUS + mechanism has been updated by the IANA to reflect that this document + now provides its technical specification. + + To: iana@iana.org + Subject: Updated Registration of SASL mechanism ANONYMOUS + + SASL mechanism name: ANONYMOUS + Security considerations: See RFC 4505. + Published specification (optional, recommended): RFC 4505 + Person & email address to contact for further information: + Kurt Zeilenga + Chris Newman + Intended usage: COMMON + Author/Change controller: IESG + Note: Updates existing entry for ANONYMOUS + + + + + + + +Zeilenga Standards Track [Page 5] + +RFC 4505 Anonymous SASL Mechanism June 2006 + + + The [StringPrep] profile "trace", first defined in this RFC, has been + registered: + + To: iana@iana.org + Subject: Initial Registration of Stringprep "trace" profile + + Stringprep profile: trace + Published specification: RFC 4505 + Person & email address to contact for further information: + Kurt Zeilenga + +7. Acknowledgement + + This document is a revision of RFC 2245 by Chris Newman. Portions of + the grammar defined in Section 1 were borrowed from RFC 3629 by + Francois Yergeau. + + This document is a product of the IETF SASL WG. + +8. Normative References + + [ABNF] Crocker, D. and P. Overell, "Augmented BNF for Syntax + Specifications: ABNF", RFC 4234, October 2005. + + [IMAIL] Resnick, P., "Internet Message Format", RFC 2822, April + 2001. + + [SASL] Melnikov, A., Ed. and K. Zeilenga, Ed., "Simple + Authentication and Security Layer (SASL)", RFC 4422, + June 2006. + + [StringPrep] Hoffman, P. and M. Blanchet, "Preparation of + Internationalized Strings ('stringprep')", RFC 3454, + December 2002. + + [Unicode] The Unicode Consortium, "The Unicode Standard, Version + 3.2.0" is defined by "The Unicode Standard, Version 3.0" + (Reading, MA, Addison-Wesley, 2000. ISBN 0-201-61633-5), + as amended by the "Unicode Standard Annex #27: Unicode + 3.1" (http://www.unicode.org/reports/tr27/) and by the + "Unicode Standard Annex #28: Unicode 3.2" + (http://www.unicode.org/reports/tr28/). + + [UTF-8] Yergeau, F., "UTF-8, a transformation format of ISO + 10646", RFC 3629 (also STD 63), November 2003. + + + + + + +Zeilenga Standards Track [Page 6] + +RFC 4505 Anonymous SASL Mechanism June 2006 + + +9. Informative References + + [IMAP4] Crispin, M., "INTERNET MESSAGE ACCESS PROTOCOL - VERSION + 4rev1", RFC 3501, March 2003. + + [IANA-SASL] IANA, "SIMPLE AUTHENTICATION AND SECURITY LAYER (SASL) + MECHANISMS", . + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Zeilenga Standards Track [Page 7] + +RFC 4505 Anonymous SASL Mechanism June 2006 + + +Appendix A. Changes since RFC 2245 + + This appendix is non-normative. + + RFC 2245 allows the client to include optional trace information in + the form of a human readable string. RFC 2245 restricted this string + to US-ASCII. As the Internet is international, this document uses a + string restricted to UTF-8 encoded Unicode characters. A + "stringprep" profile is defined to precisely define which Unicode + characters are allowed in this string. While the string remains + restricted to 255 characters, the encoded length of each character + may now range from 1 to 4 octets. + + Additionally, a number of editorial changes were made. + +Editor's Address + + Kurt D. Zeilenga + OpenLDAP Foundation + + EMail: Kurt@OpenLDAP.org + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Zeilenga Standards Track [Page 8] + +RFC 4505 Anonymous SASL Mechanism June 2006 + + +Full Copyright Statement + + Copyright (C) The Internet Society (2006). + + This document is subject to the rights, licenses and restrictions + contained in BCP 78, and except as set forth therein, the authors + retain all their rights. + + This document and the information contained herein are provided on an + "AS IS" basis and THE CONTRIBUTOR, THE ORGANIZATION HE/SHE REPRESENTS + OR IS SPONSORED BY (IF ANY), THE INTERNET SOCIETY AND THE INTERNET + ENGINEERING TASK FORCE DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, + INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE + INFORMATION HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED + WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + +Intellectual Property + + The IETF takes no position regarding the validity or scope of any + Intellectual Property Rights or other rights that might be claimed to + pertain to the implementation or use of the technology described in + this document or the extent to which any license under such rights + might or might not be available; nor does it represent that it has + made any independent effort to identify any such rights. Information + on the procedures with respect to rights in RFC documents can be + found in BCP 78 and BCP 79. + + Copies of IPR disclosures made to the IETF Secretariat and any + assurances of licenses to be made available, or the result of an + attempt made to obtain a general license or permission for the use of + such proprietary rights by implementers or users of this + specification can be obtained from the IETF on-line IPR repository at + http://www.ietf.org/ipr. + + The IETF invites any interested party to bring to its attention any + copyrights, patents or patent applications, or other proprietary + rights that may cover technology that may be required to implement + this standard. Please address the information to the IETF at + ietf-ipr@ietf.org. + +Acknowledgement + + Funding for the RFC Editor function is provided by the IETF + Administrative Support Activity (IASA). + + + + + + + +Zeilenga Standards Track [Page 9] + diff --git a/vendor/swiftmailer/swiftmailer/notes/rfc/rfc4616.txt b/vendor/swiftmailer/swiftmailer/notes/rfc/rfc4616.txt new file mode 100755 index 0000000..991189d --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/notes/rfc/rfc4616.txt @@ -0,0 +1,619 @@ + + + + + + +Network Working Group K. Zeilenga, Ed. +Request for Comments: 4616 OpenLDAP Foundation +Updates: 2595 August 2006 +Category: Standards Track + + + The PLAIN Simple Authentication and Security Layer (SASL) Mechanism + +Status of This Memo + + This document specifies an Internet standards track protocol for the + Internet community, and requests discussion and suggestions for + improvements. Please refer to the current edition of the "Internet + Official Protocol Standards" (STD 1) for the standardization state + and status of this protocol. Distribution of this memo is unlimited. + +Copyright Notice + + Copyright (C) The Internet Society (2006). + +Abstract + + This document defines a simple clear-text user/password Simple + Authentication and Security Layer (SASL) mechanism called the PLAIN + mechanism. The PLAIN mechanism is intended to be used, in + combination with data confidentiality services provided by a lower + layer, in protocols that lack a simple password authentication + command. + + + + + + + + + + + + + + + + + + + + + + + +Zeilenga Standards Track [Page 1] + +RFC 4616 The PLAIN SASL Mechanism August 2006 + + +1. Introduction + + Clear-text, multiple-use passwords are simple, interoperate with + almost all existing operating system authentication databases, and + are useful for a smooth transition to a more secure password-based + authentication mechanism. The drawback is that they are unacceptable + for use over network connections where data confidentiality is not + ensured. + + This document defines the PLAIN Simple Authentication and Security + Layer ([SASL]) mechanism for use in protocols with no clear-text + login command (e.g., [ACAP] or [SMTP-AUTH]). This document updates + RFC 2595, replacing Section 6. Changes since RFC 2595 are detailed + in Appendix A. + + The name associated with this mechanism is "PLAIN". + + The PLAIN SASL mechanism does not provide a security layer. + + The PLAIN mechanism should not be used without adequate data security + protection as this mechanism affords no integrity or confidentiality + protections itself. The mechanism is intended to be used with data + security protections provided by application-layer protocol, + generally through its use of Transport Layer Security ([TLS]) + services. + + By default, implementations SHOULD advertise and make use of the + PLAIN mechanism only when adequate data security services are in + place. Specifications for IETF protocols that indicate that this + mechanism is an applicable authentication mechanism MUST mandate that + implementations support an strong data security service, such as TLS. + + The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", + "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this + document are to be interpreted as described in [Keywords]. + +2. PLAIN SASL Mechanism + + The mechanism consists of a single message, a string of [UTF-8] + encoded [Unicode] characters, from the client to the server. The + client presents the authorization identity (identity to act as), + followed by a NUL (U+0000) character, followed by the authentication + identity (identity whose password will be used), followed by a NUL + (U+0000) character, followed by the clear-text password. As with + other SASL mechanisms, the client does not provide an authorization + identity when it wishes the server to derive an identity from the + credentials and use that as the authorization identity. + + + + +Zeilenga Standards Track [Page 2] + +RFC 4616 The PLAIN SASL Mechanism August 2006 + + + The formal grammar for the client message using Augmented BNF [ABNF] + follows. + + message = [authzid] UTF8NUL authcid UTF8NUL passwd + authcid = 1*SAFE ; MUST accept up to 255 octets + authzid = 1*SAFE ; MUST accept up to 255 octets + passwd = 1*SAFE ; MUST accept up to 255 octets + UTF8NUL = %x00 ; UTF-8 encoded NUL character + + SAFE = UTF1 / UTF2 / UTF3 / UTF4 + ;; any UTF-8 encoded Unicode character except NUL + + UTF1 = %x01-7F ;; except NUL + UTF2 = %xC2-DF UTF0 + UTF3 = %xE0 %xA0-BF UTF0 / %xE1-EC 2(UTF0) / + %xED %x80-9F UTF0 / %xEE-EF 2(UTF0) + UTF4 = %xF0 %x90-BF 2(UTF0) / %xF1-F3 3(UTF0) / + %xF4 %x80-8F 2(UTF0) + UTF0 = %x80-BF + + The authorization identity (authzid), authentication identity + (authcid), password (passwd), and NUL character deliminators SHALL be + transferred as [UTF-8] encoded strings of [Unicode] characters. As + the NUL (U+0000) character is used as a deliminator, the NUL (U+0000) + character MUST NOT appear in authzid, authcid, or passwd productions. + + The form of the authzid production is specific to the application- + level protocol's SASL profile [SASL]. The authcid and passwd + productions are form-free. Use of non-visible characters or + characters that a user may be unable to enter on some keyboards is + discouraged. + + Servers MUST be capable of accepting authzid, authcid, and passwd + productions up to and including 255 octets. It is noted that the + UTF-8 encoding of a Unicode character may be as long as 4 octets. + + Upon receipt of the message, the server will verify the presented (in + the message) authentication identity (authcid) and password (passwd) + with the system authentication database, and it will verify that the + authentication credentials permit the client to act as the (presented + or derived) authorization identity (authzid). If both steps succeed, + the user is authenticated. + + The presented authentication identity and password strings, as well + as the database authentication identity and password strings, are to + be prepared before being used in the verification process. The + [SASLPrep] profile of the [StringPrep] algorithm is the RECOMMENDED + preparation algorithm. The SASLprep preparation algorithm is + + + +Zeilenga Standards Track [Page 3] + +RFC 4616 The PLAIN SASL Mechanism August 2006 + + + recommended to improve the likelihood that comparisons behave in an + expected manner. The SASLprep preparation algorithm is not mandatory + so as to allow the server to employ other preparation algorithms + (including none) when appropriate. For instance, use of a different + preparation algorithm may be necessary for the server to interoperate + with an external system. + + When preparing the presented strings using [SASLPrep], the presented + strings are to be treated as "query" strings (Section 7 of + [StringPrep]) and hence unassigned code points are allowed to appear + in their prepared output. When preparing the database strings using + [SASLPrep], the database strings are to be treated as "stored" + strings (Section 7 of [StringPrep]) and hence unassigned code points + are prohibited from appearing in their prepared output. + + Regardless of the preparation algorithm used, if the output of a + non-invertible function (e.g., hash) of the expected string is + stored, the string MUST be prepared before input to that function. + + Regardless of the preparation algorithm used, if preparation fails or + results in an empty string, verification SHALL fail. + + When no authorization identity is provided, the server derives an + authorization identity from the prepared representation of the + provided authentication identity string. This ensures that the + derivation of different representations of the authentication + identity produces the same authorization identity. + + The server MAY use the credentials to initialize any new + authentication database, such as one suitable for [CRAM-MD5] or + [DIGEST-MD5]. + +3. Pseudo-Code + + This section provides pseudo-code illustrating the verification + process (using hashed passwords and the SASLprep preparation + function) discussed above. This section is not definitive. + + boolean Verify(string authzid, string authcid, string passwd) { + string pAuthcid = SASLprep(authcid, true); # prepare authcid + string pPasswd = SASLprep(passwd, true); # prepare passwd + if (pAuthcid == NULL || pPasswd == NULL) { + return false; # preparation failed + } + if (pAuthcid == "" || pPasswd == "") { + return false; # empty prepared string + } + + + + +Zeilenga Standards Track [Page 4] + +RFC 4616 The PLAIN SASL Mechanism August 2006 + + + storedHash = FetchPasswordHash(pAuthcid); + if (storedHash == NULL || storedHash == "") { + return false; # error or unknown authcid + } + + if (!Compare(storedHash, Hash(pPasswd))) { + return false; # incorrect password + } + + if (authzid == NULL ) { + authzid = DeriveAuthzid(pAuthcid); + if (authzid == NULL || authzid == "") { + return false; # could not derive authzid + } + } + + if (!Authorize(pAuthcid, authzid)) { + return false; # not authorized + } + + return true; + } + + The second parameter of the SASLprep function, when true, indicates + that unassigned code points are allowed in the input. When the + SASLprep function is called to prepare the password prior to + computing the stored hash, the second parameter would be false. + + The second parameter provided to the Authorize function is not + prepared by this code. The application-level SASL profile should be + consulted to determine what, if any, preparation is necessary. + + Note that the DeriveAuthzid and Authorize functions (whether + implemented as one function or two, whether designed in a manner in + which these functions or whether the mechanism implementation can be + reused elsewhere) require knowledge and understanding of mechanism + and the application-level protocol specification and/or + implementation details to implement. + + Note that the Authorize function outcome is clearly dependent on + details of the local authorization model and policy. Both functions + may be dependent on other factors as well. + + + + + + + + + +Zeilenga Standards Track [Page 5] + +RFC 4616 The PLAIN SASL Mechanism August 2006 + + +4. Examples + + This section provides examples of PLAIN authentication exchanges. + The examples are intended to help the readers understand the above + text. The examples are not definitive. + + "C:" and "S:" indicate lines sent by the client and server, + respectively. "" represents a single NUL (U+0000) character. + The Application Configuration Access Protocol ([ACAP]) is used in the + examples. + + The first example shows how the PLAIN mechanism might be used for + user authentication. + + S: * ACAP (SASL "CRAM-MD5") (STARTTLS) + C: a001 STARTTLS + S: a001 OK "Begin TLS negotiation now" + + S: * ACAP (SASL "CRAM-MD5" "PLAIN") + C: a002 AUTHENTICATE "PLAIN" + S: + "" + C: {21} + C: timtanstaaftanstaaf + S: a002 OK "Authenticated" + + The second example shows how the PLAIN mechanism might be used to + attempt to assume the identity of another user. In this example, the + server rejects the request. Also, this example makes use of the + protocol optional initial response capability to eliminate a round- + trip. + + S: * ACAP (SASL "CRAM-MD5") (STARTTLS) + C: a001 STARTTLS + S: a001 OK "Begin TLS negotiation now" + + S: * ACAP (SASL "CRAM-MD5" "PLAIN") + C: a002 AUTHENTICATE "PLAIN" {20+} + C: UrselKurtxipj3plmq + S: a002 NO "Not authorized to requested authorization identity" + +5. Security Considerations + + As the PLAIN mechanism itself provided no integrity or + confidentiality protections, it should not be used without adequate + external data security protection, such as TLS services provided by + many application-layer protocols. By default, implementations SHOULD + NOT advertise and SHOULD NOT make use of the PLAIN mechanism unless + adequate data security services are in place. + + + +Zeilenga Standards Track [Page 6] + +RFC 4616 The PLAIN SASL Mechanism August 2006 + + + When the PLAIN mechanism is used, the server gains the ability to + impersonate the user to all services with the same password + regardless of any encryption provided by TLS or other confidentiality + protection mechanisms. Whereas many other authentication mechanisms + have similar weaknesses, stronger SASL mechanisms address this issue. + Clients are encouraged to have an operational mode where all + mechanisms that are likely to reveal the user's password to the + server are disabled. + + General [SASL] security considerations apply to this mechanism. + + Unicode, [UTF-8], and [StringPrep] security considerations also + apply. + +6. IANA Considerations + + The SASL Mechanism registry [IANA-SASL] entry for the PLAIN mechanism + has been updated by the IANA to reflect that this document now + provides its technical specification. + + To: iana@iana.org + Subject: Updated Registration of SASL mechanism PLAIN + + SASL mechanism name: PLAIN + Security considerations: See RFC 4616. + Published specification (optional, recommended): RFC 4616 + Person & email address to contact for further information: + Kurt Zeilenga + IETF SASL WG + Intended usage: COMMON + Author/Change controller: IESG + Note: Updates existing entry for PLAIN + +7. Acknowledgements + + This document is a revision of RFC 2595 by Chris Newman. Portions of + the grammar defined in Section 2 were borrowed from [UTF-8] by + Francois Yergeau. + + This document is a product of the IETF Simple Authentication and + Security Layer (SASL) Working Group. + + + + + + + + + + +Zeilenga Standards Track [Page 7] + +RFC 4616 The PLAIN SASL Mechanism August 2006 + + +8. Normative References + + [ABNF] Crocker, D., Ed. and P. Overell, "Augmented BNF for + Syntax Specifications: ABNF", RFC 4234, October 2005. + + [Keywords] Bradner, S., "Key words for use in RFCs to Indicate + Requirement Levels", BCP 14, RFC 2119, March 1997. + + [SASL] Melnikov, A., Ed., and K. Zeilenga, Ed., "Simple + Authentication and Security Layer (SASL)", RFC 4422, + June 2006. + + [SASLPrep] Zeilenga, K., "SASLprep: Stringprep Profile for User + Names and Passwords", RFC 4013, February 2005. + + [StringPrep] Hoffman, P. and M. Blanchet, "Preparation of + Internationalized Strings ("stringprep")", RFC 3454, + December 2002. + + [Unicode] The Unicode Consortium, "The Unicode Standard, Version + 3.2.0" is defined by "The Unicode Standard, Version + 3.0" (Reading, MA, Addison-Wesley, 2000. ISBN 0-201- + 61633-5), as amended by the "Unicode Standard Annex + #27: Unicode 3.1" + (http://www.unicode.org/reports/tr27/) and by the + "Unicode Standard Annex #28: Unicode 3.2" + (http://www.unicode.org/reports/tr28/). + + [UTF-8] Yergeau, F., "UTF-8, a transformation format of ISO + 10646", STD 63, RFC 3629, November 2003. + + [TLS] Dierks, T. and E. Rescorla, "The Transport Layer + Security (TLS) Protocol Version 1.1", RFC 4346, April + 2006. + +9. Informative References + + [ACAP] Newman, C. and J. Myers, "ACAP -- Application + Configuration Access Protocol", RFC 2244, November + 1997. + + [CRAM-MD5] Nerenberg, L., Ed., "The CRAM-MD5 SASL Mechanism", Work + in Progress, June 2006. + + [DIGEST-MD5] Melnikov, A., Ed., "Using Digest Authentication as a + SASL Mechanism", Work in Progress, June 2006. + + + + + +Zeilenga Standards Track [Page 8] + +RFC 4616 The PLAIN SASL Mechanism August 2006 + + + [IANA-SASL] IANA, "SIMPLE AUTHENTICATION AND SECURITY LAYER (SASL) + MECHANISMS", + . + + [SMTP-AUTH] Myers, J., "SMTP Service Extension for Authentication", + RFC 2554, March 1999. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Zeilenga Standards Track [Page 9] + +RFC 4616 The PLAIN SASL Mechanism August 2006 + + +Appendix A. Changes since RFC 2595 + + This appendix is non-normative. + + This document replaces Section 6 of RFC 2595. + + The specification details how the server is to compare client- + provided character strings with stored character strings. + + The ABNF grammar was updated. In particular, the grammar now allows + LINE FEED (U+000A) and CARRIAGE RETURN (U+000D) characters in the + authzid, authcid, passwd productions. However, whether these control + characters may be used depends on the string preparation rules + applicable to the production. For passwd and authcid productions, + control characters are prohibited. For authzid, one must consult the + application-level SASL profile. This change allows PLAIN to carry + all possible authorization identity strings allowed in SASL. + + Pseudo-code was added. + + The example section was expanded to illustrate more features of the + PLAIN mechanism. + +Editor's Address + + Kurt D. Zeilenga + OpenLDAP Foundation + + EMail: Kurt@OpenLDAP.org + + + + + + + + + + + + + + + + + + + + + + +Zeilenga Standards Track [Page 10] + +RFC 4616 The PLAIN SASL Mechanism August 2006 + + +Full Copyright Statement + + Copyright (C) The Internet Society (2006). + + This document is subject to the rights, licenses and restrictions + contained in BCP 78, and except as set forth therein, the authors + retain all their rights. + + This document and the information contained herein are provided on an + "AS IS" basis and THE CONTRIBUTOR, THE ORGANIZATION HE/SHE REPRESENTS + OR IS SPONSORED BY (IF ANY), THE INTERNET SOCIETY AND THE INTERNET + ENGINEERING TASK FORCE DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, + INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE + INFORMATION HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED + WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + +Intellectual Property + + The IETF takes no position regarding the validity or scope of any + Intellectual Property Rights or other rights that might be claimed to + pertain to the implementation or use of the technology described in + this document or the extent to which any license under such rights + might or might not be available; nor does it represent that it has + made any independent effort to identify any such rights. Information + on the procedures with respect to rights in RFC documents can be + found in BCP 78 and BCP 79. + + Copies of IPR disclosures made to the IETF Secretariat and any + assurances of licenses to be made available, or the result of an + attempt made to obtain a general license or permission for the use of + such proprietary rights by implementers or users of this + specification can be obtained from the IETF on-line IPR repository at + http://www.ietf.org/ipr. + + The IETF invites any interested party to bring to its attention any + copyrights, patents or patent applications, or other proprietary + rights that may cover technology that may be required to implement + this standard. Please address the information to the IETF at + ietf-ipr@ietf.org. + +Acknowledgement + + Funding for the RFC Editor function is provided by the IETF + Administrative Support Activity (IASA). + + + + + + + +Zeilenga Standards Track [Page 11] + diff --git a/vendor/swiftmailer/swiftmailer/notes/rfc/rfc4870.txt b/vendor/swiftmailer/swiftmailer/notes/rfc/rfc4870.txt new file mode 100755 index 0000000..55ba5e2 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/notes/rfc/rfc4870.txt @@ -0,0 +1,2298 @@ + + + + + +Network Working Group M. Delany +Request for Comments: 4870 Yahoo! Inc +Obsoleted By: 4871 May 2007 +Category: Historic + + + Domain-Based Email Authentication Using Public Keys + Advertised in the DNS (DomainKeys) + +Status of This Memo + + This memo defines a Historic Document for the Internet community. It + does not specify an Internet standard of any kind. Distribution of + this memo is unlimited. + +Copyright Notice + + Copyright (C) The IETF Trust (2007). + +Abstract + + "DomainKeys" creates a domain-level authentication framework for + email by using public key technology and the DNS to prove the + provenance and contents of an email. + + This document defines a framework for digitally signing email on a + per-domain basis. The ultimate goal of this framework is to + unequivocally prove and protect identity while retaining the + semantics of Internet email as it is known today. + + Proof and protection of email identity may assist in the global + control of "spam" and "phishing". + + + + + + + + + + + + + + + + + + + +Delany Historic [Page 1] + +RFC 4870 DomainKeys May 2007 + + +Table of Contents + + 1. Introduction ....................................................3 + 1.1. Lack of Authentication Is Damaging Internet Email ..........3 + 1.2. Digitally Signing Email Creates Credible Domain + Authentication .............................................4 + 1.3. Public Keys in the DNS .....................................4 + 1.4. Initial Deployment Is Likely at the Border MTA .............5 + 1.5. Conveying Verification Results to MUAs .....................5 + 1.6. Technical Minutiae Are Not Completely Covered ..............5 + 1.7. Motivation .................................................6 + 1.8. Benefits of DomainKeys .....................................6 + 1.9. Definitions ................................................7 + 1.10. Requirements Notation .....................................8 + 2. DomainKeys Overview .............................................8 + 3. DomainKeys Detailed View ........................................8 + 3.1. Determining the Sending Address of an Email ................9 + 3.2. Retrieving the Public Key Given the Sending Domain ........10 + 3.2.1. Introducing "selectors" ............................10 + 3.2.2. Public Key Signing and Verification Algorithm ......11 + 3.2.3. Public key Representation in the DNS ...............13 + 3.2.4. Key Sizes ..........................................14 + 3.3. Storing the Signature in the Email Header .................15 + 3.4. Preparation of Email for Transit and Signing ..............17 + 3.4.1. Preparation for Transit ............................18 + 3.4.2. Canonicalization for Signing .......................18 + 3.4.2.1. The "simple" Canonicalization Algorithm ...19 + 3.4.2.2. The "nofws" Canonicalization Algorithm ....19 + 3.5. The Signing Process .......................................20 + 3.5.1. Identifying the Sending Domain .....................20 + 3.5.2. Determining Whether an Email Should Be Signed ......21 + 3.5.3. Selecting a Private Key and Corresponding + Selector Information ...............................21 + 3.5.4. Calculating the Signature Value ....................21 + 3.5.5. Prepending the "DomainKey-Signature:" Header .......21 + 3.6. Policy Statement of Sending Domain ........................22 + 3.7. The Verification Process ..................................23 + 3.7.1. Presumption that Headers Are Not Reordered .........24 + 3.7.2. Verification Should Render a Binary Result .........24 + 3.7.3. Selecting the Most Appropriate + "DomainKey-Signature:" Header ......................24 + 3.7.4. Retrieve the Public Key Based on the + Signature Information ..............................26 + 3.7.5. Verify the Signature ...............................27 + 3.7.6. Retrieving Sending Domain Policy ...................27 + 3.7.7. Applying Local Policy ..............................27 + 3.8. Conveying Verification Results to MUAs ....................27 + + + + +Delany Historic [Page 2] + +RFC 4870 DomainKeys May 2007 + + + 4. Example of Use .................................................29 + 4.1. The User Composes an Email ................................29 + 4.2. The Email Is Signed .......................................29 + 4.3. The Email Signature Is Verified ...........................30 + 5. Association with a Certificate Authority .......................31 + 5.1. The "DomainKey-X509:" Header ..............................31 + 6. Topics for Discussion ..........................................32 + 6.1. The Benefits of Selectors .................................32 + 6.2. Canonicalization of Email .................................33 + 6.3. Mailing Lists .............................................33 + 6.4. Roving Users ..............................................33 + 7. Security Considerations ........................................34 + 7.1. DNS .......................................................34 + 7.1.1. The DNS Is Not Currently Secure ....................34 + 7.1.2. DomainKeys Creates Additional DNS Load .............35 + 7.2. Key Management ............................................35 + 7.3. Implementation Risks ......................................35 + 7.4. Privacy Assumptions with Forwarding Addresses .............35 + 7.5. Cryptographic Processing Is Computationally Intensive .....36 + 8. The Trial ......................................................36 + 8.1. Goals .....................................................36 + 8.2. Results of Trial ..........................................37 + 9. Note to Implementors Regarding TXT Records .....................37 + 10. References ....................................................37 + 10.1. Normative References .....................................37 + 10.2. Informative References ...................................38 + Appendix A - Syntax Rules for the Tag=Value Format .............39 + Acknowledgments ................................................40 + +1. Introduction + + This document proposes an authentication framework for email that + stores public keys in the DNS and digitally signs email on a domain + basis. Separate documents discuss how this framework can be extended + to validate the delivery path of email as well as facilitate per-user + authentication. + + The DomainKeys specification was a primary source from which the + DomainKeys Identified Mail [DKIM] specification has been derived. + The purpose in submitting this document is as an historical reference + for deployed implementations written prior to the DKIM specification. + +1.1. Lack of Authentication Is Damaging Internet Email + + Authentication of email is not currently widespread. Not only is it + difficult to prove your own identity, it is impossible to prevent + others from abusing your identity. + + + + +Delany Historic [Page 3] + +RFC 4870 DomainKeys May 2007 + + + While most email exchanges do not intrinsically need authentication + beyond context, it is the rampant abuse of identity by "spammers", + "phishers", and their criminal ilk that makes proof necessary. In + other words, authentication is as much about protection as proof. + + Importantly, the inability to authenticate email effectively + delegates much of the control of the disposition of inbound email to + the sender, since senders can trivially assume any email address. + Creating email authentication is the first step to returning + dispositional control of email to the recipient. + + For the purposes of this document, authentication is seen from a user + perspective, and is intended to answer the question "who sent this + email?" where "who" is the email address the recipient sees and "this + email" is the content that the recipient sees. + +1.2. Digitally Signing Email Creates Credible Domain Authentication + + DomainKeys combines public key cryptography and the DNS to provide + credible domain-level authentication for email. + + When an email claims to originate from a certain domain, DomainKeys + provides a mechanism by which the recipient system can credibly + determine that the email did in fact originate from a person or + system authorized to send email for that domain. + + The authentication provided by DomainKeys works in a number of + scenarios in which other authentication systems fail or create + complex operational requirements. These include the following: + + o forwarded email + + o distributed sending systems + + o authorized third-party sending + + This base definition of DomainKeys is intended to primarily enable + domain-level authenticity. Whether a given message is really sent by + the purported user within the domain is outside the scope of the base + definition. Having said that, this specification includes the + possibility that some domains may wish to delegate fine-grained + authentication to individual users. + +1.3. Public Keys in the DNS + + DomainKeys differs from traditional hierarchical public key systems + in that it leverages the DNS for public key management, placing + complete and direct control of key generation and management with the + + + +Delany Historic [Page 4] + +RFC 4870 DomainKeys May 2007 + + + owner of the domain. That is, if you have control over the DNS for a + given domain, you have control over your DomainKeys for that domain. + + The DNS is proposed as the initial mechanism for publishing public + keys. DomainKeys is specifically designed to be extensible to other + key-fetching services as they become available. + +1.4. Initial Deployment Is Likely at the Border MTA + + For practical reasons, it is expected that initial implementations of + DomainKeys will be deployed on Mail Transfer Agents (MTAs) that + accept or relay email across administrative or organizational + boundaries. There are numerous advantages to deployment at the + border MTA, including: + + o a reduction in the number of MTAs that have to be changed to + support an implementation of DomainKeys + + o a reduction in the number of MTAs involved in transmitting the + email between a signing system and a verifying system, thus + reducing the number of places that can make accidental changes + to the contents + + o removing the need to implement DomainKeys within an internal + email network. + + However, there is no necessity to deploy DomainKeys at the border as + signing and verifying can effectively occur anywhere from the border + MTA right back to the Mail User Agent (MUA). In particular, the best + place to sign an email for many domains is likely to be at the point + of SUBMISSION where the sender is often authenticated through SMTP + AUTH or other identifying mechanisms. + +1.5. Conveying Verification Results to MUAs + + It follows that testing the authenticity of an email results in some + action based on the results of the test. Oftentimes, the action is + to notify the MUA in some way -- typically via a header line. + + The "Domainkey-Status:" header is defined in this specification for + recording authentication results in the email. + +1.6. Technical Minutiae Are Not Completely Covered + + The intent of this specification is to communicate the fundamental + characteristics of DomainKeys for an implementor. However, some + aspects are derived from the functionality of the openssl command + [OPENSSL] and, rather than duplicate that documentation, implementors + + + +Delany Historic [Page 5] + +RFC 4870 DomainKeys May 2007 + + + are expected to understand the mechanics of the openssl command, + sufficient to complete the implementation. + +1.7. Motivation + + The motivation for DomainKeys is to define a simple, cheap, and + "sufficiently effective" mechanism by which domain owners can control + who has authority to send email using their domain. To this end, the + designers of DomainKeys set out to build a framework that: + + o is transparent and compatible with the existing email + infrastructure + + o requires no new infrastructure + + o can be implemented independently of clients in order to reduce + deployment time + + o does not require the use of a central certificate authority + that might impose fees for certificates or introduce delays to + deployment + + o can be deployed incrementally + + While we believe that DomainKeys meets these criteria, it is by no + means a perfect solution. The current Internet imposes considerable + compromises on any similar scheme, and readers should be careful not + to misinterpret the information provided in this document to imply + that DomainKeys makes stronger credibility statements than it is able + to do. + +1.8. Benefits of DomainKeys + + As the reader will discover, DomainKeys is solely an authentication + system. It is not a magic bullet for spam, nor is it an + authorization system, a reputation system, a certification system, or + a trust system. + + However, a strong authentication system such as DomainKeys creates an + unimpeachable framework within which comprehensive authorization + systems, reputations systems, and their ilk can be developed. + + + + + + + + + + +Delany Historic [Page 6] + +RFC 4870 DomainKeys May 2007 + + +1.9. Definitions + + With reference to the following sample email: + + Line Data + Number Bytes Content + ---- --- -------------------------------------------- + 01 46 From: "Joe SixPack" + 02 40 To: "Suzie Q" + 03 25 Subject: Is dinner ready? + 04 43 Date: Fri, 11 Jul 2003 21:00:37 -0700 (PDT) + 05 40 Comment: This comment has a continuation + 06 51 because this line begins with folding white space + 07 60 Message-ID: <20030712040037.46341@football.example.com> + 08 00 + 09 03 Hi. + 10 00 + 11 37 We lost the game. Are you hungry yet? + 12 00 + 13 04 Joe. + 14 00 + 15 00 + + Line 01 is the first line of the email and the first line of the + headers. + + Lines 05 and 06 constitute the "Comment:" header. + + Line 06 is a continuation header line. + + Line 07 is the last line of the headers. + + Line 08 is the empty line that separates the header from the body. + + Line 09 is the first line of the body. + + Lines 10, 12, 14, and 15 are empty lines. + + Line 13 is the last non-empty line of the email. + + Line 15 is the last line of the body and the last line of the email. + + Lines 01 to 15 constitute the complete email. + + Line 01 is earlier than line 02, and line 02 is later than line 01. + + + + + + +Delany Historic [Page 7] + +RFC 4870 DomainKeys May 2007 + + +1.10. Requirements Notation + + This document occasionally uses terms that appear in capital letters. + When the terms "MUST", "SHOULD", "RECOMMENDED", "MUST NOT", "SHOULD + NOT", and "MAY" appear capitalized, they are being used to indicate + particular requirements of this specification. A discussion of the + meanings of these terms appears in [RFC2119]. + +2. DomainKeys Overview + + Under DomainKeys, a domain owner generates one or more private/public + key pairs that will be used to sign messages originating from that + domain. The domain owner places the public key in his domain + namespace (i.e., in a DNS record associated with that domain), and + makes the private key available to the outbound email system. When + an email is submitted by an authorized user of that domain, the email + system uses the private key to digitally sign the email associated + with the sending domain. The signature is added as a header to the + email, and the message is transferred to its recipients in the usual + way. + + When a message is received with a DomainKey signature header, the + receiving system can verify the signature as follows: + + 1. Extract the signature and claimed sending domain from the + email. + + 2. Fetch the public key from the claimed sending domain namespace. + + 3. Use public key to determine whether the signature of the email + has been generated with the corresponding private key, and thus + whether the email was sent with the authority of the claimed + sending domain. + + In the event that an email arrives without a signature or when the + signature verification fails, the receiving system retrieves the + policy of the claimed sending domain to ascertain the preferred + disposition of such email. + + Armed with this information, the recipient system can apply local + policy based on the results of the signature test. + +3. DomainKeys Detailed View + + This section discusses the specifics of DomainKeys that are needed to + create interoperable implementations. This section answers the + following questions: + + + + +Delany Historic [Page 8] + +RFC 4870 DomainKeys May 2007 + + + Given an email, how is the sending domain determined? + + How is the public key retrieved for a sending domain? + + As email transits the email system, it can potentially go through + a number of changes. Which parts of the email are included in the + signature and how are they protected from such transformations? + + How is the signature represented in the email? + + If a signature is not present, or a verification fails, how does + the recipient determine the policy intent of the sending domain? + + Finally, on verifying the authenticity of an email, how is that + result conveyed to participating MUAs? + + While there are many alternative design choices, most lead to + comparable functionality. The overriding selection criteria used to + choose among the alternatives are as follows: + + o use deployed technology whenever possible + + o prefer ease of implementation + + o avoid trading risk for excessive flexibility or + interoperability + + o include basic flexibility + + Adherence to these criteria implies that some existing email + implementations will require changes to participate in DomainKeys. + Ultimately, some hard choices need to be made regarding which + requirements are more important. + +3.1. Determining the Sending Address of an Email + + The goal of DomainKeys is to give the recipient confidence that the + email originated from the claimed sender. As with much of Internet + email, agreement over what constitutes the "sender" is no easy + matter. Forwarding systems and mailing lists add serious + complications to an overtly simple question. From the point of view + of the recipient, the authenticity claim should be directed at the + domain most visible to the recipient. + + In the first instance, the most visible address is clearly the RFC + 2822 "From:" address [RFC2822]. Therefore, a conforming email MUST + contain a single "From:" header from which an email address with a + domain name can be extracted. + + + +Delany Historic [Page 9] + +RFC 4870 DomainKeys May 2007 + + + A conforming email MAY contain a single RFC 2822 "Sender:" header + from which an email address with a domain name can be extracted. + + If the email has a valid "From:" and a valid "Sender:" header, then + the signer MUST use the sending address in the "Sender:" header. + + If the email has a valid "From:" and no "Sender:" header, then the + signer MUST use the first sending address in the "From:" header. + + In all other cases, a signer MUST NOT sign the email. Implementors + should note that an email with a "Sender:" header and no "From:" + header MUST NOT be signed. + + The domain name in the sending address constitutes the "sending + domain". + +3.2. Retrieving the Public Key Given the Sending Domain + + To avoid namespace conflicts, it is proposed that the DNS namespace + "_domainkey." be reserved within the sending domain for storing + public keys, e.g., if the sending domain is example.net, then the + public keys for that domain are stored in the _domainkey.example.net + namespace. + +3.2.1. Introducing "selectors" + + To support multiple concurrent public keys per sending domain, the + DNS namespace is further subdivided with "selectors". Selectors are + arbitrary names below the "_domainkey." namespace. A selector value + and length MUST be legal in the DNS namespace and in email headers + with the additional provision that they cannot contain a semicolon. + + Examples of namespaces using selectors are as follows: + + "coolumbeach._domainkey.example.net" + "sebastopol._domainkey.example.net" + "reykjavik._domainkey.example.net" + "default._domainkey.example.net" + + and + + "2005.pao._domainkey.example.net" + "2005.sql._domainkey.example.net" + "2005.rhv._domainkey.example.net" + + Periods are allowed in selectors and are to be treated as component + separators. In the case of DNS queries, that means the period + defines subdomain boundaries. + + + +Delany Historic [Page 10] + +RFC 4870 DomainKeys May 2007 + + + The number of public keys and corresponding selectors for each domain + is determined by the domain owner. Many domain owners will be + satisfied with just one selector, whereas administratively + distributed organizations may choose to manage disparate selectors + and key pairs in different regions, or on different email servers. + + Beyond administrative convenience, selectors make it possible to + seamlessly replace public keys on a routine basis. If a domain + wishes to change from using a public key associated with selector + "2005" to a public key associated with selector "2006", it merely + makes sure that both public keys are advertised in the DNS + concurrently for the transition period during which email may be in + transit prior to verification. At the start of the transition + period, the outbound email servers are configured to sign with the + "2006" private key. At the end of the transition period, the "2005" + public key is removed from the DNS. + + While some domains may wish to make selector values well known, + others will want to take care not to allocate selector names in a way + that allows harvesting of data by outside parties. For example, if + per-user keys are issued, the domain owner will need to make the + decision as to whether to make this selector associated directly with + the user name or make it some unassociated random value, such as the + fingerprint of the public key. + +3.2.2. Public Key Signing and Verification Algorithm + + The default signature is an RSA signed SHA1 digest of the complete + email. + + For ease of explanation, the openssl command is used throughout this + document to describe the mechanism by which keys and signatures are + managed. + + One way to generate a 768-bit private key suitable for DomainKeys is + to use openssl like this: + + $ openssl genrsa -out rsa.private 768 + + + + + + + + + + + + + +Delany Historic [Page 11] + +RFC 4870 DomainKeys May 2007 + + + which results in the file rsa.private containing the key information + similar to this: + + -----BEGIN RSA PRIVATE KEY----- + MIIByQIBAAJhAKJ2lzDLZ8XlVambQfMXn3LRGKOD5o6lMIgulclWjZwP56LRqdg5 + ZX15bhc/GsvW8xW/R5Sh1NnkJNyL/cqY1a+GzzL47t7EXzVc+nRLWT1kwTvFNGIo + AUsFUq+J6+OprwIDAQABAmBOX0UaLdWWusYzNol++nNZ0RLAtr1/LKMX3tk1MkLH + +Ug13EzB2RZjjDOWlUOY98yxW9/hX05Uc9V5MPo+q2Lzg8wBtyRLqlORd7pfxYCn + Kapi2RPMcR1CxEJdXOkLCFECMQDTO0fzuShRvL8q0m5sitIHlLA/L+0+r9KaSRM/ + 3WQrmUpV+fAC3C31XGjhHv2EuAkCMQDE5U2nP2ZWVlSbxOKBqX724amoL7rrkUew + ti9TEjfaBndGKF2yYF7/+g53ZowRkfcCME/xOJr58VN17pejSl1T8Icj88wGNHCs + FDWGAH4EKNwDSMnfLMG4WMBqd9rzYpkvGQIwLhAHDq2CX4hq2tZAt1zT2yYH7tTb + weiHAQxeHe0RK+x/UuZ2pRhuoSv63mwbMLEZAjAP2vy6Yn+f9SKw2mKuj1zLjEhG + 6ppw+nKD50ncnPoP322UMxVNG4Eah0GYJ4DLP0U= + -----END RSA PRIVATE KEY----- + + Once a private key has been generated, the openssl command can be + used to sign an appropriately prepared email, like this: + + $ openssl dgst -sign rsa.private -sha1 + To: "Suzie Q" + Subject: Is dinner ready? + Date: Fri, 11 Jul 2003 21:00:37 -0700 (PDT) + Message-ID: <20030712040037.46341.5F8J@football.example.com> + + Hi. + + We lost the game. Are you hungry yet? + + Joe. + +4.2. The Email Is Signed + + This email is signed by the football.example.com outbound email + server and now looks like this: + + DomainKey-Signature: a=rsa-sha1; s=brisbane; d=football.example.com; + c=simple; q=dns; + b=dzdVyOfAKCdLXdJOc9G2q8LoXSlEniSbav+yuU4zGeeruD00lszZ + VoG4ZHRNiYzR; + Received: from dsl-10.2.3.4.football.example.com [10.2.3.4] + by submitserver.football.example.com with SUBMISSION; + Fri, 11 Jul 2003 21:01:54 -0700 (PDT) + From: "Joe SixPack" + To: "Suzie Q" + Subject: Is dinner ready? + Date: Fri, 11 Jul 2003 21:00:37 -0700 (PDT) + Message-ID: <20030712040037.46341.5F8J@football.example.com> + + Hi. + + We lost the game. Are you hungry yet? + + Joe. + + The signing email server requires access to the private key + associated with the "brisbane" selector to generate this signature. + Distribution and management of private keys are outside the scope of + this document. + + + +Delany Historic [Page 29] + +RFC 4870 DomainKeys May 2007 + + +4.3. The Email Signature Is Verified + + The signature is normally verified by an inbound SMTP server or + possibly the final delivery agent. However, intervening MTAs can + also perform this verification if they choose to do so. + + The verification process uses the domain "football.example.com" + extracted from the "From:" header and the selector "brisbane" from + the "DomainKey-Signature:" header to form the DNS TXT query for: + + brisbane._domainkey.football.example.com + + Since there is no "h" tag in the "DomainKey-Signature:" header, + signature verification starts with the line following the + "DomainKey-Signature:" line. The email is canonically prepared for + verifying with the "simple" method. + + The result of the query and subsequent verification of the signature + is stored in the "DomainKey-Status:" header line. After successful + verification, the email looks like this: + + DomainKey-Status: good + from=joe@football.example.com; domainkeys=pass + Received: from mout23.brisbane.football.example.com (192.168.1.1) + by shopping.example.net with SMTP; + Fri, 11 Jul 2003 21:01:59 -0700 (PDT) + DomainKey-Signature: a=rsa-sha1; s=brisbane; d=football.example.com; + c=simple; q=dns; + b=dzdVyOfAKCdLXdJOc9G2q8LoXSlEniSbav+yuU4zGeeruD00lszZ + VoG4ZHRNiYzR; + Received: from dsl-10.2.3.4.network.example.com [10.2.3.4] + by submitserver.example.com with SUBMISSION; + Fri, 11 Jul 2003 21:01:54 -0700 (PDT) + From: "Joe SixPack" + To: "Suzie Q" + Subject: Is dinner ready? + Date: Fri, 11 Jul 2003 21:00:37 -0700 (PDT) + Message-ID: <20030712040037.46341.5F8J@football.example.com> + + Hi. + + We lost the game. Are you hungry yet? + + Joe. + + + + + + + +Delany Historic [Page 30] + +RFC 4870 DomainKeys May 2007 + + +5. Association with a Certificate Authority + + A fundamental aspect of DomainKeys is that public keys are generated + and advertised by each domain at no additional cost. This + accessibility markedly differs from traditional Public Key + Infrastructures where there is typically a Certificate Authority (CA) + who validates an applicant and issues a signed certificate -- + containing their public key -- often for a recurring fee. + + While CAs do impose costs, they also have the potential to provide + additional value as part of their certification process. Consider + financial institutions, public utilities, law enforcement agencies, + and the like. In many cases, such entities justifiably need to + discriminate themselves above and beyond the authentication that + DomainKeys offers. + + Creating a link between DomainKeys and CA-issued certificates has the + potential to access additional authentication mechanisms that are + more authoritative than domain-owner-issued authentication. It is + well beyond the scope of this specification to describe such + authorities apart from defining how the linkage could be achieved + with the "DomainKey-X509:" header. + +5.1. The "DomainKey-X509:" Header + + The "DomainKey-X509:" header provides a link between the public key + used to sign the email and the certificate issued by a CA. + + The exact content, syntax, and semantics of this header are yet to be + resolved. One possibility is that this header contains an encoding + of the certificate issued by a CA. Another possibility is that this + header contains a URL that points to a certificate issued by a CA. + + In either case, this header can only be consulted if the signature + verifies and MUST be part of the content signed by the corresponding + "DomainKey-Signature:" header. Furthermore, it is likely that MUAs + rather than MTAs will confirm that the link to the CA-issued + certificate is valid. In part, this is because many MUAs already + have built-in capabilities as a consequence of Secure/Multipurpose + Internet Mail Extensions (S/MIME) [SMIME] and Secure Socket Layer + (SSL) [SSL] support. + + The proof of linkage is made by testing that the public key in the + certificate matches the public key used to sign the email. + + + + + + + +Delany Historic [Page 31] + +RFC 4870 DomainKeys May 2007 + + + An example of an email containing the "DomainKey-X509:" header is: + + DomainKey-Signature: a=rsa-sha1; s=statements; + d=largebank.example.com; c=simple; q=dns; + b=dzdVyOfAKCdLXdJOc9G2q8LoXSlEniSbav+yuU4zGeeruD00lszZ + VoG4ZHRNiYzR; + DomainKey-X509: https://ca.example.net/largebank.example.com + From: "Large Bank" + To: "Suzie Q" + Subject: Statement for Account: 1234-5678 + ... + + The format of the retrieved value from the URL is not yet defined, + nor is the determination of valid CAs. + + The whole matter of linkage to CA-issued certificates is one aspect + of DomainKeys that needs to be resolved with relevant CA's and + certificate-issuing entities. The primary point is that a link is + possible to a higher authority. + +6. Topics for Discussion + +6.1. The Benefits of Selectors + + Selectors are at the heart of the flexibility of DomainKeys. A + domain administrator is free to use a single DomainKey for all + outbound mail. Alternatively, the domain administrator may use many + DomainKeys differentiated by selector and assign each key to + different servers. + + For example, a large outbound email farm might have a unique + DomainKey for each server, and thus their DNS will advertise + potentially hundreds of keys via their unique selectors. + + Another example is a corporate email administrator who might generate + a separate DomainKey for each regional office email server. + + In essence, selectors allow a domain owner to distribute authority to + send on behalf of that domain. Combined with the ability to revoke + by removal or Time to Live (TTL) expiration, a domain owner has + coarse-grained control over the duration of the distributed + authority. + + Selectors are particularly useful for domain owners who want to + contract a third-party mailing system to send a particular set of + mail. The domain owner can generate a special key pair and selector + just for this mail-out. The domain owner has to provide the private + key and selector to the third party for the life of the mail-out. + + + +Delany Historic [Page 32] + +RFC 4870 DomainKeys May 2007 + + + However, as soon as the mail-out is completely delivered, the domain + owner can revoke the public key by the simple expedient of removing + the entry from the DNS. + +6.2. Canonicalization of Email + + It is an unfortunate fact that some email software routinely (and + often unnecessarily) transforms email as it transits through the + network. Such transformations conflict with the fundamental purpose + of cryptographic signatures - to detect modifications. + + While two canonicalization algorithms are defined in this + specification, the primary goal of "nofws" is to provide a transition + path to "simple". With a mixture of "simple" and "nofws" email, a + receiver can determine which systems are modifying email in ways that + cause the signature to fail and thus provide feedback to the + modifying system. + +6.3. Mailing Lists + + Integrating existing Mailing List Managers (MLMs) into the DomainKeys + authentication system is a complicated area, as the behavior of MLMs + is highly variable. Essentially, there are two types of MLMs under + consideration: those that modify email to such an extent that + verification of the original content is not possible, and those that + make minimal or no modifications to an email. + + MLMs that modify email in a way that causes verification to fail MUST + prepend a "Sender:" header and SHOULD prepend a "List-ID:" header + prior to signing for distribution to list recipients. + + A participating SUBMISSION server can deduce the need to re-sign such + an email by the presence of a "Sender:" or "List-ID:" header from an + authorized submission. + + MLMs that do not modify email in a way that causes verification to + fail MAY perform the same actions as a modifying MLM. + +6.4. Roving Users + + One scenario that presents a particular problem with any form of + email authentication, including DomainKeys, is the roving user: a + user who is obliged to use a third-party SUBMISSION service when + unable to connect to the user's own SUBMISSION service. The classic + example cited is a traveling salesperson being redirected to a hotel + email server to send email. + + + + + +Delany Historic [Page 33] + +RFC 4870 DomainKeys May 2007 + + + As far as DomainKeys is concerned, email of this nature clearly + originates from an email server that does not have authority to send + on behalf of the domain of the salesperson and is therefore + indistinguishable from a forgery. While DomainKeys does not + prescribe any specific action for such email, it is likely that over + time, such email will be treated as second-class email. + + The typical solution offered to roving users is to submit email via + an authorized server for their domain -- perhaps via a Virtual + Private Network (VPN) or a web interface or even SMTP AUTH back to a + SUBMISSION server. + + While these are perfectly acceptable solutions for many, they are not + necessarily solutions that are available or possible for all such + users. + + One possible way to address the needs of this contingent of + potentially disenfranchised users is for the domain to issue per-user + DomainKeys. Per-user DomainKeys are identified by a non-empty "g" + tag value in the corresponding DNS record. + +7. Security Considerations + +7.1. DNS + + DomainKeys is primarily a security mechanism. Its core purpose is to + make claims about email authentication in a credible way. However, + DomainKeys, like virtually all Internet applications, relies on the + DNS, which has well-known security flaws [RFC3833]. + +7.1.1. The DNS Is Not Currently Secure + + While the DNS is currently insecure, it is expected that the security + problems should and will be solved by DNS Security (DNSSEC) [DNSSEC], + and all users of the DNS will reap the benefit of that work. + + Secondly, the types of DNS attacks relevant to DomainKeys are very + costly and are far less rewarding than DNS attacks on other Internet + applications. + + To systematically thwart the intent of DomainKeys, an attacker must + conduct a very costly and very extensive attack on many parts of the + DNS over an extended period. No one knows for sure how attackers + will respond; however, the cost/benefit of conducting prolonged DNS + attacks of this nature is expected to be uneconomical. + + Finally, DomainKeys is only intended as a "sufficient" method of + proving authenticity. It is not intended to provide strong + + + +Delany Historic [Page 34] + +RFC 4870 DomainKeys May 2007 + + + cryptographic proof about authorship or contents. Other technologies + such as GnuPG and S/MIME address those requirements. + +7.1.2. DomainKeys Creates Additional DNS Load + + A second security issue related to the DNS revolves around the + increased DNS traffic as a consequence of fetching selector-based + data, as well as fetching sending domain policy. Widespread + deployment of DomainKeys will result in a significant increase in DNS + queries to the claimed sending domain. In the case of forgeries on a + large scale, DNS servers could see a substantial increase in queries. + +7.2. Key Management + + All public key systems require management of key pairs. Private keys + in particular need to be securely distributed to each signing mail + server and protected on those servers. For those familiar with SSL, + the key management issues are similar to those of managing SSL + certificates. Poor key management may result in unauthorized access + to private keys, which in essence gives unauthorized access to your + identity. + +7.3. Implementation Risks + + It is well recognized in cryptographic circles that many security + failures are caused by poor implementations rather than poor + algorithms. For example, early SSL implementations were vulnerable + because the implementors used predictable "random numbers". + + While some MTA software already supports various cryptographic + techniques, such as TLS, many do not. This proposal introduces + cryptographic requirements into MTA software that implies a much + higher duty of care to manage the increased risk. + + There are numerous articles, books, courses, and consultants that + help programming security applications. Potential implementors are + strongly encouraged to avail themselves of all possible resources to + ensure secure implementations. + +7.4. Privacy Assumptions with Forwarding Addresses + + Some people believe that they can achieve anonymity by using an email + forwarding service. While this has never been particularly true, as + bounces, over-quota messages, vacation messages, and web bugs all + conspire to expose IP addresses and domain names associated with the + delivery path, the DNS queries that are required to verify DomainKeys + signature can provide additional information to the sender. + + + + +Delany Historic [Page 35] + +RFC 4870 DomainKeys May 2007 + + + In particular, as mail is forwarded through the mail network, the DNS + queries for the selector will typically identify the DNS cache used + by the forwarding and delivery MTAs. + +7.5. Cryptographic Processing Is Computationally Intensive + + Verifying a signature is computationally significant. Early + indications are that a typical mail server can expect to increase CPU + demands by 8-15 percent. While this increased demand is modest + compared to other common mail processing costs -- such as Bayesian + filtering -- any increase in resource requirements can make a + denial-of-service attack more effective against a mail system. + + A constraining factor of such attacks is that the net computational + cost of verifying is bounded by the maximum key size allowed by this + specification and is essentially linear to the rate at which mail is + accepted by the verifying system. Consequently, the additional + computational cost may augment a denial-of-service attack, but it + does not add a non-linear component to such attacks. + +8. The Trial + + The DomainKeys protocol was deployed as a trial to better understand + the implications of deploying wide-scale cryptographic email + authentication. + + Open Source implementations were made available at various places, + particularly Source Forge [SOURCEFORGE], which includes links to + numerous implementations, both Open Source and commercial. + +8.1. Goals + + The primary goals of the trial were to: + + o understand the operational implications of running a DNS-based + public key system for email + + o measure the effectiveness of the canonicalization algorithms + + o experiment with possible per-user key deployment models + + o fully define the semantics of the "DomainKey-X509:" header + + + + + + + + + +Delany Historic [Page 36] + +RFC 4870 DomainKeys May 2007 + + +8.2. Results of Trial + + The DomainKeys trial ran for approximately 2 years, in which time + numerous large ISPs and many thousands of smaller domains + participated in signing or verifying with DomainKeys. The low order + numbers are that at least one billion DomainKey signed emails transit + the Internet each day between some 12,000 participating domains. + + The operational and development experience of that trial was applied + to DKIM. + +9. Note to Implementors Regarding TXT Records + + The DNS is very flexible in that it is possible to have multiple TXT + records for a single name and for those TXT records to contain + multiple strings. + + In all cases, implementors of DomainKeys should expect a single TXT + record for any particular name. If multiple TXT records are + returned, the implementation is free to pick any single TXT record as + the authoritative data. In other words, if a name server returns + different TXT records for the same name, it can expect unpredictable + results. + + Within a single TXT record, implementors should concatenate multiple + strings in the order presented and ignore string boundaries. Note + that a number of popular DNS command-line tools render multiple + strings as separately quoted strings, which can be misleading to a + novice implementor. + +10. References + +10.1. Normative References + + [BASE64] Josefsson, S., "The Base16, Base32, and Base64 Data + Encodings", RFC 4648, October 2006. + + [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate + Requirement Levels", BCP 14, RFC 2119, March 1997. + + [PEM] Linn, J., "Privacy Enhancement for Internet Electronic + Mail: Part I: Message Encryption and Authentication + Procedures", RFC 1421 February, 1993. + + + + + + + + +Delany Historic [Page 37] + +RFC 4870 DomainKeys May 2007 + + +10.2. Informative References + + [DKIM] Allman, E., Callas, J., Delany, M., Libbey, M., Fenton, + J., and M. Thomas, "DomainKeys Identified Mail (DKIM) + Signatures", RFC 4871, May 2007. + + [DNSSEC] http://www.ietf.org/html.charters/dnsext-charter.html + + [OPENSSL] http://www.openssl.org + + [RFC2822] Resnick, P., Editor, "Internet Message Format", RFC + 2822, April 2001. + + [RFC3833] Atkins, D. and R. Austein, "Threat Analysis of the + Domain Name System (DNS)", RFC 3833, August 2004. + + [SMIME] Ramsdell, B., Ed., "Secure/Multipurpose Internet Mail + Extensions (S/MIME) Version 3.1 Message Specification", + RFC 3851, July 2004. + + [SOURCEFORGE] http://domainkeys.sourceforge.net + + [SSL] http://wp.netscape.com/security/techbriefs/ssl.html + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Delany Historic [Page 38] + +RFC 4870 DomainKeys May 2007 + + +Appendix A - Syntax Rules for the Tag=Value Format + + A simple tag=value syntax is used to encode data in the response + values for DNS queries as well as headers embedded in emails. This + section summarized the syntactic rules for this encoding: + + o A tag=value pair consists of three tokens, a "tag", the "=" + character, and the "value" + + o A tag MUST be one character long and MUST be a lowercase + alphabetic character + + o Duplicate tags are not allowed + + o A value MUST only consist of characters that are valid in RFC + 2822 headers and DNS TXT records and are within the ASCII range + of characters from SPACE (0x20) to TILDE (0x7E) inclusive. + Values MUST NOT contain a semicolon but they may contain "=" + characters. + + o A tag=value pair MUST be terminated by a semicolon or the end + of the data + + o Values MUST be processed as case sensitive unless the specific + tag description of semantics imply case insensitivity. + + o Values MAY be zero bytes long + + o Whitespace MAY surround any of the tokens; however, whitespace + within a value MUST be retained unless explicitly excluded by + the specific tag description. Currently, the only tags that + specifically ignore embedded whitespace are the "b" and "h" + tags in the "DomainKey-Signature:" header. + + o Tag=value pairs that represent the default value MAY be + included to aid legibility. + + o Unrecognized tags MUST be ignored + + + + + + + + + + + + + +Delany Historic [Page 39] + +RFC 4870 DomainKeys May 2007 + + +Acknowledgments + + The editor wishes to thank Russ Allbery, Eric Allman, Edwin Aoki, + Claus Asmann, Steve Atkins, Jon Callas, Dave Crocker, Michael Cudahy, + Jutta Degener, Timothy Der, Jim Fenton, Duncan Findlay, Phillip + Hallam-Baker, Murray S. Kucherawy, John Levine, Miles Libbey, David + Margrave, Justin Mason, David Mayne, Russell Nelson, Juan Altmayer + Pizzorno, Blake Ramsdell, Scott Renfro, the Spamhaus.org team, Malte + S. Stretz, Robert Sanders, Bradley Taylor, and Rand Wacker for their + valuable suggestions and constructive criticism. + +Author's Address + + Mark Delany + Yahoo! Inc + 701 First Avenue + Sunnyvale, CA 95087 + USA + + EMail: markd+domainkeys@yahoo-inc.com + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Delany Historic [Page 40] + +RFC 4870 DomainKeys May 2007 + + +Full Copyright Statement + + Copyright (C) The IETF Trust (2007). + + This document is subject to the rights, licenses and restrictions + contained in BCP 78, and except as set forth therein, the authors + retain all their rights. + + This document and the information contained herein are provided on an + "AS IS" basis and THE CONTRIBUTOR, THE ORGANIZATION HE/SHE REPRESENTS + OR IS SPONSORED BY (IF ANY), THE INTERNET SOCIETY, THE IETF TRUST AND + THE INTERNET ENGINEERING TASK FORCE DISCLAIM ALL WARRANTIES, EXPRESS + OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF + THE INFORMATION HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED + WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + +Intellectual Property + + The IETF takes no position regarding the validity or scope of any + Intellectual Property Rights or other rights that might be claimed to + pertain to the implementation or use of the technology described in + this document or the extent to which any license under such rights + might or might not be available; nor does it represent that it has + made any independent effort to identify any such rights. Information + on the procedures with respect to rights in RFC documents can be + found in BCP 78 and BCP 79. + + Copies of IPR disclosures made to the IETF Secretariat and any + assurances of licenses to be made available, or the result of an + attempt made to obtain a general license or permission for the use of + such proprietary rights by implementers or users of this + specification can be obtained from the IETF on-line IPR repository at + http://www.ietf.org/ipr. + + The IETF invites any interested party to bring to its attention any + copyrights, patents or patent applications, or other proprietary + rights that may cover technology that may be required to implement + this standard. Please address the information to the IETF at + ietf-ipr@ietf.org. + +Acknowledgement + + Funding for the RFC Editor function is currently provided by the + Internet Society. + + + + + + + +Delany Historic [Page 41] + diff --git a/vendor/swiftmailer/swiftmailer/notes/rfc/rfc4871.txt b/vendor/swiftmailer/swiftmailer/notes/rfc/rfc4871.txt new file mode 100755 index 0000000..80410e6 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/notes/rfc/rfc4871.txt @@ -0,0 +1,3978 @@ + + + + + +Network Working Group E. Allman +Request for Comments: 4871 Sendmail, Inc. +Obsoletes: 4870 J. Callas +Category: Standards Track PGP Corporation + M. Delany + M. Libbey + Yahoo! Inc + J. Fenton + M. Thomas + Cisco Systems, Inc. + May 2007 + + + DomainKeys Identified Mail (DKIM) Signatures + +Status of This Memo + + This document specifies an Internet standards track protocol for the + Internet community, and requests discussion and suggestions for + improvements. Please refer to the current edition of the "Internet + Official Protocol Standards" (STD 1) for the standardization state + and status of this protocol. Distribution of this memo is unlimited. + +Copyright Notice + + Copyright (C) The IETF Trust (2007). + +Abstract + + DomainKeys Identified Mail (DKIM) defines a domain-level + authentication framework for email using public-key cryptography and + key server technology to permit verification of the source and + contents of messages by either Mail Transfer Agents (MTAs) or Mail + User Agents (MUAs). The ultimate goal of this framework is to permit + a signing domain to assert responsibility for a message, thus + protecting message signer identity and the integrity of the messages + they convey while retaining the functionality of Internet email as it + is known today. Protection of email identity may assist in the + global control of "spam" and "phishing". + + + + + + + + + + + + +Allman, et al. Standards Track [Page 1] + +RFC 4871 DKIM Signatures May 2007 + + +Table of Contents + + 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . . 4 + 1.1. Signing Identity . . . . . . . . . . . . . . . . . . . . . 5 + 1.2. Scalability . . . . . . . . . . . . . . . . . . . . . . . 5 + 1.3. Simple Key Management . . . . . . . . . . . . . . . . . . 5 + 2. Terminology and Definitions . . . . . . . . . . . . . . . . . 5 + 2.1. Signers . . . . . . . . . . . . . . . . . . . . . . . . . 6 + 2.2. Verifiers . . . . . . . . . . . . . . . . . . . . . . . . 6 + 2.3. Whitespace . . . . . . . . . . . . . . . . . . . . . . . . 6 + 2.4. Common ABNF Tokens . . . . . . . . . . . . . . . . . . . . 6 + 2.5. Imported ABNF Tokens . . . . . . . . . . . . . . . . . . . 7 + 2.6. DKIM-Quoted-Printable . . . . . . . . . . . . . . . . . . 7 + 3. Protocol Elements . . . . . . . . . . . . . . . . . . . . . . 8 + 3.1. Selectors . . . . . . . . . . . . . . . . . . . . . . . . 8 + 3.2. Tag=Value Lists . . . . . . . . . . . . . . . . . . . . . 10 + 3.3. Signing and Verification Algorithms . . . . . . . . . . . 11 + 3.4. Canonicalization . . . . . . . . . . . . . . . . . . . . . 13 + 3.5. The DKIM-Signature Header Field . . . . . . . . . . . . . 17 + 3.6. Key Management and Representation . . . . . . . . . . . . 25 + 3.7. Computing the Message Hashes . . . . . . . . . . . . . . . 29 + 3.8. Signing by Parent Domains . . . . . . . . . . . . . . . . 31 + 4. Semantics of Multiple Signatures . . . . . . . . . . . . . . . 32 + 4.1. Example Scenarios . . . . . . . . . . . . . . . . . . . . 32 + 4.2. Interpretation . . . . . . . . . . . . . . . . . . . . . . 33 + 5. Signer Actions . . . . . . . . . . . . . . . . . . . . . . . . 34 + 5.1. Determine Whether the Email Should Be Signed and by + Whom . . . . . . . . . . . . . . . . . . . . . . . . . . . 34 + 5.2. Select a Private Key and Corresponding Selector + Information . . . . . . . . . . . . . . . . . . . . . . . 35 + 5.3. Normalize the Message to Prevent Transport Conversions . . 35 + 5.4. Determine the Header Fields to Sign . . . . . . . . . . . 36 + 5.5. Recommended Signature Content . . . . . . . . . . . . . . 38 + 5.6. Compute the Message Hash and Signature . . . . . . . . . . 39 + 5.7. Insert the DKIM-Signature Header Field . . . . . . . . . . 40 + 6. Verifier Actions . . . . . . . . . . . . . . . . . . . . . . . 40 + 6.1. Extract Signatures from the Message . . . . . . . . . . . 41 + 6.2. Communicate Verification Results . . . . . . . . . . . . . 46 + 6.3. Interpret Results/Apply Local Policy . . . . . . . . . . . 47 + 7. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 48 + 7.1. DKIM-Signature Tag Specifications . . . . . . . . . . . . 48 + 7.2. DKIM-Signature Query Method Registry . . . . . . . . . . . 49 + 7.3. DKIM-Signature Canonicalization Registry . . . . . . . . . 49 + 7.4. _domainkey DNS TXT Record Tag Specifications . . . . . . . 50 + 7.5. DKIM Key Type Registry . . . . . . . . . . . . . . . . . . 50 + 7.6. DKIM Hash Algorithms Registry . . . . . . . . . . . . . . 51 + 7.7. DKIM Service Types Registry . . . . . . . . . . . . . . . 51 + 7.8. DKIM Selector Flags Registry . . . . . . . . . . . . . . . 52 + + + +Allman, et al. Standards Track [Page 2] + +RFC 4871 DKIM Signatures May 2007 + + + 7.9. DKIM-Signature Header Field . . . . . . . . . . . . . . . 52 + 8. Security Considerations . . . . . . . . . . . . . . . . . . . 52 + 8.1. Misuse of Body Length Limits ("l=" Tag) . . . . . . . . . 52 + 8.2. Misappropriated Private Key . . . . . . . . . . . . . . . 53 + 8.3. Key Server Denial-of-Service Attacks . . . . . . . . . . . 54 + 8.4. Attacks Against the DNS . . . . . . . . . . . . . . . . . 54 + 8.5. Replay Attacks . . . . . . . . . . . . . . . . . . . . . . 55 + 8.6. Limits on Revoking Keys . . . . . . . . . . . . . . . . . 55 + 8.7. Intentionally Malformed Key Records . . . . . . . . . . . 56 + 8.8. Intentionally Malformed DKIM-Signature Header Fields . . . 56 + 8.9. Information Leakage . . . . . . . . . . . . . . . . . . . 56 + 8.10. Remote Timing Attacks . . . . . . . . . . . . . . . . . . 56 + 8.11. Reordered Header Fields . . . . . . . . . . . . . . . . . 56 + 8.12. RSA Attacks . . . . . . . . . . . . . . . . . . . . . . . 56 + 8.13. Inappropriate Signing by Parent Domains . . . . . . . . . 57 + 9. References . . . . . . . . . . . . . . . . . . . . . . . . . . 57 + 9.1. Normative References . . . . . . . . . . . . . . . . . . . 57 + 9.2. Informative References . . . . . . . . . . . . . . . . . . 58 + Appendix A. Example of Use (INFORMATIVE) . . . . . . . . . . . . 60 + A.1. The user composes an email . . . . . . . . . . . . . . . . 60 + A.2. The email is signed . . . . . . . . . . . . . . . . . . . 61 + A.3. The email signature is verified . . . . . . . . . . . . . 61 + Appendix B. Usage Examples (INFORMATIVE) . . . . . . . . . . . . 62 + B.1. Alternate Submission Scenarios . . . . . . . . . . . . . . 63 + B.2. Alternate Delivery Scenarios . . . . . . . . . . . . . . . 65 + Appendix C. Creating a Public Key (INFORMATIVE) . . . . . . . . . 67 + Appendix D. MUA Considerations . . . . . . . . . . . . . . . . . 68 + Appendix E. Acknowledgements . . . . . . . . . . . . . . . . . . 69 + + + + + + + + + + + + + + + + + + + + + + + +Allman, et al. Standards Track [Page 3] + +RFC 4871 DKIM Signatures May 2007 + + +1. Introduction + + DomainKeys Identified Mail (DKIM) defines a mechanism by which email + messages can be cryptographically signed, permitting a signing domain + to claim responsibility for the introduction of a message into the + mail stream. Message recipients can verify the signature by querying + the signer's domain directly to retrieve the appropriate public key, + and thereby confirm that the message was attested to by a party in + possession of the private key for the signing domain. + + The approach taken by DKIM differs from previous approaches to + message signing (e.g., Secure/Multipurpose Internet Mail Extensions + (S/MIME) [RFC1847], OpenPGP [RFC2440]) in that: + + o the message signature is written as a message header field so that + neither human recipients nor existing MUA (Mail User Agent) + software is confused by signature-related content appearing in the + message body; + + o there is no dependency on public and private key pairs being + issued by well-known, trusted certificate authorities; + + o there is no dependency on the deployment of any new Internet + protocols or services for public key distribution or revocation; + + o signature verification failure does not force rejection of the + message; + + o no attempt is made to include encryption as part of the mechanism; + + o message archiving is not a design goal. + + DKIM: + + o is compatible with the existing email infrastructure and + transparent to the fullest extent possible; + + o requires minimal new infrastructure; + + o can be implemented independently of clients in order to reduce + deployment time; + + o can be deployed incrementally; + + o allows delegation of signing to third parties. + + + + + + +Allman, et al. Standards Track [Page 4] + +RFC 4871 DKIM Signatures May 2007 + + +1.1. Signing Identity + + DKIM separates the question of the identity of the signer of the + message from the purported author of the message. In particular, a + signature includes the identity of the signer. Verifiers can use the + signing information to decide how they want to process the message. + The signing identity is included as part of the signature header + field. + + INFORMATIVE RATIONALE: The signing identity specified by a DKIM + signature is not required to match an address in any particular + header field because of the broad methods of interpretation by + recipient mail systems, including MUAs. + +1.2. Scalability + + DKIM is designed to support the extreme scalability requirements that + characterize the email identification problem. There are currently + over 70 million domains and a much larger number of individual + addresses. DKIM seeks to preserve the positive aspects of the + current email infrastructure, such as the ability for anyone to + communicate with anyone else without introduction. + +1.3. Simple Key Management + + DKIM differs from traditional hierarchical public-key systems in that + no Certificate Authority infrastructure is required; the verifier + requests the public key from a repository in the domain of the + claimed signer directly rather than from a third party. + + The DNS is proposed as the initial mechanism for the public keys. + Thus, DKIM currently depends on DNS administration and the security + of the DNS system. DKIM is designed to be extensible to other key + fetching services as they become available. + +2. Terminology and Definitions + + This section defines terms used in the rest of the document. Syntax + descriptions use the form described in Augmented BNF for Syntax + Specifications [RFC4234]. + + The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", + "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this + document are to be interpreted as described in [RFC2119]. + + + + + + + +Allman, et al. Standards Track [Page 5] + +RFC 4871 DKIM Signatures May 2007 + + +2.1. Signers + + Elements in the mail system that sign messages on behalf of a domain + are referred to as signers. These may be MUAs (Mail User Agents), + MSAs (Mail Submission Agents), MTAs (Mail Transfer Agents), or other + agents such as mailing list exploders. In general, any signer will + be involved in the injection of a message into the message system in + some way. The key issue is that a message must be signed before it + leaves the administrative domain of the signer. + +2.2. Verifiers + + Elements in the mail system that verify signatures are referred to as + verifiers. These may be MTAs, Mail Delivery Agents (MDAs), or MUAs. + In most cases it is expected that verifiers will be close to an end + user (reader) of the message or some consuming agent such as a + mailing list exploder. + +2.3. Whitespace + + There are three forms of whitespace: + + o WSP represents simple whitespace, i.e., a space or a tab character + (formal definition in [RFC4234]). + + o LWSP is linear whitespace, defined as WSP plus CRLF (formal + definition in [RFC4234]). + + o FWS is folding whitespace. It allows multiple lines separated by + CRLF followed by at least one whitespace, to be joined. + + The formal ABNF for these are (WSP and LWSP are given for information + only): + + WSP = SP / HTAB + LWSP = *(WSP / CRLF WSP) + FWS = [*WSP CRLF] 1*WSP + + The definition of FWS is identical to that in [RFC2822] except for + the exclusion of obs-FWS. + +2.4. Common ABNF Tokens + + The following ABNF tokens are used elsewhere in this document: + hyphenated-word = ALPHA [ *(ALPHA / DIGIT / "-") (ALPHA / DIGIT) ] + base64string = 1*(ALPHA / DIGIT / "+" / "/" / [FWS]) + [ "=" [FWS] [ "=" [FWS] ] ] + + + + +Allman, et al. Standards Track [Page 6] + +RFC 4871 DKIM Signatures May 2007 + + +2.5. Imported ABNF Tokens + + The following tokens are imported from other RFCs as noted. Those + RFCs should be considered definitive. + + The following tokens are imported from [RFC2821]: + + o "Local-part" (implementation warning: this permits quoted strings) + + o "sub-domain" + + The following tokens are imported from [RFC2822]: + + o "field-name" (name of a header field) + + o "dot-atom-text" (in the Local-part of an email address) + + The following tokens are imported from [RFC2045]: + + o "qp-section" (a single line of quoted-printable-encoded text) + + o "hex-octet" (a quoted-printable encoded octet) + + INFORMATIVE NOTE: Be aware that the ABNF in RFC 2045 does not obey + the rules of RFC 4234 and must be interpreted accordingly, + particularly as regards case folding. + + Other tokens not defined herein are imported from [RFC4234]. These + are intuitive primitives such as SP, HTAB, WSP, ALPHA, DIGIT, CRLF, + etc. + +2.6. DKIM-Quoted-Printable + + The DKIM-Quoted-Printable encoding syntax resembles that described in + Quoted-Printable [RFC2045], Section 6.7: any character MAY be encoded + as an "=" followed by two hexadecimal digits from the alphabet + "0123456789ABCDEF" (no lowercase characters permitted) representing + the hexadecimal-encoded integer value of that character. All control + characters (those with values < %x20), 8-bit characters (values > + %x7F), and the characters DEL (%x7F), SPACE (%x20), and semicolon + (";", %x3B) MUST be encoded. Note that all whitespace, including + SPACE, CR, and LF characters, MUST be encoded. After encoding, FWS + MAY be added at arbitrary locations in order to avoid excessively + long lines; such whitespace is NOT part of the value, and MUST be + removed before decoding. + + + + + + +Allman, et al. Standards Track [Page 7] + +RFC 4871 DKIM Signatures May 2007 + + + ABNF: + + dkim-quoted-printable = + *(FWS / hex-octet / dkim-safe-char) + ; hex-octet is from RFC 2045 + dkim-safe-char = %x21-3A / %x3C / %x3E-7E + ; '!' - ':', '<', '>' - '~' + ; Characters not listed as "mail-safe" in + ; RFC 2049 are also not recommended. + + INFORMATIVE NOTE: DKIM-Quoted-Printable differs from Quoted- + Printable as defined in RFC 2045 in several important ways: + + 1. Whitespace in the input text, including CR and LF, must be + encoded. RFC 2045 does not require such encoding, and does + not permit encoding of CR or LF characters that are part of a + CRLF line break. + + 2. Whitespace in the encoded text is ignored. This is to allow + tags encoded using DKIM-Quoted-Printable to be wrapped as + needed. In particular, RFC 2045 requires that line breaks in + the input be represented as physical line breaks; that is not + the case here. + + 3. The "soft line break" syntax ("=" as the last non-whitespace + character on the line) does not apply. + + 4. DKIM-Quoted-Printable does not require that encoded lines be + no more than 76 characters long (although there may be other + requirements depending on the context in which the encoded + text is being used). + +3. Protocol Elements + + Protocol Elements are conceptual parts of the protocol that are not + specific to either signers or verifiers. The protocol descriptions + for signers and verifiers are described in later sections (Signer + Actions (Section 5) and Verifier Actions (Section 6)). NOTE: This + section must be read in the context of those sections. + +3.1. Selectors + + To support multiple concurrent public keys per signing domain, the + key namespace is subdivided using "selectors". For example, + selectors might indicate the names of office locations (e.g., + "sanfrancisco", "coolumbeach", and "reykjavik"), the signing date + (e.g., "january2005", "february2005", etc.), or even the individual + user. + + + +Allman, et al. Standards Track [Page 8] + +RFC 4871 DKIM Signatures May 2007 + + + Selectors are needed to support some important use cases. For + example: + + o Domains that want to delegate signing capability for a specific + address for a given duration to a partner, such as an advertising + provider or other outsourced function. + + o Domains that want to allow frequent travelers to send messages + locally without the need to connect with a particular MSA. + + o "Affinity" domains (e.g., college alumni associations) that + provide forwarding of incoming mail, but that do not operate a + mail submission agent for outgoing mail. + + Periods are allowed in selectors and are component separators. When + keys are retrieved from the DNS, periods in selectors define DNS + label boundaries in a manner similar to the conventional use in + domain names. Selector components might be used to combine dates + with locations, for example, "march2005.reykjavik". In a DNS + implementation, this can be used to allow delegation of a portion of + the selector namespace. + + ABNF: + + selector = sub-domain *( "." sub-domain ) + + The number of public keys and corresponding selectors for each domain + is determined by the domain owner. Many domain owners will be + satisfied with just one selector, whereas administratively + distributed organizations may choose to manage disparate selectors + and key pairs in different regions or on different email servers. + + Beyond administrative convenience, selectors make it possible to + seamlessly replace public keys on a routine basis. If a domain + wishes to change from using a public key associated with selector + "january2005" to a public key associated with selector + "february2005", it merely makes sure that both public keys are + advertised in the public-key repository concurrently for the + transition period during which email may be in transit prior to + verification. At the start of the transition period, the outbound + email servers are configured to sign with the "february2005" private + key. At the end of the transition period, the "january2005" public + key is removed from the public-key repository. + + INFORMATIVE NOTE: A key may also be revoked as described below. + The distinction between revoking and removing a key selector + record is subtle. When phasing out keys as described above, a + signing domain would probably simply remove the key record after + + + +Allman, et al. Standards Track [Page 9] + +RFC 4871 DKIM Signatures May 2007 + + + the transition period. However, a signing domain could elect to + revoke the key (but maintain the key record) for a further period. + There is no defined semantic difference between a revoked key and + a removed key. + + While some domains may wish to make selector values well known, + others will want to take care not to allocate selector names in a way + that allows harvesting of data by outside parties. For example, if + per-user keys are issued, the domain owner will need to make the + decision as to whether to associate this selector directly with the + user name, or make it some unassociated random value, such as a + fingerprint of the public key. + + INFORMATIVE OPERATIONS NOTE: Reusing a selector with a new key + (for example, changing the key associated with a user's name) + makes it impossible to tell the difference between a message that + didn't verify because the key is no longer valid versus a message + that is actually forged. For this reason, signers are ill-advised + to reuse selectors for new keys. A better strategy is to assign + new keys to new selectors. + +3.2. Tag=Value Lists + + DKIM uses a simple "tag=value" syntax in several contexts, including + in messages and domain signature records. + + Values are a series of strings containing either plain text, "base64" + text (as defined in [RFC2045], Section 6.8), "qp-section" (ibid, + Section 6.7), or "dkim-quoted-printable" (as defined in Section 2.6). + The name of the tag will determine the encoding of each value. + Unencoded semicolon (";") characters MUST NOT occur in the tag value, + since that separates tag-specs. + + INFORMATIVE IMPLEMENTATION NOTE: Although the "plain text" defined + below (as "tag-value") only includes 7-bit characters, an + implementation that wished to anticipate future standards would be + advised not to preclude the use of UTF8-encoded text in tag=value + lists. + + + + + + + + + + + + + +Allman, et al. Standards Track [Page 10] + +RFC 4871 DKIM Signatures May 2007 + + + Formally, the syntax rules are as follows: + + tag-list = tag-spec 0*( ";" tag-spec ) [ ";" ] + tag-spec = [FWS] tag-name [FWS] "=" [FWS] tag-value [FWS] + tag-name = ALPHA 0*ALNUMPUNC + tag-value = [ tval 0*( 1*(WSP / FWS) tval ) ] + ; WSP and FWS prohibited at beginning and end + tval = 1*VALCHAR + VALCHAR = %x21-3A / %x3C-7E + ; EXCLAMATION to TILDE except SEMICOLON + ALNUMPUNC = ALPHA / DIGIT / "_" + + Note that WSP is allowed anywhere around tags. In particular, any + WSP after the "=" and any WSP before the terminating ";" is not part + of the value; however, WSP inside the value is significant. + + Tags MUST be interpreted in a case-sensitive manner. Values MUST be + processed as case sensitive unless the specific tag description of + semantics specifies case insensitivity. + + Tags with duplicate names MUST NOT occur within a single tag-list; if + a tag name does occur more than once, the entire tag-list is invalid. + + Whitespace within a value MUST be retained unless explicitly excluded + by the specific tag description. + + Tag=value pairs that represent the default value MAY be included to + aid legibility. + + Unrecognized tags MUST be ignored. + + Tags that have an empty value are not the same as omitted tags. An + omitted tag is treated as having the default value; a tag with an + empty value explicitly designates the empty string as the value. For + example, "g=" does not mean "g=*", even though "g=*" is the default + for that tag. + +3.3. Signing and Verification Algorithms + + DKIM supports multiple digital signature algorithms. Two algorithms + are defined by this specification at this time: rsa-sha1 and rsa- + sha256. The rsa-sha256 algorithm is the default if no algorithm is + specified. Verifiers MUST implement both rsa-sha1 and rsa-sha256. + Signers MUST implement and SHOULD sign using rsa-sha256. + + + + + + + +Allman, et al. Standards Track [Page 11] + +RFC 4871 DKIM Signatures May 2007 + + + INFORMATIVE NOTE: Although sha256 is strongly encouraged, some + senders of low-security messages (such as routine newsletters) may + prefer to use sha1 because of reduced CPU requirements to compute + a sha1 hash. In general, sha256 should always be used whenever + possible. + +3.3.1. The rsa-sha1 Signing Algorithm + + The rsa-sha1 Signing Algorithm computes a message hash as described + in Section 3.7 below using SHA-1 [FIPS.180-2.2002] as the hash-alg. + That hash is then signed by the signer using the RSA algorithm + (defined in PKCS#1 version 1.5 [RFC3447]) as the crypt-alg and the + signer's private key. The hash MUST NOT be truncated or converted + into any form other than the native binary form before being signed. + The signing algorithm SHOULD use a public exponent of 65537. + +3.3.2. The rsa-sha256 Signing Algorithm + + The rsa-sha256 Signing Algorithm computes a message hash as described + in Section 3.7 below using SHA-256 [FIPS.180-2.2002] as the hash-alg. + That hash is then signed by the signer using the RSA algorithm + (defined in PKCS#1 version 1.5 [RFC3447]) as the crypt-alg and the + signer's private key. The hash MUST NOT be truncated or converted + into any form other than the native binary form before being signed. + +3.3.3. Key Sizes + + Selecting appropriate key sizes is a trade-off between cost, + performance, and risk. Since short RSA keys more easily succumb to + off-line attacks, signers MUST use RSA keys of at least 1024 bits for + long-lived keys. Verifiers MUST be able to validate signatures with + keys ranging from 512 bits to 2048 bits, and they MAY be able to + validate signatures with larger keys. Verifier policies may use the + length of the signing key as one metric for determining whether a + signature is acceptable. + + Factors that should influence the key size choice include the + following: + + o The practical constraint that large (e.g., 4096 bit) keys may not + fit within a 512-byte DNS UDP response packet + + o The security constraint that keys smaller than 1024 bits are + subject to off-line attacks + + o Larger keys impose higher CPU costs to verify and sign email + + + + + +Allman, et al. Standards Track [Page 12] + +RFC 4871 DKIM Signatures May 2007 + + + o Keys can be replaced on a regular basis, thus their lifetime can + be relatively short + + o The security goals of this specification are modest compared to + typical goals of other systems that employ digital signatures + + See [RFC3766] for further discussion on selecting key sizes. + +3.3.4. Other Algorithms + + Other algorithms MAY be defined in the future. Verifiers MUST ignore + any signatures using algorithms that they do not implement. + +3.4. Canonicalization + + Empirical evidence demonstrates that some mail servers and relay + systems modify email in transit, potentially invalidating a + signature. There are two competing perspectives on such + modifications. For most signers, mild modification of email is + immaterial to the authentication status of the email. For such + signers, a canonicalization algorithm that survives modest in-transit + modification is preferred. + + Other signers demand that any modification of the email, however + minor, result in a signature verification failure. These signers + prefer a canonicalization algorithm that does not tolerate in-transit + modification of the signed email. + + Some signers may be willing to accept modifications to header fields + that are within the bounds of email standards such as [RFC2822], but + are unwilling to accept any modification to the body of messages. + + To satisfy all requirements, two canonicalization algorithms are + defined for each of the header and the body: a "simple" algorithm + that tolerates almost no modification and a "relaxed" algorithm that + tolerates common modifications such as whitespace replacement and + header field line rewrapping. A signer MAY specify either algorithm + for header or body when signing an email. If no canonicalization + algorithm is specified by the signer, the "simple" algorithm defaults + for both header and body. Verifiers MUST implement both + canonicalization algorithms. Note that the header and body may use + different canonicalization algorithms. Further canonicalization + algorithms MAY be defined in the future; verifiers MUST ignore any + signatures that use unrecognized canonicalization algorithms. + + Canonicalization simply prepares the email for presentation to the + signing or verification algorithm. It MUST NOT change the + + + + +Allman, et al. Standards Track [Page 13] + +RFC 4871 DKIM Signatures May 2007 + + + transmitted data in any way. Canonicalization of header fields and + body are described below. + + NOTE: This section assumes that the message is already in "network + normal" format (text is ASCII encoded, lines are separated with CRLF + characters, etc.). See also Section 5.3 for information about + normalizing the message. + +3.4.1. The "simple" Header Canonicalization Algorithm + + The "simple" header canonicalization algorithm does not change header + fields in any way. Header fields MUST be presented to the signing or + verification algorithm exactly as they are in the message being + signed or verified. In particular, header field names MUST NOT be + case folded and whitespace MUST NOT be changed. + +3.4.2. The "relaxed" Header Canonicalization Algorithm + + The "relaxed" header canonicalization algorithm MUST apply the + following steps in order: + + o Convert all header field names (not the header field values) to + lowercase. For example, convert "SUBJect: AbC" to "subject: AbC". + + o Unfold all header field continuation lines as described in + [RFC2822]; in particular, lines with terminators embedded in + continued header field values (that is, CRLF sequences followed by + WSP) MUST be interpreted without the CRLF. Implementations MUST + NOT remove the CRLF at the end of the header field value. + + o Convert all sequences of one or more WSP characters to a single SP + character. WSP characters here include those before and after a + line folding boundary. + + o Delete all WSP characters at the end of each unfolded header field + value. + + o Delete any WSP characters remaining before and after the colon + separating the header field name from the header field value. The + colon separator MUST be retained. + +3.4.3. The "simple" Body Canonicalization Algorithm + + The "simple" body canonicalization algorithm ignores all empty lines + at the end of the message body. An empty line is a line of zero + length after removal of the line terminator. If there is no body or + no trailing CRLF on the message body, a CRLF is added. It makes no + + + + +Allman, et al. Standards Track [Page 14] + +RFC 4871 DKIM Signatures May 2007 + + + other changes to the message body. In more formal terms, the + "simple" body canonicalization algorithm converts "0*CRLF" at the end + of the body to a single "CRLF". + + Note that a completely empty or missing body is canonicalized as a + single "CRLF"; that is, the canonicalized length will be 2 octets. + +3.4.4. The "relaxed" Body Canonicalization Algorithm + + The "relaxed" body canonicalization algorithm: + + o Ignores all whitespace at the end of lines. Implementations MUST + NOT remove the CRLF at the end of the line. + + o Reduces all sequences of WSP within a line to a single SP + character. + + o Ignores all empty lines at the end of the message body. "Empty + line" is defined in Section 3.4.3. + + INFORMATIVE NOTE: It should be noted that the relaxed body + canonicalization algorithm may enable certain types of extremely + crude "ASCII Art" attacks where a message may be conveyed by + adjusting the spacing between words. If this is a concern, the + "simple" body canonicalization algorithm should be used instead. + +3.4.5. Body Length Limits + + A body length count MAY be specified to limit the signature + calculation to an initial prefix of the body text, measured in + octets. If the body length count is not specified, the entire + message body is signed. + + INFORMATIVE RATIONALE: This capability is provided because it is + very common for mailing lists to add trailers to messages (e.g., + instructions how to get off the list). Until those messages are + also signed, the body length count is a useful tool for the + verifier since it may as a matter of policy accept messages having + valid signatures with extraneous data. + + INFORMATIVE IMPLEMENTATION NOTE: Using body length limits enables + an attack in which an attacker modifies a message to include + content that solely benefits the attacker. It is possible for the + appended content to completely replace the original content in the + end recipient's eyes and to defeat duplicate message detection + algorithms. To avoid this attack, signers should be wary of using + + + + + +Allman, et al. Standards Track [Page 15] + +RFC 4871 DKIM Signatures May 2007 + + + this tag, and verifiers might wish to ignore the tag or remove + text that appears after the specified content length, perhaps + based on other criteria. + + The body length count allows the signer of a message to permit data + to be appended to the end of the body of a signed message. The body + length count MUST be calculated following the canonicalization + algorithm; for example, any whitespace ignored by a canonicalization + algorithm is not included as part of the body length count. Signers + of MIME messages that include a body length count SHOULD be sure that + the length extends to the closing MIME boundary string. + + INFORMATIVE IMPLEMENTATION NOTE: A signer wishing to ensure that + the only acceptable modifications are to add to the MIME postlude + would use a body length count encompassing the entire final MIME + boundary string, including the final "--CRLF". A signer wishing + to allow additional MIME parts but not modification of existing + parts would use a body length count extending through the final + MIME boundary string, omitting the final "--CRLF". Note that this + only works for some MIME types, e.g., multipart/mixed but not + multipart/signed. + + A body length count of zero means that the body is completely + unsigned. + + Signers wishing to ensure that no modification of any sort can occur + should specify the "simple" canonicalization algorithm for both + header and body and omit the body length count. + +3.4.6. Canonicalization Examples (INFORMATIVE) + + In the following examples, actual whitespace is used only for + clarity. The actual input and output text is designated using + bracketed descriptors: "" for a space character, "" for a + tab character, and "" for a carriage-return/line-feed sequence. + For example, "X Y" and "XY" represent the same three + characters. + + Example 1: A message reading: + + A: X + B : Y + Z + + C + D E + + + + + +Allman, et al. Standards Track [Page 16] + +RFC 4871 DKIM Signatures May 2007 + + + when canonicalized using relaxed canonicalization for both header and + body results in a header reading: + + a:X + b:Y Z + + and a body reading: + + C + D E + + Example 2: The same message canonicalized using simple + canonicalization for both header and body results in a header + reading: + + A: X + B : Y + Z + + and a body reading: + + C + D E + + Example 3: When processed using relaxed header canonicalization and + simple body canonicalization, the canonicalized version has a header + of: + + a:X + b:Y Z + + and a body reading: + + C + D E + +3.5. The DKIM-Signature Header Field + + The signature of the email is stored in the DKIM-Signature header + field. This header field contains all of the signature and key- + fetching data. The DKIM-Signature value is a tag-list as described + in Section 3.2. + + The DKIM-Signature header field SHOULD be treated as though it were a + trace header field as defined in Section 3.6 of [RFC2822], and hence + SHOULD NOT be reordered and SHOULD be prepended to the message. + + + + + +Allman, et al. Standards Track [Page 17] + +RFC 4871 DKIM Signatures May 2007 + + + The DKIM-Signature header field being created or verified is always + included in the signature calculation, after the rest of the header + fields being signed; however, when calculating or verifying the + signature, the value of the "b=" tag (signature value) of that DKIM- + Signature header field MUST be treated as though it were an empty + string. Unknown tags in the DKIM-Signature header field MUST be + included in the signature calculation but MUST be otherwise ignored + by verifiers. Other DKIM-Signature header fields that are included + in the signature should be treated as normal header fields; in + particular, the "b=" tag is not treated specially. + + The encodings for each field type are listed below. Tags described + as qp-section are encoded as described in Section 6.7 of MIME Part + One [RFC2045], with the additional conversion of semicolon characters + to "=3B"; intuitively, this is one line of quoted-printable encoded + text. The dkim-quoted-printable syntax is defined in Section 2.6. + + Tags on the DKIM-Signature header field along with their type and + requirement status are shown below. Unrecognized tags MUST be + ignored. + + v= Version (MUST be included). This tag defines the version of this + specification that applies to the signature record. It MUST have + the value "1". Note that verifiers must do a string comparison + on this value; for example, "1" is not the same as "1.0". + + ABNF: + + sig-v-tag = %x76 [FWS] "=" [FWS] "1" + + INFORMATIVE NOTE: DKIM-Signature version numbers are expected + to increase arithmetically as new versions of this + specification are released. + + a= The algorithm used to generate the signature (plain-text; + REQUIRED). Verifiers MUST support "rsa-sha1" and "rsa-sha256"; + signers SHOULD sign using "rsa-sha256". See Section 3.3 for a + description of algorithms. + + ABNF: + + sig-a-tag = %x61 [FWS] "=" [FWS] sig-a-tag-alg + sig-a-tag-alg = sig-a-tag-k "-" sig-a-tag-h + sig-a-tag-k = "rsa" / x-sig-a-tag-k + sig-a-tag-h = "sha1" / "sha256" / x-sig-a-tag-h + x-sig-a-tag-k = ALPHA *(ALPHA / DIGIT) ; for later extension + x-sig-a-tag-h = ALPHA *(ALPHA / DIGIT) ; for later extension + + + + +Allman, et al. Standards Track [Page 18] + +RFC 4871 DKIM Signatures May 2007 + + + b= The signature data (base64; REQUIRED). Whitespace is ignored in + this value and MUST be ignored when reassembling the original + signature. In particular, the signing process can safely insert + FWS in this value in arbitrary places to conform to line-length + limits. See Signer Actions (Section 5) for how the signature is + computed. + + ABNF: + + sig-b-tag = %x62 [FWS] "=" [FWS] sig-b-tag-data + sig-b-tag-data = base64string + + bh= The hash of the canonicalized body part of the message as limited + by the "l=" tag (base64; REQUIRED). Whitespace is ignored in + this value and MUST be ignored when reassembling the original + signature. In particular, the signing process can safely insert + FWS in this value in arbitrary places to conform to line-length + limits. See Section 3.7 for how the body hash is computed. + + ABNF: + + sig-bh-tag = %x62 %x68 [FWS] "=" [FWS] sig-bh-tag-data + sig-bh-tag-data = base64string + + c= Message canonicalization (plain-text; OPTIONAL, default is + "simple/simple"). This tag informs the verifier of the type of + canonicalization used to prepare the message for signing. It + consists of two names separated by a "slash" (%d47) character, + corresponding to the header and body canonicalization algorithms + respectively. These algorithms are described in Section 3.4. If + only one algorithm is named, that algorithm is used for the + header and "simple" is used for the body. For example, + "c=relaxed" is treated the same as "c=relaxed/simple". + + ABNF: + + sig-c-tag = %x63 [FWS] "=" [FWS] sig-c-tag-alg + ["/" sig-c-tag-alg] + sig-c-tag-alg = "simple" / "relaxed" / x-sig-c-tag-alg + x-sig-c-tag-alg = hyphenated-word ; for later extension + + d= The domain of the signing entity (plain-text; REQUIRED). This is + the domain that will be queried for the public key. This domain + MUST be the same as or a parent domain of the "i=" tag (the + signing identity, as described below), or it MUST meet the + requirements for parent domain signing described in Section 3.8. + When presented with a signature that does not meet these + requirement, verifiers MUST consider the signature invalid. + + + +Allman, et al. Standards Track [Page 19] + +RFC 4871 DKIM Signatures May 2007 + + + Internationalized domain names MUST be encoded as described in + [RFC3490]. + + ABNF: + + sig-d-tag = %x64 [FWS] "=" [FWS] domain-name + domain-name = sub-domain 1*("." sub-domain) + ; from RFC 2821 Domain, but excluding address-literal + + h= Signed header fields (plain-text, but see description; REQUIRED). + A colon-separated list of header field names that identify the + header fields presented to the signing algorithm. The field MUST + contain the complete list of header fields in the order presented + to the signing algorithm. The field MAY contain names of header + fields that do not exist when signed; nonexistent header fields + do not contribute to the signature computation (that is, they are + treated as the null input, including the header field name, the + separating colon, the header field value, and any CRLF + terminator). The field MUST NOT include the DKIM-Signature + header field that is being created or verified, but may include + others. Folding whitespace (FWS) MAY be included on either side + of the colon separator. Header field names MUST be compared + against actual header field names in a case-insensitive manner. + This list MUST NOT be empty. See Section 5.4 for a discussion of + choosing header fields to sign. + + ABNF: + + sig-h-tag = %x68 [FWS] "=" [FWS] hdr-name + 0*( *FWS ":" *FWS hdr-name ) + hdr-name = field-name + + INFORMATIVE EXPLANATION: By "signing" header fields that do not + actually exist, a signer can prevent insertion of those + header fields before verification. However, since a signer + cannot possibly know what header fields might be created in + the future, and that some MUAs might present header fields + that are embedded inside a message (e.g., as a message/rfc822 + content type), the security of this solution is not total. + + INFORMATIVE EXPLANATION: The exclusion of the header field name + and colon as well as the header field value for non-existent + header fields prevents an attacker from inserting an actual + header field with a null value. + + + + + + + +Allman, et al. Standards Track [Page 20] + +RFC 4871 DKIM Signatures May 2007 + + + i= Identity of the user or agent (e.g., a mailing list manager) on + behalf of which this message is signed (dkim-quoted-printable; + OPTIONAL, default is an empty Local-part followed by an "@" + followed by the domain from the "d=" tag). The syntax is a + standard email address where the Local-part MAY be omitted. The + domain part of the address MUST be the same as or a subdomain of + the value of the "d=" tag. + + Internationalized domain names MUST be converted using the steps + listed in Section 4 of [RFC3490] using the "ToASCII" function. + + ABNF: + + sig-i-tag = %x69 [FWS] "=" [FWS] [ Local-part ] "@" domain-name + + INFORMATIVE NOTE: The Local-part of the "i=" tag is optional + because in some cases a signer may not be able to establish a + verified individual identity. In such cases, the signer may + wish to assert that although it is willing to go as far as + signing for the domain, it is unable or unwilling to commit + to an individual user name within their domain. It can do so + by including the domain part but not the Local-part of the + identity. + + INFORMATIVE DISCUSSION: This document does not require the value + of the "i=" tag to match the identity in any message header + fields. This is considered to be a verifier policy issue. + Constraints between the value of the "i=" tag and other + identities in other header fields seek to apply basic + authentication into the semantics of trust associated with a + role such as content author. Trust is a broad and complex + topic and trust mechanisms are subject to highly creative + attacks. The real-world efficacy of any but the most basic + bindings between the "i=" value and other identities is not + well established, nor is its vulnerability to subversion by + an attacker. Hence reliance on the use of these options + should be strictly limited. In particular, it is not at all + clear to what extent a typical end-user recipient can rely on + any assurances that might be made by successful use of the + "i=" options. + + l= Body length count (plain-text unsigned decimal integer; OPTIONAL, + default is entire body). This tag informs the verifier of the + number of octets in the body of the email after canonicalization + included in the cryptographic hash, starting from 0 immediately + following the CRLF preceding the body. This value MUST NOT be + larger than the actual number of octets in the canonicalized + message body. + + + +Allman, et al. Standards Track [Page 21] + +RFC 4871 DKIM Signatures May 2007 + + + INFORMATIVE IMPLEMENTATION WARNING: Use of the "l=" tag might + allow display of fraudulent content without appropriate + warning to end users. The "l=" tag is intended for + increasing signature robustness when sending to mailing lists + that both modify their content and do not sign their + messages. However, using the "l=" tag enables attacks in + which an intermediary with malicious intent modifies a + message to include content that solely benefits the attacker. + It is possible for the appended content to completely replace + the original content in the end recipient's eyes and to + defeat duplicate message detection algorithms. Examples are + described in Security Considerations (Section 8). To avoid + this attack, signers should be extremely wary of using this + tag, and verifiers might wish to ignore the tag or remove + text that appears after the specified content length. + + INFORMATIVE NOTE: The value of the "l=" tag is constrained to 76 + decimal digits. This constraint is not intended to predict + the size of future messages or to require implementations to + use an integer representation large enough to represent the + maximum possible value, but is intended to remind the + implementer to check the length of this and all other tags + during verification and to test for integer overflow when + decoding the value. Implementers may need to limit the + actual value expressed to a value smaller than 10^76, e.g., + to allow a message to fit within the available storage space. + + ABNF: + + sig-l-tag = %x6c [FWS] "=" [FWS] 1*76DIGIT + + q= A colon-separated list of query methods used to retrieve the + public key (plain-text; OPTIONAL, default is "dns/txt"). Each + query method is of the form "type[/options]", where the syntax + and semantics of the options depend on the type and specified + options. If there are multiple query mechanisms listed, the + choice of query mechanism MUST NOT change the interpretation of + the signature. Implementations MUST use the recognized query + mechanisms in the order presented. + + Currently, the only valid value is "dns/txt", which defines the DNS + TXT record lookup algorithm described elsewhere in this document. + The only option defined for the "dns" query type is "txt", which + MUST be included. Verifiers and signers MUST support "dns/txt". + + + + + + + +Allman, et al. Standards Track [Page 22] + +RFC 4871 DKIM Signatures May 2007 + + + ABNF: + + sig-q-tag = %x71 [FWS] "=" [FWS] sig-q-tag-method + *([FWS] ":" [FWS] sig-q-tag-method) + sig-q-tag-method = "dns/txt" / x-sig-q-tag-type + ["/" x-sig-q-tag-args] + x-sig-q-tag-type = hyphenated-word ; for future extension + x-sig-q-tag-args = qp-hdr-value + + s= The selector subdividing the namespace for the "d=" (domain) tag + (plain-text; REQUIRED). + + ABNF: + + sig-s-tag = %x73 [FWS] "=" [FWS] selector + + t= Signature Timestamp (plain-text unsigned decimal integer; + RECOMMENDED, default is an unknown creation time). The time that + this signature was created. The format is the number of seconds + since 00:00:00 on January 1, 1970 in the UTC time zone. The + value is expressed as an unsigned integer in decimal ASCII. This + value is not constrained to fit into a 31- or 32-bit integer. + Implementations SHOULD be prepared to handle values up to at + least 10^12 (until approximately AD 200,000; this fits into 40 + bits). To avoid denial-of-service attacks, implementations MAY + consider any value longer than 12 digits to be infinite. Leap + seconds are not counted. Implementations MAY ignore signatures + that have a timestamp in the future. + + ABNF: + + sig-t-tag = %x74 [FWS] "=" [FWS] 1*12DIGIT + + x= Signature Expiration (plain-text unsigned decimal integer; + RECOMMENDED, default is no expiration). The format is the same + as in the "t=" tag, represented as an absolute date, not as a + time delta from the signing timestamp. The value is expressed as + an unsigned integer in decimal ASCII, with the same constraints + on the value in the "t=" tag. Signatures MAY be considered + invalid if the verification time at the verifier is past the + expiration date. The verification time should be the time that + the message was first received at the administrative domain of + the verifier if that time is reliably available; otherwise the + current time should be used. The value of the "x=" tag MUST be + greater than the value of the "t=" tag if both are present. + + + + + + +Allman, et al. Standards Track [Page 23] + +RFC 4871 DKIM Signatures May 2007 + + + INFORMATIVE NOTE: The "x=" tag is not intended as an anti-replay + defense. + + ABNF: + + sig-x-tag = %x78 [FWS] "=" [FWS] 1*12DIGIT + + z= Copied header fields (dkim-quoted-printable, but see description; + OPTIONAL, default is null). A vertical-bar-separated list of + selected header fields present when the message was signed, + including both the field name and value. It is not required to + include all header fields present at the time of signing. This + field need not contain the same header fields listed in the "h=" + tag. The header field text itself must encode the vertical bar + ("|", %x7C) character (i.e., vertical bars in the "z=" text are + metacharacters, and any actual vertical bar characters in a + copied header field must be encoded). Note that all whitespace + must be encoded, including whitespace between the colon and the + header field value. After encoding, FWS MAY be added at + arbitrary locations in order to avoid excessively long lines; + such whitespace is NOT part of the value of the header field, and + MUST be removed before decoding. + + The header fields referenced by the "h=" tag refer to the fields in + the RFC 2822 header of the message, not to any copied fields in + the "z=" tag. Copied header field values are for diagnostic use. + + Header fields with characters requiring conversion (perhaps from + legacy MTAs that are not [RFC2822] compliant) SHOULD be converted + as described in MIME Part Three [RFC2047]. + + ABNF: + sig-z-tag = %x7A [FWS] "=" [FWS] sig-z-tag-copy + *( [FWS] "|" sig-z-tag-copy ) + sig-z-tag-copy = hdr-name ":" qp-hdr-value + qp-hdr-value = dkim-quoted-printable ; with "|" encoded + + INFORMATIVE EXAMPLE of a signature header field spread across + multiple continuation lines: + + + + + + + + + + + + +Allman, et al. Standards Track [Page 24] + +RFC 4871 DKIM Signatures May 2007 + + + DKIM-Signature: a=rsa-sha256; d=example.net; s=brisbane; + c=simple; q=dns/txt; i=@eng.example.net; + t=1117574938; x=1118006938; + h=from:to:subject:date; + z=From:foo@eng.example.net|To:joe@example.com| + Subject:demo=20run|Date:July=205,=202005=203:44:08=20PM=20-0700; + bh=MTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTI=; + b=dzdVyOfAKCdLXdJOc9G2q8LoXSlEniSbav+yuU4zGeeruD00lszZ + VoG4ZHRNiYzR + +3.6. Key Management and Representation + + Signature applications require some level of assurance that the + verification public key is associated with the claimed signer. Many + applications achieve this by using public key certificates issued by + a trusted third party. However, DKIM can achieve a sufficient level + of security, with significantly enhanced scalability, by simply + having the verifier query the purported signer's DNS entry (or some + security-equivalent) in order to retrieve the public key. + + DKIM keys can potentially be stored in multiple types of key servers + and in multiple formats. The storage and format of keys are + irrelevant to the remainder of the DKIM algorithm. + + Parameters to the key lookup algorithm are the type of the lookup + (the "q=" tag), the domain of the signer (the "d=" tag of the DKIM- + Signature header field), and the selector (the "s=" tag). + + public_key = dkim_find_key(q_val, d_val, s_val) + + This document defines a single binding, using DNS TXT records to + distribute the keys. Other bindings may be defined in the future. + +3.6.1. Textual Representation + + It is expected that many key servers will choose to present the keys + in an otherwise unstructured text format (for example, an XML form + would not be considered to be unstructured text for this purpose). + The following definition MUST be used for any DKIM key represented in + an otherwise unstructured textual form. + + The overall syntax is a tag-list as described in Section 3.2. The + current valid tags are described below. Other tags MAY be present + and MUST be ignored by any implementation that does not understand + them. + + + + + + +Allman, et al. Standards Track [Page 25] + +RFC 4871 DKIM Signatures May 2007 + + + v= Version of the DKIM key record (plain-text; RECOMMENDED, default + is "DKIM1"). If specified, this tag MUST be set to "DKIM1" + (without the quotes). This tag MUST be the first tag in the + record. Records beginning with a "v=" tag with any other value + MUST be discarded. Note that verifiers must do a string + comparison on this value; for example, "DKIM1" is not the same as + "DKIM1.0". + + ABNF: + + key-v-tag = %x76 [FWS] "=" [FWS] "DKIM1" + + g= Granularity of the key (plain-text; OPTIONAL, default is "*"). + This value MUST match the Local-part of the "i=" tag of the DKIM- + Signature header field (or its default value of the empty string + if "i=" is not specified), with a single, optional "*" character + matching a sequence of zero or more arbitrary characters + ("wildcarding"). An email with a signing address that does not + match the value of this tag constitutes a failed verification. + The intent of this tag is to constrain which signing address can + legitimately use this selector, for example, when delegating a + key to a third party that should only be used for special + purposes. Wildcarding allows matching for addresses such as + "user+*" or "*-offer". An empty "g=" value never matches any + addresses. + + ABNF: + + key-g-tag = %x67 [FWS] "=" [FWS] key-g-tag-lpart + key-g-tag-lpart = [dot-atom-text] ["*" [dot-atom-text] ] + + h= Acceptable hash algorithms (plain-text; OPTIONAL, defaults to + allowing all algorithms). A colon-separated list of hash + algorithms that might be used. Signers and Verifiers MUST + support the "sha256" hash algorithm. Verifiers MUST also support + the "sha1" hash algorithm. + + ABNF: + + key-h-tag = %x68 [FWS] "=" [FWS] key-h-tag-alg + 0*( [FWS] ":" [FWS] key-h-tag-alg ) + key-h-tag-alg = "sha1" / "sha256" / x-key-h-tag-alg + x-key-h-tag-alg = hyphenated-word ; for future extension + + + + + + + + +Allman, et al. Standards Track [Page 26] + +RFC 4871 DKIM Signatures May 2007 + + + k= Key type (plain-text; OPTIONAL, default is "rsa"). Signers and + verifiers MUST support the "rsa" key type. The "rsa" key type + indicates that an ASN.1 DER-encoded [ITU.X660.1997] RSAPublicKey + [RFC3447] (see Sections 3.1 and A.1.1) is being used in the "p=" + tag. (Note: the "p=" tag further encodes the value using the + base64 algorithm.) + + ABNF: + + key-k-tag = %x76 [FWS] "=" [FWS] key-k-tag-type + key-k-tag-type = "rsa" / x-key-k-tag-type + x-key-k-tag-type = hyphenated-word ; for future extension + + n= Notes that might be of interest to a human (qp-section; OPTIONAL, + default is empty). No interpretation is made by any program. + This tag should be used sparingly in any key server mechanism + that has space limitations (notably DNS). This is intended for + use by administrators, not end users. + + ABNF: + + key-n-tag = %x6e [FWS] "=" [FWS] qp-section + + p= Public-key data (base64; REQUIRED). An empty value means that + this public key has been revoked. The syntax and semantics of + this tag value before being encoded in base64 are defined by the + "k=" tag. + + INFORMATIVE RATIONALE: If a private key has been compromised + or otherwise disabled (e.g., an outsourcing contract has been + terminated), a signer might want to explicitly state that it + knows about the selector, but all messages using that + selector should fail verification. Verifiers should ignore + any DKIM-Signature header fields with a selector referencing + a revoked key. + + ABNF: + + key-p-tag = %x70 [FWS] "=" [ [FWS] base64string ] + + INFORMATIVE NOTE: A base64string is permitted to include white + space (FWS) at arbitrary places; however, any CRLFs must be + followed by at least one WSP character. Implementors and + administrators are cautioned to ensure that selector TXT + records conform to this specification. + + + + + + +Allman, et al. Standards Track [Page 27] + +RFC 4871 DKIM Signatures May 2007 + + + s= Service Type (plain-text; OPTIONAL; default is "*"). A colon- + separated list of service types to which this record applies. + Verifiers for a given service type MUST ignore this record if the + appropriate type is not listed. Currently defined service types + are as follows: + + * matches all service types + + email electronic mail (not necessarily limited to SMTP) + + This tag is intended to constrain the use of keys for other + purposes, should use of DKIM be defined by other services in the + future. + + ABNF: + + key-s-tag = %x73 [FWS] "=" [FWS] key-s-tag-type + 0*( [FWS] ":" [FWS] key-s-tag-type ) + key-s-tag-type = "email" / "*" / x-key-s-tag-type + x-key-s-tag-type = hyphenated-word ; for future extension + + t= Flags, represented as a colon-separated list of names (plain- + text; OPTIONAL, default is no flags set). The defined flags are + as follows: + + y This domain is testing DKIM. Verifiers MUST NOT treat + messages from signers in testing mode differently from + unsigned email, even should the signature fail to verify. + Verifiers MAY wish to track testing mode results to assist + the signer. + + s Any DKIM-Signature header fields using the "i=" tag MUST have + the same domain value on the right-hand side of the "@" in + the "i=" tag and the value of the "d=" tag. That is, the + "i=" domain MUST NOT be a subdomain of "d=". Use of this + flag is RECOMMENDED unless subdomaining is required. + + ABNF: + + key-t-tag = %x74 [FWS] "=" [FWS] key-t-tag-flag + 0*( [FWS] ":" [FWS] key-t-tag-flag ) + key-t-tag-flag = "y" / "s" / x-key-t-tag-flag + x-key-t-tag-flag = hyphenated-word ; for future extension + + Unrecognized flags MUST be ignored. + + + + + + +Allman, et al. Standards Track [Page 28] + +RFC 4871 DKIM Signatures May 2007 + + +3.6.2. DNS Binding + + A binding using DNS TXT records as a key service is hereby defined. + All implementations MUST support this binding. + +3.6.2.1. Namespace + + All DKIM keys are stored in a subdomain named "_domainkey". Given a + DKIM-Signature field with a "d=" tag of "example.com" and an "s=" tag + of "foo.bar", the DNS query will be for + "foo.bar._domainkey.example.com". + + INFORMATIVE OPERATIONAL NOTE: Wildcard DNS records (e.g., + *.bar._domainkey.example.com) do not make sense in this context + and should not be used. Note also that wildcards within domains + (e.g., s._domainkey.*.example.com) are not supported by the DNS. + +3.6.2.2. Resource Record Types for Key Storage + + The DNS Resource Record type used is specified by an option to the + query-type ("q=") tag. The only option defined in this base + specification is "txt", indicating the use of a TXT Resource Record + (RR). A later extension of this standard may define another RR type. + + Strings in a TXT RR MUST be concatenated together before use with no + intervening whitespace. TXT RRs MUST be unique for a particular + selector name; that is, if there are multiple records in an RRset, + the results are undefined. + + TXT RRs are encoded as described in Section 3.6.1. + +3.7. Computing the Message Hashes + + Both signing and verifying message signatures start with a step of + computing two cryptographic hashes over the message. Signers will + choose the parameters of the signature as described in Signer Actions + (Section 5); verifiers will use the parameters specified in the DKIM- + Signature header field being verified. In the following discussion, + the names of the tags in the DKIM-Signature header field that either + exists (when verifying) or will be created (when signing) are used. + Note that canonicalization (Section 3.4) is only used to prepare the + email for signing or verifying; it does not affect the transmitted + email in any way. + + The signer/verifier MUST compute two hashes, one over the body of the + message and one over the selected header fields of the message. + + + + + +Allman, et al. Standards Track [Page 29] + +RFC 4871 DKIM Signatures May 2007 + + + Signers MUST compute them in the order shown. Verifiers MAY compute + them in any order convenient to the verifier, provided that the + result is semantically identical to the semantics that would be the + case had they been computed in this order. + + In hash step 1, the signer/verifier MUST hash the message body, + canonicalized using the body canonicalization algorithm specified in + the "c=" tag and then truncated to the length specified in the "l=" + tag. That hash value is then converted to base64 form and inserted + into (signers) or compared to (verifiers) the "bh=" tag of the DKIM- + Signature header field. + + In hash step 2, the signer/verifier MUST pass the following to the + hash algorithm in the indicated order. + + 1. The header fields specified by the "h=" tag, in the order + specified in that tag, and canonicalized using the header + canonicalization algorithm specified in the "c=" tag. Each + header field MUST be terminated with a single CRLF. + + 2. The DKIM-Signature header field that exists (verifying) or will + be inserted (signing) in the message, with the value of the "b=" + tag deleted (i.e., treated as the empty string), canonicalized + using the header canonicalization algorithm specified in the "c=" + tag, and without a trailing CRLF. + + All tags and their values in the DKIM-Signature header field are + included in the cryptographic hash with the sole exception of the + value portion of the "b=" (signature) tag, which MUST be treated as + the null string. All tags MUST be included even if they might not be + understood by the verifier. The header field MUST be presented to + the hash algorithm after the body of the message rather than with the + rest of the header fields and MUST be canonicalized as specified in + the "c=" (canonicalization) tag. The DKIM-Signature header field + MUST NOT be included in its own h= tag, although other DKIM-Signature + header fields MAY be signed (see Section 4). + + When calculating the hash on messages that will be transmitted using + base64 or quoted-printable encoding, signers MUST compute the hash + after the encoding. Likewise, the verifier MUST incorporate the + values into the hash before decoding the base64 or quoted-printable + text. However, the hash MUST be computed before transport level + encodings such as SMTP "dot-stuffing" (the modification of lines + beginning with a "." to avoid confusion with the SMTP end-of-message + marker, as specified in [RFC2821]). + + With the exception of the canonicalization procedure described in + Section 3.4, the DKIM signing process treats the body of messages as + + + +Allman, et al. Standards Track [Page 30] + +RFC 4871 DKIM Signatures May 2007 + + + simply a string of octets. DKIM messages MAY be either in plain-text + or in MIME format; no special treatment is afforded to MIME content. + Message attachments in MIME format MUST be included in the content + that is signed. + + More formally, the algorithm for the signature is as follows: + body-hash = hash-alg(canon_body) + header-hash = hash-alg(canon_header || DKIM-SIG) + signature = sig-alg(header-hash, key) + + where "sig-alg" is the signature algorithm specified by the "a=" tag, + "hash-alg" is the hash algorithm specified by the "a=" tag, + "canon_header" and "canon_body" are the canonicalized message header + and body (respectively) as defined in Section 3.4 (excluding the + DKIM-Signature header field), and "DKIM-SIG" is the canonicalized + DKIM-Signature header field sans the signature value itself, but with + "body-hash" included as the "bh=" tag. + + INFORMATIVE IMPLEMENTERS' NOTE: Many digital signature APIs + provide both hashing and application of the RSA private key using + a single "sign()" primitive. When using such an API, the last two + steps in the algorithm would probably be combined into a single + call that would perform both the "hash-alg" and the "sig-alg". + +3.8. Signing by Parent Domains + + In some circumstances, it is desirable for a domain to apply a + signature on behalf of any of its subdomains without the need to + maintain separate selectors (key records) in each subdomain. By + default, private keys corresponding to key records can be used to + sign messages for any subdomain of the domain in which they reside; + e.g., a key record for the domain example.com can be used to verify + messages where the signing identity ("i=" tag of the signature) is + sub.example.com, or even sub1.sub2.example.com. In order to limit + the capability of such keys when this is not intended, the "s" flag + may be set in the "t=" tag of the key record to constrain the + validity of the record to exactly the domain of the signing identity. + If the referenced key record contains the "s" flag as part of the + "t=" tag, the domain of the signing identity ("i=" flag) MUST be the + same as that of the d= domain. If this flag is absent, the domain of + the signing identity MUST be the same as, or a subdomain of, the d= + domain. Key records that are not intended for use with subdomains + SHOULD specify the "s" flag in the "t=" tag. + + + + + + + + +Allman, et al. Standards Track [Page 31] + +RFC 4871 DKIM Signatures May 2007 + + +4. Semantics of Multiple Signatures + +4.1. Example Scenarios + + There are many reasons why a message might have multiple signatures. + For example, a given signer might sign multiple times, perhaps with + different hashing or signing algorithms during a transition phase. + + INFORMATIVE EXAMPLE: Suppose SHA-256 is in the future found to be + insufficiently strong, and DKIM usage transitions to SHA-1024. A + signer might immediately sign using the newer algorithm, but + continue to sign using the older algorithm for interoperability + with verifiers that had not yet upgraded. The signer would do + this by adding two DKIM-Signature header fields, one using each + algorithm. Older verifiers that did not recognize SHA-1024 as an + acceptable algorithm would skip that signature and use the older + algorithm; newer verifiers could use either signature at their + option, and all other things being equal might not even attempt to + verify the other signature. + + Similarly, a signer might sign a message including all headers and no + "l=" tag (to satisfy strict verifiers) and a second time with a + limited set of headers and an "l=" tag (in anticipation of possible + message modifications in route to other verifiers). Verifiers could + then choose which signature they preferred. + + INFORMATIVE EXAMPLE: A verifier might receive a message with two + signatures, one covering more of the message than the other. If + the signature covering more of the message verified, then the + verifier could make one set of policy decisions; if that signature + failed but the signature covering less of the message verified, + the verifier might make a different set of policy decisions. + + Of course, a message might also have multiple signatures because it + passed through multiple signers. A common case is expected to be + that of a signed message that passes through a mailing list that also + signs all messages. Assuming both of those signatures verify, a + recipient might choose to accept the message if either of those + signatures were known to come from trusted sources. + + INFORMATIVE EXAMPLE: Recipients might choose to whitelist mailing + lists to which they have subscribed and that have acceptable anti- + abuse policies so as to accept messages sent to that list even + from unknown authors. They might also subscribe to less trusted + mailing lists (e.g., those without anti-abuse protection) and be + willing to accept all messages from specific authors, but insist + on doing additional abuse scanning for other messages. + + + + +Allman, et al. Standards Track [Page 32] + +RFC 4871 DKIM Signatures May 2007 + + + Another related example of multiple signers might be forwarding + services, such as those commonly associated with academic alumni + sites. + + INFORMATIVE EXAMPLE: A recipient might have an address at + members.example.org, a site that has anti-abuse protection that is + somewhat less effective than the recipient would prefer. Such a + recipient might have specific authors whose messages would be + trusted absolutely, but messages from unknown authors that had + passed the forwarder's scrutiny would have only medium trust. + +4.2. Interpretation + + A signer that is adding a signature to a message merely creates a new + DKIM-Signature header, using the usual semantics of the h= option. A + signer MAY sign previously existing DKIM-Signature header fields + using the method described in Section 5.4 to sign trace header + fields. + + INFORMATIVE NOTE: Signers should be cognizant that signing DKIM- + Signature header fields may result in signature failures with + intermediaries that do not recognize that DKIM-Signature header + fields are trace header fields and unwittingly reorder them, thus + breaking such signatures. For this reason, signing existing DKIM- + Signature header fields is unadvised, albeit legal. + + INFORMATIVE NOTE: If a header field with multiple instances is + signed, those header fields are always signed from the bottom up. + Thus, it is not possible to sign only specific DKIM-Signature + header fields. For example, if the message being signed already + contains three DKIM-Signature header fields A, B, and C, it is + possible to sign all of them, B and C only, or C only, but not A + only, B only, A and B only, or A and C only. + + A signer MAY add more than one DKIM-Signature header field using + different parameters. For example, during a transition period a + signer might want to produce signatures using two different hash + algorithms. + + Signers SHOULD NOT remove any DKIM-Signature header fields from + messages they are signing, even if they know that the signatures + cannot be verified. + + When evaluating a message with multiple signatures, a verifier SHOULD + evaluate signatures independently and on their own merits. For + example, a verifier that by policy chooses not to accept signatures + with deprecated cryptographic algorithms would consider such + signatures invalid. Verifiers MAY process signatures in any order of + + + +Allman, et al. Standards Track [Page 33] + +RFC 4871 DKIM Signatures May 2007 + + + their choice; for example, some verifiers might choose to process + signatures corresponding to the From field in the message header + before other signatures. See Section 6.1 for more information about + signature choices. + + INFORMATIVE IMPLEMENTATION NOTE: Verifier attempts to correlate + valid signatures with invalid signatures in an attempt to guess + why a signature failed are ill-advised. In particular, there is + no general way that a verifier can determine that an invalid + signature was ever valid. + + Verifiers SHOULD ignore failed signatures as though they were not + present in the message. Verifiers SHOULD continue to check + signatures until a signature successfully verifies to the + satisfaction of the verifier. To limit potential denial-of-service + attacks, verifiers MAY limit the total number of signatures they will + attempt to verify. + +5. Signer Actions + + The following steps are performed in order by signers. + +5.1. Determine Whether the Email Should Be Signed and by Whom + + A signer can obviously only sign email for domains for which it has a + private key and the necessary knowledge of the corresponding public + key and selector information. However, there are a number of other + reasons beyond the lack of a private key why a signer could choose + not to sign an email. + + INFORMATIVE NOTE: Signing modules may be incorporated into any + portion of the mail system as deemed appropriate, including an + MUA, a SUBMISSION server, or an MTA. Wherever implemented, + signers should beware of signing (and thereby asserting + responsibility for) messages that may be problematic. In + particular, within a trusted enclave the signing address might be + derived from the header according to local policy; SUBMISSION + servers might only sign messages from users that are properly + authenticated and authorized. + + INFORMATIVE IMPLEMENTER ADVICE: SUBMISSION servers should not sign + Received header fields if the outgoing gateway MTA obfuscates + Received header fields, for example, to hide the details of + internal topology. + + If an email cannot be signed for some reason, it is a local policy + decision as to what to do with that email. + + + + +Allman, et al. Standards Track [Page 34] + +RFC 4871 DKIM Signatures May 2007 + + +5.2. Select a Private Key and Corresponding Selector Information + + This specification does not define the basis by which a signer should + choose which private key and selector information to use. Currently, + all selectors are equal as far as this specification is concerned, so + the decision should largely be a matter of administrative + convenience. Distribution and management of private keys is also + outside the scope of this document. + + INFORMATIVE OPERATIONS ADVICE: A signer should not sign with a + private key when the selector containing the corresponding public + key is expected to be revoked or removed before the verifier has + an opportunity to validate the signature. The signer should + anticipate that verifiers may choose to defer validation, perhaps + until the message is actually read by the final recipient. In + particular, when rotating to a new key pair, signing should + immediately commence with the new private key and the old public + key should be retained for a reasonable validation interval before + being removed from the key server. + +5.3. Normalize the Message to Prevent Transport Conversions + + Some messages, particularly those using 8-bit characters, are subject + to modification during transit, notably conversion to 7-bit form. + Such conversions will break DKIM signatures. In order to minimize + the chances of such breakage, signers SHOULD convert the message to a + suitable MIME content transfer encoding such as quoted-printable or + base64 as described in MIME Part One [RFC2045] before signing. Such + conversion is outside the scope of DKIM; the actual message SHOULD be + converted to 7-bit MIME by an MUA or MSA prior to presentation to the + DKIM algorithm. + + If the message is submitted to the signer with any local encoding + that will be modified before transmission, that modification to + canonical [RFC2822] form MUST be done before signing. In particular, + bare CR or LF characters (used by some systems as a local line + separator convention) MUST be converted to the SMTP-standard CRLF + sequence before the message is signed. Any conversion of this sort + SHOULD be applied to the message actually sent to the recipient(s), + not just to the version presented to the signing algorithm. + + More generally, the signer MUST sign the message as it is expected to + be received by the verifier rather than in some local or internal + form. + + + + + + + +Allman, et al. Standards Track [Page 35] + +RFC 4871 DKIM Signatures May 2007 + + +5.4. Determine the Header Fields to Sign + + The From header field MUST be signed (that is, included in the "h=" + tag of the resulting DKIM-Signature header field). Signers SHOULD + NOT sign an existing header field likely to be legitimately modified + or removed in transit. In particular, [RFC2821] explicitly permits + modification or removal of the Return-Path header field in transit. + Signers MAY include any other header fields present at the time of + signing at the discretion of the signer. + + INFORMATIVE OPERATIONS NOTE: The choice of which header fields to + sign is non-obvious. One strategy is to sign all existing, non- + repeatable header fields. An alternative strategy is to sign only + header fields that are likely to be displayed to or otherwise be + likely to affect the processing of the message at the receiver. A + third strategy is to sign only "well known" headers. Note that + verifiers may treat unsigned header fields with extreme + skepticism, including refusing to display them to the end user or + even ignoring the signature if it does not cover certain header + fields. For this reason, signing fields present in the message + such as Date, Subject, Reply-To, Sender, and all MIME header + fields are highly advised. + + The DKIM-Signature header field is always implicitly signed and MUST + NOT be included in the "h=" tag except to indicate that other + preexisting signatures are also signed. + + Signers MAY claim to have signed header fields that do not exist + (that is, signers MAY include the header field name in the "h=" tag + even if that header field does not exist in the message). When + computing the signature, the non-existing header field MUST be + treated as the null string (including the header field name, header + field value, all punctuation, and the trailing CRLF). + + INFORMATIVE RATIONALE: This allows signers to explicitly assert + the absence of a header field; if that header field is added later + the signature will fail. + + INFORMATIVE NOTE: A header field name need only be listed once + more than the actual number of that header field in a message at + the time of signing in order to prevent any further additions. + For example, if there is a single Comments header field at the + time of signing, listing Comments twice in the "h=" tag is + sufficient to prevent any number of Comments header fields from + being appended; it is not necessary (but is legal) to list + Comments three or more times in the "h=" tag. + + + + + +Allman, et al. Standards Track [Page 36] + +RFC 4871 DKIM Signatures May 2007 + + + Signers choosing to sign an existing header field that occurs more + than once in the message (such as Received) MUST sign the physically + last instance of that header field in the header block. Signers + wishing to sign multiple instances of such a header field MUST + include the header field name multiple times in the h= tag of the + DKIM-Signature header field, and MUST sign such header fields in + order from the bottom of the header field block to the top. The + signer MAY include more instances of a header field name in h= than + there are actual corresponding header fields to indicate that + additional header fields of that name SHOULD NOT be added. + + INFORMATIVE EXAMPLE: + + If the signer wishes to sign two existing Received header fields, + and the existing header contains: + + Received: + Received: + Received: + + then the resulting DKIM-Signature header field should read: + + DKIM-Signature: ... h=Received : Received : ... + + and Received header fields and will be signed in that + order. + + Signers should be careful of signing header fields that might have + additional instances added later in the delivery process, since such + header fields might be inserted after the signed instance or + otherwise reordered. Trace header fields (such as Received) and + Resent-* blocks are the only fields prohibited by [RFC2822] from + being reordered. In particular, since DKIM-Signature header fields + may be reordered by some intermediate MTAs, signing existing DKIM- + Signature header fields is error-prone. + + INFORMATIVE ADMONITION: Despite the fact that [RFC2822] permits + header fields to be reordered (with the exception of Received + header fields), reordering of signed header fields with multiple + instances by intermediate MTAs will cause DKIM signatures to be + broken; such anti-social behavior should be avoided. + + INFORMATIVE IMPLEMENTER'S NOTE: Although not required by this + specification, all end-user visible header fields should be signed + to avoid possible "indirect spamming". For example, if the + Subject header field is not signed, a spammer can resend a + previously signed mail, replacing the legitimate subject with a + one-line spam. + + + +Allman, et al. Standards Track [Page 37] + +RFC 4871 DKIM Signatures May 2007 + + +5.5. Recommended Signature Content + + In order to maximize compatibility with a variety of verifiers, it is + recommended that signers follow the practices outlined in this + section when signing a message. However, these are generic + recommendations applying to the general case; specific senders may + wish to modify these guidelines as required by their unique + situations. Verifiers MUST be capable of verifying signatures even + if one or more of the recommended header fields is not signed (with + the exception of From, which must always be signed) or if one or more + of the disrecommended header fields is signed. Note that verifiers + do have the option of ignoring signatures that do not cover a + sufficient portion of the header or body, just as they may ignore + signatures from an identity they do not trust. + + The following header fields SHOULD be included in the signature, if + they are present in the message being signed: + + o From (REQUIRED in all signatures) + + o Sender, Reply-To + + o Subject + + o Date, Message-ID + + o To, Cc + + o MIME-Version + + o Content-Type, Content-Transfer-Encoding, Content-ID, Content- + Description + + o Resent-Date, Resent-From, Resent-Sender, Resent-To, Resent-Cc, + Resent-Message-ID + + o In-Reply-To, References + + o List-Id, List-Help, List-Unsubscribe, List-Subscribe, List-Post, + List-Owner, List-Archive + + The following header fields SHOULD NOT be included in the signature: + + o Return-Path + + o Received + + o Comments, Keywords + + + +Allman, et al. Standards Track [Page 38] + +RFC 4871 DKIM Signatures May 2007 + + + o Bcc, Resent-Bcc + + o DKIM-Signature + + Optional header fields (those not mentioned above) normally SHOULD + NOT be included in the signature, because of the potential for + additional header fields of the same name to be legitimately added or + reordered prior to verification. There are likely to be legitimate + exceptions to this rule, because of the wide variety of application- + specific header fields that may be applied to a message, some of + which are unlikely to be duplicated, modified, or reordered. + + Signers SHOULD choose canonicalization algorithms based on the types + of messages they process and their aversion to risk. For example, + e-commerce sites sending primarily purchase receipts, which are not + expected to be processed by mailing lists or other software likely to + modify messages, will generally prefer "simple" canonicalization. + Sites sending primarily person-to-person email will likely prefer to + be more resilient to modification during transport by using "relaxed" + canonicalization. + + Signers SHOULD NOT use "l=" unless they intend to accommodate + intermediate mail processors that append text to a message. For + example, many mailing list processors append "unsubscribe" + information to message bodies. If signers use "l=", they SHOULD + include the entire message body existing at the time of signing in + computing the count. In particular, signers SHOULD NOT specify a + body length of 0 since this may be interpreted as a meaningless + signature by some verifiers. + +5.6. Compute the Message Hash and Signature + + The signer MUST compute the message hash as described in Section 3.7 + and then sign it using the selected public-key algorithm. This will + result in a DKIM-Signature header field that will include the body + hash and a signature of the header hash, where that header includes + the DKIM-Signature header field itself. + + Entities such as mailing list managers that implement DKIM and that + modify the message or a header field (for example, inserting + unsubscribe information) before retransmitting the message SHOULD + check any existing signature on input and MUST make such + modifications before re-signing the message. + + The signer MAY elect to limit the number of bytes of the body that + will be included in the hash and hence signed. The length actually + hashed should be inserted in the "l=" tag of the DKIM-Signature + header field. + + + +Allman, et al. Standards Track [Page 39] + +RFC 4871 DKIM Signatures May 2007 + + +5.7. Insert the DKIM-Signature Header Field + + Finally, the signer MUST insert the DKIM-Signature header field + created in the previous step prior to transmitting the email. The + DKIM-Signature header field MUST be the same as used to compute the + hash as described above, except that the value of the "b=" tag MUST + be the appropriately signed hash computed in the previous step, + signed using the algorithm specified in the "a=" tag of the DKIM- + Signature header field and using the private key corresponding to the + selector given in the "s=" tag of the DKIM-Signature header field, as + chosen above in Section 5.2 + + The DKIM-Signature header field MUST be inserted before any other + DKIM-Signature fields in the header block. + + INFORMATIVE IMPLEMENTATION NOTE: The easiest way to achieve this + is to insert the DKIM-Signature header field at the beginning of + the header block. In particular, it may be placed before any + existing Received header fields. This is consistent with treating + DKIM-Signature as a trace header field. + +6. Verifier Actions + + Since a signer MAY remove or revoke a public key at any time, it is + recommended that verification occur in a timely manner. In many + configurations, the most timely place is during acceptance by the + border MTA or shortly thereafter. In particular, deferring + verification until the message is accessed by the end user is + discouraged. + + A border or intermediate MTA MAY verify the message signature(s). An + MTA who has performed verification MAY communicate the result of that + verification by adding a verification header field to incoming + messages. This considerably simplifies things for the user, who can + now use an existing mail user agent. Most MUAs have the ability to + filter messages based on message header fields or content; these + filters would be used to implement whatever policy the user wishes + with respect to unsigned mail. + + A verifying MTA MAY implement a policy with respect to unverifiable + mail, regardless of whether or not it applies the verification header + field to signed messages. + + Verifiers MUST produce a result that is semantically equivalent to + applying the following steps in the order listed. In practice, + several of these steps can be performed in parallel in order to + improve performance. + + + + +Allman, et al. Standards Track [Page 40] + +RFC 4871 DKIM Signatures May 2007 + + +6.1. Extract Signatures from the Message + + The order in which verifiers try DKIM-Signature header fields is not + defined; verifiers MAY try signatures in any order they like. For + example, one implementation might try the signatures in textual + order, whereas another might try signatures by identities that match + the contents of the From header field before trying other signatures. + Verifiers MUST NOT attribute ultimate meaning to the order of + multiple DKIM-Signature header fields. In particular, there is + reason to believe that some relays will reorder the header fields in + potentially arbitrary ways. + + INFORMATIVE IMPLEMENTATION NOTE: Verifiers might use the order as + a clue to signing order in the absence of any other information. + However, other clues as to the semantics of multiple signatures + (such as correlating the signing host with Received header fields) + may also be considered. + + A verifier SHOULD NOT treat a message that has one or more bad + signatures and no good signatures differently from a message with no + signature at all; such treatment is a matter of local policy and is + beyond the scope of this document. + + When a signature successfully verifies, a verifier will either stop + processing or attempt to verify any other signatures, at the + discretion of the implementation. A verifier MAY limit the number of + signatures it tries to avoid denial-of-service attacks. + + INFORMATIVE NOTE: An attacker could send messages with large + numbers of faulty signatures, each of which would require a DNS + lookup and corresponding CPU time to verify the message. This + could be an attack on the domain that receives the message, by + slowing down the verifier by requiring it to do a large number of + DNS lookups and/or signature verifications. It could also be an + attack against the domains listed in the signatures, essentially + by enlisting innocent verifiers in launching an attack against the + DNS servers of the actual victim. + + In the following description, text reading "return status + (explanation)" (where "status" is one of "PERMFAIL" or "TEMPFAIL") + means that the verifier MUST immediately cease processing that + signature. The verifier SHOULD proceed to the next signature, if any + is present, and completely ignore the bad signature. If the status + is "PERMFAIL", the signature failed and should not be reconsidered. + If the status is "TEMPFAIL", the signature could not be verified at + this time but may be tried again later. A verifier MAY either defer + the message for later processing, perhaps by queueing it locally or + issuing a 451/4.7.5 SMTP reply, or try another signature; if no good + + + +Allman, et al. Standards Track [Page 41] + +RFC 4871 DKIM Signatures May 2007 + + + signature is found and any of the signatures resulted in a TEMPFAIL + status, the verifier MAY save the message for later processing. The + "(explanation)" is not normative text; it is provided solely for + clarification. + + Verifiers SHOULD ignore any DKIM-Signature header fields where the + signature does not validate. Verifiers that are prepared to validate + multiple signature header fields SHOULD proceed to the next signature + header field, should it exist. However, verifiers MAY make note of + the fact that an invalid signature was present for consideration at a + later step. + + INFORMATIVE NOTE: The rationale of this requirement is to permit + messages that have invalid signatures but also a valid signature + to work. For example, a mailing list exploder might opt to leave + the original submitter signature in place even though the exploder + knows that it is modifying the message in some way that will break + that signature, and the exploder inserts its own signature. In + this case, the message should succeed even in the presence of the + known-broken signature. + + For each signature to be validated, the following steps should be + performed in such a manner as to produce a result that is + semantically equivalent to performing them in the indicated order. + +6.1.1. Validate the Signature Header Field + + Implementers MUST meticulously validate the format and values in the + DKIM-Signature header field; any inconsistency or unexpected values + MUST cause the header field to be completely ignored and the verifier + to return PERMFAIL (signature syntax error). Being "liberal in what + you accept" is definitely a bad strategy in this security context. + Note however that this does not include the existence of unknown tags + in a DKIM-Signature header field, which are explicitly permitted. + + Verifiers MUST ignore DKIM-Signature header fields with a "v=" tag + that is inconsistent with this specification and return PERMFAIL + (incompatible version). + + INFORMATIVE IMPLEMENTATION NOTE: An implementation may, of course, + choose to also verify signatures generated by older versions of + this specification. + + If any tag listed as "required" in Section 3.5 is omitted from the + DKIM-Signature header field, the verifier MUST ignore the DKIM- + Signature header field and return PERMFAIL (signature missing + required tag). + + + + +Allman, et al. Standards Track [Page 42] + +RFC 4871 DKIM Signatures May 2007 + + + INFORMATIONAL NOTE: The tags listed as required in Section 3.5 are + "v=", "a=", "b=", "bh=", "d=", "h=", and "s=". Should there be a + conflict between this note and Section 3.5, Section 3.5 is + normative. + + If the DKIM-Signature header field does not contain the "i=" tag, the + verifier MUST behave as though the value of that tag were "@d", where + "d" is the value from the "d=" tag. + + Verifiers MUST confirm that the domain specified in the "d=" tag is + the same as or a parent domain of the domain part of the "i=" tag. + If not, the DKIM-Signature header field MUST be ignored and the + verifier should return PERMFAIL (domain mismatch). + + If the "h=" tag does not include the From header field, the verifier + MUST ignore the DKIM-Signature header field and return PERMFAIL (From + field not signed). + + Verifiers MAY ignore the DKIM-Signature header field and return + PERMFAIL (signature expired) if it contains an "x=" tag and the + signature has expired. + + Verifiers MAY ignore the DKIM-Signature header field if the domain + used by the signer in the "d=" tag is not associated with a valid + signing entity. For example, signatures with "d=" values such as + "com" and "co.uk" may be ignored. The list of unacceptable domains + SHOULD be configurable. + + Verifiers MAY ignore the DKIM-Signature header field and return + PERMFAIL (unacceptable signature header) for any other reason, for + example, if the signature does not sign header fields that the + verifier views to be essential. As a case in point, if MIME header + fields are not signed, certain attacks may be possible that the + verifier would prefer to avoid. + +6.1.2. Get the Public Key + + The public key for a signature is needed to complete the verification + process. The process of retrieving the public key depends on the + query type as defined by the "q=" tag in the DKIM-Signature header + field. Obviously, a public key need only be retrieved if the process + of extracting the signature information is completely successful. + Details of key management and representation are described in + Section 3.6. The verifier MUST validate the key record and MUST + ignore any public key records that are malformed. + + When validating a message, a verifier MUST perform the following + steps in a manner that is semantically the same as performing them in + + + +Allman, et al. Standards Track [Page 43] + +RFC 4871 DKIM Signatures May 2007 + + + the order indicated (in some cases, the implementation may + parallelize or reorder these steps, as long as the semantics remain + unchanged): + + 1. Retrieve the public key as described in Section 3.6 using the + algorithm in the "q=" tag, the domain from the "d=" tag, and the + selector from the "s=" tag. + + 2. If the query for the public key fails to respond, the verifier + MAY defer acceptance of this email and return TEMPFAIL (key + unavailable). If verification is occurring during the incoming + SMTP session, this MAY be achieved with a 451/4.7.5 SMTP reply + code. Alternatively, the verifier MAY store the message in the + local queue for later trial or ignore the signature. Note that + storing a message in the local queue is subject to denial-of- + service attacks. + + 3. If the query for the public key fails because the corresponding + key record does not exist, the verifier MUST immediately return + PERMFAIL (no key for signature). + + 4. If the query for the public key returns multiple key records, the + verifier may choose one of the key records or may cycle through + the key records performing the remainder of these steps on each + record at the discretion of the implementer. The order of the + key records is unspecified. If the verifier chooses to cycle + through the key records, then the "return ..." wording in the + remainder of this section means "try the next key record, if any; + if none, return to try another signature in the usual way". + + 5. If the result returned from the query does not adhere to the + format defined in this specification, the verifier MUST ignore + the key record and return PERMFAIL (key syntax error). Verifiers + are urged to validate the syntax of key records carefully to + avoid attempted attacks. In particular, the verifier MUST ignore + keys with a version code ("v=" tag) that they do not implement. + + 6. If the "g=" tag in the public key does not match the Local-part + of the "i=" tag in the message signature header field, the + verifier MUST ignore the key record and return PERMFAIL + (inapplicable key). If the Local-part of the "i=" tag on the + message signature is not present, the "g=" tag must be "*" (valid + for all addresses in the domain) or the entire g= tag must be + omitted (which defaults to "g=*"), otherwise the verifier MUST + ignore the key record and return PERMFAIL (inapplicable key). + Other than this test, verifiers SHOULD NOT treat a message signed + with a key record having a "g=" tag any differently than one + without; in particular, verifiers SHOULD NOT prefer messages that + + + +Allman, et al. Standards Track [Page 44] + +RFC 4871 DKIM Signatures May 2007 + + + seem to have an individual signature by virtue of a "g=" tag + versus a domain signature. + + 7. If the "h=" tag exists in the public key record and the hash + algorithm implied by the a= tag in the DKIM-Signature header + field is not included in the contents of the "h=" tag, the + verifier MUST ignore the key record and return PERMFAIL + (inappropriate hash algorithm). + + 8. If the public key data (the "p=" tag) is empty, then this key has + been revoked and the verifier MUST treat this as a failed + signature check and return PERMFAIL (key revoked). There is no + defined semantic difference between a key that has been revoked + and a key record that has been removed. + + 9. If the public key data is not suitable for use with the algorithm + and key types defined by the "a=" and "k=" tags in the DKIM- + Signature header field, the verifier MUST immediately return + PERMFAIL (inappropriate key algorithm). + +6.1.3. Compute the Verification + + Given a signer and a public key, verifying a signature consists of + actions semantically equivalent to the following steps. + + 1. Based on the algorithm defined in the "c=" tag, the body length + specified in the "l=" tag, and the header field names in the "h=" + tag, prepare a canonicalized version of the message as is + described in Section 3.7 (note that this version does not + actually need to be instantiated). When matching header field + names in the "h=" tag against the actual message header field, + comparisons MUST be case-insensitive. + + 2. Based on the algorithm indicated in the "a=" tag, compute the + message hashes from the canonical copy as described in + Section 3.7. + + 3. Verify that the hash of the canonicalized message body computed + in the previous step matches the hash value conveyed in the "bh=" + tag. If the hash does not match, the verifier SHOULD ignore the + signature and return PERMFAIL (body hash did not verify). + + 4. Using the signature conveyed in the "b=" tag, verify the + signature against the header hash using the mechanism appropriate + for the public key algorithm described in the "a=" tag. If the + signature does not validate, the verifier SHOULD ignore the + signature and return PERMFAIL (signature did not verify). + + + + +Allman, et al. Standards Track [Page 45] + +RFC 4871 DKIM Signatures May 2007 + + + 5. Otherwise, the signature has correctly verified. + + INFORMATIVE IMPLEMENTER'S NOTE: Implementations might wish to + initiate the public-key query in parallel with calculating the + hash as the public key is not needed until the final decryption is + calculated. Implementations may also verify the signature on the + message header before validating that the message hash listed in + the "bh=" tag in the DKIM-Signature header field matches that of + the actual message body; however, if the body hash does not match, + the entire signature must be considered to have failed. + + A body length specified in the "l=" tag of the signature limits the + number of bytes of the body passed to the verification algorithm. + All data beyond that limit is not validated by DKIM. Hence, + verifiers might treat a message that contains bytes beyond the + indicated body length with suspicion, such as by truncating the + message at the indicated body length, declaring the signature invalid + (e.g., by returning PERMFAIL (unsigned content)), or conveying the + partial verification to the policy module. + + INFORMATIVE IMPLEMENTATION NOTE: Verifiers that truncate the body + at the indicated body length might pass on a malformed MIME + message if the signer used the "N-4" trick (omitting the final + "--CRLF") described in the informative note in Section 3.4.5. + Such verifiers may wish to check for this case and include a + trailing "--CRLF" to avoid breaking the MIME structure. A simple + way to achieve this might be to append "--CRLF" to any "multipart" + message with a body length; if the MIME structure is already + correctly formed, this will appear in the postlude and will not be + displayed to the end user. + +6.2. Communicate Verification Results + + Verifiers wishing to communicate the results of verification to other + parts of the mail system may do so in whatever manner they see fit. + For example, implementations might choose to add an email header + field to the message before passing it on. Any such header field + SHOULD be inserted before any existing DKIM-Signature or preexisting + authentication status header fields in the header field block. + + INFORMATIVE ADVICE to MUA filter writers: Patterns intended to + search for results header fields to visibly mark authenticated + mail for end users should verify that such header field was added + by the appropriate verifying domain and that the verified identity + matches the author identity that will be displayed by the MUA. In + particular, MUA filters should not be influenced by bogus results + + + + + +Allman, et al. Standards Track [Page 46] + +RFC 4871 DKIM Signatures May 2007 + + + header fields added by attackers. To circumvent this attack, + verifiers may wish to delete existing results header fields after + verification and before adding a new header field. + +6.3. Interpret Results/Apply Local Policy + + It is beyond the scope of this specification to describe what actions + a verifier system should make, but an authenticated email presents an + opportunity to a receiving system that unauthenticated email cannot. + Specifically, an authenticated email creates a predictable identifier + by which other decisions can reliably be managed, such as trust and + reputation. Conversely, unauthenticated email lacks a reliable + identifier that can be used to assign trust and reputation. It is + reasonable to treat unauthenticated email as lacking any trust and + having no positive reputation. + + In general, verifiers SHOULD NOT reject messages solely on the basis + of a lack of signature or an unverifiable signature; such rejection + would cause severe interoperability problems. However, if the + verifier does opt to reject such messages (for example, when + communicating with a peer who, by prior agreement, agrees to only + send signed messages), and the verifier runs synchronously with the + SMTP session and a signature is missing or does not verify, the MTA + SHOULD use a 550/5.7.x reply code. + + If it is not possible to fetch the public key, perhaps because the + key server is not available, a temporary failure message MAY be + generated using a 451/4.7.5 reply code, such as: + + 451 4.7.5 Unable to verify signature - key server unavailable + + Temporary failures such as inability to access the key server or + other external service are the only conditions that SHOULD use a 4xx + SMTP reply code. In particular, cryptographic signature verification + failures MUST NOT return 4xx SMTP replies. + + Once the signature has been verified, that information MUST be + conveyed to higher-level systems (such as explicit allow/whitelists + and reputation systems) and/or to the end user. If the message is + signed on behalf of any address other than that in the From: header + field, the mail system SHOULD take pains to ensure that the actual + signing identity is clear to the reader. + + The verifier MAY treat unsigned header fields with extreme + skepticism, including marking them as untrusted or even deleting them + before display to the end user. + + + + + +Allman, et al. Standards Track [Page 47] + +RFC 4871 DKIM Signatures May 2007 + + + While the symptoms of a failed verification are obvious -- the + signature doesn't verify -- establishing the exact cause can be more + difficult. If a selector cannot be found, is that because the + selector has been removed, or was the value changed somehow in + transit? If the signature line is missing, is that because it was + never there, or was it removed by an overzealous filter? For + diagnostic purposes, the exact reason why the verification fails + SHOULD be made available to the policy module and possibly recorded + in the system logs. If the email cannot be verified, then it SHOULD + be rendered the same as all unverified email regardless of whether or + not it looks like it was signed. + +7. IANA Considerations + + DKIM introduces some new namespaces that have been registered with + IANA. In all cases, new values are assigned only for values that + have been documented in a published RFC that has IETF Consensus + [RFC2434]. + +7.1. DKIM-Signature Tag Specifications + + A DKIM-Signature provides for a list of tag specifications. IANA has + established the DKIM-Signature Tag Specification Registry for tag + specifications that can be used in DKIM-Signature fields. + + The initial entries in the registry comprise: + + +------+-----------------+ + | TYPE | REFERENCE | + +------+-----------------+ + | v | (this document) | + | a | (this document) | + | b | (this document) | + | bh | (this document) | + | c | (this document) | + | d | (this document) | + | h | (this document) | + | i | (this document) | + | l | (this document) | + | q | (this document) | + | s | (this document) | + | t | (this document) | + | x | (this document) | + | z | (this document) | + +------+-----------------+ + + DKIM-Signature Tag Specification Registry Initial Values + + + + +Allman, et al. Standards Track [Page 48] + +RFC 4871 DKIM Signatures May 2007 + + +7.2. DKIM-Signature Query Method Registry + + The "q=" tag-spec (specified in Section 3.5) provides for a list of + query methods. + + IANA has established the DKIM-Signature Query Method Registry for + mechanisms that can be used to retrieve the key that will permit + validation processing of a message signed using DKIM. + + The initial entry in the registry comprises: + + +------+--------+-----------------+ + | TYPE | OPTION | REFERENCE | + +------+--------+-----------------+ + | dns | txt | (this document) | + +------+--------+-----------------+ + + DKIM-Signature Query Method Registry Initial Values + +7.3. DKIM-Signature Canonicalization Registry + + The "c=" tag-spec (specified in Section 3.5) provides for a specifier + for canonicalization algorithms for the header and body of the + message. + + IANA has established the DKIM-Signature Canonicalization Algorithm + Registry for algorithms for converting a message into a canonical + form before signing or verifying using DKIM. + + The initial entries in the header registry comprise: + + +---------+-----------------+ + | TYPE | REFERENCE | + +---------+-----------------+ + | simple | (this document) | + | relaxed | (this document) | + +---------+-----------------+ + + DKIM-Signature Header Canonicalization Algorithm Registry + Initial Values + + + + + + + + + + + +Allman, et al. Standards Track [Page 49] + +RFC 4871 DKIM Signatures May 2007 + + + The initial entries in the body registry comprise: + + +---------+-----------------+ + | TYPE | REFERENCE | + +---------+-----------------+ + | simple | (this document) | + | relaxed | (this document) | + +---------+-----------------+ + + DKIM-Signature Body Canonicalization Algorithm Registry + Initial Values + +7.4. _domainkey DNS TXT Record Tag Specifications + + A _domainkey DNS TXT record provides for a list of tag + specifications. IANA has established the DKIM _domainkey DNS TXT Tag + Specification Registry for tag specifications that can be used in DNS + TXT Records. + + The initial entries in the registry comprise: + + +------+-----------------+ + | TYPE | REFERENCE | + +------+-----------------+ + | v | (this document) | + | g | (this document) | + | h | (this document) | + | k | (this document) | + | n | (this document) | + | p | (this document) | + | s | (this document) | + | t | (this document) | + +------+-----------------+ + + DKIM _domainkey DNS TXT Record Tag Specification Registry + Initial Values + +7.5. DKIM Key Type Registry + + The "k=" (specified in Section 3.6.1) and the "a=" (specified in Section 3.5) tags provide for a list of + mechanisms that can be used to decode a DKIM signature. + + IANA has established the DKIM Key Type Registry for such mechanisms. + + + + + + + +Allman, et al. Standards Track [Page 50] + +RFC 4871 DKIM Signatures May 2007 + + + The initial entry in the registry comprises: + + +------+-----------+ + | TYPE | REFERENCE | + +------+-----------+ + | rsa | [RFC3447] | + +------+-----------+ + + DKIM Key Type Initial Values + +7.6. DKIM Hash Algorithms Registry + + The "h=" (specified in Section 3.6.1) and the "a=" (specified in Section 3.5) tags provide for a list of + mechanisms that can be used to produce a digest of message data. + + IANA has established the DKIM Hash Algorithms Registry for such + mechanisms. + + The initial entries in the registry comprise: + + +--------+-------------------+ + | TYPE | REFERENCE | + +--------+-------------------+ + | sha1 | [FIPS.180-2.2002] | + | sha256 | [FIPS.180-2.2002] | + +--------+-------------------+ + + DKIM Hash Algorithms Initial Values + +7.7. DKIM Service Types Registry + + The "s=" tag (specified in Section 3.6.1) provides for a + list of service types to which this selector may apply. + + IANA has established the DKIM Service Types Registry for service + types. + + The initial entries in the registry comprise: + + +-------+-----------------+ + | TYPE | REFERENCE | + +-------+-----------------+ + | email | (this document) | + | * | (this document) | + +-------+-----------------+ + + DKIM Service Types Registry Initial Values + + + +Allman, et al. Standards Track [Page 51] + +RFC 4871 DKIM Signatures May 2007 + + +7.8. DKIM Selector Flags Registry + + The "t=" tag (specified in Section 3.6.1) provides for a + list of flags to modify interpretation of the selector. + + IANA has established the DKIM Selector Flags Registry for additional + flags. + + The initial entries in the registry comprise: + + +------+-----------------+ + | TYPE | REFERENCE | + +------+-----------------+ + | y | (this document) | + | s | (this document) | + +------+-----------------+ + + DKIM Selector Flags Registry Initial Values + +7.9. DKIM-Signature Header Field + + IANA has added DKIM-Signature to the "Permanent Message Header + Fields" registry (see [RFC3864]) for the "mail" protocol, using this + document as the reference. + +8. Security Considerations + + It has been observed that any mechanism that is introduced that + attempts to stem the flow of spam is subject to intensive attack. + DKIM needs to be carefully scrutinized to identify potential attack + vectors and the vulnerability to each. See also [RFC4686]. + +8.1. Misuse of Body Length Limits ("l=" Tag) + + Body length limits (in the form of the "l=" tag) are subject to + several potential attacks. + +8.1.1. Addition of New MIME Parts to Multipart/* + + If the body length limit does not cover a closing MIME multipart + section (including the trailing "--CRLF" portion), then it is + possible for an attacker to intercept a properly signed multipart + message and add a new body part. Depending on the details of the + MIME type and the implementation of the verifying MTA and the + receiving MUA, this could allow an attacker to change the information + displayed to an end user from an apparently trusted source. + + + + + +Allman, et al. Standards Track [Page 52] + +RFC 4871 DKIM Signatures May 2007 + + + For example, if attackers can append information to a "text/html" + body part, they may be able to exploit a bug in some MUAs that + continue to read after a "" marker, and thus display HTML text + on top of already displayed text. If a message has a + "multipart/alternative" body part, they might be able to add a new + body part that is preferred by the displaying MUA. + +8.1.2. Addition of new HTML content to existing content + + Several receiving MUA implementations do not cease display after a + """" tag. In particular, this allows attacks involving + overlaying images on top of existing text. + + INFORMATIVE EXAMPLE: Appending the following text to an existing, + properly closed message will in many MUAs result in inappropriate + data being rendered on top of existing, correct data: +
    + +
    + +8.2. Misappropriated Private Key + + If the private key for a user is resident on their computer and is + not protected by an appropriately secure mechanism, it is possible + for malware to send mail as that user and any other user sharing the + same private key. The malware would not, however, be able to + generate signed spoofs of other signers' addresses, which would aid + in identification of the infected user and would limit the + possibilities for certain types of attacks involving socially + engineered messages. This threat applies mainly to MUA-based + implementations; protection of private keys on servers can be easily + achieved through the use of specialized cryptographic hardware. + + A larger problem occurs if malware on many users' computers obtains + the private keys for those users and transmits them via a covert + channel to a site where they can be shared. The compromised users + would likely not know of the misappropriation until they receive + "bounce" messages from messages they are purported to have sent. + Many users might not understand the significance of these bounce + messages and would not take action. + + One countermeasure is to use a user-entered passphrase to encrypt the + private key, although users tend to choose weak passphrases and often + reuse them for different purposes, possibly allowing an attack + against DKIM to be extended into other domains. Nevertheless, the + decoded private key might be briefly available to compromise by + malware when it is entered, or might be discovered via keystroke + + + +Allman, et al. Standards Track [Page 53] + +RFC 4871 DKIM Signatures May 2007 + + + logging. The added complexity of entering a passphrase each time one + sends a message would also tend to discourage the use of a secure + passphrase. + + A somewhat more effective countermeasure is to send messages through + an outgoing MTA that can authenticate the submitter using existing + techniques (e.g., SMTP Authentication), possibly validate the message + itself (e.g., verify that the header is legitimate and that the + content passes a spam content check), and sign the message using a + key appropriate for the submitter address. Such an MTA can also + apply controls on the volume of outgoing mail each user is permitted + to originate in order to further limit the ability of malware to + generate bulk email. + +8.3. Key Server Denial-of-Service Attacks + + Since the key servers are distributed (potentially separate for each + domain), the number of servers that would need to be attacked to + defeat this mechanism on an Internet-wide basis is very large. + Nevertheless, key servers for individual domains could be attacked, + impeding the verification of messages from that domain. This is not + significantly different from the ability of an attacker to deny + service to the mail exchangers for a given domain, although it + affects outgoing, not incoming, mail. + + A variation on this attack is that if a very large amount of mail + were to be sent using spoofed addresses from a given domain, the key + servers for that domain could be overwhelmed with requests. However, + given the low overhead of verification compared with handling of the + email message itself, such an attack would be difficult to mount. + +8.4. Attacks Against the DNS + + Since the DNS is a required binding for key services, specific + attacks against the DNS must be considered. + + While the DNS is currently insecure [RFC3833], these security + problems are the motivation behind DNS Security (DNSSEC) [RFC4033], + and all users of the DNS will reap the benefit of that work. + + DKIM is only intended as a "sufficient" method of proving + authenticity. It is not intended to provide strong cryptographic + proof about authorship or contents. Other technologies such as + OpenPGP [RFC2440] and S/MIME [RFC3851] address those requirements. + + A second security issue related to the DNS revolves around the + increased DNS traffic as a consequence of fetching selector-based + data as well as fetching signing domain policy. Widespread + + + +Allman, et al. Standards Track [Page 54] + +RFC 4871 DKIM Signatures May 2007 + + + deployment of DKIM will result in a significant increase in DNS + queries to the claimed signing domain. In the case of forgeries on a + large scale, DNS servers could see a substantial increase in queries. + + A specific DNS security issue that should be considered by DKIM + verifiers is the name chaining attack described in Section 2.3 of the + DNS Threat Analysis [RFC3833]. A DKIM verifier, while verifying a + DKIM-Signature header field, could be prompted to retrieve a key + record of an attacker's choosing. This threat can be minimized by + ensuring that name servers, including recursive name servers, used by + the verifier enforce strict checking of "glue" and other additional + information in DNS responses and are therefore not vulnerable to this + attack. + +8.5. Replay Attacks + + In this attack, a spammer sends a message to be spammed to an + accomplice, which results in the message being signed by the + originating MTA. The accomplice resends the message, including the + original signature, to a large number of recipients, possibly by + sending the message to many compromised machines that act as MTAs. + The messages, not having been modified by the accomplice, have valid + signatures. + + Partial solutions to this problem involve the use of reputation + services to convey the fact that the specific email address is being + used for spam and that messages from that signer are likely to be + spam. This requires a real-time detection mechanism in order to + react quickly enough. However, such measures might be prone to + abuse, if for example an attacker resent a large number of messages + received from a victim in order to make them appear to be a spammer. + + Large verifiers might be able to detect unusually large volumes of + mails with the same signature in a short time period. Smaller + verifiers can get substantially the same volume of information via + existing collaborative systems. + +8.6. Limits on Revoking Keys + + When a large domain detects undesirable behavior on the part of one + of its users, it might wish to revoke the key used to sign that + user's messages in order to disavow responsibility for messages that + have not yet been verified or that are the subject of a replay + attack. However, the ability of the domain to do so can be limited + if the same key, for scalability reasons, is used to sign messages + for many other users. Mechanisms for explicitly revoking keys on a + per-address basis have been proposed but require further study as to + their utility and the DNS load they represent. + + + +Allman, et al. Standards Track [Page 55] + +RFC 4871 DKIM Signatures May 2007 + + +8.7. Intentionally Malformed Key Records + + It is possible for an attacker to publish key records in DNS that are + intentionally malformed, with the intent of causing a denial-of- + service attack on a non-robust verifier implementation. The attacker + could then cause a verifier to read the malformed key record by + sending a message to one of its users referencing the malformed + record in a (not necessarily valid) signature. Verifiers MUST + thoroughly verify all key records retrieved from the DNS and be + robust against intentionally as well as unintentionally malformed key + records. + +8.8. Intentionally Malformed DKIM-Signature Header Fields + + Verifiers MUST be prepared to receive messages with malformed DKIM- + Signature header fields, and thoroughly verify the header field + before depending on any of its contents. + +8.9. Information Leakage + + An attacker could determine when a particular signature was verified + by using a per-message selector and then monitoring their DNS traffic + for the key lookup. This would act as the equivalent of a "web bug" + for verification time rather than when the message was read. + +8.10. Remote Timing Attacks + + In some cases, it may be possible to extract private keys using a + remote timing attack [BONEH03]. Implementations should consider + obfuscating the timing to prevent such attacks. + +8.11. Reordered Header Fields + + Existing standards allow intermediate MTAs to reorder header fields. + If a signer signs two or more header fields of the same name, this + can cause spurious verification errors on otherwise legitimate + messages. In particular, signers that sign any existing DKIM- + Signature fields run the risk of having messages incorrectly fail to + verify. + +8.12. RSA Attacks + + An attacker could create a large RSA signing key with a small + exponent, thus requiring that the verification key have a large + exponent. This will force verifiers to use considerable computing + resources to verify the signature. Verifiers might avoid this attack + by refusing to verify signatures that reference selectors with public + keys having unreasonable exponents. + + + +Allman, et al. Standards Track [Page 56] + +RFC 4871 DKIM Signatures May 2007 + + + In general, an attacker might try to overwhelm a verifier by flooding + it with messages requiring verification. This is similar to other + MTA denial-of-service attacks and should be dealt with in a similar + fashion. + +8.13. Inappropriate Signing by Parent Domains + + The trust relationship described in Section 3.8 could conceivably be + used by a parent domain to sign messages with identities in a + subdomain not administratively related to the parent. For example, + the ".com" registry could create messages with signatures using an + "i=" value in the example.com domain. There is no general solution + to this problem, since the administrative cut could occur anywhere in + the domain name. For example, in the domain "example.podunk.ca.us" + there are three administrative cuts (podunk.ca.us, ca.us, and us), + any of which could create messages with an identity in the full + domain. + + INFORMATIVE NOTE: This is considered an acceptable risk for the + same reason that it is acceptable for domain delegation. For + example, in the example above any of the domains could potentially + simply delegate "example.podunk.ca.us" to a server of their choice + and completely replace all DNS-served information. Note that a + verifier MAY ignore signatures that come from an unlikely domain + such as ".com", as discussed in Section 6.1.1. + +9. References + +9.1. Normative References + + [FIPS.180-2.2002] U.S. Department of Commerce, "Secure Hash + Standard", FIPS PUB 180-2, August 2002. + + [ITU.X660.1997] "Information Technology - ASN.1 encoding rules: + Specification of Basic Encoding Rules (BER), + Canonical Encoding Rules (CER) and Distinguished + Encoding Rules (DER)", ITU-T Recommendation X.660, + 1997. + + [RFC2045] Freed, N. and N. Borenstein, "Multipurpose + Internet Mail Extensions (MIME) Part One: Format + of Internet Message Bodies", RFC 2045, + November 1996. + + [RFC2047] Moore, K., "MIME (Multipurpose Internet Mail + Extensions) Part Three: Message header field + Extensions for Non-ASCII Text", RFC 2047, + November 1996. + + + +Allman, et al. Standards Track [Page 57] + +RFC 4871 DKIM Signatures May 2007 + + + [RFC2119] Bradner, S., "Key words for use in RFCs to + Indicate Requirement Levels", BCP 14, RFC 2119, + March 1997. + + [RFC2821] Klensin, J., "Simple Mail Transfer Protocol", + RFC 2821, April 2001. + + [RFC2822] Resnick, P., "Internet Message Format", RFC 2822, + April 2001. + + [RFC3447] Jonsson, J. and B. Kaliski, "Public-Key + Cryptography Standards (PKCS) #1: RSA Cryptography + Specifications Version 2.1", RFC 3447, + February 2003. + + [RFC3490] Faltstrom, P., Hoffman, P., and A. Costello, + "Internationalizing Domain Names in Applications + (IDNA)", RFC 3490, March 2003. + + [RFC4234] Crocker, D., Ed. and P. Overell, "Augmented BNF + for Syntax Specifications: ABNF", RFC 4234, + October 2005. + +9.2. Informative References + + [BONEH03] Proc. 12th USENIX Security Symposium, "Remote + Timing Attacks are Practical", 2003. + + [RFC1847] Galvin, J., Murphy, S., Crocker, S., and N. Freed, + "Security Multiparts for MIME: Multipart/Signed + and Multipart/Encrypted", RFC 1847, October 1995. + + [RFC2434] Narten, T. and H. Alvestrand, "Guidelines for + Writing an IANA Considerations Section in RFCs", + BCP 26, RFC 2434, October 1998. + + [RFC2440] Callas, J., Donnerhacke, L., Finney, H., and R. + Thayer, "OpenPGP Message Format", RFC 2440, + November 1998. + + [RFC3766] Orman, H. and P. Hoffman, "Determining Strengths + for Public Keys Used For Exchanging Symmetric + Keys", RFC 3766, April 2004. + + [RFC3833] Atkins, D. and R. Austein, "Threat Analysis of the + Domain Name System (DNS)", RFC 3833, August 2004. + + + + + +Allman, et al. Standards Track [Page 58] + +RFC 4871 DKIM Signatures May 2007 + + + [RFC3851] Ramsdell, B., "S/MIME Version 3 Message + Specification", RFC 3851, June 1999. + + [RFC3864] Klyne, G., Nottingham, M., and J. Mogul, + "Registration Procedures for Message Header + Fields", BCP 90, September 2004. + + [RFC4033] Arends, R., Austein, R., Larson, M., Massey, D., + and S. Rose, "DNS Security Introduction and + Requirements", RFC 4033, March 2005. + + [RFC4686] Fenton, J., "Analysis of Threats Motivating + DomainKeys Identified Mail (DKIM)", RFC 4686, + September 2006. + + [RFC4870] Delany, M., "Domain-Based Email Authentication + Using Public Keys Advertised in the DNS + (DomainKeys)", RFC 4870, May 2007. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Allman, et al. Standards Track [Page 59] + +RFC 4871 DKIM Signatures May 2007 + + +Appendix A. Example of Use (INFORMATIVE) + + This section shows the complete flow of an email from submission to + final delivery, demonstrating how the various components fit + together. The key used in this example is shown in Appendix C. + +A.1. The User Composes an Email + + + From: Joe SixPack + To: Suzie Q + Subject: Is dinner ready? + Date: Fri, 11 Jul 2003 21:00:37 -0700 (PDT) + Message-ID: <20030712040037.46341.5F8J@football.example.com> + + Hi. + + We lost the game. Are you hungry yet? + + Joe. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Allman, et al. Standards Track [Page 60] + +RFC 4871 DKIM Signatures May 2007 + + +A.2. The Email Is Signed + + This email is signed by the example.com outbound email server and now + looks like this: + + DKIM-Signature: v=1; a=rsa-sha256; s=brisbane; d=example.com; + c=simple/simple; q=dns/txt; i=joe@football.example.com; + h=Received : From : To : Subject : Date : Message-ID; + bh=2jUSOH9NhtVGCQWNr9BrIAPreKQjO6Sn7XIkfJVOzv8=; + b=AuUoFEfDxTDkHlLXSZEpZj79LICEps6eda7W3deTVFOk4yAUoqOB + 4nujc7YopdG5dWLSdNg6xNAZpOPr+kHxt1IrE+NahM6L/LbvaHut + KVdkLLkpVaVVQPzeRDI009SO2Il5Lu7rDNH6mZckBdrIx0orEtZV + 4bmp/YzhwvcubU4=; + Received: from client1.football.example.com [192.0.2.1] + by submitserver.example.com with SUBMISSION; + Fri, 11 Jul 2003 21:01:54 -0700 (PDT) + From: Joe SixPack + To: Suzie Q + Subject: Is dinner ready? + Date: Fri, 11 Jul 2003 21:00:37 -0700 (PDT) + Message-ID: <20030712040037.46341.5F8J@football.example.com> + + Hi. + + We lost the game. Are you hungry yet? + + Joe. + + The signing email server requires access to the private key + associated with the "brisbane" selector to generate this signature. + +A.3. The Email Signature Is Verified + + The signature is normally verified by an inbound SMTP server or + possibly the final delivery agent. However, intervening MTAs can + also perform this verification if they choose to do so. The + verification process uses the domain "example.com" extracted from the + "d=" tag and the selector "brisbane" from the "s=" tag in the DKIM- + Signature header field to form the DNS DKIM query for: + + brisbane._domainkey.example.com + + Signature verification starts with the physically last Received + header field, the From header field, and so forth, in the order + listed in the "h=" tag. Verification follows with a single CRLF + followed by the body (starting with "Hi."). The email is canonically + prepared for verifying with the "simple" method. The result of the + query and subsequent verification of the signature is stored (in this + + + +Allman, et al. Standards Track [Page 61] + +RFC 4871 DKIM Signatures May 2007 + + + example) in the X-Authentication-Results header field line. After + successful verification, the email looks like this: + + X-Authentication-Results: shopping.example.net + header.from=joe@football.example.com; dkim=pass + Received: from mout23.football.example.com (192.168.1.1) + by shopping.example.net with SMTP; + Fri, 11 Jul 2003 21:01:59 -0700 (PDT) + DKIM-Signature: v=1; a=rsa-sha256; s=brisbane; d=example.com; + c=simple/simple; q=dns/txt; i=joe@football.example.com; + h=Received : From : To : Subject : Date : Message-ID; + bh=2jUSOH9NhtVGCQWNr9BrIAPreKQjO6Sn7XIkfJVOzv8=; + b=AuUoFEfDxTDkHlLXSZEpZj79LICEps6eda7W3deTVFOk4yAUoqOB + 4nujc7YopdG5dWLSdNg6xNAZpOPr+kHxt1IrE+NahM6L/LbvaHut + KVdkLLkpVaVVQPzeRDI009SO2Il5Lu7rDNH6mZckBdrIx0orEtZV + 4bmp/YzhwvcubU4=; + Received: from client1.football.example.com [192.0.2.1] + by submitserver.example.com with SUBMISSION; + Fri, 11 Jul 2003 21:01:54 -0700 (PDT) + From: Joe SixPack + To: Suzie Q + Subject: Is dinner ready? + Date: Fri, 11 Jul 2003 21:00:37 -0700 (PDT) + Message-ID: <20030712040037.46341.5F8J@football.example.com> + + Hi. + + We lost the game. Are you hungry yet? + + Joe. + +Appendix B. Usage Examples (INFORMATIVE) + + DKIM signing and validating can be used in different ways, for + different operational scenarios. This Appendix discusses some common + examples. + + NOTE: Descriptions in this Appendix are for informational purposes + only. They describe various ways that DKIM can be used, given + particular constraints and needs. In no case are these examples + intended to be taken as providing explanation or guidance + concerning DKIM specification details, when creating an + implementation. + + + + + + + + +Allman, et al. Standards Track [Page 62] + +RFC 4871 DKIM Signatures May 2007 + + +B.1. Alternate Submission Scenarios + + In the most simple scenario, a user's MUA, MSA, and Internet + (boundary) MTA are all within the same administrative environment, + using the same domain name. Therefore, all of the components + involved in submission and initial transfer are related. However, it + is common for two or more of the components to be under independent + administrative control. This creates challenges for choosing and + administering the domain name to use for signing, and for its + relationship to common email identity header fields. + +B.1.1. Delegated Business Functions + + Some organizations assign specific business functions to discrete + groups, inside or outside the organization. The goal, then, is to + authorize that group to sign some mail, but to constrain what + signatures they can generate. DKIM selectors (the "s=" signature + tag) and granularity (the "g=" key tag) facilitate this kind of + restricted authorization. Examples of these outsourced business + functions are legitimate email marketing providers and corporate + benefits providers. + + Here, the delegated group needs to be able to send messages that are + signed, using the email domain of the client company. At the same + time, the client often is reluctant to register a key for the + provider that grants the ability to send messages for arbitrary + addresses in the domain. + + There are multiple ways to administer these usage scenarios. In one + case, the client organization provides all of the public query + service (for example, DNS) administration, and in another it uses DNS + delegation to enable all ongoing administration of the DKIM key + record by the delegated group. + + If the client organization retains responsibility for all of the DNS + administration, the outsourcing company can generate a key pair, + supplying the public key to the client company, which then registers + it in the query service, using a unique selector that authorizes a + specific From header field Local-part. For example, a client with + the domain "example.com" could have the selector record specify + "g=winter-promotions" so that this signature is only valid for mail + with a From address of "winter-promotions@example.com". This would + enable the provider to send messages using that specific address and + have them verify properly. The client company retains control over + the email address because it retains the ability to revoke the key at + any time. + + + + + +Allman, et al. Standards Track [Page 63] + +RFC 4871 DKIM Signatures May 2007 + + + If the client wants the delegated group to do the DNS administration, + it can have the domain name that is specified with the selector point + to the provider's DNS server. The provider then creates and + maintains all of the DKIM signature information for that selector. + Hence, the client cannot provide constraints on the Local-part of + addresses that get signed, but it can revoke the provider's signing + rights by removing the DNS delegation record. + +B.1.2. PDAs and Similar Devices + + PDAs demonstrate the need for using multiple keys per domain. + Suppose that John Doe wanted to be able to send messages using his + corporate email address, jdoe@example.com, and his email device did + not have the ability to make a Virtual Private Network (VPN) + connection to the corporate network, either because the device is + limited or because there are restrictions enforced by his Internet + access provider. If the device was equipped with a private key + registered for jdoe@example.com by the administrator of the + example.com domain, and appropriate software to sign messages, John + could sign the message on the device itself before transmission + through the outgoing network of the access service provider. + +B.1.3. Roaming Users + + Roaming users often find themselves in circumstances where it is + convenient or necessary to use an SMTP server other than their home + server; examples are conferences and many hotels. In such + circumstances, a signature that is added by the submission service + will use an identity that is different from the user's home system. + + Ideally, roaming users would connect back to their home server using + either a VPN or a SUBMISSION server running with SMTP AUTHentication + on port 587. If the signing can be performed on the roaming user's + laptop, then they can sign before submission, although the risk of + further modification is high. If neither of these are possible, + these roaming users will not be able to send mail signed using their + own domain key. + +B.1.4. Independent (Kiosk) Message Submission + + Stand-alone services, such as walk-up kiosks and web-based + information services, have no enduring email service relationship + with the user, but users occasionally request that mail be sent on + their behalf. For example, a website providing news often allows the + reader to forward a copy of the article to a friend. This is + typically done using the reader's own email address, to indicate who + the author is. This is sometimes referred to as the "Evite problem", + + + + +Allman, et al. Standards Track [Page 64] + +RFC 4871 DKIM Signatures May 2007 + + + named after the website of the same name that allows a user to send + invitations to friends. + + A common way this is handled is to continue to put the reader's email + address in the From header field of the message, but put an address + owned by the email posting site into the Sender header field. The + posting site can then sign the message, using the domain that is in + the Sender field. This provides useful information to the receiving + email site, which is able to correlate the signing domain with the + initial submission email role. + + Receiving sites often wish to provide their end users with + information about mail that is mediated in this fashion. Although + the real efficacy of different approaches is a subject for human + factors usability research, one technique that is used is for the + verifying system to rewrite the From header field, to indicate the + address that was verified. For example: From: John Doe via + news@news-site.com . (Note that such rewriting + will break a signature, unless it is done after the verification pass + is complete.) + +B.2. Alternate Delivery Scenarios + + Email is often received at a mailbox that has an address different + from the one used during initial submission. In these cases, an + intermediary mechanism operates at the address originally used and it + then passes the message on to the final destination. This mediation + process presents some challenges for DKIM signatures. + +B.2.1. Affinity Addresses + + "Affinity addresses" allow a user to have an email address that + remains stable, even as the user moves among different email + providers. They are typically associated with college alumni + associations, professional organizations, and recreational + organizations with which they expect to have a long-term + relationship. These domains usually provide forwarding of incoming + email, and they often have an associated Web application that + authenticates the user and allows the forwarding address to be + changed. However, these services usually depend on users sending + outgoing messages through their own service providers' MTAs. Hence, + mail that is signed with the domain of the affinity address is not + signed by an entity that is administered by the organization owning + that domain. + + With DKIM, affinity domains could use the Web application to allow + users to register per-user keys to be used to sign messages on behalf + of their affinity address. The user would take away the secret half + + + +Allman, et al. Standards Track [Page 65] + +RFC 4871 DKIM Signatures May 2007 + + + of the key pair for signing, and the affinity domain would publish + the public half in DNS for access by verifiers. + + This is another application that takes advantage of user-level + keying, and domains used for affinity addresses would typically have + a very large number of user-level keys. Alternatively, the affinity + domain could handle outgoing mail, operating a mail submission agent + that authenticates users before accepting and signing messages for + them. This is of course dependent on the user's service provider not + blocking the relevant TCP ports used for mail submission. + +B.2.2. Simple Address Aliasing (.forward) + + In some cases, a recipient is allowed to configure an email address + to cause automatic redirection of email messages from the original + address to another, such as through the use of a Unix .forward file. + In this case, messages are typically redirected by the mail handling + service of the recipient's domain, without modification, except for + the addition of a Received header field to the message and a change + in the envelope recipient address. In this case, the recipient at + the final address' mailbox is likely to be able to verify the + original signature since the signed content has not changed, and DKIM + is able to validate the message signature. + +B.2.3. Mailing Lists and Re-Posters + + There is a wide range of behaviors in services that take delivery of + a message and then resubmit it. A primary example is with mailing + lists (collectively called "forwarders" below), ranging from those + that make no modification to the message itself, other than to add a + Received header field and change the envelope information, to those + that add header fields, change the Subject header field, add content + to the body (typically at the end), or reformat the body in some + manner. The simple ones produce messages that are quite similar to + the automated alias services. More elaborate systems essentially + create a new message. + + A Forwarder that does not modify the body or signed header fields of + a message is likely to maintain the validity of the existing + signature. It also could choose to add its own signature to the + message. + + Forwarders which modify a message in a way that could make an + existing signature invalid are particularly good candidates for + adding their own signatures (e.g., mailing-list-name@example.net). + Since (re-)signing is taking responsibility for the content of the + message, these signing forwarders are likely to be selective, and + forward or re-sign a message only if it is received with a valid + + + +Allman, et al. Standards Track [Page 66] + +RFC 4871 DKIM Signatures May 2007 + + + signature or if they have some other basis for knowing that the + message is not spoofed. + + A common practice among systems that are primarily redistributors of + mail is to add a Sender header field to the message, to identify the + address being used to sign the message. This practice will remove + any preexisting Sender header field as required by [RFC2822]. The + forwarder applies a new DKIM-Signature header field with the + signature, public key, and related information of the forwarder. + +Appendix C. Creating a Public Key (INFORMATIVE) + + The default signature is an RSA signed SHA256 digest of the complete + email. For ease of explanation, the openssl command is used to + describe the mechanism by which keys and signatures are managed. One + way to generate a 1024-bit, unencrypted private key suitable for DKIM + is to use openssl like this: + + $ openssl genrsa -out rsa.private 1024 + + For increased security, the "-passin" parameter can also be added to + encrypt the private key. Use of this parameter will require entering + a password for several of the following steps. Servers may prefer to + use hardware cryptographic support. + + The "genrsa" step results in the file rsa.private containing the key + information similar to this: + + -----BEGIN RSA PRIVATE KEY----- + MIICXwIBAAKBgQDwIRP/UC3SBsEmGqZ9ZJW3/DkMoGeLnQg1fWn7/zYtIxN2SnFC + jxOCKG9v3b4jYfcTNh5ijSsq631uBItLa7od+v/RtdC2UzJ1lWT947qR+Rcac2gb + to/NMqJ0fzfVjH4OuKhitdY9tf6mcwGjaNBcWToIMmPSPDdQPNUYckcQ2QIDAQAB + AoGBALmn+XwWk7akvkUlqb+dOxyLB9i5VBVfje89Teolwc9YJT36BGN/l4e0l6QX + /1//6DWUTB3KI6wFcm7TWJcxbS0tcKZX7FsJvUz1SbQnkS54DJck1EZO/BLa5ckJ + gAYIaqlA9C0ZwM6i58lLlPadX/rtHb7pWzeNcZHjKrjM461ZAkEA+itss2nRlmyO + n1/5yDyCluST4dQfO8kAB3toSEVc7DeFeDhnC1mZdjASZNvdHS4gbLIA1hUGEF9m + 3hKsGUMMPwJBAPW5v/U+AWTADFCS22t72NUurgzeAbzb1HWMqO4y4+9Hpjk5wvL/ + eVYizyuce3/fGke7aRYw/ADKygMJdW8H/OcCQQDz5OQb4j2QDpPZc0Nc4QlbvMsj + 7p7otWRO5xRa6SzXqqV3+F0VpqvDmshEBkoCydaYwc2o6WQ5EBmExeV8124XAkEA + qZzGsIxVP+sEVRWZmW6KNFSdVUpk3qzK0Tz/WjQMe5z0UunY9Ax9/4PVhp/j61bf + eAYXunajbBSOLlx4D+TunwJBANkPI5S9iylsbLs6NkaMHV6k5ioHBBmgCak95JGX + GMot/L2x0IYyMLAz6oLWh2hm7zwtb0CgOrPo1ke44hFYnfc= + -----END RSA PRIVATE KEY----- + + To extract the public-key component from the private key, use openssl + like this: + + $ openssl rsa -in rsa.private -out rsa.public -pubout -outform PEM + + + +Allman, et al. Standards Track [Page 67] + +RFC 4871 DKIM Signatures May 2007 + + + This results in the file rsa.public containing the key information + similar to this: + + -----BEGIN PUBLIC KEY----- + MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDwIRP/UC3SBsEmGqZ9ZJW3/DkM + oGeLnQg1fWn7/zYtIxN2SnFCjxOCKG9v3b4jYfcTNh5ijSsq631uBItLa7od+v/R + tdC2UzJ1lWT947qR+Rcac2gbto/NMqJ0fzfVjH4OuKhitdY9tf6mcwGjaNBcWToI + MmPSPDdQPNUYckcQ2QIDAQAB + -----END PUBLIC KEY----- + + This public-key data (without the BEGIN and END tags) is placed in + the DNS: + + brisbane IN TXT ("v=DKIM1; p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQ" + "KBgQDwIRP/UC3SBsEmGqZ9ZJW3/DkMoGeLnQg1fWn7/zYt" + "IxN2SnFCjxOCKG9v3b4jYfcTNh5ijSsq631uBItLa7od+v" + "/RtdC2UzJ1lWT947qR+Rcac2gbto/NMqJ0fzfVjH4OuKhi" + "tdY9tf6mcwGjaNBcWToIMmPSPDdQPNUYckcQ2QIDAQAB") + +Appendix D. MUA Considerations + + When a DKIM signature is verified, the processing system sometimes + makes the result available to the recipient user's MUA. How to + present this information to the user in a way that helps them is a + matter of continuing human factors usability research. The tendency + is to have the MUA highlight the address associated with this signing + identity in some way, in an attempt to show the user the address from + which the mail was sent. An MUA might do this with visual cues such + as graphics, or it might include the address in an alternate view, or + it might even rewrite the original From address using the verified + information. Some MUAs might indicate which header fields were + protected by the validated DKIM signature. This could be done with a + positive indication on the signed header fields, with a negative + indication on the unsigned header fields, by visually hiding the + unsigned header fields, or some combination of these. If an MUA uses + visual indications for signed header fields, the MUA probably needs + to be careful not to display unsigned header fields in a way that + might be construed by the end user as having been signed. If the + message has an l= tag whose value does not extend to the end of the + message, the MUA might also hide or mark the portion of the message + body that was not signed. + + The aforementioned information is not intended to be exhaustive. The + MUA may choose to highlight, accentuate, hide, or otherwise display + any other information that may, in the opinion of the MUA author, be + deemed important to the end user. + + + + + +Allman, et al. Standards Track [Page 68] + +RFC 4871 DKIM Signatures May 2007 + + +Appendix E. Acknowledgements + + The authors wish to thank Russ Allbery, Edwin Aoki, Claus Assmann, + Steve Atkins, Rob Austein, Fred Baker, Mark Baugher, Steve Bellovin, + Nathaniel Borenstein, Dave Crocker, Michael Cudahy, Dennis Dayman, + Jutta Degener, Frank Ellermann, Patrik Faeltstroem, Mark Fanto, + Stephen Farrell, Duncan Findlay, Elliot Gillum, Olafur + Gu[eth]mundsson, Phillip Hallam-Baker, Tony Hansen, Sam Hartman, + Arvel Hathcock, Amir Herzberg, Paul Hoffman, Russ Housley, Craig + Hughes, Cullen Jennings, Don Johnsen, Harry Katz, Murray S. + Kucherawy, Barry Leiba, John Levine, Charles Lindsey, Simon + Longsdale, David Margrave, Justin Mason, David Mayne, Thierry Moreau, + Steve Murphy, Russell Nelson, Dave Oran, Doug Otis, Shamim Pirzada, + Juan Altmayer Pizzorno, Sanjay Pol, Blake Ramsdell, Christian Renaud, + Scott Renfro, Neil Rerup, Eric Rescorla, Dave Rossetti, Hector + Santos, Jim Schaad, the Spamhaus.org team, Malte S. Stretz, Robert + Sanders, Rand Wacker, Sam Weiler, and Dan Wing for their valuable + suggestions and constructive criticism. + + The DomainKeys specification was a primary source from which this + specification has been derived. Further information about DomainKeys + is at [RFC4870]. + +Authors' Addresses + + Eric Allman + Sendmail, Inc. + 6425 Christie Ave, Suite 400 + Emeryville, CA 94608 + USA + + Phone: +1 510 594 5501 + EMail: eric+dkim@sendmail.org + URI: + + + Jon Callas + PGP Corporation + 3460 West Bayshore + Palo Alto, CA 94303 + USA + + Phone: +1 650 319 9016 + EMail: jon@pgp.com + + + + + + + +Allman, et al. Standards Track [Page 69] + +RFC 4871 DKIM Signatures May 2007 + + + Mark Delany + Yahoo! Inc + 701 First Avenue + Sunnyvale, CA 95087 + USA + + Phone: +1 408 349 6831 + EMail: markd+dkim@yahoo-inc.com + URI: + + + Miles Libbey + Yahoo! Inc + 701 First Avenue + Sunnyvale, CA 95087 + USA + + EMail: mlibbeymail-mailsig@yahoo.com + URI: + + + Jim Fenton + Cisco Systems, Inc. + MS SJ-9/2 + 170 W. Tasman Drive + San Jose, CA 95134-1706 + USA + + Phone: +1 408 526 5914 + EMail: fenton@cisco.com + URI: + + + Michael Thomas + Cisco Systems, Inc. + MS SJ-9/2 + 170 W. Tasman Drive + San Jose, CA 95134-1706 + + Phone: +1 408 525 5386 + EMail: mat@cisco.com + + + + + + + + + + +Allman, et al. Standards Track [Page 70] + +RFC 4871 DKIM Signatures May 2007 + + +Full Copyright Statement + + Copyright (C) The IETF Trust (2007). + + This document is subject to the rights, licenses and restrictions + contained in BCP 78, and except as set forth therein, the authors + retain all their rights. + + This document and the information contained herein are provided on an + "AS IS" basis and THE CONTRIBUTOR, THE ORGANIZATION HE/SHE REPRESENTS + OR IS SPONSORED BY (IF ANY), THE INTERNET SOCIETY, THE IETF TRUST AND + THE INTERNET ENGINEERING TASK FORCE DISCLAIM ALL WARRANTIES, EXPRESS + OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF + THE INFORMATION HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED + WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + +Intellectual Property + + The IETF takes no position regarding the validity or scope of any + Intellectual Property Rights or other rights that might be claimed to + pertain to the implementation or use of the technology described in + this document or the extent to which any license under such rights + might or might not be available; nor does it represent that it has + made any independent effort to identify any such rights. Information + on the procedures with respect to rights in RFC documents can be + found in BCP 78 and BCP 79. + + Copies of IPR disclosures made to the IETF Secretariat and any + assurances of licenses to be made available, or the result of an + attempt made to obtain a general license or permission for the use of + such proprietary rights by implementers or users of this + specification can be obtained from the IETF on-line IPR repository at + http://www.ietf.org/ipr. + + The IETF invites any interested party to bring to its attention any + copyrights, patents or patent applications, or other proprietary + rights that may cover technology that may be required to implement + this standard. Please address the information to the IETF at + ietf-ipr@ietf.org. + +Acknowledgement + + Funding for the RFC Editor function is currently provided by the + Internet Society. + + + + + + + +Allman, et al. Standards Track [Page 71] + diff --git a/vendor/swiftmailer/swiftmailer/notes/rfc/rfc4880.txt b/vendor/swiftmailer/swiftmailer/notes/rfc/rfc4880.txt new file mode 100755 index 0000000..0db9453 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/notes/rfc/rfc4880.txt @@ -0,0 +1,5042 @@ + + + + + +Network Working Group J. Callas +Request for Comments: 4880 PGP Corporation +Obsoletes: 1991, 2440 L. Donnerhacke +Category: Standards Track IKS GmbH + H. Finney + PGP Corporation + D. Shaw + R. Thayer + November 2007 + + + OpenPGP Message Format + +Status of This Memo + + This document specifies an Internet standards track protocol for the + Internet community, and requests discussion and suggestions for + improvements. Please refer to the current edition of the "Internet + Official Protocol Standards" (STD 1) for the standardization state + and status of this protocol. Distribution of this memo is unlimited. + +Abstract + + This document is maintained in order to publish all necessary + information needed to develop interoperable applications based on the + OpenPGP format. It is not a step-by-step cookbook for writing an + application. It describes only the format and methods needed to + read, check, generate, and write conforming packets crossing any + network. It does not deal with storage and implementation questions. + It does, however, discuss implementation issues necessary to avoid + security flaws. + + OpenPGP software uses a combination of strong public-key and + symmetric cryptography to provide security services for electronic + communications and data storage. These services include + confidentiality, key management, authentication, and digital + signatures. This document specifies the message formats used in + OpenPGP. + + + + + + + + + + + + + +Callas, et al Standards Track [Page 1] + +RFC 4880 OpenPGP Message Format November 2007 + + +Table of Contents + + 1. Introduction ....................................................5 + 1.1. Terms ......................................................5 + 2. General functions ...............................................6 + 2.1. Confidentiality via Encryption .............................6 + 2.2. Authentication via Digital Signature .......................7 + 2.3. Compression ................................................7 + 2.4. Conversion to Radix-64 .....................................8 + 2.5. Signature-Only Applications ................................8 + 3. Data Element Formats ............................................8 + 3.1. Scalar Numbers .............................................8 + 3.2. Multiprecision Integers ....................................9 + 3.3. Key IDs ....................................................9 + 3.4. Text .......................................................9 + 3.5. Time Fields ...............................................10 + 3.6. Keyrings ..................................................10 + 3.7. String-to-Key (S2K) Specifiers ............................10 + 3.7.1. String-to-Key (S2K) Specifier Types ................10 + 3.7.1.1. Simple S2K ................................10 + 3.7.1.2. Salted S2K ................................11 + 3.7.1.3. Iterated and Salted S2K ...................11 + 3.7.2. String-to-Key Usage ................................12 + 3.7.2.1. Secret-Key Encryption .....................12 + 3.7.2.2. Symmetric-Key Message Encryption ..........13 + 4. Packet Syntax ..................................................13 + 4.1. Overview ..................................................13 + 4.2. Packet Headers ............................................13 + 4.2.1. Old Format Packet Lengths ..........................14 + 4.2.2. New Format Packet Lengths ..........................15 + 4.2.2.1. One-Octet Lengths .........................15 + 4.2.2.2. Two-Octet Lengths .........................15 + 4.2.2.3. Five-Octet Lengths ........................15 + 4.2.2.4. Partial Body Lengths ......................16 + 4.2.3. Packet Length Examples .............................16 + 4.3. Packet Tags ...............................................17 + 5. Packet Types ...................................................17 + 5.1. Public-Key Encrypted Session Key Packets (Tag 1) ..........17 + 5.2. Signature Packet (Tag 2) ..................................19 + 5.2.1. Signature Types ....................................19 + 5.2.2. Version 3 Signature Packet Format ..................21 + 5.2.3. Version 4 Signature Packet Format ..................24 + 5.2.3.1. Signature Subpacket Specification .........25 + 5.2.3.2. Signature Subpacket Types .................27 + 5.2.3.3. Notes on Self-Signatures ..................27 + 5.2.3.4. Signature Creation Time ...................28 + 5.2.3.5. Issuer ....................................28 + 5.2.3.6. Key Expiration Time .......................28 + + + +Callas, et al Standards Track [Page 2] + +RFC 4880 OpenPGP Message Format November 2007 + + + 5.2.3.7. Preferred Symmetric Algorithms ............28 + 5.2.3.8. Preferred Hash Algorithms .................29 + 5.2.3.9. Preferred Compression Algorithms ..........29 + 5.2.3.10. Signature Expiration Time ................29 + 5.2.3.11. Exportable Certification .................29 + 5.2.3.12. Revocable ................................30 + 5.2.3.13. Trust Signature ..........................30 + 5.2.3.14. Regular Expression .......................31 + 5.2.3.15. Revocation Key ...........................31 + 5.2.3.16. Notation Data ............................31 + 5.2.3.17. Key Server Preferences ...................32 + 5.2.3.18. Preferred Key Server .....................33 + 5.2.3.19. Primary User ID ..........................33 + 5.2.3.20. Policy URI ...............................33 + 5.2.3.21. Key Flags ................................33 + 5.2.3.22. Signer's User ID .........................34 + 5.2.3.23. Reason for Revocation ....................35 + 5.2.3.24. Features .................................36 + 5.2.3.25. Signature Target .........................36 + 5.2.3.26. Embedded Signature .......................37 + 5.2.4. Computing Signatures ...............................37 + 5.2.4.1. Subpacket Hints ...........................38 + 5.3. Symmetric-Key Encrypted Session Key Packets (Tag 3) .......38 + 5.4. One-Pass Signature Packets (Tag 4) ........................39 + 5.5. Key Material Packet .......................................40 + 5.5.1. Key Packet Variants ................................40 + 5.5.1.1. Public-Key Packet (Tag 6) .................40 + 5.5.1.2. Public-Subkey Packet (Tag 14) .............40 + 5.5.1.3. Secret-Key Packet (Tag 5) .................41 + 5.5.1.4. Secret-Subkey Packet (Tag 7) ..............41 + 5.5.2. Public-Key Packet Formats ..........................41 + 5.5.3. Secret-Key Packet Formats ..........................43 + 5.6. Compressed Data Packet (Tag 8) ............................45 + 5.7. Symmetrically Encrypted Data Packet (Tag 9) ...............45 + 5.8. Marker Packet (Obsolete Literal Packet) (Tag 10) ..........46 + 5.9. Literal Data Packet (Tag 11) ..............................46 + 5.10. Trust Packet (Tag 12) ....................................47 + 5.11. User ID Packet (Tag 13) ..................................48 + 5.12. User Attribute Packet (Tag 17) ...........................48 + 5.12.1. The Image Attribute Subpacket .....................48 + 5.13. Sym. Encrypted Integrity Protected Data Packet (Tag 18) ..49 + 5.14. Modification Detection Code Packet (Tag 19) ..............52 + 6. Radix-64 Conversions ...........................................53 + 6.1. An Implementation of the CRC-24 in "C" ....................54 + 6.2. Forming ASCII Armor .......................................54 + 6.3. Encoding Binary in Radix-64 ...............................57 + 6.4. Decoding Radix-64 .........................................58 + 6.5. Examples of Radix-64 ......................................59 + + + +Callas, et al Standards Track [Page 3] + +RFC 4880 OpenPGP Message Format November 2007 + + + 6.6. Example of an ASCII Armored Message .......................59 + 7. Cleartext Signature Framework ..................................59 + 7.1. Dash-Escaped Text .........................................60 + 8. Regular Expressions ............................................61 + 9. Constants ......................................................61 + 9.1. Public-Key Algorithms .....................................62 + 9.2. Symmetric-Key Algorithms ..................................62 + 9.3. Compression Algorithms ....................................63 + 9.4. Hash Algorithms ...........................................63 + 10. IANA Considerations ...........................................63 + 10.1. New String-to-Key Specifier Types ........................64 + 10.2. New Packets ..............................................64 + 10.2.1. User Attribute Types ..............................64 + 10.2.1.1. Image Format Subpacket Types .............64 + 10.2.2. New Signature Subpackets ..........................64 + 10.2.2.1. Signature Notation Data Subpackets .......65 + 10.2.2.2. Key Server Preference Extensions .........65 + 10.2.2.3. Key Flags Extensions .....................65 + 10.2.2.4. Reason For Revocation Extensions .........65 + 10.2.2.5. Implementation Features ..................66 + 10.2.3. New Packet Versions ...............................66 + 10.3. New Algorithms ...........................................66 + 10.3.1. Public-Key Algorithms .............................66 + 10.3.2. Symmetric-Key Algorithms ..........................67 + 10.3.3. Hash Algorithms ...................................67 + 10.3.4. Compression Algorithms ............................67 + 11. Packet Composition ............................................67 + 11.1. Transferable Public Keys .................................67 + 11.2. Transferable Secret Keys .................................69 + 11.3. OpenPGP Messages .........................................69 + 11.4. Detached Signatures ......................................70 + 12. Enhanced Key Formats ..........................................70 + 12.1. Key Structures ...........................................70 + 12.2. Key IDs and Fingerprints .................................71 + 13. Notes on Algorithms ...........................................72 + 13.1. PKCS#1 Encoding in OpenPGP ...............................72 + 13.1.1. EME-PKCS1-v1_5-ENCODE .............................73 + 13.1.2. EME-PKCS1-v1_5-DECODE .............................73 + 13.1.3. EMSA-PKCS1-v1_5 ...................................74 + 13.2. Symmetric Algorithm Preferences ..........................75 + 13.3. Other Algorithm Preferences ..............................76 + 13.3.1. Compression Preferences ...........................76 + 13.3.2. Hash Algorithm Preferences ........................76 + 13.4. Plaintext ................................................77 + 13.5. RSA ......................................................77 + 13.6. DSA ......................................................77 + 13.7. Elgamal ..................................................78 + 13.8. Reserved Algorithm Numbers ...............................78 + + + +Callas, et al Standards Track [Page 4] + +RFC 4880 OpenPGP Message Format November 2007 + + + 13.9. OpenPGP CFB Mode .........................................78 + 13.10. Private or Experimental Parameters ......................79 + 13.11. Extension of the MDC System .............................80 + 13.12. Meta-Considerations for Expansion .......................80 + 14. Security Considerations .......................................81 + 15. Implementation Nits ...........................................84 + 16. References ....................................................86 + 16.1. Normative References .....................................86 + 16.2. Informative References ...................................88 + +1. Introduction + + This document provides information on the message-exchange packet + formats used by OpenPGP to provide encryption, decryption, signing, + and key management functions. It is a revision of RFC 2440, "OpenPGP + Message Format", which itself replaces RFC 1991, "PGP Message + Exchange Formats" [RFC1991] [RFC2440]. + +1.1. Terms + + * OpenPGP - This is a term for security software that uses PGP 5.x + as a basis, formalized in RFC 2440 and this document. + + * PGP - Pretty Good Privacy. PGP is a family of software systems + developed by Philip R. Zimmermann from which OpenPGP is based. + + * PGP 2.6.x - This version of PGP has many variants, hence the term + PGP 2.6.x. It used only RSA, MD5, and IDEA for its cryptographic + transforms. An informational RFC, RFC 1991, was written + describing this version of PGP. + + * PGP 5.x - This version of PGP is formerly known as "PGP 3" in the + community and also in the predecessor of this document, RFC 1991. + It has new formats and corrects a number of problems in the PGP + 2.6.x design. It is referred to here as PGP 5.x because that + software was the first release of the "PGP 3" code base. + + * GnuPG - GNU Privacy Guard, also called GPG. GnuPG is an OpenPGP + implementation that avoids all encumbered algorithms. + Consequently, early versions of GnuPG did not include RSA public + keys. GnuPG may or may not have (depending on version) support + for IDEA or other encumbered algorithms. + + "PGP", "Pretty Good", and "Pretty Good Privacy" are trademarks of PGP + Corporation and are used with permission. The term "OpenPGP" refers + to the protocol described in this and related documents. + + + + + +Callas, et al Standards Track [Page 5] + +RFC 4880 OpenPGP Message Format November 2007 + + + The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", + "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this + document are to be interpreted as described in [RFC2119]. + + The key words "PRIVATE USE", "HIERARCHICAL ALLOCATION", "FIRST COME + FIRST SERVED", "EXPERT REVIEW", "SPECIFICATION REQUIRED", "IESG + APPROVAL", "IETF CONSENSUS", and "STANDARDS ACTION" that appear in + this document when used to describe namespace allocation are to be + interpreted as described in [RFC2434]. + +2. General functions + + OpenPGP provides data integrity services for messages and data files + by using these core technologies: + + - digital signatures + + - encryption + + - compression + + - Radix-64 conversion + + In addition, OpenPGP provides key management and certificate + services, but many of these are beyond the scope of this document. + +2.1. Confidentiality via Encryption + + OpenPGP combines symmetric-key encryption and public-key encryption + to provide confidentiality. When made confidential, first the object + is encrypted using a symmetric encryption algorithm. Each symmetric + key is used only once, for a single object. A new "session key" is + generated as a random number for each object (sometimes referred to + as a session). Since it is used only once, the session key is bound + to the message and transmitted with it. To protect the key, it is + encrypted with the receiver's public key. The sequence is as + follows: + + 1. The sender creates a message. + + 2. The sending OpenPGP generates a random number to be used as a + session key for this message only. + + 3. The session key is encrypted using each recipient's public key. + These "encrypted session keys" start the message. + + + + + + +Callas, et al Standards Track [Page 6] + +RFC 4880 OpenPGP Message Format November 2007 + + + 4. The sending OpenPGP encrypts the message using the session key, + which forms the remainder of the message. Note that the message + is also usually compressed. + + 5. The receiving OpenPGP decrypts the session key using the + recipient's private key. + + 6. The receiving OpenPGP decrypts the message using the session key. + If the message was compressed, it will be decompressed. + + With symmetric-key encryption, an object may be encrypted with a + symmetric key derived from a passphrase (or other shared secret), or + a two-stage mechanism similar to the public-key method described + above in which a session key is itself encrypted with a symmetric + algorithm keyed from a shared secret. + + Both digital signature and confidentiality services may be applied to + the same message. First, a signature is generated for the message + and attached to the message. Then the message plus signature is + encrypted using a symmetric session key. Finally, the session key is + encrypted using public-key encryption and prefixed to the encrypted + block. + +2.2. Authentication via Digital Signature + + The digital signature uses a hash code or message digest algorithm, + and a public-key signature algorithm. The sequence is as follows: + + 1. The sender creates a message. + + 2. The sending software generates a hash code of the message. + + 3. The sending software generates a signature from the hash code + using the sender's private key. + + 4. The binary signature is attached to the message. + + 5. The receiving software keeps a copy of the message signature. + + 6. The receiving software generates a new hash code for the received + message and verifies it using the message's signature. If the + verification is successful, the message is accepted as authentic. + +2.3. Compression + + OpenPGP implementations SHOULD compress the message after applying + the signature but before encryption. + + + + +Callas, et al Standards Track [Page 7] + +RFC 4880 OpenPGP Message Format November 2007 + + + If an implementation does not implement compression, its authors + should be aware that most OpenPGP messages in the world are + compressed. Thus, it may even be wise for a space-constrained + implementation to implement decompression, but not compression. + + Furthermore, compression has the added side effect that some types of + attacks can be thwarted by the fact that slightly altered, compressed + data rarely uncompresses without severe errors. This is hardly + rigorous, but it is operationally useful. These attacks can be + rigorously prevented by implementing and using Modification Detection + Codes as described in sections following. + +2.4. Conversion to Radix-64 + + OpenPGP's underlying native representation for encrypted messages, + signature certificates, and keys is a stream of arbitrary octets. + Some systems only permit the use of blocks consisting of seven-bit, + printable text. For transporting OpenPGP's native raw binary octets + through channels that are not safe to raw binary data, a printable + encoding of these binary octets is needed. OpenPGP provides the + service of converting the raw 8-bit binary octet stream to a stream + of printable ASCII characters, called Radix-64 encoding or ASCII + Armor. + + Implementations SHOULD provide Radix-64 conversions. + +2.5. Signature-Only Applications + + OpenPGP is designed for applications that use both encryption and + signatures, but there are a number of problems that are solved by a + signature-only implementation. Although this specification requires + both encryption and signatures, it is reasonable for there to be + subset implementations that are non-conformant only in that they omit + encryption. + +3. Data Element Formats + + This section describes the data elements used by OpenPGP. + +3.1. Scalar Numbers + + Scalar numbers are unsigned and are always stored in big-endian + format. Using n[k] to refer to the kth octet being interpreted, the + value of a two-octet scalar is ((n[0] << 8) + n[1]). The value of a + four-octet scalar is ((n[0] << 24) + (n[1] << 16) + (n[2] << 8) + + n[3]). + + + + + +Callas, et al Standards Track [Page 8] + +RFC 4880 OpenPGP Message Format November 2007 + + +3.2. Multiprecision Integers + + Multiprecision integers (also called MPIs) are unsigned integers used + to hold large integers such as the ones used in cryptographic + calculations. + + An MPI consists of two pieces: a two-octet scalar that is the length + of the MPI in bits followed by a string of octets that contain the + actual integer. + + These octets form a big-endian number; a big-endian number can be + made into an MPI by prefixing it with the appropriate length. + + Examples: + + (all numbers are in hexadecimal) + + The string of octets [00 01 01] forms an MPI with the value 1. The + string [00 09 01 FF] forms an MPI with the value of 511. + + Additional rules: + + The size of an MPI is ((MPI.length + 7) / 8) + 2 octets. + + The length field of an MPI describes the length starting from its + most significant non-zero bit. Thus, the MPI [00 02 01] is not + formed correctly. It should be [00 01 01]. + + Unused bits of an MPI MUST be zero. + + Also note that when an MPI is encrypted, the length refers to the + plaintext MPI. It may be ill-formed in its ciphertext. + +3.3. Key IDs + + A Key ID is an eight-octet scalar that identifies a key. + Implementations SHOULD NOT assume that Key IDs are unique. The + section "Enhanced Key Formats" below describes how Key IDs are + formed. + +3.4. Text + + Unless otherwise specified, the character set for text is the UTF-8 + [RFC3629] encoding of Unicode [ISO10646]. + + + + + + + +Callas, et al Standards Track [Page 9] + +RFC 4880 OpenPGP Message Format November 2007 + + +3.5. Time Fields + + A time field is an unsigned four-octet number containing the number + of seconds elapsed since midnight, 1 January 1970 UTC. + +3.6. Keyrings + + A keyring is a collection of one or more keys in a file or database. + Traditionally, a keyring is simply a sequential list of keys, but may + be any suitable database. It is beyond the scope of this standard to + discuss the details of keyrings or other databases. + +3.7. String-to-Key (S2K) Specifiers + + String-to-key (S2K) specifiers are used to convert passphrase strings + into symmetric-key encryption/decryption keys. They are used in two + places, currently: to encrypt the secret part of private keys in the + private keyring, and to convert passphrases to encryption keys for + symmetrically encrypted messages. + +3.7.1. String-to-Key (S2K) Specifier Types + + There are three types of S2K specifiers currently supported, and + some reserved values: + + ID S2K Type + -- -------- + 0 Simple S2K + 1 Salted S2K + 2 Reserved value + 3 Iterated and Salted S2K + 100 to 110 Private/Experimental S2K + + These are described in Sections 3.7.1.1 - 3.7.1.3. + +3.7.1.1. Simple S2K + + This directly hashes the string to produce the key data. See below + for how this hashing is done. + + Octet 0: 0x00 + Octet 1: hash algorithm + + Simple S2K hashes the passphrase to produce the session key. The + manner in which this is done depends on the size of the session key + (which will depend on the cipher used) and the size of the hash + + + + + +Callas, et al Standards Track [Page 10] + +RFC 4880 OpenPGP Message Format November 2007 + + + algorithm's output. If the hash size is greater than the session key + size, the high-order (leftmost) octets of the hash are used as the + key. + + If the hash size is less than the key size, multiple instances of the + hash context are created -- enough to produce the required key data. + These instances are preloaded with 0, 1, 2, ... octets of zeros (that + is to say, the first instance has no preloading, the second gets + preloaded with 1 octet of zero, the third is preloaded with two + octets of zeros, and so forth). + + As the data is hashed, it is given independently to each hash + context. Since the contexts have been initialized differently, they + will each produce different hash output. Once the passphrase is + hashed, the output data from the multiple hashes is concatenated, + first hash leftmost, to produce the key data, with any excess octets + on the right discarded. + +3.7.1.2. Salted S2K + + This includes a "salt" value in the S2K specifier -- some arbitrary + data -- that gets hashed along with the passphrase string, to help + prevent dictionary attacks. + + Octet 0: 0x01 + Octet 1: hash algorithm + Octets 2-9: 8-octet salt value + + Salted S2K is exactly like Simple S2K, except that the input to the + hash function(s) consists of the 8 octets of salt from the S2K + specifier, followed by the passphrase. + +3.7.1.3. Iterated and Salted S2K + + This includes both a salt and an octet count. The salt is combined + with the passphrase and the resulting value is hashed repeatedly. + This further increases the amount of work an attacker must do to try + dictionary attacks. + + Octet 0: 0x03 + Octet 1: hash algorithm + Octets 2-9: 8-octet salt value + Octet 10: count, a one-octet, coded value + + + + + + + + +Callas, et al Standards Track [Page 11] + +RFC 4880 OpenPGP Message Format November 2007 + + + The count is coded into a one-octet number using the following + formula: + + #define EXPBIAS 6 + count = ((Int32)16 + (c & 15)) << ((c >> 4) + EXPBIAS); + + The above formula is in C, where "Int32" is a type for a 32-bit + integer, and the variable "c" is the coded count, Octet 10. + + Iterated-Salted S2K hashes the passphrase and salt data multiple + times. The total number of octets to be hashed is specified in the + encoded count in the S2K specifier. Note that the resulting count + value is an octet count of how many octets will be hashed, not an + iteration count. + + Initially, one or more hash contexts are set up as with the other S2K + algorithms, depending on how many octets of key data are needed. + Then the salt, followed by the passphrase data, is repeatedly hashed + until the number of octets specified by the octet count has been + hashed. The one exception is that if the octet count is less than + the size of the salt plus passphrase, the full salt plus passphrase + will be hashed even though that is greater than the octet count. + After the hashing is done, the data is unloaded from the hash + context(s) as with the other S2K algorithms. + +3.7.2. String-to-Key Usage + + Implementations SHOULD use salted or iterated-and-salted S2K + specifiers, as simple S2K specifiers are more vulnerable to + dictionary attacks. + +3.7.2.1. Secret-Key Encryption + + An S2K specifier can be stored in the secret keyring to specify how + to convert the passphrase to a key that unlocks the secret data. + Older versions of PGP just stored a cipher algorithm octet preceding + the secret data or a zero to indicate that the secret data was + unencrypted. The MD5 hash function was always used to convert the + passphrase to a key for the specified cipher algorithm. + + For compatibility, when an S2K specifier is used, the special value + 254 or 255 is stored in the position where the hash algorithm octet + would have been in the old data structure. This is then followed + immediately by a one-octet algorithm identifier, and then by the S2K + specifier as encoded above. + + + + + + +Callas, et al Standards Track [Page 12] + +RFC 4880 OpenPGP Message Format November 2007 + + + Therefore, preceding the secret data there will be one of these + possibilities: + + 0: secret data is unencrypted (no passphrase) + 255 or 254: followed by algorithm octet and S2K specifier + Cipher alg: use Simple S2K algorithm using MD5 hash + + This last possibility, the cipher algorithm number with an implicit + use of MD5 and IDEA, is provided for backward compatibility; it MAY + be understood, but SHOULD NOT be generated, and is deprecated. + + These are followed by an Initial Vector of the same length as the + block size of the cipher for the decryption of the secret values, if + they are encrypted, and then the secret-key values themselves. + +3.7.2.2. Symmetric-Key Message Encryption + + OpenPGP can create a Symmetric-key Encrypted Session Key (ESK) packet + at the front of a message. This is used to allow S2K specifiers to + be used for the passphrase conversion or to create messages with a + mix of symmetric-key ESKs and public-key ESKs. This allows a message + to be decrypted either with a passphrase or a public-key pair. + + PGP 2.X always used IDEA with Simple string-to-key conversion when + encrypting a message with a symmetric algorithm. This is deprecated, + but MAY be used for backward-compatibility. + +4. Packet Syntax + + This section describes the packets used by OpenPGP. + +4.1. Overview + + An OpenPGP message is constructed from a number of records that are + traditionally called packets. A packet is a chunk of data that has a + tag specifying its meaning. An OpenPGP message, keyring, + certificate, and so forth consists of a number of packets. Some of + those packets may contain other OpenPGP packets (for example, a + compressed data packet, when uncompressed, contains OpenPGP packets). + + Each packet consists of a packet header, followed by the packet body. + The packet header is of variable length. + +4.2. Packet Headers + + The first octet of the packet header is called the "Packet Tag". It + determines the format of the header and denotes the packet contents. + The remainder of the packet header is the length of the packet. + + + +Callas, et al Standards Track [Page 13] + +RFC 4880 OpenPGP Message Format November 2007 + + + Note that the most significant bit is the leftmost bit, called bit 7. + A mask for this bit is 0x80 in hexadecimal. + + +---------------+ + PTag |7 6 5 4 3 2 1 0| + +---------------+ + Bit 7 -- Always one + Bit 6 -- New packet format if set + + PGP 2.6.x only uses old format packets. Thus, software that + interoperates with those versions of PGP must only use old format + packets. If interoperability is not an issue, the new packet format + is RECOMMENDED. Note that old format packets have four bits of + packet tags, and new format packets have six; some features cannot be + used and still be backward-compatible. + + Also note that packets with a tag greater than or equal to 16 MUST + use new format packets. The old format packets can only express tags + less than or equal to 15. + + Old format packets contain: + + Bits 5-2 -- packet tag + Bits 1-0 -- length-type + + New format packets contain: + + Bits 5-0 -- packet tag + +4.2.1. Old Format Packet Lengths + + The meaning of the length-type in old format packets is: + + 0 - The packet has a one-octet length. The header is 2 octets long. + + 1 - The packet has a two-octet length. The header is 3 octets long. + + 2 - The packet has a four-octet length. The header is 5 octets long. + + 3 - The packet is of indeterminate length. The header is 1 octet + long, and the implementation must determine how long the packet + is. If the packet is in a file, this means that the packet + extends until the end of the file. In general, an implementation + SHOULD NOT use indeterminate-length packets except where the end + of the data will be clear from the context, and even then it is + better to use a definite length, or a new format header. The new + format headers described below have a mechanism for precisely + encoding data of indeterminate length. + + + +Callas, et al Standards Track [Page 14] + +RFC 4880 OpenPGP Message Format November 2007 + + +4.2.2. New Format Packet Lengths + + New format packets have four possible ways of encoding length: + + 1. A one-octet Body Length header encodes packet lengths of up to 191 + octets. + + 2. A two-octet Body Length header encodes packet lengths of 192 to + 8383 octets. + + 3. A five-octet Body Length header encodes packet lengths of up to + 4,294,967,295 (0xFFFFFFFF) octets in length. (This actually + encodes a four-octet scalar number.) + + 4. When the length of the packet body is not known in advance by the + issuer, Partial Body Length headers encode a packet of + indeterminate length, effectively making it a stream. + +4.2.2.1. One-Octet Lengths + + A one-octet Body Length header encodes a length of 0 to 191 octets. + This type of length header is recognized because the one octet value + is less than 192. The body length is equal to: + + bodyLen = 1st_octet; + +4.2.2.2. Two-Octet Lengths + + A two-octet Body Length header encodes a length of 192 to 8383 + octets. It is recognized because its first octet is in the range 192 + to 223. The body length is equal to: + + bodyLen = ((1st_octet - 192) << 8) + (2nd_octet) + 192 + +4.2.2.3. Five-Octet Lengths + + A five-octet Body Length header consists of a single octet holding + the value 255, followed by a four-octet scalar. The body length is + equal to: + + bodyLen = (2nd_octet << 24) | (3rd_octet << 16) | + (4th_octet << 8) | 5th_octet + + This basic set of one, two, and five-octet lengths is also used + internally to some packets. + + + + + + +Callas, et al Standards Track [Page 15] + +RFC 4880 OpenPGP Message Format November 2007 + + +4.2.2.4. Partial Body Lengths + + A Partial Body Length header is one octet long and encodes the length + of only part of the data packet. This length is a power of 2, from 1 + to 1,073,741,824 (2 to the 30th power). It is recognized by its one + octet value that is greater than or equal to 224, and less than 255. + The Partial Body Length is equal to: + + partialBodyLen = 1 << (1st_octet & 0x1F); + + Each Partial Body Length header is followed by a portion of the + packet body data. The Partial Body Length header specifies this + portion's length. Another length header (one octet, two-octet, + five-octet, or partial) follows that portion. The last length header + in the packet MUST NOT be a Partial Body Length header. Partial Body + Length headers may only be used for the non-final parts of the + packet. + + Note also that the last Body Length header can be a zero-length + header. + + An implementation MAY use Partial Body Lengths for data packets, be + they literal, compressed, or encrypted. The first partial length + MUST be at least 512 octets long. Partial Body Lengths MUST NOT be + used for any other packet types. + +4.2.3. Packet Length Examples + + These examples show ways that new format packets might encode the + packet lengths. + + A packet with length 100 may have its length encoded in one octet: + 0x64. This is followed by 100 octets of data. + + A packet with length 1723 may have its length encoded in two octets: + 0xC5, 0xFB. This header is followed by the 1723 octets of data. + + A packet with length 100000 may have its length encoded in five + octets: 0xFF, 0x00, 0x01, 0x86, 0xA0. + + It might also be encoded in the following octet stream: 0xEF, first + 32768 octets of data; 0xE1, next two octets of data; 0xE0, next one + octet of data; 0xF0, next 65536 octets of data; 0xC5, 0xDD, last 1693 + octets of data. This is just one possible encoding, and many + variations are possible on the size of the Partial Body Length + headers, as long as a regular Body Length header encodes the last + portion of the data. + + + + +Callas, et al Standards Track [Page 16] + +RFC 4880 OpenPGP Message Format November 2007 + + + Please note that in all of these explanations, the total length of + the packet is the length of the header(s) plus the length of the + body. + +4.3. Packet Tags + + The packet tag denotes what type of packet the body holds. Note that + old format headers can only have tags less than 16, whereas new + format headers can have tags as great as 63. The defined tags (in + decimal) are as follows: + + 0 -- Reserved - a packet tag MUST NOT have this value + 1 -- Public-Key Encrypted Session Key Packet + 2 -- Signature Packet + 3 -- Symmetric-Key Encrypted Session Key Packet + 4 -- One-Pass Signature Packet + 5 -- Secret-Key Packet + 6 -- Public-Key Packet + 7 -- Secret-Subkey Packet + 8 -- Compressed Data Packet + 9 -- Symmetrically Encrypted Data Packet + 10 -- Marker Packet + 11 -- Literal Data Packet + 12 -- Trust Packet + 13 -- User ID Packet + 14 -- Public-Subkey Packet + 17 -- User Attribute Packet + 18 -- Sym. Encrypted and Integrity Protected Data Packet + 19 -- Modification Detection Code Packet + 60 to 63 -- Private or Experimental Values + +5. Packet Types + +5.1. Public-Key Encrypted Session Key Packets (Tag 1) + + A Public-Key Encrypted Session Key packet holds the session key used + to encrypt a message. Zero or more Public-Key Encrypted Session Key + packets and/or Symmetric-Key Encrypted Session Key packets may + precede a Symmetrically Encrypted Data Packet, which holds an + encrypted message. The message is encrypted with the session key, + and the session key is itself encrypted and stored in the Encrypted + Session Key packet(s). The Symmetrically Encrypted Data Packet is + preceded by one Public-Key Encrypted Session Key packet for each + OpenPGP key to which the message is encrypted. The recipient of the + message finds a session key that is encrypted to their public key, + decrypts the session key, and then uses the session key to decrypt + the message. + + + + +Callas, et al Standards Track [Page 17] + +RFC 4880 OpenPGP Message Format November 2007 + + + The body of this packet consists of: + + - A one-octet number giving the version number of the packet type. + The currently defined value for packet version is 3. + + - An eight-octet number that gives the Key ID of the public key to + which the session key is encrypted. If the session key is + encrypted to a subkey, then the Key ID of this subkey is used + here instead of the Key ID of the primary key. + + - A one-octet number giving the public-key algorithm used. + + - A string of octets that is the encrypted session key. This + string takes up the remainder of the packet, and its contents are + dependent on the public-key algorithm used. + + Algorithm Specific Fields for RSA encryption + + - multiprecision integer (MPI) of RSA encrypted value m**e mod n. + + Algorithm Specific Fields for Elgamal encryption: + + - MPI of Elgamal (Diffie-Hellman) value g**k mod p. + + - MPI of Elgamal (Diffie-Hellman) value m * y**k mod p. + + The value "m" in the above formulas is derived from the session key + as follows. First, the session key is prefixed with a one-octet + algorithm identifier that specifies the symmetric encryption + algorithm used to encrypt the following Symmetrically Encrypted Data + Packet. Then a two-octet checksum is appended, which is equal to the + sum of the preceding session key octets, not including the algorithm + identifier, modulo 65536. This value is then encoded as described in + PKCS#1 block encoding EME-PKCS1-v1_5 in Section 7.2.1 of [RFC3447] to + form the "m" value used in the formulas above. See Section 13.1 of + this document for notes on OpenPGP's use of PKCS#1. + + Note that when an implementation forms several PKESKs with one + session key, forming a message that can be decrypted by several keys, + the implementation MUST make a new PKCS#1 encoding for each key. + + An implementation MAY accept or use a Key ID of zero as a "wild card" + or "speculative" Key ID. In this case, the receiving implementation + would try all available private keys, checking for a valid decrypted + session key. This format helps reduce traffic analysis of messages. + + + + + + +Callas, et al Standards Track [Page 18] + +RFC 4880 OpenPGP Message Format November 2007 + + +5.2. Signature Packet (Tag 2) + + A Signature packet describes a binding between some public key and + some data. The most common signatures are a signature of a file or a + block of text, and a signature that is a certification of a User ID. + + Two versions of Signature packets are defined. Version 3 provides + basic signature information, while version 4 provides an expandable + format with subpackets that can specify more information about the + signature. PGP 2.6.x only accepts version 3 signatures. + + Implementations SHOULD accept V3 signatures. Implementations SHOULD + generate V4 signatures. + + Note that if an implementation is creating an encrypted and signed + message that is encrypted to a V3 key, it is reasonable to create a + V3 signature. + +5.2.1. Signature Types + + There are a number of possible meanings for a signature, which are + indicated in a signature type octet in any given signature. Please + note that the vagueness of these meanings is not a flaw, but a + feature of the system. Because OpenPGP places final authority for + validity upon the receiver of a signature, it may be that one + signer's casual act might be more rigorous than some other + authority's positive act. See Section 5.2.4, "Computing Signatures", + for detailed information on how to compute and verify signatures of + each type. + + These meanings are as follows: + + 0x00: Signature of a binary document. + This means the signer owns it, created it, or certifies that it + has not been modified. + + 0x01: Signature of a canonical text document. + This means the signer owns it, created it, or certifies that it + has not been modified. The signature is calculated over the text + data with its line endings converted to . + + 0x02: Standalone signature. + This signature is a signature of only its own subpacket contents. + It is calculated identically to a signature over a zero-length + binary document. Note that it doesn't make sense to have a V3 + standalone signature. + + + + + +Callas, et al Standards Track [Page 19] + +RFC 4880 OpenPGP Message Format November 2007 + + + 0x10: Generic certification of a User ID and Public-Key packet. + The issuer of this certification does not make any particular + assertion as to how well the certifier has checked that the owner + of the key is in fact the person described by the User ID. + + 0x11: Persona certification of a User ID and Public-Key packet. + The issuer of this certification has not done any verification of + the claim that the owner of this key is the User ID specified. + + 0x12: Casual certification of a User ID and Public-Key packet. + The issuer of this certification has done some casual + verification of the claim of identity. + + 0x13: Positive certification of a User ID and Public-Key packet. + The issuer of this certification has done substantial + verification of the claim of identity. + + Most OpenPGP implementations make their "key signatures" as 0x10 + certifications. Some implementations can issue 0x11-0x13 + certifications, but few differentiate between the types. + + 0x18: Subkey Binding Signature + This signature is a statement by the top-level signing key that + indicates that it owns the subkey. This signature is calculated + directly on the primary key and subkey, and not on any User ID or + other packets. A signature that binds a signing subkey MUST have + an Embedded Signature subpacket in this binding signature that + contains a 0x19 signature made by the signing subkey on the + primary key and subkey. + + 0x19: Primary Key Binding Signature + This signature is a statement by a signing subkey, indicating + that it is owned by the primary key and subkey. This signature + is calculated the same way as a 0x18 signature: directly on the + primary key and subkey, and not on any User ID or other packets. + + 0x1F: Signature directly on a key + This signature is calculated directly on a key. It binds the + information in the Signature subpackets to the key, and is + appropriate to be used for subpackets that provide information + about the key, such as the Revocation Key subpacket. It is also + appropriate for statements that non-self certifiers want to make + about the key itself, rather than the binding between a key and a + name. + + + + + + + +Callas, et al Standards Track [Page 20] + +RFC 4880 OpenPGP Message Format November 2007 + + + 0x20: Key revocation signature + The signature is calculated directly on the key being revoked. A + revoked key is not to be used. Only revocation signatures by the + key being revoked, or by an authorized revocation key, should be + considered valid revocation signatures. + + 0x28: Subkey revocation signature + The signature is calculated directly on the subkey being revoked. + A revoked subkey is not to be used. Only revocation signatures + by the top-level signature key that is bound to this subkey, or + by an authorized revocation key, should be considered valid + revocation signatures. + + 0x30: Certification revocation signature + This signature revokes an earlier User ID certification signature + (signature class 0x10 through 0x13) or direct-key signature + (0x1F). It should be issued by the same key that issued the + revoked signature or an authorized revocation key. The signature + is computed over the same data as the certificate that it + revokes, and should have a later creation date than that + certificate. + + 0x40: Timestamp signature. + This signature is only meaningful for the timestamp contained in + it. + + 0x50: Third-Party Confirmation signature. + This signature is a signature over some other OpenPGP Signature + packet(s). It is analogous to a notary seal on the signed data. + A third-party signature SHOULD include Signature Target + subpacket(s) to give easy identification. Note that we really do + mean SHOULD. There are plausible uses for this (such as a blind + party that only sees the signature, not the key or source + document) that cannot include a target subpacket. + +5.2.2. Version 3 Signature Packet Format + + The body of a version 3 Signature Packet contains: + + - One-octet version number (3). + + - One-octet length of following hashed material. MUST be 5. + + - One-octet signature type. + + - Four-octet creation time. + + - Eight-octet Key ID of signer. + + + +Callas, et al Standards Track [Page 21] + +RFC 4880 OpenPGP Message Format November 2007 + + + - One-octet public-key algorithm. + + - One-octet hash algorithm. + + - Two-octet field holding left 16 bits of signed hash value. + + - One or more multiprecision integers comprising the signature. + This portion is algorithm specific, as described below. + + The concatenation of the data to be signed, the signature type, and + creation time from the Signature packet (5 additional octets) is + hashed. The resulting hash value is used in the signature algorithm. + The high 16 bits (first two octets) of the hash are included in the + Signature packet to provide a quick test to reject some invalid + signatures. + + Algorithm-Specific Fields for RSA signatures: + + - multiprecision integer (MPI) of RSA signature value m**d mod n. + + Algorithm-Specific Fields for DSA signatures: + + - MPI of DSA value r. + + - MPI of DSA value s. + + The signature calculation is based on a hash of the signed data, as + described above. The details of the calculation are different for + DSA signatures than for RSA signatures. + + With RSA signatures, the hash value is encoded using PKCS#1 encoding + type EMSA-PKCS1-v1_5 as described in Section 9.2 of RFC 3447. This + requires inserting the hash value as an octet string into an ASN.1 + structure. The object identifier for the type of hash being used is + included in the structure. The hexadecimal representations for the + currently defined hash algorithms are as follows: + + - MD5: 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x02, 0x05 + + - RIPEMD-160: 0x2B, 0x24, 0x03, 0x02, 0x01 + + - SHA-1: 0x2B, 0x0E, 0x03, 0x02, 0x1A + + - SHA224: 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x04 + + - SHA256: 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x01 + + - SHA384: 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x02 + + + +Callas, et al Standards Track [Page 22] + +RFC 4880 OpenPGP Message Format November 2007 + + + - SHA512: 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x03 + + The ASN.1 Object Identifiers (OIDs) are as follows: + + - MD5: 1.2.840.113549.2.5 + + - RIPEMD-160: 1.3.36.3.2.1 + + - SHA-1: 1.3.14.3.2.26 + + - SHA224: 2.16.840.1.101.3.4.2.4 + + - SHA256: 2.16.840.1.101.3.4.2.1 + + - SHA384: 2.16.840.1.101.3.4.2.2 + + - SHA512: 2.16.840.1.101.3.4.2.3 + + The full hash prefixes for these are as follows: + + MD5: 0x30, 0x20, 0x30, 0x0C, 0x06, 0x08, 0x2A, 0x86, + 0x48, 0x86, 0xF7, 0x0D, 0x02, 0x05, 0x05, 0x00, + 0x04, 0x10 + + RIPEMD-160: 0x30, 0x21, 0x30, 0x09, 0x06, 0x05, 0x2B, 0x24, + 0x03, 0x02, 0x01, 0x05, 0x00, 0x04, 0x14 + + SHA-1: 0x30, 0x21, 0x30, 0x09, 0x06, 0x05, 0x2b, 0x0E, + 0x03, 0x02, 0x1A, 0x05, 0x00, 0x04, 0x14 + + SHA224: 0x30, 0x31, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86, + 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x04, 0x05, + 0x00, 0x04, 0x1C + + SHA256: 0x30, 0x31, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86, + 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x01, 0x05, + 0x00, 0x04, 0x20 + + SHA384: 0x30, 0x41, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86, + 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x02, 0x05, + 0x00, 0x04, 0x30 + + SHA512: 0x30, 0x51, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86, + 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x03, 0x05, + 0x00, 0x04, 0x40 + + DSA signatures MUST use hashes that are equal in size to the number + of bits of q, the group generated by the DSA key's generator value. + + + +Callas, et al Standards Track [Page 23] + +RFC 4880 OpenPGP Message Format November 2007 + + + If the output size of the chosen hash is larger than the number of + bits of q, the hash result is truncated to fit by taking the number + of leftmost bits equal to the number of bits of q. This (possibly + truncated) hash function result is treated as a number and used + directly in the DSA signature algorithm. + +5.2.3. Version 4 Signature Packet Format + + The body of a version 4 Signature packet contains: + + - One-octet version number (4). + + - One-octet signature type. + + - One-octet public-key algorithm. + + - One-octet hash algorithm. + + - Two-octet scalar octet count for following hashed subpacket data. + Note that this is the length in octets of all of the hashed + subpackets; a pointer incremented by this number will skip over + the hashed subpackets. + + - Hashed subpacket data set (zero or more subpackets). + + - Two-octet scalar octet count for the following unhashed subpacket + data. Note that this is the length in octets of all of the + unhashed subpackets; a pointer incremented by this number will + skip over the unhashed subpackets. + + - Unhashed subpacket data set (zero or more subpackets). + + - Two-octet field holding the left 16 bits of the signed hash + value. + + - One or more multiprecision integers comprising the signature. + This portion is algorithm specific, as described above. + + The concatenation of the data being signed and the signature data + from the version number through the hashed subpacket data (inclusive) + is hashed. The resulting hash value is what is signed. The left 16 + bits of the hash are included in the Signature packet to provide a + quick test to reject some invalid signatures. + + There are two fields consisting of Signature subpackets. The first + field is hashed with the rest of the signature data, while the second + is unhashed. The second set of subpackets is not cryptographically + + + + +Callas, et al Standards Track [Page 24] + +RFC 4880 OpenPGP Message Format November 2007 + + + protected by the signature and should include only advisory + information. + + The algorithms for converting the hash function result to a signature + are described in a section below. + +5.2.3.1. Signature Subpacket Specification + + A subpacket data set consists of zero or more Signature subpackets. + In Signature packets, the subpacket data set is preceded by a two- + octet scalar count of the length in octets of all the subpackets. A + pointer incremented by this number will skip over the subpacket data + set. + + Each subpacket consists of a subpacket header and a body. The header + consists of: + + - the subpacket length (1, 2, or 5 octets), + + - the subpacket type (1 octet), + + and is followed by the subpacket-specific data. + + The length includes the type octet but not this length. Its format + is similar to the "new" format packet header lengths, but cannot have + Partial Body Lengths. That is: + + if the 1st octet < 192, then + lengthOfLength = 1 + subpacketLen = 1st_octet + + if the 1st octet >= 192 and < 255, then + lengthOfLength = 2 + subpacketLen = ((1st_octet - 192) << 8) + (2nd_octet) + 192 + + if the 1st octet = 255, then + lengthOfLength = 5 + subpacket length = [four-octet scalar starting at 2nd_octet] + + The value of the subpacket type octet may be: + + 0 = Reserved + 1 = Reserved + 2 = Signature Creation Time + 3 = Signature Expiration Time + 4 = Exportable Certification + 5 = Trust Signature + 6 = Regular Expression + + + +Callas, et al Standards Track [Page 25] + +RFC 4880 OpenPGP Message Format November 2007 + + + 7 = Revocable + 8 = Reserved + 9 = Key Expiration Time + 10 = Placeholder for backward compatibility + 11 = Preferred Symmetric Algorithms + 12 = Revocation Key + 13 = Reserved + 14 = Reserved + 15 = Reserved + 16 = Issuer + 17 = Reserved + 18 = Reserved + 19 = Reserved + 20 = Notation Data + 21 = Preferred Hash Algorithms + 22 = Preferred Compression Algorithms + 23 = Key Server Preferences + 24 = Preferred Key Server + 25 = Primary User ID + 26 = Policy URI + 27 = Key Flags + 28 = Signer's User ID + 29 = Reason for Revocation + 30 = Features + 31 = Signature Target + 32 = Embedded Signature + 100 To 110 = Private or experimental + + An implementation SHOULD ignore any subpacket of a type that it does + not recognize. + + Bit 7 of the subpacket type is the "critical" bit. If set, it + denotes that the subpacket is one that is critical for the evaluator + of the signature to recognize. If a subpacket is encountered that is + marked critical but is unknown to the evaluating software, the + evaluator SHOULD consider the signature to be in error. + + An evaluator may "recognize" a subpacket, but not implement it. The + purpose of the critical bit is to allow the signer to tell an + evaluator that it would prefer a new, unknown feature to generate an + error than be ignored. + + Implementations SHOULD implement the three preferred algorithm + subpackets (11, 21, and 22), as well as the "Reason for Revocation" + subpacket. Note, however, that if an implementation chooses not to + implement some of the preferences, it is required to behave in a + polite manner to respect the wishes of those users who do implement + these preferences. + + + +Callas, et al Standards Track [Page 26] + +RFC 4880 OpenPGP Message Format November 2007 + + +5.2.3.2. Signature Subpacket Types + + A number of subpackets are currently defined. Some subpackets apply + to the signature itself and some are attributes of the key. + Subpackets that are found on a self-signature are placed on a + certification made by the key itself. Note that a key may have more + than one User ID, and thus may have more than one self-signature, and + differing subpackets. + + A subpacket may be found either in the hashed or unhashed subpacket + sections of a signature. If a subpacket is not hashed, then the + information in it cannot be considered definitive because it is not + part of the signature proper. + +5.2.3.3. Notes on Self-Signatures + + A self-signature is a binding signature made by the key to which the + signature refers. There are three types of self-signatures, the + certification signatures (types 0x10-0x13), the direct-key signature + (type 0x1F), and the subkey binding signature (type 0x18). For + certification self-signatures, each User ID may have a self- + signature, and thus different subpackets in those self-signatures. + For subkey binding signatures, each subkey in fact has a self- + signature. Subpackets that appear in a certification self-signature + apply to the user name, and subpackets that appear in the subkey + self-signature apply to the subkey. Lastly, subpackets on the + direct-key signature apply to the entire key. + + Implementing software should interpret a self-signature's preference + subpackets as narrowly as possible. For example, suppose a key has + two user names, Alice and Bob. Suppose that Alice prefers the + symmetric algorithm CAST5, and Bob prefers IDEA or TripleDES. If the + software locates this key via Alice's name, then the preferred + algorithm is CAST5; if software locates the key via Bob's name, then + the preferred algorithm is IDEA. If the key is located by Key ID, + the algorithm of the primary User ID of the key provides the + preferred symmetric algorithm. + + Revoking a self-signature or allowing it to expire has a semantic + meaning that varies with the signature type. Revoking the self- + signature on a User ID effectively retires that user name. The + self-signature is a statement, "My name X is tied to my signing key + K" and is corroborated by other users' certifications. If another + user revokes their certification, they are effectively saying that + they no longer believe that name and that key are tied together. + Similarly, if the users themselves revoke their self-signature, then + the users no longer go by that name, no longer have that email + address, etc. Revoking a binding signature effectively retires that + + + +Callas, et al Standards Track [Page 27] + +RFC 4880 OpenPGP Message Format November 2007 + + + subkey. Revoking a direct-key signature cancels that signature. + Please see the "Reason for Revocation" subpacket (Section 5.2.3.23) + for more relevant detail. + + Since a self-signature contains important information about the key's + use, an implementation SHOULD allow the user to rewrite the self- + signature, and important information in it, such as preferences and + key expiration. + + It is good practice to verify that a self-signature imported into an + implementation doesn't advertise features that the implementation + doesn't support, rewriting the signature as appropriate. + + An implementation that encounters multiple self-signatures on the + same object may resolve the ambiguity in any way it sees fit, but it + is RECOMMENDED that priority be given to the most recent self- + signature. + +5.2.3.4. Signature Creation Time + + (4-octet time field) + + The time the signature was made. + + MUST be present in the hashed area. + +5.2.3.5. Issuer + + (8-octet Key ID) + + The OpenPGP Key ID of the key issuing the signature. + +5.2.3.6. Key Expiration Time + + (4-octet time field) + + The validity period of the key. This is the number of seconds after + the key creation time that the key expires. If this is not present + or has a value of zero, the key never expires. This is found only on + a self-signature. + +5.2.3.7. Preferred Symmetric Algorithms + + (array of one-octet values) + + Symmetric algorithm numbers that indicate which algorithms the key + holder prefers to use. The subpacket body is an ordered list of + octets with the most preferred listed first. It is assumed that only + + + +Callas, et al Standards Track [Page 28] + +RFC 4880 OpenPGP Message Format November 2007 + + + algorithms listed are supported by the recipient's software. + Algorithm numbers are in Section 9. This is only found on a self- + signature. + +5.2.3.8. Preferred Hash Algorithms + + (array of one-octet values) + + Message digest algorithm numbers that indicate which algorithms the + key holder prefers to receive. Like the preferred symmetric + algorithms, the list is ordered. Algorithm numbers are in Section 9. + This is only found on a self-signature. + +5.2.3.9. Preferred Compression Algorithms + + (array of one-octet values) + + Compression algorithm numbers that indicate which algorithms the key + holder prefers to use. Like the preferred symmetric algorithms, the + list is ordered. Algorithm numbers are in Section 9. If this + subpacket is not included, ZIP is preferred. A zero denotes that + uncompressed data is preferred; the key holder's software might have + no compression software in that implementation. This is only found + on a self-signature. + +5.2.3.10. Signature Expiration Time + + (4-octet time field) + + The validity period of the signature. This is the number of seconds + after the signature creation time that the signature expires. If + this is not present or has a value of zero, it never expires. + +5.2.3.11. Exportable Certification + + (1 octet of exportability, 0 for not, 1 for exportable) + + This subpacket denotes whether a certification signature is + "exportable", to be used by other users than the signature's issuer. + The packet body contains a Boolean flag indicating whether the + signature is exportable. If this packet is not present, the + certification is exportable; it is equivalent to a flag containing a + 1. + + Non-exportable, or "local", certifications are signatures made by a + user to mark a key as valid within that user's implementation only. + + + + + +Callas, et al Standards Track [Page 29] + +RFC 4880 OpenPGP Message Format November 2007 + + + Thus, when an implementation prepares a user's copy of a key for + transport to another user (this is the process of "exporting" the + key), any local certification signatures are deleted from the key. + + The receiver of a transported key "imports" it, and likewise trims + any local certifications. In normal operation, there won't be any, + assuming the import is performed on an exported key. However, there + are instances where this can reasonably happen. For example, if an + implementation allows keys to be imported from a key database in + addition to an exported key, then this situation can arise. + + Some implementations do not represent the interest of a single user + (for example, a key server). Such implementations always trim local + certifications from any key they handle. + +5.2.3.12. Revocable + + (1 octet of revocability, 0 for not, 1 for revocable) + + Signature's revocability status. The packet body contains a Boolean + flag indicating whether the signature is revocable. Signatures that + are not revocable have any later revocation signatures ignored. They + represent a commitment by the signer that he cannot revoke his + signature for the life of his key. If this packet is not present, + the signature is revocable. + +5.2.3.13. Trust Signature + + (1 octet "level" (depth), 1 octet of trust amount) + + Signer asserts that the key is not only valid but also trustworthy at + the specified level. Level 0 has the same meaning as an ordinary + validity signature. Level 1 means that the signed key is asserted to + be a valid trusted introducer, with the 2nd octet of the body + specifying the degree of trust. Level 2 means that the signed key is + asserted to be trusted to issue level 1 trust signatures, i.e., that + it is a "meta introducer". Generally, a level n trust signature + asserts that a key is trusted to issue level n-1 trust signatures. + The trust amount is in a range from 0-255, interpreted such that + values less than 120 indicate partial trust and values of 120 or + greater indicate complete trust. Implementations SHOULD emit values + of 60 for partial trust and 120 for complete trust. + + + + + + + + + +Callas, et al Standards Track [Page 30] + +RFC 4880 OpenPGP Message Format November 2007 + + +5.2.3.14. Regular Expression + + (null-terminated regular expression) + + Used in conjunction with trust Signature packets (of level > 0) to + limit the scope of trust that is extended. Only signatures by the + target key on User IDs that match the regular expression in the body + of this packet have trust extended by the trust Signature subpacket. + The regular expression uses the same syntax as the Henry Spencer's + "almost public domain" regular expression [REGEX] package. A + description of the syntax is found in Section 8 below. + +5.2.3.15. Revocation Key + + (1 octet of class, 1 octet of public-key algorithm ID, 20 octets of + fingerprint) + + Authorizes the specified key to issue revocation signatures for this + key. Class octet must have bit 0x80 set. If the bit 0x40 is set, + then this means that the revocation information is sensitive. Other + bits are for future expansion to other kinds of authorizations. This + is found on a self-signature. + + If the "sensitive" flag is set, the keyholder feels this subpacket + contains private trust information that describes a real-world + sensitive relationship. If this flag is set, implementations SHOULD + NOT export this signature to other users except in cases where the + data needs to be available: when the signature is being sent to the + designated revoker, or when it is accompanied by a revocation + signature from that revoker. Note that it may be appropriate to + isolate this subpacket within a separate signature so that it is not + combined with other subpackets that need to be exported. + +5.2.3.16. Notation Data + + (4 octets of flags, 2 octets of name length (M), + 2 octets of value length (N), + M octets of name data, + N octets of value data) + + This subpacket describes a "notation" on the signature that the + issuer wishes to make. The notation has a name and a value, each of + which are strings of octets. There may be more than one notation in + a signature. Notations can be used for any extension the issuer of + the signature cares to make. The "flags" field holds four octets of + flags. + + + + + +Callas, et al Standards Track [Page 31] + +RFC 4880 OpenPGP Message Format November 2007 + + + All undefined flags MUST be zero. Defined flags are as follows: + + First octet: 0x80 = human-readable. This note value is text. + Other octets: none. + + Notation names are arbitrary strings encoded in UTF-8. They reside + in two namespaces: The IETF namespace and the user namespace. + + The IETF namespace is registered with IANA. These names MUST NOT + contain the "@" character (0x40). This is a tag for the user + namespace. + + Names in the user namespace consist of a UTF-8 string tag followed by + "@" followed by a DNS domain name. Note that the tag MUST NOT + contain an "@" character. For example, the "sample" tag used by + Example Corporation could be "sample@example.com". + + Names in a user space are owned and controlled by the owners of that + domain. Obviously, it's bad form to create a new name in a DNS space + that you don't own. + + Since the user namespace is in the form of an email address, + implementers MAY wish to arrange for that address to reach a person + who can be consulted about the use of the named tag. Note that due + to UTF-8 encoding, not all valid user space name tags are valid email + addresses. + + If there is a critical notation, the criticality applies to that + specific notation and not to notations in general. + +5.2.3.17. Key Server Preferences + + (N octets of flags) + + This is a list of one-bit flags that indicate preferences that the + key holder has about how the key is handled on a key server. All + undefined flags MUST be zero. + + First octet: 0x80 = No-modify + the key holder requests that this key only be modified or updated + by the key holder or an administrator of the key server. + + This is found only on a self-signature. + + + + + + + + +Callas, et al Standards Track [Page 32] + +RFC 4880 OpenPGP Message Format November 2007 + + +5.2.3.18. Preferred Key Server + + (String) + + This is a URI of a key server that the key holder prefers be used for + updates. Note that keys with multiple User IDs can have a preferred + key server for each User ID. Note also that since this is a URI, the + key server can actually be a copy of the key retrieved by ftp, http, + finger, etc. + +5.2.3.19. Primary User ID + + (1 octet, Boolean) + + This is a flag in a User ID's self-signature that states whether this + User ID is the main User ID for this key. It is reasonable for an + implementation to resolve ambiguities in preferences, etc. by + referring to the primary User ID. If this flag is absent, its value + is zero. If more than one User ID in a key is marked as primary, the + implementation may resolve the ambiguity in any way it sees fit, but + it is RECOMMENDED that priority be given to the User ID with the most + recent self-signature. + + When appearing on a self-signature on a User ID packet, this + subpacket applies only to User ID packets. When appearing on a + self-signature on a User Attribute packet, this subpacket applies + only to User Attribute packets. That is to say, there are two + different and independent "primaries" -- one for User IDs, and one + for User Attributes. + +5.2.3.20. Policy URI + + (String) + + This subpacket contains a URI of a document that describes the policy + under which the signature was issued. + +5.2.3.21. Key Flags + + (N octets of flags) + + This subpacket contains a list of binary flags that hold information + about a key. It is a string of octets, and an implementation MUST + NOT assume a fixed size. This is so it can grow over time. If a + list is shorter than an implementation expects, the unstated flags + are considered to be zero. The defined flags are as follows: + + + + + +Callas, et al Standards Track [Page 33] + +RFC 4880 OpenPGP Message Format November 2007 + + + First octet: + + 0x01 - This key may be used to certify other keys. + + 0x02 - This key may be used to sign data. + + 0x04 - This key may be used to encrypt communications. + + 0x08 - This key may be used to encrypt storage. + + 0x10 - The private component of this key may have been split + by a secret-sharing mechanism. + + 0x20 - This key may be used for authentication. + + 0x80 - The private component of this key may be in the + possession of more than one person. + + Usage notes: + + The flags in this packet may appear in self-signatures or in + certification signatures. They mean different things depending on + who is making the statement -- for example, a certification signature + that has the "sign data" flag is stating that the certification is + for that use. On the other hand, the "communications encryption" + flag in a self-signature is stating a preference that a given key be + used for communications. Note however, that it is a thorny issue to + determine what is "communications" and what is "storage". This + decision is left wholly up to the implementation; the authors of this + document do not claim any special wisdom on the issue and realize + that accepted opinion may change. + + The "split key" (0x10) and "group key" (0x80) flags are placed on a + self-signature only; they are meaningless on a certification + signature. They SHOULD be placed only on a direct-key signature + (type 0x1F) or a subkey signature (type 0x18), one that refers to the + key the flag applies to. + +5.2.3.22. Signer's User ID + + (String) + + This subpacket allows a keyholder to state which User ID is + responsible for the signing. Many keyholders use a single key for + different purposes, such as business communications as well as + personal communications. This subpacket allows such a keyholder to + state which of their roles is making a signature. + + + + +Callas, et al Standards Track [Page 34] + +RFC 4880 OpenPGP Message Format November 2007 + + + This subpacket is not appropriate to use to refer to a User Attribute + packet. + +5.2.3.23. Reason for Revocation + + (1 octet of revocation code, N octets of reason string) + + This subpacket is used only in key revocation and certification + revocation signatures. It describes the reason why the key or + certificate was revoked. + + The first octet contains a machine-readable code that denotes the + reason for the revocation: + + 0 - No reason specified (key revocations or cert revocations) + 1 - Key is superseded (key revocations) + 2 - Key material has been compromised (key revocations) + 3 - Key is retired and no longer used (key revocations) + 32 - User ID information is no longer valid (cert revocations) + 100-110 - Private Use + + Following the revocation code is a string of octets that gives + information about the Reason for Revocation in human-readable form + (UTF-8). The string may be null, that is, of zero length. The + length of the subpacket is the length of the reason string plus one. + An implementation SHOULD implement this subpacket, include it in all + revocation signatures, and interpret revocations appropriately. + There are important semantic differences between the reasons, and + there are thus important reasons for revoking signatures. + + If a key has been revoked because of a compromise, all signatures + created by that key are suspect. However, if it was merely + superseded or retired, old signatures are still valid. If the + revoked signature is the self-signature for certifying a User ID, a + revocation denotes that that user name is no longer in use. Such a + revocation SHOULD include a 0x20 code. + + Note that any signature may be revoked, including a certification on + some other person's key. There are many good reasons for revoking a + certification signature, such as the case where the keyholder leaves + the employ of a business with an email address. A revoked + certification is no longer a part of validity calculations. + + + + + + + + + +Callas, et al Standards Track [Page 35] + +RFC 4880 OpenPGP Message Format November 2007 + + +5.2.3.24. Features + + (N octets of flags) + + The Features subpacket denotes which advanced OpenPGP features a + user's implementation supports. This is so that as features are + added to OpenPGP that cannot be backwards-compatible, a user can + state that they can use that feature. The flags are single bits that + indicate that a given feature is supported. + + This subpacket is similar to a preferences subpacket, and only + appears in a self-signature. + + An implementation SHOULD NOT use a feature listed when sending to a + user who does not state that they can use it. + + Defined features are as follows: + + First octet: + + 0x01 - Modification Detection (packets 18 and 19) + + If an implementation implements any of the defined features, it + SHOULD implement the Features subpacket, too. + + An implementation may freely infer features from other suitable + implementation-dependent mechanisms. + +5.2.3.25. Signature Target + + (1 octet public-key algorithm, 1 octet hash algorithm, N octets hash) + + This subpacket identifies a specific target signature to which a + signature refers. For revocation signatures, this subpacket + provides explicit designation of which signature is being revoked. + For a third-party or timestamp signature, this designates what + signature is signed. All arguments are an identifier of that target + signature. + + The N octets of hash data MUST be the size of the hash of the + signature. For example, a target signature with a SHA-1 hash MUST + have 20 octets of hash data. + + + + + + + + + +Callas, et al Standards Track [Page 36] + +RFC 4880 OpenPGP Message Format November 2007 + + +5.2.3.26. Embedded Signature + + (1 signature packet body) + + This subpacket contains a complete Signature packet body as + specified in Section 5.2 above. It is useful when one signature + needs to refer to, or be incorporated in, another signature. + +5.2.4. Computing Signatures + + All signatures are formed by producing a hash over the signature + data, and then using the resulting hash in the signature algorithm. + + For binary document signatures (type 0x00), the document data is + hashed directly. For text document signatures (type 0x01), the + document is canonicalized by converting line endings to , + and the resulting data is hashed. + + When a signature is made over a key, the hash data starts with the + octet 0x99, followed by a two-octet length of the key, and then body + of the key packet. (Note that this is an old-style packet header for + a key packet with two-octet length.) A subkey binding signature + (type 0x18) or primary key binding signature (type 0x19) then hashes + the subkey using the same format as the main key (also using 0x99 as + the first octet). Key revocation signatures (types 0x20 and 0x28) + hash only the key being revoked. + + A certification signature (type 0x10 through 0x13) hashes the User + ID being bound to the key into the hash context after the above + data. A V3 certification hashes the contents of the User ID or + attribute packet packet, without any header. A V4 certification + hashes the constant 0xB4 for User ID certifications or the constant + 0xD1 for User Attribute certifications, followed by a four-octet + number giving the length of the User ID or User Attribute data, and + then the User ID or User Attribute data. + + When a signature is made over a Signature packet (type 0x50), the + hash data starts with the octet 0x88, followed by the four-octet + length of the signature, and then the body of the Signature packet. + (Note that this is an old-style packet header for a Signature packet + with the length-of-length set to zero.) The unhashed subpacket data + of the Signature packet being hashed is not included in the hash, and + the unhashed subpacket data length value is set to zero. + + Once the data body is hashed, then a trailer is hashed. A V3 + signature hashes five octets of the packet body, starting from the + signature type field. This data is the signature type, followed by + the four-octet signature time. A V4 signature hashes the packet body + + + +Callas, et al Standards Track [Page 37] + +RFC 4880 OpenPGP Message Format November 2007 + + + starting from its first field, the version number, through the end + of the hashed subpacket data. Thus, the fields hashed are the + signature version, the signature type, the public-key algorithm, the + hash algorithm, the hashed subpacket length, and the hashed + subpacket body. + + V4 signatures also hash in a final trailer of six octets: the + version of the Signature packet, i.e., 0x04; 0xFF; and a four-octet, + big-endian number that is the length of the hashed data from the + Signature packet (note that this number does not include these final + six octets). + + After all this has been hashed in a single hash context, the + resulting hash field is used in the signature algorithm and placed + at the end of the Signature packet. + +5.2.4.1. Subpacket Hints + + It is certainly possible for a signature to contain conflicting + information in subpackets. For example, a signature may contain + multiple copies of a preference or multiple expiration times. In + most cases, an implementation SHOULD use the last subpacket in the + signature, but MAY use any conflict resolution scheme that makes + more sense. Please note that we are intentionally leaving conflict + resolution to the implementer; most conflicts are simply syntax + errors, and the wishy-washy language here allows a receiver to be + generous in what they accept, while putting pressure on a creator to + be stingy in what they generate. + + Some apparent conflicts may actually make sense -- for example, + suppose a keyholder has a V3 key and a V4 key that share the same + RSA key material. Either of these keys can verify a signature + created by the other, and it may be reasonable for a signature to + contain an issuer subpacket for each key, as a way of explicitly + tying those keys to the signature. + +5.3. Symmetric-Key Encrypted Session Key Packets (Tag 3) + + The Symmetric-Key Encrypted Session Key packet holds the + symmetric-key encryption of a session key used to encrypt a message. + Zero or more Public-Key Encrypted Session Key packets and/or + Symmetric-Key Encrypted Session Key packets may precede a + Symmetrically Encrypted Data packet that holds an encrypted message. + The message is encrypted with a session key, and the session key is + itself encrypted and stored in the Encrypted Session Key packet or + the Symmetric-Key Encrypted Session Key packet. + + + + + +Callas, et al Standards Track [Page 38] + +RFC 4880 OpenPGP Message Format November 2007 + + + If the Symmetrically Encrypted Data packet is preceded by one or + more Symmetric-Key Encrypted Session Key packets, each specifies a + passphrase that may be used to decrypt the message. This allows a + message to be encrypted to a number of public keys, and also to one + or more passphrases. This packet type is new and is not generated + by PGP 2.x or PGP 5.0. + + The body of this packet consists of: + + - A one-octet version number. The only currently defined version + is 4. + + - A one-octet number describing the symmetric algorithm used. + + - A string-to-key (S2K) specifier, length as defined above. + + - Optionally, the encrypted session key itself, which is decrypted + with the string-to-key object. + + If the encrypted session key is not present (which can be detected + on the basis of packet length and S2K specifier size), then the S2K + algorithm applied to the passphrase produces the session key for + decrypting the file, using the symmetric cipher algorithm from the + Symmetric-Key Encrypted Session Key packet. + + If the encrypted session key is present, the result of applying the + S2K algorithm to the passphrase is used to decrypt just that + encrypted session key field, using CFB mode with an IV of all zeros. + The decryption result consists of a one-octet algorithm identifier + that specifies the symmetric-key encryption algorithm used to + encrypt the following Symmetrically Encrypted Data packet, followed + by the session key octets themselves. + + Note: because an all-zero IV is used for this decryption, the S2K + specifier MUST use a salt value, either a Salted S2K or an + Iterated-Salted S2K. The salt value will ensure that the decryption + key is not repeated even if the passphrase is reused. + +5.4. One-Pass Signature Packets (Tag 4) + + The One-Pass Signature packet precedes the signed data and contains + enough information to allow the receiver to begin calculating any + hashes needed to verify the signature. It allows the Signature + packet to be placed at the end of the message, so that the signer + can compute the entire signed message in one pass. + + A One-Pass Signature does not interoperate with PGP 2.6.x or + earlier. + + + +Callas, et al Standards Track [Page 39] + +RFC 4880 OpenPGP Message Format November 2007 + + + The body of this packet consists of: + + - A one-octet version number. The current version is 3. + + - A one-octet signature type. Signature types are described in + Section 5.2.1. + + - A one-octet number describing the hash algorithm used. + + - A one-octet number describing the public-key algorithm used. + + - An eight-octet number holding the Key ID of the signing key. + + - A one-octet number holding a flag showing whether the signature + is nested. A zero value indicates that the next packet is + another One-Pass Signature packet that describes another + signature to be applied to the same message data. + + Note that if a message contains more than one one-pass signature, + then the Signature packets bracket the message; that is, the first + Signature packet after the message corresponds to the last one-pass + packet and the final Signature packet corresponds to the first + one-pass packet. + +5.5. Key Material Packet + + A key material packet contains all the information about a public or + private key. There are four variants of this packet type, and two + major versions. Consequently, this section is complex. + +5.5.1. Key Packet Variants + +5.5.1.1. Public-Key Packet (Tag 6) + + A Public-Key packet starts a series of packets that forms an OpenPGP + key (sometimes called an OpenPGP certificate). + +5.5.1.2. Public-Subkey Packet (Tag 14) + + A Public-Subkey packet (tag 14) has exactly the same format as a + Public-Key packet, but denotes a subkey. One or more subkeys may be + associated with a top-level key. By convention, the top-level key + provides signature services, and the subkeys provide encryption + services. + + Note: in PGP 2.6.x, tag 14 was intended to indicate a comment + packet. This tag was selected for reuse because no previous version + of PGP ever emitted comment packets but they did properly ignore + + + +Callas, et al Standards Track [Page 40] + +RFC 4880 OpenPGP Message Format November 2007 + + + them. Public-Subkey packets are ignored by PGP 2.6.x and do not + cause it to fail, providing a limited degree of backward + compatibility. + +5.5.1.3. Secret-Key Packet (Tag 5) + + A Secret-Key packet contains all the information that is found in a + Public-Key packet, including the public-key material, but also + includes the secret-key material after all the public-key fields. + +5.5.1.4. Secret-Subkey Packet (Tag 7) + + A Secret-Subkey packet (tag 7) is the subkey analog of the Secret + Key packet and has exactly the same format. + +5.5.2. Public-Key Packet Formats + + There are two versions of key-material packets. Version 3 packets + were first generated by PGP 2.6. Version 4 keys first appeared in + PGP 5.0 and are the preferred key version for OpenPGP. + + OpenPGP implementations MUST create keys with version 4 format. V3 + keys are deprecated; an implementation MUST NOT generate a V3 key, + but MAY accept it. + + A version 3 public key or public-subkey packet contains: + + - A one-octet version number (3). + + - A four-octet number denoting the time that the key was created. + + - A two-octet number denoting the time in days that this key is + valid. If this number is zero, then it does not expire. + + - A one-octet number denoting the public-key algorithm of this key. + + - A series of multiprecision integers comprising the key material: + + - a multiprecision integer (MPI) of RSA public modulus n; + + - an MPI of RSA public encryption exponent e. + + V3 keys are deprecated. They contain three weaknesses. First, it is + relatively easy to construct a V3 key that has the same Key ID as any + other key because the Key ID is simply the low 64 bits of the public + modulus. Secondly, because the fingerprint of a V3 key hashes the + key material, but not its length, there is an increased opportunity + for fingerprint collisions. Third, there are weaknesses in the MD5 + + + +Callas, et al Standards Track [Page 41] + +RFC 4880 OpenPGP Message Format November 2007 + + + hash algorithm that make developers prefer other algorithms. See + below for a fuller discussion of Key IDs and fingerprints. + + V2 keys are identical to the deprecated V3 keys except for the + version number. An implementation MUST NOT generate them and MAY + accept or reject them as it sees fit. + + The version 4 format is similar to the version 3 format except for + the absence of a validity period. This has been moved to the + Signature packet. In addition, fingerprints of version 4 keys are + calculated differently from version 3 keys, as described in the + section "Enhanced Key Formats". + + A version 4 packet contains: + + - A one-octet version number (4). + + - A four-octet number denoting the time that the key was created. + + - A one-octet number denoting the public-key algorithm of this key. + + - A series of multiprecision integers comprising the key material. + This algorithm-specific portion is: + + Algorithm-Specific Fields for RSA public keys: + + - multiprecision integer (MPI) of RSA public modulus n; + + - MPI of RSA public encryption exponent e. + + Algorithm-Specific Fields for DSA public keys: + + - MPI of DSA prime p; + + - MPI of DSA group order q (q is a prime divisor of p-1); + + - MPI of DSA group generator g; + + - MPI of DSA public-key value y (= g**x mod p where x + is secret). + + Algorithm-Specific Fields for Elgamal public keys: + + - MPI of Elgamal prime p; + + - MPI of Elgamal group generator g; + + + + + +Callas, et al Standards Track [Page 42] + +RFC 4880 OpenPGP Message Format November 2007 + + + - MPI of Elgamal public key value y (= g**x mod p where x + is secret). + +5.5.3. Secret-Key Packet Formats + + The Secret-Key and Secret-Subkey packets contain all the data of the + Public-Key and Public-Subkey packets, with additional algorithm- + specific secret-key data appended, usually in encrypted form. + + The packet contains: + + - A Public-Key or Public-Subkey packet, as described above. + + - One octet indicating string-to-key usage conventions. Zero + indicates that the secret-key data is not encrypted. 255 or 254 + indicates that a string-to-key specifier is being given. Any + other value is a symmetric-key encryption algorithm identifier. + + - [Optional] If string-to-key usage octet was 255 or 254, a one- + octet symmetric encryption algorithm. + + - [Optional] If string-to-key usage octet was 255 or 254, a + string-to-key specifier. The length of the string-to-key + specifier is implied by its type, as described above. + + - [Optional] If secret data is encrypted (string-to-key usage octet + not zero), an Initial Vector (IV) of the same length as the + cipher's block size. + + - Plain or encrypted multiprecision integers comprising the secret + key data. These algorithm-specific fields are as described + below. + + - If the string-to-key usage octet is zero or 255, then a two-octet + checksum of the plaintext of the algorithm-specific portion (sum + of all octets, mod 65536). If the string-to-key usage octet was + 254, then a 20-octet SHA-1 hash of the plaintext of the + algorithm-specific portion. This checksum or hash is encrypted + together with the algorithm-specific fields (if string-to-key + usage octet is not zero). Note that for all other values, a + two-octet checksum is required. + + Algorithm-Specific Fields for RSA secret keys: + + - multiprecision integer (MPI) of RSA secret exponent d. + + - MPI of RSA secret prime value p. + + + + +Callas, et al Standards Track [Page 43] + +RFC 4880 OpenPGP Message Format November 2007 + + + - MPI of RSA secret prime value q (p < q). + + - MPI of u, the multiplicative inverse of p, mod q. + + Algorithm-Specific Fields for DSA secret keys: + + - MPI of DSA secret exponent x. + + Algorithm-Specific Fields for Elgamal secret keys: + + - MPI of Elgamal secret exponent x. + + Secret MPI values can be encrypted using a passphrase. If a string- + to-key specifier is given, that describes the algorithm for + converting the passphrase to a key, else a simple MD5 hash of the + passphrase is used. Implementations MUST use a string-to-key + specifier; the simple hash is for backward compatibility and is + deprecated, though implementations MAY continue to use existing + private keys in the old format. The cipher for encrypting the MPIs + is specified in the Secret-Key packet. + + Encryption/decryption of the secret data is done in CFB mode using + the key created from the passphrase and the Initial Vector from the + packet. A different mode is used with V3 keys (which are only RSA) + than with other key formats. With V3 keys, the MPI bit count prefix + (i.e., the first two octets) is not encrypted. Only the MPI non- + prefix data is encrypted. Furthermore, the CFB state is + resynchronized at the beginning of each new MPI value, so that the + CFB block boundary is aligned with the start of the MPI data. + + With V4 keys, a simpler method is used. All secret MPI values are + encrypted in CFB mode, including the MPI bitcount prefix. + + The two-octet checksum that follows the algorithm-specific portion is + the algebraic sum, mod 65536, of the plaintext of all the algorithm- + specific octets (including MPI prefix and data). With V3 keys, the + checksum is stored in the clear. With V4 keys, the checksum is + encrypted like the algorithm-specific data. This value is used to + check that the passphrase was correct. However, this checksum is + deprecated; an implementation SHOULD NOT use it, but should rather + use the SHA-1 hash denoted with a usage octet of 254. The reason for + this is that there are some attacks that involve undetectably + modifying the secret key. + + + + + + + + +Callas, et al Standards Track [Page 44] + +RFC 4880 OpenPGP Message Format November 2007 + + +5.6. Compressed Data Packet (Tag 8) + + The Compressed Data packet contains compressed data. Typically, this + packet is found as the contents of an encrypted packet, or following + a Signature or One-Pass Signature packet, and contains a literal data + packet. + + The body of this packet consists of: + + - One octet that gives the algorithm used to compress the packet. + + - Compressed data, which makes up the remainder of the packet. + + A Compressed Data Packet's body contains an block that compresses + some set of packets. See section "Packet Composition" for details on + how messages are formed. + + ZIP-compressed packets are compressed with raw RFC 1951 [RFC1951] + DEFLATE blocks. Note that PGP V2.6 uses 13 bits of compression. If + an implementation uses more bits of compression, PGP V2.6 cannot + decompress it. + + ZLIB-compressed packets are compressed with RFC 1950 [RFC1950] ZLIB- + style blocks. + + BZip2-compressed packets are compressed using the BZip2 [BZ2] + algorithm. + +5.7. Symmetrically Encrypted Data Packet (Tag 9) + + The Symmetrically Encrypted Data packet contains data encrypted with + a symmetric-key algorithm. When it has been decrypted, it contains + other packets (usually a literal data packet or compressed data + packet, but in theory other Symmetrically Encrypted Data packets or + sequences of packets that form whole OpenPGP messages). + + The body of this packet consists of: + + - Encrypted data, the output of the selected symmetric-key cipher + operating in OpenPGP's variant of Cipher Feedback (CFB) mode. + + The symmetric cipher used may be specified in a Public-Key or + Symmetric-Key Encrypted Session Key packet that precedes the + Symmetrically Encrypted Data packet. In that case, the cipher + algorithm octet is prefixed to the session key before it is + encrypted. If no packets of these types precede the encrypted data, + the IDEA algorithm is used with the session key calculated as the MD5 + hash of the passphrase, though this use is deprecated. + + + +Callas, et al Standards Track [Page 45] + +RFC 4880 OpenPGP Message Format November 2007 + + + The data is encrypted in CFB mode, with a CFB shift size equal to the + cipher's block size. The Initial Vector (IV) is specified as all + zeros. Instead of using an IV, OpenPGP prefixes a string of length + equal to the block size of the cipher plus two to the data before it + is encrypted. The first block-size octets (for example, 8 octets for + a 64-bit block length) are random, and the following two octets are + copies of the last two octets of the IV. For example, in an 8-octet + block, octet 9 is a repeat of octet 7, and octet 10 is a repeat of + octet 8. In a cipher of length 16, octet 17 is a repeat of octet 15 + and octet 18 is a repeat of octet 16. As a pedantic clarification, + in both these examples, we consider the first octet to be numbered 1. + + After encrypting the first block-size-plus-two octets, the CFB state + is resynchronized. The last block-size octets of ciphertext are + passed through the cipher and the block boundary is reset. + + The repetition of 16 bits in the random data prefixed to the message + allows the receiver to immediately check whether the session key is + incorrect. See the "Security Considerations" section for hints on + the proper use of this "quick check". + +5.8. Marker Packet (Obsolete Literal Packet) (Tag 10) + + An experimental version of PGP used this packet as the Literal + packet, but no released version of PGP generated Literal packets with + this tag. With PGP 5.x, this packet has been reassigned and is + reserved for use as the Marker packet. + + The body of this packet consists of: + + - The three octets 0x50, 0x47, 0x50 (which spell "PGP" in UTF-8). + + Such a packet MUST be ignored when received. It may be placed at the + beginning of a message that uses features not available in PGP 2.6.x + in order to cause that version to report that newer software is + necessary to process the message. + +5.9. Literal Data Packet (Tag 11) + + A Literal Data packet contains the body of a message; data that is + not to be further interpreted. + + The body of this packet consists of: + + - A one-octet field that describes how the data is formatted. + + + + + + +Callas, et al Standards Track [Page 46] + +RFC 4880 OpenPGP Message Format November 2007 + + + If it is a 'b' (0x62), then the Literal packet contains binary data. + If it is a 't' (0x74), then it contains text data, and thus may need + line ends converted to local form, or other text-mode changes. The + tag 'u' (0x75) means the same as 't', but also indicates that + implementation believes that the literal data contains UTF-8 text. + + Early versions of PGP also defined a value of 'l' as a 'local' mode + for machine-local conversions. RFC 1991 [RFC1991] incorrectly stated + this local mode flag as '1' (ASCII numeral one). Both of these local + modes are deprecated. + + - File name as a string (one-octet length, followed by a file + name). This may be a zero-length string. Commonly, if the + source of the encrypted data is a file, this will be the name of + the encrypted file. An implementation MAY consider the file name + in the Literal packet to be a more authoritative name than the + actual file name. + + If the special name "_CONSOLE" is used, the message is considered to + be "for your eyes only". This advises that the message data is + unusually sensitive, and the receiving program should process it more + carefully, perhaps avoiding storing the received data to disk, for + example. + + - A four-octet number that indicates a date associated with the + literal data. Commonly, the date might be the modification date + of a file, or the time the packet was created, or a zero that + indicates no specific time. + + - The remainder of the packet is literal data. + + Text data is stored with text endings (i.e., network- + normal line endings). These should be converted to native line + endings by the receiving software. + +5.10. Trust Packet (Tag 12) + + The Trust packet is used only within keyrings and is not normally + exported. Trust packets contain data that record the user's + specifications of which key holders are trustworthy introducers, + along with other information that implementing software uses for + trust information. The format of Trust packets is defined by a given + implementation. + + Trust packets SHOULD NOT be emitted to output streams that are + transferred to other users, and they SHOULD be ignored on any input + other than local keyring files. + + + + +Callas, et al Standards Track [Page 47] + +RFC 4880 OpenPGP Message Format November 2007 + + +5.11. User ID Packet (Tag 13) + + A User ID packet consists of UTF-8 text that is intended to represent + the name and email address of the key holder. By convention, it + includes an RFC 2822 [RFC2822] mail name-addr, but there are no + restrictions on its content. The packet length in the header + specifies the length of the User ID. + +5.12. User Attribute Packet (Tag 17) + + The User Attribute packet is a variation of the User ID packet. It + is capable of storing more types of data than the User ID packet, + which is limited to text. Like the User ID packet, a User Attribute + packet may be certified by the key owner ("self-signed") or any other + key owner who cares to certify it. Except as noted, a User Attribute + packet may be used anywhere that a User ID packet may be used. + + While User Attribute packets are not a required part of the OpenPGP + standard, implementations SHOULD provide at least enough + compatibility to properly handle a certification signature on the + User Attribute packet. A simple way to do this is by treating the + User Attribute packet as a User ID packet with opaque contents, but + an implementation may use any method desired. + + The User Attribute packet is made up of one or more attribute + subpackets. Each subpacket consists of a subpacket header and a + body. The header consists of: + + - the subpacket length (1, 2, or 5 octets) + + - the subpacket type (1 octet) + + and is followed by the subpacket specific data. + + The only currently defined subpacket type is 1, signifying an image. + An implementation SHOULD ignore any subpacket of a type that it does + not recognize. Subpacket types 100 through 110 are reserved for + private or experimental use. + +5.12.1. The Image Attribute Subpacket + + The Image Attribute subpacket is used to encode an image, presumably + (but not required to be) that of the key owner. + + The Image Attribute subpacket begins with an image header. The first + two octets of the image header contain the length of the image + header. Note that unlike other multi-octet numerical values in this + document, due to a historical accident this value is encoded as a + + + +Callas, et al Standards Track [Page 48] + +RFC 4880 OpenPGP Message Format November 2007 + + + little-endian number. The image header length is followed by a + single octet for the image header version. The only currently + defined version of the image header is 1, which is a 16-octet image + header. The first three octets of a version 1 image header are thus + 0x10, 0x00, 0x01. + + The fourth octet of a version 1 image header designates the encoding + format of the image. The only currently defined encoding format is + the value 1 to indicate JPEG. Image format types 100 through 110 are + reserved for private or experimental use. The rest of the version 1 + image header is made up of 12 reserved octets, all of which MUST be + set to 0. + + The rest of the image subpacket contains the image itself. As the + only currently defined image type is JPEG, the image is encoded in + the JPEG File Interchange Format (JFIF), a standard file format for + JPEG images [JFIF]. + + An implementation MAY try to determine the type of an image by + examination of the image data if it is unable to handle a particular + version of the image header or if a specified encoding format value + is not recognized. + +5.13. Sym. Encrypted Integrity Protected Data Packet (Tag 18) + + The Symmetrically Encrypted Integrity Protected Data packet is a + variant of the Symmetrically Encrypted Data packet. It is a new + feature created for OpenPGP that addresses the problem of detecting a + modification to encrypted data. It is used in combination with a + Modification Detection Code packet. + + There is a corresponding feature in the features Signature subpacket + that denotes that an implementation can properly use this packet + type. An implementation MUST support decrypting these packets and + SHOULD prefer generating them to the older Symmetrically Encrypted + Data packet when possible. Since this data packet protects against + modification attacks, this standard encourages its proliferation. + While blanket adoption of this data packet would create + interoperability problems, rapid adoption is nevertheless important. + An implementation SHOULD specifically denote support for this packet, + but it MAY infer it from other mechanisms. + + For example, an implementation might infer from the use of a cipher + such as Advanced Encryption Standard (AES) or Twofish that a user + supports this feature. It might place in the unhashed portion of + another user's key signature a Features subpacket. It might also + present a user with an opportunity to regenerate their own self- + signature with a Features subpacket. + + + +Callas, et al Standards Track [Page 49] + +RFC 4880 OpenPGP Message Format November 2007 + + + This packet contains data encrypted with a symmetric-key algorithm + and protected against modification by the SHA-1 hash algorithm. When + it has been decrypted, it will typically contain other packets (often + a Literal Data packet or Compressed Data packet). The last decrypted + packet in this packet's payload MUST be a Modification Detection Code + packet. + + The body of this packet consists of: + + - A one-octet version number. The only currently defined value is + 1. + + - Encrypted data, the output of the selected symmetric-key cipher + operating in Cipher Feedback mode with shift amount equal to the + block size of the cipher (CFB-n where n is the block size). + + The symmetric cipher used MUST be specified in a Public-Key or + Symmetric-Key Encrypted Session Key packet that precedes the + Symmetrically Encrypted Data packet. In either case, the cipher + algorithm octet is prefixed to the session key before it is + encrypted. + + The data is encrypted in CFB mode, with a CFB shift size equal to the + cipher's block size. The Initial Vector (IV) is specified as all + zeros. Instead of using an IV, OpenPGP prefixes an octet string to + the data before it is encrypted. The length of the octet string + equals the block size of the cipher in octets, plus two. The first + octets in the group, of length equal to the block size of the cipher, + are random; the last two octets are each copies of their 2nd + preceding octet. For example, with a cipher whose block size is 128 + bits or 16 octets, the prefix data will contain 16 random octets, + then two more octets, which are copies of the 15th and 16th octets, + respectively. Unlike the Symmetrically Encrypted Data Packet, no + special CFB resynchronization is done after encrypting this prefix + data. See "OpenPGP CFB Mode" below for more details. + + The repetition of 16 bits in the random data prefixed to the message + allows the receiver to immediately check whether the session key is + incorrect. + + The plaintext of the data to be encrypted is passed through the SHA-1 + hash function, and the result of the hash is appended to the + plaintext in a Modification Detection Code packet. The input to the + hash function includes the prefix data described above; it includes + all of the plaintext, and then also includes two octets of values + 0xD3, 0x14. These represent the encoding of a Modification Detection + Code packet tag and length field of 20 octets. + + + + +Callas, et al Standards Track [Page 50] + +RFC 4880 OpenPGP Message Format November 2007 + + + The resulting hash value is stored in a Modification Detection Code + (MDC) packet, which MUST use the two octet encoding just given to + represent its tag and length field. The body of the MDC packet is + the 20-octet output of the SHA-1 hash. + + The Modification Detection Code packet is appended to the plaintext + and encrypted along with the plaintext using the same CFB context. + + During decryption, the plaintext data should be hashed with SHA-1, + including the prefix data as well as the packet tag and length field + of the Modification Detection Code packet. The body of the MDC + packet, upon decryption, is compared with the result of the SHA-1 + hash. + + Any failure of the MDC indicates that the message has been modified + and MUST be treated as a security problem. Failures include a + difference in the hash values, but also the absence of an MDC packet, + or an MDC packet in any position other than the end of the plaintext. + Any failure SHOULD be reported to the user. + + Note: future designs of new versions of this packet should consider + rollback attacks since it will be possible for an attacker to change + the version back to 1. + + NON-NORMATIVE EXPLANATION + + The MDC system, as packets 18 and 19 are called, were created to + provide an integrity mechanism that is less strong than a + signature, yet stronger than bare CFB encryption. + + It is a limitation of CFB encryption that damage to the ciphertext + will corrupt the affected cipher blocks and the block following. + Additionally, if data is removed from the end of a CFB-encrypted + block, that removal is undetectable. (Note also that CBC mode has + a similar limitation, but data removed from the front of the block + is undetectable.) + + The obvious way to protect or authenticate an encrypted block is + to digitally sign it. However, many people do not wish to + habitually sign data, for a large number of reasons beyond the + scope of this document. Suffice it to say that many people + consider properties such as deniability to be as valuable as + integrity. + + OpenPGP addresses this desire to have more security than raw + encryption and yet preserve deniability with the MDC system. An + MDC is intentionally not a MAC. Its name was not selected by + accident. It is analogous to a checksum. + + + +Callas, et al Standards Track [Page 51] + +RFC 4880 OpenPGP Message Format November 2007 + + + Despite the fact that it is a relatively modest system, it has + proved itself in the real world. It is an effective defense to + several attacks that have surfaced since it has been created. It + has met its modest goals admirably. + + Consequently, because it is a modest security system, it has + modest requirements on the hash function(s) it employs. It does + not rely on a hash function being collision-free, it relies on a + hash function being one-way. If a forger, Frank, wishes to send + Alice a (digitally) unsigned message that says, "I've always + secretly loved you, signed Bob", it is far easier for him to + construct a new message than it is to modify anything intercepted + from Bob. (Note also that if Bob wishes to communicate secretly + with Alice, but without authentication or identification and with + a threat model that includes forgers, he has a problem that + transcends mere cryptography.) + + Note also that unlike nearly every other OpenPGP subsystem, there + are no parameters in the MDC system. It hard-defines SHA-1 as its + hash function. This is not an accident. It is an intentional + choice to avoid downgrade and cross-grade attacks while making a + simple, fast system. (A downgrade attack would be an attack that + replaced SHA-256 with SHA-1, for example. A cross-grade attack + would replace SHA-1 with another 160-bit hash, such as RIPE- + MD/160, for example.) + + However, given the present state of hash function cryptanalysis + and cryptography, it may be desirable to upgrade the MDC system to + a new hash function. See Section 13.11 in the "IANA + Considerations" for guidance. + +5.14. Modification Detection Code Packet (Tag 19) + + The Modification Detection Code packet contains a SHA-1 hash of + plaintext data, which is used to detect message modification. It is + only used with a Symmetrically Encrypted Integrity Protected Data + packet. The Modification Detection Code packet MUST be the last + packet in the plaintext data that is encrypted in the Symmetrically + Encrypted Integrity Protected Data packet, and MUST appear in no + other place. + + A Modification Detection Code packet MUST have a length of 20 octets. + + + + + + + + + +Callas, et al Standards Track [Page 52] + +RFC 4880 OpenPGP Message Format November 2007 + + + The body of this packet consists of: + + - A 20-octet SHA-1 hash of the preceding plaintext data of the + Symmetrically Encrypted Integrity Protected Data packet, + including prefix data, the tag octet, and length octet of the + Modification Detection Code packet. + + Note that the Modification Detection Code packet MUST always use a + new format encoding of the packet tag, and a one-octet encoding of + the packet length. The reason for this is that the hashing rules for + modification detection include a one-octet tag and one-octet length + in the data hash. While this is a bit restrictive, it reduces + complexity. + +6. Radix-64 Conversions + + As stated in the introduction, OpenPGP's underlying native + representation for objects is a stream of arbitrary octets, and some + systems desire these objects to be immune to damage caused by + character set translation, data conversions, etc. + + In principle, any printable encoding scheme that met the requirements + of the unsafe channel would suffice, since it would not change the + underlying binary bit streams of the native OpenPGP data structures. + The OpenPGP standard specifies one such printable encoding scheme to + ensure interoperability. + + OpenPGP's Radix-64 encoding is composed of two parts: a base64 + encoding of the binary data and a checksum. The base64 encoding is + identical to the MIME base64 content-transfer-encoding [RFC2045]. + + The checksum is a 24-bit Cyclic Redundancy Check (CRC) converted to + four characters of radix-64 encoding by the same MIME base64 + transformation, preceded by an equal sign (=). The CRC is computed + by using the generator 0x864CFB and an initialization of 0xB704CE. + The accumulation is done on the data before it is converted to + radix-64, rather than on the converted data. A sample implementation + of this algorithm is in the next section. + + The checksum with its leading equal sign MAY appear on the first line + after the base64 encoded data. + + Rationale for CRC-24: The size of 24 bits fits evenly into printable + base64. The nonzero initialization can detect more errors than a + zero initialization. + + + + + + +Callas, et al Standards Track [Page 53] + +RFC 4880 OpenPGP Message Format November 2007 + + +6.1. An Implementation of the CRC-24 in "C" + + #define CRC24_INIT 0xB704CEL + #define CRC24_POLY 0x1864CFBL + + typedef long crc24; + crc24 crc_octets(unsigned char *octets, size_t len) + { + crc24 crc = CRC24_INIT; + int i; + while (len--) { + crc ^= (*octets++) << 16; + for (i = 0; i < 8; i++) { + crc <<= 1; + if (crc & 0x1000000) + crc ^= CRC24_POLY; + } + } + return crc & 0xFFFFFFL; + } + +6.2. Forming ASCII Armor + + When OpenPGP encodes data into ASCII Armor, it puts specific headers + around the Radix-64 encoded data, so OpenPGP can reconstruct the data + later. An OpenPGP implementation MAY use ASCII armor to protect raw + binary data. OpenPGP informs the user what kind of data is encoded + in the ASCII armor through the use of the headers. + + Concatenating the following data creates ASCII Armor: + + - An Armor Header Line, appropriate for the type of data + + - Armor Headers + + - A blank (zero-length, or containing only whitespace) line + + - The ASCII-Armored data + + - An Armor Checksum + + - The Armor Tail, which depends on the Armor Header Line + + An Armor Header Line consists of the appropriate header line text + surrounded by five (5) dashes ('-', 0x2D) on either side of the + header line text. The header line text is chosen based upon the type + of data that is being encoded in Armor, and how it is being encoded. + Header line texts include the following strings: + + + +Callas, et al Standards Track [Page 54] + +RFC 4880 OpenPGP Message Format November 2007 + + + BEGIN PGP MESSAGE + Used for signed, encrypted, or compressed files. + + BEGIN PGP PUBLIC KEY BLOCK + Used for armoring public keys. + + BEGIN PGP PRIVATE KEY BLOCK + Used for armoring private keys. + + BEGIN PGP MESSAGE, PART X/Y + Used for multi-part messages, where the armor is split amongst Y + parts, and this is the Xth part out of Y. + + BEGIN PGP MESSAGE, PART X + Used for multi-part messages, where this is the Xth part of an + unspecified number of parts. Requires the MESSAGE-ID Armor + Header to be used. + + BEGIN PGP SIGNATURE + Used for detached signatures, OpenPGP/MIME signatures, and + cleartext signatures. Note that PGP 2.x uses BEGIN PGP MESSAGE + for detached signatures. + + Note that all these Armor Header Lines are to consist of a complete + line. That is to say, there is always a line ending preceding the + starting five dashes, and following the ending five dashes. The + header lines, therefore, MUST start at the beginning of a line, and + MUST NOT have text other than whitespace following them on the same + line. These line endings are considered a part of the Armor Header + Line for the purposes of determining the content they delimit. This + is particularly important when computing a cleartext signature (see + below). + + The Armor Headers are pairs of strings that can give the user or the + receiving OpenPGP implementation some information about how to decode + or use the message. The Armor Headers are a part of the armor, not a + part of the message, and hence are not protected by any signatures + applied to the message. + + The format of an Armor Header is that of a key-value pair. A colon + (':' 0x38) and a single space (0x20) separate the key and value. + OpenPGP should consider improperly formatted Armor Headers to be + corruption of the ASCII Armor. Unknown keys should be reported to + the user, but OpenPGP should continue to process the message. + + Note that some transport methods are sensitive to line length. While + there is a limit of 76 characters for the Radix-64 data (Section + 6.3), there is no limit to the length of Armor Headers. Care should + + + +Callas, et al Standards Track [Page 55] + +RFC 4880 OpenPGP Message Format November 2007 + + + be taken that the Armor Headers are short enough to survive + transport. One way to do this is to repeat an Armor Header key + multiple times with different values for each so that no one line is + overly long. + + Currently defined Armor Header Keys are as follows: + + - "Version", which states the OpenPGP implementation and version + used to encode the message. + + - "Comment", a user-defined comment. OpenPGP defines all text to + be in UTF-8. A comment may be any UTF-8 string. However, the + whole point of armoring is to provide seven-bit-clean data. + Consequently, if a comment has characters that are outside the + US-ASCII range of UTF, they may very well not survive transport. + + - "MessageID", a 32-character string of printable characters. The + string must be the same for all parts of a multi-part message + that uses the "PART X" Armor Header. MessageID strings should be + unique enough that the recipient of the mail can associate all + the parts of a message with each other. A good checksum or + cryptographic hash function is sufficient. + + The MessageID SHOULD NOT appear unless it is in a multi-part + message. If it appears at all, it MUST be computed from the + finished (encrypted, signed, etc.) message in a deterministic + fashion, rather than contain a purely random value. This is to + allow the legitimate recipient to determine that the MessageID + cannot serve as a covert means of leaking cryptographic key + information. + + - "Hash", a comma-separated list of hash algorithms used in this + message. This is used only in cleartext signed messages. + + - "Charset", a description of the character set that the plaintext + is in. Please note that OpenPGP defines text to be in UTF-8. An + implementation will get best results by translating into and out + of UTF-8. However, there are many instances where this is easier + said than done. Also, there are communities of users who have no + need for UTF-8 because they are all happy with a character set + like ISO Latin-5 or a Japanese character set. In such instances, + an implementation MAY override the UTF-8 default by using this + header key. An implementation MAY implement this key and any + translations it cares to; an implementation MAY ignore it and + assume all text is UTF-8. + + + + + + +Callas, et al Standards Track [Page 56] + +RFC 4880 OpenPGP Message Format November 2007 + + + The Armor Tail Line is composed in the same manner as the Armor + Header Line, except the string "BEGIN" is replaced by the string + "END". + +6.3. Encoding Binary in Radix-64 + + The encoding process represents 24-bit groups of input bits as output + strings of 4 encoded characters. Proceeding from left to right, a + 24-bit input group is formed by concatenating three 8-bit input + groups. These 24 bits are then treated as four concatenated 6-bit + groups, each of which is translated into a single digit in the + Radix-64 alphabet. When encoding a bit stream with the Radix-64 + encoding, the bit stream must be presumed to be ordered with the most + significant bit first. That is, the first bit in the stream will be + the high-order bit in the first 8-bit octet, and the eighth bit will + be the low-order bit in the first 8-bit octet, and so on. + + +--first octet--+-second octet--+--third octet--+ + |7 6 5 4 3 2 1 0|7 6 5 4 3 2 1 0|7 6 5 4 3 2 1 0| + +-----------+---+-------+-------+---+-----------+ + |5 4 3 2 1 0|5 4 3 2 1 0|5 4 3 2 1 0|5 4 3 2 1 0| + +--1.index--+--2.index--+--3.index--+--4.index--+ + + Each 6-bit group is used as an index into an array of 64 printable + characters from the table below. The character referenced by the + index is placed in the output string. + + Value Encoding Value Encoding Value Encoding Value Encoding + 0 A 17 R 34 i 51 z + 1 B 18 S 35 j 52 0 + 2 C 19 T 36 k 53 1 + 3 D 20 U 37 l 54 2 + 4 E 21 V 38 m 55 3 + 5 F 22 W 39 n 56 4 + 6 G 23 X 40 o 57 5 + 7 H 24 Y 41 p 58 6 + 8 I 25 Z 42 q 59 7 + 9 J 26 a 43 r 60 8 + 10 K 27 b 44 s 61 9 + 11 L 28 c 45 t 62 + + 12 M 29 d 46 u 63 / + 13 N 30 e 47 v + 14 O 31 f 48 w (pad) = + 15 P 32 g 49 x + 16 Q 33 h 50 y + + The encoded output stream must be represented in lines of no more + than 76 characters each. + + + +Callas, et al Standards Track [Page 57] + +RFC 4880 OpenPGP Message Format November 2007 + + + Special processing is performed if fewer than 24 bits are available + at the end of the data being encoded. There are three possibilities: + + 1. The last data group has 24 bits (3 octets). No special processing + is needed. + + 2. The last data group has 16 bits (2 octets). The first two 6-bit + groups are processed as above. The third (incomplete) data group + has two zero-value bits added to it, and is processed as above. A + pad character (=) is added to the output. + + 3. The last data group has 8 bits (1 octet). The first 6-bit group + is processed as above. The second (incomplete) data group has + four zero-value bits added to it, and is processed as above. Two + pad characters (=) are added to the output. + +6.4. Decoding Radix-64 + + In Radix-64 data, characters other than those in the table, line + breaks, and other white space probably indicate a transmission error, + about which a warning message or even a message rejection might be + appropriate under some circumstances. Decoding software must ignore + all white space. + + Because it is used only for padding at the end of the data, the + occurrence of any "=" characters may be taken as evidence that the + end of the data has been reached (without truncation in transit). No + such assurance is possible, however, when the number of octets + transmitted was a multiple of three and no "=" characters are + present. + + + + + + + + + + + + + + + + + + + + + +Callas, et al Standards Track [Page 58] + +RFC 4880 OpenPGP Message Format November 2007 + + +6.5. Examples of Radix-64 + + Input data: 0x14FB9C03D97E + Hex: 1 4 F B 9 C | 0 3 D 9 7 E + 8-bit: 00010100 11111011 10011100 | 00000011 11011001 11111110 + 6-bit: 000101 001111 101110 011100 | 000000 111101 100111 111110 + Decimal: 5 15 46 28 0 61 37 62 + Output: F P u c A 9 l + + Input data: 0x14FB9C03D9 + Hex: 1 4 F B 9 C | 0 3 D 9 + 8-bit: 00010100 11111011 10011100 | 00000011 11011001 + pad with 00 + 6-bit: 000101 001111 101110 011100 | 000000 111101 100100 + Decimal: 5 15 46 28 0 61 36 + pad with = + Output: F P u c A 9 k = + Input data: 0x14FB9C03 + Hex: 1 4 F B 9 C | 0 3 + 8-bit: 00010100 11111011 10011100 | 00000011 + pad with 0000 + 6-bit: 000101 001111 101110 011100 | 000000 110000 + Decimal: 5 15 46 28 0 48 + pad with = = + Output: F P u c A w = = + +6.6. Example of an ASCII Armored Message + + -----BEGIN PGP MESSAGE----- + Version: OpenPrivacy 0.99 + + yDgBO22WxBHv7O8X7O/jygAEzol56iUKiXmV+XmpCtmpqQUKiQrFqclFqUDBovzS + vBSFjNSiVHsuAA== + =njUN + -----END PGP MESSAGE----- + + Note that this example has extra indenting; an actual armored message + would have no leading whitespace. + +7. Cleartext Signature Framework + + It is desirable to be able to sign a textual octet stream without + ASCII armoring the stream itself, so the signed text is still + readable without special software. In order to bind a signature to + such a cleartext, this framework is used. (Note that this framework + is not intended to be reversible. RFC 3156 [RFC3156] defines another + way to sign cleartext messages for environments that support MIME.) + + + + + +Callas, et al Standards Track [Page 59] + +RFC 4880 OpenPGP Message Format November 2007 + + + The cleartext signed message consists of: + + - The cleartext header '-----BEGIN PGP SIGNED MESSAGE-----' on a + single line, + + - One or more "Hash" Armor Headers, + + - Exactly one empty line not included into the message digest, + + - The dash-escaped cleartext that is included into the message + digest, + + - The ASCII armored signature(s) including the '-----BEGIN PGP + SIGNATURE-----' Armor Header and Armor Tail Lines. + + If the "Hash" Armor Header is given, the specified message digest + algorithm(s) are used for the signature. If there are no such + headers, MD5 is used. If MD5 is the only hash used, then an + implementation MAY omit this header for improved V2.x compatibility. + If more than one message digest is used in the signature, the "Hash" + armor header contains a comma-delimited list of used message digests. + + Current message digest names are described below with the algorithm + IDs. + + An implementation SHOULD add a line break after the cleartext, but + MAY omit it if the cleartext ends with a line break. This is for + visual clarity. + +7.1. Dash-Escaped Text + + The cleartext content of the message must also be dash-escaped. + + Dash-escaped cleartext is the ordinary cleartext where every line + starting with a dash '-' (0x2D) is prefixed by the sequence dash '-' + (0x2D) and space ' ' (0x20). This prevents the parser from + recognizing armor headers of the cleartext itself. An implementation + MAY dash-escape any line, SHOULD dash-escape lines commencing "From" + followed by a space, and MUST dash-escape any line commencing in a + dash. The message digest is computed using the cleartext itself, not + the dash-escaped form. + + As with binary signatures on text documents, a cleartext signature is + calculated on the text using canonical line endings. The + line ending (i.e., the ) before the '-----BEGIN PGP + SIGNATURE-----' line that terminates the signed text is not + considered part of the signed text. + + + + +Callas, et al Standards Track [Page 60] + +RFC 4880 OpenPGP Message Format November 2007 + + + When reversing dash-escaping, an implementation MUST strip the string + "- " if it occurs at the beginning of a line, and SHOULD warn on "-" + and any character other than a space at the beginning of a line. + + Also, any trailing whitespace -- spaces (0x20) and tabs (0x09) -- at + the end of any line is removed when the cleartext signature is + generated. + +8. Regular Expressions + + A regular expression is zero or more branches, separated by '|'. It + matches anything that matches one of the branches. + + A branch is zero or more pieces, concatenated. It matches a match + for the first, followed by a match for the second, etc. + + A piece is an atom possibly followed by '*', '+', or '?'. An atom + followed by '*' matches a sequence of 0 or more matches of the atom. + An atom followed by '+' matches a sequence of 1 or more matches of + the atom. An atom followed by '?' matches a match of the atom, or + the null string. + + An atom is a regular expression in parentheses (matching a match for + the regular expression), a range (see below), '.' (matching any + single character), '^' (matching the null string at the beginning of + the input string), '$' (matching the null string at the end of the + input string), a '\' followed by a single character (matching that + character), or a single character with no other significance + (matching that character). + + A range is a sequence of characters enclosed in '[]'. It normally + matches any single character from the sequence. If the sequence + begins with '^', it matches any single character not from the rest of + the sequence. If two characters in the sequence are separated + by '-', this is shorthand for the full list of ASCII characters + between them (e.g., '[0-9]' matches any decimal digit). To include a + literal ']' in the sequence, make it the first character (following a + possible '^'). To include a literal '-', make it the first or last + character. + +9. Constants + + This section describes the constants used in OpenPGP. + + Note that these tables are not exhaustive lists; an implementation + MAY implement an algorithm not on these lists, so long as the + algorithm numbers are chosen from the private or experimental + algorithm range. + + + +Callas, et al Standards Track [Page 61] + +RFC 4880 OpenPGP Message Format November 2007 + + + See the section "Notes on Algorithms" below for more discussion of + the algorithms. + +9.1. Public-Key Algorithms + + ID Algorithm + -- --------- + 1 - RSA (Encrypt or Sign) [HAC] + 2 - RSA Encrypt-Only [HAC] + 3 - RSA Sign-Only [HAC] + 16 - Elgamal (Encrypt-Only) [ELGAMAL] [HAC] + 17 - DSA (Digital Signature Algorithm) [FIPS186] [HAC] + 18 - Reserved for Elliptic Curve + 19 - Reserved for ECDSA + 20 - Reserved (formerly Elgamal Encrypt or Sign) + 21 - Reserved for Diffie-Hellman (X9.42, + as defined for IETF-S/MIME) + 100 to 110 - Private/Experimental algorithm + + Implementations MUST implement DSA for signatures, and Elgamal for + encryption. Implementations SHOULD implement RSA keys (1). RSA + Encrypt-Only (2) and RSA Sign-Only are deprecated and SHOULD NOT be + generated, but may be interpreted. See Section 13.5. See Section + 13.8 for notes on Elliptic Curve (18), ECDSA (19), Elgamal Encrypt or + Sign (20), and X9.42 (21). Implementations MAY implement any other + algorithm. + +9.2. Symmetric-Key Algorithms + + ID Algorithm + -- --------- + 0 - Plaintext or unencrypted data + 1 - IDEA [IDEA] + 2 - TripleDES (DES-EDE, [SCHNEIER] [HAC] - + 168 bit key derived from 192) + 3 - CAST5 (128 bit key, as per [RFC2144]) + 4 - Blowfish (128 bit key, 16 rounds) [BLOWFISH] + 5 - Reserved + 6 - Reserved + 7 - AES with 128-bit key [AES] + 8 - AES with 192-bit key + 9 - AES with 256-bit key + 10 - Twofish with 256-bit key [TWOFISH] + 100 to 110 - Private/Experimental algorithm + + Implementations MUST implement TripleDES. Implementations SHOULD + implement AES-128 and CAST5. Implementations that interoperate with + + + + +Callas, et al Standards Track [Page 62] + +RFC 4880 OpenPGP Message Format November 2007 + + + PGP 2.6 or earlier need to support IDEA, as that is the only + symmetric cipher those versions use. Implementations MAY implement + any other algorithm. + +9.3. Compression Algorithms + + ID Algorithm + -- --------- + 0 - Uncompressed + 1 - ZIP [RFC1951] + 2 - ZLIB [RFC1950] + 3 - BZip2 [BZ2] + 100 to 110 - Private/Experimental algorithm + + Implementations MUST implement uncompressed data. Implementations + SHOULD implement ZIP. Implementations MAY implement any other + algorithm. + +9.4. Hash Algorithms + + ID Algorithm Text Name + -- --------- --------- + 1 - MD5 [HAC] "MD5" + 2 - SHA-1 [FIPS180] "SHA1" + 3 - RIPE-MD/160 [HAC] "RIPEMD160" + 4 - Reserved + 5 - Reserved + 6 - Reserved + 7 - Reserved + 8 - SHA256 [FIPS180] "SHA256" + 9 - SHA384 [FIPS180] "SHA384" + 10 - SHA512 [FIPS180] "SHA512" + 11 - SHA224 [FIPS180] "SHA224" + 100 to 110 - Private/Experimental algorithm + + Implementations MUST implement SHA-1. Implementations MAY implement + other algorithms. MD5 is deprecated. + +10. IANA Considerations + + OpenPGP is highly parameterized, and consequently there are a number + of considerations for allocating parameters for extensions. This + section describes how IANA should look at extensions to the protocol + as described in this document. + + + + + + + +Callas, et al Standards Track [Page 63] + +RFC 4880 OpenPGP Message Format November 2007 + + +10.1. New String-to-Key Specifier Types + + OpenPGP S2K specifiers contain a mechanism for new algorithms to turn + a string into a key. This specification creates a registry of S2K + specifier types. The registry includes the S2K type, the name of the + S2K, and a reference to the defining specification. The initial + values for this registry can be found in Section 3.7.1. Adding a new + S2K specifier MUST be done through the IETF CONSENSUS method, as + described in [RFC2434]. + +10.2. New Packets + + Major new features of OpenPGP are defined through new packet types. + This specification creates a registry of packet types. The registry + includes the packet type, the name of the packet, and a reference to + the defining specification. The initial values for this registry can + be found in Section 4.3. Adding a new packet type MUST be done + through the IETF CONSENSUS method, as described in [RFC2434]. + +10.2.1. User Attribute Types + + The User Attribute packet permits an extensible mechanism for other + types of certificate identification. This specification creates a + registry of User Attribute types. The registry includes the User + Attribute type, the name of the User Attribute, and a reference to + the defining specification. The initial values for this registry can + be found in Section 5.12. Adding a new User Attribute type MUST be + done through the IETF CONSENSUS method, as described in [RFC2434]. + +10.2.1.1. Image Format Subpacket Types + + Within User Attribute packets, there is an extensible mechanism for + other types of image-based user attributes. This specification + creates a registry of Image Attribute subpacket types. The registry + includes the Image Attribute subpacket type, the name of the Image + Attribute subpacket, and a reference to the defining specification. + The initial values for this registry can be found in Section 5.12.1. + Adding a new Image Attribute subpacket type MUST be done through the + IETF CONSENSUS method, as described in [RFC2434]. + +10.2.2. New Signature Subpackets + + OpenPGP signatures contain a mechanism for signed (or unsigned) data + to be added to them for a variety of purposes in the Signature + subpackets as discussed in Section 5.2.3.1. This specification + creates a registry of Signature subpacket types. The registry + includes the Signature subpacket type, the name of the subpacket, and + a reference to the defining specification. The initial values for + + + +Callas, et al Standards Track [Page 64] + +RFC 4880 OpenPGP Message Format November 2007 + + + this registry can be found in Section 5.2.3.1. Adding a new + Signature subpacket MUST be done through the IETF CONSENSUS method, + as described in [RFC2434]. + +10.2.2.1. Signature Notation Data Subpackets + + OpenPGP signatures further contain a mechanism for extensions in + signatures. These are the Notation Data subpackets, which contain a + key/value pair. Notations contain a user space that is completely + unmanaged and an IETF space. + + This specification creates a registry of Signature Notation Data + types. The registry includes the Signature Notation Data type, the + name of the Signature Notation Data, its allowed values, and a + reference to the defining specification. The initial values for this + registry can be found in Section 5.2.3.16. Adding a new Signature + Notation Data subpacket MUST be done through the EXPERT REVIEW + method, as described in [RFC2434]. + +10.2.2.2. Key Server Preference Extensions + + OpenPGP signatures contain a mechanism for preferences to be + specified about key servers. This specification creates a registry + of key server preferences. The registry includes the key server + preference, the name of the preference, and a reference to the + defining specification. The initial values for this registry can be + found in Section 5.2.3.17. Adding a new key server preference MUST + be done through the IETF CONSENSUS method, as described in [RFC2434]. + +10.2.2.3. Key Flags Extensions + + OpenPGP signatures contain a mechanism for flags to be specified + about key usage. This specification creates a registry of key usage + flags. The registry includes the key flags value, the name of the + flag, and a reference to the defining specification. The initial + values for this registry can be found in Section 5.2.3.21. Adding a + new key usage flag MUST be done through the IETF CONSENSUS method, as + described in [RFC2434]. + +10.2.2.4. Reason for Revocation Extensions + + OpenPGP signatures contain a mechanism for flags to be specified + about why a key was revoked. This specification creates a registry + of "Reason for Revocation" flags. The registry includes the "Reason + for Revocation" flags value, the name of the flag, and a reference to + the defining specification. The initial values for this registry can + be found in Section 5.2.3.23. Adding a new feature flag MUST be done + through the IETF CONSENSUS method, as described in [RFC2434]. + + + +Callas, et al Standards Track [Page 65] + +RFC 4880 OpenPGP Message Format November 2007 + + +10.2.2.5. Implementation Features + + OpenPGP signatures contain a mechanism for flags to be specified + stating which optional features an implementation supports. This + specification creates a registry of feature-implementation flags. + The registry includes the feature-implementation flags value, the + name of the flag, and a reference to the defining specification. The + initial values for this registry can be found in Section 5.2.3.24. + Adding a new feature-implementation flag MUST be done through the + IETF CONSENSUS method, as described in [RFC2434]. + + Also see Section 13.12 for more information about when feature flags + are needed. + +10.2.3. New Packet Versions + + The core OpenPGP packets all have version numbers, and can be revised + by introducing a new version of an existing packet. This + specification creates a registry of packet types. The registry + includes the packet type, the number of the version, and a reference + to the defining specification. The initial values for this registry + can be found in Section 5. Adding a new packet version MUST be done + through the IETF CONSENSUS method, as described in [RFC2434]. + +10.3. New Algorithms + + Section 9 lists the core algorithms that OpenPGP uses. Adding in a + new algorithm is usually simple. For example, adding in a new + symmetric cipher usually would not need anything more than allocating + a constant for that cipher. If that cipher had other than a 64-bit + or 128-bit block size, there might need to be additional + documentation describing how OpenPGP-CFB mode would be adjusted. + Similarly, when DSA was expanded from a maximum of 1024-bit public + keys to 3072-bit public keys, the revision of FIPS 186 contained + enough information itself to allow implementation. Changes to this + document were made mainly for emphasis. + +10.3.1. Public-Key Algorithms + + OpenPGP specifies a number of public-key algorithms. This + specification creates a registry of public-key algorithm identifiers. + The registry includes the algorithm name, its key sizes and + parameters, and a reference to the defining specification. The + initial values for this registry can be found in Section 9. Adding a + new public-key algorithm MUST be done through the IETF CONSENSUS + method, as described in [RFC2434]. + + + + + +Callas, et al Standards Track [Page 66] + +RFC 4880 OpenPGP Message Format November 2007 + + +10.3.2. Symmetric-Key Algorithms + + OpenPGP specifies a number of symmetric-key algorithms. This + specification creates a registry of symmetric-key algorithm + identifiers. The registry includes the algorithm name, its key sizes + and block size, and a reference to the defining specification. The + initial values for this registry can be found in Section 9. Adding a + new symmetric-key algorithm MUST be done through the IETF CONSENSUS + method, as described in [RFC2434]. + +10.3.3. Hash Algorithms + + OpenPGP specifies a number of hash algorithms. This specification + creates a registry of hash algorithm identifiers. The registry + includes the algorithm name, a text representation of that name, its + block size, an OID hash prefix, and a reference to the defining + specification. The initial values for this registry can be found in + Section 9 for the algorithm identifiers and text names, and Section + 5.2.2 for the OIDs and expanded signature prefixes. Adding a new + hash algorithm MUST be done through the IETF CONSENSUS method, as + described in [RFC2434]. + +10.3.4. Compression Algorithms + + OpenPGP specifies a number of compression algorithms. This + specification creates a registry of compression algorithm + identifiers. The registry includes the algorithm name and a + reference to the defining specification. The initial values for this + registry can be found in Section 9.3. Adding a new compression key + algorithm MUST be done through the IETF CONSENSUS method, as + described in [RFC2434]. + +11. Packet Composition + + OpenPGP packets are assembled into sequences in order to create + messages and to transfer keys. Not all possible packet sequences are + meaningful and correct. This section describes the rules for how + packets should be placed into sequences. + +11.1. Transferable Public Keys + + OpenPGP users may transfer public keys. The essential elements of a + transferable public key are as follows: + + - One Public-Key packet + + - Zero or more revocation signatures + + + + +Callas, et al Standards Track [Page 67] + +RFC 4880 OpenPGP Message Format November 2007 + + + - One or more User ID packets + + - After each User ID packet, zero or more Signature packets + (certifications) + + - Zero or more User Attribute packets + + - After each User Attribute packet, zero or more Signature packets + (certifications) + + - Zero or more Subkey packets + + - After each Subkey packet, one Signature packet, plus optionally a + revocation + + The Public-Key packet occurs first. Each of the following User ID + packets provides the identity of the owner of this public key. If + there are multiple User ID packets, this corresponds to multiple + means of identifying the same unique individual user; for example, a + user may have more than one email address, and construct a User ID + for each one. + + Immediately following each User ID packet, there are zero or more + Signature packets. Each Signature packet is calculated on the + immediately preceding User ID packet and the initial Public-Key + packet. The signature serves to certify the corresponding public key + and User ID. In effect, the signer is testifying to his or her + belief that this public key belongs to the user identified by this + User ID. + + Within the same section as the User ID packets, there are zero or + more User Attribute packets. Like the User ID packets, a User + Attribute packet is followed by zero or more Signature packets + calculated on the immediately preceding User Attribute packet and the + initial Public-Key packet. + + User Attribute packets and User ID packets may be freely intermixed + in this section, so long as the signatures that follow them are + maintained on the proper User Attribute or User ID packet. + + After the User ID packet or Attribute packet, there may be zero or + more Subkey packets. In general, subkeys are provided in cases where + the top-level public key is a signature-only key. However, any V4 + key may have subkeys, and the subkeys may be encryption-only keys, + signature-only keys, or general-purpose keys. V3 keys MUST NOT have + subkeys. + + + + + +Callas, et al Standards Track [Page 68] + +RFC 4880 OpenPGP Message Format November 2007 + + + Each Subkey packet MUST be followed by one Signature packet, which + should be a subkey binding signature issued by the top-level key. + For subkeys that can issue signatures, the subkey binding signature + MUST contain an Embedded Signature subpacket with a primary key + binding signature (0x19) issued by the subkey on the top-level key. + + Subkey and Key packets may each be followed by a revocation Signature + packet to indicate that the key is revoked. Revocation signatures + are only accepted if they are issued by the key itself, or by a key + that is authorized to issue revocations via a Revocation Key + subpacket in a self-signature by the top-level key. + + Transferable public-key packet sequences may be concatenated to allow + transferring multiple public keys in one operation. + +11.2. Transferable Secret Keys + + OpenPGP users may transfer secret keys. The format of a transferable + secret key is the same as a transferable public key except that + secret-key and secret-subkey packets are used instead of the public + key and public-subkey packets. Implementations SHOULD include self- + signatures on any user IDs and subkeys, as this allows for a complete + public key to be automatically extracted from the transferable secret + key. Implementations MAY choose to omit the self-signatures, + especially if a transferable public key accompanies the transferable + secret key. + +11.3. OpenPGP Messages + + An OpenPGP message is a packet or sequence of packets that + corresponds to the following grammatical rules (comma represents + sequential composition, and vertical bar separates alternatives): + + OpenPGP Message :- Encrypted Message | Signed Message | + Compressed Message | Literal Message. + + Compressed Message :- Compressed Data Packet. + + Literal Message :- Literal Data Packet. + + ESK :- Public-Key Encrypted Session Key Packet | + Symmetric-Key Encrypted Session Key Packet. + + ESK Sequence :- ESK | ESK Sequence, ESK. + + Encrypted Data :- Symmetrically Encrypted Data Packet | + Symmetrically Encrypted Integrity Protected Data Packet + + + + +Callas, et al Standards Track [Page 69] + +RFC 4880 OpenPGP Message Format November 2007 + + + Encrypted Message :- Encrypted Data | ESK Sequence, Encrypted Data. + + One-Pass Signed Message :- One-Pass Signature Packet, + OpenPGP Message, Corresponding Signature Packet. + + Signed Message :- Signature Packet, OpenPGP Message | + One-Pass Signed Message. + + In addition, decrypting a Symmetrically Encrypted Data packet or a + Symmetrically Encrypted Integrity Protected Data packet as well as + decompressing a Compressed Data packet must yield a valid OpenPGP + Message. + +11.4. Detached Signatures + + Some OpenPGP applications use so-called "detached signatures". For + example, a program bundle may contain a file, and with it a second + file that is a detached signature of the first file. These detached + signatures are simply a Signature packet stored separately from the + data for which they are a signature. + +12. Enhanced Key Formats + +12.1. Key Structures + + The format of an OpenPGP V3 key is as follows. Entries in square + brackets are optional and ellipses indicate repetition. + + RSA Public Key + [Revocation Self Signature] + User ID [Signature ...] + [User ID [Signature ...] ...] + + Each signature certifies the RSA public key and the preceding User + ID. The RSA public key can have many User IDs and each User ID can + have many signatures. V3 keys are deprecated. Implementations MUST + NOT generate new V3 keys, but MAY continue to use existing ones. + + The format of an OpenPGP V4 key that uses multiple public keys is + similar except that the other keys are added to the end as "subkeys" + of the primary key. + + + + + + + + + + +Callas, et al Standards Track [Page 70] + +RFC 4880 OpenPGP Message Format November 2007 + + + Primary-Key + [Revocation Self Signature] + [Direct Key Signature...] + User ID [Signature ...] + [User ID [Signature ...] ...] + [User Attribute [Signature ...] ...] + [[Subkey [Binding-Signature-Revocation] + Primary-Key-Binding-Signature] ...] + + A subkey always has a single signature after it that is issued using + the primary key to tie the two keys together. This binding signature + may be in either V3 or V4 format, but SHOULD be V4. Subkeys that can + issue signatures MUST have a V4 binding signature due to the REQUIRED + embedded primary key binding signature. + + In the above diagram, if the binding signature of a subkey has been + revoked, the revoked key may be removed, leaving only one key. + + In a V4 key, the primary key MUST be a key capable of certification. + The subkeys may be keys of any other type. There may be other + constructions of V4 keys, too. For example, there may be a single- + key RSA key in V4 format, a DSA primary key with an RSA encryption + key, or RSA primary key with an Elgamal subkey, etc. + + It is also possible to have a signature-only subkey. This permits a + primary key that collects certifications (key signatures), but is + used only for certifying subkeys that are used for encryption and + signatures. + +12.2. Key IDs and Fingerprints + + For a V3 key, the eight-octet Key ID consists of the low 64 bits of + the public modulus of the RSA key. + + The fingerprint of a V3 key is formed by hashing the body (but not + the two-octet length) of the MPIs that form the key material (public + modulus n, followed by exponent e) with MD5. Note that both V3 keys + and MD5 are deprecated. + + A V4 fingerprint is the 160-bit SHA-1 hash of the octet 0x99, + followed by the two-octet packet length, followed by the entire + Public-Key packet starting with the version field. The Key ID is the + low-order 64 bits of the fingerprint. Here are the fields of the + hash material, with the example of a DSA key: + + a.1) 0x99 (1 octet) + + a.2) high-order length octet of (b)-(e) (1 octet) + + + +Callas, et al Standards Track [Page 71] + +RFC 4880 OpenPGP Message Format November 2007 + + + a.3) low-order length octet of (b)-(e) (1 octet) + + b) version number = 4 (1 octet); + + c) timestamp of key creation (4 octets); + + d) algorithm (1 octet): 17 = DSA (example); + + e) Algorithm-specific fields. + + Algorithm-Specific Fields for DSA keys (example): + + e.1) MPI of DSA prime p; + + e.2) MPI of DSA group order q (q is a prime divisor of p-1); + + e.3) MPI of DSA group generator g; + + e.4) MPI of DSA public-key value y (= g**x mod p where x is secret). + + Note that it is possible for there to be collisions of Key IDs -- two + different keys with the same Key ID. Note that there is a much + smaller, but still non-zero, probability that two different keys have + the same fingerprint. + + Also note that if V3 and V4 format keys share the same RSA key + material, they will have different Key IDs as well as different + fingerprints. + + Finally, the Key ID and fingerprint of a subkey are calculated in the + same way as for a primary key, including the 0x99 as the first octet + (even though this is not a valid packet ID for a public subkey). + +13. Notes on Algorithms + +13.1. PKCS#1 Encoding in OpenPGP + + This standard makes use of the PKCS#1 functions EME-PKCS1-v1_5 and + EMSA-PKCS1-v1_5. However, the calling conventions of these functions + has changed in the past. To avoid potential confusion and + interoperability problems, we are including local copies in this + document, adapted from those in PKCS#1 v2.1 [RFC3447]. RFC 3447 + should be treated as the ultimate authority on PKCS#1 for OpenPGP. + Nonetheless, we believe that there is value in having a self- + contained document that avoids problems in the future with needed + changes in the conventions. + + + + + +Callas, et al Standards Track [Page 72] + +RFC 4880 OpenPGP Message Format November 2007 + + +13.1.1. EME-PKCS1-v1_5-ENCODE + + Input: + + k = the length in octets of the key modulus + + M = message to be encoded, an octet string of length mLen, where + mLen <= k - 11 + + Output: + + EM = encoded message, an octet string of length k + + Error: "message too long" + + 1. Length checking: If mLen > k - 11, output "message too long" and + stop. + + 2. Generate an octet string PS of length k - mLen - 3 consisting of + pseudo-randomly generated nonzero octets. The length of PS will + be at least eight octets. + + 3. Concatenate PS, the message M, and other padding to form an + encoded message EM of length k octets as + + EM = 0x00 || 0x02 || PS || 0x00 || M. + + 4. Output EM. + +13.1.2. EME-PKCS1-v1_5-DECODE + + Input: + + EM = encoded message, an octet string + + Output: + + M = message, an octet string + + Error: "decryption error" + + To decode an EME-PKCS1_v1_5 message, separate the encoded message EM + into an octet string PS consisting of nonzero octets and a message M + as follows + + EM = 0x00 || 0x02 || PS || 0x00 || M. + + + + + +Callas, et al Standards Track [Page 73] + +RFC 4880 OpenPGP Message Format November 2007 + + + If the first octet of EM does not have hexadecimal value 0x00, if the + second octet of EM does not have hexadecimal value 0x02, if there is + no octet with hexadecimal value 0x00 to separate PS from M, or if the + length of PS is less than 8 octets, output "decryption error" and + stop. See also the security note in Section 14 regarding differences + in reporting between a decryption error and a padding error. + +13.1.3. EMSA-PKCS1-v1_5 + + This encoding method is deterministic and only has an encoding + operation. + + Option: + + Hash - a hash function in which hLen denotes the length in octets of + the hash function output + + Input: + + M = message to be encoded + + mL = intended length in octets of the encoded message, at least tLen + + 11, where tLen is the octet length of the DER encoding T of a + certain value computed during the encoding operation + + Output: + + EM = encoded message, an octet string of length emLen + + Errors: "message too long"; "intended encoded message length too + short" + + Steps: + + 1. Apply the hash function to the message M to produce a hash value + H: + + H = Hash(M). + + If the hash function outputs "message too long," output "message + too long" and stop. + + 2. Using the list in Section 5.2.2, produce an ASN.1 DER value for + the hash function used. Let T be the full hash prefix from + Section 5.2.2, and let tLen be the length in octets of T. + + 3. If emLen < tLen + 11, output "intended encoded message length + too short" and stop. + + + +Callas, et al Standards Track [Page 74] + +RFC 4880 OpenPGP Message Format November 2007 + + + 4. Generate an octet string PS consisting of emLen - tLen - 3 + octets with hexadecimal value 0xFF. The length of PS will be at + least 8 octets. + + 5. Concatenate PS, the hash prefix T, and other padding to form the + encoded message EM as + + EM = 0x00 || 0x01 || PS || 0x00 || T. + + 6. Output EM. + +13.2. Symmetric Algorithm Preferences + + The symmetric algorithm preference is an ordered list of algorithms + that the keyholder accepts. Since it is found on a self-signature, + it is possible that a keyholder may have multiple, different + preferences. For example, Alice may have TripleDES only specified + for "alice@work.com" but CAST5, Blowfish, and TripleDES specified for + "alice@home.org". Note that it is also possible for preferences to + be in a subkey's binding signature. + + Since TripleDES is the MUST-implement algorithm, if it is not + explicitly in the list, it is tacitly at the end. However, it is + good form to place it there explicitly. Note also that if an + implementation does not implement the preference, then it is + implicitly a TripleDES-only implementation. + + An implementation MUST NOT use a symmetric algorithm that is not in + the recipient's preference list. When encrypting to more than one + recipient, the implementation finds a suitable algorithm by taking + the intersection of the preferences of the recipients. Note that the + MUST-implement algorithm, TripleDES, ensures that the intersection is + not null. The implementation may use any mechanism to pick an + algorithm in the intersection. + + If an implementation can decrypt a message that a keyholder doesn't + have in their preferences, the implementation SHOULD decrypt the + message anyway, but MUST warn the keyholder that the protocol has + been violated. For example, suppose that Alice, above, has software + that implements all algorithms in this specification. Nonetheless, + she prefers subsets for work or home. If she is sent a message + encrypted with IDEA, which is not in her preferences, the software + warns her that someone sent her an IDEA-encrypted message, but it + would ideally decrypt it anyway. + + + + + + + +Callas, et al Standards Track [Page 75] + +RFC 4880 OpenPGP Message Format November 2007 + + +13.3. Other Algorithm Preferences + + Other algorithm preferences work similarly to the symmetric algorithm + preference, in that they specify which algorithms the keyholder + accepts. There are two interesting cases that other comments need to + be made about, though, the compression preferences and the hash + preferences. + +13.3.1. Compression Preferences + + Compression has been an integral part of PGP since its first days. + OpenPGP and all previous versions of PGP have offered compression. + In this specification, the default is for messages to be compressed, + although an implementation is not required to do so. Consequently, + the compression preference gives a way for a keyholder to request + that messages not be compressed, presumably because they are using a + minimal implementation that does not include compression. + Additionally, this gives a keyholder a way to state that it can + support alternate algorithms. + + Like the algorithm preferences, an implementation MUST NOT use an + algorithm that is not in the preference vector. If the preferences + are not present, then they are assumed to be [ZIP(1), + Uncompressed(0)]. + + Additionally, an implementation MUST implement this preference to the + degree of recognizing when to send an uncompressed message. A robust + implementation would satisfy this requirement by looking at the + recipient's preference and acting accordingly. A minimal + implementation can satisfy this requirement by never generating a + compressed message, since all implementations can handle messages + that have not been compressed. + +13.3.2. Hash Algorithm Preferences + + Typically, the choice of a hash algorithm is something the signer + does, rather than the verifier, because a signer rarely knows who is + going to be verifying the signature. This preference, though, allows + a protocol based upon digital signatures ease in negotiation. + + Thus, if Alice is authenticating herself to Bob with a signature, it + makes sense for her to use a hash algorithm that Bob's software uses. + This preference allows Bob to state in his key which algorithms Alice + may use. + + Since SHA1 is the MUST-implement hash algorithm, if it is not + explicitly in the list, it is tacitly at the end. However, it is + good form to place it there explicitly. + + + +Callas, et al Standards Track [Page 76] + +RFC 4880 OpenPGP Message Format November 2007 + + +13.4. Plaintext + + Algorithm 0, "plaintext", may only be used to denote secret keys that + are stored in the clear. Implementations MUST NOT use plaintext in + Symmetrically Encrypted Data packets; they must use Literal Data + packets to encode unencrypted or literal data. + +13.5. RSA + + There are algorithm types for RSA Sign-Only, and RSA Encrypt-Only + keys. These types are deprecated. The "key flags" subpacket in a + signature is a much better way to express the same idea, and + generalizes it to all algorithms. An implementation SHOULD NOT + create such a key, but MAY interpret it. + + An implementation SHOULD NOT implement RSA keys of size less than + 1024 bits. + +13.6. DSA + + An implementation SHOULD NOT implement DSA keys of size less than + 1024 bits. It MUST NOT implement a DSA key with a q size of less + than 160 bits. DSA keys MUST also be a multiple of 64 bits, and the + q size MUST be a multiple of 8 bits. The Digital Signature Standard + (DSS) [FIPS186] specifies that DSA be used in one of the following + ways: + + * 1024-bit key, 160-bit q, SHA-1, SHA-224, SHA-256, SHA-384, or + SHA-512 hash + + * 2048-bit key, 224-bit q, SHA-224, SHA-256, SHA-384, or SHA-512 + hash + + * 2048-bit key, 256-bit q, SHA-256, SHA-384, or SHA-512 hash + + * 3072-bit key, 256-bit q, SHA-256, SHA-384, or SHA-512 hash + + The above key and q size pairs were chosen to best balance the + strength of the key with the strength of the hash. Implementations + SHOULD use one of the above key and q size pairs when generating DSA + keys. If DSS compliance is desired, one of the specified SHA hashes + must be used as well. [FIPS186] is the ultimate authority on DSS, + and should be consulted for all questions of DSS compliance. + + Note that earlier versions of this standard only allowed a 160-bit q + with no truncation allowed, so earlier implementations may not be + able to handle signatures with a different q size or a truncated + hash. + + + +Callas, et al Standards Track [Page 77] + +RFC 4880 OpenPGP Message Format November 2007 + + +13.7. Elgamal + + An implementation SHOULD NOT implement Elgamal keys of size less than + 1024 bits. + +13.8. Reserved Algorithm Numbers + + A number of algorithm IDs have been reserved for algorithms that + would be useful to use in an OpenPGP implementation, yet there are + issues that prevent an implementer from actually implementing the + algorithm. These are marked in Section 9.1, "Public-Key Algorithms", + as "reserved for". + + The reserved public-key algorithms, Elliptic Curve (18), ECDSA (19), + and X9.42 (21), do not have the necessary parameters, parameter + order, or semantics defined. + + Previous versions of OpenPGP permitted Elgamal [ELGAMAL] signatures + with a public-key identifier of 20. These are no longer permitted. + An implementation MUST NOT generate such keys. An implementation + MUST NOT generate Elgamal signatures. See [BLEICHENBACHER]. + +13.9. OpenPGP CFB Mode + + OpenPGP does symmetric encryption using a variant of Cipher Feedback + mode (CFB mode). This section describes the procedure it uses in + detail. This mode is what is used for Symmetrically Encrypted Data + Packets; the mechanism used for encrypting secret-key material is + similar, and is described in the sections above. + + In the description below, the value BS is the block size in octets of + the cipher. Most ciphers have a block size of 8 octets. The AES and + Twofish have a block size of 16 octets. Also note that the + description below assumes that the IV and CFB arrays start with an + index of 1 (unlike the C language, which assumes arrays start with a + zero index). + + OpenPGP CFB mode uses an initialization vector (IV) of all zeros, and + prefixes the plaintext with BS+2 octets of random data, such that + octets BS+1 and BS+2 match octets BS-1 and BS. It does a CFB + resynchronization after encrypting those BS+2 octets. + + Thus, for an algorithm that has a block size of 8 octets (64 bits), + the IV is 10 octets long and octets 7 and 8 of the IV are the same as + octets 9 and 10. For an algorithm with a block size of 16 octets + (128 bits), the IV is 18 octets long, and octets 17 and 18 replicate + octets 15 and 16. Those extra two octets are an easy check for a + correct key. + + + +Callas, et al Standards Track [Page 78] + +RFC 4880 OpenPGP Message Format November 2007 + + + Step by step, here is the procedure: + + 1. The feedback register (FR) is set to the IV, which is all zeros. + + 2. FR is encrypted to produce FRE (FR Encrypted). This is the + encryption of an all-zero value. + + 3. FRE is xored with the first BS octets of random data prefixed to + the plaintext to produce C[1] through C[BS], the first BS octets + of ciphertext. + + 4. FR is loaded with C[1] through C[BS]. + + 5. FR is encrypted to produce FRE, the encryption of the first BS + octets of ciphertext. + + 6. The left two octets of FRE get xored with the next two octets of + data that were prefixed to the plaintext. This produces C[BS+1] + and C[BS+2], the next two octets of ciphertext. + + 7. (The resynchronization step) FR is loaded with C[3] through + C[BS+2]. + + 8. FR is encrypted to produce FRE. + + 9. FRE is xored with the first BS octets of the given plaintext, now + that we have finished encrypting the BS+2 octets of prefixed + data. This produces C[BS+3] through C[BS+(BS+2)], the next BS + octets of ciphertext. + + 10. FR is loaded with C[BS+3] to C[BS + (BS+2)] (which is C11-C18 for + an 8-octet block). + + 11. FR is encrypted to produce FRE. + + 12. FRE is xored with the next BS octets of plaintext, to produce + the next BS octets of ciphertext. These are loaded into FR, and + the process is repeated until the plaintext is used up. + +13.10. Private or Experimental Parameters + + S2K specifiers, Signature subpacket types, user attribute types, + image format types, and algorithms described in Section 9 all reserve + the range 100 to 110 for private and experimental use. Packet types + reserve the range 60 to 63 for private and experimental use. These + are intentionally managed with the PRIVATE USE method, as described + in [RFC2434]. + + + + +Callas, et al Standards Track [Page 79] + +RFC 4880 OpenPGP Message Format November 2007 + + + However, implementations need to be careful with these and promote + them to full IANA-managed parameters when they grow beyond the + original, limited system. + +13.11. Extension of the MDC System + + As described in the non-normative explanation in Section 5.13, the + MDC system is uniquely unparameterized in OpenPGP. This was an + intentional decision to avoid cross-grade attacks. If the MDC system + is extended to a stronger hash function, care must be taken to avoid + downgrade and cross-grade attacks. + + One simple way to do this is to create new packets for a new MDC. + For example, instead of the MDC system using packets 18 and 19, a new + MDC could use 20 and 21. This has obvious drawbacks (it uses two + packet numbers for each new hash function in a space that is limited + to a maximum of 60). + + Another simple way to extend the MDC system is to create new versions + of packet 18, and reflect this in packet 19. For example, suppose + that V2 of packet 18 implicitly used SHA-256. This would require + packet 19 to have a length of 32 octets. The change in the version + in packet 18 and the size of packet 19 prevent a downgrade attack. + + There are two drawbacks to this latter approach. The first is that + using the version number of a packet to carry algorithm information + is not tidy from a protocol-design standpoint. It is possible that + there might be several versions of the MDC system in common use, but + this untidiness would reflect untidiness in cryptographic consensus + about hash function security. The second is that different versions + of packet 19 would have to have unique sizes. If there were two + versions each with 256-bit hashes, they could not both have 32-octet + packet 19s without admitting the chance of a cross-grade attack. + + Yet another, complex approach to extend the MDC system would be a + hybrid of the two above -- create a new pair of MDC packets that are + fully parameterized, and yet protected from downgrade and cross- + grade. + + Any change to the MDC system MUST be done through the IETF CONSENSUS + method, as described in [RFC2434]. + +13.12. Meta-Considerations for Expansion + + If OpenPGP is extended in a way that is not backwards-compatible, + meaning that old implementations will not gracefully handle their + + + + + +Callas, et al Standards Track [Page 80] + +RFC 4880 OpenPGP Message Format November 2007 + + + absence of a new feature, the extension proposal can be declared in + the key holder's self-signature as part of the Features signature + subpacket. + + We cannot state definitively what extensions will not be upwards- + compatible, but typically new algorithms are upwards-compatible, + whereas new packets are not. + + If an extension proposal does not update the Features system, it + SHOULD include an explanation of why this is unnecessary. If the + proposal contains neither an extension to the Features system nor an + explanation of why such an extension is unnecessary, the proposal + SHOULD be rejected. + +14. Security Considerations + + * As with any technology involving cryptography, you should check the + current literature to determine if any algorithms used here have + been found to be vulnerable to attack. + + * This specification uses Public-Key Cryptography technologies. It + is assumed that the private key portion of a public-private key + pair is controlled and secured by the proper party or parties. + + * Certain operations in this specification involve the use of random + numbers. An appropriate entropy source should be used to generate + these numbers (see [RFC4086]). + + * The MD5 hash algorithm has been found to have weaknesses, with + collisions found in a number of cases. MD5 is deprecated for use + in OpenPGP. Implementations MUST NOT generate new signatures using + MD5 as a hash function. They MAY continue to consider old + signatures that used MD5 as valid. + + * SHA-224 and SHA-384 require the same work as SHA-256 and SHA-512, + respectively. In general, there are few reasons to use them + outside of DSS compatibility. You need a situation where one needs + more security than smaller hashes, but does not want to have the + full 256-bit or 512-bit data length. + + * Many security protocol designers think that it is a bad idea to use + a single key for both privacy (encryption) and integrity + (signatures). In fact, this was one of the motivating forces + behind the V4 key format with separate signature and encryption + keys. If you as an implementer promote dual-use keys, you should + at least be aware of this controversy. + + + + + +Callas, et al Standards Track [Page 81] + +RFC 4880 OpenPGP Message Format November 2007 + + + * The DSA algorithm will work with any hash, but is sensitive to the + quality of the hash algorithm. Verifiers should be aware that even + if the signer used a strong hash, an attacker could have modified + the signature to use a weak one. Only signatures using acceptably + strong hash algorithms should be accepted as valid. + + * As OpenPGP combines many different asymmetric, symmetric, and hash + algorithms, each with different measures of strength, care should + be taken that the weakest element of an OpenPGP message is still + sufficiently strong for the purpose at hand. While consensus about + the strength of a given algorithm may evolve, NIST Special + Publication 800-57 [SP800-57] recommends the following list of + equivalent strengths: + + Asymmetric | Hash | Symmetric + key size | size | key size + ------------+--------+----------- + 1024 160 80 + 2048 224 112 + 3072 256 128 + 7680 384 192 + 15360 512 256 + + * There is a somewhat-related potential security problem in + signatures. If an attacker can find a message that hashes to the + same hash with a different algorithm, a bogus signature structure + can be constructed that evaluates correctly. + + For example, suppose Alice DSA signs message M using hash algorithm + H. Suppose that Mallet finds a message M' that has the same hash + value as M with H'. Mallet can then construct a signature block + that verifies as Alice's signature of M' with H'. However, this + would also constitute a weakness in either H or H' or both. Should + this ever occur, a revision will have to be made to this document + to revise the allowed hash algorithms. + + * If you are building an authentication system, the recipient may + specify a preferred signing algorithm. However, the signer would + be foolish to use a weak algorithm simply because the recipient + requests it. + + * Some of the encryption algorithms mentioned in this document have + been analyzed less than others. For example, although CAST5 is + presently considered strong, it has been analyzed less than + TripleDES. Other algorithms may have other controversies + surrounding them. + + + + + +Callas, et al Standards Track [Page 82] + +RFC 4880 OpenPGP Message Format November 2007 + + + * In late summer 2002, Jallad, Katz, and Schneier published an + interesting attack on the OpenPGP protocol and some of its + implementations [JKS02]. In this attack, the attacker modifies a + message and sends it to a user who then returns the erroneously + decrypted message to the attacker. The attacker is thus using the + user as a random oracle, and can often decrypt the message. + + Compressing data can ameliorate this attack. The incorrectly + decrypted data nearly always decompresses in ways that defeat the + attack. However, this is not a rigorous fix, and leaves open some + small vulnerabilities. For example, if an implementation does not + compress a message before encryption (perhaps because it knows it + was already compressed), then that message is vulnerable. Because + of this happenstance -- that modification attacks can be thwarted + by decompression errors -- an implementation SHOULD treat a + decompression error as a security problem, not merely a data + problem. + + This attack can be defeated by the use of Modification Detection, + provided that the implementation does not let the user naively + return the data to the attacker. An implementation MUST treat an + MDC failure as a security problem, not merely a data problem. + + In either case, the implementation MAY allow the user access to the + erroneous data, but MUST warn the user as to potential security + problems should that data be returned to the sender. + + While this attack is somewhat obscure, requiring a special set of + circumstances to create it, it is nonetheless quite serious as it + permits someone to trick a user to decrypt a message. + Consequently, it is important that: + + 1. Implementers treat MDC errors and decompression failures as + security problems. + + 2. Implementers implement Modification Detection with all due + speed and encourage its spread. + + 3. Users migrate to implementations that support Modification + Detection with all due speed. + + * PKCS#1 has been found to be vulnerable to attacks in which a system + that reports errors in padding differently from errors in + decryption becomes a random oracle that can leak the private key in + mere millions of queries. Implementations must be aware of this + attack and prevent it from happening. The simplest solution is to + report a single error code for all variants of decryption errors so + as not to leak information to an attacker. + + + +Callas, et al Standards Track [Page 83] + +RFC 4880 OpenPGP Message Format November 2007 + + + * Some technologies mentioned here may be subject to government + control in some countries. + + * In winter 2005, Serge Mister and Robert Zuccherato from Entrust + released a paper describing a way that the "quick check" in OpenPGP + CFB mode can be used with a random oracle to decrypt two octets of + every cipher block [MZ05]. They recommend as prevention not using + the quick check at all. + + Many implementers have taken this advice to heart for any data that + is symmetrically encrypted and for which the session key is + public-key encrypted. In this case, the quick check is not needed + as the public-key encryption of the session key should guarantee + that it is the right session key. In other cases, the + implementation should use the quick check with care. + + On the one hand, there is a danger to using it if there is a random + oracle that can leak information to an attacker. In plainer + language, there is a danger to using the quick check if timing + information about the check can be exposed to an attacker, + particularly via an automated service that allows rapidly repeated + queries. + + On the other hand, it is inconvenient to the user to be informed + that they typed in the wrong passphrase only after a petabyte of + data is decrypted. There are many cases in cryptographic + engineering where the implementer must use care and wisdom, and + this is one. + +15. Implementation Nits + + This section is a collection of comments to help an implementer, + particularly with an eye to backward compatibility. Previous + implementations of PGP are not OpenPGP compliant. Often the + differences are small, but small differences are frequently more + vexing than large differences. Thus, this is a non-comprehensive + list of potential problems and gotchas for a developer who is trying + to be backward-compatible. + + * The IDEA algorithm is patented, and yet it is required for PGP + 2.x interoperability. It is also the de-facto preferred + algorithm for a V3 key with a V3 self-signature (or no self- + signature). + + * When exporting a private key, PGP 2.x generates the header "BEGIN + PGP SECRET KEY BLOCK" instead of "BEGIN PGP PRIVATE KEY BLOCK". + All previous versions ignore the implied data type, and look + directly at the packet data type. + + + +Callas, et al Standards Track [Page 84] + +RFC 4880 OpenPGP Message Format November 2007 + + + * PGP 2.0 through 2.5 generated V2 Public-Key packets. These are + identical to the deprecated V3 keys except for the version + number. An implementation MUST NOT generate them and may accept + or reject them as it sees fit. Some older PGP versions generated + V2 PKESK packets (Tag 1) as well. An implementation may accept + or reject V2 PKESK packets as it sees fit, and MUST NOT generate + them. + + * PGP 2.6.x will not accept key-material packets with versions + greater than 3. + + * There are many ways possible for two keys to have the same key + material, but different fingerprints (and thus Key IDs). Perhaps + the most interesting is an RSA key that has been "upgraded" to V4 + format, but since a V4 fingerprint is constructed by hashing the + key creation time along with other things, two V4 keys created at + different times, yet with the same key material will have + different fingerprints. + + * If an implementation is using zlib to interoperate with PGP 2.x, + then the "windowBits" parameter should be set to -13. + + * The 0x19 back signatures were not required for signing subkeys + until relatively recently. Consequently, there may be keys in + the wild that do not have these back signatures. Implementing + software may handle these keys as it sees fit. + + * OpenPGP does not put limits on the size of public keys. However, + larger keys are not necessarily better keys. Larger keys take + more computation time to use, and this can quickly become + impractical. Different OpenPGP implementations may also use + different upper bounds for public key sizes, and so care should + be taken when choosing sizes to maintain interoperability. As of + 2007 most implementations have an upper bound of 4096 bits. + + * ASCII armor is an optional feature of OpenPGP. The OpenPGP + working group strives for a minimal set of mandatory-to-implement + features, and since there could be useful implementations that + only use binary object formats, this is not a "MUST" feature for + an implementation. For example, an implementation that is using + OpenPGP as a mechanism for file signatures may find ASCII armor + unnecessary. OpenPGP permits an implementation to declare what + features it does and does not support, but ASCII armor is not one + of these. Since most implementations allow binary and armored + objects to be used indiscriminately, an implementation that does + not implement ASCII armor may find itself with compatibility + issues with general-purpose implementations. Moreover, + implementations of OpenPGP-MIME [RFC3156] already have a + + + +Callas, et al Standards Track [Page 85] + +RFC 4880 OpenPGP Message Format November 2007 + + + requirement for ASCII armor so those implementations will + necessarily have support. + +16. References + +16.1. Normative References + + [AES] NIST, FIPS PUB 197, "Advanced Encryption Standard + (AES)," November 2001. + http://csrc.nist.gov/publications/fips/fips197/fips- + 197.{ps,pdf} + + [BLOWFISH] Schneier, B. "Description of a New Variable-Length + Key, 64-Bit Block Cipher (Blowfish)" Fast Software + Encryption, Cambridge Security Workshop Proceedings + (December 1993), Springer-Verlag, 1994, pp191-204 + + + [BZ2] J. Seward, jseward@acm.org, "The Bzip2 and libbzip2 + home page" + + [ELGAMAL] T. Elgamal, "A Public-Key Cryptosystem and a + Signature Scheme Based on Discrete Logarithms," IEEE + Transactions on Information Theory, v. IT-31, n. 4, + 1985, pp. 469-472. + + [FIPS180] Secure Hash Signature Standard (SHS) (FIPS PUB 180- + 2). + + + [FIPS186] Digital Signature Standard (DSS) (FIPS PUB 186-2). + FIPS 186-3 describes keys + greater than 1024 bits. The latest draft is at: + + + [HAC] Alfred Menezes, Paul van Oorschot, and Scott + Vanstone, "Handbook of Applied Cryptography," CRC + Press, 1996. + + + [IDEA] Lai, X, "On the design and security of block + ciphers", ETH Series in Information Processing, J.L. + Massey (editor), Vol. 1, Hartung-Gorre Verlag + Knostanz, Technische Hochschule (Zurich), 1992 + + + + +Callas, et al Standards Track [Page 86] + +RFC 4880 OpenPGP Message Format November 2007 + + + [ISO10646] ISO/IEC 10646-1:1993. International Standard -- + Information technology -- Universal Multiple-Octet + Coded Character Set (UCS) -- Part 1: Architecture + and Basic Multilingual Plane. + + [JFIF] JPEG File Interchange Format (Version 1.02). Eric + Hamilton, C-Cube Microsystems, Milpitas, CA, + September 1, 1992. + + [RFC1950] Deutsch, P. and J-L. Gailly, "ZLIB Compressed Data + Format Specification version 3.3", RFC 1950, May + 1996. + + [RFC1951] Deutsch, P., "DEFLATE Compressed Data Format + Specification version 1.3", RFC 1951, May 1996. + + [RFC2045] Freed, N. and N. Borenstein, "Multipurpose Internet + Mail Extensions (MIME) Part One: Format of Internet + Message Bodies", RFC 2045, November 1996 + + [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate + Requirement Levels", BCP 14, RFC 2119, March 1997. + + [RFC2144] Adams, C., "The CAST-128 Encryption Algorithm", RFC + 2144, May 1997. + + [RFC2434] Narten, T. and H. Alvestrand, "Guidelines for + Writing an IANA Considerations Section in RFCs", BCP + 26, RFC 2434, October 1998. + + [RFC2822] Resnick, P., "Internet Message Format", RFC 2822, + April 2001. + + [RFC3156] Elkins, M., Del Torto, D., Levien, R., and T. + Roessler, "MIME Security with OpenPGP", RFC 3156, + August 2001. + + [RFC3447] Jonsson, J. and B. Kaliski, "Public-Key Cryptography + Standards (PKCS) #1: RSA Cryptography Specifications + Version 2.1", RFC 3447, February 2003. + + [RFC3629] Yergeau, F., "UTF-8, a transformation format of ISO + 10646", STD 63, RFC 3629, November 2003. + + [RFC4086] Eastlake, D., 3rd, Schiller, J., and S. Crocker, + "Randomness Requirements for Security", BCP 106, RFC + 4086, June 2005. + + + + +Callas, et al Standards Track [Page 87] + +RFC 4880 OpenPGP Message Format November 2007 + + + [SCHNEIER] Schneier, B., "Applied Cryptography Second Edition: + protocols, algorithms, and source code in C", 1996. + + [TWOFISH] B. Schneier, J. Kelsey, D. Whiting, D. Wagner, C. + Hall, and N. Ferguson, "The Twofish Encryption + Algorithm", John Wiley & Sons, 1999. + +16.2. Informative References + + [BLEICHENBACHER] Bleichenbacher, Daniel, "Generating Elgamal + signatures without knowing the secret key," + Eurocrypt 96. Note that the version in the + proceedings has an error. A revised version is + available at the time of writing from + + + [JKS02] Kahil Jallad, Jonathan Katz, Bruce Schneier + "Implementation of Chosen-Ciphertext Attacks against + PGP and GnuPG" http://www.counterpane.com/pgp- + attack.html + + [MAURER] Ueli Maurer, "Modelling a Public-Key + Infrastructure", Proc. 1996 European Symposium on + Research in Computer Security (ESORICS' 96), Lecture + Notes in Computer Science, Springer-Verlag, vol. + 1146, pp. 325-350, Sep 1996. + + [MZ05] Serge Mister, Robert Zuccherato, "An Attack on CFB + Mode Encryption As Used By OpenPGP," IACR ePrint + Archive: Report 2005/033, 8 Feb 2005 + http://eprint.iacr.org/2005/033 + + [REGEX] Jeffrey Friedl, "Mastering Regular Expressions," + O'Reilly, ISBN 0-596-00289-0. + + [RFC1423] Balenson, D., "Privacy Enhancement for Internet + Electronic Mail: Part III: Algorithms, Modes, and + Identifiers", RFC 1423, February 1993. + + [RFC1991] Atkins, D., Stallings, W., and P. Zimmermann, "PGP + Message Exchange Formats", RFC 1991, August 1996. + + [RFC2440] Callas, J., Donnerhacke, L., Finney, H., and R. + Thayer, "OpenPGP Message Format", RFC 2440, November + 1998. + + + + + +Callas, et al Standards Track [Page 88] + +RFC 4880 OpenPGP Message Format November 2007 + + + [SP800-57] NIST Special Publication 800-57, Recommendation on + Key Management + + + +Acknowledgements + + This memo also draws on much previous work from a number of other + authors, including: Derek Atkins, Charles Breed, Dave Del Torto, Marc + Dyksterhouse, Gail Haspert, Gene Hoffman, Paul Hoffman, Ben Laurie, + Raph Levien, Colin Plumb, Will Price, David Shaw, William Stallings, + Mark Weaver, and Philip R. Zimmermann. + +Authors' Addresses + + The working group can be contacted via the current chair: + + Derek Atkins + IHTFP Consulting, Inc. + 4 Farragut Ave + Somerville, MA 02144 USA + + EMail: derek@ihtfp.com + Tel: +1 617 623 3745 + + The principal authors of this document are as follows: + + Jon Callas + EMail: jon@callas.org + + Lutz Donnerhacke + IKS GmbH + Wildenbruchstr. 15 + 07745 Jena, Germany + EMail: lutz@iks-jena.de + + Hal Finney + EMail: hal@finney.org + + David Shaw + EMail: dshaw@jabberwocky.com + + Rodney Thayer + EMail: rodney@canola-jones.com + + + + + +Callas, et al Standards Track [Page 89] + +RFC 4880 OpenPGP Message Format November 2007 + + +Full Copyright Statement + + Copyright (C) The IETF Trust (2007). + + This document is subject to the rights, licenses and restrictions + contained in BCP 78, and except as set forth therein, the authors + retain all their rights. + + This document and the information contained herein are provided on an + "AS IS" basis and THE CONTRIBUTOR, THE ORGANIZATION HE/SHE REPRESENTS + OR IS SPONSORED BY (IF ANY), THE INTERNET SOCIETY, THE IETF TRUST AND + THE INTERNET ENGINEERING TASK FORCE DISCLAIM ALL WARRANTIES, EXPRESS + OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF + THE INFORMATION HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED + WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + +Intellectual Property + + The IETF takes no position regarding the validity or scope of any + Intellectual Property Rights or other rights that might be claimed to + pertain to the implementation or use of the technology described in + this document or the extent to which any license under such rights + might or might not be available; nor does it represent that it has + made any independent effort to identify any such rights. Information + on the procedures with respect to rights in RFC documents can be + found in BCP 78 and BCP 79. + + Copies of IPR disclosures made to the IETF Secretariat and any + assurances of licenses to be made available, or the result of an + attempt made to obtain a general license or permission for the use of + such proprietary rights by implementers or users of this + specification can be obtained from the IETF on-line IPR repository at + http://www.ietf.org/ipr. + + The IETF invites any interested party to bring to its attention any + copyrights, patents or patent applications, or other proprietary + rights that may cover technology that may be required to implement + this standard. Please address the information to the IETF at + ietf-ipr@ietf.org. + + + + + + + + + + + + +Callas, et al Standards Track [Page 90] + diff --git a/vendor/swiftmailer/swiftmailer/notes/rfc/rfc4954.txt b/vendor/swiftmailer/swiftmailer/notes/rfc/rfc4954.txt new file mode 100755 index 0000000..668d738 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/notes/rfc/rfc4954.txt @@ -0,0 +1,1123 @@ + + + + + + +Network Working Group R. Siemborski, Ed. +Request for Comments: 4954 Google, Inc. +Obsoletes: 2554 A. Melnikov, Ed. +Updates: 3463 Isode Limited +Category: Standards Track July 2007 + + + SMTP Service Extension for Authentication + +Status of This Memo + + This document specifies an Internet standards track protocol for the + Internet community, and requests discussion and suggestions for + improvements. Please refer to the current edition of the "Internet + Official Protocol Standards" (STD 1) for the standardization state + and status of this protocol. Distribution of this memo is unlimited. + +Copyright Notice + + Copyright (C) The IETF Trust (2007). + +Abstract + + This document defines a Simple Mail Transport Protocol (SMTP) + extension whereby an SMTP client may indicate an authentication + mechanism to the server, perform an authentication protocol exchange, + and optionally negotiate a security layer for subsequent protocol + interactions during this session. This extension includes a profile + of the Simple Authentication and Security Layer (SASL) for SMTP. + + This document obsoletes RFC 2554. + + + + + + + + + + + + + + + + + + + + +Siemborski & Melnikov Standards Track [Page 1] + +RFC 4954 SMTP Service Extension for Authentication July 2007 + + +Table of Contents + + 1. Introduction ....................................................2 + 2. How to Read This Document .......................................2 + 3. The Authentication Service Extension ............................3 + 4. The AUTH Command ................................................3 + 4.1. Examples ...................................................7 + 5. The AUTH Parameter to the MAIL FROM command .....................9 + 5.1. Examples ..................................................10 + 6. Status Codes ...................................................11 + 7. Additional requirements on servers .............................12 + 8. Formal Syntax ..................................................13 + 9. Security Considerations ........................................14 + 10. IANA Considerations ...........................................15 + 11. Normative References ..........................................15 + 12. Informative References ........................................16 + 13. Acknowledgments ...............................................17 + 14. Additional Requirements When Using SASL PLAIN over TLS ........17 + 15. Changes since RFC 2554 ........................................18 + +1. Introduction + + This document defines a Simple Mail Transport Protocol (SMTP) + extension whereby an SMTP client may indicate an authentication + mechanism to the server, perform an authentication protocol exchange, + optionally negotiate a security layer for subsequent protocol + interactions during this session and, during a mail transaction, + optionally specify a mailbox associated with the identity that + submitted the message to the mail delivery system. + + This extension includes a profile of the Simple Authentication and + Security Layer (SASL) for SMTP. + + When compared to RFC 2554, this document deprecates use of the 538 + response code, adds a new Enhanced Status Code, adds a requirement to + support SASLprep profile for preparing authorization identities, + recommends use of RFC 3848 transmission types in the Received trace + header field, and clarifies interaction with SMTP PIPELINING + [PIPELINING] extension. + +2. How to Read This Document + + The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", + "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this + document are to be interpreted as described in [KEYWORDS]. + + In examples, "C:" and "S:" indicate lines sent by the client and + server, respectively. + + + +Siemborski & Melnikov Standards Track [Page 2] + +RFC 4954 SMTP Service Extension for Authentication July 2007 + + +3. The Authentication Service Extension + + 1. The name of this [SMTP] service extension is "Authentication". + + 2. The EHLO keyword value associated with this extension is "AUTH". + + 3. The AUTH EHLO keyword contains as a parameter a space-separated + list of the names of available [SASL] mechanisms. The list of + available mechanisms MAY change after a successful STARTTLS + command [SMTP-TLS]. + + 4. A new [SMTP] verb "AUTH" is defined. + + 5. An optional parameter using the keyword "AUTH" is added to the + MAIL FROM command, and extends the maximum line length of the + MAIL FROM command by 500 characters. + + 6. This extension is appropriate for the submission protocol + [SUBMIT]. + +4. The AUTH Command + + AUTH mechanism [initial-response] + + Arguments: + mechanism: A string identifying a [SASL] authentication + mechanism. + + initial-response: An optional initial client response. If + present, this response MUST be encoded as described in Section + 4 of [BASE64] or contain a single character "=". + + Restrictions: + After an AUTH command has been successfully completed, no more + AUTH commands may be issued in the same session. After a + successful AUTH command completes, a server MUST reject any + further AUTH commands with a 503 reply. + + The AUTH command is not permitted during a mail transaction. + An AUTH command issued during a mail transaction MUST be + rejected with a 503 reply. + + Discussion: + The AUTH command initiates a [SASL] authentication exchange + between the client and the server. The client identifies the + SASL mechanism to use with the first parameter of the AUTH + command. If the server supports the requested authentication + mechanism, it performs the SASL exchange to authenticate the + + + +Siemborski & Melnikov Standards Track [Page 3] + +RFC 4954 SMTP Service Extension for Authentication July 2007 + + + user. Optionally, it also negotiates a security layer for + subsequent protocol interactions during this session. If the + requested authentication mechanism is invalid (e.g., is not + supported or requires an encryption layer), the server rejects + the AUTH command with a 504 reply. If the server supports the + [ESMTP-CODES] extension, it SHOULD return a 5.5.4 enhanced + response code. + + The SASL authentication exchange consists of a series of + server challenges and client responses that are specific to + the chosen [SASL] mechanism. + + A server challenge is sent as a 334 reply with the text part + containing the [BASE64] encoded string supplied by the SASL + mechanism. This challenge MUST NOT contain any text other + than the BASE64 encoded challenge. + + A client response consists of a line containing a [BASE64] + encoded string. If the client wishes to cancel the + authentication exchange, it issues a line with a single "*". + If the server receives such a response, it MUST reject the + AUTH command by sending a 501 reply. + + The optional initial response argument to the AUTH command is + used to save a round-trip when using authentication mechanisms + that support an initial client response. If the initial + response argument is omitted and the chosen mechanism requires + an initial client response, the server MUST proceed as defined + in Section 5.1 of [SASL]. In SMTP, a server challenge that + contains no data is defined as a 334 reply with no text part. + Note that there is still a space following the reply code, so + the complete response line is "334 ". + + Note that the AUTH command is still subject to the line length + limitations defined in [SMTP]. If use of the initial response + argument would cause the AUTH command to exceed this length, + the client MUST NOT use the initial response parameter (and + instead proceed as defined in Section 5.1 of [SASL]). + + If the client is transmitting an initial response of zero + length, it MUST instead transmit the response as a single + equals sign ("="). This indicates that the response is + present, but contains no data. + + If the client uses an initial-response argument to the AUTH + command with a SASL mechanism in which the client does not + begin the authentication exchange, the server MUST reject the + + + + +Siemborski & Melnikov Standards Track [Page 4] + +RFC 4954 SMTP Service Extension for Authentication July 2007 + + + AUTH command with a 501 reply. Servers using the enhanced + status codes extension [ESMTP-CODES] SHOULD return an enhanced + status code of 5.7.0 in this case. + + If the server cannot [BASE64] decode any client response, it + MUST reject the AUTH command with a 501 reply (and an enhanced + status code of 5.5.2). If the client cannot BASE64 decode any + of the server's challenges, it MUST cancel the authentication + using the "*" response. In particular, servers and clients + MUST reject (and not ignore) any character not explicitly + allowed by the BASE64 alphabet, and MUST reject any sequence + of BASE64 characters that contains the pad character ('=') + anywhere other than the end of the string (e.g., "=AAA" and + "AAA=BBB" are not allowed). + + Note that these [BASE64] strings can be much longer than + normal SMTP commands. Clients and servers MUST be able to + handle the maximum encoded size of challenges and responses + generated by their supported authentication mechanisms. This + requirement is independent of any line length limitations the + client or server may have in other parts of its protocol + implementation. (At the time of writing of this document, + 12288 octets is considered to be a sufficient line length + limit for handling of deployed authentication mechanisms.) + If, during an authentication exchange, the server receives a + line that is longer than the server's authentication buffer, + the server fails the AUTH command with the 500 reply. Servers + using the enhanced status codes extension [ESMTP-CODES] SHOULD + return an enhanced status code of 5.5.6 in this case. + + The authorization identity generated by this [SASL] exchange + is a "simple username" (in the sense defined in [SASLprep]), + and both client and server SHOULD (*) use the [SASLprep] + profile of the [StringPrep] algorithm to prepare these names + for transmission or comparison. If preparation of the + authorization identity fails or results in an empty string + (unless it was transmitted as the empty string), the server + MUST fail the authentication. + + (*) Note: Future revision of this specification may change this + requirement to MUST. Currently, the SHOULD is used in order to + avoid breaking the majority of existing implementations. + + If the server is unable to authenticate the client, it SHOULD reject + the AUTH command with a 535 reply unless a more specific error code + is appropriate. Should the client successfully complete the + exchange, the SMTP server issues a 235 reply. (Note that the SMTP + protocol doesn't support the SASL feature of returning additional + + + +Siemborski & Melnikov Standards Track [Page 5] + +RFC 4954 SMTP Service Extension for Authentication July 2007 + + + data with a successful outcome.) These status codes, along with + others defined by this extension, are discussed in Section 6 of this + document. + + If a security layer is negotiated during the SASL exchange, it takes + effect for the client on the octet immediately following the CRLF + that concludes the last response generated by the client. For the + server, it takes effect immediately following the CRLF of its success + reply. + + When a security layer takes effect, the SMTP protocol is reset to the + initial state (the state in SMTP after a server issues a 220 service + ready greeting). The server MUST discard any knowledge obtained from + the client, such as the EHLO argument, which was not obtained from + the SASL negotiation itself. Likewise, the client MUST discard any + knowledge obtained from the server, such as the list of SMTP service + extensions, which was not obtained from the SASL negotiation itself. + (Note that a client MAY compare the advertised SASL mechanisms before + and after authentication in order to detect an active down- + negotiation attack). + + The client SHOULD send an EHLO command as the first command after a + successful SASL negotiation that results in the enabling of a + security layer. + + When an entity (whether it is the client or the server end) is + sending data, and both [TLS] and SASL security layers are in effect, + the TLS encoding MUST be applied after the SASL encoding, regardless + of the order in which the layers were negotiated. + + The service name specified by this protocol's profile of SASL is + "smtp". This service name is also to be used for the [SUBMIT] + protocol. + + If an AUTH command fails, the client MAY proceed without + authentication. Alternatively, the client MAY try another + authentication mechanism or present different credentials by issuing + another AUTH + + Note: A server implementation MUST implement a configuration in which + it does NOT permit any plaintext password mechanisms, unless either + the STARTTLS [SMTP-TLS] command has been negotiated or some other + mechanism that protects the session from password snooping has been + provided. Server sites SHOULD NOT use any configuration which + permits a plaintext password mechanism without such a protection + mechanism against password snooping. + + + + + +Siemborski & Melnikov Standards Track [Page 6] + +RFC 4954 SMTP Service Extension for Authentication July 2007 + + + To ensure interoperability, client and server implementations of this + extension MUST implement the [PLAIN] SASL mechanism running over TLS + [TLS] [SMTP-TLS]. See also Section 15 for additional requirements on + implementations of [PLAIN] over [TLS]. + + Note that many existing client and server implementations implement + CRAM-MD5 [CRAM-MD5] SASL mechanism. In order to ensure + interoperability with deployed software, new implementations MAY + implement it; however, implementations should be aware that this SASL + mechanism doesn't provide any server authentication. Note that at + the time of writing of this document the SASL Working Group is + working on several replacement SASL mechanisms that provide server + authentication and other features. + + When the AUTH command is used together with the [PIPELINING] + extension, it MUST be the last command in a pipelined group of + commands. The only exception to this rule is when the AUTH command + contains an initial response for a SASL mechanism that allows the + client to send data first, the SASL mechanism is known to complete in + one round-trip, and a security layer is not negotiated by the client. + Two examples of such SASL mechanisms are PLAIN [PLAIN] and EXTERNAL + [SASL]. + +4.1. Examples + + Here is an example of a client attempting AUTH using the [PLAIN] SASL + mechanism under a TLS layer, and making use of the initial client + response: + + S: 220-smtp.example.com ESMTP Server + C: EHLO client.example.com + S: 250-smtp.example.com Hello client.example.com + S: 250-AUTH GSSAPI DIGEST-MD5 + S: 250-ENHANCEDSTATUSCODES + S: 250 STARTTLS + C: STARTTLS + S: 220 Ready to start TLS + ... TLS negotiation proceeds, further commands + protected by TLS layer ... + C: EHLO client.example.com + S: 250-smtp.example.com Hello client.example.com + S: 250 AUTH GSSAPI DIGEST-MD5 PLAIN + C: AUTH PLAIN dGVzdAB0ZXN0ADEyMzQ= + S: 235 2.7.0 Authentication successful + + Here is another client that is attempting AUTH PLAIN under a TLS + layer, this time without the initial response. Parts of the + negotiation before the TLS layer was established have been omitted: + + + +Siemborski & Melnikov Standards Track [Page 7] + +RFC 4954 SMTP Service Extension for Authentication July 2007 + + + ... TLS negotiation proceeds, further commands + protected by TLS layer ... + C: EHLO client.example.com + S: 250-smtp.example.com Hello client.example.com + S: 250 AUTH GSSAPI DIGEST-MD5 PLAIN + C: AUTH PLAIN + (note: there is a single space following the 334 + on the following line) + S: 334 + C: dGVzdAB0ZXN0ADEyMzQ= + S: 235 2.7.0 Authentication successful + + Here is an example using CRAM-MD5 [CRAM-MD5], a mechanism in which + the client does not begin the authentication exchange, and includes a + server challenge: + + S: 220-smtp.example.com ESMTP Server + C: EHLO client.example.com + S: 250-smtp.example.com Hello client.example.com + S: 250-AUTH DIGEST-MD5 CRAM-MD5 + S: 250-ENHANCEDSTATUSCODES + S: 250 STARTTLS + C: AUTH CRAM-MD5 + S: 334 PDQxOTI5NDIzNDEuMTI4Mjg0NzJAc291cmNlZm91ci5hbmRyZXcuY211LmVk + dT4= + C: cmpzMyBlYzNhNTlmZWQzOTVhYmExZWM2MzY3YzRmNGI0MWFjMA== + S: 235 2.7.0 Authentication successful + + Here is an example of a client attempting AUTH EXTERNAL under TLS, + using the derived authorization ID (and thus a zero-length initial + client response). + + S: 220-smtp.example.com ESMTP Server + C: EHLO client.example.com + S: 250-smtp.example.com Hello client.example.com + S: 250-AUTH GSSAPI DIGEST-MD5 + S: 250-ENHANCEDSTATUSCODES + S: 250 STARTTLS + C: STARTTLS + S: 220 Ready to start TLS + ... TLS negotiation proceeds, further commands + protected by TLS layer ... + C: EHLO client.example.com + S: 250-smtp.example.com Hello client.example.com + S: 250 AUTH EXTERNAL GSSAPI DIGEST-MD5 PLAIN + C: AUTH EXTERNAL = + S: 235 2.7.0 Authentication successful + + + + +Siemborski & Melnikov Standards Track [Page 8] + +RFC 4954 SMTP Service Extension for Authentication July 2007 + + +5. The AUTH Parameter to the MAIL FROM command + + AUTH=mailbox + + Arguments: + A (see Section 4.1.2 of [SMTP]) that is associated + with the identity that submitted the message to the delivery + system, or the two character sequence "<>" indicating such an + identity is unknown or insufficiently authenticated. To comply + with restrictions imposed on ESMTP parameters, the is + encoded inside an xtext. The syntax of an xtext is described in + Section 4 of [ESMTP-DSN]. + + Note: + For the purposes of this discussion, "authenticated identity" + refers to the identity (if any) derived from the authorization + identity of previous AUTH command, while the terms "authorized + identity" and "supplied " refer to the sender identity + that is being associated with a particular message. Note that + one authenticated identity may be able to identify messages as + being sent by any number of authorized identities within a + single session. For example, this may be the case when an SMTP + server (one authenticated identity) is processing its queue + (many messages with distinct authorized identities). + + Discussion: + The optional AUTH parameter to the MAIL FROM command allows + cooperating agents in a trusted environment to communicate the + authorization identity associated with individual messages. + + If the server trusts the authenticated identity of the client to + assert that the message was originally submitted by the supplied + , then the server SHOULD supply the same in + an AUTH parameter when relaying the message to any other server + which supports the AUTH extension. + + For this reason, servers that advertise support for this + extension MUST support the AUTH parameter to the MAIL FROM + command even when the client has not authenticated itself to the + server. + + A MAIL FROM parameter of AUTH=<> indicates that the original + submitter of the message is not known. The server MUST NOT + treat the message as having been originally submitted by the + authenticated identity that resulted from the AUTH command. + + + + + + +Siemborski & Melnikov Standards Track [Page 9] + +RFC 4954 SMTP Service Extension for Authentication July 2007 + + + If the AUTH parameter to the MAIL FROM command is not supplied, + the client has authenticated, and the server believes the + message is an original submission, the server MAY generate a + from the user's authenticated identity for use in an + AUTH parameter when relaying the message to any server which + supports the AUTH extension. The generated is + implementation specific, but it MUST conform to the syntax of + [SMTP]. If the implementation cannot generate a valid + , it MUST transmit AUTH=<> when relaying this message. + + If the server does not sufficiently trust the authenticated + identity of the client, or if the client is not authenticated, + then the server MUST behave as if the AUTH=<> parameter was + supplied. The server MAY, however, write the value of any + supplied AUTH parameter to a log file. + + If an AUTH=<> parameter was supplied, either explicitly or due + to the requirement in the previous paragraph, then the server + MUST supply the AUTH=<> parameter when relaying the message to + any server which it has authenticated to using the AUTH + extension. + + A server MAY treat expansion of a mailing list as a new + submission, setting the AUTH parameter to the mailing list + address or mailing list administration address when relaying the + message to list subscribers. + + Note that an implementation which is hard-coded to treat all + clients as being insufficiently trusted is compliant with this + specification. In that case, the implementation does nothing + more than parse and discard syntactically valid AUTH parameters + to the MAIL FROM command, and supply AUTH=<> parameters to any + servers that it authenticates to. + +5.1. Examples + + An example where the original identity of the sender is trusted and + known: + + C: MAIL FROM: AUTH=e+3Dmc2@example.com + S: 250 OK + + One example where the identity of the sender is not trusted or is + otherwise being suppressed by the client: + + C: MAIL FROM: AUTH=<> + S: 250 OK + + + + +Siemborski & Melnikov Standards Track [Page 10] + +RFC 4954 SMTP Service Extension for Authentication July 2007 + + +6. Status Codes + + The following error codes may be used to indicate various success or + failure conditions. Servers that return enhanced status codes + [ESMTP-CODES] SHOULD use the enhanced codes suggested here. + + 235 2.7.0 Authentication Succeeded + + This response to the AUTH command indicates that the authentication + was successful. + + 432 4.7.12 A password transition is needed + + This response to the AUTH command indicates that the user needs to + transition to the selected authentication mechanism. This is + typically done by authenticating once using the [PLAIN] + authentication mechanism. The selected mechanism SHOULD then work + for authentications in subsequent sessions. + + 454 4.7.0 Temporary authentication failure + + This response to the AUTH command indicates that the authentication + failed due to a temporary server failure. The client SHOULD NOT + prompt the user for another password in this case, and should instead + notify the user of server failure. + + 534 5.7.9 Authentication mechanism is too weak + + This response to the AUTH command indicates that the selected + authentication mechanism is weaker than server policy permits for + that user. The client SHOULD retry with a new authentication + mechanism. + + 535 5.7.8 Authentication credentials invalid + + This response to the AUTH command indicates that the authentication + failed due to invalid or insufficient authentication credentials. In + this case, the client SHOULD ask the user to supply new credentials + (such as by presenting a password dialog box). + + 500 5.5.6 Authentication Exchange line is too long + + This response to the AUTH command indicates that the authentication + failed due to the client sending a [BASE64] response that is longer + than the maximum buffer size available for the currently selected + SASL mechanism. + + + + + +Siemborski & Melnikov Standards Track [Page 11] + +RFC 4954 SMTP Service Extension for Authentication July 2007 + + + 530 5.7.0 Authentication required + + This response SHOULD be returned by any command other than AUTH, + EHLO, HELO, NOOP, RSET, or QUIT when server policy requires + authentication in order to perform the requested action and + authentication is not currently in force. + + 538 5.7.11 Encryption required for requested authentication + mechanism + + This response to the AUTH command indicates that the selected + authentication mechanism may only be used when the underlying SMTP + connection is encrypted. Note that this response code is documented + here for historical purposes only. Modern implementations SHOULD NOT + advertise mechanisms that are not permitted due to lack of + encryption, unless an encryption layer of sufficient strength is + currently being employed. + + This document adds several new enhanced status codes to the list + defined in [ENHANCED]: + + The following 3 Enhanced Status Codes were defined above: + + 5.7.8 Authentication credentials invalid + 5.7.9 Authentication mechanism is too weak + 5.7.11 Encryption required for requested authentication mechanism + + X.5.6 Authentication Exchange line is too long + + This enhanced status code SHOULD be returned when the server fails + the AUTH command due to the client sending a [BASE64] response which + is longer than the maximum buffer size available for the currently + selected SASL mechanism. This is useful for both permanent and + persistent transient errors. + +7. Additional Requirements on Servers + + As described in Section 4.4 of [SMTP], an SMTP server that receives a + message for delivery or further processing MUST insert the + "Received:" header field at the beginning of the message content. + This document places additional requirements on the content of a + generated "Received:" header field. Upon successful authentication, + a server SHOULD use the "ESMTPA" or the "ESMTPSA" [SMTP-TT] (when + appropriate) keyword in the "with" clause of the Received header + field. + + + + + + +Siemborski & Melnikov Standards Track [Page 12] + +RFC 4954 SMTP Service Extension for Authentication July 2007 + + +8. Formal Syntax + + The following syntax specification uses the Augmented Backus-Naur + Form notation as specified in [ABNF]. Non-terminals referenced but + not defined below are as defined by [ABNF] or [SASL]. The non- + terminal is defined in [SMTP]. + + Except as noted otherwise, all alphabetic characters are case- + insensitive. The use of upper or lower case characters to define + token strings is for editorial clarity only. Implementations MUST + accept these strings in a case-insensitive fashion. + + hexchar = "+" HEXDIG HEXDIG + + xchar = %x21-2A / %x2C-3C / %x3E-7E + ;; US-ASCII except for "+", "=", SP, and CTL + + xtext = *(xchar / hexchar) + ;; non-US-ASCII is only allowed as hexchar + + auth-command = "AUTH" SP sasl-mech [SP initial-response] + *(CRLF [base64]) [CRLF cancel-response] + CRLF + ;; is defined in [SASL] + + auth-param = "AUTH=" xtext + ;; Parameter to the MAIL FROM command. + ;; This non-terminal complies with + ;; syntax defined by esmtp-param [SMTP]. + ;; + ;; The decoded form of the xtext MUST be + ;; either a or the two + ;; characters "<>" + + base64 = base64-terminal / + ( 1*(4base64-char) [base64-terminal] ) + + base64-char = ALPHA / DIGIT / "+" / "/" + ;; Case-sensitive + + base64-terminal = (2base64-char "==") / (3base64-char "=") + + continue-req = "334" SP [base64] CRLF + ;; Intermediate response to the AUTH + ;; command. + ;; This non-terminal complies with + ;; syntax defined by Reply-line [SMTP]. + + + + +Siemborski & Melnikov Standards Track [Page 13] + +RFC 4954 SMTP Service Extension for Authentication July 2007 + + + initial-response= base64 / "=" + + cancel-response = "*" + +9. Security Considerations + + Security issues are discussed throughout this memo. + + If a client uses this extension to get an encrypted tunnel through an + insecure network to a cooperating server, it needs to be configured + to never send mail to that server when the connection is not mutually + authenticated and encrypted. Otherwise, an attacker could steal the + client's mail by hijacking the [SMTP] connection and either + pretending the server does not support the Authentication extension + or causing all AUTH commands to fail. + + Before the [SASL] negotiation has begun, any protocol interactions + are performed in the clear and may be modified by an active attacker. + For this reason, clients and servers MUST discard any knowledge + obtained prior to the start of the SASL negotiation upon the + establishment of a security layer. + + This mechanism does not protect the TCP port, so an active attacker + may redirect a relay connection attempt (i.e., a connection between + two Mail Transfer Agents (MTAs)) to the submission port [SUBMIT]. + The AUTH=<> parameter prevents such an attack from causing a relayed + message and, in the absence of other envelope authentication, from + picking up the authentication of the relay client. + + A message submission client may require the user to authenticate + whenever a suitable [SASL] mechanism is advertised. Therefore, it + may not be desirable for a submission server [SUBMIT] to advertise a + SASL mechanism when use of that mechanism grants the clients no + benefits over anonymous submission. + + Servers MAY implement a policy whereby the connection is dropped + after a number of failed authentication attempts. If they do so, + they SHOULD NOT drop the connection until at least 3 attempts to + authenticate have failed. + + If an implementation supports SASL mechanisms that are vulnerable to + passive eavesdropping attacks (such as [PLAIN]), then the + implementation MUST support at least one configuration where these + SASL mechanisms are not advertised or used without the presence of an + external security layer such as [TLS]. + + + + + + +Siemborski & Melnikov Standards Track [Page 14] + +RFC 4954 SMTP Service Extension for Authentication July 2007 + + + This extension is not intended to replace or be used instead of end- + to-end message signature and encryption systems such as [S/MIME] or + [PGP]. This extension addresses a different problem than end-to-end + systems; it has the following key differences: + + 1. It is generally useful only within a trusted enclave. + + 2. It protects the entire envelope of a message, not just the + message's body. + + 3. It authenticates the message submission, not authorship of the + message content. + + 4. When mutual authentication is used along with a security layer, + it can give the sender some assurance that the message was + successfully delivered to the next hop. + + Additional security considerations are mentioned in the [SASL] + specification. Additional security considerations specific to a + particular SASL mechanism are described in the relevant + specification. Additional security considerations for [PLAIN] over + [TLS] are mentioned in Section 15 of this document. + +10. IANA Considerations + + IANA updated the entry for the "smtp" SASL protocol name to point at + this document. + + IANA updated the registration of the Authentication SMTP service + extension as defined in Section 3 of this document. This registry is + currently located at . + +11. Normative References + + [ABNF] Crocker, D. and P. Overell, "Augmented BNF for Syntax + Specifications: ABNF", RFC 4234, October 2005. + + [BASE64] Josefsson, S., "The Base16, Base32, and Base64 Data + Encodings", RFC 4648, October 2006. + + [ESMTP-CODES] Freed, N., "SMTP Service Extension for Returning + Enhanced Error Codes", RFC 2034, October 1996. + + [ENHANCED] Vaudreuil, G., "Enhanced Mail System Status Codes", RFC + 3463, January 2003. + + + + + +Siemborski & Melnikov Standards Track [Page 15] + +RFC 4954 SMTP Service Extension for Authentication July 2007 + + + [ESMTP-DSN] Moore, K., "Simple Mail Transfer Protocol (SMTP) + Service Extension Delivery Status Notifications + (DSNs)", RFC 3461, January 2003. + + [KEYWORDS] Bradner, S., "Key words for use in RFCs to Indicate + Requirement Levels", BCP 14, RFC 2119, March 1997. + + [SASL] Melnikov, A. and K. Zeilenga, "Simple Authentication + and Security Layer (SASL)", RFC 4422, June 2006. + + [SASLprep] Zeilenga, K., "SASLprep: Stringprep Profile for User + Names and Passwords", RFC 4013, February 2005. + + [SMTP] Klensin, J., "Simple Mail Transfer Protocol", RFC 2821, + April 2001. + + [SMTP-TLS] Hoffman, P., "SMTP Service Extension for Secure SMTP + over Transport Layer Security", RFC 3207, February + 2002. + + [StringPrep] Hoffman, P. and M. Blanchet, "Preparation of + Internationalized Strings ("stringprep")", RFC 3454, + December 2002. + + [SUBMIT] Gellens, R. and J. Klensin, "Message Submission for + Mail", RFC 4409, April 2006. + + [SMTP-TT] Newman, C., "ESMTP and LMTP Transmission Types + Registration", RFC 3848, July 2004. + + [PLAIN] Zeilenga, K., Ed., "The PLAIN Simple Authentication and + Security Layer (SASL) Mechanism", RFC 4616, August + 2006. + + [X509] Housley, R., Polk, W., Ford, W., and D. Solo, "Internet + X.509 Public Key Infrastructure Certificate and + Certificate Revocation List (CRL) Profile", RFC 3280, + April 2002. + +12. Informative References + + [PGP] Elkins, M., "MIME Security with Pretty Good Privacy + (PGP)", RFC 2015, October 1996. + + [S/MIME] Ramsdell, B., Ed., "Secure/Multipurpose Internet Mail + Extensions (S/MIME) Version 3.1 Message Specification", + RFC 3851, July 2004. + + + + +Siemborski & Melnikov Standards Track [Page 16] + +RFC 4954 SMTP Service Extension for Authentication July 2007 + + + [TLS] Dierks, T. and E. Rescorla, "The Transport Layer + Security (TLS) Protocol Version 1.1", RFC 4346, April + 2006. + + [PIPELINING] Freed, N., "SMTP Service Extension for Command + Pipelining", STD 60, RFC 2920, September 2000. + + [CRAM-MD5] Klensin, J., Catoe, R., and P. Krumviede, "IMAP/POP + AUTHorize Extension for Simple Challenge/Response", RFC + 2195, September 1997. + +13. Acknowledgments + + The editors would like to acknowledge the contributions of John Myers + and other contributors to RFC 2554, on which this document draws from + heavily. + + The editors would also like to thank Ken Murchison, Mark Crispin, + Chris Newman, David Wilson, Dave Cridland, Frank Ellermann, Ned + Freed, John Klensin, Tony Finch, Abhijit Menon-Sen, Philip Guenther, + Sam Hartman, Russ Housley, Cullen Jennings, and Lisa Dusseault for + the time they devoted to reviewing of this document and/or for the + comments received. + +14. Additional Requirements When Using SASL PLAIN over TLS + + This section is normative for SMTP implementations that support SASL + [PLAIN] over [TLS]. + + If an SMTP client is willing to use SASL PLAIN over TLS to + authenticate to the SMTP server, the client verifies the server + certificate according to the rules of [X509]. If the server has not + provided any certificate, or if the certificate verification fails, + the client MUST NOT attempt to authenticate using the SASL PLAIN + mechanism. + + After a successful [TLS] negotiation, the client MUST check its + understanding of the server hostname against the server's identity as + presented in the server Certificate message, in order to prevent + man-in-the-middle attacks. If the match fails, the client MUST NOT + attempt to authenticate using the SASL PLAIN mechanism. Matching is + performed according to the following rules: + + The client MUST use the server hostname it used to open the + connection as the value to compare against the server name as + expressed in the server certificate. The client MUST NOT use + + + + + +Siemborski & Melnikov Standards Track [Page 17] + +RFC 4954 SMTP Service Extension for Authentication July 2007 + + + any form of the server hostname derived from an insecure remote + source (e.g., insecure DNS lookup). CNAME canonicalization is + not done. + + If a subjectAltName extension of type dNSName is present in the + certificate, it SHOULD be used as the source of the server's + identity. + + Matching is case-insensitive. + + A "*" wildcard character MAY be used as the leftmost name + component in the certificate. For example, *.example.com would + match a.example.com, foo.example.com, etc., but would not match + example.com. + + If the certificate contains multiple names (e.g., more than one + dNSName field), then a match with any one of the fields is + considered acceptable. + +15. Changes since RFC 2554 + + 1. Clarified that servers MUST support the use of the AUTH=mailbox + parameter to MAIL FROM, even when the client is not + authenticated. + + 2. Clarified the initial-client-send requirements, and give + additional examples. + + 3. Updated references to newer versions of various specifications. + + 4. Required SASL PLAIN (over TLS) as mandatory-to-implement. + + 5. Clarified that the mechanism list can change. + + 6. Deprecated the use of the 538 response code. + + 7. Added the use of the SASLprep profile for preparing authorization + identities. + + 8. Substantial cleanup of response codes and indicated suggested + enhanced response codes. Also indicated what response codes + should result in a client prompting the user for new credentials. + + 9. Updated ABNF section to use RFC 4234. + + 10. Clarified interaction with SMTP PIPELINING extension. + + 11. Added a reference to RFC 3848. + + + +Siemborski & Melnikov Standards Track [Page 18] + +RFC 4954 SMTP Service Extension for Authentication July 2007 + + + 12. Added a new Enhanced Status Code for "authentication line too + long" case. + + 13. Other general editorial clarifications. + +Editors' Addresses + + Robert Siemborski + Google, Inc. + 1600 Ampitheatre Parkway + Mountain View, CA 94043, USA + + Phone: +1 650 623 6925 + EMail: robsiemb@google.com + + + Alexey Melnikov + Isode Limited + 5 Castle Business Village, 36 Station Road, + Hampton, Middlesex, TW12 2BX, UK + + EMail: Alexey.Melnikov@isode.com + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Siemborski & Melnikov Standards Track [Page 19] + +RFC 4954 SMTP Service Extension for Authentication July 2007 + + +Full Copyright Statement + + Copyright (C) The IETF Trust (2007). + + This document is subject to the rights, licenses and restrictions + contained in BCP 78, and except as set forth therein, the authors + retain all their rights. + + This document and the information contained herein are provided on an + "AS IS" basis and THE CONTRIBUTOR, THE ORGANIZATION HE/SHE REPRESENTS + OR IS SPONSORED BY (IF ANY), THE INTERNET SOCIETY, THE IETF TRUST AND + THE INTERNET ENGINEERING TASK FORCE DISCLAIM ALL WARRANTIES, EXPRESS + OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF + THE INFORMATION HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED + WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + +Intellectual Property + + The IETF takes no position regarding the validity or scope of any + Intellectual Property Rights or other rights that might be claimed to + pertain to the implementation or use of the technology described in + this document or the extent to which any license under such rights + might or might not be available; nor does it represent that it has + made any independent effort to identify any such rights. Information + on the procedures with respect to rights in RFC documents can be + found in BCP 78 and BCP 79. + + Copies of IPR disclosures made to the IETF Secretariat and any + assurances of licenses to be made available, or the result of an + attempt made to obtain a general license or permission for the use of + such proprietary rights by implementers or users of this + specification can be obtained from the IETF on-line IPR repository at + http://www.ietf.org/ipr. + + The IETF invites any interested party to bring to its attention any + copyrights, patents or patent applications, or other proprietary + rights that may cover technology that may be required to implement + this standard. Please address the information to the IETF at + ietf-ipr@ietf.org. + +Acknowledgement + + Funding for the RFC Editor function is currently provided by the + Internet Society. + + + + + + + +Siemborski & Melnikov Standards Track [Page 20] + diff --git a/vendor/swiftmailer/swiftmailer/notes/rfc/rfc5751.txt b/vendor/swiftmailer/swiftmailer/notes/rfc/rfc5751.txt new file mode 100755 index 0000000..8d1dd21 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/notes/rfc/rfc5751.txt @@ -0,0 +1,2523 @@ + + + + + + +Internet Engineering Task Force (IETF) B. Ramsdell +Request for Comments: 5751 Brute Squad Labs +Obsoletes: 3851 S. Turner +Category: Standards Track IECA +ISSN: 2070-1721 January 2010 + + + Secure/Multipurpose Internet Mail Extensions (S/MIME) Version 3.2 + Message Specification + +Abstract + + This document defines Secure/Multipurpose Internet Mail Extensions + (S/MIME) version 3.2. S/MIME provides a consistent way to send and + receive secure MIME data. Digital signatures provide authentication, + message integrity, and non-repudiation with proof of origin. + Encryption provides data confidentiality. Compression can be used to + reduce data size. This document obsoletes RFC 3851. + +Status of This Memo + + This is an Internet Standards Track document. + + This document is a product of the Internet Engineering Task Force + (IETF). It represents the consensus of the IETF community. It has + received public review and has been approved for publication by + the Internet Engineering Steering Group (IESG). Further + information on Internet Standards is available in Section 2 of + RFC 5741. + + Information about the current status of this document, any + errata, and how to provide feedback on it may be obtained at + http://www.rfc-editor.org/info/rfc5751. + + + + + + + + + + + + + + + + + + +Ramsdell & Turner Standards Track [Page 1] + +RFC 5751 S/MIME 3.2 Message Specification January 2010 + + +Copyright Notice + + Copyright (c) 2010 IETF Trust and the persons identified as the + document authors. All rights reserved. + + This document is subject to BCP 78 and the IETF Trust's Legal + Provisions Relating to IETF Documents + (http://trustee.ietf.org/license-info) in effect on the date of + publication of this document. Please review these documents + carefully, as they describe your rights and restrictions with respect + to this document. Code Components extracted from this document must + include Simplified BSD License text as described in Section 4.e of + the Trust Legal Provisions and are provided without warranty as + described in the Simplified BSD License. + + This document may contain material from IETF Documents or IETF + Contributions published or made publicly available before November + 10, 2008. The person(s) controlling the copyright in some of this + material may not have granted the IETF Trust the right to allow + modifications of such material outside the IETF Standards Process. + Without obtaining an adequate license from the person(s) controlling + the copyright in such materials, this document may not be modified + outside the IETF Standards Process, and derivative works of it may + not be created outside the IETF Standards Process, except to format + it for publication as an RFC or to translate it into languages other + than English. + + + + + + + + + + + + + + + + + + + + + + + + + +Ramsdell & Turner Standards Track [Page 2] + +RFC 5751 S/MIME 3.2 Message Specification January 2010 + + +Table of Contents + + 1. Introduction ....................................................4 + 1.1. Specification Overview .....................................4 + 1.2. Definitions ................................................5 + 1.3. Conventions Used in This Document ..........................6 + 1.4. Compatibility with Prior Practice of S/MIME ................7 + 1.5. Changes from S/MIME v3 to S/MIME v3.1 ......................7 + 1.6. Changes since S/MIME v3.1 ..................................7 + 2. CMS Options .....................................................9 + 2.1. DigestAlgorithmIdentifier ..................................9 + 2.2. SignatureAlgorithmIdentifier ...............................9 + 2.3. KeyEncryptionAlgorithmIdentifier ..........................10 + 2.4. General Syntax ............................................11 + 2.5. Attributes and the SignerInfo Type ........................12 + 2.6. SignerIdentifier SignerInfo Type ..........................16 + 2.7. ContentEncryptionAlgorithmIdentifier ......................16 + 3. Creating S/MIME Messages .......................................18 + 3.1. Preparing the MIME Entity for Signing, Enveloping, + or Compressing ............................................19 + 3.2. The application/pkcs7-mime Media Type .....................23 + 3.3. Creating an Enveloped-Only Message ........................25 + 3.4. Creating a Signed-Only Message ............................26 + 3.5. Creating a Compressed-Only Message ........................30 + 3.6. Multiple Operations .......................................30 + 3.7. Creating a Certificate Management Message .................31 + 3.8. Registration Requests .....................................32 + 3.9. Identifying an S/MIME Message .............................32 + 4. Certificate Processing .........................................32 + 4.1. Key Pair Generation .......................................33 + 4.2. Signature Generation ......................................33 + 4.3. Signature Verification ....................................34 + 4.4. Encryption ................................................34 + 4.5. Decryption ................................................34 + 5. IANA Considerations ............................................34 + 5.1. Media Type for application/pkcs7-mime .....................34 + 5.2. Media Type for application/pkcs7-signature ................35 + 6. Security Considerations ........................................36 + 7. References .....................................................38 + 7.1. Reference Conventions .....................................38 + 7.2. Normative References ......................................39 + 7.3. Informative References ....................................41 + Appendix A. ASN.1 Module ..........................................43 + Appendix B. Moving S/MIME v2 Message Specification to Historic + Status ................................................45 + Appendix C. Acknowledgments .......................................45 + + + + + +Ramsdell & Turner Standards Track [Page 3] + +RFC 5751 S/MIME 3.2 Message Specification January 2010 + + +1. Introduction + + S/MIME (Secure/Multipurpose Internet Mail Extensions) provides a + consistent way to send and receive secure MIME data. Based on the + popular Internet MIME standard, S/MIME provides the following + cryptographic security services for electronic messaging + applications: authentication, message integrity and non-repudiation + of origin (using digital signatures), and data confidentiality (using + encryption). As a supplementary service, S/MIME provides for message + compression. + + S/MIME can be used by traditional mail user agents (MUAs) to add + cryptographic security services to mail that is sent, and to + interpret cryptographic security services in mail that is received. + However, S/MIME is not restricted to mail; it can be used with any + transport mechanism that transports MIME data, such as HTTP or SIP. + As such, S/MIME takes advantage of the object-based features of MIME + and allows secure messages to be exchanged in mixed-transport + systems. + + Further, S/MIME can be used in automated message transfer agents that + use cryptographic security services that do not require any human + intervention, such as the signing of software-generated documents and + the encryption of FAX messages sent over the Internet. + +1.1. Specification Overview + + This document describes a protocol for adding cryptographic signature + and encryption services to MIME data. The MIME standard [MIME-SPEC] + provides a general structure for the content of Internet messages and + allows extensions for new content-type-based applications. + + This specification defines how to create a MIME body part that has + been cryptographically enhanced according to the Cryptographic + Message Syntax (CMS) RFC 5652 [CMS], which is derived from PKCS #7 + [PKCS-7]. This specification also defines the application/pkcs7-mime + media type that can be used to transport those body parts. + + This document also discusses how to use the multipart/signed media + type defined in [MIME-SECURE] to transport S/MIME signed messages. + multipart/signed is used in conjunction with the application/pkcs7- + signature media type, which is used to transport a detached S/MIME + signature. + + + + + + + + +Ramsdell & Turner Standards Track [Page 4] + +RFC 5751 S/MIME 3.2 Message Specification January 2010 + + + In order to create S/MIME messages, an S/MIME agent MUST follow the + specifications in this document, as well as the specifications listed + in the Cryptographic Message Syntax document [CMS], [CMSALG], + [RSAPSS], [RSAOAEP], and [CMS-SHA2]. + + Throughout this specification, there are requirements and + recommendations made for how receiving agents handle incoming + messages. There are separate requirements and recommendations for + how sending agents create outgoing messages. In general, the best + strategy is to "be liberal in what you receive and conservative in + what you send". Most of the requirements are placed on the handling + of incoming messages, while the recommendations are mostly on the + creation of outgoing messages. + + The separation for requirements on receiving agents and sending + agents also derives from the likelihood that there will be S/MIME + systems that involve software other than traditional Internet mail + clients. S/MIME can be used with any system that transports MIME + data. An automated process that sends an encrypted message might not + be able to receive an encrypted message at all, for example. Thus, + the requirements and recommendations for the two types of agents are + listed separately when appropriate. + +1.2. Definitions + + For the purposes of this specification, the following definitions + apply. + + ASN.1: Abstract Syntax Notation One, as defined in ITU-T + Recommendation X.680 [X.680]. + + BER: Basic Encoding Rules for ASN.1, as defined in ITU- + T Recommendation X.690 [X.690]. + + Certificate: A type that binds an entity's name to a public key + with a digital signature. + + DER: Distinguished Encoding Rules for ASN.1, as defined + in ITU-T Recommendation X.690 [X.690]. + + 7-bit data: Text data with lines less than 998 characters + long, where none of the characters have the 8th + bit set, and there are no NULL characters. + and occur only as part of a end-of- + line delimiter. + + + + + + +Ramsdell & Turner Standards Track [Page 5] + +RFC 5751 S/MIME 3.2 Message Specification January 2010 + + + 8-bit data: Text data with lines less than 998 characters, and + where none of the characters are NULL characters. + and occur only as part of a + end-of-line delimiter. + + Binary data: Arbitrary data. + + Transfer encoding: A reversible transformation made on data so 8-bit + or binary data can be sent via a channel that only + transmits 7-bit data. + + Receiving agent: Software that interprets and processes S/MIME CMS + objects, MIME body parts that contain CMS content + types, or both. + + Sending agent: Software that creates S/MIME CMS content types, + MIME body parts that contain CMS content types, or + both. + + S/MIME agent: User software that is a receiving agent, a sending + agent, or both. + +1.3. Conventions Used in This Document + + The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", + "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this + document are to be interpreted as described in [MUSTSHOULD]. + + We define some additional terms here: + + SHOULD+ This term means the same as SHOULD. However, the authors + expect that a requirement marked as SHOULD+ will be + promoted at some future time to be a MUST. + + SHOULD- This term means the same as SHOULD. However, the authors + expect that a requirement marked as SHOULD- will be demoted + to a MAY in a future version of this document. + + MUST- This term means the same as MUST. However, the authors + expect that this requirement will no longer be a MUST in a + future document. Although its status will be determined at + a later time, it is reasonable to expect that if a future + revision of a document alters the status of a MUST- + requirement, it will remain at least a SHOULD or a SHOULD-. + + + + + + + +Ramsdell & Turner Standards Track [Page 6] + +RFC 5751 S/MIME 3.2 Message Specification January 2010 + + +1.4. Compatibility with Prior Practice of S/MIME + + S/MIME version 3.2 agents ought to attempt to have the greatest + interoperability possible with agents for prior versions of S/MIME. + S/MIME version 2 is described in RFC 2311 through RFC 2315 inclusive + [SMIMEv2], S/MIME version 3 is described in RFC 2630 through RFC 2634 + inclusive and RFC 5035 [SMIMEv3], and S/MIME version 3.1 is described + in RFC 3850, RFC 3851, RFC 3852, RFC 2634, and RFC 5035 [SMIMEv3.1]. + RFC 2311 also has historical information about the development of + S/MIME. + +1.5. Changes from S/MIME v3 to S/MIME v3.1 + + The RSA public key algorithm was changed to a MUST implement key + wrapping algorithm, and the Diffie-Hellman (DH) algorithm changed to + a SHOULD implement. + + The AES symmetric encryption algorithm has been included as a SHOULD + implement. + + The RSA public key algorithm was changed to a MUST implement + signature algorithm. + + Ambiguous language about the use of "empty" SignedData messages to + transmit certificates was clarified to reflect that transmission of + Certificate Revocation Lists is also allowed. + + The use of binary encoding for some MIME entities is now explicitly + discussed. + + Header protection through the use of the message/rfc822 media type + has been added. + + Use of the CompressedData CMS type is allowed, along with required + media type and file extension additions. + +1.6. Changes since S/MIME v3.1 + + Editorial changes, e.g., replaced "MIME type" with "media type", + content-type with Content-Type. + + Moved "Conventions Used in This Document" to Section 1.3. Added + definitions for SHOULD+, SHOULD-, and MUST-. + + Section 1.1 and Appendix A: Added references to RFCs for RSASSA-PSS, + RSAES-OAEP, and SHA2 CMS algorithms. Added CMS Multiple Signers + Clarification to CMS reference. + + + + +Ramsdell & Turner Standards Track [Page 7] + +RFC 5751 S/MIME 3.2 Message Specification January 2010 + + + Section 1.2: Updated references to ASN.1 to X.680 and BER and DER to + X.690. + + Section 1.4: Added references to S/MIME MSG 3.1 RFCs. + + Section 2.1 (digest algorithm): SHA-256 added as MUST, SHA-1 and MD5 + made SHOULD-. + + Section 2.2 (signature algorithms): RSA with SHA-256 added as MUST, + and DSA with SHA-256 added as SHOULD+, RSA with SHA-1, DSA with + SHA-1, and RSA with MD5 changed to SHOULD-, and RSASSA-PSS with + SHA-256 added as SHOULD+. Also added note about what S/MIME v3.1 + clients support. + + Section 2.3 (key encryption): DH changed to SHOULD-, and RSAES-OAEP + added as SHOULD+. Elaborated requirements for key wrap algorithm. + + Section 2.5.1: Added requirement that receiving agents MUST support + both GeneralizedTime and UTCTime. + + Section 2.5.2: Replaced reference "sha1WithRSAEncryption" with + "sha256WithRSAEncryption", "DES-3EDE-CBC" with "AES-128 CBC", and + deleted the RC5 example. + + Section 2.5.2.1: Deleted entire section (discussed deprecated RC2). + + Section 2.7, 2.7.1, Appendix A: references to RC2/40 removed. + + Section 2.7 (content encryption): AES-128 CBC added as MUST, AES-192 + and AES-256 CBC SHOULD+, tripleDES now SHOULD-. + + Section 2.7.1: Updated pointers from 2.7.2.1 through 2.7.2.4 to + 2.7.1.1 to 2.7.1.2. + + Section 3.1.1: Removed text about MIME character sets. + + Section 3.2.2 and 3.6: Replaced "encrypted" with "enveloped". Update + OID example to use AES-128 CBC oid. + + Section 3.4.3.2: Replace micalg parameter for SHA-1 with sha-1. + + Section 4: Updated reference to CERT v3.2. + + Section 4.1: Updated RSA and DSA key size discussion. Moved last + four sentences to security considerations. Updated reference to + randomness requirements for security. + + + + + +Ramsdell & Turner Standards Track [Page 8] + +RFC 5751 S/MIME 3.2 Message Specification January 2010 + + + Section 5: Added IANA registration templates to update media type + registry to point to this document as opposed to RFC 2311. + + Section 6: Updated security considerations. + + Section 7: Moved references from Appendix B to this section. Updated + references. Added informational references to SMIMEv2, SMIMEv3, and + SMIMEv3.1. + + Appendix B: Added Appendix B to move S/MIME v2 to Historic status. + +2. CMS Options + + CMS allows for a wide variety of options in content, attributes, and + algorithm support. This section puts forth a number of support + requirements and recommendations in order to achieve a base level of + interoperability among all S/MIME implementations. [CMSALG] and + [CMS-SHA2] provides additional details regarding the use of the + cryptographic algorithms. [ESS] provides additional details + regarding the use of additional attributes. + +2.1. DigestAlgorithmIdentifier + + Sending and receiving agents MUST support SHA-256 [CMS-SHA2] and + SHOULD- support SHA-1 [CMSALG]. Receiving agents SHOULD- support MD5 + [CMSALG] for the purpose of providing backward compatibility with + MD5-digested S/MIME v2 SignedData objects. + +2.2. SignatureAlgorithmIdentifier + + Receiving agents: + + - MUST support RSA with SHA-256. + + - SHOULD+ support DSA with SHA-256. + + - SHOULD+ support RSASSA-PSS with SHA-256. + + - SHOULD- support RSA with SHA-1. + + - SHOULD- support DSA with SHA-1. + + - SHOULD- support RSA with MD5. + + + + + + + + +Ramsdell & Turner Standards Track [Page 9] + +RFC 5751 S/MIME 3.2 Message Specification January 2010 + + + Sending agents: + + - MUST support RSA with SHA-256. + + - SHOULD+ support DSA with SHA-256. + + - SHOULD+ support RSASSA-PSS with SHA-256. + + - SHOULD- support RSA with SHA-1 or DSA with SHA-1. + + - SHOULD- support RSA with MD5. + + See Section 4.1 for information on key size and algorithm references. + + Note that S/MIME v3.1 clients support verifying id-dsa-with-sha1 and + rsaEncryption and might not implement sha256withRSAEncryption. Note + that S/MIME v3 clients might only implement signing or signature + verification using id-dsa-with-sha1, and might also use id-dsa as an + AlgorithmIdentifier in this field. Receiving clients SHOULD + recognize id-dsa as equivalent to id-dsa-with-sha1, and sending + clients MUST use id-dsa-with-sha1 if using that algorithm. Also note + that S/MIME v2 clients are only required to verify digital signatures + using the rsaEncryption algorithm with SHA-1 or MD5, and might not + implement id-dsa-with-sha1 or id-dsa at all. + +2.3. KeyEncryptionAlgorithmIdentifier + + Receiving and sending agents: + + - MUST support RSA Encryption, as specified in [CMSALG]. + + - SHOULD+ support RSAES-OAEP, as specified in [RSAOAEP]. + + - SHOULD- support DH ephemeral-static mode, as specified in + [CMSALG] and [SP800-57]. + + When DH ephemeral-static is used, a key wrap algorithm is also + specified in the KeyEncryptionAlgorithmIdentifier [CMS]. The + underlying encryption functions for the key wrap and content + encryption algorithm ([CMSALG] and [CMSAES]) and the key sizes for + the two algorithms MUST be the same (e.g., AES-128 key wrap algorithm + with AES-128 content encryption algorithm). As AES-128 CBC is the + mandatory-to-implement content encryption algorithm, the AES-128 key + wrap algorithm MUST also be supported when DH ephemeral-static is + used. + + + + + + +Ramsdell & Turner Standards Track [Page 10] + +RFC 5751 S/MIME 3.2 Message Specification January 2010 + + + Note that S/MIME v3.1 clients might only implement key encryption and + decryption using the rsaEncryption algorithm. Note that S/MIME v3 + clients might only implement key encryption and decryption using the + Diffie-Hellman algorithm. Also note that S/MIME v2 clients are only + capable of decrypting content-encryption keys using the rsaEncryption + algorithm. + +2.4. General Syntax + + There are several CMS content types. Of these, only the Data, + SignedData, EnvelopedData, and CompressedData content types are + currently used for S/MIME. + +2.4.1. Data Content Type + + Sending agents MUST use the id-data content type identifier to + identify the "inner" MIME message content. For example, when + applying a digital signature to MIME data, the CMS SignedData + encapContentInfo eContentType MUST include the id-data object + identifier and the media type MUST be stored in the SignedData + encapContentInfo eContent OCTET STRING (unless the sending agent is + using multipart/signed, in which case the eContent is absent, per + Section 3.4.3 of this document). As another example, when applying + encryption to MIME data, the CMS EnvelopedData encryptedContentInfo + contentType MUST include the id-data object identifier and the + encrypted MIME content MUST be stored in the EnvelopedData + encryptedContentInfo encryptedContent OCTET STRING. + +2.4.2. SignedData Content Type + + Sending agents MUST use the SignedData content type to apply a + digital signature to a message or, in a degenerate case where there + is no signature information, to convey certificates. Applying a + signature to a message provides authentication, message integrity, + and non-repudiation of origin. + +2.4.3. EnvelopedData Content Type + + This content type is used to apply data confidentiality to a message. + A sender needs to have access to a public key for each intended + message recipient to use this service. + +2.4.4. CompressedData Content Type + + This content type is used to apply data compression to a message. + This content type does not provide authentication, message integrity, + non-repudiation, or data confidentiality, and is only used to reduce + the message's size. + + + +Ramsdell & Turner Standards Track [Page 11] + +RFC 5751 S/MIME 3.2 Message Specification January 2010 + + + See Section 3.6 for further guidance on the use of this type in + conjunction with other CMS types. + +2.5. Attributes and the SignerInfo Type + + The SignerInfo type allows the inclusion of unsigned and signed + attributes along with a signature. + + Receiving agents MUST be able to handle zero or one instance of each + of the signed attributes listed here. Sending agents SHOULD generate + one instance of each of the following signed attributes in each + S/MIME message: + + - Signing Time (section (Section 2.5.1 in this document) + + - SMIME Capabilities (section (Section 2.5.2 in this document) + + - Encryption Key Preference (section (Section 2.5.3 in this + document) + + - Message Digest (section (Section 11.2 in [CMS]) + + - Content Type (section (Section 11.1 in [CMS]) + + Further, receiving agents SHOULD be able to handle zero or one + instance of the signingCertificate and signingCertificatev2 signed + attributes, as defined in Section 5 of RFC 2634 [ESS] and Section 3 + of RFC 5035 [ESS]. + + Sending agents SHOULD generate one instance of the signingCertificate + or signingCertificatev2 signed attribute in each SignerInfo + structure. + + Additional attributes and values for these attributes might be + defined in the future. Receiving agents SHOULD handle attributes or + values that they do not recognize in a graceful manner. + + Interactive sending agents that include signed attributes that are + not listed here SHOULD display those attributes to the user, so that + the user is aware of all of the data being signed. + +2.5.1. Signing Time Attribute + + The signing-time attribute is used to convey the time that a message + was signed. The time of signing will most likely be created by a + message originator and therefore is only as trustworthy as the + originator. + + + + +Ramsdell & Turner Standards Track [Page 12] + +RFC 5751 S/MIME 3.2 Message Specification January 2010 + + + Sending agents MUST encode signing time through the year 2049 as + UTCTime; signing times in 2050 or later MUST be encoded as + GeneralizedTime. When the UTCTime CHOICE is used, S/MIME agents MUST + interpret the year field (YY) as follows: + + If YY is greater than or equal to 50, the year is interpreted as + 19YY; if YY is less than 50, the year is interpreted as 20YY. + + Receiving agents MUST be able to process signing-time attributes that + are encoded in either UTCTime or GeneralizedTime. + +2.5.2. SMIME Capabilities Attribute + + The SMIMECapabilities attribute includes signature algorithms (such + as "sha256WithRSAEncryption"), symmetric algorithms (such as "AES-128 + CBC"), and key encipherment algorithms (such as "rsaEncryption"). + There are also several identifiers that indicate support for other + optional features such as binary encoding and compression. The + SMIMECapabilities were designed to be flexible and extensible so + that, in the future, a means of identifying other capabilities and + preferences such as certificates can be added in a way that will not + cause current clients to break. + + If present, the SMIMECapabilities attribute MUST be a + SignedAttribute; it MUST NOT be an UnsignedAttribute. CMS defines + SignedAttributes as a SET OF Attribute. The SignedAttributes in a + signerInfo MUST NOT include multiple instances of the + SMIMECapabilities attribute. CMS defines the ASN.1 syntax for + Attribute to include attrValues SET OF AttributeValue. A + SMIMECapabilities attribute MUST only include a single instance of + AttributeValue. There MUST NOT be zero or multiple instances of + AttributeValue present in the attrValues SET OF AttributeValue. + + The semantics of the SMIMECapabilities attribute specify a partial + list as to what the client announcing the SMIMECapabilities can + support. A client does not have to list every capability it + supports, and need not list all its capabilities so that the + capabilities list doesn't get too long. In an SMIMECapabilities + attribute, the object identifiers (OIDs) are listed in order of their + preference, but SHOULD be separated logically along the lines of + their categories (signature algorithms, symmetric algorithms, key + encipherment algorithms, etc.). + + The structure of the SMIMECapabilities attribute is to facilitate + simple table lookups and binary comparisons in order to determine + matches. For instance, the DER-encoding for the SMIMECapability for + AES-128 CBC MUST be identically encoded regardless of the + implementation. Because of the requirement for identical encoding, + + + +Ramsdell & Turner Standards Track [Page 13] + +RFC 5751 S/MIME 3.2 Message Specification January 2010 + + + individuals documenting algorithms to be used in the + SMIMECapabilities attribute SHOULD explicitly document the correct + byte sequence for the common cases. + + For any capability, the associated parameters for the OID MUST + specify all of the parameters necessary to differentiate between two + instances of the same algorithm. + + The OIDs that correspond to algorithms SHOULD use the same OID as the + actual algorithm, except in the case where the algorithm usage is + ambiguous from the OID. For instance, in an earlier specification, + rsaEncryption was ambiguous because it could refer to either a + signature algorithm or a key encipherment algorithm. In the event + that an OID is ambiguous, it needs to be arbitrated by the maintainer + of the registered SMIMECapabilities list as to which type of + algorithm will use the OID, and a new OID MUST be allocated under the + smimeCapabilities OID to satisfy the other use of the OID. + + The registered SMIMECapabilities list specifies the parameters for + OIDs that need them, most notably key lengths in the case of + variable-length symmetric ciphers. In the event that there are no + differentiating parameters for a particular OID, the parameters MUST + be omitted, and MUST NOT be encoded as NULL. Additional values for + the SMIMECapabilities attribute might be defined in the future. + Receiving agents MUST handle a SMIMECapabilities object that has + values that it does not recognize in a graceful manner. + + Section 2.7.1 explains a strategy for caching capabilities. + +2.5.3. Encryption Key Preference Attribute + + The encryption key preference attribute allows the signer to + unambiguously describe which of the signer's certificates has the + signer's preferred encryption key. This attribute is designed to + enhance behavior for interoperating with those clients that use + separate keys for encryption and signing. This attribute is used to + convey to anyone viewing the attribute which of the listed + certificates is appropriate for encrypting a session key for future + encrypted messages. + + If present, the SMIMEEncryptionKeyPreference attribute MUST be a + SignedAttribute; it MUST NOT be an UnsignedAttribute. CMS defines + SignedAttributes as a SET OF Attribute. The SignedAttributes in a + signerInfo MUST NOT include multiple instances of the + SMIMEEncryptionKeyPreference attribute. CMS defines the ASN.1 syntax + for Attribute to include attrValues SET OF AttributeValue. A + SMIMEEncryptionKeyPreference attribute MUST only include a single + + + + +Ramsdell & Turner Standards Track [Page 14] + +RFC 5751 S/MIME 3.2 Message Specification January 2010 + + + instance of AttributeValue. There MUST NOT be zero or multiple + instances of AttributeValue present in the attrValues SET OF + AttributeValue. + + The sending agent SHOULD include the referenced certificate in the + set of certificates included in the signed message if this attribute + is used. The certificate MAY be omitted if it has been previously + made available to the receiving agent. Sending agents SHOULD use + this attribute if the commonly used or preferred encryption + certificate is not the same as the certificate used to sign the + message. + + Receiving agents SHOULD store the preference data if the signature on + the message is valid and the signing time is greater than the + currently stored value. (As with the SMIMECapabilities, the clock + skew SHOULD be checked and the data not used if the skew is too + great.) Receiving agents SHOULD respect the sender's encryption key + preference attribute if possible. This, however, represents only a + preference and the receiving agent can use any certificate in + replying to the sender that is valid. + + Section 2.7.1 explains a strategy for caching preference data. + +2.5.3.1. Selection of Recipient Key Management Certificate + + In order to determine the key management certificate to be used when + sending a future CMS EnvelopedData message for a particular + recipient, the following steps SHOULD be followed: + + - If an SMIMEEncryptionKeyPreference attribute is found in a + SignedData object received from the desired recipient, this + identifies the X.509 certificate that SHOULD be used as the X.509 + key management certificate for the recipient. + + - If an SMIMEEncryptionKeyPreference attribute is not found in a + SignedData object received from the desired recipient, the set of + X.509 certificates SHOULD be searched for a X.509 certificate with + the same subject name as the signer of a X.509 certificate that can + be used for key management. + + - Or use some other method of determining the user's key management + key. If a X.509 key management certificate is not found, then + encryption cannot be done with the signer of the message. If + multiple X.509 key management certificates are found, the S/MIME + agent can make an arbitrary choice between them. + + + + + + +Ramsdell & Turner Standards Track [Page 15] + +RFC 5751 S/MIME 3.2 Message Specification January 2010 + + +2.6. SignerIdentifier SignerInfo Type + + S/MIME v3.2 implementations MUST support both issuerAndSerialNumber + and subjectKeyIdentifier. Messages that use the subjectKeyIdentifier + choice cannot be read by S/MIME v2 clients. + + It is important to understand that some certificates use a value for + subjectKeyIdentifier that is not suitable for uniquely identifying a + certificate. Implementations MUST be prepared for multiple + certificates for potentially different entities to have the same + value for subjectKeyIdentifier, and MUST be prepared to try each + matching certificate during signature verification before indicating + an error condition. + +2.7. ContentEncryptionAlgorithmIdentifier + + Sending and receiving agents: + + - MUST support encryption and decryption with AES-128 CBC + [CMSAES]. + + - SHOULD+ support encryption and decryption with AES-192 CBC and + AES-256 CBC [CMSAES]. + + - SHOULD- support encryption and decryption with DES EDE3 CBC, + hereinafter called "tripleDES" [CMSALG]. + +2.7.1. Deciding Which Encryption Method to Use + + When a sending agent creates an encrypted message, it has to decide + which type of encryption to use. The decision process involves using + information garnered from the capabilities lists included in messages + received from the recipient, as well as out-of-band information such + as private agreements, user preferences, legal restrictions, and so + on. + + Section 2.5.2 defines a method by which a sending agent can + optionally announce, among other things, its decrypting capabilities + in its order of preference. The following method for processing and + remembering the encryption capabilities attribute in incoming signed + messages SHOULD be used. + + - If the receiving agent has not yet created a list of + capabilities for the sender's public key, then, after verifying + the signature on the incoming message and checking the + timestamp, the receiving agent SHOULD create a new list + containing at least the signing time and the symmetric + capabilities. + + + +Ramsdell & Turner Standards Track [Page 16] + +RFC 5751 S/MIME 3.2 Message Specification January 2010 + + + - If such a list already exists, the receiving agent SHOULD verify + that the signing time in the incoming message is greater than + the signing time stored in the list and that the signature is + valid. If so, the receiving agent SHOULD update both the + signing time and capabilities in the list. Values of the + signing time that lie far in the future (that is, a greater + discrepancy than any reasonable clock skew), or a capabilities + list in messages whose signature could not be verified, MUST NOT + be accepted. + + The list of capabilities SHOULD be stored for future use in creating + messages. + + Before sending a message, the sending agent MUST decide whether it is + willing to use weak encryption for the particular data in the + message. If the sending agent decides that weak encryption is + unacceptable for this data, then the sending agent MUST NOT use a + weak algorithm. The decision to use or not use weak encryption + overrides any other decision in this section about which encryption + algorithm to use. + + Sections 2.7.1.1 through 2.7.1.2 describe the decisions a sending + agent SHOULD use in deciding which type of encryption will be applied + to a message. These rules are ordered, so the sending agent SHOULD + make its decision in the order given. + +2.7.1.1. Rule 1: Known Capabilities + + If the sending agent has received a set of capabilities from the + recipient for the message the agent is about to encrypt, then the + sending agent SHOULD use that information by selecting the first + capability in the list (that is, the capability most preferred by the + intended recipient) that the sending agent knows how to encrypt. The + sending agent SHOULD use one of the capabilities in the list if the + agent reasonably expects the recipient to be able to decrypt the + message. + +2.7.1.2. Rule 2: Unknown Capabilities, Unknown Version of S/MIME + + If the following two conditions are met: + + - the sending agent has no knowledge of the encryption + capabilities of the recipient, and + + - the sending agent has no knowledge of the version of S/MIME of + the recipient, + + + + + +Ramsdell & Turner Standards Track [Page 17] + +RFC 5751 S/MIME 3.2 Message Specification January 2010 + + + then the sending agent SHOULD use AES-128 because it is a stronger + algorithm and is required by S/MIME v3.2. If the sending agent + chooses not to use AES-128 in this step, it SHOULD use tripleDES. + +2.7.2. Choosing Weak Encryption + + All algorithms that use 40-bit keys are considered by many to be weak + encryption. A sending agent that is controlled by a human SHOULD + allow a human sender to determine the risks of sending data using a + weak encryption algorithm before sending the data, and possibly allow + the human to use a stronger encryption method such as tripleDES or + AES. + +2.7.3. Multiple Recipients + + If a sending agent is composing an encrypted message to a group of + recipients where the encryption capabilities of some of the + recipients do not overlap, the sending agent is forced to send more + than one message. Please note that if the sending agent chooses to + send a message encrypted with a strong algorithm, and then send the + same message encrypted with a weak algorithm, someone watching the + communications channel could learn the contents of the strongly + encrypted message simply by decrypting the weakly encrypted message. + +3. Creating S/MIME Messages + + This section describes the S/MIME message formats and how they are + created. S/MIME messages are a combination of MIME bodies and CMS + content types. Several media types as well as several CMS content + types are used. The data to be secured is always a canonical MIME + entity. The MIME entity and other data, such as certificates and + algorithm identifiers, are given to CMS processing facilities that + produce a CMS object. Finally, the CMS object is wrapped in MIME. + The Enhanced Security Services for S/MIME [ESS] document provides + descriptions of how nested, secured S/MIME messages are formatted. + ESS provides a description of how a triple-wrapped S/MIME message is + formatted using multipart/signed and application/pkcs7-mime for the + signatures. + + S/MIME provides one format for enveloped-only data, several formats + for signed-only data, and several formats for signed and enveloped + data. Several formats are required to accommodate several + environments, in particular for signed messages. The criteria for + choosing among these formats are also described. + + The reader of this section is expected to understand MIME as + described in [MIME-SPEC] and [MIME-SECURE]. + + + + +Ramsdell & Turner Standards Track [Page 18] + +RFC 5751 S/MIME 3.2 Message Specification January 2010 + + +3.1. Preparing the MIME Entity for Signing, Enveloping, or Compressing + + S/MIME is used to secure MIME entities. A MIME entity can be a sub- + part, sub-parts of a message, or the whole message with all its sub- + parts. A MIME entity that is the whole message includes only the + MIME message headers and MIME body, and does not include the RFC-822 + header. Note that S/MIME can also be used to secure MIME entities + used in applications other than Internet mail. If protection of the + RFC-822 header is required, the use of the message/rfc822 media type + is explained later in this section. + + The MIME entity that is secured and described in this section can be + thought of as the "inside" MIME entity. That is, it is the + "innermost" object in what is possibly a larger MIME message. + Processing "outside" MIME entities into CMS content types is + described in Sections 3.2, 3.4, and elsewhere. + + The procedure for preparing a MIME entity is given in [MIME-SPEC]. + The same procedure is used here with some additional restrictions + when signing. The description of the procedures from [MIME-SPEC] is + repeated here, but it is suggested that the reader refer to that + document for the exact procedure. This section also describes + additional requirements. + + A single procedure is used for creating MIME entities that are to + have any combination of signing, enveloping, and compressing applied. + Some additional steps are recommended to defend against known + corruptions that can occur during mail transport that are of + particular importance for clear-signing using the multipart/signed + format. It is recommended that these additional steps be performed + on enveloped messages, or signed and enveloped messages, so that the + message can be forwarded to any environment without modification. + + These steps are descriptive rather than prescriptive. The + implementer is free to use any procedure as long as the result is the + same. + + Step 1. The MIME entity is prepared according to the local + conventions. + + Step 2. The leaf parts of the MIME entity are converted to canonical + form. + + Step 3. Appropriate transfer encoding is applied to the leaves of + the MIME entity. + + + + + + +Ramsdell & Turner Standards Track [Page 19] + +RFC 5751 S/MIME 3.2 Message Specification January 2010 + + + When an S/MIME message is received, the security services on the + message are processed, and the result is the MIME entity. That MIME + entity is typically passed to a MIME-capable user agent where it is + further decoded and presented to the user or receiving application. + + In order to protect outer, non-content-related message header fields + (for instance, the "Subject", "To", "From", and "Cc" fields), the + sending client MAY wrap a full MIME message in a message/rfc822 + wrapper in order to apply S/MIME security services to these header + fields. It is up to the receiving client to decide how to present + this "inner" header along with the unprotected "outer" header. + + When an S/MIME message is received, if the top-level protected MIME + entity has a Content-Type of message/rfc822, it can be assumed that + the intent was to provide header protection. This entity SHOULD be + presented as the top-level message, taking into account header + merging issues as previously discussed. + +3.1.1. Canonicalization + + Each MIME entity MUST be converted to a canonical form that is + uniquely and unambiguously representable in the environment where the + signature is created and the environment where the signature will be + verified. MIME entities MUST be canonicalized for enveloping and + compressing as well as signing. + + The exact details of canonicalization depend on the actual media type + and subtype of an entity, and are not described here. Instead, the + standard for the particular media type SHOULD be consulted. For + example, canonicalization of type text/plain is different from + canonicalization of audio/basic. Other than text types, most types + have only one representation regardless of computing platform or + environment that can be considered their canonical representation. + In general, canonicalization will be performed by the non-security + part of the sending agent rather than the S/MIME implementation. + + The most common and important canonicalization is for text, which is + often represented differently in different environments. MIME + entities of major type "text" MUST have both their line endings and + character set canonicalized. The line ending MUST be the pair of + characters , and the charset SHOULD be a registered charset + [CHARSETS]. The details of the canonicalization are specified in + [MIME-SPEC]. + + Note that some charsets such as ISO-2022 have multiple + representations for the same characters. When preparing such text + for signing, the canonical representation specified for the charset + MUST be used. + + + +Ramsdell & Turner Standards Track [Page 20] + +RFC 5751 S/MIME 3.2 Message Specification January 2010 + + +3.1.2. Transfer Encoding + + When generating any of the secured MIME entities below, except the + signing using the multipart/signed format, no transfer encoding is + required at all. S/MIME implementations MUST be able to deal with + binary MIME objects. If no Content-Transfer-Encoding header field is + present, the transfer encoding is presumed to be 7BIT. + + S/MIME implementations SHOULD however use transfer encoding described + in Section 3.1.3 for all MIME entities they secure. The reason for + securing only 7-bit MIME entities, even for enveloped data that are + not exposed to the transport, is that it allows the MIME entity to be + handled in any environment without changing it. For example, a + trusted gateway might remove the envelope, but not the signature, of + a message, and then forward the signed message on to the end + recipient so that they can verify the signatures directly. If the + transport internal to the site is not 8-bit clean, such as on a wide- + area network with a single mail gateway, verifying the signature will + not be possible unless the original MIME entity was only 7-bit data. + + S/MIME implementations that "know" that all intended recipients are + capable of handling inner (all but the outermost) binary MIME objects + SHOULD use binary encoding as opposed to a 7-bit-safe transfer + encoding for the inner entities. The use of a 7-bit-safe encoding + (such as base64) would unnecessarily expand the message size. + Implementations MAY "know" that recipient implementations are capable + of handling inner binary MIME entities either by interpreting the id- + cap-preferBinaryInside SMIMECapabilities attribute, by prior + agreement, or by other means. + + If one or more intended recipients are unable to handle inner binary + MIME objects, or if this capability is unknown for any of the + intended recipients, S/MIME implementations SHOULD use transfer + encoding described in Section 3.1.3 for all MIME entities they + secure. + +3.1.3. Transfer Encoding for Signing Using multipart/signed + + If a multipart/signed entity is ever to be transmitted over the + standard Internet SMTP infrastructure or other transport that is + constrained to 7-bit text, it MUST have transfer encoding applied so + that it is represented as 7-bit text. MIME entities that are 7-bit + data already need no transfer encoding. Entities such as 8-bit text + and binary data can be encoded with quoted-printable or base-64 + transfer encoding. + + + + + + +Ramsdell & Turner Standards Track [Page 21] + +RFC 5751 S/MIME 3.2 Message Specification January 2010 + + + The primary reason for the 7-bit requirement is that the Internet + mail transport infrastructure cannot guarantee transport of 8-bit or + binary data. Even though many segments of the transport + infrastructure now handle 8-bit and even binary data, it is sometimes + not possible to know whether the transport path is 8-bit clean. If a + mail message with 8-bit data were to encounter a message transfer + agent that cannot transmit 8-bit or binary data, the agent has three + options, none of which are acceptable for a clear-signed message: + + - The agent could change the transfer encoding; this would + invalidate the signature. + + - The agent could transmit the data anyway, which would most likely + result in the 8th bit being corrupted; this too would invalidate + the signature. + + - The agent could return the message to the sender. + + [MIME-SECURE] prohibits an agent from changing the transfer encoding + of the first part of a multipart/signed message. If a compliant + agent that cannot transmit 8-bit or binary data encounters a + multipart/signed message with 8-bit or binary data in the first part, + it would have to return the message to the sender as undeliverable. + +3.1.4. Sample Canonical MIME Entity + + This example shows a multipart/mixed message with full transfer + encoding. This message contains a text part and an attachment. The + sample message text includes characters that are not US-ASCII and + thus need to be transfer encoded. Though not shown here, the end of + each line is . The line ending of the MIME headers, the + text, and the transfer encoded parts, all MUST be . + + Note that this example is not of an S/MIME message. + + Content-Type: multipart/mixed; boundary=bar + + --bar + Content-Type: text/plain; charset=iso-8859-1 + Content-Transfer-Encoding: quoted-printable + + =A1Hola Michael! + + How do you like the new S/MIME specification? + + It's generally a good idea to encode lines that begin with + From=20because some mail transport agents will insert a greater- + than (>) sign, thus invalidating the signature. + + + +Ramsdell & Turner Standards Track [Page 22] + +RFC 5751 S/MIME 3.2 Message Specification January 2010 + + + Also, in some cases it might be desirable to encode any =20 + trailing whitespace that occurs on lines in order to ensure =20 + that the message signature is not invalidated when passing =20 + a gateway that modifies such whitespace (like BITNET). =20 + + --bar + Content-Type: image/jpeg + Content-Transfer-Encoding: base64 + + iQCVAwUBMJrRF2N9oWBghPDJAQE9UQQAtl7LuRVndBjrk4EqYBIb3h5QXIX/LC// + jJV5bNvkZIGPIcEmI5iFd9boEgvpirHtIREEqLQRkYNoBActFBZmh9GC3C041WGq + uMbrbxc+nIs1TIKlA08rVi9ig/2Yh7LFrK5Ein57U/W72vgSxLhe/zhdfolT9Brn + HOxEa44b+EI= + + --bar-- + +3.2. The application/pkcs7-mime Media Type + + The application/pkcs7-mime media type is used to carry CMS content + types including EnvelopedData, SignedData, and CompressedData. The + details of constructing these entities are described in subsequent + sections. This section describes the general characteristics of the + application/pkcs7-mime media type. + + The carried CMS object always contains a MIME entity that is prepared + as described in Section 3.1 if the eContentType is id-data. Other + contents MAY be carried when the eContentType contains different + values. See [ESS] for an example of this with signed receipts. + + Since CMS content types are binary data, in most cases base-64 + transfer encoding is appropriate, in particular, when used with SMTP + transport. The transfer encoding used depends on the transport + through which the object is to be sent, and is not a characteristic + of the media type. + + Note that this discussion refers to the transfer encoding of the CMS + object or "outside" MIME entity. It is completely distinct from, and + unrelated to, the transfer encoding of the MIME entity secured by the + CMS object, the "inside" object, which is described in Section 3.1. + + Because there are several types of application/pkcs7-mime objects, a + sending agent SHOULD do as much as possible to help a receiving agent + know about the contents of the object without forcing the receiving + agent to decode the ASN.1 for the object. The Content-Type header + field of all application/pkcs7-mime objects SHOULD include the + optional "smime-type" parameter, as described in the following + sections. + + + + +Ramsdell & Turner Standards Track [Page 23] + +RFC 5751 S/MIME 3.2 Message Specification January 2010 + + +3.2.1. The name and filename Parameters + + For the application/pkcs7-mime, sending agents SHOULD emit the + optional "name" parameter to the Content-Type field for compatibility + with older systems. Sending agents SHOULD also emit the optional + Content-Disposition field [CONTDISP] with the "filename" parameter. + If a sending agent emits the above parameters, the value of the + parameters SHOULD be a file name with the appropriate extension: + + Media Type File Extension + application/pkcs7-mime (SignedData, EnvelopedData) .p7m + application/pkcs7-mime (degenerate SignedData .p7c + certificate management message) + application/pkcs7-mime (CompressedData) .p7z + application/pkcs7-signature (SignedData) .p7s + + In addition, the file name SHOULD be limited to eight characters + followed by a three-letter extension. The eight-character filename + base can be any distinct name; the use of the filename base "smime" + SHOULD be used to indicate that the MIME entity is associated with + S/MIME. + + Including a file name serves two purposes. It facilitates easier use + of S/MIME objects as files on disk. It also can convey type + information across gateways. When a MIME entity of type + application/pkcs7-mime (for example) arrives at a gateway that has no + special knowledge of S/MIME, it will default the entity's media type + to application/octet-stream and treat it as a generic attachment, + thus losing the type information. However, the suggested filename + for an attachment is often carried across a gateway. This often + allows the receiving systems to determine the appropriate application + to hand the attachment off to, in this case, a stand-alone S/MIME + processing application. Note that this mechanism is provided as a + convenience for implementations in certain environments. A proper + S/MIME implementation MUST use the media types and MUST NOT rely on + the file extensions. + +3.2.2. The smime-type Parameter + + The application/pkcs7-mime content type defines the optional "smime- + type" parameter. The intent of this parameter is to convey details + about the security applied (signed or enveloped) along with + information about the contained content. This specification defines + the following smime-types. + + + + + + + +Ramsdell & Turner Standards Track [Page 24] + +RFC 5751 S/MIME 3.2 Message Specification January 2010 + + + Name CMS Type Inner Content + enveloped-data EnvelopedData id-data + signed-data SignedData id-data + certs-only SignedData none + compressed-data CompressedData id-data + + In order for consistency to be obtained with future specifications, + the following guidelines SHOULD be followed when assigning a new + smime-type parameter. + + 1. If both signing and encryption can be applied to the content, + then two values for smime-type SHOULD be assigned "signed-*" + and "enveloped-*". If one operation can be assigned, then this + can be omitted. Thus, since "certs-only" can only be signed, + "signed-" is omitted. + + 2. A common string for a content OID SHOULD be assigned. We use + "data" for the id-data content OID when MIME is the inner + content. + + 3. If no common string is assigned, then the common string of + "OID." is recommended (for example, + "OID.2.16.840.1.101.3.4.1.2" would be AES-128 CBC). + + It is explicitly intended that this field be a suitable hint for mail + client applications to indicate whether a message is "signed" or + "enveloped" without having to tunnel into the CMS payload. + +3.3. Creating an Enveloped-Only Message + + This section describes the format for enveloping a MIME entity + without signing it. It is important to note that sending enveloped + but not signed messages does not provide for data integrity. It is + possible to replace ciphertext in such a way that the processed + message will still be valid, but the meaning can be altered. + + Step 1. The MIME entity to be enveloped is prepared according to + Section 3.1. + + Step 2. The MIME entity and other required data is processed into a + CMS object of type EnvelopedData. In addition to encrypting + a copy of the content-encryption key for each recipient, a + copy of the content-encryption key SHOULD be encrypted for + the originator and included in the EnvelopedData (see [CMS], + Section 6). + + Step 3. The EnvelopedData object is wrapped in a CMS ContentInfo + object. + + + +Ramsdell & Turner Standards Track [Page 25] + +RFC 5751 S/MIME 3.2 Message Specification January 2010 + + + Step 4. The ContentInfo object is inserted into an + application/pkcs7-mime MIME entity. + + The smime-type parameter for enveloped-only messages is "enveloped- + data". The file extension for this type of message is ".p7m". + + A sample message would be: + + Content-Type: application/pkcs7-mime; smime-type=enveloped-data; + name=smime.p7m + Content-Transfer-Encoding: base64 + Content-Disposition: attachment; filename=smime.p7m + + rfvbnj756tbBghyHhHUujhJhjH77n8HHGT9HG4VQpfyF467GhIGfHfYT6 + 7n8HHGghyHhHUujhJh4VQpfyF467GhIGfHfYGTrfvbnjT6jH7756tbB9H + f8HHGTrfvhJhjH776tbB9HG4VQbnj7567GhIGfHfYT6ghyHhHUujpfyF4 + 0GhIGfHfQbnj756YT64V + +3.4. Creating a Signed-Only Message + + There are two formats for signed messages defined for S/MIME: + + - application/pkcs7-mime with SignedData. + + - multipart/signed. + + In general, the multipart/signed form is preferred for sending, and + receiving agents MUST be able to handle both. + +3.4.1. Choosing a Format for Signed-Only Messages + + There are no hard-and-fast rules as to when a particular signed-only + format is chosen. It depends on the capabilities of all the + receivers and the relative importance of receivers with S/MIME + facilities being able to verify the signature versus the importance + of receivers without S/MIME software being able to view the message. + + Messages signed using the multipart/signed format can always be + viewed by the receiver whether or not they have S/MIME software. + They can also be viewed whether they are using a MIME-native user + agent or they have messages translated by a gateway. In this + context, "be viewed" means the ability to process the message + essentially as if it were not a signed message, including any other + MIME structure the message might have. + + + + + + + +Ramsdell & Turner Standards Track [Page 26] + +RFC 5751 S/MIME 3.2 Message Specification January 2010 + + + Messages signed using the SignedData format cannot be viewed by a + recipient unless they have S/MIME facilities. However, the + SignedData format protects the message content from being changed by + benign intermediate agents. Such agents might do line wrapping or + content-transfer encoding changes that would break the signature. + +3.4.2. Signing Using application/pkcs7-mime with SignedData + + This signing format uses the application/pkcs7-mime media type. The + steps to create this format are: + + Step 1. The MIME entity is prepared according to Section 3.1. + + Step 2. The MIME entity and other required data are processed into a + CMS object of type SignedData. + + Step 3. The SignedData object is wrapped in a CMS ContentInfo + object. + + Step 4. The ContentInfo object is inserted into an + application/pkcs7-mime MIME entity. + + The smime-type parameter for messages using application/pkcs7-mime + with SignedData is "signed-data". The file extension for this type + of message is ".p7m". + + A sample message would be: + + Content-Type: application/pkcs7-mime; smime-type=signed-data; + name=smime.p7m + Content-Transfer-Encoding: base64 + Content-Disposition: attachment; filename=smime.p7m + + 567GhIGfHfYT6ghyHhHUujpfyF4f8HHGTrfvhJhjH776tbB9HG4VQbnj7 + 77n8HHGT9HG4VQpfyF467GhIGfHfYT6rfvbnj756tbBghyHhHUujhJhjH + HUujhJh4VQpfyF467GhIGfHfYGTrfvbnjT6jH7756tbB9H7n8HHGghyHh + 6YT64V0GhIGfHfQbnj75 + +3.4.3. Signing Using the multipart/signed Format + + This format is a clear-signing format. Recipients without any S/MIME + or CMS processing facilities are able to view the message. It makes + use of the multipart/signed media type described in [MIME-SECURE]. + The multipart/signed media type has two parts. The first part + contains the MIME entity that is signed; the second part contains the + "detached signature" CMS SignedData object in which the + encapContentInfo eContent field is absent. + + + + +Ramsdell & Turner Standards Track [Page 27] + +RFC 5751 S/MIME 3.2 Message Specification January 2010 + + +3.4.3.1. The application/pkcs7-signature Media Type + + This media type always contains a CMS ContentInfo containing a single + CMS object of type SignedData. The SignedData encapContentInfo + eContent field MUST be absent. The signerInfos field contains the + signatures for the MIME entity. + + The file extension for signed-only messages using application/pkcs7- + signature is ".p7s". + +3.4.3.2. Creating a multipart/signed Message + + Step 1. The MIME entity to be signed is prepared according to + Section 3.1, taking special care for clear-signing. + + Step 2. The MIME entity is presented to CMS processing in order to + obtain an object of type SignedData in which the + encapContentInfo eContent field is absent. + + Step 3. The MIME entity is inserted into the first part of a + multipart/signed message with no processing other than that + described in Section 3.1. + + Step 4. Transfer encoding is applied to the "detached signature" CMS + SignedData object, and it is inserted into a MIME entity of + type application/pkcs7-signature. + + Step 5. The MIME entity of the application/pkcs7-signature is + inserted into the second part of the multipart/signed + entity. + + The multipart/signed Content-Type has two required parameters: the + protocol parameter and the micalg parameter. + + The protocol parameter MUST be "application/pkcs7-signature". Note + that quotation marks are required around the protocol parameter + because MIME requires that the "/" character in the parameter value + MUST be quoted. + + The micalg parameter allows for one-pass processing when the + signature is being verified. The value of the micalg parameter is + dependent on the message digest algorithm(s) used in the calculation + of the Message Integrity Check. If multiple message digest + algorithms are used, they MUST be separated by commas per [MIME- + SECURE]. The values to be placed in the micalg parameter SHOULD be + from the following: + + + + + +Ramsdell & Turner Standards Track [Page 28] + +RFC 5751 S/MIME 3.2 Message Specification January 2010 + + + Algorithm Value Used + + MD5 md5 + SHA-1 sha-1 + SHA-224 sha-224 + SHA-256 sha-256 + SHA-384 sha-384 + SHA-512 sha-512 + Any other (defined separately in algorithm profile or "unknown" + if not defined) + + (Historical note: some early implementations of S/MIME emitted and + expected "rsa-md5", "rsa-sha1", and "sha1" for the micalg parameter.) + Receiving agents SHOULD be able to recover gracefully from a micalg + parameter value that they do not recognize. Future names for this + parameter will be consistent with the IANA "Hash Function Textual + Names" registry. + +3.4.3.3. Sample multipart/signed Message + + Content-Type: multipart/signed; + protocol="application/pkcs7-signature"; + micalg=sha1; boundary=boundary42 + + --boundary42 + Content-Type: text/plain + + This is a clear-signed message. + + --boundary42 + Content-Type: application/pkcs7-signature; name=smime.p7s + Content-Transfer-Encoding: base64 + Content-Disposition: attachment; filename=smime.p7s + + ghyHhHUujhJhjH77n8HHGTrfvbnj756tbB9HG4VQpfyF467GhIGfHfYT6 + 4VQpfyF467GhIGfHfYT6jH77n8HHGghyHhHUujhJh756tbB9HGTrfvbnj + n8HHGTrfvhJhjH776tbB9HG4VQbnj7567GhIGfHfYT6ghyHhHUujpfyF4 + 7GhIGfHfYT64VQbnj756 + + --boundary42-- + + The content that is digested (the first part of the multipart/signed) + consists of the bytes: + + 43 6f 6e 74 65 6e 74 2d 54 79 70 65 3a 20 74 65 78 74 2f 70 6c 61 69 + 6e 0d 0a 0d 0a 54 68 69 73 20 69 73 20 61 20 63 6c 65 61 72 2d 73 69 + 67 6e 65 64 20 6d 65 73 73 61 67 65 2e 0d 0a + + + + +Ramsdell & Turner Standards Track [Page 29] + +RFC 5751 S/MIME 3.2 Message Specification January 2010 + + +3.5. Creating a Compressed-Only Message + + This section describes the format for compressing a MIME entity. + Please note that versions of S/MIME prior to version 3.1 did not + specify any use of CompressedData, and will not recognize it. The + use of a capability to indicate the ability to receive CompressedData + is described in [CMSCOMPR] and is the preferred method for + compatibility. + + Step 1. The MIME entity to be compressed is prepared according to + Section 3.1. + + Step 2. The MIME entity and other required data are processed into a + CMS object of type CompressedData. + + Step 3. The CompressedData object is wrapped in a CMS ContentInfo + object. + + Step 4. The ContentInfo object is inserted into an + application/pkcs7-mime MIME entity. + + The smime-type parameter for compressed-only messages is "compressed- + data". The file extension for this type of message is ".p7z". + + A sample message would be: + + Content-Type: application/pkcs7-mime; smime-type=compressed-data; + name=smime.p7z + Content-Transfer-Encoding: base64 + Content-Disposition: attachment; filename=smime.p7z + + rfvbnj756tbBghyHhHUujhJhjH77n8HHGT9HG4VQpfyF467GhIGfHfYT6 + 7n8HHGghyHhHUujhJh4VQpfyF467GhIGfHfYGTrfvbnjT6jH7756tbB9H + f8HHGTrfvhJhjH776tbB9HG4VQbnj7567GhIGfHfYT6ghyHhHUujpfyF4 + 0GhIGfHfQbnj756YT64V + +3.6. Multiple Operations + + The signed-only, enveloped-only, and compressed-only MIME formats can + be nested. This works because these formats are all MIME entities + that encapsulate other MIME entities. + + An S/MIME implementation MUST be able to receive and process + arbitrarily nested S/MIME within reasonable resource limits of the + recipient computer. + + + + + + +Ramsdell & Turner Standards Track [Page 30] + +RFC 5751 S/MIME 3.2 Message Specification January 2010 + + + It is possible to apply any of the signing, encrypting, and + compressing operations in any order. It is up to the implementer and + the user to choose. When signing first, the signatories are then + securely obscured by the enveloping. When enveloping first the + signatories are exposed, but it is possible to verify signatures + without removing the enveloping. This can be useful in an + environment where automatic signature verification is desired, as no + private key material is required to verify a signature. + + There are security ramifications to choosing whether to sign first or + encrypt first. A recipient of a message that is encrypted and then + signed can validate that the encrypted block was unaltered, but + cannot determine any relationship between the signer and the + unencrypted contents of the message. A recipient of a message that + is signed then encrypted can assume that the signed message itself + has not been altered, but that a careful attacker could have changed + the unauthenticated portions of the encrypted message. + + When using compression, keep the following guidelines in mind: + + - Compression of binary encoded encrypted data is discouraged, + since it will not yield significant compression. Base64 + encrypted data could very well benefit, however. + + - If a lossy compression algorithm is used with signing, you will + need to compress first, then sign. + +3.7. Creating a Certificate Management Message + + The certificate management message or MIME entity is used to + transport certificates and/or Certificate Revocation Lists, such as + in response to a registration request. + + Step 1. The certificates and/or Certificate Revocation Lists are + made available to the CMS generating process that creates a + CMS object of type SignedData. The SignedData + encapContentInfo eContent field MUST be absent and + signerInfos field MUST be empty. + + Step 2. The SignedData object is wrapped in a CMS ContentInfo + object. + + Step 3. The ContentInfo object is enclosed in an + application/pkcs7-mime MIME entity. + + The smime-type parameter for a certificate management message is + "certs-only". The file extension for this type of message is ".p7c". + + + + +Ramsdell & Turner Standards Track [Page 31] + +RFC 5751 S/MIME 3.2 Message Specification January 2010 + + +3.8. Registration Requests + + A sending agent that signs messages MUST have a certificate for the + signature so that a receiving agent can verify the signature. There + are many ways of getting certificates, such as through an exchange + with a certification authority, through a hardware token or diskette, + and so on. + + S/MIME v2 [SMIMEv2] specified a method for "registering" public keys + with certificate authorities using an application/pkcs10 body part. + Since that time, the IETF PKIX Working Group has developed other + methods for requesting certificates. However, S/MIME v3.2 does not + require a particular certificate request mechanism. + +3.9. Identifying an S/MIME Message + + Because S/MIME takes into account interoperation in non-MIME + environments, several different mechanisms are employed to carry the + type information, and it becomes a bit difficult to identify S/MIME + messages. The following table lists criteria for determining whether + or not a message is an S/MIME message. A message is considered an + S/MIME message if it matches any of the criteria listed below. + + The file suffix in the table below comes from the "name" parameter in + the Content-Type header field, or the "filename" parameter on the + Content-Disposition header field. These parameters that give the + file suffix are not listed below as part of the parameter section. + + Media type: application/pkcs7-mime + parameters: any + file suffix: any + + Media type: multipart/signed + parameters: protocol="application/pkcs7-signature" + file suffix: any + + Media type: application/octet-stream + parameters: any + file suffix: p7m, p7s, p7c, p7z + +4. Certificate Processing + + A receiving agent MUST provide some certificate retrieval mechanism + in order to gain access to certificates for recipients of digital + envelopes. This specification does not cover how S/MIME agents + handle certificates, only what they do after a certificate has been + validated or rejected. S/MIME certificate issues are covered in + [CERT32]. + + + +Ramsdell & Turner Standards Track [Page 32] + +RFC 5751 S/MIME 3.2 Message Specification January 2010 + + + At a minimum, for initial S/MIME deployment, a user agent could + automatically generate a message to an intended recipient requesting + that recipient's certificate in a signed return message. Receiving + and sending agents SHOULD also provide a mechanism to allow a user to + "store and protect" certificates for correspondents in such a way so + as to guarantee their later retrieval. + +4.1. Key Pair Generation + + All generated key pairs MUST be generated from a good source of non- + deterministic random input [RANDOM] and the private key MUST be + protected in a secure fashion. + + An S/MIME user agent MUST NOT generate asymmetric keys less than 512 + bits for use with the RSA or DSA signature algorithms. + + For 512-bit RSA with SHA-1 see [CMSALG] and [FIPS186-2] without + Change Notice 1, for 512-bit RSA with SHA-256 see [CMS-SHA2] and + [FIPS186-2] without Change Notice 1, and for 1024-bit through + 2048-bit RSA with SHA-256 see [CMS-SHA2] and [FIPS186-2] with Change + Notice 1. The first reference provides the signature algorithm's + object identifier, and the second provides the signature algorithm's + definition. + + For 512-bit DSA with SHA-1 see [CMSALG] and [FIPS186-2] without + Change Notice 1, for 512-bit DSA with SHA-256 see [CMS-SHA2] and + [FIPS186-2] without Change Notice 1, for 1024-bit DSA with SHA-1 see + [CMSALG] and [FIPS186-2] with Change Notice 1, for 1024-bit and above + DSA with SHA-256 see [CMS-SHA2] and [FIPS186-3]. The first reference + provides the signature algorithm's object identifier and the second + provides the signature algorithm's definition. + + For RSASSA-PSS with SHA-256, see [RSAPSS]. For 1024-bit DH, see + [CMSALG]. For 1024-bit and larger DH, see [SP800-56A]; regardless, + use the KDF, which is from X9.42, specified in [CMSALG]. For RSAES- + OAEP, see [RSAOAEP]. + +4.2. Signature Generation + + The following are the requirements for an S/MIME agent generated RSA, + RSASSA-PSS, and DSA signatures: + + key size <= 1023 : SHOULD NOT (see Security Considerations) + 1024 <= key size <= 2048 : SHOULD (see Security Considerations) + 2048 < key size : MAY (see Security Considerations) + + + + + + +Ramsdell & Turner Standards Track [Page 33] + +RFC 5751 S/MIME 3.2 Message Specification January 2010 + + +4.3. Signature Verification + + The following are the requirements for S/MIME receiving agents during + signature verification of RSA, RSASSA-PSS, and DSA signatures: + + key size <= 1023 : MAY (see Security Considerations) + 1024 <= key size <= 2048 : MUST (see Security Considerations) + 2048 < key size : MAY (see Security Considerations) + +4.4. Encryption + + The following are the requirements for an S/MIME agent when + establishing keys for content encryption using the RSA, RSA-OAEP, and + DH algorithms: + + key size <= 1023 : SHOULD NOT (see Security Considerations) + 1024 <= key size <= 2048 : SHOULD (see Security Considerations) + 2048 < key size : MAY (see Security Considerations) + +4.5. Decryption + + The following are the requirements for an S/MIME agent when + establishing keys for content decryption using the RSA, RSAES-OAEP, + and DH algorithms: + + key size <= 1023 : MAY (see Security Considerations) + 1024 <= key size <= 2048 : MUST (see Security Considerations) + 2048 < key size : MAY (see Security Considerations) + +5. IANA Considerations + + The following information updates the media type registration for + application/pkcs7-mime and application/pkcs7-signature to refer to + this document as opposed to RFC 2311. + + Note that other documents can define additional MIME media types for + S/MIME. + +5.1. Media Type for application/pkcs7-mime + + Type name: application + + Subtype Name: pkcs7-mime + + Required Parameters: NONE + + + + + + +Ramsdell & Turner Standards Track [Page 34] + +RFC 5751 S/MIME 3.2 Message Specification January 2010 + + + Optional Parameters: smime-type/signed-data + smime-type/enveloped-data + smime-type/compressed-data + smime-type/certs-only + name + + Encoding Considerations: See Section 3 of this document + + Security Considerations: See Section 6 of this document + + Interoperability Considerations: See Sections 1-6 of this document + + Published Specification: RFC 2311, RFC 2633, and this document + + Applications that use this media type: Security applications + + Additional information: NONE + + Person & email to contact for further information: + S/MIME working group chairs smime-chairs@tools.ietf.org + + Intended usage: COMMON + + Restrictions on usage: NONE + + Author: Sean Turner + + Change Controller: S/MIME working group delegated from the IESG + +5.2. Media Type for application/pkcs7-signature + + Type name: application + + Subtype Name: pkcs7-signature + + Required Parameters: NONE + + Optional Parameters: NONE + + Encoding Considerations: See Section 3 of this document + + Security Considerations: See Section 6 of this document + + Interoperability Considerations: See Sections 1-6 of this document + + Published Specification: RFC 2311, RFC 2633, and this document + + Applications that use this media type: Security applications + + + +Ramsdell & Turner Standards Track [Page 35] + +RFC 5751 S/MIME 3.2 Message Specification January 2010 + + + Additional information: NONE + + Person & email to contact for further information: + S/MIME working group chairs smime-chairs@tools.ietf.org + + Intended usage: COMMON + + Restrictions on usage: NONE + + Author: Sean Turner + + Change Controller: S/MIME working group delegated from the IESG + +6. Security Considerations + + Cryptographic algorithms will be broken or weakened over time. + Implementers and users need to check that the cryptographic + algorithms listed in this document continue to provide the expected + level of security. The IETF from time to time may issue documents + dealing with the current state of the art. For example: + + - The Million Message Attack described in RFC 3218 [MMA]. + + - The Diffie-Hellman "small-subgroup" attacks described in RFC + 2785 [DHSUB]. + + - The attacks against hash algorithms described in RFC 4270 [HASH- + ATTACK]. + + This specification uses Public-Key Cryptography technologies. It is + assumed that the private key is protected to ensure that it is not + accessed or altered by unauthorized parties. + + It is impossible for most people or software to estimate the value of + a message's content. Further, it is impossible for most people or + software to estimate the actual cost of recovering an encrypted + message content that is encrypted with a key of a particular size. + Further, it is quite difficult to determine the cost of a failed + decryption if a recipient cannot process a message's content. Thus, + choosing between different key sizes (or choosing whether to just use + plaintext) is also impossible for most people or software. However, + decisions based on these criteria are made all the time, and + therefore this specification gives a framework for using those + estimates in choosing algorithms. + + The choice of 2048 bits as the RSA asymmetric key size in this + specification is based on the desire to provide at least 100 bits of + security. The key sizes that must be supported to conform to this + + + +Ramsdell & Turner Standards Track [Page 36] + +RFC 5751 S/MIME 3.2 Message Specification January 2010 + + + specification seem appropriate for the Internet based on [STRENGTH]. + Of course, there are environments, such as financial and medical + systems, that may select different key sizes. For this reason, an + implementation MAY support key sizes beyond those recommended in this + specification. + + Receiving agents that validate signatures and sending agents that + encrypt messages need to be cautious of cryptographic processing + usage when validating signatures and encrypting messages using keys + larger than those mandated in this specification. An attacker could + send certificates with keys that would result in excessive + cryptographic processing, for example, keys larger than those + mandated in this specification, which could swamp the processing + element. Agents that use such keys without first validating the + certificate to a trust anchor are advised to have some sort of + cryptographic resource management system to prevent such attacks. + + Using weak cryptography in S/MIME offers little actual security over + sending plaintext. However, other features of S/MIME, such as the + specification of AES and the ability to announce stronger + cryptographic capabilities to parties with whom you communicate, + allow senders to create messages that use strong encryption. Using + weak cryptography is never recommended unless the only alternative is + no cryptography. + + RSA and DSA keys of less than 1024 bits are now considered by many + experts to be cryptographically insecure (due to advances in + computing power), and should no longer be used to protect messages. + Such keys were previously considered secure, so processing previously + received signed and encrypted mail will often result in the use of + weak keys. Implementations that wish to support previous versions of + S/MIME or process old messages need to consider the security risks + that result from smaller key sizes (e.g., spoofed messages) versus + the costs of denial of service. If an implementation supports + verification of digital signatures generated with RSA and DSA keys of + less than 1024 bits, it MUST warn the user. Implementers should + consider providing different warnings for newly received messages and + previously stored messages. Server implementations (e.g., secure + mail list servers) where user warnings are not appropriate SHOULD + reject messages with weak signatures. + + Implementers SHOULD be aware that multiple active key pairs can be + associated with a single individual. For example, one key pair can + be used to support confidentiality, while a different key pair can be + used for digital signatures. + + + + + + +Ramsdell & Turner Standards Track [Page 37] + +RFC 5751 S/MIME 3.2 Message Specification January 2010 + + + If a sending agent is sending the same message using different + strengths of cryptography, an attacker watching the communications + channel might be able to determine the contents of the strongly + encrypted message by decrypting the weakly encrypted version. In + other words, a sender SHOULD NOT send a copy of a message using + weaker cryptography than they would use for the original of the + message. + + Modification of the ciphertext can go undetected if authentication is + not also used, which is the case when sending EnvelopedData without + wrapping it in SignedData or enclosing SignedData within it. + + If an implementation is concerned about compliance with National + Institute of Standards and Technology (NIST) key size + recommendations, then see [SP800-57]. + + If messaging environments make use of the fact that a message is + signed to change the behavior of message processing (examples would + be running rules or UI display hints), without first verifying that + the message is actually signed and knowing the state of the + signature, this can lead to incorrect handling of the message. + Visual indicators on messages may need to have the signature + validation code checked periodically if the indicator is supposed to + give information on the current status of a message. + +7. References + +7.1. Reference Conventions + + [CMS] refers to [RFC5652]. + + [ESS] refers to [RFC2634] and [RFC5035]. + + [MIME] refers to [RFC2045], [RFC2046], [RFC2047], [RFC2049], + [RFC4288], and [RFC4289]. + + [SMIMEv2] refers to [RFC2311], [RFC2312], [RFC2313], [RFC2314], and + [RFC2315]. + + [SMIMEv3] refers to [RFC2630], [RFC2631], [RFC2632], [RFC2633], + [RFC2634], and [RFC5035]. + + [SMIMv3.1] refers to [RFC2634], [RFC3850], [RFC3851], [RFC3852], and + [RFC5035]. + + + + + + + +Ramsdell & Turner Standards Track [Page 38] + +RFC 5751 S/MIME 3.2 Message Specification January 2010 + + +7.2. Normative References + + [CERT32] Ramsdell, B. and S. Turner, "Secure/Multipurpose + Internet Mail Extensions (S/MIME) Version 3.2 + Certificate Handling", RFC 5750, January 2010. + + [CHARSETS] Character sets assigned by IANA. See + http://www.iana.org/assignments/character-sets. + + [CMSAES] Schaad, J., "Use of the Advanced Encryption Standard + (AES) Encryption Algorithm in Cryptographic Message + Syntax (CMS)", RFC 3565, July 2003. + + [CMSALG] Housley, R., "Cryptographic Message Syntax (CMS) + Algorithms", RFC 3370, August 2002. + + [CMSCOMPR] Gutmann, P., "Compressed Data Content Type for + Cryptographic Message Syntax (CMS)", RFC 3274, June + 2002. + + [CMS-SHA2] Turner, S., "Using SHA2 Algorithms with Cryptographic + Message Syntax", RFC 5754, January 2010. + + [CONTDISP] Troost, R., Dorner, S., and K. Moore, Ed., + "Communicating Presentation Information in Internet + Messages: The Content-Disposition Header Field", RFC + 2183, August 1997. + + [FIPS186-2] National Institute of Standards and Technology (NIST), + "Digital Signature Standard (DSS)", FIPS Publication + 186-2, January 2000. [With Change Notice 1]. + + [FIPS186-3] National Institute of Standards and Technology (NIST), + FIPS Publication 186-3: Digital Signature Standard, + June 2009. + + [MIME-SECURE] Galvin, J., Murphy, S., Crocker, S., and N. Freed, + "Security Multiparts for MIME: Multipart/Signed and + Multipart/Encrypted", RFC 1847, October 1995. + + [MUSTSHOULD] Bradner, S., "Key words for use in RFCs to Indicate + Requirement Levels", BCP 14, RFC 2119, March 1997. + + [RANDOM] Eastlake, D., 3rd, Schiller, J., and S. Crocker, + "Randomness Requirements for Security", BCP 106, RFC + 4086, June 2005. + + + + + +Ramsdell & Turner Standards Track [Page 39] + +RFC 5751 S/MIME 3.2 Message Specification January 2010 + + + [RFC2045] Freed, N. and N. Borenstein, "Multipurpose Internet + Mail Extensions (MIME) Part One: Format of Internet + Message Bodies", RFC 2045, November 1996. + + [RFC2046] Freed, N. and N. Borenstein, "Multipurpose Internet + Mail Extensions (MIME) Part Two: Media Types", RFC + 2046, November 1996. + + [RFC2047] Moore, K., "MIME (Multipurpose Internet Mail + Extensions) Part Three: Message Header Extensions for + Non-ASCII Text", RFC 2047, November 1996. + + [RFC2049] Freed, N. and N. Borenstein, "Multipurpose Internet + Mail Extensions (MIME) Part Five: Conformance Criteria + and Examples", RFC 2049, November 1996. + + [RFC2634] Hoffman, P. Ed., "Enhanced Security Services for + S/MIME", RFC 2634, June 1999. + + [RFC4288] Freed, N. and J. Klensin, "Media Type Specifications + and Registration Procedures", BCP 13, RFC 4288, + December 2005. + + [RFC4289] Freed, N. and J. Klensin, "Multipurpose Internet Mail + Extensions (MIME) Part Four: Registration Procedures", + BCP 13, RFC 4289, December 2005. + + [RFC5035] Schaad, J., "Enhanced Security Services (ESS) Update: + Adding CertID Algorithm Agility", RFC 5035, August + 2007. + + [RFC5652] Housley, R., "Cryptographic Message Syntax (CMS)", RFC + 5652, September 2009. + + [RSAOAEP] Housley, R. "Use of the RSAES-OAEP Key Transport + Algorithm in the Cryptographic Message Syntax (CMS)", + RFC 3560, July 2003. + + [RSAPSS] Schaad, J., "Use of the RSASSA-PSS Signature Algorithm + in Cryptographic Message Syntax (CMS)", RFC 4056, June + 2005. + + [SP800-56A] National Institute of Standards and Technology (NIST), + Special Publication 800-56A: Recommendation Pair-Wise + Key Establishment Schemes Using Discrete Logarithm + Cryptography (Revised), March 2007. + + + + + +Ramsdell & Turner Standards Track [Page 40] + +RFC 5751 S/MIME 3.2 Message Specification January 2010 + + + [X.680] ITU-T Recommendation X.680 (2002) | ISO/IEC + 8824-1:2002. Information Technology - Abstract Syntax + Notation One (ASN.1): Specification of basic notation. + + [X.690] ITU-T Recommendation X.690 (2002) | ISO/IEC + 8825-1:2002. Information Technology - ASN.1 encoding + rules: Specification of Basic Encoding Rules (BER), + Canonical Encoding Rules (CER) and Distinguished + Encoding Rules (DER). + +7.3. Informative References + + [DHSUB] Zuccherato, R., "Methods for Avoiding the "Small- + Subgroup" Attacks on the Diffie-Hellman Key Agreement + Method for S/MIME", RFC 2785, March 2000. + + [HASH-ATTACK] Hoffman, P. and B. Schneier, "Attacks on Cryptographic + Hashes in Internet Protocols", RFC 4270, November 2005. + + [MMA] Rescorla, E., "Preventing the Million Message Attack on + Cryptographic Message Syntax", RFC 3218, January 2002. + + [PKCS-7] Kaliski, B., "PKCS #7: Cryptographic Message Syntax + Version 1.5", RFC 2315, March 1998. + + [RFC2311] Dusse, S., Hoffman, P., Ramsdell, B., Lundblade, L., + and L. Repka, "S/MIME Version 2 Message Specification", + RFC 2311, March 1998. + + [RFC2312] Dusse, S., Hoffman, P., Ramsdell, B., and J. + Weinstein, "S/MIME Version 2 Certificate Handling", RFC + 2312, March 1998. + + [RFC2313] Kaliski, B., "PKCS #1: RSA Encryption Version 1.5", RFC + 2313, March 1998. + + [RFC2314] Kaliski, B., "PKCS #10: Certification Request Syntax + Version 1.5", RFC 2314, March 1998. + + [RFC2315] Kaliski, B., "PKCS #7: Certification Message Syntax + Version 1.5", RFC 2315, March 1998. + + [RFC2630] Housley, R., "Cryptographic Message Syntax", RFC 2630, + June 1999. + + [RFC2631] Rescorla, E., "Diffie-Hellman Key Agreement Method", + RFC 2631, June 1999. + + + + +Ramsdell & Turner Standards Track [Page 41] + +RFC 5751 S/MIME 3.2 Message Specification January 2010 + + + [RFC2632] Ramsdell, B., Ed., "S/MIME Version 3 Certificate + Handling", RFC 2632, June 1999. + + [RFC2633] Ramsdell, B., Ed., "S/MIME Version 3 Message + Specification", RFC 2633, June 1999. + + [RFC3850] Ramsdell, B., Ed., "Secure/Multipurpose Internet Mail + Extensions (S/MIME) Version 3.1 Certificate Handling", + RFC 3850, July 2004. + + [RFC3851] Ramsdell, B., Ed., "Secure/Multipurpose Internet Mail + Extensions (S/MIME) Version 3.1 Message Specification", + RFC 3851, July 2004. + + [RFC3852] Housley, R., "Cryptographic Message Syntax (CMS)", RFC + 3852, July 2004. + + [SP800-57] National Institute of Standards and Technology (NIST), + Special Publication 800-57: Recommendation for Key + Management, August 2005. + + [STRENGTH] Orman, H., and P. Hoffman, "Determining Strengths For + Public Keys Used For Exchanging Symmetric Keys", BCP + 86, RFC 3766, April 2004. + + + + + + + + + + + + + + + + + + + + + + + + + + + +Ramsdell & Turner Standards Track [Page 42] + +RFC 5751 S/MIME 3.2 Message Specification January 2010 + + +Appendix A. ASN.1 Module + + Note: The ASN.1 module contained herein is unchanged from RFC 3851 + [SMIMEv3.1] with the exception of a change to the prefersBinaryInside + ASN.1 comment. This module uses the 1988 version of ASN.1. + + SecureMimeMessageV3dot1 + + { iso(1) member-body(2) us(840) rsadsi(113549) + pkcs(1) pkcs-9(9) smime(16) modules(0) msg-v3dot1(21) } + + DEFINITIONS IMPLICIT TAGS ::= + + BEGIN + + IMPORTS + + -- Cryptographic Message Syntax [CMS] + SubjectKeyIdentifier, IssuerAndSerialNumber, + RecipientKeyIdentifier + FROM CryptographicMessageSyntax + { iso(1) member-body(2) us(840) rsadsi(113549) + pkcs(1) pkcs-9(9) smime(16) modules(0) cms-2001(14) }; + + -- id-aa is the arc with all new authenticated and unauthenticated + -- attributes produced by the S/MIME Working Group + + id-aa OBJECT IDENTIFIER ::= {iso(1) member-body(2) usa(840) + rsadsi(113549) pkcs(1) pkcs-9(9) smime(16) attributes(2)} + + -- S/MIME Capabilities provides a method of broadcasting the + -- symmetric capabilities understood. Algorithms SHOULD be ordered + -- by preference and grouped by type + + smimeCapabilities OBJECT IDENTIFIER ::= {iso(1) member-body(2) + us(840) rsadsi(113549) pkcs(1) pkcs-9(9) 15} + + SMIMECapability ::= SEQUENCE { + capabilityID OBJECT IDENTIFIER, + parameters ANY DEFINED BY capabilityID OPTIONAL } + + SMIMECapabilities ::= SEQUENCE OF SMIMECapability + + -- Encryption Key Preference provides a method of broadcasting the + -- preferred encryption certificate. + + id-aa-encrypKeyPref OBJECT IDENTIFIER ::= {id-aa 11} + + + + +Ramsdell & Turner Standards Track [Page 43] + +RFC 5751 S/MIME 3.2 Message Specification January 2010 + + + SMIMEEncryptionKeyPreference ::= CHOICE { + issuerAndSerialNumber [0] IssuerAndSerialNumber, + receipentKeyId [1] RecipientKeyIdentifier, + subjectAltKeyIdentifier [2] SubjectKeyIdentifier + } + + -- receipentKeyId is spelt incorrectly, but kept for historical + -- reasons. + + id-smime OBJECT IDENTIFIER ::= { iso(1) member-body(2) us(840) + rsadsi(113549) pkcs(1) pkcs9(9) 16 } + + id-cap OBJECT IDENTIFIER ::= { id-smime 11 } + + -- The preferBinaryInside OID indicates an ability to receive + -- messages with binary encoding inside the CMS wrapper. + -- The preferBinaryInside attribute's value field is ABSENT. + + id-cap-preferBinaryInside OBJECT IDENTIFIER ::= { id-cap 1 } + + -- The following list OIDs to be used with S/MIME V3 + + -- Signature Algorithms Not Found in [CMSALG], [CMS-SHA2], [RSAPSS], + -- and [RSAOAEP] + + -- + -- md2WithRSAEncryption OBJECT IDENTIFIER ::= + -- {iso(1) member-body(2) us(840) rsadsi(113549) pkcs(1) pkcs-1(1) + -- 2} + + -- + -- Other Signed Attributes + -- + -- signingTime OBJECT IDENTIFIER ::= + -- {iso(1) member-body(2) us(840) rsadsi(113549) pkcs(1) pkcs-9(9) + -- 5} + -- See [CMS] for a description of how to encode the attribute + -- value. + + SMIMECapabilitiesParametersForRC2CBC ::= INTEGER + -- (RC2 Key Length (number of bits)) + + END + + + + + + + + +Ramsdell & Turner Standards Track [Page 44] + +RFC 5751 S/MIME 3.2 Message Specification January 2010 + + +Appendix B. Moving S/MIME v2 Message Specification to Historic Status + + The S/MIME v3 [SMIMEv3], v3.1 [SMIMEv3.1], and v3.2 (this document) + are backwards compatible with the S/MIME v2 Message Specification + [SMIMEv2], with the exception of the algorithms (dropped RC2/40 + requirement and added DSA and RSASSA-PSS requirements). Therefore, + it is recommended that RFC 2311 [SMIMEv2] be moved to Historic + status. + +Appendix C. Acknowledgments + + Many thanks go out to the other authors of the S/MIME version 2 + Message Specification RFC: Steve Dusse, Paul Hoffman, Laurence + Lundblade, and Lisa Repka. Without v2, there wouldn't be a v3, v3.1, + or v3.2. + + A number of the members of the S/MIME Working Group have also worked + very hard and contributed to this document. Any list of people is + doomed to omission, and for that I apologize. In alphabetical order, + the following people stand out in my mind because they made direct + contributions to this document: + + Tony Capel, Piers Chivers, Dave Crocker, Bill Flanigan, Peter + Gutmann, Alfred Hoenes, Paul Hoffman, Russ Housley, William Ottaway, + John Pawling, and Jim Schaad. + +Authors' Addresses + + Blake Ramsdell + Brute Squad Labs, Inc. + + EMail: blaker@gmail.com + + + Sean Turner + IECA, Inc. + 3057 Nutley Street, Suite 106 + Fairfax, VA 22031 + USA + + EMail: turners@ieca.com + + + + + + + + + + +Ramsdell & Turner Standards Track [Page 45] + diff --git a/vendor/swiftmailer/swiftmailer/notes/rfc/whats_where.txt b/vendor/swiftmailer/swiftmailer/notes/rfc/whats_where.txt new file mode 100755 index 0000000..201a5f7 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/notes/rfc/whats_where.txt @@ -0,0 +1,90 @@ +RFC 1854: +--------- +PIPELINING extension + +RFC 2222: +--------- +SASL + +RFC 4505: +--------- +ANYNONYMOUS SASL + +RFC 4616: +--------- +PLAIN SASL + +RFC 2487: +--------- +STARTTLS extension + +RFC 2554 & 4954: +---------------- +AUTH extension + +RFC 2821: +--------- +SMTP protocol + +RFC 2822: +--------- +General message structure (focusing on important headers) + +RFC 2045: +--------- +Quoted Printable Encoding +Base 64 Encoding +Detailed message structure + +RFC 2046: +--------- +Media types (for subparts) + +RFC 2047: +--------- +Header Encoding + +RFC 2183: +--------- +The Content-Disposition header + +RFC 2231: +--------- +Encoded Text header/attribute extensions + +RFC 2234: +--------- +ABNF definitions + +RFC 3676: +--------- +Flowed formatting/delsp parameters + +RFC 2015: +--------- +Original Mime Security with OpenPGP + +RFC 2440: +--------- +Original OpenPGP message format + +RFC 3156: +--------- +Current (30/01/2009) Mime Security with OpenPGP + +RFC 4880: +--------- +Current (30/01/2009) OpenPGP Message format revision (fun, it's exactly original *2 --sorry) + +RFC 5751: +-------- +Secure/Multipurpose Internet Mail Extensions (S/MIME) Version 3.2 + +RFC 4870: +--------- +DomainKeys (historic), but still used by a few people. + +RFX 4871: +--------- +DKIM + diff --git a/vendor/swiftmailer/swiftmailer/notes/smtp.txt b/vendor/swiftmailer/swiftmailer/notes/smtp.txt new file mode 100755 index 0000000..3f8047a --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/notes/smtp.txt @@ -0,0 +1,48 @@ +General Notes +-------------- + * MX is NOT required, but an A record, or CNAME to a MX MUST be present at the least. + * EHLO should be tried, then fall back to HELO + * The 250 return code from RCPT TO is not actually clear-cut. A 251 may be + returned if the message was forwarded to another address. This could be a + useful indicator to end-users that an address should be updated. + * RCPT TO can accpet just "postmaster" without a domain name + * Server MUST not close connection before: + - QUIT and returning 221 response + - Forced requirement, and only after returning a 421 response + - Clients expriencing a forced connection closure, without prior warning should + just treat it like a 451 closure regardless + * ALWAYS use blocking sockets for the initial connection (this should prevent + Exim4's whining about sync). + +Response codes +-------------- + * From RFC2821, 4.2. + - In particular, the 220, 221, 251, 421, and 551 reply codes + are associated with message text that must be parsed and interpreted + by machines. + +Error Codes +------------ + * Numeric 5yz = Error + - 550/RCPT TO = Relay denied + - 500 = Unknown command + * Numeric 2yz = Normal + * Numeric 4yz = Temporary failure?? + + + + Swift + pear.swiftmailer.org + Free Feature-rich PHP Mailer. + + Swift Mailer integrates into any web app written in PHP 5, offering a flexible and elegant object-oriented approach to sending emails with a multitude of features. + + + Fabien Potencier + fabpot + fabien.potencier@symfony-project.org + yes + + + Chris Corbyn + d11wtq + + no + + {{ date }} + + + {{ version }} + {{ api_version }} + + + {{ stability }} + {{ stability }} + + MIT + - + + + + + + + + + + + + + + + + + + + + +{{ files }} + + + + + + + + + 5.2.4 + + + 1.4.0 + + + + + diff --git a/vendor/swiftmailer/swiftmailer/phpunit.xml.dist b/vendor/swiftmailer/swiftmailer/phpunit.xml.dist new file mode 100755 index 0000000..2420586 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/phpunit.xml.dist @@ -0,0 +1,37 @@ + + + + + + + + + + + tests/unit + + + tests/acceptance + + + tests/bug + + + tests/smoke + + + + + + + diff --git a/vendor/swiftmailer/swiftmailer/tests/IdenticalBinaryConstraint.php b/vendor/swiftmailer/swiftmailer/tests/IdenticalBinaryConstraint.php new file mode 100755 index 0000000..bcceb25 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/IdenticalBinaryConstraint.php @@ -0,0 +1,62 @@ +value = $value; + } + + /** + * Evaluates the constraint for parameter $other. Returns TRUE if the + * constraint is met, FALSE otherwise. + * + * @param mixed $other Value or object to evaluate. + * @return bool + */ + public function matches($other) + { + $aHex = $this->asHexString($this->value); + $bHex = $this->asHexString($other); + + return $aHex === $bHex; + } + + /** + * Returns a string representation of the constraint. + * + * @return string + */ + public function toString() + { + return 'indentical binary'; + } + + /** + * Get the given string of bytes as a stirng of Hexadecimal sequences. + * + * @param string $binary + * + * @return string + */ + private function asHexString($binary) + { + $hex = ''; + + $bytes = unpack('H*', $binary); + + foreach ($bytes as &$byte) { + $byte = strtoupper($byte); + } + + return implode('', $bytes); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/StreamCollector.php b/vendor/swiftmailer/swiftmailer/tests/StreamCollector.php new file mode 100755 index 0000000..7f079d9 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/StreamCollector.php @@ -0,0 +1,11 @@ +content .= $arg; + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/SwiftMailerSmokeTestCase.php b/vendor/swiftmailer/swiftmailer/tests/SwiftMailerSmokeTestCase.php new file mode 100755 index 0000000..cc246cd --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/SwiftMailerSmokeTestCase.php @@ -0,0 +1,48 @@ +markTestSkipped( + 'Smoke tests are skipped if tests/smoke.conf.php is not edited' + ); + } + } + + protected function _getMailer() + { + switch (SWIFT_SMOKE_TRANSPORT_TYPE) { + case 'smtp': + $transport = Swift_DependencyContainer::getInstance()->lookup('transport.smtp') + ->setHost(SWIFT_SMOKE_SMTP_HOST) + ->setPort(SWIFT_SMOKE_SMTP_PORT) + ->setUsername(SWIFT_SMOKE_SMTP_USER) + ->setPassword(SWIFT_SMOKE_SMTP_PASS) + ->setEncryption(SWIFT_SMOKE_SMTP_ENCRYPTION) + ; + break; + case 'sendmail': + $transport = Swift_DependencyContainer::getInstance()->lookup('transport.sendmail') + ->setCommand(SWIFT_SMOKE_SENDMAIL_COMMAND) + ; + break; + case 'mail': + case 'nativemail': + $transport = Swift_DependencyContainer::getInstance()->lookup('transport.mail'); + break; + default: + throw new Exception('Undefined transport [' . SWIFT_SMOKE_TRANSPORT_TYPE . ']'); + } + + return new Swift_Mailer($transport); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/SwiftMailerTestCase.php b/vendor/swiftmailer/swiftmailer/tests/SwiftMailerTestCase.php new file mode 100755 index 0000000..664e902 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/SwiftMailerTestCase.php @@ -0,0 +1,35 @@ + \ No newline at end of file diff --git a/vendor/swiftmailer/swiftmailer/tests/_samples/files/textfile.zip b/vendor/swiftmailer/swiftmailer/tests/_samples/files/textfile.zip new file mode 100755 index 0000000..5a580ec Binary files /dev/null and b/vendor/swiftmailer/swiftmailer/tests/_samples/files/textfile.zip differ diff --git a/vendor/swiftmailer/swiftmailer/tests/_samples/smime/CA.srl b/vendor/swiftmailer/swiftmailer/tests/_samples/smime/CA.srl new file mode 100755 index 0000000..dd9818a --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/_samples/smime/CA.srl @@ -0,0 +1 @@ +D42DA34CF90FA0DE diff --git a/vendor/swiftmailer/swiftmailer/tests/_samples/smime/ca.crt b/vendor/swiftmailer/swiftmailer/tests/_samples/smime/ca.crt new file mode 100755 index 0000000..695f814 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/_samples/smime/ca.crt @@ -0,0 +1,21 @@ +-----BEGIN CERTIFICATE----- +MIIDazCCAlOgAwIBAgIJAKJCGQYLxWT1MA0GCSqGSIb3DQEBBQUAMEwxFzAVBgNV +BAMMDlN3aWZ0bWFpbGVyIENBMRQwEgYDVQQKDAtTd2lmdG1haWxlcjEOMAwGA1UE +BwwFUGFyaXMxCzAJBgNVBAYTAkZSMB4XDTEzMTEyNzA4MzkxMFoXDTE3MTEyNjA4 +MzkxMFowTDEXMBUGA1UEAwwOU3dpZnRtYWlsZXIgQ0ExFDASBgNVBAoMC1N3aWZ0 +bWFpbGVyMQ4wDAYDVQQHDAVQYXJpczELMAkGA1UEBhMCRlIwggEiMA0GCSqGSIb3 +DQEBAQUAA4IBDwAwggEKAoIBAQC7RLdHE3OWo9aZwv1xA/cYyPui/gegxpTqClRp +gGcVQ+jxIfnJQDQndyoAvFDiqOiZ+gAjZGJeUHDp9C/2IZp05MLh+omt9N8pBykm +3nj/3ZwPXOAO0uyDPAOHhISITAxEuZCqDnq7iYujywtwfQ7bpW1hCK9PfNZYMStM +kw7LsGr5BqcKkPuOWTvxE3+NqK8HxydYolsoApEGhgonyImVh1Pg1Kjkt5ojvwAX +zOdjfw5poY5NArwuLORUH+XocetRo8DC6S42HkU/MoqcYxa9EuRuwuQh7GtE6baR +PgrDsEYaY4Asy43sK81V51F/8Q1bHZKN/goQdxQwzv+/nOLTAgMBAAGjUDBOMB0G +A1UdDgQWBBRHgqkl543tKhsVAvcx1I0JFU7JuDAfBgNVHSMEGDAWgBRHgqkl543t +KhsVAvcx1I0JFU7JuDAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBBQUAA4IBAQAz +OJiEQcygKGkkXXDiXGBvP/cSznj3nG9FolON0yHUBgdvLfNnctRMStGzPke0siLt +RJvjqiL0Uw+blmLJU8lgMyLJ9ctXkiLJ/WflabN7VzmwYRWe5HzafGQJAg5uFjae +VtAAHQgvbmdXB6brWvcMQmB8di7wjVedeigZvkt1z2V0FtBy8ybJaT5H6bX9Bf5C +dS9r4mLhk/0ThthpRhRxsmupSL6e49nJaIk9q0UTEQVnorJXPcs4SPTIY51bCp6u +cOebhNgndSxCiy0zSD7vRjNiyB/YNGZ9Uv/3DNTLleMZ9kZgfoKVpwYKrRL0IFT/ +cfS2OV1wxRxq668qaOfK +-----END CERTIFICATE----- diff --git a/vendor/swiftmailer/swiftmailer/tests/_samples/smime/ca.key b/vendor/swiftmailer/swiftmailer/tests/_samples/smime/ca.key new file mode 100755 index 0000000..df67470 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/_samples/smime/ca.key @@ -0,0 +1,27 @@ +-----BEGIN RSA PRIVATE KEY----- +MIIEogIBAAKCAQEAu0S3RxNzlqPWmcL9cQP3GMj7ov4HoMaU6gpUaYBnFUPo8SH5 +yUA0J3cqALxQ4qjomfoAI2RiXlBw6fQv9iGadOTC4fqJrfTfKQcpJt54/92cD1zg +DtLsgzwDh4SEiEwMRLmQqg56u4mLo8sLcH0O26VtYQivT3zWWDErTJMOy7Bq+Qan +CpD7jlk78RN/jaivB8cnWKJbKAKRBoYKJ8iJlYdT4NSo5LeaI78AF8znY38OaaGO +TQK8LizkVB/l6HHrUaPAwukuNh5FPzKKnGMWvRLkbsLkIexrROm2kT4Kw7BGGmOA +LMuN7CvNVedRf/ENWx2Sjf4KEHcUMM7/v5zi0wIDAQABAoIBAGyaWkvu/O7Uz2TW +z1JWgVuvWzfYaKYV5FCicvfITn/npVUKZikPge+NTR+mFqaMXHDHqoLb+axGrGUR +hysPq9q0vEx/lo763tyVWYlAJh4E8Dd8njganK0zBbz23kGJEOheUYY95XGTQBda +bqTq8c3x7zAB8GGBvXDh+wFqm38GLyMF6T+YEzWJZqXfg31f1ldRvf6+VFwlLfz6 +cvTR7oUpYIsUeGE47kBs13SN7Oju6a355o/7wy9tOCRiu+r/ikXFh8rFGLfeTiwv +R1dhYjcEYGxZUD8u64U+Cj4qR1P0gHJL0kbh22VMMqgALOc8FpndkjNdg1Nun2X8 +BWpsPwECgYEA7C9PfTOIZfxGBlCl05rmWex++/h5E5PbH1Cw/NGjIH1HjmAkO3+5 +WyMXhySOJ8yWyCBQ/nxqc0w7+TO4C7wQcEdZdUak25KJ74v0sfmWWrVw6kcnLU6k +oawW/L2F2w7ET3zDoxKh4fOF34pfHpSbZk7XJ68YOfHpYVnP4efkQVMCgYEAyvrM +KA7xjnsKumWh206ag3QEI0M/9uPHWmrh2164p7w1MtawccZTxYYJ5o5SsjTwbxkf +0cAamp4qLInmRUxU1gk76tPYC3Ndp6Yf1C+dt0q/vtzyJetCDrdz8HHT1SpKbW0l +g6z1I5FMwa6oWvWsfS++W51vsxUheNsOJ4uxKIECgYBwM7GRiw+7U3N4wItm0Wmp +Qp642Tu7vzwTzmOmV3klkB6UVrwfv/ewgiVFQGqAIcNn42JW44g2qfq70oQWnws4 +K80l15+t6Bm7QUPH4Qg6o4O26IKGFZxEadqpyudyP7um/2B5cfqRuvzYS4YQowyI +N+AirB3YOUJjyyTk7yMSnQKBgGNLpSvDg6+ryWe96Bwcq8G6s3t8noHsk81LlAl4 +oOSNUYj5NX+zAbATDizXWuUKuMPgioxVaa5RyVfYbelgme/KvKD32Sxg12P4BIIM +eR79VifMdjjOiZYhcHojdPlGovo89qkfpxwrLF1jT8CPhj4HaRvwPIBiyekRYC9A +Sv4BAoGAXCIC1xxAJP15osUuQjcM8KdsL1qw+LiPB2+cJJ2VMAZGV7CR2K0aCsis +OwRaYM0jZKUpxzp1uwtfrfqbhdYsv+jIBkfwoShYZuo6MhbUrj0sffkhJC3WrT2z +xafCFLFv1idzGvvNxatlp1DNKrndG2NS3syVAox9MnL5OMsvGM8= +-----END RSA PRIVATE KEY----- diff --git a/vendor/swiftmailer/swiftmailer/tests/_samples/smime/create-cert.sh b/vendor/swiftmailer/swiftmailer/tests/_samples/smime/create-cert.sh new file mode 100755 index 0000000..16314a2 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/_samples/smime/create-cert.sh @@ -0,0 +1,26 @@ +#!/bin/sh + +openssl genrsa -out CA.key 2048 +openssl req -x509 -new -nodes -key CA.key -days 1460 -subj '/CN=Swiftmailer CA/O=Swiftmailer/L=Paris/C=FR' -out CA.crt +openssl x509 -in CA.crt -clrtrust -out CA.crt + +openssl genrsa -out sign.key 2048 +openssl req -new -key sign.key -subj '/CN=Swiftmailer-User/O=Swiftmailer/L=Paris/C=FR' -out sign.csr +openssl x509 -req -in sign.csr -CA CA.crt -CAkey CA.key -out sign.crt -days 1460 -addtrust emailProtection +openssl x509 -in sign.crt -clrtrust -out sign.crt + +rm sign.csr + +openssl genrsa -out encrypt.key 2048 +openssl req -new -key encrypt.key -subj '/CN=Swiftmailer-User/O=Swiftmailer/L=Paris/C=FR' -out encrypt.csr +openssl x509 -req -in encrypt.csr -CA CA.crt -CAkey CA.key -CAcreateserial -out encrypt.crt -days 1460 -addtrust emailProtection +openssl x509 -in encrypt.crt -clrtrust -out encrypt.crt + +rm encrypt.csr + +openssl genrsa -out encrypt2.key 2048 +openssl req -new -key encrypt2.key -subj '/CN=Swiftmailer-User2/O=Swiftmailer/L=Paris/C=FR' -out encrypt2.csr +openssl x509 -req -in encrypt2.csr -CA CA.crt -CAkey CA.key -CAcreateserial -out encrypt2.crt -days 1460 -addtrust emailProtection +openssl x509 -in encrypt2.crt -clrtrust -out encrypt2.crt + +rm encrypt2.csr diff --git a/vendor/swiftmailer/swiftmailer/tests/_samples/smime/encrypt.crt b/vendor/swiftmailer/swiftmailer/tests/_samples/smime/encrypt.crt new file mode 100755 index 0000000..7435855 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/_samples/smime/encrypt.crt @@ -0,0 +1,19 @@ +-----BEGIN CERTIFICATE----- +MIIDFjCCAf4CCQDULaNM+Q+g3TANBgkqhkiG9w0BAQUFADBMMRcwFQYDVQQDDA5T +d2lmdG1haWxlciBDQTEUMBIGA1UECgwLU3dpZnRtYWlsZXIxDjAMBgNVBAcMBVBh +cmlzMQswCQYDVQQGEwJGUjAeFw0xMzExMjcwODM5MTFaFw0xNzExMjYwODM5MTFa +ME4xGTAXBgNVBAMMEFN3aWZ0bWFpbGVyLVVzZXIxFDASBgNVBAoMC1N3aWZ0bWFp +bGVyMQ4wDAYDVQQHDAVQYXJpczELMAkGA1UEBhMCRlIwggEiMA0GCSqGSIb3DQEB +AQUAA4IBDwAwggEKAoIBAQCcNO+fVZBT2znmVwXXZ08n3G5WA1kyvqh9z4RBBZOD +V46Gc1X9MMXr9+wzZBFkAckKaa6KsTkeUr4pC8XUBpQnakxH/kW9CaDPdOE+7wNo +FkPfc6pjWWgpAVxdkrtk7pb4/aGQ++HUkqVu0cMpIcj/7ht7H+3QLZHybn+oMr2+ +FDnn8vPmHxVioinSrxKTlUITuLWS9ZZUTrDa0dG8UAv55A/Tba4T4McCPDpJSA4m +9jrW321NGQUntQoItOJxagaueSvh6PveGV826gTXoU5X+YJ3I2OZUEQ2l6yByAzf +nT+QlxPj5ikotFwL72HsenYtetynOO/k43FblAF/V/l7AgMBAAEwDQYJKoZIhvcN +AQEFBQADggEBAJ048Sdb9Sw5OJM5L00OtGHgcT1B/phqdzSjkM/s64cg3Q20VN+F +fZIIkOnxgyYWcpOWXcdNw2tm5OWhWPGsBcYgMac7uK/ukgoOJSjICg+TTS5kRo96 +iHtmImqkWc6WjNODh7uMnQ6DsZsscdl7Bkx5pKhgGnEdHr5GW8sztgXgyPQO5LUs +YzCmR1RK1WoNMxwbPrGLgYdcpJw69ns5hJbZbMWwrdufiMjYWvTfBPABkk1JRCcY +K6rRTAx4fApsw1kEIY8grGxyAzfRXLArpro7thJr0SIquZ8GpXkQT/mgRR8JD9Hp +z9yhr98EnKzITE/yclGN4pUsuk9S3jiyzUU= +-----END CERTIFICATE----- diff --git a/vendor/swiftmailer/swiftmailer/tests/_samples/smime/encrypt.key b/vendor/swiftmailer/swiftmailer/tests/_samples/smime/encrypt.key new file mode 100755 index 0000000..aa620ca --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/_samples/smime/encrypt.key @@ -0,0 +1,27 @@ +-----BEGIN RSA PRIVATE KEY----- +MIIEpAIBAAKCAQEAnDTvn1WQU9s55lcF12dPJ9xuVgNZMr6ofc+EQQWTg1eOhnNV +/TDF6/fsM2QRZAHJCmmuirE5HlK+KQvF1AaUJ2pMR/5FvQmgz3ThPu8DaBZD33Oq +Y1loKQFcXZK7ZO6W+P2hkPvh1JKlbtHDKSHI/+4bex/t0C2R8m5/qDK9vhQ55/Lz +5h8VYqIp0q8Sk5VCE7i1kvWWVE6w2tHRvFAL+eQP022uE+DHAjw6SUgOJvY61t9t +TRkFJ7UKCLTicWoGrnkr4ej73hlfNuoE16FOV/mCdyNjmVBENpesgcgM350/kJcT +4+YpKLRcC+9h7Hp2LXrcpzjv5ONxW5QBf1f5ewIDAQABAoIBADmuMm2botfUM+Ui +bT3FIC2P8A5C3kUmsgEDB8sazAXL5w0uuanswKkJu2aepO1Q23PE4nbESlswIpf1 +iO9qHnsPfWt4MThEveTdO++JQrDEx/tTMq/M6/F4VysWa6wxjf4Taf2nhRSBsiTh +wDcICri2q98jQyWELkhfFTR+yCHPsn6iNtzE2OpNv9ojKiSqck/sVjC39Z+uU/HD +N4v0CPf9pDGkO+modaVGKf2TpvZT7Hpq/jsPzkk1h7BY7aWdZiIY4YkBkWYqZk8f +0dsxKkOR2glfuEYNtcywG+4UGx3i1AY0mMu96hH5M1ACFmFrTCoodmWDnWy9wUpm +leLmG8ECgYEAywWdryqcvLyhcmqHbnmUhCL9Vl4/5w5fr/5/FNvqArxSGwd2CxcN +Jtkvu22cxWAUoe155eMc6GlPIdNRG8KdWg4sg0TN3Jb2jiHQ3QkHXUJlWU6onjP1 +g2n5h052JxVNGBEb7hr3U7ZMW6wnuYnGdYwCB9P3r5oGxxtfVRB8ygUCgYEAxPfy +tAd3SNT8Sv/cciw76GYKbztUjJRXkLo6GOBGq/AQxP1NDWMuL2AES11YIahidMsF +TMmM+zhkNHsd5P69p87FTMWx0cLoH0M9iQNK7Q6C1luTjLf5DTFuk+nHGErM4Drs ++6Ly1Z4KLXfXgBDD8Ce6U9+W3RrCc36poGZvjX8CgYEAna0P6WJr9r19mhIYevmc +Gf/ex7xNXxMvx80dP8MIfPVrwyhJSpWtljVpt+SKtFRJ0fVRDfUUl4Bqf/fR74B3 +muCVO6ItTBxHAt5Ki9CeUpTlh7XqiWwLSvP8Y1TRuMr3ZDCtg4CYBAD6Ttxmwde6 +NcL2NMQwgsZaazrcEIHMmU0CgYEAl/Mn2tZ/oUIdt8YWzEVvmeNOXW0J1sGBo/bm +ZtZt7qpuZWl7jb5bnNSXu4QxPxXljnAokIpUJmHke9AWydfze4c6EfXZLhcMd0Gq +MQ7HOIWfTbqr4zzx9smRoq4Ql57s2nba521XpJAdDeKL7xH/9j7PsXCls8C3Dd5D +AajEmgUCgYAGEdn6tYxIdX7jF39E3x7zHQf8jHIoQ7+cLTLtd944mSGgeqMfbiww +CoUa+AAUqjdAD5ViAyJrA+gmDtWpkFnJZtToXYwfUF2o3zRo4k1DeBrVbFqwSQkE +omrfiBGtviYIPdqQLE34LYpWEooNPraqO9qTyc+9w5038u2OFS+WmQ== +-----END RSA PRIVATE KEY----- diff --git a/vendor/swiftmailer/swiftmailer/tests/_samples/smime/encrypt2.crt b/vendor/swiftmailer/swiftmailer/tests/_samples/smime/encrypt2.crt new file mode 100755 index 0000000..6908165 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/_samples/smime/encrypt2.crt @@ -0,0 +1,19 @@ +-----BEGIN CERTIFICATE----- +MIIDFzCCAf8CCQDULaNM+Q+g3jANBgkqhkiG9w0BAQUFADBMMRcwFQYDVQQDDA5T +d2lmdG1haWxlciBDQTEUMBIGA1UECgwLU3dpZnRtYWlsZXIxDjAMBgNVBAcMBVBh +cmlzMQswCQYDVQQGEwJGUjAeFw0xMzExMjcwODM5MTJaFw0xNzExMjYwODM5MTJa +ME8xGjAYBgNVBAMMEVN3aWZ0bWFpbGVyLVVzZXIyMRQwEgYDVQQKDAtTd2lmdG1h +aWxlcjEOMAwGA1UEBwwFUGFyaXMxCzAJBgNVBAYTAkZSMIIBIjANBgkqhkiG9w0B +AQEFAAOCAQ8AMIIBCgKCAQEAw4AoYVYss2sa1BWJAJpK6gVemjXrp1mVXVpb1/z6 +SH15AGsp3kiNXsMpgvsdofbqC/5HXrw2G8gWqo+uh6GuK67+Tvp7tO2aD4+8CZzU +K1cffj7Pbx95DUPwXckv79PT5ZcuyeFaVo92aug11+gS/P8n0WXSlzZxNuZ1f3G2 +r/IgwfNKZlarEf1Ih781L2SwmyveW/dtsV2pdrd4IZwsV5SOF2zBFIXSuhPN0c+m +mtwSJe+Ow1udLX4KJkAX8sGVFJ5P5q4s2nS9vLkkj7X6YRQscbyJO9L7e1TksRqL +DLxZwiko6gUhp4/bIs1wDj5tzkQBi4qXviRq3i7A9b2d0QIDAQABMA0GCSqGSIb3 +DQEBBQUAA4IBAQAj8iARhPB2DA3YfT5mJJrgU156Sm0Z3mekAECsr+VqFZtU/9Dz +pPFYEf0hg61cjvwhLtOmaTB+50hu1KNNlu8QlxAfPJqNxtH85W0CYiZHJwW9eSTr +z1swaHpRHLDUgo3oAXdh5syMbdl0MWos0Z14WP5yYu4IwJXs+j2JRW70BICyrNjm +d+AjCzoYjKMdJkSj4uxQEOuW2/5veAoDyU+kHDdfT7SmbyoKu+Pw4Xg/XDuKoWYg +w5/sRiw5vxsmOr9+anspDHdP9rUe1JEfwAJqZB3fwdqEyxu54Xw/GedG4wZBEJf0 +ZcS1eh31emcjYUHQa1IA93jcFSmXzJ+ftJrY +-----END CERTIFICATE----- diff --git a/vendor/swiftmailer/swiftmailer/tests/_samples/smime/encrypt2.key b/vendor/swiftmailer/swiftmailer/tests/_samples/smime/encrypt2.key new file mode 100755 index 0000000..e322a8f --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/_samples/smime/encrypt2.key @@ -0,0 +1,27 @@ +-----BEGIN RSA PRIVATE KEY----- +MIIEpAIBAAKCAQEAw4AoYVYss2sa1BWJAJpK6gVemjXrp1mVXVpb1/z6SH15AGsp +3kiNXsMpgvsdofbqC/5HXrw2G8gWqo+uh6GuK67+Tvp7tO2aD4+8CZzUK1cffj7P +bx95DUPwXckv79PT5ZcuyeFaVo92aug11+gS/P8n0WXSlzZxNuZ1f3G2r/IgwfNK +ZlarEf1Ih781L2SwmyveW/dtsV2pdrd4IZwsV5SOF2zBFIXSuhPN0c+mmtwSJe+O +w1udLX4KJkAX8sGVFJ5P5q4s2nS9vLkkj7X6YRQscbyJO9L7e1TksRqLDLxZwiko +6gUhp4/bIs1wDj5tzkQBi4qXviRq3i7A9b2d0QIDAQABAoIBAH8RvK1PmqxfkEeL +W8oVf13OcafgJjRW6NuNkKa5mmAlldFs1gDRvXl7dm7ZE3CjkYqMEw2DXdP+4KSp +0TH9J7zi+A6ThnaZ/QniTcEdu1YUQbcH0kIS/dZec0wyKUNDtrXC5zl2jQY4Jyrj +laOpBzaEDfhvq0p3q2yYrIRSgACpSEVEsfPoHrxtlLhfMkVNe8P0nkQkzdwou5MQ +MZKV4JUopLHLgPH6IXQCqA1wzlU32yZ86w88GFcBVLkwlLJCKbuAo7yxMCD+nzvA +xm5NuF1kzpP0gk+kZRXF+rFEV4av/2kSS+n8IeUBQZrxovLBuQHVDvJXoqcEjmlh +ZUltznUCgYEA4inwieePfb7kh7L/ma5OLLn+uCNwzVw9LayzXT1dyPravOnkHl6h +MgaoTspqDyU8k8pStedRrr5dVYbseni/A4WSMGvi4innqSXBQGp64TyeJy/e+LrS +ypSWQ6RSJkCxI5t8s4mOpR7FMcdE34I5qeA4G5RS1HIacn7Hxc7uXtcCgYEA3Uqn +E7EDfNfYdZm6AikvE6x64oihWI0x47rlkLu6lf6ihiF1dbfaEN+IAaIxQ/unGYwU +130F0TUwarXnVkeBIRlij4fXhExyd7USSQH1VpqmIqDwsS2ojrzQVMo5UcH+A22G +bbHPtwJNmw8a7yzTPWo2/vnjgV2OaXEQ9vCVG5cCgYEAu1kEoihJDGBijSqxY4wp +xBE7OSxamDNtlnV2i6l3FDMBmfaieqnnHDq5l7NDklJFUSQLyhXZ60hUprHDGV0G +1pMCW8wzQSh3d/4HjSXnrsd5N3sHWMHiNeBKbbQkPP3f/2AhN9SebpgDwE2S9xe4 +TsmnkOkYiFYRJIFzWaAmhDcCgYEAwxRCgZt0xaPKULG6RpljxOYyVm24PsYKCwYB +xjuYWw5k2/W3BJWVCXblAPuojpPUVTMmVGkErc9D5W6Ch471iOZF+t334cs6xci8 +W9v8GeKvPqu+Q5NKmrpctcKoESkA8qik7yLnSCAhpeYFCn/roKJ35QMJyktddhqU +p/yilfUCgYBxZ6YmFjYH6l5SxQdcfa5JQ2To8lZCfRJwB65EyWj4pKH4TaWFS7vb +50WOGTBwJgyhTKLCO3lOmXIUyIwC+OO9xzaeRCBjqEhpup/Ih3MsfMEd6BZRVK5E +IxtmIWba5HQ52k8FKHeRrRB7PSVSADUN2pUFkLudH+j/01kSZyJoLA== +-----END RSA PRIVATE KEY----- diff --git a/vendor/swiftmailer/swiftmailer/tests/_samples/smime/sign.crt b/vendor/swiftmailer/swiftmailer/tests/_samples/smime/sign.crt new file mode 100755 index 0000000..15fd65d --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/_samples/smime/sign.crt @@ -0,0 +1,19 @@ +-----BEGIN CERTIFICATE----- +MIIDFjCCAf4CCQDULaNM+Q+g3DANBgkqhkiG9w0BAQUFADBMMRcwFQYDVQQDDA5T +d2lmdG1haWxlciBDQTEUMBIGA1UECgwLU3dpZnRtYWlsZXIxDjAMBgNVBAcMBVBh +cmlzMQswCQYDVQQGEwJGUjAeFw0xMzExMjcwODM5MTBaFw0xNzExMjYwODM5MTBa +ME4xGTAXBgNVBAMMEFN3aWZ0bWFpbGVyLVVzZXIxFDASBgNVBAoMC1N3aWZ0bWFp +bGVyMQ4wDAYDVQQHDAVQYXJpczELMAkGA1UEBhMCRlIwggEiMA0GCSqGSIb3DQEB +AQUAA4IBDwAwggEKAoIBAQCTe8ZouyjVGgqlljhaswYqLj7icMoHq+Qg13CE+zJg +tl2/UzyPhAd3WWOIvlQ0lu+E/n0bXrS6+q28DrQ3UgJ9BskzzLz15qUO12b92AvG +vLJ+9kKuiM5KXDljOAsXc7/A9UUGwEFA1D0mkeMmkHuiQavAMkzBLha22hGpg/hz +VbE6W9MGna0szd8yh38IY1M5uR+OZ0dG3KbVZb7H3N0OLOP8j8n+4YtAGAW+Onz/ +2CGPfZ1kaDMvY/WTZwyGeA4FwCPy1D8tfeswqKnWDB9Sfl8hns5VxnoJ3dqKQHeX +iC4OMfQ0U4CcuM5sVYJZRNNwP7/TeUh3HegnOnuZ1hy9AgMBAAEwDQYJKoZIhvcN +AQEFBQADggEBAAEPjGt98GIK6ecAEat52aG+8UP7TuZaxoH3cbZdhFTafrP8187F +Rk5G3LCPTeA/QIzbHppA4fPAiS07OVSwVCknpTJbtKKn0gmtTZxThacFHF2NlzTH +XxM5bIbkK3jzIF+WattyTSj34UHHfaNAmvmS7Jyq6MhjSDbcQ+/dZ9eo2tF/AmrC ++MBhyH8aUYwKhTOQQh8yC11niziHhGO99FQ4tpuD9AKlun5snHq4uK9AOFe8VhoR +q2CqX5g5v8OAtdlvzhp50IqD4BNOP+JrUxjGLHDG76BZZIK2Ai1eBz+GhRlIQru/ +8EhQzd94mdFEPblGbmuD2QXWLFFKLiYOwOc= +-----END CERTIFICATE----- diff --git a/vendor/swiftmailer/swiftmailer/tests/_samples/smime/sign.key b/vendor/swiftmailer/swiftmailer/tests/_samples/smime/sign.key new file mode 100755 index 0000000..b3d3c53 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/_samples/smime/sign.key @@ -0,0 +1,27 @@ +-----BEGIN RSA PRIVATE KEY----- +MIIEowIBAAKCAQEAk3vGaLso1RoKpZY4WrMGKi4+4nDKB6vkINdwhPsyYLZdv1M8 +j4QHd1ljiL5UNJbvhP59G160uvqtvA60N1ICfQbJM8y89ealDtdm/dgLxryyfvZC +rojOSlw5YzgLF3O/wPVFBsBBQNQ9JpHjJpB7okGrwDJMwS4WttoRqYP4c1WxOlvT +Bp2tLM3fMod/CGNTObkfjmdHRtym1WW+x9zdDizj/I/J/uGLQBgFvjp8/9ghj32d +ZGgzL2P1k2cMhngOBcAj8tQ/LX3rMKip1gwfUn5fIZ7OVcZ6Cd3aikB3l4guDjH0 +NFOAnLjObFWCWUTTcD+/03lIdx3oJzp7mdYcvQIDAQABAoIBAH2vrw/T6GFrlwU0 +twP8q1VJIghCDLpq77hZQafilzU6VTxWyDaaUu6QPDXt1b8Xnjnd02p+1FDAj0zD +zyuR9VLtdIxzf9mj3KiAQ2IzOx3787YlUgCB0CQo4jM/MJyk5RahL1kogLOp7A8x +pr5XxTUq+B6L/0Nmbq8XupOXRyWp53amZ5N8sgWDv4oKh9fqgAhxbSG6KUkTmhYs +DLinWg86Q28pSn+eivf4dehR56YwtTBVguXW3WKO70+GW1RotSrS6e6SSxfKYksZ +a7/J1hCmJkEE3+4C8BpcI0MelgaK66ocN0pOqDF9ByxphARqyD7tYCfoS2P8gi81 +XoiZJaECgYEAwqx4AnDX63AANsfKuKVsEQfMSAG47SnKOVwHB7prTAgchTRcDph1 +EVOPtJ+4ssanosXzLcN/dCRlvqLEqnKYAOizy3C56CyRguCpO1AGbRpJjRmHTRgA +w8iArhM07HgJ3XLFn99V/0bsPCMxW8dje1ZMjKjoQtDrXRQMtWaVY+UCgYEAwfGi +f0If6z7wJj9gQUkGimWDAg/bxDkvEeh3nSD/PQyNiW0XDclcb3roNPQsal2ZoMwt +f1bwkclw7yUCIZBvXWEkZapjKCdseTp6nglScxr8GAzfN9p5KQl+OS3GzC6xZf6C +BsZQ5ucsHTHsCAi3WbwGK829z9c7x0qRwgwu9/kCgYEAsqwEwYi8Q/RZ3e1lXC9H +jiHwFi6ugc2XMyoJscghbnkLZB54V1UKLUraXFcz97FobnbsCJajxf8Z+uv9QMtI +Q51QV2ow1q0BKHP2HuAF5eD4nK5Phix/lzHRGPO74UUTGNKcG22pylBXxaIvTSMl +ZTABth/YfGqvepBKUbvDZRkCgYB5ykbUCW9H6D8glZ3ZgYU09ag+bD0CzTIs2cH7 +j1QZPz/GdBYNF00PyKv3TPpzVRH7cxyDIdJyioB7/M6Iy03T4wPbQBOCjLdGrZ2A +jrQTCngSlkq6pVx+k7KLL57ua8gFF70JihIV3kfKkaX6KZcSJ8vsSAgRc8TbUo2T +wNjh6QKBgDyxw4bG2ULs+LVaHcnp7nizLgRGXJsCkDICjla6y0eCgAnG8fSt8CcG +s5DIfJeVs/NXe/NVNuVrfwsUx0gBOirtFwQStvi5wJnY/maGAyjmgafisNFgAroT +aM5f+wyGPQeGCs7bj7JWY7Nx9lkyuUV7DdKBTZNMOe51K3+PTEL3 +-----END RSA PRIVATE KEY----- diff --git a/vendor/swiftmailer/swiftmailer/tests/acceptance.conf.php.default b/vendor/swiftmailer/swiftmailer/tests/acceptance.conf.php.default new file mode 100755 index 0000000..68902d8 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/acceptance.conf.php.default @@ -0,0 +1,44 @@ +markTestSkipped( + 'Cannot run test without a writable directory to use (' . + 'define SWIFT_TMP_DIR in tests/config.php if you wish to run this test)' + ); + } + + $this->_tmpDir = SWIFT_TMP_DIR; + $this->_testFile = $this->_tmpDir . '/swift-test-file' . __CLASS__; + file_put_contents($this->_testFile, 'abcdefghijklm'); + } + + public function tearDown() + { + unlink($this->_testFile); + } + + public function testFileDataCanBeRead() + { + $file = $this->_createFileStream($this->_testFile); + $str = ''; + while (false !== $bytes = $file->read(8192)) { + $str .= $bytes; + } + $this->assertEquals('abcdefghijklm', $str); + } + + public function testFileDataCanBeReadSequentially() + { + $file = $this->_createFileStream($this->_testFile); + $this->assertEquals('abcde', $file->read(5)); + $this->assertEquals('fghijklm', $file->read(8)); + $this->assertFalse($file->read(1)); + } + + public function testFilenameIsReturned() + { + $file = $this->_createFileStream($this->_testFile); + $this->assertEquals($this->_testFile, $file->getPath()); + } + + public function testFileCanBeWrittenTo() + { + $file = $this->_createFileStream( + $this->_testFile, true + ); + $file->write('foobar'); + $this->assertEquals('foobar', $file->read(8192)); + } + + public function testReadingFromThenWritingToFile() + { + $file = $this->_createFileStream( + $this->_testFile, true + ); + $file->write('foobar'); + $this->assertEquals('foobar', $file->read(8192)); + $file->write('zipbutton'); + $this->assertEquals('zipbutton', $file->read(8192)); + } + + public function testWritingToFileWithCanonicalization() + { + $file = $this->_createFileStream( + $this->_testFile, true + ); + $file->addFilter($this->_createFilter(array("\r\n", "\r"), "\n"), 'allToLF'); + $file->write("foo\r\nbar\r"); + $file->write("\nzip\r\ntest\r"); + $file->flushBuffers(); + $this->assertEquals("foo\nbar\nzip\ntest\n", file_get_contents($this->_testFile)); + } + + public function testBindingOtherStreamsMirrorsWriteOperations() + { + $file = $this->_createFileStream( + $this->_testFile, true + ); + $is1 = $this->_createMockInputStream(); + $is2 = $this->_createMockInputStream(); + + $is1->expects($this->at(0)) + ->method('write') + ->with('x'); + $is1->expects($this->at(1)) + ->method('write') + ->with('y'); + $is2->expects($this->at(0)) + ->method('write') + ->with('x'); + $is2->expects($this->at(1)) + ->method('write') + ->with('y'); + + $file->bind($is1); + $file->bind($is2); + + $file->write('x'); + $file->write('y'); + } + + public function testBindingOtherStreamsMirrorsFlushOperations() + { + $file = $this->_createFileStream( + $this->_testFile, true + ); + $is1 = $this->_createMockInputStream(); + $is2 = $this->_createMockInputStream(); + + $is1->expects($this->once()) + ->method('flushBuffers'); + $is2->expects($this->once()) + ->method('flushBuffers'); + + $file->bind($is1); + $file->bind($is2); + + $file->flushBuffers(); + } + + public function testUnbindingStreamPreventsFurtherWrites() + { + $file = $this->_createFileStream( + $this->_testFile, true + ); + $is1 = $this->_createMockInputStream(); + $is2 = $this->_createMockInputStream(); + + $is1->expects($this->at(0)) + ->method('write') + ->with('x'); + $is1->expects($this->at(1)) + ->method('write') + ->with('y'); + $is2->expects($this->once()) + ->method('write') + ->with('x'); + + $file->bind($is1); + $file->bind($is2); + + $file->write('x'); + + $file->unbind($is2); + + $file->write('y'); + } + + // -- Creation methods + + private function _createFilter($search, $replace) + { + return new Swift_StreamFilters_StringReplacementFilter($search, $replace); + } + + private function _createMockInputStream() + { + return $this->getMock('Swift_InputByteStream'); + } + + private function _createFileStream($file, $writable = false) + { + return new Swift_ByteStream_FileByteStream($file, $writable); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/CharacterReaderFactory/SimpleCharacterReaderFactoryAcceptanceTest.php b/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/CharacterReaderFactory/SimpleCharacterReaderFactoryAcceptanceTest.php new file mode 100755 index 0000000..911bc5d --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/CharacterReaderFactory/SimpleCharacterReaderFactoryAcceptanceTest.php @@ -0,0 +1,180 @@ +_factory = new Swift_CharacterReaderFactory_SimpleCharacterReaderFactory(); + } + + public function testCreatingUtf8Reader() + { + foreach (array('utf8', 'utf-8', 'UTF-8', 'UTF8') as $utf8) { + $reader = $this->_factory->getReaderFor($utf8); + $this->assertInstanceof($this->_prefix . 'Utf8Reader', $reader); + } + } + + public function testCreatingIso8859XReaders() + { + $charsets = array(); + foreach (range(1, 16) as $number) { + foreach (array('iso', 'iec') as $body) { + $charsets[] = $body . '-8859-' . $number; + $charsets[] = $body . '8859-' . $number; + $charsets[] = strtoupper($body) . '-8859-' . $number; + $charsets[] = strtoupper($body) . '8859-' . $number; + } + } + + foreach ($charsets as $charset) { + $reader = $this->_factory->getReaderFor($charset); + $this->assertInstanceof($this->_prefix . 'GenericFixedWidthReader', $reader); + $this->assertEquals(1, $reader->getInitialByteSize()); + } + } + + public function testCreatingWindows125XReaders() + { + $charsets = array(); + foreach (range(0, 8) as $number) { + $charsets[] = 'windows-125' . $number; + $charsets[] = 'windows125' . $number; + $charsets[] = 'WINDOWS-125' . $number; + $charsets[] = 'WINDOWS125' . $number; + } + + foreach ($charsets as $charset) { + $reader = $this->_factory->getReaderFor($charset); + $this->assertInstanceof($this->_prefix . 'GenericFixedWidthReader', $reader); + $this->assertEquals(1, $reader->getInitialByteSize()); + } + } + + public function testCreatingCodePageReaders() + { + $charsets = array(); + foreach (range(0, 8) as $number) { + $charsets[] = 'cp-125' . $number; + $charsets[] = 'cp125' . $number; + $charsets[] = 'CP-125' . $number; + $charsets[] = 'CP125' . $number; + } + + foreach (array(437, 737, 850, 855, 857, 858, 860, + 861, 863, 865, 866, 869) as $number) + { + $charsets[] = 'cp-' . $number; + $charsets[] = 'cp' . $number; + $charsets[] = 'CP-' . $number; + $charsets[] = 'CP' . $number; + } + + foreach ($charsets as $charset) { + $reader = $this->_factory->getReaderFor($charset); + $this->assertInstanceof($this->_prefix . 'GenericFixedWidthReader', $reader); + $this->assertEquals(1, $reader->getInitialByteSize()); + } + } + + public function testCreatingAnsiReader() + { + foreach (array('ansi', 'ANSI') as $ansi) { + $reader = $this->_factory->getReaderFor($ansi); + $this->assertInstanceof($this->_prefix . 'GenericFixedWidthReader', $reader); + $this->assertEquals(1, $reader->getInitialByteSize()); + } + } + + public function testCreatingMacintoshReader() + { + foreach (array('macintosh', 'MACINTOSH') as $mac) { + $reader = $this->_factory->getReaderFor($mac); + $this->assertInstanceof($this->_prefix . 'GenericFixedWidthReader', $reader); + $this->assertEquals(1, $reader->getInitialByteSize()); + } + } + + public function testCreatingKOIReaders() + { + $charsets = array(); + foreach (array('7', '8-r', '8-u', '8u', '8r') as $end) { + $charsets[] = 'koi-' . $end; + $charsets[] = 'koi' . $end; + $charsets[] = 'KOI-' . $end; + $charsets[] = 'KOI' . $end; + } + + foreach ($charsets as $charset) { + $reader = $this->_factory->getReaderFor($charset); + $this->assertInstanceof($this->_prefix . 'GenericFixedWidthReader', $reader); + $this->assertEquals(1, $reader->getInitialByteSize()); + } + } + + public function testCreatingIsciiReaders() + { + foreach (array('iscii', 'ISCII', 'viscii', 'VISCII') as $charset) { + $reader = $this->_factory->getReaderFor($charset); + $this->assertInstanceof($this->_prefix . 'GenericFixedWidthReader', $reader); + $this->assertEquals(1, $reader->getInitialByteSize()); + } + } + + public function testCreatingMIKReader() + { + foreach (array('mik', 'MIK') as $charset) { + $reader = $this->_factory->getReaderFor($charset); + $this->assertInstanceof($this->_prefix . 'GenericFixedWidthReader', $reader); + $this->assertEquals(1, $reader->getInitialByteSize()); + } + } + + public function testCreatingCorkReader() + { + foreach (array('cork', 'CORK', 't1', 'T1') as $charset) { + $reader = $this->_factory->getReaderFor($charset); + $this->assertInstanceof($this->_prefix . 'GenericFixedWidthReader', $reader); + $this->assertEquals(1, $reader->getInitialByteSize()); + } + } + + public function testCreatingUcs2Reader() + { + foreach (array('ucs-2', 'UCS-2', 'ucs2', 'UCS2') as $charset) { + $reader = $this->_factory->getReaderFor($charset); + $this->assertInstanceof($this->_prefix . 'GenericFixedWidthReader', $reader); + $this->assertEquals(2, $reader->getInitialByteSize()); + } + } + + public function testCreatingUtf16Reader() + { + foreach (array('utf-16', 'UTF-16', 'utf16', 'UTF16') as $charset) { + $reader = $this->_factory->getReaderFor($charset); + $this->assertInstanceof($this->_prefix . 'GenericFixedWidthReader', $reader); + $this->assertEquals(2, $reader->getInitialByteSize()); + } + } + + public function testCreatingUcs4Reader() + { + foreach (array('ucs-4', 'UCS-4', 'ucs4', 'UCS4') as $charset) { + $reader = $this->_factory->getReaderFor($charset); + $this->assertInstanceof($this->_prefix . 'GenericFixedWidthReader', $reader); + $this->assertEquals(4, $reader->getInitialByteSize()); + } + } + + public function testCreatingUtf32Reader() + { + foreach (array('utf-32', 'UTF-32', 'utf32', 'UTF32') as $charset) { + $reader = $this->_factory->getReaderFor($charset); + $this->assertInstanceof($this->_prefix . 'GenericFixedWidthReader', $reader); + $this->assertEquals(4, $reader->getInitialByteSize()); + } + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/DependencyContainerAcceptanceTest.php b/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/DependencyContainerAcceptanceTest.php new file mode 100755 index 0000000..8caf6f5 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/DependencyContainerAcceptanceTest.php @@ -0,0 +1,20 @@ +listItems() as $itemName) { + try { + $di->lookup($itemName); + } catch (Swift_DependencyException $e) { + $this->fail($e->getMessage()); + } + } + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/EmbeddedFileAcceptanceTest.php b/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/EmbeddedFileAcceptanceTest.php new file mode 100755 index 0000000..de43088 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/EmbeddedFileAcceptanceTest.php @@ -0,0 +1,12 @@ +_samplesDir = realpath(__DIR__ . '/../../../_samples/charsets'); + $this->_encoder = new Swift_Encoder_Base64Encoder(); + } + + public function testEncodingAndDecodingSamples() + { + $sampleFp = opendir($this->_samplesDir); + while (false !== $encodingDir = readdir($sampleFp)) { + if (substr($encodingDir, 0, 1) == '.') { + continue; + } + + $sampleDir = $this->_samplesDir . '/' . $encodingDir; + + if (is_dir($sampleDir)) { + + $fileFp = opendir($sampleDir); + while (false !== $sampleFile = readdir($fileFp)) { + if (substr($sampleFile, 0, 1) == '.') { + continue; + } + + $text = file_get_contents($sampleDir . '/' . $sampleFile); + $encodedText = $this->_encoder->encodeString($text); + + $this->assertEquals( + base64_decode($encodedText), $text, + '%s: Encoded string should decode back to original string for sample ' . + $sampleDir . '/' . $sampleFile + ); + } + closedir($fileFp); + } + + } + closedir($sampleFp); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/Encoder/QpEncoderAcceptanceTest.php b/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/Encoder/QpEncoderAcceptanceTest.php new file mode 100755 index 0000000..c99b57b --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/Encoder/QpEncoderAcceptanceTest.php @@ -0,0 +1,52 @@ +_samplesDir = realpath(__DIR__ . '/../../../_samples/charsets'); + $this->_factory = new Swift_CharacterReaderFactory_SimpleCharacterReaderFactory(); + } + + public function testEncodingAndDecodingSamples() + { + $sampleFp = opendir($this->_samplesDir); + while (false !== $encodingDir = readdir($sampleFp)) { + if (substr($encodingDir, 0, 1) == '.') { + continue; + } + + $encoding = $encodingDir; + $charStream = new Swift_CharacterStream_ArrayCharacterStream( + $this->_factory, $encoding); + $encoder = new Swift_Encoder_QpEncoder($charStream); + + $sampleDir = $this->_samplesDir . '/' . $encodingDir; + + if (is_dir($sampleDir)) { + + $fileFp = opendir($sampleDir); + while (false !== $sampleFile = readdir($fileFp)) { + if (substr($sampleFile, 0, 1) == '.') { + continue; + } + + $text = file_get_contents($sampleDir . '/' . $sampleFile); + $encodedText = $encoder->encodeString($text); + + $this->assertEquals( + quoted_printable_decode($encodedText), $text, + '%s: Encoded string should decode back to original string for sample ' . + $sampleDir . '/' . $sampleFile + ); + } + closedir($fileFp); + } + + } + closedir($sampleFp); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/Encoder/Rfc2231EncoderAcceptanceTest.php b/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/Encoder/Rfc2231EncoderAcceptanceTest.php new file mode 100755 index 0000000..5c43c7a --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/Encoder/Rfc2231EncoderAcceptanceTest.php @@ -0,0 +1,52 @@ +_samplesDir = realpath(__DIR__ . '/../../../_samples/charsets'); + $this->_factory = new Swift_CharacterReaderFactory_SimpleCharacterReaderFactory(); + } + + public function testEncodingAndDecodingSamples() + { + $sampleFp = opendir($this->_samplesDir); + while (false !== $encodingDir = readdir($sampleFp)) { + if (substr($encodingDir, 0, 1) == '.') { + continue; + } + + $encoding = $encodingDir; + $charStream = new Swift_CharacterStream_ArrayCharacterStream( + $this->_factory, $encoding); + $encoder = new Swift_Encoder_Rfc2231Encoder($charStream); + + $sampleDir = $this->_samplesDir . '/' . $encodingDir; + + if (is_dir($sampleDir)) { + + $fileFp = opendir($sampleDir); + while (false !== $sampleFile = readdir($fileFp)) { + if (substr($sampleFile, 0, 1) == '.') { + continue; + } + + $text = file_get_contents($sampleDir . '/' . $sampleFile); + $encodedText = $encoder->encodeString($text); + + $this->assertEquals( + urldecode(implode('', explode("\r\n", $encodedText))), $text, + '%s: Encoded string should decode back to original string for sample ' . + $sampleDir . '/' . $sampleFile + ); + } + closedir($fileFp); + } + + } + closedir($sampleFp); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/EncodingAcceptanceTest.php b/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/EncodingAcceptanceTest.php new file mode 100755 index 0000000..6a4d05d --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/EncodingAcceptanceTest.php @@ -0,0 +1,30 @@ +assertEquals('7bit', $encoder->getName()); + } + + public function testGet8BitEncodingReturns8BitEncoder() + { + $encoder = Swift_Encoding::get8BitEncoding(); + $this->assertEquals('8bit', $encoder->getName()); + } + + public function testGetQpEncodingReturnsQpEncoder() + { + $encoder = Swift_Encoding::getQpEncoding(); + $this->assertEquals('quoted-printable', $encoder->getName()); + } + + public function testGetBase64EncodingReturnsBase64Encoder() + { + $encoder = Swift_Encoding::getBase64Encoding(); + $this->assertEquals('base64', $encoder->getName()); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/KeyCache/ArrayKeyCacheAcceptanceTest.php b/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/KeyCache/ArrayKeyCacheAcceptanceTest.php new file mode 100755 index 0000000..6b06e2e --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/KeyCache/ArrayKeyCacheAcceptanceTest.php @@ -0,0 +1,173 @@ +_cache = new Swift_KeyCache_ArrayKeyCache( + new Swift_KeyCache_SimpleKeyCacheInputStream() + ); + } + + public function testStringDataCanBeSetAndFetched() + { + $this->_cache->setString( + $this->_key1, 'foo', 'test', Swift_KeyCache::MODE_WRITE + ); + $this->assertEquals('test', $this->_cache->getString($this->_key1, 'foo')); + } + + public function testStringDataCanBeOverwritten() + { + $this->_cache->setString( + $this->_key1, 'foo', 'test', Swift_KeyCache::MODE_WRITE + ); + $this->_cache->setString( + $this->_key1, 'foo', 'whatever', Swift_KeyCache::MODE_WRITE + ); + $this->assertEquals('whatever', $this->_cache->getString($this->_key1, 'foo')); + } + + public function testStringDataCanBeAppended() + { + $this->_cache->setString( + $this->_key1, 'foo', 'test', Swift_KeyCache::MODE_WRITE + ); + $this->_cache->setString( + $this->_key1, 'foo', 'ing', Swift_KeyCache::MODE_APPEND + ); + $this->assertEquals('testing', $this->_cache->getString($this->_key1, 'foo')); + } + + public function testHasKeyReturnValue() + { + $this->assertFalse($this->_cache->hasKey($this->_key1, 'foo')); + $this->_cache->setString( + $this->_key1, 'foo', 'test', Swift_KeyCache::MODE_WRITE + ); + $this->assertTrue($this->_cache->hasKey($this->_key1, 'foo')); + } + + public function testNsKeyIsWellPartitioned() + { + $this->_cache->setString( + $this->_key1, 'foo', 'test', Swift_KeyCache::MODE_WRITE + ); + $this->_cache->setString( + $this->_key2, 'foo', 'ing', Swift_KeyCache::MODE_WRITE + ); + $this->assertEquals('test', $this->_cache->getString($this->_key1, 'foo')); + $this->assertEquals('ing', $this->_cache->getString($this->_key2, 'foo')); + } + + public function testItemKeyIsWellPartitioned() + { + $this->_cache->setString( + $this->_key1, 'foo', 'test', Swift_KeyCache::MODE_WRITE + ); + $this->_cache->setString( + $this->_key1, 'bar', 'ing', Swift_KeyCache::MODE_WRITE + ); + $this->assertEquals('test', $this->_cache->getString($this->_key1, 'foo')); + $this->assertEquals('ing', $this->_cache->getString($this->_key1, 'bar')); + } + + public function testByteStreamCanBeImported() + { + $os = new Swift_ByteStream_ArrayByteStream(); + $os->write('abcdef'); + + $this->_cache->importFromByteStream( + $this->_key1, 'foo', $os, Swift_KeyCache::MODE_WRITE + ); + $this->assertEquals('abcdef', $this->_cache->getString($this->_key1, 'foo')); + } + + public function testByteStreamCanBeAppended() + { + $os1 = new Swift_ByteStream_ArrayByteStream(); + $os1->write('abcdef'); + + $os2 = new Swift_ByteStream_ArrayByteStream(); + $os2->write('xyzuvw'); + + $this->_cache->importFromByteStream( + $this->_key1, 'foo', $os1, Swift_KeyCache::MODE_APPEND + ); + $this->_cache->importFromByteStream( + $this->_key1, 'foo', $os2, Swift_KeyCache::MODE_APPEND + ); + + $this->assertEquals('abcdefxyzuvw', $this->_cache->getString($this->_key1, 'foo')); + } + + public function testByteStreamAndStringCanBeAppended() + { + $this->_cache->setString( + $this->_key1, 'foo', 'test', Swift_KeyCache::MODE_APPEND + ); + + $os = new Swift_ByteStream_ArrayByteStream(); + $os->write('abcdef'); + + $this->_cache->importFromByteStream( + $this->_key1, 'foo', $os, Swift_KeyCache::MODE_APPEND + ); + $this->assertEquals('testabcdef', $this->_cache->getString($this->_key1, 'foo')); + } + + public function testDataCanBeExportedToByteStream() + { + $this->_cache->setString( + $this->_key1, 'foo', 'test', Swift_KeyCache::MODE_WRITE + ); + + $is = new Swift_ByteStream_ArrayByteStream(); + + $this->_cache->exportToByteStream($this->_key1, 'foo', $is); + + $string = ''; + while (false !== $bytes = $is->read(8192)) { + $string .= $bytes; + } + + $this->assertEquals('test', $string); + } + + public function testKeyCanBeCleared() + { + $this->_cache->setString( + $this->_key1, 'foo', 'test', Swift_KeyCache::MODE_WRITE + ); + $this->assertTrue($this->_cache->hasKey($this->_key1, 'foo')); + $this->_cache->clearKey($this->_key1, 'foo'); + $this->assertFalse($this->_cache->hasKey($this->_key1, 'foo')); + } + + public function testNsKeyCanBeCleared() + { + $this->_cache->setString( + $this->_key1, 'foo', 'test', Swift_KeyCache::MODE_WRITE + ); + $this->_cache->setString( + $this->_key1, 'bar', 'xyz', Swift_KeyCache::MODE_WRITE + ); + $this->assertTrue($this->_cache->hasKey($this->_key1, 'foo')); + $this->assertTrue($this->_cache->hasKey($this->_key1, 'bar')); + $this->_cache->clearAll($this->_key1); + $this->assertFalse($this->_cache->hasKey($this->_key1, 'foo')); + $this->assertFalse($this->_cache->hasKey($this->_key1, 'bar')); + } + + public function testKeyCacheInputStream() + { + $is = $this->_cache->getInputByteStream($this->_key1, 'foo'); + $is->write('abc'); + $is->write('xyz'); + $this->assertEquals('abcxyz', $this->_cache->getString($this->_key1, 'foo')); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/KeyCache/DiskKeyCacheAcceptanceTest.php b/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/KeyCache/DiskKeyCacheAcceptanceTest.php new file mode 100755 index 0000000..4f115be --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/KeyCache/DiskKeyCacheAcceptanceTest.php @@ -0,0 +1,183 @@ +markTestSkipped( + 'Cannot run test without a writable directory to use (' . + 'define SWIFT_TMP_DIR in tests/config.php if you wish to run this test)' + ); + } + + $this->_key1 = uniqid(microtime(true), true); + $this->_key2 = uniqid(microtime(true), true); + $this->_cache = new Swift_KeyCache_DiskKeyCache( + new Swift_KeyCache_SimpleKeyCacheInputStream(), + SWIFT_TMP_DIR + ); + } + + public function testStringDataCanBeSetAndFetched() + { + $this->_cache->setString( + $this->_key1, 'foo', 'test', Swift_KeyCache::MODE_WRITE + ); + $this->assertEquals('test', $this->_cache->getString($this->_key1, 'foo')); + } + + public function testStringDataCanBeOverwritten() + { + $this->_cache->setString( + $this->_key1, 'foo', 'test', Swift_KeyCache::MODE_WRITE + ); + $this->_cache->setString( + $this->_key1, 'foo', 'whatever', Swift_KeyCache::MODE_WRITE + ); + $this->assertEquals('whatever', $this->_cache->getString($this->_key1, 'foo')); + } + + public function testStringDataCanBeAppended() + { + $this->_cache->setString( + $this->_key1, 'foo', 'test', Swift_KeyCache::MODE_WRITE + ); + $this->_cache->setString( + $this->_key1, 'foo', 'ing', Swift_KeyCache::MODE_APPEND + ); + $this->assertEquals('testing', $this->_cache->getString($this->_key1, 'foo')); + } + + public function testHasKeyReturnValue() + { + $this->assertFalse($this->_cache->hasKey($this->_key1, 'foo')); + $this->_cache->setString( + $this->_key1, 'foo', 'test', Swift_KeyCache::MODE_WRITE + ); + $this->assertTrue($this->_cache->hasKey($this->_key1, 'foo')); + } + + public function testNsKeyIsWellPartitioned() + { + $this->_cache->setString( + $this->_key1, 'foo', 'test', Swift_KeyCache::MODE_WRITE + ); + $this->_cache->setString( + $this->_key2, 'foo', 'ing', Swift_KeyCache::MODE_WRITE + ); + $this->assertEquals('test', $this->_cache->getString($this->_key1, 'foo')); + $this->assertEquals('ing', $this->_cache->getString($this->_key2, 'foo')); + } + + public function testItemKeyIsWellPartitioned() + { + $this->_cache->setString( + $this->_key1, 'foo', 'test', Swift_KeyCache::MODE_WRITE + ); + $this->_cache->setString( + $this->_key1, 'bar', 'ing', Swift_KeyCache::MODE_WRITE + ); + $this->assertEquals('test', $this->_cache->getString($this->_key1, 'foo')); + $this->assertEquals('ing', $this->_cache->getString($this->_key1, 'bar')); + } + + public function testByteStreamCanBeImported() + { + $os = new Swift_ByteStream_ArrayByteStream(); + $os->write('abcdef'); + + $this->_cache->importFromByteStream( + $this->_key1, 'foo', $os, Swift_KeyCache::MODE_WRITE + ); + $this->assertEquals('abcdef', $this->_cache->getString($this->_key1, 'foo')); + } + + public function testByteStreamCanBeAppended() + { + $os1 = new Swift_ByteStream_ArrayByteStream(); + $os1->write('abcdef'); + + $os2 = new Swift_ByteStream_ArrayByteStream(); + $os2->write('xyzuvw'); + + $this->_cache->importFromByteStream( + $this->_key1, 'foo', $os1, Swift_KeyCache::MODE_APPEND + ); + $this->_cache->importFromByteStream( + $this->_key1, 'foo', $os2, Swift_KeyCache::MODE_APPEND + ); + + $this->assertEquals('abcdefxyzuvw', $this->_cache->getString($this->_key1, 'foo')); + } + + public function testByteStreamAndStringCanBeAppended() + { + $this->_cache->setString( + $this->_key1, 'foo', 'test', Swift_KeyCache::MODE_APPEND + ); + + $os = new Swift_ByteStream_ArrayByteStream(); + $os->write('abcdef'); + + $this->_cache->importFromByteStream( + $this->_key1, 'foo', $os, Swift_KeyCache::MODE_APPEND + ); + $this->assertEquals('testabcdef', $this->_cache->getString($this->_key1, 'foo')); + } + + public function testDataCanBeExportedToByteStream() + { + $this->_cache->setString( + $this->_key1, 'foo', 'test', Swift_KeyCache::MODE_WRITE + ); + + $is = new Swift_ByteStream_ArrayByteStream(); + + $this->_cache->exportToByteStream($this->_key1, 'foo', $is); + + $string = ''; + while (false !== $bytes = $is->read(8192)) { + $string .= $bytes; + } + + $this->assertEquals('test', $string); + } + + public function testKeyCanBeCleared() + { + $this->_cache->setString( + $this->_key1, 'foo', 'test', Swift_KeyCache::MODE_WRITE + ); + $this->assertTrue($this->_cache->hasKey($this->_key1, 'foo')); + $this->_cache->clearKey($this->_key1, 'foo'); + $this->assertFalse($this->_cache->hasKey($this->_key1, 'foo')); + } + + public function testNsKeyCanBeCleared() + { + $this->_cache->setString( + $this->_key1, 'foo', 'test', Swift_KeyCache::MODE_WRITE + ); + $this->_cache->setString( + $this->_key1, 'bar', 'xyz', Swift_KeyCache::MODE_WRITE + ); + $this->assertTrue($this->_cache->hasKey($this->_key1, 'foo')); + $this->assertTrue($this->_cache->hasKey($this->_key1, 'bar')); + $this->_cache->clearAll($this->_key1); + $this->assertFalse($this->_cache->hasKey($this->_key1, 'foo')); + $this->assertFalse($this->_cache->hasKey($this->_key1, 'bar')); + } + + public function testKeyCacheInputStream() + { + $is = $this->_cache->getInputByteStream($this->_key1, 'foo'); + $is->write('abc'); + $is->write('xyz'); + $this->assertEquals('abcxyz', $this->_cache->getString($this->_key1, 'foo')); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/MessageAcceptanceTest.php b/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/MessageAcceptanceTest.php new file mode 100755 index 0000000..14751f2 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/MessageAcceptanceTest.php @@ -0,0 +1,57 @@ +_createMessage(); + $message->setSubject('just a test subject'); + $message->setFrom(array( + 'chris.corbyn@swiftmailer.org' => 'Chris Corbyn')); + + $id = $message->getId(); + $date = $message->getDate(); + $boundary = $message->getBoundary(); + + $message->addPart('foo', 'text/plain', 'iso-8859-1'); + $message->addPart('test foo', 'text/html', 'iso-8859-1'); + + $this->assertEquals( + 'Message-ID: <' . $id . '>' . "\r\n" . + 'Date: ' . date('r', $date) . "\r\n" . + 'Subject: just a test subject' . "\r\n" . + 'From: Chris Corbyn ' . "\r\n" . + 'MIME-Version: 1.0' . "\r\n" . + 'Content-Type: multipart/alternative;' . "\r\n" . + ' boundary="' . $boundary . '"' . "\r\n" . + "\r\n\r\n" . + '--' . $boundary . "\r\n" . + 'Content-Type: text/plain; charset=iso-8859-1' . "\r\n" . + 'Content-Transfer-Encoding: quoted-printable' . "\r\n" . + "\r\n" . + 'foo' . + "\r\n\r\n" . + '--' . $boundary . "\r\n" . + 'Content-Type: text/html; charset=iso-8859-1' . "\r\n" . + 'Content-Transfer-Encoding: quoted-printable' . "\r\n" . + "\r\n" . + 'test foo' . + "\r\n\r\n" . + '--' . $boundary . '--' . "\r\n", + $message->toString() + ); + } + + // -- Private helpers + + protected function _createMessage() + { + Swift_DependencyContainer::getInstance() + ->register('properties.charset')->asValue(null); + + return Swift_Message::newInstance(); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/Mime/AttachmentAcceptanceTest.php b/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/Mime/AttachmentAcceptanceTest.php new file mode 100755 index 0000000..53655bc --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/Mime/AttachmentAcceptanceTest.php @@ -0,0 +1,125 @@ +_cache = new Swift_KeyCache_ArrayKeyCache( + new Swift_KeyCache_SimpleKeyCacheInputStream() + ); + $factory = new Swift_CharacterReaderFactory_SimpleCharacterReaderFactory(); + $this->_contentEncoder = new Swift_Mime_ContentEncoder_Base64ContentEncoder(); + + $headerEncoder = new Swift_Mime_HeaderEncoder_QpHeaderEncoder( + new Swift_CharacterStream_ArrayCharacterStream($factory, 'utf-8') + ); + $paramEncoder = new Swift_Encoder_Rfc2231Encoder( + new Swift_CharacterStream_ArrayCharacterStream($factory, 'utf-8') + ); + $this->_grammar = new Swift_Mime_Grammar(); + $this->_headers = new Swift_Mime_SimpleHeaderSet( + new Swift_Mime_SimpleHeaderFactory($headerEncoder, $paramEncoder, $this->_grammar) + ); + } + + public function testDispositionIsSetInHeader() + { + $attachment = $this->_createAttachment(); + $attachment->setContentType('application/pdf'); + $attachment->setDisposition('inline'); + $this->assertEquals( + 'Content-Type: application/pdf' . "\r\n" . + 'Content-Transfer-Encoding: base64' . "\r\n" . + 'Content-Disposition: inline' . "\r\n", + $attachment->toString() + ); + } + + public function testDispositionIsAttachmentByDefault() + { + $attachment = $this->_createAttachment(); + $attachment->setContentType('application/pdf'); + $this->assertEquals( + 'Content-Type: application/pdf' . "\r\n" . + 'Content-Transfer-Encoding: base64' . "\r\n" . + 'Content-Disposition: attachment' . "\r\n", + $attachment->toString() + ); + } + + public function testFilenameIsSetInHeader() + { + $attachment = $this->_createAttachment(); + $attachment->setContentType('application/pdf'); + $attachment->setFilename('foo.pdf'); + $this->assertEquals( + 'Content-Type: application/pdf; name=foo.pdf' . "\r\n" . + 'Content-Transfer-Encoding: base64' . "\r\n" . + 'Content-Disposition: attachment; filename=foo.pdf' . "\r\n", + $attachment->toString() + ); + } + + public function testSizeIsSetInHeader() + { + $attachment = $this->_createAttachment(); + $attachment->setContentType('application/pdf'); + $attachment->setSize(12340); + $this->assertEquals( + 'Content-Type: application/pdf' . "\r\n" . + 'Content-Transfer-Encoding: base64' . "\r\n" . + 'Content-Disposition: attachment; size=12340' . "\r\n", + $attachment->toString() + ); + } + + public function testMultipleParametersInHeader() + { + $attachment = $this->_createAttachment(); + $attachment->setContentType('application/pdf'); + $attachment->setFilename('foo.pdf'); + $attachment->setSize(12340); + $this->assertEquals( + 'Content-Type: application/pdf; name=foo.pdf' . "\r\n" . + 'Content-Transfer-Encoding: base64' . "\r\n" . + 'Content-Disposition: attachment; filename=foo.pdf; size=12340' . "\r\n", + $attachment->toString() + ); + } + + public function testEndToEnd() + { + $attachment = $this->_createAttachment(); + $attachment->setContentType('application/pdf'); + $attachment->setFilename('foo.pdf'); + $attachment->setSize(12340); + $attachment->setBody('abcd'); + $this->assertEquals( + 'Content-Type: application/pdf; name=foo.pdf' . "\r\n" . + 'Content-Transfer-Encoding: base64' . "\r\n" . + 'Content-Disposition: attachment; filename=foo.pdf; size=12340' . "\r\n" . + "\r\n" . + base64_encode('abcd'), + $attachment->toString() + ); + } + + // -- Private helpers + + protected function _createAttachment() + { + $entity = new Swift_Mime_Attachment( + $this->_headers, + $this->_contentEncoder, + $this->_cache, + $this->_grammar + ); + + return $entity; + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/Mime/ContentEncoder/Base64ContentEncoderAcceptanceTest.php b/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/Mime/ContentEncoder/Base64ContentEncoderAcceptanceTest.php new file mode 100755 index 0000000..e7b2816 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/Mime/ContentEncoder/Base64ContentEncoderAcceptanceTest.php @@ -0,0 +1,58 @@ +_samplesDir = realpath(__DIR__ . '/../../../../_samples/charsets'); + $this->_encoder = new Swift_Mime_ContentEncoder_Base64ContentEncoder(); + } + + public function testEncodingAndDecodingSamples() + { + $sampleFp = opendir($this->_samplesDir); + while (false !== $encodingDir = readdir($sampleFp)) { + if (substr($encodingDir, 0, 1) == '.') { + continue; + } + + $sampleDir = $this->_samplesDir . '/' . $encodingDir; + + if (is_dir($sampleDir)) { + + $fileFp = opendir($sampleDir); + while (false !== $sampleFile = readdir($fileFp)) { + if (substr($sampleFile, 0, 1) == '.') { + continue; + } + + $text = file_get_contents($sampleDir . '/' . $sampleFile); + + $os = new Swift_ByteStream_ArrayByteStream(); + $os->write($text); + + $is = new Swift_ByteStream_ArrayByteStream(); + + $this->_encoder->encodeByteStream($os, $is); + + $encoded = ''; + while (false !== $bytes = $is->read(8192)) { + $encoded .= $bytes; + } + + $this->assertEquals( + base64_decode($encoded), $text, + '%s: Encoded string should decode back to original string for sample ' . + $sampleDir . '/' . $sampleFile + ); + } + closedir($fileFp); + } + + } + closedir($sampleFp); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/Mime/ContentEncoder/NativeQpContentEncoderAcceptanceTest.php b/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/Mime/ContentEncoder/NativeQpContentEncoderAcceptanceTest.php new file mode 100755 index 0000000..a477ffa --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/Mime/ContentEncoder/NativeQpContentEncoderAcceptanceTest.php @@ -0,0 +1,90 @@ +_samplesDir = realpath(__DIR__ . '/../../../../_samples/charsets'); + $this->_encoder = new Swift_Mime_ContentEncoder_NativeQpContentEncoder(); + } + + public function testEncodingAndDecodingSamples() + { + $sampleFp = opendir($this->_samplesDir); + while (false !== $encodingDir = readdir($sampleFp)) { + if (substr($encodingDir, 0, 1) == '.') { + continue; + } + + $sampleDir = $this->_samplesDir . '/' . $encodingDir; + + if (is_dir($sampleDir)) { + + $fileFp = opendir($sampleDir); + while (false !== $sampleFile = readdir($fileFp)) { + if (substr($sampleFile, 0, 1) == '.') { + continue; + } + + $text = file_get_contents($sampleDir . '/' . $sampleFile); + + $os = new Swift_ByteStream_ArrayByteStream(); + $os->write($text); + + $is = new Swift_ByteStream_ArrayByteStream(); + $this->_encoder->encodeByteStream($os, $is); + + $encoded = ''; + while (false !== $bytes = $is->read(8192)) { + $encoded .= $bytes; + } + + $this->assertEquals( + quoted_printable_decode($encoded), + // CR and LF are converted to CRLF + preg_replace('~\r(?!\n)|(?_createEncoderFromContainer(); + $this->assertSame('=C3=A4=C3=B6=C3=BC=C3=9F', $encoder->encodeString('äöüß')); + } + + /** + * @expectedException RuntimeException + */ + public function testCharsetChangeNotImplemented() + { + $this->_encoder->charsetChanged('utf-8'); + $this->_encoder->charsetChanged('charset'); + $this->_encoder->encodeString('foo'); + } + + public function testGetName() + { + $this->assertSame('quoted-printable', $this->_encoder->getName()); + } + + // -- Private Methods + + private function _createEncoderFromContainer() + { + return Swift_DependencyContainer::getInstance() + ->lookup('mime.nativeqpcontentencoder') + ; + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/Mime/ContentEncoder/PlainContentEncoderAcceptanceTest.php b/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/Mime/ContentEncoder/PlainContentEncoderAcceptanceTest.php new file mode 100755 index 0000000..f584a73 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/Mime/ContentEncoder/PlainContentEncoderAcceptanceTest.php @@ -0,0 +1,92 @@ +_samplesDir = realpath(__DIR__ . '/../../../../_samples/charsets'); + $this->_encoder = new Swift_Mime_ContentEncoder_PlainContentEncoder('8bit'); + } + + public function testEncodingAndDecodingSamplesString() + { + $sampleFp = opendir($this->_samplesDir); + while (false !== $encodingDir = readdir($sampleFp)) { + if (substr($encodingDir, 0, 1) == '.') { + continue; + } + + $sampleDir = $this->_samplesDir . '/' . $encodingDir; + + if (is_dir($sampleDir)) { + + $fileFp = opendir($sampleDir); + while (false !== $sampleFile = readdir($fileFp)) { + if (substr($sampleFile, 0, 1) == '.') { + continue; + } + + $text = file_get_contents($sampleDir . '/' . $sampleFile); + $encodedText = $this->_encoder->encodeString($text); + + $this->assertEquals( + $encodedText, $text, + '%s: Encoded string should be identical to original string for sample ' . + $sampleDir . '/' . $sampleFile + ); + } + closedir($fileFp); + } + + } + closedir($sampleFp); + } + + public function testEncodingAndDecodingSamplesByteStream() + { + $sampleFp = opendir($this->_samplesDir); + while (false !== $encodingDir = readdir($sampleFp)) { + if (substr($encodingDir, 0, 1) == '.') { + continue; + } + + $sampleDir = $this->_samplesDir . '/' . $encodingDir; + + if (is_dir($sampleDir)) { + + $fileFp = opendir($sampleDir); + while (false !== $sampleFile = readdir($fileFp)) { + if (substr($sampleFile, 0, 1) == '.') { + continue; + } + + $text = file_get_contents($sampleDir . '/' . $sampleFile); + + $os = new Swift_ByteStream_ArrayByteStream(); + $os->write($text); + + $is = new Swift_ByteStream_ArrayByteStream(); + + $this->_encoder->encodeByteStream($os, $is); + + $encoded = ''; + while (false !== $bytes = $is->read(8192)) { + $encoded .= $bytes; + } + + $this->assertEquals( + $encoded, $text, + '%s: Encoded string should be identical to original string for sample ' . + $sampleDir . '/' . $sampleFile + ); + } + closedir($fileFp); + } + + } + closedir($sampleFp); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/Mime/ContentEncoder/QpContentEncoderAcceptanceTest.php b/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/Mime/ContentEncoder/QpContentEncoderAcceptanceTest.php new file mode 100755 index 0000000..b29a82f --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/Mime/ContentEncoder/QpContentEncoderAcceptanceTest.php @@ -0,0 +1,163 @@ +_samplesDir = realpath(__DIR__ . '/../../../../_samples/charsets'); + $this->_factory = new Swift_CharacterReaderFactory_SimpleCharacterReaderFactory(); + } + + public function testEncodingAndDecodingSamples() + { + $sampleFp = opendir($this->_samplesDir); + while (false !== $encodingDir = readdir($sampleFp)) { + if (substr($encodingDir, 0, 1) == '.') { + continue; + } + + $encoding = $encodingDir; + $charStream = new Swift_CharacterStream_NgCharacterStream( + $this->_factory, $encoding); + $encoder = new Swift_Mime_ContentEncoder_QpContentEncoder($charStream); + + $sampleDir = $this->_samplesDir . '/' . $encodingDir; + + if (is_dir($sampleDir)) { + + $fileFp = opendir($sampleDir); + while (false !== $sampleFile = readdir($fileFp)) { + if (substr($sampleFile, 0, 1) == '.') { + continue; + } + + $text = file_get_contents($sampleDir . '/' . $sampleFile); + + $os = new Swift_ByteStream_ArrayByteStream(); + $os->write($text); + + $is = new Swift_ByteStream_ArrayByteStream(); + $encoder->encodeByteStream($os, $is); + + $encoded = ''; + while (false !== $bytes = $is->read(8192)) { + $encoded .= $bytes; + } + + $this->assertEquals( + quoted_printable_decode($encoded), $text, + '%s: Encoded string should decode back to original string for sample ' . + $sampleDir . '/' . $sampleFile + ); + } + closedir($fileFp); + } + + } + closedir($sampleFp); + } + + public function testEncodingAndDecodingSamplesFromDiConfiguredInstance() + { + $sampleFp = opendir($this->_samplesDir); + while (false !== $encodingDir = readdir($sampleFp)) { + if (substr($encodingDir, 0, 1) == '.') { + continue; + } + + $encoding = $encodingDir; + $encoder = $this->_createEncoderFromContainer(); + + $sampleDir = $this->_samplesDir . '/' . $encodingDir; + + if (is_dir($sampleDir)) { + + $fileFp = opendir($sampleDir); + while (false !== $sampleFile = readdir($fileFp)) { + if (substr($sampleFile, 0, 1) == '.') { + continue; + } + + $text = file_get_contents($sampleDir . '/' . $sampleFile); + + $os = new Swift_ByteStream_ArrayByteStream(); + $os->write($text); + + $is = new Swift_ByteStream_ArrayByteStream(); + $encoder->encodeByteStream($os, $is); + + $encoded = ''; + while (false !== $bytes = $is->read(8192)) { + $encoded .= $bytes; + } + + $this->assertEquals( + str_replace("\r\n", "\n", quoted_printable_decode($encoded)), str_replace("\r\n", "\n", $text), + '%s: Encoded string should decode back to original string for sample ' . + $sampleDir . '/' . $sampleFile + ); + } + closedir($fileFp); + } + + } + closedir($sampleFp); + } + + public function testEncodingLFTextWithDiConfiguredInstance() + { + $encoder = $this->_createEncoderFromContainer(); + $this->assertEquals("a\r\nb\r\nc", $encoder->encodeString("a\nb\nc")); + } + + public function testEncodingCRTextWithDiConfiguredInstance() + { + $encoder = $this->_createEncoderFromContainer(); + $this->assertEquals("a\r\nb\r\nc", $encoder->encodeString("a\rb\rc")); + } + + public function testEncodingLFCRTextWithDiConfiguredInstance() + { + $encoder = $this->_createEncoderFromContainer(); + $this->assertEquals("a\r\n\r\nb\r\n\r\nc", $encoder->encodeString("a\n\rb\n\rc")); + } + + public function testEncodingCRLFTextWithDiConfiguredInstance() + { + $encoder = $this->_createEncoderFromContainer(); + $this->assertEquals("a\r\nb\r\nc", $encoder->encodeString("a\r\nb\r\nc")); + } + + public function testEncodingDotStuffingWithDiConfiguredInstance() + { + // Enable DotEscaping + Swift_Preferences::getInstance()->setQPDotEscape(true); + $encoder = $this->_createEncoderFromContainer(); + $this->assertEquals("a=2E\r\n=2E\r\n=2Eb\r\nc", $encoder->encodeString("a.\r\n.\r\n.b\r\nc")); + // Return to default + Swift_Preferences::getInstance()->setQPDotEscape(false); + $encoder = $this->_createEncoderFromContainer(); + $this->assertEquals("a.\r\n.\r\n.b\r\nc", $encoder->encodeString("a.\r\n.\r\n.b\r\nc")); + } + + public function testDotStuffingEncodingAndDecodingSamplesFromDiConfiguredInstance() + { + // Enable DotEscaping + Swift_Preferences::getInstance()->setQPDotEscape(true); + $this->testEncodingAndDecodingSamplesFromDiConfiguredInstance(); + // Disable DotStuffing to continue + Swift_Preferences::getInstance()->setQPDotEscape(false); + } + + // -- Private Methods + + private function _createEncoderFromContainer() + { + return Swift_DependencyContainer::getInstance() + ->lookup('mime.qpcontentencoder') + ; + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/Mime/EmbeddedFileAcceptanceTest.php b/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/Mime/EmbeddedFileAcceptanceTest.php new file mode 100755 index 0000000..a29ce1f --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/Mime/EmbeddedFileAcceptanceTest.php @@ -0,0 +1,137 @@ +_cache = new Swift_KeyCache_ArrayKeyCache( + new Swift_KeyCache_SimpleKeyCacheInputStream() + ); + $factory = new Swift_CharacterReaderFactory_SimpleCharacterReaderFactory(); + $this->_contentEncoder = new Swift_Mime_ContentEncoder_Base64ContentEncoder(); + + $headerEncoder = new Swift_Mime_HeaderEncoder_QpHeaderEncoder( + new Swift_CharacterStream_ArrayCharacterStream($factory, 'utf-8') + ); + $paramEncoder = new Swift_Encoder_Rfc2231Encoder( + new Swift_CharacterStream_ArrayCharacterStream($factory, 'utf-8') + ); + $this->_grammar = new Swift_Mime_Grammar(); + $this->_headers = new Swift_Mime_SimpleHeaderSet( + new Swift_Mime_SimpleHeaderFactory($headerEncoder, $paramEncoder, $this->_grammar) + ); + } + + public function testContentIdIsSetInHeader() + { + $file = $this->_createEmbeddedFile(); + $file->setContentType('application/pdf'); + $file->setId('foo@bar'); + $this->assertEquals( + 'Content-Type: application/pdf' . "\r\n" . + 'Content-Transfer-Encoding: base64' . "\r\n" . + 'Content-Disposition: inline' . "\r\n" . + 'Content-ID: ' . "\r\n", + $file->toString() + ); + } + + public function testDispositionIsSetInHeader() + { + $file = $this->_createEmbeddedFile(); + $id = $file->getId(); + $file->setContentType('application/pdf'); + $file->setDisposition('attachment'); + $this->assertEquals( + 'Content-Type: application/pdf' . "\r\n" . + 'Content-Transfer-Encoding: base64' . "\r\n" . + 'Content-Disposition: attachment' . "\r\n" . + 'Content-ID: <'. $id . '>' . "\r\n", + $file->toString() + ); + } + + public function testFilenameIsSetInHeader() + { + $file = $this->_createEmbeddedFile(); + $id = $file->getId(); + $file->setContentType('application/pdf'); + $file->setFilename('foo.pdf'); + $this->assertEquals( + 'Content-Type: application/pdf; name=foo.pdf' . "\r\n" . + 'Content-Transfer-Encoding: base64' . "\r\n" . + 'Content-Disposition: inline; filename=foo.pdf' . "\r\n" . + 'Content-ID: <'. $id . '>' . "\r\n", + $file->toString() + ); + } + + public function testSizeIsSetInHeader() + { + $file = $this->_createEmbeddedFile(); + $id = $file->getId(); + $file->setContentType('application/pdf'); + $file->setSize(12340); + $this->assertEquals( + 'Content-Type: application/pdf' . "\r\n" . + 'Content-Transfer-Encoding: base64' . "\r\n" . + 'Content-Disposition: inline; size=12340' . "\r\n" . + 'Content-ID: <'. $id . '>' . "\r\n", + $file->toString() + ); + } + + public function testMultipleParametersInHeader() + { + $file = $this->_createEmbeddedFile(); + $id = $file->getId(); + $file->setContentType('application/pdf'); + $file->setFilename('foo.pdf'); + $file->setSize(12340); + $this->assertEquals( + 'Content-Type: application/pdf; name=foo.pdf' . "\r\n" . + 'Content-Transfer-Encoding: base64' . "\r\n" . + 'Content-Disposition: inline; filename=foo.pdf; size=12340' . "\r\n" . + 'Content-ID: <'. $id . '>' . "\r\n", + $file->toString() + ); + } + + public function testEndToEnd() + { + $file = $this->_createEmbeddedFile(); + $id = $file->getId(); + $file->setContentType('application/pdf'); + $file->setFilename('foo.pdf'); + $file->setSize(12340); + $file->setBody('abcd'); + $this->assertEquals( + 'Content-Type: application/pdf; name=foo.pdf' . "\r\n" . + 'Content-Transfer-Encoding: base64' . "\r\n" . + 'Content-Disposition: inline; filename=foo.pdf; size=12340' . "\r\n" . + 'Content-ID: <'. $id . '>' . "\r\n" . + "\r\n" . + base64_encode('abcd'), + $file->toString() + ); + } + + // -- Private helpers + + protected function _createEmbeddedFile() + { + $entity = new Swift_Mime_EmbeddedFile( + $this->_headers, + $this->_contentEncoder, + $this->_cache, + $this->_grammar + ); + + return $entity; + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/Mime/HeaderEncoder/Base64HeaderEncoderAcceptanceTest.php b/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/Mime/HeaderEncoder/Base64HeaderEncoderAcceptanceTest.php new file mode 100755 index 0000000..61177fe --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/Mime/HeaderEncoder/Base64HeaderEncoderAcceptanceTest.php @@ -0,0 +1,32 @@ +_encoder = new Swift_Mime_HeaderEncoder_Base64HeaderEncoder(); + } + + public function testEncodingJIS() + { + if (function_exists('mb_convert_encoding')) { + // base64_encode and split cannot handle long JIS text to fold + $subject = "é•·ã„é•·ã„é•·ã„é•·ã„é•·ã„é•·ã„é•·ã„é•·ã„é•·ã„é•·ã„é•·ã„é•·ã„é•·ã„é•·ã„é•·ã„é•·ã„é•·ã„é•·ã„é•·ã„é•·ã„件å"; + + $encodedWrapperLength = strlen('=?iso-2022-jp?' . $this->_encoder->getName() . '??='); + + $old = mb_internal_encoding(); + mb_internal_encoding('utf-8'); + $newstring = mb_encode_mimeheader($subject, 'iso-2022-jp', 'B', "\r\n"); + mb_internal_encoding($old); + + $encoded = $this->_encoder->encodeString($subject, 0, 75 - $encodedWrapperLength, 'iso-2022-jp'); + $this->assertEquals( + $encoded, $newstring, + 'Encoded string should decode back to original string for sample ' + ); + } + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/Mime/MimePartAcceptanceTest.php b/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/Mime/MimePartAcceptanceTest.php new file mode 100755 index 0000000..3922353 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/Mime/MimePartAcceptanceTest.php @@ -0,0 +1,129 @@ +_cache = new Swift_KeyCache_ArrayKeyCache( + new Swift_KeyCache_SimpleKeyCacheInputStream() + ); + $factory = new Swift_CharacterReaderFactory_SimpleCharacterReaderFactory(); + $this->_contentEncoder = new Swift_Mime_ContentEncoder_QpContentEncoder( + new Swift_CharacterStream_ArrayCharacterStream($factory, 'utf-8'), + new Swift_StreamFilters_ByteArrayReplacementFilter( + array(array(0x0D, 0x0A), array(0x0D), array(0x0A)), + array(array(0x0A), array(0x0A), array(0x0D, 0x0A)) + ) + ); + + $headerEncoder = new Swift_Mime_HeaderEncoder_QpHeaderEncoder( + new Swift_CharacterStream_ArrayCharacterStream($factory, 'utf-8') + ); + $paramEncoder = new Swift_Encoder_Rfc2231Encoder( + new Swift_CharacterStream_ArrayCharacterStream($factory, 'utf-8') + ); + $this->_grammar = new Swift_Mime_Grammar(); + $this->_headers = new Swift_Mime_SimpleHeaderSet( + new Swift_Mime_SimpleHeaderFactory($headerEncoder, $paramEncoder, $this->_grammar) + ); + } + + public function testCharsetIsSetInHeader() + { + $part = $this->_createMimePart(); + $part->setContentType('text/plain'); + $part->setCharset('utf-8'); + $part->setBody('foobar'); + $this->assertEquals( + 'Content-Type: text/plain; charset=utf-8' . "\r\n" . + 'Content-Transfer-Encoding: quoted-printable' . "\r\n" . + "\r\n" . + 'foobar', + $part->toString() + ); + } + + public function testFormatIsSetInHeaders() + { + $part = $this->_createMimePart(); + $part->setContentType('text/plain'); + $part->setFormat('flowed'); + $part->setBody('> foobar'); + $this->assertEquals( + 'Content-Type: text/plain; format=flowed' . "\r\n" . + 'Content-Transfer-Encoding: quoted-printable' . "\r\n" . + "\r\n" . + '> foobar', + $part->toString() + ); + } + + public function testDelSpIsSetInHeaders() + { + $part = $this->_createMimePart(); + $part->setContentType('text/plain'); + $part->setDelSp(true); + $part->setBody('foobar'); + $this->assertEquals( + 'Content-Type: text/plain; delsp=yes' . "\r\n" . + 'Content-Transfer-Encoding: quoted-printable' . "\r\n" . + "\r\n" . + 'foobar', + $part->toString() + ); + } + + public function testAll3ParamsInHeaders() + { + $part = $this->_createMimePart(); + $part->setContentType('text/plain'); + $part->setCharset('utf-8'); + $part->setFormat('fixed'); + $part->setDelSp(true); + $part->setBody('foobar'); + $this->assertEquals( + 'Content-Type: text/plain; charset=utf-8; format=fixed; delsp=yes' . "\r\n" . + 'Content-Transfer-Encoding: quoted-printable' . "\r\n" . + "\r\n" . + 'foobar', + $part->toString() + ); + } + + public function testBodyIsCanonicalized() + { + $part = $this->_createMimePart(); + $part->setContentType('text/plain'); + $part->setCharset('utf-8'); + $part->setBody("foobar\r\rtest\ning\r"); + $this->assertEquals( + 'Content-Type: text/plain; charset=utf-8' . "\r\n" . + 'Content-Transfer-Encoding: quoted-printable' . "\r\n" . + "\r\n" . + "foobar\r\n" . + "\r\n" . + "test\r\n" . + "ing\r\n", + $part->toString() + ); + } + + // -- Private helpers + + protected function _createMimePart() + { + $entity = new Swift_Mime_MimePart( + $this->_headers, + $this->_contentEncoder, + $this->_cache, + $this->_grammar + ); + + return $entity; + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/Mime/SimpleMessageAcceptanceTest.php b/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/Mime/SimpleMessageAcceptanceTest.php new file mode 100755 index 0000000..7929efa --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/Mime/SimpleMessageAcceptanceTest.php @@ -0,0 +1,1251 @@ +setCharset(null); //TODO: Test with the charset defined + } + + public function testBasicHeaders() + { + /* -- RFC 2822, 3.6. + */ + + $message = $this->_createMessage(); + $id = $message->getId(); + $date = $message->getDate(); + $this->assertEquals( + 'Message-ID: <' . $id . '>' . "\r\n" . + 'Date: ' . date('r', $date) . "\r\n" . + 'From: ' . "\r\n" . + 'MIME-Version: 1.0' . "\r\n" . + 'Content-Type: text/plain' . "\r\n" . + 'Content-Transfer-Encoding: quoted-printable' . "\r\n", + $message->toString(), + '%s: Only required headers, and non-empty headers should be displayed' + ); + } + + public function testSubjectIsDisplayedIfSet() + { + $message = $this->_createMessage(); + $message->setSubject('just a test subject'); + $id = $message->getId(); + $date = $message->getDate(); + $this->assertEquals( + 'Message-ID: <' . $id . '>' . "\r\n" . + 'Date: ' . date('r', $date) . "\r\n" . + 'Subject: just a test subject' . "\r\n" . + 'From: ' . "\r\n" . + 'MIME-Version: 1.0' . "\r\n" . + 'Content-Type: text/plain' . "\r\n" . + 'Content-Transfer-Encoding: quoted-printable' . "\r\n", + $message->toString() + ); + } + + public function testDateCanBeSet() + { + $message = $this->_createMessage(); + $message->setSubject('just a test subject'); + $id = $message->getId(); + $message->setDate(1234); + $this->assertEquals( + 'Message-ID: <' . $id . '>' . "\r\n" . + 'Date: ' . date('r', 1234) . "\r\n" . + 'Subject: just a test subject' . "\r\n" . + 'From: ' . "\r\n" . + 'MIME-Version: 1.0' . "\r\n" . + 'Content-Type: text/plain' . "\r\n" . + 'Content-Transfer-Encoding: quoted-printable' . "\r\n", + $message->toString() + ); + } + + public function testMessageIdCanBeSet() + { + $message = $this->_createMessage(); + $message->setSubject('just a test subject'); + $message->setId('foo@bar'); + $date = $message->getDate(); + $this->assertEquals( + 'Message-ID: ' . "\r\n" . + 'Date: ' . date('r', $date) . "\r\n" . + 'Subject: just a test subject' . "\r\n" . + 'From: ' . "\r\n" . + 'MIME-Version: 1.0' . "\r\n" . + 'Content-Type: text/plain' . "\r\n" . + 'Content-Transfer-Encoding: quoted-printable' . "\r\n", + $message->toString() + ); + } + + public function testContentTypeCanBeChanged() + { + $message = $this->_createMessage(); + $message->setSubject('just a test subject'); + $message->setContentType('text/html'); + $id = $message->getId(); + $date = $message->getDate(); + $this->assertEquals( + 'Message-ID: <' . $id . '>' . "\r\n" . + 'Date: ' . date('r', $date) . "\r\n" . + 'Subject: just a test subject' . "\r\n" . + 'From: ' . "\r\n" . + 'MIME-Version: 1.0' . "\r\n" . + 'Content-Type: text/html' . "\r\n" . + 'Content-Transfer-Encoding: quoted-printable' . "\r\n", + $message->toString() + ); + } + + public function testCharsetCanBeSet() + { + $message = $this->_createMessage(); + $message->setSubject('just a test subject'); + $message->setContentType('text/html'); + $message->setCharset('iso-8859-1'); + $id = $message->getId(); + $date = $message->getDate(); + $this->assertEquals( + 'Message-ID: <' . $id . '>' . "\r\n" . + 'Date: ' . date('r', $date) . "\r\n" . + 'Subject: just a test subject' . "\r\n" . + 'From: ' . "\r\n" . + 'MIME-Version: 1.0' . "\r\n" . + 'Content-Type: text/html; charset=iso-8859-1' . "\r\n" . + 'Content-Transfer-Encoding: quoted-printable' . "\r\n", + $message->toString() + ); + } + + public function testFormatCanBeSet() + { + $message = $this->_createMessage(); + $message->setSubject('just a test subject'); + $message->setFormat('flowed'); + $id = $message->getId(); + $date = $message->getDate(); + $this->assertEquals( + 'Message-ID: <' . $id . '>' . "\r\n" . + 'Date: ' . date('r', $date) . "\r\n" . + 'Subject: just a test subject' . "\r\n" . + 'From: ' . "\r\n" . + 'MIME-Version: 1.0' . "\r\n" . + 'Content-Type: text/plain; format=flowed' . "\r\n" . + 'Content-Transfer-Encoding: quoted-printable' . "\r\n", + $message->toString() + ); + } + + public function testEncoderCanBeSet() + { + $message = $this->_createMessage(); + $message->setSubject('just a test subject'); + $message->setContentType('text/html'); + $message->setEncoder( + new Swift_Mime_ContentEncoder_PlainContentEncoder('7bit') + ); + $id = $message->getId(); + $date = $message->getDate(); + $this->assertEquals( + 'Message-ID: <' . $id . '>' . "\r\n" . + 'Date: ' . date('r', $date) . "\r\n" . + 'Subject: just a test subject' . "\r\n" . + 'From: ' . "\r\n" . + 'MIME-Version: 1.0' . "\r\n" . + 'Content-Type: text/html' . "\r\n" . + 'Content-Transfer-Encoding: 7bit' . "\r\n", + $message->toString() + ); + } + + public function testFromAddressCanBeSet() + { + $message = $this->_createMessage(); + $message->setSubject('just a test subject'); + $message->setFrom('chris.corbyn@swiftmailer.org'); + $id = $message->getId(); + $date = $message->getDate(); + $this->assertEquals( + 'Message-ID: <' . $id . '>' . "\r\n" . + 'Date: ' . date('r', $date) . "\r\n" . + 'Subject: just a test subject' . "\r\n" . + 'From: chris.corbyn@swiftmailer.org' . "\r\n" . + 'MIME-Version: 1.0' . "\r\n" . + 'Content-Type: text/plain' . "\r\n" . + 'Content-Transfer-Encoding: quoted-printable' . "\r\n", + $message->toString() + ); + } + + public function testFromAddressCanBeSetWithName() + { + $message = $this->_createMessage(); + $message->setSubject('just a test subject'); + $message->setFrom(array('chris.corbyn@swiftmailer.org' => 'Chris Corbyn')); + $id = $message->getId(); + $date = $message->getDate(); + $this->assertEquals( + 'Message-ID: <' . $id . '>' . "\r\n" . + 'Date: ' . date('r', $date) . "\r\n" . + 'Subject: just a test subject' . "\r\n" . + 'From: Chris Corbyn ' . "\r\n" . + 'MIME-Version: 1.0' . "\r\n" . + 'Content-Type: text/plain' . "\r\n" . + 'Content-Transfer-Encoding: quoted-printable' . "\r\n", + $message->toString() + ); + } + + public function testMultipleFromAddressesCanBeSet() + { + $message = $this->_createMessage(); + $message->setSubject('just a test subject'); + $message->setFrom(array( + 'chris.corbyn@swiftmailer.org' => 'Chris Corbyn', + 'mark@swiftmailer.org' + )); + $id = $message->getId(); + $date = $message->getDate(); + $this->assertEquals( + 'Message-ID: <' . $id . '>' . "\r\n" . + 'Date: ' . date('r', $date) . "\r\n" . + 'Subject: just a test subject' . "\r\n" . + 'From: Chris Corbyn , mark@swiftmailer.org' . "\r\n" . + 'MIME-Version: 1.0' . "\r\n" . + 'Content-Type: text/plain' . "\r\n" . + 'Content-Transfer-Encoding: quoted-printable' . "\r\n", + $message->toString() + ); + } + + public function testReturnPathAddressCanBeSet() + { + $message = $this->_createMessage(); + $message->setReturnPath('chris@w3style.co.uk'); + $message->setSubject('just a test subject'); + $message->setFrom(array( + 'chris.corbyn@swiftmailer.org' => 'Chris Corbyn')); + $id = $message->getId(); + $date = $message->getDate(); + $this->assertEquals( + 'Return-Path: ' . "\r\n" . + 'Message-ID: <' . $id . '>' . "\r\n" . + 'Date: ' . date('r', $date) . "\r\n" . + 'Subject: just a test subject' . "\r\n" . + 'From: Chris Corbyn ' . "\r\n" . + 'MIME-Version: 1.0' . "\r\n" . + 'Content-Type: text/plain' . "\r\n" . + 'Content-Transfer-Encoding: quoted-printable' . "\r\n", + $message->toString() + ); + } + + public function testEmptyReturnPathHeaderCanBeUsed() + { + $message = $this->_createMessage(); + $message->setReturnPath(''); + $message->setSubject('just a test subject'); + $message->setFrom(array( + 'chris.corbyn@swiftmailer.org' => 'Chris Corbyn')); + $id = $message->getId(); + $date = $message->getDate(); + $this->assertEquals( + 'Return-Path: <>' . "\r\n" . + 'Message-ID: <' . $id . '>' . "\r\n" . + 'Date: ' . date('r', $date) . "\r\n" . + 'Subject: just a test subject' . "\r\n" . + 'From: Chris Corbyn ' . "\r\n" . + 'MIME-Version: 1.0' . "\r\n" . + 'Content-Type: text/plain' . "\r\n" . + 'Content-Transfer-Encoding: quoted-printable' . "\r\n", + $message->toString() + ); + } + + public function testSenderCanBeSet() + { + $message = $this->_createMessage(); + $message->setSubject('just a test subject'); + $message->setSender('chris.corbyn@swiftmailer.org'); + $id = $message->getId(); + $date = $message->getDate(); + $this->assertEquals( + 'Sender: chris.corbyn@swiftmailer.org' . "\r\n" . + 'Message-ID: <' . $id . '>' . "\r\n" . + 'Date: ' . date('r', $date) . "\r\n" . + 'Subject: just a test subject' . "\r\n" . + 'From: ' . "\r\n" . + 'MIME-Version: 1.0' . "\r\n" . + 'Content-Type: text/plain' . "\r\n" . + 'Content-Transfer-Encoding: quoted-printable' . "\r\n", + $message->toString() + ); + } + + public function testSenderCanBeSetWithName() + { + $message = $this->_createMessage(); + $message->setSubject('just a test subject'); + $message->setSender(array('chris.corbyn@swiftmailer.org'=>'Chris')); + $id = $message->getId(); + $date = $message->getDate(); + $this->assertEquals( + 'Sender: Chris ' . "\r\n" . + 'Message-ID: <' . $id . '>' . "\r\n" . + 'Date: ' . date('r', $date) . "\r\n" . + 'Subject: just a test subject' . "\r\n" . + 'From: ' . "\r\n" . + 'MIME-Version: 1.0' . "\r\n" . + 'Content-Type: text/plain' . "\r\n" . + 'Content-Transfer-Encoding: quoted-printable' . "\r\n", + $message->toString() + ); + } + + public function testReplyToCanBeSet() + { + $message = $this->_createMessage(); + $message->setSubject('just a test subject'); + $message->setFrom(array('chris.corbyn@swiftmailer.org'=>'Chris')); + $message->setReplyTo(array('chris@w3style.co.uk'=>'Myself')); + $id = $message->getId(); + $date = $message->getDate(); + $this->assertEquals( + 'Message-ID: <' . $id . '>' . "\r\n" . + 'Date: ' . date('r', $date) . "\r\n" . + 'Subject: just a test subject' . "\r\n" . + 'From: Chris ' . "\r\n" . + 'Reply-To: Myself ' . "\r\n" . + 'MIME-Version: 1.0' . "\r\n" . + 'Content-Type: text/plain' . "\r\n" . + 'Content-Transfer-Encoding: quoted-printable' . "\r\n", + $message->toString() + ); + } + + public function testMultipleReplyAddressCanBeUsed() + { + $message = $this->_createMessage(); + $message->setSubject('just a test subject'); + $message->setFrom(array('chris.corbyn@swiftmailer.org'=>'Chris')); + $message->setReplyTo(array( + 'chris@w3style.co.uk' => 'Myself', + 'my.other@address.com' => 'Me' + )); + $id = $message->getId(); + $date = $message->getDate(); + $this->assertEquals( + 'Message-ID: <' . $id . '>' . "\r\n" . + 'Date: ' . date('r', $date) . "\r\n" . + 'Subject: just a test subject' . "\r\n" . + 'From: Chris ' . "\r\n" . + 'Reply-To: Myself , Me ' . "\r\n" . + 'MIME-Version: 1.0' . "\r\n" . + 'Content-Type: text/plain' . "\r\n" . + 'Content-Transfer-Encoding: quoted-printable' . "\r\n", + $message->toString() + ); + } + + public function testToAddressCanBeSet() + { + $message = $this->_createMessage(); + $message->setSubject('just a test subject'); + $message->setFrom(array('chris.corbyn@swiftmailer.org'=>'Chris')); + $message->setReplyTo(array( + 'chris@w3style.co.uk' => 'Myself', + 'my.other@address.com' => 'Me' + )); + $message->setTo('mark@swiftmailer.org'); + $id = $message->getId(); + $date = $message->getDate(); + $this->assertEquals( + 'Message-ID: <' . $id . '>' . "\r\n" . + 'Date: ' . date('r', $date) . "\r\n" . + 'Subject: just a test subject' . "\r\n" . + 'From: Chris ' . "\r\n" . + 'Reply-To: Myself , Me ' . "\r\n" . + 'To: mark@swiftmailer.org' . "\r\n" . + 'MIME-Version: 1.0' . "\r\n" . + 'Content-Type: text/plain' . "\r\n" . + 'Content-Transfer-Encoding: quoted-printable' . "\r\n", + $message->toString() + ); + } + + public function testMultipleToAddressesCanBeSet() + { + $message = $this->_createMessage(); + $message->setSubject('just a test subject'); + $message->setFrom(array('chris.corbyn@swiftmailer.org'=>'Chris')); + $message->setReplyTo(array( + 'chris@w3style.co.uk' => 'Myself', + 'my.other@address.com' => 'Me' + )); + $message->setTo(array( + 'mark@swiftmailer.org', 'chris@swiftmailer.org' => 'Chris Corbyn' + )); + $id = $message->getId(); + $date = $message->getDate(); + $this->assertEquals( + 'Message-ID: <' . $id . '>' . "\r\n" . + 'Date: ' . date('r', $date) . "\r\n" . + 'Subject: just a test subject' . "\r\n" . + 'From: Chris ' . "\r\n" . + 'Reply-To: Myself , Me ' . "\r\n" . + 'To: mark@swiftmailer.org, Chris Corbyn ' . "\r\n" . + 'MIME-Version: 1.0' . "\r\n" . + 'Content-Type: text/plain' . "\r\n" . + 'Content-Transfer-Encoding: quoted-printable' . "\r\n", + $message->toString() + ); + } + + public function testCcAddressCanBeSet() + { + $message = $this->_createMessage(); + $message->setSubject('just a test subject'); + $message->setFrom(array('chris.corbyn@swiftmailer.org'=>'Chris')); + $message->setReplyTo(array( + 'chris@w3style.co.uk' => 'Myself', + 'my.other@address.com' => 'Me' + )); + $message->setTo(array( + 'mark@swiftmailer.org', 'chris@swiftmailer.org' => 'Chris Corbyn' + )); + $message->setCc('john@some-site.com'); + $id = $message->getId(); + $date = $message->getDate(); + $this->assertEquals( + 'Message-ID: <' . $id . '>' . "\r\n" . + 'Date: ' . date('r', $date) . "\r\n" . + 'Subject: just a test subject' . "\r\n" . + 'From: Chris ' . "\r\n" . + 'Reply-To: Myself , Me ' . "\r\n" . + 'To: mark@swiftmailer.org, Chris Corbyn ' . "\r\n" . + 'Cc: john@some-site.com' . "\r\n" . + 'MIME-Version: 1.0' . "\r\n" . + 'Content-Type: text/plain' . "\r\n" . + 'Content-Transfer-Encoding: quoted-printable' . "\r\n", + $message->toString() + ); + } + + public function testMultipleCcAddressesCanBeSet() + { + $message = $this->_createMessage(); + $message->setSubject('just a test subject'); + $message->setFrom(array('chris.corbyn@swiftmailer.org'=>'Chris')); + $message->setReplyTo(array( + 'chris@w3style.co.uk' => 'Myself', + 'my.other@address.com' => 'Me' + )); + $message->setTo(array( + 'mark@swiftmailer.org', 'chris@swiftmailer.org' => 'Chris Corbyn' + )); + $message->setCc(array( + 'john@some-site.com' => 'John West', + 'fred@another-site.co.uk' => 'Big Fred' + )); + $id = $message->getId(); + $date = $message->getDate(); + $this->assertEquals( + 'Message-ID: <' . $id . '>' . "\r\n" . + 'Date: ' . date('r', $date) . "\r\n" . + 'Subject: just a test subject' . "\r\n" . + 'From: Chris ' . "\r\n" . + 'Reply-To: Myself , Me ' . "\r\n" . + 'To: mark@swiftmailer.org, Chris Corbyn ' . "\r\n" . + 'Cc: John West , Big Fred ' . "\r\n" . + 'MIME-Version: 1.0' . "\r\n" . + 'Content-Type: text/plain' . "\r\n" . + 'Content-Transfer-Encoding: quoted-printable' . "\r\n", + $message->toString() + ); + } + + public function testBccAddressCanBeSet() + { + //Obviously Transports need to setBcc(array()) and send to each Bcc recipient + // separately in accordance with RFC 2822/2821 + $message = $this->_createMessage(); + $message->setSubject('just a test subject'); + $message->setFrom(array('chris.corbyn@swiftmailer.org'=>'Chris')); + $message->setReplyTo(array( + 'chris@w3style.co.uk' => 'Myself', + 'my.other@address.com' => 'Me' + )); + $message->setTo(array( + 'mark@swiftmailer.org', 'chris@swiftmailer.org' => 'Chris Corbyn' + )); + $message->setCc(array( + 'john@some-site.com' => 'John West', + 'fred@another-site.co.uk' => 'Big Fred' + )); + $message->setBcc('x@alphabet.tld'); + $id = $message->getId(); + $date = $message->getDate(); + $this->assertEquals( + 'Message-ID: <' . $id . '>' . "\r\n" . + 'Date: ' . date('r', $date) . "\r\n" . + 'Subject: just a test subject' . "\r\n" . + 'From: Chris ' . "\r\n" . + 'Reply-To: Myself , Me ' . "\r\n" . + 'To: mark@swiftmailer.org, Chris Corbyn ' . "\r\n" . + 'Cc: John West , Big Fred ' . "\r\n" . + 'Bcc: x@alphabet.tld' . "\r\n" . + 'MIME-Version: 1.0' . "\r\n" . + 'Content-Type: text/plain' . "\r\n" . + 'Content-Transfer-Encoding: quoted-printable' . "\r\n", + $message->toString() + ); + } + + public function testMultipleBccAddressesCanBeSet() + { + //Obviously Transports need to setBcc(array()) and send to each Bcc recipient + // separately in accordance with RFC 2822/2821 + $message = $this->_createMessage(); + $message->setSubject('just a test subject'); + $message->setFrom(array('chris.corbyn@swiftmailer.org'=>'Chris')); + $message->setReplyTo(array( + 'chris@w3style.co.uk' => 'Myself', + 'my.other@address.com' => 'Me' + )); + $message->setTo(array( + 'mark@swiftmailer.org', 'chris@swiftmailer.org' => 'Chris Corbyn' + )); + $message->setCc(array( + 'john@some-site.com' => 'John West', + 'fred@another-site.co.uk' => 'Big Fred' + )); + $message->setBcc(array('x@alphabet.tld', 'a@alphabet.tld' => 'A')); + $id = $message->getId(); + $date = $message->getDate(); + $this->assertEquals( + 'Message-ID: <' . $id . '>' . "\r\n" . + 'Date: ' . date('r', $date) . "\r\n" . + 'Subject: just a test subject' . "\r\n" . + 'From: Chris ' . "\r\n" . + 'Reply-To: Myself , Me ' . "\r\n" . + 'To: mark@swiftmailer.org, Chris Corbyn ' . "\r\n" . + 'Cc: John West , Big Fred ' . "\r\n" . + 'Bcc: x@alphabet.tld, A ' . "\r\n" . + 'MIME-Version: 1.0' . "\r\n" . + 'Content-Type: text/plain' . "\r\n" . + 'Content-Transfer-Encoding: quoted-printable' . "\r\n", + $message->toString() + ); + } + + public function testStringBodyIsAppended() + { + $message = $this->_createMessage(); + $message->setReturnPath('chris@w3style.co.uk'); + $message->setSubject('just a test subject'); + $message->setFrom(array( + 'chris.corbyn@swiftmailer.org' => 'Chris Corbyn')); + $message->setBody( + 'just a test body' . "\r\n" . + 'with a new line' + ); + $id = $message->getId(); + $date = $message->getDate(); + $this->assertEquals( + 'Return-Path: ' . "\r\n" . + 'Message-ID: <' . $id . '>' . "\r\n" . + 'Date: ' . date('r', $date) . "\r\n" . + 'Subject: just a test subject' . "\r\n" . + 'From: Chris Corbyn ' . "\r\n" . + 'MIME-Version: 1.0' . "\r\n" . + 'Content-Type: text/plain' . "\r\n" . + 'Content-Transfer-Encoding: quoted-printable' . "\r\n" . + "\r\n" . + 'just a test body' . "\r\n" . + 'with a new line', + $message->toString() + ); + } + + public function testStringBodyIsEncoded() + { + $message = $this->_createMessage(); + $message->setReturnPath('chris@w3style.co.uk'); + $message->setSubject('just a test subject'); + $message->setFrom(array( + 'chris.corbyn@swiftmailer.org' => 'Chris Corbyn')); + $message->setBody( + 'Just s' . pack('C*', 0xC2, 0x01, 0x01) . 'me multi-' . "\r\n" . + 'line message!' + ); + $id = $message->getId(); + $date = $message->getDate(); + $this->assertEquals( + 'Return-Path: ' . "\r\n" . + 'Message-ID: <' . $id . '>' . "\r\n" . + 'Date: ' . date('r', $date) . "\r\n" . + 'Subject: just a test subject' . "\r\n" . + 'From: Chris Corbyn ' . "\r\n" . + 'MIME-Version: 1.0' . "\r\n" . + 'Content-Type: text/plain' . "\r\n" . + 'Content-Transfer-Encoding: quoted-printable' . "\r\n" . + "\r\n" . + 'Just s=C2=01=01me multi-' . "\r\n" . + 'line message!', + $message->toString() + ); + } + + public function testChildrenCanBeAttached() + { + $message = $this->_createMessage(); + $message->setReturnPath('chris@w3style.co.uk'); + $message->setSubject('just a test subject'); + $message->setFrom(array( + 'chris.corbyn@swiftmailer.org' => 'Chris Corbyn')); + + $id = $message->getId(); + $date = $message->getDate(); + $boundary = $message->getBoundary(); + + $part1 = $this->_createMimePart(); + $part1->setContentType('text/plain'); + $part1->setCharset('iso-8859-1'); + $part1->setBody('foo'); + + $message->attach($part1); + + $part2 = $this->_createMimePart(); + $part2->setContentType('text/html'); + $part2->setCharset('iso-8859-1'); + $part2->setBody('test foo'); + + $message->attach($part2); + + $this->assertEquals( + 'Return-Path: ' . "\r\n" . + 'Message-ID: <' . $id . '>' . "\r\n" . + 'Date: ' . date('r', $date) . "\r\n" . + 'Subject: just a test subject' . "\r\n" . + 'From: Chris Corbyn ' . "\r\n" . + 'MIME-Version: 1.0' . "\r\n" . + 'Content-Type: multipart/alternative;' . "\r\n" . + ' boundary="' . $boundary . '"' . "\r\n" . + "\r\n\r\n" . + '--' . $boundary . "\r\n" . + 'Content-Type: text/plain; charset=iso-8859-1' . "\r\n" . + 'Content-Transfer-Encoding: quoted-printable' . "\r\n" . + "\r\n" . + 'foo' . + "\r\n\r\n" . + '--' . $boundary . "\r\n" . + 'Content-Type: text/html; charset=iso-8859-1' . "\r\n" . + 'Content-Transfer-Encoding: quoted-printable' . "\r\n" . + "\r\n" . + 'test foo' . + "\r\n\r\n" . + '--' . $boundary . '--' . "\r\n", + $message->toString() + ); + } + + public function testAttachmentsBeingAttached() + { + $message = $this->_createMessage(); + $message->setReturnPath('chris@w3style.co.uk'); + $message->setSubject('just a test subject'); + $message->setFrom(array( + 'chris.corbyn@swiftmailer.org' => 'Chris Corbyn')); + + $id = $message->getId(); + $date = preg_quote(date('r', $message->getDate()), '~'); + $boundary = $message->getBoundary(); + + $part = $this->_createMimePart(); + $part->setContentType('text/plain'); + $part->setCharset('iso-8859-1'); + $part->setBody('foo'); + + $message->attach($part); + + $attachment = $this->_createAttachment(); + $attachment->setContentType('application/pdf'); + $attachment->setFilename('foo.pdf'); + $attachment->setBody(''); + + $message->attach($attachment); + + $this->assertRegExp( + '~^' . + 'Return-Path: ' . "\r\n" . + 'Message-ID: <' . $id . '>' . "\r\n" . + 'Date: ' . $date . "\r\n" . + 'Subject: just a test subject' . "\r\n" . + 'From: Chris Corbyn ' . "\r\n" . + 'MIME-Version: 1.0' . "\r\n" . + 'Content-Type: multipart/mixed;' . "\r\n" . + ' boundary="' . $boundary . '"' . "\r\n" . + "\r\n\r\n" . + '--' . $boundary . "\r\n" . + 'Content-Type: multipart/alternative;' . "\r\n" . + ' boundary="(.*?)"' . "\r\n" . + "\r\n\r\n" . + '--\\1' . "\r\n" . + 'Content-Type: text/plain; charset=iso-8859-1' . "\r\n" . + 'Content-Transfer-Encoding: quoted-printable' . "\r\n" . + "\r\n" . + 'foo' . + "\r\n\r\n" . + '--\\1--' . "\r\n" . + "\r\n\r\n" . + '--' . $boundary . "\r\n" . + 'Content-Type: application/pdf; name=foo.pdf' . "\r\n" . + 'Content-Transfer-Encoding: base64' . "\r\n" . + 'Content-Disposition: attachment; filename=foo.pdf' . "\r\n" . + "\r\n" . + preg_quote(base64_encode(''), '~') . + "\r\n\r\n" . + '--' . $boundary . '--' . "\r\n" . + '$~D', + $message->toString() + ); + } + + public function testAttachmentsAndEmbeddedFilesBeingAttached() + { + $message = $this->_createMessage(); + $message->setReturnPath('chris@w3style.co.uk'); + $message->setSubject('just a test subject'); + $message->setFrom(array( + 'chris.corbyn@swiftmailer.org' => 'Chris Corbyn')); + + $id = $message->getId(); + $date = preg_quote(date('r', $message->getDate()), '~'); + $boundary = $message->getBoundary(); + + $part = $this->_createMimePart(); + $part->setContentType('text/plain'); + $part->setCharset('iso-8859-1'); + $part->setBody('foo'); + + $message->attach($part); + + $attachment = $this->_createAttachment(); + $attachment->setContentType('application/pdf'); + $attachment->setFilename('foo.pdf'); + $attachment->setBody(''); + + $message->attach($attachment); + + $file = $this->_createEmbeddedFile(); + $file->setContentType('image/jpeg'); + $file->setFilename('myimage.jpg'); + $file->setBody(''); + + $message->attach($file); + + $cid = $file->getId(); + + $this->assertRegExp( + '~^' . + 'Return-Path: ' . "\r\n" . + 'Message-ID: <' . $id . '>' . "\r\n" . + 'Date: ' . $date . "\r\n" . + 'Subject: just a test subject' . "\r\n" . + 'From: Chris Corbyn ' . "\r\n" . + 'MIME-Version: 1.0' . "\r\n" . + 'Content-Type: multipart/mixed;' . "\r\n" . + ' boundary="' . $boundary . '"' . "\r\n" . + "\r\n\r\n" . + '--' . $boundary . "\r\n" . + 'Content-Type: multipart/alternative;' . "\r\n" . + ' boundary="(.*?)"' . "\r\n" . + "\r\n\r\n" . + '--\\1' . "\r\n" . + 'Content-Type: text/plain; charset=iso-8859-1' . "\r\n" . + 'Content-Transfer-Encoding: quoted-printable' . "\r\n" . + "\r\n" . + 'foo' . + + "\r\n\r\n" . + '--\\1' . "\r\n" . + 'Content-Type: multipart/related;' . "\r\n" . + ' boundary="(.*?)"' . "\r\n" . + "\r\n\r\n" . + '--\\2' . "\r\n" . + 'Content-Type: image/jpeg; name=myimage.jpg' . "\r\n" . + 'Content-Transfer-Encoding: base64' . "\r\n" . + 'Content-Disposition: inline; filename=myimage.jpg' . "\r\n" . + 'Content-ID: <' . $cid . '>' . "\r\n" . + "\r\n" . + preg_quote(base64_encode(''), '~') . + "\r\n\r\n" . + '--\\2--' . "\r\n" . + "\r\n\r\n" . + '--\\1--' . "\r\n" . + "\r\n\r\n" . + '--' . $boundary . "\r\n" . + 'Content-Type: application/pdf; name=foo.pdf' . "\r\n" . + 'Content-Transfer-Encoding: base64' . "\r\n" . + 'Content-Disposition: attachment; filename=foo.pdf' . "\r\n" . + "\r\n" . + preg_quote(base64_encode(''), '~') . + "\r\n\r\n" . + '--' . $boundary . '--' . "\r\n" . + '$~D', + $message->toString() + ); + } + + public function testComplexEmbeddingOfContent() + { + $message = $this->_createMessage(); + $message->setReturnPath('chris@w3style.co.uk'); + $message->setSubject('just a test subject'); + $message->setFrom(array( + 'chris.corbyn@swiftmailer.org' => 'Chris Corbyn')); + + $id = $message->getId(); + $date = preg_quote(date('r', $message->getDate()), '~'); + $boundary = $message->getBoundary(); + + $attachment = $this->_createAttachment(); + $attachment->setContentType('application/pdf'); + $attachment->setFilename('foo.pdf'); + $attachment->setBody(''); + + $message->attach($attachment); + + $file = $this->_createEmbeddedFile(); + $file->setContentType('image/jpeg'); + $file->setFilename('myimage.jpg'); + $file->setBody(''); + + $part = $this->_createMimePart(); + $part->setContentType('text/html'); + $part->setCharset('iso-8859-1'); + $part->setBody('foo '); + + $message->attach($part); + + $cid = $file->getId(); + + $this->assertRegExp( + '~^' . + 'Return-Path: ' . "\r\n" . + 'Message-ID: <' . $id . '>' . "\r\n" . + 'Date: ' . $date . "\r\n" . + 'Subject: just a test subject' . "\r\n" . + 'From: Chris Corbyn ' . "\r\n" . + 'MIME-Version: 1.0' . "\r\n" . + 'Content-Type: multipart/mixed;' . "\r\n" . + ' boundary="' . $boundary . '"' . "\r\n" . + "\r\n\r\n" . + '--' . $boundary . "\r\n" . + 'Content-Type: multipart/related;' . "\r\n" . + ' boundary="(.*?)"' . "\r\n" . + "\r\n\r\n" . + '--\\1' . "\r\n" . + 'Content-Type: text/html; charset=iso-8859-1' . "\r\n" . + 'Content-Transfer-Encoding: quoted-printable' . "\r\n" . + "\r\n" . + 'foo ' . //=3D is just = in QP + "\r\n\r\n" . + '--\\1' . "\r\n" . + 'Content-Type: image/jpeg; name=myimage.jpg' . "\r\n" . + 'Content-Transfer-Encoding: base64' . "\r\n" . + 'Content-Disposition: inline; filename=myimage.jpg' . "\r\n" . + 'Content-ID: <' . $cid . '>' . "\r\n" . + "\r\n" . + preg_quote(base64_encode(''), '~') . + "\r\n\r\n" . + '--\\1--' . "\r\n" . + "\r\n\r\n" . + '--' . $boundary . "\r\n" . + 'Content-Type: application/pdf; name=foo.pdf' . "\r\n" . + 'Content-Transfer-Encoding: base64' . "\r\n" . + 'Content-Disposition: attachment; filename=foo.pdf' . "\r\n" . + "\r\n" . + preg_quote(base64_encode(''), '~') . + "\r\n\r\n" . + '--' . $boundary . '--' . "\r\n" . + '$~D', + $message->toString() + ); + } + + public function testAttachingAndDetachingContent() + { + $message = $this->_createMessage(); + $message->setReturnPath('chris@w3style.co.uk'); + $message->setSubject('just a test subject'); + $message->setFrom(array( + 'chris.corbyn@swiftmailer.org' => 'Chris Corbyn')); + + $id = $message->getId(); + $date = preg_quote(date('r', $message->getDate()), '~'); + $boundary = $message->getBoundary(); + + $part = $this->_createMimePart(); + $part->setContentType('text/plain'); + $part->setCharset('iso-8859-1'); + $part->setBody('foo'); + + $message->attach($part); + + $attachment = $this->_createAttachment(); + $attachment->setContentType('application/pdf'); + $attachment->setFilename('foo.pdf'); + $attachment->setBody(''); + + $message->attach($attachment); + + $file = $this->_createEmbeddedFile(); + $file->setContentType('image/jpeg'); + $file->setFilename('myimage.jpg'); + $file->setBody(''); + + $message->attach($file); + + $cid = $file->getId(); + + $message->detach($attachment); + + $this->assertRegExp( + '~^' . + 'Return-Path: ' . "\r\n" . + 'Message-ID: <' . $id . '>' . "\r\n" . + 'Date: ' . $date . "\r\n" . + 'Subject: just a test subject' . "\r\n" . + 'From: Chris Corbyn ' . "\r\n" . + 'MIME-Version: 1.0' . "\r\n" . + 'Content-Type: multipart/alternative;' . "\r\n" . + ' boundary="' . $boundary . '"' . "\r\n" . + "\r\n\r\n" . + '--' . $boundary . "\r\n" . + 'Content-Type: text/plain; charset=iso-8859-1' . "\r\n" . + 'Content-Transfer-Encoding: quoted-printable' . "\r\n" . + "\r\n" . + 'foo' . + "\r\n\r\n" . + '--' . $boundary . "\r\n" . + 'Content-Type: multipart/related;' . "\r\n" . + ' boundary="(.*?)"' . "\r\n" . + "\r\n\r\n" . + '--\\1' . "\r\n" . + 'Content-Type: image/jpeg; name=myimage.jpg' . "\r\n" . + 'Content-Transfer-Encoding: base64' . "\r\n" . + 'Content-Disposition: inline; filename=myimage.jpg' . "\r\n" . + 'Content-ID: <' . $cid . '>' . "\r\n" . + "\r\n" . + preg_quote(base64_encode(''), '~') . + "\r\n\r\n" . + '--\\1--' . "\r\n" . + "\r\n\r\n" . + '--' . $boundary . '--' . "\r\n" . + '$~D', + $message->toString(), + '%s: Attachment should have been detached' + ); + } + + public function testBoundaryDoesNotAppearAfterAllPartsAreDetached() + { + $message = $this->_createMessage(); + $message->setReturnPath('chris@w3style.co.uk'); + $message->setSubject('just a test subject'); + $message->setFrom(array( + 'chris.corbyn@swiftmailer.org' => 'Chris Corbyn')); + + $id = $message->getId(); + $date = $message->getDate(); + $boundary = $message->getBoundary(); + + $part1 = $this->_createMimePart(); + $part1->setContentType('text/plain'); + $part1->setCharset('iso-8859-1'); + $part1->setBody('foo'); + + $message->attach($part1); + + $part2 = $this->_createMimePart(); + $part2->setContentType('text/html'); + $part2->setCharset('iso-8859-1'); + $part2->setBody('test foo'); + + $message->attach($part2); + + $message->detach($part1); + $message->detach($part2); + + $this->assertEquals( + 'Return-Path: ' . "\r\n" . + 'Message-ID: <' . $id . '>' . "\r\n" . + 'Date: ' . date('r', $date) . "\r\n" . + 'Subject: just a test subject' . "\r\n" . + 'From: Chris Corbyn ' . "\r\n" . + 'MIME-Version: 1.0' . "\r\n" . + 'Content-Type: text/plain' . "\r\n" . + 'Content-Transfer-Encoding: quoted-printable' . "\r\n", + $message->toString(), + '%s: Message should be restored to orignal state after parts are detached' + ); + } + + public function testCharsetFormatOrDelSpAreNotShownWhenBoundaryIsSet() + { + $message = $this->_createMessage(); + $message->setReturnPath('chris@w3style.co.uk'); + $message->setSubject('just a test subject'); + $message->setFrom(array( + 'chris.corbyn@swiftmailer.org' => 'Chris Corbyn')); + $message->setCharset('utf-8'); + $message->setFormat('flowed'); + $message->setDelSp(true); + + $id = $message->getId(); + $date = $message->getDate(); + $boundary = $message->getBoundary(); + + $part1 = $this->_createMimePart(); + $part1->setContentType('text/plain'); + $part1->setCharset('iso-8859-1'); + $part1->setBody('foo'); + + $message->attach($part1); + + $part2 = $this->_createMimePart(); + $part2->setContentType('text/html'); + $part2->setCharset('iso-8859-1'); + $part2->setBody('test foo'); + + $message->attach($part2); + + $this->assertEquals( + 'Return-Path: ' . "\r\n" . + 'Message-ID: <' . $id . '>' . "\r\n" . + 'Date: ' . date('r', $date) . "\r\n" . + 'Subject: just a test subject' . "\r\n" . + 'From: Chris Corbyn ' . "\r\n" . + 'MIME-Version: 1.0' . "\r\n" . + 'Content-Type: multipart/alternative;' . "\r\n" . + ' boundary="' . $boundary . '"' . "\r\n" . + "\r\n\r\n" . + '--' . $boundary . "\r\n" . + 'Content-Type: text/plain; charset=iso-8859-1' . "\r\n" . + 'Content-Transfer-Encoding: quoted-printable' . "\r\n" . + "\r\n" . + 'foo' . + "\r\n\r\n" . + '--' . $boundary . "\r\n" . + 'Content-Type: text/html; charset=iso-8859-1' . "\r\n" . + 'Content-Transfer-Encoding: quoted-printable' . "\r\n" . + "\r\n" . + 'test foo' . + "\r\n\r\n" . + '--' . $boundary . '--' . "\r\n", + $message->toString() + ); + } + + public function testBodyCanBeSetWithAttachments() + { + $message = $this->_createMessage(); + $message->setReturnPath('chris@w3style.co.uk'); + $message->setSubject('just a test subject'); + $message->setFrom(array( + 'chris.corbyn@swiftmailer.org' => 'Chris Corbyn')); + $message->setContentType('text/html'); + $message->setCharset('iso-8859-1'); + $message->setBody('foo'); + + $id = $message->getId(); + $date = date('r', $message->getDate()); + $boundary = $message->getBoundary(); + + $attachment = $this->_createAttachment(); + $attachment->setContentType('application/pdf'); + $attachment->setFilename('foo.pdf'); + $attachment->setBody(''); + + $message->attach($attachment); + + $this->assertEquals( + 'Return-Path: ' . "\r\n" . + 'Message-ID: <' . $id . '>' . "\r\n" . + 'Date: ' . $date . "\r\n" . + 'Subject: just a test subject' . "\r\n" . + 'From: Chris Corbyn ' . "\r\n" . + 'MIME-Version: 1.0' . "\r\n" . + 'Content-Type: multipart/mixed;' . "\r\n" . + ' boundary="' . $boundary . '"' . "\r\n" . + "\r\n\r\n" . + '--' . $boundary . "\r\n" . + 'Content-Type: text/html; charset=iso-8859-1' . "\r\n" . + 'Content-Transfer-Encoding: quoted-printable' . "\r\n" . + "\r\n" . + 'foo' . + "\r\n\r\n" . + '--' . $boundary . "\r\n" . + 'Content-Type: application/pdf; name=foo.pdf' . "\r\n" . + 'Content-Transfer-Encoding: base64' . "\r\n" . + 'Content-Disposition: attachment; filename=foo.pdf' . "\r\n" . + "\r\n" . + base64_encode('') . + "\r\n\r\n" . + '--' . $boundary . '--' . "\r\n", + $message->toString() + ); + } + + public function testHtmlPartAlwaysAppearsLast() + { + $message = $this->_createMessage(); + $message->setReturnPath('chris@w3style.co.uk'); + $message->setSubject('just a test subject'); + $message->setFrom(array( + 'chris.corbyn@swiftmailer.org' => 'Chris Corbyn')); + + $id = $message->getId(); + $date = date('r', $message->getDate()); + $boundary = $message->getBoundary(); + + $part1 = $this->_createMimePart(); + $part1->setContentType('text/html'); + $part1->setBody('foo'); + + $part2 = $this->_createMimePart(); + $part2->setContentType('text/plain'); + $part2->setBody('bar'); + + $message->attach($part1); + $message->attach($part2); + + $this->assertEquals( + 'Return-Path: ' . "\r\n" . + 'Message-ID: <' . $id . '>' . "\r\n" . + 'Date: ' . $date . "\r\n" . + 'Subject: just a test subject' . "\r\n" . + 'From: Chris Corbyn ' . "\r\n" . + 'MIME-Version: 1.0' . "\r\n" . + 'Content-Type: multipart/alternative;' . "\r\n" . + ' boundary="' . $boundary . '"' . "\r\n" . + "\r\n\r\n" . + '--' . $boundary . "\r\n" . + 'Content-Type: text/plain' . "\r\n" . + 'Content-Transfer-Encoding: quoted-printable' . "\r\n" . + "\r\n" . + 'bar' . + "\r\n\r\n" . + '--' . $boundary . "\r\n" . + 'Content-Type: text/html' . "\r\n" . + 'Content-Transfer-Encoding: quoted-printable' . "\r\n" . + "\r\n" . + 'foo' . + "\r\n\r\n" . + '--' . $boundary . '--' . "\r\n", + $message->toString() + ); + } + + public function testBodyBecomesPartIfOtherPartsAttached() + { + $message = $this->_createMessage(); + $message->setReturnPath('chris@w3style.co.uk'); + $message->setSubject('just a test subject'); + $message->setFrom(array( + 'chris.corbyn@swiftmailer.org' => 'Chris Corbyn')); + $message->setContentType('text/html'); + $message->setBody('foo'); + + $id = $message->getId(); + $date = date('r', $message->getDate()); + $boundary = $message->getBoundary(); + + $part2 = $this->_createMimePart(); + $part2->setContentType('text/plain'); + $part2->setBody('bar'); + + $message->attach($part2); + + $this->assertEquals( + 'Return-Path: ' . "\r\n" . + 'Message-ID: <' . $id . '>' . "\r\n" . + 'Date: ' . $date . "\r\n" . + 'Subject: just a test subject' . "\r\n" . + 'From: Chris Corbyn ' . "\r\n" . + 'MIME-Version: 1.0' . "\r\n" . + 'Content-Type: multipart/alternative;' . "\r\n" . + ' boundary="' . $boundary . '"' . "\r\n" . + "\r\n\r\n" . + '--' . $boundary . "\r\n" . + 'Content-Type: text/plain' . "\r\n" . + 'Content-Transfer-Encoding: quoted-printable' . "\r\n" . + "\r\n" . + 'bar' . + "\r\n\r\n" . + '--' . $boundary . "\r\n" . + 'Content-Type: text/html' . "\r\n" . + 'Content-Transfer-Encoding: quoted-printable' . "\r\n" . + "\r\n" . + 'foo' . + "\r\n\r\n" . + '--' . $boundary . '--' . "\r\n", + $message->toString() + ); + } + + public function testBodyIsCanonicalized() + { + $message = $this->_createMessage(); + $message->setReturnPath('chris@w3style.co.uk'); + $message->setSubject('just a test subject'); + $message->setFrom(array( + 'chris.corbyn@swiftmailer.org' => 'Chris Corbyn')); + $message->setBody( + 'just a test body' . "\n" . + 'with a new line' + ); + $id = $message->getId(); + $date = $message->getDate(); + $this->assertEquals( + 'Return-Path: ' . "\r\n" . + 'Message-ID: <' . $id . '>' . "\r\n" . + 'Date: ' . date('r', $date) . "\r\n" . + 'Subject: just a test subject' . "\r\n" . + 'From: Chris Corbyn ' . "\r\n" . + 'MIME-Version: 1.0' . "\r\n" . + 'Content-Type: text/plain' . "\r\n" . + 'Content-Transfer-Encoding: quoted-printable' . "\r\n" . + "\r\n" . + 'just a test body' . "\r\n" . + 'with a new line', + $message->toString() + ); + } + + // -- Private helpers + + protected function _createMessage() + { + return new Swift_Message(); + } + + protected function _createMimePart() + { + return new Swift_MimePart(); + } + + protected function _createAttachment() + { + return new Swift_Attachment(); + } + + protected function _createEmbeddedFile() + { + return new Swift_EmbeddedFile(); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/MimePartAcceptanceTest.php b/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/MimePartAcceptanceTest.php new file mode 100755 index 0000000..3ec53e1 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/MimePartAcceptanceTest.php @@ -0,0 +1,15 @@ +register('properties.charset')->asValue(null); + + return Swift_MimePart::newInstance(); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/Transport/StreamBuffer/AbstractStreamBufferAcceptanceTest.php b/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/Transport/StreamBuffer/AbstractStreamBufferAcceptanceTest.php new file mode 100755 index 0000000..c5eb636 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/Transport/StreamBuffer/AbstractStreamBufferAcceptanceTest.php @@ -0,0 +1,134 @@ +markTestSkipped( + 'Will fail on travis-ci if not skipped due to travis blocking ' . + 'socket mailing tcp connections.' + ); + } + + $this->_buffer = new Swift_Transport_StreamBuffer( + $this->getMock('Swift_ReplacementFilterFactory') + ); + } + + public function testReadLine() + { + $this->_initializeBuffer(); + + $line = $this->_buffer->readLine(0); + $this->assertRegExp('/^[0-9]{3}.*?\r\n$/D', $line); + $seq = $this->_buffer->write("QUIT\r\n"); + $this->assertTrue((bool) $seq); + $line = $this->_buffer->readLine($seq); + $this->assertRegExp('/^[0-9]{3}.*?\r\n$/D', $line); + $this->_buffer->terminate(); + } + + public function testWrite() + { + $this->_initializeBuffer(); + + $line = $this->_buffer->readLine(0); + $this->assertRegExp('/^[0-9]{3}.*?\r\n$/D', $line); + + $seq = $this->_buffer->write("HELO foo\r\n"); + $this->assertTrue((bool)$seq); + $line = $this->_buffer->readLine($seq); + $this->assertRegExp('/^[0-9]{3}.*?\r\n$/D', $line); + + $seq = $this->_buffer->write("QUIT\r\n"); + $this->assertTrue((bool) $seq); + $line = $this->_buffer->readLine($seq); + $this->assertRegExp('/^[0-9]{3}.*?\r\n$/D', $line); + $this->_buffer->terminate(); + } + + public function testBindingOtherStreamsMirrorsWriteOperations() + { + $this->_initializeBuffer(); + + $is1 = $this->_createMockInputStream(); + $is2 = $this->_createMockInputStream(); + + $is1->expects($this->at(0)) + ->method('write') + ->with('x'); + $is1->expects($this->at(1)) + ->method('write') + ->with('y'); + $is2->expects($this->at(0)) + ->method('write') + ->with('x'); + $is2->expects($this->at(1)) + ->method('write') + ->with('y'); + + $this->_buffer->bind($is1); + $this->_buffer->bind($is2); + + $this->_buffer->write('x'); + $this->_buffer->write('y'); + } + + public function testBindingOtherStreamsMirrorsFlushOperations() + { + $this->_initializeBuffer(); + + $is1 = $this->_createMockInputStream(); + $is2 = $this->_createMockInputStream(); + + $is1->expects($this->once()) + ->method('flushBuffers'); + $is2->expects($this->once()) + ->method('flushBuffers'); + + $this->_buffer->bind($is1); + $this->_buffer->bind($is2); + + $this->_buffer->flushBuffers(); + } + + public function testUnbindingStreamPreventsFurtherWrites() + { + $this->_initializeBuffer(); + + $is1 = $this->_createMockInputStream(); + $is2 = $this->_createMockInputStream(); + + $is1->expects($this->at(0)) + ->method('write') + ->with('x'); + $is1->expects($this->at(1)) + ->method('write') + ->with('y'); + $is2->expects($this->once()) + ->method('write') + ->with('x'); + + $this->_buffer->bind($is1); + $this->_buffer->bind($is2); + + $this->_buffer->write('x'); + + $this->_buffer->unbind($is2); + + $this->_buffer->write('y'); + } + + // -- Creation Methods + + private function _createMockInputStream() + { + return $this->getMock('Swift_InputByteStream'); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/Transport/StreamBuffer/BasicSocketAcceptanceTest.php b/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/Transport/StreamBuffer/BasicSocketAcceptanceTest.php new file mode 100755 index 0000000..d16863f --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/Transport/StreamBuffer/BasicSocketAcceptanceTest.php @@ -0,0 +1,34 @@ +markTestSkipped( + 'Cannot run test without an SMTP host to connect to (define ' . + 'SWIFT_SMTP_HOST in tests/acceptance.conf.php if you wish to run this test)' + ); + } + parent::setUp(); + } + + protected function _initializeBuffer() + { + $parts = explode(':', SWIFT_SMTP_HOST); + $host = $parts[0]; + $port = isset($parts[1]) ? $parts[1] : 25; + + $this->_buffer->initialize(array( + 'type' => Swift_Transport_IoBuffer::TYPE_SOCKET, + 'host' => $host, + 'port' => $port, + 'protocol' => 'tcp', + 'blocking' => 1, + 'timeout' => 15 + )); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/Transport/StreamBuffer/ProcessAcceptanceTest.php b/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/Transport/StreamBuffer/ProcessAcceptanceTest.php new file mode 100755 index 0000000..9c52fe3 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/Transport/StreamBuffer/ProcessAcceptanceTest.php @@ -0,0 +1,27 @@ +markTestSkipped( + 'Cannot run test without a path to sendmail (define ' . + 'SWIFT_SENDMAIL_PATH in tests/acceptance.conf.php if you wish to run this test)' + ); + } + + parent::setUp(); + } + + protected function _initializeBuffer() + { + $this->_buffer->initialize(array( + 'type' => Swift_Transport_IoBuffer::TYPE_PROCESS, + 'command' => SWIFT_SENDMAIL_PATH . ' -bs' + )); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/Transport/StreamBuffer/SocketTimeoutTest.php b/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/Transport/StreamBuffer/SocketTimeoutTest.php new file mode 100755 index 0000000..6a23e54 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/Transport/StreamBuffer/SocketTimeoutTest.php @@ -0,0 +1,65 @@ +markTestSkipped( + 'Cannot run test without an SMTP host to connect to (define ' . + 'SWIFT_SMTP_HOST in tests/acceptance.conf.php if you wish to run this test)' + ); + } + + $serverStarted=false; + for ($i=0; $i<5; ++$i) { + $this->_randomHighPort=rand(50000,65000); + $this->_server = stream_socket_server('tcp://127.0.0.1:' . $this->_randomHighPort); + if ($this->_server) { + $serverStarted=true; + } + } + + $this->_buffer = new Swift_Transport_StreamBuffer( + $this->getMock('Swift_ReplacementFilterFactory') + ); + } + + protected function _initializeBuffer() + { + $host = '127.0.0.1'; + $port = $this->_randomHighPort; + + $this->_buffer->initialize(array( + 'type' => Swift_Transport_IoBuffer::TYPE_SOCKET, + 'host' => $host, + 'port' => $port, + 'protocol' => 'tcp', + 'blocking' => 1, + 'timeout' => 1 + )); + } + + public function testTimeoutException() + { + $this->_initializeBuffer(); + $e=null; + try { + $line = $this->_buffer->readLine(0); + } catch (Exception $e) { + } + $this->assertInstanceof('Swift_IoException', $e, 'IO Exception Not Thrown On Connection Timeout'); + $this->assertRegExp('/Connection to .* Timed Out/', $e->getMessage()); + } + + public function tearDown() + { + if ($this->_server) { + stream_socket_shutdown($this->_server, STREAM_SHUT_RDWR); + } + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/Transport/StreamBuffer/SslSocketAcceptanceTest.php b/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/Transport/StreamBuffer/SslSocketAcceptanceTest.php new file mode 100755 index 0000000..1ac0a5b --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/Transport/StreamBuffer/SslSocketAcceptanceTest.php @@ -0,0 +1,41 @@ +markTestSkipped( + 'SSL is not configured for your system. It is not possible to run this test' + ); + } + if (!defined('SWIFT_SSL_HOST')) { + $this->markTestSkipped( + 'Cannot run test without an SSL enabled SMTP host to connect to (define ' . + 'SWIFT_SSL_HOST in tests/acceptance.conf.php if you wish to run this test)' + ); + } + + parent::setUp(); + } + + protected function _initializeBuffer() + { + $parts = explode(':', SWIFT_SSL_HOST); + $host = $parts[0]; + $port = isset($parts[1]) ? $parts[1] : 25; + + $this->_buffer->initialize(array( + 'type' => Swift_Transport_IoBuffer::TYPE_SOCKET, + 'host' => $host, + 'port' => $port, + 'protocol' => 'ssl', + 'blocking' => 1, + 'timeout' => 15 + )); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/Transport/StreamBuffer/TlsSocketAcceptanceTest.php b/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/Transport/StreamBuffer/TlsSocketAcceptanceTest.php new file mode 100755 index 0000000..5b2a27e --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/acceptance/Swift/Transport/StreamBuffer/TlsSocketAcceptanceTest.php @@ -0,0 +1,40 @@ +markTestSkipped( + 'TLS is not configured for your system. It is not possible to run this test' + ); + } + if (!defined('SWIFT_TLS_HOST')) { + $this->markTestSkipped( + 'Cannot run test without a TLS enabled SMTP host to connect to (define ' . + 'SWIFT_TLS_HOST in tests/acceptance.conf.php if you wish to run this test)' + ); + } + parent::setUp(); + } + + protected function _initializeBuffer() + { + $parts = explode(':', SWIFT_TLS_HOST); + $host = $parts[0]; + $port = isset($parts[1]) ? $parts[1] : 25; + + $this->_buffer->initialize(array( + 'type' => Swift_Transport_IoBuffer::TYPE_SOCKET, + 'host' => $host, + 'port' => $port, + 'protocol' => 'tls', + 'blocking' => 1, + 'timeout' => 15 + )); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/bootstrap.php b/vendor/swiftmailer/swiftmailer/tests/bootstrap.php new file mode 100755 index 0000000..a5296d5 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/bootstrap.php @@ -0,0 +1,20 @@ +allowMockingNonExistentMethods(false); + +if (is_file(__DIR__ . '/acceptance.conf.php')) { + require_once __DIR__ . '/acceptance.conf.php'; +} +if (is_file(__DIR__ . '/smoke.conf.php')) { + require_once __DIR__ . '/smoke.conf.php'; +} +require_once __DIR__ . '/StreamCollector.php'; +require_once __DIR__ . '/IdenticalBinaryConstraint.php'; +require_once __DIR__ . '/SwiftMailerTestCase.php'; +require_once __DIR__ . '/SwiftMailerSmokeTestCase.php'; \ No newline at end of file diff --git a/vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug111Test.php b/vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug111Test.php new file mode 100755 index 0000000..06b1f59 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug111Test.php @@ -0,0 +1,42 @@ + array( + 'email1@example.com', + 'email2@example.com', + 'email3@example.com', + 'email4@example.com', + 'email5@example.com', + ), + 'sub' => array( + '-name-' => array( + 'email1', + '"email2"', + 'email3\\', + 'email4', + 'email5', + ), + '-url-' => array( + 'http://google.com', + 'http://yahoo.com', + 'http://hotmail.com', + 'http://aol.com', + 'http://facebook.com', + ), + ) + ); + $json = json_encode($complicated_header); + + $message = new Swift_Message(); + $headers = $message->getHeaders(); + $headers->addTextHeader('X-SMTPAPI', $json); + $header = $headers->get('X-SMTPAPI'); + + $this->assertEquals('Swift_Mime_Headers_UnstructuredHeader', get_class($header)); + $this->assertEquals($json, $header->getFieldBody()); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug118Test.php b/vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug118Test.php new file mode 100755 index 0000000..bd10c71 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug118Test.php @@ -0,0 +1,20 @@ +_message = new Swift_Message(); + } + + public function testCallingGenerateIdChangesTheMessageId() + { + $currentId = $this->_message->getId(); + $this->_message->generateId(); + $newId = $this->_message->getId(); + + $this->assertNotEquals($currentId, $newId); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug206Test.php b/vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug206Test.php new file mode 100755 index 0000000..9622d6b --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug206Test.php @@ -0,0 +1,38 @@ +_factory = new Swift_Mime_SimpleHeaderFactory($headerEncoder, $paramEncoder, $grammar); + } + + public function testMailboxHeaderEncoding() + { + $this->_testHeaderIsFullyEncoded('email@example.org', 'Family Name, Name', ' "Family Name, Name" '); + $this->_testHeaderIsFullyEncoded('email@example.org', 'Family Namé, Name', ' Family =?utf-8?Q?Nam=C3=A9=2C?= Name'); + $this->_testHeaderIsFullyEncoded('email@example.org', 'Family Namé , Name', ' Family =?utf-8?Q?Nam=C3=A9_=2C?= Name'); + $this->_testHeaderIsFullyEncoded('email@example.org', 'Family Namé ;Name', ' Family =?utf-8?Q?Nam=C3=A9_=3BName?= '); + } + + private function _testHeaderIsFullyEncoded($email, $name, $expected) + { + $mailboxHeader = $this->_factory->createMailboxHeader('To', array( + $email => $name + )); + + $headerBody = substr($mailboxHeader->toString(), 3, strlen($expected)); + + $this->assertEquals($expected, $headerBody); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug274Test.php b/vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug274Test.php new file mode 100755 index 0000000..d305d02 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug274Test.php @@ -0,0 +1,21 @@ +setExpectedException('Swift_IoException', 'The path cannot be empty'); + $message->attach(Swift_Attachment::fromPath('')); + } + + public function testNonEmptyFileNameAsAttachement() + { + $message = new Swift_Message(); + try { + $message->attach(Swift_Attachment::fromPath(__FILE__)); + } catch (Exception $e) { + $this->fail('Path should not be empty'); + } + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug34Test.php b/vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug34Test.php new file mode 100755 index 0000000..a7cb96f --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug34Test.php @@ -0,0 +1,75 @@ +setCharset('utf-8'); + } + + public function testEmbeddedFilesWithMultipartDataCreateMultipartRelatedContentAsAnAlternative() + { + $message = Swift_Message::newInstance(); + $message->setCharset('utf-8'); + $message->setSubject('test subject'); + $message->addPart('plain part', 'text/plain'); + + $image = Swift_Image::newInstance('', 'image.gif', 'image/gif'); + $cid = $message->embed($image); + + $message->setBody('', 'text/html'); + + $message->setTo(array('user@domain.tld' => 'User')); + + $message->setFrom(array('other@domain.tld' => 'Other')); + $message->setSender(array('other@domain.tld' => 'Other')); + + $id = $message->getId(); + $date = preg_quote(date('r', $message->getDate()), '~'); + $boundary = $message->getBoundary(); + $cidVal = $image->getId(); + + $this->assertRegExp( + '~^' . + 'Sender: Other ' . "\r\n" . + 'Message-ID: <' . $id . '>' . "\r\n" . + 'Date: ' . $date . "\r\n" . + 'Subject: test subject' . "\r\n" . + 'From: Other ' . "\r\n" . + 'To: User ' . "\r\n" . + 'MIME-Version: 1.0' . "\r\n" . + 'Content-Type: multipart/alternative;' . "\r\n" . + ' boundary="' . $boundary . '"' . "\r\n" . + "\r\n\r\n" . + '--' . $boundary . "\r\n" . + 'Content-Type: text/plain; charset=utf-8' . "\r\n" . + 'Content-Transfer-Encoding: quoted-printable' . "\r\n" . + "\r\n" . + 'plain part' . + "\r\n\r\n" . + '--' . $boundary . "\r\n" . + 'Content-Type: multipart/related;' . "\r\n" . + ' boundary="(.*?)"' . "\r\n" . + "\r\n\r\n" . + '--\\1' . "\r\n" . + 'Content-Type: text/html; charset=utf-8' . "\r\n" . + 'Content-Transfer-Encoding: quoted-printable' . "\r\n" . + "\r\n" . + '' . + "\r\n\r\n" . + '--\\1' . "\r\n" . + 'Content-Type: image/gif; name=image.gif' . "\r\n" . + 'Content-Transfer-Encoding: base64' . "\r\n" . + 'Content-Disposition: inline; filename=image.gif' . "\r\n" . + 'Content-ID: <' . $cidVal . '>' . "\r\n" . + "\r\n" . + preg_quote(base64_encode(''), '~') . + "\r\n\r\n" . + '--\\1--' . "\r\n" . + "\r\n\r\n" . + '--' . $boundary . '--' . "\r\n" . + '$~D', + $message->toString() + ); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug35Test.php b/vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug35Test.php new file mode 100755 index 0000000..bac4538 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug35Test.php @@ -0,0 +1,73 @@ +setCharset('utf-8'); + } + + public function testHTMLPartAppearsLastEvenWhenAttachmentsAdded() + { + $message = Swift_Message::newInstance(); + $message->setCharset('utf-8'); + $message->setSubject('test subject'); + $message->addPart('plain part', 'text/plain'); + + $attachment = Swift_Attachment::newInstance('', 'image.gif', 'image/gif'); + $message->attach($attachment); + + $message->setBody('HTML part', 'text/html'); + + $message->setTo(array('user@domain.tld' => 'User')); + + $message->setFrom(array('other@domain.tld' => 'Other')); + $message->setSender(array('other@domain.tld' => 'Other')); + + $id = $message->getId(); + $date = preg_quote(date('r', $message->getDate()), '~'); + $boundary = $message->getBoundary(); + + $this->assertRegExp( + '~^' . + 'Sender: Other ' . "\r\n" . + 'Message-ID: <' . $id . '>' . "\r\n" . + 'Date: ' . $date . "\r\n" . + 'Subject: test subject' . "\r\n" . + 'From: Other ' . "\r\n" . + 'To: User ' . "\r\n" . + 'MIME-Version: 1.0' . "\r\n" . + 'Content-Type: multipart/mixed;' . "\r\n" . + ' boundary="' . $boundary . '"' . "\r\n" . + "\r\n\r\n" . + '--' . $boundary . "\r\n" . + 'Content-Type: multipart/alternative;' . "\r\n" . + ' boundary="(.*?)"' . "\r\n" . + "\r\n\r\n" . + '--\\1' . "\r\n" . + 'Content-Type: text/plain; charset=utf-8' . "\r\n" . + 'Content-Transfer-Encoding: quoted-printable' . "\r\n" . + "\r\n" . + 'plain part' . + "\r\n\r\n" . + '--\\1' . "\r\n" . + 'Content-Type: text/html; charset=utf-8' . "\r\n" . + 'Content-Transfer-Encoding: quoted-printable' . "\r\n" . + "\r\n" . + 'HTML part' . + "\r\n\r\n" . + '--\\1--' . "\r\n" . + "\r\n\r\n" . + '--' . $boundary . "\r\n" . + 'Content-Type: image/gif; name=image.gif' . "\r\n" . + 'Content-Transfer-Encoding: base64' . "\r\n" . + 'Content-Disposition: attachment; filename=image.gif' . "\r\n" . + "\r\n" . + preg_quote(base64_encode(''), '~') . + "\r\n\r\n" . + '--' . $boundary . '--' . "\r\n" . + '$~D', + $message->toString() + ); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug38Test.php b/vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug38Test.php new file mode 100755 index 0000000..5719f1a --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug38Test.php @@ -0,0 +1,194 @@ +_attFileName = 'data.txt'; + $this->_attFileType = 'text/plain'; + $this->_attFile = __DIR__ . '/../../_samples/files/data.txt'; + Swift_Preferences::getInstance()->setCharset('utf-8'); + } + + public function testWritingMessageToByteStreamProducesCorrectStructure() + { + $message = new Swift_Message(); + $message->setSubject('test subject'); + $message->setTo('user@domain.tld'); + $message->setCc('other@domain.tld'); + $message->setFrom('user@domain.tld'); + + $image = new Swift_Image('', 'image.gif', 'image/gif'); + + $cid = $message->embed($image); + $message->setBody('HTML part', 'text/html'); + + $id = $message->getId(); + $date = preg_quote(date('r', $message->getDate()), '~'); + $boundary = $message->getBoundary(); + $imgId = $image->getId(); + + $stream = new Swift_ByteStream_ArrayByteStream(); + + $message->toByteStream($stream); + + $this->assertPatternInStream( + '~^' . + 'Message-ID: <' . $id . '>' . "\r\n" . + 'Date: ' . $date . "\r\n" . + 'Subject: test subject' . "\r\n" . + 'From: user@domain.tld' . "\r\n" . + 'To: user@domain.tld' . "\r\n" . + 'Cc: other@domain.tld' . "\r\n" . + 'MIME-Version: 1.0' . "\r\n" . + 'Content-Type: multipart/related;' . "\r\n" . + ' boundary="' . $boundary . '"' . "\r\n" . + "\r\n\r\n" . + '--' . $boundary . "\r\n" . + 'Content-Type: text/html; charset=utf-8' . "\r\n" . + 'Content-Transfer-Encoding: quoted-printable' . "\r\n" . + "\r\n" . + 'HTML part' . + "\r\n\r\n" . + '--' . $boundary . "\r\n" . + 'Content-Type: image/gif; name=image.gif' . "\r\n" . + 'Content-Transfer-Encoding: base64' . "\r\n" . + 'Content-Disposition: inline; filename=image.gif' . "\r\n" . + 'Content-ID: <' . preg_quote($imgId, '~') . '>' . "\r\n" . + "\r\n" . + preg_quote(base64_encode(''), '~') . + "\r\n\r\n" . + '--' . $boundary . '--' . "\r\n" . + '$~D', + $stream + ); + } + + public function testWritingMessageToByteStreamTwiceProducesCorrectStructure() + { + $message = new Swift_Message(); + $message->setSubject('test subject'); + $message->setTo('user@domain.tld'); + $message->setCc('other@domain.tld'); + $message->setFrom('user@domain.tld'); + + $image = new Swift_Image('', 'image.gif', 'image/gif'); + + $cid = $message->embed($image); + $message->setBody('HTML part', 'text/html'); + + $id = $message->getId(); + $date = preg_quote(date('r', $message->getDate()), '~'); + $boundary = $message->getBoundary(); + $imgId = $image->getId(); + + $pattern = '~^' . + 'Message-ID: <' . $id . '>' . "\r\n" . + 'Date: ' . $date . "\r\n" . + 'Subject: test subject' . "\r\n" . + 'From: user@domain.tld' . "\r\n" . + 'To: user@domain.tld' . "\r\n" . + 'Cc: other@domain.tld' . "\r\n" . + 'MIME-Version: 1.0' . "\r\n" . + 'Content-Type: multipart/related;' . "\r\n" . + ' boundary="' . $boundary . '"' . "\r\n" . + "\r\n\r\n" . + '--' . $boundary . "\r\n" . + 'Content-Type: text/html; charset=utf-8' . "\r\n" . + 'Content-Transfer-Encoding: quoted-printable' . "\r\n" . + "\r\n" . + 'HTML part' . + "\r\n\r\n" . + '--' . $boundary . "\r\n" . + 'Content-Type: image/gif; name=image.gif' . "\r\n" . + 'Content-Transfer-Encoding: base64' . "\r\n" . + 'Content-Disposition: inline; filename=image.gif' . "\r\n" . + 'Content-ID: <' . preg_quote($imgId, '~') . '>' . "\r\n" . + "\r\n" . + preg_quote(base64_encode(''), '~') . + "\r\n\r\n" . + '--' . $boundary . '--' . "\r\n" . + '$~D' + ; + + $streamA = new Swift_ByteStream_ArrayByteStream(); + $streamB = new Swift_ByteStream_ArrayByteStream(); + + $message->toByteStream($streamA); + $message->toByteStream($streamB); + + $this->assertPatternInStream($pattern, $streamA); + $this->assertPatternInStream($pattern, $streamB); + } + + public function testWritingMessageToByteStreamTwiceUsingAFileAttachment() + { + $message = new Swift_Message(); + $message->setSubject('test subject'); + $message->setTo('user@domain.tld'); + $message->setCc('other@domain.tld'); + $message->setFrom('user@domain.tld'); + + $attachment = Swift_Attachment::fromPath($this->_attFile); + + $message->attach($attachment); + + $message->setBody('HTML part', 'text/html'); + + $id = $message->getId(); + $date = preg_quote(date('r', $message->getDate()), '~'); + $boundary = $message->getBoundary(); + + $streamA = new Swift_ByteStream_ArrayByteStream(); + $streamB = new Swift_ByteStream_ArrayByteStream(); + + $pattern = '~^' . + 'Message-ID: <' . $id . '>' . "\r\n" . + 'Date: ' . $date . "\r\n" . + 'Subject: test subject' . "\r\n" . + 'From: user@domain.tld' . "\r\n" . + 'To: user@domain.tld' . "\r\n" . + 'Cc: other@domain.tld' . "\r\n" . + 'MIME-Version: 1.0' . "\r\n" . + 'Content-Type: multipart/mixed;' . "\r\n" . + ' boundary="' . $boundary . '"' . "\r\n" . + "\r\n\r\n" . + '--' . $boundary . "\r\n" . + 'Content-Type: text/html; charset=utf-8' . "\r\n" . + 'Content-Transfer-Encoding: quoted-printable' . "\r\n" . + "\r\n" . + 'HTML part' . + "\r\n\r\n" . + '--' . $boundary . "\r\n" . + 'Content-Type: ' . $this->_attFileType . '; name=' . $this->_attFileName . "\r\n" . + 'Content-Transfer-Encoding: base64' . "\r\n" . + 'Content-Disposition: attachment; filename=' . $this->_attFileName . "\r\n" . + "\r\n" . + preg_quote(base64_encode(file_get_contents($this->_attFile)), '~') . + "\r\n\r\n" . + '--' . $boundary . '--' . "\r\n" . + '$~D' + ; + + $message->toByteStream($streamA); + $message->toByteStream($streamB); + + $this->assertPatternInStream($pattern, $streamA); + $this->assertPatternInStream($pattern, $streamB); + } + + // -- Helpers + + public function assertPatternInStream($pattern, $stream, $message = '%s') + { + $string = ''; + while (false !== $bytes = $stream->read(8192)) { + $string .= $bytes; + } + $this->assertRegExp($pattern, $string, $message); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug51Test.php b/vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug51Test.php new file mode 100755 index 0000000..f22dade --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug51Test.php @@ -0,0 +1,121 @@ +markTestSkipped( + 'Cannot run test without a writable directory to use (' . + 'define SWIFT_TMP_DIR in tests/config.php if you wish to run this test)' + ); + } + + $this->_attachmentFile = SWIFT_TMP_DIR . '/attach.rand.bin'; + file_put_contents($this->_attachmentFile, ''); + + $this->_outputFile = SWIFT_TMP_DIR . '/attach.out.bin'; + file_put_contents($this->_outputFile, ''); + } + + public function tearDown() + { + unlink($this->_attachmentFile); + unlink($this->_outputFile); + } + + public function testAttachmentsDoNotGetTruncatedUsingToByteStream() + { + //Run 100 times with 10KB attachments + for ($i = 0; $i < 10; ++$i) { + $message = $this->_createMessageWithRandomAttachment( + 10000, $this->_attachmentFile + ); + + file_put_contents($this->_outputFile, ''); + $message->toByteStream( + new Swift_ByteStream_FileByteStream($this->_outputFile, true) + ); + + $emailSource = file_get_contents($this->_outputFile); + + $this->assertAttachmentFromSourceMatches( + file_get_contents($this->_attachmentFile), + $emailSource + ); + } + } + + public function testAttachmentsDoNotGetTruncatedUsingToString() + { + //Run 100 times with 10KB attachments + for ($i = 0; $i < 10; ++$i) { + $message = $this->_createMessageWithRandomAttachment( + 10000, $this->_attachmentFile + ); + + $emailSource = $message->toString(); + + $this->assertAttachmentFromSourceMatches( + file_get_contents($this->_attachmentFile), + $emailSource + ); + } + } + + // -- Custom Assertions + + public function assertAttachmentFromSourceMatches($attachmentData, $source) + { + $encHeader = 'Content-Transfer-Encoding: base64'; + $base64declaration = strpos($source, $encHeader); + + $attachmentDataStart = strpos($source, "\r\n\r\n", $base64declaration); + $attachmentDataEnd = strpos($source, "\r\n--", $attachmentDataStart); + + if (false === $attachmentDataEnd) { + $attachmentBase64 = trim(substr($source, $attachmentDataStart)); + } else { + $attachmentBase64 = trim(substr( + $source, $attachmentDataStart, + $attachmentDataEnd - $attachmentDataStart + )); + } + + $this->assertIdenticalBinary($attachmentData, base64_decode($attachmentBase64)); + } + + // -- Creation Methods + + private function _fillFileWithRandomBytes($byteCount, $file) + { + // I was going to use dd with if=/dev/random but this way seems more + // cross platform even if a hella expensive!! + + file_put_contents($file, ''); + $fp = fopen($file, 'wb'); + for ($i = 0; $i < $byteCount; ++$i) { + $byteVal = rand(0, 255); + fwrite($fp, pack('i', $byteVal)); + } + fclose($fp); + } + + private function _createMessageWithRandomAttachment($size, $attachmentPath) + { + $this->_fillFileWithRandomBytes($size, $attachmentPath); + + $message = Swift_Message::newInstance() + ->setSubject('test') + ->setBody('test') + ->setFrom('a@b.c') + ->setTo('d@e.f') + ->attach(Swift_Attachment::fromPath($attachmentPath)) + ; + + return $message; + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug71Test.php b/vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug71Test.php new file mode 100755 index 0000000..4b80453 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug71Test.php @@ -0,0 +1,20 @@ +_message = new Swift_Message('test'); + } + + public function testCallingToStringAfterSettingNewBodyReflectsChanges() + { + $this->_message->setBody('BODY1'); + $this->assertRegExp('/BODY1/', $this->_message->toString()); + + $this->_message->setBody('BODY2'); + $this->assertRegExp('/BODY2/', $this->_message->toString()); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug76Test.php b/vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug76Test.php new file mode 100755 index 0000000..3e352e1 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/bug/Swift/Bug76Test.php @@ -0,0 +1,82 @@ +markTestSkipped( + 'Cannot run test without a writable directory to use (' . + 'define SWIFT_TMP_DIR in tests/config.php if you wish to run this test)' + ); + } + + $this->_inputFile = SWIFT_TMP_DIR . '/in.bin'; + file_put_contents($this->_inputFile, ''); + + $this->_outputFile = SWIFT_TMP_DIR . '/out.bin'; + file_put_contents($this->_outputFile, ''); + + $this->_encoder = $this->_createEncoder(); + } + + public function tearDown() + { + unlink($this->_inputFile); + unlink($this->_outputFile); + } + + public function testBase64EncodedLineLengthNeverExceeds76CharactersEvenIfArgsDo() + { + $this->_fillFileWithRandomBytes(1000, $this->_inputFile); + + $os = $this->_createStream($this->_inputFile); + $is = $this->_createStream($this->_outputFile); + + $this->_encoder->encodeByteStream($os, $is, 0, 80); //Exceeds 76 + + $this->assertMaxLineLength(76, $this->_outputFile, + '%s: Line length should not exceed 76 characters' + ); + } + + // -- Custom Assertions + + public function assertMaxLineLength($length, $filePath, $message = '%s') + { + $lines = file($filePath); + foreach ($lines as $line) { + $this->assertTrue((strlen(trim($line)) <= 76), $message); + } + } + + // -- Creation Methods + + private function _fillFileWithRandomBytes($byteCount, $file) + { + // I was going to use dd with if=/dev/random but this way seems more + // cross platform even if a hella expensive!! + + file_put_contents($file, ''); + $fp = fopen($file, 'wb'); + for ($i = 0; $i < $byteCount; ++$i) { + $byteVal = rand(0, 255); + fwrite($fp, pack('i', $byteVal)); + } + fclose($fp); + } + + private function _createEncoder() + { + return new Swift_Mime_ContentEncoder_Base64ContentEncoder(); + } + + private function _createStream($file) + { + return new Swift_ByteStream_FileByteStream($file, true); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/fixtures/EsmtpTransportFixture.php b/vendor/swiftmailer/swiftmailer/tests/fixtures/EsmtpTransportFixture.php new file mode 100755 index 0000000..e46c824 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/fixtures/EsmtpTransportFixture.php @@ -0,0 +1,10 @@ +level = $level; + $this->string = $string; + $this->contentType = $contentType; + } + + public function getNestingLevel() + { + return $this->level; + } + + public function toString() + { + return $this->string; + } + + public function getContentType() + { + return $this->contentType; + } + + // These methods are here to account for the implemented interfaces + public function getId() {} + public function getHeaders() {} + public function getBody() {} + public function setBody($body, $contentType = NULL) {} + public function toByteStream(Swift_InputByteStream $is) {} + public function charsetChanged($charset) {} + public function encoderChanged(Swift_Mime_ContentEncoder $encoder) {} + public function getChildren() {} + public function setChildren(array $children) {} +} \ No newline at end of file diff --git a/vendor/swiftmailer/swiftmailer/tests/smoke.conf.php.default b/vendor/swiftmailer/swiftmailer/tests/smoke.conf.php.default new file mode 100755 index 0000000..0de2763 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/smoke.conf.php.default @@ -0,0 +1,63 @@ +_attFile = __DIR__ . '/../../../_samples/files/textfile.zip'; + } + + public function testAttachmentSending() + { + $mailer = $this->_getMailer(); + $message = Swift_Message::newInstance() + ->setSubject('[Swift Mailer] AttachmentSmokeTest') + ->setFrom(array(SWIFT_SMOKE_EMAIL_ADDRESS => 'Swift Mailer')) + ->setTo(SWIFT_SMOKE_EMAIL_ADDRESS) + ->setBody('This message should contain an attached ZIP file (named "textfile.zip").' . PHP_EOL . + 'When unzipped, the archive should produce a text file which reads:' . PHP_EOL . + '"This is part of a Swift Mailer v4 smoke test."' + ) + ->attach(Swift_Attachment::fromPath($this->_attFile)) + ; + $this->assertEquals(1, $mailer->send($message), + '%s: The smoke test should send a single message' + ); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/smoke/Swift/Smoke/BasicSmokeTest.php b/vendor/swiftmailer/swiftmailer/tests/smoke/Swift/Smoke/BasicSmokeTest.php new file mode 100755 index 0000000..48edf1f --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/smoke/Swift/Smoke/BasicSmokeTest.php @@ -0,0 +1,23 @@ +_getMailer(); + $message = Swift_Message::newInstance() + ->setSubject('[Swift Mailer] BasicSmokeTest') + ->setFrom(array(SWIFT_SMOKE_EMAIL_ADDRESS => 'Swift Mailer')) + ->setTo(SWIFT_SMOKE_EMAIL_ADDRESS) + ->setBody('One, two, three, four, five...' . PHP_EOL . + 'six, seven, eight...' + ) + ; + $this->assertEquals(1, $mailer->send($message), + '%s: The smoke test should send a single message' + ); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/smoke/Swift/Smoke/HtmlWithAttachmentSmokeTest.php b/vendor/swiftmailer/swiftmailer/tests/smoke/Swift/Smoke/HtmlWithAttachmentSmokeTest.php new file mode 100755 index 0000000..9c0d418 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/smoke/Swift/Smoke/HtmlWithAttachmentSmokeTest.php @@ -0,0 +1,29 @@ +_attFile = __DIR__ . '/../../../_samples/files/textfile.zip'; + } + + public function testAttachmentSending() + { + $mailer = $this->_getMailer(); + $message = Swift_Message::newInstance('[Swift Mailer] HtmlWithAttachmentSmokeTest') + ->setFrom(array(SWIFT_SMOKE_EMAIL_ADDRESS => 'Swift Mailer')) + ->setTo(SWIFT_SMOKE_EMAIL_ADDRESS) + ->attach(Swift_Attachment::fromPath($this->_attFile)) + ->setBody('

    This HTML-formatted message should contain an attached ZIP file (named "textfile.zip").' . PHP_EOL . + 'When unzipped, the archive should produce a text file which reads:

    ' . PHP_EOL . + '

    This is part of a Swift Mailer v4 smoke test.

    ', 'text/html' + ) + ; + $this->assertEquals(1, $mailer->send($message), + '%s: The smoke test should send a single message' + ); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/smoke/Swift/Smoke/InternationalSmokeTest.php b/vendor/swiftmailer/swiftmailer/tests/smoke/Swift/Smoke/InternationalSmokeTest.php new file mode 100755 index 0000000..27b4530 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/smoke/Swift/Smoke/InternationalSmokeTest.php @@ -0,0 +1,37 @@ +_attFile = __DIR__ . '/../../../_samples/files/textfile.zip'; + } + + public function testAttachmentSending() + { + $mailer = $this->_getMailer(); + $message = Swift_Message::newInstance() + ->setCharset('utf-8') + ->setSubject('[Swift Mailer] InternationalSmokeTest (διεθνής)') + ->setFrom(array(SWIFT_SMOKE_EMAIL_ADDRESS => 'ΧÏιστοφοÏου (Swift Mailer)')) + ->setTo(SWIFT_SMOKE_EMAIL_ADDRESS) + ->setBody('This message should contain an attached ZIP file (named "κείμενο, εδάφιο, θέμα.zip").' . PHP_EOL . + 'When unzipped, the archive should produce a text file which reads:' . PHP_EOL . + '"This is part of a Swift Mailer v4 smoke test."' . PHP_EOL . + PHP_EOL . + 'Following is some arbitrary Greek text:' . PHP_EOL . + 'Δεν βÏέθηκαν λέξεις.' + ) + ->attach(Swift_Attachment::fromPath($this->_attFile) + ->setContentType('application/zip') + ->setFilename('κείμενο, εδάφιο, θέμα.zip') + ) + ; + $this->assertEquals(1, $mailer->send($message), + '%s: The smoke test should send a single message' + ); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/ByteStream/ArrayByteStreamTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/ByteStream/ArrayByteStreamTest.php new file mode 100755 index 0000000..0193484 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/ByteStream/ArrayByteStreamTest.php @@ -0,0 +1,204 @@ +_createArrayStream($input); + $output = array(); + while (false !== $bytes = $bs->read(1)) { + $output[] = $bytes; + } + $this->assertEquals($input, $output, + '%s: Bytes read from stream should be the same as bytes in constructor' + ); + } + + public function testReadingMultipleBytesFromBaseInput() + { + $input = array('a', 'b', 'c', 'd'); + $bs = $this->_createArrayStream($input); + $output = array(); + while (false !== $bytes = $bs->read(2)) { + $output[] = $bytes; + } + $this->assertEquals(array('ab', 'cd'), $output, + '%s: Bytes read from stream should be in pairs' + ); + } + + public function testReadingOddOffsetOnLastByte() + { + $input = array('a', 'b', 'c', 'd', 'e'); + $bs = $this->_createArrayStream($input); + $output = array(); + while (false !== $bytes = $bs->read(2)) { + $output[] = $bytes; + } + $this->assertEquals(array('ab', 'cd', 'e'), $output, + '%s: Bytes read from stream should be in pairs except final read' + ); + } + + public function testSettingPointerPartway() + { + $input = array('a', 'b', 'c'); + $bs = $this->_createArrayStream($input); + $bs->setReadPointer(1); + $this->assertEquals('b', $bs->read(1), + '%s: Byte should be second byte since pointer as at offset 1' + ); + } + + public function testResettingPointerAfterExhaustion() + { + $input = array('a', 'b', 'c'); + $bs = $this->_createArrayStream($input); + + while (false !== $bs->read(1)); + + $bs->setReadPointer(0); + $this->assertEquals('a', $bs->read(1), + '%s: Byte should be first byte since pointer as at offset 0' + ); + } + + public function testPointerNeverSetsBelowZero() + { + $input = array('a', 'b', 'c'); + $bs = $this->_createArrayStream($input); + + $bs->setReadPointer(-1); + $this->assertEquals('a', $bs->read(1), + '%s: Byte should be first byte since pointer should be at offset 0' + ); + } + + public function testPointerNeverSetsAboveStackSize() + { + $input = array('a', 'b', 'c'); + $bs = $this->_createArrayStream($input); + + $bs->setReadPointer(3); + $this->assertSame(false, $bs->read(1), + '%s: Stream should be at end and thus return false' + ); + } + + public function testBytesCanBeWrittenToStream() + { + $input = array('a', 'b', 'c'); + $bs = $this->_createArrayStream($input); + + $bs->write('de'); + + $output = array(); + while (false !== $bytes = $bs->read(1)) { + $output[] = $bytes; + } + $this->assertEquals(array('a', 'b', 'c', 'd', 'e'), $output, + '%s: Bytes read from stream should be from initial stack + written' + ); + } + + public function testContentsCanBeFlushed() + { + $input = array('a', 'b', 'c'); + $bs = $this->_createArrayStream($input); + + $bs->flushBuffers(); + + $this->assertSame(false, $bs->read(1), + '%s: Contents have been flushed so read() should return false' + ); + } + + public function testConstructorCanTakeStringArgument() + { + $bs = $this->_createArrayStream('abc'); + $output = array(); + while (false !== $bytes = $bs->read(1)) { + $output[] = $bytes; + } + $this->assertEquals(array('a', 'b', 'c'), $output, + '%s: Bytes read from stream should be the same as bytes in constructor' + ); + } + + public function testBindingOtherStreamsMirrorsWriteOperations() + { + $bs = $this->_createArrayStream(''); + $is1 = $this->getMock('Swift_InputByteStream'); + $is2 = $this->getMock('Swift_InputByteStream'); + + $is1->expects($this->at(0)) + ->method('write') + ->with('x'); + $is1->expects($this->at(1)) + ->method('write') + ->with('y'); + $is2->expects($this->at(0)) + ->method('write') + ->with('x'); + $is2->expects($this->at(1)) + ->method('write') + ->with('y'); + + $bs->bind($is1); + $bs->bind($is2); + + $bs->write('x'); + $bs->write('y'); + } + + public function testBindingOtherStreamsMirrorsFlushOperations() + { + $bs = $this->_createArrayStream(''); + $is1 = $this->getMock('Swift_InputByteStream'); + $is2 = $this->getMock('Swift_InputByteStream'); + + $is1->expects($this->once()) + ->method('flushBuffers'); + $is2->expects($this->once()) + ->method('flushBuffers'); + + $bs->bind($is1); + $bs->bind($is2); + + $bs->flushBuffers(); + } + + public function testUnbindingStreamPreventsFurtherWrites() + { + $bs = $this->_createArrayStream(''); + $is1 = $this->getMock('Swift_InputByteStream'); + $is2 = $this->getMock('Swift_InputByteStream'); + + $is1->expects($this->at(0)) + ->method('write') + ->with('x'); + $is1->expects($this->at(1)) + ->method('write') + ->with('y'); + $is2->expects($this->once()) + ->method('write') + ->with('x'); + + $bs->bind($is1); + $bs->bind($is2); + + $bs->write('x'); + + $bs->unbind($is2); + + $bs->write('y'); + } + + // -- Creation Methods + + private function _createArrayStream($input) + { + return new Swift_ByteStream_ArrayByteStream($input); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/CharacterReader/GenericFixedWidthReaderTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/CharacterReader/GenericFixedWidthReaderTest.php new file mode 100755 index 0000000..3f7a46c --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/CharacterReader/GenericFixedWidthReaderTest.php @@ -0,0 +1,43 @@ +assertSame(1, $reader->getInitialByteSize()); + + $reader = new Swift_CharacterReader_GenericFixedWidthReader(4); + $this->assertSame(4, $reader->getInitialByteSize()); + } + + public function testValidationValueIsBasedOnOctetCount() + { + $reader = new Swift_CharacterReader_GenericFixedWidthReader(4); + + $this->assertSame( + 1, $reader->validateByteSequence(array(0x01, 0x02, 0x03), 3) + ); //3 octets + + $this->assertSame( + 2, $reader->validateByteSequence(array(0x01, 0x0A), 2) + ); //2 octets + + $this->assertSame( + 3, $reader->validateByteSequence(array(0xFE), 1) + ); //1 octet + + $this->assertSame( + 0, $reader->validateByteSequence(array(0xFE, 0x03, 0x67, 0x9A), 4) + ); //All 4 octets + } + + public function testValidationFailsIfTooManyOctets() + { + $reader = new Swift_CharacterReader_GenericFixedWidthReader(6); + + $this->assertSame(-1, $reader->validateByteSequence( + array(0xFE, 0x03, 0x67, 0x9A, 0x10, 0x09, 0x85), 7 + )); //7 octets + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/CharacterReader/UsAsciiReaderTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/CharacterReader/UsAsciiReaderTest.php new file mode 100755 index 0000000..41f8f70 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/CharacterReader/UsAsciiReaderTest.php @@ -0,0 +1,52 @@ +read($size); ) { + $c .= $bytes; + $size = $v->validateCharacter($c); + if (-1 == $size) { + throw new Exception( ... invalid char .. ); + } elseif (0 == $size) { + return $c; //next character in $os + } + } + + */ + + private $_reader; + + public function setUp() + { + $this->_reader = new Swift_CharacterReader_UsAsciiReader(); + } + + public function testAllValidAsciiCharactersReturnZero() + { + for ($ordinal = 0x00; $ordinal <= 0x7F; ++$ordinal) { + $this->assertSame( + 0, $this->_reader->validateByteSequence(array($ordinal), 1) + ); + } + } + + public function testMultipleBytesAreInvalid() + { + for ($ordinal = 0x00; $ordinal <= 0x7F; $ordinal += 2) { + $this->assertSame( + -1, $this->_reader->validateByteSequence(array($ordinal, $ordinal + 1), 2) + ); + } + } + + public function testBytesAboveAsciiRangeAreInvalid() + { + for ($ordinal = 0x80; $ordinal <= 0xFF; ++$ordinal) { + $this->assertSame( + -1, $this->_reader->validateByteSequence(array($ordinal), 1) + ); + } + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/CharacterReader/Utf8ReaderTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/CharacterReader/Utf8ReaderTest.php new file mode 100755 index 0000000..9e9e0a5 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/CharacterReader/Utf8ReaderTest.php @@ -0,0 +1,65 @@ +_reader = new Swift_CharacterReader_Utf8Reader(); + } + + public function testLeading7BitOctetCausesReturnZero() + { + for ($ordinal = 0x00; $ordinal <= 0x7F; ++$ordinal) { + $this->assertSame( + 0, $this->_reader->validateByteSequence(array($ordinal), 1) + ); + } + } + + public function testLeadingByteOf2OctetCharCausesReturn1() + { + for ($octet = 0xC0; $octet <= 0xDF; ++$octet) { + $this->assertSame( + 1, $this->_reader->validateByteSequence(array($octet), 1) + ); + } + } + + public function testLeadingByteOf3OctetCharCausesReturn2() + { + for ($octet = 0xE0; $octet <= 0xEF; ++$octet) { + $this->assertSame( + 2, $this->_reader->validateByteSequence(array($octet), 1) + ); + } + } + + public function testLeadingByteOf4OctetCharCausesReturn3() + { + for ($octet = 0xF0; $octet <= 0xF7; ++$octet) { + $this->assertSame( + 3, $this->_reader->validateByteSequence(array($octet), 1) + ); + } + } + + public function testLeadingByteOf5OctetCharCausesReturn4() + { + for ($octet = 0xF8; $octet <= 0xFB; ++$octet) { + $this->assertSame( + 4, $this->_reader->validateByteSequence(array($octet),1) + ); + } + } + + public function testLeadingByteOf6OctetCharCausesReturn5() + { + for ($octet = 0xFC; $octet <= 0xFD; ++$octet) { + $this->assertSame( + 5, $this->_reader->validateByteSequence(array($octet),1) + ); + } + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/CharacterStream/ArrayCharacterStreamTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/CharacterStream/ArrayCharacterStreamTest.php new file mode 100755 index 0000000..e22e496 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/CharacterStream/ArrayCharacterStreamTest.php @@ -0,0 +1,360 @@ +_getReader(); + $factory = $this->_getFactory($reader); + + $stream = new Swift_CharacterStream_ArrayCharacterStream($factory, 'utf-8'); + + $reader->shouldReceive('getInitialByteSize') + ->zeroOrMoreTimes() + ->andReturn(1); + $reader->shouldReceive('validateByteSequence')->once()->with(array(0xD0), 1)->andReturn(1); + $reader->shouldReceive('validateByteSequence')->once()->with(array(0xD0), 1)->andReturn(1); + $reader->shouldReceive('validateByteSequence')->once()->with(array(0xD0), 1)->andReturn(1); + $reader->shouldReceive('validateByteSequence')->once()->with(array(0xD1), 1)->andReturn(1); + $reader->shouldReceive('validateByteSequence')->once()->with(array(0xD0), 1)->andReturn(1); + $reader->shouldReceive('validateByteSequence')->once()->with(array(0xD0), 1)->andReturn(1); + + $stream->importString(pack('C*', + 0xD0, 0x94, + 0xD0, 0xB6, + 0xD0, 0xBE, + 0xD1, 0x8D, + 0xD0, 0xBB, + 0xD0, 0xB0 + ) + ); + } + + public function testCharactersWrittenUseValidator() + { + $reader = $this->_getReader(); + $factory = $this->_getFactory($reader); + + $stream = new Swift_CharacterStream_ArrayCharacterStream($factory, 'utf-8'); + + $reader->shouldReceive('getInitialByteSize') + ->zeroOrMoreTimes() + ->andReturn(1); + $reader->shouldReceive('validateByteSequence')->once()->with(array(0xD0), 1)->andReturn(1); + $reader->shouldReceive('validateByteSequence')->once()->with(array(0xD0), 1)->andReturn(1); + $reader->shouldReceive('validateByteSequence')->once()->with(array(0xD0), 1)->andReturn(1); + $reader->shouldReceive('validateByteSequence')->once()->with(array(0xD0), 1)->andReturn(1); + $reader->shouldReceive('validateByteSequence')->once()->with(array(0xD1), 1)->andReturn(1); + $reader->shouldReceive('validateByteSequence')->once()->with(array(0xD0), 1)->andReturn(1); + $reader->shouldReceive('validateByteSequence')->once()->with(array(0xD1), 1)->andReturn(1); + $reader->shouldReceive('validateByteSequence')->once()->with(array(0xD1), 1)->andReturn(1); + + $stream->importString(pack('C*', 0xD0, 0x94, 0xD0, 0xB6, 0xD0, 0xBE)); + + $stream->write(pack('C*', + 0xD0, 0xBB, + 0xD1, 0x8E, + 0xD0, 0xB1, + 0xD1, 0x8B, + 0xD1, 0x85 + ) + ); + } + + public function testReadCharactersAreInTact() + { + $reader = $this->_getReader(); + $factory = $this->_getFactory($reader); + + $stream = new Swift_CharacterStream_ArrayCharacterStream($factory, 'utf-8'); + + $reader->shouldReceive('getInitialByteSize') + ->zeroOrMoreTimes() + ->andReturn(1); + //String + $reader->shouldReceive('validateByteSequence')->once()->with(array(0xD0), 1)->andReturn(1); + $reader->shouldReceive('validateByteSequence')->once()->with(array(0xD0), 1)->andReturn(1); + $reader->shouldReceive('validateByteSequence')->once()->with(array(0xD0), 1)->andReturn(1); + //Stream + $reader->shouldReceive('validateByteSequence')->once()->with(array(0xD0), 1)->andReturn(1); + $reader->shouldReceive('validateByteSequence')->once()->with(array(0xD1), 1)->andReturn(1); + $reader->shouldReceive('validateByteSequence')->once()->with(array(0xD0), 1)->andReturn(1); + $reader->shouldReceive('validateByteSequence')->once()->with(array(0xD1), 1)->andReturn(1); + $reader->shouldReceive('validateByteSequence')->once()->with(array(0xD1), 1)->andReturn(1); + + $stream->importString(pack('C*', 0xD0, 0x94, 0xD0, 0xB6, 0xD0, 0xBE)); + + $stream->write(pack('C*', + 0xD0, 0xBB, + 0xD1, 0x8E, + 0xD0, 0xB1, + 0xD1, 0x8B, + 0xD1, 0x85 + ) + ); + + $this->assertIdenticalBinary(pack('C*', 0xD0, 0x94), $stream->read(1)); + $this->assertIdenticalBinary( + pack('C*', 0xD0, 0xB6, 0xD0, 0xBE), $stream->read(2) + ); + $this->assertIdenticalBinary(pack('C*', 0xD0, 0xBB), $stream->read(1)); + $this->assertIdenticalBinary( + pack('C*', 0xD1, 0x8E, 0xD0, 0xB1, 0xD1, 0x8B), $stream->read(3) + ); + $this->assertIdenticalBinary(pack('C*', 0xD1, 0x85), $stream->read(1)); + + $this->assertSame(false, $stream->read(1)); + } + + public function testCharactersCanBeReadAsByteArrays() + { + $reader = $this->_getReader(); + $factory = $this->_getFactory($reader); + + $stream = new Swift_CharacterStream_ArrayCharacterStream($factory, 'utf-8'); + + $reader->shouldReceive('getInitialByteSize') + ->zeroOrMoreTimes() + ->andReturn(1); + //String + $reader->shouldReceive('validateByteSequence')->once()->with(array(0xD0), 1)->andReturn(1); + $reader->shouldReceive('validateByteSequence')->once()->with(array(0xD0), 1)->andReturn(1); + $reader->shouldReceive('validateByteSequence')->once()->with(array(0xD0), 1)->andReturn(1); + //Stream + $reader->shouldReceive('validateByteSequence')->once()->with(array(0xD0), 1)->andReturn(1); + $reader->shouldReceive('validateByteSequence')->once()->with(array(0xD1), 1)->andReturn(1); + $reader->shouldReceive('validateByteSequence')->once()->with(array(0xD0), 1)->andReturn(1); + $reader->shouldReceive('validateByteSequence')->once()->with(array(0xD1), 1)->andReturn(1); + $reader->shouldReceive('validateByteSequence')->once()->with(array(0xD1), 1)->andReturn(1); + + $stream->importString(pack('C*', 0xD0, 0x94, 0xD0, 0xB6, 0xD0, 0xBE)); + + $stream->write(pack('C*', + 0xD0, 0xBB, + 0xD1, 0x8E, + 0xD0, 0xB1, + 0xD1, 0x8B, + 0xD1, 0x85 + ) + ); + + $this->assertEquals(array(0xD0, 0x94), $stream->readBytes(1)); + $this->assertEquals(array(0xD0, 0xB6, 0xD0, 0xBE), $stream->readBytes(2)); + $this->assertEquals(array(0xD0, 0xBB), $stream->readBytes(1)); + $this->assertEquals( + array(0xD1, 0x8E, 0xD0, 0xB1, 0xD1, 0x8B), $stream->readBytes(3) + ); + $this->assertEquals(array(0xD1, 0x85), $stream->readBytes(1)); + + $this->assertSame(false, $stream->readBytes(1)); + } + + public function testRequestingLargeCharCountPastEndOfStream() + { + $reader = $this->_getReader(); + $factory = $this->_getFactory($reader); + + $stream = new Swift_CharacterStream_ArrayCharacterStream($factory, 'utf-8'); + + $reader->shouldReceive('getInitialByteSize') + ->zeroOrMoreTimes() + ->andReturn(1); + $reader->shouldReceive('validateByteSequence')->once()->with(array(0xD0), 1)->andReturn(1); + $reader->shouldReceive('validateByteSequence')->once()->with(array(0xD0), 1)->andReturn(1); + $reader->shouldReceive('validateByteSequence')->once()->with(array(0xD0), 1)->andReturn(1); + + $stream->importString(pack('C*', 0xD0, 0x94, 0xD0, 0xB6, 0xD0, 0xBE)); + + $this->assertIdenticalBinary(pack('C*', 0xD0, 0x94, 0xD0, 0xB6, 0xD0, 0xBE), + $stream->read(100) + ); + + $this->assertSame(false, $stream->read(1)); + } + + public function testRequestingByteArrayCountPastEndOfStream() + { + $reader = $this->_getReader(); + $factory = $this->_getFactory($reader); + + $stream = new Swift_CharacterStream_ArrayCharacterStream($factory, 'utf-8'); + + $reader->shouldReceive('getInitialByteSize') + ->zeroOrMoreTimes() + ->andReturn(1); + $reader->shouldReceive('validateByteSequence')->once()->with(array(0xD0), 1)->andReturn(1); + $reader->shouldReceive('validateByteSequence')->once()->with(array(0xD0), 1)->andReturn(1); + $reader->shouldReceive('validateByteSequence')->once()->with(array(0xD0), 1)->andReturn(1); + + $stream->importString(pack('C*', 0xD0, 0x94, 0xD0, 0xB6, 0xD0, 0xBE)); + + $this->assertEquals(array(0xD0, 0x94, 0xD0, 0xB6, 0xD0, 0xBE), + $stream->readBytes(100) + ); + + $this->assertSame(false, $stream->readBytes(1)); + } + + public function testPointerOffsetCanBeSet() + { + $reader = $this->_getReader(); + $factory = $this->_getFactory($reader); + + $stream = new Swift_CharacterStream_ArrayCharacterStream($factory, 'utf-8'); + + $reader->shouldReceive('getInitialByteSize') + ->zeroOrMoreTimes() + ->andReturn(1); + $reader->shouldReceive('validateByteSequence')->once()->with(array(0xD0), 1)->andReturn(1); + $reader->shouldReceive('validateByteSequence')->once()->with(array(0xD0), 1)->andReturn(1); + $reader->shouldReceive('validateByteSequence')->once()->with(array(0xD0), 1)->andReturn(1); + + $stream->importString(pack('C*', 0xD0, 0x94, 0xD0, 0xB6, 0xD0, 0xBE)); + + $this->assertIdenticalBinary(pack('C*', 0xD0, 0x94), $stream->read(1)); + + $stream->setPointer(0); + + $this->assertIdenticalBinary(pack('C*', 0xD0, 0x94), $stream->read(1)); + + $stream->setPointer(2); + + $this->assertIdenticalBinary(pack('C*', 0xD0, 0xBE), $stream->read(1)); + } + + public function testContentsCanBeFlushed() + { + $reader = $this->_getReader(); + $factory = $this->_getFactory($reader); + + $stream = new Swift_CharacterStream_ArrayCharacterStream($factory, 'utf-8'); + + $reader->shouldReceive('getInitialByteSize') + ->zeroOrMoreTimes() + ->andReturn(1); + $reader->shouldReceive('validateByteSequence')->once()->with(array(0xD0), 1)->andReturn(1); + $reader->shouldReceive('validateByteSequence')->once()->with(array(0xD0), 1)->andReturn(1); + $reader->shouldReceive('validateByteSequence')->once()->with(array(0xD0), 1)->andReturn(1); + + $stream->importString(pack('C*', 0xD0, 0x94, 0xD0, 0xB6, 0xD0, 0xBE)); + + $stream->flushContents(); + + $this->assertSame(false, $stream->read(1)); + } + + public function testByteStreamCanBeImportingUsesValidator() + { + $reader = $this->_getReader(); + $factory = $this->_getFactory($reader); + $os = $this->_getByteStream(); + + $stream = new Swift_CharacterStream_ArrayCharacterStream($factory, 'utf-8'); + + $os->shouldReceive('setReadPointer') + ->between(0, 1) + ->with(0); + $os->shouldReceive('read')->once()->andReturn(pack('C*', 0xD0)); + $os->shouldReceive('read')->once()->andReturn(pack('C*', 0x94)); + $os->shouldReceive('read')->once()->andReturn(pack('C*', 0xD0)); + $os->shouldReceive('read')->once()->andReturn(pack('C*', 0xB6)); + $os->shouldReceive('read')->once()->andReturn(pack('C*', 0xD0)); + $os->shouldReceive('read')->once()->andReturn(pack('C*', 0xBE)); + $os->shouldReceive('read') + ->zeroOrMoreTimes() + ->andReturn(false); + + $reader->shouldReceive('getInitialByteSize') + ->zeroOrMoreTimes() + ->andReturn(1); + $reader->shouldReceive('validateByteSequence')->once()->with(array(0xD0), 1)->andReturn(1); + $reader->shouldReceive('validateByteSequence')->once()->with(array(0xD0), 1)->andReturn(1); + $reader->shouldReceive('validateByteSequence')->once()->with(array(0xD0), 1)->andReturn(1); + + $stream->importByteStream($os); + } + + public function testImportingStreamProducesCorrectCharArray() + { + $reader = $this->_getReader(); + $factory = $this->_getFactory($reader); + $os = $this->_getByteStream(); + + $stream = new Swift_CharacterStream_ArrayCharacterStream($factory, 'utf-8'); + + $os->shouldReceive('setReadPointer') + ->between(0, 1) + ->with(0); + $os->shouldReceive('read')->once()->andReturn(pack('C*', 0xD0)); + $os->shouldReceive('read')->once()->andReturn(pack('C*', 0x94)); + $os->shouldReceive('read')->once()->andReturn(pack('C*', 0xD0)); + $os->shouldReceive('read')->once()->andReturn(pack('C*', 0xB6)); + $os->shouldReceive('read')->once()->andReturn(pack('C*', 0xD0)); + $os->shouldReceive('read')->once()->andReturn(pack('C*', 0xBE)); + $os->shouldReceive('read') + ->zeroOrMoreTimes() + ->andReturn(false); + + $reader->shouldReceive('getInitialByteSize') + ->zeroOrMoreTimes() + ->andReturn(1); + $reader->shouldReceive('validateByteSequence')->once()->with(array(0xD0), 1)->andReturn(1); + $reader->shouldReceive('validateByteSequence')->once()->with(array(0xD0), 1)->andReturn(1); + $reader->shouldReceive('validateByteSequence')->once()->with(array(0xD0), 1)->andReturn(1); + + $stream->importByteStream($os); + + $this->assertIdenticalBinary(pack('C*', 0xD0, 0x94), $stream->read(1)); + $this->assertIdenticalBinary(pack('C*', 0xD0, 0xB6), $stream->read(1)); + $this->assertIdenticalBinary(pack('C*', 0xD0, 0xBE), $stream->read(1)); + + $this->assertSame(false, $stream->read(1)); + } + + public function testAlgorithmWithFixedWidthCharsets() + { + $reader = $this->_getReader(); + $factory = $this->_getFactory($reader); + + $reader->shouldReceive('getInitialByteSize') + ->zeroOrMoreTimes() + ->andReturn(2); + $reader->shouldReceive('validateByteSequence')->once()->with(array(0xD1, 0x8D), 2); + $reader->shouldReceive('validateByteSequence')->once()->with(array(0xD0, 0xBB), 2); + $reader->shouldReceive('validateByteSequence')->once()->with(array(0xD0, 0xB0), 2); + + $stream = new Swift_CharacterStream_ArrayCharacterStream( + $factory, 'utf-8' + ); + $stream->importString(pack('C*', 0xD1, 0x8D, 0xD0, 0xBB, 0xD0, 0xB0)); + + $this->assertIdenticalBinary(pack('C*', 0xD1, 0x8D), $stream->read(1)); + $this->assertIdenticalBinary(pack('C*', 0xD0, 0xBB), $stream->read(1)); + $this->assertIdenticalBinary(pack('C*', 0xD0, 0xB0), $stream->read(1)); + + $this->assertSame(false, $stream->read(1)); + } + + // -- Creation methods + + private function _getReader() + { + return $this->getMockery('Swift_CharacterReader'); + } + + private function _getFactory($reader) + { + $factory = $this->getMockery('Swift_CharacterReaderFactory'); + $factory->shouldReceive('getReaderFor') + ->zeroOrMoreTimes() + ->with('utf-8') + ->andReturn($reader); + + return $factory; + } + + private function _getByteStream() + { + return $this->getMockery('Swift_OutputByteStream'); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/DependencyContainerTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/DependencyContainerTest.php new file mode 100755 index 0000000..bc4a79b --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/DependencyContainerTest.php @@ -0,0 +1,174 @@ +arg1 = $arg1; + $this->arg2 = $arg2; + } +} + +class Swift_DependencyContainerTest extends \PHPUnit_Framework_TestCase +{ + private $_container; + + public function setUp() + { + $this->_container = new Swift_DependencyContainer(); + } + + public function testRegisterAndLookupValue() + { + $this->_container->register('foo')->asValue('bar'); + $this->assertEquals('bar', $this->_container->lookup('foo')); + } + + public function testHasReturnsTrueForRegisteredValue() + { + $this->_container->register('foo')->asValue('bar'); + $this->assertTrue($this->_container->has('foo')); + } + + public function testHasReturnsFalseForUnregisteredValue() + { + $this->assertFalse($this->_container->has('foo')); + } + + public function testRegisterAndLookupNewInstance() + { + $this->_container->register('one')->asNewInstanceOf('One'); + $this->assertInstanceof('One', $this->_container->lookup('one')); + } + + public function testHasReturnsTrueForRegisteredInstance() + { + $this->_container->register('one')->asNewInstanceOf('One'); + $this->assertTrue($this->_container->has('one')); + } + + public function testNewInstanceIsAlwaysNew() + { + $this->_container->register('one')->asNewInstanceOf('One'); + $a = $this->_container->lookup('one'); + $b = $this->_container->lookup('one'); + $this->assertEquals($a, $b); + } + + public function testRegisterAndLookupSharedInstance() + { + $this->_container->register('one')->asSharedInstanceOf('One'); + $this->assertInstanceof('One', $this->_container->lookup('one')); + } + + public function testHasReturnsTrueForSharedInstance() + { + $this->_container->register('one')->asSharedInstanceOf('One'); + $this->assertTrue($this->_container->has('one')); + } + + public function testMultipleSharedInstancesAreSameInstance() + { + $this->_container->register('one')->asSharedInstanceOf('One'); + $a = $this->_container->lookup('one'); + $b = $this->_container->lookup('one'); + $this->assertEquals($a, $b); + } + + public function testNewInstanceWithDependencies() + { + $this->_container->register('foo')->asValue('FOO'); + $this->_container->register('one')->asNewInstanceOf('One') + ->withDependencies(array('foo')); + $obj = $this->_container->lookup('one'); + $this->assertSame('FOO', $obj->arg1); + } + + public function testNewInstanceWithMultipleDependencies() + { + $this->_container->register('foo')->asValue('FOO'); + $this->_container->register('bar')->asValue(42); + $this->_container->register('one')->asNewInstanceOf('One') + ->withDependencies(array('foo', 'bar')); + $obj = $this->_container->lookup('one'); + $this->assertSame('FOO', $obj->arg1); + $this->assertSame(42, $obj->arg2); + } + + public function testNewInstanceWithInjectedObjects() + { + $this->_container->register('foo')->asValue('FOO'); + $this->_container->register('one')->asNewInstanceOf('One'); + $this->_container->register('two')->asNewInstanceOf('One') + ->withDependencies(array('one', 'foo')); + $obj = $this->_container->lookup('two'); + $this->assertEquals($this->_container->lookup('one'), $obj->arg1); + $this->assertSame('FOO', $obj->arg2); + } + + public function testNewInstanceWithAddConstructorValue() + { + $this->_container->register('one')->asNewInstanceOf('One') + ->addConstructorValue('x') + ->addConstructorValue(99); + $obj = $this->_container->lookup('one'); + $this->assertSame('x', $obj->arg1); + $this->assertSame(99, $obj->arg2); + } + + public function testNewInstanceWithAddConstructorLookup() + { + $this->_container->register('foo')->asValue('FOO'); + $this->_container->register('bar')->asValue(42); + $this->_container->register('one')->asNewInstanceOf('One') + ->addConstructorLookup('foo') + ->addConstructorLookup('bar'); + + $obj = $this->_container->lookup('one'); + $this->assertSame('FOO', $obj->arg1); + $this->assertSame(42, $obj->arg2); + } + + public function testResolvedDependenciesCanBeLookedUp() + { + $this->_container->register('foo')->asValue('FOO'); + $this->_container->register('one')->asNewInstanceOf('One'); + $this->_container->register('two')->asNewInstanceOf('One') + ->withDependencies(array('one', 'foo')); + $deps = $this->_container->createDependenciesFor('two'); + $this->assertEquals( + array($this->_container->lookup('one'), 'FOO'), $deps + ); + } + + public function testArrayOfDependenciesCanBeSpecified() + { + $this->_container->register('foo')->asValue('FOO'); + $this->_container->register('one')->asNewInstanceOf('One'); + $this->_container->register('two')->asNewInstanceOf('One') + ->withDependencies(array(array('one', 'foo'), 'foo')); + + $obj = $this->_container->lookup('two'); + $this->assertEquals(array($this->_container->lookup('one'), 'FOO'), $obj->arg1); + $this->assertSame('FOO', $obj->arg2); + } + + public function testAliasCanBeSet() + { + $this->_container->register('foo')->asValue('FOO'); + $this->_container->register('bar')->asAliasOf('foo'); + + $this->assertSame('FOO', $this->_container->lookup('bar')); + } + + public function testAliasOfAliasCanBeSet() + { + $this->_container->register('foo')->asValue('FOO'); + $this->_container->register('bar')->asAliasOf('foo'); + $this->_container->register('zip')->asAliasOf('bar'); + $this->_container->register('button')->asAliasOf('zip'); + + $this->assertSame('FOO', $this->_container->lookup('button')); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Encoder/Base64EncoderTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Encoder/Base64EncoderTest.php new file mode 100755 index 0000000..a9f500c --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Encoder/Base64EncoderTest.php @@ -0,0 +1,173 @@ +_encoder = new Swift_Encoder_Base64Encoder(); + } + + /* + There's really no point in testing the entire base64 encoding to the + level QP encoding has been tested. base64_encode() has been in PHP for + years. + */ + + public function testInputOutputRatioIs3to4Bytes() + { + /* + RFC 2045, 6.8 + + The encoding process represents 24-bit groups of input bits as output + strings of 4 encoded characters. Proceeding from left to right, a + 24-bit input group is formed by concatenating 3 8bit input groups. + These 24 bits are then treated as 4 concatenated 6-bit groups, each + of which is translated into a single digit in the base64 alphabet. + */ + + $this->assertEquals( + 'MTIz', $this->_encoder->encodeString('123'), + '%s: 3 bytes of input should yield 4 bytes of output' + ); + $this->assertEquals( + 'MTIzNDU2', $this->_encoder->encodeString('123456'), + '%s: 6 bytes in input should yield 8 bytes of output' + ); + $this->assertEquals( + 'MTIzNDU2Nzg5', $this->_encoder->encodeString('123456789'), + '%s: 9 bytes in input should yield 12 bytes of output' + ); + } + + public function testPadLength() + { + /* + RFC 2045, 6.8 + + Special processing is performed if fewer than 24 bits are available + at the end of the data being encoded. A full encoding quantum is + always completed at the end of a body. When fewer than 24 input bits + are available in an input group, zero bits are added (on the right) + to form an integral number of 6-bit groups. Padding at the end of + the data is performed using the "=" character. Since all base64 + input is an integral number of octets, only the following cases can + arise: (1) the final quantum of encoding input is an integral + multiple of 24 bits; here, the final unit of encoded output will be + an integral multiple of 4 characters with no "=" padding, (2) the + final quantum of encoding input is exactly 8 bits; here, the final + unit of encoded output will be two characters followed by two "=" + padding characters, or (3) the final quantum of encoding input is + exactly 16 bits; here, the final unit of encoded output will be three + characters followed by one "=" padding character. + */ + + for ($i = 0; $i < 30; ++$i) { + $input = pack('C', rand(0, 255)); + $this->assertRegExp( + '~^[a-zA-Z0-9/\+]{2}==$~', $this->_encoder->encodeString($input), + '%s: A single byte should have 2 bytes of padding' + ); + } + + for ($i = 0; $i < 30; ++$i) { + $input = pack('C*', rand(0, 255), rand(0, 255)); + $this->assertRegExp( + '~^[a-zA-Z0-9/\+]{3}=$~', $this->_encoder->encodeString($input), + '%s: Two bytes should have 1 byte of padding' + ); + } + + for ($i = 0; $i < 30; ++$i) { + $input = pack('C*', rand(0, 255), rand(0, 255), rand(0, 255)); + $this->assertRegExp( + '~^[a-zA-Z0-9/\+]{4}$~', $this->_encoder->encodeString($input), + '%s: Three bytes should have no padding' + ); + } + } + + public function testMaximumLineLengthIs76Characters() + { + /* + The encoded output stream must be represented in lines of no more + than 76 characters each. All line breaks or other characters not + found in Table 1 must be ignored by decoding software. + */ + + $input = + 'abcdefghijklmnopqrstuvwxyz' . + 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' . + '1234567890' . + 'abcdefghijklmnopqrstuvwxyz' . + 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' . + '1234567890' . + 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'; + + $output = + 'YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXpBQk' . //38 + 'NERUZHSElKS0xNTk9QUVJTVFVWV1hZWjEyMzQ1' . "\r\n" . //76 * + 'Njc4OTBhYmNkZWZnaGlqa2xtbm9wcXJzdHV2d3' . //38 + 'h5ekFCQ0RFRkdISUpLTE1OT1BRUlNUVVZXWFla' . "\r\n" . //76 * + 'MTIzNDU2Nzg5MEFCQ0RFRkdISUpLTE1OT1BRUl' . //38 + 'NUVVZXWFla'; //48 + + $this->assertEquals( + $output, $this->_encoder->encodeString($input), + '%s: Lines should be no more than 76 characters' + ); + } + + public function testMaximumLineLengthCanBeSpecified() + { + $input = + 'abcdefghijklmnopqrstuvwxyz' . + 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' . + '1234567890' . + 'abcdefghijklmnopqrstuvwxyz' . + 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' . + '1234567890' . + 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'; + + $output = + 'YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXpBQk' . //38 + 'NERUZHSElKS0' . "\r\n" . //50 * + 'xNTk9QUVJTVFVWV1hZWjEyMzQ1Njc4OTBhYmNk' . //38 + 'ZWZnaGlqa2xt' . "\r\n" . //50 * + 'bm9wcXJzdHV2d3h5ekFCQ0RFRkdISUpLTE1OT1' . //38 + 'BRUlNUVVZXWF' . "\r\n" . //50 * + 'laMTIzNDU2Nzg5MEFCQ0RFRkdISUpLTE1OT1BR' . //38 + 'UlNUVVZXWFla'; //50 * + + $this->assertEquals( + $output, $this->_encoder->encodeString($input, 0, 50), + '%s: Lines should be no more than 100 characters' + ); + } + + public function testFirstLineLengthCanBeDifferent() + { + $input = + 'abcdefghijklmnopqrstuvwxyz' . + 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' . + '1234567890' . + 'abcdefghijklmnopqrstuvwxyz' . + 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' . + '1234567890' . + 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'; + + $output = + 'YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXpBQk' . //38 + 'NERUZHSElKS0xNTk9QU' . "\r\n" . //57 * + 'VJTVFVWV1hZWjEyMzQ1Njc4OTBhYmNkZWZnaGl' . //38 + 'qa2xtbm9wcXJzdHV2d3h5ekFCQ0RFRkdISUpLT' . "\r\n" . //76 * + 'E1OT1BRUlNUVVZXWFlaMTIzNDU2Nzg5MEFCQ0R' . //38 + 'FRkdISUpLTE1OT1BRUlNUVVZXWFla'; //67 + + $this->assertEquals( + $output, $this->_encoder->encodeString($input, 19), + '%s: First line offset is 19 so first line should be 57 chars long' + ); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Encoder/QpEncoderTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Encoder/QpEncoderTest.php new file mode 100755 index 0000000..1068571 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Encoder/QpEncoderTest.php @@ -0,0 +1,381 @@ +_createCharStream(); + $charStream->shouldReceive('flushContents') + ->once(); + $charStream->shouldReceive('importString') + ->once() + ->with($char); + $charStream->shouldReceive('readBytes') + ->once() + ->andReturn(array($ordinal)); + $charStream->shouldReceive('readBytes') + ->atLeast()->times(1) + ->andReturn(false); + + $encoder = new Swift_Encoder_QpEncoder($charStream); + + $this->assertIdenticalBinary($char, $encoder->encodeString($char)); + } + } + + public function testWhiteSpaceAtLineEndingIsEncoded() + { + /* -- RFC 2045, 6.7 -- + (3) (White Space) Octets with values of 9 and 32 MAY be + represented as US-ASCII TAB (HT) and SPACE characters, + respectively, but MUST NOT be so represented at the end + of an encoded line. Any TAB (HT) or SPACE characters + on an encoded line MUST thus be followed on that line + by a printable character. In particular, an "=" at the + end of an encoded line, indicating a soft line break + (see rule #5) may follow one or more TAB (HT) or SPACE + characters. It follows that an octet with decimal + value 9 or 32 appearing at the end of an encoded line + must be represented according to Rule #1. This rule is + necessary because some MTAs (Message Transport Agents, + programs which transport messages from one user to + another, or perform a portion of such transfers) are + known to pad lines of text with SPACEs, and others are + known to remove "white space" characters from the end + of a line. Therefore, when decoding a Quoted-Printable + body, any trailing white space on a line must be + deleted, as it will necessarily have been added by + intermediate transport agents. + */ + + $HT = chr(0x09); //9 + $SPACE = chr(0x20); //32 + + //HT + $string = 'a' . $HT . $HT . "\r\n" . 'b'; + + $charStream = $this->_createCharStream(); + $charStream->shouldReceive('flushContents') + ->once(); + $charStream->shouldReceive('importString') + ->once() + ->with($string); + + $charStream->shouldReceive('readBytes')->once()->andReturn(array(ord('a'))); + $charStream->shouldReceive('readBytes')->once()->andReturn(array(0x09)); + $charStream->shouldReceive('readBytes')->once()->andReturn(array(0x09)); + $charStream->shouldReceive('readBytes')->once()->andReturn(array(0x0D)); + $charStream->shouldReceive('readBytes')->once()->andReturn(array(0x0A)); + $charStream->shouldReceive('readBytes')->once()->andReturn(array(ord('b'))); + $charStream->shouldReceive('readBytes')->once()->andReturn(false); + + $encoder = new Swift_Encoder_QpEncoder($charStream); + $this->assertEquals( + 'a' . $HT . '=09' . "\r\n" . 'b', + $encoder->encodeString($string) + ); + + //SPACE + $string = 'a' . $SPACE . $SPACE . "\r\n" . 'b'; + + $charStream = $this->_createCharStream(); + $charStream->shouldReceive('flushContents') + ->once(); + $charStream->shouldReceive('importString') + ->once() + ->with($string); + + $charStream->shouldReceive('readBytes')->once()->andReturn(array(ord('a'))); + $charStream->shouldReceive('readBytes')->once()->andReturn(array(0x20)); + $charStream->shouldReceive('readBytes')->once()->andReturn(array(0x20)); + $charStream->shouldReceive('readBytes')->once()->andReturn(array(0x0D)); + $charStream->shouldReceive('readBytes')->once()->andReturn(array(0x0A)); + $charStream->shouldReceive('readBytes')->once()->andReturn(array(ord('b'))); + $charStream->shouldReceive('readBytes')->once()->andReturn(false); + + $encoder = new Swift_Encoder_QpEncoder($charStream); + $this->assertEquals( + 'a' . $SPACE . '=20' . "\r\n" . 'b', + $encoder->encodeString($string) + ); + } + + public function testCRLFIsLeftAlone() + { + /* + (4) (Line Breaks) A line break in a text body, represented + as a CRLF sequence in the text canonical form, must be + represented by a (RFC 822) line break, which is also a + CRLF sequence, in the Quoted-Printable encoding. Since + the canonical representation of media types other than + text do not generally include the representation of + line breaks as CRLF sequences, no hard line breaks + (i.e. line breaks that are intended to be meaningful + and to be displayed to the user) can occur in the + quoted-printable encoding of such types. Sequences + like "=0D", "=0A", "=0A=0D" and "=0D=0A" will routinely + appear in non-text data represented in quoted- + printable, of course. + + Note that many implementations may elect to encode the + local representation of various content types directly + rather than converting to canonical form first, + encoding, and then converting back to local + representation. In particular, this may apply to plain + text material on systems that use newline conventions + other than a CRLF terminator sequence. Such an + implementation optimization is permissible, but only + when the combined canonicalization-encoding step is + equivalent to performing the three steps separately. + */ + + $string = 'a' . "\r\n" . 'b' . "\r\n" . 'c' . "\r\n"; + + $charStream = $this->_createCharStream(); + $charStream->shouldReceive('flushContents') + ->once(); + $charStream->shouldReceive('importString') + ->once() + ->with($string); + + $charStream->shouldReceive('readBytes')->once()->andReturn(array(ord('a'))); + $charStream->shouldReceive('readBytes')->once()->andReturn(array(0x0D)); + $charStream->shouldReceive('readBytes')->once()->andReturn(array(0x0A)); + $charStream->shouldReceive('readBytes')->once()->andReturn(array(ord('b'))); + $charStream->shouldReceive('readBytes')->once()->andReturn(array(0x0D)); + $charStream->shouldReceive('readBytes')->once()->andReturn(array(0x0A)); + $charStream->shouldReceive('readBytes')->once()->andReturn(array(ord('c'))); + $charStream->shouldReceive('readBytes')->once()->andReturn(array(0x0D)); + $charStream->shouldReceive('readBytes')->once()->andReturn(array(0x0A)); + $charStream->shouldReceive('readBytes')->once()->andReturn(false); + + $encoder = new Swift_Encoder_QpEncoder($charStream); + $this->assertEquals($string, $encoder->encodeString($string)); + } + + public function testLinesLongerThan76CharactersAreSoftBroken() + { + /* + (5) (Soft Line Breaks) The Quoted-Printable encoding + REQUIRES that encoded lines be no more than 76 + characters long. If longer lines are to be encoded + with the Quoted-Printable encoding, "soft" line breaks + must be used. An equal sign as the last character on a + encoded line indicates such a non-significant ("soft") + line break in the encoded text. + */ + + $input = str_repeat('a', 140); + + $charStream = $this->_createCharStream(); + $charStream->shouldReceive('flushContents') + ->once(); + $charStream->shouldReceive('importString') + ->once() + ->with($input); + + $output = ''; + for ($i = 0; $i < 140; ++$i) { + $charStream->shouldReceive('readBytes') + ->once() + ->andReturn(array(ord('a'))); + + if (75 == $i) { + $output .= "=\r\n"; + } + $output .= 'a'; + } + + $charStream->shouldReceive('readBytes') + ->once() + ->andReturn(false); + + $encoder = new Swift_Encoder_QpEncoder($charStream); + $this->assertEquals($output, $encoder->encodeString($input)); + } + + public function testMaxLineLengthCanBeSpecified() + { + $input = str_repeat('a', 100); + + $charStream = $this->_createCharStream(); + $charStream->shouldReceive('flushContents') + ->once(); + $charStream->shouldReceive('importString') + ->once() + ->with($input); + + $output = ''; + for ($i = 0; $i < 100; ++$i) { + $charStream->shouldReceive('readBytes') + ->once() + ->andReturn(array(ord('a'))); + + if (53 == $i) { + $output .= "=\r\n"; + } + $output .= 'a'; + } + $charStream->shouldReceive('readBytes') + ->once() + ->andReturn(false); + + $encoder = new Swift_Encoder_QpEncoder($charStream); + $this->assertEquals($output, $encoder->encodeString($input, 0, 54)); + } + + public function testBytesBelowPermittedRangeAreEncoded() + { + /* + According to Rule (1 & 2) + */ + + foreach (range(0, 32) as $ordinal) { + $char = chr($ordinal); + + $charStream = $this->_createCharStream(); + $charStream->shouldReceive('flushContents') + ->once(); + $charStream->shouldReceive('importString') + ->once() + ->with($char); + $charStream->shouldReceive('readBytes') + ->once() + ->andReturn(array($ordinal)); + $charStream->shouldReceive('readBytes') + ->atLeast()->times(1) + ->andReturn(false); + + $encoder = new Swift_Encoder_QpEncoder($charStream); + + $this->assertEquals( + sprintf('=%02X', $ordinal), $encoder->encodeString($char) + ); + } + } + + public function testDecimalByte61IsEncoded() + { + /* + According to Rule (1 & 2) + */ + + $char = '='; + + $charStream = $this->_createCharStream(); + $charStream->shouldReceive('flushContents') + ->once(); + $charStream->shouldReceive('importString') + ->once() + ->with($char); + $charStream->shouldReceive('readBytes') + ->once() + ->andReturn(array(61)); + $charStream->shouldReceive('readBytes') + ->atLeast()->times(1) + ->andReturn(false); + + $encoder = new Swift_Encoder_QpEncoder($charStream); + + $this->assertEquals('=3D', $encoder->encodeString('=')); + } + + public function testBytesAbovePermittedRangeAreEncoded() + { + /* + According to Rule (1 & 2) + */ + + foreach (range(127, 255) as $ordinal) { + $char = chr($ordinal); + + $charStream = $this->_createCharStream(); + $charStream->shouldReceive('flushContents') + ->once(); + $charStream->shouldReceive('importString') + ->once() + ->with($char); + $charStream->shouldReceive('readBytes') + ->once() + ->andReturn(array($ordinal)); + $charStream->shouldReceive('readBytes') + ->atLeast()->times(1) + ->andReturn(false); + + $encoder = new Swift_Encoder_QpEncoder($charStream); + + $this->assertEquals( + sprintf('=%02X', $ordinal), $encoder->encodeString($char) + ); + } + } + + public function testFirstLineLengthCanBeDifferent() + { + $input = str_repeat('a', 140); + + $charStream = $this->_createCharStream(); + $charStream->shouldReceive('flushContents') + ->once(); + $charStream->shouldReceive('importString') + ->once() + ->with($input); + + $output = ''; + for ($i = 0; $i < 140; ++$i) { + $charStream->shouldReceive('readBytes') + ->once() + ->andReturn(array(ord('a'))); + + if (53 == $i || 53 + 75 == $i) { + $output .= "=\r\n"; + } + $output .= 'a'; + } + + $charStream->shouldReceive('readBytes') + ->once() + ->andReturn(false); + + $encoder = new Swift_Encoder_QpEncoder($charStream); + $this->assertEquals( + $output, $encoder->encodeString($input, 22), + '%s: First line should start at offset 22 so can only have max length 54' + ); + } + + // -- Creation methods + + private function _createCharStream() + { + return $this->getMockery('Swift_CharacterStream')->shouldIgnoreMissing(); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Encoder/Rfc2231EncoderTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Encoder/Rfc2231EncoderTest.php new file mode 100755 index 0000000..c02a226 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Encoder/Rfc2231EncoderTest.php @@ -0,0 +1,146 @@ +getMockery('Swift_CharacterStream'); + + $string = ''; + foreach (range(0x00, 0x7F) as $octet) { + $char = pack('C', $octet); + $string .= $char; + $charStream->shouldReceive('read') + ->once() + ->andReturn($char); + } + + $charStream->shouldReceive('flushContents') + ->once(); + $charStream->shouldReceive('importString') + ->once() + ->with($string); + $charStream->shouldReceive('read') + ->atLeast()->times(1) + ->andReturn(false); + + $encoder = new Swift_Encoder_Rfc2231Encoder($charStream); + $encoded = $encoder->encodeString($string); + + foreach (explode("\r\n", $encoded) as $line) { + $this->assertRegExp($this->_rfc2045Token, $line, + '%s: Encoder should always return a valid RFC 2045 token.'); + } + } + + public function testEncodingNonAsciiCharactersProducesValidToken() + { + $charStream = $this->getMockery('Swift_CharacterStream'); + + $string = ''; + foreach (range(0x80, 0xFF) as $octet) { + $char = pack('C', $octet); + $string .= $char; + $charStream->shouldReceive('read') + ->once() + ->andReturn($char); + } + $charStream->shouldReceive('flushContents') + ->once(); + $charStream->shouldReceive('importString') + ->once() + ->with($string); + $charStream->shouldReceive('read') + ->atLeast()->times(1) + ->andReturn(false); + $encoder = new Swift_Encoder_Rfc2231Encoder($charStream); + + $encoded = $encoder->encodeString($string); + + foreach (explode("\r\n", $encoded) as $line) { + $this->assertRegExp($this->_rfc2045Token, $line, + '%s: Encoder should always return a valid RFC 2045 token.'); + } + + + } + + public function testMaximumLineLengthCanBeSet() + { + $charStream = $this->getMockery('Swift_CharacterStream'); + + $string = ''; + for ($x = 0; $x < 200; ++$x) { + $char = 'a'; + $string .= $char; + $charStream->shouldReceive('read') + ->once() + ->andReturn($char); + } + $charStream->shouldReceive('flushContents') + ->once(); + $charStream->shouldReceive('importString') + ->once() + ->with($string); + $charStream->shouldReceive('read') + ->atLeast()->times(1) + ->andReturn(false); + $encoder = new Swift_Encoder_Rfc2231Encoder($charStream); + + $encoded = $encoder->encodeString($string, 0, 75); + + $this->assertEquals( + str_repeat('a', 75) . "\r\n" . + str_repeat('a', 75) . "\r\n" . + str_repeat('a', 50), + $encoded, + '%s: Lines should be wrapped at each 75 characters' + ); + + + } + + public function testFirstLineCanHaveShorterLength() + { + $charStream = $this->getMockery('Swift_CharacterStream'); + + $string = ''; + for ($x = 0; $x < 200; ++$x) { + $char = 'a'; + $string .= $char; + $charStream->shouldReceive('read') + ->once() + ->andReturn($char); + } + $charStream->shouldReceive('flushContents') + ->once(); + $charStream->shouldReceive('importString') + ->once() + ->with($string); + $charStream->shouldReceive('read') + ->atLeast()->times(1) + ->andReturn(false); + $encoder = new Swift_Encoder_Rfc2231Encoder($charStream); + $encoded = $encoder->encodeString($string, 25, 75); + + $this->assertEquals( + str_repeat('a', 50) . "\r\n" . + str_repeat('a', 75) . "\r\n" . + str_repeat('a', 75), + $encoded, + '%s: First line should be 25 bytes shorter than the others.' + ); + + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Events/CommandEventTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Events/CommandEventTest.php new file mode 100755 index 0000000..7e59802 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Events/CommandEventTest.php @@ -0,0 +1,36 @@ +_createEvent($this->_createTransport(), "FOO\r\n"); + $this->assertEquals("FOO\r\n", $evt->getCommand()); + } + + public function testSuccessCodesCanBeFetchedViaGetter() + { + $evt = $this->_createEvent($this->_createTransport(), "FOO\r\n", array(250)); + $this->assertEquals(array(250), $evt->getSuccessCodes()); + } + + public function testSourceIsBuffer() + { + $transport = $this->_createTransport(); + $evt = $this->_createEvent($transport, "FOO\r\n"); + $ref = $evt->getSource(); + $this->assertEquals($transport, $ref); + } + + // -- Creation Methods + + private function _createEvent(Swift_Transport $source, $command, $successCodes = array()) + { + return new Swift_Events_CommandEvent($source, $command, $successCodes); + } + + private function _createTransport() + { + return $this->getMock('Swift_Transport'); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Events/EventObjectTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Events/EventObjectTest.php new file mode 100755 index 0000000..62a91be --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Events/EventObjectTest.php @@ -0,0 +1,34 @@ +_createEvent($source); + $ref = $evt->getSource(); + $this->assertEquals($source, $ref); + } + + public function testEventDoesNotHaveCancelledBubbleWhenNew() + { + $source = new stdClass(); + $evt = $this->_createEvent($source); + $this->assertFalse($evt->bubbleCancelled()); + } + + public function testBubbleCanBeCancelledInEvent() + { + $source = new stdClass(); + $evt = $this->_createEvent($source); + $evt->cancelBubble(); + $this->assertTrue($evt->bubbleCancelled()); + } + + // -- Creation Methods + + private function _createEvent($source) + { + return new Swift_Events_EventObject($source); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Events/ResponseEventTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Events/ResponseEventTest.php new file mode 100755 index 0000000..e0f3e36 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Events/ResponseEventTest.php @@ -0,0 +1,40 @@ +_createEvent($this->_createTransport(), "250 Ok\r\n", true); + $this->assertEquals("250 Ok\r\n", $evt->getResponse(), + '%s: Response should be available via getResponse()' + ); + } + + public function testResultCanBeFetchedViaGetter() + { + $evt = $this->_createEvent($this->_createTransport(), "250 Ok\r\n", false); + $this->assertFalse($evt->isValid(), + '%s: Result should be checkable via isValid()' + ); + } + + public function testSourceIsBuffer() + { + $transport = $this->_createTransport(); + $evt = $this->_createEvent($transport, "250 Ok\r\n", true); + $ref = $evt->getSource(); + $this->assertEquals($transport, $ref); + } + + // -- Creation Methods + + private function _createEvent(Swift_Transport $source, $response, $result) + { + return new Swift_Events_ResponseEvent($source, $response, $result); + } + + private function _createTransport() + { + return $this->getMock('Swift_Transport'); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Events/SendEventTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Events/SendEventTest.php new file mode 100755 index 0000000..8003870 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Events/SendEventTest.php @@ -0,0 +1,99 @@ +_createMessage(); + $transport = $this->_createTransport(); + + $evt = $this->_createEvent($transport, $message); + + $ref = $evt->getMessage(); + $this->assertEquals($message, $ref, + '%s: Message should be returned from getMessage()' + ); + } + + public function testTransportCanBeFetchViaGetter() + { + $message = $this->_createMessage(); + $transport = $this->_createTransport(); + + $evt = $this->_createEvent($transport, $message); + + $ref = $evt->getTransport(); + $this->assertEquals($transport, $ref, + '%s: Transport should be returned from getTransport()' + ); + } + + public function testTransportCanBeFetchViaGetSource() + { + $message = $this->_createMessage(); + $transport = $this->_createTransport(); + + $evt = $this->_createEvent($transport, $message); + + $ref = $evt->getSource(); + $this->assertEquals($transport, $ref, + '%s: Transport should be returned from getSource()' + ); + } + + public function testResultCanBeSetAndGet() + { + $message = $this->_createMessage(); + $transport = $this->_createTransport(); + + $evt = $this->_createEvent($transport, $message); + + $evt->setResult( + Swift_Events_SendEvent::RESULT_SUCCESS | Swift_Events_SendEvent::RESULT_TENTATIVE + ); + + $this->assertTrue((bool) ($evt->getResult() & Swift_Events_SendEvent::RESULT_SUCCESS)); + $this->assertTrue((bool) ($evt->getResult() & Swift_Events_SendEvent::RESULT_TENTATIVE)); + } + + public function testFailedRecipientsCanBeSetAndGet() + { + $message = $this->_createMessage(); + $transport = $this->_createTransport(); + + $evt = $this->_createEvent($transport, $message); + + $evt->setFailedRecipients(array('foo@bar', 'zip@button')); + + $this->assertEquals(array('foo@bar', 'zip@button'), $evt->getFailedRecipients(), + '%s: FailedRecipients should be returned from getter' + ); + } + + public function testFailedRecipientsGetsPickedUpCorrectly() + { + $message = $this->_createMessage(); + $transport = $this->_createTransport(); + + $evt = $this->_createEvent($transport, $message); + $this->assertEquals(array(), $evt->getFailedRecipients()); + } + + // -- Creation Methods + + private function _createEvent(Swift_Transport $source, + Swift_Mime_Message $message) + { + return new Swift_Events_SendEvent($source, $message); + } + + private function _createTransport() + { + return $this->getMock('Swift_Transport'); + } + + private function _createMessage() + { + return $this->getMock('Swift_Mime_Message'); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Events/SimpleEventDispatcherTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Events/SimpleEventDispatcherTest.php new file mode 100755 index 0000000..409f6f2 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Events/SimpleEventDispatcherTest.php @@ -0,0 +1,137 @@ +_dispatcher = new Swift_Events_SimpleEventDispatcher(); + } + + public function testSendEventCanBeCreated() + { + $transport = $this->getMock('Swift_Transport'); + $message = $this->getMock('Swift_Mime_Message'); + $evt = $this->_dispatcher->createSendEvent($transport, $message); + $this->assertInstanceof('Swift_Events_SendEvent', $evt); + $this->assertSame($message, $evt->getMessage()); + $this->assertSame($transport, $evt->getTransport()); + } + + public function testCommandEventCanBeCreated() + { + $buf = $this->getMock('Swift_Transport'); + $evt = $this->_dispatcher->createCommandEvent($buf, "FOO\r\n", array(250)); + $this->assertInstanceof('Swift_Events_CommandEvent', $evt); + $this->assertSame($buf, $evt->getSource()); + $this->assertEquals("FOO\r\n", $evt->getCommand()); + $this->assertEquals(array(250), $evt->getSuccessCodes()); + } + + public function testResponseEventCanBeCreated() + { + $buf = $this->getMock('Swift_Transport'); + $evt = $this->_dispatcher->createResponseEvent($buf, "250 Ok\r\n", true); + $this->assertInstanceof('Swift_Events_ResponseEvent', $evt); + $this->assertSame($buf, $evt->getSource()); + $this->assertEquals("250 Ok\r\n", $evt->getResponse()); + $this->assertTrue($evt->isValid()); + } + + public function testTransportChangeEventCanBeCreated() + { + $transport = $this->getMock('Swift_Transport'); + $evt = $this->_dispatcher->createTransportChangeEvent($transport); + $this->assertInstanceof('Swift_Events_TransportChangeEvent', $evt); + $this->assertSame($transport, $evt->getSource()); + } + + public function testTransportExceptionEventCanBeCreated() + { + $transport = $this->getMock('Swift_Transport'); + $ex = new Swift_TransportException(''); + $evt = $this->_dispatcher->createTransportExceptionEvent($transport, $ex); + $this->assertInstanceof('Swift_Events_TransportExceptionEvent', $evt); + $this->assertSame($transport, $evt->getSource()); + $this->assertSame($ex, $evt->getException()); + } + + public function testListenersAreNotifiedOfDispatchedEvent() + { + $transport = $this->getMock('Swift_Transport'); + + $evt = $this->_dispatcher->createTransportChangeEvent($transport); + + $listenerA = $this->getMock('Swift_Events_TransportChangeListener'); + $listenerB = $this->getMock('Swift_Events_TransportChangeListener'); + + $this->_dispatcher->bindEventListener($listenerA); + $this->_dispatcher->bindEventListener($listenerB); + + $listenerA->expects($this->once()) + ->method('transportStarted') + ->with($evt); + $listenerB->expects($this->once()) + ->method('transportStarted') + ->with($evt); + + $this->_dispatcher->dispatchEvent($evt, 'transportStarted'); + } + + public function testListenersAreOnlyCalledIfImplementingCorrectInterface() + { + $transport = $this->getMock('Swift_Transport'); + $message = $this->getMock('Swift_Mime_Message'); + + $evt = $this->_dispatcher->createSendEvent($transport, $message); + + $targetListener = $this->getMock('Swift_Events_SendListener'); + $otherListener = $this->getMock('Swift_Events_TransportChangeListener'); + + $this->_dispatcher->bindEventListener($targetListener); + $this->_dispatcher->bindEventListener($otherListener); + + $targetListener->expects($this->once()) + ->method('sendPerformed') + ->with($evt); + $otherListener->expects($this->never()) + ->method('sendPerformed'); + + $this->_dispatcher->dispatchEvent($evt, 'sendPerformed'); + } + + public function testListenersCanCancelBubblingOfEvent() + { + $transport = $this->getMock('Swift_Transport'); + $message = $this->getMock('Swift_Mime_Message'); + + $evt = $this->_dispatcher->createSendEvent($transport, $message); + + $listenerA = $this->getMock('Swift_Events_SendListener'); + $listenerB = $this->getMock('Swift_Events_SendListener'); + + $this->_dispatcher->bindEventListener($listenerA); + $this->_dispatcher->bindEventListener($listenerB); + + $listenerA->expects($this->once()) + ->method('sendPerformed') + ->with($evt) + ->will($this->returnCallback(function($object) { + $object->cancelBubble(true); + })); + $listenerB->expects($this->never()) + ->method('sendPerformed'); + + $this->_dispatcher->dispatchEvent($evt, 'sendPerformed'); + + $this->assertTrue($evt->bubbleCancelled()); + } + + // -- Private methods + + private function _createDispatcher(array $map) + { + return new Swift_Events_SimpleEventDispatcher($map); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Events/TransportChangeEventTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Events/TransportChangeEventTest.php new file mode 100755 index 0000000..40bec83 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Events/TransportChangeEventTest.php @@ -0,0 +1,32 @@ +_createTransport(); + $evt = $this->_createEvent($transport); + $ref = $evt->getTransport(); + $this->assertEquals($transport, $ref); + } + + public function testSourceIsTransport() + { + $transport = $this->_createTransport(); + $evt = $this->_createEvent($transport); + $ref = $evt->getSource(); + $this->assertEquals($transport, $ref); + } + + // -- Creation Methods + + private function _createEvent(Swift_Transport $source) + { + return new Swift_Events_TransportChangeEvent($source); + } + + private function _createTransport() + { + return $this->getMock('Swift_Transport'); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Events/TransportExceptionEventTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Events/TransportExceptionEventTest.php new file mode 100755 index 0000000..86c636b --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Events/TransportExceptionEventTest.php @@ -0,0 +1,43 @@ +_createException(); + $transport = $this->_createTransport(); + $evt = $this->_createEvent($transport, $ex); + $ref = $evt->getException(); + $this->assertEquals($ex, $ref, + '%s: Exception should be available via getException()' + ); + } + + public function testSourceIsTransport() + { + $ex = $this->_createException(); + $transport = $this->_createTransport(); + $evt = $this->_createEvent($transport, $ex); + $ref = $evt->getSource(); + $this->assertEquals($transport, $ref, + '%s: Transport should be available via getSource()' + ); + } + + // -- Creation Methods + + private function _createEvent(Swift_Transport $transport, Swift_TransportException $ex) + { + return new Swift_Events_TransportExceptionEvent($transport, $ex); + } + + private function _createTransport() + { + return $this->getMock('Swift_Transport'); + } + + private function _createException() + { + return new Swift_TransportException(''); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/KeyCache/ArrayKeyCacheTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/KeyCache/ArrayKeyCacheTest.php new file mode 100755 index 0000000..47ebc49 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/KeyCache/ArrayKeyCacheTest.php @@ -0,0 +1,242 @@ +_createKeyCacheInputStream(); + $cache = $this->_createCache($is); + $cache->setString( + $this->_key1, 'foo', 'test', Swift_KeyCache::MODE_WRITE + ); + $this->assertEquals('test', $cache->getString($this->_key1, 'foo')); + } + + public function testStringDataCanBeOverwritten() + { + $is = $this->_createKeyCacheInputStream(); + $cache = $this->_createCache($is); + $cache->setString( + $this->_key1, 'foo', 'test', Swift_KeyCache::MODE_WRITE + ); + $cache->setString( + $this->_key1, 'foo', 'whatever', Swift_KeyCache::MODE_WRITE + ); + + $this->assertEquals('whatever', $cache->getString($this->_key1, 'foo')); + } + + public function testStringDataCanBeAppended() + { + $is = $this->_createKeyCacheInputStream(); + $cache = $this->_createCache($is); + $cache->setString( + $this->_key1, 'foo', 'test', Swift_KeyCache::MODE_WRITE + ); + $cache->setString( + $this->_key1, 'foo', 'ing', Swift_KeyCache::MODE_APPEND + ); + + $this->assertEquals('testing', $cache->getString($this->_key1, 'foo')); + } + + public function testHasKeyReturnValue() + { + $is = $this->_createKeyCacheInputStream(); + $cache = $this->_createCache($is); + $cache->setString( + $this->_key1, 'foo', 'test', Swift_KeyCache::MODE_WRITE + ); + + $this->assertTrue($cache->hasKey($this->_key1, 'foo')); + } + + public function testNsKeyIsWellPartitioned() + { + $is = $this->_createKeyCacheInputStream(); + $cache = $this->_createCache($is); + $cache->setString( + $this->_key1, 'foo', 'test', Swift_KeyCache::MODE_WRITE + ); + $cache->setString( + $this->_key2, 'foo', 'ing', Swift_KeyCache::MODE_WRITE + ); + + $this->assertEquals('test', $cache->getString($this->_key1, 'foo')); + $this->assertEquals('ing', $cache->getString($this->_key2, 'foo')); + } + + public function testItemKeyIsWellPartitioned() + { + $is = $this->_createKeyCacheInputStream(); + $cache = $this->_createCache($is); + $cache->setString( + $this->_key1, 'foo', 'test', Swift_KeyCache::MODE_WRITE + ); + $cache->setString( + $this->_key1, 'bar', 'ing', Swift_KeyCache::MODE_WRITE + ); + + $this->assertEquals('test', $cache->getString($this->_key1, 'foo')); + $this->assertEquals('ing', $cache->getString($this->_key1, 'bar')); + } + + public function testByteStreamCanBeImported() + { + $os = $this->_createOutputStream(); + $os->expects($this->at(0)) + ->method('read') + ->will($this->returnValue('abc')); + $os->expects($this->at(1)) + ->method('read') + ->will($this->returnValue('def')); + $os->expects($this->at(2)) + ->method('read') + ->will($this->returnValue(false)); + + $is = $this->_createKeyCacheInputStream(); + $cache = $this->_createCache($is); + $cache->importFromByteStream( + $this->_key1, 'foo', $os, Swift_KeyCache::MODE_WRITE + ); + $this->assertEquals('abcdef', $cache->getString($this->_key1, 'foo')); + } + + public function testByteStreamCanBeAppended() + { + $os1 = $this->_createOutputStream(); + $os1->expects($this->at(0)) + ->method('read') + ->will($this->returnValue('abc')); + $os1->expects($this->at(1)) + ->method('read') + ->will($this->returnValue('def')); + $os1->expects($this->at(2)) + ->method('read') + ->will($this->returnValue(false)); + + $os2 = $this->_createOutputStream(); + $os2->expects($this->at(0)) + ->method('read') + ->will($this->returnValue('xyz')); + $os2->expects($this->at(1)) + ->method('read') + ->will($this->returnValue('uvw')); + $os2->expects($this->at(2)) + ->method('read') + ->will($this->returnValue(false)); + + $is = $this->_createKeyCacheInputStream(true); + + $cache = $this->_createCache($is); + + $cache->importFromByteStream( + $this->_key1, 'foo', $os1, Swift_KeyCache::MODE_APPEND + ); + $cache->importFromByteStream( + $this->_key1, 'foo', $os2, Swift_KeyCache::MODE_APPEND + ); + + $this->assertEquals('abcdefxyzuvw', $cache->getString($this->_key1, 'foo')); + } + + public function testByteStreamAndStringCanBeAppended() + { + $os = $this->_createOutputStream(); + $os->expects($this->at(0)) + ->method('read') + ->will($this->returnValue('abc')); + $os->expects($this->at(1)) + ->method('read') + ->will($this->returnValue('def')); + $os->expects($this->at(2)) + ->method('read') + ->will($this->returnValue(false)); + + $is = $this->_createKeyCacheInputStream(true); + + $cache = $this->_createCache($is); + + $cache->setString( + $this->_key1, 'foo', 'test', Swift_KeyCache::MODE_APPEND + ); + $cache->importFromByteStream( + $this->_key1, 'foo', $os, Swift_KeyCache::MODE_APPEND + ); + $this->assertEquals('testabcdef', $cache->getString($this->_key1, 'foo')); + } + + public function testDataCanBeExportedToByteStream() + { + //See acceptance test for more detail + $is = $this->_createInputStream(); + $is->expects($this->atLeastOnce()) + ->method('write'); + + $kcis = $this->_createKeyCacheInputStream(true); + + $cache = $this->_createCache($kcis); + + $cache->setString( + $this->_key1, 'foo', 'test', Swift_KeyCache::MODE_WRITE + ); + + $cache->exportToByteStream($this->_key1, 'foo', $is); + } + + public function testKeyCanBeCleared() + { + $is = $this->_createKeyCacheInputStream(); + $cache = $this->_createCache($is); + + $cache->setString( + $this->_key1, 'foo', 'test', Swift_KeyCache::MODE_WRITE + ); + $this->assertTrue($cache->hasKey($this->_key1, 'foo')); + $cache->clearKey($this->_key1, 'foo'); + $this->assertFalse($cache->hasKey($this->_key1, 'foo')); + } + + public function testNsKeyCanBeCleared() + { + $is = $this->_createKeyCacheInputStream(); + $cache = $this->_createCache($is); + + $cache->setString( + $this->_key1, 'foo', 'test', Swift_KeyCache::MODE_WRITE + ); + $cache->setString( + $this->_key1, 'bar', 'xyz', Swift_KeyCache::MODE_WRITE + ); + $this->assertTrue($cache->hasKey($this->_key1, 'foo')); + $this->assertTrue($cache->hasKey($this->_key1, 'bar')); + $cache->clearAll($this->_key1); + $this->assertFalse($cache->hasKey($this->_key1, 'foo')); + $this->assertFalse($cache->hasKey($this->_key1, 'bar')); + } + + // -- Creation methods + + private function _createCache($is) + { + return new Swift_KeyCache_ArrayKeyCache($is); + } + + private function _createKeyCacheInputStream() + { + return $this->getMock('Swift_KeyCache_KeyCacheInputStream'); + } + + private function _createOutputStream() + { + return $this->getMock('Swift_OutputByteStream'); + } + + private function _createInputStream() + { + return $this->getMock('Swift_InputByteStream'); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/KeyCache/SimpleKeyCacheInputStreamTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/KeyCache/SimpleKeyCacheInputStreamTest.php new file mode 100755 index 0000000..691c1e7 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/KeyCache/SimpleKeyCacheInputStreamTest.php @@ -0,0 +1,73 @@ +getMock('Swift_KeyCache'); + $cache->expects($this->at(0)) + ->method('setString') + ->with($this->_nsKey, 'foo', 'a', Swift_KeyCache::MODE_APPEND); + $cache->expects($this->at(1)) + ->method('setString') + ->with($this->_nsKey, 'foo', 'b', Swift_KeyCache::MODE_APPEND); + $cache->expects($this->at(2)) + ->method('setString') + ->with($this->_nsKey, 'foo', 'c', Swift_KeyCache::MODE_APPEND); + + $stream = new Swift_KeyCache_SimpleKeyCacheInputStream(); + $stream->setKeyCache($cache); + $stream->setNsKey($this->_nsKey); + $stream->setItemKey('foo'); + + $stream->write('a'); + $stream->write('b'); + $stream->write('c'); + } + + public function testFlushContentClearsKey() + { + $cache = $this->getMock('Swift_KeyCache'); + $cache->expects($this->once()) + ->method('clearKey') + ->with($this->_nsKey, 'foo'); + + $stream = new Swift_KeyCache_SimpleKeyCacheInputStream(); + $stream->setKeyCache($cache); + $stream->setNsKey($this->_nsKey); + $stream->setItemKey('foo'); + + $stream->flushBuffers(); + } + + public function testClonedStreamStillReferencesSameCache() + { + $cache = $this->getMock('Swift_KeyCache'); + $cache->expects($this->at(0)) + ->method('setString') + ->with($this->_nsKey, 'foo', 'a', Swift_KeyCache::MODE_APPEND); + $cache->expects($this->at(1)) + ->method('setString') + ->with($this->_nsKey, 'foo', 'b', Swift_KeyCache::MODE_APPEND); + $cache->expects($this->at(2)) + ->method('setString') + ->with('test', 'bar', 'x', Swift_KeyCache::MODE_APPEND); + + $stream = new Swift_KeyCache_SimpleKeyCacheInputStream(); + $stream->setKeyCache($cache); + $stream->setNsKey($this->_nsKey); + $stream->setItemKey('foo'); + + $stream->write('a'); + $stream->write('b'); + + $newStream = clone $stream; + $newStream->setKeyCache($cache); + $newStream->setNsKey('test'); + $newStream->setItemKey('bar'); + + $newStream->write('x'); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mailer/ArrayRecipientIteratorTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mailer/ArrayRecipientIteratorTest.php new file mode 100755 index 0000000..993ab5f --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mailer/ArrayRecipientIteratorTest.php @@ -0,0 +1,42 @@ +assertFalse($it->hasNext()); + } + + public function testHasNextReturnsTrueIfItemsLeft() + { + $it = new Swift_Mailer_ArrayRecipientIterator(array('foo@bar' => 'Foo')); + $this->assertTrue($it->hasNext()); + } + + public function testReadingToEndOfListCausesHasNextToReturnFalse() + { + $it = new Swift_Mailer_ArrayRecipientIterator(array('foo@bar' => 'Foo')); + $this->assertTrue($it->hasNext()); + $it->nextRecipient(); + $this->assertFalse($it->hasNext()); + } + + public function testReturnedValueHasPreservedKeyValuePair() + { + $it = new Swift_Mailer_ArrayRecipientIterator(array('foo@bar' => 'Foo')); + $this->assertEquals(array('foo@bar' => 'Foo'), $it->nextRecipient()); + } + + public function testIteratorMovesNextAfterEachIteration() + { + $it = new Swift_Mailer_ArrayRecipientIterator(array( + 'foo@bar' => 'Foo', + 'zip@button' => 'Zip thing', + 'test@test' => null + )); + $this->assertEquals(array('foo@bar' => 'Foo'), $it->nextRecipient()); + $this->assertEquals(array('zip@button' => 'Zip thing'), $it->nextRecipient()); + $this->assertEquals(array('test@test' => null), $it->nextRecipient()); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/MailerTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/MailerTest.php new file mode 100755 index 0000000..6efaa1f --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/MailerTest.php @@ -0,0 +1,150 @@ +_createTransport(); + $message = $this->_createMessage(); + + $started = false; + $transport->shouldReceive('isStarted') + ->zeroOrMoreTimes() + ->andReturnUsing(function() use (&$started) { + return $started; + }); + $transport->shouldReceive('start') + ->once() + ->andReturnUsing(function() use (&$started) { + $started = true; + return; + }); + + $mailer = $this->_createMailer($transport); + $mailer->send($message); + } + + public function testTransportIsOnlyStartedOnce() + { + $transport = $this->_createTransport(); + $message = $this->_createMessage(); + + $started = false; + $transport->shouldReceive('isStarted') + ->zeroOrMoreTimes() + ->andReturnUsing(function() use (&$started) { + return $started; + }); + $transport->shouldReceive('start') + ->once() + ->andReturnUsing(function() use (&$started) { + $started = true; + return; + }); + + $mailer = $this->_createMailer($transport); + for ($i = 0; $i < 10; ++$i) { + $mailer->send($message); + } + } + + public function testMessageIsPassedToTransport() + { + $transport = $this->_createTransport(); + $message = $this->_createMessage(); + $transport->shouldReceive('send') + ->once() + ->with($message, \Mockery::any()); + + $mailer = $this->_createMailer($transport); + $mailer->send($message); + } + + public function testSendReturnsCountFromTransport() + { + $transport = $this->_createTransport(); + $message = $this->_createMessage(); + $transport->shouldReceive('send') + ->once() + ->with($message, \Mockery::any()) + ->andReturn(57); + + $mailer = $this->_createMailer($transport); + $this->assertEquals(57, $mailer->send($message)); + } + + public function testFailedRecipientReferenceIsPassedToTransport() + { + $failures = array(); + + $transport = $this->_createTransport(); + $message = $this->_createMessage(); + $transport->shouldReceive('send') + ->once() + ->with($message, $failures) + ->andReturn(57); + + $mailer = $this->_createMailer($transport); + $mailer->send($message, $failures); + } + + public function testSendRecordsRfcComplianceExceptionAsEntireSendFailure() + { + $failures = array(); + + $rfcException = new Swift_RfcComplianceException('test'); + $transport = $this->_createTransport(); + $message = $this->_createMessage(); + $message->shouldReceive('getTo') + ->once() + ->andReturn(array('foo&invalid' => 'Foo', 'bar@valid.tld' => 'Bar')); + $transport->shouldReceive('send') + ->once() + ->with($message, $failures) + ->andThrow($rfcException); + + $mailer = $this->_createMailer($transport); + $this->assertEquals(0, $mailer->send($message, $failures), '%s: Should return 0'); + $this->assertEquals(array('foo&invalid', 'bar@valid.tld'), $failures, '%s: Failures should contain all addresses since the entire message failed to compile'); + } + + public function testRegisterPluginDelegatesToTransport() + { + $plugin = $this->_createPlugin(); + $transport = $this->_createTransport(); + $mailer = $this->_createMailer($transport); + + $transport->shouldReceive('registerPlugin') + ->once() + ->with($plugin); + + $mailer->registerPlugin($plugin); + } + + // -- Creation methods + + private function _createPlugin() + { + return $this->getMockery('Swift_Events_EventListener')->shouldIgnoreMissing(); + } + + private function _createTransport() + { + return $this->getMockery('Swift_Transport')->shouldIgnoreMissing(); + } + + private function _createMessage() + { + return $this->getMockery('Swift_Mime_Message')->shouldIgnoreMissing(); + } + + private function _createIterator() + { + return $this->getMockery('Swift_Mailer_RecipientIterator')->shouldIgnoreMissing(); + } + + private function _createMailer(Swift_Transport $transport) + { + return new Swift_Mailer($transport); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/AbstractMimeEntityTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/AbstractMimeEntityTest.php new file mode 100755 index 0000000..fe63a76 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/AbstractMimeEntityTest.php @@ -0,0 +1,1053 @@ +_createHeaderSet(); + $entity = $this->_createEntity($headers, $this->_createEncoder(), + $this->_createCache() + ); + $this->assertSame($headers, $entity->getHeaders()); + } + + public function testContentTypeIsReturnedFromHeader() + { + $ctype = $this->_createHeader('Content-Type', 'image/jpeg-test'); + $headers = $this->_createHeaderSet(array('Content-Type' => $ctype)); + $entity = $this->_createEntity($headers, $this->_createEncoder(), + $this->_createCache() + ); + $this->assertEquals('image/jpeg-test', $entity->getContentType()); + } + + public function testContentTypeIsSetInHeader() + { + $ctype = $this->_createHeader('Content-Type', 'text/plain', array(), false); + $headers = $this->_createHeaderSet(array('Content-Type' => $ctype)); + + $ctype->shouldReceive('setFieldBodyModel') + ->once() + ->with('image/jpeg'); + $ctype->shouldReceive('setFieldBodyModel') + ->zeroOrMoreTimes() + ->with(\Mockery::not('image/jpeg')); + + $entity = $this->_createEntity($headers, $this->_createEncoder(), + $this->_createCache() + ); + $entity->setContentType('image/jpeg'); + } + + public function testContentTypeHeaderIsAddedIfNoneSet() + { + $headers = $this->_createHeaderSet(array(), false); + $headers->shouldReceive('addParameterizedHeader') + ->once() + ->with('Content-Type', 'image/jpeg'); + $headers->shouldReceive('addParameterizedHeader') + ->zeroOrMoreTimes(); + + $entity = $this->_createEntity($headers, $this->_createEncoder(), + $this->_createCache() + ); + $entity->setContentType('image/jpeg'); + } + + public function testContentTypeCanBeSetViaSetBody() + { + $headers = $this->_createHeaderSet(array(), false); + $headers->shouldReceive('addParameterizedHeader') + ->once() + ->with('Content-Type', 'text/html'); + $headers->shouldReceive('addParameterizedHeader') + ->zeroOrMoreTimes(); + + $entity = $this->_createEntity($headers, $this->_createEncoder(), + $this->_createCache() + ); + $entity->setBody('foo', 'text/html'); + } + + public function testGetEncoderFromConstructor() + { + $encoder = $this->_createEncoder('base64'); + $entity = $this->_createEntity($this->_createHeaderSet(), $encoder, + $this->_createCache() + ); + $this->assertSame($encoder, $entity->getEncoder()); + } + + public function testSetAndGetEncoder() + { + $encoder = $this->_createEncoder('base64'); + $headers = $this->_createHeaderSet(); + $entity = $this->_createEntity($headers, $this->_createEncoder(), + $this->_createCache() + ); + $entity->setEncoder($encoder); + $this->assertSame($encoder, $entity->getEncoder()); + } + + public function testSettingEncoderUpdatesTransferEncoding() + { + $encoder = $this->_createEncoder('base64'); + $encoding = $this->_createHeader( + 'Content-Transfer-Encoding', '8bit', array(), false + ); + $headers = $this->_createHeaderSet(array( + 'Content-Transfer-Encoding' => $encoding + )); + $encoding->shouldReceive('setFieldBodyModel') + ->once() + ->with('base64'); + $encoding->shouldReceive('setFieldBodyModel') + ->zeroOrMoreTimes(); + + $entity = $this->_createEntity($headers, $this->_createEncoder(), + $this->_createCache() + ); + $entity->setEncoder($encoder); + } + + public function testSettingEncoderAddsEncodingHeaderIfNonePresent() + { + $headers = $this->_createHeaderSet(array(), false); + $headers->shouldReceive('addTextHeader') + ->once() + ->with('Content-Transfer-Encoding', 'something'); + $headers->shouldReceive('addTextHeader') + ->zeroOrMoreTimes(); + + $entity = $this->_createEntity($headers, $this->_createEncoder(), + $this->_createCache() + ); + $entity->setEncoder($this->_createEncoder('something')); + } + + public function testIdIsReturnedFromHeader() + { + /* -- RFC 2045, 7. + In constructing a high-level user agent, it may be desirable to allow + one body to make reference to another. Accordingly, bodies may be + labelled using the "Content-ID" header field, which is syntactically + identical to the "Message-ID" header field + */ + + $cid = $this->_createHeader('Content-ID', 'zip@button'); + $headers = $this->_createHeaderSet(array('Content-ID' => $cid)); + $entity = $this->_createEntity($headers, $this->_createEncoder(), + $this->_createCache() + ); + $this->assertEquals('zip@button', $entity->getId()); + } + + public function testIdIsSetInHeader() + { + $cid = $this->_createHeader('Content-ID', 'zip@button', array(), false); + $headers = $this->_createHeaderSet(array('Content-ID' => $cid)); + + $cid->shouldReceive('setFieldBodyModel') + ->once() + ->with('foo@bar'); + $cid->shouldReceive('setFieldBodyModel') + ->zeroOrMoreTimes(); + + $entity = $this->_createEntity($headers, $this->_createEncoder(), + $this->_createCache() + ); + $entity->setId('foo@bar'); + } + + public function testIdIsAutoGenerated() + { + $entity = $this->_createEntity($this->_createHeaderSet(), + $this->_createEncoder(), $this->_createCache() + ); + $this->assertRegExp('/^.*?@.*?$/D', $entity->getId()); + } + + public function testGenerateIdCreatesNewId() + { + $headers = $this->_createHeaderSet(); + $entity = $this->_createEntity($headers, $this->_createEncoder(), + $this->_createCache() + ); + $id1 = $entity->generateId(); + $id2 = $entity->generateId(); + $this->assertNotEquals($id1, $id2); + } + + public function testGenerateIdSetsNewId() + { + $headers = $this->_createHeaderSet(); + $entity = $this->_createEntity($headers, $this->_createEncoder(), + $this->_createCache() + ); + $id = $entity->generateId(); + $this->assertEquals($id, $entity->getId()); + } + + public function testDescriptionIsReadFromHeader() + { + /* -- RFC 2045, 8. + The ability to associate some descriptive information with a given + body is often desirable. For example, it may be useful to mark an + "image" body as "a picture of the Space Shuttle Endeavor." Such text + may be placed in the Content-Description header field. This header + field is always optional. + */ + + $desc = $this->_createHeader('Content-Description', 'something'); + $headers = $this->_createHeaderSet(array('Content-Description' => $desc)); + $entity = $this->_createEntity($headers, $this->_createEncoder(), + $this->_createCache() + ); + $this->assertEquals('something', $entity->getDescription()); + } + + public function testDescriptionIsSetInHeader() + { + $desc = $this->_createHeader('Content-Description', '', array(), false); + $desc->shouldReceive('setFieldBodyModel')->once()->with('whatever'); + + $headers = $this->_createHeaderSet(array('Content-Description' => $desc)); + + $entity = $this->_createEntity($headers, $this->_createEncoder(), + $this->_createCache() + ); + $entity->setDescription('whatever'); + } + + public function testDescriptionHeaderIsAddedIfNotPresent() + { + $headers = $this->_createHeaderSet(array(), false); + $headers->shouldReceive('addTextHeader') + ->once() + ->with('Content-Description', 'whatever'); + $headers->shouldReceive('addTextHeader') + ->zeroOrMoreTimes(); + + $entity = $this->_createEntity($headers, $this->_createEncoder(), + $this->_createCache() + ); + $entity->setDescription('whatever'); + } + + public function testSetAndGetMaxLineLength() + { + $entity = $this->_createEntity($this->_createHeaderSet(), + $this->_createEncoder(), $this->_createCache() + ); + $entity->setMaxLineLength(60); + $this->assertEquals(60, $entity->getMaxLineLength()); + } + + public function testEncoderIsUsedForStringGeneration() + { + $encoder = $this->_createEncoder('base64', false); + $encoder->expects($this->once()) + ->method('encodeString') + ->with('blah'); + + $entity = $this->_createEntity($this->_createHeaderSet(), + $encoder, $this->_createCache() + ); + $entity->setBody("blah"); + $entity->toString(); + } + + public function testMaxLineLengthIsProvidedWhenEncoding() + { + $encoder = $this->_createEncoder('base64', false); + $encoder->expects($this->once()) + ->method('encodeString') + ->with('blah', 0, 65); + + $entity = $this->_createEntity($this->_createHeaderSet(), + $encoder, $this->_createCache() + ); + $entity->setBody("blah"); + $entity->setMaxLineLength(65); + $entity->toString(); + } + + public function testHeadersAppearInString() + { + $headers = $this->_createHeaderSet(array(), false); + $headers->shouldReceive('toString') + ->once() + ->andReturn( + "Content-Type: text/plain; charset=utf-8\r\n" . + "X-MyHeader: foobar\r\n" + ); + + $entity = $this->_createEntity($headers, $this->_createEncoder(), + $this->_createCache() + ); + $this->assertEquals( + "Content-Type: text/plain; charset=utf-8\r\n" . + "X-MyHeader: foobar\r\n", + $entity->toString() + ); + } + + public function testSetAndGetBody() + { + $entity = $this->_createEntity($this->_createHeaderSet(), + $this->_createEncoder(), $this->_createCache() + ); + $entity->setBody("blah\r\nblah!"); + $this->assertEquals("blah\r\nblah!", $entity->getBody()); + } + + public function testBodyIsAppended() + { + $headers = $this->_createHeaderSet(array(), false); + $headers->shouldReceive('toString') + ->once() + ->andReturn("Content-Type: text/plain; charset=utf-8\r\n"); + + $entity = $this->_createEntity($headers, $this->_createEncoder(), + $this->_createCache() + ); + $entity->setBody("blah\r\nblah!"); + $this->assertEquals( + "Content-Type: text/plain; charset=utf-8\r\n" . + "\r\n" . + "blah\r\nblah!", + $entity->toString() + ); + } + + public function testGetBodyReturnsStringFromByteStream() + { + $os = $this->_createOutputStream("byte stream string"); + $entity = $this->_createEntity($this->_createHeaderSet(), + $this->_createEncoder(), $this->_createCache() + ); + $entity->setBody($os); + $this->assertEquals("byte stream string", $entity->getBody()); + } + + public function testByteStreamBodyIsAppended() + { + $headers = $this->_createHeaderSet(array(), false); + $os = $this->_createOutputStream("streamed"); + $headers->shouldReceive('toString') + ->once() + ->andReturn("Content-Type: text/plain; charset=utf-8\r\n"); + + $entity = $this->_createEntity($headers, $this->_createEncoder(), + $this->_createCache() + ); + $entity->setBody($os); + $this->assertEquals( + "Content-Type: text/plain; charset=utf-8\r\n" . + "\r\n" . + "streamed", + $entity->toString() + ); + } + + public function testBoundaryCanBeRetrieved() + { + /* -- RFC 2046, 5.1.1. + boundary := 0*69 bcharsnospace + + bchars := bcharsnospace / " " + + bcharsnospace := DIGIT / ALPHA / "'" / "(" / ")" / + "+" / "_" / "," / "-" / "." / + "/" / ":" / "=" / "?" + */ + + $entity = $this->_createEntity($this->_createHeaderSet(), + $this->_createEncoder(), $this->_createCache() + ); + $this->assertRegExp( + '/^[a-zA-Z0-9\'\(\)\+_\-,\.\/:=\?\ ]{0,69}[a-zA-Z0-9\'\(\)\+_\-,\.\/:=\?]$/D', + $entity->getBoundary() + ); + } + + public function testBoundaryNeverChanges() + { + $entity = $this->_createEntity($this->_createHeaderSet(), + $this->_createEncoder(), $this->_createCache() + ); + $firstBoundary = $entity->getBoundary(); + for ($i = 0; $i < 10; $i++) { + $this->assertEquals($firstBoundary, $entity->getBoundary()); + } + } + + public function testBoundaryCanBeSet() + { + $entity = $this->_createEntity($this->_createHeaderSet(), + $this->_createEncoder(), $this->_createCache() + ); + $entity->setBoundary('foobar'); + $this->assertEquals('foobar', $entity->getBoundary()); + } + + public function testAddingChildrenGeneratesBoundaryInHeaders() + { + $child = $this->_createChild(); + $cType = $this->_createHeader('Content-Type', 'text/plain', array(), false); + $cType->shouldReceive('setParameter') + ->once() + ->with('boundary', \Mockery::any()); + $cType->shouldReceive('setParameter') + ->zeroOrMoreTimes(); + + $entity = $this->_createEntity($this->_createHeaderSet(array( + 'Content-Type' => $cType + )), + $this->_createEncoder(), $this->_createCache() + ); + $entity->setChildren(array($child)); + } + + public function testChildrenOfLevelAttachmentAndLessCauseMultipartMixed() + { + for ($level = Swift_Mime_MimeEntity::LEVEL_MIXED; + $level > Swift_Mime_MimeEntity::LEVEL_TOP; $level /= 2) + { + $child = $this->_createChild($level); + $cType = $this->_createHeader( + 'Content-Type', 'text/plain', array(), false + ); + $cType->shouldReceive('setFieldBodyModel') + ->once() + ->with('multipart/mixed'); + $cType->shouldReceive('setFieldBodyModel') + ->zeroOrMoreTimes(); + + $entity = $this->_createEntity($this->_createHeaderSet(array( + 'Content-Type' => $cType)), + $this->_createEncoder(), $this->_createCache() + ); + $entity->setChildren(array($child)); + } + } + + public function testChildrenOfLevelAlternativeAndLessCauseMultipartAlternative() + { + for ($level = Swift_Mime_MimeEntity::LEVEL_ALTERNATIVE; + $level > Swift_Mime_MimeEntity::LEVEL_MIXED; $level /= 2) + { + $child = $this->_createChild($level); + $cType = $this->_createHeader( + 'Content-Type', 'text/plain', array(), false + ); + $cType->shouldReceive('setFieldBodyModel') + ->once() + ->with('multipart/alternative'); + $cType->shouldReceive('setFieldBodyModel') + ->zeroOrMoreTimes(); + + $entity = $this->_createEntity($this->_createHeaderSet(array( + 'Content-Type' => $cType)), + $this->_createEncoder(), $this->_createCache() + ); + $entity->setChildren(array($child)); + } + } + + public function testChildrenOfLevelRelatedAndLessCauseMultipartRelated() + { + for ($level = Swift_Mime_MimeEntity::LEVEL_RELATED; + $level > Swift_Mime_MimeEntity::LEVEL_ALTERNATIVE; $level /= 2) + { + $child = $this->_createChild($level); + $cType = $this->_createHeader( + 'Content-Type', 'text/plain', array(), false + ); + $cType->shouldReceive('setFieldBodyModel') + ->once() + ->with('multipart/related'); + $cType->shouldReceive('setFieldBodyModel') + ->zeroOrMoreTimes(); + + $entity = $this->_createEntity($this->_createHeaderSet(array( + 'Content-Type' => $cType)), + $this->_createEncoder(), $this->_createCache() + ); + $entity->setChildren(array($child)); + } + } + + public function testHighestLevelChildDeterminesContentType() + { + $combinations = array( + array('levels' => array(Swift_Mime_MimeEntity::LEVEL_MIXED, + Swift_Mime_MimeEntity::LEVEL_ALTERNATIVE, + Swift_Mime_MimeEntity::LEVEL_RELATED + ), + 'type' => 'multipart/mixed' + ), + array('levels' => array(Swift_Mime_MimeEntity::LEVEL_MIXED, + Swift_Mime_MimeEntity::LEVEL_RELATED + ), + 'type' => 'multipart/mixed' + ), + array('levels' => array(Swift_Mime_MimeEntity::LEVEL_MIXED, + Swift_Mime_MimeEntity::LEVEL_ALTERNATIVE + ), + 'type' => 'multipart/mixed' + ), + array('levels' => array(Swift_Mime_MimeEntity::LEVEL_ALTERNATIVE, + Swift_Mime_MimeEntity::LEVEL_RELATED + ), + 'type' => 'multipart/alternative' + ) + ); + + foreach ($combinations as $combination) { + $children = array(); + foreach ($combination['levels'] as $level) { + $children[] = $this->_createChild($level); + } + + $cType = $this->_createHeader( + 'Content-Type', 'text/plain', array(), false + ); + $cType->shouldReceive('setFieldBodyModel') + ->once() + ->with($combination['type']); + + $headerSet = $this->_createHeaderSet(array('Content-Type' => $cType)); + $headerSet->shouldReceive('newInstance') + ->zeroOrMoreTimes() + ->andReturnUsing(function() use ($headerSet) { + return $headerSet; + }); + $entity = $this->_createEntity($headerSet, + $this->_createEncoder(), $this->_createCache() + ); + $entity->setChildren($children); + } + } + + public function testChildrenAppearNestedInString() + { + /* -- RFC 2046, 5.1.1. + (excerpt too verbose to paste here) + */ + + $headers = $this->_createHeaderSet(array(), false); + + $child1 = new MimeEntityFixture(Swift_Mime_MimeEntity::LEVEL_ALTERNATIVE, + "Content-Type: text/plain\r\n" . + "\r\n" . + "foobar" + ); + + $child2 = new MimeEntityFixture(Swift_Mime_MimeEntity::LEVEL_ALTERNATIVE, + "Content-Type: text/html\r\n" . + "\r\n" . + "foobar" + ); + + $headers->shouldReceive('toString') + ->zeroOrMoreTimes() + ->andReturn("Content-Type: multipart/alternative; boundary=\"xxx\"\r\n"); + + $entity = $this->_createEntity($headers, $this->_createEncoder(), + $this->_createCache() + ); + $entity->setBoundary('xxx'); + $entity->setChildren(array($child1, $child2)); + + $this->assertEquals( + "Content-Type: multipart/alternative; boundary=\"xxx\"\r\n" . + "\r\n" . + "\r\n--xxx\r\n" . + "Content-Type: text/plain\r\n" . + "\r\n" . + "foobar\r\n" . + "\r\n--xxx\r\n" . + "Content-Type: text/html\r\n" . + "\r\n" . + "foobar\r\n" . + "\r\n--xxx--\r\n", + $entity->toString() + ); + } + + public function testMixingLevelsIsHierarchical() + { + $headers = $this->_createHeaderSet(array(), false); + $newHeaders = $this->_createHeaderSet(array(), false); + + $part = $this->_createChild(Swift_Mime_MimeEntity::LEVEL_ALTERNATIVE, + "Content-Type: text/plain\r\n" . + "\r\n" . + "foobar" + ); + + $attachment = $this->_createChild(Swift_Mime_MimeEntity::LEVEL_MIXED, + "Content-Type: application/octet-stream\r\n" . + "\r\n" . + "data" + ); + + $headers->shouldReceive('toString') + ->zeroOrMoreTimes() + ->andReturn("Content-Type: multipart/mixed; boundary=\"xxx\"\r\n"); + $headers->shouldReceive('newInstance') + ->zeroOrMoreTimes() + ->andReturn($newHeaders); + $newHeaders->shouldReceive('toString') + ->zeroOrMoreTimes() + ->andReturn("Content-Type: multipart/alternative; boundary=\"yyy\"\r\n"); + + $entity = $this->_createEntity($headers, $this->_createEncoder(), + $this->_createCache() + ); + $entity->setBoundary('xxx'); + $entity->setChildren(array($part, $attachment)); + + $this->assertRegExp( + "~^" . + "Content-Type: multipart/mixed; boundary=\"xxx\"\r\n" . + "\r\n\r\n--xxx\r\n" . + "Content-Type: multipart/alternative; boundary=\"yyy\"\r\n" . + "\r\n\r\n--(.*?)\r\n" . + "Content-Type: text/plain\r\n" . + "\r\n" . + "foobar" . + "\r\n\r\n--\\1--\r\n" . + "\r\n\r\n--xxx\r\n" . + "Content-Type: application/octet-stream\r\n" . + "\r\n" . + "data" . + "\r\n\r\n--xxx--\r\n" . + "\$~", + $entity->toString() + ); + } + + public function testSettingEncoderNotifiesChildren() + { + $child = $this->_createChild(0, '', false); + $encoder = $this->_createEncoder('base64'); + + $child->shouldReceive('encoderChanged') + ->once() + ->with($encoder); + + $entity = $this->_createEntity($this->_createHeaderSet(), + $this->_createEncoder(), $this->_createCache() + ); + $entity->setChildren(array($child)); + $entity->setEncoder($encoder); + } + + public function testReceiptOfEncoderChangeNotifiesChildren() + { + $child = $this->_createChild(0, '', false); + $encoder = $this->_createEncoder('base64'); + + $child->shouldReceive('encoderChanged') + ->once() + ->with($encoder); + + $entity = $this->_createEntity($this->_createHeaderSet(), + $this->_createEncoder(), $this->_createCache() + ); + $entity->setChildren(array($child)); + $entity->encoderChanged($encoder); + } + + public function testReceiptOfCharsetChangeNotifiesChildren() + { + $child = $this->_createChild(0, '', false); + $child->shouldReceive('charsetChanged') + ->once() + ->with('windows-874'); + + $entity = $this->_createEntity($this->_createHeaderSet(), + $this->_createEncoder(), $this->_createCache() + ); + $entity->setChildren(array($child)); + $entity->charsetChanged('windows-874'); + } + + public function testEntityIsWrittenToByteStream() + { + $entity = $this->_createEntity($this->_createHeaderSet(), + $this->_createEncoder(), $this->_createCache() + ); + $is = $this->_createInputStream(false); + $is->expects($this->atLeastOnce()) + ->method('write'); + + $entity->toByteStream($is); + } + + public function testEntityHeadersAreComittedToByteStream() + { + $entity = $this->_createEntity($this->_createHeaderSet(), + $this->_createEncoder(), $this->_createCache() + ); + $is = $this->_createInputStream(false); + $is->expects($this->atLeastOnce()) + ->method('write'); + $is->expects($this->atLeastOnce()) + ->method('commit'); + + $entity->toByteStream($is); + } + + public function testOrderingTextBeforeHtml() + { + $htmlChild = new MimeEntityFixture(Swift_Mime_MimeEntity::LEVEL_ALTERNATIVE, + "Content-Type: text/html\r\n" . + "\r\n" . + "HTML PART", + 'text/html' + ); + $textChild = new MimeEntityFixture(Swift_Mime_MimeEntity::LEVEL_ALTERNATIVE, + "Content-Type: text/plain\r\n" . + "\r\n" . + "TEXT PART", + 'text/plain' + ); + $headers = $this->_createHeaderSet(array(), false); + $headers->shouldReceive('toString') + ->zeroOrMoreTimes() + ->andReturn("Content-Type: multipart/alternative; boundary=\"xxx\"\r\n"); + + $entity = $this->_createEntity($headers, $this->_createEncoder(), + $this->_createCache() + ); + $entity->setBoundary('xxx'); + $entity->setChildren(array($htmlChild, $textChild)); + + $this->assertEquals( + "Content-Type: multipart/alternative; boundary=\"xxx\"\r\n" . + "\r\n\r\n--xxx\r\n" . + "Content-Type: text/plain\r\n" . + "\r\n" . + "TEXT PART" . + "\r\n\r\n--xxx\r\n" . + "Content-Type: text/html\r\n" . + "\r\n" . + "HTML PART" . + "\r\n\r\n--xxx--\r\n", + $entity->toString() + ); + } + + public function testUnsettingChildrenRestoresContentType() + { + $cType = $this->_createHeader('Content-Type', 'text/plain', array(), false); + $child = $this->_createChild(Swift_Mime_MimeEntity::LEVEL_ALTERNATIVE); + + $cType->shouldReceive('setFieldBodyModel') + ->twice() + ->with('image/jpeg'); + $cType->shouldReceive('setFieldBodyModel') + ->once() + ->with('multipart/alternative'); + $cType->shouldReceive('setFieldBodyModel') + ->zeroOrMoreTimes() + ->with(\Mockery::not('multipart/alternative', 'image/jpeg')); + + $entity = $this->_createEntity($this->_createHeaderSet(array( + 'Content-Type' => $cType + )), + $this->_createEncoder(), $this->_createCache() + ); + + $entity->setContentType('image/jpeg'); + $entity->setChildren(array($child)); + $entity->setChildren(array()); + } + + public function testBodyIsReadFromCacheWhenUsingToStringIfPresent() + { + $headers = $this->_createHeaderSet(array(), false); + $headers->shouldReceive('toString') + ->zeroOrMoreTimes() + ->andReturn("Content-Type: text/plain; charset=utf-8\r\n"); + + $cache = $this->_createCache(false); + $cache->shouldReceive('hasKey') + ->once() + ->with(\Mockery::any(), 'body') + ->andReturn(true); + $cache->shouldReceive('getString') + ->once() + ->with(\Mockery::any(), 'body') + ->andReturn("\r\ncache\r\ncache!"); + + $entity = $this->_createEntity($headers, $this->_createEncoder(), + $cache + ); + + $entity->setBody("blah\r\nblah!"); + $this->assertEquals( + "Content-Type: text/plain; charset=utf-8\r\n" . + "\r\n" . + "cache\r\ncache!", + $entity->toString() + ); + } + + public function testBodyIsAddedToCacheWhenUsingToString() + { + $headers = $this->_createHeaderSet(array(), false); + $headers->shouldReceive('toString') + ->zeroOrMoreTimes() + ->andReturn("Content-Type: text/plain; charset=utf-8\r\n"); + + $cache = $this->_createCache(false); + $cache->shouldReceive('hasKey') + ->once() + ->with(\Mockery::any(), 'body') + ->andReturn(false); + $cache->shouldReceive('setString') + ->once() + ->with(\Mockery::any(), 'body', "\r\nblah\r\nblah!", Swift_KeyCache::MODE_WRITE); + + $entity = $this->_createEntity($headers, $this->_createEncoder(), + $cache + ); + + $entity->setBody("blah\r\nblah!"); + $entity->toString(); + } + + public function testBodyIsClearedFromCacheIfNewBodySet() + { + $headers = $this->_createHeaderSet(array(), false); + $headers->shouldReceive('toString') + ->zeroOrMoreTimes() + ->andReturn("Content-Type: text/plain; charset=utf-8\r\n"); + + $cache = $this->_createCache(false); + $entity = $this->_createEntity($headers, $this->_createEncoder(), + $cache + ); + + $entity->setBody("blah\r\nblah!"); + $entity->toString(); + + // We set the expectation at this point because we only care what happens when calling setBody() + $cache->shouldReceive('clearKey') + ->once() + ->with(\Mockery::any(), 'body'); + + $entity->setBody("new\r\nnew!"); + } + + public function testBodyIsNotClearedFromCacheIfSameBodySet() + { + $headers = $this->_createHeaderSet(array(), false); + $headers->shouldReceive('toString') + ->zeroOrMoreTimes() + ->andReturn("Content-Type: text/plain; charset=utf-8\r\n"); + + $cache = $this->_createCache(false); + $entity = $this->_createEntity($headers, $this->_createEncoder(), + $cache + ); + + $entity->setBody("blah\r\nblah!"); + $entity->toString(); + + // We set the expectation at this point because we only care what happens when calling setBody() + $cache->shouldReceive('clearKey') + ->never(); + + $entity->setBody("blah\r\nblah!"); + } + + public function testBodyIsClearedFromCacheIfNewEncoderSet() + { + $headers = $this->_createHeaderSet(array(), false); + $headers->shouldReceive('toString') + ->zeroOrMoreTimes() + ->andReturn("Content-Type: text/plain; charset=utf-8\r\n"); + + $cache = $this->_createCache(false); + $otherEncoder = $this->_createEncoder(); + $entity = $this->_createEntity($headers, $this->_createEncoder(), + $cache + ); + + $entity->setBody("blah\r\nblah!"); + $entity->toString(); + + // We set the expectation at this point because we only care what happens when calling setEncoder() + $cache->shouldReceive('clearKey') + ->once() + ->with(\Mockery::any(), 'body'); + + $entity->setEncoder($otherEncoder); + } + + public function testBodyIsReadFromCacheWhenUsingToByteStreamIfPresent() + { + $is = $this->_createInputStream(); + $cache = $this->_createCache(false); + $cache->shouldReceive('hasKey') + ->once() + ->with(\Mockery::any(), 'body') + ->andReturn(true); + $cache->shouldReceive('exportToByteStream') + ->once() + ->with(\Mockery::any(), 'body', $is); + + $entity = $this->_createEntity($this->_createHeaderSet(), + $this->_createEncoder(), $cache + ); + $entity->setBody('foo'); + + $entity->toByteStream($is); + } + + public function testBodyIsAddedToCacheWhenUsingToByteStream() + { + $is = $this->_createInputStream(); + $cache = $this->_createCache(false); + $cache->shouldReceive('hasKey') + ->once() + ->with(\Mockery::any(), 'body') + ->andReturn(false); + $cache->shouldReceive('getInputByteStream') + ->once() + ->with(\Mockery::any(), 'body'); + + $entity = $this->_createEntity($this->_createHeaderSet(), + $this->_createEncoder(), $cache + ); + $entity->setBody('foo'); + + $entity->toByteStream($is); + } + + public function testFluidInterface() + { + $entity = $this->_createEntity($this->_createHeaderSet(), + $this->_createEncoder(), $this->_createCache() + ); + + $this->assertSame($entity, + $entity + ->setContentType('text/plain') + ->setEncoder($this->_createEncoder()) + ->setId('foo@bar') + ->setDescription('my description') + ->setMaxLineLength(998) + ->setBody('xx') + ->setBoundary('xyz') + ->setChildren(array()) + ); + } + + // -- Private helpers + + abstract protected function _createEntity($headers, $encoder, $cache); + + protected function _createChild($level = null, $string = '', $stub = true) + { + $child = $this->getMockery('Swift_Mime_MimeEntity')->shouldIgnoreMissing(); + if (isset($level)) { + $child->shouldReceive('getNestingLevel') + ->zeroOrMoreTimes() + ->andReturn($level); + } + $child->shouldReceive('toString') + ->zeroOrMoreTimes() + ->andReturn($string); + + return $child; + } + + protected function _createEncoder($name = 'quoted-printable', $stub = true) + { + $encoder = $this->getMock('Swift_Mime_ContentEncoder'); + $encoder->expects($this->any()) + ->method('getName') + ->will($this->returnValue($name)); + $encoder->expects($this->any()) + ->method('encodeString') + ->will($this->returnCallback(function() { + $args = func_get_args(); + return array_shift($args); + })); + + return $encoder; + } + + protected function _createCache($stub = true) + { + return $this->getMockery('Swift_KeyCache')->shouldIgnoreMissing(); + } + + protected function _createHeaderSet($headers = array(), $stub = true) + { + $set = $this->getMockery('Swift_Mime_HeaderSet')->shouldIgnoreMissing(); + $set->shouldReceive('get') + ->zeroOrMoreTimes() + ->andReturnUsing(function($key) use ($headers) { + return $headers[$key]; + }); + $set->shouldReceive('has') + ->zeroOrMoreTimes() + ->andReturnUsing(function($key) use ($headers) { + return array_key_exists($key, $headers); + }); + + return $set; + } + + protected function _createHeader($name, $model = null, $params = array(), $stub = true) + { + $header = $this->getMockery('Swift_Mime_ParameterizedHeader')->shouldIgnoreMissing(); + $header->shouldReceive('getFieldName') + ->zeroOrMoreTimes() + ->andReturn($name); + $header->shouldReceive('getFieldBodyModel') + ->zeroOrMoreTimes() + ->andReturn($model); + $header->shouldReceive('getParameter') + ->zeroOrMoreTimes() + ->andReturnUsing(function($key) use ($params) { + return $params[$key]; + }); + + return $header; + } + + protected function _createOutputStream($data = null, $stub = true) + { + $os = $this->getMockery('Swift_OutputByteStream'); + if (isset($data)) { + $os->shouldReceive('read') + ->zeroOrMoreTimes() + ->andReturnUsing(function() use ($data) { + static $first = true; + if (!$first) { + return false; + } + + $first = false; + return $data; + }); + } + + return $os; + } + + protected function _createInputStream($stub = true) + { + return $this->getMock('Swift_InputByteStream'); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/AttachmentTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/AttachmentTest.php new file mode 100755 index 0000000..fb58247 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/AttachmentTest.php @@ -0,0 +1,317 @@ +_createAttachment($this->_createHeaderSet(), + $this->_createEncoder(), $this->_createCache() + ); + $this->assertEquals( + Swift_Mime_MimeEntity::LEVEL_MIXED, $attachment->getNestingLevel() + ); + } + + public function testDispositionIsReturnedFromHeader() + { + /* -- RFC 2183, 2.1, 2.2. + */ + + $disposition = $this->_createHeader('Content-Disposition', 'attachment'); + $attachment = $this->_createAttachment($this->_createHeaderSet(array( + 'Content-Disposition' => $disposition)), + $this->_createEncoder(), $this->_createCache() + ); + $this->assertEquals('attachment', $attachment->getDisposition()); + } + + public function testDispositionIsSetInHeader() + { + $disposition = $this->_createHeader('Content-Disposition', 'attachment', + array(), false + ); + $disposition->shouldReceive('setFieldBodyModel') + ->once() + ->with('inline'); + $disposition->shouldReceive('setFieldBodyModel') + ->zeroOrMoreTimes(); + + $attachment = $this->_createAttachment($this->_createHeaderSet(array( + 'Content-Disposition' => $disposition)), + $this->_createEncoder(), $this->_createCache() + ); + $attachment->setDisposition('inline'); + } + + public function testDispositionIsAddedIfNonePresent() + { + $headers = $this->_createHeaderSet(array(), false); + $headers->shouldReceive('addParameterizedHeader') + ->once() + ->with('Content-Disposition', 'inline'); + $headers->shouldReceive('addParameterizedHeader') + ->zeroOrMoreTimes(); + + $attachment = $this->_createAttachment($headers, $this->_createEncoder(), + $this->_createCache() + ); + $attachment->setDisposition('inline'); + } + + public function testDispositionIsAutoDefaultedToAttachment() + { + $headers = $this->_createHeaderSet(array(), false); + $headers->shouldReceive('addParameterizedHeader') + ->once() + ->with('Content-Disposition', 'attachment'); + $headers->shouldReceive('addParameterizedHeader') + ->zeroOrMoreTimes(); + + $attachment = $this->_createAttachment($headers, $this->_createEncoder(), + $this->_createCache() + ); + } + + public function testDefaultContentTypeInitializedToOctetStream() + { + $cType = $this->_createHeader('Content-Type', '', + array(), false + ); + $cType->shouldReceive('setFieldBodyModel') + ->once() + ->with('application/octet-stream'); + $cType->shouldReceive('setFieldBodyModel') + ->zeroOrMoreTimes(); + + $attachment = $this->_createAttachment($this->_createHeaderSet(array( + 'Content-Type' => $cType)), + $this->_createEncoder(), $this->_createCache() + ); + } + + public function testFilenameIsReturnedFromHeader() + { + /* -- RFC 2183, 2.3. + */ + + $disposition = $this->_createHeader('Content-Disposition', 'attachment', + array('filename'=>'foo.txt') + ); + $attachment = $this->_createAttachment($this->_createHeaderSet(array( + 'Content-Disposition' => $disposition)), + $this->_createEncoder(), $this->_createCache() + ); + $this->assertEquals('foo.txt', $attachment->getFilename()); + } + + public function testFilenameIsSetInHeader() + { + $disposition = $this->_createHeader('Content-Disposition', 'attachment', + array('filename'=>'foo.txt'), false + ); + $disposition->shouldReceive('setParameter') + ->once() + ->with('filename', 'bar.txt'); + $disposition->shouldReceive('setParameter') + ->zeroOrMoreTimes(); + + $attachment = $this->_createAttachment($this->_createHeaderSet(array( + 'Content-Disposition' => $disposition)), + $this->_createEncoder(), $this->_createCache() + ); + $attachment->setFilename('bar.txt'); + } + + public function testSettingFilenameSetsNameInContentType() + { + /* + This is a legacy requirement which isn't covered by up-to-date RFCs. + */ + + $cType = $this->_createHeader('Content-Type', 'text/plain', + array(), false + ); + $cType->shouldReceive('setParameter') + ->once() + ->with('name', 'bar.txt'); + $cType->shouldReceive('setParameter') + ->zeroOrMoreTimes(); + + $attachment = $this->_createAttachment($this->_createHeaderSet(array( + 'Content-Type' => $cType)), + $this->_createEncoder(), $this->_createCache() + ); + $attachment->setFilename('bar.txt'); + } + + public function testSizeIsReturnedFromHeader() + { + /* -- RFC 2183, 2.7. + */ + + $disposition = $this->_createHeader('Content-Disposition', 'attachment', + array('size'=>1234) + ); + $attachment = $this->_createAttachment($this->_createHeaderSet(array( + 'Content-Disposition' => $disposition)), + $this->_createEncoder(), $this->_createCache() + ); + $this->assertEquals(1234, $attachment->getSize()); + } + + public function testSizeIsSetInHeader() + { + $disposition = $this->_createHeader('Content-Disposition', 'attachment', + array(), false + ); + $disposition->shouldReceive('setParameter') + ->once() + ->with('size', 12345); + $disposition->shouldReceive('setParameter') + ->zeroOrMoreTimes(); + + $attachment = $this->_createAttachment($this->_createHeaderSet(array( + 'Content-Disposition' => $disposition)), + $this->_createEncoder(), $this->_createCache() + ); + $attachment->setSize(12345); + } + + public function testFilnameCanBeReadFromFileStream() + { + $file = $this->_createFileStream('/bar/file.ext', ''); + $disposition = $this->_createHeader('Content-Disposition', 'attachment', + array('filename'=>'foo.txt'), false + ); + $disposition->shouldReceive('setParameter') + ->once() + ->with('filename', 'file.ext'); + + $attachment = $this->_createAttachment($this->_createHeaderSet(array( + 'Content-Disposition' => $disposition)), + $this->_createEncoder(), $this->_createCache() + ); + $attachment->setFile($file); + } + + public function testContentTypeCanBeSetViaSetFile() + { + $file = $this->_createFileStream('/bar/file.ext', ''); + $disposition = $this->_createHeader('Content-Disposition', 'attachment', + array('filename'=>'foo.txt'), false + ); + $disposition->shouldReceive('setParameter') + ->once() + ->with('filename', 'file.ext'); + + $ctype = $this->_createHeader('Content-Type', 'text/plain', array(), false); + $ctype->shouldReceive('setFieldBodyModel') + ->once() + ->with('text/html'); + $ctype->shouldReceive('setFieldBodyModel') + ->zeroOrMoreTimes(); + + $headers = $this->_createHeaderSet(array( + 'Content-Disposition' => $disposition, + 'Content-Type' => $ctype + )); + + $attachment = $this->_createAttachment($headers, $this->_createEncoder(), + $this->_createCache() + ); + $attachment->setFile($file, 'text/html'); + } + + public function XtestContentTypeCanBeLookedUpFromCommonListIfNotProvided() + { + $file = $this->_createFileStream('/bar/file.zip', ''); + $disposition = $this->_createHeader('Content-Disposition', 'attachment', + array('filename'=>'foo.zip'), false + ); + $disposition->shouldReceive('setParameter') + ->once() + ->with('filename', 'file.zip'); + + $ctype = $this->_createHeader('Content-Type', 'text/plain', array(), false); + $ctype->shouldReceive('setFieldBodyModel') + ->once() + ->with('application/zip'); + $ctype->shouldReceive('setFieldBodyModel') + ->zeroOrMoreTimes(); + + $headers = $this->_createHeaderSet(array( + 'Content-Disposition' => $disposition, + 'Content-Type' => $ctype + )); + + $attachment = $this->_createAttachment($headers, $this->_createEncoder(), + $this->_createCache(), array('zip'=>'application/zip', 'txt'=>'text/plain') + ); + $attachment->setFile($file); + } + + public function testDataCanBeReadFromFile() + { + $file = $this->_createFileStream('/foo/file.ext', ''); + $attachment = $this->_createAttachment($this->_createHeaderSet(), + $this->_createEncoder(), $this->_createCache() + ); + $attachment->setFile($file); + $this->assertEquals('', $attachment->getBody()); + } + + public function testFluidInterface() + { + $attachment = $this->_createAttachment($this->_createHeaderSet(), + $this->_createEncoder(), $this->_createCache() + ); + $this->assertSame($attachment, + $attachment + ->setContentType('application/pdf') + ->setEncoder($this->_createEncoder()) + ->setId('foo@bar') + ->setDescription('my pdf') + ->setMaxLineLength(998) + ->setBody('xx') + ->setBoundary('xyz') + ->setChildren(array()) + ->setDisposition('inline') + ->setFilename('afile.txt') + ->setSize(123) + ->setFile($this->_createFileStream('foo.txt', '')) + ); + } + + // -- Private helpers + + protected function _createEntity($headers, $encoder, $cache) + { + return $this->_createAttachment($headers, $encoder, $cache); + } + + protected function _createAttachment($headers, $encoder, $cache, $mimeTypes = array()) + { + return new Swift_Mime_Attachment($headers, $encoder, $cache, new Swift_Mime_Grammar(), $mimeTypes); + } + + protected function _createFileStream($path, $data, $stub = true) + { + $file = $this->getMockery('Swift_FileStream'); + $file->shouldReceive('getPath') + ->zeroOrMoreTimes() + ->andReturn($path); + $file->shouldReceive('read') + ->zeroOrMoreTimes() + ->andReturnUsing(function() use ($data) { + static $first = true; + if (!$first) { + return false; + } + + $first = false; + return $data; + }); + + return $file; + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/ContentEncoder/Base64ContentEncoderTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/ContentEncoder/Base64ContentEncoderTest.php new file mode 100755 index 0000000..27d0dee --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/ContentEncoder/Base64ContentEncoderTest.php @@ -0,0 +1,325 @@ +_encoder = new Swift_Mime_ContentEncoder_Base64ContentEncoder(); + } + + public function testNameIsBase64() + { + $this->assertEquals('base64', $this->_encoder->getName()); + } + + /* + There's really no point in testing the entire base64 encoding to the + level QP encoding has been tested. base64_encode() has been in PHP for + years. + */ + + public function testInputOutputRatioIs3to4Bytes() + { + /* + RFC 2045, 6.8 + + The encoding process represents 24-bit groups of input bits as output + strings of 4 encoded characters. Proceeding from left to right, a + 24-bit input group is formed by concatenating 3 8bit input groups. + These 24 bits are then treated as 4 concatenated 6-bit groups, each + of which is translated into a single digit in the base64 alphabet. + */ + + $os = $this->_createOutputByteStream(); + $is = $this->_createInputByteStream(); + $collection = new Swift_StreamCollector(); + + $is->shouldReceive('write') + ->zeroOrMoreTimes() + ->andReturnUsing($collection); + $os->shouldReceive('read') + ->once() + ->andReturn('123'); + $os->shouldReceive('read') + ->zeroOrMoreTimes() + ->andReturn(false); + + $this->_encoder->encodeByteStream($os, $is); + $this->assertEquals('MTIz', $collection->content); + } + + public function testPadLength() + { + /* + RFC 2045, 6.8 + + Special processing is performed if fewer than 24 bits are available + at the end of the data being encoded. A full encoding quantum is + always completed at the end of a body. When fewer than 24 input bits + are available in an input group, zero bits are added (on the right) + to form an integral number of 6-bit groups. Padding at the end of + the data is performed using the "=" character. Since all base64 + input is an integral number of octets, only the following cases can + arise: (1) the final quantum of encoding input is an integral + multiple of 24 bits; here, the final unit of encoded output will be + an integral multiple of 4 characters with no "=" padding, (2) the + final quantum of encoding input is exactly 8 bits; here, the final + unit of encoded output will be two characters followed by two "=" + padding characters, or (3) the final quantum of encoding input is + exactly 16 bits; here, the final unit of encoded output will be three + characters followed by one "=" padding character. + */ + + for ($i = 0; $i < 30; ++$i) { + $os = $this->_createOutputByteStream(); + $is = $this->_createInputByteStream(); + $collection = new Swift_StreamCollector(); + + $is->shouldReceive('write') + ->zeroOrMoreTimes() + ->andReturnUsing($collection); + $os->shouldReceive('read') + ->once() + ->andReturn(pack('C', rand(0, 255))); + $os->shouldReceive('read') + ->zeroOrMoreTimes() + ->andReturn(false); + + $this->_encoder->encodeByteStream($os, $is); + $this->assertRegExp('~^[a-zA-Z0-9/\+]{2}==$~', $collection->content, + '%s: A single byte should have 2 bytes of padding' + ); + } + + for ($i = 0; $i < 30; ++$i) { + $os = $this->_createOutputByteStream(); + $is = $this->_createInputByteStream(); + $collection = new Swift_StreamCollector(); + + $is->shouldReceive('write') + ->zeroOrMoreTimes() + ->andReturnUsing($collection); + $os->shouldReceive('read') + ->once() + ->andReturn(pack('C*', rand(0, 255), rand(0, 255))); + $os->shouldReceive('read') + ->zeroOrMoreTimes() + ->andReturn(false); + + $this->_encoder->encodeByteStream($os, $is); + $this->assertRegExp('~^[a-zA-Z0-9/\+]{3}=$~', $collection->content, + '%s: Two bytes should have 1 byte of padding' + ); + } + + for ($i = 0; $i < 30; ++$i) { + $os = $this->_createOutputByteStream(); + $is = $this->_createInputByteStream(); + $collection = new Swift_StreamCollector(); + + $is->shouldReceive('write') + ->zeroOrMoreTimes() + ->andReturnUsing($collection); + $os->shouldReceive('read') + ->once() + ->andReturn(pack('C*', rand(0, 255), rand(0, 255), rand(0, 255))); + $os->shouldReceive('read') + ->zeroOrMoreTimes() + ->andReturn(false); + + $this->_encoder->encodeByteStream($os, $is); + $this->assertRegExp('~^[a-zA-Z0-9/\+]{4}$~', $collection->content, + '%s: Three bytes should have no padding' + ); + } + } + + public function testMaximumLineLengthIs76Characters() + { + /* + The encoded output stream must be represented in lines of no more + than 76 characters each. All line breaks or other characters not + found in Table 1 must be ignored by decoding software. + */ + + $os = $this->_createOutputByteStream(); + $is = $this->_createInputByteStream(); + $collection = new Swift_StreamCollector(); + + $is->shouldReceive('write') + ->zeroOrMoreTimes() + ->andReturnUsing($collection); + $os->shouldReceive('read') + ->once() + ->andReturn('abcdefghijkl'); //12 + $os->shouldReceive('read') + ->once() + ->andReturn('mnopqrstuvwx'); //24 + $os->shouldReceive('read') + ->once() + ->andReturn('yzabc1234567'); //36 + $os->shouldReceive('read') + ->once() + ->andReturn('890ABCDEFGHI'); //48 + $os->shouldReceive('read') + ->once() + ->andReturn('JKLMNOPQRSTU'); //60 + $os->shouldReceive('read') + ->once() + ->andReturn('VWXYZ1234567'); //72 + $os->shouldReceive('read') + ->once() + ->andReturn('abcdefghijkl'); //84 + $os->shouldReceive('read') + ->zeroOrMoreTimes() + ->andReturn(false); + + $this->_encoder->encodeByteStream($os, $is); + $this->assertEquals( + "YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXphYmMxMjM0NTY3ODkwQUJDREVGR0hJSktMTU5PUFFS\r\n" . + "U1RVVldYWVoxMjM0NTY3YWJjZGVmZ2hpamts", + $collection->content + ); + } + + public function testMaximumLineLengthCanBeDifferent() + { + $os = $this->_createOutputByteStream(); + $is = $this->_createInputByteStream(); + $collection = new Swift_StreamCollector(); + + $is->shouldReceive('write') + ->zeroOrMoreTimes() + ->andReturnUsing($collection); + $os->shouldReceive('read') + ->once() + ->andReturn('abcdefghijkl'); //12 + $os->shouldReceive('read') + ->once() + ->andReturn('mnopqrstuvwx'); //24 + $os->shouldReceive('read') + ->once() + ->andReturn('yzabc1234567'); //36 + $os->shouldReceive('read') + ->once() + ->andReturn('890ABCDEFGHI'); //48 + $os->shouldReceive('read') + ->once() + ->andReturn('JKLMNOPQRSTU'); //60 + $os->shouldReceive('read') + ->once() + ->andReturn('VWXYZ1234567'); //72 + $os->shouldReceive('read') + ->once() + ->andReturn('abcdefghijkl'); //84 + $os->shouldReceive('read') + ->zeroOrMoreTimes() + ->andReturn(false); + + $this->_encoder->encodeByteStream($os, $is, 0, 50); + $this->assertEquals( + "YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXphYmMxMjM0NTY3OD\r\n" . + "kwQUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVoxMjM0NTY3YWJj\r\n" . + "ZGVmZ2hpamts", + $collection->content + ); + } + + public function testMaximumLineLengthIsNeverMoreThan76Chars() + { + $os = $this->_createOutputByteStream(); + $is = $this->_createInputByteStream(); + $collection = new Swift_StreamCollector(); + + $is->shouldReceive('write') + ->zeroOrMoreTimes() + ->andReturnUsing($collection); + $os->shouldReceive('read') + ->once() + ->andReturn('abcdefghijkl'); //12 + $os->shouldReceive('read') + ->once() + ->andReturn('mnopqrstuvwx'); //24 + $os->shouldReceive('read') + ->once() + ->andReturn('yzabc1234567'); //36 + $os->shouldReceive('read') + ->once() + ->andReturn('890ABCDEFGHI'); //48 + $os->shouldReceive('read') + ->once() + ->andReturn('JKLMNOPQRSTU'); //60 + $os->shouldReceive('read') + ->once() + ->andReturn('VWXYZ1234567'); //72 + $os->shouldReceive('read') + ->once() + ->andReturn('abcdefghijkl'); //84 + $os->shouldReceive('read') + ->zeroOrMoreTimes() + ->andReturn(false); + + $this->_encoder->encodeByteStream($os, $is, 0, 100); + $this->assertEquals( + "YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXphYmMxMjM0NTY3ODkwQUJDREVGR0hJSktMTU5PUFFS\r\n" . + "U1RVVldYWVoxMjM0NTY3YWJjZGVmZ2hpamts", + $collection->content + ); + } + + public function testFirstLineLengthCanBeDifferent() + { + $os = $this->_createOutputByteStream(); + $is = $this->_createInputByteStream(); + $collection = new Swift_StreamCollector(); + + $is->shouldReceive('write') + ->zeroOrMoreTimes() + ->andReturnUsing($collection); + $os->shouldReceive('read') + ->once() + ->andReturn('abcdefghijkl'); //12 + $os->shouldReceive('read') + ->once() + ->andReturn('mnopqrstuvwx'); //24 + $os->shouldReceive('read') + ->once() + ->andReturn('yzabc1234567'); //36 + $os->shouldReceive('read') + ->once() + ->andReturn('890ABCDEFGHI'); //48 + $os->shouldReceive('read') + ->once() + ->andReturn('JKLMNOPQRSTU'); //60 + $os->shouldReceive('read') + ->once() + ->andReturn('VWXYZ1234567'); //72 + $os->shouldReceive('read') + ->once() + ->andReturn('abcdefghijkl'); //84 + $os->shouldReceive('read') + ->zeroOrMoreTimes() + ->andReturn(false); + + $this->_encoder->encodeByteStream($os, $is, 19); + $this->assertEquals( + "YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXphYmMxMjM0NTY3ODkwQUJDR\r\n" . + "EVGR0hJSktMTU5PUFFSU1RVVldYWVoxMjM0NTY3YWJjZGVmZ2hpamts", + $collection->content + ); + } + + // -- Private Methods + + private function _createOutputByteStream($stub = false) + { + return $this->getMockery('Swift_OutputByteStream')->shouldIgnoreMissing(); + } + + private function _createInputByteStream($stub = false) + { + return $this->getMockery('Swift_InputByteStream')->shouldIgnoreMissing(); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/ContentEncoder/PlainContentEncoderTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/ContentEncoder/PlainContentEncoderTest.php new file mode 100755 index 0000000..496cd20 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/ContentEncoder/PlainContentEncoderTest.php @@ -0,0 +1,173 @@ +_getEncoder('7bit'); + $this->assertEquals('7bit', $encoder->getName()); + + $encoder = $this->_getEncoder('8bit'); + $this->assertEquals('8bit', $encoder->getName()); + } + + public function testNoOctetsAreModifiedInString() + { + $encoder = $this->_getEncoder('7bit'); + foreach (range(0x00, 0xFF) as $octet) { + $byte = pack('C', $octet); + $this->assertIdenticalBinary($byte, $encoder->encodeString($byte)); + } + } + + public function testNoOctetsAreModifiedInByteStream() + { + $encoder = $this->_getEncoder('7bit'); + foreach (range(0x00, 0xFF) as $octet) { + $byte = pack('C', $octet); + + $os = $this->_createOutputByteStream(); + $is = $this->_createInputByteStream(); + $collection = new Swift_StreamCollector(); + + $is->shouldReceive('write') + ->zeroOrMoreTimes() + ->andReturnUsing($collection); + $os->shouldReceive('read') + ->once() + ->andReturn($byte); + $os->shouldReceive('read') + ->zeroOrMoreTimes() + ->andReturn(false); + + $encoder->encodeByteStream($os, $is); + $this->assertIdenticalBinary($byte, $collection->content); + } + } + + public function testLineLengthCanBeSpecified() + { + $encoder = $this->_getEncoder('7bit'); + + $chars = array(); + for ($i = 0; $i < 50; $i++) { + $chars[] = 'a'; + } + $input = implode(' ', $chars); //99 chars long + + $this->assertEquals( + 'a a a a a a a a a a a a a a a a a a a a a a a a a ' . "\r\n" . //50 * + 'a a a a a a a a a a a a a a a a a a a a a a a a a', //99 + $encoder->encodeString($input, 0, 50), + '%s: Lines should be wrapped at 50 chars' + ); + } + + public function testLineLengthCanBeSpecifiedInByteStream() + { + $encoder = $this->_getEncoder('7bit'); + + $os = $this->_createOutputByteStream(); + $is = $this->_createInputByteStream(); + $collection = new Swift_StreamCollector(); + + $is->shouldReceive('write') + ->zeroOrMoreTimes() + ->andReturnUsing($collection); + + for ($i = 0; $i < 50; $i++) { + $os->shouldReceive('read') + ->once() + ->andReturn('a '); + } + + $os->shouldReceive('read') + ->zeroOrMoreTimes() + ->andReturn(false); + + $encoder->encodeByteStream($os, $is, 0, 50); + $this->assertEquals( + str_repeat('a ', 25) . "\r\n" . str_repeat('a ', 25), + $collection->content + ); + } + + public function testencodeStringGeneratesCorrectCrlf() + { + $encoder = $this->_getEncoder('7bit', true); + $this->assertEquals("a\r\nb", $encoder->encodeString("a\rb"), + '%s: Line endings should be standardized' + ); + $this->assertEquals("a\r\nb", $encoder->encodeString("a\nb"), + '%s: Line endings should be standardized' + ); + $this->assertEquals("a\r\n\r\nb", $encoder->encodeString("a\n\rb"), + '%s: Line endings should be standardized' + ); + $this->assertEquals("a\r\n\r\nb", $encoder->encodeString("a\r\rb"), + '%s: Line endings should be standardized' + ); + $this->assertEquals("a\r\n\r\nb", $encoder->encodeString("a\n\nb"), + '%s: Line endings should be standardized' + ); + } + + public function crlfProvider() + { + return array( + array("\r", "a\r\nb"), + array("\n", "a\r\nb"), + array("\n\r", "a\r\n\r\nb"), + array("\n\n", "a\r\n\r\nb"), + array("\r\r", "a\r\n\r\nb") + ); + } + + /** + * @dataProvider crlfProvider + */ + public function testCanonicEncodeByteStreamGeneratesCorrectCrlf($test, $expected) + { + $encoder = $this->_getEncoder('7bit', true); + + $os = $this->_createOutputByteStream(); + $is = $this->_createInputByteStream(); + $collection = new Swift_StreamCollector(); + + $is->shouldReceive('write') + ->zeroOrMoreTimes() + ->andReturnUsing($collection); + $os->shouldReceive('read') + ->once() + ->andReturn('a'); + $os->shouldReceive('read') + ->once() + ->andReturn($test); + $os->shouldReceive('read') + ->once() + ->andReturn('b'); + $os->shouldReceive('read') + ->zeroOrMoreTimes() + ->andReturn(false); + + $encoder->encodeByteStream($os, $is); + $this->assertEquals($expected, $collection->content); + } + + // -- Private helpers + + private function _getEncoder($name, $canonical = false) + { + return new Swift_Mime_ContentEncoder_PlainContentEncoder($name, $canonical); + } + + private function _createOutputByteStream($stub = false) + { + return $this->getMockery('Swift_OutputByteStream')->shouldIgnoreMissing(); + } + + private function _createInputByteStream($stub = false) + { + return $this->getMockery('Swift_InputByteStream')->shouldIgnoreMissing(); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/ContentEncoder/QpContentEncoderTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/ContentEncoder/QpContentEncoderTest.php new file mode 100755 index 0000000..1bdb42d --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/ContentEncoder/QpContentEncoderTest.php @@ -0,0 +1,497 @@ +_createCharacterStream(true) + ); + $this->assertEquals('quoted-printable', $encoder->getName()); + } + + /* -- RFC 2045, 6.7 -- + (1) (General 8bit representation) Any octet, except a CR or + LF that is part of a CRLF line break of the canonical + (standard) form of the data being encoded, may be + represented by an "=" followed by a two digit + hexadecimal representation of the octet's value. The + digits of the hexadecimal alphabet, for this purpose, + are "0123456789ABCDEF". Uppercase letters must be + used; lowercase letters are not allowed. Thus, for + example, the decimal value 12 (US-ASCII form feed) can + be represented by "=0C", and the decimal value 61 (US- + ASCII EQUAL SIGN) can be represented by "=3D". This + rule must be followed except when the following rules + allow an alternative encoding. + */ + + public function testPermittedCharactersAreNotEncoded() + { + /* -- RFC 2045, 6.7 -- + (2) (Literal representation) Octets with decimal values of + 33 through 60 inclusive, and 62 through 126, inclusive, + MAY be represented as the US-ASCII characters which + correspond to those octets (EXCLAMATION POINT through + LESS THAN, and GREATER THAN through TILDE, + respectively). + */ + + foreach (array_merge(range(33, 60), range(62, 126)) as $ordinal) { + $char = chr($ordinal); + + $os = $this->_createOutputByteStream(true); + $charStream = $this->_createCharacterStream(); + $is = $this->_createInputByteStream(); + $collection = new Swift_StreamCollector(); + + $is->shouldReceive('write') + ->zeroOrMoreTimes() + ->andReturnUsing($collection); + $charStream->shouldReceive('flushContents') + ->once(); + $charStream->shouldReceive('importByteStream') + ->once() + ->with($os); + $charStream->shouldReceive('readBytes') + ->once() + ->andReturn(array($ordinal)); + $charStream->shouldReceive('readBytes') + ->zeroOrMoreTimes() + ->andReturn(false); + + $encoder = new Swift_Mime_ContentEncoder_QpContentEncoder($charStream); + $encoder->encodeByteStream($os, $is); + $this->assertIdenticalBinary($char, $collection->content); + } + } + + public function testLinearWhiteSpaceAtLineEndingIsEncoded() + { + /* -- RFC 2045, 6.7 -- + (3) (White Space) Octets with values of 9 and 32 MAY be + represented as US-ASCII TAB (HT) and SPACE characters, + respectively, but MUST NOT be so represented at the end + of an encoded line. Any TAB (HT) or SPACE characters + on an encoded line MUST thus be followed on that line + by a printable character. In particular, an "=" at the + end of an encoded line, indicating a soft line break + (see rule #5) may follow one or more TAB (HT) or SPACE + characters. It follows that an octet with decimal + value 9 or 32 appearing at the end of an encoded line + must be represented according to Rule #1. This rule is + necessary because some MTAs (Message Transport Agents, + programs which transport messages from one user to + another, or perform a portion of such transfers) are + known to pad lines of text with SPACEs, and others are + known to remove "white space" characters from the end + of a line. Therefore, when decoding a Quoted-Printable + body, any trailing white space on a line must be + deleted, as it will necessarily have been added by + intermediate transport agents. + */ + + $HT = chr(0x09); //9 + $SPACE = chr(0x20); //32 + + //HT + $os = $this->_createOutputByteStream(true); + $charStream = $this->_createCharacterStream(); + $is = $this->_createInputByteStream(); + $collection = new Swift_StreamCollector(); + + $is->shouldReceive('write') + ->zeroOrMoreTimes() + ->andReturnUsing($collection); + $charStream->shouldReceive('flushContents') + ->once(); + $charStream->shouldReceive('importByteStream') + ->once() + ->with($os); + $charStream->shouldReceive('readBytes') + ->once() + ->andReturn(array(ord('a'))); + $charStream->shouldReceive('readBytes') + ->once() + ->andReturn(array(0x09)); + $charStream->shouldReceive('readBytes') + ->once() + ->andReturn(array(0x09)); + $charStream->shouldReceive('readBytes') + ->once() + ->andReturn(array(0x0D)); + $charStream->shouldReceive('readBytes') + ->once() + ->andReturn(array(0x0A)); + $charStream->shouldReceive('readBytes') + ->once() + ->andReturn(array(ord('b'))); + $charStream->shouldReceive('readBytes') + ->zeroOrMoreTimes() + ->andReturn(false); + + $encoder = new Swift_Mime_ContentEncoder_QpContentEncoder($charStream); + $encoder->encodeByteStream($os, $is); + + $this->assertEquals("a\t=09\r\nb", $collection->content); + + //SPACE + $os = $this->_createOutputByteStream(true); + $charStream = $this->_createCharacterStream(); + $is = $this->_createInputByteStream(); + $collection = new Swift_StreamCollector(); + + $is->shouldReceive('write') + ->zeroOrMoreTimes() + ->andReturnUsing($collection); + $charStream->shouldReceive('flushContents') + ->once(); + $charStream->shouldReceive('importByteStream') + ->once() + ->with($os); + $charStream->shouldReceive('readBytes') + ->once() + ->andReturn(array(ord('a'))); + $charStream->shouldReceive('readBytes') + ->once() + ->andReturn(array(0x20)); + $charStream->shouldReceive('readBytes') + ->once() + ->andReturn(array(0x20)); + $charStream->shouldReceive('readBytes') + ->once() + ->andReturn(array(0x0D)); + $charStream->shouldReceive('readBytes') + ->once() + ->andReturn(array(0x0A)); + $charStream->shouldReceive('readBytes') + ->once() + ->andReturn(array(ord('b'))); + $charStream->shouldReceive('readBytes') + ->zeroOrMoreTimes() + ->andReturn(false); + + $encoder = new Swift_Mime_ContentEncoder_QpContentEncoder($charStream); + $encoder->encodeByteStream($os, $is); + + $this->assertEquals("a =20\r\nb", $collection->content); + } + + public function testCRLFIsLeftAlone() + { + /* + (4) (Line Breaks) A line break in a text body, represented + as a CRLF sequence in the text canonical form, must be + represented by a (RFC 822) line break, which is also a + CRLF sequence, in the Quoted-Printable encoding. Since + the canonical representation of media types other than + text do not generally include the representation of + line breaks as CRLF sequences, no hard line breaks + (i.e. line breaks that are intended to be meaningful + and to be displayed to the user) can occur in the + quoted-printable encoding of such types. Sequences + like "=0D", "=0A", "=0A=0D" and "=0D=0A" will routinely + appear in non-text data represented in quoted- + printable, of course. + + Note that many implementations may elect to encode the + local representation of various content types directly + rather than converting to canonical form first, + encoding, and then converting back to local + representation. In particular, this may apply to plain + text material on systems that use newline conventions + other than a CRLF terminator sequence. Such an + implementation optimization is permissible, but only + when the combined canonicalization-encoding step is + equivalent to performing the three steps separately. + */ + + $os = $this->_createOutputByteStream(true); + $charStream = $this->_createCharacterStream(); + $is = $this->_createInputByteStream(); + $collection = new Swift_StreamCollector(); + + $is->shouldReceive('write') + ->zeroOrMoreTimes() + ->andReturnUsing($collection); + $charStream->shouldReceive('flushContents') + ->once(); + $charStream->shouldReceive('importByteStream') + ->once() + ->with($os); + $charStream->shouldReceive('readBytes') + ->once() + ->andReturn(array(ord('a'))); + $charStream->shouldReceive('readBytes') + ->once() + ->andReturn(array(0x0D)); + $charStream->shouldReceive('readBytes') + ->once() + ->andReturn(array(0x0A)); + $charStream->shouldReceive('readBytes') + ->once() + ->andReturn(array(ord('b'))); + $charStream->shouldReceive('readBytes') + ->once() + ->andReturn(array(0x0D)); + $charStream->shouldReceive('readBytes') + ->once() + ->andReturn(array(0x0A)); + $charStream->shouldReceive('readBytes') + ->once() + ->andReturn(array(ord('c'))); + $charStream->shouldReceive('readBytes') + ->once() + ->andReturn(array(0x0D)); + $charStream->shouldReceive('readBytes') + ->once() + ->andReturn(array(0x0A)); + $charStream->shouldReceive('readBytes') + ->zeroOrMoreTimes() + ->andReturn(false); + + $encoder = new Swift_Mime_ContentEncoder_QpContentEncoder($charStream); + $encoder->encodeByteStream($os, $is); + $this->assertEquals("a\r\nb\r\nc\r\n", $collection->content); + } + + public function testLinesLongerThan76CharactersAreSoftBroken() + { + /* + (5) (Soft Line Breaks) The Quoted-Printable encoding + REQUIRES that encoded lines be no more than 76 + characters long. If longer lines are to be encoded + with the Quoted-Printable encoding, "soft" line breaks + must be used. An equal sign as the last character on a + encoded line indicates such a non-significant ("soft") + line break in the encoded text. + */ + + $os = $this->_createOutputByteStream(true); + $charStream = $this->_createCharacterStream(); + $is = $this->_createInputByteStream(); + $collection = new Swift_StreamCollector(); + + $is->shouldReceive('write') + ->zeroOrMoreTimes() + ->andReturnUsing($collection); + $charStream->shouldReceive('flushContents') + ->once(); + $charStream->shouldReceive('importByteStream') + ->once() + ->with($os); + + for ($seq = 0; $seq <= 140; ++$seq) { + $charStream->shouldReceive('readBytes') + ->once() + ->andReturn(array(ord('a'))); + } + $charStream->shouldReceive('readBytes') + ->zeroOrMoreTimes() + ->andReturn(false); + + $encoder = new Swift_Mime_ContentEncoder_QpContentEncoder($charStream); + $encoder->encodeByteStream($os, $is); + $this->assertEquals(str_repeat('a', 75) . "=\r\n" . str_repeat('a', 66), $collection->content); + } + + public function testMaxLineLengthCanBeSpecified() + { + $os = $this->_createOutputByteStream(true); + $charStream = $this->_createCharacterStream(); + $is = $this->_createInputByteStream(); + $collection = new Swift_StreamCollector(); + + $is->shouldReceive('write') + ->zeroOrMoreTimes() + ->andReturnUsing($collection); + $charStream->shouldReceive('flushContents') + ->once(); + $charStream->shouldReceive('importByteStream') + ->once() + ->with($os); + + for ($seq = 0; $seq <= 100; ++$seq) { + $charStream->shouldReceive('readBytes') + ->once() + ->andReturn(array(ord('a'))); + } + $charStream->shouldReceive('readBytes') + ->zeroOrMoreTimes() + ->andReturn(false); + + $encoder = new Swift_Mime_ContentEncoder_QpContentEncoder($charStream); + $encoder->encodeByteStream($os, $is, 0, 54); + $this->assertEquals(str_repeat('a', 53) . "=\r\n" . str_repeat('a', 48), $collection->content); + } + + public function testBytesBelowPermittedRangeAreEncoded() + { + /* + According to Rule (1 & 2) + */ + + foreach (range(0, 32) as $ordinal) { + $char = chr($ordinal); + + $os = $this->_createOutputByteStream(true); + $charStream = $this->_createCharacterStream(); + $is = $this->_createInputByteStream(); + $collection = new Swift_StreamCollector(); + + $is->shouldReceive('write') + ->zeroOrMoreTimes() + ->andReturnUsing($collection); + $charStream->shouldReceive('flushContents') + ->once(); + $charStream->shouldReceive('importByteStream') + ->once() + ->with($os); + $charStream->shouldReceive('readBytes') + ->once() + ->andReturn(array($ordinal)); + $charStream->shouldReceive('readBytes') + ->zeroOrMoreTimes() + ->andReturn(false); + + $encoder = new Swift_Mime_ContentEncoder_QpContentEncoder($charStream); + $encoder->encodeByteStream($os, $is); + $this->assertEquals(sprintf('=%02X', $ordinal), $collection->content); + } + } + + public function testDecimalByte61IsEncoded() + { + /* + According to Rule (1 & 2) + */ + + $char = chr(61); + + $os = $this->_createOutputByteStream(true); + $charStream = $this->_createCharacterStream(); + $is = $this->_createInputByteStream(); + $collection = new Swift_StreamCollector(); + + $is->shouldReceive('write') + ->zeroOrMoreTimes() + ->andReturnUsing($collection); + $charStream->shouldReceive('flushContents') + ->once(); + $charStream->shouldReceive('importByteStream') + ->once() + ->with($os); + $charStream->shouldReceive('readBytes') + ->once() + ->andReturn(array(61)); + $charStream->shouldReceive('readBytes') + ->zeroOrMoreTimes() + ->andReturn(false); + + $encoder = new Swift_Mime_ContentEncoder_QpContentEncoder($charStream); + $encoder->encodeByteStream($os, $is); + $this->assertEquals(sprintf('=%02X', 61), $collection->content); + } + + public function testBytesAbovePermittedRangeAreEncoded() + { + /* + According to Rule (1 & 2) + */ + + foreach (range(127, 255) as $ordinal) { + $char = chr($ordinal); + + $os = $this->_createOutputByteStream(true); + $charStream = $this->_createCharacterStream(); + $is = $this->_createInputByteStream(); + $collection = new Swift_StreamCollector(); + + $is->shouldReceive('write') + ->zeroOrMoreTimes() + ->andReturnUsing($collection); + $charStream->shouldReceive('flushContents') + ->once(); + $charStream->shouldReceive('importByteStream') + ->once() + ->with($os); + $charStream->shouldReceive('readBytes') + ->once() + ->andReturn(array($ordinal)); + $charStream->shouldReceive('readBytes') + ->zeroOrMoreTimes() + ->andReturn(false); + + $encoder = new Swift_Mime_ContentEncoder_QpContentEncoder($charStream); + $encoder->encodeByteStream($os, $is); + $this->assertEquals(sprintf('=%02X', $ordinal), $collection->content); + } + } + + public function testFirstLineLengthCanBeDifferent() + { + $os = $this->_createOutputByteStream(true); + $charStream = $this->_createCharacterStream(); + $is = $this->_createInputByteStream(); + $collection = new Swift_StreamCollector(); + + $is->shouldReceive('write') + ->zeroOrMoreTimes() + ->andReturnUsing($collection); + $charStream->shouldReceive('flushContents') + ->once(); + $charStream->shouldReceive('importByteStream') + ->once() + ->with($os); + + for ($seq = 0; $seq <= 140; ++$seq) { + $charStream->shouldReceive('readBytes') + ->once() + ->andReturn(array(ord('a'))); + } + $charStream->shouldReceive('readBytes') + ->zeroOrMoreTimes() + ->andReturn(false); + + $encoder = new Swift_Mime_ContentEncoder_QpContentEncoder($charStream); + $encoder->encodeByteStream($os, $is, 22); + $this->assertEquals( + str_repeat('a', 53) . "=\r\n" . str_repeat('a', 75) . "=\r\n" . str_repeat('a', 13), + $collection->content + ); + } + + public function testObserverInterfaceCanChangeCharset() + { + $stream = $this->_createCharacterStream(); + $stream->shouldReceive('setCharacterSet') + ->once() + ->with('windows-1252'); + + $encoder = new Swift_Mime_ContentEncoder_QpContentEncoder($stream); + $encoder->charsetChanged('windows-1252'); + } + + // -- Creation Methods + + private function _createCharacterStream($stub = false) + { + return $this->getMockery('Swift_CharacterStream')->shouldIgnoreMissing(); + } + + private function _createEncoder($charStream) + { + return new Swift_Mime_HeaderEncoder_QpHeaderEncoder($charStream); + } + + private function _createOutputByteStream($stub = false) + { + return $this->getMockery('Swift_OutputByteStream')->shouldIgnoreMissing(); + } + + private function _createInputByteStream($stub = false) + { + return $this->getMockery('Swift_InputByteStream')->shouldIgnoreMissing(); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/EmbeddedFileTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/EmbeddedFileTest.php new file mode 100755 index 0000000..8ffe784 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/EmbeddedFileTest.php @@ -0,0 +1,56 @@ +_createEmbeddedFile($this->_createHeaderSet(), + $this->_createEncoder(), $this->_createCache() + ); + $this->assertEquals( + Swift_Mime_MimeEntity::LEVEL_RELATED, $file->getNestingLevel() + ); + } + + public function testIdIsAutoGenerated() + { + $headers = $this->_createHeaderSet(array(), false); + $headers->shouldReceive('addIdHeader') + ->once() + ->with('Content-ID', '/^.*?@.*?$/D'); + + $file = $this->_createEmbeddedFile($headers, $this->_createEncoder(), + $this->_createCache() + ); + } + + public function testDefaultDispositionIsInline() + { + $headers = $this->_createHeaderSet(array(), false); + $headers->shouldReceive('addParameterizedHeader') + ->once() + ->with('Content-Disposition', 'inline'); + $headers->shouldReceive('addParameterizedHeader') + ->zeroOrMoreTimes(); + + $file = $this->_createEmbeddedFile($headers, $this->_createEncoder(), + $this->_createCache() + ); + } + + // -- Private helpers + + protected function _createAttachment($headers, $encoder, $cache, $mimeTypes = array()) + { + return $this->_createEmbeddedFile($headers, $encoder, $cache, $mimeTypes); + } + + private function _createEmbeddedFile($headers, $encoder, $cache) + { + return new Swift_Mime_EmbeddedFile($headers, $encoder, $cache, new Swift_Mime_Grammar()); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/HeaderEncoder/Base64HeaderEncoderTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/HeaderEncoder/Base64HeaderEncoderTest.php new file mode 100755 index 0000000..3580155 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/HeaderEncoder/Base64HeaderEncoderTest.php @@ -0,0 +1,13 @@ +assertEquals('B', $encoder->getName()); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/HeaderEncoder/QpHeaderEncoderTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/HeaderEncoder/QpHeaderEncoderTest.php new file mode 100755 index 0000000..95bde92 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/HeaderEncoder/QpHeaderEncoderTest.php @@ -0,0 +1,223 @@ +_createEncoder( + $this->_createCharacterStream(true) + ); + $this->assertEquals('Q', $encoder->getName()); + } + + public function testSpaceAndTabNeverAppear() + { + /* -- RFC 2047, 4. + Only a subset of the printable ASCII characters may be used in + 'encoded-text'. Space and tab characters are not allowed, so that + the beginning and end of an 'encoded-word' are obvious. + */ + + $charStream = $this->_createCharacterStream(); + $charStream->shouldReceive('readBytes') + ->atLeast()->times(6) + ->andReturn(array(ord('a')), array(0x20), array(0x09), array(0x20), array(ord('b')), false); + + $encoder = $this->_createEncoder($charStream); + $this->assertNotRegExp('~[ \t]~', $encoder->encodeString("a \t b"), + '%s: encoded-words in headers cannot contain LWSP as per RFC 2047.' + ); + } + + public function testSpaceIsRepresentedByUnderscore() + { + /* -- RFC 2047, 4.2. + (2) The 8-bit hexadecimal value 20 (e.g., ISO-8859-1 SPACE) may be + represented as "_" (underscore, ASCII 95.). (This character may + not pass through some internetwork mail gateways, but its use + will greatly enhance readability of "Q" encoded data with mail + readers that do not support this encoding.) Note that the "_" + always represents hexadecimal 20, even if the SPACE character + occupies a different code position in the character set in use. + */ + $charStream = $this->_createCharacterStream(); + $charStream->shouldReceive('readBytes') + ->once() + ->andReturn(array(ord('a'))); + $charStream->shouldReceive('readBytes') + ->once() + ->andReturn(array(0x20)); + $charStream->shouldReceive('readBytes') + ->once() + ->andReturn(array(ord('b'))); + $charStream->shouldReceive('readBytes') + ->zeroOrMoreTimes() + ->andReturn(false); + + $encoder = $this->_createEncoder($charStream); + $this->assertEquals('a_b', $encoder->encodeString('a b'), + '%s: Spaces can be represented by more readable underscores as per RFC 2047.' + ); + } + + public function testEqualsAndQuestionAndUnderscoreAreEncoded() + { + /* -- RFC 2047, 4.2. + (3) 8-bit values which correspond to printable ASCII characters other + than "=", "?", and "_" (underscore), MAY be represented as those + characters. (But see section 5 for restrictions.) In + particular, SPACE and TAB MUST NOT be represented as themselves + within encoded words. + */ + $charStream = $this->_createCharacterStream(); + $charStream->shouldReceive('readBytes') + ->once() + ->andReturn(array(ord('='))); + $charStream->shouldReceive('readBytes') + ->once() + ->andReturn(array(ord('?'))); + $charStream->shouldReceive('readBytes') + ->once() + ->andReturn(array(ord('_'))); + $charStream->shouldReceive('readBytes') + ->zeroOrMoreTimes() + ->andReturn(false); + + $encoder = $this->_createEncoder($charStream); + $this->assertEquals('=3D=3F=5F', $encoder->encodeString('=?_'), + '%s: Chars =, ? and _ (underscore) may not appear as per RFC 2047.' + ); + } + + public function testParensAndQuotesAreEncoded() + { + /* -- RFC 2047, 5 (2). + A "Q"-encoded 'encoded-word' which appears in a 'comment' MUST NOT + contain the characters "(", ")" or " + */ + + $charStream = $this->_createCharacterStream(); + $charStream->shouldReceive('readBytes') + ->once() + ->andReturn(array(ord('('))); + $charStream->shouldReceive('readBytes') + ->once() + ->andReturn(array(ord('"'))); + $charStream->shouldReceive('readBytes') + ->once() + ->andReturn(array(ord(')'))); + $charStream->shouldReceive('readBytes') + ->zeroOrMoreTimes() + ->andReturn(false); + + $encoder = $this->_createEncoder($charStream); + $this->assertEquals('=28=22=29', $encoder->encodeString('(")'), + '%s: Chars (, " (DQUOTE) and ) may not appear as per RFC 2047.' + ); + } + + public function testOnlyCharactersAllowedInPhrasesAreUsed() + { + /* -- RFC 2047, 5. + (3) As a replacement for a 'word' entity within a 'phrase', for example, + one that precedes an address in a From, To, or Cc header. The ABNF + definition for 'phrase' from RFC 822 thus becomes: + + phrase = 1*( encoded-word / word ) + + In this case the set of characters that may be used in a "Q"-encoded + 'encoded-word' is restricted to: . An 'encoded-word' that appears within a + 'phrase' MUST be separated from any adjacent 'word', 'text' or + 'special' by 'linear-white-space'. + */ + + $allowedBytes = array_merge( + range(ord('a'), ord('z')), range(ord('A'), ord('Z')), + range(ord('0'), ord('9')), + array(ord('!'), ord('*'), ord('+'), ord('-'), ord('/')) + ); + + foreach (range(0x00, 0xFF) as $byte) { + $char = pack('C', $byte); + + $charStream = $this->_createCharacterStream(); + $charStream->shouldReceive('readBytes') + ->once() + ->andReturn(array($byte)); + $charStream->shouldReceive('readBytes') + ->zeroOrMoreTimes() + ->andReturn(false); + + $encoder = $this->_createEncoder($charStream); + $encodedChar = $encoder->encodeString($char); + + if (in_array($byte, $allowedBytes)) { + $this->assertEquals($char, $encodedChar, + '%s: Character ' . $char . ' should not be encoded.' + ); + } elseif (0x20 == $byte) //Special case + { + $this->assertEquals('_', $encodedChar, + '%s: Space character should be replaced.' + ); + } else { + $this->assertEquals(sprintf('=%02X', $byte), $encodedChar, + '%s: Byte ' . $byte . ' should be encoded.' + ); + } + } + } + + public function testEqualsNeverAppearsAtEndOfLine() + { + /* -- RFC 2047, 5 (3). + The 'encoded-text' in an 'encoded-word' must be self-contained; + 'encoded-text' MUST NOT be continued from one 'encoded-word' to + another. This implies that the 'encoded-text' portion of a "B" + 'encoded-word' will be a multiple of 4 characters long; for a "Q" + 'encoded-word', any "=" character that appears in the 'encoded-text' + portion will be followed by two hexadecimal characters. + */ + + $input = str_repeat('a', 140); + + $charStream = $this->_createCharacterStream(); + + $output = ''; + $seq = 0; + for (; $seq < 140; ++$seq) { + $charStream->shouldReceive('readBytes') + ->once() + ->andReturn(array(ord('a'))); + + if (75 == $seq) { + $output .= "\r\n"; // =\r\n + } + $output .= 'a'; + } + + $charStream->shouldReceive('readBytes') + ->zeroOrMoreTimes() + ->andReturn(false); + + $encoder = $this->_createEncoder($charStream); + $this->assertEquals($output, $encoder->encodeString($input)); + } + + // -- Creation Methods + + private function _createEncoder($charStream) + { + return new Swift_Mime_HeaderEncoder_QpHeaderEncoder($charStream); + } + + private function _createCharacterStream($stub = false) + { + return $this->getMockery('Swift_CharacterStream')->shouldIgnoreMissing(); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/Headers/DateHeaderTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/Headers/DateHeaderTest.php new file mode 100755 index 0000000..5d912e7 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/Headers/DateHeaderTest.php @@ -0,0 +1,71 @@ +_getHeader('Date'); + $this->assertEquals(Swift_Mime_Header::TYPE_DATE, $header->getFieldType()); + } + + public function testGetTimestamp() + { + $timestamp = time(); + $header = $this->_getHeader('Date'); + $header->setTimestamp($timestamp); + $this->assertSame($timestamp, $header->getTimestamp()); + } + + public function testTimestampCanBeSetBySetter() + { + $timestamp = time(); + $header = $this->_getHeader('Date'); + $header->setTimestamp($timestamp); + $this->assertSame($timestamp, $header->getTimestamp()); + } + + public function testIntegerTimestampIsConvertedToRfc2822Date() + { + $timestamp = time(); + $header = $this->_getHeader('Date'); + $header->setTimestamp($timestamp); + $this->assertEquals(date('r', $timestamp), $header->getFieldBody()); + } + + public function testSetBodyModel() + { + $timestamp = time(); + $header = $this->_getHeader('Date'); + $header->setFieldBodyModel($timestamp); + $this->assertEquals(date('r', $timestamp), $header->getFieldBody()); + } + + public function testGetBodyModel() + { + $timestamp = time(); + $header = $this->_getHeader('Date'); + $header->setTimestamp($timestamp); + $this->assertEquals($timestamp, $header->getFieldBodyModel()); + } + + public function testToString() + { + $timestamp = time(); + $header = $this->_getHeader('Date'); + $header->setTimestamp($timestamp); + $this->assertEquals('Date: ' . date('r', $timestamp) . "\r\n", + $header->toString() + ); + } + + // -- Private methods + + private function _getHeader($name) + { + return new Swift_Mime_Headers_DateHeader($name, new Swift_Mime_Grammar()); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/Headers/IdentificationHeaderTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/Headers/IdentificationHeaderTest.php new file mode 100755 index 0000000..73ec28b --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/Headers/IdentificationHeaderTest.php @@ -0,0 +1,191 @@ +_getHeader('Message-ID'); + $this->assertEquals(Swift_Mime_Header::TYPE_ID, $header->getFieldType()); + } + + public function testValueMatchesMsgIdSpec() + { + /* -- RFC 2822, 3.6.4. + message-id = "Message-ID:" msg-id CRLF + + in-reply-to = "In-Reply-To:" 1*msg-id CRLF + + references = "References:" 1*msg-id CRLF + + msg-id = [CFWS] "<" id-left "@" id-right ">" [CFWS] + + id-left = dot-atom-text / no-fold-quote / obs-id-left + + id-right = dot-atom-text / no-fold-literal / obs-id-right + + no-fold-quote = DQUOTE *(qtext / quoted-pair) DQUOTE + + no-fold-literal = "[" *(dtext / quoted-pair) "]" + */ + + $header = $this->_getHeader('Message-ID'); + $header->setId('id-left@id-right'); + $this->assertEquals('', $header->getFieldBody()); + } + + public function testIdCanBeRetrievedVerbatim() + { + $header = $this->_getHeader('Message-ID'); + $header->setId('id-left@id-right'); + $this->assertEquals('id-left@id-right', $header->getId()); + } + + public function testMultipleIdsCanBeSet() + { + $header = $this->_getHeader('References'); + $header->setIds(array('a@b', 'x@y')); + $this->assertEquals(array('a@b', 'x@y'), $header->getIds()); + } + + public function testSettingMultipleIdsProducesAListValue() + { + /* -- RFC 2822, 3.6.4. + The "References:" and "In-Reply-To:" field each contain one or more + unique message identifiers, optionally separated by CFWS. + + .. SNIP .. + + in-reply-to = "In-Reply-To:" 1*msg-id CRLF + + references = "References:" 1*msg-id CRLF + */ + + $header = $this->_getHeader('References'); + $header->setIds(array('a@b', 'x@y')); + $this->assertEquals(' ', $header->getFieldBody()); + } + + public function testIdLeftCanBeQuoted() + { + /* -- RFC 2822, 3.6.4. + id-left = dot-atom-text / no-fold-quote / obs-id-left + */ + + $header = $this->_getHeader('References'); + $header->setId('"ab"@c'); + $this->assertEquals('"ab"@c', $header->getId()); + $this->assertEquals('<"ab"@c>', $header->getFieldBody()); + } + + public function testIdLeftCanContainAnglesAsQuotedPairs() + { + /* -- RFC 2822, 3.6.4. + no-fold-quote = DQUOTE *(qtext / quoted-pair) DQUOTE + */ + + $header = $this->_getHeader('References'); + $header->setId('"a\\<\\>b"@c'); + $this->assertEquals('"a\\<\\>b"@c', $header->getId()); + $this->assertEquals('<"a\\<\\>b"@c>', $header->getFieldBody()); + } + + public function testIdLeftCanBeDotAtom() + { + $header = $this->_getHeader('References'); + $header->setId('a.b+&%$.c@d'); + $this->assertEquals('a.b+&%$.c@d', $header->getId()); + $this->assertEquals('', $header->getFieldBody()); + } + + public function testInvalidIdLeftThrowsException() + { + try { + $header = $this->_getHeader('References'); + $header->setId('a b c@d'); + $this->fail( + 'Exception should be thrown since "a b c" is not valid id-left.' + ); + } catch (Exception $e) { + } + } + + public function testIdRightCanBeDotAtom() + { + /* -- RFC 2822, 3.6.4. + id-right = dot-atom-text / no-fold-literal / obs-id-right + */ + + $header = $this->_getHeader('References'); + $header->setId('a@b.c+&%$.d'); + $this->assertEquals('a@b.c+&%$.d', $header->getId()); + $this->assertEquals('', $header->getFieldBody()); + } + + public function testIdRightCanBeLiteral() + { + /* -- RFC 2822, 3.6.4. + no-fold-literal = "[" *(dtext / quoted-pair) "]" + */ + + $header = $this->_getHeader('References'); + $header->setId('a@[1.2.3.4]'); + $this->assertEquals('a@[1.2.3.4]', $header->getId()); + $this->assertEquals('', $header->getFieldBody()); + } + + public function testInvalidIdRightThrowsException() + { + try { + $header = $this->_getHeader('References'); + $header->setId('a@b c d'); + $this->fail( + 'Exception should be thrown since "b c d" is not valid id-right.' + ); + } catch (Exception $e) { + } + } + + public function testMissingAtSignThrowsException() + { + /* -- RFC 2822, 3.6.4. + msg-id = [CFWS] "<" id-left "@" id-right ">" [CFWS] + */ + + try { + $header = $this->_getHeader('References'); + $header->setId('abc'); + $this->fail( + 'Exception should be thrown since "abc" is does not contain @.' + ); + } catch (Exception $e) { + } + } + + public function testSetBodyModel() + { + $header = $this->_getHeader('Message-ID'); + $header->setFieldBodyModel('a@b'); + $this->assertEquals(array('a@b'), $header->getIds()); + } + + public function testGetBodyModel() + { + $header = $this->_getHeader('Message-ID'); + $header->setId('a@b'); + $this->assertEquals(array('a@b'), $header->getFieldBodyModel()); + } + + public function testStringValue() + { + $header = $this->_getHeader('References'); + $header->setIds(array('a@b', 'x@y')); + $this->assertEquals('References: ' . "\r\n", $header->toString()); + } + + // -- Private methods + + private function _getHeader($name) + { + return new Swift_Mime_Headers_IdentificationHeader($name, new Swift_Mime_Grammar()); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/Headers/MailboxHeaderTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/Headers/MailboxHeaderTest.php new file mode 100755 index 0000000..5f15b07 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/Headers/MailboxHeaderTest.php @@ -0,0 +1,329 @@ +_getHeader('To', $this->_getEncoder('Q', true)); + $this->assertEquals(Swift_Mime_Header::TYPE_MAILBOX, $header->getFieldType()); + } + + public function testMailboxIsSetForAddress() + { + $header = $this->_getHeader('From', $this->_getEncoder('Q', true)); + $header->setAddresses('chris@swiftmailer.org'); + $this->assertEquals(array('chris@swiftmailer.org'), + $header->getNameAddressStrings() + ); + } + + public function testMailboxIsRenderedForNameAddress() + { + $header = $this->_getHeader('From', $this->_getEncoder('Q', true)); + $header->setNameAddresses(array('chris@swiftmailer.org' => 'Chris Corbyn')); + $this->assertEquals( + array('Chris Corbyn '), $header->getNameAddressStrings() + ); + } + + public function testAddressCanBeReturnedForAddress() + { + $header = $this->_getHeader('From', $this->_getEncoder('Q', true)); + $header->setAddresses('chris@swiftmailer.org'); + $this->assertEquals(array('chris@swiftmailer.org'), $header->getAddresses()); + } + + public function testAddressCanBeReturnedForNameAddress() + { + $header = $this->_getHeader('From', $this->_getEncoder('Q', true)); + $header->setNameAddresses(array('chris@swiftmailer.org' => 'Chris Corbyn')); + $this->assertEquals(array('chris@swiftmailer.org'), $header->getAddresses()); + } + + public function testQuotesInNameAreQuoted() + { + $header = $this->_getHeader('From', $this->_getEncoder('Q', true)); + $header->setNameAddresses(array( + 'chris@swiftmailer.org' => 'Chris Corbyn, "DHE"' + )); + $this->assertEquals( + array('"Chris Corbyn, \"DHE\"" '), + $header->getNameAddressStrings() + ); + } + + public function testEscapeCharsInNameAreQuoted() + { + $header = $this->_getHeader('From', $this->_getEncoder('Q', true)); + $header->setNameAddresses(array( + 'chris@swiftmailer.org' => 'Chris Corbyn, \\escaped\\' + )); + $this->assertEquals( + array('"Chris Corbyn, \\\\escaped\\\\" '), + $header->getNameAddressStrings() + ); + } + + public function testGetMailboxesReturnsNameValuePairs() + { + $header = $this->_getHeader('From', $this->_getEncoder('Q', true)); + $header->setNameAddresses(array( + 'chris@swiftmailer.org' => 'Chris Corbyn, DHE' + )); + $this->assertEquals( + array('chris@swiftmailer.org' => 'Chris Corbyn, DHE'), $header->getNameAddresses() + ); + } + + public function testMultipleAddressesCanBeSetAndFetched() + { + $header = $this->_getHeader('From', $this->_getEncoder('Q', true)); + $header->setAddresses(array( + 'chris@swiftmailer.org', 'mark@swiftmailer.org' + )); + $this->assertEquals( + array('chris@swiftmailer.org', 'mark@swiftmailer.org'), + $header->getAddresses() + ); + } + + public function testMultipleAddressesAsMailboxes() + { + $header = $this->_getHeader('From', $this->_getEncoder('Q', true)); + $header->setAddresses(array( + 'chris@swiftmailer.org', 'mark@swiftmailer.org' + )); + $this->assertEquals( + array('chris@swiftmailer.org'=>null, 'mark@swiftmailer.org'=>null), + $header->getNameAddresses() + ); + } + + public function testMultipleAddressesAsMailboxStrings() + { + $header = $this->_getHeader('From', $this->_getEncoder('Q', true)); + $header->setAddresses(array( + 'chris@swiftmailer.org', 'mark@swiftmailer.org' + )); + $this->assertEquals( + array('chris@swiftmailer.org', 'mark@swiftmailer.org'), + $header->getNameAddressStrings() + ); + } + + public function testMultipleNamedMailboxesReturnsMultipleAddresses() + { + $header = $this->_getHeader('From', $this->_getEncoder('Q', true)); + $header->setNameAddresses(array( + 'chris@swiftmailer.org' => 'Chris Corbyn', + 'mark@swiftmailer.org' => 'Mark Corbyn' + )); + $this->assertEquals( + array('chris@swiftmailer.org', 'mark@swiftmailer.org'), + $header->getAddresses() + ); + } + + public function testMultipleNamedMailboxesReturnsMultipleMailboxes() + { + $header = $this->_getHeader('From', $this->_getEncoder('Q', true)); + $header->setNameAddresses(array( + 'chris@swiftmailer.org' => 'Chris Corbyn', + 'mark@swiftmailer.org' => 'Mark Corbyn' + )); + $this->assertEquals(array( + 'chris@swiftmailer.org' => 'Chris Corbyn', + 'mark@swiftmailer.org' => 'Mark Corbyn' + ), + $header->getNameAddresses() + ); + } + + public function testMultipleMailboxesProducesMultipleMailboxStrings() + { + $header = $this->_getHeader('From', $this->_getEncoder('Q', true)); + $header->setNameAddresses(array( + 'chris@swiftmailer.org' => 'Chris Corbyn', + 'mark@swiftmailer.org' => 'Mark Corbyn' + )); + $this->assertEquals(array( + 'Chris Corbyn ', + 'Mark Corbyn ' + ), + $header->getNameAddressStrings() + ); + } + + public function testSetAddressesOverwritesAnyMailboxes() + { + $header = $this->_getHeader('From', $this->_getEncoder('Q', true)); + $header->setNameAddresses(array( + 'chris@swiftmailer.org' => 'Chris Corbyn', + 'mark@swiftmailer.org' => 'Mark Corbyn' + )); + $this->assertEquals( + array('chris@swiftmailer.org' => 'Chris Corbyn', + 'mark@swiftmailer.org' => 'Mark Corbyn'), + $header->getNameAddresses() + ); + $this->assertEquals( + array('chris@swiftmailer.org', 'mark@swiftmailer.org'), + $header->getAddresses() + ); + + $header->setAddresses(array('chris@swiftmailer.org', 'mark@swiftmailer.org')); + + $this->assertEquals( + array('chris@swiftmailer.org' => null, 'mark@swiftmailer.org' => null), + $header->getNameAddresses() + ); + $this->assertEquals( + array('chris@swiftmailer.org', 'mark@swiftmailer.org'), + $header->getAddresses() + ); + } + + public function testNameIsEncodedIfNonAscii() + { + $name = 'C' . pack('C', 0x8F) . 'rbyn'; + + $encoder = $this->_getEncoder('Q'); + $encoder->shouldReceive('encodeString') + ->once() + ->with($name, \Mockery::any(), \Mockery::any(), \Mockery::any()) + ->andReturn('C=8Frbyn'); + + $header = $this->_getHeader('From', $encoder); + $header->setNameAddresses(array('chris@swiftmailer.org'=>'Chris ' . $name)); + + $addresses = $header->getNameAddressStrings(); + $this->assertEquals( + 'Chris =?' . $this->_charset . '?Q?C=8Frbyn?= ', + array_shift($addresses) + ); + } + + public function testEncodingLineLengthCalculations() + { + /* -- RFC 2047, 2. + An 'encoded-word' may not be more than 75 characters long, including + 'charset', 'encoding', 'encoded-text', and delimiters. + */ + + $name = 'C' . pack('C', 0x8F) . 'rbyn'; + + $encoder = $this->_getEncoder('Q'); + $encoder->shouldReceive('encodeString') + ->once() + ->with($name, \Mockery::any(), \Mockery::any(), \Mockery::any()) + ->andReturn('C=8Frbyn'); + + $header = $this->_getHeader('From', $encoder); + $header->setNameAddresses(array('chris@swiftmailer.org'=>'Chris ' . $name)); + + $header->getNameAddressStrings(); + } + + public function testGetValueReturnsMailboxStringValue() + { + $header = $this->_getHeader('From', $this->_getEncoder('Q', true)); + $header->setNameAddresses(array( + 'chris@swiftmailer.org' => 'Chris Corbyn' + )); + $this->assertEquals( + 'Chris Corbyn ', $header->getFieldBody() + ); + } + + public function testGetValueReturnsMailboxStringValueForMultipleMailboxes() + { + $header = $this->_getHeader('From', $this->_getEncoder('Q', true)); + $header->setNameAddresses(array( + 'chris@swiftmailer.org' => 'Chris Corbyn', + 'mark@swiftmailer.org' => 'Mark Corbyn' + )); + $this->assertEquals( + 'Chris Corbyn , Mark Corbyn ', + $header->getFieldBody() + ); + } + + public function testRemoveAddressesWithSingleValue() + { + $header = $this->_getHeader('From', $this->_getEncoder('Q', true)); + $header->setNameAddresses(array( + 'chris@swiftmailer.org' => 'Chris Corbyn', + 'mark@swiftmailer.org' => 'Mark Corbyn' + )); + $header->removeAddresses('chris@swiftmailer.org'); + $this->assertEquals(array('mark@swiftmailer.org'), + $header->getAddresses() + ); + } + + public function testRemoveAddressesWithList() + { + $header = $this->_getHeader('From', $this->_getEncoder('Q', true)); + $header->setNameAddresses(array( + 'chris@swiftmailer.org' => 'Chris Corbyn', + 'mark@swiftmailer.org' => 'Mark Corbyn' + )); + $header->removeAddresses( + array('chris@swiftmailer.org', 'mark@swiftmailer.org') + ); + $this->assertEquals(array(), $header->getAddresses()); + } + + public function testSetBodyModel() + { + $header = $this->_getHeader('From', $this->_getEncoder('Q', true)); + $header->setFieldBodyModel('chris@swiftmailer.org'); + $this->assertEquals(array('chris@swiftmailer.org'=>null), $header->getNameAddresses()); + } + + public function testGetBodyModel() + { + $header = $this->_getHeader('From', $this->_getEncoder('Q', true)); + $header->setAddresses(array('chris@swiftmailer.org')); + $this->assertEquals(array('chris@swiftmailer.org'=>null), $header->getFieldBodyModel()); + } + + public function testToString() + { + $header = $this->_getHeader('From', $this->_getEncoder('Q', true)); + $header->setNameAddresses(array( + 'chris@swiftmailer.org' => 'Chris Corbyn', + 'mark@swiftmailer.org' => 'Mark Corbyn' + )); + $this->assertEquals( + 'From: Chris Corbyn , ' . + 'Mark Corbyn ' . "\r\n", + $header->toString() + ); + } + + // -- Private methods + + private function _getHeader($name, $encoder) + { + $header = new Swift_Mime_Headers_MailboxHeader($name, $encoder, new Swift_Mime_Grammar()); + $header->setCharset($this->_charset); + + return $header; + } + + private function _getEncoder($type, $stub = false) + { + $encoder = $this->getMockery('Swift_Mime_HeaderEncoder')->shouldIgnoreMissing(); + $encoder->shouldReceive('getName') + ->zeroOrMoreTimes() + ->andReturn($type); + + return $encoder; + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/Headers/ParameterizedHeaderTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/Headers/ParameterizedHeaderTest.php new file mode 100755 index 0000000..0018c04 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/Headers/ParameterizedHeaderTest.php @@ -0,0 +1,401 @@ +_getHeader('Content-Type', + $this->_getHeaderEncoder('Q', true), $this->_getParameterEncoder(true) + ); + $this->assertEquals(Swift_Mime_Header::TYPE_PARAMETERIZED, $header->getFieldType()); + } + + public function testValueIsReturnedVerbatim() + { + $header = $this->_getHeader('Content-Type', + $this->_getHeaderEncoder('Q', true), $this->_getParameterEncoder(true) + ); + $header->setValue('text/plain'); + $this->assertEquals('text/plain', $header->getValue()); + } + + public function testParametersAreAppended() + { + /* -- RFC 2045, 5.1 + parameter := attribute "=" value + + attribute := token + ; Matching of attributes + ; is ALWAYS case-insensitive. + + value := token / quoted-string + + token := 1* + + tspecials := "(" / ")" / "<" / ">" / "@" / + "," / ";" / ":" / "\" / <"> + "/" / "[" / "]" / "?" / "=" + ; Must be in quoted-string, + ; to use within parameter values + */ + + $header = $this->_getHeader('Content-Type', + $this->_getHeaderEncoder('Q', true), $this->_getParameterEncoder(true) + ); + $header->setValue('text/plain'); + $header->setParameters(array('charset' => 'utf-8')); + $this->assertEquals('text/plain; charset=utf-8', $header->getFieldBody()); + } + + public function testSpaceInParamResultsInQuotedString() + { + $header = $this->_getHeader('Content-Disposition', + $this->_getHeaderEncoder('Q', true), $this->_getParameterEncoder(true) + ); + $header->setValue('attachment'); + $header->setParameters(array('filename' => 'my file.txt')); + $this->assertEquals('attachment; filename="my file.txt"', + $header->getFieldBody() + ); + } + + public function testLongParamsAreBrokenIntoMultipleAttributeStrings() + { + /* -- RFC 2231, 3. + The asterisk character ("*") followed + by a decimal count is employed to indicate that multiple parameters + are being used to encapsulate a single parameter value. The count + starts at 0 and increments by 1 for each subsequent section of the + parameter value. Decimal values are used and neither leading zeroes + nor gaps in the sequence are allowed. + + The original parameter value is recovered by concatenating the + various sections of the parameter, in order. For example, the + content-type field + + Content-Type: message/external-body; access-type=URL; + URL*0="ftp://"; + URL*1="cs.utk.edu/pub/moore/bulk-mailer/bulk-mailer.tar" + + is semantically identical to + + Content-Type: message/external-body; access-type=URL; + URL="ftp://cs.utk.edu/pub/moore/bulk-mailer/bulk-mailer.tar" + + Note that quotes around parameter values are part of the value + syntax; they are NOT part of the value itself. Furthermore, it is + explicitly permitted to have a mixture of quoted and unquoted + continuation fields. + */ + + $value = str_repeat('a', 180); + + $encoder = $this->_getParameterEncoder(); + $encoder->shouldReceive('encodeString') + ->once() + ->with($value, \Mockery::any(), 63, \Mockery::any()) + ->andReturn(str_repeat('a', 63) . "\r\n" . + str_repeat('a', 63) . "\r\n" . str_repeat('a', 54)); + + $header = $this->_getHeader('Content-Disposition', + $this->_getHeaderEncoder('Q', true), $encoder + ); + $header->setValue('attachment'); + $header->setParameters(array('filename' => $value)); + $header->setMaxLineLength(78); + $this->assertEquals( + 'attachment; ' . + 'filename*0*=utf-8\'\'' . str_repeat('a', 63) . ";\r\n " . + 'filename*1*=' . str_repeat('a', 63) . ";\r\n " . + 'filename*2*=' . str_repeat('a', 54), + $header->getFieldBody() + ); + } + + public function testEncodedParamDataIncludesCharsetAndLanguage() + { + /* -- RFC 2231, 4. + Asterisks ("*") are reused to provide the indicator that language and + character set information is present and encoding is being used. A + single quote ("'") is used to delimit the character set and language + information at the beginning of the parameter value. Percent signs + ("%") are used as the encoding flag, which agrees with RFC 2047. + + Specifically, an asterisk at the end of a parameter name acts as an + indicator that character set and language information may appear at + the beginning of the parameter value. A single quote is used to + separate the character set, language, and actual value information in + the parameter value string, and an percent sign is used to flag + octets encoded in hexadecimal. For example: + + Content-Type: application/x-stuff; + title*=us-ascii'en-us'This%20is%20%2A%2A%2Afun%2A%2A%2A + + Note that it is perfectly permissible to leave either the character + set or language field blank. Note also that the single quote + delimiters MUST be present even when one of the field values is + omitted. + */ + + $value = str_repeat('a', 20) . pack('C', 0x8F) . str_repeat('a', 10); + + $encoder = $this->_getParameterEncoder(); + $encoder->shouldReceive('encodeString') + ->once() + ->with($value, 12, 62, \Mockery::any()) + ->andReturn(str_repeat('a', 20) . '%8F' . str_repeat('a', 10)); + + $header = $this->_getHeader('Content-Disposition', + $this->_getHeaderEncoder('Q', true), $encoder + ); + $header->setValue('attachment'); + $header->setParameters(array('filename' => $value)); + $header->setMaxLineLength(78); + $header->setLanguage($this->_lang); + $this->assertEquals( + 'attachment; filename*=' . $this->_charset . "'" . $this->_lang . "'" . + str_repeat('a', 20) . '%8F' . str_repeat('a', 10), + $header->getFieldBody() + ); + } + + public function testMultipleEncodedParamLinesAreFormattedCorrectly() + { + /* -- RFC 2231, 4.1. + Character set and language information may be combined with the + parameter continuation mechanism. For example: + + Content-Type: application/x-stuff + title*0*=us-ascii'en'This%20is%20even%20more%20 + title*1*=%2A%2A%2Afun%2A%2A%2A%20 + title*2="isn't it!" + + Note that: + + (1) Language and character set information only appear at + the beginning of a given parameter value. + + (2) Continuations do not provide a facility for using more + than one character set or language in the same + parameter value. + + (3) A value presented using multiple continuations may + contain a mixture of encoded and unencoded segments. + + (4) The first segment of a continuation MUST be encoded if + language and character set information are given. + + (5) If the first segment of a continued parameter value is + encoded the language and character set field delimiters + MUST be present even when the fields are left blank. + */ + + $value = str_repeat('a', 20) . pack('C', 0x8F) . str_repeat('a', 60); + + $encoder = $this->_getParameterEncoder(); + $encoder->shouldReceive('encodeString') + ->once() + ->with($value, 12, 62, \Mockery::any()) + ->andReturn(str_repeat('a', 20) . '%8F' . str_repeat('a', 28) . "\r\n" . + str_repeat('a', 32)); + + $header = $this->_getHeader('Content-Disposition', + $this->_getHeaderEncoder('Q', true), $encoder + ); + $header->setValue('attachment'); + $header->setParameters(array('filename' => $value)); + $header->setMaxLineLength(78); + $header->setLanguage($this->_lang); + $this->assertEquals( + 'attachment; filename*0*=' . $this->_charset . "'" . $this->_lang . "'" . + str_repeat('a', 20) . '%8F' . str_repeat('a', 28) . ";\r\n " . + 'filename*1*=' . str_repeat('a', 32), + $header->getFieldBody() + ); + } + + public function testToString() + { + $header = $this->_getHeader('Content-Type', + $this->_getHeaderEncoder('Q', true), $this->_getParameterEncoder(true) + ); + $header->setValue('text/html'); + $header->setParameters(array('charset' => 'utf-8')); + $this->assertEquals('Content-Type: text/html; charset=utf-8' . "\r\n", + $header->toString() + ); + } + + public function testValueCanBeEncodedIfNonAscii() + { + $value = 'fo' . pack('C', 0x8F) .'bar'; + + $encoder = $this->_getHeaderEncoder('Q'); + $encoder->shouldReceive('encodeString') + ->once() + ->with($value, \Mockery::any(), \Mockery::any(), \Mockery::any()) + ->andReturn('fo=8Fbar'); + + $header = $this->_getHeader('X-Foo', $encoder, $this->_getParameterEncoder(true)); + $header->setValue($value); + $header->setParameters(array('lookslike' => 'foobar')); + $this->assertEquals('X-Foo: =?utf-8?Q?fo=8Fbar?=; lookslike=foobar' . "\r\n", + $header->toString() + ); + } + + public function testValueAndParamCanBeEncodedIfNonAscii() + { + $value = 'fo' . pack('C', 0x8F) .'bar'; + + $encoder = $this->_getHeaderEncoder('Q'); + $encoder->shouldReceive('encodeString') + ->once() + ->with($value, \Mockery::any(), \Mockery::any(), \Mockery::any()) + ->andReturn('fo=8Fbar'); + + $paramEncoder = $this->_getParameterEncoder(); + $paramEncoder->shouldReceive('encodeString') + ->once() + ->with($value, \Mockery::any(), \Mockery::any(), \Mockery::any()) + ->andReturn('fo%8Fbar'); + + $header = $this->_getHeader('X-Foo', $encoder, $paramEncoder); + $header->setValue($value); + $header->setParameters(array('says' => $value)); + $this->assertEquals("X-Foo: =?utf-8?Q?fo=8Fbar?=; says*=utf-8''fo%8Fbar\r\n", + $header->toString() + ); + } + + public function testParamsAreEncodedWithEncodedWordsIfNoParamEncoderSet() + { + $value = 'fo' . pack('C', 0x8F) .'bar'; + + $encoder = $this->_getHeaderEncoder('Q'); + $encoder->shouldReceive('encodeString') + ->once() + ->with($value, \Mockery::any(), \Mockery::any(), \Mockery::any()) + ->andReturn('fo=8Fbar'); + + $header = $this->_getHeader('X-Foo', $encoder, null); + $header->setValue('bar'); + $header->setParameters(array('says' => $value)); + $this->assertEquals("X-Foo: bar; says=\"=?utf-8?Q?fo=8Fbar?=\"\r\n", + $header->toString() + ); + } + + public function testLanguageInformationAppearsInEncodedWords() + { + /* -- RFC 2231, 5. + 5. Language specification in Encoded Words + + RFC 2047 provides support for non-US-ASCII character sets in RFC 822 + message header comments, phrases, and any unstructured text field. + This is done by defining an encoded word construct which can appear + in any of these places. Given that these are fields intended for + display, it is sometimes necessary to associate language information + with encoded words as well as just the character set. This + specification extends the definition of an encoded word to allow the + inclusion of such information. This is simply done by suffixing the + character set specification with an asterisk followed by the language + tag. For example: + + From: =?US-ASCII*EN?Q?Keith_Moore?= + */ + + $value = 'fo' . pack('C', 0x8F) .'bar'; + + $encoder = $this->_getHeaderEncoder('Q'); + $encoder->shouldReceive('encodeString') + ->once() + ->with($value, \Mockery::any(), \Mockery::any(), \Mockery::any()) + ->andReturn('fo=8Fbar'); + + $paramEncoder = $this->_getParameterEncoder(); + $paramEncoder->shouldReceive('encodeString') + ->once() + ->with($value, \Mockery::any(), \Mockery::any(), \Mockery::any()) + ->andReturn('fo%8Fbar'); + + $header = $this->_getHeader('X-Foo', $encoder, $paramEncoder); + $header->setLanguage('en'); + $header->setValue($value); + $header->setParameters(array('says' => $value)); + $this->assertEquals("X-Foo: =?utf-8*en?Q?fo=8Fbar?=; says*=utf-8'en'fo%8Fbar\r\n", + $header->toString() + ); + } + + public function testSetBodyModel() + { + $header = $this->_getHeader('Content-Type', + $this->_getHeaderEncoder('Q', true), $this->_getParameterEncoder(true) + ); + $header->setFieldBodyModel('text/html'); + $this->assertEquals('text/html', $header->getValue()); + } + + public function testGetBodyModel() + { + $header = $this->_getHeader('Content-Type', + $this->_getHeaderEncoder('Q', true), $this->_getParameterEncoder(true) + ); + $header->setValue('text/plain'); + $this->assertEquals('text/plain', $header->getFieldBodyModel()); + } + + public function testSetParameter() + { + $header = $this->_getHeader('Content-Type', + $this->_getHeaderEncoder('Q', true), $this->_getParameterEncoder(true) + ); + $header->setParameters(array('charset'=>'utf-8', 'delsp' => 'yes')); + $header->setParameter('delsp', 'no'); + $this->assertEquals(array('charset'=>'utf-8', 'delsp'=>'no'), + $header->getParameters() + ); + } + + public function testGetParameter() + { + $header = $this->_getHeader('Content-Type', + $this->_getHeaderEncoder('Q', true), $this->_getParameterEncoder(true) + ); + $header->setParameters(array('charset'=>'utf-8', 'delsp' => 'yes')); + $this->assertEquals('utf-8', $header->getParameter('charset')); + } + + // -- Private helper + + private function _getHeader($name, $encoder, $paramEncoder) + { + $header = new Swift_Mime_Headers_ParameterizedHeader($name, $encoder, + $paramEncoder, new Swift_Mime_Grammar() + ); + $header->setCharset($this->_charset); + + return $header; + } + + private function _getHeaderEncoder($type, $stub = false) + { + $encoder = $this->getMockery('Swift_Mime_HeaderEncoder')->shouldIgnoreMissing(); + $encoder->shouldReceive('getName') + ->zeroOrMoreTimes() + ->andReturn($type); + + return $encoder; + } + + private function _getParameterEncoder($stub = false) + { + return $this->getMockery('Swift_Encoder')->shouldIgnoreMissing(); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/Headers/PathHeaderTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/Headers/PathHeaderTest.php new file mode 100755 index 0000000..3172cab --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/Headers/PathHeaderTest.php @@ -0,0 +1,79 @@ +_getHeader('Return-Path'); + $this->assertEquals(Swift_Mime_Header::TYPE_PATH, $header->getFieldType()); + } + + public function testSingleAddressCanBeSetAndFetched() + { + $header = $this->_getHeader('Return-Path'); + $header->setAddress('chris@swiftmailer.org'); + $this->assertEquals('chris@swiftmailer.org', $header->getAddress()); + } + + public function testAddressMustComplyWithRfc2822() + { + try { + $header = $this->_getHeader('Return-Path'); + $header->setAddress('chr is@swiftmailer.org'); + $this->fail('Addresses not valid according to RFC 2822 addr-spec grammar must be rejected.'); + } catch (Exception $e) { + } + } + + public function testValueIsAngleAddrWithValidAddress() + { + /* -- RFC 2822, 3.6.7. + + return = "Return-Path:" path CRLF + + path = ([CFWS] "<" ([CFWS] / addr-spec) ">" [CFWS]) / + obs-path + */ + + $header = $this->_getHeader('Return-Path'); + $header->setAddress('chris@swiftmailer.org'); + $this->assertEquals('', $header->getFieldBody()); + } + + public function testValueIsEmptyAngleBracketsIfEmptyAddressSet() + { + $header = $this->_getHeader('Return-Path'); + $header->setAddress(''); + $this->assertEquals('<>', $header->getFieldBody()); + } + + public function testSetBodyModel() + { + $header = $this->_getHeader('Return-Path'); + $header->setFieldBodyModel('foo@bar.tld'); + $this->assertEquals('foo@bar.tld', $header->getAddress()); + } + + public function testGetBodyModel() + { + $header = $this->_getHeader('Return-Path'); + $header->setAddress('foo@bar.tld'); + $this->assertEquals('foo@bar.tld', $header->getFieldBodyModel()); + } + + public function testToString() + { + $header = $this->_getHeader('Return-Path'); + $header->setAddress('chris@swiftmailer.org'); + $this->assertEquals('Return-Path: ' . "\r\n", + $header->toString() + ); + } + + // -- Private methods + + private function _getHeader($name) + { + return new Swift_Mime_Headers_PathHeader($name, new Swift_Mime_Grammar()); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/Headers/UnstructuredHeaderTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/Headers/UnstructuredHeaderTest.php new file mode 100755 index 0000000..e94249a --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/Headers/UnstructuredHeaderTest.php @@ -0,0 +1,358 @@ +_getHeader('Subject', $this->_getEncoder('Q', true)); + $this->assertEquals(Swift_Mime_Header::TYPE_TEXT, $header->getFieldType()); + } + + public function testGetNameReturnsNameVerbatim() + { + $header = $this->_getHeader('Subject', $this->_getEncoder('Q', true)); + $this->assertEquals('Subject', $header->getFieldName()); + } + + public function testGetValueReturnsValueVerbatim() + { + $header = $this->_getHeader('Subject', $this->_getEncoder('Q', true)); + $header->setValue('Test'); + $this->assertEquals('Test', $header->getValue()); + } + + public function testBasicStructureIsKeyValuePair() + { + /* -- RFC 2822, 2.2 + Header fields are lines composed of a field name, followed by a colon + (":"), followed by a field body, and terminated by CRLF. + */ + $header = $this->_getHeader('Subject', $this->_getEncoder('Q', true)); + $header->setValue('Test'); + $this->assertEquals('Subject: Test' . "\r\n", $header->toString()); + } + + public function testLongHeadersAreFoldedAtWordBoundary() + { + /* -- RFC 2822, 2.2.3 + Each header field is logically a single line of characters comprising + the field name, the colon, and the field body. For convenience + however, and to deal with the 998/78 character limitations per line, + the field body portion of a header field can be split into a multiple + line representation; this is called "folding". The general rule is + that wherever this standard allows for folding white space (not + simply WSP characters), a CRLF may be inserted before any WSP. + */ + + $value = 'The quick brown fox jumped over the fence, he was a very very ' . + 'scary brown fox with a bushy tail'; + $header = $this->_getHeader('X-Custom-Header', + $this->_getEncoder('Q', true) + ); + $header->setValue($value); + $header->setMaxLineLength(78); //A safe [RFC 2822, 2.2.3] default + /* + X-Custom-Header: The quick brown fox jumped over the fence, he was a very very + scary brown fox with a bushy tail + */ + $this->assertEquals( + 'X-Custom-Header: The quick brown fox jumped over the fence, he was a' . + ' very very' . "\r\n" . //Folding + ' scary brown fox with a bushy tail' . "\r\n", + $header->toString(), '%s: The header should have been folded at 78th char' + ); + } + + public function testPrintableAsciiOnlyAppearsInHeaders() + { + /* -- RFC 2822, 2.2. + A field name MUST be composed of printable US-ASCII characters (i.e., + characters that have values between 33 and 126, inclusive), except + colon. A field body may be composed of any US-ASCII characters, + except for CR and LF. + */ + + $nonAsciiChar = pack('C', 0x8F); + $header = $this->_getHeader('X-Test', $this->_getEncoder('Q', true)); + $header->setValue($nonAsciiChar); + $this->assertRegExp( + '~^[^:\x00-\x20\x80-\xFF]+: [^\x80-\xFF\r\n]+\r\n$~s', + $header->toString() + ); + } + + public function testEncodedWordsFollowGeneralStructure() + { + /* -- RFC 2047, 1. + Generally, an "encoded-word" is a sequence of printable ASCII + characters that begins with "=?", ends with "?=", and has two "?"s in + between. + */ + + $nonAsciiChar = pack('C', 0x8F); + $header = $this->_getHeader('X-Test', $this->_getEncoder('Q', true)); + $header->setValue($nonAsciiChar); + $this->assertRegExp( + '~^X-Test: \=?.*?\?.*?\?.*?\?=\r\n$~s', + $header->toString() + ); + } + + public function testEncodedWordIncludesCharsetAndEncodingMethodAndText() + { + /* -- RFC 2047, 2. + An 'encoded-word' is defined by the following ABNF grammar. The + notation of RFC 822 is used, with the exception that white space + characters MUST NOT appear between components of an 'encoded-word'. + + encoded-word = "=?" charset "?" encoding "?" encoded-text "?=" + */ + + $nonAsciiChar = pack('C', 0x8F); + + $encoder = $this->_getEncoder('Q'); + $encoder->shouldReceive('encodeString') + ->once() + ->with($nonAsciiChar, \Mockery::any(), \Mockery::any(), \Mockery::any()) + ->andReturn('=8F'); + + $header = $this->_getHeader('X-Test', $encoder); + $header->setValue($nonAsciiChar); + $this->assertEquals( + 'X-Test: =?' . $this->_charset . '?Q?=8F?=' . "\r\n", + $header->toString() + ); + } + + public function testEncodedWordsAreUsedToEncodedNonPrintableAscii() + { + //SPACE and TAB permitted + $nonPrintableBytes = array_merge( + range(0x00, 0x08), range(0x10, 0x19), array(0x7F) + ); + + foreach ($nonPrintableBytes as $byte) { + $char = pack('C', $byte); + $encodedChar = sprintf('=%02X', $byte); + + $encoder = $this->_getEncoder('Q'); + $encoder->shouldReceive('encodeString') + ->once() + ->with($char, \Mockery::any(), \Mockery::any(), \Mockery::any()) + ->andReturn($encodedChar); + + $header = $this->_getHeader('X-A', $encoder); + $header->setValue($char); + + $this->assertEquals( + 'X-A: =?' . $this->_charset . '?Q?' . $encodedChar . '?=' . "\r\n", + $header->toString(), '%s: Non-printable ascii should be encoded' + ); + } + } + + public function testEncodedWordsAreUsedToEncode8BitOctets() + { + $_8BitBytes = range(0x80, 0xFF); + + foreach ($_8BitBytes as $byte) { + $char = pack('C', $byte); + $encodedChar = sprintf('=%02X', $byte); + + $encoder = $this->_getEncoder('Q'); + $encoder->shouldReceive('encodeString') + ->once() + ->with($char, \Mockery::any(), \Mockery::any(), \Mockery::any()) + ->andReturn($encodedChar); + + $header = $this->_getHeader('X-A', $encoder); + $header->setValue($char); + + $this->assertEquals( + 'X-A: =?' . $this->_charset . '?Q?' . $encodedChar . '?=' . "\r\n", + $header->toString(), '%s: 8-bit octets should be encoded' + ); + } + } + + public function testEncodedWordsAreNoMoreThan75CharsPerLine() + { + /* -- RFC 2047, 2. + An 'encoded-word' may not be more than 75 characters long, including + 'charset', 'encoding', 'encoded-text', and delimiters. + + ... SNIP ... + + While there is no limit to the length of a multiple-line header + field, each line of a header field that contains one or more + 'encoded-word's is limited to 76 characters. + */ + + $nonAsciiChar = pack('C', 0x8F); + + $encoder = $this->_getEncoder('Q'); + $encoder->shouldReceive('encodeString') + ->once() + ->with($nonAsciiChar, \Mockery::any(), \Mockery::any(), \Mockery::any()) + ->andReturn('=8F'); + //Note that multi-line headers begin with LWSP which makes 75 + 1 = 76 + //Note also that =?utf-8?q??= is 12 chars which makes 75 - 12 = 63 + + //* X-Test: is 8 chars + $header = $this->_getHeader('X-Test', $encoder); + $header->setValue($nonAsciiChar); + + $this->assertEquals( + 'X-Test: =?' . $this->_charset . '?Q?=8F?=' . "\r\n", + $header->toString() + ); + } + + public function testFWSPIsUsedWhenEncoderReturnsMultipleLines() + { + /* --RFC 2047, 2. + If it is desirable to encode more text than will fit in an 'encoded-word' of + 75 characters, multiple 'encoded-word's (separated by CRLF SPACE) may + be used. + */ + + //Note the Mock does NOT return 8F encoded, the 8F merely triggers + // encoding for the sake of testing + $nonAsciiChar = pack('C', 0x8F); + + $encoder = $this->_getEncoder('Q'); + $encoder->shouldReceive('encodeString') + ->once() + ->with($nonAsciiChar, 8, 63, \Mockery::any()) + ->andReturn('line_one_here' . "\r\n" . 'line_two_here'); + + //Note that multi-line headers begin with LWSP which makes 75 + 1 = 76 + //Note also that =?utf-8?q??= is 12 chars which makes 75 - 12 = 63 + + //* X-Test: is 8 chars + $header = $this->_getHeader('X-Test', $encoder); + $header->setValue($nonAsciiChar); + + $this->assertEquals( + 'X-Test: =?' . $this->_charset . '?Q?line_one_here?=' . "\r\n" . + ' =?' . $this->_charset . '?Q?line_two_here?=' . "\r\n", + $header->toString() + ); + } + + public function testAdjacentWordsAreEncodedTogether() + { + /* -- RFC 2047, 5 (1) + Ordinary ASCII text and 'encoded-word's may appear together in the + same header field. However, an 'encoded-word' that appears in a + header field defined as '*text' MUST be separated from any adjacent + 'encoded-word' or 'text' by 'linear-white-space'. + + -- RFC 2047, 2. + IMPORTANT: 'encoded-word's are designed to be recognized as 'atom's + by an RFC 822 parser. As a consequence, unencoded white space + characters (such as SPACE and HTAB) are FORBIDDEN within an + 'encoded-word'. + */ + + //It would be valid to encode all words needed, however it's probably + // easiest to encode the longest amount required at a time + + $word = 'w' . pack('C', 0x8F) . 'rd'; + $text = 'start ' . $word . ' ' . $word . ' then end ' . $word; + // 'start', ' word word', ' and end', ' word' + + $encoder = $this->_getEncoder('Q'); + $encoder->shouldReceive('encodeString') + ->once() + ->with($word . ' ' . $word, \Mockery::any(), \Mockery::any(), \Mockery::any()) + ->andReturn('w=8Frd_w=8Frd'); + $encoder->shouldReceive('encodeString') + ->once() + ->with($word, \Mockery::any(), \Mockery::any(), \Mockery::any()) + ->andReturn('w=8Frd'); + + $header = $this->_getHeader('X-Test', $encoder); + $header->setValue($text); + + $headerString = $header->toString(); + + $this->assertEquals('X-Test: start =?' . $this->_charset . '?Q?' . + 'w=8Frd_w=8Frd?= then end =?' . $this->_charset . '?Q?'. + 'w=8Frd?=' . "\r\n", $headerString, + '%s: Adjacent encoded words should appear grouped with WSP encoded' + ); + } + + public function testLanguageInformationAppearsInEncodedWords() + { + /* -- RFC 2231, 5. + 5. Language specification in Encoded Words + + RFC 2047 provides support for non-US-ASCII character sets in RFC 822 + message header comments, phrases, and any unstructured text field. + This is done by defining an encoded word construct which can appear + in any of these places. Given that these are fields intended for + display, it is sometimes necessary to associate language information + with encoded words as well as just the character set. This + specification extends the definition of an encoded word to allow the + inclusion of such information. This is simply done by suffixing the + character set specification with an asterisk followed by the language + tag. For example: + + From: =?US-ASCII*EN?Q?Keith_Moore?= + */ + + $value = 'fo' . pack('C', 0x8F) . 'bar'; + + $encoder = $this->_getEncoder('Q'); + $encoder->shouldReceive('encodeString') + ->once() + ->with($value, \Mockery::any(), \Mockery::any(), \Mockery::any()) + ->andReturn('fo=8Fbar'); + + $header = $this->_getHeader('Subject', $encoder); + $header->setLanguage('en'); + $header->setValue($value); + $this->assertEquals("Subject: =?utf-8*en?Q?fo=8Fbar?=\r\n", + $header->toString() + ); + } + + public function testSetBodyModel() + { + $header = $this->_getHeader('Subject', $this->_getEncoder('Q', true)); + $header->setFieldBodyModel('test'); + $this->assertEquals('test', $header->getValue()); + } + + public function testGetBodyModel() + { + $header = $this->_getHeader('Subject', $this->_getEncoder('Q', true)); + $header->setValue('test'); + $this->assertEquals('test', $header->getFieldBodyModel()); + } + + // -- Private methods + + private function _getHeader($name, $encoder) + { + $header = new Swift_Mime_Headers_UnstructuredHeader($name, $encoder, new Swift_Mime_Grammar()); + $header->setCharset($this->_charset); + + return $header; + } + + private function _getEncoder($type, $stub = false) + { + $encoder = $this->getMockery('Swift_Mime_HeaderEncoder')->shouldIgnoreMissing(); + $encoder->shouldReceive('getName') + ->zeroOrMoreTimes() + ->andReturn($type); + + return $encoder; + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/MimePartTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/MimePartTest.php new file mode 100755 index 0000000..679790f --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/MimePartTest.php @@ -0,0 +1,233 @@ +_createMimePart($this->_createHeaderSet(), + $this->_createEncoder(), $this->_createCache() + ); + $this->assertEquals( + Swift_Mime_MimeEntity::LEVEL_ALTERNATIVE, $part->getNestingLevel() + ); + } + + public function testCharsetIsReturnedFromHeader() + { + /* -- RFC 2046, 4.1.2. + A critical parameter that may be specified in the Content-Type field + for "text/plain" data is the character set. This is specified with a + "charset" parameter, as in: + + Content-type: text/plain; charset=iso-8859-1 + + Unlike some other parameter values, the values of the charset + parameter are NOT case sensitive. The default character set, which + must be assumed in the absence of a charset parameter, is US-ASCII. + */ + + $cType = $this->_createHeader('Content-Type', 'text/plain', + array('charset' => 'iso-8859-1') + ); + $part = $this->_createMimePart($this->_createHeaderSet(array( + 'Content-Type' => $cType)), + $this->_createEncoder(), $this->_createCache() + ); + $this->assertEquals('iso-8859-1', $part->getCharset()); + } + + public function testCharsetIsSetInHeader() + { + $cType = $this->_createHeader('Content-Type', 'text/plain', + array('charset' => 'iso-8859-1'), false + ); + $cType->shouldReceive('setParameter')->once()->with('charset', 'utf-8'); + + $part = $this->_createMimePart($this->_createHeaderSet(array( + 'Content-Type' => $cType)), + $this->_createEncoder(), $this->_createCache() + ); + $part->setCharset('utf-8'); + } + + public function testCharsetIsSetInHeaderIfPassedToSetBody() + { + $cType = $this->_createHeader('Content-Type', 'text/plain', + array('charset' => 'iso-8859-1'), false + ); + $cType->shouldReceive('setParameter')->once()->with('charset', 'utf-8'); + + $part = $this->_createMimePart($this->_createHeaderSet(array( + 'Content-Type' => $cType)), + $this->_createEncoder(), $this->_createCache() + ); + $part->setBody('', 'text/plian', 'utf-8'); + } + + public function testSettingCharsetNotifiesEncoder() + { + $encoder = $this->_createEncoder('quoted-printable', false); + $encoder->expects($this->once()) + ->method('charsetChanged') + ->with('utf-8'); + + $part = $this->_createMimePart($this->_createHeaderSet(), + $encoder, $this->_createCache() + ); + $part->setCharset('utf-8'); + } + + public function testSettingCharsetNotifiesHeaders() + { + $headers = $this->_createHeaderSet(array(), false); + $headers->shouldReceive('charsetChanged') + ->zeroOrMoreTimes() + ->with('utf-8'); + + $part = $this->_createMimePart($headers, $this->_createEncoder(), + $this->_createCache() + ); + $part->setCharset('utf-8'); + } + + public function testSettingCharsetNotifiesChildren() + { + $child = $this->_createChild(0, '', false); + $child->shouldReceive('charsetChanged') + ->once() + ->with('windows-874'); + + $part = $this->_createMimePart($this->_createHeaderSet(), + $this->_createEncoder(), $this->_createCache() + ); + $part->setChildren(array($child)); + $part->setCharset('windows-874'); + } + + public function testCharsetChangeUpdatesCharset() + { + $cType = $this->_createHeader('Content-Type', 'text/plain', + array('charset' => 'iso-8859-1'), false + ); + $cType->shouldReceive('setParameter')->once()->with('charset', 'utf-8'); + + $part = $this->_createMimePart($this->_createHeaderSet(array( + 'Content-Type' => $cType)), + $this->_createEncoder(), $this->_createCache() + ); + $part->charsetChanged('utf-8'); + } + + public function testSettingCharsetClearsCache() + { + $headers = $this->_createHeaderSet(array(), false); + $headers->shouldReceive('toString') + ->zeroOrMoreTimes() + ->andReturn("Content-Type: text/plain; charset=utf-8\r\n"); + + $cache = $this->_createCache(false); + + $entity = $this->_createEntity($headers, $this->_createEncoder(), + $cache + ); + + $entity->setBody("blah\r\nblah!"); + $entity->toString(); + + // Initialize the expectation here because we only care about what happens in setCharset() + $cache->shouldReceive('clearKey') + ->once() + ->with(\Mockery::any(), 'body'); + + $entity->setCharset('iso-2022'); + } + + public function testFormatIsReturnedFromHeader() + { + /* -- RFC 3676. + */ + + $cType = $this->_createHeader('Content-Type', 'text/plain', + array('format' => 'flowed') + ); + $part = $this->_createMimePart($this->_createHeaderSet(array( + 'Content-Type' => $cType)), + $this->_createEncoder(), $this->_createCache() + ); + $this->assertEquals('flowed', $part->getFormat()); + } + + public function testFormatIsSetInHeader() + { + $cType = $this->_createHeader('Content-Type', 'text/plain', array(), false); + $cType->shouldReceive('setParameter')->once()->with('format', 'fixed'); + + $part = $this->_createMimePart($this->_createHeaderSet(array( + 'Content-Type' => $cType)), + $this->_createEncoder(), $this->_createCache() + ); + $part->setFormat('fixed'); + } + + public function testDelSpIsReturnedFromHeader() + { + /* -- RFC 3676. + */ + + $cType = $this->_createHeader('Content-Type', 'text/plain', + array('delsp' => 'no') + ); + $part = $this->_createMimePart($this->_createHeaderSet(array( + 'Content-Type' => $cType)), + $this->_createEncoder(), $this->_createCache() + ); + $this->assertSame(false, $part->getDelSp()); + } + + public function testDelSpIsSetInHeader() + { + $cType = $this->_createHeader('Content-Type', 'text/plain', array(), false); + $cType->shouldReceive('setParameter')->once()->with('delsp', 'yes'); + + $part = $this->_createMimePart($this->_createHeaderSet(array( + 'Content-Type' => $cType)), + $this->_createEncoder(), $this->_createCache() + ); + $part->setDelSp(true); + } + + public function testFluidInterface() + { + $part = $this->_createMimePart($this->_createHeaderSet(), + $this->_createEncoder(), $this->_createCache() + ); + + $this->assertSame($part, + $part + ->setContentType('text/plain') + ->setEncoder($this->_createEncoder()) + ->setId('foo@bar') + ->setDescription('my description') + ->setMaxLineLength(998) + ->setBody('xx') + ->setBoundary('xyz') + ->setChildren(array()) + ->setCharset('utf-8') + ->setFormat('flowed') + ->setDelSp(true) + ); + } + + // -- Private helpers + + //abstract + protected function _createEntity($headers, $encoder, $cache) + { + return $this->_createMimePart($headers, $encoder, $cache); + } + + protected function _createMimePart($headers, $encoder, $cache) + { + return new Swift_Mime_MimePart($headers, $encoder, $cache, new Swift_Mime_Grammar()); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/SimpleHeaderFactoryTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/SimpleHeaderFactoryTest.php new file mode 100755 index 0000000..19f91d9 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/SimpleHeaderFactoryTest.php @@ -0,0 +1,168 @@ +_factory = $this->_createFactory(); + } + + public function testMailboxHeaderIsCorrectType() + { + $header = $this->_factory->createMailboxHeader('X-Foo'); + $this->assertInstanceof('Swift_Mime_Headers_MailboxHeader', $header); + } + + public function testMailboxHeaderHasCorrectName() + { + $header = $this->_factory->createMailboxHeader('X-Foo'); + $this->assertEquals('X-Foo', $header->getFieldName()); + } + + public function testMailboxHeaderHasCorrectModel() + { + $header = $this->_factory->createMailboxHeader('X-Foo', + array('foo@bar'=>'FooBar') + ); + $this->assertEquals(array('foo@bar'=>'FooBar'), $header->getFieldBodyModel()); + } + + public function testDateHeaderHasCorrectType() + { + $header = $this->_factory->createDateHeader('X-Date'); + $this->assertInstanceof('Swift_Mime_Headers_DateHeader', $header); + } + + public function testDateHeaderHasCorrectName() + { + $header = $this->_factory->createDateHeader('X-Date'); + $this->assertEquals('X-Date', $header->getFieldName()); + } + + public function testDateHeaderHasCorrectModel() + { + $header = $this->_factory->createDateHeader('X-Date', 123); + $this->assertEquals(123, $header->getFieldBodyModel()); + } + + public function testTextHeaderHasCorrectType() + { + $header = $this->_factory->createTextHeader('X-Foo'); + $this->assertInstanceof('Swift_Mime_Headers_UnstructuredHeader', $header); + } + + public function testTextHeaderHasCorrectName() + { + $header = $this->_factory->createTextHeader('X-Foo'); + $this->assertEquals('X-Foo', $header->getFieldName()); + } + + public function testTextHeaderHasCorrectModel() + { + $header = $this->_factory->createTextHeader('X-Foo', 'bar'); + $this->assertEquals('bar', $header->getFieldBodyModel()); + } + + public function testParameterizedHeaderHasCorrectType() + { + $header = $this->_factory->createParameterizedHeader('X-Foo'); + $this->assertInstanceof('Swift_Mime_Headers_ParameterizedHeader', $header); + } + + public function testParameterizedHeaderHasCorrectName() + { + $header = $this->_factory->createParameterizedHeader('X-Foo'); + $this->assertEquals('X-Foo', $header->getFieldName()); + } + + public function testParameterizedHeaderHasCorrectModel() + { + $header = $this->_factory->createParameterizedHeader('X-Foo', 'bar'); + $this->assertEquals('bar', $header->getFieldBodyModel()); + } + + public function testParameterizedHeaderHasCorrectParams() + { + $header = $this->_factory->createParameterizedHeader('X-Foo', 'bar', + array('zip' => 'button') + ); + $this->assertEquals(array('zip'=>'button'), $header->getParameters()); + } + + public function testIdHeaderHasCorrectType() + { + $header = $this->_factory->createIdHeader('X-ID'); + $this->assertInstanceof('Swift_Mime_Headers_IdentificationHeader', $header); + } + + public function testIdHeaderHasCorrectName() + { + $header = $this->_factory->createIdHeader('X-ID'); + $this->assertEquals('X-ID', $header->getFieldName()); + } + + public function testIdHeaderHasCorrectModel() + { + $header = $this->_factory->createIdHeader('X-ID', 'xyz@abc'); + $this->assertEquals(array('xyz@abc'), $header->getFieldBodyModel()); + } + + public function testPathHeaderHasCorrectType() + { + $header = $this->_factory->createPathHeader('X-Path'); + $this->assertInstanceof('Swift_Mime_Headers_PathHeader', $header); + } + + public function testPathHeaderHasCorrectName() + { + $header = $this->_factory->createPathHeader('X-Path'); + $this->assertEquals('X-Path', $header->getFieldName()); + } + + public function testPathHeaderHasCorrectModel() + { + $header = $this->_factory->createPathHeader('X-Path', 'foo@bar'); + $this->assertEquals('foo@bar', $header->getFieldBodyModel()); + } + + public function testCharsetChangeNotificationNotifiesEncoders() + { + $encoder = $this->_createHeaderEncoder(); + $encoder->expects($this->once()) + ->method('charsetChanged') + ->with('utf-8'); + $paramEncoder = $this->_createParamEncoder(); + $paramEncoder->expects($this->once()) + ->method('charsetChanged') + ->with('utf-8'); + + $factory = $this->_createFactory($encoder, $paramEncoder); + + $factory->charsetChanged('utf-8'); + } + + // -- Creation methods + + private function _createFactory($encoder = null, $paramEncoder = null) + { + return new Swift_Mime_SimpleHeaderFactory( + $encoder + ? $encoder : $this->_createHeaderEncoder(), + $paramEncoder + ? $paramEncoder : $this->_createParamEncoder(), + new Swift_Mime_Grammar() + ); + } + + private function _createHeaderEncoder() + { + return $this->getMock('Swift_Mime_HeaderEncoder'); + } + + private function _createParamEncoder() + { + return $this->getMock('Swift_Encoder'); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/SimpleHeaderSetTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/SimpleHeaderSetTest.php new file mode 100755 index 0000000..f1fd8d5 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/SimpleHeaderSetTest.php @@ -0,0 +1,734 @@ +_createFactory(); + $factory->expects($this->once()) + ->method('createMailboxHeader') + ->with('From', array('person@domain'=>'Person')) + ->will($this->returnValue($this->_createHeader('From'))); + + $set = $this->_createSet($factory); + $set->addMailboxHeader('From', array('person@domain'=>'Person')); + } + + public function testAddDateHeaderDelegatesToFactory() + { + $factory = $this->_createFactory(); + $factory->expects($this->once()) + ->method('createDateHeader') + ->with('Date', 1234) + ->will($this->returnValue($this->_createHeader('Date'))); + + $set = $this->_createSet($factory); + $set->addDateHeader('Date', 1234); + } + + public function testAddTextHeaderDelegatesToFactory() + { + $factory = $this->_createFactory(); + $factory->expects($this->once()) + ->method('createTextHeader') + ->with('Subject', 'some text') + ->will($this->returnValue($this->_createHeader('Subject'))); + + $set = $this->_createSet($factory); + $set->addTextHeader('Subject', 'some text'); + } + + public function testAddParameterizedHeaderDelegatesToFactory() + { + $factory = $this->_createFactory(); + $factory->expects($this->once()) + ->method('createParameterizedHeader') + ->with('Content-Type', 'text/plain', array('charset'=>'utf-8')) + ->will($this->returnValue($this->_createHeader('Content-Type'))); + + $set = $this->_createSet($factory); + $set->addParameterizedHeader('Content-Type', 'text/plain', + array('charset'=>'utf-8') + ); + } + + public function testAddIdHeaderDelegatesToFactory() + { + $factory = $this->_createFactory(); + $factory->expects($this->once()) + ->method('createIdHeader') + ->with('Message-ID', 'some@id') + ->will($this->returnValue($this->_createHeader('Message-ID'))); + + $set = $this->_createSet($factory); + $set->addIdHeader('Message-ID', 'some@id'); + } + + public function testAddPathHeaderDelegatesToFactory() + { + $factory = $this->_createFactory(); + $factory->expects($this->once()) + ->method('createPathHeader') + ->with('Return-Path', 'some@path') + ->will($this->returnValue($this->_createHeader('Return-Path'))); + + $set = $this->_createSet($factory); + $set->addPathHeader('Return-Path', 'some@path'); + } + + public function testHasReturnsFalseWhenNoHeaders() + { + $set = $this->_createSet($this->_createFactory()); + $this->assertFalse($set->has('Some-Header')); + } + + public function testAddedMailboxHeaderIsSeenByHas() + { + $factory = $this->_createFactory(); + $factory->expects($this->once()) + ->method('createMailboxHeader') + ->with('From', array('person@domain'=>'Person')) + ->will($this->returnValue($this->_createHeader('From'))); + + $set = $this->_createSet($factory); + $set->addMailboxHeader('From', array('person@domain'=>'Person')); + $this->assertTrue($set->has('From')); + } + + public function testAddedDateHeaderIsSeenByHas() + { + $factory = $this->_createFactory(); + $factory->expects($this->once()) + ->method('createDateHeader') + ->with('Date', 1234) + ->will($this->returnValue($this->_createHeader('Date'))); + + $set = $this->_createSet($factory); + $set->addDateHeader('Date', 1234); + $this->assertTrue($set->has('Date')); + } + + public function testAddedTextHeaderIsSeenByHas() + { + $factory = $this->_createFactory(); + $factory->expects($this->once()) + ->method('createTextHeader') + ->with('Subject', 'some text') + ->will($this->returnValue($this->_createHeader('Subject'))); + + $set = $this->_createSet($factory); + $set->addTextHeader('Subject', 'some text'); + $this->assertTrue($set->has('Subject')); + } + + public function testAddedParameterizedHeaderIsSeenByHas() + { + $factory = $this->_createFactory(); + $factory->expects($this->once()) + ->method('createParameterizedHeader') + ->with('Content-Type', 'text/plain', array('charset'=>'utf-8')) + ->will($this->returnValue($this->_createHeader('Content-Type'))); + + $set = $this->_createSet($factory); + $set->addParameterizedHeader('Content-Type', 'text/plain', + array('charset'=>'utf-8') + ); + $this->assertTrue($set->has('Content-Type')); + } + + public function testAddedIdHeaderIsSeenByHas() + { + $factory = $this->_createFactory(); + $factory->expects($this->once()) + ->method('createIdHeader') + ->with('Message-ID', 'some@id') + ->will($this->returnValue($this->_createHeader('Message-ID'))); + + $set = $this->_createSet($factory); + $set->addIdHeader('Message-ID', 'some@id'); + $this->assertTrue($set->has('Message-ID')); + } + + public function testAddedPathHeaderIsSeenByHas() + { + $factory = $this->_createFactory(); + $factory->expects($this->once()) + ->method('createPathHeader') + ->with('Return-Path', 'some@path') + ->will($this->returnValue($this->_createHeader('Return-Path'))); + + $set = $this->_createSet($factory); + $set->addPathHeader('Return-Path', 'some@path'); + $this->assertTrue($set->has('Return-Path')); + } + + public function testNewlySetHeaderIsSeenByHas() + { + $factory = $this->_createFactory(); + $header = $this->_createHeader('X-Foo', 'bar'); + $set = $this->_createSet($factory); + $set->set($header); + $this->assertTrue($set->has('X-Foo')); + } + + public function testHasCanAcceptOffset() + { + $factory = $this->_createFactory(); + $factory->expects($this->once()) + ->method('createIdHeader') + ->with('Message-ID', 'some@id') + ->will($this->returnValue($this->_createHeader('Message-ID'))); + + $set = $this->_createSet($factory); + $set->addIdHeader('Message-ID', 'some@id'); + $this->assertTrue($set->has('Message-ID', 0)); + } + + public function testHasWithIllegalOffsetReturnsFalse() + { + $factory = $this->_createFactory(); + $factory->expects($this->once()) + ->method('createIdHeader') + ->with('Message-ID', 'some@id') + ->will($this->returnValue($this->_createHeader('Message-ID'))); + + $set = $this->_createSet($factory); + $set->addIdHeader('Message-ID', 'some@id'); + $this->assertFalse($set->has('Message-ID', 1)); + } + + public function testHasCanDistinguishMultipleHeaders() + { + $factory = $this->_createFactory(); + $factory->expects($this->at(0)) + ->method('createIdHeader') + ->with('Message-ID', 'some@id') + ->will($this->returnValue($this->_createHeader('Message-ID'))); + $factory->expects($this->at(1)) + ->method('createIdHeader') + ->with('Message-ID', 'other@id') + ->will($this->returnValue($this->_createHeader('Message-ID'))); + + $set = $this->_createSet($factory); + $set->addIdHeader('Message-ID', 'some@id'); + $set->addIdHeader('Message-ID', 'other@id'); + $this->assertTrue($set->has('Message-ID', 1)); + } + + public function testGetWithUnspecifiedOffset() + { + $header = $this->_createHeader('Message-ID'); + $factory = $this->_createFactory(); + $factory->expects($this->once()) + ->method('createIdHeader') + ->with('Message-ID', 'some@id') + ->will($this->returnValue($header)); + + $set = $this->_createSet($factory); + $set->addIdHeader('Message-ID', 'some@id'); + $this->assertSame($header, $set->get('Message-ID')); + } + + public function testGetWithSpeiciedOffset() + { + $header0 = $this->_createHeader('Message-ID'); + $header1 = $this->_createHeader('Message-ID'); + $header2 = $this->_createHeader('Message-ID'); + $factory = $this->_createFactory(); + $factory->expects($this->at(0)) + ->method('createIdHeader') + ->with('Message-ID', 'some@id') + ->will($this->returnValue($header0)); + $factory->expects($this->at(1)) + ->method('createIdHeader') + ->with('Message-ID', 'other@id') + ->will($this->returnValue($header1)); + $factory->expects($this->at(2)) + ->method('createIdHeader') + ->with('Message-ID', 'more@id') + ->will($this->returnValue($header2)); + + $set = $this->_createSet($factory); + $set->addIdHeader('Message-ID', 'some@id'); + $set->addIdHeader('Message-ID', 'other@id'); + $set->addIdHeader('Message-ID', 'more@id'); + $this->assertSame($header1, $set->get('Message-ID', 1)); + } + + public function testGetReturnsNullIfHeaderNotSet() + { + $set = $this->_createSet($this->_createFactory()); + $this->assertNull($set->get('Message-ID', 99)); + } + + public function testGetAllReturnsAllHeadersMatchingName() + { + $header0 = $this->_createHeader('Message-ID'); + $header1 = $this->_createHeader('Message-ID'); + $header2 = $this->_createHeader('Message-ID'); + $factory = $this->_createFactory(); + $factory->expects($this->at(0)) + ->method('createIdHeader') + ->with('Message-ID', 'some@id') + ->will($this->returnValue($header0)); + $factory->expects($this->at(1)) + ->method('createIdHeader') + ->with('Message-ID', 'other@id') + ->will($this->returnValue($header1)); + $factory->expects($this->at(2)) + ->method('createIdHeader') + ->with('Message-ID', 'more@id') + ->will($this->returnValue($header2)); + + $set = $this->_createSet($factory); + $set->addIdHeader('Message-ID', 'some@id'); + $set->addIdHeader('Message-ID', 'other@id'); + $set->addIdHeader('Message-ID', 'more@id'); + + $this->assertEquals(array($header0, $header1, $header2), + $set->getAll('Message-ID') + ); + } + + public function testGetAllReturnsAllHeadersIfNoArguments() + { + $header0 = $this->_createHeader('Message-ID'); + $header1 = $this->_createHeader('Subject'); + $header2 = $this->_createHeader('To'); + $factory = $this->_createFactory(); + $factory->expects($this->at(0)) + ->method('createIdHeader') + ->with('Message-ID', 'some@id') + ->will($this->returnValue($header0)); + $factory->expects($this->at(1)) + ->method('createIdHeader') + ->with('Subject', 'thing') + ->will($this->returnValue($header1)); + $factory->expects($this->at(2)) + ->method('createIdHeader') + ->with('To', 'person@example.org') + ->will($this->returnValue($header2)); + + $set = $this->_createSet($factory); + $set->addIdHeader('Message-ID', 'some@id'); + $set->addIdHeader('Subject', 'thing'); + $set->addIdHeader('To', 'person@example.org'); + + $this->assertEquals(array($header0, $header1, $header2), + $set->getAll() + ); + } + + public function testGetAllReturnsEmptyArrayIfNoneSet() + { + $set = $this->_createSet($this->_createFactory()); + $this->assertEquals(array(), $set->getAll('Received')); + } + + public function testRemoveWithUnspecifiedOffset() + { + $header = $this->_createHeader('Message-ID'); + $factory = $this->_createFactory(); + $factory->expects($this->at(0)) + ->method('createIdHeader') + ->with('Message-ID', 'some@id') + ->will($this->returnValue($header)); + + $set = $this->_createSet($factory); + $set->addIdHeader('Message-ID', 'some@id'); + $set->remove('Message-ID'); + $this->assertFalse($set->has('Message-ID')); + } + + public function testRemoveWithSpecifiedIndexRemovesHeader() + { + $header0 = $this->_createHeader('Message-ID'); + $header1 = $this->_createHeader('Message-ID'); + $factory = $this->_createFactory(); + $factory->expects($this->at(0)) + ->method('createIdHeader') + ->with('Message-ID', 'some@id') + ->will($this->returnValue($header0)); + $factory->expects($this->at(1)) + ->method('createIdHeader') + ->with('Message-ID', 'other@id') + ->will($this->returnValue($header1)); + + $set = $this->_createSet($factory); + $set->addIdHeader('Message-ID', 'some@id'); + $set->addIdHeader('Message-ID', 'other@id'); + $set->remove('Message-ID', 1); + $this->assertFalse($set->has('Message-ID', 1)); + } + + public function testRemoveWithSpecifiedIndexLeavesOtherHeaders() + { + $header0 = $this->_createHeader('Message-ID'); + $header1 = $this->_createHeader('Message-ID'); + $factory = $this->_createFactory(); + $factory->expects($this->at(0)) + ->method('createIdHeader') + ->with('Message-ID', 'some@id') + ->will($this->returnValue($header0)); + $factory->expects($this->at(1)) + ->method('createIdHeader') + ->with('Message-ID', 'other@id') + ->will($this->returnValue($header1)); + + $set = $this->_createSet($factory); + $set->addIdHeader('Message-ID', 'some@id'); + $set->addIdHeader('Message-ID', 'other@id'); + $set->remove('Message-ID', 1); + $this->assertTrue($set->has('Message-ID', 0)); + } + + public function testRemoveWithInvalidOffsetDoesNothing() + { + $header = $this->_createHeader('Message-ID'); + $factory = $this->_createFactory(); + $factory->expects($this->at(0)) + ->method('createIdHeader') + ->with('Message-ID', 'some@id') + ->will($this->returnValue($header)); + + $set = $this->_createSet($factory); + $set->addIdHeader('Message-ID', 'some@id'); + $set->remove('Message-ID', 50); + $this->assertTrue($set->has('Message-ID')); + } + + public function testRemoveAllRemovesAllHeadersWithName() + { + $header0 = $this->_createHeader('Message-ID'); + $header1 = $this->_createHeader('Message-ID'); + $factory = $this->_createFactory(); + $factory->expects($this->at(0)) + ->method('createIdHeader') + ->with('Message-ID', 'some@id') + ->will($this->returnValue($header0)); + $factory->expects($this->at(1)) + ->method('createIdHeader') + ->with('Message-ID', 'other@id') + ->will($this->returnValue($header1)); + + $set = $this->_createSet($factory); + $set->addIdHeader('Message-ID', 'some@id'); + $set->addIdHeader('Message-ID', 'other@id'); + $set->removeAll('Message-ID'); + $this->assertFalse($set->has('Message-ID', 0)); + $this->assertFalse($set->has('Message-ID', 1)); + } + + public function testHasIsNotCaseSensitive() + { + $header = $this->_createHeader('Message-ID'); + $factory = $this->_createFactory(); + $factory->expects($this->at(0)) + ->method('createIdHeader') + ->with('Message-ID', 'some@id') + ->will($this->returnValue($header)); + + $set = $this->_createSet($factory); + $set->addIdHeader('Message-ID', 'some@id'); + $this->assertTrue($set->has('message-id')); + } + + public function testGetIsNotCaseSensitive() + { + $header = $this->_createHeader('Message-ID'); + $factory = $this->_createFactory(); + $factory->expects($this->at(0)) + ->method('createIdHeader') + ->with('Message-ID', 'some@id') + ->will($this->returnValue($header)); + + $set = $this->_createSet($factory); + $set->addIdHeader('Message-ID', 'some@id'); + $this->assertSame($header, $set->get('message-id')); + } + + public function testGetAllIsNotCaseSensitive() + { + $header = $this->_createHeader('Message-ID'); + $factory = $this->_createFactory(); + $factory->expects($this->at(0)) + ->method('createIdHeader') + ->with('Message-ID', 'some@id') + ->will($this->returnValue($header)); + + $set = $this->_createSet($factory); + $set->addIdHeader('Message-ID', 'some@id'); + $this->assertEquals(array($header), $set->getAll('message-id')); + } + + public function testRemoveIsNotCaseSensitive() + { + $header = $this->_createHeader('Message-ID'); + $factory = $this->_createFactory(); + $factory->expects($this->at(0)) + ->method('createIdHeader') + ->with('Message-ID', 'some@id') + ->will($this->returnValue($header)); + + $set = $this->_createSet($factory); + $set->addIdHeader('Message-ID', 'some@id'); + $set->remove('message-id'); + $this->assertFalse($set->has('Message-ID')); + } + + public function testRemoveAllIsNotCaseSensitive() + { + $header = $this->_createHeader('Message-ID'); + $factory = $this->_createFactory(); + $factory->expects($this->at(0)) + ->method('createIdHeader') + ->with('Message-ID', 'some@id') + ->will($this->returnValue($header)); + + $set = $this->_createSet($factory); + $set->addIdHeader('Message-ID', 'some@id'); + $set->removeAll('message-id'); + $this->assertFalse($set->has('Message-ID')); + } + + public function testNewInstance() + { + $set = $this->_createSet($this->_createFactory()); + $instance = $set->newInstance(); + $this->assertInstanceof('Swift_Mime_HeaderSet', $instance); + } + + public function testToStringJoinsHeadersTogether() + { + $factory = $this->_createFactory(); + $factory->expects($this->at(0)) + ->method('createTextHeader') + ->with('Foo', 'bar') + ->will($this->returnValue($this->_createHeader('Foo', 'bar'))); + $factory->expects($this->at(1)) + ->method('createTextHeader') + ->with('Zip', 'buttons') + ->will($this->returnValue($this->_createHeader('Zip', 'buttons'))); + + $set = $this->_createSet($factory); + $set->addTextHeader('Foo', 'bar'); + $set->addTextHeader('Zip', 'buttons'); + $this->assertEquals( + "Foo: bar\r\n" . + "Zip: buttons\r\n", + $set->toString() + ); + } + + public function testHeadersWithoutBodiesAreNotDisplayed() + { + $factory = $this->_createFactory(); + $factory->expects($this->at(0)) + ->method('createTextHeader') + ->with('Foo', 'bar') + ->will($this->returnValue($this->_createHeader('Foo', 'bar'))); + $factory->expects($this->at(1)) + ->method('createTextHeader') + ->with('Zip', '') + ->will($this->returnValue($this->_createHeader('Zip', ''))); + + $set = $this->_createSet($factory); + $set->addTextHeader('Foo', 'bar'); + $set->addTextHeader('Zip', ''); + $this->assertEquals( + "Foo: bar\r\n", + $set->toString() + ); + } + + public function testHeadersWithoutBodiesCanBeForcedToDisplay() + { + $factory = $this->_createFactory(); + $factory->expects($this->at(0)) + ->method('createTextHeader') + ->with('Foo', '') + ->will($this->returnValue($this->_createHeader('Foo', ''))); + $factory->expects($this->at(1)) + ->method('createTextHeader') + ->with('Zip', '') + ->will($this->returnValue($this->_createHeader('Zip', ''))); + + $set = $this->_createSet($factory); + $set->addTextHeader('Foo', ''); + $set->addTextHeader('Zip', ''); + $set->setAlwaysDisplayed(array('Foo', 'Zip')); + $this->assertEquals( + "Foo: \r\n" . + "Zip: \r\n", + $set->toString() + ); + } + + public function testHeaderSequencesCanBeSpecified() + { + $factory = $this->_createFactory(); + $factory->expects($this->at(0)) + ->method('createTextHeader') + ->with('Third', 'three') + ->will($this->returnValue($this->_createHeader('Third', 'three'))); + $factory->expects($this->at(1)) + ->method('createTextHeader') + ->with('First', 'one') + ->will($this->returnValue($this->_createHeader('First', 'one'))); + $factory->expects($this->at(2)) + ->method('createTextHeader') + ->with('Second', 'two') + ->will($this->returnValue($this->_createHeader('Second', 'two'))); + + $set = $this->_createSet($factory); + $set->addTextHeader('Third', 'three'); + $set->addTextHeader('First', 'one'); + $set->addTextHeader('Second', 'two'); + + $set->defineOrdering(array('First', 'Second', 'Third')); + + $this->assertEquals( + "First: one\r\n" . + "Second: two\r\n" . + "Third: three\r\n", + $set->toString() + ); + } + + public function testUnsortedHeadersAppearAtEnd() + { + $factory = $this->_createFactory(); + $factory->expects($this->at(0)) + ->method('createTextHeader') + ->with('Fourth', 'four') + ->will($this->returnValue($this->_createHeader('Fourth', 'four'))); + $factory->expects($this->at(1)) + ->method('createTextHeader') + ->with('Fifth', 'five') + ->will($this->returnValue($this->_createHeader('Fifth', 'five'))); + $factory->expects($this->at(2)) + ->method('createTextHeader') + ->with('Third', 'three') + ->will($this->returnValue($this->_createHeader('Third', 'three'))); + $factory->expects($this->at(3)) + ->method('createTextHeader') + ->with('First', 'one') + ->will($this->returnValue($this->_createHeader('First', 'one'))); + $factory->expects($this->at(4)) + ->method('createTextHeader') + ->with('Second', 'two') + ->will($this->returnValue($this->_createHeader('Second', 'two'))); + + $set = $this->_createSet($factory); + $set->addTextHeader('Fourth', 'four'); + $set->addTextHeader('Fifth', 'five'); + $set->addTextHeader('Third', 'three'); + $set->addTextHeader('First', 'one'); + $set->addTextHeader('Second', 'two'); + + $set->defineOrdering(array('First', 'Second', 'Third')); + + $this->assertEquals( + "First: one\r\n" . + "Second: two\r\n" . + "Third: three\r\n" . + "Fourth: four\r\n" . + "Fifth: five\r\n", + $set->toString() + ); + } + + public function testSettingCharsetNotifiesAlreadyExistingHeaders() + { + $subject = $this->_createHeader('Subject', 'some text'); + $xHeader = $this->_createHeader('X-Header', 'some text'); + $factory = $this->_createFactory(); + $factory->expects($this->at(0)) + ->method('createTextHeader') + ->with('Subject', 'some text') + ->will($this->returnValue($subject)); + $factory->expects($this->at(1)) + ->method('createTextHeader') + ->with('X-Header', 'some text') + ->will($this->returnValue($xHeader)); + $subject->expects($this->once()) + ->method('setCharset') + ->with('utf-8'); + $xHeader->expects($this->once()) + ->method('setCharset') + ->with('utf-8'); + + $set = $this->_createSet($factory); + $set->addTextHeader('Subject', 'some text'); + $set->addTextHeader('X-Header', 'some text'); + + $set->setCharset('utf-8'); + } + + public function testCharsetChangeNotifiesAlreadyExistingHeaders() + { + $subject = $this->_createHeader('Subject', 'some text'); + $xHeader = $this->_createHeader('X-Header', 'some text'); + $factory = $this->_createFactory(); + $factory->expects($this->at(0)) + ->method('createTextHeader') + ->with('Subject', 'some text') + ->will($this->returnValue($subject)); + $factory->expects($this->at(1)) + ->method('createTextHeader') + ->with('X-Header', 'some text') + ->will($this->returnValue($xHeader)); + $subject->expects($this->once()) + ->method('setCharset') + ->with('utf-8'); + $xHeader->expects($this->once()) + ->method('setCharset') + ->with('utf-8'); + + $set = $this->_createSet($factory); + $set->addTextHeader('Subject', 'some text'); + $set->addTextHeader('X-Header', 'some text'); + + $set->charsetChanged('utf-8'); + } + + public function testCharsetChangeNotifiesFactory() + { + $factory = $this->_createFactory(); + $factory->expects($this->once()) + ->method('charsetChanged') + ->with('utf-8'); + + $set = $this->_createSet($factory); + + $set->setCharset('utf-8'); + } + + // -- Creation methods + + private function _createSet($factory) + { + return new Swift_Mime_SimpleHeaderSet($factory); + } + + private function _createFactory() + { + return $this->getMock('Swift_Mime_HeaderFactory'); + } + + private function _createHeader($name, $body = '') + { + $header = $this->getMock('Swift_Mime_Header'); + $header->expects($this->any()) + ->method('getFieldName') + ->will($this->returnValue($name)); + $header->expects($this->any()) + ->method('toString') + ->will($this->returnValue(sprintf("%s: %s\r\n", $name, $body))); + $header->expects($this->any()) + ->method('getFieldBody') + ->will($this->returnValue($body)); + + return $header; + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/SimpleMessageTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/SimpleMessageTest.php new file mode 100755 index 0000000..2b03941 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/SimpleMessageTest.php @@ -0,0 +1,828 @@ +_createMessage($this->_createHeaderSet(), + $this->_createEncoder(), $this->_createCache() + ); + $this->assertEquals( + Swift_Mime_MimeEntity::LEVEL_TOP, $message->getNestingLevel() + ); + } + + public function testDateIsReturnedFromHeader() + { + $date = $this->_createHeader('Date', 123); + $message = $this->_createMessage( + $this->_createHeaderSet(array('Date' => $date)), + $this->_createEncoder(), $this->_createCache() + ); + $this->assertEquals(123, $message->getDate()); + } + + public function testDateIsSetInHeader() + { + $date = $this->_createHeader('Date', 123, array(), false); + $date->shouldReceive('setFieldBodyModel') + ->once() + ->with(1234); + $date->shouldReceive('setFieldBodyModel') + ->zeroOrMoreTimes(); + + $message = $this->_createMessage( + $this->_createHeaderSet(array('Date' => $date)), + $this->_createEncoder(), $this->_createCache() + ); + $message->setDate(1234); + } + + public function testDateHeaderIsCreatedIfNonePresent() + { + $headers = $this->_createHeaderSet(array(), false); + $headers->shouldReceive('addDateHeader') + ->once() + ->with('Date', 1234); + $headers->shouldReceive('addDateHeader') + ->zeroOrMoreTimes(); + + $message = $this->_createMessage($headers, $this->_createEncoder(), + $this->_createCache() + ); + $message->setDate(1234); + } + + public function testDateHeaderIsAddedDuringConstruction() + { + $headers = $this->_createHeaderSet(array(), false); + $headers->shouldReceive('addDateHeader') + ->once() + ->with('Date', '/^[0-9]+$/D'); + + $message = $this->_createMessage($headers, $this->_createEncoder(), + $this->_createCache() + ); + } + + public function testIdIsReturnedFromHeader() + { + /* -- RFC 2045, 7. + In constructing a high-level user agent, it may be desirable to allow + one body to make reference to another. Accordingly, bodies may be + labelled using the "Content-ID" header field, which is syntactically + identical to the "Message-ID" header field + */ + + $messageId = $this->_createHeader('Message-ID', 'a@b'); + $message = $this->_createMessage( + $this->_createHeaderSet(array('Message-ID' => $messageId)), + $this->_createEncoder(), $this->_createCache() + ); + $this->assertEquals('a@b', $message->getId()); + } + + public function testIdIsSetInHeader() + { + $messageId = $this->_createHeader('Message-ID', 'a@b', array(), false); + $messageId->shouldReceive('setFieldBodyModel') + ->once() + ->with('x@y'); + $messageId->shouldReceive('setFieldBodyModel') + ->zeroOrMoreTimes(); + + $message = $this->_createMessage( + $this->_createHeaderSet(array('Message-ID' => $messageId)), + $this->_createEncoder(), $this->_createCache() + ); + $message->setId('x@y'); + } + + public function testIdIsAutoGenerated() + { + $headers = $this->_createHeaderSet(array(), false); + $headers->shouldReceive('addIdHeader') + ->once() + ->with('Message-ID', '/^.*?@.*?$/D'); + + $message = $this->_createMessage($headers, $this->_createEncoder(), + $this->_createCache() + ); + } + + public function testSubjectIsReturnedFromHeader() + { + /* -- RFC 2822, 3.6.5. + */ + + $subject = $this->_createHeader('Subject', 'example subject'); + $message = $this->_createMessage( + $this->_createHeaderSet(array('Subject' => $subject)), + $this->_createEncoder(), $this->_createCache() + ); + $this->assertEquals('example subject', $message->getSubject()); + } + + public function testSubjectIsSetInHeader() + { + $subject = $this->_createHeader('Subject', '', array(), false); + $subject->shouldReceive('setFieldBodyModel') + ->once() + ->with('foo'); + + $message = $this->_createMessage( + $this->_createHeaderSet(array('Subject' => $subject)), + $this->_createEncoder(), $this->_createCache() + ); + $message->setSubject('foo'); + } + + public function testSubjectHeaderIsCreatedIfNotPresent() + { + $headers = $this->_createHeaderSet(array(), false); + $headers->shouldReceive('addTextHeader') + ->once() + ->with('Subject', 'example subject'); + $headers->shouldReceive('addTextHeader') + ->zeroOrMoreTimes(); + + $message = $this->_createMessage($headers, $this->_createEncoder(), + $this->_createCache() + ); + $message->setSubject('example subject'); + } + + public function testReturnPathIsReturnedFromHeader() + { + /* -- RFC 2822, 3.6.7. + */ + + $path = $this->_createHeader('Return-Path', 'bounces@domain'); + $message = $this->_createMessage( + $this->_createHeaderSet(array('Return-Path' => $path)), + $this->_createEncoder(), $this->_createCache() + ); + $this->assertEquals('bounces@domain', $message->getReturnPath()); + } + + public function testReturnPathIsSetInHeader() + { + $path = $this->_createHeader('Return-Path', '', array(), false); + $path->shouldReceive('setFieldBodyModel') + ->once() + ->with('bounces@domain'); + + $message = $this->_createMessage( + $this->_createHeaderSet(array('Return-Path' => $path)), + $this->_createEncoder(), $this->_createCache() + ); + $message->setReturnPath('bounces@domain'); + } + + public function testReturnPathHeaderIsAddedIfNoneSet() + { + $headers = $this->_createHeaderSet(array(), false); + $headers->shouldReceive('addPathHeader') + ->once() + ->with('Return-Path', 'bounces@domain'); + + $message = $this->_createMessage($headers, $this->_createEncoder(), + $this->_createCache() + ); + $message->setReturnPath('bounces@domain'); + } + + public function testSenderIsReturnedFromHeader() + { + /* -- RFC 2822, 3.6.2. + */ + + $sender = $this->_createHeader('Sender', array('sender@domain'=>'Name')); + $message = $this->_createMessage( + $this->_createHeaderSet(array('Sender' => $sender)), + $this->_createEncoder(), $this->_createCache() + ); + $this->assertEquals(array('sender@domain'=>'Name'), $message->getSender()); + } + + public function testSenderIsSetInHeader() + { + $sender = $this->_createHeader('Sender', array('sender@domain'=>'Name'), + array(), false + ); + $sender->shouldReceive('setFieldBodyModel') + ->once() + ->with(array('other@domain'=>'Other')); + + $message = $this->_createMessage( + $this->_createHeaderSet(array('Sender' => $sender)), + $this->_createEncoder(), $this->_createCache() + ); + $message->setSender(array('other@domain'=>'Other')); + } + + public function testSenderHeaderIsAddedIfNoneSet() + { + $headers = $this->_createHeaderSet(array(), false); + $headers->shouldReceive('addMailboxHeader') + ->once() + ->with('Sender', (array) 'sender@domain'); + $headers->shouldReceive('addMailboxHeader') + ->zeroOrMoreTimes(); + + $message = $this->_createMessage($headers, $this->_createEncoder(), + $this->_createCache() + ); + $message->setSender('sender@domain'); + } + + public function testNameCanBeUsedInSenderHeader() + { + $headers = $this->_createHeaderSet(array(), false); + $headers->shouldReceive('addMailboxHeader') + ->once() + ->with('Sender', array('sender@domain'=>'Name')); + $headers->shouldReceive('addMailboxHeader') + ->zeroOrMoreTimes(); + + $message = $this->_createMessage($headers, $this->_createEncoder(), + $this->_createCache() + ); + $message->setSender('sender@domain', 'Name'); + } + + public function testFromIsReturnedFromHeader() + { + /* -- RFC 2822, 3.6.2. + */ + + $from = $this->_createHeader('From', array('from@domain'=>'Name')); + $message = $this->_createMessage( + $this->_createHeaderSet(array('From' => $from)), + $this->_createEncoder(), $this->_createCache() + ); + $this->assertEquals(array('from@domain'=>'Name'), $message->getFrom()); + } + + public function testFromIsSetInHeader() + { + $from = $this->_createHeader('From', array('from@domain'=>'Name'), + array(), false + ); + $from->shouldReceive('setFieldBodyModel') + ->once() + ->with(array('other@domain'=>'Other')); + + $message = $this->_createMessage( + $this->_createHeaderSet(array('From' => $from)), + $this->_createEncoder(), $this->_createCache() + ); + $message->setFrom(array('other@domain'=>'Other')); + } + + public function testFromIsAddedToHeadersDuringAddFrom() + { + $from = $this->_createHeader('From', array('from@domain'=>'Name'), + array(), false + ); + $from->shouldReceive('setFieldBodyModel') + ->once() + ->with(array('from@domain'=>'Name', 'other@domain'=>'Other')); + + $message = $this->_createMessage( + $this->_createHeaderSet(array('From' => $from)), + $this->_createEncoder(), $this->_createCache() + ); + $message->addFrom('other@domain', 'Other'); + } + + public function testFromHeaderIsAddedIfNoneSet() + { + $headers = $this->_createHeaderSet(array(), false); + $headers->shouldReceive('addMailboxHeader') + ->once() + ->with('From', (array) 'from@domain'); + $headers->shouldReceive('addMailboxHeader') + ->zeroOrMoreTimes(); + + $message = $this->_createMessage($headers, $this->_createEncoder(), + $this->_createCache() + ); + $message->setFrom('from@domain'); + } + + public function testPersonalNameCanBeUsedInFromAddress() + { + $headers = $this->_createHeaderSet(array(), false); + $headers->shouldReceive('addMailboxHeader') + ->once() + ->with('From', array('from@domain'=>'Name')); + $headers->shouldReceive('addMailboxHeader') + ->zeroOrMoreTimes(); + + $message = $this->_createMessage($headers, $this->_createEncoder(), + $this->_createCache() + ); + $message->setFrom('from@domain', 'Name'); + } + + public function testReplyToIsReturnedFromHeader() + { + /* -- RFC 2822, 3.6.2. + */ + + $reply = $this->_createHeader('Reply-To', array('reply@domain'=>'Name')); + $message = $this->_createMessage( + $this->_createHeaderSet(array('Reply-To' => $reply)), + $this->_createEncoder(), $this->_createCache() + ); + $this->assertEquals(array('reply@domain'=>'Name'), $message->getReplyTo()); + } + + public function testReplyToIsSetInHeader() + { + $reply = $this->_createHeader('Reply-To', array('reply@domain'=>'Name'), + array(), false + ); + $reply->shouldReceive('setFieldBodyModel') + ->once() + ->with(array('other@domain'=>'Other')); + + $message = $this->_createMessage( + $this->_createHeaderSet(array('Reply-To' => $reply)), + $this->_createEncoder(), $this->_createCache() + ); + $message->setReplyTo(array('other@domain'=>'Other')); + } + + public function testReplyToIsAddedToHeadersDuringAddReplyTo() + { + $replyTo = $this->_createHeader('Reply-To', array('from@domain'=>'Name'), + array(), false + ); + $replyTo->shouldReceive('setFieldBodyModel') + ->once() + ->with(array('from@domain'=>'Name', 'other@domain'=>'Other')); + + $message = $this->_createMessage( + $this->_createHeaderSet(array('Reply-To' => $replyTo)), + $this->_createEncoder(), $this->_createCache() + ); + $message->addReplyTo('other@domain', 'Other'); + } + + public function testReplyToHeaderIsAddedIfNoneSet() + { + $headers = $this->_createHeaderSet(array(), false); + $headers->shouldReceive('addMailboxHeader') + ->once() + ->with('Reply-To', (array) 'reply@domain'); + $headers->shouldReceive('addMailboxHeader') + ->zeroOrMoreTimes(); + + $message = $this->_createMessage($headers, $this->_createEncoder(), + $this->_createCache() + ); + $message->setReplyTo('reply@domain'); + } + + public function testNameCanBeUsedInReplyTo() + { + $headers = $this->_createHeaderSet(array(), false); + $headers->shouldReceive('addMailboxHeader') + ->once() + ->with('Reply-To', array('reply@domain'=>'Name')); + $headers->shouldReceive('addMailboxHeader') + ->zeroOrMoreTimes(); + + $message = $this->_createMessage($headers, $this->_createEncoder(), + $this->_createCache() + ); + $message->setReplyTo('reply@domain', 'Name'); + } + + public function testToIsReturnedFromHeader() + { + /* -- RFC 2822, 3.6.3. + */ + + $to = $this->_createHeader('To', array('to@domain'=>'Name')); + $message = $this->_createMessage( + $this->_createHeaderSet(array('To' => $to)), + $this->_createEncoder(), $this->_createCache() + ); + $this->assertEquals(array('to@domain'=>'Name'), $message->getTo()); + } + + public function testToIsSetInHeader() + { + $to = $this->_createHeader('To', array('to@domain'=>'Name'), + array(), false + ); + $to->shouldReceive('setFieldBodyModel') + ->once() + ->with(array('other@domain'=>'Other')); + + $message = $this->_createMessage( + $this->_createHeaderSet(array('To' => $to)), + $this->_createEncoder(), $this->_createCache() + ); + $message->setTo(array('other@domain'=>'Other')); + } + + public function testToIsAddedToHeadersDuringAddTo() + { + $to = $this->_createHeader('To', array('from@domain'=>'Name'), + array(), false + ); + $to->shouldReceive('setFieldBodyModel') + ->once() + ->with(array('from@domain'=>'Name', 'other@domain'=>'Other')); + + $message = $this->_createMessage( + $this->_createHeaderSet(array('To' => $to)), + $this->_createEncoder(), $this->_createCache() + ); + $message->addTo('other@domain', 'Other'); + } + + public function testToHeaderIsAddedIfNoneSet() + { + $headers = $this->_createHeaderSet(array(), false); + $headers->shouldReceive('addMailboxHeader') + ->once() + ->with('To', (array) 'to@domain'); + $headers->shouldReceive('addMailboxHeader') + ->zeroOrMoreTimes(); + + $message = $this->_createMessage($headers, $this->_createEncoder(), + $this->_createCache() + ); + $message->setTo('to@domain'); + } + + public function testNameCanBeUsedInToHeader() + { + $headers = $this->_createHeaderSet(array(), false); + $headers->shouldReceive('addMailboxHeader') + ->once() + ->with('To', array('to@domain'=>'Name')); + $headers->shouldReceive('addMailboxHeader') + ->zeroOrMoreTimes(); + + $message = $this->_createMessage($headers, $this->_createEncoder(), + $this->_createCache() + ); + $message->setTo('to@domain', 'Name'); + } + + public function testCcIsReturnedFromHeader() + { + /* -- RFC 2822, 3.6.3. + */ + + $cc = $this->_createHeader('Cc', array('cc@domain'=>'Name')); + $message = $this->_createMessage( + $this->_createHeaderSet(array('Cc' => $cc)), + $this->_createEncoder(), $this->_createCache() + ); + $this->assertEquals(array('cc@domain'=>'Name'), $message->getCc()); + } + + public function testCcIsSetInHeader() + { + $cc = $this->_createHeader('Cc', array('cc@domain'=>'Name'), + array(), false + ); + $cc->shouldReceive('setFieldBodyModel') + ->once() + ->with(array('other@domain'=>'Other')); + + $message = $this->_createMessage( + $this->_createHeaderSet(array('Cc' => $cc)), + $this->_createEncoder(), $this->_createCache() + ); + $message->setCc(array('other@domain'=>'Other')); + } + + public function testCcIsAddedToHeadersDuringAddCc() + { + $cc = $this->_createHeader('Cc', array('from@domain'=>'Name'), + array(), false + ); + $cc->shouldReceive('setFieldBodyModel') + ->once() + ->with(array('from@domain'=>'Name', 'other@domain'=>'Other')); + + $message = $this->_createMessage( + $this->_createHeaderSet(array('Cc' => $cc)), + $this->_createEncoder(), $this->_createCache() + ); + $message->addCc('other@domain', 'Other'); + } + + public function testCcHeaderIsAddedIfNoneSet() + { + $headers = $this->_createHeaderSet(array(), false); + $headers->shouldReceive('addMailboxHeader') + ->once() + ->with('Cc', (array) 'cc@domain'); + $headers->shouldReceive('addMailboxHeader') + ->zeroOrMoreTimes(); + + $message = $this->_createMessage($headers, $this->_createEncoder(), + $this->_createCache() + ); + $message->setCc('cc@domain'); + } + + public function testNameCanBeUsedInCcHeader() + { + $headers = $this->_createHeaderSet(array(), false); + $headers->shouldReceive('addMailboxHeader') + ->once() + ->with('Cc', array('cc@domain'=>'Name')); + $headers->shouldReceive('addMailboxHeader') + ->zeroOrMoreTimes(); + + $message = $this->_createMessage($headers, $this->_createEncoder(), + $this->_createCache() + ); + $message->setCc('cc@domain', 'Name'); + } + + public function testBccIsReturnedFromHeader() + { + /* -- RFC 2822, 3.6.3. + */ + + $bcc = $this->_createHeader('Bcc', array('bcc@domain'=>'Name')); + $message = $this->_createMessage( + $this->_createHeaderSet(array('Bcc' => $bcc)), + $this->_createEncoder(), $this->_createCache() + ); + $this->assertEquals(array('bcc@domain'=>'Name'), $message->getBcc()); + } + + public function testBccIsSetInHeader() + { + $bcc = $this->_createHeader('Bcc', array('bcc@domain'=>'Name'), + array(), false + ); + $bcc->shouldReceive('setFieldBodyModel') + ->once() + ->with(array('other@domain'=>'Other')); + + $message = $this->_createMessage( + $this->_createHeaderSet(array('Bcc' => $bcc)), + $this->_createEncoder(), $this->_createCache() + ); + $message->setBcc(array('other@domain'=>'Other')); + } + + public function testBccIsAddedToHeadersDuringAddBcc() + { + $bcc = $this->_createHeader('Bcc', array('from@domain'=>'Name'), + array(), false + ); + $bcc->shouldReceive('setFieldBodyModel') + ->once() + ->with(array('from@domain'=>'Name', 'other@domain'=>'Other')); + + $message = $this->_createMessage( + $this->_createHeaderSet(array('Bcc' => $bcc)), + $this->_createEncoder(), $this->_createCache() + ); + $message->addBcc('other@domain', 'Other'); + } + + public function testBccHeaderIsAddedIfNoneSet() + { + $headers = $this->_createHeaderSet(array(), false); + $headers->shouldReceive('addMailboxHeader') + ->once() + ->with('Bcc', (array) 'bcc@domain'); + $headers->shouldReceive('addMailboxHeader') + ->zeroOrMoreTimes(); + + $message = $this->_createMessage($headers, $this->_createEncoder(), + $this->_createCache() + ); + $message->setBcc('bcc@domain'); + } + + public function testNameCanBeUsedInBcc() + { + $headers = $this->_createHeaderSet(array(), false); + $headers->shouldReceive('addMailboxHeader') + ->once() + ->with('Bcc', array('bcc@domain'=>'Name')); + $headers->shouldReceive('addMailboxHeader') + ->zeroOrMoreTimes(); + + $message = $this->_createMessage($headers, $this->_createEncoder(), + $this->_createCache() + ); + $message->setBcc('bcc@domain', 'Name'); + } + + public function testPriorityIsReadFromHeader() + { + $prio = $this->_createHeader('X-Priority', '2 (High)'); + $message = $this->_createMessage( + $this->_createHeaderSet(array('X-Priority' => $prio)), + $this->_createEncoder(), $this->_createCache() + ); + $this->assertEquals(2, $message->getPriority()); + } + + public function testPriorityIsSetInHeader() + { + $prio = $this->_createHeader('X-Priority', '2 (High)', array(), false); + $prio->shouldReceive('setFieldBodyModel') + ->once() + ->with('5 (Lowest)'); + + $message = $this->_createMessage( + $this->_createHeaderSet(array('X-Priority' => $prio)), + $this->_createEncoder(), $this->_createCache() + ); + $message->setPriority(5); + } + + public function testPriorityHeaderIsAddedIfNoneSet() + { + $headers = $this->_createHeaderSet(array(), false); + $headers->shouldReceive('addTextHeader') + ->once() + ->with('X-Priority', '4 (Low)'); + $headers->shouldReceive('addTextHeader') + ->zeroOrMoreTimes(); + + $message = $this->_createMessage($headers, $this->_createEncoder(), + $this->_createCache() + ); + $message->setPriority(4); + } + + public function testReadReceiptAddressReadFromHeader() + { + $rcpt = $this->_createHeader('Disposition-Notification-To', + array('chris@swiftmailer.org'=>'Chris') + ); + $message = $this->_createMessage( + $this->_createHeaderSet(array('Disposition-Notification-To' => $rcpt)), + $this->_createEncoder(), $this->_createCache() + ); + $this->assertEquals(array('chris@swiftmailer.org'=>'Chris'), + $message->getReadReceiptTo() + ); + } + + public function testReadReceiptIsSetInHeader() + { + $rcpt = $this->_createHeader('Disposition-Notification-To', array(), array(), false); + $rcpt->shouldReceive('setFieldBodyModel') + ->once() + ->with('mark@swiftmailer.org'); + + $message = $this->_createMessage( + $this->_createHeaderSet(array('Disposition-Notification-To' => $rcpt)), + $this->_createEncoder(), $this->_createCache() + ); + $message->setReadReceiptTo('mark@swiftmailer.org'); + } + + public function testReadReceiptHeaderIsAddedIfNoneSet() + { + $headers = $this->_createHeaderSet(array(), false); + $headers->shouldReceive('addMailboxHeader') + ->once() + ->with('Disposition-Notification-To', 'mark@swiftmailer.org'); + $headers->shouldReceive('addMailboxHeader') + ->zeroOrMoreTimes(); + + $message = $this->_createMessage($headers, $this->_createEncoder(), + $this->_createCache() + ); + $message->setReadReceiptTo('mark@swiftmailer.org'); + } + + public function testChildrenCanBeAttached() + { + $child1 = $this->_createChild(); + $child2 = $this->_createChild(); + + $message = $this->_createMessage($this->_createHeaderSet(), + $this->_createEncoder(), $this->_createCache() + ); + + $message->attach($child1); + $message->attach($child2); + + $this->assertEquals(array($child1, $child2), $message->getChildren()); + } + + public function testChildrenCanBeDetached() + { + $child1 = $this->_createChild(); + $child2 = $this->_createChild(); + + $message = $this->_createMessage($this->_createHeaderSet(), + $this->_createEncoder(), $this->_createCache() + ); + + $message->attach($child1); + $message->attach($child2); + + $message->detach($child1); + + $this->assertEquals(array($child2), $message->getChildren()); + } + + public function testEmbedAttachesChild() + { + $child = $this->_createChild(); + + $message = $this->_createMessage($this->_createHeaderSet(), + $this->_createEncoder(), $this->_createCache() + ); + + $message->embed($child); + + $this->assertEquals(array($child), $message->getChildren()); + } + + public function testEmbedReturnsValidCid() + { + $child = $this->_createChild(Swift_Mime_MimeEntity::LEVEL_RELATED, '', + false + ); + $child->shouldReceive('getId') + ->zeroOrMoreTimes() + ->andReturn('foo@bar'); + + $message = $this->_createMessage($this->_createHeaderSet(), + $this->_createEncoder(), $this->_createCache() + ); + + $this->assertEquals('cid:foo@bar', $message->embed($child)); + } + + public function testFluidInterface() + { + $child = $this->_createChild(); + $message = $this->_createMessage($this->_createHeaderSet(), + $this->_createEncoder(), $this->_createCache() + ); + $this->assertSame($message, + $message + ->setContentType('text/plain') + ->setEncoder($this->_createEncoder()) + ->setId('foo@bar') + ->setDescription('my description') + ->setMaxLineLength(998) + ->setBody('xx') + ->setBoundary('xyz') + ->setChildren(array()) + ->setCharset('iso-8859-1') + ->setFormat('flowed') + ->setDelSp(false) + ->setSubject('subj') + ->setDate(123) + ->setReturnPath('foo@bar') + ->setSender('foo@bar') + ->setFrom(array('x@y' => 'XY')) + ->setReplyTo(array('ab@cd' => 'ABCD')) + ->setTo(array('chris@site.tld', 'mark@site.tld')) + ->setCc('john@somewhere.tld') + ->setBcc(array('one@site', 'two@site' => 'Two')) + ->setPriority(4) + ->setReadReceiptTo('a@b') + ->attach($child) + ->detach($child) + ); + } + + // -- Private helpers + + //abstract + protected function _createEntity($headers, $encoder, $cache) + { + return $this->_createMessage($headers, $encoder, $cache); + } + + protected function _createMimePart($headers, $encoder, $cache) + { + return $this->_createMessage($headers, $encoder, $cache); + } + + private function _createMessage($headers, $encoder, $cache) + { + return new Swift_Mime_SimpleMessage($headers, $encoder, $cache, new Swift_Mime_Grammar()); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/SimpleMimeEntityTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/SimpleMimeEntityTest.php new file mode 100755 index 0000000..b54d7f8 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Mime/SimpleMimeEntityTest.php @@ -0,0 +1,11 @@ +assertEquals(10, $plugin->getThreshold()); + $plugin->setThreshold(100); + $this->assertEquals(100, $plugin->getThreshold()); + } + + public function testSleepTimeCanBeSetAndFetched() + { + $plugin = new Swift_Plugins_AntiFloodPlugin(10, 5); + $this->assertEquals(5, $plugin->getSleepTime()); + $plugin->setSleepTime(1); + $this->assertEquals(1, $plugin->getSleepTime()); + } + + public function testPluginStopsConnectionAfterThreshold() + { + $transport = $this->_createTransport(); + $transport->expects($this->once()) + ->method('start'); + $transport->expects($this->once()) + ->method('stop'); + + $evt = $this->_createSendEvent($transport); + + $plugin = new Swift_Plugins_AntiFloodPlugin(10); + for ($i = 0; $i < 12; $i++) { + $plugin->sendPerformed($evt); + } + } + + public function testPluginCanStopAndStartMultipleTimes() + { + $transport = $this->_createTransport(); + $transport->expects($this->exactly(5)) + ->method('start'); + $transport->expects($this->exactly(5)) + ->method('stop'); + + $evt = $this->_createSendEvent($transport); + + $plugin = new Swift_Plugins_AntiFloodPlugin(2); + for ($i = 0; $i < 11; $i++) { + $plugin->sendPerformed($evt); + } + } + + public function testPluginCanSleepDuringRestart() + { + $sleeper = $this->getMock('Swift_Plugins_Sleeper');; + $sleeper->expects($this->once()) + ->method('sleep') + ->with(10); + + $transport = $this->_createTransport(); + $transport->expects($this->once()) + ->method('start'); + $transport->expects($this->once()) + ->method('stop'); + + $evt = $this->_createSendEvent($transport); + + $plugin = new Swift_Plugins_AntiFloodPlugin(99, 10, $sleeper); + for ($i = 0; $i < 101; $i++) { + $plugin->sendPerformed($evt); + } + } + + // -- Creation Methods + + private function _createTransport() + { + return $this->getMock('Swift_Transport'); + } + + private function _createSendEvent($transport) + { + $evt = $this->getMockBuilder('Swift_Events_SendEvent') + ->disableOriginalConstructor() + ->getMock(); + $evt->expects($this->any()) + ->method('getSource') + ->will($this->returnValue($transport)); + $evt->expects($this->any()) + ->method('getTransport') + ->will($this->returnValue($transport)); + + return $evt; + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Plugins/BandwidthMonitorPluginTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Plugins/BandwidthMonitorPluginTest.php new file mode 100755 index 0000000..20ad73e --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Plugins/BandwidthMonitorPluginTest.php @@ -0,0 +1,127 @@ +_monitor = new Swift_Plugins_BandwidthMonitorPlugin(); + } + + public function testBytesOutIncreasesWhenCommandsSent() + { + $evt = $this->_createCommandEvent("RCPT TO: \r\n"); + + $this->assertEquals(0, $this->_monitor->getBytesOut()); + $this->_monitor->commandSent($evt); + $this->assertEquals(24, $this->_monitor->getBytesOut()); + $this->_monitor->commandSent($evt); + $this->assertEquals(48, $this->_monitor->getBytesOut()); + } + + public function testBytesInIncreasesWhenResponsesReceived() + { + $evt = $this->_createResponseEvent("250 Ok\r\n"); + + $this->assertEquals(0, $this->_monitor->getBytesIn()); + $this->_monitor->responseReceived($evt); + $this->assertEquals(8, $this->_monitor->getBytesIn()); + $this->_monitor->responseReceived($evt); + $this->assertEquals(16, $this->_monitor->getBytesIn()); + } + + public function testCountersCanBeReset() + { + $evt = $this->_createResponseEvent("250 Ok\r\n"); + + $this->assertEquals(0, $this->_monitor->getBytesIn()); + $this->_monitor->responseReceived($evt); + $this->assertEquals(8, $this->_monitor->getBytesIn()); + $this->_monitor->responseReceived($evt); + $this->assertEquals(16, $this->_monitor->getBytesIn()); + + $evt = $this->_createCommandEvent("RCPT TO: \r\n"); + + $this->assertEquals(0, $this->_monitor->getBytesOut()); + $this->_monitor->commandSent($evt); + $this->assertEquals(24, $this->_monitor->getBytesOut()); + $this->_monitor->commandSent($evt); + $this->assertEquals(48, $this->_monitor->getBytesOut()); + + $this->_monitor->reset(); + + $this->assertEquals(0, $this->_monitor->getBytesOut()); + $this->assertEquals(0, $this->_monitor->getBytesIn()); + } + + public function testBytesOutIncreasesAccordingToMessageLength() + { + $message = $this->_createMessageWithByteCount(6); + $evt = $this->_createSendEvent($message); + + $this->assertEquals(0, $this->_monitor->getBytesOut()); + $this->_monitor->sendPerformed($evt); + $this->assertEquals(6, $this->_monitor->getBytesOut()); + $this->_monitor->sendPerformed($evt); + $this->assertEquals(12, $this->_monitor->getBytesOut()); + } + + // -- Creation Methods + + private function _createSendEvent($message) + { + $evt = $this->getMockBuilder('Swift_Events_SendEvent') + ->disableOriginalConstructor() + ->getMock(); + $evt->expects($this->any()) + ->method('getMessage') + ->will($this->returnValue($message)); + + return $evt; + } + + private function _createCommandEvent($command) + { + $evt = $this->getMockBuilder('Swift_Events_CommandEvent') + ->disableOriginalConstructor() + ->getMock(); + $evt->expects($this->any()) + ->method('getCommand') + ->will($this->returnValue($command)); + + return $evt; + } + + private function _createResponseEvent($response) + { + $evt = $this->getMockBuilder('Swift_Events_ResponseEvent') + ->disableOriginalConstructor() + ->getMock(); + $evt->expects($this->any()) + ->method('getResponse') + ->will($this->returnValue($response)); + + return $evt; + } + + private function _createMessageWithByteCount($bytes) + { + $this->_bytes = $bytes; + $msg = $this->getMock('Swift_Mime_Message'); + $msg->expects($this->any()) + ->method('toByteStream') + ->will($this->returnCallback(array($this, '_write'))); + /* $this->_checking(Expectations::create() + -> ignoring($msg)->toByteStream(any()) -> calls(array($this, '_write')) + ); */ + + return $msg; + } + + private $_bytes = 0; + public function _write($is) + { + for ($i = 0; $i < $this->_bytes; ++$i) { + $is->write('x'); + } + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Plugins/DecoratorPluginTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Plugins/DecoratorPluginTest.php new file mode 100755 index 0000000..7a7e160 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Plugins/DecoratorPluginTest.php @@ -0,0 +1,269 @@ +_createMessage( + $this->_createHeaders(), + array('zip@button.tld' => 'Zipathon'), + array('chris.corbyn@swiftmailer.org' => 'Chris'), + 'Subject', + 'Hello {name}, you are customer #{id}' + ); + $message->shouldReceive('setBody') + ->once() + ->with('Hello Zip, you are customer #456'); + $message->shouldReceive('setBody') + ->zeroOrMoreTimes(); + + $plugin = $this->_createPlugin( + array('zip@button.tld' => array('{name}' => 'Zip', '{id}' => '456')) + ); + + $evt = $this->_createSendEvent($message); + + $plugin->beforeSendPerformed($evt); + $plugin->sendPerformed($evt); + } + + public function testReplacementsCanBeAppliedToSameMessageMultipleTimes() + { + $message = $this->_createMessage( + $this->_createHeaders(), + array('zip@button.tld' => 'Zipathon', 'foo@bar.tld' => 'Foo'), + array('chris.corbyn@swiftmailer.org' => 'Chris'), + 'Subject', + 'Hello {name}, you are customer #{id}' + ); + $message->shouldReceive('setBody') + ->once() + ->with('Hello Zip, you are customer #456'); + $message->shouldReceive('setBody') + ->once() + ->with('Hello {name}, you are customer #{id}'); + $message->shouldReceive('setBody') + ->once() + ->with('Hello Foo, you are customer #123'); + $message->shouldReceive('setBody') + ->zeroOrMoreTimes(); + + $plugin = $this->_createPlugin( + array( + 'foo@bar.tld' => array('{name}' => 'Foo', '{id}' => '123'), + 'zip@button.tld' => array('{name}' => 'Zip', '{id}' => '456') + ) + ); + + $evt = $this->_createSendEvent($message); + + $plugin->beforeSendPerformed($evt); + $plugin->sendPerformed($evt); + $plugin->beforeSendPerformed($evt); + $plugin->sendPerformed($evt); + } + + public function testReplacementsCanBeMadeInHeaders() + { + $headers = $this->_createHeaders(array( + $returnPathHeader = $this->_createHeader('Return-Path', 'foo-{id}@swiftmailer.org'), + $toHeader = $this->_createHeader('Subject', 'A message for {name}!') + )); + + $message = $this->_createMessage( + $headers, + array('zip@button.tld' => 'Zipathon'), + array('chris.corbyn@swiftmailer.org' => 'Chris'), + 'A message for {name}!', + 'Hello {name}, you are customer #{id}' + ); + + $message->shouldReceive('setBody') + ->once() + ->with('Hello Zip, you are customer #456'); + $toHeader->shouldReceive('setFieldBodyModel') + ->once() + ->with('A message for Zip!'); + $returnPathHeader->shouldReceive('setFieldBodyModel') + ->once() + ->with('foo-456@swiftmailer.org'); + $message->shouldReceive('setBody') + ->zeroOrMoreTimes(); + $toHeader->shouldReceive('setFieldBodyModel') + ->zeroOrMoreTimes(); + $returnPathHeader->shouldReceive('setFieldBodyModel') + ->zeroOrMoreTimes(); + + $plugin = $this->_createPlugin( + array('zip@button.tld' => array('{name}' => 'Zip', '{id}' => '456')) + ); + $evt = $this->_createSendEvent($message); + + $plugin->beforeSendPerformed($evt); + $plugin->sendPerformed($evt); + } + + public function testReplacementsAreMadeOnSubparts() + { + $part1 = $this->_createPart('text/plain', 'Your name is {name}?', '1@x'); + $part2 = $this->_createPart('text/html', 'Your name is {name}?', '2@x'); + $message = $this->_createMessage( + $this->_createHeaders(), + array('zip@button.tld' => 'Zipathon'), + array('chris.corbyn@swiftmailer.org' => 'Chris'), + 'A message for {name}!', + 'Subject' + ); + $message->shouldReceive('getChildren') + ->zeroOrMoreTimes() + ->andReturn(array($part1, $part2)); + $part1->shouldReceive('setBody') + ->once() + ->with('Your name is Zip?'); + $part2->shouldReceive('setBody') + ->once() + ->with('Your name is Zip?'); + $part1->shouldReceive('setBody') + ->zeroOrMoreTimes(); + $part2->shouldReceive('setBody') + ->zeroOrMoreTimes(); + + $plugin = $this->_createPlugin( + array('zip@button.tld' => array('{name}' => 'Zip', '{id}' => '456')) + ); + + $evt = $this->_createSendEvent($message); + + $plugin->beforeSendPerformed($evt); + $plugin->sendPerformed($evt); + } + + public function testReplacementsCanBeTakenFromCustomReplacementsObject() + { + $message = $this->_createMessage( + $this->_createHeaders(), + array('foo@bar' => 'Foobar', 'zip@zap' => 'Zip zap'), + array('chris.corbyn@swiftmailer.org' => 'Chris'), + 'Subject', + 'Something {a}' + ); + + $replacements = $this->_createReplacements(); + + $message->shouldReceive('setBody') + ->once() + ->with('Something b'); + $message->shouldReceive('setBody') + ->once() + ->with('Something c'); + $message->shouldReceive('setBody') + ->zeroOrMoreTimes(); + $replacements->shouldReceive('getReplacementsFor') + ->once() + ->with('foo@bar') + ->andReturn(array('{a}'=>'b')); + $replacements->shouldReceive('getReplacementsFor') + ->once() + ->with('zip@zap') + ->andReturn(array('{a}'=>'c')); + + $plugin = $this->_createPlugin($replacements); + + $evt = $this->_createSendEvent($message); + + $plugin->beforeSendPerformed($evt); + $plugin->sendPerformed($evt); + $plugin->beforeSendPerformed($evt); + $plugin->sendPerformed($evt); + } + + // -- Creation methods + + private function _createMessage($headers, $to = array(), $from = null, $subject = null, + $body = null) + { + $message = $this->getMockery('Swift_Mime_Message')->shouldIgnoreMissing(); + foreach ($to as $addr => $name) { + $message->shouldReceive('getTo') + ->once() + ->andReturn(array($addr => $name)); + } + $message->shouldReceive('getHeaders') + ->zeroOrMoreTimes() + ->andReturn($headers); + $message->shouldReceive('getFrom') + ->zeroOrMoreTimes() + ->andReturn($from); + $message->shouldReceive('getSubject') + ->zeroOrMoreTimes() + ->andReturn($subject); + $message->shouldReceive('getBody') + ->zeroOrMoreTimes() + ->andReturn($body); + + return $message; + } + + private function _createPlugin($replacements) + { + return new Swift_Plugins_DecoratorPlugin($replacements); + } + + private function _createReplacements() + { + return $this->getMockery('Swift_Plugins_Decorator_Replacements')->shouldIgnoreMissing(); + } + + private function _createSendEvent(Swift_Mime_Message $message) + { + $evt = $this->getMockery('Swift_Events_SendEvent')->shouldIgnoreMissing(); + $evt->shouldReceive('getMessage') + ->zeroOrMoreTimes() + ->andReturn($message); + + return $evt; + } + + private function _createPart($type, $body, $id) + { + $part = $this->getMockery('Swift_Mime_MimeEntity')->shouldIgnoreMissing(); + $part->shouldReceive('getContentType') + ->zeroOrMoreTimes() + ->andReturn($type); + $part->shouldReceive('getBody') + ->zeroOrMoreTimes() + ->andReturn($body); + $part->shouldReceive('getId') + ->zeroOrMoreTimes() + ->andReturn($id); + + return $part; + } + + private function _createHeaders($headers = array()) + { + $set = $this->getMockery('Swift_Mime_HeaderSet')->shouldIgnoreMissing(); + $set->shouldReceive('getAll') + ->zeroOrMoreTimes() + ->andReturn($headers); + + foreach ($headers as $header) { + $set->set($header); + } + + return $set; + } + + private function _createHeader($name, $body = '') + { + $header = $this->getMockery('Swift_Mime_Header')->shouldIgnoreMissing(); + $header->shouldReceive('getFieldName') + ->zeroOrMoreTimes() + ->andReturn($name); + $header->shouldReceive('getFieldBodyModel') + ->zeroOrMoreTimes() + ->andReturn($body); + + return $header; + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Plugins/LoggerPluginTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Plugins/LoggerPluginTest.php new file mode 100755 index 0000000..bd1fd97 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Plugins/LoggerPluginTest.php @@ -0,0 +1,190 @@ +_createLogger(); + $logger->expects($this->once()) + ->method('add') + ->with('foo'); + + $plugin = $this->_createPlugin($logger); + $plugin->add('foo'); + } + + public function testLoggerDelegatesDumpingEntries() + { + $logger = $this->_createLogger(); + $logger->expects($this->once()) + ->method('dump') + ->will($this->returnValue('foobar')); + + $plugin = $this->_createPlugin($logger); + $this->assertEquals('foobar', $plugin->dump()); + } + + public function testLoggerDelegatesClearingEntries() + { + $logger = $this->_createLogger(); + $logger->expects($this->once()) + ->method('clear'); + + $plugin = $this->_createPlugin($logger); + $plugin->clear(); + } + + public function testCommandIsSentToLogger() + { + $evt = $this->_createCommandEvent("foo\r\n"); + $logger = $this->_createLogger(); + $logger->expects($this->once()) + ->method('add') + ->with($this->regExp('~foo\r\n~')); + + $plugin = $this->_createPlugin($logger); + $plugin->commandSent($evt); + } + + public function testResponseIsSentToLogger() + { + $evt = $this->_createResponseEvent("354 Go ahead\r\n"); + $logger = $this->_createLogger(); + $logger->expects($this->once()) + ->method('add') + ->with($this->regExp('~354 Go ahead\r\n~')); + + $plugin = $this->_createPlugin($logger); + $plugin->responseReceived($evt); + } + + public function testTransportBeforeStartChangeIsSentToLogger() + { + $evt = $this->_createTransportChangeEvent(); + $logger = $this->_createLogger(); + $logger->expects($this->once()) + ->method('add') + ->with($this->anything()); + + $plugin = $this->_createPlugin($logger); + $plugin->beforeTransportStarted($evt); + } + + public function testTransportStartChangeIsSentToLogger() + { + $evt = $this->_createTransportChangeEvent(); + $logger = $this->_createLogger(); + $logger->expects($this->once()) + ->method('add') + ->with($this->anything()); + + $plugin = $this->_createPlugin($logger); + $plugin->transportStarted($evt); + } + + public function testTransportStopChangeIsSentToLogger() + { + $evt = $this->_createTransportChangeEvent(); + $logger = $this->_createLogger(); + $logger->expects($this->once()) + ->method('add') + ->with($this->anything()); + + $plugin = $this->_createPlugin($logger); + $plugin->transportStopped($evt); + } + + public function testTransportBeforeStopChangeIsSentToLogger() + { + $evt = $this->_createTransportChangeEvent(); + $logger = $this->_createLogger(); + $logger->expects($this->once()) + ->method('add') + ->with($this->anything()); + + $plugin = $this->_createPlugin($logger); + $plugin->beforeTransportStopped($evt); + } + + public function testExceptionsArePassedToDelegateAndLeftToBubbleUp() + { + $transport = $this->_createTransport(); + $evt = $this->_createTransportExceptionEvent(); + $logger = $this->_createLogger(); + $logger->expects($this->once()) + ->method('add') + ->with($this->anything()); + + $plugin = $this->_createPlugin($logger); + try { + $plugin->exceptionThrown($evt); + $this->fail('Exception should bubble up.'); + } catch (Swift_TransportException $ex) { + } + } + + // -- Creation Methods + + private function _createLogger() + { + return $this->getMock('Swift_Plugins_Logger'); + } + + private function _createPlugin($logger) + { + return new Swift_Plugins_LoggerPlugin($logger); + } + + private function _createCommandEvent($command) + { + $evt = $this->getMockBuilder('Swift_Events_CommandEvent') + ->disableOriginalConstructor() + ->getMock(); + $evt->expects($this->any()) + ->method('getCommand') + ->will($this->returnValue($command)); + + return $evt; + } + + private function _createResponseEvent($response) + { + $evt = $this->getMockBuilder('Swift_Events_ResponseEvent') + ->disableOriginalConstructor() + ->getMock(); + $evt->expects($this->any()) + ->method('getResponse') + ->will($this->returnValue($response)); + + return $evt; + } + + private function _createTransport() + { + return $this->getMock('Swift_Transport'); + } + + private function _createTransportChangeEvent() + { + $evt = $this->getMockBuilder('Swift_Events_TransportChangeEvent') + ->disableOriginalConstructor() + ->getMock(); + $evt->expects($this->any()) + ->method('getSource') + ->will($this->returnValue($this->_createTransport())); + + return $evt; + } + + public function _createTransportExceptionEvent() + { + $evt = $this->getMockBuilder('Swift_Events_TransportExceptionEvent') + ->disableOriginalConstructor() + ->getMock(); + $evt->expects($this->any()) + ->method('getException') + ->will($this->returnValue(new Swift_TransportException(''))); + + return $evt; + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Plugins/Loggers/ArrayLoggerTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Plugins/Loggers/ArrayLoggerTest.php new file mode 100755 index 0000000..9487985 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Plugins/Loggers/ArrayLoggerTest.php @@ -0,0 +1,66 @@ +add(">> Foo\r\n"); + $this->assertEquals(">> Foo\r\n", $logger->dump()); + } + + public function testAddingMultipleEntriesDumpsMultipleLines() + { + $logger = new Swift_Plugins_Loggers_ArrayLogger(); + $logger->add(">> FOO\r\n"); + $logger->add("<< 502 That makes no sense\r\n"); + $logger->add(">> RSET\r\n"); + $logger->add("<< 250 OK\r\n"); + + $this->assertEquals( + ">> FOO\r\n" . PHP_EOL . + "<< 502 That makes no sense\r\n" . PHP_EOL . + ">> RSET\r\n" . PHP_EOL . + "<< 250 OK\r\n", + $logger->dump() + ); + } + + public function testLogCanBeCleared() + { + $logger = new Swift_Plugins_Loggers_ArrayLogger(); + $logger->add(">> FOO\r\n"); + $logger->add("<< 502 That makes no sense\r\n"); + $logger->add(">> RSET\r\n"); + $logger->add("<< 250 OK\r\n"); + + $this->assertEquals( + ">> FOO\r\n" . PHP_EOL . + "<< 502 That makes no sense\r\n" . PHP_EOL . + ">> RSET\r\n" . PHP_EOL . + "<< 250 OK\r\n", + $logger->dump() + ); + + $logger->clear(); + + $this->assertEquals('', $logger->dump()); + } + + public function testLengthCanBeTruncated() + { + $logger = new Swift_Plugins_Loggers_ArrayLogger(2); + $logger->add(">> FOO\r\n"); + $logger->add("<< 502 That makes no sense\r\n"); + $logger->add(">> RSET\r\n"); + $logger->add("<< 250 OK\r\n"); + + $this->assertEquals( + ">> RSET\r\n" . PHP_EOL . + "<< 250 OK\r\n", + $logger->dump(), + '%s: Log should be truncated to last 2 entries' + ); + } + +} diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Plugins/Loggers/EchoLoggerTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Plugins/Loggers/EchoLoggerTest.php new file mode 100755 index 0000000..128c71d --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Plugins/Loggers/EchoLoggerTest.php @@ -0,0 +1,25 @@ +add(">> Foo"); + $data = ob_get_clean(); + + $this->assertEquals(">> Foo" . PHP_EOL, $data); + } + + public function testAddingEntryDumpsEscapedLineWithHtml() + { + $logger = new Swift_Plugins_Loggers_EchoLogger(true); + ob_start(); + $logger->add(">> Foo"); + $data = ob_get_clean(); + + $this->assertEquals(">> Foo
    " . PHP_EOL, $data); + } + +} diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Plugins/PopBeforeSmtpPluginTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Plugins/PopBeforeSmtpPluginTest.php new file mode 100755 index 0000000..1227c24 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Plugins/PopBeforeSmtpPluginTest.php @@ -0,0 +1,103 @@ +_createConnection(); + $connection->expects($this->once()) + ->method('connect'); + + $plugin = $this->_createPlugin('pop.host.tld', 110); + $plugin->setConnection($connection); + + $transport = $this->_createTransport(); + $evt = $this->_createTransportChangeEvent($transport); + + $plugin->beforeTransportStarted($evt); + } + + public function testPluginDisconnectsFromPop3HostBeforeTransportStarts() + { + $connection = $this->_createConnection(); + $connection->expects($this->once()) + ->method('disconnect'); + + $plugin = $this->_createPlugin('pop.host.tld', 110); + $plugin->setConnection($connection); + + $transport = $this->_createTransport(); + $evt = $this->_createTransportChangeEvent($transport); + + $plugin->beforeTransportStarted($evt); + } + + public function testPluginDoesNotConnectToSmtpIfBoundToDifferentTransport() + { + $connection = $this->_createConnection(); + $connection->expects($this->never()) + ->method('disconnect'); + $connection->expects($this->never()) + ->method('connect'); + + $smtp = $this->_createTransport(); + + $plugin = $this->_createPlugin('pop.host.tld', 110); + $plugin->setConnection($connection); + $plugin->bindSmtp($smtp); + + $transport = $this->_createTransport(); + $evt = $this->_createTransportChangeEvent($transport); + + $plugin->beforeTransportStarted($evt); + } + + public function testPluginCanBindToSpecificTransport() + { + $connection = $this->_createConnection(); + $connection->expects($this->once()) + ->method('connect'); + + $smtp = $this->_createTransport(); + + $plugin = $this->_createPlugin('pop.host.tld', 110); + $plugin->setConnection($connection); + $plugin->bindSmtp($smtp); + + $evt = $this->_createTransportChangeEvent($smtp); + + $plugin->beforeTransportStarted($evt); + } + + // -- Creation Methods + + private function _createTransport() + { + return $this->getMock('Swift_Transport'); + } + + private function _createTransportChangeEvent($transport) + { + $evt = $this->getMockBuilder('Swift_Events_TransportChangeEvent') + ->disableOriginalConstructor() + ->getMock(); + $evt->expects($this->any()) + ->method('getSource') + ->will($this->returnValue($transport)); + $evt->expects($this->any()) + ->method('getTransport') + ->will($this->returnValue($transport)); + + return $evt; + } + + public function _createConnection() + { + return $this->getMock('Swift_Plugins_Pop_Pop3Connection'); + } + + public function _createPlugin($host, $port, $crypto = null) + { + return new Swift_Plugins_PopBeforeSmtpPlugin($host, $port, $crypto); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Plugins/RedirectingPluginTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Plugins/RedirectingPluginTest.php new file mode 100755 index 0000000..e2ec86c --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Plugins/RedirectingPluginTest.php @@ -0,0 +1,153 @@ +assertEquals('fabien@example.com', $plugin->getRecipient()); + $plugin->setRecipient('chris@example.com'); + $this->assertEquals('chris@example.com', $plugin->getRecipient()); + } + + public function testPluginChangesRecipients() + { + $message = Swift_Message::newInstance() + ->setSubject('...') + ->setFrom(array('john@example.com' => 'John Doe')) + ->setTo($to = array( + 'fabien-to@example.com' => 'Fabien (To)', + 'chris-to@example.com' => 'Chris (To)', + )) + ->setCc($cc = array( + 'fabien-cc@example.com' => 'Fabien (Cc)', + 'chris-cc@example.com' => 'Chris (Cc)', + )) + ->setBcc($bcc = array( + 'fabien-bcc@example.com' => 'Fabien (Bcc)', + 'chris-bcc@example.com' => 'Chris (Bcc)', + )) + ->setBody('...') + ; + + $plugin = new Swift_Plugins_RedirectingPlugin('god@example.com'); + + $evt = $this->_createSendEvent($message); + + $plugin->beforeSendPerformed($evt); + + $this->assertEquals($message->getTo(), array('god@example.com' => '')); + $this->assertEquals($message->getCc(), array()); + $this->assertEquals($message->getBcc(), array()); + + $plugin->sendPerformed($evt); + + $this->assertEquals($message->getTo(), $to); + $this->assertEquals($message->getCc(), $cc); + $this->assertEquals($message->getBcc(), $bcc); + } + + public function testPluginRespectsAWhitelistOfPatterns() + { + $message = Swift_Message::newInstance() + ->setSubject('...') + ->setFrom(array('john@example.com' => 'John Doe')) + ->setTo($to = array( + 'fabien-to@example.com' => 'Fabien (To)', + 'chris-to@example.com' => 'Chris (To)', + 'lars-to@internal.com' => 'Lars (To)', + )) + ->setCc($cc = array( + 'fabien-cc@example.com' => 'Fabien (Cc)', + 'chris-cc@example.com' => 'Chris (Cc)', + 'lars-cc@internal.org' => 'Lars (Cc)', + )) + ->setBcc($bcc = array( + 'fabien-bcc@example.com' => 'Fabien (Bcc)', + 'chris-bcc@example.com' => 'Chris (Bcc)', + 'john-bcc@example.org' => 'John (Bcc)', + )) + ->setBody('...') + ; + + $recipient = 'god@example.com'; + $patterns = array('/^.*@internal.[a-z]+$/', '/^john-.*$/'); + + $plugin = new Swift_Plugins_RedirectingPlugin($recipient, $patterns); + + $this->assertEquals($recipient, $plugin->getRecipient()); + $this->assertEquals($plugin->getWhitelist(), $patterns); + + $evt = $this->_createSendEvent($message); + + $plugin->beforeSendPerformed($evt); + + $this->assertEquals($message->getTo(), array('lars-to@internal.com' => 'Lars (To)', 'god@example.com' => null)); + $this->assertEquals($message->getCc(), array('lars-cc@internal.org' => 'Lars (Cc)')); + $this->assertEquals($message->getBcc(), array('john-bcc@example.org' => 'John (Bcc)')); + + $plugin->sendPerformed($evt); + + $this->assertEquals($message->getTo(), $to); + $this->assertEquals($message->getCc(), $cc); + $this->assertEquals($message->getBcc(), $bcc); + } + + public function testArrayOfRecipientsCanBeExplicitlyDefined() + { + $message = Swift_Message::newInstance() + ->setSubject('...') + ->setFrom(array('john@example.com' => 'John Doe')) + ->setTo(array( + 'fabien@example.com' => 'Fabien', + 'chris@example.com' => 'Chris (To)', + 'lars-to@internal.com' => 'Lars (To)', + )) + ->setCc(array( + 'fabien@example.com' => 'Fabien', + 'chris-cc@example.com' => 'Chris (Cc)', + 'lars-cc@internal.org' => 'Lars (Cc)', + )) + ->setBcc(array( + 'fabien@example.com' => 'Fabien', + 'chris-bcc@example.com' => 'Chris (Bcc)', + 'john-bcc@example.org' => 'John (Bcc)', + )) + ->setBody('...') + ; + + $recipients = array('god@example.com', 'fabien@example.com'); + $patterns = array('/^.*@internal.[a-z]+$/'); + + $plugin = new Swift_Plugins_RedirectingPlugin($recipients, $patterns); + + $evt = $this->_createSendEvent($message); + + $plugin->beforeSendPerformed($evt); + + $this->assertEquals( + $message->getTo(), + array('fabien@example.com' => 'Fabien', 'lars-to@internal.com' => 'Lars (To)', 'god@example.com' => null) + ); + $this->assertEquals( + $message->getCc(), + array('fabien@example.com' => 'Fabien', 'lars-cc@internal.org' => 'Lars (Cc)') + ); + $this->assertEquals($message->getBcc(), array('fabien@example.com' => 'Fabien')); + + } + + // -- Creation Methods + + private function _createSendEvent(Swift_Mime_Message $message) + { + $evt = $this->getMockBuilder('Swift_Events_SendEvent') + ->disableOriginalConstructor() + ->getMock(); + $evt->expects($this->any()) + ->method('getMessage') + ->will($this->returnValue($message)); + + return $evt; + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Plugins/ReporterPluginTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Plugins/ReporterPluginTest.php new file mode 100755 index 0000000..8101883 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Plugins/ReporterPluginTest.php @@ -0,0 +1,88 @@ +_createMessage(); + $evt = $this->_createSendEvent(); + $reporter = $this->_createReporter(); + + $message->shouldReceive('getTo')->zeroOrMoreTimes()->andReturn(array('foo@bar.tld' => 'Foo')); + $evt->shouldReceive('getMessage')->zeroOrMoreTimes()->andReturn($message); + $evt->shouldReceive('getFailedRecipients')->zeroOrMoreTimes()->andReturn(array()); + $reporter->shouldReceive('notify')->once()->with($message, 'foo@bar.tld', Swift_Plugins_Reporter::RESULT_PASS); + + $plugin = new Swift_Plugins_ReporterPlugin($reporter); + $plugin->sendPerformed($evt); + } + + public function testReportingFailedTo() + { + $message = $this->_createMessage(); + $evt = $this->_createSendEvent(); + $reporter = $this->_createReporter(); + + $message->shouldReceive('getTo')->zeroOrMoreTimes()->andReturn(array('foo@bar.tld' => 'Foo', 'zip@button' => 'Zip')); + $evt->shouldReceive('getMessage')->zeroOrMoreTimes()->andReturn($message); + $evt->shouldReceive('getFailedRecipients')->zeroOrMoreTimes()->andReturn(array('zip@button')); + $reporter->shouldReceive('notify')->once()->with($message, 'foo@bar.tld', Swift_Plugins_Reporter::RESULT_PASS); + $reporter->shouldReceive('notify')->once()->with($message, 'zip@button', Swift_Plugins_Reporter::RESULT_FAIL); + + $plugin = new Swift_Plugins_ReporterPlugin($reporter); + $plugin->sendPerformed($evt); + } + + public function testReportingFailedCc() + { + $message = $this->_createMessage(); + $evt = $this->_createSendEvent(); + $reporter = $this->_createReporter(); + + $message->shouldReceive('getTo')->zeroOrMoreTimes()->andReturn(array('foo@bar.tld' => 'Foo')); + $message->shouldReceive('getCc')->zeroOrMoreTimes()->andReturn(array('zip@button' => 'Zip', 'test@test.com' => 'Test')); + $evt->shouldReceive('getMessage')->zeroOrMoreTimes()->andReturn($message); + $evt->shouldReceive('getFailedRecipients')->zeroOrMoreTimes()->andReturn(array('zip@button')); + $reporter->shouldReceive('notify')->once()->with($message, 'foo@bar.tld', Swift_Plugins_Reporter::RESULT_PASS); + $reporter->shouldReceive('notify')->once()->with($message, 'zip@button', Swift_Plugins_Reporter::RESULT_FAIL); + $reporter->shouldReceive('notify')->once()->with($message, 'test@test.com', Swift_Plugins_Reporter::RESULT_PASS); + + $plugin = new Swift_Plugins_ReporterPlugin($reporter); + $plugin->sendPerformed($evt); + } + + public function testReportingFailedBcc() + { + $message = $this->_createMessage(); + $evt = $this->_createSendEvent(); + $reporter = $this->_createReporter(); + + $message->shouldReceive('getTo')->zeroOrMoreTimes()->andReturn(array('foo@bar.tld' => 'Foo')); + $message->shouldReceive('getBcc')->zeroOrMoreTimes()->andReturn(array('zip@button' => 'Zip', 'test@test.com' => 'Test')); + $evt->shouldReceive('getMessage')->zeroOrMoreTimes()->andReturn($message); + $evt->shouldReceive('getFailedRecipients')->zeroOrMoreTimes()->andReturn(array('zip@button')); + $reporter->shouldReceive('notify')->once()->with($message, 'foo@bar.tld', Swift_Plugins_Reporter::RESULT_PASS); + $reporter->shouldReceive('notify')->once()->with($message, 'zip@button', Swift_Plugins_Reporter::RESULT_FAIL); + $reporter->shouldReceive('notify')->once()->with($message, 'test@test.com', Swift_Plugins_Reporter::RESULT_PASS); + + $plugin = new Swift_Plugins_ReporterPlugin($reporter); + $plugin->sendPerformed($evt); + } + + // -- Creation Methods + + private function _createMessage() + { + return $this->getMockery('Swift_Mime_Message')->shouldIgnoreMissing(); + } + + private function _createSendEvent() + { + return $this->getMockery('Swift_Events_SendEvent')->shouldIgnoreMissing(); + } + + private function _createReporter() + { + return $this->getMockery('Swift_Plugins_Reporter')->shouldIgnoreMissing(); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Plugins/Reporters/HitReporterTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Plugins/Reporters/HitReporterTest.php new file mode 100755 index 0000000..4d31c3c --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Plugins/Reporters/HitReporterTest.php @@ -0,0 +1,64 @@ +_hitReporter = new Swift_Plugins_Reporters_HitReporter(); + $this->_message = $this->getMock('Swift_Mime_Message'); + } + + public function testReportingFail() + { + $this->_hitReporter->notify($this->_message, 'foo@bar.tld', + Swift_Plugins_Reporter::RESULT_FAIL + ); + $this->assertEquals(array('foo@bar.tld'), + $this->_hitReporter->getFailedRecipients() + ); + } + + public function testMultipleReports() + { + $this->_hitReporter->notify($this->_message, 'foo@bar.tld', + Swift_Plugins_Reporter::RESULT_FAIL + ); + $this->_hitReporter->notify($this->_message, 'zip@button', + Swift_Plugins_Reporter::RESULT_FAIL + ); + $this->assertEquals(array('foo@bar.tld', 'zip@button'), + $this->_hitReporter->getFailedRecipients() + ); + } + + public function testReportingPassIsIgnored() + { + $this->_hitReporter->notify($this->_message, 'foo@bar.tld', + Swift_Plugins_Reporter::RESULT_FAIL + ); + $this->_hitReporter->notify($this->_message, 'zip@button', + Swift_Plugins_Reporter::RESULT_PASS + ); + $this->assertEquals(array('foo@bar.tld'), + $this->_hitReporter->getFailedRecipients() + ); + } + + public function testBufferCanBeCleared() + { + $this->_hitReporter->notify($this->_message, 'foo@bar.tld', + Swift_Plugins_Reporter::RESULT_FAIL + ); + $this->_hitReporter->notify($this->_message, 'zip@button', + Swift_Plugins_Reporter::RESULT_FAIL + ); + $this->assertEquals(array('foo@bar.tld', 'zip@button'), + $this->_hitReporter->getFailedRecipients() + ); + $this->_hitReporter->clear(); + $this->assertEquals(array(), $this->_hitReporter->getFailedRecipients()); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Plugins/Reporters/HtmlReporterTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Plugins/Reporters/HtmlReporterTest.php new file mode 100755 index 0000000..3e78fca --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Plugins/Reporters/HtmlReporterTest.php @@ -0,0 +1,54 @@ +_html = new Swift_Plugins_Reporters_HtmlReporter(); + $this->_message = $this->getMock('Swift_Mime_Message'); + } + + public function testReportingPass() + { + ob_start(); + $this->_html->notify($this->_message, 'foo@bar.tld', + Swift_Plugins_Reporter::RESULT_PASS + ); + $html = ob_get_clean(); + + $this->assertRegExp('~ok|pass~i', $html, '%s: Reporter should indicate pass'); + $this->assertRegExp('~foo@bar\.tld~', $html, '%s: Reporter should show address'); + } + + public function testReportingFail() + { + ob_start(); + $this->_html->notify($this->_message, 'zip@button', + Swift_Plugins_Reporter::RESULT_FAIL + ); + $html = ob_get_clean(); + + $this->assertRegExp('~fail~i', $html, '%s: Reporter should indicate fail'); + $this->assertRegExp('~zip@button~', $html, '%s: Reporter should show address'); + } + + public function testMultipleReports() + { + ob_start(); + $this->_html->notify($this->_message, 'foo@bar.tld', + Swift_Plugins_Reporter::RESULT_PASS + ); + $this->_html->notify($this->_message, 'zip@button', + Swift_Plugins_Reporter::RESULT_FAIL + ); + $html = ob_get_clean(); + + $this->assertRegExp('~ok|pass~i', $html, '%s: Reporter should indicate pass'); + $this->assertRegExp('~foo@bar\.tld~', $html, '%s: Reporter should show address'); + $this->assertRegExp('~fail~i', $html, '%s: Reporter should indicate fail'); + $this->assertRegExp('~zip@button~', $html, '%s: Reporter should show address'); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Plugins/ThrottlerPluginTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Plugins/ThrottlerPluginTest.php new file mode 100755 index 0000000..8e22766 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Plugins/ThrottlerPluginTest.php @@ -0,0 +1,104 @@ +_createSleeper(); + $timer = $this->_createTimer(); + + //10MB/min + $plugin = new Swift_Plugins_ThrottlerPlugin( + 10000000, Swift_Plugins_ThrottlerPlugin::BYTES_PER_MINUTE, + $sleeper, $timer + ); + + $timer->shouldReceive('getTimestamp')->once()->andReturn(0); + $timer->shouldReceive('getTimestamp')->once()->andReturn(1); //expected 0.6 + $timer->shouldReceive('getTimestamp')->once()->andReturn(1); //expected 1.2 (sleep 1) + $timer->shouldReceive('getTimestamp')->once()->andReturn(2); //expected 1.8 + $timer->shouldReceive('getTimestamp')->once()->andReturn(2); //expected 2.4 (sleep 1) + $sleeper->shouldReceive('sleep')->twice()->with(1); + + //10,000,000 bytes per minute + //100,000 bytes per email + + // .: (10,000,000/100,000)/60 emails per second = 1.667 emais/sec + + $message = $this->_createMessageWithByteCount(100000); //100KB + + $evt = $this->_createSendEvent($message); + + for ($i = 0; $i < 5; ++$i) { + $plugin->beforeSendPerformed($evt); + $plugin->sendPerformed($evt); + } + } + + public function testMessagesPerMinuteThrottling() + { + $sleeper = $this->_createSleeper(); + $timer = $this->_createTimer(); + + //60/min + $plugin = new Swift_Plugins_ThrottlerPlugin( + 60, Swift_Plugins_ThrottlerPlugin::MESSAGES_PER_MINUTE, + $sleeper, $timer + ); + + $timer->shouldReceive('getTimestamp')->once()->andReturn(0); + $timer->shouldReceive('getTimestamp')->once()->andReturn(0); //expected 1 (sleep 1) + $timer->shouldReceive('getTimestamp')->once()->andReturn(2); //expected 2 + $timer->shouldReceive('getTimestamp')->once()->andReturn(2); //expected 3 (sleep 1) + $timer->shouldReceive('getTimestamp')->once()->andReturn(4); //expected 4 + $sleeper->shouldReceive('sleep')->twice()->with(1); + + //60 messages per minute + //1 message per second + + $message = $this->_createMessageWithByteCount(10); + + $evt = $this->_createSendEvent($message); + + for ($i = 0; $i < 5; ++$i) { + $plugin->beforeSendPerformed($evt); + $plugin->sendPerformed($evt); + } + } + + // -- Creation Methods + + private function _createSleeper() + { + return $this->getMockery('Swift_Plugins_Sleeper'); + } + + private function _createTimer() + { + return $this->getMockery('Swift_Plugins_Timer'); + } + + private function _createMessageWithByteCount($bytes) + { + $msg = $this->getMockery('Swift_Mime_Message'); + $msg->shouldReceive('toByteStream') + ->zeroOrMoreTimes() + ->andReturnUsing(function($is) use ($bytes) { + for ($i = 0; $i < $bytes; ++$i) { + $is->write('x'); + } + }); + + return $msg; + } + + private function _createSendEvent($message) + { + $evt = $this->getMockery('Swift_Events_SendEvent'); + $evt->shouldReceive('getMessage') + ->zeroOrMoreTimes() + ->andReturn($message); + + return $evt; + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Signers/DKIMSignerTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Signers/DKIMSignerTest.php new file mode 100755 index 0000000..5f6e4df --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Signers/DKIMSignerTest.php @@ -0,0 +1,227 @@ +markTestSkipped( + 'skipping because of https://bugs.php.net/bug.php?id=61421' + ); + } + } + + public function testBasicSigningHeaderManipulation() + { + $headers = $this->_createHeaders(); + $messageContent = "Hello World"; + $signer = new Swift_Signers_DKIMSigner(file_get_contents(dirname(dirname(dirname(__DIR__))) . '/_samples/dkim/dkim.test.priv'), 'dummy.nxdomain.be', 'dummySelector'); + /* @var $signer Swift_Signers_HeaderSigner */ + $altered = $signer->getAlteredHeaders(); + $signer->reset(); + // Headers + $signer->setHeaders($headers); + // Body + $signer->startBody(); + $signer->write($messageContent); + $signer->endBody(); + // Signing + $signer->addSignature($headers); + } + + // Default Signing + public function testSigningDefaults() + { + $headerSet = $this->_createHeaderSet(); + $messageContent = "Hello World"; + $signer = new Swift_Signers_DKIMSigner(file_get_contents(dirname(dirname(dirname(__DIR__))) . '/_samples/dkim/dkim.test.priv'), 'dummy.nxdomain.be', 'dummySelector'); + $signer->setSignatureTimestamp('1299879181'); + $altered = $signer->getAlteredHeaders(); + $this->assertEquals(array('DKIM-Signature'), $altered); + $signer->reset(); + $signer->setHeaders($headerSet); + $this->assertFalse($headerSet->has('DKIM-Signature')); + $signer->startBody(); + $signer->write($messageContent); + $signer->endBody(); + $signer->addSignature($headerSet); + $this->assertTrue($headerSet->has('DKIM-Signature')); + $dkim = $headerSet->getAll('DKIM-Signature'); + $sig = reset($dkim); + $this->assertEquals($sig->getValue(), 'v=1; a=rsa-sha1; bh=wlbYcY9O9OPInGJ4D0E/rGsvMLE=; d=dummy.nxdomain.be; h=; i=@dummy.nxdomain.be; s=dummySelector; t=1299879181; b=RMSNelzM2O5MAAnMjT3G3/VF36S3DGJXoPCXR001F1WDReu0prGphWjuzK/m6V1pwqQL8cCNg Hi74mTx2bvyAvmkjvQtJf1VMUOCc9WHGcm1Yec66I3ZWoNMGSWZ1EKAm2CtTzyG0IFw4ml9DI wSkyAFxlgicckDD6FibhqwX4w='); + } + + // SHA256 Signing + public function testSigning256() + { + $headerSet = $this->_createHeaderSet(); + $messageContent = "Hello World"; + $signer = new Swift_Signers_DKIMSigner(file_get_contents(dirname(dirname(dirname(__DIR__))) . '/_samples/dkim/dkim.test.priv'), 'dummy.nxdomain.be', 'dummySelector'); + $signer->setHashAlgorithm('rsa-sha256'); + $signer->setSignatureTimestamp('1299879181'); + $altered = $signer->getAlteredHeaders(); + $this->assertEquals(array('DKIM-Signature'), $altered); + $signer->reset(); + $signer->setHeaders($headerSet); + $this->assertFalse($headerSet->has('DKIM-Signature')); + $signer->startBody(); + $signer->write($messageContent); + $signer->endBody(); + $signer->addSignature($headerSet); + $this->assertTrue($headerSet->has('DKIM-Signature')); + $dkim = $headerSet->getAll('DKIM-Signature'); + $sig = reset($dkim); + $this->assertEquals($sig->getValue(), 'v=1; a=rsa-sha256; bh=f+W+hu8dIhf2VAni89o8lF6WKTXi7nViA4RrMdpD5/U=; d=dummy.nxdomain.be; h=; i=@dummy.nxdomain.be; s=dummySelector; t=1299879181; b=jqPmieHzF5vR9F4mXCAkowuphpO4iJ8IAVuioh1BFZ3VITXZj5jlOFxULJMBiiApm2keJirnh u4mzogj444QkpT3lJg8/TBGAYQPdcvkG3KC0jdyN6QpSgpITBJG2BwWa+keXsv2bkQgLRAzNx qRhP45vpHCKun0Tg9LrwW/KCg='); + } + + // Relaxed/Relaxed Hash Signing + public function testSigningRelaxedRelaxed256() + { + $headerSet = $this->_createHeaderSet(); + $messageContent = "Hello World"; + $signer = new Swift_Signers_DKIMSigner(file_get_contents(dirname(dirname(dirname(__DIR__))) . '/_samples/dkim/dkim.test.priv'), 'dummy.nxdomain.be', 'dummySelector'); + $signer->setHashAlgorithm('rsa-sha256'); + $signer->setSignatureTimestamp('1299879181'); + $signer->setBodyCanon('relaxed'); + $signer->setHeaderCanon('relaxed'); + $altered = $signer->getAlteredHeaders(); + $this->assertEquals(array('DKIM-Signature'), $altered); + $signer->reset(); + $signer->setHeaders($headerSet); + $this->assertFalse($headerSet->has('DKIM-Signature')); + $signer->startBody(); + $signer->write($messageContent); + $signer->endBody(); + $signer->addSignature($headerSet); + $this->assertTrue($headerSet->has('DKIM-Signature')); + $dkim = $headerSet->getAll('DKIM-Signature'); + $sig = reset($dkim); + $this->assertEquals($sig->getValue(), 'v=1; a=rsa-sha256; bh=f+W+hu8dIhf2VAni89o8lF6WKTXi7nViA4RrMdpD5/U=; d=dummy.nxdomain.be; h=; i=@dummy.nxdomain.be; s=dummySelector; c=relaxed/relaxed; t=1299879181; b=gzOI+PX6HpZKQFzwwmxzcVJsyirdLXOS+4pgfCpVHQIdqYusKLrhlLeFBTNoz75HrhNvGH6T0 Rt3w5aTqkrWfUuAEYt0Ns14GowLM7JojaFN+pZ4eYnRB3CBBgW6fee4NEMD5WPca3uS09tr1E 10RYh9ILlRtl+84sovhx5id3Y='); + } + + + // Relaxed/Simple Hash Signing + public function testSigningRelaxedSimple256() + { + $headerSet = $this->_createHeaderSet(); + $messageContent = "Hello World"; + $signer = new Swift_Signers_DKIMSigner(file_get_contents(dirname(dirname(dirname(__DIR__))) . '/_samples/dkim/dkim.test.priv'), 'dummy.nxdomain.be', 'dummySelector'); + $signer->setHashAlgorithm('rsa-sha256'); + $signer->setSignatureTimestamp('1299879181'); + $signer->setHeaderCanon('relaxed'); + $altered = $signer->getAlteredHeaders(); + $this->assertEquals(array('DKIM-Signature'), $altered); + $signer->reset(); + $signer->setHeaders($headerSet); + $this->assertFalse($headerSet->has('DKIM-Signature')); + $signer->startBody(); + $signer->write($messageContent); + $signer->endBody(); + $signer->addSignature($headerSet); + $this->assertTrue($headerSet->has('DKIM-Signature')); + $dkim = $headerSet->getAll('DKIM-Signature'); + $sig = reset($dkim); + $this->assertEquals($sig->getValue(), 'v=1; a=rsa-sha256; bh=f+W+hu8dIhf2VAni89o8lF6WKTXi7nViA4RrMdpD5/U=; d=dummy.nxdomain.be; h=; i=@dummy.nxdomain.be; s=dummySelector; c=relaxed; t=1299879181; b=dLPJNec5v81oelyzGOY0qPqTlGnQeNfUNBOrV/JKbStr3NqWGI9jH4JAe2YvO2V32lfPNoby1 4MMzZ6EPkaZkZDDSPa+53YbCPQAlqiD9QZZIUe2UNM33HN8yAMgiWEF5aP7MbQnxeVZMfVLEl 9S8qOImu+K5JZqhQQTL0dgLwA='); + } + + // Simple/Relaxed Hash Signing + public function testSigningSimpleRelaxed256() + { + $headerSet = $this->_createHeaderSet(); + $messageContent = "Hello World"; + $signer = new Swift_Signers_DKIMSigner(file_get_contents(dirname(dirname(dirname(__DIR__))) . '/_samples/dkim/dkim.test.priv'), 'dummy.nxdomain.be', 'dummySelector'); + $signer->setHashAlgorithm('rsa-sha256'); + $signer->setSignatureTimestamp('1299879181'); + $signer->setBodyCanon('relaxed'); + $altered = $signer->getAlteredHeaders(); + $this->assertEquals(array('DKIM-Signature'), $altered); + $signer->reset(); + $signer->setHeaders($headerSet); + $this->assertFalse($headerSet->has('DKIM-Signature')); + $signer->startBody(); + $signer->write($messageContent); + $signer->endBody(); + $signer->addSignature($headerSet); + $this->assertTrue($headerSet->has('DKIM-Signature')); + $dkim = $headerSet->getAll('DKIM-Signature'); + $sig = reset($dkim); + $this->assertEquals($sig->getValue(), 'v=1; a=rsa-sha256; bh=f+W+hu8dIhf2VAni89o8lF6WKTXi7nViA4RrMdpD5/U=; d=dummy.nxdomain.be; h=; i=@dummy.nxdomain.be; s=dummySelector; c=simple/relaxed; t=1299879181; b=M5eomH/zamyzix9kOes+6YLzQZxuJdBP4x3nP9zF2N26eMLG2/cBKbnNyqiOTDhJdYfWPbLIa 1CWnjST0j5p4CpeOkGYuiE+M4TWEZwhRmRWootlPO3Ii6XpbBJKFk1o9zviS7OmXblUUE4aqb yRSIMDhtLdCK5GlaCneFLN7RQ='); + } + + // -- Creation Methods + private function _createHeaderSet() + { + $cache = new Swift_KeyCache_ArrayKeyCache(new Swift_KeyCache_SimpleKeyCacheInputStream()); + $factory = new Swift_CharacterReaderFactory_SimpleCharacterReaderFactory(); + $contentEncoder = new Swift_Mime_ContentEncoder_Base64ContentEncoder(); + + $headerEncoder = new Swift_Mime_HeaderEncoder_QpHeaderEncoder(new Swift_CharacterStream_ArrayCharacterStream($factory, 'utf-8')); + $paramEncoder = new Swift_Encoder_Rfc2231Encoder(new Swift_CharacterStream_ArrayCharacterStream($factory, 'utf-8')); + $grammar = new Swift_Mime_Grammar(); + $headers = new Swift_Mime_SimpleHeaderSet(new Swift_Mime_SimpleHeaderFactory($headerEncoder, $paramEncoder, $grammar)); + return $headers; + } + + /** + * @return Swift_Mime_Headers + */ + private function _createHeaders() + { + $x = 0; + $cache = new Swift_KeyCache_ArrayKeyCache(new Swift_KeyCache_SimpleKeyCacheInputStream()); + $factory = new Swift_CharacterReaderFactory_SimpleCharacterReaderFactory(); + $contentEncoder = new Swift_Mime_ContentEncoder_Base64ContentEncoder(); + + $headerEncoder = new Swift_Mime_HeaderEncoder_QpHeaderEncoder(new Swift_CharacterStream_ArrayCharacterStream($factory, 'utf-8')); + $paramEncoder = new Swift_Encoder_Rfc2231Encoder(new Swift_CharacterStream_ArrayCharacterStream($factory, 'utf-8')); + $grammar = new Swift_Mime_Grammar(); + $headerFactory = new Swift_Mime_SimpleHeaderFactory($headerEncoder, $paramEncoder, $grammar); + $headers = $this->getMockery('Swift_Mime_HeaderSet'); + + $headers->shouldReceive('listAll') + ->zeroOrMoreTimes() + ->andReturn(array('From', 'To', 'Date', 'Subject')); + $headers->shouldReceive('has') + ->zeroOrMoreTimes() + ->with('From') + ->andReturn(true); + $headers->shouldReceive('getAll') + ->zeroOrMoreTimes() + ->with('From') + ->andReturn(array($headerFactory->createMailboxHeader('From', 'test@test.test'))); + $headers->shouldReceive('has') + ->zeroOrMoreTimes() + ->with('To') + ->andReturn(true); + $headers->shouldReceive('getAll') + ->zeroOrMoreTimes() + ->with('To') + ->andReturn(array($headerFactory->createMailboxHeader('To', 'test@test.test'))); + $headers->shouldReceive('has') + ->zeroOrMoreTimes() + ->with('Date') + ->andReturn(true); + $headers->shouldReceive('getAll') + ->zeroOrMoreTimes() + ->with('Date') + ->andReturn(array($headerFactory->createTextHeader('Date', 'Fri, 11 Mar 2011 20:56:12 +0000 (GMT)'))); + $headers->shouldReceive('has') + ->zeroOrMoreTimes() + ->with('Subject') + ->andReturn(true); + $headers->shouldReceive('getAll') + ->zeroOrMoreTimes() + ->with('Subject') + ->andReturn(array($headerFactory->createTextHeader('Subject', 'Foo Bar Text Message'))); + $headers->shouldReceive('addTextHeader') + ->zeroOrMoreTimes() + ->with('DKIM-Signature', \Mockery::any()) + ->andReturn(true); + $headers->shouldReceive('getAll') + ->zeroOrMoreTimes() + ->with('DKIM-Signature') + ->andReturn(array($headerFactory->createTextHeader('DKIM-Signature', 'Foo Bar Text Message'))); + + return $headers; + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Signers/OpenDKIMSignerTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Signers/OpenDKIMSignerTest.php new file mode 100755 index 0000000..245793a --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Signers/OpenDKIMSignerTest.php @@ -0,0 +1,46 @@ +markTestSkipped( + 'Need OpenDKIM extension run these tests.' + ); + } + } + + public function testBasicSigningHeaderManipulation() + { + } + + // Default Signing + public function testSigningDefaults() + { + } + + // SHA256 Signing + public function testSigning256() + { + } + + // Relaxed/Relaxed Hash Signing + public function testSigningRelaxedRelaxed256() + { + } + + + // Relaxed/Simple Hash Signing + public function testSigningRelaxedSimple256() + { + } + + // Simple/Relaxed Hash Signing + public function testSigningSimpleRelaxed256() + { + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Signers/SMimeSignerTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Signers/SMimeSignerTest.php new file mode 100755 index 0000000..2b8fa06 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Signers/SMimeSignerTest.php @@ -0,0 +1,511 @@ +replacementFactory = Swift_DependencyContainer::getInstance() + ->lookup('transport.replacementfactory'); + + $this->samplesDir = str_replace('\\', '/', realpath(__DIR__. '/../../../_samples/')) . '/'; + } + + public function testUnSingedMessage() + { + $message = Swift_SignedMessage::newInstance('Wonderful Subject') + ->setFrom(array('john@doe.com' => 'John Doe')) + ->setTo(array('receiver@domain.org', 'other@domain.org' => 'A name')) + ->setBody('Here is the message itself'); + + $this->assertEquals('Here is the message itself', $message->getBody()); + } + + public function testSingedMessage() + { + $message = Swift_SignedMessage::newInstance('Wonderful Subject') + ->setFrom(array('john@doe.com' => 'John Doe')) + ->setTo(array('receiver@domain.org', 'other@domain.org' => 'A name')) + ->setBody('Here is the message itself'); + + $signer = new Swift_Signers_SMimeSigner(); + $signer->setSignCertificate($this->samplesDir . 'smime/sign.crt', $this->samplesDir . 'smime/sign.key'); + $message->attachSigner($signer); + + $messageStream = $this->newFilteredStream(); + $message->toByteStream($messageStream); + $messageStream->commit(); + + $entityString = $messageStream->getContent(); + $headers = self::getHeadersOfMessage($entityString); + + if (!($boundary = $this->getBoundary($headers['content-type']))) { + return false; + } + + $expectedBody = <<assertValidVerify($expectedBody, $messageStream); + unset($messageStream); + } + + public function testSingedMessageBinary() + { + $message = Swift_SignedMessage::newInstance('Wonderful Subject') + ->setFrom(array('john@doe.com' => 'John Doe')) + ->setTo(array('receiver@domain.org', 'other@domain.org' => 'A name')) + ->setBody('Here is the message itself'); + + $signer = new Swift_Signers_SMimeSigner(); + $signer->setSignCertificate($this->samplesDir . 'smime/sign.crt', $this->samplesDir . 'smime/sign.key', PKCS7_BINARY); + $message->attachSigner($signer); + + $messageStream = $this->newFilteredStream(); + $message->toByteStream($messageStream); + $messageStream->commit(); + + $entityString = $messageStream->getContent(); + $headers = self::getHeadersOfMessage($entityString); + + if (!preg_match('#^application/(x\-)?pkcs7-mime; smime-type=signed\-data;#', $headers['content-type'])) { + $this->fail('Content-type does not match.'); + + return false; + } + + $this->assertEquals($headers['content-transfer-encoding'], 'base64'); + $this->assertEquals($headers['content-disposition'], 'attachment; filename="smime.p7m"'); + + $expectedBody = '(?:^[a-zA-Z0-9\/\\r\\n+]*={0,2})'; + + $messageStreamClean = $this->newFilteredStream(); + + $this->assertValidVerify($expectedBody, $messageStream); + unset($messageStreamClean, $messageStream); + } + + public function testSingedMessageWithAttachments() + { + $message = Swift_SignedMessage::newInstance('Wonderful Subject') + ->setFrom(array('john@doe.com' => 'John Doe')) + ->setTo(array('receiver@domain.org', 'other@domain.org' => 'A name')) + ->setBody('Here is the message itself'); + + $message->attach(Swift_Attachment::fromPath($this->samplesDir . '/files/textfile.zip')); + + $signer = new Swift_Signers_SMimeSigner(); + $signer->setSignCertificate($this->samplesDir . 'smime/sign.crt', $this->samplesDir . 'smime/sign.key'); + $message->attachSigner($signer); + + $messageStream = $this->newFilteredStream(); + $message->toByteStream($messageStream); + $messageStream->commit(); + + $entityString = $messageStream->getContent(); + $headers = self::getHeadersOfMessage($entityString); + + if (!($boundary = $this->getBoundary($headers['content-type']))) { + return false; + } + + $expectedBody = <<assertValidVerify($expectedBody, $messageStream); + unset($messageStream); + } + + public function testEncryptedMessage() + { + $message = Swift_SignedMessage::newInstance('Wonderful Subject') + ->setFrom(array('john@doe.com' => 'John Doe')) + ->setTo(array('receiver@domain.org', 'other@domain.org' => 'A name')) + ->setBody('Here is the message itself'); + + $originalMessage = $this->cleanMessage($message->toString()); + + $signer = new Swift_Signers_SMimeSigner(); + $signer->setEncryptCertificate($this->samplesDir . 'smime/encrypt.crt'); + $message->attachSigner($signer); + + $messageStream = new Swift_ByteStream_TemporaryFileByteStream(); + $message->toByteStream($messageStream); + $messageStream->commit(); + + $entityString = $messageStream->getContent(); + $headers = self::getHeadersOfMessage($entityString); + + if (!preg_match('#^application/(x\-)?pkcs7-mime; smime-type=enveloped\-data;#', $headers['content-type'])) { + $this->fail('Content-type does not match.'); + + return false; + } + + $expectedBody = '(?:^[a-zA-Z0-9\/\\r\\n+]*={0,2})'; + + $decryptedMessageStream = new Swift_ByteStream_TemporaryFileByteStream(); + + if (!openssl_pkcs7_decrypt($messageStream->getPath(), $decryptedMessageStream->getPath(), 'file://' . $this->samplesDir . 'smime/encrypt.crt', array('file://' . $this->samplesDir . 'smime/encrypt.key', 'swift'))) { + $this->fail(sprintf('Decrypt of the message failed. Internal error "%s".', openssl_error_string())); + } + + $this->assertEquals($originalMessage, $decryptedMessageStream->getContent()); + unset($decryptedMessageStream, $messageStream); + } + + public function testEncryptedMessageWithMultipleCerts() + { + $message = Swift_SignedMessage::newInstance('Wonderful Subject') + ->setFrom(array('john@doe.com' => 'John Doe')) + ->setTo(array('receiver@domain.org', 'other@domain.org' => 'A name')) + ->setBody('Here is the message itself'); + + $originalMessage = $this->cleanMessage($message->toString()); + + $signer = new Swift_Signers_SMimeSigner(); + $signer->setEncryptCertificate(array($this->samplesDir . 'smime/encrypt.crt', $this->samplesDir . 'smime/encrypt2.crt')); + $message->attachSigner($signer); + + $messageStream = new Swift_ByteStream_TemporaryFileByteStream(); + $message->toByteStream($messageStream); + $messageStream->commit(); + + $entityString = $messageStream->getContent(); + $headers = self::getHeadersOfMessage($entityString); + + if (!preg_match('#^application/(x\-)?pkcs7-mime; smime-type=enveloped\-data;#', $headers['content-type'])) { + $this->fail('Content-type does not match.'); + + return false; + } + + $expectedBody = '(?:^[a-zA-Z0-9\/\\r\\n+]*={0,2})'; + + $decryptedMessageStream = new Swift_ByteStream_TemporaryFileByteStream(); + + if (!openssl_pkcs7_decrypt($messageStream->getPath(), $decryptedMessageStream->getPath(), 'file://' . $this->samplesDir . 'smime/encrypt.crt', array('file://' . $this->samplesDir . 'smime/encrypt.key', 'swift'))) { + $this->fail(sprintf('Decrypt of the message failed. Internal error "%s".', openssl_error_string())); + } + + $this->assertEquals($originalMessage, $decryptedMessageStream->getContent()); + unset($decryptedMessageStream); + + $decryptedMessageStream = new Swift_ByteStream_TemporaryFileByteStream(); + + if (!openssl_pkcs7_decrypt($messageStream->getPath(), $decryptedMessageStream->getPath(), 'file://' . $this->samplesDir . 'smime/encrypt2.crt', array('file://' . $this->samplesDir . 'smime/encrypt2.key', 'swift'))) { + $this->fail(sprintf('Decrypt of the message failed. Internal error "%s".', openssl_error_string())); + } + + $this->assertEquals($originalMessage, $decryptedMessageStream->getContent()); + unset($decryptedMessageStream, $messageStream); + } + + public function testSignThenEncryptedMessage() + { + $message = Swift_SignedMessage::newInstance('Wonderful Subject') + ->setFrom(array('john@doe.com' => 'John Doe')) + ->setTo(array('receiver@domain.org', 'other@domain.org' => 'A name')) + ->setBody('Here is the message itself'); + + $signer = new Swift_Signers_SMimeSigner(); + $signer->setSignCertificate($this->samplesDir . 'smime/sign.crt', $this->samplesDir . 'smime/sign.key'); + $signer->setEncryptCertificate($this->samplesDir . 'smime/encrypt.crt'); + $message->attachSigner($signer); + + $messageStream = new Swift_ByteStream_TemporaryFileByteStream(); + $message->toByteStream($messageStream); + $messageStream->commit(); + + $entityString = $messageStream->getContent(); + $headers = self::getHeadersOfMessage($entityString); + + if (!preg_match('#^application/(x\-)?pkcs7-mime; smime-type=enveloped\-data;#', $headers['content-type'])) { + $this->fail('Content-type does not match.'); + + return false; + } + + $expectedBody = '(?:^[a-zA-Z0-9\/\\r\\n+]*={0,2})'; + + $decryptedMessageStream = new Swift_ByteStream_TemporaryFileByteStream(); + + if (!openssl_pkcs7_decrypt($messageStream->getPath(), $decryptedMessageStream->getPath(), 'file://' . $this->samplesDir . 'smime/encrypt.crt', array('file://' . $this->samplesDir . 'smime/encrypt.key', 'swift'))) { + $this->fail(sprintf('Decrypt of the message failed. Internal error "%s".', openssl_error_string())); + } + + $entityString = $decryptedMessageStream->getContent(); + $headers = self::getHeadersOfMessage($entityString); + + if (!($boundary = $this->getBoundary($headers['content-type']))) { + return false; + } + + $expectedBody = <<assertValidVerify($expectedBody, $decryptedMessageStream)) { + return false; + } + + unset($decryptedMessageStream, $messageStream); + } + + public function testEncryptThenSignMessage() + { + $message = Swift_SignedMessage::newInstance('Wonderful Subject') + ->setFrom(array('john@doe.com' => 'John Doe')) + ->setTo(array('receiver@domain.org', 'other@domain.org' => 'A name')) + ->setBody('Here is the message itself'); + + $originalMessage = $this->cleanMessage($message->toString()); + + $signer = Swift_Signers_SMimeSigner::newInstance(); + $signer->setSignCertificate($this->samplesDir . 'smime/sign.crt', $this->samplesDir . 'smime/sign.key'); + $signer->setEncryptCertificate($this->samplesDir . 'smime/encrypt.crt'); + $signer->setSignThenEncrypt(false); + $message->attachSigner($signer); + + $messageStream = $this->newFilteredStream(); + $message->toByteStream($messageStream); + $messageStream->commit(); + + $entityString = $messageStream->getContent(); + $headers = self::getHeadersOfMessage($entityString); + + if (!($boundary = $this->getBoundary($headers['content-type']))) { + return false; + } + + $expectedBody = <<MIME-Version: 1\.0 +Content-Disposition: attachment; filename="smime\.p7m" +Content-Type: application/(x\-)?pkcs7-mime; smime-type=enveloped-data; name="smime\.p7m" +Content-Transfer-Encoding: base64 + +(?:^[a-zA-Z0-9\/\\r\\n+]*={0,2}) + + +)--$boundary +Content-Type: application/(x\-)?pkcs7-signature; name="smime\.p7s" +Content-Transfer-Encoding: base64 +Content-Disposition: attachment; filename="smime\.p7s" + +(?:^[a-zA-Z0-9\/\\r\\n+]*={0,2}) + +--$boundary-- +OEL; + + if (!$this->assertValidVerify($expectedBody, $messageStream)) { + return false; + } + + $expectedBody = str_replace("\n", "\r\n", $expectedBody); + if (!preg_match('%' . $expectedBody . '*%m', $entityString, $entities)) { + $this->fail('Failed regex match.'); + + return false; + } + + $messageStreamClean = new Swift_ByteStream_TemporaryFileByteStream(); + $messageStreamClean->write($entities['encrypted_message']); + + $decryptedMessageStream = new Swift_ByteStream_TemporaryFileByteStream(); + + if (!openssl_pkcs7_decrypt($messageStreamClean->getPath(), $decryptedMessageStream->getPath(), 'file://' . $this->samplesDir . 'smime/encrypt.crt', array('file://' . $this->samplesDir . 'smime/encrypt.key', 'swift'))) { + $this->fail(sprintf('Decrypt of the message failed. Internal error "%s".', openssl_error_string())); + } + + $this->assertEquals($originalMessage, $decryptedMessageStream->getContent()); + unset($messageStreamClean, $messageStream, $decryptedMessageStream); + } + + protected function assertValidVerify($expected, Swift_ByteStream_TemporaryFileByteStream $messageStream) + { + $actual = $messageStream->getContent(); + + // File is UNIX encoded so convert them to correct line ending + $expected = str_replace("\n", "\r\n", $expected); + + $actual = trim(self::getBodyOfMessage($actual)); + if (!$this->assertRegExp('%^' . $expected . '$\s*%m', $actual)) { + return false; + } + + $opensslOutput = new Swift_ByteStream_TemporaryFileByteStream(); + $verify = openssl_pkcs7_verify($messageStream->getPath(), null, $opensslOutput->getPath(), array($this->samplesDir . 'smime/ca.crt')); + + if (false === $verify) { + $this->fail('Verification of the message failed.'); + + return false; + } elseif (-1 === $verify) { + $this->fail(sprintf('Verification of the message failed. Internal error "%s".', openssl_error_string())); + + return false; + } + + return true; + } + + protected function getBoundary($contentType) + { + if (!preg_match('/boundary=("[^"]+"|(?:[^\s]+|$))/is', $contentType, $contentTypeData)) { + $this->fail('Failed to find Boundary parameter'); + + return false; + } + + return trim($contentTypeData[1], '"'); + } + + protected function newFilteredStream() + { + $messageStream = new Swift_ByteStream_TemporaryFileByteStream(); + $messageStream->addFilter($this->replacementFactory->createFilter("\r\n", "\n"), 'CRLF to LF'); + $messageStream->addFilter($this->replacementFactory->createFilter("\n", "\r\n"), 'LF to CRLF'); + + return $messageStream; + } + + protected static function getBodyOfMessage($message) + { + return substr($message, strpos($message, "\r\n\r\n")); + } + + /** + * Strips of the sender headers and Mime-Version. + * + * @param Swift_ByteStream_TemporaryFileByteStream $messageStream + * @param Swift_ByteStream_TemporaryFileByteStream $inputStream + */ + protected function cleanMessage($content) + { + $newContent = ''; + + $headers = self::getHeadersOfMessage($content); + foreach ($headers as $headerName => $value) { + if (!in_array($headerName, array('content-type', 'content-transfer-encoding', 'content-disposition'))) { + continue; + } + + $headerName = explode('-', $headerName); + $headerName = array_map('ucfirst', $headerName); + $headerName = implode('-', $headerName); + + if (strlen($value) > 62) { + $value = wordwrap($value, 62, "\n "); + } + + $newContent .= "$headerName: $value\r\n"; + } + + return $newContent . "\r\n" . ltrim(self::getBodyOfMessage($content)); + } + + /** + * Returns the headers of the message. + * + * Header-names are lowercase. + * + * @param string $message + * + * @return array + */ + protected static function getHeadersOfMessage($message) + { + $headersPosEnd = strpos($message, "\r\n\r\n"); + $headerData = substr($message, 0, $headersPosEnd); + $headerLines = explode("\r\n", $headerData); + + if (empty($headerLines)) { + return array(); + } + + $headers = array(); + + foreach ($headerLines as $headerLine) { + if (ctype_space($headerLines[0]) || false === strpos($headerLine, ':')) { + $headers[$currentHeaderName] .= ' ' . trim($headerLine); + continue; + } + + $header = explode(':', $headerLine, 2); + $currentHeaderName = strtolower($header[0]); + $headers[$currentHeaderName] = trim($header[1]); + } + + return $headers; + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/StreamFilters/ByteArrayReplacementFilterTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/StreamFilters/ByteArrayReplacementFilterTest.php new file mode 100755 index 0000000..bd53011 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/StreamFilters/ByteArrayReplacementFilterTest.php @@ -0,0 +1,131 @@ +_createFilter(array(0x61, 0x62), array(0x63, 0x64)); + $this->assertEquals( + array(0x59, 0x60, 0x63, 0x64, 0x65), + $filter->filter(array(0x59, 0x60, 0x61, 0x62, 0x65)) + ); + } + + public function testShouldBufferReturnsTrueIfPartialMatchAtEndOfBuffer() + { + $filter = $this->_createFilter(array(0x61, 0x62), array(0x63, 0x64)); + $this->assertTrue($filter->shouldBuffer(array(0x59, 0x60, 0x61)), + '%s: Filter should buffer since 0x61 0x62 is the needle and the ending ' . + '0x61 could be from 0x61 0x62' + ); + } + + public function testFilterCanMakeMultipleReplacements() + { + $filter = $this->_createFilter(array(array(0x61), array(0x62)), array(0x63)); + $this->assertEquals( + array(0x60, 0x63, 0x60, 0x63, 0x60), + $filter->filter(array(0x60, 0x61, 0x60, 0x62, 0x60)) + ); + } + + public function testMultipleReplacementsCanBeDifferent() + { + $filter = $this->_createFilter(array(array(0x61), array(0x62)), array(array(0x63), array(0x64))); + $this->assertEquals( + array(0x60, 0x63, 0x60, 0x64, 0x60), + $filter->filter(array(0x60, 0x61, 0x60, 0x62, 0x60)) + ); + } + + public function testShouldBufferReturnsFalseIfPartialMatchNotAtEndOfString() + { + $filter = $this->_createFilter(array(0x0D, 0x0A), array(0x0A)); + $this->assertFalse($filter->shouldBuffer(array(0x61, 0x62, 0x0D, 0x0A, 0x63)), + '%s: Filter should not buffer since x0Dx0A is the needle and is not at EOF' + ); + } + + public function testShouldBufferReturnsTrueIfAnyOfMultipleMatchesAtEndOfString() + { + $filter = $this->_createFilter(array(array(0x61, 0x62), array(0x63)), array(0x64)); + $this->assertTrue($filter->shouldBuffer(array(0x59, 0x60, 0x61)), + '%s: Filter should buffer since 0x61 0x62 is a needle and the ending ' . + '0x61 could be from 0x61 0x62' + ); + } + + public function testConvertingAllLineEndingsToCRLFWhenInputIsLF() + { + $filter = $this->_createFilter( + array(array(0x0D, 0x0A), array(0x0D), array(0x0A)), + array(array(0x0A), array(0x0A), array(0x0D, 0x0A)) + ); + + $this->assertEquals( + array(0x60, 0x0D, 0x0A, 0x61, 0x0D, 0x0A, 0x62, 0x0D, 0x0A, 0x63), + $filter->filter(array(0x60, 0x0A, 0x61, 0x0A, 0x62, 0x0A, 0x63)) + ); + } + + public function testConvertingAllLineEndingsToCRLFWhenInputIsCR() + { + $filter = $this->_createFilter( + array(array(0x0D, 0x0A), array(0x0D), array(0x0A)), + array(array(0x0A), array(0x0A), array(0x0D, 0x0A)) + ); + + $this->assertEquals( + array(0x60, 0x0D, 0x0A, 0x61, 0x0D, 0x0A, 0x62, 0x0D, 0x0A, 0x63), + $filter->filter(array(0x60, 0x0D, 0x61, 0x0D, 0x62, 0x0D, 0x63)) + ); + } + + public function testConvertingAllLineEndingsToCRLFWhenInputIsCRLF() + { + $filter = $this->_createFilter( + array(array(0x0D, 0x0A), array(0x0D), array(0x0A)), + array(array(0x0A), array(0x0A), array(0x0D, 0x0A)) + ); + + $this->assertEquals( + array(0x60, 0x0D, 0x0A, 0x61, 0x0D, 0x0A, 0x62, 0x0D, 0x0A, 0x63), + $filter->filter(array(0x60, 0x0D, 0x0A, 0x61, 0x0D, 0x0A, 0x62, 0x0D, 0x0A, 0x63)) + ); + } + + public function testConvertingAllLineEndingsToCRLFWhenInputIsLFCR() + { + $filter = $this->_createFilter( + array(array(0x0D, 0x0A), array(0x0D), array(0x0A)), + array(array(0x0A), array(0x0A), array(0x0D, 0x0A)) + ); + + $this->assertEquals( + array(0x60, 0x0D, 0x0A, 0x0D, 0x0A, 0x61, 0x0D, 0x0A, 0x0D, 0x0A, 0x62, 0x0D, 0x0A, 0x0D, 0x0A, 0x63), + $filter->filter(array(0x60, 0x0A, 0x0D, 0x61, 0x0A, 0x0D, 0x62, 0x0A, 0x0D, 0x63)) + ); + } + + public function testConvertingAllLineEndingsToCRLFWhenInputContainsLFLF() + { + //Lighthouse Bug #23 + + $filter = $this->_createFilter( + array(array(0x0D, 0x0A), array(0x0D), array(0x0A)), + array(array(0x0A), array(0x0A), array(0x0D, 0x0A)) + ); + + $this->assertEquals( + array(0x60, 0x0D, 0x0A, 0x0D, 0x0A, 0x61, 0x0D, 0x0A, 0x0D, 0x0A, 0x62, 0x0D, 0x0A, 0x0D, 0x0A, 0x63), + $filter->filter(array(0x60, 0x0A, 0x0A, 0x61, 0x0A, 0x0A, 0x62, 0x0A, 0x0A, 0x63)) + ); + } + + // -- Creation methods + + private function _createFilter($search, $replace) + { + return new Swift_StreamFilters_ByteArrayReplacementFilter($search, $replace); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/StreamFilters/StringReplacementFilterFactoryTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/StreamFilters/StringReplacementFilterFactoryTest.php new file mode 100755 index 0000000..bd44f5c --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/StreamFilters/StringReplacementFilterFactoryTest.php @@ -0,0 +1,38 @@ +_createFactory(); + $this->assertInstanceof( + 'Swift_StreamFilters_StringReplacementFilter', + $factory->createFilter('a', 'b') + ); + } + + public function testSameInstancesAreCached() + { + $factory = $this->_createFactory(); + $filter1 = $factory->createFilter('a', 'b'); + $filter2 = $factory->createFilter('a', 'b'); + $this->assertSame($filter1, $filter2, '%s: Instances should be cached'); + } + + public function testDifferingInstancesAreNotCached() + { + $factory = $this->_createFactory(); + $filter1 = $factory->createFilter('a', 'b'); + $filter2 = $factory->createFilter('a', 'c'); + $this->assertNotEquals($filter1, $filter2, + '%s: Differing instances should not be cached' + ); + } + + // -- Creation methods + + private function _createFactory() + { + return new Swift_StreamFilters_StringReplacementFilterFactory(); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/StreamFilters/StringReplacementFilterTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/StreamFilters/StringReplacementFilterTest.php new file mode 100755 index 0000000..7459afd --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/StreamFilters/StringReplacementFilterTest.php @@ -0,0 +1,55 @@ +_createFilter('foo', 'bar'); + $this->assertEquals('XbarYbarZ', $filter->filter('XfooYfooZ')); + } + + public function testShouldBufferReturnsTrueIfPartialMatchAtEndOfBuffer() + { + $filter = $this->_createFilter('foo', 'bar'); + $this->assertTrue($filter->shouldBuffer('XfooYf'), + '%s: Filter should buffer since "foo" is the needle and the ending ' . + '"f" could be from "foo"' + ); + } + + public function testFilterCanMakeMultipleReplacements() + { + $filter = $this->_createFilter(array('a', 'b'), 'foo'); + $this->assertEquals('XfooYfooZ', $filter->filter('XaYbZ')); + } + + public function testMultipleReplacementsCanBeDifferent() + { + $filter = $this->_createFilter(array('a', 'b'), array('foo', 'zip')); + $this->assertEquals('XfooYzipZ', $filter->filter('XaYbZ')); + } + + public function testShouldBufferReturnsFalseIfPartialMatchNotAtEndOfString() + { + $filter = $this->_createFilter("\r\n", "\n"); + $this->assertFalse($filter->shouldBuffer("foo\r\nbar"), + '%s: Filter should not buffer since x0Dx0A is the needle and is not at EOF' + ); + } + + public function testShouldBufferReturnsTrueIfAnyOfMultipleMatchesAtEndOfString() + { + $filter = $this->_createFilter(array('foo', 'zip'), 'bar'); + $this->assertTrue($filter->shouldBuffer('XfooYzi'), + '%s: Filter should buffer since "zip" is a needle and the ending ' . + '"zi" could be from "zip"' + ); + } + + // -- Creation methods + + private function _createFilter($search, $replace) + { + return new Swift_StreamFilters_StringReplacementFilter($search, $replace); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Transport/AbstractSmtpEventSupportTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Transport/AbstractSmtpEventSupportTest.php new file mode 100755 index 0000000..4419345 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Transport/AbstractSmtpEventSupportTest.php @@ -0,0 +1,560 @@ +_getBuffer(); + $dispatcher = $this->_createEventDispatcher(false); + $listener = $this->getMockery('Swift_Events_EventListener'); + $smtp = $this->_getTransport($buf, $dispatcher); + $dispatcher->shouldReceive('bindEventListener') + ->once() + ->with($listener); + + $smtp->registerPlugin($listener); + } + + public function testSendingDispatchesBeforeSendEvent() + { + $buf = $this->_getBuffer(); + $dispatcher = $this->_createEventDispatcher(false); + $message = $this->_createMessage(); + $smtp = $this->_getTransport($buf, $dispatcher); + $evt = $this->getMockery('Swift_Events_SendEvent')->shouldIgnoreMissing(); + + $message->shouldReceive('getFrom') + ->zeroOrMoreTimes() + ->andReturn(array('chris@swiftmailer.org'=>null)); + $message->shouldReceive('getTo') + ->zeroOrMoreTimes() + ->andReturn(array('mark@swiftmailer.org'=>'Mark')); + $dispatcher->shouldReceive('createSendEvent') + ->once() + ->andReturn($evt); + $dispatcher->shouldReceive('dispatchEvent') + ->once() + ->with($evt, 'beforeSendPerformed'); + $dispatcher->shouldReceive('dispatchEvent') + ->zeroOrMoreTimes(); + $evt->shouldReceive('bubbleCancelled') + ->zeroOrMoreTimes() + ->andReturn(false); + + $this->_finishBuffer($buf); + $smtp->start(); + $this->assertEquals(1, $smtp->send($message)); + } + + public function testSendingDispatchesSendEvent() + { + $buf = $this->_getBuffer(); + $dispatcher = $this->_createEventDispatcher(false); + $message = $this->_createMessage(); + $smtp = $this->_getTransport($buf, $dispatcher); + $evt = $this->getMockery('Swift_Events_SendEvent')->shouldIgnoreMissing(); + + $message->shouldReceive('getFrom') + ->zeroOrMoreTimes() + ->andReturn(array('chris@swiftmailer.org'=>null)); + $message->shouldReceive('getTo') + ->zeroOrMoreTimes() + ->andReturn(array('mark@swiftmailer.org'=>'Mark')); + $dispatcher->shouldReceive('createSendEvent') + ->once() + ->andReturn($evt); + $dispatcher->shouldReceive('dispatchEvent') + ->once() + ->with($evt, 'sendPerformed'); + $dispatcher->shouldReceive('dispatchEvent') + ->zeroOrMoreTimes(); + $evt->shouldReceive('bubbleCancelled') + ->zeroOrMoreTimes() + ->andReturn(false); + + $this->_finishBuffer($buf); + $smtp->start(); + $this->assertEquals(1, $smtp->send($message)); + } + + public function testSendEventCapturesFailures() + { + $buf = $this->_getBuffer(); + $dispatcher = $this->_createEventDispatcher(false); + $evt = $this->getMockery('Swift_Events_SendEvent')->shouldIgnoreMissing(); + $smtp = $this->_getTransport($buf, $dispatcher); + $message = $this->_createMessage(); + + $message->shouldReceive('getFrom') + ->zeroOrMoreTimes() + ->andReturn(array('chris@swiftmailer.org'=>null)); + $message->shouldReceive('getTo') + ->zeroOrMoreTimes() + ->andReturn(array('mark@swiftmailer.org'=>'Mark')); + $buf->shouldReceive('write') + ->once() + ->with("MAIL FROM: \r\n") + ->andReturn(1); + $buf->shouldReceive('readLine') + ->once() + ->with(1) + ->andReturn("250 OK\r\n"); + $buf->shouldReceive('write') + ->once() + ->with("RCPT TO: \r\n") + ->andReturn(2); + $buf->shouldReceive('readLine') + ->once() + ->with(2) + ->andReturn("500 Not now\r\n"); + $dispatcher->shouldReceive('createSendEvent') + ->zeroOrMoreTimes() + ->with($smtp, \Mockery::any()) + ->andReturn($evt); + $dispatcher->shouldReceive('dispatchEvent') + ->once() + ->with($evt, 'sendPerformed'); + $dispatcher->shouldReceive('dispatchEvent') + ->zeroOrMoreTimes(); + $evt->shouldReceive('bubbleCancelled') + ->zeroOrMoreTimes() + ->andReturn(false); + $evt->shouldReceive('setFailedRecipients') + ->once() + ->with(array('mark@swiftmailer.org')); + + $this->_finishBuffer($buf); + $smtp->start(); + $this->assertEquals(0, $smtp->send($message)); + } + + public function testSendEventHasResultFailedIfAllFailures() + { + $buf = $this->_getBuffer(); + $dispatcher = $this->_createEventDispatcher(false); + $evt = $this->getMockery('Swift_Events_SendEvent')->shouldIgnoreMissing(); + $smtp = $this->_getTransport($buf, $dispatcher); + $message = $this->_createMessage(); + + $message->shouldReceive('getFrom') + ->zeroOrMoreTimes() + ->andReturn(array('chris@swiftmailer.org'=>null)); + $message->shouldReceive('getTo') + ->zeroOrMoreTimes() + ->andReturn(array('mark@swiftmailer.org'=>'Mark')); + $buf->shouldReceive('write') + ->once() + ->with("MAIL FROM: \r\n") + ->andReturn(1); + $buf->shouldReceive('readLine') + ->once() + ->with(1) + ->andReturn("250 OK\r\n"); + $buf->shouldReceive('write') + ->once() + ->with("RCPT TO: \r\n") + ->andReturn(2); + $buf->shouldReceive('readLine') + ->once() + ->with(2) + ->andReturn("500 Not now\r\n"); + $dispatcher->shouldReceive('createSendEvent') + ->zeroOrMoreTimes() + ->with($smtp, \Mockery::any()) + ->andReturn($evt); + $dispatcher->shouldReceive('dispatchEvent') + ->once() + ->with($evt, 'sendPerformed'); + $dispatcher->shouldReceive('dispatchEvent') + ->zeroOrMoreTimes(); + $evt->shouldReceive('bubbleCancelled') + ->zeroOrMoreTimes() + ->andReturn(false); + $evt->shouldReceive('setResult') + ->once() + ->with(Swift_Events_SendEvent::RESULT_FAILED); + + $this->_finishBuffer($buf); + $smtp->start(); + $this->assertEquals(0, $smtp->send($message)); + } + + public function testSendEventHasResultTentativeIfSomeFailures() + { + $buf = $this->_getBuffer(); + $dispatcher = $this->_createEventDispatcher(false); + $evt = $this->getMockery('Swift_Events_SendEvent')->shouldIgnoreMissing(); + $smtp = $this->_getTransport($buf, $dispatcher); + $message = $this->_createMessage(); + + $message->shouldReceive('getFrom') + ->zeroOrMoreTimes() + ->andReturn(array('chris@swiftmailer.org'=>null)); + $message->shouldReceive('getTo') + ->zeroOrMoreTimes() + ->andReturn(array( + 'mark@swiftmailer.org'=>'Mark', + 'chris@site.tld'=>'Chris' + )); + $buf->shouldReceive('write') + ->once() + ->with("MAIL FROM: \r\n") + ->andReturn(1); + $buf->shouldReceive('readLine') + ->once() + ->with(1) + ->andReturn("250 OK\r\n"); + $buf->shouldReceive('write') + ->once() + ->with("RCPT TO: \r\n") + ->andReturn(2); + $buf->shouldReceive('readLine') + ->once() + ->with(2) + ->andReturn("500 Not now\r\n"); + $dispatcher->shouldReceive('createSendEvent') + ->zeroOrMoreTimes() + ->with($smtp, \Mockery::any()) + ->andReturn($evt); + $dispatcher->shouldReceive('dispatchEvent') + ->once() + ->with($evt, 'sendPerformed'); + $dispatcher->shouldReceive('dispatchEvent') + ->zeroOrMoreTimes(); + $evt->shouldReceive('bubbleCancelled') + ->zeroOrMoreTimes() + ->andReturn(false); + $evt->shouldReceive('setResult') + ->once() + ->with(Swift_Events_SendEvent::RESULT_TENTATIVE); + + $this->_finishBuffer($buf); + $smtp->start(); + $this->assertEquals(1, $smtp->send($message)); + } + + public function testSendEventHasResultSuccessIfNoFailures() + { + $buf = $this->_getBuffer(); + $dispatcher = $this->_createEventDispatcher(false); + $evt = $this->getMockery('Swift_Events_SendEvent')->shouldIgnoreMissing(); + $smtp = $this->_getTransport($buf, $dispatcher); + $message = $this->_createMessage(); + + $message->shouldReceive('getFrom') + ->zeroOrMoreTimes() + ->andReturn(array('chris@swiftmailer.org'=>null)); + $message->shouldReceive('getTo') + ->zeroOrMoreTimes() + ->andReturn(array( + 'mark@swiftmailer.org'=>'Mark', + 'chris@site.tld'=>'Chris' + )); + $dispatcher->shouldReceive('createSendEvent') + ->zeroOrMoreTimes() + ->with($smtp, \Mockery::any()) + ->andReturn($evt); + $dispatcher->shouldReceive('dispatchEvent') + ->once() + ->with($evt, 'sendPerformed'); + $dispatcher->shouldReceive('dispatchEvent') + ->zeroOrMoreTimes(); + $evt->shouldReceive('bubbleCancelled') + ->zeroOrMoreTimes() + ->andReturn(false); + $evt->shouldReceive('setResult') + ->once() + ->with(Swift_Events_SendEvent::RESULT_SUCCESS); + + $this->_finishBuffer($buf); + $smtp->start(); + $this->assertEquals(2, $smtp->send($message)); + } + + public function testCancellingEventBubbleBeforeSendStopsEvent() + { + $buf = $this->_getBuffer(); + $dispatcher = $this->_createEventDispatcher(false); + $evt = $this->getMockery('Swift_Events_SendEvent')->shouldIgnoreMissing(); + $smtp = $this->_getTransport($buf, $dispatcher); + $message = $this->_createMessage(); + + $message->shouldReceive('getFrom') + ->zeroOrMoreTimes() + ->andReturn(array('chris@swiftmailer.org'=>null)); + $message->shouldReceive('getTo') + ->zeroOrMoreTimes() + ->andReturn(array('mark@swiftmailer.org'=>'Mark')); + $dispatcher->shouldReceive('createSendEvent') + ->zeroOrMoreTimes() + ->with($smtp, \Mockery::any()) + ->andReturn($evt); + $dispatcher->shouldReceive('dispatchEvent') + ->once() + ->with($evt, 'beforeSendPerformed'); + $dispatcher->shouldReceive('dispatchEvent') + ->zeroOrMoreTimes(); + $evt->shouldReceive('bubbleCancelled') + ->atLeast()->once() + ->andReturn(true); + + $this->_finishBuffer($buf); + $smtp->start(); + $this->assertEquals(0, $smtp->send($message)); + } + + public function testStartingTransportDispatchesTransportChangeEvent() + { + $buf = $this->_getBuffer(); + $dispatcher = $this->_createEventDispatcher(false); + $evt = $this->getMockery('Swift_Events_TransportChangeEvent'); + $smtp = $this->_getTransport($buf, $dispatcher); + + $dispatcher->shouldReceive('createTransportChangeEvent') + ->atLeast()->once() + ->with($smtp) + ->andReturn($evt); + $dispatcher->shouldReceive('dispatchEvent') + ->once() + ->with($evt, 'transportStarted'); + $dispatcher->shouldReceive('dispatchEvent') + ->zeroOrMoreTimes(); + $evt->shouldReceive('bubbleCancelled') + ->atLeast()->once() + ->andReturn(false); + + $this->_finishBuffer($buf); + $smtp->start(); + } + + public function testStartingTransportDispatchesBeforeTransportChangeEvent() + { + $buf = $this->_getBuffer(); + $dispatcher = $this->_createEventDispatcher(false); + $evt = $this->getMockery('Swift_Events_TransportChangeEvent'); + $smtp = $this->_getTransport($buf, $dispatcher); + + $dispatcher->shouldReceive('createTransportChangeEvent') + ->atLeast()->once() + ->with($smtp) + ->andReturn($evt); + $dispatcher->shouldReceive('dispatchEvent') + ->once() + ->with($evt, 'beforeTransportStarted'); + $dispatcher->shouldReceive('dispatchEvent') + ->zeroOrMoreTimes(); + $evt->shouldReceive('bubbleCancelled') + ->atLeast()->once() + ->andReturn(false); + + $this->_finishBuffer($buf); + $smtp->start(); + } + + public function testCancellingBubbleBeforeTransportStartStopsEvent() + { + $buf = $this->_getBuffer(); + $dispatcher = $this->_createEventDispatcher(false); + $evt = $this->getMockery('Swift_Events_TransportChangeEvent'); + $smtp = $this->_getTransport($buf, $dispatcher); + + $dispatcher->shouldReceive('createTransportChangeEvent') + ->atLeast()->once() + ->with($smtp) + ->andReturn($evt); + $dispatcher->shouldReceive('dispatchEvent') + ->once() + ->with($evt, 'beforeTransportStarted'); + $dispatcher->shouldReceive('dispatchEvent') + ->zeroOrMoreTimes(); + $evt->shouldReceive('bubbleCancelled') + ->atLeast()->once() + ->andReturn(true); + + $this->_finishBuffer($buf); + $smtp->start(); + + $this->assertFalse($smtp->isStarted(), + '%s: Transport should not be started since event bubble was cancelled' + ); + } + + public function testStoppingTransportDispatchesTransportChangeEvent() + { + $buf = $this->_getBuffer(); + $dispatcher = $this->_createEventDispatcher(false); + $evt = $this->getMockery('Swift_Events_TransportChangeEvent')->shouldIgnoreMissing(); + $smtp = $this->_getTransport($buf, $dispatcher); + + $dispatcher->shouldReceive('createTransportChangeEvent') + ->atLeast()->once() + ->with($smtp) + ->andReturn($evt); + $dispatcher->shouldReceive('dispatchEvent') + ->once() + ->with($evt, 'transportStopped'); + $dispatcher->shouldReceive('dispatchEvent') + ->zeroOrMoreTimes(); + + $this->_finishBuffer($buf); + $smtp->start(); + $smtp->stop(); + } + + public function testStoppingTransportDispatchesBeforeTransportChangeEvent() + { + $buf = $this->_getBuffer(); + $dispatcher = $this->_createEventDispatcher(false); + $evt = $this->getMockery('Swift_Events_TransportChangeEvent')->shouldIgnoreMissing(); + $smtp = $this->_getTransport($buf, $dispatcher); + + $dispatcher->shouldReceive('createTransportChangeEvent') + ->atLeast()->once() + ->with($smtp) + ->andReturn($evt); + $dispatcher->shouldReceive('dispatchEvent') + ->once() + ->with($evt, 'beforeTransportStopped'); + $dispatcher->shouldReceive('dispatchEvent') + ->zeroOrMoreTimes(); + + $this->_finishBuffer($buf); + $smtp->start(); + $smtp->stop(); + } + + public function testCancellingBubbleBeforeTransportStoppedStopsEvent() + { + $buf = $this->_getBuffer(); + $dispatcher = $this->_createEventDispatcher(false); + $evt = $this->getMockery('Swift_Events_TransportChangeEvent'); + $smtp = $this->_getTransport($buf, $dispatcher); + + $hasRun = false; + $dispatcher->shouldReceive('createTransportChangeEvent') + ->atLeast()->once() + ->with($smtp) + ->andReturn($evt); + $dispatcher->shouldReceive('dispatchEvent') + ->once() + ->with($evt, 'beforeTransportStopped') + ->andReturnUsing(function() use (&$hasRun) { + $hasRun = true; + }); + $dispatcher->shouldReceive('dispatchEvent') + ->zeroOrMoreTimes(); + $evt->shouldReceive('bubbleCancelled') + ->zeroOrMoreTimes() + ->andReturnUsing(function() use (&$hasRun) { + return $hasRun; + }); + + $this->_finishBuffer($buf); + $smtp->start(); + $smtp->stop(); + + $this->assertTrue($smtp->isStarted(), + '%s: Transport should not be stopped since event bubble was cancelled' + ); + } + + public function testResponseEventsAreGenerated() + { + $buf = $this->_getBuffer(); + $dispatcher = $this->_createEventDispatcher(false); + $evt = $this->getMockery('Swift_Events_ResponseEvent'); + $smtp = $this->_getTransport($buf, $dispatcher); + + $dispatcher->shouldReceive('createResponseEvent') + ->atLeast()->once() + ->with($smtp, \Mockery::any(), \Mockery::any()) + ->andReturn($evt); + $dispatcher->shouldReceive('dispatchEvent') + ->atLeast()->once() + ->with($evt, 'responseReceived'); + + $this->_finishBuffer($buf); + $smtp->start(); + } + + public function testCommandEventsAreGenerated() + { + $buf = $this->_getBuffer(); + $dispatcher = $this->_createEventDispatcher(false); + $evt = $this->getMockery('Swift_Events_CommandEvent'); + $smtp = $this->_getTransport($buf, $dispatcher); + + $dispatcher->shouldReceive('createCommandEvent') + ->once() + ->with($smtp, \Mockery::any(), \Mockery::any()) + ->andReturn($evt); + $dispatcher->shouldReceive('dispatchEvent') + ->once() + ->with($evt, 'commandSent'); + + $this->_finishBuffer($buf); + $smtp->start(); + } + + public function testExceptionsCauseExceptionEvents() + { + $buf = $this->_getBuffer(); + $dispatcher = $this->_createEventDispatcher(false); + $evt = $this->getMockery('Swift_Events_TransportExceptionEvent'); + $smtp = $this->_getTransport($buf, $dispatcher); + + $buf->shouldReceive('readLine') + ->atLeast()->once() + ->andReturn("503 I'm sleepy, go away!\r\n"); + $dispatcher->shouldReceive('createTransportExceptionEvent') + ->zeroOrMoreTimes() + ->with($smtp, \Mockery::any()) + ->andReturn($evt); + $dispatcher->shouldReceive('dispatchEvent') + ->once() + ->with($evt, 'exceptionThrown'); + $evt->shouldReceive('bubbleCancelled') + ->atLeast()->once() + ->andReturn(false); + + try { + $smtp->start(); + $this->fail('TransportException should be thrown on invalid response'); + } catch (Swift_TransportException $e) { + } + } + + public function testExceptionBubblesCanBeCancelled() + { + $buf = $this->_getBuffer(); + $dispatcher = $this->_createEventDispatcher(false); + $evt = $this->getMockery('Swift_Events_TransportExceptionEvent'); + $smtp = $this->_getTransport($buf, $dispatcher); + + $buf->shouldReceive('readLine') + ->atLeast()->once() + ->andReturn("503 I'm sleepy, go away!\r\n"); + $dispatcher->shouldReceive('createTransportExceptionEvent') + ->twice() + ->with($smtp, \Mockery::any()) + ->andReturn($evt); + $dispatcher->shouldReceive('dispatchEvent') + ->twice() + ->with($evt, 'exceptionThrown'); + $evt->shouldReceive('bubbleCancelled') + ->atLeast()->once() + ->andReturn(true); + + $this->_finishBuffer($buf); + $smtp->start(); + } + + // -- Creation Methods + + protected function _createEventDispatcher($stub = true) + { + return $this->getMockery('Swift_Events_EventDispatcher')->shouldIgnoreMissing(); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Transport/AbstractSmtpTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Transport/AbstractSmtpTest.php new file mode 100755 index 0000000..25031cb --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Transport/AbstractSmtpTest.php @@ -0,0 +1,1251 @@ +_getBuffer(); + $smtp = $this->_getTransport($buf); + $buf->shouldReceive('initialize') + ->once(); + $buf->shouldReceive('readLine') + ->once() + ->with(0) + ->andReturn("220 some.server.tld bleh\r\n"); + + $this->_finishBuffer($buf); + try { + $this->assertFalse($smtp->isStarted(), '%s: SMTP should begin non-started'); + $smtp->start(); + $this->assertTrue($smtp->isStarted(), '%s: start() should have started connection'); + } catch (Exception $e) { + $this->fail('220 is a valid SMTP greeting and should be accepted'); + } + } + + public function testBadGreetingCausesException() + { + $buf = $this->_getBuffer(); + $smtp = $this->_getTransport($buf); + $buf->shouldReceive('initialize') + ->once(); + $buf->shouldReceive('readLine') + ->once() + ->with(0) + ->andReturn("554 I'm busy\r\n"); + $this->_finishBuffer($buf); + try { + $this->assertFalse($smtp->isStarted(), '%s: SMTP should begin non-started'); + $smtp->start(); + $this->fail('554 greeting indicates an error and should cause an exception'); + } catch (Exception $e) { + $this->assertFalse($smtp->isStarted(), '%s: start() should have failed'); + } + } + + public function testStartSendsHeloToInitiate() + { + /* -- RFC 2821, 3.2. + + 3.2 Client Initiation + + Once the server has sent the welcoming message and the client has + received it, the client normally sends the EHLO command to the + server, indicating the client's identity. In addition to opening the + session, use of EHLO indicates that the client is able to process + service extensions and requests that the server provide a list of the + extensions it supports. Older SMTP systems which are unable to + support service extensions and contemporary clients which do not + require service extensions in the mail session being initiated, MAY + use HELO instead of EHLO. Servers MUST NOT return the extended + EHLO-style response to a HELO command. For a particular connection + attempt, if the server returns a "command not recognized" response to + EHLO, the client SHOULD be able to fall back and send HELO. + + In the EHLO command the host sending the command identifies itself; + the command may be interpreted as saying "Hello, I am " (and, + in the case of EHLO, "and I support service extension requests"). + + -- RFC 2281, 4.1.1.1. + + ehlo = "EHLO" SP Domain CRLF + helo = "HELO" SP Domain CRLF + + -- RFC 2821, 4.3.2. + + EHLO or HELO + S: 250 + E: 504, 550 + + */ + + $buf = $this->_getBuffer(); + $smtp = $this->_getTransport($buf); + + $buf->shouldReceive('initialize') + ->once(); + $buf->shouldReceive('readLine') + ->once() + ->with(0) + ->andReturn("220 some.server.tld bleh\r\n"); + $buf->shouldReceive('write') + ->once() + ->with('~^HELO .*?\r\n$~D') + ->andReturn(1); + $buf->shouldReceive('readLine') + ->once() + ->with(1) + ->andReturn('250 ServerName' . "\r\n"); + + $this->_finishBuffer($buf); + try { + $smtp->start(); + } catch (Exception $e) { + $this->fail('Starting SMTP should send HELO and accept 250 response'); + } + } + + public function testInvalidHeloResponseCausesException() + { + $buf = $this->_getBuffer(); + $smtp = $this->_getTransport($buf); + + $buf->shouldReceive('initialize') + ->once(); + $buf->shouldReceive('readLine') + ->once() + ->with(0) + ->andReturn("220 some.server.tld bleh\r\n"); + $buf->shouldReceive('write') + ->once() + ->with('~^HELO .*?\r\n$~D') + ->andReturn(1); + $buf->shouldReceive('readLine') + ->once() + ->with(1) + ->andReturn('504 WTF' . "\r\n"); + + $this->_finishBuffer($buf); + try { + $this->assertFalse($smtp->isStarted(), '%s: SMTP should begin non-started'); + $smtp->start(); + $this->fail('Non 250 HELO response should raise Exception'); + } catch (Exception $e) { + $this->assertFalse($smtp->isStarted(), '%s: SMTP start() should have failed'); + } + } + + public function testDomainNameIsPlacedInHelo() + { + /* -- RFC 2821, 4.1.4. + + The SMTP client MUST, if possible, ensure that the domain parameter + to the EHLO command is a valid principal host name (not a CNAME or MX + name) for its host. If this is not possible (e.g., when the client's + address is dynamically assigned and the client does not have an + obvious name), an address literal SHOULD be substituted for the + domain name and supplemental information provided that will assist in + identifying the client. + */ + + $buf = $this->_getBuffer(); + $smtp = $this->_getTransport($buf); + + $buf->shouldReceive('initialize') + ->once(); + $buf->shouldReceive('readLine') + ->once() + ->with(0) + ->andReturn("220 some.server.tld bleh\r\n"); + $buf->shouldReceive('write') + ->once() + ->with("HELO mydomain.com\r\n") + ->andReturn(1); + $buf->shouldReceive('readLine') + ->once() + ->with(1) + ->andReturn('250 ServerName' . "\r\n"); + + $this->_finishBuffer($buf); + $smtp->setLocalDomain('mydomain.com'); + $smtp->start(); + } + + public function testSuccessfulMailCommand() + { + /* -- RFC 2821, 3.3. + + There are three steps to SMTP mail transactions. The transaction + starts with a MAIL command which gives the sender identification. + + ..... + + The first step in the procedure is the MAIL command. + + MAIL FROM: [SP ] + + -- RFC 2821, 4.1.1.2. + + Syntax: + + "MAIL FROM:" ("<>" / Reverse-Path) + [SP Mail-parameters] CRLF + -- RFC 2821, 4.1.2. + + Reverse-path = Path + Forward-path = Path + Path = "<" [ A-d-l ":" ] Mailbox ">" + A-d-l = At-domain *( "," A-d-l ) + ; Note that this form, the so-called "source route", + ; MUST BE accepted, SHOULD NOT be generated, and SHOULD be + ; ignored. + At-domain = "@" domain + + -- RFC 2821, 4.3.2. + + MAIL + S: 250 + E: 552, 451, 452, 550, 553, 503 + */ + + $buf = $this->_getBuffer(); + $smtp = $this->_getTransport($buf); + $message = $this->_createMessage(); + $message->shouldReceive('getFrom') + ->once() + ->andReturn(array('me@domain.com' => 'Me')); + $message->shouldReceive('getTo') + ->once() + ->andReturn(array('foo@bar' => null)); + $buf->shouldReceive('initialize') + ->once(); + $buf->shouldReceive('write') + ->once() + ->with("MAIL FROM: \r\n") + ->andReturn(1); + $buf->shouldReceive('readLine') + ->once() + ->with(1) + ->andReturn("250 OK\r\n"); + + $this->_finishBuffer($buf); + try { + $smtp->start(); + $smtp->send($message); + } catch (Exception $e) { + $this->fail('MAIL FROM should accept a 250 response'); + } + } + + public function testInvalidResponseCodeFromMailCausesException() + { + $buf = $this->_getBuffer(); + $smtp = $this->_getTransport($buf); + $message = $this->_createMessage(); + + $message->shouldReceive('getFrom') + ->once() + ->andReturn(array('me@domain.com' => 'Me')); + $message->shouldReceive('getTo') + ->once() + ->andReturn(array('foo@bar' => null)); + $buf->shouldReceive('write') + ->once() + ->with("MAIL FROM: \r\n") + ->andReturn(1); + $buf->shouldReceive('readLine') + ->once() + ->with(1) + ->andReturn('553 Bad' . "\r\n"); + + $this->_finishBuffer($buf); + try { + $smtp->start(); + $smtp->send($message); + $this->fail('MAIL FROM should accept a 250 response'); + } catch (Exception $e) { + } + } + + public function testSenderIsPreferredOverFrom() + { + $buf = $this->_getBuffer(); + $smtp = $this->_getTransport($buf); + $message = $this->_createMessage(); + + $message->shouldReceive('getFrom') + ->once() + ->andReturn(array('me@domain.com' => 'Me')); + $message->shouldReceive('getSender') + ->once() + ->andReturn(array('another@domain.com'=>'Someone')); + $message->shouldReceive('getTo') + ->once() + ->andReturn(array('foo@bar' => null)); + $buf->shouldReceive('write') + ->once() + ->with("MAIL FROM: \r\n") + ->andReturn(1); + $buf->shouldReceive('readLine') + ->once() + ->with(1) + ->andReturn('250 OK' . "\r\n"); + + $this->_finishBuffer($buf); + $smtp->start(); + $smtp->send($message); + } + + public function testReturnPathIsPreferredOverSender() + { + $buf = $this->_getBuffer(); + $smtp = $this->_getTransport($buf); + $message = $this->_createMessage(); + + $message->shouldReceive('getFrom') + ->once() + ->andReturn(array('me@domain.com' => 'Me')); + $message->shouldReceive('getSender') + ->once() + ->andReturn(array('another@domain.com'=>'Someone')); + $message->shouldReceive('getReturnPath') + ->once() + ->andReturn('more@domain.com'); + $message->shouldReceive('getTo') + ->once() + ->andReturn(array('foo@bar' => null)); + $buf->shouldReceive('write') + ->once() + ->with("MAIL FROM: \r\n") + ->andReturn(1); + $buf->shouldReceive('readLine') + ->once() + ->with(1) + ->andReturn('250 OK' . "\r\n"); + + $this->_finishBuffer($buf); + $smtp->start(); + $smtp->send($message); + } + + public function testSuccessfulRcptCommandWith250Response() + { + /* -- RFC 2821, 3.3. + + The second step in the procedure is the RCPT command. + + RCPT TO: [ SP ] + + The first or only argument to this command includes a forward-path + (normally a mailbox and domain, always surrounded by "<" and ">" + brackets) identifying one recipient. If accepted, the SMTP server + returns a 250 OK reply and stores the forward-path. If the recipient + is known not to be a deliverable address, the SMTP server returns a + 550 reply, typically with a string such as "no such user - " and the + mailbox name (other circumstances and reply codes are possible). + This step of the procedure can be repeated any number of times. + + -- RFC 2821, 4.1.1.3. + + This command is used to identify an individual recipient of the mail + data; multiple recipients are specified by multiple use of this + command. The argument field contains a forward-path and may contain + optional parameters. + + The forward-path normally consists of the required destination + mailbox. Sending systems SHOULD not generate the optional list of + hosts known as a source route. + + ....... + + "RCPT TO:" ("" / "" / Forward-Path) + [SP Rcpt-parameters] CRLF + + -- RFC 2821, 4.2.2. + + 250 Requested mail action okay, completed + 251 User not local; will forward to + (See section 3.4) + 252 Cannot VRFY user, but will accept message and attempt + delivery + + -- RFC 2821, 4.3.2. + + RCPT + S: 250, 251 (but see section 3.4 for discussion of 251 and 551) + E: 550, 551, 552, 553, 450, 451, 452, 503, 550 + */ + + //We'll treat 252 as accepted since it isn't really a failure + + $buf = $this->_getBuffer(); + $smtp = $this->_getTransport($buf); + $message = $this->_createMessage(); + + $message->shouldReceive('getFrom') + ->once() + ->andReturn(array('me@domain.com' => 'Me')); + $message->shouldReceive('getTo') + ->once() + ->andReturn(array('foo@bar' => null)); + $buf->shouldReceive('write') + ->once() + ->with("MAIL FROM: \r\n") + ->andReturn(1); + $buf->shouldReceive('readLine') + ->once() + ->with(1) + ->andReturn('250 OK' . "\r\n"); + $buf->shouldReceive('write') + ->once() + ->with("RCPT TO: \r\n") + ->andReturn(2); + $buf->shouldReceive('readLine') + ->once() + ->with(2) + ->andReturn('250 OK' . "\r\n"); + + $this->_finishBuffer($buf); + try { + $smtp->start(); + $smtp->send($message); + } catch (Exception $e) { + $this->fail('RCPT TO should accept a 250 response'); + } + } + + public function testMailFromCommandIsOnlySentOncePerMessage() + { + $buf = $this->_getBuffer(); + $smtp = $this->_getTransport($buf); + $message = $this->_createMessage(); + + $message->shouldReceive('getFrom') + ->once() + ->andReturn(array('me@domain.com' => 'Me')); + $message->shouldReceive('getTo') + ->once() + ->andReturn(array('foo@bar' => null)); + $buf->shouldReceive('write') + ->once() + ->with("MAIL FROM: \r\n") + ->andReturn(1); + $buf->shouldReceive('readLine') + ->once() + ->with(1) + ->andReturn('250 OK' . "\r\n"); + $buf->shouldReceive('write') + ->once() + ->with("RCPT TO: \r\n") + ->andReturn(2); + $buf->shouldReceive('readLine') + ->once() + ->with(2) + ->andReturn('250 OK' . "\r\n"); + $buf->shouldReceive('write') + ->never() + ->with("MAIL FROM: \r\n"); + + $this->_finishBuffer($buf); + $smtp->start(); + $smtp->send($message); + } + + public function testMultipleRecipientsSendsMultipleRcpt() + { + $buf = $this->_getBuffer(); + $smtp = $this->_getTransport($buf); + $message = $this->_createMessage(); + + $message->shouldReceive('getFrom') + ->once() + ->andReturn(array('me@domain.com' => 'Me')); + $message->shouldReceive('getTo') + ->once() + ->andReturn(array( + 'foo@bar' => null, + 'zip@button' => 'Zip Button', + 'test@domain' => 'Test user' + )); + $buf->shouldReceive('write') + ->once() + ->with("RCPT TO: \r\n") + ->andReturn(1); + $buf->shouldReceive('readLine') + ->once() + ->with(1) + ->andReturn('250 OK' . "\r\n"); + $buf->shouldReceive('write') + ->once() + ->with("RCPT TO: \r\n") + ->andReturn(2); + $buf->shouldReceive('readLine') + ->once() + ->with(2) + ->andReturn('250 OK' . "\r\n"); + $buf->shouldReceive('write') + ->once() + ->with("RCPT TO: \r\n") + ->andReturn(3); + $buf->shouldReceive('readLine') + ->once() + ->with(3) + ->andReturn('250 OK' . "\r\n"); + + $this->_finishBuffer($buf); + $smtp->start(); + $smtp->send($message); + } + + public function testCcRecipientsSendsMultipleRcpt() + { + $buf = $this->_getBuffer(); + $smtp = $this->_getTransport($buf); + $message = $this->_createMessage(); + + $message->shouldReceive('getFrom') + ->once() + ->andReturn(array('me@domain.com' => 'Me')); + $message->shouldReceive('getTo') + ->once() + ->andReturn(array('foo@bar' => null)); + $message->shouldReceive('getCc') + ->once() + ->andReturn(array( + 'zip@button' => 'Zip Button', + 'test@domain' => 'Test user' + )); + $buf->shouldReceive('write') + ->once() + ->with("RCPT TO: \r\n") + ->andReturn(1); + $buf->shouldReceive('readLine') + ->once() + ->with(1) + ->andReturn('250 OK' . "\r\n"); + $buf->shouldReceive('write') + ->once() + ->with("RCPT TO: \r\n") + ->andReturn(2); + $buf->shouldReceive('readLine') + ->once() + ->with(2) + ->andReturn('250 OK' . "\r\n"); + $buf->shouldReceive('write') + ->once() + ->with("RCPT TO: \r\n") + ->andReturn(3); + $buf->shouldReceive('readLine') + ->once() + ->with(3) + ->andReturn('250 OK' . "\r\n"); + + $this->_finishBuffer($buf); + $smtp->start(); + $smtp->send($message); + } + + public function testSendReturnsNumberOfSuccessfulRecipients() + { + $buf = $this->_getBuffer(); + $smtp = $this->_getTransport($buf); + $message = $this->_createMessage(); + + $message->shouldReceive('getFrom') + ->once() + ->andReturn(array('me@domain.com' => 'Me')); + $message->shouldReceive('getTo') + ->once() + ->andReturn(array('foo@bar' => null)); + $message->shouldReceive('getCc') + ->once() + ->andReturn(array( + 'zip@button' => 'Zip Button', + 'test@domain' => 'Test user' + )); + $buf->shouldReceive('write') + ->once() + ->with("RCPT TO: \r\n") + ->andReturn(1); + $buf->shouldReceive('readLine') + ->once() + ->with(1) + ->andReturn('250 OK' . "\r\n"); + $buf->shouldReceive('write') + ->once() + ->with("RCPT TO: \r\n") + ->andReturn(2); + $buf->shouldReceive('readLine') + ->once() + ->with(2) + ->andReturn('501 Nobody here' . "\r\n"); + $buf->shouldReceive('write') + ->once() + ->with("RCPT TO: \r\n") + ->andReturn(3); + $buf->shouldReceive('readLine') + ->once() + ->with(3) + ->andReturn('250 OK' . "\r\n"); + + $this->_finishBuffer($buf); + $smtp->start(); + $this->assertEquals(2, $smtp->send($message), + '%s: 1 of 3 recipients failed so 2 should be returned' + ); + } + + public function testRsetIsSentIfNoSuccessfulRecipients() + { + /* --RFC 2821, 4.1.1.5. + + This command specifies that the current mail transaction will be + aborted. Any stored sender, recipients, and mail data MUST be + discarded, and all buffers and state tables cleared. The receiver + MUST send a "250 OK" reply to a RSET command with no arguments. A + reset command may be issued by the client at any time. + + -- RFC 2821, 4.3.2. + + RSET + S: 250 + */ + + $buf = $this->_getBuffer(); + $smtp = $this->_getTransport($buf); + $message = $this->_createMessage(); + + $message->shouldReceive('getFrom') + ->once() + ->andReturn(array('me@domain.com' => 'Me')); + $message->shouldReceive('getTo') + ->once() + ->andReturn(array('foo@bar' => null)); + $buf->shouldReceive('write') + ->once() + ->with("RCPT TO: \r\n") + ->andReturn(1); + $buf->shouldReceive('readLine') + ->once() + ->with(1) + ->andReturn('503 Bad' . "\r\n"); + $buf->shouldReceive('write') + ->once() + ->with("RSET\r\n") + ->andReturn(2); + $buf->shouldReceive('readLine') + ->once() + ->with(2) + ->andReturn('250 OK' . "\r\n"); + + $this->_finishBuffer($buf); + $smtp->start(); + $this->assertEquals(0, $smtp->send($message), + '%s: 1 of 1 recipients failed so 0 should be returned' + ); + } + + public function testSuccessfulDataCommand() + { + /* -- RFC 2821, 3.3. + + The third step in the procedure is the DATA command (or some + alternative specified in a service extension). + + DATA + + If accepted, the SMTP server returns a 354 Intermediate reply and + considers all succeeding lines up to but not including the end of + mail data indicator to be the message text. + + -- RFC 2821, 4.1.1.4. + + The receiver normally sends a 354 response to DATA, and then treats + the lines (strings ending in sequences, as described in + section 2.3.7) following the command as mail data from the sender. + This command causes the mail data to be appended to the mail data + buffer. The mail data may contain any of the 128 ASCII character + codes, although experience has indicated that use of control + characters other than SP, HT, CR, and LF may cause problems and + SHOULD be avoided when possible. + + -- RFC 2821, 4.3.2. + + DATA + I: 354 -> data -> S: 250 + E: 552, 554, 451, 452 + E: 451, 554, 503 + */ + + $buf = $this->_getBuffer(); + $smtp = $this->_getTransport($buf); + $message = $this->_createMessage(); + + $message->shouldReceive('getFrom') + ->once() + ->andReturn(array('me@domain.com' => 'Me')); + $message->shouldReceive('getTo') + ->once() + ->andReturn(array('foo@bar' => null)); + $buf->shouldReceive('write') + ->once() + ->with("DATA\r\n") + ->andReturn(1); + $buf->shouldReceive('readLine') + ->once() + ->with(1) + ->andReturn('354 Go ahead' . "\r\n"); + + $this->_finishBuffer($buf); + try { + $smtp->start(); + $smtp->send($message); + } catch (Exception $e) { + $this->fail('354 is the expected response to DATA'); + } + } + + public function testBadDataResponseCausesException() + { + $buf = $this->_getBuffer(); + $smtp = $this->_getTransport($buf); + $message = $this->_createMessage(); + + $message->shouldReceive('getFrom') + ->once() + ->andReturn(array('me@domain.com' => 'Me')); + $message->shouldReceive('getTo') + ->once() + ->andReturn(array('foo@bar' => null)); + $buf->shouldReceive('write') + ->once() + ->with("DATA\r\n") + ->andReturn(1); + $buf->shouldReceive('readLine') + ->once() + ->with(1) + ->andReturn('451 Bad' . "\r\n"); + + $this->_finishBuffer($buf); + try { + $smtp->start(); + $smtp->send($message); + $this->fail('354 is the expected response to DATA (not observed)'); + } catch (Exception $e) { + } + } + + public function testMessageIsStreamedToBufferForData() + { + $buf = $this->_getBuffer(); + $smtp = $this->_getTransport($buf); + $message = $this->_createMessage(); + + $message->shouldReceive('getFrom') + ->once() + ->andReturn(array('me@domain.com' => 'Me')); + $message->shouldReceive('getTo') + ->once() + ->andReturn(array('foo@bar' => null)); + $buf->shouldReceive('write') + ->once() + ->with("DATA\r\n") + ->andReturn(1); + $buf->shouldReceive('readLine') + ->once() + ->with(1) + ->andReturn('354 OK' . "\r\n"); + $buf->shouldReceive('write') + ->once() + ->with("\r\n.\r\n") + ->andReturn(2); + $buf->shouldReceive('readLine') + ->once() + ->with(2) + ->andReturn('250 OK' . "\r\n"); + + $this->_finishBuffer($buf); + $smtp->start(); + $smtp->send($message); + } + + public function testBadResponseAfterDataTransmissionCausesException() + { + $buf = $this->_getBuffer(); + $smtp = $this->_getTransport($buf); + $message = $this->_createMessage(); + + $message->shouldReceive('getFrom') + ->once() + ->andReturn(array('me@domain.com' => 'Me')); + $message->shouldReceive('getTo') + ->once() + ->andReturn(array('foo@bar' => null)); + $buf->shouldReceive('write') + ->once() + ->with("DATA\r\n") + ->andReturn(1); + $buf->shouldReceive('readLine') + ->once() + ->with(1) + ->andReturn('354 OK' . "\r\n"); + $buf->shouldReceive('write') + ->once() + ->with("\r\n.\r\n") + ->andReturn(2); + $buf->shouldReceive('readLine') + ->once() + ->with(2) + ->andReturn('554 Error' . "\r\n"); + + $this->_finishBuffer($buf); + try { + $smtp->start(); + $smtp->send($message); + $this->fail('250 is the expected response after a DATA transmission (not observed)'); + } catch (Exception $e) { + } + } + + public function testBccRecipientsAreRemovedFromHeaders() + { + /* -- RFC 2821, 7.2. + + Addresses that do not appear in the message headers may appear in the + RCPT commands to an SMTP server for a number of reasons. The two + most common involve the use of a mailing address as a "list exploder" + (a single address that resolves into multiple addresses) and the + appearance of "blind copies". Especially when more than one RCPT + command is present, and in order to avoid defeating some of the + purpose of these mechanisms, SMTP clients and servers SHOULD NOT copy + the full set of RCPT command arguments into the headers, either as + part of trace headers or as informational or private-extension + headers. Since this rule is often violated in practice, and cannot + be enforced, sending SMTP systems that are aware of "bcc" use MAY + find it helpful to send each blind copy as a separate message + transaction containing only a single RCPT command. + */ + + $buf = $this->_getBuffer(); + $smtp = $this->_getTransport($buf); + $message = $this->_createMessage(); + $message->shouldReceive('getFrom') + ->zeroOrMoreTimes() + ->andReturn(array('me@domain.com' => 'Me')); + $message->shouldReceive('getTo') + ->zeroOrMoreTimes() + ->andReturn(array('foo@bar' => null)); + $message->shouldReceive('getBcc') + ->zeroOrMoreTimes() + ->andReturn(array( + 'zip@button' => 'Zip Button', + 'test@domain' => 'Test user' + )); + $message->shouldReceive('setBcc') + ->once() + ->with(array()); + $message->shouldReceive('setBcc') + ->zeroOrMoreTimes(); + + $this->_finishBuffer($buf); + $smtp->start(); + $smtp->send($message); + } + + public function testEachBccRecipientIsSentASeparateMessage() + { + $buf = $this->_getBuffer(); + $smtp = $this->_getTransport($buf); + $message = $this->_createMessage(); + + $message->shouldReceive('getFrom') + ->zeroOrMoreTimes() + ->andReturn(array('me@domain.com' => 'Me')); + $message->shouldReceive('getTo') + ->zeroOrMoreTimes() + ->andReturn(array('foo@bar' => null)); + $message->shouldReceive('getBcc') + ->zeroOrMoreTimes() + ->andReturn(array( + 'zip@button' => 'Zip Button', + 'test@domain' => 'Test user' + )); + $message->shouldReceive('setBcc') + ->atLeast()->once() + ->with(array()); + $message->shouldReceive('setBcc') + ->once() + ->with(array('zip@button' => 'Zip Button')); + $message->shouldReceive('setBcc') + ->once() + ->with(array('test@domain' => 'Test user')); + $message->shouldReceive('setBcc') + ->atLeast()->once() + ->with(array( + 'zip@button' => 'Zip Button', + 'test@domain' => 'Test user' + )); + + $buf->shouldReceive('write')->once()->with("MAIL FROM: \r\n")->andReturn(1); + $buf->shouldReceive('readLine')->once()->with(1)->andReturn("250 OK\r\n"); + $buf->shouldReceive('write')->once()->with("RCPT TO: \r\n")->andReturn(2); + $buf->shouldReceive('readLine')->once()->with(2)->andReturn("250 OK\r\n"); + $buf->shouldReceive('write')->once()->with("DATA\r\n")->andReturn(3); + $buf->shouldReceive('readLine')->once()->with(3)->andReturn("354 OK\r\n"); + $buf->shouldReceive('write')->once()->with("\r\n.\r\n")->andReturn(4); + $buf->shouldReceive('readLine')->once()->with(4)->andReturn("250 OK\r\n"); + + $buf->shouldReceive('write')->once()->with("MAIL FROM: \r\n")->andReturn(5); + $buf->shouldReceive('readLine')->once()->with(5)->andReturn("250 OK\r\n"); + $buf->shouldReceive('write')->once()->with("RCPT TO: \r\n")->andReturn(6); + $buf->shouldReceive('readLine')->once()->with(6)->andReturn("250 OK\r\n"); + $buf->shouldReceive('write')->once()->with("DATA\r\n")->andReturn(7); + $buf->shouldReceive('readLine')->once()->with(7)->andReturn("354 OK\r\n"); + $buf->shouldReceive('write')->once()->with("\r\n.\r\n")->andReturn(8); + $buf->shouldReceive('readLine')->once()->with(8)->andReturn("250 OK\r\n"); + + $buf->shouldReceive('write')->once()->with("MAIL FROM: \r\n")->andReturn(9); + $buf->shouldReceive('readLine')->once()->with(9)->andReturn("250 OK\r\n"); + $buf->shouldReceive('write')->once()->with("RCPT TO: \r\n")->andReturn(10); + $buf->shouldReceive('readLine')->once()->with(10)->andReturn("250 OK\r\n"); + $buf->shouldReceive('write')->once()->with("DATA\r\n")->andReturn(11); + $buf->shouldReceive('readLine')->once()->with(11)->andReturn("354 OK\r\n"); + $buf->shouldReceive('write')->once()->with("\r\n.\r\n")->andReturn(12); + $buf->shouldReceive('readLine')->once()->with(12)->andReturn("250 OK\r\n"); + + $this->_finishBuffer($buf); + $smtp->start(); + $this->assertEquals(3, $smtp->send($message)); + } + + public function testMessageStateIsRestoredOnFailure() + { + $buf = $this->_getBuffer(); + $smtp = $this->_getTransport($buf); + $message = $this->_createMessage(); + + $message->shouldReceive('getFrom') + ->zeroOrMoreTimes() + ->andReturn(array('me@domain.com' => 'Me')); + $message->shouldReceive('getTo') + ->zeroOrMoreTimes() + ->andReturn(array('foo@bar' => null)); + $message->shouldReceive('getBcc') + ->zeroOrMoreTimes() + ->andReturn(array( + 'zip@button' => 'Zip Button', + 'test@domain' => 'Test user' + )); + $message->shouldReceive('setBcc') + ->once() + ->with(array()); + $message->shouldReceive('setBcc') + ->once() + ->with(array( + 'zip@button' => 'Zip Button', + 'test@domain' => 'Test user' + )); + $buf->shouldReceive('write') + ->once() + ->with("MAIL FROM: \r\n") + ->andReturn(1); + $buf->shouldReceive('readLine') + ->once() + ->with(1) + ->andReturn("250 OK\r\n"); + $buf->shouldReceive('write') + ->once() + ->with("RCPT TO: \r\n") + ->andReturn(2); + $buf->shouldReceive('readLine') + ->once() + ->with(2) + ->andReturn("250 OK\r\n"); + $buf->shouldReceive('write') + ->once() + ->with("DATA\r\n") + ->andReturn(3); + $buf->shouldReceive('readLine') + ->once() + ->with(3) + ->andReturn("451 No\r\n"); + + $this->_finishBuffer($buf); + + $smtp->start(); + try { + $smtp->send($message); + $this->fail('A bad response was given so exception is expected'); + } catch (Exception $e) { + } + } + + public function testStopSendsQuitCommand() + { + /* -- RFC 2821, 4.1.1.10. + + This command specifies that the receiver MUST send an OK reply, and + then close the transmission channel. + + The receiver MUST NOT intentionally close the transmission channel + until it receives and replies to a QUIT command (even if there was an + error). The sender MUST NOT intentionally close the transmission + channel until it sends a QUIT command and SHOULD wait until it + receives the reply (even if there was an error response to a previous + command). If the connection is closed prematurely due to violations + of the above or system or network failure, the server MUST cancel any + pending transaction, but not undo any previously completed + transaction, and generally MUST act as if the command or transaction + in progress had received a temporary error (i.e., a 4yz response). + + The QUIT command may be issued at any time. + + Syntax: + "QUIT" CRLF + */ + + $buf = $this->_getBuffer(); + $smtp = $this->_getTransport($buf); + $message = $this->_createMessage(); + $buf->shouldReceive('initialize') + ->once(); + $buf->shouldReceive('write') + ->once() + ->with("QUIT\r\n") + ->andReturn(1); + $buf->shouldReceive('readLine') + ->once() + ->with(1) + ->andReturn("221 Bye\r\n"); + $buf->shouldReceive('terminate') + ->once(); + + $this->_finishBuffer($buf); + + $this->assertFalse($smtp->isStarted()); + $smtp->start(); + $this->assertTrue($smtp->isStarted()); + $smtp->stop(); + $this->assertFalse($smtp->isStarted()); + } + + public function testBufferCanBeFetched() + { + $buf = $this->_getBuffer(); + $smtp = $this->_getTransport($buf); + $ref = $smtp->getBuffer(); + $this->assertEquals($buf, $ref); + } + + public function testBufferCanBeWrittenToUsingExecuteCommand() + { + $buf = $this->_getBuffer(); + $smtp = $this->_getTransport($buf); + $message = $this->_createMessage(); + $buf->shouldReceive('write') + ->zeroOrMoreTimes() + ->with("FOO\r\n") + ->andReturn(1); + $buf->shouldReceive('readLine') + ->zeroOrMoreTimes() + ->with(1) + ->andReturn("250 OK\r\n"); + + $res = $smtp->executeCommand("FOO\r\n"); + $this->assertEquals("250 OK\r\n", $res); + } + + public function testResponseCodesAreValidated() + { + $buf = $this->_getBuffer(); + $smtp = $this->_getTransport($buf); + $message = $this->_createMessage(); + $buf->shouldReceive('write') + ->zeroOrMoreTimes() + ->with("FOO\r\n") + ->andReturn(1); + $buf->shouldReceive('readLine') + ->zeroOrMoreTimes() + ->with(1) + ->andReturn("551 Not ok\r\n"); + + try { + $smtp->executeCommand("FOO\r\n", array(250, 251)); + $this->fail('A 250 or 251 response was needed but 551 was returned.'); + } catch (Exception $e) { + } + } + + public function testFailedRecipientsCanBeCollectedByReference() + { + $buf = $this->_getBuffer(); + $smtp = $this->_getTransport($buf); + $message = $this->_createMessage(); + + $message->shouldReceive('getFrom') + ->zeroOrMoreTimes() + ->andReturn(array('me@domain.com' => 'Me')); + $message->shouldReceive('getTo') + ->zeroOrMoreTimes() + ->andReturn(array('foo@bar' => null)); + $message->shouldReceive('getBcc') + ->zeroOrMoreTimes() + ->andReturn(array( + 'zip@button' => 'Zip Button', + 'test@domain' => 'Test user' + )); + $message->shouldReceive('setBcc') + ->atLeast()->once() + ->with(array()); + $message->shouldReceive('setBcc') + ->once() + ->with(array('zip@button' => 'Zip Button')); + $message->shouldReceive('setBcc') + ->once() + ->with(array('test@domain' => 'Test user')); + $message->shouldReceive('setBcc') + ->atLeast()->once() + ->with(array( + 'zip@button' => 'Zip Button', + 'test@domain' => 'Test user' + )); + + $buf->shouldReceive('write')->once()->with("MAIL FROM: \r\n")->andReturn(1); + $buf->shouldReceive('readLine')->once()->with(1)->andReturn("250 OK\r\n"); + $buf->shouldReceive('write')->once()->with("RCPT TO: \r\n")->andReturn(2); + $buf->shouldReceive('readLine')->once()->with(2)->andReturn("250 OK\r\n"); + $buf->shouldReceive('write')->once()->with("DATA\r\n")->andReturn(3); + $buf->shouldReceive('readLine')->once()->with(3)->andReturn("354 OK\r\n"); + $buf->shouldReceive('write')->once()->with("\r\n.\r\n")->andReturn(4); + $buf->shouldReceive('readLine')->once()->with(4)->andReturn("250 OK\r\n"); + + $buf->shouldReceive('write')->once()->with("MAIL FROM: \r\n")->andReturn(5); + $buf->shouldReceive('readLine')->once()->with(5)->andReturn("250 OK\r\n"); + $buf->shouldReceive('write')->once()->with("RCPT TO: \r\n")->andReturn(6); + $buf->shouldReceive('readLine')->once()->with(6)->andReturn("500 Bad\r\n"); + $buf->shouldReceive('write')->once()->with("RSET\r\n")->andReturn(7); + $buf->shouldReceive('readLine')->once()->with(7)->andReturn("250 OK\r\n"); + + $buf->shouldReceive('write')->once()->with("MAIL FROM: \r\n")->andReturn(9); + $buf->shouldReceive('readLine')->once()->with(9)->andReturn("250 OK\r\n"); + $buf->shouldReceive('write')->once()->with("RCPT TO: \r\n")->andReturn(10); + $buf->shouldReceive('readLine')->once()->with(10)->andReturn("500 Bad\r\n"); + $buf->shouldReceive('write')->once()->with("RSET\r\n")->andReturn(11); + $buf->shouldReceive('readLine')->once()->with(11)->andReturn("250 OK\r\n"); + + $this->_finishBuffer($buf); + $smtp->start(); + $this->assertEquals(1, $smtp->send($message, $failures)); + $this->assertEquals(array('zip@button', 'test@domain'), $failures, + '%s: Failures should be caught in an array' + ); + } + + public function testSendingRegeneratesMessageId() + { + $buf = $this->_getBuffer(); + $smtp = $this->_getTransport($buf); + $message = $this->_createMessage(); + $message->shouldReceive('getFrom') + ->zeroOrMoreTimes() + ->andReturn(array('me@domain.com'=>'Me')); + $message->shouldReceive('getTo') + ->zeroOrMoreTimes() + ->andReturn(array('foo@bar'=>null)); + $message->shouldReceive('generateId') + ->once(); + + $this->_finishBuffer($buf); + $smtp->start(); + $smtp->send($message); + } + + // -- Protected methods + + protected function _getBuffer() + { + return $this->getMockery('Swift_Transport_IoBuffer')->shouldIgnoreMissing(); + } + + protected function _createMessage() + { + return $this->getMockery('Swift_Mime_Message')->shouldIgnoreMissing(); + } + + protected function _finishBuffer($buf) + { + $buf->shouldReceive('readLine') + ->zeroOrMoreTimes() + ->with(0) + ->andReturn('220 server.com foo' . "\r\n"); + $buf->shouldReceive('write') + ->zeroOrMoreTimes() + ->with('~^(EH|HE)LO .*?\r\n$~D') + ->andReturn($x = uniqid()); + $buf->shouldReceive('readLine') + ->zeroOrMoreTimes() + ->with($x) + ->andReturn('250 ServerName' . "\r\n"); + $buf->shouldReceive('write') + ->zeroOrMoreTimes() + ->with('~^MAIL FROM: <.*?>\r\n$~D') + ->andReturn($x = uniqid()); + $buf->shouldReceive('readLine') + ->zeroOrMoreTimes() + ->with($x) + ->andReturn("250 OK\r\n"); + $buf->shouldReceive('write') + ->zeroOrMoreTimes() + ->with('~^RCPT TO: <.*?>\r\n$~D') + ->andReturn($x = uniqid()); + $buf->shouldReceive('readLine') + ->zeroOrMoreTimes() + ->with($x) + ->andReturn("250 OK\r\n"); + $buf->shouldReceive('write') + ->zeroOrMoreTimes() + ->with("DATA\r\n") + ->andReturn($x = uniqid()); + $buf->shouldReceive('readLine') + ->zeroOrMoreTimes() + ->with($x) + ->andReturn("354 OK\r\n"); + $buf->shouldReceive('write') + ->zeroOrMoreTimes() + ->with("\r\n.\r\n") + ->andReturn($x = uniqid()); + $buf->shouldReceive('readLine') + ->zeroOrMoreTimes() + ->with($x) + ->andReturn("250 OK\r\n"); + $buf->shouldReceive('write') + ->zeroOrMoreTimes() + ->with("RSET\r\n") + ->andReturn($x = uniqid()); + $buf->shouldReceive('readLine') + ->zeroOrMoreTimes() + ->with($x) + ->andReturn("250 OK\r\n"); + + $buf->shouldReceive('write') + ->zeroOrMoreTimes() + ->andReturn(false); + $buf->shouldReceive('readLine') + ->zeroOrMoreTimes() + ->andReturn(false); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Transport/Esmtp/Auth/CramMd5AuthenticatorTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Transport/Esmtp/Auth/CramMd5AuthenticatorTest.php new file mode 100755 index 0000000..d448e58 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Transport/Esmtp/Auth/CramMd5AuthenticatorTest.php @@ -0,0 +1,66 @@ +_agent = $this->getMockery('Swift_Transport_SmtpAgent')->shouldIgnoreMissing(); + } + + public function testKeywordIsCramMd5() + { + /* -- RFC 2195, 2. + The authentication type associated with CRAM is "CRAM-MD5". + */ + + $cram = $this->_getAuthenticator(); + $this->assertEquals('CRAM-MD5', $cram->getAuthKeyword()); + } + + public function testSuccessfulAuthentication() + { + $cram = $this->_getAuthenticator(); + + $this->_agent->shouldReceive('executeCommand') + ->once() + ->with("AUTH CRAM-MD5\r\n", array(334)) + ->andReturn('334 ' . base64_encode('') . "\r\n"); + $this->_agent->shouldReceive('executeCommand') + ->once() + ->with(\Mockery::any(), array(235)); + + $this->assertTrue($cram->authenticate($this->_agent, 'jack', 'pass'), + '%s: The buffer accepted all commands authentication should succeed' + ); + } + + public function testAuthenticationFailureSendRsetAndReturnFalse() + { + $cram = $this->_getAuthenticator(); + + $this->_agent->shouldReceive('executeCommand') + ->once() + ->with("AUTH CRAM-MD5\r\n", array(334)) + ->andReturn('334 ' . base64_encode('') . "\r\n"); + $this->_agent->shouldReceive('executeCommand') + ->once() + ->with(\Mockery::any(), array(235)) + ->andThrow(new Swift_TransportException("")); + $this->_agent->shouldReceive('executeCommand') + ->once() + ->with("RSET\r\n", array(250)); + + $this->assertFalse($cram->authenticate($this->_agent, 'jack', 'pass'), + '%s: Authentication fails, so RSET should be sent' + ); + } + + // -- Private helpers + + private function _getAuthenticator() + { + return new Swift_Transport_Esmtp_Auth_CramMd5Authenticator(); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Transport/Esmtp/Auth/LoginAuthenticatorTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Transport/Esmtp/Auth/LoginAuthenticatorTest.php new file mode 100755 index 0000000..b655971 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Transport/Esmtp/Auth/LoginAuthenticatorTest.php @@ -0,0 +1,66 @@ +_agent = $this->getMockery('Swift_Transport_SmtpAgent')->shouldIgnoreMissing(); + } + + public function testKeywordIsLogin() + { + $login = $this->_getAuthenticator(); + $this->assertEquals('LOGIN', $login->getAuthKeyword()); + } + + public function testSuccessfulAuthentication() + { + $login = $this->_getAuthenticator(); + + $this->_agent->shouldReceive('executeCommand') + ->once() + ->with("AUTH LOGIN\r\n", array(334)); + $this->_agent->shouldReceive('executeCommand') + ->once() + ->with(base64_encode('jack') . "\r\n", array(334)); + $this->_agent->shouldReceive('executeCommand') + ->once() + ->with(base64_encode('pass') . "\r\n", array(235)); + + $this->assertTrue($login->authenticate($this->_agent, 'jack', 'pass'), + '%s: The buffer accepted all commands authentication should succeed' + ); + } + + public function testAuthenticationFailureSendRsetAndReturnFalse() + { + $login = $this->_getAuthenticator(); + + $this->_agent->shouldReceive('executeCommand') + ->once() + ->with("AUTH LOGIN\r\n", array(334)); + $this->_agent->shouldReceive('executeCommand') + ->once() + ->with(base64_encode('jack') . "\r\n", array(334)); + $this->_agent->shouldReceive('executeCommand') + ->once() + ->with(base64_encode('pass') . "\r\n", array(235)) + ->andThrow(new Swift_TransportException("")); + $this->_agent->shouldReceive('executeCommand') + ->once() + ->with("RSET\r\n", array(250)); + + $this->assertFalse($login->authenticate($this->_agent, 'jack', 'pass'), + '%s: Authentication fails, so RSET should be sent' + ); + } + + // -- Private helpers + + private function _getAuthenticator() + { + return new Swift_Transport_Esmtp_Auth_LoginAuthenticator(); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Transport/Esmtp/Auth/NTLMAuthenticatorTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Transport/Esmtp/Auth/NTLMAuthenticatorTest.php new file mode 100755 index 0000000..f6efbfe --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Transport/Esmtp/Auth/NTLMAuthenticatorTest.php @@ -0,0 +1,233 @@ +markTestSkipped( + 'One of the required functions is not available.' + ); + } + } + + public function testKeywordIsNtlm() + { + $login = $this->_getAuthenticator(); + $this->assertEquals('NTLM', $login->getAuthKeyword()); + } + + public function testMessage1Generator() + { + $login = $this->_getAuthenticator(); + $message1 = $this->_invokePrivateMethod('createMessage1', $login); + + $this->assertEquals($this->_message1, bin2hex($message1), + '%s: We send the smallest ntlm message which should never fail.' + ); + } + + public function testLMv1Generator() + { + $password = "test1234"; + $challenge = "b019d38bad875c9d"; + $lmv1 = "1879f60127f8a877022132ec221bcbf3ca016a9f76095606"; + + $login = $this->_getAuthenticator(); + $lmv1Result = $this->_invokePrivateMethod('createLMPassword', $login, array($password, $this->hex2bin($challenge))); + + $this->assertEquals($lmv1, bin2hex($lmv1Result), + '%s: The keys should be the same cause we use the same values to generate them.' + ); + } + + public function testLMv2Generator() + { + $username = "user"; + $password = "SecREt01"; + $domain = "DOMAIN"; + $challenge = "0123456789abcdef"; + $lmv2 = "d6e6152ea25d03b7c6ba6629c2d6aaf0ffffff0011223344"; + + $login = $this->_getAuthenticator(); + $lmv2Result = $this->_invokePrivateMethod('createLMv2Password', $login, array($password, $username, $domain, $this->hex2bin($challenge), $this->hex2bin("ffffff0011223344"))); + + $this->assertEquals($lmv2, bin2hex($lmv2Result), + '%s: The keys should be the same cause we use the same values to generate them.' + ); + } + + public function testMessage3v1Generator() + { + $username = "test"; + $domain = "TESTNT"; + $workstation = "MEMBER"; + $lmResponse = "1879f60127f8a877022132ec221bcbf3ca016a9f76095606"; + $ntlmResponse = "e6285df3287c5d194f84df1a94817c7282d09754b6f9e02a"; + $message3T = "4e544c4d5353500003000000180018006000000018001800780000000c000c0040000000080008004c0000000c000c0054000000000000009a0000000102000054004500530054004e00540074006500730074004d0045004d004200450052001879f60127f8a877022132ec221bcbf3ca016a9f76095606e6285df3287c5d194f84df1a94817c7282d09754b6f9e02a"; + + $login = $this->_getAuthenticator(); + $message3 = $this->_invokePrivateMethod('createMessage3', $login, array($domain, $username, $workstation, $this->hex2bin($lmResponse), $this->hex2bin($ntlmResponse))); + + $this->assertEquals($message3T, bin2hex($message3), + '%s: We send the same information as the example is created with so this should be the same' + ); + } + + public function testMessage3v2Generator() + { + $username = "test"; + $domain = "TESTNT"; + $workstation = "MEMBER"; + $lmResponse = "bf2e015119f6bdb3f6fdb768aa12d478f5ce3d2401c8f6e9"; + $ntlmResponse = "caa4da8f25d5e840974ed8976d3ada46010100000000000030fa7e3c677bc301f5ce3d2401c8f6e90000000002000c0054004500530054004e00540001000c004d0045004d0042004500520003001e006d0065006d006200650072002e0074006500730074002e0063006f006d000000000000000000"; + + $login = $this->_getAuthenticator(); + $message3 = $this->_invokePrivateMethod('createMessage3', $login, array($domain, $username, $workstation, $this->hex2bin($lmResponse), $this->hex2bin($ntlmResponse))); + + $this->assertEquals($this->_message3, bin2hex($message3), + '%s: We send the same information as the example is created with so this should be the same' + ); + } + + public function testGetDomainAndUsername() + { + $username = "DOMAIN\user"; + + $login = $this->_getAuthenticator(); + list($domain, $user) = $this->_invokePrivateMethod('getDomainAndUsername', $login, array($username)); + + $this->assertEquals('DOMAIN', $domain, + '%s: the fetched domain did not match' + ); + $this->assertEquals('user', $user, + '%s: the fetched user did not match' + ); + } + + public function testGetDomainAndUsernameWithExtension() + { + $username = "domain.com\user"; + + $login = $this->_getAuthenticator(); + list($domain, $user) = $this->_invokePrivateMethod('getDomainAndUsername', $login, array($username)); + + $this->assertEquals('domain.com', $domain, + '%s: the fetched domain did not match' + ); + $this->assertEquals('user', $user, + '%s: the fetched user did not match' + ); + } + + public function testGetDomainAndUsernameWithAtSymbol() + { + $username = "user@DOMAIN"; + + $login = $this->_getAuthenticator(); + list($domain, $user) = $this->_invokePrivateMethod('getDomainAndUsername', $login, array($username)); + + $this->assertEquals('DOMAIN', $domain, + '%s: the fetched domain did not match' + ); + $this->assertEquals('user', $user, + '%s: the fetched user did not match' + ); + } + + public function testGetDomainAndUsernameWithAtSymbolAndExtension() + { + $username = "user@domain.com"; + + $login = $this->_getAuthenticator(); + list($domain, $user) = $this->_invokePrivateMethod('getDomainAndUsername', $login, array($username)); + + $this->assertEquals('domain.com', $domain, + '%s: the fetched domain did not match' + ); + $this->assertEquals('user', $user, + '%s: the fetched user did not match' + ); + } + + public function testSuccessfulAuthentication() + { + $domain = "TESTNT"; + $username = "test"; + $secret = "test1234"; + + $ntlm = $this->_getAuthenticator(); + $agent = $this->_getAgent(); + $agent->shouldReceive('executeCommand') + ->once() + ->with('AUTH NTLM ' . base64_encode( + $this->_invokePrivateMethod('createMessage1', $ntlm) + ) . "\r\n", array(334)) + ->andReturn("334 " . base64_encode($this->hex2bin("4e544c4d53535000020000000c000c003000000035828980514246973ea892c10000000000000000460046003c00000054004500530054004e00540002000c0054004500530054004e00540001000c004d0045004d0042004500520003001e006d0065006d006200650072002e0074006500730074002e0063006f006d0000000000"))); + $agent->shouldReceive('executeCommand') + ->once() + ->with(base64_encode( + $this->_invokePrivateMethod('createMessage3', $ntlm, array($domain, $username, $this->hex2bin("4d0045004d00420045005200"), $this->hex2bin("bf2e015119f6bdb3f6fdb768aa12d478f5ce3d2401c8f6e9"), $this->hex2bin("caa4da8f25d5e840974ed8976d3ada46010100000000000030fa7e3c677bc301f5ce3d2401c8f6e90000000002000c0054004500530054004e00540001000c004d0045004d0042004500520003001e006d0065006d006200650072002e0074006500730074002e0063006f006d000000000000000000")) + )) . "\r\n", array(235)); + + $this->assertTrue($ntlm->authenticate($agent, $username . '@' . $domain, $secret, $this->hex2bin("30fa7e3c677bc301"), $this->hex2bin("f5ce3d2401c8f6e9")), + '%s: The buffer accepted all commands authentication should succeed' + ); + } + + public function testAuthenticationFailureSendRsetAndReturnFalse() + { + $domain = "TESTNT"; + $username = "test"; + $secret = "test1234"; + + $ntlm = $this->_getAuthenticator(); + $agent = $this->_getAgent(); + $agent->shouldReceive('executeCommand') + ->once() + ->with('AUTH NTLM ' . base64_encode( + $this->_invokePrivateMethod('createMessage1', $ntlm) + ) . "\r\n", array(334)) + ->andThrow(new Swift_TransportException("")); + $agent->shouldReceive('executeCommand') + ->once() + ->with("RSET\r\n", array(250)); + + $this->assertFalse($ntlm->authenticate($agent, $username . '@' . $domain, $secret, $this->hex2bin("30fa7e3c677bc301"), $this->hex2bin("f5ce3d2401c8f6e9")), + '%s: Authentication fails, so RSET should be sent' + ); + } + + // -- Private helpers + private function _getAuthenticator() + { + return new Swift_Transport_Esmtp_Auth_NTLMAuthenticator(); + } + + private function _getAgent() + { + return $this->getMockery('Swift_Transport_SmtpAgent')->shouldIgnoreMissing();; + } + + private function _invokePrivateMethod($method, $instance, array $args = array()) + { + $methodC = new ReflectionMethod($instance, trim($method)); + $methodC->setAccessible(true); + + return $methodC->invokeArgs($instance, $args); + } + + /** + * Hex2bin replacement for < PHP 5.4 + * @param string $hex + * @return string Binary + */ + protected function hex2bin($hex) + { + return function_exists('hex2bin') ? hex2bin($hex) : pack('H*', $hex); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Transport/Esmtp/Auth/PlainAuthenticatorTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Transport/Esmtp/Auth/PlainAuthenticatorTest.php new file mode 100755 index 0000000..c85d3a4 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Transport/Esmtp/Auth/PlainAuthenticatorTest.php @@ -0,0 +1,69 @@ +_agent = $this->getMockery('Swift_Transport_SmtpAgent')->shouldIgnoreMissing(); + } + + public function testKeywordIsPlain() + { + /* -- RFC 4616, 1. + The name associated with this mechanism is "PLAIN". + */ + + $login = $this->_getAuthenticator(); + $this->assertEquals('PLAIN', $login->getAuthKeyword()); + } + + public function testSuccessfulAuthentication() + { + /* -- RFC 4616, 2. + The client presents the authorization identity (identity to act as), + followed by a NUL (U+0000) character, followed by the authentication + identity (identity whose password will be used), followed by a NUL + (U+0000) character, followed by the clear-text password. + */ + + $plain = $this->_getAuthenticator(); + + $this->_agent->shouldReceive('executeCommand') + ->once() + ->with('AUTH PLAIN ' . base64_encode( + 'jack' . chr(0) . 'jack' . chr(0) . 'pass' + ) . "\r\n", array(235)); + + $this->assertTrue($plain->authenticate($this->_agent, 'jack', 'pass'), + '%s: The buffer accepted all commands authentication should succeed' + ); + } + + public function testAuthenticationFailureSendRsetAndReturnFalse() + { + $plain = $this->_getAuthenticator(); + + $this->_agent->shouldReceive('executeCommand') + ->once() + ->with('AUTH PLAIN ' . base64_encode( + 'jack' . chr(0) . 'jack' . chr(0) . 'pass' + ) . "\r\n", array(235)) + ->andThrow(new Swift_TransportException("")); + $this->_agent->shouldReceive('executeCommand') + ->once() + ->with("RSET\r\n", array(250)); + + $this->assertFalse($plain->authenticate($this->_agent, 'jack', 'pass'), + '%s: Authentication fails, so RSET should be sent' + ); + } + + // -- Private helpers + + private function _getAuthenticator() + { + return new Swift_Transport_Esmtp_Auth_PlainAuthenticator(); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Transport/Esmtp/AuthHandlerTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Transport/Esmtp/AuthHandlerTest.php new file mode 100755 index 0000000..6157ea3 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Transport/Esmtp/AuthHandlerTest.php @@ -0,0 +1,168 @@ +_agent = $this->getMockery('Swift_Transport_SmtpAgent')->shouldIgnoreMissing(); + } + + public function testKeywordIsAuth() + { + $auth = $this->_createHandler(array()); + $this->assertEquals('AUTH', $auth->getHandledKeyword()); + } + + public function testUsernameCanBeSetAndFetched() + { + $auth = $this->_createHandler(array()); + $auth->setUsername('jack'); + $this->assertEquals('jack', $auth->getUsername()); + } + + public function testPasswordCanBeSetAndFetched() + { + $auth = $this->_createHandler(array()); + $auth->setPassword('pass'); + $this->assertEquals('pass', $auth->getPassword()); + } + + public function testAuthModeCanBeSetAndFetched() + { + $auth = $this->_createHandler(array()); + $auth->setAuthMode('PLAIN'); + $this->assertEquals('PLAIN', $auth->getAuthMode()); + } + + public function testMixinMethods() + { + $auth = $this->_createHandler(array()); + $mixins = $auth->exposeMixinMethods(); + $this->assertTrue(in_array('getUsername', $mixins), + '%s: getUsername() should be accessible via mixin' + ); + $this->assertTrue(in_array('setUsername', $mixins), + '%s: setUsername() should be accessible via mixin' + ); + $this->assertTrue(in_array('getPassword', $mixins), + '%s: getPassword() should be accessible via mixin' + ); + $this->assertTrue(in_array('setPassword', $mixins), + '%s: setPassword() should be accessible via mixin' + ); + $this->assertTrue(in_array('setAuthMode', $mixins), + '%s: setAuthMode() should be accessible via mixin' + ); + $this->assertTrue(in_array('getAuthMode', $mixins), + '%s: getAuthMode() should be accessible via mixin' + ); + } + + public function testAuthenticatorsAreCalledAccordingToParamsAfterEhlo() + { + $a1 = $this->_createMockAuthenticator('PLAIN'); + $a2 = $this->_createMockAuthenticator('LOGIN'); + + $a1->shouldReceive('authenticate') + ->never() + ->with($this->_agent, 'jack', 'pass'); + $a2->shouldReceive('authenticate') + ->once() + ->with($this->_agent, 'jack', 'pass') + ->andReturn(true); + + $auth = $this->_createHandler(array($a1, $a2)); + $auth->setUsername('jack'); + $auth->setPassword('pass'); + + $auth->setKeywordParams(array('CRAM-MD5', 'LOGIN')); + $auth->afterEhlo($this->_agent); + } + + public function testAuthenticatorsAreNotUsedIfNoUsernameSet() + { + $a1 = $this->_createMockAuthenticator('PLAIN'); + $a2 = $this->_createMockAuthenticator('LOGIN'); + + $a1->shouldReceive('authenticate') + ->never() + ->with($this->_agent, 'jack', 'pass'); + $a2->shouldReceive('authenticate') + ->never() + ->with($this->_agent, 'jack', 'pass') + ->andReturn(true); + + $auth = $this->_createHandler(array($a1, $a2)); + + $auth->setKeywordParams(array('CRAM-MD5', 'LOGIN')); + $auth->afterEhlo($this->_agent); + } + + public function testSeveralAuthenticatorsAreTriedIfNeeded() + { + $a1 = $this->_createMockAuthenticator('PLAIN'); + $a2 = $this->_createMockAuthenticator('LOGIN'); + + $a1->shouldReceive('authenticate') + ->once() + ->with($this->_agent, 'jack', 'pass') + ->andReturn(false); + $a2->shouldReceive('authenticate') + ->once() + ->with($this->_agent, 'jack', 'pass') + ->andReturn(true); + + $auth = $this->_createHandler(array($a1, $a2)); + $auth->setUsername('jack'); + $auth->setPassword('pass'); + + $auth->setKeywordParams(array('PLAIN', 'LOGIN')); + $auth->afterEhlo($this->_agent); + } + + public function testFirstAuthenticatorToPassBreaksChain() + { + $a1 = $this->_createMockAuthenticator('PLAIN'); + $a2 = $this->_createMockAuthenticator('LOGIN'); + $a3 = $this->_createMockAuthenticator('CRAM-MD5'); + + $a1->shouldReceive('authenticate') + ->once() + ->with($this->_agent, 'jack', 'pass') + ->andReturn(false); + $a2->shouldReceive('authenticate') + ->once() + ->with($this->_agent, 'jack', 'pass') + ->andReturn(true); + $a3->shouldReceive('authenticate') + ->never() + ->with($this->_agent, 'jack', 'pass'); + + $auth = $this->_createHandler(array($a1, $a2)); + $auth->setUsername('jack'); + $auth->setPassword('pass'); + + $auth->setKeywordParams(array('PLAIN', 'LOGIN', 'CRAM-MD5')); + $auth->afterEhlo($this->_agent); + } + + // -- Private helpers + + private function _createHandler($authenticators) + { + return new Swift_Transport_Esmtp_AuthHandler($authenticators); + } + + private function _createMockAuthenticator($type) + { + $authenticator = $this->getMockery('Swift_Transport_Esmtp_Authenticator')->shouldIgnoreMissing(); + $authenticator->shouldReceive('getAuthKeyword') + ->zeroOrMoreTimes() + ->andReturn($type); + + return $authenticator; + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Transport/EsmtpTransport/ExtensionSupportTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Transport/EsmtpTransport/ExtensionSupportTest.php new file mode 100755 index 0000000..c81220c --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Transport/EsmtpTransport/ExtensionSupportTest.php @@ -0,0 +1,530 @@ +_getBuffer(); + $smtp = $this->_getTransport($buf); + $ext1 = $this->getMockery('Swift_Transport_EsmtpHandler')->shouldIgnoreMissing(); + $ext2 = $this->getMockery('Swift_Transport_EsmtpHandler')->shouldIgnoreMissing(); + + $ext1->shouldReceive('getHandledKeyword') + ->zeroOrMoreTimes() + ->andReturn('AUTH'); + $ext1->shouldReceive('getPriorityOver') + ->zeroOrMoreTimes() + ->with('STARTTLS') + ->andReturn(0); + $ext2->shouldReceive('getHandledKeyword') + ->zeroOrMoreTimes() + ->andReturn('STARTTLS'); + $ext2->shouldReceive('getPriorityOver') + ->zeroOrMoreTimes() + ->with('AUTH') + ->andReturn(-1); + $this->_finishBuffer($buf); + + $smtp->setExtensionHandlers(array($ext1, $ext2)); + $this->assertEquals(array($ext2, $ext1), $smtp->getExtensionHandlers()); + } + + public function testHandlersAreNotifiedOfParams() + { + $buf = $this->_getBuffer(); + $smtp = $this->_getTransport($buf); + $ext1 = $this->getMockery('Swift_Transport_EsmtpHandler')->shouldIgnoreMissing(); + $ext2 = $this->getMockery('Swift_Transport_EsmtpHandler')->shouldIgnoreMissing(); + + $buf->shouldReceive('readLine') + ->once() + ->with(0) + ->andReturn("220 server.com foo\r\n"); + $buf->shouldReceive('write') + ->once() + ->with('~^EHLO .*?\r\n$~D') + ->andReturn(1); + $buf->shouldReceive('readLine') + ->once() + ->with(1) + ->andReturn("250-ServerName.tld\r\n"); + $buf->shouldReceive('readLine') + ->once() + ->with(1) + ->andReturn("250-AUTH PLAIN LOGIN\r\n"); + $buf->shouldReceive('readLine') + ->once() + ->with(1) + ->andReturn("250 SIZE=123456\r\n"); + + $ext1->shouldReceive('getHandledKeyword') + ->zeroOrMoreTimes() + ->andReturn('AUTH'); + $ext1->shouldReceive('setKeywordParams') + ->once() + ->with(array('PLAIN', 'LOGIN')); + $ext2->shouldReceive('getHandledKeyword') + ->zeroOrMoreTimes() + ->andReturn('SIZE'); + $ext2->shouldReceive('setKeywordParams') + ->zeroOrMoreTimes() + ->with(array('123456')); + $this->_finishBuffer($buf); + + $smtp->setExtensionHandlers(array($ext1, $ext2)); + $smtp->start(); + } + + public function testSupportedExtensionHandlersAreRunAfterEhlo() + { + $buf = $this->_getBuffer(); + $smtp = $this->_getTransport($buf); + $ext1 = $this->getMockery('Swift_Transport_EsmtpHandler')->shouldIgnoreMissing(); + $ext2 = $this->getMockery('Swift_Transport_EsmtpHandler')->shouldIgnoreMissing(); + $ext3 = $this->getMockery('Swift_Transport_EsmtpHandler')->shouldIgnoreMissing(); + + $buf->shouldReceive('readLine') + ->once() + ->with(0) + ->andReturn("220 server.com foo\r\n"); + $buf->shouldReceive('write') + ->once() + ->with('~^EHLO .*?\r\n$~D') + ->andReturn(1); + $buf->shouldReceive('readLine') + ->once() + ->with(1) + ->andReturn("250-ServerName.tld\r\n"); + $buf->shouldReceive('readLine') + ->once() + ->with(1) + ->andReturn("250-AUTH PLAIN LOGIN\r\n"); + $buf->shouldReceive('readLine') + ->once() + ->with(1) + ->andReturn("250 SIZE=123456\r\n"); + + $ext1->shouldReceive('getHandledKeyword') + ->zeroOrMoreTimes() + ->andReturn('AUTH'); + $ext1->shouldReceive('afterEhlo') + ->once() + ->with($smtp); + $ext2->shouldReceive('getHandledKeyword') + ->zeroOrMoreTimes() + ->andReturn('SIZE'); + $ext2->shouldReceive('afterEhlo') + ->zeroOrMoreTimes() + ->with($smtp); + $ext3->shouldReceive('getHandledKeyword') + ->zeroOrMoreTimes() + ->andReturn('STARTTLS'); + $ext3->shouldReceive('afterEhlo') + ->never() + ->with($smtp); + $this->_finishBuffer($buf); + + $smtp->setExtensionHandlers(array($ext1, $ext2, $ext3)); + $smtp->start(); + } + + public function testExtensionsCanModifyMailFromParams() + { + $buf = $this->_getBuffer(); + $dispatcher = $this->_createEventDispatcher(); + $smtp = new EsmtpTransportFixture($buf, array(), $dispatcher); + $ext1 = $this->getMockery('Swift_Transport_EsmtpHandler')->shouldIgnoreMissing(); + $ext2 = $this->getMockery('Swift_Transport_EsmtpHandler')->shouldIgnoreMissing(); + $ext3 = $this->getMockery('Swift_Transport_EsmtpHandler')->shouldIgnoreMissing(); + $message = $this->_createMessage(); + + $message->shouldReceive('getFrom') + ->zeroOrMoreTimes() + ->andReturn(array('me@domain' => 'Me')); + $message->shouldReceive('getTo') + ->zeroOrMoreTimes() + ->andReturn(array('foo@bar' => null)); + + $buf->shouldReceive('readLine') + ->once() + ->with(0) + ->andReturn("220 server.com foo\r\n"); + $buf->shouldReceive('write') + ->once() + ->with('~^EHLO .*?\r\n$~D') + ->andReturn(1); + $buf->shouldReceive('readLine') + ->once() + ->with(1) + ->andReturn("250-ServerName.tld\r\n"); + $buf->shouldReceive('readLine') + ->once() + ->with(1) + ->andReturn("250-AUTH PLAIN LOGIN\r\n"); + $buf->shouldReceive('readLine') + ->once() + ->with(1) + ->andReturn("250 SIZE=123456\r\n"); + $buf->shouldReceive('write') + ->once() + ->with("MAIL FROM: FOO ZIP\r\n") + ->andReturn(2); + $buf->shouldReceive('readLine') + ->once() + ->with(2) + ->andReturn("250 OK\r\n"); + $buf->shouldReceive('write') + ->once() + ->with("RCPT TO: \r\n") + ->andReturn(3); + $buf->shouldReceive('readLine') + ->once() + ->with(3) + ->andReturn("250 OK\r\n"); + $this->_finishBuffer($buf); + + $ext1->shouldReceive('getHandledKeyword') + ->zeroOrMoreTimes() + ->andReturn('AUTH'); + $ext1->shouldReceive('getMailParams') + ->once() + ->andReturn('FOO'); + $ext1->shouldReceive('getPriorityOver') + ->zeroOrMoreTimes() + ->with('AUTH') + ->andReturn(-1); + $ext2->shouldReceive('getHandledKeyword') + ->zeroOrMoreTimes() + ->andReturn('SIZE'); + $ext2->shouldReceive('getMailParams') + ->once() + ->andReturn('ZIP'); + $ext2->shouldReceive('getPriorityOver') + ->zeroOrMoreTimes() + ->with('AUTH') + ->andReturn(1); + $ext3->shouldReceive('getHandledKeyword') + ->zeroOrMoreTimes() + ->andReturn('STARTTLS'); + $ext3->shouldReceive('getMailParams') + ->never(); + + $smtp->setExtensionHandlers(array($ext1, $ext2, $ext3)); + $smtp->start(); + $smtp->send($message); + } + + public function testExtensionsCanModifyRcptParams() + { + $buf = $this->_getBuffer(); + $dispatcher = $this->_createEventDispatcher(); + $smtp = new EsmtpTransportFixture($buf, array(), $dispatcher); + $ext1 = $this->getMockery('Swift_Transport_EsmtpHandler')->shouldIgnoreMissing(); + $ext2 = $this->getMockery('Swift_Transport_EsmtpHandler')->shouldIgnoreMissing(); + $ext3 = $this->getMockery('Swift_Transport_EsmtpHandler')->shouldIgnoreMissing(); + $message = $this->_createMessage(); + + $message->shouldReceive('getFrom') + ->zeroOrMoreTimes() + ->andReturn(array('me@domain'=>'Me')); + $message->shouldReceive('getTo') + ->zeroOrMoreTimes() + ->andReturn(array('foo@bar'=>null)); + + $buf->shouldReceive('readLine') + ->once() + ->with(0) + ->andReturn("220 server.com foo\r\n"); + $buf->shouldReceive('write') + ->once() + ->with('~^EHLO .+?\r\n$~D') + ->andReturn(1); + $buf->shouldReceive('readLine') + ->once() + ->with(1) + ->andReturn("250-ServerName.tld\r\n"); + $buf->shouldReceive('readLine') + ->once() + ->with(1) + ->andReturn("250-AUTH PLAIN LOGIN\r\n"); + $buf->shouldReceive('readLine') + ->once() + ->with(1) + ->andReturn("250 SIZE=123456\r\n"); + $buf->shouldReceive('write') + ->once() + ->with("MAIL FROM: \r\n") + ->andReturn(2); + $buf->shouldReceive('readLine') + ->once() + ->with(2) + ->andReturn("250 OK\r\n"); + $buf->shouldReceive('write') + ->once() + ->with("RCPT TO: FOO ZIP\r\n") + ->andReturn(3); + $buf->shouldReceive('readLine') + ->once() + ->with(3) + ->andReturn("250 OK\r\n"); + $this->_finishBuffer($buf); + + $ext1->shouldReceive('getHandledKeyword') + ->zeroOrMoreTimes() + ->andReturn('AUTH'); + $ext1->shouldReceive('getRcptParams') + ->once() + ->andReturn('FOO'); + $ext1->shouldReceive('getPriorityOver') + ->zeroOrMoreTimes() + ->with('AUTH') + ->andReturn(-1); + $ext2->shouldReceive('getHandledKeyword') + ->zeroOrMoreTimes() + ->andReturn('SIZE'); + $ext2->shouldReceive('getRcptParams') + ->once() + ->andReturn('ZIP'); + $ext2->shouldReceive('getPriorityOver') + ->zeroOrMoreTimes() + ->with('AUTH') + ->andReturn(1); + $ext3->shouldReceive('getHandledKeyword') + ->zeroOrMoreTimes() + ->andReturn('STARTTLS'); + $ext3->shouldReceive('getRcptParams') + ->never(); + + $smtp->setExtensionHandlers(array($ext1, $ext2, $ext3)); + $smtp->start(); + $smtp->send($message); + } + + public function testExtensionsAreNotifiedOnCommand() + { + $buf = $this->_getBuffer(); + $smtp = $this->_getTransport($buf); + $ext1 = $this->getMockery('Swift_Transport_EsmtpHandler')->shouldIgnoreMissing(); + $ext2 = $this->getMockery('Swift_Transport_EsmtpHandler')->shouldIgnoreMissing(); + $ext3 = $this->getMockery('Swift_Transport_EsmtpHandler')->shouldIgnoreMissing(); + + $buf->shouldReceive('readLine') + ->once() + ->with(0) + ->andReturn("220 server.com foo\r\n"); + $buf->shouldReceive('write') + ->once() + ->with('~^EHLO .+?\r\n$~D') + ->andReturn(1); + $buf->shouldReceive('readLine') + ->once() + ->with(1) + ->andReturn("250-ServerName.tld\r\n"); + $buf->shouldReceive('readLine') + ->once() + ->with(1) + ->andReturn("250-AUTH PLAIN LOGIN\r\n"); + $buf->shouldReceive('readLine') + ->once() + ->with(1) + ->andReturn("250 SIZE=123456\r\n"); + $buf->shouldReceive('write') + ->once() + ->with("FOO\r\n") + ->andReturn(2); + $buf->shouldReceive('readLine') + ->once() + ->with(2) + ->andReturn("250 Cool\r\n"); + $this->_finishBuffer($buf); + + $ext1->shouldReceive('getHandledKeyword') + ->zeroOrMoreTimes() + ->andReturn('AUTH'); + $ext1->shouldReceive('onCommand') + ->once() + ->with($smtp, "FOO\r\n", array(250, 251), \Mockery::any(), \Mockery::any()); + $ext2->shouldReceive('getHandledKeyword') + ->zeroOrMoreTimes() + ->andReturn('SIZE'); + $ext2->shouldReceive('onCommand') + ->once() + ->with($smtp, "FOO\r\n", array(250, 251), \Mockery::any(), \Mockery::any()); + $ext3->shouldReceive('getHandledKeyword') + ->zeroOrMoreTimes() + ->andReturn('STARTTLS'); + $ext3->shouldReceive('onCommand') + ->never() + ->with(\Mockery::any(), \Mockery::any(), \Mockery::any(), \Mockery::any(), \Mockery::any()); + + $smtp->setExtensionHandlers(array($ext1, $ext2, $ext3)); + $smtp->start(); + $smtp->executeCommand("FOO\r\n", array(250, 251)); + } + + public function testChainOfCommandAlgorithmWhenNotifyingExtensions() + { + $buf = $this->_getBuffer(); + $smtp = $this->_getTransport($buf); + $ext1 = $this->getMockery('Swift_Transport_EsmtpHandler')->shouldIgnoreMissing(); + $ext2 = $this->getMockery('Swift_Transport_EsmtpHandler')->shouldIgnoreMissing(); + $ext3 = $this->getMockery('Swift_Transport_EsmtpHandler')->shouldIgnoreMissing(); + + $buf->shouldReceive('readLine') + ->once() + ->with(0) + ->andReturn("220 server.com foo\r\n"); + $buf->shouldReceive('write') + ->once() + ->with('~^EHLO .+?\r\n$~D') + ->andReturn(1); + $buf->shouldReceive('readLine') + ->once() + ->with(1) + ->andReturn("250-ServerName.tld\r\n"); + $buf->shouldReceive('readLine') + ->once() + ->with(1) + ->andReturn("250-AUTH PLAIN LOGIN\r\n"); + $buf->shouldReceive('readLine') + ->once() + ->with(1) + ->andReturn("250 SIZE=123456\r\n"); + $buf->shouldReceive('write') + ->never() + ->with("FOO\r\n"); + $this->_finishBuffer($buf); + + $ext1->shouldReceive('getHandledKeyword') + ->zeroOrMoreTimes() + ->andReturn('AUTH'); + $ext1->shouldReceive('onCommand') + ->once() + ->with($smtp, "FOO\r\n", array(250, 251), \Mockery::any(), \Mockery::any()) + ->andReturnUsing(function($a, $b, $c, $d, &$e) { + $e = true; + return "250 ok"; + }); + $ext2->shouldReceive('getHandledKeyword') + ->zeroOrMoreTimes() + ->andReturn('SIZE'); + $ext2->shouldReceive('onCommand') + ->never() + ->with(\Mockery::any(), \Mockery::any(), \Mockery::any(), \Mockery::any()); + + $ext3->shouldReceive('getHandledKeyword') + ->zeroOrMoreTimes() + ->andReturn('STARTTLS'); + $ext3->shouldReceive('onCommand') + ->never() + ->with(\Mockery::any(), \Mockery::any(), \Mockery::any(), \Mockery::any()); + + $smtp->setExtensionHandlers(array($ext1, $ext2, $ext3)); + $smtp->start(); + $smtp->executeCommand("FOO\r\n", array(250, 251)); + } + + public function testExtensionsCanExposeMixinMethods() + { + $buf = $this->_getBuffer(); + $smtp = $this->_getTransport($buf); + $ext1 = $this->getMockery('Swift_Transport_EsmtpHandlerMixin')->shouldIgnoreMissing(); + $ext2 = $this->getMockery('Swift_Transport_EsmtpHandler')->shouldIgnoreMissing(); + + $ext1->shouldReceive('getHandledKeyword') + ->zeroOrMoreTimes() + ->andReturn('AUTH'); + $ext1->shouldReceive('exposeMixinMethods') + ->zeroOrMoreTimes() + ->andReturn(array('setUsername', 'setPassword')); + $ext1->shouldReceive('setUsername') + ->once() + ->with('mick'); + $ext1->shouldReceive('setPassword') + ->once() + ->with('pass'); + $ext2->shouldReceive('getHandledKeyword') + ->zeroOrMoreTimes() + ->andReturn('STARTTLS'); + $this->_finishBuffer($buf); + + $smtp->setExtensionHandlers(array($ext1, $ext2)); + $smtp->setUsername('mick'); + $smtp->setPassword('pass'); + } + + public function testMixinMethodsBeginningWithSetAndNullReturnAreFluid() + { + $buf = $this->_getBuffer(); + $smtp = $this->_getTransport($buf); + $ext1 = $this->getMockery('Swift_Transport_EsmtpHandlerMixin')->shouldIgnoreMissing(); + $ext2 = $this->getMockery('Swift_Transport_EsmtpHandler')->shouldIgnoreMissing(); + + $ext1->shouldReceive('getHandledKeyword') + ->zeroOrMoreTimes() + ->andReturn('AUTH'); + $ext1->shouldReceive('exposeMixinMethods') + ->zeroOrMoreTimes() + ->andReturn(array('setUsername', 'setPassword')); + $ext1->shouldReceive('setUsername') + ->once() + ->with('mick') + ->andReturn(NULL); + $ext1->shouldReceive('setPassword') + ->once() + ->with('pass') + ->andReturn(NULL); + $ext2->shouldReceive('getHandledKeyword') + ->zeroOrMoreTimes() + ->andReturn('STARTTLS'); + $this->_finishBuffer($buf); + + $smtp->setExtensionHandlers(array($ext1, $ext2)); + $ret = $smtp->setUsername('mick'); + $this->assertEquals($smtp, $ret); + $ret = $smtp->setPassword('pass'); + $this->assertEquals($smtp, $ret); + } + + public function testMixinSetterWhichReturnValuesAreNotFluid() + { + $buf = $this->_getBuffer(); + $smtp = $this->_getTransport($buf); + $ext1 = $this->getMockery('Swift_Transport_EsmtpHandlerMixin')->shouldIgnoreMissing(); + $ext2 = $this->getMockery('Swift_Transport_EsmtpHandler')->shouldIgnoreMissing(); + + $ext1->shouldReceive('getHandledKeyword') + ->zeroOrMoreTimes() + ->andReturn('AUTH'); + $ext1->shouldReceive('exposeMixinMethods') + ->zeroOrMoreTimes() + ->andReturn(array('setUsername', 'setPassword')); + $ext1->shouldReceive('setUsername') + ->once() + ->with('mick') + ->andReturn('x'); + $ext1->shouldReceive('setPassword') + ->once() + ->with('pass') + ->andReturn('x'); + $ext2->shouldReceive('getHandledKeyword') + ->zeroOrMoreTimes() + ->andReturn('STARTTLS'); + $this->_finishBuffer($buf); + + $smtp->setExtensionHandlers(array($ext1, $ext2)); + $this->assertEquals('x', $smtp->setUsername('mick')); + $this->assertEquals('x', $smtp->setPassword('pass')); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Transport/EsmtpTransportTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Transport/EsmtpTransportTest.php new file mode 100755 index 0000000..8d3ecc2 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Transport/EsmtpTransportTest.php @@ -0,0 +1,295 @@ +_createEventDispatcher(); + } + + return new Swift_Transport_EsmtpTransport($buf, array(), $dispatcher); + } + + public function testHostCanBeSetAndFetched() + { + $buf = $this->_getBuffer(); + $smtp = $this->_getTransport($buf); + $smtp->setHost('foo'); + $this->assertEquals('foo', $smtp->getHost(), '%s: Host should be returned'); + } + + public function testPortCanBeSetAndFetched() + { + $buf = $this->_getBuffer(); + $smtp = $this->_getTransport($buf); + $smtp->setPort(25); + $this->assertEquals(25, $smtp->getPort(), '%s: Port should be returned'); + } + + public function testTimeoutCanBeSetAndFetched() + { + $buf = $this->_getBuffer(); + $buf->shouldReceive('setParam') + ->once() + ->with('timeout', 10); + + $smtp = $this->_getTransport($buf); + $smtp->setTimeout(10); + $this->assertEquals(10, $smtp->getTimeout(), '%s: Timeout should be returned'); + } + + public function testEncryptionCanBeSetAndFetched() + { + $buf = $this->_getBuffer(); + $smtp = $this->_getTransport($buf); + $smtp->setEncryption('tls'); + $this->assertEquals('tls', $smtp->getEncryption(), '%s: Crypto should be returned'); + } + + public function testStartSendsHeloToInitiate() + {//Overridden for EHLO instead + } + + public function testStartSendsEhloToInitiate() + { + /* -- RFC 2821, 3.2. + + 3.2 Client Initiation + + Once the server has sent the welcoming message and the client has + received it, the client normally sends the EHLO command to the + server, indicating the client's identity. In addition to opening the + session, use of EHLO indicates that the client is able to process + service extensions and requests that the server provide a list of the + extensions it supports. Older SMTP systems which are unable to + support service extensions and contemporary clients which do not + require service extensions in the mail session being initiated, MAY + use HELO instead of EHLO. Servers MUST NOT return the extended + EHLO-style response to a HELO command. For a particular connection + attempt, if the server returns a "command not recognized" response to + EHLO, the client SHOULD be able to fall back and send HELO. + + In the EHLO command the host sending the command identifies itself; + the command may be interpreted as saying "Hello, I am " (and, + in the case of EHLO, "and I support service extension requests"). + + -- RFC 2281, 4.1.1.1. + + ehlo = "EHLO" SP Domain CRLF + helo = "HELO" SP Domain CRLF + + -- RFC 2821, 4.3.2. + + EHLO or HELO + S: 250 + E: 504, 550 + + */ + + $buf = $this->_getBuffer(); + $smtp = $this->_getTransport($buf); + + $buf->shouldReceive('initialize') + ->once(); + $buf->shouldReceive('readLine') + ->once() + ->with(0) + ->andReturn("220 some.server.tld bleh\r\n"); + $buf->shouldReceive('write') + ->once() + ->with('~^EHLO .+?\r\n$~D') + ->andReturn(1); + $buf->shouldReceive('readLine') + ->once() + ->with(1) + ->andReturn('250 ServerName' . "\r\n"); + + $this->_finishBuffer($buf); + try { + $smtp->start(); + } catch (Exception $e) { + $this->fail('Starting Esmtp should send EHLO and accept 250 response'); + } + } + + public function testHeloIsUsedAsFallback() + { + /* -- RFC 2821, 4.1.4. + + If the EHLO command is not acceptable to the SMTP server, 501, 500, + or 502 failure replies MUST be returned as appropriate. The SMTP + server MUST stay in the same state after transmitting these replies + that it was in before the EHLO was received. + */ + + $buf = $this->_getBuffer(); + $smtp = $this->_getTransport($buf); + + $buf->shouldReceive('initialize') + ->once(); + $buf->shouldReceive('readLine') + ->once() + ->with(0) + ->andReturn("220 some.server.tld bleh\r\n"); + $buf->shouldReceive('write') + ->once() + ->with('~^EHLO .+?\r\n$~D') + ->andReturn(1); + $buf->shouldReceive('readLine') + ->once() + ->with(1) + ->andReturn('501 WTF' . "\r\n"); + $buf->shouldReceive('write') + ->once() + ->with('~^HELO .+?\r\n$~D') + ->andReturn(2); + $buf->shouldReceive('readLine') + ->once() + ->with(2) + ->andReturn('250 HELO' . "\r\n"); + + $this->_finishBuffer($buf); + try { + $smtp->start(); + } catch (Exception $e) { + $this->fail( + 'Starting Esmtp should fallback to HELO if needed and accept 250 response' + ); + } + } + + public function testInvalidHeloResponseCausesException() + {//Overridden to first try EHLO + $buf = $this->_getBuffer(); + $smtp = $this->_getTransport($buf); + + $buf->shouldReceive('initialize') + ->once(); + $buf->shouldReceive('readLine') + ->once() + ->with(0) + ->andReturn("220 some.server.tld bleh\r\n"); + $buf->shouldReceive('write') + ->once() + ->with('~^EHLO .+?\r\n$~D') + ->andReturn(1); + $buf->shouldReceive('readLine') + ->once() + ->with(1) + ->andReturn('501 WTF' . "\r\n"); + $buf->shouldReceive('write') + ->once() + ->with('~^HELO .+?\r\n$~D') + ->andReturn(2); + $buf->shouldReceive('readLine') + ->once() + ->with(2) + ->andReturn('504 WTF' . "\r\n"); + $this->_finishBuffer($buf); + + try { + $this->assertFalse($smtp->isStarted(), '%s: SMTP should begin non-started'); + $smtp->start(); + $this->fail('Non 250 HELO response should raise Exception'); + } catch (Exception $e) { + $this->assertFalse($smtp->isStarted(), '%s: SMTP start() should have failed'); + } + } + + public function testDomainNameIsPlacedInEhlo() + { + /* -- RFC 2821, 4.1.4. + + The SMTP client MUST, if possible, ensure that the domain parameter + to the EHLO command is a valid principal host name (not a CNAME or MX + name) for its host. If this is not possible (e.g., when the client's + address is dynamically assigned and the client does not have an + obvious name), an address literal SHOULD be substituted for the + domain name and supplemental information provided that will assist in + identifying the client. + */ + + $buf = $this->_getBuffer(); + $smtp = $this->_getTransport($buf); + $buf->shouldReceive('initialize') + ->once(); + $buf->shouldReceive('readLine') + ->once() + ->with(0) + ->andReturn("220 some.server.tld bleh\r\n"); + $buf->shouldReceive('write') + ->once() + ->with("EHLO mydomain.com\r\n") + ->andReturn(1); + $buf->shouldReceive('readLine') + ->once() + ->with(1) + ->andReturn('250 ServerName' . "\r\n"); + + $this->_finishBuffer($buf); + $smtp->setLocalDomain('mydomain.com'); + $smtp->start(); + } + + public function testDomainNameIsPlacedInHelo() + { //Overridden to include ESMTP + /* -- RFC 2821, 4.1.4. + + The SMTP client MUST, if possible, ensure that the domain parameter + to the EHLO command is a valid principal host name (not a CNAME or MX + name) for its host. If this is not possible (e.g., when the client's + address is dynamically assigned and the client does not have an + obvious name), an address literal SHOULD be substituted for the + domain name and supplemental information provided that will assist in + identifying the client. + */ + + $buf = $this->_getBuffer(); + $smtp = $this->_getTransport($buf); + $buf->shouldReceive('initialize') + ->once(); + $buf->shouldReceive('readLine') + ->once() + ->with(0) + ->andReturn("220 some.server.tld bleh\r\n"); + $buf->shouldReceive('write') + ->once() + ->with('~^EHLO .+?\r\n$~D') + ->andReturn(1); + $buf->shouldReceive('readLine') + ->once() + ->with(1) + ->andReturn('501 WTF' . "\r\n"); + $buf->shouldReceive('write') + ->once() + ->with("HELO mydomain.com\r\n") + ->andReturn(2); + $buf->shouldReceive('readLine') + ->once() + ->with(2) + ->andReturn('250 ServerName' . "\r\n"); + + $this->_finishBuffer($buf); + $smtp->setLocalDomain('mydomain.com'); + $smtp->start(); + } + + public function testFluidInterface() + { + $buf = $this->_getBuffer(); + $smtp = $this->_getTransport($buf); + $buf->shouldReceive('setParam') + ->once() + ->with('timeout', 30); + + $ref = $smtp + ->setHost('foo') + ->setPort(25) + ->setEncryption('tls') + ->setTimeout(30) + ; + $this->assertEquals($ref, $smtp); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Transport/FailoverTransportTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Transport/FailoverTransportTest.php new file mode 100755 index 0000000..553bb7b --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Transport/FailoverTransportTest.php @@ -0,0 +1,524 @@ +getMockery('Swift_Mime_Message'); + $message2 = $this->getMockery('Swift_Mime_Message'); + $t1 = $this->getMockery('Swift_Transport'); + $t2 = $this->getMockery('Swift_Transport'); + $connectionState = false; + + $t1->shouldReceive('isStarted') + ->zeroOrMoreTimes() + ->andReturnUsing(function() use (&$connectionState) { + return $connectionState; + }); + $t1->shouldReceive('start') + ->once() + ->andReturnUsing(function() use (&$connectionState) { + if (!$connectionState) { + $connectionState = true; + } + }); + $t1->shouldReceive('send') + ->twice() + ->with(\Mockery::anyOf($message1, $message2), \Mockery::any()) + ->andReturnUsing(function() use (&$connectionState) { + if ($connectionState) { + return 1; + } + }); + $t2->shouldReceive('start')->never(); + $t2->shouldReceive('send')->never(); + + $transport = $this->_getTransport(array($t1, $t2)); + $transport->start(); + $this->assertEquals(1, $transport->send($message1)); + $this->assertEquals(1, $transport->send($message2)); + } + + public function testMessageCanBeTriedOnNextTransportIfExceptionThrown() + { + $e = new Swift_TransportException('b0rken'); + + $message = $this->getMockery('Swift_Mime_Message'); + $t1 = $this->getMockery('Swift_Transport'); + $t2 = $this->getMockery('Swift_Transport'); + $connectionState1 = false; + $connectionState2 = false; + + $t1->shouldReceive('isStarted') + ->zeroOrMoreTimes() + ->andReturnUsing(function() use (&$connectionState1) { + return $connectionState1; + }); + $t1->shouldReceive('start') + ->once() + ->andReturnUsing(function() use (&$connectionState1) { + if (!$connectionState1) { + $connectionState1 = true; + } + }); + $t1->shouldReceive('send') + ->once() + ->with($message, \Mockery::any()) + ->andReturnUsing(function() use (&$connectionState1, $e) { + if ($connectionState1) { + throw $e; + } + }); + + $t2->shouldReceive('isStarted') + ->zeroOrMoreTimes() + ->andReturnUsing(function() use (&$connectionState2) { + return $connectionState2; + }); + $t2->shouldReceive('start') + ->once() + ->andReturnUsing(function() use (&$connectionState2) { + if (!$connectionState2) { + $connectionState2 = true; + } + }); + $t2->shouldReceive('send') + ->once() + ->with($message, \Mockery::any()) + ->andReturnUsing(function() use (&$connectionState2, $e) { + if ($connectionState2) { + return 1; + } + }); + + $transport = $this->_getTransport(array($t1, $t2)); + $transport->start(); + $this->assertEquals(1, $transport->send($message)); + } + + public function testZeroIsReturnedIfTransportReturnsZero() + { + $message = $this->getMockery('Swift_Mime_Message')->shouldIgnoreMissing(); + $t1 = $this->getMockery('Swift_Transport')->shouldIgnoreMissing(); + + $connectionState = false; + $t1->shouldReceive('isStarted') + ->zeroOrMoreTimes() + ->andReturnUsing(function() use (&$connectionState) { + return $connectionState; + }); + $t1->shouldReceive('start') + ->once() + ->andReturnUsing(function() use (&$connectionState) { + if (!$connectionState) { + $connectionState = true; + } + }); + $testCase = $this; + $t1->shouldReceive('send') + ->once() + ->with($message, \Mockery::any()) + ->andReturnUsing(function() use (&$connectionState, $testCase) { + if (!$connectionState) { + $testCase->fail(); + } + return 0; + }); + + $transport = $this->_getTransport(array($t1)); + $transport->start(); + $this->assertEquals(0, $transport->send($message)); + } + + public function testTransportsWhichThrowExceptionsAreNotRetried() + { + $e = new Swift_TransportException('maur b0rken'); + + $message1 = $this->getMockery('Swift_Mime_Message'); + $message2 = $this->getMockery('Swift_Mime_Message'); + $message3 = $this->getMockery('Swift_Mime_Message'); + $message4 = $this->getMockery('Swift_Mime_Message'); + $t1 = $this->getMockery('Swift_Transport'); + $t2 = $this->getMockery('Swift_Transport'); + $connectionState1 = false; + $connectionState2 = false; + + $t1->shouldReceive('isStarted') + ->zeroOrMoreTimes() + ->andReturnUsing(function() use (&$connectionState1) { + return $connectionState1; + }); + $t1->shouldReceive('start') + ->once() + ->andReturnUsing(function() use (&$connectionState1) { + if (!$connectionState1) { + $connectionState1 = true; + } + }); + $t1->shouldReceive('send') + ->once() + ->with($message1, \Mockery::any()) + ->andReturnUsing(function() use (&$connectionState1, $e) { + if ($connectionState1) { + throw $e; + } + }); + $t1->shouldReceive('send') + ->never() + ->with($message2, \Mockery::any()); + $t1->shouldReceive('send') + ->never() + ->with($message3, \Mockery::any()); + $t1->shouldReceive('send') + ->never() + ->with($message4, \Mockery::any()); + + $t2->shouldReceive('isStarted') + ->zeroOrMoreTimes() + ->andReturnUsing(function() use (&$connectionState2) { + return $connectionState2; + }); + $t2->shouldReceive('start') + ->once() + ->andReturnUsing(function() use (&$connectionState2) { + if (!$connectionState2) { + $connectionState2 = true; + } + }); + $t2->shouldReceive('send') + ->times(4) + ->with(\Mockery::anyOf($message1, $message2, $message3, $message4), \Mockery::any()) + ->andReturnUsing(function() use (&$connectionState2, $e) { + if ($connectionState2) { + return 1; + } + }); + + $transport = $this->_getTransport(array($t1, $t2)); + $transport->start(); + $this->assertEquals(1, $transport->send($message1)); + $this->assertEquals(1, $transport->send($message2)); + $this->assertEquals(1, $transport->send($message3)); + $this->assertEquals(1, $transport->send($message4)); + } + + public function testExceptionIsThrownIfAllTransportsDie() + { + $e = new Swift_TransportException('b0rken'); + + $message = $this->getMockery('Swift_Mime_Message'); + $t1 = $this->getMockery('Swift_Transport'); + $t2 = $this->getMockery('Swift_Transport'); + $connectionState1 = false; + $connectionState2 = false; + + $t1->shouldReceive('isStarted') + ->zeroOrMoreTimes() + ->andReturnUsing(function() use (&$connectionState1) { + return $connectionState1; + }); + $t1->shouldReceive('start') + ->once() + ->andReturnUsing(function() use (&$connectionState1) { + if (!$connectionState1) { + $connectionState1 = true; + } + }); + $t1->shouldReceive('send') + ->once() + ->with($message, \Mockery::any()) + ->andReturnUsing(function() use (&$connectionState1, $e) { + if ($connectionState1) { + throw $e; + } + }); + + $t2->shouldReceive('isStarted') + ->zeroOrMoreTimes() + ->andReturnUsing(function() use (&$connectionState2) { + return $connectionState2; + }); + $t2->shouldReceive('start') + ->once() + ->andReturnUsing(function() use (&$connectionState2) { + if (!$connectionState2) { + $connectionState2 = true; + } + }); + $t2->shouldReceive('send') + ->once() + ->with($message, \Mockery::any()) + ->andReturnUsing(function() use (&$connectionState2, $e) { + if ($connectionState2) { + throw $e; + } + }); + + $transport = $this->_getTransport(array($t1, $t2)); + $transport->start(); + try { + $transport->send($message); + $this->fail('All transports failed so Exception should be thrown'); + } catch (Exception $e) { + } + } + + public function testStoppingTransportStopsAllDelegates() + { + $t1 = $this->getMockery('Swift_Transport'); + $t2 = $this->getMockery('Swift_Transport'); + + $connectionState1 = true; + $connectionState2 = true; + + $t1->shouldReceive('isStarted') + ->zeroOrMoreTimes() + ->andReturnUsing(function() use (&$connectionState1) { + return $connectionState1; + }); + $t1->shouldReceive('stop') + ->once() + ->andReturnUsing(function() use (&$connectionState1) { + if ($connectionState1) { + $connectionState1 = false; + } + }); + + $t2->shouldReceive('isStarted') + ->zeroOrMoreTimes() + ->andReturnUsing(function() use (&$connectionState2) { + return $connectionState2; + }); + $t2->shouldReceive('stop') + ->once() + ->andReturnUsing(function() use (&$connectionState2) { + if ($connectionState2) { + $connectionState2 = false; + } + }); + + $transport = $this->_getTransport(array($t1, $t2)); + $transport->start(); + $transport->stop(); + } + + public function testTransportShowsAsNotStartedIfAllDelegatesDead() + { + $e = new Swift_TransportException('b0rken'); + + $message = $this->getMockery('Swift_Mime_Message'); + $t1 = $this->getMockery('Swift_Transport'); + $t2 = $this->getMockery('Swift_Transport'); + + $connectionState1 = false; + $connectionState2 = false; + + $t1->shouldReceive('isStarted') + ->zeroOrMoreTimes() + ->andReturnUsing(function() use (&$connectionState1) { + return $connectionState1; + }); + $t1->shouldReceive('start') + ->once() + ->andReturnUsing(function() use (&$connectionState1) { + if (!$connectionState1) { + $connectionState1 = true; + } + }); + $t1->shouldReceive('send') + ->once() + ->with($message, \Mockery::any()) + ->andReturnUsing(function() use (&$connectionState1, $e) { + if ($connectionState1) { + $connectionState1 = false; + throw $e; + } + }); + + $t2->shouldReceive('isStarted') + ->zeroOrMoreTimes() + ->andReturnUsing(function() use (&$connectionState2) { + return $connectionState2; + }); + $t2->shouldReceive('start') + ->once() + ->andReturnUsing(function() use (&$connectionState2) { + if (!$connectionState2) { + $connectionState2 = true; + } + }); + $t2->shouldReceive('send') + ->once() + ->with($message, \Mockery::any()) + ->andReturnUsing(function() use (&$connectionState2, $e) { + if ($connectionState2) { + $connectionState2 = false; + throw $e; + } + }); + + $transport = $this->_getTransport(array($t1, $t2)); + $transport->start(); + $this->assertTrue($transport->isStarted()); + try { + $transport->send($message); + $this->fail('All transports failed so Exception should be thrown'); + } catch (Exception $e) { + $this->assertFalse($transport->isStarted()); + } + } + + public function testRestartingTransportRestartsDeadDelegates() + { + $e = new Swift_TransportException('b0rken'); + + $message1 = $this->getMockery('Swift_Mime_Message'); + $message2 = $this->getMockery('Swift_Mime_Message'); + $t1 = $this->getMockery('Swift_Transport'); + $t2 = $this->getMockery('Swift_Transport'); + + $connectionState1 = false; + $connectionState2 = false; + + $t1->shouldReceive('isStarted') + ->zeroOrMoreTimes() + ->andReturnUsing(function() use (&$connectionState1) { + return $connectionState1; + }); + $t1->shouldReceive('start') + ->twice() + ->andReturnUsing(function() use (&$connectionState1) { + if (!$connectionState1) { + $connectionState1 = true; + } + }); + $t1->shouldReceive('send') + ->once() + ->with($message1, \Mockery::any()) + ->andReturnUsing(function() use (&$connectionState1, $e) { + if ($connectionState1) { + $connectionState1 = false; + throw $e; + } + }); + $t1->shouldReceive('send') + ->once() + ->with($message2, \Mockery::any()) + ->andReturnUsing(function() use (&$connectionState1) { + if ($connectionState1) { + return 10; + } + }); + + $t2->shouldReceive('isStarted') + ->zeroOrMoreTimes() + ->andReturnUsing(function() use (&$connectionState2) { + return $connectionState2; + }); + $t2->shouldReceive('start') + ->once() + ->andReturnUsing(function() use (&$connectionState2) { + if (!$connectionState2) { + $connectionState2 = true; + } + }); + $t2->shouldReceive('send') + ->once() + ->with($message1, \Mockery::any()) + ->andReturnUsing(function() use (&$connectionState2, $e) { + if ($connectionState2) { + $connectionState2 = false; + throw $e; + } + }); + $t2->shouldReceive('send') + ->never() + ->with($message2, \Mockery::any()); + + $transport = $this->_getTransport(array($t1, $t2)); + $transport->start(); + $this->assertTrue($transport->isStarted()); + try { + $transport->send($message1); + $this->fail('All transports failed so Exception should be thrown'); + } catch (Exception $e) { + $this->assertFalse($transport->isStarted()); + } + //Restart and re-try + $transport->start(); + $this->assertTrue($transport->isStarted()); + $this->assertEquals(10, $transport->send($message2)); + } + + public function testFailureReferenceIsPassedToDelegates() + { + $failures = array(); + + $message = $this->getMockery('Swift_Mime_Message'); + $t1 = $this->getMockery('Swift_Transport'); + + $connectionState = false; + + $t1->shouldReceive('isStarted') + ->zeroOrMoreTimes() + ->andReturnUsing(function() use ($connectionState) { + return $connectionState; + }); + $t1->shouldReceive('start') + ->once() + ->andReturnUsing(function() use ($connectionState) { + if (!$connectionState) { + $connectionState = true; + } + }); + $t1->shouldReceive('send') + ->once() + ->with($message, $failures) + ->andReturnUsing(function() use ($connectionState) { + if ($connectionState) { + return 1; + } + }); + + $transport = $this->_getTransport(array($t1)); + $transport->start(); + $transport->send($message, $failures); + } + + public function testRegisterPluginDelegatesToLoadedTransports() + { + $plugin = $this->_createPlugin(); + + $t1 = $this->getMockery('Swift_Transport'); + $t2 = $this->getMockery('Swift_Transport'); + $t1->shouldReceive('registerPlugin') + ->once() + ->with($plugin); + $t2->shouldReceive('registerPlugin') + ->once() + ->with($plugin); + + $transport = $this->_getTransport(array($t1, $t2)); + $transport->registerPlugin($plugin); + } + + // -- Private helpers + + private function _getTransport(array $transports) + { + $transport = new Swift_Transport_FailoverTransport(); + $transport->setTransports($transports); + + return $transport; + } + + private function _createPlugin() + { + return $this->getMockery('Swift_Events_EventListener'); + } + + private function _createInnerTransport() + { + return $this->getMockery('Swift_Transport'); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Transport/LoadBalancedTransportTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Transport/LoadBalancedTransportTest.php new file mode 100755 index 0000000..c882f75 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Transport/LoadBalancedTransportTest.php @@ -0,0 +1,752 @@ +getMockery('Swift_Mime_Message'); + $message2 = $this->getMockery('Swift_Mime_Message'); + $t1 = $this->getMockery('Swift_Transport'); + $t2 = $this->getMockery('Swift_Transport'); + $connectionState1 = false; + $connectionState2 = false; + + $testCase = $this; + $t1->shouldReceive('isStarted') + ->zeroOrMoreTimes() + ->andReturnUsing(function() use (&$connectionState1) { + return $connectionState1; + }); + $t1->shouldReceive('start') + ->once() + ->andReturnUsing(function() use (&$connectionState1) { + if (!$connectionState1) { + $connectionState1 = true; + } + }); + $t1->shouldReceive('send') + ->once() + ->with($message1, \Mockery::any()) + ->andReturnUsing(function() use (&$connectionState1, $testCase) { + if ($connectionState1) { + return 1; + } + $testCase->fail(); + }); + $t1->shouldReceive('send') + ->never() + ->with($message2, \Mockery::any()); + + $t2->shouldReceive('isStarted') + ->zeroOrMoreTimes() + ->andReturnUsing(function() use (&$connectionState2) { + return $connectionState2; + }); + $t2->shouldReceive('start') + ->once() + ->andReturnUsing(function() use (&$connectionState2) { + if (!$connectionState2) { + $connectionState2 = true; + } + }); + $t2->shouldReceive('send') + ->once() + ->with($message2, \Mockery::any()) + ->andReturnUsing(function() use (&$connectionState2, $testCase) { + if ($connectionState2) { + return 1; + } + $testCase->fail(); + }); + $t2->shouldReceive('send') + ->never() + ->with($message1, \Mockery::any()); + + $transport = $this->_getTransport(array($t1, $t2)); + $transport->start(); + $this->assertEquals(1, $transport->send($message1)); + $this->assertEquals(1, $transport->send($message2)); + } + + public function testTransportsAreReusedInRotatingFashion() + { + $message1 = $this->getMockery('Swift_Mime_Message'); + $message2 = $this->getMockery('Swift_Mime_Message'); + $message3 = $this->getMockery('Swift_Mime_Message'); + $message4 = $this->getMockery('Swift_Mime_Message'); + $t1 = $this->getMockery('Swift_Transport'); + $t2 = $this->getMockery('Swift_Transport'); + $connectionState1 = false; + $connectionState2 = false; + + $testCase = $this; + $t1->shouldReceive('isStarted') + ->zeroOrMoreTimes() + ->andReturnUsing(function() use (&$connectionState1) { + return $connectionState1; + }); + $t1->shouldReceive('start') + ->once() + ->andReturnUsing(function() use (&$connectionState1) { + if (!$connectionState1) { + $connectionState1 = true; + } + }); + $t1->shouldReceive('send') + ->once() + ->with($message1, \Mockery::any()) + ->andReturnUsing(function() use (&$connectionState1, $testCase) { + if ($connectionState1) { + return 1; + } + $testCase->fail(); + }); + $t1->shouldReceive('send') + ->never() + ->with($message2, \Mockery::any()); + $t1->shouldReceive('send') + ->once() + ->with($message3, \Mockery::any()) + ->andReturnUsing(function() use (&$connectionState1, $testCase) { + if ($connectionState1) { + return 1; + } + $testCase->fail(); + }); + $t1->shouldReceive('send') + ->never() + ->with($message4, \Mockery::any()); + + $t2->shouldReceive('isStarted') + ->zeroOrMoreTimes() + ->andReturnUsing(function() use (&$connectionState2) { + return $connectionState2; + }); + $t2->shouldReceive('start') + ->once() + ->andReturnUsing(function() use (&$connectionState2) { + if (!$connectionState2) { + $connectionState2 = true; + } + }); + $t2->shouldReceive('send') + ->once() + ->with($message2, \Mockery::any()) + ->andReturnUsing(function() use (&$connectionState2, $testCase) { + if ($connectionState2) { + return 1; + } + $testCase->fail(); + }); + $t2->shouldReceive('send') + ->never() + ->with($message1, \Mockery::any()); + $t2->shouldReceive('send') + ->once() + ->with($message4, \Mockery::any()) + ->andReturnUsing(function() use (&$connectionState2, $testCase) { + if ($connectionState2) { + return 1; + } + $testCase->fail(); + }); + $t2->shouldReceive('send') + ->never() + ->with($message3, \Mockery::any()); + + $transport = $this->_getTransport(array($t1, $t2)); + $transport->start(); + + $this->assertEquals(1, $transport->send($message1)); + $this->assertEquals(1, $transport->send($message2)); + $this->assertEquals(1, $transport->send($message3)); + $this->assertEquals(1, $transport->send($message4)); + } + + public function testMessageCanBeTriedOnNextTransportIfExceptionThrown() + { + $e = new Swift_TransportException('b0rken'); + + $message = $this->getMockery('Swift_Mime_Message'); + $t1 = $this->getMockery('Swift_Transport'); + $t2 = $this->getMockery('Swift_Transport'); + $connectionState1 = false; + $connectionState2 = false; + + $testCase = $this; + $t1->shouldReceive('isStarted') + ->zeroOrMoreTimes() + ->andReturnUsing(function() use (&$connectionState1) { + return $connectionState1; + }); + $t1->shouldReceive('start') + ->once() + ->andReturnUsing(function() use (&$connectionState1) { + if (!$connectionState1) { + $connectionState1 = true; + } + }); + $t1->shouldReceive('send') + ->once() + ->with($message, \Mockery::any()) + ->andReturnUsing(function() use (&$connectionState1, $e, $testCase) { + if ($connectionState1) { + throw $e; + } + $testCase->fail(); + }); + + $t2->shouldReceive('isStarted') + ->zeroOrMoreTimes() + ->andReturnUsing(function() use (&$connectionState2) { + return $connectionState2; + }); + $t2->shouldReceive('start') + ->once() + ->andReturnUsing(function() use (&$connectionState2) { + if (!$connectionState2) { + $connectionState2 = true; + } + }); + $t2->shouldReceive('send') + ->once() + ->with($message, \Mockery::any()) + ->andReturnUsing(function() use (&$connectionState2, $testCase) { + if ($connectionState2) { + return 1; + } + $testCase->fail(); + }); + + $transport = $this->_getTransport(array($t1, $t2)); + $transport->start(); + $this->assertEquals(1, $transport->send($message)); + } + + public function testMessageIsTriedOnNextTransportIfZeroReturned() + { + $message = $this->getMockery('Swift_Mime_Message'); + $t1 = $this->getMockery('Swift_Transport'); + $t2 = $this->getMockery('Swift_Transport'); + $connectionState1 = false; + $connectionState2 = false; + + $t1->shouldReceive('isStarted') + ->zeroOrMoreTimes() + ->andReturnUsing(function() use (&$connectionState1) { + return $connectionState1; + }); + $t1->shouldReceive('start') + ->once() + ->andReturnUsing(function() use (&$connectionState1) { + if (!$connectionState1) { + $connectionState1 = true; + } + }); + $t1->shouldReceive('send') + ->once() + ->with($message, \Mockery::any()) + ->andReturnUsing(function() use (&$connectionState1) { + if ($connectionState1) { + return 0; + } + return 1; + }); + + $t2->shouldReceive('isStarted') + ->zeroOrMoreTimes() + ->andReturnUsing(function() use (&$connectionState2) { + return $connectionState2; + }); + $t2->shouldReceive('start') + ->once() + ->andReturnUsing(function() use (&$connectionState2) { + if (!$connectionState2) { + $connectionState2 = true; + } + }); + $t2->shouldReceive('send') + ->once() + ->with($message, \Mockery::any()) + ->andReturnUsing(function() use (&$connectionState2) { + if ($connectionState2) { + return 1; + } + return 0; + }); + + $transport = $this->_getTransport(array($t1, $t2)); + $transport->start(); + $this->assertEquals(1, $transport->send($message)); + } + + public function testZeroIsReturnedIfAllTransportsReturnZero() + { + $message = $this->getMockery('Swift_Mime_Message'); + $t1 = $this->getMockery('Swift_Transport'); + $t2 = $this->getMockery('Swift_Transport'); + $connectionState1 = false; + $connectionState2 = false; + + $t1->shouldReceive('isStarted') + ->zeroOrMoreTimes() + ->andReturnUsing(function() use (&$connectionState1) { + return $connectionState1; + }); + $t1->shouldReceive('start') + ->once() + ->andReturnUsing(function() use (&$connectionState1) { + if (!$connectionState1) { + $connectionState1 = true; + } + }); + $t1->shouldReceive('send') + ->once() + ->with($message, \Mockery::any()) + ->andReturnUsing(function() use (&$connectionState1) { + if ($connectionState1) { + return 0; + } + return 1; + }); + + $t2->shouldReceive('isStarted') + ->zeroOrMoreTimes() + ->andReturnUsing(function() use (&$connectionState2) { + return $connectionState2; + }); + $t2->shouldReceive('start') + ->once() + ->andReturnUsing(function() use (&$connectionState2) { + if (!$connectionState2) { + $connectionState2 = true; + } + }); + $t2->shouldReceive('send') + ->once() + ->with($message, \Mockery::any()) + ->andReturnUsing(function() use (&$connectionState2) { + if ($connectionState2) { + return 0; + } + return 1; + }); + + $transport = $this->_getTransport(array($t1, $t2)); + $transport->start(); + $this->assertEquals(0, $transport->send($message)); + } + + public function testTransportsWhichThrowExceptionsAreNotRetried() + { + $e = new Swift_TransportException('maur b0rken'); + + $message1 = $this->getMockery('Swift_Mime_Message'); + $message2 = $this->getMockery('Swift_Mime_Message'); + $message3 = $this->getMockery('Swift_Mime_Message'); + $message4 = $this->getMockery('Swift_Mime_Message'); + $t1 = $this->getMockery('Swift_Transport'); + $t2 = $this->getMockery('Swift_Transport'); + $connectionState1 = false; + $connectionState2 = false; + + $testCase = $this; + $t1->shouldReceive('isStarted') + ->zeroOrMoreTimes() + ->andReturnUsing(function() use (&$connectionState1) { + return $connectionState1; + }); + $t1->shouldReceive('start') + ->once() + ->andReturnUsing(function() use (&$connectionState1) { + if (!$connectionState1) { + $connectionState1 = true; + } + }); + $t1->shouldReceive('send') + ->once() + ->with($message1, \Mockery::any()) + ->andReturnUsing(function() use (&$connectionState1, $e, $testCase) { + if ($connectionState1) { + throw $e; + } + $testCase->fail(); + }); + $t1->shouldReceive('send') + ->never() + ->with($message2, \Mockery::any()); + $t1->shouldReceive('send') + ->never() + ->with($message3, \Mockery::any()); + $t1->shouldReceive('send') + ->never() + ->with($message4, \Mockery::any()); + + $t2->shouldReceive('isStarted') + ->zeroOrMoreTimes() + ->andReturnUsing(function() use (&$connectionState2) { + return $connectionState2; + }); + $t2->shouldReceive('start') + ->once() + ->andReturnUsing(function() use (&$connectionState2) { + if (!$connectionState2) { + $connectionState2 = true; + } + }); + $t2->shouldReceive('send') + ->times(4) + ->with(\Mockery::anyOf($message1, $message3, $message3, $message4), \Mockery::any()) + ->andReturnUsing(function() use (&$connectionState2, $testCase) { + if ($connectionState2) { + return 1; + } + $testCase->fail(); + }); + + $transport = $this->_getTransport(array($t1, $t2)); + $transport->start(); + $this->assertEquals(1, $transport->send($message1)); + $this->assertEquals(1, $transport->send($message2)); + $this->assertEquals(1, $transport->send($message3)); + $this->assertEquals(1, $transport->send($message4)); + } + + public function testExceptionIsThrownIfAllTransportsDie() + { + $e = new Swift_TransportException('b0rken'); + + $message = $this->getMockery('Swift_Mime_Message'); + $t1 = $this->getMockery('Swift_Transport'); + $t2 = $this->getMockery('Swift_Transport'); + $connectionState1 = false; + $connectionState2 = false; + + $t1->shouldReceive('isStarted') + ->zeroOrMoreTimes() + ->andReturnUsing(function() use (&$connectionState1) { + return $connectionState1; + }); + $t1->shouldReceive('start') + ->once() + ->andReturnUsing(function() use (&$connectionState1) { + if (!$connectionState1) { + $connectionState1 = true; + } + }); + $t1->shouldReceive('send') + ->once() + ->with($message, \Mockery::any()) + ->andReturnUsing(function() use (&$connectionState1, $e) { + if ($connectionState1) { + throw $e; + } + }); + + $t2->shouldReceive('isStarted') + ->zeroOrMoreTimes() + ->andReturnUsing(function() use (&$connectionState2) { + return $connectionState2; + }); + $t2->shouldReceive('start') + ->once() + ->andReturnUsing(function() use (&$connectionState2) { + if (!$connectionState2) { + $connectionState2 = true; + } + }); + $t2->shouldReceive('send') + ->once() + ->with($message, \Mockery::any()) + ->andReturnUsing(function() use (&$connectionState2, $e) { + if ($connectionState2) { + throw $e; + } + }); + + $transport = $this->_getTransport(array($t1, $t2)); + $transport->start(); + try { + $transport->send($message); + $this->fail('All transports failed so Exception should be thrown'); + } catch (Exception $e) { + } + } + + public function testStoppingTransportStopsAllDelegates() + { + $t1 = $this->getMockery('Swift_Transport'); + $t2 = $this->getMockery('Swift_Transport'); + $connectionState1 = true; + $connectionState2 = true; + + $t1->shouldReceive('isStarted') + ->zeroOrMoreTimes() + ->andReturnUsing(function() use (&$connectionState1) { + return $connectionState1; + }); + $t1->shouldReceive('stop') + ->once() + ->andReturnUsing(function() use (&$connectionState1) { + if ($connectionState1) { + $connectionState1 = false; + } + }); + + $t2->shouldReceive('isStarted') + ->zeroOrMoreTimes() + ->andReturnUsing(function() use (&$connectionState2) { + return $connectionState2; + }); + $t2->shouldReceive('stop') + ->once() + ->andReturnUsing(function() use (&$connectionState2) { + if ($connectionState2) { + $connectionState2 = false; + } + }); + + $transport = $this->_getTransport(array($t1, $t2)); + $transport->start(); + $transport->stop(); + } + + public function testTransportShowsAsNotStartedIfAllDelegatesDead() + { + $e = new Swift_TransportException('b0rken'); + + $message = $this->getMockery('Swift_Mime_Message'); + $t1 = $this->getMockery('Swift_Transport'); + $t2 = $this->getMockery('Swift_Transport'); + $connectionState1 = false; + $connectionState2 = false; + + $t1->shouldReceive('isStarted') + ->zeroOrMoreTimes() + ->andReturnUsing(function() use (&$connectionState1) { + return $connectionState1; + }); + $t1->shouldReceive('start') + ->once() + ->andReturnUsing(function() use (&$connectionState1) { + if (!$connectionState1) { + $connectionState1 = true; + } + }); + $t1->shouldReceive('send') + ->once() + ->with($message, \Mockery::any()) + ->andReturnUsing(function() use (&$connectionState1, $e) { + if ($connectionState1) { + throw $e; + } + }); + + $t2->shouldReceive('isStarted') + ->zeroOrMoreTimes() + ->andReturnUsing(function() use (&$connectionState2) { + return $connectionState2; + }); + $t2->shouldReceive('start') + ->once() + ->andReturnUsing(function() use (&$connectionState2) { + if (!$connectionState2) { + $connectionState2 = true; + } + }); + $t2->shouldReceive('send') + ->once() + ->with($message, \Mockery::any()) + ->andReturnUsing(function() use (&$connectionState2, $e) { + if ($connectionState2) { + throw $e; + } + }); + + $transport = $this->_getTransport(array($t1, $t2)); + $transport->start(); + $this->assertTrue($transport->isStarted()); + try { + $transport->send($message); + $this->fail('All transports failed so Exception should be thrown'); + } catch (Exception $e) { + $this->assertFalse($transport->isStarted()); + } + } + + public function testRestartingTransportRestartsDeadDelegates() + { + $e = new Swift_TransportException('b0rken'); + + $message1 = $this->getMockery('Swift_Mime_Message'); + $message2 = $this->getMockery('Swift_Mime_Message'); + $t1 = $this->getMockery('Swift_Transport'); + $t2 = $this->getMockery('Swift_Transport'); + $connectionState1 = false; + $connectionState2 = false; + + $t1->shouldReceive('isStarted') + ->zeroOrMoreTimes() + ->andReturnUsing(function() use (&$connectionState1) { + return $connectionState1; + }); + $t1->shouldReceive('start') + ->twice() + ->andReturnUsing(function() use (&$connectionState1) { + if (!$connectionState1) { + $connectionState1 = true; + } + }); + $t1->shouldReceive('send') + ->once() + ->with($message1, \Mockery::any()) + ->andReturnUsing(function() use (&$connectionState1, $e) { + if ($connectionState1) { + $connectionState1 = false; + throw $e; + } + }); + $t1->shouldReceive('send') + ->once() + ->with($message2, \Mockery::any()) + ->andReturnUsing(function() use (&$connectionState1, $e) { + if ($connectionState1) { + return 10; + } + }); + + $t2->shouldReceive('isStarted') + ->zeroOrMoreTimes() + ->andReturnUsing(function() use (&$connectionState2) { + return $connectionState2; + }); + $t2->shouldReceive('start') + ->once() + ->andReturnUsing(function() use (&$connectionState2) { + if (!$connectionState2) { + $connectionState2 = true; + } + }); + $t2->shouldReceive('send') + ->once() + ->with($message1, \Mockery::any()) + ->andReturnUsing(function() use (&$connectionState2, $e) { + if ($connectionState2) { + throw $e; + } + }); + $t2->shouldReceive('send') + ->never() + ->with($message2, \Mockery::any()); + + $transport = $this->_getTransport(array($t1, $t2)); + $transport->start(); + $this->assertTrue($transport->isStarted()); + try { + $transport->send($message1); + $this->fail('All transports failed so Exception should be thrown'); + } catch (Exception $e) { + $this->assertFalse($transport->isStarted()); + } + //Restart and re-try + $transport->start(); + $this->assertTrue($transport->isStarted()); + $this->assertEquals(10, $transport->send($message2)); + } + + public function testFailureReferenceIsPassedToDelegates() + { + $failures = array(); + $testCase = $this; + + $message = $this->getMockery('Swift_Mime_Message'); + $t1 = $this->getMockery('Swift_Transport'); + $connectionState = false; + + $t1->shouldReceive('isStarted') + ->zeroOrMoreTimes() + ->andReturnUsing(function() use (&$connectionState) { + return $connectionState; + }); + $t1->shouldReceive('start') + ->once() + ->andReturnUsing(function() use (&$connectionState) { + if (!$connectionState) { + $connectionState = true; + } + }); + $t1->shouldReceive('send') + ->once() + ->with($message, \Mockery::on(function(&$var) use (&$failures, $testCase) { + return $testCase->varsAreReferences($var, $failures); + })) + ->andReturnUsing(function() use (&$connectionState) { + if ($connectionState) { + return 1; + } + }); + + $transport = $this->_getTransport(array($t1)); + $transport->start(); + $transport->send($message, $failures); + } + + public function testRegisterPluginDelegatesToLoadedTransports() + { + $plugin = $this->_createPlugin(); + + $t1 = $this->getMockery('Swift_Transport'); + $t2 = $this->getMockery('Swift_Transport'); + + $t1->shouldReceive('registerPlugin') + ->once() + ->with($plugin); + $t2->shouldReceive('registerPlugin') + ->once() + ->with($plugin); + + $transport = $this->_getTransport(array($t1, $t2)); + $transport->registerPlugin($plugin); + } + + /** + * Adapted from Yay_Matchers_ReferenceMatcher + */ + public function varsAreReferences(&$ref1, &$ref2) + { + if (is_object($ref2)) { + return ($ref1 === $ref2); + } + if ($ref1 !== $ref2) { + return false; + } + + $copy = $ref2; + $randomString = uniqid('yay'); + $ref2 = $randomString; + $isRef = ($ref1 === $ref2); + $ref2 = $copy; + + return $isRef; + } + + // -- Private helpers + + private function _getTransport(array $transports) + { + $transport = new Swift_Transport_LoadBalancedTransport(); + $transport->setTransports($transports); + + return $transport; + } + + private function _createPlugin() + { + return $this->getMockery('Swift_Events_EventListener'); + } + + private function _createInnerTransport() + { + return $this->getMockery('Swift_Transport'); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Transport/MailTransportTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Transport/MailTransportTest.php new file mode 100755 index 0000000..ef747e6 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Transport/MailTransportTest.php @@ -0,0 +1,311 @@ +_createInvoker(); + $dispatcher = $this->_createEventDispatcher(); + $transport = $this->_createTransport($invoker, $dispatcher); + + $headers = $this->_createHeaders(); + $message = $this->_createMessage($headers); + + $invoker->shouldReceive('mail') + ->once(); + + $transport->send($message); + } + + public function testTransportUsesToFieldBodyInSending() + { + $invoker = $this->_createInvoker(); + $dispatcher = $this->_createEventDispatcher(); + $transport = $this->_createTransport($invoker, $dispatcher); + + $to = $this->_createHeader(); + $headers = $this->_createHeaders(array( + 'To' => $to + )); + $message = $this->_createMessage($headers); + + $to->shouldReceive('getFieldBody') + ->zeroOrMoreTimes() + ->andReturn("Foo "); + $invoker->shouldReceive('mail') + ->once() + ->with("Foo ", \Mockery::any(), \Mockery::any(), \Mockery::any(), \Mockery::any()); + + $transport->send($message); + } + + public function testTransportUsesSubjectFieldBodyInSending() + { + $invoker = $this->_createInvoker(); + $dispatcher = $this->_createEventDispatcher(); + $transport = $this->_createTransport($invoker, $dispatcher); + + $subj = $this->_createHeader(); + $headers = $this->_createHeaders(array( + 'Subject' => $subj + )); + $message = $this->_createMessage($headers); + + $subj->shouldReceive('getFieldBody') + ->zeroOrMoreTimes() + ->andReturn("Thing"); + $invoker->shouldReceive('mail') + ->once() + ->with(\Mockery::any(), "Thing", \Mockery::any(), \Mockery::any(), \Mockery::any()); + + $transport->send($message); + } + + public function testTransportUsesBodyOfMessage() + { + $invoker = $this->_createInvoker(); + $dispatcher = $this->_createEventDispatcher(); + $transport = $this->_createTransport($invoker, $dispatcher); + + $headers = $this->_createHeaders(); + $message = $this->_createMessage($headers); + + $message->shouldReceive('toString') + ->zeroOrMoreTimes() + ->andReturn( + "To: Foo \r\n" . + "\r\n" . + "This body" + ); + $invoker->shouldReceive('mail') + ->once() + ->with(\Mockery::any(), \Mockery::any(), "This body", \Mockery::any(), \Mockery::any()); + + $transport->send($message); + } + + public function testTransportUsesHeadersFromMessage() + { + $invoker = $this->_createInvoker(); + $dispatcher = $this->_createEventDispatcher(); + $transport = $this->_createTransport($invoker, $dispatcher); + + $headers = $this->_createHeaders(); + $message = $this->_createMessage($headers); + + $message->shouldReceive('toString') + ->zeroOrMoreTimes() + ->andReturn( + "Subject: Stuff\r\n" . + "\r\n" . + "This body" + ); + $invoker->shouldReceive('mail') + ->once() + ->with(\Mockery::any(), \Mockery::any(), \Mockery::any(), "Subject: Stuff" . PHP_EOL, \Mockery::any()); + + $transport->send($message); + } + + public function testTransportReturnsCountOfAllRecipientsIfInvokerReturnsTrue() + { + $invoker = $this->_createInvoker(); + $dispatcher = $this->_createEventDispatcher(); + $transport = $this->_createTransport($invoker, $dispatcher); + + $headers = $this->_createHeaders(); + $message = $this->_createMessage($headers); + + $message->shouldReceive('getTo') + ->zeroOrMoreTimes() + ->andReturn(array('foo@bar'=>null, 'zip@button'=>null)); + $message->shouldReceive('getCc') + ->zeroOrMoreTimes() + ->andReturn(array('test@test'=>null)); + $invoker->shouldReceive('mail') + ->once() + ->with(\Mockery::any(), \Mockery::any(), \Mockery::any(), \Mockery::any(), \Mockery::any()) + ->andReturn(true); + + $this->assertEquals(3, $transport->send($message)); + } + + public function testTransportReturnsZeroIfInvokerReturnsFalse() + { + $invoker = $this->_createInvoker(); + $dispatcher = $this->_createEventDispatcher(); + $transport = $this->_createTransport($invoker, $dispatcher); + + $headers = $this->_createHeaders(); + $message = $this->_createMessage($headers); + + $message->shouldReceive('getTo') + ->zeroOrMoreTimes() + ->andReturn(array('foo@bar'=>null, 'zip@button'=>null)); + $message->shouldReceive('getCc') + ->zeroOrMoreTimes() + ->andReturn(array('test@test'=>null)); + $invoker->shouldReceive('mail') + ->once() + ->with(\Mockery::any(), \Mockery::any(), \Mockery::any(), \Mockery::any(), \Mockery::any()) + ->andReturn(false); + + $this->assertEquals(0, $transport->send($message)); + } + + public function testToHeaderIsRemovedFromHeaderSetDuringSending() + { + $invoker = $this->_createInvoker(); + $dispatcher = $this->_createEventDispatcher(); + $transport = $this->_createTransport($invoker, $dispatcher); + + $to = $this->_createHeader(); + $headers = $this->_createHeaders(array( + 'To' => $to + )); + $message = $this->_createMessage($headers); + + $headers->shouldReceive('remove') + ->once() + ->with('To'); + $headers->shouldReceive('remove') + ->zeroOrMoreTimes(); + $invoker->shouldReceive('mail') + ->once() + ->with(\Mockery::any(), \Mockery::any(), \Mockery::any(), \Mockery::any(), \Mockery::any()); + + $transport->send($message); + } + + public function testSubjectHeaderIsRemovedFromHeaderSetDuringSending() + { + $invoker = $this->_createInvoker(); + $dispatcher = $this->_createEventDispatcher(); + $transport = $this->_createTransport($invoker, $dispatcher); + + $subject = $this->_createHeader(); + $headers = $this->_createHeaders(array( + 'Subject' => $subject + )); + $message = $this->_createMessage($headers); + + $headers->shouldReceive('remove') + ->once() + ->with('Subject'); + $headers->shouldReceive('remove') + ->zeroOrMoreTimes(); + $invoker->shouldReceive('mail') + ->once() + ->with(\Mockery::any(), \Mockery::any(), \Mockery::any(), \Mockery::any(), \Mockery::any()); + + $transport->send($message); + } + + public function testToHeaderIsPutBackAfterSending() + { + $invoker = $this->_createInvoker(); + $dispatcher = $this->_createEventDispatcher(); + $transport = $this->_createTransport($invoker, $dispatcher); + + $to = $this->_createHeader(); + $headers = $this->_createHeaders(array( + 'To' => $to + )); + $message = $this->_createMessage($headers); + + $headers->shouldReceive('set') + ->once() + ->with($to); + $headers->shouldReceive('set') + ->zeroOrMoreTimes(); + $invoker->shouldReceive('mail') + ->once() + ->with(\Mockery::any(), \Mockery::any(), \Mockery::any(), \Mockery::any(), \Mockery::any()); + + $transport->send($message); + } + + public function testSubjectHeaderIsPutBackAfterSending() + { + $invoker = $this->_createInvoker(); + $dispatcher = $this->_createEventDispatcher(); + $transport = $this->_createTransport($invoker, $dispatcher); + + $subject = $this->_createHeader(); + $headers = $this->_createHeaders(array( + 'Subject' => $subject + )); + $message = $this->_createMessage($headers); + + $headers->shouldReceive('set') + ->once() + ->with($subject); + $headers->shouldReceive('set') + ->zeroOrMoreTimes(); + $invoker->shouldReceive('mail') + ->once() + ->with(\Mockery::any(), \Mockery::any(), \Mockery::any(), \Mockery::any(), \Mockery::any()); + + $transport->send($message); + } + + // -- Creation Methods + + private function _createTransport($invoker, $dispatcher) + { + return new Swift_Transport_MailTransport($invoker, $dispatcher); + } + + private function _createEventDispatcher() + { + return $this->getMockery('Swift_Events_EventDispatcher')->shouldIgnoreMissing(); + } + + private function _createInvoker() + { + return $this->getMockery('Swift_Transport_MailInvoker'); + } + + private function _createMessage($headers) + { + $message = $this->getMockery('Swift_Mime_Message')->shouldIgnoreMissing(); + $message->shouldReceive('getHeaders') + ->zeroOrMoreTimes() + ->andReturn($headers); + + return $message; + } + + private function _createHeaders($headers = array()) + { + $set = $this->getMockery('Swift_Mime_HeaderSet')->shouldIgnoreMissing(); + + if (count($headers) > 0) { + foreach ($headers as $name => $header) { + $set->shouldReceive('get') + ->zeroOrMoreTimes() + ->with($name) + ->andReturn($header); + $set->shouldReceive('has') + ->zeroOrMoreTimes() + ->with($name) + ->andReturn(true); + } + } + + $header = $this->_createHeader(); + $set->shouldReceive('get') + ->zeroOrMoreTimes() + ->andReturn($header); + $set->shouldReceive('has') + ->zeroOrMoreTimes() + ->andReturn(true); + + return $set; + } + + private function _createHeader() + { + return $this->getMockery('Swift_Mime_Header')->shouldIgnoreMissing(); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Transport/SendmailTransportTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Transport/SendmailTransportTest.php new file mode 100755 index 0000000..7d74978 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Transport/SendmailTransportTest.php @@ -0,0 +1,152 @@ +_createEventDispatcher(); + } + $transport = new Swift_Transport_SendmailTransport($buf, $dispatcher); + $transport->setCommand($command); + + return $transport; + } + + protected function _getSendmail($buf, $dispatcher = null) + { + if (!$dispatcher) { + $dispatcher = $this->_createEventDispatcher(); + } + $sendmail = new Swift_Transport_SendmailTransport($buf, $dispatcher); + + return $sendmail; + } + + public function testCommandCanBeSetAndFetched() + { + $buf = $this->_getBuffer(); + $sendmail = $this->_getSendmail($buf); + + $sendmail->setCommand('/usr/sbin/sendmail -bs'); + $this->assertEquals('/usr/sbin/sendmail -bs', $sendmail->getCommand()); + $sendmail->setCommand('/usr/sbin/sendmail -oi -t'); + $this->assertEquals('/usr/sbin/sendmail -oi -t', $sendmail->getCommand()); + } + + public function testSendingMessageIn_t_ModeUsesSimplePipe() + { + $buf = $this->_getBuffer(); + $sendmail = $this->_getSendmail($buf); + $message = $this->_createMessage(); + + $message->shouldReceive('getTo') + ->zeroOrMoreTimes() + ->andReturn(array('foo@bar'=>'Foobar', 'zip@button'=>'Zippy')); + $message->shouldReceive('toByteStream') + ->once() + ->with($buf); + $buf->shouldReceive('initialize') + ->once(); + $buf->shouldReceive('terminate') + ->once(); + $buf->shouldReceive('setWriteTranslations') + ->once() + ->with(array("\r\n"=>"\n", "\n." => "\n..")); + $buf->shouldReceive('setWriteTranslations') + ->once() + ->with(array()); + + $sendmail->setCommand('/usr/sbin/sendmail -t'); + $this->assertEquals(2, $sendmail->send($message)); + } + + public function testSendingIn_t_ModeWith_i_FlagDoesntEscapeDot() + { + $buf = $this->_getBuffer(); + $sendmail = $this->_getSendmail($buf); + $message = $this->_createMessage(); + + $message->shouldReceive('getTo') + ->zeroOrMoreTimes() + ->andReturn(array('foo@bar'=>'Foobar', 'zip@button'=>'Zippy')); + $message->shouldReceive('toByteStream') + ->once() + ->with($buf); + $buf->shouldReceive('initialize') + ->once(); + $buf->shouldReceive('terminate') + ->once(); + $buf->shouldReceive('setWriteTranslations') + ->once() + ->with(array("\r\n"=>"\n")); + $buf->shouldReceive('setWriteTranslations') + ->once() + ->with(array()); + + $sendmail->setCommand('/usr/sbin/sendmail -i -t'); + $this->assertEquals(2, $sendmail->send($message)); + } + + public function testSendingInTModeWith_oi_FlagDoesntEscapeDot() + { + $buf = $this->_getBuffer(); + $sendmail = $this->_getSendmail($buf); + $message = $this->_createMessage(); + + $message->shouldReceive('getTo') + ->zeroOrMoreTimes() + ->andReturn(array('foo@bar'=>'Foobar', 'zip@button'=>'Zippy')); + $message->shouldReceive('toByteStream') + ->once() + ->with($buf); + $buf->shouldReceive('initialize') + ->once(); + $buf->shouldReceive('terminate') + ->once(); + $buf->shouldReceive('setWriteTranslations') + ->once() + ->with(array("\r\n"=>"\n")); + $buf->shouldReceive('setWriteTranslations') + ->once() + ->with(array()); + + $sendmail->setCommand('/usr/sbin/sendmail -oi -t'); + $this->assertEquals(2, $sendmail->send($message)); + } + + public function testSendingMessageRegeneratesId() + { + $buf = $this->_getBuffer(); + $sendmail = $this->_getSendmail($buf); + $message = $this->_createMessage(); + + $message->shouldReceive('getTo') + ->zeroOrMoreTimes() + ->andReturn(array('foo@bar'=>'Foobar', 'zip@button'=>'Zippy')); + $message->shouldReceive('generateId'); + $buf->shouldReceive('initialize') + ->once(); + $buf->shouldReceive('terminate') + ->once(); + $buf->shouldReceive('setWriteTranslations') + ->once() + ->with(array("\r\n"=>"\n", "\n." => "\n..")); + $buf->shouldReceive('setWriteTranslations') + ->once() + ->with(array()); + + $sendmail->setCommand('/usr/sbin/sendmail -t'); + $this->assertEquals(2, $sendmail->send($message)); + } + + public function testFluidInterface() + { + $buf = $this->_getBuffer(); + $sendmail = $this->_getTransport($buf); + + $ref = $sendmail->setCommand('/foo'); + $this->assertEquals($ref, $sendmail); + } +} diff --git a/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Transport/StreamBufferTest.php b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Transport/StreamBufferTest.php new file mode 100755 index 0000000..3ec74b3 --- /dev/null +++ b/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Transport/StreamBufferTest.php @@ -0,0 +1,45 @@ +_createFactory(); + $factory->expects($this->once()) + ->method('createFilter') + ->with('a', 'b') + ->will($this->returnCallback(array($this, '_createFilter'))); + + $buffer = $this->_createBuffer($factory); + $buffer->setWriteTranslations(array('a' => 'b')); + } + + public function testOverridingTranslationsOnlyAddsNeededFilters() + { + $factory = $this->_createFactory(); + $factory->expects($this->exactly(2)) + ->method('createFilter') + ->will($this->returnCallback(array($this, '_createFilter'))); + + $buffer = $this->_createBuffer($factory); + $buffer->setWriteTranslations(array('a' => 'b')); + $buffer->setWriteTranslations(array('x' => 'y', 'a' => 'b')); + } + + // -- Creation methods + + private function _createBuffer($replacementFactory) + { + return new Swift_Transport_StreamBuffer($replacementFactory); + } + + private function _createFactory() + { + return $this->getMock('Swift_ReplacementFilterFactory'); + } + + public function _createFilter() + { + return $this->getMock('Swift_StreamFilter'); + } +} diff --git a/vendor/symfony/browser-kit/Symfony/Component/BrowserKit/.gitignore b/vendor/symfony/browser-kit/Symfony/Component/BrowserKit/.gitignore new file mode 100755 index 0000000..c49a5d8 --- /dev/null +++ b/vendor/symfony/browser-kit/Symfony/Component/BrowserKit/.gitignore @@ -0,0 +1,3 @@ +vendor/ +composer.lock +phpunit.xml diff --git a/vendor/symfony/browser-kit/Symfony/Component/BrowserKit/CHANGELOG.md b/vendor/symfony/browser-kit/Symfony/Component/BrowserKit/CHANGELOG.md new file mode 100755 index 0000000..d2b1074 --- /dev/null +++ b/vendor/symfony/browser-kit/Symfony/Component/BrowserKit/CHANGELOG.md @@ -0,0 +1,18 @@ +CHANGELOG +========= + +2.3.0 +----- + + * [BC BREAK] `Client::followRedirect()` won't redirect responses with + a non-3xx Status Code and `Location` header anymore, as per + http://tools.ietf.org/html/rfc2616#section-14.30 + + * added `Client::getInternalRequest()` and `Client::getInternalResponse()` to + have access to the BrowserKit internal request and response objects + +2.1.0 +----- + + * [BC BREAK] The CookieJar internals have changed to allow cookies with the + same name on different sub-domains/sub-paths diff --git a/vendor/symfony/browser-kit/Symfony/Component/BrowserKit/Client.php b/vendor/symfony/browser-kit/Symfony/Component/BrowserKit/Client.php new file mode 100755 index 0000000..a7a8401 --- /dev/null +++ b/vendor/symfony/browser-kit/Symfony/Component/BrowserKit/Client.php @@ -0,0 +1,617 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\BrowserKit; + +use Symfony\Component\DomCrawler\Crawler; +use Symfony\Component\DomCrawler\Link; +use Symfony\Component\DomCrawler\Form; +use Symfony\Component\Process\PhpProcess; + +/** + * Client simulates a browser. + * + * To make the actual request, you need to implement the doRequest() method. + * + * If you want to be able to run requests in their own process (insulated flag), + * you need to also implement the getScript() method. + * + * @author Fabien Potencier + * + * @api + */ +abstract class Client +{ + protected $history; + protected $cookieJar; + protected $server = array(); + protected $internalRequest; + protected $request; + protected $internalResponse; + protected $response; + protected $crawler; + protected $insulated = false; + protected $redirect; + protected $followRedirects = true; + + private $maxRedirects = -1; + private $redirectCount = 0; + private $isMainRequest = true; + + /** + * Constructor. + * + * @param array $server The server parameters (equivalent of $_SERVER) + * @param History $history A History instance to store the browser history + * @param CookieJar $cookieJar A CookieJar instance to store the cookies + * + * @api + */ + public function __construct(array $server = array(), History $history = null, CookieJar $cookieJar = null) + { + $this->setServerParameters($server); + $this->history = $history ?: new History(); + $this->cookieJar = $cookieJar ?: new CookieJar(); + } + + /** + * Sets whether to automatically follow redirects or not. + * + * @param bool $followRedirect Whether to follow redirects + * + * @api + */ + public function followRedirects($followRedirect = true) + { + $this->followRedirects = (bool) $followRedirect; + } + + /** + * Sets the maximum number of requests that crawler can follow. + * + * @param int $maxRedirects + */ + public function setMaxRedirects($maxRedirects) + { + $this->maxRedirects = $maxRedirects < 0 ? -1 : $maxRedirects; + $this->followRedirects = -1 != $this->maxRedirects; + } + + /** + * Sets the insulated flag. + * + * @param bool $insulated Whether to insulate the requests or not + * + * @throws \RuntimeException When Symfony Process Component is not installed + * + * @api + */ + public function insulate($insulated = true) + { + if ($insulated && !class_exists('Symfony\\Component\\Process\\Process')) { + // @codeCoverageIgnoreStart + throw new \RuntimeException('Unable to isolate requests as the Symfony Process Component is not installed.'); + // @codeCoverageIgnoreEnd + } + + $this->insulated = (bool) $insulated; + } + + /** + * Sets server parameters. + * + * @param array $server An array of server parameters + * + * @api + */ + public function setServerParameters(array $server) + { + $this->server = array_merge(array( + 'HTTP_HOST' => 'localhost', + 'HTTP_USER_AGENT' => 'Symfony2 BrowserKit', + ), $server); + } + + /** + * Sets single server parameter. + * + * @param string $key A key of the parameter + * @param string $value A value of the parameter + */ + public function setServerParameter($key, $value) + { + $this->server[$key] = $value; + } + + /** + * Gets single server parameter for specified key. + * + * @param string $key A key of the parameter to get + * @param string $default A default value when key is undefined + * + * @return string A value of the parameter + */ + public function getServerParameter($key, $default = '') + { + return (isset($this->server[$key])) ? $this->server[$key] : $default; + } + + /** + * Returns the History instance. + * + * @return History A History instance + * + * @api + */ + public function getHistory() + { + return $this->history; + } + + /** + * Returns the CookieJar instance. + * + * @return CookieJar A CookieJar instance + * + * @api + */ + public function getCookieJar() + { + return $this->cookieJar; + } + + /** + * Returns the current Crawler instance. + * + * @return Crawler|null A Crawler instance + * + * @api + */ + public function getCrawler() + { + return $this->crawler; + } + + /** + * Returns the current BrowserKit Response instance. + * + * @return Response|null A BrowserKit Response instance + * + * @api + */ + public function getInternalResponse() + { + return $this->internalResponse; + } + + /** + * Returns the current origin response instance. + * + * The origin response is the response instance that is returned + * by the code that handles requests. + * + * @return object|null A response instance + * + * @see doRequest + * + * @api + */ + public function getResponse() + { + return $this->response; + } + + /** + * Returns the current BrowserKit Request instance. + * + * @return Request|null A BrowserKit Request instance + * + * @api + */ + public function getInternalRequest() + { + return $this->internalRequest; + } + + /** + * Returns the current origin Request instance. + * + * The origin request is the request instance that is sent + * to the code that handles requests. + * + * @return object|null A Request instance + * + * @see doRequest + * + * @api + */ + public function getRequest() + { + return $this->request; + } + + /** + * Clicks on a given link. + * + * @param Link $link A Link instance + * + * @return Crawler + * + * @api + */ + public function click(Link $link) + { + if ($link instanceof Form) { + return $this->submit($link); + } + + return $this->request($link->getMethod(), $link->getUri()); + } + + /** + * Submits a form. + * + * @param Form $form A Form instance + * @param array $values An array of form field values + * + * @return Crawler + * + * @api + */ + public function submit(Form $form, array $values = array()) + { + $form->setValues($values); + + return $this->request($form->getMethod(), $form->getUri(), $form->getPhpValues(), $form->getPhpFiles()); + } + + /** + * Calls a URI. + * + * @param string $method The request method + * @param string $uri The URI to fetch + * @param array $parameters The Request parameters + * @param array $files The files + * @param array $server The server parameters (HTTP headers are referenced with a HTTP_ prefix as PHP does) + * @param string $content The raw body data + * @param bool $changeHistory Whether to update the history or not (only used internally for back(), forward(), and reload()) + * + * @return Crawler + * + * @api + */ + public function request($method, $uri, array $parameters = array(), array $files = array(), array $server = array(), $content = null, $changeHistory = true) + { + if ($this->isMainRequest) { + $this->redirectCount = 0; + } else { + ++$this->redirectCount; + } + + $uri = $this->getAbsoluteUri($uri); + + if (isset($server['HTTP_HOST'])) { + $uri = preg_replace('{^(https?\://)'.parse_url($uri, PHP_URL_HOST).'}', '${1}'.$server['HTTP_HOST'], $uri); + } + + if (isset($server['HTTPS'])) { + $uri = preg_replace('{^'.parse_url($uri, PHP_URL_SCHEME).'}', $server['HTTPS'] ? 'https' : 'http', $uri); + } + + $server = array_merge($this->server, $server); + + if (!$this->history->isEmpty()) { + $server['HTTP_REFERER'] = $this->history->current()->getUri(); + } + + $server['HTTP_HOST'] = parse_url($uri, PHP_URL_HOST); + + if ($port = parse_url($uri, PHP_URL_PORT)) { + $server['HTTP_HOST'] .= ':'.$port; + } + + $server['HTTPS'] = 'https' == parse_url($uri, PHP_URL_SCHEME); + + $this->internalRequest = new Request($uri, $method, $parameters, $files, $this->cookieJar->allValues($uri), $server, $content); + + $this->request = $this->filterRequest($this->internalRequest); + + if (true === $changeHistory) { + $this->history->add($this->internalRequest); + } + + if ($this->insulated) { + $this->response = $this->doRequestInProcess($this->request); + } else { + $this->response = $this->doRequest($this->request); + } + + $this->internalResponse = $this->filterResponse($this->response); + + $this->cookieJar->updateFromResponse($this->internalResponse, $uri); + + $status = $this->internalResponse->getStatus(); + + if ($status >= 300 && $status < 400) { + $this->redirect = $this->internalResponse->getHeader('Location'); + } else { + $this->redirect = null; + } + + if ($this->followRedirects && $this->redirect) { + return $this->crawler = $this->followRedirect(); + } + + return $this->crawler = $this->createCrawlerFromContent($this->internalRequest->getUri(), $this->internalResponse->getContent(), $this->internalResponse->getHeader('Content-Type')); + } + + /** + * Makes a request in another process. + * + * @param object $request An origin request instance + * + * @return object An origin response instance + * + * @throws \RuntimeException When processing returns exit code + */ + protected function doRequestInProcess($request) + { + // We set the TMPDIR (for Macs) and TEMP (for Windows), because on these platforms the temp directory changes based on the user. + $process = new PhpProcess($this->getScript($request), null, array('TMPDIR' => sys_get_temp_dir(), 'TEMP' => sys_get_temp_dir())); + $process->run(); + + if (!$process->isSuccessful() || !preg_match('/^O\:\d+\:/', $process->getOutput())) { + throw new \RuntimeException(sprintf('OUTPUT: %s ERROR OUTPUT: %s', $process->getOutput(), $process->getErrorOutput())); + } + + return unserialize($process->getOutput()); + } + + /** + * Makes a request. + * + * @param object $request An origin request instance + * + * @return object An origin response instance + */ + abstract protected function doRequest($request); + + /** + * Returns the script to execute when the request must be insulated. + * + * @param object $request An origin request instance + * + * @throws \LogicException When this abstract class is not implemented + */ + protected function getScript($request) + { + // @codeCoverageIgnoreStart + throw new \LogicException('To insulate requests, you need to override the getScript() method.'); + // @codeCoverageIgnoreEnd + } + + /** + * Filters the BrowserKit request to the origin one. + * + * @param Request $request The BrowserKit Request to filter + * + * @return object An origin request instance + */ + protected function filterRequest(Request $request) + { + return $request; + } + + /** + * Filters the origin response to the BrowserKit one. + * + * @param object $response The origin response to filter + * + * @return Response An BrowserKit Response instance + */ + protected function filterResponse($response) + { + return $response; + } + + /** + * Creates a crawler. + * + * This method returns null if the DomCrawler component is not available. + * + * @param string $uri A URI + * @param string $content Content for the crawler to use + * @param string $type Content type + * + * @return Crawler|null + */ + protected function createCrawlerFromContent($uri, $content, $type) + { + if (!class_exists('Symfony\Component\DomCrawler\Crawler')) { + return; + } + + $crawler = new Crawler(null, $uri); + $crawler->addContent($content, $type); + + return $crawler; + } + + /** + * Goes back in the browser history. + * + * @return Crawler + * + * @api + */ + public function back() + { + return $this->requestFromRequest($this->history->back(), false); + } + + /** + * Goes forward in the browser history. + * + * @return Crawler + * + * @api + */ + public function forward() + { + return $this->requestFromRequest($this->history->forward(), false); + } + + /** + * Reloads the current browser. + * + * @return Crawler + * + * @api + */ + public function reload() + { + return $this->requestFromRequest($this->history->current(), false); + } + + /** + * Follow redirects? + * + * @return Crawler + * + * @throws \LogicException If request was not a redirect + * + * @api + */ + public function followRedirect() + { + if (empty($this->redirect)) { + throw new \LogicException('The request was not redirected.'); + } + + if (-1 !== $this->maxRedirects) { + if ($this->redirectCount > $this->maxRedirects) { + throw new \LogicException(sprintf('The maximum number (%d) of redirections was reached.', $this->maxRedirects)); + } + } + + $request = $this->internalRequest; + + if (in_array($this->internalResponse->getStatus(), array(302, 303))) { + $method = 'get'; + $files = array(); + $content = null; + } else { + $method = $request->getMethod(); + $files = $request->getFiles(); + $content = $request->getContent(); + } + + if ('get' === strtolower($method)) { + // Don't forward parameters for GET request as it should reach the redirection URI + $parameters = array(); + } else { + $parameters = $request->getParameters(); + } + + $server = $request->getServer(); + $server = $this->updateServerFromUri($server, $this->redirect); + + $this->isMainRequest = false; + + $response = $this->request($method, $this->redirect, $parameters, $files, $server, $content); + + $this->isMainRequest = true; + + return $response; + } + + /** + * Restarts the client. + * + * It flushes history and all cookies. + * + * @api + */ + public function restart() + { + $this->cookieJar->clear(); + $this->history->clear(); + } + + /** + * Takes a URI and converts it to absolute if it is not already absolute. + * + * @param string $uri A URI + * + * @return string An absolute URI + */ + protected function getAbsoluteUri($uri) + { + // already absolute? + if (0 === strpos($uri, 'http')) { + return $uri; + } + + if (!$this->history->isEmpty()) { + $currentUri = $this->history->current()->getUri(); + } else { + $currentUri = sprintf('http%s://%s/', + isset($this->server['HTTPS']) ? 's' : '', + isset($this->server['HTTP_HOST']) ? $this->server['HTTP_HOST'] : 'localhost' + ); + } + + // protocol relative URL + if (0 === strpos($uri, '//')) { + return parse_url($currentUri, PHP_URL_SCHEME).':'.$uri; + } + + // anchor? + if (!$uri || '#' == $uri[0]) { + return preg_replace('/#.*?$/', '', $currentUri).$uri; + } + + if ('/' !== $uri[0]) { + $path = parse_url($currentUri, PHP_URL_PATH); + + if ('/' !== substr($path, -1)) { + $path = substr($path, 0, strrpos($path, '/') + 1); + } + + $uri = $path.$uri; + } + + return preg_replace('#^(.*?//[^/]+)\/.*$#', '$1', $currentUri).$uri; + } + + /** + * Makes a request from a Request object directly. + * + * @param Request $request A Request instance + * @param bool $changeHistory Whether to update the history or not (only used internally for back(), forward(), and reload()) + * + * @return Crawler + */ + protected function requestFromRequest(Request $request, $changeHistory = true) + { + return $this->request($request->getMethod(), $request->getUri(), $request->getParameters(), $request->getFiles(), $request->getServer(), $request->getContent(), $changeHistory); + } + + private function updateServerFromUri($server, $uri) + { + $server['HTTP_HOST'] = parse_url($uri, PHP_URL_HOST); + $scheme = parse_url($uri, PHP_URL_SCHEME); + $server['HTTPS'] = null === $scheme ? $server['HTTPS'] : 'https' == $scheme; + unset($server['HTTP_IF_NONE_MATCH'], $server['HTTP_IF_MODIFIED_SINCE']); + + return $server; + } +} diff --git a/vendor/symfony/browser-kit/Symfony/Component/BrowserKit/Cookie.php b/vendor/symfony/browser-kit/Symfony/Component/BrowserKit/Cookie.php new file mode 100755 index 0000000..90636e9 --- /dev/null +++ b/vendor/symfony/browser-kit/Symfony/Component/BrowserKit/Cookie.php @@ -0,0 +1,332 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\BrowserKit; + +/** + * Cookie represents an HTTP cookie. + * + * @author Fabien Potencier + * + * @api + */ +class Cookie +{ + /** + * Handles dates as defined by RFC 2616 section 3.3.1, and also some other + * non-standard, but common formats. + * + * @var array + */ + private static $dateFormats = array( + 'D, d M Y H:i:s T', + 'D, d-M-y H:i:s T', + 'D, d-M-Y H:i:s T', + 'D, d-m-y H:i:s T', + 'D, d-m-Y H:i:s T', + 'D M j G:i:s Y', + 'D M d H:i:s Y T', + ); + + protected $name; + protected $value; + protected $expires; + protected $path; + protected $domain; + protected $secure; + protected $httponly; + protected $rawValue; + + /** + * Sets a cookie. + * + * @param string $name The cookie name + * @param string $value The value of the cookie + * @param string $expires The time the cookie expires + * @param string $path The path on the server in which the cookie will be available on + * @param string $domain The domain that the cookie is available + * @param bool $secure Indicates that the cookie should only be transmitted over a secure HTTPS connection from the client + * @param bool $httponly The cookie httponly flag + * @param bool $encodedValue Whether the value is encoded or not + * + * @api + */ + public function __construct($name, $value, $expires = null, $path = null, $domain = '', $secure = false, $httponly = true, $encodedValue = false) + { + if ($encodedValue) { + $this->value = urldecode($value); + $this->rawValue = $value; + } else { + $this->value = $value; + $this->rawValue = urlencode($value); + } + $this->name = $name; + $this->expires = null === $expires ? null : (int) $expires; + $this->path = empty($path) ? '/' : $path; + $this->domain = $domain; + $this->secure = (bool) $secure; + $this->httponly = (bool) $httponly; + } + + /** + * Returns the HTTP representation of the Cookie. + * + * @return string The HTTP representation of the Cookie + * + * @throws \UnexpectedValueException + * + * @api + */ + public function __toString() + { + $cookie = sprintf('%s=%s', $this->name, $this->rawValue); + + if (null !== $this->expires) { + $dateTime = \DateTime::createFromFormat('U', $this->expires, new \DateTimeZone('GMT')); + + if ($dateTime === false) { + throw new \UnexpectedValueException(sprintf('The cookie expiration time "%s" is not valid.'), $this->expires); + } + + $cookie .= '; expires='.str_replace('+0000', '', $dateTime->format(self::$dateFormats[0])); + } + + if ('' !== $this->domain) { + $cookie .= '; domain='.$this->domain; + } + + if ($this->path) { + $cookie .= '; path='.$this->path; + } + + if ($this->secure) { + $cookie .= '; secure'; + } + + if ($this->httponly) { + $cookie .= '; httponly'; + } + + return $cookie; + } + + /** + * Creates a Cookie instance from a Set-Cookie header value. + * + * @param string $cookie A Set-Cookie header value + * @param string $url The base URL + * + * @return Cookie A Cookie instance + * + * @throws \InvalidArgumentException + * + * @api + */ + public static function fromString($cookie, $url = null) + { + $parts = explode(';', $cookie); + + if (false === strpos($parts[0], '=')) { + throw new \InvalidArgumentException(sprintf('The cookie string "%s" is not valid.', $parts[0])); + } + + list($name, $value) = explode('=', array_shift($parts), 2); + + $values = array( + 'name' => trim($name), + 'value' => trim($value), + 'expires' => null, + 'path' => '/', + 'domain' => '', + 'secure' => false, + 'httponly' => false, + 'passedRawValue' => true, + ); + + if (null !== $url) { + if ((false === $urlParts = parse_url($url)) || !isset($urlParts['host'])) { + throw new \InvalidArgumentException(sprintf('The URL "%s" is not valid.', $url)); + } + + $values['domain'] = $urlParts['host']; + $values['path'] = isset($urlParts['path']) ? substr($urlParts['path'], 0, strrpos($urlParts['path'], '/')) : ''; + } + + foreach ($parts as $part) { + $part = trim($part); + + if ('secure' === strtolower($part)) { + // Ignore the secure flag if the original URI is not given or is not HTTPS + if (!$url || !isset($urlParts['scheme']) || 'https' != $urlParts['scheme']) { + continue; + } + + $values['secure'] = true; + + continue; + } + + if ('httponly' === strtolower($part)) { + $values['httponly'] = true; + + continue; + } + + if (2 === count($elements = explode('=', $part, 2))) { + if ('expires' === strtolower($elements[0])) { + $elements[1] = self::parseDate($elements[1]); + } + + $values[strtolower($elements[0])] = $elements[1]; + } + } + + return new static( + $values['name'], + $values['value'], + $values['expires'], + $values['path'], + $values['domain'], + $values['secure'], + $values['httponly'], + $values['passedRawValue'] + ); + } + + private static function parseDate($dateValue) + { + // trim single quotes around date if present + if (($length = strlen($dateValue)) > 1 && "'" === $dateValue[0] && "'" === $dateValue[$length-1]) { + $dateValue = substr($dateValue, 1, -1); + } + + foreach (self::$dateFormats as $dateFormat) { + if (false !== $date = \DateTime::createFromFormat($dateFormat, $dateValue, new \DateTimeZone('GMT'))) { + return $date->getTimestamp(); + } + } + + // attempt a fallback for unusual formatting + if (false !== $date = date_create($dateValue, new \DateTimeZone('GMT'))) { + return $date->getTimestamp(); + } + + throw new \InvalidArgumentException(sprintf('Could not parse date "%s".', $dateValue)); + } + + /** + * Gets the name of the cookie. + * + * @return string The cookie name + * + * @api + */ + public function getName() + { + return $this->name; + } + + /** + * Gets the value of the cookie. + * + * @return string The cookie value + * + * @api + */ + public function getValue() + { + return $this->value; + } + + /** + * Gets the raw value of the cookie. + * + * @return string The cookie value + * + * @api + */ + public function getRawValue() + { + return $this->rawValue; + } + + /** + * Gets the expires time of the cookie. + * + * @return string The cookie expires time + * + * @api + */ + public function getExpiresTime() + { + return $this->expires; + } + + /** + * Gets the path of the cookie. + * + * @return string The cookie path + * + * @api + */ + public function getPath() + { + return $this->path; + } + + /** + * Gets the domain of the cookie. + * + * @return string The cookie domain + * + * @api + */ + public function getDomain() + { + return $this->domain; + } + + /** + * Returns the secure flag of the cookie. + * + * @return bool The cookie secure flag + * + * @api + */ + public function isSecure() + { + return $this->secure; + } + + /** + * Returns the httponly flag of the cookie. + * + * @return bool The cookie httponly flag + * + * @api + */ + public function isHttpOnly() + { + return $this->httponly; + } + + /** + * Returns true if the cookie has expired. + * + * @return bool true if the cookie has expired, false otherwise + * + * @api + */ + public function isExpired() + { + return null !== $this->expires && 0 !== $this->expires && $this->expires < time(); + } +} diff --git a/vendor/symfony/browser-kit/Symfony/Component/BrowserKit/CookieJar.php b/vendor/symfony/browser-kit/Symfony/Component/BrowserKit/CookieJar.php new file mode 100755 index 0000000..a3b0e24 --- /dev/null +++ b/vendor/symfony/browser-kit/Symfony/Component/BrowserKit/CookieJar.php @@ -0,0 +1,265 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\BrowserKit; + +/** + * CookieJar. + * + * @author Fabien Potencier + * + * @api + */ +class CookieJar +{ + protected $cookieJar = array(); + + /** + * Sets a cookie. + * + * @param Cookie $cookie A Cookie instance + * + * @api + */ + public function set(Cookie $cookie) + { + $this->cookieJar[$cookie->getDomain()][$cookie->getPath()][$cookie->getName()] = $cookie; + } + + /** + * Gets a cookie by name. + * + * You should never use an empty domain, but if you do so, + * this method returns the first cookie for the given name/path + * (this behavior ensures a BC behavior with previous versions of + * Symfony). + * + * @param string $name The cookie name + * @param string $path The cookie path + * @param string $domain The cookie domain + * + * @return Cookie|null A Cookie instance or null if the cookie does not exist + * + * @api + */ + public function get($name, $path = '/', $domain = null) + { + $this->flushExpiredCookies(); + + if (!empty($domain)) { + foreach ($this->cookieJar as $cookieDomain => $pathCookies) { + if ($cookieDomain) { + $cookieDomain = '.'.ltrim($cookieDomain, '.'); + if ($cookieDomain != substr('.'.$domain, -strlen($cookieDomain))) { + continue; + } + } + + foreach ($pathCookies as $cookiePath => $namedCookies) { + if ($cookiePath != substr($path, 0, strlen($cookiePath))) { + continue; + } + if (isset($namedCookies[$name])) { + return $namedCookies[$name]; + } + } + } + + return; + } + + // avoid relying on this behavior that is mainly here for BC reasons + foreach ($this->cookieJar as $cookies) { + if (isset($cookies[$path][$name])) { + return $cookies[$path][$name]; + } + } + } + + /** + * Removes a cookie by name. + * + * You should never use an empty domain, but if you do so, + * all cookies for the given name/path expire (this behavior + * ensures a BC behavior with previous versions of Symfony). + * + * @param string $name The cookie name + * @param string $path The cookie path + * @param string $domain The cookie domain + * + * @api + */ + public function expire($name, $path = '/', $domain = null) + { + if (null === $path) { + $path = '/'; + } + + if (empty($domain)) { + // an empty domain means any domain + // this should never happen but it allows for a better BC + $domains = array_keys($this->cookieJar); + } else { + $domains = array($domain); + } + + foreach ($domains as $domain) { + unset($this->cookieJar[$domain][$path][$name]); + + if (empty($this->cookieJar[$domain][$path])) { + unset($this->cookieJar[$domain][$path]); + + if (empty($this->cookieJar[$domain])) { + unset($this->cookieJar[$domain]); + } + } + } + } + + /** + * Removes all the cookies from the jar. + * + * @api + */ + public function clear() + { + $this->cookieJar = array(); + } + + /** + * Updates the cookie jar from a response Set-Cookie headers. + * + * @param array $setCookies Set-Cookie headers from an HTTP response + * @param string $uri The base URL + */ + public function updateFromSetCookie(array $setCookies, $uri = null) + { + $cookies = array(); + + foreach ($setCookies as $cookie) { + foreach (explode(',', $cookie) as $i => $part) { + if (0 === $i || preg_match('/^(?P\s*[0-9A-Za-z!#\$%\&\'\*\+\-\.^_`\|~]+)=/', $part)) { + $cookies[] = ltrim($part); + } else { + $cookies[count($cookies) - 1] .= ','.$part; + } + } + } + + foreach ($cookies as $cookie) { + try { + $this->set(Cookie::fromString($cookie, $uri)); + } catch (\InvalidArgumentException $e) { + // invalid cookies are just ignored + } + } + } + + /** + * Updates the cookie jar from a Response object. + * + * @param Response $response A Response object + * @param string $uri The base URL + */ + public function updateFromResponse(Response $response, $uri = null) + { + $this->updateFromSetCookie($response->getHeader('Set-Cookie', false), $uri); + } + + /** + * Returns not yet expired cookies. + * + * @return Cookie[] An array of cookies + */ + public function all() + { + $this->flushExpiredCookies(); + + $flattenedCookies = array(); + foreach ($this->cookieJar as $path) { + foreach ($path as $cookies) { + foreach ($cookies as $cookie) { + $flattenedCookies[] = $cookie; + } + } + } + + return $flattenedCookies; + } + + /** + * Returns not yet expired cookie values for the given URI. + * + * @param string $uri A URI + * @param bool $returnsRawValue Returns raw value or urldecoded value + * + * @return array An array of cookie values + */ + public function allValues($uri, $returnsRawValue = false) + { + $this->flushExpiredCookies(); + + $parts = array_replace(array('path' => '/'), parse_url($uri)); + $cookies = array(); + foreach ($this->cookieJar as $domain => $pathCookies) { + if ($domain) { + $domain = '.'.ltrim($domain, '.'); + if ($domain != substr('.'.$parts['host'], -strlen($domain))) { + continue; + } + } + + foreach ($pathCookies as $path => $namedCookies) { + if ($path != substr($parts['path'], 0, strlen($path))) { + continue; + } + + foreach ($namedCookies as $cookie) { + if ($cookie->isSecure() && 'https' != $parts['scheme']) { + continue; + } + + $cookies[$cookie->getName()] = $returnsRawValue ? $cookie->getRawValue() : $cookie->getValue(); + } + } + } + + return $cookies; + } + + /** + * Returns not yet expired raw cookie values for the given URI. + * + * @param string $uri A URI + * + * @return array An array of cookie values + */ + public function allRawValues($uri) + { + return $this->allValues($uri, true); + } + + /** + * Removes all expired cookies. + */ + public function flushExpiredCookies() + { + foreach ($this->cookieJar as $domain => $pathCookies) { + foreach ($pathCookies as $path => $namedCookies) { + foreach ($namedCookies as $name => $cookie) { + if ($cookie->isExpired()) { + unset($this->cookieJar[$domain][$path][$name]); + } + } + } + } + } +} diff --git a/vendor/symfony/browser-kit/Symfony/Component/BrowserKit/History.php b/vendor/symfony/browser-kit/Symfony/Component/BrowserKit/History.php new file mode 100755 index 0000000..d76d79b --- /dev/null +++ b/vendor/symfony/browser-kit/Symfony/Component/BrowserKit/History.php @@ -0,0 +1,102 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\BrowserKit; + +/** + * History. + * + * @author Fabien Potencier + */ +class History +{ + protected $stack = array(); + protected $position = -1; + + /** + * Clears the history. + */ + public function clear() + { + $this->stack = array(); + $this->position = -1; + } + + /** + * Adds a Request to the history. + * + * @param Request $request A Request instance + */ + public function add(Request $request) + { + $this->stack = array_slice($this->stack, 0, $this->position + 1); + $this->stack[] = clone $request; + $this->position = count($this->stack) - 1; + } + + /** + * Returns true if the history is empty. + * + * @return bool true if the history is empty, false otherwise + */ + public function isEmpty() + { + return count($this->stack) == 0; + } + + /** + * Goes back in the history. + * + * @return Request A Request instance + * + * @throws \LogicException if the stack is already on the first page + */ + public function back() + { + if ($this->position < 1) { + throw new \LogicException('You are already on the first page.'); + } + + return clone $this->stack[--$this->position]; + } + + /** + * Goes forward in the history. + * + * @return Request A Request instance + * + * @throws \LogicException if the stack is already on the last page + */ + public function forward() + { + if ($this->position > count($this->stack) - 2) { + throw new \LogicException('You are already on the last page.'); + } + + return clone $this->stack[++$this->position]; + } + + /** + * Returns the current element in the history. + * + * @return Request A Request instance + * + * @throws \LogicException if the stack is empty + */ + public function current() + { + if (-1 == $this->position) { + throw new \LogicException('The page history is empty.'); + } + + return clone $this->stack[$this->position]; + } +} diff --git a/vendor/symfony/browser-kit/Symfony/Component/BrowserKit/LICENSE b/vendor/symfony/browser-kit/Symfony/Component/BrowserKit/LICENSE new file mode 100755 index 0000000..0b3292c --- /dev/null +++ b/vendor/symfony/browser-kit/Symfony/Component/BrowserKit/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2004-2014 Fabien Potencier + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is furnished +to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/vendor/symfony/browser-kit/Symfony/Component/BrowserKit/README.md b/vendor/symfony/browser-kit/Symfony/Component/BrowserKit/README.md new file mode 100755 index 0000000..1b40c9f --- /dev/null +++ b/vendor/symfony/browser-kit/Symfony/Component/BrowserKit/README.md @@ -0,0 +1,23 @@ +BrowserKit Component +==================== + +BrowserKit simulates the behavior of a web browser. + +The component only provide an abstract client and does not provide any +"default" backend for the HTTP layer. + +Resources +--------- + +For a simple implementation of a browser based on an HTTP layer, have a look +at [Goutte](https://github.com/fabpot/Goutte). + +For an implementation based on HttpKernelInterface, have a look at the +[Client](https://github.com/symfony/symfony/blob/master/src/Symfony/Component/HttpKernel/Client.php) +provided by the HttpKernel component. + +You can run the unit tests with the following command: + + $ cd path/to/Symfony/Component/BrowserKit/ + $ composer.phar install + $ phpunit diff --git a/vendor/symfony/browser-kit/Symfony/Component/BrowserKit/Request.php b/vendor/symfony/browser-kit/Symfony/Component/BrowserKit/Request.php new file mode 100755 index 0000000..6d381d2 --- /dev/null +++ b/vendor/symfony/browser-kit/Symfony/Component/BrowserKit/Request.php @@ -0,0 +1,138 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\BrowserKit; + +/** + * Request object. + * + * @author Fabien Potencier + * + * @api + */ +class Request +{ + protected $uri; + protected $method; + protected $parameters; + protected $files; + protected $cookies; + protected $server; + protected $content; + + /** + * Constructor. + * + * @param string $uri The request URI + * @param string $method The HTTP method request + * @param array $parameters The request parameters + * @param array $files An array of uploaded files + * @param array $cookies An array of cookies + * @param array $server An array of server parameters + * @param string $content The raw body data + * + * @api + */ + public function __construct($uri, $method, array $parameters = array(), array $files = array(), array $cookies = array(), array $server = array(), $content = null) + { + $this->uri = $uri; + $this->method = $method; + $this->parameters = $parameters; + $this->files = $files; + $this->cookies = $cookies; + $this->server = $server; + $this->content = $content; + } + + /** + * Gets the request URI. + * + * @return string The request URI + * + * @api + */ + public function getUri() + { + return $this->uri; + } + + /** + * Gets the request HTTP method. + * + * @return string The request HTTP method + * + * @api + */ + public function getMethod() + { + return $this->method; + } + + /** + * Gets the request parameters. + * + * @return array The request parameters + * + * @api + */ + public function getParameters() + { + return $this->parameters; + } + + /** + * Gets the request server files. + * + * @return array The request files + * + * @api + */ + public function getFiles() + { + return $this->files; + } + + /** + * Gets the request cookies. + * + * @return array The request cookies + * + * @api + */ + public function getCookies() + { + return $this->cookies; + } + + /** + * Gets the request server parameters. + * + * @return array The request server parameters + * + * @api + */ + public function getServer() + { + return $this->server; + } + + /** + * Gets the request raw body data. + * + * @return string The request raw body data. + * + * @api + */ + public function getContent() + { + return $this->content; + } +} diff --git a/vendor/symfony/browser-kit/Symfony/Component/BrowserKit/Response.php b/vendor/symfony/browser-kit/Symfony/Component/BrowserKit/Response.php new file mode 100755 index 0000000..77aad83 --- /dev/null +++ b/vendor/symfony/browser-kit/Symfony/Component/BrowserKit/Response.php @@ -0,0 +1,138 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\BrowserKit; + +/** + * Response object. + * + * @author Fabien Potencier + * + * @api + */ +class Response +{ + protected $content; + protected $status; + protected $headers; + + /** + * Constructor. + * + * The headers array is a set of key/value pairs. If a header is present multiple times + * then the value is an array of all the values. + * + * @param string $content The content of the response + * @param int $status The response status code + * @param array $headers An array of headers + * + * @api + */ + public function __construct($content = '', $status = 200, array $headers = array()) + { + $this->content = $content; + $this->status = $status; + $this->headers = $headers; + } + + /** + * Converts the response object to string containing all headers and the response content. + * + * @return string The response with headers and content + */ + public function __toString() + { + $headers = ''; + foreach ($this->headers as $name => $value) { + if (is_string($value)) { + $headers .= $this->buildHeader($name, $value); + } else { + foreach ($value as $headerValue) { + $headers .= $this->buildHeader($name, $headerValue); + } + } + } + + return $headers."\n".$this->content; + } + + /** + * Returns the build header line. + * + * @param string $name The header name + * @param string $value The header value + * + * @return string The built header line + */ + protected function buildHeader($name, $value) + { + return sprintf("%s: %s\n", $name, $value); + } + + /** + * Gets the response content. + * + * @return string The response content + * + * @api + */ + public function getContent() + { + return $this->content; + } + + /** + * Gets the response status code. + * + * @return int The response status code + * + * @api + */ + public function getStatus() + { + return $this->status; + } + + /** + * Gets the response headers. + * + * @return array The response headers + * + * @api + */ + public function getHeaders() + { + return $this->headers; + } + + /** + * Gets a response header. + * + * @param string $header The header name + * @param bool $first Whether to return the first value or all header values + * + * @return string|array The first header value if $first is true, an array of values otherwise + */ + public function getHeader($header, $first = true) + { + foreach ($this->headers as $key => $value) { + if (str_replace('-', '_', strtolower($key)) == str_replace('-', '_', strtolower($header))) { + if ($first) { + return is_array($value) ? (count($value) ? $value[0] : '') : $value; + } + + return is_array($value) ? $value : array($value); + } + } + + return $first ? null : array(); + } +} diff --git a/vendor/symfony/browser-kit/Symfony/Component/BrowserKit/Tests/ClientTest.php b/vendor/symfony/browser-kit/Symfony/Component/BrowserKit/Tests/ClientTest.php new file mode 100755 index 0000000..ca6898a --- /dev/null +++ b/vendor/symfony/browser-kit/Symfony/Component/BrowserKit/Tests/ClientTest.php @@ -0,0 +1,594 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\BrowserKit\Tests; + +use Symfony\Component\BrowserKit\Client; +use Symfony\Component\BrowserKit\History; +use Symfony\Component\BrowserKit\CookieJar; +use Symfony\Component\BrowserKit\Request; +use Symfony\Component\BrowserKit\Response; + +class SpecialResponse extends Response +{ +} + +class TestClient extends Client +{ + protected $nextResponse = null; + protected $nextScript = null; + + public function setNextResponse(Response $response) + { + $this->nextResponse = $response; + } + + public function setNextScript($script) + { + $this->nextScript = $script; + } + + protected function doRequest($request) + { + if (null === $this->nextResponse) { + return new Response(); + } + + $response = $this->nextResponse; + $this->nextResponse = null; + + return $response; + } + + protected function filterResponse($response) + { + if ($response instanceof SpecialResponse) { + return new Response($response->getContent(), $response->getStatus(), $response->getHeaders()); + } + + return $response; + } + + protected function getScript($request) + { + $r = new \ReflectionClass('Symfony\Component\BrowserKit\Response'); + $path = $r->getFileName(); + + return <<nextScript); +EOF; + } +} + +class ClientTest extends \PHPUnit_Framework_TestCase +{ + /** + * @covers Symfony\Component\BrowserKit\Client::getHistory + */ + public function testGetHistory() + { + $client = new TestClient(array(), $history = new History()); + $this->assertSame($history, $client->getHistory(), '->getHistory() returns the History'); + } + + /** + * @covers Symfony\Component\BrowserKit\Client::getCookieJar + */ + public function testGetCookieJar() + { + $client = new TestClient(array(), null, $cookieJar = new CookieJar()); + $this->assertSame($cookieJar, $client->getCookieJar(), '->getCookieJar() returns the CookieJar'); + } + + /** + * @covers Symfony\Component\BrowserKit\Client::getRequest + */ + public function testGetRequest() + { + $client = new TestClient(); + $client->request('GET', 'http://example.com/'); + + $this->assertEquals('http://example.com/', $client->getRequest()->getUri(), '->getCrawler() returns the Request of the last request'); + } + + public function testGetRequestWithIpAsHost() + { + $client = new TestClient(); + $client->request('GET', 'https://example.com/foo', array(), array(), array('HTTP_HOST' => '127.0.0.1')); + + $this->assertEquals('https://127.0.0.1/foo', $client->getRequest()->getUri()); + } + + public function testGetResponse() + { + $client = new TestClient(); + $client->setNextResponse(new Response('foo')); + $client->request('GET', 'http://example.com/'); + + $this->assertEquals('foo', $client->getResponse()->getContent(), '->getCrawler() returns the Response of the last request'); + $this->assertInstanceOf('Symfony\Component\BrowserKit\Response', $client->getResponse(), '->getCrawler() returns the Response of the last request'); + } + + public function testGetInternalResponse() + { + $client = new TestClient(); + $client->setNextResponse(new SpecialResponse('foo')); + $client->request('GET', 'http://example.com/'); + + $this->assertInstanceOf('Symfony\Component\BrowserKit\Response', $client->getInternalResponse()); + $this->assertNotInstanceOf('Symfony\Component\BrowserKit\Tests\SpecialResponse', $client->getInternalResponse()); + $this->assertInstanceOf('Symfony\Component\BrowserKit\Tests\SpecialResponse', $client->getResponse()); + } + + public function testGetContent() + { + $json = '{"jsonrpc":"2.0","method":"echo","id":7,"params":["Hello World"]}'; + + $client = new TestClient(); + $client->request('POST', 'http://example.com/jsonrpc', array(), array(), array(), $json); + $this->assertEquals($json, $client->getRequest()->getContent()); + } + + /** + * @covers Symfony\Component\BrowserKit\Client::getCrawler + */ + public function testGetCrawler() + { + $client = new TestClient(); + $client->setNextResponse(new Response('foo')); + $crawler = $client->request('GET', 'http://example.com/'); + + $this->assertSame($crawler, $client->getCrawler(), '->getCrawler() returns the Crawler of the last request'); + } + + public function testRequestHttpHeaders() + { + $client = new TestClient(); + $client->request('GET', '/'); + $headers = $client->getRequest()->getServer(); + $this->assertEquals('localhost', $headers['HTTP_HOST'], '->request() sets the HTTP_HOST header'); + + $client = new TestClient(); + $client->request('GET', 'http://www.example.com'); + $headers = $client->getRequest()->getServer(); + $this->assertEquals('www.example.com', $headers['HTTP_HOST'], '->request() sets the HTTP_HOST header'); + + $client->request('GET', 'https://www.example.com'); + $headers = $client->getRequest()->getServer(); + $this->assertTrue($headers['HTTPS'], '->request() sets the HTTPS header'); + + $client = new TestClient(); + $client->request('GET', 'http://www.example.com:8080'); + $headers = $client->getRequest()->getServer(); + $this->assertEquals('www.example.com:8080', $headers['HTTP_HOST'], '->request() sets the HTTP_HOST header with port'); + } + + public function testRequestURIConversion() + { + $client = new TestClient(); + $client->request('GET', '/foo'); + $this->assertEquals('http://localhost/foo', $client->getRequest()->getUri(), '->request() converts the URI to an absolute one'); + + $client = new TestClient(); + $client->request('GET', 'http://www.example.com'); + $this->assertEquals('http://www.example.com', $client->getRequest()->getUri(), '->request() does not change absolute URIs'); + + $client = new TestClient(); + $client->request('GET', 'http://www.example.com/'); + $client->request('GET', '/foo'); + $this->assertEquals('http://www.example.com/foo', $client->getRequest()->getUri(), '->request() uses the previous request for relative URLs'); + + $client = new TestClient(); + $client->request('GET', 'http://www.example.com/foo'); + $client->request('GET', '#'); + $this->assertEquals('http://www.example.com/foo#', $client->getRequest()->getUri(), '->request() uses the previous request for #'); + $client->request('GET', '#'); + $this->assertEquals('http://www.example.com/foo#', $client->getRequest()->getUri(), '->request() uses the previous request for #'); + $client->request('GET', '#foo'); + $this->assertEquals('http://www.example.com/foo#foo', $client->getRequest()->getUri(), '->request() uses the previous request for #'); + + $client = new TestClient(); + $client->request('GET', 'http://www.example.com/foo/'); + $client->request('GET', 'bar'); + $this->assertEquals('http://www.example.com/foo/bar', $client->getRequest()->getUri(), '->request() uses the previous request for relative URLs'); + + $client = new TestClient(); + $client->request('GET', 'http://www.example.com/foo/foobar'); + $client->request('GET', 'bar'); + $this->assertEquals('http://www.example.com/foo/bar', $client->getRequest()->getUri(), '->request() uses the previous request for relative URLs'); + } + + public function testRequestReferer() + { + $client = new TestClient(); + $client->request('GET', 'http://www.example.com/foo/foobar'); + $client->request('GET', 'bar'); + $server = $client->getRequest()->getServer(); + $this->assertEquals('http://www.example.com/foo/foobar', $server['HTTP_REFERER'], '->request() sets the referer'); + } + + public function testRequestHistory() + { + $client = new TestClient(); + $client->request('GET', 'http://www.example.com/foo/foobar'); + $client->request('GET', 'bar'); + + $this->assertEquals('http://www.example.com/foo/bar', $client->getHistory()->current()->getUri(), '->request() updates the History'); + $this->assertEquals('http://www.example.com/foo/foobar', $client->getHistory()->back()->getUri(), '->request() updates the History'); + } + + public function testRequestCookies() + { + $client = new TestClient(); + $client->setNextResponse(new Response('
    foo', 200, array('Set-Cookie' => 'foo=bar'))); + $client->request('GET', 'http://www.example.com/foo/foobar'); + $this->assertEquals(array('foo' => 'bar'), $client->getCookieJar()->allValues('http://www.example.com/foo/foobar'), '->request() updates the CookieJar'); + + $client->request('GET', 'bar'); + $this->assertEquals(array('foo' => 'bar'), $client->getCookieJar()->allValues('http://www.example.com/foo/foobar'), '->request() updates the CookieJar'); + } + + public function testRequestSecureCookies() + { + $client = new TestClient(); + $client->setNextResponse(new Response('foo', 200, array('Set-Cookie' => 'foo=bar; path=/; secure'))); + $client->request('GET', 'https://www.example.com/foo/foobar'); + + $this->assertTrue($client->getCookieJar()->get('foo', '/', 'www.example.com')->isSecure()); + } + + public function testClick() + { + $client = new TestClient(); + $client->setNextResponse(new Response('foo')); + $crawler = $client->request('GET', 'http://www.example.com/foo/foobar'); + + $client->click($crawler->filter('a')->link()); + + $this->assertEquals('http://www.example.com/foo', $client->getRequest()->getUri(), '->click() clicks on links'); + } + + public function testClickForm() + { + $client = new TestClient(); + $client->setNextResponse(new Response('
    ')); + $crawler = $client->request('GET', 'http://www.example.com/foo/foobar'); + + $client->click($crawler->filter('input')->form()); + + $this->assertEquals('http://www.example.com/foo', $client->getRequest()->getUri(), '->click() Form submit forms'); + } + + public function testSubmit() + { + $client = new TestClient(); + $client->setNextResponse(new Response('
    ')); + $crawler = $client->request('GET', 'http://www.example.com/foo/foobar'); + + $client->submit($crawler->filter('input')->form()); + + $this->assertEquals('http://www.example.com/foo', $client->getRequest()->getUri(), '->submit() submit forms'); + } + + public function testSubmitPreserveAuth() + { + $client = new TestClient(array('PHP_AUTH_USER' => 'foo', 'PHP_AUTH_PW' => 'bar')); + $client->setNextResponse(new Response('
    ')); + $crawler = $client->request('GET', 'http://www.example.com/foo/foobar'); + + $server = $client->getRequest()->getServer(); + $this->assertArrayHasKey('PHP_AUTH_USER', $server); + $this->assertEquals('foo', $server['PHP_AUTH_USER']); + $this->assertArrayHasKey('PHP_AUTH_PW', $server); + $this->assertEquals('bar', $server['PHP_AUTH_PW']); + + $client->submit($crawler->filter('input')->form()); + + $this->assertEquals('http://www.example.com/foo', $client->getRequest()->getUri(), '->submit() submit forms'); + + $server = $client->getRequest()->getServer(); + $this->assertArrayHasKey('PHP_AUTH_USER', $server); + $this->assertEquals('foo', $server['PHP_AUTH_USER']); + $this->assertArrayHasKey('PHP_AUTH_PW', $server); + $this->assertEquals('bar', $server['PHP_AUTH_PW']); + } + + public function testFollowRedirect() + { + $client = new TestClient(); + $client->followRedirects(false); + $client->request('GET', 'http://www.example.com/foo/foobar'); + + try { + $client->followRedirect(); + $this->fail('->followRedirect() throws a \LogicException if the request was not redirected'); + } catch (\Exception $e) { + $this->assertInstanceof('LogicException', $e, '->followRedirect() throws a \LogicException if the request was not redirected'); + } + + $client->setNextResponse(new Response('', 302, array('Location' => 'http://www.example.com/redirected'))); + $client->request('GET', 'http://www.example.com/foo/foobar'); + $client->followRedirect(); + + $this->assertEquals('http://www.example.com/redirected', $client->getRequest()->getUri(), '->followRedirect() follows a redirect if any'); + + $client = new TestClient(); + $client->setNextResponse(new Response('', 302, array('Location' => 'http://www.example.com/redirected'))); + $client->request('GET', 'http://www.example.com/foo/foobar'); + + $this->assertEquals('http://www.example.com/redirected', $client->getRequest()->getUri(), '->followRedirect() automatically follows redirects if followRedirects is true'); + + $client = new TestClient(); + $client->setNextResponse(new Response('', 201, array('Location' => 'http://www.example.com/redirected'))); + $client->request('GET', 'http://www.example.com/foo/foobar'); + + $this->assertEquals('http://www.example.com/foo/foobar', $client->getRequest()->getUri(), '->followRedirect() does not follow redirect if HTTP Code is not 30x'); + + $client = new TestClient(); + $client->setNextResponse(new Response('', 201, array('Location' => 'http://www.example.com/redirected'))); + $client->followRedirects(false); + $client->request('GET', 'http://www.example.com/foo/foobar'); + + try { + $client->followRedirect(); + $this->fail('->followRedirect() throws a \LogicException if the request did not respond with 30x HTTP Code'); + } catch (\Exception $e) { + $this->assertInstanceof('LogicException', $e, '->followRedirect() throws a \LogicException if the request did not respond with 30x HTTP Code'); + } + } + + public function testFollowRedirectWithMaxRedirects() + { + $client = new TestClient(); + $client->setMaxRedirects(1); + $client->setNextResponse(new Response('', 302, array('Location' => 'http://www.example.com/redirected'))); + $client->request('GET', 'http://www.example.com/foo/foobar'); + $this->assertEquals('http://www.example.com/redirected', $client->getRequest()->getUri(), '->followRedirect() follows a redirect if any'); + + $client->setNextResponse(new Response('', 302, array('Location' => 'http://www.example.com/redirected2'))); + try { + $client->followRedirect(); + $this->fail('->followRedirect() throws a \LogicException if the request was redirected and limit of redirections was reached'); + } catch (\Exception $e) { + $this->assertInstanceof('LogicException', $e, '->followRedirect() throws a \LogicException if the request was redirected and limit of redirections was reached'); + } + + $client->setNextResponse(new Response('', 302, array('Location' => 'http://www.example.com/redirected'))); + $client->request('GET', 'http://www.example.com/foo/foobar'); + $this->assertEquals('http://www.example.com/redirected', $client->getRequest()->getUri(), '->followRedirect() follows a redirect if any'); + + $client->setNextResponse(new Response('', 302, array('Location' => '/redirected'))); + $client->request('GET', 'http://www.example.com/foo/foobar'); + + $this->assertEquals('http://www.example.com/redirected', $client->getRequest()->getUri(), '->followRedirect() follows relative URLs'); + + $client = new TestClient(); + $client->setNextResponse(new Response('', 302, array('Location' => '//www.example.org/'))); + $client->request('GET', 'https://www.example.com/'); + + $this->assertEquals('https://www.example.org/', $client->getRequest()->getUri(), '->followRedirect() follows protocol-relative URLs'); + + $client = new TestClient(); + $client->setNextResponse(new Response('', 302, array('Location' => 'http://www.example.com/redirected'))); + $client->request('POST', 'http://www.example.com/foo/foobar', array('name' => 'bar')); + + $this->assertEquals('get', $client->getRequest()->getMethod(), '->followRedirect() uses a get for 302'); + $this->assertEquals(array(), $client->getRequest()->getParameters(), '->followRedirect() does not submit parameters when changing the method'); + } + + public function testFollowRedirectWithCookies() + { + $client = new TestClient(); + $client->followRedirects(false); + $client->setNextResponse(new Response('', 302, array( + 'Location' => 'http://www.example.com/redirected', + 'Set-Cookie' => 'foo=bar', + ))); + $client->request('GET', 'http://www.example.com/'); + $this->assertEquals(array(), $client->getRequest()->getCookies()); + $client->followRedirect(); + $this->assertEquals(array('foo' => 'bar'), $client->getRequest()->getCookies()); + } + + public function testFollowRedirectWithHeaders() + { + $headers = array( + 'HTTP_HOST' => 'www.example.com', + 'HTTP_USER_AGENT' => 'Symfony2 BrowserKit', + 'CONTENT_TYPE' => 'application/vnd.custom+xml', + 'HTTPS' => false, + ); + + $client = new TestClient(); + $client->followRedirects(false); + $client->setNextResponse(new Response('', 302, array( + 'Location' => 'http://www.example.com/redirected', + ))); + $client->request('GET', 'http://www.example.com/', array(), array(), array( + 'CONTENT_TYPE' => 'application/vnd.custom+xml', + )); + + $this->assertEquals($headers, $client->getRequest()->getServer()); + + $client->followRedirect(); + + $headers['HTTP_REFERER'] = 'http://www.example.com/'; + + $this->assertEquals($headers, $client->getRequest()->getServer()); + } + + public function testFollowRedirectWithPort() + { + $headers = array( + 'HTTP_HOST' => 'www.example.com:8080', + 'HTTP_USER_AGENT' => 'Symfony2 BrowserKit', + 'HTTPS' => false + ); + + $client = new TestClient(); + $client->followRedirects(false); + $client->setNextResponse(new Response('', 302, array( + 'Location' => 'http://www.example.com:8080/redirected', + ))); + $client->request('GET', 'http://www.example.com:8080/'); + + $this->assertEquals($headers, $client->getRequest()->getServer()); + } + + public function testBack() + { + $client = new TestClient(); + + $parameters = array('foo' => 'bar'); + $files = array('myfile.foo' => 'baz'); + $server = array('X_TEST_FOO' => 'bazbar'); + $content = 'foobarbaz'; + + $client->request('GET', 'http://www.example.com/foo/foobar', $parameters, $files, $server, $content); + $client->request('GET', 'http://www.example.com/foo'); + $client->back(); + + $this->assertEquals('http://www.example.com/foo/foobar', $client->getRequest()->getUri(), '->back() goes back in the history'); + $this->assertArrayHasKey('foo', $client->getRequest()->getParameters(), '->back() keeps parameters'); + $this->assertArrayHasKey('myfile.foo', $client->getRequest()->getFiles(), '->back() keeps files'); + $this->assertArrayHasKey('X_TEST_FOO', $client->getRequest()->getServer(), '->back() keeps $_SERVER'); + $this->assertEquals($content, $client->getRequest()->getContent(), '->back() keeps content'); + } + + public function testForward() + { + $client = new TestClient(); + + $parameters = array('foo' => 'bar'); + $files = array('myfile.foo' => 'baz'); + $server = array('X_TEST_FOO' => 'bazbar'); + $content = 'foobarbaz'; + + $client->request('GET', 'http://www.example.com/foo/foobar'); + $client->request('GET', 'http://www.example.com/foo', $parameters, $files, $server, $content); + $client->back(); + $client->forward(); + + $this->assertEquals('http://www.example.com/foo', $client->getRequest()->getUri(), '->forward() goes forward in the history'); + $this->assertArrayHasKey('foo', $client->getRequest()->getParameters(), '->forward() keeps parameters'); + $this->assertArrayHasKey('myfile.foo', $client->getRequest()->getFiles(), '->forward() keeps files'); + $this->assertArrayHasKey('X_TEST_FOO', $client->getRequest()->getServer(), '->forward() keeps $_SERVER'); + $this->assertEquals($content, $client->getRequest()->getContent(), '->forward() keeps content'); + } + + public function testReload() + { + $client = new TestClient(); + + $parameters = array('foo' => 'bar'); + $files = array('myfile.foo' => 'baz'); + $server = array('X_TEST_FOO' => 'bazbar'); + $content = 'foobarbaz'; + + $client->request('GET', 'http://www.example.com/foo/foobar', $parameters, $files, $server, $content); + $client->reload(); + + $this->assertEquals('http://www.example.com/foo/foobar', $client->getRequest()->getUri(), '->reload() reloads the current page'); + $this->assertArrayHasKey('foo', $client->getRequest()->getParameters(), '->reload() keeps parameters'); + $this->assertArrayHasKey('myfile.foo', $client->getRequest()->getFiles(), '->reload() keeps files'); + $this->assertArrayHasKey('X_TEST_FOO', $client->getRequest()->getServer(), '->reload() keeps $_SERVER'); + $this->assertEquals($content, $client->getRequest()->getContent(), '->reload() keeps content'); + } + + public function testRestart() + { + $client = new TestClient(); + $client->request('GET', 'http://www.example.com/foo/foobar'); + $client->restart(); + + $this->assertTrue($client->getHistory()->isEmpty(), '->restart() clears the history'); + $this->assertEquals(array(), $client->getCookieJar()->all(), '->restart() clears the cookies'); + } + + public function testInsulatedRequests() + { + $client = new TestClient(); + $client->insulate(); + $client->setNextScript("new Symfony\Component\BrowserKit\Response('foobar')"); + $client->request('GET', 'http://www.example.com/foo/foobar'); + + $this->assertEquals('foobar', $client->getResponse()->getContent(), '->insulate() process the request in a forked process'); + + $client->setNextScript("new Symfony\Component\BrowserKit\Response('foobar)"); + + try { + $client->request('GET', 'http://www.example.com/foo/foobar'); + $this->fail('->request() throws a \RuntimeException if the script has an error'); + } catch (\Exception $e) { + $this->assertInstanceof('RuntimeException', $e, '->request() throws a \RuntimeException if the script has an error'); + } + } + + public function testGetServerParameter() + { + $client = new TestClient(); + $this->assertEquals('localhost', $client->getServerParameter('HTTP_HOST')); + $this->assertEquals('Symfony2 BrowserKit', $client->getServerParameter('HTTP_USER_AGENT')); + $this->assertEquals('testvalue', $client->getServerParameter('testkey', 'testvalue')); + } + + public function testSetServerParameter() + { + $client = new TestClient(); + + $this->assertEquals('localhost', $client->getServerParameter('HTTP_HOST')); + $this->assertEquals('Symfony2 BrowserKit', $client->getServerParameter('HTTP_USER_AGENT')); + + $client->setServerParameter('HTTP_HOST', 'testhost'); + $this->assertEquals('testhost', $client->getServerParameter('HTTP_HOST')); + + $client->setServerParameter('HTTP_USER_AGENT', 'testua'); + $this->assertEquals('testua', $client->getServerParameter('HTTP_USER_AGENT')); + } + + public function testSetServerParameterInRequest() + { + $client = new TestClient(); + + $this->assertEquals('localhost', $client->getServerParameter('HTTP_HOST')); + $this->assertEquals('Symfony2 BrowserKit', $client->getServerParameter('HTTP_USER_AGENT')); + + $client->request('GET', 'https://www.example.com/https/www.example.com', array(), array(), array( + 'HTTP_HOST' => 'testhost', + 'HTTP_USER_AGENT' => 'testua', + 'HTTPS' => false, + 'NEW_SERVER_KEY' => 'new-server-key-value' + )); + + $this->assertEquals('localhost', $client->getServerParameter('HTTP_HOST')); + $this->assertEquals('Symfony2 BrowserKit', $client->getServerParameter('HTTP_USER_AGENT')); + + $this->assertEquals('http://testhost/https/www.example.com', $client->getRequest()->getUri()); + + $server = $client->getRequest()->getServer(); + + $this->assertArrayHasKey('HTTP_USER_AGENT', $server); + $this->assertEquals('testua', $server['HTTP_USER_AGENT']); + + $this->assertArrayHasKey('HTTP_HOST', $server); + $this->assertEquals('testhost', $server['HTTP_HOST']); + + $this->assertArrayHasKey('NEW_SERVER_KEY', $server); + $this->assertEquals('new-server-key-value', $server['NEW_SERVER_KEY']); + + $this->assertArrayHasKey('HTTPS', $server); + $this->assertFalse($server['HTTPS']); + } +} diff --git a/vendor/symfony/browser-kit/Symfony/Component/BrowserKit/Tests/CookieJarTest.php b/vendor/symfony/browser-kit/Symfony/Component/BrowserKit/Tests/CookieJarTest.php new file mode 100755 index 0000000..3deef66 --- /dev/null +++ b/vendor/symfony/browser-kit/Symfony/Component/BrowserKit/Tests/CookieJarTest.php @@ -0,0 +1,231 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\BrowserKit\Tests; + +use Symfony\Component\BrowserKit\CookieJar; +use Symfony\Component\BrowserKit\Cookie; +use Symfony\Component\BrowserKit\Response; + +class CookieJarTest extends \PHPUnit_Framework_TestCase +{ + public function testSetGet() + { + $cookieJar = new CookieJar(); + $cookieJar->set($cookie = new Cookie('foo', 'bar')); + + $this->assertEquals($cookie, $cookieJar->get('foo'), '->set() sets a cookie'); + + $this->assertNull($cookieJar->get('foobar'), '->get() returns null if the cookie does not exist'); + + $cookieJar->set($cookie = new Cookie('foo', 'bar', time() - 86400)); + $this->assertNull($cookieJar->get('foo'), '->get() returns null if the cookie is expired'); + } + + public function testExpire() + { + $cookieJar = new CookieJar(); + $cookieJar->set($cookie = new Cookie('foo', 'bar')); + $cookieJar->expire('foo'); + $this->assertNull($cookieJar->get('foo'), '->get() returns null if the cookie is expired'); + } + + public function testAll() + { + $cookieJar = new CookieJar(); + $cookieJar->set($cookie1 = new Cookie('foo', 'bar')); + $cookieJar->set($cookie2 = new Cookie('bar', 'foo')); + + $this->assertEquals(array($cookie1, $cookie2), $cookieJar->all(), '->all() returns all cookies in the jar'); + } + + public function testClear() + { + $cookieJar = new CookieJar(); + $cookieJar->set($cookie1 = new Cookie('foo', 'bar')); + $cookieJar->set($cookie2 = new Cookie('bar', 'foo')); + + $cookieJar->clear(); + + $this->assertEquals(array(), $cookieJar->all(), '->clear() expires all cookies'); + } + + public function testUpdateFromResponse() + { + $response = new Response('', 200, array('Set-Cookie' => 'foo=foo')); + + $cookieJar = new CookieJar(); + $cookieJar->updateFromResponse($response); + + $this->assertEquals('foo', $cookieJar->get('foo')->getValue(), '->updateFromResponse() updates cookies from a Response objects'); + } + + public function testUpdateFromSetCookie() + { + $setCookies = array('foo=foo'); + + $cookieJar = new CookieJar(); + $cookieJar->set(new Cookie('bar', 'bar')); + $cookieJar->updateFromSetCookie($setCookies); + + $this->assertInstanceOf('Symfony\Component\BrowserKit\Cookie', $cookieJar->get('foo')); + $this->assertInstanceOf('Symfony\Component\BrowserKit\Cookie', $cookieJar->get('bar')); + $this->assertEquals('foo', $cookieJar->get('foo')->getValue(), '->updateFromSetCookie() updates cookies from a Set-Cookie header'); + $this->assertEquals('bar', $cookieJar->get('bar')->getValue(), '->updateFromSetCookie() keeps existing cookies'); + } + + public function testUpdateFromEmptySetCookie() + { + $cookieJar = new CookieJar(); + $cookieJar->updateFromSetCookie(array('')); + $this->assertEquals(array(), $cookieJar->all()); + } + + public function testUpdateFromSetCookieWithMultipleCookies() + { + $timestamp = time() + 3600; + $date = gmdate('D, d M Y H:i:s \G\M\T', $timestamp); + $setCookies = array(sprintf('foo=foo; expires=%s; domain=.symfony.com; path=/, bar=bar; domain=.blog.symfony.com, PHPSESSID=id; expires=%s', $date, $date)); + + $cookieJar = new CookieJar(); + $cookieJar->updateFromSetCookie($setCookies); + + $fooCookie = $cookieJar->get('foo', '/', '.symfony.com'); + $barCookie = $cookieJar->get('bar', '/', '.blog.symfony.com'); + $phpCookie = $cookieJar->get('PHPSESSID'); + + $this->assertInstanceOf('Symfony\Component\BrowserKit\Cookie', $fooCookie); + $this->assertInstanceOf('Symfony\Component\BrowserKit\Cookie', $barCookie); + $this->assertInstanceOf('Symfony\Component\BrowserKit\Cookie', $phpCookie); + $this->assertEquals('foo', $fooCookie->getValue()); + $this->assertEquals('bar', $barCookie->getValue()); + $this->assertEquals('id', $phpCookie->getValue()); + $this->assertEquals($timestamp, $fooCookie->getExpiresTime()); + $this->assertNull($barCookie->getExpiresTime()); + $this->assertEquals($timestamp, $phpCookie->getExpiresTime()); + } + + /** + * @dataProvider provideAllValuesValues + */ + public function testAllValues($uri, $values) + { + $cookieJar = new CookieJar(); + $cookieJar->set($cookie1 = new Cookie('foo_nothing', 'foo')); + $cookieJar->set($cookie2 = new Cookie('foo_expired', 'foo', time() - 86400)); + $cookieJar->set($cookie3 = new Cookie('foo_path', 'foo', null, '/foo')); + $cookieJar->set($cookie4 = new Cookie('foo_domain', 'foo', null, '/', '.example.com')); + $cookieJar->set($cookie4 = new Cookie('foo_strict_domain', 'foo', null, '/', '.www4.example.com')); + $cookieJar->set($cookie5 = new Cookie('foo_secure', 'foo', null, '/', '', true)); + + $this->assertEquals($values, array_keys($cookieJar->allValues($uri)), '->allValues() returns the cookie for a given URI'); + } + + public function provideAllValuesValues() + { + return array( + array('http://www.example.com', array('foo_nothing', 'foo_domain')), + array('http://www.example.com/', array('foo_nothing', 'foo_domain')), + array('http://foo.example.com/', array('foo_nothing', 'foo_domain')), + array('http://foo.example1.com/', array('foo_nothing')), + array('https://foo.example.com/', array('foo_nothing', 'foo_secure', 'foo_domain')), + array('http://www.example.com/foo/bar', array('foo_nothing', 'foo_path', 'foo_domain')), + array('http://www4.example.com/', array('foo_nothing', 'foo_domain', 'foo_strict_domain')), + ); + } + + public function testEncodedValues() + { + $cookieJar = new CookieJar(); + $cookieJar->set($cookie = new Cookie('foo', 'bar%3Dbaz', null, '/', '', false, true, true)); + + $this->assertEquals(array('foo' => 'bar=baz'), $cookieJar->allValues('/')); + $this->assertEquals(array('foo' => 'bar%3Dbaz'), $cookieJar->allRawValues('/')); + } + + public function testCookieExpireWithSameNameButDifferentPaths() + { + $cookieJar = new CookieJar(); + $cookieJar->set($cookie1 = new Cookie('foo', 'bar1', null, '/foo')); + $cookieJar->set($cookie2 = new Cookie('foo', 'bar2', null, '/bar')); + $cookieJar->expire('foo', '/foo'); + + $this->assertNull($cookieJar->get('foo'), '->get() returns null if the cookie is expired'); + $this->assertEquals(array(), array_keys($cookieJar->allValues('http://example.com/'))); + $this->assertEquals(array(), $cookieJar->allValues('http://example.com/foo')); + $this->assertEquals(array('foo' => 'bar2'), $cookieJar->allValues('http://example.com/bar')); + } + + public function testCookieExpireWithNullPaths() + { + $cookieJar = new CookieJar(); + $cookieJar->set($cookie1 = new Cookie('foo', 'bar1', null, '/')); + $cookieJar->expire('foo', null); + + $this->assertNull($cookieJar->get('foo'), '->get() returns null if the cookie is expired'); + $this->assertEquals(array(), array_keys($cookieJar->allValues('http://example.com/'))); + } + + public function testCookieWithSameNameButDifferentPaths() + { + $cookieJar = new CookieJar(); + $cookieJar->set($cookie1 = new Cookie('foo', 'bar1', null, '/foo')); + $cookieJar->set($cookie2 = new Cookie('foo', 'bar2', null, '/bar')); + + $this->assertEquals(array(), array_keys($cookieJar->allValues('http://example.com/'))); + $this->assertEquals(array('foo' => 'bar1'), $cookieJar->allValues('http://example.com/foo')); + $this->assertEquals(array('foo' => 'bar2'), $cookieJar->allValues('http://example.com/bar')); + } + + public function testCookieWithSameNameButDifferentDomains() + { + $cookieJar = new CookieJar(); + $cookieJar->set($cookie1 = new Cookie('foo', 'bar1', null, '/', 'foo.example.com')); + $cookieJar->set($cookie2 = new Cookie('foo', 'bar2', null, '/', 'bar.example.com')); + + $this->assertEquals(array(), array_keys($cookieJar->allValues('http://example.com/'))); + $this->assertEquals(array('foo' => 'bar1'), $cookieJar->allValues('http://foo.example.com/')); + $this->assertEquals(array('foo' => 'bar2'), $cookieJar->allValues('http://bar.example.com/')); + } + + public function testCookieGetWithSubdomain() + { + $cookieJar = new CookieJar(); + $cookieJar->set($cookie1 = new Cookie('foo', 'bar', null, '/', '.example.com')); + $cookieJar->set($cookie2 = new Cookie('foo1', 'bar', null, '/', 'test.example.com')); + + $this->assertEquals($cookie1, $cookieJar->get('foo','/','foo.example.com')); + $this->assertEquals($cookie1, $cookieJar->get('foo','/','example.com')); + $this->assertEquals($cookie2, $cookieJar->get('foo1','/','test.example.com')); + } + + public function testCookieGetWithSubdirectory() + { + $cookieJar = new CookieJar(); + $cookieJar->set($cookie1 = new Cookie('foo', 'bar', null, '/test', '.example.com')); + $cookieJar->set($cookie2 = new Cookie('foo1', 'bar1', null, '/', '.example.com')); + + $this->assertNull($cookieJar->get('foo','/','.example.com')); + $this->assertNull($cookieJar->get('foo','/bar','.example.com')); + $this->assertEquals($cookie1, $cookieJar->get('foo','/test','example.com')); + $this->assertEquals($cookie2, $cookieJar->get('foo1','/','example.com')); + $this->assertEquals($cookie2, $cookieJar->get('foo1','/bar','example.com')); + } + + public function testCookieWithWildcardDomain() + { + $cookieJar = new CookieJar(); + $cookieJar->set(new Cookie('foo', 'bar', null, '/', '.example.com')); + + $this->assertEquals(array('foo' => 'bar'), $cookieJar->allValues('http://www.example.com')); + $this->assertEmpty($cookieJar->allValues('http://wwwexample.com')); + } +} diff --git a/vendor/symfony/browser-kit/Symfony/Component/BrowserKit/Tests/CookieTest.php b/vendor/symfony/browser-kit/Symfony/Component/BrowserKit/Tests/CookieTest.php new file mode 100755 index 0000000..8e3578a --- /dev/null +++ b/vendor/symfony/browser-kit/Symfony/Component/BrowserKit/Tests/CookieTest.php @@ -0,0 +1,179 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\BrowserKit\Tests; + +use Symfony\Component\BrowserKit\Cookie; + +class CookieTest extends \PHPUnit_Framework_TestCase +{ + /** + * @dataProvider getTestsForToFromString + */ + public function testToFromString($cookie, $url = null) + { + $this->assertEquals($cookie, (string) Cookie::fromString($cookie, $url)); + } + + public function getTestsForToFromString() + { + return array( + array('foo=bar; path=/'), + array('foo=bar; path=/foo'), + array('foo=bar; domain=google.com; path=/'), + array('foo=bar; domain=example.com; path=/; secure', 'https://example.com/'), + array('foo=bar; path=/; httponly'), + array('foo=bar; domain=google.com; path=/foo; secure; httponly', 'https://google.com/'), + array('foo=bar=baz; path=/'), + array('foo=bar%3Dbaz; path=/'), + ); + } + + public function testFromStringIgnoreSecureFlag() + { + $this->assertFalse(Cookie::fromString('foo=bar; secure')->isSecure()); + $this->assertFalse(Cookie::fromString('foo=bar; secure', 'http://example.com/')->isSecure()); + } + + /** + * @dataProvider getExpireCookieStrings + */ + public function testFromStringAcceptsSeveralExpiresDateFormats($cookie) + { + $this->assertEquals(1596185377, Cookie::fromString($cookie)->getExpiresTime()); + } + + public function getExpireCookieStrings() + { + return array( + array('foo=bar; expires=Fri, 31-Jul-2020 08:49:37 GMT'), + array('foo=bar; expires=Fri, 31 Jul 2020 08:49:37 GMT'), + array('foo=bar; expires=Fri, 31-07-2020 08:49:37 GMT'), + array('foo=bar; expires=Fri, 31-07-20 08:49:37 GMT'), + array('foo=bar; expires=Friday, 31-Jul-20 08:49:37 GMT'), + array('foo=bar; expires=Fri Jul 31 08:49:37 2020'), + array('foo=bar; expires=\'Fri Jul 31 08:49:37 2020\''), + array('foo=bar; expires=Friday July 31st 2020, 08:49:37 GMT'), + ); + } + + public function testFromStringWithCapitalization() + { + $this->assertEquals('Foo=Bar; path=/', (string) Cookie::fromString('Foo=Bar')); + $this->assertEquals('foo=bar; expires=Fri, 31 Dec 2010 23:59:59 GMT; path=/', (string) Cookie::fromString('foo=bar; Expires=Fri, 31 Dec 2010 23:59:59 GMT')); + $this->assertEquals('foo=bar; domain=www.example.org; path=/; httponly', (string) Cookie::fromString('foo=bar; DOMAIN=www.example.org; HttpOnly')); + } + + public function testFromStringWithUrl() + { + $this->assertEquals('foo=bar; domain=www.example.com; path=/', (string) Cookie::FromString('foo=bar', 'http://www.example.com/')); + $this->assertEquals('foo=bar; domain=www.example.com; path=/', (string) Cookie::FromString('foo=bar', 'http://www.example.com')); + $this->assertEquals('foo=bar; domain=www.example.com; path=/', (string) Cookie::FromString('foo=bar', 'http://www.example.com?foo')); + $this->assertEquals('foo=bar; domain=www.example.com; path=/foo', (string) Cookie::FromString('foo=bar', 'http://www.example.com/foo/bar')); + $this->assertEquals('foo=bar; domain=www.example.com; path=/', (string) Cookie::FromString('foo=bar; path=/', 'http://www.example.com/foo/bar')); + $this->assertEquals('foo=bar; domain=www.myotherexample.com; path=/', (string) Cookie::FromString('foo=bar; domain=www.myotherexample.com', 'http://www.example.com/')); + } + + public function testFromStringThrowsAnExceptionIfCookieIsNotValid() + { + $this->setExpectedException('InvalidArgumentException'); + Cookie::FromString('foo'); + } + + public function testFromStringThrowsAnExceptionIfCookieDateIsNotValid() + { + $this->setExpectedException('InvalidArgumentException'); + Cookie::FromString('foo=bar; expires=Flursday July 31st 2020, 08:49:37 GMT'); + } + + public function testFromStringThrowsAnExceptionIfUrlIsNotValid() + { + $this->setExpectedException('InvalidArgumentException'); + Cookie::FromString('foo=bar', 'foobar'); + } + + public function testGetName() + { + $cookie = new Cookie('foo', 'bar'); + $this->assertEquals('foo', $cookie->getName(), '->getName() returns the cookie name'); + } + + public function testGetValue() + { + $cookie = new Cookie('foo', 'bar'); + $this->assertEquals('bar', $cookie->getValue(), '->getValue() returns the cookie value'); + + $cookie = new Cookie('foo', 'bar%3Dbaz', null, '/', '', false, true, true); // raw value + $this->assertEquals('bar=baz', $cookie->getValue(), '->getValue() returns the urldecoded cookie value'); + } + + public function testGetRawValue() + { + $cookie = new Cookie('foo', 'bar=baz'); // decoded value + $this->assertEquals('bar%3Dbaz', $cookie->getRawValue(), '->getRawValue() returns the urlencoded cookie value'); + $cookie = new Cookie('foo', 'bar%3Dbaz', null, '/', '', false, true, true); // raw value + $this->assertEquals('bar%3Dbaz', $cookie->getRawValue(), '->getRawValue() returns the non-urldecoded cookie value'); + } + + public function testGetPath() + { + $cookie = new Cookie('foo', 'bar', 0); + $this->assertEquals('/', $cookie->getPath(), '->getPath() returns / is no path is defined'); + + $cookie = new Cookie('foo', 'bar', 0, '/foo'); + $this->assertEquals('/foo', $cookie->getPath(), '->getPath() returns the cookie path'); + } + + public function testGetDomain() + { + $cookie = new Cookie('foo', 'bar', 0, '/', 'foo.com'); + $this->assertEquals('foo.com', $cookie->getDomain(), '->getDomain() returns the cookie domain'); + } + + public function testIsSecure() + { + $cookie = new Cookie('foo', 'bar'); + $this->assertFalse($cookie->isSecure(), '->isSecure() returns false if not defined'); + + $cookie = new Cookie('foo', 'bar', 0, '/', 'foo.com', true); + $this->assertTrue($cookie->isSecure(), '->isSecure() returns the cookie secure flag'); + } + + public function testIsHttponly() + { + $cookie = new Cookie('foo', 'bar'); + $this->assertTrue($cookie->isHttpOnly(), '->isHttpOnly() returns false if not defined'); + + $cookie = new Cookie('foo', 'bar', 0, '/', 'foo.com', false, true); + $this->assertTrue($cookie->isHttpOnly(), '->isHttpOnly() returns the cookie httponly flag'); + } + + public function testGetExpiresTime() + { + $cookie = new Cookie('foo', 'bar'); + $this->assertNull($cookie->getExpiresTime(), '->getExpiresTime() returns the expires time'); + + $cookie = new Cookie('foo', 'bar', $time = time() - 86400); + $this->assertEquals($time, $cookie->getExpiresTime(), '->getExpiresTime() returns the expires time'); + } + + public function testIsExpired() + { + $cookie = new Cookie('foo', 'bar'); + $this->assertFalse($cookie->isExpired(), '->isExpired() returns false when the cookie never expires (null as expires time)'); + + $cookie = new Cookie('foo', 'bar', time() - 86400); + $this->assertTrue($cookie->isExpired(), '->isExpired() returns true when the cookie is expired'); + + $cookie = new Cookie('foo', 'bar', 0); + $this->assertFalse($cookie->isExpired()); + } +} diff --git a/vendor/symfony/browser-kit/Symfony/Component/BrowserKit/Tests/HistoryTest.php b/vendor/symfony/browser-kit/Symfony/Component/BrowserKit/Tests/HistoryTest.php new file mode 100755 index 0000000..882b730 --- /dev/null +++ b/vendor/symfony/browser-kit/Symfony/Component/BrowserKit/Tests/HistoryTest.php @@ -0,0 +1,101 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\BrowserKit\Tests; + +use Symfony\Component\BrowserKit\History; +use Symfony\Component\BrowserKit\Request; + +class HistoryTest extends \PHPUnit_Framework_TestCase +{ + public function testAdd() + { + $history = new History(); + $history->add(new Request('http://www.example1.com/', 'get')); + $this->assertSame('http://www.example1.com/', $history->current()->getUri(), '->add() adds a request to the history'); + + $history->add(new Request('http://www.example2.com/', 'get')); + $this->assertSame('http://www.example2.com/', $history->current()->getUri(), '->add() adds a request to the history'); + + $history->add(new Request('http://www.example3.com/', 'get')); + $history->back(); + $history->add(new Request('http://www.example4.com/', 'get')); + $this->assertSame('http://www.example4.com/', $history->current()->getUri(), '->add() adds a request to the history'); + + $history->back(); + $this->assertSame('http://www.example2.com/', $history->current()->getUri(), '->add() adds a request to the history'); + } + + public function testClearIsEmpty() + { + $history = new History(); + $history->add(new Request('http://www.example.com/', 'get')); + + $this->assertFalse($history->isEmpty(), '->isEmpty() returns false if the history is not empty'); + + $history->clear(); + + $this->assertTrue($history->isEmpty(), '->isEmpty() true if the history is empty'); + } + + public function testCurrent() + { + $history = new History(); + + try { + $history->current(); + $this->fail('->current() throws a \LogicException if the history is empty'); + } catch (\Exception $e) { + $this->assertInstanceof('LogicException', $e, '->current() throws a \LogicException if the history is empty'); + } + + $history->add(new Request('http://www.example.com/', 'get')); + + $this->assertSame('http://www.example.com/', $history->current()->getUri(), '->current() returns the current request in the history'); + } + + public function testBack() + { + $history = new History(); + $history->add(new Request('http://www.example.com/', 'get')); + + try { + $history->back(); + $this->fail('->back() throws a \LogicException if the history is already on the first page'); + } catch (\Exception $e) { + $this->assertInstanceof('LogicException', $e, '->current() throws a \LogicException if the history is already on the first page'); + } + + $history->add(new Request('http://www.example1.com/', 'get')); + $history->back(); + + $this->assertSame('http://www.example.com/', $history->current()->getUri(), '->back() returns the previous request in the history'); + } + + public function testForward() + { + $history = new History(); + $history->add(new Request('http://www.example.com/', 'get')); + $history->add(new Request('http://www.example1.com/', 'get')); + + try { + $history->forward(); + $this->fail('->forward() throws a \LogicException if the history is already on the last page'); + } catch (\Exception $e) { + $this->assertInstanceof('LogicException', $e, '->forward() throws a \LogicException if the history is already on the last page'); + } + + $history->back(); + $history->forward(); + + $this->assertSame('http://www.example1.com/', $history->current()->getUri(), '->forward() returns the next request in the history'); + } +} diff --git a/vendor/symfony/browser-kit/Symfony/Component/BrowserKit/Tests/RequestTest.php b/vendor/symfony/browser-kit/Symfony/Component/BrowserKit/Tests/RequestTest.php new file mode 100755 index 0000000..b75b5fb --- /dev/null +++ b/vendor/symfony/browser-kit/Symfony/Component/BrowserKit/Tests/RequestTest.php @@ -0,0 +1,53 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\BrowserKit\Tests; + +use Symfony\Component\BrowserKit\Request; + +class RequestTest extends \PHPUnit_Framework_TestCase +{ + public function testGetUri() + { + $request = new Request('http://www.example.com/', 'get'); + $this->assertEquals('http://www.example.com/', $request->getUri(), '->getUri() returns the URI of the request'); + } + + public function testGetMethod() + { + $request = new Request('http://www.example.com/', 'get'); + $this->assertEquals('get', $request->getMethod(), '->getMethod() returns the method of the request'); + } + + public function testGetParameters() + { + $request = new Request('http://www.example.com/', 'get', array('foo' => 'bar')); + $this->assertEquals(array('foo' => 'bar'), $request->getParameters(), '->getParameters() returns the parameters of the request'); + } + + public function testGetFiles() + { + $request = new Request('http://www.example.com/', 'get', array(), array('foo' => 'bar')); + $this->assertEquals(array('foo' => 'bar'), $request->getFiles(), '->getFiles() returns the uploaded files of the request'); + } + + public function testGetCookies() + { + $request = new Request('http://www.example.com/', 'get', array(), array(), array('foo' => 'bar')); + $this->assertEquals(array('foo' => 'bar'), $request->getCookies(), '->getCookies() returns the cookies of the request'); + } + + public function testGetServer() + { + $request = new Request('http://www.example.com/', 'get', array(), array(), array(), array('foo' => 'bar')); + $this->assertEquals(array('foo' => 'bar'), $request->getServer(), '->getServer() returns the server parameters of the request'); + } +} diff --git a/vendor/symfony/browser-kit/Symfony/Component/BrowserKit/Tests/ResponseTest.php b/vendor/symfony/browser-kit/Symfony/Component/BrowserKit/Tests/ResponseTest.php new file mode 100755 index 0000000..878752c --- /dev/null +++ b/vendor/symfony/browser-kit/Symfony/Component/BrowserKit/Tests/ResponseTest.php @@ -0,0 +1,76 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\BrowserKit\Tests; + +use Symfony\Component\BrowserKit\Response; + +class ResponseTest extends \PHPUnit_Framework_TestCase +{ + public function testGetUri() + { + $response = new Response('foo'); + $this->assertEquals('foo', $response->getContent(), '->getContent() returns the content of the response'); + } + + public function testGetStatus() + { + $response = new Response('foo', 304); + $this->assertEquals('304', $response->getStatus(), '->getStatus() returns the status of the response'); + } + + public function testGetHeaders() + { + $response = new Response('foo', 200, array('foo' => 'bar')); + $this->assertEquals(array('foo' => 'bar'), $response->getHeaders(), '->getHeaders() returns the headers of the response'); + } + + public function testGetHeader() + { + $response = new Response('foo', 200, array( + 'Content-Type' => 'text/html', + 'Set-Cookie' => array('foo=bar', 'bar=foo'), + )); + + $this->assertEquals('text/html', $response->getHeader('Content-Type'), '->getHeader() returns a header of the response'); + $this->assertEquals('text/html', $response->getHeader('content-type'), '->getHeader() returns a header of the response'); + $this->assertEquals('text/html', $response->getHeader('content_type'), '->getHeader() returns a header of the response'); + $this->assertEquals('foo=bar', $response->getHeader('Set-Cookie'), '->getHeader() returns the first header value'); + $this->assertEquals(array('foo=bar', 'bar=foo'), $response->getHeader('Set-Cookie', false), '->getHeader() returns all header values if first is false'); + + $this->assertNull($response->getHeader('foo'), '->getHeader() returns null if the header is not defined'); + $this->assertEquals(array(), $response->getHeader('foo', false), '->getHeader() returns an empty array if the header is not defined and first is set to false'); + } + + public function testMagicToString() + { + $response = new Response('foo', 304, array('foo' => 'bar')); + + $this->assertEquals("foo: bar\n\nfoo", $response->__toString(), '->__toString() returns the headers and the content as a string'); + } + + public function testMagicToStringWithMultipleSetCookieHeader() + { + $headers = array( + 'content-type' => 'text/html; charset=utf-8', + 'set-cookie' => array('foo=bar', 'bar=foo') + ); + + $expected = 'content-type: text/html; charset=utf-8'."\n"; + $expected.= 'set-cookie: foo=bar'."\n"; + $expected.= 'set-cookie: bar=foo'."\n\n"; + $expected.= 'foo'; + + $response = new Response('foo', 304, $headers); + + $this->assertEquals($expected, $response->__toString(), '->__toString() returns the headers and the content as a string'); + } +} diff --git a/vendor/symfony/browser-kit/Symfony/Component/BrowserKit/composer.json b/vendor/symfony/browser-kit/Symfony/Component/BrowserKit/composer.json new file mode 100755 index 0000000..592fda9 --- /dev/null +++ b/vendor/symfony/browser-kit/Symfony/Component/BrowserKit/composer.json @@ -0,0 +1,39 @@ +{ + "name": "symfony/browser-kit", + "type": "library", + "description": "Symfony BrowserKit Component", + "keywords": [], + "homepage": "http://symfony.com", + "license": "MIT", + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + } + ], + "require": { + "php": ">=5.3.3", + "symfony/dom-crawler": "~2.0" + }, + "require-dev": { + "symfony/process": "~2.0", + "symfony/css-selector": "~2.0" + }, + "suggest": { + "symfony/process": "" + }, + "autoload": { + "psr-0": { "Symfony\\Component\\BrowserKit\\": "" } + }, + "target-dir": "Symfony/Component/BrowserKit", + "minimum-stability": "dev", + "extra": { + "branch-alias": { + "dev-master": "2.4-dev" + } + } +} diff --git a/vendor/symfony/browser-kit/Symfony/Component/BrowserKit/phpunit.xml.dist b/vendor/symfony/browser-kit/Symfony/Component/BrowserKit/phpunit.xml.dist new file mode 100755 index 0000000..8dff1ea --- /dev/null +++ b/vendor/symfony/browser-kit/Symfony/Component/BrowserKit/phpunit.xml.dist @@ -0,0 +1,30 @@ + + + + + + ./Tests/ + + + + + + ./ + + ./Resources + ./Tests + ./vendor + + + + diff --git a/vendor/symfony/console/Symfony/Component/Console/.gitignore b/vendor/symfony/console/Symfony/Component/Console/.gitignore new file mode 100755 index 0000000..c49a5d8 --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/.gitignore @@ -0,0 +1,3 @@ +vendor/ +composer.lock +phpunit.xml diff --git a/vendor/symfony/console/Symfony/Component/Console/Application.php b/vendor/symfony/console/Symfony/Component/Console/Application.php new file mode 100755 index 0000000..c28cd24 --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Application.php @@ -0,0 +1,1143 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Console; + +use Symfony\Component\Console\Descriptor\TextDescriptor; +use Symfony\Component\Console\Descriptor\XmlDescriptor; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Input\ArgvInput; +use Symfony\Component\Console\Input\ArrayInput; +use Symfony\Component\Console\Input\InputDefinition; +use Symfony\Component\Console\Input\InputOption; +use Symfony\Component\Console\Input\InputArgument; +use Symfony\Component\Console\Input\InputAwareInterface; +use Symfony\Component\Console\Output\BufferedOutput; +use Symfony\Component\Console\Output\OutputInterface; +use Symfony\Component\Console\Output\ConsoleOutput; +use Symfony\Component\Console\Output\ConsoleOutputInterface; +use Symfony\Component\Console\Command\Command; +use Symfony\Component\Console\Command\HelpCommand; +use Symfony\Component\Console\Command\ListCommand; +use Symfony\Component\Console\Helper\HelperSet; +use Symfony\Component\Console\Helper\FormatterHelper; +use Symfony\Component\Console\Helper\DialogHelper; +use Symfony\Component\Console\Helper\ProgressHelper; +use Symfony\Component\Console\Helper\TableHelper; +use Symfony\Component\Console\Event\ConsoleCommandEvent; +use Symfony\Component\Console\Event\ConsoleExceptionEvent; +use Symfony\Component\Console\Event\ConsoleTerminateEvent; +use Symfony\Component\EventDispatcher\EventDispatcherInterface; + +/** + * An Application is the container for a collection of commands. + * + * It is the main entry point of a Console application. + * + * This class is optimized for a standard CLI environment. + * + * Usage: + * + * $app = new Application('myapp', '1.0 (stable)'); + * $app->add(new SimpleCommand()); + * $app->run(); + * + * @author Fabien Potencier + * + * @api + */ +class Application +{ + private $commands = array(); + private $wantHelps = false; + private $runningCommand; + private $name; + private $version; + private $catchExceptions = true; + private $autoExit = true; + private $definition; + private $helperSet; + private $dispatcher; + private $terminalDimensions; + + /** + * Constructor. + * + * @param string $name The name of the application + * @param string $version The version of the application + * + * @api + */ + public function __construct($name = 'UNKNOWN', $version = 'UNKNOWN') + { + $this->name = $name; + $this->version = $version; + $this->helperSet = $this->getDefaultHelperSet(); + $this->definition = $this->getDefaultInputDefinition(); + + foreach ($this->getDefaultCommands() as $command) { + $this->add($command); + } + } + + public function setDispatcher(EventDispatcherInterface $dispatcher) + { + $this->dispatcher = $dispatcher; + } + + /** + * Runs the current application. + * + * @param InputInterface $input An Input instance + * @param OutputInterface $output An Output instance + * + * @return int 0 if everything went fine, or an error code + * + * @throws \Exception When doRun returns Exception + * + * @api + */ + public function run(InputInterface $input = null, OutputInterface $output = null) + { + if (null === $input) { + $input = new ArgvInput(); + } + + if (null === $output) { + $output = new ConsoleOutput(); + } + + $this->configureIO($input, $output); + + try { + $exitCode = $this->doRun($input, $output); + } catch (\Exception $e) { + if (!$this->catchExceptions) { + throw $e; + } + + if ($output instanceof ConsoleOutputInterface) { + $this->renderException($e, $output->getErrorOutput()); + } else { + $this->renderException($e, $output); + } + + $exitCode = $e->getCode(); + if (is_numeric($exitCode)) { + $exitCode = (int) $exitCode; + if (0 === $exitCode) { + $exitCode = 1; + } + } else { + $exitCode = 1; + } + } + + if ($this->autoExit) { + if ($exitCode > 255) { + $exitCode = 255; + } + // @codeCoverageIgnoreStart + exit($exitCode); + // @codeCoverageIgnoreEnd + } + + return $exitCode; + } + + /** + * Runs the current application. + * + * @param InputInterface $input An Input instance + * @param OutputInterface $output An Output instance + * + * @return int 0 if everything went fine, or an error code + */ + public function doRun(InputInterface $input, OutputInterface $output) + { + if (true === $input->hasParameterOption(array('--version', '-V'))) { + $output->writeln($this->getLongVersion()); + + return 0; + } + + $name = $this->getCommandName($input); + if (true === $input->hasParameterOption(array('--help', '-h'))) { + if (!$name) { + $name = 'help'; + $input = new ArrayInput(array('command' => 'help')); + } else { + $this->wantHelps = true; + } + } + + if (!$name) { + $name = 'list'; + $input = new ArrayInput(array('command' => 'list')); + } + + // the command name MUST be the first element of the input + $command = $this->find($name); + + $this->runningCommand = $command; + $exitCode = $this->doRunCommand($command, $input, $output); + $this->runningCommand = null; + + return $exitCode; + } + + /** + * Set a helper set to be used with the command. + * + * @param HelperSet $helperSet The helper set + * + * @api + */ + public function setHelperSet(HelperSet $helperSet) + { + $this->helperSet = $helperSet; + } + + /** + * Get the helper set associated with the command. + * + * @return HelperSet The HelperSet instance associated with this command + * + * @api + */ + public function getHelperSet() + { + return $this->helperSet; + } + + /** + * Set an input definition set to be used with this application + * + * @param InputDefinition $definition The input definition + * + * @api + */ + public function setDefinition(InputDefinition $definition) + { + $this->definition = $definition; + } + + /** + * Gets the InputDefinition related to this Application. + * + * @return InputDefinition The InputDefinition instance + */ + public function getDefinition() + { + return $this->definition; + } + + /** + * Gets the help message. + * + * @return string A help message. + */ + public function getHelp() + { + $messages = array( + $this->getLongVersion(), + '', + 'Usage:', + ' [options] command [arguments]', + '', + 'Options:', + ); + + foreach ($this->getDefinition()->getOptions() as $option) { + $messages[] = sprintf(' %-29s %s %s', + '--'.$option->getName().'', + $option->getShortcut() ? '-'.$option->getShortcut().'' : ' ', + $option->getDescription() + ); + } + + return implode(PHP_EOL, $messages); + } + + /** + * Sets whether to catch exceptions or not during commands execution. + * + * @param bool $boolean Whether to catch exceptions or not during commands execution + * + * @api + */ + public function setCatchExceptions($boolean) + { + $this->catchExceptions = (bool) $boolean; + } + + /** + * Sets whether to automatically exit after a command execution or not. + * + * @param bool $boolean Whether to automatically exit after a command execution or not + * + * @api + */ + public function setAutoExit($boolean) + { + $this->autoExit = (bool) $boolean; + } + + /** + * Gets the name of the application. + * + * @return string The application name + * + * @api + */ + public function getName() + { + return $this->name; + } + + /** + * Sets the application name. + * + * @param string $name The application name + * + * @api + */ + public function setName($name) + { + $this->name = $name; + } + + /** + * Gets the application version. + * + * @return string The application version + * + * @api + */ + public function getVersion() + { + return $this->version; + } + + /** + * Sets the application version. + * + * @param string $version The application version + * + * @api + */ + public function setVersion($version) + { + $this->version = $version; + } + + /** + * Returns the long version of the application. + * + * @return string The long application version + * + * @api + */ + public function getLongVersion() + { + if ('UNKNOWN' !== $this->getName() && 'UNKNOWN' !== $this->getVersion()) { + return sprintf('%s version %s', $this->getName(), $this->getVersion()); + } + + return 'Console Tool'; + } + + /** + * Registers a new command. + * + * @param string $name The command name + * + * @return Command The newly created command + * + * @api + */ + public function register($name) + { + return $this->add(new Command($name)); + } + + /** + * Adds an array of command objects. + * + * @param Command[] $commands An array of commands + * + * @api + */ + public function addCommands(array $commands) + { + foreach ($commands as $command) { + $this->add($command); + } + } + + /** + * Adds a command object. + * + * If a command with the same name already exists, it will be overridden. + * + * @param Command $command A Command object + * + * @return Command The registered command + * + * @api + */ + public function add(Command $command) + { + $command->setApplication($this); + + if (!$command->isEnabled()) { + $command->setApplication(null); + + return; + } + + if (null === $command->getDefinition()) { + throw new \LogicException(sprintf('Command class "%s" is not correctly initialized. You probably forgot to call the parent constructor.', get_class($command))); + } + + $this->commands[$command->getName()] = $command; + + foreach ($command->getAliases() as $alias) { + $this->commands[$alias] = $command; + } + + return $command; + } + + /** + * Returns a registered command by name or alias. + * + * @param string $name The command name or alias + * + * @return Command A Command object + * + * @throws \InvalidArgumentException When command name given does not exist + * + * @api + */ + public function get($name) + { + if (!isset($this->commands[$name])) { + throw new \InvalidArgumentException(sprintf('The command "%s" does not exist.', $name)); + } + + $command = $this->commands[$name]; + + if ($this->wantHelps) { + $this->wantHelps = false; + + $helpCommand = $this->get('help'); + $helpCommand->setCommand($command); + + return $helpCommand; + } + + return $command; + } + + /** + * Returns true if the command exists, false otherwise. + * + * @param string $name The command name or alias + * + * @return bool true if the command exists, false otherwise + * + * @api + */ + public function has($name) + { + return isset($this->commands[$name]); + } + + /** + * Returns an array of all unique namespaces used by currently registered commands. + * + * It does not returns the global namespace which always exists. + * + * @return array An array of namespaces + */ + public function getNamespaces() + { + $namespaces = array(); + foreach ($this->commands as $command) { + $namespaces[] = $this->extractNamespace($command->getName()); + + foreach ($command->getAliases() as $alias) { + $namespaces[] = $this->extractNamespace($alias); + } + } + + return array_values(array_unique(array_filter($namespaces))); + } + + /** + * Finds a registered namespace by a name or an abbreviation. + * + * @param string $namespace A namespace or abbreviation to search for + * + * @return string A registered namespace + * + * @throws \InvalidArgumentException When namespace is incorrect or ambiguous + */ + public function findNamespace($namespace) + { + $allNamespaces = $this->getNamespaces(); + $expr = preg_replace_callback('{([^:]+|)}', function ($matches) { return preg_quote($matches[1]).'[^:]*'; }, $namespace); + $namespaces = preg_grep('{^'.$expr.'}', $allNamespaces); + + if (empty($namespaces)) { + $message = sprintf('There are no commands defined in the "%s" namespace.', $namespace); + + if ($alternatives = $this->findAlternatives($namespace, $allNamespaces, array())) { + if (1 == count($alternatives)) { + $message .= "\n\nDid you mean this?\n "; + } else { + $message .= "\n\nDid you mean one of these?\n "; + } + + $message .= implode("\n ", $alternatives); + } + + throw new \InvalidArgumentException($message); + } + + $exact = in_array($namespace, $namespaces, true); + if (count($namespaces) > 1 && !$exact) { + throw new \InvalidArgumentException(sprintf('The namespace "%s" is ambiguous (%s).', $namespace, $this->getAbbreviationSuggestions(array_values($namespaces)))); + } + + return $exact ? $namespace : reset($namespaces); + } + + /** + * Finds a command by name or alias. + * + * Contrary to get, this command tries to find the best + * match if you give it an abbreviation of a name or alias. + * + * @param string $name A command name or a command alias + * + * @return Command A Command instance + * + * @throws \InvalidArgumentException When command name is incorrect or ambiguous + * + * @api + */ + public function find($name) + { + $allCommands = array_keys($this->commands); + $expr = preg_replace_callback('{([^:]+|)}', function ($matches) { return preg_quote($matches[1]).'[^:]*'; }, $name); + $commands = preg_grep('{^'.$expr.'}', $allCommands); + + if (empty($commands) || count(preg_grep('{^'.$expr.'$}', $commands)) < 1) { + if (false !== $pos = strrpos($name, ':')) { + // check if a namespace exists and contains commands + $this->findNamespace(substr($name, 0, $pos)); + } + + $message = sprintf('Command "%s" is not defined.', $name); + + if ($alternatives = $this->findAlternatives($name, $allCommands, array())) { + if (1 == count($alternatives)) { + $message .= "\n\nDid you mean this?\n "; + } else { + $message .= "\n\nDid you mean one of these?\n "; + } + $message .= implode("\n ", $alternatives); + } + + throw new \InvalidArgumentException($message); + } + + // filter out aliases for commands which are already on the list + if (count($commands) > 1) { + $commandList = $this->commands; + $commands = array_filter($commands, function ($nameOrAlias) use ($commandList, $commands) { + $commandName = $commandList[$nameOrAlias]->getName(); + + return $commandName === $nameOrAlias || !in_array($commandName, $commands); + }); + } + + $exact = in_array($name, $commands, true); + if (count($commands) > 1 && !$exact) { + $suggestions = $this->getAbbreviationSuggestions(array_values($commands)); + + throw new \InvalidArgumentException(sprintf('Command "%s" is ambiguous (%s).', $name, $suggestions)); + } + + return $this->get($exact ? $name : reset($commands)); + } + + /** + * Gets the commands (registered in the given namespace if provided). + * + * The array keys are the full names and the values the command instances. + * + * @param string $namespace A namespace name + * + * @return Command[] An array of Command instances + * + * @api + */ + public function all($namespace = null) + { + if (null === $namespace) { + return $this->commands; + } + + $commands = array(); + foreach ($this->commands as $name => $command) { + if ($namespace === $this->extractNamespace($name, substr_count($namespace, ':') + 1)) { + $commands[$name] = $command; + } + } + + return $commands; + } + + /** + * Returns an array of possible abbreviations given a set of names. + * + * @param array $names An array of names + * + * @return array An array of abbreviations + */ + public static function getAbbreviations($names) + { + $abbrevs = array(); + foreach ($names as $name) { + for ($len = strlen($name); $len > 0; --$len) { + $abbrev = substr($name, 0, $len); + $abbrevs[$abbrev][] = $name; + } + } + + return $abbrevs; + } + + /** + * Returns a text representation of the Application. + * + * @param string $namespace An optional namespace name + * @param bool $raw Whether to return raw command list + * + * @return string A string representing the Application + * + * @deprecated Deprecated since version 2.3, to be removed in 3.0. + */ + public function asText($namespace = null, $raw = false) + { + $descriptor = new TextDescriptor(); + $output = new BufferedOutput(BufferedOutput::VERBOSITY_NORMAL, !$raw); + $descriptor->describe($output, $this, array('namespace' => $namespace, 'raw_output' => true)); + + return $output->fetch(); + } + + /** + * Returns an XML representation of the Application. + * + * @param string $namespace An optional namespace name + * @param bool $asDom Whether to return a DOM or an XML string + * + * @return string|\DOMDocument An XML string representing the Application + * + * @deprecated Deprecated since version 2.3, to be removed in 3.0. + */ + public function asXml($namespace = null, $asDom = false) + { + $descriptor = new XmlDescriptor(); + + if ($asDom) { + return $descriptor->getApplicationDocument($this, $namespace); + } + + $output = new BufferedOutput(); + $descriptor->describe($output, $this, array('namespace' => $namespace)); + + return $output->fetch(); + } + + /** + * Renders a caught exception. + * + * @param \Exception $e An exception instance + * @param OutputInterface $output An OutputInterface instance + */ + public function renderException($e, $output) + { + do { + $title = sprintf(' [%s] ', get_class($e)); + + $len = $this->stringWidth($title); + + $width = $this->getTerminalWidth() ? $this->getTerminalWidth() - 1 : PHP_INT_MAX; + // HHVM only accepts 32 bits integer in str_split, even when PHP_INT_MAX is a 64 bit integer: https://github.com/facebook/hhvm/issues/1327 + if (defined('HHVM_VERSION') && $width > 1 << 31) { + $width = 1 << 31; + } + $formatter = $output->getFormatter(); + $lines = array(); + foreach (preg_split('/\r?\n/', $e->getMessage()) as $line) { + foreach ($this->splitStringByWidth($line, $width - 4) as $line) { + // pre-format lines to get the right string length + $lineLength = $this->stringWidth(preg_replace('/\[[^m]*m/', '', $formatter->format($line))) + 4; + $lines[] = array($line, $lineLength); + + $len = max($lineLength, $len); + } + } + + $messages = array('', ''); + $messages[] = $emptyLine = $formatter->format(sprintf('%s', str_repeat(' ', $len))); + $messages[] = $formatter->format(sprintf('%s%s', $title, str_repeat(' ', max(0, $len - $this->stringWidth($title))))); + foreach ($lines as $line) { + $messages[] = $formatter->format(sprintf(' %s %s', $line[0], str_repeat(' ', $len - $line[1]))); + } + $messages[] = $emptyLine; + $messages[] = ''; + $messages[] = ''; + + $output->writeln($messages, OutputInterface::OUTPUT_RAW); + + if (OutputInterface::VERBOSITY_VERBOSE <= $output->getVerbosity()) { + $output->writeln('Exception trace:'); + + // exception related properties + $trace = $e->getTrace(); + array_unshift($trace, array( + 'function' => '', + 'file' => $e->getFile() != null ? $e->getFile() : 'n/a', + 'line' => $e->getLine() != null ? $e->getLine() : 'n/a', + 'args' => array(), + )); + + for ($i = 0, $count = count($trace); $i < $count; $i++) { + $class = isset($trace[$i]['class']) ? $trace[$i]['class'] : ''; + $type = isset($trace[$i]['type']) ? $trace[$i]['type'] : ''; + $function = $trace[$i]['function']; + $file = isset($trace[$i]['file']) ? $trace[$i]['file'] : 'n/a'; + $line = isset($trace[$i]['line']) ? $trace[$i]['line'] : 'n/a'; + + $output->writeln(sprintf(' %s%s%s() at %s:%s', $class, $type, $function, $file, $line)); + } + + $output->writeln(""); + $output->writeln(""); + } + } while ($e = $e->getPrevious()); + + if (null !== $this->runningCommand) { + $output->writeln(sprintf('%s', sprintf($this->runningCommand->getSynopsis(), $this->getName()))); + $output->writeln(""); + $output->writeln(""); + } + } + + /** + * Tries to figure out the terminal width in which this application runs + * + * @return int|null + */ + protected function getTerminalWidth() + { + $dimensions = $this->getTerminalDimensions(); + + return $dimensions[0]; + } + + /** + * Tries to figure out the terminal height in which this application runs + * + * @return int|null + */ + protected function getTerminalHeight() + { + $dimensions = $this->getTerminalDimensions(); + + return $dimensions[1]; + } + + /** + * Tries to figure out the terminal dimensions based on the current environment + * + * @return array Array containing width and height + */ + public function getTerminalDimensions() + { + if ($this->terminalDimensions) { + return $this->terminalDimensions; + } + + if (defined('PHP_WINDOWS_VERSION_BUILD')) { + // extract [w, H] from "wxh (WxH)" + if (preg_match('/^(\d+)x\d+ \(\d+x(\d+)\)$/', trim(getenv('ANSICON')), $matches)) { + return array((int) $matches[1], (int) $matches[2]); + } + // extract [w, h] from "wxh" + if (preg_match('/^(\d+)x(\d+)$/', $this->getConsoleMode(), $matches)) { + return array((int) $matches[1], (int) $matches[2]); + } + } + + if ($sttyString = $this->getSttyColumns()) { + // extract [w, h] from "rows h; columns w;" + if (preg_match('/rows.(\d+);.columns.(\d+);/i', $sttyString, $matches)) { + return array((int) $matches[2], (int) $matches[1]); + } + // extract [w, h] from "; h rows; w columns" + if (preg_match('/;.(\d+).rows;.(\d+).columns/i', $sttyString, $matches)) { + return array((int) $matches[2], (int) $matches[1]); + } + } + + return array(null, null); + } + + /** + * Sets terminal dimensions. + * + * Can be useful to force terminal dimensions for functional tests. + * + * @param int $width The width + * @param int $height The height + * + * @return Application The current application + */ + public function setTerminalDimensions($width, $height) + { + $this->terminalDimensions = array($width, $height); + + return $this; + } + + /** + * Configures the input and output instances based on the user arguments and options. + * + * @param InputInterface $input An InputInterface instance + * @param OutputInterface $output An OutputInterface instance + */ + protected function configureIO(InputInterface $input, OutputInterface $output) + { + if (true === $input->hasParameterOption(array('--ansi'))) { + $output->setDecorated(true); + } elseif (true === $input->hasParameterOption(array('--no-ansi'))) { + $output->setDecorated(false); + } + + if (true === $input->hasParameterOption(array('--no-interaction', '-n'))) { + $input->setInteractive(false); + } elseif (function_exists('posix_isatty') && $this->getHelperSet()->has('dialog')) { + $inputStream = $this->getHelperSet()->get('dialog')->getInputStream(); + if (!@posix_isatty($inputStream)) { + $input->setInteractive(false); + } + } + + if (true === $input->hasParameterOption(array('--quiet', '-q'))) { + $output->setVerbosity(OutputInterface::VERBOSITY_QUIET); + } else { + if ($input->hasParameterOption('-vvv') || $input->hasParameterOption('--verbose=3') || $input->getParameterOption('--verbose') === 3) { + $output->setVerbosity(OutputInterface::VERBOSITY_DEBUG); + } elseif ($input->hasParameterOption('-vv') || $input->hasParameterOption('--verbose=2') || $input->getParameterOption('--verbose') === 2) { + $output->setVerbosity(OutputInterface::VERBOSITY_VERY_VERBOSE); + } elseif ($input->hasParameterOption('-v') || $input->hasParameterOption('--verbose=1') || $input->hasParameterOption('--verbose') || $input->getParameterOption('--verbose')) { + $output->setVerbosity(OutputInterface::VERBOSITY_VERBOSE); + } + } + } + + /** + * Runs the current command. + * + * If an event dispatcher has been attached to the application, + * events are also dispatched during the life-cycle of the command. + * + * @param Command $command A Command instance + * @param InputInterface $input An Input instance + * @param OutputInterface $output An Output instance + * + * @return int 0 if everything went fine, or an error code + */ + protected function doRunCommand(Command $command, InputInterface $input, OutputInterface $output) + { + foreach ($command->getHelperSet() as $helper) { + if ($helper instanceof InputAwareInterface) { + $helper->setInput($input); + } + } + + if (null === $this->dispatcher) { + return $command->run($input, $output); + } + + $event = new ConsoleCommandEvent($command, $input, $output); + $this->dispatcher->dispatch(ConsoleEvents::COMMAND, $event); + + try { + $exitCode = $command->run($input, $output); + } catch (\Exception $e) { + $event = new ConsoleTerminateEvent($command, $input, $output, $e->getCode()); + $this->dispatcher->dispatch(ConsoleEvents::TERMINATE, $event); + + $event = new ConsoleExceptionEvent($command, $input, $output, $e, $event->getExitCode()); + $this->dispatcher->dispatch(ConsoleEvents::EXCEPTION, $event); + + throw $event->getException(); + } + + $event = new ConsoleTerminateEvent($command, $input, $output, $exitCode); + $this->dispatcher->dispatch(ConsoleEvents::TERMINATE, $event); + + return $event->getExitCode(); + } + + /** + * Gets the name of the command based on input. + * + * @param InputInterface $input The input interface + * + * @return string The command name + */ + protected function getCommandName(InputInterface $input) + { + return $input->getFirstArgument(); + } + + /** + * Gets the default input definition. + * + * @return InputDefinition An InputDefinition instance + */ + protected function getDefaultInputDefinition() + { + return new InputDefinition(array( + new InputArgument('command', InputArgument::REQUIRED, 'The command to execute'), + + new InputOption('--help', '-h', InputOption::VALUE_NONE, 'Display this help message.'), + new InputOption('--quiet', '-q', InputOption::VALUE_NONE, 'Do not output any message.'), + new InputOption('--verbose', '-v|vv|vvv', InputOption::VALUE_NONE, 'Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug'), + new InputOption('--version', '-V', InputOption::VALUE_NONE, 'Display this application version.'), + new InputOption('--ansi', '', InputOption::VALUE_NONE, 'Force ANSI output.'), + new InputOption('--no-ansi', '', InputOption::VALUE_NONE, 'Disable ANSI output.'), + new InputOption('--no-interaction', '-n', InputOption::VALUE_NONE, 'Do not ask any interactive question.'), + )); + } + + /** + * Gets the default commands that should always be available. + * + * @return Command[] An array of default Command instances + */ + protected function getDefaultCommands() + { + return array(new HelpCommand(), new ListCommand()); + } + + /** + * Gets the default helper set with the helpers that should always be available. + * + * @return HelperSet A HelperSet instance + */ + protected function getDefaultHelperSet() + { + return new HelperSet(array( + new FormatterHelper(), + new DialogHelper(), + new ProgressHelper(), + new TableHelper(), + )); + } + + /** + * Runs and parses stty -a if it's available, suppressing any error output + * + * @return string + */ + private function getSttyColumns() + { + if (!function_exists('proc_open')) { + return; + } + + $descriptorspec = array(1 => array('pipe', 'w'), 2 => array('pipe', 'w')); + $process = proc_open('stty -a | grep columns', $descriptorspec, $pipes, null, null, array('suppress_errors' => true)); + if (is_resource($process)) { + $info = stream_get_contents($pipes[1]); + fclose($pipes[1]); + fclose($pipes[2]); + proc_close($process); + + return $info; + } + } + + /** + * Runs and parses mode CON if it's available, suppressing any error output + * + * @return string x or null if it could not be parsed + */ + private function getConsoleMode() + { + if (!function_exists('proc_open')) { + return; + } + + $descriptorspec = array(1 => array('pipe', 'w'), 2 => array('pipe', 'w')); + $process = proc_open('mode CON', $descriptorspec, $pipes, null, null, array('suppress_errors' => true)); + if (is_resource($process)) { + $info = stream_get_contents($pipes[1]); + fclose($pipes[1]); + fclose($pipes[2]); + proc_close($process); + + if (preg_match('/--------+\r?\n.+?(\d+)\r?\n.+?(\d+)\r?\n/', $info, $matches)) { + return $matches[2].'x'.$matches[1]; + } + } + } + + /** + * Returns abbreviated suggestions in string format. + * + * @param array $abbrevs Abbreviated suggestions to convert + * + * @return string A formatted string of abbreviated suggestions + */ + private function getAbbreviationSuggestions($abbrevs) + { + return sprintf('%s, %s%s', $abbrevs[0], $abbrevs[1], count($abbrevs) > 2 ? sprintf(' and %d more', count($abbrevs) - 2) : ''); + } + + /** + * Returns the namespace part of the command name. + * + * This method is not part of public API and should not be used directly. + * + * @param string $name The full name of the command + * @param string $limit The maximum number of parts of the namespace + * + * @return string The namespace of the command + */ + public function extractNamespace($name, $limit = null) + { + $parts = explode(':', $name); + array_pop($parts); + + return implode(':', null === $limit ? $parts : array_slice($parts, 0, $limit)); + } + + /** + * Finds alternative of $name among $collection, + * if nothing is found in $collection, try in $abbrevs + * + * @param string $name The string + * @param array|\Traversable $collection The collection + * + * @return array A sorted array of similar string + */ + private function findAlternatives($name, $collection) + { + $threshold = 1e3; + $alternatives = array(); + + $collectionParts = array(); + foreach ($collection as $item) { + $collectionParts[$item] = explode(':', $item); + } + + foreach (explode(':', $name) as $i => $subname) { + foreach ($collectionParts as $collectionName => $parts) { + $exists = isset($alternatives[$collectionName]); + if (!isset($parts[$i]) && $exists) { + $alternatives[$collectionName] += $threshold; + continue; + } elseif (!isset($parts[$i])) { + continue; + } + + $lev = levenshtein($subname, $parts[$i]); + if ($lev <= strlen($subname) / 3 || false !== strpos($parts[$i], $subname)) { + $alternatives[$collectionName] = $exists ? $alternatives[$collectionName] + $lev : $lev; + } elseif ($exists) { + $alternatives[$collectionName] += $threshold; + } + } + } + + foreach ($collection as $item) { + $lev = levenshtein($name, $item); + if ($lev <= strlen($name) / 3 || false !== strpos($item, $name)) { + $alternatives[$item] = isset($alternatives[$item]) ? $alternatives[$item] - $lev : $lev; + } + } + + $alternatives = array_filter($alternatives, function ($lev) use ($threshold) { return $lev < 2*$threshold; }); + asort($alternatives); + + return array_keys($alternatives); + } + + private function stringWidth($string) + { + if (!function_exists('mb_strwidth')) { + return strlen($string); + } + + if (false === $encoding = mb_detect_encoding($string)) { + return strlen($string); + } + + return mb_strwidth($string, $encoding); + } + + private function splitStringByWidth($string, $width) + { + // str_split is not suitable for multi-byte characters, we should use preg_split to get char array properly. + // additionally, array_slice() is not enough as some character has doubled width. + // we need a function to split string not by character count but by string width + + if (!function_exists('mb_strwidth')) { + return str_split($string, $width); + } + + if (false === $encoding = mb_detect_encoding($string)) { + return str_split($string, $width); + } + + $utf8String = mb_convert_encoding($string, 'utf8', $encoding); + $lines = array(); + $line = ''; + foreach (preg_split('//u', $utf8String) as $char) { + // test if $char could be appended to current line + if (mb_strwidth($line.$char, 'utf8') <= $width) { + $line .= $char; + continue; + } + // if not, push current line to array and make new line + $lines[] = str_pad($line, $width); + $line = $char; + } + if (strlen($line)) { + $lines[] = count($lines) ? str_pad($line, $width) : $line; + } + + mb_convert_variables($encoding, 'utf8', $lines); + + return $lines; + } +} diff --git a/vendor/symfony/console/Symfony/Component/Console/CHANGELOG.md b/vendor/symfony/console/Symfony/Component/Console/CHANGELOG.md new file mode 100755 index 0000000..4d00cbb --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/CHANGELOG.md @@ -0,0 +1,45 @@ +CHANGELOG +========= + +2.4.0 +----- + + * added a way to force terminal dimensions + * added a convenient method to detect verbosity level + * [BC BREAK] made descriptors use output instead of returning a string + +2.3.0 +----- + + * added multiselect support to the select dialog helper + * added Table Helper for tabular data rendering + * added support for events in `Application` + * added a way to normalize EOLs in `ApplicationTester::getDisplay()` and `CommandTester::getDisplay()` + * added a way to set the progress bar progress via the `setCurrent` method + * added support for multiple InputOption shortcuts, written as `'-a|-b|-c'` + * added two additional verbosity levels, VERBOSITY_VERY_VERBOSE and VERBOSITY_DEBUG + +2.2.0 +----- + + * added support for colorization on Windows via ConEmu + * add a method to Dialog Helper to ask for a question and hide the response + * added support for interactive selections in console (DialogHelper::select()) + * added support for autocompletion as you type in Dialog Helper + +2.1.0 +----- + + * added ConsoleOutputInterface + * added the possibility to disable a command (Command::isEnabled()) + * added suggestions when a command does not exist + * added a --raw option to the list command + * added support for STDERR in the console output class (errors are now sent + to STDERR) + * made the defaults (helper set, commands, input definition) in Application + more easily customizable + * added support for the shell even if readline is not available + * added support for process isolation in Symfony shell via + `--process-isolation` switch + * added support for `--`, which disables options parsing after that point + (tokens will be parsed as arguments) diff --git a/vendor/symfony/console/Symfony/Component/Console/Command/Command.php b/vendor/symfony/console/Symfony/Component/Console/Command/Command.php new file mode 100755 index 0000000..ebab4ad --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Command/Command.php @@ -0,0 +1,622 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Console\Command; + +use Symfony\Component\Console\Descriptor\TextDescriptor; +use Symfony\Component\Console\Descriptor\XmlDescriptor; +use Symfony\Component\Console\Input\InputDefinition; +use Symfony\Component\Console\Input\InputOption; +use Symfony\Component\Console\Input\InputArgument; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Output\BufferedOutput; +use Symfony\Component\Console\Output\OutputInterface; +use Symfony\Component\Console\Application; +use Symfony\Component\Console\Helper\HelperSet; + +/** + * Base class for all commands. + * + * @author Fabien Potencier + * + * @api + */ +class Command +{ + private $application; + private $name; + private $aliases = array(); + private $definition; + private $help; + private $description; + private $ignoreValidationErrors = false; + private $applicationDefinitionMerged = false; + private $applicationDefinitionMergedWithArgs = false; + private $code; + private $synopsis; + private $helperSet; + + /** + * Constructor. + * + * @param string|null $name The name of the command; passing null means it must be set in configure() + * + * @throws \LogicException When the command name is empty + * + * @api + */ + public function __construct($name = null) + { + $this->definition = new InputDefinition(); + + if (null !== $name) { + $this->setName($name); + } + + $this->configure(); + + if (!$this->name) { + throw new \LogicException('The command name cannot be empty.'); + } + } + + /** + * Ignores validation errors. + * + * This is mainly useful for the help command. + */ + public function ignoreValidationErrors() + { + $this->ignoreValidationErrors = true; + } + + /** + * Sets the application instance for this command. + * + * @param Application $application An Application instance + * + * @api + */ + public function setApplication(Application $application = null) + { + $this->application = $application; + if ($application) { + $this->setHelperSet($application->getHelperSet()); + } else { + $this->helperSet = null; + } + } + + /** + * Sets the helper set. + * + * @param HelperSet $helperSet A HelperSet instance + */ + public function setHelperSet(HelperSet $helperSet) + { + $this->helperSet = $helperSet; + } + + /** + * Gets the helper set. + * + * @return HelperSet A HelperSet instance + */ + public function getHelperSet() + { + return $this->helperSet; + } + + /** + * Gets the application instance for this command. + * + * @return Application An Application instance + * + * @api + */ + public function getApplication() + { + return $this->application; + } + + /** + * Checks whether the command is enabled or not in the current environment + * + * Override this to check for x or y and return false if the command can not + * run properly under the current conditions. + * + * @return bool + */ + public function isEnabled() + { + return true; + } + + /** + * Configures the current command. + */ + protected function configure() + { + } + + /** + * Executes the current command. + * + * This method is not abstract because you can use this class + * as a concrete class. In this case, instead of defining the + * execute() method, you set the code to execute by passing + * a Closure to the setCode() method. + * + * @param InputInterface $input An InputInterface instance + * @param OutputInterface $output An OutputInterface instance + * + * @return null|int null or 0 if everything went fine, or an error code + * + * @throws \LogicException When this abstract method is not implemented + * @see setCode() + */ + protected function execute(InputInterface $input, OutputInterface $output) + { + throw new \LogicException('You must override the execute() method in the concrete command class.'); + } + + /** + * Interacts with the user. + * + * @param InputInterface $input An InputInterface instance + * @param OutputInterface $output An OutputInterface instance + */ + protected function interact(InputInterface $input, OutputInterface $output) + { + } + + /** + * Initializes the command just after the input has been validated. + * + * This is mainly useful when a lot of commands extends one main command + * where some things need to be initialized based on the input arguments and options. + * + * @param InputInterface $input An InputInterface instance + * @param OutputInterface $output An OutputInterface instance + */ + protected function initialize(InputInterface $input, OutputInterface $output) + { + } + + /** + * Runs the command. + * + * The code to execute is either defined directly with the + * setCode() method or by overriding the execute() method + * in a sub-class. + * + * @param InputInterface $input An InputInterface instance + * @param OutputInterface $output An OutputInterface instance + * + * @return int The command exit code + * + * @throws \Exception + * + * @see setCode() + * @see execute() + * + * @api + */ + public function run(InputInterface $input, OutputInterface $output) + { + // force the creation of the synopsis before the merge with the app definition + $this->getSynopsis(); + + // add the application arguments and options + $this->mergeApplicationDefinition(); + + // bind the input against the command specific arguments/options + try { + $input->bind($this->definition); + } catch (\Exception $e) { + if (!$this->ignoreValidationErrors) { + throw $e; + } + } + + $this->initialize($input, $output); + + if ($input->isInteractive()) { + $this->interact($input, $output); + } + + $input->validate(); + + if ($this->code) { + $statusCode = call_user_func($this->code, $input, $output); + } else { + $statusCode = $this->execute($input, $output); + } + + return is_numeric($statusCode) ? (int) $statusCode : 0; + } + + /** + * Sets the code to execute when running this command. + * + * If this method is used, it overrides the code defined + * in the execute() method. + * + * @param callable $code A callable(InputInterface $input, OutputInterface $output) + * + * @return Command The current instance + * + * @throws \InvalidArgumentException + * + * @see execute() + * + * @api + */ + public function setCode($code) + { + if (!is_callable($code)) { + throw new \InvalidArgumentException('Invalid callable provided to Command::setCode.'); + } + + $this->code = $code; + + return $this; + } + + /** + * Merges the application definition with the command definition. + * + * This method is not part of public API and should not be used directly. + * + * @param bool $mergeArgs Whether to merge or not the Application definition arguments to Command definition arguments + */ + public function mergeApplicationDefinition($mergeArgs = true) + { + if (null === $this->application || (true === $this->applicationDefinitionMerged && ($this->applicationDefinitionMergedWithArgs || !$mergeArgs))) { + return; + } + + if ($mergeArgs) { + $currentArguments = $this->definition->getArguments(); + $this->definition->setArguments($this->application->getDefinition()->getArguments()); + $this->definition->addArguments($currentArguments); + } + + $this->definition->addOptions($this->application->getDefinition()->getOptions()); + + $this->applicationDefinitionMerged = true; + if ($mergeArgs) { + $this->applicationDefinitionMergedWithArgs = true; + } + } + + /** + * Sets an array of argument and option instances. + * + * @param array|InputDefinition $definition An array of argument and option instances or a definition instance + * + * @return Command The current instance + * + * @api + */ + public function setDefinition($definition) + { + if ($definition instanceof InputDefinition) { + $this->definition = $definition; + } else { + $this->definition->setDefinition($definition); + } + + $this->applicationDefinitionMerged = false; + + return $this; + } + + /** + * Gets the InputDefinition attached to this Command. + * + * @return InputDefinition An InputDefinition instance + * + * @api + */ + public function getDefinition() + { + return $this->definition; + } + + /** + * Gets the InputDefinition to be used to create XML and Text representations of this Command. + * + * Can be overridden to provide the original command representation when it would otherwise + * be changed by merging with the application InputDefinition. + * + * This method is not part of public API and should not be used directly. + * + * @return InputDefinition An InputDefinition instance + */ + public function getNativeDefinition() + { + return $this->getDefinition(); + } + + /** + * Adds an argument. + * + * @param string $name The argument name + * @param int $mode The argument mode: InputArgument::REQUIRED or InputArgument::OPTIONAL + * @param string $description A description text + * @param mixed $default The default value (for InputArgument::OPTIONAL mode only) + * + * @return Command The current instance + * + * @api + */ + public function addArgument($name, $mode = null, $description = '', $default = null) + { + $this->definition->addArgument(new InputArgument($name, $mode, $description, $default)); + + return $this; + } + + /** + * Adds an option. + * + * @param string $name The option name + * @param string $shortcut The shortcut (can be null) + * @param int $mode The option mode: One of the InputOption::VALUE_* constants + * @param string $description A description text + * @param mixed $default The default value (must be null for InputOption::VALUE_REQUIRED or InputOption::VALUE_NONE) + * + * @return Command The current instance + * + * @api + */ + public function addOption($name, $shortcut = null, $mode = null, $description = '', $default = null) + { + $this->definition->addOption(new InputOption($name, $shortcut, $mode, $description, $default)); + + return $this; + } + + /** + * Sets the name of the command. + * + * This method can set both the namespace and the name if + * you separate them by a colon (:) + * + * $command->setName('foo:bar'); + * + * @param string $name The command name + * + * @return Command The current instance + * + * @throws \InvalidArgumentException When the name is invalid + * + * @api + */ + public function setName($name) + { + $this->validateName($name); + + $this->name = $name; + + return $this; + } + + /** + * Returns the command name. + * + * @return string The command name + * + * @api + */ + public function getName() + { + return $this->name; + } + + /** + * Sets the description for the command. + * + * @param string $description The description for the command + * + * @return Command The current instance + * + * @api + */ + public function setDescription($description) + { + $this->description = $description; + + return $this; + } + + /** + * Returns the description for the command. + * + * @return string The description for the command + * + * @api + */ + public function getDescription() + { + return $this->description; + } + + /** + * Sets the help for the command. + * + * @param string $help The help for the command + * + * @return Command The current instance + * + * @api + */ + public function setHelp($help) + { + $this->help = $help; + + return $this; + } + + /** + * Returns the help for the command. + * + * @return string The help for the command + * + * @api + */ + public function getHelp() + { + return $this->help; + } + + /** + * Returns the processed help for the command replacing the %command.name% and + * %command.full_name% patterns with the real values dynamically. + * + * @return string The processed help for the command + */ + public function getProcessedHelp() + { + $name = $this->name; + + $placeholders = array( + '%command.name%', + '%command.full_name%' + ); + $replacements = array( + $name, + $_SERVER['PHP_SELF'].' '.$name + ); + + return str_replace($placeholders, $replacements, $this->getHelp()); + } + + /** + * Sets the aliases for the command. + * + * @param array $aliases An array of aliases for the command + * + * @return Command The current instance + * + * @throws \InvalidArgumentException When an alias is invalid + * + * @api + */ + public function setAliases($aliases) + { + foreach ($aliases as $alias) { + $this->validateName($alias); + } + + $this->aliases = $aliases; + + return $this; + } + + /** + * Returns the aliases for the command. + * + * @return array An array of aliases for the command + * + * @api + */ + public function getAliases() + { + return $this->aliases; + } + + /** + * Returns the synopsis for the command. + * + * @return string The synopsis + */ + public function getSynopsis() + { + if (null === $this->synopsis) { + $this->synopsis = trim(sprintf('%s %s', $this->name, $this->definition->getSynopsis())); + } + + return $this->synopsis; + } + + /** + * Gets a helper instance by name. + * + * @param string $name The helper name + * + * @return mixed The helper value + * + * @throws \InvalidArgumentException if the helper is not defined + * + * @api + */ + public function getHelper($name) + { + return $this->helperSet->get($name); + } + + /** + * Returns a text representation of the command. + * + * @return string A string representing the command + * + * @deprecated Deprecated since version 2.3, to be removed in 3.0. + */ + public function asText() + { + $descriptor = new TextDescriptor(); + $output = new BufferedOutput(BufferedOutput::VERBOSITY_NORMAL, true); + $descriptor->describe($output, $this, array('raw_output' => true)); + + return $output->fetch(); + } + + /** + * Returns an XML representation of the command. + * + * @param bool $asDom Whether to return a DOM or an XML string + * + * @return string|\DOMDocument An XML string representing the command + * + * @deprecated Deprecated since version 2.3, to be removed in 3.0. + */ + public function asXml($asDom = false) + { + $descriptor = new XmlDescriptor(); + + if ($asDom) { + return $descriptor->getCommandDocument($this); + } + + $output = new BufferedOutput(); + $descriptor->describe($output, $this); + + return $output->fetch(); + } + + /** + * Validates a command name. + * + * It must be non-empty and parts can optionally be separated by ":". + * + * @param string $name + * + * @throws \InvalidArgumentException When the name is invalid + */ + private function validateName($name) + { + if (!preg_match('/^[^\:]++(\:[^\:]++)*$/', $name)) { + throw new \InvalidArgumentException(sprintf('Command name "%s" is invalid.', $name)); + } + } +} diff --git a/vendor/symfony/console/Symfony/Component/Console/Command/HelpCommand.php b/vendor/symfony/console/Symfony/Component/Console/Command/HelpCommand.php new file mode 100755 index 0000000..e76044a --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Command/HelpCommand.php @@ -0,0 +1,91 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Console\Command; + +use Symfony\Component\Console\Helper\DescriptorHelper; +use Symfony\Component\Console\Input\InputArgument; +use Symfony\Component\Console\Input\InputOption; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Output\OutputInterface; + +/** + * HelpCommand displays the help for a given command. + * + * @author Fabien Potencier + */ +class HelpCommand extends Command +{ + private $command; + + /** + * {@inheritdoc} + */ + protected function configure() + { + $this->ignoreValidationErrors(); + + $this + ->setName('help') + ->setDefinition(array( + new InputArgument('command_name', InputArgument::OPTIONAL, 'The command name', 'help'), + new InputOption('xml', null, InputOption::VALUE_NONE, 'To output help as XML'), + new InputOption('format', null, InputOption::VALUE_REQUIRED, 'To output help in other formats', 'txt'), + new InputOption('raw', null, InputOption::VALUE_NONE, 'To output raw command help'), + )) + ->setDescription('Displays help for a command') + ->setHelp(<<%command.name% command displays help for a given command: + + php %command.full_name% list + +You can also output the help in other formats by using the --format option: + + php %command.full_name% --format=xml list + +To display the list of available commands, please use the list command. +EOF + ) + ; + } + + /** + * Sets the command + * + * @param Command $command The command to set + */ + public function setCommand(Command $command) + { + $this->command = $command; + } + + /** + * {@inheritdoc} + */ + protected function execute(InputInterface $input, OutputInterface $output) + { + if (null === $this->command) { + $this->command = $this->getApplication()->find($input->getArgument('command_name')); + } + + if ($input->getOption('xml')) { + $input->setOption('format', 'xml'); + } + + $helper = new DescriptorHelper(); + $helper->describe($output, $this->command, array( + 'format' => $input->getOption('format'), + 'raw' => $input->getOption('raw'), + )); + + $this->command = null; + } +} diff --git a/vendor/symfony/console/Symfony/Component/Console/Command/ListCommand.php b/vendor/symfony/console/Symfony/Component/Console/Command/ListCommand.php new file mode 100755 index 0000000..25c2120 --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Command/ListCommand.php @@ -0,0 +1,95 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Console\Command; + +use Symfony\Component\Console\Helper\DescriptorHelper; +use Symfony\Component\Console\Input\InputArgument; +use Symfony\Component\Console\Input\InputOption; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Output\OutputInterface; +use Symfony\Component\Console\Input\InputDefinition; + +/** + * ListCommand displays the list of all available commands for the application. + * + * @author Fabien Potencier + */ +class ListCommand extends Command +{ + /** + * {@inheritdoc} + */ + protected function configure() + { + $this + ->setName('list') + ->setDefinition($this->createDefinition()) + ->setDescription('Lists commands') + ->setHelp(<<%command.name% command lists all commands: + + php %command.full_name% + +You can also display the commands for a specific namespace: + + php %command.full_name% test + +You can also output the information in other formats by using the --format option: + + php %command.full_name% --format=xml + +It's also possible to get raw list of commands (useful for embedding command runner): + + php %command.full_name% --raw +EOF + ) + ; + } + + /** + * {@inheritdoc} + */ + public function getNativeDefinition() + { + return $this->createDefinition(); + } + + /** + * {@inheritdoc} + */ + protected function execute(InputInterface $input, OutputInterface $output) + { + if ($input->getOption('xml')) { + $input->setOption('format', 'xml'); + } + + $helper = new DescriptorHelper(); + $helper->describe($output, $this->getApplication(), array( + 'format' => $input->getOption('format'), + 'raw_text' => $input->getOption('raw'), + 'namespace' => $input->getArgument('namespace'), + )); + } + + /** + * {@inheritdoc} + */ + private function createDefinition() + { + return new InputDefinition(array( + new InputArgument('namespace', InputArgument::OPTIONAL, 'The namespace name'), + new InputOption('xml', null, InputOption::VALUE_NONE, 'To output list as XML'), + new InputOption('raw', null, InputOption::VALUE_NONE, 'To output raw command list'), + new InputOption('format', null, InputOption::VALUE_REQUIRED, 'To output list in other formats', 'txt'), + )); + } +} diff --git a/vendor/symfony/console/Symfony/Component/Console/ConsoleEvents.php b/vendor/symfony/console/Symfony/Component/Console/ConsoleEvents.php new file mode 100755 index 0000000..12ede2d --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/ConsoleEvents.php @@ -0,0 +1,55 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Console; + +/** + * Contains all events dispatched by an Application. + * + * @author Francesco Levorato + */ +final class ConsoleEvents +{ + /** + * The COMMAND event allows you to attach listeners before any command is + * executed by the console. It also allows you to modify the command, input and output + * before they are handled to the command. + * + * The event listener method receives a Symfony\Component\Console\Event\ConsoleCommandEvent + * instance. + * + * @var string + */ + const COMMAND = 'console.command'; + + /** + * The TERMINATE event allows you to attach listeners after a command is + * executed by the console. + * + * The event listener method receives a Symfony\Component\Console\Event\ConsoleTerminateEvent + * instance. + * + * @var string + */ + const TERMINATE = 'console.terminate'; + + /** + * The EXCEPTION event occurs when an uncaught exception appears. + * + * This event allows you to deal with the exception or + * to modify the thrown exception. The event listener method receives + * a Symfony\Component\Console\Event\ConsoleExceptionEvent + * instance. + * + * @var string + */ + const EXCEPTION = 'console.exception'; +} diff --git a/vendor/symfony/console/Symfony/Component/Console/Descriptor/ApplicationDescription.php b/vendor/symfony/console/Symfony/Component/Console/Descriptor/ApplicationDescription.php new file mode 100755 index 0000000..cdf1493 --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Descriptor/ApplicationDescription.php @@ -0,0 +1,153 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Console\Descriptor; + +use Symfony\Component\Console\Application; +use Symfony\Component\Console\Command\Command; + +/** + * @author Jean-François Simon + */ +class ApplicationDescription +{ + const GLOBAL_NAMESPACE = '_global'; + + /** + * @var Application + */ + private $application; + + /** + * @var null|string + */ + private $namespace; + + /** + * @var array + */ + private $namespaces; + + /** + * @var Command[] + */ + private $commands; + + /** + * @var Command[] + */ + private $aliases; + + /** + * Constructor. + * + * @param Application $application + * @param string|null $namespace + */ + public function __construct(Application $application, $namespace = null) + { + $this->application = $application; + $this->namespace = $namespace; + } + + /** + * @return array + */ + public function getNamespaces() + { + if (null === $this->namespaces) { + $this->inspectApplication(); + } + + return $this->namespaces; + } + + /** + * @return Command[] + */ + public function getCommands() + { + if (null === $this->commands) { + $this->inspectApplication(); + } + + return $this->commands; + } + + /** + * @param string $name + * + * @return Command + * + * @throws \InvalidArgumentException + */ + public function getCommand($name) + { + if (!isset($this->commands[$name]) && !isset($this->aliases[$name])) { + throw new \InvalidArgumentException(sprintf('Command %s does not exist.', $name)); + } + + return isset($this->commands[$name]) ? $this->commands[$name] : $this->aliases[$name]; + } + + private function inspectApplication() + { + $this->commands = array(); + $this->namespaces = array(); + + $all = $this->application->all($this->namespace ? $this->application->findNamespace($this->namespace) : null); + foreach ($this->sortCommands($all) as $namespace => $commands) { + $names = array(); + + /** @var Command $command */ + foreach ($commands as $name => $command) { + if (!$command->getName()) { + continue; + } + + if ($command->getName() === $name) { + $this->commands[$name] = $command; + } else { + $this->aliases[$name] = $command; + } + + $names[] = $name; + } + + $this->namespaces[$namespace] = array('id' => $namespace, 'commands' => $names); + } + } + + /** + * @param array $commands + * + * @return array + */ + private function sortCommands(array $commands) + { + $namespacedCommands = array(); + foreach ($commands as $name => $command) { + $key = $this->application->extractNamespace($name, 1); + if (!$key) { + $key = '_global'; + } + + $namespacedCommands[$key][$name] = $command; + } + ksort($namespacedCommands); + + foreach ($namespacedCommands as &$commands) { + ksort($commands); + } + + return $namespacedCommands; + } +} diff --git a/vendor/symfony/console/Symfony/Component/Console/Descriptor/Descriptor.php b/vendor/symfony/console/Symfony/Component/Console/Descriptor/Descriptor.php new file mode 100755 index 0000000..ab7acc6 --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Descriptor/Descriptor.php @@ -0,0 +1,119 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Console\Descriptor; + +use Symfony\Component\Console\Application; +use Symfony\Component\Console\Command\Command; +use Symfony\Component\Console\Input\InputArgument; +use Symfony\Component\Console\Input\InputDefinition; +use Symfony\Component\Console\Input\InputOption; +use Symfony\Component\Console\Output\OutputInterface; + +/** + * @author Jean-François Simon + */ +abstract class Descriptor implements DescriptorInterface +{ + /** + * @var OutputInterface + */ + private $output; + + /** + * {@inheritdoc} + */ + public function describe(OutputInterface $output, $object, array $options = array()) + { + $this->output = $output; + + switch (true) { + case $object instanceof InputArgument: + $this->describeInputArgument($object, $options); + break; + case $object instanceof InputOption: + $this->describeInputOption($object, $options); + break; + case $object instanceof InputDefinition: + $this->describeInputDefinition($object, $options); + break; + case $object instanceof Command: + $this->describeCommand($object, $options); + break; + case $object instanceof Application: + $this->describeApplication($object, $options); + break; + default: + throw new \InvalidArgumentException(sprintf('Object of type "%s" is not describable.', get_class($object))); + } + } + + /** + * Writes content to output. + * + * @param string $content + * @param bool $decorated + */ + protected function write($content, $decorated = false) + { + $this->output->write($content, false, $decorated ? OutputInterface::OUTPUT_NORMAL : OutputInterface::OUTPUT_RAW); + } + + /** + * Describes an InputArgument instance. + * + * @param InputArgument $argument + * @param array $options + * + * @return string|mixed + */ + abstract protected function describeInputArgument(InputArgument $argument, array $options = array()); + + /** + * Describes an InputOption instance. + * + * @param InputOption $option + * @param array $options + * + * @return string|mixed + */ + abstract protected function describeInputOption(InputOption $option, array $options = array()); + + /** + * Describes an InputDefinition instance. + * + * @param InputDefinition $definition + * @param array $options + * + * @return string|mixed + */ + abstract protected function describeInputDefinition(InputDefinition $definition, array $options = array()); + + /** + * Describes a Command instance. + * + * @param Command $command + * @param array $options + * + * @return string|mixed + */ + abstract protected function describeCommand(Command $command, array $options = array()); + + /** + * Describes an Application instance. + * + * @param Application $application + * @param array $options + * + * @return string|mixed + */ + abstract protected function describeApplication(Application $application, array $options = array()); +} diff --git a/vendor/symfony/console/Symfony/Component/Console/Descriptor/DescriptorInterface.php b/vendor/symfony/console/Symfony/Component/Console/Descriptor/DescriptorInterface.php new file mode 100755 index 0000000..3929b6d --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Descriptor/DescriptorInterface.php @@ -0,0 +1,31 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Console\Descriptor; + +use Symfony\Component\Console\Output\OutputInterface; + +/** + * Descriptor interface. + * + * @author Jean-François Simon + */ +interface DescriptorInterface +{ + /** + * Describes an InputArgument instance. + * + * @param OutputInterface $output + * @param object $object + * @param array $options + */ + public function describe(OutputInterface $output, $object, array $options = array()); +} diff --git a/vendor/symfony/console/Symfony/Component/Console/Descriptor/JsonDescriptor.php b/vendor/symfony/console/Symfony/Component/Console/Descriptor/JsonDescriptor.php new file mode 100755 index 0000000..05adf0f --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Descriptor/JsonDescriptor.php @@ -0,0 +1,165 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Console\Descriptor; + +use Symfony\Component\Console\Application; +use Symfony\Component\Console\Command\Command; +use Symfony\Component\Console\Input\InputArgument; +use Symfony\Component\Console\Input\InputDefinition; +use Symfony\Component\Console\Input\InputOption; + +/** + * JSON descriptor. + * + * @author Jean-François Simon + */ +class JsonDescriptor extends Descriptor +{ + /** + * {@inheritdoc} + */ + protected function describeInputArgument(InputArgument $argument, array $options = array()) + { + $this->writeData($this->getInputArgumentData($argument), $options); + } + + /** + * {@inheritdoc} + */ + protected function describeInputOption(InputOption $option, array $options = array()) + { + $this->writeData($this->getInputOptionData($option), $options); + } + + /** + * {@inheritdoc} + */ + protected function describeInputDefinition(InputDefinition $definition, array $options = array()) + { + $this->writeData($this->getInputDefinitionData($definition), $options); + } + + /** + * {@inheritdoc} + */ + protected function describeCommand(Command $command, array $options = array()) + { + $this->writeData($this->getCommandData($command), $options); + } + + /** + * {@inheritdoc} + */ + protected function describeApplication(Application $application, array $options = array()) + { + $describedNamespace = isset($options['namespace']) ? $options['namespace'] : null; + $description = new ApplicationDescription($application, $describedNamespace); + $commands = array(); + + foreach ($description->getCommands() as $command) { + $commands[] = $this->getCommandData($command); + } + + $data = $describedNamespace + ? array('commands' => $commands, 'namespace' => $describedNamespace) + : array('commands' => $commands, 'namespaces' => array_values($description->getNamespaces())); + + $this->writeData($data, $options); + } + + /** + * Writes data as json. + * + * @param array $data + * @param array $options + * + * @return array|string + */ + private function writeData(array $data, array $options) + { + $this->write(json_encode($data, isset($options['json_encoding']) ? $options['json_encoding'] : 0)); + } + + /** + * @param InputArgument $argument + * + * @return array + */ + private function getInputArgumentData(InputArgument $argument) + { + return array( + 'name' => $argument->getName(), + 'is_required' => $argument->isRequired(), + 'is_array' => $argument->isArray(), + 'description' => $argument->getDescription(), + 'default' => $argument->getDefault(), + ); + } + + /** + * @param InputOption $option + * + * @return array + */ + private function getInputOptionData(InputOption $option) + { + return array( + 'name' => '--'.$option->getName(), + 'shortcut' => $option->getShortcut() ? '-'.implode('|-', explode('|', $option->getShortcut())) : '', + 'accept_value' => $option->acceptValue(), + 'is_value_required' => $option->isValueRequired(), + 'is_multiple' => $option->isArray(), + 'description' => $option->getDescription(), + 'default' => $option->getDefault(), + ); + } + + /** + * @param InputDefinition $definition + * + * @return array + */ + private function getInputDefinitionData(InputDefinition $definition) + { + $inputArguments = array(); + foreach ($definition->getArguments() as $name => $argument) { + $inputArguments[$name] = $this->getInputArgumentData($argument); + } + + $inputOptions = array(); + foreach ($definition->getOptions() as $name => $option) { + $inputOptions[$name] = $this->getInputOptionData($option); + } + + return array('arguments' => $inputArguments, 'options' => $inputOptions); + } + + /** + * @param Command $command + * + * @return array + */ + private function getCommandData(Command $command) + { + $command->getSynopsis(); + $command->mergeApplicationDefinition(false); + + return array( + 'name' => $command->getName(), + 'usage' => $command->getSynopsis(), + 'description' => $command->getDescription(), + 'help' => $command->getProcessedHelp(), + 'aliases' => $command->getAliases(), + 'definition' => $this->getInputDefinitionData($command->getNativeDefinition()), + ); + } +} diff --git a/vendor/symfony/console/Symfony/Component/Console/Descriptor/MarkdownDescriptor.php b/vendor/symfony/console/Symfony/Component/Console/Descriptor/MarkdownDescriptor.php new file mode 100755 index 0000000..7bc5808 --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Descriptor/MarkdownDescriptor.php @@ -0,0 +1,139 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Console\Descriptor; + +use Symfony\Component\Console\Application; +use Symfony\Component\Console\Command\Command; +use Symfony\Component\Console\Input\InputArgument; +use Symfony\Component\Console\Input\InputDefinition; +use Symfony\Component\Console\Input\InputOption; + +/** + * Markdown descriptor. + * + * @author Jean-François Simon + */ +class MarkdownDescriptor extends Descriptor +{ + /** + * {@inheritdoc} + */ + protected function describeInputArgument(InputArgument $argument, array $options = array()) + { + $this->write( + '**'.$argument->getName().':**'."\n\n" + .'* Name: '.($argument->getName() ?: '')."\n" + .'* Is required: '.($argument->isRequired() ? 'yes' : 'no')."\n" + .'* Is array: '.($argument->isArray() ? 'yes' : 'no')."\n" + .'* Description: '.($argument->getDescription() ?: '')."\n" + .'* Default: `'.str_replace("\n", '', var_export($argument->getDefault(), true)).'`' + ); + } + + /** + * {@inheritdoc} + */ + protected function describeInputOption(InputOption $option, array $options = array()) + { + $this->write( + '**'.$option->getName().':**'."\n\n" + .'* Name: `--'.$option->getName().'`'."\n" + .'* Shortcut: '.($option->getShortcut() ? '`-'.implode('|-', explode('|', $option->getShortcut())).'`' : '')."\n" + .'* Accept value: '.($option->acceptValue() ? 'yes' : 'no')."\n" + .'* Is value required: '.($option->isValueRequired() ? 'yes' : 'no')."\n" + .'* Is multiple: '.($option->isArray() ? 'yes' : 'no')."\n" + .'* Description: '.($option->getDescription() ?: '')."\n" + .'* Default: `'.str_replace("\n", '', var_export($option->getDefault(), true)).'`' + ); + } + + /** + * {@inheritdoc} + */ + protected function describeInputDefinition(InputDefinition $definition, array $options = array()) + { + if ($showArguments = count($definition->getArguments()) > 0) { + $this->write('### Arguments:'); + foreach ($definition->getArguments() as $argument) { + $this->write("\n\n"); + $this->write($this->describeInputArgument($argument)); + } + } + + if (count($definition->getOptions()) > 0) { + if ($showArguments) { + $this->write("\n\n"); + } + + $this->write('### Options:'); + foreach ($definition->getOptions() as $option) { + $this->write("\n\n"); + $this->write($this->describeInputOption($option)); + } + } + } + + /** + * {@inheritdoc} + */ + protected function describeCommand(Command $command, array $options = array()) + { + $command->getSynopsis(); + $command->mergeApplicationDefinition(false); + + $this->write( + $command->getName()."\n" + .str_repeat('-', strlen($command->getName()))."\n\n" + .'* Description: '.($command->getDescription() ?: '')."\n" + .'* Usage: `'.$command->getSynopsis().'`'."\n" + .'* Aliases: '.(count($command->getAliases()) ? '`'.implode('`, `', $command->getAliases()).'`' : '') + ); + + if ($help = $command->getProcessedHelp()) { + $this->write("\n\n"); + $this->write($help); + } + + if ($definition = $command->getNativeDefinition()) { + $this->write("\n\n"); + $this->describeInputDefinition($command->getNativeDefinition()); + } + } + + /** + * {@inheritdoc} + */ + protected function describeApplication(Application $application, array $options = array()) + { + $describedNamespace = isset($options['namespace']) ? $options['namespace'] : null; + $description = new ApplicationDescription($application, $describedNamespace); + + $this->write($application->getName()."\n".str_repeat('=', strlen($application->getName()))); + + foreach ($description->getNamespaces() as $namespace) { + if (ApplicationDescription::GLOBAL_NAMESPACE !== $namespace['id']) { + $this->write("\n\n"); + $this->write('**'.$namespace['id'].':**'); + } + + $this->write("\n\n"); + $this->write(implode("\n", array_map(function ($commandName) { + return '* '.$commandName; + } , $namespace['commands']))); + } + + foreach ($description->getCommands() as $command) { + $this->write("\n\n"); + $this->write($this->describeCommand($command)); + } + } +} diff --git a/vendor/symfony/console/Symfony/Component/Console/Descriptor/TextDescriptor.php b/vendor/symfony/console/Symfony/Component/Console/Descriptor/TextDescriptor.php new file mode 100755 index 0000000..f979fa7 --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Descriptor/TextDescriptor.php @@ -0,0 +1,229 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Console\Descriptor; + +use Symfony\Component\Console\Application; +use Symfony\Component\Console\Command\Command; +use Symfony\Component\Console\Input\InputArgument; +use Symfony\Component\Console\Input\InputDefinition; +use Symfony\Component\Console\Input\InputOption; + +/** + * Text descriptor. + * + * @author Jean-François Simon + */ +class TextDescriptor extends Descriptor +{ + /** + * {@inheritdoc} + */ + protected function describeInputArgument(InputArgument $argument, array $options = array()) + { + if (null !== $argument->getDefault() && (!is_array($argument->getDefault()) || count($argument->getDefault()))) { + $default = sprintf(' (default: %s)', $this->formatDefaultValue($argument->getDefault())); + } else { + $default = ''; + } + + $nameWidth = isset($options['name_width']) ? $options['name_width'] : strlen($argument->getName()); + + $this->writeText(sprintf(" %-${nameWidth}s %s%s", + $argument->getName(), + str_replace("\n", "\n".str_repeat(' ', $nameWidth + 2), $argument->getDescription()), + $default + ), $options); + } + + /** + * {@inheritdoc} + */ + protected function describeInputOption(InputOption $option, array $options = array()) + { + if ($option->acceptValue() && null !== $option->getDefault() && (!is_array($option->getDefault()) || count($option->getDefault()))) { + $default = sprintf(' (default: %s)', $this->formatDefaultValue($option->getDefault())); + } else { + $default = ''; + } + + $nameWidth = isset($options['name_width']) ? $options['name_width'] : strlen($option->getName()); + $nameWithShortcutWidth = $nameWidth - strlen($option->getName()) - 2; + + $this->writeText(sprintf(" %s %-${nameWithShortcutWidth}s%s%s%s", + '--'.$option->getName(), + $option->getShortcut() ? sprintf('(-%s) ', $option->getShortcut()) : '', + str_replace("\n", "\n".str_repeat(' ', $nameWidth + 2), $option->getDescription()), + $default, + $option->isArray() ? ' (multiple values allowed)' : '' + ), $options); + } + + /** + * {@inheritdoc} + */ + protected function describeInputDefinition(InputDefinition $definition, array $options = array()) + { + $nameWidth = 0; + foreach ($definition->getOptions() as $option) { + $nameLength = strlen($option->getName()) + 2; + if ($option->getShortcut()) { + $nameLength += strlen($option->getShortcut()) + 3; + } + $nameWidth = max($nameWidth, $nameLength); + } + foreach ($definition->getArguments() as $argument) { + $nameWidth = max($nameWidth, strlen($argument->getName())); + } + ++$nameWidth; + + if ($definition->getArguments()) { + $this->writeText('Arguments:', $options); + $this->writeText("\n"); + foreach ($definition->getArguments() as $argument) { + $this->describeInputArgument($argument, array_merge($options, array('name_width' => $nameWidth))); + $this->writeText("\n"); + } + } + + if ($definition->getArguments() && $definition->getOptions()) { + $this->writeText("\n"); + } + + if ($definition->getOptions()) { + $this->writeText('Options:', $options); + $this->writeText("\n"); + foreach ($definition->getOptions() as $option) { + $this->describeInputOption($option, array_merge($options, array('name_width' => $nameWidth))); + $this->writeText("\n"); + } + } + } + + /** + * {@inheritdoc} + */ + protected function describeCommand(Command $command, array $options = array()) + { + $command->getSynopsis(); + $command->mergeApplicationDefinition(false); + + $this->writeText('Usage:', $options); + $this->writeText("\n"); + $this->writeText(' '.$command->getSynopsis(), $options); + $this->writeText("\n"); + + if (count($command->getAliases()) > 0) { + $this->writeText("\n"); + $this->writeText('Aliases: '.implode(', ', $command->getAliases()).'', $options); + } + + if ($definition = $command->getNativeDefinition()) { + $this->writeText("\n"); + $this->describeInputDefinition($definition, $options); + } + + $this->writeText("\n"); + + if ($help = $command->getProcessedHelp()) { + $this->writeText('Help:', $options); + $this->writeText("\n"); + $this->writeText(' '.str_replace("\n", "\n ", $help), $options); + $this->writeText("\n"); + } + } + + /** + * {@inheritdoc} + */ + protected function describeApplication(Application $application, array $options = array()) + { + $describedNamespace = isset($options['namespace']) ? $options['namespace'] : null; + $description = new ApplicationDescription($application, $describedNamespace); + + if (isset($options['raw_text']) && $options['raw_text']) { + $width = $this->getColumnWidth($description->getCommands()); + + foreach ($description->getCommands() as $command) { + $this->writeText(sprintf("%-${width}s %s", $command->getName(), $command->getDescription()), $options); + $this->writeText("\n"); + } + } else { + $width = $this->getColumnWidth($description->getCommands()); + + $this->writeText($application->getHelp(), $options); + $this->writeText("\n\n"); + + if ($describedNamespace) { + $this->writeText(sprintf("Available commands for the \"%s\" namespace:", $describedNamespace), $options); + } else { + $this->writeText('Available commands:', $options); + } + + // add commands by namespace + foreach ($description->getNamespaces() as $namespace) { + if (!$describedNamespace && ApplicationDescription::GLOBAL_NAMESPACE !== $namespace['id']) { + $this->writeText("\n"); + $this->writeText(''.$namespace['id'].'', $options); + } + + foreach ($namespace['commands'] as $name) { + $this->writeText("\n"); + $this->writeText(sprintf(" %-${width}s %s", $name, $description->getCommand($name)->getDescription()), $options); + } + } + + $this->writeText("\n"); + } + } + + /** + * {@inheritdoc} + */ + private function writeText($content, array $options = array()) + { + $this->write( + isset($options['raw_text']) && $options['raw_text'] ? strip_tags($content) : $content, + isset($options['raw_output']) ? !$options['raw_output'] : true + ); + } + + /** + * Formats input option/argument default value. + * + * @param mixed $default + * + * @return string + */ + private function formatDefaultValue($default) + { + if (version_compare(PHP_VERSION, '5.4', '<')) { + return str_replace('\/', '/', json_encode($default)); + } + + return json_encode($default, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE); + } + + /** + * @param Command[] $commands + * + * @return int + */ + private function getColumnWidth(array $commands) + { + $width = 0; + foreach ($commands as $command) { + $width = strlen($command->getName()) > $width ? strlen($command->getName()) : $width; + } + + return $width + 2; + } +} diff --git a/vendor/symfony/console/Symfony/Component/Console/Descriptor/XmlDescriptor.php b/vendor/symfony/console/Symfony/Component/Console/Descriptor/XmlDescriptor.php new file mode 100755 index 0000000..ac1e25e --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Descriptor/XmlDescriptor.php @@ -0,0 +1,264 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Console\Descriptor; + +use Symfony\Component\Console\Application; +use Symfony\Component\Console\Command\Command; +use Symfony\Component\Console\Input\InputArgument; +use Symfony\Component\Console\Input\InputDefinition; +use Symfony\Component\Console\Input\InputOption; + +/** + * XML descriptor. + * + * @author Jean-François Simon + */ +class XmlDescriptor extends Descriptor +{ + /** + * @param InputDefinition $definition + * + * @return \DOMDocument + */ + public function getInputDefinitionDocument(InputDefinition $definition) + { + $dom = new \DOMDocument('1.0', 'UTF-8'); + $dom->appendChild($definitionXML = $dom->createElement('definition')); + + $definitionXML->appendChild($argumentsXML = $dom->createElement('arguments')); + foreach ($definition->getArguments() as $argument) { + $this->appendDocument($argumentsXML, $this->getInputArgumentDocument($argument)); + } + + $definitionXML->appendChild($optionsXML = $dom->createElement('options')); + foreach ($definition->getOptions() as $option) { + $this->appendDocument($optionsXML, $this->getInputOptionDocument($option)); + } + + return $dom; + } + + /** + * @param Command $command + * + * @return \DOMDocument + */ + public function getCommandDocument(Command $command) + { + $dom = new \DOMDocument('1.0', 'UTF-8'); + $dom->appendChild($commandXML = $dom->createElement('command')); + + $command->getSynopsis(); + $command->mergeApplicationDefinition(false); + + $commandXML->setAttribute('id', $command->getName()); + $commandXML->setAttribute('name', $command->getName()); + + $commandXML->appendChild($usageXML = $dom->createElement('usage')); + $usageXML->appendChild($dom->createTextNode(sprintf($command->getSynopsis(), ''))); + + $commandXML->appendChild($descriptionXML = $dom->createElement('description')); + $descriptionXML->appendChild($dom->createTextNode(str_replace("\n", "\n ", $command->getDescription()))); + + $commandXML->appendChild($helpXML = $dom->createElement('help')); + $helpXML->appendChild($dom->createTextNode(str_replace("\n", "\n ", $command->getProcessedHelp()))); + + $commandXML->appendChild($aliasesXML = $dom->createElement('aliases')); + foreach ($command->getAliases() as $alias) { + $aliasesXML->appendChild($aliasXML = $dom->createElement('alias')); + $aliasXML->appendChild($dom->createTextNode($alias)); + } + + $definitionXML = $this->getInputDefinitionDocument($command->getNativeDefinition()); + $this->appendDocument($commandXML, $definitionXML->getElementsByTagName('definition')->item(0)); + + return $dom; + } + + /** + * @param Application $application + * @param string|null $namespace + * + * @return \DOMDocument + */ + public function getApplicationDocument(Application $application, $namespace = null) + { + $dom = new \DOMDocument('1.0', 'UTF-8'); + $dom->appendChild($rootXml = $dom->createElement('symfony')); + + if ($application->getName() !== 'UNKNOWN') { + $rootXml->setAttribute('name', $application->getName()); + if ($application->getVersion() !== 'UNKNOWN') { + $rootXml->setAttribute('version', $application->getVersion()); + } + } + + $rootXml->appendChild($commandsXML = $dom->createElement('commands')); + + $description = new ApplicationDescription($application, $namespace); + + if ($namespace) { + $commandsXML->setAttribute('namespace', $namespace); + } + + foreach ($description->getCommands() as $command) { + $this->appendDocument($commandsXML, $this->getCommandDocument($command)); + } + + if (!$namespace) { + $rootXml->appendChild($namespacesXML = $dom->createElement('namespaces')); + + foreach ($description->getNamespaces() as $namespaceDescription) { + $namespacesXML->appendChild($namespaceArrayXML = $dom->createElement('namespace')); + $namespaceArrayXML->setAttribute('id', $namespaceDescription['id']); + + foreach ($namespaceDescription['commands'] as $name) { + $namespaceArrayXML->appendChild($commandXML = $dom->createElement('command')); + $commandXML->appendChild($dom->createTextNode($name)); + } + } + } + + return $dom; + } + + /** + * {@inheritdoc} + */ + protected function describeInputArgument(InputArgument $argument, array $options = array()) + { + $this->writeDocument($this->getInputArgumentDocument($argument)); + } + + /** + * {@inheritdoc} + */ + protected function describeInputOption(InputOption $option, array $options = array()) + { + $this->writeDocument($this->getInputOptionDocument($option)); + } + + /** + * {@inheritdoc} + */ + protected function describeInputDefinition(InputDefinition $definition, array $options = array()) + { + $this->writeDocument($this->getInputDefinitionDocument($definition)); + } + + /** + * {@inheritdoc} + */ + protected function describeCommand(Command $command, array $options = array()) + { + $this->writeDocument($this->getCommandDocument($command)); + } + + /** + * {@inheritdoc} + */ + protected function describeApplication(Application $application, array $options = array()) + { + $this->writeDocument($this->getApplicationDocument($application, isset($options['namespace']) ? $options['namespace'] : null)); + } + + /** + * Appends document children to parent node. + * + * @param \DOMNode $parentNode + * @param \DOMNode $importedParent + */ + private function appendDocument(\DOMNode $parentNode, \DOMNode $importedParent) + { + foreach ($importedParent->childNodes as $childNode) { + $parentNode->appendChild($parentNode->ownerDocument->importNode($childNode, true)); + } + } + + /** + * Writes DOM document. + * + * @param \DOMDocument $dom + * + * @return \DOMDocument|string + */ + private function writeDocument(\DOMDocument $dom) + { + $dom->formatOutput = true; + $this->write($dom->saveXML()); + } + + /** + * @param InputArgument $argument + * + * @return \DOMDocument + */ + private function getInputArgumentDocument(InputArgument $argument) + { + $dom = new \DOMDocument('1.0', 'UTF-8'); + + $dom->appendChild($objectXML = $dom->createElement('argument')); + $objectXML->setAttribute('name', $argument->getName()); + $objectXML->setAttribute('is_required', $argument->isRequired() ? 1 : 0); + $objectXML->setAttribute('is_array', $argument->isArray() ? 1 : 0); + $objectXML->appendChild($descriptionXML = $dom->createElement('description')); + $descriptionXML->appendChild($dom->createTextNode($argument->getDescription())); + + $objectXML->appendChild($defaultsXML = $dom->createElement('defaults')); + $defaults = is_array($argument->getDefault()) ? $argument->getDefault() : (is_bool($argument->getDefault()) ? array(var_export($argument->getDefault(), true)) : ($argument->getDefault() ? array($argument->getDefault()) : array())); + foreach ($defaults as $default) { + $defaultsXML->appendChild($defaultXML = $dom->createElement('default')); + $defaultXML->appendChild($dom->createTextNode($default)); + } + + return $dom; + } + + /** + * @param InputOption $option + * + * @return \DOMDocument + */ + private function getInputOptionDocument(InputOption $option) + { + $dom = new \DOMDocument('1.0', 'UTF-8'); + + $dom->appendChild($objectXML = $dom->createElement('option')); + $objectXML->setAttribute('name', '--'.$option->getName()); + $pos = strpos($option->getShortcut(), '|'); + if (false !== $pos) { + $objectXML->setAttribute('shortcut', '-'.substr($option->getShortcut(), 0, $pos)); + $objectXML->setAttribute('shortcuts', '-'.implode('|-', explode('|', $option->getShortcut()))); + } else { + $objectXML->setAttribute('shortcut', $option->getShortcut() ? '-'.$option->getShortcut() : ''); + } + $objectXML->setAttribute('accept_value', $option->acceptValue() ? 1 : 0); + $objectXML->setAttribute('is_value_required', $option->isValueRequired() ? 1 : 0); + $objectXML->setAttribute('is_multiple', $option->isArray() ? 1 : 0); + $objectXML->appendChild($descriptionXML = $dom->createElement('description')); + $descriptionXML->appendChild($dom->createTextNode($option->getDescription())); + + if ($option->acceptValue()) { + $defaults = is_array($option->getDefault()) ? $option->getDefault() : (is_bool($option->getDefault()) ? array(var_export($option->getDefault(), true)) : ($option->getDefault() ? array($option->getDefault()) : array())); + $objectXML->appendChild($defaultsXML = $dom->createElement('defaults')); + + if (!empty($defaults)) { + foreach ($defaults as $default) { + $defaultsXML->appendChild($defaultXML = $dom->createElement('default')); + $defaultXML->appendChild($dom->createTextNode($default)); + } + } + } + + return $dom; + } +} diff --git a/vendor/symfony/console/Symfony/Component/Console/Event/ConsoleCommandEvent.php b/vendor/symfony/console/Symfony/Component/Console/Event/ConsoleCommandEvent.php new file mode 100755 index 0000000..47ac68b --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Event/ConsoleCommandEvent.php @@ -0,0 +1,21 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Console\Event; + +/** + * Allows to do things before the command is executed. + * + * @author Fabien Potencier + */ +class ConsoleCommandEvent extends ConsoleEvent +{ +} diff --git a/vendor/symfony/console/Symfony/Component/Console/Event/ConsoleEvent.php b/vendor/symfony/console/Symfony/Component/Console/Event/ConsoleEvent.php new file mode 100755 index 0000000..ab620c4 --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Event/ConsoleEvent.php @@ -0,0 +1,67 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Console\Event; + +use Symfony\Component\Console\Command\Command; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Output\OutputInterface; +use Symfony\Component\EventDispatcher\Event; + +/** + * Allows to inspect input and output of a command. + * + * @author Francesco Levorato + */ +class ConsoleEvent extends Event +{ + protected $command; + + private $input; + private $output; + + public function __construct(Command $command, InputInterface $input, OutputInterface $output) + { + $this->command = $command; + $this->input = $input; + $this->output = $output; + } + + /** + * Gets the command that is executed. + * + * @return Command A Command instance + */ + public function getCommand() + { + return $this->command; + } + + /** + * Gets the input instance. + * + * @return InputInterface An InputInterface instance + */ + public function getInput() + { + return $this->input; + } + + /** + * Gets the output instance. + * + * @return OutputInterface An OutputInterface instance + */ + public function getOutput() + { + return $this->output; + } +} diff --git a/vendor/symfony/console/Symfony/Component/Console/Event/ConsoleExceptionEvent.php b/vendor/symfony/console/Symfony/Component/Console/Event/ConsoleExceptionEvent.php new file mode 100755 index 0000000..7075903 --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Event/ConsoleExceptionEvent.php @@ -0,0 +1,67 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Console\Event; + +use Symfony\Component\Console\Command\Command; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Output\OutputInterface; + +/** + * Allows to handle exception thrown in a command. + * + * @author Fabien Potencier + */ +class ConsoleExceptionEvent extends ConsoleEvent +{ + private $exception; + private $exitCode; + + public function __construct(Command $command, InputInterface $input, OutputInterface $output, \Exception $exception, $exitCode) + { + parent::__construct($command, $input, $output); + + $this->setException($exception); + $this->exitCode = (int) $exitCode; + } + + /** + * Returns the thrown exception. + * + * @return \Exception The thrown exception + */ + public function getException() + { + return $this->exception; + } + + /** + * Replaces the thrown exception. + * + * This exception will be thrown if no response is set in the event. + * + * @param \Exception $exception The thrown exception + */ + public function setException(\Exception $exception) + { + $this->exception = $exception; + } + + /** + * Gets the exit code. + * + * @return int The command exit code + */ + public function getExitCode() + { + return $this->exitCode; + } +} diff --git a/vendor/symfony/console/Symfony/Component/Console/Event/ConsoleTerminateEvent.php b/vendor/symfony/console/Symfony/Component/Console/Event/ConsoleTerminateEvent.php new file mode 100755 index 0000000..ea3318d --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Event/ConsoleTerminateEvent.php @@ -0,0 +1,58 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Console\Event; + +use Symfony\Component\Console\Command\Command; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Output\OutputInterface; + +/** + * Allows to manipulate the exit code of a command after its execution. + * + * @author Francesco Levorato + */ +class ConsoleTerminateEvent extends ConsoleEvent +{ + /** + * The exit code of the command. + * + * @var int + */ + private $exitCode; + + public function __construct(Command $command, InputInterface $input, OutputInterface $output, $exitCode) + { + parent::__construct($command, $input, $output); + + $this->setExitCode($exitCode); + } + + /** + * Sets the exit code. + * + * @param int $exitCode The command exit code + */ + public function setExitCode($exitCode) + { + $this->exitCode = (int) $exitCode; + } + + /** + * Gets the exit code. + * + * @return int The command exit code + */ + public function getExitCode() + { + return $this->exitCode; + } +} diff --git a/vendor/symfony/console/Symfony/Component/Console/Formatter/OutputFormatter.php b/vendor/symfony/console/Symfony/Component/Console/Formatter/OutputFormatter.php new file mode 100755 index 0000000..ca5f287 --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Formatter/OutputFormatter.php @@ -0,0 +1,236 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Console\Formatter; + +/** + * Formatter class for console output. + * + * @author Konstantin Kudryashov + * + * @api + */ +class OutputFormatter implements OutputFormatterInterface +{ + private $decorated; + private $styles = array(); + private $styleStack; + + /** + * Escapes "<" special char in given text. + * + * @param string $text Text to escape + * + * @return string Escaped text + */ + public static function escape($text) + { + return preg_replace('/([^\\\\]?) FormatterStyle" instances + * + * @api + */ + public function __construct($decorated = false, array $styles = array()) + { + $this->decorated = (bool) $decorated; + + $this->setStyle('error', new OutputFormatterStyle('white', 'red')); + $this->setStyle('info', new OutputFormatterStyle('green')); + $this->setStyle('comment', new OutputFormatterStyle('yellow')); + $this->setStyle('question', new OutputFormatterStyle('black', 'cyan')); + + foreach ($styles as $name => $style) { + $this->setStyle($name, $style); + } + + $this->styleStack = new OutputFormatterStyleStack(); + } + + /** + * Sets the decorated flag. + * + * @param bool $decorated Whether to decorate the messages or not + * + * @api + */ + public function setDecorated($decorated) + { + $this->decorated = (bool) $decorated; + } + + /** + * Gets the decorated flag. + * + * @return bool true if the output will decorate messages, false otherwise + * + * @api + */ + public function isDecorated() + { + return $this->decorated; + } + + /** + * Sets a new style. + * + * @param string $name The style name + * @param OutputFormatterStyleInterface $style The style instance + * + * @api + */ + public function setStyle($name, OutputFormatterStyleInterface $style) + { + $this->styles[strtolower($name)] = $style; + } + + /** + * Checks if output formatter has style with specified name. + * + * @param string $name + * + * @return bool + * + * @api + */ + public function hasStyle($name) + { + return isset($this->styles[strtolower($name)]); + } + + /** + * Gets style options from style with specified name. + * + * @param string $name + * + * @return OutputFormatterStyleInterface + * + * @throws \InvalidArgumentException When style isn't defined + * + * @api + */ + public function getStyle($name) + { + if (!$this->hasStyle($name)) { + throw new \InvalidArgumentException(sprintf('Undefined style: %s', $name)); + } + + return $this->styles[strtolower($name)]; + } + + /** + * Formats a message according to the given styles. + * + * @param string $message The message to style + * + * @return string The styled message + * + * @api + */ + public function format($message) + { + $offset = 0; + $output = ''; + $tagRegex = '[a-z][a-z0-9_=;-]*'; + preg_match_all("#<(($tagRegex) | /($tagRegex)?)>#isx", $message, $matches, PREG_OFFSET_CAPTURE); + foreach ($matches[0] as $i => $match) { + $pos = $match[1]; + $text = $match[0]; + + // add the text up to the next tag + $output .= $this->applyCurrentStyle(substr($message, $offset, $pos - $offset)); + $offset = $pos + strlen($text); + + // opening tag? + if ($open = '/' != $text[1]) { + $tag = $matches[1][$i][0]; + } else { + $tag = isset($matches[3][$i][0]) ? $matches[3][$i][0] : ''; + } + + if (!$open && !$tag) { + // + $this->styleStack->pop(); + } elseif ($pos && '\\' == $message[$pos - 1]) { + // escaped tag + $output .= $this->applyCurrentStyle($text); + } elseif (false === $style = $this->createStyleFromString(strtolower($tag))) { + $output .= $this->applyCurrentStyle($text); + } elseif ($open) { + $this->styleStack->push($style); + } else { + $this->styleStack->pop($style); + } + } + + $output .= $this->applyCurrentStyle(substr($message, $offset)); + + return str_replace('\\<', '<', $output); + } + + /** + * @return OutputFormatterStyleStack + */ + public function getStyleStack() + { + return $this->styleStack; + } + + /** + * Tries to create new style instance from string. + * + * @param string $string + * + * @return OutputFormatterStyle|bool false if string is not format string + */ + private function createStyleFromString($string) + { + if (isset($this->styles[$string])) { + return $this->styles[$string]; + } + + if (!preg_match_all('/([^=]+)=([^;]+)(;|$)/', strtolower($string), $matches, PREG_SET_ORDER)) { + return false; + } + + $style = new OutputFormatterStyle(); + foreach ($matches as $match) { + array_shift($match); + + if ('fg' == $match[0]) { + $style->setForeground($match[1]); + } elseif ('bg' == $match[0]) { + $style->setBackground($match[1]); + } else { + $style->setOption($match[1]); + } + } + + return $style; + } + + /** + * Applies current style from stack to text, if must be applied. + * + * @param string $text Input text + * + * @return string Styled text + */ + private function applyCurrentStyle($text) + { + return $this->isDecorated() && strlen($text) > 0 ? $this->styleStack->getCurrent()->apply($text) : $text; + } +} diff --git a/vendor/symfony/console/Symfony/Component/Console/Formatter/OutputFormatterInterface.php b/vendor/symfony/console/Symfony/Component/Console/Formatter/OutputFormatterInterface.php new file mode 100755 index 0000000..151adcd --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Formatter/OutputFormatterInterface.php @@ -0,0 +1,83 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Console\Formatter; + +/** + * Formatter interface for console output. + * + * @author Konstantin Kudryashov + * + * @api + */ +interface OutputFormatterInterface +{ + /** + * Sets the decorated flag. + * + * @param bool $decorated Whether to decorate the messages or not + * + * @api + */ + public function setDecorated($decorated); + + /** + * Gets the decorated flag. + * + * @return bool true if the output will decorate messages, false otherwise + * + * @api + */ + public function isDecorated(); + + /** + * Sets a new style. + * + * @param string $name The style name + * @param OutputFormatterStyleInterface $style The style instance + * + * @api + */ + public function setStyle($name, OutputFormatterStyleInterface $style); + + /** + * Checks if output formatter has style with specified name. + * + * @param string $name + * + * @return bool + * + * @api + */ + public function hasStyle($name); + + /** + * Gets style options from style with specified name. + * + * @param string $name + * + * @return OutputFormatterStyleInterface + * + * @api + */ + public function getStyle($name); + + /** + * Formats a message according to the given styles. + * + * @param string $message The message to style + * + * @return string The styled message + * + * @api + */ + public function format($message); +} diff --git a/vendor/symfony/console/Symfony/Component/Console/Formatter/OutputFormatterStyle.php b/vendor/symfony/console/Symfony/Component/Console/Formatter/OutputFormatterStyle.php new file mode 100755 index 0000000..f0bbd38 --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Formatter/OutputFormatterStyle.php @@ -0,0 +1,222 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Console\Formatter; + +/** + * Formatter style class for defining styles. + * + * @author Konstantin Kudryashov + * + * @api + */ +class OutputFormatterStyle implements OutputFormatterStyleInterface +{ + private static $availableForegroundColors = array( + 'black' => 30, + 'red' => 31, + 'green' => 32, + 'yellow' => 33, + 'blue' => 34, + 'magenta' => 35, + 'cyan' => 36, + 'white' => 37 + ); + private static $availableBackgroundColors = array( + 'black' => 40, + 'red' => 41, + 'green' => 42, + 'yellow' => 43, + 'blue' => 44, + 'magenta' => 45, + 'cyan' => 46, + 'white' => 47 + ); + private static $availableOptions = array( + 'bold' => 1, + 'underscore' => 4, + 'blink' => 5, + 'reverse' => 7, + 'conceal' => 8 + ); + + private $foreground; + private $background; + private $options = array(); + + /** + * Initializes output formatter style. + * + * @param string|null $foreground The style foreground color name + * @param string|null $background The style background color name + * @param array $options The style options + * + * @api + */ + public function __construct($foreground = null, $background = null, array $options = array()) + { + if (null !== $foreground) { + $this->setForeground($foreground); + } + if (null !== $background) { + $this->setBackground($background); + } + if (count($options)) { + $this->setOptions($options); + } + } + + /** + * Sets style foreground color. + * + * @param string|null $color The color name + * + * @throws \InvalidArgumentException When the color name isn't defined + * + * @api + */ + public function setForeground($color = null) + { + if (null === $color) { + $this->foreground = null; + + return; + } + + if (!isset(static::$availableForegroundColors[$color])) { + throw new \InvalidArgumentException(sprintf( + 'Invalid foreground color specified: "%s". Expected one of (%s)', + $color, + implode(', ', array_keys(static::$availableForegroundColors)) + )); + } + + $this->foreground = static::$availableForegroundColors[$color]; + } + + /** + * Sets style background color. + * + * @param string|null $color The color name + * + * @throws \InvalidArgumentException When the color name isn't defined + * + * @api + */ + public function setBackground($color = null) + { + if (null === $color) { + $this->background = null; + + return; + } + + if (!isset(static::$availableBackgroundColors[$color])) { + throw new \InvalidArgumentException(sprintf( + 'Invalid background color specified: "%s". Expected one of (%s)', + $color, + implode(', ', array_keys(static::$availableBackgroundColors)) + )); + } + + $this->background = static::$availableBackgroundColors[$color]; + } + + /** + * Sets some specific style option. + * + * @param string $option The option name + * + * @throws \InvalidArgumentException When the option name isn't defined + * + * @api + */ + public function setOption($option) + { + if (!isset(static::$availableOptions[$option])) { + throw new \InvalidArgumentException(sprintf( + 'Invalid option specified: "%s". Expected one of (%s)', + $option, + implode(', ', array_keys(static::$availableOptions)) + )); + } + + if (false === array_search(static::$availableOptions[$option], $this->options)) { + $this->options[] = static::$availableOptions[$option]; + } + } + + /** + * Unsets some specific style option. + * + * @param string $option The option name + * + * @throws \InvalidArgumentException When the option name isn't defined + * + */ + public function unsetOption($option) + { + if (!isset(static::$availableOptions[$option])) { + throw new \InvalidArgumentException(sprintf( + 'Invalid option specified: "%s". Expected one of (%s)', + $option, + implode(', ', array_keys(static::$availableOptions)) + )); + } + + $pos = array_search(static::$availableOptions[$option], $this->options); + if (false !== $pos) { + unset($this->options[$pos]); + } + } + + /** + * Sets multiple style options at once. + * + * @param array $options + */ + public function setOptions(array $options) + { + $this->options = array(); + + foreach ($options as $option) { + $this->setOption($option); + } + } + + /** + * Applies the style to a given text. + * + * @param string $text The text to style + * + * @return string + */ + public function apply($text) + { + $codes = array(); + + if (null !== $this->foreground) { + $codes[] = $this->foreground; + } + if (null !== $this->background) { + $codes[] = $this->background; + } + if (count($this->options)) { + $codes = array_merge($codes, $this->options); + } + + if (0 === count($codes)) { + return $text; + } + + return sprintf("\033[%sm%s\033[0m", implode(';', $codes), $text); + } +} diff --git a/vendor/symfony/console/Symfony/Component/Console/Formatter/OutputFormatterStyleInterface.php b/vendor/symfony/console/Symfony/Component/Console/Formatter/OutputFormatterStyleInterface.php new file mode 100755 index 0000000..e8642b3 --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Formatter/OutputFormatterStyleInterface.php @@ -0,0 +1,72 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Console\Formatter; + +/** + * Formatter style interface for defining styles. + * + * @author Konstantin Kudryashov + * + * @api + */ +interface OutputFormatterStyleInterface +{ + /** + * Sets style foreground color. + * + * @param string $color The color name + * + * @api + */ + public function setForeground($color = null); + + /** + * Sets style background color. + * + * @param string $color The color name + * + * @api + */ + public function setBackground($color = null); + + /** + * Sets some specific style option. + * + * @param string $option The option name + * + * @api + */ + public function setOption($option); + + /** + * Unsets some specific style option. + * + * @param string $option The option name + */ + public function unsetOption($option); + + /** + * Sets multiple style options at once. + * + * @param array $options + */ + public function setOptions(array $options); + + /** + * Applies the style to a given text. + * + * @param string $text The text to style + * + * @return string + */ + public function apply($text); +} diff --git a/vendor/symfony/console/Symfony/Component/Console/Formatter/OutputFormatterStyleStack.php b/vendor/symfony/console/Symfony/Component/Console/Formatter/OutputFormatterStyleStack.php new file mode 100755 index 0000000..e63912c --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Formatter/OutputFormatterStyleStack.php @@ -0,0 +1,121 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Console\Formatter; + +/** + * @author Jean-François Simon + */ +class OutputFormatterStyleStack +{ + /** + * @var OutputFormatterStyleInterface[] + */ + private $styles; + + /** + * @var OutputFormatterStyleInterface + */ + private $emptyStyle; + + /** + * Constructor. + * + * @param OutputFormatterStyleInterface|null $emptyStyle + */ + public function __construct(OutputFormatterStyleInterface $emptyStyle = null) + { + $this->emptyStyle = $emptyStyle ?: new OutputFormatterStyle(); + $this->reset(); + } + + /** + * Resets stack (ie. empty internal arrays). + */ + public function reset() + { + $this->styles = array(); + } + + /** + * Pushes a style in the stack. + * + * @param OutputFormatterStyleInterface $style + */ + public function push(OutputFormatterStyleInterface $style) + { + $this->styles[] = $style; + } + + /** + * Pops a style from the stack. + * + * @param OutputFormatterStyleInterface|null $style + * + * @return OutputFormatterStyleInterface + * + * @throws \InvalidArgumentException When style tags incorrectly nested + */ + public function pop(OutputFormatterStyleInterface $style = null) + { + if (empty($this->styles)) { + return $this->emptyStyle; + } + + if (null === $style) { + return array_pop($this->styles); + } + + foreach (array_reverse($this->styles, true) as $index => $stackedStyle) { + if ($style->apply('') === $stackedStyle->apply('')) { + $this->styles = array_slice($this->styles, 0, $index); + + return $stackedStyle; + } + } + + throw new \InvalidArgumentException('Incorrectly nested style tag found.'); + } + + /** + * Computes current style with stacks top codes. + * + * @return OutputFormatterStyle + */ + public function getCurrent() + { + if (empty($this->styles)) { + return $this->emptyStyle; + } + + return $this->styles[count($this->styles)-1]; + } + + /** + * @param OutputFormatterStyleInterface $emptyStyle + * + * @return OutputFormatterStyleStack + */ + public function setEmptyStyle(OutputFormatterStyleInterface $emptyStyle) + { + $this->emptyStyle = $emptyStyle; + + return $this; + } + + /** + * @return OutputFormatterStyleInterface + */ + public function getEmptyStyle() + { + return $this->emptyStyle; + } +} diff --git a/vendor/symfony/console/Symfony/Component/Console/Helper/DescriptorHelper.php b/vendor/symfony/console/Symfony/Component/Console/Helper/DescriptorHelper.php new file mode 100755 index 0000000..932dd0f --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Helper/DescriptorHelper.php @@ -0,0 +1,96 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Console\Helper; + +use Symfony\Component\Console\Descriptor\DescriptorInterface; +use Symfony\Component\Console\Descriptor\JsonDescriptor; +use Symfony\Component\Console\Descriptor\MarkdownDescriptor; +use Symfony\Component\Console\Descriptor\TextDescriptor; +use Symfony\Component\Console\Descriptor\XmlDescriptor; +use Symfony\Component\Console\Output\OutputInterface; + +/** + * This class adds helper method to describe objects in various formats. + * + * @author Jean-François Simon + */ +class DescriptorHelper extends Helper +{ + /** + * @var DescriptorInterface[] + */ + private $descriptors = array(); + + /** + * Constructor. + */ + public function __construct() + { + $this + ->register('txt', new TextDescriptor()) + ->register('xml', new XmlDescriptor()) + ->register('json', new JsonDescriptor()) + ->register('md', new MarkdownDescriptor()) + ; + } + + /** + * Describes an object if supported. + * + * Available options are: + * * format: string, the output format name + * * raw_text: boolean, sets output type as raw + * + * @param OutputInterface $output + * @param object $object + * @param array $options + * + * @throws \InvalidArgumentException + */ + public function describe(OutputInterface $output, $object, array $options = array()) + { + $options = array_merge(array( + 'raw_text' => false, + 'format' => 'txt', + ), $options); + + if (!isset($this->descriptors[$options['format']])) { + throw new \InvalidArgumentException(sprintf('Unsupported format "%s".', $options['format'])); + } + + $descriptor = $this->descriptors[$options['format']]; + $descriptor->describe($output, $object, $options); + } + + /** + * Registers a descriptor. + * + * @param string $format + * @param DescriptorInterface $descriptor + * + * @return DescriptorHelper + */ + public function register($format, DescriptorInterface $descriptor) + { + $this->descriptors[$format] = $descriptor; + + return $this; + } + + /** + * {@inheritdoc} + */ + public function getName() + { + return 'descriptor'; + } +} diff --git a/vendor/symfony/console/Symfony/Component/Console/Helper/DialogHelper.php b/vendor/symfony/console/Symfony/Component/Console/Helper/DialogHelper.php new file mode 100755 index 0000000..84fe0ad --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Helper/DialogHelper.php @@ -0,0 +1,473 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Console\Helper; + +use Symfony\Component\Console\Output\OutputInterface; +use Symfony\Component\Console\Formatter\OutputFormatterStyle; + +/** + * The Dialog class provides helpers to interact with the user. + * + * @author Fabien Potencier + */ +class DialogHelper extends InputAwareHelper +{ + private $inputStream; + private static $shell; + private static $stty; + + /** + * Asks the user to select a value. + * + * @param OutputInterface $output An Output instance + * @param string|array $question The question to ask + * @param array $choices List of choices to pick from + * @param bool|string $default The default answer if the user enters nothing + * @param bool|int $attempts Max number of times to ask before giving up (false by default, which means infinite) + * @param string $errorMessage Message which will be shown if invalid value from choice list would be picked + * @param bool $multiselect Select more than one value separated by comma + * + * @return int|string|array The selected value or values (the key of the choices array) + * + * @throws \InvalidArgumentException + */ + public function select(OutputInterface $output, $question, $choices, $default = null, $attempts = false, $errorMessage = 'Value "%s" is invalid', $multiselect = false) + { + $width = max(array_map('strlen', array_keys($choices))); + + $messages = (array) $question; + foreach ($choices as $key => $value) { + $messages[] = sprintf(" [%-${width}s] %s", $key, $value); + } + + $output->writeln($messages); + + $result = $this->askAndValidate($output, '> ', function ($picked) use ($choices, $errorMessage, $multiselect) { + // Collapse all spaces. + $selectedChoices = str_replace(" ", "", $picked); + + if ($multiselect) { + // Check for a separated comma values + if (!preg_match('/^[a-zA-Z0-9_-]+(?:,[a-zA-Z0-9_-]+)*$/', $selectedChoices, $matches)) { + throw new \InvalidArgumentException(sprintf($errorMessage, $picked)); + } + $selectedChoices = explode(",", $selectedChoices); + } else { + $selectedChoices = array($picked); + } + + $multiselectChoices = array(); + + foreach ($selectedChoices as $value) { + if (empty($choices[$value])) { + throw new \InvalidArgumentException(sprintf($errorMessage, $value)); + } + array_push($multiselectChoices, $value); + } + + if ($multiselect) { + return $multiselectChoices; + } + + return $picked; + }, $attempts, $default); + + return $result; + } + + /** + * Asks a question to the user. + * + * @param OutputInterface $output An Output instance + * @param string|array $question The question to ask + * @param string $default The default answer if none is given by the user + * @param array $autocomplete List of values to autocomplete + * + * @return string The user answer + * + * @throws \RuntimeException If there is no data to read in the input stream + */ + public function ask(OutputInterface $output, $question, $default = null, array $autocomplete = null) + { + if ($this->input && !$this->input->isInteractive()) { + return $default; + } + + $output->write($question); + + $inputStream = $this->inputStream ?: STDIN; + + if (null === $autocomplete || !$this->hasSttyAvailable()) { + $ret = fgets($inputStream, 4096); + if (false === $ret) { + throw new \RuntimeException('Aborted'); + } + $ret = trim($ret); + } else { + $ret = ''; + + $i = 0; + $ofs = -1; + $matches = $autocomplete; + $numMatches = count($matches); + + $sttyMode = shell_exec('stty -g'); + + // Disable icanon (so we can fread each keypress) and echo (we'll do echoing here instead) + shell_exec('stty -icanon -echo'); + + // Add highlighted text style + $output->getFormatter()->setStyle('hl', new OutputFormatterStyle('black', 'white')); + + // Read a keypress + while (!feof($inputStream)) { + $c = fread($inputStream, 1); + + // Backspace Character + if ("\177" === $c) { + if (0 === $numMatches && 0 !== $i) { + $i--; + // Move cursor backwards + $output->write("\033[1D"); + } + + if ($i === 0) { + $ofs = -1; + $matches = $autocomplete; + $numMatches = count($matches); + } else { + $numMatches = 0; + } + + // Pop the last character off the end of our string + $ret = substr($ret, 0, $i); + } elseif ("\033" === $c) { // Did we read an escape sequence? + $c .= fread($inputStream, 2); + + // A = Up Arrow. B = Down Arrow + if ('A' === $c[2] || 'B' === $c[2]) { + if ('A' === $c[2] && -1 === $ofs) { + $ofs = 0; + } + + if (0 === $numMatches) { + continue; + } + + $ofs += ('A' === $c[2]) ? -1 : 1; + $ofs = ($numMatches + $ofs) % $numMatches; + } + } elseif (ord($c) < 32) { + if ("\t" === $c || "\n" === $c) { + if ($numMatches > 0 && -1 !== $ofs) { + $ret = $matches[$ofs]; + // Echo out remaining chars for current match + $output->write(substr($ret, $i)); + $i = strlen($ret); + } + + if ("\n" === $c) { + $output->write($c); + break; + } + + $numMatches = 0; + } + + continue; + } else { + $output->write($c); + $ret .= $c; + $i++; + + $numMatches = 0; + $ofs = 0; + + foreach ($autocomplete as $value) { + // If typed characters match the beginning chunk of value (e.g. [AcmeDe]moBundle) + if (0 === strpos($value, $ret) && $i !== strlen($value)) { + $matches[$numMatches++] = $value; + } + } + } + + // Erase characters from cursor to end of line + $output->write("\033[K"); + + if ($numMatches > 0 && -1 !== $ofs) { + // Save cursor position + $output->write("\0337"); + // Write highlighted text + $output->write(''.substr($matches[$ofs], $i).''); + // Restore cursor position + $output->write("\0338"); + } + } + + // Reset stty so it behaves normally again + shell_exec(sprintf('stty %s', $sttyMode)); + } + + return strlen($ret) > 0 ? $ret : $default; + } + + /** + * Asks a confirmation to the user. + * + * The question will be asked until the user answers by nothing, yes, or no. + * + * @param OutputInterface $output An Output instance + * @param string|array $question The question to ask + * @param bool $default The default answer if the user enters nothing + * + * @return bool true if the user has confirmed, false otherwise + */ + public function askConfirmation(OutputInterface $output, $question, $default = true) + { + $answer = 'z'; + while ($answer && !in_array(strtolower($answer[0]), array('y', 'n'))) { + $answer = $this->ask($output, $question); + } + + if (false === $default) { + return $answer && 'y' == strtolower($answer[0]); + } + + return !$answer || 'y' == strtolower($answer[0]); + } + + /** + * Asks a question to the user, the response is hidden + * + * @param OutputInterface $output An Output instance + * @param string|array $question The question + * @param bool $fallback In case the response can not be hidden, whether to fallback on non-hidden question or not + * + * @return string The answer + * + * @throws \RuntimeException In case the fallback is deactivated and the response can not be hidden + */ + public function askHiddenResponse(OutputInterface $output, $question, $fallback = true) + { + if (defined('PHP_WINDOWS_VERSION_BUILD')) { + $exe = __DIR__.'/../Resources/bin/hiddeninput.exe'; + + // handle code running from a phar + if ('phar:' === substr(__FILE__, 0, 5)) { + $tmpExe = sys_get_temp_dir().'/hiddeninput.exe'; + copy($exe, $tmpExe); + $exe = $tmpExe; + } + + $output->write($question); + $value = rtrim(shell_exec($exe)); + $output->writeln(''); + + if (isset($tmpExe)) { + unlink($tmpExe); + } + + return $value; + } + + if ($this->hasSttyAvailable()) { + $output->write($question); + + $sttyMode = shell_exec('stty -g'); + + shell_exec('stty -echo'); + $value = fgets($this->inputStream ?: STDIN, 4096); + shell_exec(sprintf('stty %s', $sttyMode)); + + if (false === $value) { + throw new \RuntimeException('Aborted'); + } + + $value = trim($value); + $output->writeln(''); + + return $value; + } + + if (false !== $shell = $this->getShell()) { + $output->write($question); + $readCmd = $shell === 'csh' ? 'set mypassword = $<' : 'read -r mypassword'; + $command = sprintf("/usr/bin/env %s -c 'stty -echo; %s; stty echo; echo \$mypassword'", $shell, $readCmd); + $value = rtrim(shell_exec($command)); + $output->writeln(''); + + return $value; + } + + if ($fallback) { + return $this->ask($output, $question); + } + + throw new \RuntimeException('Unable to hide the response'); + } + + /** + * Asks for a value and validates the response. + * + * The validator receives the data to validate. It must return the + * validated data when the data is valid and throw an exception + * otherwise. + * + * @param OutputInterface $output An Output instance + * @param string|array $question The question to ask + * @param callable $validator A PHP callback + * @param int $attempts Max number of times to ask before giving up (false by default, which means infinite) + * @param string $default The default answer if none is given by the user + * @param array $autocomplete List of values to autocomplete + * + * @return mixed + * + * @throws \Exception When any of the validators return an error + */ + public function askAndValidate(OutputInterface $output, $question, $validator, $attempts = false, $default = null, array $autocomplete = null) + { + $that = $this; + + $interviewer = function () use ($output, $question, $default, $autocomplete, $that) { + return $that->ask($output, $question, $default, $autocomplete); + }; + + return $this->validateAttempts($interviewer, $output, $validator, $attempts); + } + + /** + * Asks for a value, hide and validates the response. + * + * The validator receives the data to validate. It must return the + * validated data when the data is valid and throw an exception + * otherwise. + * + * @param OutputInterface $output An Output instance + * @param string|array $question The question to ask + * @param callable $validator A PHP callback + * @param int $attempts Max number of times to ask before giving up (false by default, which means infinite) + * @param bool $fallback In case the response can not be hidden, whether to fallback on non-hidden question or not + * + * @return string The response + * + * @throws \Exception When any of the validators return an error + * @throws \RuntimeException In case the fallback is deactivated and the response can not be hidden + * + */ + public function askHiddenResponseAndValidate(OutputInterface $output, $question, $validator, $attempts = false, $fallback = true) + { + $that = $this; + + $interviewer = function () use ($output, $question, $fallback, $that) { + return $that->askHiddenResponse($output, $question, $fallback); + }; + + return $this->validateAttempts($interviewer, $output, $validator, $attempts); + } + + /** + * Sets the input stream to read from when interacting with the user. + * + * This is mainly useful for testing purpose. + * + * @param resource $stream The input stream + */ + public function setInputStream($stream) + { + $this->inputStream = $stream; + } + + /** + * Returns the helper's input stream + * + * @return string + */ + public function getInputStream() + { + return $this->inputStream; + } + + /** + * {@inheritdoc} + */ + public function getName() + { + return 'dialog'; + } + + /** + * Return a valid Unix shell + * + * @return string|bool The valid shell name, false in case no valid shell is found + */ + private function getShell() + { + if (null !== self::$shell) { + return self::$shell; + } + + self::$shell = false; + + if (file_exists('/usr/bin/env')) { + // handle other OSs with bash/zsh/ksh/csh if available to hide the answer + $test = "/usr/bin/env %s -c 'echo OK' 2> /dev/null"; + foreach (array('bash', 'zsh', 'ksh', 'csh') as $sh) { + if ('OK' === rtrim(shell_exec(sprintf($test, $sh)))) { + self::$shell = $sh; + break; + } + } + } + + return self::$shell; + } + + private function hasSttyAvailable() + { + if (null !== self::$stty) { + return self::$stty; + } + + exec('stty 2>&1', $output, $exitcode); + + return self::$stty = $exitcode === 0; + } + + /** + * Validate an attempt + * + * @param callable $interviewer A callable that will ask for a question and return the result + * @param OutputInterface $output An Output instance + * @param callable $validator A PHP callback + * @param int $attempts Max number of times to ask before giving up ; false will ask infinitely + * + * @return string The validated response + * + * @throws \Exception In case the max number of attempts has been reached and no valid response has been given + */ + private function validateAttempts($interviewer, OutputInterface $output, $validator, $attempts) + { + $error = null; + while (false === $attempts || $attempts--) { + if (null !== $error) { + $output->writeln($this->getHelperSet()->get('formatter')->formatBlock($error->getMessage(), 'error')); + } + + try { + return call_user_func($validator, $interviewer()); + } catch (\Exception $error) { + } + } + + throw $error; + } +} diff --git a/vendor/symfony/console/Symfony/Component/Console/Helper/FormatterHelper.php b/vendor/symfony/console/Symfony/Component/Console/Helper/FormatterHelper.php new file mode 100755 index 0000000..b942943 --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Helper/FormatterHelper.php @@ -0,0 +1,80 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Console\Helper; + +use Symfony\Component\Console\Formatter\OutputFormatter; + +/** + * The Formatter class provides helpers to format messages. + * + * @author Fabien Potencier + */ +class FormatterHelper extends Helper +{ + /** + * Formats a message within a section. + * + * @param string $section The section name + * @param string $message The message + * @param string $style The style to apply to the section + * + * @return string The format section + */ + public function formatSection($section, $message, $style = 'info') + { + return sprintf('<%s>[%s] %s', $style, $section, $style, $message); + } + + /** + * Formats a message as a block of text. + * + * @param string|array $messages The message to write in the block + * @param string $style The style to apply to the whole block + * @param bool $large Whether to return a large block + * + * @return string The formatter message + */ + public function formatBlock($messages, $style, $large = false) + { + $messages = (array) $messages; + + $len = 0; + $lines = array(); + foreach ($messages as $message) { + $message = OutputFormatter::escape($message); + $lines[] = sprintf($large ? ' %s ' : ' %s ', $message); + $len = max($this->strlen($message) + ($large ? 4 : 2), $len); + } + + $messages = $large ? array(str_repeat(' ', $len)) : array(); + foreach ($lines as $line) { + $messages[] = $line.str_repeat(' ', $len - $this->strlen($line)); + } + if ($large) { + $messages[] = str_repeat(' ', $len); + } + + foreach ($messages as &$message) { + $message = sprintf('<%s>%s', $style, $message, $style); + } + + return implode("\n", $messages); + } + + /** + * {@inheritdoc} + */ + public function getName() + { + return 'formatter'; + } +} diff --git a/vendor/symfony/console/Symfony/Component/Console/Helper/Helper.php b/vendor/symfony/console/Symfony/Component/Console/Helper/Helper.php new file mode 100755 index 0000000..b2a8389 --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Helper/Helper.php @@ -0,0 +1,62 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Console\Helper; + +/** + * Helper is the base class for all helper classes. + * + * @author Fabien Potencier + */ +abstract class Helper implements HelperInterface +{ + protected $helperSet = null; + + /** + * Sets the helper set associated with this helper. + * + * @param HelperSet $helperSet A HelperSet instance + */ + public function setHelperSet(HelperSet $helperSet = null) + { + $this->helperSet = $helperSet; + } + + /** + * Gets the helper set associated with this helper. + * + * @return HelperSet A HelperSet instance + */ + public function getHelperSet() + { + return $this->helperSet; + } + + /** + * Returns the length of a string, using mb_strlen if it is available. + * + * @param string $string The string to check its length + * + * @return int The length of the string + */ + protected function strlen($string) + { + if (!function_exists('mb_strwidth')) { + return strlen($string); + } + + if (false === $encoding = mb_detect_encoding($string)) { + return strlen($string); + } + + return mb_strwidth($string, $encoding); + } +} diff --git a/vendor/symfony/console/Symfony/Component/Console/Helper/HelperInterface.php b/vendor/symfony/console/Symfony/Component/Console/Helper/HelperInterface.php new file mode 100755 index 0000000..6d39449 --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Helper/HelperInterface.php @@ -0,0 +1,49 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Console\Helper; + +/** + * HelperInterface is the interface all helpers must implement. + * + * @author Fabien Potencier + * + * @api + */ +interface HelperInterface +{ + /** + * Sets the helper set associated with this helper. + * + * @param HelperSet $helperSet A HelperSet instance + * + * @api + */ + public function setHelperSet(HelperSet $helperSet = null); + + /** + * Gets the helper set associated with this helper. + * + * @return HelperSet A HelperSet instance + * + * @api + */ + public function getHelperSet(); + + /** + * Returns the canonical name of this helper. + * + * @return string The canonical name + * + * @api + */ + public function getName(); +} diff --git a/vendor/symfony/console/Symfony/Component/Console/Helper/HelperSet.php b/vendor/symfony/console/Symfony/Component/Console/Helper/HelperSet.php new file mode 100755 index 0000000..76fa2e4 --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Helper/HelperSet.php @@ -0,0 +1,108 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Console\Helper; + +use Symfony\Component\Console\Command\Command; + +/** + * HelperSet represents a set of helpers to be used with a command. + * + * @author Fabien Potencier + */ +class HelperSet implements \IteratorAggregate +{ + private $helpers = array(); + private $command; + + /** + * Constructor. + * + * @param Helper[] $helpers An array of helper. + */ + public function __construct(array $helpers = array()) + { + foreach ($helpers as $alias => $helper) { + $this->set($helper, is_int($alias) ? null : $alias); + } + } + + /** + * Sets a helper. + * + * @param HelperInterface $helper The helper instance + * @param string $alias An alias + */ + public function set(HelperInterface $helper, $alias = null) + { + $this->helpers[$helper->getName()] = $helper; + if (null !== $alias) { + $this->helpers[$alias] = $helper; + } + + $helper->setHelperSet($this); + } + + /** + * Returns true if the helper if defined. + * + * @param string $name The helper name + * + * @return bool true if the helper is defined, false otherwise + */ + public function has($name) + { + return isset($this->helpers[$name]); + } + + /** + * Gets a helper value. + * + * @param string $name The helper name + * + * @return HelperInterface The helper instance + * + * @throws \InvalidArgumentException if the helper is not defined + */ + public function get($name) + { + if (!$this->has($name)) { + throw new \InvalidArgumentException(sprintf('The helper "%s" is not defined.', $name)); + } + + return $this->helpers[$name]; + } + + /** + * Sets the command associated with this helper set. + * + * @param Command $command A Command instance + */ + public function setCommand(Command $command = null) + { + $this->command = $command; + } + + /** + * Gets the command associated with this helper set. + * + * @return Command A Command instance + */ + public function getCommand() + { + return $this->command; + } + + public function getIterator() + { + return new \ArrayIterator($this->helpers); + } +} diff --git a/vendor/symfony/console/Symfony/Component/Console/Helper/InputAwareHelper.php b/vendor/symfony/console/Symfony/Component/Console/Helper/InputAwareHelper.php new file mode 100755 index 0000000..4261767 --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Helper/InputAwareHelper.php @@ -0,0 +1,33 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Console\Helper; + +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Input\InputAwareInterface; + +/** + * An implementation of InputAwareInterface for Helpers. + * + * @author Wouter J + */ +abstract class InputAwareHelper extends Helper implements InputAwareInterface +{ + protected $input; + + /** + * {@inheritdoc} + */ + public function setInput(InputInterface $input) + { + $this->input = $input; + } +} diff --git a/vendor/symfony/console/Symfony/Component/Console/Helper/ProgressHelper.php b/vendor/symfony/console/Symfony/Component/Console/Helper/ProgressHelper.php new file mode 100755 index 0000000..647d616 --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Helper/ProgressHelper.php @@ -0,0 +1,452 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Console\Helper; + +use Symfony\Component\Console\Output\OutputInterface; + +/** + * The Progress class provides helpers to display progress output. + * + * @author Chris Jones + * @author Fabien Potencier + */ +class ProgressHelper extends Helper +{ + const FORMAT_QUIET = ' %percent%%'; + const FORMAT_NORMAL = ' %current%/%max% [%bar%] %percent%%'; + const FORMAT_VERBOSE = ' %current%/%max% [%bar%] %percent%% Elapsed: %elapsed%'; + const FORMAT_QUIET_NOMAX = ' %current%'; + const FORMAT_NORMAL_NOMAX = ' %current% [%bar%]'; + const FORMAT_VERBOSE_NOMAX = ' %current% [%bar%] Elapsed: %elapsed%'; + + // options + private $barWidth = 28; + private $barChar = '='; + private $emptyBarChar = '-'; + private $progressChar = '>'; + private $format = null; + private $redrawFreq = 1; + + private $lastMessagesLength; + private $barCharOriginal; + + /** + * @var OutputInterface + */ + private $output; + + /** + * Current step + * + * @var int + */ + private $current; + + /** + * Maximum number of steps + * + * @var int + */ + private $max; + + /** + * Start time of the progress bar + * + * @var int + */ + private $startTime; + + /** + * List of formatting variables + * + * @var array + */ + private $defaultFormatVars = array( + 'current', + 'max', + 'bar', + 'percent', + 'elapsed', + ); + + /** + * Available formatting variables + * + * @var array + */ + private $formatVars; + + /** + * Stored format part widths (used for padding) + * + * @var array + */ + private $widths = array( + 'current' => 4, + 'max' => 4, + 'percent' => 3, + 'elapsed' => 6, + ); + + /** + * Various time formats + * + * @var array + */ + private $timeFormats = array( + array(0, '???'), + array(2, '1 sec'), + array(59, 'secs', 1), + array(60, '1 min'), + array(3600, 'mins', 60), + array(5400, '1 hr'), + array(86400, 'hrs', 3600), + array(129600, '1 day'), + array(604800, 'days', 86400), + ); + + /** + * Sets the progress bar width. + * + * @param int $size The progress bar size + */ + public function setBarWidth($size) + { + $this->barWidth = (int) $size; + } + + /** + * Sets the bar character. + * + * @param string $char A character + */ + public function setBarCharacter($char) + { + $this->barChar = $char; + } + + /** + * Sets the empty bar character. + * + * @param string $char A character + */ + public function setEmptyBarCharacter($char) + { + $this->emptyBarChar = $char; + } + + /** + * Sets the progress bar character. + * + * @param string $char A character + */ + public function setProgressCharacter($char) + { + $this->progressChar = $char; + } + + /** + * Sets the progress bar format. + * + * @param string $format The format + */ + public function setFormat($format) + { + $this->format = $format; + } + + /** + * Sets the redraw frequency. + * + * @param int $freq The frequency in steps + */ + public function setRedrawFrequency($freq) + { + $this->redrawFreq = (int) $freq; + } + + /** + * Starts the progress output. + * + * @param OutputInterface $output An Output instance + * @param int|null $max Maximum steps + */ + public function start(OutputInterface $output, $max = null) + { + $this->startTime = time(); + $this->current = 0; + $this->max = (int) $max; + $this->output = $output; + $this->lastMessagesLength = 0; + $this->barCharOriginal = ''; + + if (null === $this->format) { + switch ($output->getVerbosity()) { + case OutputInterface::VERBOSITY_QUIET: + $this->format = self::FORMAT_QUIET_NOMAX; + if ($this->max > 0) { + $this->format = self::FORMAT_QUIET; + } + break; + case OutputInterface::VERBOSITY_VERBOSE: + case OutputInterface::VERBOSITY_VERY_VERBOSE: + case OutputInterface::VERBOSITY_DEBUG: + $this->format = self::FORMAT_VERBOSE_NOMAX; + if ($this->max > 0) { + $this->format = self::FORMAT_VERBOSE; + } + break; + default: + $this->format = self::FORMAT_NORMAL_NOMAX; + if ($this->max > 0) { + $this->format = self::FORMAT_NORMAL; + } + break; + } + } + + $this->initialize(); + } + + /** + * Advances the progress output X steps. + * + * @param int $step Number of steps to advance + * @param bool $redraw Whether to redraw or not + * + * @throws \LogicException + */ + public function advance($step = 1, $redraw = false) + { + $this->setCurrent($this->current + $step, $redraw); + } + + /** + * Sets the current progress. + * + * @param int $current The current progress + * @param bool $redraw Whether to redraw or not + * + * @throws \LogicException + */ + public function setCurrent($current, $redraw = false) + { + if (null === $this->startTime) { + throw new \LogicException('You must start the progress bar before calling setCurrent().'); + } + + $current = (int) $current; + + if ($current < $this->current) { + throw new \LogicException('You can\'t regress the progress bar'); + } + + if (0 === $this->current) { + $redraw = true; + } + + $prevPeriod = intval($this->current / $this->redrawFreq); + + $this->current = $current; + + $currPeriod = intval($this->current / $this->redrawFreq); + if ($redraw || $prevPeriod !== $currPeriod || $this->max === $this->current) { + $this->display(); + } + } + + /** + * Outputs the current progress string. + * + * @param bool $finish Forces the end result + * + * @throws \LogicException + */ + public function display($finish = false) + { + if (null === $this->startTime) { + throw new \LogicException('You must start the progress bar before calling display().'); + } + + $message = $this->format; + foreach ($this->generate($finish) as $name => $value) { + $message = str_replace("%{$name}%", $value, $message); + } + $this->overwrite($this->output, $message); + } + + /** + * Removes the progress bar from the current line. + * + * This is useful if you wish to write some output + * while a progress bar is running. + * Call display() to show the progress bar again. + */ + public function clear() + { + $this->overwrite($this->output, ''); + } + + /** + * Finishes the progress output. + */ + public function finish() + { + if (null === $this->startTime) { + throw new \LogicException('You must start the progress bar before calling finish().'); + } + + if (null !== $this->startTime) { + if (!$this->max) { + $this->barChar = $this->barCharOriginal; + $this->display(true); + } + $this->startTime = null; + $this->output->writeln(''); + $this->output = null; + } + } + + /** + * Initializes the progress helper. + */ + private function initialize() + { + $this->formatVars = array(); + foreach ($this->defaultFormatVars as $var) { + if (false !== strpos($this->format, "%{$var}%")) { + $this->formatVars[$var] = true; + } + } + + if ($this->max > 0) { + $this->widths['max'] = $this->strlen($this->max); + $this->widths['current'] = $this->widths['max']; + } else { + $this->barCharOriginal = $this->barChar; + $this->barChar = $this->emptyBarChar; + } + } + + /** + * Generates the array map of format variables to values. + * + * @param bool $finish Forces the end result + * + * @return array Array of format vars and values + */ + private function generate($finish = false) + { + $vars = array(); + $percent = 0; + if ($this->max > 0) { + $percent = (float) $this->current / $this->max; + } + + if (isset($this->formatVars['bar'])) { + $completeBars = 0; + + if ($this->max > 0) { + $completeBars = floor($percent * $this->barWidth); + } else { + if (!$finish) { + $completeBars = floor($this->current % $this->barWidth); + } else { + $completeBars = $this->barWidth; + } + } + + $emptyBars = $this->barWidth - $completeBars - $this->strlen($this->progressChar); + $bar = str_repeat($this->barChar, $completeBars); + if ($completeBars < $this->barWidth) { + $bar .= $this->progressChar; + $bar .= str_repeat($this->emptyBarChar, $emptyBars); + } + + $vars['bar'] = $bar; + } + + if (isset($this->formatVars['elapsed'])) { + $elapsed = time() - $this->startTime; + $vars['elapsed'] = str_pad($this->humaneTime($elapsed), $this->widths['elapsed'], ' ', STR_PAD_LEFT); + } + + if (isset($this->formatVars['current'])) { + $vars['current'] = str_pad($this->current, $this->widths['current'], ' ', STR_PAD_LEFT); + } + + if (isset($this->formatVars['max'])) { + $vars['max'] = $this->max; + } + + if (isset($this->formatVars['percent'])) { + $vars['percent'] = str_pad(floor($percent * 100), $this->widths['percent'], ' ', STR_PAD_LEFT); + } + + return $vars; + } + + /** + * Converts seconds into human-readable format. + * + * @param int $secs Number of seconds + * + * @return string Time in readable format + */ + private function humaneTime($secs) + { + $text = ''; + foreach ($this->timeFormats as $format) { + if ($secs < $format[0]) { + if (count($format) == 2) { + $text = $format[1]; + break; + } else { + $text = ceil($secs / $format[2]).' '.$format[1]; + break; + } + } + } + + return $text; + } + + /** + * Overwrites a previous message to the output. + * + * @param OutputInterface $output An Output instance + * @param string $message The message + */ + private function overwrite(OutputInterface $output, $message) + { + $length = $this->strlen($message); + + // append whitespace to match the last line's length + if (null !== $this->lastMessagesLength && $this->lastMessagesLength > $length) { + $message = str_pad($message, $this->lastMessagesLength, "\x20", STR_PAD_RIGHT); + } + + // carriage return + $output->write("\x0D"); + $output->write($message); + + $this->lastMessagesLength = $this->strlen($message); + } + + /** + * {@inheritdoc} + */ + public function getName() + { + return 'progress'; + } +} diff --git a/vendor/symfony/console/Symfony/Component/Console/Helper/TableHelper.php b/vendor/symfony/console/Symfony/Component/Console/Helper/TableHelper.php new file mode 100755 index 0000000..3281fc8 --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Helper/TableHelper.php @@ -0,0 +1,520 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Console\Helper; + +use Symfony\Component\Console\Output\OutputInterface; +use InvalidArgumentException; + +/** + * Provides helpers to display table output. + * + * @author Саша Стаменковић + */ +class TableHelper extends Helper +{ + const LAYOUT_DEFAULT = 0; + const LAYOUT_BORDERLESS = 1; + const LAYOUT_COMPACT = 2; + + /** + * Table headers. + * + * @var array + */ + private $headers = array(); + + /** + * Table rows. + * + * @var array + */ + private $rows = array(); + + // Rendering options + private $paddingChar; + private $horizontalBorderChar; + private $verticalBorderChar; + private $crossingChar; + private $cellHeaderFormat; + private $cellRowFormat; + private $cellRowContentFormat; + private $borderFormat; + private $padType; + + /** + * Column widths cache. + * + * @var array + */ + private $columnWidths = array(); + + /** + * Number of columns cache. + * + * @var array + */ + private $numberOfColumns; + + /** + * @var OutputInterface + */ + private $output; + + public function __construct() + { + $this->setLayout(self::LAYOUT_DEFAULT); + } + + /** + * Sets table layout type. + * + * @param int $layout self::LAYOUT_* + * + * @return TableHelper + */ + public function setLayout($layout) + { + switch ($layout) { + case self::LAYOUT_BORDERLESS: + $this + ->setPaddingChar(' ') + ->setHorizontalBorderChar('=') + ->setVerticalBorderChar(' ') + ->setCrossingChar(' ') + ->setCellHeaderFormat('%s') + ->setCellRowFormat('%s') + ->setCellRowContentFormat(' %s ') + ->setBorderFormat('%s') + ->setPadType(STR_PAD_RIGHT) + ; + break; + + case self::LAYOUT_COMPACT: + $this + ->setPaddingChar(' ') + ->setHorizontalBorderChar('') + ->setVerticalBorderChar(' ') + ->setCrossingChar('') + ->setCellHeaderFormat('%s') + ->setCellRowFormat('%s') + ->setCellRowContentFormat('%s') + ->setBorderFormat('%s') + ->setPadType(STR_PAD_RIGHT) + ; + break; + + case self::LAYOUT_DEFAULT: + $this + ->setPaddingChar(' ') + ->setHorizontalBorderChar('-') + ->setVerticalBorderChar('|') + ->setCrossingChar('+') + ->setCellHeaderFormat('%s') + ->setCellRowFormat('%s') + ->setCellRowContentFormat(' %s ') + ->setBorderFormat('%s') + ->setPadType(STR_PAD_RIGHT) + ; + break; + + default: + throw new InvalidArgumentException(sprintf('Invalid table layout "%s".', $layout)); + break; + }; + + return $this; + } + + public function setHeaders(array $headers) + { + $this->headers = array_values($headers); + + return $this; + } + + public function setRows(array $rows) + { + $this->rows = array(); + + return $this->addRows($rows); + } + + public function addRows(array $rows) + { + foreach ($rows as $row) { + $this->addRow($row); + } + + return $this; + } + + public function addRow(array $row) + { + $this->rows[] = array_values($row); + + $keys = array_keys($this->rows); + $rowKey = array_pop($keys); + + foreach ($row as $key => $cellValue) { + if (!strstr($cellValue, "\n")) { + continue; + } + + $lines = explode("\n", $cellValue); + $this->rows[$rowKey][$key] = $lines[0]; + unset($lines[0]); + + foreach ($lines as $lineKey => $line) { + $nextRowKey = $rowKey + $lineKey + 1; + + if (isset($this->rows[$nextRowKey])) { + $this->rows[$nextRowKey][$key] = $line; + } else { + $this->rows[$nextRowKey] = array($key => $line); + } + } + } + + return $this; + } + + public function setRow($column, array $row) + { + $this->rows[$column] = $row; + + return $this; + } + + /** + * Sets padding character, used for cell padding. + * + * @param string $paddingChar + * + * @return TableHelper + */ + public function setPaddingChar($paddingChar) + { + if (!$paddingChar) { + throw new \LogicException('The padding char must not be empty'); + } + + $this->paddingChar = $paddingChar; + + return $this; + } + + /** + * Sets horizontal border character. + * + * @param string $horizontalBorderChar + * + * @return TableHelper + */ + public function setHorizontalBorderChar($horizontalBorderChar) + { + $this->horizontalBorderChar = $horizontalBorderChar; + + return $this; + } + + /** + * Sets vertical border character. + * + * @param string $verticalBorderChar + * + * @return TableHelper + */ + public function setVerticalBorderChar($verticalBorderChar) + { + $this->verticalBorderChar = $verticalBorderChar; + + return $this; + } + + /** + * Sets crossing character. + * + * @param string $crossingChar + * + * @return TableHelper + */ + public function setCrossingChar($crossingChar) + { + $this->crossingChar = $crossingChar; + + return $this; + } + + /** + * Sets header cell format. + * + * @param string $cellHeaderFormat + * + * @return TableHelper + */ + public function setCellHeaderFormat($cellHeaderFormat) + { + $this->cellHeaderFormat = $cellHeaderFormat; + + return $this; + } + + /** + * Sets row cell format. + * + * @param string $cellRowFormat + * + * @return TableHelper + */ + public function setCellRowFormat($cellRowFormat) + { + $this->cellRowFormat = $cellRowFormat; + + return $this; + } + + /** + * Sets row cell content format. + * + * @param string $cellRowContentFormat + * + * @return TableHelper + */ + public function setCellRowContentFormat($cellRowContentFormat) + { + $this->cellRowContentFormat = $cellRowContentFormat; + + return $this; + } + + /** + * Sets table border format. + * + * @param string $borderFormat + * + * @return TableHelper + */ + public function setBorderFormat($borderFormat) + { + $this->borderFormat = $borderFormat; + + return $this; + } + + /** + * Sets cell padding type. + * + * @param int $padType STR_PAD_* + * + * @return TableHelper + */ + public function setPadType($padType) + { + $this->padType = $padType; + + return $this; + } + + /** + * Renders table to output. + * + * Example: + * +---------------+-----------------------+------------------+ + * | ISBN | Title | Author | + * +---------------+-----------------------+------------------+ + * | 99921-58-10-7 | Divine Comedy | Dante Alighieri | + * | 9971-5-0210-0 | A Tale of Two Cities | Charles Dickens | + * | 960-425-059-0 | The Lord of the Rings | J. R. R. Tolkien | + * +---------------+-----------------------+------------------+ + * + * @param OutputInterface $output + */ + public function render(OutputInterface $output) + { + $this->output = $output; + + $this->renderRowSeparator(); + $this->renderRow($this->headers, $this->cellHeaderFormat); + if (!empty($this->headers)) { + $this->renderRowSeparator(); + } + foreach ($this->rows as $row) { + $this->renderRow($row, $this->cellRowFormat); + } + if (!empty($this->rows)) { + $this->renderRowSeparator(); + } + + $this->cleanup(); + } + + /** + * Renders horizontal header separator. + * + * Example: +-----+-----------+-------+ + */ + private function renderRowSeparator() + { + if (0 === $count = $this->getNumberOfColumns()) { + return; + } + + if (!$this->horizontalBorderChar && !$this->crossingChar) { + return; + } + + $markup = $this->crossingChar; + for ($column = 0; $column < $count; $column++) { + $markup .= str_repeat($this->horizontalBorderChar, $this->getColumnWidth($column)).$this->crossingChar; + } + + $this->output->writeln(sprintf($this->borderFormat, $markup)); + } + + /** + * Renders vertical column separator. + */ + private function renderColumnSeparator() + { + $this->output->write(sprintf($this->borderFormat, $this->verticalBorderChar)); + } + + /** + * Renders table row. + * + * Example: | 9971-5-0210-0 | A Tale of Two Cities | Charles Dickens | + * + * @param array $row + * @param string $cellFormat + */ + private function renderRow(array $row, $cellFormat) + { + if (empty($row)) { + return; + } + + $this->renderColumnSeparator(); + for ($column = 0, $count = $this->getNumberOfColumns(); $column < $count; $column++) { + $this->renderCell($row, $column, $cellFormat); + $this->renderColumnSeparator(); + } + $this->output->writeln(''); + } + + /** + * Renders table cell with padding. + * + * @param array $row + * @param int $column + * @param string $cellFormat + */ + private function renderCell(array $row, $column, $cellFormat) + { + $cell = isset($row[$column]) ? $row[$column] : ''; + $width = $this->getColumnWidth($column); + + // str_pad won't work properly with multi-byte strings, we need to fix the padding + if (function_exists('mb_strlen') && false !== $encoding = mb_detect_encoding($cell)) { + $width += strlen($cell) - mb_strlen($cell, $encoding); + } + + $width += $this->strlen($cell) - $this->computeLengthWithoutDecoration($cell); + + $content = sprintf($this->cellRowContentFormat, $cell); + + $this->output->write(sprintf($cellFormat, str_pad($content, $width, $this->paddingChar, $this->padType))); + } + + /** + * Gets number of columns for this table. + * + * @return int + */ + private function getNumberOfColumns() + { + if (null !== $this->numberOfColumns) { + return $this->numberOfColumns; + } + + $columns = array(0); + $columns[] = count($this->headers); + foreach ($this->rows as $row) { + $columns[] = count($row); + } + + return $this->numberOfColumns = max($columns); + } + + /** + * Gets column width. + * + * @param int $column + * + * @return int + */ + private function getColumnWidth($column) + { + if (isset($this->columnWidths[$column])) { + return $this->columnWidths[$column]; + } + + $lengths = array(0); + $lengths[] = $this->getCellWidth($this->headers, $column); + foreach ($this->rows as $row) { + $lengths[] = $this->getCellWidth($row, $column); + } + + return $this->columnWidths[$column] = max($lengths) + strlen($this->cellRowContentFormat) - 2; + } + + /** + * Gets cell width. + * + * @param array $row + * @param int $column + * + * @return int + */ + private function getCellWidth(array $row, $column) + { + return isset($row[$column]) ? $this->computeLengthWithoutDecoration($row[$column]) : 0; + } + + /** + * Called after rendering to cleanup cache data. + */ + private function cleanup() + { + $this->columnWidths = array(); + $this->numberOfColumns = null; + } + + private function computeLengthWithoutDecoration($string) + { + $formatter = $this->output->getFormatter(); + $isDecorated = $formatter->isDecorated(); + $formatter->setDecorated(false); + + $string = $formatter->format($string); + $formatter->setDecorated($isDecorated); + + return $this->strlen($string); + } + + /** + * {@inheritdoc} + */ + public function getName() + { + return 'table'; + } +} diff --git a/vendor/symfony/console/Symfony/Component/Console/Input/ArgvInput.php b/vendor/symfony/console/Symfony/Component/Console/Input/ArgvInput.php new file mode 100755 index 0000000..3a0f0a7 --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Input/ArgvInput.php @@ -0,0 +1,351 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Console\Input; + +/** + * ArgvInput represents an input coming from the CLI arguments. + * + * Usage: + * + * $input = new ArgvInput(); + * + * By default, the `$_SERVER['argv']` array is used for the input values. + * + * This can be overridden by explicitly passing the input values in the constructor: + * + * $input = new ArgvInput($_SERVER['argv']); + * + * If you pass it yourself, don't forget that the first element of the array + * is the name of the running application. + * + * When passing an argument to the constructor, be sure that it respects + * the same rules as the argv one. It's almost always better to use the + * `StringInput` when you want to provide your own input. + * + * @author Fabien Potencier + * + * @see http://www.gnu.org/software/libc/manual/html_node/Argument-Syntax.html + * @see http://www.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap12.html#tag_12_02 + * + * @api + */ +class ArgvInput extends Input +{ + private $tokens; + private $parsed; + + /** + * Constructor. + * + * @param array $argv An array of parameters from the CLI (in the argv format) + * @param InputDefinition $definition A InputDefinition instance + * + * @api + */ + public function __construct(array $argv = null, InputDefinition $definition = null) + { + if (null === $argv) { + $argv = $_SERVER['argv']; + } + + // strip the application name + array_shift($argv); + + $this->tokens = $argv; + + parent::__construct($definition); + } + + protected function setTokens(array $tokens) + { + $this->tokens = $tokens; + } + + /** + * Processes command line arguments. + */ + protected function parse() + { + $parseOptions = true; + $this->parsed = $this->tokens; + while (null !== $token = array_shift($this->parsed)) { + if ($parseOptions && '' == $token) { + $this->parseArgument($token); + } elseif ($parseOptions && '--' == $token) { + $parseOptions = false; + } elseif ($parseOptions && 0 === strpos($token, '--')) { + $this->parseLongOption($token); + } elseif ($parseOptions && '-' === $token[0] && '-' !== $token) { + $this->parseShortOption($token); + } else { + $this->parseArgument($token); + } + } + } + + /** + * Parses a short option. + * + * @param string $token The current token. + */ + private function parseShortOption($token) + { + $name = substr($token, 1); + + if (strlen($name) > 1) { + if ($this->definition->hasShortcut($name[0]) && $this->definition->getOptionForShortcut($name[0])->acceptValue()) { + // an option with a value (with no space) + $this->addShortOption($name[0], substr($name, 1)); + } else { + $this->parseShortOptionSet($name); + } + } else { + $this->addShortOption($name, null); + } + } + + /** + * Parses a short option set. + * + * @param string $name The current token + * + * @throws \RuntimeException When option given doesn't exist + */ + private function parseShortOptionSet($name) + { + $len = strlen($name); + for ($i = 0; $i < $len; $i++) { + if (!$this->definition->hasShortcut($name[$i])) { + throw new \RuntimeException(sprintf('The "-%s" option does not exist.', $name[$i])); + } + + $option = $this->definition->getOptionForShortcut($name[$i]); + if ($option->acceptValue()) { + $this->addLongOption($option->getName(), $i === $len - 1 ? null : substr($name, $i + 1)); + + break; + } else { + $this->addLongOption($option->getName(), null); + } + } + } + + /** + * Parses a long option. + * + * @param string $token The current token + */ + private function parseLongOption($token) + { + $name = substr($token, 2); + + if (false !== $pos = strpos($name, '=')) { + $this->addLongOption(substr($name, 0, $pos), substr($name, $pos + 1)); + } else { + $this->addLongOption($name, null); + } + } + + /** + * Parses an argument. + * + * @param string $token The current token + * + * @throws \RuntimeException When too many arguments are given + */ + private function parseArgument($token) + { + $c = count($this->arguments); + + // if input is expecting another argument, add it + if ($this->definition->hasArgument($c)) { + $arg = $this->definition->getArgument($c); + $this->arguments[$arg->getName()] = $arg->isArray()? array($token) : $token; + + // if last argument isArray(), append token to last argument + } elseif ($this->definition->hasArgument($c - 1) && $this->definition->getArgument($c - 1)->isArray()) { + $arg = $this->definition->getArgument($c - 1); + $this->arguments[$arg->getName()][] = $token; + + // unexpected argument + } else { + throw new \RuntimeException('Too many arguments.'); + } + } + + /** + * Adds a short option value. + * + * @param string $shortcut The short option key + * @param mixed $value The value for the option + * + * @throws \RuntimeException When option given doesn't exist + */ + private function addShortOption($shortcut, $value) + { + if (!$this->definition->hasShortcut($shortcut)) { + throw new \RuntimeException(sprintf('The "-%s" option does not exist.', $shortcut)); + } + + $this->addLongOption($this->definition->getOptionForShortcut($shortcut)->getName(), $value); + } + + /** + * Adds a long option value. + * + * @param string $name The long option key + * @param mixed $value The value for the option + * + * @throws \RuntimeException When option given doesn't exist + */ + private function addLongOption($name, $value) + { + if (!$this->definition->hasOption($name)) { + throw new \RuntimeException(sprintf('The "--%s" option does not exist.', $name)); + } + + $option = $this->definition->getOption($name); + + // Convert false values (from a previous call to substr()) to null + if (false === $value) { + $value = null; + } + + if (null !== $value && !$option->acceptValue()) { + throw new \RuntimeException(sprintf('The "--%s" option does not accept a value.', $name, $value)); + } + + if (null === $value && $option->acceptValue() && count($this->parsed)) { + // if option accepts an optional or mandatory argument + // let's see if there is one provided + $next = array_shift($this->parsed); + if (isset($next[0]) && '-' !== $next[0]) { + $value = $next; + } elseif (empty($next)) { + $value = ''; + } else { + array_unshift($this->parsed, $next); + } + } + + if (null === $value) { + if ($option->isValueRequired()) { + throw new \RuntimeException(sprintf('The "--%s" option requires a value.', $name)); + } + + if (!$option->isArray()) { + $value = $option->isValueOptional() ? $option->getDefault() : true; + } + } + + if ($option->isArray()) { + $this->options[$name][] = $value; + } else { + $this->options[$name] = $value; + } + } + + /** + * Returns the first argument from the raw parameters (not parsed). + * + * @return string The value of the first argument or null otherwise + */ + public function getFirstArgument() + { + foreach ($this->tokens as $token) { + if ($token && '-' === $token[0]) { + continue; + } + + return $token; + } + } + + /** + * Returns true if the raw parameters (not parsed) contain a value. + * + * This method is to be used to introspect the input parameters + * before they have been validated. It must be used carefully. + * + * @param string|array $values The value(s) to look for in the raw parameters (can be an array) + * + * @return bool true if the value is contained in the raw parameters + */ + public function hasParameterOption($values) + { + $values = (array) $values; + + foreach ($this->tokens as $token) { + foreach ($values as $value) { + if ($token === $value || 0 === strpos($token, $value.'=')) { + return true; + } + } + } + + return false; + } + + /** + * Returns the value of a raw option (not parsed). + * + * This method is to be used to introspect the input parameters + * before they have been validated. It must be used carefully. + * + * @param string|array $values The value(s) to look for in the raw parameters (can be an array) + * @param mixed $default The default value to return if no result is found + * + * @return mixed The option value + */ + public function getParameterOption($values, $default = false) + { + $values = (array) $values; + + $tokens = $this->tokens; + while ($token = array_shift($tokens)) { + foreach ($values as $value) { + if ($token === $value || 0 === strpos($token, $value.'=')) { + if (false !== $pos = strpos($token, '=')) { + return substr($token, $pos + 1); + } + + return array_shift($tokens); + } + } + } + + return $default; + } + + /** + * Returns a stringified representation of the args passed to the command + * + * @return string + */ + public function __toString() + { + $self = $this; + $tokens = array_map(function ($token) use ($self) { + if (preg_match('{^(-[^=]+=)(.+)}', $token, $match)) { + return $match[1] . $self->escapeToken($match[2]); + } + + if ($token && $token[0] !== '-') { + return $self->escapeToken($token); + } + + return $token; + }, $this->tokens); + + return implode(' ', $tokens); + } +} diff --git a/vendor/symfony/console/Symfony/Component/Console/Input/ArrayInput.php b/vendor/symfony/console/Symfony/Component/Console/Input/ArrayInput.php new file mode 100755 index 0000000..27d9132 --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Input/ArrayInput.php @@ -0,0 +1,209 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Console\Input; + +/** + * ArrayInput represents an input provided as an array. + * + * Usage: + * + * $input = new ArrayInput(array('name' => 'foo', '--bar' => 'foobar')); + * + * @author Fabien Potencier + * + * @api + */ +class ArrayInput extends Input +{ + private $parameters; + + /** + * Constructor. + * + * @param array $parameters An array of parameters + * @param InputDefinition $definition A InputDefinition instance + * + * @api + */ + public function __construct(array $parameters, InputDefinition $definition = null) + { + $this->parameters = $parameters; + + parent::__construct($definition); + } + + /** + * Returns the first argument from the raw parameters (not parsed). + * + * @return string The value of the first argument or null otherwise + */ + public function getFirstArgument() + { + foreach ($this->parameters as $key => $value) { + if ($key && '-' === $key[0]) { + continue; + } + + return $value; + } + } + + /** + * Returns true if the raw parameters (not parsed) contain a value. + * + * This method is to be used to introspect the input parameters + * before they have been validated. It must be used carefully. + * + * @param string|array $values The values to look for in the raw parameters (can be an array) + * + * @return bool true if the value is contained in the raw parameters + */ + public function hasParameterOption($values) + { + $values = (array) $values; + + foreach ($this->parameters as $k => $v) { + if (!is_int($k)) { + $v = $k; + } + + if (in_array($v, $values)) { + return true; + } + } + + return false; + } + + /** + * Returns the value of a raw option (not parsed). + * + * This method is to be used to introspect the input parameters + * before they have been validated. It must be used carefully. + * + * @param string|array $values The value(s) to look for in the raw parameters (can be an array) + * @param mixed $default The default value to return if no result is found + * + * @return mixed The option value + */ + public function getParameterOption($values, $default = false) + { + $values = (array) $values; + + foreach ($this->parameters as $k => $v) { + if (is_int($k) && in_array($v, $values)) { + return true; + } elseif (in_array($k, $values)) { + return $v; + } + } + + return $default; + } + + /** + * Returns a stringified representation of the args passed to the command + * + * @return string + */ + public function __toString() + { + $params = array(); + foreach ($this->parameters as $param => $val) { + if ($param && '-' === $param[0]) { + $params[] = $param . ('' != $val ? '='.$this->escapeToken($val) : ''); + } else { + $params[] = $this->escapeToken($val); + } + } + + return implode(' ', $params); + } + + /** + * Processes command line arguments. + */ + protected function parse() + { + foreach ($this->parameters as $key => $value) { + if (0 === strpos($key, '--')) { + $this->addLongOption(substr($key, 2), $value); + } elseif ('-' === $key[0]) { + $this->addShortOption(substr($key, 1), $value); + } else { + $this->addArgument($key, $value); + } + } + } + + /** + * Adds a short option value. + * + * @param string $shortcut The short option key + * @param mixed $value The value for the option + * + * @throws \InvalidArgumentException When option given doesn't exist + */ + private function addShortOption($shortcut, $value) + { + if (!$this->definition->hasShortcut($shortcut)) { + throw new \InvalidArgumentException(sprintf('The "-%s" option does not exist.', $shortcut)); + } + + $this->addLongOption($this->definition->getOptionForShortcut($shortcut)->getName(), $value); + } + + /** + * Adds a long option value. + * + * @param string $name The long option key + * @param mixed $value The value for the option + * + * @throws \InvalidArgumentException When option given doesn't exist + * @throws \InvalidArgumentException When a required value is missing + */ + private function addLongOption($name, $value) + { + if (!$this->definition->hasOption($name)) { + throw new \InvalidArgumentException(sprintf('The "--%s" option does not exist.', $name)); + } + + $option = $this->definition->getOption($name); + + if (null === $value) { + if ($option->isValueRequired()) { + throw new \InvalidArgumentException(sprintf('The "--%s" option requires a value.', $name)); + } + + $value = $option->isValueOptional() ? $option->getDefault() : true; + } + + $this->options[$name] = $value; + } + + /** + * Adds an argument value. + * + * @param string $name The argument name + * @param mixed $value The value for the argument + * + * @throws \InvalidArgumentException When argument given doesn't exist + */ + private function addArgument($name, $value) + { + if (!$this->definition->hasArgument($name)) { + throw new \InvalidArgumentException(sprintf('The "%s" argument does not exist.', $name)); + } + + $this->arguments[$name] = $value; + } +} diff --git a/vendor/symfony/console/Symfony/Component/Console/Input/Input.php b/vendor/symfony/console/Symfony/Component/Console/Input/Input.php new file mode 100755 index 0000000..494dd42 --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Input/Input.php @@ -0,0 +1,226 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Console\Input; + +/** + * Input is the base class for all concrete Input classes. + * + * Three concrete classes are provided by default: + * + * * `ArgvInput`: The input comes from the CLI arguments (argv) + * * `StringInput`: The input is provided as a string + * * `ArrayInput`: The input is provided as an array + * + * @author Fabien Potencier + */ +abstract class Input implements InputInterface +{ + /** + * @var InputDefinition + */ + protected $definition; + protected $options = array(); + protected $arguments = array(); + protected $interactive = true; + + /** + * Constructor. + * + * @param InputDefinition $definition A InputDefinition instance + */ + public function __construct(InputDefinition $definition = null) + { + if (null === $definition) { + $this->definition = new InputDefinition(); + } else { + $this->bind($definition); + $this->validate(); + } + } + + /** + * Binds the current Input instance with the given arguments and options. + * + * @param InputDefinition $definition A InputDefinition instance + */ + public function bind(InputDefinition $definition) + { + $this->arguments = array(); + $this->options = array(); + $this->definition = $definition; + + $this->parse(); + } + + /** + * Processes command line arguments. + */ + abstract protected function parse(); + + /** + * Validates the input. + * + * @throws \RuntimeException When not enough arguments are given + */ + public function validate() + { + if (count($this->arguments) < $this->definition->getArgumentRequiredCount()) { + throw new \RuntimeException('Not enough arguments.'); + } + } + + /** + * Checks if the input is interactive. + * + * @return bool Returns true if the input is interactive + */ + public function isInteractive() + { + return $this->interactive; + } + + /** + * Sets the input interactivity. + * + * @param bool $interactive If the input should be interactive + */ + public function setInteractive($interactive) + { + $this->interactive = (bool) $interactive; + } + + /** + * Returns the argument values. + * + * @return array An array of argument values + */ + public function getArguments() + { + return array_merge($this->definition->getArgumentDefaults(), $this->arguments); + } + + /** + * Returns the argument value for a given argument name. + * + * @param string $name The argument name + * + * @return mixed The argument value + * + * @throws \InvalidArgumentException When argument given doesn't exist + */ + public function getArgument($name) + { + if (!$this->definition->hasArgument($name)) { + throw new \InvalidArgumentException(sprintf('The "%s" argument does not exist.', $name)); + } + + return isset($this->arguments[$name]) ? $this->arguments[$name] : $this->definition->getArgument($name)->getDefault(); + } + + /** + * Sets an argument value by name. + * + * @param string $name The argument name + * @param string $value The argument value + * + * @throws \InvalidArgumentException When argument given doesn't exist + */ + public function setArgument($name, $value) + { + if (!$this->definition->hasArgument($name)) { + throw new \InvalidArgumentException(sprintf('The "%s" argument does not exist.', $name)); + } + + $this->arguments[$name] = $value; + } + + /** + * Returns true if an InputArgument object exists by name or position. + * + * @param string|int $name The InputArgument name or position + * + * @return bool true if the InputArgument object exists, false otherwise + */ + public function hasArgument($name) + { + return $this->definition->hasArgument($name); + } + + /** + * Returns the options values. + * + * @return array An array of option values + */ + public function getOptions() + { + return array_merge($this->definition->getOptionDefaults(), $this->options); + } + + /** + * Returns the option value for a given option name. + * + * @param string $name The option name + * + * @return mixed The option value + * + * @throws \InvalidArgumentException When option given doesn't exist + */ + public function getOption($name) + { + if (!$this->definition->hasOption($name)) { + throw new \InvalidArgumentException(sprintf('The "%s" option does not exist.', $name)); + } + + return isset($this->options[$name]) ? $this->options[$name] : $this->definition->getOption($name)->getDefault(); + } + + /** + * Sets an option value by name. + * + * @param string $name The option name + * @param string|bool $value The option value + * + * @throws \InvalidArgumentException When option given doesn't exist + */ + public function setOption($name, $value) + { + if (!$this->definition->hasOption($name)) { + throw new \InvalidArgumentException(sprintf('The "%s" option does not exist.', $name)); + } + + $this->options[$name] = $value; + } + + /** + * Returns true if an InputOption object exists by name. + * + * @param string $name The InputOption name + * + * @return bool true if the InputOption object exists, false otherwise + */ + public function hasOption($name) + { + return $this->definition->hasOption($name); + } + + /** + * Escapes a token through escapeshellarg if it contains unsafe chars + * + * @param string $token + * + * @return string + */ + public function escapeToken($token) + { + return preg_match('{^[\w-]+$}', $token) ? $token : escapeshellarg($token); + } +} diff --git a/vendor/symfony/console/Symfony/Component/Console/Input/InputArgument.php b/vendor/symfony/console/Symfony/Component/Console/Input/InputArgument.php new file mode 100755 index 0000000..bf9c99e --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Input/InputArgument.php @@ -0,0 +1,132 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Console\Input; + +/** + * Represents a command line argument. + * + * @author Fabien Potencier + * + * @api + */ +class InputArgument +{ + const REQUIRED = 1; + const OPTIONAL = 2; + const IS_ARRAY = 4; + + private $name; + private $mode; + private $default; + private $description; + + /** + * Constructor. + * + * @param string $name The argument name + * @param int $mode The argument mode: self::REQUIRED or self::OPTIONAL + * @param string $description A description text + * @param mixed $default The default value (for self::OPTIONAL mode only) + * + * @throws \InvalidArgumentException When argument mode is not valid + * + * @api + */ + public function __construct($name, $mode = null, $description = '', $default = null) + { + if (null === $mode) { + $mode = self::OPTIONAL; + } elseif (!is_int($mode) || $mode > 7 || $mode < 1) { + throw new \InvalidArgumentException(sprintf('Argument mode "%s" is not valid.', $mode)); + } + + $this->name = $name; + $this->mode = $mode; + $this->description = $description; + + $this->setDefault($default); + } + + /** + * Returns the argument name. + * + * @return string The argument name + */ + public function getName() + { + return $this->name; + } + + /** + * Returns true if the argument is required. + * + * @return bool true if parameter mode is self::REQUIRED, false otherwise + */ + public function isRequired() + { + return self::REQUIRED === (self::REQUIRED & $this->mode); + } + + /** + * Returns true if the argument can take multiple values. + * + * @return bool true if mode is self::IS_ARRAY, false otherwise + */ + public function isArray() + { + return self::IS_ARRAY === (self::IS_ARRAY & $this->mode); + } + + /** + * Sets the default value. + * + * @param mixed $default The default value + * + * @throws \LogicException When incorrect default value is given + */ + public function setDefault($default = null) + { + if (self::REQUIRED === $this->mode && null !== $default) { + throw new \LogicException('Cannot set a default value except for InputArgument::OPTIONAL mode.'); + } + + if ($this->isArray()) { + if (null === $default) { + $default = array(); + } elseif (!is_array($default)) { + throw new \LogicException('A default value for an array argument must be an array.'); + } + } + + $this->default = $default; + } + + /** + * Returns the default value. + * + * @return mixed The default value + */ + public function getDefault() + { + return $this->default; + } + + /** + * Returns the description text. + * + * @return string The description text + */ + public function getDescription() + { + return $this->description; + } +} diff --git a/vendor/symfony/console/Symfony/Component/Console/Input/InputAwareInterface.php b/vendor/symfony/console/Symfony/Component/Console/Input/InputAwareInterface.php new file mode 100755 index 0000000..d0f11e9 --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Input/InputAwareInterface.php @@ -0,0 +1,28 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Console\Input; + +/** + * InputAwareInterface should be implemented by classes that depends on the + * Console Input. + * + * @author Wouter J + */ +interface InputAwareInterface +{ + /** + * Sets the Console Input. + * + * @param InputInterface + */ + public function setInput(InputInterface $input); +} diff --git a/vendor/symfony/console/Symfony/Component/Console/Input/InputDefinition.php b/vendor/symfony/console/Symfony/Component/Console/Input/InputDefinition.php new file mode 100755 index 0000000..46579a2 --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Input/InputDefinition.php @@ -0,0 +1,458 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Console\Input; + +if (!defined('JSON_UNESCAPED_UNICODE')) { + define('JSON_UNESCAPED_SLASHES', 64); + define('JSON_UNESCAPED_UNICODE', 256); +} + +use Symfony\Component\Console\Descriptor\TextDescriptor; +use Symfony\Component\Console\Descriptor\XmlDescriptor; +use Symfony\Component\Console\Output\BufferedOutput; + +/** + * A InputDefinition represents a set of valid command line arguments and options. + * + * Usage: + * + * $definition = new InputDefinition(array( + * new InputArgument('name', InputArgument::REQUIRED), + * new InputOption('foo', 'f', InputOption::VALUE_REQUIRED), + * )); + * + * @author Fabien Potencier + * + * @api + */ +class InputDefinition +{ + private $arguments; + private $requiredCount; + private $hasAnArrayArgument = false; + private $hasOptional; + private $options; + private $shortcuts; + + /** + * Constructor. + * + * @param array $definition An array of InputArgument and InputOption instance + * + * @api + */ + public function __construct(array $definition = array()) + { + $this->setDefinition($definition); + } + + /** + * Sets the definition of the input. + * + * @param array $definition The definition array + * + * @api + */ + public function setDefinition(array $definition) + { + $arguments = array(); + $options = array(); + foreach ($definition as $item) { + if ($item instanceof InputOption) { + $options[] = $item; + } else { + $arguments[] = $item; + } + } + + $this->setArguments($arguments); + $this->setOptions($options); + } + + /** + * Sets the InputArgument objects. + * + * @param InputArgument[] $arguments An array of InputArgument objects + * + * @api + */ + public function setArguments($arguments = array()) + { + $this->arguments = array(); + $this->requiredCount = 0; + $this->hasOptional = false; + $this->hasAnArrayArgument = false; + $this->addArguments($arguments); + } + + /** + * Adds an array of InputArgument objects. + * + * @param InputArgument[] $arguments An array of InputArgument objects + * + * @api + */ + public function addArguments($arguments = array()) + { + if (null !== $arguments) { + foreach ($arguments as $argument) { + $this->addArgument($argument); + } + } + } + + /** + * Adds an InputArgument object. + * + * @param InputArgument $argument An InputArgument object + * + * @throws \LogicException When incorrect argument is given + * + * @api + */ + public function addArgument(InputArgument $argument) + { + if (isset($this->arguments[$argument->getName()])) { + throw new \LogicException(sprintf('An argument with name "%s" already exists.', $argument->getName())); + } + + if ($this->hasAnArrayArgument) { + throw new \LogicException('Cannot add an argument after an array argument.'); + } + + if ($argument->isRequired() && $this->hasOptional) { + throw new \LogicException('Cannot add a required argument after an optional one.'); + } + + if ($argument->isArray()) { + $this->hasAnArrayArgument = true; + } + + if ($argument->isRequired()) { + ++$this->requiredCount; + } else { + $this->hasOptional = true; + } + + $this->arguments[$argument->getName()] = $argument; + } + + /** + * Returns an InputArgument by name or by position. + * + * @param string|int $name The InputArgument name or position + * + * @return InputArgument An InputArgument object + * + * @throws \InvalidArgumentException When argument given doesn't exist + * + * @api + */ + public function getArgument($name) + { + if (!$this->hasArgument($name)) { + throw new \InvalidArgumentException(sprintf('The "%s" argument does not exist.', $name)); + } + + $arguments = is_int($name) ? array_values($this->arguments) : $this->arguments; + + return $arguments[$name]; + } + + /** + * Returns true if an InputArgument object exists by name or position. + * + * @param string|int $name The InputArgument name or position + * + * @return bool true if the InputArgument object exists, false otherwise + * + * @api + */ + public function hasArgument($name) + { + $arguments = is_int($name) ? array_values($this->arguments) : $this->arguments; + + return isset($arguments[$name]); + } + + /** + * Gets the array of InputArgument objects. + * + * @return InputArgument[] An array of InputArgument objects + * + * @api + */ + public function getArguments() + { + return $this->arguments; + } + + /** + * Returns the number of InputArguments. + * + * @return int The number of InputArguments + */ + public function getArgumentCount() + { + return $this->hasAnArrayArgument ? PHP_INT_MAX : count($this->arguments); + } + + /** + * Returns the number of required InputArguments. + * + * @return int The number of required InputArguments + */ + public function getArgumentRequiredCount() + { + return $this->requiredCount; + } + + /** + * Gets the default values. + * + * @return array An array of default values + */ + public function getArgumentDefaults() + { + $values = array(); + foreach ($this->arguments as $argument) { + $values[$argument->getName()] = $argument->getDefault(); + } + + return $values; + } + + /** + * Sets the InputOption objects. + * + * @param InputOption[] $options An array of InputOption objects + * + * @api + */ + public function setOptions($options = array()) + { + $this->options = array(); + $this->shortcuts = array(); + $this->addOptions($options); + } + + /** + * Adds an array of InputOption objects. + * + * @param InputOption[] $options An array of InputOption objects + * + * @api + */ + public function addOptions($options = array()) + { + foreach ($options as $option) { + $this->addOption($option); + } + } + + /** + * Adds an InputOption object. + * + * @param InputOption $option An InputOption object + * + * @throws \LogicException When option given already exist + * + * @api + */ + public function addOption(InputOption $option) + { + if (isset($this->options[$option->getName()]) && !$option->equals($this->options[$option->getName()])) { + throw new \LogicException(sprintf('An option named "%s" already exists.', $option->getName())); + } + + if ($option->getShortcut()) { + foreach (explode('|', $option->getShortcut()) as $shortcut) { + if (isset($this->shortcuts[$shortcut]) && !$option->equals($this->options[$this->shortcuts[$shortcut]])) { + throw new \LogicException(sprintf('An option with shortcut "%s" already exists.', $shortcut)); + } + } + } + + $this->options[$option->getName()] = $option; + if ($option->getShortcut()) { + foreach (explode('|', $option->getShortcut()) as $shortcut) { + $this->shortcuts[$shortcut] = $option->getName(); + } + } + } + + /** + * Returns an InputOption by name. + * + * @param string $name The InputOption name + * + * @return InputOption A InputOption object + * + * @throws \InvalidArgumentException When option given doesn't exist + * + * @api + */ + public function getOption($name) + { + if (!$this->hasOption($name)) { + throw new \InvalidArgumentException(sprintf('The "--%s" option does not exist.', $name)); + } + + return $this->options[$name]; + } + + /** + * Returns true if an InputOption object exists by name. + * + * @param string $name The InputOption name + * + * @return bool true if the InputOption object exists, false otherwise + * + * @api + */ + public function hasOption($name) + { + return isset($this->options[$name]); + } + + /** + * Gets the array of InputOption objects. + * + * @return InputOption[] An array of InputOption objects + * + * @api + */ + public function getOptions() + { + return $this->options; + } + + /** + * Returns true if an InputOption object exists by shortcut. + * + * @param string $name The InputOption shortcut + * + * @return bool true if the InputOption object exists, false otherwise + */ + public function hasShortcut($name) + { + return isset($this->shortcuts[$name]); + } + + /** + * Gets an InputOption by shortcut. + * + * @param string $shortcut the Shortcut name + * + * @return InputOption An InputOption object + */ + public function getOptionForShortcut($shortcut) + { + return $this->getOption($this->shortcutToName($shortcut)); + } + + /** + * Gets an array of default values. + * + * @return array An array of all default values + */ + public function getOptionDefaults() + { + $values = array(); + foreach ($this->options as $option) { + $values[$option->getName()] = $option->getDefault(); + } + + return $values; + } + + /** + * Returns the InputOption name given a shortcut. + * + * @param string $shortcut The shortcut + * + * @return string The InputOption name + * + * @throws \InvalidArgumentException When option given does not exist + */ + private function shortcutToName($shortcut) + { + if (!isset($this->shortcuts[$shortcut])) { + throw new \InvalidArgumentException(sprintf('The "-%s" option does not exist.', $shortcut)); + } + + return $this->shortcuts[$shortcut]; + } + + /** + * Gets the synopsis. + * + * @return string The synopsis + */ + public function getSynopsis() + { + $elements = array(); + foreach ($this->getOptions() as $option) { + $shortcut = $option->getShortcut() ? sprintf('-%s|', $option->getShortcut()) : ''; + $elements[] = sprintf('['.($option->isValueRequired() ? '%s--%s="..."' : ($option->isValueOptional() ? '%s--%s[="..."]' : '%s--%s')).']', $shortcut, $option->getName()); + } + + foreach ($this->getArguments() as $argument) { + $elements[] = sprintf($argument->isRequired() ? '%s' : '[%s]', $argument->getName().($argument->isArray() ? '1' : '')); + + if ($argument->isArray()) { + $elements[] = sprintf('... [%sN]', $argument->getName()); + } + } + + return implode(' ', $elements); + } + + /** + * Returns a textual representation of the InputDefinition. + * + * @return string A string representing the InputDefinition + * + * @deprecated Deprecated since version 2.3, to be removed in 3.0. + */ + public function asText() + { + $descriptor = new TextDescriptor(); + $output = new BufferedOutput(BufferedOutput::VERBOSITY_NORMAL, true); + $descriptor->describe($output, $this, array('raw_output' => true)); + + return $output->fetch(); + } + + /** + * Returns an XML representation of the InputDefinition. + * + * @param bool $asDom Whether to return a DOM or an XML string + * + * @return string|\DOMDocument An XML string representing the InputDefinition + * + * @deprecated Deprecated since version 2.3, to be removed in 3.0. + */ + public function asXml($asDom = false) + { + $descriptor = new XmlDescriptor(); + + if ($asDom) { + return $descriptor->getInputDefinitionDocument($this); + } + + $output = new BufferedOutput(); + $descriptor->describe($output, $this); + + return $output->fetch(); + } +} diff --git a/vendor/symfony/console/Symfony/Component/Console/Input/InputInterface.php b/vendor/symfony/console/Symfony/Component/Console/Input/InputInterface.php new file mode 100755 index 0000000..befa272 --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Input/InputInterface.php @@ -0,0 +1,152 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Console\Input; + +/** + * InputInterface is the interface implemented by all input classes. + * + * @author Fabien Potencier + */ +interface InputInterface +{ + /** + * Returns the first argument from the raw parameters (not parsed). + * + * @return string The value of the first argument or null otherwise + */ + public function getFirstArgument(); + + /** + * Returns true if the raw parameters (not parsed) contain a value. + * + * This method is to be used to introspect the input parameters + * before they have been validated. It must be used carefully. + * + * @param string|array $values The values to look for in the raw parameters (can be an array) + * + * @return bool true if the value is contained in the raw parameters + */ + public function hasParameterOption($values); + + /** + * Returns the value of a raw option (not parsed). + * + * This method is to be used to introspect the input parameters + * before they have been validated. It must be used carefully. + * + * @param string|array $values The value(s) to look for in the raw parameters (can be an array) + * @param mixed $default The default value to return if no result is found + * + * @return mixed The option value + */ + public function getParameterOption($values, $default = false); + + /** + * Binds the current Input instance with the given arguments and options. + * + * @param InputDefinition $definition A InputDefinition instance + */ + public function bind(InputDefinition $definition); + + /** + * Validates if arguments given are correct. + * + * Throws an exception when not enough arguments are given. + * + * @throws \RuntimeException + */ + public function validate(); + + /** + * Returns all the given arguments merged with the default values. + * + * @return array + */ + public function getArguments(); + + /** + * Gets argument by name. + * + * @param string $name The name of the argument + * + * @return mixed + */ + public function getArgument($name); + + /** + * Sets an argument value by name. + * + * @param string $name The argument name + * @param string $value The argument value + * + * @throws \InvalidArgumentException When argument given doesn't exist + */ + public function setArgument($name, $value); + + /** + * Returns true if an InputArgument object exists by name or position. + * + * @param string|int $name The InputArgument name or position + * + * @return bool true if the InputArgument object exists, false otherwise + */ + public function hasArgument($name); + + /** + * Returns all the given options merged with the default values. + * + * @return array + */ + public function getOptions(); + + /** + * Gets an option by name. + * + * @param string $name The name of the option + * + * @return mixed + */ + public function getOption($name); + + /** + * Sets an option value by name. + * + * @param string $name The option name + * @param string|bool $value The option value + * + * @throws \InvalidArgumentException When option given doesn't exist + */ + public function setOption($name, $value); + + /** + * Returns true if an InputOption object exists by name. + * + * @param string $name The InputOption name + * + * @return bool true if the InputOption object exists, false otherwise + */ + public function hasOption($name); + + /** + * Is this input means interactive? + * + * @return bool + */ + public function isInteractive(); + + /** + * Sets the input interactivity. + * + * @param bool $interactive If the input should be interactive + */ + public function setInteractive($interactive); +} diff --git a/vendor/symfony/console/Symfony/Component/Console/Input/InputOption.php b/vendor/symfony/console/Symfony/Component/Console/Input/InputOption.php new file mode 100755 index 0000000..18d05e9 --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Input/InputOption.php @@ -0,0 +1,212 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Console\Input; + +/** + * Represents a command line option. + * + * @author Fabien Potencier + * + * @api + */ +class InputOption +{ + const VALUE_NONE = 1; + const VALUE_REQUIRED = 2; + const VALUE_OPTIONAL = 4; + const VALUE_IS_ARRAY = 8; + + private $name; + private $shortcut; + private $mode; + private $default; + private $description; + + /** + * Constructor. + * + * @param string $name The option name + * @param string|array $shortcut The shortcuts, can be null, a string of shortcuts delimited by | or an array of shortcuts + * @param int $mode The option mode: One of the VALUE_* constants + * @param string $description A description text + * @param mixed $default The default value (must be null for self::VALUE_REQUIRED or self::VALUE_NONE) + * + * @throws \InvalidArgumentException If option mode is invalid or incompatible + * + * @api + */ + public function __construct($name, $shortcut = null, $mode = null, $description = '', $default = null) + { + if (0 === strpos($name, '--')) { + $name = substr($name, 2); + } + + if (empty($name)) { + throw new \InvalidArgumentException('An option name cannot be empty.'); + } + + if (empty($shortcut)) { + $shortcut = null; + } + + if (null !== $shortcut) { + if (is_array($shortcut)) { + $shortcut = implode('|', $shortcut); + } + $shortcuts = preg_split('{(\|)-?}', ltrim($shortcut, '-')); + $shortcuts = array_filter($shortcuts); + $shortcut = implode('|', $shortcuts); + + if (empty($shortcut)) { + throw new \InvalidArgumentException('An option shortcut cannot be empty.'); + } + } + + if (null === $mode) { + $mode = self::VALUE_NONE; + } elseif (!is_int($mode) || $mode > 15 || $mode < 1) { + throw new \InvalidArgumentException(sprintf('Option mode "%s" is not valid.', $mode)); + } + + $this->name = $name; + $this->shortcut = $shortcut; + $this->mode = $mode; + $this->description = $description; + + if ($this->isArray() && !$this->acceptValue()) { + throw new \InvalidArgumentException('Impossible to have an option mode VALUE_IS_ARRAY if the option does not accept a value.'); + } + + $this->setDefault($default); + } + + /** + * Returns the option shortcut. + * + * @return string The shortcut + */ + public function getShortcut() + { + return $this->shortcut; + } + + /** + * Returns the option name. + * + * @return string The name + */ + public function getName() + { + return $this->name; + } + + /** + * Returns true if the option accepts a value. + * + * @return bool true if value mode is not self::VALUE_NONE, false otherwise + */ + public function acceptValue() + { + return $this->isValueRequired() || $this->isValueOptional(); + } + + /** + * Returns true if the option requires a value. + * + * @return bool true if value mode is self::VALUE_REQUIRED, false otherwise + */ + public function isValueRequired() + { + return self::VALUE_REQUIRED === (self::VALUE_REQUIRED & $this->mode); + } + + /** + * Returns true if the option takes an optional value. + * + * @return bool true if value mode is self::VALUE_OPTIONAL, false otherwise + */ + public function isValueOptional() + { + return self::VALUE_OPTIONAL === (self::VALUE_OPTIONAL & $this->mode); + } + + /** + * Returns true if the option can take multiple values. + * + * @return bool true if mode is self::VALUE_IS_ARRAY, false otherwise + */ + public function isArray() + { + return self::VALUE_IS_ARRAY === (self::VALUE_IS_ARRAY & $this->mode); + } + + /** + * Sets the default value. + * + * @param mixed $default The default value + * + * @throws \LogicException When incorrect default value is given + */ + public function setDefault($default = null) + { + if (self::VALUE_NONE === (self::VALUE_NONE & $this->mode) && null !== $default) { + throw new \LogicException('Cannot set a default value when using InputOption::VALUE_NONE mode.'); + } + + if ($this->isArray()) { + if (null === $default) { + $default = array(); + } elseif (!is_array($default)) { + throw new \LogicException('A default value for an array option must be an array.'); + } + } + + $this->default = $this->acceptValue() ? $default : false; + } + + /** + * Returns the default value. + * + * @return mixed The default value + */ + public function getDefault() + { + return $this->default; + } + + /** + * Returns the description text. + * + * @return string The description text + */ + public function getDescription() + { + return $this->description; + } + + /** + * Checks whether the given option equals this one + * + * @param InputOption $option option to compare + * @return bool + */ + public function equals(InputOption $option) + { + return $option->getName() === $this->getName() + && $option->getShortcut() === $this->getShortcut() + && $option->getDefault() === $this->getDefault() + && $option->isArray() === $this->isArray() + && $option->isValueRequired() === $this->isValueRequired() + && $option->isValueOptional() === $this->isValueOptional() + ; + } +} diff --git a/vendor/symfony/console/Symfony/Component/Console/Input/StringInput.php b/vendor/symfony/console/Symfony/Component/Console/Input/StringInput.php new file mode 100755 index 0000000..7f87f71 --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Input/StringInput.php @@ -0,0 +1,85 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Console\Input; + +/** + * StringInput represents an input provided as a string. + * + * Usage: + * + * $input = new StringInput('foo --bar="foobar"'); + * + * @author Fabien Potencier + * + * @api + */ +class StringInput extends ArgvInput +{ + const REGEX_STRING = '([^\s]+?)(?:\s|(?setTokens($this->tokenize($input)); + + if (null !== $definition) { + $this->bind($definition); + } + } + + /** + * Tokenizes a string. + * + * @param string $input The input to tokenize + * + * @return array An array of tokens + * + * @throws \InvalidArgumentException When unable to parse input (should never happen) + */ + private function tokenize($input) + { + $tokens = array(); + $length = strlen($input); + $cursor = 0; + while ($cursor < $length) { + if (preg_match('/\s+/A', $input, $match, null, $cursor)) { + } elseif (preg_match('/([^="\'\s]+?)(=?)('.self::REGEX_QUOTED_STRING.'+)/A', $input, $match, null, $cursor)) { + $tokens[] = $match[1].$match[2].stripcslashes(str_replace(array('"\'', '\'"', '\'\'', '""'), '', substr($match[3], 1, strlen($match[3]) - 2))); + } elseif (preg_match('/'.self::REGEX_QUOTED_STRING.'/A', $input, $match, null, $cursor)) { + $tokens[] = stripcslashes(substr($match[0], 1, strlen($match[0]) - 2)); + } elseif (preg_match('/'.self::REGEX_STRING.'/A', $input, $match, null, $cursor)) { + $tokens[] = stripcslashes($match[1]); + } else { + // should never happen + // @codeCoverageIgnoreStart + throw new \InvalidArgumentException(sprintf('Unable to parse input near "... %s ..."', substr($input, $cursor, 10))); + // @codeCoverageIgnoreEnd + } + + $cursor += strlen($match[0]); + } + + return $tokens; + } +} diff --git a/vendor/symfony/console/Symfony/Component/Console/LICENSE b/vendor/symfony/console/Symfony/Component/Console/LICENSE new file mode 100755 index 0000000..0b3292c --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2004-2014 Fabien Potencier + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is furnished +to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/vendor/symfony/console/Symfony/Component/Console/Output/BufferedOutput.php b/vendor/symfony/console/Symfony/Component/Console/Output/BufferedOutput.php new file mode 100755 index 0000000..5682fc2 --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Output/BufferedOutput.php @@ -0,0 +1,48 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Console\Output; + +/** + * @author Jean-François Simon + */ +class BufferedOutput extends Output +{ + /** + * @var string + */ + private $buffer = ''; + + /** + * Empties buffer and returns its content. + * + * @return string + */ + public function fetch() + { + $content = $this->buffer; + $this->buffer = ''; + + return $content; + } + + /** + * {@inheritdoc} + */ + protected function doWrite($message, $newline) + { + $this->buffer .= $message; + + if ($newline) { + $this->buffer .= "\n"; + } + } +} diff --git a/vendor/symfony/console/Symfony/Component/Console/Output/ConsoleOutput.php b/vendor/symfony/console/Symfony/Component/Console/Output/ConsoleOutput.php new file mode 100755 index 0000000..b5eaf15 --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Output/ConsoleOutput.php @@ -0,0 +1,113 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Console\Output; + +use Symfony\Component\Console\Formatter\OutputFormatterInterface; + +/** + * ConsoleOutput is the default class for all CLI output. It uses STDOUT. + * + * This class is a convenient wrapper around `StreamOutput`. + * + * $output = new ConsoleOutput(); + * + * This is equivalent to: + * + * $output = new StreamOutput(fopen('php://stdout', 'w')); + * + * @author Fabien Potencier + * + * @api + */ +class ConsoleOutput extends StreamOutput implements ConsoleOutputInterface +{ + private $stderr; + + /** + * Constructor. + * + * @param int $verbosity The verbosity level (one of the VERBOSITY constants in OutputInterface) + * @param bool|null $decorated Whether to decorate messages (null for auto-guessing) + * @param OutputFormatterInterface|null $formatter Output formatter instance (null to use default OutputFormatter) + * + * @api + */ + public function __construct($verbosity = self::VERBOSITY_NORMAL, $decorated = null, OutputFormatterInterface $formatter = null) + { + $outputStream = 'php://stdout'; + if (!$this->hasStdoutSupport()) { + $outputStream = 'php://output'; + } + + parent::__construct(fopen($outputStream, 'w'), $verbosity, $decorated, $formatter); + + $this->stderr = new StreamOutput(fopen('php://stderr', 'w'), $verbosity, $decorated, $formatter); + } + + /** + * {@inheritdoc} + */ + public function setDecorated($decorated) + { + parent::setDecorated($decorated); + $this->stderr->setDecorated($decorated); + } + + /** + * {@inheritdoc} + */ + public function setFormatter(OutputFormatterInterface $formatter) + { + parent::setFormatter($formatter); + $this->stderr->setFormatter($formatter); + } + + /** + * {@inheritdoc} + */ + public function setVerbosity($level) + { + parent::setVerbosity($level); + $this->stderr->setVerbosity($level); + } + + /** + * {@inheritdoc} + */ + public function getErrorOutput() + { + return $this->stderr; + } + + /** + * {@inheritdoc} + */ + public function setErrorOutput(OutputInterface $error) + { + $this->stderr = $error; + } + + /** + * Returns true if current environment supports writing console output to + * STDOUT. + * + * IBM iSeries (OS400) exhibits character-encoding issues when writing to + * STDOUT and doesn't properly convert ASCII to EBCDIC, resulting in garbage + * output. + * + * @return bool + */ + protected function hasStdoutSupport() + { + return ('OS400' != php_uname('s')); + } +} diff --git a/vendor/symfony/console/Symfony/Component/Console/Output/ConsoleOutputInterface.php b/vendor/symfony/console/Symfony/Component/Console/Output/ConsoleOutputInterface.php new file mode 100755 index 0000000..5eb4fc7 --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Output/ConsoleOutputInterface.php @@ -0,0 +1,35 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Console\Output; + +/** + * ConsoleOutputInterface is the interface implemented by ConsoleOutput class. + * This adds information about stderr output stream. + * + * @author Dariusz Górecki + */ +interface ConsoleOutputInterface extends OutputInterface +{ + /** + * Gets the OutputInterface for errors. + * + * @return OutputInterface + */ + public function getErrorOutput(); + + /** + * Sets the OutputInterface used for errors. + * + * @param OutputInterface $error + */ + public function setErrorOutput(OutputInterface $error); +} diff --git a/vendor/symfony/console/Symfony/Component/Console/Output/NullOutput.php b/vendor/symfony/console/Symfony/Component/Console/Output/NullOutput.php new file mode 100755 index 0000000..c75cfca --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Output/NullOutput.php @@ -0,0 +1,93 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Console\Output; + +use Symfony\Component\Console\Formatter\OutputFormatter; +use Symfony\Component\Console\Formatter\OutputFormatterInterface; + +/** + * NullOutput suppresses all output. + * + * $output = new NullOutput(); + * + * @author Fabien Potencier + * @author Tobias Schultze + * + * @api + */ +class NullOutput implements OutputInterface +{ + /** + * {@inheritdoc} + */ + public function setFormatter(OutputFormatterInterface $formatter) + { + // do nothing + } + + /** + * {@inheritdoc} + */ + public function getFormatter() + { + // to comply with the interface we must return a OutputFormatterInterface + return new OutputFormatter(); + } + + /** + * {@inheritdoc} + */ + public function setDecorated($decorated) + { + // do nothing + } + + /** + * {@inheritdoc} + */ + public function isDecorated() + { + return false; + } + + /** + * {@inheritdoc} + */ + public function setVerbosity($level) + { + // do nothing + } + + /** + * {@inheritdoc} + */ + public function getVerbosity() + { + return self::VERBOSITY_QUIET; + } + + /** + * {@inheritdoc} + */ + public function writeln($messages, $type = self::OUTPUT_NORMAL) + { + // do nothing + } + + /** + * {@inheritdoc} + */ + public function write($messages, $newline = false, $type = self::OUTPUT_NORMAL) + { + // do nothing + } +} diff --git a/vendor/symfony/console/Symfony/Component/Console/Output/Output.php b/vendor/symfony/console/Symfony/Component/Console/Output/Output.php new file mode 100755 index 0000000..22c81cd --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Output/Output.php @@ -0,0 +1,165 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Console\Output; + +use Symfony\Component\Console\Formatter\OutputFormatterInterface; +use Symfony\Component\Console\Formatter\OutputFormatter; + +/** + * Base class for output classes. + * + * There are five levels of verbosity: + * + * * normal: no option passed (normal output) + * * verbose: -v (more output) + * * very verbose: -vv (highly extended output) + * * debug: -vvv (all debug output) + * * quiet: -q (no output) + * + * @author Fabien Potencier + * + * @api + */ +abstract class Output implements OutputInterface +{ + private $verbosity; + private $formatter; + + /** + * Constructor. + * + * @param int $verbosity The verbosity level (one of the VERBOSITY constants in OutputInterface) + * @param bool $decorated Whether to decorate messages + * @param OutputFormatterInterface|null $formatter Output formatter instance (null to use default OutputFormatter) + * + * @api + */ + public function __construct($verbosity = self::VERBOSITY_NORMAL, $decorated = false, OutputFormatterInterface $formatter = null) + { + $this->verbosity = null === $verbosity ? self::VERBOSITY_NORMAL : $verbosity; + $this->formatter = $formatter ?: new OutputFormatter(); + $this->formatter->setDecorated($decorated); + } + + /** + * {@inheritdoc} + */ + public function setFormatter(OutputFormatterInterface $formatter) + { + $this->formatter = $formatter; + } + + /** + * {@inheritdoc} + */ + public function getFormatter() + { + return $this->formatter; + } + + /** + * {@inheritdoc} + */ + public function setDecorated($decorated) + { + $this->formatter->setDecorated($decorated); + } + + /** + * {@inheritdoc} + */ + public function isDecorated() + { + return $this->formatter->isDecorated(); + } + + /** + * {@inheritdoc} + */ + public function setVerbosity($level) + { + $this->verbosity = (int) $level; + } + + /** + * {@inheritdoc} + */ + public function getVerbosity() + { + return $this->verbosity; + } + + public function isQuiet() + { + return self::VERBOSITY_QUIET === $this->verbosity; + } + + public function isVerbose() + { + return self::VERBOSITY_VERBOSE <= $this->verbosity; + } + + public function isVeryVerbose() + { + return self::VERBOSITY_VERY_VERBOSE <= $this->verbosity; + } + + public function isDebug() + { + return self::VERBOSITY_DEBUG <= $this->verbosity; + } + + /** + * {@inheritdoc} + */ + public function writeln($messages, $type = self::OUTPUT_NORMAL) + { + $this->write($messages, true, $type); + } + + /** + * {@inheritdoc} + */ + public function write($messages, $newline = false, $type = self::OUTPUT_NORMAL) + { + if (self::VERBOSITY_QUIET === $this->verbosity) { + return; + } + + $messages = (array) $messages; + + foreach ($messages as $message) { + switch ($type) { + case OutputInterface::OUTPUT_NORMAL: + $message = $this->formatter->format($message); + break; + case OutputInterface::OUTPUT_RAW: + break; + case OutputInterface::OUTPUT_PLAIN: + $message = strip_tags($this->formatter->format($message)); + break; + default: + throw new \InvalidArgumentException(sprintf('Unknown output type given (%s)', $type)); + } + + $this->doWrite($message, $newline); + } + } + + /** + * Writes a message to the output. + * + * @param string $message A message to write to the output + * @param bool $newline Whether to add a newline or not + */ + abstract protected function doWrite($message, $newline); +} diff --git a/vendor/symfony/console/Symfony/Component/Console/Output/OutputInterface.php b/vendor/symfony/console/Symfony/Component/Console/Output/OutputInterface.php new file mode 100755 index 0000000..ad128c6 --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Output/OutputInterface.php @@ -0,0 +1,113 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Console\Output; + +use Symfony\Component\Console\Formatter\OutputFormatterInterface; + +/** + * OutputInterface is the interface implemented by all Output classes. + * + * @author Fabien Potencier + * + * @api + */ +interface OutputInterface +{ + const VERBOSITY_QUIET = 0; + const VERBOSITY_NORMAL = 1; + const VERBOSITY_VERBOSE = 2; + const VERBOSITY_VERY_VERBOSE = 3; + const VERBOSITY_DEBUG = 4; + + const OUTPUT_NORMAL = 0; + const OUTPUT_RAW = 1; + const OUTPUT_PLAIN = 2; + + /** + * Writes a message to the output. + * + * @param string|array $messages The message as an array of lines or a single string + * @param bool $newline Whether to add a newline + * @param int $type The type of output (one of the OUTPUT constants) + * + * @throws \InvalidArgumentException When unknown output type is given + * + * @api + */ + public function write($messages, $newline = false, $type = self::OUTPUT_NORMAL); + + /** + * Writes a message to the output and adds a newline at the end. + * + * @param string|array $messages The message as an array of lines of a single string + * @param int $type The type of output (one of the OUTPUT constants) + * + * @throws \InvalidArgumentException When unknown output type is given + * + * @api + */ + public function writeln($messages, $type = self::OUTPUT_NORMAL); + + /** + * Sets the verbosity of the output. + * + * @param int $level The level of verbosity (one of the VERBOSITY constants) + * + * @api + */ + public function setVerbosity($level); + + /** + * Gets the current verbosity of the output. + * + * @return int The current level of verbosity (one of the VERBOSITY constants) + * + * @api + */ + public function getVerbosity(); + + /** + * Sets the decorated flag. + * + * @param bool $decorated Whether to decorate the messages + * + * @api + */ + public function setDecorated($decorated); + + /** + * Gets the decorated flag. + * + * @return bool true if the output will decorate messages, false otherwise + * + * @api + */ + public function isDecorated(); + + /** + * Sets output formatter. + * + * @param OutputFormatterInterface $formatter + * + * @api + */ + public function setFormatter(OutputFormatterInterface $formatter); + + /** + * Returns current output formatter instance. + * + * @return OutputFormatterInterface + * + * @api + */ + public function getFormatter(); +} diff --git a/vendor/symfony/console/Symfony/Component/Console/Output/StreamOutput.php b/vendor/symfony/console/Symfony/Component/Console/Output/StreamOutput.php new file mode 100755 index 0000000..6415fa2 --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Output/StreamOutput.php @@ -0,0 +1,107 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Console\Output; + +use Symfony\Component\Console\Formatter\OutputFormatterInterface; + +/** + * StreamOutput writes the output to a given stream. + * + * Usage: + * + * $output = new StreamOutput(fopen('php://stdout', 'w')); + * + * As `StreamOutput` can use any stream, you can also use a file: + * + * $output = new StreamOutput(fopen('/path/to/output.log', 'a', false)); + * + * @author Fabien Potencier + * + * @api + */ +class StreamOutput extends Output +{ + private $stream; + + /** + * Constructor. + * + * @param mixed $stream A stream resource + * @param int $verbosity The verbosity level (one of the VERBOSITY constants in OutputInterface) + * @param bool|null $decorated Whether to decorate messages (null for auto-guessing) + * @param OutputFormatterInterface|null $formatter Output formatter instance (null to use default OutputFormatter) + * + * @throws \InvalidArgumentException When first argument is not a real stream + * + * @api + */ + public function __construct($stream, $verbosity = self::VERBOSITY_NORMAL, $decorated = null, OutputFormatterInterface $formatter = null) + { + if (!is_resource($stream) || 'stream' !== get_resource_type($stream)) { + throw new \InvalidArgumentException('The StreamOutput class needs a stream as its first argument.'); + } + + $this->stream = $stream; + + if (null === $decorated) { + $decorated = $this->hasColorSupport(); + } + + parent::__construct($verbosity, $decorated, $formatter); + } + + /** + * Gets the stream attached to this StreamOutput instance. + * + * @return resource A stream resource + */ + public function getStream() + { + return $this->stream; + } + + /** + * {@inheritdoc} + */ + protected function doWrite($message, $newline) + { + if (false === @fwrite($this->stream, $message.($newline ? PHP_EOL : ''))) { + // @codeCoverageIgnoreStart + // should never happen + throw new \RuntimeException('Unable to write output.'); + // @codeCoverageIgnoreEnd + } + + fflush($this->stream); + } + + /** + * Returns true if the stream supports colorization. + * + * Colorization is disabled if not supported by the stream: + * + * - Windows without Ansicon and ConEmu + * - non tty consoles + * + * @return bool true if the stream supports colorization, false otherwise + */ + protected function hasColorSupport() + { + // @codeCoverageIgnoreStart + if (DIRECTORY_SEPARATOR == '\\') { + return false !== getenv('ANSICON') || 'ON' === getenv('ConEmuANSI'); + } + + return function_exists('posix_isatty') && @posix_isatty($this->stream); + // @codeCoverageIgnoreEnd + } +} diff --git a/vendor/symfony/console/Symfony/Component/Console/README.md b/vendor/symfony/console/Symfony/Component/Console/README.md new file mode 100755 index 0000000..bfc7044 --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/README.md @@ -0,0 +1,63 @@ +Console Component +================= + +Console eases the creation of beautiful and testable command line interfaces. + +The Application object manages the CLI application: + + use Symfony\Component\Console\Application; + + $console = new Application(); + $console->run(); + +The ``run()`` method parses the arguments and options passed on the command +line and executes the right command. + +Registering a new command can easily be done via the ``register()`` method, +which returns a ``Command`` instance: + + use Symfony\Component\Console\Input\InputInterface; + use Symfony\Component\Console\Input\InputArgument; + use Symfony\Component\Console\Input\InputOption; + use Symfony\Component\Console\Output\OutputInterface; + + $console + ->register('ls') + ->setDefinition(array( + new InputArgument('dir', InputArgument::REQUIRED, 'Directory name'), + )) + ->setDescription('Displays the files in the given directory') + ->setCode(function (InputInterface $input, OutputInterface $output) { + $dir = $input->getArgument('dir'); + + $output->writeln(sprintf('Dir listing for %s', $dir)); + }) + ; + +You can also register new commands via classes. + +The component provides a lot of features like output coloring, input and +output abstractions (so that you can easily unit-test your commands), +validation, automatic help messages, ... + +Tests +----- + +You can run the unit tests with the following command: + + $ cd path/to/Symfony/Component/Console/ + $ composer.phar install + $ phpunit + +Third Party +----------- + +`Resources/bin/hiddeninput.exe` is a third party binary provided within this +component. Find sources and license at https://github.com/Seldaek/hidden-input. + +Resources +--------- + +[The Console Component](http://symfony.com/doc/current/components/console.html) + +[How to create a Console Command](http://symfony.com/doc/current/cookbook/console/console_command.html) diff --git a/vendor/symfony/console/Symfony/Component/Console/Resources/bin/hiddeninput.exe b/vendor/symfony/console/Symfony/Component/Console/Resources/bin/hiddeninput.exe new file mode 100755 index 0000000..c8cf65e Binary files /dev/null and b/vendor/symfony/console/Symfony/Component/Console/Resources/bin/hiddeninput.exe differ diff --git a/vendor/symfony/console/Symfony/Component/Console/Shell.php b/vendor/symfony/console/Symfony/Component/Console/Shell.php new file mode 100755 index 0000000..75a1174 --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Shell.php @@ -0,0 +1,228 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Console; + +use Symfony\Component\Console\Input\StringInput; +use Symfony\Component\Console\Output\ConsoleOutput; +use Symfony\Component\Process\ProcessBuilder; +use Symfony\Component\Process\PhpExecutableFinder; + +/** + * A Shell wraps an Application to add shell capabilities to it. + * + * Support for history and completion only works with a PHP compiled + * with readline support (either --with-readline or --with-libedit) + * + * @author Fabien Potencier + * @author Martin Hasoň + */ +class Shell +{ + private $application; + private $history; + private $output; + private $hasReadline; + private $processIsolation = false; + + /** + * Constructor. + * + * If there is no readline support for the current PHP executable + * a \RuntimeException exception is thrown. + * + * @param Application $application An application instance + */ + public function __construct(Application $application) + { + $this->hasReadline = function_exists('readline'); + $this->application = $application; + $this->history = getenv('HOME').'/.history_'.$application->getName(); + $this->output = new ConsoleOutput(); + } + + /** + * Runs the shell. + */ + public function run() + { + $this->application->setAutoExit(false); + $this->application->setCatchExceptions(true); + + if ($this->hasReadline) { + readline_read_history($this->history); + readline_completion_function(array($this, 'autocompleter')); + } + + $this->output->writeln($this->getHeader()); + $php = null; + if ($this->processIsolation) { + $finder = new PhpExecutableFinder(); + $php = $finder->find(); + $this->output->writeln(<<Running with process isolation, you should consider this: + * each command is executed as separate process, + * commands don't support interactivity, all params must be passed explicitly, + * commands output is not colorized. + +EOF + ); + } + + while (true) { + $command = $this->readline(); + + if (false === $command) { + $this->output->writeln("\n"); + + break; + } + + if ($this->hasReadline) { + readline_add_history($command); + readline_write_history($this->history); + } + + if ($this->processIsolation) { + $pb = new ProcessBuilder(); + + $process = $pb + ->add($php) + ->add($_SERVER['argv'][0]) + ->add($command) + ->inheritEnvironmentVariables(true) + ->getProcess() + ; + + $output = $this->output; + $process->run(function ($type, $data) use ($output) { + $output->writeln($data); + }); + + $ret = $process->getExitCode(); + } else { + $ret = $this->application->run(new StringInput($command), $this->output); + } + + if (0 !== $ret) { + $this->output->writeln(sprintf('The command terminated with an error status (%s)', $ret)); + } + } + } + + /** + * Returns the shell header. + * + * @return string The header string + */ + protected function getHeader() + { + return <<{$this->application->getName()} shell ({$this->application->getVersion()}). + +At the prompt, type help for some help, +or list to get a list of available commands. + +To exit the shell, type ^D. + +EOF; + } + + /** + * Renders a prompt. + * + * @return string The prompt + */ + protected function getPrompt() + { + // using the formatter here is required when using readline + return $this->output->getFormatter()->format($this->application->getName().' > '); + } + + protected function getOutput() + { + return $this->output; + } + + protected function getApplication() + { + return $this->application; + } + + /** + * Tries to return autocompletion for the current entered text. + * + * @param string $text The last segment of the entered text + * + * @return bool|array A list of guessed strings or true + */ + private function autocompleter($text) + { + $info = readline_info(); + $text = substr($info['line_buffer'], 0, $info['end']); + + if ($info['point'] !== $info['end']) { + return true; + } + + // task name? + if (false === strpos($text, ' ') || !$text) { + return array_keys($this->application->all()); + } + + // options and arguments? + try { + $command = $this->application->find(substr($text, 0, strpos($text, ' '))); + } catch (\Exception $e) { + return true; + } + + $list = array('--help'); + foreach ($command->getDefinition()->getOptions() as $option) { + $list[] = '--'.$option->getName(); + } + + return $list; + } + + /** + * Reads a single line from standard input. + * + * @return string The single line from standard input + */ + private function readline() + { + if ($this->hasReadline) { + $line = readline($this->getPrompt()); + } else { + $this->output->write($this->getPrompt()); + $line = fgets(STDIN, 1024); + $line = (!$line && strlen($line) == 0) ? false : rtrim($line); + } + + return $line; + } + + public function getProcessIsolation() + { + return $this->processIsolation; + } + + public function setProcessIsolation($processIsolation) + { + $this->processIsolation = (bool) $processIsolation; + + if ($this->processIsolation && !class_exists('Symfony\\Component\\Process\\Process')) { + throw new \RuntimeException('Unable to isolate processes as the Symfony Process Component is not installed.'); + } + } +} diff --git a/vendor/symfony/console/Symfony/Component/Console/Tester/ApplicationTester.php b/vendor/symfony/console/Symfony/Component/Console/Tester/ApplicationTester.php new file mode 100755 index 0000000..1630a97 --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Tester/ApplicationTester.php @@ -0,0 +1,128 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Console\Tester; + +use Symfony\Component\Console\Application; +use Symfony\Component\Console\Input\ArrayInput; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Output\OutputInterface; +use Symfony\Component\Console\Output\StreamOutput; + +/** + * Eases the testing of console applications. + * + * When testing an application, don't forget to disable the auto exit flag: + * + * $application = new Application(); + * $application->setAutoExit(false); + * + * @author Fabien Potencier + */ +class ApplicationTester +{ + private $application; + private $input; + private $output; + private $statusCode; + + /** + * Constructor. + * + * @param Application $application An Application instance to test. + */ + public function __construct(Application $application) + { + $this->application = $application; + } + + /** + * Executes the application. + * + * Available options: + * + * * interactive: Sets the input interactive flag + * * decorated: Sets the output decorated flag + * * verbosity: Sets the output verbosity flag + * + * @param array $input An array of arguments and options + * @param array $options An array of options + * + * @return int The command exit code + */ + public function run(array $input, $options = array()) + { + $this->input = new ArrayInput($input); + if (isset($options['interactive'])) { + $this->input->setInteractive($options['interactive']); + } + + $this->output = new StreamOutput(fopen('php://memory', 'w', false)); + if (isset($options['decorated'])) { + $this->output->setDecorated($options['decorated']); + } + if (isset($options['verbosity'])) { + $this->output->setVerbosity($options['verbosity']); + } + + return $this->statusCode = $this->application->run($this->input, $this->output); + } + + /** + * Gets the display returned by the last execution of the application. + * + * @param bool $normalize Whether to normalize end of lines to \n or not + * + * @return string The display + */ + public function getDisplay($normalize = false) + { + rewind($this->output->getStream()); + + $display = stream_get_contents($this->output->getStream()); + + if ($normalize) { + $display = str_replace(PHP_EOL, "\n", $display); + } + + return $display; + } + + /** + * Gets the input instance used by the last execution of the application. + * + * @return InputInterface The current input instance + */ + public function getInput() + { + return $this->input; + } + + /** + * Gets the output instance used by the last execution of the application. + * + * @return OutputInterface The current output instance + */ + public function getOutput() + { + return $this->output; + } + + /** + * Gets the status code returned by the last execution of the application. + * + * @return int The status code + */ + public function getStatusCode() + { + return $this->statusCode; + } +} diff --git a/vendor/symfony/console/Symfony/Component/Console/Tester/CommandTester.php b/vendor/symfony/console/Symfony/Component/Console/Tester/CommandTester.php new file mode 100755 index 0000000..fe94d1e --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Tester/CommandTester.php @@ -0,0 +1,132 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Console\Tester; + +use Symfony\Component\Console\Command\Command; +use Symfony\Component\Console\Input\ArrayInput; +use Symfony\Component\Console\Output\StreamOutput; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Output\OutputInterface; + +/** + * Eases the testing of console commands. + * + * @author Fabien Potencier + */ +class CommandTester +{ + private $command; + private $input; + private $output; + private $statusCode; + + /** + * Constructor. + * + * @param Command $command A Command instance to test. + */ + public function __construct(Command $command) + { + $this->command = $command; + } + + /** + * Executes the command. + * + * Available options: + * + * * interactive: Sets the input interactive flag + * * decorated: Sets the output decorated flag + * * verbosity: Sets the output verbosity flag + * + * @param array $input An array of arguments and options + * @param array $options An array of options + * + * @return int The command exit code + */ + public function execute(array $input, array $options = array()) + { + // set the command name automatically if the application requires + // this argument and no command name was passed + if (!isset($input['command']) + && (null !== $application = $this->command->getApplication()) + && $application->getDefinition()->hasArgument('command') + ) { + $input['command'] = $this->command->getName(); + } + + $this->input = new ArrayInput($input); + if (isset($options['interactive'])) { + $this->input->setInteractive($options['interactive']); + } + + $this->output = new StreamOutput(fopen('php://memory', 'w', false)); + if (isset($options['decorated'])) { + $this->output->setDecorated($options['decorated']); + } + if (isset($options['verbosity'])) { + $this->output->setVerbosity($options['verbosity']); + } + + return $this->statusCode = $this->command->run($this->input, $this->output); + } + + /** + * Gets the display returned by the last execution of the command. + * + * @param bool $normalize Whether to normalize end of lines to \n or not + * + * @return string The display + */ + public function getDisplay($normalize = false) + { + rewind($this->output->getStream()); + + $display = stream_get_contents($this->output->getStream()); + + if ($normalize) { + $display = str_replace(PHP_EOL, "\n", $display); + } + + return $display; + } + + /** + * Gets the input instance used by the last execution of the command. + * + * @return InputInterface The current input instance + */ + public function getInput() + { + return $this->input; + } + + /** + * Gets the output instance used by the last execution of the command. + * + * @return OutputInterface The current output instance + */ + public function getOutput() + { + return $this->output; + } + + /** + * Gets the status code returned by the last execution of the application. + * + * @return int The status code + */ + public function getStatusCode() + { + return $this->statusCode; + } +} diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/ApplicationTest.php b/vendor/symfony/console/Symfony/Component/Console/Tests/ApplicationTest.php new file mode 100755 index 0000000..32a23aa --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Tests/ApplicationTest.php @@ -0,0 +1,951 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Console\Tests; + +use Symfony\Component\Console\Application; +use Symfony\Component\Console\Helper\HelperSet; +use Symfony\Component\Console\Helper\FormatterHelper; +use Symfony\Component\Console\Input\ArgvInput; +use Symfony\Component\Console\Input\ArrayInput; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Input\InputArgument; +use Symfony\Component\Console\Input\InputDefinition; +use Symfony\Component\Console\Input\InputOption; +use Symfony\Component\Console\Output\NullOutput; +use Symfony\Component\Console\Output\Output; +use Symfony\Component\Console\Output\OutputInterface; +use Symfony\Component\Console\Output\StreamOutput; +use Symfony\Component\Console\Tester\ApplicationTester; +use Symfony\Component\Console\Event\ConsoleCommandEvent; +use Symfony\Component\Console\Event\ConsoleExceptionEvent; +use Symfony\Component\Console\Event\ConsoleTerminateEvent; +use Symfony\Component\EventDispatcher\EventDispatcher; + +class ApplicationTest extends \PHPUnit_Framework_TestCase +{ + protected static $fixturesPath; + + public static function setUpBeforeClass() + { + self::$fixturesPath = realpath(__DIR__.'/Fixtures/'); + require_once self::$fixturesPath.'/FooCommand.php'; + require_once self::$fixturesPath.'/Foo1Command.php'; + require_once self::$fixturesPath.'/Foo2Command.php'; + require_once self::$fixturesPath.'/Foo3Command.php'; + require_once self::$fixturesPath.'/Foo4Command.php'; + require_once self::$fixturesPath.'/Foo5Command.php'; + require_once self::$fixturesPath.'/FoobarCommand.php'; + require_once self::$fixturesPath.'/BarBucCommand.php'; + } + + protected function normalizeLineBreaks($text) + { + return str_replace(PHP_EOL, "\n", $text); + } + + /** + * Replaces the dynamic placeholders of the command help text with a static version. + * The placeholder %command.full_name% includes the script path that is not predictable + * and can not be tested against. + */ + protected function ensureStaticCommandHelp(Application $application) + { + foreach ($application->all() as $command) { + $command->setHelp(str_replace('%command.full_name%', 'app/console %command.name%', $command->getHelp())); + } + } + + public function testConstructor() + { + $application = new Application('foo', 'bar'); + $this->assertEquals('foo', $application->getName(), '__construct() takes the application name as its first argument'); + $this->assertEquals('bar', $application->getVersion(), '__construct() takes the application version as its second argument'); + $this->assertEquals(array('help', 'list'), array_keys($application->all()), '__construct() registered the help and list commands by default'); + } + + public function testSetGetName() + { + $application = new Application(); + $application->setName('foo'); + $this->assertEquals('foo', $application->getName(), '->setName() sets the name of the application'); + } + + public function testSetGetVersion() + { + $application = new Application(); + $application->setVersion('bar'); + $this->assertEquals('bar', $application->getVersion(), '->setVersion() sets the version of the application'); + } + + public function testGetLongVersion() + { + $application = new Application('foo', 'bar'); + $this->assertEquals('foo version bar', $application->getLongVersion(), '->getLongVersion() returns the long version of the application'); + } + + public function testHelp() + { + $application = new Application(); + $this->assertStringEqualsFile(self::$fixturesPath.'/application_gethelp.txt', $this->normalizeLineBreaks($application->getHelp()), '->setHelp() returns a help message'); + } + + public function testAll() + { + $application = new Application(); + $commands = $application->all(); + $this->assertInstanceOf('Symfony\\Component\\Console\\Command\\HelpCommand', $commands['help'], '->all() returns the registered commands'); + + $application->add(new \FooCommand()); + $commands = $application->all('foo'); + $this->assertCount(1, $commands, '->all() takes a namespace as its first argument'); + } + + public function testRegister() + { + $application = new Application(); + $command = $application->register('foo'); + $this->assertEquals('foo', $command->getName(), '->register() registers a new command'); + } + + public function testAdd() + { + $application = new Application(); + $application->add($foo = new \FooCommand()); + $commands = $application->all(); + $this->assertEquals($foo, $commands['foo:bar'], '->add() registers a command'); + + $application = new Application(); + $application->addCommands(array($foo = new \FooCommand(), $foo1 = new \Foo1Command())); + $commands = $application->all(); + $this->assertEquals(array($foo, $foo1), array($commands['foo:bar'], $commands['foo:bar1']), '->addCommands() registers an array of commands'); + } + + /** + * @expectedException \LogicException + * @expectedExceptionMessage Command class "Foo5Command" is not correctly initialized. You probably forgot to call the parent constructor. + */ + public function testAddCommandWithEmptyConstructor() + { + $application = new Application(); + $application->add(new \Foo5Command()); + } + + public function testHasGet() + { + $application = new Application(); + $this->assertTrue($application->has('list'), '->has() returns true if a named command is registered'); + $this->assertFalse($application->has('afoobar'), '->has() returns false if a named command is not registered'); + + $application->add($foo = new \FooCommand()); + $this->assertTrue($application->has('afoobar'), '->has() returns true if an alias is registered'); + $this->assertEquals($foo, $application->get('foo:bar'), '->get() returns a command by name'); + $this->assertEquals($foo, $application->get('afoobar'), '->get() returns a command by alias'); + + $application = new Application(); + $application->add($foo = new \FooCommand()); + // simulate --help + $r = new \ReflectionObject($application); + $p = $r->getProperty('wantHelps'); + $p->setAccessible(true); + $p->setValue($application, true); + $command = $application->get('foo:bar'); + $this->assertInstanceOf('Symfony\Component\Console\Command\HelpCommand', $command, '->get() returns the help command if --help is provided as the input'); + } + + public function testSilentHelp() + { + $application = new Application(); + $application->setAutoExit(false); + $application->setCatchExceptions(false); + + $tester = new ApplicationTester($application); + $tester->run(array('-h' => true, '-q' => true), array('decorated' => false)); + + $this->assertEmpty($tester->getDisplay(true)); + } + + /** + * @expectedException \InvalidArgumentException + * @expectedExceptionMessage The command "foofoo" does not exist. + */ + public function testGetInvalidCommand() + { + $application = new Application(); + $application->get('foofoo'); + } + + public function testGetNamespaces() + { + $application = new Application(); + $application->add(new \FooCommand()); + $application->add(new \Foo1Command()); + $this->assertEquals(array('foo'), $application->getNamespaces(), '->getNamespaces() returns an array of unique used namespaces'); + } + + public function testFindNamespace() + { + $application = new Application(); + $application->add(new \FooCommand()); + $this->assertEquals('foo', $application->findNamespace('foo'), '->findNamespace() returns the given namespace if it exists'); + $this->assertEquals('foo', $application->findNamespace('f'), '->findNamespace() finds a namespace given an abbreviation'); + $application->add(new \Foo2Command()); + $this->assertEquals('foo', $application->findNamespace('foo'), '->findNamespace() returns the given namespace if it exists'); + } + + /** + * @expectedException \InvalidArgumentException + * @expectedExceptionMessage The namespace "f" is ambiguous (foo, foo1). + */ + public function testFindAmbiguousNamespace() + { + $application = new Application(); + $application->add(new \BarBucCommand()); + $application->add(new \FooCommand()); + $application->add(new \Foo2Command()); + $application->findNamespace('f'); + } + + /** + * @expectedException \InvalidArgumentException + * @expectedExceptionMessage There are no commands defined in the "bar" namespace. + */ + public function testFindInvalidNamespace() + { + $application = new Application(); + $application->findNamespace('bar'); + } + + /** + * @expectedException \InvalidArgumentException + * @expectedExceptionMessage Command "foo1" is not defined + */ + public function testFindUniqueNameButNamespaceName() + { + $application = new Application(); + $application->add(new \FooCommand()); + $application->add(new \Foo1Command()); + $application->add(new \Foo2Command()); + + $application->find($commandName = 'foo1'); + } + + public function testFind() + { + $application = new Application(); + $application->add(new \FooCommand()); + + $this->assertInstanceOf('FooCommand', $application->find('foo:bar'), '->find() returns a command if its name exists'); + $this->assertInstanceOf('Symfony\Component\Console\Command\HelpCommand', $application->find('h'), '->find() returns a command if its name exists'); + $this->assertInstanceOf('FooCommand', $application->find('f:bar'), '->find() returns a command if the abbreviation for the namespace exists'); + $this->assertInstanceOf('FooCommand', $application->find('f:b'), '->find() returns a command if the abbreviation for the namespace and the command name exist'); + $this->assertInstanceOf('FooCommand', $application->find('a'), '->find() returns a command if the abbreviation exists for an alias'); + } + + /** + * @dataProvider provideAmbiguousAbbreviations + */ + public function testFindWithAmbiguousAbbreviations($abbreviation, $expectedExceptionMessage) + { + $this->setExpectedException('InvalidArgumentException', $expectedExceptionMessage); + + $application = new Application(); + $application->add(new \FooCommand()); + $application->add(new \Foo1Command()); + $application->add(new \Foo2Command()); + + $application->find($abbreviation); + } + + public function provideAmbiguousAbbreviations() + { + return array( + array('f', 'Command "f" is not defined.'), + array('a', 'Command "a" is ambiguous (afoobar, afoobar1 and 1 more).'), + array('foo:b', 'Command "foo:b" is ambiguous (foo:bar, foo:bar1 and 1 more).') + ); + } + + public function testFindCommandEqualNamespace() + { + $application = new Application(); + $application->add(new \Foo3Command()); + $application->add(new \Foo4Command()); + + $this->assertInstanceOf('Foo3Command', $application->find('foo3:bar'), '->find() returns the good command even if a namespace has same name'); + $this->assertInstanceOf('Foo4Command', $application->find('foo3:bar:toh'), '->find() returns a command even if its namespace equals another command name'); + } + + public function testFindCommandWithAmbiguousNamespacesButUniqueName() + { + $application = new Application(); + $application->add(new \FooCommand()); + $application->add(new \FoobarCommand()); + + $this->assertInstanceOf('FoobarCommand', $application->find('f:f')); + } + + public function testFindCommandWithMissingNamespace() + { + $application = new Application(); + $application->add(new \Foo4Command()); + + $this->assertInstanceOf('Foo4Command', $application->find('f::t')); + } + + /** + * @dataProvider provideInvalidCommandNamesSingle + * @expectedException \InvalidArgumentException + * @expectedExceptionMessage Did you mean this + */ + public function testFindAlternativeExceptionMessageSingle($name) + { + $application = new Application(); + $application->add(new \Foo3Command()); + $application->find($name); + } + + public function provideInvalidCommandNamesSingle() + { + return array( + array('foo3:baR'), + array('foO3:bar') + ); + } + + public function testFindAlternativeExceptionMessageMultiple() + { + $application = new Application(); + $application->add(new \FooCommand()); + $application->add(new \Foo1Command()); + $application->add(new \Foo2Command()); + + // Command + plural + try { + $application->find('foo:baR'); + $this->fail('->find() throws an \InvalidArgumentException if command does not exist, with alternatives'); + } catch (\Exception $e) { + $this->assertInstanceOf('\InvalidArgumentException', $e, '->find() throws an \InvalidArgumentException if command does not exist, with alternatives'); + $this->assertRegExp('/Did you mean one of these/', $e->getMessage(), '->find() throws an \InvalidArgumentException if command does not exist, with alternatives'); + $this->assertRegExp('/foo1:bar/', $e->getMessage()); + $this->assertRegExp('/foo:bar/', $e->getMessage()); + } + + // Namespace + plural + try { + $application->find('foo2:bar'); + $this->fail('->find() throws an \InvalidArgumentException if command does not exist, with alternatives'); + } catch (\Exception $e) { + $this->assertInstanceOf('\InvalidArgumentException', $e, '->find() throws an \InvalidArgumentException if command does not exist, with alternatives'); + $this->assertRegExp('/Did you mean one of these/', $e->getMessage(), '->find() throws an \InvalidArgumentException if command does not exist, with alternatives'); + $this->assertRegExp('/foo1/', $e->getMessage()); + } + + $application->add(new \Foo3Command()); + $application->add(new \Foo4Command()); + + // Subnamespace + plural + try { + $a = $application->find('foo3:'); + $this->fail('->find() should throw an \InvalidArgumentException if a command is ambiguous because of a subnamespace, with alternatives'); + } catch (\Exception $e) { + $this->assertInstanceOf('\InvalidArgumentException', $e); + $this->assertRegExp('/foo3:bar/', $e->getMessage()); + $this->assertRegExp('/foo3:bar:toh/', $e->getMessage()); + } + } + + public function testFindAlternativeCommands() + { + $application = new Application(); + + $application->add(new \FooCommand()); + $application->add(new \Foo1Command()); + $application->add(new \Foo2Command()); + + try { + $application->find($commandName = 'Unknown command'); + $this->fail('->find() throws an \InvalidArgumentException if command does not exist'); + } catch (\Exception $e) { + $this->assertInstanceOf('\InvalidArgumentException', $e, '->find() throws an \InvalidArgumentException if command does not exist'); + $this->assertEquals(sprintf('Command "%s" is not defined.', $commandName), $e->getMessage(), '->find() throws an \InvalidArgumentException if command does not exist, without alternatives'); + } + + // Test if "bar1" command throw an "\InvalidArgumentException" and does not contain + // "foo:bar" as alternative because "bar1" is too far from "foo:bar" + try { + $application->find($commandName = 'bar1'); + $this->fail('->find() throws an \InvalidArgumentException if command does not exist'); + } catch (\Exception $e) { + $this->assertInstanceOf('\InvalidArgumentException', $e, '->find() throws an \InvalidArgumentException if command does not exist'); + $this->assertRegExp(sprintf('/Command "%s" is not defined./', $commandName), $e->getMessage(), '->find() throws an \InvalidArgumentException if command does not exist, with alternatives'); + $this->assertRegExp('/afoobar1/', $e->getMessage(), '->find() throws an \InvalidArgumentException if command does not exist, with alternative : "afoobar1"'); + $this->assertRegExp('/foo:bar1/', $e->getMessage(), '->find() throws an \InvalidArgumentException if command does not exist, with alternative : "foo:bar1"'); + $this->assertNotRegExp('/foo:bar(?>!1)/', $e->getMessage(), '->find() throws an \InvalidArgumentException if command does not exist, without "foo:bar" alternative'); + } + } + + public function testFindAlternativeCommandsWithAnAlias() + { + $fooCommand = new \FooCommand(); + $fooCommand->setAliases(array('foo2')); + + $application = new Application(); + $application->add($fooCommand); + + $result = $application->find('foo'); + + $this->assertSame($fooCommand, $result); + } + + public function testFindAlternativeNamespace() + { + $application = new Application(); + + $application->add(new \FooCommand()); + $application->add(new \Foo1Command()); + $application->add(new \Foo2Command()); + $application->add(new \foo3Command()); + + try { + $application->find('Unknown-namespace:Unknown-command'); + $this->fail('->find() throws an \InvalidArgumentException if namespace does not exist'); + } catch (\Exception $e) { + $this->assertInstanceOf('\InvalidArgumentException', $e, '->find() throws an \InvalidArgumentException if namespace does not exist'); + $this->assertEquals('There are no commands defined in the "Unknown-namespace" namespace.', $e->getMessage(), '->find() throws an \InvalidArgumentException if namespace does not exist, without alternatives'); + } + + try { + $application->find('foo2:command'); + $this->fail('->find() throws an \InvalidArgumentException if namespace does not exist'); + } catch (\Exception $e) { + $this->assertInstanceOf('\InvalidArgumentException', $e, '->find() throws an \InvalidArgumentException if namespace does not exist'); + $this->assertRegExp('/There are no commands defined in the "foo2" namespace./', $e->getMessage(), '->find() throws an \InvalidArgumentException if namespace does not exist, with alternative'); + $this->assertRegExp('/foo/', $e->getMessage(), '->find() throws an \InvalidArgumentException if namespace does not exist, with alternative : "foo"'); + $this->assertRegExp('/foo1/', $e->getMessage(), '->find() throws an \InvalidArgumentException if namespace does not exist, with alternative : "foo1"'); + $this->assertRegExp('/foo3/', $e->getMessage(), '->find() throws an \InvalidArgumentException if namespace does not exist, with alternative : "foo3"'); + } + } + + public function testFindNamespaceDoesNotFailOnDeepSimilarNamespaces() + { + $application = $this->getMock('Symfony\Component\Console\Application', array('getNamespaces')); + $application->expects($this->once()) + ->method('getNamespaces') + ->will($this->returnValue(array('foo:sublong', 'bar:sub'))); + + $this->assertEquals('foo:sublong', $application->findNamespace('f:sub')); + } + + public function testSetCatchExceptions() + { + $application = $this->getMock('Symfony\Component\Console\Application', array('getTerminalWidth')); + $application->setAutoExit(false); + $application->expects($this->any()) + ->method('getTerminalWidth') + ->will($this->returnValue(120)); + $tester = new ApplicationTester($application); + + $application->setCatchExceptions(true); + $tester->run(array('command' => 'foo'), array('decorated' => false)); + $this->assertStringEqualsFile(self::$fixturesPath.'/application_renderexception1.txt', $tester->getDisplay(true), '->setCatchExceptions() sets the catch exception flag'); + + $application->setCatchExceptions(false); + try { + $tester->run(array('command' => 'foo'), array('decorated' => false)); + $this->fail('->setCatchExceptions() sets the catch exception flag'); + } catch (\Exception $e) { + $this->assertInstanceOf('\Exception', $e, '->setCatchExceptions() sets the catch exception flag'); + $this->assertEquals('Command "foo" is not defined.', $e->getMessage(), '->setCatchExceptions() sets the catch exception flag'); + } + } + + public function testAsText() + { + $application = new Application(); + $application->add(new \FooCommand()); + $this->ensureStaticCommandHelp($application); + $this->assertStringEqualsFile(self::$fixturesPath.'/application_astext1.txt', $this->normalizeLineBreaks($application->asText()), '->asText() returns a text representation of the application'); + $this->assertStringEqualsFile(self::$fixturesPath.'/application_astext2.txt', $this->normalizeLineBreaks($application->asText('foo')), '->asText() returns a text representation of the application'); + } + + public function testAsXml() + { + $application = new Application(); + $application->add(new \FooCommand()); + $this->ensureStaticCommandHelp($application); + $this->assertXmlStringEqualsXmlFile(self::$fixturesPath.'/application_asxml1.txt', $application->asXml(), '->asXml() returns an XML representation of the application'); + $this->assertXmlStringEqualsXmlFile(self::$fixturesPath.'/application_asxml2.txt', $application->asXml('foo'), '->asXml() returns an XML representation of the application'); + } + + public function testRenderException() + { + $application = $this->getMock('Symfony\Component\Console\Application', array('getTerminalWidth')); + $application->setAutoExit(false); + $application->expects($this->any()) + ->method('getTerminalWidth') + ->will($this->returnValue(120)); + $tester = new ApplicationTester($application); + + $tester->run(array('command' => 'foo'), array('decorated' => false)); + $this->assertStringEqualsFile(self::$fixturesPath.'/application_renderexception1.txt', $tester->getDisplay(true), '->renderException() renders a pretty exception'); + + $tester->run(array('command' => 'foo'), array('decorated' => false, 'verbosity' => Output::VERBOSITY_VERBOSE)); + $this->assertContains('Exception trace', $tester->getDisplay(), '->renderException() renders a pretty exception with a stack trace when verbosity is verbose'); + + $tester->run(array('command' => 'list', '--foo' => true), array('decorated' => false)); + $this->assertStringEqualsFile(self::$fixturesPath.'/application_renderexception2.txt', $tester->getDisplay(true), '->renderException() renders the command synopsis when an exception occurs in the context of a command'); + + $application->add(new \Foo3Command()); + $tester = new ApplicationTester($application); + $tester->run(array('command' => 'foo3:bar'), array('decorated' => false)); + $this->assertStringEqualsFile(self::$fixturesPath.'/application_renderexception3.txt', $tester->getDisplay(true), '->renderException() renders a pretty exceptions with previous exceptions'); + + $tester->run(array('command' => 'foo3:bar'), array('decorated' => true)); + $this->assertStringEqualsFile(self::$fixturesPath.'/application_renderexception3decorated.txt', $tester->getDisplay(true), '->renderException() renders a pretty exceptions with previous exceptions'); + + $application = $this->getMock('Symfony\Component\Console\Application', array('getTerminalWidth')); + $application->setAutoExit(false); + $application->expects($this->any()) + ->method('getTerminalWidth') + ->will($this->returnValue(32)); + $tester = new ApplicationTester($application); + + $tester->run(array('command' => 'foo'), array('decorated' => false)); + $this->assertStringEqualsFile(self::$fixturesPath.'/application_renderexception4.txt', $tester->getDisplay(true), '->renderException() wraps messages when they are bigger than the terminal'); + } + + public function testRenderExceptionWithDoubleWidthCharacters() + { + $application = $this->getMock('Symfony\Component\Console\Application', array('getTerminalWidth')); + $application->setAutoExit(false); + $application->expects($this->any()) + ->method('getTerminalWidth') + ->will($this->returnValue(120)); + $application->register('foo')->setCode(function () { + throw new \Exception('エラーメッセージ'); + }); + $tester = new ApplicationTester($application); + + $tester->run(array('command' => 'foo'), array('decorated' => false)); + $this->assertStringEqualsFile(self::$fixturesPath.'/application_renderexception_doublewidth1.txt', $tester->getDisplay(true), '->renderException() renderes a pretty exceptions with previous exceptions'); + + $tester->run(array('command' => 'foo'), array('decorated' => true)); + $this->assertStringEqualsFile(self::$fixturesPath.'/application_renderexception_doublewidth1decorated.txt', $tester->getDisplay(true), '->renderException() renderes a pretty exceptions with previous exceptions'); + + $application = $this->getMock('Symfony\Component\Console\Application', array('getTerminalWidth')); + $application->setAutoExit(false); + $application->expects($this->any()) + ->method('getTerminalWidth') + ->will($this->returnValue(32)); + $application->register('foo')->setCode(function () { + throw new \Exception('コマンドã®å®Ÿè¡Œä¸­ã«ã‚¨ãƒ©ãƒ¼ãŒç™ºç”Ÿã—ã¾ã—ãŸã€‚'); + }); + $tester = new ApplicationTester($application); + $tester->run(array('command' => 'foo'), array('decorated' => false)); + $this->assertStringEqualsFile(self::$fixturesPath.'/application_renderexception_doublewidth2.txt', $tester->getDisplay(true), '->renderException() wraps messages when they are bigger than the terminal'); + } + + public function testRun() + { + $application = new Application(); + $application->setAutoExit(false); + $application->setCatchExceptions(false); + $application->add($command = new \Foo1Command()); + $_SERVER['argv'] = array('cli.php', 'foo:bar1'); + + ob_start(); + $application->run(); + ob_end_clean(); + + $this->assertInstanceOf('Symfony\Component\Console\Input\ArgvInput', $command->input, '->run() creates an ArgvInput by default if none is given'); + $this->assertInstanceOf('Symfony\Component\Console\Output\ConsoleOutput', $command->output, '->run() creates a ConsoleOutput by default if none is given'); + + $application = new Application(); + $application->setAutoExit(false); + $application->setCatchExceptions(false); + + $this->ensureStaticCommandHelp($application); + $tester = new ApplicationTester($application); + + $tester->run(array(), array('decorated' => false)); + $this->assertStringEqualsFile(self::$fixturesPath.'/application_run1.txt', $tester->getDisplay(true), '->run() runs the list command if no argument is passed'); + + $tester->run(array('--help' => true), array('decorated' => false)); + $this->assertStringEqualsFile(self::$fixturesPath.'/application_run2.txt', $tester->getDisplay(true), '->run() runs the help command if --help is passed'); + + $tester->run(array('-h' => true), array('decorated' => false)); + $this->assertStringEqualsFile(self::$fixturesPath.'/application_run2.txt', $tester->getDisplay(true), '->run() runs the help command if -h is passed'); + + $tester->run(array('command' => 'list', '--help' => true), array('decorated' => false)); + $this->assertStringEqualsFile(self::$fixturesPath.'/application_run3.txt', $tester->getDisplay(true), '->run() displays the help if --help is passed'); + + $tester->run(array('command' => 'list', '-h' => true), array('decorated' => false)); + $this->assertStringEqualsFile(self::$fixturesPath.'/application_run3.txt', $tester->getDisplay(true), '->run() displays the help if -h is passed'); + + $tester->run(array('--ansi' => true)); + $this->assertTrue($tester->getOutput()->isDecorated(), '->run() forces color output if --ansi is passed'); + + $tester->run(array('--no-ansi' => true)); + $this->assertFalse($tester->getOutput()->isDecorated(), '->run() forces color output to be disabled if --no-ansi is passed'); + + $tester->run(array('--version' => true), array('decorated' => false)); + $this->assertStringEqualsFile(self::$fixturesPath.'/application_run4.txt', $tester->getDisplay(true), '->run() displays the program version if --version is passed'); + + $tester->run(array('-V' => true), array('decorated' => false)); + $this->assertStringEqualsFile(self::$fixturesPath.'/application_run4.txt', $tester->getDisplay(true), '->run() displays the program version if -v is passed'); + + $tester->run(array('command' => 'list', '--quiet' => true)); + $this->assertSame('', $tester->getDisplay(), '->run() removes all output if --quiet is passed'); + + $tester->run(array('command' => 'list', '-q' => true)); + $this->assertSame('', $tester->getDisplay(), '->run() removes all output if -q is passed'); + + $tester->run(array('command' => 'list', '--verbose' => true)); + $this->assertSame(Output::VERBOSITY_VERBOSE, $tester->getOutput()->getVerbosity(), '->run() sets the output to verbose if --verbose is passed'); + + $tester->run(array('command' => 'list', '--verbose' => 1)); + $this->assertSame(Output::VERBOSITY_VERBOSE, $tester->getOutput()->getVerbosity(), '->run() sets the output to verbose if --verbose=1 is passed'); + + $tester->run(array('command' => 'list', '--verbose' => 2)); + $this->assertSame(Output::VERBOSITY_VERY_VERBOSE, $tester->getOutput()->getVerbosity(), '->run() sets the output to very verbose if --verbose=2 is passed'); + + $tester->run(array('command' => 'list', '--verbose' => 3)); + $this->assertSame(Output::VERBOSITY_DEBUG, $tester->getOutput()->getVerbosity(), '->run() sets the output to debug if --verbose=3 is passed'); + + $tester->run(array('command' => 'list', '--verbose' => 4)); + $this->assertSame(Output::VERBOSITY_VERBOSE, $tester->getOutput()->getVerbosity(), '->run() sets the output to verbose if unknown --verbose level is passed'); + + $tester->run(array('command' => 'list', '-v' => true)); + $this->assertSame(Output::VERBOSITY_VERBOSE, $tester->getOutput()->getVerbosity(), '->run() sets the output to verbose if -v is passed'); + + $tester->run(array('command' => 'list', '-vv' => true)); + $this->assertSame(Output::VERBOSITY_VERY_VERBOSE, $tester->getOutput()->getVerbosity(), '->run() sets the output to verbose if -v is passed'); + + $tester->run(array('command' => 'list', '-vvv' => true)); + $this->assertSame(Output::VERBOSITY_DEBUG, $tester->getOutput()->getVerbosity(), '->run() sets the output to verbose if -v is passed'); + + $application = new Application(); + $application->setAutoExit(false); + $application->setCatchExceptions(false); + $application->add(new \FooCommand()); + $tester = new ApplicationTester($application); + + $tester->run(array('command' => 'foo:bar', '--no-interaction' => true), array('decorated' => false)); + $this->assertSame('called'.PHP_EOL, $tester->getDisplay(), '->run() does not call interact() if --no-interaction is passed'); + + $tester->run(array('command' => 'foo:bar', '-n' => true), array('decorated' => false)); + $this->assertSame('called'.PHP_EOL, $tester->getDisplay(), '->run() does not call interact() if -n is passed'); + } + + /** + * Issue #9285 + * + * If the "verbose" option is just before an argument in ArgvInput, + * an argument value should not be treated as verbosity value. + * This test will fail with "Not enough arguments." if broken + */ + public function testVerboseValueNotBreakArguments() + { + $application = new Application(); + $application->setAutoExit(false); + $application->setCatchExceptions(false); + $application->add(new \FooCommand()); + + $output = new StreamOutput(fopen('php://memory', 'w', false)); + + $input = new ArgvInput(array('cli.php', '-v', 'foo:bar')); + $application->run($input, $output); + + $input = new ArgvInput(array('cli.php', '--verbose', 'foo:bar')); + $application->run($input, $output); + } + + public function testRunReturnsIntegerExitCode() + { + $exception = new \Exception('', 4); + + $application = $this->getMock('Symfony\Component\Console\Application', array('doRun')); + $application->setAutoExit(false); + $application->expects($this->once()) + ->method('doRun') + ->will($this->throwException($exception)); + + $exitCode = $application->run(new ArrayInput(array()), new NullOutput()); + + $this->assertSame(4, $exitCode, '->run() returns integer exit code extracted from raised exception'); + } + + public function testRunReturnsExitCodeOneForExceptionCodeZero() + { + $exception = new \Exception('', 0); + + $application = $this->getMock('Symfony\Component\Console\Application', array('doRun')); + $application->setAutoExit(false); + $application->expects($this->once()) + ->method('doRun') + ->will($this->throwException($exception)); + + $exitCode = $application->run(new ArrayInput(array()), new NullOutput()); + + $this->assertSame(1, $exitCode, '->run() returns exit code 1 when exception code is 0'); + } + + /** + * @expectedException \LogicException + * @dataProvider getAddingAlreadySetDefinitionElementData + */ + public function testAddingAlreadySetDefinitionElementData($def) + { + $application = new Application(); + $application->setAutoExit(false); + $application->setCatchExceptions(false); + $application + ->register('foo') + ->setDefinition(array($def)) + ->setCode(function (InputInterface $input, OutputInterface $output) {}) + ; + + $input = new ArrayInput(array('command' => 'foo')); + $output = new NullOutput(); + $application->run($input, $output); + } + + public function getAddingAlreadySetDefinitionElementData() + { + return array( + array(new InputArgument('command', InputArgument::REQUIRED)), + array(new InputOption('quiet', '', InputOption::VALUE_NONE)), + array(new InputOption('query', 'q', InputOption::VALUE_NONE)), + ); + } + + public function testGetDefaultHelperSetReturnsDefaultValues() + { + $application = new Application(); + $application->setAutoExit(false); + $application->setCatchExceptions(false); + + $helperSet = $application->getHelperSet(); + + $this->assertTrue($helperSet->has('formatter')); + $this->assertTrue($helperSet->has('dialog')); + $this->assertTrue($helperSet->has('progress')); + } + + public function testAddingSingleHelperSetOverwritesDefaultValues() + { + $application = new Application(); + $application->setAutoExit(false); + $application->setCatchExceptions(false); + + $application->setHelperSet(new HelperSet(array(new FormatterHelper()))); + + $helperSet = $application->getHelperSet(); + + $this->assertTrue($helperSet->has('formatter')); + + // no other default helper set should be returned + $this->assertFalse($helperSet->has('dialog')); + $this->assertFalse($helperSet->has('progress')); + } + + public function testOverwritingDefaultHelperSetOverwritesDefaultValues() + { + $application = new CustomApplication(); + $application->setAutoExit(false); + $application->setCatchExceptions(false); + + $application->setHelperSet(new HelperSet(array(new FormatterHelper()))); + + $helperSet = $application->getHelperSet(); + + $this->assertTrue($helperSet->has('formatter')); + + // no other default helper set should be returned + $this->assertFalse($helperSet->has('dialog')); + $this->assertFalse($helperSet->has('progress')); + } + + public function testGetDefaultInputDefinitionReturnsDefaultValues() + { + $application = new Application(); + $application->setAutoExit(false); + $application->setCatchExceptions(false); + + $inputDefinition = $application->getDefinition(); + + $this->assertTrue($inputDefinition->hasArgument('command')); + + $this->assertTrue($inputDefinition->hasOption('help')); + $this->assertTrue($inputDefinition->hasOption('quiet')); + $this->assertTrue($inputDefinition->hasOption('verbose')); + $this->assertTrue($inputDefinition->hasOption('version')); + $this->assertTrue($inputDefinition->hasOption('ansi')); + $this->assertTrue($inputDefinition->hasOption('no-ansi')); + $this->assertTrue($inputDefinition->hasOption('no-interaction')); + } + + public function testOverwritingDefaultInputDefinitionOverwritesDefaultValues() + { + $application = new CustomApplication(); + $application->setAutoExit(false); + $application->setCatchExceptions(false); + + $inputDefinition = $application->getDefinition(); + + // check whether the default arguments and options are not returned any more + $this->assertFalse($inputDefinition->hasArgument('command')); + + $this->assertFalse($inputDefinition->hasOption('help')); + $this->assertFalse($inputDefinition->hasOption('quiet')); + $this->assertFalse($inputDefinition->hasOption('verbose')); + $this->assertFalse($inputDefinition->hasOption('version')); + $this->assertFalse($inputDefinition->hasOption('ansi')); + $this->assertFalse($inputDefinition->hasOption('no-ansi')); + $this->assertFalse($inputDefinition->hasOption('no-interaction')); + + $this->assertTrue($inputDefinition->hasOption('custom')); + } + + public function testSettingCustomInputDefinitionOverwritesDefaultValues() + { + $application = new Application(); + $application->setAutoExit(false); + $application->setCatchExceptions(false); + + $application->setDefinition(new InputDefinition(array(new InputOption('--custom', '-c', InputOption::VALUE_NONE, 'Set the custom input definition.')))); + + $inputDefinition = $application->getDefinition(); + + // check whether the default arguments and options are not returned any more + $this->assertFalse($inputDefinition->hasArgument('command')); + + $this->assertFalse($inputDefinition->hasOption('help')); + $this->assertFalse($inputDefinition->hasOption('quiet')); + $this->assertFalse($inputDefinition->hasOption('verbose')); + $this->assertFalse($inputDefinition->hasOption('version')); + $this->assertFalse($inputDefinition->hasOption('ansi')); + $this->assertFalse($inputDefinition->hasOption('no-ansi')); + $this->assertFalse($inputDefinition->hasOption('no-interaction')); + + $this->assertTrue($inputDefinition->hasOption('custom')); + } + + public function testRunWithDispatcher() + { + $application = new Application(); + $application->setAutoExit(false); + $application->setDispatcher($this->getDispatcher()); + + $application->register('foo')->setCode(function (InputInterface $input, OutputInterface $output) { + $output->write('foo.'); + }); + + $tester = new ApplicationTester($application); + $tester->run(array('command' => 'foo')); + $this->assertEquals('before.foo.after.', $tester->getDisplay()); + } + + /** + * @expectedException \LogicException + * @expectedExceptionMessage caught + */ + public function testRunWithExceptionAndDispatcher() + { + $application = new Application(); + $application->setDispatcher($this->getDispatcher()); + $application->setAutoExit(false); + $application->setCatchExceptions(false); + + $application->register('foo')->setCode(function (InputInterface $input, OutputInterface $output) { + throw new \RuntimeException('foo'); + }); + + $tester = new ApplicationTester($application); + $tester->run(array('command' => 'foo')); + } + + public function testRunDispatchesAllEventsWithException() + { + $application = new Application(); + $application->setDispatcher($this->getDispatcher()); + $application->setAutoExit(false); + + $application->register('foo')->setCode(function (InputInterface $input, OutputInterface $output) { + $output->write('foo.'); + + throw new \RuntimeException('foo'); + }); + + $tester = new ApplicationTester($application); + $tester->run(array('command' => 'foo')); + $this->assertContains('before.foo.after.caught.', $tester->getDisplay()); + } + + public function testTerminalDimensions() + { + $application = new Application(); + $originalDimensions = $application->getTerminalDimensions(); + $this->assertCount(2, $originalDimensions); + + $width = 80; + if ($originalDimensions[0] == $width) { + $width = 100; + } + + $application->setTerminalDimensions($width, 80); + $this->assertSame(array($width, 80), $application->getTerminalDimensions()); + } + + protected function getDispatcher() + { + $dispatcher = new EventDispatcher(); + $dispatcher->addListener('console.command', function (ConsoleCommandEvent $event) { + $event->getOutput()->write('before.'); + }); + $dispatcher->addListener('console.terminate', function (ConsoleTerminateEvent $event) { + $event->getOutput()->write('after.'); + + $event->setExitCode(128); + }); + $dispatcher->addListener('console.exception', function (ConsoleExceptionEvent $event) { + $event->getOutput()->writeln('caught.'); + + $event->setException(new \LogicException('caught.', $event->getExitCode(), $event->getException())); + }); + + return $dispatcher; + } +} + +class CustomApplication extends Application +{ + /** + * Overwrites the default input definition. + * + * @return InputDefinition An InputDefinition instance + */ + protected function getDefaultInputDefinition() + { + return new InputDefinition(array(new InputOption('--custom', '-c', InputOption::VALUE_NONE, 'Set the custom input definition.'))); + } + + /** + * Gets the default helper set with the helpers that should always be available. + * + * @return HelperSet A HelperSet instance + */ + protected function getDefaultHelperSet() + { + return new HelperSet(array(new FormatterHelper())); + } +} diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Command/CommandTest.php b/vendor/symfony/console/Symfony/Component/Console/Tests/Command/CommandTest.php new file mode 100755 index 0000000..872bb7f --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Tests/Command/CommandTest.php @@ -0,0 +1,338 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Console\Tests\Command; + +use Symfony\Component\Console\Command\Command; +use Symfony\Component\Console\Helper\FormatterHelper; +use Symfony\Component\Console\Application; +use Symfony\Component\Console\Input\InputDefinition; +use Symfony\Component\Console\Input\InputArgument; +use Symfony\Component\Console\Input\InputOption; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Input\StringInput; +use Symfony\Component\Console\Output\OutputInterface; +use Symfony\Component\Console\Output\NullOutput; +use Symfony\Component\Console\Tester\CommandTester; + +class CommandTest extends \PHPUnit_Framework_TestCase +{ + protected static $fixturesPath; + + public static function setUpBeforeClass() + { + self::$fixturesPath = __DIR__.'/../Fixtures/'; + require_once self::$fixturesPath.'/TestCommand.php'; + } + + public function testConstructor() + { + $command = new Command('foo:bar'); + $this->assertEquals('foo:bar', $command->getName(), '__construct() takes the command name as its first argument'); + } + + /** + * @expectedException \LogicException + * @expectedExceptionMessage The command name cannot be empty. + */ + public function testCommandNameCannotBeEmpty() + { + new Command(); + } + + public function testSetApplication() + { + $application = new Application(); + $command = new \TestCommand(); + $command->setApplication($application); + $this->assertEquals($application, $command->getApplication(), '->setApplication() sets the current application'); + } + + public function testSetGetDefinition() + { + $command = new \TestCommand(); + $ret = $command->setDefinition($definition = new InputDefinition()); + $this->assertEquals($command, $ret, '->setDefinition() implements a fluent interface'); + $this->assertEquals($definition, $command->getDefinition(), '->setDefinition() sets the current InputDefinition instance'); + $command->setDefinition(array(new InputArgument('foo'), new InputOption('bar'))); + $this->assertTrue($command->getDefinition()->hasArgument('foo'), '->setDefinition() also takes an array of InputArguments and InputOptions as an argument'); + $this->assertTrue($command->getDefinition()->hasOption('bar'), '->setDefinition() also takes an array of InputArguments and InputOptions as an argument'); + $command->setDefinition(new InputDefinition()); + } + + public function testAddArgument() + { + $command = new \TestCommand(); + $ret = $command->addArgument('foo'); + $this->assertEquals($command, $ret, '->addArgument() implements a fluent interface'); + $this->assertTrue($command->getDefinition()->hasArgument('foo'), '->addArgument() adds an argument to the command'); + } + + public function testAddOption() + { + $command = new \TestCommand(); + $ret = $command->addOption('foo'); + $this->assertEquals($command, $ret, '->addOption() implements a fluent interface'); + $this->assertTrue($command->getDefinition()->hasOption('foo'), '->addOption() adds an option to the command'); + } + + public function testGetNamespaceGetNameSetName() + { + $command = new \TestCommand(); + $this->assertEquals('namespace:name', $command->getName(), '->getName() returns the command name'); + $command->setName('foo'); + $this->assertEquals('foo', $command->getName(), '->setName() sets the command name'); + + $ret = $command->setName('foobar:bar'); + $this->assertEquals($command, $ret, '->setName() implements a fluent interface'); + $this->assertEquals('foobar:bar', $command->getName(), '->setName() sets the command name'); + } + + /** + * @dataProvider provideInvalidCommandNames + */ + public function testInvalidCommandNames($name) + { + $this->setExpectedException('InvalidArgumentException', sprintf('Command name "%s" is invalid.', $name)); + + $command = new \TestCommand(); + $command->setName($name); + } + + public function provideInvalidCommandNames() + { + return array( + array(''), + array('foo:') + ); + } + + public function testGetSetDescription() + { + $command = new \TestCommand(); + $this->assertEquals('description', $command->getDescription(), '->getDescription() returns the description'); + $ret = $command->setDescription('description1'); + $this->assertEquals($command, $ret, '->setDescription() implements a fluent interface'); + $this->assertEquals('description1', $command->getDescription(), '->setDescription() sets the description'); + } + + public function testGetSetHelp() + { + $command = new \TestCommand(); + $this->assertEquals('help', $command->getHelp(), '->getHelp() returns the help'); + $ret = $command->setHelp('help1'); + $this->assertEquals($command, $ret, '->setHelp() implements a fluent interface'); + $this->assertEquals('help1', $command->getHelp(), '->setHelp() sets the help'); + } + + public function testGetProcessedHelp() + { + $command = new \TestCommand(); + $command->setHelp('The %command.name% command does... Example: php %command.full_name%.'); + $this->assertContains('The namespace:name command does...', $command->getProcessedHelp(), '->getProcessedHelp() replaces %command.name% correctly'); + $this->assertNotContains('%command.full_name%', $command->getProcessedHelp(), '->getProcessedHelp() replaces %command.full_name%'); + } + + public function testGetSetAliases() + { + $command = new \TestCommand(); + $this->assertEquals(array('name'), $command->getAliases(), '->getAliases() returns the aliases'); + $ret = $command->setAliases(array('name1')); + $this->assertEquals($command, $ret, '->setAliases() implements a fluent interface'); + $this->assertEquals(array('name1'), $command->getAliases(), '->setAliases() sets the aliases'); + } + + public function testGetSynopsis() + { + $command = new \TestCommand(); + $command->addOption('foo'); + $command->addArgument('foo'); + $this->assertEquals('namespace:name [--foo] [foo]', $command->getSynopsis(), '->getSynopsis() returns the synopsis'); + } + + public function testGetHelper() + { + $application = new Application(); + $command = new \TestCommand(); + $command->setApplication($application); + $formatterHelper = new FormatterHelper(); + $this->assertEquals($formatterHelper->getName(), $command->getHelper('formatter')->getName(), '->getHelper() returns the correct helper'); + } + + public function testGet() + { + $application = new Application(); + $command = new \TestCommand(); + $command->setApplication($application); + $formatterHelper = new FormatterHelper(); + $this->assertEquals($formatterHelper->getName(), $command->getHelper('formatter')->getName(), '->__get() returns the correct helper'); + } + + public function testMergeApplicationDefinition() + { + $application1 = new Application(); + $application1->getDefinition()->addArguments(array(new InputArgument('foo'))); + $application1->getDefinition()->addOptions(array(new InputOption('bar'))); + $command = new \TestCommand(); + $command->setApplication($application1); + $command->setDefinition($definition = new InputDefinition(array(new InputArgument('bar'), new InputOption('foo')))); + + $r = new \ReflectionObject($command); + $m = $r->getMethod('mergeApplicationDefinition'); + $m->setAccessible(true); + $m->invoke($command); + $this->assertTrue($command->getDefinition()->hasArgument('foo'), '->mergeApplicationDefinition() merges the application arguments and the command arguments'); + $this->assertTrue($command->getDefinition()->hasArgument('bar'), '->mergeApplicationDefinition() merges the application arguments and the command arguments'); + $this->assertTrue($command->getDefinition()->hasOption('foo'), '->mergeApplicationDefinition() merges the application options and the command options'); + $this->assertTrue($command->getDefinition()->hasOption('bar'), '->mergeApplicationDefinition() merges the application options and the command options'); + + $m->invoke($command); + $this->assertEquals(3, $command->getDefinition()->getArgumentCount(), '->mergeApplicationDefinition() does not try to merge twice the application arguments and options'); + } + + public function testMergeApplicationDefinitionWithoutArgsThenWithArgsAddsArgs() + { + $application1 = new Application(); + $application1->getDefinition()->addArguments(array(new InputArgument('foo'))); + $application1->getDefinition()->addOptions(array(new InputOption('bar'))); + $command = new \TestCommand(); + $command->setApplication($application1); + $command->setDefinition($definition = new InputDefinition(array())); + + $r = new \ReflectionObject($command); + $m = $r->getMethod('mergeApplicationDefinition'); + $m->setAccessible(true); + $m->invoke($command, false); + $this->assertTrue($command->getDefinition()->hasOption('bar'), '->mergeApplicationDefinition(false) merges the application and the commmand options'); + $this->assertFalse($command->getDefinition()->hasArgument('foo'), '->mergeApplicationDefinition(false) does not merge the application arguments'); + + $m->invoke($command, true); + $this->assertTrue($command->getDefinition()->hasArgument('foo'), '->mergeApplicationDefinition(true) merges the application arguments and the command arguments'); + + $m->invoke($command); + $this->assertEquals(2, $command->getDefinition()->getArgumentCount(), '->mergeApplicationDefinition() does not try to merge twice the application arguments'); + } + + public function testRunInteractive() + { + $tester = new CommandTester(new \TestCommand()); + + $tester->execute(array(), array('interactive' => true)); + + $this->assertEquals('interact called'.PHP_EOL.'execute called'.PHP_EOL, $tester->getDisplay(), '->run() calls the interact() method if the input is interactive'); + } + + public function testRunNonInteractive() + { + $tester = new CommandTester(new \TestCommand()); + + $tester->execute(array(), array('interactive' => false)); + + $this->assertEquals('execute called'.PHP_EOL, $tester->getDisplay(), '->run() does not call the interact() method if the input is not interactive'); + } + + /** + * @expectedException \LogicException + * @expectedExceptionMessage You must override the execute() method in the concrete command class. + */ + public function testExecuteMethodNeedsToBeOverriden() + { + $command = new Command('foo'); + $command->run(new StringInput(''), new NullOutput()); + } + + /** + * @expectedException \InvalidArgumentException + * @expectedExceptionMessage The "--bar" option does not exist. + */ + public function testRunWithInvalidOption() + { + $command = new \TestCommand(); + $tester = new CommandTester($command); + $tester->execute(array('--bar' => true)); + } + + public function testRunReturnsIntegerExitCode() + { + $command = new \TestCommand(); + $exitCode = $command->run(new StringInput(''), new NullOutput()); + $this->assertSame(0, $exitCode, '->run() returns integer exit code (treats null as 0)'); + + $command = $this->getMock('TestCommand', array('execute')); + $command->expects($this->once()) + ->method('execute') + ->will($this->returnValue('2.3')); + $exitCode = $command->run(new StringInput(''), new NullOutput()); + $this->assertSame(2, $exitCode, '->run() returns integer exit code (casts numeric to int)'); + } + + public function testRunReturnsAlwaysInteger() + { + $command = new \TestCommand(); + + $this->assertSame(0, $command->run(new StringInput(''), new NullOutput())); + } + + public function testSetCode() + { + $command = new \TestCommand(); + $ret = $command->setCode(function (InputInterface $input, OutputInterface $output) { + $output->writeln('from the code...'); + }); + $this->assertEquals($command, $ret, '->setCode() implements a fluent interface'); + $tester = new CommandTester($command); + $tester->execute(array()); + $this->assertEquals('interact called'.PHP_EOL.'from the code...'.PHP_EOL, $tester->getDisplay()); + } + + public function testSetCodeWithNonClosureCallable() + { + $command = new \TestCommand(); + $ret = $command->setCode(array($this, 'callableMethodCommand')); + $this->assertEquals($command, $ret, '->setCode() implements a fluent interface'); + $tester = new CommandTester($command); + $tester->execute(array()); + $this->assertEquals('interact called'.PHP_EOL.'from the code...'.PHP_EOL, $tester->getDisplay()); + } + + /** + * @expectedException \InvalidArgumentException + * @expectedExceptionMessage Invalid callable provided to Command::setCode. + */ + public function testSetCodeWithNonCallable() + { + $command = new \TestCommand(); + $command->setCode(array($this, 'nonExistentMethod')); + } + + public function callableMethodCommand(InputInterface $input, OutputInterface $output) + { + $output->writeln('from the code...'); + } + + public function testAsText() + { + $command = new \TestCommand(); + $command->setApplication(new Application()); + $tester = new CommandTester($command); + $tester->execute(array('command' => $command->getName())); + $this->assertStringEqualsFile(self::$fixturesPath.'/command_astext.txt', $command->asText(), '->asText() returns a text representation of the command'); + } + + public function testAsXml() + { + $command = new \TestCommand(); + $command->setApplication(new Application()); + $tester = new CommandTester($command); + $tester->execute(array('command' => $command->getName())); + $this->assertXmlStringEqualsXmlFile(self::$fixturesPath.'/command_asxml.txt', $command->asXml(), '->asXml() returns an XML representation of the command'); + } +} diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Command/HelpCommandTest.php b/vendor/symfony/console/Symfony/Component/Console/Tests/Command/HelpCommandTest.php new file mode 100755 index 0000000..ea69c8b --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Tests/Command/HelpCommandTest.php @@ -0,0 +1,64 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Console\Tests\Command; + +use Symfony\Component\Console\Tester\CommandTester; +use Symfony\Component\Console\Command\HelpCommand; +use Symfony\Component\Console\Command\ListCommand; +use Symfony\Component\Console\Application; + +class HelpCommandTest extends \PHPUnit_Framework_TestCase +{ + public function testExecuteForCommandAlias() + { + $command = new HelpCommand(); + $command->setApplication(new Application()); + $commandTester = new CommandTester($command); + $commandTester->execute(array('command_name' => 'li')); + $this->assertRegExp('/list \[--xml\] \[--raw\] \[--format="\.\.\."\] \[namespace\]/', $commandTester->getDisplay(), '->execute() returns a text help for the given command alias'); + } + + public function testExecuteForCommand() + { + $command = new HelpCommand(); + $commandTester = new CommandTester($command); + $command->setCommand(new ListCommand()); + $commandTester->execute(array()); + $this->assertRegExp('/list \[--xml\] \[--raw\] \[--format="\.\.\."\] \[namespace\]/', $commandTester->getDisplay(), '->execute() returns a text help for the given command'); + } + + public function testExecuteForCommandWithXmlOption() + { + $command = new HelpCommand(); + $commandTester = new CommandTester($command); + $command->setCommand(new ListCommand()); + $commandTester->execute(array('--format' => 'xml')); + $this->assertRegExp('/getDisplay(), '->execute() returns an XML help text if --xml is passed'); + } + + public function testExecuteForApplicationCommand() + { + $application = new Application(); + $commandTester = new CommandTester($application->get('help')); + $commandTester->execute(array('command_name' => 'list')); + $this->assertRegExp('/list \[--xml\] \[--raw\] \[--format="\.\.\."\] \[namespace\]/', $commandTester->getDisplay(), '->execute() returns a text help for the given command'); + } + + public function testExecuteForApplicationCommandWithXmlOption() + { + $application = new Application(); + $commandTester = new CommandTester($application->get('help')); + $commandTester->execute(array('command_name' => 'list', '--format' => 'xml')); + $this->assertRegExp('/list \[--xml\] \[--raw\] \[--format="\.\.\."\] \[namespace\]/', $commandTester->getDisplay(), '->execute() returns a text help for the given command'); + $this->assertRegExp('/getDisplay(), '->execute() returns an XML help text if --format=xml is passed'); + } +} diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Command/ListCommandTest.php b/vendor/symfony/console/Symfony/Component/Console/Tests/Command/ListCommandTest.php new file mode 100755 index 0000000..1df06f5 --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Tests/Command/ListCommandTest.php @@ -0,0 +1,65 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Console\Tests\Command; + +use Symfony\Component\Console\Tester\CommandTester; +use Symfony\Component\Console\Application; + +class ListCommandTest extends \PHPUnit_Framework_TestCase +{ + public function testExecuteListsCommands() + { + $application = new Application(); + $commandTester = new CommandTester($command = $application->get('list')); + $commandTester->execute(array('command' => $command->getName()), array('decorated' => false)); + + $this->assertRegExp('/help Displays help for a command/', $commandTester->getDisplay(), '->execute() returns a list of available commands'); + } + + public function testExecuteListsCommandsWithXmlOption() + { + $application = new Application(); + $commandTester = new CommandTester($command = $application->get('list')); + $commandTester->execute(array('command' => $command->getName(), '--format' => 'xml')); + $this->assertRegExp('//', $commandTester->getDisplay(), '->execute() returns a list of available commands in XML if --xml is passed'); + } + + public function testExecuteListsCommandsWithRawOption() + { + $application = new Application(); + $commandTester = new CommandTester($command = $application->get('list')); + $commandTester->execute(array('command' => $command->getName(), '--raw' => true)); + $output = <<assertEquals($output, $commandTester->getDisplay(true)); + } + + public function testExecuteListsCommandsWithNamespaceArgument() + { + + require_once(realpath(__DIR__.'/../Fixtures/FooCommand.php')); + $application = new Application(); + $application->add(new \FooCommand()); + $commandTester = new CommandTester($command = $application->get('list')); + $commandTester->execute(array('command' => $command->getName(), 'namespace' => 'foo', '--raw' => true)); + $output = <<assertEquals($output, $commandTester->getDisplay(true)); + } +} diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Descriptor/AbstractDescriptorTest.php b/vendor/symfony/console/Symfony/Component/Console/Tests/Descriptor/AbstractDescriptorTest.php new file mode 100755 index 0000000..406c659 --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Tests/Descriptor/AbstractDescriptorTest.php @@ -0,0 +1,105 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Console\Tests\Descriptor; + +use Symfony\Component\Console\Application; +use Symfony\Component\Console\Command\Command; +use Symfony\Component\Console\Input\InputArgument; +use Symfony\Component\Console\Input\InputDefinition; +use Symfony\Component\Console\Input\InputOption; +use Symfony\Component\Console\Output\BufferedOutput; + +abstract class AbstractDescriptorTest extends \PHPUnit_Framework_TestCase +{ + /** @dataProvider getDescribeInputArgumentTestData */ + public function testDescribeInputArgument(InputArgument $argument, $expectedDescription) + { + $this->assertDescription($expectedDescription, $argument); + } + + /** @dataProvider getDescribeInputOptionTestData */ + public function testDescribeInputOption(InputOption $option, $expectedDescription) + { + $this->assertDescription($expectedDescription, $option); + } + + /** @dataProvider getDescribeInputDefinitionTestData */ + public function testDescribeInputDefinition(InputDefinition $definition, $expectedDescription) + { + $this->assertDescription($expectedDescription, $definition); + } + + /** @dataProvider getDescribeCommandTestData */ + public function testDescribeCommand(Command $command, $expectedDescription) + { + $this->assertDescription($expectedDescription, $command); + } + + /** @dataProvider getDescribeApplicationTestData */ + public function testDescribeApplication(Application $application, $expectedDescription) + { + // Replaces the dynamic placeholders of the command help text with a static version. + // The placeholder %command.full_name% includes the script path that is not predictable + // and can not be tested against. + foreach ($application->all() as $command) { + $command->setHelp(str_replace('%command.full_name%', 'app/console %command.name%', $command->getHelp())); + } + + $this->assertDescription($expectedDescription, $application); + } + + public function getDescribeInputArgumentTestData() + { + return $this->getDescriptionTestData(ObjectsProvider::getInputArguments()); + } + + public function getDescribeInputOptionTestData() + { + return $this->getDescriptionTestData(ObjectsProvider::getInputOptions()); + } + + public function getDescribeInputDefinitionTestData() + { + return $this->getDescriptionTestData(ObjectsProvider::getInputDefinitions()); + } + + public function getDescribeCommandTestData() + { + return $this->getDescriptionTestData(ObjectsProvider::getCommands()); + } + + public function getDescribeApplicationTestData() + { + return $this->getDescriptionTestData(ObjectsProvider::getApplications()); + } + + abstract protected function getDescriptor(); + abstract protected function getFormat(); + + private function getDescriptionTestData(array $objects) + { + $data = array(); + foreach ($objects as $name => $object) { + $description = file_get_contents(sprintf('%s/../Fixtures/%s.%s', __DIR__, $name, $this->getFormat())); + $data[] = array($object, $description); + } + + return $data; + } + + private function assertDescription($expectedDescription, $describedObject) + { + $output = new BufferedOutput(BufferedOutput::VERBOSITY_NORMAL, true); + $this->getDescriptor()->describe($output, $describedObject, array('raw_output' => true)); + $this->assertEquals(trim($expectedDescription), trim(str_replace(PHP_EOL, "\n", $output->fetch()))); + } +} diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Descriptor/JsonDescriptorTest.php b/vendor/symfony/console/Symfony/Component/Console/Tests/Descriptor/JsonDescriptorTest.php new file mode 100755 index 0000000..943ea29 --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Tests/Descriptor/JsonDescriptorTest.php @@ -0,0 +1,27 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Console\Tests\Descriptor; + +use Symfony\Component\Console\Descriptor\JsonDescriptor; + +class JsonDescriptorTest extends AbstractDescriptorTest +{ + protected function getDescriptor() + { + return new JsonDescriptor(); + } + + protected function getFormat() + { + return 'json'; + } +} diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Descriptor/MarkdownDescriptorTest.php b/vendor/symfony/console/Symfony/Component/Console/Tests/Descriptor/MarkdownDescriptorTest.php new file mode 100755 index 0000000..c85e8a5 --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Tests/Descriptor/MarkdownDescriptorTest.php @@ -0,0 +1,27 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Console\Tests\Descriptor; + +use Symfony\Component\Console\Descriptor\MarkdownDescriptor; + +class MarkdownDescriptorTest extends AbstractDescriptorTest +{ + protected function getDescriptor() + { + return new MarkdownDescriptor(); + } + + protected function getFormat() + { + return 'md'; + } +} diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Descriptor/ObjectsProvider.php b/vendor/symfony/console/Symfony/Component/Console/Tests/Descriptor/ObjectsProvider.php new file mode 100755 index 0000000..a3c49d7 --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Tests/Descriptor/ObjectsProvider.php @@ -0,0 +1,74 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Console\Tests\Descriptor; + +use Symfony\Component\Console\Input\InputArgument; +use Symfony\Component\Console\Input\InputDefinition; +use Symfony\Component\Console\Input\InputOption; +use Symfony\Component\Console\Tests\Fixtures\DescriptorApplication1; +use Symfony\Component\Console\Tests\Fixtures\DescriptorApplication2; +use Symfony\Component\Console\Tests\Fixtures\DescriptorCommand1; +use Symfony\Component\Console\Tests\Fixtures\DescriptorCommand2; + +/** + * @author Jean-François Simon + */ +class ObjectsProvider +{ + public static function getInputArguments() + { + return array( + 'input_argument_1' => new InputArgument('argument_name', InputArgument::REQUIRED), + 'input_argument_2' => new InputArgument('argument_name', InputArgument::IS_ARRAY, 'argument description'), + 'input_argument_3' => new InputArgument('argument_name', InputArgument::OPTIONAL, 'argument description', 'default_value'), + ); + } + + public static function getInputOptions() + { + return array( + 'input_option_1' => new InputOption('option_name', 'o', InputOption::VALUE_NONE), + 'input_option_2' => new InputOption('option_name', 'o', InputOption::VALUE_OPTIONAL, 'option description', 'default_value'), + 'input_option_3' => new InputOption('option_name', 'o', InputOption::VALUE_REQUIRED, 'option description'), + 'input_option_4' => new InputOption('option_name', 'o', InputOption::VALUE_IS_ARRAY | InputOption::VALUE_OPTIONAL, 'option description', array()), + ); + } + + public static function getInputDefinitions() + { + return array( + 'input_definition_1' => new InputDefinition(), + 'input_definition_2' => new InputDefinition(array(new InputArgument('argument_name', InputArgument::REQUIRED))), + 'input_definition_3' => new InputDefinition(array(new InputOption('option_name', 'o', InputOption::VALUE_NONE))), + 'input_definition_4' => new InputDefinition(array( + new InputArgument('argument_name', InputArgument::REQUIRED), + new InputOption('option_name', 'o', InputOption::VALUE_NONE), + )), + ); + } + + public static function getCommands() + { + return array( + 'command_1' => new DescriptorCommand1(), + 'command_2' => new DescriptorCommand2(), + ); + } + + public static function getApplications() + { + return array( + 'application_1' => new DescriptorApplication1(), + 'application_2' => new DescriptorApplication2(), + ); + } +} diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Descriptor/TextDescriptorTest.php b/vendor/symfony/console/Symfony/Component/Console/Tests/Descriptor/TextDescriptorTest.php new file mode 100755 index 0000000..350b679 --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Tests/Descriptor/TextDescriptorTest.php @@ -0,0 +1,27 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Console\Tests\Descriptor; + +use Symfony\Component\Console\Descriptor\TextDescriptor; + +class TextDescriptorTest extends AbstractDescriptorTest +{ + protected function getDescriptor() + { + return new TextDescriptor(); + } + + protected function getFormat() + { + return 'txt'; + } +} diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Descriptor/XmlDescriptorTest.php b/vendor/symfony/console/Symfony/Component/Console/Tests/Descriptor/XmlDescriptorTest.php new file mode 100755 index 0000000..59a5d1e --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Tests/Descriptor/XmlDescriptorTest.php @@ -0,0 +1,27 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Console\Tests\Descriptor; + +use Symfony\Component\Console\Descriptor\XmlDescriptor; + +class XmlDescriptorTest extends AbstractDescriptorTest +{ + protected function getDescriptor() + { + return new XmlDescriptor(); + } + + protected function getFormat() + { + return 'xml'; + } +} diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/BarBucCommand.php b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/BarBucCommand.php new file mode 100755 index 0000000..52b619e --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/BarBucCommand.php @@ -0,0 +1,11 @@ +setName('bar:buc'); + } +} diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/DescriptorApplication1.php b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/DescriptorApplication1.php new file mode 100755 index 0000000..132b6d5 --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/DescriptorApplication1.php @@ -0,0 +1,18 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Console\Tests\Fixtures; + +use Symfony\Component\Console\Application; + +class DescriptorApplication1 extends Application +{ +} diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/DescriptorApplication2.php b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/DescriptorApplication2.php new file mode 100755 index 0000000..ff55135 --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/DescriptorApplication2.php @@ -0,0 +1,24 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Console\Tests\Fixtures; + +use Symfony\Component\Console\Application; + +class DescriptorApplication2 extends Application +{ + public function __construct() + { + parent::__construct('My Symfony application', 'v1.0'); + $this->add(new DescriptorCommand1()); + $this->add(new DescriptorCommand2()); + } +} diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/DescriptorCommand1.php b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/DescriptorCommand1.php new file mode 100755 index 0000000..ede05d7 --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/DescriptorCommand1.php @@ -0,0 +1,27 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Console\Tests\Fixtures; + +use Symfony\Component\Console\Command\Command; + +class DescriptorCommand1 extends Command +{ + protected function configure() + { + $this + ->setName('descriptor:command1') + ->setAliases(array('alias1', 'alias2')) + ->setDescription('command 1 description') + ->setHelp('command 1 help') + ; + } +} diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/DescriptorCommand2.php b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/DescriptorCommand2.php new file mode 100755 index 0000000..bc04ca9 --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/DescriptorCommand2.php @@ -0,0 +1,30 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Console\Tests\Fixtures; + +use Symfony\Component\Console\Command\Command; +use Symfony\Component\Console\Input\InputArgument; +use Symfony\Component\Console\Input\InputOption; + +class DescriptorCommand2 extends Command +{ + protected function configure() + { + $this + ->setName('descriptor:command2') + ->setDescription('command 2 description') + ->setHelp('command 2 help') + ->addArgument('argument_name', InputArgument::REQUIRED) + ->addOption('option_name', 'o', InputOption::VALUE_NONE) + ; + } +} diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/Foo1Command.php b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/Foo1Command.php new file mode 100755 index 0000000..254162f --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/Foo1Command.php @@ -0,0 +1,26 @@ +setName('foo:bar1') + ->setDescription('The foo:bar1 command') + ->setAliases(array('afoobar1')) + ; + } + + protected function execute(InputInterface $input, OutputInterface $output) + { + $this->input = $input; + $this->output = $output; + } +} diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/Foo2Command.php b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/Foo2Command.php new file mode 100755 index 0000000..8071dc8 --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/Foo2Command.php @@ -0,0 +1,21 @@ +setName('foo1:bar') + ->setDescription('The foo1:bar command') + ->setAliases(array('afoobar2')) + ; + } + + protected function execute(InputInterface $input, OutputInterface $output) + { + } +} diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/Foo3Command.php b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/Foo3Command.php new file mode 100755 index 0000000..43a3507 --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/Foo3Command.php @@ -0,0 +1,29 @@ +setName('foo3:bar') + ->setDescription('The foo3:bar command') + ; + } + + protected function execute(InputInterface $input, OutputInterface $output) + { + try { + try { + throw new \Exception("First exception

    this is html

    "); + } catch (\Exception $e) { + throw new \Exception("Second exception comment", 0, $e); + } + } catch (\Exception $e) { + throw new \Exception("Third exception comment", 0, $e); + } + } +} diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/Foo4Command.php b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/Foo4Command.php new file mode 100755 index 0000000..1c54639 --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/Foo4Command.php @@ -0,0 +1,11 @@ +setName('foo3:bar:toh'); + } +} diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/Foo5Command.php b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/Foo5Command.php new file mode 100755 index 0000000..a1c6082 --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/Foo5Command.php @@ -0,0 +1,10 @@ +setName('foo:bar') + ->setDescription('The foo:bar command') + ->setAliases(array('afoobar')) + ; + } + + protected function interact(InputInterface $input, OutputInterface $output) + { + $output->writeln('interact called'); + } + + protected function execute(InputInterface $input, OutputInterface $output) + { + $this->input = $input; + $this->output = $output; + + $output->writeln('called'); + } +} diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/FoobarCommand.php b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/FoobarCommand.php new file mode 100755 index 0000000..9681628 --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/FoobarCommand.php @@ -0,0 +1,25 @@ +setName('foobar:foo') + ->setDescription('The foobar:foo command') + ; + } + + protected function execute(InputInterface $input, OutputInterface $output) + { + $this->input = $input; + $this->output = $output; + } +} diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/TestCommand.php b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/TestCommand.php new file mode 100755 index 0000000..dcd3273 --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/TestCommand.php @@ -0,0 +1,28 @@ +setName('namespace:name') + ->setAliases(array('name')) + ->setDescription('description') + ->setHelp('help') + ; + } + + protected function execute(InputInterface $input, OutputInterface $output) + { + $output->writeln('execute called'); + } + + protected function interact(InputInterface $input, OutputInterface $output) + { + $output->writeln('interact called'); + } +} diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/application_1.json b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/application_1.json new file mode 100755 index 0000000..09adbd4 --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/application_1.json @@ -0,0 +1 @@ +{"commands":[{"name":"help","usage":"help [--xml] [--format=\"...\"] [--raw] [command_name]","description":"Displays help for a command","help":"The help<\/info> command displays help for a given command:\n\n php app\/console help list<\/info>\n\nYou can also output the help in other formats by using the --format<\/comment> option:\n\n php app\/console help --format=xml list<\/info>\n\nTo display the list of available commands, please use the list<\/info> command.","aliases":[],"definition":{"arguments":{"command_name":{"name":"command_name","is_required":false,"is_array":false,"description":"The command name","default":"help"}},"options":{"xml":{"name":"--xml","shortcut":"","accept_value":false,"is_value_required":false,"is_multiple":false,"description":"To output help as XML","default":false},"format":{"name":"--format","shortcut":"","accept_value":true,"is_value_required":true,"is_multiple":false,"description":"To output help in other formats","default":"txt"},"raw":{"name":"--raw","shortcut":"","accept_value":false,"is_value_required":false,"is_multiple":false,"description":"To output raw command help","default":false},"help":{"name":"--help","shortcut":"-h","accept_value":false,"is_value_required":false,"is_multiple":false,"description":"Display this help message.","default":false},"quiet":{"name":"--quiet","shortcut":"-q","accept_value":false,"is_value_required":false,"is_multiple":false,"description":"Do not output any message.","default":false},"verbose":{"name":"--verbose","shortcut":"-v|-vv|-vvv","accept_value":false,"is_value_required":false,"is_multiple":false,"description":"Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug","default":false},"version":{"name":"--version","shortcut":"-V","accept_value":false,"is_value_required":false,"is_multiple":false,"description":"Display this application version.","default":false},"ansi":{"name":"--ansi","shortcut":"","accept_value":false,"is_value_required":false,"is_multiple":false,"description":"Force ANSI output.","default":false},"no-ansi":{"name":"--no-ansi","shortcut":"","accept_value":false,"is_value_required":false,"is_multiple":false,"description":"Disable ANSI output.","default":false},"no-interaction":{"name":"--no-interaction","shortcut":"-n","accept_value":false,"is_value_required":false,"is_multiple":false,"description":"Do not ask any interactive question.","default":false}}}},{"name":"list","usage":"list [--xml] [--raw] [--format=\"...\"] [namespace]","description":"Lists commands","help":"The list<\/info> command lists all commands:\n\n php app\/console list<\/info>\n\nYou can also display the commands for a specific namespace:\n\n php app\/console list test<\/info>\n\nYou can also output the information in other formats by using the --format<\/comment> option:\n\n php app\/console list --format=xml<\/info>\n\nIt's also possible to get raw list of commands (useful for embedding command runner):\n\n php app\/console list --raw<\/info>","aliases":[],"definition":{"arguments":{"namespace":{"name":"namespace","is_required":false,"is_array":false,"description":"The namespace name","default":null}},"options":{"xml":{"name":"--xml","shortcut":"","accept_value":false,"is_value_required":false,"is_multiple":false,"description":"To output list as XML","default":false},"raw":{"name":"--raw","shortcut":"","accept_value":false,"is_value_required":false,"is_multiple":false,"description":"To output raw command list","default":false},"format":{"name":"--format","shortcut":"","accept_value":true,"is_value_required":true,"is_multiple":false,"description":"To output list in other formats","default":"txt"}}}}],"namespaces":[{"id":"_global","commands":["help","list"]}]} diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/application_1.md b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/application_1.md new file mode 100755 index 0000000..a789251 --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/application_1.md @@ -0,0 +1,199 @@ +UNKNOWN +======= + +* help +* list + +help +---- + +* Description: Displays help for a command +* Usage: `help [--xml] [--format="..."] [--raw] [command_name]` +* Aliases: + +The help command displays help for a given command: + + php app/console help list + +You can also output the help in other formats by using the --format option: + + php app/console help --format=xml list + +To display the list of available commands, please use the list command. + +### Arguments: + +**command_name:** + +* Name: command_name +* Is required: no +* Is array: no +* Description: The command name +* Default: `'help'` + +### Options: + +**xml:** + +* Name: `--xml` +* Shortcut: +* Accept value: no +* Is value required: no +* Is multiple: no +* Description: To output help as XML +* Default: `false` + +**format:** + +* Name: `--format` +* Shortcut: +* Accept value: yes +* Is value required: yes +* Is multiple: no +* Description: To output help in other formats +* Default: `'txt'` + +**raw:** + +* Name: `--raw` +* Shortcut: +* Accept value: no +* Is value required: no +* Is multiple: no +* Description: To output raw command help +* Default: `false` + +**help:** + +* Name: `--help` +* Shortcut: `-h` +* Accept value: no +* Is value required: no +* Is multiple: no +* Description: Display this help message. +* Default: `false` + +**quiet:** + +* Name: `--quiet` +* Shortcut: `-q` +* Accept value: no +* Is value required: no +* Is multiple: no +* Description: Do not output any message. +* Default: `false` + +**verbose:** + +* Name: `--verbose` +* Shortcut: `-v|-vv|-vvv` +* Accept value: no +* Is value required: no +* Is multiple: no +* Description: Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug +* Default: `false` + +**version:** + +* Name: `--version` +* Shortcut: `-V` +* Accept value: no +* Is value required: no +* Is multiple: no +* Description: Display this application version. +* Default: `false` + +**ansi:** + +* Name: `--ansi` +* Shortcut: +* Accept value: no +* Is value required: no +* Is multiple: no +* Description: Force ANSI output. +* Default: `false` + +**no-ansi:** + +* Name: `--no-ansi` +* Shortcut: +* Accept value: no +* Is value required: no +* Is multiple: no +* Description: Disable ANSI output. +* Default: `false` + +**no-interaction:** + +* Name: `--no-interaction` +* Shortcut: `-n` +* Accept value: no +* Is value required: no +* Is multiple: no +* Description: Do not ask any interactive question. +* Default: `false` + +list +---- + +* Description: Lists commands +* Usage: `list [--xml] [--raw] [--format="..."] [namespace]` +* Aliases: + +The list command lists all commands: + + php app/console list + +You can also display the commands for a specific namespace: + + php app/console list test + +You can also output the information in other formats by using the --format option: + + php app/console list --format=xml + +It's also possible to get raw list of commands (useful for embedding command runner): + + php app/console list --raw + +### Arguments: + +**namespace:** + +* Name: namespace +* Is required: no +* Is array: no +* Description: The namespace name +* Default: `NULL` + +### Options: + +**xml:** + +* Name: `--xml` +* Shortcut: +* Accept value: no +* Is value required: no +* Is multiple: no +* Description: To output list as XML +* Default: `false` + +**raw:** + +* Name: `--raw` +* Shortcut: +* Accept value: no +* Is value required: no +* Is multiple: no +* Description: To output raw command list +* Default: `false` + +**format:** + +* Name: `--format` +* Shortcut: +* Accept value: yes +* Is value required: yes +* Is multiple: no +* Description: To output list in other formats +* Default: `'txt'` diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/application_1.txt b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/application_1.txt new file mode 100755 index 0000000..24ab4a0 --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/application_1.txt @@ -0,0 +1,17 @@ +Console Tool + +Usage: + [options] command [arguments] + +Options: + --help -h Display this help message. + --quiet -q Do not output any message. + --verbose -v|vv|vvv Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug + --version -V Display this application version. + --ansi Force ANSI output. + --no-ansi Disable ANSI output. + --no-interaction -n Do not ask any interactive question. + +Available commands: + help Displays help for a command + list Lists commands diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/application_1.xml b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/application_1.xml new file mode 100755 index 0000000..bfe5de0 --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/application_1.xml @@ -0,0 +1,108 @@ + + + + + help [--xml] [--format="..."] [--raw] [command_name] + Displays help for a command + The <info>help</info> command displays help for a given command: + + <info>php app/console help list</info> + + You can also output the help in other formats by using the <comment>--format</comment> option: + + <info>php app/console help --format=xml list</info> + + To display the list of available commands, please use the <info>list</info> command. + + + + The command name + + help + + + + + + + + + + + + + + + + + + list [--xml] [--raw] [--format="..."] [namespace] + Lists commands + The <info>list</info> command lists all commands: + + <info>php app/console list</info> + + You can also display the commands for a specific namespace: + + <info>php app/console list test</info> + + You can also output the information in other formats by using the <comment>--format</comment> option: + + <info>php app/console list --format=xml</info> + + It's also possible to get raw list of commands (useful for embedding command runner): + + <info>php app/console list --raw</info> + + + + The namespace name + + + + + + + + + + + + + help + list + + + diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/application_2.json b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/application_2.json new file mode 100755 index 0000000..27745c1 --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/application_2.json @@ -0,0 +1 @@ +{"commands":[{"name":"help","usage":"help [--xml] [--format=\"...\"] [--raw] [command_name]","description":"Displays help for a command","help":"The help<\/info> command displays help for a given command:\n\n php app\/console help list<\/info>\n\nYou can also output the help in other formats by using the --format<\/comment> option:\n\n php app\/console help --format=xml list<\/info>\n\nTo display the list of available commands, please use the list<\/info> command.","aliases":[],"definition":{"arguments":{"command_name":{"name":"command_name","is_required":false,"is_array":false,"description":"The command name","default":"help"}},"options":{"xml":{"name":"--xml","shortcut":"","accept_value":false,"is_value_required":false,"is_multiple":false,"description":"To output help as XML","default":false},"format":{"name":"--format","shortcut":"","accept_value":true,"is_value_required":true,"is_multiple":false,"description":"To output help in other formats","default":"txt"},"raw":{"name":"--raw","shortcut":"","accept_value":false,"is_value_required":false,"is_multiple":false,"description":"To output raw command help","default":false},"help":{"name":"--help","shortcut":"-h","accept_value":false,"is_value_required":false,"is_multiple":false,"description":"Display this help message.","default":false},"quiet":{"name":"--quiet","shortcut":"-q","accept_value":false,"is_value_required":false,"is_multiple":false,"description":"Do not output any message.","default":false},"verbose":{"name":"--verbose","shortcut":"-v|-vv|-vvv","accept_value":false,"is_value_required":false,"is_multiple":false,"description":"Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug","default":false},"version":{"name":"--version","shortcut":"-V","accept_value":false,"is_value_required":false,"is_multiple":false,"description":"Display this application version.","default":false},"ansi":{"name":"--ansi","shortcut":"","accept_value":false,"is_value_required":false,"is_multiple":false,"description":"Force ANSI output.","default":false},"no-ansi":{"name":"--no-ansi","shortcut":"","accept_value":false,"is_value_required":false,"is_multiple":false,"description":"Disable ANSI output.","default":false},"no-interaction":{"name":"--no-interaction","shortcut":"-n","accept_value":false,"is_value_required":false,"is_multiple":false,"description":"Do not ask any interactive question.","default":false}}}},{"name":"list","usage":"list [--xml] [--raw] [--format=\"...\"] [namespace]","description":"Lists commands","help":"The list<\/info> command lists all commands:\n\n php app\/console list<\/info>\n\nYou can also display the commands for a specific namespace:\n\n php app\/console list test<\/info>\n\nYou can also output the information in other formats by using the --format<\/comment> option:\n\n php app\/console list --format=xml<\/info>\n\nIt's also possible to get raw list of commands (useful for embedding command runner):\n\n php app\/console list --raw<\/info>","aliases":[],"definition":{"arguments":{"namespace":{"name":"namespace","is_required":false,"is_array":false,"description":"The namespace name","default":null}},"options":{"xml":{"name":"--xml","shortcut":"","accept_value":false,"is_value_required":false,"is_multiple":false,"description":"To output list as XML","default":false},"raw":{"name":"--raw","shortcut":"","accept_value":false,"is_value_required":false,"is_multiple":false,"description":"To output raw command list","default":false},"format":{"name":"--format","shortcut":"","accept_value":true,"is_value_required":true,"is_multiple":false,"description":"To output list in other formats","default":"txt"}}}},{"name":"descriptor:command1","usage":"descriptor:command1","description":"command 1 description","help":"command 1 help","aliases":["alias1","alias2"],"definition":{"arguments":[],"options":{"help":{"name":"--help","shortcut":"-h","accept_value":false,"is_value_required":false,"is_multiple":false,"description":"Display this help message.","default":false},"quiet":{"name":"--quiet","shortcut":"-q","accept_value":false,"is_value_required":false,"is_multiple":false,"description":"Do not output any message.","default":false},"verbose":{"name":"--verbose","shortcut":"-v|-vv|-vvv","accept_value":false,"is_value_required":false,"is_multiple":false,"description":"Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug","default":false},"version":{"name":"--version","shortcut":"-V","accept_value":false,"is_value_required":false,"is_multiple":false,"description":"Display this application version.","default":false},"ansi":{"name":"--ansi","shortcut":"","accept_value":false,"is_value_required":false,"is_multiple":false,"description":"Force ANSI output.","default":false},"no-ansi":{"name":"--no-ansi","shortcut":"","accept_value":false,"is_value_required":false,"is_multiple":false,"description":"Disable ANSI output.","default":false},"no-interaction":{"name":"--no-interaction","shortcut":"-n","accept_value":false,"is_value_required":false,"is_multiple":false,"description":"Do not ask any interactive question.","default":false}}}},{"name":"descriptor:command2","usage":"descriptor:command2 [-o|--option_name] argument_name","description":"command 2 description","help":"command 2 help","aliases":[],"definition":{"arguments":{"argument_name":{"name":"argument_name","is_required":true,"is_array":false,"description":"","default":null}},"options":{"option_name":{"name":"--option_name","shortcut":"-o","accept_value":false,"is_value_required":false,"is_multiple":false,"description":"","default":false},"help":{"name":"--help","shortcut":"-h","accept_value":false,"is_value_required":false,"is_multiple":false,"description":"Display this help message.","default":false},"quiet":{"name":"--quiet","shortcut":"-q","accept_value":false,"is_value_required":false,"is_multiple":false,"description":"Do not output any message.","default":false},"verbose":{"name":"--verbose","shortcut":"-v|-vv|-vvv","accept_value":false,"is_value_required":false,"is_multiple":false,"description":"Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug","default":false},"version":{"name":"--version","shortcut":"-V","accept_value":false,"is_value_required":false,"is_multiple":false,"description":"Display this application version.","default":false},"ansi":{"name":"--ansi","shortcut":"","accept_value":false,"is_value_required":false,"is_multiple":false,"description":"Force ANSI output.","default":false},"no-ansi":{"name":"--no-ansi","shortcut":"","accept_value":false,"is_value_required":false,"is_multiple":false,"description":"Disable ANSI output.","default":false},"no-interaction":{"name":"--no-interaction","shortcut":"-n","accept_value":false,"is_value_required":false,"is_multiple":false,"description":"Do not ask any interactive question.","default":false}}}}],"namespaces":[{"id":"_global","commands":["alias1","alias2","help","list"]},{"id":"descriptor","commands":["descriptor:command1","descriptor:command2"]}]} diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/application_2.md b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/application_2.md new file mode 100755 index 0000000..e52ecd3 --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/application_2.md @@ -0,0 +1,388 @@ +My Symfony application +====================== + +* alias1 +* alias2 +* help +* list + +**descriptor:** + +* descriptor:command1 +* descriptor:command2 + +help +---- + +* Description: Displays help for a command +* Usage: `help [--xml] [--format="..."] [--raw] [command_name]` +* Aliases: + +The help command displays help for a given command: + + php app/console help list + +You can also output the help in other formats by using the --format option: + + php app/console help --format=xml list + +To display the list of available commands, please use the list command. + +### Arguments: + +**command_name:** + +* Name: command_name +* Is required: no +* Is array: no +* Description: The command name +* Default: `'help'` + +### Options: + +**xml:** + +* Name: `--xml` +* Shortcut: +* Accept value: no +* Is value required: no +* Is multiple: no +* Description: To output help as XML +* Default: `false` + +**format:** + +* Name: `--format` +* Shortcut: +* Accept value: yes +* Is value required: yes +* Is multiple: no +* Description: To output help in other formats +* Default: `'txt'` + +**raw:** + +* Name: `--raw` +* Shortcut: +* Accept value: no +* Is value required: no +* Is multiple: no +* Description: To output raw command help +* Default: `false` + +**help:** + +* Name: `--help` +* Shortcut: `-h` +* Accept value: no +* Is value required: no +* Is multiple: no +* Description: Display this help message. +* Default: `false` + +**quiet:** + +* Name: `--quiet` +* Shortcut: `-q` +* Accept value: no +* Is value required: no +* Is multiple: no +* Description: Do not output any message. +* Default: `false` + +**verbose:** + +* Name: `--verbose` +* Shortcut: `-v|-vv|-vvv` +* Accept value: no +* Is value required: no +* Is multiple: no +* Description: Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug +* Default: `false` + +**version:** + +* Name: `--version` +* Shortcut: `-V` +* Accept value: no +* Is value required: no +* Is multiple: no +* Description: Display this application version. +* Default: `false` + +**ansi:** + +* Name: `--ansi` +* Shortcut: +* Accept value: no +* Is value required: no +* Is multiple: no +* Description: Force ANSI output. +* Default: `false` + +**no-ansi:** + +* Name: `--no-ansi` +* Shortcut: +* Accept value: no +* Is value required: no +* Is multiple: no +* Description: Disable ANSI output. +* Default: `false` + +**no-interaction:** + +* Name: `--no-interaction` +* Shortcut: `-n` +* Accept value: no +* Is value required: no +* Is multiple: no +* Description: Do not ask any interactive question. +* Default: `false` + +list +---- + +* Description: Lists commands +* Usage: `list [--xml] [--raw] [--format="..."] [namespace]` +* Aliases: + +The list command lists all commands: + + php app/console list + +You can also display the commands for a specific namespace: + + php app/console list test + +You can also output the information in other formats by using the --format option: + + php app/console list --format=xml + +It's also possible to get raw list of commands (useful for embedding command runner): + + php app/console list --raw + +### Arguments: + +**namespace:** + +* Name: namespace +* Is required: no +* Is array: no +* Description: The namespace name +* Default: `NULL` + +### Options: + +**xml:** + +* Name: `--xml` +* Shortcut: +* Accept value: no +* Is value required: no +* Is multiple: no +* Description: To output list as XML +* Default: `false` + +**raw:** + +* Name: `--raw` +* Shortcut: +* Accept value: no +* Is value required: no +* Is multiple: no +* Description: To output raw command list +* Default: `false` + +**format:** + +* Name: `--format` +* Shortcut: +* Accept value: yes +* Is value required: yes +* Is multiple: no +* Description: To output list in other formats +* Default: `'txt'` + +descriptor:command1 +------------------- + +* Description: command 1 description +* Usage: `descriptor:command1` +* Aliases: `alias1`, `alias2` + +command 1 help + +### Options: + +**help:** + +* Name: `--help` +* Shortcut: `-h` +* Accept value: no +* Is value required: no +* Is multiple: no +* Description: Display this help message. +* Default: `false` + +**quiet:** + +* Name: `--quiet` +* Shortcut: `-q` +* Accept value: no +* Is value required: no +* Is multiple: no +* Description: Do not output any message. +* Default: `false` + +**verbose:** + +* Name: `--verbose` +* Shortcut: `-v|-vv|-vvv` +* Accept value: no +* Is value required: no +* Is multiple: no +* Description: Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug +* Default: `false` + +**version:** + +* Name: `--version` +* Shortcut: `-V` +* Accept value: no +* Is value required: no +* Is multiple: no +* Description: Display this application version. +* Default: `false` + +**ansi:** + +* Name: `--ansi` +* Shortcut: +* Accept value: no +* Is value required: no +* Is multiple: no +* Description: Force ANSI output. +* Default: `false` + +**no-ansi:** + +* Name: `--no-ansi` +* Shortcut: +* Accept value: no +* Is value required: no +* Is multiple: no +* Description: Disable ANSI output. +* Default: `false` + +**no-interaction:** + +* Name: `--no-interaction` +* Shortcut: `-n` +* Accept value: no +* Is value required: no +* Is multiple: no +* Description: Do not ask any interactive question. +* Default: `false` + +descriptor:command2 +------------------- + +* Description: command 2 description +* Usage: `descriptor:command2 [-o|--option_name] argument_name` +* Aliases: + +command 2 help + +### Arguments: + +**argument_name:** + +* Name: argument_name +* Is required: yes +* Is array: no +* Description: +* Default: `NULL` + +### Options: + +**option_name:** + +* Name: `--option_name` +* Shortcut: `-o` +* Accept value: no +* Is value required: no +* Is multiple: no +* Description: +* Default: `false` + +**help:** + +* Name: `--help` +* Shortcut: `-h` +* Accept value: no +* Is value required: no +* Is multiple: no +* Description: Display this help message. +* Default: `false` + +**quiet:** + +* Name: `--quiet` +* Shortcut: `-q` +* Accept value: no +* Is value required: no +* Is multiple: no +* Description: Do not output any message. +* Default: `false` + +**verbose:** + +* Name: `--verbose` +* Shortcut: `-v|-vv|-vvv` +* Accept value: no +* Is value required: no +* Is multiple: no +* Description: Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug +* Default: `false` + +**version:** + +* Name: `--version` +* Shortcut: `-V` +* Accept value: no +* Is value required: no +* Is multiple: no +* Description: Display this application version. +* Default: `false` + +**ansi:** + +* Name: `--ansi` +* Shortcut: +* Accept value: no +* Is value required: no +* Is multiple: no +* Description: Force ANSI output. +* Default: `false` + +**no-ansi:** + +* Name: `--no-ansi` +* Shortcut: +* Accept value: no +* Is value required: no +* Is multiple: no +* Description: Disable ANSI output. +* Default: `false` + +**no-interaction:** + +* Name: `--no-interaction` +* Shortcut: `-n` +* Accept value: no +* Is value required: no +* Is multiple: no +* Description: Do not ask any interactive question. +* Default: `false` diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/application_2.txt b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/application_2.txt new file mode 100755 index 0000000..78580d0 --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/application_2.txt @@ -0,0 +1,22 @@ +My Symfony application version v1.0 + +Usage: + [options] command [arguments] + +Options: + --help -h Display this help message. + --quiet -q Do not output any message. + --verbose -v|vv|vvv Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug + --version -V Display this application version. + --ansi Force ANSI output. + --no-ansi Disable ANSI output. + --no-interaction -n Do not ask any interactive question. + +Available commands: + alias1 command 1 description + alias2 command 1 description + help Displays help for a command + list Lists commands +descriptor + descriptor:command1 command 1 description + descriptor:command2 command 2 description diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/application_2.xml b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/application_2.xml new file mode 100755 index 0000000..9fc3a21 --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/application_2.xml @@ -0,0 +1,185 @@ + + + + + help [--xml] [--format="..."] [--raw] [command_name] + Displays help for a command + The <info>help</info> command displays help for a given command: + + <info>php app/console help list</info> + + You can also output the help in other formats by using the <comment>--format</comment> option: + + <info>php app/console help --format=xml list</info> + + To display the list of available commands, please use the <info>list</info> command. + + + + The command name + + help + + + + + + + + + + + + + + + + + + list [--xml] [--raw] [--format="..."] [namespace] + Lists commands + The <info>list</info> command lists all commands: + + <info>php app/console list</info> + + You can also display the commands for a specific namespace: + + <info>php app/console list test</info> + + You can also output the information in other formats by using the <comment>--format</comment> option: + + <info>php app/console list --format=xml</info> + + It's also possible to get raw list of commands (useful for embedding command runner): + + <info>php app/console list --raw</info> + + + + The namespace name + + + + + + + + + + + descriptor:command1 + command 1 description + command 1 help + + alias1 + alias2 + + + + + + + + + + + + + + descriptor:command2 [-o|--option_name] argument_name + command 2 description + command 2 help + + + + + + + + + + + + + + + + + + + + + + alias1 + alias2 + help + list + + + descriptor:command1 + descriptor:command2 + + + diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/application_astext1.txt b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/application_astext1.txt new file mode 100755 index 0000000..dca37e2 --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/application_astext1.txt @@ -0,0 +1,20 @@ +Console Tool + +Usage: + [options] command [arguments] + +Options: + --help -h Display this help message. + --quiet -q Do not output any message. + --verbose -v|vv|vvv Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug + --version -V Display this application version. + --ansi Force ANSI output. + --no-ansi Disable ANSI output. + --no-interaction -n Do not ask any interactive question. + +Available commands: + afoobar The foo:bar command + help Displays help for a command + list Lists commands +foo + foo:bar The foo:bar command diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/application_astext2.txt b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/application_astext2.txt new file mode 100755 index 0000000..827c406 --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/application_astext2.txt @@ -0,0 +1,16 @@ +Console Tool + +Usage: + [options] command [arguments] + +Options: + --help -h Display this help message. + --quiet -q Do not output any message. + --verbose -v|vv|vvv Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug + --version -V Display this application version. + --ansi Force ANSI output. + --no-ansi Disable ANSI output. + --no-interaction -n Do not ask any interactive question. + +Available commands for the "foo" namespace: + foo:bar The foo:bar command diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/application_asxml1.txt b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/application_asxml1.txt new file mode 100755 index 0000000..94a6863 --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/application_asxml1.txt @@ -0,0 +1,144 @@ + + + + + help [--xml] [--format="..."] [--raw] [command_name] + Displays help for a command + The <info>help</info> command displays help for a given command: + + <info>php app/console help list</info> + + You can also output the help in other formats by using the <comment>--format</comment> option: + + <info>php app/console help --format=xml list</info> + + To display the list of available commands, please use the <info>list</info> command. + + + + The command name + + help + + + + + + + + + + + + + + + + + + list [--xml] [--raw] [--format="..."] [namespace] + Lists commands + The <info>list</info> command lists all commands: + + <info>php app/console list</info> + + You can also display the commands for a specific namespace: + + <info>php app/console list test</info> + + You can also output the information in other formats by using the <comment>--format</comment> option: + + <info>php app/console list --format=xml</info> + + It's also possible to get raw list of commands (useful for embedding command runner): + + <info>php app/console list --raw</info> + + + + The namespace name + + + + + + + + + + + foo:bar + The foo:bar command + + + afoobar + + + + + + + + + + + + + + + + afoobar + help + list + + + foo:bar + + + diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/application_asxml2.txt b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/application_asxml2.txt new file mode 100755 index 0000000..5d61d2a --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/application_asxml2.txt @@ -0,0 +1,37 @@ + + + + + foo:bar + The foo:bar command + + + afoobar + + + + + + + + + + + + + + diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/application_gethelp.txt b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/application_gethelp.txt new file mode 100755 index 0000000..79c36f9 --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/application_gethelp.txt @@ -0,0 +1,13 @@ +Console Tool + +Usage: + [options] command [arguments] + +Options: + --help -h Display this help message. + --quiet -q Do not output any message. + --verbose -v|vv|vvv Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug + --version -V Display this application version. + --ansi Force ANSI output. + --no-ansi Disable ANSI output. + --no-interaction -n Do not ask any interactive question. \ No newline at end of file diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/application_renderexception1.txt b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/application_renderexception1.txt new file mode 100755 index 0000000..4629345 --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/application_renderexception1.txt @@ -0,0 +1,8 @@ + + + + [InvalidArgumentException] + Command "foo" is not defined. + + + diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/application_renderexception2.txt b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/application_renderexception2.txt new file mode 100755 index 0000000..c758129 --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/application_renderexception2.txt @@ -0,0 +1,11 @@ + + + + [InvalidArgumentException] + The "--foo" option does not exist. + + + +list [--xml] [--raw] [--format="..."] [namespace] + + diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/application_renderexception3.txt b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/application_renderexception3.txt new file mode 100755 index 0000000..72a7286 --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/application_renderexception3.txt @@ -0,0 +1,27 @@ + + + + [Exception] + Third exception comment + + + + + + + [Exception] + Second exception comment + + + + + + + [Exception] + First exception

    this is html

    + + + +foo3:bar + + diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/application_renderexception3decorated.txt b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/application_renderexception3decorated.txt new file mode 100755 index 0000000..4bdcd77 --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/application_renderexception3decorated.txt @@ -0,0 +1,27 @@ + + +  + [Exception]  + Third exception comment  +  + + + + +  + [Exception]  + Second exception comment  +  + + + + +  + [Exception]  + First exception 

    this is html

      +  + + +foo3:bar + + diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/application_renderexception4.txt b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/application_renderexception4.txt new file mode 100755 index 0000000..19f893b --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/application_renderexception4.txt @@ -0,0 +1,9 @@ + + + + [InvalidArgumentException] + Command "foo" is not define + d. + + + diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/application_renderexception_doublewidth1.txt b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/application_renderexception_doublewidth1.txt new file mode 100755 index 0000000..6a98660 --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/application_renderexception_doublewidth1.txt @@ -0,0 +1,11 @@ + + + + [Exception] + エラーメッセージ + + + +foo + + diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/application_renderexception_doublewidth1decorated.txt b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/application_renderexception_doublewidth1decorated.txt new file mode 100755 index 0000000..c68a60f --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/application_renderexception_doublewidth1decorated.txt @@ -0,0 +1,11 @@ + + +  + [Exception]  + エラーメッセージ  +  + + +foo + + diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/application_renderexception_doublewidth2.txt b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/application_renderexception_doublewidth2.txt new file mode 100755 index 0000000..545cd7b --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/application_renderexception_doublewidth2.txt @@ -0,0 +1,12 @@ + + + + [Exception] + コマンドã®å®Ÿè¡Œä¸­ã«ã‚¨ãƒ©ãƒ¼ãŒ + 発生ã—ã¾ã—ãŸã€‚ + + + +foo + + diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/application_run1.txt b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/application_run1.txt new file mode 100755 index 0000000..5e9554f --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/application_run1.txt @@ -0,0 +1,17 @@ +Console Tool + +Usage: + [options] command [arguments] + +Options: + --help -h Display this help message. + --quiet -q Do not output any message. + --verbose -v|vv|vvv Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug + --version -V Display this application version. + --ansi Force ANSI output. + --no-ansi Disable ANSI output. + --no-interaction -n Do not ask any interactive question. + +Available commands: + help Displays help for a command + list Lists commands diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/application_run2.txt b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/application_run2.txt new file mode 100755 index 0000000..33c2442 --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/application_run2.txt @@ -0,0 +1,29 @@ +Usage: + help [--xml] [--format="..."] [--raw] [command_name] + +Arguments: + command The command to execute + command_name The command name (default: "help") + +Options: + --xml To output help as XML + --format To output help in other formats (default: "txt") + --raw To output raw command help + --help (-h) Display this help message. + --quiet (-q) Do not output any message. + --verbose (-v|vv|vvv) Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug + --version (-V) Display this application version. + --ansi Force ANSI output. + --no-ansi Disable ANSI output. + --no-interaction (-n) Do not ask any interactive question. + +Help: + The help command displays help for a given command: + + php app/console help list + + You can also output the help in other formats by using the --format option: + + php app/console help --format=xml list + + To display the list of available commands, please use the list command. diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/application_run3.txt b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/application_run3.txt new file mode 100755 index 0000000..0139775 --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/application_run3.txt @@ -0,0 +1,27 @@ +Usage: + list [--xml] [--raw] [--format="..."] [namespace] + +Arguments: + namespace The namespace name + +Options: + --xml To output list as XML + --raw To output raw command list + --format To output list in other formats (default: "txt") + +Help: + The list command lists all commands: + + php app/console list + + You can also display the commands for a specific namespace: + + php app/console list test + + You can also output the information in other formats by using the --format option: + + php app/console list --format=xml + + It's also possible to get raw list of commands (useful for embedding command runner): + + php app/console list --raw diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/application_run4.txt b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/application_run4.txt new file mode 100755 index 0000000..47187fc --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/application_run4.txt @@ -0,0 +1 @@ +Console Tool diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/command_1.json b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/command_1.json new file mode 100755 index 0000000..0c1675d --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/command_1.json @@ -0,0 +1 @@ +{"name":"descriptor:command1","usage":"descriptor:command1","description":"command 1 description","help":"command 1 help","aliases":["alias1","alias2"],"definition":{"arguments":[],"options":[]}} diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/command_1.md b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/command_1.md new file mode 100755 index 0000000..2cef9a2 --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/command_1.md @@ -0,0 +1,8 @@ +descriptor:command1 +------------------- + +* Description: command 1 description +* Usage: `descriptor:command1` +* Aliases: `alias1`, `alias2` + +command 1 help diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/command_1.txt b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/command_1.txt new file mode 100755 index 0000000..2375ac0 --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/command_1.txt @@ -0,0 +1,7 @@ +Usage: + descriptor:command1 + +Aliases: alias1, alias2 + +Help: + command 1 help diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/command_1.xml b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/command_1.xml new file mode 100755 index 0000000..dcfa6fa --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/command_1.xml @@ -0,0 +1,12 @@ + + + descriptor:command1 + command 1 description + command 1 help + + alias1 + alias2 + + + + diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/command_2.json b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/command_2.json new file mode 100755 index 0000000..493b584 --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/command_2.json @@ -0,0 +1 @@ +{"name":"descriptor:command2","usage":"descriptor:command2 [-o|--option_name] argument_name","description":"command 2 description","help":"command 2 help","aliases":[],"definition":{"arguments":{"argument_name":{"name":"argument_name","is_required":true,"is_array":false,"description":"","default":null}},"options":{"option_name":{"name":"--option_name","shortcut":"-o","accept_value":false,"is_value_required":false,"is_multiple":false,"description":"","default":false}}}} diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/command_2.md b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/command_2.md new file mode 100755 index 0000000..5257c0d --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/command_2.md @@ -0,0 +1,30 @@ +descriptor:command2 +------------------- + +* Description: command 2 description +* Usage: `descriptor:command2 [-o|--option_name] argument_name` +* Aliases: + +command 2 help + +### Arguments: + +**argument_name:** + +* Name: argument_name +* Is required: yes +* Is array: no +* Description: +* Default: `NULL` + +### Options: + +**option_name:** + +* Name: `--option_name` +* Shortcut: `-o` +* Accept value: no +* Is value required: no +* Is multiple: no +* Description: +* Default: `false` diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/command_2.txt b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/command_2.txt new file mode 100755 index 0000000..1da9f3d --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/command_2.txt @@ -0,0 +1,11 @@ +Usage: + descriptor:command2 [-o|--option_name] argument_name + +Arguments: + argument_name + +Options: + --option_name (-o) + +Help: + command 2 help diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/command_2.xml b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/command_2.xml new file mode 100755 index 0000000..c411c36 --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/command_2.xml @@ -0,0 +1,18 @@ + + + descriptor:command2 [-o|--option_name] argument_name + command 2 description + command 2 help + + + + + + + + + + + diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/command_astext.txt b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/command_astext.txt new file mode 100755 index 0000000..8b6c74c --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/command_astext.txt @@ -0,0 +1,18 @@ +Usage: + namespace:name + +Aliases: name +Arguments: + command The command to execute + +Options: + --help (-h) Display this help message. + --quiet (-q) Do not output any message. + --verbose (-v|vv|vvv) Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug + --version (-V) Display this application version. + --ansi Force ANSI output. + --no-ansi Disable ANSI output. + --no-interaction (-n) Do not ask any interactive question. + +Help: + help diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/command_asxml.txt b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/command_asxml.txt new file mode 100755 index 0000000..4b0012d --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/command_asxml.txt @@ -0,0 +1,38 @@ + + + namespace:name + description + help + + name + + + + The command to execute + + + + + + + + + + + + + diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/definition_astext.txt b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/definition_astext.txt new file mode 100755 index 0000000..a7d7e0d --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/definition_astext.txt @@ -0,0 +1,11 @@ +Arguments: + foo The foo argument + baz The baz argument (default: true) + bar The bar argument (default: ["http://foo.com/"]) + +Options: + --foo (-f) The foo option + --baz The baz option (default: false) + --bar (-b) The bar option (default: "bar") + --qux The qux option (default: ["http://foo.com/","bar"]) (multiple values allowed) + --qux2 The qux2 option (default: {"foo":"bar"}) (multiple values allowed) diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/definition_asxml.txt b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/definition_asxml.txt new file mode 100755 index 0000000..eec8c07 --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/definition_asxml.txt @@ -0,0 +1,39 @@ + + + + + The foo argument + + + + The baz argument + + true + + + + The bar argument + + bar + + + + + + + + + diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_argument_1.json b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_argument_1.json new file mode 100755 index 0000000..b8173b6 --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_argument_1.json @@ -0,0 +1 @@ +{"name":"argument_name","is_required":true,"is_array":false,"description":"","default":null} diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_argument_1.md b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_argument_1.md new file mode 100755 index 0000000..88f311a --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_argument_1.md @@ -0,0 +1,7 @@ +**argument_name:** + +* Name: argument_name +* Is required: yes +* Is array: no +* Description: +* Default: `NULL` diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_argument_1.txt b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_argument_1.txt new file mode 100755 index 0000000..111e515 --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_argument_1.txt @@ -0,0 +1 @@ + argument_name diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_argument_1.xml b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_argument_1.xml new file mode 100755 index 0000000..cb37f81 --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_argument_1.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_argument_2.json b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_argument_2.json new file mode 100755 index 0000000..ef06b09 --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_argument_2.json @@ -0,0 +1 @@ +{"name":"argument_name","is_required":false,"is_array":true,"description":"argument description","default":[]} diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_argument_2.md b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_argument_2.md new file mode 100755 index 0000000..3cdb00c --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_argument_2.md @@ -0,0 +1,7 @@ +**argument_name:** + +* Name: argument_name +* Is required: no +* Is array: yes +* Description: argument description +* Default: `array ()` diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_argument_2.txt b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_argument_2.txt new file mode 100755 index 0000000..9497b1c --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_argument_2.txt @@ -0,0 +1 @@ + argument_name argument description diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_argument_2.xml b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_argument_2.xml new file mode 100755 index 0000000..629da5a --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_argument_2.xml @@ -0,0 +1,5 @@ + + + argument description + + diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_argument_3.json b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_argument_3.json new file mode 100755 index 0000000..de8484e --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_argument_3.json @@ -0,0 +1 @@ +{"name":"argument_name","is_required":false,"is_array":false,"description":"argument description","default":"default_value"} diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_argument_3.md b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_argument_3.md new file mode 100755 index 0000000..be1c443 --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_argument_3.md @@ -0,0 +1,7 @@ +**argument_name:** + +* Name: argument_name +* Is required: no +* Is array: no +* Description: argument description +* Default: `'default_value'` diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_argument_3.txt b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_argument_3.txt new file mode 100755 index 0000000..c421fc9 --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_argument_3.txt @@ -0,0 +1 @@ + argument_name argument description (default: "default_value") diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_argument_3.xml b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_argument_3.xml new file mode 100755 index 0000000..399a5c8 --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_argument_3.xml @@ -0,0 +1,7 @@ + + + argument description + + default_value + + diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_definition_1.json b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_definition_1.json new file mode 100755 index 0000000..c7a7d83 --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_definition_1.json @@ -0,0 +1 @@ +{"arguments":[],"options":[]} diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_definition_1.md b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_definition_1.md new file mode 100755 index 0000000..e69de29 diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_definition_1.txt b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_definition_1.txt new file mode 100755 index 0000000..e69de29 diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_definition_1.xml b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_definition_1.xml new file mode 100755 index 0000000..b5481ce --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_definition_1.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_definition_2.json b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_definition_2.json new file mode 100755 index 0000000..9964a55 --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_definition_2.json @@ -0,0 +1 @@ +{"arguments":{"argument_name":{"name":"argument_name","is_required":true,"is_array":false,"description":"","default":null}},"options":[]} diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_definition_2.md b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_definition_2.md new file mode 100755 index 0000000..923191c --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_definition_2.md @@ -0,0 +1,9 @@ +### Arguments: + +**argument_name:** + +* Name: argument_name +* Is required: yes +* Is array: no +* Description: +* Default: `NULL` diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_definition_2.txt b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_definition_2.txt new file mode 100755 index 0000000..0db9f66 --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_definition_2.txt @@ -0,0 +1,2 @@ +Arguments: + argument_name diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_definition_2.xml b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_definition_2.xml new file mode 100755 index 0000000..102efc1 --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_definition_2.xml @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_definition_3.json b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_definition_3.json new file mode 100755 index 0000000..6a86056 --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_definition_3.json @@ -0,0 +1 @@ +{"arguments":[],"options":{"option_name":{"name":"--option_name","shortcut":"-o","accept_value":false,"is_value_required":false,"is_multiple":false,"description":"","default":false}}} diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_definition_3.md b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_definition_3.md new file mode 100755 index 0000000..40fd7b0 --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_definition_3.md @@ -0,0 +1,11 @@ +### Options: + +**option_name:** + +* Name: `--option_name` +* Shortcut: `-o` +* Accept value: no +* Is value required: no +* Is multiple: no +* Description: +* Default: `false` diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_definition_3.txt b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_definition_3.txt new file mode 100755 index 0000000..c6fb2cc --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_definition_3.txt @@ -0,0 +1,2 @@ +Options: + --option_name (-o) diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_definition_3.xml b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_definition_3.xml new file mode 100755 index 0000000..bc95151 --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_definition_3.xml @@ -0,0 +1,9 @@ + + + + + + + diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_definition_4.json b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_definition_4.json new file mode 100755 index 0000000..c5a0019 --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_definition_4.json @@ -0,0 +1 @@ +{"arguments":{"argument_name":{"name":"argument_name","is_required":true,"is_array":false,"description":"","default":null}},"options":{"option_name":{"name":"--option_name","shortcut":"-o","accept_value":false,"is_value_required":false,"is_multiple":false,"description":"","default":false}}} diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_definition_4.md b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_definition_4.md new file mode 100755 index 0000000..a31feea --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_definition_4.md @@ -0,0 +1,21 @@ +### Arguments: + +**argument_name:** + +* Name: argument_name +* Is required: yes +* Is array: no +* Description: +* Default: `NULL` + +### Options: + +**option_name:** + +* Name: `--option_name` +* Shortcut: `-o` +* Accept value: no +* Is value required: no +* Is multiple: no +* Description: +* Default: `false` diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_definition_4.txt b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_definition_4.txt new file mode 100755 index 0000000..e17c61c --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_definition_4.txt @@ -0,0 +1,5 @@ +Arguments: + argument_name + +Options: + --option_name (-o) diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_definition_4.xml b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_definition_4.xml new file mode 100755 index 0000000..cffceec --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_definition_4.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_option_1.json b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_option_1.json new file mode 100755 index 0000000..60c5b56 --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_option_1.json @@ -0,0 +1 @@ +{"name":"--option_name","shortcut":"-o","accept_value":false,"is_value_required":false,"is_multiple":false,"description":"","default":false} diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_option_1.md b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_option_1.md new file mode 100755 index 0000000..6f9e9a7 --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_option_1.md @@ -0,0 +1,9 @@ +**option_name:** + +* Name: `--option_name` +* Shortcut: `-o` +* Accept value: no +* Is value required: no +* Is multiple: no +* Description: +* Default: `false` diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_option_1.txt b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_option_1.txt new file mode 100755 index 0000000..daf83d0 --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_option_1.txt @@ -0,0 +1 @@ + --option_name (-o) diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_option_1.xml b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_option_1.xml new file mode 100755 index 0000000..8a64ea6 --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_option_1.xml @@ -0,0 +1,4 @@ + + diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_option_2.json b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_option_2.json new file mode 100755 index 0000000..04e4228 --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_option_2.json @@ -0,0 +1 @@ +{"name":"--option_name","shortcut":"-o","accept_value":true,"is_value_required":false,"is_multiple":false,"description":"option description","default":"default_value"} diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_option_2.md b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_option_2.md new file mode 100755 index 0000000..634ac0b --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_option_2.md @@ -0,0 +1,9 @@ +**option_name:** + +* Name: `--option_name` +* Shortcut: `-o` +* Accept value: yes +* Is value required: no +* Is multiple: no +* Description: option description +* Default: `'default_value'` diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_option_2.txt b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_option_2.txt new file mode 100755 index 0000000..627e3c1 --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_option_2.txt @@ -0,0 +1 @@ + --option_name (-o) option description (default: "default_value") diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_option_2.xml b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_option_2.xml new file mode 100755 index 0000000..4afac5b --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_option_2.xml @@ -0,0 +1,7 @@ + + diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_option_3.json b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_option_3.json new file mode 100755 index 0000000..c1ea120 --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_option_3.json @@ -0,0 +1 @@ +{"name":"--option_name","shortcut":"-o","accept_value":true,"is_value_required":true,"is_multiple":false,"description":"option description","default":null} diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_option_3.md b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_option_3.md new file mode 100755 index 0000000..3428289 --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_option_3.md @@ -0,0 +1,9 @@ +**option_name:** + +* Name: `--option_name` +* Shortcut: `-o` +* Accept value: yes +* Is value required: yes +* Is multiple: no +* Description: option description +* Default: `NULL` diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_option_3.txt b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_option_3.txt new file mode 100755 index 0000000..b88b12d --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_option_3.txt @@ -0,0 +1 @@ + --option_name (-o) option description diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_option_3.xml b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_option_3.xml new file mode 100755 index 0000000..dcc0631 --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_option_3.xml @@ -0,0 +1,5 @@ + + diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_option_4.json b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_option_4.json new file mode 100755 index 0000000..1b671d8 --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_option_4.json @@ -0,0 +1 @@ +{"name":"--option_name","shortcut":"-o","accept_value":true,"is_value_required":false,"is_multiple":true,"description":"option description","default":[]} diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_option_4.md b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_option_4.md new file mode 100755 index 0000000..8ffba56 --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_option_4.md @@ -0,0 +1,9 @@ +**option_name:** + +* Name: `--option_name` +* Shortcut: `-o` +* Accept value: yes +* Is value required: no +* Is multiple: yes +* Description: option description +* Default: `array ()` diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_option_4.txt b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_option_4.txt new file mode 100755 index 0000000..5dba5e6 --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_option_4.txt @@ -0,0 +1 @@ + --option_name (-o) option description (multiple values allowed) diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_option_4.xml b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_option_4.xml new file mode 100755 index 0000000..5e2418b --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Tests/Fixtures/input_option_4.xml @@ -0,0 +1,5 @@ + + diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Formatter/OutputFormatterStyleStackTest.php b/vendor/symfony/console/Symfony/Component/Console/Tests/Formatter/OutputFormatterStyleStackTest.php new file mode 100755 index 0000000..774df26 --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Tests/Formatter/OutputFormatterStyleStackTest.php @@ -0,0 +1,70 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Console\Tests\Formatter; + +use Symfony\Component\Console\Formatter\OutputFormatterStyleStack; +use Symfony\Component\Console\Formatter\OutputFormatterStyle; + +class OutputFormatterStyleStackTest extends \PHPUnit_Framework_TestCase +{ + public function testPush() + { + $stack = new OutputFormatterStyleStack(); + $stack->push($s1 = new OutputFormatterStyle('white', 'black')); + $stack->push($s2 = new OutputFormatterStyle('yellow', 'blue')); + + $this->assertEquals($s2, $stack->getCurrent()); + + $stack->push($s3 = new OutputFormatterStyle('green', 'red')); + + $this->assertEquals($s3, $stack->getCurrent()); + } + + public function testPop() + { + $stack = new OutputFormatterStyleStack(); + $stack->push($s1 = new OutputFormatterStyle('white', 'black')); + $stack->push($s2 = new OutputFormatterStyle('yellow', 'blue')); + + $this->assertEquals($s2, $stack->pop()); + $this->assertEquals($s1, $stack->pop()); + } + + public function testPopEmpty() + { + $stack = new OutputFormatterStyleStack(); + $style = new OutputFormatterStyle(); + + $this->assertEquals($style, $stack->pop()); + } + + public function testPopNotLast() + { + $stack = new OutputFormatterStyleStack(); + $stack->push($s1 = new OutputFormatterStyle('white', 'black')); + $stack->push($s2 = new OutputFormatterStyle('yellow', 'blue')); + $stack->push($s3 = new OutputFormatterStyle('green', 'red')); + + $this->assertEquals($s2, $stack->pop($s2)); + $this->assertEquals($s1, $stack->pop()); + } + + /** + * @expectedException \InvalidArgumentException + */ + public function testInvalidPop() + { + $stack = new OutputFormatterStyleStack(); + $stack->push(new OutputFormatterStyle('white', 'black')); + $stack->pop(new OutputFormatterStyle('yellow', 'blue')); + } +} diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Formatter/OutputFormatterStyleTest.php b/vendor/symfony/console/Symfony/Component/Console/Tests/Formatter/OutputFormatterStyleTest.php new file mode 100755 index 0000000..6890a9b --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Tests/Formatter/OutputFormatterStyleTest.php @@ -0,0 +1,93 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Console\Tests\Formatter; + +use Symfony\Component\Console\Formatter\OutputFormatterStyle; + +class OutputFormatterStyleTest extends \PHPUnit_Framework_TestCase +{ + public function testConstructor() + { + $style = new OutputFormatterStyle('green', 'black', array('bold', 'underscore')); + $this->assertEquals("\033[32;40;1;4mfoo\033[0m", $style->apply('foo')); + + $style = new OutputFormatterStyle('red', null, array('blink')); + $this->assertEquals("\033[31;5mfoo\033[0m", $style->apply('foo')); + + $style = new OutputFormatterStyle(null, 'white'); + $this->assertEquals("\033[47mfoo\033[0m", $style->apply('foo')); + } + + public function testForeground() + { + $style = new OutputFormatterStyle(); + + $style->setForeground('black'); + $this->assertEquals("\033[30mfoo\033[0m", $style->apply('foo')); + + $style->setForeground('blue'); + $this->assertEquals("\033[34mfoo\033[0m", $style->apply('foo')); + + $this->setExpectedException('InvalidArgumentException'); + $style->setForeground('undefined-color'); + } + + public function testBackground() + { + $style = new OutputFormatterStyle(); + + $style->setBackground('black'); + $this->assertEquals("\033[40mfoo\033[0m", $style->apply('foo')); + + $style->setBackground('yellow'); + $this->assertEquals("\033[43mfoo\033[0m", $style->apply('foo')); + + $this->setExpectedException('InvalidArgumentException'); + $style->setBackground('undefined-color'); + } + + public function testOptions() + { + $style = new OutputFormatterStyle(); + + $style->setOptions(array('reverse', 'conceal')); + $this->assertEquals("\033[7;8mfoo\033[0m", $style->apply('foo')); + + $style->setOption('bold'); + $this->assertEquals("\033[7;8;1mfoo\033[0m", $style->apply('foo')); + + $style->unsetOption('reverse'); + $this->assertEquals("\033[8;1mfoo\033[0m", $style->apply('foo')); + + $style->setOption('bold'); + $this->assertEquals("\033[8;1mfoo\033[0m", $style->apply('foo')); + + $style->setOptions(array('bold')); + $this->assertEquals("\033[1mfoo\033[0m", $style->apply('foo')); + + try { + $style->setOption('foo'); + $this->fail('->setOption() throws an \InvalidArgumentException when the option does not exist in the available options'); + } catch (\Exception $e) { + $this->assertInstanceOf('\InvalidArgumentException', $e, '->setOption() throws an \InvalidArgumentException when the option does not exist in the available options'); + $this->assertContains('Invalid option specified: "foo"', $e->getMessage(), '->setOption() throws an \InvalidArgumentException when the option does not exist in the available options'); + } + + try { + $style->unsetOption('foo'); + $this->fail('->unsetOption() throws an \InvalidArgumentException when the option does not exist in the available options'); + } catch (\Exception $e) { + $this->assertInstanceOf('\InvalidArgumentException', $e, '->unsetOption() throws an \InvalidArgumentException when the option does not exist in the available options'); + $this->assertContains('Invalid option specified: "foo"', $e->getMessage(), '->unsetOption() throws an \InvalidArgumentException when the option does not exist in the available options'); + } + } +} diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Formatter/OutputFormatterTest.php b/vendor/symfony/console/Symfony/Component/Console/Tests/Formatter/OutputFormatterTest.php new file mode 100755 index 0000000..c8f0b98 --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Tests/Formatter/OutputFormatterTest.php @@ -0,0 +1,252 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Console\Tests\Formatter; + +use Symfony\Component\Console\Formatter\OutputFormatter; +use Symfony\Component\Console\Formatter\OutputFormatterStyle; + +class OutputFormatterTest extends \PHPUnit_Framework_TestCase +{ + public function testEmptyTag() + { + $formatter = new OutputFormatter(true); + $this->assertEquals("foo<>bar", $formatter->format('foo<>bar')); + } + + public function testLGCharEscaping() + { + $formatter = new OutputFormatter(true); + + $this->assertEquals("fooformat('foo\\assertEquals("some info", $formatter->format('\\some info\\')); + $this->assertEquals("\\some info\\", OutputFormatter::escape('some info')); + + $this->assertEquals( + "\033[33mSymfony\\Component\\Console does work very well!\033[0m", + $formatter->format('Symfony\Component\Console does work very well!') + ); + } + + public function testBundledStyles() + { + $formatter = new OutputFormatter(true); + + $this->assertTrue($formatter->hasStyle('error')); + $this->assertTrue($formatter->hasStyle('info')); + $this->assertTrue($formatter->hasStyle('comment')); + $this->assertTrue($formatter->hasStyle('question')); + + $this->assertEquals( + "\033[37;41msome error\033[0m", + $formatter->format('some error') + ); + $this->assertEquals( + "\033[32msome info\033[0m", + $formatter->format('some info') + ); + $this->assertEquals( + "\033[33msome comment\033[0m", + $formatter->format('some comment') + ); + $this->assertEquals( + "\033[30;46msome question\033[0m", + $formatter->format('some question') + ); + } + + public function testNestedStyles() + { + $formatter = new OutputFormatter(true); + + $this->assertEquals( + "\033[37;41msome \033[0m\033[32msome info\033[0m\033[37;41m error\033[0m", + $formatter->format('some some info error') + ); + } + + public function testAdjacentStyles() + { + $formatter = new OutputFormatter(true); + + $this->assertEquals( + "\033[37;41msome error\033[0m\033[32msome info\033[0m", + $formatter->format('some errorsome info') + ); + } + + public function testStyleMatchingNotGreedy() + { + $formatter = new OutputFormatter(true); + + $this->assertEquals( + "(\033[32m>=2.0,<2.3\033[0m)", + $formatter->format('(>=2.0,<2.3)') + ); + } + + public function testStyleEscaping() + { + $formatter = new OutputFormatter(true); + + $this->assertEquals( + "(\033[32mz>=2.0,format('('.$formatter->escape('z>=2.0,)') + ); + } + + public function testDeepNestedStyles() + { + $formatter = new OutputFormatter(true); + + $this->assertEquals( + "\033[37;41merror\033[0m\033[32minfo\033[0m\033[33mcomment\033[0m\033[37;41merror\033[0m", + $formatter->format('errorinfocommenterror') + ); + } + + public function testNewStyle() + { + $formatter = new OutputFormatter(true); + + $style = new OutputFormatterStyle('blue', 'white'); + $formatter->setStyle('test', $style); + + $this->assertEquals($style, $formatter->getStyle('test')); + $this->assertNotEquals($style, $formatter->getStyle('info')); + + $style = new OutputFormatterStyle('blue', 'white'); + $formatter->setStyle('b', $style); + + $this->assertEquals("\033[34;47msome \033[0m\033[34;47mcustom\033[0m\033[34;47m msg\033[0m", $formatter->format('some custom msg')); + } + + public function testRedefineStyle() + { + $formatter = new OutputFormatter(true); + + $style = new OutputFormatterStyle('blue', 'white'); + $formatter->setStyle('info', $style); + + $this->assertEquals("\033[34;47msome custom msg\033[0m", $formatter->format('some custom msg')); + } + + public function testInlineStyle() + { + $formatter = new OutputFormatter(true); + + $this->assertEquals("\033[34;41msome text\033[0m", $formatter->format('some text')); + $this->assertEquals("\033[34;41msome text\033[0m", $formatter->format('some text')); + } + + public function testNonStyleTag() + { + $formatter = new OutputFormatter(true); + + $this->assertEquals("\033[32msome \033[0m\033[32m\033[0m\033[32m styled \033[0m\033[32m

    \033[0m\033[32msingle-char tag\033[0m\033[32m

    \033[0m", $formatter->format('some styled

    single-char tag

    ')); + } + + public function testFormatLongString() + { + $formatter = new OutputFormatter(true); + $long = str_repeat("\\", 14000); + $this->assertEquals("\033[37;41msome error\033[0m".$long, $formatter->format('some error'.$long)); + } + + public function testNotDecoratedFormatter() + { + $formatter = new OutputFormatter(false); + + $this->assertTrue($formatter->hasStyle('error')); + $this->assertTrue($formatter->hasStyle('info')); + $this->assertTrue($formatter->hasStyle('comment')); + $this->assertTrue($formatter->hasStyle('question')); + + $this->assertEquals( + "some error", $formatter->format('some error') + ); + $this->assertEquals( + "some info", $formatter->format('some info') + ); + $this->assertEquals( + "some comment", $formatter->format('some comment') + ); + $this->assertEquals( + "some question", $formatter->format('some question') + ); + + $formatter->setDecorated(true); + + $this->assertEquals( + "\033[37;41msome error\033[0m", $formatter->format('some error') + ); + $this->assertEquals( + "\033[32msome info\033[0m", $formatter->format('some info') + ); + $this->assertEquals( + "\033[33msome comment\033[0m", $formatter->format('some comment') + ); + $this->assertEquals( + "\033[30;46msome question\033[0m", $formatter->format('some question') + ); + } + + public function testContentWithLineBreaks() + { + $formatter = new OutputFormatter(true); + + $this->assertEquals(<<format(<< +some text
    +EOF + )); + + $this->assertEquals(<<format(<<some text +
    +EOF + )); + + $this->assertEquals(<<format(<< +some text +
    +EOF + )); + + $this->assertEquals(<<format(<< +some text +more text +
    +EOF + )); + } +} diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Helper/DialogHelperTest.php b/vendor/symfony/console/Symfony/Component/Console/Tests/Helper/DialogHelperTest.php new file mode 100755 index 0000000..5364f38 --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Tests/Helper/DialogHelperTest.php @@ -0,0 +1,192 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Console\Tests\Helper; + +use Symfony\Component\Console\Input\ArrayInput; +use Symfony\Component\Console\Helper\DialogHelper; +use Symfony\Component\Console\Helper\HelperSet; +use Symfony\Component\Console\Helper\FormatterHelper; +use Symfony\Component\Console\Output\StreamOutput; + +class DialogHelperTest extends \PHPUnit_Framework_TestCase +{ + public function testSelect() + { + $dialog = new DialogHelper(); + + $helperSet = new HelperSet(array(new FormatterHelper())); + $dialog->setHelperSet($helperSet); + + $heroes = array('Superman', 'Batman', 'Spiderman'); + + $dialog->setInputStream($this->getInputStream("\n1\n 1 \nFabien\n1\nFabien\n1\n0,2\n 0 , 2 \n\n\n")); + $this->assertEquals('2', $dialog->select($this->getOutputStream(), 'What is your favorite superhero?', $heroes, '2')); + $this->assertEquals('1', $dialog->select($this->getOutputStream(), 'What is your favorite superhero?', $heroes)); + $this->assertEquals('1', $dialog->select($this->getOutputStream(), 'What is your favorite superhero?', $heroes)); + $this->assertEquals('1', $dialog->select($output = $this->getOutputStream(), 'What is your favorite superhero?', $heroes, null, false, 'Input "%s" is not a superhero!', false)); + + rewind($output->getStream()); + $this->assertContains('Input "Fabien" is not a superhero!', stream_get_contents($output->getStream())); + + try { + $this->assertEquals('1', $dialog->select($output = $this->getOutputStream(), 'What is your favorite superhero?', $heroes, null, 1)); + $this->fail(); + } catch (\InvalidArgumentException $e) { + $this->assertEquals('Value "Fabien" is invalid', $e->getMessage()); + } + + $this->assertEquals(array('1'), $dialog->select($this->getOutputStream(), 'What is your favorite superhero?', $heroes, null, false, 'Input "%s" is not a superhero!', true)); + $this->assertEquals(array('0', '2'), $dialog->select($this->getOutputStream(), 'What is your favorite superhero?', $heroes, null, false, 'Input "%s" is not a superhero!', true)); + $this->assertEquals(array('0', '2'), $dialog->select($this->getOutputStream(), 'What is your favorite superhero?', $heroes, null, false, 'Input "%s" is not a superhero!', true)); + $this->assertEquals(array('0', '1'), $dialog->select($this->getOutputStream(), 'What is your favorite superhero?', $heroes, '0,1', false, 'Input "%s" is not a superhero!', true)); + $this->assertEquals(array('0', '1'), $dialog->select($this->getOutputStream(), 'What is your favorite superhero?', $heroes, ' 0 , 1 ', false, 'Input "%s" is not a superhero!', true)); + } + + public function testAsk() + { + $dialog = new DialogHelper(); + + $dialog->setInputStream($this->getInputStream("\n8AM\n")); + + $this->assertEquals('2PM', $dialog->ask($this->getOutputStream(), 'What time is it?', '2PM')); + $this->assertEquals('8AM', $dialog->ask($output = $this->getOutputStream(), 'What time is it?', '2PM')); + + rewind($output->getStream()); + $this->assertEquals('What time is it?', stream_get_contents($output->getStream())); + } + + public function testAskWithAutocomplete() + { + if (!$this->hasSttyAvailable()) { + $this->markTestSkipped('`stty` is required to test autocomplete functionality'); + } + + // Acm + // AcsTest + // + // + // Test + // + // S + // F00oo + $inputStream = $this->getInputStream("Acm\nAc\177\177s\tTest\n\n\033[A\033[A\n\033[A\033[A\033[A\033[A\033[A\tTest\n\033[B\nS\177\177\033[B\033[B\nF00\177\177oo\t\n"); + + $dialog = new DialogHelper(); + $dialog->setInputStream($inputStream); + + $bundles = array('AcmeDemoBundle', 'AsseticBundle', 'SecurityBundle', 'FooBundle'); + + $this->assertEquals('AcmeDemoBundle', $dialog->ask($this->getOutputStream(), 'Please select a bundle', 'FrameworkBundle', $bundles)); + $this->assertEquals('AsseticBundleTest', $dialog->ask($this->getOutputStream(), 'Please select a bundle', 'FrameworkBundle', $bundles)); + $this->assertEquals('FrameworkBundle', $dialog->ask($this->getOutputStream(), 'Please select a bundle', 'FrameworkBundle', $bundles)); + $this->assertEquals('SecurityBundle', $dialog->ask($this->getOutputStream(), 'Please select a bundle', 'FrameworkBundle', $bundles)); + $this->assertEquals('FooBundleTest', $dialog->ask($this->getOutputStream(), 'Please select a bundle', 'FrameworkBundle', $bundles)); + $this->assertEquals('AcmeDemoBundle', $dialog->ask($this->getOutputStream(), 'Please select a bundle', 'FrameworkBundle', $bundles)); + $this->assertEquals('AsseticBundle', $dialog->ask($this->getOutputStream(), 'Please select a bundle', 'FrameworkBundle', $bundles)); + $this->assertEquals('FooBundle', $dialog->ask($this->getOutputStream(), 'Please select a bundle', 'FrameworkBundle', $bundles)); + } + + /** + * @group tty + */ + public function testAskHiddenResponse() + { + if (defined('PHP_WINDOWS_VERSION_BUILD')) { + $this->markTestSkipped('This test is not supported on Windows'); + } + + $dialog = new DialogHelper(); + + $dialog->setInputStream($this->getInputStream("8AM\n")); + + $this->assertEquals('8AM', $dialog->askHiddenResponse($this->getOutputStream(), 'What time is it?')); + } + + public function testAskConfirmation() + { + $dialog = new DialogHelper(); + + $dialog->setInputStream($this->getInputStream("\n\n")); + $this->assertTrue($dialog->askConfirmation($this->getOutputStream(), 'Do you like French fries?')); + $this->assertFalse($dialog->askConfirmation($this->getOutputStream(), 'Do you like French fries?', false)); + + $dialog->setInputStream($this->getInputStream("y\nyes\n")); + $this->assertTrue($dialog->askConfirmation($this->getOutputStream(), 'Do you like French fries?', false)); + $this->assertTrue($dialog->askConfirmation($this->getOutputStream(), 'Do you like French fries?', false)); + + $dialog->setInputStream($this->getInputStream("n\nno\n")); + $this->assertFalse($dialog->askConfirmation($this->getOutputStream(), 'Do you like French fries?', true)); + $this->assertFalse($dialog->askConfirmation($this->getOutputStream(), 'Do you like French fries?', true)); + } + + public function testAskAndValidate() + { + $dialog = new DialogHelper(); + $helperSet = new HelperSet(array(new FormatterHelper())); + $dialog->setHelperSet($helperSet); + + $question ='What color was the white horse of Henry IV?'; + $error = 'This is not a color!'; + $validator = function ($color) use ($error) { + if (!in_array($color, array('white', 'black'))) { + throw new \InvalidArgumentException($error); + } + + return $color; + }; + + $dialog->setInputStream($this->getInputStream("\nblack\n")); + $this->assertEquals('white', $dialog->askAndValidate($this->getOutputStream(), $question, $validator, 2, 'white')); + $this->assertEquals('black', $dialog->askAndValidate($this->getOutputStream(), $question, $validator, 2, 'white')); + + $dialog->setInputStream($this->getInputStream("green\nyellow\norange\n")); + try { + $this->assertEquals('white', $dialog->askAndValidate($this->getOutputStream(), $question, $validator, 2, 'white')); + $this->fail(); + } catch (\InvalidArgumentException $e) { + $this->assertEquals($error, $e->getMessage()); + } + } + + public function testNoInteraction() + { + $dialog = new DialogHelper(); + + $input = new ArrayInput(array()); + $input->setInteractive(false); + + $dialog->setInput($input); + + $this->assertEquals('not yet', $dialog->ask($this->getOutputStream(), 'Do you have a job?', 'not yet')); + } + + protected function getInputStream($input) + { + $stream = fopen('php://memory', 'r+', false); + fputs($stream, $input); + rewind($stream); + + return $stream; + } + + protected function getOutputStream() + { + return new StreamOutput(fopen('php://memory', 'r+', false)); + } + + private function hasSttyAvailable() + { + exec('stty 2>&1', $output, $exitcode); + + return $exitcode === 0; + } +} diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Helper/FormatterHelperTest.php b/vendor/symfony/console/Symfony/Component/Console/Tests/Helper/FormatterHelperTest.php new file mode 100755 index 0000000..db61de4 --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Tests/Helper/FormatterHelperTest.php @@ -0,0 +1,99 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Console\Tests\Helper; + +use Symfony\Component\Console\Helper\FormatterHelper; + +class FormatterHelperTest extends \PHPUnit_Framework_TestCase +{ + public function testFormatSection() + { + $formatter = new FormatterHelper(); + + $this->assertEquals( + '[cli] Some text to display', + $formatter->formatSection('cli', 'Some text to display'), + '::formatSection() formats a message in a section' + ); + } + + public function testFormatBlock() + { + $formatter = new FormatterHelper(); + + $this->assertEquals( + ' Some text to display ', + $formatter->formatBlock('Some text to display', 'error'), + '::formatBlock() formats a message in a block' + ); + + $this->assertEquals( + ' Some text to display '."\n" . + ' foo bar ', + $formatter->formatBlock(array('Some text to display', 'foo bar'), 'error'), + '::formatBlock() formats a message in a block' + ); + + $this->assertEquals( + ' '."\n" . + ' Some text to display '."\n" . + ' ', + $formatter->formatBlock('Some text to display', 'error', true), + '::formatBlock() formats a message in a block' + ); + } + + public function testFormatBlockWithDiacriticLetters() + { + if (!function_exists('mb_detect_encoding')) { + $this->markTestSkipped('This test requires mbstring to work.'); + } + + $formatter = new FormatterHelper(); + + $this->assertEquals( + ' '."\n" . + ' Du texte à afficher '."\n" . + ' ', + $formatter->formatBlock('Du texte à afficher', 'error', true), + '::formatBlock() formats a message in a block' + ); + } + + public function testFormatBlockWithDoubleWidthDiacriticLetters() + { + if (!extension_loaded('mbstring')) { + $this->markTestSkipped('This test requires mbstring to work.'); + } + $formatter = new FormatterHelper(); + $this->assertEquals( + ' '."\n" . + ' 表示ã™ã‚‹ãƒ†ã‚­ã‚¹ãƒˆ '."\n" . + ' ', + $formatter->formatBlock('表示ã™ã‚‹ãƒ†ã‚­ã‚¹ãƒˆ', 'error', true), + '::formatBlock() formats a message in a block' + ); + } + + public function testFormatBlockLGEscaping() + { + $formatter = new FormatterHelper(); + + $this->assertEquals( + ' '."\n" . + ' \some info\ '."\n" . + ' ', + $formatter->formatBlock('some info', 'error', true), + '::formatBlock() escapes \'<\' chars' + ); + } +} diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Helper/HelperSetTest.php b/vendor/symfony/console/Symfony/Component/Console/Tests/Helper/HelperSetTest.php new file mode 100755 index 0000000..a6ccde2 --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Tests/Helper/HelperSetTest.php @@ -0,0 +1,153 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Console\Tests\Helper; + +use Symfony\Component\Console\Helper\HelperSet; +use Symfony\Component\Console\Command\Command; + +class HelperSetTest extends \PHPUnit_Framework_TestCase +{ + /** + * @covers \Symfony\Component\Console\Helper\HelperSet::__construct + */ + public function testConstructor() + { + $mock_helper = $this->getGenericMockHelper('fake_helper'); + $helperset = new HelperSet(array('fake_helper_alias' => $mock_helper)); + + $this->assertEquals($mock_helper, $helperset->get('fake_helper_alias'), '__construct sets given helper to helpers'); + $this->assertTrue($helperset->has('fake_helper_alias'), '__construct sets helper alias for given helper'); + } + + /** + * @covers \Symfony\Component\Console\Helper\HelperSet::set + */ + public function testSet() + { + $helperset = new HelperSet(); + $helperset->set($this->getGenericMockHelper('fake_helper', $helperset)); + $this->assertTrue($helperset->has('fake_helper'), '->set() adds helper to helpers'); + + $helperset = new HelperSet(); + $helperset->set($this->getGenericMockHelper('fake_helper_01', $helperset)); + $helperset->set($this->getGenericMockHelper('fake_helper_02', $helperset)); + $this->assertTrue($helperset->has('fake_helper_01'), '->set() will set multiple helpers on consecutive calls'); + $this->assertTrue($helperset->has('fake_helper_02'), '->set() will set multiple helpers on consecutive calls'); + + $helperset = new HelperSet(); + $helperset->set($this->getGenericMockHelper('fake_helper', $helperset), 'fake_helper_alias'); + $this->assertTrue($helperset->has('fake_helper'), '->set() adds helper alias when set'); + $this->assertTrue($helperset->has('fake_helper_alias'), '->set() adds helper alias when set'); + } + + /** + * @covers \Symfony\Component\Console\Helper\HelperSet::has + */ + public function testHas() + { + $helperset = new HelperSet(array('fake_helper_alias' => $this->getGenericMockHelper('fake_helper'))); + $this->assertTrue($helperset->has('fake_helper'), '->has() finds set helper'); + $this->assertTrue($helperset->has('fake_helper_alias'), '->has() finds set helper by alias'); + } + + /** + * @covers \Symfony\Component\Console\Helper\HelperSet::get + */ + public function testGet() + { + $helper_01 = $this->getGenericMockHelper('fake_helper_01'); + $helper_02 = $this->getGenericMockHelper('fake_helper_02'); + $helperset = new HelperSet(array('fake_helper_01_alias' => $helper_01, 'fake_helper_02_alias' => $helper_02)); + $this->assertEquals($helper_01, $helperset->get('fake_helper_01'), '->get() returns correct helper by name'); + $this->assertEquals($helper_01, $helperset->get('fake_helper_01_alias'), '->get() returns correct helper by alias'); + $this->assertEquals($helper_02, $helperset->get('fake_helper_02'), '->get() returns correct helper by name'); + $this->assertEquals($helper_02, $helperset->get('fake_helper_02_alias'), '->get() returns correct helper by alias'); + + $helperset = new HelperSet(); + try { + $helperset->get('foo'); + $this->fail('->get() throws \InvalidArgumentException when helper not found'); + } catch (\Exception $e) { + $this->assertInstanceOf('\InvalidArgumentException', $e, '->get() throws \InvalidArgumentException when helper not found'); + $this->assertContains('The helper "foo" is not defined.', $e->getMessage(), '->get() throws \InvalidArgumentException when helper not found'); + } + } + + /** + * @covers \Symfony\Component\Console\Helper\HelperSet::setCommand + */ + public function testSetCommand() + { + $cmd_01 = new Command('foo'); + $cmd_02 = new Command('bar'); + + $helperset = new HelperSet(); + $helperset->setCommand($cmd_01); + $this->assertEquals($cmd_01, $helperset->getCommand(), '->setCommand() stores given command'); + + $helperset = new HelperSet(); + $helperset->setCommand($cmd_01); + $helperset->setCommand($cmd_02); + $this->assertEquals($cmd_02, $helperset->getCommand(), '->setCommand() overwrites stored command with consecutive calls'); + } + + /** + * @covers \Symfony\Component\Console\Helper\HelperSet::getCommand + */ + public function testGetCommand() + { + $cmd = new Command('foo'); + $helperset = new HelperSet(); + $helperset->setCommand($cmd); + $this->assertEquals($cmd, $helperset->getCommand(), '->getCommand() retrieves stored command'); + } + + /** + * @covers \Symfony\Component\Console\Helper\HelperSet::getIterator + */ + public function testIteration() + { + $helperset = new HelperSet(); + $helperset->set($this->getGenericMockHelper('fake_helper_01', $helperset)); + $helperset->set($this->getGenericMockHelper('fake_helper_02', $helperset)); + + $helpers = array('fake_helper_01', 'fake_helper_02'); + $i = 0; + + foreach ($helperset as $helper) { + $this->assertEquals($helpers[$i++], $helper->getName()); + } + } + + /** + * Create a generic mock for the helper interface. Optionally check for a call to setHelperSet with a specific + * helperset instance. + * + * @param string $name + * @param HelperSet $helperset allows a mock to verify a particular helperset set is being added to the Helper + */ + private function getGenericMockHelper($name, HelperSet $helperset = null) + { + $mock_helper = $this->getMock('\Symfony\Component\Console\Helper\HelperInterface'); + $mock_helper->expects($this->any()) + ->method('getName') + ->will($this->returnValue($name)); + + if ($helperset) { + $mock_helper->expects($this->any()) + ->method('setHelperSet') + ->with($this->equalTo($helperset)); + } + + return $mock_helper; + } +} diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Helper/ProgressHelperTest.php b/vendor/symfony/console/Symfony/Component/Console/Tests/Helper/ProgressHelperTest.php new file mode 100755 index 0000000..40d856f --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Tests/Helper/ProgressHelperTest.php @@ -0,0 +1,214 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Console\Tests\Helper; + +use Symfony\Component\Console\Helper\ProgressHelper; +use Symfony\Component\Console\Output\StreamOutput; + +class ProgressHelperTest extends \PHPUnit_Framework_TestCase +{ + public function testAdvance() + { + $progress = new ProgressHelper(); + $progress->start($output = $this->getOutputStream()); + $progress->advance(); + + rewind($output->getStream()); + $this->assertEquals($this->generateOutput(' 1 [->--------------------------]'), stream_get_contents($output->getStream())); + } + + public function testAdvanceWithStep() + { + $progress = new ProgressHelper(); + $progress->start($output = $this->getOutputStream()); + $progress->advance(5); + + rewind($output->getStream()); + $this->assertEquals($this->generateOutput(' 5 [----->----------------------]'), stream_get_contents($output->getStream())); + } + + public function testAdvanceMultipleTimes() + { + $progress = new ProgressHelper(); + $progress->start($output = $this->getOutputStream()); + $progress->advance(3); + $progress->advance(2); + + rewind($output->getStream()); + $this->assertEquals($this->generateOutput(' 3 [--->------------------------]').$this->generateOutput(' 5 [----->----------------------]'), stream_get_contents($output->getStream())); + } + + public function testCustomizations() + { + $progress = new ProgressHelper(); + $progress->setBarWidth(10); + $progress->setBarCharacter('_'); + $progress->setEmptyBarCharacter(' '); + $progress->setProgressCharacter('/'); + $progress->setFormat(' %current%/%max% [%bar%] %percent%%'); + $progress->start($output = $this->getOutputStream(), 10); + $progress->advance(); + + rewind($output->getStream()); + $this->assertEquals($this->generateOutput(' 1/10 [_/ ] 10%'), stream_get_contents($output->getStream())); + } + + public function testPercent() + { + $progress = new ProgressHelper(); + $progress->start($output = $this->getOutputStream(), 50); + $progress->display(); + $progress->advance(); + $progress->advance(); + + rewind($output->getStream()); + $this->assertEquals($this->generateOutput(' 0/50 [>---------------------------] 0%').$this->generateOutput(' 1/50 [>---------------------------] 2%').$this->generateOutput(' 2/50 [=>--------------------------] 4%'), stream_get_contents($output->getStream())); + } + + public function testOverwriteWithShorterLine() + { + $progress = new ProgressHelper(); + $progress->setFormat(' %current%/%max% [%bar%] %percent%%'); + $progress->start($output = $this->getOutputStream(), 50); + $progress->display(); + $progress->advance(); + + // set shorter format + $progress->setFormat(' %current%/%max% [%bar%]'); + $progress->advance(); + + rewind($output->getStream()); + $this->assertEquals( + $this->generateOutput(' 0/50 [>---------------------------] 0%') . + $this->generateOutput(' 1/50 [>---------------------------] 2%') . + $this->generateOutput(' 2/50 [=>--------------------------] '), + stream_get_contents($output->getStream()) + ); + } + + public function testSetCurrentProgress() + { + $progress = new ProgressHelper(); + $progress->start($output = $this->getOutputStream(), 50); + $progress->display(); + $progress->advance(); + $progress->setCurrent(15); + $progress->setCurrent(25); + + rewind($output->getStream()); + $this->assertEquals( + $this->generateOutput(' 0/50 [>---------------------------] 0%') . + $this->generateOutput(' 1/50 [>---------------------------] 2%') . + $this->generateOutput(' 15/50 [========>-------------------] 30%') . + $this->generateOutput(' 25/50 [==============>-------------] 50%'), + stream_get_contents($output->getStream()) + ); + } + + /** + * @expectedException \LogicException + * @expectedExceptionMessage You must start the progress bar + */ + public function testSetCurrentBeforeStarting() + { + $progress = new ProgressHelper(); + $progress->setCurrent(15); + } + + /** + * @expectedException \LogicException + * @expectedExceptionMessage You can't regress the progress bar + */ + public function testRegressProgress() + { + $progress = new ProgressHelper(); + $progress->start($output = $this->getOutputStream(), 50); + $progress->setCurrent(15); + $progress->setCurrent(10); + } + + public function testRedrawFrequency() + { + $progress = $this->getMock('Symfony\Component\Console\Helper\ProgressHelper', array('display')); + $progress->expects($this->exactly(4)) + ->method('display'); + + $progress->setRedrawFrequency(2); + + $progress->start($output = $this->getOutputStream(), 6); + $progress->setCurrent(1); + $progress->advance(2); + $progress->advance(2); + $progress->advance(1); + } + + public function testMultiByteSupport() + { + if (!function_exists('mb_strlen') || (false === $encoding = mb_detect_encoding('â– '))) { + $this->markTestSkipped('The mbstring extension is needed for multi-byte support'); + } + + $progress = new ProgressHelper(); + $progress->start($output = $this->getOutputStream()); + $progress->setBarCharacter('â– '); + $progress->advance(3); + + rewind($output->getStream()); + $this->assertEquals($this->generateOutput(' 3 [â– â– â– >------------------------]'), stream_get_contents($output->getStream())); + } + + public function testClear() + { + $progress = new ProgressHelper(); + $progress->start($output = $this->getOutputStream(), 50); + $progress->setCurrent(25); + $progress->clear(); + + rewind($output->getStream()); + $this->assertEquals( + $this->generateOutput(' 25/50 [==============>-------------] 50%') . $this->generateOutput(''), + stream_get_contents($output->getStream()) + ); + } + + public function testPercentNotHundredBeforeComplete() + { + $progress = new ProgressHelper(); + $progress->start($output = $this->getOutputStream(), 200); + $progress->display(); + $progress->advance(199); + $progress->advance(); + + rewind($output->getStream()); + $this->assertEquals($this->generateOutput(' 0/200 [>---------------------------] 0%').$this->generateOutput(' 199/200 [===========================>] 99%').$this->generateOutput(' 200/200 [============================] 100%'), stream_get_contents($output->getStream())); + } + + protected function getOutputStream() + { + return new StreamOutput(fopen('php://memory', 'r+', false)); + } + + protected $lastMessagesLength; + + protected function generateOutput($expected) + { + $expectedout = $expected; + + if ($this->lastMessagesLength !== null) { + $expectedout = str_pad($expected, $this->lastMessagesLength, "\x20", STR_PAD_RIGHT); + } + + $this->lastMessagesLength = strlen($expectedout); + + return "\x0D".$expectedout; + } +} diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Helper/TableHelperTest.php b/vendor/symfony/console/Symfony/Component/Console/Tests/Helper/TableHelperTest.php new file mode 100755 index 0000000..f3cda0d --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Tests/Helper/TableHelperTest.php @@ -0,0 +1,294 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Console\Tests\Helper; + +use Symfony\Component\Console\Helper\TableHelper; +use Symfony\Component\Console\Output\StreamOutput; + +class TableHelperTest extends \PHPUnit_Framework_TestCase +{ + protected $stream; + + protected function setUp() + { + $this->stream = fopen('php://memory', 'r+'); + } + + protected function tearDown() + { + fclose($this->stream); + $this->stream = null; + } + + /** + * @dataProvider testRenderProvider + */ + public function testRender($headers, $rows, $layout, $expected) + { + $table = new TableHelper(); + $table + ->setHeaders($headers) + ->setRows($rows) + ->setLayout($layout) + ; + $table->render($output = $this->getOutputStream()); + + $this->assertEquals($expected, $this->getOutputContent($output)); + } + + /** + * @dataProvider testRenderProvider + */ + public function testRenderAddRows($headers, $rows, $layout, $expected) + { + $table = new TableHelper(); + $table + ->setHeaders($headers) + ->addRows($rows) + ->setLayout($layout) + ; + $table->render($output = $this->getOutputStream()); + + $this->assertEquals($expected, $this->getOutputContent($output)); + } + + /** + * @dataProvider testRenderProvider + */ + public function testRenderAddRowsOneByOne($headers, $rows, $layout, $expected) + { + $table = new TableHelper(); + $table + ->setHeaders($headers) + ->setLayout($layout) + ; + foreach ($rows as $row) { + $table->addRow($row); + } + $table->render($output = $this->getOutputStream()); + + $this->assertEquals($expected, $this->getOutputContent($output)); + } + + public function testRenderProvider() + { + $books = array( + array('99921-58-10-7', 'Divine Comedy', 'Dante Alighieri'), + array('9971-5-0210-0', 'A Tale of Two Cities', 'Charles Dickens'), + array('960-425-059-0', 'The Lord of the Rings', 'J. R. R. Tolkien'), + array('80-902734-1-6', 'And Then There Were None', 'Agatha Christie'), + ); + + return array( + array( + array('ISBN', 'Title', 'Author'), + $books, + TableHelper::LAYOUT_DEFAULT, +<< array( + array('ISBN', 'Title', 'Author'), + array( + array('99921-58-10-7', 'Divine Comedy', 'Dante Alighieri'), + array('9971-5-0210-0', 'A Tale of Two Cities', 'Charles Dickens'), + ), + TableHelper::LAYOUT_DEFAULT, +<<
    array( + array('ISBN', 'Title', 'Author'), + array( + array('99921-58-10-700', 'Divine Com', 'Dante Alighieri'), + array('9971-5-0210-0', 'A Tale of Two Cities', 'Charles Dickens'), + ), + TableHelper::LAYOUT_DEFAULT, +<<
    99921-58-10-700 | Divine Com | Dante Alighieri | +| 9971-5-0210-0 | A Tale of Two Cities | Charles Dickens | ++----------------------------------+----------------------+-----------------+ + +TABLE + ), + ); + } + + public function testRenderMultiByte() + { + if (!function_exists('mb_strlen')) { + $this->markTestSkipped('The "mbstring" extension is not available'); + } + + $table = new TableHelper(); + $table + ->setHeaders(array('â– â– ')) + ->setRows(array(array(1234))) + ->setLayout(TableHelper::LAYOUT_DEFAULT) + ; + $table->render($output = $this->getOutputStream()); + + $expected = +<<
    assertEquals($expected, $this->getOutputContent($output)); + } + + protected function getOutputStream() + { + return new StreamOutput($this->stream, StreamOutput::VERBOSITY_NORMAL, false); + } + + protected function getOutputContent(StreamOutput $output) + { + rewind($output->getStream()); + + return str_replace(PHP_EOL, "\n", stream_get_contents($output->getStream())); + } +} diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Input/ArgvInputTest.php b/vendor/symfony/console/Symfony/Component/Console/Tests/Input/ArgvInputTest.php new file mode 100755 index 0000000..507990d --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Tests/Input/ArgvInputTest.php @@ -0,0 +1,316 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Console\Tests\Input; + +use Symfony\Component\Console\Input\ArgvInput; +use Symfony\Component\Console\Input\InputDefinition; +use Symfony\Component\Console\Input\InputArgument; +use Symfony\Component\Console\Input\InputOption; + +class ArgvInputTest extends \PHPUnit_Framework_TestCase +{ + public function testConstructor() + { + $_SERVER['argv'] = array('cli.php', 'foo'); + $input = new ArgvInput(); + $r = new \ReflectionObject($input); + $p = $r->getProperty('tokens'); + $p->setAccessible(true); + + $this->assertEquals(array('foo'), $p->getValue($input), '__construct() automatically get its input from the argv server variable'); + } + + public function testParseArguments() + { + $input = new ArgvInput(array('cli.php', 'foo')); + $input->bind(new InputDefinition(array(new InputArgument('name')))); + $this->assertEquals(array('name' => 'foo'), $input->getArguments(), '->parse() parses required arguments'); + + $input->bind(new InputDefinition(array(new InputArgument('name')))); + $this->assertEquals(array('name' => 'foo'), $input->getArguments(), '->parse() is stateless'); + } + + /** + * @dataProvider provideOptions + */ + public function testParseOptions($input, $options, $expectedOptions, $message) + { + $input = new ArgvInput($input); + $input->bind(new InputDefinition($options)); + + $this->assertEquals($expectedOptions, $input->getOptions(), $message); + } + + public function provideOptions() + { + return array( + array( + array('cli.php', '--foo'), + array(new InputOption('foo')), + array('foo' => true), + '->parse() parses long options without a value' + ), + array( + array('cli.php', '--foo=bar'), + array(new InputOption('foo', 'f', InputOption::VALUE_REQUIRED)), + array('foo' => 'bar'), + '->parse() parses long options with a required value (with a = separator)' + ), + array( + array('cli.php', '--foo', 'bar'), + array(new InputOption('foo', 'f', InputOption::VALUE_REQUIRED)), + array('foo' => 'bar'), + '->parse() parses long options with a required value (with a space separator)' + ), + array( + array('cli.php', '-f'), + array(new InputOption('foo', 'f')), + array('foo' => true), + '->parse() parses short options without a value' + ), + array( + array('cli.php', '-fbar'), + array(new InputOption('foo', 'f', InputOption::VALUE_REQUIRED)), + array('foo' => 'bar'), + '->parse() parses short options with a required value (with no separator)' + ), + array( + array('cli.php', '-f', 'bar'), + array(new InputOption('foo', 'f', InputOption::VALUE_REQUIRED)), + array('foo' => 'bar'), + '->parse() parses short options with a required value (with a space separator)' + ), + array( + array('cli.php', '-f', ''), + array(new InputOption('foo', 'f', InputOption::VALUE_OPTIONAL)), + array('foo' => ''), + '->parse() parses short options with an optional empty value' + ), + array( + array('cli.php', '-f', '', 'foo'), + array(new InputArgument('name'), new InputOption('foo', 'f', InputOption::VALUE_OPTIONAL)), + array('foo' => ''), + '->parse() parses short options with an optional empty value followed by an argument' + ), + array( + array('cli.php', '-f', '', '-b'), + array(new InputOption('foo', 'f', InputOption::VALUE_OPTIONAL), new InputOption('bar', 'b')), + array('foo' => '', 'bar' => true), + '->parse() parses short options with an optional empty value followed by an option' + ), + array( + array('cli.php', '-f', '-b', 'foo'), + array(new InputArgument('name'), new InputOption('foo', 'f', InputOption::VALUE_OPTIONAL), new InputOption('bar', 'b')), + array('foo' => null, 'bar' => true), + '->parse() parses short options with an optional value which is not present' + ), + array( + array('cli.php', '-fb'), + array(new InputOption('foo', 'f'), new InputOption('bar', 'b')), + array('foo' => true, 'bar' => true), + '->parse() parses short options when they are aggregated as a single one' + ), + array( + array('cli.php', '-fb', 'bar'), + array(new InputOption('foo', 'f'), new InputOption('bar', 'b', InputOption::VALUE_REQUIRED)), + array('foo' => true, 'bar' => 'bar'), + '->parse() parses short options when they are aggregated as a single one and the last one has a required value' + ), + array( + array('cli.php', '-fb', 'bar'), + array(new InputOption('foo', 'f'), new InputOption('bar', 'b', InputOption::VALUE_OPTIONAL)), + array('foo' => true, 'bar' => 'bar'), + '->parse() parses short options when they are aggregated as a single one and the last one has an optional value' + ), + array( + array('cli.php', '-fbbar'), + array(new InputOption('foo', 'f'), new InputOption('bar', 'b', InputOption::VALUE_OPTIONAL)), + array('foo' => true, 'bar' => 'bar'), + '->parse() parses short options when they are aggregated as a single one and the last one has an optional value with no separator' + ), + array( + array('cli.php', '-fbbar'), + array(new InputOption('foo', 'f', InputOption::VALUE_OPTIONAL), new InputOption('bar', 'b', InputOption::VALUE_OPTIONAL)), + array('foo' => 'bbar', 'bar' => null), + '->parse() parses short options when they are aggregated as a single one and one of them takes a value' + ) + ); + } + + /** + * @dataProvider provideInvalidInput + */ + public function testInvalidInput($argv, $definition, $expectedExceptionMessage) + { + $this->setExpectedException('RuntimeException', $expectedExceptionMessage); + + $input = new ArgvInput($argv); + $input->bind($definition); + } + + public function provideInvalidInput() + { + return array( + array( + array('cli.php', '--foo'), + new InputDefinition(array(new InputOption('foo', 'f', InputOption::VALUE_REQUIRED))), + 'The "--foo" option requires a value.' + ), + array( + array('cli.php', '-f'), + new InputDefinition(array(new InputOption('foo', 'f', InputOption::VALUE_REQUIRED))), + 'The "--foo" option requires a value.' + ), + array( + array('cli.php', '-ffoo'), + new InputDefinition(array(new InputOption('foo', 'f', InputOption::VALUE_NONE))), + 'The "-o" option does not exist.' + ), + array( + array('cli.php', '--foo=bar'), + new InputDefinition(array(new InputOption('foo', 'f', InputOption::VALUE_NONE))), + 'The "--foo" option does not accept a value.' + ), + array( + array('cli.php', 'foo', 'bar'), + new InputDefinition(), + 'Too many arguments.' + ), + array( + array('cli.php', '--foo'), + new InputDefinition(), + 'The "--foo" option does not exist.' + ), + array( + array('cli.php', '-f'), + new InputDefinition(), + 'The "-f" option does not exist.' + ), + array( + array('cli.php', '-1'), + new InputDefinition(array(new InputArgument('number'))), + 'The "-1" option does not exist.' + ) + ); + } + + public function testParseArrayArgument() + { + $input = new ArgvInput(array('cli.php', 'foo', 'bar', 'baz', 'bat')); + $input->bind(new InputDefinition(array(new InputArgument('name', InputArgument::IS_ARRAY)))); + + $this->assertEquals(array('name' => array('foo', 'bar', 'baz', 'bat')), $input->getArguments(), '->parse() parses array arguments'); + } + + public function testParseArrayOption() + { + $input = new ArgvInput(array('cli.php', '--name=foo', '--name=bar', '--name=baz')); + $input->bind(new InputDefinition(array(new InputOption('name', null, InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY)))); + + $this->assertEquals(array('name' => array('foo', 'bar', 'baz')), $input->getOptions(), '->parse() parses array options ("--option=value" syntax)'); + + $input = new ArgvInput(array('cli.php', '--name', 'foo', '--name', 'bar', '--name', 'baz')); + $input->bind(new InputDefinition(array(new InputOption('name', null, InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY)))); + $this->assertEquals(array('name' => array('foo', 'bar', 'baz')), $input->getOptions(), '->parse() parses array options ("--option value" syntax)'); + + $input = new ArgvInput(array('cli.php', '--name=foo', '--name=bar', '--name=')); + $input->bind(new InputDefinition(array(new InputOption('name', null, InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY)))); + $this->assertSame(array('name' => array('foo', 'bar', null)), $input->getOptions(), '->parse() parses empty array options as null ("--option=value" syntax)'); + + $input = new ArgvInput(array('cli.php', '--name', 'foo', '--name', 'bar', '--name', '--anotherOption')); + $input->bind(new InputDefinition(array( + new InputOption('name', null, InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY), + new InputOption('anotherOption', null, InputOption::VALUE_NONE), + ))); + $this->assertSame(array('name' => array('foo', 'bar', null), 'anotherOption' => true), $input->getOptions(), '->parse() parses empty array options as null ("--option value" syntax)'); + } + + public function testParseNegativeNumberAfterDoubleDash() + { + $input = new ArgvInput(array('cli.php', '--', '-1')); + $input->bind(new InputDefinition(array(new InputArgument('number')))); + $this->assertEquals(array('number' => '-1'), $input->getArguments(), '->parse() parses arguments with leading dashes as arguments after having encountered a double-dash sequence'); + + $input = new ArgvInput(array('cli.php', '-f', 'bar', '--', '-1')); + $input->bind(new InputDefinition(array(new InputArgument('number'), new InputOption('foo', 'f', InputOption::VALUE_OPTIONAL)))); + $this->assertEquals(array('foo' => 'bar'), $input->getOptions(), '->parse() parses arguments with leading dashes as options before having encountered a double-dash sequence'); + $this->assertEquals(array('number' => '-1'), $input->getArguments(), '->parse() parses arguments with leading dashes as arguments after having encountered a double-dash sequence'); + } + + public function testParseEmptyStringArgument() + { + $input = new ArgvInput(array('cli.php', '-f', 'bar', '')); + $input->bind(new InputDefinition(array(new InputArgument('empty'), new InputOption('foo', 'f', InputOption::VALUE_OPTIONAL)))); + + $this->assertEquals(array('empty' => ''), $input->getArguments(), '->parse() parses empty string arguments'); + } + + public function testGetFirstArgument() + { + $input = new ArgvInput(array('cli.php', '-fbbar')); + $this->assertEquals('', $input->getFirstArgument(), '->getFirstArgument() returns the first argument from the raw input'); + + $input = new ArgvInput(array('cli.php', '-fbbar', 'foo')); + $this->assertEquals('foo', $input->getFirstArgument(), '->getFirstArgument() returns the first argument from the raw input'); + } + + public function testHasParameterOption() + { + $input = new ArgvInput(array('cli.php', '-f', 'foo')); + $this->assertTrue($input->hasParameterOption('-f'), '->hasParameterOption() returns true if the given short option is in the raw input'); + + $input = new ArgvInput(array('cli.php', '--foo', 'foo')); + $this->assertTrue($input->hasParameterOption('--foo'), '->hasParameterOption() returns true if the given short option is in the raw input'); + + $input = new ArgvInput(array('cli.php', 'foo')); + $this->assertFalse($input->hasParameterOption('--foo'), '->hasParameterOption() returns false if the given short option is not in the raw input'); + + $input = new ArgvInput(array('cli.php', '--foo=bar')); + $this->assertTrue($input->hasParameterOption('--foo'), '->hasParameterOption() returns true if the given option with provided value is in the raw input'); + } + + public function testToString() + { + $input = new ArgvInput(array('cli.php', '-f', 'foo')); + $this->assertEquals('-f foo', (string) $input); + + $input = new ArgvInput(array('cli.php', '-f', '--bar=foo', 'a b c d', "A\nB'C")); + $this->assertEquals('-f --bar=foo '.escapeshellarg('a b c d').' '.escapeshellarg("A\nB'C"), (string) $input); + } + + /** + * @dataProvider provideGetParameterOptionValues + */ + public function testGetParameterOptionEqualSign($argv, $key, $expected) + { + $input = new ArgvInput($argv); + $this->assertEquals($expected, $input->getParameterOption($key), '->getParameterOption() returns the expected value'); + } + + public function provideGetParameterOptionValues() + { + return array( + array(array('app/console', 'foo:bar', '-e', 'dev'), '-e', 'dev'), + array(array('app/console', 'foo:bar', '--env=dev'), '--env', 'dev'), + array(array('app/console', 'foo:bar', '-e', 'dev'), array('-e', '--env'), 'dev'), + array(array('app/console', 'foo:bar', '--env=dev'), array('-e', '--env'), 'dev'), + array(array('app/console', 'foo:bar', '--env=dev', '--en=1'), array('--en'), '1'), + ); + } + + public function testParseSingleDashAsArgument() + { + $input = new ArgvInput(array('cli.php', '-')); + $input->bind(new InputDefinition(array(new InputArgument('file')))); + $this->assertEquals(array('file' => '-'), $input->getArguments(), '->parse() parses single dash as an argument'); + } +} diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Input/ArrayInputTest.php b/vendor/symfony/console/Symfony/Component/Console/Tests/Input/ArrayInputTest.php new file mode 100755 index 0000000..73f2e33 --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Tests/Input/ArrayInputTest.php @@ -0,0 +1,129 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Console\Tests\Input; + +use Symfony\Component\Console\Input\ArrayInput; +use Symfony\Component\Console\Input\InputDefinition; +use Symfony\Component\Console\Input\InputArgument; +use Symfony\Component\Console\Input\InputOption; + +class ArrayInputTest extends \PHPUnit_Framework_TestCase +{ + public function testGetFirstArgument() + { + $input = new ArrayInput(array()); + $this->assertNull($input->getFirstArgument(), '->getFirstArgument() returns null if no argument were passed'); + $input = new ArrayInput(array('name' => 'Fabien')); + $this->assertEquals('Fabien', $input->getFirstArgument(), '->getFirstArgument() returns the first passed argument'); + $input = new ArrayInput(array('--foo' => 'bar', 'name' => 'Fabien')); + $this->assertEquals('Fabien', $input->getFirstArgument(), '->getFirstArgument() returns the first passed argument'); + } + + public function testHasParameterOption() + { + $input = new ArrayInput(array('name' => 'Fabien', '--foo' => 'bar')); + $this->assertTrue($input->hasParameterOption('--foo'), '->hasParameterOption() returns true if an option is present in the passed parameters'); + $this->assertFalse($input->hasParameterOption('--bar'), '->hasParameterOption() returns false if an option is not present in the passed parameters'); + + $input = new ArrayInput(array('--foo')); + $this->assertTrue($input->hasParameterOption('--foo'), '->hasParameterOption() returns true if an option is present in the passed parameters'); + } + + public function testParseArguments() + { + $input = new ArrayInput(array('name' => 'foo'), new InputDefinition(array(new InputArgument('name')))); + + $this->assertEquals(array('name' => 'foo'), $input->getArguments(), '->parse() parses required arguments'); + } + + /** + * @dataProvider provideOptions + */ + public function testParseOptions($input, $options, $expectedOptions, $message) + { + $input = new ArrayInput($input, new InputDefinition($options)); + + $this->assertEquals($expectedOptions, $input->getOptions(), $message); + } + + public function provideOptions() + { + return array( + array( + array('--foo' => 'bar'), + array(new InputOption('foo')), + array('foo' => 'bar'), + '->parse() parses long options' + ), + array( + array('--foo' => 'bar'), + array(new InputOption('foo', 'f', InputOption::VALUE_OPTIONAL, '', 'default')), + array('foo' => 'bar'), + '->parse() parses long options with a default value' + ), + array( + array('--foo' => null), + array(new InputOption('foo', 'f', InputOption::VALUE_OPTIONAL, '', 'default')), + array('foo' => 'default'), + '->parse() parses long options with a default value' + ), + array( + array('-f' => 'bar'), + array(new InputOption('foo', 'f')), + array('foo' => 'bar'), + '->parse() parses short options' + ) + ); + } + + /** + * @dataProvider provideInvalidInput + */ + public function testParseInvalidInput($parameters, $definition, $expectedExceptionMessage) + { + $this->setExpectedException('InvalidArgumentException', $expectedExceptionMessage); + + new ArrayInput($parameters, $definition); + } + + public function provideInvalidInput() + { + return array( + array( + array('foo' => 'foo'), + new InputDefinition(array(new InputArgument('name'))), + 'The "foo" argument does not exist.' + ), + array( + array('--foo' => null), + new InputDefinition(array(new InputOption('foo', 'f', InputOption::VALUE_REQUIRED))), + 'The "--foo" option requires a value.' + ), + array( + array('--foo' => 'foo'), + new InputDefinition(), + 'The "--foo" option does not exist.' + ), + array( + array('-o' => 'foo'), + new InputDefinition(), + 'The "-o" option does not exist.' + ) + ); + } + + public function testToString() + { + $input = new ArrayInput(array('-f' => null, '-b' => 'bar', '--foo' => 'b a z', '--lala' => null, 'test' => 'Foo', 'test2' => "A\nB'C")); + $this->assertEquals('-f -b=bar --foo='.escapeshellarg('b a z').' --lala Foo '.escapeshellarg("A\nB'C"), (string) $input); + } +} diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Input/InputArgumentTest.php b/vendor/symfony/console/Symfony/Component/Console/Tests/Input/InputArgumentTest.php new file mode 100755 index 0000000..3bfc796 --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Tests/Input/InputArgumentTest.php @@ -0,0 +1,111 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Console\Tests\Input; + +use Symfony\Component\Console\Input\InputArgument; + +class InputArgumentTest extends \PHPUnit_Framework_TestCase +{ + public function testConstructor() + { + $argument = new InputArgument('foo'); + $this->assertEquals('foo', $argument->getName(), '__construct() takes a name as its first argument'); + } + + public function testModes() + { + $argument = new InputArgument('foo'); + $this->assertFalse($argument->isRequired(), '__construct() gives a "InputArgument::OPTIONAL" mode by default'); + + $argument = new InputArgument('foo', null); + $this->assertFalse($argument->isRequired(), '__construct() can take "InputArgument::OPTIONAL" as its mode'); + + $argument = new InputArgument('foo', InputArgument::OPTIONAL); + $this->assertFalse($argument->isRequired(), '__construct() can take "InputArgument::OPTIONAL" as its mode'); + + $argument = new InputArgument('foo', InputArgument::REQUIRED); + $this->assertTrue($argument->isRequired(), '__construct() can take "InputArgument::REQUIRED" as its mode'); + } + + /** + * @dataProvider provideInvalidModes + */ + public function testInvalidModes($mode) + { + $this->setExpectedException('InvalidArgumentException', sprintf('Argument mode "%s" is not valid.', $mode)); + + new InputArgument('foo', $mode); + } + + public function provideInvalidModes() + { + return array( + array('ANOTHER_ONE'), + array(-1) + ); + } + + public function testIsArray() + { + $argument = new InputArgument('foo', InputArgument::IS_ARRAY); + $this->assertTrue($argument->isArray(), '->isArray() returns true if the argument can be an array'); + $argument = new InputArgument('foo', InputArgument::OPTIONAL | InputArgument::IS_ARRAY); + $this->assertTrue($argument->isArray(), '->isArray() returns true if the argument can be an array'); + $argument = new InputArgument('foo', InputArgument::OPTIONAL); + $this->assertFalse($argument->isArray(), '->isArray() returns false if the argument can not be an array'); + } + + public function testGetDescription() + { + $argument = new InputArgument('foo', null, 'Some description'); + $this->assertEquals('Some description', $argument->getDescription(), '->getDescription() return the message description'); + } + + public function testGetDefault() + { + $argument = new InputArgument('foo', InputArgument::OPTIONAL, '', 'default'); + $this->assertEquals('default', $argument->getDefault(), '->getDefault() return the default value'); + } + + public function testSetDefault() + { + $argument = new InputArgument('foo', InputArgument::OPTIONAL, '', 'default'); + $argument->setDefault(null); + $this->assertNull($argument->getDefault(), '->setDefault() can reset the default value by passing null'); + $argument->setDefault('another'); + $this->assertEquals('another', $argument->getDefault(), '->setDefault() changes the default value'); + + $argument = new InputArgument('foo', InputArgument::OPTIONAL | InputArgument::IS_ARRAY); + $argument->setDefault(array(1, 2)); + $this->assertEquals(array(1, 2), $argument->getDefault(), '->setDefault() changes the default value'); + } + + /** + * @expectedException \LogicException + * @expectedExceptionMessage Cannot set a default value except for InputArgument::OPTIONAL mode. + */ + public function testSetDefaultWithRequiredArgument() + { + $argument = new InputArgument('foo', InputArgument::REQUIRED); + $argument->setDefault('default'); + } + + /** + * @expectedException \LogicException + * @expectedExceptionMessage A default value for an array argument must be an array. + */ + public function testSetDefaultWithArrayArgument() + { + $argument = new InputArgument('foo', InputArgument::IS_ARRAY); + $argument->setDefault('default'); + } +} diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Input/InputDefinitionTest.php b/vendor/symfony/console/Symfony/Component/Console/Tests/Input/InputDefinitionTest.php new file mode 100755 index 0000000..5cf5011 --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Tests/Input/InputDefinitionTest.php @@ -0,0 +1,420 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Console\Tests\Input; + +use Symfony\Component\Console\Input\InputDefinition; +use Symfony\Component\Console\Input\InputArgument; +use Symfony\Component\Console\Input\InputOption; + +class InputDefinitionTest extends \PHPUnit_Framework_TestCase +{ + protected static $fixtures; + + protected $foo, $bar, $foo1, $foo2; + + public static function setUpBeforeClass() + { + self::$fixtures = __DIR__.'/../Fixtures/'; + } + + public function testConstructorArguments() + { + $this->initializeArguments(); + + $definition = new InputDefinition(); + $this->assertEquals(array(), $definition->getArguments(), '__construct() creates a new InputDefinition object'); + + $definition = new InputDefinition(array($this->foo, $this->bar)); + $this->assertEquals(array('foo' => $this->foo, 'bar' => $this->bar), $definition->getArguments(), '__construct() takes an array of InputArgument objects as its first argument'); + } + + public function testConstructorOptions() + { + $this->initializeOptions(); + + $definition = new InputDefinition(); + $this->assertEquals(array(), $definition->getOptions(), '__construct() creates a new InputDefinition object'); + + $definition = new InputDefinition(array($this->foo, $this->bar)); + $this->assertEquals(array('foo' => $this->foo, 'bar' => $this->bar), $definition->getOptions(), '__construct() takes an array of InputOption objects as its first argument'); + } + + public function testSetArguments() + { + $this->initializeArguments(); + + $definition = new InputDefinition(); + $definition->setArguments(array($this->foo)); + $this->assertEquals(array('foo' => $this->foo), $definition->getArguments(), '->setArguments() sets the array of InputArgument objects'); + $definition->setArguments(array($this->bar)); + + $this->assertEquals(array('bar' => $this->bar), $definition->getArguments(), '->setArguments() clears all InputArgument objects'); + } + + public function testAddArguments() + { + $this->initializeArguments(); + + $definition = new InputDefinition(); + $definition->addArguments(array($this->foo)); + $this->assertEquals(array('foo' => $this->foo), $definition->getArguments(), '->addArguments() adds an array of InputArgument objects'); + $definition->addArguments(array($this->bar)); + $this->assertEquals(array('foo' => $this->foo, 'bar' => $this->bar), $definition->getArguments(), '->addArguments() does not clear existing InputArgument objects'); + } + + public function testAddArgument() + { + $this->initializeArguments(); + + $definition = new InputDefinition(); + $definition->addArgument($this->foo); + $this->assertEquals(array('foo' => $this->foo), $definition->getArguments(), '->addArgument() adds a InputArgument object'); + $definition->addArgument($this->bar); + $this->assertEquals(array('foo' => $this->foo, 'bar' => $this->bar), $definition->getArguments(), '->addArgument() adds a InputArgument object'); + } + + /** + * @expectedException \LogicException + * @expectedExceptionMessage An argument with name "foo" already exists. + */ + public function testArgumentsMustHaveDifferentNames() + { + $this->initializeArguments(); + + $definition = new InputDefinition(); + $definition->addArgument($this->foo); + $definition->addArgument($this->foo1); + } + + /** + * @expectedException \LogicException + * @expectedExceptionMessage Cannot add an argument after an array argument. + */ + public function testArrayArgumentHasToBeLast() + { + $this->initializeArguments(); + + $definition = new InputDefinition(); + $definition->addArgument(new InputArgument('fooarray', InputArgument::IS_ARRAY)); + $definition->addArgument(new InputArgument('anotherbar')); + } + + /** + * @expectedException \LogicException + * @expectedExceptionMessage Cannot add a required argument after an optional one. + */ + public function testRequiredArgumentCannotFollowAnOptionalOne() + { + $this->initializeArguments(); + + $definition = new InputDefinition(); + $definition->addArgument($this->foo); + $definition->addArgument($this->foo2); + } + + public function testGetArgument() + { + $this->initializeArguments(); + + $definition = new InputDefinition(); + $definition->addArguments(array($this->foo)); + $this->assertEquals($this->foo, $definition->getArgument('foo'), '->getArgument() returns a InputArgument by its name'); + } + + /** + * @expectedException \InvalidArgumentException + * @expectedExceptionMessage The "bar" argument does not exist. + */ + public function testGetInvalidArgument() + { + $this->initializeArguments(); + + $definition = new InputDefinition(); + $definition->addArguments(array($this->foo)); + $definition->getArgument('bar'); + } + + public function testHasArgument() + { + $this->initializeArguments(); + + $definition = new InputDefinition(); + $definition->addArguments(array($this->foo)); + + $this->assertTrue($definition->hasArgument('foo'), '->hasArgument() returns true if a InputArgument exists for the given name'); + $this->assertFalse($definition->hasArgument('bar'), '->hasArgument() returns false if a InputArgument exists for the given name'); + } + + public function testGetArgumentRequiredCount() + { + $this->initializeArguments(); + + $definition = new InputDefinition(); + $definition->addArgument($this->foo2); + $this->assertEquals(1, $definition->getArgumentRequiredCount(), '->getArgumentRequiredCount() returns the number of required arguments'); + $definition->addArgument($this->foo); + $this->assertEquals(1, $definition->getArgumentRequiredCount(), '->getArgumentRequiredCount() returns the number of required arguments'); + } + + public function testGetArgumentCount() + { + $this->initializeArguments(); + + $definition = new InputDefinition(); + $definition->addArgument($this->foo2); + $this->assertEquals(1, $definition->getArgumentCount(), '->getArgumentCount() returns the number of arguments'); + $definition->addArgument($this->foo); + $this->assertEquals(2, $definition->getArgumentCount(), '->getArgumentCount() returns the number of arguments'); + } + + public function testGetArgumentDefaults() + { + $definition = new InputDefinition(array( + new InputArgument('foo1', InputArgument::OPTIONAL), + new InputArgument('foo2', InputArgument::OPTIONAL, '', 'default'), + new InputArgument('foo3', InputArgument::OPTIONAL | InputArgument::IS_ARRAY), + // new InputArgument('foo4', InputArgument::OPTIONAL | InputArgument::IS_ARRAY, '', array(1, 2)), + )); + $this->assertEquals(array('foo1' => null, 'foo2' => 'default', 'foo3' => array()), $definition->getArgumentDefaults(), '->getArgumentDefaults() return the default values for each argument'); + + $definition = new InputDefinition(array( + new InputArgument('foo4', InputArgument::OPTIONAL | InputArgument::IS_ARRAY, '', array(1, 2)), + )); + $this->assertEquals(array('foo4' => array(1, 2)), $definition->getArgumentDefaults(), '->getArgumentDefaults() return the default values for each argument'); + } + + public function testSetOptions() + { + $this->initializeOptions(); + + $definition = new InputDefinition(array($this->foo)); + $this->assertEquals(array('foo' => $this->foo), $definition->getOptions(), '->setOptions() sets the array of InputOption objects'); + $definition->setOptions(array($this->bar)); + $this->assertEquals(array('bar' => $this->bar), $definition->getOptions(), '->setOptions() clears all InputOption objects'); + } + + /** + * @expectedException \InvalidArgumentException + * @expectedExceptionMessage The "-f" option does not exist. + */ + public function testSetOptionsClearsOptions() + { + $this->initializeOptions(); + + $definition = new InputDefinition(array($this->foo)); + $definition->setOptions(array($this->bar)); + $definition->getOptionForShortcut('f'); + } + + public function testAddOptions() + { + $this->initializeOptions(); + + $definition = new InputDefinition(array($this->foo)); + $this->assertEquals(array('foo' => $this->foo), $definition->getOptions(), '->addOptions() adds an array of InputOption objects'); + $definition->addOptions(array($this->bar)); + $this->assertEquals(array('foo' => $this->foo, 'bar' => $this->bar), $definition->getOptions(), '->addOptions() does not clear existing InputOption objects'); + } + + public function testAddOption() + { + $this->initializeOptions(); + + $definition = new InputDefinition(); + $definition->addOption($this->foo); + $this->assertEquals(array('foo' => $this->foo), $definition->getOptions(), '->addOption() adds a InputOption object'); + $definition->addOption($this->bar); + $this->assertEquals(array('foo' => $this->foo, 'bar' => $this->bar), $definition->getOptions(), '->addOption() adds a InputOption object'); + } + + /** + * @expectedException \LogicException + * @expectedExceptionMessage An option named "foo" already exists. + */ + public function testAddDuplicateOption() + { + $this->initializeOptions(); + + $definition = new InputDefinition(); + $definition->addOption($this->foo); + $definition->addOption($this->foo2); + } + + /** + * @expectedException \LogicException + * @expectedExceptionMessage An option with shortcut "f" already exists. + */ + public function testAddDuplicateShortcutOption() + { + $this->initializeOptions(); + + $definition = new InputDefinition(); + $definition->addOption($this->foo); + $definition->addOption($this->foo1); + } + + public function testGetOption() + { + $this->initializeOptions(); + + $definition = new InputDefinition(array($this->foo)); + $this->assertEquals($this->foo, $definition->getOption('foo'), '->getOption() returns a InputOption by its name'); + } + + /** + * @expectedException \InvalidArgumentException + * @expectedExceptionMessage The "--bar" option does not exist. + */ + public function testGetInvalidOption() + { + $this->initializeOptions(); + + $definition = new InputDefinition(array($this->foo)); + $definition->getOption('bar'); + } + + public function testHasOption() + { + $this->initializeOptions(); + + $definition = new InputDefinition(array($this->foo)); + $this->assertTrue($definition->hasOption('foo'), '->hasOption() returns true if a InputOption exists for the given name'); + $this->assertFalse($definition->hasOption('bar'), '->hasOption() returns false if a InputOption exists for the given name'); + } + + public function testHasShortcut() + { + $this->initializeOptions(); + + $definition = new InputDefinition(array($this->foo)); + $this->assertTrue($definition->hasShortcut('f'), '->hasShortcut() returns true if a InputOption exists for the given shortcut'); + $this->assertFalse($definition->hasShortcut('b'), '->hasShortcut() returns false if a InputOption exists for the given shortcut'); + } + + public function testGetOptionForShortcut() + { + $this->initializeOptions(); + + $definition = new InputDefinition(array($this->foo)); + $this->assertEquals($this->foo, $definition->getOptionForShortcut('f'), '->getOptionForShortcut() returns a InputOption by its shortcut'); + } + + public function testGetOptionForMultiShortcut() + { + $this->initializeOptions(); + + $definition = new InputDefinition(array($this->multi)); + $this->assertEquals($this->multi, $definition->getOptionForShortcut('m'), '->getOptionForShortcut() returns a InputOption by its shortcut'); + $this->assertEquals($this->multi, $definition->getOptionForShortcut('mmm'), '->getOptionForShortcut() returns a InputOption by its shortcut'); + } + + /** + * @expectedException \InvalidArgumentException + * @expectedExceptionMessage The "-l" option does not exist. + */ + public function testGetOptionForInvalidShortcut() + { + $this->initializeOptions(); + + $definition = new InputDefinition(array($this->foo)); + $definition->getOptionForShortcut('l'); + } + + public function testGetOptionDefaults() + { + $definition = new InputDefinition(array( + new InputOption('foo1', null, InputOption::VALUE_NONE), + new InputOption('foo2', null, InputOption::VALUE_REQUIRED), + new InputOption('foo3', null, InputOption::VALUE_REQUIRED, '', 'default'), + new InputOption('foo4', null, InputOption::VALUE_OPTIONAL), + new InputOption('foo5', null, InputOption::VALUE_OPTIONAL, '', 'default'), + new InputOption('foo6', null, InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY), + new InputOption('foo7', null, InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, '', array(1, 2)), + )); + $defaults = array( + 'foo1' => null, + 'foo2' => null, + 'foo3' => 'default', + 'foo4' => null, + 'foo5' => 'default', + 'foo6' => array(), + 'foo7' => array(1, 2), + ); + $this->assertEquals($defaults, $definition->getOptionDefaults(), '->getOptionDefaults() returns the default values for all options'); + } + + public function testGetSynopsis() + { + $definition = new InputDefinition(array(new InputOption('foo'))); + $this->assertEquals('[--foo]', $definition->getSynopsis(), '->getSynopsis() returns a synopsis of arguments and options'); + $definition = new InputDefinition(array(new InputOption('foo', 'f'))); + $this->assertEquals('[-f|--foo]', $definition->getSynopsis(), '->getSynopsis() returns a synopsis of arguments and options'); + $definition = new InputDefinition(array(new InputOption('foo', 'f', InputOption::VALUE_REQUIRED))); + $this->assertEquals('[-f|--foo="..."]', $definition->getSynopsis(), '->getSynopsis() returns a synopsis of arguments and options'); + $definition = new InputDefinition(array(new InputOption('foo', 'f', InputOption::VALUE_OPTIONAL))); + $this->assertEquals('[-f|--foo[="..."]]', $definition->getSynopsis(), '->getSynopsis() returns a synopsis of arguments and options'); + + $definition = new InputDefinition(array(new InputArgument('foo'))); + $this->assertEquals('[foo]', $definition->getSynopsis(), '->getSynopsis() returns a synopsis of arguments and options'); + $definition = new InputDefinition(array(new InputArgument('foo', InputArgument::REQUIRED))); + $this->assertEquals('foo', $definition->getSynopsis(), '->getSynopsis() returns a synopsis of arguments and options'); + $definition = new InputDefinition(array(new InputArgument('foo', InputArgument::IS_ARRAY))); + $this->assertEquals('[foo1] ... [fooN]', $definition->getSynopsis(), '->getSynopsis() returns a synopsis of arguments and options'); + $definition = new InputDefinition(array(new InputArgument('foo', InputArgument::REQUIRED | InputArgument::IS_ARRAY))); + $this->assertEquals('foo1 ... [fooN]', $definition->getSynopsis(), '->getSynopsis() returns a synopsis of arguments and options'); + } + + public function testAsText() + { + $definition = new InputDefinition(array( + new InputArgument('foo', InputArgument::OPTIONAL, 'The foo argument'), + new InputArgument('baz', InputArgument::OPTIONAL, 'The baz argument', true), + new InputArgument('bar', InputArgument::OPTIONAL | InputArgument::IS_ARRAY, 'The bar argument', array('http://foo.com/')), + new InputOption('foo', 'f', InputOption::VALUE_REQUIRED, 'The foo option'), + new InputOption('baz', null, InputOption::VALUE_OPTIONAL, 'The baz option', false), + new InputOption('bar', 'b', InputOption::VALUE_OPTIONAL, 'The bar option', 'bar'), + new InputOption('qux', '', InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, 'The qux option', array('http://foo.com/', 'bar')), + new InputOption('qux2', '', InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, 'The qux2 option', array('foo' => 'bar')), + )); + $this->assertStringEqualsFile(self::$fixtures.'/definition_astext.txt', $definition->asText(), '->asText() returns a textual representation of the InputDefinition'); + } + + public function testAsXml() + { + $definition = new InputDefinition(array( + new InputArgument('foo', InputArgument::OPTIONAL, 'The foo argument'), + new InputArgument('baz', InputArgument::OPTIONAL, 'The baz argument', true), + new InputArgument('bar', InputArgument::OPTIONAL | InputArgument::IS_ARRAY, 'The bar argument', array('bar')), + new InputOption('foo', 'f', InputOption::VALUE_REQUIRED, 'The foo option'), + new InputOption('baz', null, InputOption::VALUE_OPTIONAL, 'The baz option', false), + new InputOption('bar', 'b', InputOption::VALUE_OPTIONAL, 'The bar option', 'bar'), + )); + $this->assertXmlStringEqualsXmlFile(self::$fixtures.'/definition_asxml.txt', $definition->asXml(), '->asText() returns a textual representation of the InputDefinition'); + } + + protected function initializeArguments() + { + $this->foo = new InputArgument('foo'); + $this->bar = new InputArgument('bar'); + $this->foo1 = new InputArgument('foo'); + $this->foo2 = new InputArgument('foo2', InputArgument::REQUIRED); + } + + protected function initializeOptions() + { + $this->foo = new InputOption('foo', 'f'); + $this->bar = new InputOption('bar', 'b'); + $this->foo1 = new InputOption('fooBis', 'f'); + $this->foo2 = new InputOption('foo', 'p'); + $this->multi = new InputOption('multi', 'm|mm|mmm'); + } +} diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Input/InputOptionTest.php b/vendor/symfony/console/Symfony/Component/Console/Tests/Input/InputOptionTest.php new file mode 100755 index 0000000..5817e8f --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Tests/Input/InputOptionTest.php @@ -0,0 +1,204 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Console\Tests\Input; + +use Symfony\Component\Console\Input\InputOption; + +class InputOptionTest extends \PHPUnit_Framework_TestCase +{ + public function testConstructor() + { + $option = new InputOption('foo'); + $this->assertEquals('foo', $option->getName(), '__construct() takes a name as its first argument'); + $option = new InputOption('--foo'); + $this->assertEquals('foo', $option->getName(), '__construct() removes the leading -- of the option name'); + } + + /** + * @expectedException \InvalidArgumentException + * @expectedExceptionMessage Impossible to have an option mode VALUE_IS_ARRAY if the option does not accept a value. + */ + public function testArrayModeWithoutValue() + { + new InputOption('foo', 'f', InputOption::VALUE_IS_ARRAY); + } + + public function testShortcut() + { + $option = new InputOption('foo', 'f'); + $this->assertEquals('f', $option->getShortcut(), '__construct() can take a shortcut as its second argument'); + $option = new InputOption('foo', '-f|-ff|fff'); + $this->assertEquals('f|ff|fff', $option->getShortcut(), '__construct() removes the leading - of the shortcuts'); + $option = new InputOption('foo', array('f', 'ff', '-fff')); + $this->assertEquals('f|ff|fff', $option->getShortcut(), '__construct() removes the leading - of the shortcuts'); + $option = new InputOption('foo'); + $this->assertNull($option->getShortcut(), '__construct() makes the shortcut null by default'); + } + + public function testModes() + { + $option = new InputOption('foo', 'f'); + $this->assertFalse($option->acceptValue(), '__construct() gives a "InputOption::VALUE_NONE" mode by default'); + $this->assertFalse($option->isValueRequired(), '__construct() gives a "InputOption::VALUE_NONE" mode by default'); + $this->assertFalse($option->isValueOptional(), '__construct() gives a "InputOption::VALUE_NONE" mode by default'); + + $option = new InputOption('foo', 'f', null); + $this->assertFalse($option->acceptValue(), '__construct() can take "InputOption::VALUE_NONE" as its mode'); + $this->assertFalse($option->isValueRequired(), '__construct() can take "InputOption::VALUE_NONE" as its mode'); + $this->assertFalse($option->isValueOptional(), '__construct() can take "InputOption::VALUE_NONE" as its mode'); + + $option = new InputOption('foo', 'f', InputOption::VALUE_NONE); + $this->assertFalse($option->acceptValue(), '__construct() can take "InputOption::VALUE_NONE" as its mode'); + $this->assertFalse($option->isValueRequired(), '__construct() can take "InputOption::VALUE_NONE" as its mode'); + $this->assertFalse($option->isValueOptional(), '__construct() can take "InputOption::VALUE_NONE" as its mode'); + + $option = new InputOption('foo', 'f', InputOption::VALUE_REQUIRED); + $this->assertTrue($option->acceptValue(), '__construct() can take "InputOption::VALUE_REQUIRED" as its mode'); + $this->assertTrue($option->isValueRequired(), '__construct() can take "InputOption::VALUE_REQUIRED" as its mode'); + $this->assertFalse($option->isValueOptional(), '__construct() can take "InputOption::VALUE_REQUIRED" as its mode'); + + $option = new InputOption('foo', 'f', InputOption::VALUE_OPTIONAL); + $this->assertTrue($option->acceptValue(), '__construct() can take "InputOption::VALUE_OPTIONAL" as its mode'); + $this->assertFalse($option->isValueRequired(), '__construct() can take "InputOption::VALUE_OPTIONAL" as its mode'); + $this->assertTrue($option->isValueOptional(), '__construct() can take "InputOption::VALUE_OPTIONAL" as its mode'); + } + + /** + * @dataProvider provideInvalidModes + */ + public function testInvalidModes($mode) + { + $this->setExpectedException('InvalidArgumentException', sprintf('Option mode "%s" is not valid.', $mode)); + + new InputOption('foo', 'f', $mode); + } + + public function provideInvalidModes() + { + return array( + array('ANOTHER_ONE'), + array(-1) + ); + } + + /** + * @expectedException \InvalidArgumentException + */ + public function testEmptyNameIsInvalid() + { + new InputOption(''); + } + + /** + * @expectedException \InvalidArgumentException + */ + public function testDoubleDashNameIsInvalid() + { + new InputOption('--'); + } + + /** + * @expectedException \InvalidArgumentException + */ + public function testSingleDashOptionIsInvalid() + { + new InputOption('foo', '-'); + } + + public function testIsArray() + { + $option = new InputOption('foo', null, InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY); + $this->assertTrue($option->isArray(), '->isArray() returns true if the option can be an array'); + $option = new InputOption('foo', null, InputOption::VALUE_NONE); + $this->assertFalse($option->isArray(), '->isArray() returns false if the option can not be an array'); + } + + public function testGetDescription() + { + $option = new InputOption('foo', 'f', null, 'Some description'); + $this->assertEquals('Some description', $option->getDescription(), '->getDescription() returns the description message'); + } + + public function testGetDefault() + { + $option = new InputOption('foo', null, InputOption::VALUE_OPTIONAL, '', 'default'); + $this->assertEquals('default', $option->getDefault(), '->getDefault() returns the default value'); + + $option = new InputOption('foo', null, InputOption::VALUE_REQUIRED, '', 'default'); + $this->assertEquals('default', $option->getDefault(), '->getDefault() returns the default value'); + + $option = new InputOption('foo', null, InputOption::VALUE_REQUIRED); + $this->assertNull($option->getDefault(), '->getDefault() returns null if no default value is configured'); + + $option = new InputOption('foo', null, InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY); + $this->assertEquals(array(), $option->getDefault(), '->getDefault() returns an empty array if option is an array'); + + $option = new InputOption('foo', null, InputOption::VALUE_NONE); + $this->assertFalse($option->getDefault(), '->getDefault() returns false if the option does not take a value'); + } + + public function testSetDefault() + { + $option = new InputOption('foo', null, InputOption::VALUE_REQUIRED, '', 'default'); + $option->setDefault(null); + $this->assertNull($option->getDefault(), '->setDefault() can reset the default value by passing null'); + $option->setDefault('another'); + $this->assertEquals('another', $option->getDefault(), '->setDefault() changes the default value'); + + $option = new InputOption('foo', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY); + $option->setDefault(array(1, 2)); + $this->assertEquals(array(1, 2), $option->getDefault(), '->setDefault() changes the default value'); + } + + /** + * @expectedException \LogicException + * @expectedExceptionMessage Cannot set a default value when using InputOption::VALUE_NONE mode. + */ + public function testDefaultValueWithValueNoneMode() + { + $option = new InputOption('foo', 'f', InputOption::VALUE_NONE); + $option->setDefault('default'); + } + + /** + * @expectedException \LogicException + * @expectedExceptionMessage A default value for an array option must be an array. + */ + public function testDefaultValueWithIsArrayMode() + { + $option = new InputOption('foo', 'f', InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY); + $option->setDefault('default'); + } + + public function testEquals() + { + $option = new InputOption('foo', 'f', null, 'Some description'); + $option2 = new InputOption('foo', 'f', null, 'Alternative description'); + $this->assertTrue($option->equals($option2)); + + $option = new InputOption('foo', 'f', InputOption::VALUE_OPTIONAL, 'Some description'); + $option2 = new InputOption('foo', 'f', InputOption::VALUE_OPTIONAL, 'Some description', true); + $this->assertFalse($option->equals($option2)); + + $option = new InputOption('foo', 'f', null, 'Some description'); + $option2 = new InputOption('bar', 'f', null, 'Some description'); + $this->assertFalse($option->equals($option2)); + + $option = new InputOption('foo', 'f', null, 'Some description'); + $option2 = new InputOption('foo', '', null, 'Some description'); + $this->assertFalse($option->equals($option2)); + + $option = new InputOption('foo', 'f', null, 'Some description'); + $option2 = new InputOption('foo', 'f', InputOption::VALUE_OPTIONAL, 'Some description'); + $this->assertFalse($option->equals($option2)); + } +} diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Input/InputTest.php b/vendor/symfony/console/Symfony/Component/Console/Tests/Input/InputTest.php new file mode 100755 index 0000000..0b3e38f --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Tests/Input/InputTest.php @@ -0,0 +1,121 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Console\Tests\Input; + +use Symfony\Component\Console\Input\ArrayInput; +use Symfony\Component\Console\Input\InputDefinition; +use Symfony\Component\Console\Input\InputArgument; +use Symfony\Component\Console\Input\InputOption; + +class InputTest extends \PHPUnit_Framework_TestCase +{ + public function testConstructor() + { + $input = new ArrayInput(array('name' => 'foo'), new InputDefinition(array(new InputArgument('name')))); + $this->assertEquals('foo', $input->getArgument('name'), '->__construct() takes a InputDefinition as an argument'); + } + + public function testOptions() + { + $input = new ArrayInput(array('--name' => 'foo'), new InputDefinition(array(new InputOption('name')))); + $this->assertEquals('foo', $input->getOption('name'), '->getOption() returns the value for the given option'); + + $input->setOption('name', 'bar'); + $this->assertEquals('bar', $input->getOption('name'), '->setOption() sets the value for a given option'); + $this->assertEquals(array('name' => 'bar'), $input->getOptions(), '->getOptions() returns all option values'); + + $input = new ArrayInput(array('--name' => 'foo'), new InputDefinition(array(new InputOption('name'), new InputOption('bar', '', InputOption::VALUE_OPTIONAL, '', 'default')))); + $this->assertEquals('default', $input->getOption('bar'), '->getOption() returns the default value for optional options'); + $this->assertEquals(array('name' => 'foo', 'bar' => 'default'), $input->getOptions(), '->getOptions() returns all option values, even optional ones'); + } + + /** + * @expectedException \InvalidArgumentException + * @expectedExceptionMessage The "foo" option does not exist. + */ + public function testSetInvalidOption() + { + $input = new ArrayInput(array('--name' => 'foo'), new InputDefinition(array(new InputOption('name'), new InputOption('bar', '', InputOption::VALUE_OPTIONAL, '', 'default')))); + $input->setOption('foo', 'bar'); + } + + /** + * @expectedException \InvalidArgumentException + * @expectedExceptionMessage The "foo" option does not exist. + */ + public function testGetInvalidOption() + { + $input = new ArrayInput(array('--name' => 'foo'), new InputDefinition(array(new InputOption('name'), new InputOption('bar', '', InputOption::VALUE_OPTIONAL, '', 'default')))); + $input->getOption('foo'); + } + + public function testArguments() + { + $input = new ArrayInput(array('name' => 'foo'), new InputDefinition(array(new InputArgument('name')))); + $this->assertEquals('foo', $input->getArgument('name'), '->getArgument() returns the value for the given argument'); + + $input->setArgument('name', 'bar'); + $this->assertEquals('bar', $input->getArgument('name'), '->setArgument() sets the value for a given argument'); + $this->assertEquals(array('name' => 'bar'), $input->getArguments(), '->getArguments() returns all argument values'); + + $input = new ArrayInput(array('name' => 'foo'), new InputDefinition(array(new InputArgument('name'), new InputArgument('bar', InputArgument::OPTIONAL, '', 'default')))); + $this->assertEquals('default', $input->getArgument('bar'), '->getArgument() returns the default value for optional arguments'); + $this->assertEquals(array('name' => 'foo', 'bar' => 'default'), $input->getArguments(), '->getArguments() returns all argument values, even optional ones'); + } + + /** + * @expectedException \InvalidArgumentException + * @expectedExceptionMessage The "foo" argument does not exist. + */ + public function testSetInvalidArgument() + { + $input = new ArrayInput(array('name' => 'foo'), new InputDefinition(array(new InputArgument('name'), new InputArgument('bar', InputArgument::OPTIONAL, '', 'default')))); + $input->setArgument('foo', 'bar'); + } + + /** + * @expectedException \InvalidArgumentException + * @expectedExceptionMessage The "foo" argument does not exist. + */ + public function testGetInvalidArgument() + { + $input = new ArrayInput(array('name' => 'foo'), new InputDefinition(array(new InputArgument('name'), new InputArgument('bar', InputArgument::OPTIONAL, '', 'default')))); + $input->getArgument('foo'); + } + + /** + * @expectedException \RuntimeException + * @expectedExceptionMessage Not enough arguments. + */ + public function testValidateWithMissingArguments() + { + $input = new ArrayInput(array()); + $input->bind(new InputDefinition(array(new InputArgument('name', InputArgument::REQUIRED)))); + $input->validate(); + } + + public function testValidate() + { + $input = new ArrayInput(array('name' => 'foo')); + $input->bind(new InputDefinition(array(new InputArgument('name', InputArgument::REQUIRED)))); + + $this->assertNull($input->validate()); + } + + public function testSetGetInteractive() + { + $input = new ArrayInput(array()); + $this->assertTrue($input->isInteractive(), '->isInteractive() returns whether the input should be interactive or not'); + $input->setInteractive(false); + $this->assertFalse($input->isInteractive(), '->setInteractive() changes the interactive flag'); + } +} diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Input/StringInputTest.php b/vendor/symfony/console/Symfony/Component/Console/Tests/Input/StringInputTest.php new file mode 100755 index 0000000..b284320 --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Tests/Input/StringInputTest.php @@ -0,0 +1,90 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Console\Tests\Input; + +use Symfony\Component\Console\Input\InputDefinition; +use Symfony\Component\Console\Input\InputOption; +use Symfony\Component\Console\Input\StringInput; + +class StringInputTest extends \PHPUnit_Framework_TestCase +{ + /** + * @dataProvider getTokenizeData + */ + public function testTokenize($input, $tokens, $message) + { + $input = new StringInput($input); + $r = new \ReflectionClass('Symfony\Component\Console\Input\ArgvInput'); + $p = $r->getProperty('tokens'); + $p->setAccessible(true); + $this->assertEquals($tokens, $p->getValue($input), $message); + } + + public function testInputOptionWithGivenString() + { + $definition = new InputDefinition( + array(new InputOption('foo', null, InputOption::VALUE_REQUIRED)) + ); + + // call to bind + $input = new StringInput('--foo=bar'); + $input->bind($definition); + $this->assertEquals('bar', $input->getOption('foo')); + + // definition in constructor + $input = new StringInput('--foo=bar', $definition); + $this->assertEquals('bar', $input->getOption('foo')); + } + + public function getTokenizeData() + { + return array( + array('', array(), '->tokenize() parses an empty string'), + array('foo', array('foo'), '->tokenize() parses arguments'), + array(' foo bar ', array('foo', 'bar'), '->tokenize() ignores whitespaces between arguments'), + array('"quoted"', array('quoted'), '->tokenize() parses quoted arguments'), + array("'quoted'", array('quoted'), '->tokenize() parses quoted arguments'), + array("'a\rb\nc\td'", array("a\rb\nc\td"), '->tokenize() parses whitespace chars in strings'), + array("'a'\r'b'\n'c'\t'd'", array('a','b','c','d'), '->tokenize() parses whitespace chars between args as spaces'), + array('\"quoted\"', array('"quoted"'), '->tokenize() parses escaped-quoted arguments'), + array("\'quoted\'", array('\'quoted\''), '->tokenize() parses escaped-quoted arguments'), + array('-a', array('-a'), '->tokenize() parses short options'), + array('-azc', array('-azc'), '->tokenize() parses aggregated short options'), + array('-awithavalue', array('-awithavalue'), '->tokenize() parses short options with a value'), + array('-a"foo bar"', array('-afoo bar'), '->tokenize() parses short options with a value'), + array('-a"foo bar""foo bar"', array('-afoo barfoo bar'), '->tokenize() parses short options with a value'), + array('-a\'foo bar\'', array('-afoo bar'), '->tokenize() parses short options with a value'), + array('-a\'foo bar\'\'foo bar\'', array('-afoo barfoo bar'), '->tokenize() parses short options with a value'), + array('-a\'foo bar\'"foo bar"', array('-afoo barfoo bar'), '->tokenize() parses short options with a value'), + array('--long-option', array('--long-option'), '->tokenize() parses long options'), + array('--long-option=foo', array('--long-option=foo'), '->tokenize() parses long options with a value'), + array('--long-option="foo bar"', array('--long-option=foo bar'), '->tokenize() parses long options with a value'), + array('--long-option="foo bar""another"', array('--long-option=foo baranother'), '->tokenize() parses long options with a value'), + array('--long-option=\'foo bar\'', array('--long-option=foo bar'), '->tokenize() parses long options with a value'), + array("--long-option='foo bar''another'", array("--long-option=foo baranother"), '->tokenize() parses long options with a value'), + array("--long-option='foo bar'\"another\"", array("--long-option=foo baranother"), '->tokenize() parses long options with a value'), + array('foo -a -ffoo --long bar', array('foo', '-a', '-ffoo', '--long', 'bar'), '->tokenize() parses when several arguments and options'), + ); + } + + public function testToString() + { + $input = new StringInput('-f foo'); + $this->assertEquals('-f foo', (string) $input); + + $input = new StringInput('-f --bar=foo "a b c d"'); + $this->assertEquals('-f --bar=foo '.escapeshellarg('a b c d'), (string) $input); + + $input = new StringInput('-f --bar=foo \'a b c d\' '."'A\nB\\'C'"); + $this->assertEquals('-f --bar=foo '.escapeshellarg('a b c d').' '.escapeshellarg("A\nB'C"), (string) $input); + } +} diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Output/ConsoleOutputTest.php b/vendor/symfony/console/Symfony/Component/Console/Tests/Output/ConsoleOutputTest.php new file mode 100755 index 0000000..7a3ede3 --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Tests/Output/ConsoleOutputTest.php @@ -0,0 +1,24 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Console\Tests\Output; + +use Symfony\Component\Console\Output\ConsoleOutput; +use Symfony\Component\Console\Output\Output; + +class ConsoleOutputTest extends \PHPUnit_Framework_TestCase +{ + public function testConstructor() + { + $output = new ConsoleOutput(Output::VERBOSITY_QUIET, true); + $this->assertEquals(Output::VERBOSITY_QUIET, $output->getVerbosity(), '__construct() takes the verbosity as its first argument'); + } +} diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Output/NullOutputTest.php b/vendor/symfony/console/Symfony/Component/Console/Tests/Output/NullOutputTest.php new file mode 100755 index 0000000..b20ae4e --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Tests/Output/NullOutputTest.php @@ -0,0 +1,39 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Console\Tests\Output; + +use Symfony\Component\Console\Output\NullOutput; +use Symfony\Component\Console\Output\OutputInterface; + +class NullOutputTest extends \PHPUnit_Framework_TestCase +{ + public function testConstructor() + { + $output = new NullOutput(); + + ob_start(); + $output->write('foo'); + $buffer = ob_get_clean(); + + $this->assertSame('', $buffer, '->write() does nothing (at least nothing is printed)'); + $this->assertFalse($output->isDecorated(), '->isDecorated() returns false'); + } + + public function testVerbosity() + { + $output = new NullOutput(); + $this->assertSame(OutputInterface::VERBOSITY_QUIET, $output->getVerbosity(), '->getVerbosity() returns VERBOSITY_QUIET for NullOutput by default'); + + $output->setVerbosity(OutputInterface::VERBOSITY_VERBOSE); + $this->assertSame(OutputInterface::VERBOSITY_QUIET, $output->getVerbosity(), '->getVerbosity() always returns VERBOSITY_QUIET for NullOutput'); + } +} diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Output/OutputTest.php b/vendor/symfony/console/Symfony/Component/Console/Tests/Output/OutputTest.php new file mode 100755 index 0000000..95bbbe6 --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Tests/Output/OutputTest.php @@ -0,0 +1,156 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Console\Tests\Output; + +use Symfony\Component\Console\Output\Output; +use Symfony\Component\Console\Formatter\OutputFormatterStyle; + +class OutputTest extends \PHPUnit_Framework_TestCase +{ + public function testConstructor() + { + $output = new TestOutput(Output::VERBOSITY_QUIET, true); + $this->assertEquals(Output::VERBOSITY_QUIET, $output->getVerbosity(), '__construct() takes the verbosity as its first argument'); + $this->assertTrue($output->isDecorated(), '__construct() takes the decorated flag as its second argument'); + } + + public function testSetIsDecorated() + { + $output = new TestOutput(); + $output->setDecorated(true); + $this->assertTrue($output->isDecorated(), 'setDecorated() sets the decorated flag'); + } + + public function testSetGetVerbosity() + { + $output = new TestOutput(); + $output->setVerbosity(Output::VERBOSITY_QUIET); + $this->assertEquals(Output::VERBOSITY_QUIET, $output->getVerbosity(), '->setVerbosity() sets the verbosity'); + + $this->assertTrue($output->isQuiet()); + $this->assertFalse($output->isVerbose()); + $this->assertFalse($output->isVeryVerbose()); + $this->assertFalse($output->isDebug()); + + $output->setVerbosity(Output::VERBOSITY_NORMAL); + $this->assertFalse($output->isQuiet()); + $this->assertFalse($output->isVerbose()); + $this->assertFalse($output->isVeryVerbose()); + $this->assertFalse($output->isDebug()); + + $output->setVerbosity(Output::VERBOSITY_VERBOSE); + $this->assertFalse($output->isQuiet()); + $this->assertTrue($output->isVerbose()); + $this->assertFalse($output->isVeryVerbose()); + $this->assertFalse($output->isDebug()); + + $output->setVerbosity(Output::VERBOSITY_VERY_VERBOSE); + $this->assertFalse($output->isQuiet()); + $this->assertTrue($output->isVerbose()); + $this->assertTrue($output->isVeryVerbose()); + $this->assertFalse($output->isDebug()); + + $output->setVerbosity(Output::VERBOSITY_DEBUG); + $this->assertFalse($output->isQuiet()); + $this->assertTrue($output->isVerbose()); + $this->assertTrue($output->isVeryVerbose()); + $this->assertTrue($output->isDebug()); + } + + public function testWriteWithVerbosityQuiet() + { + $output = new TestOutput(Output::VERBOSITY_QUIET); + $output->writeln('foo'); + $this->assertEquals('', $output->output, '->writeln() outputs nothing if verbosity is set to VERBOSITY_QUIET'); + } + + public function testWriteAnArrayOfMessages() + { + $output = new TestOutput(); + $output->writeln(array('foo', 'bar')); + $this->assertEquals("foo\nbar\n", $output->output, '->writeln() can take an array of messages to output'); + } + + /** + * @dataProvider provideWriteArguments + */ + public function testWriteRawMessage($message, $type, $expectedOutput) + { + $output = new TestOutput(); + $output->writeln($message, $type); + $this->assertEquals($expectedOutput, $output->output); + } + + public function provideWriteArguments() + { + return array( + array('foo', Output::OUTPUT_RAW, "foo\n"), + array('foo', Output::OUTPUT_PLAIN, "foo\n"), + ); + } + + public function testWriteWithDecorationTurnedOff() + { + $output = new TestOutput(); + $output->setDecorated(false); + $output->writeln('foo'); + $this->assertEquals("foo\n", $output->output, '->writeln() strips decoration tags if decoration is set to false'); + } + + public function testWriteDecoratedMessage() + { + $fooStyle = new OutputFormatterStyle('yellow', 'red', array('blink')); + $output = new TestOutput(); + $output->getFormatter()->setStyle('FOO', $fooStyle); + $output->setDecorated(true); + $output->writeln('foo'); + $this->assertEquals("\033[33;41;5mfoo\033[0m\n", $output->output, '->writeln() decorates the output'); + } + + /** + * @expectedException \InvalidArgumentException + * @expectedExceptionMessage Unknown output type given (24) + */ + public function testWriteWithInvalidOutputType() + { + $output = new TestOutput(); + $output->writeln('foo', 24); + } + + public function testWriteWithInvalidStyle() + { + $output = new TestOutput(); + + $output->clear(); + $output->write('foo'); + $this->assertEquals('foo', $output->output, '->write() do nothing when a style does not exist'); + + $output->clear(); + $output->writeln('foo'); + $this->assertEquals("foo\n", $output->output, '->writeln() do nothing when a style does not exist'); + } +} + +class TestOutput extends Output +{ + public $output = ''; + + public function clear() + { + $this->output = ''; + } + + protected function doWrite($message, $newline) + { + $this->output .= $message.($newline ? "\n" : ''); + } +} diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Output/StreamOutputTest.php b/vendor/symfony/console/Symfony/Component/Console/Tests/Output/StreamOutputTest.php new file mode 100755 index 0000000..2fd4f61 --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Tests/Output/StreamOutputTest.php @@ -0,0 +1,60 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Console\Tests\Output; + +use Symfony\Component\Console\Output\Output; +use Symfony\Component\Console\Output\StreamOutput; + +class StreamOutputTest extends \PHPUnit_Framework_TestCase +{ + protected $stream; + + protected function setUp() + { + $this->stream = fopen('php://memory', 'a', false); + } + + protected function tearDown() + { + $this->stream = null; + } + + public function testConstructor() + { + $output = new StreamOutput($this->stream, Output::VERBOSITY_QUIET, true); + $this->assertEquals(Output::VERBOSITY_QUIET, $output->getVerbosity(), '__construct() takes the verbosity as its first argument'); + $this->assertTrue($output->isDecorated(), '__construct() takes the decorated flag as its second argument'); + } + + /** + * @expectedException \InvalidArgumentException + * @expectedExceptionMessage The StreamOutput class needs a stream as its first argument. + */ + public function testStreamIsRequired() + { + new StreamOutput('foo'); + } + + public function testGetStream() + { + $output = new StreamOutput($this->stream); + $this->assertEquals($this->stream, $output->getStream(), '->getStream() returns the current stream'); + } + + public function testDoWrite() + { + $output = new StreamOutput($this->stream); + $output->writeln('foo'); + rewind($output->getStream()); + $this->assertEquals('foo'.PHP_EOL, stream_get_contents($output->getStream()), '->doWrite() writes to the stream'); + } +} diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Tester/ApplicationTesterTest.php b/vendor/symfony/console/Symfony/Component/Console/Tests/Tester/ApplicationTesterTest.php new file mode 100755 index 0000000..a8389dd --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Tests/Tester/ApplicationTesterTest.php @@ -0,0 +1,69 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Console\Tests\Tester; + +use Symfony\Component\Console\Application; +use Symfony\Component\Console\Output\Output; +use Symfony\Component\Console\Tester\ApplicationTester; + +class ApplicationTesterTest extends \PHPUnit_Framework_TestCase +{ + protected $application; + protected $tester; + + protected function setUp() + { + $this->application = new Application(); + $this->application->setAutoExit(false); + $this->application->register('foo') + ->addArgument('foo') + ->setCode(function ($input, $output) { $output->writeln('foo'); }) + ; + + $this->tester = new ApplicationTester($this->application); + $this->tester->run(array('command' => 'foo', 'foo' => 'bar'), array('interactive' => false, 'decorated' => false, 'verbosity' => Output::VERBOSITY_VERBOSE)); + } + + protected function tearDown() + { + $this->application = null; + $this->tester = null; + } + + public function testRun() + { + $this->assertFalse($this->tester->getInput()->isInteractive(), '->execute() takes an interactive option'); + $this->assertFalse($this->tester->getOutput()->isDecorated(), '->execute() takes a decorated option'); + $this->assertEquals(Output::VERBOSITY_VERBOSE, $this->tester->getOutput()->getVerbosity(), '->execute() takes a verbosity option'); + } + + public function testGetInput() + { + $this->assertEquals('bar', $this->tester->getInput()->getArgument('foo'), '->getInput() returns the current input instance'); + } + + public function testGetOutput() + { + rewind($this->tester->getOutput()->getStream()); + $this->assertEquals('foo'.PHP_EOL, stream_get_contents($this->tester->getOutput()->getStream()), '->getOutput() returns the current output instance'); + } + + public function testGetDisplay() + { + $this->assertEquals('foo'.PHP_EOL, $this->tester->getDisplay(), '->getDisplay() returns the display of the last execution'); + } + + public function testGetStatusCode() + { + $this->assertSame(0, $this->tester->getStatusCode(), '->getStatusCode() returns the status code'); + } +} diff --git a/vendor/symfony/console/Symfony/Component/Console/Tests/Tester/CommandTesterTest.php b/vendor/symfony/console/Symfony/Component/Console/Tests/Tester/CommandTesterTest.php new file mode 100755 index 0000000..b54c00e --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/Tests/Tester/CommandTesterTest.php @@ -0,0 +1,84 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Console\Tests\Tester; + +use Symfony\Component\Console\Application; +use Symfony\Component\Console\Command\Command; +use Symfony\Component\Console\Output\Output; +use Symfony\Component\Console\Tester\CommandTester; + +class CommandTesterTest extends \PHPUnit_Framework_TestCase +{ + protected $command; + protected $tester; + + protected function setUp() + { + $this->command = new Command('foo'); + $this->command->addArgument('command'); + $this->command->addArgument('foo'); + $this->command->setCode(function ($input, $output) { $output->writeln('foo'); }); + + $this->tester = new CommandTester($this->command); + $this->tester->execute(array('foo' => 'bar'), array('interactive' => false, 'decorated' => false, 'verbosity' => Output::VERBOSITY_VERBOSE)); + } + + protected function tearDown() + { + $this->command = null; + $this->tester = null; + } + + public function testExecute() + { + $this->assertFalse($this->tester->getInput()->isInteractive(), '->execute() takes an interactive option'); + $this->assertFalse($this->tester->getOutput()->isDecorated(), '->execute() takes a decorated option'); + $this->assertEquals(Output::VERBOSITY_VERBOSE, $this->tester->getOutput()->getVerbosity(), '->execute() takes a verbosity option'); + } + + public function testGetInput() + { + $this->assertEquals('bar', $this->tester->getInput()->getArgument('foo'), '->getInput() returns the current input instance'); + } + + public function testGetOutput() + { + rewind($this->tester->getOutput()->getStream()); + $this->assertEquals('foo'.PHP_EOL, stream_get_contents($this->tester->getOutput()->getStream()), '->getOutput() returns the current output instance'); + } + + public function testGetDisplay() + { + $this->assertEquals('foo'.PHP_EOL, $this->tester->getDisplay(), '->getDisplay() returns the display of the last execution'); + } + + public function testGetStatusCode() + { + $this->assertSame(0, $this->tester->getStatusCode(), '->getStatusCode() returns the status code'); + } + + public function testCommandFromApplication() + { + $application = new Application(); + $application->setAutoExit(false); + + $command = new Command('foo'); + $command->setCode(function ($input, $output) { $output->writeln('foo'); }); + + $application->add($command); + + $tester = new CommandTester($application->find('foo')); + + // check that there is no need to pass the command name here + $this->assertEquals(0, $tester->execute(array())); + } +} diff --git a/vendor/symfony/console/Symfony/Component/Console/composer.json b/vendor/symfony/console/Symfony/Component/Console/composer.json new file mode 100755 index 0000000..77777aa --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/composer.json @@ -0,0 +1,37 @@ +{ + "name": "symfony/console", + "type": "library", + "description": "Symfony Console Component", + "keywords": [], + "homepage": "http://symfony.com", + "license": "MIT", + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + } + ], + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "symfony/event-dispatcher": "~2.1" + }, + "suggest": { + "symfony/event-dispatcher": "" + }, + "autoload": { + "psr-0": { "Symfony\\Component\\Console\\": "" } + }, + "target-dir": "Symfony/Component/Console", + "minimum-stability": "dev", + "extra": { + "branch-alias": { + "dev-master": "2.4-dev" + } + } +} diff --git a/vendor/symfony/console/Symfony/Component/Console/phpunit.xml.dist b/vendor/symfony/console/Symfony/Component/Console/phpunit.xml.dist new file mode 100755 index 0000000..8a7edd4 --- /dev/null +++ b/vendor/symfony/console/Symfony/Component/Console/phpunit.xml.dist @@ -0,0 +1,30 @@ + + + + + + ./Tests/ + + + + + + ./ + + ./Resources + ./Tests + ./vendor + + + + diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/.gitignore b/vendor/symfony/css-selector/Symfony/Component/CssSelector/.gitignore new file mode 100755 index 0000000..c49a5d8 --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/.gitignore @@ -0,0 +1,3 @@ +vendor/ +composer.lock +phpunit.xml diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/CHANGELOG.md b/vendor/symfony/css-selector/Symfony/Component/CssSelector/CHANGELOG.md new file mode 100755 index 0000000..be10abe --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/CHANGELOG.md @@ -0,0 +1,7 @@ +CHANGELOG +========= + +2.1.0 +----- + + * none diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/CssSelector.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/CssSelector.php new file mode 100755 index 0000000..7a12a8b --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/CssSelector.php @@ -0,0 +1,83 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\CssSelector; + +use Symfony\Component\CssSelector\Parser\Shortcut\ClassParser; +use Symfony\Component\CssSelector\Parser\Shortcut\ElementParser; +use Symfony\Component\CssSelector\Parser\Shortcut\EmptyStringParser; +use Symfony\Component\CssSelector\Parser\Shortcut\HashParser; +use Symfony\Component\CssSelector\XPath\Extension\HtmlExtension; +use Symfony\Component\CssSelector\XPath\Translator; + +/** + * CssSelector is the main entry point of the component and can convert CSS + * selectors to XPath expressions. + * + * $xpath = CssSelector::toXpath('h1.foo'); + * + * This component is a port of the Python cssselector library, + * which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect. + * + * @author Fabien Potencier + * + * @api + */ +class CssSelector +{ + private static $html = true; + + /** + * Translates a CSS expression to its XPath equivalent. + * Optionally, a prefix can be added to the resulting XPath + * expression with the $prefix parameter. + * + * @param mixed $cssExpr The CSS expression. + * @param string $prefix An optional prefix for the XPath expression. + * + * @return string + * + * @api + */ + public static function toXPath($cssExpr, $prefix = 'descendant-or-self::') + { + $translator = new Translator(); + + if (self::$html) { + $translator->registerExtension(new HtmlExtension($translator)); + } + + $translator + ->registerParserShortcut(new EmptyStringParser()) + ->registerParserShortcut(new ElementParser()) + ->registerParserShortcut(new ClassParser()) + ->registerParserShortcut(new HashParser()) + ; + + return $translator->cssToXPath($cssExpr, $prefix); + } + + /** + * Enables the HTML extension. + */ + public static function enableHtmlExtension() + { + self::$html = true; + } + + /** + * Disables the HTML extension. + */ + public static function disableHtmlExtension() + { + self::$html = false; + } +} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Exception/ExceptionInterface.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Exception/ExceptionInterface.php new file mode 100755 index 0000000..da01c2b --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Exception/ExceptionInterface.php @@ -0,0 +1,24 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\CssSelector\Exception; + +/** + * Interface for exceptions. + * + * This component is a port of the Python cssselector library, + * which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect. + * + * @author Jean-François Simon + */ +interface ExceptionInterface +{ +} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Exception/ExpressionErrorException.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Exception/ExpressionErrorException.php new file mode 100755 index 0000000..151dbf0 --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Exception/ExpressionErrorException.php @@ -0,0 +1,24 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\CssSelector\Exception; + +/** + * ParseException is thrown when a CSS selector syntax is not valid. + * + * This component is a port of the Python cssselector library, + * which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect. + * + * @author Jean-François Simon + */ +class ExpressionErrorException extends ParseException implements ExceptionInterface +{ +} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Exception/InternalErrorException.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Exception/InternalErrorException.php new file mode 100755 index 0000000..8a815fb --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Exception/InternalErrorException.php @@ -0,0 +1,24 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\CssSelector\Exception; + +/** + * ParseException is thrown when a CSS selector syntax is not valid. + * + * This component is a port of the Python cssselector library, + * which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect. + * + * @author Jean-François Simon + */ +class InternalErrorException extends ParseException implements ExceptionInterface +{ +} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Exception/ParseException.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Exception/ParseException.php new file mode 100755 index 0000000..9c119f8 --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Exception/ParseException.php @@ -0,0 +1,24 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\CssSelector\Exception; + +/** + * ParseException is thrown when a CSS selector syntax is not valid. + * + * This component is a port of the Python cssselector library, + * which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect. + * + * @author Fabien Potencier + */ +class ParseException extends \Exception implements ExceptionInterface +{ +} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Exception/SyntaxErrorException.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Exception/SyntaxErrorException.php new file mode 100755 index 0000000..529b891 --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Exception/SyntaxErrorException.php @@ -0,0 +1,73 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\CssSelector\Exception; + +use Symfony\Component\CssSelector\Parser\Token; + +/** + * ParseException is thrown when a CSS selector syntax is not valid. + * + * This component is a port of the Python cssselector library, + * which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect. + * + * @author Jean-François Simon + */ +class SyntaxErrorException extends ParseException implements ExceptionInterface +{ + /** + * @param string $expectedValue + * @param Token $foundToken + * + * @return SyntaxErrorException + */ + public static function unexpectedToken($expectedValue, Token $foundToken) + { + return new self(sprintf('Expected %s, but %s found.', $expectedValue, $foundToken)); + } + + /** + * @param string $pseudoElement + * @param string $unexpectedLocation + * + * @return SyntaxErrorException + */ + public static function pseudoElementFound($pseudoElement, $unexpectedLocation) + { + return new self(sprintf('Unexpected pseudo-element "::%s" found %s.', $pseudoElement, $unexpectedLocation)); + } + + /** + * @param int $position + * + * @return SyntaxErrorException + */ + public static function unclosedString($position) + { + return new self(sprintf('Unclosed/invalid string at %s.', $position)); + } + + /** + * @return SyntaxErrorException + */ + public static function nestedNot() + { + return new self('Got nested ::not().'); + } + + /** + * @return SyntaxErrorException + */ + public static function stringAsFunctionArgument() + { + return new self('String not allowed as function argument.'); + } +} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/LICENSE b/vendor/symfony/css-selector/Symfony/Component/CssSelector/LICENSE new file mode 100755 index 0000000..0b3292c --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2004-2014 Fabien Potencier + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is furnished +to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Node/AbstractNode.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Node/AbstractNode.php new file mode 100755 index 0000000..f5324e1 --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Node/AbstractNode.php @@ -0,0 +1,40 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\CssSelector\Node; + +/** + * Abstract base node class. + * + * This component is a port of the Python cssselector library, + * which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect. + * + * @author Jean-François Simon + */ +abstract class AbstractNode implements NodeInterface +{ + /** + * @var string + */ + private $nodeName; + + /** + * @return string + */ + public function getNodeName() + { + if (null === $this->nodeName) { + $this->nodeName = preg_replace('~.*\\\\([^\\\\]+)Node$~', '$1', get_called_class()); + } + + return $this->nodeName; + } +} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Node/AttributeNode.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Node/AttributeNode.php new file mode 100755 index 0000000..e2fa9a2 --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Node/AttributeNode.php @@ -0,0 +1,124 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\CssSelector\Node; + +/** + * Represents a "[| ]" node. + * + * This component is a port of the Python cssselector library, + * which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect. + * + * @author Jean-François Simon + */ +class AttributeNode extends AbstractNode +{ + /** + * @var NodeInterface + */ + private $selector; + + /** + * @var string + */ + private $namespace; + + /** + * @var string + */ + private $attribute; + + /** + * @var string + */ + private $operator; + + /** + * @var string + */ + private $value; + + /** + * @param NodeInterface $selector + * @param string $namespace + * @param string $attribute + * @param string $operator + * @param string $value + */ + public function __construct(NodeInterface $selector, $namespace, $attribute, $operator, $value) + { + $this->selector = $selector; + $this->namespace = $namespace; + $this->attribute = $attribute; + $this->operator = $operator; + $this->value = $value; + } + + /** + * @return NodeInterface + */ + public function getSelector() + { + return $this->selector; + } + + /** + * @return string + */ + public function getNamespace() + { + return $this->namespace; + } + + /** + * @return string + */ + public function getAttribute() + { + return $this->attribute; + } + + /** + * @return string + */ + public function getOperator() + { + return $this->operator; + } + + /** + * @return string + */ + public function getValue() + { + return $this->value; + } + + /** + * {@inheritdoc} + */ + public function getSpecificity() + { + return $this->selector->getSpecificity()->plus(new Specificity(0, 1, 0)); + } + + /** + * {@inheritdoc} + */ + public function __toString() + { + $attribute = $this->namespace ? $this->namespace.'|'.$this->attribute : $this->attribute; + + return 'exists' === $this->operator + ? sprintf('%s[%s[%s]]', $this->getNodeName(), $this->selector, $attribute) + : sprintf("%s[%s[%s %s '%s']]", $this->getNodeName(), $this->selector, $attribute, $this->operator, $this->value); + } +} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Node/ClassNode.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Node/ClassNode.php new file mode 100755 index 0000000..a7a59a3 --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Node/ClassNode.php @@ -0,0 +1,75 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\CssSelector\Node; + +/** + * Represents a "." node. + * + * This component is a port of the Python cssselector library, + * which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect. + * + * @author Jean-François Simon + */ +class ClassNode extends AbstractNode +{ + /** + * @var NodeInterface + */ + private $selector; + + /** + * @var string + */ + private $name; + + /** + * @param NodeInterface $selector + * @param string $name + */ + public function __construct(NodeInterface $selector, $name) + { + $this->selector = $selector; + $this->name = $name; + } + + /** + * @return NodeInterface + */ + public function getSelector() + { + return $this->selector; + } + + /** + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * {@inheritdoc} + */ + public function getSpecificity() + { + return $this->selector->getSpecificity()->plus(new Specificity(0, 1, 0)); + } + + /** + * {@inheritdoc} + */ + public function __toString() + { + return sprintf('%s[%s.%s]', $this->getNodeName(), $this->selector, $this->name); + } +} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Node/CombinedSelectorNode.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Node/CombinedSelectorNode.php new file mode 100755 index 0000000..4e085ea --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Node/CombinedSelectorNode.php @@ -0,0 +1,92 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\CssSelector\Node; + +/** + * Represents a combined node. + * + * This component is a port of the Python cssselector library, + * which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect. + * + * @author Jean-François Simon + */ +class CombinedSelectorNode extends AbstractNode +{ + /** + * @var NodeInterface + */ + private $selector; + + /** + * @var string + */ + private $combinator; + + /** + * @var NodeInterface + */ + private $subSelector; + + /** + * @param NodeInterface $selector + * @param string $combinator + * @param NodeInterface $subSelector + */ + public function __construct(NodeInterface $selector, $combinator, NodeInterface $subSelector) + { + $this->selector = $selector; + $this->combinator = $combinator; + $this->subSelector = $subSelector; + } + + /** + * @return NodeInterface + */ + public function getSelector() + { + return $this->selector; + } + + /** + * @return string + */ + public function getCombinator() + { + return $this->combinator; + } + + /** + * @return NodeInterface + */ + public function getSubSelector() + { + return $this->subSelector; + } + + /** + * {@inheritdoc} + */ + public function getSpecificity() + { + return $this->selector->getSpecificity()->plus($this->subSelector->getSpecificity()); + } + + /** + * {@inheritdoc} + */ + public function __toString() + { + $combinator = ' ' === $this->combinator ? '' : $this->combinator; + + return sprintf('%s[%s %s %s]', $this->getNodeName(), $this->selector, $combinator, $this->subSelector); + } +} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Node/ElementNode.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Node/ElementNode.php new file mode 100755 index 0000000..9ab13c3 --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Node/ElementNode.php @@ -0,0 +1,77 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\CssSelector\Node; + +/** + * Represents a "|" node. + * + * This component is a port of the Python cssselector library, + * which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect. + * + * @author Jean-François Simon + */ +class ElementNode extends AbstractNode +{ + /** + * @var string|null + */ + private $namespace; + + /** + * @var string|null + */ + private $element; + + /** + * @param string|null $namespace + * @param string|null $element + */ + public function __construct($namespace = null, $element = null) + { + $this->namespace = $namespace; + $this->element = $element; + } + + /** + * @return null|string + */ + public function getNamespace() + { + return $this->namespace; + } + + /** + * @return null|string + */ + public function getElement() + { + return $this->element; + } + + /** + * {@inheritdoc} + */ + public function getSpecificity() + { + return new Specificity(0, 0, $this->element ? 1 : 0); + } + + /** + * {@inheritdoc} + */ + public function __toString() + { + $element = $this->element ?: '*'; + + return sprintf('%s[%s]', $this->getNodeName(), $this->namespace ? $this->namespace.'|'.$element : $element); + } +} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Node/FunctionNode.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Node/FunctionNode.php new file mode 100755 index 0000000..ecd11a5 --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Node/FunctionNode.php @@ -0,0 +1,96 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\CssSelector\Node; + +use Symfony\Component\CssSelector\Parser\Token; + +/** + * Represents a ":()" node. + * + * This component is a port of the Python cssselector library, + * which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect. + * + * @author Jean-François Simon + */ +class FunctionNode extends AbstractNode +{ + /** + * @var NodeInterface + */ + private $selector; + + /** + * @var string + */ + private $name; + + /** + * @var Token[] + */ + private $arguments; + + /** + * @param NodeInterface $selector + * @param string $name + * @param Token[] $arguments + */ + public function __construct(NodeInterface $selector, $name, array $arguments = array()) + { + $this->selector = $selector; + $this->name = strtolower($name); + $this->arguments = $arguments; + } + + /** + * @return NodeInterface + */ + public function getSelector() + { + return $this->selector; + } + + /** + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * @return Token[] + */ + public function getArguments() + { + return $this->arguments; + } + + /** + * {@inheritdoc} + */ + public function getSpecificity() + { + return $this->selector->getSpecificity()->plus(new Specificity(0, 1, 0)); + } + + /** + * {@inheritdoc} + */ + public function __toString() + { + $arguments = implode(', ', array_map(function (Token $token) { + return "'".$token->getValue()."'"; + }, $this->arguments)); + + return sprintf('%s[%s:%s(%s)]', $this->getNodeName(), $this->selector, $this->name, $arguments ? '['.$arguments.']' : ''); + } +} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Node/HashNode.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Node/HashNode.php new file mode 100755 index 0000000..7fb4075 --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Node/HashNode.php @@ -0,0 +1,75 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\CssSelector\Node; + +/** + * Represents a "#" node. + * + * This component is a port of the Python cssselector library, + * which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect. + * + * @author Jean-François Simon + */ +class HashNode extends AbstractNode +{ + /** + * @var NodeInterface + */ + private $selector; + + /** + * @var string + */ + private $id; + + /** + * @param NodeInterface $selector + * @param string $id + */ + public function __construct(NodeInterface $selector, $id) + { + $this->selector = $selector; + $this->id = $id; + } + + /** + * @return NodeInterface + */ + public function getSelector() + { + return $this->selector; + } + + /** + * @return string + */ + public function getId() + { + return $this->id; + } + + /** + * {@inheritdoc} + */ + public function getSpecificity() + { + return $this->selector->getSpecificity()->plus(new Specificity(1, 0, 0)); + } + + /** + * {@inheritdoc} + */ + public function __toString() + { + return sprintf('%s[%s#%s]', $this->getNodeName(), $this->selector, $this->id); + } +} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Node/NegationNode.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Node/NegationNode.php new file mode 100755 index 0000000..2529689 --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Node/NegationNode.php @@ -0,0 +1,75 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\CssSelector\Node; + +/** + * Represents a ":not()" node. + * + * This component is a port of the Python cssselector library, + * which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect. + * + * @author Jean-François Simon + */ +class NegationNode extends AbstractNode +{ + /** + * @var NodeInterface + */ + private $selector; + + /** + * @var NodeInterface + */ + private $subSelector; + + /** + * @param NodeInterface $selector + * @param NodeInterface $subSelector + */ + public function __construct(NodeInterface $selector, NodeInterface $subSelector) + { + $this->selector = $selector; + $this->subSelector = $subSelector; + } + + /** + * @return NodeInterface + */ + public function getSelector() + { + return $this->selector; + } + + /** + * @return NodeInterface + */ + public function getSubSelector() + { + return $this->subSelector; + } + + /** + * {@inheritdoc} + */ + public function getSpecificity() + { + return $this->selector->getSpecificity()->plus($this->subSelector->getSpecificity()); + } + + /** + * {@inheritdoc} + */ + public function __toString() + { + return sprintf('%s[%s:not(%s)]', $this->getNodeName(), $this->selector, $this->subSelector); + } +} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Node/NodeInterface.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Node/NodeInterface.php new file mode 100755 index 0000000..1601c33 --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Node/NodeInterface.php @@ -0,0 +1,44 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\CssSelector\Node; + +/** + * Interface for nodes. + * + * This component is a port of the Python cssselector library, + * which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect. + * + * @author Jean-François Simon + */ +interface NodeInterface +{ + /** + * Returns node's name. + * + * @return string + */ + public function getNodeName(); + + /** + * Returns node's specificity. + * + * @return Specificity + */ + public function getSpecificity(); + + /** + * Returns node's string representation. + * + * @return string + */ + public function __toString(); +} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Node/PseudoNode.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Node/PseudoNode.php new file mode 100755 index 0000000..4f2d538 --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Node/PseudoNode.php @@ -0,0 +1,75 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\CssSelector\Node; + +/** + * Represents a ":" node. + * + * This component is a port of the Python cssselector library, + * which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect. + * + * @author Jean-François Simon + */ +class PseudoNode extends AbstractNode +{ + /** + * @var NodeInterface + */ + private $selector; + + /** + * @var string + */ + private $identifier; + + /** + * @param NodeInterface $selector + * @param string $identifier + */ + public function __construct(NodeInterface $selector, $identifier) + { + $this->selector = $selector; + $this->identifier = strtolower($identifier); + } + + /** + * @return NodeInterface + */ + public function getSelector() + { + return $this->selector; + } + + /** + * @return string + */ + public function getIdentifier() + { + return $this->identifier; + } + + /** + * {@inheritdoc} + */ + public function getSpecificity() + { + return $this->selector->getSpecificity()->plus(new Specificity(0, 1, 0)); + } + + /** + * {@inheritdoc} + */ + public function __toString() + { + return sprintf('%s[%s:%s]', $this->getNodeName(), $this->selector, $this->identifier); + } +} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Node/SelectorNode.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Node/SelectorNode.php new file mode 100755 index 0000000..49f417f --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Node/SelectorNode.php @@ -0,0 +1,75 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\CssSelector\Node; + +/** + * Represents a "(::|:)" node. + * + * This component is a port of the Python cssselector library, + * which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect. + * + * @author Jean-François Simon + */ +class SelectorNode extends AbstractNode +{ + /** + * @var NodeInterface + */ + private $tree; + + /** + * @var null|string + */ + private $pseudoElement; + + /** + * @param NodeInterface $tree + * @param null|string $pseudoElement + */ + public function __construct(NodeInterface $tree, $pseudoElement = null) + { + $this->tree = $tree; + $this->pseudoElement = $pseudoElement ? strtolower($pseudoElement) : null; + } + + /** + * @return NodeInterface + */ + public function getTree() + { + return $this->tree; + } + + /** + * @return null|string + */ + public function getPseudoElement() + { + return $this->pseudoElement; + } + + /** + * {@inheritdoc} + */ + public function getSpecificity() + { + return $this->tree->getSpecificity()->plus(new Specificity(0, 0, $this->pseudoElement ? 1 : 0)); + } + + /** + * {@inheritdoc} + */ + public function __toString() + { + return sprintf('%s[%s%s]', $this->getNodeName(), $this->tree, $this->pseudoElement ? '::'.$this->pseudoElement : ''); + } +} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Node/Specificity.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Node/Specificity.php new file mode 100755 index 0000000..96bbd11 --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Node/Specificity.php @@ -0,0 +1,78 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\CssSelector\Node; + +/** + * Represents a node specificity. + * + * This component is a port of the Python cssselector library, + * which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect. + * + * @see http://www.w3.org/TR/selectors/#specificity + * + * @author Jean-François Simon + */ +class Specificity +{ + const A_FACTOR = 100; + const B_FACTOR = 10; + const C_FACTOR = 1; + + /** + * @var int + */ + private $a; + + /** + * @var int + */ + private $b; + + /** + * @var int + */ + private $c; + + /** + * Constructor. + * + * @param int $a + * @param int $b + * @param int $c + */ + public function __construct($a, $b, $c) + { + $this->a = $a; + $this->b = $b; + $this->c = $c; + } + + /** + * @param Specificity $specificity + * + * @return Specificity + */ + public function plus(Specificity $specificity) + { + return new self($this->a + $specificity->a, $this->b + $specificity->b, $this->c + $specificity->c); + } + + /** + * Returns global specificity value. + * + * @return int + */ + public function getValue() + { + return $this->a * self::A_FACTOR + $this->b * self::B_FACTOR + $this->c * self::C_FACTOR; + } +} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/Handler/CommentHandler.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/Handler/CommentHandler.php new file mode 100755 index 0000000..97c3f8d --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/Handler/CommentHandler.php @@ -0,0 +1,46 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\CssSelector\Parser\Handler; + +use Symfony\Component\CssSelector\Parser\Reader; +use Symfony\Component\CssSelector\Parser\TokenStream; + +/** + * CSS selector comment handler. + * + * This component is a port of the Python cssselector library, + * which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect. + * + * @author Jean-François Simon + */ +class CommentHandler implements HandlerInterface +{ + /** + * {@inheritdoc} + */ + public function handle(Reader $reader, TokenStream $stream) + { + if ('/*' !== $reader->getSubstring(2)) { + return false; + } + + $offset = $reader->getOffset('*/'); + + if (false === $offset) { + $reader->moveToEnd(); + } else { + $reader->moveForward($offset + 2); + } + + return true; + } +} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/Handler/HandlerInterface.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/Handler/HandlerInterface.php new file mode 100755 index 0000000..c7a48c0 --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/Handler/HandlerInterface.php @@ -0,0 +1,34 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\CssSelector\Parser\Handler; + +use Symfony\Component\CssSelector\Parser\Reader; +use Symfony\Component\CssSelector\Parser\TokenStream; + +/** + * CSS selector handler interface. + * + * This component is a port of the Python cssselector library, + * which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect. + * + * @author Jean-François Simon + */ +interface HandlerInterface +{ + /** + * @param Reader $reader + * @param TokenStream $stream + * + * @return bool + */ + public function handle(Reader $reader, TokenStream $stream); +} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/Handler/HashHandler.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/Handler/HashHandler.php new file mode 100755 index 0000000..2227ea6 --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/Handler/HashHandler.php @@ -0,0 +1,67 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\CssSelector\Parser\Handler; + +use Symfony\Component\CssSelector\Parser\Reader; +use Symfony\Component\CssSelector\Parser\Token; +use Symfony\Component\CssSelector\Parser\TokenStream; +use Symfony\Component\CssSelector\Parser\Tokenizer\TokenizerEscaping; +use Symfony\Component\CssSelector\Parser\Tokenizer\TokenizerPatterns; + +/** + * CSS selector comment handler. + * + * This component is a port of the Python cssselector library, + * which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect. + * + * @author Jean-François Simon + */ +class HashHandler implements HandlerInterface +{ + /** + * @var TokenizerPatterns + */ + private $patterns; + + /** + * @var TokenizerEscaping + */ + private $escaping; + + /** + * @param TokenizerPatterns $patterns + * @param TokenizerEscaping $escaping + */ + public function __construct(TokenizerPatterns $patterns, TokenizerEscaping $escaping) + { + $this->patterns = $patterns; + $this->escaping = $escaping; + } + + /** + * {@inheritdoc} + */ + public function handle(Reader $reader, TokenStream $stream) + { + $match = $reader->findPattern($this->patterns->getHashPattern()); + + if (!$match) { + return false; + } + + $value = $this->escaping->escapeUnicode($match[1]); + $stream->push(new Token(Token::TYPE_HASH, $value, $reader->getPosition())); + $reader->moveForward(strlen($match[0])); + + return true; + } +} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/Handler/IdentifierHandler.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/Handler/IdentifierHandler.php new file mode 100755 index 0000000..346532e --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/Handler/IdentifierHandler.php @@ -0,0 +1,67 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\CssSelector\Parser\Handler; + +use Symfony\Component\CssSelector\Parser\Reader; +use Symfony\Component\CssSelector\Parser\Token; +use Symfony\Component\CssSelector\Parser\TokenStream; +use Symfony\Component\CssSelector\Parser\Tokenizer\TokenizerEscaping; +use Symfony\Component\CssSelector\Parser\Tokenizer\TokenizerPatterns; + +/** + * CSS selector comment handler. + * + * This component is a port of the Python cssselector library, + * which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect. + * + * @author Jean-François Simon + */ +class IdentifierHandler implements HandlerInterface +{ + /** + * @var TokenizerPatterns + */ + private $patterns; + + /** + * @var TokenizerEscaping + */ + private $escaping; + + /** + * @param TokenizerPatterns $patterns + * @param TokenizerEscaping $escaping + */ + public function __construct(TokenizerPatterns $patterns, TokenizerEscaping $escaping) + { + $this->patterns = $patterns; + $this->escaping = $escaping; + } + + /** + * {@inheritdoc} + */ + public function handle(Reader $reader, TokenStream $stream) + { + $match = $reader->findPattern($this->patterns->getIdentifierPattern()); + + if (!$match) { + return false; + } + + $value = $this->escaping->escapeUnicode($match[0]); + $stream->push(new Token(Token::TYPE_IDENTIFIER, $value, $reader->getPosition())); + $reader->moveForward(strlen($match[0])); + + return true; + } +} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/Handler/NumberHandler.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/Handler/NumberHandler.php new file mode 100755 index 0000000..208f83c --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/Handler/NumberHandler.php @@ -0,0 +1,58 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\CssSelector\Parser\Handler; + +use Symfony\Component\CssSelector\Parser\Reader; +use Symfony\Component\CssSelector\Parser\Token; +use Symfony\Component\CssSelector\Parser\TokenStream; +use Symfony\Component\CssSelector\Parser\Tokenizer\TokenizerPatterns; + +/** + * CSS selector comment handler. + * + * This component is a port of the Python cssselector library, + * which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect. + * + * @author Jean-François Simon + */ +class NumberHandler implements HandlerInterface +{ + /** + * @var TokenizerPatterns + */ + private $patterns; + + /** + * @param TokenizerPatterns $patterns + */ + public function __construct(TokenizerPatterns $patterns) + { + $this->patterns = $patterns; + } + + /** + * {@inheritdoc} + */ + public function handle(Reader $reader, TokenStream $stream) + { + $match = $reader->findPattern($this->patterns->getNumberPattern()); + + if (!$match) { + return false; + } + + $stream->push(new Token(Token::TYPE_NUMBER, $match[0], $reader->getPosition())); + $reader->moveForward(strlen($match[0])); + + return true; + } +} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/Handler/StringHandler.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/Handler/StringHandler.php new file mode 100755 index 0000000..2663fe8 --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/Handler/StringHandler.php @@ -0,0 +1,86 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\CssSelector\Parser\Handler; + +use Symfony\Component\CssSelector\Exception\InternalErrorException; +use Symfony\Component\CssSelector\Exception\SyntaxErrorException; +use Symfony\Component\CssSelector\Parser\Reader; +use Symfony\Component\CssSelector\Parser\Token; +use Symfony\Component\CssSelector\Parser\TokenStream; +use Symfony\Component\CssSelector\Parser\Tokenizer\TokenizerEscaping; +use Symfony\Component\CssSelector\Parser\Tokenizer\TokenizerPatterns; + +/** + * CSS selector comment handler. + * + * This component is a port of the Python cssselector library, + * which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect. + * + * @author Jean-François Simon + */ +class StringHandler implements HandlerInterface +{ + /** + * @var TokenizerPatterns + */ + private $patterns; + + /** + * @var TokenizerEscaping + */ + private $escaping; + + /** + * @param TokenizerPatterns $patterns + * @param TokenizerEscaping $escaping + */ + public function __construct(TokenizerPatterns $patterns, TokenizerEscaping $escaping) + { + $this->patterns = $patterns; + $this->escaping = $escaping; + } + + /** + * {@inheritdoc} + */ + public function handle(Reader $reader, TokenStream $stream) + { + $quote = $reader->getSubstring(1); + + if (!in_array($quote, array("'", '"'))) { + return false; + } + + $reader->moveForward(1); + $match = $reader->findPattern($this->patterns->getQuotedStringPattern($quote)); + + if (!$match) { + throw new InternalErrorException(sprintf('Should have found at least an empty match at %s.', $reader->getPosition())); + } + + // check unclosed strings + if (strlen($match[0]) === $reader->getRemainingLength()) { + throw SyntaxErrorException::unclosedString($reader->getPosition() - 1); + } + + // check quotes pairs validity + if ($quote !== $reader->getSubstring(1, strlen($match[0]))) { + throw SyntaxErrorException::unclosedString($reader->getPosition() - 1); + } + + $string = $this->escaping->escapeUnicodeAndNewLine($match[0]); + $stream->push(new Token(Token::TYPE_STRING, $string, $reader->getPosition())); + $reader->moveForward(strlen($match[0]) + 1); + + return true; + } +} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/Handler/WhitespaceHandler.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/Handler/WhitespaceHandler.php new file mode 100755 index 0000000..806cfbb --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/Handler/WhitespaceHandler.php @@ -0,0 +1,44 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\CssSelector\Parser\Handler; + +use Symfony\Component\CssSelector\Parser\Reader; +use Symfony\Component\CssSelector\Parser\Token; +use Symfony\Component\CssSelector\Parser\TokenStream; + +/** + * CSS selector whitespace handler. + * + * This component is a port of the Python cssselector library, + * which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect. + * + * @author Jean-François Simon + */ +class WhitespaceHandler implements HandlerInterface +{ + /** + * {@inheritdoc} + */ + public function handle(Reader $reader, TokenStream $stream) + { + $match = $reader->findPattern('~^[ \t\r\n\f]+~'); + + if (false === $match) { + return false; + } + + $stream->push(new Token(Token::TYPE_WHITESPACE, $match[0], $reader->getPosition())); + $reader->moveForward(strlen($match[0])); + + return true; + } +} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/Parser.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/Parser.php new file mode 100755 index 0000000..6c7c3be --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/Parser.php @@ -0,0 +1,399 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\CssSelector\Parser; + +use Symfony\Component\CssSelector\Exception\SyntaxErrorException; +use Symfony\Component\CssSelector\Node; +use Symfony\Component\CssSelector\Parser\Tokenizer\Tokenizer; + +/** + * CSS selector parser. + * + * This component is a port of the Python cssselector library, + * which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect. + * + * @author Jean-François Simon + */ +class Parser implements ParserInterface +{ + /** + * @var Tokenizer + */ + private $tokenizer; + + /** + * Constructor. + * + * @param null|Tokenizer $tokenizer + */ + public function __construct(Tokenizer $tokenizer = null) + { + $this->tokenizer = $tokenizer ?: new Tokenizer(); + } + + /** + * {@inheritdoc} + */ + public function parse($source) + { + $reader = new Reader($source); + $stream = $this->tokenizer->tokenize($reader); + + return $this->parseSelectorList($stream); + } + + /** + * Parses the arguments for ":nth-child()" and friends. + * + * @param Token[] $tokens + * + * @throws SyntaxErrorException + * + * @return array + */ + public static function parseSeries(array $tokens) + { + foreach ($tokens as $token) { + if ($token->isString()) { + throw SyntaxErrorException::stringAsFunctionArgument(); + } + } + + $joined = trim(implode('', array_map(function (Token $token) { + return $token->getValue(); + }, $tokens))); + + $int = function ($string) { + if (!is_numeric($string)) { + throw SyntaxErrorException::stringAsFunctionArgument(); + } + + return (int) $string; + }; + + switch (true) { + case 'odd' === $joined: + return array(2, 1); + case 'even' === $joined: + return array(2, 0); + case 'n' === $joined: + return array(1, 0); + case false === strpos($joined, 'n'): + return array(0, $int($joined)); + } + + $split = explode('n', $joined); + $first = isset($split[0]) ? $split[0] : null; + + return array( + $first ? ('-' === $first || '+' === $first ? $int($first.'1') : $int($first)) : 1, + isset($split[1]) && $split[1] ? $int($split[1]) : 0 + ); + } + + /** + * Parses selector nodes. + * + * @param TokenStream $stream + * + * @return array + */ + private function parseSelectorList(TokenStream $stream) + { + $stream->skipWhitespace(); + $selectors = array(); + + while (true) { + $selectors[] = $this->parserSelectorNode($stream); + + if ($stream->getPeek()->isDelimiter(array(','))) { + $stream->getNext(); + $stream->skipWhitespace(); + } else { + break; + } + } + + return $selectors; + } + + /** + * Parses next selector or combined node. + * + * @param TokenStream $stream + * + * @throws SyntaxErrorException + * + * @return Node\SelectorNode + */ + private function parserSelectorNode(TokenStream $stream) + { + list($result, $pseudoElement) = $this->parseSimpleSelector($stream); + + while (true) { + $stream->skipWhitespace(); + $peek = $stream->getPeek(); + + if ($peek->isFileEnd() || $peek->isDelimiter(array(','))) { + break; + } + + if (null !== $pseudoElement) { + throw SyntaxErrorException::pseudoElementFound($pseudoElement, 'not at the end of a selector'); + } + + if ($peek->isDelimiter(array('+', '>', '~'))) { + $combinator = $stream->getNext()->getValue(); + $stream->skipWhitespace(); + } else { + $combinator = ' '; + } + + list($nextSelector, $pseudoElement) = $this->parseSimpleSelector($stream); + $result = new Node\CombinedSelectorNode($result, $combinator, $nextSelector); + } + + return new Node\SelectorNode($result, $pseudoElement); + } + + /** + * Parses next simple node (hash, class, pseudo, negation). + * + * @param TokenStream $stream + * @param bool $insideNegation + * + * @throws SyntaxErrorException + * + * @return array + */ + private function parseSimpleSelector(TokenStream $stream, $insideNegation = false) + { + $stream->skipWhitespace(); + + $selectorStart = count($stream->getUsed()); + $result = $this->parseElementNode($stream); + $pseudoElement = null; + + while (true) { + $peek = $stream->getPeek(); + if ($peek->isWhitespace() + || $peek->isFileEnd() + || $peek->isDelimiter(array(',', '+', '>', '~')) + || ($insideNegation && $peek->isDelimiter(array(')'))) + ) { + break; + } + + if (null !== $pseudoElement) { + throw SyntaxErrorException::pseudoElementFound($pseudoElement, 'not at the end of a selector'); + } + + if ($peek->isHash()) { + $result = new Node\HashNode($result, $stream->getNext()->getValue()); + } elseif ($peek->isDelimiter(array('.'))) { + $stream->getNext(); + $result = new Node\ClassNode($result, $stream->getNextIdentifier()); + } elseif ($peek->isDelimiter(array('['))) { + $stream->getNext(); + $result = $this->parseAttributeNode($result, $stream); + } elseif ($peek->isDelimiter(array(':'))) { + $stream->getNext(); + + if ($stream->getPeek()->isDelimiter(array(':'))) { + $stream->getNext(); + $pseudoElement = $stream->getNextIdentifier(); + + continue; + } + + $identifier = $stream->getNextIdentifier(); + if (in_array(strtolower($identifier), array('first-line', 'first-letter', 'before', 'after'))) { + // Special case: CSS 2.1 pseudo-elements can have a single ':'. + // Any new pseudo-element must have two. + $pseudoElement = $identifier; + + continue; + } + + if (!$stream->getPeek()->isDelimiter(array('('))) { + $result = new Node\PseudoNode($result, $identifier); + + continue; + } + + $stream->getNext(); + $stream->skipWhitespace(); + + if ('not' === strtolower($identifier)) { + if ($insideNegation) { + throw SyntaxErrorException::nestedNot(); + } + + list($argument, $argumentPseudoElement) = $this->parseSimpleSelector($stream, true); + $next = $stream->getNext(); + + if (null !== $argumentPseudoElement) { + throw SyntaxErrorException::pseudoElementFound($argumentPseudoElement, 'inside ::not()'); + } + + if (!$next->isDelimiter(array(')'))) { + throw SyntaxErrorException::unexpectedToken('")"', $next); + } + + $result = new Node\NegationNode($result, $argument); + } else { + $arguments = array(); + $next = null; + + while (true) { + $stream->skipWhitespace(); + $next = $stream->getNext(); + + if ($next->isIdentifier() + || $next->isString() + || $next->isNumber() + || $next->isDelimiter(array('+', '-')) + ) { + $arguments[] = $next; + } elseif ($next->isDelimiter(array(')'))) { + break; + } else { + throw SyntaxErrorException::unexpectedToken('an argument', $next); + } + } + + if (empty($arguments)) { + throw SyntaxErrorException::unexpectedToken('at least one argument', $next); + } + + $result = new Node\FunctionNode($result, $identifier, $arguments); + } + } else { + throw SyntaxErrorException::unexpectedToken('selector', $peek); + } + } + + if (count($stream->getUsed()) === $selectorStart) { + throw SyntaxErrorException::unexpectedToken('selector', $stream->getPeek()); + } + + return array($result, $pseudoElement); + } + + /** + * Parses next element node. + * + * @param TokenStream $stream + * + * @return Node\ElementNode + */ + private function parseElementNode(TokenStream $stream) + { + $peek = $stream->getPeek(); + + if ($peek->isIdentifier() || $peek->isDelimiter(array('*'))) { + if ($peek->isIdentifier()) { + $namespace = $stream->getNext()->getValue(); + } else { + $stream->getNext(); + $namespace = null; + } + + if ($stream->getPeek()->isDelimiter(array('|'))) { + $stream->getNext(); + $element = $stream->getNextIdentifierOrStar(); + } else { + $element = $namespace; + $namespace = null; + } + } else { + $element = $namespace = null; + } + + return new Node\ElementNode($namespace, $element); + } + + /** + * Parses next attribute node. + * + * @param Node\NodeInterface $selector + * @param TokenStream $stream + * + * @throws SyntaxErrorException + * + * @return Node\AttributeNode + */ + private function parseAttributeNode(Node\NodeInterface $selector, TokenStream $stream) + { + $stream->skipWhitespace(); + $attribute = $stream->getNextIdentifierOrStar(); + + if (null === $attribute && !$stream->getPeek()->isDelimiter(array('|'))) { + throw SyntaxErrorException::unexpectedToken('"|"', $stream->getPeek()); + } + + if ($stream->getPeek()->isDelimiter(array('|'))) { + $stream->getNext(); + + if ($stream->getPeek()->isDelimiter(array('='))) { + $namespace = null; + $stream->getNext(); + $operator = '|='; + } else { + $namespace = $attribute; + $attribute = $stream->getNextIdentifier(); + $operator = null; + } + } else { + $namespace = $operator = null; + } + + if (null === $operator) { + $stream->skipWhitespace(); + $next = $stream->getNext(); + + if ($next->isDelimiter(array(']'))) { + return new Node\AttributeNode($selector, $namespace, $attribute, 'exists', null); + } elseif ($next->isDelimiter(array('='))) { + $operator = '='; + } elseif ($next->isDelimiter(array('^', '$', '*', '~', '|', '!')) + && $stream->getPeek()->isDelimiter(array('=')) + ) { + $operator = $next->getValue().'='; + $stream->getNext(); + } else { + throw SyntaxErrorException::unexpectedToken('operator', $next); + } + } + + $stream->skipWhitespace(); + $value = $stream->getNext(); + + if ($value->isNumber()) { + // if the value is a number, it's casted into a string + $value = new Token(Token::TYPE_STRING, (string) $value->getValue(), $value->getPosition()); + } + + if (!($value->isIdentifier() || $value->isString())) { + throw SyntaxErrorException::unexpectedToken('string or identifier', $value); + } + + $stream->skipWhitespace(); + $next = $stream->getNext(); + + if (!$next->isDelimiter(array(']'))) { + throw SyntaxErrorException::unexpectedToken('"]"', $next); + } + + return new Node\AttributeNode($selector, $namespace, $attribute, $operator, $value->getValue()); + } +} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/ParserInterface.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/ParserInterface.php new file mode 100755 index 0000000..b27f79f --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/ParserInterface.php @@ -0,0 +1,34 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\CssSelector\Parser; + +use Symfony\Component\CssSelector\Node\SelectorNode; + +/** + * CSS selector parser interface. + * + * This component is a port of the Python cssselector library, + * which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect. + * + * @author Jean-François Simon + */ +interface ParserInterface +{ + /** + * Parses given selector source into an array of tokens. + * + * @param string $source + * + * @return SelectorNode[] + */ + public function parse($source); +} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/Reader.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/Reader.php new file mode 100755 index 0000000..2a6c4bb --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/Reader.php @@ -0,0 +1,125 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\CssSelector\Parser; + +/** + * CSS selector reader. + * + * This component is a port of the Python cssselector library, + * which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect. + * + * @author Jean-François Simon + */ +class Reader +{ + /** + * @var string + */ + private $source; + + /** + * @var int + */ + private $length; + + /** + * @var int + */ + private $position = 0; + + /** + * @param string $source + */ + public function __construct($source) + { + $this->source = $source; + $this->length = strlen($source); + } + + /** + * @return bool + */ + public function isEOF() + { + return $this->position >= $this->length; + } + + /** + * @return int + */ + public function getPosition() + { + return $this->position; + } + + /** + * @return int + */ + public function getRemainingLength() + { + return $this->length - $this->position; + } + + /** + * @param int $length + * @param int $offset + * + * @return string + */ + public function getSubstring($length, $offset = 0) + { + return substr($this->source, $this->position + $offset, $length); + } + + /** + * @param string $string + * + * @return int + */ + public function getOffset($string) + { + $position = strpos($this->source, $string, $this->position); + + return false === $position ? false : $position - $this->position; + } + + /** + * @param string $pattern + * + * @return bool + */ + public function findPattern($pattern) + { + $source = substr($this->source, $this->position); + + if (preg_match($pattern, $source, $matches)) { + return $matches; + } + + return false; + } + + /** + * @param int $length + */ + public function moveForward($length) + { + $this->position += $length; + } + + /** + */ + public function moveToEnd() + { + $this->position = $this->length; + } +} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/Shortcut/ClassParser.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/Shortcut/ClassParser.php new file mode 100755 index 0000000..db35233 --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/Shortcut/ClassParser.php @@ -0,0 +1,50 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\CssSelector\Parser\Shortcut; + +use Symfony\Component\CssSelector\Node\ClassNode; +use Symfony\Component\CssSelector\Node\ElementNode; +use Symfony\Component\CssSelector\Node\SelectorNode; +use Symfony\Component\CssSelector\Parser\ParserInterface; + +/** + * CSS selector class parser shortcut. + * + * This component is a port of the Python cssselector library, + * which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect. + * + * @author Jean-François Simon + */ +class ClassParser implements ParserInterface +{ + /** + * {@inheritdoc} + */ + public function parse($source) + { + // Matches an optional namespace, optional element, and required class + // $source = 'test|input.ab6bd_field'; + // $matches = array (size=5) + // 0 => string 'test:input.ab6bd_field' (length=22) + // 1 => string 'test:' (length=5) + // 2 => string 'test' (length=4) + // 3 => string 'input' (length=5) + // 4 => string 'ab6bd_field' (length=11) + if (preg_match('/^(([a-z]+)\|)?([\w-]+|\*)?\.([\w-]+)$/i', trim($source), $matches)) { + return array( + new SelectorNode(new ClassNode(new ElementNode($matches[2] ?: null, $matches[3] ?: null), $matches[4])) + ); + } + + return array(); + } +} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/Shortcut/ElementParser.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/Shortcut/ElementParser.php new file mode 100755 index 0000000..eae18b9 --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/Shortcut/ElementParser.php @@ -0,0 +1,46 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\CssSelector\Parser\Shortcut; + +use Symfony\Component\CssSelector\Node\ElementNode; +use Symfony\Component\CssSelector\Node\SelectorNode; +use Symfony\Component\CssSelector\Parser\ParserInterface; + +/** + * CSS selector element parser shortcut. + * + * This component is a port of the Python cssselector library, + * which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect. + * + * @author Jean-François Simon + */ +class ElementParser implements ParserInterface +{ + /** + * {@inheritdoc} + */ + public function parse($source) + { + // Matches an optional namespace, required element or `*` + // $source = 'testns|testel'; + // $matches = array (size=4) + // 0 => string 'testns:testel' (length=13) + // 1 => string 'testns:' (length=7) + // 2 => string 'testns' (length=6) + // 3 => string 'testel' (length=6) + if (preg_match('/^(([a-z]+)\|)?([\w-]+|\*)$/i', trim($source), $matches)) { + return array(new SelectorNode(new ElementNode($matches[2] ?: null, $matches[3]))); + } + + return array(); + } +} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/Shortcut/EmptyStringParser.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/Shortcut/EmptyStringParser.php new file mode 100755 index 0000000..0031f7c --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/Shortcut/EmptyStringParser.php @@ -0,0 +1,44 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\CssSelector\Parser\Shortcut; + +use Symfony\Component\CssSelector\Node\ElementNode; +use Symfony\Component\CssSelector\Node\SelectorNode; +use Symfony\Component\CssSelector\Parser\ParserInterface; + +/** + * CSS selector class parser shortcut. + * + * This shortcut ensure compatibility with previous version. + * - The parser fails to parse an empty string. + * - In the previous version, an empty string matches each tags. + * + * This component is a port of the Python cssselector library, + * which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect. + * + * @author Jean-François Simon + */ +class EmptyStringParser implements ParserInterface +{ + /** + * {@inheritdoc} + */ + public function parse($source) + { + // Matches an empty string + if ($source == '') { + return array(new SelectorNode(new ElementNode(null, '*'))); + } + + return array(); + } +} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/Shortcut/HashParser.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/Shortcut/HashParser.php new file mode 100755 index 0000000..95d7d5f --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/Shortcut/HashParser.php @@ -0,0 +1,50 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\CssSelector\Parser\Shortcut; + +use Symfony\Component\CssSelector\Node\ElementNode; +use Symfony\Component\CssSelector\Node\HashNode; +use Symfony\Component\CssSelector\Node\SelectorNode; +use Symfony\Component\CssSelector\Parser\ParserInterface; + +/** + * CSS selector hash parser shortcut. + * + * This component is a port of the Python cssselector library, + * which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect. + * + * @author Jean-François Simon + */ +class HashParser implements ParserInterface +{ + /** + * {@inheritdoc} + */ + public function parse($source) + { + // Matches an optional namespace, optional element, and required id + // $source = 'test|input#ab6bd_field'; + // $matches = array (size=5) + // 0 => string 'test:input#ab6bd_field' (length=22) + // 1 => string 'test:' (length=5) + // 2 => string 'test' (length=4) + // 3 => string 'input' (length=5) + // 4 => string 'ab6bd_field' (length=11) + if (preg_match('/^(([a-z]+)\|)?([\w-]+|\*)?#([\w-]+)$/i', trim($source), $matches)) { + return array( + new SelectorNode(new HashNode(new ElementNode($matches[2] ?: null, $matches[3] ?: null), $matches[4])) + ); + } + + return array(); + } +} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/Token.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/Token.php new file mode 100755 index 0000000..4adfca8 --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/Token.php @@ -0,0 +1,160 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\CssSelector\Parser; + +/** + * CSS selector token. + * + * This component is a port of the Python cssselector library, + * which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect. + * + * @author Jean-François Simon + */ +class Token +{ + const TYPE_FILE_END = 'eof'; + const TYPE_DELIMITER = 'delimiter'; + const TYPE_WHITESPACE = 'whitespace'; + const TYPE_IDENTIFIER = 'identifier'; + const TYPE_HASH = 'hash'; + const TYPE_NUMBER = 'number'; + const TYPE_STRING = 'string'; + + /** + * @var int + */ + private $type; + + /** + * @var string + */ + private $value; + + /** + * @var int + */ + private $position; + + /** + * @param int $type + * @param string $value + * @param int $position + */ + public function __construct($type, $value, $position) + { + $this->type = $type; + $this->value = $value; + $this->position = $position; + } + + /** + * @return int + */ + public function getType() + { + return $this->type; + } + + /** + * @return string + */ + public function getValue() + { + return $this->value; + } + + /** + * @return int + */ + public function getPosition() + { + return $this->position; + } + + /** + * @return bool + */ + public function isFileEnd() + { + return self::TYPE_FILE_END === $this->type; + } + + /** + * @param array $values + * + * @return bool + */ + public function isDelimiter(array $values = array()) + { + if (self::TYPE_DELIMITER !== $this->type) { + return false; + } + + if (empty($values)) { + return true; + } + + return in_array($this->value, $values); + } + + /** + * @return bool + */ + public function isWhitespace() + { + return self::TYPE_WHITESPACE === $this->type; + } + + /** + * @return bool + */ + public function isIdentifier() + { + return self::TYPE_IDENTIFIER === $this->type; + } + + /** + * @return bool + */ + public function isHash() + { + return self::TYPE_HASH === $this->type; + } + + /** + * @return bool + */ + public function isNumber() + { + return self::TYPE_NUMBER === $this->type; + } + + /** + * @return bool + */ + public function isString() + { + return self::TYPE_STRING === $this->type; + } + + /** + * @return string + */ + public function __toString() + { + if ($this->value) { + return sprintf('<%s "%s" at %s>', $this->type, $this->value, $this->position); + } + + return sprintf('<%s at %s>', $this->type, $this->position); + } +} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/TokenStream.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/TokenStream.php new file mode 100755 index 0000000..05d715b --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/TokenStream.php @@ -0,0 +1,182 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\CssSelector\Parser; + +use Symfony\Component\CssSelector\Exception\InternalErrorException; +use Symfony\Component\CssSelector\Exception\SyntaxErrorException; + +/** + * CSS selector token stream. + * + * This component is a port of the Python cssselector library, + * which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect. + * + * @author Jean-François Simon + */ +class TokenStream +{ + /** + * @var Token[] + */ + private $tokens = array(); + + /** + * @var bool + */ + private $frozen = false; + + /** + * @var Token[] + */ + private $used = array(); + + /** + * @var int + */ + private $cursor = 0; + + /** + * @var Token|null + */ + private $peeked = null; + + /** + * @var bool + */ + private $peeking = false; + + /** + * Pushes a token. + * + * @param Token $token + * + * @return TokenStream + */ + public function push(Token $token) + { + $this->tokens[] = $token; + + return $this; + } + + /** + * Freezes stream. + * + * @return TokenStream + */ + public function freeze() + { + $this->frozen = true; + + return $this; + } + + /** + * Returns next token. + * + * @throws InternalErrorException If there is no more token + * + * @return Token + */ + public function getNext() + { + if ($this->peeking) { + $this->peeking = false; + $this->used[] = $this->peeked; + + return $this->peeked; + } + + if (!isset($this->tokens[$this->cursor])) { + throw new InternalErrorException('Unexpected token stream end.'); + } + + return $this->tokens[$this->cursor ++]; + } + + /** + * Returns peeked token. + * + * @return Token + */ + public function getPeek() + { + if (!$this->peeking) { + $this->peeked = $this->getNext(); + $this->peeking = true; + } + + return $this->peeked; + } + + /** + * Returns used tokens. + * + * @return Token[] + */ + public function getUsed() + { + return $this->used; + } + + /** + * Returns nex identifier token. + * + * @throws SyntaxErrorException If next token is not an identifier + * + * @return string The identifier token value + */ + public function getNextIdentifier() + { + $next = $this->getNext(); + + if (!$next->isIdentifier()) { + throw SyntaxErrorException::unexpectedToken('identifier', $next); + } + + return $next->getValue(); + } + + /** + * Returns nex identifier or star delimiter token. + * + * @throws SyntaxErrorException If next token is not an identifier or a star delimiter + * + * @return null|string The identifier token value or null if star found + */ + public function getNextIdentifierOrStar() + { + $next = $this->getNext(); + + if ($next->isIdentifier()) { + return $next->getValue(); + } + + if ($next->isDelimiter(array('*'))) { + return; + } + + throw SyntaxErrorException::unexpectedToken('identifier or "*"', $next); + } + + /** + * Skips next whitespace if any. + */ + public function skipWhitespace() + { + $peek = $this->getPeek(); + + if ($peek->isWhitespace()) { + $this->getNext(); + } + } +} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/Tokenizer/Tokenizer.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/Tokenizer/Tokenizer.php new file mode 100755 index 0000000..c850276 --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/Tokenizer/Tokenizer.php @@ -0,0 +1,78 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\CssSelector\Parser\Tokenizer; + +use Symfony\Component\CssSelector\Parser\Handler; +use Symfony\Component\CssSelector\Parser\Reader; +use Symfony\Component\CssSelector\Parser\Token; +use Symfony\Component\CssSelector\Parser\TokenStream; + +/** + * CSS selector tokenizer. + * + * This component is a port of the Python cssselector library, + * which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect. + * + * @author Jean-François Simon + */ +class Tokenizer +{ + /** + * @var Handler\HandlerInterface[] + */ + private $handlers; + + /** + * Constructor. + */ + public function __construct() + { + $patterns = new TokenizerPatterns(); + $escaping = new TokenizerEscaping($patterns); + + $this->handlers = array( + new Handler\WhitespaceHandler(), + new Handler\IdentifierHandler($patterns, $escaping), + new Handler\HashHandler($patterns, $escaping), + new Handler\StringHandler($patterns, $escaping), + new Handler\NumberHandler($patterns), + new Handler\CommentHandler(), + ); + } + + /** + * Tokenize selector source code. + * + * @param Reader $reader + * + * @return TokenStream + */ + public function tokenize(Reader $reader) + { + $stream = new TokenStream(); + + while (!$reader->isEOF()) { + foreach ($this->handlers as $handler) { + if ($handler->handle($reader, $stream)) { + continue 2; + } + } + + $stream->push(new Token(Token::TYPE_DELIMITER, $reader->getSubstring(1), $reader->getPosition())); + $reader->moveForward(1); + } + + return $stream + ->push(new Token(Token::TYPE_FILE_END, null, $reader->getPosition())) + ->freeze(); + } +} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/Tokenizer/TokenizerEscaping.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/Tokenizer/TokenizerEscaping.php new file mode 100755 index 0000000..921fc39 --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/Tokenizer/TokenizerEscaping.php @@ -0,0 +1,82 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\CssSelector\Parser\Tokenizer; + +/** + * CSS selector tokenizer escaping applier. + * + * This component is a port of the Python cssselector library, + * which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect. + * + * @author Jean-François Simon + */ +class TokenizerEscaping +{ + /** + * @var TokenizerPatterns + */ + private $patterns; + + /** + * @param TokenizerPatterns $patterns + */ + public function __construct(TokenizerPatterns $patterns) + { + $this->patterns = $patterns; + } + + /** + * @param string $value + * + * @return string + */ + public function escapeUnicode($value) + { + $value = $this->replaceUnicodeSequences($value); + + return preg_replace($this->patterns->getSimpleEscapePattern(), '$1', $value); + } + + /** + * @param string $value + * + * @return string + */ + public function escapeUnicodeAndNewLine($value) + { + $value = preg_replace($this->patterns->getNewLineEscapePattern(), '', $value); + + return $this->escapeUnicode($value); + } + + /** + * @param string $value + * + * @return string + */ + private function replaceUnicodeSequences($value) + { + return preg_replace_callback($this->patterns->getUnicodeEscapePattern(), function ($match) { + $c = hexdec($match[1]); + + if (0x80 > $c %= 0x200000) { + return chr($c); + } + if (0x800 > $c) { + return chr(0xC0 | $c>>6).chr(0x80 | $c & 0x3F); + } + if (0x10000 > $c) { + return chr(0xE0 | $c>>12).chr(0x80 | $c>>6 & 0x3F).chr(0x80 | $c & 0x3F); + } + }, $value); + } +} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/Tokenizer/TokenizerPatterns.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/Tokenizer/TokenizerPatterns.php new file mode 100755 index 0000000..6fc98b7 --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Parser/Tokenizer/TokenizerPatterns.php @@ -0,0 +1,160 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\CssSelector\Parser\Tokenizer; + +/** + * CSS selector tokenizer patterns builder. + * + * This component is a port of the Python cssselector library, + * which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect. + * + * @author Jean-François Simon + */ +class TokenizerPatterns +{ + /** + * @var string + */ + private $unicodeEscapePattern; + + /** + * @var string + */ + private $simpleEscapePattern; + + /** + * @var string + */ + private $newLineEscapePattern; + + /** + * @var string + */ + private $escapePattern; + + /** + * @var string + */ + private $stringEscapePattern; + + /** + * @var string + */ + private $nonAsciiPattern; + + /** + * @var string + */ + private $nmCharPattern; + + /** + * @var string + */ + private $nmStartPattern; + + /** + * @var string + */ + private $identifierPattern; + + /** + * @var string + */ + private $hashPattern; + + /** + * @var string + */ + private $numberPattern; + + /** + * @var string + */ + private $quotedStringPattern; + + /** + * Constructor. + */ + public function __construct() + { + $this->unicodeEscapePattern = '\\\\([0-9a-f]{1,6})(?:\r\n|[ \n\r\t\f])?'; + $this->simpleEscapePattern = '\\\\(.)'; + $this->newLineEscapePattern = '\\\\(?:\n|\r\n|\r|\f)'; + $this->escapePattern = $this->unicodeEscapePattern.'|\\\\[^\n\r\f0-9a-f]'; + $this->stringEscapePattern = $this->newLineEscapePattern.'|'.$this->escapePattern; + $this->nonAsciiPattern = '[^\x00-\x7F]'; + $this->nmCharPattern = '[_a-z0-9-]|'.$this->escapePattern.'|'.$this->nonAsciiPattern; + $this->nmStartPattern = '[_a-z]|'.$this->escapePattern.'|'.$this->nonAsciiPattern; + $this->identifierPattern = '(?:'.$this->nmStartPattern.')(?:'.$this->nmCharPattern.')*'; + $this->hashPattern = '#((?:'.$this->nmCharPattern.')+)'; + $this->numberPattern = '[+-]?(?:[0-9]*\.[0-9]+|[0-9]+)'; + $this->quotedStringPattern = '([^\n\r\f%s]|'.$this->stringEscapePattern.')*'; + } + + /** + * @return string + */ + public function getNewLineEscapePattern() + { + return '~^'.$this->newLineEscapePattern.'~'; + } + + /** + * @return string + */ + public function getSimpleEscapePattern() + { + return '~^'.$this->simpleEscapePattern.'~'; + } + + /** + * @return string + */ + public function getUnicodeEscapePattern() + { + return '~^'.$this->unicodeEscapePattern.'~i'; + } + + /** + * @return string + */ + public function getIdentifierPattern() + { + return '~^'.$this->identifierPattern.'~i'; + } + + /** + * @return string + */ + public function getHashPattern() + { + return '~^'.$this->hashPattern.'~i'; + } + + /** + * @return string + */ + public function getNumberPattern() + { + return '~^'.$this->numberPattern.'~'; + } + + /** + * @param string $quote + * + * @return string + */ + public function getQuotedStringPattern($quote) + { + return '~^'.sprintf($this->quotedStringPattern, $quote).'~i'; + } +} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/README.md b/vendor/symfony/css-selector/Symfony/Component/CssSelector/README.md new file mode 100755 index 0000000..623649b --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/README.md @@ -0,0 +1,44 @@ +CssSelector Component +===================== + +CssSelector converts CSS selectors to XPath expressions. + +The component only goal is to convert CSS selectors to their XPath +equivalents: + + use Symfony\Component\CssSelector\CssSelector; + + print CssSelector::toXPath('div.item > h4 > a'); + +HTML and XML are different +-------------------------- + +The `CssSelector` component comes with an `HTML` extension which is enabled by +default. If you need to use this component with `XML` documents, you have to +disable this `HTML` extension. That's because, `HTML` tag & attribute names +are always lower-cased, but case-sensitive in `XML`: + + // disable `HTML` extension: + CssSelector::disableHtmlExtension(); + + // re-enable `HTML` extension: + CssSelector::enableHtmlExtension(); + +When the `HTML` extension is enabled, tag names are lower-cased, attribute +names are lower-cased, the following extra pseudo-classes are supported: +`checked`, `link`, `disabled`, `enabled`, `selected`, `invalid`, `hover`, +`visited`, and the `lang()` function is also added. + +Resources +--------- + +This component is a port of the Python lxml library, which is copyright Infrae +and distributed under the BSD license. + +Current code is a port of https://github.com/SimonSapin/cssselect@v0.7.1 + +You can run the unit tests with the following command: + + $ cd path/to/Symfony/Component/CssSelector/ + $ composer.phar install + $ phpunit diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/CssSelectorTest.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/CssSelectorTest.php new file mode 100755 index 0000000..50daecc --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/CssSelectorTest.php @@ -0,0 +1,64 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\CssSelector\Tests; + +use Symfony\Component\CssSelector\CssSelector; + +class CssSelectorTest extends \PHPUnit_Framework_TestCase +{ + public function testCssToXPath() + { + $this->assertEquals('descendant-or-self::*', CssSelector::toXPath('')); + $this->assertEquals('descendant-or-self::h1', CssSelector::toXPath('h1')); + $this->assertEquals("descendant-or-self::h1[@id = 'foo']", CssSelector::toXPath('h1#foo')); + $this->assertEquals("descendant-or-self::h1[@class and contains(concat(' ', normalize-space(@class), ' '), ' foo ')]", CssSelector::toXPath('h1.foo')); + $this->assertEquals('descendant-or-self::foo:h1', CssSelector::toXPath('foo|h1')); + } + + /** @dataProvider getCssToXPathWithoutPrefixTestData */ + public function testCssToXPathWithoutPrefix($css, $xpath) + { + $this->assertEquals($xpath, CssSelector::toXPath($css, ''), '->parse() parses an input string and returns a node'); + } + + public function testParseExceptions() + { + try { + CssSelector::toXPath('h1:'); + $this->fail('->parse() throws an Exception if the css selector is not valid'); + } catch (\Exception $e) { + $this->assertInstanceOf('\Symfony\Component\CssSelector\Exception\ParseException', $e, '->parse() throws an Exception if the css selector is not valid'); + $this->assertEquals("Expected identifier, but found.", $e->getMessage(), '->parse() throws an Exception if the css selector is not valid'); + } + } + + public function getCssToXPathWithoutPrefixTestData() + { + return array( + array('h1', "h1"), + array('foo|h1', "foo:h1"), + array('h1, h2, h3', "h1 | h2 | h3"), + array('h1:nth-child(3n+1)', "*/*[name() = 'h1' and (position() - 1 >= 0 and (position() - 1) mod 3 = 0)]"), + array('h1 > p', "h1/p"), + array('h1#foo', "h1[@id = 'foo']"), + array('h1.foo', "h1[@class and contains(concat(' ', normalize-space(@class), ' '), ' foo ')]"), + array('h1[class*="foo bar"]', "h1[@class and contains(@class, 'foo bar')]"), + array('h1[foo|class*="foo bar"]', "h1[@foo:class and contains(@foo:class, 'foo bar')]"), + array('h1[class]', "h1[@class]"), + array('h1 .foo', "h1/descendant-or-self::*/*[@class and contains(concat(' ', normalize-space(@class), ' '), ' foo ')]"), + array('h1 #foo', "h1/descendant-or-self::*/*[@id = 'foo']"), + array('h1 [class*=foo]', "h1/descendant-or-self::*/*[@class and contains(@class, 'foo')]"), + array('div>.foo', "div/*[@class and contains(concat(' ', normalize-space(@class), ' '), ' foo ')]"), + array('div > .foo', "div/*[@class and contains(concat(' ', normalize-space(@class), ' '), ' foo ')]"), + ); + } +} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Node/AbstractNodeTest.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Node/AbstractNodeTest.php new file mode 100755 index 0000000..16a3a34 --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Node/AbstractNodeTest.php @@ -0,0 +1,32 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\CssSelector\Tests\Node; + +use Symfony\Component\CssSelector\Node\NodeInterface; + +abstract class AbstractNodeTest extends \PHPUnit_Framework_TestCase +{ + /** @dataProvider getToStringConversionTestData */ + public function testToStringConversion(NodeInterface $node, $representation) + { + $this->assertEquals($representation, (string) $node); + } + + /** @dataProvider getSpecificityValueTestData */ + public function testSpecificityValue(NodeInterface $node, $value) + { + $this->assertEquals($value, $node->getSpecificity()->getValue()); + } + + abstract public function getToStringConversionTestData(); + abstract public function getSpecificityValueTestData(); +} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Node/AttributeNodeTest.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Node/AttributeNodeTest.php new file mode 100755 index 0000000..1fd090f --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Node/AttributeNodeTest.php @@ -0,0 +1,37 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\CssSelector\Tests\Node; + +use Symfony\Component\CssSelector\Node\AttributeNode; +use Symfony\Component\CssSelector\Node\ElementNode; + +class AttributeNodeTest extends AbstractNodeTest +{ + public function getToStringConversionTestData() + { + return array( + array(new AttributeNode(new ElementNode(), null, 'attribute', 'exists', null), 'Attribute[Element[*][attribute]]'), + array(new AttributeNode(new ElementNode(), null, 'attribute', '$=', 'value'), "Attribute[Element[*][attribute $= 'value']]"), + array(new AttributeNode(new ElementNode(), 'namespace', 'attribute', '$=', 'value'), "Attribute[Element[*][namespace|attribute $= 'value']]"), + ); + } + + public function getSpecificityValueTestData() + { + return array( + array(new AttributeNode(new ElementNode(), null, 'attribute', 'exists', null), 10), + array(new AttributeNode(new ElementNode(null, 'element'), null, 'attribute', 'exists', null), 11), + array(new AttributeNode(new ElementNode(), null, 'attribute', '$=', 'value'), 10), + array(new AttributeNode(new ElementNode(), 'namespace', 'attribute', '$=', 'value'), 10), + ); + } +} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Node/ClassNodeTest.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Node/ClassNodeTest.php new file mode 100755 index 0000000..e0ab45a --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Node/ClassNodeTest.php @@ -0,0 +1,33 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\CssSelector\Tests\Node; + +use Symfony\Component\CssSelector\Node\ClassNode; +use Symfony\Component\CssSelector\Node\ElementNode; + +class ClassNodeTest extends AbstractNodeTest +{ + public function getToStringConversionTestData() + { + return array( + array(new ClassNode(new ElementNode(), 'class'), 'Class[Element[*].class]'), + ); + } + + public function getSpecificityValueTestData() + { + return array( + array(new ClassNode(new ElementNode(), 'class'), 10), + array(new ClassNode(new ElementNode(null, 'element'), 'class'), 11), + ); + } +} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Node/CombinedSelectorNodeTest.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Node/CombinedSelectorNodeTest.php new file mode 100755 index 0000000..9547298 --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Node/CombinedSelectorNodeTest.php @@ -0,0 +1,35 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\CssSelector\Tests\Node; + +use Symfony\Component\CssSelector\Node\CombinedSelectorNode; +use Symfony\Component\CssSelector\Node\ElementNode; + +class CombinedSelectorNodeTest extends AbstractNodeTest +{ + public function getToStringConversionTestData() + { + return array( + array(new CombinedSelectorNode(new ElementNode(), '>', new ElementNode()), 'CombinedSelector[Element[*] > Element[*]]'), + array(new CombinedSelectorNode(new ElementNode(), ' ', new ElementNode()), 'CombinedSelector[Element[*] Element[*]]'), + ); + } + + public function getSpecificityValueTestData() + { + return array( + array(new CombinedSelectorNode(new ElementNode(), '>', new ElementNode()), 0), + array(new CombinedSelectorNode(new ElementNode(null, 'element'), '>', new ElementNode()), 1), + array(new CombinedSelectorNode(new ElementNode(null, 'element'), '>', new ElementNode(null, 'element')), 2), + ); + } +} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Node/ElementNodeTest.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Node/ElementNodeTest.php new file mode 100755 index 0000000..1db6a59 --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Node/ElementNodeTest.php @@ -0,0 +1,35 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\CssSelector\Tests\Node; + +use Symfony\Component\CssSelector\Node\ElementNode; + +class ElementNodeTest extends AbstractNodeTest +{ + public function getToStringConversionTestData() + { + return array( + array(new ElementNode(), 'Element[*]'), + array(new ElementNode(null, 'element'), 'Element[element]'), + array(new ElementNode('namespace', 'element'), 'Element[namespace|element]'), + ); + } + + public function getSpecificityValueTestData() + { + return array( + array(new ElementNode(), 0), + array(new ElementNode(null, 'element'), 1), + array(new ElementNode('namespace', 'element'),1), + ); + } +} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Node/FunctionNodeTest.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Node/FunctionNodeTest.php new file mode 100755 index 0000000..ee3ce51 --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Node/FunctionNodeTest.php @@ -0,0 +1,47 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\CssSelector\Tests\Node; + +use Symfony\Component\CssSelector\Node\ElementNode; +use Symfony\Component\CssSelector\Node\FunctionNode; +use Symfony\Component\CssSelector\Parser\Token; + +class FunctionNodeTest extends AbstractNodeTest +{ + public function getToStringConversionTestData() + { + return array( + array(new FunctionNode(new ElementNode(), 'function'), 'Function[Element[*]:function()]'), + array(new FunctionNode(new ElementNode(), 'function', array( + new Token(Token::TYPE_IDENTIFIER, 'value', 0), + )), "Function[Element[*]:function(['value'])]"), + array(new FunctionNode(new ElementNode(), 'function', array( + new Token(Token::TYPE_STRING, 'value1', 0), + new Token(Token::TYPE_NUMBER, 'value2', 0), + )), "Function[Element[*]:function(['value1', 'value2'])]"), + ); + } + + public function getSpecificityValueTestData() + { + return array( + array(new FunctionNode(new ElementNode(), 'function'), 10), + array(new FunctionNode(new ElementNode(), 'function', array( + new Token(Token::TYPE_IDENTIFIER, 'value', 0), + )), 10), + array(new FunctionNode(new ElementNode(), 'function', array( + new Token(Token::TYPE_STRING, 'value1', 0), + new Token(Token::TYPE_NUMBER, 'value2', 0), + )), 10), + ); + } +} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Node/HashNodeTest.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Node/HashNodeTest.php new file mode 100755 index 0000000..8554b22 --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Node/HashNodeTest.php @@ -0,0 +1,33 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\CssSelector\Tests\Node; + +use Symfony\Component\CssSelector\Node\HashNode; +use Symfony\Component\CssSelector\Node\ElementNode; + +class HashNodeTest extends AbstractNodeTest +{ + public function getToStringConversionTestData() + { + return array( + array(new HashNode(new ElementNode(), 'id'), 'Hash[Element[*]#id]'), + ); + } + + public function getSpecificityValueTestData() + { + return array( + array(new HashNode(new ElementNode(), 'id'), 100), + array(new HashNode(new ElementNode(null, 'id'), 'class'), 101), + ); + } +} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Node/NegationNodeTest.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Node/NegationNodeTest.php new file mode 100755 index 0000000..edf4552 --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Node/NegationNodeTest.php @@ -0,0 +1,33 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\CssSelector\Tests\Node; + +use Symfony\Component\CssSelector\Node\ClassNode; +use Symfony\Component\CssSelector\Node\NegationNode; +use Symfony\Component\CssSelector\Node\ElementNode; + +class NegationNodeTest extends AbstractNodeTest +{ + public function getToStringConversionTestData() + { + return array( + array(new NegationNode(new ElementNode(), new ClassNode(new ElementNode(), 'class')), 'Negation[Element[*]:not(Class[Element[*].class])]'), + ); + } + + public function getSpecificityValueTestData() + { + return array( + array(new NegationNode(new ElementNode(), new ClassNode(new ElementNode(), 'class')), 10), + ); + } +} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Node/PseudoNodeTest.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Node/PseudoNodeTest.php new file mode 100755 index 0000000..bc57813 --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Node/PseudoNodeTest.php @@ -0,0 +1,32 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\CssSelector\Tests\Node; + +use Symfony\Component\CssSelector\Node\ElementNode; +use Symfony\Component\CssSelector\Node\PseudoNode; + +class PseudoNodeTest extends AbstractNodeTest +{ + public function getToStringConversionTestData() + { + return array( + array(new PseudoNode(new ElementNode(), 'pseudo'), 'Pseudo[Element[*]:pseudo]'), + ); + } + + public function getSpecificityValueTestData() + { + return array( + array(new PseudoNode(new ElementNode(), 'pseudo'), 10), + ); + } +} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Node/SelectorNodeTest.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Node/SelectorNodeTest.php new file mode 100755 index 0000000..5badf71 --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Node/SelectorNodeTest.php @@ -0,0 +1,34 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\CssSelector\Tests\Node; + +use Symfony\Component\CssSelector\Node\ElementNode; +use Symfony\Component\CssSelector\Node\SelectorNode; + +class SelectorNodeTest extends AbstractNodeTest +{ + public function getToStringConversionTestData() + { + return array( + array(new SelectorNode(new ElementNode()), 'Selector[Element[*]]'), + array(new SelectorNode(new ElementNode(), 'pseudo'), 'Selector[Element[*]::pseudo]'), + ); + } + + public function getSpecificityValueTestData() + { + return array( + array(new SelectorNode(new ElementNode()), 0), + array(new SelectorNode(new ElementNode(), 'pseudo'), 1), + ); + } +} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Node/SpecificityTest.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Node/SpecificityTest.php new file mode 100755 index 0000000..1f200cf --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Node/SpecificityTest.php @@ -0,0 +1,40 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\CssSelector\Tests\Node; + +use Symfony\Component\CssSelector\Node\Specificity; + +class SpecificityTest extends \PHPUnit_Framework_TestCase +{ + /** @dataProvider getValueTestData */ + public function testValue(Specificity $specificity, $value) + { + $this->assertEquals($value, $specificity->getValue()); + } + + /** @dataProvider getValueTestData */ + public function testPlusValue(Specificity $specificity, $value) + { + $this->assertEquals($value + 123, $specificity->plus(new Specificity(1, 2, 3))->getValue()); + } + + public function getValueTestData() + { + return array( + array(new Specificity(0, 0, 0), 0), + array(new Specificity(0, 0, 2), 2), + array(new Specificity(0, 3, 0), 30), + array(new Specificity(4, 0, 0), 400), + array(new Specificity(4, 3, 2), 432), + ); + } +} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Parser/Handler/AbstractHandlerTest.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Parser/Handler/AbstractHandlerTest.php new file mode 100755 index 0000000..a06dca0 --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Parser/Handler/AbstractHandlerTest.php @@ -0,0 +1,67 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\CssSelector\Tests\Parser\Handler; + +use Symfony\Component\CssSelector\Parser\Reader; +use Symfony\Component\CssSelector\Parser\Token; +use Symfony\Component\CssSelector\Parser\TokenStream; + +/** + * @author Jean-François Simon + */ +abstract class AbstractHandlerTest extends \PHPUnit_Framework_TestCase +{ + /** @dataProvider getHandleValueTestData */ + public function testHandleValue($value, Token $expectedToken, $remainingContent) + { + $reader = new Reader($value); + $stream = new TokenStream(); + + $this->assertTrue($this->generateHandler()->handle($reader, $stream)); + $this->assertEquals($expectedToken, $stream->getNext()); + $this->assertRemainingContent($reader, $remainingContent); + } + + /** @dataProvider getDontHandleValueTestData */ + public function testDontHandleValue($value) + { + $reader = new Reader($value); + $stream = new TokenStream(); + + $this->assertFalse($this->generateHandler()->handle($reader, $stream)); + $this->assertStreamEmpty($stream); + $this->assertRemainingContent($reader, $value); + } + + abstract public function getHandleValueTestData(); + abstract public function getDontHandleValueTestData(); + abstract protected function generateHandler(); + + protected function assertStreamEmpty(TokenStream $stream) + { + $property = new \ReflectionProperty($stream, 'tokens'); + $property->setAccessible(true); + + $this->assertEquals(array(), $property->getValue($stream)); + } + + protected function assertRemainingContent(Reader $reader, $remainingContent) + { + if ('' === $remainingContent) { + $this->assertEquals(0, $reader->getRemainingLength()); + $this->assertTrue($reader->isEOF()); + } else { + $this->assertEquals(strlen($remainingContent), $reader->getRemainingLength()); + $this->assertEquals(0, $reader->getOffset($remainingContent)); + } + } +} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Parser/Handler/CommentHandlerTest.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Parser/Handler/CommentHandlerTest.php new file mode 100755 index 0000000..3961bf7 --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Parser/Handler/CommentHandlerTest.php @@ -0,0 +1,55 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\CssSelector\Tests\Parser\Handler; + +use Symfony\Component\CssSelector\Parser\Handler\CommentHandler; +use Symfony\Component\CssSelector\Parser\Reader; +use Symfony\Component\CssSelector\Parser\Token; +use Symfony\Component\CssSelector\Parser\TokenStream; + +class CommentHandlerTest extends AbstractHandlerTest +{ + /** @dataProvider getHandleValueTestData */ + public function testHandleValue($value, Token $unusedArgument, $remainingContent) + { + $reader = new Reader($value); + $stream = new TokenStream(); + + $this->assertTrue($this->generateHandler()->handle($reader, $stream)); + // comments are ignored (not pushed as token in stream) + $this->assertStreamEmpty($stream); + $this->assertRemainingContent($reader, $remainingContent); + } + + public function getHandleValueTestData() + { + return array( + // 2nd argument only exists for inherited method compatibility + array('/* comment */', new Token(null, null, null), ''), + array('/* comment */foo', new Token(null, null, null), 'foo'), + ); + } + + public function getDontHandleValueTestData() + { + return array( + array('>'), + array('+'), + array(' '), + ); + } + + protected function generateHandler() + { + return new CommentHandler(); + } +} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Parser/Handler/HashHandlerTest.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Parser/Handler/HashHandlerTest.php new file mode 100755 index 0000000..b7fa00a --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Parser/Handler/HashHandlerTest.php @@ -0,0 +1,49 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\CssSelector\Tests\Parser\Handler; + +use Symfony\Component\CssSelector\Parser\Handler\HashHandler; +use Symfony\Component\CssSelector\Parser\Token; +use Symfony\Component\CssSelector\Parser\Tokenizer\TokenizerPatterns; +use Symfony\Component\CssSelector\Parser\Tokenizer\TokenizerEscaping; + +class HashHandlerTest extends AbstractHandlerTest +{ + public function getHandleValueTestData() + { + return array( + array('#id', new Token(Token::TYPE_HASH, 'id', 0), ''), + array('#123', new Token(Token::TYPE_HASH, '123', 0), ''), + + array('#id.class', new Token(Token::TYPE_HASH, 'id', 0), '.class'), + array('#id element', new Token(Token::TYPE_HASH, 'id', 0), ' element'), + ); + } + + public function getDontHandleValueTestData() + { + return array( + array('id'), + array('123'), + array('<'), + array('<'), + array('#'), + ); + } + + protected function generateHandler() + { + $patterns = new TokenizerPatterns(); + + return new HashHandler($patterns, new TokenizerEscaping($patterns)); + } +} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Parser/Handler/IdentifierHandlerTest.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Parser/Handler/IdentifierHandlerTest.php new file mode 100755 index 0000000..44d3574 --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Parser/Handler/IdentifierHandlerTest.php @@ -0,0 +1,49 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\CssSelector\Tests\Parser\Handler; + +use Symfony\Component\CssSelector\Parser\Handler\IdentifierHandler; +use Symfony\Component\CssSelector\Parser\Token; +use Symfony\Component\CssSelector\Parser\Tokenizer\TokenizerPatterns; +use Symfony\Component\CssSelector\Parser\Tokenizer\TokenizerEscaping; + +class IdentifierHandlerTest extends AbstractHandlerTest +{ + public function getHandleValueTestData() + { + return array( + array('foo', new Token(Token::TYPE_IDENTIFIER, 'foo', 0), ''), + array('foo|bar', new Token(Token::TYPE_IDENTIFIER, 'foo', 0), '|bar'), + array('foo.class', new Token(Token::TYPE_IDENTIFIER, 'foo', 0), '.class'), + array('foo[attr]', new Token(Token::TYPE_IDENTIFIER, 'foo', 0), '[attr]'), + array('foo bar', new Token(Token::TYPE_IDENTIFIER, 'foo', 0), ' bar'), + ); + } + + public function getDontHandleValueTestData() + { + return array( + array('>'), + array('+'), + array(' '), + array('*|foo'), + array('/* comment */'), + ); + } + + protected function generateHandler() + { + $patterns = new TokenizerPatterns(); + + return new IdentifierHandler($patterns, new TokenizerEscaping($patterns)); + } +} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Parser/Handler/NumberHandlerTest.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Parser/Handler/NumberHandlerTest.php new file mode 100755 index 0000000..675fd05 --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Parser/Handler/NumberHandlerTest.php @@ -0,0 +1,50 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\CssSelector\Tests\Parser\Handler; + +use Symfony\Component\CssSelector\Parser\Handler\NumberHandler; +use Symfony\Component\CssSelector\Parser\Token; +use Symfony\Component\CssSelector\Parser\Tokenizer\TokenizerPatterns; + +class NumberHandlerTest extends AbstractHandlerTest +{ + public function getHandleValueTestData() + { + return array( + array('12', new Token(Token::TYPE_NUMBER, '12', 0), ''), + array('12.34', new Token(Token::TYPE_NUMBER, '12.34', 0), ''), + array('+12.34', new Token(Token::TYPE_NUMBER, '+12.34', 0), ''), + array('-12.34', new Token(Token::TYPE_NUMBER, '-12.34', 0), ''), + + array('12 arg', new Token(Token::TYPE_NUMBER, '12', 0), ' arg'), + array('12]', new Token(Token::TYPE_NUMBER, '12', 0), ']'), + ); + } + + public function getDontHandleValueTestData() + { + return array( + array('hello'), + array('>'), + array('+'), + array(' '), + array('/* comment */'), + ); + } + + protected function generateHandler() + { + $patterns = new TokenizerPatterns(); + + return new NumberHandler($patterns); + } +} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Parser/Handler/StringHandlerTest.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Parser/Handler/StringHandlerTest.php new file mode 100755 index 0000000..89eff8b --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Parser/Handler/StringHandlerTest.php @@ -0,0 +1,50 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\CssSelector\Tests\Parser\Handler; + +use Symfony\Component\CssSelector\Parser\Handler\StringHandler; +use Symfony\Component\CssSelector\Parser\Token; +use Symfony\Component\CssSelector\Parser\Tokenizer\TokenizerPatterns; +use Symfony\Component\CssSelector\Parser\Tokenizer\TokenizerEscaping; + +class StringHandlerTest extends AbstractHandlerTest +{ + public function getHandleValueTestData() + { + return array( + array('"hello"', new Token(Token::TYPE_STRING, 'hello', 1), ''), + array('"1"', new Token(Token::TYPE_STRING, '1', 1), ''), + array('" "', new Token(Token::TYPE_STRING, ' ', 1), ''), + array('""', new Token(Token::TYPE_STRING, '', 1), ''), + array("'hello'", new Token(Token::TYPE_STRING, 'hello', 1), ''), + + array("'foo'bar", new Token(Token::TYPE_STRING, 'foo', 1), 'bar'), + ); + } + + public function getDontHandleValueTestData() + { + return array( + array('hello'), + array('>'), + array('1'), + array(' '), + ); + } + + protected function generateHandler() + { + $patterns = new TokenizerPatterns(); + + return new StringHandler($patterns, new TokenizerEscaping($patterns)); + } +} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Parser/Handler/WhitespaceHandlerTest.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Parser/Handler/WhitespaceHandlerTest.php new file mode 100755 index 0000000..f5f9e71 --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Parser/Handler/WhitespaceHandlerTest.php @@ -0,0 +1,44 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\CssSelector\Tests\Parser\Handler; + +use Symfony\Component\CssSelector\Parser\Handler\WhitespaceHandler; +use Symfony\Component\CssSelector\Parser\Token; + +class WhitespaceHandlerTest extends AbstractHandlerTest +{ + public function getHandleValueTestData() + { + return array( + array(' ', new Token(Token::TYPE_WHITESPACE, ' ', 0), ''), + array("\n", new Token(Token::TYPE_WHITESPACE, "\n", 0), ''), + array("\t", new Token(Token::TYPE_WHITESPACE, "\t", 0), ''), + + array(' foo', new Token(Token::TYPE_WHITESPACE, ' ', 0), 'foo'), + array(' .foo', new Token(Token::TYPE_WHITESPACE, ' ', 0), '.foo'), + ); + } + + public function getDontHandleValueTestData() + { + return array( + array('>'), + array('1'), + array('a'), + ); + } + + protected function generateHandler() + { + return new WhitespaceHandler(); + } +} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Parser/ParserTest.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Parser/ParserTest.php new file mode 100755 index 0000000..0454d9f --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Parser/ParserTest.php @@ -0,0 +1,248 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\CssSelector\Tests\Parser; + +use Symfony\Component\CssSelector\Exception\SyntaxErrorException; +use Symfony\Component\CssSelector\Node\FunctionNode; +use Symfony\Component\CssSelector\Node\SelectorNode; +use Symfony\Component\CssSelector\Parser\Parser; +use Symfony\Component\CssSelector\Parser\Token; + +class ParserTest extends \PHPUnit_Framework_TestCase +{ + /** @dataProvider getParserTestData */ + public function testParser($source, $representation) + { + $parser = new Parser(); + + $this->assertEquals($representation, array_map(function (SelectorNode $node) { + return (string) $node->getTree(); + }, $parser->parse($source))); + } + + /** @dataProvider getParserExceptionTestData */ + public function testParserException($source, $message) + { + $parser = new Parser(); + + try { + $parser->parse($source); + $this->fail('Parser should throw a SyntaxErrorException.'); + } catch (SyntaxErrorException $e) { + $this->assertEquals($message, $e->getMessage()); + } + } + + /** @dataProvider getPseudoElementsTestData */ + public function testPseudoElements($source, $element, $pseudo) + { + $parser = new Parser(); + $selectors = $parser->parse($source); + $this->assertCount(1, $selectors); + + /** @var SelectorNode $selector */ + $selector = $selectors[0]; + $this->assertEquals($element, (string) $selector->getTree()); + $this->assertEquals($pseudo, (string) $selector->getPseudoElement()); + } + + /** @dataProvider getSpecificityTestData */ + public function testSpecificity($source, $value) + { + $parser = new Parser(); + $selectors = $parser->parse($source); + $this->assertCount(1, $selectors); + + /** @var SelectorNode $selector */ + $selector = $selectors[0]; + $this->assertEquals($value, $selector->getSpecificity()->getValue()); + } + + /** @dataProvider getParseSeriesTestData */ + public function testParseSeries($series, $a, $b) + { + $parser = new Parser(); + $selectors = $parser->parse(sprintf(':nth-child(%s)', $series)); + $this->assertCount(1, $selectors); + + /** @var FunctionNode $function */ + $function = $selectors[0]->getTree(); + $this->assertEquals(array($a, $b), Parser::parseSeries($function->getArguments())); + } + + /** @dataProvider getParseSeriesExceptionTestData */ + public function testParseSeriesException($series) + { + $parser = new Parser(); + $selectors = $parser->parse(sprintf(':nth-child(%s)', $series)); + $this->assertCount(1, $selectors); + + /** @var FunctionNode $function */ + $function = $selectors[0]->getTree(); + $this->setExpectedException('Symfony\Component\CssSelector\Exception\SyntaxErrorException'); + Parser::parseSeries($function->getArguments()); + } + + public function getParserTestData() + { + return array( + array('*', array('Element[*]')), + array('*|*', array('Element[*]')), + array('*|foo', array('Element[foo]')), + array('foo|*', array('Element[foo|*]')), + array('foo|bar', array('Element[foo|bar]')), + array('#foo#bar', array('Hash[Hash[Element[*]#foo]#bar]')), + array('div>.foo', array('CombinedSelector[Element[div] > Class[Element[*].foo]]')), + array('div> .foo', array('CombinedSelector[Element[div] > Class[Element[*].foo]]')), + array('div >.foo', array('CombinedSelector[Element[div] > Class[Element[*].foo]]')), + array('div > .foo', array('CombinedSelector[Element[div] > Class[Element[*].foo]]')), + array("div \n> \t \t .foo", array('CombinedSelector[Element[div] > Class[Element[*].foo]]')), + array('td.foo,.bar', array('Class[Element[td].foo]', 'Class[Element[*].bar]')), + array('td.foo, .bar', array('Class[Element[td].foo]', 'Class[Element[*].bar]')), + array("td.foo\t\r\n\f ,\t\r\n\f .bar", array('Class[Element[td].foo]', 'Class[Element[*].bar]')), + array('td.foo,.bar', array('Class[Element[td].foo]', 'Class[Element[*].bar]')), + array('td.foo, .bar', array('Class[Element[td].foo]', 'Class[Element[*].bar]')), + array("td.foo\t\r\n\f ,\t\r\n\f .bar", array('Class[Element[td].foo]', 'Class[Element[*].bar]')), + array('div, td.foo, div.bar span', array('Element[div]', 'Class[Element[td].foo]', 'CombinedSelector[Class[Element[div].bar] Element[span]]')), + array('div > p', array('CombinedSelector[Element[div] > Element[p]]')), + array('td:first', array('Pseudo[Element[td]:first]')), + array('td :first', array('CombinedSelector[Element[td] Pseudo[Element[*]:first]]')), + array('a[name]', array('Attribute[Element[a][name]]')), + array("a[ name\t]", array('Attribute[Element[a][name]]')), + array('a [name]', array('CombinedSelector[Element[a] Attribute[Element[*][name]]]')), + array('a[rel="include"]', array("Attribute[Element[a][rel = 'include']]")), + array('a[rel = include]', array("Attribute[Element[a][rel = 'include']]")), + array("a[hreflang |= 'en']", array("Attribute[Element[a][hreflang |= 'en']]")), + array('a[hreflang|=en]', array("Attribute[Element[a][hreflang |= 'en']]")), + array('div:nth-child(10)', array("Function[Element[div]:nth-child(['10'])]")), + array(':nth-child(2n+2)', array("Function[Element[*]:nth-child(['2', 'n', '+2'])]")), + array('div:nth-of-type(10)', array("Function[Element[div]:nth-of-type(['10'])]")), + array('div div:nth-of-type(10) .aclass', array("CombinedSelector[CombinedSelector[Element[div] Function[Element[div]:nth-of-type(['10'])]] Class[Element[*].aclass]]")), + array('label:only', array('Pseudo[Element[label]:only]')), + array('a:lang(fr)', array("Function[Element[a]:lang(['fr'])]")), + array('div:contains("foo")', array("Function[Element[div]:contains(['foo'])]")), + array('div#foobar', array('Hash[Element[div]#foobar]')), + array('div:not(div.foo)', array('Negation[Element[div]:not(Class[Element[div].foo])]')), + array('td ~ th', array('CombinedSelector[Element[td] ~ Element[th]]')), + array('.foo[data-bar][data-baz=0]', array("Attribute[Attribute[Class[Element[*].foo][data-bar]][data-baz = '0']]")), + ); + } + + public function getParserExceptionTestData() + { + return array( + array('attributes(href)/html/body/a', SyntaxErrorException::unexpectedToken('selector', new Token(Token::TYPE_DELIMITER, '(', 10))->getMessage()), + array('attributes(href)', SyntaxErrorException::unexpectedToken('selector', new Token(Token::TYPE_DELIMITER, '(', 10))->getMessage()), + array('html/body/a', SyntaxErrorException::unexpectedToken('selector', new Token(Token::TYPE_DELIMITER, '/', 4))->getMessage()), + array(' ', SyntaxErrorException::unexpectedToken('selector', new Token(Token::TYPE_FILE_END, '', 1))->getMessage()), + array('div, ', SyntaxErrorException::unexpectedToken('selector', new Token(Token::TYPE_FILE_END, '', 5))->getMessage()), + array(' , div', SyntaxErrorException::unexpectedToken('selector', new Token(Token::TYPE_DELIMITER, ',', 1))->getMessage()), + array('p, , div', SyntaxErrorException::unexpectedToken('selector', new Token(Token::TYPE_DELIMITER, ',', 3))->getMessage()), + array('div > ', SyntaxErrorException::unexpectedToken('selector', new Token(Token::TYPE_FILE_END, '', 6))->getMessage()), + array(' > div', SyntaxErrorException::unexpectedToken('selector', new Token(Token::TYPE_DELIMITER, '>', 2))->getMessage()), + array('foo|#bar', SyntaxErrorException::unexpectedToken('identifier or "*"', new Token(Token::TYPE_HASH, 'bar', 4))->getMessage()), + array('#.foo', SyntaxErrorException::unexpectedToken('selector', new Token(Token::TYPE_DELIMITER, '#', 0))->getMessage()), + array('.#foo', SyntaxErrorException::unexpectedToken('identifier', new Token(Token::TYPE_HASH, 'foo', 1))->getMessage()), + array(':#foo', SyntaxErrorException::unexpectedToken('identifier', new Token(Token::TYPE_HASH, 'foo', 1))->getMessage()), + array('[*]', SyntaxErrorException::unexpectedToken('"|"', new Token(Token::TYPE_DELIMITER, ']', 2))->getMessage()), + array('[foo|]', SyntaxErrorException::unexpectedToken('identifier', new Token(Token::TYPE_DELIMITER, ']', 5))->getMessage()), + array('[#]', SyntaxErrorException::unexpectedToken('identifier or "*"', new Token(Token::TYPE_DELIMITER, '#', 1))->getMessage()), + array('[foo=#]', SyntaxErrorException::unexpectedToken('string or identifier', new Token(Token::TYPE_DELIMITER, '#', 5))->getMessage()), + array(':nth-child()', SyntaxErrorException::unexpectedToken('at least one argument', new Token(Token::TYPE_DELIMITER, ')', 11))->getMessage()), + array('[href]a', SyntaxErrorException::unexpectedToken('selector', new Token(Token::TYPE_IDENTIFIER, 'a', 6))->getMessage()), + array('[rel:stylesheet]', SyntaxErrorException::unexpectedToken('operator', new Token(Token::TYPE_DELIMITER, ':', 4))->getMessage()), + array('[rel=stylesheet', SyntaxErrorException::unexpectedToken('"]"', new Token(Token::TYPE_FILE_END, '', 15))->getMessage()), + array(':lang(fr', SyntaxErrorException::unexpectedToken('an argument', new Token(Token::TYPE_FILE_END, '', 8))->getMessage()), + array(':contains("foo', SyntaxErrorException::unclosedString(10)->getMessage()), + array('foo!', SyntaxErrorException::unexpectedToken('selector', new Token(Token::TYPE_DELIMITER, '!', 3))->getMessage()), + ); + } + + public function getPseudoElementsTestData() + { + return array( + array('foo', 'Element[foo]', ''), + array('*', 'Element[*]', ''), + array(':empty', 'Pseudo[Element[*]:empty]', ''), + array(':BEfore', 'Element[*]', 'before'), + array(':aftER', 'Element[*]', 'after'), + array(':First-Line', 'Element[*]', 'first-line'), + array(':First-Letter', 'Element[*]', 'first-letter'), + array('::befoRE', 'Element[*]', 'before'), + array('::AFter', 'Element[*]', 'after'), + array('::firsT-linE', 'Element[*]', 'first-line'), + array('::firsT-letteR', 'Element[*]', 'first-letter'), + array('::Selection', 'Element[*]', 'selection'), + array('foo:after', 'Element[foo]', 'after'), + array('foo::selection', 'Element[foo]', 'selection'), + array('lorem#ipsum ~ a#b.c[href]:empty::selection', 'CombinedSelector[Hash[Element[lorem]#ipsum] ~ Pseudo[Attribute[Class[Hash[Element[a]#b].c][href]]:empty]]', 'selection'), + ); + } + + public function getSpecificityTestData() + { + return array( + array('*', 0), + array(' foo', 1), + array(':empty ', 10), + array(':before', 1), + array('*:before', 1), + array(':nth-child(2)', 10), + array('.bar', 10), + array('[baz]', 10), + array('[baz="4"]', 10), + array('[baz^="4"]', 10), + array('#lipsum', 100), + array(':not(*)', 0), + array(':not(foo)', 1), + array(':not(.foo)', 10), + array(':not([foo])', 10), + array(':not(:empty)', 10), + array(':not(#foo)', 100), + array('foo:empty', 11), + array('foo:before', 2), + array('foo::before', 2), + array('foo:empty::before', 12), + array('#lorem + foo#ipsum:first-child > bar:first-line', 213), + ); + } + + public function getParseSeriesTestData() + { + return array( + array('1n+3', 1, 3), + array('1n +3', 1, 3), + array('1n + 3', 1, 3), + array('1n+ 3', 1, 3), + array('1n-3', 1, -3), + array('1n -3', 1, -3), + array('1n - 3', 1, -3), + array('1n- 3', 1, -3), + array('n-5', 1, -5), + array('odd', 2, 1), + array('even', 2, 0), + array('3n', 3, 0), + array('n', 1, 0), + array('+n', 1, 0), + array('-n', -1, 0), + array('5', 0, 5), + ); + } + + public function getParseSeriesExceptionTestData() + { + return array( + array('foo'), + array('n+'), + ); + } +} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Parser/ReaderTest.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Parser/ReaderTest.php new file mode 100755 index 0000000..03c054e --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Parser/ReaderTest.php @@ -0,0 +1,101 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\CssSelector\Tests\Parser; + +use Symfony\Component\CssSelector\Parser\Reader; + +class ReaderTest extends \PHPUnit_Framework_TestCase +{ + public function testIsEOF() + { + $reader = new Reader(''); + $this->assertTrue($reader->isEOF()); + + $reader = new Reader('hello'); + $this->assertFalse($reader->isEOF()); + + $this->assignPosition($reader, 2); + $this->assertFalse($reader->isEOF()); + + $this->assignPosition($reader, 5); + $this->assertTrue($reader->isEOF()); + } + + public function testGetRemainingLength() + { + $reader = new Reader('hello'); + $this->assertEquals(5, $reader->getRemainingLength()); + + $this->assignPosition($reader, 2); + $this->assertEquals(3, $reader->getRemainingLength()); + + $this->assignPosition($reader, 5); + $this->assertEquals(0, $reader->getRemainingLength()); + } + + public function testGetSubstring() + { + $reader = new Reader('hello'); + $this->assertEquals('he', $reader->getSubstring(2)); + $this->assertEquals('el', $reader->getSubstring(2, 1)); + + $this->assignPosition($reader, 2); + $this->assertEquals('ll', $reader->getSubstring(2)); + $this->assertEquals('lo', $reader->getSubstring(2, 1)); + } + + public function testGetOffset() + { + $reader = new Reader('hello'); + $this->assertEquals(2, $reader->getOffset('ll')); + $this->assertFalse($reader->getOffset('w')); + + $this->assignPosition($reader, 2); + $this->assertEquals(0, $reader->getOffset('ll')); + $this->assertFalse($reader->getOffset('he')); + } + + public function testFindPattern() + { + $reader = new Reader('hello'); + + $this->assertFalse($reader->findPattern('/world/')); + $this->assertEquals(array('hello', 'h'), $reader->findPattern('/^([a-z]).*/')); + + $this->assignPosition($reader, 2); + $this->assertFalse($reader->findPattern('/^h.*/')); + $this->assertEquals(array('llo'), $reader->findPattern('/^llo$/')); + } + + public function testMoveForward() + { + $reader = new Reader('hello'); + $this->assertEquals(0, $reader->getPosition()); + + $reader->moveForward(2); + $this->assertEquals(2, $reader->getPosition()); + } + + public function testToEnd() + { + $reader = new Reader('hello'); + $reader->moveToEnd(); + $this->assertTrue($reader->isEOF()); + } + + private function assignPosition(Reader $reader, $value) + { + $position = new \ReflectionProperty($reader, 'position'); + $position->setAccessible(true); + $position->setValue($reader, $value); + } +} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Parser/Shortcut/ClassParserTest.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Parser/Shortcut/ClassParserTest.php new file mode 100755 index 0000000..6efdd67 --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Parser/Shortcut/ClassParserTest.php @@ -0,0 +1,44 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\CssSelector\Tests\Parser\Shortcut; + +use Symfony\Component\CssSelector\Node\SelectorNode; +use Symfony\Component\CssSelector\Parser\Shortcut\ClassParser; + +/** + * @author Jean-François Simon + */ +class ClassParserTest extends \PHPUnit_Framework_TestCase +{ + /** @dataProvider getParseTestData */ + public function testParse($source, $representation) + { + $parser = new ClassParser(); + $selectors = $parser->parse($source); + $this->assertCount(1, $selectors); + + /** @var SelectorNode $selector */ + $selector = $selectors[0]; + $this->assertEquals($representation, (string) $selector->getTree()); + } + + public function getParseTestData() + { + return array( + array('.testclass', 'Class[Element[*].testclass]'), + array('testel.testclass', 'Class[Element[testel].testclass]'), + array('testns|.testclass', 'Class[Element[testns|*].testclass]'), + array('testns|*.testclass', 'Class[Element[testns|*].testclass]'), + array('testns|testel.testclass', 'Class[Element[testns|testel].testclass]'), + ); + } +} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Parser/Shortcut/ElementParserTest.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Parser/Shortcut/ElementParserTest.php new file mode 100755 index 0000000..b30b5ee --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Parser/Shortcut/ElementParserTest.php @@ -0,0 +1,43 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\CssSelector\Tests\Parser\Shortcut; + +use Symfony\Component\CssSelector\Node\SelectorNode; +use Symfony\Component\CssSelector\Parser\Shortcut\ElementParser; + +/** + * @author Jean-François Simon + */ +class ElementParserTest extends \PHPUnit_Framework_TestCase +{ + /** @dataProvider getParseTestData */ + public function testParse($source, $representation) + { + $parser = new ElementParser(); + $selectors = $parser->parse($source); + $this->assertCount(1, $selectors); + + /** @var SelectorNode $selector */ + $selector = $selectors[0]; + $this->assertEquals($representation, (string) $selector->getTree()); + } + + public function getParseTestData() + { + return array( + array('*', 'Element[*]'), + array('testel', 'Element[testel]'), + array('testns|*', 'Element[testns|*]'), + array('testns|testel', 'Element[testns|testel]'), + ); + } +} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Parser/Shortcut/EmptyStringParserTest.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Parser/Shortcut/EmptyStringParserTest.php new file mode 100755 index 0000000..b7c3539 --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Parser/Shortcut/EmptyStringParserTest.php @@ -0,0 +1,35 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\CssSelector\Tests\Parser\Shortcut; + +use Symfony\Component\CssSelector\Node\SelectorNode; +use Symfony\Component\CssSelector\Parser\Shortcut\EmptyStringParser; + +/** + * @author Jean-François Simon + */ +class EmptyStringParserTest extends \PHPUnit_Framework_TestCase +{ + public function testParse() + { + $parser = new EmptyStringParser(); + $selectors = $parser->parse(''); + $this->assertCount(1, $selectors); + + /** @var SelectorNode $selector */ + $selector = $selectors[0]; + $this->assertEquals('Element[*]', (string) $selector->getTree()); + + $selectors = $parser->parse('this will produce an empty array'); + $this->assertCount(0, $selectors); + } +} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Parser/Shortcut/HashParserTest.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Parser/Shortcut/HashParserTest.php new file mode 100755 index 0000000..d2ce891 --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Parser/Shortcut/HashParserTest.php @@ -0,0 +1,44 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\CssSelector\Tests\Parser\Shortcut; + +use Symfony\Component\CssSelector\Node\SelectorNode; +use Symfony\Component\CssSelector\Parser\Shortcut\HashParser; + +/** + * @author Jean-François Simon + */ +class HashParserTest extends \PHPUnit_Framework_TestCase +{ + /** @dataProvider getParseTestData */ + public function testParse($source, $representation) + { + $parser = new HashParser(); + $selectors = $parser->parse($source); + $this->assertCount(1, $selectors); + + /** @var SelectorNode $selector */ + $selector = $selectors[0]; + $this->assertEquals($representation, (string) $selector->getTree()); + } + + public function getParseTestData() + { + return array( + array('#testid', 'Hash[Element[*]#testid]'), + array('testel#testid', 'Hash[Element[testel]#testid]'), + array('testns|#testid', 'Hash[Element[testns|*]#testid]'), + array('testns|*#testid', 'Hash[Element[testns|*]#testid]'), + array('testns|testel#testid', 'Hash[Element[testns|testel]#testid]'), + ); + } +} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Parser/TokenStreamTest.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Parser/TokenStreamTest.php new file mode 100755 index 0000000..8f3253a --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/Parser/TokenStreamTest.php @@ -0,0 +1,95 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\CssSelector\Tests\Parser; + +use Symfony\Component\CssSelector\Parser\Token; +use Symfony\Component\CssSelector\Parser\TokenStream; + +class TokenStreamTest extends \PHPUnit_Framework_TestCase +{ + public function testGetNext() + { + $stream = new TokenStream(); + $stream->push($t1 = new Token(Token::TYPE_IDENTIFIER, 'h1', 0)); + $stream->push($t2 = new Token(Token::TYPE_DELIMITER, '.', 2)); + $stream->push($t3 = new Token(Token::TYPE_IDENTIFIER, 'title', 3)); + + $this->assertSame($t1, $stream->getNext()); + $this->assertSame($t2, $stream->getNext()); + $this->assertSame($t3, $stream->getNext()); + } + + public function testGetPeek() + { + $stream = new TokenStream(); + $stream->push($t1 = new Token(Token::TYPE_IDENTIFIER, 'h1', 0)); + $stream->push($t2 = new Token(Token::TYPE_DELIMITER, '.', 2)); + $stream->push($t3 = new Token(Token::TYPE_IDENTIFIER, 'title', 3)); + + $this->assertSame($t1, $stream->getPeek()); + $this->assertSame($t1, $stream->getNext()); + $this->assertSame($t2, $stream->getPeek()); + $this->assertSame($t2, $stream->getPeek()); + $this->assertSame($t2, $stream->getNext()); + } + + public function testGetNextIdentifier() + { + $stream = new TokenStream(); + $stream->push(new Token(Token::TYPE_IDENTIFIER, 'h1', 0)); + + $this->assertEquals('h1', $stream->getNextIdentifier()); + } + + public function testFailToGetNextIdentifier() + { + $this->setExpectedException('Symfony\Component\CssSelector\Exception\SyntaxErrorException'); + + $stream = new TokenStream(); + $stream->push(new Token(Token::TYPE_DELIMITER, '.', 2)); + $stream->getNextIdentifier(); + } + + public function testGetNextIdentifierOrStar() + { + $stream = new TokenStream(); + + $stream->push(new Token(Token::TYPE_IDENTIFIER, 'h1', 0)); + $this->assertEquals('h1', $stream->getNextIdentifierOrStar()); + + $stream->push(new Token(Token::TYPE_DELIMITER, '*', 0)); + $this->assertNull($stream->getNextIdentifierOrStar()); + } + + public function testFailToGetNextIdentifierOrStar() + { + $this->setExpectedException('Symfony\Component\CssSelector\Exception\SyntaxErrorException'); + + $stream = new TokenStream(); + $stream->push(new Token(Token::TYPE_DELIMITER, '.', 2)); + $stream->getNextIdentifierOrStar(); + } + + public function testSkipWhitespace() + { + $stream = new TokenStream(); + $stream->push($t1 = new Token(Token::TYPE_IDENTIFIER, 'h1', 0)); + $stream->push($t2 = new Token(Token::TYPE_WHITESPACE, ' ', 2)); + $stream->push($t3 = new Token(Token::TYPE_IDENTIFIER, 'h1', 3)); + + $stream->skipWhitespace(); + $this->assertSame($t1, $stream->getNext()); + + $stream->skipWhitespace(); + $this->assertSame($t3, $stream->getNext()); + } +} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/XPath/Fixtures/ids.html b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/XPath/Fixtures/ids.html new file mode 100755 index 0000000..5799fad --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/XPath/Fixtures/ids.html @@ -0,0 +1,48 @@ + + + + +
    + + + + link +
      +
    1. content
    2. +
    3. +
      +
      +
    4. +
    5. +
    6. +
    7. +
    8. +
    9. +
    +

    + hi there + guy + + + + + + + +

    + + +
    +

    +
      +
    + + + + +
    +
    + diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/XPath/Fixtures/lang.xml b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/XPath/Fixtures/lang.xml new file mode 100755 index 0000000..14f8dbe --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/XPath/Fixtures/lang.xml @@ -0,0 +1,11 @@ + + a + b + c + d + e + f + + + + diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/XPath/Fixtures/shakespear.html b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/XPath/Fixtures/shakespear.html new file mode 100755 index 0000000..15d1ad3 --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/XPath/Fixtures/shakespear.html @@ -0,0 +1,308 @@ + + + + + + +
    +
    +

    As You Like It

    +
    + by William Shakespeare +
    +
    +

    ACT I, SCENE III. A room in the palace.

    +
    +
    Enter CELIA and ROSALIND
    +
    +
    CELIA
    +
    +
    Why, cousin! why, Rosalind! Cupid have mercy! not a word?
    +
    +
    ROSALIND
    +
    +
    Not one to throw at a dog.
    +
    +
    CELIA
    +
    +
    No, thy words are too precious to be cast away upon
    +
    curs; throw some of them at me; come, lame me with reasons.
    +
    +
    ROSALIND
    +
    CELIA
    +
    +
    But is all this for your father?
    +
    +
    +
    Then there were two cousins laid up; when the one
    +
    should be lamed with reasons and the other mad
    +
    without any.
    +
    +
    ROSALIND
    +
    +
    No, some of it is for my child's father. O, how
    +
    full of briers is this working-day world!
    +
    +
    CELIA
    +
    +
    They are but burs, cousin, thrown upon thee in
    +
    holiday foolery: if we walk not in the trodden
    +
    paths our very petticoats will catch them.
    +
    +
    ROSALIND
    +
    +
    I could shake them off my coat: these burs are in my heart.
    +
    +
    CELIA
    +
    +
    Hem them away.
    +
    +
    ROSALIND
    +
    +
    I would try, if I could cry 'hem' and have him.
    +
    +
    CELIA
    +
    +
    Come, come, wrestle with thy affections.
    +
    +
    ROSALIND
    +
    +
    O, they take the part of a better wrestler than myself!
    +
    +
    CELIA
    +
    +
    O, a good wish upon you! you will try in time, in
    +
    despite of a fall. But, turning these jests out of
    +
    service, let us talk in good earnest: is it
    +
    possible, on such a sudden, you should fall into so
    +
    strong a liking with old Sir Rowland's youngest son?
    +
    +
    ROSALIND
    +
    +
    The duke my father loved his father dearly.
    +
    +
    CELIA
    +
    +
    Doth it therefore ensue that you should love his son
    +
    dearly? By this kind of chase, I should hate him,
    +
    for my father hated his father dearly; yet I hate
    +
    not Orlando.
    +
    +
    ROSALIND
    +
    +
    No, faith, hate him not, for my sake.
    +
    +
    CELIA
    +
    +
    Why should I not? doth he not deserve well?
    +
    +
    ROSALIND
    +
    +
    Let me love him for that, and do you love him
    +
    because I do. Look, here comes the duke.
    +
    +
    CELIA
    +
    +
    With his eyes full of anger.
    +
    Enter DUKE FREDERICK, with Lords
    +
    +
    DUKE FREDERICK
    +
    +
    Mistress, dispatch you with your safest haste
    +
    And get you from our court.
    +
    +
    ROSALIND
    +
    +
    Me, uncle?
    +
    +
    DUKE FREDERICK
    +
    +
    You, cousin
    +
    Within these ten days if that thou be'st found
    +
    So near our public court as twenty miles,
    +
    Thou diest for it.
    +
    +
    ROSALIND
    +
    +
    I do beseech your grace,
    +
    Let me the knowledge of my fault bear with me:
    +
    If with myself I hold intelligence
    +
    Or have acquaintance with mine own desires,
    +
    If that I do not dream or be not frantic,--
    +
    As I do trust I am not--then, dear uncle,
    +
    Never so much as in a thought unborn
    +
    Did I offend your highness.
    +
    +
    DUKE FREDERICK
    +
    +
    Thus do all traitors:
    +
    If their purgation did consist in words,
    +
    They are as innocent as grace itself:
    +
    Let it suffice thee that I trust thee not.
    +
    +
    ROSALIND
    +
    +
    Yet your mistrust cannot make me a traitor:
    +
    Tell me whereon the likelihood depends.
    +
    +
    DUKE FREDERICK
    +
    +
    Thou art thy father's daughter; there's enough.
    +
    +
    ROSALIND
    +
    +
    So was I when your highness took his dukedom;
    +
    So was I when your highness banish'd him:
    +
    Treason is not inherited, my lord;
    +
    Or, if we did derive it from our friends,
    +
    What's that to me? my father was no traitor:
    +
    Then, good my liege, mistake me not so much
    +
    To think my poverty is treacherous.
    +
    +
    CELIA
    +
    +
    Dear sovereign, hear me speak.
    +
    +
    DUKE FREDERICK
    +
    +
    Ay, Celia; we stay'd her for your sake,
    +
    Else had she with her father ranged along.
    +
    +
    CELIA
    +
    +
    I did not then entreat to have her stay;
    +
    It was your pleasure and your own remorse:
    +
    I was too young that time to value her;
    +
    But now I know her: if she be a traitor,
    +
    Why so am I; we still have slept together,
    +
    Rose at an instant, learn'd, play'd, eat together,
    +
    And wheresoever we went, like Juno's swans,
    +
    Still we went coupled and inseparable.
    +
    +
    DUKE FREDERICK
    +
    +
    She is too subtle for thee; and her smoothness,
    +
    Her very silence and her patience
    +
    Speak to the people, and they pity her.
    +
    Thou art a fool: she robs thee of thy name;
    +
    And thou wilt show more bright and seem more virtuous
    +
    When she is gone. Then open not thy lips:
    +
    Firm and irrevocable is my doom
    +
    Which I have pass'd upon her; she is banish'd.
    +
    +
    CELIA
    +
    +
    Pronounce that sentence then on me, my liege:
    +
    I cannot live out of her company.
    +
    +
    DUKE FREDERICK
    +
    +
    You are a fool. You, niece, provide yourself:
    +
    If you outstay the time, upon mine honour,
    +
    And in the greatness of my word, you die.
    +
    Exeunt DUKE FREDERICK and Lords
    +
    +
    CELIA
    +
    +
    O my poor Rosalind, whither wilt thou go?
    +
    Wilt thou change fathers? I will give thee mine.
    +
    I charge thee, be not thou more grieved than I am.
    +
    +
    ROSALIND
    +
    +
    I have more cause.
    +
    +
    CELIA
    +
    +
    Thou hast not, cousin;
    +
    Prithee be cheerful: know'st thou not, the duke
    +
    Hath banish'd me, his daughter?
    +
    +
    ROSALIND
    +
    +
    That he hath not.
    +
    +
    CELIA
    +
    +
    No, hath not? Rosalind lacks then the love
    +
    Which teacheth thee that thou and I am one:
    +
    Shall we be sunder'd? shall we part, sweet girl?
    +
    No: let my father seek another heir.
    +
    Therefore devise with me how we may fly,
    +
    Whither to go and what to bear with us;
    +
    And do not seek to take your change upon you,
    +
    To bear your griefs yourself and leave me out;
    +
    For, by this heaven, now at our sorrows pale,
    +
    Say what thou canst, I'll go along with thee.
    +
    +
    ROSALIND
    +
    +
    Why, whither shall we go?
    +
    +
    CELIA
    +
    +
    To seek my uncle in the forest of Arden.
    +
    +
    ROSALIND
    +
    +
    Alas, what danger will it be to us,
    +
    Maids as we are, to travel forth so far!
    +
    Beauty provoketh thieves sooner than gold.
    +
    +
    CELIA
    +
    +
    I'll put myself in poor and mean attire
    +
    And with a kind of umber smirch my face;
    +
    The like do you: so shall we pass along
    +
    And never stir assailants.
    +
    +
    ROSALIND
    +
    +
    Were it not better,
    +
    Because that I am more than common tall,
    +
    That I did suit me all points like a man?
    +
    A gallant curtle-axe upon my thigh,
    +
    A boar-spear in my hand; and--in my heart
    +
    Lie there what hidden woman's fear there will--
    +
    We'll have a swashing and a martial outside,
    +
    As many other mannish cowards have
    +
    That do outface it with their semblances.
    +
    +
    CELIA
    +
    +
    What shall I call thee when thou art a man?
    +
    +
    ROSALIND
    +
    +
    I'll have no worse a name than Jove's own page;
    +
    And therefore look you call me Ganymede.
    +
    But what will you be call'd?
    +
    +
    CELIA
    +
    +
    Something that hath a reference to my state
    +
    No longer Celia, but Aliena.
    +
    +
    ROSALIND
    +
    +
    But, cousin, what if we assay'd to steal
    +
    The clownish fool out of your father's court?
    +
    Would he not be a comfort to our travel?
    +
    +
    CELIA
    +
    +
    He'll go along o'er the wide world with me;
    +
    Leave me alone to woo him. Let's away,
    +
    And get our jewels and our wealth together,
    +
    Devise the fittest time and safest way
    +
    To hide us from pursuit that will be made
    +
    After my flight. Now go we in content
    +
    To liberty and not to banishment.
    +
    Exeunt
    +
    +
    +
    +
    + + diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/XPath/TranslatorTest.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/XPath/TranslatorTest.php new file mode 100755 index 0000000..30f7189 --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/Tests/XPath/TranslatorTest.php @@ -0,0 +1,324 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\CssSelector\Tests\XPath; + +use Symfony\Component\CssSelector\XPath\Extension\HtmlExtension; +use Symfony\Component\CssSelector\XPath\Translator; + +class TranslatorTest extends \PHPUnit_Framework_TestCase +{ + /** @dataProvider getXpathLiteralTestData */ + public function testXpathLiteral($value, $literal) + { + $this->assertEquals($literal, Translator::getXpathLiteral($value)); + } + + /** @dataProvider getCssToXPathTestData */ + public function testCssToXPath($css, $xpath) + { + $translator = new Translator(); + $translator->registerExtension(new HtmlExtension($translator)); + $this->assertEquals($xpath, $translator->cssToXPath($css, '')); + } + + /** @dataProvider getXmlLangTestData */ + public function testXmlLang($css, array $elementsId) + { + $translator = new Translator(); + $document = new \SimpleXMLElement(file_get_contents(__DIR__.'/Fixtures/lang.xml')); + $elements = $document->xpath($translator->cssToXPath($css)); + $this->assertEquals(count($elementsId), count($elements)); + foreach ($elements as $element) { + $this->assertTrue(in_array($element->attributes()->id, $elementsId)); + } + } + + /** @dataProvider getHtmlIdsTestData */ + public function testHtmlIds($css, array $elementsId) + { + $translator = new Translator(); + $translator->registerExtension(new HtmlExtension($translator)); + $document = new \DOMDocument(); + $document->strictErrorChecking = false; + $internalErrors = libxml_use_internal_errors(true); + $document->loadHTMLFile(__DIR__.'/Fixtures/ids.html'); + $document = simplexml_import_dom($document); + $elements = $document->xpath($translator->cssToXPath($css)); + $this->assertCount(count($elementsId), $elementsId); + foreach ($elements as $element) { + if (null !== $element->attributes()->id) { + $this->assertTrue(in_array($element->attributes()->id, $elementsId)); + } + } + libxml_clear_errors(); + libxml_use_internal_errors($internalErrors); + } + + /** @dataProvider getHtmlShakespearTestData */ + public function testHtmlShakespear($css, $count) + { + $translator = new Translator(); + $translator->registerExtension(new HtmlExtension($translator)); + $document = new \DOMDocument(); + $document->strictErrorChecking = false; + $document->loadHTMLFile(__DIR__.'/Fixtures/shakespear.html'); + $document = simplexml_import_dom($document); + $bodies = $document->xpath('//body'); + $elements = $bodies[0]->xpath($translator->cssToXPath($css)); + $this->assertEquals($count, count($elements)); + } + + public function getXpathLiteralTestData() + { + return array( + array('foo', "'foo'"), + array("foo's bar", '"foo\'s bar"'), + array("foo's \"middle\" bar", 'concat(\'foo\', "\'", \'s "middle" bar\')'), + array("foo's 'middle' \"bar\"", 'concat(\'foo\', "\'", \'s \', "\'", \'middle\', "\'", \' "bar"\')'), + ); + } + + public function getCssToXPathTestData() + { + return array( + array('*', "*"), + array('e', "e"), + array('*|e', "e"), + array('e|f', "e:f"), + array('e[foo]', "e[@foo]"), + array('e[foo|bar]', "e[@foo:bar]"), + array('e[foo="bar"]', "e[@foo = 'bar']"), + array('e[foo~="bar"]', "e[@foo and contains(concat(' ', normalize-space(@foo), ' '), ' bar ')]"), + array('e[foo^="bar"]', "e[@foo and starts-with(@foo, 'bar')]"), + array('e[foo$="bar"]', "e[@foo and substring(@foo, string-length(@foo)-2) = 'bar']"), + array('e[foo*="bar"]', "e[@foo and contains(@foo, 'bar')]"), + array('e[hreflang|="en"]', "e[@hreflang and (@hreflang = 'en' or starts-with(@hreflang, 'en-'))]"), + array('e:nth-child(1)', "*/*[name() = 'e' and (position() = 1)]"), + array('e:nth-last-child(1)', "*/*[name() = 'e' and (position() = last() - 0)]"), + array('e:nth-last-child(2n+2)', "*/*[name() = 'e' and (last() - position() - 1 >= 0 and (last() - position() - 1) mod 2 = 0)]"), + array('e:nth-of-type(1)', "*/e[position() = 1]"), + array('e:nth-last-of-type(1)', "*/e[position() = last() - 0]"), + array('div e:nth-last-of-type(1) .aclass', "div/descendant-or-self::*/e[position() = last() - 0]/descendant-or-self::*/*[@class and contains(concat(' ', normalize-space(@class), ' '), ' aclass ')]"), + array('e:first-child', "*/*[name() = 'e' and (position() = 1)]"), + array('e:last-child', "*/*[name() = 'e' and (position() = last())]"), + array('e:first-of-type', "*/e[position() = 1]"), + array('e:last-of-type', "*/e[position() = last()]"), + array('e:only-child', "*/*[name() = 'e' and (last() = 1)]"), + array('e:only-of-type', "e[last() = 1]"), + array('e:empty', "e[not(*) and not(string-length())]"), + array('e:EmPTY', "e[not(*) and not(string-length())]"), + array('e:root', "e[not(parent::*)]"), + array('e:hover', "e[0]"), + array('e:contains("foo")', "e[contains(string(.), 'foo')]"), + array('e:ConTains(foo)', "e[contains(string(.), 'foo')]"), + array('e.warning', "e[@class and contains(concat(' ', normalize-space(@class), ' '), ' warning ')]"), + array('e#myid', "e[@id = 'myid']"), + array('e:not(:nth-child(odd))', "e[not(position() - 1 >= 0 and (position() - 1) mod 2 = 0)]"), + array('e:nOT(*)', "e[0]"), + array('e f', "e/descendant-or-self::*/f"), + array('e > f', "e/f"), + array('e + f', "e/following-sibling::*[name() = 'f' and (position() = 1)]"), + array('e ~ f', "e/following-sibling::f"), + array('div#container p', "div[@id = 'container']/descendant-or-self::*/p"), + ); + } + + public function getXmlLangTestData() + { + return array( + array(':lang("EN")', array('first', 'second', 'third', 'fourth')), + array(':lang("en-us")', array('second', 'fourth')), + array(':lang(en-nz)', array('third')), + array(':lang(fr)', array('fifth')), + array(':lang(ru)', array('sixth')), + array(":lang('ZH')", array('eighth')), + array(':lang(de) :lang(zh)', array('eighth')), + array(':lang(en), :lang(zh)', array('first', 'second', 'third', 'fourth', 'eighth')), + array(':lang(es)', array()), + ); + } + + public function getHtmlIdsTestData() + { + return array( + array('div', array('outer-div', 'li-div', 'foobar-div')), + array('DIV', array('outer-div', 'li-div', 'foobar-div')), // case-insensitive in HTML + array('div div', array('li-div')), + array('div, div div', array('outer-div', 'li-div', 'foobar-div')), + array('a[name]', array('name-anchor')), + array('a[NAme]', array('name-anchor')), // case-insensitive in HTML: + array('a[rel]', array('tag-anchor', 'nofollow-anchor')), + array('a[rel="tag"]', array('tag-anchor')), + array('a[href*="localhost"]', array('tag-anchor')), + array('a[href*=""]', array()), + array('a[href^="http"]', array('tag-anchor', 'nofollow-anchor')), + array('a[href^="http:"]', array('tag-anchor')), + array('a[href^=""]', array()), + array('a[href$="org"]', array('nofollow-anchor')), + array('a[href$=""]', array()), + array('div[foobar~="bc"]', array('foobar-div')), + array('div[foobar~="cde"]', array('foobar-div')), + array('[foobar~="ab bc"]', array('foobar-div')), + array('[foobar~=""]', array()), + array('[foobar~=" \t"]', array()), + array('div[foobar~="cd"]', array()), + array('*[lang|="En"]', array('second-li')), + array('[lang|="En-us"]', array('second-li')), + // Attribute values are case sensitive + array('*[lang|="en"]', array()), + array('[lang|="en-US"]', array()), + array('*[lang|="e"]', array()), + // ... :lang() is not. + array(':lang("EN")', array('second-li', 'li-div')), + array('*:lang(en-US)', array('second-li', 'li-div')), + array(':lang("e")', array()), + array('li:nth-child(3)', array('third-li')), + array('li:nth-child(10)', array()), + array('li:nth-child(2n)', array('second-li', 'fourth-li', 'sixth-li')), + array('li:nth-child(even)', array('second-li', 'fourth-li', 'sixth-li')), + array('li:nth-child(2n+0)', array('second-li', 'fourth-li', 'sixth-li')), + array('li:nth-child(+2n+1)', array('first-li', 'third-li', 'fifth-li', 'seventh-li')), + array('li:nth-child(odd)', array('first-li', 'third-li', 'fifth-li', 'seventh-li')), + array('li:nth-child(2n+4)', array('fourth-li', 'sixth-li')), + array('li:nth-child(3n+1)', array('first-li', 'fourth-li', 'seventh-li')), + array('li:nth-child(n)', array('first-li', 'second-li', 'third-li', 'fourth-li', 'fifth-li', 'sixth-li', 'seventh-li')), + array('li:nth-child(n-1)', array('first-li', 'second-li', 'third-li', 'fourth-li', 'fifth-li', 'sixth-li', 'seventh-li')), + array('li:nth-child(n+1)', array('first-li', 'second-li', 'third-li', 'fourth-li', 'fifth-li', 'sixth-li', 'seventh-li')), + array('li:nth-child(n+3)', array('third-li', 'fourth-li', 'fifth-li', 'sixth-li', 'seventh-li')), + array('li:nth-child(-n)', array()), + array('li:nth-child(-n-1)', array()), + array('li:nth-child(-n+1)', array('first-li')), + array('li:nth-child(-n+3)', array('first-li', 'second-li', 'third-li')), + array('li:nth-last-child(0)', array()), + array('li:nth-last-child(2n)', array('second-li', 'fourth-li', 'sixth-li')), + array('li:nth-last-child(even)', array('second-li', 'fourth-li', 'sixth-li')), + array('li:nth-last-child(2n+2)', array('second-li', 'fourth-li', 'sixth-li')), + array('li:nth-last-child(n)', array('first-li', 'second-li', 'third-li', 'fourth-li', 'fifth-li', 'sixth-li', 'seventh-li')), + array('li:nth-last-child(n-1)', array('first-li', 'second-li', 'third-li', 'fourth-li', 'fifth-li', 'sixth-li', 'seventh-li')), + array('li:nth-last-child(n-3)', array('first-li', 'second-li', 'third-li', 'fourth-li', 'fifth-li', 'sixth-li', 'seventh-li')), + array('li:nth-last-child(n+1)', array('first-li', 'second-li', 'third-li', 'fourth-li', 'fifth-li', 'sixth-li', 'seventh-li')), + array('li:nth-last-child(n+3)', array('first-li', 'second-li', 'third-li', 'fourth-li', 'fifth-li')), + array('li:nth-last-child(-n)', array()), + array('li:nth-last-child(-n-1)', array()), + array('li:nth-last-child(-n+1)', array('seventh-li')), + array('li:nth-last-child(-n+3)', array('fifth-li', 'sixth-li', 'seventh-li')), + array('ol:first-of-type', array('first-ol')), + array('ol:nth-child(1)', array('first-ol')), + array('ol:nth-of-type(2)', array('second-ol')), + array('ol:nth-last-of-type(1)', array('second-ol')), + array('span:only-child', array('foobar-span')), + array('li div:only-child', array('li-div')), + array('div *:only-child', array('li-div', 'foobar-span')), + array('p:only-of-type', array('paragraph')), + array('a:empty', array('name-anchor')), + array('a:EMpty', array('name-anchor')), + array('li:empty', array('third-li', 'fourth-li', 'fifth-li', 'sixth-li')), + array(':root', array('html')), + array('html:root', array('html')), + array('li:root', array()), + array('* :root', array()), + array('*:contains("link")', array('html', 'outer-div', 'tag-anchor', 'nofollow-anchor')), + array(':CONtains("link")', array('html', 'outer-div', 'tag-anchor', 'nofollow-anchor')), + array('*:contains("LInk")', array()), // case sensitive + array('*:contains("e")', array('html', 'nil', 'outer-div', 'first-ol', 'first-li', 'paragraph', 'p-em')), + array('*:contains("E")', array()), // case-sensitive + array('.a', array('first-ol')), + array('.b', array('first-ol')), + array('*.a', array('first-ol')), + array('ol.a', array('first-ol')), + array('.c', array('first-ol', 'third-li', 'fourth-li')), + array('*.c', array('first-ol', 'third-li', 'fourth-li')), + array('ol *.c', array('third-li', 'fourth-li')), + array('ol li.c', array('third-li', 'fourth-li')), + array('li ~ li.c', array('third-li', 'fourth-li')), + array('ol > li.c', array('third-li', 'fourth-li')), + array('#first-li', array('first-li')), + array('li#first-li', array('first-li')), + array('*#first-li', array('first-li')), + array('li div', array('li-div')), + array('li > div', array('li-div')), + array('div div', array('li-div')), + array('div > div', array()), + array('div>.c', array('first-ol')), + array('div > .c', array('first-ol')), + array('div + div', array('foobar-div')), + array('a ~ a', array('tag-anchor', 'nofollow-anchor')), + array('a[rel="tag"] ~ a', array('nofollow-anchor')), + array('ol#first-ol li:last-child', array('seventh-li')), + array('ol#first-ol *:last-child', array('li-div', 'seventh-li')), + array('#outer-div:first-child', array('outer-div')), + array('#outer-div :first-child', array('name-anchor', 'first-li', 'li-div', 'p-b', 'checkbox-fieldset-disabled', 'area-href')), + array('a[href]', array('tag-anchor', 'nofollow-anchor')), + array(':not(*)', array()), + array('a:not([href])', array('name-anchor')), + array('ol :Not(li[class])', array('first-li', 'second-li', 'li-div', 'fifth-li', 'sixth-li', 'seventh-li')), + // HTML-specific + array(':link', array('link-href', 'tag-anchor', 'nofollow-anchor', 'area-href')), + array(':visited', array()), + array(':enabled', array('link-href', 'tag-anchor', 'nofollow-anchor', 'checkbox-unchecked', 'text-checked', 'checkbox-checked', 'area-href')), + array(':disabled', array('checkbox-disabled', 'checkbox-disabled-checked', 'fieldset', 'checkbox-fieldset-disabled')), + array(':checked', array('checkbox-checked', 'checkbox-disabled-checked')), + ); + } + + public function getHtmlShakespearTestData() + { + return array( + array('*', 246), + array('div:contains(CELIA)', 26), + array('div:only-child', 22), // ? + array('div:nth-child(even)', 106), + array('div:nth-child(2n)', 106), + array('div:nth-child(odd)', 137), + array('div:nth-child(2n+1)', 137), + array('div:nth-child(n)', 243), + array('div:last-child', 53), + array('div:first-child', 51), + array('div > div', 242), + array('div + div', 190), + array('div ~ div', 190), + array('body', 1), + array('body div', 243), + array('div', 243), + array('div div', 242), + array('div div div', 241), + array('div, div, div', 243), + array('div, a, span', 243), + array('.dialog', 51), + array('div.dialog', 51), + array('div .dialog', 51), + array('div.character, div.dialog', 99), + array('div.direction.dialog', 0), + array('div.dialog.direction', 0), + array('div.dialog.scene', 1), + array('div.scene.scene', 1), + array('div.scene .scene', 0), + array('div.direction .dialog ', 0), + array('div .dialog .direction', 4), + array('div.dialog .dialog .direction', 4), + array('#speech5', 1), + array('div#speech5', 1), + array('div #speech5', 1), + array('div.scene div.dialog', 49), + array('div#scene1 div.dialog div', 142), + array('#scene1 #speech1', 1), + array('div[class]', 103), + array('div[class=dialog]', 50), + array('div[class^=dia]', 51), + array('div[class$=log]', 50), + array('div[class*=sce]', 1), + array('div[class|=dialog]', 50), // ? Seems right + array('div[class!=madeup]', 243), // ? Seems right + array('div[class~=dialog]', 51), // ? Seems right + ); + } +} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/XPath/Extension/AbstractExtension.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/XPath/Extension/AbstractExtension.php new file mode 100755 index 0000000..1b147e9 --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/XPath/Extension/AbstractExtension.php @@ -0,0 +1,63 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\CssSelector\XPath\Extension; + +/** + * XPath expression translator abstract extension. + * + * This component is a port of the Python cssselector library, + * which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect. + * + * @author Jean-François Simon + */ +abstract class AbstractExtension implements ExtensionInterface +{ + /** + * {@inheritdoc} + */ + public function getNodeTranslators() + { + return array(); + } + + /** + * {@inheritdoc} + */ + public function getCombinationTranslators() + { + return array(); + } + + /** + * {@inheritdoc} + */ + public function getFunctionTranslators() + { + return array(); + } + + /** + * {@inheritdoc} + */ + public function getPseudoClassTranslators() + { + return array(); + } + + /** + * {@inheritdoc} + */ + public function getAttributeMatchingTranslators() + { + return array(); + } +} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/XPath/Extension/AttributeMatchingExtension.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/XPath/Extension/AttributeMatchingExtension.php new file mode 100755 index 0000000..1b1f00f --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/XPath/Extension/AttributeMatchingExtension.php @@ -0,0 +1,173 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\CssSelector\XPath\Extension; + +use Symfony\Component\CssSelector\XPath\Translator; +use Symfony\Component\CssSelector\XPath\XPathExpr; + +/** + * XPath expression translator attribute extension. + * + * This component is a port of the Python cssselector library, + * which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect. + * + * @author Jean-François Simon + */ +class AttributeMatchingExtension extends AbstractExtension +{ + /** + * {@inheritdoc} + */ + public function getAttributeMatchingTranslators() + { + return array( + 'exists' => array($this, 'translateExists'), + '=' => array($this, 'translateEquals'), + '~=' => array($this, 'translateIncludes'), + '|=' => array($this, 'translateDashMatch'), + '^=' => array($this, 'translatePrefixMatch'), + '$=' => array($this, 'translateSuffixMatch'), + '*=' => array($this, 'translateSubstringMatch'), + '!=' => array($this, 'translateDifferent'), + ); + } + + /** + * @param XPathExpr $xpath + * @param string $attribute + * @param string $value + * + * @return XPathExpr + */ + public function translateExists(XPathExpr $xpath, $attribute, $value) + { + return $xpath->addCondition($attribute); + } + + /** + * @param XPathExpr $xpath + * @param string $attribute + * @param string $value + * + * @return XPathExpr + */ + public function translateEquals(XPathExpr $xpath, $attribute, $value) + { + return $xpath->addCondition(sprintf('%s = %s', $attribute, Translator::getXpathLiteral($value))); + } + + /** + * @param XPathExpr $xpath + * @param string $attribute + * @param string $value + * + * @return XPathExpr + */ + public function translateIncludes(XPathExpr $xpath, $attribute, $value) + { + return $xpath->addCondition($value ? sprintf( + '%1$s and contains(concat(\' \', normalize-space(%1$s), \' \'), %2$s)', + $attribute, + Translator::getXpathLiteral(' '.$value.' ') + ) : '0'); + } + + /** + * @param XPathExpr $xpath + * @param string $attribute + * @param string $value + * + * @return XPathExpr + */ + public function translateDashMatch(XPathExpr $xpath, $attribute, $value) + { + return $xpath->addCondition(sprintf( + '%1$s and (%1$s = %2$s or starts-with(%1$s, %3$s))', + $attribute, + Translator::getXpathLiteral($value), + Translator::getXpathLiteral($value.'-') + )); + } + + /** + * @param XPathExpr $xpath + * @param string $attribute + * @param string $value + * + * @return XPathExpr + */ + public function translatePrefixMatch(XPathExpr $xpath, $attribute, $value) + { + return $xpath->addCondition($value ? sprintf( + '%1$s and starts-with(%1$s, %2$s)', + $attribute, + Translator::getXpathLiteral($value) + ) : '0'); + } + + /** + * @param XPathExpr $xpath + * @param string $attribute + * @param string $value + * + * @return XPathExpr + */ + public function translateSuffixMatch(XPathExpr $xpath, $attribute, $value) + { + return $xpath->addCondition($value ? sprintf( + '%1$s and substring(%1$s, string-length(%1$s)-%2$s) = %3$s', + $attribute, + strlen($value) - 1, + Translator::getXpathLiteral($value) + ) : '0'); + } + + /** + * @param XPathExpr $xpath + * @param string $attribute + * @param string $value + * + * @return XPathExpr + */ + public function translateSubstringMatch(XPathExpr $xpath, $attribute, $value) + { + return $xpath->addCondition($value ? sprintf( + '%1$s and contains(%1$s, %2$s)', + $attribute, + Translator::getXpathLiteral($value) + ) : '0'); + } + + /** + * @param XPathExpr $xpath + * @param string $attribute + * @param string $value + * + * @return XPathExpr + */ + public function translateDifferent(XPathExpr $xpath, $attribute, $value) + { + return $xpath->addCondition(sprintf( + $value ? 'not(%1$s) or %1$s != %2$s' : '%s != %s', + $attribute, + Translator::getXpathLiteral($value) + )); + } + + /** + * {@inheritdoc} + */ + public function getName() + { + return 'attribute-matching'; + } +} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/XPath/Extension/CombinationExtension.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/XPath/Extension/CombinationExtension.php new file mode 100755 index 0000000..639e924 --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/XPath/Extension/CombinationExtension.php @@ -0,0 +1,93 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\CssSelector\XPath\Extension; + +use Symfony\Component\CssSelector\XPath\XPathExpr; + +/** + * XPath expression translator combination extension. + * + * This component is a port of the Python cssselector library, + * which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect. + * + * @author Jean-François Simon + */ +class CombinationExtension extends AbstractExtension +{ + /** + * {@inheritdoc} + */ + public function getCombinationTranslators() + { + return array( + ' ' => array($this, 'translateDescendant'), + '>' => array($this, 'translateChild'), + '+' => array($this, 'translateDirectAdjacent'), + '~' => array($this, 'translateIndirectAdjacent'), + ); + } + + /** + * @param XPathExpr $xpath + * @param XPathExpr $combinedXpath + * + * @return XPathExpr + */ + public function translateDescendant(XPathExpr $xpath, XPathExpr $combinedXpath) + { + return $xpath->join('/descendant-or-self::*/', $combinedXpath); + } + + /** + * @param XPathExpr $xpath + * @param XPathExpr $combinedXpath + * + * @return XPathExpr + */ + public function translateChild(XPathExpr $xpath, XPathExpr $combinedXpath) + { + return $xpath->join('/', $combinedXpath); + } + + /** + * @param XPathExpr $xpath + * @param XPathExpr $combinedXpath + * + * @return XPathExpr + */ + public function translateDirectAdjacent(XPathExpr $xpath, XPathExpr $combinedXpath) + { + return $xpath + ->join('/following-sibling::', $combinedXpath) + ->addNameTest() + ->addCondition('position() = 1'); + } + + /** + * @param XPathExpr $xpath + * @param XPathExpr $combinedXpath + * + * @return XPathExpr + */ + public function translateIndirectAdjacent(XPathExpr $xpath, XPathExpr $combinedXpath) + { + return $xpath->join('/following-sibling::', $combinedXpath); + } + + /** + * {@inheritdoc} + */ + public function getName() + { + return 'combination'; + } +} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/XPath/Extension/ExtensionInterface.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/XPath/Extension/ExtensionInterface.php new file mode 100755 index 0000000..65ab287 --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/XPath/Extension/ExtensionInterface.php @@ -0,0 +1,65 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\CssSelector\XPath\Extension; + +/** + * XPath expression translator extension interface. + * + * This component is a port of the Python cssselector library, + * which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect. + * + * @author Jean-François Simon + */ +interface ExtensionInterface +{ + /** + * Returns node translators. + * + * @return callable[] + */ + public function getNodeTranslators(); + + /** + * Returns combination translators. + * + * @return callable[] + */ + public function getCombinationTranslators(); + + /** + * Returns function translators. + * + * @return callable[] + */ + public function getFunctionTranslators(); + + /** + * Returns pseudo-class translators. + * + * @return callable[] + */ + public function getPseudoClassTranslators(); + + /** + * Returns attribute operation translators. + * + * @return callable[] + */ + public function getAttributeMatchingTranslators(); + + /** + * Returns extension name. + * + * @return string + */ + public function getName(); +} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/XPath/Extension/FunctionExtension.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/XPath/Extension/FunctionExtension.php new file mode 100755 index 0000000..ff8f333 --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/XPath/Extension/FunctionExtension.php @@ -0,0 +1,209 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\CssSelector\XPath\Extension; + +use Symfony\Component\CssSelector\Exception\ExpressionErrorException; +use Symfony\Component\CssSelector\Exception\SyntaxErrorException; +use Symfony\Component\CssSelector\Node\FunctionNode; +use Symfony\Component\CssSelector\Parser\Parser; +use Symfony\Component\CssSelector\XPath\Translator; +use Symfony\Component\CssSelector\XPath\XPathExpr; + +/** + * XPath expression translator function extension. + * + * This component is a port of the Python cssselector library, + * which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect. + * + * @author Jean-François Simon + */ +class FunctionExtension extends AbstractExtension +{ + /** + * {@inheritdoc} + */ + public function getFunctionTranslators() + { + return array( + 'nth-child' => array($this, 'translateNthChild'), + 'nth-last-child' => array($this, 'translateNthLastChild'), + 'nth-of-type' => array($this, 'translateNthOfType'), + 'nth-last-of-type' => array($this, 'translateNthLastOfType'), + 'contains' => array($this, 'translateContains'), + 'lang' => array($this, 'translateLang'), + ); + } + + /** + * @param XPathExpr $xpath + * @param FunctionNode $function + * @param bool $last + * @param bool $addNameTest + * + * @return XPathExpr + * + * @throws ExpressionErrorException + */ + public function translateNthChild(XPathExpr $xpath, FunctionNode $function, $last = false, $addNameTest = true) + { + try { + list($a, $b) = Parser::parseSeries($function->getArguments()); + } catch (SyntaxErrorException $e) { + throw new ExpressionErrorException(sprintf('Invalid series: %s', implode(', ', $function->getArguments())), 0, $e); + } + + $xpath->addStarPrefix(); + if ($addNameTest) { + $xpath->addNameTest(); + } + + if (0 === $a) { + return $xpath->addCondition('position() = '.($last ? 'last() - '.($b - 1) : $b)); + } + + if ($a < 0) { + if ($b < 1) { + return $xpath->addCondition('false()'); + } + + $sign = '<='; + } else { + $sign = '>='; + } + + $expr = 'position()'; + + if ($last) { + $expr = 'last() - '.$expr; + $b--; + } + + if (0 !== $b) { + $expr .= ' - '.$b; + } + + $conditions = array(sprintf('%s %s 0', $expr, $sign)); + + if (1 !== $a && -1 !== $a) { + $conditions[] = sprintf('(%s) mod %d = 0', $expr, $a); + } + + return $xpath->addCondition(implode(' and ', $conditions)); + + // todo: handle an+b, odd, even + // an+b means every-a, plus b, e.g., 2n+1 means odd + // 0n+b means b + // n+0 means a=1, i.e., all elements + // an means every a elements, i.e., 2n means even + // -n means -1n + // -1n+6 means elements 6 and previous + } + + /** + * @param XPathExpr $xpath + * @param FunctionNode $function + * + * @return XPathExpr + */ + public function translateNthLastChild(XPathExpr $xpath, FunctionNode $function) + { + return $this->translateNthChild($xpath, $function, true); + } + + /** + * @param XPathExpr $xpath + * @param FunctionNode $function + * + * @return XPathExpr + */ + public function translateNthOfType(XPathExpr $xpath, FunctionNode $function) + { + return $this->translateNthChild($xpath, $function, false, false); + } + + /** + * @param XPathExpr $xpath + * @param FunctionNode $function + * + * @return XPathExpr + * + * @throws ExpressionErrorException + */ + public function translateNthLastOfType(XPathExpr $xpath, FunctionNode $function) + { + if ('*' === $xpath->getElement()) { + throw new ExpressionErrorException('"*:nth-of-type()" is not implemented.'); + } + + return $this->translateNthChild($xpath, $function, true, false); + } + + /** + * @param XPathExpr $xpath + * @param FunctionNode $function + * + * @return XPathExpr + * + * @throws ExpressionErrorException + */ + public function translateContains(XPathExpr $xpath, FunctionNode $function) + { + $arguments = $function->getArguments(); + foreach ($arguments as $token) { + if (!($token->isString() || $token->isIdentifier())) { + throw new ExpressionErrorException( + 'Expected a single string or identifier for :contains(), got ' + .implode(', ', $arguments) + ); + } + } + + return $xpath->addCondition(sprintf( + 'contains(string(.), %s)', + Translator::getXpathLiteral($arguments[0]->getValue()) + )); + } + + /** + * @param XPathExpr $xpath + * @param FunctionNode $function + * + * @return XPathExpr + * + * @throws ExpressionErrorException + */ + public function translateLang(XPathExpr $xpath, FunctionNode $function) + { + $arguments = $function->getArguments(); + foreach ($arguments as $token) { + if (!($token->isString() || $token->isIdentifier())) { + throw new ExpressionErrorException( + 'Expected a single string or identifier for :lang(), got ' + .implode(', ', $arguments) + ); + } + } + + return $xpath->addCondition(sprintf( + 'lang(%s)', + Translator::getXpathLiteral($arguments[0]->getValue()) + )); + } + + /** + * {@inheritdoc} + */ + public function getName() + { + return 'function'; + } +} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/XPath/Extension/HtmlExtension.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/XPath/Extension/HtmlExtension.php new file mode 100755 index 0000000..aef8052 --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/XPath/Extension/HtmlExtension.php @@ -0,0 +1,238 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\CssSelector\XPath\Extension; + +use Symfony\Component\CssSelector\Exception\ExpressionErrorException; +use Symfony\Component\CssSelector\Node\FunctionNode; +use Symfony\Component\CssSelector\XPath\Translator; +use Symfony\Component\CssSelector\XPath\XPathExpr; + +/** + * XPath expression translator HTML extension. + * + * This component is a port of the Python cssselector library, + * which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect. + * + * @author Jean-François Simon + */ +class HtmlExtension extends AbstractExtension +{ + /** + * Constructor. + * + * @param Translator $translator + */ + public function __construct(Translator $translator) + { + $translator + ->getExtension('node') + ->setFlag(NodeExtension::ELEMENT_NAME_IN_LOWER_CASE, true) + ->setFlag(NodeExtension::ATTRIBUTE_NAME_IN_LOWER_CASE, true); + } + + /** + * {@inheritdoc} + */ + public function getPseudoClassTranslators() + { + return array( + 'checked' => array($this, 'translateChecked'), + 'link' => array($this, 'translateLink'), + 'disabled' => array($this, 'translateDisabled'), + 'enabled' => array($this, 'translateEnabled'), + 'selected' => array($this, 'translateSelected'), + 'invalid' => array($this, 'translateInvalid'), + 'hover' => array($this, 'translateHover'), + 'visited' => array($this, 'translateVisited'), + ); + } + + /** + * {@inheritdoc} + */ + public function getFunctionTranslators() + { + return array( + 'lang' => array($this, 'translateLang'), + ); + } + + /** + * @param XPathExpr $xpath + * + * @return XPathExpr + */ + public function translateChecked(XPathExpr $xpath) + { + return $xpath->addCondition( + '(@checked ' + ."and (name(.) = 'input' or name(.) = 'command')" + ."and (@type = 'checkbox' or @type = 'radio'))" + ); + } + + /** + * @param XPathExpr $xpath + * + * @return XPathExpr + */ + public function translateLink(XPathExpr $xpath) + { + return $xpath->addCondition("@href and (name(.) = 'a' or name(.) = 'link' or name(.) = 'area')"); + } + + /** + * @param XPathExpr $xpath + * + * @return XPathExpr + */ + public function translateDisabled(XPathExpr $xpath) + { + return $xpath->addCondition( + "(" + ."@disabled and" + ."(" + ."(name(.) = 'input' and @type != 'hidden')" + ." or name(.) = 'button'" + ." or name(.) = 'select'" + ." or name(.) = 'textarea'" + ." or name(.) = 'command'" + ." or name(.) = 'fieldset'" + ." or name(.) = 'optgroup'" + ." or name(.) = 'option'" + .")" + .") or (" + ."(name(.) = 'input' and @type != 'hidden')" + ." or name(.) = 'button'" + ." or name(.) = 'select'" + ." or name(.) = 'textarea'" + .")" + ." and ancestor::fieldset[@disabled]" + ); + // todo: in the second half, add "and is not a descendant of that fieldset element's first legend element child, if any." + } + + /** + * @param XPathExpr $xpath + * + * @return XPathExpr + */ + public function translateEnabled(XPathExpr $xpath) + { + return $xpath->addCondition( + '(' + .'@href and (' + ."name(.) = 'a'" + ." or name(.) = 'link'" + ." or name(.) = 'area'" + .')' + .') or (' + .'(' + ."name(.) = 'command'" + ." or name(.) = 'fieldset'" + ." or name(.) = 'optgroup'" + .')' + .' and not(@disabled)' + .') or (' + .'(' + ."(name(.) = 'input' and @type != 'hidden')" + ." or name(.) = 'button'" + ." or name(.) = 'select'" + ." or name(.) = 'textarea'" + ." or name(.) = 'keygen'" + .')' + ." and not (@disabled or ancestor::fieldset[@disabled])" + .') or (' + ."name(.) = 'option' and not(" + ."@disabled or ancestor::optgroup[@disabled]" + .')' + .')' + ); + } + + /** + * @param XPathExpr $xpath + * @param FunctionNode $function + * + * @return XPathExpr + * + * @throws ExpressionErrorException + */ + public function translateLang(XPathExpr $xpath, FunctionNode $function) + { + $arguments = $function->getArguments(); + foreach ($arguments as $token) { + if (!($token->isString() || $token->isIdentifier())) { + throw new ExpressionErrorException( + 'Expected a single string or identifier for :lang(), got ' + .implode(', ', $arguments) + ); + } + } + + return $xpath->addCondition(sprintf( + 'ancestor-or-self::*[@lang][1][starts-with(concat(' + ."translate(@%s, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz'), '-')" + .', %s)]', + 'lang', + Translator::getXpathLiteral(strtolower($arguments[0]->getValue()).'-') + )); + } + + /** + * @param XPathExpr $xpath + * + * @return XPathExpr + */ + public function translateSelected(XPathExpr $xpath) + { + return $xpath->addCondition("(@selected and name(.) = 'option')"); + } + + /** + * @param XPathExpr $xpath + * + * @return XPathExpr + */ + public function translateInvalid(XPathExpr $xpath) + { + return $xpath->addCondition('0'); + } + + /** + * @param XPathExpr $xpath + * + * @return XPathExpr + */ + public function translateHover(XPathExpr $xpath) + { + return $xpath->addCondition('0'); + } + + /** + * @param XPathExpr $xpath + * + * @return XPathExpr + */ + public function translateVisited(XPathExpr $xpath) + { + return $xpath->addCondition('0'); + } + + /** + * {@inheritdoc} + */ + public function getName() + { + return 'html'; + } +} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/XPath/Extension/NodeExtension.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/XPath/Extension/NodeExtension.php new file mode 100755 index 0000000..f86f2b9 --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/XPath/Extension/NodeExtension.php @@ -0,0 +1,270 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\CssSelector\XPath\Extension; + +use Symfony\Component\CssSelector\Node; +use Symfony\Component\CssSelector\XPath\Translator; +use Symfony\Component\CssSelector\XPath\XPathExpr; + +/** + * XPath expression translator node extension. + * + * This component is a port of the Python cssselector library, + * which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect. + * + * @author Jean-François Simon + */ +class NodeExtension extends AbstractExtension +{ + const ELEMENT_NAME_IN_LOWER_CASE = 1; + const ATTRIBUTE_NAME_IN_LOWER_CASE = 2; + const ATTRIBUTE_VALUE_IN_LOWER_CASE = 4; + + /** + * @var Translator + */ + private $translator; + + /** + * @var int + */ + private $flags; + + /** + * Constructor. + * + * @param Translator $translator + * @param int $flags + */ + public function __construct(Translator $translator, $flags = 0) + { + $this->translator = $translator; + $this->flags = $flags; + } + + /** + * @param int $flag + * @param bool $on + * + * @return NodeExtension + */ + public function setFlag($flag, $on) + { + if ($on && !$this->hasFlag($flag)) { + $this->flags += $flag; + } + + if (!$on && $this->hasFlag($flag)) { + $this->flags -= $flag; + } + + return $this; + } + + /** + * @param int $flag + * + * @return bool + */ + public function hasFlag($flag) + { + return $this->flags & $flag; + } + + /** + * {@inheritdoc} + */ + public function getNodeTranslators() + { + return array( + 'Selector' => array($this, 'translateSelector'), + 'CombinedSelector' => array($this, 'translateCombinedSelector'), + 'Negation' => array($this, 'translateNegation'), + 'Function' => array($this, 'translateFunction'), + 'Pseudo' => array($this, 'translatePseudo'), + 'Attribute' => array($this, 'translateAttribute'), + 'Class' => array($this, 'translateClass'), + 'Hash' => array($this, 'translateHash'), + 'Element' => array($this, 'translateElement'), + ); + } + + /** + * @param Node\SelectorNode $node + * + * @return XPathExpr + */ + public function translateSelector(Node\SelectorNode $node) + { + return $this->translator->nodeToXPath($node->getTree()); + } + + /** + * @param Node\CombinedSelectorNode $node + * + * @return XPathExpr + */ + public function translateCombinedSelector(Node\CombinedSelectorNode $node) + { + return $this->translator->addCombination($node->getCombinator(), $node->getSelector(), $node->getSubSelector()); + } + + /** + * @param Node\NegationNode $node + * + * @return XPathExpr + */ + public function translateNegation(Node\NegationNode $node) + { + $xpath = $this->translator->nodeToXPath($node->getSelector()); + $subXpath = $this->translator->nodeToXPath($node->getSubSelector()); + $subXpath->addNameTest(); + + if ($subXpath->getCondition()) { + return $xpath->addCondition(sprintf('not(%s)', $subXpath->getCondition())); + } + + return $xpath->addCondition('0'); + } + + /** + * @param Node\FunctionNode $node + * + * @return XPathExpr + */ + public function translateFunction(Node\FunctionNode $node) + { + $xpath = $this->translator->nodeToXPath($node->getSelector()); + + return $this->translator->addFunction($xpath, $node); + } + + /** + * @param Node\PseudoNode $node + * + * @return XPathExpr + */ + public function translatePseudo(Node\PseudoNode $node) + { + $xpath = $this->translator->nodeToXPath($node->getSelector()); + + return $this->translator->addPseudoClass($xpath, $node->getIdentifier()); + } + + /** + * @param Node\AttributeNode $node + * + * @return XPathExpr + */ + public function translateAttribute(Node\AttributeNode $node) + { + $name = $node->getAttribute(); + $safe = $this->isSafeName($name); + + if ($this->hasFlag(self::ATTRIBUTE_NAME_IN_LOWER_CASE)) { + $name = strtolower($name); + } + + if ($node->getNamespace()) { + $name = sprintf('%s:%s', $node->getNamespace(), $name); + $safe = $safe && $this->isSafeName($node->getNamespace()); + } + + $attribute = $safe ? '@'.$name : sprintf('attribute::*[name() = %s]', Translator::getXpathLiteral($name)); + $value = $node->getValue(); + $xpath = $this->translator->nodeToXPath($node->getSelector()); + + if ($this->hasFlag(self::ATTRIBUTE_VALUE_IN_LOWER_CASE)) { + $value = strtolower($value); + } + + return $this->translator->addAttributeMatching($xpath, $node->getOperator(), $attribute, $value); + } + + /** + * @param Node\ClassNode $node + * + * @return XPathExpr + */ + public function translateClass(Node\ClassNode $node) + { + $xpath = $this->translator->nodeToXPath($node->getSelector()); + + return $this->translator->addAttributeMatching($xpath, '~=', '@class', $node->getName()); + } + + /** + * @param Node\HashNode $node + * + * @return XPathExpr + */ + public function translateHash(Node\HashNode $node) + { + $xpath = $this->translator->nodeToXPath($node->getSelector()); + + return $this->translator->addAttributeMatching($xpath, '=', '@id', $node->getId()); + } + + /** + * @param Node\ElementNode $node + * + * @return XPathExpr + */ + public function translateElement(Node\ElementNode $node) + { + $element = $node->getElement(); + + if ($this->hasFlag(self::ELEMENT_NAME_IN_LOWER_CASE)) { + $element = strtolower($element); + } + + if ($element) { + $safe = $this->isSafeName($element); + } else { + $element = '*'; + $safe = true; + } + + if ($node->getNamespace()) { + $element = sprintf('%s:%s', $node->getNamespace(), $element); + $safe = $safe && $this->isSafeName($node->getNamespace()); + } + + $xpath = new XPathExpr('', $element); + + if (!$safe) { + $xpath->addNameTest(); + } + + return $xpath; + } + + /** + * {@inheritdoc} + */ + public function getName() + { + return 'node'; + } + + /** + * Tests if given name is safe. + * + * @param string $name + * + * @return bool + */ + private function isSafeName($name) + { + return 0 < preg_match('~^[a-zA-Z_][a-zA-Z0-9_.-]*$~', $name); + } +} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/XPath/Extension/PseudoClassExtension.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/XPath/Extension/PseudoClassExtension.php new file mode 100755 index 0000000..d230dd7 --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/XPath/Extension/PseudoClassExtension.php @@ -0,0 +1,162 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\CssSelector\XPath\Extension; + +use Symfony\Component\CssSelector\Exception\ExpressionErrorException; +use Symfony\Component\CssSelector\XPath\XPathExpr; + +/** + * XPath expression translator pseudo-class extension. + * + * This component is a port of the Python cssselector library, + * which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect. + * + * @author Jean-François Simon + */ +class PseudoClassExtension extends AbstractExtension +{ + /** + * {@inheritdoc} + */ + public function getPseudoClassTranslators() + { + return array( + 'root' => array($this, 'translateRoot'), + 'first-child' => array($this, 'translateFirstChild'), + 'last-child' => array($this, 'translateLastChild'), + 'first-of-type' => array($this, 'translateFirstOfType'), + 'last-of-type' => array($this, 'translateLastOfType'), + 'only-child' => array($this, 'translateOnlyChild'), + 'only-of-type' => array($this, 'translateOnlyOfType'), + 'empty' => array($this, 'translateEmpty'), + ); + } + + /** + * @param XPathExpr $xpath + * + * @return XPathExpr + */ + public function translateRoot(XPathExpr $xpath) + { + return $xpath->addCondition('not(parent::*)'); + } + + /** + * @param XPathExpr $xpath + * + * @return XPathExpr + */ + public function translateFirstChild(XPathExpr $xpath) + { + return $xpath + ->addStarPrefix() + ->addNameTest() + ->addCondition('position() = 1'); + } + + /** + * @param XPathExpr $xpath + * + * @return XPathExpr + */ + public function translateLastChild(XPathExpr $xpath) + { + return $xpath + ->addStarPrefix() + ->addNameTest() + ->addCondition('position() = last()'); + } + + /** + * @param XPathExpr $xpath + * + * @return XPathExpr + * + * @throws ExpressionErrorException + */ + public function translateFirstOfType(XPathExpr $xpath) + { + if ('*' === $xpath->getElement()) { + throw new ExpressionErrorException('"*:first-of-type" is not implemented.'); + } + + return $xpath + ->addStarPrefix() + ->addCondition('position() = 1'); + } + + /** + * @param XPathExpr $xpath + * + * @return XPathExpr + * + * @throws ExpressionErrorException + */ + public function translateLastOfType(XPathExpr $xpath) + { + if ('*' === $xpath->getElement()) { + throw new ExpressionErrorException('"*:last-of-type" is not implemented.'); + } + + return $xpath + ->addStarPrefix() + ->addCondition('position() = last()'); + } + + /** + * @param XPathExpr $xpath + * + * @return XPathExpr + */ + public function translateOnlyChild(XPathExpr $xpath) + { + return $xpath + ->addStarPrefix() + ->addNameTest() + ->addCondition('last() = 1'); + } + + /** + * @param XPathExpr $xpath + * + * @return XPathExpr + * + * @throws ExpressionErrorException + */ + public function translateOnlyOfType(XPathExpr $xpath) + { + if ('*' === $xpath->getElement()) { + throw new ExpressionErrorException('"*:only-of-type" is not implemented.'); + } + + return $xpath->addCondition('last() = 1'); + } + + /** + * @param XPathExpr $xpath + * + * @return XPathExpr + */ + public function translateEmpty(XPathExpr $xpath) + { + return $xpath->addCondition('not(*) and not(string-length())'); + } + + /** + * {@inheritdoc} + */ + public function getName() + { + return 'pseudo-class'; + } +} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/XPath/Translator.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/XPath/Translator.php new file mode 100755 index 0000000..5a8eb99 --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/XPath/Translator.php @@ -0,0 +1,301 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\CssSelector\XPath; + +use Symfony\Component\CssSelector\Exception\ExpressionErrorException; +use Symfony\Component\CssSelector\Node\FunctionNode; +use Symfony\Component\CssSelector\Node\NodeInterface; +use Symfony\Component\CssSelector\Node\SelectorNode; +use Symfony\Component\CssSelector\Parser\Parser; +use Symfony\Component\CssSelector\Parser\ParserInterface; + +/** + * XPath expression translator interface. + * + * This component is a port of the Python cssselector library, + * which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect. + * + * @author Jean-François Simon + */ +class Translator implements TranslatorInterface +{ + /** + * @var ParserInterface + */ + private $mainParser; + + /** + * @var ParserInterface[] + */ + private $shortcutParsers = array(); + + /** + * @var Extension\ExtensionInterface + */ + private $extensions = array(); + + /** + * @var array + */ + private $nodeTranslators = array(); + + /** + * @var array + */ + private $combinationTranslators = array(); + + /** + * @var array + */ + private $functionTranslators = array(); + + /** + * @var array + */ + private $pseudoClassTranslators = array(); + + /** + * @var array + */ + private $attributeMatchingTranslators = array(); + + /** + * Constructor. + */ + public function __construct(ParserInterface $parser = null) + { + $this->mainParser = $parser ?: new Parser(); + + $this + ->registerExtension(new Extension\NodeExtension($this)) + ->registerExtension(new Extension\CombinationExtension()) + ->registerExtension(new Extension\FunctionExtension()) + ->registerExtension(new Extension\PseudoClassExtension()) + ->registerExtension(new Extension\AttributeMatchingExtension()) + ; + } + + /** + * @param string $element + * + * @return string + */ + public static function getXpathLiteral($element) + { + if (false === strpos($element, "'")) { + return "'".$element."'"; + } + + if (false === strpos($element, '"')) { + return '"'.$element.'"'; + } + + $string = $element; + $parts = array(); + while (true) { + if (false !== $pos = strpos($string, "'")) { + $parts[] = sprintf("'%s'", substr($string, 0, $pos)); + $parts[] = "\"'\""; + $string = substr($string, $pos + 1); + } else { + $parts[] = "'$string'"; + break; + } + } + + return sprintf('concat(%s)', implode($parts, ', ')); + } + + /** + * {@inheritdoc} + */ + public function cssToXPath($cssExpr, $prefix = 'descendant-or-self::') + { + $selectors = $this->parseSelectors($cssExpr); + + /** @var SelectorNode $selector */ + foreach ($selectors as $selector) { + if (null !== $selector->getPseudoElement()) { + throw new ExpressionErrorException('Pseudo-elements are not supported.'); + } + } + + $translator = $this; + + return implode(' | ', array_map(function (SelectorNode $selector) use ($translator, $prefix) { + return $translator->selectorToXPath($selector, $prefix); + }, $selectors)); + } + + /** + * {@inheritdoc} + */ + public function selectorToXPath(SelectorNode $selector, $prefix = 'descendant-or-self::') + { + return ($prefix ?: '').$this->nodeToXPath($selector); + } + + /** + * Registers an extension. + * + * @param Extension\ExtensionInterface $extension + * + * @return Translator + */ + public function registerExtension(Extension\ExtensionInterface $extension) + { + $this->extensions[$extension->getName()] = $extension; + + $this->nodeTranslators = array_merge($this->nodeTranslators, $extension->getNodeTranslators()); + $this->combinationTranslators = array_merge($this->combinationTranslators, $extension->getCombinationTranslators()); + $this->functionTranslators = array_merge($this->functionTranslators, $extension->getFunctionTranslators()); + $this->pseudoClassTranslators = array_merge($this->pseudoClassTranslators, $extension->getPseudoClassTranslators()); + $this->attributeMatchingTranslators = array_merge($this->attributeMatchingTranslators, $extension->getAttributeMatchingTranslators()); + + return $this; + } + + /** + * @param string $name + * + * @return Extension\ExtensionInterface + * + * @throws ExpressionErrorException + */ + public function getExtension($name) + { + if (!isset($this->extensions[$name])) { + throw new ExpressionErrorException(sprintf('Extension "%s" not registered.', $name)); + } + + return $this->extensions[$name]; + } + + /** + * Registers a shortcut parser. + * + * @param ParserInterface $shortcut + * + * @return Translator + */ + public function registerParserShortcut(ParserInterface $shortcut) + { + $this->shortcutParsers[] = $shortcut; + + return $this; + } + + /** + * @param NodeInterface $node + * + * @return XPathExpr + * + * @throws ExpressionErrorException + */ + public function nodeToXPath(NodeInterface $node) + { + if (!isset($this->nodeTranslators[$node->getNodeName()])) { + throw new ExpressionErrorException(sprintf('Node "%s" not supported.', $node->getNodeName())); + } + + return call_user_func($this->nodeTranslators[$node->getNodeName()], $node); + } + + /** + * @param string $combiner + * @param NodeInterface $xpath + * @param NodeInterface $combinedXpath + * + * @return XPathExpr + * + * @throws ExpressionErrorException + */ + public function addCombination($combiner, NodeInterface $xpath, NodeInterface $combinedXpath) + { + if (!isset($this->combinationTranslators[$combiner])) { + throw new ExpressionErrorException(sprintf('Combiner "%s" not supported.', $combiner)); + } + + return call_user_func($this->combinationTranslators[$combiner], $this->nodeToXPath($xpath), $this->nodeToXPath($combinedXpath)); + } + + /** + * @param XPathExpr $xpath + * @param FunctionNode $function + * + * @return XPathExpr + * + * @throws ExpressionErrorException + */ + public function addFunction(XPathExpr $xpath, FunctionNode $function) + { + if (!isset($this->functionTranslators[$function->getName()])) { + throw new ExpressionErrorException(sprintf('Function "%s" not supported.', $function->getName())); + } + + return call_user_func($this->functionTranslators[$function->getName()], $xpath, $function); + } + + /** + * @param XPathExpr $xpath + * @param string $pseudoClass + * + * @return XPathExpr + * + * @throws ExpressionErrorException + */ + public function addPseudoClass(XPathExpr $xpath, $pseudoClass) + { + if (!isset($this->pseudoClassTranslators[$pseudoClass])) { + throw new ExpressionErrorException(sprintf('Pseudo-class "%s" not supported.', $pseudoClass)); + } + + return call_user_func($this->pseudoClassTranslators[$pseudoClass], $xpath); + } + + /** + * @param XPathExpr $xpath + * @param string $operator + * @param string $attribute + * @param string $value + * + * @throws ExpressionErrorException + * + * @return XPathExpr + */ + public function addAttributeMatching(XPathExpr $xpath, $operator, $attribute, $value) + { + if (!isset($this->attributeMatchingTranslators[$operator])) { + throw new ExpressionErrorException(sprintf('Attribute matcher operator "%s" not supported.', $operator)); + } + + return call_user_func($this->attributeMatchingTranslators[$operator], $xpath, $attribute, $value); + } + + /** + * @param string $css + * + * @return SelectorNode[] + */ + private function parseSelectors($css) + { + foreach ($this->shortcutParsers as $shortcut) { + $tokens = $shortcut->parse($css); + + if (!empty($tokens)) { + return $tokens; + } + } + + return $this->mainParser->parse($css); + } +} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/XPath/TranslatorInterface.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/XPath/TranslatorInterface.php new file mode 100755 index 0000000..b26cf5b --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/XPath/TranslatorInterface.php @@ -0,0 +1,45 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\CssSelector\XPath; + +use Symfony\Component\CssSelector\Node\SelectorNode; + +/** + * XPath expression translator interface. + * + * This component is a port of the Python cssselector library, + * which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect. + * + * @author Jean-François Simon + */ +interface TranslatorInterface +{ + /** + * Translates a CSS selector to an XPath expression. + * + * @param string $cssExpr + * @param string $prefix + * + * @return XPathExpr + */ + public function cssToXPath($cssExpr, $prefix = 'descendant-or-self::'); + + /** + * Translates a parsed selector node to an XPath expression + * + * @param SelectorNode $selector + * @param string $prefix + * + * @return XPathExpr + */ + public function selectorToXPath(SelectorNode $selector, $prefix = 'descendant-or-self::'); +} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/XPath/XPathExpr.php b/vendor/symfony/css-selector/Symfony/Component/CssSelector/XPath/XPathExpr.php new file mode 100755 index 0000000..f0f2f98 --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/XPath/XPathExpr.php @@ -0,0 +1,140 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\CssSelector\XPath; + +/** + * XPath expression translator interface. + * + * This component is a port of the Python cssselector library, + * which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect. + * + * @author Jean-François Simon + */ +class XPathExpr +{ + /** + * @var string + */ + private $path; + + /** + * @var string + */ + private $element; + + /** + * @var string + */ + private $condition; + + /** + * @param string $path + * @param string $element + * @param string $condition + * @param bool $starPrefix + */ + public function __construct($path = '', $element = '*', $condition = '', $starPrefix = false) + { + $this->path = $path; + $this->element = $element; + $this->condition = $condition; + + if ($starPrefix) { + $this->addStarPrefix(); + } + } + + /** + * @return string + */ + public function getElement() + { + return $this->element; + } + + /** + * @param $condition + * + * @return XPathExpr + */ + public function addCondition($condition) + { + $this->condition = $this->condition ? sprintf('%s and (%s)', $this->condition, $condition) : $condition; + + return $this; + } + + /** + * @return string + */ + public function getCondition() + { + return $this->condition; + } + + /** + * @return XPathExpr + */ + public function addNameTest() + { + if ('*' !== $this->element) { + $this->addCondition('name() = '.Translator::getXpathLiteral($this->element)); + $this->element = '*'; + } + + return $this; + } + + /** + * @return XPathExpr + */ + public function addStarPrefix() + { + $this->path .= '*/'; + + return $this; + } + + /** + * Joins another XPathExpr with a combiner. + * + * @param string $combiner + * @param XPathExpr $expr + * + * @return XPathExpr + */ + public function join($combiner, XPathExpr $expr) + { + $path = $this->__toString().$combiner; + + if ('*/' !== $expr->path) { + $path .= $expr->path; + } + + $this->path = $path; + $this->element = $expr->element; + $this->condition = $expr->condition; + + return $this; + } + + /** + * @return string + */ + public function __toString() + { + $path = $this->path.$this->element; + $condition = null === $this->condition || '' === $this->condition ? '' : '['.$this->condition.']'; + + return $path.$condition; + } +} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/composer.json b/vendor/symfony/css-selector/Symfony/Component/CssSelector/composer.json new file mode 100755 index 0000000..1ab133f --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/composer.json @@ -0,0 +1,35 @@ +{ + "name": "symfony/css-selector", + "type": "library", + "description": "Symfony CssSelector Component", + "keywords": [], + "homepage": "http://symfony.com", + "license": "MIT", + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Jean-François Simon", + "email": "jeanfrancois.simon@sensiolabs.com" + }, + { + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + } + ], + "require": { + "php": ">=5.3.3" + }, + "autoload": { + "psr-0": { "Symfony\\Component\\CssSelector\\": "" } + }, + "target-dir": "Symfony/Component/CssSelector", + "minimum-stability": "dev", + "extra": { + "branch-alias": { + "dev-master": "2.4-dev" + } + } +} diff --git a/vendor/symfony/css-selector/Symfony/Component/CssSelector/phpunit.xml.dist b/vendor/symfony/css-selector/Symfony/Component/CssSelector/phpunit.xml.dist new file mode 100755 index 0000000..a19dc00 --- /dev/null +++ b/vendor/symfony/css-selector/Symfony/Component/CssSelector/phpunit.xml.dist @@ -0,0 +1,30 @@ + + + + + + ./Tests/ + + + + + + ./ + + ./Resources + ./Tests + ./vendor + + + + diff --git a/vendor/symfony/debug/Symfony/Component/Debug/.gitignore b/vendor/symfony/debug/Symfony/Component/Debug/.gitignore new file mode 100755 index 0000000..c49a5d8 --- /dev/null +++ b/vendor/symfony/debug/Symfony/Component/Debug/.gitignore @@ -0,0 +1,3 @@ +vendor/ +composer.lock +phpunit.xml diff --git a/vendor/symfony/debug/Symfony/Component/Debug/CHANGELOG.md b/vendor/symfony/debug/Symfony/Component/Debug/CHANGELOG.md new file mode 100755 index 0000000..84335a1 --- /dev/null +++ b/vendor/symfony/debug/Symfony/Component/Debug/CHANGELOG.md @@ -0,0 +1,13 @@ +CHANGELOG +========= + +2.4.0 +----- + + * added a DebugClassLoader able to wrap any autoloader providing a findFile method + * improved error messages for not found classes and functions + +2.3.0 +----- + + * added the component diff --git a/vendor/symfony/debug/Symfony/Component/Debug/Debug.php b/vendor/symfony/debug/Symfony/Component/Debug/Debug.php new file mode 100755 index 0000000..e0710c5 --- /dev/null +++ b/vendor/symfony/debug/Symfony/Component/Debug/Debug.php @@ -0,0 +1,54 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Debug; + +/** + * Registers all the debug tools. + * + * @author Fabien Potencier + */ +class Debug +{ + private static $enabled = false; + + /** + * Enables the debug tools. + * + * This method registers an error handler and an exception handler. + * + * If the Symfony ClassLoader component is available, a special + * class loader is also registered. + * + * @param int $errorReportingLevel The level of error reporting you want + * @param bool $displayErrors Whether to display errors (for development) or just log them (for production) + */ + public static function enable($errorReportingLevel = null, $displayErrors = true) + { + if (static::$enabled) { + return; + } + + static::$enabled = true; + + error_reporting(-1); + + ErrorHandler::register($errorReportingLevel, $displayErrors); + if ('cli' !== php_sapi_name()) { + ExceptionHandler::register(); + // CLI - display errors only if they're not already logged to STDERR + } elseif ($displayErrors && (!ini_get('log_errors') || ini_get('error_log'))) { + ini_set('display_errors', 1); + } + + DebugClassLoader::enable(); + } +} diff --git a/vendor/symfony/debug/Symfony/Component/Debug/DebugClassLoader.php b/vendor/symfony/debug/Symfony/Component/Debug/DebugClassLoader.php new file mode 100755 index 0000000..67db200 --- /dev/null +++ b/vendor/symfony/debug/Symfony/Component/Debug/DebugClassLoader.php @@ -0,0 +1,133 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Debug; + +/** + * Autoloader checking if the class is really defined in the file found. + * + * The ClassLoader will wrap all registered autoloaders providing a + * findFile method and will throw an exception if a file is found but does + * not declare the class. + * + * @author Fabien Potencier + * @author Christophe Coevoet + * + * @api + */ +class DebugClassLoader +{ + private $classFinder; + + /** + * Constructor. + * + * @param object $classFinder + * + * @api + */ + public function __construct($classFinder) + { + $this->classFinder = $classFinder; + } + + /** + * Gets the wrapped class loader. + * + * @return object a class loader instance + */ + public function getClassLoader() + { + return $this->classFinder; + } + + /** + * Replaces all autoloaders implementing a findFile method by a DebugClassLoader wrapper. + */ + public static function enable() + { + if (!is_array($functions = spl_autoload_functions())) { + return; + } + + foreach ($functions as $function) { + spl_autoload_unregister($function); + } + + foreach ($functions as $function) { + if (is_array($function) && !$function[0] instanceof self && method_exists($function[0], 'findFile')) { + $function = array(new static($function[0]), 'loadClass'); + } + + spl_autoload_register($function); + } + } + + /** + * Disables the wrapping. + */ + public static function disable() + { + if (!is_array($functions = spl_autoload_functions())) { + return; + } + + foreach ($functions as $function) { + spl_autoload_unregister($function); + } + + foreach ($functions as $function) { + if (is_array($function) && $function[0] instanceof self) { + $function[0] = $function[0]->getClassLoader(); + } + + spl_autoload_register($function); + } + } + + /** + * Finds a file by class name + * + * @param string $class A class name to resolve to file + * + * @return string|null + */ + public function findFile($class) + { + return $this->classFinder->findFile($class); + } + + /** + * Loads the given class or interface. + * + * @param string $class The name of the class + * + * @return bool|null True, if loaded + * + * @throws \RuntimeException + */ + public function loadClass($class) + { + if ($file = $this->classFinder->findFile($class)) { + require $file; + + if (!class_exists($class, false) && !interface_exists($class, false) && (!function_exists('trait_exists') || !trait_exists($class, false))) { + if (false !== strpos($class, '/')) { + throw new \RuntimeException(sprintf('Trying to autoload a class with an invalid name "%s". Be careful that the namespace separator is "\" in PHP, not "/".', $class)); + } + + throw new \RuntimeException(sprintf('The autoloader expected class "%s" to be defined in file "%s". The file was found but the class was not in it, the class name or namespace probably has a typo.', $class, $file)); + } + + return true; + } + } +} diff --git a/vendor/symfony/debug/Symfony/Component/Debug/ErrorHandler.php b/vendor/symfony/debug/Symfony/Component/Debug/ErrorHandler.php new file mode 100755 index 0000000..e865f37 --- /dev/null +++ b/vendor/symfony/debug/Symfony/Component/Debug/ErrorHandler.php @@ -0,0 +1,252 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Debug; + +use Psr\Log\LoggerInterface; +use Symfony\Component\Debug\Exception\ContextErrorException; +use Symfony\Component\Debug\Exception\FatalErrorException; +use Symfony\Component\Debug\Exception\DummyException; +use Symfony\Component\Debug\FatalErrorHandler\UndefinedFunctionFatalErrorHandler; +use Symfony\Component\Debug\FatalErrorHandler\ClassNotFoundFatalErrorHandler; +use Symfony\Component\Debug\FatalErrorHandler\FatalErrorHandlerInterface; + +/** + * ErrorHandler. + * + * @author Fabien Potencier + * @author Konstantin Myakshin + */ +class ErrorHandler +{ + const TYPE_DEPRECATION = -100; + + private $levels = array( + E_WARNING => 'Warning', + E_NOTICE => 'Notice', + E_USER_ERROR => 'User Error', + E_USER_WARNING => 'User Warning', + E_USER_NOTICE => 'User Notice', + E_STRICT => 'Runtime Notice', + E_RECOVERABLE_ERROR => 'Catchable Fatal Error', + E_DEPRECATED => 'Deprecated', + E_USER_DEPRECATED => 'User Deprecated', + E_ERROR => 'Error', + E_CORE_ERROR => 'Core Error', + E_COMPILE_ERROR => 'Compile Error', + E_PARSE => 'Parse', + ); + + private $level; + + private $reservedMemory; + + private $displayErrors; + + /** + * @var LoggerInterface[] Loggers for channels + */ + private static $loggers = array(); + + /** + * Registers the error handler. + * + * @param int $level The level at which the conversion to Exception is done (null to use the error_reporting() value and 0 to disable) + * @param bool $displayErrors Display errors (for dev environment) or just log them (production usage) + * + * @return ErrorHandler The registered error handler + */ + public static function register($level = null, $displayErrors = true) + { + $handler = new static(); + $handler->setLevel($level); + $handler->setDisplayErrors($displayErrors); + + ini_set('display_errors', 0); + set_error_handler(array($handler, 'handle')); + register_shutdown_function(array($handler, 'handleFatal')); + $handler->reservedMemory = str_repeat('x', 10240); + + return $handler; + } + + /** + * Sets the level at which the conversion to Exception is done. + * + * @param int|null $level The level (null to use the error_reporting() value and 0 to disable) + */ + public function setLevel($level) + { + $this->level = null === $level ? error_reporting() : $level; + } + + /** + * Sets the display_errors flag value. + * + * @param int $displayErrors The display_errors flag value + */ + public function setDisplayErrors($displayErrors) + { + $this->displayErrors = $displayErrors; + } + + /** + * Sets a logger for the given channel. + * + * @param LoggerInterface $logger A logger interface + * @param string $channel The channel associated with the logger (deprecation or emergency) + */ + public static function setLogger(LoggerInterface $logger, $channel = 'deprecation') + { + self::$loggers[$channel] = $logger; + } + + /** + * @throws ContextErrorException When error_reporting returns error + */ + public function handle($level, $message, $file = 'unknown', $line = 0, $context = array()) + { + if (0 === $this->level) { + return false; + } + + if ($level & (E_USER_DEPRECATED | E_DEPRECATED)) { + if (isset(self::$loggers['deprecation'])) { + if (version_compare(PHP_VERSION, '5.4', '<')) { + $stack = array_map( + function ($row) { + unset($row['args']); + + return $row; + }, + array_slice(debug_backtrace(false), 0, 10) + ); + } else { + $stack = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 10); + } + + self::$loggers['deprecation']->warning($message, array('type' => self::TYPE_DEPRECATION, 'stack' => $stack)); + } + + return true; + } + + if ($this->displayErrors && error_reporting() & $level && $this->level & $level) { + // make sure the ContextErrorException class is loaded (https://bugs.php.net/bug.php?id=65322) + if (!class_exists('Symfony\Component\Debug\Exception\ContextErrorException')) { + require __DIR__.'/Exception/ContextErrorException.php'; + } + if (!class_exists('Symfony\Component\Debug\Exception\FlattenException')) { + require __DIR__.'/Exception/FlattenException.php'; + } + + if (PHP_VERSION_ID < 50400 && isset($context['GLOBALS']) && is_array($context)) { + unset($context['GLOBALS']); + } + + $exception = new ContextErrorException(sprintf('%s: %s in %s line %d', isset($this->levels[$level]) ? $this->levels[$level] : $level, $message, $file, $line), 0, $level, $file, $line, $context); + + // Exceptions thrown from error handlers are sometimes not caught by the exception + // handler, so we invoke it directly (https://bugs.php.net/bug.php?id=54275) + $exceptionHandler = set_exception_handler(function () {}); + restore_exception_handler(); + + if (is_array($exceptionHandler) && $exceptionHandler[0] instanceof ExceptionHandler) { + $exceptionHandler[0]->handle($exception); + + if (!class_exists('Symfony\Component\Debug\Exception\DummyException')) { + require __DIR__.'/Exception/DummyException.php'; + } + + // we must stop the PHP script execution, as the exception has + // already been dealt with, so, let's throw an exception that + // will be caught by a dummy exception handler + set_exception_handler(function (\Exception $e) use ($exceptionHandler) { + if (!$e instanceof DummyException) { + // happens if our dummy exception is caught by a + // catch-all from user code, in which case, let's the + // current handler handle this "new" exception + call_user_func($exceptionHandler, $e); + } + }); + + throw new DummyException(); + } + } + + return false; + } + + public function handleFatal() + { + if (null === $error = error_get_last()) { + return; + } + + $this->reservedMemory = ''; + $type = $error['type']; + if (0 === $this->level || !in_array($type, array(E_ERROR, E_CORE_ERROR, E_COMPILE_ERROR, E_PARSE))) { + return; + } + + if (isset(self::$loggers['emergency'])) { + $fatal = array( + 'type' => $type, + 'file' => $error['file'], + 'line' => $error['line'], + ); + + self::$loggers['emergency']->emerg($error['message'], $fatal); + } + + if (!$this->displayErrors) { + return; + } + + // get current exception handler + $exceptionHandler = set_exception_handler(function () {}); + restore_exception_handler(); + + if (is_array($exceptionHandler) && $exceptionHandler[0] instanceof ExceptionHandler) { + $this->handleFatalError($exceptionHandler[0], $error); + } + } + + /** + * Gets the fatal error handlers. + * + * Override this method if you want to define more fatal error handlers. + * + * @return FatalErrorHandlerInterface[] An array of FatalErrorHandlerInterface + */ + protected function getFatalErrorHandlers() + { + return array( + new UndefinedFunctionFatalErrorHandler(), + new ClassNotFoundFatalErrorHandler(), + ); + } + + private function handleFatalError(ExceptionHandler $exceptionHandler, array $error) + { + $level = isset($this->levels[$error['type']]) ? $this->levels[$error['type']] : $error['type']; + $message = sprintf('%s: %s in %s line %d', $level, $error['message'], $error['file'], $error['line']); + $exception = new FatalErrorException($message, 0, $error['type'], $error['file'], $error['line']); + + foreach ($this->getFatalErrorHandlers() as $handler) { + if ($ex = $handler->handleError($error, $exception)) { + return $exceptionHandler->handle($ex); + } + } + + $exceptionHandler->handle($exception); + } +} diff --git a/vendor/symfony/debug/Symfony/Component/Debug/Exception/ClassNotFoundException.php b/vendor/symfony/debug/Symfony/Component/Debug/Exception/ClassNotFoundException.php new file mode 100755 index 0000000..94169b4 --- /dev/null +++ b/vendor/symfony/debug/Symfony/Component/Debug/Exception/ClassNotFoundException.php @@ -0,0 +1,32 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Debug\Exception; + +/** + * Class (or Trait or Interface) Not Found Exception. + * + * @author Konstanton Myakshin + */ +class ClassNotFoundException extends FatalErrorException +{ + public function __construct($message, \ErrorException $previous) + { + parent::__construct( + $message, + $previous->getCode(), + $previous->getSeverity(), + $previous->getFile(), + $previous->getLine(), + $previous->getPrevious() + ); + } +} diff --git a/vendor/symfony/debug/Symfony/Component/Debug/Exception/ContextErrorException.php b/vendor/symfony/debug/Symfony/Component/Debug/Exception/ContextErrorException.php new file mode 100755 index 0000000..54f0198 --- /dev/null +++ b/vendor/symfony/debug/Symfony/Component/Debug/Exception/ContextErrorException.php @@ -0,0 +1,36 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Debug\Exception; + +/** + * Error Exception with Variable Context. + * + * @author Christian Sciberras + */ +class ContextErrorException extends \ErrorException +{ + private $context = array(); + + public function __construct($message, $code, $severity, $filename, $lineno, $context = array()) + { + parent::__construct($message, $code, $severity, $filename, $lineno); + $this->context = $context; + } + + /** + * @return array Array of variables that existed when the exception occurred + */ + public function getContext() + { + return $this->context; + } +} diff --git a/vendor/symfony/debug/Symfony/Component/Debug/Exception/DummyException.php b/vendor/symfony/debug/Symfony/Component/Debug/Exception/DummyException.php new file mode 100755 index 0000000..8891f2f --- /dev/null +++ b/vendor/symfony/debug/Symfony/Component/Debug/Exception/DummyException.php @@ -0,0 +1,21 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Debug\Exception; + +/** + * Used to stop execution of a PHP script after handling a fatal error. + * + * @author Fabien Potencier + */ +class DummyException extends \ErrorException +{ +} diff --git a/vendor/symfony/debug/Symfony/Component/Debug/Exception/FatalErrorException.php b/vendor/symfony/debug/Symfony/Component/Debug/Exception/FatalErrorException.php new file mode 100755 index 0000000..bf37ef8 --- /dev/null +++ b/vendor/symfony/debug/Symfony/Component/Debug/Exception/FatalErrorException.php @@ -0,0 +1,21 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Debug\Exception; + +/** + * Fatal Error Exception. + * + * @author Konstanton Myakshin + */ +class FatalErrorException extends \ErrorException +{ +} diff --git a/vendor/symfony/debug/Symfony/Component/Debug/Exception/FlattenException.php b/vendor/symfony/debug/Symfony/Component/Debug/Exception/FlattenException.php new file mode 100755 index 0000000..878ac4d --- /dev/null +++ b/vendor/symfony/debug/Symfony/Component/Debug/Exception/FlattenException.php @@ -0,0 +1,277 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Debug\Exception; + +use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface; + +/** + * FlattenException wraps a PHP Exception to be able to serialize it. + * + * Basically, this class removes all objects from the trace. + * + * @author Fabien Potencier + */ +class FlattenException +{ + private $message; + private $code; + private $previous; + private $trace; + private $class; + private $statusCode; + private $headers; + private $file; + private $line; + + public static function create(\Exception $exception, $statusCode = null, array $headers = array()) + { + $e = new static(); + $e->setMessage($exception->getMessage()); + $e->setCode($exception->getCode()); + + if ($exception instanceof HttpExceptionInterface) { + $statusCode = $exception->getStatusCode(); + $headers = array_merge($headers, $exception->getHeaders()); + } + + if (null === $statusCode) { + $statusCode = 500; + } + + $e->setStatusCode($statusCode); + $e->setHeaders($headers); + $e->setTraceFromException($exception); + $e->setClass(get_class($exception)); + $e->setFile($exception->getFile()); + $e->setLine($exception->getLine()); + if ($exception->getPrevious()) { + $e->setPrevious(static::create($exception->getPrevious())); + } + + return $e; + } + + public function toArray() + { + $exceptions = array(); + foreach (array_merge(array($this), $this->getAllPrevious()) as $exception) { + $exceptions[] = array( + 'message' => $exception->getMessage(), + 'class' => $exception->getClass(), + 'trace' => $exception->getTrace(), + ); + } + + return $exceptions; + } + + public function getStatusCode() + { + return $this->statusCode; + } + + public function setStatusCode($code) + { + $this->statusCode = $code; + } + + public function getHeaders() + { + return $this->headers; + } + + public function setHeaders(array $headers) + { + $this->headers = $headers; + } + + public function getClass() + { + return $this->class; + } + + public function setClass($class) + { + $this->class = $class; + } + + public function getFile() + { + return $this->file; + } + + public function setFile($file) + { + $this->file = $file; + } + + public function getLine() + { + return $this->line; + } + + public function setLine($line) + { + $this->line = $line; + } + + public function getMessage() + { + return $this->message; + } + + public function setMessage($message) + { + $this->message = $message; + } + + public function getCode() + { + return $this->code; + } + + public function setCode($code) + { + $this->code = $code; + } + + public function getPrevious() + { + return $this->previous; + } + + public function setPrevious(FlattenException $previous) + { + $this->previous = $previous; + } + + public function getAllPrevious() + { + $exceptions = array(); + $e = $this; + while ($e = $e->getPrevious()) { + $exceptions[] = $e; + } + + return $exceptions; + } + + public function getTrace() + { + return $this->trace; + } + + public function setTraceFromException(\Exception $exception) + { + $trace = $exception->getTrace(); + + if ($exception instanceof FatalErrorException) { + if (function_exists('xdebug_get_function_stack')) { + $trace = array_slice(array_reverse(xdebug_get_function_stack()), 4); + + foreach ($trace as $i => $frame) { + // XDebug pre 2.1.1 doesn't currently set the call type key http://bugs.xdebug.org/view.php?id=695 + if (!isset($frame['type'])) { + $trace[$i]['type'] = '??'; + } + + if ('dynamic' === $trace[$i]['type']) { + $trace[$i]['type'] = '->'; + } elseif ('static' === $trace[$i]['type']) { + $trace[$i]['type'] = '::'; + } + + // XDebug also has a different name for the parameters array + if (isset($frame['params']) && !isset($frame['args'])) { + $trace[$i]['args'] = $frame['params']; + unset($trace[$i]['params']); + } + } + } else { + $trace = array_slice(array_reverse($trace), 1); + } + } + + $this->setTrace($trace, $exception->getFile(), $exception->getLine()); + } + + public function setTrace($trace, $file, $line) + { + $this->trace = array(); + $this->trace[] = array( + 'namespace' => '', + 'short_class' => '', + 'class' => '', + 'type' => '', + 'function' => '', + 'file' => $file, + 'line' => $line, + 'args' => array(), + ); + foreach ($trace as $entry) { + $class = ''; + $namespace = ''; + if (isset($entry['class'])) { + $parts = explode('\\', $entry['class']); + $class = array_pop($parts); + $namespace = implode('\\', $parts); + } + + $this->trace[] = array( + 'namespace' => $namespace, + 'short_class' => $class, + 'class' => isset($entry['class']) ? $entry['class'] : '', + 'type' => isset($entry['type']) ? $entry['type'] : '', + 'function' => isset($entry['function']) ? $entry['function'] : null, + 'file' => isset($entry['file']) ? $entry['file'] : null, + 'line' => isset($entry['line']) ? $entry['line'] : null, + 'args' => isset($entry['args']) ? $this->flattenArgs($entry['args']) : array(), + ); + } + } + + private function flattenArgs($args, $level = 0) + { + $result = array(); + foreach ($args as $key => $value) { + if (is_object($value)) { + $result[$key] = array('object', get_class($value)); + } elseif (is_array($value)) { + if ($level > 10) { + $result[$key] = array('array', '*DEEP NESTED ARRAY*'); + } else { + $result[$key] = array('array', $this->flattenArgs($value, $level + 1)); + } + } elseif (null === $value) { + $result[$key] = array('null', null); + } elseif (is_bool($value)) { + $result[$key] = array('boolean', $value); + } elseif (is_resource($value)) { + $result[$key] = array('resource', get_resource_type($value)); + } elseif ($value instanceof \__PHP_Incomplete_Class) { + // Special case of object, is_object will return false + $result[$key] = array('incomplete-object', $this->getClassNameFromIncomplete($value)); + } else { + $result[$key] = array('string', (string) $value); + } + } + + return $result; + } + + private function getClassNameFromIncomplete(\__PHP_Incomplete_Class $value) + { + $array = new \ArrayObject($value); + + return $array['__PHP_Incomplete_Class_Name']; + } +} diff --git a/vendor/symfony/debug/Symfony/Component/Debug/Exception/UndefinedFunctionException.php b/vendor/symfony/debug/Symfony/Component/Debug/Exception/UndefinedFunctionException.php new file mode 100755 index 0000000..572c8b3 --- /dev/null +++ b/vendor/symfony/debug/Symfony/Component/Debug/Exception/UndefinedFunctionException.php @@ -0,0 +1,32 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Debug\Exception; + +/** + * Undefined Function Exception. + * + * @author Konstanton Myakshin + */ +class UndefinedFunctionException extends FatalErrorException +{ + public function __construct($message, \ErrorException $previous) + { + parent::__construct( + $message, + $previous->getCode(), + $previous->getSeverity(), + $previous->getFile(), + $previous->getLine(), + $previous->getPrevious() + ); + } +} diff --git a/vendor/symfony/debug/Symfony/Component/Debug/ExceptionHandler.php b/vendor/symfony/debug/Symfony/Component/Debug/ExceptionHandler.php new file mode 100755 index 0000000..9688c71 --- /dev/null +++ b/vendor/symfony/debug/Symfony/Component/Debug/ExceptionHandler.php @@ -0,0 +1,318 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Debug; + +use Symfony\Component\HttpFoundation\Response; +use Symfony\Component\Debug\Exception\FlattenException; + +if (!defined('ENT_SUBSTITUTE')) { + define('ENT_SUBSTITUTE', 8); +} + +/** + * ExceptionHandler converts an exception to a Response object. + * + * It is mostly useful in debug mode to replace the default PHP/XDebug + * output with something prettier and more useful. + * + * As this class is mainly used during Kernel boot, where nothing is yet + * available, the Response content is always HTML. + * + * @author Fabien Potencier + */ +class ExceptionHandler +{ + private $debug; + private $charset; + + public function __construct($debug = true, $charset = 'UTF-8') + { + $this->debug = $debug; + $this->charset = $charset; + } + + /** + * Registers the exception handler. + * + * @param bool $debug + * + * @return ExceptionHandler The registered exception handler + */ + public static function register($debug = true) + { + $handler = new static($debug); + + set_exception_handler(array($handler, 'handle')); + + return $handler; + } + + /** + * Sends a response for the given Exception. + * + * If you have the Symfony HttpFoundation component installed, + * this method will use it to create and send the response. If not, + * it will fallback to plain PHP functions. + * + * @param \Exception $exception An \Exception instance + * + * @see sendPhpResponse + * @see createResponse + */ + public function handle(\Exception $exception) + { + if (class_exists('Symfony\Component\HttpFoundation\Response')) { + $this->createResponse($exception)->send(); + } else { + $this->sendPhpResponse($exception); + } + } + + /** + * Sends the error associated with the given Exception as a plain PHP response. + * + * This method uses plain PHP functions like header() and echo to output + * the response. + * + * @param \Exception|FlattenException $exception An \Exception instance + */ + public function sendPhpResponse($exception) + { + if (!$exception instanceof FlattenException) { + $exception = FlattenException::create($exception); + } + + if (!headers_sent()) { + header(sprintf('HTTP/1.0 %s', $exception->getStatusCode())); + foreach ($exception->getHeaders() as $name => $value) { + header($name.': '.$value, false); + } + } + + echo $this->decorate($this->getContent($exception), $this->getStylesheet($exception)); + } + + /** + * Creates the error Response associated with the given Exception. + * + * @param \Exception|FlattenException $exception An \Exception instance + * + * @return Response A Response instance + */ + public function createResponse($exception) + { + if (!$exception instanceof FlattenException) { + $exception = FlattenException::create($exception); + } + + return new Response($this->decorate($this->getContent($exception), $this->getStylesheet($exception)), $exception->getStatusCode(), $exception->getHeaders()); + } + + /** + * Gets the HTML content associated with the given exception. + * + * @param FlattenException $exception A FlattenException instance + * + * @return string The content as a string + */ + public function getContent(FlattenException $exception) + { + switch ($exception->getStatusCode()) { + case 404: + $title = 'Sorry, the page you are looking for could not be found.'; + break; + default: + $title = 'Whoops, looks like something went wrong.'; + } + + $content = ''; + if ($this->debug) { + try { + $count = count($exception->getAllPrevious()); + $total = $count + 1; + foreach ($exception->toArray() as $position => $e) { + $ind = $count - $position + 1; + $class = $this->abbrClass($e['class']); + $message = nl2br($e['message']); + $content .= sprintf(<< +

    %d/%d %s: %s

    + +
    +
      + +EOF + , $ind, $total, $class, $message); + foreach ($e['trace'] as $trace) { + $content .= '
    1. '; + if ($trace['function']) { + $content .= sprintf('at %s%s%s(%s)', $this->abbrClass($trace['class']), $trace['type'], $trace['function'], $this->formatArgs($trace['args'])); + } + if (isset($trace['file']) && isset($trace['line'])) { + if ($linkFormat = ini_get('xdebug.file_link_format')) { + $link = str_replace(array('%f', '%l'), array($trace['file'], $trace['line']), $linkFormat); + $content .= sprintf(' in %s line %s', $link, $trace['file'], $trace['line']); + } else { + $content .= sprintf(' in %s line %s', $trace['file'], $trace['line']); + } + } + $content .= "
    2. \n"; + } + + $content .= "
    \n
    \n"; + } + } catch (\Exception $e) { + // something nasty happened and we cannot throw an exception anymore + if ($this->debug) { + $title = sprintf('Exception thrown when handling an exception (%s: %s)', get_class($exception), $exception->getMessage()); + } else { + $title = 'Whoops, looks like something went wrong.'; + } + } + } + + return << +

    $title

    + $content + +EOF; + } + + /** + * Gets the stylesheet associated with the given exception. + * + * @param FlattenException $exception A FlattenException instance + * + * @return string The stylesheet as a string + */ + public function getStylesheet(FlattenException $exception) + { + return << + + + + + + + + $content + + +EOF; + } + + private function abbrClass($class) + { + $parts = explode('\\', $class); + + return sprintf("%s", $class, array_pop($parts)); + } + + /** + * Formats an array as a string. + * + * @param array $args The argument array + * + * @return string + */ + private function formatArgs(array $args) + { + $result = array(); + foreach ($args as $key => $item) { + if ('object' === $item[0]) { + $formattedValue = sprintf("object(%s)", $this->abbrClass($item[1])); + } elseif ('array' === $item[0]) { + $formattedValue = sprintf("array(%s)", is_array($item[1]) ? $this->formatArgs($item[1]) : $item[1]); + } elseif ('string' === $item[0]) { + $formattedValue = sprintf("'%s'", htmlspecialchars($item[1], ENT_QUOTES | ENT_SUBSTITUTE, $this->charset)); + } elseif ('null' === $item[0]) { + $formattedValue = 'null'; + } elseif ('boolean' === $item[0]) { + $formattedValue = ''.strtolower(var_export($item[1], true)).''; + } elseif ('resource' === $item[0]) { + $formattedValue = 'resource'; + } else { + $formattedValue = str_replace("\n", '', var_export(htmlspecialchars((string) $item[1], ENT_QUOTES | ENT_SUBSTITUTE, $this->charset), true)); + } + + $result[] = is_int($key) ? $formattedValue : sprintf("'%s' => %s", $key, $formattedValue); + } + + return implode(', ', $result); + } +} diff --git a/vendor/symfony/debug/Symfony/Component/Debug/FatalErrorHandler/ClassNotFoundFatalErrorHandler.php b/vendor/symfony/debug/Symfony/Component/Debug/FatalErrorHandler/ClassNotFoundFatalErrorHandler.php new file mode 100755 index 0000000..1554a81 --- /dev/null +++ b/vendor/symfony/debug/Symfony/Component/Debug/FatalErrorHandler/ClassNotFoundFatalErrorHandler.php @@ -0,0 +1,181 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Debug\FatalErrorHandler; + +use Symfony\Component\Debug\Exception\ClassNotFoundException; +use Symfony\Component\Debug\Exception\FatalErrorException; +use Symfony\Component\Debug\DebugClassLoader; +use Composer\Autoload\ClassLoader as ComposerClassLoader; +use Symfony\Component\ClassLoader as SymfonyClassLoader; + +/** + * ErrorHandler for classes that do not exist. + * + * @author Fabien Potencier + */ +class ClassNotFoundFatalErrorHandler implements FatalErrorHandlerInterface +{ + /** + * {@inheritdoc} + */ + public function handleError(array $error, FatalErrorException $exception) + { + $messageLen = strlen($error['message']); + $notFoundSuffix = '\' not found'; + $notFoundSuffixLen = strlen($notFoundSuffix); + if ($notFoundSuffixLen > $messageLen) { + return; + } + + if (0 !== substr_compare($error['message'], $notFoundSuffix, -$notFoundSuffixLen)) { + return; + } + + foreach (array('class', 'interface', 'trait') as $typeName) { + $prefix = ucfirst($typeName).' \''; + $prefixLen = strlen($prefix); + if (0 !== strpos($error['message'], $prefix)) { + continue; + } + + $fullyQualifiedClassName = substr($error['message'], $prefixLen, -$notFoundSuffixLen); + if (false !== $namespaceSeparatorIndex = strrpos($fullyQualifiedClassName, '\\')) { + $className = substr($fullyQualifiedClassName, $namespaceSeparatorIndex + 1); + $namespacePrefix = substr($fullyQualifiedClassName, 0, $namespaceSeparatorIndex); + $message = sprintf( + 'Attempted to load %s "%s" from namespace "%s" in %s line %d. Do you need to "use" it from another namespace?', + $typeName, + $className, + $namespacePrefix, + $error['file'], + $error['line'] + ); + } else { + $className = $fullyQualifiedClassName; + $message = sprintf( + 'Attempted to load %s "%s" from the global namespace in %s line %d. Did you forget a use statement for this %s?', + $typeName, + $className, + $error['file'], + $error['line'], + $typeName + ); + } + + if ($classes = $this->getClassCandidates($className)) { + $message .= sprintf(' Perhaps you need to add a use statement for one of the following: %s.', implode(', ', $classes)); + } + + return new ClassNotFoundException($message, $exception); + } + } + + /** + * Tries to guess the full namespace for a given class name. + * + * By default, it looks for PSR-0 classes registered via a Symfony or a Composer + * autoloader (that should cover all common cases). + * + * @param string $class A class name (without its namespace) + * + * @return array An array of possible fully qualified class names + */ + private function getClassCandidates($class) + { + if (!is_array($functions = spl_autoload_functions())) { + return array(); + } + + // find Symfony and Composer autoloaders + $classes = array(); + foreach ($functions as $function) { + if (!is_array($function)) { + continue; + } + + // get class loaders wrapped by DebugClassLoader + if ($function[0] instanceof DebugClassLoader && method_exists($function[0], 'getClassLoader')) { + $function[0] = $function[0]->getClassLoader(); + } + + if ($function[0] instanceof ComposerClassLoader || $function[0] instanceof SymfonyClassLoader) { + foreach ($function[0]->getPrefixes() as $paths) { + foreach ($paths as $path) { + $classes = array_merge($classes, $this->findClassInPath($path, $class)); + } + } + } + } + + return $classes; + } + + /** + * @param string $path + * @param string $class + * + * @return array + */ + private function findClassInPath($path, $class) + { + if (!$path = realpath($path)) { + return array(); + } + + $classes = array(); + $filename = $class.'.php'; + foreach (new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($path), \RecursiveIteratorIterator::LEAVES_ONLY) as $file) { + if ($filename == $file->getFileName() && $class = $this->convertFileToClass($path, $file->getPathName())) { + $classes[] = $class; + } + } + + return $classes; + } + + /** + * @param string $path + * @param string $file + * + * @return string|null + */ + private function convertFileToClass($path, $file) + { + $namespacedClass = str_replace(array($path.DIRECTORY_SEPARATOR, '.php', '/'), array('', '', '\\'), $file); + $pearClass = str_replace('\\', '_', $namespacedClass); + + // We cannot use the autoloader here as most of them use require; but if the class + // is not found, the new autoloader call will require the file again leading to a + // "cannot redeclare class" error. + if (!$this->classExists($namespacedClass) && !$this->classExists($pearClass)) { + require_once $file; + } + + if ($this->classExists($namespacedClass)) { + return $namespacedClass; + } + + if ($this->classExists($pearClass)) { + return $pearClass; + } + } + + /** + * @param string $class + * + * @return bool + */ + private function classExists($class) + { + return class_exists($class, false) || interface_exists($class, false) || (function_exists('trait_exists') && trait_exists($class, false)); + } +} diff --git a/vendor/symfony/debug/Symfony/Component/Debug/FatalErrorHandler/FatalErrorHandlerInterface.php b/vendor/symfony/debug/Symfony/Component/Debug/FatalErrorHandler/FatalErrorHandlerInterface.php new file mode 100755 index 0000000..6b87eb3 --- /dev/null +++ b/vendor/symfony/debug/Symfony/Component/Debug/FatalErrorHandler/FatalErrorHandlerInterface.php @@ -0,0 +1,32 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Debug\FatalErrorHandler; + +use Symfony\Component\Debug\Exception\FatalErrorException; + +/** + * Attempts to convert fatal errors to exceptions. + * + * @author Fabien Potencier + */ +interface FatalErrorHandlerInterface +{ + /** + * Attempts to convert an error into an exception. + * + * @param array $error An array as returned by error_get_last() + * @param FatalErrorException $exception A FatalErrorException instance + * + * @return FatalErrorException|null A FatalErrorException instance if the class is able to convert the error, null otherwise + */ + public function handleError(array $error, FatalErrorException $exception); +} diff --git a/vendor/symfony/debug/Symfony/Component/Debug/FatalErrorHandler/UndefinedFunctionFatalErrorHandler.php b/vendor/symfony/debug/Symfony/Component/Debug/FatalErrorHandler/UndefinedFunctionFatalErrorHandler.php new file mode 100755 index 0000000..4b6fc90 --- /dev/null +++ b/vendor/symfony/debug/Symfony/Component/Debug/FatalErrorHandler/UndefinedFunctionFatalErrorHandler.php @@ -0,0 +1,90 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Debug\FatalErrorHandler; + +use Symfony\Component\Debug\Exception\UndefinedFunctionException; +use Symfony\Component\Debug\Exception\FatalErrorException; + +/** + * ErrorHandler for undefined functions. + * + * @author Fabien Potencier + */ +class UndefinedFunctionFatalErrorHandler implements FatalErrorHandlerInterface +{ + /** + * {@inheritdoc} + */ + public function handleError(array $error, FatalErrorException $exception) + { + $messageLen = strlen($error['message']); + $notFoundSuffix = '()'; + $notFoundSuffixLen = strlen($notFoundSuffix); + if ($notFoundSuffixLen > $messageLen) { + return; + } + + if (0 !== substr_compare($error['message'], $notFoundSuffix, -$notFoundSuffixLen)) { + return; + } + + $prefix = 'Call to undefined function '; + $prefixLen = strlen($prefix); + if (0 !== strpos($error['message'], $prefix)) { + return; + } + + $fullyQualifiedFunctionName = substr($error['message'], $prefixLen, -$notFoundSuffixLen); + if (false !== $namespaceSeparatorIndex = strrpos($fullyQualifiedFunctionName, '\\')) { + $functionName = substr($fullyQualifiedFunctionName, $namespaceSeparatorIndex + 1); + $namespacePrefix = substr($fullyQualifiedFunctionName, 0, $namespaceSeparatorIndex); + $message = sprintf( + 'Attempted to call function "%s" from namespace "%s" in %s line %d.', + $functionName, + $namespacePrefix, + $error['file'], + $error['line'] + ); + } else { + $functionName = $fullyQualifiedFunctionName; + $message = sprintf( + 'Attempted to call function "%s" from the global namespace in %s line %d.', + $functionName, + $error['file'], + $error['line'] + ); + } + + $candidates = array(); + foreach (get_defined_functions() as $type => $definedFunctionNames) { + foreach ($definedFunctionNames as $definedFunctionName) { + if (false !== $namespaceSeparatorIndex = strrpos($definedFunctionName, '\\')) { + $definedFunctionNameBasename = substr($definedFunctionName, $namespaceSeparatorIndex + 1); + } else { + $definedFunctionNameBasename = $definedFunctionName; + } + + if ($definedFunctionNameBasename === $functionName) { + $candidates[] = '\\'.$definedFunctionName; + } + } + } + + if ($candidates) { + $message .= ' Did you mean to call: '.implode(', ', array_map(function ($val) { + return '"'.$val.'"'; + }, $candidates)).'?'; + } + + return new UndefinedFunctionException($message, $exception); + } +} diff --git a/vendor/symfony/debug/Symfony/Component/Debug/LICENSE b/vendor/symfony/debug/Symfony/Component/Debug/LICENSE new file mode 100755 index 0000000..0b3292c --- /dev/null +++ b/vendor/symfony/debug/Symfony/Component/Debug/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2004-2014 Fabien Potencier + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is furnished +to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/vendor/symfony/debug/Symfony/Component/Debug/README.md b/vendor/symfony/debug/Symfony/Component/Debug/README.md new file mode 100755 index 0000000..dd5bdca --- /dev/null +++ b/vendor/symfony/debug/Symfony/Component/Debug/README.md @@ -0,0 +1,40 @@ +Debug Component +=============== + +Debug provides tools to make debugging easier. + +Enabling all debug tools is as easy as calling the `enable()` method on the +main `Debug` class: + + use Symfony\Component\Debug\Debug; + + Debug::enable(); + +You can also use the tools individually: + + use Symfony\Component\Debug\ErrorHandler; + use Symfony\Component\Debug\ExceptionHandler; + + error_reporting(-1); + + ErrorHandler::register($errorReportingLevel); + if ('cli' !== php_sapi_name()) { + ExceptionHandler::register(); + } elseif (!ini_get('log_errors') || ini_get('error_log')) { + ini_set('display_errors', 1); + } + +Note that the `Debug::enable()` call also registers the debug class loader +from the Symfony ClassLoader component when available. + +This component can optionally take advantage of the features of the HttpKernel +and HttpFoundation components. + +Resources +--------- + +You can run the unit tests with the following command: + + $ cd path/to/Symfony/Component/Debug/ + $ composer.phar install --dev + $ phpunit diff --git a/vendor/symfony/debug/Symfony/Component/Debug/Tests/DebugClassLoaderTest.php b/vendor/symfony/debug/Symfony/Component/Debug/Tests/DebugClassLoaderTest.php new file mode 100755 index 0000000..a18e581 --- /dev/null +++ b/vendor/symfony/debug/Symfony/Component/Debug/Tests/DebugClassLoaderTest.php @@ -0,0 +1,66 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Debug\Tests; + +use Symfony\Component\Debug\DebugClassLoader; + +class DebugClassLoaderTest extends \PHPUnit_Framework_TestCase +{ + private $loader; + + protected function setUp() + { + $this->loader = new ClassLoader(); + spl_autoload_register(array($this->loader, 'loadClass')); + } + + protected function tearDown() + { + spl_autoload_unregister(array($this->loader, 'loadClass')); + } + + public function testIdempotence() + { + DebugClassLoader::enable(); + DebugClassLoader::enable(); + + $functions = spl_autoload_functions(); + foreach ($functions as $function) { + if (is_array($function) && $function[0] instanceof DebugClassLoader) { + $reflClass = new \ReflectionClass($function[0]); + $reflProp = $reflClass->getProperty('classFinder'); + $reflProp->setAccessible(true); + + $this->assertNotInstanceOf('Symfony\Component\Debug\DebugClassLoader', $reflProp->getValue($function[0])); + + DebugClassLoader::disable(); + + return; + } + } + + DebugClassLoader::disable(); + + $this->fail('DebugClassLoader did not register'); + } +} + +class ClassLoader +{ + public function loadClass($class) + { + } + + public function findFile($class) + { + } +} diff --git a/vendor/symfony/debug/Symfony/Component/Debug/Tests/ErrorHandlerTest.php b/vendor/symfony/debug/Symfony/Component/Debug/Tests/ErrorHandlerTest.php new file mode 100755 index 0000000..e764b4d --- /dev/null +++ b/vendor/symfony/debug/Symfony/Component/Debug/Tests/ErrorHandlerTest.php @@ -0,0 +1,294 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Debug\Tests; + +use Symfony\Component\Debug\ErrorHandler; +use Symfony\Component\Debug\Exception\DummyException; + +/** + * ErrorHandlerTest + * + * @author Robert Schönthal + */ +class ErrorHandlerTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var int Error reporting level before running tests. + */ + protected $errorReporting; + + /** + * @var string Display errors setting before running tests. + */ + protected $displayErrors; + + public function setUp() + { + $this->errorReporting = error_reporting(E_ALL | E_STRICT); + $this->displayErrors = ini_get('display_errors'); + ini_set('display_errors', '1'); + } + + public function tearDown() + { + ini_set('display_errors', $this->displayErrors); + error_reporting($this->errorReporting); + } + + public function testCompileTimeError() + { + // the ContextErrorException must not be loaded to test the workaround + // for https://bugs.php.net/bug.php?id=65322. + if (class_exists('Symfony\Component\Debug\Exception\ContextErrorException', false)) { + $this->markTestSkipped('The ContextErrorException class is already loaded.'); + } + + $exceptionHandler = $this->getMock('Symfony\Component\Debug\ExceptionHandler', array('handle')); + + // the following code forces some PHPUnit classes to be loaded + // so that they will be available in the exception handler + // as they won't be autoloaded by PHP + class_exists('PHPUnit_Framework_MockObject_Invocation_Object'); + $this->assertInstanceOf('stdClass', new \stdClass()); + $this->assertEquals(1, 1); + $this->assertStringStartsWith('foo', 'foobar'); + $this->assertArrayHasKey('bar', array('bar' => 'foo')); + + $that = $this; + $exceptionCheck = function ($exception) use ($that) { + $that->assertInstanceOf('Symfony\Component\Debug\Exception\ContextErrorException', $exception); + $that->assertEquals(E_STRICT, $exception->getSeverity()); + $that->assertEquals(2, $exception->getLine()); + $that->assertStringStartsWith('Runtime Notice: Declaration of _CompileTimeError::foo() should be compatible with', $exception->getMessage()); + $that->assertArrayHasKey('bar', $exception->getContext()); + }; + + $exceptionHandler->expects($this->once()) + ->method('handle') + ->will($this->returnCallback($exceptionCheck)) + ; + + ErrorHandler::register(); + set_exception_handler(array($exceptionHandler, 'handle')); + + // dummy variable to check for in error handler. + $bar = 123; + + // trigger compile time error + try { + eval(<<<'PHP' +class _BaseCompileTimeError { function foo() {} } +class _CompileTimeError extends _BaseCompileTimeError { function foo($invalid) {} } +PHP + ); + } catch (DummyException $e) { + // if an exception is thrown, the test passed + } catch (\Exception $e) { + restore_error_handler(); + restore_exception_handler(); + + throw $e; + } + + restore_error_handler(); + restore_exception_handler(); + } + + public function testNotice() + { + $exceptionHandler = $this->getMock('Symfony\Component\Debug\ExceptionHandler', array('handle')); + set_exception_handler(array($exceptionHandler, 'handle')); + + $that = $this; + $exceptionCheck = function ($exception) use ($that) { + $that->assertInstanceOf('Symfony\Component\Debug\Exception\ContextErrorException', $exception); + $that->assertEquals(E_NOTICE, $exception->getSeverity()); + $that->assertEquals(__LINE__ + 44, $exception->getLine()); + $that->assertEquals(__FILE__, $exception->getFile()); + $that->assertRegexp('/^Notice: Undefined variable: (foo|bar)/', $exception->getMessage()); + $that->assertArrayHasKey('foobar', $exception->getContext()); + + $trace = $exception->getTrace(); + $that->assertEquals(__FILE__, $trace[0]['file']); + $that->assertEquals('Symfony\Component\Debug\ErrorHandler', $trace[0]['class']); + $that->assertEquals('handle', $trace[0]['function']); + $that->assertEquals('->', $trace[0]['type']); + + $that->assertEquals(__FILE__, $trace[1]['file']); + $that->assertEquals(__CLASS__, $trace[1]['class']); + $that->assertEquals('triggerNotice', $trace[1]['function']); + $that->assertEquals('::', $trace[1]['type']); + + $that->assertEquals(__CLASS__, $trace[2]['class']); + $that->assertEquals('testNotice', $trace[2]['function']); + $that->assertEquals('->', $trace[2]['type']); + }; + + $exceptionHandler->expects($this->once()) + ->method('handle') + ->will($this->returnCallback($exceptionCheck)); + ErrorHandler::register(); + + try { + self::triggerNotice($this); + } catch (DummyException $e) { + // if an exception is thrown, the test passed + } catch (\Exception $e) { + restore_error_handler(); + + throw $e; + } + + restore_error_handler(); + } + + // dummy function to test trace in error handler. + private static function triggerNotice($that) + { + // dummy variable to check for in error handler. + $foobar = 123; + $that->assertSame('', $foo.$foo.$bar); + } + + public function testConstruct() + { + try { + $handler = ErrorHandler::register(3); + + $level = new \ReflectionProperty($handler, 'level'); + $level->setAccessible(true); + + $this->assertEquals(3, $level->getValue($handler)); + + restore_error_handler(); + } catch (\Exception $e) { + restore_error_handler(); + + throw $e; + } + } + + public function testHandle() + { + try { + $handler = ErrorHandler::register(0); + $this->assertFalse($handler->handle(0, 'foo', 'foo.php', 12, array())); + + restore_error_handler(); + + $handler = ErrorHandler::register(3); + $this->assertFalse($handler->handle(4, 'foo', 'foo.php', 12, array())); + + restore_error_handler(); + + $handler = ErrorHandler::register(3); + try { + $handler->handle(111, 'foo', 'foo.php', 12, array()); + } catch (\ErrorException $e) { + $this->assertSame('111: foo in foo.php line 12', $e->getMessage()); + $this->assertSame(111, $e->getSeverity()); + $this->assertSame('foo.php', $e->getFile()); + $this->assertSame(12, $e->getLine()); + } + + restore_error_handler(); + + $handler = ErrorHandler::register(E_USER_DEPRECATED); + $this->assertTrue($handler->handle(E_USER_DEPRECATED, 'foo', 'foo.php', 12, array())); + + restore_error_handler(); + + $handler = ErrorHandler::register(E_DEPRECATED); + $this->assertTrue($handler->handle(E_DEPRECATED, 'foo', 'foo.php', 12, array())); + + restore_error_handler(); + + $logger = $this->getMock('Psr\Log\LoggerInterface'); + + $that = $this; + $warnArgCheck = function ($message, $context) use ($that) { + $that->assertEquals('foo', $message); + $that->assertArrayHasKey('type', $context); + $that->assertEquals($context['type'], ErrorHandler::TYPE_DEPRECATION); + $that->assertArrayHasKey('stack', $context); + $that->assertInternalType('array', $context['stack']); + }; + + $logger + ->expects($this->once()) + ->method('warning') + ->will($this->returnCallback($warnArgCheck)) + ; + + $handler = ErrorHandler::register(E_USER_DEPRECATED); + $handler->setLogger($logger); + $handler->handle(E_USER_DEPRECATED, 'foo', 'foo.php', 12, array()); + + restore_error_handler(); + } catch (\Exception $e) { + restore_error_handler(); + + throw $e; + } + } + + /** + * @dataProvider provideFatalErrorHandlersData + */ + public function testFatalErrorHandlers($error, $class, $translatedMessage) + { + $handler = new ErrorHandler(); + $exceptionHandler = new MockExceptionHandler(); + + $m = new \ReflectionMethod($handler, 'handleFatalError'); + $m->setAccessible(true); + $m->invoke($handler, $exceptionHandler, $error); + + $this->assertInstanceof($class, $exceptionHandler->e); + $this->assertSame($translatedMessage, $exceptionHandler->e->getMessage()); + $this->assertSame($error['type'], $exceptionHandler->e->getSeverity()); + $this->assertSame($error['file'], $exceptionHandler->e->getFile()); + $this->assertSame($error['line'], $exceptionHandler->e->getLine()); + } + + public function provideFatalErrorHandlersData() + { + return array( + // undefined function + array( + array( + 'type' => 1, + 'line' => 12, + 'file' => 'foo.php', + 'message' => 'Call to undefined function test_namespaced_function_again()', + ), + 'Symfony\Component\Debug\Exception\UndefinedFunctionException', + 'Attempted to call function "test_namespaced_function_again" from the global namespace in foo.php line 12. Did you mean to call: "\\symfony\\component\\debug\\tests\\test_namespaced_function_again"?', + ), + // class not found + array( + array( + 'type' => 1, + 'line' => 12, + 'file' => 'foo.php', + 'message' => 'Class \'WhizBangFactory\' not found', + ), + 'Symfony\Component\Debug\Exception\ClassNotFoundException', + 'Attempted to load class "WhizBangFactory" from the global namespace in foo.php line 12. Did you forget a use statement for this class?', + ), + ); + } +} + +function test_namespaced_function_again() +{ +} diff --git a/vendor/symfony/debug/Symfony/Component/Debug/Tests/Exception/FlattenExceptionTest.php b/vendor/symfony/debug/Symfony/Component/Debug/Tests/Exception/FlattenExceptionTest.php new file mode 100755 index 0000000..4caa9ed --- /dev/null +++ b/vendor/symfony/debug/Symfony/Component/Debug/Tests/Exception/FlattenExceptionTest.php @@ -0,0 +1,235 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Debug\Tests\Exception; + +use Symfony\Component\Debug\Exception\FlattenException; +use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; +use Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException; +use Symfony\Component\HttpKernel\Exception\UnauthorizedHttpException; +use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; +use Symfony\Component\HttpKernel\Exception\NotAcceptableHttpException; +use Symfony\Component\HttpKernel\Exception\ConflictHttpException; +use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; +use Symfony\Component\HttpKernel\Exception\GoneHttpException; +use Symfony\Component\HttpKernel\Exception\LengthRequiredHttpException; +use Symfony\Component\HttpKernel\Exception\PreconditionFailedHttpException; +use Symfony\Component\HttpKernel\Exception\PreconditionRequiredHttpException; +use Symfony\Component\HttpKernel\Exception\ServiceUnavailableHttpException; +use Symfony\Component\HttpKernel\Exception\TooManyRequestsHttpException; +use Symfony\Component\HttpKernel\Exception\UnsupportedMediaTypeHttpException; + +class FlattenExceptionTest extends \PHPUnit_Framework_TestCase +{ + public function testStatusCode() + { + $flattened = FlattenException::create(new \RuntimeException(), 403); + $this->assertEquals('403', $flattened->getStatusCode()); + + $flattened = FlattenException::create(new \RuntimeException()); + $this->assertEquals('500', $flattened->getStatusCode()); + + $flattened = FlattenException::create(new NotFoundHttpException()); + $this->assertEquals('404', $flattened->getStatusCode()); + + $flattened = FlattenException::create(new UnauthorizedHttpException('Basic realm="My Realm"')); + $this->assertEquals('401', $flattened->getStatusCode()); + + $flattened = FlattenException::create(new BadRequestHttpException()); + $this->assertEquals('400', $flattened->getStatusCode()); + + $flattened = FlattenException::create(new NotAcceptableHttpException()); + $this->assertEquals('406', $flattened->getStatusCode()); + + $flattened = FlattenException::create(new ConflictHttpException()); + $this->assertEquals('409', $flattened->getStatusCode()); + + $flattened = FlattenException::create(new MethodNotAllowedHttpException(array('POST'))); + $this->assertEquals('405', $flattened->getStatusCode()); + + $flattened = FlattenException::create(new AccessDeniedHttpException()); + $this->assertEquals('403', $flattened->getStatusCode()); + + $flattened = FlattenException::create(new GoneHttpException()); + $this->assertEquals('410', $flattened->getStatusCode()); + + $flattened = FlattenException::create(new LengthRequiredHttpException()); + $this->assertEquals('411', $flattened->getStatusCode()); + + $flattened = FlattenException::create(new PreconditionFailedHttpException()); + $this->assertEquals('412', $flattened->getStatusCode()); + + $flattened = FlattenException::create(new PreconditionRequiredHttpException()); + $this->assertEquals('428', $flattened->getStatusCode()); + + $flattened = FlattenException::create(new ServiceUnavailableHttpException()); + $this->assertEquals('503', $flattened->getStatusCode()); + + $flattened = FlattenException::create(new TooManyRequestsHttpException()); + $this->assertEquals('429', $flattened->getStatusCode()); + + $flattened = FlattenException::create(new UnsupportedMediaTypeHttpException()); + $this->assertEquals('415', $flattened->getStatusCode()); + } + + public function testHeadersForHttpException() + { + $flattened = FlattenException::create(new MethodNotAllowedHttpException(array('POST'))); + $this->assertEquals(array('Allow' => 'POST'), $flattened->getHeaders()); + + $flattened = FlattenException::create(new UnauthorizedHttpException('Basic realm="My Realm"')); + $this->assertEquals(array('WWW-Authenticate' => 'Basic realm="My Realm"'), $flattened->getHeaders()); + + $flattened = FlattenException::create(new ServiceUnavailableHttpException('Fri, 31 Dec 1999 23:59:59 GMT')); + $this->assertEquals(array('Retry-After' => 'Fri, 31 Dec 1999 23:59:59 GMT'), $flattened->getHeaders()); + + $flattened = FlattenException::create(new ServiceUnavailableHttpException(120)); + $this->assertEquals(array('Retry-After' => 120), $flattened->getHeaders()); + + $flattened = FlattenException::create(new TooManyRequestsHttpException('Fri, 31 Dec 1999 23:59:59 GMT')); + $this->assertEquals(array('Retry-After' => 'Fri, 31 Dec 1999 23:59:59 GMT'), $flattened->getHeaders()); + + $flattened = FlattenException::create(new TooManyRequestsHttpException(120)); + $this->assertEquals(array('Retry-After' => 120), $flattened->getHeaders()); + } + + /** + * @dataProvider flattenDataProvider + */ + public function testFlattenHttpException(\Exception $exception, $statusCode) + { + $flattened = FlattenException::create($exception); + $flattened2 = FlattenException::create($exception); + + $flattened->setPrevious($flattened2); + + $this->assertEquals($exception->getMessage(), $flattened->getMessage(), 'The message is copied from the original exception.'); + $this->assertEquals($exception->getCode(), $flattened->getCode(), 'The code is copied from the original exception.'); + $this->assertInstanceOf($flattened->getClass(), $exception, 'The class is set to the class of the original exception'); + + } + + /** + * @dataProvider flattenDataProvider + */ + public function testPrevious(\Exception $exception, $statusCode) + { + $flattened = FlattenException::create($exception); + $flattened2 = FlattenException::create($exception); + + $flattened->setPrevious($flattened2); + + $this->assertSame($flattened2,$flattened->getPrevious()); + + $this->assertSame(array($flattened2),$flattened->getAllPrevious()); + } + + /** + * @dataProvider flattenDataProvider + */ + public function testLine(\Exception $exception) + { + $flattened = FlattenException::create($exception); + $this->assertSame($exception->getLine(), $flattened->getLine()); + } + + /** + * @dataProvider flattenDataProvider + */ + public function testFile(\Exception $exception) + { + $flattened = FlattenException::create($exception); + $this->assertSame($exception->getFile(), $flattened->getFile()); + } + + /** + * @dataProvider flattenDataProvider + */ + public function testToArray(\Exception $exception, $statusCode) + { + $flattened = FlattenException::create($exception); + $flattened->setTrace(array(), 'foo.php', 123); + + $this->assertEquals(array( + array( + 'message'=> 'test', + 'class'=>'Exception', + 'trace'=>array(array( + 'namespace' => '', 'short_class' => '', 'class' => '','type' => '','function' => '', 'file' => 'foo.php', 'line' => 123, + 'args' => array() + )), + ) + ), $flattened->toArray()); + } + + public function flattenDataProvider() + { + return array( + array(new \Exception('test', 123), 500), + ); + } + + public function testRecursionInArguments() + { + $a = array('foo', array(2, &$a)); + $exception = $this->createException($a); + + $flattened = FlattenException::create($exception); + $trace = $flattened->getTrace(); + $this->assertContains('*DEEP NESTED ARRAY*', serialize($trace)); + } + + private function createException($foo) + { + return new \Exception(); + } + + public function testSetTraceIncompleteClass() + { + $flattened = FlattenException::create(new \Exception('test', 123)); + $flattened->setTrace( + array( + array( + 'file' => __FILE__, + 'line' => 123, + 'function' => 'test', + 'args' => array( + unserialize('O:14:"BogusTestClass":0:{}') + ), + ), + ), + 'foo.php', 123 + ); + + $this->assertEquals(array( + array( + 'message'=> 'test', + 'class'=>'Exception', + 'trace'=>array( + array( + 'namespace' => '', 'short_class' => '', 'class' => '','type' => '','function' => '', + 'file' => 'foo.php', 'line' => 123, + 'args' => array(), + ), + array( + 'namespace' => '', 'short_class' => '', 'class' => '','type' => '','function' => 'test', + 'file' => __FILE__, 'line' => 123, + 'args' => array( + array( + 'incomplete-object', 'BogusTestClass' + ), + ), + ) + ), + ) + ), $flattened->toArray()); + } +} diff --git a/vendor/symfony/debug/Symfony/Component/Debug/Tests/ExceptionHandlerTest.php b/vendor/symfony/debug/Symfony/Component/Debug/Tests/ExceptionHandlerTest.php new file mode 100755 index 0000000..b202b8f --- /dev/null +++ b/vendor/symfony/debug/Symfony/Component/Debug/Tests/ExceptionHandlerTest.php @@ -0,0 +1,62 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Debug\Tests; + +use Symfony\Component\Debug\ExceptionHandler; +use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; +use Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException; + +class ExceptionHandlerTest extends \PHPUnit_Framework_TestCase +{ + public function testDebug() + { + $handler = new ExceptionHandler(false); + $response = $handler->createResponse(new \RuntimeException('Foo')); + + $this->assertContains('

    Whoops, looks like something went wrong.

    ', $response->getContent()); + $this->assertNotContains('
    ', $response->getContent()); + + $handler = new ExceptionHandler(true); + $response = $handler->createResponse(new \RuntimeException('Foo')); + + $this->assertContains('

    Whoops, looks like something went wrong.

    ', $response->getContent()); + $this->assertContains('
    ', $response->getContent()); + } + + public function testStatusCode() + { + $handler = new ExceptionHandler(false); + + $response = $handler->createResponse(new \RuntimeException('Foo')); + $this->assertEquals('500', $response->getStatusCode()); + $this->assertContains('Whoops, looks like something went wrong.', $response->getContent()); + + $response = $handler->createResponse(new NotFoundHttpException('Foo')); + $this->assertEquals('404', $response->getStatusCode()); + $this->assertContains('Sorry, the page you are looking for could not be found.', $response->getContent()); + } + + public function testHeaders() + { + $handler = new ExceptionHandler(false); + + $response = $handler->createResponse(new MethodNotAllowedHttpException(array('POST'))); + $this->assertEquals('405', $response->getStatusCode()); + $this->assertEquals('POST', $response->headers->get('Allow')); + } + + public function testNestedExceptions() + { + $handler = new ExceptionHandler(true); + $response = $handler->createResponse(new \RuntimeException('Foo', 0, new \RuntimeException('Bar'))); + } +} diff --git a/vendor/symfony/debug/Symfony/Component/Debug/Tests/FatalErrorHandler/ClassNotFoundFatalErrorHandlerTest.php b/vendor/symfony/debug/Symfony/Component/Debug/Tests/FatalErrorHandler/ClassNotFoundFatalErrorHandlerTest.php new file mode 100755 index 0000000..be6c74a --- /dev/null +++ b/vendor/symfony/debug/Symfony/Component/Debug/Tests/FatalErrorHandler/ClassNotFoundFatalErrorHandlerTest.php @@ -0,0 +1,105 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Debug\Tests\FatalErrorHandler; + +use Symfony\Component\Debug\Exception\FatalErrorException; +use Symfony\Component\Debug\FatalErrorHandler\ClassNotFoundFatalErrorHandler; + +class ClassNotFoundFatalErrorHandlerTest extends \PHPUnit_Framework_TestCase +{ + /** + * @dataProvider provideClassNotFoundData + */ + public function testClassNotFound($error, $translatedMessage) + { + $handler = new ClassNotFoundFatalErrorHandler(); + $exception = $handler->handleError($error, new FatalErrorException('', 0, $error['type'], $error['file'], $error['line'])); + + $this->assertInstanceof('Symfony\Component\Debug\Exception\ClassNotFoundException', $exception); + $this->assertSame($translatedMessage, $exception->getMessage()); + $this->assertSame($error['type'], $exception->getSeverity()); + $this->assertSame($error['file'], $exception->getFile()); + $this->assertSame($error['line'], $exception->getLine()); + } + + public function provideClassNotFoundData() + { + return array( + array( + array( + 'type' => 1, + 'line' => 12, + 'file' => 'foo.php', + 'message' => 'Class \'WhizBangFactory\' not found', + ), + 'Attempted to load class "WhizBangFactory" from the global namespace in foo.php line 12. Did you forget a use statement for this class?', + ), + array( + array( + 'type' => 1, + 'line' => 12, + 'file' => 'foo.php', + 'message' => 'Class \'Foo\\Bar\\WhizBangFactory\' not found', + ), + 'Attempted to load class "WhizBangFactory" from namespace "Foo\\Bar" in foo.php line 12. Do you need to "use" it from another namespace?', + ), + array( + array( + 'type' => 1, + 'line' => 12, + 'file' => 'foo.php', + 'message' => 'Class \'UndefinedFunctionException\' not found', + ), + 'Attempted to load class "UndefinedFunctionException" from the global namespace in foo.php line 12. Did you forget a use statement for this class? Perhaps you need to add a use statement for one of the following: Symfony\Component\Debug\Exception\UndefinedFunctionException.', + ), + array( + array( + 'type' => 1, + 'line' => 12, + 'file' => 'foo.php', + 'message' => 'Class \'PEARClass\' not found', + ), + 'Attempted to load class "PEARClass" from the global namespace in foo.php line 12. Did you forget a use statement for this class? Perhaps you need to add a use statement for one of the following: Symfony_Component_Debug_Tests_Fixtures_PEARClass.', + ), + array( + array( + 'type' => 1, + 'line' => 12, + 'file' => 'foo.php', + 'message' => 'Class \'Foo\\Bar\\UndefinedFunctionException\' not found', + ), + 'Attempted to load class "UndefinedFunctionException" from namespace "Foo\Bar" in foo.php line 12. Do you need to "use" it from another namespace? Perhaps you need to add a use statement for one of the following: Symfony\Component\Debug\Exception\UndefinedFunctionException.', + ), + ); + } + + public function testCannotRedeclareClass() + { + if (!file_exists(__DIR__.'/../FIXTURES/REQUIREDTWICE.PHP')) { + $this->markTestSkipped('Can only be run on case insensitive filesystems'); + } + + require_once __DIR__.'/../FIXTURES/REQUIREDTWICE.PHP'; + + $error = array( + 'type' => 1, + 'line' => 12, + 'file' => 'foo.php', + 'message' => 'Class \'Foo\\Bar\\RequiredTwice\' not found', + ); + + $handler = new ClassNotFoundFatalErrorHandler(); + $exception = $handler->handleError($error, new FatalErrorException('', 0, $error['type'], $error['file'], $error['line'])); + + $this->assertInstanceof('Symfony\Component\Debug\Exception\ClassNotFoundException', $exception); + } +} diff --git a/vendor/symfony/debug/Symfony/Component/Debug/Tests/FatalErrorHandler/UndefinedFunctionFatalErrorHandlerTest.php b/vendor/symfony/debug/Symfony/Component/Debug/Tests/FatalErrorHandler/UndefinedFunctionFatalErrorHandlerTest.php new file mode 100755 index 0000000..511f204 --- /dev/null +++ b/vendor/symfony/debug/Symfony/Component/Debug/Tests/FatalErrorHandler/UndefinedFunctionFatalErrorHandlerTest.php @@ -0,0 +1,79 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Debug\Tests\FatalErrorHandler; + +use Symfony\Component\Debug\Exception\FatalErrorException; +use Symfony\Component\Debug\FatalErrorHandler\UndefinedFunctionFatalErrorHandler; + +class UndefinedFunctionFatalErrorHandlerTest extends \PHPUnit_Framework_TestCase +{ + /** + * @dataProvider provideUndefinedFunctionData + */ + public function testUndefinedFunction($error, $translatedMessage) + { + $handler = new UndefinedFunctionFatalErrorHandler(); + $exception = $handler->handleError($error, new FatalErrorException('', 0, $error['type'], $error['file'], $error['line'])); + + $this->assertInstanceof('Symfony\Component\Debug\Exception\UndefinedFunctionException', $exception); + $this->assertSame($translatedMessage, $exception->getMessage()); + $this->assertSame($error['type'], $exception->getSeverity()); + $this->assertSame($error['file'], $exception->getFile()); + $this->assertSame($error['line'], $exception->getLine()); + } + + public function provideUndefinedFunctionData() + { + return array( + array( + array( + 'type' => 1, + 'line' => 12, + 'file' => 'foo.php', + 'message' => 'Call to undefined function test_namespaced_function()', + ), + 'Attempted to call function "test_namespaced_function" from the global namespace in foo.php line 12. Did you mean to call: "\\symfony\\component\\debug\\tests\\fatalerrorhandler\\test_namespaced_function"?', + ), + array( + array( + 'type' => 1, + 'line' => 12, + 'file' => 'foo.php', + 'message' => 'Call to undefined function Foo\\Bar\\Baz\\test_namespaced_function()', + ), + 'Attempted to call function "test_namespaced_function" from namespace "Foo\\Bar\\Baz" in foo.php line 12. Did you mean to call: "\\symfony\\component\\debug\\tests\\fatalerrorhandler\\test_namespaced_function"?', + ), + array( + array( + 'type' => 1, + 'line' => 12, + 'file' => 'foo.php', + 'message' => 'Call to undefined function foo()', + ), + 'Attempted to call function "foo" from the global namespace in foo.php line 12.', + ), + array( + array( + 'type' => 1, + 'line' => 12, + 'file' => 'foo.php', + 'message' => 'Call to undefined function Foo\\Bar\\Baz\\foo()', + ), + 'Attempted to call function "foo" from namespace "Foo\Bar\Baz" in foo.php line 12.', + ), + ); + } +} + +function test_namespaced_function() +{ +} diff --git a/vendor/symfony/debug/Symfony/Component/Debug/Tests/Fixtures/PEARClass.php b/vendor/symfony/debug/Symfony/Component/Debug/Tests/Fixtures/PEARClass.php new file mode 100755 index 0000000..39f2281 --- /dev/null +++ b/vendor/symfony/debug/Symfony/Component/Debug/Tests/Fixtures/PEARClass.php @@ -0,0 +1,5 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Debug\Tests; + +use Symfony\Component\Debug\ExceptionHandler; + +class MockExceptionHandler extends Exceptionhandler +{ + public $e; + + public function handle(\Exception $e) + { + $this->e = $e; + } +} diff --git a/vendor/symfony/debug/Symfony/Component/Debug/composer.json b/vendor/symfony/debug/Symfony/Component/Debug/composer.json new file mode 100755 index 0000000..17dcb3e --- /dev/null +++ b/vendor/symfony/debug/Symfony/Component/Debug/composer.json @@ -0,0 +1,39 @@ +{ + "name": "symfony/debug", + "type": "library", + "description": "Symfony Debug Component", + "keywords": [], + "homepage": "http://symfony.com", + "license": "MIT", + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + } + ], + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "symfony/http-kernel": "~2.1", + "symfony/http-foundation": "~2.1" + }, + "suggest": { + "symfony/http-foundation": "", + "symfony/http-kernel": "" + }, + "autoload": { + "psr-0": { "Symfony\\Component\\Debug\\": "" } + }, + "target-dir": "Symfony/Component/Debug", + "minimum-stability": "dev", + "extra": { + "branch-alias": { + "dev-master": "2.4-dev" + } + } +} diff --git a/vendor/symfony/debug/Symfony/Component/Debug/phpunit.xml.dist b/vendor/symfony/debug/Symfony/Component/Debug/phpunit.xml.dist new file mode 100755 index 0000000..8bab165 --- /dev/null +++ b/vendor/symfony/debug/Symfony/Component/Debug/phpunit.xml.dist @@ -0,0 +1,29 @@ + + + + + + ./Tests/ + + + + + + ./ + + ./Tests + ./vendor + + + + diff --git a/vendor/symfony/dom-crawler/Symfony/Component/DomCrawler/.gitignore b/vendor/symfony/dom-crawler/Symfony/Component/DomCrawler/.gitignore new file mode 100755 index 0000000..c49a5d8 --- /dev/null +++ b/vendor/symfony/dom-crawler/Symfony/Component/DomCrawler/.gitignore @@ -0,0 +1,3 @@ +vendor/ +composer.lock +phpunit.xml diff --git a/vendor/symfony/dom-crawler/Symfony/Component/DomCrawler/CHANGELOG.md b/vendor/symfony/dom-crawler/Symfony/Component/DomCrawler/CHANGELOG.md new file mode 100755 index 0000000..bc51805 --- /dev/null +++ b/vendor/symfony/dom-crawler/Symfony/Component/DomCrawler/CHANGELOG.md @@ -0,0 +1,36 @@ +CHANGELOG +========= + +2.4.0 +----- + + * `Crawler::addXmlContent()` removes the default document namespace again if it's an only namespace. + * added support for automatic discovery and explicit registration of document + namespaces for `Crawler::filterXPath()` and `Crawler::filter()` + * improved content type guessing in `Crawler::addContent()` + * [BC BREAK] `Crawler::addXmlContent()` no longer removes the default document + namespace + +2.3.0 +----- + + * added Crawler::html() + * [BC BREAK] Crawler::each() and Crawler::reduce() now return Crawler instances instead of DomElement instances + * added schema relative URL support to links + * added support for HTML5 'form' attribute + +2.2.0 +----- + + * added a way to set raw path to the file in FileFormField - necessary for + simulating HTTP requests + +2.1.0 +----- + + * added support for the HTTP PATCH method + * refactored the Form class internals to support multi-dimensional fields + (the public API is backward compatible) + * added a way to get parsing errors for Crawler::addHtmlContent() and + Crawler::addXmlContent() via libxml functions + * added support for submitting a form without a submit button diff --git a/vendor/symfony/dom-crawler/Symfony/Component/DomCrawler/Crawler.php b/vendor/symfony/dom-crawler/Symfony/Component/DomCrawler/Crawler.php new file mode 100755 index 0000000..ba209ab --- /dev/null +++ b/vendor/symfony/dom-crawler/Symfony/Component/DomCrawler/Crawler.php @@ -0,0 +1,995 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\DomCrawler; + +use Symfony\Component\CssSelector\CssSelector; + +/** + * Crawler eases navigation of a list of \DOMNode objects. + * + * @author Fabien Potencier + * + * @api + */ +class Crawler extends \SplObjectStorage +{ + /** + * @var string The current URI or the base href value + */ + protected $uri; + + /** + * @var string The default namespace prefix to be used with XPath and CSS expressions + */ + private $defaultNamespacePrefix = 'default'; + + /** + * @var array A map of manually registered namespaces + */ + private $namespaces = array(); + + /** + * Constructor. + * + * @param mixed $node A Node to use as the base for the crawling + * @param string $uri The current URI or the base href value + * + * @api + */ + public function __construct($node = null, $uri = null) + { + $this->uri = $uri; + + $this->add($node); + } + + /** + * Removes all the nodes. + * + * @api + */ + public function clear() + { + $this->removeAll($this); + } + + /** + * Adds a node to the current list of nodes. + * + * This method uses the appropriate specialized add*() method based + * on the type of the argument. + * + * @param \DOMNodeList|\DOMNode|array|string|null $node A node + * + * @throws \InvalidArgumentException When node is not the expected type. + * + * @api + */ + public function add($node) + { + if ($node instanceof \DOMNodeList) { + $this->addNodeList($node); + } elseif ($node instanceof \DOMNode) { + $this->addNode($node); + } elseif (is_array($node)) { + $this->addNodes($node); + } elseif (is_string($node)) { + $this->addContent($node); + } elseif (null !== $node) { + throw new \InvalidArgumentException(sprintf('Expecting a DOMNodeList or DOMNode instance, an array, a string, or null, but got "%s".', is_object($node) ? get_class($node) : gettype($node))); + } + } + + /** + * Adds HTML/XML content. + * + * If the charset is not set via the content type, it is assumed + * to be ISO-8859-1, which is the default charset defined by the + * HTTP 1.1 specification. + * + * @param string $content A string to parse as HTML/XML + * @param null|string $type The content type of the string + */ + public function addContent($content, $type = null) + { + if (empty($type)) { + $type = 0 === strpos($content, ']+charset *= *["\']?([a-zA-Z\-0-9_:.]+)/i', $content, $matches)) { + $charset = $matches[1]; + } + + if (null === $charset) { + $charset = 'ISO-8859-1'; + } + + if ('x' === $xmlMatches[1]) { + $this->addXmlContent($content, $charset); + } else { + $this->addHtmlContent($content, $charset); + } + } + + /** + * Adds an HTML content to the list of nodes. + * + * The libxml errors are disabled when the content is parsed. + * + * If you want to get parsing errors, be sure to enable + * internal errors via libxml_use_internal_errors(true) + * and then, get the errors via libxml_get_errors(). Be + * sure to clear errors with libxml_clear_errors() afterward. + * + * @param string $content The HTML content + * @param string $charset The charset + * + * @api + */ + public function addHtmlContent($content, $charset = 'UTF-8') + { + $internalErrors = libxml_use_internal_errors(true); + $disableEntities = libxml_disable_entity_loader(true); + + $dom = new \DOMDocument('1.0', $charset); + $dom->validateOnParse = true; + + if (function_exists('mb_convert_encoding')) { + $hasError = false; + set_error_handler(function () use (&$hasError) { + $hasError = true; + }); + $tmpContent = @mb_convert_encoding($content, 'HTML-ENTITIES', $charset); + + restore_error_handler(); + + if (!$hasError) { + $content = $tmpContent; + } + } + + if ('' !== trim($content)) { + @$dom->loadHTML($content); + } + + libxml_use_internal_errors($internalErrors); + libxml_disable_entity_loader($disableEntities); + + $this->addDocument($dom); + + $base = $this->filterRelativeXPath('descendant-or-self::base')->extract(array('href')); + + $baseHref = current($base); + if (count($base) && !empty($baseHref)) { + if ($this->uri) { + $linkNode = $dom->createElement('a'); + $linkNode->setAttribute('href', $baseHref); + $link = new Link($linkNode, $this->uri); + $this->uri = $link->getUri(); + } else { + $this->uri = $baseHref; + } + } + } + + /** + * Adds an XML content to the list of nodes. + * + * The libxml errors are disabled when the content is parsed. + * + * If you want to get parsing errors, be sure to enable + * internal errors via libxml_use_internal_errors(true) + * and then, get the errors via libxml_get_errors(). Be + * sure to clear errors with libxml_clear_errors() afterward. + * + * @param string $content The XML content + * @param string $charset The charset + * + * @api + */ + public function addXmlContent($content, $charset = 'UTF-8') + { + // remove the default namespace if it's the only namespace to make XPath expressions simpler + if (!preg_match('/xmlns:/', $content)) { + $content = str_replace('xmlns', 'ns', $content); + } + + $internalErrors = libxml_use_internal_errors(true); + $disableEntities = libxml_disable_entity_loader(true); + + $dom = new \DOMDocument('1.0', $charset); + $dom->validateOnParse = true; + + if ('' !== trim($content)) { + @$dom->loadXML($content, LIBXML_NONET); + } + + libxml_use_internal_errors($internalErrors); + libxml_disable_entity_loader($disableEntities); + + $this->addDocument($dom); + } + + /** + * Adds a \DOMDocument to the list of nodes. + * + * @param \DOMDocument $dom A \DOMDocument instance + * + * @api + */ + public function addDocument(\DOMDocument $dom) + { + if ($dom->documentElement) { + $this->addNode($dom->documentElement); + } + } + + /** + * Adds a \DOMNodeList to the list of nodes. + * + * @param \DOMNodeList $nodes A \DOMNodeList instance + * + * @api + */ + public function addNodeList(\DOMNodeList $nodes) + { + foreach ($nodes as $node) { + $this->addNode($node); + } + } + + /** + * Adds an array of \DOMNode instances to the list of nodes. + * + * @param \DOMNode[] $nodes An array of \DOMNode instances + * + * @api + */ + public function addNodes(array $nodes) + { + foreach ($nodes as $node) { + $this->add($node); + } + } + + /** + * Adds a \DOMNode instance to the list of nodes. + * + * @param \DOMNode $node A \DOMNode instance + * + * @api + */ + public function addNode(\DOMNode $node) + { + if ($node instanceof \DOMDocument) { + $this->attach($node->documentElement); + } else { + $this->attach($node); + } + } + + /** + * Returns a node given its position in the node list. + * + * @param int $position The position + * + * @return Crawler A new instance of the Crawler with the selected node, or an empty Crawler if it does not exist. + * + * @api + */ + public function eq($position) + { + foreach ($this as $i => $node) { + if ($i == $position) { + return new static($node, $this->uri); + } + } + + return new static(null, $this->uri); + } + + /** + * Calls an anonymous function on each node of the list. + * + * The anonymous function receives the position and the node wrapped + * in a Crawler instance as arguments. + * + * Example: + * + * $crawler->filter('h1')->each(function ($node, $i) { + * return $node->text(); + * }); + * + * @param \Closure $closure An anonymous function + * + * @return array An array of values returned by the anonymous function + * + * @api + */ + public function each(\Closure $closure) + { + $data = array(); + foreach ($this as $i => $node) { + $data[] = $closure(new static($node, $this->uri), $i); + } + + return $data; + } + + /** + * Reduces the list of nodes by calling an anonymous function. + * + * To remove a node from the list, the anonymous function must return false. + * + * @param \Closure $closure An anonymous function + * + * @return Crawler A Crawler instance with the selected nodes. + * + * @api + */ + public function reduce(\Closure $closure) + { + $nodes = array(); + foreach ($this as $i => $node) { + if (false !== $closure(new static($node, $this->uri), $i)) { + $nodes[] = $node; + } + } + + return new static($nodes, $this->uri); + } + + /** + * Returns the first node of the current selection + * + * @return Crawler A Crawler instance with the first selected node + * + * @api + */ + public function first() + { + return $this->eq(0); + } + + /** + * Returns the last node of the current selection + * + * @return Crawler A Crawler instance with the last selected node + * + * @api + */ + public function last() + { + return $this->eq(count($this) - 1); + } + + /** + * Returns the siblings nodes of the current selection + * + * @return Crawler A Crawler instance with the sibling nodes + * + * @throws \InvalidArgumentException When current node is empty + * + * @api + */ + public function siblings() + { + if (!count($this)) { + throw new \InvalidArgumentException('The current node list is empty.'); + } + + return new static($this->sibling($this->getNode(0)->parentNode->firstChild), $this->uri); + } + + /** + * Returns the next siblings nodes of the current selection + * + * @return Crawler A Crawler instance with the next sibling nodes + * + * @throws \InvalidArgumentException When current node is empty + * + * @api + */ + public function nextAll() + { + if (!count($this)) { + throw new \InvalidArgumentException('The current node list is empty.'); + } + + return new static($this->sibling($this->getNode(0)), $this->uri); + } + + /** + * Returns the previous sibling nodes of the current selection + * + * @return Crawler A Crawler instance with the previous sibling nodes + * + * @throws \InvalidArgumentException + * + * @api + */ + public function previousAll() + { + if (!count($this)) { + throw new \InvalidArgumentException('The current node list is empty.'); + } + + return new static($this->sibling($this->getNode(0), 'previousSibling'), $this->uri); + } + + /** + * Returns the parents nodes of the current selection + * + * @return Crawler A Crawler instance with the parents nodes of the current selection + * + * @throws \InvalidArgumentException When current node is empty + * + * @api + */ + public function parents() + { + if (!count($this)) { + throw new \InvalidArgumentException('The current node list is empty.'); + } + + $node = $this->getNode(0); + $nodes = array(); + + while ($node = $node->parentNode) { + if (1 === $node->nodeType) { + $nodes[] = $node; + } + } + + return new static($nodes, $this->uri); + } + + /** + * Returns the children nodes of the current selection + * + * @return Crawler A Crawler instance with the children nodes + * + * @throws \InvalidArgumentException When current node is empty + * + * @api + */ + public function children() + { + if (!count($this)) { + throw new \InvalidArgumentException('The current node list is empty.'); + } + + $node = $this->getNode(0)->firstChild; + + return new static($node ? $this->sibling($node) : array(), $this->uri); + } + + /** + * Returns the attribute value of the first node of the list. + * + * @param string $attribute The attribute name + * + * @return string|null The attribute value or null if the attribute does not exist + * + * @throws \InvalidArgumentException When current node is empty + * + * @api + */ + public function attr($attribute) + { + if (!count($this)) { + throw new \InvalidArgumentException('The current node list is empty.'); + } + + $node = $this->getNode(0); + + return $node->hasAttribute($attribute) ? $node->getAttribute($attribute) : null; + } + + /** + * Returns the node value of the first node of the list. + * + * @return string The node value + * + * @throws \InvalidArgumentException When current node is empty + * + * @api + */ + public function text() + { + if (!count($this)) { + throw new \InvalidArgumentException('The current node list is empty.'); + } + + return $this->getNode(0)->nodeValue; + } + + /** + * Returns the first node of the list as HTML. + * + * @return string The node html + * + * @throws \InvalidArgumentException When current node is empty + */ + public function html() + { + if (!count($this)) { + throw new \InvalidArgumentException('The current node list is empty.'); + } + + $html = ''; + foreach ($this->getNode(0)->childNodes as $child) { + if (version_compare(PHP_VERSION, '5.3.6', '>=')) { + // node parameter was added to the saveHTML() method in PHP 5.3.6 + // @see http://php.net/manual/en/domdocument.savehtml.php + $html .= $child->ownerDocument->saveHTML($child); + } else { + $document = new \DOMDocument('1.0', 'UTF-8'); + $document->appendChild($document->importNode($child, true)); + $html .= rtrim($document->saveHTML()); + } + } + + return $html; + } + + /** + * Extracts information from the list of nodes. + * + * You can extract attributes or/and the node value (_text). + * + * Example: + * + * $crawler->filter('h1 a')->extract(array('_text', 'href')); + * + * @param array $attributes An array of attributes + * + * @return array An array of extracted values + * + * @api + */ + public function extract($attributes) + { + $attributes = (array) $attributes; + $count = count($attributes); + + $data = array(); + foreach ($this as $node) { + $elements = array(); + foreach ($attributes as $attribute) { + if ('_text' === $attribute) { + $elements[] = $node->nodeValue; + } else { + $elements[] = $node->getAttribute($attribute); + } + } + + $data[] = $count > 1 ? $elements : $elements[0]; + } + + return $data; + } + + /** + * Filters the list of nodes with an XPath expression. + * + * The XPath expression is evaluated in the context of the crawler, which + * is considered as a fake parent of the elements inside it. + * This means that a child selector "div" or "./div" will match only + * the div elements of the current crawler, not their children. + * + * @param string $xpath An XPath expression + * + * @return Crawler A new instance of Crawler with the filtered list of nodes + * + * @api + */ + public function filterXPath($xpath) + { + $xpath = $this->relativize($xpath); + + // If we dropped all expressions in the XPath while preparing it, there would be no match + if ('' === $xpath) { + return new static(null, $this->uri); + } + + return $this->filterRelativeXPath($xpath); + } + + /** + * Filters the list of nodes with a CSS selector. + * + * This method only works if you have installed the CssSelector Symfony Component. + * + * @param string $selector A CSS selector + * + * @return Crawler A new instance of Crawler with the filtered list of nodes + * + * @throws \RuntimeException if the CssSelector Component is not available + * + * @api + */ + public function filter($selector) + { + if (!class_exists('Symfony\\Component\\CssSelector\\CssSelector')) { + // @codeCoverageIgnoreStart + throw new \RuntimeException('Unable to filter with a CSS selector as the Symfony CssSelector is not installed (you can use filterXPath instead).'); + // @codeCoverageIgnoreEnd + } + + // The CssSelector already prefixes the selector with descendant-or-self:: + return $this->filterRelativeXPath(CssSelector::toXPath($selector)); + } + + /** + * Selects links by name or alt value for clickable images. + * + * @param string $value The link text + * + * @return Crawler A new instance of Crawler with the filtered list of nodes + * + * @api + */ + public function selectLink($value) + { + $xpath = sprintf('descendant-or-self::a[contains(concat(\' \', normalize-space(string(.)), \' \'), %s) ', static::xpathLiteral(' '.$value.' ')). + sprintf('or ./img[contains(concat(\' \', normalize-space(string(@alt)), \' \'), %s)]]', static::xpathLiteral(' '.$value.' ')); + + return $this->filterRelativeXPath($xpath); + } + + /** + * Selects a button by name or alt value for images. + * + * @param string $value The button text + * + * @return Crawler A new instance of Crawler with the filtered list of nodes + * + * @api + */ + public function selectButton($value) + { + $translate = 'translate(@type, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "abcdefghijklmnopqrstuvwxyz")'; + $xpath = sprintf('descendant-or-self::input[((contains(%s, "submit") or contains(%s, "button")) and contains(concat(\' \', normalize-space(string(@value)), \' \'), %s)) ', $translate, $translate, static::xpathLiteral(' '.$value.' ')). + sprintf('or (contains(%s, "image") and contains(concat(\' \', normalize-space(string(@alt)), \' \'), %s)) or @id="%s" or @name="%s"] ', $translate, static::xpathLiteral(' '.$value.' '), $value, $value). + sprintf('| descendant-or-self::button[contains(concat(\' \', normalize-space(string(.)), \' \'), %s) or @id="%s" or @name="%s"]', static::xpathLiteral(' '.$value.' '), $value, $value); + + return $this->filterRelativeXPath($xpath); + } + + /** + * Returns a Link object for the first node in the list. + * + * @param string $method The method for the link (get by default) + * + * @return Link A Link instance + * + * @throws \InvalidArgumentException If the current node list is empty + * + * @api + */ + public function link($method = 'get') + { + if (!count($this)) { + throw new \InvalidArgumentException('The current node list is empty.'); + } + + $node = $this->getNode(0); + + return new Link($node, $this->uri, $method); + } + + /** + * Returns an array of Link objects for the nodes in the list. + * + * @return Link[] An array of Link instances + * + * @api + */ + public function links() + { + $links = array(); + foreach ($this as $node) { + $links[] = new Link($node, $this->uri, 'get'); + } + + return $links; + } + + /** + * Returns a Form object for the first node in the list. + * + * @param array $values An array of values for the form fields + * @param string $method The method for the form + * + * @return Form A Form instance + * + * @throws \InvalidArgumentException If the current node list is empty + * + * @api + */ + public function form(array $values = null, $method = null) + { + if (!count($this)) { + throw new \InvalidArgumentException('The current node list is empty.'); + } + + $form = new Form($this->getNode(0), $this->uri, $method); + + if (null !== $values) { + $form->setValues($values); + } + + return $form; + } + + /** + * Overloads a default namespace prefix to be used with XPath and CSS expressions. + * + * @param string $prefix + */ + public function setDefaultNamespacePrefix($prefix) + { + $this->defaultNamespacePrefix = $prefix; + } + + /** + * @param string $prefix + * @param string $namespace + */ + public function registerNamespace($prefix, $namespace) + { + $this->namespaces[$prefix] = $namespace; + } + + /** + * Converts string for XPath expressions. + * + * Escaped characters are: quotes (") and apostrophe ('). + * + * Examples: + * + * echo Crawler::xpathLiteral('foo " bar'); + * //prints 'foo " bar' + * + * echo Crawler::xpathLiteral("foo ' bar"); + * //prints "foo ' bar" + * + * echo Crawler::xpathLiteral('a\'b"c'); + * //prints concat('a', "'", 'b"c') + * + * + * @param string $s String to be escaped + * + * @return string Converted string + */ + public static function xpathLiteral($s) + { + if (false === strpos($s, "'")) { + return sprintf("'%s'", $s); + } + + if (false === strpos($s, '"')) { + return sprintf('"%s"', $s); + } + + $string = $s; + $parts = array(); + while (true) { + if (false !== $pos = strpos($string, "'")) { + $parts[] = sprintf("'%s'", substr($string, 0, $pos)); + $parts[] = "\"'\""; + $string = substr($string, $pos + 1); + } else { + $parts[] = "'$string'"; + break; + } + } + + return sprintf("concat(%s)", implode($parts, ', ')); + } + + /** + * Filters the list of nodes with an XPath expression. + * + * The XPath expression should already be processed to apply it in the context of each node. + * + * @param string $xpath + * + * @return Crawler + */ + private function filterRelativeXPath($xpath) + { + $prefixes = $this->findNamespacePrefixes($xpath); + + $crawler = new static(null, $this->uri); + + foreach ($this as $node) { + $domxpath = $this->createDOMXPath($node->ownerDocument, $prefixes); + $crawler->add($domxpath->query($xpath, $node)); + } + + return $crawler; + } + + /** + * Make the XPath relative to the current context. + * + * The returned XPath will match elements matching the XPath inside the current crawler + * when running in the context of a node of the crawler. + * + * @param string $xpath + * + * @return string + */ + private function relativize($xpath) + { + $expressions = array(); + + $unionPattern = '/\|(?![^\[]*\])/'; + // An expression which will never match to replace expressions which cannot match in the crawler + // We cannot simply drop + $nonMatchingExpression = 'a[name() = "b"]'; + + // Split any unions into individual expressions. + foreach (preg_split($unionPattern, $xpath) as $expression) { + $expression = trim($expression); + $parenthesis = ''; + + // If the union is inside some braces, we need to preserve the opening braces and apply + // the change only inside it. + if (preg_match('/^[\(\s*]+/', $expression, $matches)) { + $parenthesis = $matches[0]; + $expression = substr($expression, strlen($parenthesis)); + } + + // BC for Symfony 2.4 and lower were elements were adding in a fake _root parent + if (0 === strpos($expression, '/_root/')) { + $expression = './'.substr($expression, 7); + } + + // add prefix before absolute element selector + if (empty($expression)) { + $expression = $nonMatchingExpression; + } elseif (0 === strpos($expression, '//')) { + $expression = 'descendant-or-self::' . substr($expression, 2); + } elseif (0 === strpos($expression, './/')) { + $expression = 'descendant-or-self::' . substr($expression, 3); + } elseif (0 === strpos($expression, './')) { + $expression = 'self::' . substr($expression, 2); + } elseif ('/' === $expression[0]) { + // the only direct child in Symfony 2.4 and lower is _root, which is already handled previously + // so let's drop the expression entirely + $expression = $nonMatchingExpression; + } elseif ('.' === $expression[0]) { + // '.' is the fake root element in Symfony 2.4 and lower, which is excluded from results + $expression = $nonMatchingExpression; + } elseif (0 === strpos($expression, 'descendant::')) { + $expression = 'descendant-or-self::' . substr($expression, strlen('descendant::')); + } elseif (0 !== strpos($expression, 'descendant-or-self::')) { + $expression = 'self::' .$expression; + } + $expressions[] = $parenthesis.$expression; + } + + return implode(' | ', $expressions); + } + + /** + * @param int $position + * + * @return \DOMElement|null + */ + public function getNode($position) + { + foreach ($this as $i => $node) { + if ($i == $position) { + return $node; + } + // @codeCoverageIgnoreStart + } + // @codeCoverageIgnoreEnd + } + + /** + * @param \DOMElement $node + * @param string $siblingDir + * + * @return array + */ + protected function sibling($node, $siblingDir = 'nextSibling') + { + $nodes = array(); + + do { + if ($node !== $this->getNode(0) && $node->nodeType === 1) { + $nodes[] = $node; + } + } while ($node = $node->$siblingDir); + + return $nodes; + } + + /** + * @param \DOMDocument $document + * @param array $prefixes + * + * @return \DOMXPath + * + * @throws \InvalidArgumentException + */ + private function createDOMXPath(\DOMDocument $document, array $prefixes = array()) + { + $domxpath = new \DOMXPath($document); + + foreach ($prefixes as $prefix) { + $namespace = $this->discoverNamespace($domxpath, $prefix); + if (null !== $namespace) { + $domxpath->registerNamespace($prefix, $namespace); + } + } + + return $domxpath; + } + + /** + * @param \DOMXPath $domxpath + * @param string $prefix + * + * @return string + * + * @throws \InvalidArgumentException + */ + private function discoverNamespace(\DOMXPath $domxpath, $prefix) + { + if (isset($this->namespaces[$prefix])) { + return $this->namespaces[$prefix]; + } + + // ask for one namespace, otherwise we'd get a collection with an item for each node + $namespaces = $domxpath->query(sprintf('(//namespace::*[name()="%s"])[last()]', $this->defaultNamespacePrefix === $prefix ? '' : $prefix)); + + if ($node = $namespaces->item(0)) { + return $node->nodeValue; + } + } + + /** + * @param $xpath + * + * @return array + */ + private function findNamespacePrefixes($xpath) + { + if (preg_match_all('/(?P[a-z_][a-z_0-9\-\.]*):[^"\/]/i', $xpath, $matches)) { + return array_unique($matches['prefix']); + } + + return array(); + } +} diff --git a/vendor/symfony/dom-crawler/Symfony/Component/DomCrawler/Field/ChoiceFormField.php b/vendor/symfony/dom-crawler/Symfony/Component/DomCrawler/Field/ChoiceFormField.php new file mode 100755 index 0000000..9af67c1 --- /dev/null +++ b/vendor/symfony/dom-crawler/Symfony/Component/DomCrawler/Field/ChoiceFormField.php @@ -0,0 +1,327 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\DomCrawler\Field; + +/** + * ChoiceFormField represents a choice form field. + * + * It is constructed from a HTML select tag, or a HTML checkbox, or radio inputs. + * + * @author Fabien Potencier + * + * @api + */ +class ChoiceFormField extends FormField +{ + /** + * @var string + */ + private $type; + /** + * @var bool + */ + private $multiple; + /** + * @var array + */ + private $options; + /** + * @var bool + */ + private $validationDisabled = false; + + /** + * Returns true if the field should be included in the submitted values. + * + * @return bool true if the field should be included in the submitted values, false otherwise + */ + public function hasValue() + { + // don't send a value for unchecked checkboxes + if (in_array($this->type, array('checkbox', 'radio')) && null === $this->value) { + return false; + } + + return true; + } + + /** + * Check if the current selected option is disabled + * + * @return bool + */ + public function isDisabled() + { + foreach ($this->options as $option) { + if ($option['value'] == $this->value && $option['disabled']) { + return true; + } + } + + return false; + } + + /** + * Sets the value of the field. + * + * @param string $value The value of the field + * + * @api + */ + public function select($value) + { + $this->setValue($value); + } + + /** + * Ticks a checkbox. + * + * @throws \LogicException When the type provided is not correct + * + * @api + */ + public function tick() + { + if ('checkbox' !== $this->type) { + throw new \LogicException(sprintf('You cannot tick "%s" as it is not a checkbox (%s).', $this->name, $this->type)); + } + + $this->setValue(true); + } + + /** + * Ticks a checkbox. + * + * @throws \LogicException When the type provided is not correct + * + * @api + */ + public function untick() + { + if ('checkbox' !== $this->type) { + throw new \LogicException(sprintf('You cannot tick "%s" as it is not a checkbox (%s).', $this->name, $this->type)); + } + + $this->setValue(false); + } + + /** + * Sets the value of the field. + * + * @param string $value The value of the field + * + * @throws \InvalidArgumentException When value type provided is not correct + */ + public function setValue($value) + { + if ('checkbox' === $this->type && false === $value) { + // uncheck + $this->value = null; + } elseif ('checkbox' === $this->type && true === $value) { + // check + $this->value = $this->options[0]['value']; + } else { + if (is_array($value)) { + if (!$this->multiple) { + throw new \InvalidArgumentException(sprintf('The value for "%s" cannot be an array.', $this->name)); + } + + foreach ($value as $v) { + if (!$this->containsOption($v, $this->options)) { + throw new \InvalidArgumentException(sprintf('Input "%s" cannot take "%s" as a value (possible values: %s).', $this->name, $v, implode(', ', $this->availableOptionValues()))); + } + } + } elseif (!$this->containsOption($value, $this->options)) { + throw new \InvalidArgumentException(sprintf('Input "%s" cannot take "%s" as a value (possible values: %s).', $this->name, $value, implode(', ', $this->availableOptionValues()))); + } + + if ($this->multiple) { + $value = (array) $value; + } + + if (is_array($value)) { + $this->value = $value; + } else { + parent::setValue($value); + } + } + } + + /** + * Adds a choice to the current ones. + * + * This method should only be used internally. + * + * @param \DOMNode $node A \DOMNode + * + * @throws \LogicException When choice provided is not multiple nor radio + */ + public function addChoice(\DOMNode $node) + { + if (!$this->multiple && 'radio' !== $this->type) { + throw new \LogicException(sprintf('Unable to add a choice for "%s" as it is not multiple or is not a radio button.', $this->name)); + } + + $option = $this->buildOptionValue($node); + $this->options[] = $option; + + if ($node->hasAttribute('checked')) { + $this->value = $option['value']; + } + } + + /** + * Returns the type of the choice field (radio, select, or checkbox). + * + * @return string The type + */ + public function getType() + { + return $this->type; + } + + /** + * Returns true if the field accepts multiple values. + * + * @return bool true if the field accepts multiple values, false otherwise + */ + public function isMultiple() + { + return $this->multiple; + } + + /** + * Initializes the form field. + * + * @throws \LogicException When node type is incorrect + */ + protected function initialize() + { + if ('input' !== $this->node->nodeName && 'select' !== $this->node->nodeName) { + throw new \LogicException(sprintf('A ChoiceFormField can only be created from an input or select tag (%s given).', $this->node->nodeName)); + } + + if ('input' === $this->node->nodeName && 'checkbox' !== strtolower($this->node->getAttribute('type')) && 'radio' !== strtolower($this->node->getAttribute('type'))) { + throw new \LogicException(sprintf('A ChoiceFormField can only be created from an input tag with a type of checkbox or radio (given type is %s).', $this->node->getAttribute('type'))); + } + + $this->value = null; + $this->options = array(); + $this->multiple = false; + + if ('input' == $this->node->nodeName) { + $this->type = strtolower($this->node->getAttribute('type')); + $optionValue = $this->buildOptionValue($this->node); + $this->options[] = $optionValue; + + if ($this->node->hasAttribute('checked')) { + $this->value = $optionValue['value']; + } + } else { + $this->type = 'select'; + if ($this->node->hasAttribute('multiple')) { + $this->multiple = true; + $this->value = array(); + $this->name = str_replace('[]', '', $this->name); + } + + $found = false; + foreach ($this->xpath->query('descendant::option', $this->node) as $option) { + $optionValue = $this->buildOptionValue($option); + $this->options[] = $optionValue; + + if ($option->hasAttribute('selected')) { + $found = true; + if ($this->multiple) { + $this->value[] = $optionValue['value']; + } else { + $this->value = $optionValue['value']; + } + } + } + + // if no option is selected and if it is a simple select box, take the first option as the value + if (!$found && !$this->multiple && !empty($this->options)) { + $this->value = $this->options[0]['value']; + } + } + } + + /** + * Returns option value with associated disabled flag + * + * @param \DOMNode $node + * + * @return array + */ + private function buildOptionValue($node) + { + $option = array(); + + $defaultValue = (isset($node->nodeValue) && !empty($node->nodeValue)) ? $node->nodeValue : '1'; + $option['value'] = $node->hasAttribute('value') ? $node->getAttribute('value') : $defaultValue; + $option['disabled'] = $node->hasAttribute('disabled'); + + return $option; + } + + /** + * Checks whether given value is in the existing options + * + * @param string $optionValue + * @param array $options + * + * @return bool + */ + public function containsOption($optionValue, $options) + { + if ($this->validationDisabled) { + return true; + } + + foreach ($options as $option) { + if ($option['value'] == $optionValue) { + return true; + } + } + + return false; + } + + /** + * Returns list of available field options + * + * @return array + */ + public function availableOptionValues() + { + $values = array(); + + foreach ($this->options as $option) { + $values[] = $option['value']; + } + + return $values; + } + + /** + * Disables the internal validation of the field. + * + * @return self + */ + public function disableValidation() + { + $this->validationDisabled = true; + + return $this; + } +} diff --git a/vendor/symfony/dom-crawler/Symfony/Component/DomCrawler/Field/FileFormField.php b/vendor/symfony/dom-crawler/Symfony/Component/DomCrawler/Field/FileFormField.php new file mode 100755 index 0000000..bbdf467 --- /dev/null +++ b/vendor/symfony/dom-crawler/Symfony/Component/DomCrawler/Field/FileFormField.php @@ -0,0 +1,112 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\DomCrawler\Field; + +/** + * FileFormField represents a file form field (an HTML file input tag). + * + * @author Fabien Potencier + * + * @api + */ +class FileFormField extends FormField +{ + /** + * Sets the PHP error code associated with the field. + * + * @param int $error The error code (one of UPLOAD_ERR_INI_SIZE, UPLOAD_ERR_FORM_SIZE, UPLOAD_ERR_PARTIAL, UPLOAD_ERR_NO_FILE, UPLOAD_ERR_NO_TMP_DIR, UPLOAD_ERR_CANT_WRITE, or UPLOAD_ERR_EXTENSION) + * + * @throws \InvalidArgumentException When error code doesn't exist + */ + public function setErrorCode($error) + { + $codes = array(UPLOAD_ERR_INI_SIZE, UPLOAD_ERR_FORM_SIZE, UPLOAD_ERR_PARTIAL, UPLOAD_ERR_NO_FILE, UPLOAD_ERR_NO_TMP_DIR, UPLOAD_ERR_CANT_WRITE, UPLOAD_ERR_EXTENSION); + if (!in_array($error, $codes)) { + throw new \InvalidArgumentException(sprintf('The error code %s is not valid.', $error)); + } + + $this->value = array('name' => '', 'type' => '', 'tmp_name' => '', 'error' => $error, 'size' => 0); + } + + /** + * Sets the value of the field. + * + * @param string $value The value of the field + * + * @api + */ + public function upload($value) + { + $this->setValue($value); + } + + /** + * Sets the value of the field. + * + * @param string $value The value of the field + */ + public function setValue($value) + { + if (null !== $value && is_readable($value)) { + $error = UPLOAD_ERR_OK; + $size = filesize($value); + $info = pathinfo($value); + $name = $info['basename']; + + // copy to a tmp location + $tmp = sys_get_temp_dir().'/'.sha1(uniqid(mt_rand(), true)); + if (array_key_exists('extension', $info)) { + $tmp .= '.'.$info['extension']; + } + if (is_file($tmp)) { + unlink($tmp); + } + copy($value, $tmp); + $value = $tmp; + } else { + $error = UPLOAD_ERR_NO_FILE; + $size = 0; + $name = ''; + $value = ''; + } + + $this->value = array('name' => $name, 'type' => '', 'tmp_name' => $value, 'error' => $error, 'size' => $size); + } + + /** + * Sets path to the file as string for simulating HTTP request + * + * @param string $path The path to the file + */ + public function setFilePath($path) + { + parent::setValue($path); + } + + /** + * Initializes the form field. + * + * @throws \LogicException When node type is incorrect + */ + protected function initialize() + { + if ('input' !== $this->node->nodeName) { + throw new \LogicException(sprintf('A FileFormField can only be created from an input tag (%s given).', $this->node->nodeName)); + } + + if ('file' !== strtolower($this->node->getAttribute('type'))) { + throw new \LogicException(sprintf('A FileFormField can only be created from an input tag with a type of file (given type is %s).', $this->node->getAttribute('type'))); + } + + $this->setValue(null); + } +} diff --git a/vendor/symfony/dom-crawler/Symfony/Component/DomCrawler/Field/FormField.php b/vendor/symfony/dom-crawler/Symfony/Component/DomCrawler/Field/FormField.php new file mode 100755 index 0000000..9db4335 --- /dev/null +++ b/vendor/symfony/dom-crawler/Symfony/Component/DomCrawler/Field/FormField.php @@ -0,0 +1,116 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\DomCrawler\Field; + +/** + * FormField is the abstract class for all form fields. + * + * @author Fabien Potencier + */ +abstract class FormField +{ + /** + * @var \DOMNode + */ + protected $node; + /** + * @var string + */ + protected $name; + /** + * @var string + */ + protected $value; + /** + * @var \DOMDocument + */ + protected $document; + /** + * @var \DOMXPath + */ + protected $xpath; + /** + * @var bool + */ + protected $disabled; + + /** + * Constructor. + * + * @param \DOMNode $node The node associated with this field + */ + public function __construct(\DOMNode $node) + { + $this->node = $node; + $this->name = $node->getAttribute('name'); + $this->xpath = new \DOMXPath($node->ownerDocument); + + $this->initialize(); + } + + /** + * Returns the name of the field. + * + * @return string The name of the field + */ + public function getName() + { + return $this->name; + } + + /** + * Gets the value of the field. + * + * @return string|array The value of the field + */ + public function getValue() + { + return $this->value; + } + + /** + * Sets the value of the field. + * + * @param string $value The value of the field + * + * @api + */ + public function setValue($value) + { + $this->value = (string) $value; + } + + /** + * Returns true if the field should be included in the submitted values. + * + * @return bool true if the field should be included in the submitted values, false otherwise + */ + public function hasValue() + { + return true; + } + + /** + * Check if the current field is disabled + * + * @return bool + */ + public function isDisabled() + { + return $this->node->hasAttribute('disabled'); + } + + /** + * Initializes the form field. + */ + abstract protected function initialize(); +} diff --git a/vendor/symfony/dom-crawler/Symfony/Component/DomCrawler/Field/InputFormField.php b/vendor/symfony/dom-crawler/Symfony/Component/DomCrawler/Field/InputFormField.php new file mode 100755 index 0000000..b9bd0a4 --- /dev/null +++ b/vendor/symfony/dom-crawler/Symfony/Component/DomCrawler/Field/InputFormField.php @@ -0,0 +1,47 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\DomCrawler\Field; + +/** + * InputFormField represents an input form field (an HTML input tag). + * + * For inputs with type of file, checkbox, or radio, there are other more + * specialized classes (cf. FileFormField and ChoiceFormField). + * + * @author Fabien Potencier + * + * @api + */ +class InputFormField extends FormField +{ + /** + * Initializes the form field. + * + * @throws \LogicException When node type is incorrect + */ + protected function initialize() + { + if ('input' !== $this->node->nodeName && 'button' !== $this->node->nodeName) { + throw new \LogicException(sprintf('An InputFormField can only be created from an input or button tag (%s given).', $this->node->nodeName)); + } + + if ('checkbox' === strtolower($this->node->getAttribute('type'))) { + throw new \LogicException('Checkboxes should be instances of ChoiceFormField.'); + } + + if ('file' === strtolower($this->node->getAttribute('type'))) { + throw new \LogicException('File inputs should be instances of FileFormField.'); + } + + $this->value = $this->node->getAttribute('value'); + } +} diff --git a/vendor/symfony/dom-crawler/Symfony/Component/DomCrawler/Field/TextareaFormField.php b/vendor/symfony/dom-crawler/Symfony/Component/DomCrawler/Field/TextareaFormField.php new file mode 100755 index 0000000..a14e707 --- /dev/null +++ b/vendor/symfony/dom-crawler/Symfony/Component/DomCrawler/Field/TextareaFormField.php @@ -0,0 +1,39 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\DomCrawler\Field; + +/** + * TextareaFormField represents a textarea form field (an HTML textarea tag). + * + * @author Fabien Potencier + * + * @api + */ +class TextareaFormField extends FormField +{ + /** + * Initializes the form field. + * + * @throws \LogicException When node type is incorrect + */ + protected function initialize() + { + if ('textarea' !== $this->node->nodeName) { + throw new \LogicException(sprintf('A TextareaFormField can only be created from a textarea tag (%s given).', $this->node->nodeName)); + } + + $this->value = ''; + foreach ($this->node->childNodes as $node) { + $this->value .= $node->wholeText; + } + } +} diff --git a/vendor/symfony/dom-crawler/Symfony/Component/DomCrawler/Form.php b/vendor/symfony/dom-crawler/Symfony/Component/DomCrawler/Form.php new file mode 100755 index 0000000..e8faf49 --- /dev/null +++ b/vendor/symfony/dom-crawler/Symfony/Component/DomCrawler/Form.php @@ -0,0 +1,472 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\DomCrawler; + +use Symfony\Component\DomCrawler\Field\FormField; + +/** + * Form represents an HTML form. + * + * @author Fabien Potencier + * + * @api + */ +class Form extends Link implements \ArrayAccess +{ + /** + * @var \DOMNode + */ + private $button; + + /** + * @var FormFieldRegistry + */ + private $fields; + + /** + * Constructor. + * + * @param \DOMNode $node A \DOMNode instance + * @param string $currentUri The URI of the page where the form is embedded + * @param string $method The method to use for the link (if null, it defaults to the method defined by the form) + * + * @throws \LogicException if the node is not a button inside a form tag + * + * @api + */ + public function __construct(\DOMNode $node, $currentUri, $method = null) + { + parent::__construct($node, $currentUri, $method); + + $this->initialize(); + } + + /** + * Gets the form node associated with this form. + * + * @return \DOMNode A \DOMNode instance + */ + public function getFormNode() + { + return $this->node; + } + + /** + * Sets the value of the fields. + * + * @param array $values An array of field values + * + * @return Form + * + * @api + */ + public function setValues(array $values) + { + foreach ($values as $name => $value) { + $this->fields->set($name, $value); + } + + return $this; + } + + /** + * Gets the field values. + * + * The returned array does not include file fields (@see getFiles). + * + * @return array An array of field values. + * + * @api + */ + public function getValues() + { + $values = array(); + foreach ($this->fields->all() as $name => $field) { + if ($field->isDisabled()) { + continue; + } + + if (!$field instanceof Field\FileFormField && $field->hasValue()) { + $values[$name] = $field->getValue(); + } + } + + return $values; + } + + /** + * Gets the file field values. + * + * @return array An array of file field values. + * + * @api + */ + public function getFiles() + { + if (!in_array($this->getMethod(), array('POST', 'PUT', 'DELETE', 'PATCH'))) { + return array(); + } + + $files = array(); + + foreach ($this->fields->all() as $name => $field) { + if ($field->isDisabled()) { + continue; + } + + if ($field instanceof Field\FileFormField) { + $files[$name] = $field->getValue(); + } + } + + return $files; + } + + /** + * Gets the field values as PHP. + * + * This method converts fields with the array notation + * (like foo[bar] to arrays) like PHP does. + * + * @return array An array of field values. + * + * @api + */ + public function getPhpValues() + { + $values = array(); + foreach ($this->getValues() as $name => $value) { + $qs = http_build_query(array($name => $value), '', '&'); + parse_str($qs, $expandedValue); + $varName = substr($name, 0, strlen(key($expandedValue))); + $values = array_replace_recursive($values, array($varName => current($expandedValue))); + } + + return $values; + } + + /** + * Gets the file field values as PHP. + * + * This method converts fields with the array notation + * (like foo[bar] to arrays) like PHP does. + * + * @return array An array of field values. + * + * @api + */ + public function getPhpFiles() + { + $values = array(); + foreach ($this->getFiles() as $name => $value) { + $qs = http_build_query(array($name => $value), '', '&'); + parse_str($qs, $expandedValue); + $varName = substr($name, 0, strlen(key($expandedValue))); + $values = array_replace_recursive($values, array($varName => current($expandedValue))); + } + + return $values; + } + + /** + * Gets the URI of the form. + * + * The returned URI is not the same as the form "action" attribute. + * This method merges the value if the method is GET to mimics + * browser behavior. + * + * @return string The URI + * + * @api + */ + public function getUri() + { + $uri = parent::getUri(); + + if (!in_array($this->getMethod(), array('POST', 'PUT', 'DELETE', 'PATCH')) && $queryString = http_build_query($this->getValues(), null, '&')) { + $sep = false === strpos($uri, '?') ? '?' : '&'; + $uri .= $sep.$queryString; + } + + return $uri; + } + + protected function getRawUri() + { + return $this->node->getAttribute('action'); + } + + /** + * Gets the form method. + * + * If no method is defined in the form, GET is returned. + * + * @return string The method + * + * @api + */ + public function getMethod() + { + if (null !== $this->method) { + return $this->method; + } + + return $this->node->getAttribute('method') ? strtoupper($this->node->getAttribute('method')) : 'GET'; + } + + /** + * Returns true if the named field exists. + * + * @param string $name The field name + * + * @return bool true if the field exists, false otherwise + * + * @api + */ + public function has($name) + { + return $this->fields->has($name); + } + + /** + * Removes a field from the form. + * + * @param string $name The field name + * + * @throws \InvalidArgumentException when the name is malformed + * + * @api + */ + public function remove($name) + { + $this->fields->remove($name); + } + + /** + * Gets a named field. + * + * @param string $name The field name + * + * @return FormField The field instance + * + * @throws \InvalidArgumentException When field is not present in this form + * + * @api + */ + public function get($name) + { + return $this->fields->get($name); + } + + /** + * Sets a named field. + * + * @param FormField $field The field + * + * @api + */ + public function set(FormField $field) + { + $this->fields->add($field); + } + + /** + * Gets all fields. + * + * @return FormField[] An array of fields + * + * @api + */ + public function all() + { + return $this->fields->all(); + } + + /** + * Returns true if the named field exists. + * + * @param string $name The field name + * + * @return bool true if the field exists, false otherwise + */ + public function offsetExists($name) + { + return $this->has($name); + } + + /** + * Gets the value of a field. + * + * @param string $name The field name + * + * @return FormField The associated Field instance + * + * @throws \InvalidArgumentException if the field does not exist + */ + public function offsetGet($name) + { + return $this->fields->get($name); + } + + /** + * Sets the value of a field. + * + * @param string $name The field name + * @param string|array $value The value of the field + * + * @throws \InvalidArgumentException if the field does not exist + */ + public function offsetSet($name, $value) + { + $this->fields->set($name, $value); + } + + /** + * Removes a field from the form. + * + * @param string $name The field name + */ + public function offsetUnset($name) + { + $this->fields->remove($name); + } + + /** + * Disables validation + * + * @return self + */ + public function disableValidation() + { + foreach ($this->fields->all() as $field) { + if ($field instanceof Field\ChoiceFormField) { + $field->disableValidation(); + } + } + + return $this; + } + + /** + * Sets the node for the form. + * + * Expects a 'submit' button \DOMNode and finds the corresponding form element. + * + * @param \DOMNode $node A \DOMNode instance + * + * @throws \LogicException If given node is not a button or input or does not have a form ancestor + */ + protected function setNode(\DOMNode $node) + { + $this->button = $node; + if ('button' === $node->nodeName || ('input' === $node->nodeName && in_array(strtolower($node->getAttribute('type')), array('submit', 'button', 'image')))) { + if ($node->hasAttribute('form')) { + // if the node has the HTML5-compliant 'form' attribute, use it + $formId = $node->getAttribute('form'); + $form = $node->ownerDocument->getElementById($formId); + if (null === $form) { + throw new \LogicException(sprintf('The selected node has an invalid form attribute (%s).', $formId)); + } + $this->node = $form; + + return; + } + // we loop until we find a form ancestor + do { + if (null === $node = $node->parentNode) { + throw new \LogicException('The selected node does not have a form ancestor.'); + } + } while ('form' !== $node->nodeName); + } elseif ('form' !== $node->nodeName) { + throw new \LogicException(sprintf('Unable to submit on a "%s" tag.', $node->nodeName)); + } + + $this->node = $node; + } + + /** + * Adds form elements related to this form. + * + * Creates an internal copy of the submitted 'button' element and + * the form node or the entire document depending on whether we need + * to find non-descendant elements through HTML5 'form' attribute. + */ + private function initialize() + { + $this->fields = new FormFieldRegistry(); + + $xpath = new \DOMXPath($this->node->ownerDocument); + + // add submitted button if it has a valid name + if ('form' !== $this->button->nodeName && $this->button->hasAttribute('name') && $this->button->getAttribute('name')) { + if ('input' == $this->button->nodeName && 'image' == strtolower($this->button->getAttribute('type'))) { + $name = $this->button->getAttribute('name'); + $this->button->setAttribute('value', '0'); + + // temporarily change the name of the input node for the x coordinate + $this->button->setAttribute('name', $name.'.x'); + $this->set(new Field\InputFormField($this->button)); + + // temporarily change the name of the input node for the y coordinate + $this->button->setAttribute('name', $name.'.y'); + $this->set(new Field\InputFormField($this->button)); + + // restore the original name of the input node + $this->button->setAttribute('name', $name); + } else { + $this->set(new Field\InputFormField($this->button)); + } + } + + // find form elements corresponding to the current form + if ($this->node->hasAttribute('id')) { + // corresponding elements are either descendants or have a matching HTML5 form attribute + $formId = Crawler::xpathLiteral($this->node->getAttribute('id')); + + $fieldNodes = $xpath->query(sprintf('descendant::input[@form=%s] | descendant::button[@form=%s] | descendant::textarea[@form=%s] | descendant::select[@form=%s] | //form[@id=%s]//input[not(@form)] | //form[@id=%s]//button[not(@form)] | //form[@id=%s]//textarea[not(@form)] | //form[@id=%s]//select[not(@form)]', $formId, $formId, $formId, $formId, $formId, $formId, $formId, $formId)); + foreach ($fieldNodes as $node) { + $this->addField($node); + } + } else { + // do the xpath query with $this->node as the context node, to only find descendant elements + // however, descendant elements with form attribute are not part of this form + $fieldNodes = $xpath->query('descendant::input[not(@form)] | descendant::button[not(@form)] | descendant::textarea[not(@form)] | descendant::select[not(@form)]', $this->node); + foreach ($fieldNodes as $node) { + $this->addField($node); + } + } + } + + private function addField(\DOMNode $node) + { + if (!$node->hasAttribute('name') || !$node->getAttribute('name')) { + return; + } + + $nodeName = $node->nodeName; + if ('select' == $nodeName || 'input' == $nodeName && 'checkbox' == strtolower($node->getAttribute('type'))) { + $this->set(new Field\ChoiceFormField($node)); + } elseif ('input' == $nodeName && 'radio' == strtolower($node->getAttribute('type'))) { + if ($this->has($node->getAttribute('name'))) { + $this->get($node->getAttribute('name'))->addChoice($node); + } else { + $this->set(new Field\ChoiceFormField($node)); + } + } elseif ('input' == $nodeName && 'file' == strtolower($node->getAttribute('type'))) { + $this->set(new Field\FileFormField($node)); + } elseif ('input' == $nodeName && !in_array(strtolower($node->getAttribute('type')), array('submit', 'button', 'image'))) { + $this->set(new Field\InputFormField($node)); + } elseif ('textarea' == $nodeName) { + $this->set(new Field\TextareaFormField($node)); + } + } +} diff --git a/vendor/symfony/dom-crawler/Symfony/Component/DomCrawler/FormFieldRegistry.php b/vendor/symfony/dom-crawler/Symfony/Component/DomCrawler/FormFieldRegistry.php new file mode 100755 index 0000000..150f94d --- /dev/null +++ b/vendor/symfony/dom-crawler/Symfony/Component/DomCrawler/FormFieldRegistry.php @@ -0,0 +1,220 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\DomCrawler; + +use Symfony\Component\DomCrawler\Field\FormField; + +/** + * This is an internal class that must not be used directly. + */ +class FormFieldRegistry +{ + private $fields = array(); + + private $base; + + /** + * Adds a field to the registry. + * + * @param FormField $field The field + * + * @throws \InvalidArgumentException when the name is malformed + */ + public function add(FormField $field) + { + $segments = $this->getSegments($field->getName()); + + $target =& $this->fields; + while ($segments) { + if (!is_array($target)) { + $target = array(); + } + $path = array_shift($segments); + if ('' === $path) { + $target =& $target[]; + } else { + $target =& $target[$path]; + } + } + $target = $field; + } + + /** + * Removes a field and its children from the registry. + * + * @param string $name The fully qualified name of the base field + * + * @throws \InvalidArgumentException when the name is malformed + */ + public function remove($name) + { + $segments = $this->getSegments($name); + $target =& $this->fields; + while (count($segments) > 1) { + $path = array_shift($segments); + if (!array_key_exists($path, $target)) { + return; + } + $target =& $target[$path]; + } + unset($target[array_shift($segments)]); + } + + /** + * Returns the value of the field and its children. + * + * @param string $name The fully qualified name of the field + * + * @return mixed The value of the field + * + * @throws \InvalidArgumentException when the name is malformed + * @throws \InvalidArgumentException if the field does not exist + */ + public function &get($name) + { + $segments = $this->getSegments($name); + $target =& $this->fields; + while ($segments) { + $path = array_shift($segments); + if (!array_key_exists($path, $target)) { + throw new \InvalidArgumentException(sprintf('Unreachable field "%s"', $path)); + } + $target =& $target[$path]; + } + + return $target; + } + + /** + * Tests whether the form has the given field. + * + * @param string $name The fully qualified name of the field + * + * @return bool Whether the form has the given field + */ + public function has($name) + { + try { + $this->get($name); + + return true; + } catch (\InvalidArgumentException $e) { + return false; + } + } + + /** + * Set the value of a field and its children. + * + * @param string $name The fully qualified name of the field + * @param mixed $value The value + * + * @throws \InvalidArgumentException when the name is malformed + * @throws \InvalidArgumentException if the field does not exist + */ + public function set($name, $value) + { + $target =& $this->get($name); + if (!is_array($value) || $target instanceof Field\ChoiceFormField) { + $target->setValue($value); + } else { + $fields = self::create($name, $value); + foreach ($fields->all() as $k => $v) { + $this->set($k, $v); + } + } + } + + /** + * Returns the list of field with their value. + * + * @return FormField[] The list of fields as array((string) Fully qualified name => (mixed) value) + */ + public function all() + { + return $this->walk($this->fields, $this->base); + } + + /** + * Creates an instance of the class. + * + * This function is made private because it allows overriding the $base and + * the $values properties without any type checking. + * + * @param string $base The fully qualified name of the base field + * @param array $values The values of the fields + * + * @return FormFieldRegistry + */ + private static function create($base, array $values) + { + $registry = new static(); + $registry->base = $base; + $registry->fields = $values; + + return $registry; + } + + /** + * Transforms a PHP array in a list of fully qualified name / value. + * + * @param array $array The PHP array + * @param string $base The name of the base field + * @param array $output The initial values + * + * @return array The list of fields as array((string) Fully qualified name => (mixed) value) + */ + private function walk(array $array, $base = '', array &$output = array()) + { + foreach ($array as $k => $v) { + $path = empty($base) ? $k : sprintf("%s[%s]", $base, $k); + if (is_array($v)) { + $this->walk($v, $path, $output); + } else { + $output[$path] = $v; + } + } + + return $output; + } + + /** + * Splits a field name into segments as a web browser would do. + * + * + * getSegments('base[foo][3][]') = array('base', 'foo, '3', ''); + * + * + * @param string $name The name of the field + * + * @return string[] The list of segments + * + * @throws \InvalidArgumentException when the name is malformed + */ + private function getSegments($name) + { + if (preg_match('/^(?P[^[]+)(?P(\[.*)|$)/', $name, $m)) { + $segments = array($m['base']); + while (!empty($m['extra'])) { + if (preg_match('/^\[(?P.*?)\](?P.*)$/', $m['extra'], $m)) { + $segments[] = $m['segment']; + } else { + throw new \InvalidArgumentException(sprintf('Malformed field path "%s"', $name)); + } + } + + return $segments; + } + + throw new \InvalidArgumentException(sprintf('Malformed field path "%s"', $name)); + } +} diff --git a/vendor/symfony/dom-crawler/Symfony/Component/DomCrawler/LICENSE b/vendor/symfony/dom-crawler/Symfony/Component/DomCrawler/LICENSE new file mode 100755 index 0000000..0b3292c --- /dev/null +++ b/vendor/symfony/dom-crawler/Symfony/Component/DomCrawler/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2004-2014 Fabien Potencier + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is furnished +to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/vendor/symfony/dom-crawler/Symfony/Component/DomCrawler/Link.php b/vendor/symfony/dom-crawler/Symfony/Component/DomCrawler/Link.php new file mode 100755 index 0000000..05d5e92 --- /dev/null +++ b/vendor/symfony/dom-crawler/Symfony/Component/DomCrawler/Link.php @@ -0,0 +1,197 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\DomCrawler; + +/** + * Link represents an HTML link (an HTML a or area tag). + * + * @author Fabien Potencier + * + * @api + */ +class Link +{ + /** + * @var \DOMNode A \DOMNode instance + */ + protected $node; + /** + * @var string The method to use for the link + */ + protected $method; + /** + * @var string The URI of the page where the link is embedded (or the base href) + */ + protected $currentUri; + + /** + * Constructor. + * + * @param \DOMNode $node A \DOMNode instance + * @param string $currentUri The URI of the page where the link is embedded (or the base href) + * @param string $method The method to use for the link (get by default) + * + * @throws \InvalidArgumentException if the node is not a link + * + * @api + */ + public function __construct(\DOMNode $node, $currentUri, $method = 'GET') + { + if (!in_array(strtolower(substr($currentUri, 0, 4)), array('http', 'file'))) { + throw new \InvalidArgumentException(sprintf('Current URI must be an absolute URL ("%s").', $currentUri)); + } + + $this->setNode($node); + $this->method = $method ? strtoupper($method) : null; + $this->currentUri = $currentUri; + } + + /** + * Gets the node associated with this link. + * + * @return \DOMNode A \DOMNode instance + */ + public function getNode() + { + return $this->node; + } + + /** + * Gets the method associated with this link. + * + * @return string The method + * + * @api + */ + public function getMethod() + { + return $this->method; + } + + /** + * Gets the URI associated with this link. + * + * @return string The URI + * + * @api + */ + public function getUri() + { + $uri = trim($this->getRawUri()); + + // absolute URL? + if (null !== parse_url($uri, PHP_URL_SCHEME)) { + return $uri; + } + + // empty URI + if (!$uri) { + return $this->currentUri; + } + + // only an anchor + if ('#' === $uri[0]) { + $baseUri = $this->currentUri; + if (false !== $pos = strpos($baseUri, '#')) { + $baseUri = substr($baseUri, 0, $pos); + } + + return $baseUri.$uri; + } + + // only a query string + if ('?' === $uri[0]) { + $baseUri = $this->currentUri; + + // remove the query string from the current URI + if (false !== $pos = strpos($baseUri, '?')) { + $baseUri = substr($baseUri, 0, $pos); + } + + return $baseUri.$uri; + } + + // absolute URL with relative schema + if (0 === strpos($uri, '//')) { + return preg_replace('#^([^/]*)//.*$#', '$1', $this->currentUri).$uri; + } + + $baseUri = preg_replace('#^(.*?//[^/]*)(?:\/.*)?$#', '$1', $this->currentUri); + + // absolute path + if ('/' === $uri[0]) { + return $baseUri.$uri; + } + + // relative path + $path = parse_url(substr($this->currentUri, strlen($baseUri)), PHP_URL_PATH); + $path = $this->canonicalizePath(substr($path, 0, strrpos($path, '/')).'/'.$uri); + + return $baseUri.('' === $path || '/' !== $path[0] ? '/' : '').$path; + } + + /** + * Returns raw URI data. + * + * @return string + */ + protected function getRawUri() + { + return $this->node->getAttribute('href'); + } + + /** + * Returns the canonicalized URI path (see RFC 3986, section 5.2.4) + * + * @param string $path URI path + * + * @return string + */ + protected function canonicalizePath($path) + { + if ('' === $path || '/' === $path) { + return $path; + } + + if ('.' === substr($path, -1)) { + $path = $path.'/'; + } + + $output = array(); + + foreach (explode('/', $path) as $segment) { + if ('..' === $segment) { + array_pop($output); + } elseif ('.' !== $segment) { + array_push($output, $segment); + } + } + + return implode('/', $output); + } + + /** + * Sets current \DOMNode instance. + * + * @param \DOMNode $node A \DOMNode instance + * + * @throws \LogicException If given node is not an anchor + */ + protected function setNode(\DOMNode $node) + { + if ('a' !== $node->nodeName && 'area' !== $node->nodeName) { + throw new \LogicException(sprintf('Unable to click on a "%s" tag.', $node->nodeName)); + } + + $this->node = $node; + } +} diff --git a/vendor/symfony/dom-crawler/Symfony/Component/DomCrawler/README.md b/vendor/symfony/dom-crawler/Symfony/Component/DomCrawler/README.md new file mode 100755 index 0000000..489e468 --- /dev/null +++ b/vendor/symfony/dom-crawler/Symfony/Component/DomCrawler/README.md @@ -0,0 +1,32 @@ +DomCrawler Component +==================== + +DomCrawler eases DOM navigation for HTML and XML documents. + +If you are familiar with jQuery, DomCrawler is a PHP equivalent: + + use Symfony\Component\DomCrawler\Crawler; + + $crawler = new Crawler(); + $crawler->addContent('

    Hello World!

    '); + + print $crawler->filterXPath('descendant-or-self::body/p')->text(); + +If you are also using the CssSelector component, you can use CSS Selectors +instead of XPath expressions: + + use Symfony\Component\DomCrawler\Crawler; + + $crawler = new Crawler(); + $crawler->addContent('

    Hello World!

    '); + + print $crawler->filter('body > p')->text(); + +Resources +--------- + +You can run the unit tests with the following command: + + $ cd path/to/Symfony/Component/DomCrawler/ + $ composer.phar install + $ phpunit diff --git a/vendor/symfony/dom-crawler/Symfony/Component/DomCrawler/Tests/CrawlerTest.php b/vendor/symfony/dom-crawler/Symfony/Component/DomCrawler/Tests/CrawlerTest.php new file mode 100755 index 0000000..44c3a56 --- /dev/null +++ b/vendor/symfony/dom-crawler/Symfony/Component/DomCrawler/Tests/CrawlerTest.php @@ -0,0 +1,882 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\DomCrawler\Tests; + +use Symfony\Component\CssSelector\CssSelector; +use Symfony\Component\DomCrawler\Crawler; + +class CrawlerTest extends \PHPUnit_Framework_TestCase +{ + public function testConstructor() + { + $crawler = new Crawler(); + $this->assertCount(0, $crawler, '__construct() returns an empty crawler'); + + $crawler = new Crawler(new \DOMNode()); + $this->assertCount(1, $crawler, '__construct() takes a node as a first argument'); + } + + /** + * @covers Symfony\Component\DomCrawler\Crawler::add + */ + public function testAdd() + { + $crawler = new Crawler(); + $crawler->add($this->createDomDocument()); + $this->assertEquals('foo', $crawler->filterXPath('//div')->attr('class'), '->add() adds nodes from a \DOMDocument'); + + $crawler = new Crawler(); + $crawler->add($this->createNodeList()); + $this->assertEquals('foo', $crawler->filterXPath('//div')->attr('class'), '->add() adds nodes from a \DOMNodeList'); + + foreach ($this->createNodeList() as $node) { + $list[] = $node; + } + $crawler = new Crawler(); + $crawler->add($list); + $this->assertEquals('foo', $crawler->filterXPath('//div')->attr('class'), '->add() adds nodes from an array of nodes'); + + $crawler = new Crawler(); + $crawler->add($this->createNodeList()->item(0)); + $this->assertEquals('foo', $crawler->filterXPath('//div')->attr('class'), '->add() adds nodes from an \DOMNode'); + + $crawler = new Crawler(); + $crawler->add('Foo'); + $this->assertEquals('Foo', $crawler->filterXPath('//body')->text(), '->add() adds nodes from a string'); + } + + /** + * @expectedException \InvalidArgumentException + */ + public function testAddInvalidNode() + { + $crawler = new Crawler(); + $crawler->add(1); + } + + /** + * @covers Symfony\Component\DomCrawler\Crawler::addHtmlContent + */ + public function testAddHtmlContent() + { + $crawler = new Crawler(); + $crawler->addHtmlContent('
    ', 'UTF-8'); + + $this->assertEquals('foo', $crawler->filterXPath('//div')->attr('class'), '->addHtmlContent() adds nodes from an HTML string'); + + $crawler->addHtmlContent('', 'UTF-8'); + + $this->assertEquals('http://symfony.com', $crawler->filterXPath('//base')->attr('href'), '->addHtmlContent() adds nodes from an HTML string'); + $this->assertEquals('http://symfony.com/contact', $crawler->filterXPath('//a')->link()->getUri(), '->addHtmlContent() adds nodes from an HTML string'); + } + + /** + * @covers Symfony\Component\DomCrawler\Crawler::addHtmlContent + */ + public function testAddHtmlContentCharset() + { + $crawler = new Crawler(); + $crawler->addHtmlContent('
    Tiếng Việt', 'UTF-8'); + + $this->assertEquals('Tiếng Việt', $crawler->filterXPath('//div')->text()); + } + + /** + * @covers Symfony\Component\DomCrawler\Crawler::addHtmlContent + */ + public function testAddHtmlContentInvalidBaseTag() + { + $crawler = new Crawler(null, 'http://symfony.com'); + + $crawler->addHtmlContent('', 'UTF-8'); + + $this->assertEquals('http://symfony.com/contact', current($crawler->filterXPath('//a')->links())->getUri(), '->addHtmlContent() correctly handles a non-existent base tag href attribute'); + } + + /** + * @covers Symfony\Component\DomCrawler\Crawler::addHtmlContent + */ + public function testAddHtmlContentUnsupportedCharset() + { + $crawler = new Crawler(); + $crawler->addHtmlContent(file_get_contents(__DIR__.'/Fixtures/windows-1250.html'), 'Windows-1250'); + + $this->assertEquals('ŽťÄýů', $crawler->filterXPath('//p')->text()); + } + + /** + * @covers Symfony\Component\DomCrawler\Crawler::addHtmlContent + */ + public function testAddHtmlContentCharsetGbk() + { + $crawler = new Crawler(); + //gbk encode of

    中文

    + $crawler->addHtmlContent(base64_decode('PGh0bWw+PHA+1tDOxDwvcD48L2h0bWw+'), 'gbk'); + + $this->assertEquals('中文', $crawler->filterXPath('//p')->text()); + } + + /** + * @covers Symfony\Component\DomCrawler\Crawler::addHtmlContent + */ + public function testAddHtmlContentWithErrors() + { + $internalErrors = libxml_use_internal_errors(true); + + $crawler = new Crawler(); + $crawler->addHtmlContent(<< + + + + + + + +EOF + , 'UTF-8'); + + $errors = libxml_get_errors(); + $this->assertCount(1, $errors); + $this->assertEquals("Tag nav invalid\n", $errors[0]->message); + + libxml_clear_errors(); + libxml_use_internal_errors($internalErrors); + } + + /** + * @covers Symfony\Component\DomCrawler\Crawler::addXmlContent + */ + public function testAddXmlContent() + { + $crawler = new Crawler(); + $crawler->addXmlContent('
    ', 'UTF-8'); + + $this->assertEquals('foo', $crawler->filterXPath('//div')->attr('class'), '->addXmlContent() adds nodes from an XML string'); + } + + /** + * @covers Symfony\Component\DomCrawler\Crawler::addXmlContent + */ + public function testAddXmlContentCharset() + { + $crawler = new Crawler(); + $crawler->addXmlContent('
    Tiếng Việt
    ', 'UTF-8'); + + $this->assertEquals('Tiếng Việt', $crawler->filterXPath('//div')->text()); + } + + /** + * @covers Symfony\Component\DomCrawler\Crawler::addXmlContent + */ + public function testAddXmlContentWithErrors() + { + $internalErrors = libxml_use_internal_errors(true); + + $crawler = new Crawler(); + $crawler->addXmlContent(<< + + + + +
    + + +EOF + , 'UTF-8'); + + $this->assertTrue(count(libxml_get_errors()) > 1); + + libxml_clear_errors(); + libxml_use_internal_errors($internalErrors); + } + + /** + * @covers Symfony\Component\DomCrawler\Crawler::addContent + */ + public function testAddContent() + { + $crawler = new Crawler(); + $crawler->addContent('
    ', 'text/html; charset=UTF-8'); + $this->assertEquals('foo', $crawler->filterXPath('//div')->attr('class'), '->addContent() adds nodes from an HTML string'); + + $crawler = new Crawler(); + $crawler->addContent('
    ', 'text/html; charset=UTF-8; dir=RTL'); + $this->assertEquals('foo', $crawler->filterXPath('//div')->attr('class'), '->addContent() adds nodes from an HTML string with extended content type'); + + $crawler = new Crawler(); + $crawler->addContent('
    '); + $this->assertEquals('foo', $crawler->filterXPath('//div')->attr('class'), '->addContent() uses text/html as the default type'); + + $crawler = new Crawler(); + $crawler->addContent('
    ', 'text/xml; charset=UTF-8'); + $this->assertEquals('foo', $crawler->filterXPath('//div')->attr('class'), '->addContent() adds nodes from an XML string'); + + $crawler = new Crawler(); + $crawler->addContent('
    ', 'text/xml'); + $this->assertEquals('foo', $crawler->filterXPath('//div')->attr('class'), '->addContent() adds nodes from an XML string'); + + $crawler = new Crawler(); + $crawler->addContent('foo bar', 'text/plain'); + $this->assertCount(0, $crawler, '->addContent() does nothing if the type is not (x|ht)ml'); + + $crawler = new Crawler(); + $crawler->addContent('中文'); + $this->assertEquals('中文', $crawler->filterXPath('//span')->text(), '->addContent() guess wrong charset'); + + $crawler = new Crawler(); + $crawler->addContent(mb_convert_encoding('日本語', 'SJIS', 'UTF-8')); + $this->assertEquals('日本語', $crawler->filterXPath('//body')->text(), '->addContent() can recognize "Shift_JIS" in html5 meta charset tag'); + } + + /** + * @covers Symfony\Component\DomCrawler\Crawler::addDocument + */ + public function testAddDocument() + { + $crawler = new Crawler(); + $crawler->addDocument($this->createDomDocument()); + + $this->assertEquals('foo', $crawler->filterXPath('//div')->attr('class'), '->addDocument() adds nodes from a \DOMDocument'); + } + + /** + * @covers Symfony\Component\DomCrawler\Crawler::addNodeList + */ + public function testAddNodeList() + { + $crawler = new Crawler(); + $crawler->addNodeList($this->createNodeList()); + + $this->assertEquals('foo', $crawler->filterXPath('//div')->attr('class'), '->addNodeList() adds nodes from a \DOMNodeList'); + } + + /** + * @covers Symfony\Component\DomCrawler\Crawler::addNodes + */ + public function testAddNodes() + { + foreach ($this->createNodeList() as $node) { + $list[] = $node; + } + + $crawler = new Crawler(); + $crawler->addNodes($list); + + $this->assertEquals('foo', $crawler->filterXPath('//div')->attr('class'), '->addNodes() adds nodes from an array of nodes'); + } + + /** + * @covers Symfony\Component\DomCrawler\Crawler::addNode + */ + public function testAddNode() + { + $crawler = new Crawler(); + $crawler->addNode($this->createNodeList()->item(0)); + + $this->assertEquals('foo', $crawler->filterXPath('//div')->attr('class'), '->addNode() adds nodes from an \DOMNode'); + } + + public function testClear() + { + $crawler = new Crawler(new \DOMNode()); + $crawler->clear(); + $this->assertCount(0, $crawler, '->clear() removes all the nodes from the crawler'); + } + + public function testEq() + { + $crawler = $this->createTestCrawler()->filterXPath('//li'); + $this->assertNotSame($crawler, $crawler->eq(0), '->eq() returns a new instance of a crawler'); + $this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Crawler', $crawler, '->eq() returns a new instance of a crawler'); + + $this->assertEquals('Two', $crawler->eq(1)->text(), '->eq() returns the nth node of the list'); + $this->assertCount(0, $crawler->eq(100), '->eq() returns an empty crawler if the nth node does not exist'); + } + + public function testEach() + { + $data = $this->createTestCrawler()->filterXPath('//ul[1]/li')->each(function ($node, $i) { + return $i.'-'.$node->text(); + }); + + $this->assertEquals(array('0-One', '1-Two', '2-Three'), $data, '->each() executes an anonymous function on each node of the list'); + } + + public function testReduce() + { + $crawler = $this->createTestCrawler()->filterXPath('//ul[1]/li'); + $nodes = $crawler->reduce(function ($node, $i) { + return $i == 1 ? false : true; + }); + $this->assertNotSame($nodes, $crawler, '->reduce() returns a new instance of a crawler'); + $this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Crawler', $nodes, '->reduce() returns a new instance of a crawler'); + + $this->assertCount(2, $nodes, '->reduce() filters the nodes in the list'); + } + + public function testAttr() + { + $this->assertEquals('first', $this->createTestCrawler()->filterXPath('//li')->attr('class'), '->attr() returns the attribute of the first element of the node list'); + + try { + $this->createTestCrawler()->filterXPath('//ol')->attr('class'); + $this->fail('->attr() throws an \InvalidArgumentException if the node list is empty'); + } catch (\InvalidArgumentException $e) { + $this->assertTrue(true, '->attr() throws an \InvalidArgumentException if the node list is empty'); + } + } + + public function testMissingAttrValueIsNull() + { + $crawler = new Crawler(); + $crawler->addContent('
    ', 'text/html; charset=UTF-8'); + $div = $crawler->filterXPath('//div'); + + $this->assertEquals('sample value', $div->attr('non-empty-attr'), '->attr() reads non-empty attributes correctly'); + $this->assertEquals('', $div->attr('empty-attr'), '->attr() reads empty attributes correctly'); + $this->assertNull($div->attr('missing-attr'), '->attr() reads missing attributes correctly'); + } + + public function testText() + { + $this->assertEquals('One', $this->createTestCrawler()->filterXPath('//li')->text(), '->text() returns the node value of the first element of the node list'); + + try { + $this->createTestCrawler()->filterXPath('//ol')->text(); + $this->fail('->text() throws an \InvalidArgumentException if the node list is empty'); + } catch (\InvalidArgumentException $e) { + $this->assertTrue(true, '->text() throws an \InvalidArgumentException if the node list is empty'); + } + } + + public function testHtml() + { + $this->assertEquals('Bar', $this->createTestCrawler()->filterXPath('//a[5]')->html()); + $this->assertEquals('' + , trim($this->createTestCrawler()->filterXPath('//form[@id="FooFormId"]')->html())); + + try { + $this->createTestCrawler()->filterXPath('//ol')->html(); + $this->fail('->html() throws an \InvalidArgumentException if the node list is empty'); + } catch (\InvalidArgumentException $e) { + $this->assertTrue(true, '->html() throws an \InvalidArgumentException if the node list is empty'); + } + } + + public function testExtract() + { + $crawler = $this->createTestCrawler()->filterXPath('//ul[1]/li'); + + $this->assertEquals(array('One', 'Two', 'Three'), $crawler->extract('_text'), '->extract() returns an array of extracted data from the node list'); + $this->assertEquals(array(array('One', 'first'), array('Two', ''), array('Three', '')), $crawler->extract(array('_text', 'class')), '->extract() returns an array of extracted data from the node list'); + + $this->assertEquals(array(), $this->createTestCrawler()->filterXPath('//ol')->extract('_text'), '->extract() returns an empty array if the node list is empty'); + } + + public function testFilterXpathComplexQueries() + { + $crawler = $this->createTestCrawler()->filterXPath('//body'); + + $this->assertCount(0, $crawler->filterXPath('/input')); + $this->assertCount(0, $crawler->filterXPath('/body')); + $this->assertCount(1, $crawler->filterXPath('/_root/body')); + $this->assertCount(1, $crawler->filterXPath('./body')); + $this->assertCount(1, $crawler->filterXPath('.//body')); + $this->assertCount(5, $crawler->filterXPath('.//input')); + $this->assertCount(4, $crawler->filterXPath('//form')->filterXPath('//button | //input')); + $this->assertCount(1, $crawler->filterXPath('body')); + $this->assertCount(6, $crawler->filterXPath('//button | //input')); + $this->assertCount(1, $crawler->filterXPath('//body')); + $this->assertCount(1, $crawler->filterXPath('descendant-or-self::body')); + $this->assertCount(1, $crawler->filterXPath('//div[@id="parent"]')->filterXPath('./div'), 'A child selection finds only the current div'); + $this->assertCount(2, $crawler->filterXPath('//div[@id="parent"]')->filterXPath('descendant::div'), 'A descendant selector matches the current div and its child'); + $this->assertCount(2, $crawler->filterXPath('//div[@id="parent"]')->filterXPath('//div'), 'A descendant selector matches the current div and its child'); + $this->assertCount(5, $crawler->filterXPath('(//a | //div)//img')); + $this->assertCount(7, $crawler->filterXPath('((//a | //div)//img | //ul)')); + $this->assertCount(7, $crawler->filterXPath('( ( //a | //div )//img | //ul )')); + } + + /** + * @covers Symfony\Component\DomCrawler\Crawler::filterXPath + */ + public function testFilterXPath() + { + $crawler = $this->createTestCrawler(); + $this->assertNotSame($crawler, $crawler->filterXPath('//li'), '->filterXPath() returns a new instance of a crawler'); + $this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Crawler', $crawler, '->filterXPath() returns a new instance of a crawler'); + + $crawler = $this->createTestCrawler()->filterXPath('//ul'); + $this->assertCount(6, $crawler->filterXPath('//li'), '->filterXPath() filters the node list with the XPath expression'); + + $crawler = $this->createTestCrawler(); + $this->assertCount(3, $crawler->filterXPath('//body')->filterXPath('//button')->parents(), '->filterXpath() preserves parents when chained'); + } + + public function testFilterXPathWithDefaultNamespace() + { + $crawler = $this->createTestXmlCrawler()->filterXPath('//default:entry/default:id'); + $this->assertCount(1, $crawler, '->filterXPath() automatically registers a namespace'); + $this->assertSame('tag:youtube.com,2008:video:kgZRZmEc9j4', $crawler->text()); + } + + public function testFilterXPathWithCustomDefaultNamespace() + { + $crawler = $this->createTestXmlCrawler(); + $crawler->setDefaultNamespacePrefix('x'); + $crawler = $crawler->filterXPath('//x:entry/x:id'); + + $this->assertCount(1, $crawler, '->filterXPath() lets to override the default namespace prefix'); + $this->assertSame('tag:youtube.com,2008:video:kgZRZmEc9j4', $crawler->text()); + } + + public function testFilterXPathWithNamespace() + { + $crawler = $this->createTestXmlCrawler()->filterXPath('//yt:accessControl'); + $this->assertCount(2, $crawler, '->filterXPath() automatically registers a namespace'); + } + + public function testFilterXPathWithMultipleNamespaces() + { + $crawler = $this->createTestXmlCrawler()->filterXPath('//media:group/yt:aspectRatio'); + $this->assertCount(1, $crawler, '->filterXPath() automatically registers multiple namespaces'); + $this->assertSame('widescreen', $crawler->text()); + } + + public function testFilterXPathWithManuallyRegisteredNamespace() + { + $crawler = $this->createTestXmlCrawler(); + $crawler->registerNamespace('m', 'http://search.yahoo.com/mrss/'); + + $crawler = $crawler->filterXPath('//m:group/yt:aspectRatio'); + $this->assertCount(1, $crawler, '->filterXPath() uses manually registered namespace'); + $this->assertSame('widescreen', $crawler->text()); + } + + public function testFilterXPathWithAnUrl() + { + $crawler = $this->createTestXmlCrawler(); + + $crawler = $crawler->filterXPath('//media:category[@scheme="http://gdata.youtube.com/schemas/2007/categories.cat"]'); + $this->assertCount(1, $crawler); + $this->assertSame('Music', $crawler->text()); + } + + /** + * @covers Symfony\Component\DomCrawler\Crawler::filter + */ + public function testFilter() + { + $crawler = $this->createTestCrawler(); + $this->assertNotSame($crawler, $crawler->filter('li'), '->filter() returns a new instance of a crawler'); + $this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Crawler', $crawler, '->filter() returns a new instance of a crawler'); + + $crawler = $this->createTestCrawler()->filter('ul'); + + $this->assertCount(6, $crawler->filter('li'), '->filter() filters the node list with the CSS selector'); + } + + public function testFilterWithDefaultNamespace() + { + $crawler = $this->createTestXmlCrawler()->filter('default|entry default|id'); + $this->assertCount(1, $crawler, '->filter() automatically registers namespaces'); + $this->assertSame('tag:youtube.com,2008:video:kgZRZmEc9j4', $crawler->text()); + } + + public function testFilterWithNamespace() + { + CssSelector::disableHtmlExtension(); + + $crawler = $this->createTestXmlCrawler()->filter('yt|accessControl'); + $this->assertCount(2, $crawler, '->filter() automatically registers namespaces'); + } + + public function testFilterWithMultipleNamespaces() + { + CssSelector::disableHtmlExtension(); + + $crawler = $this->createTestXmlCrawler()->filter('media|group yt|aspectRatio'); + $this->assertCount(1, $crawler, '->filter() automatically registers namespaces'); + $this->assertSame('widescreen', $crawler->text()); + } + + public function testFilterWithDefaultNamespaceOnly() + { + $crawler = new Crawler(' + + + http://localhost/foo + weekly + 0.5 + 2012-11-16 + + + http://localhost/bar + weekly + 0.5 + 2012-11-16 + + + '); + + $this->assertEquals(2, $crawler->filter('url')->count()); + } + + public function testSelectLink() + { + $crawler = $this->createTestCrawler(); + $this->assertNotSame($crawler, $crawler->selectLink('Foo'), '->selectLink() returns a new instance of a crawler'); + $this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Crawler', $crawler, '->selectLink() returns a new instance of a crawler'); + + $this->assertCount(1, $crawler->selectLink('Fabien\'s Foo'), '->selectLink() selects links by the node values'); + $this->assertCount(1, $crawler->selectLink('Fabien\'s Bar'), '->selectLink() selects links by the alt attribute of a clickable image'); + + $this->assertCount(2, $crawler->selectLink('Fabien"s Foo'), '->selectLink() selects links by the node values'); + $this->assertCount(2, $crawler->selectLink('Fabien"s Bar'), '->selectLink() selects links by the alt attribute of a clickable image'); + + $this->assertCount(1, $crawler->selectLink('\' Fabien"s Foo'), '->selectLink() selects links by the node values'); + $this->assertCount(1, $crawler->selectLink('\' Fabien"s Bar'), '->selectLink() selects links by the alt attribute of a clickable image'); + + $this->assertCount(4, $crawler->selectLink('Foo'), '->selectLink() selects links by the node values'); + $this->assertCount(4, $crawler->selectLink('Bar'), '->selectLink() selects links by the node values'); + } + + public function testSelectButton() + { + $crawler = $this->createTestCrawler(); + $this->assertNotSame($crawler, $crawler->selectButton('FooValue'), '->selectButton() returns a new instance of a crawler'); + $this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Crawler', $crawler, '->selectButton() returns a new instance of a crawler'); + + $this->assertEquals(1, $crawler->selectButton('FooValue')->count(), '->selectButton() selects buttons'); + $this->assertEquals(1, $crawler->selectButton('FooName')->count(), '->selectButton() selects buttons'); + $this->assertEquals(1, $crawler->selectButton('FooId')->count(), '->selectButton() selects buttons'); + + $this->assertEquals(1, $crawler->selectButton('BarValue')->count(), '->selectButton() selects buttons'); + $this->assertEquals(1, $crawler->selectButton('BarName')->count(), '->selectButton() selects buttons'); + $this->assertEquals(1, $crawler->selectButton('BarId')->count(), '->selectButton() selects buttons'); + + $this->assertEquals(1, $crawler->selectButton('FooBarValue')->count(), '->selectButton() selects buttons with form attribute too'); + $this->assertEquals(1, $crawler->selectButton('FooBarName')->count(), '->selectButton() selects buttons with form attribute too'); + } + + public function testLink() + { + $crawler = $this->createTestCrawler('http://example.com/bar/')->selectLink('Foo'); + $this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Link', $crawler->link(), '->link() returns a Link instance'); + + $this->assertEquals('POST', $crawler->link('post')->getMethod(), '->link() takes a method as its argument'); + + $crawler = $this->createTestCrawler('http://example.com/bar')->selectLink('GetLink'); + $this->assertEquals('http://example.com/bar?get=param', $crawler->link()->getUri(), '->link() returns a Link instance'); + + try { + $this->createTestCrawler()->filterXPath('//ol')->link(); + $this->fail('->link() throws an \InvalidArgumentException if the node list is empty'); + } catch (\InvalidArgumentException $e) { + $this->assertTrue(true, '->link() throws an \InvalidArgumentException if the node list is empty'); + } + } + + public function testSelectLinkAndLinkFiltered() + { + $html = << + + +
    +
    + + + + +HTML; + + $crawler = new Crawler($html); + $filtered = $crawler->filterXPath("descendant-or-self::*[@id = 'login-form']"); + + $this->assertCount(0, $filtered->selectLink('Login')); + $this->assertCount(1, $filtered->selectButton('Submit')); + + $filtered = $crawler->filterXPath("descendant-or-self::*[@id = 'action']"); + + $this->assertCount(1, $filtered->selectLink('Login')); + $this->assertCount(0, $filtered->selectButton('Submit')); + + $this->assertCount(1, $crawler->selectLink('Login')->selectLink('Login')); + $this->assertCount(1, $crawler->selectButton('Submit')->selectButton('Submit')); + } + + public function testChaining() + { + $crawler = new Crawler('
    '); + + $this->assertEquals('a', $crawler->filterXPath('//div')->filterXPath('div')->filterXPath('div')->attr('name')); + } + + public function testLinks() + { + $crawler = $this->createTestCrawler('http://example.com/bar/')->selectLink('Foo'); + $this->assertInternalType('array', $crawler->links(), '->links() returns an array'); + + $this->assertCount(4, $crawler->links(), '->links() returns an array'); + $links = $crawler->links(); + $this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Link', $links[0], '->links() returns an array of Link instances'); + + $this->assertEquals(array(), $this->createTestCrawler()->filterXPath('//ol')->links(), '->links() returns an empty array if the node selection is empty'); + } + + public function testForm() + { + $testCrawler = $this->createTestCrawler('http://example.com/bar/'); + $crawler = $testCrawler->selectButton('FooValue'); + $crawler2 = $testCrawler->selectButton('FooBarValue'); + $this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Form', $crawler->form(), '->form() returns a Form instance'); + $this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Form', $crawler2->form(), '->form() returns a Form instance'); + + $this->assertEquals($crawler->form()->getFormNode()->getAttribute('id'), $crawler2->form()->getFormNode()->getAttribute('id'), '->form() works on elements with form attribute'); + + $this->assertEquals(array('FooName' => 'FooBar', 'TextName' => 'TextValue', 'FooTextName' => 'FooTextValue'), $crawler->form(array('FooName' => 'FooBar'))->getValues(), '->form() takes an array of values to submit as its first argument'); + $this->assertEquals(array('FooName' => 'FooValue', 'TextName' => 'TextValue', 'FooTextName' => 'FooTextValue'), $crawler->form()->getValues(), '->getValues() returns correct form values'); + $this->assertEquals(array('FooBarName' => 'FooBarValue', 'TextName' => 'TextValue', 'FooTextName' => 'FooTextValue'), $crawler2->form()->getValues(), '->getValues() returns correct form values'); + + try { + $this->createTestCrawler()->filterXPath('//ol')->form(); + $this->fail('->form() throws an \InvalidArgumentException if the node list is empty'); + } catch (\InvalidArgumentException $e) { + $this->assertTrue(true, '->form() throws an \InvalidArgumentException if the node list is empty'); + } + } + + public function testLast() + { + $crawler = $this->createTestCrawler()->filterXPath('//ul[1]/li'); + $this->assertNotSame($crawler, $crawler->last(), '->last() returns a new instance of a crawler'); + $this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Crawler', $crawler, '->last() returns a new instance of a crawler'); + + $this->assertEquals('Three', $crawler->last()->text()); + } + + public function testFirst() + { + $crawler = $this->createTestCrawler()->filterXPath('//li'); + $this->assertNotSame($crawler, $crawler->first(), '->first() returns a new instance of a crawler'); + $this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Crawler', $crawler, '->first() returns a new instance of a crawler'); + + $this->assertEquals('One', $crawler->first()->text()); + } + + public function testSiblings() + { + $crawler = $this->createTestCrawler()->filterXPath('//li')->eq(1); + $this->assertNotSame($crawler, $crawler->siblings(), '->siblings() returns a new instance of a crawler'); + $this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Crawler', $crawler, '->siblings() returns a new instance of a crawler'); + + $nodes = $crawler->siblings(); + $this->assertEquals(2, $nodes->count()); + $this->assertEquals('One', $nodes->eq(0)->text()); + $this->assertEquals('Three', $nodes->eq(1)->text()); + + $nodes = $this->createTestCrawler()->filterXPath('//li')->eq(0)->siblings(); + $this->assertEquals(2, $nodes->count()); + $this->assertEquals('Two', $nodes->eq(0)->text()); + $this->assertEquals('Three', $nodes->eq(1)->text()); + + try { + $this->createTestCrawler()->filterXPath('//ol')->siblings(); + $this->fail('->siblings() throws an \InvalidArgumentException if the node list is empty'); + } catch (\InvalidArgumentException $e) { + $this->assertTrue(true, '->siblings() throws an \InvalidArgumentException if the node list is empty'); + } + } + + public function testNextAll() + { + $crawler = $this->createTestCrawler()->filterXPath('//li')->eq(1); + $this->assertNotSame($crawler, $crawler->nextAll(), '->nextAll() returns a new instance of a crawler'); + $this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Crawler', $crawler, '->nextAll() returns a new instance of a crawler'); + + $nodes = $crawler->nextAll(); + $this->assertEquals(1, $nodes->count()); + $this->assertEquals('Three', $nodes->eq(0)->text()); + + try { + $this->createTestCrawler()->filterXPath('//ol')->nextAll(); + $this->fail('->nextAll() throws an \InvalidArgumentException if the node list is empty'); + } catch (\InvalidArgumentException $e) { + $this->assertTrue(true, '->nextAll() throws an \InvalidArgumentException if the node list is empty'); + } + } + + public function testPreviousAll() + { + $crawler = $this->createTestCrawler()->filterXPath('//li')->eq(2); + $this->assertNotSame($crawler, $crawler->previousAll(), '->previousAll() returns a new instance of a crawler'); + $this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Crawler', $crawler, '->previousAll() returns a new instance of a crawler'); + + $nodes = $crawler->previousAll(); + $this->assertEquals(2, $nodes->count()); + $this->assertEquals('Two', $nodes->eq(0)->text()); + + try { + $this->createTestCrawler()->filterXPath('//ol')->previousAll(); + $this->fail('->previousAll() throws an \InvalidArgumentException if the node list is empty'); + } catch (\InvalidArgumentException $e) { + $this->assertTrue(true, '->previousAll() throws an \InvalidArgumentException if the node list is empty'); + } + } + + public function testChildren() + { + $crawler = $this->createTestCrawler()->filterXPath('//ul'); + $this->assertNotSame($crawler, $crawler->children(), '->children() returns a new instance of a crawler'); + $this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Crawler', $crawler, '->children() returns a new instance of a crawler'); + + $nodes = $crawler->children(); + $this->assertEquals(3, $nodes->count()); + $this->assertEquals('One', $nodes->eq(0)->text()); + $this->assertEquals('Two', $nodes->eq(1)->text()); + $this->assertEquals('Three', $nodes->eq(2)->text()); + + try { + $this->createTestCrawler()->filterXPath('//ol')->children(); + $this->fail('->children() throws an \InvalidArgumentException if the node list is empty'); + } catch (\InvalidArgumentException $e) { + $this->assertTrue(true, '->children() throws an \InvalidArgumentException if the node list is empty'); + } + + try { + $crawler = new Crawler('

    '); + $crawler->filter('p')->children(); + $this->assertTrue(true, '->children() does not trigger a notice if the node has no children'); + } catch (\PHPUnit_Framework_Error_Notice $e) { + $this->fail('->children() does not trigger a notice if the node has no children'); + } + } + + public function testParents() + { + $crawler = $this->createTestCrawler()->filterXPath('//li[1]'); + $this->assertNotSame($crawler, $crawler->parents(), '->parents() returns a new instance of a crawler'); + $this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Crawler', $crawler, '->parents() returns a new instance of a crawler'); + + $nodes = $crawler->parents(); + $this->assertEquals(3, $nodes->count()); + + $nodes = $this->createTestCrawler()->filterXPath('//html')->parents(); + $this->assertEquals(0, $nodes->count()); + + try { + $this->createTestCrawler()->filterXPath('//ol')->parents(); + $this->fail('->parents() throws an \InvalidArgumentException if the node list is empty'); + } catch (\InvalidArgumentException $e) { + $this->assertTrue(true, '->parents() throws an \InvalidArgumentException if the node list is empty'); + } + } + + public function testBaseTag() + { + $crawler = new Crawler(''); + $this->assertEquals('http://base.com/link', $crawler->filterXPath('//a')->link()->getUri()); + + $crawler = new Crawler('', 'https://domain.com'); + $this->assertEquals('https://base.com/link', $crawler->filterXPath('//a')->link()->getUri(), ' tag can use a schema-less URL'); + + $crawler = new Crawler('', 'https://domain.com'); + $this->assertEquals('https://domain.com/path/link', $crawler->filterXPath('//a')->link()->getUri(), ' tag can set a path'); + } + + public function createTestCrawler($uri = null) + { + $dom = new \DOMDocument(); + $dom->loadHTML(' + + + Foo + Fabien\'s Foo + Fabien"s Foo + \' Fabien"s Foo + + Bar +    Fabien\'s Bar   + Fabien"s Bar + \' Fabien"s Bar + + GetLink + +
    + + + + ', + array('bar' => array('InputFormField', 'bar')), + ), + array( + 'appends the submitted button value but not other submit buttons', + ' + ', + array('foobar' => array('InputFormField', 'foobar')), + ), + array( + 'turns an image input into x and y fields', + '', + array('bar.x' => array('InputFormField', '0'), 'bar.y' => array('InputFormField', '0')), + ), + array( + 'returns textareas', + ' + ', + array('foo' => array('TextareaFormField', 'foo')), + ), + array( + 'returns inputs', + ' + ', + array('foo' => array('InputFormField', 'foo')), + ), + array( + 'returns checkboxes', + ' + ', + array('foo' => array('ChoiceFormField', 'foo')), + ), + array( + 'returns not-checked checkboxes', + ' + ', + array('foo' => array('ChoiceFormField', false)), + ), + array( + 'returns radio buttons', + ' + + ', + array('foo' => array('ChoiceFormField', 'bar')), + ), + array( + 'returns file inputs', + ' + ', + array('foo' => array('FileFormField', array('name' => '', 'type' => '', 'tmp_name' => '', 'error' => 4, 'size' => 0))), + ), + ); + } + + public function testGetFormNode() + { + $dom = new \DOMDocument(); + $dom->loadHTML('
    '); + + $form = new Form($dom->getElementsByTagName('input')->item(0), 'http://example.com'); + + $this->assertSame($dom->getElementsByTagName('form')->item(0), $form->getFormNode(), '->getFormNode() returns the form node associated with this form'); + } + + public function testGetFormNodeFromNamedForm() + { + $dom = new \DOMDocument(); + $dom->loadHTML('
    '); + + $form = new Form($dom->getElementsByTagName('form')->item(0), 'http://example.com'); + + $this->assertSame($dom->getElementsByTagName('form')->item(0), $form->getFormNode(), '->getFormNode() returns the form node associated with this form'); + } + + public function testGetMethod() + { + $form = $this->createForm('
    '); + $this->assertEquals('GET', $form->getMethod(), '->getMethod() returns get if no method is defined'); + + $form = $this->createForm('
    '); + $this->assertEquals('POST', $form->getMethod(), '->getMethod() returns the method attribute value of the form'); + + $form = $this->createForm('
    ', 'put'); + $this->assertEquals('PUT', $form->getMethod(), '->getMethod() returns the method defined in the constructor if provided'); + + $form = $this->createForm('
    ', 'delete'); + $this->assertEquals('DELETE', $form->getMethod(), '->getMethod() returns the method defined in the constructor if provided'); + + $form = $this->createForm('
    ', 'patch'); + $this->assertEquals('PATCH', $form->getMethod(), '->getMethod() returns the method defined in the constructor if provided'); + } + + public function testGetSetValue() + { + $form = $this->createForm('
    '); + + $this->assertEquals('foo', $form['foo']->getValue(), '->offsetGet() returns the value of a form field'); + + $form['foo'] = 'bar'; + + $this->assertEquals('bar', $form['foo']->getValue(), '->offsetSet() changes the value of a form field'); + + try { + $form['foobar'] = 'bar'; + $this->fail('->offsetSet() throws an \InvalidArgumentException exception if the field does not exist'); + } catch (\InvalidArgumentException $e) { + $this->assertTrue(true, '->offsetSet() throws an \InvalidArgumentException exception if the field does not exist'); + } + + try { + $form['foobar']; + $this->fail('->offsetSet() throws an \InvalidArgumentException exception if the field does not exist'); + } catch (\InvalidArgumentException $e) { + $this->assertTrue(true, '->offsetSet() throws an \InvalidArgumentException exception if the field does not exist'); + } + } + + public function testSetValueOnMultiValuedFieldsWithMalformedName() + { + $form = $this->createForm('
    '); + + try { + $form['foo[bar'] = 'bar'; + $this->fail('->offsetSet() throws an \InvalidArgumentException exception if the name is malformed.'); + } catch (\InvalidArgumentException $e) { + $this->assertTrue(true, '->offsetSet() throws an \InvalidArgumentException exception if the name is malformed.'); + } + } + + public function testDisableValidation() + { + $form = $this->createForm('
    + + + + '); + + $form->disableValidation(); + + $form['foo[bar]']->select('foo'); + $form['foo[baz]']->select('bar'); + $this->assertEquals('foo', $form['foo[bar]']->getValue(), '->disableValidation() disables validation of all ChoiceFormField.'); + $this->assertEquals('bar', $form['foo[baz]']->getValue(), '->disableValidation() disables validation of all ChoiceFormField.'); + } + + public function testOffsetUnset() + { + $form = $this->createForm('
    '); + unset($form['foo']); + $this->assertFalse(isset($form['foo']), '->offsetUnset() removes a field'); + } + + public function testOffsetExists() + { + $form = $this->createForm('
    '); + + $this->assertTrue(isset($form['foo']), '->offsetExists() return true if the field exists'); + $this->assertFalse(isset($form['bar']), '->offsetExists() return false if the field does not exist'); + } + + public function testGetValues() + { + $form = $this->createForm('
    '); + $this->assertEquals(array('foo[bar]' => 'foo', 'bar' => 'bar'), $form->getValues(), '->getValues() returns all form field values'); + + $form = $this->createForm('
    '); + $this->assertEquals(array('bar' => 'bar'), $form->getValues(), '->getValues() does not include not-checked checkboxes'); + + $form = $this->createForm('
    '); + $this->assertEquals(array('bar' => 'bar'), $form->getValues(), '->getValues() does not include file input fields'); + + $form = $this->createForm('
    '); + $this->assertEquals(array('bar' => 'bar'), $form->getValues(), '->getValues() does not include disabled fields'); + } + + public function testSetValues() + { + $form = $this->createForm('
    '); + $form->setValues(array('foo' => false, 'bar' => 'foo')); + $this->assertEquals(array('bar' => 'foo'), $form->getValues(), '->setValues() sets the values of fields'); + } + + public function testMultiselectSetValues() + { + $form = $this->createForm('
    '); + $form->setValues(array('multi' => array("foo", "bar"))); + $this->assertEquals(array('multi' => array('foo', 'bar')), $form->getValues(), '->setValue() sets the values of select'); + } + + public function testGetPhpValues() + { + $form = $this->createForm('
    '); + $this->assertEquals(array('foo' => array('bar' => 'foo'), 'bar' => 'bar'), $form->getPhpValues(), '->getPhpValues() converts keys with [] to arrays'); + + $form = $this->createForm('
    '); + $this->assertEquals(array('fo.o' => array('ba.r' => 'foo'), 'ba r' => 'bar'), $form->getPhpValues(), '->getPhpValues() preserves periods and spaces in names'); + + $form = $this->createForm('
    '); + $this->assertEquals(array('fo.o' => array('ba.r' => array('foo', 'ba.z' => 'bar'))), $form->getPhpValues(), '->getPhpValues() preserves periods and spaces in names recursively'); + } + + public function testGetFiles() + { + $form = $this->createForm('
    '); + $this->assertEquals(array(), $form->getFiles(), '->getFiles() returns an empty array if method is get'); + + $form = $this->createForm('
    '); + $this->assertEquals(array('foo[bar]' => array('name' => '', 'type' => '', 'tmp_name' => '', 'error' => 4, 'size' => 0)), $form->getFiles(), '->getFiles() only returns file fields for POST'); + + $form = $this->createForm('
    ', 'put'); + $this->assertEquals(array('foo[bar]' => array('name' => '', 'type' => '', 'tmp_name' => '', 'error' => 4, 'size' => 0)), $form->getFiles(), '->getFiles() only returns file fields for PUT'); + + $form = $this->createForm('
    ', 'delete'); + $this->assertEquals(array('foo[bar]' => array('name' => '', 'type' => '', 'tmp_name' => '', 'error' => 4, 'size' => 0)), $form->getFiles(), '->getFiles() only returns file fields for DELETE'); + + $form = $this->createForm('
    ', 'patch'); + $this->assertEquals(array('foo[bar]' => array('name' => '', 'type' => '', 'tmp_name' => '', 'error' => 4, 'size' => 0)), $form->getFiles(), '->getFiles() only returns file fields for PATCH'); + + $form = $this->createForm('
    '); + $this->assertEquals(array(), $form->getFiles(), '->getFiles() does not include disabled file fields'); + } + + public function testGetPhpFiles() + { + $form = $this->createForm('
    '); + $this->assertEquals(array('foo' => array('bar' => array('name' => '', 'type' => '', 'tmp_name' => '', 'error' => 4, 'size' => 0))), $form->getPhpFiles(), '->getPhpFiles() converts keys with [] to arrays'); + + $form = $this->createForm('
    '); + $this->assertEquals(array('f.o o' => array('bar' => array('name' => '', 'type' => '', 'tmp_name' => '', 'error' => 4, 'size' => 0))), $form->getPhpFiles(), '->getPhpFiles() preserves periods and spaces in names'); + + $form = $this->createForm('
    '); + $this->assertEquals(array('f.o o' => array('bar' => array('ba.z' => array('name' => '', 'type' => '', 'tmp_name' => '', 'error' => 4, 'size' => 0), array('name' => '', 'type' => '', 'tmp_name' => '', 'error' => 4, 'size' => 0)))), $form->getPhpFiles(), '->getPhpFiles() preserves periods and spaces in names recursively'); + } + + /** + * @dataProvider provideGetUriValues + */ + public function testGetUri($message, $form, $values, $uri, $method = null) + { + $form = $this->createForm($form, $method); + $form->setValues($values); + + $this->assertEquals('http://example.com'.$uri, $form->getUri(), '->getUri() '.$message); + } + + public function testGetBaseUri() + { + $dom = new \DOMDocument(); + $dom->loadHTML('
    '); + + $nodes = $dom->getElementsByTagName('input'); + $form = new Form($nodes->item($nodes->length - 1), 'http://www.foo.com/'); + $this->assertEquals('http://www.foo.com/foo.php', $form->getUri()); + } + + public function testGetUriWithAnchor() + { + $form = $this->createForm('
    ', null, 'http://example.com/id/123'); + + $this->assertEquals('http://example.com/id/123#foo', $form->getUri()); + } + + public function testGetUriActionAbsolute() + { + $formHtml='
    '; + + $form = $this->createForm($formHtml); + $this->assertEquals('https://login.foo.com/login.php?login_attempt=1', $form->getUri(), '->getUri() returns absolute URIs set in the action form'); + + $form = $this->createForm($formHtml, null, 'https://login.foo.com'); + $this->assertEquals('https://login.foo.com/login.php?login_attempt=1', $form->getUri(), '->getUri() returns absolute URIs set in the action form'); + + $form = $this->createForm($formHtml, null, 'https://login.foo.com/bar/'); + $this->assertEquals('https://login.foo.com/login.php?login_attempt=1', $form->getUri(), '->getUri() returns absolute URIs set in the action form'); + + // The action URI haven't the same domain Host have an another domain as Host + $form = $this->createForm($formHtml, null, 'https://www.foo.com'); + $this->assertEquals('https://login.foo.com/login.php?login_attempt=1', $form->getUri(), '->getUri() returns absolute URIs set in the action form'); + + $form = $this->createForm($formHtml, null, 'https://www.foo.com/bar/'); + $this->assertEquals('https://login.foo.com/login.php?login_attempt=1', $form->getUri(), '->getUri() returns absolute URIs set in the action form'); + } + + public function testGetUriAbsolute() + { + $form = $this->createForm('
    ', null, 'http://localhost/foo/'); + $this->assertEquals('http://localhost/foo/foo', $form->getUri(), '->getUri() returns absolute URIs'); + + $form = $this->createForm('
    ', null, 'http://localhost/foo/'); + $this->assertEquals('http://localhost/foo', $form->getUri(), '->getUri() returns absolute URIs'); + } + + public function testGetUriWithOnlyQueryString() + { + $form = $this->createForm('
    ', null, 'http://localhost/foo/bar'); + $this->assertEquals('http://localhost/foo/bar?get=param', $form->getUri(), '->getUri() returns absolute URIs only if the host has been defined in the constructor'); + } + + public function testGetUriWithoutAction() + { + $form = $this->createForm('
    ', null, 'http://localhost/foo/bar'); + $this->assertEquals('http://localhost/foo/bar', $form->getUri(), '->getUri() returns path if no action defined'); + } + + public function provideGetUriValues() + { + return array( + array( + 'returns the URI of the form', + '
    ', + array(), + '/foo' + ), + array( + 'appends the form values if the method is get', + '
    ', + array(), + '/foo?foo=foo' + ), + array( + 'appends the form values and merges the submitted values', + '
    ', + array('foo' => 'bar'), + '/foo?foo=bar' + ), + array( + 'does not append values if the method is post', + '
    ', + array(), + '/foo' + ), + array( + 'does not append values if the method is patch', + '
    ', + array(), + '/foo', + 'PUT' + ), + array( + 'does not append values if the method is delete', + '
    ', + array(), + '/foo', + 'DELETE' + ), + array( + 'does not append values if the method is put', + '
    ', + array(), + '/foo', + 'PATCH' + ), + array( + 'appends the form values to an existing query string', + '
    ', + array(), + '/foo?bar=bar&foo=foo' + ), + array( + 'returns an empty URI if the action is empty', + '
    ', + array(), + '/', + ), + array( + 'appends the form values even if the action is empty', + '
    ', + array(), + '/?foo=foo', + ), + array( + 'chooses the path if the action attribute value is a sharp (#)', + '
    ', + array(), + '/#', + ), + ); + } + + public function testHas() + { + $form = $this->createForm('
    '); + + $this->assertFalse($form->has('foo'), '->has() returns false if a field is not in the form'); + $this->assertTrue($form->has('bar'), '->has() returns true if a field is in the form'); + } + + public function testRemove() + { + $form = $this->createForm('
    '); + $form->remove('bar'); + $this->assertFalse($form->has('bar'), '->remove() removes a field'); + } + + public function testGet() + { + $form = $this->createForm('
    '); + + $this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Field\\InputFormField', $form->get('bar'), '->get() returns the field object associated with the given name'); + + try { + $form->get('foo'); + $this->fail('->get() throws an \InvalidArgumentException if the field does not exist'); + } catch (\InvalidArgumentException $e) { + $this->assertTrue(true, '->get() throws an \InvalidArgumentException if the field does not exist'); + } + } + + public function testAll() + { + $form = $this->createForm('
    '); + + $fields = $form->all(); + $this->assertCount(1, $fields, '->all() return an array of form field objects'); + $this->assertInstanceOf('Symfony\\Component\\DomCrawler\\Field\\InputFormField', $fields['bar'], '->all() return an array of form field objects'); + } + + public function testSubmitWithoutAFormButton() + { + $dom = new \DOMDocument(); + $dom->loadHTML(' + +
    + + + + '); + + $nodes = $dom->getElementsByTagName('form'); + $form = new Form($nodes->item(0), 'http://example.com'); + $this->assertSame($nodes->item(0), $form->getFormNode(), '->getFormNode() returns the form node associated with this form'); + } + + public function testTypeAttributeIsCaseInsensitive() + { + $form = $this->createForm('
    '); + $this->assertTrue($form->has('example.x'), '->has() returns true if the image input was correctly turned into an x and a y fields'); + $this->assertTrue($form->has('example.y'), '->has() returns true if the image input was correctly turned into an x and a y fields'); + } + + /** + * @expectedException \InvalidArgumentException + */ + public function testFormFieldRegistryAddThrowAnExceptionWhenTheNameIsMalformed() + { + $registry = new FormFieldRegistry(); + $registry->add($this->getFormFieldMock('[foo]')); + } + + /** + * @expectedException \InvalidArgumentException + */ + public function testFormFieldRegistryRemoveThrowAnExceptionWhenTheNameIsMalformed() + { + $registry = new FormFieldRegistry(); + $registry->remove('[foo]'); + } + + /** + * @expectedException \InvalidArgumentException + */ + public function testFormFieldRegistryGetThrowAnExceptionWhenTheNameIsMalformed() + { + $registry = new FormFieldRegistry(); + $registry->get('[foo]'); + } + + /** + * @expectedException \InvalidArgumentException + */ + public function testFormFieldRegistryGetThrowAnExceptionWhenTheFieldDoesNotExist() + { + $registry = new FormFieldRegistry(); + $registry->get('foo'); + } + + /** + * @expectedException \InvalidArgumentException + */ + public function testFormFieldRegistrySetThrowAnExceptionWhenTheNameIsMalformed() + { + $registry = new FormFieldRegistry(); + $registry->set('[foo]', null); + } + + /** + * @expectedException \InvalidArgumentException + */ + public function testFormFieldRegistrySetThrowAnExceptionWhenTheFieldDoesNotExist() + { + $registry = new FormFieldRegistry(); + $registry->set('foo', null); + } + + public function testFormFieldRegistryHasReturnsTrueWhenTheFQNExists() + { + $registry = new FormFieldRegistry(); + $registry->add($this->getFormFieldMock('foo[bar]')); + + $this->assertTrue($registry->has('foo')); + $this->assertTrue($registry->has('foo[bar]')); + $this->assertFalse($registry->has('bar')); + $this->assertFalse($registry->has('foo[foo]')); + } + + public function testFormRegistryFieldsCanBeRemoved() + { + $registry = new FormFieldRegistry(); + $registry->add($this->getFormFieldMock('foo')); + $registry->remove('foo'); + $this->assertFalse($registry->has('foo')); + } + + public function testFormRegistrySupportsMultivaluedFields() + { + $registry = new FormFieldRegistry(); + $registry->add($this->getFormFieldMock('foo[]')); + $registry->add($this->getFormFieldMock('foo[]')); + $registry->add($this->getFormFieldMock('bar[5]')); + $registry->add($this->getFormFieldMock('bar[]')); + $registry->add($this->getFormFieldMock('bar[baz]')); + + $this->assertEquals( + array('foo[0]', 'foo[1]', 'bar[5]', 'bar[6]', 'bar[baz]'), + array_keys($registry->all()) + ); + } + + public function testFormRegistrySetValues() + { + $registry = new FormFieldRegistry(); + $registry->add($f2 = $this->getFormFieldMock('foo[2]')); + $registry->add($f3 = $this->getFormFieldMock('foo[3]')); + $registry->add($fbb = $this->getFormFieldMock('foo[bar][baz]')); + + $f2 + ->expects($this->exactly(2)) + ->method('setValue') + ->with(2) + ; + + $f3 + ->expects($this->exactly(2)) + ->method('setValue') + ->with(3) + ; + + $fbb + ->expects($this->exactly(2)) + ->method('setValue') + ->with('fbb') + ; + + $registry->set('foo[2]', 2); + $registry->set('foo[3]', 3); + $registry->set('foo[bar][baz]', 'fbb'); + + $registry->set('foo', array( + 2 => 2, + 3 => 3, + 'bar' => array( + 'baz' => 'fbb' + ) + )); + } + + protected function getFormFieldMock($name, $value = null) + { + $field = $this + ->getMockBuilder('Symfony\\Component\\DomCrawler\\Field\\FormField') + ->setMethods(array('getName', 'getValue', 'setValue', 'initialize')) + ->disableOriginalConstructor() + ->getMock() + ; + + $field + ->expects($this->any()) + ->method('getName') + ->will($this->returnValue($name)) + ; + + $field + ->expects($this->any()) + ->method('getValue') + ->will($this->returnValue($value)) + ; + + return $field; + } + + protected function createForm($form, $method = null, $currentUri = null) + { + $dom = new \DOMDocument(); + $dom->loadHTML(''.$form.''); + + $xPath = new \DOMXPath($dom); + $nodes = $xPath->query('//input | //button'); + + if (null === $currentUri) { + $currentUri = 'http://example.com/'; + } + + return new Form($nodes->item($nodes->length - 1), $currentUri, $method); + } + + protected function createTestHtml5Form() + { + $dom = new \DOMDocument(); + $dom->loadHTML(' + +

    Hello form

    +
    +
    + +
    + + + + +
    +
    +
    + + + +
    + +
    + +
    +
    +
    + + +
    + + + +
    +
    +
    + + + + +